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
b0fdf157c0aebdbc5888342df6adcf2e3a19304c
8cf32b4cbca07bd39341e1d0a29428e420b492a6
/contracts/libc++/upstream/test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp
d4f885c14781ac6b456bb4e69e32d8a056d2eb41
[ "NCSA", "MIT" ]
permissive
cubetrain/CubeTrain
e1cd516d5dbca77082258948d3c7fc70ebd50fdc
b930a3e88e941225c2c54219267f743c790e388f
refs/heads/master
2020-04-11T23:00:50.245442
2018-12-17T16:07:16
2018-12-17T16:07:16
156,970,178
0
0
null
null
null
null
UTF-8
C++
false
false
702
cpp
//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <ios> // template <class charT, class traits> class basic_ios // iostate rdstate() const; #include <ios> #include <cassert> int main() { std::ios ios(0); assert(ios.rdstate() == std::ios::badbit); ios.setstate(std::ios::failbit); assert(ios.rdstate() == (std::ios::failbit | std::ios::badbit)); }
[ "1848@shanchain.com" ]
1848@shanchain.com
52fbda7db6da184f367d5eb886d598805f740838
f89e7d3912e37dd46bb1f9ca4f955864c91a3ae9
/client/Views/Panel.h
f97f2dd824b8990ddc33c08d0a5aeca3f90a2901
[]
no_license
hilgenberg/amoc
5eb78bd233e2b9fc806831fe23100488c29b27cb
99df710a12e623c9c80206f91fb3331d3d88ac3c
refs/heads/master
2023-02-17T17:28:05.085161
2023-02-12T14:27:50
2023-02-12T14:27:50
82,281,215
3
0
null
null
null
null
UTF-8
C++
false
false
1,837
h
#pragma once #include <ncurses.h> #include "../../playlist.h" #include "../Util/Rect.h" #include "View.h" enum menu_request { REQ_UP, REQ_DOWN, REQ_XUP, REQ_XDOWN, REQ_SCROLL_UP, REQ_SCROLL_DOWN, REQ_PGUP, REQ_PGDOWN, REQ_TOP, REQ_BOTTOM, REQ_COLLAPSE // collapse multi-selection to a single selection }; class Interface; //--------------------------------------------------------------- // Panel draws the playlist views and handles selection, current // song mark and various events. Closely related to FrameView. //--------------------------------------------------------------- struct Panel : public View { // c'tor gets called before the interface is running! Panel(Interface &iface, plist &items) : iface(iface), items(items) , top(0), sel(-1), xsel(0), mark(-1) , layout{.c0 = -1 } {} void set_active(bool a) { active = a; } void draw() const override; // no frame, draws just the inside void update_layout() { layout.c0 = -1; } void move_selection(menu_request req); bool handle_click(int x, int y, bool dbl) override; bool mark_path(const str &f); // or unmark if not found void mark_item(int i, bool take_sel = true); // this and mark_path take the selection along if sel==mark bool select_path(const str &f); // leave selection as is if not found void select_item(int i); bool item_visible (int i) const { return i >= top && i < top + bounds.h; }; Interface &iface; plist &items; Rect bounds; bool active; mutable int top; // first visible item mutable int sel, mark; // selected and marked items, -1 if none mutable int xsel; // if != 0: multi-sel from sel to sel+xsel (both inclusive) mutable struct{ int c0,c1,c2,cn; bool hide_artist, hide_album; bool too_small; bool readtags; int prefix_len; #ifndef NDEBUG int rows; #endif } layout; };
[ "th@zoon.cc" ]
th@zoon.cc
79c99df916e7fbed2f50cbbf9cedc2380dc55b02
a565193016f9b08ff3131420bd8e4571827fa969
/b4-hack/fb/core/RelocArray.h
4f8213460531ae686fbba7e604b1ae0027c2906d
[]
no_license
APPLlCATLON/bf4-booster
f257fd11af7fbf6ac19eac7b7b46e531f9d5bd8f
ddcfad778ecd4b01f3cd2ca40ea6c9aaf63922e4
refs/heads/master
2020-05-29T10:10:24.455441
2013-12-07T16:11:27
2013-12-07T16:11:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
459
h
#ifndef __RELOCARRAY_H__ #define __RELOCARRAY_H__ #include "../../fb2_classes.h" #include "../../fb2_offsets.h" #include <Windows.h> namespace fb { template< class T > class RelocArray { public: unsigned int size() { return m_count; } T at( int idx ) { return *( T* )( ( DWORD )m_data + ( idx * sizeof( T ) ) ); } T operator [] ( int idx ) { return at( idx ); } private: unsigned int m_count; T* m_data; }; }; #endif
[ "karl@skomski.com" ]
karl@skomski.com
b4054b86edb917dff88bb1e08663ea78b8b0bb66
5dc4ea36514927efd678638e2095a4e8e32c0386
/NPSVisor/tools/svLabelMaker/source/svmRule.cpp
5e5452adf90dcc5c2620d4e9faf0cbce0e46e60d
[ "Unlicense" ]
permissive
NPaolini/NPS_OpenSource
732173afe958f9549af13bc39b15de79e5d6470c
0c7da066b02b57ce282a1903a3901a563d04a28f
refs/heads/main
2023-03-15T09:34:19.674662
2021-03-13T13:22:00
2021-03-13T13:22:00
342,852,203
0
0
null
null
null
null
UTF-8
C++
false
false
6,771
cpp
//------------------ svmRule.cpp ---------------------------- //----------------------------------------------------------- #include "precHeader.h" //----------------------------------------------------------- #include "svmRule.h" #include "common.h" //----------------------------------------------------------- //----------------------------------------------------------- void mdcCustom::clear() { if(mdc) { SetBkMode(mdc, oldMode); SetBkColor(mdc, oldBkg); SetTextColor(mdc, oldColor); SetTextAlign(mdc, oldAlign); SelectObject(mdc, oldPen); SelectObject(mdc, oldBmp); SetGraphicsMode(mdc, GM_COMPATIBLE); DeleteDC(mdc); DeleteObject(hBmpTmp); DeleteObject(bkg); mdc = 0; } } //----------------------------------------------------------- HDC mdcCustom::getMdc(PWin* owner, HDC hdc) { PRect r; GetClientRect(*owner, r); if(!mdc && r.Width()) { mdc = CreateCompatibleDC(hdc); SetGraphicsMode(mdc, GM_ADVANCED); hBmpTmp = CreateCompatibleBitmap(hdc, r.Width(), r.Height()); oldBmp = SelectObject(mdc, hBmpTmp); oldPen = SelectObject(mdc, pen); oldAlign = SetTextAlign(mdc, TA_BOTTOM | TA_CENTER); oldColor = SetTextColor(mdc, RGB(0, 0, 220)); oldBkg = SetBkColor(mdc, cBkg); oldMode = SetBkMode(mdc, OPAQUE); bkg = CreateSolidBrush(cBkg); } if(mdc) FillRect(mdc, r, bkg); return mdc; } //----------------------------------------------------------- bool PRule::create() { if(!baseClass::create()) return false; return true; } //----------------------------------------------------------- void PRule::setStartLg(long start) { if(start != Start) { Start = start; InvalidateRect(*this, 0, 0); } } //----------------------------------------------------------- void PRule::setStartPx(long start) { HDC hdc = GetDC(*this); SetMapMode(hdc, MM_LOMETRIC); POINT pt = { start, 0 }; DPtoLP(hdc, &pt, 1); SetMapMode(hdc, MM_TEXT); ReleaseDC(*this, hdc); setStartLg(pt.x); } //----------------------------------------------------------- void PRule::setZoom(svmManZoom::zoomX zoom, bool force) { if(Zoom != zoom || force) { Zoom = zoom; InvalidateRect(*this, 0, 0); } } //----------------------------------------------------------- LRESULT PRule::windowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_ERASEBKGND: return 1; case WM_SIZE: Mdc.clear(); break; case WM_PAINT: do { PAINTSTRUCT Paint; HDC hdc = BeginPaint(hwnd, &Paint); if(!hdc) { EndPaint(*this, &Paint); return 0; } HDC mdc = Mdc.getMdc(this, hdc); if(mdc) { SetMapMode(mdc, MM_LOMETRIC); XFORM xForm; FLOAT z = 1; svmManZoom mZ; mZ.setCurrZoom(Zoom); xForm.eM11 = 1; xForm.eM22 = 1; if(isHorz) { mZ.calcToScreenH(z); xForm.eM11 = z; } else { mZ.calcToScreenV(z); xForm.eM22 = z; } xForm.eM12 = (FLOAT) 0.0; xForm.eM21 = (FLOAT) 0.0; xForm.eDx = (FLOAT) 0.0; xForm.eDy = (FLOAT) 0.0; SetWorldTransform(mdc, &xForm); evPaint(mdc); xForm.eM11 = (FLOAT) 1.0; xForm.eM22 = (FLOAT) 1.0; SetWorldTransform(mdc, &xForm); SetMapMode(mdc, MM_TEXT); PRect rect2(Paint.rcPaint); BitBlt(hdc, rect2.left, rect2.top, rect2.Width(), rect2.Height(), mdc, rect2.left, rect2.top, SRCCOPY); } EndPaint(hwnd, &Paint); } while(false); return 0; } return baseClass::windowProc(hwnd, message, wParam, lParam); } //----------------------------------------------------------- void PRule::getWindowClass(WNDCLASS& wcl) { baseClass::getWindowClass(wcl); wcl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); } //----------------------------------------------------------- //----------------------------------------------------------- #define DEF_STEP 100 #define VERT_ANGLE 2700 //----------------------------------------------------------- #define ADD_POINT(buff, v) \ wsprintf(buff, _T("%d.%02d"), (v) / 100, (v) % 100) //----------------------------------------------------------- void PRuleX::evPaint(HDC hdc) { PRect r; GetClientRect(*this, r); DPtoLP(hdc, (LPPOINT)(LPRECT)r, 2); int h = r.Height(); LONG step = DEF_STEP; LONG start = Start % DEF_STEP; int start2 = Start - start; int end = r.Width() + start; for(int i = -start; i < end; i += step) { MoveToEx(hdc, i, 0, 0); LineTo(hdc, i, h); } h /= 2; for(int i = step / 2 - start; i < end; i += step) { MoveToEx(hdc, i, 0, 0); LineTo(hdc, i, h); } TCHAR buff[64]; HFONT fnt = D_FONT_ORIENT(h, 0, 0, 0, _T("arial")); HGDIOBJ oldF = SelectObject(hdc, fnt); h *= 2; if(Zoom > svmManZoom::zOne) { for(int i = -start; i < end; i += step, start2 += DEF_STEP) { ADD_POINT(buff, start2); ExtTextOut(hdc, i, h, 0 , 0, buff, _tcslen(buff), 0); } } else { step *= 2; int i = -start; if(!((start2 / DEF_STEP) & 1)) { start2 += DEF_STEP; i += step / 2; } for(; i < end; i += step, start2 += DEF_STEP * 2) { ADD_POINT(buff, start2); ExtTextOut(hdc, i, h, 0 , 0, buff, _tcslen(buff), 0); } } DeleteObject(SelectObject(hdc, oldF)); } //----------------------------------------------------------- void PRuleY::evPaint(HDC hdc) { PRect r; GetClientRect(*this, r); DPtoLP(hdc, (LPPOINT)(LPRECT)r, 2); int w = r.Width(); LONG step = DEF_STEP; LONG start = Start % DEF_STEP; int start2 = Start - start; int end = r.Height() - start; for(int i = start; i > end; i -= step) { MoveToEx(hdc, 0, i, 0); LineTo(hdc, w, i); } w /= 2; for(int i = start + step / 2; i > end; i -= step) { MoveToEx(hdc, 0, i, 0); LineTo(hdc, w, i); } TCHAR buff[64]; HFONT fnt = D_FONT_ORIENT(w, 0, VERT_ANGLE, 0, _T("arial")); HGDIOBJ oldF = SelectObject(hdc, fnt); w *= 2; if(Zoom > svmManZoom::zOne) { for(int i = start; i > end; i -= step, start2 += DEF_STEP) { ADD_POINT(buff, start2); ExtTextOut(hdc, r.Width(), i, 0 , 0, buff, _tcslen(buff), 0); } } else { step *= 2; int i = start; if(!((start2 / DEF_STEP) & 1)) { start2 += DEF_STEP; i -= step / 2; } for(; i > end; i -= step, start2 += DEF_STEP * 2) { ADD_POINT(buff, start2); ExtTextOut(hdc, r.Width(), i, 0 , 0, buff, _tcslen(buff), 0); } } DeleteObject(SelectObject(hdc, oldF)); } //-----------------------------------------------------------
[ "npaolini@ennepisoft.it" ]
npaolini@ennepisoft.it
13ab318356caf6c24c6fdc6d56d14530c345abc7
9b6763581388237af03d9bbf378955901a77a1dc
/Graduate_CLIMBGUYS/cpp&h/steelblock.h
e5f40d01a7370da718483cf6d9ffd4f4242fa3f6
[]
no_license
Nishin3614/ClimbBuys
e2623ecfef3cbe8f5b00b6963da8c823291b0a79
09c967dc36b59d32be44174e34a74daf02c1e48b
refs/heads/master
2023-02-25T06:46:07.896211
2021-01-29T00:19:08
2021-01-29T00:19:08
303,862,684
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
5,590
h
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // // 鋼鉄ブロック処理 [steelblock.h] // Author : KOKI NISHIYAMA // // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #ifndef _STEELBLOCK_H_ #define _STEELBLOCK_H_ // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // インクルードファイル // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #include "baseblock.h" // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // 前方宣言 // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // 構造体 // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // クラス // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- class CSteelblock : public CBaseblock { public: /* 列挙型 */ /* 構造体 */ /* 関数 */ // コンストラクタ CSteelblock(); // デストラクタ virtual ~CSteelblock(); // 初期化処理 virtual void Init(void); // 更新処理 virtual void Uninit(void); // 更新処理 virtual void Update(void); // 描画処理 virtual void Draw(void); // 当たった後の処理 // nObjType : 相手オブジェクトタイプ // pScene : 相手のシーン情報 virtual void Scene_MyCollision( int const &nObjType = 0, // オブジェクトタイプ CScene * pScene = NULL // 相手のシーン情報 ); // 相手に当てられた後の処理 // nObjType : 相手オブジェクトタイプ // pScene : 相手のシーン情報 virtual void Scene_OpponentCollision( int const &nObjType = 0, // オブジェクトタイプ CScene * pScene = NULL // 相手のシーン情報 ); // 自分から当たらなかった後の処理 // nObjType : 相手オブジェクトタイプ // pScene : 相手のシーン情報 virtual void Scene_NoMyCollision( int const &nObjType = 0, // オブジェクトタイプ CScene * pScene = NULL // 相手のシーン情報 ) {}; // 相手に当てられなかった後の処理 // nObjType : 相手オブジェクトタイプ // pScene : 相手のシーン情報 virtual void Scene_NoOpponentCollision( int const &nObjType = 0, // オブジェクトタイプ CScene * pScene = NULL // 相手のシーン情報 ) {}; // 当たった後の判定 // Obj : オブジェタイプ // pScene : シーン情報 void HitCollision( COLLISIONDIRECTION const &Direct, // 前後左右上下 CScene::OBJ const & Obj, // オブジェタイプ CScene * pScene = NULL // シーン情報 ); // 鋼鉄ブロック全ソースの読み込み static HRESULT Load(void); // 鋼鉄ブロック全ソースの開放 static void UnLoad(void); // 作成(シーン管理) // pos : 位置 // nModelId : モデル番号 // pCol : 色情報 // layer : レイヤー static CSteelblock * Create( int const & nModelId, // モデル番号 GRID const & Grid, // 行列高さ番号 D3DXCOLOR * pCol, // 色情報 float const & fGravity, // 重力 CScene::LAYER const & layer = CScene::LAYER_3DBLOCK // レイヤー ); // 作成(個人管理) // pos : 位置 // nModelId : モデル番号 // pCol : 色情報 static CSteelblock * Create_Self( int const & nModelId, // モデル番号 GRID const & Grid, // 行列高さ番号 D3DXCOLOR * pCol // 色情報 ); // unique_ptr作成(個人管理unique) // ※戻り値はstd::moveで受け取る // pos : 位置 // nModelId : モデル番号 // pCol : 色情報 static std::unique_ptr<CSteelblock> Creat_Unique( int const & nModelId, // モデル番号 GRID const & Grid, // 行列高さ番号 D3DXCOLOR * pCol // 色情報 ); #ifdef _DEBUG // デバッグ処理 virtual void Debug(void); #endif // _DEBUG protected: /* 関数 */ // 設定 // private: /* 関数 */ /* 変数 */ }; #endif
[ "nishin369714@gmail.com" ]
nishin369714@gmail.com
e209e6f7af7092e7c67ad07e88f8093a8c0308cc
8a100a50efe9df71962b2552bd9b75300958b1fe
/Transmitters/Old Version/X_CTRL_STM32F10x/ElsCtrl_v1.6/USER/GUI/Page_Calibration.cpp
553af4cc00139ecd9089934b3256414374fcef93
[ "MIT" ]
permissive
yu1741588584/X-CTRL
156d608a02a9953de3a92e1d0a0abc62ece74350
9d93a49688fd8526253c9c9119479d04fab8371b
refs/heads/master
2022-12-27T22:29:31.691813
2022-04-30T03:49:20
2022-04-30T03:49:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,604
cpp
#include "FileGroup.h" #include "GUI_Private.h" #include "DigitalFilter.h" static MillisTaskManager mtm_Calibration(3); static FilterAverage<int> dfJSL_Y_ADC(13); void Task_JoystickCab() { int16_t ADC_LY = dfJSL_Y_ADC.getNext(JSL_Y_ADC); if(ADC_LY > JS_L.Ymax)JS_L.Ymax = ADC_LY; if(ADC_LY < JS_L.Ymin)JS_L.Ymin = ADC_LY; } void Task_ShowJoystickStatus() { screen.setCursor(StatusBarPos + 5, 14); screen.printf("Max:%4d",JS_L.Ymax); screen.setCursor(StatusBarPos + 5, 22); screen.printf("Min:%4d",JS_L.Ymin); } static void Setup() { screen.setCursor(StatusBarPos + 5, 5); screen.print("Calibrating..."); BuzzTone(1000, 200); uint32_t LY_sum = 0.0; uint32_t cnt = 0; for(cnt = 0; cnt < 1000; cnt++) { LY_sum += dfJSL_Y_ADC.getNext(JSL_Y_ADC); delay(1); } JS_L.Ymid = LY_sum / (cnt + 1); JS_L.Ymax = ADC_MaxValue / 2 + 200, JS_L.Ymin = ADC_MaxValue / 2 - 200; mtm_Calibration.TaskRegister(0, Task_JoystickCab, 10); mtm_Calibration.TaskRegister(1, Task_ShowJoystickStatus, 50); } static void Loop() { mtm_Calibration.Running(millis()); } static void Exit() { EEPROM_Handle(EEPROM_Chs::SaveData); ClearPage(); BuzzTone(500, 200); } static void ButtonLongPressEvent() { page.PageChangeTo(PAGE_CtrlInfo); } void PageRegister_Calibration(uint8_t ThisPage) { page.PageRegister_Basic(ThisPage, Setup, Loop, Exit); // page.PageRegister_Event(ThisPage, EVENT_ButtonPress, ButtonPressEvent); page.PageRegister_Event(ThisPage, EVENT_ButtonLongPress, ButtonLongPressEvent); }
[ "1290176185@qq.com" ]
1290176185@qq.com
43099c1f91000fd5a9dcc175b86bfb1dd5640a14
0014fb5ce4aa3a6f460128bb646a3c3cfe81eb9e
/testdata/8/2/src/node6.cpp
0cb52d2026c4a56e3862b81582d8116e08f5bd37
[]
no_license
yps158/randomGraph
c1fa9c531b11bb935d112d1c9e510b5c02921df2
68f9e2e5b0bed1f04095642ee6924a68c0768f0c
refs/heads/master
2021-09-05T05:32:45.210171
2018-01-24T11:23:06
2018-01-24T11:23:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,002
cpp
#include "ros/ros.h" #include "std_msgs/String.h" #include "unistd.h" #include <sstream> #include <random> std::random_device rd; std::mt19937 gen(rd()); std::normal_distribution<> d(0.029935, 0.005); class Node6{ public: Node6(){ sub_0_6_flag = 0; sub_0_6 = n.subscribe("topic_0_6", 1, &Node6::middlemanCallback0,this); pub_6_7 = n.advertise<std_msgs::String>("topic_6_7", 1); } void middlemanCallback0(const std_msgs::String::ConstPtr& msg){ if( true){ usleep(d(gen)*1000000); ROS_INFO("I'm node6 last from node0, intercepted: [%s]", msg->data.c_str()); pub_6_7.publish(msg); } else{ ROS_INFO("I'm node6, from node0 intercepted: [%s]", msg->data.c_str()); sub_0_6_flag = 1; } } private: ros::NodeHandle n; ros::Publisher pub_6_7; int sub_0_6_flag; ros::Subscriber sub_0_6; }; int main(int argc, char **argv){ ros::init(argc, argv, "node6"); Node6 node6; ros::spin(); return 0; }
[ "sasaki@thinkingreed.co.jp" ]
sasaki@thinkingreed.co.jp
acdfb00002eb165983feeea630761ea5ac283697
9638a88e0e59707e741c413b6ede69dfa8e95f63
/main34_fehlerfrei/ConnectFour.h
19759fb510eff85bbb2be53263a86c13766dfd37
[]
no_license
Fibs2000/Table_stabil_2015
f641a922fb70d27196e3827a2f0029c97f4b1d44
3c1b42f458a5041e9541fae1a9800485d9615d63
refs/heads/master
2021-01-10T17:19:12.017704
2015-11-10T15:46:03
2015-11-10T15:46:03
45,922,170
0
0
null
null
null
null
UTF-8
C++
false
false
469
h
#ifndef ConnectFour_h #define ConnectFour_h #include "Game.h" class ConnectFour : public Game{ public: ConnectFour(NESController *controller, Adafruit_WS2801 *strip, RGBmatrixPanel *matrix); ~ConnectFour(); void newGame(); void run(); void resume(); private: void updateDisplay(); void redrawBoard(); int dropPos; byte curPlayer; byte winner; Point winPos[4]; long winTime; int dropHeight; byte droppedPieces[7][6]; const static int xOffset; }; #endif
[ "michel.fibs@gmail.com" ]
michel.fibs@gmail.com
a517a1aa3a15310a16c4f5b1f18272027c0565a2
bc4f297919596f3af1b0af9b8c0433c4a0e7ca74
/D_Alice_Bob_and_Candies.cpp
57f5bea601e394022dbe5339d512cc2391e29d2d
[]
no_license
fahadkhaanz/Competitive-Programming
34d92ec73c0b4aba5a2a18c68f998a92a57dc57e
bc3d4206d6749055d67e7b291acd230a31a4e5bc
refs/heads/master
2023-08-02T05:26:03.594439
2021-09-26T08:44:15
2021-09-26T08:44:15
291,102,479
0
0
null
null
null
null
UTF-8
C++
false
false
2,964
cpp
//git pull --rebase origin master #include<bits/stdc++.h> using namespace std; #define gc getchar_unlocked #define fo(i,n) for(int i=0;i<n;i++) #define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1) #define ll long long #define si(x) scanf("%d",&x) #define sl(x) scanf("%lld",&x) #define ss(s) scanf("%s",s) #define pi(x) printf("%d\n",x) #define pl(x) printf("%lld\n",x) #define ps(s) printf("%s\n",s) #define deb(x) cout << #x << "=" << x << endl #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl #define pb push_back #define mp make_pair #define F first #define S second #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof(x)) #define sortall(x) sort(all(x)) #define tr(it, a) for(auto it = a.begin(); it != a.end(); it++) #define PI 3.1415926535897932384626 #define wi(t) int t;cin>>t;while(t--) typedef pair<int, int> pii; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpii; typedef vector<pl> vpl; typedef vector<vi> vvi; typedef vector<vl> vvl; mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count()); int rng(int lim) { uniform_int_distribution<int> uid(0,lim-1); return uid(rang); } int mpow(int base, int exp); void ipgraph(int n, int m); void dfs(int u, int par); const int mod = 1000000007; const int N = 3e5, M = N; //======================= vi g[N]; int a[N]; ll int gcd(ll int a, ll int b) { if (b == 0) return a; return gcd(b, a % b); } int tc=1; void solve() { ll int n; cin>>n; vl ar(n); fo(i,n) cin>>ar[i]; ll int al=0,bob=0,mo=0,all=0,bo=0; int i=0,j=n-1; while(i<=j) { al=0; int c=0; while(al<=bob) { if(i>j) break; al=al+ar[i++]; if(c==0) mo++; c++; } all+=al; c=0; bob=0; while(bob<=al) { if(i>j) break; bob+=ar[j--]; if(c==0) mo++; c++; } bo+=bob; } cout<<mo<<" "<<all<<" "<<bo<<"\n"; } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); srand(chrono::high_resolution_clock::now().time_since_epoch().count()); wi(t) { solve(); } return 0; } int mpow(int base, int exp) { base %= mod; int result = 1; while (exp > 0) { if (exp & 1) result = ((ll)result * base) % mod; base = ((ll)base * base) % mod; exp >>= 1; } return result; } void ipgraph(int n, int m){ int i, u, v; while(m--){ cin>>u>>v; u--, v--; g[u].pb(v); g[v].pb(u); } } void dfs(int u, int par){ for(int v:g[u]){ if (v == par) continue; dfs(v, u); } }
[ "fk0881889@gmail.com" ]
fk0881889@gmail.com
23dced3024fe2c5634abc346c57f1482d74f014d
f746c798d1bef7d665c07b1923bf35d03ad408d4
/lib/poppler/qt4/src/poppler-qt4.h
1b5afb2ef63dbe08b6f6703b8ef792803bb51c1b
[ "GPL-1.0-or-later", "GPL-2.0-only", "GPL-3.0-only", "LGPL-2.0-or-later", "MIT" ]
permissive
istex/popplonode
cd51a2c582759869bc025558f3f06d864506e8c3
1637685667757df6e54077fa93b60d5d1f7fbc8a
refs/heads/master
2023-01-08T00:12:20.923850
2019-11-04T10:41:10
2019-11-04T10:41:10
101,175,171
4
1
MIT
2022-12-30T17:48:06
2017-08-23T12:00:08
C++
UTF-8
C++
false
false
53,311
h
/* poppler-qt.h: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2007, Brad Hards <bradh@frogmouth.net> * Copyright (C) 2005-2012, 2014, 2015, Albert Astals Cid <aacid@kde.org> * Copyright (C) 2005, Stefan Kebekus <stefan.kebekus@math.uni-koeln.de> * Copyright (C) 2006-2011, Pino Toscano <pino@kde.org> * Copyright (C) 2009 Shawn Rutledge <shawn.t.rutledge@gmail.com> * Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> * Copyright (C) 2010 Matthias Fauconneau <matthias.fauconneau@gmail.com> * Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> * Copyright (C) 2011 Glad Deschrijver <glad.deschrijver@gmail.com> * Copyright (C) 2012, Guillermo A. Amaral B. <gamaral@kde.org> * Copyright (C) 2012, Fabio D'Urso <fabiodurso@hotmail.it> * Copyright (C) 2012, Tobias Koenig <tobias.koenig@kdab.com> * Copyright (C) 2012, 2014, 2015 Adam Reichold <adamreichold@myopera.com> * Copyright (C) 2012, 2013 Thomas Freitag <Thomas.Freitag@alfa.de> * Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __POPPLER_QT_H__ #define __POPPLER_QT_H__ #include "poppler-annotation.h" #include "poppler-link.h" #include "poppler-optcontent.h" #include "poppler-page-transition.h" #include <QtCore/QByteArray> #include <QtCore/QDateTime> #include <QtCore/QSet> #include <QtXml/QDomDocument> #include "poppler-export.h" class EmbFile; class Sound; class AnnotMovie; /** The %Poppler Qt4 binding. */ namespace Poppler { class Document; class DocumentData; class PageData; class FormField; class TextBoxData; class PDFConverter; class PSConverter; /** Debug/error function. This function type is used for debugging & error output; the first parameter is the actual message, the second is the unaltered closure argument which was passed to the setDebugErrorFunction call. \since 0.16 */ typedef void (*PopplerDebugFunc)(const QString & /*message*/, const QVariant & /*closure*/); /** Set a new debug/error output function. If not set, by default error and debug messages will be sent to the Qt \p qDebug() function. \param debugFunction the new debug function \param closure user data which will be passes as-is to the debug function \since 0.16 */ POPPLER_QT4_EXPORT void setDebugErrorFunction(PopplerDebugFunc debugFunction, const QVariant &closure); /** Describes the physical location of text on a document page This very simple class describes the physical location of text on the page. It consists of - a QString that contains the text - a QRectF that gives a box that describes where on the page the text is found. */ class POPPLER_QT4_EXPORT TextBox { friend class Page; public: /** The default constructor sets the \p text and the rectangle that contains the text. Coordinates for the \p bBox are in points = 1/72 of an inch. */ TextBox(const QString& text, const QRectF &bBox); /** Destructor. */ ~TextBox(); /** Returns the text of this text box */ QString text() const; /** Returns the position of the text, in point, i.e., 1/72 of an inch \since 0.8 */ QRectF boundingBox() const; /** Returns the pointer to the next text box, if there is one. Otherwise, it returns a null pointer. */ TextBox *nextWord() const; /** Returns the bounding box of the \p i -th characted of the word. */ QRectF charBoundingBox(int i) const; /** Returns whether there is a space character after this text box */ bool hasSpaceAfter() const; private: Q_DISABLE_COPY(TextBox) TextBoxData *m_data; }; class FontInfoData; /** Container class for information about a font within a PDF document */ class POPPLER_QT4_EXPORT FontInfo { friend class Document; public: /** The type of font. */ enum Type { unknown, Type1, Type1C, Type1COT, Type3, TrueType, TrueTypeOT, CIDType0, CIDType0C, CIDType0COT, CIDTrueType, CIDTrueTypeOT }; /// \cond PRIVATE /** Create a new font information container. */ FontInfo(); /** Create a new font information container. */ FontInfo( const FontInfoData &fid ); /// \endcond /** Copy constructor. */ FontInfo( const FontInfo &fi ); /** Destructor. */ ~FontInfo(); /** The name of the font. Can be QString::null if the font has no name */ QString name() const; /** The path of the font file used to represent this font on this system, or a null string is the font is embedded */ QString file() const; /** Whether the font is embedded in the file, or not \return true if the font is embedded */ bool isEmbedded() const; /** Whether the font provided is only a subset of the full font or not. This only has meaning if the font is embedded. \return true if the font is only a subset */ bool isSubset() const; /** The type of font encoding \return a enumerated value corresponding to the font encoding used \sa typeName for a string equivalent */ Type type() const; /** The name of the font encoding used \note if you are looking for the name of the font (as opposed to the encoding format used), you probably want name(). \sa type for a enumeration version */ QString typeName() const; /** Standard assignment operator */ FontInfo& operator=( const FontInfo &fi ); private: FontInfoData *m_data; }; class FontIteratorData; /** Iterator for reading the fonts in a document. FontIterator provides a Java-style iterator for reading the fonts in a document. You can use it in the following way: \code Poppler::FontIterator* it = doc->newFontIterator(); while (it->hasNext()) { QList<Poppler::FontInfo> fonts = it->next(); // do something with the fonts } // after doing the job, the iterator must be freed delete it; \endcode \since 0.12 */ class POPPLER_QT4_EXPORT FontIterator { friend class Document; friend class DocumentData; public: /** Destructor. */ ~FontIterator(); /** Returns the fonts of the current page and then advances the iterator to the next page. */ QList<FontInfo> next(); /** Checks whether there is at least one more page to iterate, ie returns false when the iterator is beyond the last page. */ bool hasNext() const; /** Returns the current page where the iterator is. */ int currentPage() const; private: Q_DISABLE_COPY( FontIterator ) FontIterator( int, DocumentData *dd ); FontIteratorData *d; }; class EmbeddedFileData; /** Container class for an embedded file with a PDF document */ class POPPLER_QT4_EXPORT EmbeddedFile { friend class DocumentData; friend class AnnotationPrivate; public: /// \cond PRIVATE EmbeddedFile(EmbFile *embfile); /// \endcond /** Destructor. */ ~EmbeddedFile(); /** The name associated with the file */ QString name() const; /** The description associated with the file, if any. This will return an empty QString if there is no description element */ QString description() const; /** The size of the file. This will return < 0 if there is no size element */ int size() const; /** The modification date for the embedded file, if known. */ QDateTime modDate() const; /** The creation date for the embedded file, if known. */ QDateTime createDate() const; /** The MD5 checksum of the file. This will return an empty QByteArray if there is no checksum element. */ QByteArray checksum() const; /** The MIME type of the file, if known. \since 0.8 */ QString mimeType() const; /** The data as a byte array */ QByteArray data(); /** Is the embedded file valid? \since 0.12 */ bool isValid() const; /** A QDataStream for the actual data? */ //QDataStream dataStream() const; private: Q_DISABLE_COPY(EmbeddedFile) EmbeddedFile(EmbeddedFileData &dd); EmbeddedFileData *m_embeddedFile; }; /** \brief A page in a document. The Page class represents a single page within a PDF document. You cannot construct a Page directly, but you have to use the Document functions that return a new Page out of an index or a label. */ class POPPLER_QT4_EXPORT Page { friend class Document; public: /** Destructor. */ ~Page(); /** The type of rotation to apply for an operation */ enum Rotation { Rotate0 = 0, ///< Do not rotate Rotate90 = 1, ///< Rotate 90 degrees clockwise Rotate180 = 2, ///< Rotate 180 degrees Rotate270 = 3 ///< Rotate 270 degrees clockwise (90 degrees counterclockwise) }; /** The kinds of page actions */ enum PageAction { Opening, ///< The action when a page is "opened" Closing ///< The action when a page is "closed" }; /** How the text is going to be returned \since 0.16 */ enum TextLayout { PhysicalLayout, ///< The text is layouted to resemble the real page layout RawOrderLayout ///< The text is returned without any type of processing }; /** Additional flags for the renderToPainter method \since 0.16 */ enum PainterFlag { /** Do not save/restore the caller-owned painter. renderToPainter() by default preserves, using save() + restore(), the state of the painter specified; if this is not needed, this flag can avoid this job */ DontSaveAndRestore = 0x00000001 }; Q_DECLARE_FLAGS( PainterFlags, PainterFlag ) /** Render the page to a QImage using the current \link Document::renderBackend() Document renderer\endlink. If \p x = \p y = \p w = \p h = -1, the method will automatically compute the size of the image from the horizontal and vertical resolutions specified in \p xres and \p yres. Otherwise, the method renders only a part of the page, specified by the parameters (\p x, \p y, \p w, \p h) in pixel coordinates. The returned QImage then has size (\p w, \p h), independent of the page size. \param x specifies the left x-coordinate of the box, in pixels. \param y specifies the top y-coordinate of the box, in pixels. \param w specifies the width of the box, in pixels. \param h specifies the height of the box, in pixels. \param xres horizontal resolution of the graphics device, in dots per inch \param yres vertical resolution of the graphics device, in dots per inch \param rotate how to rotate the page \warning The parameter (\p x, \p y, \p w, \p h) are not well-tested. Unusual or meaningless parameters may lead to rather unexpected results. \returns a QImage of the page, or a null image on failure. \since 0.6 */ QImage renderToImage(double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1, Rotation rotate = Rotate0) const; /** Render the page to the specified QPainter using the current \link Document::renderBackend() Document renderer\endlink. If \p x = \p y = \p w = \p h = -1, the method will automatically compute the size of the page area from the horizontal and vertical resolutions specified in \p xres and \p yres. Otherwise, the method renders only a part of the page, specified by the parameters (\p x, \p y, \p w, \p h) in pixel coordinates. \param painter the painter to paint on \param x specifies the left x-coordinate of the box, in pixels. \param y specifies the top y-coordinate of the box, in pixels. \param w specifies the width of the box, in pixels. \param h specifies the height of the box, in pixels. \param xres horizontal resolution of the graphics device, in dots per inch \param yres vertical resolution of the graphics device, in dots per inch \param rotate how to rotate the page \param flags additional painter flags \warning The parameter (\p x, \p y, \p w, \p h) are not well-tested. Unusual or meaningless parameters may lead to rather unexpected results. \returns whether the painting succeeded \note This method is only supported for Arthur \since 0.16 */ bool renderToPainter(QPainter* painter, double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1, Rotation rotate = Rotate0, PainterFlags flags = 0) const; /** Get the page thumbnail if it exists. \return a QImage of the thumbnail, or a null image if the PDF does not contain one for this page \since 0.12 */ QImage thumbnail() const; /** Returns the text that is inside a specified rectangle \param rect the rectangle specifying the area of interest, with coordinates given in points, i.e., 1/72th of an inch. If rect is null, all text on the page is given \since 0.16 **/ QString text(const QRectF &rect, TextLayout textLayout) const; /** Returns the text that is inside a specified rectangle. The text is returned using the physical layout of the page \param rect the rectangle specifying the area of interest, with coordinates given in points, i.e., 1/72th of an inch. If rect is null, all text on the page is given **/ QString text(const QRectF &rect) const; /** The starting point for a search */ enum SearchDirection { FromTop, ///< Start sorting at the top of the document NextResult, ///< Find the next result, moving "down the page" PreviousResult ///< Find the previous result, moving "up the page" }; /** The type of search to perform */ enum SearchMode { CaseSensitive, ///< Case differences cause no match in searching CaseInsensitive ///< Case differences are ignored in matching }; /** Flags to modify the search behaviour \since 0.31 */ enum SearchFlag { IgnoreCase = 0x00000001, ///< Case differences are ignored WholeWords = 0x00000002 ///< Only whole words are matched }; Q_DECLARE_FLAGS( SearchFlags, SearchFlag ) /** Returns true if the specified text was found. \param text the text the search \param rect in all directions is used to return where the text was found, for NextResult and PreviousResult indicates where to continue searching for \param direction in which direction do the search \param caseSensitive be case sensitive? \param rotate the rotation to apply for the search order **/ Q_DECL_DEPRECATED bool search(const QString &text, QRectF &rect, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const; /** Returns true if the specified text was found. \param text the text the search \param rectXXX in all directions is used to return where the text was found, for NextResult and PreviousResult indicates where to continue searching for \param direction in which direction do the search \param caseSensitive be case sensitive? \param rotate the rotation to apply for the search order \since 0.14 **/ Q_DECL_DEPRECATED bool search(const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const; /** Returns true if the specified text was found. \param text the text the search \param rectXXX in all directions is used to return where the text was found, for NextResult and PreviousResult indicates where to continue searching for \param direction in which direction do the search \param flags the flags to consider during matching \param rotate the rotation to apply for the search order \since 0.31 **/ bool search(const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchFlags flags = 0, Rotation rotate = Rotate0) const; /** Returns a list of all occurrences of the specified text on the page. \param text the text to search \param caseSensitive whether to be case sensitive \param rotate the rotation to apply for the search order \warning Do not use the returned QRectF as arguments of another search call because of truncation issues if qreal is defined as float. \since 0.22 **/ Q_DECL_DEPRECATED QList<QRectF> search(const QString &text, SearchMode caseSensitive, Rotation rotate = Rotate0) const; /** Returns a list of all occurrences of the specified text on the page. \param text the text to search \param flags the flags to consider during matching \param rotate the rotation to apply for the search order \warning Do not use the returned QRectF as arguments of another search call because of truncation issues if qreal is defined as float. \since 0.31 **/ QList<QRectF> search(const QString &text, SearchFlags flags = 0, Rotation rotate = Rotate0) const; /** Returns a list of text of the page This method returns a QList of TextBoxes that contain all the text of the page, with roughly one text word of text per TextBox item. For text written in western languages (left-to-right and up-to-down), the QList contains the text in the proper order. \note The caller owns the text boxes and they should be deleted when no longer required. \warning This method is not tested with Asian scripts */ QList<TextBox*> textList(Rotation rotate = Rotate0) const; /** \return The dimensions (cropbox) of the page, in points (i.e. 1/72th of an inch) */ QSizeF pageSizeF() const; /** \return The dimensions (cropbox) of the page, in points (i.e. 1/72th of an inch) */ QSize pageSize() const; /** Returns the transition of this page \returns a pointer to a PageTransition structure that defines how transition to this page shall be performed. \note The PageTransition structure is owned by this page, and will automatically be destroyed when this page class is destroyed. **/ PageTransition *transition() const; /** Gets the page action specified, or NULL if there is no action. \since 0.6 **/ Link *action( PageAction act ) const; /** Types of orientations that are possible */ enum Orientation { Landscape, ///< Landscape orientation (portrait, with 90 degrees clockwise rotation ) Portrait, ///< Normal portrait orientation Seascape, ///< Seascape orientation (portrait, with 270 degrees clockwise rotation) UpsideDown ///< Upside down orientation (portrait, with 180 degrees rotation) }; /** The orientation of the page */ Orientation orientation() const; /** The default CTM */ void defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown); /** Gets the links of the page */ QList<Link*> links() const; /** Returns the annotations of the page \note If you call this method twice, you get different objects pointing to the same annotations (see Annotation). The caller owns the returned objects and they should be deleted when no longer required. */ QList<Annotation*> annotations() const; /** Returns the annotations of the page \param subtypes the subtypes of annotations you are interested in \note If you call this method twice, you get different objects pointing to the same annotations (see Annotation). The caller owns the returned objects and they should be deleted when no longer required. \since 0.28 */ QList<Annotation*> annotations(const QSet<Annotation::SubType> &subtypes) const; /** Adds an annotation to the page \note Ownership of the annotation object stays with the caller, who can delete it at any time. \since 0.20 */ void addAnnotation( const Annotation *ann ); /** Removes an annotation from the page and destroys the annotation object \note There mustn't be other Annotation objects pointing this annotation \since 0.20 */ void removeAnnotation( const Annotation *ann ); /** Returns the form fields on the page The caller gets the ownership of the returned objects. \since 0.6 */ QList<FormField*> formFields() const; /** Returns the page duration. That is the time, in seconds, that the page should be displayed before the presentation automatically advances to the next page. Returns < 0 if duration is not set. \since 0.6 */ double duration() const; /** Returns the label of the page, or a null string is the page has no label. \since 0.6 **/ QString label() const; private: Q_DISABLE_COPY(Page) Page(DocumentData *doc, int index); PageData *m_page; }; /** \brief PDF document. The Document class represents a PDF document: its pages, and all the global properties, metadata, etc. \section ownership Ownership of the returned objects All the functions that returns class pointers create new object, and the responsability of those is given to the callee. The only exception is \link Poppler::Page::transition() Page::transition()\endlink. \section document-loading Loading To get a Document, you have to load it via the load() & loadFromData() functions. In all the functions that have passwords as arguments, they \b must be Latin1 encoded. If you have a password that is a UTF-8 string, you need to use QString::toLatin1() (or similar) to convert the password first. If you have a UTF-8 character array, consider converting it to a QString first (QString::fromUtf8(), or similar) before converting to Latin1 encoding. \section document-rendering Rendering To render pages of a document, you have different Document functions to set various options. \subsection document-rendering-backend Backends %Poppler offers a different backends for rendering the pages. Currently there are two backends (see #RenderBackend), but only the Splash engine works well and has been tested. The available rendering backends can be discovered via availableRenderBackends(). The current rendering backend can be changed using setRenderBackend(). Please note that setting a backend not listed in the available ones will always result in null QImage's. \section document-cms Color management support %Poppler, if compiled with this support, provides functions to handle color profiles. To know whether the %Poppler version you are using has support for color management, you can query Poppler::isCmsAvailable(). In case it is not avilable, all the color management-related functions will either do nothing or return null. */ class POPPLER_QT4_EXPORT Document { friend class Page; friend class DocumentData; public: /** The page mode */ enum PageMode { UseNone, ///< No mode - neither document outline nor thumbnail images are visible UseOutlines, ///< Document outline visible UseThumbs, ///< Thumbnail images visible FullScreen, ///< Fullscreen mode (no menubar, windows controls etc) UseOC, ///< Optional content group panel visible UseAttach ///< Attachments panel visible }; /** The page layout */ enum PageLayout { NoLayout, ///< Layout not specified SinglePage, ///< Display a single page OneColumn, ///< Display a single column of pages TwoColumnLeft, ///< Display the pages in two columns, with odd-numbered pages on the left TwoColumnRight, ///< Display the pages in two columns, with odd-numbered pages on the right TwoPageLeft, ///< Display the pages two at a time, with odd-numbered pages on the left TwoPageRight ///< Display the pages two at a time, with odd-numbered pages on the right }; /** The render backends available \since 0.6 */ enum RenderBackend { SplashBackend, ///< Splash backend ArthurBackend ///< Arthur (Qt4) backend }; /** The render hints available \since 0.6 */ enum RenderHint { Antialiasing = 0x00000001, ///< Antialiasing for graphics TextAntialiasing = 0x00000002, ///< Antialiasing for text TextHinting = 0x00000004, ///< Hinting for text \since 0.12.1 TextSlightHinting = 0x00000008, ///< Lighter hinting for text when combined with TextHinting \since 0.18 OverprintPreview = 0x00000010, ///< Overprint preview \since 0.22 ThinLineSolid = 0x00000020, ///< Enhance thin lines solid \since 0.24 ThinLineShape = 0x00000040, ///< Enhance thin lines shape. Wins over ThinLineSolid \since 0.24 IgnorePaperColor = 0x00000080 ///< Do not compose with the paper color \since 0.35 }; Q_DECLARE_FLAGS( RenderHints, RenderHint ) /** Form types \since 0.22 */ enum FormType { NoForm, ///< Document doesn't contain forms AcroForm, ///< AcroForm XfaForm ///< Adobe XML Forms Architecture (XFA), currently unsupported }; /** Set a color display profile for the current document. \param outputProfileA is a \c cmsHPROFILE of the LCMS library. \since 0.12 */ void setColorDisplayProfile(void *outputProfileA); /** Set a color display profile for the current document. \param name is the name of the display profile to set. \since 0.12 */ void setColorDisplayProfileName(const QString &name); /** Return the current RGB profile. \return a \c cmsHPROFILE of the LCMS library. \since 0.12 */ void* colorRgbProfile() const; /** Return the current display profile. \return a \c cmsHPROFILE of the LCMS library. \since 0.12 */ void *colorDisplayProfile() const; /** Load the document from a file on disk \param filePath the name (and path, if required) of the file to load \param ownerPassword the Latin1-encoded owner password to use in loading the file \param userPassword the Latin1-encoded user ("open") password to use in loading the file \return the loaded document, or NULL on error \note The caller owns the pointer to Document, and this should be deleted when no longer required. \warning The returning document may be locked if a password is required to open the file, and one is not provided (as the userPassword). */ static Document *load(const QString & filePath, const QByteArray &ownerPassword=QByteArray(), const QByteArray &userPassword=QByteArray()); /** Load the document from memory \param fileContents the file contents. They are copied so there is no need to keep the byte array around for the full life time of the document. \param ownerPassword the Latin1-encoded owner password to use in loading the file \param userPassword the Latin1-encoded user ("open") password to use in loading the file \return the loaded document, or NULL on error \note The caller owns the pointer to Document, and this should be deleted when no longer required. \warning The returning document may be locked if a password is required to open the file, and one is not provided (as the userPassword). \since 0.6 */ static Document *loadFromData(const QByteArray &fileContents, const QByteArray &ownerPassword=QByteArray(), const QByteArray &userPassword=QByteArray()); /** Get a specified Page Note that this follows the PDF standard of being zero based - if you want the first page, then you need an index of zero. The caller gets the ownership of the returned object. \param index the page number index */ Page *page(int index) const; /** \overload The intent is that you can pass in a label like \c "ix" and get the page with that label (which might be in the table of contents), or pass in \c "1" and get the page that the user expects (which might not be the first page, if there is a title page and a table of contents). \param label the page label */ Page *page(const QString &label) const; /** The number of pages in the document */ int numPages() const; /** The type of mode that should be used by the application when the document is opened. Note that while this is called page mode, it is really viewer application mode. */ PageMode pageMode() const; /** The layout that pages should be shown in when the document is first opened. This basically describes how pages are shown relative to each other. */ PageLayout pageLayout() const; /** The predominant reading order for text as supplied by the document's viewer preferences. \since 0.26 */ Qt::LayoutDirection textDirection() const; /** Provide the passwords required to unlock the document \param ownerPassword the Latin1-encoded owner password to use in loading the file \param userPassword the Latin1-encoded user ("open") password to use in loading the file */ bool unlock(const QByteArray &ownerPassword, const QByteArray &userPassword); /** Determine if the document is locked */ bool isLocked() const; /** The date associated with the document You would use this method with something like: \code QDateTime created = m_doc->date("CreationDate"); QDateTime modified = m_doc->date("ModDate"); \endcode The available dates are: - CreationDate: the date of creation of the document - ModDate: the date of the last change in the document \param data the type of date that is required */ QDateTime date( const QString & data ) const; /** Set the Info dict date entry specified by \param key to \param val \returns true on success, false on failure */ bool setDate( const QString & key, const QDateTime & val ); /** The date of the creation of the document */ QDateTime creationDate() const; /** Set the creation date of the document to \param val \returns true on success, false on failure */ bool setCreationDate( const QDateTime & val ); /** The date of the last change in the document */ QDateTime modificationDate() const; /** Set the modification date of the document to \param val \returns true on success, false on failure */ bool setModificationDate( const QDateTime & val ); /** Get specified information associated with the document You would use this method with something like: \code QString title = m_doc->info("Title"); QString subject = m_doc->info("Subject"); \endcode In addition to \c Title and \c Subject, other information that may be available include \c Author, \c Keywords, \c Creator and \c Producer. \param data the information that is required \sa infoKeys() to get a list of the available keys */ QString info( const QString & data ) const; /** Set the value of the document's Info dictionary entry specified by \param key to \param val \returns true on success, false on failure */ bool setInfo( const QString & key, const QString & val ); /** The title of the document */ QString title() const; /** Set the title of the document to \param val \returns true on success, false on failure */ bool setTitle( const QString & val ); /** The author of the document */ QString author() const; /** Set the author of the document to \param val \returns true on success, false on failure */ bool setAuthor( const QString & val ); /** The subject of the document */ QString subject() const; /** Set the subject of the document to \param val \returns true on success, false on failure */ bool setSubject( const QString & val ); /** The keywords of the document */ QString keywords() const; /** Set the keywords of the document to \param val \returns true on success, false on failure */ bool setKeywords( const QString & val ); /** The creator of the document */ QString creator() const; /** Set the creator of the document to \param val \returns true on success, false on failure */ bool setCreator( const QString & val ); /** The producer of the document */ QString producer() const; /** Set the producer of the document to \param val \returns true on success, false on failure */ bool setProducer( const QString & val ); /** Remove the document's Info dictionary \returns true on success, false on failure */ bool removeInfo(); /** Obtain a list of the available string information keys. */ QStringList infoKeys() const; /** Test if the document is encrypted */ bool isEncrypted() const; /** Test if the document is linearised In some cases, this is called "fast web view", since it is mostly an optimisation for viewing over the Web. */ bool isLinearized() const; /** Test if the permissions on the document allow it to be printed */ bool okToPrint() const; /** Test if the permissions on the document allow it to be printed at high resolution */ bool okToPrintHighRes() const; /** Test if the permissions on the document allow it to be changed. \note depending on the type of change, it may be more appropriate to check other properties as well. */ bool okToChange() const; /** Test if the permissions on the document allow the contents to be copied / extracted */ bool okToCopy() const; /** Test if the permissions on the document allow annotations to be added or modified, and interactive form fields (including signature fields) to be completed. */ bool okToAddNotes() const; /** Test if the permissions on the document allow interactive form fields (including signature fields) to be completed. \note this can be true even if okToAddNotes() is false - this means that only form completion is permitted. */ bool okToFillForm() const; /** Test if the permissions on the document allow interactive form fields (including signature fields) to be set, created and modified */ bool okToCreateFormFields() const; /** Test if the permissions on the document allow content extraction (text and perhaps other content) for accessibility usage (eg for a screen reader) */ bool okToExtractForAccessibility() const; /** Test if the permissions on the document allow it to be "assembled" - insertion, rotation and deletion of pages; or creation of bookmarks and thumbnail images. \note this can be true even if okToChange() is false */ bool okToAssemble() const; /** The version of the PDF specification that the document conforms to \deprecated use getPdfVersion and avoid float point comparisons/handling */ Q_DECL_DEPRECATED double pdfVersion() const; /** The version of the PDF specification that the document conforms to \param major an optional pointer to a variable where store the "major" number of the version \param minor an optional pointer to a variable where store the "minor" number of the version \since 0.12 */ void getPdfVersion(int *major, int *minor) const; /** The fonts within the PDF document. This is a shorthand for getting all the fonts at once. \note this can take a very long time to run with a large document. You may wish to use a FontIterator if you have more than say 20 pages \see newFontIterator() */ QList<FontInfo> fonts() const; /** Scans for fonts within the PDF document. \param numPages the number of pages to scan \param fontList pointer to the list where the font information should be placed \note with this method you can scan for fonts only \em once for each document; once the end is reached, no more scanning with this method can be done \return false if the end of the document has been reached \deprecated this function is quite limited in its job (see note), better use fonts() or newFontIterator() \see fonts(), newFontIterator() */ Q_DECL_DEPRECATED bool scanForFonts( int numPages, QList<FontInfo> *fontList ) const; /** Creates a new FontIterator object for font scanning. The new iterator can be used for reading the font information of the document, reading page by page. The caller is responsible for the returned object, ie it should freed it when no more useful. \param startPage the initial page from which start reading fonts \see fonts() \since 0.12 */ FontIterator* newFontIterator( int startPage = 0 ) const; /** The font data if the font is an embedded one. \since 0.10 */ QByteArray fontData(const FontInfo &font) const; /** The documents embedded within the PDF document. \note there are two types of embedded document - this call only accesses documents that are embedded at the document level. */ QList<EmbeddedFile*> embeddedFiles() const; /** Whether there are any documents embedded in this PDF document. */ bool hasEmbeddedFiles() const; /** Gets the table of contents (TOC) of the Document. The caller is responsable for the returned object. In the tree the tag name is the 'screen' name of the entry. A tag can have attributes. Here follows the list of tag attributes with meaning: - Destination: A string description of the referred destination - DestinationName: A 'named reference' to the viewport - ExternalFileName: A link to a external filename - Open: A bool value that tells whether the subbranch of the item is open or not Resolving the final destination for each item can be done in the following way: - first, checking for 'Destination': if not empty, then a LinkDestination can be constructed straight with it - as second step, if the 'DestinationName' is not empty, then the destination can be resolved using linkDestination() Note also that if 'ExternalFileName' is not emtpy, then the destination refers to that document (and not to the current one). \returns the TOC, or NULL if the Document does not have one */ QDomDocument *toc() const; /** Tries to resolve the named destination \p name. \note this operation starts a search through the whole document \returns a new LinkDestination object if the named destination was actually found, or NULL otherwise */ LinkDestination *linkDestination( const QString &name ); /** Sets the paper color \param color the new paper color */ void setPaperColor(const QColor &color); /** The paper color The default color is white. */ QColor paperColor() const; /** Sets the backend used to render the pages. \param backend the new rendering backend \since 0.6 */ void setRenderBackend( RenderBackend backend ); /** The currently set render backend The default backend is \ref SplashBackend \since 0.6 */ RenderBackend renderBackend() const; /** The available rendering backends. \since 0.6 */ static QSet<RenderBackend> availableRenderBackends(); /** Sets the render \p hint . \note some hints may not be supported by some rendering backends. \param on whether the flag should be added or removed. \since 0.6 */ void setRenderHint( RenderHint hint, bool on = true ); /** The currently set render hints. \since 0.6 */ RenderHints renderHints() const; /** Gets a new PS converter for this document. The caller gets the ownership of the returned converter. \since 0.6 */ PSConverter *psConverter() const; /** Gets a new PDF converter for this document. The caller gets the ownership of the returned converter. \since 0.8 */ PDFConverter *pdfConverter() const; /** Gets the metadata stream contents \since 0.6 */ QString metadata() const; /** Test whether this document has "optional content". Optional content is used to optionally turn on (display) and turn off (not display) some elements of the document. The most common use of this is for layers in design applications, but it can be used for a range of things, such as not including some content in printing, and displaying content in the appropriate language. \since 0.8 */ bool hasOptionalContent() const; /** Itemviews model for optional content. The model is owned by the document. \since 0.8 */ OptContentModel *optionalContentModel(); /** Document-level JavaScript scripts. Returns the list of document level JavaScript scripts to be always executed before any other script. \since 0.10 */ QStringList scripts() const; /** The PDF identifiers. \param permanentId an optional pointer to a variable where store the permanent ID of the document \param updateId an optional pointer to a variable where store the update ID of the document \return whether the document has the IDs \since 0.16 */ bool getPdfId(QByteArray *permanentId, QByteArray *updateId) const; /** Returns the type of forms contained in the document \since 0.22 */ FormType formType() const; /** Destructor. */ ~Document(); private: Q_DISABLE_COPY(Document) DocumentData *m_doc; Document(DocumentData *dataA); }; class BaseConverterPrivate; class PSConverterPrivate; class PDFConverterPrivate; /** \brief Base converter. This is the base class for the converters. \since 0.8 */ class POPPLER_QT4_EXPORT BaseConverter { friend class Document; public: /** Destructor. */ virtual ~BaseConverter(); /** Sets the output file name. You must set this or the output device. */ void setOutputFileName(const QString &outputFileName); /** * Sets the output device. You must set this or the output file name. * * \since 0.8 */ void setOutputDevice(QIODevice *device); /** Does the conversion. \return whether the conversion succeeded */ virtual bool convert() = 0; enum Error { NoError, FileLockedError, OpenOutputError, NotSupportedInputFileError }; /** Returns the last error \since 0.12.1 */ Error lastError() const; protected: /// \cond PRIVATE BaseConverter(BaseConverterPrivate &dd); Q_DECLARE_PRIVATE(BaseConverter) BaseConverterPrivate *d_ptr; /// \endcond private: Q_DISABLE_COPY(BaseConverter) }; /** Converts a PDF to PS Sizes have to be in Points (1/72 inch) If you are using QPrinter you can get paper size by doing: \code QPrinter dummy(QPrinter::PrinterResolution); dummy.setFullPage(true); dummy.setPageSize(myPageSize); width = dummy.width(); height = dummy.height(); \endcode \since 0.6 */ class POPPLER_QT4_EXPORT PSConverter : public BaseConverter { friend class Document; public: /** Options for the PS export. \since 0.10 */ enum PSOption { Printing = 0x00000001, ///< The PS is generated for printing purposes StrictMargins = 0x00000002, ForceRasterization = 0x00000004, PrintToEPS = 0x00000008, ///< Output EPS instead of PS \since 0.20 HideAnnotations = 0x00000010 ///< Don't print annotations \since 0.20 }; Q_DECLARE_FLAGS( PSOptions, PSOption ) /** Destructor. */ ~PSConverter(); /** Sets the list of pages to print. Mandatory. */ void setPageList(const QList<int> &pageList); /** Sets the title of the PS Document. Optional */ void setTitle(const QString &title); /** Sets the horizontal DPI. Defaults to 72.0 */ void setHDPI(double hDPI); /** Sets the vertical DPI. Defaults to 72.0 */ void setVDPI(double vDPI); /** Sets the rotate. Defaults to not rotated */ void setRotate(int rotate); /** Sets the output paper width. Has to be set. */ void setPaperWidth(int paperWidth); /** Sets the output paper height. Has to be set. */ void setPaperHeight(int paperHeight); /** Sets the output right margin. Defaults to 0 */ void setRightMargin(int marginRight); /** Sets the output bottom margin. Defaults to 0 */ void setBottomMargin(int marginBottom); /** Sets the output left margin. Defaults to 0 */ void setLeftMargin(int marginLeft); /** Sets the output top margin. Defaults to 0 */ void setTopMargin(int marginTop); /** Defines if margins have to be strictly followed (even if that means changing aspect ratio), or if the margins can be adapted to keep aspect ratio. Defaults to false. */ void setStrictMargins(bool strictMargins); /** Defines if the page will be rasterized to an image before printing. Defaults to false */ void setForceRasterize(bool forceRasterize); /** Sets the options for the PS export. \since 0.10 */ void setPSOptions(PSOptions options); /** The currently set options for the PS export. The default flags are: Printing. \since 0.10 */ PSOptions psOptions() const; /** Sets a function that will be called each time a page is converted. The payload belongs to the caller. \since 0.16 */ void setPageConvertedCallback(void (* callback)(int page, void *payload), void *payload); bool convert(); private: Q_DECLARE_PRIVATE(PSConverter) Q_DISABLE_COPY(PSConverter) PSConverter(DocumentData *document); }; /** Converts a PDF to PDF (thus saves a copy of the document). \since 0.8 */ class POPPLER_QT4_EXPORT PDFConverter : public BaseConverter { friend class Document; public: /** Options for the PDF export. */ enum PDFOption { WithChanges = 0x00000001 ///< The changes done to the document are saved as well }; Q_DECLARE_FLAGS( PDFOptions, PDFOption ) /** Destructor. */ virtual ~PDFConverter(); /** Sets the options for the PDF export. */ void setPDFOptions(PDFOptions options); /** The currently set options for the PDF export. */ PDFOptions pdfOptions() const; bool convert(); private: Q_DECLARE_PRIVATE(PDFConverter) Q_DISABLE_COPY(PDFConverter) PDFConverter(DocumentData *document); }; /** Conversion from PDF date string format to QDateTime */ POPPLER_QT4_EXPORT QDateTime convertDate( char *dateString ); /** Whether the color management functions are available. \since 0.12 */ POPPLER_QT4_EXPORT bool isCmsAvailable(); /** Whether the overprint preview functionality is available. \since 0.22 */ POPPLER_QT4_EXPORT bool isOverprintPreviewAvailable(); class SoundData; /** Container class for a sound file in a PDF document. A sound can be either External (in that case should be loaded the file whose url is represented by url() ), or Embedded, and the player has to play the data contained in data(). \since 0.6 */ class POPPLER_QT4_EXPORT SoundObject { public: /** The type of sound */ enum SoundType { External, ///< The real sound file is external Embedded ///< The sound is contained in the data }; /** The encoding format used for the sound */ enum SoundEncoding { Raw, ///< Raw encoding, with unspecified or unsigned values in the range [ 0, 2^B - 1 ] Signed, ///< Twos-complement values muLaw, ///< mu-law-encoded samples ALaw ///< A-law-encoded samples }; /// \cond PRIVATE SoundObject(Sound *popplersound); /// \endcond ~SoundObject(); /** Is the sound embedded (SoundObject::Embedded) or external (SoundObject::External)? */ SoundType soundType() const; /** The URL of the sound file to be played, in case of SoundObject::External */ QString url() const; /** The data of the sound, in case of SoundObject::Embedded */ QByteArray data() const; /** The sampling rate of the sound */ double samplingRate() const; /** The number of sound channels to use to play the sound */ int channels() const; /** The number of bits per sample value per channel */ int bitsPerSample() const; /** The encoding used for the sound */ SoundEncoding soundEncoding() const; private: Q_DISABLE_COPY(SoundObject) SoundData *m_soundData; }; class MovieData; /** Container class for a movie object in a PDF document. \since 0.10 */ class POPPLER_QT4_EXPORT MovieObject { friend class AnnotationPrivate; public: /** The play mode for playing the movie */ enum PlayMode { PlayOnce, ///< Play the movie once, closing the movie controls at the end PlayOpen, ///< Like PlayOnce, but leaving the controls open PlayRepeat, ///< Play continuously until stopped PlayPalindrome ///< Play forward, then backward, then again foward and so on until stopped }; ~MovieObject(); /** The URL of the movie to be played */ QString url() const; /** The size of the movie */ QSize size() const; /** The rotation (either 0, 90, 180, or 270 degrees clockwise) for the movie, */ int rotation() const; /** Whether show a bar with movie controls */ bool showControls() const; /** How to play the movie */ PlayMode playMode() const; /** Returns whether a poster image should be shown if the movie is not playing. \since 0.22 */ bool showPosterImage() const; /** Returns the poster image that should be shown if the movie is not playing. If the image is null but showImagePoster() returns @c true, the first frame of the movie should be used as poster image. \since 0.22 */ QImage posterImage() const; private: /// \cond PRIVATE MovieObject( AnnotMovie *ann ); /// \endcond Q_DISABLE_COPY(MovieObject) MovieData *m_movieData; }; } Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::PainterFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::SearchFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Document::RenderHints) Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PDFConverter::PDFOptions) Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PSConverter::PSOptions) #endif
[ "remy.meja@inist.fr" ]
remy.meja@inist.fr
9fb5bae0cf5ad74501e6d0e01598e2c2df3d3f3e
fec81bfe0453c5646e00c5d69874a71c579a103d
/blazetest/src/mathtest/operations/dmatdmatsub/H3x3aH3x3a.cpp
808f88efad273b5656af23ae078c1f11660ba3f1
[ "BSD-3-Clause" ]
permissive
parsa/blaze
801b0f619a53f8c07454b80d0a665ac0a3cf561d
6ce2d5d8951e9b367aad87cc55ac835b054b5964
refs/heads/master
2022-09-19T15:46:44.108364
2022-07-30T04:47:03
2022-07-30T04:47:03
105,918,096
52
7
null
null
null
null
UTF-8
C++
false
false
3,712
cpp
//================================================================================================= /*! // \file src/mathtest/operations/dmatdmatsub/H3x3aH3x3a.cpp // \brief Source file for the H3x3aH3x3a dense matrix/dense matrix subtraction math test // // Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. 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. // 3. Neither the names of the Blaze development group 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 HOLDER 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. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/HermitianMatrix.h> #include <blaze/math/StaticMatrix.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/operations/dmatdmatsub/OperationTest.h> #include <blazetest/system/MathTest.h> #ifdef BLAZE_USE_HPX_THREADS # include <hpx/hpx_main.hpp> #endif //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'H3x3aH3x3a'..." << std::endl; using blazetest::mathtest::ScalarA; try { // Matrix type definitions using H3x3a = blaze::HermitianMatrix< blaze::StaticMatrix<ScalarA,3UL,3UL> >; // Creator type definitions using CH3x3a = blazetest::Creator<H3x3a>; // Running the tests RUN_DMATDMATSUB_OPERATION_TEST( CH3x3a(), CH3x3a() ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during dense matrix/dense matrix subtraction:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
[ "klaus.iglberger@gmail.com" ]
klaus.iglberger@gmail.com
c9a4d5f6adbec5514fb4b6eda62be58baef32bf5
91971732033d69414cb6acdcf471c2862483679c
/testsuites/posix-torture/src/main.cpp
3fd676b4e98ef704f4dd1c96ef941cbc7faba55b
[ "MIT" ]
permissive
managarm/managarm
d94e5bab607e36df458213984876fafc4575b184
f274d8d531f7f083284c0681ac065db1e467256f
refs/heads/master
2023-09-04T08:07:06.523632
2023-08-29T22:26:04
2023-08-29T22:26:04
63,081,862
1,261
87
MIT
2023-08-29T22:26:06
2016-07-11T15:57:53
C++
UTF-8
C++
false
false
576
cpp
#include <iostream> #include <vector> #include "testsuite.hpp" std::vector<abstract_test_case *> &test_case_ptrs() { static std::vector<abstract_test_case *> singleton; return singleton; } void abstract_test_case::register_case(abstract_test_case *tcp) { test_case_ptrs().push_back(tcp); } int main() { for(int s = 10; s < 24; s++) { int n = 1 << s; for(abstract_test_case *tcp : test_case_ptrs()) { std::cout << "posix-torture: Running " << tcp->name() << " for " << n << " iterations" << std::endl; for(int i = 0; i < n; i++) tcp->run(); } } }
[ "alexander.vandergrinten@gmail.com" ]
alexander.vandergrinten@gmail.com
ca588cda8d0a10ac6126b003cd39120cc9ddb0ff
32c0040dbb00970af34bf437c96d66d58e201ee0
/Include/TheEngine/filesystem/file.h
34b066d7e797efd6c835bfb6e53d7288f8b16e92
[]
no_license
Exh/synqera_engine
da456860c59d82fa0ef451a8332a9216516618bc
31a39f952fe47d15de0819e007b287a38ae966fd
refs/heads/master
2021-04-06T20:08:34.495983
2016-02-16T13:14:52
2016-02-16T13:14:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
487
h
#ifndef _THE_FILE_ #define _THE_FILE_ #include "TheEngine/common.h" enum ChunkType { SURFACE = 0, VERTEX, BONES, BONE_ANIMATION_HEADER, BONE_ANIMATION_CURVE }; struct ChunkHeader { ChunkType type; int32_t offset; int32_t size; int32_t dummyData[4]; }; class TheFile { std::vector<ChunkHeader> headers; public: TheFile(the::filesystem::stream &stream); ~TheFile(){} std::vector<ChunkHeader> getHeaders(ChunkType type); ChunkHeader getHeader(ChunkType type); }; #endif
[ "kirill.shabordin@dev.zodiac.tv" ]
kirill.shabordin@dev.zodiac.tv
2ca8e56518f1acabeeeb2895b339c1090d3d98bf
4f052287d727d37a56559517267c51555025a7f2
/mortage_calculation/main.cpp
82c3ce1494d30052cd235c7e262ca1013b4dfea2
[]
no_license
davidjie1949/linux_os_coding
2c87bce089450151514e24cba13f32db1625b498
8ecda327acbb02967b31e99d28fb8ac96de8f3d7
refs/heads/master
2023-03-04T07:01:05.065943
2021-02-17T05:20:36
2021-02-17T05:20:36
329,320,752
0
0
null
null
null
null
UTF-8
C++
false
false
368
cpp
#include <iostream> #include "mortage.h" using namespace std; int main(){ mortage jieYang(2020, 0.02375, 600000, 0.2); cout << jieYang.getYear() << endl; cout << jieYang.getDownPayment() << endl; cout << jieYang.getInterestRate() << endl; cout << jieYang.loan_amount() << endl; cout << jieYang.total_interest_paid() << endl; return 0; }
[ "jieyng@umich.edu" ]
jieyng@umich.edu
91189d9b9a3ea29b5dcbcaa7aa6e87cf19956524
e4f347154205d12124a07f660f5965cc6abc1fc3
/src/Calque/LayerStack.hpp
71c6439a62bbaf4778ea52c38e78f2299ad8edee
[]
no_license
jonike/FriendPaint
45fb89103b95520e808bc2bf146a52b1338dfbb2
2adb49452c2a6734714cd607ab7161fb521c7b37
refs/heads/master
2021-06-14T18:20:38.346275
2017-01-22T22:01:13
2017-01-22T22:01:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
509
hpp
#ifndef DEF_LAYERSTACK #define DEF_LAYERSTACK #include <iostream> #include <string> #include <vector> #include "Layer.hpp" class LayerStack { public: LayerStack(); void createLayer(sf::Uint32 index, sf::String name); void moveLayer(Uint32 index, Uint32 delta); void renameLayer(sf::Uint32 index, sf::String new_name); void deleteLayer(sf::Uint32 index); void mergeDownLayer(sf::Uint32 index); private: std::vector<Layer*> list; }; #endif
[ "yoanlecoq.io@gmail.com" ]
yoanlecoq.io@gmail.com
6e4579ec93c2c155dc12614181aa8255d1b42612
15e4df20d16cddce804c0c9541da29a4d5e1b252
/2.Firmware/SimpleFOC_version/Ctrl-FOC-Lite-fw/lib/Arduino-FOC/examples/utils/driver_standalone_test/stepper_driver_2pwm_standalone/stepper_driver_2pwm_standalone.ino
6bf7dd7ac9cf989f7890fe3d18226195996404d8
[ "MIT" ]
permissive
asdlei99/Ctrl-FOC-Lite
acaee52046abe4cc6535bac14d8ee15251cf865c
a57dd3b2c3262d97789361c05a2ef86ba6ff8d73
refs/heads/main
2023-08-17T23:49:53.793225
2022-02-05T07:28:08
2022-02-05T07:28:08
447,481,103
0
0
null
2022-01-13T05:56:35
2022-01-13T05:56:35
null
UTF-8
C++
false
false
901
ino
// Stepper driver standalone example #include <SimpleFOC.h> // Stepper driver instance // StepperDriver2PWM(pwm1, in1a, in1b, pwm2, in2a, in2b, (en1, en2 optional)) StepperDriver2PWM driver = StepperDriver2PWM(3, 4, 5, 10, 9, 8, 11, 12); // StepperDriver2PWM(pwm1, dir1, pwm2, dir2,(en1, en2 optional)) // StepperDriver2PWM driver = StepperDriver2PWM(3, 4, 5, 6, 11, 12); void setup() { // pwm frequency to be used [Hz] // for atmega328 fixed to 32kHz // esp32/stm32/teensy configurable driver.pwm_frequency = 30000; // power supply voltage [V] driver.voltage_power_supply = 12; // Max DC voltage allowed - default voltage_power_supply driver.voltage_limit = 12; // driver init driver.init(); // enable driver driver.enable(); _delay(1000); } void loop() { // setting pwm // phase A: 3V // phase B: 6V driver.setPwm(3, 6); }
[ "593245898@qq.com" ]
593245898@qq.com
54cbedb45180544c9fde1e565d673fe841bb5554
2cb681e118e3f1e4b2b141372ae1c6914599b835
/codechef/tweed1.cpp
721d371889e62defd221f1109e959b64d47c9d3b
[]
no_license
jatinarora2702/Competitive-Coding
1ad978a91122c920c839483e46812b5fb70a246e
a77f5d4f1737ca4e408ccf706128ba90ed664286
refs/heads/master
2021-01-11T20:11:34.791960
2020-12-31T00:21:06
2020-12-31T00:21:06
79,060,813
0
0
null
null
null
null
UTF-8
C++
false
false
488
cpp
#include <bits/stdc++.h> #define N 55 using namespace std; int a[N]; char s[20]; int main() { int t, n, i, f, ke, ko, ch, win, waste; scanf("%d", &t); while(t--) { scanf("%d %s", &n, s); ke = ko = 0; for(i = 0 ; i < n ; i++) { scanf("%d", &a[i]); } if(strcmp(s, "Dee") == 0){ f = 0; } else{ f = 1; } if(n == 1 && a[0] % 2 == 0 && f == 0) win = 0; else win = 1; if(win == 0) { printf("Dee\n"); } else { printf("Dum\n"); } } return 0; }
[ "jatinarora2702@gmail.com" ]
jatinarora2702@gmail.com
207052136dda363c306120a189826879894f1097
28f243f705fae7e092288c16e9826c27730564a5
/powietrzesala.h
4406aadbc9f75a1619018e38c3fec3d3c243a6d0
[]
no_license
Jaro966/kinoGitHub4
c792e5d67e8f21259c245fb78ff4befc66f1406c
0822bd1ea3a21fdcd555e4eac078ed50ccea460f
refs/heads/master
2020-04-29T12:43:28.544182
2019-03-24T18:55:39
2019-03-24T18:55:39
176,148,046
0
0
null
null
null
null
UTF-8
C++
false
false
1,620
h
/** * Klasa PowietrzeSala służy do modelowania parametrów powietrza - temperatury i stężenia CO2. * Pobiera trzy wartości typu int i zwraca wartość typu bool. * * \param[in] CO2zadaneSala wartość zadana stężenia CO2 wyrażona w ppm (objętościowo). * \param[in] emisjaCO2osoba wartość emisji CO2 na 1 osobę wyrażona w litrach CO2/(osoba x godz). * \param[in] zyskiCieplaOsoba wartość zysków ciepła generowanych przez 1 osobę wyrażone w Watach. * \return true jeśli da się zbudować trójkąt, false w przeciwnym wypadku */ #ifndef POWIETRZESALA_H #define POWIETRZESALA_H #include "sala.h" #include <QObject> class PowietrzeSala : public QObject { Q_OBJECT public: PowietrzeSala(); ~PowietrzeSala(); double CO2zadaneSala; /**< stężenie CO2 zadane w sali - setpoint CO2 */ double emisjaCO2osoba; /**< emisja CO2 przez 1 osobę - wartość domyślna w konstruktorze*/ double zyskiCieplaOsoba; /**< zyski ciepła od jednej osoby - wartość domyślna w konstruktorze */ double CO2zadaneZewn; /**< zawartość CO2 w powietrzu zewnętrznym - wartość domyślna w konstruktorze */ double tempChwilSali; /**< przechowuje temperaturę chwilową sali */ double tempZadanaSali; /**< przechowuje temperaturę zadaną sali */ double CO2chwilSali; /**< przechowuje stężenie chwilowe sali */ void obliczTempSali(double QprzenP, double QludzP, double QklimP, double VsaliP, double &tSala); void obliczCO2wSali(double Vchw, int &liczbaOsob, double Vkina, double &CO2Sala); signals: void valueChanged(int &newValue); }; #endif // POWIETRZESALA_H
[ "47575561+Jaro966@users.noreply.github.com" ]
47575561+Jaro966@users.noreply.github.com
c96165bfaae976a9e20717003e9c3a6ee06399d4
e346b4507619e21b082226d87937ff4896c0c734
/base/process/process_metrics_posix.cc
3422a730dce691847b886de4f092c1720ede0c2f
[]
no_license
hicdre/libxz
4f190023ac08698b6072984cd0460866bb21206f
82ec093c25fb5e0c6a774c1b55a38b3e41d6623c
refs/heads/master
2021-01-13T02:30:20.111939
2014-04-25T03:01:53
2014-04-25T03:01:53
11,816,688
3
3
null
null
null
null
UTF-8
C++
false
false
559
cc
// Copyright (c) 2013 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/process/process_metrics.h" #include <sys/time.h> namespace base { int64 TimeValToMicroseconds(const struct timeval& tv) { static const int kMicrosecondsPerSecond = 1000000; int64 ret = tv.tv_sec; // Avoid (int * int) integer overflow. ret *= kMicrosecondsPerSecond; ret += tv.tv_usec; return ret; } ProcessMetrics::~ProcessMetrics() { } } // namespace base
[ "iicdre@gmail.com" ]
iicdre@gmail.com
380093cdeaeb14c9713d29b3899bd89c0fe4bd3f
9aa414c4ce84f474cfe76997b2ca1630bd62d8e8
/src/cproton.cc
48f85b8c40ce0918cf93d8178e432c4c400caf2d
[]
no_license
pofallon/node-qpid
0564261d04e533a4dcb58faa3d04e815f49eb150
78984aae238666049d61597f2a3ded157c70c60b
refs/heads/master
2021-03-12T23:58:46.414011
2015-01-25T03:00:40
2015-01-25T03:00:40
7,335,942
22
5
null
2014-11-04T02:38:07
2012-12-27T04:39:12
C
UTF-8
C++
false
false
193
cc
#define BUILDING_NODE_EXTENSION #include <node.h> #include "messenger.h" using namespace v8; void InitAll(Handle<Object> target) { Messenger::Init(target); } NODE_MODULE(cproton, InitAll)
[ "paul@ofallonfamily.com" ]
paul@ofallonfamily.com
4cb7e55cbf76ba4f8a32c3912faa7f851aac0399
a77a50f3f25853ec6a7b5b8548a13b7a4b4b3980
/include/EntitiesManager.h
a636bf77a5c77f8b956613ebc9c4dacc20372c19
[]
no_license
nidoro/PointlessWars
f051b41cb71df783141e5953d2c03d9cf305150a
2e8a9c073026ebb07454922cc3caec41d8c68f29
refs/heads/master
2021-03-27T13:12:04.182891
2016-11-08T15:23:16
2016-11-08T15:23:16
71,281,107
0
0
null
null
null
null
UTF-8
C++
false
false
957
h
#ifndef ENTITIESMANAGER_H #define ENTITIESMANAGER_H #include "Entity.h" #include "Component.h" class EntitiesManager{ public: enum Event{ LIST_UPDATED, GAME_SCREEN_UPDATED }; EntitiesManager(); ~EntitiesManager(); void addEntity(Entity* e); void removeEntity(Entity* e); void addModified(Entity* e); void clearSystem(); bool listen(Event ev); void notify(Event ev); void clearEvents(); void updateList(); bool updated(); void clearActorScript(Entity* e); std::list<Entity*> addedEntities; std::list<Entity*> removedEntities; std::list<Entity*> modifiedEntities; Entity* createEntity(); bool isDead(Entity* e); int getCount(); void clearAll(); private: std::list<Entity*> entities; std::list<Event> events; }; #endif // ENTITIESMANAGER_H
[ "davi_doro@hotmail.com" ]
davi_doro@hotmail.com
6f6a3a9dc2eebfc4f1943e658698b30420bb687a
2ec3c51831ca29cd97fc50a28e2bfd10918ba296
/avr/cores/casper/HardwareSerial0.cpp
c4258d811a06b053d3bebd0c40d02abf5a420a0c
[]
no_license
coduino/coduino_boards
d845767bbf6429c3fbaab578753a3d6fb90f81e5
ca823a87493aef62ca31a433ceb0642cf7b0c3c2
refs/heads/master
2016-08-11T15:51:38.115652
2016-02-18T12:47:22
2016-02-18T12:47:22
52,006,436
0
0
null
null
null
null
UTF-8
C++
false
false
2,608
cpp
/* HardwareSerial0.cpp - Hardware serial library for Wiring Copyright (c) 2006 Nicholas Zambetti. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul Modified 14 August 2012 by Alarus Modified 3 December 2013 by Matthijs Kooijman */ #include "Arduino.h" #include "HardwareSerial.h" #include "HardwareSerial_private.h" // Each HardwareSerial is defined in its own file, sine the linker pulls // in the entire file when any element inside is used. --gc-sections can // additionally cause unused symbols to be dropped, but ISRs have the // "used" attribute so are never dropped and they keep the // HardwareSerial instance in as well. Putting each instance in its own // file prevents the linker from pulling in any unused instances in the // first place. #if defined(HAVE_HWSERIAL0) #if defined(USART_RX_vect) ISR(USART_RX_vect) #elif defined(USART0_RX_vect) ISR(USART0_RX_vect) #elif defined(USART_RXC_vect) ISR(USART_RXC_vect) // ATmega8 #else #error "Don't know what the Data Received vector is called for Serial" #endif { Serial._rx_complete_irq(); } #if defined(UART0_UDRE_vect) ISR(UART0_UDRE_vect) #elif defined(UART_UDRE_vect) ISR(UART_UDRE_vect) #elif defined(USART0_UDRE_vect) ISR(USART0_UDRE_vect) #elif defined(USART_UDRE_vect) ISR(USART_UDRE_vect) #else #error "Don't know what the Data Register Empty vector is called for Serial" #endif { Serial._tx_udr_empty_irq(); } #if defined(UBRRH) && defined(UBRRL) HardwareSerial Serial(&UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR); #else HardwareSerial Serial(&UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0); #endif // Function that can be weakly referenced by serialEventRun to prevent // pulling in this file if it's not otherwise used. uint8_t Serial0_available() { return Serial.available(); } #endif // HAVE_HWSERIAL0
[ "torworx@gmail.com" ]
torworx@gmail.com
34811ed5e6a8a80d025a6274f8c7236e0477e0e0
c8a6040af5a8a5dd8f89bbabde1d00519ef1ea62
/android_webview/browser/aw_feature_list.cc
c37a0351a0410ed368469da1180a27f32c8ebd12
[ "BSD-3-Clause" ]
permissive
imdark/chromium
a02c7f42444bd2f0619cfdeaf2c79a48baf9534f
088d11844c64d6477e49e31036a621a92853cc53
refs/heads/master
2023-01-16T10:34:55.745660
2019-04-02T03:21:05
2019-04-02T03:21:05
161,010,625
0
0
NOASSERTION
2018-12-09T06:15:31
2018-12-09T06:15:30
null
UTF-8
C++
false
false
2,355
cc
// Copyright 2018 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 "android_webview/browser/aw_feature_list.h" #include <string> #include "base/android/jni_string.h" #include "base/feature_list.h" #include "base/macros.h" #include "base/stl_util.h" #include "jni/AwFeatureList_jni.h" using base::android::ConvertJavaStringToUTF8; using base::android::JavaParamRef; namespace android_webview { namespace { // Array of features exposed through the Java ChromeFeatureList API. Entries in // this array may either refer to features defined in the header of this file or // in other locations in the code base (e.g. content/, components/, etc). const base::Feature* kFeaturesExposedToJava[] = { &features::kWebViewConnectionlessSafeBrowsing, &features::kWebViewPageStartedOnCommit, }; const base::Feature* FindFeatureExposedToJava(const std::string& feature_name) { for (size_t i = 0; i < base::size(kFeaturesExposedToJava); ++i) { if (kFeaturesExposedToJava[i]->name == feature_name) return kFeaturesExposedToJava[i]; } NOTREACHED() << "Queried feature cannot be found in AwFeatureList: " << feature_name; return nullptr; } } // namespace namespace features { // Alphabetical: // Use the SafeBrowsingApiHandler which uses the connectionless GMS APIs. This // Feature is checked and used in downstream internal code. const base::Feature kWebViewConnectionlessSafeBrowsing{ "WebViewConnectionlessSafeBrowsing", base::FEATURE_DISABLED_BY_DEFAULT}; // Kill switch for feature to call onPageFinished for browser-initiated // navigations when the navigation commits. const base::Feature kWebViewPageStartedOnCommit{ "WebViewPageStartedOnCommit", base::FEATURE_DISABLED_BY_DEFAULT}; // Whether the application package name is logged in UMA. const base::Feature kWebViewUmaLogAppPackageName{ "WebViewUmaLogAppPackageName", base::FEATURE_DISABLED_BY_DEFAULT}; } // namespace features static jboolean JNI_AwFeatureList_IsEnabled( JNIEnv* env, const JavaParamRef<jstring>& jfeature_name) { const base::Feature* feature = FindFeatureExposedToJava(ConvertJavaStringToUTF8(env, jfeature_name)); return base::FeatureList::IsEnabled(*feature); } } // namespace android_webview
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
dec02c27cb19dc23c547d9b5cb1afc9703382700
46d12703bc79140473a46bb7b063f25029a1b7fa
/LaFarra/Tienda.cpp
cec6064de4ba38d9b0280bf4d2ce81164aa81838
[]
no_license
Estefaniahurtadog12/POO
bcf8785e754e061b0cb07e8db1b4d813902d4b8b
d88e62f19df80b25fdedf53eca70dce4f52ddf46
refs/heads/main
2023-07-25T07:39:37.888812
2021-09-08T22:44:38
2021-09-08T22:44:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,952
cpp
#include <iostream> #include "Tienda.h" // Constructor por defecto Tienda::Tienda() { this->nombre = "La Farra"; this->contCodFactura = 1; TipoProducto licor("Licor", 0.19); TipoProducto snack("Snacks", 0.16); Producto productoUno(licor, "Cerveza", 2500, 1800, 100, 10); Producto productoDos(snack, "Papitas de limon margarita", 3000, 1000, 2, 50); Producto productoTres(snack, "Papitas de pollo margarita", 3000, 1000, 3, 50); // Inicializar valores de la tienda this->inventario[productoUno.getCodigo()] = productoUno; this->inventario[productoDos.getCodigo()] = productoDos; this->inventario[productoTres.getCodigo()] = productoTres; } bool Tienda::existeProductoPorCod(int codigo) { // True si el mapa retorna un iterador diferente al iterador de fin de contenedor, esto significa // que existe. False en caso contrario. if (this->inventario.find(codigo) != this->inventario.end()) { return true; } else { return false; } } void Tienda::agregarProducto() { string nombre; float costo; float precio; int codigo; cout << "Ingrese el nombre del producto : "; getline(cin, nombre); // Mejor instruccion para recibir cadenas do { cout << "Ingrese el costo de compra del producto : "; cin >> costo; cout << "Ingrese el precio al que va a vender el producto : "; cin >> precio; } while (costo < 0 || precio < 0); bool existeProducto = true; // controlara que no existan productos con codigo repetido do { cout << "Ingrese la identificacion del producto : "; cin >> codigo; if (existeProductoPorCod(codigo)) { existeProducto = false; } } while (existeProducto); // Terminada la validacion se agrega el producto Producto productoTemp; productoTemp.setNombre(nombre); productoTemp.setCosto(costo); productoTemp.setPrecio(precio); productoTemp.setCodigo(codigo); // Adición al mapa de productos inventario[codigo] = productoTemp; // Tambien se puede inventario.insert(std::pair<int, Producto>(codigo, productoTemp)); } void Tienda::agregarDetalle(float &totalIVA, float &totalSinIVA, float &totalGeneral, Factura &factura) { int codigo, cantidad; // Se busca el producto en el inventario. //Se pregunta hasta que se encuentre un producto con el codigo ingresado do { cout << "Ingrese el codigoProductoComprar \n"; cin >> codigo; } while (!existeProductoPorCod(codigo)); // while(existeProductoPorCod(codigo) == false); // Se dispone de inventario para la venta Producto productoTemp = this->inventario[codigo]; // Se obtiene del mapa. Existe pq ya se hizo esta validacion do { cout << "Cuantos productos quiere comprar \n"; cin >> cantidad; } while (cantidad <= 0 || cantidad > productoTemp.getCantUnidades()); // Cuando falla // Hago la venta float valorPagarIvaProd = cantidad * productoTemp.getTipoProducto().getIva() * productoTemp.getPrecio(); float valorPagarSinIVAProd = productoTemp.getPrecio() * cantidad; float valorTotalProd = valorPagarIvaProd + valorPagarSinIVAProd; // Agregan los datos al detalle de venta, aprovecho el constructor DetalleFactura detalle(productoTemp, cantidad, valorPagarSinIVAProd, valorPagarIvaProd, valorTotalProd); // Agrega informacion a la factura factura.agregarDetalle(detalle); // Actualizar el acumulado total de la venta totalIVA += valorPagarIvaProd; totalGeneral += valorTotalProd; totalSinIVA += valorPagarSinIVAProd; // Disminuir a la cantidad de unidades vendidas al producto vendido this->inventario[codigo].setCantUnidades(productoTemp.getCantUnidades() - cantidad); } void Tienda::vender() { float totalIVA = 0, totalGeneral = 0; float totalSinIVA = 0; int opc = 0; Factura factura; string fecha; cout << "Ingrese la fecha de venta \n"; cin >> fecha; factura.setFecha(fecha); // Asigno el codigo a la factura y luego actualizo el contador factura.setCod(this->contCodFactura++); do { cout << "Ingrese 1 para continuar la venta -1 para terminar \n"; cin >> opc; if (opc != -1) { // Se llama otra funcion que controla la adicion de productos // paso de parametros por referencia agregarDetalle(totalIVA, totalGeneral, totalSinIVA, factura); } } while (opc != -1); // -1 termina la venta // Se agregan los valores totales factura.setValorPagarSinIVA(totalSinIVA); factura.setValorTotalIVA(totalIVA); factura.setValorTotal(totalGeneral); // Se adiciona la factura a la coleccion para tener la lista de facturas facturas.push_back(factura); } void Tienda::mostrarFacturas() { for (vector<Factura>::iterator pFactura = facturas.begin(); pFactura != facturas.end(); pFactura++) { pFactura->mostrarFactura(); } } void Tienda::mostrarProductos() { for (map<int, Producto>::iterator pProducto = inventario.begin(); pProducto != inventario.end(); pProducto++) { Producto valor = pProducto->second; // Se obtiene el valor asociado al mapa valor.mostrarProducto(); } } string Tienda::getNombre() { return nombre; }
[ "lufe089@gmail.com" ]
lufe089@gmail.com
1e18ea02b94018727ffb28db53673df54e2c7999
c0d3e574b1f50522e0e8bfc8680f7a0817e4d2bc
/headers/Sound.hpp
8bf9edee3f55fb3d8cc65e635d1e9276cdb56fd4
[]
no_license
rgsax/MyAllegro
8ac3f1810cc20220457abcb57d90a384072e747e
64a50f9edac7097016edbf7325cff526d572ea64
refs/heads/master
2021-09-24T09:09:04.784709
2018-10-06T08:23:13
2018-10-06T08:23:13
113,880,223
0
0
null
null
null
null
UTF-8
C++
false
false
661
hpp
#ifndef SOUND_H #define SOUND_H #include <allegro5/allegro_audio.h> #include <allegro5/allegro_acodec.h> /* * Fa parte di un insieme di classi per gestire le primitive fornite * dalla libreria di Allegro. */ enum Mode{ ONCE = 0, LOOP, BIDIR }; class Sound{ public: Sound(const char*, Mode = ONCE); ~Sound(); ALLEGRO_SAMPLE* getContent(); void setVolume(float); float getVolume(); void setSpeed(float); float getSpeed(); void play(); void stop(); protected: ALLEGRO_SAMPLE *sample; ALLEGRO_SAMPLE_ID *id; ALLEGRO_PLAYMODE playmode; float volume; float speed; static bool primaIstanza; static unsigned istanze; }; #endif
[ "riccardog.sax@gmail.com" ]
riccardog.sax@gmail.com
a4a8b5bcff2521ae0c5672516027a24ac2b6d80e
1820c20fe574e95d2e98b5b51784f67119777fa3
/25.11.2017/Tribonacci.cpp
c76086783c3eb5e91f8c102ec0862d553e71ccac
[]
no_license
p4panash/Computer-Science-Problems
6ba1c8cb8224c2dbc984eb0c19da085f0faa8bdf
68e7c3a032ba7a9ed36c955c6fb2eff96e2eb4e2
refs/heads/master
2020-04-05T04:30:11.139949
2019-07-14T18:43:33
2019-07-14T18:43:33
156,554,088
0
0
null
null
null
null
UTF-8
C++
false
false
2,092
cpp
#include <iostream> using namespace std; void Read(int data[], int &lenght) { lenght = 0; int number; cin >> number; while (number != 0) { data[lenght] = number; lenght++; cin >> number; } } bool IsTribonacci(int number) { int a = 0; int b = 1; int c = 1; while (c < number) { int aux = c; c = a + b + c; a = b; b = aux; } if (c == number) return true; return false; } bool SubListIsTribonacci(int data[], int startPos, int endPos) { int a = 1; int b = 1; int c = 2; if (data[startPos] == 1 && data[startPos + 1] == 1) { startPos+=2; } else if (data[startPos] == 1) { startPos++; } else { while (c < data[startPos]) { int aux = c; c = a + b + c; a = b; b = aux; } } for (int i = startPos; i < endPos; i++) { if (c != data[i]) { return false; } else { int aux = c; c = a + b + c; a = b; b = aux; } } return true; } void GetMaximalSubList(int data[], int lenght, int &startPos, int &endPos) { int max = 0; for (int i = 0; i < lenght; i++) { if (IsTribonacci(data[i])) { for (int j = i; j < lenght; j++) { if (SubListIsTribonacci(data, i, j)) { if ((j - i) + 1 > max) { startPos = i; endPos = j; max = (j - i) + 1; } } } } } } void PrintResult(int data[], int startPos, int endPos) { for (int i = startPos; i < endPos; i++) cout << data[i] << " "; cout << endl; } int main() { int const MAX_SIZE = 1005; int data[MAX_SIZE]; int lenght = 0; Read(data, lenght); int startPos = -1, endPos = -1; //cout << SubListIsTribonacci(data, 6, 16); GetMaximalSubList(data, lenght, startPos, endPos); PrintResult(data, startPos, endPos); }
[ "muntean.catalin.avram@gmail.com" ]
muntean.catalin.avram@gmail.com
293e8eb5595f310f1df0a4aa0d1794d0d4a01d0a
fb5e449e5349bfa98ab987f96d179e94fb264dd5
/Fraction/src/ZFraction.cpp
a0e0ac6bb14474d6e23d8cc6bb269b5131c9da94
[]
no_license
th3fr33man/sdz
6bf80286d54a017313af118112e84335b8586afd
3c392d67f02be7bf2a726461386f009272d06487
refs/heads/master
2021-01-13T01:37:11.236105
2015-01-09T13:36:18
2015-01-09T13:36:18
25,178,456
0
0
null
null
null
null
ISO-8859-1
C++
false
false
3,608
cpp
/* * ZFraction.cpp * * Created on: 13 nov. 2014 * Author: rip */ #include <iostream> #include "ZFraction.h" using namespace std; /** * */ ZFraction::ZFraction(int a, int b) : m_num(a) , m_den(b) { // simplification simplification(); } int ZFraction::pgcd(int a, int b) { while (b != 0) { const int t = b; b = a%b; a=t; } return a; } void ZFraction::simplification() { int m_pgcd = pgcd(m_num, m_den); m_num /= m_pgcd; m_den /= m_pgcd; } double ZFraction::calculNombreReel() const { double m_reel = (double)m_num/m_den; return m_reel; } ZFraction& ZFraction::operator +=(const ZFraction& fraction) { // mise au même dénominateur int m_nouveauNumA = m_num * fraction.m_den; int m_nouveauNumB = fraction.m_num * m_den; int m_nouveauDen = m_den * fraction.m_den; m_num = m_nouveauNumA + m_nouveauNumB; m_den = m_nouveauDen; // simplification de la fraction simplification(); return *this; } ZFraction& ZFraction::operator -=(const ZFraction& fraction) { // mise au même dénominateur int m_nouveauNumA = m_num * fraction.m_den; int m_nouveauNumB = fraction.m_num * m_den; int m_nouveauDen = m_den * fraction.m_den; m_num = m_nouveauNumA - m_nouveauNumB; m_den = m_nouveauDen; // simplification de la fraction simplification(); return *this; } ZFraction& ZFraction::operator /=(const ZFraction& fraction) { m_num *= fraction.m_den; m_den *= fraction.m_num; simplification(); return *this; } ZFraction& ZFraction::operator *=(const ZFraction& fraction) { m_num *= fraction.m_num; m_den *= fraction.m_den; simplification(); return *this; } ZFraction& ZFraction::operator %=(const ZFraction& fraction) { } void ZFraction::afficher(std::ostream& out) const { out << m_num << "/" << m_den ; } bool ZFraction::estEgal(const ZFraction& b) const { return m_num/m_den == b.m_num/b.m_den; } bool ZFraction::estPlusPetitQue(const ZFraction& b) const { // on met au même dénominateur int m_nouveauNumA = m_num * b.m_den; int m_nouveauNumB = b.m_num * m_den; return m_nouveauNumA < m_nouveauNumB; } ZFraction::~ZFraction() { // TODO Auto-generated destructor stub } //======Operateurs================================================================ ostream& operator<<(ostream& out, ZFraction const& fraction) { fraction.afficher(out) ; return out; } bool operator ==(const ZFraction& a, const ZFraction& b) { return a.estEgal(b); } bool operator !=(const ZFraction& a, const ZFraction& b) { return !(a == b); } bool operator >(const ZFraction& a, const ZFraction& b) { return b.estPlusPetitQue(a); } bool operator <(const ZFraction& a, const ZFraction& b) { return a.estPlusPetitQue(b); } bool operator >=(const ZFraction& a, const ZFraction& b) { return a > b && a == b; } bool operator <=(const ZFraction& a, const ZFraction& b) { return a < b && a == b; } ZFraction operator +(const ZFraction& a, const ZFraction& b) { ZFraction copie(a); copie +=b; return copie; } ZFraction operator -(const ZFraction& a, const ZFraction& b) { ZFraction copie(a); copie -=b; return copie; } ZFraction operator *(const ZFraction& a, const ZFraction& b) { ZFraction copie(a); copie *=b; return copie; } ZFraction operator /(const ZFraction& a, const ZFraction& b) { ZFraction copie(a); copie /=b; return copie; } ZFraction operator %(const ZFraction& a, const ZFraction& b) { }
[ "raczkaromain@gmail.com" ]
raczkaromain@gmail.com
ffde3fc77d1ff03c44b007316d02054bf7af4574
59abf9cf4595cc3d2663fcb38bacd328ab6618af
/MCD/Render/Sphere.cpp
573d1d78a03432f9ea4f44d404e07a5e03316a5f
[]
no_license
DrDrake/mcore3d
2ce53148ae3b9c07a3d48b15b3f1a0eab7846de6
0bab2c59650a815d6a5b581a2c2551d0659c51c3
refs/heads/master
2021-01-10T17:08:00.014942
2011-03-18T09:16:28
2011-03-18T09:16:28
54,134,775
0
0
null
null
null
null
UTF-8
C++
false
false
2,152
cpp
#include "Pch.h" #include "Sphere.h" #include "MeshBuilder.h" #include "../Core/Math/Vec2.h" #include "../Core/Math/Mat33.h" #include "../Core/Math/BasicFunction.h" using namespace MCD; SphereBuilder::SphereBuilder(float radius, uint16_t segmentCount) { // const float width = radius; // const float height = radius; const uint16_t widthSegmentCount = segmentCount; const uint16_t heightSegmentCount = segmentCount; // Many code are borrowed from PlanMeshBuilder posId = declareAttribute(VertexFormat::get("position"), 1); normalId = declareAttribute(VertexFormat::get("normal"), 1); uvId = declareAttribute(VertexFormat::get("uv0"), 1); const uint16_t vxCount = widthSegmentCount + 1; // Number of vertex along x direction const uint16_t vzCount = heightSegmentCount + 1; // Number of vertex along z direction const uint16_t vertexCount = vxCount * vzCount; // Number of vertex for the whole plane const uint16_t triCount = 2 * widthSegmentCount * heightSegmentCount; MCD_VERIFY(reserveBuffers(vertexCount, triCount * 3)); // Create vertices for(uint16_t x = 0; x < vxCount; ++x) { for(uint16_t z = 0; z < vzCount; ++z) { // Calculate the 2 angles by mapping [0 - segment count] to [0 to 2PI] const float ax = 2 * Mathf::cPi() * float(x) / widthSegmentCount; const float az = 2 * Mathf::cPi() * float(z) / heightSegmentCount; Vec3f normal( cosf(ax) * cosf(az), sinf(az), sinf(ax) * cosf(az) /* Vec3f normal( cosf(ax) * sinf(az), sinf(ax) * sinf(az), cosf(az)*/ ); Vec3f pos = normal * radius; const Vec2f uv(float(x) / (vxCount-1), float(z) / (vzCount-1)); MCD_VERIFY(vertexAttribute(posId, &pos)); MCD_VERIFY(vertexAttribute(normalId, &normal)); MCD_VERIFY(vertexAttribute(uvId, &uv)); addVertex(); } } // Create index for(uint16_t z = 0; z < heightSegmentCount; ++z) { uint16_t indexedVertexCount = (z * vxCount); for(uint16_t x = indexedVertexCount; x < indexedVertexCount + widthSegmentCount; ++x) { MCD_VERIFY(addQuad( x, x + vxCount, x + vxCount + 1, x + 1 )); } } MCD_ASSERT(indexCount() / 3 == triCount); }
[ "mtlung@080b3119-2d51-0410-af92-4d39592ae298" ]
mtlung@080b3119-2d51-0410-af92-4d39592ae298
80fc147cb0e2b8f13d23b8e6f80193c12698df34
757f94f197c14c918f8038b262b45d90ad79c1d3
/src/params.hpp
91356ec2a2a6c397fde36c390d0b459de8d4ee59
[]
no_license
anhuipl2010/YOLOV3_ECO_tracking
5b9e90149d337831493df59cd9770e0a0f2b1176
3bc5b8626a54cd59c0d2922378a2caf9456d48f3
refs/heads/master
2020-06-23T23:50:43.278396
2019-04-01T02:49:39
2019-04-01T02:49:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,232
hpp
#ifndef PARAMS_H #define PARAMS_H #include <vector> #include <string> using std::vector; using std::string; //**** hog parameters cofiguration ***** struct hog_params { int cell_size; int compressed_dim; int nOrients; size_t nDim; float penalty; }; struct cn_params { bool use_cn; int cell_size; int compressed_dim; int nOrients; size_t nDim; float penalty; }; struct hog_feature { hog_params fparams; cv::Size img_input_sz; //*** input sample size ****** cv::Size img_sample_sz; //*** the size of sample ******* cv::Size data_sz_block1; //**** hog feature ***** }; struct cn_feature { cn_params fparams; cv::Size img_input_sz; //*** input sample size ****** cv::Size img_sample_sz; //*** the size of sample ******* cv::Size data_sz_block1; //**** hog feature ***** }; //*** ECO parameters configuration ***** struct eco_params { cn_feature cn_feat; hog_feature hog_feat; //***** img sample parameters ***** float search_area_scale; int min_image_sample_size; int max_image_sample_size; //***** Detection parameters ***** int refinement_iterations; // Number of iterations used to refine the resulting position in a frame int newton_iterations ; // The number of Newton iterations used for optimizing the detection score bool clamp_position; // Clamp the target position to be inside the image bool visualization; //***** Learning parameters float output_sigma_factor; // Label function sigma float learning_rate ; // Learning rate size_t nSamples; // Maximum number of stored training samples string sample_replace_strategy; // Which sample to replace when the memory is full bool lt_size; // The size of the long - term memory(where all samples have equal weight) int train_gap; // The number of intermediate frames with no training(0 corresponds to training every frame) int skip_after_frame; // After which frame number the sparse update scheme should start(1 is directly) bool use_detection_sample; // Use the sample that was extracted at the detection stage also for learning // Regularization window parameters bool use_reg_window; // Use spatial regularization or not double reg_window_min; // The minimum value of the regularization window double reg_window_edge; // The impact of the spatial regularization size_t reg_window_power; // The degree of the polynomial to use(e.g. 2 is a quadratic window) float reg_sparsity_threshold; // A relative threshold of which DFT coefficients that should be set to zero // Interpolation parameters string interpolation_method; // The kind of interpolation kernel float interpolation_bicubic_a; // The parameter for the bicubic interpolation kernel bool interpolation_centering; // Center the kernel at the feature sample bool interpolation_windowing; // Do additional windowing on the Fourier coefficients of the kernel // Scale parameters for the translation model // Only used if: params.use_scale_filter = false size_t number_of_scales ; // Number of scales to run the detector float scale_step; // The scale factor cv::Size init_sz; // Scale filter parameters bool use_scale_filter ; float scale_sigma_factor ; float scale_learning_rate ; int number_of_scales_filter ; int number_of_interp_scales; float scale_model_factor ; float scale_step_filter ; int scale_model_max_area ; string scale_feature ; string s_num_compressed_dim; float lambda ; bool do_poly_interp; //*** Conjugate Gradient parameters int CG_iter ; // The number of Conjugate Gradient iterations in each update after the first frame int init_CG_iter ; // The total number of Conjugate Gradient iterations used in the first frame int init_GN_iter ; // The number of Gauss - Newton iterations used in the first frame(only if the projection matrix is updated) bool CG_use_FR ; // Use the Fletcher - Reeves(true) or Polak - Ribiere(false) formula in the Conjugate Gradient bool CG_standard_alpha; // Use the standard formula for computing the step length in Conjugate Gradient int CG_forgetting_rate ; // Forgetting rate of the last conjugate direction float precond_data_param ; // Weight of the data term in the preconditioner float precond_reg_param ; // Weight of the regularization term in the preconditioner int precond_proj_param; // Weight of the projection matrix part in the preconditioner double projection_reg; // Regularization paremeter of the projection matrix }; #endif
[ "chengxinnn@outlook.com" ]
chengxinnn@outlook.com
9c6be09d156633527a623e6ce9863eac10fcd15c
230fb8845f39bef0f30f5d3541eff5dc0641de14
/Connect3/Export/windows/obj/include/haxe/ui/util/ImageLoader.h
d9e271cab5c41ede19b957213cd55ec2a16cd544
[]
no_license
vhlk/AlgoritmoMinMax
76abd62a6e2859ed229e5831264b6d8af27e318d
40eded4948794ca48d50d16d2133a9ab21207768
refs/heads/main
2023-06-30T15:16:17.492478
2021-08-02T13:29:32
2021-08-02T13:29:32
390,493,745
1
0
null
null
null
null
UTF-8
C++
false
true
2,099
h
// Generated by Haxe 4.2.0 #ifndef INCLUDED_haxe_ui_util_ImageLoader #define INCLUDED_haxe_ui_util_ImageLoader #ifndef HXCPP_H #include <hxcpp.h> #endif HX_DECLARE_CLASS3(haxe,ui,util,ImageLoader) HX_DECLARE_CLASS3(haxe,ui,util,VariantType) namespace haxe{ namespace ui{ namespace util{ class HXCPP_CLASS_ATTRIBUTES ImageLoader_obj : public ::hx::Object { public: typedef ::hx::Object super; typedef ImageLoader_obj OBJ_; ImageLoader_obj(); public: enum { _hx_ClassId = 0x6efa3c32 }; void __construct( ::haxe::ui::util::VariantType resource); inline void *operator new(size_t inSize, bool inContainer=true,const char *inName="haxe.ui.util.ImageLoader") { return ::hx::Object::operator new(inSize,inContainer,inName); } inline void *operator new(size_t inSize, int extra) { return ::hx::Object::operator new(inSize+extra,true,"haxe.ui.util.ImageLoader"); } static ::hx::ObjectPtr< ImageLoader_obj > __new( ::haxe::ui::util::VariantType resource); static ::hx::ObjectPtr< ImageLoader_obj > __alloc(::hx::Ctx *_hx_ctx, ::haxe::ui::util::VariantType resource); static void * _hx_vtable; static Dynamic __CreateEmpty(); static Dynamic __Create(::hx::DynamicArray inArgs); //~ImageLoader_obj(); HX_DO_RTTI_ALL; ::hx::Val __Field(const ::String &inString, ::hx::PropertyAccess inCallProp); ::hx::Val __SetField(const ::String &inString,const ::hx::Val &inValue, ::hx::PropertyAccess inCallProp); void __GetFields(Array< ::String> &outFields); static void __register(); void __Mark(HX_MARK_PARAMS); void __Visit(HX_VISIT_PARAMS); bool _hx_isInstanceOf(int inClassId); ::String __ToString() const { return HX_("ImageLoader",ae,e9,e1,84); } ::haxe::ui::util::VariantType _resource; void load( ::Dynamic callback); ::Dynamic load_dyn(); void loadFromHttp(::String url, ::Dynamic callback); ::Dynamic loadFromHttp_dyn(); void loadFromFile(::String filename, ::Dynamic callback); ::Dynamic loadFromFile_dyn(); }; } // end namespace haxe } // end namespace ui } // end namespace util #endif /* INCLUDED_haxe_ui_util_ImageLoader */
[ "vhlk@cin.ufpe.br" ]
vhlk@cin.ufpe.br
9ba371fddc3727ed3dea4a092df61729b3a9dea1
be60bef9d1a71e4f3efaedd63115a45cd6346d1c
/ecommserver/app/http/httpserver/httpconnectionhandler.h
b85cd40a35dfa495892626b1103c353ff916e63e
[]
no_license
robertoborgesqt/ecommv1
73873abd4c50259a51c63a6382dd45e39d7b3f4b
0635092583790056b7c6ff6ce70a21a0e3a54abe
refs/heads/main
2023-07-10T07:07:20.434685
2021-08-24T20:19:03
2021-08-24T20:19:03
399,258,521
0
2
null
null
null
null
UTF-8
C++
false
false
3,245
h
/** @file @author Stefan Frings */ #ifndef HTTPCONNECTIONHANDLER_H #define HTTPCONNECTIONHANDLER_H #ifndef QT_NO_OPENSSL #include <QSslConfiguration> #endif #include <QTcpSocket> #include <QSettings> #include <QTimer> #include <QThread> #include "httpglobal.h" #include "httprequest.h" #include "httprequesthandler.h" namespace webserverspace { /** Alias type definition, for compatibility to different Qt versions */ #if QT_VERSION >= 0x050000 typedef qintptr tSocketDescriptor; #else typedef int tSocketDescriptor; #endif /** Alias for QSslConfiguration if OpenSSL is not supported */ #ifdef QT_NO_OPENSSL #define QSslConfiguration QObject #endif /** The connection handler accepts incoming connections and dispatches incoming requests to to a request mapper. Since HTTP clients can send multiple requests before waiting for the response, the incoming requests are queued and processed one after the other. <p> Example for the required configuration settings: <code><pre> readTimeout=60000 maxRequestSize=16000 maxMultiPartSize=1000000 </pre></code> <p> The readTimeout value defines the maximum time to wait for a complete HTTP request. @see HttpRequest for description of config settings maxRequestSize and maxMultiPartSize. */ class DECLSPEC HttpConnectionHandler : public QThread { Q_OBJECT Q_DISABLE_COPY(HttpConnectionHandler) public: /** Constructor. @param settings Configuration settings of the HTTP webserver @param requestHandler Handler that will process each incoming HTTP request @param sslConfiguration SSL (HTTPS) will be used if not NULL */ HttpConnectionHandler(QSettings* settings, HttpRequestHandler* requestHandler, QSslConfiguration* sslConfiguration=NULL); /** Destructor */ virtual ~HttpConnectionHandler(); /** Returns true, if this handler is in use. */ bool isBusy(); /** Mark this handler as busy */ void setBusy(); private: /** Configuration settings */ QSettings* settings; /** TCP socket of the current connection */ QTcpSocket* socket; /** Time for read timeout detection */ QTimer readTimer; /** Storage for the current incoming HTTP request */ HttpRequest* currentRequest; /** Dispatches received requests to services */ HttpRequestHandler* requestHandler; /** This shows the busy-state from a very early time */ bool busy; /** Configuration for SSL */ QSslConfiguration* sslConfiguration; /** Executes the threads own event loop */ void run(); /** Create SSL or TCP socket */ void createSocket(); public slots: /** Received from from the listener, when the handler shall start processing a new connection. @param socketDescriptor references the accepted connection. */ void handleConnection(tSocketDescriptor socketDescriptor); private slots: /** Received from the socket when a read-timeout occured */ void readTimeout(); /** Received from the socket when incoming data can be read */ void read(); /** Received from the socket when a connection has been closed */ void disconnected(); }; } // end of namespace #endif // HTTPCONNECTIONHANDLER_H
[ "rborges67@me.com" ]
rborges67@me.com
1b6cbce5e974b84ac856721d2de0f84d61f350b5
ae8763b93c3c32ecb266891a85859c7e1b731f32
/WestWorld5/WestWorld5/Guest.cpp
d8bb67fde74e2522ec6b52dc00586e96f4795978
[]
no_license
Miapata/CSC215
98a6ade4a7355a21c489c1af97a8f1f09019f5cd
535bedab8822ad22c097cbc2d50882d75adef146
refs/heads/master
2020-03-17T20:39:26.933385
2018-06-28T06:44:36
2018-06-28T06:44:36
133,582,935
0
0
null
null
null
null
UTF-8
C++
false
false
180
cpp
#include "stdafx.h" #include "Guest.h" #include"Denizen.h" #include <iostream> using namespace std; void Guest::trueDeath() { cout << getName() << " is dying for reals!"<<endl; }
[ "MIAPATA@uat.edu" ]
MIAPATA@uat.edu
554fb872a22d12008556df7e9fcf6f65574ada85
782f5876711aecea8c414b5281d01290c626b2ab
/db/c.cc
ee8a4722b9c344bdf73af9f41ded5e69c93825e1
[ "BSD-3-Clause" ]
permissive
chronostore/leveldb
b1ca83755fbc053416bbaebc19a3c20364117665
fbe4e3af3f4e368e0779b6d75cd6005d67469aa2
refs/heads/master
2021-01-18T20:38:31.238871
2011-08-06T00:19:37
2011-08-06T00:19:37
2,127,531
1
1
null
null
null
null
UTF-8
C++
false
false
11,765
cc
// Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. #include "leveldb/c.h" #include <stdlib.h> #include <unistd.h> #include "leveldb/cache.h" #include "leveldb/comparator.h" #include "leveldb/db.h" #include "leveldb/env.h" #include "leveldb/iterator.h" #include "leveldb/options.h" #include "leveldb/status.h" #include "leveldb/write_batch.h" namespace leveldb { extern "C" { struct leveldb_t { DB* rep; }; struct leveldb_iterator_t { Iterator* rep; }; struct leveldb_writebatch_t { WriteBatch rep; }; struct leveldb_snapshot_t { const Snapshot* rep; }; struct leveldb_readoptions_t { ReadOptions rep; }; struct leveldb_writeoptions_t { WriteOptions rep; }; struct leveldb_options_t { Options rep; }; struct leveldb_cache_t { Cache* rep; }; struct leveldb_seqfile_t { SequentialFile* rep; }; struct leveldb_randomfile_t { RandomAccessFile* rep; }; struct leveldb_writablefile_t { WritableFile* rep; }; struct leveldb_logger_t { Logger* rep; }; struct leveldb_filelock_t { FileLock* rep; }; struct leveldb_comparator_t : public Comparator { void* state_; void (*destructor_)(void*); int (*compare_)( void*, const char* a, size_t alen, const char* b, size_t blen); const char* (*name_)(void*); virtual ~leveldb_comparator_t() { (*destructor_)(state_); } virtual int Compare(const Slice& a, const Slice& b) const { return (*compare_)(state_, a.data(), a.size(), b.data(), b.size()); } virtual const char* Name() const { return (*name_)(state_); } // No-ops since the C binding does not support key shortening methods. virtual void FindShortestSeparator(std::string*, const Slice&) const { } virtual void FindShortSuccessor(std::string* key) const { } }; struct leveldb_env_t { Env* rep; bool is_default; }; static bool SaveError(char** errptr, const Status& s) { assert(errptr != NULL); if (s.ok()) { return false; } else if (*errptr == NULL) { *errptr = strdup(s.ToString().c_str()); } else { // TODO(sanjay): Merge with existing error? free(*errptr); *errptr = strdup(s.ToString().c_str()); } return true; } static char* CopyString(const std::string& str) { char* result = reinterpret_cast<char*>(malloc(sizeof(char) * str.size())); memcpy(result, str.data(), sizeof(char) * str.size()); return result; } leveldb_t* leveldb_open( const leveldb_options_t* options, const char* name, char** errptr) { DB* db; if (SaveError(errptr, DB::Open(options->rep, std::string(name), &db))) { return NULL; } leveldb_t* result = new leveldb_t; result->rep = db; return result; } void leveldb_close(leveldb_t* db) { delete db->rep; delete db; } void leveldb_put( leveldb_t* db, const leveldb_writeoptions_t* options, const char* key, size_t keylen, const char* val, size_t vallen, char** errptr) { SaveError(errptr, db->rep->Put(options->rep, Slice(key, keylen), Slice(val, vallen))); } void leveldb_delete( leveldb_t* db, const leveldb_writeoptions_t* options, const char* key, size_t keylen, char** errptr) { SaveError(errptr, db->rep->Delete(options->rep, Slice(key, keylen))); } void leveldb_write( leveldb_t* db, const leveldb_writeoptions_t* options, leveldb_writebatch_t* batch, char** errptr) { SaveError(errptr, db->rep->Write(options->rep, &batch->rep)); } char* leveldb_get( leveldb_t* db, const leveldb_readoptions_t* options, const char* key, size_t keylen, size_t* vallen, char** errptr) { char* result = NULL; std::string tmp; Status s = db->rep->Get(options->rep, Slice(key, keylen), &tmp); if (s.ok()) { *vallen = tmp.size(); result = CopyString(tmp); } else { *vallen = 0; if (!s.IsNotFound()) { SaveError(errptr, s); } } return result; } leveldb_iterator_t* leveldb_create_iterator( leveldb_t* db, const leveldb_readoptions_t* options) { leveldb_iterator_t* result = new leveldb_iterator_t; result->rep = db->rep->NewIterator(options->rep); return result; } const leveldb_snapshot_t* leveldb_create_snapshot( leveldb_t* db) { leveldb_snapshot_t* result = new leveldb_snapshot_t; result->rep = db->rep->GetSnapshot(); return result; } void leveldb_release_snapshot( leveldb_t* db, const leveldb_snapshot_t* snapshot) { db->rep->ReleaseSnapshot(snapshot->rep); delete snapshot; } const char* leveldb_property_value( leveldb_t* db, const char* propname) { std::string tmp; if (db->rep->GetProperty(Slice(propname), &tmp)) { return CopyString(tmp); } else { return NULL; } } void leveldb_approximate_sizes( leveldb_t* db, int num_ranges, const char* const* range_start_key, const size_t* range_start_key_len, const char* const* range_limit_key, const size_t* range_limit_key_len, uint64_t* sizes) { Range* ranges = new Range[num_ranges]; for (int i = 0; i < num_ranges; i++) { ranges[i].start = Slice(range_start_key[i], range_start_key_len[i]); ranges[i].limit = Slice(range_limit_key[i], range_limit_key_len[i]); } db->rep->GetApproximateSizes(ranges, num_ranges, sizes); delete[] ranges; } void leveldb_destroy_db( const leveldb_options_t* options, const char* name, char** errptr) { SaveError(errptr, DestroyDB(name, options->rep)); } void leveldb_repair_db( const leveldb_options_t* options, const char* name, char** errptr) { SaveError(errptr, RepairDB(name, options->rep)); } void leveldb_iter_destroy(leveldb_iterator_t* iter) { delete iter->rep; delete iter; } unsigned char leveldb_iter_valid(const leveldb_iterator_t* iter) { return iter->rep->Valid(); } void leveldb_iter_seek_to_first(leveldb_iterator_t* iter) { iter->rep->SeekToFirst(); } void leveldb_iter_seek_to_last(leveldb_iterator_t* iter) { iter->rep->SeekToLast(); } void leveldb_iter_seek(leveldb_iterator_t* iter, const char* k, size_t klen) { iter->rep->Seek(Slice(k, klen)); } void leveldb_iter_next(leveldb_iterator_t* iter) { iter->rep->Next(); } void leveldb_iter_prev(leveldb_iterator_t* iter) { iter->rep->Prev(); } const char* leveldb_iter_key(const leveldb_iterator_t* iter, size_t* klen) { Slice s = iter->rep->key(); *klen = s.size(); return s.data(); } const char* leveldb_iter_value(const leveldb_iterator_t* iter, size_t* vlen) { Slice s = iter->rep->value(); *vlen = s.size(); return s.data(); } void leveldb_iter_get_error(const leveldb_iterator_t* iter, char** errptr) { SaveError(errptr, iter->rep->status()); } leveldb_writebatch_t* leveldb_writebatch_create() { return new leveldb_writebatch_t; } void leveldb_writebatch_destroy(leveldb_writebatch_t* b) { delete b; } void leveldb_writebatch_clear(leveldb_writebatch_t* b) { b->rep.Clear(); } void leveldb_writebatch_put( leveldb_writebatch_t* b, const char* key, size_t klen, const char* val, size_t vlen) { b->rep.Put(Slice(key, klen), Slice(val, vlen)); } void leveldb_writebatch_delete( leveldb_writebatch_t* b, const char* key, size_t klen) { b->rep.Delete(Slice(key, klen)); } void leveldb_writebatch_iterate( leveldb_writebatch_t* b, void* state, void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen), void (*deleted)(void*, const char* k, size_t klen)) { class H : public WriteBatch::Handler { public: void* state_; void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen); void (*deleted_)(void*, const char* k, size_t klen); virtual void Put(const Slice& key, const Slice& value) { (*put_)(state_, key.data(), key.size(), value.data(), value.size()); } virtual void Delete(const Slice& key) { (*deleted_)(state_, key.data(), key.size()); } }; H handler; handler.state_ = state; handler.put_ = put; handler.deleted_ = deleted; b->rep.Iterate(&handler); } leveldb_options_t* leveldb_options_create() { return new leveldb_options_t; } void leveldb_options_destroy(leveldb_options_t* options) { delete options; } void leveldb_options_set_comparator( leveldb_options_t* opt, leveldb_comparator_t* cmp) { opt->rep.comparator = cmp; } void leveldb_options_set_create_if_missing( leveldb_options_t* opt, unsigned char v) { opt->rep.create_if_missing = v; } void leveldb_options_set_error_if_exists( leveldb_options_t* opt, unsigned char v) { opt->rep.error_if_exists = v; } void leveldb_options_set_paranoid_checks( leveldb_options_t* opt, unsigned char v) { opt->rep.paranoid_checks = v; } void leveldb_options_set_env(leveldb_options_t* opt, leveldb_env_t* env) { opt->rep.env = (env ? env->rep : NULL); } void leveldb_options_set_info_log(leveldb_options_t* opt, leveldb_logger_t* l) { opt->rep.info_log = (l ? l->rep : NULL); } void leveldb_options_set_write_buffer_size(leveldb_options_t* opt, size_t s) { opt->rep.write_buffer_size = s; } void leveldb_options_set_max_open_files(leveldb_options_t* opt, int n) { opt->rep.max_open_files = n; } void leveldb_options_set_cache(leveldb_options_t* opt, leveldb_cache_t* c) { opt->rep.block_cache = c->rep; } void leveldb_options_set_block_size(leveldb_options_t* opt, size_t s) { opt->rep.block_size = s; } void leveldb_options_set_block_restart_interval(leveldb_options_t* opt, int n) { opt->rep.block_restart_interval = n; } void leveldb_options_set_compression(leveldb_options_t* opt, int t) { opt->rep.compression = static_cast<CompressionType>(t); } leveldb_comparator_t* leveldb_comparator_create( void* state, void (*destructor)(void*), int (*compare)( void*, const char* a, size_t alen, const char* b, size_t blen), const char* (*name)(void*)) { leveldb_comparator_t* result = new leveldb_comparator_t; result->state_ = state; result->destructor_ = destructor; result->compare_ = compare; result->name_ = name; return result; } void leveldb_comparator_destroy(leveldb_comparator_t* cmp) { delete cmp; } leveldb_readoptions_t* leveldb_readoptions_create() { return new leveldb_readoptions_t; } void leveldb_readoptions_destroy(leveldb_readoptions_t* opt) { delete opt; } void leveldb_readoptions_set_verify_checksums( leveldb_readoptions_t* opt, unsigned char v) { opt->rep.verify_checksums = v; } void leveldb_readoptions_set_fill_cache( leveldb_readoptions_t* opt, unsigned char v) { opt->rep.fill_cache = v; } void leveldb_readoptions_set_snapshot( leveldb_readoptions_t* opt, const leveldb_snapshot_t* snap) { opt->rep.snapshot = (snap ? snap->rep : NULL); } leveldb_writeoptions_t* leveldb_writeoptions_create() { return new leveldb_writeoptions_t; } void leveldb_writeoptions_destroy(leveldb_writeoptions_t* opt) { delete opt; } void leveldb_writeoptions_set_sync( leveldb_writeoptions_t* opt, unsigned char v) { opt->rep.sync = v; } leveldb_cache_t* leveldb_cache_create_lru(size_t capacity) { leveldb_cache_t* c = new leveldb_cache_t; c->rep = NewLRUCache(capacity); return c; } void leveldb_cache_destroy(leveldb_cache_t* cache) { delete cache->rep; delete cache; } leveldb_env_t* leveldb_create_default_env() { leveldb_env_t* result = new leveldb_env_t; result->rep = Env::Default(); result->is_default = true; return result; } void leveldb_env_destroy(leveldb_env_t* env) { if (!env->is_default) delete env->rep; delete env; } } // end extern "C" }
[ "gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529" ]
gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529
e32bc6caeff908c748c7e75c175d3b799a193365
45d300db6d241ecc7ee0bda2d73afd011e97cf28
/OTCDerivativesCalculatorModule/Project_Cpp/lib_static/FpmlSerialized/GenClass/fpml-asset-5-4/ExchangeTradedContract.hpp
0caca004b5482341cb751bd6a70aef3259407584
[]
no_license
fagan2888/OTCDerivativesCalculatorModule
50076076f5634ffc3b88c52ef68329415725e22d
e698e12660c0c2c0d6899eae55204d618d315532
refs/heads/master
2021-05-30T03:52:28.667409
2015-11-27T06:57:45
2015-11-27T06:57:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,577
hpp
// ExchangeTradedContract.hpp #ifndef FpmlSerialized_ExchangeTradedContract_hpp #define FpmlSerialized_ExchangeTradedContract_hpp #include <fpml-asset-5-4/ExchangeTraded.hpp> #include <built_in_type/XsdTypePositiveInteger.hpp> #include <built_in_type/XsdTypeString.hpp> #include <fpml-shared-5-4/AdjustableOrRelativeDate.hpp> namespace FpmlSerialized { class ExchangeTradedContract : public ExchangeTraded { public: ExchangeTradedContract(TiXmlNode* xmlNode); bool isMultiplier(){return this->multiplierIsNull_;} boost::shared_ptr<XsdTypePositiveInteger> getMultiplier(); std::string getMultiplierIDRef(){return multiplierIDRef_;} bool isContractReference(){return this->contractReferenceIsNull_;} boost::shared_ptr<XsdTypeString> getContractReference(); std::string getContractReferenceIDRef(){return contractReferenceIDRef_;} bool isExpirationDate(){return this->expirationDateIsNull_;} boost::shared_ptr<AdjustableOrRelativeDate> getExpirationDate(); std::string getExpirationDateIDRef(){return expirationDateIDRef_;} protected: boost::shared_ptr<XsdTypePositiveInteger> multiplier_; std::string multiplierIDRef_; bool multiplierIsNull_; boost::shared_ptr<XsdTypeString> contractReference_; std::string contractReferenceIDRef_; bool contractReferenceIsNull_; boost::shared_ptr<AdjustableOrRelativeDate> expirationDate_; std::string expirationDateIDRef_; bool expirationDateIsNull_; }; } //namespaceFpmlSerialized end #endif
[ "math.ansang@gmail.com" ]
math.ansang@gmail.com
7a03817bf52a3b08da9ad4cf2a6d8ad9f20750b2
5e8d200078e64b97e3bbd1e61f83cb5bae99ab6e
/main/source/src/protocols/pb_potential/SetupPoissonBoltzmannPotential.fwd.hh
d13b4af8a4652652811497c7128efab8c67b9885
[]
no_license
MedicaicloudLink/Rosetta
3ee2d79d48b31bd8ca898036ad32fe910c9a7a28
01affdf77abb773ed375b83cdbbf58439edd8719
refs/heads/master
2020-12-07T17:52:01.350906
2020-01-10T08:24:09
2020-01-10T08:24:09
232,757,729
2
6
null
null
null
null
UTF-8
C++
false
false
1,556
hh
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*- // vi: set ts=2 noet: // // (c) Copyright Rosetta Commons Member Institutions. // (c) This file is part of the Rosetta software suite and is made available under license. // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons. // (c) For more information, see http://www.rosettacommons.org. Questions about this can be // (c) addressed to University of Washington CoMotion, email: license@uw.edu. /// @file protocols/pb_potential/PoissonBoltzmannPotential.fwd.hh /// @brief setupPoissonBoltzmannPotential class forward delcaration /// @author Sachko Honda (honda@apl.washington.edu) #ifndef INCLUDED_protocols_pb_potential_SetupPoissonBoltzmannPotential_FWD_HH #define INCLUDED_protocols_pb_potential_SetupPoissonBoltzmannPotential_FWD_HH #include <utility/pointer/owning_ptr.hh> #include <utility/pointer/access_ptr.hh> namespace core { namespace scoring { class SetupPoissonBoltzmannPotential; typedef utility::pointer::shared_ptr< SetupPoissonBoltzmannPotential > SetupPoissonBoltzmannPotentialOP; typedef utility::pointer::shared_ptr< SetupPoissonBoltzmannPotential const > SetupPoissonBoltzmannPotentialCOP; typedef utility::pointer::weak_ptr< SetupPoissonBoltzmannPotential > SetupPoissonBoltzmannPotentialAP; typedef utility::pointer::weak_ptr< SetupPoissonBoltzmannPotential const > SetupPoissonBoltzmannPotentialCAP; } } #endif // INCLUDED_protocols_pb_potential_SetupPoissonBoltzmannPotential_FWD_HH
[ "36790013+MedicaicloudLink@users.noreply.github.com" ]
36790013+MedicaicloudLink@users.noreply.github.com
f9efc53c4899e6291f777d0a9852898c363158a9
26ad4cc35496d364b31396e43a863aee08ef2636
/SDK/SoT_Proposal_Merchant_Rank10Reward_001_functions.cpp
3a51705f9b54c1c4a430c8a9c3dbd28d5301ca38
[]
no_license
cw100/SoT-SDK
ddb9b19ce6ae623299b2b02dee51c29581537ba1
3e6f12384c8e21ed83ef56f00030ca0506d297fb
refs/heads/master
2020-05-05T12:09:55.938323
2019-03-20T14:11:57
2019-03-20T14:11:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
371
cpp
// Sea of Thieves (1.4) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "SoT_Proposal_Merchant_Rank10Reward_001_classes.hpp" namespace SDK { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "igromanru@yahoo.de" ]
igromanru@yahoo.de
35dcd7c87f891b97031a7dfd764bc2a7db5d1a4d
a29a30550ce70f7fe7358bc2e91132b62721b383
/build/lin/obj/moc_pagemotorsettings.cpp
339940f38f7b59306ddbb135142dabe7bb8ef98f
[]
no_license
console-beaver/vesc_tool
2223cd0e119d3c6ea3b0d8388c6f5bfd09bb2e7e
ea1865aae233489a4298f97f5dabe8b34577e42e
refs/heads/master
2021-09-11T00:52:22.346906
2018-04-05T04:36:43
2018-04-05T04:36:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,565
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'pagemotorsettings.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.3) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../../pages/pagemotorsettings.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'pagemotorsettings.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.9.3. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_PageMotorSettings_t { QByteArrayData data[3]; char stringdata0[53]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_PageMotorSettings_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_PageMotorSettings_t qt_meta_stringdata_PageMotorSettings = { { QT_MOC_LITERAL(0, 0, 17), // "PageMotorSettings" QT_MOC_LITERAL(1, 18, 33), // "on_motorSetupWizardButton_cli..." QT_MOC_LITERAL(2, 52, 0) // "" }, "PageMotorSettings\0on_motorSetupWizardButton_clicked\0" "" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_PageMotorSettings[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 19, 2, 0x08 /* Private */, // slots: parameters QMetaType::Void, 0 // eod }; void PageMotorSettings::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { PageMotorSettings *_t = static_cast<PageMotorSettings *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->on_motorSetupWizardButton_clicked(); break; default: ; } } Q_UNUSED(_a); } const QMetaObject PageMotorSettings::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_PageMotorSettings.data, qt_meta_data_PageMotorSettings, qt_static_metacall, nullptr, nullptr} }; const QMetaObject *PageMotorSettings::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *PageMotorSettings::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_PageMotorSettings.stringdata0)) return static_cast<void*>(this); return QWidget::qt_metacast(_clname); } int PageMotorSettings::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } return _id; } QT_WARNING_POP QT_END_MOC_NAMESPACE
[ "tlalexander@gmail.com" ]
tlalexander@gmail.com
76b9223868e81fdd7c6ac2f9382fa974d7ce3770
58bd6097e65226a63ad74a85303676b88db69ce1
/ControlTask_8/Task_8.cpp
43bab1940e89ba8573f16dce1a2441dc86a46a53
[]
no_license
WarBall/Tasks.Cpp
c50f334c12a846a9833c86307d8e62c9513573b0
f982ae09242b5c59752776711d1fa5503ed3e8c8
refs/heads/master
2023-06-28T12:40:38.857470
2021-08-01T19:52:07
2021-08-01T19:52:07
387,199,469
0
0
null
null
null
null
UTF-8
C++
false
false
226
cpp
#include "Time.h" #include <iostream> int main() { Time time1(1, 70, 63); time1.printTime(); Time time2(12, 53, 99); time2.printTime(); Time time3 = time3.addTime(time1, time2); time3.printTime(); }
[ "desik_t9@mail.ru" ]
desik_t9@mail.ru
55bf2cb666b28952b1f71e683b888c194760bc81
ec7acad8f079b37c5c855ceda374414240426e67
/eq-hmi20191219/dialog_truck_info.cpp
b935b62b6172c9f03fce833498baed279d98ca31
[]
no_license
chouer19/eqProj
145143e732608127776eaaf3aac755956a5ffbe7
0815fb46295ce70aafe8e1637863e2eb43e4d510
refs/heads/main
2023-06-30T12:51:26.200328
2021-08-02T01:42:14
2021-08-02T01:42:14
391,785,564
0
2
null
null
null
null
UTF-8
C++
false
false
2,755
cpp
#include "dialog_truck_info.h" #include "ui_dialog_truck_info.h" Dialog_truck_info::Dialog_truck_info(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog_truck_info) { ui->setupUi(this); QRect screenRect = QApplication::desktop()->availableGeometry(); move (screenRect.width()/2-this->width()/2, screenRect.height()/2-this->height()/2); this->setWindowFlags(Qt::FramelessWindowHint); timerId=startTimer(100); } Dialog_truck_info::~Dialog_truck_info() { delete ui; } void Dialog_truck_info::on_pushButton_stop_clicked() { Dialog_confirm *confirm =new Dialog_confirm(); SURRD_TRUCK_INFO_REQ _surrdTruckInfoReq=getSurrdTruckInfoReq(); QString _string =QString::fromStdString(_surrdTruckInfoReq.vehicleNum)+ "卡车紧急停车确认"; confirm->setConfirmInfo(_string); confirm->exec(); if(confirm->confirmed()) { SURRD_TRUCK_CTRL_REQ _surrTruckCtrlReq; _surrTruckCtrlReq.isNew=true; _surrTruckCtrlReq.vehicleNum=_surrdTruckInfoReq.vehicleNum; _surrTruckCtrlReq.ctrlType=0; sys->telecom->setSurrdTruckCtrlReq(_surrTruckCtrlReq); } else { } delete confirm; } void Dialog_truck_info::on_pushButton_close_clicked() { close(); } void Dialog_truck_info::timerEvent(QTimerEvent *event) { if(event->timerId()==timerId) { SURRD_TRUCK_INFO_REQ _surrdTruckInfoReq=getSurrdTruckInfoReq(); ui->label_vehicle_number->setText(QString::fromStdString(_surrdTruckInfoReq.vehicleNum)); getVehicleTask_respond_t _surrdTruckInfo=sys->telecom->getSurrdTruckInfo(); if(_surrdTruckInfo.code=="200") { ui->label_vehicle_task->setText(QString::fromStdString(_surrdTruckInfo.task_type)); ui->label_vehicle_load->setText(QString::fromStdString(_surrdTruckInfo.load_state)); } else { sys->telecom->setSurrdTruckInfoReq(_surrdTruckInfoReq); ui->label_vehicle_task->setText("获取中。。"); ui->label_vehicle_load->setText("获取中。。"); } } } void Dialog_truck_info::setSurrdTruckInfoReq(SURRD_TRUCK_INFO_REQ _surrdTruckInfoReq) { std::unique_lock<std::mutex> lck(m_mutex); surrdTruckInfoReq=_surrdTruckInfoReq; } SURRD_TRUCK_INFO_REQ Dialog_truck_info::getSurrdTruckInfoReq() { std::unique_lock<std::mutex> lck(m_mutex); return surrdTruckInfoReq; } SURRD_TRUCK_CTRL_REQ Dialog_truck_info::getSurrdTruckCtrlReq() { std::unique_lock<std::mutex> lck(m_mutex); return surrdTruckCtrlReq; } void Dialog_truck_info::setSurrdTruckCtrlReq(SURRD_TRUCK_CTRL_REQ _surrdTruckCtrlReq) { std::unique_lock<std::mutex> lck(m_mutex); surrdTruckCtrlReq=_surrdTruckCtrlReq; }
[ "xuec17@icloud.com" ]
xuec17@icloud.com
672f637ddf95d63f52d9c0c9ec3368fce3b1c947
4220a8edb142338ac240e521705c8f3f99a151e9
/src/local_search.cpp
038c13eabdb7cb92798458bb3f60c5938d6612e3
[]
no_license
sergei-sl/CVRPTW-Solver
e4f80e8183b57a806190ee3f8527a13d46676907
0c91d2001ad0dd7b3bfb5ea750e5141adc69b552
refs/heads/master
2020-04-01T11:56:51.648718
2018-10-15T21:37:09
2018-10-15T21:37:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,798
cpp
#pragma once #include "local_search.h" #include <random> #include <algorithm> #include <iterator> bool TwoOpt(Problem& problem, Route& route) { if (route.size() < 4) return false; bool route_changed = false; for (size_t iteration = 0; iteration < 2; ++iteration) { label: bool change_made = false; Route best_route = route; Route old_route = route; double best_gain = 0.0; double gain = 0.0; for (size_t i = 1; i < route.size() - 1; ++i) { for (size_t j = i + 1; j < route.size() - 1; ++j) { if (ProcedureTwoOpt(problem, route, i, j, gain)) { if ((best_gain - gain) > 0.0001 || !problem.IsFeasible(route, false) || (problem.GetDistance(route) - problem.GetDistance(best_route) < -0.00001) ) { ProcedureTwoOpt(problem, route, i, j, gain, true); } else { best_gain = gain; change_made = true; route_changed = true; best_route = route; route = old_route; } } } } if (change_made) { route = best_route; goto label; } break; } return route_changed; } bool OrOpt(Problem& problem, Route& route) { if (route.size() < 4) return false; bool route_changed = false; for (size_t iteration = 0; iteration < 2; ++iteration) { label: bool change_made = false; Route best_route = route; double best_gain = 0.0; double gain = 0.0; for (size_t i = 1; i < route.size() - 2; ++i) { for (size_t j = 1; j < route.size() - 1; ++j) { if (ProcedureOrOpt(problem, best_route, i, j, gain)) { if ((best_gain - gain) > 0.0001 || !problem.IsFeasible(best_route, false)) { ProcedureOrOpt(problem, best_route, i, j, gain, true); } else { best_gain = gain; change_made = true; route_changed = true; } } } } if (change_made) { route = best_route; goto label; } break; } return route_changed; } bool Relocate(Problem& problem, Route& route1, Route& route2) { if (route1.size() < 3) return false; bool routes_changed = false; for (size_t iteration = 0; iteration < 2; ++iteration) { label: bool change_made = false; size_t best_index1 = -1; size_t best_index2 = -1; Route old_route1 = route1; Route old_route2 = route2; double best_gain = 0.0; double gain = 0.0; for (size_t i = 1; i < route1.size() - 1; ++i) { for (size_t j = 0; j < route2.size() - 1; ++j) { if (ProcedureRelocate(problem, route1, route2, i, j, gain)) { if ((best_gain - gain) > 0.0001 || !problem.IsFeasible(route1, true) || !problem.IsFeasible(route2, true)) { ProcedureRelocate(problem, route1, route2, i, j, gain, false, true); } else { best_gain = gain; best_index1 = i; best_index2 = j; change_made = true; routes_changed = true; route1 = old_route1; route2 = old_route2; } } } } if (change_made) { ProcedureRelocate(problem, route1, route2, best_index1, best_index2, gain); goto label; } break; } return routes_changed; } bool Exchange(Problem& problem, Route& route1, Route& route2) { if (route1.size() < 3 || route2.size() < 3) return false; bool routes_changed = false; for (size_t iteration = 0; iteration < 2; ++iteration) { label: bool change_made = false; size_t best_index1 = -1; size_t best_index2 = -1; Route old_route1 = route1; Route old_route2 = route2; double best_gain = 0.0; double gain = 0.0; for (size_t i = 1; i < route1.size() - 1; ++i) { for (size_t j = 1; j < route2.size() - 1; ++j) { if (ProcedureExchange(problem, route1, route2, i, j, gain)) { if ((best_gain - gain) > 0.0001 || !problem.IsFeasible(route1, true) || !problem.IsFeasible(route2, true) || (problem.GetDistance(route1) - problem.GetDistance(old_route1) + problem.GetDistance(route2) - problem.GetDistance(old_route2) < -0.00001)) { ProcedureExchange(problem, route1, route2, i, j, gain, false, true); } else { best_gain = gain; best_index1 = i; best_index2 = j; change_made = true; routes_changed = true; route1 = old_route1; route2 = old_route2; } } } } if (change_made) { ProcedureExchange(problem, route1, route2, best_index1, best_index2, gain); goto label; } break; } return routes_changed; } bool CrossExchange(Problem& problem, Route& route1, Route& route2) { if (route1.size() < 3 || route2.size() < 3 || route1.size() < 4 && route2.size() < 4) return false; bool routes_changed = false; for (size_t segment_size2 = 5; segment_size2 >= 2; --segment_size2) { for (size_t segment_size1 = segment_size2; segment_size1 >= 1; --segment_size1) { label: bool change_made = false; size_t best_index1 = -1; size_t best_index2 = -1; Route old_route1 = route1; Route old_route2 = route2; double best_gain = 0.0; double gain = 0.0; for (size_t i = 1; i < route1.size() - 1; ++i) { for (size_t j = 1; j < route2.size() - 1; ++j) { if (ProcedureCrossExchange(problem, route1, route2, i, j, segment_size1, segment_size2, gain)) { if ((best_gain - gain) > 0.0001 || !problem.IsFeasible(route1, true) || !problem.IsFeasible(route2, true)) { ProcedureCrossExchange(problem, route1, route2, i, j, segment_size1, segment_size2, gain, true); } else { best_gain = gain; best_index1 = i; best_index2 = j; change_made = true; routes_changed = true; route1 = old_route1; route2 = old_route2; } } } } if (change_made) { ProcedureCrossExchange(problem, route1, route2, best_index1, best_index2, segment_size1, segment_size2, gain); goto label; } break; } } return routes_changed; } bool LocalSearchTwoOpt(Problem& problem, Solution & solution) { bool change_made = false; for (auto& route : solution) { change_made |= TwoOpt(problem, route); } return change_made; } bool LocalSearchOrOpt(Problem& problem, Solution & solution) { bool change_made = false; for (auto& route : solution) { change_made |= OrOpt(problem, route); } return change_made; } bool LocalSearchRelocate(Problem& problem, Solution & solution) { size_t interations = 0; bool change_made = false; label: interations++; bool not_local_optimum = false; for (auto& route1 : solution) { for (auto& route2 : solution) { not_local_optimum |= Relocate(problem, route1, route2); } } if (not_local_optimum) { change_made = true; if (interations > solution.size()) goto label; } return change_made; } bool LocalSearchExchange(Problem& problem, Solution & solution) { size_t interations = 0; bool change_made = false; label: interations++; bool not_local_optimum = false; for (auto& route1 : solution) { for (auto& route2 : solution) { not_local_optimum |= Exchange(problem, route1, route2); } } if (not_local_optimum) { change_made = true; if (interations > 5) goto label; } return change_made; } bool LocalSearchCrossExchange(Problem& problem, Solution & solution) { size_t interations = 0; bool change_made = false; label: interations++; bool not_local_optimum = false; for (auto& route1 : solution) { for (auto& route2 : solution) { not_local_optimum |= CrossExchange(problem, route1, route2); } } if (not_local_optimum) { change_made = true; if (interations > 5) goto label; } return change_made; } bool MakeLocalSearchWithOperation(LocalSearchOperations operation_type, Problem& problem, Solution & solution) { switch (operation_type) { case LocalSearchOperations::OperationTwoOpt: return LocalSearchTwoOpt(problem, solution); case LocalSearchOperations::OperationOrOpt: return LocalSearchOrOpt(problem, solution); case LocalSearchOperations::OperationRelocate: return LocalSearchRelocate(problem, solution); case LocalSearchOperations::OperationExchange: return LocalSearchExchange(problem, solution); case LocalSearchOperations::OperationCrossExchange: return LocalSearchCrossExchange(problem, solution); default: return false; } } bool LocalSearch(Problem& problem, Solution & solution) { std::vector<LocalSearchOperations> operations; operations.push_back(LocalSearchOperations::OperationTwoOpt); operations.push_back(LocalSearchOperations::OperationOrOpt); operations.push_back(LocalSearchOperations::OperationExchange); operations.push_back(LocalSearchOperations::OperationRelocate); operations.push_back(LocalSearchOperations::OperationCrossExchange); std::random_device rd; std::mt19937 g(rd()); std::shuffle(operations.begin(), operations.end(), g); operations.push_back(LocalSearchOperations::OperationOrOpt); operations.push_back(LocalSearchOperations::OperationTwoOpt); bool modified = false; bool not_local_optimum = true; size_t iterations = 0; while (not_local_optimum && iterations<10) { iterations++; not_local_optimum = false; for (auto operation : operations) { not_local_optimum |= MakeLocalSearchWithOperation(operation, problem, solution); modified |= not_local_optimum; } std::shuffle(operations.begin(), operations.end(), g); } return modified; }
[ "sergeisl95@yandex.ru" ]
sergeisl95@yandex.ru
4ee03ce3de4d22a38b2891aa72d672d481af0a8a
331bb7bf14c3a4204f59b4bdb9ab714e4f693866
/OpenGL/src/VertexBuffer.cpp
75c72119d778e2dca653efa6f3303601b106cdd4
[]
no_license
woodsjs/cherno_opengl
1b37e0b3c238dfa0a897b9ac407ca69e795b182d
480ab1d1b57f5385c20508d12af4666e75e61ab3
refs/heads/main
2023-04-18T06:07:03.852238
2021-04-23T00:59:54
2021-04-23T00:59:54
352,333,020
0
0
null
null
null
null
UTF-8
C++
false
false
464
cpp
#include "VertexBuffer.h" VertexBuffer::VertexBuffer(const void* data, unsigned int size) { glGenBuffers(1, &m_RendererID); glBindBuffer(GL_ARRAY_BUFFER, m_RendererID); glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW); } VertexBuffer::~VertexBuffer() { glDeleteBuffers(1, &m_RendererID); } void VertexBuffer::Bind() const { glBindBuffer(GL_ARRAY_BUFFER, m_RendererID); } void VertexBuffer::Unbind() const { glBindBuffer(GL_ARRAY_BUFFER, 0); }
[ "jason@coder.haus" ]
jason@coder.haus
424cd98a2243a25763f3d78c6b45f6f96fe5c1b5
699a07206dad2d5edc5bae8e51365ebcd1497984
/src/internet/model/ipv6-extension-header.cc
782badd6123685ba6181ef1478ab133323f56694
[]
no_license
anyonepaw/ns3-iot-realisation
d5bc126968a737e476e656b21a5810241b9905bd
02353ae9f1c8b4dc186a63b1e2f260a91aaa0447
refs/heads/master
2020-04-23T23:00:02.343096
2019-06-02T12:19:52
2019-06-02T12:19:52
171,520,704
7
5
null
2019-05-30T15:20:42
2019-02-19T17:44:57
C++
UTF-8
C++
false
false
16,500
cc
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007-2009 Strasbourg University * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: David Gross <gdavid.devel@gmail.com> */ #include "ns3/assert.h" #include "ns3/log.h" #include "ns3/header.h" #include "ipv6-extension-header.h" namespace ns3 { NS_LOG_COMPONENT_DEFINE ("Ipv6ExtensionHeader"); NS_OBJECT_ENSURE_REGISTERED (Ipv6ExtensionHeader); TypeId Ipv6ExtensionHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::Ipv6ExtensionHeader") .AddConstructor<Ipv6ExtensionHeader> () .SetParent<Header> () .SetGroupName ("Internet") ; return tid; } TypeId Ipv6ExtensionHeader::GetInstanceTypeId () const { return GetTypeId (); } Ipv6ExtensionHeader::Ipv6ExtensionHeader () : m_length (0), m_nextHeader (0), m_data (0) { } Ipv6ExtensionHeader::~Ipv6ExtensionHeader () { } void Ipv6ExtensionHeader::SetNextHeader (uint8_t nextHeader) { m_nextHeader = nextHeader; } uint8_t Ipv6ExtensionHeader::GetNextHeader () const { return m_nextHeader; } void Ipv6ExtensionHeader::SetLength (uint16_t length) { NS_ASSERT_MSG (!(length & 0x7), "Invalid Ipv6ExtensionHeader Length, must be a multiple of 8 bytes."); NS_ASSERT_MSG (length > 0, "Invalid Ipv6ExtensionHeader Length, must be greater than 0."); NS_ASSERT_MSG (length < 2048, "Invalid Ipv6ExtensionHeader Length, must be a lower than 2048."); m_length = (length >> 3) - 1; } uint16_t Ipv6ExtensionHeader::GetLength () const { return (m_length + 1) << 3; } void Ipv6ExtensionHeader::Print (std::ostream &os) const { os << "( nextHeader = " << (uint32_t)GetNextHeader () << " length = " << (uint32_t)GetLength () << " )"; } uint32_t Ipv6ExtensionHeader::GetSerializedSize () const { return 2; } void Ipv6ExtensionHeader::Serialize (Buffer::Iterator start) const { Buffer::Iterator i = start; i.WriteU8 (m_nextHeader); i.WriteU8 (m_length); i.Write (m_data.PeekData (), m_data.GetSize ()); } uint32_t Ipv6ExtensionHeader::Deserialize (Buffer::Iterator start) { Buffer::Iterator i = start; m_nextHeader = i.ReadU8 (); m_length = i.ReadU8 (); uint32_t dataLength = GetLength () - 2; uint8_t* data = new uint8_t[dataLength]; i.Read (data, dataLength); if (dataLength > m_data.GetSize ()) { m_data.AddAtEnd (dataLength - m_data.GetSize ()); } else { m_data.RemoveAtEnd (m_data.GetSize () - dataLength); } i = m_data.Begin (); i.Write (data, dataLength); delete[] data; return GetSerializedSize (); } OptionField::OptionField (uint32_t optionsOffset) : m_optionData (0), m_optionsOffset (optionsOffset) { } OptionField::~OptionField () { } uint32_t OptionField::GetSerializedSize () const { return m_optionData.GetSize () + CalculatePad (Ipv6OptionHeader::Alignment{ 8,0}); } void OptionField::Serialize (Buffer::Iterator start) const { start.Write (m_optionData.Begin (), m_optionData.End ()); uint32_t fill = CalculatePad (Ipv6OptionHeader::Alignment{8,0}); NS_LOG_LOGIC ("fill with " << fill << " bytes padding"); switch (fill) { case 0: return; case 1: Ipv6OptionPad1Header ().Serialize (start); return; default: Ipv6OptionPadnHeader (fill).Serialize (start); return; } } uint32_t OptionField::Deserialize (Buffer::Iterator start, uint32_t length) { uint8_t* buf = new uint8_t[length]; start.Read (buf, length); m_optionData = Buffer (); m_optionData.AddAtEnd (length); m_optionData.Begin ().Write (buf, length); delete[] buf; return length; } void OptionField::AddOption (Ipv6OptionHeader const& option) { NS_LOG_FUNCTION_NOARGS (); uint32_t pad = CalculatePad (option.GetAlignment ()); NS_LOG_LOGIC ("need " << pad << " bytes padding"); switch (pad) { case 0: break; //no padding needed case 1: AddOption (Ipv6OptionPad1Header ()); break; default: AddOption (Ipv6OptionPadnHeader (pad)); break; } m_optionData.AddAtEnd (option.GetSerializedSize ()); Buffer::Iterator it = m_optionData.End (); it.Prev (option.GetSerializedSize ()); option.Serialize (it); } uint32_t OptionField::CalculatePad (Ipv6OptionHeader::Alignment alignment) const { return (alignment.offset - (m_optionData.GetSize () + m_optionsOffset)) % alignment.factor; } uint32_t OptionField::GetOptionsOffset () { return m_optionsOffset; } Buffer OptionField::GetOptionBuffer () { return m_optionData; } NS_OBJECT_ENSURE_REGISTERED (Ipv6ExtensionHopByHopHeader); TypeId Ipv6ExtensionHopByHopHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::Ipv6ExtensionHopByHopHeader") .AddConstructor<Ipv6ExtensionHopByHopHeader> () .SetParent<Ipv6ExtensionHeader> () .SetGroupName ("Internet") ; return tid; } TypeId Ipv6ExtensionHopByHopHeader::GetInstanceTypeId () const { return GetTypeId (); } Ipv6ExtensionHopByHopHeader::Ipv6ExtensionHopByHopHeader () : OptionField (2) { } Ipv6ExtensionHopByHopHeader::~Ipv6ExtensionHopByHopHeader () { } void Ipv6ExtensionHopByHopHeader::Print (std::ostream &os) const { os << "( nextHeader = " << (uint32_t)GetNextHeader () << " length = " << (uint32_t)GetLength () << " )"; } uint32_t Ipv6ExtensionHopByHopHeader::GetSerializedSize () const { return 2 + OptionField::GetSerializedSize (); } void Ipv6ExtensionHopByHopHeader::Serialize (Buffer::Iterator start) const { Buffer::Iterator i = start; i.WriteU8 (GetNextHeader ()); i.WriteU8 ((GetSerializedSize () >> 3) - 1); OptionField::Serialize (i); } uint32_t Ipv6ExtensionHopByHopHeader::Deserialize (Buffer::Iterator start) { Buffer::Iterator i = start; SetNextHeader (i.ReadU8 ()); m_length = i.ReadU8 (); OptionField::Deserialize (i, GetLength () - 2); return GetSerializedSize (); } NS_OBJECT_ENSURE_REGISTERED (Ipv6ExtensionDestinationHeader); TypeId Ipv6ExtensionDestinationHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::Ipv6ExtensionDestinationHeader") .AddConstructor<Ipv6ExtensionDestinationHeader> () .SetParent<Ipv6ExtensionHeader> () .SetGroupName ("Internet") ; return tid; } TypeId Ipv6ExtensionDestinationHeader::GetInstanceTypeId () const { return GetTypeId (); } Ipv6ExtensionDestinationHeader::Ipv6ExtensionDestinationHeader () : OptionField (2) { } Ipv6ExtensionDestinationHeader::~Ipv6ExtensionDestinationHeader () { } void Ipv6ExtensionDestinationHeader::Print (std::ostream &os) const { os << "( nextHeader = " << (uint32_t)GetNextHeader () << " length = " << (uint32_t)GetLength () << " )"; } uint32_t Ipv6ExtensionDestinationHeader::GetSerializedSize () const { return 2 + OptionField::GetSerializedSize (); } void Ipv6ExtensionDestinationHeader::Serialize (Buffer::Iterator start) const { Buffer::Iterator i = start; i.WriteU8 (GetNextHeader ()); i.WriteU8 ((GetSerializedSize () >> 3) - 1); OptionField::Serialize (i); } uint32_t Ipv6ExtensionDestinationHeader::Deserialize (Buffer::Iterator start) { Buffer::Iterator i = start; SetNextHeader (i.ReadU8 ()); m_length = i.ReadU8 (); OptionField::Deserialize (i, GetLength () - 2); return GetSerializedSize (); } NS_OBJECT_ENSURE_REGISTERED (Ipv6ExtensionFragmentHeader); TypeId Ipv6ExtensionFragmentHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::Ipv6ExtensionFragmentHeader") .AddConstructor<Ipv6ExtensionFragmentHeader> () .SetParent<Ipv6ExtensionHeader> () .SetGroupName ("Internet") ; return tid; } TypeId Ipv6ExtensionFragmentHeader::GetInstanceTypeId () const { return GetTypeId (); } Ipv6ExtensionFragmentHeader::Ipv6ExtensionFragmentHeader () : m_offset (0), m_identification (0) { m_length = 0; } Ipv6ExtensionFragmentHeader::~Ipv6ExtensionFragmentHeader () { } void Ipv6ExtensionFragmentHeader::SetOffset (uint16_t offset) { // Clear the offset, and save the MF bit m_offset &= 1; m_offset |= offset & (~7); } uint16_t Ipv6ExtensionFragmentHeader::GetOffset () const { return m_offset & (~1); } void Ipv6ExtensionFragmentHeader::SetMoreFragment (bool moreFragment) { m_offset = moreFragment ? m_offset | 1 : m_offset & (~1); } bool Ipv6ExtensionFragmentHeader::GetMoreFragment () const { return m_offset & 1; } void Ipv6ExtensionFragmentHeader::SetIdentification (uint32_t identification) { m_identification = identification; } uint32_t Ipv6ExtensionFragmentHeader::GetIdentification () const { return m_identification; } void Ipv6ExtensionFragmentHeader::Print (std::ostream &os) const { os << "( nextHeader = " << (uint32_t)GetNextHeader () << " length = " << (uint32_t)GetLength () << " offset = " << (uint32_t)GetOffset () << " MF = " << (uint32_t)GetMoreFragment () << " identification = " << (uint32_t)m_identification << " )"; } uint32_t Ipv6ExtensionFragmentHeader::GetSerializedSize () const { return 8; } void Ipv6ExtensionFragmentHeader::Serialize (Buffer::Iterator start) const { Buffer::Iterator i = start; i.WriteU8 (GetNextHeader ()); // Fragment header does not carry an extension length i.WriteU8 (0); i.WriteHtonU16 (m_offset); i.WriteHtonU32 (m_identification); } uint32_t Ipv6ExtensionFragmentHeader::Deserialize (Buffer::Iterator start) { Buffer::Iterator i = start; SetNextHeader (i.ReadU8 ()); // Fragment header does not carry an extension length i.ReadU8 (); m_offset = i.ReadNtohU16 (); m_identification = i.ReadNtohU32 (); return GetSerializedSize (); } NS_OBJECT_ENSURE_REGISTERED (Ipv6ExtensionRoutingHeader); TypeId Ipv6ExtensionRoutingHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::Ipv6ExtensionRoutingHeader") .AddConstructor<Ipv6ExtensionRoutingHeader> () .SetParent<Ipv6ExtensionHeader> () .SetGroupName ("Internet") ; return tid; } TypeId Ipv6ExtensionRoutingHeader::GetInstanceTypeId () const { return GetTypeId (); } Ipv6ExtensionRoutingHeader::Ipv6ExtensionRoutingHeader () : m_typeRouting (0), m_segmentsLeft (0) { } Ipv6ExtensionRoutingHeader::~Ipv6ExtensionRoutingHeader () { } void Ipv6ExtensionRoutingHeader::SetTypeRouting (uint8_t typeRouting) { m_typeRouting = typeRouting; } uint8_t Ipv6ExtensionRoutingHeader::GetTypeRouting () const { return m_typeRouting; } void Ipv6ExtensionRoutingHeader::SetSegmentsLeft (uint8_t segmentsLeft) { m_segmentsLeft = segmentsLeft; } uint8_t Ipv6ExtensionRoutingHeader::GetSegmentsLeft () const { return m_segmentsLeft; } void Ipv6ExtensionRoutingHeader::Print (std::ostream &os) const { os << "( nextHeader = " << (uint32_t)GetNextHeader () << " length = " << (uint32_t)GetLength () << " typeRouting = " << (uint32_t)m_typeRouting << " segmentsLeft = " << (uint32_t)m_segmentsLeft << " )"; } uint32_t Ipv6ExtensionRoutingHeader::GetSerializedSize () const { return 4; } void Ipv6ExtensionRoutingHeader::Serialize (Buffer::Iterator start) const { Buffer::Iterator i = start; i.WriteU8 (GetNextHeader ()); i.WriteU8 (m_length); i.WriteU8 (m_typeRouting); i.WriteU8 (m_segmentsLeft); } uint32_t Ipv6ExtensionRoutingHeader::Deserialize (Buffer::Iterator start) { Buffer::Iterator i = start; SetNextHeader (i.ReadU8 ()); m_length = i.ReadU8 (); m_typeRouting = i.ReadU8 (); m_segmentsLeft = i.ReadU8 (); return GetSerializedSize (); } NS_OBJECT_ENSURE_REGISTERED (Ipv6ExtensionLooseRoutingHeader); TypeId Ipv6ExtensionLooseRoutingHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::Ipv6ExtensionLooseRoutingHeader") .AddConstructor<Ipv6ExtensionLooseRoutingHeader> () .SetParent<Ipv6ExtensionRoutingHeader> () .SetGroupName ("Internet") ; return tid; } TypeId Ipv6ExtensionLooseRoutingHeader::GetInstanceTypeId () const { return GetTypeId (); } Ipv6ExtensionLooseRoutingHeader::Ipv6ExtensionLooseRoutingHeader () : m_routersAddress (0) { } Ipv6ExtensionLooseRoutingHeader::~Ipv6ExtensionLooseRoutingHeader () { } void Ipv6ExtensionLooseRoutingHeader::SetNumberAddress (uint8_t n) { m_routersAddress.clear (); m_routersAddress.assign (n, Ipv6Address ("")); } void Ipv6ExtensionLooseRoutingHeader::SetRoutersAddress (std::vector<Ipv6Address> routersAddress) { m_routersAddress = routersAddress; } std::vector<Ipv6Address> Ipv6ExtensionLooseRoutingHeader::GetRoutersAddress () const { return m_routersAddress; } void Ipv6ExtensionLooseRoutingHeader::SetRouterAddress (uint8_t index, Ipv6Address addr) { m_routersAddress.at (index) = addr; } Ipv6Address Ipv6ExtensionLooseRoutingHeader::GetRouterAddress (uint8_t index) const { return m_routersAddress.at (index); } void Ipv6ExtensionLooseRoutingHeader::Print (std::ostream &os) const { os << "( nextHeader = " << (uint32_t)GetNextHeader () << " length = " << (uint32_t)GetLength () << " typeRouting = " << (uint32_t)GetTypeRouting () << " segmentsLeft = " << (uint32_t)GetSegmentsLeft () << " "; for (std::vector<Ipv6Address>::const_iterator it = m_routersAddress.begin (); it != m_routersAddress.end (); it++) { os << *it << " "; } os << " )"; } uint32_t Ipv6ExtensionLooseRoutingHeader::GetSerializedSize () const { return 8 + m_routersAddress.size () * 16; } void Ipv6ExtensionLooseRoutingHeader::Serialize (Buffer::Iterator start) const { Buffer::Iterator i = start; uint8_t buff[16]; uint8_t addressNum = m_routersAddress.size (); i.WriteU8 (GetNextHeader ()); i.WriteU8 (addressNum*2); i.WriteU8 (GetTypeRouting ()); i.WriteU8 (GetSegmentsLeft ()); i.WriteU32 (0); for (VectorIpv6Address_t::const_iterator it = m_routersAddress.begin (); it != m_routersAddress.end (); it++) { it->Serialize (buff); i.Write (buff, 16); } } uint32_t Ipv6ExtensionLooseRoutingHeader::Deserialize (Buffer::Iterator start) { Buffer::Iterator i = start; uint8_t buff[16]; SetNextHeader (i.ReadU8 ()); m_length = i.ReadU8 (); SetTypeRouting (i.ReadU8 ()); SetSegmentsLeft (i.ReadU8 ()); i.ReadU32 (); uint8_t addressNum = m_length / 2; SetNumberAddress (addressNum); for (uint8_t index = 0; index < addressNum; index++) { i.Read (buff, 16); SetRouterAddress (index, Ipv6Address (buff)); } return GetSerializedSize (); } NS_OBJECT_ENSURE_REGISTERED (Ipv6ExtensionESPHeader); TypeId Ipv6ExtensionESPHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::Ipv6ExtensionESPHeader") .AddConstructor<Ipv6ExtensionESPHeader> () .SetParent<Ipv6ExtensionHeader> () .SetGroupName ("Internet") ; return tid; } TypeId Ipv6ExtensionESPHeader::GetInstanceTypeId () const { return GetTypeId (); } Ipv6ExtensionESPHeader::Ipv6ExtensionESPHeader () { } Ipv6ExtensionESPHeader::~Ipv6ExtensionESPHeader () { } void Ipv6ExtensionESPHeader::Print (std::ostream &os) const { /** \todo */ } uint32_t Ipv6ExtensionESPHeader::GetSerializedSize () const { /** \todo */ return 0; } void Ipv6ExtensionESPHeader::Serialize (Buffer::Iterator start) const { /** \todo */ } uint32_t Ipv6ExtensionESPHeader::Deserialize (Buffer::Iterator start) { /** \todo */ return 0; } NS_OBJECT_ENSURE_REGISTERED (Ipv6ExtensionAHHeader); TypeId Ipv6ExtensionAHHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::Ipv6ExtensionAHHeader") .AddConstructor<Ipv6ExtensionAHHeader> () .SetParent<Ipv6ExtensionHeader> () .SetGroupName ("Internet") ; return tid; } TypeId Ipv6ExtensionAHHeader::GetInstanceTypeId () const { return GetTypeId (); } Ipv6ExtensionAHHeader::Ipv6ExtensionAHHeader () { } Ipv6ExtensionAHHeader::~Ipv6ExtensionAHHeader () { } void Ipv6ExtensionAHHeader::Print (std::ostream &os) const { /** \todo */ } uint32_t Ipv6ExtensionAHHeader::GetSerializedSize () const { /** \todo */ return 0; } void Ipv6ExtensionAHHeader::Serialize (Buffer::Iterator start) const { /** \todo */ } uint32_t Ipv6ExtensionAHHeader::Deserialize (Buffer::Iterator start) { /** \todo */ return 0; } } /* namespace ns3 */
[ "gabrielcarvfer@gmail.com" ]
gabrielcarvfer@gmail.com
11398fcd9b6e27be602fe664a2e4f2a805075841
ef9a782df42136ec09485cbdbfa8a56512c32530
/branches/Chickens/src/livestock/pullets.h
c749dc10141b4aaa4eab4ddf9c42d4f114f9875c
[]
no_license
penghuz/main
c24ca5f2bf13b8cc1f483778e72ff6432577c83b
26d9398309eeacbf24e3c5affbfb597be1cc8cd4
refs/heads/master
2020-04-22T15:59:50.432329
2017-11-23T10:30:22
2017-11-23T10:30:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,314
h
/****************************************************************************\ $URL$ $LastChangedDate$ $LastChangedRevision$ $LastChangedBy$ \****************************************************************************/ /****************************************************************************\ \****************************************************************************/ #ifndef PULLETS_H #define PULLETS_H #include "poultry.h" #include "../products/animalProduct.h" /****************************************************************************\ Class: pullets \****************************************************************************/ class pullets : public poultry { /* Attributes */ private: animalProduct* pulletsPrDay; /* Actions */ private: public: // Default Constructor pullets(); pullets(const char *aName,const int aIndex,const base * aOwner); // Destructor ~pullets(); // Other functions double feedingDays(); void Manure(manure* fluidManure, manure* solidManure); void DailyUpdate(); void ReceivePlan(char * FileName); void SetNumberPrYear (double aNumberPrYear){ poultry::SetNumberPrYear(aNumberPrYear);} virtual double GetSensibleHeatProduction(double weight, double n); }; #endif
[ "sai@agro.au.dk" ]
sai@agro.au.dk
3088533550dc4630d0250aa29e0a466826813625
645a7fdf468e107f62811de7a57b0be4b2c87936
/server/node_modules/opencv-build/opencv/build/modules/core/convert.vsx3.cpp
f5905361a3c341ec25e639880b68c5a151a3ad9b
[]
no_license
nnaboon/WebForRecNodejs
20acc1123f3473369b8f1a8456af0cbdf90bef22
83613dbb0515d8fb88c0871cd33fdc278d13b19c
refs/heads/main
2023-02-19T04:35:35.782345
2021-01-18T10:51:47
2021-01-18T10:51:47
330,635,487
0
0
null
null
null
null
UTF-8
C++
false
false
278
cpp
#include "/Users/naboon/Develop/wks/react_wks/camera_test2/server/node_modules/opencv-build/opencv/opencv/modules/core/src/precomp.hpp" #include "/Users/naboon/Develop/wks/react_wks/camera_test2/server/node_modules/opencv-build/opencv/opencv/modules/core/src/convert.simd.hpp"
[ "srisawasdina@gmail.com" ]
srisawasdina@gmail.com
24d0779ca65af0ea636b63ced2abdcf423599c5a
d1590021cb64d76623c5804d36cab12c24f1cb1a
/2020/day02.cpp
1bdf7286dff33f969a27f2b9f4d1793a73c0aee7
[]
no_license
evroon/adventofcode
697bff2650cfef2cc96e02aa303a539bfc74e4bd
ceffd754b2723dd3f7141eb754ab4384590e8a14
refs/heads/master
2022-12-13T12:53:45.298040
2022-12-06T21:32:09
2022-12-06T21:32:09
159,942,333
1
0
null
2022-11-09T18:13:25
2018-12-01T12:28:25
C++
UTF-8
C++
false
false
743
cpp
#include <iostream> #include <fstream> #include <stdlib.h> #include <vector> #include "manager.h" R day2_part2(std::ifstream& input) { std::string line; R occurences = 0; while (std::getline(input, line)) { int min = std::atoi(line.substr(0, line.find("-")).c_str()); std::string rest = line.substr(line.find("-")+1, line.size() - 1); int max = std::atoi(rest.substr(0, rest.find(" ")).c_str()); char c = rest.substr(rest.find(" ") + 1, rest.find(":") - 1)[0]; std::string password = line.substr(line.find(":") + 2, line.size() - 1); if ((password[min-1] == c) != (password[max-1] == c)) { occurences++; } } return occurences; } ADD_SOLUTION(2)
[ "erik.vroon22@gmail.com" ]
erik.vroon22@gmail.com
7ceb8ccafa2046a3b16f4ab9bb520658d97b6dca
5b641d7b69ba0d43bd224d19831ab67a5b101582
/talks/crosstalk/src/FindTwoPhoton/Class/FindTwoPhoton_DONT_TOUCH.cc
a926ba6ebca1b3157ed413ea56fd45af2e862373
[]
no_license
jpivarski-talks/1999-2006_gradschool-2
9d7a4e91bbde6dc7f472ea21253b32a0eca104e4
ca889b4d09814a226513e39625ae2f140c97b5d5
refs/heads/master
2022-11-19T11:37:55.623868
2020-07-25T01:19:32
2020-07-25T01:19:32
282,235,528
0
0
null
null
null
null
UTF-8
C++
false
false
1,329
cc
// -*- C++ -*- // // Package: FindTwoPhoton // Module: FindTwoPhoton_DONT_TOUCH // // Description: DONT TOUCH THIS FILE // // Definition of bind action // // Implementation: // // Author: Jim Pivarski // Created: Mon Jun 16 21:55:05 EDT 2003 // $Id$ // // Revision history // // $Log$ #include "Experiment/Experiment.h" // system include files #if defined(AMBIGUOUS_STRING_FUNCTIONS_BUG) #include <string> #endif /* AMBIGUOUS_STRING_FUNCTIONS_BUG */ // user include files #include "FindTwoPhoton/FindTwoPhoton.h" #include "Processor/Action.h" // STL classes // // constants, enums and typedefs // // ---- cvs-based strings (Id and Tag with which file was checked out) static const char* const kIdString = "$Id: processor_DONT_TOUCH.cc,v 1.5 1998/12/01 21:11:58 mkl Exp $"; static const char* const kTagString = "$Name: v06_08_00 $"; // // function definitions // // // static data member definitions // // // member functions // // ---------------- binding method to stream ------------------- void FindTwoPhoton::bind( ActionBase::ActionResult (FindTwoPhoton::*iMethod)( Frame& ), const Stream::Type& iStream ) { bindAction( iStream, new Action<FindTwoPhoton>( iMethod, this ) ); } // // const member functions // // // static member functions //
[ "jpivarski@gmail.com" ]
jpivarski@gmail.com
987aad008647fc2fdf7521d2af939f718672595b
71a798687f8c83510cdc52ae769b71f31e5f95d0
/spoj/NHAY/main.cpp
3642d9a5f1150205694a915e00f370f618d73133
[]
no_license
shashank30071996/mycodes
210f59eaad81115898c044b85a2adeee3934155b
729010cd7ac77285f4c5b962f0ecd6e83096157a
refs/heads/master
2021-01-02T08:35:29.695258
2017-08-01T17:05:26
2017-08-01T17:05:26
99,024,466
0
0
null
null
null
null
UTF-8
C++
false
false
1,328
cpp
#include <bits/stdc++.h> using namespace std; void KMP(string pat,string txt,int m); void computelps(string pat,int *lps,int m); int main() { int m; string pat;string txt; while(scanf("%d",&m)!=EOF){ cin>>pat; cin>>txt; KMP(pat,txt,m); } } void KMP(string pat,string txt,int m) { int i=0,j=0;vector<int> loc; int lps[m]; computelps(pat,lps,m);int k=0; while(i<txt.length()) { if(txt[i]==pat[j]) { i++; j++; } if(j==m) { printf("%d\n",i-j); j=lps[j-1];k=1; loc.push_back(i-j); } else if(i<txt.length() && pat[j]!=txt[i]) { if(j!=0) j=lps[j-1]; else i=i+1; } } if(k==0) cout<<endl; cout<<endl; } void computelps(string pat,int *lps,int m) { int len=0; lps[0]=0; int i=1; while(i<m) { if(pat[len]==pat[i]) { len++; lps[i]=len;i++; } else{ if(len!=0) len=lps[len-1]; else { lps[i]=0;i++; } } } }
[ "singhshashank229@gmail.com" ]
singhshashank229@gmail.com
1189e4b485078b58190df854540798cc7528d5e7
edfb435ee89eec4875d6405e2de7afac3b2bc648
/tags/selenium-2.0-rc-1/cpp/IEDriver/IEDriverServer.cpp
cd5570675f4124b69859e20a57c712fe7a4ff1b1
[ "Apache-2.0" ]
permissive
Escobita/selenium
6c1c78fcf0fb71604e7b07a3259517048e584037
f4173df37a79ab6dd6ae3f1489ae0cd6cc7db6f1
refs/heads/master
2021-01-23T21:01:17.948880
2012-12-06T22:47:50
2012-12-06T22:47:50
8,271,631
1
0
null
null
null
null
UTF-8
C++
false
false
22,307
cpp
// Copyright 2011 WebDriver committers // 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 "StdAfx.h" #include <regex> #include "IEDriverServer.h" #include "logging.h" namespace webdriver { IEDriverServer::IEDriverServer(int port) { // It's possible to set the log level at compile time using this: LOG::Level("FATAL"); LOG(INFO) << "Starting IE Driver server on port: " << port; this->port_ = port; this->PopulateCommandRepository(); } IEDriverServer::~IEDriverServer(void) { if (this->sessions_.size() > 0) { vector<std::wstring> session_ids; SessionMap::iterator it = this->sessions_.begin(); for (; it != this->sessions_.end(); ++it) { session_ids.push_back(it->first); } for (size_t index = 0; index < session_ids.size(); ++index) { this->ShutDownSession(session_ids[index]); } } } std::wstring IEDriverServer::CreateSession() { unsigned int thread_id = 0; HWND session_window_handle = NULL; HANDLE event_handle = ::CreateEvent(NULL, TRUE, FALSE, EVENT_NAME); HANDLE thread_handle = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, &Session::ThreadProc, reinterpret_cast<void*>(&session_window_handle), 0, &thread_id)); if (event_handle != NULL) { ::WaitForSingleObject(event_handle, INFINITE); ::CloseHandle(event_handle); } if (thread_handle != NULL) { ::CloseHandle(thread_handle); } ::SendMessage(session_window_handle, WD_INIT, static_cast<WPARAM>(this->port_), NULL); vector<TCHAR> window_text_buffer(37); ::GetWindowText(session_window_handle, &window_text_buffer[0], 37); std::wstring session_id = &window_text_buffer[0]; this->sessions_[session_id] = session_window_handle; return session_id; } void IEDriverServer::ShutDownSession(const std::wstring& session_id) { SessionMap::iterator it = this->sessions_.find(session_id); if (it != this->sessions_.end()) { DWORD process_id; DWORD thread_id = ::GetWindowThreadProcessId(it->second, &process_id); HANDLE thread_handle = ::OpenThread(SYNCHRONIZE, FALSE, thread_id); ::SendMessage(it->second, WM_CLOSE, NULL, NULL); if (thread_handle != NULL) { DWORD wait_result = ::WaitForSingleObject(thread_handle, 30000); if (wait_result != WAIT_OBJECT_0) { LOG(DEBUG) << "Waiting for thread to end returned " << wait_result; } ::CloseHandle(thread_handle); } this->sessions_.erase(session_id); } } std::wstring IEDriverServer::ReadRequestBody(struct mg_connection* conn, const struct mg_request_info* request_info) { std::wstring request_body = L""; int content_length = 0; for (int header_index = 0; header_index < 64; ++header_index) { if (request_info->http_headers[header_index].name == NULL) { break; } if (strcmp(request_info->http_headers[header_index].name, "Content-Length") == 0) { content_length = atoi(request_info->http_headers[header_index].value); break; } } if (content_length == 0) { request_body = L"{}"; } else { std::vector<char> input_buffer(content_length + 1); int bytes_read = 0; while (bytes_read < content_length) { bytes_read += mg_read(conn, &input_buffer[bytes_read], content_length - bytes_read); } input_buffer[content_length] = '\0'; int output_buffer_size = ::MultiByteToWideChar(CP_UTF8, 0, &input_buffer[0], -1, NULL, 0); vector<TCHAR> output_buffer(output_buffer_size); ::MultiByteToWideChar(CP_UTF8, 0, &input_buffer[0], -1, &output_buffer[0], output_buffer_size); request_body.append(&output_buffer[0], output_buffer_size); } return request_body; } int IEDriverServer::ProcessRequest(struct mg_connection* conn, const struct mg_request_info* request_info) { int return_code = NULL; std::string http_verb = request_info->request_method; std::wstring request_body = L"{}"; if (http_verb == "POST") { request_body = this->ReadRequestBody(conn, request_info); } if (strcmp(request_info->uri, "/") == 0) { this->SendWelcomePage(conn, request_info); return_code = 200; } else { std::wstring session_id = L""; std::wstring locator_parameters = L""; int command = this->LookupCommand(request_info->uri, http_verb, &session_id, &locator_parameters); if (command == NoCommand) { if (locator_parameters.size() != 0) { this->SendHttpMethodNotAllowed(conn, request_info, locator_parameters); } else { this->SendHttpNotImplemented(conn, request_info, "Command not implemented"); } } else { if (command == NewSession) { session_id = this->CreateSession(); } std::wstring serialized_response = L""; HWND session_window_handle = NULL; if (!this->LookupSession(session_id, &session_window_handle)) { // Hand-code the response for an invalid session id serialized_response = L"{ \"status\" : 404, \"sessionId\" : \"" + session_id + L"\", \"value\" : \"session " + session_id + L" does not exist\" }"; } else { // Compile the serialized JSON representation of the command by hand. std::wstringstream command_value_stream; command_value_stream << command; std::wstring command_value = command_value_stream.str(); std::wstring serialized_command = L"{ \"command\" : " + command_value + L", \"locator\" : " + locator_parameters + L", \"parameters\" : " + request_body + L" }"; bool session_is_valid = this->SendCommandToSession(session_window_handle, serialized_command, &serialized_response); if (!session_is_valid) { this->ShutDownSession(session_id); } } return_code = this->SendResponseToBrowser(conn, request_info, serialized_response); } } return return_code; } bool IEDriverServer::LookupSession(const std::wstring& session_id, HWND* session_window_handle) { SessionMap::iterator it = this->sessions_.find(session_id); if (it == this->sessions_.end()) { return false; } *session_window_handle = it->second; return true; } bool IEDriverServer::SendCommandToSession(const HWND& session_window_handle, const std::wstring& serialized_command, std::wstring* serialized_response) { // Sending a command consists of five actions: // 1. Setting the command to be executed // 2. Executing the command // 3. Waiting for the response to be populated // 4. Retrieving the response // 5. Retrieving whether the command sent caused the session to be ready for shutdown ::SendMessage(session_window_handle, WD_SET_COMMAND, NULL, reinterpret_cast<LPARAM>(serialized_command.c_str())); ::PostMessage(session_window_handle, WD_EXEC_COMMAND, NULL, NULL); int response_length = static_cast<int>(::SendMessage(session_window_handle, WD_GET_RESPONSE_LENGTH, NULL, NULL)); while (response_length == 0) { // Sleep a short time to prevent thread starvation on single-core machines. ::Sleep(10); response_length = static_cast<int>(::SendMessage(session_window_handle, WD_GET_RESPONSE_LENGTH, NULL, NULL)); } // Must add one to the length to handle the terminating character. std::vector<TCHAR> response_buffer(response_length + 1); ::SendMessage(session_window_handle, WD_GET_RESPONSE, NULL, reinterpret_cast<LPARAM>(&response_buffer[0])); *serialized_response = &response_buffer[0]; bool session_is_valid = ::SendMessage(session_window_handle, WD_IS_SESSION_VALID, NULL, NULL) != 0; return session_is_valid; } int IEDriverServer::SendResponseToBrowser(struct mg_connection* conn, const struct mg_request_info* request_info, const std::wstring& serialized_response) { int return_code = 0; if (serialized_response.size() > 0) { Response response; response.Deserialize(serialized_response); if (response.status_code() == 0) { this->SendHttpOk(conn, request_info, serialized_response); return_code = 200; } else if (response.status_code() == 303) { std::string location = response.value().asString(); response.SetResponse(SUCCESS, response.value()); this->SendHttpSeeOther(conn, request_info, location); return_code = 303; } else if (response.status_code() == 400) { this->SendHttpBadRequest(conn, request_info, serialized_response); return_code = 400; } else if (response.status_code() == 404) { this->SendHttpNotFound(conn, request_info, serialized_response); return_code = 404; } else if (response.status_code() == 501) { this->SendHttpNotImplemented(conn, request_info, "Command not implemented"); return_code = 501; } else { this->SendHttpInternalError(conn, request_info, serialized_response); return_code = 500; } } return return_code; } void IEDriverServer::SendWelcomePage(struct mg_connection* connection, const struct mg_request_info* request_info) { std::string page_body = SERVER_DEFAULT_PAGE; std::ostringstream out; out << "HTTP/1.1 200 OK\r\n" << "Content-Length: " << strlen(page_body.c_str()) << "\r\n" << "Content-Type: text/html; charset=UTF-8\r\n" << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" << "Accept-Ranges: bytes\r\n" << "Connection: close\r\n\r\n"; if (strcmp(request_info->request_method, "HEAD") != 0) { out << page_body << "\r\n"; } mg_write(connection, out.str().c_str(), out.str().size()); } // The standard HTTP Status codes are implemented below. Chrome uses // OK, See Other, Not Found, Method Not Allowed, and Internal Error. // Internal Error, HTTP 500, is used as a catch all for any issue // not covered in the JSON protocol. void IEDriverServer::SendHttpOk(struct mg_connection* connection, const struct mg_request_info* request_info, const std::wstring& body) { std::string narrow_body = CW2A(body.c_str(), CP_UTF8); std::ostringstream out; out << "HTTP/1.1 200 OK\r\n" << "Content-Length: " << strlen(narrow_body.c_str()) << "\r\n" << "Content-Type: application/json; charset=UTF-8\r\n" << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" << "Accept-Ranges: bytes\r\n" << "Connection: close\r\n\r\n"; if (strcmp(request_info->request_method, "HEAD") != 0) { out << narrow_body << "\r\n"; } mg_write(connection, out.str().c_str(), out.str().size()); } void IEDriverServer::SendHttpBadRequest(struct mg_connection* const connection, const struct mg_request_info* const request_info, const std::wstring& body) { std::string narrow_body = CW2A(body.c_str(), CP_UTF8); std::ostringstream out; out << "HTTP/1.1 400 Bad Request\r\n" << "Content-Length: " << strlen(narrow_body.c_str()) << "\r\n" << "Content-Type: application/json; charset=UTF-8\r\n" << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" << "Accept-Ranges: bytes\r\n" << "Connection: close\r\n\r\n"; if (strcmp(request_info->request_method, "HEAD") != 0) { out << narrow_body << "\r\n"; } mg_printf(connection, "%s", out.str().c_str()); } void IEDriverServer::SendHttpInternalError(struct mg_connection* connection, const struct mg_request_info* request_info, const std::wstring& body) { std::string narrow_body = CW2A(body.c_str(), CP_UTF8); std::ostringstream out; out << "HTTP/1.1 500 Internal Server Error\r\n" << "Content-Length: " << strlen(narrow_body.c_str()) << "\r\n" << "Content-Type: application/json; charset=UTF-8\r\n" << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" << "Accept-Ranges: bytes\r\n" << "Connection: close\r\n\r\n"; if (strcmp(request_info->request_method, "HEAD") != 0) { out << narrow_body << "\r\n"; } mg_write(connection, out.str().c_str(), out.str().size()); } void IEDriverServer::SendHttpNotFound(struct mg_connection* const connection, const struct mg_request_info* const request_info, const std::wstring& body) { std::string narrow_body = CW2A(body.c_str(), CP_UTF8); std::ostringstream out; out << "HTTP/1.1 404 Not Found\r\n" << "Content-Length: " << strlen(narrow_body.c_str()) << "\r\n" << "Content-Type: application/json; charset=UTF-8\r\n" << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" << "Accept-Ranges: bytes\r\n" << "Connection: close\r\n\r\n"; if (strcmp(request_info->request_method, "HEAD") != 0) { out << narrow_body << "\r\n"; } mg_printf(connection, "%s", out.str().c_str()); } void IEDriverServer::SendHttpMethodNotAllowed(struct mg_connection* connection, const struct mg_request_info* request_info, const std::wstring& allowed_methods) { std::string narrow_body = CW2A(allowed_methods.c_str(), CP_UTF8); std::ostringstream out; out << "HTTP/1.1 405 Method Not Allowed\r\n" << "Content-Type: text/html\r\n" << "Content-Length: 0\r\n" << "Allow: " << narrow_body << "\r\n\r\n"; mg_write(connection, out.str().c_str(), out.str().size()); } void IEDriverServer::SendHttpNotImplemented(struct mg_connection* connection, const struct mg_request_info* request_info, const std::string& body) { std::ostringstream out; out << "HTTP/1.1 501 Not Implemented\r\n" << "Content-Type: text/html\r\n" << "Content-Length: 0\r\n" << "Allow: " << body << "\r\n\r\n"; mg_write(connection, out.str().c_str(), out.str().size()); } void IEDriverServer::SendHttpSeeOther(struct mg_connection* connection, const struct mg_request_info* request_info, const std::string& location) { std::ostringstream out; out << "HTTP/1.1 303 See Other\r\n" << "Location: " << location << "\r\n" << "Content-Type: text/html\r\n" << "Content-Length: 0\r\n\r\n"; mg_write(connection, out.str().c_str(), out.str().size()); } int IEDriverServer::LookupCommand(const std::string& uri, const std::string& http_verb, std::wstring* session_id, std::wstring* locator) { int value = NoCommand; UrlMap::const_iterator it = this->commands_.begin(); for (; it != this->commands_.end(); ++it) { std::vector<std::string> locator_param_names; std::string url_candidate = it->first; size_t param_start_pos = url_candidate.find_first_of(":"); while (param_start_pos != std::string::npos) { size_t param_len = std::string::npos; size_t param_end_pos = url_candidate.find_first_of("/", param_start_pos); if (param_end_pos != std::string::npos) { param_len = param_end_pos - param_start_pos; } // Skip the colon std::string param_name = url_candidate.substr(param_start_pos + 1, param_len - 1); locator_param_names.push_back(param_name); if (param_name == "sessionid" || param_name == "id") { url_candidate.replace(param_start_pos, param_len, "([0-9a-fA-F-]+)"); } else { url_candidate.replace(param_start_pos, param_len, "([^/]+)"); } param_start_pos = url_candidate.find_first_of(":"); } std::string::const_iterator uri_start = uri.begin(); std::string::const_iterator uri_end = uri.end(); std::tr1::regex matcher("^" + url_candidate + "$"); std::tr1::match_results<std::string::const_iterator> matches; if (std::tr1::regex_search(uri_start, uri_end, matches, matcher)) { VerbMap::const_iterator verb_iterator = it->second.find(http_verb); if (verb_iterator != it->second.end()) { value = verb_iterator->second; std::string param = "{"; size_t param_count = locator_param_names.size(); for (unsigned int i = 0; i < param_count; i++) { if (i != 0) { param += ","; } std::string locator_param_value(matches[i + 1].first, matches[i + 1].second); param += " \"" + locator_param_names[i] + "\" : \"" + locator_param_value + "\""; if (locator_param_names[i] == "sessionid") { session_id->append(CA2W(locator_param_value.c_str(), CP_UTF8)); } } param += " }"; std::wstring wide_param(param.begin(), param.end()); locator->append(wide_param); break; } else { verb_iterator = it->second.begin(); for (; verb_iterator != it->second.end(); ++verb_iterator) { if (locator->size() != 0) { locator->append(L","); } locator->append(CA2W(verb_iterator->first.c_str(), CP_UTF8)); } } } } return value; } void IEDriverServer::PopulateCommandRepository() { this->commands_["/session"]["POST"] = NewSession; this->commands_["/session/:sessionid"]["GET"] = GetSessionCapabilities; this->commands_["/session/:sessionid"]["DELETE"] = Quit; this->commands_["/session/:sessionid/window_handle"]["GET"] = GetCurrentWindowHandle; this->commands_["/session/:sessionid/window_handles"]["GET"] = GetWindowHandles; this->commands_["/session/:sessionid/url"]["GET"] = GetCurrentUrl; this->commands_["/session/:sessionid/url"]["POST"] = Get; this->commands_["/session/:sessionid/forward"]["POST"] = GoForward; this->commands_["/session/:sessionid/back"]["POST"] = GoBack; this->commands_["/session/:sessionid/refresh"]["POST"] = Refresh; this->commands_["/session/:sessionid/speed"]["GET"] = GetSpeed; this->commands_["/session/:sessionid/speed"]["POST"] = SetSpeed; this->commands_["/session/:sessionid/execute"]["POST"] = ExecuteScript; this->commands_["/session/:sessionid/execute_async"]["POST"] = ExecuteAsyncScript; this->commands_["/session/:sessionid/screenshot"]["GET"] = Screenshot; this->commands_["/session/:sessionid/frame"]["POST"] = SwitchToFrame; this->commands_["/session/:sessionid/window"]["POST"] = SwitchToWindow; this->commands_["/session/:sessionid/window"]["DELETE"] = Close; this->commands_["/session/:sessionid/cookie"]["GET"] = GetAllCookies; this->commands_["/session/:sessionid/cookie"]["POST"] = AddCookie; this->commands_["/session/:sessionid/cookie"]["DELETE"] = DeleteAllCookies; this->commands_["/session/:sessionid/cookie/:name"]["DELETE"] = DeleteCookie; this->commands_["/session/:sessionid/source"]["GET"] = GetPageSource; this->commands_["/session/:sessionid/title"]["GET"] = GetTitle; this->commands_["/session/:sessionid/element"]["POST"] = FindElement; this->commands_["/session/:sessionid/elements"]["POST"] = FindElements; this->commands_["/session/:sessionid/timeouts/implicit_wait"]["POST"] = ImplicitlyWait; this->commands_["/session/:sessionid/timeouts/async_script"]["POST"] = SetAsyncScriptTimeout; this->commands_["/session/:sessionid/element/active"]["POST"] = GetActiveElement; this->commands_["/session/:sessionid/element/:id/element"]["POST"] = FindChildElement; this->commands_["/session/:sessionid/element/:id/elements"]["POST"] = FindChildElements; this->commands_["/session/:sessionid/element/:id"]["GET"] = DescribeElement; this->commands_["/session/:sessionid/element/:id/click"]["POST"] = ClickElement; this->commands_["/session/:sessionid/element/:id/text"]["GET"] = GetElementText; this->commands_["/session/:sessionid/element/:id/submit"]["POST"] = SubmitElement; this->commands_["/session/:sessionid/element/:id/value"]["GET"] = GetElementValue; this->commands_["/session/:sessionid/element/:id/value"]["POST"] = SendKeysToElement; this->commands_["/session/:sessionid/element/:id/name"]["GET"] = GetElementTagName; this->commands_["/session/:sessionid/element/:id/clear"]["POST"] = ClearElement; this->commands_["/session/:sessionid/element/:id/selected"]["GET"] = IsElementSelected; this->commands_["/session/:sessionid/element/:id/selected"]["POST"] = SetElementSelected; this->commands_["/session/:sessionid/element/:id/toggle"]["POST"] = ToggleElement; this->commands_["/session/:sessionid/element/:id/enabled"]["GET"] = IsElementEnabled; this->commands_["/session/:sessionid/element/:id/displayed"]["GET"] = IsElementDisplayed; this->commands_["/session/:sessionid/element/:id/location"]["GET"] = GetElementLocation; this->commands_["/session/:sessionid/element/:id/location_in_view"]["GET"] = GetElementLocationOnceScrolledIntoView; this->commands_["/session/:sessionid/element/:id/size"]["GET"] = GetElementSize; this->commands_["/session/:sessionid/element/:id/css/:propertyName"]["GET"] = GetElementValueOfCssProperty; this->commands_["/session/:sessionid/element/:id/attribute/:name"]["GET"] = GetElementAttribute; this->commands_["/session/:sessionid/element/:id/equals/:other"]["GET"] = ElementEquals; this->commands_["/session/:sessionid/element/:id/hover"]["POST"] = HoverOverElement; this->commands_["/session/:sessionid/element/:id/drag"]["POST"] = DragElement; this->commands_["/session/:sessionid/screenshot"]["GET"] = Screenshot; this->commands_["/session/:sessionid/accept_alert"]["POST"] = AcceptAlert; this->commands_["/session/:sessionid/dismiss_alert"]["POST"] = DismissAlert; this->commands_["/session/:sessionid/alert_text"]["GET"] = GetAlertText; this->commands_["/session/:sessionid/alert_text"]["POST"] = SendKeysToAlert; this->commands_["/session/:sessionid/modifier"]["POST"] = SendModifierKey; this->commands_["/session/:sessionid/moveto"]["POST"] = MouseMoveTo; this->commands_["/session/:sessionid/click"]["POST"] = MouseClick; this->commands_["/session/:sessionid/doubleclick"]["POST"] = MouseDoubleClick; this->commands_["/session/:sessionid/buttondown"]["POST"] = MouseButtonDown; this->commands_["/session/:sessionid/buttonup"]["POST"] = MouseButtonUp; /* commandDictionary.Add(DriverCommand.DefineDriverMapping, new CommandInfo(CommandInfo.PostCommand, "/config/drivers")); commandDictionary.Add(DriverCommand.SetBrowserVisible, new CommandInfo(CommandInfo.PostCommand, "/session/{sessionId}/visible")); commandDictionary.Add(DriverCommand.IsBrowserVisible, new CommandInfo(CommandInfo.GetCommand, "/session/{sessionId}/visible")); */ } } // namespace webdriver
[ "eran.mes@gmail.com@07704840-8298-11de-bf8c-fd130f914ac9" ]
eran.mes@gmail.com@07704840-8298-11de-bf8c-fd130f914ac9
367bfd33f63c2a4e1e5d68067019fad2cff956d1
06d5fc42053e6449f8abc03ab2000267bf53c7ff
/ex8/boost.cpp
c5967b961233939dfe8c78d8fa61f51582dc8158
[]
no_license
GenosW/many_cores
15ce5733c2b8bdb8c1fa96d69d5bab719be1184b
cb0a36ecaccb9d8d6e8843416733de0b368abb0c
refs/heads/main
2023-02-21T23:23:05.757698
2021-01-24T13:27:22
2021-01-24T13:27:22
306,657,939
0
0
null
null
null
null
UTF-8
C++
false
false
4,304
cpp
#include <vector> #include <string> #include <algorithm> #include <numeric> #include <iostream> #include <fstream> #include <cstdlib> #include "timer.hpp" // boost #include <boost/compute/algorithm/transform.hpp> #include <boost/compute/algorithm/inner_product.hpp> #include <boost/compute/container/vector.hpp> #include <boost/compute/functional/math.hpp> namespace compute = boost::compute; // functions used: // inner_prod(): https://www.boost.org/doc/libs/1_65_1/libs/compute/doc/html/boost/compute/inner_product.html // DEFINES #define EX "ex8" #define CSV_NAME "ph_data_boost_ocl.csv" #define COUT #define NUM_TEST 5 #define N_MIN 10 #define N_MAX 10000000 //1e8 // //----------- Helper functions // template <template <typename, typename> class Container, typename ValueType, typename Allocator = std::allocator<ValueType>> double median(Container<ValueType, Allocator> data) { size_t size = data.size(); if (size == 0) return 0.; sort(data.begin(), data.end()); size_t mid = size / 2; return size % 2 == 0 ? (data[mid] + data[mid - 1]) / 2 : data[mid]; }; template <typename T> double median(T *array, size_t size) { if (size == 0) return 0.; sort(array, array + size); size_t mid = size / 2; return size % 2 == 0 ? (array[mid] + array[mid - 1]) / 2 : array[mid]; }; // //----------- functions for this program // double benchmark(compute::context& context, compute::command_queue& queue, size_t N, double x_init, double y_init, std::vector<double>& results) { Timer timer; timer.reset(); std::vector<double> x(N, x_init); std::vector<double> y(N, y_init); compute::vector<double> X(N, context); compute::vector<double> Y(N, context); compute::vector<double> TMP(N, context); compute::vector<double> TMP2(N, context); compute::copy(x.begin(), x.end(), X.begin(), queue); compute::copy(y.begin(), y.end(), Y.begin(), queue); results[0] = timer.get(); double dot; std::vector<double> tmp(NUM_TEST, 0.0); for (int iter = 0; iter < NUM_TEST; iter++) { timer.reset(); compute::transform(X.begin(), X.end(), Y.begin(), TMP.begin(), compute::plus<double>{}, queue); // I tried to reuse the vector X for the result of the last transform, // but it did not work properly. I assume, that the reason is that these // are asynchronous calls that can happen in parallel, // so it might happen that parts of X // are overwritten before the first is finished. // That seems weird... compute::transform(X.begin(), X.end(), Y.begin(), TMP2.begin(), compute::minus<double>{}, queue); dot = compute::inner_product(TMP.begin(), TMP.end(), TMP2.begin(), 0.0, queue); tmp[iter] = timer.get(); } results[1] = median(tmp); double true_dot = (x_init + y_init) * (x_init - y_init) * N; #ifdef COUT std::cout << "(x+y, x-y) = " << dot << " ?= " << true_dot << std::endl; std::cout << "Computation took " << results[1] << "s" << std::endl; #endif timer.reset(); results[3] = dot; results[2] = timer.get(); return dot; } int main(int argc, char const *argv[]) { // get default device and setup context compute::device device = compute::system::default_device(); compute::context context(device); std::cout << device.name() << std::endl; // print list of selected devices compute::command_queue queue(context, device); double x_init = 1., y_init = 2.; std::vector<double> results(4, 0.0); std::ofstream csv; std::string sep = ";"; std::string header = "N;vec_init_time;dot_time;memcpy_time;dot_result"; auto to_csv = [&csv, &sep] (double x) { csv << sep << x;}; csv.open(CSV_NAME, std::fstream::out | std::fstream::trunc); csv << header << std::endl; for (size_t N = N_MIN; N < 1+N_MAX; N*=10){ #ifdef COUT std::cout << "N: " << N << std::endl; #endif benchmark(context, queue, N, x_init, y_init, results); csv << N; std::for_each(results.begin(), results.end(), to_csv); csv << std::endl; } std::cout << "Data: https://gtx1080.360252.org/2020/" << EX << "/" << CSV_NAME; return EXIT_SUCCESS; }
[ "peter.anton.holzner@student.tuwien.ac.at" ]
peter.anton.holzner@student.tuwien.ac.at
f026d8f08a6ae5356f4e5a6007780494f371e1b7
5963efb46c9bbef73ccb6744ab4a52b6ebd6b305
/Reference_Implementation/crypto_kem/ntru-hrss701/ntru01/enc/syn/systemc/AES256_ECB_ctx_RoundKey.h
fc1d50721fd864fc4fe8558fcce25335954f045b
[]
no_license
Deepsavani/Post-Quantum-Crypto---NTRU
a5c0324c0281a9890fc977eae55cc4432c5dd8bd
5494bd4af96998d4056a17ef425489cf45efbae7
refs/heads/master
2023-03-18T03:15:59.184060
2021-03-16T16:14:22
2021-03-16T16:14:22
348,408,223
0
0
null
null
null
null
UTF-8
C++
false
false
3,753
h
// ============================================================== // File generated on Sun Aug 23 21:46:48 EDT 2020 // Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC v2018.3 (64-bit) // SW Build 2405991 on Thu Dec 6 23:36:41 MST 2018 // IP Build 2404404 on Fri Dec 7 01:43:56 MST 2018 // Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // ============================================================== #ifndef __AES256_ECB_ctx_RoundKey_H__ #define __AES256_ECB_ctx_RoundKey_H__ #include <systemc> using namespace sc_core; using namespace sc_dt; #include <iostream> #include <fstream> struct AES256_ECB_ctx_RoundKey_ram : public sc_core::sc_module { static const unsigned DataWidth = 8; static const unsigned AddressRange = 240; static const unsigned AddressWidth = 8; //latency = 1 //input_reg = 1 //output_reg = 0 sc_core::sc_in <sc_lv<AddressWidth> > address0; sc_core::sc_in <sc_logic> ce0; sc_core::sc_out <sc_lv<DataWidth> > q0; sc_core::sc_in<sc_logic> we0; sc_core::sc_in<sc_lv<DataWidth> > d0; sc_core::sc_in <sc_lv<AddressWidth> > address1; sc_core::sc_in <sc_logic> ce1; sc_core::sc_out <sc_lv<DataWidth> > q1; sc_core::sc_in<sc_logic> we1; sc_core::sc_in<sc_lv<DataWidth> > d1; sc_core::sc_in<sc_logic> reset; sc_core::sc_in<bool> clk; sc_lv<DataWidth> ram[AddressRange]; SC_CTOR(AES256_ECB_ctx_RoundKey_ram) { SC_METHOD(prc_write_0); sensitive<<clk.pos(); SC_METHOD(prc_write_1); sensitive<<clk.pos(); } void prc_write_0() { if (ce0.read() == sc_dt::Log_1) { if (we0.read() == sc_dt::Log_1) { if(address0.read().is_01() && address0.read().to_uint()<AddressRange) { ram[address0.read().to_uint()] = d0.read(); q0 = d0.read(); } else q0 = sc_lv<DataWidth>(); } else { if(address0.read().is_01() && address0.read().to_uint()<AddressRange) q0 = ram[address0.read().to_uint()]; else q0 = sc_lv<DataWidth>(); } } } void prc_write_1() { if (ce1.read() == sc_dt::Log_1) { if (we1.read() == sc_dt::Log_1) { if(address1.read().is_01() && address1.read().to_uint()<AddressRange) { ram[address1.read().to_uint()] = d1.read(); q1 = d1.read(); } else q1 = sc_lv<DataWidth>(); } else { if(address1.read().is_01() && address1.read().to_uint()<AddressRange) q1 = ram[address1.read().to_uint()]; else q1 = sc_lv<DataWidth>(); } } } }; //endmodule SC_MODULE(AES256_ECB_ctx_RoundKey) { static const unsigned DataWidth = 8; static const unsigned AddressRange = 240; static const unsigned AddressWidth = 8; sc_core::sc_in <sc_lv<AddressWidth> > address0; sc_core::sc_in<sc_logic> ce0; sc_core::sc_out <sc_lv<DataWidth> > q0; sc_core::sc_in<sc_logic> we0; sc_core::sc_in<sc_lv<DataWidth> > d0; sc_core::sc_in <sc_lv<AddressWidth> > address1; sc_core::sc_in<sc_logic> ce1; sc_core::sc_out <sc_lv<DataWidth> > q1; sc_core::sc_in<sc_logic> we1; sc_core::sc_in<sc_lv<DataWidth> > d1; sc_core::sc_in<sc_logic> reset; sc_core::sc_in<bool> clk; AES256_ECB_ctx_RoundKey_ram* meminst; SC_CTOR(AES256_ECB_ctx_RoundKey) { meminst = new AES256_ECB_ctx_RoundKey_ram("AES256_ECB_ctx_RoundKey_ram"); meminst->address0(address0); meminst->ce0(ce0); meminst->q0(q0); meminst->we0(we0); meminst->d0(d0); meminst->address1(address1); meminst->ce1(ce1); meminst->q1(q1); meminst->we1(we1); meminst->d1(d1); meminst->reset(reset); meminst->clk(clk); } ~AES256_ECB_ctx_RoundKey() { delete meminst; } };//endmodule #endif
[ "deepsavani@deeps-mbp.myfiosgateway.com" ]
deepsavani@deeps-mbp.myfiosgateway.com
63a2de36c2206c235110b5c98e01c34a320ea358
0e40a0486826825c2c8adba9a538e16ad3efafaf
/S3DWrapper10/Commands/CreateDepthStencilState.h
4f5751791465a803eedf0db965b1a142f7beb4f1
[ "MIT" ]
permissive
iraqigeek/iZ3D
4c45e69a6e476ad434d5477f21f5b5eb48336727
ced8b3a4b0a152d0177f2e94008918efc76935d5
refs/heads/master
2023-05-25T19:04:06.082744
2020-12-28T03:27:55
2020-12-28T03:27:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,461
h
#pragma once #include "Command.h" #include <memory.h> namespace Commands { class CreateDepthStencilState : public CommandWithAllocator<CreateDepthStencilState> { public: CreateDepthStencilState() { CommandId = idCreateDepthStencilState; } CreateDepthStencilState(const D3D10_DDI_DEPTH_STENCIL_DESC* pDepthStencilDesc, D3D10DDI_HDEPTHSTENCILSTATE hDepthStencilState, D3D10DDI_HRTDEPTHSTENCILSTATE hRTDepthStencilState) { CommandId = idCreateDepthStencilState; memcpy(&DepthStencilDesc_, pDepthStencilDesc, sizeof(D3D10_DDI_DEPTH_STENCIL_DESC)); hDepthStencilState_ = hDepthStencilState; hRTDepthStencilState_ = hRTDepthStencilState; } virtual void Execute ( D3DDeviceWrapper *pWrapper ); virtual bool WriteToFile ( D3DDeviceWrapper *pWrapper ) const; virtual bool WriteToFileSimple( D3DDeviceWrapper *pWrapper ) const { return WriteToFile(pWrapper); } virtual bool ReadFromFile(); void BuildCommand(CDumpState *ds); public: D3D10_DDI_DEPTH_STENCIL_DESC DepthStencilDesc_; D3D10DDI_HDEPTHSTENCILSTATE hDepthStencilState_; D3D10DDI_HRTDEPTHSTENCILSTATE hRTDepthStencilState_; CREATES(hDepthStencilState_); }; } VOID ( APIENTRY CreateDepthStencilState )( D3D10DDI_HDEVICE hDevice, CONST D3D10_DDI_DEPTH_STENCIL_DESC* pDepthStencilDesc, D3D10DDI_HDEPTHSTENCILSTATE hDepthStencilState, D3D10DDI_HRTDEPTHSTENCILSTATE hRTDepthStencilState );
[ "github@bo3b.net" ]
github@bo3b.net
11ae714ac88a2569573f685843e77bfcfe0921d2
8f588242dc7ff6ff4e19d05022fea095b93fc070
/transportInc/System/construct/insertPlate.cxx
90ea9f23312c7bf1bd1e80f20e89ebb51a8819c5
[]
no_license
milocco/sinbad
fe768462b26b2cfa5f0bf4ea76d9ba211fb2fc13
60a9d3e6e4abf8f701a97ed4ba8b3c62d5d0c9b2
refs/heads/master
2021-01-15T23:11:57.499083
2016-02-14T23:31:59
2016-02-14T23:31:59
30,890,395
0
0
null
null
null
null
UTF-8
C++
false
false
9,120
cxx
/********************************************************************* CombLayer : MCNP(X) Input builder * File: construct/insertPlate.cxx * * Copyright (c) 2004-2015 by Stuart Ansell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ****************************************************************************/ #include <fstream> #include <iomanip> #include <iostream> #include <sstream> #include <cmath> #include <complex> #include <list> #include <vector> #include <set> #include <map> #include <string> #include <algorithm> #include <memory> #include "Exception.h" #include "FileReport.h" #include "GTKreport.h" #include "NameStack.h" #include "RegMethod.h" #include "OutputLog.h" #include "BaseVisit.h" #include "BaseModVisit.h" #include "support.h" #include "MatrixBase.h" #include "Matrix.h" #include "Vec3D.h" #include "Quaternion.h" #include "Surface.h" #include "surfIndex.h" #include "surfRegister.h" #include "objectRegister.h" #include "surfEqual.h" #include "Quadratic.h" #include "Plane.h" #include "Cylinder.h" #include "Line.h" #include "LineIntersectVisit.h" #include "Rules.h" #include "varList.h" #include "Code.h" #include "FuncDataBase.h" #include "HeadRule.h" #include "Object.h" #include "Qhull.h" #include "Simulation.h" #include "ModelSupport.h" #include "MaterialSupport.h" #include "generateSurf.h" #include "LinkUnit.h" #include "FixedComp.h" #include "ContainedComp.h" #include "insertPlate.h" namespace ModelSupport { insertPlate::insertPlate(const std::string& Key) : attachSystem::ContainedComp(),attachSystem::FixedComp(Key,6), ptIndex(ModelSupport::objectRegister::Instance().cell(Key)), cellIndex(ptIndex+31),populated(0), zAngle(0.0),xyAngle(0.0),defMat(0) /*! Constructor BUT ALL variable are left unpopulated. \param Key :: Name for item in search */ {} insertPlate::insertPlate(const insertPlate& A) : attachSystem::ContainedComp(A),attachSystem::FixedComp(A), ptIndex(A.ptIndex),cellIndex(A.cellIndex), populated(A.populated),zAngle(A.zAngle),xyAngle(A.xyAngle), width(A.width),height(A.height),depth(A.depth),defMat(A.defMat) /*! Copy constructor \param A :: insertPlate to copy */ {} insertPlate& insertPlate::operator=(const insertPlate& A) /*! Assignment operator \param A :: insertPlate to copy \return *this */ { if (this!=&A) { attachSystem::ContainedComp::operator=(A); attachSystem::FixedComp::operator=(A); cellIndex=A.cellIndex; populated=A.populated; zAngle=A.zAngle; xyAngle=A.xyAngle; width=A.width; height=A.height; depth=A.depth; defMat=A.defMat; } return *this; } insertPlate::~insertPlate() /*! Destructor */ {} void insertPlate::populate(const FuncDataBase& Control) /*! Populate all the variables \param Control :: Data Basex */ { ELog::RegMethod RegA("insertPlate","populate"); zAngle=Control.EvalVar<double>(keyName+"ZAngle"); xyAngle=Control.EvalVar<double>(keyName+"XYAngle"); width=Control.EvalVar<double>(keyName+"Width"); height=Control.EvalVar<double>(keyName+"Height"); depth=Control.EvalVar<double>(keyName+"Depth"); defMat=ModelSupport::EvalMat<int>(Control,keyName+"DefMat"); populated=1; return; } void insertPlate::createUnitVector(const Geometry::Vec3D& OG, const attachSystem::FixedComp& FC) /*! Create the unit vectors \param OG :: Origin \param LC :: LinearComponent to attach to */ { ELog::RegMethod RegA("insertPlate","createUnitVector"); FixedComp::createUnitVector(FC); createUnitVector(OG,X,Y,Z); return; } void insertPlate::createUnitVector(const Geometry::Vec3D& OG, const Geometry::Vec3D& XUnit, const Geometry::Vec3D& YUnit, const Geometry::Vec3D& ZUnit) /*! Create the unit vectors \param OG :: Origin \param XUnit :: Xdirection \param YUnit :: Xdirection \param ZUnit :: Xdirection */ { ELog::RegMethod RegA("insertPlate","createUnitVector<Vec>"); X=XUnit.unit(); Y=YUnit.unit(); Z=ZUnit.unit(); const Geometry::Quaternion Qz= Geometry::Quaternion::calcQRotDeg(zAngle,X); const Geometry::Quaternion Qxy= Geometry::Quaternion::calcQRotDeg(xyAngle,Z); Qz.rotate(Y); Qz.rotate(Z); Qxy.rotate(Y); Qxy.rotate(X); Qxy.rotate(Z); Origin=OG; return; } void insertPlate::createSurfaces() /*! Create all the surfaces */ { ELog::RegMethod RegA("insertPlate","createSurface"); ModelSupport::buildPlane(SMap,ptIndex+1,Origin-Y*depth/2.0,Y); ModelSupport::buildPlane(SMap,ptIndex+2,Origin+Y*depth/2.0,Y); ModelSupport::buildPlane(SMap,ptIndex+3,Origin-X*width/2.0,X); ModelSupport::buildPlane(SMap,ptIndex+4,Origin+X*width/2.0,X); ModelSupport::buildPlane(SMap,ptIndex+5,Origin-Z*height/2.0,Z); ModelSupport::buildPlane(SMap,ptIndex+6,Origin+Z*height/2.0,Z); return; } void insertPlate::createLinks() /*! Create link pointsx */ { ELog::RegMethod RegA("insertPlate","createLinks"); const double T[3]={depth,width,height}; const Geometry::Vec3D Dir[3]={Y,X,Z}; for(size_t i=0;i<6;i++) { const double SN((i%2) ? 1.0 : -1.0); FixedComp::setConnect(i,Origin+Dir[i/2]*T[i/2],Dir[i/2]*SN); FixedComp::setLinkSurf(i,SMap.realSurf(ptIndex+1+static_cast<int>(i))); } return; } void insertPlate::createObjects(Simulation& System) /*! Adds the Chip guide components \param System :: Simulation to create objects in */ { ELog::RegMethod RegA("insertPlate","createObjects"); std::string Out= ModelSupport::getComposite(SMap,ptIndex,"1 -2 3 -4 5 -6"); addOuterSurf(Out); if (defMat<0) System.addCell(MonteCarlo::Qhull(cellIndex++,0,0.0,Out)); else System.addCell(MonteCarlo::Qhull(cellIndex++,defMat,0.0,Out)); return; } void insertPlate::findObjects(const Simulation& System) /*! Insert the objects into the main simulation. It is separated from creation since we need to determine those object that need to have an exclude item added to them. \param System :: Simulation to add object to */ { ELog::RegMethod RegA("insertPlate","findObjects"); std::set<int> ICells; // Process all the corners MonteCarlo::Object* OPtr(System.findCell(Origin,0)); if (OPtr) ICells.insert(OPtr->getName()); for(int i=0;i<8;i++) { const double mX((i%2) ? -1.0 : 1.0); const double mY(((i>>1)%2) ? -1.0 : 1.0); const double mZ(((i>>2)%2) ? -1.0 : 1.0); Geometry::Vec3D TP(Origin); TP+=X*(mX*depth/2.0); TP+=Y*(mY*depth/2.0); TP+=Z*(mZ*depth/2.0); OPtr=System.findCell(TP,OPtr); if (OPtr) ICells.insert(OPtr->getName()); } for(const int IC : ICells) attachSystem::ContainedComp::addInsertCell(IC); return; } void insertPlate::setValues(const double XS,const double YS, const double ZS,const int Mat) /*! Set the values and populate flag \param XS :: X-size [width] \param YS :: Y-size [depth] \param ZS :: Z-size [height] \param Mat :: Material number */ { width=XS; depth=YS; height=ZS; defMat=Mat; populated=1; return; } void insertPlate::mainAll(Simulation& System) /*! Common part to createAll \param System :: Simulation */ { ELog::RegMethod RegA("insertPlate","mainAll"); createSurfaces(); createObjects(System); createLinks(); findObjects(System); insertObjects(System); return; } void insertPlate::createAll(Simulation& System,const Geometry::Vec3D& OG, const attachSystem::FixedComp& FC) /*! Generic function to create everything \param System :: Simulation item \param FC :: Linear component to set axis etc */ { ELog::RegMethod RegA("insertPlate","createAll"); if (!populated) populate(System.getDataBase()); createUnitVector(OG,FC); mainAll(System); return; } void insertPlate::createAll(Simulation& System,const Geometry::Vec3D& OG, const Geometry::Vec3D& Xunit, const Geometry::Vec3D& Yunit, const Geometry::Vec3D& Zunit) /*! Generic function to create everything \param System :: Simulation item \param OG :: Origin \param XUnit :: X-direction \param YUnit :: Y-direction \param ZUnit :: Z-direction */ { ELog::RegMethod RegA("insertPlate","createAll<vec>"); if (!populated) populate(System.getDataBase()); createUnitVector(OG,Xunit,Yunit,Zunit); mainAll(System); return; } } // NAMESPACE shutterSystem
[ "alberto.milocco@gmail.com" ]
alberto.milocco@gmail.com
68c93b16f9e4a99cff2675eb8731d261e8e014e9
8f3f67b62569a2104bb534486cac0aca019dd223
/include/SDIMCompiler/ScopingBlock.hpp
fe0b751e9e32807d726d982beb45f3b1f76e9692
[ "MIT" ]
permissive
DamienHenderson/SDIM
872122b64d9f0055af25f578cc9292fc32a47f88
623ac00402a68a504451c3b7c76cd16fde2fa57e
refs/heads/master
2020-04-19T03:22:54.326678
2019-05-30T03:22:17
2019-05-30T03:22:17
167,932,615
0
0
null
null
null
null
UTF-8
C++
false
false
1,079
hpp
#pragma once #include "Types.hpp" #include <unordered_map> #include <string> namespace SDIM { // Scoping block // has it's own set of key value pairs of strings to variables // each scoping block is completely self contained // variables in scopes closer to the current scoping block have precedence over variables in higher scopes (for example variables in function scope have precedence over variables in global scope) class ScopingBlock { public: ScopingBlock(const std::string& scope_name) : scope_name_(scope_name) {} ~ScopingBlock() {} /// returns true if the variable was successfully added /// returns false if the variable was not added bool AddVariable(const std::string& var_name, const Variable& var); /// Returns the current value of a variable /// If the variable doesn't exist the variable will have it's type set to unknown Variable GetVariable(const std::string& var_name); void PrintScope() const; std::string GetName() const; private: std::unordered_map<std::string, Variable> variables_; std::string scope_name_; }; }
[ "damien.henderson97@gmail.com" ]
damien.henderson97@gmail.com
be2bb0f66c5a044b890db47d0bf81d0a13bea092
5105bdcb3fe6e73df70ebf77bb1a8343efb96425
/simd_helpers/simd_trimatrix.hpp
53c0ac5b2a32bcf07bcdbaed52d5d78ecae19860
[]
no_license
kmsmith137/simd_helpers
6b642040574bda8e4cddb4f138ed0349c56858bf
ba14240db3f6ff6d7dce824752076e208cf96140
refs/heads/master
2022-03-16T06:37:04.764112
2022-03-03T18:07:53
2022-03-03T18:07:53
75,947,098
4
1
null
2022-03-03T18:07:54
2016-12-08T14:55:18
C++
UTF-8
C++
false
false
7,426
hpp
#ifndef _SIMD_HELPERS_SIMD_TRIMATRIX_HPP #define _SIMD_HELPERS_SIMD_TRIMATRIX_HPP #if (__cplusplus < 201103) && !defined(__GXX_EXPERIMENTAL_CXX0X__) #error "This source file needs to be compiled with C++11 support (g++ -std=c++11)" #endif #include "core.hpp" #include "simd_ntuple.hpp" namespace simd_helpers { #if 0 } // pacify emacs c-mode #endif template<typename T, int S, int N> struct simd_trimatrix { simd_trimatrix<T,S,N-1> m; simd_ntuple<T,S,N> v; simd_trimatrix() { } simd_trimatrix(const simd_trimatrix<T,S,N-1> &m_, const simd_ntuple<T,S,N> &v_) : m(m_), v(v_) { } inline void setzero() { m.setzero(); v.setzero(); } inline void set_identity() { m.set_identity(); v.v.setzero(); v.x = 1; } inline void loadu(const T *p) { m.loadu(p); v.loadu(p+(N*(N-1)*S)/2); } inline void storeu(T *p) const { m.storeu(p); v.storeu(p+(N*(N-1)*S)/2); } inline simd_trimatrix<T,S,N> &operator+=(const simd_trimatrix<T,S,N> &t) { m += t.m; v += t.v; return *this; } inline simd_trimatrix<T,S,N> &operator-=(const simd_trimatrix<T,S,N> &t) { m -= t.m; v -= t.v; return *this; } inline simd_trimatrix<T,S,N> &operator*=(const simd_trimatrix<T,S,N> &t) { m *= t.m; v *= t.v; return *this; } inline simd_trimatrix<T,S,N> &operator/=(const simd_trimatrix<T,S,N> &t) { m /= t.m; v /= t.v; return *this; } inline simd_trimatrix<T,S,N> operator+(const simd_trimatrix<T,S,N> &t) const { simd_trimatrix<T,S,N> ret; ret.m = m + t.m; ret.v = v + t.v; return ret; } inline simd_trimatrix<T,S,N> operator-(const simd_trimatrix<T,S,N> &t) const { simd_trimatrix<T,S,N> ret; ret.m = m - t.m; ret.v = v - t.v; return ret; } inline simd_trimatrix<T,S,N> operator*(const simd_trimatrix<T,S,N> &t) const { simd_trimatrix<T,S,N> ret; ret.m = m * t.m; ret.v = v * t.v; return ret; } inline simd_trimatrix<T,S,N> operator/(const simd_trimatrix<T,S,N> &t) const { simd_trimatrix<T,S,N> ret; ret.m = m / t.m; ret.v = v / t.v; return ret; } // vertical_sum(): returns elementwise sum of all simd_t's in the triangular matrix inline simd_t<T,S> _vertical_sum(simd_t<T,S> x) const { return m._vertical_sum(x + v.vertical_sum()); } inline simd_t<T,S> vertical_sum() const { return m._vertical_sum(v.vertical_sum()); } inline void horizontal_sum_in_place() { m.horizontal_sum_in_place(); v.horizontal_sum_in_place(); } // sum(): returns sum of all scalar elements in the matrix inline T sum() const { return this->vertical_sum().sum(); } // In-register linear algebra inlines start here. inline simd_ntuple<T,S,N> multiply_symmetric(const simd_ntuple<T,S,N> &t) const { simd_ntuple<T,S,N> ret; ret.v = this->m.multiply_symmetric(t.v) + this->v.v * t.x; ret.x = this->v.vertical_dot(t); return ret; } inline void multiply_lower_in_place(simd_ntuple<T,S,N> &t) const { t.x = this->v.vertical_dot(t); this->m.multiply_lower_in_place(t.v); } inline void multiply_upper_in_place(simd_ntuple<T,S,N> &t) const { this->m.multiply_upper_in_place(t.v); t.v += this->v.v * t.x; t.x *= this->v.x; } inline void solve_lower_in_place(simd_ntuple<T,S,N> &t) const { this->m.solve_lower_in_place(t.v); t.x = this->v.v._vertical_dotn(t.v, t.x) / this->v.x; } inline void solve_upper_in_place(simd_ntuple<T,S,N> &t) const { t.x /= this->v.x; t.v -= this->v.v * t.x; this->m.solve_upper_in_place(t.v); } inline void cholesky_in_place() { m.cholesky_in_place(); m.solve_lower_in_place(v.v); simd_t<T,S> u = v.v._vertical_dotn(v.v, v.x); v.x = u.sqrt(); } inline void decholesky_in_place() { v.x = v.vertical_dot(v); m.multiply_lower_in_place(v.v); m.decholesky_in_place(); } // Returns 0xff.. if Cholesky factorization succeeded, 0 if poorly conditioned. inline smask_t<T,S> cholesky_in_place_checked(simd_t<T,S> epsilon) { smask_t<T,S> flags = m.cholesky_in_place_checked(epsilon); m.solve_lower_in_place(v.v); simd_t<T,S> u = v.v._vertical_dotn(v.v, v.x); simd_t<T,S> u0 = epsilon * v.x; flags = flags.bitwise_and(u.compare_gt(u0)); // This ensures that even when the Cholesky factorization is poorly conditioned, the // Cholesky factor can still be passed to solve_*_in_place() without generating NaN's u = blendv(flags, u, simd_t<T,S> (1.0)); v.x = u.sqrt(); return flags; } inline simd_ntuple<T,S,N> multiply_lower(const simd_ntuple<T,S,N> &t) const { simd_ntuple<T,S,N> ret = t; multiply_lower_in_place(ret); return ret; } inline simd_ntuple<T,S,N> multiply_upper(const simd_ntuple<T,S,N> &t) const { simd_ntuple<T,S,N> ret = t; multiply_upper_in_place(ret); return ret; } inline simd_ntuple<T,S,N> solve_lower(const simd_ntuple<T,S,N> &t) const { simd_ntuple<T,S,N> ret = t; solve_lower_in_place(ret); return ret; } inline simd_ntuple<T,S,N> solve_upper(const simd_ntuple<T,S,N> &t) const { simd_ntuple<T,S,N> ret = t; solve_upper_in_place(ret); return ret; } inline simd_trimatrix<T,S,N> cholesky() const { simd_trimatrix<T,S,N> ret = *this; ret.cholesky_in_place(); return ret; } inline simd_trimatrix<T,S,N> decholesky() const { simd_trimatrix<T,S,N> ret = *this; ret.decholesky_in_place(); return ret; } }; template<typename T, int S> struct simd_trimatrix<T,S,0> { inline void setzero() { } inline void loadu(const T *p) { } inline void storeu(T *p) const { } inline simd_trimatrix<T,S,0> &operator+=(const simd_trimatrix<T,S,0> &t) { return *this; } inline simd_trimatrix<T,S,0> &operator-=(const simd_trimatrix<T,S,0> &t) { return *this; } inline simd_trimatrix<T,S,0> &operator*=(const simd_trimatrix<T,S,0> &t) { return *this; } inline simd_trimatrix<T,S,0> &operator/=(const simd_trimatrix<T,S,0> &t) { return *this; } inline simd_trimatrix<T,S,0> operator+(const simd_trimatrix<T,S,0> &t) const { return simd_trimatrix<T,S,0>(); } inline simd_trimatrix<T,S,0> operator-(const simd_trimatrix<T,S,0> &t) const { return simd_trimatrix<T,S,0>(); } inline simd_trimatrix<T,S,0> operator*(const simd_trimatrix<T,S,0> &t) const { return simd_trimatrix<T,S,0>(); } inline simd_trimatrix<T,S,0> operator/(const simd_trimatrix<T,S,0> &t) const { return simd_trimatrix<T,S,0>(); } inline simd_t<T,S> _vertical_sum(simd_t<T,S> x) const { return x; } inline simd_ntuple<T,S,0> multiply_lower_in_place(const simd_ntuple<T,S,0> &t) const { return simd_ntuple<T,S,0> (); } inline simd_ntuple<T,S,0> multiply_upper_in_place(const simd_ntuple<T,S,0> &t) const { return simd_ntuple<T,S,0> (); } inline simd_ntuple<T,S,0> multiply_symmetric(const simd_ntuple<T,S,0> &t) const { return simd_ntuple<T,S,0> (); } inline simd_ntuple<T,S,0> solve_lower_in_place(const simd_ntuple<T,S,0> &t) const { return simd_ntuple<T,S,0> (); } inline simd_ntuple<T,S,0> solve_upper_in_place(const simd_ntuple<T,S,0> &t) const { return simd_ntuple<T,S,0> (); } inline void horizontal_sum_in_place() { } inline void cholesky_in_place() { } inline void decholesky_in_place() { } inline smask_t<T,S> cholesky_in_place_checked(simd_t<T,S> epsilon) { return smask_t<T,S>(-1); } }; } // namespace simd_helpers #endif // _SIMD_HELPERS_SIMD_TRIMATRIX_HPP
[ "kmsmith@perimeterinstitute.ca" ]
kmsmith@perimeterinstitute.ca
3880b95823533733f57be0432ef23e78c1cf9bff
c93ac2f725f4ea1e09ec3178dee52de56a41783a
/SPOJ/BC.cpp
d6139012ee4e7d87eccdeb1bc77482d5daf77ce6
[]
no_license
TheStranger512/Competitive-Programming-Stuff
4b51f140907c044616c28b14db28e881ee9d2f41
66824e816b1f3ee113e29444dab3506a668c437d
refs/heads/master
2021-01-21T01:26:36.676309
2014-01-22T08:18:01
2014-01-22T08:18:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,164
cpp
/* Solved * 9935. Break the Chocolate * File: BC.cpp * Author: Andy Y.F. Huang * Created on September 30, 2012, 12:30 PM */ #include <cstdio> #include <iostream> #include <cmath> #include <algorithm> #include <stack> #include <vector> #include <queue> #include <string> #include <cstring> #include <fstream> #include <set> #include <map> #include <sstream> #include <deque> #include <cassert> #ifdef AZN #include "Azn.cpp" #endif using namespace std; /** * Solved * @author Andy Y.F. Huang */ namespace BC { void solve(int test_num) { int a, b, c; scanf("%d %d %d", &a, &b, &c); long long vol = 1LL * a * b * c; int cuts = 0; while (a > 1 || b > 1 || c > 1) { int high = max(a, max(b, c)); if (high == a) a = (a + 1) >> 1; else if (high == b) b = (b + 1) >> 1; else c = (c + 1) >> 1; cuts++; } printf("Case #%d: %lld %d\n", test_num, vol - 1, cuts); } void solve() { #ifdef AZN freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int tests; scanf("%d", &tests); for (int i = 1; i <= tests; i++) solve(i); } } int main() { BC::solve(); return 0; }
[ "huang.yf.andy@live.ca" ]
huang.yf.andy@live.ca
24da316d0ca01b5796c3b78957daa40d9823e0b6
5f8d9d61075c2f3e604b3ad21eb20a7b5b581184
/Project4/MapLoader.cpp
9dfeda72aced785120ad4f4d34918a5636af01c7
[]
no_license
olivergoch/Computer-Science-32
16d85f03bcd2d69c24538920c13bf186151231b1
a281bc292bb9dace9f8939a9af90fd0511603f94
refs/heads/master
2020-03-27T21:30:16.120638
2018-09-03T04:14:55
2018-09-03T04:14:55
147,149,959
0
0
null
null
null
null
UTF-8
C++
false
false
2,956
cpp
#include "provided.h" #include <string> #include <vector> #include <fstream> using namespace std; class MapLoaderImpl { public: MapLoaderImpl(); ~MapLoaderImpl(); bool load(string mapFile); size_t getNumSegments() const; bool getSegment(size_t segNum, StreetSegment& seg) const; private: vector<StreetSegment> m_segs; int m_numSegs; }; MapLoaderImpl::MapLoaderImpl() { m_numSegs = 0; } MapLoaderImpl::~MapLoaderImpl() { } bool MapLoaderImpl::load(string mapFile) { ifstream infile(mapFile); if(!infile) { return false; exit(1); } string line; int lineNum = 0; //total number of attractions int totalAttract = 0; //current number of attractions int numOfAttract = 0; while (getline(infile, line)) { if(lineNum == 0){ StreetSegment newSeg; m_segs.push_back(newSeg); m_segs[m_numSegs].streetName = line; lineNum++; } else if(lineNum == 1) { GeoCoord start(line.substr(0,10), line.substr(12,12)); GeoCoord end(line.substr(25, 10), line.substr(36, 12)); m_segs[m_numSegs].segment.start = start; m_segs[m_numSegs].segment.end = end; lineNum++; } else if(lineNum == 2) { totalAttract = stoi(line); if(totalAttract == 0) { lineNum = 0; m_numSegs++; } else lineNum++; } else if(lineNum > 2) { m_segs[m_numSegs].attractions.push_back(*new Attraction); size_t pos = line.find('|'); m_segs[m_numSegs].attractions[numOfAttract].name = line.substr(0, pos); GeoCoord place(line.substr(pos+1, 10), line.substr(pos+13, 12)); m_segs[m_numSegs].attractions[numOfAttract].geocoordinates = place; numOfAttract++; if(numOfAttract == totalAttract) { lineNum = 0; m_numSegs++; numOfAttract = 0; } } } return true; } size_t MapLoaderImpl::getNumSegments() const { return m_numSegs; } bool MapLoaderImpl::getSegment(size_t segNum, StreetSegment &seg) const { if(segNum >= m_numSegs) return false; seg = m_segs[segNum]; return true; } //******************** MapLoader functions ************************************ // These functions simply delegate to MapLoaderImpl's functions. // You probably don't want to change any of this code. MapLoader::MapLoader() { m_impl = new MapLoaderImpl; } MapLoader::~MapLoader() { delete m_impl; } bool MapLoader::load(string mapFile) { return m_impl->load(mapFile); } size_t MapLoader::getNumSegments() const { return m_impl->getNumSegments(); } bool MapLoader::getSegment(size_t segNum, StreetSegment& seg) const { return m_impl->getSegment(segNum, seg); }
[ "the.oliver.goch@gmail.com" ]
the.oliver.goch@gmail.com
78b3ead3b247720b2db601b5277611e02857d878
8ea53d45e88f919f94b7050bb2856e4d86d0329f
/Assignment4/bai4_1.cpp
48941a4bd4d383c26e8b209efd9cb2d9d16e5683
[]
no_license
newstar94/VyTDuong-LBEP
be4d53724743bd428330a7c6e475de43cb21a8b0
c47e9b6a99a340b8b10819eea40dce48d3afabcc
refs/heads/main
2023-05-08T07:39:49.930954
2021-06-05T09:04:22
2021-06-05T09:04:22
367,024,519
0
0
null
null
null
null
UTF-8
C++
false
false
152
cpp
#include <stdio.h> #include <math.h> int main(){ double s,n; s=0; n=0; while (n<100001){ s=s+n; n++; } printf("Tong day so la: %.0lf",s); }
[ "77623864+newstar94@users.noreply.github.com" ]
77623864+newstar94@users.noreply.github.com
c060a6b98f2ff592c9ae0a6eefd94a151e30fa43
772d932a0e5f6849227a38cf4b154fdc21741c6b
/CPP_Joc_Windows_Android/SH_Client_Win_Cpp_Cmake/App/src/base/component/IComponent_UIView.cpp
1241a87e5cc203a22966d56bd01ac8281f236116
[]
no_license
AdrianNostromo/CodeSamples
1a7b30fb6874f2059b7d03951dfe529f2464a3c0
a0307a4b896ba722dd520f49d74c0f08c0e0042c
refs/heads/main
2023-02-16T04:18:32.176006
2021-01-11T17:47:45
2021-01-11T17:47:45
328,739,437
0
0
null
null
null
null
UTF-8
C++
false
false
258
cpp
#include "IComponent_UIView.h" #include <base/exceptions/LogicException.h> #include "ComponentsHandler.h" int IComponent_UIView::COMPONENT_CATEGORY = GetNew_COMPONENT_CATEGORY(); int IComponent_UIView::getComponentCategory() { return COMPONENT_CATEGORY; }
[ "adriannostromo@gmail.com" ]
adriannostromo@gmail.com
727fe622abd40599079460362a90d4be30213f46
de7e771699065ec21a340ada1060a3cf0bec3091
/core/src/java/org/apache/lucene/codecs/blocktree/SegmentTermsEnumFrame.cpp
42fe22190d478ec12a1ef715bf9a84f1837b826c
[]
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
22,113
cpp
using namespace std; #include "SegmentTermsEnumFrame.h" #include "../../index/IndexOptions.h" #include "../../store/ByteArrayDataInput.h" #include "../../util/ArrayUtil.h" #include "../../util/BytesRef.h" #include "../BlockTermState.h" #include "SegmentTermsEnum.h" namespace org::apache::lucene::codecs::blocktree { using BlockTermState = org::apache::lucene::codecs::BlockTermState; using IndexOptions = org::apache::lucene::index::IndexOptions; using SeekStatus = org::apache::lucene::index::TermsEnum::SeekStatus; using ByteArrayDataInput = org::apache::lucene::store::ByteArrayDataInput; using ArrayUtil = org::apache::lucene::util::ArrayUtil; using BytesRef = org::apache::lucene::util::BytesRef; using FST = org::apache::lucene::util::fst::FST; SegmentTermsEnumFrame::SegmentTermsEnumFrame(shared_ptr<SegmentTermsEnum> ste, int ord) : ord(ord), state(ste->fr->parent->postingsReader->newTermState()), longs(std::deque<int64_t>(ste->fr->longsSize)), ste(ste) { this->state->totalTermFreq = -1; } void SegmentTermsEnumFrame::setFloorData(shared_ptr<ByteArrayDataInput> in_, shared_ptr<BytesRef> source) { constexpr int numBytes = source->length - (in_->getPosition() - source->offset); if (numBytes > floorData.size()) { floorData = std::deque<char>(ArrayUtil::oversize(numBytes, 1)); } System::arraycopy(source->bytes, source->offset + in_->getPosition(), floorData, 0, numBytes); floorDataReader->reset(floorData, 0, numBytes); numFollowFloorBlocks = floorDataReader->readVInt(); nextFloorLabel = floorDataReader->readByte() & 0xff; // if (DEBUG) { // System.out.println(" setFloorData fpOrig=" + fpOrig + " bytes=" + new // BytesRef(source.bytes, source.offset + in.getPosition(), numBytes) + " // numFollowFloorBlocks=" + numFollowFloorBlocks + " nextFloorLabel=" + // toHex(nextFloorLabel)); //} } int SegmentTermsEnumFrame::getTermBlockOrd() { return isLeafBlock ? nextEnt : state->termBlockOrd; } void SegmentTermsEnumFrame::loadNextFloorBlock() { // if (DEBUG) { // System.out.println(" loadNextFloorBlock fp=" + fp + " fpEnd=" + fpEnd); //} assert((arc == nullptr || isFloor, L"arc=" + arc + L" isFloor=" + StringHelper::toString(isFloor))); fp = fpEnd; nextEnt = -1; loadBlock(); } void SegmentTermsEnumFrame::loadBlock() { // Clone the IndexInput lazily, so that consumers // that just pull a TermsEnum to // seekExact(TermState) don't pay this cost: ste->initIndexInput(); if (nextEnt != -1) { // Already loaded return; } // System.out.println("blc=" + blockLoadCount); ste->in_->seek(fp); int code = ste->in_->readVInt(); entCount = static_cast<int>(static_cast<unsigned int>(code) >> 1); assert(entCount > 0); isLastInFloor = (code & 1) != 0; assert((arc == nullptr || (isLastInFloor || isFloor), L"fp=" + to_wstring(fp) + L" arc=" + arc + L" isFloor=" + StringHelper::toString(isFloor) + L" isLastInFloor=" + StringHelper::toString(isLastInFloor))); // TODO: if suffixes were stored in random-access // array structure, then we could do binary search // instead of linear scan to find target term; eg // we could have simple array of offsets // term suffixes: code = ste->in_->readVInt(); isLeafBlock = (code & 1) != 0; int numBytes = static_cast<int>(static_cast<unsigned int>(code) >> 1); if (suffixBytes.size() < numBytes) { suffixBytes = std::deque<char>(ArrayUtil::oversize(numBytes, 1)); } ste->in_->readBytes(suffixBytes, 0, numBytes); suffixesReader->reset(suffixBytes, 0, numBytes); /*if (DEBUG) { if (arc == null) { System.out.println(" loadBlock (next) fp=" + fp + " entCount=" + entCount + " prefixLen=" + prefix + " isLastInFloor=" + isLastInFloor + " leaf?=" + isLeafBlock); } else { System.out.println(" loadBlock (seek) fp=" + fp + " entCount=" + entCount + " prefixLen=" + prefix + " hasTerms?=" + hasTerms + " isFloor?=" + isFloor + " isLastInFloor=" + isLastInFloor + " leaf?=" + isLeafBlock); } }*/ // stats numBytes = ste->in_->readVInt(); if (statBytes.size() < numBytes) { statBytes = std::deque<char>(ArrayUtil::oversize(numBytes, 1)); } ste->in_->readBytes(statBytes, 0, numBytes); statsReader->reset(statBytes, 0, numBytes); metaDataUpto = 0; state->termBlockOrd = 0; nextEnt = 0; lastSubFP = -1; // TODO: we could skip this if !hasTerms; but // that's rare so won't help much // metadata numBytes = ste->in_->readVInt(); if (bytes.size() < numBytes) { bytes = std::deque<char>(ArrayUtil::oversize(numBytes, 1)); } ste->in_->readBytes(bytes, 0, numBytes); bytesReader->reset(bytes, 0, numBytes); // Sub-blocks of a single floor block are always // written one after another -- tail recurse: fpEnd = ste->in_->getFilePointer(); // if (DEBUG) { // System.out.println(" fpEnd=" + fpEnd); // } } void SegmentTermsEnumFrame::rewind() { // Force reload: fp = fpOrig; nextEnt = -1; hasTerms = hasTermsOrig; if (isFloor) { floorDataReader->rewind(); numFollowFloorBlocks = floorDataReader->readVInt(); assert(numFollowFloorBlocks > 0); nextFloorLabel = floorDataReader->readByte() & 0xff; } /* //System.out.println("rewind"); // Keeps the block loaded, but rewinds its state: if (nextEnt > 0 || fp != fpOrig) { if (DEBUG) { System.out.println(" rewind frame ord=" + ord + " fpOrig=" + fpOrig + " fp=" + fp + " hasTerms?=" + hasTerms + " isFloor?=" + isFloor + " nextEnt=" + nextEnt + " prefixLen=" + prefix); } if (fp != fpOrig) { fp = fpOrig; nextEnt = -1; } else { nextEnt = 0; } hasTerms = hasTermsOrig; if (isFloor) { floorDataReader.rewind(); numFollowFloorBlocks = floorDataReader.readVInt(); nextFloorLabel = floorDataReader.readByte() & 0xff; } assert suffixBytes != null; suffixesReader.rewind(); assert statBytes != null; statsReader.rewind(); metaDataUpto = 0; state.termBlockOrd = 0; // TODO: skip this if !hasTerms? Then postings // impl wouldn't have to write useless 0 byte postingsReader.resetTermsBlock(fieldInfo, state); lastSubFP = -1; } else if (DEBUG) { System.out.println(" skip rewind fp=" + fp + " fpOrig=" + fpOrig + " nextEnt=" + nextEnt + " ord=" + ord); } */ } bool SegmentTermsEnumFrame::next() { if (isLeafBlock) { nextLeaf(); return false; } else { return nextNonLeaf(); } } void SegmentTermsEnumFrame::nextLeaf() { // if (DEBUG) System.out.println(" frame.next ord=" + ord + " nextEnt=" + // nextEnt + " entCount=" + entCount); assert((nextEnt != -1 && nextEnt < entCount, L"nextEnt=" + to_wstring(nextEnt) + L" entCount=" + to_wstring(entCount) + L" fp=" + to_wstring(fp))); nextEnt++; suffix = suffixesReader->readVInt(); startBytePos = suffixesReader->getPosition(); ste->term_->setLength(prefix + suffix); ste->term_.grow(ste->term_->length()); suffixesReader->readBytes(ste->term_.bytes(), prefix, suffix); ste->termExists = true; } bool SegmentTermsEnumFrame::nextNonLeaf() { // if (DEBUG) System.out.println(" stef.next ord=" + ord + " nextEnt=" + // nextEnt + " entCount=" + entCount + " fp=" + suffixesReader.getPosition()); while (true) { if (nextEnt == entCount) { assert((arc == nullptr || (isFloor && isLastInFloor == false), L"isFloor=" + StringHelper::toString(isFloor) + L" isLastInFloor=" + StringHelper::toString(isLastInFloor))); loadNextFloorBlock(); if (isLeafBlock) { nextLeaf(); return false; } else { continue; } } assert((nextEnt != -1 && nextEnt < entCount, L"nextEnt=" + to_wstring(nextEnt) + L" entCount=" + to_wstring(entCount) + L" fp=" + to_wstring(fp))); nextEnt++; constexpr int code = suffixesReader->readVInt(); suffix = static_cast<int>(static_cast<unsigned int>(code) >> 1); startBytePos = suffixesReader->getPosition(); ste->term_->setLength(prefix + suffix); ste->term_.grow(ste->term_->length()); suffixesReader->readBytes(ste->term_.bytes(), prefix, suffix); if ((code & 1) == 0) { // A normal term ste->termExists = true; subCode = 0; state->termBlockOrd++; return false; } else { // A sub-block; make sub-FP absolute: ste->termExists = false; subCode = suffixesReader->readVLong(); lastSubFP = fp - subCode; // if (DEBUG) { // System.out.println(" lastSubFP=" + lastSubFP); //} return true; } } } void SegmentTermsEnumFrame::scanToFloorFrame(shared_ptr<BytesRef> target) { if (!isFloor || target->length <= prefix) { // if (DEBUG) { // System.out.println(" scanToFloorFrame skip: isFloor=" + isFloor + " // target.length=" + target.length + " vs prefix=" + prefix); // } return; } constexpr int targetLabel = target->bytes[target->offset + prefix] & 0xFF; // if (DEBUG) { // System.out.println(" scanToFloorFrame fpOrig=" + fpOrig + " // targetLabel=" + toHex(targetLabel) + " vs nextFloorLabel=" + // toHex(nextFloorLabel) + " numFollowFloorBlocks=" + numFollowFloorBlocks); // } if (targetLabel < nextFloorLabel) { // if (DEBUG) { // System.out.println(" already on correct block"); // } return; } assert(numFollowFloorBlocks != 0); int64_t newFP = fpOrig; while (true) { constexpr int64_t code = floorDataReader->readVLong(); newFP = fpOrig + (static_cast<int64_t>(static_cast<uint64_t>(code) >> 1)); hasTerms = (code & 1) != 0; // if (DEBUG) { // System.out.println(" label=" + toHex(nextFloorLabel) + " fp=" + // newFP + " hasTerms?=" + hasTerms + " numFollowFloor=" + // numFollowFloorBlocks); // } isLastInFloor = numFollowFloorBlocks == 1; numFollowFloorBlocks--; if (isLastInFloor) { nextFloorLabel = 256; // if (DEBUG) { // System.out.println(" stop! last block nextFloorLabel=" + // toHex(nextFloorLabel)); // } break; } else { nextFloorLabel = floorDataReader->readByte() & 0xff; if (targetLabel < nextFloorLabel) { // if (DEBUG) { // System.out.println(" stop! nextFloorLabel=" + // toHex(nextFloorLabel)); // } break; } } } if (newFP != fp) { // Force re-load of the block: // if (DEBUG) { // System.out.println(" force switch to fp=" + newFP + " oldFP=" + // fp); // } nextEnt = -1; fp = newFP; } else { // if (DEBUG) { // System.out.println(" stay on same fp=" + newFP); // } } } void SegmentTermsEnumFrame::decodeMetaData() { // if (DEBUG) System.out.println("\nBTTR.decodeMetadata seg=" + segment + " // mdUpto=" + metaDataUpto + " vs termBlockOrd=" + state.termBlockOrd); // lazily catch up on metadata decode: constexpr int limit = getTermBlockOrd(); bool absolute = metaDataUpto == 0; assert(limit > 0); // TODO: better API would be "jump straight to term=N"??? while (metaDataUpto < limit) { // TODO: we could make "tiers" of metadata, ie, // decode docFreq/totalTF but don't decode postings // metadata; this way caller could get // docFreq/totalTF w/o paying decode cost for // postings // TODO: if docFreq were bulk decoded we could // just skipN here: // stats state->docFreq = statsReader->readVInt(); // if (DEBUG) System.out.println(" dF=" + state.docFreq); if (ste->fr->fieldInfo->getIndexOptions() != IndexOptions::DOCS) { state->totalTermFreq = state->docFreq + statsReader->readVLong(); // if (DEBUG) System.out.println(" totTF=" + state.totalTermFreq); } // metadata for (int i = 0; i < ste->fr->longsSize; i++) { longs[i] = bytesReader->readVLong(); } ste->fr->parent->postingsReader->decodeTerm( longs, bytesReader, ste->fr->fieldInfo, state, absolute); metaDataUpto++; absolute = false; } state->termBlockOrd = metaDataUpto; } bool SegmentTermsEnumFrame::prefixMatches(shared_ptr<BytesRef> target) { for (int bytePos = 0; bytePos < prefix; bytePos++) { if (target->bytes[target->offset + bytePos] != ste->term_.byteAt(bytePos)) { return false; } } return true; } void SegmentTermsEnumFrame::scanToSubBlock(int64_t subFP) { assert(!isLeafBlock); // if (DEBUG) System.out.println(" scanToSubBlock fp=" + fp + " subFP=" + // subFP + " entCount=" + entCount + " lastSubFP=" + lastSubFP); assert nextEnt // == 0; if (lastSubFP == subFP) { // if (DEBUG) System.out.println(" already positioned"); return; } assert( (subFP < fp, L"fp=" + to_wstring(fp) + L" subFP=" + to_wstring(subFP))); constexpr int64_t targetSubCode = fp - subFP; // if (DEBUG) System.out.println(" targetSubCode=" + targetSubCode); while (true) { assert(nextEnt < entCount); nextEnt++; constexpr int code = suffixesReader->readVInt(); suffixesReader->skipBytes( static_cast<int>(static_cast<unsigned int>(code) >> 1)); if ((code & 1) != 0) { constexpr int64_t subCode = suffixesReader->readVLong(); if (targetSubCode == subCode) { // if (DEBUG) System.out.println(" match!"); lastSubFP = subFP; return; } } else { state->termBlockOrd++; } } } SeekStatus SegmentTermsEnumFrame::scanToTerm(shared_ptr<BytesRef> target, bool exactOnly) { return isLeafBlock ? scanToTermLeaf(target, exactOnly) : scanToTermNonLeaf(target, exactOnly); } SeekStatus SegmentTermsEnumFrame::scanToTermLeaf(shared_ptr<BytesRef> target, bool exactOnly) { // if (DEBUG) System.out.println(" scanToTermLeaf: block fp=" + fp + " // prefix=" + prefix + " nextEnt=" + nextEnt + " (of " + entCount + ") // target=" + brToString(target) + " term=" + brToString(term)); assert(nextEnt != -1); ste->termExists = true; subCode = 0; if (nextEnt == entCount) { if (exactOnly) { fillTerm(); } return SeekStatus::END; } assert(prefixMatches(target)); // Loop over each entry (term or sub-block) in this block: // nextTerm: while(nextEnt < entCount) { while (true) { nextEnt++; suffix = suffixesReader->readVInt(); // if (DEBUG) { // BytesRef suffixBytesRef = new BytesRef(); // suffixBytesRef.bytes = suffixBytes; // suffixBytesRef.offset = suffixesReader.getPosition(); // suffixBytesRef.length = suffix; // System.out.println(" cycle: term " + (nextEnt-1) + " (of " + // entCount + ") suffix=" + brToString(suffixBytesRef)); // } constexpr int termLen = prefix + suffix; startBytePos = suffixesReader->getPosition(); suffixesReader->skipBytes(suffix); constexpr int targetLimit = target->offset + (target->length < termLen ? target->length : termLen); int targetPos = target->offset + prefix; // Loop over bytes in the suffix, comparing to // the target int bytePos = startBytePos; while (true) { constexpr int cmp; constexpr bool stop; if (targetPos < targetLimit) { cmp = (suffixBytes[bytePos++] & 0xFF) - (target->bytes[targetPos++] & 0xFF); stop = false; } else { assert(targetPos == targetLimit); cmp = termLen - target->length; stop = true; } if (cmp < 0) { // Current entry is still before the target; // keep scanning if (nextEnt == entCount) { // We are done scanning this block goto nextTermBreak; } else { goto nextTermContinue; } } else if (cmp > 0) { // Done! Current entry is after target -- // return NOT_FOUND: fillTerm(); // if (DEBUG) System.out.println(" not found"); return SeekStatus::NOT_FOUND; } else if (stop) { // Exact match! // This cannot be a sub-block because we // would have followed the index to this // sub-block from the start: assert(ste->termExists); fillTerm(); // if (DEBUG) System.out.println(" found!"); return SeekStatus::FOUND; } } nextTermContinue:; } nextTermBreak: // It is possible (and OK) that terms index pointed us // at this block, but, we scanned the entire block and // did not find the term to position to. This happens // when the target is after the last term in the block // (but, before the next term in the index). EG // target could be foozzz, and terms index pointed us // to the foo* block, but the last term in this block // was fooz (and, eg, first term in the next block will // bee fop). // if (DEBUG) System.out.println(" block end"); if (exactOnly) { fillTerm(); } // TODO: not consistent that in the // not-exact case we don't next() into the next // frame here return SeekStatus::END; } SeekStatus SegmentTermsEnumFrame::scanToTermNonLeaf(shared_ptr<BytesRef> target, bool exactOnly) { // if (DEBUG) System.out.println(" scanToTermNonLeaf: block fp=" + fp + " // prefix=" + prefix + " nextEnt=" + nextEnt + " (of " + entCount + ") target=" // + brToString(target) + " term=" + brToString(target)); assert(nextEnt != -1); if (nextEnt == entCount) { if (exactOnly) { fillTerm(); ste->termExists = subCode == 0; } return SeekStatus::END; } assert(prefixMatches(target)); // Loop over each entry (term or sub-block) in this block: while (nextEnt < entCount) { nextEnt++; constexpr int code = suffixesReader->readVInt(); suffix = static_cast<int>(static_cast<unsigned int>(code) >> 1); // if (DEBUG) { // BytesRef suffixBytesRef = new BytesRef(); // suffixBytesRef.bytes = suffixBytes; // suffixBytesRef.offset = suffixesReader.getPosition(); // suffixBytesRef.length = suffix; // System.out.println(" cycle: " + ((code&1)==1 ? "sub-block" : // "term") + " " + (nextEnt-1) + " (of " + entCount + ") suffix=" + // brToString(suffixBytesRef)); //} constexpr int termLen = prefix + suffix; startBytePos = suffixesReader->getPosition(); suffixesReader->skipBytes(suffix); ste->termExists = (code & 1) == 0; if (ste->termExists) { state->termBlockOrd++; subCode = 0; } else { subCode = suffixesReader->readVLong(); lastSubFP = fp - subCode; } constexpr int targetLimit = target->offset + (target->length < termLen ? target->length : termLen); int targetPos = target->offset + prefix; // Loop over bytes in the suffix, comparing to // the target int bytePos = startBytePos; while (true) { constexpr int cmp; constexpr bool stop; if (targetPos < targetLimit) { cmp = (suffixBytes[bytePos++] & 0xFF) - (target->bytes[targetPos++] & 0xFF); stop = false; } else { assert(targetPos == targetLimit); cmp = termLen - target->length; stop = true; } if (cmp < 0) { // Current entry is still before the target; // keep scanning goto nextTermContinue; } else if (cmp > 0) { // Done! Current entry is after target -- // return NOT_FOUND: fillTerm(); // if (DEBUG) System.out.println(" maybe done exactOnly=" + // exactOnly + " ste.termExists=" + ste.termExists); if (!exactOnly && !ste->termExists) { // System.out.println(" now pushFrame"); // TODO this // We are on a sub-block, and caller wants // us to position to the next term after // the target, so we must recurse into the // sub-frame(s): ste->currentFrame = ste->pushFrame(nullptr, ste->currentFrame->lastSubFP, termLen); ste->currentFrame->loadBlock(); while (ste->currentFrame->next()) { ste->currentFrame = ste->pushFrame( nullptr, ste->currentFrame->lastSubFP, ste->term_->length()); ste->currentFrame->loadBlock(); } } // if (DEBUG) System.out.println(" not found"); return SeekStatus::NOT_FOUND; } else if (stop) { // Exact match! // This cannot be a sub-block because we // would have followed the index to this // sub-block from the start: assert(ste->termExists); fillTerm(); // if (DEBUG) System.out.println(" found!"); return SeekStatus::FOUND; } } nextTermContinue:; } nextTermBreak: // It is possible (and OK) that terms index pointed us // at this block, but, we scanned the entire block and // did not find the term to position to. This happens // when the target is after the last term in the block // (but, before the next term in the index). EG // target could be foozzz, and terms index pointed us // to the foo* block, but the last term in this block // was fooz (and, eg, first term in the next block will // bee fop). // if (DEBUG) System.out.println(" block end"); if (exactOnly) { fillTerm(); } // TODO: not consistent that in the // not-exact case we don't next() into the next // frame here return SeekStatus::END; } void SegmentTermsEnumFrame::fillTerm() { constexpr int termLength = prefix + suffix; ste->term_->setLength(termLength); ste->term_.grow(termLength); System::arraycopy(suffixBytes, startBytePos, ste->term_.bytes(), prefix, suffix); } } // namespace org::apache::lucene::codecs::blocktree
[ "smamunr@fedora.localdomain" ]
smamunr@fedora.localdomain
65af69b3a62a2cefb728a24d7cdb00f293047b4c
0e8f68043c4349175c7a877aa0b89201c1fe1c76
/leetcode/Discuss/027.Serialization.Deserialization.of.a.Binary.Tree.II.cpp
5ba16454fee09742c3fbe908f9d9f343a194f1be
[]
no_license
jiabailie/Algorithm
f26f0d9f5e4e4b1d42cee7d2150cfc49ca2c6faf
1357cccf698a98a32e7e03a84d697478b56e3fe5
refs/heads/master
2021-01-25T07:08:20.331355
2016-11-23T06:25:26
2016-11-23T06:25:26
9,423,405
0
0
null
null
null
null
UTF-8
C++
false
false
3,246
cpp
#include <cstdio> #include <iostream> #include <fstream> #include <vector> #include <cstring> #include <vld.h> using namespace std; struct TreeNode { int i_val; TreeNode *p_left; TreeNode *p_right; TreeNode() : i_val(0), p_left(0), p_right(0) {} TreeNode(int val) : i_val(val), p_left(0), p_right(0) {} TreeNode(const TreeNode &treeNode) : i_val(treeNode.i_val), p_left(treeNode.p_left), p_right(treeNode.p_right) {} TreeNode &operator=(const TreeNode &treeNode) { if(this != &treeNode) { this->i_val = treeNode.i_val; this->p_left = treeNode.p_left; this->p_right = treeNode.p_right; } return *this; } }; // whether the next char is splitting token inline bool isToken(char c, string &token) { for(string::iterator it = token.begin(); it != token.end(); ++it) { if(c == (*it)) { return true; } } return false; } // whether the next word is number or not inline bool isNumber(string &str) { if(str.size() == 0) { return false; } for(int i = 0; i < str.size(); ++i) { if(str[i] < '0' || str[i] > '9') { return false; } } return true; } // transfer a string to integer int str2int(string &str) { int ret = 0; for(int i = 0; i < str.size(); ++i) { ret = ret * 10 + (str[i] - '0'); } return ret; } // read text from file // here, the text in file is // 30 10 50 # # # 20 45 # # 35 # # vector<string> readFile(ifstream &in, string &token) { if(!in.is_open()) { cout << "Error during opening the file." << endl; exit(1); } char c; string word; vector<string> vec_Str; while(in.get(c)) { if(!isToken(c, token)) { word.push_back(c); continue; } if(word.length() > 0) { vec_Str.push_back(string(word.begin(), word.end())); word.clear(); } } if(word.length() > 0) { vec_Str.push_back(string(word.begin(), word.end())); } return vec_Str; } // Deserialize the binary tree TreeNode *DeserializeTree(int &cur, vector<string> &vec_SerialTree) { if(cur < 0 || cur >= vec_SerialTree.size() || vec_SerialTree.size() == 0 || !isNumber(vec_SerialTree[cur])) { return 0; } TreeNode *p_Node = new TreeNode(str2int(vec_SerialTree[cur])); cur = cur + 1; p_Node->p_left = DeserializeTree(cur, vec_SerialTree); cur = cur + 1; p_Node->p_right = DeserializeTree(cur, vec_SerialTree); return p_Node; } // Serialize the binary tree void SerializeTree(TreeNode *p_Root, ostream &out) { if(!p_Root) { out << "# "; } else { out << p_Root->i_val << " "; SerializeTree(p_Root->p_left, out); SerializeTree(p_Root->p_right, out); } } // Release the resources void DestroyTree(TreeNode **p_Root) { if(!p_Root || !(*p_Root)) { return; } DestroyTree(&((*p_Root)->p_left)); DestroyTree(&((*p_Root)->p_right)); delete *p_Root; p_Root = 0; } int main() { string token(" "); ifstream in("D:/Lab/clab/file/1.txt"); ofstream out("D:/Lab/clab/file/2.txt"); vector<string> vec_SerialTree = readFile(in, token); int cur = 0; TreeNode *p_Root = DeserializeTree(cur, vec_SerialTree); if(out) { SerializeTree(p_Root, out); } DestroyTree(&p_Root); return 0; }
[ "spotlightyrg@gmail.com" ]
spotlightyrg@gmail.com
7e8e716368ba2637eefc312a437c2fb190ee2010
2ba2e7b90f2582f67790e7515a34610b94b80010
/common/strings/rebase.cc
23a8a037e535ba60bc435cab2984a25b7f2c28af
[ "Apache-2.0" ]
permissive
antmicro/verible
8354b0d3523bd66c58be9cf3a9bc2c9359734277
9f59b14270d62945521fd7e93de1f304ad9c4a28
refs/heads/master
2023-07-22T22:18:03.579585
2023-05-19T17:01:34
2023-05-19T17:01:34
221,144,955
1
2
Apache-2.0
2023-02-17T08:58:07
2019-11-12T06:21:02
C++
UTF-8
C++
false
false
1,085
cc
// Copyright 2017-2020 The Verible Authors. // // 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 "common/strings/rebase.h" #include "common/util/logging.h" namespace verible { void RebaseStringView(absl::string_view* src, absl::string_view dest) { CHECK_EQ(*src, dest) << "RebaseStringView() is only valid when the " "new text referenced matches the old text."; *src = dest; } void RebaseStringView(absl::string_view* src, const char* dest) { RebaseStringView(src, absl::string_view(dest, src->length())); } } // namespace verible
[ "h.zeller@acm.org" ]
h.zeller@acm.org
848d7e370c013bb7fda11f5aafe760406fbadbc0
cdf069f16596a61d39d51e739cc8454deb132b38
/Framework/MeshContainer.h
c9232a0a253261bee045eb21088683cbe533bfea
[]
no_license
YutaTachibana0310/hackathon0729
bfcb944d628fd3eaaaab80d242b18d10b190ba9a
b05f1324758351b4faafab2b28a5ddb650d51d27
refs/heads/master
2020-06-25T09:09:50.555342
2019-07-29T08:01:18
2019-07-29T08:01:18
199,267,811
0
0
null
2019-07-29T06:45:42
2019-07-28T09:32:36
C++
SHIFT_JIS
C++
false
false
1,242
h
//===================================== // //メッシュコンテナヘッダ[MeshContainer.h] //Author:GP12B332 21 立花雄太 // //===================================== #ifndef _MESHCONTAINER_H_ #define _MESHCONTAINER_H_ #include "../main.h" /************************************** マクロ定義 ***************************************/ /************************************** クラス定義 ***************************************/ class MeshContainer { public: MeshContainer(); //コンストラクタ ~MeshContainer(); //デストラクタ HRESULT Load(const char* filePath); //Xファイルの読み込み void Release(); //モデルデータを解放 void Draw(); //モデルを描画 void GetMaterial(unsigned id, D3DMATERIAL9 *pOut); //マテリアル取得 void GetTexture(unsigned id, LPDIRECT3DTEXTURE9 *pOut); //テクスチャ取得 DWORD GetMaterialNum(); //マテリアル数取得 void SetMaterialColor(D3DXCOLOR& color); void SetMaterialAlpha(float alpha); private: LPD3DXMESH mesh; //メッシュデータ D3DMATERIAL9* materials; //マテリアル情報 LPDIRECT3DTEXTURE9 *textures; //テクスチャ DWORD materialNum; //マテリアル数 }; #endif
[ "yuta.tachibana0310@gmail.com" ]
yuta.tachibana0310@gmail.com
a954b1a96105b2fe465e357652c4bd711a8cee77
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/tsan/interception/interception_win.h
4590013019e375a41817fc088a06463012d34b3b
[ "MIT" ]
permissive
ziglang/zig
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
refs/heads/master
2023-08-31T13:16:45.980913
2023-08-31T05:50:29
2023-08-31T05:50:29
40,276,274
25,560
2,399
MIT
2023-09-14T21:09:50
2015-08-06T00:51:28
Zig
UTF-8
C++
false
false
3,463
h
//===-- interception_linux.h ------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file is a part of AddressSanitizer, an address sanity checker. // // Windows-specific interception methods. //===----------------------------------------------------------------------===// #if SANITIZER_WINDOWS #if !defined(INCLUDED_FROM_INTERCEPTION_LIB) # error "interception_win.h should be included from interception library only" #endif #ifndef INTERCEPTION_WIN_H #define INTERCEPTION_WIN_H namespace __interception { // All the functions in the OverrideFunction() family return true on success, // false on failure (including "couldn't find the function"). // Overrides a function by its address. bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func = 0); // Overrides a function in a system DLL or DLL CRT by its exported name. bool OverrideFunction(const char *name, uptr new_func, uptr *orig_old_func = 0); // Windows-only replacement for GetProcAddress. Useful for some sanitizers. uptr InternalGetProcAddress(void *module, const char *func_name); // Overrides a function only when it is called from a specific DLL. For example, // this is used to override calls to HeapAlloc/HeapFree from ucrtbase without // affecting other third party libraries. bool OverrideImportedFunction(const char *module_to_patch, const char *imported_module, const char *function_name, uptr new_function, uptr *orig_old_func); #if !SANITIZER_WINDOWS64 // Exposed for unittests bool OverrideFunctionWithDetour( uptr old_func, uptr new_func, uptr *orig_old_func); #endif // Exposed for unittests bool OverrideFunctionWithRedirectJump( uptr old_func, uptr new_func, uptr *orig_old_func); bool OverrideFunctionWithHotPatch( uptr old_func, uptr new_func, uptr *orig_old_func); bool OverrideFunctionWithTrampoline( uptr old_func, uptr new_func, uptr *orig_old_func); // Exposed for unittests void TestOnlyReleaseTrampolineRegions(); } // namespace __interception #if defined(INTERCEPTION_DYNAMIC_CRT) #define INTERCEPT_FUNCTION_WIN(func) \ ::__interception::OverrideFunction(#func, \ (::__interception::uptr)WRAP(func), \ (::__interception::uptr *)&REAL(func)) #else #define INTERCEPT_FUNCTION_WIN(func) \ ::__interception::OverrideFunction((::__interception::uptr)func, \ (::__interception::uptr)WRAP(func), \ (::__interception::uptr *)&REAL(func)) #endif #define INTERCEPT_FUNCTION_VER_WIN(func, symver) INTERCEPT_FUNCTION_WIN(func) #define INTERCEPT_FUNCTION_DLLIMPORT(user_dll, provider_dll, func) \ ::__interception::OverrideImportedFunction( \ user_dll, provider_dll, #func, (::__interception::uptr)WRAP(func), \ (::__interception::uptr *)&REAL(func)) #endif // INTERCEPTION_WIN_H #endif // SANITIZER_WINDOWS
[ "andrew@ziglang.org" ]
andrew@ziglang.org
63b68925ce1d6919caca4ba1e2205dcf64e1cf56
928775398b79b42c42fb20b5622b6f1a9d653b2b
/config-generic.h
5143710b74556b397295616d116e6db0294b1882
[ "MIT" ]
permissive
davidchisnall/azure-freebsd-minimal
5f55a874d6904453a7b1f4306886ea25e13990ad
9b41e81a2f38e7ce9fcd05d3ad69f138aa2e9ece
refs/heads/main
2023-08-27T22:32:35.388360
2021-10-16T11:49:13
2021-10-16T11:49:13
393,779,072
1
0
null
null
null
null
UTF-8
C++
false
false
18,362
h
// Copyright David Chisnall // SPDX-License-Identifier: MIT #pragma once #include <algorithm> #include <assert.h> #include <chrono> #include <initializer_list> #include <optional> #include <string_view> #include <ucl.h> #include <unordered_map> #include <utility> #include <stdio.h> #ifndef CONFIG_DETAIL_NAMESPACE # define CONFIG_DETAIL_NAMESPACE config::detail #endif #ifdef __clang__ # define CONFIG_LIFETIME_BOUND [[clang::lifetimebound]] #else # define CONFIG_LIFETIME_BOUND #endif namespace CONFIG_DETAIL_NAMESPACE { /** * Smart pointer to a UCL object, manages the lifetime of the object. */ class UCLPtr { /** * The UCL object that this manages a reference to. */ const ucl_object_t *obj = nullptr; public: /** * Default constructor, points to nothing. */ UCLPtr() {} /** * Construct from a raw UCL object pointer. This does not take * ownership of the reference, the underlying object must have unref'd * if this is called with an owning reference. */ UCLPtr(const ucl_object_t *o) : obj(ucl_object_ref(o)) {} /** * Copy constructor, increments the reference count of the underlying * object. */ UCLPtr(const UCLPtr &o) : obj(ucl_object_ref(o.obj)) {} /** * Move constructor, takes ownership of the underlying reference. */ UCLPtr(UCLPtr &&o) : obj(o.obj) { o.obj = nullptr; } /** * Destructor. Drops the reference to the UCL object. */ ~UCLPtr() { ucl_object_unref(const_cast<ucl_object_t *>(obj)); } /** * Assignment operator. Replaces currently managed object with a new * one. */ UCLPtr &operator=(const ucl_object_t *o) { o = ucl_object_ref(o); ucl_object_unref(const_cast<ucl_object_t *>(obj)); obj = o; return *this; } /** * Copy assignment operator. */ UCLPtr &operator=(const UCLPtr o) { return (*this = o.obj); } /** * Implicit conversion operator, returns the underlying object. */ operator const ucl_object_t *() const { return obj; } /** * Comparison operator. Returns true if `o` is a different UCL object * to the one that this manages. */ bool operator!=(const ucl_object_t *o) { return obj != o; } /** * Look up a property in this object by name and return a smart pointer * to the new object. */ UCLPtr operator[](const char *key) const { return ucl_object_lookup(obj, key); } }; /** * Range. Exposes a UCL collection as an iterable range of type `T`, with * `Adaptor` used to convert from the underlying UCL object to `T`. If * `IterateProperties` is true then this iterates over the properties of an * object, rather than just over UCL arrays. */ template<typename T, typename Adaptor = T, bool IterateProperties = false> class Range { /** * The array that this will iterate over. */ UCLPtr array; /** * The kind of iteration that this will perform. */ enum ucl_iterate_type iterate_type; /** * Iterator type for this range. */ class Iter { /** * The current iterator. */ ucl_object_iter_t iter{nullptr}; /** * The current object in the iteration. */ UCLPtr obj; /** * The array that we're iterating over. */ UCLPtr array; /** * The kind of iteration. */ enum ucl_iterate_type iterate_type; public: /** * Default constructor. Compares equal to the end iterator from any * range. */ Iter() : iter(nullptr), obj(nullptr), array(nullptr) {} /** * These iterators cannot be copy constructed. */ Iter(const Iter &) = delete; /** * These iterators cannot be move constructed. */ Iter(Iter &&) = delete; /** * Constructor, passed an object to iterate over and the kind of * iteration to perform. */ Iter(const ucl_object_t *arr, const ucl_iterate_type type) : array(arr), iterate_type(type) { // If this is not an array and we are not iterating over // properties then treat this as a collection of one object. if (!IterateProperties && (ucl_object_type(array) != UCL_ARRAY)) { array = nullptr; obj = arr; return; } iter = ucl_object_iterate_new(array); ++(*this); } /** * Arrow operator, uses `Adaptor` to expose the underlying object * as if it were of type `T`. */ T operator->() { return Adaptor(obj); } /** * Dereference operator, uses `Adaptor` to expose the underlying * object as if it were of type `T`. */ T operator*() { return Adaptor(obj); } /** * Non-equality comparison, used to terminate range-based for * loops. Compares the current iterated object. This is typically * a comparison against `nullptr` from the iterator at the end of a * range. */ bool operator!=(const Iter &other) { return obj != other.obj; } /** * Pre-increment operator, advances the iteration point. If we * have reached the end then the object will be `nullptr`. */ Iter &operator++() { if (iter == nullptr) { obj = nullptr; } else { obj = ucl_object_iterate_safe(iter, iterate_type); } return *this; } /** * Destructor, frees any iteration state. */ ~Iter() { if (iter != nullptr) { ucl_object_iterate_free(iter); } } }; public: /** * Constructor. Constructs a range from an object. The second * argument specifies whether this should iterate over implicit arrays, * explicit arrays, or both. */ Range(const ucl_object_t * arr, const ucl_iterate_type type = UCL_ITERATE_BOTH) : array(arr), iterate_type(type) { } /** * Returns an iterator to the start of the range. */ Iter begin() { return {array, iterate_type}; } /** * Returns an iterator to the end of the range. */ Iter end() { return {}; } /** * Returns true if this is an empty range. */ bool empty() { return (array == nullptr) || (ucl_object_type(array) == UCL_NULL); } }; /** * String view adaptor exposes a UCL object as a string view. * * Adaptors are intended to be short-lived, created only as temporaries, * and must not outlive the object that they are adapting. */ class StringViewAdaptor { /** * Non-owning pointer to the UCL object that this adaptor is wrapping. */ const ucl_object_t *obj; public: /** * Constructor, captures a non-owning reference to a UCL object. */ StringViewAdaptor(const ucl_object_t *o) : obj(o) {} /** * Implicit cast operator. Returns a string view representing the * object. */ operator std::string_view() { const char *cstr = ucl_object_tostring(obj); if (cstr != nullptr) { return cstr; } return std::string_view("", 0); } }; /** * Duration adaptor, exposes a UCL object as a duration. * * Adaptors are intended to be short-lived, created only as temporaries, * and must not outlive the object that they are adapting. */ class DurationAdaptor { /** * Non-owning pointer to the UCL object that this adaptor is wrapping. */ const ucl_object_t *obj; public: /** * Constructor, captures a non-owning reference to the underling UCL * object. */ DurationAdaptor(const ucl_object_t *o) : obj(o) {} /** * Implicit cast operator, returns the underlying object as a duration * in seconds. */ operator std::chrono::seconds() { assert(ucl_object_type(obj) == UCL_TIME); return std::chrono::seconds( static_cast<long long>(ucl_object_todouble(obj))); } }; /** * Generic adaptor for number types. Templated with the type of the number * and the UCL function required to convert to a type that can represent * the value. * * Adaptors are intended to be short-lived, created only as temporaries, * and must not outlive the object that they are adapting. */ template<typename NumberType, auto (*Conversion)(const ucl_object_t *) = ucl_object_toint> class NumberAdaptor { /** * Non-owning pointer to the UCL object that this adaptor is wrapping. */ const ucl_object_t *obj; public: /** * Constructor, captures a non-owning reference to the underling UCL * object. */ NumberAdaptor(const ucl_object_t *o) : obj(o) {} /** * Implicit conversion operator, returns the object represented as a * `NumberType`. */ operator NumberType() { return static_cast<NumberType>(Conversion(obj)); } }; using UInt64Adaptor = NumberAdaptor<uint64_t>; using UInt32Adaptor = NumberAdaptor<uint32_t>; using UInt16Adaptor = NumberAdaptor<uint16_t>; using UInt8Adaptor = NumberAdaptor<uint8_t>; using Int64Adaptor = NumberAdaptor<int64_t>; using Int32Adaptor = NumberAdaptor<int32_t>; using Int16Adaptor = NumberAdaptor<int16_t>; using Int8Adaptor = NumberAdaptor<int8_t>; using BoolAdaptor = NumberAdaptor<bool, ucl_object_toboolean>; using FloatAdaptor = NumberAdaptor<float, ucl_object_todouble>; using DoubleAdaptor = NumberAdaptor<double, ucl_object_todouble>; /** * String for use in C++20 templates as a literal value. */ template<size_t N> struct StringLiteral { /** * Constructor, takes a string literal and provides an object that can * be used as a template parameter. */ constexpr StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); } /** * Implicit conversion, exposes the object as a string view. */ operator std::string_view() const { // Strip out the null terminator return {value, N - 1}; } /** * Implicit conversion, exposes the object as a C string. */ operator const char *() const { return value; } /** * Storage for the string. Template arguments are compared by * structural equality and so two instances of this class will compare * equal for the purpose of template instantiation of this array * contains the same set of characters. */ char value[N]; }; /** * A key-value pair of a string and an `enum` value defined in a way that * allows them to be used as template argument literals. The template * arguments should never be specified directly, they should be inferred by * calling the constructor. */ template<size_t Size, typename EnumType> struct Enum { /** * Constructor, takes a string literal defining a name and the `enum` * value that this maps to as arguments. */ constexpr Enum(const char (&str)[Size], EnumType e) : val(e) { std::copy_n(str, Size - 1, key_buffer); } /** * Internal storage for the key. Object literals in template arguments * are compared by structural equality so two instances of this refer * to the same type if they have the same character sequence here, the * same `enum` type and the same value in `val`. */ char key_buffer[Size - 1] = {0}; /** * The `enum` value that this key-value pair maps to. */ EnumType val; /** * Expose the key as a string view. */ constexpr std::string_view key() const { // Strip out the null terminator return {key_buffer, Size - 1}; } }; /** * Compile-time map from strings to `enum` values. Created by providing a * list of `Enum` object literals as template parameters. */ template<Enum... kvp> class EnumValueMap { /** * The type of a tuple of all of the key-value pairs in this map. */ using KVPs = std::tuple<decltype(kvp)...>; /** * The key-value pairs. */ static constexpr KVPs kvps{kvp...}; /** * The type of a value. All of the key-value pairs must refer to the * same `enum` type. */ using Value = std::remove_reference_t<decltype(std::get<0>(kvps).val)>; /** * Look up a key. This is `constexpr` and can be compile-time * evaluated. The template parameter is the index into the key-value * pair list to look. If the lookup fails, then this will recursively * invoke the same method on the next key-value pair. * * This is currently a linear scan, so if this is * evaluated at run time then it will be O(n). In the intended use, * `n` is small and the values of the keys are sufficiently small that * the comparison can be 1-2 instructions. Compilers seem to generate * very good code for this after inlining. */ template<size_t Element> static constexpr Value lookup(std::string_view key) noexcept { static_assert( std::is_same_v< Value, std::remove_reference_t<decltype(std::get<Element>(kvps).val)>>, "All entries must use the same enum value"); // Re if (key == std::get<Element>(kvps).key()) { return std::get<Element>(kvps).val; } if constexpr (Element + 1 < std::tuple_size_v<KVPs>) { return lookup<Element + 1>(key); } else { return static_cast<Value>(-1); } } public: /** * Looks up an `enum` value by name. This can be called at compile * time. */ static constexpr Value get(std::string_view key) noexcept { return lookup<0>(key); } }; /** * Adaptor for `enum`s. This is instantiated with the type of the `enum` * and a `EnumValueMap` that maps from strings to `enum` values. */ template<typename EnumType, typename Map> class EnumAdaptor { /** * Non-owning pointer to the UCL object that this adaptor is wrapping. */ const ucl_object_t *obj; public: /** * Constructor, captures a non-owning pointer to the underlying object. */ EnumAdaptor(const ucl_object_t *o) : obj(o) {} /** * Implicit conversion, extracts the string value and converts it to an * `enum` using the compile-time map provided as the second template * parameter. */ operator EnumType() { return Map::get(ucl_object_tostring(obj)); } }; /** * Class representing a compile-time mapping from a string to a type. This * is used to generate compile-time maps from keys to types. */ template<StringLiteral Key, typename Adaptor> struct NamedType { /** * Given a UCL object, construct an `Adaptor` from that object. */ static Adaptor construct(const ucl_object_t *obj) { return Adaptor{obj}; } /** * Return the key as a string view. */ static constexpr std::string_view key() { return Key; } }; /** * Named type adaptor. This is used to represent UCL objects that have a * field whose name describes their type. The template parameters are the * name of the key that defines the type and a list of `NamedType`s that * represent the set of valid values and the types that they represent. * * This exposes a visitor interface, where callbacks for each of the * possible types can be provided, giving a match-like API. */ template<StringLiteral KeyName, typename... Types> class NamedTypeAdaptor { /** * The underlying object that this represents. */ UCLPtr obj; /** * A type describing all of the string-to-type maps as a tuple. */ using TypesAsTuple = std::tuple<Types...>; /** * Implementation of the visitor. Recursive template that inspects * each of the possible values in the names map and invokes the visitor * with the matching type. */ template<typename T, size_t I = 0> constexpr void visit_impl(std::string_view key, T &&v) { if (key == std::tuple_element_t<I, TypesAsTuple>::key()) { return v(std::tuple_element_t<I, TypesAsTuple>::construct(obj)); } if constexpr (I + 1 < std::tuple_size_v<TypesAsTuple>) { return visit_impl<T, I + 1>(key, std::forward<T &&>(v)); } } /** * Dispatch helper. This is instantiated with an array of lambdas, one * for each matched type. It will expose all of their call operators * as different overloads. * * Taken from an example on cppreference.com. */ template<class... Fs> struct Dispatcher : Fs... { using Fs::operator()...; }; public: /** * Constructor, captures a non-owning reference to a UCL object. */ NamedTypeAdaptor(const ucl_object_t *o) : obj(o) {} /** * Visit. Can be called in two configurations, either with a single * visitor class, or with an array of lambdas each taking one of the * possible types as its sole argument. * * Either the explicit visitor or the lambda must cover all cases. * This can be done with an `auto` parameter overload as the fallback. * * WARNING: This cannot be called with a visitor class *and* lambdas, * because it will attempt to copy the visitor and so any state will * not be updated. */ template<typename... Visitors> auto visit(Visitors &&...visitors) { /** * If this is called with a single visitor, use it directly. */ if constexpr (sizeof...(Visitors) == 1) { return visit_impl(StringViewAdaptor(obj[KeyName]), visitors...); } else { return visit_impl(StringViewAdaptor(obj[KeyName]), Dispatcher{visitors...}); } } /** * Visit. This should be called with a list of lambdas as the * argument. Each lambda should take one of the types. Unlike the * `visit` method, this does not need to cover all cases. Any cases * that are not handled will be silently ignored. */ template<typename... Visitors> auto visit_some(Visitors &&...visitors) { return visit_impl(StringViewAdaptor(obj[KeyName]), Dispatcher{visitors..., [](auto &&) {}}); } }; /** * Property adaptor. Wraps some other adaptor for the value and also * provides an accessor for the key. */ template<typename Adaptor> class PropertyAdaptor : public Adaptor { public: /** * Constructor, captures a non-owning reference to a UCL object. */ PropertyAdaptor(const ucl_object_t *o) : Adaptor(o) {} /** * Provide the key as a string view. */ std::string_view key() { return ucl_object_key(Adaptor::obj); } }; /** * Helper to construct a value with an adaptor if it exists. If `o` is not * null, uses `Adaptor` to construct an instance of `T`. Returns an * `optional<T>`, where the value is present if `o` is not null. */ template<typename Adaptor, typename T = Adaptor> std::optional<T> make_optional(const ucl_object_t *o) { if (o == nullptr) { return {}; } return Adaptor(o); } } // namespace CONFIG_DETAIL_NAMESPACE
[ "David.Chisnall@microsoft.com" ]
David.Chisnall@microsoft.com
de83464e4af98521a91b597bbcfa38aa6e9b828d
e60678d3bd87ba051f73772fe956271847bd09d5
/34-android-system-module/34-26-weidongshan_4_term_android/cpp_projects_weids_bak/cpp_projects/03th_ProgramStructure/06th/dog.cpp
c94acceff733ae7a5c9d11bc73fd3defa2009d06
[]
no_license
juyingguo/android-knowledge-principle-interview
da75682d97ab9353850567eb9d96f516a7d36328
368a3ce91bc9bd735d78985a8dd8925232f9b8c6
refs/heads/master
2023-04-15T06:18:36.200436
2023-03-21T13:39:29
2023-03-21T13:39:29
198,389,681
2
2
null
2022-09-01T23:10:43
2019-07-23T08:44:37
Java
UTF-8
C++
false
false
401
cpp
#include <iostream> #include "dog.h" namespace C { using namespace std; void Dog::setName(char *name) { this->name = name; } int Dog::setAge(int age) { if (age < 0 || age > 20) { this->age = 0; return -1; } this->age = age; return 0; } void Dog::printInfo(void) { cout<<"name = "<<name<<" age = "<<age<<endl; } void printVersion(void) { cout<<"Dog v1, by weidongshan"<<endl; } }
[ "juying2050@sina.cn" ]
juying2050@sina.cn
4764164789b35e5d9e541b92a09bc153306b6fea
dde31782e6e39cf6dcbff2a4bbea46e75091693a
/src/pagespeed/kernel/base/string_util.cc
a042975da76f45202bee7af1f333987350f4933e
[]
no_license
apache/incubator-pagespeed-debian
02a320a67860118b22be3019428d3acf176fc59c
0202964b14afc20ea2a17a21444bb5be3e3c8c1c
refs/heads/master
2023-07-02T21:15:01.888831
2023-04-21T06:58:40
2023-04-21T14:55:52
78,453,135
3
5
null
2023-04-21T14:55:53
2017-01-09T17:43:02
C++
UTF-8
C++
false
false
20,638
cc
/* * Copyright 2010 Google Inc. * * 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. */ // Author: jmarantz@google.com (Joshua Marantz) #include "pagespeed/kernel/base/string_util.h" #include <algorithm> #include <cstddef> #include <cstdlib> #include <vector> #include "pagespeed/kernel/base/string.h" namespace net_instaweb { bool StringToDouble(const char* in, double* out) { char* endptr; *out = strtod(in, &endptr); if (endptr != in) { while (IsHtmlSpace(*endptr)) ++endptr; } // Ignore range errors from strtod. The values it // returns on underflow and overflow are the right // fallback in a robust setting. return *in != '\0' && *endptr == '\0'; } GoogleString StrCat(StringPiece a, StringPiece b) { GoogleString res; res.reserve(a.size() + b.size()); a.AppendToString(&res); b.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c) { GoogleString res; res.reserve(a.size() + b.size() + c.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c, StringPiece d) { GoogleString res; res.reserve(a.size() + b.size() + c.size() + d.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); d.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e) { GoogleString res; res.reserve(a.size() + b.size() + c.size() + d.size() + e.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); d.AppendToString(&res); e.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f) { GoogleString res; res.reserve(a.size() + b.size() + c.size() + d.size() + e.size() + f.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); d.AppendToString(&res); e.AppendToString(&res); f.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f, StringPiece g) { GoogleString res; res.reserve(a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + g.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); d.AppendToString(&res); e.AppendToString(&res); f.AppendToString(&res); g.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f, StringPiece g, StringPiece h) { GoogleString res; res.reserve(a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + g.size() + h.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); d.AppendToString(&res); e.AppendToString(&res); f.AppendToString(&res); g.AppendToString(&res); h.AppendToString(&res); return res; } namespace internal { GoogleString StrCatNineOrMore(const StringPiece* a, ...) { GoogleString res; va_list args; va_start(args, a); size_t size = a->size(); while (const StringPiece* arg = va_arg(args, const StringPiece*)) { size += arg->size(); } res.reserve(size); va_end(args); va_start(args, a); a->AppendToString(&res); while (const StringPiece* arg = va_arg(args, const StringPiece*)) { arg->AppendToString(&res); } va_end(args); return res; } } // namespace internal void StrAppend(GoogleString* target, StringPiece a, StringPiece b) { target->reserve(target->size() + a.size() + b.size()); a.AppendToString(target); b.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c) { target->reserve(target->size() + a.size() + b.size() + c.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size() + e.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); e.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size() + e.size() + f.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); e.AppendToString(target); f.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f, StringPiece g) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + g.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); e.AppendToString(target); f.AppendToString(target); g.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f, StringPiece g, StringPiece h) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + g.size() + h.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); e.AppendToString(target); f.AppendToString(target); g.AppendToString(target); h.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f, StringPiece g, StringPiece h, StringPiece i) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + g.size() + h.size() + i.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); e.AppendToString(target); f.AppendToString(target); g.AppendToString(target); h.AppendToString(target); i.AppendToString(target); } void SplitStringPieceToVector(StringPiece sp, StringPiece separators, StringPieceVector* components, bool omit_empty_strings) { size_t prev_pos = 0; size_t pos = 0; while ((pos = sp.find_first_of(separators, pos)) != StringPiece::npos) { if (!omit_empty_strings || (pos > prev_pos)) { components->push_back(sp.substr(prev_pos, pos - prev_pos)); } ++pos; prev_pos = pos; } if (!omit_empty_strings || (prev_pos < sp.size())) { components->push_back(sp.substr(prev_pos, prev_pos - sp.size())); } } void SplitStringUsingSubstr(StringPiece full, StringPiece substr, StringPieceVector* result) { StringPiece::size_type begin_index = 0; while (true) { const StringPiece::size_type end_index = full.find(substr, begin_index); if (end_index == StringPiece::npos) { const StringPiece term = full.substr(begin_index); result->push_back(term); return; } const StringPiece term = full.substr(begin_index, end_index - begin_index); if (!term.empty()) { result->push_back(term); } begin_index = end_index + substr.size(); } } void BackslashEscape(StringPiece src, StringPiece to_escape, GoogleString* dest) { dest->reserve(dest->size() + src.size()); for (const char *p = src.data(), *end = src.data() + src.size(); p != end; ++p) { if (to_escape.find(*p) != StringPiece::npos) { dest->push_back('\\'); } dest->push_back(*p); } } GoogleString CEscape(StringPiece src) { int len = src.length(); const char* read = src.data(); const char* end = read + len; int used = 0; char* dest = new char[len * 4 + 1]; for (; read != end; ++read) { unsigned char ch = static_cast<unsigned char>(*read); switch (ch) { case '\n': dest[used++] = '\\'; dest[used++] = 'n'; break; case '\r': dest[used++] = '\\'; dest[used++] = 'r'; break; case '\t': dest[used++] = '\\'; dest[used++] = 't'; break; case '\"': dest[used++] = '\\'; dest[used++] = '\"'; break; case '\'': dest[used++] = '\\'; dest[used++] = '\''; break; case '\\': dest[used++] = '\\'; dest[used++] = '\\'; break; default: if (ch < 32 || ch >= 127) { base::snprintf(dest + used, 5, "\\%03o", ch); // NOLINT used += 4; } else { dest[used++] = ch; } break; } } GoogleString final(dest, used); delete[] dest; return final; } // From src/third_party/protobuf/src/google/protobuf/stubs/strutil.h // but we don't need any other aspect of protobufs so we don't want to // incur the link cost. bool HasPrefixString(StringPiece str, StringPiece prefix) { return str.starts_with(prefix); } // From src/third_party/protobuf/src/google/protobuf/stubs/strutil.h // but we don't need any other aspect of protobufs so we don't want to // incur the link cost. void UpperString(GoogleString* s) { GoogleString::iterator end = s->end(); for (GoogleString::iterator i = s->begin(); i != end; ++i) { *i = UpperChar(*i); } } void LowerString(GoogleString* s) { GoogleString::iterator end = s->end(); for (GoogleString::iterator i = s->begin(); i != end; ++i) { *i = LowerChar(*i); } } // ---------------------------------------------------------------------- // GlobalReplaceSubstring() // Replaces all instances of a substring in a string. Returns the // number of replacements. // // NOTE: The string pieces must not overlap s. // ---------------------------------------------------------------------- int GlobalReplaceSubstring(StringPiece substring, StringPiece replacement, GoogleString* s) { CHECK(s != NULL); if (s->empty()) return 0; GoogleString tmp; int num_replacements = 0; size_t pos = 0; for (size_t match_pos = s->find(substring.data(), pos, substring.length()); match_pos != GoogleString::npos; pos = match_pos + substring.length(), match_pos = s->find(substring.data(), pos, substring.length())) { ++num_replacements; // Append the original content before the match. tmp.append(*s, pos, match_pos - pos); // Append the replacement for the match. tmp.append(replacement.begin(), replacement.end()); } // Append the content after the last match. If no replacements were made, the // original string is left untouched. if (num_replacements > 0) { tmp.append(*s, pos, s->length() - pos); s->swap(tmp); } return num_replacements; } // Erase shortest substrings in string bracketed by left and right. int GlobalEraseBracketedSubstring(StringPiece left, StringPiece right, GoogleString* string) { int deletions = 0; size_t keep_start = 0; size_t keep_end = string->find(left.data(), keep_start, left.size()); if (keep_end == GoogleString::npos) { // Fast path without allocation for no occurrences of left. return 0; } GoogleString result; result.reserve(string->size()); while (keep_end != GoogleString::npos) { result.append(*string, keep_start, keep_end - keep_start); keep_start = string->find(right.data(), keep_end + left.size(), right.size()); if (keep_start == GoogleString::npos) { keep_start = keep_end; break; } keep_start += right.size(); ++deletions; keep_end = string->find(left.data(), keep_start, left.size()); } result.append(*string, keep_start, string->size() - keep_start); string->swap(result); string->reserve(string->size()); // shrink_to_fit, C++99-style return deletions; } GoogleString JoinStringStar(const ConstStringStarVector& vector, StringPiece delim) { GoogleString result; if (vector.size() > 0) { // Precompute resulting length so we can reserve() memory in one shot. int length = delim.size() * (vector.size() - 1); for (ConstStringStarVector::const_iterator iter = vector.begin(); iter < vector.end(); ++iter) { length += (*iter)->size(); } result.reserve(length); // Now combine everything. for (ConstStringStarVector::const_iterator iter = vector.begin(); iter < vector.end(); ++iter) { if (iter != vector.begin()) { result.append(delim.data(), delim.size()); } result.append(**iter); } } return result; } bool StringCaseStartsWith(StringPiece str, StringPiece prefix) { return ((str.size() >= prefix.size()) && (0 == StringCaseCompare(prefix, str.substr(0, prefix.size())))); } bool StringCaseEndsWith(StringPiece str, StringPiece suffix) { return ((str.size() >= suffix.size()) && (0 == StringCaseCompare(suffix, str.substr(str.size() - suffix.size())))); } bool StringEqualConcat(StringPiece str, StringPiece first, StringPiece second) { return (str.size() == first.size() + second.size()) && str.starts_with(first) && str.ends_with(second); } StringPiece PieceAfterEquals(StringPiece piece) { size_t index = piece.find("="); if (index != piece.npos) { ++index; StringPiece ret = piece; ret.remove_prefix(index); TrimWhitespace(&ret); return ret; } return StringPiece(piece.data(), 0); } int CountCharacterMismatches(StringPiece s1, StringPiece s2) { int s1_length = s1.size(); int s2_length = s2.size(); int mismatches = 0; for (int i = 0, n = std::min(s1_length, s2_length); i < n; ++i) { mismatches += s1[i] != s2[i]; } return mismatches + std::abs(s1_length - s2_length); } void ParseShellLikeString(StringPiece input, std::vector<GoogleString>* output) { output->clear(); for (size_t index = 0; index < input.size();) { const char ch = input[index]; if (ch == '"' || ch == '\'') { // If we see a quoted section, treat it as a single item even if there are // spaces in it. const char quote = ch; ++index; // skip open quote output->push_back(""); GoogleString& part = output->back(); for (; index < input.size() && input[index] != quote; ++index) { if (input[index] == '\\') { ++index; // skip backslash if (index >= input.size()) { break; } } part.push_back(input[index]); } ++index; // skip close quote } else if (!IsHtmlSpace(ch)) { // Without quotes, items are whitespace-separated. output->push_back(""); GoogleString& part = output->back(); for (; index < input.size() && !IsHtmlSpace(input[index]); ++index) { part.push_back(input[index]); } } else { // Ignore whitespace (outside of quotes). ++index; } } } int CountSubstring(StringPiece text, StringPiece substring) { int number_of_occurrences = 0; size_t pos = 0; for (size_t match_pos = text.find(substring, pos); match_pos != StringPiece::npos; pos = match_pos + 1, match_pos = text.find(substring, pos)) { number_of_occurrences++; } return number_of_occurrences; } stringpiece_ssize_type FindIgnoreCase( StringPiece haystack, StringPiece needle) { stringpiece_ssize_type pos = 0; while (haystack.size() >= needle.size()) { if (StringCaseStartsWith(haystack, needle)) { return pos; } ++pos; haystack.remove_prefix(1); } return StringPiece::npos; } // In-place StringPiece whitespace trimming. This mutates the StringPiece. bool TrimLeadingWhitespace(StringPiece* str) { // We use stringpiece_ssize_type to avoid signedness problems. stringpiece_ssize_type size = str->size(); stringpiece_ssize_type trim = 0; while (trim != size && IsHtmlSpace(str->data()[trim])) { ++trim; } str->remove_prefix(trim); return (trim > 0); } bool TrimTrailingWhitespace(StringPiece* str) { // We use stringpiece_ssize_type to avoid signedness problems. stringpiece_ssize_type rightmost = str->size(); while (rightmost != 0 && IsHtmlSpace(str->data()[rightmost - 1])) { --rightmost; } if (rightmost != str->size()) { str->remove_suffix(str->size() - rightmost); return true; } return false; } bool TrimWhitespace(StringPiece* str) { // We *must* trim *both* leading and trailing spaces, so we use the // non-shortcut bitwise | on the boolean results. return TrimLeadingWhitespace(str) | TrimTrailingWhitespace(str); } namespace { bool TrimCasePattern(StringPiece pattern, StringPiece* str) { bool did_something = false; if (StringCaseStartsWith(*str, pattern)) { str->remove_prefix(pattern.size()); did_something = true; } if (StringCaseEndsWith(*str, pattern)) { str->remove_suffix(pattern.size()); did_something = false; } return did_something; } } // namespace void TrimQuote(StringPiece* str) { TrimWhitespace(str); if (str->starts_with("\"") || str->starts_with("'")) { str->remove_prefix(1); } if (str->ends_with("\"") || str->ends_with("'")) { str->remove_suffix(1); } TrimWhitespace(str); } void TrimUrlQuotes(StringPiece* str) { TrimWhitespace(str); bool cont = true; // Unwrap a string with an arbitrary nesting of real and URL percent-encoded // quotes. We do this one layer at a time, always removing backslashed // quotes before removing un-backslashed quotes. while (cont) { cont = (TrimCasePattern("%5C%27", str) || // \" TrimCasePattern("%5C%22", str) || // \' TrimCasePattern("%27", str) || // " TrimCasePattern("%22", str) || // ' TrimCasePattern("\"", str) || TrimCasePattern("'", str)); } TrimWhitespace(str); } // TODO(jmarantz): This is a very slow implementation. But strncasecmp // will fail test StringCaseTest.Locale. If this shows up as a performance // bottleneck then an SSE implementation would be better. int StringCaseCompare(StringPiece s1, StringPiece s2) { for (int i = 0, n = std::min(s1.size(), s2.size()); i < n; ++i) { unsigned char c1 = UpperChar(s1[i]); unsigned char c2 = UpperChar(s2[i]); if (c1 < c2) { return -1; } else if (c1 > c2) { return 1; } } if (s1.size() < s2.size()) { return -1; } else if (s1.size() > s2.size()) { return 1; } return 0; } bool MemCaseEqual(const char* s1, size_t size1, const char* s2, size_t size2) { if (size1 != size2) { return false; } for (; size1 != 0; --size1, ++s1, ++s2) { if (UpperChar(*s1) != UpperChar(*s2)) { return false; } } return true; } bool SplitStringPieceToIntegerVector(StringPiece src, StringPiece separators, std::vector<int>* ints) { StringPieceVector values; SplitStringPieceToVector( src, separators, &values, true /* omit_empty_strings */); ints->clear(); int v; for (int i = 0, n = values.size(); i < n; ++i) { if (StringToInt(values[i], &v)) { ints->push_back(v); } else { ints->clear(); return false; } } return true; } } // namespace net_instaweb
[ "morlovich@google.com" ]
morlovich@google.com
29bac6eb072cda6fa0fb39475862ac1f3edf5d20
7fa6aa899c62125789da0368c3cbd514cd7def10
/PagedLOD/Tests/UnitTests/TestCase_3002/test.cpp
25ef21dd679448ad90213c5b206006fba520d774
[]
no_license
xiaoqiye/RFPagedLOD
f78e72d537319101063980a98b675eec13f37b32
aa0eefe17955cef5144874612d0d37f34b2f21fc
refs/heads/master
2022-11-21T20:18:59.908851
2020-07-26T12:21:31
2020-07-26T12:21:31
255,565,532
0
0
null
null
null
null
UTF-8
C++
false
false
1,886
cpp
#include "pch.h" #include "MockData.h" TEST(TestMeshLURList, TestPushTileNode) { auto LRUList = MockData::createMeshLRUList(); //1 insert LRUList.push(SSplayElement("Tile_1_3.bin", 400, 400)); LRUList.push(SSplayElement("Tile_1_2_1.bin", 300, 200)); LRUList.push(SSplayElement("Tile_1_2_0.bin", 200, 200)); LRUList.push(SSplayElement("Tile_1_1.bin", 100, 100)); //1_1->1_2_0->1_2_1->1_3; memsize = 1700 EXPECT_EQ(LRUList.getCurrentMemorySize(), 1700); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_1_1.bin"); //2 update LRUList.push(SSplayElement("Tile_1_2_0.bin", 200, 200)); LRUList.push(SSplayElement("Tile_1_3.bin", 400, 400)); //1_3->1_2_0->1_1->1_2_1; memsize = 1700 EXPECT_EQ(LRUList.getCurrentMemorySize(), 1700); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_1_3.bin"); //3 delete LRUList.push(SSplayElement("Tile_2_2_0.bin", 400, 200)); //2_2_0->1_3->1_2_0->1_1; memsize = 2000 EXPECT_EQ(LRUList.getCurrentMemorySize(), 2000); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_2_2_0.bin"); EXPECT_EQ(LRUList.getBackNode().MeshName, "Tile_1_1.bin"); LRUList.push(SSplayElement("Tile_2_2_1.bin", 500, 200)); //2_2_1->2_2_0->1_3; memsize = 1900 EXPECT_EQ(LRUList.getCurrentMemorySize(), 1900); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_2_2_1.bin"); EXPECT_EQ(LRUList.getBackNode().MeshName, "Tile_1_3.bin"); LRUList.push(SSplayElement("Tile_1_3.bin", 400, 400)); //1_3->2_2_0->2_2_1; memsize = 1900 EXPECT_EQ(LRUList.getCurrentMemorySize(), 1900); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_1_3.bin"); EXPECT_EQ(LRUList.getBackNode().MeshName, "Tile_2_2_1.bin"); LRUList.push(SSplayElement("Tile_3_3.bin", 800, 100)); //3_3->1_3; memsize = 1700 EXPECT_EQ(LRUList.getCurrentMemorySize(), 1700); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_3_3.bin"); EXPECT_EQ(LRUList.getBackNode().MeshName, "Tile_1_3.bin"); }
[ "806707499@qq.com" ]
806707499@qq.com
cecf04243930bf73b99295818f8167dc73848408
9e7ad0241ab120559af94050a1e31c62f1d63941
/addons/ofxRaycaster/example-segment-intersection/src/ofApp.h
6b65952d4497607612f56de41984d22dd4d3fb12
[]
no_license
nickdchee/CityBuilderRTS
d27117ab7aa7ac672d1d5cc83556752cbbfc77a2
16e77418bdbae36cb0f01e22bf8a340ab894365b
refs/heads/master
2020-04-16T17:38:59.848644
2019-01-29T08:08:19
2019-01-29T08:08:19
165,784,090
1
0
null
2019-01-20T16:52:31
2019-01-15T04:15:49
C++
UTF-8
C++
false
false
811
h
#pragma once #include "ofMain.h" #include "ofxRaycaster.h" class ofApp : public ofBaseApp{ public: void setup(); void update(); void draw(); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void mouseEntered(int x, int y); void mouseExited(int x, int y); void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); void drawLegend(glm::vec2 rayOrig, glm::vec2 intersection,bool intersects); ofxraycaster::Ray<glm::vec2> ray; ofxraycaster::Plane<glm::vec2> plane; glm::vec2 p1 = glm::vec2(700, 80); glm::vec2 p2 = glm::vec2(900, 600); };
[ "tiganov@ualberta.ca" ]
tiganov@ualberta.ca
1da93f3476ab0f1d84350766d9bd6f032d6dadf4
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/angle/src/libANGLE/renderer/metal/renderermtl_utils.h
54615ce89c4889ae7be36b40cb4cda51945961e5
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
1,346
h
// // Copyright 2023 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // renderermtl_utils: // Helper methods pertaining to the Metal backend. // #ifndef LIBANGLE_RENDERER_METAL_RENDERERMTL_UTILS_H_ #define LIBANGLE_RENDERER_METAL_RENDERERMTL_UTILS_H_ #include <cstdint> #include <limits> #include <map> #include "GLSLANG/ShaderLang.h" #include "common/angleutils.h" #include "common/utilities.h" #include "libANGLE/angletypes.h" namespace rx { namespace mtl { template <int cols, int rows> struct SetFloatUniformMatrixMetal { static void Run(unsigned int arrayElementOffset, unsigned int elementCount, GLsizei countIn, GLboolean transpose, const GLfloat *value, uint8_t *targetData); }; // Helper method to de-tranpose a matrix uniform for an API query, Metal Version void GetMatrixUniformMetal(GLenum type, GLfloat *dataOut, const GLfloat *source, bool transpose); template <typename NonFloatT> void GetMatrixUniformMetal(GLenum type, NonFloatT *dataOut, const NonFloatT *source, bool transpose); } // namespace mtl } // namespace rx #endif
[ "jengelh@inai.de" ]
jengelh@inai.de
b367509d880debf451309c520306dc9492177831
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5631572862566400_1/C++/psir/bffs.cpp
49020311517c0529e5564d03d6a2dd435d1e0bf7
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
3,067
cpp
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstdio> #include <map> #include <cstdlib> #include <cstring> #include <fstream> #include <set> #define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i)) #define FORC(it,cont) for(__typeof(cont.begin()) it=(cont).begin(); it!=(cont).end();++(it)) #define VI vector<int> #define VS vector<string> #define maxN 2000 using namespace std; vector< VI > adj; vector< VI > dabl; int visited[maxN]; int visited2[maxN]; VI cycle; set<int> S; void extract_cycle(int pos, int last) { //cout << pos << " " << last << endl; cycle.push_back(pos); if( pos == last ) return; extract_cycle(visited[pos],last); return; } void dfs(int pos) { //cout << pos << endl; //system("pause"); FOR(j,0,adj[pos].size()) { int pnew = adj[pos][j]; if (visited[pos] == pnew ) continue; if( visited[pnew] == -5 ) { visited[adj[pos][j]] = pos; dfs(adj[pos][j]); } else if(cycle.size() == 0) { extract_cycle(pos,pnew); } } //cout << pos << endl; //system("pause"); FOR(j,0,dabl[pos].size()) { int pnew = dabl[pos][j]; if( visited[pnew]!= -5 && cycle.size() == 0) { extract_cycle(pos,pnew); } } return; } int dfs2(int pos,int parent) { int sol = 0; FOR(i,0,adj[pos].size()) { int pnew = adj[pos][i]; if(S.count(pnew) == 0 && pnew != parent ) sol = max(sol, 1 + dfs2(pnew,pos)); } return sol; } int main() { int T,N; ifstream fcin("in.txt",ios::in); FILE* fout; fout = fopen("out.txt","w"); fcin >> T; FOR(tc,0,T) { //cout << "test " << tc << endl; // system("pause"); fcin >> N; VI x(N); FOR(i,0,N) {fcin >> x[i]; --x[i];} adj.resize(0); adj.resize(N); dabl.resize(0); dabl.resize(N); FOR(i,0,N) { if( x[i] < i && x[x[i]] == i ) { dabl[i].push_back(x[i]); dabl[x[i]].push_back(i); } else { adj[i].push_back(x[i]); adj[x[i]].push_back(i); } } FOR(i,0,N) { visited[i] = -5; visited2[i] = -5; } VI CL; VI TS; FOR(i,0,N) if( visited[i] == -5 ) { // cout << "start at " << i << " of " << N << endl; cycle.resize(0); visited[i] = -1; dfs(i); int csize = cycle.size(); if (csize > 2 ) { CL.push_back(csize); TS.push_back(csize); continue; } S.clear(); FOR(j,0,cycle.size()) S.insert(cycle[j]); VI maxdepth(cycle.size()); FOR(j,0,cycle.size()) maxdepth[j] = dfs2(cycle[j],cycle[j]); sort(maxdepth.begin(),maxdepth.end()); int depth = maxdepth[csize-1] + maxdepth[csize -2]; CL.push_back(csize); TS.push_back(csize + depth); } int maxC = 0; int TS2 = 0; FOR(i,0,CL.size()) { maxC = max(maxC,CL[i]); if( CL[i] == 2 ) TS2 += TS[i]; } int res = max(maxC,TS2); fprintf(fout,"Case #%d: %d\n",tc+1,res); } fcin.close(); return 0; }
[ "alexandra1.back@gmail.com" ]
alexandra1.back@gmail.com
711d1a5a1d7e264265d76bc1a8d8f2a479916e16
efc9f7ce45fd208d6ed43c41ea9a6ed8b4664feb
/src/libs/SGAL/lib/geometries/Tex_coord_array.cpp
719f9d341626352df01de84ee5ece1e1574fc61d
[]
no_license
efifogel/sgal
312d604e879240baae60e82faa87acc637a38542
bb3ebcb1c06aff311f3ea095f50e02cc6bd2983e
refs/heads/master
2020-03-27T22:15:31.407935
2018-09-03T13:38:10
2018-09-03T13:38:10
147,217,311
4
0
null
null
null
null
UTF-8
C++
false
false
1,673
cpp
// Copyright (c) 2013 Israel. // All rights reserved. // // This file is part of SGAL; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; version 2.1 of the // License. See the file LICENSE.LGPL distributed with SGAL. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the // software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING // THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A // PARTICULAR PURPOSE. // // Author(s) : Efi Fogel <efifogel@gmail.com> #include <iostream> #include <sstream> #include "SGAL/Tex_coord_array.hpp" #include "SGAL/Element.hpp" #include "SGAL/Container_proto.hpp" SGAL_BEGIN_NAMESPACE //! The node prototype. Container_proto* Tex_coord_array::s_prototype(nullptr); //! \brief initializes the node prototype. void Tex_coord_array::init_prototype() { if (s_prototype) return; s_prototype = new Container_proto(Container::get_prototype()); } //! \brief deletes the node prototype. void Tex_coord_array::delete_prototype() { delete s_prototype; s_prototype = NULL; } //! \brief obtains the node prototype. Container_proto* Tex_coord_array::get_prototype() { if (s_prototype == NULL) Tex_coord_array::init_prototype(); return s_prototype; } //! \brief sets the attributes of the object extracted from an input file. void Tex_coord_array::set_attributes(Element* elem) { Container::set_attributes(elem); // Remove all the deleted attributes: elem->delete_marked(); } SGAL_END_NAMESPACE
[ "efifogel@gmail.com" ]
efifogel@gmail.com
30c29ee641f1f979c8f265d6906064860003f7be
fb9a9e720c116281da77d77bc8648e7f010322a3
/01-1/Betweenadder/betweenAdder.cpp
b1efee65ff7319b773a5901faaf79c734c239107
[]
no_license
Jelcream/Cpp_study
fac6e706e6f903ace237cebac56bf4ab9eac6673
c3b073b1630bd97c2fd7617f37feed3ba971612d
refs/heads/master
2023-03-30T06:07:32.207733
2021-04-05T16:20:59
2021-04-05T16:20:59
354,875,840
0
0
null
null
null
null
UHC
C++
false
false
447
cpp
#include <iostream> int main() { int val1, val2; int result = 0; std::cout<<"두 개의 숫자입력: "; std::cin>>val1>>val2; if(val1 < val2) { for (int i = val1+1; i<val2; i++) { result+=i; } } else { for(int i = val2+1; i<val1;i++) { result+=i; } } std::cout<<"두 수 사이의 정수 합: "<<result<<std::endl; return 0; }
[ "43948280+Jelcream@users.noreply.github.com" ]
43948280+Jelcream@users.noreply.github.com
32d23bdc35819faea861565dc2c47cebf243ae0f
71e5b5cd3b6834fa1f342b991dffb7212816274b
/ldr/ldr.ino
4be4ac35397d6740d272480feaa1b589311efde1
[ "Apache-2.0" ]
permissive
trcclub/Basic-Arduino-Projects
b222296509cb5830c6ab91468696d99f0b8fe35d
230cbad2fd8008f529ee5b983c66c3e8fb264e41
refs/heads/master
2022-06-01T02:00:38.371728
2020-04-22T17:39:43
2020-04-22T17:39:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
227
ino
int sensorPin=A0;//select the inputpin for LDR int sensorValue=0; void setup() { Serial.begin(9600); } void loop(){ sensorValue = analogRead(sensorPin); Serial.print("sensorValue"); Serial.println(sensorValue); delay(250); }
[ "thameemk612@gmail.com" ]
thameemk612@gmail.com
166983321fd345be2f23756dd9eb5c173ff36f0b
5e9c396ea5d81dce62ef4e6f260db21385608922
/src/chrono_vehicle/tracked_vehicle/track_shoe/TrackShoeSinglePin.cpp
662719708ee0afb9888a706b36fe4223ec05d57d
[ "BSD-3-Clause" ]
permissive
gvvynplaine/chrono
357b30f896eb6c1dcabcebd0d88f10fab3faff20
a3c0c8735eb069d5c845a7b508a048b58e022ce0
refs/heads/develop
2023-01-05T08:43:13.115419
2020-07-09T08:24:34
2020-07-09T08:24:34
278,308,549
0
0
BSD-3-Clause
2020-10-30T12:17:47
2020-07-09T08:33:24
null
UTF-8
C++
false
false
6,892
cpp
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban // ============================================================================= // // Single-pin track shoe constructed with data from file (JSON format). // // ============================================================================= #include "chrono/assets/ChTriangleMeshShape.h" #include "chrono_vehicle/ChVehicleModelData.h" #include "chrono_vehicle/tracked_vehicle/track_shoe/TrackShoeSinglePin.h" #include "chrono_vehicle/utils/ChUtilsJSON.h" #include "chrono_thirdparty/filesystem/path.h" using namespace rapidjson; namespace chrono { namespace vehicle { // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- TrackShoeSinglePin::TrackShoeSinglePin(const std::string& filename) : ChTrackShoeSinglePin(""), m_has_mesh(false) { Document d = ReadFileJSON(filename); if (d.IsNull()) return; Create(d); GetLog() << "Loaded JSON: " << filename.c_str() << "\n"; } TrackShoeSinglePin::TrackShoeSinglePin(const rapidjson::Document& d) : ChTrackShoeSinglePin(""), m_has_mesh(false) { Create(d); } void TrackShoeSinglePin::Create(const rapidjson::Document& d) { // Invoke base class method. ChPart::Create(d); // Read shoe body geometry and mass properties assert(d.HasMember("Shoe")); m_shoe_height = d["Shoe"]["Height"].GetDouble(); m_shoe_pitch = d["Shoe"]["Pitch"].GetDouble(); m_shoe_mass = d["Shoe"]["Mass"].GetDouble(); m_shoe_inertia = ReadVectorJSON(d["Shoe"]["Inertia"]); // Read location of guide pin center (for detracking control) m_pin_center = ReadVectorJSON(d["Guide Pin Center"]); // Read contact data assert(d.HasMember("Contact")); assert(d["Contact"].HasMember("Cylinder Material")); assert(d["Contact"].HasMember("Shoe Materials")); assert(d["Contact"].HasMember("Cylinder Shape")); assert(d["Contact"].HasMember("Shoe Shapes")); assert(d["Contact"]["Shoe Materials"].IsArray()); assert(d["Contact"]["Shoe Shapes"].IsArray()); // Read contact material information (defer creating the materials until CreateContactMaterials) m_cyl_mat_info = ReadMaterialInfoJSON(d["Contact"]["Cylinder Material"]); int num_mats = d["Contact"]["Shoe Materials"].Size(); for (int i = 0; i < num_mats; i++) { MaterialInfo minfo = ReadMaterialInfoJSON(d["Contact"]["Shoe Materials"][i]); m_shoe_mat_info.push_back(minfo); } // Read geometric collison data m_cyl_radius = d["Contact"]["Cylinder Shape"]["Radius"].GetDouble(); m_front_cyl_loc = d["Contact"]["Cylinder Shape"]["Front Offset"].GetDouble(); m_rear_cyl_loc = d["Contact"]["Cylinder Shape"]["Rear Offset"].GetDouble(); int num_shapes = d["Contact"]["Shoe Shapes"].Size(); for (int i = 0; i < num_shapes; i++) { const Value& shape = d["Contact"]["Shoe Shapes"][i]; std::string type = shape["Type"].GetString(); int matID = shape["Material Index"].GetInt(); assert(matID >= 0 && matID < num_mats); if (type.compare("BOX") == 0) { ChVector<> pos = ReadVectorJSON(shape["Location"]); ChQuaternion<> rot = ReadQuaternionJSON(shape["Orientation"]); ChVector<> dims = ReadVectorJSON(shape["Dimensions"]); m_coll_boxes.push_back(BoxShape(pos, rot, dims, matID)); } else if (type.compare("CYLINDER") == 0) { ChVector<> pos = ReadVectorJSON(shape["Location"]); ChQuaternion<> rot = ReadQuaternionJSON(shape["Orientation"]); double radius = shape["Radius"].GetDouble(); double length = shape["Length"].GetDouble(); m_coll_cylinders.push_back(CylinderShape(pos, rot, radius, length, matID)); } } // Read visualization data if (d.HasMember("Visualization")) { if (d["Visualization"].HasMember("Mesh")) { m_meshFile = d["Visualization"]["Mesh"].GetString(); m_has_mesh = true; } if (d["Visualization"].HasMember("Primitives")) { assert(d["Visualization"]["Primitives"].IsArray()); int num_shapes = d["Visualization"]["Primitives"].Size(); for (int i = 0; i < num_shapes; i++) { const Value& shape = d["Visualization"]["Primitives"][i]; std::string type = shape["Type"].GetString(); if (type.compare("BOX") == 0) { ChVector<> pos = ReadVectorJSON(shape["Location"]); ChQuaternion<> rot = ReadQuaternionJSON(shape["Orientation"]); ChVector<> dims = ReadVectorJSON(shape["Dimensions"]); m_vis_boxes.push_back(BoxShape(pos, rot, dims)); } else if (type.compare("CYLINDER") == 0) { ChVector<> pos = ReadVectorJSON(shape["Location"]); ChQuaternion<> rot = ReadQuaternionJSON(shape["Orientation"]); double radius = shape["Radius"].GetDouble(); double length = shape["Length"].GetDouble(); m_vis_cylinders.push_back(CylinderShape(pos, rot, radius, length)); } } } } } void TrackShoeSinglePin::CreateContactMaterials(ChContactMethod contact_method) { m_cyl_material = m_cyl_mat_info.CreateMaterial(contact_method); for (auto minfo : m_shoe_mat_info) { m_shoe_materials.push_back(minfo.CreateMaterial(contact_method)); } } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- void TrackShoeSinglePin::AddVisualizationAssets(VisualizationType vis) { if (vis == VisualizationType::MESH && m_has_mesh) { auto trimesh = chrono_types::make_shared<geometry::ChTriangleMeshConnected>(); trimesh->LoadWavefrontMesh(vehicle::GetDataFile(m_meshFile), false, false); auto trimesh_shape = chrono_types::make_shared<ChTriangleMeshShape>(); trimesh_shape->SetMesh(trimesh); trimesh_shape->SetName(filesystem::path(m_meshFile).stem()); trimesh_shape->SetStatic(true); m_shoe->AddAsset(trimesh_shape); } else { ChTrackShoeSinglePin::AddVisualizationAssets(vis); } } } // end namespace vehicle } // end namespace chrono
[ "serban@wisc.edu" ]
serban@wisc.edu
b37bcff6cbdfc524dc36bd98e7e90849d50f560d
357fe03065b6cb5e15272f0f426e2bfaec39b004
/2020-21-1/algo II/codes/minta/bruteforce.cpp
31b4d5893371927e3d3d9f0f651f75445bbff962
[]
no_license
imdonix/elte-ik-bsc
f2101456dac556264ee5bed0650829bf9522fbaa
126181bebcf9af323b54222a2177eb8dbb797144
refs/heads/master
2023-07-30T23:36:03.440246
2022-05-17T21:25:57
2022-05-17T21:25:57
219,555,437
6
4
null
2021-11-17T22:07:07
2019-11-04T17:15:05
C++
UTF-8
C++
false
false
801
cpp
#include <iostream> #include <string> #include <vector> void print_results(std::vector<int> S) { std::cout << "Talalatok:"; for (int i = 0; i < S.size(); i++) { std::cout << " " << S[i]; } std::cout << std::endl; } void Bruteforce(const std::string& T, const std::string& P) { std::cout << "Bruteforce algoritmus" << std::endl << std::endl; std::vector<int> S; int n = T.length(), m = P.length(); for (int i = 0; i <= n - m; i++) { int j = 0; while (j < m && T[i+j] == P[j]) { j++; } if (j == m) { S.push_back(i); } } print_results(S); } int main() { std::string txt("ADABACACACABADABABADABABA"); std::string pat("ADABABA"); Bruteforce(txt, pat); return 0; }
[ "tamas.donix@gmail.com" ]
tamas.donix@gmail.com
1cb16f60ae9d45d53867db08b50eb9c9b46db20e
005eb1edbcef8e69a7f203642c4a849f27d82668
/2261/main.cpp
747770707b52c82a891ec2dc3293ecc06f9082ab
[]
no_license
JustinLiu1998/ECNU-Online-Judge
3dc2e1fe899f4ff7d64decafc5f21508b8bab40d
c57d4343334c5c15b48e6ce09882ec8092e07672
refs/heads/master
2022-04-07T14:05:06.856405
2020-02-25T13:28:36
2020-02-25T13:28:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,883
cpp
// // main.cpp // 2261 // // Created by 刘靖迪 on 2017/9/18. // Copyright © 2017年 刘靖迪. All rights reserved. // #include <iostream> #include <cstring> using namespace std; int power (int n, int prime, int e) { int ans=0; while (n / prime) { n /= prime; ans += n; } return ans/e; } int main(int argc, const char * argv[]) { int prime[168]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997}; int a[168]; int T, cas=0; cin >> T; while (T--) { int b, n; cin >> b >> n; if (n == 1) { cout << "Scenario #" << ++cas << ":" << endl << "0" << endl << endl; continue; } memset(a, 0, sizeof(a)); int i=0; while (b != 1) { if (b % prime[i] == 0) { while (b % prime[i] == 0) { a[i]++; b /= prime[i]; } } i++; } int tem, min=1e9; for (int j=0; j<i; j++) { if (a[j]) { tem = power(n, prime[j], a[j]); if (tem < min) min = tem; } } cout << "Scenario #" << ++cas << ":\n"; cout << min << endl << endl; } return 0; }
[ "liujingdiljd@icloud.com" ]
liujingdiljd@icloud.com
6df387db2ba225a9ed5171f331368c03a90bdcfa
fe402a0d7dcbedf88f68aed85e531b5a9c519dd8
/spring10/evilsnakes/enemy.h
47321de7e472f406493a37f6a6fd093358ee7a8e
[]
no_license
ericx2x/csundergradhomework
1e12c68ffeb50406648238142cc0abe29735e1a1
486bcd8c09e7bba39953e2509e61045ff4adbff3
refs/heads/master
2021-06-09T12:47:09.025877
2016-12-13T23:32:14
2016-12-13T23:32:14
76,407,145
2
0
null
null
null
null
UTF-8
C++
false
false
843
h
/*********************************************************/ /* Programmer: Michael Staub */ /* */ /* File Name: enemy.h */ /* */ /* Date: 2/28/2010 */ /*********************************************************/ #ifndef ENEMY_H #define ENEMY_H #include "sprite.h" class Level ; class Character ; class Enemy : public Sprite { public: Enemy( Level *l, DrawEngine *de, int s_index, float x = 1, float y = 1, int i_lives = 1 ) ; void addGoal( Character *g ) ; bool move( float x, float y ) ; void idleUpdate( void ) ; protected: void simulateAI( void ) ; Character *goal ; } ; #endif
[ "ericjlima@gmail.com" ]
ericjlima@gmail.com
7d42abb775f6a53c122d5c8f2124163100221058
55ae9643ce366b1d5e05328703cd82af5bf2bde3
/3019.cpp
fabec7b20320cb975178ef54993e05bc6fa5d936
[]
no_license
thextroid/edunote
486a9030cc60e1aca454d55d8228babe4d7cedf8
8fe6ac5929ce3fc322a2196ab716d4cc9136786e
refs/heads/master
2021-01-19T21:40:43.428088
2017-04-19T01:59:11
2017-04-19T01:59:11
88,685,790
0
0
null
null
null
null
UTF-8
C++
false
false
414
cpp
#include <iostream> #include <stdio.h> #define abs(a) (a)<0? -(a):(a) using namespace std; int main(){ freopen("data.in","r",stdin); freopen("data.out","w",stdout); int NT,n; int v[51]; scanf("%d",&NT); while(NT--){ scanf("%d",&n); for(int i = 0 ;i < n;++i) scanf("%d",&v[i]); int diff=0; for(int i = 0 ; i< n;++i) if(v[i]!=i+1) diff+= abs(i+1-v[i]); printf("%d\n", diff); } return 0; }
[ "thexfer@gmail.com" ]
thexfer@gmail.com
2f87390fa07a68a5beca58140f5c8ea4cbb46a75
b7ee9ac14d6981e18fa1b19214366878a4884a42
/Projects/Irrlicht/Source/SoftwareDriver2_helper.h
2185b23f8111402926cb82842b338a38d91ec967
[ "MIT" ]
permissive
skylicht-lab/skylicht-engine
89d51b4240ca6ed5a7f15b413df5711288580e9e
ff0e875581840efd15503cdfa49f112b6adade98
refs/heads/master
2023-09-01T02:23:45.865965
2023-08-29T08:21:41
2023-08-29T08:21:41
220,988,542
492
46
MIT
2023-06-05T10:18:45
2019-11-11T13:34:56
C++
UTF-8
C++
false
false
8,303
h
// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h /* History: - changed behavior for log2 textures ( replaced multiplies by shift ) */ #ifndef __S_VIDEO_2_SOFTWARE_HELPER_H_INCLUDED__ #define __S_VIDEO_2_SOFTWARE_HELPER_H_INCLUDED__ #include "irrMath.h" #include "SMaterial.h" namespace irr { // supporting different packed pixel needs many defines... typedef u32 tVideoSample; #define MASK_A 0xFF000000 #define MASK_R 0x00FF0000 #define MASK_G 0x0000FF00 #define MASK_B 0x000000FF #define SHIFT_A 24 #define SHIFT_R 16 #define SHIFT_G 8 #define SHIFT_B 0 #define COLOR_MAX 0xFF #define COLOR_MAX_LOG2 8 #define COLOR_BRIGHT_WHITE 0xFFFFFFFF #define VIDEO_SAMPLE_GRANULARITY 2 // ----------------------- Generic ---------------------------------- //! a more useful memset for pixel // (standard memset only works with 8-bit values) inline void memset32(void * dest, const u32 value, u32 bytesize) { u32 * d = (u32*) dest; u32 i; // loops unrolled to reduce the number of increments by factor ~8. i = bytesize >> (2 + 3); while (i) { d[0] = value; d[1] = value; d[2] = value; d[3] = value; d[4] = value; d[5] = value; d[6] = value; d[7] = value; d += 8; i -= 1; } i = (bytesize >> 2 ) & 7; while (i) { d[0] = value; d += 1; i -= 1; } } //! a more useful memset for pixel // (standard memset only works with 8-bit values) inline void memset16(void * dest, const u16 value, u32 bytesize) { u16 * d = (u16*) dest; u32 i; // loops unrolled to reduce the number of increments by factor ~8. i = bytesize >> (1 + 3); while (i) { d[0] = value; d[1] = value; d[2] = value; d[3] = value; d[4] = value; d[5] = value; d[6] = value; d[7] = value; d += 8; --i; } i = (bytesize >> 1 ) & 7; while (i) { d[0] = value; ++d; --i; } } /* use biased loop counter --> 0 byte copy is forbidden */ REALINLINE void memcpy32_small ( void * dest, const void *source, u32 bytesize ) { u32 c = bytesize >> 2; do { ((u32*) dest ) [ c-1 ] = ((u32*) source) [ c-1 ]; } while ( --c ); } // integer log2 of a float ieee 754. TODO: non ieee floating point static inline s32 s32_log2_f32( f32 f) { u32 x = IR ( f ); return ((x & 0x7F800000) >> 23) - 127; } static inline s32 s32_log2_s32(u32 x) { return s32_log2_f32( (f32) x); } static inline s32 s32_abs(s32 x) { s32 b = x >> 31; return (x ^ b ) - b; } //! conditional set based on mask and arithmetic shift REALINLINE u32 if_mask_a_else_b ( const u32 mask, const u32 a, const u32 b ) { return ( mask & ( a ^ b ) ) ^ b; } // ------------------ Video--------------------------------------- /*! Pixel = dest * ( 1 - alpha ) + source * alpha alpha [0;256] */ REALINLINE u32 PixelBlend32 ( const u32 c2, const u32 c1, u32 alpha ) { u32 srcRB = c1 & 0x00FF00FF; u32 srcXG = c1 & 0x0000FF00; u32 dstRB = c2 & 0x00FF00FF; u32 dstXG = c2 & 0x0000FF00; u32 rb = srcRB - dstRB; u32 xg = srcXG - dstXG; rb *= alpha; xg *= alpha; rb >>= 8; xg >>= 8; rb += dstRB; xg += dstXG; rb &= 0x00FF00FF; xg &= 0x0000FF00; return rb | xg; } /*! Pixel = dest * ( 1 - alpha ) + source * alpha alpha [0;32] */ inline u16 PixelBlend16 ( const u16 c2, const u32 c1, const u16 alpha ) { const u16 srcRB = c1 & 0x7C1F; const u16 srcXG = c1 & 0x03E0; const u16 dstRB = c2 & 0x7C1F; const u16 dstXG = c2 & 0x03E0; u32 rb = srcRB - dstRB; u32 xg = srcXG - dstXG; rb *= alpha; xg *= alpha; rb >>= 5; xg >>= 5; rb += dstRB; xg += dstXG; rb &= 0x7C1F; xg &= 0x03E0; return (u16)(rb | xg); } /* Pixel = c0 * (c1/31). c0 Alpha retain */ inline u16 PixelMul16 ( const u16 c0, const u16 c1) { return (u16)((( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 ) | (( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 ) | (( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 ) | (c0 & 0x8000)); } /* Pixel = c0 * (c1/31). */ inline u16 PixelMul16_2 ( u16 c0, u16 c1) { return (u16)(( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 | ( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 | ( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 | ( c0 & c1 & 0x8000)); } /* Pixel = c0 * (c1/255). c0 Alpha Retain */ REALINLINE u32 PixelMul32 ( const u32 c0, const u32 c1) { return (c0 & 0xFF000000) | (( ( (c0 & 0x00FF0000) >> 12 ) * ( (c1 & 0x00FF0000) >> 12 ) ) & 0x00FF0000 ) | (( ( (c0 & 0x0000FF00) * (c1 & 0x0000FF00) ) >> 16 ) & 0x0000FF00 ) | (( ( (c0 & 0x000000FF) * (c1 & 0x000000FF) ) >> 8 ) & 0x000000FF); } /* Pixel = c0 * (c1/255). */ REALINLINE u32 PixelMul32_2 ( const u32 c0, const u32 c1) { return (( ( (c0 & 0xFF000000) >> 16 ) * ( (c1 & 0xFF000000) >> 16 ) ) & 0xFF000000 ) | (( ( (c0 & 0x00FF0000) >> 12 ) * ( (c1 & 0x00FF0000) >> 12 ) ) & 0x00FF0000 ) | (( ( (c0 & 0x0000FF00) * (c1 & 0x0000FF00) ) >> 16 ) & 0x0000FF00 ) | (( ( (c0 & 0x000000FF) * (c1 & 0x000000FF) ) >> 8 ) & 0x000000FF); } /* Pixel = clamp ( c0 + c1, 0, 255 ) */ REALINLINE u32 PixelAdd32 ( const u32 c2, const u32 c1) { u32 sum = ( c2 & 0x00FFFFFF ) + ( c1 & 0x00FFFFFF ); u32 low_bits = ( c2 ^ c1 ) & 0x00010101; s32 carries = ( sum - low_bits ) & 0x01010100; u32 modulo = sum - carries; u32 clamp = carries - ( carries >> 8 ); return modulo | clamp; } #if 0 // 1 - Bit Alpha Blending inline u16 PixelBlend16 ( const u16 destination, const u16 source ) { if((source & 0x8000) == 0x8000) return source; // The source is visible, so use it. else return destination; // The source is transparent, so use the destination. } // 1 - Bit Alpha Blending 16Bit SIMD inline u32 PixelBlend16_simd ( const u32 destination, const u32 source ) { switch(source & 0x80008000) { case 0x80008000: // Both source pixels are visible return source; case 0x80000000: // Only the first source pixel is visible return (source & 0xFFFF0000) | (destination & 0x0000FFFF); case 0x00008000: // Only the second source pixel is visible. return (destination & 0xFFFF0000) | (source & 0x0000FFFF); default: // Neither source pixel is visible. return destination; } } #else // 1 - Bit Alpha Blending inline u16 PixelBlend16 ( const u16 c2, const u16 c1 ) { u16 mask = ((c1 & 0x8000) >> 15 ) + 0x7fff; return (c2 & mask ) | ( c1 & ~mask ); } // 1 - Bit Alpha Blending 16Bit SIMD inline u32 PixelBlend16_simd ( const u32 c2, const u32 c1 ) { u32 mask = ((c1 & 0x80008000) >> 15 ) + 0x7fff7fff; return (c2 & mask ) | ( c1 & ~mask ); } #endif /*! Pixel = dest * ( 1 - SourceAlpha ) + source * SourceAlpha */ inline u32 PixelBlend32 ( const u32 c2, const u32 c1 ) { // alpha test u32 alpha = c1 & 0xFF000000; if ( 0 == alpha ) return c2; if ( 0xFF000000 == alpha ) { return c1; } alpha >>= 24; // add highbit alpha, if ( alpha > 127 ) alpha += 1; alpha += ( alpha >> 7); u32 srcRB = c1 & 0x00FF00FF; u32 srcXG = c1 & 0x0000FF00; u32 dstRB = c2 & 0x00FF00FF; u32 dstXG = c2 & 0x0000FF00; u32 rb = srcRB - dstRB; u32 xg = srcXG - dstXG; rb *= alpha; xg *= alpha; rb >>= 8; xg >>= 8; rb += dstRB; xg += dstXG; rb &= 0x00FF00FF; xg &= 0x0000FF00; return (c1 & 0xFF000000) | rb | xg; } // some 2D Defines struct AbsRectangle { s32 x0; s32 y0; s32 x1; s32 y1; }; //! 2D Intersection test inline bool intersect ( AbsRectangle &dest, const AbsRectangle& a, const AbsRectangle& b) { dest.x0 = core::s32_max( a.x0, b.x0 ); dest.y0 = core::s32_max( a.y0, b.y0 ); dest.x1 = core::s32_min( a.x1, b.x1 ); dest.y1 = core::s32_min( a.y1, b.y1 ); return dest.x0 < dest.x1 && dest.y0 < dest.y1; } // some 1D defines struct sIntervall { s32 start; s32 end; }; // returning intersection width inline s32 intervall_intersect_test( const sIntervall& a, const sIntervall& b) { return core::s32_min( a.end, b.end ) - core::s32_max( a.start, b.start ); } } // end namespace irr #endif
[ "hongduc.pr@gmail.com" ]
hongduc.pr@gmail.com
db3fd5cd898473c2e716c47b7068fe11a66d86da
cc5a7ff1651b7f744096b963b706da193c9fda64
/ch1_DP1/9095.cpp
f7f7a0c5cec085726ae2fd33f5c9cd0ca096165e
[]
no_license
Taeu/Algo
bc80a0c7c12b6e80b72c5510bb8601c73e46996e
8aa5d7c72bcd52b6c6c66460e1a69dd018f6f1f5
refs/heads/master
2020-03-10T19:15:16.344175
2019-07-04T09:00:33
2019-07-04T09:00:33
129,544,183
0
0
null
null
null
null
UTF-8
C++
false
false
384
cpp
#include<vector> #include<iostream> using namespace std; #pragma warning(disable:4996) int dp[1001]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; dp[1] = 1; dp[2] = 2; dp[3] = 4; for (int i = 4; i < 12; i++) { dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]; } while (n--) { int num; cin >> num; cout << dp[num] << '\n'; } return 0; }
[ "specia1ktu@gmail.com" ]
specia1ktu@gmail.com
b6d1ae100c4b12d58497a1eaad56b48cb81c983b
c732666c24d86e0da4cd2c1ee12619e9c514e818
/offline/01_03/02-14/1654.cpp
13d2c8ada4c13da6beb6b7997db7ce669f3af75e
[]
no_license
Algostu/boradori
032f71e9e58163d3e188856629a5de4afaa87b30
939d60e8652074e26ba08252217f7788cae9063c
refs/heads/master
2023-04-22T03:57:26.823917
2021-04-06T23:09:36
2021-04-06T23:09:36
263,754,451
0
0
null
null
null
null
UTF-8
C++
false
false
864
cpp
// Created on 강한결의 iPad. #include <bits/stdc++.h> using namespace std; inline long long splitN(vector<int> &arr, int N){ long long sum = 0; int size = arr.size(); for(int i=0; i<size; i++){ sum += arr[i] / N; } return sum; } int main() { int k, n; cin >> k >> n; vector<int> arr(k); int max_val = 0; for(int i=0; i<k; i++){ scanf("%d", &arr[i]); max_val = max(max_val, arr[i]); } int m = 1; long long l = 2; long long r = max_val; int size = arr.size(); while(l <= r){ long long c_m = (l + r)/2; long long t = 0; for(int i=0; i<size; i++){ t += arr[i]/c_m; } if(t >= n){ m = c_m; l = c_m+1; } else { r = c_m-1; } } cout << m << "\n"; return 0; }
[ "consistant1y@ajou.ac.kr" ]
consistant1y@ajou.ac.kr
2dfe461e3d84346201040bdb3c1a9a205ed01958
0df59ab0f0e41625b93e9860bb2c7d61b7127cef
/algoritmoGeneticoCPlusPlus/teste.h
ed0c7ab8d238bbce130edd7a651ea4fbc4f0eae6
[]
no_license
RichardUlissesGabriel/tcc-algoritmo-genetico
3a5a95fa66562f48c370a8f08a878f6e877b55c1
d0ad3058111ac46ce58bcbd06bb38d1d5c76c0c7
refs/heads/master
2023-01-30T04:56:03.814396
2020-12-14T23:56:19
2020-12-14T23:56:19
321,500,986
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
976
h
#pragma once #include <string> #include <vector> #include <map> using namespace std; class teste{ private: string nomeTeste; string nomeFileSaida; //vetor de parametros, cada elemento é um conjunto de parametros map<string, int> conjuntoParams; public: teste(); ~teste(); string getNomeTeste(); string getNomeFileSaida(); map<string, int>& getConjuntoParams(); void setNomeTeste(string); void setNomeFileSaida(string); void setConjuntoParams(map<string, int>); }; class conjuntoTestes { private: int id; string nomeConjuntoTeste; string nomeFileSaida; vector<teste> conjuntoTeste; public: conjuntoTestes(); ~conjuntoTestes(); int getId(); string getNomeConjuntoTeste(); string getNomeFileSaida(); vector<teste>& getConjuntoTeste(); void setId(int); void setNomeConjuntoTeste(string); void setconjuntoTeste(vector<teste>); void addTeste(teste); void setNomeFileSaida(string); };
[ "rick_gabriel2009@hotmail.com" ]
rick_gabriel2009@hotmail.com
f208fe64e10922f4127ce82544d841edb7761c8e
01a42b69633daf62a2eb3bb70c5b1b6e2639aa5f
/SCUM_Sexy_Jeans_Shorts_02_functions.cpp
e6131ce2fabe7b1fb0bfa6bef4d203571cfa1480
[]
no_license
Kehczar/scum_sdk
45db80e46dac736cc7370912ed671fa77fcb95cf
8d1770b44321a9d0b277e4029551f39b11f15111
refs/heads/master
2022-07-25T10:06:20.892750
2020-05-21T11:45:36
2020-05-21T11:45:36
265,826,541
1
0
null
null
null
null
UTF-8
C++
false
false
3,196
cpp
// Scum 3.79.22573 (UE 4.24) #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace Classes { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function ConZ.ClothesItem.UpdateMaterialParamsOnClients // () void ASexy_Jeans_Shorts_02_C::UpdateMaterialParamsOnClients() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.UpdateMaterialParamsOnClients"); ASexy_Jeans_Shorts_02_C_UpdateMaterialParamsOnClients_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.ClothesItem.SetDirtiness // () // Parameters: // float* dirtiness (Parm, ZeroConstructor, IsPlainOldData) void ASexy_Jeans_Shorts_02_C::SetDirtiness(float* dirtiness) { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.SetDirtiness"); ASexy_Jeans_Shorts_02_C_SetDirtiness_Params params; params.dirtiness = dirtiness; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.ClothesItem.OnRep_MaterialParameters // () void ASexy_Jeans_Shorts_02_C::OnRep_MaterialParameters() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.OnRep_MaterialParameters"); ASexy_Jeans_Shorts_02_C_OnRep_MaterialParameters_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.ClothesItem.GetWarmth // () // Parameters: // int ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) int ASexy_Jeans_Shorts_02_C::GetWarmth() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.GetWarmth"); ASexy_Jeans_Shorts_02_C_GetWarmth_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.ClothesItem.GetCapacityY // () // Parameters: // int ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) int ASexy_Jeans_Shorts_02_C::GetCapacityY() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.GetCapacityY"); ASexy_Jeans_Shorts_02_C_GetCapacityY_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.ClothesItem.GetCapacityX // () // Parameters: // int ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) int ASexy_Jeans_Shorts_02_C::GetCapacityX() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.GetCapacityX"); ASexy_Jeans_Shorts_02_C_GetCapacityX_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "65712402+Kehczar@users.noreply.github.com" ]
65712402+Kehczar@users.noreply.github.com
bfaf862660651a6e89249f4d705084e413f2ae9f
4e70b3c405ac56c985f61b6394591fae98563eb0
/configuration.cpp
fcf8c7c00dd6869eb80146375fd20a4d96ae5cc2
[]
no_license
chrisschuette/GL.Minimizer
06c6833f26d8d3a907a7e85e44c5277a8788e504
aed4339e8025295c1156c7df56a90dd70cb2cf80
refs/heads/master
2021-01-25T07:28:15.472121
2014-06-28T10:39:32
2014-06-28T10:39:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,169
cpp
/* * File: Configuration.cpp * Author: chris * * Created on January 2, 2012, 2:32 PM */ #include "configuration.h" #include "exception.h" #include "utils.h" #include "luainterpreter.h" #include <iostream> #include <sstream> using namespace basic; bool Configuration::s_registered = scripting::LuaInterpreter::getInstance().addRegisterFunction(Configuration::Register); void Configuration::Register() { #ifndef LUADISABLED scripting::LuaInterpreter& luaInterpreter = scripting::LuaInterpreter::getInstance(); if(!luaInterpreter.isClassRegistered("Configuration")) { luabind::module(luaInterpreter.getL()) [ luabind::class_< Configuration >("Configuration") .def("readFile", &Configuration::readFile) .def("addSetting", &Configuration::addSetting) .def("editSetting", &Configuration::editSetting) .def("getDouble", &Configuration::getDouble) .def("getBool", &Configuration::getBool) .def("getInteger", &Configuration::getInteger) .def("getString", &Configuration::getString) //dictionary ]; luaInterpreter.setClassRegistered("Configuration"); } #endif } std::auto_ptr<Configuration> Configuration::m_instancePtr(0); Configuration& Configuration::getInstance() { if(m_instancePtr.get() == 0) { m_instancePtr = std::auto_ptr<Configuration>(new Configuration); } return *m_instancePtr.get(); } Configuration::Configuration() : Named("Configuration") { } void Configuration::readFile(std::string configFile) { try { m_configuration.readFile(configFile.c_str()); } catch (libconfig::SettingTypeException& ste) { ERROR(std::string("invalid type for ") + std::string(ste.getPath())); } catch(libconfig::SettingNotFoundException& snfe) { ERROR(std::string("setting not found: ") + snfe.getPath()); } catch (libconfig::ParseException& pe) { ERROR(std::string("unable to parse config file ") + pe.getFile() + " at line " + utils::toString(pe.getLine())); } catch(libconfig::FileIOException& fioe) { ERROR("Unable to read file " + configFile) } catch (...) { throw; // someone will be interested in this } } void Configuration::addSetting(std::string path, std::string name, std::string value) { libconfig::Setting& group = m_configuration.lookup(path); libconfig::Setting& setting = group.add(name, libconfig::Setting::TypeString); setting = value; } void Configuration::editSetting(std::string path, std::string name, double value) { std::string fullpath = ""; if(path != "") fullpath = path + "."; fullpath += name; libconfig::Setting& setting = m_configuration.lookup(fullpath); setting = value; } double Configuration::getDouble(std::string path) { return m_configuration.lookup(path); } bool Configuration::getBool(std::string path) { return m_configuration.lookup(path); } int Configuration::getInteger(std::string path) { return m_configuration.lookup(path); } std::string Configuration::getString(std::string path){ return m_configuration.lookup(path); } Configuration::~Configuration() { }
[ "mail@christophschuette.com" ]
mail@christophschuette.com
48702dbfe46eb357ccff793bd750038900df46fe
1ee5f4a7d365db72ab3dc5d87a16d4f64debe5e3
/Source/SourceStringChecker.h
cf2f81b9f87f04c3981b188718fcb4ddf5b7dc07
[]
no_license
Bigstorm20008/FileConverter
9fe4f409811f155b80c82f69877cabf2616875b5
effc773eadd48ae56575d0397c6f862e44a18a35
refs/heads/master
2020-03-28T02:18:31.427612
2018-09-09T05:42:24
2018-09-09T05:42:24
147,561,434
0
1
null
null
null
null
UTF-8
C++
false
false
597
h
#ifndef SOURCE_STRING_CHECKER_H #define SOURCE_STRING_CHECKER_H #include <string> class SourceStringChecker { public: SourceStringChecker(); ~SourceStringChecker(); bool isCorrectString(const std::wstring& sourceString); const std::wstring& getUnixTimeStamp()const; const std::wstring& getBid()const; const std::wstring& getAsk()const; private: const wchar_t m_limiter; const size_t m_correctTimeStampLenght; std::wstring m_unixTimeStamp; std::wstring m_bid; std::wstring m_ask; bool checkTimeStamp()const; bool checkBidAndAsk()const; }; #endif // !SOURCE_STRING_CHECKER_H
[ "bigstorm@3g.ua" ]
bigstorm@3g.ua
f261c6aab6aaf1707ad00245a1180d01e8d80a52
e27d9e460c374473e692f58013ca692934347ef1
/drafts/quickSpectrogram_2/libraries/liblsl/external/lslboost/spirit/home/phoenix/object/construct.hpp
a278872d71753b23f52406af9732eff0a821a753
[ "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
2,573
hpp
/*============================================================================= Copyright (c) 2001-2007 Joel de Guzman Distributed under 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) ==============================================================================*/ #ifndef PHOENIX_OBJECT_CONSTRUCT_HPP #define PHOENIX_OBJECT_CONSTRUCT_HPP #include <lslboost/spirit/home/phoenix/core/compose.hpp> #include <lslboost/preprocessor/repetition/enum_params_with_a_default.hpp> namespace lslboost { namespace phoenix { namespace detail { template <typename T> struct construct_eval { template <typename Env, BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( PHOENIX_COMPOSITE_LIMIT, typename T, fusion::void_)> struct result { typedef T type; }; template <typename RT, typename Env> static RT eval(Env const& /*env*/) { return RT(); } template <typename RT, typename Env, typename A0> static RT eval(Env const& env, A0& _0) { return RT(_0.eval(env)); } template <typename RT , typename Env, typename A0, typename A1> static RT eval(Env const& env, A0& _0, A1& _1) { return RT(_0.eval(env), _1.eval(env)); } // Bring in the rest of the evals #include <lslboost/spirit/home/phoenix/object/detail/construct_eval.hpp> }; } template <typename T> inline actor<typename as_composite<detail::construct_eval<T> >::type> construct() { return compose<detail::construct_eval<T> >(); } template <typename T, typename A0> inline actor<typename as_composite<detail::construct_eval<T>, A0>::type> construct(A0 const& _0) { return compose<detail::construct_eval<T> >(_0); } template <typename T, typename A0, typename A1> inline actor<typename as_composite<detail::construct_eval<T>, A0, A1>::type> construct(A0 const& _0, A1 const& _1) { return compose<detail::construct_eval<T> >(_0, _1); } // Bring in the rest of the new_ functions #include <lslboost/spirit/home/phoenix/object/detail/construct.hpp> }} #endif
[ "gabriel.ibagon@gmail.com" ]
gabriel.ibagon@gmail.com
cffa2092ab5e08861aa438506ca0fea668b0babb
c67ed12eae84af574406e453106b7d898ff47dc7
/chap02/Exer02_35.cpp
b5ed3a275f16d6ad777e7194ae1f76d2ed6a57cb
[ "Apache-2.0" ]
permissive
chihyang/CPP_Primer
8374396b58ea0e1b0f4c4adaf093a7c0116a6901
9e268d46e9582d60d1e9c3d8d2a41c1e7b83293b
refs/heads/master
2022-09-16T08:54:59.465691
2022-09-03T17:25:59
2022-09-03T17:25:59
43,039,810
58
23
Apache-2.0
2023-01-14T07:06:19
2015-09-24T02:25:47
C++
UTF-8
C++
false
false
408
cpp
#include<iostream> int main() { const int i =42; auto j = i; // int const auto &k = i; // const reference(or say, reference to const) auto *p = &i; // pointer to const, const of i is not ignored, so it's const int * const auto j2 = i, &k2 = i; // j2, const int; i, const reference std::cout << j << " " << k << " " << *p << " " << j2 << " " << k2 << " " << std::endl; return 0; }
[ "chihyanghsin@gmail.com" ]
chihyanghsin@gmail.com
62f8a88d8ea63c077e9336e5ce6429e445ace5aa
d05383f9f471b4e0691a7735aa1ca50654704c8b
/CPP2MIssues/SampleClass686.cpp
169e8ab2423e5fa61bbe6a647e17af80d4179f57
[]
no_license
KetkiT/CPP2MIssues
d2186a78beeb36312cc1a756a005d08043e27246
82664377d0f0047d84e6c47e9380d1bafa840d19
refs/heads/master
2021-08-26T07:27:00.804769
2017-11-22T07:29:45
2017-11-22T07:29:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
50,048
cpp
class SampleClass686{ public: void m1() { int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); } };
[ "ketki.thosar@acellere.com" ]
ketki.thosar@acellere.com
db61f3de0417c3cc4b3ed4571c7f94071e8d4af3
8cf32b4cbca07bd39341e1d0a29428e420b492a6
/contracts/libc++/upstream/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp
78090344684003b947e775308c9aab6751315c55
[ "NCSA", "MIT" ]
permissive
cubetrain/CubeTrain
e1cd516d5dbca77082258948d3c7fc70ebd50fdc
b930a3e88e941225c2c54219267f743c790e388f
refs/heads/master
2020-04-11T23:00:50.245442
2018-12-17T16:07:16
2018-12-17T16:07:16
156,970,178
0
0
null
null
null
null
UTF-8
C++
false
false
709
cpp
//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <random> // template<class RealType = double> // class weibull_distribution // weibull_distribution(const weibull_distribution&); #include <random> #include <cassert> void test1() { typedef std::weibull_distribution<> D; D d1(20, 1.75); D d2 = d1; assert(d1 == d2); } int main() { test1(); }
[ "1848@shanchain.com" ]
1848@shanchain.com
bd6f6e2d7f8647c6251e2bcdf5cf39da0f45eeac
8465159705a71cede7f2e9970904aeba83e4fc6c
/src_change_the_layout/modules/IEC61131-3/Conversion/BYTE/F_BYTE_TO_WORD.h
5231045cb24368637df36a289a3acba93d9a0a6e
[]
no_license
TuojianLYU/forte_IO_OPCUA_Integration
051591b61f902258e3d0d6608bf68e2302f67ac1
4a3aed7b89f8a7d5f9554ac5937cf0a93607a4c6
refs/heads/main
2023-08-20T16:17:58.147635
2021-10-27T05:34:43
2021-10-27T05:34:43
419,704,624
1
0
null
null
null
null
UTF-8
C++
false
false
1,841
h
/******************************************************************************* * Copyright (c) 2011 ACIN * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Monika Wenger * - initial API and implementation and/or initial documentation *******************************************************************************/ #ifndef _F_BYTE_TO_WORD_H_ #define _F_BYTE_TO_WORD_H_ #include <funcbloc.h> class FORTE_F_BYTE_TO_WORD: public CFunctionBlock{ DECLARE_FIRMWARE_FB(FORTE_F_BYTE_TO_WORD) private: static const CStringDictionary::TStringId scm_anDataInputNames[]; static const CStringDictionary::TStringId scm_anDataInputTypeIds[]; CIEC_BYTE &st_IN() { return *static_cast<CIEC_BYTE*>(getDI(0)); }; static const CStringDictionary::TStringId scm_anDataOutputNames[]; static const CStringDictionary::TStringId scm_anDataOutputTypeIds[]; CIEC_WORD &st_OUT() { return *static_cast<CIEC_WORD*>(getDO(0)); }; static const TEventID scm_nEventREQID = 0; static const TForteInt16 scm_anEIWithIndexes[]; static const TDataIOID scm_anEIWith[]; static const CStringDictionary::TStringId scm_anEventInputNames[]; static const TEventID scm_nEventCNFID = 0; static const TForteInt16 scm_anEOWithIndexes[]; static const TDataIOID scm_anEOWith[]; static const CStringDictionary::TStringId scm_anEventOutputNames[]; static const SFBInterfaceSpec scm_stFBInterfaceSpec; FORTE_FB_DATA_ARRAY(1, 1, 1, 0); void executeEvent(int pa_nEIID); public: FUNCTION_BLOCK_CTOR(FORTE_F_BYTE_TO_WORD){ }; virtual ~FORTE_F_BYTE_TO_WORD(){}; }; #endif //close the ifdef sequence from the beginning of the file
[ "tuojianlyu@gmail.com" ]
tuojianlyu@gmail.com
4baa3758359665b3ca2f7202abdb4460e2b72126
b956eb9be02f74d81176bc58d585f273accf73fb
/aladdin/audio/Sound.h
0b8f7ea1c21f0a1df4922be162ecfbc05981f84a
[ "MIT" ]
permissive
Khuongnb/game-aladdin
b9b1c439d14658ca9d67d5c6fe261ec27084b2e9
74b13ffcd623de0d6f799b0669c7e8917eef3b14
refs/heads/master
2020-05-05T10:20:05.616126
2019-04-07T09:05:11
2019-04-07T09:05:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
762
h
#ifndef __ALADDIN_AUDIO_SOUND_H__ #define __ALADDIN_AUDIO_SOUND_H__ #include "AudioInclude.h" NAMESPACE_ALA { ALA_CLASS_HEADER_2(Sound, ala::Initializable, ala::Releasable) private: std::string _sourceFile; public: Sound( const std::string& sourceFile ); virtual ~Sound(); public: void initialize() override; void release() override; const std::string& getSourceFile() const; // =================================================== // Platform specific // =================================================== private: CSound* _cSound; public: CSound* getCSound() const; void setCSound( CSound* cSound ); bool isPlaying() const; private: void initCSound(); void releaseCSound(); }; } #endif //!__ALADDIN_AUDIO_SOUND_H__
[ "khuongnb1997@gmail.com" ]
khuongnb1997@gmail.com
c163b77ddc758f80373ae592dfdd1532e1285514
7acc4c004ab9865b9ddd2ffdbe1075bcecbf519a
/tetrixwindow.cpp
721065a7cab3089d780f398a3214b80aa4dafd10
[]
no_license
m17saitou/QTetris
8d84e4faaca4f7b4cfe4f700c51eacaf73457a65
ccc25f034ba455ff4682da3606b95924e161d93f
refs/heads/master
2020-08-31T01:07:57.230127
2019-11-02T00:44:09
2019-11-02T00:44:09
218,542,039
0
0
null
null
null
null
UTF-8
C++
false
false
5,384
cpp
/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** BSD License Usage ** Alternatively, you may use this file under the terms of the BSD license ** as follows: ** ** "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 Qt Company Ltd 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." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "tetrixboard.h" #include "tetrixwindow.h" #include <QCoreApplication> #include <QGridLayout> #include <QLabel> #include <QLCDNumber> #include <QPushButton> //! [0] TetrixWindow::TetrixWindow(QWidget *parent) : QWidget(parent), board(new TetrixBoard) { //! [0] nextPieceLabel = new QLabel; nextPieceLabel->setFrameStyle(QFrame::Box | QFrame::Raised); nextPieceLabel->setAlignment(Qt::AlignCenter); board->setNextPieceLabel(nextPieceLabel); //! [1] scoreLcd = new QLCDNumber(5); scoreLcd->setSegmentStyle(QLCDNumber::Filled); //! [1] levelLcd = new QLCDNumber(2); levelLcd->setSegmentStyle(QLCDNumber::Filled); linesLcd = new QLCDNumber(5); linesLcd->setSegmentStyle(QLCDNumber::Filled); //! [2] startButton = new QPushButton(tr("&Start")); startButton->setFocusPolicy(Qt::NoFocus); quitButton = new QPushButton(tr("&Quit")); quitButton->setFocusPolicy(Qt::NoFocus); pauseButton = new QPushButton(tr("&Pause")); //! [2] //! [3] pauseButton->setFocusPolicy(Qt::NoFocus); //! [3] //! [4] connect(startButton, &QPushButton::clicked, board, &TetrixBoard::start); //! [4] //! [5] connect(quitButton , &QPushButton::clicked, qApp, &QCoreApplication::quit); connect(pauseButton, &QPushButton::clicked, board, &TetrixBoard::pause); #if __cplusplus >= 201402L connect(board, &TetrixBoard::scoreChanged, scoreLcd, qOverload<int>(&QLCDNumber::display)); connect(board, &TetrixBoard::levelChanged, levelLcd, qOverload<int>(&QLCDNumber::display)); connect(board, &TetrixBoard::linesRemovedChanged, linesLcd, qOverload<int>(&QLCDNumber::display)); #else connect(board, &TetrixBoard::scoreChanged, scoreLcd, QOverload<int>::of(&QLCDNumber::display)); connect(board, &TetrixBoard::levelChanged, levelLcd, QOverload<int>::of(&QLCDNumber::display)); connect(board, &TetrixBoard::linesRemovedChanged, linesLcd, QOverload<int>::of(&QLCDNumber::display)); #endif //! [5] //! [6] QGridLayout *layout = new QGridLayout; layout->addWidget(createLabel(tr("NEXT")), 0, 0); layout->addWidget(nextPieceLabel, 1, 0); layout->addWidget(createLabel(tr("LEVEL")), 2, 0); layout->addWidget(levelLcd, 3, 0); layout->addWidget(startButton, 4, 0); layout->addWidget(board, 0, 1, 6, 1); layout->addWidget(createLabel(tr("SCORE")), 0, 2); layout->addWidget(scoreLcd, 1, 2); layout->addWidget(createLabel(tr("LINES REMOVED")), 2, 2); layout->addWidget(linesLcd, 3, 2); layout->addWidget(quitButton, 4, 2); layout->addWidget(pauseButton, 5, 2); setLayout(layout); setWindowTitle(tr("QTetris")); resize(550, 370); } //! [6] //! [7] QLabel *TetrixWindow::createLabel(const QString &text) { QLabel *label = new QLabel(text); label->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); return label; } //! [7]
[ "m17saitou@gmail.com" ]
m17saitou@gmail.com
6767b3cf9937418c1ae894221d24ce4fd5504510
239e2373f459d08b3eabd7e99242c1f756dc97f3
/logdevice/ops/ldquery/tables/LogGroups.cpp
d7b45659450a4a160a23ebe4753db51c5d395120
[ "BSD-3-Clause" ]
permissive
zhengxiaochuan-3/LogDevice
edb04140e1906f281faf26f6789ddd26db3a2cc3
01e2302a382db1d87f934e305c8cc74ffc0a24a4
refs/heads/master
2020-07-06T22:44:08.337104
2019-08-19T10:05:17
2019-08-19T10:07:21
203,161,120
1
0
NOASSERTION
2019-08-19T11:41:10
2019-08-19T11:41:09
null
UTF-8
C++
false
false
5,081
cpp
/** * Copyright (c) 2017-present, Facebook, Inc. and its affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #include "logdevice/ops/ldquery/tables/LogGroups.h" #include <folly/Conv.h> #include <folly/json.h> #include "../Table.h" #include "../Utils.h" #include "logdevice/common/configuration/Configuration.h" #include "logdevice/common/configuration/ReplicationProperty.h" #include "logdevice/common/configuration/UpdateableConfig.h" #include "logdevice/common/debug.h" #include "logdevice/lib/ClientImpl.h" using facebook::logdevice::Configuration; namespace facebook { namespace logdevice { namespace ldquery { namespace tables { TableColumns LogGroups::getColumns() const { return { {"name", DataType::TEXT, "Name of the log group."}, {"logid_lo", DataType::LOGID, "Defines the lower bound (inclusive) of the range of log ids in this " "log group."}, {"logid_hi", DataType::LOGID, "Defines the upper bound (inclusive) of the range of log ids in this " "log group."}, {"replication_property", DataType::TEXT, "Replication property configured for this log group."}, {"synced_copies", DataType::INTEGER, "Number of copies that must be acknowledged by storage nodes are synced " "to disk before the record is acknowledged to the client as fully " "appended."}, {"max_writes_in_flight", DataType::INTEGER, "The largest number of records not released for delivery that the " "sequencer allows to be outstanding."}, {"backlog_duration_sec", DataType::INTEGER, "Time-based retention of records of logs in that log group. If null or " "zero, this log group does not use time-based retention."}, {"storage_set_size", DataType::INTEGER, "Size of the storage set for logs in that log group. The storage set " "is the set of shards that may hold data for a log."}, {"delivery_latency", DataType::INTEGER, "For logs in that log group, maximum amount of time that we can delay " "delivery of newly written records. This option increases delivery " "latency but improves server and client performance."}, {"scd_enabled", DataType::INTEGER, "Indicates whether the Single Copy Delivery optimization is enabled for " "this log group. This efficiency optimization allows only one copy of " "each record to be served to readers."}, {"custom_fields", DataType::TEXT, "Custom text field provided by the user."}, }; } std::shared_ptr<TableData> LogGroups::getData(QueryContext& ctx) { auto result = std::make_shared<TableData>(); auto full_client = ld_ctx_->getFullClient(); ld_check(full_client); ClientImpl* client_impl = static_cast<ClientImpl*>(full_client.get()); auto config = client_impl->getConfig()->get(); auto add_row = [&](const std::string name, logid_range_t range) { auto log = config->getLogGroupByIDShared(range.first); ld_check(log); auto log_attrs = log->attrs(); ColumnValue custom; if (log_attrs.extras().hasValue() && (*log_attrs.extras()).size() > 0) { folly::dynamic extra_attrs = folly::dynamic::object; for (const auto& it : log_attrs.extras().value()) { extra_attrs[it.first] = it.second; } custom = folly::toJson(extra_attrs); } ReplicationProperty rprop = ReplicationProperty::fromLogAttributes(log_attrs); // This should remain the first ColumnValue as expected by the code below. result->cols["name"].push_back(name); result->cols["logid_lo"].push_back(s(range.first.val_)); result->cols["logid_hi"].push_back(s(range.second.val_)); result->cols["replication_property"].push_back(rprop.toString()); result->cols["synced_copies"].push_back(s(*log_attrs.syncedCopies())); result->cols["max_writes_in_flight"].push_back( s(*log_attrs.maxWritesInFlight())); result->cols["backlog_duration_sec"].push_back( s(*log_attrs.backlogDuration())); result->cols["storage_set_size"].push_back(s(*log_attrs.nodeSetSize())); result->cols["delivery_latency"].push_back(s(*log_attrs.deliveryLatency())); result->cols["scd_enabled"].push_back(s(*log_attrs.scdEnabled())); result->cols["custom_fields"].push_back(custom); }; // If the query contains a constraint on the group name, we can efficiently // find the log group using getLogRangeByName(). std::string expr; if (columnHasEqualityConstraint(0, ctx, expr)) { logid_range_t range = config->logsConfig()->getLogRangeByName(expr); if (range.first != LOGID_INVALID) { add_row(expr, range); } } else { auto ranges = config->logsConfig()->getLogRangesByNamespace(""); for (auto& r : ranges) { add_row(s(r.first), r.second); } } return result; } }}}} // namespace facebook::logdevice::ldquery::tables
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
742b82d140ef9dc0d6bd463ee9b262c4a323357a
0ce9c7737c67548001d757eb4f3225b693f1619b
/src/Raster_Reader.cpp
58caea814741e7bc225082ce37da394bd6ad0c13
[]
no_license
welarfao/Fire-rs-internship
808a6c8ce66882599d542ffca59ed6ad8cf9eb15
1c0fc8e2778e7bdf5dc35cd0147d8ecd22eb89f7
refs/heads/master
2020-03-27T22:20:52.766353
2018-09-03T15:22:07
2018-09-03T15:22:07
147,223,114
0
0
null
null
null
null
UTF-8
C++
false
false
5,523
cpp
#include "Raster_Reader.h" Raster_Reader::Raster_Reader( ){ } Raster_Reader::Raster_Reader( const std::string& path){ GDALAllRegister() ; /*Once the drivers are registered, the application should call the free standing GDALOpen() function to open a dataset, passing the name of the dataset and the access desired (GA_ReadOnly or GA_Update).*/ /// get a DEM file gDataSet = (GDALDataset * ) GDALOpen( path.c_str() , GA_ReadOnly); ///check if data is present if (gDataSet == NULL){ cerr<< "No data found"; //break ; }; nCols = gDataSet->GetRasterXSize(); nRows = gDataSet->GetRasterYSize(); nBands = gDataSet->GetRasterCount(); no_data_value = gDataSet->GetRasterBand(1)->GetNoDataValue(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////// //this function fetches the values of :originX, originY, pWidth, pHeightusing GDAL geotransform ; void Raster_Reader::geoTransform() { if( gDataSet->GetGeoTransform(gTransform) == CE_None ){ //position of the top left x originX = gTransform[0]; //position of top left y originY = gTransform[3]; //the pixel width //west-east pixel resolution pWidth = gTransform[1]; //the pixel height//north-south pixel resolution (negative value) pHeight = gTransform[5]; max_east = originX + nCols*gTransform[1]; max_west = originX ; max_north = originY; max_south = originY + nRows*gTransform[5]; }else{ cerr<<"DEM error : no transform can be fetched"; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string Raster_Reader::get_projection(){ return gDataSet->GetProjectionRef(); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Raster_Reader::Put_Raster_invector(){ GDALRasterBand *poBand; poBand = gDataSet->GetRasterBand( 1 ); float maxH=0; float minH=10000; float *Buffer; int nXSize = poBand->GetXSize(); //read row data and store in vector for(int i=0; i < nRows; i++){ //buffer to read row:creates a free space in the memory with the size we order Buffer = (float *) CPLMalloc(sizeof(float)*nXSize); // read a row poBand ->RasterIO(GF_Read, 0, i, nXSize, 1, Buffer, nXSize, 1, GDT_Float32, 0, 0); for (int j=0; j< nCols; ++j){ RasterData.push_back(Buffer[j]); maxH = max(maxH,Buffer[j]); if( Buffer[j] != poBand->GetNoDataValue()){ minH = min(minH,Buffer[j]); } } CPLFree(Buffer); } maxheight = maxH; minheight = minH; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Raster_Reader::Put_in_Raster(cv::Mat FP,string gdal_result_path) { GDALDriver *poDriver; const char *pszFormat = "GTiff"; poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); char **papszOptions = NULL; GDALDataset *poDstDS; poDstDS = poDriver->Create( gdal_result_path.c_str(), nCols, nRows,1, GDT_Float32 ,papszOptions ); poDstDS->SetGeoTransform( gTransform); poDstDS->SetProjection( gDataSet->GetProjectionRef() ); GDALRasterBand *poBand; poBand = poDstDS->GetRasterBand(1); float *Buffer; for(int i=0; i < nRows; i++){ Buffer = (float *) CPLMalloc(sizeof(float)*nCols); for (int j=0; j< nCols; ++j){ Buffer[j] =FP.at<uchar>(i,j); } poBand->RasterIO(GF_Write , 0, i, nCols, 1, Buffer, nCols, 1, GDT_Float32 , 0, 0); } GDALClose( (GDALDatasetH) poDstDS ); CPLFree(Buffer); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Point2D Raster_Reader::get_World_coord(float col , float row ){ Point2D point; point.x = originX + col*gTransform[1] + row*gTransform[2]; point.y = originY + col*gTransform[4] + row*gTransform[5]; return point; } /////////////////////////////////////////////////////////////////////////////////////////// Pixel Raster_Reader::get_pixel(double x , double y ){ /* X = originX + col*geoTransform[1] + row*geoTransform[2]; Y = originY + col*geoTransform[4] + row*geoTransform[5]; we consider that we won t have any rotation ,so the equations become : X = originX + col*geoTransform[1] ; Y = originY + row*geoTransform[5]; */ Pixel pix; pix.col = (int) ((x - originX ) / gTransform[1]) ; pix.row = (int) ((y - originY) / gTransform[5]) ; return pix ; } //////////////////////////////////////////////////////// double Raster_Reader::get_height(size_t col , size_t row ){ /* RasterData=[ (# # # # ... # # # nCols values)first row / (# # # # ... # # # nCols values )second row / ..............(# # # # ... # # # nCols values)last row which is the row number nRows] so to get to the row number y we multiply it with number of cols ,and then we add the position of the the colonne x we need to be exqctly at the position (x,y) of the matrix */ size_t cpt = 0 ; cpt = nCols*row + col ; return RasterData[cpt] ; } //////////////////////////////////////////////////////////////////////////////////////////// Raster_Reader::~Raster_Reader() { if (gDataSet != NULL){ GDALClose(gDataSet); } }
[ "welarfao@laas.fr" ]
welarfao@laas.fr
866029caeb3f341d798cf6bfa5d73c3448c139cb
b78fc2c6f75020a534a5fd62cd75549fecd73f77
/lib/string_utils.cpp
ef7386f84434d5d760597bec0eac078109820f68
[]
no_license
mrdooz/world
a59b5204bdbc12edaaf255d6cdadb6326f199551
7782ed26200bee2ef0ae6e506241fd8610b603fd
refs/heads/master
2021-01-10T06:14:46.035579
2015-11-16T02:14:29
2015-11-16T02:14:29
45,221,867
0
0
null
null
null
null
UTF-8
C++
false
false
3,491
cpp
#include "string_utils.hpp" #include <stdint.h> using namespace std; namespace world { string ToString(char const* const format, ...) { #ifdef _WIN32 va_list arg; va_start(arg, format); const int len = _vscprintf(format, arg) + 1; char* buf = (char*)_alloca(len); vsprintf_s(buf, len, format, arg); va_end(arg); return string(buf); #else static char buf[4 * 1024]; va_list arg; va_start(arg, format); vsprintf(buf, format, arg); string res(buf); va_end(arg); return res; #endif } #ifdef _WIN32 string WideCharToUtf8(const WCHAR* str) { int len = (int)wcslen(str); char* buf = (char*)_alloca(len * 2 + 1); int res = WideCharToMultiByte(CP_UTF8, 0, str, len, buf, len * 2 + 1, NULL, NULL); if (res == 0) return false; buf[res] = '\0'; return string(buf); } bool WideCharToUtf8(LPCOLESTR unicode, int len, string* str) { if (!unicode) return false; char* buf = (char*)_alloca(len * 2 + 1); int res = WideCharToMultiByte(CP_UTF8, 0, unicode, len, buf, len * 2 + 1, NULL, NULL); if (res == 0) return false; buf[res] = '\0'; *str = string(buf); return true; } #endif string Trim(const string& str) { int leading = 0, trailing = 0; while (isspace((uint8_t)str[leading])) leading++; const size_t end = str.size() - 1; while (isspace((uint8_t)str[end - trailing])) trailing++; return leading || trailing ? str.substr(leading, str.size() - (leading + trailing)) : str; } bool StartsWith(const char* str, const char* sub_str) { const size_t len_a = strlen(str); const size_t len_b = strlen(sub_str); if (len_a < len_b) return false; for (; *sub_str; ++str, ++sub_str) { if (*sub_str != *str) return false; } return true; } bool StartsWith(const string& str, const string& sub_str) { const size_t len_a = str.size(); const size_t len_b = sub_str.size(); if (len_a < len_b) return false; for (size_t i = 0; i < len_b; ++i) { if (sub_str[i] != str[i]) return false; } return true; } #ifdef _WIN32 wstring Utf8ToWide(const char* str) { int len = (int)strlen(str); WCHAR* buf = (WCHAR*)_alloca((len + 1) * 2); wstring res; if (MultiByteToWideChar(CP_UTF8, 0, str, -1, buf, (len + 1) * 2)) { res = wstring(buf); } else { int err = GetLastError(); } return res; } #endif //------------------------------------------------------------------------------ vector<string> StringSplit(const string& str, char delim) { vector<string> res; const char* start = str.c_str(); const char* end = str.c_str() + str.size(); const char* cur = start; const char* prevStart = start; while (cur != end) { if (*cur == delim) { res.push_back(string(prevStart, cur - prevStart)); prevStart = cur + 1; } cur++; } if (prevStart < end) { res.push_back(string(prevStart, cur - prevStart)); } return res; } //------------------------------------------------------------------------------ std::string StringJoin(const std::vector<std::string>& v, const std::string& delim) { string res; size_t cnt = v.size(); for (size_t i = 0; i < cnt; ++i) { res += v[i]; if (i != cnt - 1) res += delim; } return res; } }
[ "magnus.osterlind@gmail.com" ]
magnus.osterlind@gmail.com
542621f05afd4050dfdb14ed0478d45627db6e3e
4a2c47d8a84a821235dcdda8d898ff82aea54238
/opcn2.h
ab63b004f00314fafb30eee227d6c745b91ecf8b
[]
no_license
iamczar/opcn2-Arduino
3d3b2ca4f25376903af5b69f6498b9299bf8ea23
3be64397e00d437dd1856a7da9376621c078f382
refs/heads/master
2020-05-16T06:48:06.324850
2019-04-22T20:11:00
2019-04-22T20:11:00
182,858,708
0
0
null
2019-04-22T19:59:51
2019-04-22T19:59:50
null
UTF-8
C++
false
false
3,894
h
/* opcn2.h - Library for operating the Alphasense OPC-N2 Particle counter. Created by David H Hagan, March 2016. Modified by Marcelo Yungaicela, May 2017 Released with an MIT license. */ #ifndef Opcn2_h #define Opcn2_h // Includes struct Status { int fanON; int laserON; int fanDAC; int laserDAC; }; struct Firmware { int major; int minor; }; struct HistogramData { double bin0; double bin1; double bin2; double bin3; double bin4; double bin5; double bin6; double bin7; double bin8; double bin9; double bin10; double bin11; double bin12; double bin13; double bin14; double bin15; // Mass Time-of-Flight float bin1MToF; float bin3MToF; float bin5MToF; float bin7MToF; // Sample Flow Rate float sfr; // Either the Temperature or Pressure unsigned long temp_pressure; // Sampling Period float period; // Checksum unsigned int checksum; float pm1; float pm25; float pm10; }; struct PMData { float pm1; float pm25; float pm10; }; struct ConfigVars { // Bin Boundaries int bb0; int bb1; int bb2; int bb3; int bb4; int bb5; int bb6; int bb7; int bb8; int bb9; int bb10; int bb11; int bb12; int bb13; int bb14; // Bin Particle Volume (floats) float bpv0; float bpv1; float bpv2; float bpv3; float bpv4; float bpv5; float bpv6; float bpv7; float bpv8; float bpv9; float bpv10; float bpv11; float bpv12; float bpv13; float bpv14; float bpv15; // Bin Particle Densities (floats) float bpd0; float bpd1; float bpd2; float bpd3; float bpd4; float bpd5; float bpd6; float bpd7; float bpd8; float bpd9; float bpd10; float bpd11; float bpd12; float bpd13; float bpd14; float bpd15; // Bin Sample Volume Weightings (floats) float bsvw0; float bsvw1; float bsvw2; float bsvw3; float bsvw4; float bsvw5; float bsvw6; float bsvw7; float bsvw8; float bsvw9; float bsvw10; float bsvw11; float bsvw12; float bsvw13; float bsvw14; float bsvw15; // Gain Scaling Coefficient float gsc; // Sample Flow Rate (ml/s) float sfr; // LaserDAC 8 bit int unsigned int laser_dac; unsigned int fan_dac; // Time of Flight to Sample Flow Rate Conversion Factor unsigned int tof_sfr; }; struct ConfigVars2 { int AMSamplingInterval; int AMIntervalCount; int AMFanOnIdle; int AMLaserOnIdle; int AMMaxDataArraysInFile; int AMOnlySavePMData; }; class OPCN2 { private: // attributes uint8_t _CS; int _fv; // methods uint16_t _16bit_int(byte MSB, byte LSB); bool _compare_arrays(byte array1[], byte array2[], int length); float _calculate_float(byte val0, byte val1, byte val2, byte val3); uint32_t _32bit_int(byte val0, byte val1, byte val2, byte val3); public: OPCN2(uint8_t chip_select); // attributes Firmware firm_ver; // methods bool ping(); bool on(); bool off(); bool write_config_variables(byte values[]); bool write_config_variables2(byte values[]); bool write_serial_number_string(byte values[]); bool save_config_variables(); bool enter_bootloader(); bool set_fan_power(uint8_t value); bool set_laser_power(uint8_t value); bool toggle_fan(bool state); bool toggle_laser(bool state); String read_information_string(); String read_serial_number(); Firmware read_firmware_version(); Status read_status(); ConfigVars read_configuration_variables(); ConfigVars2 read_configuration_variables2(); PMData read_pm_data(); HistogramData read_histogram(bool convert_to_conc = true); }; #endif
[ "n.marceloy@gmail.com" ]
n.marceloy@gmail.com
783fc3cd1c5421ac9e2fc132756c161c07388069
a06515f4697a3dbcbae4e3c05de2f8632f8d5f46
/corpus/taken_from_cppcheck_tests/stolen_10725.cpp
ab83292c58601c24314184208008b7b23b8d1cfc
[]
no_license
pauldreik/fuzzcppcheck
12d9c11bcc182cc1f1bb4893e0925dc05fcaf711
794ba352af45971ff1f76d665b52adeb42dcab5f
refs/heads/master
2020-05-01T01:55:04.280076
2019-03-22T21:05:28
2019-03-22T21:05:28
177,206,313
0
0
null
null
null
null
UTF-8
C++
false
false
112
cpp
void f(int x) { int ret; switch (x) { case 123: ret = 1; break; } ret = 3; }
[ "github@pauldreik.se" ]
github@pauldreik.se
afba313b38f9188acd995d6e894ae782a099d92f
653709022e7a5c93c7091ccc4d9ec17a518820b3
/DirectXFramework/Graphics2/BoundingVolume.h
383b24d2fd6954f1efc7cdef473d9449c3551f28
[]
no_license
ShayyP/Graphics-2-Coursework
cf99071a472091b17e960977e722839bbc9cd9dc
3e0ac4a16320e96630298bfecc998221fd850ac5
refs/heads/master
2022-06-17T22:22:14.298664
2020-05-10T16:31:01
2020-05-10T16:31:01
240,533,313
0
0
null
null
null
null
UTF-8
C++
false
false
1,040
h
#pragma once #include "core.h" #include "DirectXCore.h" #include <vector> #include "Structs.h" using namespace std; // Base class for bounding volumes, has virtual methods that are overridden by child classes class BoundingVolume : public enable_shared_from_this<BoundingVolume> { public: BoundingVolume() { XMStoreFloat4x4(&_combinedWorldTransformation, XMMatrixIdentity()); } virtual bool IsIntersecting(shared_ptr<BoundingVolume> otherVolume) { return false; } virtual float IsIntersectingRay(XMVECTOR origin, XMVECTOR direction) { return false; } virtual void Update(FXMMATRIX& worldTransformation) {} virtual void Render() {}; XMFLOAT4X4 GetCombinedWorldTransformation() { return _combinedWorldTransformation; } vector<WireframeVertex> GetVertices() { return _vertices; } vector<UINT> GetIndices() { return _indices; } float GetMaxSize() { return _maxSize; } protected: XMFLOAT4X4 _combinedWorldTransformation; vector<WireframeVertex> _vertices; vector<UINT> _indices; float _maxSize = 0.0f; };
[ "shayp2000@gmail.com" ]
shayp2000@gmail.com
9b168f4fe8f8e6c11c94e10ea7224f7d98e6b974
b39c7014415ea7904e1786e381a2a724eb91cb6e
/Codesignal/The Core/Book Market/isUnstablePair.cpp
60c5d5e67d9dcab8aebf230085f11b5758ab1cff
[]
no_license
chidihn/Learn-cpp
e217d2a722d49226269b8fa727ca1e909714fc12
682d44edb14d75d700bd7ec50ee1b61d52ed67fe
refs/heads/master
2020-08-06T00:15:33.650474
2019-10-01T06:37:23
2019-10-01T06:37:23
212,767,703
3
0
null
2019-10-04T08:20:17
2019-10-04T08:20:17
null
UTF-8
C++
false
false
342
cpp
// Như return #include <iostream> using namespace std; bool isUnstablePair(string a, string b) { string c, d; for (char i : a) c += tolower(i); for (char i : b) d += tolower(i); return (a < b && c > d) || (a > b && c < d); } int main() { cout << boolalpha << isUnstablePair("aa", "AAB"); return 0; }
[ "trvathin@gmail.com" ]
trvathin@gmail.com
8616cd8024f931c0daae2555fbcb3027ba1779dc
01ec5fae952211e0a0ab29dfb49a0261a8510742
/backup/source/cpp/[1121]将数组分成几个递增序列.cpp
682e3261a9144f8b5931619d7c448aad77125899
[]
no_license
algoboy101/LeetCodeCrowdsource
5cbf3394087546f9051c493b1613b5587c52056b
25e93171fa16d6af5ab0caec08be943d2fdd7c2e
refs/heads/master
2021-02-20T00:18:51.225422
2020-06-21T09:04:24
2020-06-21T09:04:24
245,323,834
10
4
null
2020-03-09T02:23:39
2020-03-06T03:43:27
C++
UTF-8
C++
false
false
888
cpp
//给你一个 非递减 的正整数数组 nums 和整数 K,判断该数组是否可以被分成一个或几个 长度至少 为 K 的 不相交的递增子序列。 // // // // 示例 1: // // 输入:nums = [1,2,2,3,3,4,4], K = 3 //输出:true //解释: //该数组可以分成两个子序列 [1,2,3,4] 和 [2,3,4],每个子序列的长度都至少是 3。 // // // 示例 2: // // 输入:nums = [5,6,6,7,8], K = 3 //输出:false //解释: //没有办法根据条件来划分数组。 // // // // // 提示: // // // 1 <= nums.length <= 10^5 // 1 <= K <= nums.length // 1 <= nums[i] <= 10^5 // // Related Topics 数学 //leetcode submit region begin(Prohibit modification and deletion) class Solution { public: bool canDivideIntoSubsequences(vector<int>& nums, int K) { } }; //leetcode submit region end(Prohibit modification and deletion)
[ "chenwenwen0210@126.com" ]
chenwenwen0210@126.com