blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
1f906bf9174843133caf8e2df6e8135dc8d08ed4
39e03684081b27311385a0ab31afcc2e09883e5c
/mmdet/ops/grid_sampler/src/cudnn/grid_sampler_cudnn.cpp
061d3e259a70d42285783bf7594a8597be50efd9
[ "MIT", "Python-2.0" ]
permissive
witnessai/MMSceneGraph
8d0b2011a946ddcced95fbe15445b7f4da818509
bc5e0f3385205404c712ae9f702a61a3191da0a1
refs/heads/master
2023-08-12T06:54:00.551237
2021-10-12T03:04:21
2021-10-12T03:04:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,633
cpp
#include <ATen/ATen.h> #include <ATen/NativeFunctions.h> #include <ATen/Config.h> #include <ATen/cuda/CUDAConfig.h> #if !AT_CUDNN_ENABLED() namespace at { namespace native { // See Note [ATen preprocessor philosophy] Tensor cudnn_grid_sampler_forward( const Tensor& input_t, const Tensor& grid_t) { AT_ERROR("cudnn_grid_sampler_forward: ATen not compiled with cuDNN support"); } std::tuple<Tensor, Tensor> cudnn_grid_sampler_backward( const Tensor& input_t, const Tensor& grid_t, const Tensor& grad_output_t) { AT_ERROR("cudnn_grid_sampler_backward: ATen not compiled with cuDNN support"); } }} #else // AT_CUDNN_ENABLED #include <ATen/cudnn/Descriptors.h> #include <ATen/cudnn/Types.h> #include <ATen/cudnn/Utils.h> #include <ATen/cuda/Exceptions.h> #include <ATen/TensorUtils.h> // TODO: descriptor checking namespace mmdetection { using namespace at; namespace { void setSamplerDescriptor(SpatialTransformerDescriptor& desc, cudnnDataType_t dataType, const at::Tensor& tensor) { int inputSize[4] = {0}; for (int i = 0; i < tensor.dim(); ++i) { inputSize[i] = (int) tensor.size(i); } desc.set(dataType, 4, inputSize); } void checkGridSize(CheckedFrom c, TensorArg grid, TensorArg input) { // assert size of grid is n*h*w*2 // FYI: grid is between [-1, 1], where -1 left most pixel, // 1 represents right most pixel (and hence 0 is the center pixel) // if grid has values >1 or <-1, those values are ignored checkContiguous(c, grid); checkDim(c, grid, 4); // TODO: Maybe more user friendly to report where the expected size // came from checkSize(c, grid, 0, input->size(0)); checkSize(c, grid, 3, 2); } } // namespace Tensor cudnn_grid_sampler_forward( const Tensor& input_t, const Tensor& grid_t) { TensorArg input{ contiguousIfZeroInStrides(input_t), "input", 1 }, grid{ grid_t.contiguous(), "grid", 2 }; CheckedFrom c = "cudnn_grid_sampler_forward"; checkAllSameGPU(c, {input, grid}); checkAllSameType(c, {input, grid}); checkGridSize(c, grid, input); checkDim(c, input, 4); auto output_t = at::empty({0}, input->options()); output_t.resize_({input->size(0), input->size(1), grid->size(1), grid->size(2)}); TensorDescriptor idesc{ *input }; // input descriptor TensorDescriptor odesc{ output_t }; // output descriptor SpatialTransformerDescriptor desc; // sampler descriptor auto handle = getCudnnHandle(); auto dataType = getCudnnDataType(*input); setSamplerDescriptor(desc, dataType, output_t); Constant one(dataType, 1); Constant zero(dataType, 0); AT_CUDNN_CHECK(cudnnSpatialTfSamplerForward( handle, desc.desc(), &one, idesc.desc(), input->data_ptr(), grid->data_ptr(), &zero, odesc.desc(), output_t.data_ptr() )); return output_t; } // NB: CuDNN does not support output mask; you always get both // gradients. std::tuple<Tensor, Tensor> cudnn_grid_sampler_backward( const Tensor& input_t, const Tensor& grid_t, const Tensor& grad_output_t) { TensorArg input{ contiguousIfZeroInStrides(input_t), "input", 1 }, grid{ grid_t.contiguous(), "grid", 2 }, grad_output{ contiguousIfZeroInStrides(grad_output_t), "grad_output", 3 }; CheckedFrom c = "cudnn_grid_sampler_backward"; checkAllSameGPU(c, {input, grad_output, grid}); checkGridSize(c, grid, input); checkDim(c, input, 4); checkDim(c, grad_output, 4); auto grad_input_t = at::empty({0}, input->options()); grad_input_t.resize_(input->sizes()); auto grad_grid_t = at::empty({0}, grid->options()); grad_grid_t.resize_(grid->sizes()); TensorDescriptor idesc{ *input }; // input descriptor TensorDescriptor odesc{ *grad_output }; // grad_output descriptor TensorDescriptor gdesc{ grad_input_t }; // grad_input descriptor SpatialTransformerDescriptor desc; // sampler descriptor auto handle = getCudnnHandle(); auto dataType = getCudnnDataType(*input); setSamplerDescriptor(desc, dataType, *grad_output); Constant one(dataType, 1); Constant zero(dataType, 0); AT_CUDNN_CHECK(cudnnSpatialTfSamplerBackward( handle, desc.desc(), &one, idesc.desc(), input->data_ptr(), &zero, gdesc.desc(), grad_input_t.data_ptr(), &one, odesc.desc(), grad_output->data_ptr(), // intruigingly, the outputs don't need descriptors grid->data_ptr(), &zero, grad_grid_t.data_ptr() )); return std::tuple<Tensor, Tensor>{ grad_input_t, grad_grid_t }; } } // namespace mmdetection #endif
[ "23736866+Kenneth-Wong@users.noreply.github.com" ]
23736866+Kenneth-Wong@users.noreply.github.com
050cd081164b856380931ac369fe358988f26ddd
8be7a7efbaa6a4034e435bc8221cc5fb54f8067c
/GraphicsScenePlot/tests/GraphicsPlotLegend/tst_GraphicsPlotLegendTest.cpp
88dc8247034af9595fa304a9acc9fe46bc47ac4f
[]
no_license
RinatB2017/Qt_github
9faaa54e3c8e7a5f84f742d49f4559dcdd5622dd
5177baa735c0140d39d8b0e84fc6af3dcb581abd
refs/heads/master
2023-08-08T08:36:17.664868
2023-07-28T07:39:35
2023-07-28T07:39:35
163,097,727
2
1
null
null
null
null
UTF-8
C++
false
false
950
cpp
#include <QString> #include <QtTest> #include <QGraphicsView> #include <QGraphicsScene> #include <GraphicsPlotLegend.h> class GraphicsPlotLegendTest : public QObject { Q_OBJECT public: GraphicsPlotLegendTest(); private Q_SLOTS: void baseTest(); }; GraphicsPlotLegendTest::GraphicsPlotLegendTest() { } void GraphicsPlotLegendTest::baseTest() { QGraphicsView view; view.setMinimumSize(300, 300); QGraphicsScene * scene = new QGraphicsScene(); view.setScene(scene); GraphicsPlotLegend * legend = new GraphicsPlotLegend(); scene->addItem(legend); legend->setRect(QRectF(0, 0, 250, 250)); Graphics2DGraphItem dataItem; dataItem.setTitle(QString("Test title")); dataItem.setPen(QColor(Qt::blue)); legend->addDataItem(&dataItem); view.show(); dataItem.setPen(QColor(Qt::red)); qApp->exec(); } QTEST_MAIN(GraphicsPlotLegendTest) #include "tst_GraphicsPlotLegendTest.moc"
[ "tux4096@gmail.com" ]
tux4096@gmail.com
55310dcf47261aa914e8de61d27213cea217aa98
c80f25d24cee6ed8dba1513c227886c07d83cf75
/WeaponGirl_1/Client/trunk/Classes/Mgr/SignMgr.h
1553c7236db6d6ac432baa205926d444710dffe9
[ "MIT" ]
permissive
cnsuhao/newProBase
c250e54ead43efb57363347d1700649a35617d15
4fe81d30740a2a0857ca6e09a281fed1146e6202
refs/heads/master
2021-08-23T14:19:24.568828
2015-11-27T13:37:54
2015-11-27T13:37:54
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
796
h
//////////////////////////////////////////////////////////////////////// // Copyright(c) 2015-9999, WuHan GoodGame, All Rights Reserved // Moudle: SignMgr.h // Author: ³Â½¨¾ü(Chen Jianjun) // Created: 2015-10-31 //////////////////////////////////////////////////////////////////////// #ifndef _JYP_SIGN_MGR_H_ #define _JYP_SIGN_MGR_H_ #include "Global/Global.h" class SignMgr : public Ref { public: static SignMgr* getInstance(); static void destroyInstance(); private: SignMgr(); static SignMgr* m_pInstance; public: bool getSignAwardInfo(std::vector<ST_SIGN_AWARD_INFO>& vecInfo); void addSignAwardInfo(ST_SIGN_AWARD_INFO& info); void signSuc(); protected: std::vector<ST_SIGN_AWARD_INFO> m_vecSignAwardInfo; }; #endif // end of _JYP_SIGN_MGR_H_
[ "c913421043@dbc7df3a-5862-4ee2-b0ae-4c0d245d469e" ]
c913421043@dbc7df3a-5862-4ee2-b0ae-4c0d245d469e
dcb552f6bf4db875e0538e86f88f25357a5e2e1d
0530042cc639dec1a0e9c6eba14d5b7ab523336e
/Box2DProjects/HelloPhysics20192/HelloPhysics/HelloPhysics/SceneManager.h
eee69cf645e3d1c3c6ecce356de3329e60045c75
[]
no_license
UtopiaGS/UnisinosProjects
1475a1ea7f21322ad39abaa1b4204b7aa1d33e34
76c2a0f66c0c3d16d83177d95364fa84e84914e8
refs/heads/master
2023-05-05T22:32:21.714458
2021-05-25T21:59:10
2021-05-25T21:59:10
206,886,360
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,051
h
#pragma once #include "Shader.h" #include "GameObject.h" // GLM #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/type_ptr.hpp> #include <vector> #include "PhysicsManager.h" using namespace std; class SceneManager { public: SceneManager(); ~SceneManager(); void initialize(GLuint width, GLuint height); void initializeGraphics(); void addShader(string vFilename, string fFilename); //GLFW callbacks static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode); static void resize(GLFWwindow* window, int width, int height); void update(); void render(); void run(); void finish(); // scene void setupScene(); void setupCamera2D(); private: //GFLW window GLFWwindow *window; //our shader program Shader *shader; //2D Camera - Projection matrix glm::mat4 projection; //Scene object(s) GameObject *gameObj; //A ideia é poder ter mais de um GameObject vector <GameObject *> objs; //Gerenciador da simulação física PhysicsManager *physics; };
[ "ocruznathalia@gmail.com" ]
ocruznathalia@gmail.com
0a817588f9a1c358bb6bb815fb48d0cc910ee4d2
cd484c21d9d412d81ee3039072365fbb32947fce
/WBoard/Source/desktop/WBDesktopAnnotationController.cpp
cee04f2f4b52c95666133f77f1ad418682a45497
[]
no_license
drivestudy/WBoard
8c97fc4f01f58540718cd2c082562f9eab5761de
18959203a234944fb402b444462db76c6dd5b3c6
refs/heads/main
2023-08-01T01:41:04.303780
2021-09-09T04:56:46
2021-09-09T04:56:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
32,380
cpp
#include <QDesktopWidget> #include "WBDesktopAnnotationController.h" #include "frameworks/WBPlatformUtils.h" #include "core/WBApplication.h" #include "core/WBApplicationController.h" #include "core/WBDisplayManager.h" #include "core/WBSettings.h" #include "web/WBWebController.h" #include "gui/WBMainWindow.h" #include "board/WBBoardView.h" #include "board/WBDrawingController.h" #include "board/WBBoardController.h" #include "board/WBBoardPaletteManager.h" #include "domain/WBGraphicsScene.h" #include "domain/WBGraphicsPolygonItem.h" #include "WBCustomCaptureWindow.h" #include "WBWindowCapture.h" #include "WBDesktopPalette.h" #include "WBDesktopPropertyPalette.h" #include "gui/WBKeyboardPalette.h" #include "gui/WBResources.h" #include "core/memcheck.h" WBDesktopAnnotationController::WBDesktopAnnotationController(QObject *parent, WBRightPalette* rightPalette) : QObject(parent) , mTransparentDrawingView(0) , mTransparentDrawingScene(0) , mDesktopPalette(NULL) , mDesktopPenPalette(NULL) , mDesktopMarkerPalette(NULL) , mDesktopEraserPalette(NULL) , mRightPalette(rightPalette) , mWindowPositionInitialized(false) , mIsFullyTransparent(false) , mDesktopToolsPalettePositioned(false) , mPendingPenButtonPressed(false) , mPendingMarkerButtonPressed(false) , mPendingEraserButtonPressed(false) , mbArrowClicked(false) , mBoardStylusTool(WBDrawingController::drawingController()->stylusTool()) , mDesktopStylusTool(WBDrawingController::drawingController()->stylusTool()) { mTransparentDrawingView = new WBBoardView(WBApplication::boardController, static_cast<QWidget*>(0), false, true); // deleted in WBDesktopAnnotationController::destructor mTransparentDrawingView->setAttribute(Qt::WA_TranslucentBackground, true); #ifdef Q_OS_OSX mTransparentDrawingView->setAttribute(Qt::WA_MacNoShadow, true); #endif mTransparentDrawingView->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Window | Qt::NoDropShadowWindowHint); mTransparentDrawingView->setCacheMode(QGraphicsView::CacheNone); mTransparentDrawingView->resize(WBApplication::desktop()->width(), WBApplication::desktop()->height()); mTransparentDrawingView->setMouseTracking(true); mTransparentDrawingView->setAcceptDrops(true); QString backgroundStyle = "QWidget {background-color: rgba(127, 127, 127, 0)}"; mTransparentDrawingView->setStyleSheet(backgroundStyle); mTransparentDrawingScene = new WBGraphicsScene(0, false); updateColors(); mTransparentDrawingView->setScene(mTransparentDrawingScene); mTransparentDrawingScene->setDrawingMode(true); mDesktopPalette = new WBDesktopPalette(mTransparentDrawingView, rightPalette); // This was not fix, parent reverted // FIX #633: The palette must be 'floating' in order to stay on top of the library palette if (WBPlatformUtils::hasVirtualKeyboard()) { connect( WBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); #ifdef Q_OS_LINUX connect(WBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask())); connect(WBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(refreshMask())); connect(mDesktopPalette,SIGNAL(refreshMask()), this, SLOT(refreshMask())); #endif } connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard())); connect(mDesktopPalette, SIGNAL(customClick()), this, SLOT(customCapture())); connect(mDesktopPalette, SIGNAL(windowClick()), this, SLOT(windowCapture())); connect(mDesktopPalette, SIGNAL(screenClick()), this, SLOT(screenCapture())); connect(WBApplication::mainWindow->actionPointer, SIGNAL(triggered()), this, SLOT(onToolClicked())); connect(WBApplication::mainWindow->actionSelector, SIGNAL(triggered()), this, SLOT(onToolClicked())); connect(mDesktopPalette, SIGNAL(maximized()), this, SLOT(onDesktopPaletteMaximized())); connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), this, SLOT(onDesktopPaletteMinimize())); connect(mDesktopPalette, SIGNAL(mouseEntered()), mTransparentDrawingScene, SLOT(hideTool())); connect(mRightPalette, SIGNAL(mouseEntered()), mTransparentDrawingScene, SLOT(hideTool())); connect(mTransparentDrawingView, SIGNAL(resized(QResizeEvent*)), this, SLOT(onTransparentWidgetResized())); connect(WBDrawingController::drawingController(), SIGNAL(stylusToolChanged(int)), this, SLOT(stylusToolChanged(int))); // Add the desktop associated palettes mDesktopPenPalette = new WBDesktopPenPalette(mTransparentDrawingView, rightPalette); connect(mDesktopPalette, SIGNAL(maximized()), mDesktopPenPalette, SLOT(onParentMaximized())); connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), mDesktopPenPalette, SLOT(onParentMinimized())); mDesktopMarkerPalette = new WBDesktopMarkerPalette(mTransparentDrawingView, rightPalette); mDesktopEraserPalette = new WBDesktopEraserPalette(mTransparentDrawingView, rightPalette); mDesktopPalette->setBackgroundBrush(WBSettings::settings()->opaquePaletteColor); mDesktopPenPalette->setBackgroundBrush(WBSettings::settings()->opaquePaletteColor); mDesktopMarkerPalette->setBackgroundBrush(WBSettings::settings()->opaquePaletteColor); mDesktopEraserPalette->setBackgroundBrush(WBSettings::settings()->opaquePaletteColor); // Hack : the size of the property palettes is computed the first time the palette is visible // In order to prevent palette overlap on if the desktop palette is on the right of the // screen, a setVisible(true) followed by a setVisible(false) is done. mDesktopPenPalette->setVisible(true); mDesktopMarkerPalette->setVisible(true); mDesktopEraserPalette->setVisible(true); mDesktopPenPalette->setVisible(false); mDesktopMarkerPalette->setVisible(false); mDesktopEraserPalette->setVisible(false); connect(WBApplication::mainWindow->actionEraseDesktopAnnotations, SIGNAL(triggered()), this, SLOT(eraseDesktopAnnotations())); connect(WBApplication::boardController, SIGNAL(backgroundChanged()), this, SLOT(updateColors())); connect(WBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(updateColors())); connect(&mHoldTimerPen, SIGNAL(timeout()), this, SLOT(penActionReleased())); connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased())); connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased())); #ifdef Q_OS_LINUX connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask())); connect(WBApplication::boardController->paletteManager()->rightPalette(), SIGNAL(resized()), this, SLOT(refreshMask())); connect(WBApplication::boardController->paletteManager()->addItemPalette(), SIGNAL(closed()), this, SLOT(refreshMask())); #endif onDesktopPaletteMaximized(); // FIX #633: Ensure that these palettes stay on top of the other elements //mDesktopEraserPalette->raise(); //mDesktopMarkerPalette->raise(); //mDesktopPenPalette->raise(); } WBDesktopAnnotationController::~WBDesktopAnnotationController() { delete mTransparentDrawingScene; delete mTransparentDrawingView; } void WBDesktopAnnotationController::updateColors(){ if(WBApplication::boardController->activeScene()->isDarkBackground()){ mTransparentDrawingScene->setBackground(true, WBPageBackground::plain); }else{ mTransparentDrawingScene->setBackground(false, WBPageBackground::plain); } } WBDesktopPalette* WBDesktopAnnotationController::desktopPalette() { return mDesktopPalette; } QPainterPath WBDesktopAnnotationController::desktopPalettePath() const { QPainterPath result; if (mDesktopPalette && mDesktopPalette->isVisible()) { result.addRect(mDesktopPalette->geometry()); } if (mDesktopPenPalette && mDesktopPenPalette->isVisible()) { result.addRect(mDesktopPenPalette->geometry()); } if (mDesktopMarkerPalette && mDesktopMarkerPalette->isVisible()) { result.addRect(mDesktopMarkerPalette->geometry()); } if (mDesktopEraserPalette && mDesktopEraserPalette->isVisible()) { result.addRect(mDesktopEraserPalette->geometry()); } return result; } /** * \brief Toggle the visibility of the pen associated palette * @param checked as the visibility state */ void WBDesktopAnnotationController::desktopPenActionToggled(bool checked) { setAssociatedPalettePosition(mDesktopPenPalette, "actionPen"); mDesktopPenPalette->setVisible(checked); mDesktopMarkerPalette->setVisible(false); mDesktopEraserPalette->setVisible(false); } /** * \brief Toggle the visibility of the marker associated palette * @param checked as the visibility state */ void WBDesktopAnnotationController::desktopMarkerActionToggled(bool checked) { setAssociatedPalettePosition(mDesktopMarkerPalette, "actionMarker"); mDesktopMarkerPalette->setVisible(checked); mDesktopPenPalette->setVisible(false); mDesktopEraserPalette->setVisible(false); } /** * \brief Toggle the visibility of the eraser associated palette * @param checked as the visibility state */ void WBDesktopAnnotationController::desktopEraserActionToggled(bool checked) { setAssociatedPalettePosition(mDesktopEraserPalette, "actionEraser"); mDesktopEraserPalette->setVisible(checked); mDesktopPenPalette->setVisible(false); mDesktopMarkerPalette->setVisible(false); } /** * \brief Set the location of the properties palette * @param palette as the palette * @param actionName as the name of the related action */ void WBDesktopAnnotationController::setAssociatedPalettePosition(WBActionPalette *palette, const QString &actionName) { QPoint desktopPalettePos = mDesktopPalette->geometry().topLeft(); QList<QAction*> actions = mDesktopPalette->actions(); int yPen = 0; foreach(QAction* act, actions) { if(act->objectName() == actionName) { int iAction = actions.indexOf(act); yPen = iAction * (mDesktopPalette->buttonSize().height() + 2 * mDesktopPalette->border() +6); // This is the mysterious value (6) break; } } // First determine if the palette must be shown on the left or on the right if(desktopPalettePos.x() <= (mTransparentDrawingView->width() - (palette->width() + mDesktopPalette->width() + mRightPalette->width() + 20))) // we take a small margin of 20 pixels { // Display it on the right desktopPalettePos += QPoint(mDesktopPalette->width(), yPen); } else { // Display it on the left desktopPalettePos += QPoint(0 - palette->width(), yPen); } palette->setCustomPosition(true); palette->move(desktopPalettePos); } void WBDesktopAnnotationController::eraseDesktopAnnotations() { if (mTransparentDrawingScene) { mTransparentDrawingScene->clearContent(WBGraphicsScene::clearAnnotations); } } WBBoardView* WBDesktopAnnotationController::drawingView() { return mTransparentDrawingView; } void WBDesktopAnnotationController::showWindow() { mDesktopPalette->setDisplaySelectButtonVisible(true); connect(WBApplication::applicationController, SIGNAL(desktopMode(bool)) , mDesktopPalette, SLOT(setDisplaySelectButtonVisible(bool))); mDesktopPalette->show(); bool showDisplay = WBSettings::settings()->webShowPageImmediatelyOnMirroredScreen->get().toBool(); mDesktopPalette->showHideClick(showDisplay); mDesktopPalette->updateShowHideState(showDisplay); if (!mWindowPositionInitialized) { QRect desktopRect = QApplication::desktop()->screenGeometry(mDesktopPalette->pos()); mDesktopPalette->move(5, desktopRect.top() + 150); mWindowPositionInitialized = true; mDesktopPalette->maximizeMe(); } updateBackground(); mBoardStylusTool = WBDrawingController::drawingController()->stylusTool(); WBDrawingController::drawingController()->setStylusTool(mDesktopStylusTool); #ifndef Q_OS_LINUX WBPlatformUtils::showFullScreen(mTransparentDrawingView); #else // this is necessary to avoid hiding the panels on Unity and Cinnamon // if finer control is necessary, use qgetenv("XDG_CURRENT_DESKTOP") mTransparentDrawingView->show(); #endif WBPlatformUtils::setDesktopMode(true); mDesktopPalette->appear(); #ifdef Q_OS_LINUX updateMask(true); #endif } void WBDesktopAnnotationController::close() { if (mTransparentDrawingView) mTransparentDrawingView->hide(); mDesktopPalette->hide(); } void WBDesktopAnnotationController::stylusToolChanged(int tool) { Q_UNUSED(tool); updateBackground(); } void WBDesktopAnnotationController::updateBackground() { QBrush newBrush; if (mIsFullyTransparent || WBDrawingController::drawingController()->stylusTool() == WBStylusTool::Selector) { newBrush = QBrush(Qt::transparent); #ifdef Q_OS_LINUX updateMask(true); #endif } else { #if defined(Q_OS_OSX) newBrush = QBrush(QColor(127, 127, 127, 15)); #else newBrush = QBrush(QColor(127, 127, 127, 1)); #endif #ifdef Q_OS_LINUX updateMask(false); #endif } if (mTransparentDrawingScene && mTransparentDrawingScene->backgroundBrush() != newBrush) mTransparentDrawingScene->setBackgroundBrush(newBrush); } void WBDesktopAnnotationController::hideWindow() { if (mTransparentDrawingView) mTransparentDrawingView->hide(); mDesktopPalette->hide(); mDesktopStylusTool = WBDrawingController::drawingController()->stylusTool(); WBDrawingController::drawingController()->setStylusTool(mBoardStylusTool); } void WBDesktopAnnotationController::goToUniboard() { WBApplication::applicationController->showBoard(); } void WBDesktopAnnotationController::customCapture() { onToolClicked(); mIsFullyTransparent = true; updateBackground(); mDesktopPalette->disappearForCapture(); WBCustomCaptureWindow customCaptureWindow(mDesktopPalette); // need to show the window before execute it to avoid some glitch on windows. #ifndef Q_OS_WIN // Working only without this call on win32 desktop mode WBPlatformUtils::showFullScreen(&customCaptureWindow); #endif if (customCaptureWindow.execute(getScreenPixmap()) == QDialog::Accepted) { QPixmap selectedPixmap = customCaptureWindow.getSelectedPixmap(); emit imageCaptured(selectedPixmap, false); } mDesktopPalette->appear(); mIsFullyTransparent = false; updateBackground(); } void WBDesktopAnnotationController::windowCapture() { onToolClicked(); mIsFullyTransparent = true; updateBackground(); mDesktopPalette->disappearForCapture(); WBWindowCapture util(this); if (util.execute() == QDialog::Accepted) { QPixmap windowPixmap = util.getCapturedWindow(); // on Mac OS X we can only know that user cancel the operatiion by checking is the image is null // because the screencapture utility always return code 0 event if user cancel the application if (!windowPixmap.isNull()) { emit imageCaptured(windowPixmap, false); } } mDesktopPalette->appear(); mIsFullyTransparent = false; updateBackground(); } void WBDesktopAnnotationController::screenCapture() { onToolClicked(); mIsFullyTransparent = true; updateBackground(); mDesktopPalette->disappearForCapture(); QPixmap originalPixmap = getScreenPixmap(); mDesktopPalette->appear(); emit imageCaptured(originalPixmap, false); mIsFullyTransparent = false; updateBackground(); } QPixmap WBDesktopAnnotationController::getScreenPixmap() { QDesktopWidget *desktop = QApplication::desktop(); QScreen * screen = WBApplication::controlScreen(); QRect rect = desktop->screenGeometry(QCursor::pos()); return screen->grabWindow(desktop->effectiveWinId(), rect.x(), rect.y(), rect.width(), rect.height()); } void WBDesktopAnnotationController::updateShowHideState(bool pEnabled) { mDesktopPalette->updateShowHideState(pEnabled); } void WBDesktopAnnotationController::screenLayoutChanged() { if (WBApplication::applicationController && WBApplication::applicationController->displayManager() && WBApplication::applicationController->displayManager()->hasDisplay()) { mDesktopPalette->setShowHideButtonVisible(true); } else { mDesktopPalette->setShowHideButtonVisible(false); } } /** * \brief Handles the pen action pressed event */ void WBDesktopAnnotationController::penActionPressed() { mbArrowClicked = false; mDesktopMarkerPalette->hide(); mDesktopEraserPalette->hide(); WBDrawingController::drawingController()->setStylusTool(WBStylusTool::Pen); mPenHoldTimer = QTime::currentTime(); mPendingPenButtonPressed = true; // Check if the mouse cursor is on the little arrow QPoint cursorPos = QCursor::pos(); QPoint palettePos = mDesktopPalette->pos(); QPoint buttonPos = mDesktopPalette->buttonPos(WBApplication::mainWindow->actionPen); int iX = cursorPos.x() - (palettePos.x() + buttonPos.x()); // x position of the cursor in the palette int iY = cursorPos.y() - (palettePos.y() + buttonPos.y()); // y position of the cursor in the palette if(iX >= 30 && iX <= 40 && iY >= 30 && iY <= 40) { mbArrowClicked = true; penActionReleased(); } else { mHoldTimerPen.start(PROPERTY_PALETTE_TIMER); } } /** * \brief Handles the pen action released event */ void WBDesktopAnnotationController::penActionReleased() { mHoldTimerPen.stop(); if(mPendingPenButtonPressed) { if(mbArrowClicked || mPenHoldTimer.msecsTo(QTime::currentTime()) > PROPERTY_PALETTE_TIMER - 100) { togglePropertyPalette(mDesktopPenPalette); } else { WBApplication::mainWindow->actionPen->trigger(); } mPendingPenButtonPressed = false; } WBApplication::mainWindow->actionPen->setChecked(true); switchCursor(WBStylusTool::Pen); } /** * \brief Handles the eraser action pressed event */ void WBDesktopAnnotationController::eraserActionPressed() { mbArrowClicked = false; mDesktopPenPalette->hide(); mDesktopMarkerPalette->hide(); WBDrawingController::drawingController()->setStylusTool(WBStylusTool::Eraser); mEraserHoldTimer = QTime::currentTime(); mPendingEraserButtonPressed = true; // Check if the mouse cursor is on the little arrow QPoint cursorPos = QCursor::pos(); QPoint palettePos = mDesktopPalette->pos(); QPoint buttonPos = mDesktopPalette->buttonPos(WBApplication::mainWindow->actionEraser); int iX = cursorPos.x() - (palettePos.x() + buttonPos.x()); // x position of the cursor in the palette int iY = cursorPos.y() - (palettePos.y() + buttonPos.y()); // y position of the cursor in the palette if(iX >= 30 && iX <= 40 && iY >= 30 && iY <= 40) { mbArrowClicked = true; eraserActionReleased(); } else { mHoldTimerEraser.start(PROPERTY_PALETTE_TIMER); } } /** * \brief Handles the eraser action released event */ void WBDesktopAnnotationController::eraserActionReleased() { mHoldTimerEraser.stop(); if(mPendingEraserButtonPressed) { if(mbArrowClicked || mEraserHoldTimer.msecsTo(QTime::currentTime()) > PROPERTY_PALETTE_TIMER - 100) { togglePropertyPalette(mDesktopEraserPalette); } else { WBApplication::mainWindow->actionEraser->trigger(); } mPendingEraserButtonPressed = false; } WBApplication::mainWindow->actionEraser->setChecked(true); switchCursor(WBStylusTool::Eraser); } /** * \brief Handles the marker action pressed event */ void WBDesktopAnnotationController::markerActionPressed() { mbArrowClicked = false; mDesktopPenPalette->hide(); mDesktopEraserPalette->hide(); WBDrawingController::drawingController()->setStylusTool(WBStylusTool::Marker); mMarkerHoldTimer = QTime::currentTime(); mPendingMarkerButtonPressed = true; // Check if the mouse cursor is on the little arrow QPoint cursorPos = QCursor::pos(); QPoint palettePos = mDesktopPalette->pos(); QPoint buttonPos = mDesktopPalette->buttonPos(WBApplication::mainWindow->actionMarker); int iX = cursorPos.x() - (palettePos.x() + buttonPos.x()); // x position of the cursor in the palette int iY = cursorPos.y() - (palettePos.y() + buttonPos.y()); // y position of the cursor in the palette if(iX >= 30 && iX <= 40 && iY >= 30 && iY <= 40) { mbArrowClicked = true; markerActionReleased(); } else { mHoldTimerMarker.start(PROPERTY_PALETTE_TIMER); } } /** * \brief Handles the marker action released event */ void WBDesktopAnnotationController::markerActionReleased() { mHoldTimerMarker.stop(); if(mPendingMarkerButtonPressed) { if(mbArrowClicked || mMarkerHoldTimer.msecsTo(QTime::currentTime()) > PROPERTY_PALETTE_TIMER - 100) { togglePropertyPalette(mDesktopMarkerPalette); } else { WBApplication::mainWindow->actionMarker->trigger(); } mPendingMarkerButtonPressed = false; } WBApplication::mainWindow->actionMarker->setChecked(true); switchCursor(WBStylusTool::Marker); } void WBDesktopAnnotationController::selectorActionPressed() { } void WBDesktopAnnotationController::selectorActionReleased() { WBApplication::mainWindow->actionSelector->setChecked(true); switchCursor(WBStylusTool::Selector); } void WBDesktopAnnotationController::pointerActionPressed() { } void WBDesktopAnnotationController::pointerActionReleased() { WBApplication::mainWindow->actionPointer->setChecked(true); switchCursor(WBStylusTool::Pointer); } /** * \brief Toggle the given palette visibility * @param palette as the given palette */ void WBDesktopAnnotationController::togglePropertyPalette(WBActionPalette *palette) { if(NULL != palette) { bool bShow = !palette->isVisible(); if(mDesktopPenPalette == palette) { desktopPenActionToggled(bShow); } else if(mDesktopMarkerPalette == palette) { desktopMarkerActionToggled(bShow); } else if(mDesktopEraserPalette == palette) { desktopEraserActionToggled(bShow); } } } void WBDesktopAnnotationController::switchCursor(const int tool) { mTransparentDrawingScene->setToolCursor(tool); mTransparentDrawingView->setToolCursor(tool); } /** * \brief Reconnect the pressed & released signals of the property palettes */ void WBDesktopAnnotationController::onDesktopPaletteMaximized() { // Pen WBActionPaletteButton* pPenButton = mDesktopPalette->getButtonFromAction(WBApplication::mainWindow->actionPen); if(NULL != pPenButton) { connect(pPenButton, SIGNAL(pressed()), this, SLOT(penActionPressed())); connect(pPenButton, SIGNAL(released()), this, SLOT(penActionReleased())); } // Eraser WBActionPaletteButton* pEraserButton = mDesktopPalette->getButtonFromAction(WBApplication::mainWindow->actionEraser); if(NULL != pEraserButton) { connect(pEraserButton, SIGNAL(pressed()), this, SLOT(eraserActionPressed())); connect(pEraserButton, SIGNAL(released()), this, SLOT(eraserActionReleased())); } // Marker WBActionPaletteButton* pMarkerButton = mDesktopPalette->getButtonFromAction(WBApplication::mainWindow->actionMarker); if(NULL != pMarkerButton) { connect(pMarkerButton, SIGNAL(pressed()), this, SLOT(markerActionPressed()));//zhusizhi 20210625 connect(pMarkerButton, SIGNAL(released()), this, SLOT(markerActionReleased())); } // Pointer WBActionPaletteButton* pSelectorButton = mDesktopPalette->getButtonFromAction(WBApplication::mainWindow->actionSelector); if(NULL != pSelectorButton) { connect(pSelectorButton, SIGNAL(pressed()), this, SLOT(selectorActionPressed())); connect(pSelectorButton, SIGNAL(released()), this, SLOT(selectorActionReleased())); } // Pointer WBActionPaletteButton* pPointerButton = mDesktopPalette->getButtonFromAction(WBApplication::mainWindow->actionPointer); if(NULL != pPointerButton) { connect(pPointerButton, SIGNAL(pressed()), this, SLOT(pointerActionPressed())); connect(pPointerButton, SIGNAL(released()), this, SLOT(pointerActionReleased())); } } /** * \brief Disconnect the pressed & release signals of the property palettes * This is done to prevent memory leaks */ void WBDesktopAnnotationController::onDesktopPaletteMinimize() { // Pen WBActionPaletteButton* pPenButton = mDesktopPalette->getButtonFromAction(WBApplication::mainWindow->actionPen); if(NULL != pPenButton) { disconnect(pPenButton, SIGNAL(pressed()), this, SLOT(penActionPressed())); disconnect(pPenButton, SIGNAL(released()), this, SLOT(penActionReleased())); } // Marker WBActionPaletteButton* pMarkerButton = mDesktopPalette->getButtonFromAction(WBApplication::mainWindow->actionMarker); if(NULL != pMarkerButton) { disconnect(pMarkerButton, SIGNAL(pressed()), this, SLOT(markerActionPressed())); disconnect(pMarkerButton, SIGNAL(released()), this, SLOT(markerActionReleased())); } // Eraser WBActionPaletteButton* pEraserButton = mDesktopPalette->getButtonFromAction(WBApplication::mainWindow->actionEraser); if(NULL != pEraserButton) { disconnect(pEraserButton, SIGNAL(pressed()), this, SLOT(eraserActionPressed())); disconnect(pEraserButton, SIGNAL(released()), this, SLOT(eraserActionReleased())); } } void WBDesktopAnnotationController::TransparentWidgetResized() { onTransparentWidgetResized(); } /** * \brief Resize the library palette. */ void WBDesktopAnnotationController::onTransparentWidgetResized() { int rW = WBApplication::boardController->paletteManager()->rightPalette()->width(); int lW = WBApplication::boardController->paletteManager()->leftPalette()->width(); int rH = mTransparentDrawingView->height(); WBApplication::boardController->paletteManager()->rightPalette()->resize(rW+1, rH); WBApplication::boardController->paletteManager()->rightPalette()->resize(rW, rH); WBApplication::boardController->paletteManager()->leftPalette()->resize(lW+1, rH); WBApplication::boardController->paletteManager()->leftPalette()->resize(lW, rH); } void WBDesktopAnnotationController::updateMask(bool bTransparent) { if(bTransparent) { // Here we have to generate a new mask This method is certainly resource // consuming but for the moment this is the only solution that I found. mMask = QPixmap(mTransparentDrawingView->width(), mTransparentDrawingView->height()); mMask.fill(Qt::transparent); QPainter p; p.begin(&mMask); p.setPen(Qt::red); p.setBrush(QBrush(Qt::red)); // Here we draw the widget mask if(mDesktopPalette->isVisible()) { p.drawRect(mDesktopPalette->geometry().x(), mDesktopPalette->geometry().y(), mDesktopPalette->width(), mDesktopPalette->height()); } if(WBApplication::boardController->paletteManager()->mKeyboardPalette->isVisible()) { p.drawRect(WBApplication::boardController->paletteManager()->mKeyboardPalette->geometry().x(), WBApplication::boardController->paletteManager()->mKeyboardPalette->geometry().y(), WBApplication::boardController->paletteManager()->mKeyboardPalette->width(), WBApplication::boardController->paletteManager()->mKeyboardPalette->height()); } if(WBApplication::boardController->paletteManager()->leftPalette()->isVisible()) { QRect leftPalette(WBApplication::boardController->paletteManager()->leftPalette()->geometry().x(), WBApplication::boardController->paletteManager()->leftPalette()->geometry().y(), WBApplication::boardController->paletteManager()->leftPalette()->width(), WBApplication::boardController->paletteManager()->leftPalette()->height()); QRect tabsPalette(WBApplication::boardController->paletteManager()->leftPalette()->getTabPaletteRect()); p.drawRect(leftPalette); p.drawRect(tabsPalette); } if(WBApplication::boardController->paletteManager()->rightPalette()->isVisible()) { QRect rightPalette(WBApplication::boardController->paletteManager()->rightPalette()->geometry().x(), WBApplication::boardController->paletteManager()->rightPalette()->geometry().y(), WBApplication::boardController->paletteManager()->rightPalette()->width(), WBApplication::boardController->paletteManager()->rightPalette()->height()); QRect tabsPalette(WBApplication::boardController->paletteManager()->rightPalette()->getTabPaletteRect()); p.drawRect(rightPalette); p.drawRect(tabsPalette); } #ifdef Q_OS_LINUX //Rquiered only for compiz wm //TODO. Window manager detection screen if (WBApplication::boardController->paletteManager()->addItemPalette()->isVisible()) { p.drawRect(WBApplication::boardController->paletteManager()->addItemPalette()->geometry()); } #endif p.end(); // Then we add the annotations. We create another painter because we need to // apply transformations on it for coordinates matching QPainter annotationPainter; QTransform trans; trans.translate(mTransparentDrawingView->width()/2, mTransparentDrawingView->height()/2); annotationPainter.begin(&mMask); annotationPainter.setPen(Qt::red); annotationPainter.setBrush(Qt::red); annotationPainter.setTransform(trans); QList<QGraphicsItem*> allItems = mTransparentDrawingScene->items(); for(int i = 0; i < allItems.size(); i++) { QGraphicsItem* pCrntItem = allItems.at(i); if(pCrntItem->isVisible() && pCrntItem->type() == WBGraphicsPolygonItem::Type) { QPainterPath crntPath = pCrntItem->shape(); QRectF rect = crntPath.boundingRect(); annotationPainter.drawRect(rect); } } annotationPainter.end(); mTransparentDrawingView->setMask(mMask.mask()); } else { // Remove the mask QPixmap noMask(mTransparentDrawingView->width(), mTransparentDrawingView->height()); mTransparentDrawingView->setMask(noMask.mask()); } } void WBDesktopAnnotationController::refreshMask() { if (mTransparentDrawingScene && mTransparentDrawingView->isVisible()) { if(mIsFullyTransparent || WBDrawingController::drawingController()->stylusTool() == WBStylusTool::Selector //Needed to work correctly when another actions on stylus are checked || WBDrawingController::drawingController()->stylusTool() == WBStylusTool::Eraser || WBDrawingController::drawingController()->stylusTool() == WBStylusTool::Pointer || WBDrawingController::drawingController()->stylusTool() == WBStylusTool::Pen || WBDrawingController::drawingController()->stylusTool() == WBStylusTool::Marker) { updateMask(true); } } } void WBDesktopAnnotationController::onToolClicked() { mDesktopEraserPalette->hide(); mDesktopMarkerPalette->hide(); mDesktopPenPalette->hide(); }
[ "574226409@qq.com" ]
574226409@qq.com
01588d9f5d10cd72b727d2f06652860eda1de07a
d0c42e3b1b3b2fb206f9fd747cc30f2f1acfd283
/2.C++Primer/8.TheIO_Library/8.2/8.4.cpp
90b110ec05ba97586972e91193a0e89f4dfc0865
[]
no_license
yirenzhi/Reading-notes
5e7e7d45fc8b3c6a7621bdfe9a3aded958295a91
fca0fbc82b6e3df6a2f1b0c5a6560e1c1b7d7eb1
refs/heads/master
2021-07-17T08:56:17.214292
2021-02-23T09:54:04
2021-02-23T09:54:04
50,393,710
0
0
null
null
null
null
UTF-8
C++
false
false
421
cpp
#include<iostream> #include<string> #include<vector> #include<fstream> using namespace std; void read(const string name,vector<string>& datas) { fstream f(name); if (f) { string buf; while(getline(f,buf)) { datas.push_back(buf); } } } int main() { vector<string> datas; read("data",datas); for(const auto& data:datas) cout<<data<<endl; return 0; }
[ "yiren_zhi@163.com" ]
yiren_zhi@163.com
e62c0a5f05e5e6d32238448574c002152a966867
3505dc59e38763af442aeda7cef6307d0b2cc06e
/Lab_5/Exercise_B/square.cpp
d6af18db14a79cbc18a4c56aee2fd81cd185ec9b
[]
no_license
ENSF-619/Lab_5
37c48b0edfbf236eec7b505633ecb2d0dcb039ce
9aa7248fe12f8cc2d9aed1878183a6394c71b305
refs/heads/master
2022-12-31T02:42:58.099688
2020-10-23T21:05:51
2020-10-23T21:05:51
305,926,762
0
0
null
null
null
null
UTF-8
C++
false
false
1,041
cpp
/* *File Name: Exercise_B,square.cpp * Lab_5 * Completed by Ziad Chemali * Submission: 23,10,2020 */ #include "square.h" #include <iomanip> Square::Square(double x, double y, double side, const char* name):Shape(x, y, name) { this->side = side; } double Square::get_side_a() const { return side; } void Square::set_side_a(double num) { side = num; } Square::Square(const Square& r):Shape(r) { this->set_side_a(r.get_side_a()); } Square& Square::operator=(const Square& rhs) { if (this != &rhs) { Shape::operator=(rhs); this->side=rhs.get_side_a(); } return *this; } double Square::area() const { return pow(side, 2); } double Square::perimeter() const { return side * 4; } void Square::display() { cout << "\nShape name: " << getName() << endl; getOrigin().display(); cout << "side a: " << setprecision(4) << side << endl; cout << "Area: " <<setprecision(4) <<area()<< endl; cout << "Perimeter: " << setprecision(4) << perimeter() << endl; }
[ "zchemali@ucalgary.ca" ]
zchemali@ucalgary.ca
9740804257651b3606791016806302febf1dcacb
d9fc6f6787a8d3b2558b73566e6ad70a3d0936b3
/TestBed/Example.hpp
4c0d7ddfbadf1d3e5c9536e3889f7eaba7240d5f
[ "MIT" ]
permissive
geotyper/HitboxBuilder-2D
5d574ab8e48051aa83c7e7eefe0965211c013fda
ab86816005d7b7c44338bfa27975054b45e66cc3
refs/heads/master
2021-09-15T21:08:10.747954
2018-06-10T14:20:10
2018-06-10T14:20:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,289
hpp
#ifndef TESTBED_EXAMPLE_HPP #define TESTBED_EXAMPLE_HPP #include <string> #include <vector> #include <SFML/Graphics/RenderWindow.hpp> #include <SFML/Graphics/Sprite.hpp> #include <SFML/Graphics/Text.hpp> #include <SFML/Graphics/Texture.hpp> #include <SFML/Graphics/VertexArray.hpp> #include "Types.hpp" namespace hb = HitboxBuilder; namespace TestBed { class Example { public: const int kAccIncrement = 2; public: explicit Example(const std::vector<std::string>& fonts); void run(const std::vector<std::string>& images); private: void updateDrawables(std::vector<sf::VertexArray>& bodyVertices, sf::VertexArray& boundingBox); void loadSprites(const std::vector<std::string>& images); std::vector<sf::VertexArray> buildPolygon(const std::vector<hb::Polygon>& polygons); sf::VertexArray buildBoundingBox(const hb::Polygon& boundingBox) const; bool handleEvents(const sf::Event& event); void close(); private: struct Text { sf::Text text; sf::Font font; }; private: sf::RenderWindow _window; std::vector<sf::Texture> _textures; std::vector<sf::Sprite> _sprites; private: size_t _accuracy{ 50 }; size_t _spriteIdx{ 0 }; bool _displaySprite{ true }; sf::Vector2i _center; Text _polygonCount; }; } /* namespace TestBed */ #endif
[ "luc.sinet@etixgroup.com" ]
luc.sinet@etixgroup.com
631b80126b7899f6351cadc2043b23e0cb5564b2
cfeac52f970e8901871bd02d9acb7de66b9fb6b4
/generated/src/aws-cpp-sdk-datapipeline/source/model/SetStatusRequest.cpp
4b9789a92679539bf7e723e7b5782fa53be4cb66
[ "Apache-2.0", "MIT", "JSON" ]
permissive
aws/aws-sdk-cpp
aff116ddf9ca2b41e45c47dba1c2b7754935c585
9a7606a6c98e13c759032c2e920c7c64a6a35264
refs/heads/main
2023-08-25T11:16:55.982089
2023-08-24T18:14:53
2023-08-24T18:14:53
35,440,404
1,681
1,133
Apache-2.0
2023-09-12T15:59:33
2015-05-11T17:57:32
null
UTF-8
C++
false
false
1,392
cpp
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/datapipeline/model/SetStatusRequest.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::DataPipeline::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; SetStatusRequest::SetStatusRequest() : m_pipelineIdHasBeenSet(false), m_objectIdsHasBeenSet(false), m_statusHasBeenSet(false) { } Aws::String SetStatusRequest::SerializePayload() const { JsonValue payload; if(m_pipelineIdHasBeenSet) { payload.WithString("pipelineId", m_pipelineId); } if(m_objectIdsHasBeenSet) { Aws::Utils::Array<JsonValue> objectIdsJsonList(m_objectIds.size()); for(unsigned objectIdsIndex = 0; objectIdsIndex < objectIdsJsonList.GetLength(); ++objectIdsIndex) { objectIdsJsonList[objectIdsIndex].AsString(m_objectIds[objectIdsIndex]); } payload.WithArray("objectIds", std::move(objectIdsJsonList)); } if(m_statusHasBeenSet) { payload.WithString("status", m_status); } return payload.View().WriteReadable(); } Aws::Http::HeaderValueCollection SetStatusRequest::GetRequestSpecificHeaders() const { Aws::Http::HeaderValueCollection headers; headers.insert(Aws::Http::HeaderValuePair("X-Amz-Target", "DataPipeline.SetStatus")); return headers; }
[ "sdavtaker@users.noreply.github.com" ]
sdavtaker@users.noreply.github.com
84a6b8f4f0c9e35d9b1c437f75894fca3aaab358
30cf116b0e35c10bfed3fc31d46bf97bfc99d7f0
/File Handlers/CHK/Sections/CHKSectionOWNR.h
7573f13c33a1e66969b821079abeaeb21a22a10d
[ "MIT" ]
permissive
poiuyqwert/SCMS
1980e98baf396e44037e96a0e65096958c323bed
8aa5f90a8f4caf1db489614fdbd5fb2decf783d7
refs/heads/master
2021-01-18T15:46:17.345224
2018-02-17T18:44:42
2018-02-17T18:44:42
75,118,126
1
1
null
null
null
null
UTF-8
C++
false
false
655
h
// // CHKSectionOWNR.h // SCMS // // Created by Zach Zahos on 2016-01-04. // // #pragma once #include "CHKSection.h" #include "Types.h" #include "BroodWar.h" class CHKSectionOWNR : public CHKSection { u8 owners[StarCraft::Player::COUNT]; public: static const u32 ID = L('OWNR'); static const CHKRequirements Requirements; enum : u8 { Inactive, OccupiedComouter, // INVALID OccupiedHuman, // INVALID ReusePassive, Unused, Computer, Human, Neutral, Closed // INVALID }; CHKSectionOWNR(CHK *chk); u32 sectionID() { return CHKSectionOWNR::ID; } void load_data(const u8 *data, u32 size); u8* save_data(u32 &size); };
[ "zzahos@konradgroup.com" ]
zzahos@konradgroup.com
bfbb49fb083abfa8b702f0b7dfa6b9fcb1ae936d
9055c093cd4ba9ab67470fd40d1ef13330f42492
/Source/LoongWorld/skill_buff.cpp
1cd57f87b827164e27d4c84ca46eece93d2ee42d
[]
no_license
webdes27/LoongSource
379875f51df0c9d9753515f1952d5f11afdc7dec
6c248e3340788041714c3006906e704dd5853f71
refs/heads/master
2022-01-10T18:38:11.764963
2019-06-06T12:33:52
2019-06-06T12:33:52
null
0
0
null
null
null
null
GB18030
C++
false
false
4,380
cpp
//------------------------------------------------------------------------------- // Copyright (c) 2004 TENGWU Entertainment All rights reserved. // filename: skill_buff.h // author: Aslan // actor: // data: 2008-9-23 // last: // brief: 技能 //------------------------------------------------------------------------------- #include "stdafx.h" #include "../WorldDefine/skill_define.h" #include "../WorldDefine/buff_define.h" #include "att_res.h" #include "skill_buff.h" #include "world.h" //------------------------------------------------------------------------------------ // 设置加成 //------------------------------------------------------------------------------------ VOID tagBuffMod::SetMod(const tagSkillProto* pProto) { if( FALSE == P_VALID(pProto) ) return; if( ESTT_Buff != pProto->eTargetType ) return; // 持续时间 nPersistTickMod += pProto->nBuffPersistTimeAdd / TICK_TIME; // 叠加次数 nWarpTimesMod += pProto->nBuffWarpTimesAdd; // 攻击消除几率 nAttackInterruptRateMod += pProto->nBuffInterruptResistAdd; // 效果加成 if( EBEM_Null != pProto->eModBuffMode ) { // 之前没有过特殊效果加成 if( EBEM_Null == eModBuffEffectMode ) { eModBuffEffectMode = pProto->eModBuffMode; nEffectMisc1Mod = pProto->nBuffMisc1Add; nEffectMisc2Mod = pProto->nBuffMisc2Add; if( EBEM_Persist != pProto->eModBuffMode ) { IFASTCODE->MemCpy(nEffectAttMod, pProto->nBuffEffectAttMod, sizeof(nEffectAttMod)); } } // 之前有特殊效果加成,则新技能的特殊效果加成的阶段必须和其一样 else if( eModBuffEffectMode == pProto->eModBuffMode ) { nEffectMisc1Mod += pProto->nBuffMisc1Add; nEffectMisc2Mod += pProto->nBuffMisc2Add; if( EBEM_Persist != pProto->eModBuffMode ) { for(INT n = 0; n < EBEA_End; ++n) { nEffectAttMod[n] += pProto->nBuffEffectAttMod[n]; } } } // 新技能的特殊效果加成与之前的加成不一样,不会出现这种情况 else { ILOG->Write(_T("skill mod buff failed, skill type id is %u\r\n"), pProto->dwID); } } // 人物属性加成 ERoleAttribute eAtt = ERA_Null; INT nMod = 0; TMap<ERoleAttribute, INT>& mapMod = pProto->mapRoleAttMod; TMap<ERoleAttribute, INT>::TMapIterator itMod = mapMod.Begin(); while( mapMod.PeekNext(itMod, eAtt, nMod) ) { mapRoleAttMod.ModifyValue(eAtt, nMod); } TMap<ERoleAttribute, INT>& mapModPct = pProto->mapRoleAttModPct; TMap<ERoleAttribute, INT>::TMapIterator itModPct = mapModPct.Begin(); while( mapModPct.PeekNext(itModPct, eAtt, nMod) ) { mapRoleAttModPct.ModifyValue(eAtt, nMod); } // 将该技能TypeID存入本地list,以便保存 listModifier.PushBack(pProto->dwID); // 设置该Mod本身有效 bValid = TRUE; } //------------------------------------------------------------------------------------ // 取消加成 //------------------------------------------------------------------------------------ VOID tagBuffMod::UnSetMod(const tagSkillProto* pProto) { if( FALSE == P_VALID(pProto) ) return; if( ESTT_Buff != pProto->eTargetType ) return; // 持续时间 nPersistTickMod -= pProto->nBuffPersistTimeAdd / TICK_TIME; // 叠加次数 nWarpTimesMod -= pProto->nBuffWarpTimesAdd; // 攻击消除几率 nAttackInterruptRateMod -= pProto->nBuffInterruptResistAdd; // 效果加成 if( EBEM_Null != pProto->eModBuffMode ) { // 有特殊效果加成,则技能的特殊效果加成的阶段必须和其一样 if( eModBuffEffectMode == pProto->eModBuffMode ) { nEffectMisc1Mod -= pProto->nBuffMisc1Add; nEffectMisc2Mod -= pProto->nBuffMisc2Add; if( EBEM_Persist != pProto->eModBuffMode ) { for(INT n = 0; n < EBEA_End; ++n) { nEffectAttMod[n] -= pProto->nBuffEffectAttMod[n]; } } } } // 人物属性加成 ERoleAttribute eAtt = ERA_Null; INT nMod = 0; TMap<ERoleAttribute, INT>& mapMod = pProto->mapRoleAttMod; TMap<ERoleAttribute, INT>::TMapIterator itMod = mapMod.Begin(); while( mapMod.PeekNext(itMod, eAtt, nMod) ) { mapRoleAttMod.ModifyValue(eAtt, -nMod); } TMap<ERoleAttribute, INT>& mapModPct = pProto->mapRoleAttModPct; TMap<ERoleAttribute, INT>::TMapIterator itModPct = mapModPct.Begin(); while( mapModPct.PeekNext(itModPct, eAtt, nMod) ) { mapRoleAttModPct.ModifyValue(eAtt, -nMod); } listModifier.Erase(const_cast<tagSkillProto*>(pProto)->dwID); }
[ "prihodko@dlit.dp.ua" ]
prihodko@dlit.dp.ua
921602b5ab2d98d8584368e7675ed1a68b9977bb
499026f8c310592371c708c065d9cc01f7750033
/points2image/include/points_image/points_image.hpp
f7e9cf98616b0b8f53f911835c26e64a9ac5a6be
[]
no_license
CastielLiu/data_fusion
54232f220d8943873d05f1a106775e05531355cf
d705d1dbef79d3329fc8d03a57b3b10bc53342fa
refs/heads/master
2022-06-11T12:40:03.707443
2020-05-07T15:51:56
2020-05-07T15:51:56
261,800,554
1
1
null
null
null
null
UTF-8
C++
false
false
1,204
hpp
/* * Copyright 2015-2019 Autoware Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _POINTS_IMAGE_H_ #define _POINTS_IMAGE_H_ #include <opencv2/opencv.hpp> #include <sensor_msgs/PointCloud2.h> void resetMatrix(); void pointcloud2_to_image(const sensor_msgs::PointCloud2ConstPtr& pointcloud2, cv::Mat& image, const cv::Mat& cameraExtrinsicMat, const cv::Mat& cameraMat, const cv::Mat& distCoeff, const cv::Size& imageSize); /*points2image::CameraExtrinsic pointcloud2_to_3d_calibration(const sensor_msgs::PointCloud2ConstPtr& pointclound2, const cv::Mat& cameraExtrinsicMat); */ #endif /* _POINTS_IMAGE_H_ */
[ "castiel_liu@outlook.com" ]
castiel_liu@outlook.com
a460e553a1642cd350335fda1c5e3bc463361b28
3e680d4c4aa55fda901e70bfbfbd1c93be9104fb
/depot/ghost/ai/chokudai.cc
c57037676dd7b3f14847a1800fa6ae85fa16c3d1
[]
no_license
imos/icfpc2014
26efe0a05df8a8edc02d920f705bf20e9dc230b7
eeb653810ae85c8f1eb6cdda95bce7eaa88ea1a8
refs/heads/master
2021-01-19T11:48:16.730628
2014-07-28T11:57:16
2014-07-28T11:57:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
103
cc
#include "ghost/ai/chokudai.h" namespace dummy { void ghost_ai_chokudai_cc() {} } // namespace dummy
[ "github@imoz.jp" ]
github@imoz.jp
6631149d98307f8712156fa79ea8caf051e0f7f2
becdc5eaaee5e0063abe524a84e78c9c5f355032
/dqm/common/include/emu/dqm/common/functions/FunctionLauncher.h
1ebe8f56747d35c40f02dd09c74671f5b0989f81
[]
no_license
slava77/emu
db6e59d6b0d694a75ebc8583d1f8c3696c8836e2
c0036c238757d4283ebdcc20ed559d7b27a980c7
refs/heads/svn-devel
2021-01-21T05:00:47.307761
2016-06-03T14:12:10
2016-06-03T14:12:10
23,416,919
1
10
null
2016-05-09T21:16:14
2014-08-28T05:51:44
C++
UTF-8
C++
false
false
9,970
h
/* * ===================================================================================== * * Filename: FunctionLauncher.h * * Description: FunctionLauncher application that does actual work of * transformation. It parses transformation string and executes it. * This class is being addresed within EmuMonitoringCanvas objects. * FunctionLauncher is being created statically and stores the list of * available functions. * * If you have created a function (base class AbstractFunction) to * register it here please do the following: * * - add include line in the appropriate section, i.e. * * #include "MyFunction.h" * * - add registration line within the constructor, i.e. * * functions.insert(make_pair("My", new MyFunction())); * * Now it can be used within the canvas XML map, i.e. * * <Pad1>My(histogram1, histogram2)</Pad1> * * Syntax: * * function([functin_params]) * where function_params = function_param [, function_params] * function_param = [-]histogram|function([function_params]) * * * Version: 1.0 * Created: 04/14/2008 11:40:30 AM * Revision: none * Compiler: gcc * * Author: Valdas Rapsevicius (VR), Valdas.Rapsevicius@cern.ch * Company: CERN, CH * * ===================================================================================== */ #ifndef FunctionLauncher_h #define FunctionLauncher_h #include <map> #include <vector> #include <stack> #include "../EmuMonitoringObject.h" #include "AbstractFunction.h" /** Functions */ #include "SetFunction.h" #include "DrawFunction.h" #include "ChamberMapFunction.h" #include "AddFunction.h" #include "DivideFunction.h" /** Register of functions (see Constructor if you wish to register one) */ typedef map<std::string, AbstractFunction*> FunctionMap; typedef FunctionMap::iterator FunctionMapIterator; /** Functions are being executed in stack * so this is an exceptional stack item*/ struct ExecItem { AbstractFunction* func; EmuMonitoringObject* me_emu; MonitorElement* me; }; class FunctionLauncher { public: /** * @brief Class Constructor * @param * @return */ FunctionLauncher () { // Initialization of build-in functions setFunction = new SetFunction(); drawFunction = new DrawFunction(); // Register of functions functions.insert(make_pair("Set", setFunction)); functions.insert(make_pair("Draw", drawFunction)); functions.insert(make_pair("Add", new AddFunction())); functions.insert(make_pair("Divide", new DivideFunction())); functions.insert(make_pair("DrawChamberMap", new ChamberMapFunction())); }; /** * @brief Class destructor that removes function registry! * @param * @return */ ~FunctionLauncher() { FunctionMapIterator iter; for (iter = functions.begin(); iter != functions.end(); iter++) { delete iter->second; iter->second = NULL; } }; /** * @brief Entry point function * @param command Command line (actualy it is everything what lies inside * <Padx/> element. * @param MEs Monitoring elements of the apropriate scale, e.g. EMU level * @return */ void execute(const std::string command, ME_List& MEs) { if (!command.empty() && !MEs.empty()) { if (REMATCH("^.+$", command)) { std::string l_command = command; if (REMATCH("^[-a-zA-Z0-9_]+$", l_command)) { l_command = "Draw(" + l_command + ")"; } executeFunction(l_command, MEs); } else { cerr << "Wrong command syntax [" << command << "]!\n"; } } }; private: /** Register of functions... */ FunctionMap functions; // Pointers to build-in functions SetFunction* setFunction; DrawFunction* drawFunction; /** * @brief Actual execution function * @param command Command string * @param MEs List of me's * @return */ bool executeFunction(const std::string command, ME_List& MEs) { bool result = true; std::stack<ExecItem> execStack; ExecItem item; std::string lcom = command, name; // // remove spaces (if any) // REREPLACEM(" {1,}", lcom, "", "g"); // // Lets eat lcom step by step ;) // while (!lcom.empty()) { // // Get and remove starting name of something :) // name = lcom; REREPLACE("^([-a-zA-Z0-9_]+).*", name, "$1"); REREPLACE("^[-a-zA-Z0-9_]+", lcom, ""); // // Is it a EmuMonitoringObject ? // if (lcom.empty() || REMATCH("^[\\),]", lcom)) { bool mandatory = true; if (REMATCH("^-", name)) { mandatory = false; REREPLACE("^-", name, ""); } ME_List_iterator iemu = MEs.find(name); if (iemu != MEs.end()) { item.func = NULL; item.me_emu = iemu->second; item.me = NULL; execStack.push(item); } else if (mandatory) { cerr << "EmuMonitoringObject [" << name << "] not found! Command [" << command << "]\n"; result = false; break; } else { cerr << "Optional EmuMonitoringObject [" << name << "] not found in Command [" << command << "]. Ignoring...\n"; } } else // // Next is function? // if (REMATCH("^\\(", lcom)) { FunctionMapIterator ifunc = functions.find(name); if (ifunc != functions.end()) { item.func = ifunc->second;; item.me_emu = NULL; item.me = NULL; execStack.push(item); } else { cerr << "Function [" << name << "] not found! Command [" << command << "]\n"; result = false; break; } if (REMATCH("^\\(\\)", lcom)) { REREPLACE("^.", lcom, ""); } } // // Execute // while (REMATCH("^\\)", lcom)) { REREPLACE("^.", lcom, ""); // // Lets collect all the MEs from stack ;) // EmuMonitoringObject* lastEmu = NULL; FunctionParameters params; while (!execStack.empty() && execStack.top().func == NULL) { if (execStack.top().me_emu != NULL) { MonitorElement* me = dynamic_cast<MonitorElement*>(execStack.top().me_emu->getObject()->Clone()); params.insert(params.begin(), me); execStack.top().me_emu->applyPadProperties(); if (lastEmu == NULL) { lastEmu = execStack.top().me_emu; } } else { params.push_back(execStack.top().me); //lastEmu = NULL; } execStack.pop(); } // NULLify stuff item.func = NULL; item.me_emu = NULL; item.me = NULL; // Execute if (!execStack.empty() && execStack.top().func != NULL) { AbstractFunction* function = execStack.top().func; execStack.pop(); item.me = function->calc(params); // Do something for built-in Draw function if (function == drawFunction && lastEmu != NULL) { std::string statOpt = lastEmu->getParameter("SetOptStat"); if (statOpt != "" ) { gStyle->SetOptStat(statOpt.c_str()); } } // Do an exception for built-in Set function if (function == setFunction && lastEmu != NULL) { std::string h_name = lastEmu->getObject()->GetName(); std::string h_title = lastEmu->getObject()->GetTitle(); lastEmu->setObject(item.me); lastEmu->getObject()->SetName(h_name.c_str()); lastEmu->getObject()->SetTitle(h_title.c_str()); item.me_emu = lastEmu; item.me = NULL; } execStack.push(item); } // Clear things ... for (unsigned int i = 0; i < params.size(); i++) { if (params[i] != NULL && params[i] != item.me) { delete params[i]; } } } // // Replace current command character... // if (!lcom.empty()) { REREPLACE("^.", lcom, ""); } } // // Execute remaining stuff on stack while (!execStack.empty()) { /* if(execStack.top().me_emu != NULL){ execStack.top().me_emu->applyPadProperties(); execStack.top().me_emu->Draw(); std::string statOpt = execStack.top().me_emu->getParameter("SetOptStat"); if (statOpt != "" ) { gStyle->SetOptStat(statOpt.c_str()); } } */ if (execStack.top().me != NULL) { delete execStack.top().me; } execStack.pop(); } return result; } }; #endif
[ "barvic@4525493e-7705-40b1-a816-d608a930855b" ]
barvic@4525493e-7705-40b1-a816-d608a930855b
61048cf87ccbedc612415407deb6cb6153ef4b96
e61f5b7a23c3b1ca014e4809e487e95a65fc3e2c
/Source/BansheeEngine/Source/BsShapeMeshes2D.cpp
a8e65e8df0e5d8192ba0b275139c10d7491ffc3b
[]
no_license
ketoo/BansheeEngine
83568cb22f2997162905223013f3f6d73ae4227e
1ce5ec1bb46329695dd7cc13c0556b5bf7278e39
refs/heads/master
2021-01-02T08:49:09.416072
2017-08-01T15:46:42
2017-08-01T15:46:42
99,069,699
1
0
null
2017-08-02T03:48:06
2017-08-02T03:48:06
null
UTF-8
C++
false
false
8,821
cpp
//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// #include "BsShapeMeshes2D.h" #include "BsRect2.h" #include "BsMesh.h" #include "BsVector2.h" #include "BsLine2.h" #include "BsPass.h" #include "BsVertexDataDesc.h" namespace bs { const UINT32 ShapeMeshes2D::NUM_VERTICES_AA_LINE = 4; const UINT32 ShapeMeshes2D::NUM_INDICES_AA_LINE = 6; void ShapeMeshes2D::solidQuad(const Rect2& area, const SPtr<MeshData>& meshData, UINT32 vertexOffset, UINT32 indexOffset) { UINT32* indexData = meshData->getIndices32(); UINT8* positionData = meshData->getElementData(VES_POSITION); assert((vertexOffset + 4) <= meshData->getNumVertices()); assert((indexOffset + 6) <= meshData->getNumIndices()); Vector<Vector2> points; points.push_back(Vector2(area.x, area.y)); points.push_back(Vector2(area.x + area.width, area.y)); points.push_back(Vector2(area.x + area.width, area.y + area.height)); points.push_back(Vector2(area.x, area.y + area.height)); pixelSolidPolygon(points, positionData, vertexOffset, meshData->getVertexDesc()->getVertexStride(), indexData, indexOffset); } void ShapeMeshes2D::pixelLine(const Vector2& a, const Vector2& b, const SPtr<MeshData>& meshData, UINT32 vertexOffset, UINT32 indexOffset) { UINT32* indexData = meshData->getIndices32(); UINT8* positionData = meshData->getElementData(VES_POSITION); assert((vertexOffset + 2) <= meshData->getNumVertices()); assert((indexOffset + 2) <= meshData->getNumIndices()); pixelLine(a, b, positionData, vertexOffset, meshData->getVertexDesc()->getVertexStride(), indexData, indexOffset); } void ShapeMeshes2D::quadLine(const Vector2& a, const Vector2& b, float width, float border, const Color& color, const SPtr<MeshData>& meshData, UINT32 vertexOffset, UINT32 indexOffset) { Vector<Vector2> linePoints = { a, b }; quadLineList(linePoints, width, border, color, meshData, vertexOffset, indexOffset); } void ShapeMeshes2D::pixelLineList(const Vector<Vector2>& linePoints, const SPtr<MeshData>& meshData, UINT32 vertexOffset, UINT32 indexOffset) { assert(linePoints.size() % 2 == 0); assert((vertexOffset + linePoints.size() * 2) <= meshData->getNumVertices()); assert((indexOffset + linePoints.size() * 2) <= meshData->getNumIndices()); UINT32 curVertOffset = vertexOffset; UINT32 curIdxOffset = indexOffset; UINT32* indexData = meshData->getIndices32(); UINT8* positionData = meshData->getElementData(VES_POSITION); UINT32 numPoints = (UINT32)linePoints.size(); for(UINT32 i = 0; i < numPoints; i += 2) { pixelLine(linePoints[i], linePoints[i + 1], positionData, curVertOffset, meshData->getVertexDesc()->getVertexStride(), indexData, curIdxOffset); curVertOffset += 2; curIdxOffset += 2; } } void ShapeMeshes2D::quadLineList(const Vector<Vector2>& linePoints, float width, float border, const Color& color, const SPtr<MeshData>& meshData, UINT32 vertexOffset, UINT32 indexOffset) { UINT32 numPoints = (UINT32)linePoints.size(); assert(numPoints >= 2); UINT32 numLines = (UINT32)linePoints.size() - 1; assert((vertexOffset + (numLines * 2 + 2)) <= meshData->getNumVertices()); assert((indexOffset + (numLines * 6)) <= meshData->getNumIndices()); UINT32* outIndices = indexOffset + meshData->getIndices32(); UINT8* outVertices = vertexOffset + meshData->getElementData(VES_POSITION); UINT8* outColors = vertexOffset + meshData->getElementData(VES_COLOR); UINT32 vertexStride = meshData->getVertexDesc()->getVertexStride(); quadLineList(&linePoints[0], numPoints, width, border, outVertices, vertexStride, true); RGBA colorValue = color.getAsRGBA(); // Colors and indices for(UINT32 i = 0; i < numLines; i++) { memcpy(outColors, &colorValue, sizeof(colorValue)); outColors += vertexStride; memcpy(outColors, &colorValue, sizeof(colorValue)); outColors += vertexStride; UINT32 idxStart = i * 6; outIndices[idxStart + 0] = vertexOffset + idxStart + 0; outIndices[idxStart + 1] = vertexOffset + idxStart + 1; outIndices[idxStart + 2] = vertexOffset + idxStart + 2; outIndices[idxStart + 3] = vertexOffset + idxStart + 1; outIndices[idxStart + 4] = vertexOffset + idxStart + 3; outIndices[idxStart + 5] = vertexOffset + idxStart + 2; } memcpy(outColors, &colorValue, sizeof(colorValue)); outColors += vertexStride; memcpy(outColors, &colorValue, sizeof(colorValue)); outColors += vertexStride; } void ShapeMeshes2D::quadLineList(const Vector2* linePoints, UINT32 numPoints, float width, float border, UINT8* outVertices, UINT32 vertexStride, bool indexed) { assert(numPoints >= 2); UINT32 numLines = numPoints - 1; width += border; Vector2 prevPoints[2]; // Start segment { Vector2 a = linePoints[0]; Vector2 b = linePoints[1]; Vector2 diff = b - a; diff.normalize(); // Flip 90 degrees Vector2 normal(diff.y, -diff.x); prevPoints[0] = a - normal * width - diff * border; prevPoints[1] = a + normal * width - diff * border; memcpy(outVertices, &prevPoints[0], sizeof(prevPoints[0])); outVertices += vertexStride; memcpy(outVertices, &prevPoints[1], sizeof(prevPoints[1])); outVertices += vertexStride; } // Middle segments { for (UINT32 i = 1; i < numLines; i++) { Vector2 a = linePoints[i - 1]; Vector2 b = linePoints[i]; Vector2 c = linePoints[i + 1]; Vector2 diffPrev = b - a; diffPrev.normalize(); Vector2 diffNext = c - b; diffNext.normalize(); // Flip 90 degrees Vector2 normalPrev(diffPrev.y, -diffPrev.x); Vector2 normalNext(diffNext.y, -diffNext.x); Vector2 curPoints[2]; const float sign[] = { -1.0f, 1.0f }; for (UINT32 j = 0; j < 2; j++) { Vector2 linePrevPoint = a + normalPrev * width * sign[j]; Line2 linePrev(linePrevPoint, diffPrev); Vector2 lineNextPoint = b + normalNext * width * sign[j]; Line2 lineNext(lineNextPoint, diffNext); auto intersect = linePrev.intersects(lineNext); if (intersect.second != 0.0f) // Not parallel curPoints[j] = linePrev.getPoint(intersect.second); else curPoints[j] = lineNextPoint; memcpy(outVertices, &curPoints[j], sizeof(curPoints[j])); outVertices += vertexStride; } if (!indexed) { memcpy(outVertices, &curPoints[0], sizeof(curPoints[0])); outVertices += vertexStride; memcpy(outVertices, &prevPoints[1], sizeof(prevPoints[1])); outVertices += vertexStride; memcpy(outVertices, &curPoints[0], sizeof(curPoints[0])); outVertices += vertexStride; memcpy(outVertices, &curPoints[1], sizeof(curPoints[1])); outVertices += vertexStride; prevPoints[0] = curPoints[0]; prevPoints[1] = curPoints[1]; } } } // End segment { Vector2 a = linePoints[numPoints - 2]; Vector2 b = linePoints[numPoints - 1]; Vector2 diff = b - a; diff.normalize(); // Flip 90 degrees Vector2 normal(diff.y, -diff.x); Vector2 curPoints[2]; curPoints[0] = b - normal * width + diff * border; curPoints[1] = b + normal * width + diff * border; memcpy(outVertices, &curPoints[0], sizeof(curPoints[0])); outVertices += vertexStride; memcpy(outVertices, &curPoints[1], sizeof(curPoints[1])); outVertices += vertexStride; if (!indexed) { memcpy(outVertices, &curPoints[0], sizeof(curPoints[0])); outVertices += vertexStride; memcpy(outVertices, &prevPoints[1], sizeof(prevPoints[1])); outVertices += vertexStride; } } } void ShapeMeshes2D::pixelSolidPolygon(const Vector<Vector2>& points, UINT8* outVertices, UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset) { outVertices += (vertexOffset * vertexStride); for (auto& point : points) { Vector2* vertices = (Vector2*)outVertices; (*vertices) = point; outVertices += vertexStride; } outIndices += indexOffset; INT32 numPoints = (INT32)points.size(); UINT32 idxCnt = 0; for (int i = 2; i < numPoints; i++) { outIndices[idxCnt++] = vertexOffset; outIndices[idxCnt++] = vertexOffset + i - 1; outIndices[idxCnt++] = vertexOffset + i; } } void ShapeMeshes2D::pixelLine(const Vector2& a, const Vector2& b, UINT8* outVertices, UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset) { outVertices += (vertexOffset * vertexStride); Vector2* vertices = (Vector2*)outVertices; (*vertices) = a; vertices = (Vector2*)(outVertices + vertexStride); (*vertices) = b; outIndices += indexOffset; outIndices[0] = vertexOffset + 0; outIndices[1] = vertexOffset + 1; } }
[ "bearishsun@gmail.com" ]
bearishsun@gmail.com
563ebe228fd8716025f87472b1f644e72abff6fa
1eabff5e7e15f64091adfeb5cee0e97ee6723c4c
/source/Utils/ConsoleBuffer.h
ad3260e23cc02f18b7c7c998f37fb0b1ef46694f
[]
no_license
boksajak/theStrategy
ecf6592ea369c4d1225cdd2b53ac7e998d6939aa
91c53f138d42ebaf31076416a3a2238c03b59af5
refs/heads/master
2016-09-05T16:16:28.525657
2014-12-12T12:53:29
2014-12-12T12:53:29
null
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
2,079
h
//---------------------------------------------------------------------------------------- /** * \file ConsoleBuffer.h * \author Jakub Bokšanský * \date 2011/27/10 * \brief Console buffer class * * Provides functionality for text output to dedicated console window. Can be * supplied to C++ streams (attaches to std::cout on construction); * */ //---------------------------------------------------------------------------------------- #pragma once #include <iostream> #ifdef USE_CONSOLE #include <windows.h> #endif #ifdef USE_CONSOLE #define TRACE(X) std::cout << X; #define TRACE_RENDERER(X) consoleInst.setColor(3); std::cout << "Renderer: " << X; consoleInst.setColor(7); #define TRACE_UTILS(X) consoleInst.setColor(2); std::cout << "Utils: " << X; consoleInst.setColor(7); #define TRACE_ANIMATION(X) consoleInst.setColor(5); std::cout << "Animation: " << X; consoleInst.setColor(7); #define TRACE_LOADER(X) consoleInst.setColor(6); std::cout << "Loader: " << X; consoleInst.setColor(7); #define TRACE_ERROR(X) {consoleInst.setColor(12); std::cout << X; consoleInst.setColor(7);} #define TRACE_WARNING(X) {consoleInst.setColor(11); std::cout << X; consoleInst.setColor(7);} #else #define TRACE(X) ; #define TRACE_RENDERER(X) ; #define TRACE_UTILS(X) ; #define TRACE_ANIMATION(X) ; #define TRACE_LOADER(X) ; #define TRACE_ERROR(X) ; #define TRACE_WARNING(X) ; #endif #ifdef USE_CONSOLE class ConsoleBuffer : public std::streambuf { public: explicit ConsoleBuffer(); virtual ~ConsoleBuffer(); void setColor(WORD color) { flushAndRewind(); SetConsoleTextAttribute(m_hConsole, color); } void move(int x, int y, int width, int height) { MoveWindow(m_hWnd, x, y, width, height, true); } protected: virtual int_type overflow(int_type c); virtual int sync(); private: void flushAndRewind(); static const int BUFFER_SIZE = 256; HANDLE m_hConsole; HWND m_hWnd; char m_buffer[BUFFER_SIZE+1]; ConsoleBuffer(const ConsoleBuffer &); ConsoleBuffer &operator= (const ConsoleBuffer &); }; extern ConsoleBuffer consoleInst; #endif
[ "jakub.boksansky@gmail.com" ]
jakub.boksansky@gmail.com
4c95dbe294b4912acf1e5634de18eca0b3152435
63ab6ddb72da28123904e5e76cc80dc629dfc335
/week_1/66_Add_One .cpp
f9ea71b57d0693298d2da8e6551b863de789cd2c
[]
no_license
Azhenpia/geekAlgo
5aa63a4fbf894892e061c79455ed3a163c74bcdc
15ee7a97011b1ee0a6d933558301b47292f8b5d7
refs/heads/main
2023-09-03T19:46:43.842254
2021-11-01T16:25:57
2021-11-01T16:25:57
415,628,255
0
0
null
null
null
null
UTF-8
C++
false
false
374
cpp
class Solution { public: vector<int> plusOne(vector<int>& digits) { int hold = 1; for(int i = digits.size() - 1; i >= 0; --i){ digits[i] = digits[i] + hold; hold = digits[i] / 10; digits[i] %= 10; if(!hold) break; } if(hold) digits.insert(digits.begin(), 1); return digits; } };
[ "291753162@qq.com" ]
291753162@qq.com
2575271cbebaf96d52fa5f6edb979f1dde68620a
3ad27002da4859524ff09395d7d6f9d16de2aa89
/src/source/main.cpp
88cf679367746250b1c37fe2aea22e3145e2ea56
[]
no_license
MathDotSqrt/LevelOneAdventure
4ed6ab7a44848d775ea55acbbc859cbfbd85529a
6fc427e0b33801d300fb7aedb01f6f3ab0d8f047
refs/heads/master
2023-02-17T07:26:02.704697
2021-01-20T01:22:42
2021-01-20T01:22:42
313,788,692
1
0
null
null
null
null
UTF-8
C++
false
false
949
cpp
#include <stdio.h> #include <stdlib.h> #include <GL/glew.h> #include <glm/glm.hpp> #include <iostream> #include "common.h" #include "PlayState.h" #include "Window.h" #include "Util/Timer.h" int main(void) { LOA::Window &window = LOA::Window::createInstance(1280, 1024, "Level One Adventure"); glewExperimental = GL_TRUE; GLenum glewErr = glewInit(); if (glewErr != GLEW_OK) { std::cout << "FATAL\n"; } int count = 0; LOA::PlayState state; auto& manager = LOA::Util::TimerManager::getInstance(); while (!window.shouldClose()) { { LOA::Util::Timer timer("Main"); state.update(1 / 60.0f); state.render(); } window.update(); if (count >= 60) { //manager.display(); count -= 60; } manager.clear(); count++; } LOA::Window::destroyInstance(); exit(EXIT_SUCCESS); }
[ "ctrenkov@gmail.com" ]
ctrenkov@gmail.com
e0bb0972a9e2f78b08cbf5430a194a81da43c364
7d31a457a41cb85c02218149094e60955bba3fb1
/Widgets/ToolItemGroup/ToolItemGroup.cpp
b6de41f333d065cc2eb87b764d5a5e2ce33af09f
[]
no_license
Madankal/CGui
b1dfb51e2a2db25220daac8ee76bfbc381e19777
a97acd6ecad6ddb97c8bcbae00497c655ec137c0
refs/heads/master
2022-12-30T04:58:36.007615
2020-10-22T18:59:30
2020-10-22T18:59:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,553
cpp
#include "./ToolItemGroup.hh" namespace CGui { ToolItemGroup::ToolItemGroup(GtkToolItemGroup* group) : Container(this) { this->widget = GTK_WIDGET(group); this->SetContext(widget); } ToolItemGroup::ToolItemGroup(const char* label) : Container(this) { widget = gtk_tool_item_group_new(label); this->SetContext(widget); } void ToolItemGroup::Collapsed(bool collapsed) { gtk_tool_item_group_set_collapsed(GTK_TOOL_ITEM_GROUP(widget), collapsed); } bool ToolItemGroup::Collapsed() { return gtk_tool_item_group_get_collapsed(GTK_TOOL_ITEM_GROUP(widget)); } void ToolItemGroup::EllipsizeMode(CGui::EllipsizeMode mode) { gtk_tool_item_group_set_ellipsize(GTK_TOOL_ITEM_GROUP(widget), (PangoEllipsizeMode)mode); } CGui::EllipsizeMode ToolItemGroup::EllipsizeMode() { return (CGui::EllipsizeMode)gtk_tool_item_group_get_ellipsize(GTK_TOOL_ITEM_GROUP(widget)); } void ToolItemGroup::ItemPosition(ToolItem& item, int pos) { gtk_tool_item_group_set_item_position(GTK_TOOL_ITEM_GROUP(widget), GTK_TOOL_ITEM(item.GetWidget()), pos); } int ToolItemGroup::ItemPosition(ToolItem& item) { return gtk_tool_item_group_get_item_position(GTK_TOOL_ITEM_GROUP(widget), GTK_TOOL_ITEM(item.GetWidget())); } void ToolItemGroup::Label(const char* label) { gtk_tool_item_group_set_label(GTK_TOOL_ITEM_GROUP(widget), label); } const char* ToolItemGroup::Label() { return gtk_tool_item_group_get_label(GTK_TOOL_ITEM_GROUP(widget)); } void ToolItemGroup::LabelWidget(Widget& label) { gtk_tool_item_group_set_label_widget(GTK_TOOL_ITEM_GROUP(widget), label.GetWidget()); } Widget ToolItemGroup::LabelWidget() { return Widget(gtk_tool_item_group_get_label_widget(GTK_TOOL_ITEM_GROUP(widget))); } void ToolItemGroup::HeaderRelief(CGui::ReliefStyle style) { gtk_tool_item_group_set_header_relief(GTK_TOOL_ITEM_GROUP(widget), (GtkReliefStyle)style); } CGui::ReliefStyle ToolItemGroup::HeaderRelief() { return (CGui::ReliefStyle)gtk_tool_item_group_get_header_relief(GTK_TOOL_ITEM_GROUP(widget)); } unsigned int ToolItemGroup::NumItems() { return gtk_tool_item_group_get_n_items(GTK_TOOL_ITEM_GROUP(widget)); } ToolItem ToolItemGroup::NthItem(int index) { return ToolItem(gtk_tool_item_group_get_nth_item(GTK_TOOL_ITEM_GROUP(widget), index)); } void ToolItemGroup::Insert(ToolItem& item, int pos) { gtk_tool_item_group_insert(GTK_TOOL_ITEM_GROUP(widget), GTK_TOOL_ITEM(item.GetWidget()), pos); } bool ToolItemGroup::IsToolItemGroup() { return GTK_IS_TOOL_ITEM_GROUP(widget); } }
[ "developmentprogramming154@gmail.com" ]
developmentprogramming154@gmail.com
81031577644965447f09d013247767fd519843cd
9526b3ee25e9252623d9ea41ba8b9658a541fa63
/sumi/sumi/communicator.cc
c5a8495d416f4f5419c963c0870aa3696f669533
[ "BSD-3-Clause" ]
permissive
summonersRift/sst-macro
e6f3e80cdf70aa1e26e6ecf17e44960b522c4ae9
1307bb4f31e033dbbd2d9b82c54d3753446d31a4
refs/heads/master
2021-01-21T10:59:20.172254
2017-02-24T15:01:07
2017-02-24T15:01:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
857
cc
#include <sumi/communicator.h> #include <sumi/transport.h> #include <sprockit/errors.h> namespace sumi { void communicator::rank_resolved(int global_rank, int comm_rank) { for (rank_callback* cback : rank_callbacks_){ cback->rank_resolved(global_rank, comm_rank); } } global_communicator::global_communicator(transport *tport) : transport_(tport), communicator(tport->rank()) { } int global_communicator::nproc() const { return transport_->nproc(); } int global_communicator::comm_to_global_rank(int comm_rank) const { return comm_rank; } int global_communicator::global_to_comm_rank(int global_rank) const { return global_rank; } int index_communicator::global_to_comm_rank(int global_rank) const { spkt_throw(sprockit::unimplemented_error, "index_domain::global_to_comm_rank: this should only be involved in failures"); } }
[ "jjwilke@sandia.gov" ]
jjwilke@sandia.gov
1ddb8602743b4a4b1e867f08a1d575c169999048
3cb635004677c95db974b79b7c2f736d74eeaf17
/tools/multiCamCalibrate/include/Homography.hpp
781a96dc7c94cfae0cba0d8850796fb24b1544e9
[ "Apache-2.0" ]
permissive
Falcons-Robocup/code
46ca709cf8680edc45494a40dc2db54e579dffe6
dca3ffdfd7020a9913e6af6b555eac107b38a4ca
refs/heads/master
2023-02-07T10:47:58.550403
2023-01-21T16:29:47
2023-01-21T16:29:47
102,643,355
6
7
NOASSERTION
2019-09-24T21:05:13
2017-09-06T18:22:44
C++
UTF-8
C++
false
false
341
hpp
#include "opencv2/core/core.hpp" class Homography { public: Homography(); ~Homography(); cv::Mat Run(cv::Mat& getImg); private: static void onMouse(int event, int x, int y, int, void*); static cv::Point2f roi4point[4]; static int roiIndex; static bool oksign; void PointOrderbyConner(cv::Point2f* inPoints); };
[ "jan.feitsma@gmail.com" ]
jan.feitsma@gmail.com
e8211998f2e4de21ca79fd33625ad441289d64b0
5838eadbf52b3b5eb55d7db2146da6bb3ceb9f98
/8/gets.cpp
bea72221c3fa582249962cbd0dab5465f3bb63bb
[]
no_license
moetazaneta/uni-programming-basics
84abdc869718cad7def8444900d879e65fb77687
0034af4061a628f3d3393d5001ad3ad1c2059360
refs/heads/master
2022-12-15T15:04:26.020883
2020-09-19T19:39:39
2020-09-19T19:39:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,404
cpp
char* getStr(void) { int len = 1; char* str = new char[len]; char* tmp = NULL; while (true) { str[len - 1] = getchar(); if (str[len - 1] == '\b') { printf("%c", str[len - 1]); printf("%c", ' '); printf("%c", str[len - 1]); tmp = new char[len - 1]; for (int i = 0; i < len - 2; i++) { tmp[i] = str[i]; } delete[] str; str = tmp; len--; } if (str[len - 1] == '\n') { str[len - 1] = '\0'; break; } tmp = new char[len + 1]; for (int i = 0; i < len; i++) { tmp[i] = str[i]; } delete[] str; str = tmp; len++; } char* resStr = new char[60]; strncpy(resStr, str, 60); resStr[60] = '\0'; delete[] str; return resStr; } int getInt(int min, int max) { long input; char symbol; while (scanf_s("%d%c", &input, &symbol, 1) != 2 || symbol != '\n' || input < min || input > max) { printf("Error. Input correct number.\n"); while (getchar() != '\n'); } return input; } int getPositiveInt() { long input; char symbol; while (scanf_s("%d%c", &input, &symbol, 1) != 2 || symbol != '\n' || input < 0) { printf("Error. Input correct number.\n"); while (getchar() != '\n'); } return input; } int getBoolStr() { char symbol; while (scanf_s("%c", &symbol, 1) && symbol != 'n' && symbol != 'y') { printf("Error. Input correct answer(y/n).\n"); while (getchar() != '\n'); } return symbol == 'y' ? 1 : 0; }
[ "teqqmu@gmail.com" ]
teqqmu@gmail.com
032550c721d1d8784953c25fef9aa96c715d4f60
b68877cbe9328314a63dcdb6d5e07b53e3e4d82d
/MFCWnd/ColumnStyle.h
986ab09cc2278e253f494df4155896fdc7100d78
[]
no_license
c1xfr2e/windows_snippet
64dc133f6842aec4845a70948a786d1403a4a750
226e84f786bd76c2e582f14fd9dcea9c5f82af89
refs/heads/master
2021-05-26T15:25:55.380928
2013-12-24T12:44:06
2013-12-24T12:44:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,075
h
#pragma once class CMyList; class CWordListController; class CColumnStyle { public: CColumnStyle() : m_bUseDefaultFont(true) {} void SetFont(int nPointSize, LPCTSTR lpszFaceName); virtual void DrawItem(CWordListController& listController, int nItemIndex, int colIndex, CRect rcBound, CRect rcLabel, CDC* pDC) = 0; protected: void DrawString(CDC* pDC, LPCTSTR lpszString, int nCount, CRect rect, UINT nFormat); CFont m_fontItem; bool m_bUseDefaultFont; }; class CColumnStyle_CheckBox : public CColumnStyle { public: virtual void DrawItem(CWordListController& listController, int nItemIndex, int nColIndex, CRect rcBound, CRect rcLabel, CDC* pDC); }; class CColumnStyle_Text : public CColumnStyle { public: virtual void DrawItem(CWordListController& listController, int nItemIndex, int nColIndex, CRect rcBound, CRect rcLabel, CDC* pDC); }; class CColumnStyle_Progress : public CColumnStyle { public: virtual void DrawItem(CWordListController& listController, int nItemIndex, int nColIndex, CRect rcBound, CRect rcLabel, CDC* pDC); };
[ "zhaohao7282@163.com" ]
zhaohao7282@163.com
9a5a91e7a5af725f8d7e0751256b9db64e5970e0
b1884b6cd511d361482cfb48c76e0bc3ebc5adaa
/Unreal/Tank/tank/Source/tank/Private/Projectile.cpp
c6656153520976ebb98c5c7f5140d63cd2108b27
[]
no_license
silence394/LearnDemos
550c8a8933782c1a729d24399fe438cc401f8473
74b29448f04c53ffa4b9f3bf3efe9cd280b34bd9
refs/heads/master
2021-07-19T09:28:59.230969
2020-04-21T07:00:33
2020-04-21T07:00:33
135,886,284
0
0
null
null
null
null
UTF-8
C++
false
false
2,270
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "Projectile.h" // Sets default values AProjectile::AProjectile() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; mProjectileMoveCom = CreateDefaultSubobject<UProjectileMovementComponent>("ProjectileMovement"); mProjectileMoveCom->bAutoActivate = false; mCollisionMesh = CreateDefaultSubobject<UStaticMeshComponent>(FName("CollisionMesh")); mCollisionMesh->SetNotifyRigidBodyCollision(true); mCollisionMesh->SetVisibility(true); SetRootComponent(mCollisionMesh); mLaunchParticle = CreateDefaultSubobject<UParticleSystemComponent>(FName("Launch")); mLaunchParticle->AttachTo(RootComponent); mLaunchParticle->SetAutoActivate(false); mHitParticle = CreateDefaultSubobject<UParticleSystemComponent>(FName("Hit")); mHitParticle->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform); mHitParticle->SetAutoActivate(false); mExplosionForce = CreateDefaultSubobject<URadialForceComponent>(FName("ExplosionForce")); mExplosionForce->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform); mHitParticle->SetAutoActivate(false); } // Called when the game starts or when spawned void AProjectile::BeginPlay() { Super::BeginPlay(); mCollisionMesh->OnComponentHit.AddDynamic(this, &AProjectile::OnHit); } // Called every frame void AProjectile::Tick(float DeltaTime) { Super::Tick(DeltaTime); } void AProjectile::LaunchProjectile(float speed) { mProjectileMoveCom->SetVelocityInLocalSpace(FVector::ForwardVector * speed); mProjectileMoveCom->Activate(); mLaunchParticle->SetActive(true); } void AProjectile::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) { mHitParticle->SetActive(true); mCollisionMesh->SetNotifyRigidBodyCollision(false); SetRootComponent(mHitParticle); mCollisionMesh->DestroyComponent(); mExplosionForce->FireImpulse(); UGameplayStatics::ApplyRadialDamage(this, mProjectileDamage, GetActorLocation(), mExplosionForce->Radius, UDamageType::StaticClass(), TArray<AActor*>()); }
[ "silence394@126.com" ]
silence394@126.com
11f06cad733937a6224be82b77fa0e35ad0afa4b
466714254203250dc3a4f6499acedd363ff1e375
/src/Utils.h
ad438d21a9a38b6ad3ac9b0f88d24a45fcbe83fc
[ "MIT" ]
permissive
matiasvc/Toucan
8209c346cdb1c007ce2205919875fcde9014015c
3ca3cd9c7152905ba8b75eadb110e9d2dcb0f4b1
refs/heads/master
2023-04-06T04:01:41.164487
2021-02-21T12:12:26
2021-02-21T12:12:26
321,046,926
18
2
MIT
2021-04-02T16:40:12
2020-12-13T11:18:22
C++
UTF-8
C++
false
false
3,775
h
#pragma once #include <cassert> #include <Toucan/LinAlg.h> namespace Toucan { template<typename T, typename U> constexpr size_t offset_of(U T::*member) { return (char*) &((T*) nullptr->*member) - (char*) nullptr; } inline Toucan::Matrix4f create_3d_orientation_and_handedness_matrix(const Orientation& orientation, const Handedness& handedness) { Toucan::Vector3f x_vec = Toucan::Vector3f::UnitX(); Toucan::Vector3f y_vec = Toucan::Vector3f::UnitY(); Toucan::Vector3f z_vec = Toucan::Vector3f::UnitZ(); switch (orientation) { case Orientation::X_UP : { x_vec = Toucan::Vector3f::UnitZ(); y_vec = Toucan::Vector3f::UnitX(); z_vec = x_vec.cross_product(y_vec); if (handedness == Handedness::LEFT_HANDED) { z_vec = -z_vec; } } break; case Orientation::X_DOWN : { x_vec = -Toucan::Vector3f::UnitZ(); y_vec = Toucan::Vector3f::UnitX(); z_vec = x_vec.cross_product(y_vec); if (handedness == Handedness::LEFT_HANDED) { z_vec = -z_vec; } } break; case Orientation::Y_UP : { y_vec = Toucan::Vector3f::UnitZ(); z_vec = Toucan::Vector3f::UnitX(); x_vec = y_vec.cross_product(z_vec); if (handedness == Handedness::LEFT_HANDED) { x_vec = -x_vec; } } break; case Orientation::Y_DOWN : { y_vec = -Toucan::Vector3f::UnitZ(); z_vec = Toucan::Vector3f::UnitX(); x_vec = y_vec.cross_product(z_vec); if (handedness == Handedness::LEFT_HANDED) { x_vec = -x_vec; } } break; case Orientation::Z_UP : { z_vec = Toucan::Vector3f::UnitZ(); x_vec = Toucan::Vector3f::UnitX(); y_vec = z_vec.cross_product(x_vec); if (handedness == Handedness::LEFT_HANDED) { y_vec = -y_vec; } } break; case Orientation::Z_DOWN : { z_vec = -Toucan::Vector3f::UnitZ(); x_vec = Toucan::Vector3f::UnitX(); y_vec = z_vec.cross_product(x_vec); if (handedness == Handedness::LEFT_HANDED) { y_vec = -y_vec; } } break; } Toucan::Matrix4f m( x_vec.x(), y_vec.x(), z_vec.x(), 0.0f, x_vec.y(), y_vec.y(), z_vec.y(), 0.0f, x_vec.z(), y_vec.z(), z_vec.z(), 0.0f, 0.0f, 0.0f, 0.0f, 1.0f ); return m; } inline Toucan::Matrix4f create_2d_view_matrix(const Rectangle& draw_view, YAxisDirection y_axis_direction) { const float& a = draw_view.min.x(); const float& b = draw_view.min.y(); const float w = draw_view.width(); const float h = draw_view.height(); if (y_axis_direction == YAxisDirection::UP) { Toucan::Matrix4f m( 2.0f/w, 0.0f, 0.0f, -2.0f*a/w - 1.0f , 0.0f, -2.0f/h, 0.0f, 2.0f*b/h + 1.0f , 0.0f, 0.0f, 1.0f, 0.0f , 0.0f, 0.0f, 0.0f, 1.0f ); return m; } else { Toucan::Matrix4f m( 2.0f/w, 0.0f, 0.0f, -2.0f*a/w - 1.0f , 0.0f, 2.0f/h, 0.0f, -2.0f*b/h - 1.0f , 0.0f, 0.0f, 1.0f, 0.0f , 0.0f, 0.0f, 0.0f, 1.0f ); return m; } } inline std::vector<float> data_to_pixel(const std::vector<float>& data_coords, float data_from_value, float data_to_value, float pixel_from_value, float pixel_to_value) { std::vector<float> pixel_coords; pixel_coords.reserve(data_coords.size()); const float data_width = data_to_value - data_from_value; const float pixel_width = pixel_to_value - pixel_from_value; for (auto data_coord : data_coords) { float normalized_coord = (data_coord - data_from_value)/data_width; float pixel_coord = pixel_width*normalized_coord + pixel_from_value; pixel_coords.emplace_back(pixel_coord); } return pixel_coords; } template<typename T> constexpr inline T remap(T x, T x0, T x1, T y0, T y1) { return y0 + (x - x0) * (y1 - y0) / (x1 - x0); } template<typename T> constexpr inline T sgn(T value) { return value < T(0) ? T(-1) : value > T(0) ? T(1) : T(0); } } // namespace Toucan
[ "mattivc@gmail.com" ]
mattivc@gmail.com
93f25b2958cdc5816562e8ebdd496efd453ed41d
2a0af60379a8cf62dc6fa692b71b187f982f5546
/9주차/18_example_1/18_example_1.ino
5d36da5965fbd13432d38b9cc456e44363e5db50
[]
no_license
govl0407/changyeongong
8a1870f1423148a2d50ce2745532f4e8d9ef4c5b
1660b70c5c5a9bdee31e4a951f115e569d2165b2
refs/heads/master
2023-01-27T19:44:50.260348
2020-12-14T10:05:19
2020-12-14T10:05:19
294,625,389
0
0
null
null
null
null
UTF-8
C++
false
false
508
ino
// Arduino pin assignment #define PIN_IR A0 #define PIN_LED 9 void setup() { // initialize GPIO pins pinMode(PIN_LED,OUTPUT); digitalWrite(PIN_LED, 1); // initialize serial port Serial.begin(57600); } float ir_distance(void){ // return value unit: mm float val; float volt = float(analogRead(PIN_IR)); val = ((6762.0/(volt-9.0))-4.0) * 10.0; return val; } void loop() { float raw_dist = ir_distance(); Serial.print("min:0,max:500,dist:"); Serial.println(raw_dist); delay(20); }
[ "govl0407@gmail.com" ]
govl0407@gmail.com
c20e6d47c3168113461e76c942943a393e03d2d2
701090bd68f3be7d5ec5eaa84cf79886411b0917
/setdefaults.cpp
38acb6fee0af5763f863097f4cc99660f79dc716
[]
no_license
tuhinsundey/APIthet
6066a31c79f54b2f69504711cc246452aeb10af7
e3289ffd8e79ffd5062dcfcfa7d24232e288d8c0
refs/heads/master
2021-01-13T12:17:08.974563
2016-10-19T07:59:48
2016-10-19T07:59:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,129
cpp
/* * Copyright [2016] [mail.gulpfriction@gmail.com] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "mainwindow.h" #include "ui_mainwindow.h" void MainWindow::setDefault() { csrfPayload = false; csrfIssueLikely = false; headerHasAuth = false; hasQueryParams = false; likelyUnauth = false; passwdInGetQuery = false; passwdInPostQuery = false; postQueryHasBody = false; //initilize the count of absent headers to 0 contentHeaderMissed = 0; xFrameHeaderMissed = 0; xContentHeaderMissed = 0; hstsHeaderMissed = 0; xssProtHeaderMissed = 0; }
[ "mail.gulpfriction@gmail.com" ]
mail.gulpfriction@gmail.com
40b0737239d9660c0c0c937cfe7bf33af6fc3acb
755237da97f85ab4280ac0461c3fd81bab999939
/include/Entity/Destroyable/Crate.hpp
153bc6f1699ca810b77074b6b06e9772945d3d09
[]
no_license
PuentesTimothee/IndieStudio
32ad4e821c17605e79597d663ea60f757f27e0bc
902aa1bf774c46024d71df84b3a731a62a41ecda
refs/heads/master
2021-01-25T12:37:12.424366
2018-03-01T21:02:37
2018-03-01T21:02:37
123,487,508
0
0
null
null
null
null
UTF-8
C++
false
false
437
hpp
// // Created by puentes on 14/06/17. // #ifndef INDIE_CRATE_HPP #define INDIE_CRATE_HPP #include <Entity/Entity.hpp> #include "Components/Components.hpp" #include "Components/Model.hpp" #include "Components/EntityState.hpp" #include "Components/Stats.hpp" #include "Components/Sound.hpp" namespace Gauntlet { class Crate : public Gauntlet::Entity { public: Crate(int id); ~Crate() {}; }; } #endif //INDIE_CRATE_HPP
[ "timothee.puentes@epitech.eu" ]
timothee.puentes@epitech.eu
b159f5dfb529ec7d4d496ce90e986b31b2492e51
b4d433c797fd106fccbc67d70d4ca9a4c04bf015
/src/optimizers.cpp
afebe27f57ab05d79fe3d1caf3c88db7a29bde18
[]
no_license
frontseat-astronaut/Computation-graph
fe0c33434713bfc316d86565ac7bd0d688bfc702
760928c941e3ed9cb80fe1f670f9074071237abd
refs/heads/master
2023-03-06T06:30:55.904916
2021-02-11T15:12:40
2021-02-11T15:12:40
292,539,592
1
0
null
null
null
null
UTF-8
C++
false
false
2,182
cpp
#include <optimizers.h> namespace dio { // optimizer double optimizer::get_lr() { return learning_rate; } void optimizer::update_lr() { return; } std::vector<std::vector<double>> optimizer::get_grads(std::shared_ptr<node>f) { std::map<long long, std::vector<std::vector<double>>>Jcache = f->reverse_diff(); std::vector<std::vector<double>>grads(parameters.size()); for(int i=0; i<parameters.size(); ++i) { auto param = parameters[i]; long long key = (long long)param.get(); if(Jcache.find(key) == Jcache.end()) grads[i] = std::vector<double>(param->get_size()); else grads[i] = Jcache[key][0]; } return grads; } void optimizer::step(std::shared_ptr<node>f, bool do_gradient_check, double EPSILON) { if(f->get_size() != 1) throw NotRealFunction(); auto grads = get_grads(f); // GRADIENT CHECK if(do_gradient_check) gradient_check(f, grads, parameters, EPSILON); update_parameters(grads); } // sgd sgd::sgd(std::vector<std::shared_ptr<node>>parameters, double learning_rate, double momentum): optimizer(parameters, learning_rate), momentum{momentum} { if(!iszero(momentum)) { for(auto param: parameters) velocity.push_back(std::vector<double>(param->get_size())); } } void sgd::update_parameters(std::vector<std::vector<double>>&grads) { for(int i=0; i<parameters.size(); ++i) { std::shared_ptr<node> param = parameters[i]; std::vector<double> &value = *(param->get_value()); std::vector<double> grad = grads[i]; scale_vector(grad, -learning_rate); if(!iszero(momentum)) { scale_vector(velocity[i], momentum); add_vectors(velocity[i], velocity[i], grad); add_vectors(value, value, velocity[i]); } else add_vectors(value, value, grad); } } }
[ "frontseatastronaut@gmail.com" ]
frontseatastronaut@gmail.com
e4d6d842793e4fb4d16d52c949bc4202fbb4bf1e
5185c2e175dc21117972c0c37edd586af509ce9c
/threads/thread.cc
9792f5e4f0d505ccc486ec075caddb0b661efc1c
[ "MIT-Modern-Variant" ]
permissive
Anant16/cs330_ass2_code
3092ae936831dde62f7af06892ceeafe1d50a490
9f1650e8cdd3535be1744e8662b27b955ebaa9d1
refs/heads/master
2021-07-20T06:29:36.622323
2017-10-26T15:12:28
2017-10-26T15:12:28
107,881,876
0
0
null
null
null
null
UTF-8
C++
false
false
22,958
cc
// thread.cc // Routines to manage threads. There are four main operations: // // ThreadFork -- create a thread to run a procedure concurrently // with the caller (this is done in two steps -- first // allocate the NachOSThread object, then call ThreadFork on it) // FinishThread -- called when the forked procedure finishes, to clean up // YieldCPU -- relinquish control over the CPU to another ready thread // PutThreadToSleep -- relinquish control over the CPU, but thread is now blocked. // In other words, it will not run again, until explicitly // put back on the ready queue. // // Copyright (c) 1992-1993 The Regents of the University of California. // All rights reserved. See copyright.h for copyright notice and limitation // of liability and disclaimer of warranty provisions. #include "copyright.h" #include "thread.h" #include "switch.h" #include "synch.h" #include "system.h" #define STACK_FENCEPOST 0xdeadbeef // this is put at the top of the // execution stack, for detecting // stack overflows //---------------------------------------------------------------------- // NachOSThread::NachOSThread // Initialize a thread control block, so that we can then call // NachOSThread::ThreadFork. // // "threadName" is an arbitrary string, useful for debugging. //---------------------------------------------------------------------- NachOSThread::NachOSThread(char* threadName) { int i; name = threadName; stackTop = NULL; stack = NULL; //status = JUST_CREATED; setStatus(JUST_CREATED); #ifdef USER_PROGRAM space = NULL; stateRestored = true; #endif threadArray[thread_index] = this; pid = thread_index; thread_index++; ASSERT(thread_index < MAX_THREAD_COUNT); if (currentThread != NULL) { ppid = currentThread->GetPID(); currentThread->RegisterNewChild (pid); } else ppid = -1; //----------assignment-2------------- cpuCount[pid] = 0; priorityValue[pid] = priorityValue[ppid]; basePriorityValue[pid] = basePriorityValue[ppid]; //---------------------------- childcount = 0; waitchild_id = -1; for (i=0; i<MAX_CHILD_COUNT; i++) exitedChild[i] = false; instructionCount = 0; } //---------------------------------------------------------------------- // NachOSThread::NachOSThread // Initialize a thread control block, so that we can then call // NachOSThread::ThreadFork. // // "threadName" is an arbitrary string, useful for debugging. // used to set the priority of thread. //---------------------------------------------------------------------- // NachOSThread::NachOSThread(char* threadName, int _priority) // { // int i; // base_priority = 50; // priority = base_priority + _priority; // name = threadName; // stackTop = NULL; // stack = NULL; // status = JUST_CREATED; // #ifdef USER_PROGRAM // space = NULL; // stateRestored = true; // #endif // Entry_Time_Ready_Queue=0; // Estimated_CPU_Burst; //to be determined... // threadArray[thread_index] = this; // pid = thread_index; // thread_index++; // ASSERT(thread_index < MAX_THREAD_COUNT); // if (currentThread != NULL) { // ppid = currentThread->GetPID(); // currentThread->RegisterNewChild (pid); // } // else ppid = -1; // childcount = 0; // waitchild_id = -1; // for (i=0; i<MAX_CHILD_COUNT; i++) exitedChild[i] = false; // instructionCount = 0; // } //---------------------------------------------------------------------- // NachOSThread::~NachOSThread // De-allocate a thread. // // NOTE: the current thread *cannot* delete itself directly, // since it is still running on the stack that we need to delete. // // NOTE: if this is the main thread, we can't delete the stack // because we didn't allocate it -- we got it automatically // as part of starting up Nachos. //---------------------------------------------------------------------- NachOSThread::~NachOSThread() { DEBUG('t', "Deleting thread \"%s\" with pid %d\n", name, pid); ASSERT(this != currentThread); if (stack != NULL) DeallocBoundedArray((char *) stack, StackSize * sizeof(int)); } //---------------------------------------------------------------------- // NachOSThread::ThreadFork // Invoke (*func)(arg), allowing caller and callee to execute // concurrently. // // NOTE: although our definition allows only a single integer argument // to be passed to the procedure, it is possible to pass multiple // arguments by making them fields of a structure, and passing a pointer // to the structure as "arg". // // Implemented as the following steps: // 1. Allocate a stack // 2. Initialize the stack so that a call to SWITCH will // cause it to run the procedure // 3. Put the thread on the ready queue // // "func" is the procedure to run concurrently. // "arg" is a single argument to be passed to the procedure. //---------------------------------------------------------------------- void NachOSThread::ThreadFork(VoidFunctionPtr func, int arg) { DEBUG('t', "Forking thread \"%s\" with pid %d with func = 0x%x, arg = %d\n", name, pid, (int) func, arg); CreateThreadStack(func, arg); IntStatus oldLevel = interrupt->SetLevel(IntOff); scheduler->MoveThreadToReadyQueue(this); // MoveThreadToReadyQueue assumes that interrupts // are disabled! (void) interrupt->SetLevel(oldLevel); } //---------------------------------------------------------------------- // NachOSThread::CheckOverflow // Check a thread's stack to see if it has overrun the space // that has been allocated for it. If we had a smarter compiler, // we wouldn't need to worry about this, but we don't. // // NOTE: Nachos will not catch all stack overflow conditions. // In other words, your program may still crash because of an overflow. // // If you get bizarre results (such as seg faults where there is no code) // then you *may* need to increase the stack size. You can avoid stack // overflows by not putting large data structures on the stack. // Don't do this: void foo() { int bigArray[10000]; ... } //---------------------------------------------------------------------- void NachOSThread::CheckOverflow() { if (stack != NULL) #ifdef HOST_SNAKE // Stacks grow upward on the Snakes ASSERT(stack[StackSize - 1] == STACK_FENCEPOST); #else ASSERT(*stack == STACK_FENCEPOST); #endif } //---------------------------------------------------------------------- // NachOSThread::FinishThread // Called by ThreadRoot when a thread is done executing the // forked procedure. // // NOTE: we don't immediately de-allocate the thread data structure // or the execution stack, because we're still running in the thread // and we're still on the stack! Instead, we set "threadToBeDestroyed", // so that ProcessScheduler::Schedule() will call the destructor, once we're // running in the context of a different thread. // // NOTE: we disable interrupts, so that we don't get a time slice // between setting threadToBeDestroyed, and going to sleep. //---------------------------------------------------------------------- // void NachOSThread::FinishThread () { (void) interrupt->SetLevel(IntOff); ASSERT(this == currentThread); DEBUG('t', "Finishing thread \"%s\" with pid %d\n", getName(), pid); threadToBeDestroyed = currentThread; PutThreadToSleep(); // invokes SWITCH // not reached } //---------------------------------------------------------------------- // NachOSThread::SetChildExitCode // Called by an exiting thread on parent's thread object. //---------------------------------------------------------------------- void NachOSThread::SetChildExitCode (int childpid, int ecode) { unsigned i; // Find out which child for (i=0; i<childcount; i++) { if (childpid == childpidArray[i]) break; } ASSERT(i < childcount); childexitcode[i] = ecode; exitedChild[i] = true; if (waitchild_id == (int)i) { waitchild_id = -1; // I will wake myself up IntStatus oldLevel = interrupt->SetLevel(IntOff); scheduler->MoveThreadToReadyQueue(this); (void) interrupt->SetLevel(oldLevel); } } //---------------------------------------------------------------------- // NachOSThread::Exit // Called by ExceptionHandler when a thread calls Exit. // The argument specifies if all threads have called Exit, in which // case, the simulation should be terminated. //---------------------------------------------------------------------- void NachOSThread::Exit (bool terminateSim, int exitcode) { (void) interrupt->SetLevel(IntOff); ASSERT(this == currentThread); DEBUG('t', "Finishing thread \"%s\" with pid %d\n", getName(), pid); threadToBeDestroyed = currentThread; NachOSThread *nextThread; // status = BLOCKED; printf("thread[%d] exiting, average-cpu-burst = %d\n",pid, Estimated_CPU_Burst ); setStatus(BLOCKED); // Set exit code in parent's structure provided the parent hasn't exited if (ppid != -1) { ASSERT(threadArray[ppid] != NULL); if (!exitThreadArray[ppid]) { threadArray[ppid]->SetChildExitCode (pid, exitcode); } } while ((nextThread = scheduler->SelectNextReadyThread()) == NULL) { if (terminateSim) { DEBUG('i', "Machine idle. No interrupts to do.\n"); printf("\nNo threads ready or runnable, and no pending interrupts.\n"); printf("Assuming all programs completed.\n"); interrupt->Halt(); } else interrupt->Idle(); // no one to run, wait for an interrupt } scheduler->ScheduleThread(nextThread); // returns when we've been signalled } //---------------------------------------------------------------------- // NachOSThread::YieldCPU // Relinquish the CPU if any other thread is ready to run. // If so, put the thread on the end of the ready list, so that // it will eventually be re-scheduled. // // NOTE: returns immediately if no other thread on the ready queue. // Otherwise returns when the thread eventually works its way // to the front of the ready list and gets re-scheduled. // // NOTE: we disable interrupts, so that looking at the thread // on the front of the ready list, and switching to it, can be done // atomically. On return, we re-set the interrupt level to its // original state, in case we are called with interrupts disabled. // // Similar to NachOSThread::PutThreadToSleep(), but a little different. //---------------------------------------------------------------------- void NachOSThread::YieldCPU () { NachOSThread *nextThread; IntStatus oldLevel = interrupt->SetLevel(IntOff); ASSERT(this == currentThread); DEBUG('t', "Yielding thread \"%s\" with pid %d\n", getName(), pid); nextThread = scheduler->SelectNextReadyThread(); if (nextThread != NULL) { scheduler->MoveThreadToReadyQueue(this); scheduler->ScheduleThread(nextThread); } // else :: the current thread will continue to run wtihout updating // the priority of any thread at the end of this time quanta. (void) interrupt->SetLevel(oldLevel); } //---------------------------------------------------------------------- // NachOSThread::PutThreadToSleep // Relinquish the CPU, because the current thread is blocked // waiting on a synchronization variable (Semaphore, Lock, or Condition). // Eventually, some thread will wake this thread up, and put it // back on the ready queue, so that it can be re-scheduled. // // NOTE: if there are no threads on the ready queue, that means // we have no thread to run. "Interrupt::Idle" is called // to signify that we should idle the CPU until the next I/O interrupt // occurs (the only thing that could cause a thread to become // ready to run). // // NOTE: we assume interrupts are already disabled, because it // is called from the synchronization routines which must // disable interrupts for atomicity. We need interrupts off // so that there can't be a time slice between pulling the first thread // off the ready list, and switching to it. //---------------------------------------------------------------------- void NachOSThread::PutThreadToSleep () { NachOSThread *nextThread; ASSERT(this == currentThread); ASSERT(interrupt->getLevel() == IntOff); DEBUG('t', "Sleeping thread \"%s\" with pid %d\n", getName(), pid); //status = BLOCKED; setStatus(BLOCKED); while ((nextThread = scheduler->SelectNextReadyThread()) == NULL) interrupt->Idle(); // no one to run, wait for an interrupt scheduler->ScheduleThread(nextThread); // returns when we've been signalled } //---------------------------------------------------------------------- // ThreadFinish, InterruptEnable, ThreadPrint // Dummy functions because C++ does not allow a pointer to a member // function. So in order to do this, we create a dummy C function // (which we can pass a pointer to), that then simply calls the // member function. //---------------------------------------------------------------------- static void ThreadFinish() { currentThread->FinishThread(); } static void InterruptEnable() { interrupt->Enable(); } void ThreadPrint(int arg){ NachOSThread *t = (NachOSThread *)arg; t->Print(); } //---------------------------------------------------------------------- // NachOSThread::CreateThreadStack // Allocate and initialize an execution stack. The stack is // initialized with an initial stack frame for ThreadRoot, which: // enables interrupts // calls (*func)(arg) // calls NachOSThread::FinishThread // // "func" is the procedure to be forked // "arg" is the parameter to be passed to the procedure //---------------------------------------------------------------------- void NachOSThread::CreateThreadStack (VoidFunctionPtr func, int arg) { stack = (int *) AllocBoundedArray(StackSize * sizeof(int)); #ifdef HOST_SNAKE // HP stack works from low addresses to high addresses stackTop = stack + 16; // HP requires 64-byte frame marker stack[StackSize - 1] = STACK_FENCEPOST; #else // i386 & MIPS & SPARC stack works from high addresses to low addresses #ifdef HOST_SPARC // SPARC stack must contains at least 1 activation record to start with. stackTop = stack + StackSize - 96; #else // HOST_MIPS || HOST_i386 stackTop = stack + StackSize - 4; // -4 to be on the safe side! #ifdef HOST_i386 // the 80386 passes the return address on the stack. In order for // SWITCH() to go to ThreadRoot when we switch to this thread, the // return addres used in SWITCH() must be the starting address of // ThreadRoot. *(--stackTop) = (int)_ThreadRoot; #endif #endif // HOST_SPARC *stack = STACK_FENCEPOST; #endif // HOST_SNAKE machineState[PCState] = (int) _ThreadRoot; machineState[StartupPCState] = (int) InterruptEnable; machineState[InitialPCState] = (int) func; machineState[InitialArgState] = arg; machineState[WhenDonePCState] = (int) ThreadFinish; } #ifdef USER_PROGRAM #include "machine.h" //---------------------------------------------------------------------- // NachOSThread::SaveUserState // Save the CPU state of a user program on a context switch. // // Note that a user program thread has *two* sets of CPU registers -- // one for its state while executing user code, one for its state // while executing kernel code. This routine saves the former. //---------------------------------------------------------------------- void NachOSThread::SaveUserState() { if (stateRestored) { for (int i = 0; i < NumTotalRegs; i++) userRegisters[i] = machine->ReadRegister(i); stateRestored = false; } } //---------------------------------------------------------------------- // NachOSThread::RestoreUserState // Restore the CPU state of a user program on a context switch. // // Note that a user program thread has *two* sets of CPU registers -- // one for its state while executing user code, one for its state // while executing kernel code. This routine restores the former. //---------------------------------------------------------------------- void NachOSThread::RestoreUserState() { for (int i = 0; i < NumTotalRegs; i++) machine->WriteRegister(i, userRegisters[i]); stateRestored = true; } #endif //---------------------------------------------------------------------- // NachOSThread::CheckIfChild // Checks if the passed pid belongs to a child of mine. // Returns child id if all is fine; otherwise returns -1. //---------------------------------------------------------------------- int NachOSThread::CheckIfChild (int childpid) { unsigned i; // Find out which child for (i=0; i<childcount; i++) { if (childpid == childpidArray[i]) break; } if (i == childcount) return -1; return i; } //---------------------------------------------------------------------- // NachOSThread::JoinWithChild // Called by a thread as a result of SysCall_Join. // Returns the exit code of the child being joined with. //---------------------------------------------------------------------- int NachOSThread::JoinWithChild (int whichchild) { // Has the child exited? if (!exitedChild[whichchild]) { // Put myself to sleep waitchild_id = whichchild; IntStatus oldLevel = interrupt->SetLevel(IntOff); printf("[pid %d] Before sleep in JoinWithChild.\n", pid); PutThreadToSleep(); printf("[pid %d] After sleep in JoinWithChild.\n", pid); (void) interrupt->SetLevel(oldLevel); } return childexitcode[whichchild]; } #ifdef USER_PROGRAM //---------------------------------------------------------------------- // NachOSThread::ResetReturnValue // Sets the syscall return value to zero. Used to set the return // value of SysCall_Fork in the created child. //---------------------------------------------------------------------- void NachOSThread::ResetReturnValue () { userRegisters[2] = 0; } #endif //---------------------------------------------------------------------- // NachOSThread::Schedule // Enqueues the thread in the ready queue. //---------------------------------------------------------------------- void NachOSThread::Schedule() { IntStatus oldLevel = interrupt->SetLevel(IntOff); scheduler->MoveThreadToReadyQueue(this); // MoveThreadToReadyQueue assumes that interrupts // are disabled! (void) interrupt->SetLevel(oldLevel); } //---------------------------------------------------------------------- // NachOSThread::Startup // Part of the scheduling code needed to cleanly start a forked child. //---------------------------------------------------------------------- void NachOSThread::Startup() { scheduler->Tail(); } //---------------------------------------------------------------------- // NachOSThread::SortedInsertInWaitQueue // Called by SysCall_Sleep before putting the caller thread to sleep //---------------------------------------------------------------------- void NachOSThread::SortedInsertInWaitQueue (unsigned when) { TimeSortedWaitQueue *ptr, *prev, *temp; if (sleepQueueHead == NULL) { sleepQueueHead = new TimeSortedWaitQueue (this, when); ASSERT(sleepQueueHead != NULL); } else { ptr = sleepQueueHead; prev = NULL; while ((ptr != NULL) && (ptr->GetWhen() <= when)) { prev = ptr; ptr = ptr->GetNext(); } if (ptr == NULL) { // Insert at tail ptr = new TimeSortedWaitQueue (this, when); ASSERT(ptr != NULL); ASSERT(prev->GetNext() == NULL); prev->SetNext(ptr); } else if (prev == NULL) { // Insert at head ptr = new TimeSortedWaitQueue (this, when); ASSERT(ptr != NULL); ptr->SetNext(sleepQueueHead); sleepQueueHead = ptr; } else { temp = new TimeSortedWaitQueue (this, when); ASSERT(temp != NULL); temp->SetNext(ptr); prev->SetNext(temp); } } IntStatus oldLevel = interrupt->SetLevel(IntOff); //printf("[pid %d] Going to sleep at %d.\n", pid, stats->totalTicks); PutThreadToSleep(); //printf("[pid %d] Returned from sleep at %d.\n", pid, stats->totalTicks); (void) interrupt->SetLevel(oldLevel); } //---------------------------------------------------------------------- // NachOSThread::IncInstructionCount // Called by Machine::Run to update instruction count //---------------------------------------------------------------------- void NachOSThread::IncInstructionCount (void) { instructionCount++; } //---------------------------------------------------------------------- // NachOSThread::GetInstructionCount // Called by SysCall_NumInstr //---------------------------------------------------------------------- unsigned NachOSThread::GetInstructionCount (void) { return instructionCount; } void NachOSThread::setStatus(ThreadStatus st) { if(status == READY) { ASSERT(st == RUNNING); // as it can only go to running from ready. stats -> set_current_burst_start_time(); } else if(status == RUNNING) { if(st == READY || st == BLOCKED) { int burst_time = stats->totalTicks - stats->current_burst_start_time; printf("thread[%d] burst time over, burst_time = %d, present-average = %d\n", pid, burst_time, Estimated_CPU_Burst); if(burst_time > 0) { if(scheduler->type >= 7 && scheduler->type <=10) { cpuCount[pid] += burst_time; int i; for(i=0; i< thread_index; ++i) { if(!exitThreadArray[i]) { cpuCount[i] = cpuCount[i]>>1; priorityValue[i] = basePriorityValue[i] + cpuCount[i]>>1; } } } if(scheduler->type == 2 ) { Estimated_CPU_Burst = (int)((1-a_factor)*Estimated_CPU_Burst + (a_factor)*burst_time); } } } else { printf("----------------WARNING: status going from RUNNING to JUST_CREATED or RUNNING---------\n"); } } else if(status == BLOCKED) { if(st == READY) { Entry_Time_Ready_Queue = stats -> totalTicks; } else { printf("---------------ERROR: going from BLOCKED to other than READY-----------------------\n"); } } else if(status == JUST_CREATED) { if(st == READY) { Entry_Time_Ready_Queue = stats -> totalTicks; } else if(st == RUNNING) { printf("----------- WARNING: Going from JUST_CREATED to RUNNING---------\n"); stats->set_current_burst_start_time(); } else ASSERT(false); } else ASSERT(false); status = st; threadStatusPid[pid] = st; }
[ "anantvats16@gmail.com" ]
anantvats16@gmail.com
3b2faa2528f5f207d2865a2e76329d063b7755e4
a0d74fd8415e5396655a16195758b768984f3f67
/ch05/pro5-2.cpp
719fc9d0cca25e18bca74305c871f87e09238b6e
[]
no_license
593903762/Introduction_to_Algorithm_Competition
672774ffce7c7f93ec36a7ce659b470e3ba24e6a
c2bc5d8c8f995b8aaea842f0a5acb453ade1fde2
refs/heads/master
2020-04-30T07:44:31.551962
2018-07-18T13:08:10
2018-07-18T13:08:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,173
cpp
#include <iostream> #include <vector> #include <cstdio> #include <cmath> using namespace std; const int maxn = 15; int a_cur[maxn], a_init[maxn]; int main() { vector<int> v; int n; while (scanf("%d", &n) == 1 && n) { for (int i = 0; i < n; i++) { scanf("%d", &a_cur[i]); v.push_back(a_cur[i]); a_init[i] = a_cur[i]; } for (int t = 0; t < 1000; t++) { for (int i = 0; i < n; i++) { v[i] = abs(a_cur[i] - a_cur[(i + 1) % n]); } for (int i = 0; i < n; i++) { a_cur[i] = v[i]; } int flag = 1, sum = 0; for (int i = 0; i < n; i++) { if (a_cur[i] != a_init[i]) flag = 0; sum += a_cur[i]; } if (flag) { printf("The Ducci sequence is cyclic!\n"); break; } if (!sum) { printf("The Ducci sequence is 0.\n"); break; } } } return 0; }
[ "2456217567@whut.edu.cn" ]
2456217567@whut.edu.cn
0e30f1ff1c2fb6f92a5fc8904552ab61f4780d43
06bed8ad5fd60e5bba6297e9870a264bfa91a71d
/LayoutEditor/drawrectangle.h
eabdc9c40ff2a80eb9d6e204c5cfcbe12f41337b
[]
no_license
allenck/DecoderPro_app
43aeb9561fe3fe9753684f7d6d76146097d78e88
226c7f245aeb6951528d970f773776d50ae2c1dc
refs/heads/master
2023-05-12T07:36:18.153909
2023-05-10T21:17:40
2023-05-10T21:17:40
61,044,197
4
3
null
null
null
null
UTF-8
C++
false
false
910
h
#ifndef DRAWRECTANGLE_H #define DRAWRECTANGLE_H #include "drawframe.h" class JTextField; class DrawRectangle : public DrawFrame { Q_OBJECT public: //explicit DrawRectangle(QWidget *parent = 0); /*public*/ DrawRectangle(QString which, QString _title, ShapeDrawer* parent); /*public*/ QString getClassName(); signals: public slots: void widthEdited(QString); void heightEdited(QString); private: int _width; int _height; JTextField* _widthText; JTextField* _heightText; protected: /*protected*/ virtual QWidget* makeParamsPanel(PositionableShape* ps); /*protected*/ virtual void makeFigure(); ///*protected*/ void setPositionableParams(PositionableShape* p); /*protected*/ virtual void setDisplayParams(PositionableShape* p); ///*protected*/ virtual void updateFigure(PositionableShape* p); friend class DrawRoundRect; }; #endif // DRAWRECTANGLE_H
[ "allenck@windstream.net" ]
allenck@windstream.net
c340a21bde1a7c757eb9b63ff99ba243aeafcb00
1315eb7312202c4ed39057a48e102d9105e23c5f
/source/auto_generated/gpu_perf_api_counter_generator/public_counter_definitions_gl_gfx8_carrizo.h
4679a20e9bc593ed95487b970be6615799d268a2
[ "MIT" ]
permissive
Dragon31337/gpu_performance_api
0d8bf5edac2741d08417291557ef73337b09c629
02c82579db5de51217dd6c1949e696feebae7d87
refs/heads/master
2023-01-23T07:19:02.781637
2020-11-23T02:57:45
2020-11-23T03:02:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,224
h
//============================================================================== // Copyright (c) 2010-2020 Advanced Micro Devices, Inc. All rights reserved. /// \author AMD Developer Tools Team /// \file /// \brief Public Counter Definitions for GLGFX8_CARRIZO //============================================================================== #ifndef _PUBLIC_COUNTER_DEFINITIONS_GL_GFX8_CARRIZO_H_ #define _PUBLIC_COUNTER_DEFINITIONS_GL_GFX8_CARRIZO_H_ //*** Note, this is an auto-generated file. Do not edit. Execute PublicCounterCompiler to rebuild. #include "gpa_derived_counter.h" namespace gl_gfx8_carrizo { /// Updates default GPU generation Public derived counters with ASIC specific versions if available. /// \param desired_generation Hardware generation currently in use. /// \param asic_type The ASIC type that is currently in use. /// \param c Derived counters instance. /// \return True if the ASIC matched one available, and derivedCounters was updated. extern bool UpdatePublicAsicSpecificCounters(GDT_HW_GENERATION desired_generation, GDT_HW_ASIC_TYPE asic_type, GPA_DerivedCounters& c); } // namespace gl_gfx8_carrizo #endif // _PUBLIC_COUNTER_DEFINITIONS_GL_GFX8_CARRIZO_H_
[ "amit_prakash07@hotmail.com" ]
amit_prakash07@hotmail.com
7853c8447746ef85d2105fc591da797aa48139ae
ff5b3c9e555ba82cbc58a7dbb6da24f221a22658
/branch/EMTG_student/src/Astrodynamics.h
9897ae55956855d9d3923ab59c064b65ca42d697
[ "LicenseRef-scancode-us-govt-public-domain", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-unknown-license-reference" ]
permissive
xbigot/emtg
7b7b6351140f0a9e956a04c7e02b74326ad1c3cd
18a2d22819ff7d04c69248042c6ff3dfa0db094b
refs/heads/master
2020-07-03T11:26:39.658177
2015-02-11T22:05:14
2015-02-11T22:05:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,249
h
//header file for astrodynamics functions #include "missionoptions.h" #include "universe.h" #ifndef _ASTRODYNAMICS #define _ASTRODYNAMICS //#define _use_universal_kepler namespace EMTG{ namespace Astrodynamics { //****************************** //some constants const double AU = 149597870.691; //****************************** //insertion burn double insertion_burn(const double *Vin, const double *Vplanet, const double mu, const double R_SOI, const double destination_a, const double destination_e, double* v_inf_inbound); //****************************** //unpowered flyby void unpowered_flyby (const double* v_initial, const double *planet_v, const double mu, //INPUT const double rplanet, const double R_SOI, double rp, const double beta,//INPUT double* v_final, double* outgoing_C3, double* flyby_delta, double *flyby_orbit_energy);//OUTPUT //****************************** //powered flyby void powered_flyby (const double *v_initial, const double *v_final, const double *planet_v, const double mu, //INPUT const double rplanet, const double R_SOI,//INPUT double *dVmag, double *flyby_altitude, double* flyby_delta, double* outgoing_C3, double *flyby_orbit_energy); //output //functions to convert between inertial coordinates and classical orbit elements void COE2inertial(const double* E_COE, const double mu, double* state); void inertial2COE(const double* state, const double mu, double* E_COE); //functions to convert between classical orbit elements and modified equinoctial orbit elements void COE2MEE(const double* E_COE, double* E_MEE); void MEE2COE(const double* E_MEE, double* E_COE); //****************************** //thruster code int find_engine_parameters( EMTG::missionoptions* options, const double& r, const double& total_flight_time, double* max_thrust, double* max_mass_flow_rate, double* Isp, double* power, double* active_power, int* number_of_active_engines, const bool& generate_derivatives, double* dTdP, double* dmdotdP, double* dTdIsp, double* dmdotdIsp, double* dPdr, double* dPdt); //****************************** //force model code int force_model(EMTG::missionoptions * options, EMTG::Astrodynamics::universe * Universe, double * spacecraft_state, const double& epoch, const double& launch_epoch, double * control, double * max_thrust, double * max_mass_flow_rate, double * Isp, double * power, double * active_power, int * number_of_active_engines, double * force_vector, const bool & generate_derivatives, double * dTdP, double * dmdotdP, double * dTdIsp, double * dmdotdIsp, double * dPdr, double * dPdt, double * dSRPdr, vector<double> & dagravdRvec, vector<double> & dagravdtvec, vector<double> & central_body_state_mks); int FBLT_force_model(EMTG::missionoptions * options, EMTG::Astrodynamics::universe * Universe, std::vector <double> & spacecraft_state_relative_to_central_body_in_km, EMTG::math::Matrix <double> & dspacecraft_state_relative_to_central_body_in_kmdTOF, const double & epoch_step_left, std::vector <double> & depoch_left_stepdTOF, const double & c, const double & h, const double & dhdTOF, const double & launch_epoch, const std::vector <double> & control, std::vector <double> & f, EMTG::math::Matrix <double> & dfdTOF, double * max_thrust, double * max_mass_flow_rate, double * Isp, double * power, double * active_power, int * number_of_active_engines, std::vector <double> & force_vector, const bool & generate_derivatives, double * dTdP, double * dmdotdP, double * dTdIsp, double * dmdotdIsp, double * dPdr, double * dPdt, double * dFSRPdr, EMTG::math::Matrix<double> & A, vector<double> & dagravdRvec, vector<double> & dagravdtvec, vector<double> & central_body_state_mks); //****************************** //launch vehicle code void find_mass_to_orbit(double C3, double DLA, int LV_type, double* mass, double* dmdC3, missionoptions* options); //****************************** //spiral approximation code void Battin_spiral (const double& mass_before_spiral, const double& r0, const double& R0_planet, const double& time_since_launch, double& Isp, double& spiral_thrust, double& spiral_mdot, int& spiral_number_of_engines, double& spiral_power, double& spiral_active_power, const double& mu, const bool& generate_derivatives, missionoptions* options, double* t_spiral, double* mass_after_spiral, double* dv_spiral, double* dm_after_dm_before, double* dt_spiral_dm_before, double* dm_after_dIsp, double* dt_spiral_dIsp ); void Edelbaum_spiral (const double& mass_before_spiral, const double& r0, const double& R0_planet, const double& r_SOI, const double& time_since_launch, double& Isp, double& spiral_thrust, double& spiral_mdot, int& spiral_number_of_engines, double& spiral_power, double& spiral_active_power, const double& mu, const bool& generate_derivatives, missionoptions* options, double* t_spiral, double* mass_after_spiral, double* dv_spiral, double* dm_after_dm_before, double* dt_spiral_dm_before, double* dm_after_dIsp, double* dt_spiral_dIsp ); }} #endif //_ASTRODYNAMICS
[ "nasachilla@77bb456d-b9d8-4424-8c4a-7c450a671a84" ]
nasachilla@77bb456d-b9d8-4424-8c4a-7c450a671a84
e66fad897b75f6b3a5b61c913b57683d3cb3fd88
8a3f98746cd1bc103107fd06568cb63ec96c9ce8
/lab3/ex3/smart_pointers_2.cpp
463609891cfef5ed9365786ebf80e85b2ecd7351
[]
no_license
m43/fer-ooup
b295f23b058926e25ed685c97506a4f569895fdd
73cd80015638d3d79ead6284bf0af8f03afbf34b
refs/heads/master
2022-11-09T07:33:19.035076
2020-06-26T21:16:43
2020-06-26T21:16:43
251,527,337
0
0
null
2020-06-26T21:16:44
2020-03-31T07:12:16
Python
UTF-8
C++
false
false
1,042
cpp
#include <vector> #include <iostream> #include <memory> using namespace std; class Tiger { public: Tiger(string name) : name_(name) { cout << "tiger " << name << " constructor" << endl; }; ~Tiger() { cout << "tiger destructor" << endl; }; const string &getName() const { return name_; } private: string name_; }; int main() { vector<shared_ptr<Tiger> > tigers; auto tiger = make_shared<Tiger>("Rikola"); tigers.push_back(tiger); // AVOID: makes a copy of the shared pointer! now there are two owners of Rikola tigers.push_back(move(tiger)); // GOOD: moves the shared pointer into the vector. 'tiger' is no longer a owner // For more info: https://stackoverflow.com/questions/19334889/vector-of-shared-pointers-memory-problems-after-clearing-the-vector cout << "All done. Lets iterate over all tigers." << endl; for (const auto &t: tigers) { cout << t->getName() << endl; } tigers.clear(); cout << "Tigers vector cleaned. All done." << endl; return 0; }
[ "frano.rajich@gmail.com" ]
frano.rajich@gmail.com
eeed0334247f9fa5013443ef63015badb9fdc3e8
cee9786af78ef4beb5c90ce02cc315dcce79dbfd
/SIec_neuronowa/Neuron.h
6d39e45c3431424d5b38c8a4b3f0c2a7b189370d
[]
no_license
DarthBartek/SIec_neuronowa
1ee2bbd3d75a28faa6688e3415e4a9c8d21a3693
318ed553d89e7093b139528adc5f593f5a315350
refs/heads/master
2020-03-28T18:52:40.428584
2018-09-15T17:01:03
2018-09-15T17:01:03
148,922,117
0
0
null
null
null
null
UTF-8
C++
false
false
566
h
#pragma once #include <iostream> #include <vector> using namespace std; struct Connections { double value; double deltavalue; }; class Neuron { private: double outputVal; double derivative; vector<Connections> outputWeights; public: double error; bool bias; void setDerivative(double div); Neuron(int numOfOutputs, bool biasNeuron); void setOutputVal(double x); void setWeight(int index, double x); double getWeight(int index); double getDerivative(); double getOutput(void); void setError(double e); double getError(); int getNumOfWeights(); };
[ "thedarthbartek@gmail.com" ]
thedarthbartek@gmail.com
9e90db354505ea9d768fe69ac6235a8463948d27
19079c088fc306ac773d4a6f7e85715a3fc8cc9d
/challenge/flutter/all_samples/widgets_aligntransition_1/windows/runner/main.cpp
6ac4b17895c522981195eb11c5211883d3eaf4a9
[ "Apache-2.0" ]
permissive
davidzou/WonderingWall
75929193af4852675209b21dd544cb8b60da5fa5
1060f6501c432510e164578d4af60a49cd5ed681
refs/heads/master
2022-11-03T22:33:12.340125
2022-10-14T08:12:14
2022-10-14T08:12:14
5,868,257
4
0
null
null
null
null
UTF-8
C++
false
false
1,285
cpp
#include <flutter/dart_project.h> #include <flutter/flutter_view_controller.h> #include <windows.h> #include "flutter_window.h" #include "utils.h" int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, _In_ wchar_t *command_line, _In_ int show_command) { // Attach to console when present (e.g., 'flutter run') or create a // new console when running with a debugger. if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { CreateAndAttachConsole(); } // Initialize COM, so that it is available for use in the library and/or // plugins. ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); flutter::DartProject project(L"data"); std::vector<std::string> command_line_arguments = GetCommandLineArguments(); project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); if (!window.CreateAndShow(L"widgets_aligntransition_1", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true); ::MSG msg; while (::GetMessage(&msg, nullptr, 0, 0)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } ::CoUninitialize(); return EXIT_SUCCESS; }
[ "wearecisco@gmail.com" ]
wearecisco@gmail.com
329bcd4490bf055a93897f45c853d735427ba079
3db0149ad4b7074bdef6ba59d99bc1353bb9cd25
/src/Backends/Helmholtz/Configuration.h
3fcc4112a54c1a7e652ef612ee75d9f702f79863
[ "MIT" ]
permissive
jjfPCSI1/CoolProp
182b64127343c983c83b52bde3b272457d931ea4
6dae921535288c56fd1ca585b401e0bfa8eadedf
refs/heads/master
2021-01-17T08:50:15.350920
2014-11-10T22:05:23
2014-11-10T22:05:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
562
h
#ifndef COOLPROP_CONFIGURATION #define COOLPROP_CONFIGURATION #include "Exceptions.h" #include "CoolPropTools.h" enum configuration_keys {NORMALIZE_GAS_CONSTANTS, CRITICAL_SPLINES_ENABLED}; namespace CoolProp { // //class Configuration //{ //public: // Configuration(); // ~Configuration(); // //}; /// Return the value of a boolean key from the configuration bool get_config_bool(configuration_keys key); double get_config_double(configuration_keys key); std::string get_config_string(configuration_keys key); } #endif // COOLPROP_CONFIGURATION
[ "ian.h.bell@gmail.com" ]
ian.h.bell@gmail.com
65e994b99e72380e5e75f856ec04e81d49a333e5
4966d504c798e00b24c7cf5014c93aab6cc260d8
/dbms/src/Access/AllowedClientHosts.h
17f8be878a1b735ae8b734001d005163d6bec36a
[ "Apache-2.0" ]
permissive
maxulan/ClickHouse
d2921201a5aa22f69146013e7b88d248c21ca137
2d4b6716ffc6b1757d0013748110f97ee775bc4c
refs/heads/master
2020-06-16T21:06:37.192948
2019-12-20T05:00:55
2019-12-20T05:00:55
195,697,493
1
0
Apache-2.0
2019-08-01T22:56:55
2019-07-07T21:12:36
C++
UTF-8
C++
false
false
3,474
h
#pragma once #include <Core/Types.h> #include <Poco/Net/IPAddress.h> #include <memory> #include <vector> namespace Poco { class RegularExpression; } namespace DB { /// Represents lists of hosts an user is allowed to connect to server from. class AllowedClientHosts { public: using IPAddress = Poco::Net::IPAddress; struct IPSubnet { IPAddress prefix; IPAddress mask; String toString() const; friend bool operator ==(const IPSubnet & lhs, const IPSubnet & rhs) { return (lhs.prefix == rhs.prefix) && (lhs.mask == rhs.mask); } friend bool operator !=(const IPSubnet & lhs, const IPSubnet & rhs) { return !(lhs == rhs); } }; struct AllAddressesTag {}; AllowedClientHosts(); explicit AllowedClientHosts(AllAddressesTag); ~AllowedClientHosts(); AllowedClientHosts(const AllowedClientHosts & src); AllowedClientHosts & operator =(const AllowedClientHosts & src); AllowedClientHosts(AllowedClientHosts && src); AllowedClientHosts & operator =(AllowedClientHosts && src); /// Removes all contained addresses. This will disallow all addresses. void clear(); bool empty() const; /// Allows exact IP address. /// For example, 213.180.204.3 or 2a02:6b8::3 void addAddress(const IPAddress & address); void addAddress(const String & address); /// Allows an IP subnet. void addSubnet(const IPSubnet & subnet); void addSubnet(const String & subnet); /// Allows an IP subnet. /// For example, 312.234.1.1/255.255.255.0 or 2a02:6b8::3/FFFF:FFFF:FFFF:FFFF:: void addSubnet(const IPAddress & prefix, const IPAddress & mask); /// Allows an IP subnet. /// For example, 10.0.0.1/8 or 2a02:6b8::3/64 void addSubnet(const IPAddress & prefix, size_t num_prefix_bits); /// Allows all addresses. void addAllAddresses(); /// Allows an exact host. The `contains()` function will check that the provided address equals to one of that host's addresses. void addHostName(const String & host_name); /// Allows a regular expression for the host. void addHostRegexp(const String & host_regexp); const std::vector<IPAddress> & getAddresses() const { return addresses; } const std::vector<IPSubnet> & getSubnets() const { return subnets; } const std::vector<String> & getHostNames() const { return host_names; } const std::vector<String> & getHostRegexps() const { return host_regexps; } /// Checks if the provided address is in the list. Returns false if not. bool contains(const IPAddress & address) const; /// Checks if any address is allowed. bool containsAllAddresses() const; /// Checks if the provided address is in the list. Throws an exception if not. /// `username` is only used for generating an error message if the address isn't in the list. void checkContains(const IPAddress & address, const String & user_name = String()) const; friend bool operator ==(const AllowedClientHosts & lhs, const AllowedClientHosts & rhs); friend bool operator !=(const AllowedClientHosts & lhs, const AllowedClientHosts & rhs) { return !(lhs == rhs); } private: void compileRegexps() const; std::vector<IPAddress> addresses; bool loopback = false; std::vector<IPSubnet> subnets; std::vector<String> host_names; std::vector<String> host_regexps; mutable std::vector<std::unique_ptr<Poco::RegularExpression>> compiled_host_regexps; }; }
[ "vitbar@yandex-team.ru" ]
vitbar@yandex-team.ru
aa21f92f9cd25b5d78b7519c66228d81d368c9b2
985f9a15ae3d14b6785c98f5430f0e7b6be82a02
/include/Customs/LifeBarScript.h
e1a0cb652e0902d269f18d00715af0500b6dd5f7
[ "MIT" ]
permissive
vitorfhc/SquareOrDie
eba3be006cf658d49e18345ced0f8e3ae9cf1f56
5101b9c3069a4c363490717f4731d68d5563b4c6
refs/heads/master
2021-01-21T06:42:53.722239
2017-06-22T16:58:14
2017-06-22T16:58:14
91,582,919
0
0
null
null
null
null
UTF-8
C++
false
false
565
h
#ifndef SQUAREORDIE_LIFEBARSCRIPT_H #define SQUAREORDIE_LIFEBARSCRIPT_H #include <Components/RectangleRenderer.h> #include <Components/Script.h> #include <Customs/PlayerScript.h> #include <Globals/EngineGlobals.h> class LifeBarScript : public Script { public: LifeBarScript(GameObject *owner); void ComponentUpdate() override; std::string GetComponentName() override; void SetPlayer(PlayerScript *playerScript); void Start() override; private: RectangleRenderer *m_rRenderer; PlayerScript *m_playerScript; }; #endif // SQUAREORDIE_LIFEBARSCRIPT_H
[ "vitorfhcosta@gmail.com" ]
vitorfhcosta@gmail.com
277d1e1f87521380f11484b64d8ce66e4afb606e
2884fcda1e07c9e6ddf265531c27add7968a119f
/include/gie/allocator/simple_to_std_aligned_allocator.hpp
15dffc5108dfa378f722d7e75fdb738baeac4095
[]
no_license
igorge/libgie
08e78ae246f0dfd278f8732cd9bb570abe7fd59d
a76c1cfc1b8a1f891bc2cbb16870b9a9677c8263
refs/heads/master
2020-09-20T20:39:27.745521
2018-01-12T14:24:26
2018-01-12T14:24:26
67,069,311
0
0
null
null
null
null
UTF-8
C++
false
false
8,604
hpp
//================================================================================================================================================ // FILE: simple_to_std_aligned_allocator.h // (c) GIE 2016-10-20 02:09 // //================================================================================================================================================ #ifndef H_GUARD_SIMPLE_TO_STD_ALIGNED_ALLOCATOR_2016_10_20_02_09 #define H_GUARD_SIMPLE_TO_STD_ALIGNED_ALLOCATOR_2016_10_20_02_09 //================================================================================================================================================ #pragma once //================================================================================================================================================ #include "gie/log/debug.hpp" #include <type_traits> //================================================================================================================================================ namespace gie { auto const alloc_marker_no_alignment_overhead = 0xCCu; auto const alloc_marker_alignment_overhead_in_next_byte = 0xBBu; template <class T, class SimpleAllocatorT> struct simple_to_std_aligned_allocator_t { typedef T * pointer; typedef T const * const_pointer; typedef T & reference; typedef T const & const_reference; typedef T value_type; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; template <typename T1, typename T2> friend struct simple_to_std_aligned_allocator_t; template <class T1, class T2, class CommonSimpleAllocatorT> friend bool operator==(const simple_to_std_aligned_allocator_t<T1, CommonSimpleAllocatorT>& l, const simple_to_std_aligned_allocator_t<T2, CommonSimpleAllocatorT>& r); template <class T1, class T2, class CommonSimpleAllocatorT> friend bool operator!=(const simple_to_std_aligned_allocator_t<T1, CommonSimpleAllocatorT>& l, const simple_to_std_aligned_allocator_t<T2, CommonSimpleAllocatorT>& r); template <typename U> struct rebind { typedef simple_to_std_aligned_allocator_t<U, SimpleAllocatorT> other; }; explicit simple_to_std_aligned_allocator_t(SimpleAllocatorT& simple_allocator) : m_simple_allocator(simple_allocator) { //GIE_DEBUG_TRACE_INOUT(); }; template <class U> simple_to_std_aligned_allocator_t(const simple_to_std_aligned_allocator_t<U, SimpleAllocatorT>& other) : simple_to_std_aligned_allocator_t(other.m_simple_allocator) { //GIE_DEBUG_TRACE_INOUT(); } void write_extra_(void * const buffer, size_t const data_size, unsigned char b1, unsigned char b2)const{ assert(buffer); unsigned char * const p = static_cast<unsigned char*>(buffer); p[data_size] = b1; p[data_size+1] = b2; } std::pair<unsigned int, unsigned int> read_extra_(void * const buffer, size_t const data_size)const{ assert(buffer); unsigned char * const p = static_cast<unsigned char*>(buffer); return {p[data_size], p[data_size+1]}; }; const size_t extra_size = 2; // [marker][alignment padding] T* allocate(std::size_t n)const{ //GIE_DEBUG_LOG("Allocating "<<n*sizeof( T )<< " bytes"); static_assert( alignof(T) <= std::numeric_limits<unsigned char>::max() ); auto const data_size_in_bytes = n * sizeof( T ); auto const buffer_in_bytes_plus_alignment_overhead = data_size_in_bytes + alignof(T); auto const buffer_in_bytes_plus_extra = buffer_in_bytes_plus_alignment_overhead + extra_size; void * const buffer = m_simple_allocator.allocate(buffer_in_bytes_plus_extra); auto p = buffer; auto sz = buffer_in_bytes_plus_alignment_overhead; p = std::align(alignof(T), data_size_in_bytes, p, sz); assert( p ); if(p==buffer){ write_extra_(buffer, data_size_in_bytes, alloc_marker_no_alignment_overhead, 0); return static_cast< T* >( buffer ); } else { auto const diff = buffer_in_bytes_plus_alignment_overhead - sz; assert(diff<=std::numeric_limits<unsigned char>::max()); write_extra_(p, data_size_in_bytes, alloc_marker_alignment_overhead_in_next_byte, diff); return static_cast< T* >( p ); } } void deallocate(T* p, std::size_t n)const{ //GIE_DEBUG_LOG("Deallocating "<<n*sizeof( T )<< " bytes"); auto const data_size_in_bytes = n * sizeof( T ); auto const buffer_in_bytes_plus_alignment_overhead = data_size_in_bytes + alignof(T); auto const buffer_in_bytes_plus_extra = buffer_in_bytes_plus_alignment_overhead + extra_size; auto const& extra = read_extra_(p,data_size_in_bytes); assert( (extra.first==alloc_marker_no_alignment_overhead) || (extra.first==alloc_marker_alignment_overhead_in_next_byte) ); //memory corrupted on assert if(extra.first==alloc_marker_no_alignment_overhead){ m_simple_allocator.deallocate(p, buffer_in_bytes_plus_extra); } else if(extra.first==alloc_marker_alignment_overhead_in_next_byte) { assert(extra.second<=std::numeric_limits<unsigned char>::max()); auto const corrected_pointer = static_cast<unsigned char*>(static_cast<void*>(p)) - extra.second; m_simple_allocator.deallocate(corrected_pointer, buffer_in_bytes_plus_extra); } } template <class TT, class... Args> TT* alloc_(Args&& ...args)const{ return gie::construct_new<TT>(*this, std::forward<Args>(args)...); } template <class TT> void dealloc_(TT* const p)const { gie::destroy_free(*this, p); } private: SimpleAllocatorT& m_simple_allocator; }; template <class SimpleAllocatorT> struct simple_to_std_aligned_allocator_t<void,SimpleAllocatorT> { typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template <typename T1, typename T2> friend struct simple_to_std_aligned_allocator_t; template <class T1, class T2, class CommonSimpleAllocatorT> friend bool operator==(const simple_to_std_aligned_allocator_t<T1, CommonSimpleAllocatorT>& l, const simple_to_std_aligned_allocator_t<T2, CommonSimpleAllocatorT>& r); template <class T1, class T2, class CommonSimpleAllocatorT> friend bool operator!=(const simple_to_std_aligned_allocator_t<T1, CommonSimpleAllocatorT>& l, const simple_to_std_aligned_allocator_t<T2, CommonSimpleAllocatorT>& r); explicit simple_to_std_aligned_allocator_t(SimpleAllocatorT& simple_allocator) : m_simple_allocator(simple_allocator) { }; template <class U> simple_to_std_aligned_allocator_t(simple_to_std_non_aligned_allocator_t<U, SimpleAllocatorT>const & other) : simple_to_std_aligned_allocator_t(other.m_simple_allocator) { } template <typename U> struct rebind { typedef simple_to_std_aligned_allocator_t<U, SimpleAllocatorT> other; }; private: SimpleAllocatorT& m_simple_allocator; }; template <class T, class U, class SimpleAllocatorT> bool operator==(const simple_to_std_aligned_allocator_t<T, SimpleAllocatorT>& l, const simple_to_std_aligned_allocator_t<U, SimpleAllocatorT>& r){ return static_cast<void*>(&l.m_simple_allocator) == static_cast<void*>(&r.m_simple_allocator); } template <class T, class U, class SimpleAllocatorT> bool operator!=(const simple_to_std_aligned_allocator_t<T, SimpleAllocatorT>& l, const simple_to_std_aligned_allocator_t<U, SimpleAllocatorT>& r){ return static_cast<void*>(&l.m_simple_allocator) != static_cast<void*>(&r.m_simple_allocator); } } //================================================================================================================================================ #endif //================================================================================================================================================
[ "igormbox@gmail.com" ]
igormbox@gmail.com
cc7e53cbb6d649c7d3f20722dd02238e7eeb6658
2241721b7a93e3353aa93e3dab5cdb94f1d4094f
/overloads/overload.cpp
57fc50aabfdaa8fc0cd84e808874ef9de5423328
[]
no_license
CedricThomas/PwnAdventure
3d4739bcf12c08c5e7c97da3c2407bbffdd4ebe7
ca019b4237954aaccb6df693550551a4b4dc4466
refs/heads/master
2022-11-11T13:13:41.696819
2020-07-01T14:49:38
2020-07-01T14:49:46
195,578,893
0
0
null
null
null
null
UTF-8
C++
false
false
1,536
cpp
#include <iostream> #include <sstream> #include "overload.hpp" bool Player::CanJump() { return true; } void Player::Chat(const char *raw) { auto ok = std::string(raw); std::istringstream iss(ok); std::string cmd; iss >> cmd; std::string arg; iss >> arg; if (cmd == "jump") m_jumpSpeed = std::atof(arg.c_str()); else if (cmd == "speed") m_walkingSpeed = std::atof(arg.c_str()); } void BearChest::AddBear(class Bear *) { printf("AddBear\n"); } void Bear::OnPrepareAttack(class Actor *) { printf("OnPrepareAttack\n"); } void BearChest::Tick(float) { printf("Tick \n"); if (m_bears.size() != 0) return; for (auto ok : m_playerTimeLeft) { printf("%f for %s\n", ok.second, ok.first.Get()->GetPlayerName()); ok.second -= 1; } } float Bear::GetAggressionRadius() { printf("GetAggressionRadius\n"); return 0.0; } bool BearChest::IsArmedStage() { printf("IsArmedStage\n"); return false; } bool BearChest::IsEliteStage() { printf("IsEliteStage\n"); return false; } bool Bear::CanBeArmed() { printf("CanUse\n"); return false; } void Bear::AttackForChest(class IPlayer *) { printf("AttackForChest\n"); } void Bear::Init() { printf("Init\n"); } class Actor *BearSpawner::Spawn() { printf("Spawn\n"); return new Bear(); } size_t BearSpawner::GetMaxActors() { printf("GetMaxActors\n"); return 2; } void BearDefendChestState::EnterState(class Actor *) { printf("EnterState\n"); }
[ "cedric.thomas@epitech.eu" ]
cedric.thomas@epitech.eu
b8a274db7ec8685fe11340f35a095b4b261d1b4a
23c7dfdfce59bd7bb9675d150f2b52b27fe1061f
/lib/pki_lookup.h
1f5ebcc1cba765c4dcf31e53a17724a4ac5b744b
[ "BSD-3-Clause" ]
permissive
chris2511/xca
6d0d0e0d277b2a13897a88c0458186dd86ec924e
96ca26cc83f0b684b36be54bb303cbcc1c415c1b
refs/heads/main
2023-09-05T16:27:54.681428
2023-09-03T19:47:49
2023-09-03T20:37:02
649,898
1,122
213
NOASSERTION
2023-09-03T20:12:55
2010-05-06T07:54:43
C++
UTF-8
C++
false
false
2,327
h
/* vi: set sw=4 ts=4: * * Copyright (C) 2020 Christian Hohnstaedt. * * All rights reserved. */ #ifndef __PKI_LOOKUP_H #define __PKI_LOOKUP_H #include <typeinfo> #include <QString> #include <QVariant> #include <QHash> #include <QDebug> #include "XcaWarningCore.h" #include "base.h" #include "sql.h" class pki_base; class pki_lookup { private: QHash<quint64, pki_base*> lookup; pki_base *get(quint64 id) const { if (id > 0 && !lookup.keys().contains(id)) qCritical("pki_lookup: ID %u not found", (unsigned)id); return lookup[id]; } public: ~pki_lookup() { flush(); } void add(QVariant id, pki_base *pki) { add(id.toULongLong(), pki); } void add(quint64 id, pki_base *pki) { if (id == 0) qCritical("pki_lookup: ID 0 not permitted"); if (!pki) qCritical("pki_lookup: Refusing to add NULL item " "with ID %u", (unsigned)id); if (lookup.keys().contains(id)) qCritical("pki_lookup: ID %u in use", (unsigned)id); lookup[id] = pki; } XSqlQuery sqlSELECTpki(QString query, QList<QVariant> values = QList<QVariant>()) { XSqlQuery q; int i, num_values = values.size(); SQL_PREPARE(q, query); for (i = 0; i < num_values; i++) q.bindValue(i, values[i]); q.exec(); XCA_SQLERROR(q.lastError()); return q; } template <class T> QList<T*> sqlSELECTpki(QString query, QList<QVariant> values = QList<QVariant>()) { XSqlQuery q = sqlSELECTpki(query, values); QList<T *> x; while (q.next()) { T *pki = lookupPki<T>(q.value(0)); if (pki) x << pki; } return x; } template <class T> T *lookupPki(QVariant v) const { quint64 id = v.toULongLong(); if (id == 0) return NULL; T *pki = dynamic_cast<T*>(get(id)); if (pki) return pki; pki_base *p = get(id); qCritical() << QString("Invalid Type of ItemId(%1) %2 %3. Expected %4.") .arg(id).arg(typeid(p).name()) .arg("") //p ? p->getIntName() : "<NULL item>") .arg(typeid(T*).name()); return NULL; } template <class T> QList<T *> getAll() const { QList<T *> result; foreach(pki_base *pki, lookup.values()) { T *p = dynamic_cast<T*>(pki); if (p) result << p; } return result; } pki_base *operator[](quint64 id) const { return get(id); } void flush() { qDeleteAll(lookup); lookup.clear(); } }; #endif
[ "christian@hohnstaedt.de" ]
christian@hohnstaedt.de
7eff0c2dd3ef7db49a5df2b6f1a0c9033c1f3aad
ea18d801262e84618aff0a36c0bf6457bbbc3e21
/homework3/src/helpers/CarSystem.cpp
9ef35ec5b614fe7d61df58a41700d245a1324d10
[]
no_license
aruisdante/RBE595-Motion-Planning
34709d2245eb865e4af49e38d8240456ce94adce
263d1d704c1604605ccb4ca891bd11140c1ea268
refs/heads/master
2016-08-12T03:52:22.540046
2013-04-02T20:51:51
2013-04-02T20:51:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,939
cpp
/** * @file CarSystem.cpp * * @date Apr 2, 2013 * @author parallels * @brief \TODO */ //*********** SYSTEM DEPENDANCIES ****************// //************ LOCAL DEPENDANCIES ****************// #include<homework3/CarSystem.h> //*********** NAMESPACES ****************// using namespace homework3; CarControlSpace::CarControlSpace(const ob::StateSpacePtr &stateSpace): oc::RealVectorControlSpace(stateSpace, 2) { this->setName("CarControl"+getName()); } CarStateSpace::StateType::StateType() : CompoundStateSpace::StateType(){} double CarStateSpace::StateType::getX() const { return as<ob::RealVectorStateSpace::StateType>(0)->values[0]; } double CarStateSpace::StateType::getY() const { return as<ob::RealVectorStateSpace::StateType>(0)->values[1]; } double CarStateSpace::StateType::getTheta() const { return as<ob::RealVectorStateSpace::StateType>(0)->values[2]; } double CarStateSpace::StateType::getV() const { return as<ob::RealVectorStateSpace::StateType>(0)->values[3]; } void CarStateSpace::StateType::setX(double x) { as<ob::RealVectorStateSpace::StateType>(0)->values[0] = x; } void CarStateSpace::StateType::setY(double y) { as<ob::RealVectorStateSpace::StateType>(0)->values[1] = y; } void CarStateSpace::StateType::setTheta(double theta) { as<ob::RealVectorStateSpace::StateType>(0)->values[2] = theta; } void CarStateSpace::StateType::setV(double v) { as<ob::RealVectorStateSpace::StateType>(0)->values[3] = v; } CarStateSpace::CarStateSpace() : CompoundStateSpace() { this->setName("CarSpace"+getName()); this->addSubspace(ob::StateSpacePtr(new ob::RealVectorStateSpace(4)), 1.0); this->lock(); } void CarStateSpace::setBounds(const ob::RealVectorBounds &bounds) { as<ob::RealVectorStateSpace>(0)->setBounds(bounds); } const ob::RealVectorBounds& CarStateSpace::getBounds() const { return as<ob::RealVectorStateSpace>(0)->getBounds(); }
[ "adampanzica@gmail.com" ]
adampanzica@gmail.com
f6cb235cae5c35ff5eac237168fde39d5f55bee1
8ac12c56f8d01c45613c4afdbf165128d6f84cb3
/src/client/shell/test/stress/stressm.cpp
03eec24011d3380bfbb07a1752640d2ea0bf8030
[]
no_license
Nojus2001/microsoft_zone_internetgames
1f7d813edb3a0e39d0c7432e8c2f73b46183e0ab
d6f83127d287a5ea46a8f4b36351b2a2389393cd
refs/heads/master
2020-06-30T00:54:19.197556
2019-08-04T18:58:01
2019-08-04T18:58:01
200,671,380
2
1
null
2019-08-05T14:27:36
2019-08-05T14:27:35
null
UTF-8
C++
false
false
8,759
cpp
#include "stdafx.h" #include <commctrl.h> #include "resource.h" #include "StressCore.h" #include <initguid.h> #include "zClient.h" #include "zClient_i.c" //#include "zProxy.h" //#include "zProxy_i.c" /////////////////////////////////////////////////////////////////////////////// // Global variable initialization /////////////////////////////////////////////////////////////////////////////// CStressCore* gpCore = NULL; // primary object IEventQueue** gppEventQueues = NULL; // pointer to list of event queues IZoneShell** gppZoneShells = NULL; TCHAR gszLanguage[16]; // language extension TCHAR gszInternalName[128]; // internal name TCHAR gszFamilyName[128]; // family name TCHAR gszGameName[128]; // game name TCHAR gszGameCode[128]; TCHAR gszServerName[128]; // server's ip address DWORD gdwServerPort = 0; // server's port DWORD gdwServerAnonymous = 0; // server's authentication HINSTANCE ghResourceDlls[32]; // resource dll array int gnResourceDlls = 0; // resource dll array count HANDLE ghEventQueue = NULL; // event queue notification event HANDLE ghQuit = NULL; DWORD gnClients = 1; HANDLE ghStressThread = NULL; DWORD gdwStressThreadID = 0; int grgnParameters[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /////////////////////////////////////////////////////////////////////////////// // Local variables /////////////////////////////////////////////////////////////////////////////// static const DWORD dwTimeOut = 0; // time for EXE to be idle before shutting down static const DWORD dwPause = 1000; // time to wait for threads to finish up /////////////////////////////////////////////////////////////////////////////// // Process Monitor /////////////////////////////////////////////////////////////////////////////// static DWORD WINAPI MonitorProc(void* pv) { CExeModule* p = (CExeModule*) pv; p->MonitorShutdown(); return 0; } LONG CExeModule::Unlock() { LONG l = CComModule::Unlock(); if (l == 0) { bActivity = true; SetEvent(hEventShutdown); // tell monitor that we transitioned to zero } return l; } void CExeModule::MonitorShutdown() { while (1) { WaitForSingleObject(hEventShutdown, INFINITE); DWORD dwWait=0; do { bActivity = false; dwWait = WaitForSingleObject(hEventShutdown, dwTimeOut); } while (dwWait == WAIT_OBJECT_0); // timed out, if no activity let's really bail if (!bActivity && m_nLockCnt == 0) { break; } } CloseHandle(hEventShutdown); PostThreadMessage(dwThreadID, WM_QUIT, 0, 0); } bool CExeModule::StartMonitor() { hEventShutdown = CreateEvent(NULL, false, false, NULL); if (hEventShutdown == NULL) return false; DWORD dwThreadID; HANDLE h = CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID); return (h != NULL); } /////////////////////////////////////////////////////////////////////////////// // Object map /////////////////////////////////////////////////////////////////////////////// CExeModule _Module; BEGIN_OBJECT_MAP(ObjectMap) END_OBJECT_MAP() /////////////////////////////////////////////////////////////////////////////// // Helper Functions /////////////////////////////////////////////////////////////////////////////// static LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2) { while (p1 != NULL && *p1 != NULL) { LPCTSTR p = p2; while (p != NULL && *p != NULL) { if (*p1 == *p) return CharNext(p1); p = CharNext(p); } p1 = CharNext(p1); } return NULL; } ///////////////////////////////////////////////////////////////////////////// // WinMain ///////////////////////////////////////////////////////////////////////////// extern "C" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmd, int nShowCmd ) { int nRet = 0; LPTSTR lpCmdLine; int i; // this line necessary for _ATL_MIN_CRT lpCmdLine = GetCommandLine(); // initialize OLE HRESULT hRes = CoInitialize(NULL); _ASSERTE(SUCCEEDED(hRes)); // initialize ATL _Module.Init(ObjectMap, hInstance ); _Module.dwThreadID = GetCurrentThreadId(); lstrcpy(gszGameCode, _T("chkr")); lstrcpy(gszServerName, _T("zmill01")); ZeroMemory( gszLanguage, sizeof(gszLanguage) ); ZeroMemory( gszInternalName, sizeof(gszInternalName) ); ZeroMemory( gszFamilyName, sizeof(gszFamilyName) ); ZeroMemory( gszGameName, sizeof(gszGameName) ); // parse command line TCHAR szTokens[] = _T("-/"); LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens); while (lpszToken != NULL) { if(lpszToken[0] >= '0' && lpszToken[0] <= '9') grgnParameters[lpszToken[0] - '0'] = zatol(lpszToken + 1); if(lpszToken[0] == _T('c') || lpszToken[0] == _T('C')) gnClients = zatol(lpszToken + 1); if(lpszToken[0] == _T('s') || lpszToken[0] == _T('S')) { lstrcpyn(gszServerName, lpszToken + 1, NUMELEMENTS(gszServerName)); for(i = 0; gszServerName[i]; i++) if(gszServerName[i] == _T(' ')) break; gszServerName[i] = _T('\0'); } if(lpszToken[0] == _T('g') || lpszToken[0] == _T('G')) { lstrcpyn(gszGameCode, lpszToken + 1, NUMELEMENTS(gszGameCode)); for(i = 0; gszGameCode[i]; i++) if(gszGameCode[i] == _T(' ')) break; gszGameCode[i] = _T('\0'); } lpszToken = FindOneOf(lpszToken, szTokens); } if(gnClients) { // initialize globals ZeroMemory( ghResourceDlls, sizeof(ghResourceDlls) ); gppEventQueues = new IEventQueue *[gnClients]; ZeroMemory(gppEventQueues, sizeof(*gppEventQueues) * gnClients); gppZoneShells = new IZoneShell *[gnClients]; ZeroMemory(gppZoneShells, sizeof(*gppZoneShells) * gnClients); // register object _Module.StartMonitor(); hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE ); _ASSERTE(SUCCEEDED(hRes)); // create event queue notification event ghEventQueue = CreateEvent( NULL, FALSE, FALSE, NULL ); ghQuit = CreateEvent(NULL, TRUE, FALSE, NULL); ASSERT( ghEventQueue && ghQuit); // start stressing CComObject<CStressCore> *p; CComObject<CStressCore>::CreateInstance(&p); ASSERT(gpCore); gpCore->Stress(); // pump messages for ( bool bContinue = true; bContinue; ) { for ( bool bFoundItem = true; bFoundItem; ) { bFoundItem = false; // process window message MSG msg; while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { if ( msg.message == WM_QUIT ) { bContinue = false; break; } else { bFoundItem = true; ::TranslateMessage( &msg ); ::DispatchMessage( &msg ); } } // process event queues for(i = 0; i < gnClients; i++) { if(gppEventQueues[i] && gppEventQueues[i]->ProcessEvents( true ) != ZERR_EMPTY ) bFoundItem = true; } } if ( bContinue ) MsgWaitForMultipleObjects( 1, &ghEventQueue, FALSE, INFINITE, QS_ALLINPUT ); } // unregister object _Module.RevokeClassObjects(); Sleep(dwPause); } // make sure StressCore thread is dead SetEvent(ghQuit); WaitForSingleObject(ghStressThread, INFINITE); // close event queues if(gppEventQueues) for(i = 0; i < gnClients; i++) if(gppEventQueues[i]) { gppEventQueues[i]->SetNotificationHandle(NULL); gppEventQueues[i]->Release(); gppEventQueues[i] = NULL; } // close event queue handler if ( ghEventQueue ) { CloseHandle( ghEventQueue ); ghEventQueue = NULL; } if ( ghQuit ) { CloseHandle( ghQuit ); ghQuit = NULL; } // destroy the shells if(gppZoneShells) for(i = 0; i < gnClients; i++) if(gppZoneShells[i]) { gppZoneShells[i]->Close(); if(gppZoneShells[i]->GetPalette()) { DeleteObject(gppZoneShells[i]->GetPalette()); gppZoneShells[i]->SetPalette(NULL); } gppZoneShells[i]->Release(); } // free resource libraries for(i = 0; i < gnResourceDlls; i++) { if ( ghResourceDlls[i] ) { FreeLibrary( ghResourceDlls[i] ); ghResourceDlls[i] = NULL; } } gnResourceDlls = 0; // release self-reference if ( gpCore ) { gpCore->Release(); gpCore = NULL; } _Module.Term(); CoUninitialize(); return nRet; }
[ "masonleeback@gmail.com" ]
masonleeback@gmail.com
80e11b30840c81720a0cc495210764a7407e45d0
a75bfdb61d2bfa20f71d2a1548188db18a8e5e6d
/UVa/482.cpp
eb984d53dcad62171f70d2917876cdb16c567435
[]
no_license
Ra1nWarden/Online-Judges
79bbe269fd35bfb1b4a5b3ea68b806fb39b49e15
6d8516bb1560f3620bdc2fc429863a1551d60e6a
refs/heads/master
2022-05-01T17:50:00.253901
2022-04-18T06:55:25
2022-04-18T06:55:25
18,355,773
0
0
null
null
null
null
UTF-8
C++
false
false
773
cpp
#include <iostream> #include <sstream> #include <vector> using namespace std; int main() { int cases; string line; cin >> cases; getline(cin, line); for(int i = 0; i < cases; i++) { if (i != 0) cout << endl; getline(cin, line); getline(cin, line); istringstream iss(line.c_str()); vector<int> indices; int eachindex; while(iss >> eachindex) indices.push_back(eachindex); getline(cin, line); vector<string> sorted(indices.size()); istringstream issfloat(line.c_str()); for(int j = 0; j < indices.size(); j++) { string eachfloat; issfloat >> eachfloat; sorted[indices[j] - 1] = eachfloat; } for(int j = 0; j < sorted.size(); j++) cout << sorted[j] << endl; } return 0; }
[ "wzh19921016@gmail.com" ]
wzh19921016@gmail.com
fb387bd5ff39f17aa62247cde86ab1bfbeed8161
c48b5a7de78029f546107d0d8ece8af38d5c6178
/Project1_Starter_Code/Token.cpp
20fdb3ff3f0e53e543c53ab7f2ef5a58d2a9d7cd
[]
no_license
mrtullis-dev/lexerlab1
5cc3201aba554cde901f22536d704d4315e99ec0
1e4f5b29de7cca2d299c031cffc724d997808efa
refs/heads/master
2023-08-07T20:38:26.666594
2021-09-22T22:43:01
2021-09-22T22:43:01
406,521,667
0
0
null
null
null
null
UTF-8
C++
false
false
1,824
cpp
#include "Token.h" Token::Token(TokenType type, std::string description, int line) { // TODO: initialize all member variables this->type = type; this->description = description; this->line = line; } std::string Token::ToString(){ return "(" + TokenToString(type) + ",\"" + description + "\","+ std::to_string(line) + ")"; }; std::string Token::TokenToString(TokenType token) { switch(type){ case COMMA: return "COMMA"; break; case PERIOD: return "PERIOD"; break; case Q_MARK: return "Q_MARK"; break; case LEFT_PAREN: return "LEFT_PAREN"; break; case RIGHT_PAREN: return "RIGHT_PAREN"; break; case MULTIPLY: return "MULTIPLY"; break; case ADD: return "ADD"; break; case COLON: return "COLON"; break; case COLON_DASH: return "COLON_DASH"; break; case RULES: return "RULES"; break; case QUERIES: return "QUERIES"; break; case FACTS: return "FACTS"; break; case SCHEMES: return "SCHEMES"; break; case ID: return "ID"; break; case STRING: return "STRING"; break; case COMMENT: return "COMMENT"; break; case UNDEFINED: return "UNDEFINED"; break; case END: return "EOF"; break; default: return "Default"; break; } }
[ "masontullis@gmail.com" ]
masontullis@gmail.com
41974d10000738ce5e2360dc0f2d02d08697f798
cccfb7be281ca89f8682c144eac0d5d5559b2deb
/base/memory/unsafe_shared_memory_pool.h
f573409c67283251dbe80de9506ad8ba025e0274
[ "BSD-3-Clause" ]
permissive
SREERAGI18/chromium
172b23d07568a4e3873983bf49b37adc92453dd0
fd8a8914ca0183f0add65ae55f04e287543c7d4a
refs/heads/master
2023-08-27T17:45:48.928019
2021-11-11T22:24:28
2021-11-11T22:24:28
428,659,250
1
0
BSD-3-Clause
2021-11-16T13:08:14
2021-11-16T13:08:14
null
UTF-8
C++
false
false
2,947
h
// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_MEMORY_UNSAFE_SHARED_MEMORY_POOL_H_ #define BASE_MEMORY_UNSAFE_SHARED_MEMORY_POOL_H_ #include <memory> #include <utility> #include <vector> #include "base/memory/ref_counted.h" #include "base/memory/unsafe_shared_memory_region.h" #include "base/synchronization/lock.h" #include "base/types/pass_key.h" namespace base { // UnsafeSharedMemoryPool manages allocation and pooling of // UnsafeSharedMemoryRegions. Using pool saves cost of repeated shared memory // allocations. Up-to 32 regions would be pooled. It is thread-safe. May return // bigger regions than requested. If a requested size is increased, all stored // regions are purged. Regions are returned to the buffer on destruction of // |SharedMemoryHandle| if they are of a correct size. class BASE_EXPORT UnsafeSharedMemoryPool : public RefCountedThreadSafe<UnsafeSharedMemoryPool> { public: // Used to store the allocation result. // This class returns memory to the pool upon destruction. class BASE_EXPORT Handle { public: Handle(PassKey<UnsafeSharedMemoryPool>, UnsafeSharedMemoryRegion region, WritableSharedMemoryMapping mapping, scoped_refptr<UnsafeSharedMemoryPool> pool); ~Handle(); // Disallow copy and assign. Handle(const Handle&) = delete; Handle& operator=(const Handle&) = delete; const UnsafeSharedMemoryRegion& GetRegion() const; const WritableSharedMemoryMapping& GetMapping() const; private: UnsafeSharedMemoryRegion region_; WritableSharedMemoryMapping mapping_; scoped_refptr<UnsafeSharedMemoryPool> pool_; }; UnsafeSharedMemoryPool(); // Disallow copy and assign. UnsafeSharedMemoryPool(const UnsafeSharedMemoryPool&) = delete; UnsafeSharedMemoryPool& operator=(const UnsafeSharedMemoryPool&) = delete; // Allocates a region of the given |size| or reuses a previous allocation if // possible. std::unique_ptr<Handle> MaybeAllocateBuffer(size_t size); // Shuts down the pool, freeing all currently unused allocations and freeing // outstanding ones as they are returned. void Shutdown(); private: friend class RefCountedThreadSafe<UnsafeSharedMemoryPool>; ~UnsafeSharedMemoryPool(); void ReleaseBuffer(UnsafeSharedMemoryRegion region, WritableSharedMemoryMapping mapping); Lock lock_; // All shared memory regions cached internally are guaranteed to be // at least `region_size_` bytes in size. size_t region_size_ GUARDED_BY(lock_) = 0u; // Cached unused regions and their mappings. std::vector<std::pair<UnsafeSharedMemoryRegion, WritableSharedMemoryMapping>> regions_ GUARDED_BY(lock_); bool is_shutdown_ GUARDED_BY(lock_) = false; }; } // namespace base #endif // BASE_MEMORY_UNSAFE_SHARED_MEMORY_POOL_H_
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
4bdfbf61a16c353e348d5f38c7de91a06a21f20c
3f209e71f2f619037c404fd7e57cf63006749b3f
/PA1_BasicDataStructures/check_brackets.cpp
37e9ac21826f7a7f8cbc01e220dc58e493bce01e
[]
no_license
vjainlion/Coursera_Data-Structures
5b7f04fea62abe9265b5bae791b8a309b485a111
9b353bb76358523ab5970301f76a08aad256aaec
refs/heads/master
2021-06-13T18:28:17.669666
2017-03-18T18:33:24
2017-03-18T18:33:24
null
0
0
null
null
null
null
BIG5
C++
false
false
2,282
cpp
/* ------------------------ Check brackets ------------------------- */ /* Input contains one string S which consists of big and small /* latin letters, digits, punctuation marks and brackets from the set []{}() /* If the code in S uses brackets correctly, output "Success" /* Otherwise, output the 1-based index of the first unmatched closing bracket /* output the 1-based index of the first unmatched opening bracket. /* ------------------------------------------------------------------*/ #include <iostream> #include <stack> #include <string> using namespace std; struct Bracket { Bracket(char type, int position): type(type), position(position) {} bool Matchc(char c) { if (type == '[' && c == ']') return true; if (type == '{' && c == '}') return true; if (type == '(' && c == ')') return true; return false; } char type; int position; }; int main() { // 經典的stack問題, 將左括號都放入stack, 遇到右括號就pop最上面的左括號檢查是否成對 string text; getline(cin, text); stack <Bracket> opening_brackets_stack; int pos; for (int position = 0; position < text.length(); ++position) { char next = text[position]; if (next == '(' || next == '[' || next == '{') { // struct型態的stack, 要push資料就要宣告成該struct型態 struct Bracket data = Bracket(next, position); opening_brackets_stack.push(data); } if (next == ')' || next == ']' || next == '}') { // opening brackets should exist first if(opening_brackets_stack.empty()){ cout << position+1 << endl; return 0; } // match if(opening_brackets_stack.top().Matchc(next)) opening_brackets_stack.pop(); // not match else{ cout << position+1 << endl; return 0; } } } if(opening_brackets_stack.empty()) cout << "Success" << endl; // 迴圈結束後stack還有東西, 代表有多餘的左括號 else cout << opening_brackets_stack.top().position+1 << endl; return 0; }
[ "jokeygeek@gmail.com" ]
jokeygeek@gmail.com
2e3ccd4e7573d3d34af48fabc940ca27f81576d1
9f2daca8b634161346cf5e6e1e46378e392b04d2
/053.指针函数正确实例1/指针函数正确实例1.cpp
8ede614c5ea404830ff2f71dc43a7d95ba119bd0
[]
no_license
DengHaiYang1234/CPlusPlus
3915b1b087ce5981185c82b19a3614dcd011d026
6476bd863d864a3a35d8236fc1d6bab77adc8198
refs/heads/master
2020-03-25T15:31:08.518148
2018-08-27T14:32:16
2018-08-27T14:32:16
143,886,884
0
0
null
null
null
null
GB18030
C++
false
false
422
cpp
#include "stdafx.h" #include <iostream> #include <cassert> using namespace std; #pragma region 指针函数正确实例1 int* search(int* a, int num); int main() { int arr[4]; for (int i = 0; i < 4; i++) cin >> arr[i]; int* ptr = search(arr, 4); cout << *ptr << endl; return 0; } int* search(int* a, int num) { for (int i = 0; i < num; i++) { if (a[i] == 0) { return &a[i]; } } } #pragma endregion
[ "429078038@qq.com" ]
429078038@qq.com
d45fdaa8883460133d67a20d1291ebc75af5c284
ef94bb6da6f93eadca46b30ff78dcd7d2e4beee3
/midi_mfc/MIDIInDevice.cpp
797fd37e716c7b61935cf8aa5f917b9b018f5c3a
[]
no_license
glocklueng/032
10cf69ef5604f993d42f787011642f62261c4473
69bb94e002867f14048c0c9907ce5731bfab5f15
refs/heads/master
2021-01-13T09:47:20.395124
2017-01-27T07:00:07
2017-01-27T07:00:07
80,231,375
1
1
null
null
null
null
UTF-8
C++
false
false
14,045
cpp
/******************************************************************************* MIDIInDevice.cpp - Implementation for CMIDIInDevice and related classes. Copyright (c) 2008 Leslie Sanford Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Contact: Leslie Sanford (jabberdabber@hotmail.com) Last modified: 01/23/2008 ******************************************************************************/ //-------------------------------------------------------------------- // Dependencies //-------------------------------------------------------------------- #include "MIDIInDevice.h" #include "midi.h" //-------------------------------------------------------------------- // Using declarations //-------------------------------------------------------------------- using midi::CMIDIInDevice; using midi::CMIDIReceiver; using midi::CMIDIInException; //-------------------------------------------------------------------- // CMIDIInHeader implementation //-------------------------------------------------------------------- // Constructor CMIDIInDevice::CMIDIInHeader::CMIDIInHeader(HMIDIIN DevHandle, LPSTR Buffer, DWORD BufferLength) : m_DevHandle(DevHandle) { // Initialize header m_MIDIHdr.lpData = Buffer; m_MIDIHdr.dwBufferLength = BufferLength; m_MIDIHdr.dwFlags = 0; // Prepare header MMRESULT Result = ::midiInPrepareHeader(DevHandle, &m_MIDIHdr, sizeof m_MIDIHdr); // If an error occurred, throw exception if(Result != MMSYSERR_NOERROR) { throw CMIDIInException(Result); } } // Destructor CMIDIInDevice::CMIDIInHeader::~CMIDIInHeader() { ::midiInUnprepareHeader(m_DevHandle, &m_MIDIHdr, sizeof m_MIDIHdr); } // Add system exclusive buffer to queue void CMIDIInDevice::CMIDIInHeader::AddSysExBuffer() { MMRESULT Result = ::midiInAddBuffer(m_DevHandle, &m_MIDIHdr, sizeof m_MIDIHdr); // If an error occurred, throw exception if(Result != MMSYSERR_NOERROR) { throw CMIDIInException(Result); } } //-------------------------------------------------------------------- // CHeaderQueue implementation //-------------------------------------------------------------------- // Constructor CMIDIInDevice::CHeaderQueue::CHeaderQueue() { ::InitializeCriticalSection(&m_CriticalSection); } // Destructor CMIDIInDevice::CHeaderQueue::~CHeaderQueue() { RemoveAll(); ::DeleteCriticalSection(&m_CriticalSection); } // Add header to queue void CMIDIInDevice::CHeaderQueue::AddHeader( CMIDIInDevice::CMIDIInHeader *Header) { ::EnterCriticalSection(&m_CriticalSection); m_HdrQueue.push(Header); ::LeaveCriticalSection(&m_CriticalSection); } // Remove header from queue void CMIDIInDevice::CHeaderQueue::RemoveHeader() { ::EnterCriticalSection(&m_CriticalSection); if(!m_HdrQueue.empty()) { delete m_HdrQueue.front(); m_HdrQueue.pop(); } ::LeaveCriticalSection(&m_CriticalSection); } // Empty header queue void CMIDIInDevice::CHeaderQueue::RemoveAll() { ::EnterCriticalSection(&m_CriticalSection); while(!m_HdrQueue.empty()) { delete m_HdrQueue.front(); m_HdrQueue.pop(); } ::LeaveCriticalSection(&m_CriticalSection); } // Determines if the header queue is empty bool CMIDIInDevice::CHeaderQueue::IsEmpty() { bool Result; ::EnterCriticalSection(&m_CriticalSection); Result = m_HdrQueue.empty(); ::LeaveCriticalSection(&m_CriticalSection); return Result; } //-------------------------------------------------------------------- // CMIDIInDevice implementation //-------------------------------------------------------------------- // Constructs CMIDIInDevice object in an closed state CMIDIInDevice::CMIDIInDevice() : m_Receiver(0), m_State(CLOSED) { // If we are unable to create signalling event, throw exception if(!CreateEvent()) { throw CMIDIInEventFailure(); } } // Constructs CMIDIInDevice object in an closed state and initializes the // MIDI receiver CMIDIInDevice::CMIDIInDevice(CMIDIReceiver &Receiver) : m_Receiver(&Receiver), m_State(CLOSED) { // If we are unable to create signalling event, throw exception if(!CreateEvent()) { throw CMIDIInEventFailure(); } } // Constructs CMIDIInDevice object in an opened state CMIDIInDevice::CMIDIInDevice(UINT DeviceId, CMIDIReceiver &Receiver) : m_Receiver(&Receiver), m_State(CLOSED) { // Open device Open(DeviceId); // If we are unable to create signalling event, throw exception if(!CreateEvent()) { Close(); throw CMIDIInEventFailure(); } } // Destruction CMIDIInDevice::~CMIDIInDevice() { // Close device Close(); // Close handle to signalling event ::CloseHandle(m_Event); } // Opens the MIDI input device void CMIDIInDevice::Open(UINT DeviceId) { // Makes sure the previous device, if any, is closed before // opening another one Close(); // Open MIDI input device MMRESULT Result = ::midiInOpen(&m_DevHandle, DeviceId, reinterpret_cast<DWORD>(MidiInProc), reinterpret_cast<DWORD>(this), CALLBACK_FUNCTION); // If we are able to open the device, change state if(Result == MMSYSERR_NOERROR) { m_State = OPENED; } // Else opening failed, throw exception else { throw CMIDIInException(Result); } } // Closes the MIDI input device void CMIDIInDevice::Close() { // If the device is recording, stop recording before closing the // device if(m_State == RECORDING) { StopRecording(); } // If the device is opened... if(m_State == OPENED) { // Close the device MMRESULT Result = ::midiInClose(m_DevHandle); // If a failure occurred, throw exception if(Result != MMSYSERR_NOERROR) { throw CMIDIInException(Result); } // Change state m_State = CLOSED; } } // Adds a buffer for receiving system exclusive messages void CMIDIInDevice::AddSysExBuffer(LPSTR Buffer, DWORD BufferLength) { CMIDIInHeader *Header; try { // Create new header Header = new CMIDIInHeader(m_DevHandle, Buffer, BufferLength); } // If memory allocation failed, throw exception catch(const std::bad_alloc &) { throw CMIDIInMemFailure(); } // If preparation for the header failed, rethrow exception catch(const CMIDIInDevice &) { throw; } try { // Add header to queue Header->AddSysExBuffer(); m_HdrQueue.AddHeader(Header); } // If we are unable to add the buffer to the queue, delete header // and throw exception catch(const CMIDIInDevice &) { delete Header; throw; } } // Starts the recording process void CMIDIInDevice::StartRecording() { // Only begin recording if the MIDI input device has been opened if(m_State == OPENED) { // Change state m_State = RECORDING; m_Thread = ::AfxBeginThread((AFX_THREADPROC)HeaderProc, this); // Start recording MMRESULT Result = ::midiInStart(m_DevHandle); // If recording attempt failed... if(Result != MMSYSERR_NOERROR) { // Revert back to opened state m_State = OPENED; // Signal the worker thread to finish ::SetEvent(m_Event); ::WaitForSingleObject(m_Thread->m_hThread, INFINITE); // Throw exception throw CMIDIInException(Result); } } } // Stops the recording process void CMIDIInDevice::StopRecording() { // If the device is in fact recording... if(m_State == RECORDING) { // Change state m_State = OPENED; // Signal the worker thread to finish ::SetEvent(m_Event); ::WaitForSingleObject(m_Thread->m_hThread, INFINITE); // Reset the MIDI input device ::midiInReset(m_DevHandle); // Empty header queue m_HdrQueue.RemoveAll(); } } // Registers the MIDI receiver. Returns the previous receiver. CMIDIReceiver *CMIDIInDevice::SetReceiver(CMIDIReceiver &Receiver) { CMIDIReceiver *PrevReceiver = m_Receiver; m_Receiver = &Receiver; return PrevReceiver; } // Determines if the MIDI input device is opened bool CMIDIInDevice::IsOpen() const { return ((m_State == OPENED) || (m_State == RECORDING)); } // Determines if the MIDI input device is recording bool CMIDIInDevice::IsRecording() const { return (m_State == RECORDING); } // Gets Id for this device UINT CMIDIInDevice::GetDevID() const { UINT DeviceID; MMRESULT Result = ::midiInGetID(m_DevHandle, &DeviceID); if(Result != MMSYSERR_NOERROR) { throw CMIDIInException(Result); } return DeviceID; } // Gets the capabilities of a particular MIDI input device void CMIDIInDevice::GetDevCaps(UINT DeviceId, MIDIINCAPS &Caps) { MMRESULT Result = ::midiInGetDevCaps(DeviceId, &Caps, sizeof Caps); // If we are not able to retrieve device capabilities, throw // exception if(Result != MMSYSERR_NOERROR) { throw CMIDIInException(Result); } } // Creates event for signalling header thread bool CMIDIInDevice::CreateEvent() { bool Result = true; m_Event = ::CreateEvent(NULL, FALSE, FALSE, NULL); // If event creation failed, record failure if(m_Event == NULL) { Result = false; } return Result; } // Called by Windows when a MIDI input event occurs void CALLBACK CMIDIInDevice::MidiInProc(HMIDIIN MidiIn, UINT Msg, DWORD_PTR Instance, DWORD_PTR Param1, DWORD_PTR Param2) { CMIDIInDevice *Device; Device = reinterpret_cast<CMIDIInDevice *>(Instance); if(Device->m_Receiver != 0) { switch(Msg) { case MIM_DATA: // Short message received Device->m_Receiver->ReceiveMsg(Param1, Param2); break; case MIM_ERROR: // Invalid short message received Device->m_Receiver->OnError(Param1, Param2); break; case MIM_LONGDATA: // System exclusive message received if(Device->m_State == RECORDING) { // Retrieve data, send it to receiver, and notify header // thread that we are done with the system exclusive // message MIDIHDR *MidiHdr = reinterpret_cast<MIDIHDR *>(Param1); Device->m_Receiver->ReceiveMsg(MidiHdr->lpData, MidiHdr->dwBytesRecorded, Param2); ::SetEvent(Device->m_Event); } break; case MIM_LONGERROR: // Invalid system exclusive message received if(Device->m_State == RECORDING) { // Retrieve data, send it to receiver, and notify header // thread that we are done with the system exclusive // message MIDIHDR *MidiHdr = reinterpret_cast<MIDIHDR *>(Param1); Device->m_Receiver->OnError(MidiHdr->lpData, MidiHdr->dwBytesRecorded, Param2); ::SetEvent(Device->m_Event); } break; } } } // Header worker thread DWORD CMIDIInDevice::HeaderProc(LPVOID Parameter) { CMIDIInDevice *Device; Device = reinterpret_cast<CMIDIInDevice *>(Parameter); // Continue while the MIDI input device is recording while(Device->m_State == RECORDING) { ::WaitForSingleObject(Device->m_Event, INFINITE); // Make sure we are still recording if(Device->m_State == RECORDING) { // Remove the finished header Device->m_HdrQueue.RemoveHeader(); } } return 0; }
[ "charliex@47c6005b-331e-4be2-8628-a174f3e7207f" ]
charliex@47c6005b-331e-4be2-8628-a174f3e7207f
636fdb9c6377a9fa37629410eec052b0788491ab
b6d142e1b286c229460f03a97a39903e2603bac8
/OOP/C-plus-plus-master/Exercises 1/Bai1.9.cpp
1ac5e89d05f45bc91e84125d30614b611602c3c5
[]
no_license
PhamKhoa96/DataStructure_Algorithm
a782752767776a0f5dc0e667341cf93c7d0ac20e
36f975f0c9df73489233540794cc0342aeebe453
refs/heads/master
2023-01-05T22:50:29.840029
2020-11-05T17:25:21
2020-11-05T17:25:21
302,213,441
0
0
null
2020-11-05T17:25:22
2020-10-08T02:37:11
C++
UTF-8
C++
false
false
942
cpp
#include "pch.h" #include <iostream> #include <cmath> using namespace std; int main() { float a, b, c; float x1, x2; cout << "Nhap he so a, b, c: "; cin >> a >> b >> c; if (a == 0) { // giai phuong trinh bac 1 if (b == 0 && c == 0) { cout << "Phuong trinh co vo so nghiem!" << endl; } else if (b == 0 && c != 0) { cout << "Phuong trinh vo nghiem" << endl; } else { float ketQua = -c * 1.0 / b; cout << "Nghiem phuong trinh " << b << "x" << " + " << c << " = 0 la: x= " << ketQua << endl; } } else { float delta = b * b - 4 * a*c; if (delta < 0) { cout << "Phuong trinh vo nghiem" << endl; } else if (delta == 0) { cout << "Phuong trinh co nghiem kep x = " << -b / (2 * a) << endl; } else { x1 = -b + sqrt(delta) / (2 * a); x2 = -b - sqrt(delta) / (2 * a); cout << "Nghiem phuong trinh la: \n" << "x1 = " << x1 << endl << "x2 = " << x2 << endl; } } return 0; }
[ "=" ]
=
5ae9c2667f51efbeba94d0f43fbf26ad913d48c3
6052c551a54f4db0da2d399bd8c842a28e86b2a8
/src/net/Acceptor.h
d1663cddb070f3101d6fb7f2cf8fd02b0863a36f
[]
no_license
xuefeng529/utils
232372b612c596ffd45d8ffbb2958dc311e59c4d
233474c7bcfb466f5511cd8dd638e74520a52fe6
refs/heads/master
2022-12-13T18:09:28.785793
2022-12-05T05:59:15
2022-12-05T05:59:15
64,121,638
7
1
null
null
null
null
UTF-8
C++
false
false
940
h
#ifndef NET_ACCEPTOR_H #define NET_ACCEPTOR_H #include "net/InetAddress.h" #include <boost/noncopyable.hpp> #include <boost/function.hpp> struct evconnlistener; namespace net { class EventLoop; class Acceptor : boost::noncopyable { public: typedef boost::function <void(int sockfd, const InetAddress&)> NewConnectionCallback; Acceptor(EventLoop* loop, const InetAddress& listenAddr); ~Acceptor(); void setNewConnectionCallback(const NewConnectionCallback& cb) { newConnectionCallback_ = cb; } void listen(); private: static void handleAccept(struct evconnlistener *listener, int fd, struct sockaddr *sa, int socklen, void *ctx); static void handleAcceptError(struct evconnlistener *listener, void *ctx); EventLoop* loop_; const InetAddress listenAddr_; struct evconnlistener* listener_; NewConnectionCallback newConnectionCallback_; }; } // namespace net #endif // NET_ACCEPTOR_H
[ "113436761@qq.com" ]
113436761@qq.com
b14148bc8f1dd95e762e7c4b913e3b188868f409
2211758d49789c6db188bb9492d98cb549a6a80c
/huffman.cpp
12e5f94c4c934b76cd0ad9230b8135d796fea3ad
[ "MIT" ]
permissive
rexagod/huffman-coding
a64c8a2884c9e9170b54cfba6f3f15c837b6fe8f
48eb29f91ef48646725d6e4d5c94e67ff0ccec04
refs/heads/master
2022-07-18T00:33:03.507958
2020-05-20T16:47:59
2020-05-20T16:47:59
265,626,586
0
0
null
null
null
null
UTF-8
C++
false
false
10,726
cpp
#include <bits/stdc++.h> #include <windows.h> #include <conio.h> using namespace std; map<char, string> Huffman_codes; map<string, char> canonical_codes; int arr[500]; void makezero() { for (int i = 0; i < 500; i++) { arr[i] = 0; } } int x = 55, y = 30; int gl = 1; int ecdsize = 0; int osize = 0; void welcome(); void HuffmanCodes(vector<char> data, vector<int> freq, int size); void get_frequency(string text, vector<char> &ch, vector<int> &freq); void printCodes(struct MinHeapNode *root, string str); string encode(string text); void gotoxy(int x, int y); void get_canonical_codes(); void printint(vector<int> &freq); void printch(vector<char> &ch); void gotoxy(int x, int y) { COORD c; c.X = x; c.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c); } struct MinHeapNode { char data; unsigned freq; MinHeapNode *left, *right; MinHeapNode(char data, unsigned freq) { left = right = NULL; this -> data = data; this -> freq = freq; } }; struct compare { bool operator()(MinHeapNode *l, MinHeapNode *r) { return (l -> freq > r -> freq); } }; void get_frequency(string text, vector<char> &ch, vector<int> &freq) { for (int j = 0; j < text.size(); j++) { int num = tolower(text[j]); int r = toascii(num); arr[r] = arr[r] + 1; } for (int i = 0; i < text.size(); ++i) { if (find(ch.begin(), ch.end(), text[i]) == ch.end()) { ch.push_back(text[i]); freq.push_back(1); continue; } int index = distance(ch.begin(), find(ch.begin(), ch.end(), text[i])); ++freq[index]; } return; } void HuffmanCodes(vector<char> data, vector<int> freq, int size) { struct MinHeapNode *left, *right, *top; priority_queue<MinHeapNode *, vector<MinHeapNode *>, compare> minHeap; for (int i = 0; i < size; ++i) minHeap.push(new MinHeapNode(data[i], freq[i])); while (minHeap.size() != 1) { // These two extracted nodes will be the left and right children left = minHeap.top(); minHeap.pop(); right = minHeap.top(); minHeap.pop(); // Create a new internal node with frequency equal to the sum of the // two nodes' frequencies // Add this node to the min heap // '$' is a special value for internal nodes that are not used top = new MinHeapNode('$', left -> freq + right -> freq); top -> left = left; top -> right = right; minHeap.push(top); } printCodes(minHeap.top(), ""); } string do_padding(unsigned index, unsigned mlength) { string padding; if (int((index - 1) / 2) != 0) { return (int((index - 1) / 2) % 2 == 0) ? (do_padding(int((index - 1) / 2), mlength) + string(mlength + 4, ' ') + " ") : (do_padding(int((index - 1) / 2), mlength) + string(mlength + 3, ' ') + " |"); } return padding; } void printer(vector<char> const &tree, unsigned index, unsigned mlength) { auto last = tree.size() - 1; auto left = 2 * index + 1; auto right = 2 * index + 2; cout << " " << tree[index] << " "; if (left <= last) { auto llength = to_string(tree[left]).size(); cout << "---" << string(mlength - llength, '-'); printer(tree, left, mlength); if (right <= last) { auto rlength = to_string(tree[right]).size(); cout << "\n" << do_padding(right, mlength) << string(mlength + 3, ' ') << " | "; cout << "\n" << do_padding(right, mlength) << string(mlength + 3, ' ') << " |-" << string(mlength - rlength, '-'); printer(tree, right, mlength); } } } void print_tree(vector<char> &tree) { unsigned mlength = 0; for (char &element : tree) { auto clength = to_string(element).size(); if (clength > mlength) { mlength = to_string(element).size(); } } cout << string(mlength - to_string(tree[0]).size(), ' '); printer(tree, 0, mlength); } void printCodes(struct MinHeapNode *root, string str) { if (!root) return; if (root -> data != '$') { int n = tolower(root -> data); int rs = toascii(n); int pr = arr[rs] * str.size(); ecdsize = ecdsize + pr; osize = osize + arr[rs]; cout << root -> data << ": " << str << "\n"; gotoxy(x, y++); Huffman_codes[root -> data] = str; } printCodes(root -> left, str + "0"); printCodes(root -> right, str + "1"); } string encode(string text) { int i = 0; string encoded_text; for (i = 0; i < text.size(); i++) { encoded_text += Huffman_codes[text[i]]; } return encoded_text; } void get_canonical_codes() { char temp; string temp_str; int i = 0; map<char, string>::iterator it = Huffman_codes.begin(); for (i = 0; i < Huffman_codes.size(); i++) { temp = it -> first; temp_str = it -> second; canonical_codes[temp_str] = temp; it++; } return; } string get_text(string encoded_text) { int start, length; string decoded_text = ""; start = 0; length = 1; while (start + length <= encoded_text.size()) { string current = encoded_text.substr(start, length); if (canonical_codes.find(current) != canonical_codes.end()) { decoded_text += canonical_codes[current]; start += length; length = 1; continue; } ++length; } return decoded_text; } void delay() { int i = 0, j = 0; for (i = 0; i < 10000; i++) { for (j = 0; j < 1000; j++) { } } return; } void printch(vector<char> &ch) { cout << endl; int i; for (i = 0; i < ch.size(); i++) { cout << ch[i] << " "; } cout << endl; return; } void printint(vector<int> &freq) { cout << endl; int i; for (i = 0; i < freq.size(); i++) { cout << freq[i] << " "; } cout << endl; return; } void welcome() { gotoxy(50, 10); cout << "| | "; delay(); cout << "| | "; delay(); cout << ("|= "); delay(); cout << ("|= "); delay(); cout << ("|\\/| "); delay(); cout << ("/\\ "); delay(); cout << ("|\\ | "); delay(); cout << (" / "); delay(); cout << ("_ "); delay(); cout << ("|\\ "); delay(); cout << ("_ _ "); delay(); cout << ("|\\ | "); delay(); cout << (" _ "); delay(); cout << endl; gotoxy(50, 11); // second line cout << ("|_| "); delay(); cout << ("| | "); delay(); cout << ("|= "); delay(); cout << ("|= "); delay(); cout << ("| | "); delay(); cout << ("/__\\ "); delay(); cout << ("| \\ | "); delay(); cout << ("| "); delay(); cout << ("|\\ | "); delay(); cout << ("| | "); delay(); cout << ("| "); delay(); cout << ("| \\ | "); delay(); cout << ("| _ "); delay(); cout << endl; gotoxy(50, 12); // third line cout << ("| | "); delay(); cout << ("|_| "); delay(); cout << ("| "); delay(); cout << ("| "); delay(); cout << ("| | "); delay(); cout << ("/ \\ "); delay(); cout << ("| \\| "); delay(); cout << (" \\ "); delay(); cout << ("|_\\| "); delay(); cout << ("|/ "); delay(); cout << ("_|_ "); delay(); cout << ("| \\| "); delay(); cout << ("|_| | "); delay(); cout << endl; return; } int main() { cout << "NOTE: 'input.txt' CONTAINS THE INPUT STRING." << endl; cout << "\t'input.txt' AND 'huffman.cpp' MUST BE IN THE SAME DIRECTORY." << endl; cout << "\tAN 'encoded.txt' FILE CONTAINING THE ENCODED DATA WILL ALSO BE CREATED IN THE SAME DIRECTORY." << endl; cout << "\tA 'output.txt' FILE CONTAINING THE DECODED DATA WILL ALSO BE CREATED IN THE SAME DIRECTORY." << endl; system("COLOR 47"); welcome(); string line; string text; ifstream file; string filename = "input.txt"; file.open(filename); while (getline(file, line)) { text = text + " " + line; } file.close(); cout << endl; string encoded_text; cout << text << endl; vector<char> ch; vector<int> freq; makezero(); get_frequency(text, ch, freq); cout << "Press Any KEY to print the frequencies of different characters." << endl; if (cin.get()) { cout << endl; printch(ch); printint(freq); } int size = ch.size(); cout << "Press Any KEY to print Huffman codes of different characters." << endl; if (cin.get()) { cout << endl; gotoxy(x, y); HuffmanCodes(ch, freq, size); } gotoxy(0, y); print_tree(ch); cout<<endl; cout << "Press Any KEY to print the encoded and decoded text." << endl; if (cin.get()) { encoded_text = encode(text); cout << endl; cout << "Encoded text: "; cout << endl << encoded_text << endl; ofstream encode("encoded.txt"); encode << encoded_text; encode.close(); } get_canonical_codes(); string decoded_text; cout << endl; cout << "Decoded text"; decoded_text = get_text(encoded_text); cout << endl << decoded_text << endl; int z = osize * 8; cout << endl; cout << "The size of the original text file is approx. ( assuming each " "character " << endl; cout << "takes 8 bits so total bits = 8 * number of characters) - " << z / 8 << " bytes" << endl; cout << endl; cout << "The size of the encoding is (assuming each encoded 1/0" << endl; cout << "represents 1 bit so total size in bits = size of encoding) - " << ecdsize / 8 << " bytes" << endl; cout << endl; cout << "Therefore, Huffman coding can be used for compression." << endl; ofstream decode("output.txt"); decode << decoded_text; decode.close(); return 0; }
[ "rexagod@gmail.com" ]
rexagod@gmail.com
fd7492e6c69cab2517279b0064e010490acaca64
dc35372d59f303c0a086e21d114b39832f60cbe9
/tensorflow/compiler/mlir/hlo/lib/Dialect/mhlo/transforms/unfuse_batch_norm.cc
69fa757ced235030a705711e013e01fa9f62cf85
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause" ]
permissive
dongAxis/tensorflow
3f048e0d3f5196dc323b829242dbfd5288198f2d
a89e2c0b7ceb1299d191138e873249bc245bf661
refs/heads/master
2022-02-28T00:12:00.355043
2022-02-23T02:41:35
2022-02-23T02:45:35
462,568,457
1
0
Apache-2.0
2022-02-23T03:34:47
2022-02-23T03:34:46
null
UTF-8
C++
false
false
7,673
cc
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "llvm/ADT/SmallVector.h" #include "mlir-hlo/Dialect/mhlo/IR/hlo_ops.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/MLIRContext.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/Types.h" #include "mlir/Transforms/DialectConversion.h" namespace mlir { namespace mhlo { namespace { // Broadcasts the 1D value tensor 'value_1d' to the shape of 'result_type'. If // 'shape_value' is initialized, creates a dynamic broadcast, otherwise creates // a static broadcast. Value BroadcastToFeatureDim(Location loc, RankedTensorType result_type, Value value_1d, Value shape_value, int64_t feature_dim, PatternRewriter& rewriter) { // NOLINT Builder b(rewriter.getContext()); auto dims_type = RankedTensorType::get({1}, b.getIntegerType(64)); auto dims = DenseIntElementsAttr::get(dims_type, {feature_dim}); if (shape_value) { return rewriter.createOrFold<mhlo::DynamicBroadcastInDimOp>( loc, result_type, value_1d, shape_value, dims); } assert(result_type.hasStaticShape()); return rewriter.create<mhlo::BroadcastInDimOp>(loc, result_type, value_1d, dims); } // Calculate the shape value of operand, assuming it is a dynamic shape with // static rank. Value CalculateShapeValue(Location loc, Value operand, PatternRewriter& rewriter) { // NOLINT RankedTensorType result_type = operand.getType().dyn_cast<RankedTensorType>(); llvm::SmallVector<Value, 4> shape_values; int64_t rank = result_type.getRank(); shape_values.reserve(rank); for (int64_t i = 0; i < rank; ++i) { shape_values.push_back( rewriter.create<mlir::tensor::DimOp>(loc, operand, i)); } return rewriter.create<tensor::FromElementsOp>(loc, shape_values); } Value MaterializeEpsilon(Operation* op, FloatAttr epsilon_attr, FloatType fp_type, Value variance, RankedTensorType broadcast_to_type, PatternRewriter& rewriter) { // NOLINT Builder b(rewriter.getContext()); if (epsilon_attr.getType() != fp_type) { // Need to convert. bool loses_info; APFloat epsilon_float = epsilon_attr.getValue(); auto status = epsilon_float.convert( fp_type.getFloatSemantics(), APFloat::rmNearestTiesToEven, &loses_info); if ((status & (~APFloat::opInexact)) != APFloat::opOK) { op->emitWarning() << "Could not convert batch_norm epsilon to target fp " "type: opStatus = " << static_cast<int>(status); return nullptr; } if (loses_info) { op->emitWarning("Conversion of epsilon loses precision"); } epsilon_attr = b.getFloatAttr(fp_type, epsilon_float); } auto scalar_type = RankedTensorType::get({}, fp_type); auto epsilon_tensor_attr = DenseElementsAttr::get(scalar_type, {epsilon_attr.cast<Attribute>()}); Value epsilon = rewriter.create<mhlo::ConstOp>(op->getLoc(), epsilon_tensor_attr); auto dims_type = RankedTensorType::get({0}, b.getIntegerType(64)); auto dims = DenseIntElementsAttr::get(dims_type, SmallVector<int64_t, 1>{}); if (broadcast_to_type.hasStaticShape()) { return rewriter.create<mhlo::BroadcastInDimOp>( op->getLoc(), broadcast_to_type, epsilon, /*broadcast_dims=*/dims); } Value shape_value = CalculateShapeValue(op->getLoc(), variance, rewriter); return rewriter.createOrFold<mhlo::DynamicBroadcastInDimOp>( op->getLoc(), broadcast_to_type, epsilon, shape_value, /*broadcast_dims=*/dims); } class UnfuseBatchNormInferencePattern : public OpRewritePattern<mhlo::BatchNormInferenceOp> { public: using OpRewritePattern<mhlo::BatchNormInferenceOp>::OpRewritePattern; LogicalResult matchAndRewrite(mhlo::BatchNormInferenceOp bn_op, PatternRewriter& rewriter) const override { // Enforce type invariants. // Note that we deduce the actual element type from the variance, // which should not be subject to quantization at a higher level. auto input_type = bn_op.operand().getType().dyn_cast<RankedTensorType>(); auto variance_type = bn_op.variance().getType().dyn_cast<RankedTensorType>(); if (!input_type || !variance_type) { return failure(); } auto fp_type = variance_type.getElementType().dyn_cast<FloatType>(); if (!fp_type) { return failure(); } int64_t feature_dim = bn_op.feature_index(); // Add epsilon to the variance and sqrt to get stddev: // stddev = sqrt(variance + epsilon) auto epsilon = MaterializeEpsilon(bn_op.getOperation(), bn_op.epsilonAttr(), fp_type, bn_op.variance(), variance_type, rewriter); if (!epsilon) { return failure(); } Value stddev = rewriter.create<mhlo::AddOp>(bn_op.getLoc(), bn_op.variance(), epsilon); stddev = rewriter.create<mhlo::SqrtOp>(bn_op.getLoc(), stddev); // Broadcast all terms. Value shape_value; if (!input_type.hasStaticShape()) { shape_value = CalculateShapeValue(bn_op.getLoc(), bn_op.operand(), rewriter); } auto broadcast_scale = BroadcastToFeatureDim(bn_op.getLoc(), input_type, bn_op.scale(), shape_value, feature_dim, rewriter); auto broadcast_offset = BroadcastToFeatureDim(bn_op.getLoc(), input_type, bn_op.offset(), shape_value, feature_dim, rewriter); auto broadcast_mean = BroadcastToFeatureDim(bn_op.getLoc(), input_type, bn_op.mean(), shape_value, feature_dim, rewriter); auto broadcast_stddev = BroadcastToFeatureDim( bn_op.getLoc(), input_type, stddev, shape_value, feature_dim, rewriter); // Compute: // scale * (input - mean) / stddev + offset Value result = rewriter.create<mhlo::SubOp>(bn_op.getLoc(), bn_op.operand(), broadcast_mean); result = rewriter.create<mhlo::MulOp>(bn_op.getLoc(), result, broadcast_scale); result = rewriter.create<mhlo::DivOp>(bn_op.getLoc(), result, broadcast_stddev); rewriter.replaceOpWithNewOp<mhlo::AddOp>(bn_op, result, broadcast_offset); return success(); } }; } // namespace // Populates conversion patterns to unfuse batch normalization operations. // In combination with marking such ops as illegal, this allows backends that // do not have special support for fused batchnorm to use simpler arithmetic // primitives. void PopulateUnfuseBatchNormPatterns(MLIRContext* context, RewritePatternSet* patterns) { patterns->add<UnfuseBatchNormInferencePattern>(context); } } // namespace mhlo } // namespace mlir
[ "gardener@tensorflow.org" ]
gardener@tensorflow.org
a646807c26e1de68346d40c3c3b72d732f00f212
8f6bb931bb993893f8a102c50306b2b134f7b559
/include/TCPServer.h
1ead7f028f89b4a771358ff631ede0f4945fe24a
[]
no_license
gavanderhoorn/smart5six_gazebo_plugin
ee3e54b945d474d01d0aa2b29afddf9ac02f5ab3
2a2e732936b408d3c086c43b5faccc8226b64eb3
refs/heads/master
2021-01-13T10:35:05.613890
2015-03-11T10:33:16
2015-03-11T10:33:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,035
h
#ifndef TCPSERVER_H #define TCPSERVER_H #include <ros/ros.h> #include <sensor_msgs/JointState.h> #include <std_msgs/Float64.h> #include <boost/thread.hpp> #include <boost/bind.hpp> #include "smart5six_gazebo_plugin/endEffectorPosition.h" #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <math.h> #include <stdint.h> #define pack754_32(f) (pack754((f), 32, 8)) #define pack754_64(f) (pack754((f), 64, 11)) #define RAD2DEG 57.295779513 /** * This class receives ROS messages and forwards their values through a TCP packet */ class TCPServer { public: /** * TCPServer class constructor */ TCPServer(); /** * TCPServer class destructor */ ~TCPServer(); /** * This callback method receives a jointState message and sends its values through a TCP packet * @param jointState is the JointState message containing the angle value of each joint (in radians) */ void jointsAnglesCB(const sensor_msgs::JointState::ConstPtr &jointState); /** * This callback method receives a endEffectorPosition message and sends its values through a TCP packet * @param positionMsg is the endEffectorPosition custom message containing the x, y and z position and the three Euler angles */ void endEffectorPositionCB(const smart5six_gazebo_plugin::endEffectorPosition::ConstPtr &positionMsg); private: long double fnorm; int shift, listenfd, connfd; long long sign, exp, significand; unsigned significandbits; double values[6]; uint64_t number, packetNum; char modalityChar; struct sockaddr_in serv_addr, client_addr; char sendBuff[sizeof (number) * 7 + sizeof (modalityChar)]; //1 long for packet number + 6 double for joints angles/end-effector position + 1 char for modality + uint64_t pack754(long double f, unsigned bits, unsigned expbits) { significandbits = bits - expbits - 1; // -1 for sign bit if (f == 0.0) return 0; // get this special case out of the way // check sign and begin normalization if (f < 0) { sign = 1; fnorm = -f; } else { sign = 0; fnorm = f; } // get the normalized form of f and track the exponent shift = 0; while (fnorm >= 2.0) { fnorm /= 2.0; shift++; } while (fnorm < 1.0) { fnorm *= 2.0; shift--; } fnorm = fnorm - 1.0; // calculate the binary form (non-float) of the significand data significand = fnorm * ((1LL << significandbits) + 0.5f); // get the biased exponent exp = shift + ((1 << (expbits - 1)) - 1); // shift + bias // return the final answer return (sign << (bits - 1)) | (exp << (bits - expbits - 1)) | significand; } }; #endif /* TCPSERVER_H */
[ "elisatosello@gmail.com" ]
elisatosello@gmail.com
fb5f3bf477c7193afa631227833a14914b80981d
02eaeecc510492a7bc5d9f6b7d09b29d6053a15b
/include/typelist.hpp
64d12567c0fc2d277a75d71a1b0782c01f2f5df6
[ "MIT" ]
permissive
matrixjoeq/candy
a5160e3dbbb76ce0674580222abab0e837039254
53fe18d8b68d2f131c8e1c8f76c7d9b7f752bbdc
refs/heads/master
2020-07-09T14:28:40.908162
2020-02-11T08:58:18
2020-02-11T08:58:18
203,995,650
0
0
null
null
null
null
UTF-8
C++
false
false
795
hpp
#pragma once #include "typelist/accumulate.hpp" #include "typelist/all_of.hpp" #include "typelist/any_of.hpp" #include "typelist/at.hpp" #include "typelist/back.hpp" #include "typelist/concat.hpp" #include "typelist/count.hpp" #include "typelist/empty.hpp" #include "typelist/erase.hpp" #include "typelist/find.hpp" #include "typelist/front.hpp" #include "typelist/insert.hpp" #include "typelist/merge.hpp" #include "typelist/none_of.hpp" #include "typelist/pop_back.hpp" #include "typelist/pop_front.hpp" #include "typelist/push_back.hpp" #include "typelist/push_front.hpp" #include "typelist/remove.hpp" #include "typelist/replace.hpp" #include "typelist/reverse.hpp" #include "typelist/size.hpp" #include "typelist/sort.hpp" #include "typelist/transform.hpp" #include "typelist/unique.hpp"
[ "xqu@telenav.cn" ]
xqu@telenav.cn
5b2216c0299a03ff62de864f499bd902b9585969
11eea8da1b414871e0f8608dd61ee543e81b4b19
/P1873.cpp
41b646fc66c463def25727b8f0b69e09ba902424
[]
no_license
Tomistong/MyLuoguRepo
57ed57ad504978f7402bd1bbeba30b2f4ae32a22
5dfe5e99b0909f9fe5416d5eaad01f368a2bf891
refs/heads/master
2023-08-29T05:18:29.981970
2021-10-06T04:23:02
2021-10-06T04:23:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
582
cpp
#include <bits/stdc++.h> using namespace std; int n=0,m=0,arr[1000020]; int isOk(int num){ long long add = 0; for(int i=0;i<n;i++){ add+=((arr[i]>num)?((long long)(arr[i]-num)):0); } return add>=m; } int main() { cin >> n >> m; for(int i=0;i<n;i++){ cin >> arr[i]; } int start=1,end=100000000; while(start!=end-1){ int tmp =((start+end)>>1); if(isOk(tmp)){ start=tmp; }else{ end=tmp; } } cout << start; system("pause"); return 0; }
[ "wumingyun2120@outlook.com" ]
wumingyun2120@outlook.com
d0a999646e3fc8a23d69c87ce2bb33053d53975f
f9fb35ea2374952c72e6f556ae31636188131ce8
/threaded.cpp
09d0c536700b6ab4b0e910bc75f01b7cfebf1912
[]
no_license
mreigad1/Simplex
69b3c1e61041ba3d578a6ac1f071f4943ff9e818
df080a0f7ea53d30e63c5036d73d6873c4e836e2
refs/heads/master
2021-01-12T16:33:47.436217
2016-10-20T00:55:41
2016-10-20T00:55:41
71,412,005
0
0
null
null
null
null
UTF-8
C++
false
false
1,284
cpp
/******************************************************************************/ /** Threaded: **/ /** Threaded presents an abstract class to be implemented by children **/ /** classes to present an easy interface for threading classes **/ /******************************************************************************/ #include <pthread.h> #include <unistd.h> namespace simplex{ const int ms_per_second = 1000; const int us_per_ms = 1000; const int us_per_second = us_per_ms * ms_per_second; struct threadedImpl { pthread_t thread; pthread_attr_t attr; threadedImpl() { } ~threadedImpl() { } }; threaded::threaded() { impl = new threadedImpl; } threaded::threaded(size_t stack_size, double delay_ms, double frequency) { impl = new threadedImpl; } ~threaded::threaded() { if (impl) { delete impl; } impl = NULL; } void threaded::startWorker() { } void threaded::stopWorker() { } void threaded::waitOnWorker() { } void threaded::launchWorker(void* p) { threaded* threadedObj = (threaded*) p; } };
[ "matthew@Matthews-MacBook-Pro.local" ]
matthew@Matthews-MacBook-Pro.local
dd6aa961320d13eba14601deec23e0f71d1e0147
fe06b6d602595b147ea4e8bbcbdd2a2e25d6e2ab
/2_stars/357.cpp
02e209c1679298794b6c255b742b61930600e0fc
[]
no_license
lausai/UVa
8c4a86785d5c561bb9d464466b60bdf4e993757c
fb14b6f9031a449e20830d5f0903a06a8899dfa5
refs/heads/master
2022-10-17T12:49:02.561369
2022-09-23T03:02:50
2022-09-23T03:02:50
20,293,790
0
0
null
null
null
null
UTF-8
C++
false
false
650
cpp
#include <cstdio> using namespace std; int main() { int money[5] = {1, 5, 10, 25, 50}; long long ways[30001] = {1}; for (int i = 0; i < 5; i++) { for (int j = money[i]; j <= 30000; j++) ways[j] += ways[j - money[i]]; } int data = 0; while (EOF != scanf("%d", &data)) { if (data < 5) printf("There is only 1 way to produce %d cents change.\n", data); else printf("There are %lld ways to produce %d cents change.\n", ways[data], data); } return 0; }
[ "lausai360@gmail.com" ]
lausai360@gmail.com
88dadf1d65d79a2ef5cfd01c5c405fc4aca91b98
e27d9e460c374473e692f58013ca692934347ef1
/drafts/quickSpectrogram_2/libraries/liblsl/external/lslboost/math/tools/detail/rational_horner3_18.hpp
32c4fe2b6e9a1fd4753096306a5f6f535677e388
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
thoughtworksarts/Dual_Brains
84a0edf69d95299021daf4af9311aed5724a2e84
a7a6586b91a280950693b427d8269bd68bf8a7ab
refs/heads/master
2021-09-18T15:50:51.397078
2018-07-16T23:20:18
2018-07-16T23:20:18
119,759,649
3
0
null
2018-07-16T23:14:34
2018-02-01T00:09:16
HTML
UTF-8
C++
false
false
35,093
hpp
// (C) Copyright John Maddock 2007. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.lslboost.org/LICENSE_1_0.txt) // // This file is machine generated, do not edit by hand // Polynomial evaluation using second order Horners rule #ifndef BOOST_MATH_TOOLS_RAT_EVAL_18_HPP #define BOOST_MATH_TOOLS_RAT_EVAL_18_HPP namespace lslboost{ namespace math{ namespace tools{ namespace detail{ template <class T, class U, class V> inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) { return static_cast<V>(0); } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) { return static_cast<V>(a[0]) / static_cast<V>(b[0]); } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) { return static_cast<V>((a[1] * x + a[0]) / (b[1] * x + b[0])); } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) { return static_cast<V>(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) { return static_cast<V>((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[4] * x2 + a[2]; t[1] = a[3] * x2 + a[1]; t[2] = b[4] * x2 + b[2]; t[3] = b[3] * x2 + b[1]; t[0] *= x2; t[2] *= x2; t[0] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[0]); t[1] *= x; t[3] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[2] *= z2; t[0] += static_cast<V>(a[4]); t[2] += static_cast<V>(b[4]); t[1] *= z; t[3] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[5] * x2 + a[3]; t[1] = a[4] * x2 + a[2]; t[2] = b[5] * x2 + b[3]; t[3] = b[4] * x2 + b[2]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[1]); t[1] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[1]); t[3] += static_cast<V>(b[0]); t[0] *= x; t[2] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z; t[2] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[6] * x2 + a[4]; t[1] = a[5] * x2 + a[3]; t[2] = b[6] * x2 + b[4]; t[3] = b[5] * x2 + b[3]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[2]); t[1] += static_cast<V>(a[1]); t[2] += static_cast<V>(b[2]); t[3] += static_cast<V>(b[1]); t[0] *= x2; t[2] *= x2; t[0] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[0]); t[1] *= x; t[3] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[2] *= z2; t[0] += static_cast<V>(a[6]); t[2] += static_cast<V>(b[6]); t[1] *= z; t[3] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[7] * x2 + a[5]; t[1] = a[6] * x2 + a[4]; t[2] = b[7] * x2 + b[5]; t[3] = b[6] * x2 + b[4]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[3]); t[1] += static_cast<V>(a[2]); t[2] += static_cast<V>(b[3]); t[3] += static_cast<V>(b[2]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[1]); t[1] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[1]); t[3] += static_cast<V>(b[0]); t[0] *= x; t[2] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z; t[2] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[8] * x2 + a[6]; t[1] = a[7] * x2 + a[5]; t[2] = b[8] * x2 + b[6]; t[3] = b[7] * x2 + b[5]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[3]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[3]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[2]); t[1] += static_cast<V>(a[1]); t[2] += static_cast<V>(b[2]); t[3] += static_cast<V>(b[1]); t[0] *= x2; t[2] *= x2; t[0] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[0]); t[1] *= x; t[3] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z2; t[2] *= z2; t[0] += static_cast<V>(a[8]); t[2] += static_cast<V>(b[8]); t[1] *= z; t[3] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[9] * x2 + a[7]; t[1] = a[8] * x2 + a[6]; t[2] = b[9] * x2 + b[7]; t[3] = b[8] * x2 + b[6]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[5]); t[1] += static_cast<V>(a[4]); t[2] += static_cast<V>(b[5]); t[3] += static_cast<V>(b[4]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[3]); t[1] += static_cast<V>(a[2]); t[2] += static_cast<V>(b[3]); t[3] += static_cast<V>(b[2]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[1]); t[1] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[1]); t[3] += static_cast<V>(b[0]); t[0] *= x; t[2] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[9]); t[0] *= z; t[2] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[10] * x2 + a[8]; t[1] = a[9] * x2 + a[7]; t[2] = b[10] * x2 + b[8]; t[3] = b[9] * x2 + b[7]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[5]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[3]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[3]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[2]); t[1] += static_cast<V>(a[1]); t[2] += static_cast<V>(b[2]); t[3] += static_cast<V>(b[1]); t[0] *= x2; t[2] *= x2; t[0] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[0]); t[1] *= x; t[3] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[9]); t[0] *= z2; t[2] *= z2; t[0] += static_cast<V>(a[10]); t[2] += static_cast<V>(b[10]); t[1] *= z; t[3] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[11] * x2 + a[9]; t[1] = a[10] * x2 + a[8]; t[2] = b[11] * x2 + b[9]; t[3] = b[10] * x2 + b[8]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[7]); t[1] += static_cast<V>(a[6]); t[2] += static_cast<V>(b[7]); t[3] += static_cast<V>(b[6]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[5]); t[1] += static_cast<V>(a[4]); t[2] += static_cast<V>(b[5]); t[3] += static_cast<V>(b[4]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[3]); t[1] += static_cast<V>(a[2]); t[2] += static_cast<V>(b[3]); t[3] += static_cast<V>(b[2]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[1]); t[1] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[1]); t[3] += static_cast<V>(b[0]); t[0] *= x; t[2] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[9]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[10]); t[1] += static_cast<V>(a[11]); t[2] += static_cast<V>(b[10]); t[3] += static_cast<V>(b[11]); t[0] *= z; t[2] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[12] * x2 + a[10]; t[1] = a[11] * x2 + a[9]; t[2] = b[12] * x2 + b[10]; t[3] = b[11] * x2 + b[9]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[7]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[5]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[3]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[3]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[2]); t[1] += static_cast<V>(a[1]); t[2] += static_cast<V>(b[2]); t[3] += static_cast<V>(b[1]); t[0] *= x2; t[2] *= x2; t[0] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[0]); t[1] *= x; t[3] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[9]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[10]); t[1] += static_cast<V>(a[11]); t[2] += static_cast<V>(b[10]); t[3] += static_cast<V>(b[11]); t[0] *= z2; t[2] *= z2; t[0] += static_cast<V>(a[12]); t[2] += static_cast<V>(b[12]); t[1] *= z; t[3] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[13] * x2 + a[11]; t[1] = a[12] * x2 + a[10]; t[2] = b[13] * x2 + b[11]; t[3] = b[12] * x2 + b[10]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[9]); t[1] += static_cast<V>(a[8]); t[2] += static_cast<V>(b[9]); t[3] += static_cast<V>(b[8]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[7]); t[1] += static_cast<V>(a[6]); t[2] += static_cast<V>(b[7]); t[3] += static_cast<V>(b[6]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[5]); t[1] += static_cast<V>(a[4]); t[2] += static_cast<V>(b[5]); t[3] += static_cast<V>(b[4]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[3]); t[1] += static_cast<V>(a[2]); t[2] += static_cast<V>(b[3]); t[3] += static_cast<V>(b[2]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[1]); t[1] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[1]); t[3] += static_cast<V>(b[0]); t[0] *= x; t[2] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[9]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[10]); t[1] += static_cast<V>(a[11]); t[2] += static_cast<V>(b[10]); t[3] += static_cast<V>(b[11]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[12]); t[1] += static_cast<V>(a[13]); t[2] += static_cast<V>(b[12]); t[3] += static_cast<V>(b[13]); t[0] *= z; t[2] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[14] * x2 + a[12]; t[1] = a[13] * x2 + a[11]; t[2] = b[14] * x2 + b[12]; t[3] = b[13] * x2 + b[11]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[10]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[10]); t[3] += static_cast<V>(b[9]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[7]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[5]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[3]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[3]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[2]); t[1] += static_cast<V>(a[1]); t[2] += static_cast<V>(b[2]); t[3] += static_cast<V>(b[1]); t[0] *= x2; t[2] *= x2; t[0] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[0]); t[1] *= x; t[3] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[9]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[10]); t[1] += static_cast<V>(a[11]); t[2] += static_cast<V>(b[10]); t[3] += static_cast<V>(b[11]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[12]); t[1] += static_cast<V>(a[13]); t[2] += static_cast<V>(b[12]); t[3] += static_cast<V>(b[13]); t[0] *= z2; t[2] *= z2; t[0] += static_cast<V>(a[14]); t[2] += static_cast<V>(b[14]); t[1] *= z; t[3] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[15] * x2 + a[13]; t[1] = a[14] * x2 + a[12]; t[2] = b[15] * x2 + b[13]; t[3] = b[14] * x2 + b[12]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[11]); t[1] += static_cast<V>(a[10]); t[2] += static_cast<V>(b[11]); t[3] += static_cast<V>(b[10]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[9]); t[1] += static_cast<V>(a[8]); t[2] += static_cast<V>(b[9]); t[3] += static_cast<V>(b[8]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[7]); t[1] += static_cast<V>(a[6]); t[2] += static_cast<V>(b[7]); t[3] += static_cast<V>(b[6]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[5]); t[1] += static_cast<V>(a[4]); t[2] += static_cast<V>(b[5]); t[3] += static_cast<V>(b[4]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[3]); t[1] += static_cast<V>(a[2]); t[2] += static_cast<V>(b[3]); t[3] += static_cast<V>(b[2]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[1]); t[1] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[1]); t[3] += static_cast<V>(b[0]); t[0] *= x; t[2] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[9]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[10]); t[1] += static_cast<V>(a[11]); t[2] += static_cast<V>(b[10]); t[3] += static_cast<V>(b[11]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[12]); t[1] += static_cast<V>(a[13]); t[2] += static_cast<V>(b[12]); t[3] += static_cast<V>(b[13]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[14]); t[1] += static_cast<V>(a[15]); t[2] += static_cast<V>(b[14]); t[3] += static_cast<V>(b[15]); t[0] *= z; t[2] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[16] * x2 + a[14]; t[1] = a[15] * x2 + a[13]; t[2] = b[16] * x2 + b[14]; t[3] = b[15] * x2 + b[13]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[12]); t[1] += static_cast<V>(a[11]); t[2] += static_cast<V>(b[12]); t[3] += static_cast<V>(b[11]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[10]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[10]); t[3] += static_cast<V>(b[9]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[7]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[5]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[3]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[3]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[2]); t[1] += static_cast<V>(a[1]); t[2] += static_cast<V>(b[2]); t[3] += static_cast<V>(b[1]); t[0] *= x2; t[2] *= x2; t[0] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[0]); t[1] *= x; t[3] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[9]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[10]); t[1] += static_cast<V>(a[11]); t[2] += static_cast<V>(b[10]); t[3] += static_cast<V>(b[11]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[12]); t[1] += static_cast<V>(a[13]); t[2] += static_cast<V>(b[12]); t[3] += static_cast<V>(b[13]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[14]); t[1] += static_cast<V>(a[15]); t[2] += static_cast<V>(b[14]); t[3] += static_cast<V>(b[15]); t[0] *= z2; t[2] *= z2; t[0] += static_cast<V>(a[16]); t[2] += static_cast<V>(b[16]); t[1] *= z; t[3] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } template <class T, class U, class V> inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) { if(x <= 1) { V x2 = x * x; V t[4]; t[0] = a[17] * x2 + a[15]; t[1] = a[16] * x2 + a[14]; t[2] = b[17] * x2 + b[15]; t[3] = b[16] * x2 + b[14]; t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[13]); t[1] += static_cast<V>(a[12]); t[2] += static_cast<V>(b[13]); t[3] += static_cast<V>(b[12]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[11]); t[1] += static_cast<V>(a[10]); t[2] += static_cast<V>(b[11]); t[3] += static_cast<V>(b[10]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[9]); t[1] += static_cast<V>(a[8]); t[2] += static_cast<V>(b[9]); t[3] += static_cast<V>(b[8]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[7]); t[1] += static_cast<V>(a[6]); t[2] += static_cast<V>(b[7]); t[3] += static_cast<V>(b[6]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[5]); t[1] += static_cast<V>(a[4]); t[2] += static_cast<V>(b[5]); t[3] += static_cast<V>(b[4]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[3]); t[1] += static_cast<V>(a[2]); t[2] += static_cast<V>(b[3]); t[3] += static_cast<V>(b[2]); t[0] *= x2; t[1] *= x2; t[2] *= x2; t[3] *= x2; t[0] += static_cast<V>(a[1]); t[1] += static_cast<V>(a[0]); t[2] += static_cast<V>(b[1]); t[3] += static_cast<V>(b[0]); t[0] *= x; t[2] *= x; return (t[0] + t[1]) / (t[2] + t[3]); } else { V z = 1 / x; V z2 = 1 / (x * x); V t[4]; t[0] = a[0] * z2 + a[2]; t[1] = a[1] * z2 + a[3]; t[2] = b[0] * z2 + b[2]; t[3] = b[1] * z2 + b[3]; t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[4]); t[1] += static_cast<V>(a[5]); t[2] += static_cast<V>(b[4]); t[3] += static_cast<V>(b[5]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[6]); t[1] += static_cast<V>(a[7]); t[2] += static_cast<V>(b[6]); t[3] += static_cast<V>(b[7]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[8]); t[1] += static_cast<V>(a[9]); t[2] += static_cast<V>(b[8]); t[3] += static_cast<V>(b[9]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[10]); t[1] += static_cast<V>(a[11]); t[2] += static_cast<V>(b[10]); t[3] += static_cast<V>(b[11]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[12]); t[1] += static_cast<V>(a[13]); t[2] += static_cast<V>(b[12]); t[3] += static_cast<V>(b[13]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[14]); t[1] += static_cast<V>(a[15]); t[2] += static_cast<V>(b[14]); t[3] += static_cast<V>(b[15]); t[0] *= z2; t[1] *= z2; t[2] *= z2; t[3] *= z2; t[0] += static_cast<V>(a[16]); t[1] += static_cast<V>(a[17]); t[2] += static_cast<V>(b[16]); t[3] += static_cast<V>(b[17]); t[0] *= z; t[2] *= z; return (t[0] + t[1]) / (t[2] + t[3]); } } }}}} // namespaces #endif // include guard
[ "gabriel.ibagon@gmail.com" ]
gabriel.ibagon@gmail.com
1ec379ec2403e2400731ee452cfcec4c69b088dd
00c018a0d1a98c617d23ad84ea3097796d6eb772
/media/gpu/vaapi/vaapi_video_decoder.h
c993da4d01f241f45d5aff858bfd58fc494386c6
[ "BSD-3-Clause" ]
permissive
Ambyjkl/chromium
14ea14729df5e6ecdfbe5c996855c73740b5304f
23b2a91ba2010775480846cf8df64aeb7dba3db3
refs/heads/master
2023-03-10T21:18:50.899286
2019-11-22T02:46:17
2019-11-22T02:46:17
223,312,529
0
0
BSD-3-Clause
2019-11-22T03:04:16
2019-11-22T03:04:14
null
UTF-8
C++
false
false
6,630
h
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_GPU_VAAPI_VAAPI_VIDEO_DECODER_H_ #define MEDIA_GPU_VAAPI_VAAPI_VIDEO_DECODER_H_ #include <stdint.h> #include <va/va.h> #include <map> #include <memory> #include <string> #include <utility> #include "base/containers/mru_cache.h" #include "base/containers/queue.h" #include "base/macros.h" #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" #include "base/optional.h" #include "base/sequence_checker.h" #include "base/threading/thread.h" #include "base/time/time.h" #include "media/base/video_codecs.h" #include "media/base/video_frame_layout.h" #include "media/gpu/chromeos/video_decoder_pipeline.h" #include "media/gpu/decode_surface_handler.h" #include "media/video/supported_video_decoder_config.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/size.h" namespace media { class AcceleratedVideoDecoder; class DmabufVideoFramePool; class VaapiWrapper; class VideoFrame; class VASurface; class VaapiVideoDecoder : public DecoderInterface, public DecodeSurfaceHandler<VASurface> { public: static std::unique_ptr<DecoderInterface> Create( scoped_refptr<base::SequencedTaskRunner> decoder_task_runner, base::WeakPtr<DecoderInterface::Client> client); static SupportedVideoDecoderConfigs GetSupportedConfigs(); // DecoderInterface implementation. void Initialize(const VideoDecoderConfig& config, InitCB init_cb, const OutputCB& output_cb) override; void Decode(scoped_refptr<DecoderBuffer> buffer, DecodeCB decode_cb) override; void Reset(base::OnceClosure reset_cb) override; void OnPipelineFlushed() override; // DecodeSurfaceHandler<VASurface> implementation. scoped_refptr<VASurface> CreateSurface() override; void SurfaceReady(const scoped_refptr<VASurface>& va_surface, int32_t buffer_id, const gfx::Rect& visible_rect, const VideoColorSpace& color_space) override; private: // Decode task holding single decode request. struct DecodeTask { DecodeTask(scoped_refptr<DecoderBuffer> buffer, int32_t buffer_id, DecodeCB decode_done_cb); ~DecodeTask(); DecodeTask(DecodeTask&&); DecodeTask& operator=(DecodeTask&&) = default; scoped_refptr<DecoderBuffer> buffer_; int32_t buffer_id_ = -1; DecodeCB decode_done_cb_; DISALLOW_COPY_AND_ASSIGN(DecodeTask); }; enum class State { kUninitialized, // not initialized yet or initialization failed. kWaitingForInput, // waiting for input buffers. kWaitingForOutput, // waiting for output buffers. kDecoding, // decoding buffers. kResetting, // resetting decoder. kError, // decoder encountered an error. }; VaapiVideoDecoder( scoped_refptr<base::SequencedTaskRunner> decoder_task_runner, base::WeakPtr<DecoderInterface::Client> client); ~VaapiVideoDecoder() override; // Schedule the next decode task in the queue to be executed. void ScheduleNextDecodeTask(); // Try to decode a single input buffer on the decoder thread. void HandleDecodeTask(); // Clear the decode task queue on the decoder thread. This is done when // resetting or destroying the decoder, or encountering an error. void ClearDecodeTaskQueue(DecodeStatus status); // Output a single |video_frame| on the decoder thread. void OutputFrameTask(scoped_refptr<VideoFrame> video_frame, const gfx::Rect& visible_rect, base::TimeDelta timestamp); // Release the video frame associated with the specified |surface_id| on the // decoder thread. This is called when the last reference to the associated // VASurface has been released, which happens when the decoder outputted the // video frame, or stopped using it as a reference frame. Note that this // doesn't mean the frame can be reused immediately, as it might still be used // by the client. void ReleaseFrameTask(scoped_refptr<VASurface> va_surface, VASurfaceID surface_id); // Called when a video frame was returned to the video frame pool on the // decoder thread. This will happen when both the client and decoder // (in ReleaseFrameTask()) released their reference to the video frame. void NotifyFrameAvailableTask(); // Flush the decoder on the decoder thread, blocks until all pending decode // tasks have been executed and all frames have been output. void FlushTask(); // Called when resetting the decoder is done, executes |reset_cb|. void ResetDoneTask(base::OnceClosure reset_cb); // Change the current |state_| to the specified |state| on the decoder thread. void SetState(State state); // The video decoder's state. State state_ = State::kUninitialized; // Callback used to notify the client when a frame is available for output. OutputCB output_cb_; // The video stream's profile. VideoCodecProfile profile_ = VIDEO_CODEC_PROFILE_UNKNOWN; // Ratio of natural size to |visible_rect_| of the output frames. double pixel_aspect_ratio_ = 0.0; // Video frame pool used to allocate and recycle video frames. DmabufVideoFramePool* frame_pool_ = nullptr; // The time at which each buffer decode operation started. Not each decode // operation leads to a frame being output and frames might be reordered, so // we don't know when it's safe to drop a timestamp. This means we need to use // a cache here, with a size large enough to account for frame reordering. base::MRUCache<int32_t, base::TimeDelta> buffer_id_to_timestamp_; // Queue containing all requested decode tasks. base::queue<DecodeTask> decode_task_queue_; // The decode task we're currently trying to execute. base::Optional<DecodeTask> current_decode_task_; // The next input buffer id. int32_t next_buffer_id_ = 0; // The list of frames currently used as output buffers or reference frames. std::map<VASurfaceID, scoped_refptr<VideoFrame>> output_frames_; // Platform and codec specific video decoder. std::unique_ptr<AcceleratedVideoDecoder> decoder_; scoped_refptr<VaapiWrapper> vaapi_wrapper_; SEQUENCE_CHECKER(decoder_sequence_checker_); base::WeakPtr<VaapiVideoDecoder> weak_this_; base::WeakPtrFactory<VaapiVideoDecoder> weak_this_factory_; DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecoder); }; } // namespace media #endif // MEDIA_GPU_VAAPI_VAAPI_VIDEO_DECODER_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
1a300e9359324c8b815ad72eccc56249be49a2aa
6cea61162a434f67df7ec8ad637e7e8df246be4b
/dependencies/MyGUI/Platforms/Ogre/OgrePlatform/src/MyGUI_OgreRenderManager.cpp
58848e65b72a99fde951f6f3d596f909346e59bc
[]
no_license
razvanlupusoru/Lost-Marbles
971dd2d674d61874d579c86fa4ca83ccc10d8ca7
8a2f6fe2cafe3e1cc76c418d28d0ba7448a92e0c
refs/heads/master
2020-12-24T16:06:06.900195
2012-01-31T06:47:57
2012-01-31T06:47:57
2,338,795
2
0
null
null
null
null
WINDOWS-1251
C++
false
false
10,633
cpp
/*! @file @author Albert Semenov @date 04/2008 @module */ #include "MyGUI_OgreDataManager.h" #include "MyGUI_OgreRenderManager.h" #include "MyGUI_OgreTexture.h" #include "MyGUI_OgreVertexBuffer.h" #include "MyGUI_LogManager.h" #include "MyGUI_Gui.h" #include "MyGUI_OgreDiagnostic.h" #include "MyGUI_LayerManager.h" #include "MyGUI_Timer.h" namespace MyGUI { MYGUI_INSTANCE_IMPLEMENT(OgreRenderManager) void OgreRenderManager::initialise(Ogre::RenderWindow* _window, Ogre::SceneManager* _scene) { MYGUI_PLATFORM_ASSERT(!mIsInitialise, INSTANCE_TYPE_NAME << " initialised twice"); MYGUI_PLATFORM_LOG(Info, "* Initialise: " << INSTANCE_TYPE_NAME); mColorBlendMode.blendType = Ogre::LBT_COLOUR; mColorBlendMode.source1 = Ogre::LBS_TEXTURE; mColorBlendMode.source2 = Ogre::LBS_DIFFUSE; mColorBlendMode.operation = Ogre::LBX_MODULATE; mAlphaBlendMode.blendType = Ogre::LBT_ALPHA; mAlphaBlendMode.source1 = Ogre::LBS_TEXTURE; mAlphaBlendMode.source2 = Ogre::LBS_DIFFUSE; mAlphaBlendMode.operation = Ogre::LBX_MODULATE; mTextureAddressMode.u = Ogre::TextureUnitState::TAM_CLAMP; mTextureAddressMode.v = Ogre::TextureUnitState::TAM_CLAMP; mTextureAddressMode.w = Ogre::TextureUnitState::TAM_CLAMP; mSceneManager = nullptr; mWindow = nullptr; mUpdate = false; mRenderSystem = nullptr; mActiveViewport = 0; Ogre::Root * root = Ogre::Root::getSingletonPtr(); if (root != nullptr) setRenderSystem(root->getRenderSystem()); setRenderWindow(_window); setSceneManager(_scene); MYGUI_PLATFORM_LOG(Info, INSTANCE_TYPE_NAME << " successfully initialized"); mIsInitialise = true; } void OgreRenderManager::shutdown() { if (!mIsInitialise) return; MYGUI_PLATFORM_LOG(Info, "* Shutdown: " << INSTANCE_TYPE_NAME); destroyAllResources(); setSceneManager(nullptr); setRenderWindow(nullptr); setRenderSystem(nullptr); MYGUI_PLATFORM_LOG(Info, INSTANCE_TYPE_NAME << " successfully shutdown"); mIsInitialise = false; } void OgreRenderManager::setRenderSystem(Ogre::RenderSystem* _render) { // отписываемся if (mRenderSystem != nullptr) { mRenderSystem->removeListener(this); mRenderSystem = nullptr; } mRenderSystem = _render; // подписываемся на рендер евент if (mRenderSystem != nullptr) { mRenderSystem->addListener(this); // формат цвета в вершинах Ogre::VertexElementType vertext_type = mRenderSystem->getColourVertexElementType(); if (vertext_type == Ogre::VET_COLOUR_ARGB) mVertexFormat = VertexColourType::ColourARGB; else if (vertext_type == Ogre::VET_COLOUR_ABGR) mVertexFormat = VertexColourType::ColourABGR; updateRenderInfo(); } } void OgreRenderManager::setRenderWindow(Ogre::RenderWindow* _window) { // отписываемся if (mWindow != nullptr) { Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this); mWindow = nullptr; } mWindow = _window; if (mWindow != nullptr) { Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this); windowResized(mWindow); } } void OgreRenderManager::setSceneManager(Ogre::SceneManager* _scene) { if (nullptr != mSceneManager) { mSceneManager->removeRenderQueueListener(this); mSceneManager = nullptr; } mSceneManager = _scene; if (nullptr != mSceneManager) { mSceneManager->addRenderQueueListener(this); } } void OgreRenderManager::setActiveViewport(size_t _num) { mActiveViewport = _num; if (mWindow != nullptr) { Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this); Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this); // рассылка обновлений windowResized(mWindow); } } void OgreRenderManager::renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation) { if (Ogre::RENDER_QUEUE_OVERLAY != queueGroupId) return; Ogre::Viewport * viewport = mSceneManager->getCurrentViewport(); if (nullptr == viewport || !viewport->getOverlaysEnabled()) return; if (mWindow->getNumViewports() <= mActiveViewport || viewport != mWindow->getViewport(mActiveViewport)) return; static Timer timer; static unsigned long last_time = timer.getMilliseconds(); unsigned long now_time = timer.getMilliseconds(); unsigned long time = now_time - last_time; Gui* gui = Gui::getInstancePtr(); if (gui != nullptr) gui->_injectFrameEntered((float)((double)(time) / (double)1000)); last_time = now_time; begin(); LayerManager::getInstance().renderToTarget(this, mUpdate); end(); // сбрасываем флаг mUpdate = false; } void OgreRenderManager::renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation) { } void OgreRenderManager::eventOccurred(const Ogre::String& eventName, const Ogre::NameValuePairList* parameters) { if (eventName == "DeviceLost") { } else if (eventName == "DeviceRestored") { // обновить всех mUpdate = true; } } IVertexBuffer* OgreRenderManager::createVertexBuffer() { return new OgreVertexBuffer(); } void OgreRenderManager::destroyVertexBuffer(IVertexBuffer* _buffer) { delete _buffer; } // для оповещений об изменении окна рендера void OgreRenderManager::windowResized(Ogre::RenderWindow* _window) { if (_window->getNumViewports() > mActiveViewport) { Ogre::Viewport* port = _window->getViewport(mActiveViewport); mViewSize.set(port->getActualWidth(), port->getActualHeight()); // обновить всех mUpdate = true; updateRenderInfo(); Gui* gui = Gui::getInstancePtr(); if (gui != nullptr) gui->resizeWindow(mViewSize); } } void OgreRenderManager::updateRenderInfo() { if (mRenderSystem != nullptr) { mInfo.maximumDepth = mRenderSystem->getMaximumDepthInputValue(); mInfo.hOffset = mRenderSystem->getHorizontalTexelOffset() / float(mViewSize.width); mInfo.vOffset = mRenderSystem->getVerticalTexelOffset() / float(mViewSize.height); mInfo.aspectCoef = float(mViewSize.height) / float(mViewSize.width); mInfo.pixScaleX = 1.0 / float(mViewSize.width); mInfo.pixScaleY = 1.0 / float(mViewSize.height); } } void OgreRenderManager::doRender(IVertexBuffer* _buffer, ITexture* _texture, size_t _count) { if (_texture) { OgreTexture* texture = static_cast<OgreTexture*>(_texture); Ogre::TexturePtr texture_ptr = texture->getOgreTexture(); if (!texture_ptr.isNull()) { // в OpenGL фильтрация сбрасывается после смены текстуры mRenderSystem->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE); mRenderSystem->_setTexture(0, true, texture_ptr); } } OgreVertexBuffer* buffer = static_cast<OgreVertexBuffer*>(_buffer); Ogre::RenderOperation* operation = buffer->getRenderOperation(); operation->vertexData->vertexCount = _count; mRenderSystem->_render(*operation); } void OgreRenderManager::begin() { // set-up matrices mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); mRenderSystem->_setViewMatrix(Ogre::Matrix4::IDENTITY); mRenderSystem->_setProjectionMatrix(Ogre::Matrix4::IDENTITY); // initialise render settings mRenderSystem->setLightingEnabled(false); mRenderSystem->_setDepthBufferParams(false, false); mRenderSystem->_setDepthBias(0, 0); mRenderSystem->_setCullingMode(Ogre::CULL_NONE); mRenderSystem->_setFog(Ogre::FOG_NONE); mRenderSystem->_setColourBufferWriteEnabled(true, true, true, true); mRenderSystem->unbindGpuProgram(Ogre::GPT_FRAGMENT_PROGRAM); mRenderSystem->unbindGpuProgram(Ogre::GPT_VERTEX_PROGRAM); mRenderSystem->setShadingType(Ogre::SO_GOURAUD); // initialise texture settings mRenderSystem->_setTextureCoordCalculation(0, Ogre::TEXCALC_NONE); mRenderSystem->_setTextureCoordSet(0, 0); mRenderSystem->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE); mRenderSystem->_setTextureAddressingMode(0, mTextureAddressMode); mRenderSystem->_setTextureMatrix(0, Ogre::Matrix4::IDENTITY); #if OGRE_VERSION < MYGUI_DEFINE_VERSION(1, 6, 0) mRenderSystem->_setAlphaRejectSettings(Ogre::CMPF_ALWAYS_PASS, 0); #else mRenderSystem->_setAlphaRejectSettings(Ogre::CMPF_ALWAYS_PASS, 0, false); #endif mRenderSystem->_setTextureBlendMode(0, mColorBlendMode); mRenderSystem->_setTextureBlendMode(0, mAlphaBlendMode); mRenderSystem->_disableTextureUnitsFrom(1); // enable alpha blending mRenderSystem->_setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA); } void OgreRenderManager::end() { } ITexture* OgreRenderManager::createTexture(const std::string& _name) { MapTexture::const_iterator item = mTextures.find(_name); MYGUI_PLATFORM_ASSERT(item == mTextures.end(), "Texture '" << _name << "' already exist"); OgreTexture* texture = new OgreTexture(_name, OgreDataManager::getInstance().getGroup()); mTextures[_name] = texture; return texture; } void OgreRenderManager::destroyTexture(ITexture* _texture) { if (_texture == nullptr) return; MapTexture::iterator item = mTextures.find(_texture->getName()); MYGUI_PLATFORM_ASSERT(item != mTextures.end(), "Texture '" << _texture->getName() << "' not found"); mTextures.erase(item); delete _texture; } ITexture* OgreRenderManager::getTexture(const std::string& _name) { MapTexture::const_iterator item = mTextures.find(_name); if (item == mTextures.end()) { Ogre::TexturePtr texture = (Ogre::TexturePtr)Ogre::TextureManager::getSingleton().getByName(_name); if (!texture.isNull()) { ITexture* result = createTexture(_name); static_cast<OgreTexture*>(result)->setOgreTexture(texture); return result; } return nullptr; } return item->second; } bool OgreRenderManager::isFormatSupported(PixelFormat _format, TextureUsage _usage) { return Ogre::TextureManager::getSingleton().isFormatSupported( Ogre::TEX_TYPE_2D, OgreTexture::convertFormat(_format), OgreTexture::convertUsage(_usage)); } void OgreRenderManager::destroyAllResources() { for (MapTexture::const_iterator item=mTextures.begin(); item!=mTextures.end(); ++item) { delete item->second; } mTextures.clear(); } #if MYGUI_DEBUG_MODE == 1 bool OgreRenderManager::checkTexture(ITexture* _texture) { for (MapTexture::const_iterator item=mTextures.begin(); item!=mTextures.end(); ++item) { if (item->second == _texture) return true; } return false; } #endif } // namespace MyGUI
[ "razvan.lupusoru@gmail.com" ]
razvan.lupusoru@gmail.com
3a4d1943a3b5d03a5b79a5945db547b8bddd294e
4bf6b87d0341d004cd1f84f29978d12672d88edc
/examples/vowelCounter.cpp
6dc3135ffba5beb922605b82576ef40a51fd8125
[]
no_license
Ze1598/Cpp_stuff
597bb748434b1f551c1a95779a1e43ac34cef219
959c05897fb1012e6d741fcd0084961789a80ba9
refs/heads/master
2020-04-25T06:47:28.633775
2019-06-16T19:24:31
2019-06-16T19:24:31
172,592,723
0
0
null
null
null
null
UTF-8
C++
false
false
2,676
cpp
// Find the frequency of each vowel in a given string and save the results // in an unordered map (unordered_map) #include <iostream> #include <string> // string #include <unordered_map> // unordered_map<> #include <vector> // vector<> #include <algorithm> // find() using namespace std; // Loop through a string to extract the frequency of each vowel,\ // returning an unordered map where each key-value pair represents a\ // vowel and its frequency unordered_map<char, int> vowelCounter (string word) { // Create the hash map unordered_map<char, int> vowelCounts = {}; // Create an array with all vowels char vowels [5] = {'a', 'e', 'i', 'o', 'u'}; // Loop through the word for (int i=0; i<word.length(); i++) { // Save the current character char letter = word[i]; // If the character is a vowel (i.e., the character is present in\ // the `vowels` array) if ( find(begin(vowels), end(vowels), letter) != end(vowels) ) { // If the vowel is in the map, increment its frequency (value) if (vowelCounts.find(letter) != vowelCounts.end()) { vowelCounts[letter] += 1; } // Else, add it as a new key with a value of 1 else { vowelCounts[letter] = 1; } } } // Return the map return vowelCounts; } // Return a vector with all the keys of a given unordered map vector<char> getKeys (unordered_map<char, int> uMap) { // Declare a new empty vector vector<char> vowels; // Loop through the map to extract its keys for (auto key_value : uMap) { // Append the current key (`.first`) to the vector vowels.push_back(key_value.first); } // Return the vector return vowels; } // Function responsible for calling other functions to extract the frequency of\ // vowels in the target string (as an `unordered_map`), create a vector with\ // the keys of the map, and lastly print the frequencies (values) of each vowel\ // (key) void printKeyValues (string word) { cout << "Target string: \"" << word << "\"" << endl; // Return an unordered map where each key-value pair represents a vowel\ // and its frequency in the string unordered_map<char, int> counted = vowelCounter(word); // Return a vector with all the vowels (keys) in the above map vector<char> vowelsFound = getKeys(counted); // Now loop through the vector to print the value (frequency) of each key\ // (vowel) in the map cout << "Frequency of vowels:" << endl; for (int i=0; i<vowelsFound.size(); i++) { cout << vowelsFound[i] << ": " << counted[vowelsFound[i]] << endl; } } int main () { string a = "banaena"; // This function will call the necessary functions so that we only need to\ // pass it the target string printKeyValues(a); }
[ "jose.fernando.costa.1998@gmailcom" ]
jose.fernando.costa.1998@gmailcom
1585f9287c12e6284f70d9abf6a7ae470c71c28b
0054fb390669181d45cbc9013b5ea4f87d0ec265
/Testes/testeimsl/arduino/talkerArduino/talkerArduino.ino
e5b8563d2a719e467e7ecba154f79a88072eadda
[]
no_license
PauloVLB/Projeto_Integrador
04797fa0e0bf672abd4ee5b4582198b8790bd7f9
57ba1e1964dd0edfc8f8eaacec295595dd370b1a
refs/heads/master
2020-04-28T12:13:43.390363
2020-04-08T09:58:13
2020-04-08T09:58:13
175,269,634
4
0
null
null
null
null
UTF-8
C++
false
false
309
ino
#include <ros.h> #include <std_msgs/String.h> ros::NodeHandle nh; std_msgs::String str_msg; ros::Publisher pub("publisherArduino", &str_msg); char msg[13] = "hello world!"; void setup() { nh.initNode(); nh.advertise(pub); } void loop() { str_msg.data = msg; pub.publish(&str_msg); nh.spinOnce(); }
[ "isaacmarlondasilvalourenco@gmail.com" ]
isaacmarlondasilvalourenco@gmail.com
a95d4e9b280a04f104a2aa470663f0c70e90e318
99f685e9f559c87d3333985ae229884ccbfbd8ee
/禁忌搜索N出去T的运算实现/try.cpp
4181b749a49ca797ababd1beb7437e5749635a87
[]
no_license
StephennQin/Program-Examples
a52c8e2b0b956b88fd773cb8b6a5d6eb6b3562b0
8b9f48709c7c446f9daa2550bbff54d6a5028d49
refs/heads/master
2020-12-02T08:05:33.359532
2017-07-10T11:11:38
2017-07-10T11:11:38
96,765,985
0
0
null
null
null
null
UTF-8
C++
false
false
432
cpp
#include<iostream> using namespace std; void main() { int N[6][2]= { {1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4} }; int T[3][2]= { {1,2}, {2,3}, {3,4} }; for(int i=0;i<3;i++) { for(int j=0;j<6;j++) if ((N[j][0]==T[i][0])&&(N[j][1]==T[i][1])) { N[j][0]=0; N[j][1]=0; } } for (int i=0;i<6;i++) { for (int j=0;j<2;j++) { cout<<N[i][j]<<" "; } cout<<endl; } system("pause"); }
[ "StephennQin@users.noreply.github.com" ]
StephennQin@users.noreply.github.com
00092c857bdf95c284960c23ddccd9a3991ca80c
e9556bdc5de2360f9db12aa6162d20a09a14dee9
/src/anki/gr/common/StackGpuAllocator.cpp
ef2c97abe0a13025e208a6539338c6ae6f7c5042
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
Chainsawkitten/anki-3d-engine
e390638f71c833608a29765b21812343708b8af1
0c6b9ef3d9ff3c276f067543fcd6c6bf251f26b2
refs/heads/master
2021-05-14T01:15:38.405207
2017-12-20T20:10:02
2017-12-20T20:10:02
116,559,250
0
0
null
2018-01-07T11:19:28
2018-01-07T11:19:27
null
UTF-8
C++
false
false
2,901
cpp
// Copyright (C) 2009-2017, Panagiotis Christopoulos Charitos and contributors. // All rights reserved. // Code licensed under the BSD License. // http://www.anki3d.org/LICENSE #include <anki/gr/common/StackGpuAllocator.h> namespace anki { class StackGpuAllocatorChunk { public: StackGpuAllocatorChunk* m_next; StackGpuAllocatorMemory* m_mem; Atomic<U32> m_offset; PtrSize m_size; }; StackGpuAllocator::~StackGpuAllocator() { Chunk* chunk = m_chunkListHead; while(chunk) { if(chunk->m_mem) { m_iface->free(chunk->m_mem); } Chunk* next = chunk->m_next; m_alloc.deleteInstance(chunk); chunk = next; } } void StackGpuAllocator::init(GenericMemoryPoolAllocator<U8> alloc, StackGpuAllocatorInterface* iface) { ANKI_ASSERT(iface); m_alloc = alloc; m_iface = iface; iface->getChunkGrowInfo(m_scale, m_bias, m_initialSize); ANKI_ASSERT(m_scale >= 1.0); ANKI_ASSERT(m_initialSize > 0); m_alignment = iface->getMaxAlignment(); ANKI_ASSERT(m_alignment > 0); ANKI_ASSERT(m_initialSize >= m_alignment); ANKI_ASSERT((m_initialSize % m_alignment) == 0); } Error StackGpuAllocator::allocate(PtrSize size, StackGpuAllocatorHandle& handle) { alignRoundUp(m_alignment, size); ANKI_ASSERT(size > 0); ANKI_ASSERT(size <= m_initialSize && "The chunks should have enough space to hold at least one allocation"); Chunk* crntChunk; Bool retry = true; do { crntChunk = m_crntChunk.load(); PtrSize offset; if(crntChunk && ((offset = crntChunk->m_offset.fetchAdd(size)) + size) <= crntChunk->m_size) { // All is fine, there is enough space in the chunk handle.m_memory = crntChunk->m_mem; handle.m_offset = offset; retry = false; } else { // Need new chunk LockGuard<Mutex> lock(m_lock); // Make sure that only one thread will create a new chunk if(m_crntChunk.load() == crntChunk) { // We can create a new chunk if(crntChunk == nullptr || crntChunk->m_next == nullptr) { // Need to create a new chunk Chunk* newChunk = m_alloc.newInstance<Chunk>(); if(crntChunk) { crntChunk->m_next = newChunk; newChunk->m_size = crntChunk->m_size * m_scale + m_bias; } else { newChunk->m_size = m_initialSize; if(m_chunkListHead == nullptr) { m_chunkListHead = newChunk; } } alignRoundUp(m_alignment, newChunk->m_size); newChunk->m_next = nullptr; newChunk->m_offset.set(0); ANKI_CHECK(m_iface->allocate(newChunk->m_size, newChunk->m_mem)); m_crntChunk.store(newChunk); } else { // Need to recycle one crntChunk->m_next->m_offset.set(0); m_crntChunk.store(crntChunk->m_next); } } } } while(retry); return Error::NONE; } void StackGpuAllocator::reset() { m_crntChunk.set(m_chunkListHead); if(m_chunkListHead) { m_chunkListHead->m_offset.set(0); } } } // end namespace anki
[ "godlike@ancient-ritual.com" ]
godlike@ancient-ritual.com
14f7d5081ff0ca95821091db6dab12438660a73d
c5d06c94adb027b8f22b0a7ae3e0cf15a171234f
/PlayingWithSDL/PlayingWithSDL/ReferenceCounter.h
bcc5572070694f5f9af9d702e642bcddd5b9f48d
[]
no_license
Anon3024/Playing-With-SDL
4cf713560752a14625247701884383b9650ee606
df206330ae9ca7c0eceb562ce90be6775158737b
refs/heads/master
2021-02-14T13:15:24.178899
2020-03-16T05:28:31
2020-03-16T05:28:31
244,806,216
0
0
null
null
null
null
UTF-8
C++
false
false
398
h
#pragma once class ReferenceCounter { public: ReferenceCounter(); void AddReference(); void ReleseCount(); int GetCount(); private: int Count; }; ReferenceCounter::ReferenceCounter() : Count(0) { } void ReferenceCounter::AddReference() { ++Count; } void ReferenceCounter::ReleseCount() { --Count; } int ReferenceCounter::GetCount() { return Count; }
[ "kellyforgey@gmail.com" ]
kellyforgey@gmail.com
2b7f2bd4dd868ee583f577909a75c42827f3292a
8a684fe634c2739593be77e171ce0b9571207488
/booster/lib/locale/test/test_generator.cpp
eae21984c4f4326f5ffc3bd21b31f744ee9fc036
[ "MIT", "BSL-1.0" ]
permissive
artyom-beilis/cppcms
350165aa8f0a1f502526b01a12cfe8b8ba909c0a
a11e9d4c2184c90b4c396e2881361fe4d833adcd
refs/heads/master
2023-09-03T19:11:08.554894
2023-05-17T03:49:47
2023-05-17T03:49:47
83,480,120
451
145
NOASSERTION
2023-07-09T16:27:45
2017-02-28T21:18:15
C++
UTF-8
C++
false
false
3,620
cpp
// // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // #include <booster/locale/generator.h> #include <booster/locale/info.h> #include <booster/locale/message.h> #include <iomanip> #include "test_locale.h" bool has_message(std::locale const &l) { return std::has_facet<booster::locale::message_format<char> >(l); } struct test_facet : public std::locale::facet { test_facet() : std::locale::facet(0) {} static std::locale::id id; }; std::locale::id test_facet::id; int main() { try { booster::locale::generator g; std::locale l=g("en_US.UTF-8"); TEST(has_message(l)); g.categories(g.categories() ^ booster::locale::message_facet); g.locale_cache_enabled(true); g("en_US.UTF-8"); g.categories(g.categories() | booster::locale::message_facet); l=g("en_US.UTF-8"); TEST(!has_message(l)); g.clear_cache(); g.locale_cache_enabled(false); l=g("en_US.UTF-8"); TEST(has_message(l)); g.characters(g.characters() ^ booster::locale::char_facet); l=g("en_US.UTF-8"); TEST(!has_message(l)); g.characters(g.characters() | booster::locale::char_facet); l=g("en_US.UTF-8"); TEST(has_message(l)); l=g("en_US.ISO8859-1"); TEST(std::use_facet<booster::locale::info>(l).language()=="en"); TEST(std::use_facet<booster::locale::info>(l).country()=="US"); TEST(!std::use_facet<booster::locale::info>(l).utf8()); TEST(std::use_facet<booster::locale::info>(l).encoding()=="iso8859-1"); l=g("en_US.UTF-8"); TEST(std::use_facet<booster::locale::info>(l).language()=="en"); TEST(std::use_facet<booster::locale::info>(l).country()=="US"); TEST(std::use_facet<booster::locale::info>(l).utf8()); l=g("en_US.ISO8859-1"); TEST(std::use_facet<booster::locale::info>(l).language()=="en"); TEST(std::use_facet<booster::locale::info>(l).country()=="US"); TEST(!std::use_facet<booster::locale::info>(l).utf8()); TEST(std::use_facet<booster::locale::info>(l).encoding()=="iso8859-1"); l=g("en_US.ISO8859-1"); TEST(std::use_facet<booster::locale::info>(l).language()=="en"); TEST(std::use_facet<booster::locale::info>(l).country()=="US"); TEST(!std::use_facet<booster::locale::info>(l).utf8()); TEST(std::use_facet<booster::locale::info>(l).encoding()=="iso8859-1"); std::locale l_wt(std::locale::classic(),new test_facet); TEST(std::has_facet<test_facet>(g.generate(l_wt,"en_US.UTF-8"))); TEST(std::has_facet<test_facet>(g.generate(l_wt,"en_US.ISO8859-1"))); TEST(!std::has_facet<test_facet>(g("en_US.UTF-8"))); TEST(!std::has_facet<test_facet>(g("en_US.ISO8859-1"))); g.locale_cache_enabled(true); g.generate(l_wt,"en_US.UTF-8"); g.generate(l_wt,"en_US.ISO8859-1"); TEST(std::has_facet<test_facet>(g("en_US.UTF-8"))); TEST(std::has_facet<test_facet>(g("en_US.ISO8859-1"))); TEST(std::use_facet<booster::locale::info>(g("en_US.UTF-8")).utf8()); TEST(!std::use_facet<booster::locale::info>(g("en_US.ISO8859-1")).utf8()); } catch(std::exception const &e) { std::cerr << "Failed " << e.what() << std::endl; return EXIT_FAILURE; } FINALIZE(); } // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 // boostinspect:noascii
[ "artyomtnk@yahoo.com" ]
artyomtnk@yahoo.com
653b8f42cd111618068132e420e51e489932982e
d9641b4013e9a01e3369c01713347bfebf2621be
/src/darksend.h
402deb296222f5258044ddeb94f16763a4cfccd6
[ "MIT" ]
permissive
forkee/monacoCoin-Core
645fab7cec4623e30f8af8babfebc51f73dd070a
6312ef2e8c224fd2e6e04cd64100d241f3929176
refs/heads/master
2021-07-05T23:33:51.639286
2017-10-01T08:02:27
2017-10-01T08:02:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,123
h
// // Copyright (c) 2014-2017 The *D ash Core developers // Copyright (c) 2016-2017 The MonacoCore Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef DARKSEND_H #define DARKSEND_H #include "masternode.h" #include "wallet/wallet.h" class CDarksendPool; class CDarkSendSigner; class CDarksendBroadcastTx; // timeouts static const int PRIVATESEND_AUTO_TIMEOUT_MIN = 5; static const int PRIVATESEND_AUTO_TIMEOUT_MAX = 15; static const int PRIVATESEND_QUEUE_TIMEOUT = 30; static const int PRIVATESEND_SIGNING_TIMEOUT = 15; //! minimum peer version accepted by mixing pool static const int MIN_PRIVATESEND_PEER_PROTO_VERSION = 70206; static const CAmount PRIVATESEND_COLLATERAL = 0.001 * COIN; static const CAmount PRIVATESEND_POOL_MAX = 999.999 * COIN; static const int DENOMS_COUNT_MAX = 100; static const int DEFAULT_PRIVATESEND_ROUNDS = 2; static const int DEFAULT_PRIVATESEND_AMOUNT = 1000; static const int DEFAULT_PRIVATESEND_LIQUIDITY = 0; static const bool DEFAULT_PRIVATESEND_MULTISESSION = false; // Warn user if mixing in gui or try to create backup if mixing in daemon mode // when we have only this many keys left static const int PRIVATESEND_KEYS_THRESHOLD_WARNING = 100; // Stop mixing completely, it's too dangerous to continue when we have only this many keys left static const int PRIVATESEND_KEYS_THRESHOLD_STOP = 50; extern int nPrivateSendRounds; extern int nPrivateSendAmount; extern int nLiquidityProvider; extern bool fEnablePrivateSend; extern bool fPrivateSendMultiSession; // The main object for accessing mixing extern CDarksendPool darkSendPool; // A helper object for signing messages from Masternodes extern CDarkSendSigner darkSendSigner; extern std::map<uint256, CDarksendBroadcastTx> mapDarksendBroadcastTxes; extern std::vector<CAmount> vecPrivateSendDenominations; /** Holds an mixing input */ class CTxDSIn : public CTxIn { public: bool fHasSig; // flag to indicate if signed int nSentTimes; //times we've sent this anonymously CTxDSIn(const CTxIn& txin) : CTxIn(txin), fHasSig(false), nSentTimes(0) {} CTxDSIn() : CTxIn(), fHasSig(false), nSentTimes(0) {} }; /** Holds an mixing output */ class CTxDSOut : public CTxOut { public: int nSentTimes; //times we've sent this anonymously CTxDSOut(const CTxOut& out) : CTxOut(out), nSentTimes(0) {} CTxDSOut() : CTxOut(), nSentTimes(0) {} }; // A clients transaction in the mixing pool class CDarkSendEntry { public: std::vector<CTxDSIn> vecTxDSIn; std::vector<CTxDSOut> vecTxDSOut; CTransaction txCollateral; CDarkSendEntry() : vecTxDSIn(std::vector<CTxDSIn>()), vecTxDSOut(std::vector<CTxDSOut>()), txCollateral(CTransaction()) {} CDarkSendEntry(const std::vector<CTxIn>& vecTxIn, const std::vector<CTxOut>& vecTxOut, const CTransaction& txCollateral) : txCollateral(txCollateral) { BOOST_FOREACH(CTxIn txin, vecTxIn) vecTxDSIn.push_back(txin); BOOST_FOREACH(CTxOut txout, vecTxOut) vecTxDSOut.push_back(txout); } ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(vecTxDSIn); READWRITE(txCollateral); READWRITE(vecTxDSOut); } bool AddScriptSig(const CTxIn& txin); }; /** * A currently inprogress mixing merge and denomination information */ class CDarksendQueue { public: int nDenom; CTxIn vin; int64_t nTime; bool fReady; //ready for submit std::vector<unsigned char> vchSig; // memory only bool fTried; CDarksendQueue() : nDenom(0), vin(CTxIn()), nTime(0), fReady(false), vchSig(std::vector<unsigned char>()), fTried(false) {} CDarksendQueue(int nDenom, CTxIn vin, int64_t nTime, bool fReady) : nDenom(nDenom), vin(vin), nTime(nTime), fReady(fReady), vchSig(std::vector<unsigned char>()), fTried(false) {} ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(nDenom); READWRITE(vin); READWRITE(nTime); READWRITE(fReady); READWRITE(vchSig); } /** Sign this mixing transaction * \return true if all conditions are met: * 1) we have an active Masternode, * 2) we have a valid Masternode private key, * 3) we signed the message successfully, and * 4) we verified the message successfully */ bool Sign(); /// Check if we have a valid Masternode address bool CheckSignature(const CPubKey& pubKeyMasternode); bool Relay(); /// Is this queue expired? bool IsExpired() { return GetTime() - nTime > PRIVATESEND_QUEUE_TIMEOUT; } std::string ToString() { return strprintf("nDenom=%d, nTime=%lld, fReady=%s, fTried=%s, masternode=%s", nDenom, nTime, fReady ? "true" : "false", fTried ? "true" : "false", vin.prevout.ToStringShort()); } friend bool operator==(const CDarksendQueue& a, const CDarksendQueue& b) { return a.nDenom == b.nDenom && a.vin.prevout == b.vin.prevout && a.nTime == b.nTime && a.fReady == b.fReady; } }; /** Helper class to store mixing transaction (tx) information. */ class CDarksendBroadcastTx { public: CTransaction tx; CTxIn vin; std::vector<unsigned char> vchSig; int64_t sigTime; CDarksendBroadcastTx() : tx(CTransaction()), vin(CTxIn()), vchSig(std::vector<unsigned char>()), sigTime(0) {} CDarksendBroadcastTx(CTransaction tx, CTxIn vin, int64_t sigTime) : tx(tx), vin(vin), vchSig(std::vector<unsigned char>()), sigTime(sigTime) {} ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(tx); READWRITE(vin); READWRITE(vchSig); READWRITE(sigTime); } bool Sign(); bool CheckSignature(const CPubKey& pubKeyMasternode); }; /** Helper object for signing and checking signatures */ class CDarkSendSigner { public: /// Is the input associated with this public key? (and there is 1000 MCC - checking if valid masternode) bool IsVinAssociatedWithPubkey(const CTxIn& vin, const CPubKey& pubkey); /// Set the private/public key values, returns true if successful bool GetKeysFromSecret(std::string strSecret, CKey& keyRet, CPubKey& pubkeyRet); /// Sign the message, returns true if successful bool SignMessage(std::string strMessage, std::vector<unsigned char>& vchSigRet, CKey key); /// Verify the message, returns true if succcessful bool VerifyMessage(CPubKey pubkey, const std::vector<unsigned char>& vchSig, std::string strMessage, std::string& strErrorRet); }; /** Used to keep track of current status of mixing pool */ class CDarksendPool { private: // pool responses enum PoolMessage { ERR_ALREADY_HAVE, ERR_DENOM, ERR_ENTRIES_FULL, ERR_EXISTING_TX, ERR_FEES, ERR_INVALID_COLLATERAL, ERR_INVALID_INPUT, ERR_INVALID_SCRIPT, ERR_INVALID_TX, ERR_MAXIMUM, ERR_MN_LIST, ERR_MODE, ERR_NON_STANDARD_PUBKEY, ERR_NOT_A_MN, ERR_QUEUE_FULL, ERR_RECENT, ERR_SESSION, ERR_MISSING_TX, ERR_VERSION, MSG_NOERR, MSG_SUCCESS, MSG_ENTRIES_ADDED, MSG_POOL_MIN = ERR_ALREADY_HAVE, MSG_POOL_MAX = MSG_ENTRIES_ADDED }; // pool states enum PoolState { POOL_STATE_IDLE, POOL_STATE_QUEUE, POOL_STATE_ACCEPTING_ENTRIES, POOL_STATE_SIGNING, POOL_STATE_ERROR, POOL_STATE_SUCCESS, POOL_STATE_MIN = POOL_STATE_IDLE, POOL_STATE_MAX = POOL_STATE_SUCCESS }; // status update message constants enum PoolStatusUpdate { STATUS_REJECTED, STATUS_ACCEPTED }; mutable CCriticalSection cs_darksend; // The current mixing sessions in progress on the network std::vector<CDarksendQueue> vecDarksendQueue; // Keep track of the used Masternodes std::vector<CTxIn> vecMasternodesUsed; std::vector<CAmount> vecDenominationsSkipped; std::vector<COutPoint> vecOutPointLocked; // Mixing uses collateral transactions to trust parties entering the pool // to behave honestly. If they don't it takes their money. std::vector<CTransaction> vecSessionCollaterals; std::vector<CDarkSendEntry> vecEntries; // Masternode/clients entries PoolState nState; // should be one of the POOL_STATE_XXX values int64_t nTimeLastSuccessfulStep; // the time when last successful mixing step was performed, in UTC milliseconds int nCachedLastSuccessBlock; int nMinBlockSpacing; //required blocks between mixes const CBlockIndex *pCurrentBlockIndex; // Keep track of current block index int nSessionID; // 0 if no mixing session is active int nEntriesCount; bool fLastEntryAccepted; std::string strLastMessage; std::string strAutoDenomResult; bool fUnitTest; CMutableTransaction txMyCollateral; // client side collateral CMutableTransaction finalMutableTransaction; // the finalized transaction ready for signing /// Add a clients entry to the pool bool AddEntry(const CDarkSendEntry& entryNew, PoolMessage& nMessageIDRet); /// Add signature to a txin bool AddScriptSig(const CTxIn& txin); /// Charge fees to bad actors (Charge clients a fee if they're abusive) void ChargeFees(); /// Rarely charge fees to pay miners void ChargeRandomFees(); /// Check for process void CheckPool(); void CreateFinalTransaction(); void CommitFinalTransaction(); void CompletedTransaction(PoolMessage nMessageID); /// Get the denominations for a specific amount of monacoCoin. int GetDenominationsByAmounts(const std::vector<CAmount>& vecAmount); std::string GetMessageByID(PoolMessage nMessageID); /// Get the maximum number of transactions for the pool int GetMaxPoolTransactions() { return Params().PoolMaxTransactions(); } /// Is this nDenom and txCollateral acceptable? bool IsAcceptableDenomAndCollateral(int nDenom, CTransaction txCollateral, PoolMessage &nMessageIDRet); bool CreateNewSession(int nDenom, CTransaction txCollateral, PoolMessage &nMessageIDRet); bool AddUserToExistingSession(int nDenom, CTransaction txCollateral, PoolMessage &nMessageIDRet); /// Do we have enough users to take entries? bool IsSessionReady() { return (int)vecSessionCollaterals.size() >= GetMaxPoolTransactions(); } /// If the collateral is valid given by a client bool IsCollateralValid(const CTransaction& txCollateral); /// Check that all inputs are signed. (Are all inputs signed?) bool IsSignaturesComplete(); /// Check to make sure a given input matches an input in the pool and its scriptSig is valid bool IsInputScriptSigValid(const CTxIn& txin); /// Are these outputs compatible with other client in the pool? bool IsOutputsCompatibleWithSessionDenom(const std::vector<CTxDSOut>& vecTxDSOut); bool IsDenomSkipped(CAmount nDenomValue) { return std::find(vecDenominationsSkipped.begin(), vecDenominationsSkipped.end(), nDenomValue) != vecDenominationsSkipped.end(); } /// Create denominations bool CreateDenominated(); bool CreateDenominated(const CompactTallyItem& tallyItem, bool fCreateMixingCollaterals); /// Split up large inputs or make fee sized inputs bool MakeCollateralAmounts(); bool MakeCollateralAmounts(const CompactTallyItem& tallyItem); /// As a client, submit part of a future mixing transaction to a Masternode to start the process bool SubmitDenominate(); /// step 1: prepare denominated inputs and outputs bool PrepareDenominate(int nMinRounds, int nMaxRounds, std::string& strErrorRet, std::vector<CTxIn>& vecTxInRet, std::vector<CTxOut>& vecTxOutRet); /// step 2: send denominated inputs and outputs prepared in step 1 bool SendDenominate(const std::vector<CTxIn>& vecTxIn, const std::vector<CTxOut>& vecTxOut); /// Get Masternode updates about the progress of mixing bool CheckPoolStateUpdate(PoolState nStateNew, int nEntriesCountNew, PoolStatusUpdate nStatusUpdate, PoolMessage nMessageID, int nSessionIDNew=0); // Set the 'state' value, with some logging and capturing when the state changed void SetState(PoolState nStateNew); /// As a client, check and sign the final transaction bool SignFinalTransaction(const CTransaction& finalTransactionNew, CNode* pnode); /// Relay mixing Messages void RelayFinalTransaction(const CTransaction& txFinal); void RelaySignaturesAnon(std::vector<CTxIn>& vin); void RelayInAnon(std::vector<CTxIn>& vin, std::vector<CTxOut>& vout); void RelayIn(const CDarkSendEntry& entry); void PushStatus(CNode* pnode, PoolStatusUpdate nStatusUpdate, PoolMessage nMessageID); void RelayStatus(PoolStatusUpdate nStatusUpdate, PoolMessage nMessageID = MSG_NOERR); void RelayCompletedTransaction(PoolMessage nMessageID); void SetNull(); public: CMasternode* pSubmittedToMasternode; int nSessionDenom; //Users must submit an denom matching this int nCachedNumBlocks; //used for the overview screen bool fCreateAutoBackups; //builtin support for automatic backups CDarksendPool() : nCachedLastSuccessBlock(0), nMinBlockSpacing(0), fUnitTest(false), txMyCollateral(CMutableTransaction()), nCachedNumBlocks(std::numeric_limits<int>::max()), fCreateAutoBackups(true) { SetNull(); } /** Process a mixing message using the protocol below * \param pfrom * \param strCommand lower case command string; valid values are: * Command | Description * -------- | ----------------- * dsa | Acceptable * dsc | Complete * dsf | Final tx * dsi | Vector of CTxIn * dsq | Queue * dss | Signal Final Tx * dssu | status update * \param vRecv */ void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); void InitDenominations(); void ClearSkippedDenominations() { vecDenominationsSkipped.clear(); } /// Get the denominations for a list of outputs (returns a bitshifted integer) int GetDenominations(const std::vector<CTxOut>& vecTxOut, bool fSingleRandomDenom = false); int GetDenominations(const std::vector<CTxDSOut>& vecTxDSOut); std::string GetDenominationsToString(int nDenom); bool GetDenominationsBits(int nDenom, std::vector<int> &vecBitsRet); void SetMinBlockSpacing(int nMinBlockSpacingIn) { nMinBlockSpacing = nMinBlockSpacingIn; } void ResetPool(); void UnlockCoins(); int GetQueueSize() const { return vecDarksendQueue.size(); } int GetState() const { return nState; } std::string GetStateString() const; std::string GetStatus(); int GetEntriesCount() const { return vecEntries.size(); } /// Passively run mixing in the background according to the configuration in settings bool DoAutomaticDenominating(bool fDryRun=false); void CheckTimeout(); void CheckForCompleteQueue(); /// Process a new block void NewBlock(); void UpdatedBlockTip(const CBlockIndex *pindex); }; void ThreadCheckDarkSendPool(); #endif
[ "monacocoin@gmail.com" ]
monacocoin@gmail.com
5359ac828b084f729efb72172db367e3ce8e2702
09eaf2b22ad39d284eea42bad4756a39b34da8a2
/ojs/codeforces/913/E/snd.cpp
9413ded69d0bd0500c0a8451692e24cd02bf83ff
[]
no_license
victorsenam/treinos
186b70c44b7e06c7c07a86cb6849636210c9fc61
72a920ce803a738e25b6fc87efa32b20415de5f5
refs/heads/master
2021-01-24T05:58:48.713217
2018-10-14T13:51:29
2018-10-14T13:51:29
41,270,007
2
0
null
null
null
null
UTF-8
C++
false
false
1,783
cpp
#include <bits/stdc++.h> #define cout if (1) cout using namespace std; typedef long long int ll; typedef pair<ll,ll> pii; #define pb push_back struct str { string s; int k, p; str () {} str (string t, int x, int y) : s(t), k(x), p(y) {} bool operator < (str o) const { if (o.s.size()*s.size() == 0) return (o.s.size() == 0); if (o.s.size() != s.size()) return s.size() < o.s.size(); return s < o.s; } }; const int N = (1<<8); str bs[3][N]; set<str> pq; string NO("!"), OP("("), CP(")"), AND("&"), OR("|"); void go (str e) { if (e < bs[e.k][e.p]) { if (bs[e.k][e.p].s.size()) pq.erase(bs[e.k][e.p]); bs[e.k][e.p] = e; pq.insert(bs[e.k][e.p]); } } int n; int main () { go(str(string("x"), 0, (1<<4)-1)); go(str(string("y"), 0, ((1<<2)-1 + (((1<<2)-1)<<4)))); go(str(string("z"), 0, 1+4+16+64)); while (!pq.empty()) { str s = *pq.begin(); pq.erase(pq.begin()); if (s.k == 0) { go(str({ NO + s.s, 0, (1<<8) - 1 - s.p})); go(str({ s.s, 1, s.p})); for (int i = 0; i < N; i++) if (bs[1][i].s.size()) go(str({ bs[1][i].s + AND + s.s, 1, bs[1][i].p & s.p })); } else if (s.k == 1) { go(str({ s.s, 2, s.p })); for (int i = 0; i < N; i++) { if (bs[0][i].s.size()) go(str({ s.s + AND + bs[0][i].s, 1, bs[0][i].p & s.p })); if (bs[2][i].s.size()) go(str({ bs[2][i].s + OR + s.s, 2, bs[2][i].p | s.p })); } } else { go(str({ OP + s.s + CP, 0, s.p })); for (int i = 0; i < N; i++) { if (bs[1][i].s.size()) go(str({ s.s + OR + bs[1][i].s, 2, bs[1][i].p | s.p })); } } } int t; scanf("%d", &t); char str[10]; for (int i = 0; i < t; i++) { scanf(" %s", str); int s = 0; for (int j = 0; j < 8; j++) s = s + s + (str[j] == '1'); printf("%s\n", bs[2][s].s.c_str()); } }
[ "victorsenam@gmail.com" ]
victorsenam@gmail.com
6949e4c46105c5efd4f9a2c04077295a8c0dc0c7
6a42841765f2356da99d9844cab8f3f3353eaebf
/WHAndroidClient/共享组件/界面控件/GdipButton.cpp
72e2be2a0811f7d4d2bf32b4773bf932a593678b
[]
no_license
Ivanhan2018/wh6602_zhuque
d904e1d7136ed7db6cd9b46d65ab33797f400a74
b0e7e574786eac927d109967618ba2a3af5bbee3
refs/heads/master
2020-04-05T17:28:14.739789
2018-12-24T07:36:47
2018-12-24T07:36:47
157,062,380
2
8
null
null
null
null
GB18030
C++
false
false
18,272
cpp
// // GdipButton.cpp : Version 1.0 - see article at CodeProject.com // // Author: Darren Sessions // // // Description: // GdipButton is a CButton derived control that uses GDI+ // to support alternate image formats // // History // Version 1.0 - 2008 June 10 // - Initial public release // // License: // This software is released under the Code Project Open License (CPOL), // which may be found here: http://www.codeproject.com/info/eula.aspx // You are free to use this software in any way you like, except that you // may not sell this source code. // // This software is provided "as is" with no expressed or implied warranty. // I accept no liability for any damage or loss of business that this // software may cause. // /////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "MemDC.h" #include "GdipButton.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //五态图 const int IBTSTATENUMS = 5; //状态序列 //1:正常状态 //2:鼠标经过状态 //3:鼠标按下状态 //4:获得焦点状态 //5:不激活状态 ///////////////////////////////////////////////////////////////////////////// // CGdipButton CGdipButton::CGdipButton() { m_bIsHovering = FALSE; m_bIsTracking = FALSE; m_pToolTip = NULL; m_dcBk.m_hDC = NULL; m_dcStd.m_hDC = NULL; m_dcStdP.m_hDC = NULL; m_dcStdH.m_hDC = NULL; m_dcStdF.m_hDC = NULL; m_dcGS.m_hDC = NULL; m_pCurBtn = NULL; m_pStdImage = NULL; m_bIsResetDC = FALSE; m_fAlpha = 1.0f; GdiplusStartupInput GdiplusStart; GdiplusStartup(&m_dwToken, &GdiplusStart, NULL ); } CGdipButton::~CGdipButton() { if(m_pToolTip) { delete m_pToolTip; } m_pToolTip = NULL; delete m_pStdImage; m_pStdImage = NULL; SetDCNull(); if (NULL != m_dcBk.m_hDC) { m_dcBk.DeleteDC(); } m_dcBk.m_hDC = NULL; GdiplusShutdown(m_dwToken); } //句柄初始化为空 void CGdipButton::SetDCNull() { if (NULL != m_dcStd.m_hDC) { m_dcStd.DeleteDC(); } m_dcStd.m_hDC = NULL; if (NULL != m_dcStdP.m_hDC) { m_dcStdP.DeleteDC(); } m_dcStdP.m_hDC = NULL; if (NULL != m_dcStdH.m_hDC) { m_dcStdH.DeleteDC(); } m_dcStdH.m_hDC = NULL; if (NULL != m_dcStdF.m_hDC) { m_dcStdF.DeleteDC(); } m_dcStdF.m_hDC = NULL; if (NULL != m_dcGS.m_hDC) { m_dcGS.DeleteDC(); } m_dcGS.m_hDC = NULL; } BEGIN_MESSAGE_MAP(CGdipButton, CButton) //{{AFX_MSG_MAP(CGdipButton) ON_WM_DRAWITEM() ON_WM_ERASEBKGND() ON_WM_CTLCOLOR_REFLECT() ON_WM_MOUSEMOVE() ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave) ON_MESSAGE(WM_MOUSEHOVER, OnMouseHover) //}}AFX_MSG_MAP END_MESSAGE_MAP() BOOL CGdipButton::LoadImage(const WCHAR * pwzFilePath) { if (NULL != pwzFilePath) { if (m_pStdImage) { delete m_pStdImage; } m_pStdImage = NULL; m_pStdImage = Gdiplus::Image::FromFile(pwzFilePath); if (NULL!=m_pStdImage && !IsNull()) { ResetBT(); SetWndSize(); return TRUE; } return FALSE; } return FALSE; } BOOL CGdipButton::LoadStream(IStream * pStream) { if (NULL != pStream) { if (m_pStdImage) { delete m_pStdImage; } m_pStdImage = NULL; m_pStdImage = Gdiplus::Image::FromStream(pStream); if (NULL!=m_pStdImage && !IsNull()) { ResetBT(); SetWndSize(); return TRUE; } return FALSE; } return FALSE; } //============================================================================= // // LoadStdImage() // // Purpose: The LoadStdImage() Loads the image for the button. This // function must be called at a minimum or the button wont do // anything. // // Parameters: // [IN] id // resource id, one of the resources already imported with the // resource editor, usually begins with IDR_ // // [IN] pType // pointer to string describing the resource type // // Returns: BOOL // Non zero if successful, otherwise zero // //============================================================================= BOOL CGdipButton::LoadImage(UINT uResourceID, HINSTANCE hResourceDLL,const LPCTSTR szResType) { IStream *pStream = GetStreamFromRes(uResourceID, hResourceDLL, szResType); if (NULL != pStream) { if (m_pStdImage) { delete m_pStdImage; } m_pStdImage = NULL; m_pStdImage = Gdiplus::Image::FromStream(pStream); pStream->Release(); if (NULL!=m_pStdImage && !IsNull()) { ResetBT(); SetWndSize(); return TRUE; } return FALSE; } return FALSE; } IStream * CGdipButton::GetStreamFromRes(UINT uResourceID, HINSTANCE hResourceDLL, LPCTSTR szResType) { HRSRC hSource = FindResource(hResourceDLL, MAKEINTRESOURCE(uResourceID), szResType); ASSERT(hSource); HGLOBAL hGlobal = LoadResource(hResourceDLL, hSource); ASSERT(hGlobal); LPVOID lpVoid = ::LockResource(hGlobal); ASSERT(lpVoid); int nSize = (UINT)SizeofResource(hResourceDLL, hSource); HGLOBAL hGlobal2 = GlobalAlloc(GMEM_MOVEABLE, nSize); void* pData = GlobalLock(hGlobal2); memcpy(pData, (void *)hGlobal, nSize); GlobalUnlock(hGlobal2); IStream* pStream = NULL; if(S_OK == CreateStreamOnHGlobal(hGlobal2, TRUE, &pStream)) { FreeResource(hGlobal2); return pStream; } return NULL; } //设置窗口大小 void CGdipButton::SetWndSize() { UINT uiWidth = 0; UINT uiHeight = 0; if (NULL!=m_pStdImage && !IsNull()) { uiWidth = m_pStdImage->GetWidth()/IBTSTATENUMS; uiHeight = m_pStdImage->GetHeight(); SetWindowPos(NULL,0,0,uiWidth,uiHeight,SWP_NOMOVE); } else { SetWindowPos(NULL,0,0,uiWidth,uiHeight,SWP_NOMOVE); } m_bIsResetDC = TRUE; Invalidate(); } //设置透明度 void CGdipButton::SetAlpha(float falpha) { m_fAlpha = falpha; m_bIsResetDC = TRUE; Invalidate(); } //获得按钮的宽度 UINT CGdipButton::GetWidth() { if (NULL!=m_pStdImage && !IsNull()) { UINT uiWidth = m_pStdImage->GetWidth()/IBTSTATENUMS; return uiWidth; } return 0; } //获得按钮的高度 UINT CGdipButton::GetHeight() { if (NULL!=m_pStdImage && !IsNull()) { UINT uiHeight = m_pStdImage->GetHeight(); return uiHeight; } return 0; } //刷新 void CGdipButton::Update() { if(NULL!=m_dcBk.m_hDC && NULL!=m_pStdImage && !IsNull() && m_bIsResetDC) { SetDCNull(); CBitmap bmp, *pOldBitmap=NULL; CDC *pScreenDC = GetDC(); if (NULL == pScreenDC) { return; } UINT uiWidth = GetWidth(); UINT uiHeight = GetHeight(); if (0==uiWidth || 0==uiHeight) { return; } Gdiplus::Point points[3]; memset(points, 0, sizeof (points)); points[1].X = uiWidth; points[2].Y = uiHeight; float fColorArray[25] = { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, m_fAlpha, 0, 0, 0, 0, 0, 1 }; // do everything with mem dc CRect rect; rect.left = 0; rect.right = uiWidth; rect.top = 0; rect.bottom = uiHeight; CMemDC pDC(pScreenDC, rect); Gdiplus::Graphics graphics(pDC.m_hDC); // standard image if (m_dcStd.m_hDC == NULL) { PaintBk(&pDC);//绘制透明背景 //正常状态 ColorMatrix colorMatrix; memcpy(&colorMatrix, fColorArray, sizeof (colorMatrix)); ImageAttributes imageAttr; imageAttr.SetColorMatrix(&colorMatrix); graphics.DrawImage(m_pStdImage, points, 3, 0, 0, uiWidth, uiHeight, UnitPixel, &imageAttr); m_dcStd.CreateCompatibleDC(&pDC); bmp.CreateCompatibleBitmap(&pDC, uiWidth, uiHeight); pOldBitmap = m_dcStd.SelectObject(&bmp); m_dcStd.BitBlt(0, 0, uiWidth, uiHeight, &pDC, 0, 0, SRCCOPY); bmp.DeleteObject(); // standard image hot if(m_dcStdH.m_hDC == NULL) {//鼠标经过状态 PaintBk(&pDC); ColorMatrix colorMatrix; memcpy(&colorMatrix, fColorArray, sizeof (colorMatrix)); ImageAttributes imageAttr; imageAttr.SetColorMatrix(&colorMatrix); graphics.DrawImage(m_pStdImage, points, 3, uiWidth, 0, uiWidth, uiHeight, UnitPixel, &imageAttr); m_dcStdH.CreateCompatibleDC(&pDC); bmp.CreateCompatibleBitmap(&pDC, uiWidth, uiHeight); pOldBitmap = m_dcStdH.SelectObject(&bmp); m_dcStdH.BitBlt(0, 0, uiWidth, uiHeight, &pDC, 0, 0, SRCCOPY); bmp.DeleteObject(); } // standard image pressed if (m_dcStdP.m_hDC == NULL) {//鼠标按下状态 PaintBk(&pDC); ColorMatrix colorMatrix; memcpy(&colorMatrix, fColorArray, sizeof (colorMatrix)); ImageAttributes imageAttr; imageAttr.SetColorMatrix(&colorMatrix); graphics.DrawImage(m_pStdImage, points, 3, 2*uiWidth, 0, uiWidth, uiHeight, UnitPixel, &imageAttr); m_dcStdP.CreateCompatibleDC(&pDC); bmp.CreateCompatibleBitmap(&pDC, uiWidth, uiHeight); pOldBitmap = m_dcStdP.SelectObject(&bmp); m_dcStdP.BitBlt(0, 0, uiWidth, uiHeight, &pDC, 0, 0, SRCCOPY); bmp.DeleteObject(); } // standard image hot if(m_dcStdF.m_hDC == NULL) {//获得焦点状态 PaintBk(&pDC); ColorMatrix colorMatrix; memcpy(&colorMatrix, fColorArray, sizeof (colorMatrix)); ImageAttributes imageAttr; imageAttr.SetColorMatrix(&colorMatrix); graphics.DrawImage(m_pStdImage, points, 3, 3*uiWidth, 0, uiWidth, uiHeight, UnitPixel, &imageAttr); m_dcStdF.CreateCompatibleDC(&pDC); bmp.CreateCompatibleBitmap(&pDC, uiWidth, uiHeight); pOldBitmap = m_dcStdF.SelectObject(&bmp); m_dcStdF.BitBlt(0, 0, uiWidth, uiHeight, &pDC, 0, 0, SRCCOPY); bmp.DeleteObject(); } // grayscale image if(m_dcGS.m_hDC == NULL) {//不激活状态 PaintBk(&pDC); ColorMatrix colorMatrix; memcpy(&colorMatrix, fColorArray, sizeof (colorMatrix)); ImageAttributes imageAttr; imageAttr.SetColorMatrix(&colorMatrix); graphics.DrawImage(m_pStdImage, points, 3, 4*uiWidth, 0, uiWidth, uiHeight, UnitPixel, &imageAttr); m_dcGS.CreateCompatibleDC(&pDC); bmp.CreateCompatibleBitmap(&pDC, uiWidth, uiHeight); pOldBitmap = m_dcGS.SelectObject(&bmp); m_dcGS.BitBlt(0, 0, uiWidth, uiHeight, &pDC, 0, 0, SRCCOPY); bmp.DeleteObject(); } } ReleaseDC(pScreenDC); if(m_pCurBtn == NULL) { m_pCurBtn = &m_dcStd; } m_bIsResetDC = FALSE; } } //============================================================================= // // The framework calls this member function when a child control is about to // be drawn. All the bitmaps are created here on the first call. Every thing // is done with a memory DC except the background, which get's it's information // from the parent. The background is needed for transparent portions of PNG // images. An always on top app (such as Task Manager) that is in the way can // cause it to get an incorrect background. To avoid this, the parent should // call the SetBkGnd function with a memory DC when it creates the background. // //============================================================================= HBRUSH CGdipButton::CtlColor(CDC* pScreenDC, UINT nCtlColor) { // background透明背景 if (m_dcBk.m_hDC == NULL) { CBitmap bmp, *pOldBitmap=NULL; UINT uiWidth = GetWidth(); UINT uiHeight = GetHeight(); CRect rect1; CClientDC clDC(GetParent()); GetWindowRect(rect1); GetParent()->ScreenToClient(rect1); m_dcBk.CreateCompatibleDC(&clDC); bmp.CreateCompatibleBitmap(&clDC, uiWidth, uiHeight); pOldBitmap = m_dcBk.SelectObject(&bmp); m_dcBk.BitBlt(0, 0, uiWidth, uiHeight, &clDC, rect1.left, rect1.top, SRCCOPY); bmp.DeleteObject(); } return NULL; } //============================================================================= // paint the background //============================================================================= void CGdipButton::PaintBk(CDC *pDC) { CRect rect; GetClientRect(rect); pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &m_dcBk, 0, 0, SRCCOPY); } //============================================================================= // paint the bitmap currently pointed to with m_pCurBtn //============================================================================= void CGdipButton::PaintBtn(CDC *pDC) { CRect rect; GetClientRect(rect); pDC->BitBlt(0, 0, rect.Width(), rect.Height(), m_pCurBtn, 0, 0, SRCCOPY); } //============================================================================= // set the control to owner draw //============================================================================= void CGdipButton::PreSubclassWindow() { // Set control to owner draw ModifyStyle(0, BS_OWNERDRAW, SWP_FRAMECHANGED); CButton::PreSubclassWindow(); } //============================================================================= // disable double click //============================================================================= BOOL CGdipButton::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_LBUTTONDBLCLK) pMsg->message = WM_LBUTTONDOWN; if (m_pToolTip != NULL) { if (::IsWindow(m_pToolTip->m_hWnd)) { m_pToolTip->RelayEvent(pMsg); } } return CButton::PreTranslateMessage(pMsg); } //============================================================================= // overide the erase function //============================================================================= BOOL CGdipButton::OnEraseBkgnd(CDC* pDC) { return TRUE; } //============================================================================= // Paint the button depending on the state of the mouse //============================================================================= void CGdipButton::DrawItem(LPDRAWITEMSTRUCT lpDIS) { CDC* pDC = CDC::FromHandle(lpDIS->hDC); Update(); BOOL bIsPressed = (lpDIS->itemState & ODS_SELECTED); BOOL bIsFocused = (lpDIS->itemState & ODS_FOCUS); BOOL bDisable=(lpDIS->itemState&ODS_DISABLED); if(bDisable) {//不激活状态 m_pCurBtn = &m_dcGS; } else if(bIsPressed) {//鼠标按下状态 m_pCurBtn = &m_dcStdP; } else if(m_bIsHovering) {//鼠标经过状态 m_pCurBtn = &m_dcStdH; } else if (bIsFocused) {//获得焦点状态 m_pCurBtn = &m_dcStdF; } else {//正常状态 m_pCurBtn = &m_dcStd; } // paint the button PaintBtn(pDC); CDC::DeleteTempMap(); //add lq 2011-12-16 } //============================================================================= LRESULT CGdipButton::OnMouseHover(WPARAM wparam, LPARAM lparam) //============================================================================= { m_bIsHovering = TRUE; Invalidate(); DeleteToolTip(); // Create a new Tooltip with new Button Size and Location SetToolTipText(m_tooltext); if (m_pToolTip != NULL) { if (::IsWindow(m_pToolTip->m_hWnd)) { //Display ToolTip m_pToolTip->Update(); } } return 0; } //============================================================================= LRESULT CGdipButton::OnMouseLeave(WPARAM wparam, LPARAM lparam) //============================================================================= { m_bIsTracking = FALSE; m_bIsHovering = FALSE; Invalidate(); return 0; } //============================================================================= void CGdipButton::OnMouseMove(UINT nFlags, CPoint point) //============================================================================= { if (!m_bIsTracking) { TRACKMOUSEEVENT tme; tme.cbSize = sizeof(tme); tme.hwndTrack = m_hWnd; tme.dwFlags = TME_LEAVE|TME_HOVER; tme.dwHoverTime = 1; m_bIsTracking = _TrackMouseEvent(&tme); } CButton::OnMouseMove(nFlags, point); } //============================================================================= // // Call this member function with a memory DC from the code that paints // the parents background. Passing the screen DC defeats the purpose of // using this function. // //============================================================================= void CGdipButton::SetBkGnd(CDC* pDC) { CRect rect, rectS; CBitmap bmp, *pOldBitmap=NULL; GetClientRect(rect); GetWindowRect(rectS); GetParent()->ScreenToClient(rectS); m_dcBk.DeleteDC(); m_dcBk.CreateCompatibleDC(pDC); bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()); pOldBitmap = m_dcBk.SelectObject(&bmp); m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, rectS.left, rectS.top, SRCCOPY); bmp.DeleteObject(); } //============================================================================= // Set the tooltip with a string resource //============================================================================= void CGdipButton::SetToolTipText(UINT nId, BOOL bActivate) { // load string resource m_tooltext.LoadString(nId); // If string resource is not empty if (m_tooltext.IsEmpty() == FALSE) { SetToolTipText(m_tooltext, bActivate); } } //============================================================================= // Set the tooltip with a CString //============================================================================= void CGdipButton::SetToolTipText(CString spText, BOOL bActivate) { // We cannot accept NULL pointer if (spText.IsEmpty()) return; // Initialize ToolTip InitToolTip(); m_tooltext = spText; // If there is no tooltip defined then add it if (m_pToolTip->GetToolCount() == 0) { CRect rectBtn; GetClientRect(rectBtn); m_pToolTip->AddTool(this, m_tooltext, rectBtn, 1); } // Set text for tooltip m_pToolTip->UpdateTipText(m_tooltext, this, 1); m_pToolTip->SetDelayTime(2000); m_pToolTip->Activate(bActivate); } //============================================================================= void CGdipButton::InitToolTip() //============================================================================= { if (m_pToolTip == NULL) { m_pToolTip = new CToolTipCtrl; // Create ToolTip control m_pToolTip->Create(this); m_pToolTip->Activate(TRUE); } } //============================================================================= void CGdipButton::DeleteToolTip() //============================================================================= { // Destroy Tooltip incase the size of the button has changed. if (m_pToolTip != NULL) { delete m_pToolTip; m_pToolTip = NULL; } } bool CGdipButton::IsNull() { if (NULL == m_pStdImage) { return true; } if (Ok != m_pStdImage->GetLastStatus()) { delete m_pStdImage; m_pStdImage = NULL; return true; } return false; } //重置按钮 void CGdipButton::ResetBT() { if (NULL != m_dcBk.m_hDC) { m_dcBk.DeleteDC(); } m_dcBk.m_hDC = NULL; SetDCNull(); m_bIsResetDC = true; Invalidate(); InvalidateRect(NULL); }
[ "hanshouqing85@163.com" ]
hanshouqing85@163.com
31525f003618cc356b3144bf157de634c51a8d3d
de7e771699065ec21a340ada1060a3cf0bec3091
/analysis/common/src/test/org/apache/lucene/analysis/en/TestEnglishAnalyzer.cpp
17ce891fb59dab5a0c1e8e0a543b4bff4f924c1b
[]
no_license
sraihan73/Lucene-
0d7290bacba05c33b8d5762e0a2a30c1ec8cf110
1fe2b48428dcbd1feb3e10202ec991a5ca0d54f3
refs/heads/master
2020-03-31T07:23:46.505891
2018-12-08T14:57:54
2018-12-08T14:57:54
152,020,180
7
0
null
null
null
null
UTF-8
C++
false
false
1,699
cpp
using namespace std; #include "TestEnglishAnalyzer.h" #include "../../../../../../../../../core/src/java/org/apache/lucene/analysis/Analyzer.h" #include "../../../../../../../../../core/src/java/org/apache/lucene/analysis/CharArraySet.h" #include "../../../../../../java/org/apache/lucene/analysis/en/EnglishAnalyzer.h" namespace org::apache::lucene::analysis::en { using Analyzer = org::apache::lucene::analysis::Analyzer; using BaseTokenStreamTestCase = org::apache::lucene::analysis::BaseTokenStreamTestCase; using CharArraySet = org::apache::lucene::analysis::CharArraySet; void TestEnglishAnalyzer::testResourcesAvailable() { delete (make_shared<EnglishAnalyzer>()); } void TestEnglishAnalyzer::testBasics() { shared_ptr<Analyzer> a = make_shared<EnglishAnalyzer>(); // stemming checkOneTerm(a, L"books", L"book"); checkOneTerm(a, L"book", L"book"); // stopword assertAnalyzesTo(a, L"the", std::deque<wstring>()); // possessive removal checkOneTerm(a, L"steven's", L"steven"); checkOneTerm(a, L"steven\u2019s", L"steven"); checkOneTerm(a, L"steven\uFF07s", L"steven"); delete a; } void TestEnglishAnalyzer::testExclude() { shared_ptr<CharArraySet> exclusionSet = make_shared<CharArraySet>(asSet({L"books"}), false); shared_ptr<Analyzer> a = make_shared<EnglishAnalyzer>( EnglishAnalyzer::getDefaultStopSet(), exclusionSet); checkOneTerm(a, L"books", L"books"); checkOneTerm(a, L"book", L"book"); delete a; } void TestEnglishAnalyzer::testRandomStrings() { shared_ptr<Analyzer> a = make_shared<EnglishAnalyzer>(); checkRandomData(random(), a, 1000 * RANDOM_MULTIPLIER); delete a; } } // namespace org::apache::lucene::analysis::en
[ "smamunr@fedora.localdomain" ]
smamunr@fedora.localdomain
8215ca58f27de88df7105aacbd5c53e4dcb59d99
1abf985d2784efce3196976fc1b13ab91d6a2a9e
/opentracker/src/otqt/QtMouseButtonSink.cxx
fd56b0a5fbfcfc884167704aaf3d8240bcfdd8ca
[ "BSD-3-Clause" ]
permissive
dolphinking/mirror-studierstube
2550e246f270eb406109d4c3a2af7885cd7d86d0
57249d050e4195982c5380fcf78197073d3139a5
refs/heads/master
2021-01-11T02:19:48.803878
2012-09-14T13:01:15
2012-09-14T13:01:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,939
cxx
/* ======================================================================== * Copyright (c) 2006, * Institute for Computer Graphics and Vision * Graz University of Technology * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Graz University of Technology nor the names of * its contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ======================================================================== * PROJECT: OpenTracker * ======================================================================== */ /** * @file QtMouseButtonSink.cxx * @author Christian Pirchheim * * @brief Implementation of class @c QtMouseButtonSink * * $Id: OpenTracker.h 900 2006-01-19 16:47:43Z spiczak $ */ #include <OpenTracker/dllinclude.h> #if USE_OTQT #include <OpenTracker/otqt/QtMouseButtonSink.h> #include <OpenTracker/otqt/OTQtLog.h> namespace ot { //-------------------------------------------------------------------------------- void QtMouseButtonSink::onEventGenerated(Event & event, Node & generator) { OTQT_DEBUG("QtMouseButtonSink::onEventGenerated(): --- START: event.getButton() = %hx\n", event.getButton() ); if (!(state_ & EVENT_ACQUIRE_LOCK)) { if (event.getButton() != curr_event_.getButton()) { // acquire tracking event acquireEvent(event); } } // pass original event to parent nodes forwardEvent(event); } void QtMouseButtonSink::pushEvent() { // nothing to do } void QtMouseButtonSink::pullEvent() { // nothing to do } //-------------------------------------------------------------------------------- bool QtMouseButtonSink::buttonPressed(ButtonId button_id) const { if (button_id < 0 || button_id >= BUTTON_COUNT) return false; if (((prev_event_.getButton() >> button_id) & 0x0001) == 0 && ((curr_event_.getButton() >> button_id) & 0x0001) == 1) { return true; } return false; } //-------------------------------------------------------------------------------- bool QtMouseButtonSink::buttonReleased(ButtonId button_id) const { if (button_id < 0 || button_id >= BUTTON_COUNT) return false; if (((prev_event_.getButton() >> button_id) & 0x0001) == 1 && ((curr_event_.getButton() >> button_id) & 0x0001) == 0) { return true; } return false; } //-------------------------------------------------------------------------------- bool QtMouseButtonSink::buttonOn(ButtonId button_id) const { if (button_id < 0 || button_id >= BUTTON_COUNT) return false; return (((curr_event_.getButton() >> button_id) & 0x0001) == 1); } //-------------------------------------------------------------------------------- QMouseButton_t QtMouseButtonSink::getQButtonId(ButtonId button_id) { QMouseButton_t ret = Qt::NoButton; switch (button_id) { case LEFT_BUTTON: ret = Qt::LeftButton; break; case RIGHT_BUTTON: ret = Qt::RightButton; break; case MIDDLE_BUTTON: ret = Qt::MidButton; break; } return ret; } } // namespace ot #endif // USE_OTQT /* * ------------------------------------------------------------ * End of QtMouseButtonSink.cxx * ------------------------------------------------------------ * Automatic Emacs configuration follows. * Local Variables: * mode:c++ * c-basic-offset: 4 * eval: (c-set-offset 'substatement-open 0) * eval: (c-set-offset 'case-label '+) * eval: (c-set-offset 'statement 'c-lineup-runin-statements) * eval: (setq indent-tabs-mode nil) * End: * ------------------------------------------------------------ */
[ "s.astanin@gmail.com" ]
s.astanin@gmail.com
1fd0cf67966e0ababa38aadb2665ad17342f6aba
ae4fb37916933d5ecce3655e8730759a59426849
/Zee/Zee/Source/BillboardNode.cpp
80eee9fb4c88eabfceff568aa1b671a2d604f723
[]
no_license
15831944/Zee
1c29fc6c5696f0e4dc486ef5b7f24922b9194f35
794890424b060e7fa3e88c87a0e7b4fc8c39c872
refs/heads/master
2023-03-20T21:00:42.104338
2014-03-29T08:48:54
2014-03-29T08:48:54
null
0
0
null
null
null
null
GB18030
C++
false
false
1,833
cpp
#include "BillboardNode.h" #include "Engine.h" #include "Camera.h" BillboardNode::BillboardNode( const wchar_t* name, float width, float height, D3DCOLOR color ) :SceneNode(name) { mType = SCENE_NODE_BILLBOARD; mBillboard = New Billboard(width, height, color); gEngine->GetResourceManager()->AddBillboard(mBillboard); mBillboard->Grab(); } void BillboardNode::Draw(Camera* camera) { mBillboard->Draw(mWorldPos, camera); } Billboard* BillboardNode::GetBillboard() { return mBillboard; } void BillboardNode::updateAABBoxSelf() { Camera* camera = gEngine->GetSceneManager()->GetMainCamera(); // TODO:这里直接使用了mainCamera Vector3 pos[4]; pos[0] = mWorldPos - 0.5f * mBillboard->GetWidth() * camera->GetWorldRight().Normalized() - 0.5f * mBillboard->GetHeight() * camera->GetWorldUp().Normalized(); pos[1] = mWorldPos - 0.5f * mBillboard->GetWidth() * camera->GetWorldRight().Normalized() + 0.5f * mBillboard->GetHeight() * camera->GetWorldUp().Normalized(); pos[2] = mWorldPos + 0.5f * mBillboard->GetWidth() * camera->GetWorldRight().Normalized() - 0.5f * mBillboard->GetHeight() * camera->GetWorldUp().Normalized(); pos[3] = mWorldPos + 0.5f * mBillboard->GetWidth() * camera->GetWorldRight().Normalized() + 0.5f * mBillboard->GetHeight() * camera->GetWorldUp().Normalized(); mAABBox.mMin = Vector3(FLT_MAX, FLT_MAX, FLT_MAX); mAABBox.mMax = Vector3(-FLT_MAX, -FLT_MAX, -FLT_MAX); for(int i = 0; i < 4; ++i) { if(pos[i].x > mAABBox.mMax.x) mAABBox.mMax.x = pos[i].x; if(pos[i].x < mAABBox.mMin.x) mAABBox.mMin.x = pos[i].x; if(pos[i].y > mAABBox.mMax.y) mAABBox.mMax.y = pos[i].y; if(pos[i].y < mAABBox.mMin.y) mAABBox.mMin.y = pos[i].y; if(pos[i].z > mAABBox.mMax.z) mAABBox.mMax.z = pos[i].z; if(pos[i].z < mAABBox.mMin.z) mAABBox.mMin.z = pos[i].z; } }
[ "sinyocto@gmail.com" ]
sinyocto@gmail.com
e5109c838464ccbdef1fc79d5eb9d999d9e64477
ed20cf1539dbc0aa2f57f3451f0aba2c77e02eb8
/week-05/day-2/Animal_protection/AnimalShelter.h
2835ed30027c3641ad65acd10019a9d5fff712a9
[]
no_license
green-fox-academy/Joco456
60b0090dcc9f368240cca045eea4b3f67df69f83
3b98cdb39f26010246ecc38837b62e4f37d00b91
refs/heads/master
2020-05-04T08:59:18.192461
2019-10-03T09:17:11
2019-10-03T09:17:11
179,058,002
0
0
null
null
null
null
UTF-8
C++
false
false
641
h
// // Created by Admin on 30/04/2019. // #ifndef ANIMAL_PROTECTION_ANIMALSHELTER_H #define ANIMAL_PROTECTION_ANIMALSHELTER_H #include "Animal.h" #include <vector> #include <map> class AnimalShelter { public: AnimalShelter(); int rescue(Animal *animal); int heal(); void addAdopter(std::string name); std::map<Animal*, std::string> findNewOwner(std::vector<Animal*> animals, std::vector<std::string> adopters); int earnDonation(int amount); void toString(); private: int _budget; std::vector<Animal*> _animals; std::vector<std::string> _adopters; }; #endif //ANIMAL_PROTECTION_ANIMALSHELTER_H
[ "jozsef.varga.123@gmail.com" ]
jozsef.varga.123@gmail.com
ca5d789853144904fd3db7957b3ed132a57889b2
32b8db47c9335f65aeb39848c928c3b64fc8a52e
/mgame-client-classes-20160829/game/ui/system/Window.cpp
39c766eb4ec960bedf3b72fa47d46578d20722e9
[]
no_license
mengtest/backup-1
763dedbb09d662b0940a2cedffb4b9fd1f7fb35d
d9f34e5bc08fe88485ac82f8e9aa09b994bb0e54
refs/heads/master
2020-05-04T14:29:30.181303
2016-12-13T02:28:23
2016-12-13T02:28:23
null
0
0
null
null
null
null
GB18030
C++
false
false
17,823
cpp
#include "Window.h" #include "game/ui//PageFunction.h" #include "achieve/AchievePanel.h" #include "game/winner/WinnerControl.h" #include "act/ActPanel.h" #include "game/notice/NoticeDialog.h" #include "game/ui/dialogs/GiftAwardDialog.h" #include "game/ui/dialogs/About.h" #include "game/ui/dialogs/ConnectingNode.h" #include "game/ui/dialogs/BackPackDialog.h" #include "game/ui/dialogs/DayTaskDialog.h" #include "game/act/ActFirstCharge.h" #include "game/ui/dialogs/ActivationDialog.h" #include "game/chat/ChattingDialog.h" #include "game/chat/ExpressionPanel.h" #include "game/ui/dialogs/PvpRoom.h" #include "game/ui/dialogs/FriendDialog.h" #include "game/ui/dialogs/PvpInviteDialog.h" #include "game/ui/dialogs/SetHeadDialog.h" #include "game/chat/InfoPanel.h" #include "game/ui/dialogs/NewsBibleDialog.h" #include "prop/PropItem.h" #include "data/TableManager.h" #include "winner/WinnerGift.h" #include "game/ui/dialogs/CrazyWeekDialog.h" #include "shop/ShopPanel.h" #include "game/mail/MailProxy.h" #include "game/ui/dialogs/HonorShopDialog.h" #include "game/notice/ActInform.h" #include "game/ui/dialogs/VipDialog.h" #include "game/ui/dialogs/VipTimeDialog.h" #include "game/ui/dialogs/PlayerUpgradeDialog.h" #include "game/ui/dialogs/UpRankSessionDialog.h" #include "ResManager.h" #include "core/luaHelp/CppCallLuaHelper.h" #include "game/login/SrvListDialog.h" #include "game/ui/dialogs/BadgeDialog.h" #include "game/login/SrvDownNoticeDialog.h" #include "game/ui/dialogs/BoxRewardDialog.h" #include "CCLuaEngine.h" #include "game/battle/BattleControl.h" #ifdef MGAME_PLATFORM_MPLUS #include "mplus/CustomerService.h" #include "mplus/FiveStar.h" #include "mplus/InviteCodeDialog.h" #include "mplus/DailyHeroes.h" #endif Widget* Window::LAYER_UIMANAGER_LAYER = nullptr; map<std::string, Window*> Window::CACHE_WINDOWS = *(new std::map<std::string, Window*>()); bool Window::initOnceFlag = false; Window::Window() :mIsCanClean(true) ,mIsNoRelease(false) { } Window::Window(ePriority priority) { } Window::Window(Widget* belongTo) { } Window::Window(ePriority priority, Widget* showFrom) { } ePriority Window::getPriority() { return mPriority; } //窗口暂时不分类 void Window::initOnce() { //if (!initOnceFlag) //{ // LAYER_UIMANAGER_LAYER->addChild(LAYER_WINDOW); // initOnceFlag = true; //} } Widget* Window::getShowFromLayer() { return pShowFrom; } void Window::setWindowLayoutEnable(bool enable) { this->pWindowLayout->setVisible(enable); } bool Window::isWindowLayoutEnable() { return this->pWindowLayout->isVisible(); } bool Window::_initWindow(ePriority priority, Widget* showFrom) { //first init //Window::initOnce(); // //Size size = Director::getInstance()->getWinSize(); this->bIsShow = false; mPriority = priority; pShowFrom = showFrom != NULL ? showFrom : LAYER_UIMANAGER_LAYER; pWindowLayout = CSLoader::getInstance()->createNode("GenerlPage.csb"); pWindowLayout->retain(); addChildCenter(this); //this->setPosition(Vec2(-1 * this->getContentSize().width / 2, -1 * this->getContentSize().height / 2)); pWindowLayout->addChild(this); pWindowLayout->setZOrder((int)this->mPriority); return true; } void Window::setShow(bool b) { if (bIsShow != b) { if (b) { Window::Add(this); this->bIsShow = true; this->onShow(); } else { Window::Remove(this); this->bIsShow = false; this->onClose(); this->afterClose(); cleanUp(); } } //else if (bIsShow&&b) //{ // Window::Add(this); //} } bool Window::isShow() { return bIsShow; } void Window::addChildCenter(Node* node) { Vec2 pos; Size size = (Director::getInstance()->getWinSize() - node->getContentSize()) / 2; pos.x = size.width; pos.y = size.height; node->setPosition(pos); } void Window::Add(Window* ui) { ui->getShowFromLayer()->addChild(ui->pWindowLayout); } void Window::Remove(Window* ui) { ui->pWindowLayout->removeFromParent(); /*map<std::string, Window*>::iterator it = CACHE_WINDOWS.find(ui->getPageName()); if (it != CACHE_WINDOWS.end()) { CACHE_WINDOWS.erase(it); }*/ } Window* Window::Create(std::string pageName, ePageType pageType,const int luaType ) { map<std::string, Window*>::iterator it = CACHE_WINDOWS.find(pageName); if (it != CACHE_WINDOWS.end()) { if (luaType == 1) { int luaWinId = sgCppCallLuaHelper()->getLuaWindowId(pageName); sgResManager()->loadResByPageType(luaWinId); } else { sgResManager()->loadResByPageType(pageType); } return it->second; } else { Window* gameWindow = createWithName(pageName, pageType, luaType); if (gameWindow && gameWindow->_initWindow(PRIORITY_WINDOW, NULL)) { CACHE_WINDOWS.insert(std::make_pair(pageName, gameWindow)); return gameWindow; } } return nullptr; } Window* Window::createWithName(std::string pageName, ePageType pageType, const int luaType) { Window* pPage = nullptr; //目前代码中init用到了资源 if (luaType == 1) { int luaWinId = sgCppCallLuaHelper()->getLuaWindowId(pageName); sgResManager()->loadResByPageType(luaWinId); } else { sgResManager()->loadResByPageType(pageType); } if (luaType) { pPage = sgCppCallLuaHelper()->CallOnReceiveMassage(pageName); } else { if (pageName == "ResultDialog.csb") pPage = ResultDialog::create(); else if (pageName == "FailDialog.csb") pPage = FailDialog::create(); else if (pageName == "LevelDialog.csb") pPage = LevelDialog::create(); else if (pageName == "PauseDialog.csb") pPage = PauseDialog::create(); else if (pageName == "GenerlDialog.csb") pPage = GenerlDialog::create(); else if (pageName == "ShopNode.csb") pPage = ShopPanel::create(); else if (pageName == "SetDialog.csb") pPage = SetDialog::create(); else if (pageName == "PVPDialog.csb") pPage = PvpDialog::create(); else if (pageName == "AchieveNode.csb") pPage = AchievePanel::create(); else if (pageName == "ActNode.csb") pPage = ActPanel::create(); else if (pageName == "RankingDialog.csb") pPage = RankingDialog::create(); else if (pageName == "WinnerDialog.csb") pPage = WinnerDialog::create(); else if (pageName == "ProDialog.csb") pPage = ProDialog::create(); else if (pageName == "NoticeDialog.csb") pPage = NoticeDialog::create(); else if (pageName == "GiftAwardNode.csb") pPage = GiftAwardDialog::create(); //else if (pageName == "SetNameDialog.csb") // pPage = SetNameDialog::create(); else if (pageName == "PVPResult.csb") pPage = PVPResult::create(); else if (pageName == "ShopDetailed.csb") pPage = ShopDetailed::create(); else if (pageName == "PVPWatchDialog.csb") pPage = PVPWatchDialog::create(); else if (pageName == "PVPRoomBackDialog.csb") pPage = PVPRoomBackDialog::create(); else if (pageName == "About.csb") pPage = About::create(); else if (pageName == "ConnectingNode.csb") pPage = ConnectingNode::create(); else if (pageName == "backpackDialog.csb") pPage = BackPackDialog::create(); else if (pageName == "DayTaskNode.csb") pPage = DayTaskDialog::create(); else if (pageName == "PowerDialog.csb") pPage = PowerDialog::create(); //else if (pageName == "ActNewerPacksDialog.csb") // pPage = ActNewerPacksDialog::create(); else if (pageName == "ActivationDialog.csb") pPage = ActivationDialog::create(); else if (pageName == "ChattingDialog.csb") pPage = ChattingDialog::create(); else if (pageName == "ExpressionPanel.csb") pPage = ExpressionPanel::create(); else if (pageName == "FriendPanel.csb") pPage = FriendDialog::create(); else if (pageName == "PropNoSetDilog.csb") pPage = PropNoSetDilog::create(); else if (pageName == "PVPRoom.csb") pPage = PvpRoom::create(); else if (pageName == "PVPInvite.csb") pPage = PvpInviteDialog::create(); else if (pageName == "SetHeadDialog.csb") pPage = SetHeadDialog::create(); else if (pageName == "InfoPanel.csb") pPage = InfoPanel::create(); //else if (pageName == "GenerlDialog2.csb") // pPage = GeneralDialogOther::create(); else if (pageName == "PropExchangeView") pPage = PropExchangeView::create(); else if (pageName == "NewsBibleDialog.csb") pPage = NewsBibleDialog::create(); else if (pageName == "PvpInfoDialog.csb") pPage = PvpInfoDialog::create(); else if (pageName == "ReLogin.csb") pPage = ReLoginDialog::create(); else if (pageName == "PVPMatchLoadingDialog.csb") pPage = PVPMatchLoadingDialog::create(); else if (pageName == "WinnerGift.csb") pPage = WinnerGift::create(); else if (pageName == "KickPlayer.csb") pPage = KickPlayerDialog::create(); else if (pageName == "CrazyWeekDialog.csb") pPage = CrazyWeekDialog::create(); else if (pageName == "RankingInfoNode.csb") pPage = RankingInfoDialog::create(); else if (pageName == "MailNode.csb") pPage = MailPanel::create(); else if (pageName == "UpRankSessionNode.csb") pPage = UpRankSessionDialog::create(); else if (pageName == "ActFirstCharge.csb") pPage = ActFirstCharge::create(); /*else if (pageName == "ResultDialog.csb") pPage = ResultDialog::create(); else if (pageName == "FailDialog.csb") pPage = FailDialog::create(); else if (pageName == "LevelDialog.csb") pPage = LevelDialog::create(); else if (pageName == "PauseDialog.csb") pPage = PauseDialog::create(); else if (pageName == "GenerlDialog.csb") pPage = GenerlDialog::create(); else if (pageName == "ShopNode.csb") pPage = ShopPanel::create(); else if (pageName == "PVPDialog.csb") pPage = PvpDialog::create(); else if (pageName == "RankingDialog.csb") pPage = RankingDialog::create(); else if (pageName == "WinnerDialog.csb") pPage = WinnerDialog::create(); else if (pageName == "ProDialog.csb") pPage = ProDialog::create(); else if (pageName == "NoticeDialog.csb") pPage = NoticeDialog::create(); else if (pageName == "GiftAwardNode.csb") pPage = GiftAwardDialog::create(); else if (pageName == "SetNameDialog.csb") pPage = SetNameDialog::create(); else if (pageName == "PVPResult.csb") pPage = PVPResult::create(); else if (pageName == "ShopDetailed.csb") pPage = ShopDetailed::create(); else if (pageName == "PVPWatchDialog.csb") pPage = PVPWatchDialog::create(); else if (pageName == "PVPRoomBackDialog.csb") pPage = PVPRoomBackDialog::create(); else if (pageName == "About.csb") pPage = About::create(); else if (pageName == "ConnectingNode.csb") pPage = ConnectingNode::create(); else if (pageName == "backpackDialog.csb") pPage = BackPackDialog::create(); else if (pageName == "DayTaskNode.csb") pPage = DayTaskDialog::create(); else if (pageName == "PowerDialog.csb") pPage = PowerDialog::create(); else if (pageName == "ActFirstCharge.csb") pPage = ActFirstCharge::create(); else if (pageName == "ActivationDialog.csb") pPage = ActivationDialog::create(); else if (pageName == "ChattingDialog.csb") pPage = ChattingDialog::create(); else if (pageName == "ExpressionPanel.csb") pPage = ExpressionPanel::create(); else if (pageName == "FriendPanel.csb") pPage = FriendDialog::create(); else if (pageName == "PropNoSetDilog.csb") pPage = PropNoSetDilog::create(); else if (pageName == "PVPRoom.csb") pPage = PvpRoom::create(); else if (pageName == "PVPInvite.csb") pPage = PvpInviteDialog::create(); else if (pageName == "SetHeadDialog.csb") pPage = SetHeadDialog::create(); else if (pageName == "InfoPanel.csb") pPage = InfoPanel::create(); else if (pageName == "PropExchangeView") pPage = PropExchangeView::create(); else if (pageName == "NewsBibleDialog.csb") pPage = NewsBibleDialog::create(); else if (pageName == "PvpInfoDialog.csb") pPage = PvpInfoDialog::create(); else if (pageName == "ReLogin.csb") pPage = ReLoginDialog::create(); else if (pageName == "PVPMatchLoadingDialog.csb") pPage = PVPMatchLoadingDialog::create(); else if (pageName == "WinnerGift.csb") pPage = WinnerGift::create(); else if (pageName == "KickPlayer.csb") pPage = KickPlayerDialog::create(); else if (pageName == "CrazyWeekDialog.csb") pPage = CrazyWeekDialog::create(); else if (pageName == "RankingInfoDialog.csb") pPage = RankingInfoDialog::create(); else if (pageName == "MailNode.csb") pPage = MailPanel::create(); */ else if (pageName == "HonorShopDialog.csb") pPage = HonorShopDialog::create(); else if (pageName == "ActInform.csb") pPage = ActInform::create(); else if (pageName == "VIPDialog.csb") pPage = VipDialog::create(); else if (pageName == "VipTimeEnd.csb") pPage = VipTimeDialog::create(); else if (pageName == "upgradeNode.csb") pPage = PlayerUpgradeDialog::create(); else if (pageName == "SrvListDialog.csb") pPage = SrvListDialog::create(); else if (pageName == "BadgeDialog.csb") pPage = BadgeDialog::create(); else if (pageName == "SrvDownNoticeDialog.csb") pPage = SrvDownNoticeDialog::create(); else if (pageName == "ChattingTips.csb") pPage = ChattingTips::create(); else if (pageName == "BoxRewardDialog.csb") pPage = BoxRewardDialog::create(); else if (pageName == "NameingDialog.csb") pPage = NameingDialog::create(); #ifdef MGAME_PLATFORM_MPLUS else if (pageName == "SetDialog.csb") pPage = SetDialog::create(); else if (pageName == "CustomerService.csb") pPage = CustomerService::create(); else if (pageName == "InviteCodeDialog.csb") pPage = InviteCodeDialog::create(); else if (pageName == "FiveStar.csb") pPage = FiveStar::create(); else if (pageName == "FreeDiamond.csb") pPage = FreeDiamond::create(); else if (pageName == "DailyHeroesNode.csb") pPage = DailyHeroes::create(); #endif else { pPage = sgCppCallLuaHelper()->CallOnReceiveMassage(pageName); } } if (pPage != nullptr) { pPage->setLuaType(luaType); pPage->setPageType(pageType); pPage->setPageName(pageName); } return pPage; } void Window::setAllWindowHide() { for (auto it = CACHE_WINDOWS.begin(); it != CACHE_WINDOWS.end();) { auto window = it->second; if (window && !window->mIsNoRelease) { if (window->isShow()) { window->onClose(); } it = CACHE_WINDOWS.erase(it); Window::Remove(window); window->removeFromParent(); window = nullptr; } else it++; } } void Window::showTextTip(const std::string pStr, Point pPoint, Size pSize) { Text* pText = Text::create(); pText->setFontSize(36); pText->setFontName("font.TTF"); pText->setTextColor(Color4B(111, 254, 22, 255)); Size pWinSize = Director::getInstance()->getWinSize(); pText->setPosition(pPoint//mRoot->getPosition() ); //阴影,暂不用参数控制开关 pText->enableShadow(Color4B::BLACK, Size(1, -1)); Director::getInstance()->getNotificationNode()->addChild(pText,1000); pText->setPosition(pWinSize/2); pText->setString(pStr); if (pSize.width != 0.0) { pText->ignoreContentAdaptWithSize(false); pText->setContentSize(pSize); } pText->runAction(Sequence::create(Spawn::create(MoveBy::create(2.0,Vec2(0,250)),FadeOut::create(2.0),NULL), RemoveSelf::create(), NULL)); } void Window::setPageType(ePageType pageType) { mPageType = pageType; } void Window::onShow() { if (mLuaType == 1) { int luaWinId = sgCppCallLuaHelper()->getLuaWindowId(mPageName); sgResManager()->loadResByPageType(luaWinId); } else { sgResManager()->loadResByPageType(mPageType); } if (getLuaType()) { sgCppCallLuaHelper()->onShow(this, true); } } void Window::onClose() { if (mLuaType == 1) { int luaWinId = sgCppCallLuaHelper()->getLuaWindowId(mPageName); sgResManager()->purgeResByPageType(luaWinId); } else { sgResManager()->purgeResByPageType(mPageType); } if (getLuaType()) { sgCppCallLuaHelper()->onShow(this, false); } PageBase::cleanup(); auto msgHandle = dynamic_cast<MessageHandler*>(this); if (msgHandle) sgMessageManager()->removeMessageHandler(msgHandle); if (mPageName == "LevelModeTip.csb" && !sgBattleControl()->getIsPvp()) LuaEngine::getInstance()->executeString("sgUiUtils():saveSceneImage(1)"); } void Window::afterClose() { if (this->getShowingWindowSize() == 0) sgMessageManager()->sendMessage(EMT_OPEN_DAILY_MISSION, ""); } void Window::setBgOpacity(int opacity) { Layout* m = (Layout*)pWindowLayout->getChildByName("Panel_5"); m->setBackGroundColor(Color3B::BLACK); m->setBackGroundColorOpacity(opacity); } void Window::cleanUp() { if (!mIsCanClean) { return; } map<std::string, Window*>::iterator it = CACHE_WINDOWS.find(getPageName()); if (it != CACHE_WINDOWS.end()) { CACHE_WINDOWS.erase(it); } removeFromParent(); } Window* Window::getWindow(std::string pageName) { Window* pWindow = NULL; auto it = CACHE_WINDOWS.find(pageName); if (it != CACHE_WINDOWS.end()) { pWindow = (*it).second; } return pWindow; } Layout* Window::getBgPanel() { Layout* m = (Layout*)pWindowLayout->getChildByName("Panel_5"); return m; } int Window::getWindowSize() { return CACHE_WINDOWS.size(); } int Window::getShowingWindowSize() { int pRet = 0; for (auto it = CACHE_WINDOWS.begin(); it != CACHE_WINDOWS.end(); it++) { if (it->second->isShow() && it->first.compare("SevenGoalNode.csb") != 0) { pRet += 1; } } return pRet; }
[ "1027718562@qq.com" ]
1027718562@qq.com
12d4a1e1020a9891812bd0359fa9f13e28c1d535
1af49694004c6fbc31deada5618dae37255ce978
/chromeos/printing/ppd_metadata_parser.h
dd897696f26dc1ff75e79114413d4b5eab5e7e3f
[ "BSD-3-Clause" ]
permissive
sadrulhc/chromium
59682b173a00269ed036eee5ebfa317ba3a770cc
a4b950c23db47a0fdd63549cccf9ac8acd8e2c41
refs/heads/master
2023-02-02T07:59:20.295144
2020-12-01T21:32:32
2020-12-01T21:32:32
317,678,056
3
0
BSD-3-Clause
2020-12-01T21:56:26
2020-12-01T21:56:25
null
UTF-8
C++
false
false
4,694
h
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file declares parsing functions for use with PPD metadata. // The PpdMetadataManager class is the primary consumer. // // Each Parse*() function promises these invariants: // 1. they attempt to parse as much JSON as possible (returning // all relevant data that can be reasonably extracted), // 2. they return base::nullopt on irrecoverable parse error, and // 3. they never return a non-nullopt value that unwraps into an empty // container. // // Googlers: you may consult the primary documentation for PPD metadata // at go/cros-printing:ppd-metadata #include <string> #include <vector> #include "base/containers/flat_map.h" #include "base/optional.h" #include "base/strings/string_piece_forward.h" #include "base/version.h" #include "chromeos/chromeos_export.h" #ifndef CHROMEOS_PRINTING_PPD_METADATA_PARSER_H_ #define CHROMEOS_PRINTING_PPD_METADATA_PARSER_H_ namespace chromeos { // Defines the limitations on when we show a particular PPD. struct Restrictions { Restrictions(); ~Restrictions(); Restrictions(const Restrictions&); Restrictions& operator=(const Restrictions&); base::Optional<base::Version> min_milestone; base::Optional<base::Version> max_milestone; }; struct CHROMEOS_EXPORT ReverseIndexLeaf { std::string manufacturer; std::string model; }; // A ParsedPrinter is a value parsed from printers metadata. struct CHROMEOS_EXPORT ParsedPrinter { ParsedPrinter(); ~ParsedPrinter(); ParsedPrinter(const ParsedPrinter&); ParsedPrinter& operator=(const ParsedPrinter&); std::string user_visible_printer_name; std::string effective_make_and_model; Restrictions restrictions; }; // A single leaf value parsed from a forward index. struct CHROMEOS_EXPORT ParsedIndexLeaf { ParsedIndexLeaf(); ~ParsedIndexLeaf(); ParsedIndexLeaf(const ParsedIndexLeaf&); ParsedIndexLeaf& operator=(const ParsedIndexLeaf&); std::string ppd_basename; Restrictions restrictions; std::string license; }; // A collection of values parsed from a forward index. // Corresponds to one effective-make-and-model string. struct CHROMEOS_EXPORT ParsedIndexValues { ParsedIndexValues(); ~ParsedIndexValues(); ParsedIndexValues(const ParsedIndexValues&); ParsedIndexValues& operator=(const ParsedIndexValues&); std::vector<ParsedIndexLeaf> values; }; // Maps manufacturer names to basenames of printers metadata. using ParsedManufacturers = base::flat_map<std::string, std::string>; using ParsedPrinters = std::vector<ParsedPrinter>; // * Keys are effective-make-and-model strings. // * Values collect information corresponding to each // effective-make-and-model string - chiefly information about // individual PPDs. // * Googlers, see also: go/cros-printing:ppd-metadata#index using ParsedIndex = base::flat_map<std::string, ParsedIndexValues>; // Maps USB product IDs to effective-make-and-model strings. using ParsedUsbIndex = base::flat_map<int, std::string>; // Maps USB vendor IDs to manufacturer names. using ParsedUsbVendorIdMap = base::flat_map<int, std::string>; // Keyed on effective-make-and-model strings. using ParsedReverseIndex = base::flat_map<std::string, ReverseIndexLeaf>; // Parses |locales_json| and returns a list of locales. CHROMEOS_EXPORT base::Optional<std::vector<std::string>> ParseLocales( base::StringPiece locales_json); // Parses |manufacturers_json| and returns the parsed map type. CHROMEOS_EXPORT base::Optional<ParsedManufacturers> ParseManufacturers( base::StringPiece manufacturers_json); // Parses |printers_json| and returns the parsed map type. CHROMEOS_EXPORT base::Optional<ParsedPrinters> ParsePrinters( base::StringPiece printers_json); // Parses |forward_index_json| and returns the parsed map type. CHROMEOS_EXPORT base::Optional<ParsedIndex> ParseForwardIndex( base::StringPiece forward_index_json); // Parses |usb_index_json| and returns a map of USB product IDs to // effective-make-and-model strings. CHROMEOS_EXPORT base::Optional<ParsedUsbIndex> ParseUsbIndex( base::StringPiece usb_index_json); // Parses |usb_vendor_id_map_json| and returns a map of USB vendor IDs // to manufacturer names. CHROMEOS_EXPORT base::Optional<ParsedUsbVendorIdMap> ParseUsbVendorIdMap( base::StringPiece usb_vendor_id_map_json); // Parses |reverse_index_json| and returns the parsed map type. CHROMEOS_EXPORT base::Optional<ParsedReverseIndex> ParseReverseIndex( base::StringPiece reverse_index_json); } // namespace chromeos #endif // CHROMEOS_PRINTING_PPD_METADATA_PARSER_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
2599ee843a64c1f010407c66eafca96d03c77500
dfcb384119934faff24ecffb3ed88dfa9d82c735
/ZBase/source/ZQuadMesh.cpp
6117022645e870cf7ccd178594b20e928e217041
[]
no_license
Jaegwang/ZFX
65a99bd93f0f5e057126b6915f1a8ae83d24e51b
1bc0ab64d892d992d72eab8cc1bd4bdd977942f9
refs/heads/master
2020-11-27T15:12:31.973573
2019-12-22T02:56:59
2019-12-22T02:56:59
229,505,672
0
0
null
null
null
null
UTF-8
C++
false
false
7,536
cpp
//---------------// // ZQuadMesh.cpp // //-------------------------------------------------------// // author: Wanho Choi @ Dexter Studios // // last update: 2016.11.04 // //-------------------------------------------------------// #include <ZelosBase.h> ZELOS_NAMESPACE_BEGIN ZQuadMesh::ZQuadMesh() { // nothing to do } ZQuadMesh::ZQuadMesh( const ZQuadMesh& other ) { *this = other; } ZQuadMesh::ZQuadMesh( const char* filePathName ) { load( filePathName ); } void ZQuadMesh::reset() { p .reset(); v0123 .reset(); uv .reset(); } ZQuadMesh& ZQuadMesh::operator=( const ZQuadMesh& other ) { p = other.p; v0123 = other.v0123; uv = other.uv; return (*this); } void ZQuadMesh::transform( const ZMatrix& matrix, bool useOpenMP ) { const int numV = numVertices(); #pragma omp parallel for if( useOpenMP && numV>100000 ) FOR( i, 0, numV ) { ZPoint& pt = p[i]; pt = matrix.transform( pt, false ); } } ZBoundingBox ZQuadMesh::boundingBox() const { return p.boundingBox(); } void ZQuadMesh::reverse() { const int numQ = numQuads(); FOR( i, 0, numQ ) { ZInt4& t = v0123[i]; ZSwap( t[1], t[3] ); } } void ZQuadMesh::getVertexNormals( ZVectorArray& normals ) const { const int nVertices = numVertices(); const int nQuads = numQuads(); normals.setLength( nVertices ); ZVector nrm; FOR( i, 0, nQuads ) { const ZInt4& q = v0123[i]; const int& v0=q[0]; const ZPoint& p0=p[v0]; const int& v1=q[1]; const ZPoint& p1=p[v1]; const int& v2=q[2]; const ZPoint& p2=p[v2]; nrm = Area(p0,p1,p2) * Normal(p0,p1,p2); normals[v0] += nrm; normals[v1] += nrm; normals[v2] += nrm; } FOR( i, 0, nVertices ) { normals[i].normalize(); } } void ZQuadMesh::combine( const ZQuadMesh& mesh ) { const int oldNumVerts = numVertices(); const int oldNumQuads = numQuads(); p.append( mesh.p ); v0123.append( mesh.v0123 ); uv.append( mesh.uv ); // Is it meaningful? const int newNumVerts = numVertices(); const int newNumQuads = numQuads(); FOR( i, oldNumQuads, newNumQuads ) { v0123[i][0] += oldNumVerts; v0123[i][1] += oldNumVerts; v0123[i][2] += oldNumVerts; v0123[i][3] += oldNumVerts; } } void ZQuadMesh::getTriangleIndices( ZInt3Array& triangles ) const { triangles.clear(); const int nQ = numQuads(); triangles.reserve( 2*nQ ); ZInt3 idx; FOR( i, 0, nQ ) { const ZInt4& quad = v0123[i]; FOR( j, 0, 2 ) { idx[0] = quad[0]; idx[1] = quad[j+1]; idx[2] = quad[j+2]; triangles.push_back( idx ); } } } double ZQuadMesh::usedMemorySize( ZDataUnit::DataUnit dataUnit ) const { double ret = 0; ret += p.usedMemorySize( dataUnit ); ret += v0123.usedMemorySize( dataUnit ); ret += uv.usedMemorySize( dataUnit ); return ret; } const ZString ZQuadMesh::dataType() const { return ZString( "ZQuadMesh" ); } void ZQuadMesh::write( ofstream& fout ) const { p.write( fout, true ); v0123.write( fout, true ); uv.write( fout, true ); } void ZQuadMesh::read( ifstream& fin ) { p.read( fin, true ); v0123.read( fin, true ); uv.read( fin, true ); } bool ZQuadMesh::save( const char* filePathName ) const { ofstream fout( filePathName, ios::out|ios::binary|ios::trunc ); if( fout.fail() || !fout.is_open() ) { cout << "Error@ZQuadMesh::save(): Failed to save file: " << filePathName << endl; return false; } dataType().write( fout, true ); write( fout ); fout.close(); return true; } bool ZQuadMesh::load( const char* filePathName ) { reset(); ifstream fin( filePathName, ios::out|ios::binary ); if( fin.fail() ) { cout << "Error@ZQuadMesh::load(): Failed to load file." << endl; return false; } ZString type; type.read( fin, true ); if( type != dataType() ) { cout << "Error@ZQuadMesh::load(): Data type mismatch." << endl; reset(); return false; } read( fin ); fin.close(); return true; } void ZQuadMesh::drawVertices() const { p.drawPoints( false ); } void ZQuadMesh::drawWireframe() const { const int numV = numVertices(); const int numQ = numQuads(); if( !( numV && numQ ) ) { return; } glBegin( GL_LINES ); { FOR( i, 0, numQ ) { const ZInt4& q = v0123[i]; glVertex( p[ q[0] ] ); glVertex( p[ q[1] ] ); glVertex( p[ q[1] ] ); glVertex( p[ q[2] ] ); glVertex( p[ q[2] ] ); glVertex( p[ q[3] ] ); glVertex( p[ q[3] ] ); glVertex( p[ q[0] ] ); } } glEnd(); } void ZQuadMesh::drawSurface( bool withNormal ) const { const int numV = numVertices(); const int numQ = numQuads(); if( !( numV && numQ ) ) { return; } if( withNormal ) { glBegin( GL_QUADS ); { FOR( i, 0, numQ ) { const ZInt4& q = v0123[i]; const ZPoint& p0 = p[ q[0] ]; const ZPoint& p1 = p[ q[1] ]; const ZPoint& p2 = p[ q[2] ]; const ZPoint& p3 = p[ q[3] ]; const ZVector n( Normal(p0,p1,p2) ); glNormal( n ); glVertex( p0 ); glNormal( n ); glVertex( p1 ); glNormal( n ); glVertex( p2 ); glNormal( n ); glVertex( p3 ); } } glEnd(); } else { glBegin( GL_QUADS ); { FOR( i, 0, numQ ) { const ZInt4& q = v0123[i]; const ZPoint& p0 = p[ q[0] ]; const ZPoint& p1 = p[ q[1] ]; const ZPoint& p2 = p[ q[2] ]; const ZPoint& p3 = p[ q[3] ]; const ZVector n( Normal(p0,p1,p2) ); glVertex( p0 ); glVertex( p1 ); glVertex( p2 ); glVertex( p3 ); } } glEnd(); } } void ZQuadMesh::draw( ZMeshDisplayMode::MeshDisplayMode mode, const ZColor& lineColor, const ZColor& surfaceColor, float opacity ) const { const int numV = numVertices(); const int numQ = numQuads(); if( !( numV && numQ ) ) { return; } if( mode == ZMeshDisplayMode::zPoints ) // as p cloud { glColor( lineColor, opacity ); glBegin( GL_POINTS ); FOR( i, 0, numV ) { glVertex( p[i] ); } glEnd(); return; } if( ( mode == ZMeshDisplayMode::zSurface ) || ( mode == ZMeshDisplayMode::zWireSurface ) ) // as solid surface { glColor( surfaceColor, opacity ); FOR( i, 0, numQ ) { const ZInt4& q = v0123[i]; glBegin( GL_QUADS ); glVertex( p[ q[0] ] ); glVertex( p[ q[1] ] ); glVertex( p[ q[2] ] ); glVertex( p[ q[3] ] ); glEnd(); } } if( ( mode == ZMeshDisplayMode::zWireframe ) || ( mode == ZMeshDisplayMode::zWireSurface ) ) // as solid surface { glEnable( GL_POLYGON_OFFSET_LINE ); glPolygonOffset( -1, -1 ); glColor( lineColor, opacity ); FOR( i, 0, numQ ) { const ZInt4& q = v0123[i]; glBegin( GL_LINE_LOOP ); glVertex( p[ q[0] ] ); glVertex( p[ q[1] ] ); glVertex( p[ q[2] ] ); glEnd(); } } } void ZQuadMesh::drawVertexNormals( const ZVectorArray& vNrm, float scale ) const { const int numV = numVertices(); if( vNrm.length() != numV ) { cout << "Error@ZQuadMesh::draw(): Invalid array length." << endl; return; } FOR( i, 0, numV ) { glBegin( GL_LINES ); glVertex(p[i]); glVertex(vNrm[i]*scale); glEnd(); } } void ZQuadMesh::drawUVs() const { const int numT = numQuads(); const int numUV = numUVs(); if( !( numT && numUV ) ) { return; } FOR( i, 0, numT ) { int idx = 4*i; glBegin( GL_LINE_LOOP ); glVertex( uv[ idx] ); glVertex( uv[++idx] ); glVertex( uv[++idx] ); glVertex( uv[++idx] ); glEnd(); } } ostream& operator<<( ostream& os, const ZQuadMesh& object ) { os << "<ZQuadMesh>" << endl; os << " # of vertices : " << ZString::commify( object.numVertices() ) << endl; os << " # of quadfaces: " << ZString::commify( object.numQuads() ) << endl; os << endl; return os; } ZELOS_NAMESPACE_END
[ "jaegwang@outlook.com" ]
jaegwang@outlook.com
483f9e18974c6c321d39e2d3ce83fb77443b2785
b5d660ae85d29803df7d8ca42990a12efb5bc6de
/VKTS/src/layer0/engine/TaskQueue.hpp
ab35e1ea76aba246acc763b2572f3145c5501232
[ "MIT", "BSD-3-Clause", "LicenseRef-scancode-khronos", "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-happy-bunny" ]
permissive
mtavenrath/Vulkan
f8ead9761c2f8dfc377f63e35e4556a7f1b336f8
f23e81290c4477c0f9af058dca0a8883742837aa
refs/heads/master
2021-01-18T10:57:35.674378
2016-02-21T14:34:26
2016-02-21T14:34:26
52,257,980
2
1
null
2016-02-22T08:18:19
2016-02-22T08:18:19
null
UTF-8
C++
false
false
2,467
hpp
/** * VKTS - VulKan ToolS. * * The MIT License (MIT) * * Copyright (c) since 2014 Norbert Nopper * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #ifndef VKTS_TASKQUEUE_HPP_ #define VKTS_TASKQUEUE_HPP_ #include <vkts/vkts.hpp> namespace vkts { class TaskQueueElement { public: ITaskSP task; double created; double used; double recycled; double send; double received; TaskQueueElement(const double time) : task(nullptr), created(time), used(-1.0), recycled(-1.0), send(-1.0f), received(-1.0f) { } ~TaskQueueElement() { } }; class TaskQueue { private: std::vector<TaskQueueElement*> taskQueueElementCache; ThreadsafeQueue<TaskQueueElement*> queue; mutable std::mutex mutex; TaskQueueElement* getTaskQueueElement(); void recycleTaskQueueElement(TaskQueueElement* taskQueueElement); public: TaskQueue(); TaskQueue(const TaskQueue& other) = delete; TaskQueue(TaskQueue&& other) = delete; virtual ~TaskQueue(); TaskQueue& operator =(const TaskQueue& other) = delete; TaskQueue& operator =(TaskQueue && other) = delete; VkBool32 addTask(const ITaskSP& task); VkBool32 receiveTask(ITaskSP& task); }; typedef std::shared_ptr<TaskQueue> TaskQueueSP; } /* namespace vkts */ #endif /* VKTS_TASKQUEUE_HPP_ */
[ "norbert@nopper.tv" ]
norbert@nopper.tv
93b37f30690f5380fbb7dfee0ecf5a833ca69059
dd80a584130ef1a0333429ba76c1cee0eb40df73
/external/oprofile/libutil++/op_exception.h
af344ed81d3ebb7ec8d254e46c32488f97acfb56
[ "MIT", "GPL-2.0-only" ]
permissive
karunmatharu/Android-4.4-Pay-by-Data
466f4e169ede13c5835424c78e8c30ce58f885c1
fcb778e92d4aad525ef7a995660580f948d40bc9
refs/heads/master
2021-03-24T13:33:01.721868
2017-02-18T17:48:49
2017-02-18T17:48:49
81,847,777
0
2
MIT
2020-03-09T00:02:12
2017-02-13T16:47:00
null
UTF-8
C++
false
false
1,396
h
/** * @file op_exception.h * exception base class * * This provide simple base class for exception object. All * exception are derived from directly or indirectly from * std::exception. This class are not itended to be catched * in your code except at top level, derive what you want * and catch derived class rather. * * @remark Copyright 2003 OProfile authors * @remark Read the file COPYING * * @author Philippe Elie * @author John Levon */ #ifndef OP_EXCEPTION_H #define OP_EXCEPTION_H #include <stdexcept> #include <string> /** * exception abstract base class */ class op_exception : public std::exception { public: explicit op_exception(std::string const& msg); ~op_exception() throw() = 0; char const * what() const throw(); private: std::string message; }; /** * fatal exception, never catch it except at top level (likely main or * gui). Intended to replace cerr << "blah"; exit(EXIT_FAILURE); by a * throw op_fatal_error("blah") when returning error code is not an option */ struct op_fatal_error : op_exception { explicit op_fatal_error(std::string const & msg); }; /** * Encapsulate a runtime error with or w/o a valid errno */ struct op_runtime_error : std::runtime_error { explicit op_runtime_error(std::string const & err); op_runtime_error(std::string const & err, int cerrno); ~op_runtime_error() throw(); }; #endif /* !OP_EXCEPTION_H */
[ "karun.matharu@gmail.com" ]
karun.matharu@gmail.com
068a9aecd3a42ead9c8fa45c7ac85c0ee3ffb28d
072a4f67c91b9211ecb65fe2565fe2ddfff45892
/phase8/src/main.cpp
0c755c40e74a1dea98ea7aaaa03d81bf6d44ec94
[]
no_license
aradzu10/WebAssDecoders
b09302563007b3a01e97216a9c04aa61c8db6ff0
ac3a45e74163dd6eaf4de68dbc2c5e28930eb331
refs/heads/master
2020-05-09T16:42:49.632326
2019-06-21T08:00:02
2019-06-21T08:00:02
181,279,872
0
1
null
null
null
null
UTF-8
C++
false
false
887
cpp
#include <emscripten.h> #include <string> #include <iostream> #include <sstream> using namespace std; EM_JS(void, run_code, (const char* str), { new Function(UTF8ToString(str))(); }); int main() { int len = 45 * 2; char words[17][10] = {"success", "wait", "pass", "break", "while do", "fail", "signed", "join", "namespace", "queue", "zero", "xor", "HPGK", "02985", "61347", ",;}{", "=:<>()'"}; int numbers[] = { 1, 1, 4, 3, 0, 4, 3, 1, 1, 3, 16, 4, 16, 6, 12, 1, 4, 1, 1, 1, 0, 0, 0, 4, 4, 5, 13, 3, 16, 1, 4, 5, 12, 0, 0, 4, 4, 3, 4, 3, 4, 7, 4, 5, 1, 3, 4, 1, 0, 4, 3, 1, 0, 4, 15, 0, 4, 5, 12, 2, 0, 4, 6, 3, 0, 4, 3, 1, 1, 1, 4, 3, 4, 5, 12, 3, 1, 1, 6, 3, 4, 7, 3, 0, 1, 2, 16, 6, 16, 5 }; ostringstream oss(""); for (int temp = 0; temp < len; temp += 2) oss << words[numbers[temp]][numbers[temp + 1]]; run_code(oss.str().c_str()); }
[ "mdombelski@aligntech.com" ]
mdombelski@aligntech.com
7612b236208467305b930236b7f655b6961f1d6a
06054c85e152651b9f7ff490ed76357fb5e31232
/src/windows/mainwindow.cpp
0458d50dbe5aaa66a7e59b2112e4fa5e62c9d3fd
[]
no_license
isabella232/linuxtag_2019
d0b985ce5cc2ecde81a8ff7df6d6a04ef50b0dd9
cf148bfab90de760ce6bfb4bf8401a3d5c779e0e
refs/heads/master
2022-12-26T12:17:59.719873
2020-10-07T14:46:33
2020-10-07T14:46:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
465
cpp
#include "mainwindow.hpp" #include "ui_mainwindow.h" #include <QDebug> MainWindow::MainWindow( QWidget* parent ) : QMainWindow( parent ), ui( new Ui::MainWindow ) { ui->setupUi( this ); ui->pushButton->setIcon( QIcon( ":/icons/icons/circle.png" ) ); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { qDebug() << "Button was clicked!"; ui->statusBar->showMessage( "Button was clicked!", 2000 ); }
[ "elsamuko@gmail.com" ]
elsamuko@gmail.com
1fc422abc7444b73d6b3085b200df5cabc15138a
072b1f0d3996e93e9820a790624742b001239c21
/gutil/proto_matchers.h
86f8a827a55cdbeb89e1c4fcf4b4a1d88bc0e1ec
[]
no_license
donNewtonAlpha/p4rt_standalone
925d40a60c62ab86f4a88095233064360ab3cb58
f5860e490e6936a03d4f1b18e6f3df72c25f6d71
refs/heads/master
2023-07-01T06:27:40.827170
2021-07-21T17:42:10
2021-07-21T17:42:10
372,921,851
1
0
null
2021-08-06T22:47:23
2021-06-01T18:09:41
C++
UTF-8
C++
false
false
4,643
h
// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef GUTIL_PROTO_MATCHERS_H #define GUTIL_PROTO_MATCHERS_H #include <memory> #include <ostream> #include <string> #include "google/protobuf/message.h" #include "google/protobuf/text_format.h" #include "google/protobuf/util/message_differencer.h" #include "gtest/gtest.h" namespace gutil { // Implements a protobuf matcher interface that verifies 2 protobufs are equal // while ignoring the repeated field ordering. // // Sample usage: // EXPECT_THAT(MyCall(), EqualsProto<pdpi::IrTableEntry>(R"pb( // table_name: "ROUTER_INTERFACE_TABLE" // priority: 123 // matches { // name: "router_interface_id" // exact { str: "16" } // } // )pb")); // // Sample output on failure: // Value of: MyCall() // Expected: // table_name: "ROUTER_INTERFACE_TABLE" // matches { // name: "router_interface_id" // exact { // str: "16" // } // } // priority: 123 // // Actual: 96-byte object <58-AC 77-4D 5C-55 00-00 00-00 00-00 00-00 00-00 // 00-00 00-00 00-00 00-00 01-00 00-00 04-00 00-00 30-8D 80-4D 5C-55 00-00 // 30-55 80-4D 5C-55 00-00 20-25 79-4D 5C-55 00-00 00-00 00-00 00-00 00-00 // 00-00 00-00 00-00 00-00 C8-01 00-00 5C-55 00-00 00-E6 12-7F 70-7F 00-00 // 00-00 00-00 00-00 00-00> (of type pdpi::IrTableEntry), // table_name: "ROUTER_INTERFACE_TABLE" // matches { // name: "router_interface_id" // exact { // str: "16" // } // } // priority: 456 class ProtobufEqMatcher { public: ProtobufEqMatcher(const google::protobuf::Message& expected) : expected_(expected.New()) { expected_->CopyFrom(expected); } ProtobufEqMatcher(const std::string& expected_text) : expected_text_(expected_text) {} ProtobufEqMatcher(const ProtobufEqMatcher& other) : expected_text_(other.expected_text_) { if (other.expected_ != nullptr) { expected_.reset(other.expected_->New()); expected_->CopyFrom(*other.expected_); } } void DescribeTo(std::ostream* os) const { if (expected_ == nullptr) { *os << "\n" << expected_text_; } else { *os << "\n" << expected_->DebugString(); } } void DescribeNegationTo(std::ostream* os) const { *os << "not"; DescribeTo(os); } template <typename ProtoType> bool MatchAndExplain(const ProtoType& actual, ::testing::MatchResultListener* listener) const { // Order does not matter for repeated fields. google::protobuf::util::MessageDifferencer diff; diff.set_repeated_field_comparison( google::protobuf::util::MessageDifferencer::RepeatedFieldComparison:: AS_SET); // TODO: remove listener // output once this is resolved. *listener << "\n" << actual.DebugString(); // When parsing from a proto text string we must first create a temporary // with the same proto type as the "acutal" argument. if (expected_ == nullptr) { ProtoType expected_proto; if (!google::protobuf::TextFormat::ParseFromString(expected_text_, &expected_proto)) { *listener << "\nCould not parse expected proto text as " << expected_proto.GetTypeName(); return false; } return diff.Compare(actual, expected_proto); } // Otherwise we can compare directly with the passed protobuf message. return diff.Compare(actual, *expected_); } private: std::unique_ptr<google::protobuf::Message> expected_ = nullptr; const std::string expected_text_ = ""; }; inline ::testing::PolymorphicMatcher<ProtobufEqMatcher> EqualsProto( const google::protobuf::Message& proto) { return ::testing::MakePolymorphicMatcher(ProtobufEqMatcher(proto)); } inline ::testing::PolymorphicMatcher<ProtobufEqMatcher> EqualsProto( const std::string& proto_text) { return ::testing::MakePolymorphicMatcher(ProtobufEqMatcher(proto_text)); } } // namespace gutil #endif // GUTIL_PROTO_MATCHERS_H
[ "don@opennetworking.org" ]
don@opennetworking.org
7b4f7927a8820772dcafe45ce8d46c8fcf36f96a
0c843210e8dcc58cf8e54cd7631d714354b94c7e
/LearningOpenGL/LearnOpenGLDemo/LearnOpenGLDemo/Classes/1_gettting_started/hello_triangle_indexed.cpp
fd5ce1e5986cba6b09654ec33a9729f59cbe98ad
[ "MIT" ]
permissive
XINCGer/Unity3DTraining
a76ddef97f6d863b4c5a2fff2df251b61ed4d6fe
e4062ca4955bff0aa11ae08d47e248b8202d0489
refs/heads/master
2023-08-29T19:12:55.721240
2023-08-29T13:58:25
2023-08-29T13:58:25
57,049,212
6,371
1,837
MIT
2023-07-31T11:59:09
2016-04-25T14:37:08
C#
GB18030
C++
false
false
4,313
cpp
#define _Hello_Triangle_Indexed_H #ifndef _Hello_Triangle_Indexed_H #include<glad/glad.h> #include<GLFW/glfw3.h> #include<iostream> void framebuffer_size_callback(GLFWwindow* window, int width, int height); void processInput(GLFWwindow *window); const char *vertexShaderSource = "#version 330 core\n" "layout (location = 0) in vec3 aPos;\n" "void main()\n" "{\n" " gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n" "}\0"; const char *fragmentShaderSource = "#version 330 core\n" "out vec4 FragColor;\n" "void main()\n" "{\n" " FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n" "}\n\0"; int main() { glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); GLFWwindow * window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL); if (NULL == window) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); //初始化glad if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { std::cout << "Failed to initialize GLAD" << std::endl; return -1; } //创建编译Shader //顶点着色器 int vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, 1, &vertexShaderSource, NULL); glCompileShader(vertexShader); //检测Shader编译结果 int success; char infoLog[512]; glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(vertexShader, 512, NULL, infoLog); std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl; } //片段着色器 int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL); glCompileShader(fragmentShader); //检测Shader编译结果 glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog); std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl; } //链接Shader int shaderProgram = glCreateProgram(); glAttachShader(shaderProgram, vertexShader); glAttachShader(shaderProgram, fragmentShader); glLinkProgram(shaderProgram); //检测Shader链接结果 glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success); if (!success) { glGetProgramInfoLog(shaderProgram, 521, NULL, infoLog); std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl; } //删除Shader对象 glDeleteShader(vertexShader); glDeleteShader(fragmentShader); //设置顶点数据 float vertices[] = { 0.5f, 0.5f, 0.0f, // top right 0.5f, -0.5f, 0.0f, // bottom right -0.5f, -0.5f, 0.0f, // bottom left -0.5f, 0.5f, 0.0f // top left }; unsigned int indices[] = { // note that we start from 0! 0, 1, 3, // first Triangle 1, 2, 3 // second Triangle }; unsigned int VBO, VAO,EBO; glGenVertexArrays(1, &VAO); glGenBuffers(1, &VBO); glGenBuffers(1, &EBO); //绑定VAO glBindVertexArray(VAO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void *)0); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); while (!glfwWindowShouldClose(window)) { processInput(window); glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //绘制三角形 glUseProgram(shaderProgram); glBindVertexArray(VAO); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glfwSwapBuffers(window); glfwPollEvents(); } glDeleteVertexArrays(1, &VAO); glDeleteBuffers(1, &VBO); glDeleteBuffers(1, &EBO); glfwTerminate(); return 0; } void framebuffer_size_callback(GLFWwindow * window, int width, int height) { glViewport(0, 0, width, height); } void processInput(GLFWwindow * window) { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) { glfwSetWindowShouldClose(window, true); } } #endif // !_Hello_Triangle_Indexed_H
[ "1790617178@qq.com" ]
1790617178@qq.com
c20229ac30dccb072f027aa45d9e6a5940bbf9e9
4352b5c9e6719d762e6a80e7a7799630d819bca3
/tutorials/eulerVortex.twitch.test-test-test/eulerVortex.cyclic.twitch/1.62/mag(U)
6ad49aac5fd4f22210c5e70e10c549f3c140e69d
[]
no_license
dashqua/epicProject
d6214b57c545110d08ad053e68bc095f1d4dc725
54afca50a61c20c541ef43e3d96408ef72f0bcbc
refs/heads/master
2022-02-28T17:20:20.291864
2019-10-28T13:33:16
2019-10-28T13:33:16
184,294,390
1
0
null
null
null
null
UTF-8
C++
false
false
83,099
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "1.62"; object mag(U); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<scalar> 10000 ( 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999969 0.999969 0.999969 0.999969 0.999969 0.999969 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999969 0.999969 0.999969 0.999969 0.999969 0.999969 0.999968 0.999968 0.999968 0.999969 0.999969 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999969 0.999969 0.99997 0.999969 0.999968 0.999968 0.999968 0.999967 0.999967 0.999967 0.999967 0.999967 0.999968 0.999968 0.999969 0.99997 0.99997 0.999971 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.999969 0.999969 0.999967 0.999967 0.999966 0.999965 0.999965 0.999964 0.999965 0.999965 0.999966 0.999967 0.999968 0.999969 0.99997 0.999971 0.999972 0.999972 0.999971 0.999972 0.999971 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999968 0.999967 0.999966 0.999965 0.999962 0.999961 0.99996 0.999959 0.99996 0.999961 0.999961 0.999964 0.999966 0.999968 0.99997 0.999971 0.999973 0.999973 0.999973 0.999973 0.999972 0.999972 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999967 0.999966 0.999963 0.99996 0.999957 0.999954 0.999952 0.999951 0.99995 0.999951 0.999954 0.999957 0.999962 0.999966 0.999969 0.999971 0.999973 0.999974 0.999975 0.999975 0.999974 0.999973 0.999972 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999968 0.999967 0.999964 0.999962 0.999957 0.999952 0.999947 0.999942 0.999937 0.999935 0.999935 0.999936 0.99994 0.999946 0.999953 0.999959 0.999964 0.99997 0.999974 0.999976 0.999977 0.999976 0.999975 0.999975 0.999974 0.999972 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999968 0.999966 0.999961 0.999955 0.999947 0.999939 0.999929 0.99992 0.999911 0.999907 0.999905 0.999907 0.999913 0.999923 0.999935 0.999946 0.999957 0.999965 0.999972 0.999976 0.999979 0.999979 0.999978 0.999977 0.999975 0.999974 0.999972 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999968 0.999966 0.999961 0.999954 0.999944 0.99993 0.999914 0.999897 0.99988 0.999866 0.999856 0.999852 0.999855 0.999865 0.99988 0.999899 0.999919 0.999939 0.999954 0.999967 0.999975 0.99998 0.999982 0.999982 0.99998 0.999977 0.999975 0.999973 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999966 0.999962 0.999954 0.999941 0.999922 0.999899 0.99987 0.99984 0.99981 0.999784 0.999767 0.999759 0.999763 0.999778 0.999803 0.999835 0.999869 0.999901 0.999931 0.999953 0.999969 0.999979 0.999983 0.999983 0.999983 0.99998 0.999977 0.999975 0.999973 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999968 0.999963 0.999955 0.99994 0.999917 0.999885 0.999844 0.999795 0.999742 0.99969 0.999644 0.999611 0.999596 0.9996 0.999625 0.999666 0.999719 0.999776 0.999831 0.999882 0.999922 0.999951 0.999971 0.999982 0.999985 0.999985 0.999982 0.999979 0.999976 0.999973 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999971 0.99997 0.999969 0.999966 0.999957 0.999941 0.999915 0.999875 0.999818 0.999749 0.999665 0.999572 0.999483 0.999404 0.999346 0.999318 0.999322 0.99936 0.999427 0.999514 0.999609 0.999704 0.999789 0.999861 0.999913 0.999949 0.999971 0.999982 0.999984 0.999983 0.999979 0.999976 0.999973 0.999971 0.99997 0.99997 0.999969 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.999969 0.999966 0.999959 0.999944 0.999915 0.99987 0.999801 0.999706 0.999586 0.999444 0.999288 0.999136 0.999 0.9989 0.998848 0.998853 0.998911 0.999019 0.999161 0.99932 0.999479 0.999624 0.999745 0.999839 0.999904 0.999946 0.999969 0.999979 0.99998 0.999979 0.999976 0.999973 0.99997 0.999969 0.999968 0.999968 0.999968 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.999969 0.999969 0.999969 0.99997 0.999969 0.999966 0.99996 0.999946 0.999919 0.999869 0.999791 0.999674 0.999514 0.999312 0.999074 0.998815 0.998559 0.998333 0.998164 0.998073 0.998074 0.998168 0.998341 0.998571 0.998831 0.999094 0.999334 0.999539 0.9997 0.999816 0.999892 0.999938 0.999962 0.999972 0.999974 0.999972 0.99997 0.999968 0.999967 0.999966 0.999967 0.999967 0.999968 0.999968 0.999968 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.999969 0.99997 0.999969 0.999968 0.999968 0.999969 0.999968 0.999966 0.999961 0.999949 0.999923 0.999873 0.999789 0.999656 0.99946 0.999194 0.99886 0.998467 0.998041 0.997621 0.99725 0.99697 0.996819 0.996817 0.996963 0.997239 0.997609 0.998029 0.998456 0.998851 0.999189 0.999459 0.999657 0.999794 0.999879 0.999927 0.999951 0.999961 0.999964 0.999964 0.999963 0.999963 0.999963 0.999965 0.999966 0.999967 0.999968 0.999968 0.999968 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.999969 0.999969 0.999968 0.999967 0.999967 0.999966 0.999965 0.99996 0.99995 0.999927 0.999881 0.999796 0.999653 0.99943 0.999108 0.998673 0.998126 0.997489 0.996802 0.996125 0.995526 0.995075 0.99483 0.994821 0.995052 0.99549 0.99608 0.996751 0.997434 0.998069 0.998618 0.999059 0.99939 0.99962 0.999772 0.999861 0.999911 0.999936 0.999947 0.999952 0.999954 0.999956 0.999958 0.999962 0.999963 0.999965 0.999967 0.999967 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.999969 0.999969 0.999968 0.999968 0.999967 0.999966 0.999965 0.999963 0.999958 0.99995 0.99993 0.999889 0.999809 0.999666 0.99943 0.999064 0.99854 0.99784 0.996965 0.99595 0.994858 0.993785 0.992839 0.992129 0.991745 0.991732 0.992095 0.992785 0.993713 0.994769 0.995846 0.996851 0.997722 0.998426 0.99896 0.99934 0.999593 0.99975 0.999842 0.999892 0.999919 0.999932 0.99994 0.999946 0.999951 0.999955 0.999959 0.999962 0.999965 0.999967 0.999967 0.999968 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.99997 0.999969 0.999968 0.999966 0.999963 0.999962 0.999958 0.999948 0.999932 0.999896 0.999824 0.99969 0.999455 0.99907 0.998484 0.99765 0.996541 0.995164 0.993574 0.991873 0.990207 0.988742 0.987649 0.987059 0.987051 0.987624 0.988701 0.990145 0.991784 0.993454 0.995012 0.996365 0.997463 0.998301 0.998905 0.999313 0.999574 0.999731 0.999821 0.999872 0.9999 0.999917 0.999929 0.999939 0.999947 0.999953 0.999959 0.999962 0.999965 0.999967 0.999968 0.999968 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999969 0.999967 0.999966 0.999963 0.99996 0.999956 0.999947 0.999933 0.999901 0.99984 0.99972 0.9995 0.999121 0.998509 0.997586 0.996282 0.994559 0.992435 0.989992 0.987391 0.984852 0.982632 0.980985 0.980112 0.980128 0.981029 0.982694 0.98491 0.987417 0.989961 0.99233 0.994385 0.996056 0.997335 0.998261 0.998897 0.999309 0.999564 0.999715 0.999801 0.999852 0.999884 0.999906 0.999923 0.999935 0.999945 0.999953 0.999959 0.999962 0.999965 0.999967 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999968 0.999968 0.999966 0.999965 0.99996 0.999955 0.999947 0.999932 0.999906 0.999854 0.999752 0.999557 0.999206 0.99861 0.997657 0.996232 0.994233 0.991612 0.988395 0.984716 0.980814 0.977022 0.973728 0.971302 0.970046 0.970127 0.971535 0.974082 0.97744 0.981215 0.985022 0.988552 0.991603 0.99408 0.995981 0.99736 0.998312 0.998936 0.999326 0.999563 0.999702 0.999785 0.999837 0.999873 0.999899 0.999919 0.999934 0.999946 0.999954 0.999959 0.999964 0.999966 0.999967 0.999968 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999967 0.999967 0.999965 0.999961 0.999955 0.999947 0.999933 0.999911 0.999867 0.999781 0.999618 0.99931 0.998765 0.997848 0.996398 0.994242 0.991243 0.98733 0.982557 0.977122 0.971387 0.965842 0.961049 0.957559 0.955809 0.956037 0.958222 0.962072 0.967089 0.972678 0.978272 0.983424 0.987851 0.99143 0.994168 0.996156 0.997532 0.998438 0.99901 0.99936 0.99957 0.999697 0.999776 0.999829 0.999869 0.999897 0.99992 0.999935 0.999948 0.999956 0.999962 0.999965 0.999967 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999968 0.999968 0.999966 0.999963 0.999957 0.999949 0.999937 0.999915 0.999877 0.999808 0.999674 0.999419 0.99895 0.998123 0.996745 0.994583 0.991395 0.986986 0.981267 0.974324 0.96646 0.958199 0.950252 0.943429 0.938525 0.936168 0.936696 0.940055 0.945801 0.953183 0.961319 0.969382 0.976738 0.983005 0.988038 0.991866 0.994638 0.996551 0.997814 0.998615 0.999106 0.999403 0.999585 0.999698 0.999775 0.999829 0.99987 0.999901 0.999923 0.999939 0.99995 0.999958 0.999963 0.999966 0.999967 0.999968 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999968 0.999967 0.999964 0.999959 0.999953 0.999941 0.999921 0.99989 0.999832 0.999725 0.999521 0.999136 0.998436 0.997212 0.99519 0.99204 0.987425 0.981079 0.972893 0.963005 0.951857 0.9402 0.929044 0.919544 0.912826 0.909782 0.910868 0.915982 0.924443 0.935134 0.946763 0.958147 0.96841 0.977056 0.98393 0.989114 0.992844 0.995406 0.997092 0.998159 0.998815 0.999212 0.999454 0.999608 0.99971 0.999783 0.999837 0.999877 0.999908 0.999929 0.999945 0.999954 0.999961 0.999964 0.999966 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999969 0.999967 0.999966 0.999962 0.999956 0.999945 0.999928 0.999902 0.999855 0.999769 0.99961 0.99931 0.998746 0.997725 0.995959 0.99306 0.988571 0.982035 0.973094 0.961623 0.947834 0.93236 0.91625 0.900923 0.887996 0.879048 0.875317 0.877409 0.885114 0.897396 0.912615 0.928909 0.944624 0.958588 0.970189 0.979288 0.986073 0.9909 0.994188 0.996336 0.997688 0.998516 0.999013 0.999316 0.999509 0.999638 0.999731 0.9998 0.999852 0.99989 0.999918 0.999937 0.99995 0.999958 0.999963 0.999966 0.999967 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999968 0.999966 0.999964 0.999959 0.999951 0.999937 0.999914 0.999876 0.999808 0.999687 0.999457 0.999026 0.998221 0.996774 0.994284 0.990221 0.983968 0.974909 0.962588 0.946859 0.928041 0.907011 0.885225 0.864631 0.847467 0.835926 0.831692 0.835529 0.847013 0.864571 0.885818 0.908145 0.929304 0.947784 0.962875 0.974517 0.98306 0.989051 0.993075 0.995669 0.997283 0.998258 0.99884 0.999191 0.999414 0.999566 0.999676 0.999759 0.999823 0.99987 0.999905 0.999929 0.999945 0.999955 0.999961 0.999965 0.999967 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999968 0.999966 0.999962 0.999956 0.999946 0.999927 0.999896 0.999843 0.999751 0.999581 0.999261 0.998657 0.997537 0.995534 0.992107 0.986544 0.978027 0.965756 0.949149 0.928054 0.902931 0.87498 0.846165 0.819132 0.796948 0.782619 0.778402 0.785169 0.802085 0.826752 0.855776 0.8856 0.913295 0.937 0.95597 0.970306 0.98061 0.987687 0.992342 0.995282 0.997069 0.998125 0.998742 0.999109 0.999343 0.999504 0.999625 0.999721 0.999794 0.99985 0.999891 0.99992 0.999939 0.999952 0.999959 0.999964 0.999966 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.999969 0.999967 0.999965 0.999961 0.999953 0.999939 0.999915 0.999875 0.999805 0.99968 0.999449 0.999013 0.998191 0.996673 0.993967 0.989361 0.981921 0.970586 0.954337 0.93246 0.904811 0.872036 0.835734 0.798504 0.763889 0.736055 0.719084 0.715922 0.727417 0.751968 0.785938 0.824612 0.863326 0.898438 0.927806 0.950748 0.967649 0.979471 0.987354 0.992376 0.995436 0.997221 0.998227 0.998789 0.999113 0.999319 0.999469 0.999588 0.999686 0.999767 0.99983 0.999877 0.99991 0.999933 0.999949 0.999958 0.999962 0.999966 0.999967 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999966 0.999964 0.999958 0.999948 0.999932 0.999902 0.99985 0.99976 0.999597 0.999291 0.998713 0.997622 0.995613 0.992048 0.986004 0.976286 0.961547 0.940531 0.912392 0.877018 0.835298 0.789303 0.742398 0.69924 0.665421 0.64644 0.646052 0.664787 0.699705 0.745397 0.795524 0.84424 0.887258 0.922288 0.948875 0.967832 0.9806 0.988743 0.99366 0.99646 0.997955 0.998707 0.99907 0.999257 0.999377 0.999478 0.999574 0.999665 0.999746 0.999813 0.999864 0.999902 0.999928 0.999945 0.999955 0.999962 0.999966 0.999967 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.999968 0.999966 0.999963 0.999957 0.999945 0.999924 0.999887 0.999822 0.999708 0.9995 0.999106 0.998358 0.996949 0.994356 0.98977 0.982028 0.969636 0.950932 0.924408 0.889114 0.845023 0.793323 0.736619 0.679132 0.626822 0.587076 0.567241 0.57199 0.601052 0.649355 0.709148 0.772263 0.831696 0.882636 0.922828 0.952245 0.972313 0.985088 0.992645 0.996748 0.998732 0.999524 0.999724 0.999688 0.999605 0.999554 0.999554 0.999598 0.999663 0.999735 0.999801 0.999854 0.999894 0.999923 0.999942 0.999954 0.999961 0.999965 0.999967 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999968 0.999966 0.999961 0.999955 0.999941 0.999915 0.999872 0.999793 0.999652 0.999394 0.998899 0.997956 0.996178 0.992913 0.987157 0.977481 0.962065 0.938916 0.906297 0.863215 0.809822 0.747673 0.679929 0.611634 0.5501 0.504793 0.485458 0.497914 0.540442 0.604929 0.680855 0.758156 0.828706 0.88725 0.931721 0.962739 0.982566 0.994043 0.999866 1.00221 1.00264 1.00219 1.00145 1.00075 1.00022 0.99989 0.999723 0.999673 0.99969 0.99974 0.999797 0.999848 0.99989 0.999919 0.999939 0.999952 0.99996 0.999964 0.999967 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999967 0.999965 0.999961 0.999953 0.999936 0.999908 0.999856 0.999764 0.999595 0.99928 0.998675 0.997517 0.995329 0.991318 0.984269 0.972476 0.953781 0.925875 0.886858 0.835821 0.773251 0.701169 0.623231 0.545068 0.474974 0.424403 0.406215 0.428121 0.486396 0.569061 0.662623 0.755112 0.837156 0.902968 0.950729 0.981912 0.99987 1.00846 1.01115 1.01057 1.00856 1.00619 1.00404 1.00236 1.00117 1.00043 1.00001 0.999815 0.999755 0.999766 0.999805 0.999849 0.999888 0.999917 0.999937 0.999951 0.999959 0.999964 0.999967 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999967 0.999965 0.999959 0.999949 0.999932 0.999899 0.999841 0.999736 0.999539 0.999166 0.998443 0.997055 0.99443 0.989623 0.981206 0.967198 0.945122 0.912405 0.867112 0.808651 0.738088 0.658048 0.572562 0.487298 0.410443 0.354359 0.335741 0.366365 0.440738 0.542333 0.654508 0.76316 0.857322 0.930381 0.980684 1.01068 1.0251 1.02908 1.02705 1.02225 1.01676 1.01171 1.00762 1.00459 1.00251 1.00119 1.00043 1.00003 0.999865 0.999817 0.999827 0.999857 0.99989 0.999917 0.999937 0.99995 0.999958 0.999963 0.999967 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999967 0.999964 0.999959 0.999949 0.99993 0.999894 0.99983 0.99971 0.999487 0.999056 0.998216 0.996591 0.993519 0.987904 0.978106 0.9619 0.936545 0.899308 0.848428 0.783971 0.707946 0.623764 0.535656 0.448519 0.368608 0.306592 0.282502 0.316631 0.404396 0.524054 0.655125 0.780783 0.8879 0.968612 1.02119 1.04906 1.05848 1.0562 1.04787 1.03747 1.02742 1.01889 1.01227 1.00749 1.00425 1.00221 1.001 1.00034 1.00002 0.999897 0.999866 0.999875 0.999898 0.999921 0.999938 0.999951 0.999958 0.999964 0.999966 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999967 0.999964 0.999959 0.999948 0.999927 0.99989 0.999821 0.999691 0.999442 0.998958 0.998006 0.996154 0.992649 0.986254 0.975141 0.956892 0.928606 0.887539 0.8324 0.764362 0.6868 0.604055 0.520226 0.438443 0.361266 0.294874 0.259163 0.286223 0.380165 0.514463 0.663236 0.805943 0.926594 1.01554 1.0706 1.09596 1.09946 1.08959 1.07352 1.05621 1.04052 1.0277 1.01798 1.01106 1.00642 1.00347 1.00171 1.00074 1.00023 1.00001 0.999921 0.999903 0.999911 0.999926 0.999941 0.999952 0.999959 0.999964 0.999966 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999967 0.999965 0.999958 0.999948 0.999927 0.999889 0.999817 0.999679 0.999411 0.998881 0.997829 0.99577 0.991872 0.984775 0.972498 0.952509 0.921891 0.878091 0.820635 0.75228 0.678109 0.603247 0.530858 0.461118 0.392215 0.325824 0.278449 0.288247 0.376233 0.51749 0.679813 0.837711 0.971367 1.06863 1.12642 1.14936 1.14656 1.12831 1.10345 1.07815 1.05588 1.03802 1.02467 1.01526 1.00896 1.00497 1.00257 1.00121 1.0005 1.00015 0.999994 0.999941 0.999931 0.999937 0.999946 0.999955 0.999961 0.999965 0.999966 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999967 0.999965 0.999959 0.999949 0.999928 0.99989 0.999817 0.999676 0.999395 0.99883 0.997699 0.995467 0.991243 0.983572 0.970367 0.949078 0.916944 0.87185 0.814458 0.749493 0.683794 0.622571 0.566744 0.512634 0.454866 0.393032 0.341004 0.334278 0.405339 0.541621 0.709237 0.877591 1.0218 1.12615 1.18624 1.20676 1.19772 1.17085 1.13663 1.1026 1.07304 1.04956 1.03215 1.01995 1.01181 1.00665 1.00354 1.00176 1.0008 1.00031 1.00008 0.999987 0.999956 0.99995 0.999954 0.999958 0.999962 0.999966 0.999967 0.999968 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999967 0.999966 0.999961 0.99995 0.999932 0.999896 0.999825 0.999684 0.999397 0.998813 0.997629 0.995275 0.99081 0.982737 0.968913 0.946864 0.914183 0.869426 0.814634 0.756623 0.703623 0.659813 0.622717 0.584915 0.539208 0.485336 0.4363 0.422199 0.475066 0.59559 0.757681 0.929132 1.07933 1.18783 1.24847 1.26589 1.25061 1.21525 1.17161 1.12858 1.09134 1.0619 1.04015 1.02496 1.01486 1.00846 1.00459 1.00235 1.00113 1.00049 1.00018 1.00004 0.999984 0.999965 0.999962 0.999962 0.999965 0.999967 0.999968 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.999968 0.999966 0.999962 0.999953 0.999937 0.999904 0.999838 0.999703 0.999421 0.998832 0.997626 0.995211 0.990615 0.982341 0.968257 0.946046 0.913818 0.871034 0.821184 0.772987 0.735387 0.710528 0.692194 0.670222 0.637134 0.593823 0.55303 0.539855 0.580387 0.681468 0.829195 0.995691 1.14601 1.25427 1.31239 1.3251 1.30313 1.25947 1.20672 1.15484 1.10993 1.07444 1.04828 1.03005 1.01796 1.0103 1.00566 1.00296 1.00147 1.00068 1.00029 1.0001 1.00002 0.999983 0.99997 0.999968 0.999967 0.999968 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.999969 0.999968 0.999967 0.999964 0.999957 0.999942 0.999915 0.999856 0.999733 0.999463 0.998889 0.997696 0.995285 0.990677 0.982417 0.96846 0.946686 0.915835 0.876448 0.833397 0.796826 0.775692 0.769647 0.769192 0.762579 0.742868 0.712067 0.682377 0.674705 0.709112 0.793354 0.923165 1.07834 1.22269 1.3257 1.37749 1.38311 1.3535 1.3016 1.24022 1.18002 1.12782 1.08654 1.05612 1.03495 1.02094 1.01207 1.00669 1.00356 1.00181 1.00088 1.0004 1.00016 1.00005 1 0.999982 0.999974 0.99997 0.999969 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999968 0.999966 0.999962 0.99995 0.999929 0.999881 0.999771 0.999525 0.998983 0.997835 0.995498 0.991005 0.982968 0.969508 0.94873 0.920003 0.885044 0.849963 0.82574 0.820807 0.832481 0.848837 0.857386 0.8519 0.834952 0.81763 0.817322 0.84963 0.921661 1.03452 1.17486 1.30806 1.401 1.44267 1.43862 1.40016 1.33992 1.2705 1.20275 1.144 1.09747 1.06319 1.03937 1.02362 1.01367 1.00762 1.0041 1.00212 1.00106 1.0005 1.00022 1.00008 1.00002 0.999992 0.999979 0.999974 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999968 0.999969 0.999966 0.999959 0.999945 0.999907 0.999817 0.999603 0.999108 0.998038 0.995838 0.991578 0.98396 0.97132 0.952026 0.925946 0.895931 0.869221 0.857118 0.867228 0.895057 0.927147 0.95075 0.960171 0.957909 0.953477 0.961184 0.993492 1.05695 1.15532 1.27964 1.39807 1.47723 1.50575 1.48995 1.44155 1.3729 1.29609 1.2218 1.15748 1.10656 1.06905 1.04302 1.02584 1.01498 1.0084 1.00455 1.00239 1.00121 1.00059 1.00027 1.00011 1.00004 1 0.999984 0.999976 0.999972 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999962 0.999937 0.999869 0.99969 0.999258 0.998292 0.996284 0.992365 0.985331 0.97376 0.956323 0.933215 0.908147 0.889411 0.88843 0.911905 0.954099 1.00076 1.03912 1.06372 1.0765 1.08518 1.10122 1.13456 1.19148 1.27723 1.38529 1.48685 1.54995 1.56359 1.53484 1.47596 1.39909 1.31572 1.23608 1.16745 1.1132 1.0733 1.04566 1.02743 1.01593 1.00897 1.00489 1.00259 1.00133 1.00066 1.00032 1.00014 1.00005 1.00001 0.999989 0.999979 0.999974 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999973 0.999976 0.999978 0.999979 0.999968 0.999921 0.999783 0.999422 0.998584 0.996806 0.99331 0.987001 0.97666 0.961316 0.941346 0.920841 0.908957 0.917407 0.952235 1.0069 1.06679 1.1192 1.15864 1.18624 1.20794 1.23246 1.26745 1.31908 1.39342 1.48518 1.56857 1.61436 1.61251 1.57067 1.50155 1.41712 1.32833 1.24476 1.17326 1.11696 1.07565 1.04708 1.02829 1.01645 1.00928 1.00509 1.00272 1.00141 1.00072 1.00035 1.00016 1.00007 1.00002 0.999993 0.999981 0.999975 0.999972 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999972 0.999975 0.99998 0.999986 0.999994 0.999997 0.999974 0.999876 0.999592 0.998893 0.997372 0.994351 0.988862 0.979854 0.966673 0.949875 0.933397 0.926735 0.942237 0.986 1.05113 1.12276 1.18811 1.24142 1.28296 1.31699 1.34977 1.38686 1.4343 1.49829 1.57399 1.63847 1.66626 1.64905 1.59485 1.5165 1.42578 1.33308 1.24726 1.17452 1.11757 1.07593 1.04721 1.02836 1.01651 1.00934 1.00514 1.00276 1.00145 1.00074 1.00037 1.00017 1.00007 1.00002 0.999996 0.999982 0.999976 0.999972 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999973 0.999977 0.999983 0.999995 1.00001 1.00002 1.00002 0.999964 0.999755 0.999201 0.99795 0.995421 0.990803 0.983177 0.972104 0.95835 0.945402 0.942258 0.961862 1.01147 1.08468 1.16634 1.24323 1.30902 1.36305 1.40812 1.44837 1.48775 1.53196 1.58669 1.64691 1.69245 1.70222 1.67037 1.60521 1.51936 1.42421 1.32954 1.24337 1.17115 1.11499 1.07413 1.04604 1.02765 1.0161 1.00912 1.00504 1.00272 1.00144 1.00075 1.00037 1.00018 1.00008 1.00002 0.999997 0.999983 0.999977 0.999973 0.999972 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999972 0.999974 0.999979 0.999986 1 1.00002 1.00004 1.00006 1.00004 0.999905 0.999489 0.998505 0.996466 0.992708 0.986465 0.977383 0.966382 0.956534 0.955568 0.97629 1.02787 1.10586 1.19528 1.28204 1.35868 1.42349 1.47791 1.52441 1.56585 1.60748 1.65388 1.69948 1.72678 1.71937 1.67432 1.60029 1.50928 1.41209 1.3177 1.23328 1.16336 1.10944 1.07041 1.04368 1.02622 1.01528 1.00867 1.0048 1.00261 1.00139 1.00072 1.00037 1.00018 1.00008 1.00003 0.999999 0.999984 0.999977 0.999973 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999972 0.999974 0.99998 0.999989 1 1.00003 1.00006 1.00009 1.00011 1.00003 0.999746 0.999009 0.997431 0.994483 0.989564 0.982339 0.973719 0.966504 0.966921 0.986468 1.03593 1.11424 1.20796 1.30212 1.38766 1.46138 1.52334 1.57472 1.61775 1.65713 1.69598 1.728 1.73843 1.71566 1.65973 1.57956 1.48628 1.38979 1.29819 1.21762 1.15172 1.10133 1.06506 1.04031 1.02419 1.0141 1.00801 1.00445 1.00242 1.0013 1.00068 1.00035 1.00017 1.00008 1.00003 0.999999 0.999984 0.999977 0.999974 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999972 0.999975 0.999981 0.99999 1.00001 1.00003 1.00007 1.00012 1.00015 1.00014 0.999957 0.999441 0.998284 0.996058 0.992335 0.98682 0.980243 0.97513 0.976483 0.993663 1.0378 1.11153 1.20464 1.30232 1.3939 1.47429 1.54193 1.59689 1.64104 1.67845 1.71044 1.73012 1.72573 1.69037 1.62674 1.54375 1.45143 1.35857 1.27222 1.19749 1.13708 1.09127 1.05849 1.0362 1.02171 1.01266 1.0072 1.00401 1.00219 1.00118 1.00062 1.00032 1.00016 1.00007 1.00002 0.999997 0.999984 0.999976 0.999974 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999972 0.999975 0.999979 0.999991 1.00001 1.00004 1.00008 1.00013 1.00018 1.00021 1.00012 0.999793 0.998989 0.99739 0.994697 0.9907 0.98589 0.982406 0.984321 0.998858 1.03606 1.10126 1.18836 1.2844 1.3779 1.46193 1.53308 1.5903 1.63522 1.67087 1.69658 1.70537 1.6889 1.64461 1.57714 1.49502 1.40696 1.3205 1.24159 1.17428 1.12048 1.08 1.05117 1.03164 1.01897 1.01107 1.0063 1.00352 1.00193 1.00104 1.00055 1.00028 1.00014 1.00006 1.00002 0.999995 0.999983 0.999976 0.999973 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999972 0.999975 0.999979 0.99999 1.00001 1.00003 1.00008 1.00013 1.0002 1.00025 1.00024 1.00005 0.999539 0.998459 0.996614 0.993887 0.990596 0.988409 0.990581 1.00261 1.03276 1.08736 1.16411 1.25325 1.34385 1.42766 1.49952 1.55748 1.60266 1.63638 1.6561 1.65569 1.63059 1.58162 1.5145 1.43684 1.35599 1.27823 1.20839 1.14959 1.10304 1.06825 1.04359 1.02692 1.01614 1.00942 1.00537 1.003 1.00165 1.00089 1.00047 1.00024 1.00012 1.00005 1.00001 0.999992 0.999982 0.999976 0.999973 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999972 0.999975 0.999979 0.999988 1 1.00003 1.00007 1.00013 1.0002 1.00028 1.00031 1.00023 0.99994 0.999271 0.99809 0.996354 0.994334 0.993199 0.99546 1.00528 1.02908 1.07285 1.13699 1.21526 1.29844 1.37783 1.44726 1.50413 1.54841 1.57926 1.59311 1.58573 1.55594 1.50672 1.44379 1.3736 1.30219 1.23463 1.17477 1.12492 1.08578 1.05669 1.03615 1.02231 1.01337 1.0078 1.00445 1.00249 1.00137 1.00075 1.0004 1.0002 1.0001 1.00004 1.00001 0.99999 0.99998 0.999975 0.999972 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999972 0.999974 0.999979 0.999986 1 1.00003 1.00007 1.00012 1.0002 1.00027 1.00034 1.00034 1.00021 0.999837 0.999151 0.998168 0.997107 0.996819 0.999111 1.0071 1.02554 1.05948 1.11076 1.17615 1.24853 1.31985 1.38391 1.43752 1.47892 1.50554 1.51405 1.50253 1.47207 1.4264 1.37058 1.30986 1.24909 1.19235 1.14262 1.10157 1.06955 1.04588 1.02922 1.01801 1.01079 1.0063 1.0036 1.00202 1.00111 1.0006 1.00032 1.00016 1.00008 1.00003 1 0.999986 0.999978 0.999974 0.999972 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.99997 0.999974 0.999976 0.999985 0.999997 1.00002 1.00005 1.00011 1.00018 1.00026 1.00034 1.00038 1.00036 1.00019 0.999863 0.999398 0.999016 0.999337 1.00165 1.00816 1.02232 1.04802 1.0876 1.13976 1.19955 1.26042 1.31678 1.36473 1.40106 1.42262 1.42717 1.41452 1.38667 1.3471 1.29997 1.24951 1.1996 1.15345 1.11334 1.08047 1.05496 1.03618 1.02301 1.01417 1.00848 1.00495 1.00283 1.00159 1.00088 1.00047 1.00025 1.00013 1.00006 1.00002 0.999995 0.999983 0.999977 0.999974 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999973 0.999976 0.999983 0.999993 1.00001 1.00004 1.00009 1.00015 1.00023 1.00031 1.00039 1.00042 1.00039 1.00028 1.00016 1.00021 1.0009 1.00315 1.00851 1.01935 1.03855 1.06823 1.10817 1.15527 1.20475 1.25176 1.29206 1.322 1.33878 1.34118 1.32969 1.30631 1.27391 1.2358 1.19536 1.15568 1.11925 1.08779 1.06215 1.04235 1.02782 1.01766 1.01086 1.00649 1.00378 1.00216 1.00121 1.00067 1.00036 1.00019 1.00009 1.00004 1.00001 0.999991 0.999981 0.999975 0.999973 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999973 0.999975 0.999981 0.999989 1.00001 1.00003 1.00007 1.00013 1.0002 1.00028 1.00036 1.00042 1.00046 1.00049 1.00056 1.00084 1.0017 1.0038 1.00821 1.01653 1.03075 1.05252 1.08211 1.11772 1.15605 1.19311 1.22505 1.24857 1.26151 1.26307 1.25383 1.2354 1.21003 1.18032 1.14895 1.11832 1.09035 1.06633 1.04682 1.03182 1.02086 1.01321 1.00811 1.00484 1.00282 1.00161 1.0009 1.00049 1.00026 1.00014 1.00006 1.00002 1 0.999986 0.999978 0.999974 0.999972 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999972 0.999974 0.999979 0.999986 1 1.00002 1.00005 1.0001 1.00016 1.00023 1.00031 1.00038 1.00046 1.00054 1.0007 1.00108 1.00196 1.00382 1.00739 1.01376 1.02424 1.03999 1.06136 1.08736 1.11577 1.14358 1.16773 1.18559 1.19548 1.19678 1.18989 1.17598 1.15681 1.13438 1.11074 1.08773 1.0668 1.04889 1.03442 1.02333 1.01525 1.00963 1.00589 1.00351 1.00204 1.00116 1.00065 1.00035 1.00019 1.00009 1.00004 1.00001 0.999992 0.999982 0.999976 0.999973 0.999972 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.99997 0.999972 0.999973 0.999977 0.999983 0.999992 1.00001 1.00004 1.00007 1.00012 1.00018 1.00025 1.00032 1.0004 1.0005 1.00069 1.00107 1.00186 1.00342 1.00626 1.01108 1.01875 1.03003 1.04518 1.06366 1.08398 1.10408 1.12168 1.13484 1.14225 1.14337 1.13844 1.12829 1.11422 1.09773 1.08036 1.0635 1.04821 1.03518 1.02469 1.01668 1.01086 1.00684 1.00417 1.00247 1.00143 1.00081 1.00045 1.00024 1.00012 1.00006 1.00002 0.999999 0.999987 0.999979 0.999975 0.999972 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999973 0.999975 0.999979 0.999988 1 1.00002 1.00005 1.00009 1.00014 1.00019 1.00025 1.00032 1.00042 1.00059 1.00092 1.00158 1.00281 1.005 1.00859 1.01414 1.02213 1.03273 1.0456 1.05978 1.07389 1.08635 1.09576 1.10114 1.10205 1.09859 1.09136 1.08126 1.06942 1.05696 1.04489 1.03397 1.02471 1.01727 1.01163 1.00754 1.00473 1.00287 1.00169 1.00097 1.00055 1.0003 1.00016 1.00008 1.00003 1.00001 0.999991 0.999981 0.999976 0.999973 0.999972 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999972 0.999973 0.999978 0.999983 0.999995 1.00001 1.00003 1.00006 1.0001 1.00014 1.00018 1.00024 1.00031 1.00045 1.00071 1.00122 1.00216 1.00378 1.00639 1.01034 1.01593 1.02325 1.03208 1.04179 1.05148 1.06008 1.06663 1.07041 1.07108 1.06868 1.06362 1.05652 1.0482 1.03945 1.03099 1.02338 1.01694 1.01179 1.0079 1.0051 1.00318 1.00192 1.00112 1.00064 1.00035 1.00019 1.00009 1.00004 1.00001 0.999994 0.999984 0.999978 0.999974 0.999972 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999973 0.999975 0.999981 0.999987 0.999999 1.00002 1.00004 1.00006 1.00009 1.00013 1.00016 1.00022 1.00031 1.0005 1.00087 1.00154 1.0027 1.00455 1.00731 1.01116 1.01614 1.02212 1.02866 1.0352 1.04101 1.04546 1.04803 1.04849 1.04683 1.04334 1.03844 1.03271 1.0267 1.02091 1.01571 1.01133 1.00785 1.00523 1.00335 1.00207 1.00124 1.00072 1.0004 1.00022 1.00011 1.00005 1.00002 0.999998 0.999986 0.999979 0.999975 0.999973 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999971 0.999972 0.999974 0.999977 0.999983 0.999991 1 1.00002 1.00003 1.00006 1.00008 1.0001 1.00013 1.00019 1.00032 1.00057 1.00103 1.00182 1.00309 1.00497 1.00757 1.01092 1.0149 1.01925 1.02359 1.02745 1.0304 1.03211 1.0324 1.03127 1.02889 1.02558 1.02171 1.01766 1.01378 1.0103 1.00739 1.00509 1.00337 1.00214 1.00131 1.00077 1.00044 1.00024 1.00012 1.00006 1.00002 0.999999 0.999987 0.99998 0.999976 0.999973 0.999972 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.99997 0.999972 0.999976 0.999979 0.999984 0.999992 1 1.00001 1.00003 1.00004 1.00005 1.00007 1.00011 1.00018 1.00033 1.00063 1.00116 1.002 1.00325 1.00497 1.00717 1.00979 1.01263 1.01547 1.01799 1.01992 1.02103 1.0212 1.02043 1.01885 1.01665 1.01409 1.01142 1.00887 1.0066 1.00471 1.00322 1.00211 1.00133 1.0008 1.00046 1.00025 1.00013 1.00006 1.00002 1 0.999988 0.999981 0.999976 0.999974 0.999972 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999971 0.999971 0.999972 0.999976 0.999979 0.999987 0.999992 1 1.00001 1.00001 1.00002 1.00002 1.00004 1.00008 1.00017 1.00035 1.00068 1.00121 1.00202 1.00313 1.00456 1.00625 1.00809 1.00991 1.01153 1.01277 1.01348 1.01358 1.01307 1.01204 1.0106 1.00894 1.00722 1.00558 1.00412 1.00292 1.00198 1.00128 1.00079 1.00047 1.00026 1.00014 1.00006 1.00002 1 0.999987 0.99998 0.999976 0.999974 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999972 0.999974 0.999976 0.999979 0.999985 0.999989 0.999993 0.999996 0.999995 0.999996 0.999997 1.00001 1.00006 1.00016 1.00036 1.00069 1.00119 1.0019 1.0028 1.00387 1.00503 1.00619 1.00722 1.00801 1.00846 1.00851 1.00818 1.00752 1.00661 1.00555 1.00446 1.00343 1.00252 1.00177 1.00118 1.00075 1.00046 1.00026 1.00014 1.00006 1.00002 0.999999 0.999986 0.999979 0.999975 0.999974 0.999972 0.999971 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999971 0.999972 0.999974 0.999977 0.999978 0.999982 0.999984 0.999983 0.999982 0.999975 0.99997 0.999973 0.999989 1.00004 1.00016 1.00035 1.00066 1.00109 1.00165 1.00231 1.00304 1.00377 1.00441 1.0049 1.00518 1.00522 1.00502 1.0046 1.00403 1.00337 1.00269 1.00206 1.0015 1.00104 1.00068 1.00043 1.00025 1.00013 1.00006 1.00002 0.999997 0.999984 0.999977 0.999975 0.999973 0.999971 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999973 0.999975 0.999975 0.999977 0.999976 0.999976 0.999972 0.999968 0.999959 0.999951 0.999958 0.999978 1.00004 1.00015 1.00033 1.00058 1.00093 1.00133 1.00178 1.00223 1.00263 1.00293 1.00311 1.00313 1.00301 1.00275 1.00241 1.002 1.00159 1.00121 1.00087 1.00059 1.00038 1.00023 1.00012 1.00006 1.00002 0.999995 0.999982 0.999977 0.999974 0.999971 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999971 0.999972 0.999972 0.999973 0.999973 0.999974 0.999971 0.999969 0.999961 0.999954 0.999945 0.99994 0.999949 0.999975 1.00003 1.00013 1.00028 1.00049 1.00073 1.001 1.00128 1.00152 1.00171 1.00182 1.00184 1.00176 1.00161 1.0014 1.00116 1.00092 1.00069 1.00049 1.00032 1.0002 1.00011 1.00005 1.00002 0.999993 0.99998 0.999975 0.999972 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999971 0.999971 0.999972 0.99997 0.999969 0.999966 0.999962 0.999954 0.999945 0.999939 0.999937 0.999947 0.999977 1.00003 1.00012 1.00023 1.00038 1.00054 1.0007 1.00085 1.00097 1.00104 1.00105 1.00101 1.00092 1.0008 1.00066 1.00052 1.00038 1.00026 1.00017 1.0001 1.00005 1.00001 0.999992 0.999981 0.999974 0.999971 0.999971 0.99997 0.99997 0.99997 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999966 0.999962 0.999956 0.999948 0.999941 0.999937 0.999938 0.999952 0.99998 1.00003 1.00009 1.00018 1.00027 1.00037 1.00046 1.00053 1.00058 1.00059 1.00056 1.00051 1.00044 1.00036 1.00028 1.0002 1.00013 1.00008 1.00004 1.00001 0.999992 0.999981 0.999975 0.999971 0.99997 0.999969 0.99997 0.999969 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999967 0.999963 0.999958 0.999953 0.999946 0.999941 0.999941 0.999945 0.999958 0.999983 1.00002 1.00007 1.00012 1.00018 1.00024 1.00028 1.00031 1.00032 1.0003 1.00028 1.00024 1.00019 1.00014 1.0001 1.00006 1.00003 1.00001 0.999991 0.99998 0.999974 0.999972 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.999969 0.999967 0.999965 0.999962 0.999956 0.999952 0.999948 0.999945 0.999946 0.999952 0.999966 0.999986 1.00001 1.00004 1.00008 1.00011 1.00014 1.00015 1.00016 1.00016 1.00014 1.00012 1.00009 1.00007 1.00004 1.00002 1 0.999988 0.99998 0.999975 0.999971 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.999969 0.999968 0.999966 0.999963 0.999961 0.999957 0.999954 0.999951 0.999952 0.999953 0.99996 0.99997 0.999986 1 1.00002 1.00004 1.00006 1.00007 1.00007 1.00007 1.00006 1.00005 1.00004 1.00002 1.00001 0.999997 0.999987 0.99998 0.999975 0.999972 0.99997 0.999969 0.999969 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999968 0.999967 0.999966 0.999964 0.999961 0.999959 0.999957 0.999956 0.999956 0.99996 0.999966 0.999975 0.999984 0.999996 1.00001 1.00002 1.00002 1.00003 1.00003 1.00002 1.00002 1.00001 0.999999 0.999991 0.999985 0.999979 0.999975 0.999972 0.999971 0.99997 0.999969 0.999969 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999968 0.999969 0.999967 0.999967 0.999966 0.999964 0.999962 0.999961 0.99996 0.99996 0.999962 0.999964 0.999969 0.999975 0.99998 0.999988 0.999994 0.999998 1 1 0.999998 0.999995 0.99999 0.999987 0.999982 0.999978 0.999975 0.999973 0.999971 0.99997 0.999969 0.99997 0.999969 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999968 0.999966 0.999966 0.999965 0.999964 0.999963 0.999962 0.999963 0.999965 0.999967 0.99997 0.999975 0.999979 0.999982 0.999985 0.999985 0.999986 0.999985 0.999983 0.999982 0.999978 0.999975 0.999974 0.999972 0.999971 0.99997 0.99997 0.99997 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999968 0.999968 0.999966 0.999967 0.999966 0.999966 0.999966 0.999965 0.999966 0.999968 0.99997 0.999972 0.999974 0.999975 0.999977 0.999978 0.999978 0.999978 0.999978 0.999976 0.999975 0.999973 0.999972 0.999971 0.99997 0.99997 0.99997 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999968 0.999969 0.999968 0.999967 0.999967 0.999966 0.999967 0.999968 0.999968 0.999969 0.99997 0.999972 0.999973 0.999974 0.999975 0.999974 0.999974 0.999974 0.999973 0.999972 0.999972 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999968 0.999969 0.999969 0.999969 0.999968 0.999968 0.999968 0.999969 0.999969 0.99997 0.999971 0.999971 0.999972 0.999972 0.999971 0.999972 0.999971 0.999972 0.999971 0.999971 0.999971 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999969 0.999968 0.999969 0.999969 0.999969 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.999971 0.999971 0.999971 0.999971 0.99997 0.99997 0.99997 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.999969 0.999969 0.999969 0.999969 0.999969 0.999969 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.999969 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 0.99997 ) ; boundaryField { emptyPatches_empt { type empty; } top_cyc { type cyclic; } bottom_cyc { type cyclic; } inlet_cyc { type cyclic; } outlet_cyc { type cyclic; } } // ************************************************************************* //
[ "tdg@debian" ]
tdg@debian
a05d95e5bcd992eacfd1adb34093583b9f57b9a3
e4376d199c6c7cc428be0abe90b143d1ae90c132
/feeder.cpp
a003c8da85623ef5d2800f1ce447fd0501622df9
[]
no_license
wangyx0055/remote-sniff
076d370c0e6410d41a0e9cbb5db045f1b4cf43ee
c288bb20a638f4842966a1c1bc6b4bcf9f98fdb8
refs/heads/master
2023-08-31T02:20:42.401608
2015-11-20T11:12:38
2015-11-20T11:12:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,643
cpp
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <linux/limits.h> #include <linux/if.h> #include <linux/if_tun.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/signal.h> #include <sys/time.h> #include <fcntl.h> #include <errno.h> #include <cstring> #include <unistd.h> #include <iostream> #include <stdexcept> #include <string> #include <cstdint> #include <memory> struct Feeder { int fd; virtual ssize_t feed(const char *buf, const int len) { std::cout << "."; std::cout.flush(); return write(fd, buf, len); } virtual const char *name() const = 0; virtual ~Feeder() {} }; struct Tap : public Feeder { ifreq ifr; Tap() { const char *clonedev = "/dev/net/tun"; fd = open(clonedev, O_RDWR); if (fd < 0) throw std::runtime_error(std::string("Could not open ") + clonedev + ": " + strerror(errno)); memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; ifr.ifr_name[0] = 0; int err = ioctl(fd, TUNSETIFF, (void *)&ifr); if (err < 0) throw std::runtime_error(std::string("Could not create TAP device: ") + strerror(errno)); int sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) throw std::runtime_error(std::string("Could not create AF_INET socket: ") + strerror(errno)); ifr.ifr_flags |= IFF_UP | IFF_RUNNING; err = ioctl(sock, SIOCSIFFLAGS, &ifr); if (err < 0) throw std::runtime_error(std::string("Could not set UP flags for TAP device: ") + strerror(errno)); close(sock); } const char *name() const override { return ifr.ifr_name; } virtual ~Tap() { if (fd >= 0) close(fd); } }; struct Fifo : public Feeder { char dirname[PATH_MAX]; char *tmpdir; char namebuf[PATH_MAX]; Fifo() { strcpy(dirname, "/tmp/feedXXXXXX"); tmpdir = mkdtemp(dirname); if (!tmpdir) throw std::runtime_error(std::string("Could not create temp directory: ") + strerror(errno)); strcpy(namebuf, tmpdir); strcat(namebuf, "/fifo"); int err; err = mkfifo(namebuf, 0600); if (err < 0) throw std::runtime_error(std::string("Could not create fifo: ") + strerror(errno)); std::cout << "Waiting for someone to attach to " << namebuf << std::endl; fd = open(namebuf, O_WRONLY); if (fd < 0) throw std::runtime_error(std::string("Could not open fifo: ") + strerror(errno)); writeHeader(); } void writeHeader() { struct pcap_hdr_s { uint32_t magic_number; /* magic number */ uint16_t version_major; /* major version number */ uint16_t version_minor; /* minor version number */ int32_t thiszone; /* GMT to local correction */ uint32_t sigfigs; /* accuracy of timestamps */ uint32_t snaplen; /* max length of captured packets, in octets */ uint32_t network; /* data link type */ } hdr; hdr.magic_number = 0xa1b2c3d4; hdr.version_major = 2; hdr.version_minor = 4; hdr.thiszone = 0; hdr.sigfigs = 0; hdr.snaplen = 65536; hdr.network = 1; write(fd, &hdr, sizeof(hdr)); } const char *name() const override { return namebuf; } virtual ssize_t feed(const char *buf, const int len) { struct pcaprec_hdr_s { uint32_t ts_sec; /* timestamp seconds */ uint32_t ts_usec; /* timestamp microseconds */ uint32_t incl_len; /* number of octets of packet saved in file */ uint32_t orig_len; /* actual length of packet */ } hdr; timeval tv; gettimeofday(&tv, nullptr); hdr.ts_sec = tv.tv_sec; hdr.ts_usec = tv.tv_usec; hdr.incl_len = hdr.orig_len = len; write(fd, &hdr, sizeof(hdr)); return Feeder::feed(buf, len); } ~Fifo() { if (fd >= 0) close(fd); if (tmpdir) { unlink(name()); rmdir(tmpdir); } } }; bool alive = true; void interrupt(int signo) { std::cerr << "Interrupted" << std::endl; alive = false; } struct Server { int sock; char buf[BUFSIZ]; Server(const char *listenip, int port) { sockaddr_in saddr; memset(&saddr, 0, sizeof(saddr)); saddr.sin_family = AF_INET; saddr.sin_addr.s_addr = inet_addr(listenip); saddr.sin_port = htons(port); sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sock < 0) throw std::runtime_error(std::string("Could not create UDP socket: ") + strerror(errno)); int err = bind(sock, (sockaddr *)&saddr, sizeof(saddr)); if (err < 0) throw std::runtime_error(std::string("Could not bind: ") + strerror(errno)); } void process(Feeder *f) { while (alive) { sockaddr_in caddr; socklen_t fromlen = sizeof(caddr); int recvsize = recvfrom(sock, buf, BUFSIZ, 0, (sockaddr *)&caddr, &fromlen); if (recvsize < 0) throw std::runtime_error(std::string("Recvfrom failed: ") + strerror(errno)); ssize_t err = f->feed(buf, recvsize); if (err < 0) alive = false; } } ~Server() { if (sock >= 0) close(sock); } }; int usage(const char *argv0) { std::cerr << "USAGE: " << argv0 << " -t/-f <bind ip> <bind port>" << std::endl << "\t use -t to create a TAP device (requires root) and -f to create a fifo" << std::endl; return 1; } int main(int argc, char **argv) { if (argc < 4) return usage(argv[0]); try { struct sigaction sa; sa.sa_handler = interrupt; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(SIGINT, &sa, nullptr); signal(SIGPIPE, SIG_IGN); std::unique_ptr<Feeder> f; if (strcmp(argv[1], "-t") == 0) f = std::unique_ptr<Feeder>(new Tap()); else f = std::unique_ptr<Feeder>(new Fifo()); std::cout << "Created " << f->name() << std::endl; Server s(argv[2], atoi(argv[3])); s.process(f.get()); std::cout << std::endl; } catch (const std::runtime_error &e) { std::cerr << e.what() << std::endl; return 1; } return 0; }
[ "tsybulin@crec.mipt.ru" ]
tsybulin@crec.mipt.ru
50187d59e4418dc414236804d0fed1942a2ddf84
59d26f54e985df3a0df505827b25da0c5ff586e8
/Contest/0. Codeforces div2/502/B. The Bits.cpp
779acfbee5522335c92b28de7fff0b45713f61ea
[]
no_license
minhaz1217/My-C-Journey
820f7b284e221eff2595611b2e86dc9e32f90278
3c8d998ede172e9855dc6bd02cb468d744a9cad6
refs/heads/master
2022-12-06T06:12:30.823678
2022-11-27T12:09:03
2022-11-27T12:09:03
160,788,252
2
1
null
null
null
null
UTF-8
C++
false
false
1,021
cpp
#include<bits/stdc++.h> //#include<iostream> using namespace std; #define check(a) cout << a << endl; #define cc(a) cout << a << endl; #define msg(a,b) cout << a << " : " << b << endl; #define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl; int main(){ int n; string str1,str2; cin >> n; cin >> str1 >> str2; long long int counter00 = 0 , counter01 =0 , counter11=0, counter10=0, counter1 =0 , counter0 = 0; for(int i=0;str1[i];i++){ if(str1[i] == '0' && str2[i] == '0'){ counter00++; }else if(str1[i] == '1' && str2[i] == '0'){ counter10++; }else if(str1[i] == '1' && str2[i] == '1'){ counter11++; }else{ counter01++; } if(str1[i] == '1'){ counter1++; } if(str1[i] == '0'){ counter0++; } } //msg2(counter01, counter10, counter1) cout << counter00*counter11 + counter01*counter10 + counter00 * counter10<< endl; return 0; }
[ "minhaz1217@gmail.com" ]
minhaz1217@gmail.com
e48ccbd469b33a48e74a94fd8a5067c132c7d1b3
6ea50d800eaf5690de87eea3f99839f07c662c8b
/ver.0.14.0/MoveEntityPacket.h
2b3b1c629d4a2a0973a2c1cd08b3f8d05e352b03
[]
no_license
Toku555/MCPE-Headers
73eefeab8754a9ce9db2545fb0ea437328cade9e
b0806aebd8c3f4638a1972199623d1bf686e6497
refs/heads/master
2021-01-15T20:53:23.115576
2016-09-01T15:38:27
2016-09-01T15:38:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
194
h
#pragma once class MoveEntityPacket{ public: void getId(void); void handle(RakNet::RakNetGUID const&,NetEventCallback *); void ~MoveEntityPacket(); void ~MoveEntityPacket(); };
[ "sinigami3427@gmail.com" ]
sinigami3427@gmail.com
e00e416ae44d24fcebd72ccbf9883ea3e38f146a
e8138f0a9fb7aa407dcebf955e585349fdd44471
/src/filters/ofxCIColorPosterize.h
51ed87aa9723d95a1440f3776ac7ab5fafb0ef80
[]
no_license
abdullah38rcc/ofxCoreImage
c81cce11e8599ef62a587b6b5abe53dea9f313d0
f3218a8374a874b3e300186a4475332564e9eb18
refs/heads/master
2021-01-18T17:23:27.426956
2014-04-17T21:43:51
2014-04-17T21:43:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,699
h
// // ofxEasyCI.h // coreImage_sketch // // Created by Blair Neal on 4/15/14. // // #pragma once #include "ofMain.h" #include "ofxCoreImage.h" class ofxCIColorPosterize{ //This CI Filter lets you adjust brightness, saturation and contrast public: void setup(int width, int height, CIContext* _glCIcontext){ genericRGB = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); glCIcontext = _glCIcontext; texSize = CGSizeMake(width, height); inRect = CGRectMake(0,0,width,height); outRect = CGRectMake(0,0,width,height); filter = [CIFilter filterWithName:@"CIColorPosterize"]; [filter setDefaults]; //always do this on load } //------------------------- void update(ofTexture tex){ //this takes an ofTexture and texID = tex.texData.textureID; inputCIImage = [CIImage imageWithTexture:texID size:texSize flipped:NO colorSpace:genericRGB]; [filter setValue:inputCIImage forKey:@"inputImage"]; } //------------------------- void update(CIImage* inputImage){//don't use both updates with one class...use this for chaining - you need to start with an OF texture first though [filter setValue:inputImage forKey:@"inputImage"]; } //------------------------- void setLevels(float levels){ levels = ofClamp(levels,2, 30); [filter setValue:[NSNumber numberWithFloat: levels] forKey:@"inputLevels"]; } //------------------------- void setDefaults(){ [filter setDefaults]; } //------------------------- CIImage* getCIImage(){ //use this to pass into other effects for chaining filterCIImage = [filter valueForKey:@"outputImage"]; return filterCIImage; } //------------------------- void draw(int x, int y){ filterCIImage = [filter valueForKey:@"outputImage"]; ofPushMatrix(); ofTranslate(x,y); [glCIcontext drawImage:filterCIImage inRect:outRect fromRect:inRect]; ofPopMatrix(); } private: CGLContextObj CGLContext; NSOpenGLPixelFormatAttribute* attr; NSOpenGLPixelFormat* pf; CGColorSpaceRef genericRGB; CIImage* filterCIImage; CGSize texSize; GLint texID; CGRect outRect; CGRect inRect; CIContext* glCIcontext; CIImage* inputCIImage; CIFilter* filter; };
[ "laserpilot@gmail.com" ]
laserpilot@gmail.com
d76c25a40f4ed5cb4ccdd26102065ee00f4eea5d
4765dd8790ffcd830eda65e371b326190664c765
/backend/config/Config.cc
d828944eec42f0e77377b4a8532deb5afb6fc94f
[ "MIT" ]
permissive
EricJeffrey/TheCheatSheet
31eac0124e0f319846bab322faadc1bab2f29591
d3a9c91be10ad9179fdcbb25832d3235ea644115
refs/heads/main
2023-04-08T18:08:34.667182
2021-04-18T05:47:39
2021-04-18T05:47:39
305,010,267
3
1
MIT
2021-04-12T13:40:03
2020-10-18T02:52:56
C++
UTF-8
C++
false
false
4,305
cc
#if !defined(CONFIG_CC) #define CONFIG_CC #include "Config.hpp" #include "../eshelper/EsContext.hpp" #include "../mongohelper/MongoContext.hpp" #include "../util/logger.hpp" #include <string> #include <vector> #include <cxxopts.hpp> using std::vector; string Config::host = "0.0.0.0"; int32_t Config::port = 8000; bool Config::daemon = false; int32_t Config::loglevel = 1; string Config::logFilePath = "cheatsheet_backend.log"; bool Config::logToFile = false; int32_t Config::maxLogFileSize = (1 << 20) * 10; int32_t Config::maxLogFileNumber = 10; string Config::mongoHost = "127.0.0.1"; int32_t Config::mongoPort = 27017; string Config::esHost = "127.0.0.1"; int32_t Config::esPort = 9200; bool Config::initConfigByArgs(int argc, char *argv[]) { using CxxOptions = cxxopts::Options; // helper to make it more pretty struct Adder { cxxopts::OptionAdder &&mAdder; Adder(cxxopts::OptionAdder &&adder) : mAdder(std::move(adder)) {} Adder &add(const string &option, const string &desc, std::shared_ptr<cxxopts::Value> v = cxxopts::value<bool>()) { mAdder(option, desc, v); return *this; } }; CxxOptions options{"cheatsheet_backend", "web server for TheCheatsheet project"}; Adder(options.add_options()) .add("d,daemon", "run as daemon, when set logs will be written into files as -o or --logout specified") .add("host", "host to listen, default 0.0.0.0", cxxopts::value<string>()) .add("l,loglevel", "set the log level, 2-debug,3-info,4-warn,5-err,6-critical,7-off, default info", cxxopts::value<int32_t>()) .add("p,port", "port to listen on, default 8000", cxxopts::value<int32_t>()) .add("mongohost", "host of mongodb, default 127.0.0.1", cxxopts::value<string>()) .add("mongoport", "port of mongodb, default 27017", cxxopts::value<int32_t>()) .add("eshost", "host of elasticsearch, default 127.0.0.1", cxxopts::value<string>()) .add("esport", "port of elasticsearch, default 9200", cxxopts::value<int32_t>()) .add("o,logout", "path to log file, default cheatsheet_backend.log at current dir", cxxopts::value<string>()) .add("h,help", "print usage"); auto printUsage = [&options]() { fprintf(stdout, "%s\n", options.help().c_str()); }; auto result = options.parse(argc, argv); if (result.count("help") > 0) { printUsage(); return false; } if (result.count("daemon") > 0) { Config::logToFile = true; Config::daemon = result["daemon"].as<bool>(); } if (result.count("logout") > 0) { Config::logToFile = true; Config::logFilePath = result["logout"].as<string>(); } if (result.count("host") > 0) Config::host = result["host"].as<string>(); if (result.count("loglevel") > 0) { switch (result["loglevel"].as<int32_t>()) { case 2: Logger()->set_level(spdlog::level::debug); break; case 3: Logger()->set_level(spdlog::level::info); break; case 4: Logger()->set_level(spdlog::level::warn); break; case 5: Logger()->set_level(spdlog::level::err); break; case 6: Logger()->set_level(spdlog::level::critical); break; case 7: Logger()->set_level(spdlog::level::off); break; default: printUsage(); return false; } } else { Logger()->set_level(spdlog::level::info); } if (result.count("port") > 0) Config::port = result["port"].as<int32_t>(); if (result.count("mongohost") > 0) Config::mongoHost = result["mongohost"].as<string>(); if (result.count("mongoport") > 0) Config::mongoPort = result["mongoport"].as<int32_t>(); if (result.count("eshost") > 0) Config::esHost = result["eshost"].as<string>(); if (result.count("esport") > 0) Config::esPort = result["esport"].as<int32_t>(); mongohelper::MongoContext::config(Config::mongoHost, Config::mongoPort); eshelper::EsContext::config(Config::esHost, Config::esPort); return true; } #endif // CONFIG_CC
[ "1719937412@qq.com" ]
1719937412@qq.com
4631cbae1fd5496c51de37a3a43e0ff6a4ba9ff6
617bd24f8c106b9c707a0afcef2abc2b64e08e43
/ios/versioned-react-native/ABI31_0_0/ReactCommon/ABI31_0_0fabric/components/root/ABI31_0_0RootProps.h
2380c6916751eeceb3e78fd31fd48c2e1c8b3a2d
[ "MIT", "BSD-3-Clause", "Apache-2.0" ]
permissive
atiato78/expo
54f15c932a3984f2a60b7fddc9bd55c470ba92e4
0c9ef858e125b5f9d421edc183ec10aa84c9b41b
refs/heads/master
2022-12-15T09:30:33.721793
2019-07-31T20:04:43
2019-07-31T20:04:43
199,931,004
2
0
MIT
2022-12-04T05:33:11
2019-07-31T21:24:06
Objective-C
UTF-8
C++
false
false
912
h
/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <memory> #include <ABI31_0_0fabric/ABI31_0_0components/view/ViewProps.h> #include <ABI31_0_0fabric/ABI31_0_0core/LayoutConstraints.h> #include <ABI31_0_0fabric/ABI31_0_0core/LayoutContext.h> namespace facebook { namespace ReactABI31_0_0 { class RootProps; using SharedRootProps = std::shared_ptr<const RootProps>; class RootProps final: public ViewProps { public: RootProps() = default; RootProps( const RootProps &sourceProps, const LayoutConstraints &layoutConstraints, const LayoutContext &layoutContext ); #pragma mark - Props const LayoutConstraints layoutConstraints {}; const LayoutContext layoutContext {}; }; } // namespace ReactABI31_0_0 } // namespace facebook
[ "tsapeta@users.noreply.github.com" ]
tsapeta@users.noreply.github.com
3975dab56ff11e77ffb85a02c8bf3c67a0d7d8aa
53865c028b5bd4f3cf677bf546c3081722990f32
/2014/2014Robot/Commands/TiltIntakeDownV2Command.h
aa9f3f1d3a1f502c8c1b0ba0b0f9f77753d582e8
[ "Apache-2.0" ]
permissive
KennedyRoboEagles/PublicRobotCode
4a040765d97d1397411d680d16ddbaad1ca161c9
9a6eaaca3931453281a76da8c9da89379ca9358a
refs/heads/master
2021-01-10T16:50:17.441810
2020-01-03T22:12:18
2020-01-03T22:12:18
48,923,377
0
0
null
2019-01-05T06:42:12
2016-01-02T20:47:43
C++
UTF-8
C++
false
false
388
h
#ifndef TILTINTAKEDOWNV2COMMAND_H #define TILTINTAKEDOWNV2COMMAND_H #include "../CommandBase.h" /** * * * @author nowireless */ class TiltIntakeDownV2Command: public CommandBase { private: Timer *timer; public: TiltIntakeDownV2Command(); virtual void Initialize(); virtual void Execute(); virtual bool IsFinished(); virtual void End(); virtual void Interrupted(); }; #endif
[ "nowirelss@gmail.com" ]
nowirelss@gmail.com
82054668a74b90574c3b3a06e4bd1b973bdd5410
83e81c25b1f74f88ed0f723afc5d3f83e7d05da8
/tests/Camera2Tests/SmartCamera/SimpleCamera/jni/frametovalues.cpp
ed09d5fe26747438b918b2f06a9060bcfa2e6885
[ "Apache-2.0", "LicenseRef-scancode-unicode" ]
permissive
Ankits-lab/frameworks_base
8a63f39a79965c87a84e80550926327dcafb40b7
150a9240e5a11cd5ebc9bb0832ce30e9c23f376a
refs/heads/main
2023-02-06T03:57:44.893590
2020-11-14T09:13:40
2020-11-14T09:13:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,735
cpp
/* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Native function to extract histogram from image (handed down as ByteBuffer). #include "frametovalues.h" #include <string.h> #include <jni.h> #include <unistd.h> #include <android/log.h> #include "imgprocutil.h" jboolean Java_androidx_media_filterpacks_image_ToGrayValuesFilter_toGrayValues( JNIEnv* env, jclass clazz, jobject imageBuffer, jobject grayBuffer ) { unsigned char* pixelPtr = static_cast<unsigned char*>(env->GetDirectBufferAddress(imageBuffer)); unsigned char* grayPtr = static_cast<unsigned char*>(env->GetDirectBufferAddress(grayBuffer)); if (pixelPtr == 0 || grayPtr == 0) { return JNI_FALSE; } int numPixels = env->GetDirectBufferCapacity(imageBuffer) / 4; // TODO: the current implementation is focused on the correctness not performance. // If performance becomes an issue, it is better to increment pixelPtr directly. int disp = 0; for(int idx = 0; idx < numPixels; idx++, disp+=4) { int R = *(pixelPtr + disp); int G = *(pixelPtr + disp + 1); int B = *(pixelPtr + disp + 2); int gray = getIntensityFast(R, G, B); *(grayPtr+idx) = static_cast<unsigned char>(gray); } return JNI_TRUE; } jboolean Java_androidx_media_filterpacks_image_ToRgbValuesFilter_toRgbValues( JNIEnv* env, jclass clazz, jobject imageBuffer, jobject rgbBuffer ) { unsigned char* pixelPtr = static_cast<unsigned char*>(env->GetDirectBufferAddress(imageBuffer)); unsigned char* rgbPtr = static_cast<unsigned char*>(env->GetDirectBufferAddress(rgbBuffer)); if (pixelPtr == 0 || rgbPtr == 0) { return JNI_FALSE; } int numPixels = env->GetDirectBufferCapacity(imageBuffer) / 4; // TODO: this code could be revised to improve the performance as the TODO above. int pixelDisp = 0; int rgbDisp = 0; for(int idx = 0; idx < numPixels; idx++, pixelDisp += 4, rgbDisp += 3) { for (int c = 0; c < 3; ++c) { *(rgbPtr + rgbDisp + c) = *(pixelPtr + pixelDisp + c); } } return JNI_TRUE; }
[ "keneankit01@gmail.com" ]
keneankit01@gmail.com
06c3c5bb93dd0f1b98f46790911abeb967c6a030
b13c836acf370ea3e1542978baa71a9589f15b5b
/src/cube3d.h
62a9b50980cba09cfdc7892c0efc0afa07335656
[]
no_license
amine2734/cube
1c7efee2739e96c2fa2e924a5cd4f5bda629d81a
27643a268c5a78a752dcf0653e9ee398a9292d0f
refs/heads/master
2021-01-16T21:41:25.318660
2014-01-08T12:22:23
2014-01-08T12:22:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
682
h
#ifndef _CUBE3D_H #define _CUBE3D_H #include "cubelet.h" #include "facemap.h" #define GetCubelet(x, y, z) Map[(z)*9 + (y)*3 + (x)] class Cube3D { public: enum Axis {X, Y, Z}; Cube3D(); ~Cube3D(); void Render(); void Picking(bool state); void Pick(int n, int f, int* xyz); void SetColors(); void AnimateMove(char m, int rot); void AnimateStick(char m, int rot); void AnimateStop(char m, int rot); GLfloat angles[3]; FaceletMap FaceMap; protected: bool IsAnimated(Cubelet* c); private: Cubelet* Map[27]; int TransCount; float TransRot; Axis TransAxis; Cubelet* Transform[18]; }; #endif // _CUBE3D_H
[ "yndi@undev.ru" ]
yndi@undev.ru
1d9fda7ac0ee25a14786e6fc02d661d277c43e74
bdf42290c1e3208c2b675bab0562054adbda63bd
/base/threading/thread_local_unittest.cc
9d0a7c9edb6c3c906f8b00e9d6eb4d54a7c7ac34
[ "BSD-3-Clause" ]
permissive
mockingbirdnest/chromium
245a60c0c99b8c2eb2b43c104d82981070ba459d
e5eff7e6629d0e80dcef392166651e863af2d2fb
refs/heads/master
2023-05-25T01:25:21.964034
2023-05-14T16:49:08
2023-05-14T16:49:08
372,263,533
0
0
BSD-3-Clause
2023-05-14T16:49:09
2021-05-30T16:28:29
C++
UTF-8
C++
false
false
3,970
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/logging.h" #include "base/threading/simple_thread.h" #include "base/threading/thread_local.h" #include "base/synchronization/waitable_event.h" #include "testing/gtest/include/gtest/gtest.h" namespace base { namespace { class ThreadLocalTesterBase : public base::DelegateSimpleThreadPool::Delegate { public: typedef base::ThreadLocalPointer<ThreadLocalTesterBase> TLPType; ThreadLocalTesterBase(TLPType* tlp, base::WaitableEvent* done) : tlp_(tlp), done_(done) { } virtual ~ThreadLocalTesterBase() {} protected: TLPType* tlp_; base::WaitableEvent* done_; }; class SetThreadLocal : public ThreadLocalTesterBase { public: SetThreadLocal(TLPType* tlp, base::WaitableEvent* done) : ThreadLocalTesterBase(tlp, done), val_(NULL) { } virtual ~SetThreadLocal() {} void set_value(ThreadLocalTesterBase* val) { val_ = val; } virtual void Run() override { DCHECK(!done_->IsSignaled()); tlp_->Set(val_); done_->Signal(); } private: ThreadLocalTesterBase* val_; }; class GetThreadLocal : public ThreadLocalTesterBase { public: GetThreadLocal(TLPType* tlp, base::WaitableEvent* done) : ThreadLocalTesterBase(tlp, done), ptr_(NULL) { } virtual ~GetThreadLocal() {} void set_ptr(ThreadLocalTesterBase** ptr) { ptr_ = ptr; } virtual void Run() override { DCHECK(!done_->IsSignaled()); *ptr_ = tlp_->Get(); done_->Signal(); } private: ThreadLocalTesterBase** ptr_; }; } // namespace // In this test, we start 2 threads which will access a ThreadLocalPointer. We // make sure the default is NULL, and the pointers are unique to the threads. TEST(ThreadLocalTest, Pointer) { base::DelegateSimpleThreadPool tp1("ThreadLocalTest tp1", 1); base::DelegateSimpleThreadPool tp2("ThreadLocalTest tp1", 1); tp1.Start(); tp2.Start(); base::ThreadLocalPointer<ThreadLocalTesterBase> tlp; static ThreadLocalTesterBase* const kBogusPointer = reinterpret_cast<ThreadLocalTesterBase*>(0x1234); ThreadLocalTesterBase* tls_val; base::WaitableEvent done(true, false); GetThreadLocal getter(&tlp, &done); getter.set_ptr(&tls_val); // Check that both threads defaulted to NULL. tls_val = kBogusPointer; done.Reset(); tp1.AddWork(&getter); done.Wait(); EXPECT_EQ(static_cast<ThreadLocalTesterBase*>(NULL), tls_val); tls_val = kBogusPointer; done.Reset(); tp2.AddWork(&getter); done.Wait(); EXPECT_EQ(static_cast<ThreadLocalTesterBase*>(NULL), tls_val); SetThreadLocal setter(&tlp, &done); setter.set_value(kBogusPointer); // Have thread 1 set their pointer value to kBogusPointer. done.Reset(); tp1.AddWork(&setter); done.Wait(); tls_val = NULL; done.Reset(); tp1.AddWork(&getter); done.Wait(); EXPECT_EQ(kBogusPointer, tls_val); // Make sure thread 2 is still NULL tls_val = kBogusPointer; done.Reset(); tp2.AddWork(&getter); done.Wait(); EXPECT_EQ(static_cast<ThreadLocalTesterBase*>(NULL), tls_val); // Set thread 2 to kBogusPointer + 1. setter.set_value(kBogusPointer + 1); done.Reset(); tp2.AddWork(&setter); done.Wait(); tls_val = NULL; done.Reset(); tp2.AddWork(&getter); done.Wait(); EXPECT_EQ(kBogusPointer + 1, tls_val); // Make sure thread 1 is still kBogusPointer. tls_val = NULL; done.Reset(); tp1.AddWork(&getter); done.Wait(); EXPECT_EQ(kBogusPointer, tls_val); tp1.JoinAll(); tp2.JoinAll(); } TEST(ThreadLocalTest, Boolean) { { base::ThreadLocalBoolean tlb; EXPECT_FALSE(tlb.Get()); tlb.Set(false); EXPECT_FALSE(tlb.Get()); tlb.Set(true); EXPECT_TRUE(tlb.Get()); } // Our slot should have been freed, we're all reset. { base::ThreadLocalBoolean tlb; EXPECT_FALSE(tlb.Get()); } } } // namespace base
[ "egg.robin.leroy@gmail.com" ]
egg.robin.leroy@gmail.com
1d937cd0d002772652fa05befc19755ef8c1f88b
19c357f301d187e8a5457ba5955952266ba983a1
/Chapter15/HookDll/dllmain.cpp
21c0e766c02f500bb7a3e3b4fc929fde2a0bc5c0
[ "MIT" ]
permissive
zodiacon/Win10SysProgBookSamples
91d2860077d64e140a0a26d6d07d6d0ed04cce72
d52979fffbf74d3460eeb2e23ad2aebb2398d105
refs/heads/master
2023-07-05T23:12:11.100845
2023-06-30T01:18:53
2023-06-30T01:18:53
196,049,252
361
107
MIT
2022-10-25T06:55:06
2019-07-09T16:54:32
C++
UTF-8
C++
false
false
1,035
cpp
// dllmain.cpp : Defines the entry point for the DLL application. #include "pch.h" #pragma data_seg(".shared") DWORD g_ThreadId = 0; HHOOK g_hHook = nullptr; #pragma data_seg() #pragma comment(linker, "/section:.shared,RWS") BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, PVOID pReserved) { switch (reason) { case DLL_PROCESS_ATTACH: ::DisableThreadLibraryCalls(hModule); break; case DLL_PROCESS_DETACH: ::PostThreadMessage(g_ThreadId, WM_QUIT, 0, 0); break; } return TRUE; } LRESULT CALLBACK HookFunction(int code, WPARAM wParam, LPARAM lParam) { if (code == HC_ACTION) { auto msg = (MSG*)lParam; if (msg->message == WM_CHAR) { ::PostThreadMessage(g_ThreadId, WM_APP, msg->wParam, msg->lParam); // prevent A characters from getting to the app //if (msg->wParam == 'A' || msg->wParam == 'a') // msg->wParam = 0; } } return ::CallNextHookEx(g_hHook, code, wParam, lParam); } void WINAPI SetNotificationThread(DWORD threadId, HHOOK hHook) { g_ThreadId = threadId; g_hHook = hHook; }
[ "zodiacon@live.com" ]
zodiacon@live.com
11da4e3116e3be24ff0ca0bfcca3af32389140b2
84c99ed28b53370bb587b580e47cd15b5be44d94
/src/floor.cc
3ad0d9f7f27b0ea2cca87a0d2f9fe4c3c359438b
[]
no_license
mohfunk/Rouge-Like
ee55e229eb2604bca3a224a7c17ac5606724325f
81ac9cd10878f30b0d5f44ac543056a496248c5d
refs/heads/master
2020-03-22T22:53:11.450519
2018-11-25T07:27:41
2018-11-25T07:27:41
140,776,390
0
0
null
null
null
null
UTF-8
C++
false
false
35,810
cc
#include <iostream> #include <string> #include <cstdlib> #include <sstream> #include <fstream> #include"floor.hpp" #include"characters.hpp" #include"players.hpp" #include"game.hpp" #include"potion.hpp" #include"enemies.hpp" using namespace std; // checkHelp void Floor::checkHelp(int row,int col){ for(int i = 0; i < countp;i++){ if((potion[i]->getRow() == row) && (potion[i]->getCol() == col)){ if(potion[i]->getView()){ action += "The PC sees a " + potion[i]->getName() + " potion "; } else{ action += "The PC sees an unknown potion "; } // else } // if } // for } // checkHelp // checkForP void Floor::checkForP(){ if(td->floor[player->getRow() + 1][player->getCol()] == 'P'){ checkHelp(player->getRow() + 1, player->getCol()); action += "to the south. "; } if(td->floor[player->getRow() - 1][player->getCol()] == 'P'){ checkHelp(player->getRow() - 1, player->getCol()); action += "to the north. "; } if(td->floor[player->getRow()][player->getCol() + 1] == 'P'){ checkHelp(player->getRow(), player->getCol() + 1); action += "to the east. "; } if(td->floor[player->getRow()][player->getCol() - 1] == 'P'){ checkHelp(player->getRow(), player->getCol() - 1); action += "to the west. "; } if(td->floor[player->getRow() + 1][player->getCol() + 1] == 'P'){ checkHelp(player->getRow() + 1, player->getCol() + 1); action += "to the southeast. "; } if(td->floor[player->getRow() + 1][player->getCol() - 1] == 'P'){ checkHelp(player->getRow() + 1, player->getCol() - 1); action += "to the southwest. "; } if(td->floor[player->getRow() - 1][player->getCol() + 1] == 'P'){ checkHelp(player->getRow() - 1, player->getCol() + 1); action += "to the northeast. "; } if(td->floor[player->getRow() - 1][player->getCol() - 1] == 'P'){ checkHelp(player->getRow() - 1, player->getCol() - 1); action += "to the northwest. "; } // if } // checkForP // getCell char Floor::getCell(int r,int c){ return td->floor[r][c]; } // getFloornum int Floor::getFloornum(){ return floornum; } /* for reference |-----------------------------------------------------------------------------| | | | |--------------------------| |-----------------------| | | |..........................| |.......................| | | |..........................+########+.......................|-------| | | |..........................| # |...............................|--| | | |..........................| # |..................................|--| | | |----------+---------------| # |----+----------------|...............| | | # ############# |...............| | | # # |-----+------| |...............| | | # # |............| |...............| | | ################### |............| ######+...............| | | # # |............| # |...............| | | # # |-----+------| # |--------+------| | | |---------+-----------| # # # # | | |.....................| # # # |----+------| | | |.....................| ######################## |...........| | | |.....................| # # |...........| | | |.....................| # |------+--------------------|...........| | | |.....................| # |.......................................| | | |.....................+##########+.......................................| | | |.....................| |.......................................| | | |---------------------| |---------------------------------------| | | | |-----------------------------------------------------------------------------| */ // chamber int Floor::chamber(int cham){ int ran = game->random(5); if(ran == cham){ return chamber(cham); } return ran; } // row int Floor::row(int cham){ if(cham == 0){ return 3 + game->random(4); } else if(cham == 1){ return 3 + game->random(10); } else if(cham == 2){ return 10 + game->random(3); } else if(cham == 3){ return 15 + game->random(7); } else{ return 16 + game->random(6); } } // col int Floor::Col(int cham, int row){ int col; if(cham == 0){ col = 3 + game->random(26); if(isValid(row,col)){ return col; } else{ return Col(cham, row); } } else if(cham == 1){ if(row == 3 || row == 4){ col = 39 + game->random(23); } else if(row == 5){ col = 39 + game->random(31); } else if(row == 6){ col = 39 + game->random(34); } else{ col = 61 + game->random(15); } if(isValid(row,col)){ return col; } else{ return Col(cham, row); } } else if(cham == 2){ col = 38 + game->random(12); if(isValid(row,col)){ return col; } else{ return Col(cham, row); } } else if(cham == 3){ col = 4 + game->random(21); if(isValid(row,col)){ return col; } else{ return Col(cham, row); } } else{ if(row == 16 || row == 17 || row == 18){ col = 65 + game->random(11); } else{ col = 37 + game->random(39); } if(isValid(row,col)){ return col; } else{ return Col(cham, row); } } } // isValid bool Floor::isValid(int row, int col){ if(td->floor[row][col] == '.' || td->floor[row][col] == '+' || td->floor[row][col] == '#'){ return true; } else{ return false; } } // ctor Floor::Floor(Player &Player, Game &gm, string file): player(&Player), action(""), floornum(1), game(&gm), RH(false), BA(false), BD(false), PH(false), WA(false), WD(false), HostilM(false){ td = new TextDisplay; reset(file); } // setDragon void Floor::setDragon(Dragon & d, int r, int c){ int ran = game->random(8); if(canMove(r,c) == false){ return; } if(ran == 0 && isDot(r - 1, c)){ d.setRow(r - 1); d.setCol(c); td->floor[r-1][c] = 'D'; } else if(ran == 1 && isDot(r, c + 1)){ d.setRow(r); d.setCol(c + 1); td->floor[r][c+1] = 'D'; } else if(ran == 2 && isDot(r + 1, c)){ d.setRow(r + 1); d.setCol(c); td->floor[r+1][c] = 'D'; } else if(ran == 3 && isDot(r, c-1)){ d.setRow(r); d.setCol(c-1); td->floor[r][c-1] = 'D'; } else if(ran == 4 && isDot(r - 1, c + 1)){ d.setRow(r - 1); d.setCol(c + 1); td->floor[r-1][c + 1] = 'D'; } else if(ran == 5 && isDot(r + 1, c + 1)){ d.setRow(r + 1); d.setCol(c + 1); td->floor[r+1][c+1] = 'D'; } else if(ran == 0 && isDot(r + 1, c -1)){ d.setRow(r + 1); d.setCol(c-1); td->floor[r+1][c-1] = 'D'; } else if(ran == 0 && isDot(r - 1, c - 1)){ d.setRow(r - 1); d.setCol(c -1); td->floor[r-1][c-1] = 'D'; } else{ setDragon(d, r, c); } } void Floor::reset(string file){ // creation and set up of potions, gold, enemies, and dragon arrays potion = new Potion*[10]; gold = new Gold*[10]; enemy = new Enemy*[20]; dragon = new Dragon*[10]; for(int i = 0; i < 10;i++){ // setting dragons to null dragon[i] = NULL; } if(file == ""){ // handles command line gameplay ( when no files is given ) // initial set up countp = 10; countg = 10; counte = 20; countd = 10; cape = 20; capp = 10; capg = 10; capd = 10; int cham; int pcham = chamber(); int Row = row(pcham); int col = Col(pcham, Row); player->setRow(Row); player->setCol(col); player->setPrev('.'); td->floor[Row][col] = '@'; cham = chamber(pcham); Row = row(cham); col = Col(cham, Row); td->floor[Row][col] = '\\'; // potions creation and placement for(int i = 0; i < 10;i++){ // creation int ran = game->random(6); if(game->Probability(1,ran)){ potion[i] = new Potion(new RHStrategy); if(RH){ potion[i]->viewTrue(); } } else if(game->Probability(2,ran)){ potion[i] = new Potion(new BAStrategy); if(BA){ potion[i]->viewTrue(); } } else if(game->Probability(3,ran)){ potion[i] = new Potion(new BDStrategy); if(BD){ potion[i]->viewTrue(); } } else if(game->Probability(4,ran)){ potion[i] = new Potion(new PHStrategy); if(PH){ potion[i]->viewTrue(); } } else if(game->Probability(5,ran)){ potion[i] = new Potion(new WAStrategy); if(WA){ potion[i]->viewTrue(); } } else{ potion[i] = new Potion(new WDStrategy); if(WD){ potion[i]->viewTrue(); } } // placement cham = chamber(); Row = row(cham); col = Col(cham, Row); potion[i]->setRow(Row); potion[i]->setCol(col); td->floor[Row][col] = 'P'; } // for loop /* cham = chamber(); Row = row(cham); col = Col(cham, Row); */ // gold creation and placement for(int i = 0; i < 10;i++){ // creation int ran = game->random(8); if(game->Probability(0,ran)){ gold[i] = new Gold("Dragon hoard"); } else if(game->Probability(1,ran) || game->Probability(2,ran)){ gold[i] = new Gold("small pile"); } else { gold[i] = new Gold("normal pile"); } // placement cham = chamber(); Row = row(cham); col = Col(cham, Row); gold[i]->setRow(Row); gold[i]->setCol(col); if(ran == 0){ for(int j = 0;j < 10;j++){ // dragons creation, placement and tying to dragon hords if(dragon[j] == NULL){ dragon[j] = new Dragon(gold[i]->getRow(), gold[i]->getCol()); setDragon(*dragon[j], gold[i]->getRow(), gold[i]->getCol()); break; } // if } // for } // if td->floor[Row][col] = 'G'; } // for loop // enemies creation and replacement for(int i = 0; i < 20;i++){ int ran = game->random(18); if(game->Probability(0,ran) || game->Probability(1,ran) || game->Probability(2,ran) || game->Probability(3,ran)) { enemy[i] = new Human; } else if(game->Probability(4,ran) || game->Probability(5,ran) || game->Probability(6,ran)) { enemy[i] = new Dwarf; } else if(game->Probability(7,ran) || game->Probability(8,ran) || game->Probability(9,ran) || game->Probability(10,ran) || game->Probability(11,ran) ) { enemy[i] = new Halfling; } else if(game->Probability(12,ran) || game->Probability(13,ran) ) { enemy[i] = new Elf; } else if(game->Probability(14,ran) || game->Probability(15,ran) ) { enemy[i] = new Orc; } else { enemy[i] = new Merchant; } // if cham = chamber(); Row = row(cham); col = Col(cham,Row); enemy[i]->setRow(Row); enemy[i]->setCol(col); td->floor[Row][col] = enemy[i]->getSymbol(); } // for } else{ // reading in from a file countp = 0; countg = 0; counte = 0; countd = 0; cape = 20; capp = 10; capg = 10; capd = 10; ifstream ifs(file.c_str()); for(int i = 1; i < floornum; i++){ for(int j = 0; j < 25;j++){ // numof floors string s; getline(ifs,s); } } for(int i = 0; i < 25; i++){ string s; getline(ifs,s); for(int j = 0; j < 79; j++){ if(capp == countp){ capp *= 2; Potion **newp; newp = new Potion*[capp]; for(int i = 0;i < countp;i++){ newp[i] = potion[i]; } delete []potion; potion = newp; } if(capg == countg){ capg *= 2; Gold **newg; newg = new Gold*[capg]; for(int i = 0;i < countg;i++){ newg[i] = gold[i]; } delete []gold; gold = newg; } if(cape == counte){ cape *= 2; Enemy **newe; newe = new Enemy*[cape]; for(int i = 0;i < counte;i++){ newe[i] = enemy[i]; } delete []enemy; enemy = newe; } if(capd == countd){ capd *= 2; Dragon **newd; newd = new Dragon*[capd]; for(int i = 0;i < countd;i++){ newd[i] = dragon[i]; } delete []dragon; dragon = newd; } if(s[j] == '@'){ player->setRow(i); player->setCol(j); td->floor[i][j] = '@'; } else if(s[j] == '0'){ potion[countp] = new Potion(new RHStrategy); potion[countp]->setRow(i); potion[countp]->setCol(j); if(RH){ potion[countp]->viewTrue(); } countp += 1; td->floor[i][j] = 'P'; } else if(s[j] == '1'){ potion[countp] = new Potion(new BAStrategy); potion[countp]->setRow(i); potion[countp]->setCol(j); if(BA){ potion[countp]->viewTrue(); } countp += 1; td->floor[i][j] = 'P'; } else if(s[j] == '2'){ potion[countp] = new Potion(new BDStrategy); potion[countp]->setRow(i); potion[countp]->setCol(j); if(BD){ potion[countp]->viewTrue(); } countp += 1; td->floor[i][j] = 'P'; } else if(s[j] == '3'){ potion[countp] = new Potion(new PHStrategy); potion[countp]->setRow(i); potion[countp]->setCol(j); if(PH){ potion[countp]->viewTrue(); } countp += 1; td->floor[i][j] = 'P'; } else if(s[j] == '4'){ potion[countp] = new Potion(new WAStrategy); potion[countp]->setRow(i); potion[countp]->setCol(j); if(WA){ potion[countp]->viewTrue(); } countp += 1; td->floor[i][j] = 'P'; } else if(s[j] == '5'){ potion[countp] = new Potion(new WDStrategy); potion[countp]->setRow(i); potion[countp]->setCol(j); if(WD){ potion[countp]->viewTrue(); } countp += 1; td->floor[i][j] = 'P'; } else if(s[j] == '6'){ gold[countg] = new Gold("normal pile"); gold[countg]->setRow(i); gold[countg]->setCol(j); countg += 1; td->floor[i][j] = 'G'; } else if(s[j] == '7'){ gold[countg] = new Gold("small pile"); gold[countg]->setRow(i); gold[countg]->setCol(j); countg += 1; td->floor[i][j] = 'G'; } else if(s[j] == '8'){ gold[countg] = new Gold("merchant hoard"); gold[countg]->setRow(i); gold[countg]->setCol(j); countg += 1; td->floor[i][j] = 'G'; } else if(s[j] == '9'){ gold[countg] = new Gold("Dragon hoard"); gold[countg]->setRow(i); gold[countg]->setCol(j); countg += 1; td->floor[i][j] = 'G'; } else if(s[j] == 'H'){ enemy[counte] = new Human; enemy[counte]->setRow(i); enemy[counte]->setCol(j); counte += 1; td->floor[i][j] = 'H'; } else if(s[j] == 'W'){ enemy[counte] = new Dwarf; enemy[counte]->setRow(i); enemy[counte]->setCol(j); counte += 1; td->floor[i][j] = 'W'; } else if(s[j] == 'E'){ enemy[counte] = new Elf; enemy[counte]->setRow(i); enemy[counte]->setCol(j); counte += 1; td->floor[i][j] = 'E'; } else if(s[j] == 'O'){ enemy[counte] = new Orc; enemy[counte]->setRow(i); enemy[counte]->setCol(j); counte += 1; td->floor[i][j] = 'O'; } else if(s[j] == 'M'){ enemy[counte] = new Merchant; enemy[counte]->setRow(i); enemy[counte]->setCol(j); counte += 1; td->floor[i][j] = 'M'; } else if(s[j] == 'L'){ enemy[counte] = new Halfling; enemy[counte]->setRow(i); enemy[counte]->setCol(j); counte += 1; td->floor[i][j] = 'L'; } else{ td->floor[i][j] = s[j]; }// else }// for j }// for i // read again, look for dragons and tie them with their dragon hords for(int i = 0; i < 25; i++){ for(int j = 0; j < 79; j++){ if(capd == countd){ capd *= 2; Dragon **newd; newd = new Dragon*[capd]; for(int i = 0;i < countd;i++){ newd[i] = dragon[i]; } delete []dragon; dragon = newd; } if(td->floor[i][j] == 'D'){ int r; int c; for(int g = 0; g < countg; g++){ r = gold[g]->getRow(); c = gold[g]->getCol(); if(gold[g]->getType() == "Dragon hoard" && gold[g]->getIsTied() == false && isOneRad(r,c,i,j)){ dragon[countd] = new Dragon(r,c); dragon[countd]->setRow(i); dragon[countd]->setCol(j); countd += 1; gold[g]->setIsTied(true); break; } // if } // for counting gold } // if } // for j } // for i } // else ( reading from files) } // reset // isOneRad bool Floor::isOneRad(int r1, int c1, int r2, int c2){ int r = r1 - r2; int c = c1 - c2; if( r == -1 && c == 0 ) {return true;} else if( r == 0 && c == 1 ) {return true;} else if( r == 1 && c == 0 ) {return true;} else if( r == 0 && c == -1 ) {return true;} else if( r == -1 && c == -1 ) {return true;} else if( r == -1 && c == 1 ) {return true;} else if( r == 1 && c == 1 ) {return true;} else if( r == 1 && c == -1 ) {return true;} else {return false;} } // dtor Floor::~Floor(){ delete td; for(int i = 0; i < countp; i++){ delete potion[i]; } for(int i = 0; i < countg; i++){ delete gold[i]; } for(int i = 0; i < counte; i++){ delete enemy[i]; } for(int i = 0; i < countd; i++){ delete dragon[i]; } delete[] enemy; delete[] potion; delete[] gold; delete[] dragon; } // printFloor void Floor::printFloor(){ td->print(); cout << "Race: " << player->getRace(); cout << " Gold: " << player->getGold(); cout << " Floor " << floornum << endl; cout << "HP: " << player->getHP() << endl; cout << "Atk: " << player->getAtk() << endl; cout << "Def: " << player->getDef() << endl; cout << "Action: " << action << endl; } // setAction void Floor::setAction(string desc){ action = desc; } // setPoint void Floor::setPoint(int row, int col, Player &player, string file){ if(isValid(row, col)){ if (td->floor[player.getRow()][player.getCol()] == '|' || td->floor[player.getRow()][player.getCol()] == '-'){ player.setPrev('.'); player.setRow(row); player.setCol(col); td->floor[row][col] = player.getSymbol(); } else{ td->floor[player.getRow()][player.getCol()] = player.getPrev(); player.setPrev(td->floor[row][col]); player.setRow(row); player.setCol(col); td->floor[row][col] = player.getSymbol(); } } // if else if(td->floor[row][col] == '\\'){ floornum += 1; if(floornum == 6){ cout << "You have conquered the dungeon." << endl; if(player.getRace() == "Shade"){ cout << "Score: " << (player.getGold() * 1.5) << endl; } else{ cout << "Score: " << player.getGold() << endl; } return; } for(int i = 0; i < countp; i++){ delete potion[i]; } delete[] potion; for(int i = 0; i < countg; i++){ delete gold[i]; } delete[] gold; for(int i = 0; i < counte; i++){ delete enemy[i]; } delete[] enemy; for(int i = 0; i < countd; i++){ delete dragon[i]; } delete[] dragon; action += "Player ascends to another floor and the effects of attack and defence potions have been lifted. "; player.setPrev('.'); player.resetAD(); td->reset(); reset(file); } // else if else if(td->floor[row][col] == 'G'){ td->floor[player.getRow()][player.getCol()] = player.getPrev(); player.setPrev('.'); for(int i = 0; i < countg; i++){ if(gold[i]->getRow() == row && gold[i]->getCol() == col){ if(gold[i]->getType() == "Dragon hoard"){ if(isDragonNear(gold[i]->getRow(),gold[i]->getCol()) == false){ gold[i]->DragonIsDead(); } } if(gold[i]->canTake()){ player.setGold(player.getGold() + gold[i]->getValue()); stringstream ss; ss << gold[i]->getValue(); string s; ss >> s; if(gold[i]->getType() == "2 normal piles"){ action += "Player picks up " + gold[i]->getType() + " of gold (" + s + "). "; } else{ action += "Player picks up a " + gold[i]->getType() + " of gold (" + s + "). "; } break; } else{ player.setPrev('G'); action += "Can't take gold until the Dragon is slain. "; break; } // else } // if } // for player.setRow(row); player.setCol(col); td->floor[row][col] = player.getSymbol(); } // else if } // setPoint // isDragonNear bool Floor::isDragonNear(int r, int c){ if( td->floor[r-1][c] == 'D' ) {return true;} else if( td->floor[r][c+1] == 'D' ) {return true;} else if( td->floor[r+1][c] == 'D' ) {return true;} else if( td->floor[r][c-1] == 'D' ) {return true;} else if( td->floor[r-1][c+1] == 'D' ) {return true;} else if( td->floor[r-1][c-1] == 'D' ) {return true;} else if( td->floor[r+1][c+1] == 'D' ) {return true;} else if( td->floor[r+1][c-1] == 'D' ) {return true;} else {return false;} } // usePotion void Floor::usePotion(int r, int c){ for(int i = 0;i < countp;i++){ if(r == potion[i]->getRow() && c == potion[i]->getCol()){ action += "PC consumes a " + potion[i]->getName() + " potion. "; potion[i]->usePotion(*player); td->floor[potion[i]->getRow()][potion[i]->getCol()] = '.'; if(potion[i]->getName() == "RH" && RH == false){ RH = true; setPotionsTrue("RH"); } else if(potion[i]->getName() == "BA" && BA == false){ BA = true; setPotionsTrue("BA"); } else if(potion[i]->getName() == "BD" && BD == false){ BD = true; setPotionsTrue("BD"); } else if(potion[i]->getName() == "PH" && PH == false){ PH = true; setPotionsTrue("PH"); } else if(potion[i]->getName() == "WA" && WA == false){ WA = true; setPotionsTrue("WA"); } else if(potion[i]->getName() == "WD" && WD == false){ WD = true; setPotionsTrue("WD"); } //else if } //if } // for } // usePotion // setPotionsTrue void Floor::setPotionsTrue(string name){ for(int i = 0; i < countp; i ++){ if(potion[i]->getName() == name){ potion[i]->viewTrue(); } // if } // for } // setPotionsTrue // isDot bool Floor::isDot(int row, int col) { if(td->floor[row][col] == '.') { return true;} return false; } // nearByPlayer bool Floor::nearByPlayer(int row, int col) { if(td->floor[row-1][col] == '@') {return true;} // north if(td->floor[row][col+1] == '@') {return true;} // east if(td->floor[row+1][col] == '@') {return true;} // south if(td->floor[row][col-1] == '@') {return true;} // west if(td->floor[row-1][col+1] == '@') {return true;} // ne if(td->floor[row+1][col+1] == '@') {return true;} // se if(td->floor[row+1][col-1] == '@') {return true;} // sw if(td->floor[row-1][col-1] == '@') {return true;} // nw else { return false; } } // canMove bool Floor::canMove(int row, int col) { if(td->floor[row-1][col] == '.') {return true;} // north if(td->floor[row][col+1] == '.') {return true;} // east if(td->floor[row+1][col] == '.') {return true;} // south if(td->floor[row][col-1] == '.') {return true;} // west if(td->floor[row-1][col+1] == '.') {return true;} // ne if(td->floor[row+1][col+1] == '.') {return true;} // se if(td->floor[row+1][col-1] == '.') {return true;} // sw if(td->floor[row-1][col-1] == '.') {return true;} // nw else { return false; } } // MoveEnemy void Floor::MoveEnemy(Enemy & e) { int ran = game->random(8); int r = e.getRow(); int c = e.getCol(); if ( ran == 0 ) { if(isDot(r-1,c)) { e.setRow(r-1); td->floor[r][c] = '.'; td->floor[r-1][c] = e.getSymbol(); } else { MoveEnemy(e); } } else if ( ran == 1 ) { if(isDot(r,c+1)) { e.setCol(c+1); td->floor[r][c] = '.'; td->floor[r][c+1] = e.getSymbol(); } else { MoveEnemy(e); } } else if ( ran == 2 ) { if(isDot(r+1,c)) { e.setRow(r+1); td->floor[r][c] = '.'; td->floor[r+1][c] = e.getSymbol(); } else { MoveEnemy(e); } } else if ( ran == 3 ) { if(isDot(r,c-1)) { e.setCol(c-1); td->floor[r][c] = '.'; td->floor[r][c-1] = e.getSymbol(); } else { MoveEnemy(e); } } else if ( ran == 4 ) { if(isDot(r-1,c+1)) { e.setRow(r-1); e.setCol(c+1); td->floor[r][c] = '.'; td->floor[r-1][c+1] = e.getSymbol(); } else { MoveEnemy(e); } } else if ( ran == 5 ) { if(isDot(r+1,c+1)) { e.setRow(r+1); e.setCol(c+1); td->floor[r][c] = '.'; td->floor[r+1][c+1] = e.getSymbol(); } else { MoveEnemy(e); } } else if ( ran == 6 ) { if(isDot(r+1,c-1)) { e.setRow(r+1); e.setCol(c-1); td->floor[r][c] = '.'; td->floor[r+1][c-1] = e.getSymbol(); } else { MoveEnemy(e); } } else if ( ran == 7 ) { if(isDot(r-1,c-1)) { e.setRow(r-1); e.setCol(c-1); td->floor[r][c] = '.'; td->floor[r-1][c-1] = e.getSymbol(); } else { MoveEnemy(e); } // else } // else if } // moveEnemy // Enemybeh void Floor::Enemybeh() { for(int j = 0;j < 25;j++) { for(int k = 0; k < 79; k++) { if(td->floor[j][k] == 'D') { // dragon attacks for(int l = 0; l < countd; ++l) { if(dragon[l] != NULL){ if(dragon[l]->getRow() == j && dragon[l]->getCol() == k) { if(nearByPlayer(j,k) || nearByPlayer(dragon[l]->getGoldRow(), dragon[l]->getGoldCol())){ EnemyAtk(*dragon[l]); } // if player nearby } // if dragon at } // if dragon } // for } // if dragon // other enemies else if(td->floor[j][k] == 'H' || td->floor[j][k] == 'W' || td->floor[j][k] == 'E' || td->floor[j][k] == 'O' || td->floor[j][k] == 'M' || td->floor[j][k] == 'L'){ for(int i = 0; i < counte; i++){ int r = enemy[i]->getRow(); int c = enemy[i]->getCol(); if(r == j && c == k && enemy[i]->getMoved() == false){ if (nearByPlayer(r,c) == false && canMove(r,c) && enemy[i]->isDead() == false) { MoveEnemy(*enemy[i]); enemy[i]->setMoved(true); } else if (nearByPlayer(r,c) && enemy[i]->isDead() == false) { EnemyAtk(*enemy[i]); } // else if } // if } // for } // else if } // for k } // for j // after attacking, enemies cant move for(int g = 0; g < counte;g++){ enemy[g]->setMoved(false); } } // EnemyAtk void Floor::EnemyAtk(Enemy & e){ if(e.getSymbol() == 'M'){ if(HostilM){ if(game->random(2) == 0){ int health = player->getHP(); string s; game->PlayerDamage(*player, e); health = health - player->getHP(); stringstream ss; ss << health; ss >> s; action += "The " + e.getRace() + " dealt " + s + " damage to the player. "; } else{ action += "The " + e.getRace() + "'s attack missed. "; } } } else if(e.getSymbol() == 'E'){ if(player->getRace() == "Drow"){ if(game->random(2) == 0){ int health = player->getHP(); string s; game->PlayerDamage(*player, e); health = health - player->getHP(); stringstream ss; ss << health; ss >> s; action += "The " + e.getRace() + " dealt " + s + " damage to the player. "; } else{ action += "The " + e.getRace() + "'s attack missed. "; } } else{ if(game->random(2) == 0){ int health = player->getHP(); string s; game->PlayerDamage(*player, e); health = health - player->getHP(); stringstream ss; ss << health; ss >> s; action += "The " + e.getRace() + "'s first attack dealt " + s + " damage to the player. "; } else{ action += "The Elf's first attack missed. "; } if(game->random(2) == 0){ int health = player->getHP(); string s; game->PlayerDamage(*player, e); health = health - player->getHP(); stringstream ss; ss << health; ss >> s; action += "The " + e.getRace() + "'s second attack dealt " + s + " damage to the player. "; } else{ action += "The Elf's second attack missed. "; } } } else if(game->random(2) == 0){ int health = player->getHP(); string s; game->PlayerDamage(*player, e); health = health - player->getHP(); stringstream ss; ss << health; ss >> s; action += "The " + e.getRace() + " dealt " + s + " damage to the player. "; } else{ action += "The " + e.getRace() + "'s attack missed. "; } } void Floor::PlayerAtk(int r,int c){ for(int i = 0; i < countd; i++){ if(dragon[i] != NULL) { if(dragon[i]->getRow() == r && dragon[i]->getCol() == c){ int health = dragon[i]->getHP(); game->EnemyDamage(*player, *dragon[i]); health = health - dragon[i]->getHP(); if(dragon[i]->isDead()){ action += "The PC has slain the dragon. "; int rw = dragon[i]->getGoldRow(); int cl = dragon[i]->getGoldCol(); for(int j = 0; j < countg;j++){ if(gold[j]->getRow() == rw && gold[j]->getCol() == cl){ gold[j]->DragonIsDead(); break; } } td->floor[dragon[i]->getRow()][dragon[i]->getCol()] = '.'; } else{ string s; string h; stringstream ss; ss << health; ss >> s; stringstream sss; sss << dragon[i]->getHP(); sss >> h; action += "The PC dealt " + s + " damage to the dragon (" + h + "). "; } // else } // if } // if } // for for(int i = 0; i < counte;i++){ if(enemy[i]->getRow() == r && enemy[i]->getCol() == c){ int health = enemy[i]->getHP(); if(enemy[i]->getSymbol() == 'L'){ int ran = game->random(2); if(ran == 1){ action += "The halfling dodged your attack. "; break; } } if(enemy[i]->getSymbol() == 'M'){ if(HostilM == false){ HostilM = true; action += "You attack a merchant. Now all merchants will attack you if you go near them. "; } } game->EnemyDamage(*player, *enemy[i]); if(player->getRace() == "Vampire"){ if(enemy[i]->getSymbol() == 'W'){ if(player->getHP() - 5 < 0){ player->setHP(0); action += "PC died from bad blood. "; } else{ player->setHP(player->getHP() - 5); action += "Vampires are allergic to dwarfs. The PC loses 5 HP. "; } } else{ player->setHP(player->getHP() + 5); action += "Vampire drank some blood and restored 5 hp. "; } } if(enemy[i]->isDead()){ td->floor[enemy[i]->getRow()][enemy[i]->getCol()] = '.'; action += "The PC has slain the " + enemy[i]->getRace() + ". "; if(enemy[i]->getSymbol() == 'H'){ if(capg == countg){ capg *= 2; Gold **newg; newg = new Gold*[capg]; for(int j = 0;j < countg;j++){ newg[j] = gold[j]; } delete []gold; gold = newg; } gold[countg] = new Gold("2 normal piles"); gold[countg]->setRow(enemy[i]->getRow()); gold[countg]->setCol(enemy[i]->getCol()); td->floor[enemy[i]->getRow()][enemy[i]->getCol()] = 'G'; countg += 1; } else if(enemy[i]->getSymbol() == 'M'){ if(capg == countg){ capg *= 2; Gold **newg; newg = new Gold*[capg]; for(int j = 0;j < countg;j++){ newg[j] = gold[j]; } delete []gold; gold = newg; } gold[countg] = new Gold("merchant hoard"); gold[countg]->setRow(enemy[i]->getRow()); gold[countg]->setCol(enemy[i]->getCol()); td->floor[enemy[i]->getRow()][enemy[i]->getCol()] = 'G'; countg += 1; } else if(enemy[i]->getSymbol() != 'D'){ int ran = game->random(2); if(ran == 0){ player->setGold(player->getGold() + 2); action += "PC recieves 2 gold for killing the " + enemy[i]->getRace() + ". "; } else{ player->setGold(player->getGold() + 1); action += "PC recieves 1 gold for killing the " + enemy[i]->getRace() + ". "; } } if(player->getRace() == "Goblin"){ player->setGold(player->getGold() + 5); action += " PC steals 5 gold from the " + enemy[i]->getRace() + ". "; } } else { health = health - enemy[i]->getHP(); string s; string h; stringstream ss; ss << health; ss >> s; stringstream sss; sss << enemy[i]->getHP(); sss >> h; action += "The PC dealt " + s + " damage to the " + enemy[i]->getRace() + " (" + h + "). "; } // else break; } // if } // for } //player atk // notifiy void Floor::notify(int row, int col, string input, string file) { action = ""; // start with an empty action bool b = true; // to stop enemies from moving while going up the stairs if (td->floor[row+player->getRow()][col+player->getCol()] == '\\') { b = false; } if(player->getRace() == "Troll" && player->getMaxHP() != player->getHP()){ if(player->getHP() + 5 > player->getMaxHP()){ player->setHP(player->getMaxHP()); action += "The player is back at full health. "; } else{ player->setHP(player->getHP() + 5); action += "5 HP has been restored to the player. "; } } if ( input == "no" ) action += "PC moves North. "; if ( input == "so" ) action += "PC moves South. "; if ( input == "ea" ) action += "PC moves East. "; if ( input == "we" ) action += "PC moves West. "; if ( input == "ne" ) action += "PC moves NorthEast. "; if ( input == "nw" ) action += "PC moves NorthWest. "; if ( input == "se" ) action += "PC moves SouthEast. "; if ( input == "sw" ) action += "PC moves SouthWest. "; if ( input[0] == 'u' ){ usePotion(row + player->getRow(),col + player->getCol()); } else if(input[0] == 'a'){ PlayerAtk(row + player->getRow(),col + player->getCol()); } else{ setPoint(row + player->getRow(),col + player->getCol(), *this->player, file); if(floornum == 6) return; } checkForP(); if ( b == true) { Enemybeh(); } printFloor(); }
[ "mohfunk@gmail.com" ]
mohfunk@gmail.com
79f3347e0af598fb1cd49217f5eae7ce149cd8e4
b7985fda8b7378e9f26015ac41b1a8697683c628
/Assign04/sequenceTest.cpp
fcf2a3a8685a0efb770bec755743e5fac72b777a
[]
no_license
codyryanwright/Sequence
e3487cf6ccb56a582f0d53649f40603535ea090a
6c0713ad4cabd24aa02324487c9d92a851b952bd
refs/heads/master
2020-06-28T01:12:49.415957
2019-11-25T01:16:48
2019-11-25T01:16:48
200,102,871
0
0
null
null
null
null
UTF-8
C++
false
false
10,958
cpp
// Name: Cody Wright // Date: 2/25/2019 // Last Modified: 2/25/2019 // FILE: sequenceTest.cpp // An interactive test program for the sequence class #include <cctype> // provides toupper #include <iostream> // provides cout and cin #include <cstdlib> // provides EXIT_SUCCESS #include "sequence.h" using namespace std; using namespace CS3358_SP2019_A04; // PROTOTYPES for functions used by this test program: void print_menu(); // Pre: (none) // Post: A menu of choices for this program is written to cout. char get_user_command(); // Pre: (none) // Post: The user is prompted to enter a one character command. // The next character is read (skipping blanks and newline // characters), and this character is returned. template <class Item> void show_list(sequence<Item> src); // Pre: (none) // Post: The items of src are printed to cout (one per line). int get_object_num(); // Pre: (none) // Post: The user is prompted to enter either 1 or 2. The // prompt is repeated until a valid integer can be read // and the integer's value is either 1 or 2. The valid // integer read is returned. The input buffer is cleared // of any extra input until and including the first // newline character. double get_number(); // Pre: (none) // Post: The user is prompted to enter a real number. The prompt // is repeated until a valid real number can be read. The // valid real number read is returned. The input buffer is // cleared of any extra input until and including the // first newline character. char get_character(); // Pre: (none) // Post: The user is prompted to enter a non-whitespace character. // The prompt is repeated until a non-whitespace character // can be read. The non-whitespace character read is returned. // The input buffer is cleared of any extra input until and // including the first newline character. int main(int argc, char *argv[]) { sequence<double> s1; // A sequence of double for testing sequence<char> s2; // A sequence of char for testing int objectNum; // A number to indicate selection of s1 or s2 double numHold; // Holder for a real number char charHold; // Holder for a character char choice; // A command character entered by the user cout << "An empty sequence of real numbers (s1) and\n" << "an empty sequence of characters (s2) have been created." << endl; do { if (argc == 1) print_menu(); choice = toupper( get_user_command() ); switch (choice) { case '!': objectNum = get_object_num(); if (objectNum == 1) { s1.start(); cout << "s1 started" << endl; } else { s2.start(); cout << "s2 started" << endl; } break; case '&': objectNum = get_object_num(); if (objectNum == 1) { s1.end(); cout << "s1 ended" << endl; } else { s2.end(); cout << "s2 ended" << endl; } break; case '+': objectNum = get_object_num(); if (objectNum == 1) { if ( ! s1.is_item() ) cout << "Can't advance s1." << endl; else { s1.advance(); cout << "Advanced s1 one item."<< endl; } } else { if ( ! s2.is_item() ) cout << "Can't advance s2." << endl; else { s2.advance(); cout << "Advanced s2 one item."<< endl; } } break; case '-': objectNum = get_object_num(); if (objectNum == 1) { if ( ! s1.is_item() ) cout << "Can't move back s1." << endl; else { s1.move_back(); cout << "Moved s1 back one item."<< endl; } } else { if ( ! s2.is_item() ) cout << "Can't move back s2." << endl; else { s2.move_back(); cout << "Moved s2 back one item."<< endl; } } break; case '?': objectNum = get_object_num(); if (objectNum == 1) { if ( s1.is_item() ) cout << "s1 has a current item." << endl; else cout << "s1 has no current item." << endl; } else { if ( s2.is_item() ) cout << "s2 has a current item." << endl; else cout << "s2 has no current item." << endl; } break; case 'C': objectNum = get_object_num(); if (objectNum == 1) { if ( s1.is_item() ) cout << "Current item in s1 is: " << s1.current() << endl; else cout << "s1 has no current item." << endl; } else { if ( s2.is_item() ) cout << "Current item in s2 is: " << s2.current() << endl; else cout << "s2 has no current item." << endl; } break; case 'P': objectNum = get_object_num(); if (objectNum == 1) { if (s1.size() > 0) { cout << "s1: "; show_list(s1); cout << endl; } else cout << "s1 is empty." << endl; } else { if (s2.size() > 0) { cout << "s2: "; show_list(s2); cout << endl; } else cout << "s2 is empty." << endl; } break; case 'S': objectNum = get_object_num(); if (objectNum == 1) cout << "Size of s1 is: " << s1.size() << endl; else cout << "Size of s2 is: " << s2.size() << endl; break; case 'A': objectNum = get_object_num(); if (objectNum == 1) { numHold = get_number(); s1.add(numHold); cout << numHold << " added to s1." << endl; } else { charHold = get_character(); s2.add(charHold); cout << charHold << " added to s2." << endl; } break; case 'R': objectNum = get_object_num(); if (objectNum == 1) { if ( s1.is_item() ) { numHold = s1.current(); s1.remove_current(); cout << numHold << " removed from s1." << endl; } else cout << "s1 has no current item." << endl; } else { if ( s2.is_item() ) { charHold = s2.current(); s2.remove_current(); cout << charHold << " removed from s2." << endl; } else cout << "s2 has no current item." << endl; } break; case 'Q': cout << "Quit option selected...bye" << endl; break; default: cout << choice << " is invalid...try again" << endl; } } while (choice != 'Q'); cin.ignore(999, '\n'); cout << "Press Enter or Return when ready..."; cin.get(); return EXIT_SUCCESS; } void print_menu() { cout << endl; cout << "The following choices are available:\n"; cout << " ! Activate the start() function\n"; cout << " & Activate the end() function\n"; cout << " + Activate the advance() function\n"; cout << " - Activate the move_back() function\n"; cout << " ? Print the result from the is_item() function\n"; cout << " C Print the result from the current() function\n"; cout << " P Print a copy of the entire sequence\n"; cout << " S Print the result from the size() function\n"; cout << " A Add a new item with the add(...) function\n"; cout << " R Activate the remove_current() function\n"; cout << " Q Quit this test program" << endl; } char get_user_command() { char command; cout << "Enter choice: "; cin >> command; cout << "You entered "; cout << command << endl; return command; } template <class Item> void show_list(sequence<Item> src) { for ( src.start(); src.is_item(); src.advance() ) cout << src.current() << " "; } int get_object_num() { int result; cout << "Enter object # (1 = s1, 2 = s2) "; cin >> result; while ( ! cin.good() ) { cerr << "Invalid integer input..." << endl; cin.clear(); cin.ignore(999, '\n'); cout << "Re-enter object # (1 = s1, 2 = s2) "; cin >> result; } // cin.ignore(999, '\n'); while (result != 1 && result != 2) { cin.ignore(999, '\n'); cerr << "Invalid object # (must be 1 or 2)..." << endl; cout << "Re-enter object # (1 = s1, 2 = s2) "; cin >> result; while ( ! cin.good() ) { cerr << "Invalid integer input..." << endl; cin.clear(); cin.ignore(999, '\n'); cout << "Re-enter object # (1 = s1, 2 = s2) "; cin >> result; } // cin.ignore(999, '\n'); } cout << "You entered "; cout << result << endl; return result; } double get_number() { double result; cout << "Enter a real number: "; cin >> result; while ( ! cin.good() ) { cerr << "Invalid real number input..." << endl; cin.clear(); cin.ignore(999, '\n'); cout << "Re-enter a real number "; cin >> result; } // cin.ignore(999, '\n'); cout << "You entered "; cout << result << endl; return result; } char get_character() { char result; cout << "Enter a non-whitespace character: "; cin >> result; while ( ! cin ) { cerr << "Invalid non-whitespace character input..." << endl; cin.ignore(999, '\n'); cout << "Re-enter a non-whitespace character: "; cin >> result; } // cin.ignore(999, '\n'); cout << "You entered "; cout << result << endl; return result; }
[ "cwright68@gmail.com" ]
cwright68@gmail.com
7260380690e9a83382d8da8fc660851f099d1aae
e0c44bd7eae42a75ca2e4abd9de827b29e23e4e3
/cpp11/4.1.cpp
710d1fe43eb6de19028a4bfb56ed5eb741f5fda0
[]
no_license
Lowpower/Books
441862804ae2f47b99d2714b04c915c3792aca66
cea274a1da90aa8cf870573a0d16c5f71f835096
refs/heads/master
2023-07-22T08:04:42.160870
2023-07-18T09:46:46
2023-07-18T09:46:46
210,081,729
0
0
null
null
null
null
UTF-8
C++
false
false
226
cpp
#include <iostream> #include <memory> using namespace std; struct A { shared_ptr<A> GetSelf() { return shared_ptr<A>(this); } }; int main() { shared_ptr<A> sp1(new A); shared_ptr<A> sp2 = sp1->GetSelf(); return 0; }
[ "szq123456123@gmail.com" ]
szq123456123@gmail.com