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
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 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
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
a5a7f209f86b823f5ab558986431da5d358ffe4b
85ef0f6ffc78282803d1b1e0db8c1800bb01f72c
/leetcode/108.cpp
18360456305ec8e65cf9a4003b3fb0e5c0be2fbf
[]
no_license
yangyiming0516/my-online-judge-code
76a461142e4a7cc7c2f08c8e2301aadbced3e543
5c2c7baf4acba72056cde83528870cbe5c6b289a
refs/heads/master
2021-01-25T11:57:16.705378
2019-03-03T18:25:03
2019-03-03T18:25:03
123,449,383
0
0
null
null
null
null
UTF-8
C++
false
false
581
cpp
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: TreeNode* sortedArrayToBST(vector<int>& nums) { return AtoB(nums,0, nums.size()-1); } TreeNode* AtoB(vector<int>& nums,int L, int R){ if (L>R) return NULL; TreeNode *tmp = new TreeNode(nums[(L+R)/2]); tmp->left = AtoB(nums,L,(L+R)/2-1); tmp->right = AtoB(nums,(L+R)/2+1,R); return tmp; } };
[ "noreply@github.com" ]
yangyiming0516.noreply@github.com
435a07e6fab2d089aa55ee5dcb59e69bc2159bb1
7dc2589f403c4a42310191f7449bc0603fe9d30d
/project-game/GameProject/Sun.h
68f31a88a8fe76f841b5c580bbd3ff75326e64e9
[]
no_license
SuganumaYutaka/city-project
c469eabc429af1e6495be83a081a984c6efce9ee
38269866f3d678fdfb56c6402d3e23281ce1298a
refs/heads/master
2022-12-01T21:40:16.152744
2022-11-25T08:55:44
2022-11-25T08:55:44
109,118,688
3
0
null
2018-02-14T06:11:33
2017-11-01T10:36:48
C++
UTF-8
C++
false
false
1,240
h
/*============================================================================== Sun.h - 太陽 Author : Yutaka Suganuma Date : 2017/8/16 ==============================================================================*/ #ifndef _SUN_H_ #define _SUN_H_ /*------------------------------------------------------------------------------ インクルードファイル ------------------------------------------------------------------------------*/ #include "Manager.h" #include "Component.h" /*------------------------------------------------------------------------------ 前方宣言 ------------------------------------------------------------------------------*/ class Camera; class Light; /*------------------------------------------------------------------------------ クラス定義 ------------------------------------------------------------------------------*/ class Sun : public Component { public: static Component* Create( GameObject* gameObject); Sun( GameObject* pGameObject); void Uninit( void); void SetFieldSize( const Vector3& size); virtual void Save( Text& text); virtual void Load( Text& text); private: void Update(); Camera* m_pCamera; Light* m_pLight; }; #endif
[ "yumetaigachibi@gmail.com" ]
yumetaigachibi@gmail.com
22ab21260f3e221c61d247cf745a6d3be1ecf449
3ae8fb577d6f34bc94c725b3b7140abacc51047d
/gambit/armlib/src/gambit.cpp
0aefce35c56ef326f9f4d43f50ff6d2da382abbf
[]
no_license
mjyc/gambit-lego-pkg
b25b7831e864bba0f126f64a3d40f412a19664c1
d2ae2fa4eb09d5e149c0816eabf9213f75b7283f
refs/heads/master
2022-12-30T17:11:30.768639
2013-09-03T22:02:21
2013-09-03T22:02:21
306,082,007
0
0
null
null
null
null
UTF-8
C++
false
false
3,855
cpp
#include <armlib/gambit.h> #include "ik_gambit.cpp" namespace armlib { Gambit::Gambit() : _spinner(1, &_cb_queue) { _latency_usec = 250000; _n_dofs = 7; _n_arm_dofs = 6; _n_manip_dofs = 1; _data_valid = false; _encoder_position.resize(_n_dofs); _joint_weights.push_back(1.5); _joint_weights.push_back(1.5); _joint_weights.push_back(1.0); _joint_weights.push_back(0.5); _joint_weights.push_back(0.5); _joint_weights.push_back(0.5); _joint_weights.push_back(0.5); _joints_cr.push_back(true); _joints_cr.push_back(true); _joints_cr.push_back(true); _joints_cr.push_back(false); _joints_cr.push_back(false); _joints_cr.push_back(false); _joints_cr.push_back(false); ros::NodeHandle nh; nh.setCallbackQueue(&_cb_queue); _joint_target_pub = nh.advertise<gambit_msgs::JointTargets>("/arm/joint_targets", 1); _joint_encoder_sub = nh.subscribe("/arm/joint_state", 1, &Gambit::joint_encoder_cb, this); _spinner.start(); get_encoder_pos(_commanded_pos); } void Gambit::joint_encoder_cb(const gambit_msgs::JointStateConstPtr &joints) { assert(joints->positions.size() == _n_dofs); lock(); for(unsigned int i=0; i<_n_dofs; i++) _encoder_position[i] = joints->positions[i]; if(_at_target && !_closed_loop_mode) _commanded_pos = _encoder_position; _data_valid = true; unlock(); } bool Gambit::get_encoder_pos(js_vect &position) { _data_valid = false; while(!_data_valid) { if(_should_terminate || !ros::ok()) return false; usleep(1000); } lock(); position = _encoder_position; unlock(); return true; } bool Gambit::set_target_pos(js_vect &position) { assert(position.size() == _n_dofs); gambit_msgs::JointTargets jv; jv.header.stamp = ros::Time::now(); for(unsigned int i=0; i<_n_dofs; i++) { jv.indices.push_back(i); jv.targets.push_back(position[i]); } _joint_target_pub.publish(jv); return true; } bool Gambit::check_joint_limits(js_vect &position) { assert(position.size() >= _n_dofs); return ( position[3] >= -2.618 && position[3] <= 2.618 && position[4] >= -1.571 && position[4] <= 1.571 && position[5] >= -2.618 && position[5] <= 2.618 && position[6] >= -0.530 && position[6] <= 2.618 ); } bool Gambit::check_arm_joint_limits(js_vect &position) { assert(position.size() >= _n_arm_dofs); return ( position[3] >= -2.618 && position[3] <= 2.618 && position[4] >= -1.571 && position[4] <= 1.571 && position[5] >= -2.618 && position[5] <= 2.618 ); } bool Gambit::check_manip_joint_limits(js_vect &position) { assert(position.size() >= _n_manip_dofs); return position[0] >= -0.530 && position[0] <= 2.618; } bool Gambit::inverse_kinematics(double *position, double *orientation, std::vector<js_vect> &solutions) { ik_gambit::IKReal eetrans[3]; ik_gambit::IKReal eerot[9]; ik_gambit::IKReal vfree[1] = {0.0}; solutions.clear(); for(unsigned int i=0; i<3; i++) eetrans[i] = position[i]; for(unsigned int i=0; i<9; i++) eerot[i] = orientation[i]; std::vector<ik_gambit::IKSolution> vsolutions; bool ik_success = ik_gambit::ik(eetrans, eerot, vfree, vsolutions); if(!ik_success) { //printf("debug: ik failed\n"); return false; } std::vector<ik_gambit::IKReal> sol(_n_arm_dofs); //printf("debug: %d solutions\n", vsolutions.size()); for(unsigned int i=0; i<vsolutions.size(); i++) { std::vector<ik_gambit::IKReal> vsolfree(vsolutions[i].GetFree().size()); vsolutions[i].GetSolution(&sol[0], &vsolfree[0]); js_vect js_sol; //printf("debug: solution: "); for(unsigned int j=0; j<_n_arm_dofs; j++) { js_sol.push_back(sol[j]); //printf("%f ", sol[j]); } if(check_arm_joint_limits(js_sol)) { solutions.push_back(js_sol); //printf("(reachable)"); } //printf("\n"); } //printf("debug: &solutions: %p\n", &solutions); //printf("debug: solutions.size(): %d\n", solutions.size()); return !solutions.empty(); } }
[ "mjyc@cs.washington.edu" ]
mjyc@cs.washington.edu
f9424d18dba2a118bd97f258c99f1618bb4b6b6e
ea8aa77c861afdbf2c9b3268ba1ae3f9bfd152fe
/meituan17D/meituan17D/ACMTemplete.cpp
47bd95da4f5a5988b4da704a16c61bb346019e23
[]
no_license
lonelam/SolveSet
987a01e72d92f975703f715e6a7588d097f7f2e5
66a9a984d7270ff03b9c2dfa229d99b922907d57
refs/heads/master
2021-04-03T02:02:03.108669
2018-07-21T14:25:53
2018-07-21T14:25:53
62,948,874
9
3
null
null
null
null
UTF-8
C++
false
false
1,827
cpp
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <cstdio> #include <cmath> #include <map> #include <set> #include <utility> #include <stack> #include <cstring> #include <bitset> #include <deque> #include <string> #include <list> #include <cstdlib> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 100000 + 100; typedef long long ll; typedef long double ld; int n; bool vis[maxn]; bool reach[maxn]; int a[maxn]; int b[maxn]; vector<int> G[maxn]; void rdfs(int cur) { reach[cur] = true; for (int i = 0; i < G[cur].size(); i++) { if (!reach[G[cur][i]]) rdfs(G[cur][i]); } } int dfs(int cur, string & ans) { if (vis[cur]) return -1; vis[cur] = true; if (cur == n - 1) return 1; int ta = cur + a[cur]; int tb = cur + b[cur]; if (0 <= ta && ta < n && reach[ta]) { ans.push_back('a'); int oa = dfs(ta, ans); if (oa == 1) return 1; if (oa == -1) return -1; ans.pop_back(); } if (0 <= tb && tb < n && reach[tb]) { ans.push_back('b'); int ob = dfs(tb, ans); if (ob == 1) return 1; if (ob == -1) return -1; ans.pop_back(); } return 0; } int main() { while (scanf("%d", &n) != EOF) { memset(vis, 0, sizeof(vis)); memset(reach, 0, sizeof(reach)); for (int i = 0; i < n; i++) { G[i].clear(); } for (int i = 0; i < n; i++) { scanf("%d", a + i); int tar = i + a[i]; if (tar >= 0 && tar < n) { G[tar].push_back(i); } } for (int i = 0; i < n; i++) { scanf("%d", b + i); int tar = i + b[i]; if (tar >= 0 && tar < n) { G[tar].push_back(i); } } rdfs(n - 1); if (reach[0]) { string ans; if (dfs(0, ans) == 1) { printf("%s\n", ans.c_str()); } else { printf("Infinity!\n"); } } else { printf("No solution!\n"); } } }
[ "laizenan@gmail.com" ]
laizenan@gmail.com
9dfcc768bcf8e289a771291983ab122165808834
9dc0e27554c5139534087ec2064d2a07ec3b943f
/semestr_1/dynamiczne_zarzadzanie_pamiecia_algorytmy_i_struktury_danych/Kodowanie Huffmana/kodowanie_huffmana.cpp
35b3606b9392256ed8146c93cc85e52834b8c2e8
[]
no_license
rikonek/zut
82d2bc4084d0d17ab8385181386f391446ec35ac
d236b275ffc19524c64369dd21fa711f735605c7
refs/heads/master
2020-12-24T20:00:13.639419
2018-01-25T09:53:29
2018-01-25T09:53:29
86,224,826
1
3
null
2018-01-09T11:40:52
2017-03-26T10:36:59
HTML
UTF-8
C++
false
false
374
cpp
#include <iostream> #include <fstream> #include "huffman.class.h" int main(int argc,char **argv) { std::ifstream plik(argv[1]); if(!plik.is_open()) { std::cout << "Nie mozna otworzyc pliku zrodlowego" << std::endl; return 1; } huffman h; h.debug(true); std::cout << h.encode(plik) << std::endl; plik.close(); return 0; }
[ "radek@madenet.pl" ]
radek@madenet.pl
fe095c6c941658f78f02c1bf0ffa60c4f117687b
a7764174fb0351ea666faa9f3b5dfe304390a011
/inc/Handle_PPoly_HArray1OfTriangle.hxx
84bbc8c656ce1693e38869fe1441597500a8d075
[]
no_license
uel-dataexchange/Opencascade_uel
f7123943e9d8124f4fa67579e3cd3f85cfe52d91
06ec93d238d3e3ea2881ff44ba8c21cf870435cd
refs/heads/master
2022-11-16T07:40:30.837854
2020-07-08T01:56:37
2020-07-08T01:56:37
276,290,778
0
0
null
null
null
null
UTF-8
C++
false
false
916
hxx
// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _Handle_PPoly_HArray1OfTriangle_HeaderFile #define _Handle_PPoly_HArray1OfTriangle_HeaderFile #ifndef _Standard_Macro_HeaderFile #include <Standard_Macro.hxx> #endif #ifndef _Standard_DefineHandle_HeaderFile #include <Standard_DefineHandle.hxx> #endif #ifndef _Standard_HeaderFile #include <Standard.hxx> #endif #ifndef _Handle_Standard_Persistent_HeaderFile #include <Handle_Standard_Persistent.hxx> #endif class Standard_Persistent; class Handle(Standard_Type); class Handle(Standard_Persistent); class PPoly_HArray1OfTriangle; DEFINE_STANDARD_PHANDLE(PPoly_HArray1OfTriangle,Standard_Persistent) #endif
[ "shoka.sho2@excel.co.jp" ]
shoka.sho2@excel.co.jp
ff8ab998e988148c788ced5e52bf52d17b69a7ce
ec5168f927a2e6e577b1434ff6afb3a6920e919d
/BFS - Shortest Path.cpp
19b279d0ef6b4eda6c43db7c8566d451a887667e
[]
no_license
prabhsimar100/Backup-for-Codes-Competitive-Programming-
3e556e61b429f0b5ef7c0410deae9e3d486617ae
897c02aba520b8b8983bdcd2632103278373292d
refs/heads/master
2022-12-08T14:56:59.396630
2020-09-06T11:35:41
2020-09-06T11:35:41
293,262,987
0
0
null
2020-09-06T11:35:42
2020-09-06T11:32:13
C++
UTF-8
C++
false
false
2,064
cpp
#include<bits/stdc++.h> using namespace std; #define ll long long int #define P pair<int,int> #define pb push_back vector<int> graph[1005]; void bfs(int distance[],int root, int n) { for (int i = 1; i <=n; ++i) { distance[i]=0; } queue<int> Q; Q.push(root); // for (int i = 0; i < graph[root].size(); ++i) // { // Q.push(graph[root][i]); // distance[graph[root][i]]=distance[root]+6; // } while(!Q.empty()) { int cur=Q.front(); Q.pop(); for (int i = 0; i < graph[cur].size(); ++i) { if(distance[graph[cur][i]]==0&&graph[cur][i]!=root) { Q.push(graph[cur][i]); distance[graph[cur][i]]=distance[cur]+6; } } } } int main(){ ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t; cin>>t; while(t--) { int n,m,u,v; cin>>n>>m; int distance[1005]; for (int i = 0; i < m; ++i) { cin>>u>>v; graph[u].pb(v); graph[v].pb(u); } int s; cin>>s; for (int i = 1; i <=n; ++i) { distance[i]=0; } distance[s]=0; bfs(distance,s,n); for (int i = 1; i <=n; ++i) { if(i!=s) if(distance[i]==0) cout<<-1<<" "; else cout<<distance[i]<<" "; } cout<<endl; for (int i = 0; i < n; ++i) graph[i].clear(); } return 0; } // map<int, int> dist; // queue<P>q; // P x; // x.first=root; // x.second=0; // q.push(x); // // dist[x]=0; // dist[x.first]=0; // q.pop(); // for(int i=0;i<graph[x.first].size();i++) // { // P a; // a.first=graph[x.first][i]; // a.second=x.second+6; // q.push(a); // } // while(!q.empty()) // { // P y=q.front(); // q.pop(); // dist[y.first]=y.second; // for(int i=0;i<graph[y.first].size();i++) // { // P a; // a.first=graph[y.first][i]; // a.second=y.second+6; // if(!dist.count(a.first)) // q.push(a); // } // } // for(int i=0;i<dist.size();i++) // { if(dist[i]==0) // dist[i]=-1; // if(i!=root) // cout<<dist[i]<<" ";} // cout<<endl;
[ "prabhsimar100@gmail.com" ]
prabhsimar100@gmail.com
d47b0f911b4f7a4446b6bd5b374700cbe71eacba
04fdfc9d6d1cd2ff13ef7d9e29da988bf2710204
/think_in_c++/chapters02/_17PointerToFunction.cpp
865435f36fb8d4293809a731d71fb30f35f51728
[]
no_license
DongHuaLu/C-plus-plus
29bd872e13e70aef80965c48446d5a5b51134b78
6a3405fd50ed7b23e40a0927267388c4c5f0c45a
refs/heads/master
2020-03-30T05:28:17.467026
2017-02-09T06:05:08
2017-02-09T06:05:08
39,047,161
0
0
null
null
null
null
UTF-8
C++
false
false
215
cpp
#include <iostream> using namespace std; int func(int i){ cout << "i = " << i << endl; return i; } int main(){ int (*fp1)(int); fp1 = func; (*fp1)(2); int (*fp2)(int) = func; (*fp2)(55); }
[ "ctl70000@163.com" ]
ctl70000@163.com
6db78db0707c229277eec3b8c04aa6ac42214554
e38231ec168a4daaec38b3b6ac90c3080acd5204
/src/FaBoMotor_DRV8830.cpp
ec4e0a38831446b2d853cd0cd1b92a605b532736
[ "Artistic-2.0" ]
permissive
gcohen10/FaBoMotor-DRV8830-Library
1f9bc1aeb4db24f49d0e9bc8e70bd5bfeb615877
25817b3c37543b47a03b662d98a7ee97d508f0d6
refs/heads/master
2022-01-07T05:49:09.016233
2019-01-03T16:21:35
2019-01-03T16:21:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,411
cpp
/** @file FaBoMotor_DRV8830.cpp @brief This is a library for the FaBo Temperature I2C Brick. Released under APACHE LICENSE, VERSION 2.0 http://www.apache.org/licenses/ @author FaBo<info@fabo.io> */ #include "FaBoMotor_DRV8830.h" /** @brief Constructor */ FaBoMotor::FaBoMotor(uint8_t addr) { _i2caddr = addr; Wire.begin(); } /** @brief Begin Device */ boolean FaBoMotor::begin() { uint8_t status = 0; return readI2c(DRV8830_FAULT_REG, 1, &status); } /** @brief Configure Device @param [in] config Configure Parameter */ void FaBoMotor::drive(uint8_t direction, uint8_t speed) { uint8_t param = speed << 2 | direction; writeI2c(DRV8830_CONTROL_REG, param); } /** @brief Write I2C @param [in] address register address @param [in] data write data */ void FaBoMotor::writeI2c(uint8_t address, uint8_t data) { Wire.beginTransmission(_i2caddr); Wire.write(address); Wire.write(data); Wire.endTransmission(); } /** @brief Read I2C @param [in] address register address @param [in] num read length @param [out] data read data */ boolean FaBoMotor::readI2c(uint8_t address, uint8_t num, uint8_t * data) { Wire.beginTransmission(_i2caddr); boolean result = Wire.write(address); Serial.print(result); Wire.endTransmission(); uint8_t i = 0; Wire.requestFrom(_i2caddr, num); while( Wire.available() ) { data[i++] = Wire.read(); } return result; }
[ "gclue.akira@gmail.com" ]
gclue.akira@gmail.com
e66c02796f8619bff91d493e7ef2518aa1e078de
781f351347692832c17ebd43bb90accd1036572d
/Sources/Core/Src/KSubWorld.h
5e39d90776a7dee5d86e6a965af39cddab9f4a8e
[]
no_license
fcccode/Jx
71f9a549c7c6bbd1d00df5ad3e074a7c1c665bd1
4b436851508d76dd626779522a080b35cf8edc14
refs/heads/master
2020-04-14T07:59:12.814607
2017-05-23T07:57:15
2017-05-23T07:57:15
null
0
0
null
null
null
null
GB18030
C++
false
false
4,191
h
#ifndef KWorldH #define KWorldH #ifdef _SERVER #define MAX_SUBWORLD 80 #else #define MAX_SUBWORLD 1 #endif #define VOID_REGION -2 //------------------------------------------------------------- #include "KEngine.h" #include "KRegion.h" #include "KWeatherMgr.h" #ifdef _SERVER #include "KMission.h" #include "KMissionArray.h" #define MAX_SUBWORLD_MISSIONCOUNT 10 #define MAX_GLOBAL_MISSIONCOUNT 50 typedef KMissionArray <KMission , MAX_TIMER_PERMISSION> KSubWorldMissionArray; typedef KMissionArray <KMission , MAX_GLOBAL_MISSIONCOUNT> KGlobalMissionArray; extern KGlobalMissionArray g_GlobalMissionArray; #endif //------------------------------------------------------------- #ifndef TOOLVERSION class KSubWorld #else class CORE_API KSubWorld #endif { public: int m_nIndex; int m_SubWorldID; #ifdef _SERVER KSubWorldMissionArray m_MissionArray; #endif KRegion* m_Region; #ifndef _SERVER int m_ClientRegionIdx[MAX_REGION]; char m_szMapPath[FILE_NAME_LENGTH]; //KLittleMap m_cLittleMap; #endif int m_nWorldRegionWidth; // SubWorld里宽几个Region int m_nWorldRegionHeight; // SubWorld里高几个Region int m_nTotalRegion; // SubWorld里Region个数 int m_nRegionWidth; // Region的格子宽度 int m_nRegionHeight; // Region的格子高度 int m_nCellWidth; // Cell的像素宽度 int m_nCellHeight; // Cell的像素高度 int m_nRegionBeginX; int m_nRegionBeginY; int m_nWeather; // 天气变化 DWORD m_dwCurrentTime; // 当前帧 KWorldMsg m_WorldMessage; // 消息 KList m_NoneRegionNpcList; // 不在地图上的NPC #ifdef _SERVER KWeatherMgr *m_pWeatherMgr; #endif private: public: KSubWorld(); ~KSubWorld(); void Activate(); void GetFreeObjPos(POINT& pos); BOOL CanPutObj(POINT pos); void ObjChangeRegion(int nSrcRegionIdx, int nDesRegionIdx, int nObjIdx); void MissleChangeRegion(int nSrcRegionIdx, int nDesRegionIdx, int nObjIdx); void AddPlayer(int nRegion, int nIdx); void RemovePlayer(int nRegion, int nIdx); void Close(); int GetDistance(int nRx1, int nRy1, int nRx2, int nRy2); // 像素级坐标 void Map2Mps(int nR, int nX, int nY, int nDx, int nDy, int *nRx, int *nRy); // 格子坐标转像素坐标 static void Map2Mps(int nRx, int nRy, int nX, int nY, int nDx, int nDy, int *pnX, int *pnY); // 格子坐标转像素坐标 void Mps2Map(int Rx, int Ry, int * nR, int * nX, int * nY, int *nDx, int * nDy); // 像素坐标转格子坐标 void GetMps(int *nX, int *nY, int nSpeed, int nDir, int nMaxDir = 64); // 取得某方向某速度下一点的坐标 BYTE TestBarrier(int nMpsX, int nMpsY); BYTE TestBarrier(int nRegion, int nMapX, int nMapY, int nDx, int nDy, int nChangeX, int nChangeY); // 检测下一点是否为障碍 BYTE TestBarrierMin(int nRegion, int nMapX, int nMapY, int nDx, int nDy, int nChangeX, int nChangeY); // 检测下一点是否为障碍 BYTE GetBarrier(int nMpsX, int nMpsY); // 取得某点的障碍信息 DWORD GetTrap(int nMpsX, int nMpsY); void MessageLoop(); int FindRegion(int RegionID); // 找到某ID的Region的索引 int FindFreeRegion(int nX = 0, int nY = 0); #ifdef _SERVER int RevivalAllNpc();//将地图上所有的Npc包括已死亡的Npc全部恢复成原始状态 void BroadCast(const char* pBuffer, size_t uSize); BOOL LoadMap(int nIdx); void LoadObject(char* szPath, char* szFile); void NpcChangeRegion(int nSrcRegionIdx, int nDesRegionIdx, int nNpcIdx); void PlayerChangeRegion(int nSrcRegionIdx, int nDesRegionIdx, int nObjIdx); BOOL SendSyncData(int nIdx, int nClient); int GetRegionIndex(int nRegionID); int FindNpcFromName(const char * szName); #endif #ifndef _SERVER BOOL LoadMap(int nIdx, int nRegion); void NpcChangeRegion(int nSrcRegionIdx, int nDesRegionIdx, int nNpcIdx); void Paint(); void Mps2Screen(int *Rx, int *Ry); void Screen2Mps(int *Rx, int *Ry); #endif private: void LoadTrap(); void ProcessMsg(KWorldMsgNode *pMsg); #ifndef _SERVER void LoadCell(); #endif }; #ifndef TOOLVERSION extern KSubWorld SubWorld[MAX_SUBWORLD]; #else extern CORE_API KSubWorld SubWorld[MAX_SUBWORLD]; #endif #endif
[ "tuan.n0s0und@gmail.com" ]
tuan.n0s0und@gmail.com
31a4cdecf1c61a27f8d1246d81cc2872e57ae982
ad20ec70814c8e3992e14c8e78ef1830d7c73597
/TripleX/main.cpp
c45e529e76be9924d25f61e139a55aa784b234c0
[]
no_license
koerriva/UnrealEngine4Course
eab6ea63d00777a53476f750528257563891cea0
c575fe211e034e405e34f524ebe0f1ac498be0d7
refs/heads/master
2022-10-13T15:16:09.067684
2020-06-02T14:26:52
2020-06-02T14:26:52
265,832,276
0
0
null
null
null
null
UTF-8
C++
false
false
1,931
cpp
#include <iostream> #include <ctime> void PrintIntroduction(int Difficulty) { std::cout << "\033[1;33mYou are a secret agent breaking into a level "; std::cout << "\033[1;32m" << Difficulty << "\033[0m"; std::cout << "\033[1;33m" << " secure server room...\033[0m\n"; std::cout << "\033[1;31mEnter the correct code to continue...\033[0m\n\n"; } bool PlayGame(int Difficulty) { PrintIntroduction(Difficulty); const int CodeA = rand() % Difficulty + 1; const int CodeB = rand() % Difficulty + 1; const int CodeC = rand() % Difficulty + 1; const int CodeSum = CodeA + CodeB + CodeC; const int CodeProduct = CodeA * CodeB * CodeC; std::cout << "+ There are 3 numbers in the code"; std::cout << "\n+ The codes add-up to:\033[1;32m" << CodeSum; std::cout << "\033[0m\n+ The codes multiply to give:\033[1;32m" << CodeProduct << "\033[0m" << std::endl; int GuessA, GuessB, GuessC; std::cin >> GuessA >> GuessB >> GuessC; const int GuessSum = GuessA + GuessB + GuessC; const int GuessProduct = GuessA * GuessB * GuessC; if (GuessSum == CodeSum && GuessProduct == CodeProduct) { std::cout << "\033[1;32m" << "Well done!You have extracted a file!" << "\033[0m\n\n"; return true; } else { std::cout << "\033[1;31m" << "You entered wrong code!Be carefully!Try again!" << "\033[0m\n\n"; return false; } } int main() { srand(time(NULL)); int LevelDifficulty = 1; const int MaxLevelDifficulty = 5; while (LevelDifficulty <= MaxLevelDifficulty) { bool bLevelComplete = PlayGame(LevelDifficulty); std::cin.clear(); std::cin.ignore(); if (bLevelComplete) { ++LevelDifficulty; } } std::cout << "\n*** Great work agent! ***\n"; return 0; }
[ "504097978@qq.com" ]
504097978@qq.com
390b3e557568277807833847dd196073931a5739
09a353319e8e3f7abe82cdf959254fb8338321dc
/src/runtime/vm/translator/hopt/linearscan.h
4dea13eb48d4162c0e67aff03be0ef2cc2b5f7af
[ "LicenseRef-scancode-unknown-license-reference", "PHP-3.01", "Zend-2.0" ]
permissive
huzhiguang/hiphop-php_20121224_original
37b26487d96707ecb11b1810ff21c69b8f61acd8
029125e8af031cb79fe8e0c2eea9b8f2ad5769a2
refs/heads/master
2020-05-04T17:07:19.378484
2013-08-19T10:06:52
2013-08-19T10:06:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,547
h
/* +----------------------------------------------------------------------+ | HipHop for PHP | +----------------------------------------------------------------------+ | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ #ifndef incl_HPHP_VM_LINEAR_SCAN_H_ #define incl_HPHP_VM_LINEAR_SCAN_H_ #include <boost/noncopyable.hpp> #include "runtime/vm/translator/physreg.h" #include "runtime/vm/translator/abi-x64.h" #include "runtime/vm/translator/hopt/ir.h" #include "runtime/vm/translator/hopt/tracebuilder.h" #include "runtime/vm/translator/hopt/codegen.h" namespace HPHP { namespace VM { namespace JIT { /* * The main entry point for register allocation. Called prior to code * generation. */ void allocRegsForTrace(Trace*, IRFactory*, TraceBuilder*); }}} #endif
[ "huzhiguang@jd.com" ]
huzhiguang@jd.com
bbe54247f976922ff01895d54e1eb0055737ff5b
81fdded2f4a5482e9c00ebb2230a7f8975fc38fd
/ComIOP/Wrapper/ProxyServer/OpcUaComProxyServer.cpp
894c4fd92d29a30e129d80570ec77514cb90b1f9
[ "LicenseRef-scancode-generic-cla" ]
no_license
thephez/UA-.NETStandardLibrary
c38477a95d69387fa37f9eb3cd2056e460b5ae40
759ea05f8d8f990a9aa2354c58dbb846e2ffd88b
refs/heads/master
2021-01-21T07:25:31.968237
2017-01-03T21:01:07
2017-01-03T21:01:07
64,311,762
1
1
null
2016-07-27T13:42:48
2016-07-27T13:42:48
null
UTF-8
C++
false
false
3,620
cpp
/* ======================================================================== * Copyright (c) 2005-2016 The OPC Foundation, Inc. All rights reserved. * * OPC Foundation MIT License 1.00 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * The complete license agreement can be found here: * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ #include "StdAfx.h" #include "Da/COpcUaDaProxyServer.h" #include "Ae/COpcUaAe2ProxyServer.h" #include "Hda/COpcUaHdaProxyServer.h" #pragma warning(disable:4192) //================================================================================ // COM Module Declarations OPC_DECLARE_APPLICATION(OpcUa, OpcUaComProxyServer, "UA COM Proxy Server", TRUE) OPC_BEGIN_CLASS_TABLE() OPC_CLASS_TABLE_ENTRY(COpcUaDaProxyServer, ComDaProxyServer, 1, "UA COM DA Proxy Server") OPC_CLASS_TABLE_ENTRY(COpcUaAe2ProxyServer, ComAe2ProxyServer, 1, "UA COM AE Proxy Server") // OPC_CLASS_TABLE_ENTRY(COpcUaAeProxyServer, ComAeProxyServer, 1, "UA COM AE Proxy Server") OPC_CLASS_TABLE_ENTRY(COpcUaHdaProxyServer, ComHdaProxyServer, 1, "UA COM HDA Proxy Server") OPC_END_CLASS_TABLE() OPC_BEGIN_CATEGORY_TABLE() OPC_CATEGORY_TABLE_ENTRY(ComDaProxyServer, CATID_OPCDAServer20, OPC_CATEGORY_DESCRIPTION_DA20) #ifndef OPCUA_NO_DA3_SUPPORT OPC_CATEGORY_TABLE_ENTRY(ComDaProxyServer, CATID_OPCDAServer30, OPC_CATEGORY_DESCRIPTION_DA30) #endif // OPC_CATEGORY_TABLE_ENTRY(ComAeProxyServer, CATID_OPCAEServer10, OPC_CATEGORY_DESCRIPTION_AE10) OPC_CATEGORY_TABLE_ENTRY(ComAe2ProxyServer, CATID_OPCAEServer10, OPC_CATEGORY_DESCRIPTION_AE10) OPC_CATEGORY_TABLE_ENTRY(ComHdaProxyServer, CATID_OPCHDAServer10, OPC_CATEGORY_DESCRIPTION_HDA10) OPC_END_CATEGORY_TABLE() #ifndef _USRDLL // {037D6665-27F3-462f-9E8F-F8C146D28669} OPC_IMPLEMENT_LOCAL_SERVER(0x37d6665, 0x27f3, 0x462f, 0x9e, 0x8f, 0xf8, 0xc1, 0x46, 0xd2, 0x86, 0x69); //================================================================================ // WinMain extern "C" int WINAPI _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd ) { OPC_START_LOCAL_SERVER_EX(hInstance, lpCmdLine); return 0; } #else OPC_IMPLEMENT_INPROC_SERVER(); //============================================================================== // DllMain extern "C" BOOL WINAPI DllMain( HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) { OPC_START_INPROC_SERVER(hModule, dwReason); return TRUE; } #endif // _USRDLL
[ "mregen@microsoft.com" ]
mregen@microsoft.com
b2d480d42ad7290ca3f5c828db7722bfd4e55e46
341c6ea936988af9e24379f5cf08a62be1d9d811
/ccursor.cpp
9ade2e2634292e71272a114441865681674a7f6f
[]
no_license
mextier/Patience
3fad4544ccc123782756f4de411527a43a047bc6
bad1f104f82d3c895e4565499137acaf27da3f20
refs/heads/master
2021-10-24T05:04:45.991183
2019-03-22T05:17:40
2019-03-22T05:17:40
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
3,369
cpp
//==================================================================================================== //подключаемые библиотеки //==================================================================================================== #include "ccursor.h" //==================================================================================================== //конструктор и деструктор класса //==================================================================================================== //---------------------------------------------------------------------------------------------------- //конструктор //---------------------------------------------------------------------------------------------------- CCursor::CCursor(void) { Init(); } //---------------------------------------------------------------------------------------------------- //деструктор //---------------------------------------------------------------------------------------------------- CCursor::~CCursor() { } //==================================================================================================== //закрытые функции класса //==================================================================================================== //==================================================================================================== //открытые функции класса //==================================================================================================== //---------------------------------------------------------------------------------------------------- //инициализировать //---------------------------------------------------------------------------------------------------- void CCursor::Init(void) { cCoord_Position.X=0; cCoord_Position.Y=0; MoveMode=false; for(int32_t n=0;n<NConsts::PATIENCE_NUMBER_AMOUNT;n++) PatienceNumber[n]=0; ResetSelected(); } //---------------------------------------------------------------------------------------------------- //сбросить выбор //---------------------------------------------------------------------------------------------------- void CCursor::ResetSelected(void) { SelectedBoxIndex=-1; SelectedPositionIndexInBox=-1; cCoord_OffsetWithSelectedPosition.X=-1; cCoord_OffsetWithSelectedPosition.Y=-1; } //---------------------------------------------------------------------------------------------------- //сохранить состояние //---------------------------------------------------------------------------------------------------- bool CCursor::SaveState(std::ofstream &file) { if (file.write(reinterpret_cast<char*>(&PatienceNumber),sizeof(uint8_t)*NConsts::PATIENCE_NUMBER_AMOUNT).fail()==true) return(false); return(true); } //---------------------------------------------------------------------------------------------------- //загрузить состояние //---------------------------------------------------------------------------------------------------- bool CCursor::LoadState(std::ifstream &file) { if (file.read(reinterpret_cast<char*>(&PatienceNumber),sizeof(uint8_t)*NConsts::PATIENCE_NUMBER_AMOUNT).fail()==true) return(false); return(true); }
[ "da-nie@yandex.ru" ]
da-nie@yandex.ru
509a0bb6dd889547c470d03729e808191c894668
188fb8ded33ad7a2f52f69975006bb38917437ef
/Fluid/processor5/0.54/Force
2cdaa9d96d5a6ff1f1921b4cb0b78a0ba171f205
[]
no_license
abarcaortega/Tuto_2
34a4721f14725c20471ff2dc8d22b52638b8a2b3
4a84c22efbb9cd2eaeda92883343b6910e0941e2
refs/heads/master
2020-08-05T16:11:57.674940
2019-10-04T09:56:09
2019-10-04T09:56:09
212,573,883
0
0
null
null
null
null
UTF-8
C++
false
false
1,724
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "0.54"; object Force; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [1 1 -2 0 0 0 0]; internalField uniform (0 0 0); boundaryField { inlet { type calculated; value nonuniform 0(); } outlet { type calculated; value uniform (0 0 0); } flap { type calculated; value nonuniform 0(); } upperWall { type calculated; value nonuniform 0(); } lowerWall { type calculated; value uniform (0 0 0); } frontAndBack { type empty; } procBoundary5to2 { type processor; value uniform (0 0 0); } procBoundary5to4 { type processor; value uniform (0 0 0); } } // ************************************************************************* //
[ "aldo.abarca.ortega@gmail.com" ]
aldo.abarca.ortega@gmail.com
8f44ca22c4f15cecfa7ca9af7931ee8685718ba5
d1d31c9bb9bb1347d0c31ff39ce781236cd1c89a
/test/ComponentTypeInformationTest.cpp
5b929f036d0d16a1610d870d08181b32319b924a
[]
no_license
defacto2k15/pwAsteroids
bf8cb516f788565c11601095348581d74f87897b
546678ce169a5a1855f2c5c2752f5e00c0c77d0f
refs/heads/master
2021-01-21T14:04:28.377090
2016-05-25T12:58:52
2016-05-25T12:58:52
44,272,235
1
0
null
null
null
null
UTF-8
C++
false
false
745
cpp
// // Created by defacto on 26.10.15. // #include <lib/gmock-1.7.0/gtest/include/gtest/gtest.h> #include <Model/components/Component.h> class C1 : public Component{}; class C2 : public Component{}; class C3 : public C2{}; TEST(ComponentTypeInformationTest, WorksForTwoComponentsOfTheSameTypeWhenSecondIsCastedToBase){ C3 *ptrToC3 = nullptr; ComponentTypeChecker checker(ptrToC3); C3 *anotherPtrToC3 = new C3; Component *ptrToC3AsComponent = anotherPtrToC3; ASSERT_TRUE(checker.wasCastSuccesfull(ptrToC3AsComponent)); } TEST(ComponentTypeInformationTest, falseIfComponentsAreOfDiffrentType){ C1 *ptrToC1 = new C1; C2 *ptrToC2 = nullptr; ComponentTypeChecker checker(ptrToC2); ASSERT_FALSE(checker.wasCastSuccesfull(ptrToC1)); }
[ "defacto2k15@gmail.com" ]
defacto2k15@gmail.com
678cd10a426ee46dca1f758231f8d3b2e2f2eb77
7598c557d4be8308ed0fb57e99e54bf64a583cdc
/test/core/event_engine/windows/iocp_test.cc
1736446d3d43f8a4dfa403faa562c695aef953ec
[ "BSD-3-Clause", "MPL-2.0", "Apache-2.0" ]
permissive
kedartal/grpc
c2c817bec4f00eab5af26ddffcd61ff8c2ba7c07
d699b574a8e773e256b438d685ba3121b9ab96b3
refs/heads/master
2022-10-17T00:07:56.318728
2022-10-12T19:37:14
2022-10-12T19:37:14
265,615,706
0
0
Apache-2.0
2020-05-20T15:57:40
2020-05-20T15:57:39
null
UTF-8
C++
false
false
13,757
cc
// Copyright 2022 gRPC 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 <grpc/support/port_platform.h> #ifdef GPR_WINDOWS #include <thread> #include <gmock/gmock.h> #include <gtest/gtest.h> #include "absl/status/status.h" #include "absl/time/time.h" #include "absl/types/variant.h" #include <grpc/grpc.h> #include <grpc/support/log_windows.h> #include "src/core/lib/event_engine/common_closures.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/thread_pool.h" #include "src/core/lib/event_engine/windows/iocp.h" #include "src/core/lib/event_engine/windows/win_socket.h" #include "src/core/lib/gprpp/notification.h" #include "src/core/lib/iomgr/error.h" #include "test/core/event_engine/windows/create_sockpair.h" namespace { using ::grpc_event_engine::experimental::AnyInvocableClosure; using ::grpc_event_engine::experimental::CreateSockpair; using ::grpc_event_engine::experimental::EventEngine; using ::grpc_event_engine::experimental::IOCP; using ::grpc_event_engine::experimental::Poller; using ::grpc_event_engine::experimental::SelfDeletingClosure; using ::grpc_event_engine::experimental::ThreadPool; using ::grpc_event_engine::experimental::WinSocket; } // namespace class IOCPTest : public testing::Test {}; TEST_F(IOCPTest, ClientReceivesNotificationOfServerSend) { ThreadPool executor; IOCP iocp(&executor); SOCKET sockpair[2]; CreateSockpair(sockpair, iocp.GetDefaultSocketFlags()); WinSocket* wrapped_client_socket = static_cast<WinSocket*>(iocp.Watch(sockpair[0])); WinSocket* wrapped_server_socket = static_cast<WinSocket*>(iocp.Watch(sockpair[1])); grpc_core::Notification read_called; grpc_core::Notification write_called; DWORD flags = 0; AnyInvocableClosure* on_read; AnyInvocableClosure* on_write; { // When the client gets some data, ensure it matches what we expect. WSABUF read_wsabuf; read_wsabuf.len = 2048; char read_char_buffer[2048]; read_wsabuf.buf = read_char_buffer; DWORD bytes_rcvd; memset(wrapped_client_socket->read_info()->overlapped(), 0, sizeof(OVERLAPPED)); int status = WSARecv(wrapped_client_socket->socket(), &read_wsabuf, 1, &bytes_rcvd, &flags, wrapped_client_socket->read_info()->overlapped(), NULL); // Expecting error 997, WSA_IO_PENDING EXPECT_EQ(status, -1); int last_error = WSAGetLastError(); ASSERT_EQ(last_error, WSA_IO_PENDING); on_read = new AnyInvocableClosure([wrapped_client_socket, &read_called, &read_wsabuf, &bytes_rcvd]() { gpr_log(GPR_DEBUG, "Notified on read"); EXPECT_GE(wrapped_client_socket->read_info()->bytes_transferred(), 10); EXPECT_STREQ(read_wsabuf.buf, "hello!"); read_called.Notify(); }); wrapped_client_socket->NotifyOnRead(on_read); } { // Have the server send a message to the client WSABUF write_wsabuf; char write_char_buffer[2048] = "hello!"; write_wsabuf.len = 2048; write_wsabuf.buf = write_char_buffer; DWORD bytes_sent; memset(wrapped_server_socket->write_info()->overlapped(), 0, sizeof(OVERLAPPED)); int status = WSASend(wrapped_server_socket->socket(), &write_wsabuf, 1, &bytes_sent, 0, wrapped_server_socket->write_info()->overlapped(), NULL); EXPECT_EQ(status, 0); if (status != 0) { int error_num = WSAGetLastError(); char* utf8_message = gpr_format_message(error_num); gpr_log(GPR_INFO, "Error sending data: (%d) %s", error_num, utf8_message); gpr_free(utf8_message); } on_write = new AnyInvocableClosure([&write_called] { gpr_log(GPR_DEBUG, "Notified on write"); write_called.Notify(); }); wrapped_server_socket->NotifyOnWrite(on_write); } // Doing work for WSASend bool cb_invoked = false; auto work_result = iocp.Work(std::chrono::seconds(10), [&cb_invoked]() { cb_invoked = true; }); ASSERT_TRUE(work_result == Poller::WorkResult::kOk); ASSERT_TRUE(cb_invoked); // Doing work for WSARecv cb_invoked = false; work_result = iocp.Work(std::chrono::seconds(10), [&cb_invoked]() { cb_invoked = true; }); ASSERT_TRUE(work_result == Poller::WorkResult::kOk); ASSERT_TRUE(cb_invoked); // wait for the callbacks to run read_called.WaitForNotification(); write_called.WaitForNotification(); delete on_read; delete on_write; wrapped_client_socket->MaybeShutdown(absl::OkStatus()); wrapped_server_socket->MaybeShutdown(absl::OkStatus()); delete wrapped_client_socket; delete wrapped_server_socket; } TEST_F(IOCPTest, IocpWorkTimeoutDueToNoNotificationRegistered) { ThreadPool executor; IOCP iocp(&executor); SOCKET sockpair[2]; CreateSockpair(sockpair, iocp.GetDefaultSocketFlags()); WinSocket* wrapped_client_socket = static_cast<WinSocket*>(iocp.Watch(sockpair[0])); grpc_core::Notification read_called; DWORD flags = 0; AnyInvocableClosure* on_read; { // Set the client to receive asynchronously // Prepare a notification callback, but don't register it yet. WSABUF read_wsabuf; read_wsabuf.len = 2048; char read_char_buffer[2048]; read_wsabuf.buf = read_char_buffer; DWORD bytes_rcvd; memset(wrapped_client_socket->read_info()->overlapped(), 0, sizeof(OVERLAPPED)); int status = WSARecv(wrapped_client_socket->socket(), &read_wsabuf, 1, &bytes_rcvd, &flags, wrapped_client_socket->read_info()->overlapped(), NULL); // Expecting error 997, WSA_IO_PENDING EXPECT_EQ(status, -1); int last_error = WSAGetLastError(); ASSERT_EQ(last_error, WSA_IO_PENDING); on_read = new AnyInvocableClosure([wrapped_client_socket, &read_called, &read_wsabuf, &bytes_rcvd]() { gpr_log(GPR_DEBUG, "Notified on read"); EXPECT_GE(wrapped_client_socket->read_info()->bytes_transferred(), 10); EXPECT_STREQ(read_wsabuf.buf, "hello!"); read_called.Notify(); }); } { // Have the server send a message to the client. No need to track via IOCP WSABUF write_wsabuf; char write_char_buffer[2048] = "hello!"; write_wsabuf.len = 2048; write_wsabuf.buf = write_char_buffer; DWORD bytes_sent; OVERLAPPED write_overlapped; memset(&write_overlapped, 0, sizeof(OVERLAPPED)); int status = WSASend(sockpair[1], &write_wsabuf, 1, &bytes_sent, 0, &write_overlapped, NULL); EXPECT_EQ(status, 0); } // IOCP::Work without any notification callbacks should still return Ok. bool cb_invoked = false; auto work_result = iocp.Work(std::chrono::seconds(2), [&cb_invoked]() { cb_invoked = true; }); ASSERT_TRUE(work_result == Poller::WorkResult::kOk); ASSERT_TRUE(cb_invoked); // register the closure, which should trigger it immediately. wrapped_client_socket->NotifyOnRead(on_read); // wait for the callbacks to run read_called.WaitForNotification(); delete on_read; wrapped_client_socket->MaybeShutdown(absl::OkStatus()); delete wrapped_client_socket; } TEST_F(IOCPTest, KickWorks) { ThreadPool executor; IOCP iocp(&executor); grpc_core::Notification kicked; executor.Run([&iocp, &kicked] { bool cb_invoked = false; Poller::WorkResult result = iocp.Work( std::chrono::seconds(30), [&cb_invoked]() { cb_invoked = true; }); ASSERT_TRUE(result == Poller::WorkResult::kKicked); ASSERT_FALSE(cb_invoked); kicked.Notify(); }); executor.Run([&iocp] { // give the worker thread a chance to start absl::SleepFor(absl::Milliseconds(42)); iocp.Kick(); }); // wait for the callbacks to run kicked.WaitForNotification(); } TEST_F(IOCPTest, KickThenShutdownCasusesNextWorkerToBeKicked) { // TODO(hork): evaluate if a kick count is going to be useful. // This documents the existing poller's behavior of maintaining a kick count, // but it's unclear if it's going to be needed. ThreadPool executor; IOCP iocp(&executor); // kick twice iocp.Kick(); iocp.Kick(); bool cb_invoked = false; // Assert the next two WorkResults are kicks auto result = iocp.Work(std::chrono::milliseconds(1), [&cb_invoked]() { cb_invoked = true; }); ASSERT_TRUE(result == Poller::WorkResult::kKicked); ASSERT_FALSE(cb_invoked); result = iocp.Work(std::chrono::milliseconds(1), [&cb_invoked]() { cb_invoked = true; }); ASSERT_TRUE(result == Poller::WorkResult::kKicked); ASSERT_FALSE(cb_invoked); // followed by a DeadlineExceeded result = iocp.Work(std::chrono::milliseconds(1), [&cb_invoked]() { cb_invoked = true; }); ASSERT_TRUE(result == Poller::WorkResult::kDeadlineExceeded); ASSERT_FALSE(cb_invoked); } TEST_F(IOCPTest, CrashOnWatchingAClosedSocket) { ThreadPool executor; IOCP iocp(&executor); SOCKET sockpair[2]; CreateSockpair(sockpair, iocp.GetDefaultSocketFlags()); closesocket(sockpair[0]); ASSERT_DEATH( { WinSocket* wrapped_client_socket = static_cast<WinSocket*>(iocp.Watch(sockpair[0])); }, ""); } TEST_F(IOCPTest, StressTestThousandsOfSockets) { // Start 10 threads, each with their own IOCP // On each thread, create 50 socket pairs (100 sockets) and have them exchange // a message before shutting down. int thread_count = 10; int sockets_per_thread = 50; std::atomic<int> read_count{0}; std::atomic<int> write_count{0}; std::vector<std::thread> threads; threads.reserve(thread_count); for (int thread_n = 0; thread_n < thread_count; thread_n++) { threads.emplace_back([thread_n, sockets_per_thread, &read_count, &write_count] { ThreadPool executor; IOCP iocp(&executor); // Start a looping worker thread with a moderate timeout std::thread iocp_worker([&iocp, &executor] { Poller::WorkResult result; do { result = iocp.Work(std::chrono::seconds(1), []() {}); } while (result != Poller::WorkResult::kDeadlineExceeded); }); for (int i = 0; i < sockets_per_thread; i++) { SOCKET sockpair[2]; CreateSockpair(sockpair, iocp.GetDefaultSocketFlags()); WinSocket* wrapped_client_socket = static_cast<WinSocket*>(iocp.Watch(sockpair[0])); WinSocket* wrapped_server_socket = static_cast<WinSocket*>(iocp.Watch(sockpair[1])); wrapped_client_socket->NotifyOnRead( SelfDeletingClosure::Create([&read_count, wrapped_client_socket] { read_count.fetch_add(1); wrapped_client_socket->MaybeShutdown(absl::OkStatus()); })); wrapped_server_socket->NotifyOnWrite( SelfDeletingClosure::Create([&write_count, wrapped_server_socket] { write_count.fetch_add(1); wrapped_server_socket->MaybeShutdown(absl::OkStatus()); })); { // Set the client to receive WSABUF read_wsabuf; read_wsabuf.len = 20; char read_char_buffer[20]; read_wsabuf.buf = read_char_buffer; DWORD bytes_rcvd; DWORD flags = 0; memset(wrapped_client_socket->read_info()->overlapped(), 0, sizeof(OVERLAPPED)); int status = WSARecv( wrapped_client_socket->socket(), &read_wsabuf, 1, &bytes_rcvd, &flags, wrapped_client_socket->read_info()->overlapped(), NULL); // Expecting error 997, WSA_IO_PENDING EXPECT_EQ(status, -1); int last_error = WSAGetLastError(); ASSERT_EQ(last_error, WSA_IO_PENDING); } { // Have the server send a message to the client. WSABUF write_wsabuf; char write_char_buffer[20] = "hello!"; write_wsabuf.len = 20; write_wsabuf.buf = write_char_buffer; DWORD bytes_sent; memset(wrapped_server_socket->write_info()->overlapped(), 0, sizeof(OVERLAPPED)); int status = WSASend( wrapped_server_socket->socket(), &write_wsabuf, 1, &bytes_sent, 0, wrapped_server_socket->write_info()->overlapped(), NULL); EXPECT_EQ(status, 0); } } iocp_worker.join(); }); } for (auto& t : threads) { t.join(); } absl::Time deadline = absl::Now() + absl::Seconds(30); while (read_count.load() != thread_count * sockets_per_thread || write_count.load() != thread_count * sockets_per_thread) { absl::SleepFor(absl::Milliseconds(50)); if (deadline < absl::Now()) { FAIL() << "Deadline exceeded with " << read_count.load() << " reads and " << write_count.load() << " writes"; } } ASSERT_EQ(read_count.load(), thread_count * sockets_per_thread); ASSERT_EQ(write_count.load(), thread_count * sockets_per_thread); } int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); grpc_init(); int status = RUN_ALL_TESTS(); grpc_shutdown(); return status; } #else // not GPR_WINDOWS int main(int /* argc */, char** /* argv */) { return 0; } #endif
[ "noreply@github.com" ]
kedartal.noreply@github.com
6133ca93acfccd10156c5b107ddf16c4bd5891f5
b2810745e7d746140b87367f9fa55374cc82b2f2
/Source/BansheeEditor/Source/Win32/BsVSCodeEditor.cpp
ac98bd4c6ee446ec6e04398f8151d7b5fe2352e5
[]
no_license
nemerle/BansheeEngine
7aabb7d2c1af073b1069f313a2192e0152b56e99
10436324afc9327865251169918177a6eabc8506
refs/heads/preview
2020-04-05T18:29:09.657686
2016-05-11T08:19:09
2016-05-11T08:19:09
58,526,181
2
0
null
2016-05-11T08:10:44
2016-05-11T08:10:44
null
UTF-8
C++
false
false
22,469
cpp
//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// #include "Win32/BsVSCodeEditor.h" #include <windows.h> #include <atlbase.h> #include "BsFileSystem.h" #include "BsDataStream.h" // Import EnvDTE #pragma warning(disable: 4278) #import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("8.0") lcid("0") raw_interfaces_only named_guids #pragma warning(default: 4278) namespace BansheeEngine { /** * Reads a string value from the specified key in the registry. * * @param[in] key Registry key to read from. * @param[in] name Identifier of the value to read from. * @param[in] value Output value read from the key. * @param[in] defaultValue Default value to return if the key or identifier doesn't exist. */ LONG getRegistryStringValue(HKEY hKey, const WString& name, WString& value, const WString& defaultValue) { value = defaultValue; wchar_t strBuffer[512]; DWORD strBufferSize = sizeof(strBuffer); ULONG result = RegQueryValueExW(hKey, name.c_str(), 0, nullptr, (LPBYTE)strBuffer, &strBufferSize); if (result == ERROR_SUCCESS) value = strBuffer; return result; } /** Contains data about a Visual Studio project. */ struct VSProjectInfo { WString GUID; WString name; Path path; }; /** * Handles retrying of calls that fail to access Visual Studio. This is due to the weird nature of VS when calling its * methods from external code. If this message filter isn't registered some calls will just fail silently. */ class VSMessageFilter : public IMessageFilter { DWORD __stdcall HandleInComingCall(DWORD dwCallType, HTASK htaskCaller, DWORD dwTickCount, LPINTERFACEINFO lpInterfaceInfo) override { return SERVERCALL_ISHANDLED; } DWORD __stdcall RetryRejectedCall(HTASK htaskCallee, DWORD dwTickCount, DWORD dwRejectType) override { if (dwRejectType == SERVERCALL_RETRYLATER) { // Retry immediatey return 99; } // Cancel the call return -1; } DWORD __stdcall MessagePending(HTASK htaskCallee, DWORD dwTickCount, DWORD dwPendingType) override { return PENDINGMSG_WAITDEFPROCESS; } /** COM requirement. Returns instance of an interface of provided type. */ HRESULT __stdcall QueryInterface(REFIID iid, void** ppvObject) override { if(iid == IID_IDropTarget || iid == IID_IUnknown) { AddRef(); *ppvObject = this; return S_OK; } else { *ppvObject = nullptr; return E_NOINTERFACE; } } /** COM requirement. Increments objects reference count. */ ULONG __stdcall AddRef() override { return InterlockedIncrement(&mRefCount); } /** COM requirement. Decreases the objects reference count and deletes the object if its zero. */ ULONG __stdcall Release() override { LONG count = InterlockedDecrement(&mRefCount); if(count == 0) { bs_delete(this); return 0; } else { return count; } } private: LONG mRefCount; }; /** Contains various helper classes for interacting with a Visual Studio instance running on this machine. */ class VisualStudio { private: static const String SLN_TEMPLATE; /**< Template text used for a solution file. */ static const String PROJ_ENTRY_TEMPLATE; /**< Template text used for a project entry in a solution file. */ static const String PROJ_PLATFORM_TEMPLATE; /**< Template text used for platform specific information for a project entry in a solution file. */ static const String PROJ_TEMPLATE; /**< Template XML used for a project file. */ static const String REFERENCE_ENTRY_TEMPLATE; /**< Template XML used for a reference to another assembly entry by name. */ static const String REFERENCE_PROJECT_ENTRY_TEMPLATE; /**< Template XML used for a reference to another project entry. */ static const String REFERENCE_PATH_ENTRY_TEMPLATE; /**< Template XML used for a reference to another assembly entry by name and path. */ static const String CODE_ENTRY_TEMPLATE; /**< Template XML used for a single code file entry in a project. */ static const String NON_CODE_ENTRY_TEMPLATE; /**< Template XML used for a single non-code file entry in a project. */ public: /** * Scans the running processes to find a running Visual Studio instance with the specified version and open solution. * * @param[in] clsID Class ID of the specific Visual Studio version we are looking for. * @param[in] solutionPath Path to the solution the instance needs to have open. * @return DTE object that may be used to interact with the Visual Studio instance, or null if * not found. */ static CComPtr<EnvDTE::_DTE> findRunningInstance(const CLSID& clsID, const Path& solutionPath) { CComPtr<IRunningObjectTable> runningObjectTable = nullptr; if (FAILED(GetRunningObjectTable(0, &runningObjectTable))) return nullptr; CComPtr<IEnumMoniker> enumMoniker = nullptr; if (FAILED(runningObjectTable->EnumRunning(&enumMoniker))) return nullptr; CComPtr<IMoniker> dteMoniker = nullptr; if (FAILED(CreateClassMoniker(clsID, &dteMoniker))) return nullptr; CComBSTR bstrSolution(solutionPath.toWString(Path::PathType::Windows).c_str()); CComPtr<IMoniker> moniker; ULONG count = 0; while (enumMoniker->Next(1, &moniker, &count) == S_OK) { if (moniker->IsEqual(dteMoniker)) { CComPtr<IUnknown> curObject = nullptr; HRESULT result = runningObjectTable->GetObject(moniker, &curObject); moniker = nullptr; if (result != S_OK) continue; CComPtr<EnvDTE::_DTE> dte; curObject->QueryInterface(__uuidof(EnvDTE::_DTE), (void**)&dte); if (dte == nullptr) continue; CComPtr<EnvDTE::_Solution> solution; if (FAILED(dte->get_Solution(&solution))) continue; CComBSTR fullName; if (FAILED(solution->get_FullName(&fullName))) continue; if (fullName == bstrSolution) return dte; } } return nullptr; } /** * Opens a new Visual Studio instance of the specified version with the provided solution. * * @param[in] clsID Class ID of the specific Visual Studio version to start. * @param[in] solutionPath Path to the solution the instance needs to open. */ static CComPtr<EnvDTE::_DTE> openInstance(const CLSID& clsid, const Path& solutionPath) { CComPtr<IUnknown> newInstance = nullptr; if (FAILED(::CoCreateInstance(clsid, nullptr, CLSCTX_LOCAL_SERVER, EnvDTE::IID__DTE, (LPVOID*)&newInstance))) return nullptr; CComPtr<EnvDTE::_DTE> dte; newInstance->QueryInterface(__uuidof(EnvDTE::_DTE), (void**)&dte); if (dte == nullptr) return nullptr; dte->put_UserControl(TRUE); CComPtr<EnvDTE::_Solution> solution; if (FAILED(dte->get_Solution(&solution))) return nullptr; CComBSTR bstrSolution(solutionPath.toWString(Path::PathType::Windows).c_str()); if (FAILED(solution->Open(bstrSolution))) return nullptr; // Wait until VS opens UINT32 elapsed = 0; while (elapsed < 10000) { EnvDTE::Window* window = nullptr; if (SUCCEEDED(dte->get_MainWindow(&window))) return dte; Sleep(100); elapsed += 100; } return nullptr; } /** * Opens a file on a specific line in a running Visual Studio instance. * * @param[in] dte DTE object retrieved from findRunningInstance() or openInstance(). * @param[in] filePath Path of the file to open. File should be a part of the VS solution. * @param[in] line Line on which to focus Visual Studio after the file is open. */ static bool openFile(CComPtr<EnvDTE::_DTE> dte, const Path& filePath, UINT32 line) { // Open file CComPtr<EnvDTE::ItemOperations> itemOperations; if (FAILED(dte->get_ItemOperations(&itemOperations))) return false; CComBSTR bstrFilePath(filePath.toWString(Path::PathType::Windows).c_str()); CComBSTR bstrKind(EnvDTE::vsViewKindPrimary); CComPtr<EnvDTE::Window> window = nullptr; if (FAILED(itemOperations->OpenFile(bstrFilePath, bstrKind, &window))) return false; // Scroll to line CComPtr<EnvDTE::Document> activeDocument; if (SUCCEEDED(dte->get_ActiveDocument(&activeDocument))) { CComPtr<IDispatch> selection; if (SUCCEEDED(activeDocument->get_Selection(&selection))) { CComPtr<EnvDTE::TextSelection> textSelection; if (SUCCEEDED(selection->QueryInterface(&textSelection))) { textSelection->GotoLine(line, TRUE); } } } // Bring the window in focus window = nullptr; if (SUCCEEDED(dte->get_MainWindow(&window))) { window->Activate(); HWND hWnd; window->get_HWnd((LONG*)&hWnd); SetForegroundWindow(hWnd); } return true; } /** Generates a Visual Studio project GUID from the project name. */ static String getProjectGUID(const WString& projectName) { static const String guidTemplate = "{0}-{1}-{2}-{3}-{4}"; String hash = md5(projectName); String output = StringUtil::format(guidTemplate, hash.substr(0, 8), hash.substr(8, 4), hash.substr(12, 4), hash.substr(16, 4), hash.substr(20, 12)); StringUtil::toUpperCase(output); return output; } /** * Builds the Visual Studio solution text (.sln) for the provided version, using the provided solution data. * * @param[in] version Visual Studio version for which we're generating the solution file. * @param[in] data Data containing a list of projects and other information required to build the solution text. * @return Generated text of the solution file. */ static String writeSolution(VisualStudioVersion version, const CodeSolutionData& data) { struct VersionData { String formatVersion; }; Map<VisualStudioVersion, VersionData> versionData = { { VisualStudioVersion::VS2008, { "10.00" } }, { VisualStudioVersion::VS2010, { "11.00" } }, { VisualStudioVersion::VS2012, { "12.00" } }, { VisualStudioVersion::VS2013, { "12.00" } }, { VisualStudioVersion::VS2015, { "12.00" } } }; StringStream projectEntriesStream; StringStream projectPlatformsStream; for (auto& project : data.projects) { String guid = getProjectGUID(project.name); String projectName = toString(project.name); projectEntriesStream << StringUtil::format(PROJ_ENTRY_TEMPLATE, projectName, projectName + ".csproj", guid); projectPlatformsStream << StringUtil::format(PROJ_PLATFORM_TEMPLATE, guid); } String projectEntries = projectEntriesStream.str(); String projectPlatforms = projectPlatformsStream.str(); return StringUtil::format(SLN_TEMPLATE, versionData[version].formatVersion, projectEntries, projectPlatforms); } /** * Builds the Visual Studio project text (.csproj) for the provided version, using the provided project data. * * @param[in] version Visual Studio version for which we're generating the project file. * @param[in] projectData Data containing a list of files, references and other information required to * build the project text. * @return Generated text of the project file. */ static String writeProject(VisualStudioVersion version, const CodeProjectData& projectData) { struct VersionData { String toolsVersion; }; Map<VisualStudioVersion, VersionData> versionData = { { VisualStudioVersion::VS2008, { "3.5" } }, { VisualStudioVersion::VS2010, { "4.0" } }, { VisualStudioVersion::VS2012, { "4.0" } }, { VisualStudioVersion::VS2013, { "12.0" } }, { VisualStudioVersion::VS2015, { "13.0" } } }; StringStream tempStream; for (auto& codeEntry : projectData.codeFiles) tempStream << StringUtil::format(CODE_ENTRY_TEMPLATE, codeEntry.toString()); String codeEntries = tempStream.str(); tempStream.str(""); tempStream.clear(); for (auto& nonCodeEntry : projectData.nonCodeFiles) tempStream << StringUtil::format(NON_CODE_ENTRY_TEMPLATE, nonCodeEntry.toString()); String nonCodeEntries = tempStream.str(); tempStream.str(""); tempStream.clear(); for (auto& referenceEntry : projectData.assemblyReferences) { String referenceName = toString(referenceEntry.name); if (referenceEntry.path.isEmpty()) tempStream << StringUtil::format(REFERENCE_ENTRY_TEMPLATE, referenceName); else tempStream << StringUtil::format(REFERENCE_PATH_ENTRY_TEMPLATE, referenceName, referenceEntry.path.toString()); } String referenceEntries = tempStream.str(); tempStream.str(""); tempStream.clear(); for (auto& referenceEntry : projectData.projectReferences) { String referenceName = toString(referenceEntry.name); String projectGUID = getProjectGUID(referenceEntry.name); tempStream << StringUtil::format(REFERENCE_PROJECT_ENTRY_TEMPLATE, referenceName, projectGUID); } String projectReferenceEntries = tempStream.str(); tempStream.str(""); tempStream.clear(); tempStream << toString(projectData.defines); String defines = tempStream.str(); String projectGUID = getProjectGUID(projectData.name); return StringUtil::format(PROJ_TEMPLATE, versionData[version].toolsVersion, projectGUID, toString(projectData.name), defines, referenceEntries, projectReferenceEntries, codeEntries, nonCodeEntries); } }; const String VisualStudio::SLN_TEMPLATE = R"(Microsoft Visual Studio Solution File, Format Version {0} # Visual Studio 2013 VisualStudioVersion = 12.0.30723.0 MinimumVisualStudioVersion = 10.0.40219.1{1} Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution{2} EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal )"; const String VisualStudio::PROJ_ENTRY_TEMPLATE = R"( Project("\{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC\}") = "{0}", "{1}", "\{{2}\}" EndProject)"; const String VisualStudio::PROJ_PLATFORM_TEMPLATE = R"( \{{0}\}.Debug|Any CPU.ActiveCfg = Debug|Any CPU \{{0}\}.Debug|Any CPU.Build.0 = Debug|Any CPU \{{0}\}.Release|Any CPU.ActiveCfg = Release|Any CPU \{{0}\}.Release|Any CPU.Build.0 = Release|Any CPU)"; const String VisualStudio::PROJ_TEMPLATE = R"literal(<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="{0}" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition = " '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition = " '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>\{{1}\}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace></RootNamespace> <AssemblyName>{2}</AssemblyName> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <BaseDirectory>Resources</BaseDirectory> <SchemaVersion>2.0</SchemaVersion> </PropertyGroup> <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>Internal\\Temp\\Assemblies\\Debug\\</OutputPath> <BaseIntermediateOutputPath>Internal\\Temp\\Assemblies\\</BaseIntermediateOutputPath> <DefineConstants>DEBUG;TRACE;{3}</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel > </PropertyGroup> <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>Internal\\Temp\\Assemblies\\Release\\</OutputPath> <BaseIntermediateOutputPath>Internal\\Temp\\Assemblies\\</BaseIntermediateOutputPath> <DefineConstants>TRACE;{3}</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup>{4} </ItemGroup> <ItemGroup>{5} </ItemGroup> <ItemGroup>{6} </ItemGroup> <ItemGroup>{7} </ItemGroup> <Import Project = "$(MSBuildToolsPath)\\Microsoft.CSharp.targets"/> </Project>)literal"; const String VisualStudio::REFERENCE_ENTRY_TEMPLATE = R"( <Reference Include="{0}"/>)"; const String VisualStudio::REFERENCE_PATH_ENTRY_TEMPLATE = R"( <Reference Include="{0}"> <HintPath>{1}</HintPath> </Reference>)"; const String VisualStudio::REFERENCE_PROJECT_ENTRY_TEMPLATE = R"( <ProjectReference Include="{0}.csproj"> <Project>\{{1}\}</Project> <Name>{0}</Name> </ProjectReference>)"; const String VisualStudio::CODE_ENTRY_TEMPLATE = R"( <Compile Include="{0}"/>)"; const String VisualStudio::NON_CODE_ENTRY_TEMPLATE = R"( <None Include="{0}"/>)"; VSCodeEditor::VSCodeEditor(VisualStudioVersion version, const Path& execPath, const WString& CLSID) :mVersion(version), mExecPath(execPath), mCLSID(CLSID) { } void VSCodeEditor::openFile(const Path& solutionPath, const Path& filePath, UINT32 lineNumber) const { CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); CLSID clsID; if (FAILED(CLSIDFromString(mCLSID.c_str(), &clsID))) { CoUninitialize(); return; } CComPtr<EnvDTE::_DTE> dte = VisualStudio::findRunningInstance(clsID, solutionPath); if (dte == nullptr) dte = VisualStudio::openInstance(clsID, solutionPath); if (dte == nullptr) { CoUninitialize(); return; } VSMessageFilter* newFilter = new VSMessageFilter(); IMessageFilter* oldFilter; CoRegisterMessageFilter(newFilter, &oldFilter); EnvDTE::Window* window = nullptr; if (SUCCEEDED(dte->get_MainWindow(&window))) window->Activate(); VisualStudio::openFile(dte, filePath, lineNumber); CoRegisterMessageFilter(oldFilter, nullptr); CoUninitialize(); } void VSCodeEditor::syncSolution(const CodeSolutionData& data, const Path& outputPath) const { String solutionString = VisualStudio::writeSolution(mVersion, data); solutionString = StringUtil::replaceAll(solutionString, "\n", "\r\n"); Path solutionPath = outputPath; solutionPath.append(data.name + L".sln"); for (auto& project : data.projects) { String projectString = VisualStudio::writeProject(mVersion, project); projectString = StringUtil::replaceAll(projectString, "\n", "\r\n"); Path projectPath = outputPath; projectPath.append(project.name + L".csproj"); SPtr<DataStream> projectStream = FileSystem::createAndOpenFile(projectPath); projectStream->write(projectString.c_str(), projectString.size() * sizeof(String::value_type)); projectStream->close(); } SPtr<DataStream> solutionStream = FileSystem::createAndOpenFile(solutionPath); solutionStream->write(solutionString.c_str(), solutionString.size() * sizeof(String::value_type)); solutionStream->close(); } VSCodeEditorFactory::VSCodeEditorFactory() :mAvailableVersions(getAvailableVersions()) { for (auto& version : mAvailableVersions) mAvailableEditors.push_back(version.first); } Map<CodeEditorType, VSCodeEditorFactory::VSVersionInfo> VSCodeEditorFactory::getAvailableVersions() const { #if BS_ARCH_TYPE == BS_ARCHITECTURE_x86_64 bool is64bit = true; #else bool is64bit = false; IsWow64Process(GetCurrentProcess(), (PBOOL)&is64bit); #endif WString registryKeyRoot; if (is64bit) registryKeyRoot = L"SOFTWARE\\Wow6432Node\\Microsoft"; else registryKeyRoot = L"SOFTWARE\\Microsoft"; struct VersionData { CodeEditorType type; WString registryKey; WString name; WString executable; }; Map<VisualStudioVersion, VersionData> versionToVersionNumber = { { VisualStudioVersion::VS2008, { CodeEditorType::VS2008, L"VisualStudio\\9.0", L"Visual Studio 2008", L"devenv.exe" } }, { VisualStudioVersion::VS2010, { CodeEditorType::VS2010, L"VisualStudio\\10.0", L"Visual Studio 2010", L"devenv.exe" } }, { VisualStudioVersion::VS2012, { CodeEditorType::VS2012, L"VisualStudio\\11.0", L"Visual Studio 2012", L"devenv.exe" } }, { VisualStudioVersion::VS2013, { CodeEditorType::VS2013, L"VisualStudio\\12.0", L"Visual Studio 2013", L"devenv.exe" } }, { VisualStudioVersion::VS2015, { CodeEditorType::VS2015, L"VisualStudio\\14.0", L"Visual Studio 2015", L"devenv.exe" } } }; Map<CodeEditorType, VSVersionInfo> versionInfo; for(auto version : versionToVersionNumber) { WString registryKey = registryKeyRoot + L"\\" + version.second.registryKey; HKEY regKey; LONG result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryKey.c_str(), 0, KEY_READ, &regKey); if (result != ERROR_SUCCESS) continue; WString installPath; getRegistryStringValue(regKey, L"InstallDir", installPath, StringUtil::WBLANK); if (installPath.empty()) continue; WString clsID; getRegistryStringValue(regKey, L"ThisVersionDTECLSID", clsID, StringUtil::WBLANK); VSVersionInfo info; info.name = version.second.name; info.execPath = installPath.append(version.second.executable); info.CLSID = clsID; info.version = version.first; versionInfo[version.second.type] = info; } return versionInfo; } CodeEditor* VSCodeEditorFactory::create(CodeEditorType type) const { auto findIter = mAvailableVersions.find(type); if (findIter == mAvailableVersions.end()) return nullptr; // TODO - Also create VSExpress and VSCommunity editors return bs_new<VSCodeEditor>(findIter->second.version, findIter->second.execPath, findIter->second.CLSID); } }
[ "bearishsun@gmail.com" ]
bearishsun@gmail.com
eaf89ae9f32bac205334c7381ad28ccb6f9d402d
50c74a5dd38180e26f0608cb0002585489445555
/Codeforces Solutions/201A.cpp
cfdc91499bfd6ce3a728949417d01b155ff997fe
[]
no_license
ShobhitBehl/Competitive-Programming
1518fe25001cc57095c1643cc8c904523b2ac2ef
7a05897ca0ef5565655350803327f7f23bcf82fe
refs/heads/master
2020-04-17T05:20:52.302129
2019-03-18T10:17:47
2019-03-18T10:17:47
166,265,289
0
0
null
null
null
null
UTF-8
C++
false
false
772
cpp
#include <bits/stdc++.h> using namespace std; typedef long long int lli; #define pi 3.141592653589793238 typedef pair<lli,lli> pll; typedef map<lli,lli> mll; typedef set<lli> sl; //typedef pair<int,int> pii; typedef map<int,int> mii; typedef set<int> si; #define x first #define y second #define mp make_pair #define pb push_back int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); lli x; cin >> x; if(x == 3) { cout << 5 << endl; return 0; } for(int i = 1; i<50; i+=2) { lli num = ((i*i) + 1)/2; if(num >= x) { cout << i << endl; return 0; } } }
[ "shobhitbehl1@gmail.com" ]
shobhitbehl1@gmail.com
f9d054b276bb474ba401ed6614b848a43fce7142
03b20afd312ba32e375d8a2619a070971f3e31f5
/Coursera/Data Structures and Algorithms Specialization/Algorithmic Toolbox/Week2/last_digit_of_a_large_fibonacci_number.cpp
87330ec8ee5bce10f11044d63577426135a55425
[]
no_license
AndrewShkrob/Courses
9c368e107786ba7c19a1744072d6f50bc332efbb
c5d95e468ac8ee0d38a6af7119c1d9c1962c4941
refs/heads/master
2022-10-05T02:48:38.388577
2020-06-06T14:25:27
2020-06-06T14:25:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
402
cpp
#include <bits/stdc++.h> using namespace std; uint64_t FibonacciLastDigit(uint64_t n) { if (n <= 1) return n; uint64_t a = 0; uint64_t b = 1; uint64_t ans = 0; for (size_t i = 2; i <= n; i++) { ans = (a + b) % 10; a = b; b = ans; } return ans; } int main() { uint64_t n; cin >> n; cout << FibonacciLastDigit(n); return 0; }
[ "andrei5709978@gmail.com" ]
andrei5709978@gmail.com
32bedefb699943affb1725b7938320a4470bb00b
5df7293b4a7d7f3cf4e4d25921e252ac92c21b5f
/onnxruntime/core/providers/rocm/rocm_execution_provider_info.h
b7c308d13de026eef46fb8e641dd35a17f55ff2d
[ "MIT" ]
permissive
Nifury/onnxruntime
ccd7fed07ad917fb3b63ae333c388895073f9263
198994d01d4e226fd3a8816e8b2fad00c84a691c
refs/heads/main
2023-04-08T21:40:39.383881
2023-04-05T00:34:13
2023-04-05T00:34:13
312,125,003
7
2
MIT
2020-11-12T00:28:40
2020-11-12T00:28:39
null
UTF-8
C++
false
false
2,757
h
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #include <functional> #include <limits> #include "core/common/hash_combine.h" #include "core/framework/arena_extend_strategy.h" #include "core/framework/ortdevice.h" #include "core/framework/provider_options.h" #include "core/session/onnxruntime_c_api.h" namespace onnxruntime { // Information needed to construct ROCM execution providers. struct ROCMExecutionProviderExternalAllocatorInfo { void* alloc{nullptr}; void* free{nullptr}; void* empty_cache{nullptr}; ROCMExecutionProviderExternalAllocatorInfo() { alloc = nullptr; free = nullptr; empty_cache = nullptr; } ROCMExecutionProviderExternalAllocatorInfo(void* a, void* f, void* e) { alloc = a; free = f; empty_cache = e; } bool UseExternalAllocator() const { return (alloc != nullptr) && (free != nullptr); } }; namespace rocm { struct TunableOpInfo { bool enabled{false}; }; } // namespace rocm struct ROCMExecutionProviderInfo { OrtDevice::DeviceId device_id{0}; size_t gpu_mem_limit{std::numeric_limits<size_t>::max()}; // Will be over-ridden by contents of `default_memory_arena_cfg` (if specified) ArenaExtendStrategy arena_extend_strategy{ArenaExtendStrategy::kNextPowerOfTwo}; // Will be over-ridden by contents of `default_memory_arena_cfg` (if specified) bool miopen_conv_exhaustive_search{false}; bool do_copy_in_default_stream{true}; bool has_user_compute_stream{false}; void* user_compute_stream{nullptr}; // The following OrtArenaCfg instance only characterizes the behavior of the default memory // arena allocator and not any other auxiliary allocator that may also be part of the ROCM EP. // For example, auxiliary allocators `HIP_PINNED` and `HIP_CPU` will not be configured using this // arena config. OrtArenaCfg* default_memory_arena_cfg{nullptr}; ROCMExecutionProviderExternalAllocatorInfo external_allocator_info{}; // By default, try to use as much as possible memory for algo search. // If set to false, use fix workspace size (32M) for Conv algo search, the final algo might not be the best. bool miopen_conv_use_max_workspace{true}; rocm::TunableOpInfo tunable_op{}; static ROCMExecutionProviderInfo FromProviderOptions(const ProviderOptions& options); static ProviderOptions ToProviderOptions(const ROCMExecutionProviderInfo& info); }; } // namespace onnxruntime template<> struct std::hash<::onnxruntime::rocm::TunableOpInfo> { size_t operator()(const ::onnxruntime::rocm::TunableOpInfo& info) const { size_t seed_and_value{0xbc9f1d34}; onnxruntime::HashCombine(info.enabled, seed_and_value); return seed_and_value; } };
[ "noreply@github.com" ]
Nifury.noreply@github.com
8733b71ded70c4ef071f1255b4285d6fd6d247a1
7e79e0be56f612288e9783582c7b65a1a6a53397
/problem-solutions/codeforces/408/D.cpp
7876c3a3644482f6dffb8ca40766a688c55f5fbb
[]
no_license
gcamargo96/Competitive-Programming
a643f492b429989c2d13d7d750c6124e99373771
0325097de60e693009094990d408ee8f3e8bb18a
refs/heads/master
2020-07-14T10:27:26.572439
2019-08-24T15:11:20
2019-08-24T15:11:20
66,391,304
0
0
null
null
null
null
UTF-8
C++
false
false
2,028
cpp
#include <bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f #define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i)) #define mp make_pair #define pb push_back #define fi first #define se second #define endl "\n" #define PI acos(-1) typedef long long ll; typedef vector<int> vi; typedef vector<bool> vb; typedef pair<int,int> ii; typedef complex<double> base; const int N = 300002; int n, k, d; map<ii, int> road; vi adj[N]; priority_queue<pair<int, ii> > pq; int dist[N], cor[N]; vi res; set<int> police; void dijkstra(){ //memset(dist, INF, sizeof dist); while(!pq.empty()){ int u = pq.top().se.fi; int di = -pq.top().fi; int c = pq.top().se.se; pq.pop(); cor[u] = c; if(di > d) continue; //printf("%d\n", u); For(i,0,adj[u].size()){ int v = adj[u][i]; if(cor[v] != 0 and cor[u] != cor[v] and di+1 >= dist[v]){ if(road.count(ii(u,v))){ res.pb(road[ii(u,v)]); } else{ res.pb(road[ii(v,u)]); } continue; } if(di+1 < dist[v]){ dist[v] = di+1; //cor[v] = cor[u]; pq.push(mp(-dist[v], ii(v, c))); } } } } int main(void){ scanf("%d%d%d", &n, &k, &d); int x; For(i,0,N) dist[i] = INF; For(i,0,k){ scanf("%d", &x); police.insert(x); pq.push(mp(0, ii(x, i+1))); cor[x] = i+1; dist[x] = 0; } int u, v; For(i,0,n-1){ scanf("%d%d", &u, &v); road[ii(u,v)] = i+1; if(police.count(u) and police.count(v)){ if(road.count(ii(u,v))){ res.pb(road[ii(u,v)]); } else{ res.pb(road[ii(v,u)]); } } else{ adj[u].pb(v); adj[v].pb(u); } } if(d == 0){ printf("%d\n", n-1); for(int i = 1; i <= n-1; i++){ printf("%d ", i); } printf("\n"); return 0; } dijkstra(); /*printf("dists = "); for(int i = 1; i <= n; i++){ printf("%d ", dist[i]); } printf("\n"); */ /*sort(res.begin(), res.end()); auto it = unique(res.begin(), res.end()); res.resize(it-res.begin()); */ printf("%d\n", res.size()); For(i,0,res.size()){ printf("%d ", res[i]); } printf("\n"); return 0; }
[ "gacamargo1.000@gmail.com" ]
gacamargo1.000@gmail.com
5cff9c1adda869142180d8859f2dbc854306699b
b7e10af07325fbe34a8f6acb8ad3de090383b845
/edgeRuntime/StandardPlayer.h
eaeacf0bb5b805ee026eb944a8c8fb92b83f3e1e
[ "Apache-2.0" ]
permissive
Joshua0128/mpcToolkit
dabc59d8c1844072fbd92e66eebcd236361e3c3d
67d647488907e6f00575026e5c0b2c26b0b92b25
refs/heads/master
2021-12-29T23:44:16.268521
2016-03-21T15:58:55
2016-03-21T15:58:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,628
h
// // StandardPlayer.h // edgeRuntime // // Created by Abdelrahaman Aly on 06/11/13. // Copyright (c) 2013 Abdelrahaman Aly. All rights reserved. // #ifndef edgeRuntime_StandardPlayer_h #define edgeRuntime_StandardPlayer_h //Generic Headers #include <string.h> namespace Players { /** * @class StandardPlayer * @ingroup Players * @brief * Player Bean class * @details * contains communicational and identification data needed for transmission process * @todo <ul> <li> change player for idPlayer <li> correct address - now reads adress <\ul> * @author Abdelrahaman Aly * @date 2013/11/06 * @version 0.0.1.15 */ class StandardPlayer { private: int * ipAdress_; //ip address of player int port_; //service port int player_; //player id i.e 1, 2, 3, etc. public: /** * @brief Custom class constructor * @details Initialize all estate variables * @param player Represents the player id number * @param port service port * @param ipAddress int vector of size 4 to store service ip address * @exception NA * @todo <ul> <li>Build Exceptions for non compatible data, specially ip Address </ul> */ StandardPlayer(int player, int port, int * ipAdress); /** * @brief Default class constructor * @details Initialize all estate variables with default values * @exception NA * @todo <ul> <li>Build Exceptions for non compatible data, in case of ocupied ports </ul> */ StandardPlayer(); /** @brief Simple Getter @return ipAddress int vector of size 4 to store service ip address */ int * getIpAdress(); /** @brief Simple Setter @param ipAdress int vector of size 4 to store service ip address */ void setIpAdress(int * ipAdress); /** @brief Simple Getter @return player id i.e 1, 2, 3, etc. */ int getPlayer(); /** @brief Simple Setter @param player id i.e 1, 2, 3, etc. */ void setPlayer(int player); /** @brief Simple Getter @return port service port of player. */ int getPort(); /** @brief Simple Setter @param port service port of player. */ void setPort(int port); }; } #endif
[ "abdelrahaman.aly@gmail.com" ]
abdelrahaman.aly@gmail.com
addc5b1c12b7b43b61875450b13d0454d7d12f71
e73ca94a87c263b0e7622a850a576d526fc22d82
/D3DX_Doyun_Engine/ConsoleLogger.h
d3d286b16c8a1110bdbab2c9cf8e3671418a6877
[]
no_license
Sicarim/D3DX_Project
de3805bb1bf08b66396ab815c1abc6ffad68ba64
5679aa80a7aac9e8cd05f77567eb4bc279657257
refs/heads/main
2023-03-26T22:25:52.857187
2021-03-15T15:05:04
2021-03-15T15:05:04
348,013,258
0
0
null
null
null
null
UTF-8
C++
false
false
6,611
h
// ConsoleLogger.h: interface for the CConsoleLogger class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_CONSOLELOGGER_H__294FDF9B_F91E_4F6A_A953_700181DD1996__INCLUDED_) #define AFX_CONSOLELOGGER_H__294FDF9B_F91E_4F6A_A953_700181DD1996__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "windows.h" #include <time.h> #include <stdio.h> #include "stdlib.h" #include <fcntl.h> #include "io.h" #include "direct.h" #include "ntverp.h" #if !defined(VER_PRODUCTBUILD) || VER_PRODUCTBUILD<3790 #pragma message ("********************************************************************************************") #pragma message ("Notice (performance-warning): you are not using the Microsoft Platform SDK,") #pragma message (" we'll use CRITICAL_SECTION instead of InterLocked operation") #pragma message ("********************************************************************************************") #else #define CONSOLE_LOGGER_USING_MS_SDK #endif // If no "helper_executable" location was specify - // search for the DEFAULT_HELPER_EXE #define DEFAULT_HELPER_EXE "ConsoleLoggerHelper.exe" class CConsoleLogger { public: // ctor,dtor CConsoleLogger(); virtual ~CConsoleLogger(); // create a logger: starts a pipe+create the child process long Create(const char *lpszWindowTitle=NULL, int buffer_size_x=-1,int buffer_size_y=-1, const char *logger_name=NULL, const char *helper_executable=NULL); // close everything long Close(void); // output functions inline int print(const char *lpszText,int iSize=-1); int printf(const char *format,...); // play with the CRT output functions int SetAsDefaultOutput(void); static int ResetDefaultOutput(void); protected: char m_name[64]; HANDLE m_hPipe; #ifdef CONSOLE_LOGGER_USING_MS_SDK // we'll use this DWORD as VERY fast critical-section . for more info: // * "Understand the Impact of Low-Lock Techniques in Multithreaded Apps" // Vance Morrison , MSDN Magazine October 2005 // * "Performance-Conscious Thread Synchronization" , Jeffrey Richter , MSDN Magazine October 2005 volatile long m_fast_critical_section; inline void InitializeCriticalSection(void) { m_fast_critical_section=0; } inline void DeleteCriticalSection(void) { m_fast_critical_section=0; } // our own LOCK function inline void EnterCriticalSection(void) { while ( InterlockedCompareExchange(&m_fast_critical_section,1,0)!=0) Sleep(0); } // our own UNLOCK function inline void LeaveCriticalSection(void) { m_fast_critical_section=0; } #else CRITICAL_SECTION m_cs; inline void InitializeCriticalSection(void) { ::InitializeCriticalSection(&m_cs); } inline void DeleteCriticalSection(void) { ::DeleteCriticalSection(&m_cs); } // our own LOCK function inline void EnterCriticalSection(void) { ::EnterCriticalSection(&m_cs); } // our own UNLOCK function inline void LeaveCriticalSection(void) { ::LeaveCriticalSection(&m_cs); } #endif // you can extend this class by overriding the function virtual long AddHeaders(void) { return 0;} // the _print() helper function virtual int _print(const char *lpszText,int iSize); // SafeWriteFile : write safely to the pipe inline BOOL SafeWriteFile( /*__in*/ HANDLE hFile, /*__in_bcount(nNumberOfBytesToWrite)*/ LPCVOID lpBuffer, /*__in */ DWORD nNumberOfBytesToWrite, /*__out_opt */ LPDWORD lpNumberOfBytesWritten, /*__inout_opt */ LPOVERLAPPED lpOverlapped ) { EnterCriticalSection(); BOOL bRet = ::WriteFile(hFile,lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,lpOverlapped); LeaveCriticalSection(); return bRet; } }; /////////////////////////////////////////////////////////////////////////// // CConsoleLoggerEx: same as CConsoleLogger, // but with COLORS and more functionality (cls,gotoxy,...) // // the drawback - we first send the "command" and than the data, // so it's little bit slower . (i don't believe that anyone // is going to notice the differences , it's not measurable) // ////////////////////////////////////////////////////////////////////////// class CConsoleLoggerEx : public CConsoleLogger { DWORD m_dwCurrentAttributes; enum enumCommands { COMMAND_PRINT, COMMAND_CPRINT, COMMAND_CLEAR_SCREEN, COMMAND_COLORED_CLEAR_SCREEN, COMMAND_GOTOXY, COMMAND_CLEAR_EOL, COMMAND_COLORED_CLEAR_EOL }; public: CConsoleLoggerEx(); enum enumColors { COLOR_BLACK=0, COLOR_BLUE=FOREGROUND_BLUE, COLOR_GREEN=FOREGROUND_GREEN , COLOR_RED =FOREGROUND_RED , COLOR_WHITE=COLOR_RED|COLOR_GREEN|COLOR_BLUE, COLOR_INTENSITY =FOREGROUND_INTENSITY , COLOR_BACKGROUND_BLACK=0, COLOR_BACKGROUND_BLUE =BACKGROUND_BLUE , COLOR_BACKGROUND_GREEN =BACKGROUND_GREEN , COLOR_BACKGROUND_RED =BACKGROUND_RED , COLOR_BACKGROUND_WHITE =COLOR_BACKGROUND_RED|COLOR_BACKGROUND_GREEN|COLOR_BACKGROUND_BLUE , COLOR_BACKGROUND_INTENSITY =BACKGROUND_INTENSITY , COLOR_COMMON_LVB_LEADING_BYTE =COMMON_LVB_LEADING_BYTE , COLOR_COMMON_LVB_TRAILING_BYTE =COMMON_LVB_TRAILING_BYTE , COLOR_COMMON_LVB_GRID_HORIZONTAL =COMMON_LVB_GRID_HORIZONTAL , COLOR_COMMON_LVB_GRID_LVERTICAL =COMMON_LVB_GRID_LVERTICAL , COLOR_COMMON_LVB_GRID_RVERTICAL =COMMON_LVB_GRID_RVERTICAL , COLOR_COMMON_LVB_REVERSE_VIDEO =COMMON_LVB_REVERSE_VIDEO , COLOR_COMMON_LVB_UNDERSCORE=COMMON_LVB_UNDERSCORE }; // Clear screen , use default color (black&white) void cls(void); // Clear screen use specific color void cls(DWORD color); // Clear till End Of Line , use default color (black&white) void clear_eol(void); // Clear till End Of Line , use specified color void clear_eol(DWORD color); // write string , use specified color int cprintf(int attributes,const char *format,...); // write string , use current color int cprintf(const char *format,...); // goto(x,y) void gotoxy(int x,int y); DWORD GetCurrentColor(void) { return m_dwCurrentAttributes; } void SetCurrentColor(DWORD dwColor) { m_dwCurrentAttributes=dwColor; } protected: virtual long AddHeaders(void) { // Thnx to this function, the "Helper" can see that we are "extended" logger !!! // (so we can use the same helper-child-application for both loggers DWORD cbWritten=0; const char *ptr= "Extended-Console: TRUE\r\n"; WriteFile(m_hPipe,ptr,strlen(ptr),&cbWritten,NULL); return (cbWritten==strlen(ptr)) ? 0 : -1; } virtual int _print(const char *lpszText,int iSize); virtual int _cprint(int attributes,const char *lpszText,int iSize); }; #endif
[ "djawleh@naver.com" ]
djawleh@naver.com
936c6b1f0f486a1ee84416fc0d8852225ea51cad
1097ed333a4000634e68a590ee6ffc6129ae61e3
/Offer/CPP/旋转数组的最小数字.cpp
ee33cc555c7f33c09616b0d831e08e40937f496d
[ "MIT" ]
permissive
AutuanLiu/Code-Storm2019
1bbe890c7ca0d033c32348173bfebba612623a90
8efc7c5475fd888f7d86c3b08a3c1c9e55c1ac30
refs/heads/master
2020-04-23T07:03:08.975232
2019-10-24T08:56:26
2019-10-24T08:56:26
170,995,032
1
0
null
null
null
null
UTF-8
C++
false
false
2,299
cpp
// 旋转数组的最小数字.cpp // 二分法解题 class Solution { public: int minNumberInRotateArray(vector<int> rotateArray) { if (rotateArray.size() <= 0) return -1; // error int ptr1 = 0; int ptr2 = rotateArray.size() - 1; int mid = ptr1; // 一旦第一个元素小于最后一个元素,说明数组本身是有序的,所以初始化为 ptr1 while (rotateArray[ptr1] >= rotateArray[ptr2]) { // 当 ptr1 和 ptr2 相邻的时候,结束 if (ptr2 - ptr1 == 1) { mid = ptr2; break; } mid = (ptr1 + ptr2) / 2; // 当 ptr1, ptr2, mid 三者的数字相同时,只能使用顺序搜索 if (rotateArray[mid] >= rotateArray[ptr1] && rotateArray[mid] <= rotateArray[ptr2]) return inorderSearch(rotateArray); if (rotateArray[mid] >= rotateArray[ptr1]) ptr1 = mid; else if (rotateArray[mid] <= rotateArray[ptr2]) ptr2 = mid; } return rotateArray[mid]; } int inorderSearch(vector<int> rotateArray) { int min_num = rotateArray[0]; for (auto i = rotateArray.begin(); i != rotateArray.end(); i++) { if (*i < min_num) min_num = *i; } return min_num; } }; // 顺序搜索,只需要找到分界点即可 class Solution { public: int minNumberInRotateArray(vector<int> rotateArray) { if (rotateArray.size() <= 0) return -1; int bound = 0; // 分界点的位置 bool flag = false; // 只能取到倒数第二个元素 for (; bound < rotateArray.size() - 1; bound++) { if (rotateArray[bound] > rotateArray[bound + 1]) { flag = true; break; } } return flag ? rotateArray[bound + 1] : rotateArray[0]; } }; class Solution { public: int minNumberInRotateArray(vector<int> rotateArray) { int n = rotateArray.size(); for (int pos = 1; pos < n; pos++) { if (rotateArray[pos] < rotateArray[pos - 1]) { return rotateArray[pos]; } } return rotateArray[0]; } };
[ "autuanliu@163.com" ]
autuanliu@163.com
35bb5a26000ed27182ac488cf1c23457adfa61dc
38af875a44c6f42169b38d8a85237e778f855e22
/main.cpp
029f79d2172c02c56ce042cbaa7b64879d2bf310
[]
no_license
gaurab2702/Cpp-graph-library
f93f02ce92325b5376282d2ef9fef10bfd988d89
20a48dcee9ed1b9714cfac28a45a0e50d187b154
refs/heads/main
2023-06-18T17:25:23.247370
2021-07-20T07:22:16
2021-07-20T07:22:16
387,704,926
0
0
null
2021-07-20T07:19:42
2021-07-20T07:10:31
null
UTF-8
C++
false
false
864
cpp
#include "Graph.h" #include <iostream> #include <fstream> #include <string> using namespace std; string edgeString(tuple<string, string, int>); //Useful for print edges int main() { vector<string> nodes = {"A", "B", "C", "D"}; Graph G; G.addNode(1.12314, "A"); G.addNode(-7.3412, "B"); G.addNode(420, "C"); G.addNode(-12423, "D"); G.addEdge("A","B", 1); G.addEdge("B","C", -714234.322323); G.addEdge("C","D", 313412341234123); G.addEdge("D","A", -3); G.saveGraph("Yee"); Graph F(string("Yee.txt")); cout << G.getInfo(); cout << F.getInfo(); cout << "\n------------------------------------" << endl; cout << "Done." << endl; cout << "------------------------------------" << endl; } string edgeString(tuple<string, string, int> edge) { string str = get<0>(edge) + get<1>(edge) + to_string(get<2>(edge)); return str; }
[ "noreply@github.com" ]
gaurab2702.noreply@github.com
6955ad08326f1cf2d1c0aaf749566ed6ba6ce3f0
5012f1a7f9d746c117f04ff56f7ebe6d5fc9128f
/1.Server/2.Midware/KFPlugin/KFRobot/KFQueryFriendRankState.cpp
3f23e0ad284c1c1cae7bddbb58bde3f1bb49e3c8
[ "Apache-2.0" ]
permissive
hw233/KFrame
c9badd576ab7c75f4e5aea2cfb3b20f6f102177f
a7e300c301225d0ba3241abcf81e871d8932f326
refs/heads/master
2023-05-11T07:50:30.349114
2019-01-25T08:20:11
2019-01-25T08:20:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
961
cpp
#include "KFQueryFriendRankState.h" #include "KFRobot.h" namespace KFrame { void KFQueryFriendRankState::EnterState( KFRobot* kfrobot ) { // 启动定时器, 10秒认证一次 kfrobot->StartTimer( _kf_robot_config->_state_rep_time ); } void KFQueryFriendRankState::LeaveState( KFRobot* kfrobot ) { kfrobot->StopTimer(); } void KFQueryFriendRankState::CheckState( KFRobot* kfrobot ) { } void KFQueryFriendRankState::RunState( KFRobot* kfrobot ) { if ( !kfrobot->DoneTimer() ) { return; } if ( kfrobot->_loop_wait_times >= _kf_robot_config->_next_state_cryl_time ) { kfrobot->ChangeStateProxy(); //kfrobot->ChangeState( RobotStateEnum::EnterChat ); kfrobot->_loop_wait_times = 0; return; } kfrobot->QueryFriendRankList(); ++kfrobot->_loop_wait_times; } }
[ "lori227@qq.com" ]
lori227@qq.com
eb1d76fa137b7b7e67ed56e4748d7ec0059b3eb1
2665b0d8ab0ba8584721b6dcd50f404952921900
/src/interpreter.hh
576835201010c4237152a77cefa7d19026ae1874
[ "MIT" ]
permissive
hxdaze/Epilog
2f9d938828e5f3e5e356d2695867fca78221650f
48cd45be6003f7968e5ed9ad69d2907fed9f435e
refs/heads/master
2021-12-14T09:34:22.457568
2017-04-22T11:38:05
2017-04-22T11:38:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,172
hh
#include "runtime.hh" namespace Epilog { namespace Interpreter { struct FunctorClause { // A structure entailing a block of instructions containing the definition for each clause with a certain functor. std::vector<Instruction::instructionReference> startAddresses; Instruction::instructionReference endAddress; FunctorClause(Instruction::instructionReference startAddress, Instruction::instructionReference endAddress) : endAddress(endAddress) { startAddresses.push_back(startAddress); } }; class Context { public: std::unordered_map<std::string, FunctorClause> functorClauses; Instruction::instructionReference insertionAddress = 0; }; } // These functions are made visible to external classes so that dynamic instruction generation is possible. namespace AST { void executeInstructions(Instruction::instructionReference startAddress, Instruction::instructionReference endAddress, std::unordered_map<std::string, HeapReference>* allocations); } Instruction::instructionReference pushInstruction(Interpreter::Context& context, Instruction* instruction); void initialiseBuiltins(Interpreter::Context& context); }
[ "github@varkor.com" ]
github@varkor.com
cc0b80bbfaf9d74f44dfe7bcd86ae46a8320ea63
102eae403665433dc48f48196a7e9210ca344678
/MultiThreads/Generated Files/winrt/Windows.Devices.I2c.h
76c119e200ab095dd01dd690ce0ec172f3c02273
[]
no_license
AIchemists/multiThreads
5fd583c46314296cc745d3afa23dbe1994dff9f6
df57a18dff84cd51eda31184a9ba1c811d30e2c0
refs/heads/master
2022-12-18T16:09:57.390044
2020-09-22T01:57:58
2020-09-22T01:57:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
21,568
h
// WARNING: Please don't edit this file. It was generated by C++/WinRT v2.0.200917.4 #ifndef WINRT_Windows_Devices_I2c_H #define WINRT_Windows_Devices_I2c_H #include "winrt/base.h" static_assert(winrt::check_version(CPPWINRT_VERSION, "2.0.200917.4"), "Mismatched C++/WinRT headers."); #define CPPWINRT_VERSION "2.0.200917.4" #include "winrt/Windows.Devices.h" #include "winrt/impl/Windows.Devices.I2c.Provider.2.h" #include "winrt/impl/Windows.Foundation.2.h" #include "winrt/impl/Windows.Foundation.Collections.2.h" #include "winrt/impl/Windows.Devices.I2c.2.h" namespace winrt::impl { template <typename D> WINRT_IMPL_AUTO(int32_t) consume_Windows_Devices_I2c_II2cConnectionSettings<D>::SlaveAddress() const { int32_t value{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cConnectionSettings)->get_SlaveAddress(&value)); return value; } template <typename D> WINRT_IMPL_AUTO(void) consume_Windows_Devices_I2c_II2cConnectionSettings<D>::SlaveAddress(int32_t value) const { check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cConnectionSettings)->put_SlaveAddress(value)); } template <typename D> WINRT_IMPL_AUTO(Windows::Devices::I2c::I2cBusSpeed) consume_Windows_Devices_I2c_II2cConnectionSettings<D>::BusSpeed() const { Windows::Devices::I2c::I2cBusSpeed value{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cConnectionSettings)->get_BusSpeed(reinterpret_cast<int32_t*>(&value))); return value; } template <typename D> WINRT_IMPL_AUTO(void) consume_Windows_Devices_I2c_II2cConnectionSettings<D>::BusSpeed(Windows::Devices::I2c::I2cBusSpeed const& value) const { check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cConnectionSettings)->put_BusSpeed(static_cast<int32_t>(value))); } template <typename D> WINRT_IMPL_AUTO(Windows::Devices::I2c::I2cSharingMode) consume_Windows_Devices_I2c_II2cConnectionSettings<D>::SharingMode() const { Windows::Devices::I2c::I2cSharingMode value{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cConnectionSettings)->get_SharingMode(reinterpret_cast<int32_t*>(&value))); return value; } template <typename D> WINRT_IMPL_AUTO(void) consume_Windows_Devices_I2c_II2cConnectionSettings<D>::SharingMode(Windows::Devices::I2c::I2cSharingMode const& value) const { check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cConnectionSettings)->put_SharingMode(static_cast<int32_t>(value))); } template <typename D> WINRT_IMPL_AUTO(Windows::Devices::I2c::I2cConnectionSettings) consume_Windows_Devices_I2c_II2cConnectionSettingsFactory<D>::Create(int32_t slaveAddress) const { void* value{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cConnectionSettingsFactory)->Create(slaveAddress, &value)); return Windows::Devices::I2c::I2cConnectionSettings{ value, take_ownership_from_abi }; } template <typename D> WINRT_IMPL_AUTO(Windows::Devices::I2c::I2cDevice) consume_Windows_Devices_I2c_II2cController<D>::GetDevice(Windows::Devices::I2c::I2cConnectionSettings const& settings) const { void* device{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cController)->GetDevice(*(void**)(&settings), &device)); return Windows::Devices::I2c::I2cDevice{ device, take_ownership_from_abi }; } template <typename D> WINRT_IMPL_AUTO(Windows::Foundation::IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::Devices::I2c::I2cController>>) consume_Windows_Devices_I2c_II2cControllerStatics<D>::GetControllersAsync(Windows::Devices::I2c::Provider::II2cProvider const& provider) const { void* operation{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cControllerStatics)->GetControllersAsync(*(void**)(&provider), &operation)); return Windows::Foundation::IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::Devices::I2c::I2cController>>{ operation, take_ownership_from_abi }; } template <typename D> WINRT_IMPL_AUTO(Windows::Foundation::IAsyncOperation<Windows::Devices::I2c::I2cController>) consume_Windows_Devices_I2c_II2cControllerStatics<D>::GetDefaultAsync() const { void* operation{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cControllerStatics)->GetDefaultAsync(&operation)); return Windows::Foundation::IAsyncOperation<Windows::Devices::I2c::I2cController>{ operation, take_ownership_from_abi }; } template <typename D> WINRT_IMPL_AUTO(hstring) consume_Windows_Devices_I2c_II2cDevice<D>::DeviceId() const { void* value{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDevice)->get_DeviceId(&value)); return hstring{ value, take_ownership_from_abi }; } template <typename D> WINRT_IMPL_AUTO(Windows::Devices::I2c::I2cConnectionSettings) consume_Windows_Devices_I2c_II2cDevice<D>::ConnectionSettings() const { void* value{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDevice)->get_ConnectionSettings(&value)); return Windows::Devices::I2c::I2cConnectionSettings{ value, take_ownership_from_abi }; } template <typename D> WINRT_IMPL_AUTO(void) consume_Windows_Devices_I2c_II2cDevice<D>::Write(array_view<uint8_t const> buffer) const { check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDevice)->Write(buffer.size(), get_abi(buffer))); } template <typename D> WINRT_IMPL_AUTO(Windows::Devices::I2c::I2cTransferResult) consume_Windows_Devices_I2c_II2cDevice<D>::WritePartial(array_view<uint8_t const> buffer) const { Windows::Devices::I2c::I2cTransferResult result{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDevice)->WritePartial(buffer.size(), get_abi(buffer), put_abi(result))); return result; } template <typename D> WINRT_IMPL_AUTO(void) consume_Windows_Devices_I2c_II2cDevice<D>::Read(array_view<uint8_t> buffer) const { check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDevice)->Read(buffer.size(), put_abi(buffer))); } template <typename D> WINRT_IMPL_AUTO(Windows::Devices::I2c::I2cTransferResult) consume_Windows_Devices_I2c_II2cDevice<D>::ReadPartial(array_view<uint8_t> buffer) const { Windows::Devices::I2c::I2cTransferResult result{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDevice)->ReadPartial(buffer.size(), put_abi(buffer), put_abi(result))); return result; } template <typename D> WINRT_IMPL_AUTO(void) consume_Windows_Devices_I2c_II2cDevice<D>::WriteRead(array_view<uint8_t const> writeBuffer, array_view<uint8_t> readBuffer) const { check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDevice)->WriteRead(writeBuffer.size(), get_abi(writeBuffer), readBuffer.size(), put_abi(readBuffer))); } template <typename D> WINRT_IMPL_AUTO(Windows::Devices::I2c::I2cTransferResult) consume_Windows_Devices_I2c_II2cDevice<D>::WriteReadPartial(array_view<uint8_t const> writeBuffer, array_view<uint8_t> readBuffer) const { Windows::Devices::I2c::I2cTransferResult result{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDevice)->WriteReadPartial(writeBuffer.size(), get_abi(writeBuffer), readBuffer.size(), put_abi(readBuffer), put_abi(result))); return result; } template <typename D> WINRT_IMPL_AUTO(hstring) consume_Windows_Devices_I2c_II2cDeviceStatics<D>::GetDeviceSelector() const { void* value{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDeviceStatics)->GetDeviceSelector(&value)); return hstring{ value, take_ownership_from_abi }; } template <typename D> WINRT_IMPL_AUTO(hstring) consume_Windows_Devices_I2c_II2cDeviceStatics<D>::GetDeviceSelector(param::hstring const& friendlyName) const { void* value{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDeviceStatics)->GetDeviceSelectorFromFriendlyName(*(void**)(&friendlyName), &value)); return hstring{ value, take_ownership_from_abi }; } template <typename D> WINRT_IMPL_AUTO(Windows::Foundation::IAsyncOperation<Windows::Devices::I2c::I2cDevice>) consume_Windows_Devices_I2c_II2cDeviceStatics<D>::FromIdAsync(param::hstring const& deviceId, Windows::Devices::I2c::I2cConnectionSettings const& settings) const { void* operation{}; check_hresult(WINRT_IMPL_SHIM(Windows::Devices::I2c::II2cDeviceStatics)->FromIdAsync(*(void**)(&deviceId), *(void**)(&settings), &operation)); return Windows::Foundation::IAsyncOperation<Windows::Devices::I2c::I2cDevice>{ operation, take_ownership_from_abi }; } #ifndef WINRT_LEAN_AND_MEAN template <typename D> struct produce<D, Windows::Devices::I2c::II2cConnectionSettings> : produce_base<D, Windows::Devices::I2c::II2cConnectionSettings> { int32_t __stdcall get_SlaveAddress(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from<int32_t>(this->shim().SlaveAddress()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_SlaveAddress(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().SlaveAddress(value); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_BusSpeed(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from<Windows::Devices::I2c::I2cBusSpeed>(this->shim().BusSpeed()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_BusSpeed(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().BusSpeed(*reinterpret_cast<Windows::Devices::I2c::I2cBusSpeed const*>(&value)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_SharingMode(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from<Windows::Devices::I2c::I2cSharingMode>(this->shim().SharingMode()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_SharingMode(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().SharingMode(*reinterpret_cast<Windows::Devices::I2c::I2cSharingMode const*>(&value)); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template <typename D> struct produce<D, Windows::Devices::I2c::II2cConnectionSettingsFactory> : produce_base<D, Windows::Devices::I2c::II2cConnectionSettingsFactory> { int32_t __stdcall Create(int32_t slaveAddress, void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from<Windows::Devices::I2c::I2cConnectionSettings>(this->shim().Create(slaveAddress)); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template <typename D> struct produce<D, Windows::Devices::I2c::II2cController> : produce_base<D, Windows::Devices::I2c::II2cController> { int32_t __stdcall GetDevice(void* settings, void** device) noexcept final try { clear_abi(device); typename D::abi_guard guard(this->shim()); *device = detach_from<Windows::Devices::I2c::I2cDevice>(this->shim().GetDevice(*reinterpret_cast<Windows::Devices::I2c::I2cConnectionSettings const*>(&settings))); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template <typename D> struct produce<D, Windows::Devices::I2c::II2cControllerStatics> : produce_base<D, Windows::Devices::I2c::II2cControllerStatics> { int32_t __stdcall GetControllersAsync(void* provider, void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from<Windows::Foundation::IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::Devices::I2c::I2cController>>>(this->shim().GetControllersAsync(*reinterpret_cast<Windows::Devices::I2c::Provider::II2cProvider const*>(&provider))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall GetDefaultAsync(void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from<Windows::Foundation::IAsyncOperation<Windows::Devices::I2c::I2cController>>(this->shim().GetDefaultAsync()); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template <typename D> struct produce<D, Windows::Devices::I2c::II2cDevice> : produce_base<D, Windows::Devices::I2c::II2cDevice> { int32_t __stdcall get_DeviceId(void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from<hstring>(this->shim().DeviceId()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_ConnectionSettings(void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from<Windows::Devices::I2c::I2cConnectionSettings>(this->shim().ConnectionSettings()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall Write(uint32_t __bufferSize, uint8_t* buffer) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().Write(array_view<uint8_t const>(reinterpret_cast<uint8_t const *>(buffer), reinterpret_cast<uint8_t const *>(buffer) + __bufferSize)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall WritePartial(uint32_t __bufferSize, uint8_t* buffer, struct struct_Windows_Devices_I2c_I2cTransferResult* result) noexcept final try { zero_abi<Windows::Devices::I2c::I2cTransferResult>(result); typename D::abi_guard guard(this->shim()); *result = detach_from<Windows::Devices::I2c::I2cTransferResult>(this->shim().WritePartial(array_view<uint8_t const>(reinterpret_cast<uint8_t const *>(buffer), reinterpret_cast<uint8_t const *>(buffer) + __bufferSize))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall Read(uint32_t __bufferSize, uint8_t* buffer) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().Read(array_view<uint8_t>(reinterpret_cast<uint8_t*>(buffer), reinterpret_cast<uint8_t*>(buffer) + __bufferSize)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall ReadPartial(uint32_t __bufferSize, uint8_t* buffer, struct struct_Windows_Devices_I2c_I2cTransferResult* result) noexcept final try { zero_abi<Windows::Devices::I2c::I2cTransferResult>(result); typename D::abi_guard guard(this->shim()); *result = detach_from<Windows::Devices::I2c::I2cTransferResult>(this->shim().ReadPartial(array_view<uint8_t>(reinterpret_cast<uint8_t*>(buffer), reinterpret_cast<uint8_t*>(buffer) + __bufferSize))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall WriteRead(uint32_t __writeBufferSize, uint8_t* writeBuffer, uint32_t __readBufferSize, uint8_t* readBuffer) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().WriteRead(array_view<uint8_t const>(reinterpret_cast<uint8_t const *>(writeBuffer), reinterpret_cast<uint8_t const *>(writeBuffer) + __writeBufferSize), array_view<uint8_t>(reinterpret_cast<uint8_t*>(readBuffer), reinterpret_cast<uint8_t*>(readBuffer) + __readBufferSize)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall WriteReadPartial(uint32_t __writeBufferSize, uint8_t* writeBuffer, uint32_t __readBufferSize, uint8_t* readBuffer, struct struct_Windows_Devices_I2c_I2cTransferResult* result) noexcept final try { zero_abi<Windows::Devices::I2c::I2cTransferResult>(result); typename D::abi_guard guard(this->shim()); *result = detach_from<Windows::Devices::I2c::I2cTransferResult>(this->shim().WriteReadPartial(array_view<uint8_t const>(reinterpret_cast<uint8_t const *>(writeBuffer), reinterpret_cast<uint8_t const *>(writeBuffer) + __writeBufferSize), array_view<uint8_t>(reinterpret_cast<uint8_t*>(readBuffer), reinterpret_cast<uint8_t*>(readBuffer) + __readBufferSize))); return 0; } catch (...) { return to_hresult(); } }; #endif template <typename D> struct produce<D, Windows::Devices::I2c::II2cDeviceStatics> : produce_base<D, Windows::Devices::I2c::II2cDeviceStatics> { int32_t __stdcall GetDeviceSelector(void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from<hstring>(this->shim().GetDeviceSelector()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall GetDeviceSelectorFromFriendlyName(void* friendlyName, void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from<hstring>(this->shim().GetDeviceSelector(*reinterpret_cast<hstring const*>(&friendlyName))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall FromIdAsync(void* deviceId, void* settings, void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from<Windows::Foundation::IAsyncOperation<Windows::Devices::I2c::I2cDevice>>(this->shim().FromIdAsync(*reinterpret_cast<hstring const*>(&deviceId), *reinterpret_cast<Windows::Devices::I2c::I2cConnectionSettings const*>(&settings))); return 0; } catch (...) { return to_hresult(); } }; } WINRT_EXPORT namespace winrt::Windows::Devices::I2c { inline I2cConnectionSettings::I2cConnectionSettings(int32_t slaveAddress) : I2cConnectionSettings(impl::call_factory<I2cConnectionSettings, II2cConnectionSettingsFactory>([&](II2cConnectionSettingsFactory const& f) { return f.Create(slaveAddress); })) { } inline auto I2cController::GetControllersAsync(Windows::Devices::I2c::Provider::II2cProvider const& provider) { return impl::call_factory<I2cController, II2cControllerStatics>([&](II2cControllerStatics const& f) { return f.GetControllersAsync(provider); }); } inline auto I2cController::GetDefaultAsync() { return impl::call_factory_cast<Windows::Foundation::IAsyncOperation<Windows::Devices::I2c::I2cController>(*)(II2cControllerStatics const&), I2cController, II2cControllerStatics>([](II2cControllerStatics const& f) { return f.GetDefaultAsync(); }); } inline auto I2cDevice::GetDeviceSelector() { return impl::call_factory_cast<hstring(*)(II2cDeviceStatics const&), I2cDevice, II2cDeviceStatics>([](II2cDeviceStatics const& f) { return f.GetDeviceSelector(); }); } inline auto I2cDevice::GetDeviceSelector(param::hstring const& friendlyName) { return impl::call_factory<I2cDevice, II2cDeviceStatics>([&](II2cDeviceStatics const& f) { return f.GetDeviceSelector(friendlyName); }); } inline auto I2cDevice::FromIdAsync(param::hstring const& deviceId, Windows::Devices::I2c::I2cConnectionSettings const& settings) { return impl::call_factory<I2cDevice, II2cDeviceStatics>([&](II2cDeviceStatics const& f) { return f.FromIdAsync(deviceId, settings); }); } } namespace std { #ifndef WINRT_LEAN_AND_MEAN template<> struct hash<winrt::Windows::Devices::I2c::II2cConnectionSettings> : winrt::impl::hash_base {}; template<> struct hash<winrt::Windows::Devices::I2c::II2cConnectionSettingsFactory> : winrt::impl::hash_base {}; template<> struct hash<winrt::Windows::Devices::I2c::II2cController> : winrt::impl::hash_base {}; template<> struct hash<winrt::Windows::Devices::I2c::II2cControllerStatics> : winrt::impl::hash_base {}; template<> struct hash<winrt::Windows::Devices::I2c::II2cDevice> : winrt::impl::hash_base {}; template<> struct hash<winrt::Windows::Devices::I2c::II2cDeviceStatics> : winrt::impl::hash_base {}; template<> struct hash<winrt::Windows::Devices::I2c::I2cConnectionSettings> : winrt::impl::hash_base {}; template<> struct hash<winrt::Windows::Devices::I2c::I2cController> : winrt::impl::hash_base {}; template<> struct hash<winrt::Windows::Devices::I2c::I2cDevice> : winrt::impl::hash_base {}; #endif } #endif
[ "jicheng@yahoo.com" ]
jicheng@yahoo.com
2f30b0feb79c37a7639798b04b76f63b8bdb5d4b
812125f1d67ab7cb468a06171fb6ef86c8ef1483
/buff/b.cpp
310642ffc8ccd0bd78875e732dbdcdf68523ef1f
[]
no_license
sxw106106/cpp-learning
861e8d67ed29ce0ceac78acb900e4756667adad6
7cd2817699e816acd6725137e6f7254b9fcbe1a0
refs/heads/master
2021-01-21T06:46:47.779675
2014-03-24T16:20:28
2014-03-24T16:20:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
983
cpp
#include <string.h> #include <stdio.h> #include <stdlib.h> int main(void) { char buff2[4 * 16000 * 16 /8]; printf("################## sizeof(buff2)= %d#################\n",sizeof(buff2)); char buff[3][4 * 16000 * 16 /8]; memset(buff,0,sizeof(buff)); printf("################## sizeof(buff)= %d#################\n",sizeof(buff)); printf("################## sizeof(buff)0= %d#################\n",sizeof(buff[0])); printf("################## sizeof(buff)1= %d#################\n",sizeof(buff[1])); printf("################## sizeof(buff)2= %d#################\n",sizeof(buff[2])); printf("################## address(buff)0= %x#################\n",&buff[0]); printf("################## address(buff)1= %x#################\n",&buff[1]); printf("################## address(buff)2= %x#################\n",&buff[2]); printf("################## len(buff)= %d#################\n",sizeof(buff)/sizeof(buff[0])); return 1; }
[ "no7david@gmail.com" ]
no7david@gmail.com
0dd0f914eea606945a4af6c214d24c7b137c2754
7de2a17a61f83d3aea9d0078d2210d7dfd7960a3
/src/ImProcGLTexture_ClrChk.h
a27c206ec597f80f46a3c66839beb9968224c504
[]
no_license
hhcoder/GlCameraRendering
688ceeed70289a7f8b8bfd1163a2da00cb434883
26ad341cfe075a532e629841e73054e03f31c8d7
refs/heads/master
2020-09-24T10:48:32.021361
2019-12-04T00:18:38
2019-12-04T00:18:38
225,741,857
0
0
null
null
null
null
UTF-8
C++
false
false
1,487
h
#ifndef _IMPROCGLTEXTURE_CLRCHK_H_ #define _IMPROCGLTEXTURE_CLRCHK_H_ #include "ImProcGLTexture.h" #include "ImProcUtilColorChecker.h" namespace ImProc { class GLTexture_ColorChecker : public GLTexture { public: GLTexture_ColorChecker(GLuint iw, GLuint ih) : nFrameWidth(iw), nFrameHeight(ih), textureId(0), pCC(NULL) { pCC = new img_rgb(nFrameWidth, nFrameHeight); glGenTextures(1, &textureId); glBindTexture(GL_TEXTURE_2D, textureId); } virtual void Update(GLubyte* iframe) { GLubyte* pixels = pCC->get_buf(); ActiveTexture0(); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, nFrameWidth, nFrameHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels); } ~GLTexture_ColorChecker() { if(NULL!=pCC) delete pCC; if(0!=textureId) glDeleteTextures(1, &textureId); } private: void ActiveTexture0(void) { // Set up the interpolation method glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); // Active this texture glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textureId); } private: GLuint textureId; GLuint nFrameWidth; GLuint nFrameHeight; private: img_rgb* pCC; };//end namespace ImProc }; #endif
[ "hhwu.coder@outlook.com" ]
hhwu.coder@outlook.com
76a61ab4d8a8fbf46b6ae5b33f89a7d5f83c9fe3
80ed2d804f11a90013b95d51f838513f1e42ef1c
/src/SimpleVariantCallTool.cpp
e2a6a5c5288f517339c61edd211d7fedfbd0e1bc
[]
no_license
ZengFLab/PyroTools
dc80b4cd44b830fd9efe0d16632a8c51650b6e48
81ece81d1947100edbecb807755a01a472d348ad
refs/heads/master
2021-12-05T01:35:57.751050
2015-05-26T03:39:35
2015-05-26T03:39:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
19,328
cpp
#include "SimpleVariantCallTool.h" #include "GenericRegionTools.h" #include "GenericVariant.h" #include "GenericBamAlignmentTools.h" #include "GenericSequenceGlobal.h" using namespace GenericSequenceTools; #include <getopt.h> #include <time.h> #include <tuple> #include <utility> #include <iomanip> #include <iostream> #include <fstream> #include <sstream> #include <sys/stat.h> #include <algorithm> #include <forward_list> #include <unordered_map> #include <parallel/algorithm> #include <omp.h> using namespace std; #include "api/BamReader.h" #include "api/BamMultiReader.h" #include "api/BamAux.h" #include "api/BamAlignment.h" using namespace BamTools; SimpleVariantCallTool::SimpleVariantCallTool() :mapQualThres(5) ,readLenThres(100) ,alnIdentityThres(0.9) ,numAmbiguousThres(2) ,alnFlagMarker(0) ,baseQualThres(10) ,snpHitThres(2) ,indelHitThres(2) ,ignoreSnp(false) ,ignoreIndel(false) ,outputFormat("bed") ,numThreads(1) ,windowSize(1e+5) ,verbose(0) { } // verbose inline void Verbose(string MSG) { cerr << "[" << CurrentTime() << " PyroTools-SimpleVarCall] " << MSG << endl; } // check the existence of a file // reference: http://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c inline bool file_exist(const string& filename) { struct stat buffer; return (stat (filename.c_str(), &buffer) == 0); } // help message int SimpleVariantCallTool::Help() { cerr << "SYNOPSIS" << endl; cerr << " PyroTools SimpleVarCall [OPTIONS] <GENOME> <BAM> [<BAM>...]" << endl; cerr << "" << endl; cerr << "DESCRIPTION" << endl; cerr << " SimpleVarCall is to simply profile all suspect variants in the genome given sequencing data." << endl; cerr << "" << endl; cerr << "OPTIONS" << endl; cerr << "Read Filtration" << endl; cerr << " --roi filter reads not hit the region of interest" << endl; cerr << " --roi-list filter reads not hit the regions of interest" << endl; cerr << " --mq filter reads with mapping quality less than the value (default:5) [INT]" << endl; cerr << " --len filter reads with length less than the value (default:100) [INT]" << endl; cerr << " --iden filter reads with the identity less than the value (default:0.9) [FLT]" << endl; cerr << " --na filter reads with many ambiguous base (default:2) [INT]" << endl; cerr << " --ff filter reads with the specified flags, flag info could be found in SAM manual [INT]" << endl; cerr << "Variant Filtration" << endl; cerr << " --bq filter read alleles with base quality less than the value (default:10) [INT]" << endl; cerr << " --snp-hit filter SNPs with the hits less than the value (default:2) [INT]" << endl; cerr << " --indel-hit filter INDELs with the hits less than the value (default:2) [INT]" << endl; cerr << "Variant Output" << endl; cerr << " --disable-snp ignore SNPs" << endl; cerr << " --disable-indel ignore INDELs" << endl; cerr << " --out-format specify the format of output, valid arguments: bed or vcf (default:bed) [STR]" << endl; cerr << "Miscellaneous" << endl; cerr << " --window specify the size of the scanning window (default:1e+5) [INT]" << endl; cerr << " --num-cores specify the number of cpu cores being used (default:1) [INT]" << endl; cerr << " -v,--verbose specify the level of verbosity, valid arguments: 0 for quiet, 1 for debug (default:0) [INT]" << endl; cerr << " -h,--help print help message" << endl; return 0; } int SimpleVariantCallTool::commandLineParser(int argc, char *argv[]) { auto isHexString = [](string s) { for (auto c : s) { if (c=='x') return true; if (c=='X') return true; } return false; }; int c; while (1) { static struct option long_options[] = { {"roi", required_argument, 0, 0}, {"roi-list", required_argument, 0, 0}, {"mq", required_argument, 0, 0}, {"len", required_argument, 0, 0}, {"iden", required_argument, 0, 0}, {"na", required_argument, 0, 0}, {"ff", required_argument, 0, 0}, {"bq", required_argument, 0, 0}, {"snp-hit", required_argument, 0, 0}, {"indel-hit", required_argument, 0, 0}, {"disable-snp", no_argument, 0, 0}, {"disable-indel", no_argument, 0, 0}, {"out-format", required_argument, 0, 0}, {"num-cores", required_argument, 0, 0}, {"window", required_argument, 0, 0}, {"verbose", required_argument, 0, 'v'}, {"help", no_argument, 0, 'h'}, {0,0,0,0} }; // getopt_long stores the option index here int option_index = 0; c = getopt_long(argc, argv, "v:h", long_options, &option_index); // detect the end of the options if (c==-1) break; switch(c) { case 0: switch(option_index) { case 0: regionStringsOfInterest.emplace_back(optarg); break; case 1: { ifstream infile(optarg); string line; while (getline(infile,line)) { if (!line.empty()) regionStringsOfInterest.emplace_back(optarg); } infile.close(); } break; case 2: mapQualThres=stoi(optarg); break; case 3: readLenThres=stoi(optarg); break; case 4: alnIdentityThres=stod(optarg); break; case 5: numAmbiguousThres=stoi(optarg); break; case 6: if (isHexString(optarg)){ alnFlagMarker |= stoul(optarg,nullptr,16); }else{ alnFlagMarker |= stoi(optarg); } break; case 7: baseQualThres=stoi(optarg); break; case 8: snpHitThres=stoi(optarg); break; case 9: indelHitThres=stoi(optarg); break; case 10: ignoreSnp=true; break; case 11: ignoreIndel=true; break; case 12: outputFormat=optarg; break; case 13: numThreads=stoi(optarg); break; case 14: windowSize=stod(optarg); break; default: abort(); } break; case 'v': verbose=stoi(optarg); break; case 'h': Help(); exit(EXIT_SUCCESS); break; case '?': exit(EXIT_FAILURE); break; default: abort(); } } // genome file if (optind<argc) { genomeFile=argv[optind++]; // check the existence of the genome file if (!file_exist(genomeFile)) { cerr << "[PyroTools-SimpleVarCall] error: " << genomeFile << " not existed" << endl; exit(EXIT_FAILURE); } // check the existence of the genome index file if (!file_exist(genomeFile+".fai")) { cerr << "[PyroTools-SimpleVarCall] error: " << (genomeFile+".fai") << " not existed" << endl; exit(EXIT_FAILURE); } } // bam file for (; optind<argc;) { bamFiles.emplace_back(argv[optind++]); // check the existence of the bam file auto f=*bamFiles.rbegin(); BamReader bamReader; if (!bamReader.Open(f)) { cerr << "[PyroTools-ConsensusGraph] error: " << f << " not existed or invalid" << endl; exit(EXIT_FAILURE); } } // canonicalize the regions if (regionStringsOfInterest.empty()) { BamMultiReader bamReader; bamReader.Open(bamFiles); RefVector genomeDict = bamReader.GetReferenceData(); for (auto g : genomeDict) { regionStringsOfInterest.emplace_back(g.RefName); } } return 0; } // interface int SimpleVariantCallTool::Run(int argc, char *argv[]) { // print help message if no arguments provided if (argc==2) { Help(); exit(EXIT_SUCCESS); } // parse command line options commandLineParser(argc-1,argv+1); // run the simple variant call if (SimpleVariantCall()!=0) return 1; return 0; } // region sorting function inline bool isValidAlignment(BamAlignment& al, int minReadLen, int minMapQual, int flag) { // check read length if (!GenericBamAlignmentTools::validReadLength(al,minReadLen)) return false; // check map quality if (!GenericBamAlignmentTools::validMapQuality(al,minMapQual)) return false; // check the alignment flag if (GenericBamAlignmentTools::isFilteredByFlag(al,flag)) return false; return true; } // workhorse int SimpleVariantCallTool::SimpleVariantCall() { // open bam file BamMultiReader bamReader; bamReader.Open(bamFiles); // the dictionary of the chromosomes RefVector genomeDict = bamReader.GetReferenceData(); // define the scanning window if (verbose>=1) Verbose(string("define the scanning window")); vector<tuple<int,int,int>> scanWindowSet; int numWindow = GenericRegionTools::toScanWindow(genomeDict, regionStringsOfInterest, windowSize, scanWindowSet); // compute the width for cout int wc1=3,wc2=3,wc3=3,wc4=1,wc5=1; for_each(genomeDict.begin(),genomeDict.end(),[&](RefData& a){ if (wc1<a.RefName.length()) wc1 = a.RefName.length(); if (wc2<to_string(a.RefLength).length()) wc2 = to_string(a.RefLength).length(); if (wc3<to_string(a.RefLength).length()) wc3 = to_string(a.RefLength).length(); }); // lambda funtion for output auto repoVar = [&](GenericAllele& allele) { // to avoid cout interleaving error in parallel mode stringstream buffer; string info = "snp"; if (allele.m_allele=="-" && allele.m_reference!="-") info = "del"; if (allele.m_allele!="-" && allele.m_reference=="-") info = "ins"; buffer << setw(wc1) << left << genomeDict[allele.m_chrID].RefName << "\t" << setw(wc2) << left << (allele.m_chrPosition+1) << "\t" << setw(wc3) << left << (allele.m_chrPosition+1+1) << "\t" << setw(wc4) << left << allele.m_reference << "\t" << setw(wc5) << left << allele.m_allele << "\t" << setw(3) << left << allele.m_alleleDepth << "\t" << setw(3) << left << allele.m_globalDepth << "\t" << setw(3) << left << info << "\n"; std::cout << buffer.str() << std::flush; }; clock_t allTime = 0; // loop over windows if (verbose>=1) Verbose(string("looping over the windows")); omp_set_dynamic(0); omp_set_num_threads(numThreads); #pragma omp parallel for shared(genomeDict,repoVar) reduction(+:allTime) for (int i=0; i<numWindow; i++) { BamMultiReader bamReader; bamReader.Open(bamFiles); clock_t tStart = clock(); // define an alignment BamAlignment aln; // alleles in the window unordered_map<string,GenericAllele> alleles; // define a lambda function auto depoVar = [&](int tId, int tPos, char tRef, char tAlt, double tBq, int tDep) { string tKey = GenericAllele::key(tId, tPos, tRef, tAlt); auto tPtr = alleles.find(tKey); if (tPtr==alleles.end()) { GenericAllele allele; allele.m_chrID = tId; allele.m_chrPosition = tPos; allele.m_reference = tRef; allele.m_globalDepth = tDep; allele.m_allele = tAlt; allele.m_alleleDepth = 1; allele.m_alleleMapAvgQual = aln.MapQuality; allele.m_alleleStrandPos = (aln.IsReverseStrand()?0:1); allele.m_alleleStrandNeg = (aln.IsReverseStrand()?1:0); allele.m_bamData.emplace_back(tuple<char,int,int,int>(tAlt,tBq,aln.MapQuality,((aln.IsReverseStrand()?-1:1)))); alleles.emplace(make_pair(tKey, allele)); }else { tPtr->second.m_alleleDepth += 1; tPtr->second.m_alleleMapAvgQual += aln.MapQuality; tPtr->second.m_alleleStrandPos += (aln.IsReverseStrand()?0:1); tPtr->second.m_alleleStrandNeg += (aln.IsReverseStrand()?1:0); tPtr->second.m_bamData.emplace_back(tuple<char,int,int,int>(tAlt,tBq,aln.MapQuality,((aln.IsReverseStrand()?-1:1)))); } }; // window position tuple<int,int,int> w = scanWindowSet[i]; int wId = get<0>(w); int wLp = get<1>(w); int wRp = get<2>(w); // get sequencing depth if (verbose>=1) Verbose("retrieve the depths in "+genomeDict[wId].RefName+":"+to_string(wLp+1)+"-"+to_string(wRp)); map<long,long> genomeDepth; string CMD, DepthResult; stringstream ssCMD; ssCMD << "samtools depth "; ssCMD << "-r " << genomeDict[wId].RefName+":"+to_string(wLp+1)+"-"+to_string(wRp) << " "; ssCMD << "-q " << baseQualThres << " "; ssCMD << "-Q " << mapQualThres << " "; ssCMD << "-l " << readLenThres << " "; for (auto bf : bamFiles) ssCMD << " " << bf; CMD = ssCMD.str(); // run the command RunCmdGetReturn(CMD, DepthResult); // parse the result { string tId; int tPos, tDep; string result; stringstream ssResult; stringstream ssDepthResult(DepthResult); while(getline(ssDepthResult, result)){ ssResult << result; ssResult >> tId >> tPos >> tDep; ssResult.clear(); ssResult.str(""); genomeDepth[tPos-1] = tDep; } } // get variants if (verbose>=1) Verbose("retrieve the variants in "+genomeDict[wId].RefName+":"+to_string(wLp+1)+"-"+to_string(wRp)); // rewind the reader bamReader.Rewind(); // set the window region bamReader.SetRegion(wId, wLp, wId, wRp); // retrieve an alignment in the window while (bamReader.GetNextAlignment(aln)) { // skip the alignment if it doesn't overlap the window if (aln.Position>=wRp || aln.GetEndPosition()<=wLp) continue; // skip the invalid alignment if (!isValidAlignment(aln, readLenThres, mapQualThres, alnFlagMarker)) continue; // skip the alignment harboring too many mismatches if (!GenericBamAlignmentTools::validReadIdentity(aln, 1-alnIdentityThres)) continue; if (!ignoreSnp) { // retrieve the SNPs on the read vector<long> readSnpPos; vector<char> readSnpRef; vector<char> readSnpAlt; vector<double> readSnpBq; GenericBamAlignmentTools::getBamAlignmentMismatches(aln, readSnpPos, readSnpRef, readSnpAlt, readSnpBq); for (size_t j=0; j<readSnpAlt.size(); j++) { if (readSnpBq[j]<baseQualThres) continue; if (readSnpPos[j]<wLp || readSnpPos[j]>=wRp) continue; depoVar(wId, readSnpPos[j], readSnpRef[j], readSnpAlt[j], readSnpBq[j], genomeDepth[readSnpPos[j]]); } } if (!ignoreIndel) { // retrieve the inserts on the read vector<long> readInsPos; vector<string> readInsSeq; vector<vector<double>> readInsBq; GenericBamAlignmentTools::getBamAlignmentInserts(aln, readInsPos, readInsSeq, readInsBq); for (size_t j=0; j<readInsPos.size(); j++) { int ip = readInsPos[j]; string iseq = readInsSeq[j]; vector<double> ibq = readInsBq[j]; for (size_t k=0; k<iseq.length(); k++, ip++) { if (ip<wLp || ip>=wRp) continue; depoVar(wId, ip, '-', iseq[k], ibq[k], genomeDepth[ip]); } } } if (!ignoreIndel) { // retrieve the deletes on the read vector<long> readDelPos; vector<string> readDelSeq; GenericBamAlignmentTools::getBamAlignmentDeletes(aln, readDelPos, readDelSeq); for (size_t j=0; j<readDelPos.size(); j++) { int dp = readDelPos[j]; string dseq = readDelSeq[j]; for (size_t k=0; k<dseq.length(); k++, dp++) { if (dp<wLp || dp>=wRp) continue; depoVar(wId, dp, dseq[k], '-', 0, genomeDepth[dp]); } } } } if (verbose>=1) Verbose("output the variants"); // filter and output for (auto ptr : alleles) { GenericAllele allele = get<1>(ptr); if (ignoreSnp && allele.m_reference!="-" && allele.m_allele!="-") continue; if (ignoreIndel && (allele.m_reference=="-" || allele.m_allele=="-")) continue; if (allele.m_reference!="-" && allele.m_allele!="-") { if (allele.m_alleleDepth>snpHitThres) { repoVar(allele); } }else { if (allele.m_alleleDepth>indelHitThres) { repoVar(allele); } } } clock_t tEnd = clock(); allTime += tEnd - tStart; if (verbose>=1) Verbose("time elapsed "+to_string((double)(tEnd-tStart)/CLOCKS_PER_SEC)+" seconds"); } if (verbose>=1) Verbose("total time elapsed "+to_string((double)allTime/CLOCKS_PER_SEC)+" seconds"); bamReader.Close(); return 0; }
[ "zeng.bupt@gmail.com" ]
zeng.bupt@gmail.com
90e3241c86b5ce4a32b1ada77a53bdf247fd2f06
22d5d10c1f67efe97b8854760b7934d8e16d269b
/LeetCodeCPP/47. PermutationsII/main.cpp
7a88a97f926481b3ad11969dd754c48358f0cdd4
[ "Apache-2.0" ]
permissive
18600130137/leetcode
42241ece7fce1536255d427a87897015b26fd16d
fd2dc72c0b85da50269732f0fcf91326c4787d3a
refs/heads/master
2020-04-24T01:48:03.049019
2019-10-17T06:02:57
2019-10-17T06:02:57
171,612,908
1
0
null
null
null
null
UTF-8
C++
false
false
1,591
cpp
// // main.cpp // 47. PermutationsII // // Created by admin on 2019/3/18. // Copyright © 2019年 liu. All rights reserved. // #include <iostream> #include <vector> using namespace std; class Solution { private: // void helper(vector<vector<int>> &ret,vector<int> &nums,int start){ // if(start>=nums.size()-1){ // ret.push_back(nums); // return; // } // for(int i=start;i<nums.size();i++){ // if(i>start && nums[i]==nums[start]){ // continue; // } // swap(nums[start],nums[i]); // helper(ret,nums,start+1); // swap(nums[start],nums[i]); // } // } void helper1(vector<vector<int>> &ret,vector<int> nums,int start){ if(start>=nums.size()-1){ ret.push_back(nums); return; } for(int i=start;i<nums.size();i++){ if(i>start && nums[i]==nums[start]){ continue; } swap(nums[start],nums[i]); helper1(ret,nums,start+1); } } public: vector<vector<int>> permuteUnique(vector<int>& nums) { sort(nums.begin(),nums.end()); vector<vector<int>> ret; helper1(ret,nums,0); return ret; } }; int main(int argc, const char * argv[]) { vector<int> input={1,1,2,2}; Solution so=Solution(); vector<vector<int>> ret=so.permuteUnique(input); for(vector<int> item:ret){ for(int i:item){ cout<<i<<" "; } cout<<endl; } return 0; }
[ "guodongliu6@crediteses.cn" ]
guodongliu6@crediteses.cn
faf80e17980949abd2b6d7cd85c2439262df41f6
3f96f4c7d8c32b662a4b913f5596c2c33953ab65
/RealTimeClock.h
2992a9bc69242cee8e24e062299519aa02a9c22c
[]
no_license
hannahellis4242/clock
397dad52941e6d51747c47cab737a8a7e55447f2
d8f450f246c7178812b7282ca308a8f48a261d18
refs/heads/master
2022-08-29T09:19:00.157778
2020-05-28T16:04:52
2020-05-28T16:04:52
255,748,417
0
0
null
null
null
null
UTF-8
C++
false
false
763
h
#ifndef REALTIMECLOCK_H #define REALTIMECLOCK_H #include "Array.h" class RealTimeClock { private: volatile uint8_t * out_port_ ; const volatile uint8_t * in_port_ ; uint8_t ce_mask_high_ ; uint8_t ce_mask_low_ ; public: RealTimeClock(volatile uint8_t * out_port , const volatile uint8_t * in_port , const uint8_t ce_pin ) ; Array< uint8_t , 7 > read() const; void write( const Array< uint8_t , 7 > & data ) const; uint8_t getControlRegister()const ; uint8_t getSecondsByte() const; uint8_t getMinutesByte() const; uint8_t getHoursByte() const; uint8_t getDayByte() const; uint8_t getDateByte() const; uint8_t getMonthByte() const; uint8_t getYearByte() const; void setControlRegister( const uint8_t value )const; }; #endif
[ "hannah.ellis@pulsic.com" ]
hannah.ellis@pulsic.com
57c125372bb62b28735315c8c24afd9bfc8f2b16
da70d298517ee35165391f8486489df0a0417319
/LAB3.1/Message.cpp
486596be8ac479dd2a37c23aef19d6586e4ed7de
[]
no_license
Lorenzodelso/PdS
1eb5f0cb837fd0e85ed11b0f64dbd684e4a809e8
41b0f7f878968c587e5a0344fd73a110bce5dd0b
refs/heads/master
2020-05-19T09:12:06.752650
2019-05-15T14:56:37
2019-05-15T14:56:37
184,941,385
1
0
null
null
null
null
UTF-8
C++
false
false
414
cpp
// // Created by Lorenzo Del Sordo on 2019-05-14. // #include "Message.h" Message::Message(bool insert, int siteId, Symbol* s): s(s),insert(insert),siteId(siteId) {} Message::Message(const Message &m) { this->insert = m.insert; this->siteId = m.siteId; this->s = m.s; } bool Message::isInsert() { return insert;} Symbol* Message::getSymbol(){ return s;} int Message::getSiteId() { return siteId;}
[ "noreply@github.com" ]
Lorenzodelso.noreply@github.com
9ee48f6304aaf1e28305bae593445a2126289807
aa925e9df0eada356de766d656ad7ba95d818b7b
/algorithm/tree/KthSmallestInBST.cpp
53d7745f17d4402aa52503a71163645b4505892d
[]
no_license
starboy520/starboy
38bf51be81b5cc526a77e1ea16b1dab0b3e9f058
ce386c0f5f4f8625e7030305f32194b75ca5ab1b
refs/heads/master
2021-01-17T12:10:57.480551
2014-08-06T07:09:49
2014-08-06T07:09:49
554,437
1
0
null
null
null
null
UTF-8
C++
false
false
885
cpp
struct TreeNode { TreeNode* left; TreeNode* right; int val; }; TreeNode* findKthSmallest(TreeNode* root, int& val, int k) { TreeNode* tmp = NULL; if (root->left && val < k) { tmp = findKthSmallest(root->left, val, k) } val++; if (val == k) return tmp; if (root->right && *n < k) tmp = findKthSmallest(root->right, val, k); return tmp; } // find a node's successor TreeNode* inOrderSucessor(TreeNode* root, TreeNode* p) { if (p->right) { TreeNode* q = p->right; while (q->left) q = q->left; return q; } TreeNode* succ = NULL; while (root != NULL) { if (p->val < root->val) { succ = root; root = root->left; } else if (n->val > root->val) root = root->right; else break; } return succ; }
[ "starboy.qi@gmail.com" ]
starboy.qi@gmail.com
b8f6a619f16a44378cba52af5ab40db757bd6376
81ec283d00fa64b514063918475cf716fce18902
/empty csgo sdk/handling/hooks/hooks.cpp
a88765231097dae6b750560c1f1a4e0f54c0f1a1
[]
no_license
zanzo420/csgobase
ee350c11a6487bae6395821bed0e31f6142ca286
7c6ef093594cbe185420f8f55d21540f62d81abb
refs/heads/master
2022-04-28T03:24:07.887141
2020-04-03T22:22:36
2020-04-03T22:22:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,303
cpp
#include "hooks.h" #include "../utils/render.h" #include "../../hacks/hacks.h" #include "../../menu/main/menu.h" namespace handling { namespace hooks { std::unique_ptr <handling::utils::vmt_hook> CModeHook; std::unique_ptr <handling::utils::vmt_hook> GPanelHook; std::unique_ptr <handling::utils::vmt_hook> SurfaceVGUI; static bool __fastcall CreateMoveHook( sdk::interfaces::client_mode* thisptr, std::uint32_t* edx, float Time, sdk::classes::user_cmd* Command ) noexcept { if ( !Time || !Command || !Command->CommandNumber ) return false; if ( !sdk::interfaces::EngineClient->IsConnected( ) || !sdk::interfaces::EngineClient->IsInGame( ) ) return false; // Run variables handling::utils::Command = Command; handling::utils::Local = reinterpret_cast< sdk::classes::base_general* >( sdk::interfaces::ClientEntityList->GetClientEntity( sdk::interfaces::EngineClient->GetLocalPlayer( ) ) ); hacks::misc::OnMove( ); hacks::aimbot::OnMove( ); return false; } static void __fastcall PaintTraverseHook( std::uint32_t* ecx, std::uint32_t* edx, std::uint32_t Panel, bool ForceRepaint, bool AllowForce ) noexcept { static auto OriginPaintTraverse = GPanelHook->GetOriginalFunction< decltype( &PaintTraverseHook) > ( handling::hooks::funcs_indexes::paint_traverse ) ; static std::uint32_t PanelID; // Free the engine if ( OriginPaintTraverse ) OriginPaintTraverse( ecx, edx, Panel, ForceRepaint, AllowForce ); if ( !PanelID ) { if ( !strcmp( "MatSystemTopPanel", sdk::interfaces::GuiPanel->GetPanelName( Panel ) ) ) PanelID = Panel; } if ( PanelID == Panel ) { hacks::visuals::RunVisuals( ); menu::draw::DrawMenu( ); } } static void __fastcall LockCursorHook( std::uint32_t* ecx, std::uint32_t* edx ) noexcept { static auto OriginLockCursor = SurfaceVGUI->GetOriginalFunction< decltype( &LockCursorHook ) >( handling::hooks::funcs_indexes::lock_cursor ); if ( menu::MenuOpened ) { sdk::interfaces::GuiSurface->UnlockCursor( ); sdk::interfaces::InputSystem->EnableInput( false ); return; } else { sdk::interfaces::InputSystem->EnableInput( true ); } if ( OriginLockCursor ) OriginLockCursor( ecx, edx ); } void RunHooks( void ) noexcept { CModeHook = std::make_unique <handling::utils::vmt_hook>( ); CModeHook->Initialize( sdk::interfaces::ClientMode ); CModeHook->HookFunction( handling::hooks::funcs_indexes::create_move, reinterpret_cast < void* > ( handling::hooks::CreateMoveHook ) ); GPanelHook = std::make_unique <handling::utils::vmt_hook>( ); GPanelHook->Initialize( sdk::interfaces::GuiPanel ); GPanelHook->HookFunction( handling::hooks::funcs_indexes::paint_traverse, reinterpret_cast < void* > ( handling::hooks::PaintTraverseHook ) ); SurfaceVGUI = std::make_unique <handling::utils::vmt_hook>( ); SurfaceVGUI->Initialize( sdk::interfaces::GuiSurface ); SurfaceVGUI->HookFunction( handling::hooks::funcs_indexes::lock_cursor, reinterpret_cast < void* > ( handling::hooks::LockCursorHook ) ); } void ShutdownHooks( void ) noexcept { CModeHook->Unhook( ); GPanelHook->Unhook( ); SurfaceVGUI->Unhook( ); } }; };
[ "noreply@github.com" ]
zanzo420.noreply@github.com
cfe6ea69b76a06517c71b274721dafb4b8459b43
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_1/ISA2+dmb.sy+po+ctrl.c.cbmc_out.cpp
1b8de5e51e7f2305d9a294d4e8bd3b587c0671d9
[]
no_license
ashutosh0gupta/llvm_bmc
aaac7961c723ba6f7ffd77a39559e0e52432eade
0287c4fb180244e6b3c599a9902507f05c8a7234
refs/heads/master
2023-08-02T17:14:06.178723
2023-07-31T10:46:53
2023-07-31T10:46:53
143,100,825
3
4
null
2023-05-25T05:50:55
2018-08-01T03:47:00
C++
UTF-8
C++
false
false
43,657
cpp
// 0:vars:3 // 8:thr2:1 // 3:atom_1_X0_1:1 // 4:atom_2_X0_1:1 // 5:atom_2_X2_0:1 // 6:thr0:1 // 7:thr1:1 #define ADDRSIZE 9 #define NPROC 4 #define NCONTEXT 1 #define ASSUME(stmt) __CPROVER_assume(stmt) #define ASSERT(stmt) __CPROVER_assert(stmt, "error") #define max(a,b) (a>b?a:b) char __get_rng(); char get_rng( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } char get_rng_th( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } int main(int argc, char **argv) { // declare arrays for intial value version in contexts int meminit_[ADDRSIZE*NCONTEXT]; #define meminit(x,k) meminit_[(x)*NCONTEXT+k] int coinit_[ADDRSIZE*NCONTEXT]; #define coinit(x,k) coinit_[(x)*NCONTEXT+k] int deltainit_[ADDRSIZE*NCONTEXT]; #define deltainit(x,k) deltainit_[(x)*NCONTEXT+k] // declare arrays for running value version in contexts int mem_[ADDRSIZE*NCONTEXT]; #define mem(x,k) mem_[(x)*NCONTEXT+k] int co_[ADDRSIZE*NCONTEXT]; #define co(x,k) co_[(x)*NCONTEXT+k] int delta_[ADDRSIZE*NCONTEXT]; #define delta(x,k) delta_[(x)*NCONTEXT+k] // declare arrays for local buffer and observed writes int buff_[NPROC*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NPROC*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NPROC*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NPROC*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NPROC*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NPROC*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NPROC*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NPROC*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NPROC*ADDRSIZE]; #define crmax(x,k) crmax_[(x)*ADDRSIZE+k] char sforbid_[ADDRSIZE*NCONTEXT]; #define sforbid(x,k) sforbid_[(x)*NCONTEXT+k] // declare arrays for synchronizations int cl[NPROC]; int cdy[NPROC]; int cds[NPROC]; int cdl[NPROC]; int cisb[NPROC]; int caddr[NPROC]; int cctrl[NPROC]; int cstart[NPROC]; int creturn[NPROC]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; int r0= 0; char creg_r0; int r1= 0; char creg_r1; int r2= 0; char creg_r2; int r3= 0; char creg_r3; int r4= 0; char creg_r4; int r5= 0; char creg_r5; int r6= 0; char creg_r6; int r7= 0; char creg_r7; int r8= 0; char creg_r8; int r9= 0; char creg_r9; int r10= 0; char creg_r10; int r11= 0; char creg_r11; int r12= 0; char creg_r12; char old_cctrl= 0; char old_cr= 0; char old_cdy= 0; char old_cw= 0; char new_creg= 0; buff(0,0) = 0; pw(0,0) = 0; cr(0,0) = 0; iw(0,0) = 0; cw(0,0) = 0; cx(0,0) = 0; is(0,0) = 0; cs(0,0) = 0; crmax(0,0) = 0; buff(0,1) = 0; pw(0,1) = 0; cr(0,1) = 0; iw(0,1) = 0; cw(0,1) = 0; cx(0,1) = 0; is(0,1) = 0; cs(0,1) = 0; crmax(0,1) = 0; buff(0,2) = 0; pw(0,2) = 0; cr(0,2) = 0; iw(0,2) = 0; cw(0,2) = 0; cx(0,2) = 0; is(0,2) = 0; cs(0,2) = 0; crmax(0,2) = 0; buff(0,3) = 0; pw(0,3) = 0; cr(0,3) = 0; iw(0,3) = 0; cw(0,3) = 0; cx(0,3) = 0; is(0,3) = 0; cs(0,3) = 0; crmax(0,3) = 0; buff(0,4) = 0; pw(0,4) = 0; cr(0,4) = 0; iw(0,4) = 0; cw(0,4) = 0; cx(0,4) = 0; is(0,4) = 0; cs(0,4) = 0; crmax(0,4) = 0; buff(0,5) = 0; pw(0,5) = 0; cr(0,5) = 0; iw(0,5) = 0; cw(0,5) = 0; cx(0,5) = 0; is(0,5) = 0; cs(0,5) = 0; crmax(0,5) = 0; buff(0,6) = 0; pw(0,6) = 0; cr(0,6) = 0; iw(0,6) = 0; cw(0,6) = 0; cx(0,6) = 0; is(0,6) = 0; cs(0,6) = 0; crmax(0,6) = 0; buff(0,7) = 0; pw(0,7) = 0; cr(0,7) = 0; iw(0,7) = 0; cw(0,7) = 0; cx(0,7) = 0; is(0,7) = 0; cs(0,7) = 0; crmax(0,7) = 0; buff(0,8) = 0; pw(0,8) = 0; cr(0,8) = 0; iw(0,8) = 0; cw(0,8) = 0; cx(0,8) = 0; is(0,8) = 0; cs(0,8) = 0; crmax(0,8) = 0; cl[0] = 0; cdy[0] = 0; cds[0] = 0; cdl[0] = 0; cisb[0] = 0; caddr[0] = 0; cctrl[0] = 0; cstart[0] = get_rng(0,NCONTEXT-1); creturn[0] = get_rng(0,NCONTEXT-1); buff(1,0) = 0; pw(1,0) = 0; cr(1,0) = 0; iw(1,0) = 0; cw(1,0) = 0; cx(1,0) = 0; is(1,0) = 0; cs(1,0) = 0; crmax(1,0) = 0; buff(1,1) = 0; pw(1,1) = 0; cr(1,1) = 0; iw(1,1) = 0; cw(1,1) = 0; cx(1,1) = 0; is(1,1) = 0; cs(1,1) = 0; crmax(1,1) = 0; buff(1,2) = 0; pw(1,2) = 0; cr(1,2) = 0; iw(1,2) = 0; cw(1,2) = 0; cx(1,2) = 0; is(1,2) = 0; cs(1,2) = 0; crmax(1,2) = 0; buff(1,3) = 0; pw(1,3) = 0; cr(1,3) = 0; iw(1,3) = 0; cw(1,3) = 0; cx(1,3) = 0; is(1,3) = 0; cs(1,3) = 0; crmax(1,3) = 0; buff(1,4) = 0; pw(1,4) = 0; cr(1,4) = 0; iw(1,4) = 0; cw(1,4) = 0; cx(1,4) = 0; is(1,4) = 0; cs(1,4) = 0; crmax(1,4) = 0; buff(1,5) = 0; pw(1,5) = 0; cr(1,5) = 0; iw(1,5) = 0; cw(1,5) = 0; cx(1,5) = 0; is(1,5) = 0; cs(1,5) = 0; crmax(1,5) = 0; buff(1,6) = 0; pw(1,6) = 0; cr(1,6) = 0; iw(1,6) = 0; cw(1,6) = 0; cx(1,6) = 0; is(1,6) = 0; cs(1,6) = 0; crmax(1,6) = 0; buff(1,7) = 0; pw(1,7) = 0; cr(1,7) = 0; iw(1,7) = 0; cw(1,7) = 0; cx(1,7) = 0; is(1,7) = 0; cs(1,7) = 0; crmax(1,7) = 0; buff(1,8) = 0; pw(1,8) = 0; cr(1,8) = 0; iw(1,8) = 0; cw(1,8) = 0; cx(1,8) = 0; is(1,8) = 0; cs(1,8) = 0; crmax(1,8) = 0; cl[1] = 0; cdy[1] = 0; cds[1] = 0; cdl[1] = 0; cisb[1] = 0; caddr[1] = 0; cctrl[1] = 0; cstart[1] = get_rng(0,NCONTEXT-1); creturn[1] = get_rng(0,NCONTEXT-1); buff(2,0) = 0; pw(2,0) = 0; cr(2,0) = 0; iw(2,0) = 0; cw(2,0) = 0; cx(2,0) = 0; is(2,0) = 0; cs(2,0) = 0; crmax(2,0) = 0; buff(2,1) = 0; pw(2,1) = 0; cr(2,1) = 0; iw(2,1) = 0; cw(2,1) = 0; cx(2,1) = 0; is(2,1) = 0; cs(2,1) = 0; crmax(2,1) = 0; buff(2,2) = 0; pw(2,2) = 0; cr(2,2) = 0; iw(2,2) = 0; cw(2,2) = 0; cx(2,2) = 0; is(2,2) = 0; cs(2,2) = 0; crmax(2,2) = 0; buff(2,3) = 0; pw(2,3) = 0; cr(2,3) = 0; iw(2,3) = 0; cw(2,3) = 0; cx(2,3) = 0; is(2,3) = 0; cs(2,3) = 0; crmax(2,3) = 0; buff(2,4) = 0; pw(2,4) = 0; cr(2,4) = 0; iw(2,4) = 0; cw(2,4) = 0; cx(2,4) = 0; is(2,4) = 0; cs(2,4) = 0; crmax(2,4) = 0; buff(2,5) = 0; pw(2,5) = 0; cr(2,5) = 0; iw(2,5) = 0; cw(2,5) = 0; cx(2,5) = 0; is(2,5) = 0; cs(2,5) = 0; crmax(2,5) = 0; buff(2,6) = 0; pw(2,6) = 0; cr(2,6) = 0; iw(2,6) = 0; cw(2,6) = 0; cx(2,6) = 0; is(2,6) = 0; cs(2,6) = 0; crmax(2,6) = 0; buff(2,7) = 0; pw(2,7) = 0; cr(2,7) = 0; iw(2,7) = 0; cw(2,7) = 0; cx(2,7) = 0; is(2,7) = 0; cs(2,7) = 0; crmax(2,7) = 0; buff(2,8) = 0; pw(2,8) = 0; cr(2,8) = 0; iw(2,8) = 0; cw(2,8) = 0; cx(2,8) = 0; is(2,8) = 0; cs(2,8) = 0; crmax(2,8) = 0; cl[2] = 0; cdy[2] = 0; cds[2] = 0; cdl[2] = 0; cisb[2] = 0; caddr[2] = 0; cctrl[2] = 0; cstart[2] = get_rng(0,NCONTEXT-1); creturn[2] = get_rng(0,NCONTEXT-1); buff(3,0) = 0; pw(3,0) = 0; cr(3,0) = 0; iw(3,0) = 0; cw(3,0) = 0; cx(3,0) = 0; is(3,0) = 0; cs(3,0) = 0; crmax(3,0) = 0; buff(3,1) = 0; pw(3,1) = 0; cr(3,1) = 0; iw(3,1) = 0; cw(3,1) = 0; cx(3,1) = 0; is(3,1) = 0; cs(3,1) = 0; crmax(3,1) = 0; buff(3,2) = 0; pw(3,2) = 0; cr(3,2) = 0; iw(3,2) = 0; cw(3,2) = 0; cx(3,2) = 0; is(3,2) = 0; cs(3,2) = 0; crmax(3,2) = 0; buff(3,3) = 0; pw(3,3) = 0; cr(3,3) = 0; iw(3,3) = 0; cw(3,3) = 0; cx(3,3) = 0; is(3,3) = 0; cs(3,3) = 0; crmax(3,3) = 0; buff(3,4) = 0; pw(3,4) = 0; cr(3,4) = 0; iw(3,4) = 0; cw(3,4) = 0; cx(3,4) = 0; is(3,4) = 0; cs(3,4) = 0; crmax(3,4) = 0; buff(3,5) = 0; pw(3,5) = 0; cr(3,5) = 0; iw(3,5) = 0; cw(3,5) = 0; cx(3,5) = 0; is(3,5) = 0; cs(3,5) = 0; crmax(3,5) = 0; buff(3,6) = 0; pw(3,6) = 0; cr(3,6) = 0; iw(3,6) = 0; cw(3,6) = 0; cx(3,6) = 0; is(3,6) = 0; cs(3,6) = 0; crmax(3,6) = 0; buff(3,7) = 0; pw(3,7) = 0; cr(3,7) = 0; iw(3,7) = 0; cw(3,7) = 0; cx(3,7) = 0; is(3,7) = 0; cs(3,7) = 0; crmax(3,7) = 0; buff(3,8) = 0; pw(3,8) = 0; cr(3,8) = 0; iw(3,8) = 0; cw(3,8) = 0; cx(3,8) = 0; is(3,8) = 0; cs(3,8) = 0; crmax(3,8) = 0; cl[3] = 0; cdy[3] = 0; cds[3] = 0; cdl[3] = 0; cisb[3] = 0; caddr[3] = 0; cctrl[3] = 0; cstart[3] = get_rng(0,NCONTEXT-1); creturn[3] = get_rng(0,NCONTEXT-1); // Dumping initializations mem(0+0,0) = 0; mem(0+1,0) = 0; mem(0+2,0) = 0; mem(8+0,0) = 0; mem(3+0,0) = 0; mem(4+0,0) = 0; mem(5+0,0) = 0; mem(6+0,0) = 0; mem(7+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; co(1,0) = 0; delta(1,0) = -1; co(2,0) = 0; delta(2,0) = -1; co(3,0) = 0; delta(3,0) = -1; co(4,0) = 0; delta(4,0) = -1; co(5,0) = 0; delta(5,0) = -1; co(6,0) = 0; delta(6,0) = -1; co(7,0) = 0; delta(7,0) = -1; co(8,0) = 0; delta(8,0) = -1; // Dumping thread 1 int ret_thread_1 = 0; cdy[1] = get_rng(0,NCONTEXT-1); ASSUME(cdy[1] >= cstart[1]); T1BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !37, metadata !DIExpression()), !dbg !46 // br label %label_1, !dbg !47 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !45), !dbg !48 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !38, metadata !DIExpression()), !dbg !49 // call void @llvm.dbg.value(metadata i64 1, metadata !41, metadata !DIExpression()), !dbg !49 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !50 // ST: Guess iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,0)] == 1); ASSUME(active[cw(1,0)] == 1); ASSUME(sforbid(0,cw(1,0))== 0); ASSUME(iw(1,0) >= 0); ASSUME(iw(1,0) >= 0); ASSUME(cw(1,0) >= iw(1,0)); ASSUME(cw(1,0) >= old_cw); ASSUME(cw(1,0) >= cr(1,0)); ASSUME(cw(1,0) >= cl[1]); ASSUME(cw(1,0) >= cisb[1]); ASSUME(cw(1,0) >= cdy[1]); ASSUME(cw(1,0) >= cdl[1]); ASSUME(cw(1,0) >= cds[1]); ASSUME(cw(1,0) >= cctrl[1]); ASSUME(cw(1,0) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,0) = 1; mem(0,cw(1,0)) = 1; co(0,cw(1,0))+=1; delta(0,cw(1,0)) = -1; ASSUME(creturn[1] >= cw(1,0)); // call void (...) @dmbsy(), !dbg !51 // dumbsy: Guess old_cdy = cdy[1]; cdy[1] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[1] >= old_cdy); ASSUME(cdy[1] >= cisb[1]); ASSUME(cdy[1] >= cdl[1]); ASSUME(cdy[1] >= cds[1]); ASSUME(cdy[1] >= cctrl[1]); ASSUME(cdy[1] >= cw(1,0+0)); ASSUME(cdy[1] >= cw(1,0+1)); ASSUME(cdy[1] >= cw(1,0+2)); ASSUME(cdy[1] >= cw(1,8+0)); ASSUME(cdy[1] >= cw(1,3+0)); ASSUME(cdy[1] >= cw(1,4+0)); ASSUME(cdy[1] >= cw(1,5+0)); ASSUME(cdy[1] >= cw(1,6+0)); ASSUME(cdy[1] >= cw(1,7+0)); ASSUME(cdy[1] >= cr(1,0+0)); ASSUME(cdy[1] >= cr(1,0+1)); ASSUME(cdy[1] >= cr(1,0+2)); ASSUME(cdy[1] >= cr(1,8+0)); ASSUME(cdy[1] >= cr(1,3+0)); ASSUME(cdy[1] >= cr(1,4+0)); ASSUME(cdy[1] >= cr(1,5+0)); ASSUME(cdy[1] >= cr(1,6+0)); ASSUME(cdy[1] >= cr(1,7+0)); ASSUME(creturn[1] >= cdy[1]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !42, metadata !DIExpression()), !dbg !52 // call void @llvm.dbg.value(metadata i64 1, metadata !44, metadata !DIExpression()), !dbg !52 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !53 // ST: Guess iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0+1*1); cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,0+1*1)] == 1); ASSUME(active[cw(1,0+1*1)] == 1); ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(cw(1,0+1*1) >= iw(1,0+1*1)); ASSUME(cw(1,0+1*1) >= old_cw); ASSUME(cw(1,0+1*1) >= cr(1,0+1*1)); ASSUME(cw(1,0+1*1) >= cl[1]); ASSUME(cw(1,0+1*1) >= cisb[1]); ASSUME(cw(1,0+1*1) >= cdy[1]); ASSUME(cw(1,0+1*1) >= cdl[1]); ASSUME(cw(1,0+1*1) >= cds[1]); ASSUME(cw(1,0+1*1) >= cctrl[1]); ASSUME(cw(1,0+1*1) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,0+1*1) = 1; mem(0+1*1,cw(1,0+1*1)) = 1; co(0+1*1,cw(1,0+1*1))+=1; delta(0+1*1,cw(1,0+1*1)) = -1; ASSUME(creturn[1] >= cw(1,0+1*1)); // ret i8* null, !dbg !54 ret_thread_1 = (- 1); // Dumping thread 2 int ret_thread_2 = 0; cdy[2] = get_rng(0,NCONTEXT-1); ASSUME(cdy[2] >= cstart[2]); T2BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !57, metadata !DIExpression()), !dbg !71 // br label %label_2, !dbg !53 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !70), !dbg !73 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !60, metadata !DIExpression()), !dbg !74 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !56 // LD: Guess old_cr = cr(2,0+1*1); cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0+1*1)] == 2); ASSUME(cr(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cr(2,0+1*1) >= 0); ASSUME(cr(2,0+1*1) >= cdy[2]); ASSUME(cr(2,0+1*1) >= cisb[2]); ASSUME(cr(2,0+1*1) >= cdl[2]); ASSUME(cr(2,0+1*1) >= cl[2]); // Update creg_r0 = cr(2,0+1*1); crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+1*1) < cw(2,0+1*1)) { r0 = buff(2,0+1*1); } else { if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) { ASSUME(cr(2,0+1*1) >= old_cr); } pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1)); r0 = mem(0+1*1,cr(2,0+1*1)); } ASSUME(creturn[2] >= cr(2,0+1*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !62, metadata !DIExpression()), !dbg !74 // %conv = trunc i64 %0 to i32, !dbg !57 // call void @llvm.dbg.value(metadata i32 %conv, metadata !58, metadata !DIExpression()), !dbg !71 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !63, metadata !DIExpression()), !dbg !77 // call void @llvm.dbg.value(metadata i64 1, metadata !65, metadata !DIExpression()), !dbg !77 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !59 // ST: Guess iw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,0+2*1); cw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,0+2*1)] == 2); ASSUME(active[cw(2,0+2*1)] == 2); ASSUME(sforbid(0+2*1,cw(2,0+2*1))== 0); ASSUME(iw(2,0+2*1) >= 0); ASSUME(iw(2,0+2*1) >= 0); ASSUME(cw(2,0+2*1) >= iw(2,0+2*1)); ASSUME(cw(2,0+2*1) >= old_cw); ASSUME(cw(2,0+2*1) >= cr(2,0+2*1)); ASSUME(cw(2,0+2*1) >= cl[2]); ASSUME(cw(2,0+2*1) >= cisb[2]); ASSUME(cw(2,0+2*1) >= cdy[2]); ASSUME(cw(2,0+2*1) >= cdl[2]); ASSUME(cw(2,0+2*1) >= cds[2]); ASSUME(cw(2,0+2*1) >= cctrl[2]); ASSUME(cw(2,0+2*1) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,0+2*1) = 1; mem(0+2*1,cw(2,0+2*1)) = 1; co(0+2*1,cw(2,0+2*1))+=1; delta(0+2*1,cw(2,0+2*1)) = -1; ASSUME(creturn[2] >= cw(2,0+2*1)); // %cmp = icmp eq i32 %conv, 1, !dbg !60 // %conv1 = zext i1 %cmp to i32, !dbg !60 // call void @llvm.dbg.value(metadata i32 %conv1, metadata !66, metadata !DIExpression()), !dbg !71 // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !67, metadata !DIExpression()), !dbg !80 // %1 = zext i32 %conv1 to i64 // call void @llvm.dbg.value(metadata i64 %1, metadata !69, metadata !DIExpression()), !dbg !80 // store atomic i64 %1, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !62 // ST: Guess iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,3); cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,3)] == 2); ASSUME(active[cw(2,3)] == 2); ASSUME(sforbid(3,cw(2,3))== 0); ASSUME(iw(2,3) >= max(creg_r0,0)); ASSUME(iw(2,3) >= 0); ASSUME(cw(2,3) >= iw(2,3)); ASSUME(cw(2,3) >= old_cw); ASSUME(cw(2,3) >= cr(2,3)); ASSUME(cw(2,3) >= cl[2]); ASSUME(cw(2,3) >= cisb[2]); ASSUME(cw(2,3) >= cdy[2]); ASSUME(cw(2,3) >= cdl[2]); ASSUME(cw(2,3) >= cds[2]); ASSUME(cw(2,3) >= cctrl[2]); ASSUME(cw(2,3) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,3) = (r0==1); mem(3,cw(2,3)) = (r0==1); co(3,cw(2,3))+=1; delta(3,cw(2,3)) = -1; ASSUME(creturn[2] >= cw(2,3)); // ret i8* null, !dbg !63 ret_thread_2 = (- 1); // Dumping thread 3 int ret_thread_3 = 0; cdy[3] = get_rng(0,NCONTEXT-1); ASSUME(cdy[3] >= cstart[3]); T3BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !85, metadata !DIExpression()), !dbg !104 // br label %label_3, !dbg !59 goto T3BLOCK1; T3BLOCK1: // call void @llvm.dbg.label(metadata !102), !dbg !106 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !87, metadata !DIExpression()), !dbg !107 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !62 // LD: Guess old_cr = cr(3,0+2*1); cr(3,0+2*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM // Check ASSUME(active[cr(3,0+2*1)] == 3); ASSUME(cr(3,0+2*1) >= iw(3,0+2*1)); ASSUME(cr(3,0+2*1) >= 0); ASSUME(cr(3,0+2*1) >= cdy[3]); ASSUME(cr(3,0+2*1) >= cisb[3]); ASSUME(cr(3,0+2*1) >= cdl[3]); ASSUME(cr(3,0+2*1) >= cl[3]); // Update creg_r1 = cr(3,0+2*1); crmax(3,0+2*1) = max(crmax(3,0+2*1),cr(3,0+2*1)); caddr[3] = max(caddr[3],0); if(cr(3,0+2*1) < cw(3,0+2*1)) { r1 = buff(3,0+2*1); } else { if(pw(3,0+2*1) != co(0+2*1,cr(3,0+2*1))) { ASSUME(cr(3,0+2*1) >= old_cr); } pw(3,0+2*1) = co(0+2*1,cr(3,0+2*1)); r1 = mem(0+2*1,cr(3,0+2*1)); } ASSUME(creturn[3] >= cr(3,0+2*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !89, metadata !DIExpression()), !dbg !107 // %conv = trunc i64 %0 to i32, !dbg !63 // call void @llvm.dbg.value(metadata i32 %conv, metadata !86, metadata !DIExpression()), !dbg !104 // %tobool = icmp ne i32 %conv, 0, !dbg !64 // br i1 %tobool, label %if.then, label %if.else, !dbg !66 old_cctrl = cctrl[3]; cctrl[3] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[3] >= old_cctrl); ASSUME(cctrl[3] >= creg_r1); ASSUME(cctrl[3] >= 0); if((r1!=0)) { goto T3BLOCK2; } else { goto T3BLOCK3; } T3BLOCK2: // br label %lbl_LC00, !dbg !67 goto T3BLOCK4; T3BLOCK3: // br label %lbl_LC00, !dbg !68 goto T3BLOCK4; T3BLOCK4: // call void @llvm.dbg.label(metadata !103), !dbg !115 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !91, metadata !DIExpression()), !dbg !116 // %1 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !71 // LD: Guess old_cr = cr(3,0); cr(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM // Check ASSUME(active[cr(3,0)] == 3); ASSUME(cr(3,0) >= iw(3,0)); ASSUME(cr(3,0) >= 0); ASSUME(cr(3,0) >= cdy[3]); ASSUME(cr(3,0) >= cisb[3]); ASSUME(cr(3,0) >= cdl[3]); ASSUME(cr(3,0) >= cl[3]); // Update creg_r2 = cr(3,0); crmax(3,0) = max(crmax(3,0),cr(3,0)); caddr[3] = max(caddr[3],0); if(cr(3,0) < cw(3,0)) { r2 = buff(3,0); } else { if(pw(3,0) != co(0,cr(3,0))) { ASSUME(cr(3,0) >= old_cr); } pw(3,0) = co(0,cr(3,0)); r2 = mem(0,cr(3,0)); } ASSUME(creturn[3] >= cr(3,0)); // call void @llvm.dbg.value(metadata i64 %1, metadata !93, metadata !DIExpression()), !dbg !116 // %conv4 = trunc i64 %1 to i32, !dbg !72 // call void @llvm.dbg.value(metadata i32 %conv4, metadata !90, metadata !DIExpression()), !dbg !104 // %cmp = icmp eq i32 %conv, 1, !dbg !73 // %conv5 = zext i1 %cmp to i32, !dbg !73 // call void @llvm.dbg.value(metadata i32 %conv5, metadata !94, metadata !DIExpression()), !dbg !104 // call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !95, metadata !DIExpression()), !dbg !120 // %2 = zext i32 %conv5 to i64 // call void @llvm.dbg.value(metadata i64 %2, metadata !97, metadata !DIExpression()), !dbg !120 // store atomic i64 %2, i64* @atom_2_X0_1 seq_cst, align 8, !dbg !75 // ST: Guess iw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW old_cw = cw(3,4); cw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM // Check ASSUME(active[iw(3,4)] == 3); ASSUME(active[cw(3,4)] == 3); ASSUME(sforbid(4,cw(3,4))== 0); ASSUME(iw(3,4) >= max(creg_r1,0)); ASSUME(iw(3,4) >= 0); ASSUME(cw(3,4) >= iw(3,4)); ASSUME(cw(3,4) >= old_cw); ASSUME(cw(3,4) >= cr(3,4)); ASSUME(cw(3,4) >= cl[3]); ASSUME(cw(3,4) >= cisb[3]); ASSUME(cw(3,4) >= cdy[3]); ASSUME(cw(3,4) >= cdl[3]); ASSUME(cw(3,4) >= cds[3]); ASSUME(cw(3,4) >= cctrl[3]); ASSUME(cw(3,4) >= caddr[3]); // Update caddr[3] = max(caddr[3],0); buff(3,4) = (r1==1); mem(4,cw(3,4)) = (r1==1); co(4,cw(3,4))+=1; delta(4,cw(3,4)) = -1; ASSUME(creturn[3] >= cw(3,4)); // %cmp7 = icmp eq i32 %conv4, 0, !dbg !76 // %conv8 = zext i1 %cmp7 to i32, !dbg !76 // call void @llvm.dbg.value(metadata i32 %conv8, metadata !98, metadata !DIExpression()), !dbg !104 // call void @llvm.dbg.value(metadata i64* @atom_2_X2_0, metadata !99, metadata !DIExpression()), !dbg !123 // %3 = zext i32 %conv8 to i64 // call void @llvm.dbg.value(metadata i64 %3, metadata !101, metadata !DIExpression()), !dbg !123 // store atomic i64 %3, i64* @atom_2_X2_0 seq_cst, align 8, !dbg !78 // ST: Guess iw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW old_cw = cw(3,5); cw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM // Check ASSUME(active[iw(3,5)] == 3); ASSUME(active[cw(3,5)] == 3); ASSUME(sforbid(5,cw(3,5))== 0); ASSUME(iw(3,5) >= max(creg_r2,0)); ASSUME(iw(3,5) >= 0); ASSUME(cw(3,5) >= iw(3,5)); ASSUME(cw(3,5) >= old_cw); ASSUME(cw(3,5) >= cr(3,5)); ASSUME(cw(3,5) >= cl[3]); ASSUME(cw(3,5) >= cisb[3]); ASSUME(cw(3,5) >= cdy[3]); ASSUME(cw(3,5) >= cdl[3]); ASSUME(cw(3,5) >= cds[3]); ASSUME(cw(3,5) >= cctrl[3]); ASSUME(cw(3,5) >= caddr[3]); // Update caddr[3] = max(caddr[3],0); buff(3,5) = (r2==0); mem(5,cw(3,5)) = (r2==0); co(5,cw(3,5))+=1; delta(5,cw(3,5)) = -1; ASSUME(creturn[3] >= cw(3,5)); // ret i8* null, !dbg !79 ret_thread_3 = (- 1); // Dumping thread 0 int ret_thread_0 = 0; cdy[0] = get_rng(0,NCONTEXT-1); ASSUME(cdy[0] >= cstart[0]); T0BLOCK0: // %thr0 = alloca i64, align 8 // %thr1 = alloca i64, align 8 // %thr2 = alloca i64, align 8 // call void @llvm.dbg.value(metadata i32 %argc, metadata !133, metadata !DIExpression()), !dbg !173 // call void @llvm.dbg.value(metadata i8** %argv, metadata !134, metadata !DIExpression()), !dbg !173 // %0 = bitcast i64* %thr0 to i8*, !dbg !83 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !83 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !135, metadata !DIExpression()), !dbg !175 // %1 = bitcast i64* %thr1 to i8*, !dbg !85 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !85 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !139, metadata !DIExpression()), !dbg !177 // %2 = bitcast i64* %thr2 to i8*, !dbg !87 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !87 // call void @llvm.dbg.declare(metadata i64* %thr2, metadata !140, metadata !DIExpression()), !dbg !179 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !141, metadata !DIExpression()), !dbg !180 // call void @llvm.dbg.value(metadata i64 0, metadata !143, metadata !DIExpression()), !dbg !180 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !90 // ST: Guess iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+2*1); cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+2*1)] == 0); ASSUME(active[cw(0,0+2*1)] == 0); ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(cw(0,0+2*1) >= iw(0,0+2*1)); ASSUME(cw(0,0+2*1) >= old_cw); ASSUME(cw(0,0+2*1) >= cr(0,0+2*1)); ASSUME(cw(0,0+2*1) >= cl[0]); ASSUME(cw(0,0+2*1) >= cisb[0]); ASSUME(cw(0,0+2*1) >= cdy[0]); ASSUME(cw(0,0+2*1) >= cdl[0]); ASSUME(cw(0,0+2*1) >= cds[0]); ASSUME(cw(0,0+2*1) >= cctrl[0]); ASSUME(cw(0,0+2*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+2*1) = 0; mem(0+2*1,cw(0,0+2*1)) = 0; co(0+2*1,cw(0,0+2*1))+=1; delta(0+2*1,cw(0,0+2*1)) = -1; ASSUME(creturn[0] >= cw(0,0+2*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !144, metadata !DIExpression()), !dbg !182 // call void @llvm.dbg.value(metadata i64 0, metadata !146, metadata !DIExpression()), !dbg !182 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !92 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+1*1)] == 0); ASSUME(active[cw(0,0+1*1)] == 0); ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(cw(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cw(0,0+1*1) >= old_cw); ASSUME(cw(0,0+1*1) >= cr(0,0+1*1)); ASSUME(cw(0,0+1*1) >= cl[0]); ASSUME(cw(0,0+1*1) >= cisb[0]); ASSUME(cw(0,0+1*1) >= cdy[0]); ASSUME(cw(0,0+1*1) >= cdl[0]); ASSUME(cw(0,0+1*1) >= cds[0]); ASSUME(cw(0,0+1*1) >= cctrl[0]); ASSUME(cw(0,0+1*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+1*1) = 0; mem(0+1*1,cw(0,0+1*1)) = 0; co(0+1*1,cw(0,0+1*1))+=1; delta(0+1*1,cw(0,0+1*1)) = -1; ASSUME(creturn[0] >= cw(0,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !147, metadata !DIExpression()), !dbg !184 // call void @llvm.dbg.value(metadata i64 0, metadata !149, metadata !DIExpression()), !dbg !184 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !94 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0)] == 0); ASSUME(active[cw(0,0)] == 0); ASSUME(sforbid(0,cw(0,0))== 0); ASSUME(iw(0,0) >= 0); ASSUME(iw(0,0) >= 0); ASSUME(cw(0,0) >= iw(0,0)); ASSUME(cw(0,0) >= old_cw); ASSUME(cw(0,0) >= cr(0,0)); ASSUME(cw(0,0) >= cl[0]); ASSUME(cw(0,0) >= cisb[0]); ASSUME(cw(0,0) >= cdy[0]); ASSUME(cw(0,0) >= cdl[0]); ASSUME(cw(0,0) >= cds[0]); ASSUME(cw(0,0) >= cctrl[0]); ASSUME(cw(0,0) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0) = 0; mem(0,cw(0,0)) = 0; co(0,cw(0,0))+=1; delta(0,cw(0,0)) = -1; ASSUME(creturn[0] >= cw(0,0)); // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !150, metadata !DIExpression()), !dbg !186 // call void @llvm.dbg.value(metadata i64 0, metadata !152, metadata !DIExpression()), !dbg !186 // store atomic i64 0, i64* @atom_1_X0_1 monotonic, align 8, !dbg !96 // ST: Guess iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,3); cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,3)] == 0); ASSUME(active[cw(0,3)] == 0); ASSUME(sforbid(3,cw(0,3))== 0); ASSUME(iw(0,3) >= 0); ASSUME(iw(0,3) >= 0); ASSUME(cw(0,3) >= iw(0,3)); ASSUME(cw(0,3) >= old_cw); ASSUME(cw(0,3) >= cr(0,3)); ASSUME(cw(0,3) >= cl[0]); ASSUME(cw(0,3) >= cisb[0]); ASSUME(cw(0,3) >= cdy[0]); ASSUME(cw(0,3) >= cdl[0]); ASSUME(cw(0,3) >= cds[0]); ASSUME(cw(0,3) >= cctrl[0]); ASSUME(cw(0,3) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,3) = 0; mem(3,cw(0,3)) = 0; co(3,cw(0,3))+=1; delta(3,cw(0,3)) = -1; ASSUME(creturn[0] >= cw(0,3)); // call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !153, metadata !DIExpression()), !dbg !188 // call void @llvm.dbg.value(metadata i64 0, metadata !155, metadata !DIExpression()), !dbg !188 // store atomic i64 0, i64* @atom_2_X0_1 monotonic, align 8, !dbg !98 // ST: Guess iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,4); cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,4)] == 0); ASSUME(active[cw(0,4)] == 0); ASSUME(sforbid(4,cw(0,4))== 0); ASSUME(iw(0,4) >= 0); ASSUME(iw(0,4) >= 0); ASSUME(cw(0,4) >= iw(0,4)); ASSUME(cw(0,4) >= old_cw); ASSUME(cw(0,4) >= cr(0,4)); ASSUME(cw(0,4) >= cl[0]); ASSUME(cw(0,4) >= cisb[0]); ASSUME(cw(0,4) >= cdy[0]); ASSUME(cw(0,4) >= cdl[0]); ASSUME(cw(0,4) >= cds[0]); ASSUME(cw(0,4) >= cctrl[0]); ASSUME(cw(0,4) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,4) = 0; mem(4,cw(0,4)) = 0; co(4,cw(0,4))+=1; delta(4,cw(0,4)) = -1; ASSUME(creturn[0] >= cw(0,4)); // call void @llvm.dbg.value(metadata i64* @atom_2_X2_0, metadata !156, metadata !DIExpression()), !dbg !190 // call void @llvm.dbg.value(metadata i64 0, metadata !158, metadata !DIExpression()), !dbg !190 // store atomic i64 0, i64* @atom_2_X2_0 monotonic, align 8, !dbg !100 // ST: Guess iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,5); cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,5)] == 0); ASSUME(active[cw(0,5)] == 0); ASSUME(sforbid(5,cw(0,5))== 0); ASSUME(iw(0,5) >= 0); ASSUME(iw(0,5) >= 0); ASSUME(cw(0,5) >= iw(0,5)); ASSUME(cw(0,5) >= old_cw); ASSUME(cw(0,5) >= cr(0,5)); ASSUME(cw(0,5) >= cl[0]); ASSUME(cw(0,5) >= cisb[0]); ASSUME(cw(0,5) >= cdy[0]); ASSUME(cw(0,5) >= cdl[0]); ASSUME(cw(0,5) >= cds[0]); ASSUME(cw(0,5) >= cctrl[0]); ASSUME(cw(0,5) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,5) = 0; mem(5,cw(0,5)) = 0; co(5,cw(0,5))+=1; delta(5,cw(0,5)) = -1; ASSUME(creturn[0] >= cw(0,5)); // %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !101 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call11 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !102 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %call12 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !103 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[3] >= cdy[0]); // %3 = load i64, i64* %thr0, align 8, !dbg !104, !tbaa !105 // LD: Guess old_cr = cr(0,6); cr(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,6)] == 0); ASSUME(cr(0,6) >= iw(0,6)); ASSUME(cr(0,6) >= 0); ASSUME(cr(0,6) >= cdy[0]); ASSUME(cr(0,6) >= cisb[0]); ASSUME(cr(0,6) >= cdl[0]); ASSUME(cr(0,6) >= cl[0]); // Update creg_r4 = cr(0,6); crmax(0,6) = max(crmax(0,6),cr(0,6)); caddr[0] = max(caddr[0],0); if(cr(0,6) < cw(0,6)) { r4 = buff(0,6); } else { if(pw(0,6) != co(6,cr(0,6))) { ASSUME(cr(0,6) >= old_cr); } pw(0,6) = co(6,cr(0,6)); r4 = mem(6,cr(0,6)); } ASSUME(creturn[0] >= cr(0,6)); // %call13 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !109 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %4 = load i64, i64* %thr1, align 8, !dbg !110, !tbaa !105 // LD: Guess old_cr = cr(0,7); cr(0,7) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,7)] == 0); ASSUME(cr(0,7) >= iw(0,7)); ASSUME(cr(0,7) >= 0); ASSUME(cr(0,7) >= cdy[0]); ASSUME(cr(0,7) >= cisb[0]); ASSUME(cr(0,7) >= cdl[0]); ASSUME(cr(0,7) >= cl[0]); // Update creg_r5 = cr(0,7); crmax(0,7) = max(crmax(0,7),cr(0,7)); caddr[0] = max(caddr[0],0); if(cr(0,7) < cw(0,7)) { r5 = buff(0,7); } else { if(pw(0,7) != co(7,cr(0,7))) { ASSUME(cr(0,7) >= old_cr); } pw(0,7) = co(7,cr(0,7)); r5 = mem(7,cr(0,7)); } ASSUME(creturn[0] >= cr(0,7)); // %call14 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !111 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // %5 = load i64, i64* %thr2, align 8, !dbg !112, !tbaa !105 // LD: Guess old_cr = cr(0,8); cr(0,8) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,8)] == 0); ASSUME(cr(0,8) >= iw(0,8)); ASSUME(cr(0,8) >= 0); ASSUME(cr(0,8) >= cdy[0]); ASSUME(cr(0,8) >= cisb[0]); ASSUME(cr(0,8) >= cdl[0]); ASSUME(cr(0,8) >= cl[0]); // Update creg_r6 = cr(0,8); crmax(0,8) = max(crmax(0,8),cr(0,8)); caddr[0] = max(caddr[0],0); if(cr(0,8) < cw(0,8)) { r6 = buff(0,8); } else { if(pw(0,8) != co(8,cr(0,8))) { ASSUME(cr(0,8) >= old_cr); } pw(0,8) = co(8,cr(0,8)); r6 = mem(8,cr(0,8)); } ASSUME(creturn[0] >= cr(0,8)); // %call15 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !113 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[3]); // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !160, metadata !DIExpression()), !dbg !205 // %6 = load atomic i64, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !115 // LD: Guess old_cr = cr(0,3); cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,3)] == 0); ASSUME(cr(0,3) >= iw(0,3)); ASSUME(cr(0,3) >= 0); ASSUME(cr(0,3) >= cdy[0]); ASSUME(cr(0,3) >= cisb[0]); ASSUME(cr(0,3) >= cdl[0]); ASSUME(cr(0,3) >= cl[0]); // Update creg_r7 = cr(0,3); crmax(0,3) = max(crmax(0,3),cr(0,3)); caddr[0] = max(caddr[0],0); if(cr(0,3) < cw(0,3)) { r7 = buff(0,3); } else { if(pw(0,3) != co(3,cr(0,3))) { ASSUME(cr(0,3) >= old_cr); } pw(0,3) = co(3,cr(0,3)); r7 = mem(3,cr(0,3)); } ASSUME(creturn[0] >= cr(0,3)); // call void @llvm.dbg.value(metadata i64 %6, metadata !162, metadata !DIExpression()), !dbg !205 // %conv = trunc i64 %6 to i32, !dbg !116 // call void @llvm.dbg.value(metadata i32 %conv, metadata !159, metadata !DIExpression()), !dbg !173 // call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !164, metadata !DIExpression()), !dbg !208 // %7 = load atomic i64, i64* @atom_2_X0_1 seq_cst, align 8, !dbg !118 // LD: Guess old_cr = cr(0,4); cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,4)] == 0); ASSUME(cr(0,4) >= iw(0,4)); ASSUME(cr(0,4) >= 0); ASSUME(cr(0,4) >= cdy[0]); ASSUME(cr(0,4) >= cisb[0]); ASSUME(cr(0,4) >= cdl[0]); ASSUME(cr(0,4) >= cl[0]); // Update creg_r8 = cr(0,4); crmax(0,4) = max(crmax(0,4),cr(0,4)); caddr[0] = max(caddr[0],0); if(cr(0,4) < cw(0,4)) { r8 = buff(0,4); } else { if(pw(0,4) != co(4,cr(0,4))) { ASSUME(cr(0,4) >= old_cr); } pw(0,4) = co(4,cr(0,4)); r8 = mem(4,cr(0,4)); } ASSUME(creturn[0] >= cr(0,4)); // call void @llvm.dbg.value(metadata i64 %7, metadata !166, metadata !DIExpression()), !dbg !208 // %conv19 = trunc i64 %7 to i32, !dbg !119 // call void @llvm.dbg.value(metadata i32 %conv19, metadata !163, metadata !DIExpression()), !dbg !173 // call void @llvm.dbg.value(metadata i64* @atom_2_X2_0, metadata !168, metadata !DIExpression()), !dbg !211 // %8 = load atomic i64, i64* @atom_2_X2_0 seq_cst, align 8, !dbg !121 // LD: Guess old_cr = cr(0,5); cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,5)] == 0); ASSUME(cr(0,5) >= iw(0,5)); ASSUME(cr(0,5) >= 0); ASSUME(cr(0,5) >= cdy[0]); ASSUME(cr(0,5) >= cisb[0]); ASSUME(cr(0,5) >= cdl[0]); ASSUME(cr(0,5) >= cl[0]); // Update creg_r9 = cr(0,5); crmax(0,5) = max(crmax(0,5),cr(0,5)); caddr[0] = max(caddr[0],0); if(cr(0,5) < cw(0,5)) { r9 = buff(0,5); } else { if(pw(0,5) != co(5,cr(0,5))) { ASSUME(cr(0,5) >= old_cr); } pw(0,5) = co(5,cr(0,5)); r9 = mem(5,cr(0,5)); } ASSUME(creturn[0] >= cr(0,5)); // call void @llvm.dbg.value(metadata i64 %8, metadata !170, metadata !DIExpression()), !dbg !211 // %conv23 = trunc i64 %8 to i32, !dbg !122 // call void @llvm.dbg.value(metadata i32 %conv23, metadata !167, metadata !DIExpression()), !dbg !173 // %and = and i32 %conv19, %conv23, !dbg !123 creg_r10 = max(creg_r8,creg_r9); ASSUME(active[creg_r10] == 0); r10 = r8 & r9; // call void @llvm.dbg.value(metadata i32 %and, metadata !171, metadata !DIExpression()), !dbg !173 // %and24 = and i32 %conv, %and, !dbg !124 creg_r11 = max(creg_r7,creg_r10); ASSUME(active[creg_r11] == 0); r11 = r7 & r10; // call void @llvm.dbg.value(metadata i32 %and24, metadata !172, metadata !DIExpression()), !dbg !173 // %cmp = icmp eq i32 %and24, 1, !dbg !125 // br i1 %cmp, label %if.then, label %if.end, !dbg !127 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg_r11); ASSUME(cctrl[0] >= 0); if((r11==1)) { goto T0BLOCK1; } else { goto T0BLOCK2; } T0BLOCK1: // call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([104 x i8], [104 x i8]* @.str.1, i64 0, i64 0), i32 noundef 74, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !128 // unreachable, !dbg !128 r12 = 1; T0BLOCK2: // %9 = bitcast i64* %thr2 to i8*, !dbg !131 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !131 // %10 = bitcast i64* %thr1 to i8*, !dbg !131 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !131 // %11 = bitcast i64* %thr0 to i8*, !dbg !131 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #7, !dbg !131 // ret i32 0, !dbg !132 ret_thread_0 = 0; ASSERT(r12== 0); }
[ "tuan-phong.ngo@it.uu.se" ]
tuan-phong.ngo@it.uu.se
7837ee3dad481b3f279d17fa1497053a19968ef5
07fbf3ab32180d94afb1eadd1a8f8ddd657e8656
/NWNXLib/API/Linux/API/CExoArrayListTemplatedCFileInfo.hpp
69f8472d3d01916bd71abe4ba9b74906d63bd0b8
[ "MIT" ]
permissive
ELadner/nwnx-unified
3b322e8722eab70c9c72a45e71013b89dbbf1e89
09f8e8a0c1474e8b16d4746f9cb57ca870a17ce5
refs/heads/master
2021-09-04T08:52:06.521478
2018-01-17T13:04:29
2018-01-17T13:04:29
117,771,934
0
0
null
2018-01-17T02:29:14
2018-01-17T02:29:14
null
UTF-8
C++
false
false
931
hpp
#pragma once #include <cstdint> #include "CFileInfo.hpp" namespace NWNXLib { namespace API { struct CExoArrayListTemplatedCFileInfo { CFileInfo* element; int32_t num; int32_t array_size; // The below are auto generated stubs. CExoArrayListTemplatedCFileInfo() = default; CExoArrayListTemplatedCFileInfo(const CExoArrayListTemplatedCFileInfo&) = default; CExoArrayListTemplatedCFileInfo& operator=(const CExoArrayListTemplatedCFileInfo&) = default; ~CExoArrayListTemplatedCFileInfo(); void Add(CFileInfo); void Allocate(int32_t); }; void CExoArrayListTemplatedCFileInfo__CExoArrayListTemplatedCFileInfoDtor(CExoArrayListTemplatedCFileInfo* thisPtr); void CExoArrayListTemplatedCFileInfo__Add(CExoArrayListTemplatedCFileInfo* thisPtr, CFileInfo); void CExoArrayListTemplatedCFileInfo__Allocate(CExoArrayListTemplatedCFileInfo* thisPtr, int32_t); } }
[ "liarethnwn@gmail.com" ]
liarethnwn@gmail.com
adf1e8d9dc4bf42d38dee8fb8cf1e37ec0f3332b
8c48a060ec96f5d4857d4e08c08f5a44d4163e6e
/tester/OverallTest/cpp/main.cpp
5b09ad811e82a2c8f4ce0019a418838fe4ce21a6
[]
no_license
ccf19881030/JQHttpServer
cd6e50eb74a361241d87e0dc33857ca580a51268
49508b53dea2c65808b2e82cef549441d268484c
refs/heads/master
2022-12-08T09:37:10.363944
2020-09-05T03:53:14
2020-09-05T03:53:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
272
cpp
// Qt lib import #include <QCoreApplication> #include <QtTest> // Project lib import #include "OverallTest.h" int main(int argc, char *argv[]) { QCoreApplication app( argc, argv ); OverallTest benchMark; return QTest::qExec( &benchMark, argc, argv ); }
[ "188080501@qq.com" ]
188080501@qq.com
6c7ebc66296005eab8c9d6352eb790f8ee5ad069
4434644992afc0ced6a255d1701464fb82e19f91
/w_autogyro/lcd_manager.cpp
f833726a09f1d01216717004803ee45950ba7691
[]
no_license
albaniac/Sergey_gyro_mega128_mpu6050_lcd
307d1cd205d71e5d7a8f95f91e4e67e52ced19e4
5284bc287306d2ec693ab4744d7b43ca79a824bb
refs/heads/master
2020-04-10T11:26:34.632573
2017-12-29T13:47:40
2017-12-29T13:47:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,897
cpp
#include "lcd_manager.h" #include <stdio.h> #include <string.h> //======================================================================================= LCDManager::LCDManager(){ }; //======================================================================================= void LCDManager::SetXY (double x, double y){ sprintf(&str_[0][5], "X:%4d", (int)x); sprintf(&str_[1][5], "Y:%4d", (int)y); }; //======================================================================================= void LCDManager::SetLeftFirstWeelVal (double val){ sprintf(&str_[0][0], "%3d", (int)val); str_[0][3] = '%'; }; //======================================================================================= void LCDManager::SetLeftLastWeelVal (double val){ sprintf(&str_[1][0], "%3d", (int)val); str_[1][3] = '%'; }; //======================================================================================= void LCDManager::SetRightFirstWeelVal (double val){ sprintf(&str_[0][12], "%3d", (int)val); str_[0][15] = '%'; }; //======================================================================================= void LCDManager::setRightLastWeelVal (double val){ sprintf(&str_[1][12], "%3d", (int)val); str_[1][15] = '%'; }; //======================================================================================= void LCDManager::SetModeName (const char* mode_name){ is_need_refresh_[2] = true; sprintf(&str_[2][0], "%s*", mode_name); }; //======================================================================================= void LCDManager::ClearModeName (){ memcpy(&str_[2][0], clear_str_, LCD_STR_MAX_LEN); }; //======================================================================================= void LCDManager::SetMenuName (const char* menu_name){ is_need_refresh_[3] = true; sprintf(&str_[3][0], "%s*", menu_name); }; //======================================================================================= void LCDManager::ClearMenuName (){ memcpy(&str_[3][0], clear_str_, LCD_STR_MAX_LEN); }; //======================================================================================= void LCDManager::SetErrorText (const char* err_text){ is_need_refresh_[3] = true; sprintf(&str_[3][0], "%s*", err_text); }; //======================================================================================= void LCDManager::ClearErrorText (){ memcpy(&str_[3][0], clear_str_, LCD_STR_MAX_LEN); } //======================================================================================= void LCDManager::Refresh(){ //LCD_Clear_lcd(); //LCD_Write_String(0, 0, clear_str_); //LCD_Write_String(1, 0, clear_str_); //LCD_Write_String(2, 0, clear_str_); //LCD_Write_String(3, 0, clear_str_); LCDWriteString(0, 0, &str_[0][0]); LCDWriteString(1, 0, &str_[1][0]); if (is_need_refresh_[2]){ LCDWriteString(2, 0, clear_str_); LCDWriteString(2, 0, &str_[2][0]); is_need_refresh_[2] = false; } if (is_need_refresh_[3]){ LCDWriteString(3, 0, clear_str_); LCDWriteString(3, 0, &str_[3][0]); is_need_refresh_[3] = false; } }; //======================================================================================= void LCDManager::Init(){ memcpy(clear_str_ , " *", LCD_STR_MAX_LEN); memcpy(&str_[0][0], "111% X:-179 222%*", LCD_STR_MAX_LEN); memcpy(&str_[1][0], "333% Y:-123 444%*", LCD_STR_MAX_LEN); memcpy(&str_[2][0], " *", LCD_STR_MAX_LEN); memcpy(&str_[3][0], " *", LCD_STR_MAX_LEN); for (unsigned char i = 0; i < LCD_STR_COUNT; i++){ is_need_refresh_[i] = false; } LCDInit(); LCDLigth(LCD_LIGHT_ON); }; //======================================================================================= static LCDManager g_lcd_manager; LCDManager * g_lcd_manager_p = &g_lcd_manager; //=======================================================================================
[ "blobby@radico.ru" ]
blobby@radico.ru
e335cda7e142ddf3a27c1373562afb9606cb75ca
d78b48d71abc96fbd45b51103ecf3e5c36486402
/practicaFinalRedone/TouchGFX/generated/gui_generated/include/gui_generated/common/FrontendApplicationBase.hpp
cf63ad0e2dcd92688856a6ebcea9282f4a004ec4
[]
no_license
Adrian-Rod-Mol/sistemasEmpotrados
c445c80d9490382149cde22dd80ded00faed5b53
9c3475e6a8e99a1186c87020318f9f43fd3adce5
refs/heads/master
2023-05-13T06:36:16.926220
2021-06-09T17:01:28
2021-06-09T17:01:28
374,237,389
0
0
null
null
null
null
UTF-8
C++
false
false
1,184
hpp
/*********************************************************************************/ /********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/ /*********************************************************************************/ #ifndef FRONTENDAPPLICATIONBASE_HPP #define FRONTENDAPPLICATIONBASE_HPP #include <mvp/MVPApplication.hpp> #include <gui/model/Model.hpp> class FrontendHeap; class FrontendApplicationBase : public touchgfx::MVPApplication { public: FrontendApplicationBase(Model& m, FrontendHeap& heap); virtual ~FrontendApplicationBase() { } // MainScreen void gotoMainScreenScreenNoTransition(); void gotoMainScreenScreenWipeTransitionEast(); // ConfScreen void gotoConfScreenScreenWipeTransitionWest(); protected: touchgfx::Callback<FrontendApplicationBase> transitionCallback; FrontendHeap& frontendHeap; Model& model; // MainScreen void gotoMainScreenScreenNoTransitionImpl(); void gotoMainScreenScreenWipeTransitionEastImpl(); // ConfScreen void gotoConfScreenScreenWipeTransitionWestImpl(); }; #endif // FRONTENDAPPLICATIONBASE_HPP
[ "adrian.rod.mol@gmail.com" ]
adrian.rod.mol@gmail.com
322564a6bc4f1db4100e2299b1f95e471a8ccf41
6fe04bf9ced0dade346a4665f791ac64ee8dcb9e
/dbnamelist.h
7e99875d5dc7195042ba7af7ea5987225d789130
[]
no_license
zizle/dbAssistant
29514276c037540080476518944080e4b3fd6527
4ca579d10f1a82c342c3f3c7ba04b438312b0e3f
refs/heads/master
2021-05-23T16:24:35.391962
2020-04-14T15:03:27
2020-04-14T15:03:27
253,380,126
0
0
null
2020-04-14T15:03:28
2020-04-06T02:52:11
null
UTF-8
C++
false
false
327
h
#ifndef DBNAMELIST_H #define DBNAMELIST_H #include <QListWidget> class DBNameList : public QListWidget { Q_OBJECT public: explicit DBNameList(QWidget *parent = nullptr); bool m_IsConnected = false; signals: void nameListActionSignal(QString action, QString dbName); public slots: }; #endif // DBNAMELIST_H
[ "zizle_lin@163.com" ]
zizle_lin@163.com
7c856708503aec1bfe10c12834901d773b249882
10b4ba9e8707576a5b0210da43e6261c7e2f072e
/pat/成绩排名.cpp
9714b5ae1ac315c0d3b7857aa4cdd173e8c8e73e
[]
no_license
liyingfei142118/Document2018
2ec1116cbe61ddfb63144cf06281f0c1b3b1823e
662c5a6a50f5c7b6251027601c6f0a13307dca58
refs/heads/master
2020-07-03T10:31:23.981102
2019-08-12T08:08:34
2019-08-12T08:08:34
201,878,629
1
0
null
null
null
null
GB18030
C++
false
false
1,375
cpp
/*读入n名学生的姓名、学号、成绩,分别输出成绩最高和成绩最低学生的姓名和学号。 输入格式:每个测试输入包含1个测试用例,格式为 第1行:正整数n 第2行:第1个学生的姓名 学号 成绩 第3行:第2个学生的姓名 学号 成绩 ... ... ... 第n+1行:第n个学生的姓名 学号 成绩 其中姓名和学号均为不超过10个字符的字符串,成绩为0到100之间的一个整数, 这里保证在一组测试用例中没有两个学生的成绩是相同的。 输出格式:对每个测试用例输出2行,第1行是成绩最高学生的姓名和学号, 第2行是成绩最低学生的姓名和学号,字符串间有1空格。 输入样例: 3 Joe Math990112 89 Mike CS991301 100 Mary EE990830 95 输出样例: Mike CS991301 Joe Math990112 */ #include<iostream> using namespace std; typedef struct { char name[11]; char ID[11]; int grad; }student; int main() { int n; cin>>n; student stu[n+1]; int max=0,m,min=100,n1; for(int i=1;i<=n;i++) { cin>>stu[i].name; cin>>stu[i].ID; cin>>stu[i].grad; if(stu[i].grad>max) { max=stu[i].grad; m=i; } if(stu[i].grad<min) { min=stu[i].grad; n1=i; } } cout<<stu[m].name<<" "<<stu[m].ID<<endl; cout<<stu[n1].name<<" "<<stu[n1].ID<<endl; }
[ "liyingfei103@jobmail.vip" ]
liyingfei103@jobmail.vip
ec09b5e90c55664f190a29f17fa93e67396b7b1d
3850eac3882e8753be5f8d2d33bbc45f261141ab
/linked_list/linked_list_matrix.cpp
b41f5709f6e51cce36f12c00033a26695274f5d9
[]
no_license
ankitkumarsamota121/geeksforgeeks_practice
0f2ab48bc76dceadc465ad8bf588a70db053f83c
27cbca1d44e2e6105ae8729ab9f4ea1b4a97d13c
refs/heads/master
2023-02-07T14:58:37.107833
2021-01-03T11:55:47
2021-01-03T11:55:47
255,017,249
0
0
null
null
null
null
UTF-8
C++
false
false
2,257
cpp
// { Driver Code Starts #include <bits/stdc++.h> #define MAX 20 using namespace std; struct Node { int data; Node *right, *down; Node(int x) { data = x; right = NULL; down = NULL; } }; void display(Node *head) { Node *Rp; Node *Dp = head; while (Dp) { Rp = Dp; while (Rp) { cout << Rp->data << " "; Rp = Rp->right; } Dp = Dp->down; } } Node *constructLinkedMatrix(int mat[MAX][MAX], int n); // driver program int main() { int t; cin >> t; while (t--) { int n; cin >> n; int mat[MAX][MAX]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> mat[i][j]; Node *head = constructLinkedMatrix(mat, n); if (!head) cout << "-1"; else display(head); cout << "\n"; } return 0; } // } Driver Code Ends /*structure of the node of the linked list is as struct Node { int data; Node* right, *down; Node(int x){ data = x; right = NULL; down = NULL; } }; */ // n is the size of the matrix // function must return the pointer to the first element // of the in linked list i.e. that should be the element at arr[0][0] Node *constructLinkedMatrix(int mat[MAX][MAX], int n) { // code here Node *head = NULL; Node *p = NULL; Node *q = NULL; Node *start = NULL; Node *t = NULL; for (int row = 0; row < n; ++row){ q = start; for (int col = 0; col < n; ++col){ t = new Node(mat[row][col]); if (head == NULL){ head = t; p = head; start = head; } else if (col == 0){ p = t; if (q){ q->down = t; q = q->right; } } else { p->right = t; p = p->right; if (q){ q->down = t; q = q->right; } } } p = NULL; q = start; if (start->down) start = start->down; } return head; }
[ "ankitkumarsamota121@gmail.com" ]
ankitkumarsamota121@gmail.com
c8af3c3dc9c493a90ba672bab02585a0dd79e042
564a1c1bd548a080a07ca16a96ff2e0521de46c0
/tests/src/pressed_keys_manager/src/pressed_keys_manager_test.cpp
cd119a65cdd6eff698306bf851fc99f9ff82ecb3
[ "Unlicense" ]
permissive
lianyu125/Karabiner-Elements
645aa142aeab2927180ff4101df9d4c83e0ba944
e65ccbe26b4bc847d61888ff6aa33bcc78ac8e89
refs/heads/master
2023-01-19T06:36:54.849723
2020-11-26T23:49:16
2020-11-26T23:49:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,922
cpp
#include <catch2/catch.hpp> #include "pressed_keys_manager.hpp" TEST_CASE("pressed_keys_manager") { // empty { krbn::pressed_keys_manager manager; REQUIRE(manager.empty()); } // key_code { krbn::pressed_keys_manager manager; manager.insert(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::keyboard_or_keypad, pqrs::hid::usage::keyboard_or_keypad::keyboard_a))); REQUIRE(!manager.empty()); manager.erase(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::keyboard_or_keypad, pqrs::hid::usage::keyboard_or_keypad::keyboard_a))); REQUIRE(manager.empty()); } // Duplicated key_code { krbn::pressed_keys_manager manager; manager.insert(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::keyboard_or_keypad, pqrs::hid::usage::keyboard_or_keypad::keyboard_a))); manager.insert(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::keyboard_or_keypad, pqrs::hid::usage::keyboard_or_keypad::keyboard_a))); REQUIRE(!manager.empty()); manager.erase(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::keyboard_or_keypad, pqrs::hid::usage::keyboard_or_keypad::keyboard_a))); REQUIRE(manager.empty()); } // consumer_key_code { krbn::pressed_keys_manager manager; manager.insert(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::consumer, pqrs::hid::usage::consumer::mute))); REQUIRE(!manager.empty()); manager.erase(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::consumer, pqrs::hid::usage::consumer::mute))); REQUIRE(manager.empty()); } // pointing_button { krbn::pressed_keys_manager manager; manager.insert(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::button, pqrs::hid::usage::button::button_1))); REQUIRE(!manager.empty()); manager.erase(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::button, pqrs::hid::usage::button::button_1))); REQUIRE(manager.empty()); } // combination { krbn::pressed_keys_manager manager; manager.insert(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::keyboard_or_keypad, pqrs::hid::usage::keyboard_or_keypad::keyboard_a))); REQUIRE(!manager.empty()); manager.insert(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::keyboard_or_keypad, pqrs::hid::usage::keyboard_or_keypad::keyboard_a))); REQUIRE(!manager.empty()); manager.insert(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::consumer, pqrs::hid::usage::consumer::mute))); REQUIRE(!manager.empty()); manager.insert(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::button, pqrs::hid::usage::button::button_1))); REQUIRE(!manager.empty()); manager.erase(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::keyboard_or_keypad, pqrs::hid::usage::keyboard_or_keypad::keyboard_a))); REQUIRE(!manager.empty()); manager.erase(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::consumer, pqrs::hid::usage::consumer::mute))); REQUIRE(!manager.empty()); manager.erase(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::button, pqrs::hid::usage::button::button_10))); REQUIRE(!manager.empty()); manager.erase(krbn::momentary_switch_event(pqrs::hid::usage_pair( pqrs::hid::usage_page::button, pqrs::hid::usage::button::button_1))); REQUIRE(manager.empty()); } }
[ "tekezo@pqrs.org" ]
tekezo@pqrs.org
7272179785d922b36366316ff38297b3d9f3e6a6
6d41a2bdaad0bf0399466417a2270fc73147c153
/programs in April/0421/校门外的树/校门外的树/校门外的树.cpp
8c9eb1bb3686600229ac0f3fa5d0f17e66d04d98
[]
no_license
yuheng95/CPP_Project
b0c7aaf4af24ac158e0ab931f274ccb957e0850d
5d5630bc21bc6d65e7b0e8dfbf6cf6e17ccfcecf
refs/heads/master
2021-07-05T19:41:08.813794
2017-09-30T18:23:24
2017-09-30T18:23:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
411
cpp
#include <iostream>; using namespace std; int main() { int L, M = 0; int a[10001]; int sum = 0; cin >> L >> M; for (int i = 0; i <= L; i++) { a[i] = 1; } for (int p = 1; p <= M; p++) { int start = 0; int end = 0; cin >> start >> end; for (int j = start; j <= end; j++) { a[j] = 0; } } for (int i = 0; i <= L; i++) { if (a[i] == 1) { sum++; } } cout << sum << endl; return 0; };
[ "aqwmx11@pku.edu.cn" ]
aqwmx11@pku.edu.cn
6042e76ba3b1e9c11658256d013f9897f6a2b028
d850e50d2cb97b85c524802201efb624889fe132
/a095.cpp
af825e6fbf2642d8f257c077ff6fce1cdb1ac8fa
[]
no_license
rosynirvana/ZeroJudge
347e8bd5b18adb20d8c39efa700056696c720f6c
c48e7daf99da3f8c5928d20b51510c4ddbdea161
refs/heads/master
2021-01-21T22:29:10.608134
2013-09-04T12:38:12
2013-09-04T12:38:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
176
cpp
#include <iostream> int main() { int N, M; while(std::cin >> N){ std::cin >> M; if(M != N) std::cout << M+1 << "\n"; else std::cout << M << "\n"; } return 0; }
[ "kongchuijin@gmail.com" ]
kongchuijin@gmail.com
e08c9eb25af2e62a661b50b1bc8e79264e1d765e
10ef710dda5acd5206be8ca0f0d6bf7f1c8075b7
/Segundo cuatrimestre/8A - Duplicar una lista y mas/listaDuplica.h
d060b7de9eba30ef7cb3063fe10baaf2a2aa9a1e
[]
no_license
imartin28/EDA
0aee47a11c148a7e7a2742e3498c317229f45d49
f989f0e96ced60dfb3514b60e33767519481ab3b
refs/heads/master
2020-08-02T06:41:38.426057
2019-09-27T08:01:59
2019-09-27T08:01:59
211,266,446
0
0
null
null
null
null
UTF-8
C++
false
false
1,680
h
// // lista_duplica.h // EDA_2 // // Created by Irene Martin berlanga on 15/02/2019. // Copyright © 2019 Irene Martin berlanga. All rights reserved. // #ifndef lista_duplica_h #define lista_duplica_h #include <iostream> #include <iomanip> #include <fstream> #include "queue_eda.h" template <class T> class listaDuplica : public queue<T> { using Nodo = typename queue<T>::Nodo; // para poder usar Nodo aquí public: void print(std::ostream & o = std::cout) const { if(!this->empty()) { Nodo *actual = this->prim; while(actual->sig != nullptr) { o << actual->elem; o << " "; actual = actual->sig; } o << actual->elem; } } // Duplicar los nodos de una lista enlazada simple void duplica() { if(!this->empty()){ Nodo *nodo_actual = this->prim; Nodo *nodo_nuevo = nullptr; while(nodo_actual != nullptr){ nodo_nuevo = new Nodo(nodo_actual->elem, nodo_actual->sig); nodo_actual->sig = nodo_nuevo; // this->prim = nodo_nuevo; nodo_actual = nodo_nuevo->sig; // nodo_nuevo->sig = nodo_actual->sig; ++this->nelems; } this->ult = nodo_nuevo; } } }; template <class T> inline std::ostream & operator<<(std::ostream & out, listaDuplica<T> const& lista) { lista.print(out); return out; } #endif /* lista_duplica_h */
[ "imart02@ucm.es" ]
imart02@ucm.es
f3304244e588c20c1a41348dec3ea815903f8c47
b4925f354c0236406d07cdab4e47667f12f58067
/distribuidos/VisualizadordeInterfaces/SocketDatagrama.cpp
75fe0e82a65cba0b237977171ec5968562791e57
[ "MIT" ]
permissive
MauricioCerv10/schoolhistory
93be0e0adc57a79e5feea4665cac92d925edd9d8
7e5ef296909cc1e6daa54846e595b299e4be4e6e
refs/heads/master
2023-07-01T16:14:25.918824
2021-07-30T03:12:15
2021-07-30T03:12:15
390,902,375
0
0
null
null
null
null
UTF-8
C++
false
false
1,526
cpp
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <strings.h> #include <stdio.h> #include <stdlib.h> #include <arpa/inet.h> #include <unistd.h> #include <string.h> #include "SocketDatagrama.h" #include "PaqueteDatagrama.h" using namespace std; SocketDatagrama::SocketDatagrama(int a){ s=socket(AF_INET, SOCK_DGRAM, a); bzero((char *)&direccionLocal, sizeof(direccionLocal)); direccionLocal.sin_family = AF_INET; direccionLocal.sin_addr.s_addr = INADDR_ANY; direccionLocal.sin_port = htons(7200); bind(s, (struct sockaddr *)&direccionLocal, sizeof(direccionLocal)); bzero((char *)&direccionForanea, sizeof(direccionForanea)); direccionForanea.sin_family = AF_INET; } SocketDatagrama::~SocketDatagrama(){ close(s); } int SocketDatagrama::recibe(PaqueteDatagrama &p){ char dat[p.obtieneLongitud()]; unsigned int clileng = sizeof(direccionForanea); recvfrom(s, dat, p.obtieneLongitud()*sizeof(char), 0, (struct sockaddr *) &direccionForanea, &clileng); p.inicializaDatos(dat); char str[16]; inet_ntop(AF_INET, &direccionForanea.sin_addr.s_addr, str, 16); p.inicializaIp(str); p.inicializaPuerto(direccionForanea.sin_port); return 0; } int SocketDatagrama::envia(PaqueteDatagrama &p){ inet_pton(AF_INET, p.obtieneDireccion(), &direccionForanea.sin_addr); direccionForanea.sin_port = htons(p.obtienePuerto()); sendto(s, p.obtieneDatos(), p.obtieneLongitud() * sizeof(char), 0, (struct sockaddr *) &direccionForanea, sizeof(direccionForanea)); return 0; }
[ "mauriciocervantesdelgadillo10@gmail.com" ]
mauriciocervantesdelgadillo10@gmail.com
d16c73c25ed72c5d8b723bcfe281629015944900
1754c9ca732121677ac6a9637db31419d32dbcf1
/dependencies/libsbml-vs2017-release-32/include/sbml/validator/OverdeterminedValidator.h
8a965fee5242fbffa7e5ebbaa8e6ecb848cf7d14
[ "BSD-2-Clause" ]
permissive
sys-bio/Libstructural
1701e239e3f4f64674b86e9e1053e9c61fe868a7
fb698bcaeaef95f0d07c010f80c84d2cb6e93793
refs/heads/master
2021-09-14T17:54:17.538528
2018-05-16T21:12:24
2018-05-16T21:12:24
114,693,721
3
1
null
2017-12-18T22:25:11
2017-12-18T22:25:10
null
UTF-8
C++
false
false
2,257
h
/** * @cond doxygenLibsbmlInternal * * @file OverdeterminedValidator.h * @brief Performs consistency checks on an SBML model * @author Sarah Keating * * <!-------------------------------------------------------------------------- * This file is part of libSBML. Please visit http://sbml.org for more * information about SBML, and the latest version of libSBML. * * Copyright (C) 2013-2017 jointly by the following organizations: * 1. California Institute of Technology, Pasadena, CA, USA * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK * 3. University of Heidelberg, Heidelberg, Germany * * Copyright (C) 2009-2013 jointly by the following organizations: * 1. California Institute of Technology, Pasadena, CA, USA * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK * * Copyright (C) 2006-2008 by the California Institute of Technology, * Pasadena, CA, USA * * Copyright (C) 2002-2005 jointly by the following organizations: * 1. California Institute of Technology, Pasadena, CA, USA * 2. Japan Science and Technology Agency, Japan * * 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. A copy of the license agreement is provided * in the file named "LICENSE.txt" included with this software distribution and * also available online as http://sbml.org/software/libsbml/license.html * ---------------------------------------------------------------------- -->*/ #ifndef OverdeterminedValidator_h #define OverdeterminedValidator_h #ifdef __cplusplus #include <sbml/validator/Validator.h> #include <sbml/SBMLError.h> LIBSBML_CPP_NAMESPACE_BEGIN class OverdeterminedValidator: public Validator { public: OverdeterminedValidator () : Validator( LIBSBML_CAT_OVERDETERMINED_MODEL ) { } virtual ~OverdeterminedValidator () { } /** * Initializes this Validator with a set of Constraints. */ virtual void init (); }; LIBSBML_CPP_NAMESPACE_END #endif /* __cplusplus */ #endif /* OverdeterminedValidator_h */ /** @endcond */
[ "yosefmaru@gmail.com" ]
yosefmaru@gmail.com
c9fae1c2a7046fc83d281dde707d1dae7d45dbf9
7174bbeaf7729dda4e529fb47a374cd959e91c05
/Ticket-Seller/Transakcja.h
8aea33c1c60dbd7a9027e72a0ac729dde2ddb832
[]
no_license
bk44271/Ticketseller
77fd2a9c2ed357ec9c50c3ad7c00ad20b649de72
a22dbc10e378619ad4831bcb5181a4c43e8c006a
refs/heads/master
2022-10-18T03:15:54.242246
2020-06-15T08:43:15
2020-06-15T08:43:15
262,981,266
0
0
null
null
null
null
UTF-8
C++
false
false
423
h
#include <vector> using namespace std; #ifndef __Transakcja_h__ #define __Transakcja_h__ // #include "buyer.h" // #include "seller.h" #include "bilet.h" class buyer; class seller; class bilet; class Transakcja; class Transakcja { private: int _iD; private: string _data_tran; public: buyer* _unnamed_buyer_; public: seller* _unnamed_seller_; public: std::vector<bilet*> _bilet; }; #endif
[ "noreply@github.com" ]
bk44271.noreply@github.com
0dd7e9f882b8a7bf3ebb6cbadae295070e560d55
80bee850d1197772d61e05d8febc014e9980d7c0
/Addons/MostWanted/MostWanted_Client/Notifications.hpp
f3de98f67f3b232f5bdff8face5cd591b28655f8
[ "MIT" ]
permissive
x-cessive/Exile
0443bb201bda31201fadc9c0ac80823fb2d7a25d
c5d1f679879a183549e1c87d078d462cbba32c25
refs/heads/master
2021-11-29T08:40:00.286597
2021-11-14T17:36:51
2021-11-14T17:36:51
82,304,207
10
8
null
2017-04-11T14:44:21
2017-02-17T14:20:22
SQF
UTF-8
C++
false
false
1,248
hpp
class MostWanted { displayName = "MostWanted"; class NewBounty { displayName = "New Bounty"; description = "%3INMATES!%4%1A perspective client has set a bounty on a fellow inmate.%1The client is offering <t color='#ff0000'>%11</t> poptabs for their head.%1Your local Office Trader has the details and the contract if you choose to accept it."; image = ""; noImage = true; tip = ""; arguments[] = { "MostWanted_BountyAmount" }; }; class SuccessfulKill { displayName = "Kill Confirmed"; description = "%3Ouch! That looked like that hurt.%4%1You have successfully completed your bounty contract.%1Talk to your local Office Trader to collect your bounty of <t color='#ff0000'>%11</t>."; image = ""; noImage = true; tip = ""; arguments[] = { "MostWanted_SuccessfulKill" }; }; class BountyClaimed { displayName = "Bounty Claimed"; description = "%3Bounty Claimed!%4%1One very lucky inmate has claimed the bounty on <t color='#ff0000'>%11</t>.%1Contracts on this inmate have been cleared!%1Please visit your local Office Trader to get another contract."; image = ""; noImage = true; tip = ""; arguments[] = { "MostWanted_BountyName" }; }; };
[ "mrsage@xcsv.tv" ]
mrsage@xcsv.tv
795674d1fbc85a65e3222945bf988ba5f7a7e09b
66330f7a1ff0b8447b4245474ab4de48727fd1c5
/libs/multiprecision/plots/cpp_bin_float_tgamma_errors.cpp
5e3dd11051ab81908028e9c1a12059142a4a9191
[ "MIT" ]
permissive
everscalecodes/knapsack-snark
fd3cc6155125ae6ff0fc56aa979f84ba6a8c49c7
633515a13906407338a81b9874d964869ddec624
refs/heads/main
2023-07-18T06:05:22.319230
2021-08-31T16:10:16
2021-08-31T16:10:16
447,180,824
0
1
MIT
2022-01-12T10:53:21
2022-01-12T10:53:20
null
UTF-8
C++
false
false
2,044
cpp
// (C) Copyright Nick Thompson 2020. // (C) Copyright John Maddock 2020. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <iostream> #include <boost/math/tools/ulps_plot.hpp> #include <boost/core/demangle.hpp> #include <nil/crypto3/multiprecision/mpfr.hpp> #include <nil/crypto3/multiprecision/cpp_bin_float.hpp> using boost::math::tools::ulps_plot; int main() { using PreciseReal = nil::crypto3::multiprecision::mpfr_float_100; using CoarseReal = nil::crypto3::multiprecision::cpp_bin_float_50; typedef boost::math::policies::policy< boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false> > no_promote_policy; auto ai_coarse = [](CoarseReal const& x)->CoarseReal { return tgamma(x); }; auto ai_precise = [](PreciseReal const& x)->PreciseReal { return tgamma(x); }; std::string filename = "cpp_bin_float_tgamma.svg"; int samples = 100000; // How many pixels wide do you want your .svg? int width = 700; // Near a root, we have unbounded relative error. So for functions with roots, we define an ULP clip: PreciseReal clip = 400; // Should we perturb the abscissas? bool perturb_abscissas = false; auto plot = ulps_plot<decltype(ai_precise), PreciseReal, CoarseReal>(ai_precise, CoarseReal(-20), CoarseReal(200), samples, perturb_abscissas); // Note the argument chaining: plot.clip(clip).width(width); plot.background_color("white").font_color("black"); // Sometimes it's useful to set a title, but in many cases it's more useful to just use a caption. //std::string title = "Airy Ai ULP plot at " + boost::core::demangle(typeid(CoarseReal).name()) + " precision"; //plot.title(title); plot.vertical_lines(6); plot.add_fn(ai_coarse); // You can write the plot to a stream: //std::cout << plot; // Or to a file: plot.write(filename); }
[ "curryrasul@gmail.com" ]
curryrasul@gmail.com
4453a277bdf96bebd35d6c10b85c6df1a42f075a
d52399169d3ce1ca274583241ed471fcac857ec9
/OS/labs/lab12/os12COM/lab12/lab12/CFactory.h
9bf083a713ffb6b9e29b57045799236337a2a0cb
[]
no_license
sshkodunishka/thirdCourse2Sem
bc7d7af3b8376aa0265a926041d1765c9173cd78
0eb3bb66af0e7ccc24c82a616167f08803ea3c2e
refs/heads/main
2023-05-06T18:36:05.330071
2021-06-03T05:06:08
2021-06-03T05:06:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
461
h
#pragma once #include <objbase.h> class CFactory : public IClassFactory { public : virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppv); virtual ULONG STDMETHODCALLTYPE AddRef(void); virtual ULONG STDMETHODCALLTYPE Release(void); virtual HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUO, const IID& id, void** ppv); virtual HRESULT STDMETHODCALLTYPE LockServer(BOOL b); CFactory(); ~CFactory(); private: ULONG m_Ref; };
[ "anton.borisov.17@mail.ru" ]
anton.borisov.17@mail.ru
c6dff43645cc65834c5dc8efe17ce64c45a7c237
e9e33cbc5e0c5fe037c6e72d59190e20987e0f28
/templates/codeforces.cpp
4dcc48c3b2a2daa19f75b9d9c1743da7a4437b52
[]
no_license
DakshinD/Competitive-Programming
ae7f952ac382820c0687a6cbdf23b0990e25a40e
03fbf8d06a59d121780b667897131cb25484930a
refs/heads/master
2021-05-21T04:56:29.271648
2020-12-18T16:34:26
2020-12-18T16:34:26
252,552,732
1
0
null
null
null
null
UTF-8
C++
false
false
2,455
cpp
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef priority_queue<int> pq; typedef priority_queue<int, vi, greater<int>> mpq; const ll INF = 1e18; const ll NINF = -1e18; const int inf = 1e9+5; const int ninf = -(1e9+5); const int mod = 1e9+7; const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; #define whatis(x) cerr << #x << " is " << x << endl; #define dbg(x, n) for(int i = 0; i < n; i++) cerr << x[i] << " ";cout << endl; #define yes() cout << "YES" << endl; #define no() cout << "NO" << endl; #define here() cout << "here" << endl; #define endl "\n" #define f first #define s second #define pb push_back #define eb emplace_back #define mp make_pair #define ft front() #define bk back() #define sz(x) (long long)x.size() #define all(x) (x).begin(), (x).end() #define ub upper_bound #define lb lower_bound #define trav(a, x) for(auto a : x) #define travto(a, x) for(auto& a : x) #define FOR(i, a, b) for(int i = a; i < b; i++) #define FoR(i, a, b) for(int i = a; i <= b; i++) #define ROF(i, a, b) for (int i = a-1; i >= b; i--) #define RoF(i, a, b) for (int i = a-1; i > b; i--) #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); } int rup(int a, int b){return (a+b-1)/b;} template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); } //-----------------------| Template By: DakDak |---------------------------- int main(){ return 0; // Read notes to self } /* NOTES TO SELF: * See if the restrictions can hint at a solution! * Check for int vs ll, worst case just switch everything to ll * Check for array bounds if you SEGFAULT, especially in range based loops * Always initialize everything in global * Edge cases such as n = 1 or 0 * Make sure to calculate big O complexity * You are geniosity you got this */
[ "noreply@github.com" ]
DakshinD.noreply@github.com
01106bff80159e1d5a09fd11d3b2fe330c760509
da8fc6a09a690cf111a1d88e9f5a2d749b81af27
/StoneSword/src/StoneSword/Events/ApplicationEvent.h
98d5beeb504d263ef56d2ba8f9a57eb42c4a689c
[ "Apache-2.0" ]
permissive
qqqcode/StoneSword
0864b5b0016538805581e37e553edc21192ca1f8
0d6217b934508196327d3bd001b42f20d8ea9c7f
refs/heads/master
2023-03-01T18:04:05.241472
2021-02-01T16:53:26
2021-02-01T16:53:26
325,945,127
0
0
null
null
null
null
UTF-8
C++
false
false
1,340
h
#pragma once #include "Event.h" namespace StoneSword { class STONESWORD_API WindowResizeEvent : public Event { public: WindowResizeEvent(unsigned int width, unsigned int height) : m_Width(width), m_Height(height) {} unsigned int GetWidth() const { return m_Width; } unsigned int GetHeight() const { return m_Height; } std::string ToString() const override { std::stringstream ss; ss << "WindowResizeEvent: " << m_Width << ", " << m_Height; return ss.str(); } EVENT_CLASS_TYPE(WindowResize) EVENT_CLASS_CATEGORY(EventCategoryApplication) private: unsigned int m_Width, m_Height; }; class STONESWORD_API WindowCloseEvent : public Event { public: WindowCloseEvent() = default; EVENT_CLASS_TYPE(WindowClose) EVENT_CLASS_CATEGORY(EventCategoryApplication) }; class STONESWORD_API AppTickEvent : public Event { public: AppTickEvent() = default; EVENT_CLASS_TYPE(AppTick) EVENT_CLASS_CATEGORY(EventCategoryApplication) }; class STONESWORD_API AppUpdateEvent : public Event { public: AppUpdateEvent() = default; EVENT_CLASS_TYPE(AppUpdate) EVENT_CLASS_CATEGORY(EventCategoryApplication) }; class STONESWORD_API AppRenderEvent : public Event { public: AppRenderEvent() = default; EVENT_CLASS_TYPE(AppRender) EVENT_CLASS_CATEGORY(EventCategoryApplication) }; }
[ "1278323354@qq.com" ]
1278323354@qq.com
d28903d2fd712f64bec3d7a33765e3799a3513bf
d324dafd7b383d1fccac2e6f954d2c35264d84d8
/multigpu_graphics_attila/src/trace/ACD/Implementation/ACDTexture3DImp.h
f21ec86142a602dfd6e55409b70c45e13349d39c
[ "BSD-3-Clause", "BSD-2-Clause-Views", "MIT" ]
permissive
flair2005/Scalable-Multi-GPU-Rendering
847efbaddd7c091c7bea20ebec1f22fcd5d80022
1fe0fa74cee5891424db73654551335a7fd5380c
refs/heads/main
2023-02-06T07:57:02.429875
2020-12-29T01:06:10
2020-12-29T01:06:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,426
h
/************************************************************************** * * Copyright (c) 2002 - 2011 by Computer Architecture Department, * Universitat Politecnica de Catalunya. * All rights reserved. * * The contents of this file may not be disclosed to third parties, * copied or duplicated in any form, in whole or in part, without the * prior permission of the authors, Computer Architecture Department * and Universitat Politecnica de Catalunya. * */ #ifndef ACD_TEXTURE3D_IMP #define ACD_TEXTURE3D_IMP #include "ACDTexture3D.h" #include "TextureMipmapChain.h" #include "TextureMipmap.h" #include "MemoryObject.h" #include <set> namespace acdlib { class ACDTexture3DImp : public ACDTexture3D, public MemoryObject { public: ACDTexture3DImp(); /// Methods inherited from ACDResource interface virtual void setUsage(ACD_USAGE usage); virtual ACD_USAGE getUsage() const; virtual void setMemoryLayout(ACD_MEMORY_LAYOUT layout); virtual ACD_MEMORY_LAYOUT getMemoryLayout() const; virtual ACD_RESOURCE_TYPE getType() const; virtual void setPriority(acd_uint prio); virtual acd_uint getPriority() const; virtual acd_uint getSubresources() const; virtual acd_bool wellDefined() const; /// Methods inherited form ACDTexture interface virtual acd_uint getBaseLevel() const; virtual acd_uint getMaxLevel() const; virtual void setBaseLevel(acd_uint minMipLevel); virtual void setMaxLevel(acd_uint maxMipLevel); virtual acd_uint getSettedMipmaps(); /// Methods inherited from ACDTexture2D interface virtual acd_uint getWidth(acd_uint mipmap) const; virtual acd_uint getHeight(acd_uint mipmap) const; virtual acd_uint getDepth(acd_uint mipLevel) const; virtual ACD_FORMAT getFormat(acd_uint mipmap) const; virtual acd_bool isMultisampled(acd_uint mipmap) const; virtual acd_uint getSamples(acd_uint mipmap) const; virtual acd_uint getTexelSize(acd_uint mipmap) const; virtual void setData( acd_uint mipLevel, acd_uint width, acd_uint height, acd_uint depth, ACD_FORMAT format, acd_uint rowPitch, const acd_ubyte* srcTexelData, acd_uint texSize, acd_bool preloadData = false); virtual void setData(acd_uint mipLevel, acd_uint width, acd_uint height, acd_uint depth, acd_bool multisampling, acd_uint samples, ACD_FORMAT format); virtual void updateData( acd_uint mipLevel, acd_uint x, acd_uint y, acd_uint z, acd_uint width, acd_uint height, acd_uint depth, ACD_FORMAT format, acd_uint rowPitch, const acd_ubyte* srcTexelData, acd_bool preloadData = false); virtual acd_bool map( acd_uint mipLevel, ACD_MAP mapType, acd_ubyte*& pData, acd_uint& dataRowPitch, acd_uint& dataPlanePitch); virtual acd_bool unmap(acd_uint mipLevel, acd_bool preloadData = false); /// Method required by MemoryObject derived classes virtual const acd_ubyte* memoryData(acd_uint region, acd_uint& memorySizeInBytes) const; virtual const acd_char* stringType() const; void dumpMipmap(acd_uint region, acd_ubyte* mipName); const acd_ubyte* getData(acd_uint mipLevel, acd_uint& memorySizeInBytes, acd_uint& rowPitch, acd_uint& planePitch) const; virtual void setSamplerID(acd_int id) { samplerID = id; } virtual acd_int getSamplerID() const { return samplerID; } private: const TextureMipmap* _getMipmap(acd_uint mipLevel, const acd_char* methodStr) const; acd_uint _baseLevel; acd_uint _maxLevel; TextureMipmapChain _mips; std::set<acd_uint> _mappedMips; ACD_MEMORY_LAYOUT layout; acd_int samplerID; }; // class ACDTexture3DImp } #endif // ACD_TEXTURE3D_IMP
[ "renxiaowei66@gmail.com" ]
renxiaowei66@gmail.com
4b0998ab7bbe1b25038d28cae141b8b6ee204a93
c27e82cde645bb5bb33c0c2c5f418dc3ba7a491c
/src/shell/command_parser/structures/OutAppend.cpp
214edb500e8161b5327fb67600f4d7773d5f1de0
[]
no_license
pik694/UXP1A_shell
8729cb28507dc5f9a0029226b44b10b0519b821d
f6efd8d1cd3ebc8f0e85505da429c4c63566d9ff
refs/heads/master
2020-03-13T13:58:17.432490
2018-06-14T17:22:14
2018-06-14T17:22:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
181
cpp
// // Created by Daniel Bigos on 13.06.18. // #include "OutAppend.h" using namespace shell::parser::structures; OutAppend::OutAppend( const std::string &path ) : Out( path ) { }
[ "daniel.bigos96@gmail.com" ]
daniel.bigos96@gmail.com
025ddbee6d4849149e13c1bbb8d7c6eed8b97873
b0bdd09dbbaa05bcfb1c02263325188c4ba9c588
/src/SLR1.cpp
924b708c221a2aed4dfa51852c9bc8587d140a23
[]
no_license
Nightbot1448/SLR1
b26068ed3a49b13b8282dbb91cb8ebd605417686
20fa5523d192a19cdb45aef16620b6b41f34a5ce
refs/heads/master
2021-07-19T06:11:31.784183
2021-01-23T12:40:30
2021-01-23T12:40:30
235,463,065
0
0
null
null
null
null
UTF-8
C++
false
false
2,113
cpp
#include "SLR_parser.h" #include "SLR_base.h" #include <iostream> #include <fstream> #ifdef __linux__ #include <getopt.h> #endif int main(int argc, char **argv) { bool print_parsing_table = false; bool print_tree = false; std::string input_string("-n+(n*n--n/n)+n"); std::string input_file; const char* short_options = "pti:f:"; int res=0; int option_index; #ifdef __linux__ const struct option long_options[] = { {"file",required_argument,NULL,'f'}, {"input",required_argument,NULL,'i'}, {"print_tree",no_argument,NULL,'t'}, {"print_table",no_argument,NULL,'p'}, {NULL,0,NULL,0} }; while ((res=getopt_long(argc,argv,short_options, long_options,&option_index))!=-1){ switch(res){ case 'p': { print_parsing_table = true; break; } case 't': { print_tree = true; break; } case 'i': { input_string = optarg; break; } case 'f': { input_file = optarg; break; } case '?': default: { std::cout << "unknown option" << std::endl; break; } } } #endif Grammar grammar; grammar.emplace('S', "E"); grammar.emplace('E', "T"); grammar.emplace('E', "E+T"); grammar.emplace('E', "E-T"); grammar.emplace('T', "F"); grammar.emplace('T', "T*F"); grammar.emplace('T', "T/F"); grammar.emplace('F', "(E)"); grammar.emplace('F', "-F"); grammar.emplace('F', "n"); SLR1_parser parser; try{ parser = SLR1_parser(grammar, print_parsing_table); } catch(std::logic_error &e){ std::cout << e.what() << std::endl; } if (input_file.empty()) { std::cout << "Input string: " << input_string << std::endl << "Result : "<< (parser.parse(input_string, print_tree) ? "accepted" : "reject") << std::endl; } else { std::ifstream in(input_file, std::ios::in); if (in.is_open()) { std::string str; while (in >> str) { std::cout << "Input string: " << str << std::endl << "Result : " << (parser.parse(str, print_tree) ? "accepted" : "reject") << std::endl << "---" << std::endl; } } else{ std::cout << "file wasn't open; exiting" << std::endl; return 0; } } return 0; }
[ "night1337bot@gmail.com" ]
night1337bot@gmail.com
293b37023bbcdf27b6ae924ee5e55fc45b00fc1f
5ede0e0fd1668416fc74fc5a3c997547b7708abc
/src/map_patterns.cpp
d93d1e1499a4c6bc0c71e3f9ead2eefb4c0c565b
[]
no_license
ethanfine/ia
d1f8671177cacb4bc351d5257e65c8cc05e6732d
134ff030939fc3286545d7f58cc20cbfbc5547fa
refs/heads/develop
2020-04-06T05:09:13.466507
2015-12-08T19:19:16
2015-12-08T19:19:16
47,472,684
0
0
null
2015-12-05T21:05:43
2015-12-05T21:05:42
null
UTF-8
C++
false
false
3,486
cpp
#include "map_patterns.hpp" #include "init.hpp" #include <vector> #include "map.hpp" #include "feature_rigid.hpp" #include "game_time.hpp" namespace map_patterns { void cells_in_room(const Room& room, std::vector<P>& adj_to_walls, std::vector<P>& away_from_walls) { TRACE_FUNC_BEGIN_VERBOSE; std::vector<P> pos_bucket; pos_bucket.clear(); const Rect& r = room.r_; for (int x = r.p0.x; x <= r.p1.x; ++x) { for (int y = r.p0.y; y <= r.p1.y; ++y) { if (map::room_map[x][y] == &room) { auto* const f = map::cells[x][y].rigid; if (f->can_move_cmn() && f->can_have_rigid()) { pos_bucket.push_back(P(x, y)); } } } } adj_to_walls.clear(); away_from_walls.clear(); for (P& pos : pos_bucket) { const int NR_BLK_R = walk_blockers_in_dir(Dir::right, pos); const int NR_BLK_D = walk_blockers_in_dir(Dir::down, pos); const int NR_BLK_L = walk_blockers_in_dir(Dir::left, pos); const int NR_BLK_U = walk_blockers_in_dir(Dir::up, pos); const bool IS_ZERO_BLK_ALL_DIR = NR_BLK_R == 0 && NR_BLK_D == 0 && NR_BLK_L == 0 && NR_BLK_U == 0; if (IS_ZERO_BLK_ALL_DIR) { away_from_walls.push_back(pos); continue; } bool is_door_adjacent = false; for (int dx = -1; dx <= 1; ++dx) { for (int dy = -1; dy <= 1; ++dy) { const auto* const f = map::cells[pos.x + dx][pos.y + dy].rigid; if (f->id() == Feature_id::door) {is_door_adjacent = true;} } } if (is_door_adjacent) {continue;} if ( (NR_BLK_R == 3 && NR_BLK_U == 1 && NR_BLK_D == 1 && NR_BLK_L == 0) || (NR_BLK_R == 1 && NR_BLK_U == 3 && NR_BLK_D == 0 && NR_BLK_L == 1) || (NR_BLK_R == 1 && NR_BLK_U == 0 && NR_BLK_D == 3 && NR_BLK_L == 1) || (NR_BLK_R == 0 && NR_BLK_U == 1 && NR_BLK_D == 1 && NR_BLK_L == 3)) { adj_to_walls.push_back(pos); continue; } } TRACE_FUNC_END_VERBOSE; } int walk_blockers_in_dir(const Dir dir, const P& pos) { int nr_blockers = 0; switch (dir) { case Dir::right: { for (int dy = -1; dy <= 1; ++dy) { const auto* const f = map::cells[pos.x + 1][pos.y + dy].rigid; if (!f->can_move_cmn()) {nr_blockers += 1;} } } break; case Dir::down: { for (int dx = -1; dx <= 1; ++dx) { const auto* const f = map::cells[pos.x + dx][pos.y + 1].rigid; if (!f->can_move_cmn()) {nr_blockers += 1;} } } break; case Dir::left: { for (int dy = -1; dy <= 1; ++dy) { const auto* const f = map::cells[pos.x - 1][pos.y + dy].rigid; if (!f->can_move_cmn()) {nr_blockers += 1;} } } break; case Dir::up: { for (int dx = -1; dx <= 1; ++dx) { const auto* const f = map::cells[pos.x + dx][pos.y - 1].rigid; if (!f->can_move_cmn()) {nr_blockers += 1;} } } break; case Dir::down_left: case Dir::down_right: case Dir::up_left: case Dir::up_right: case Dir::center: case Dir::END: break; } return nr_blockers; } } //map_patterns
[ "m.tornq@gmail.com" ]
m.tornq@gmail.com
394a805fa897aa08cd8375de5bebd9aad769eb0b
3c1f699c1da70d1b5f3075d74887129acbedb949
/include/BigUint.hpp
b6145521de07624d7fb4af8df074ddbe572f01e2
[ "MIT" ]
permissive
peterzuger/BigInt
8acebad47bbbb19a608663398563cf4ce273f17e
2c106cbb24db5728f34d6e7748f423e9d4301b65
refs/heads/master
2021-05-18T01:56:55.779994
2020-07-19T08:42:15
2020-07-19T08:42:15
251,055,820
0
0
null
null
null
null
UTF-8
C++
false
false
6,727
hpp
/** * @file BigInt/include/BigUint.hpp * @author Peter Züger * @date 29.03.2020 * @brief Library for representing big integers * * The MIT License (MIT) * * Copyright (c) 2020 Philippe Peter * Copyright (c) 2020 Peter Züger * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef BIGINT_BIGUINT_HPP #define BIGINT_BIGUINT_HPP #include <array> #include <climits> #include <istream> #include <limits> #include <ostream> namespace Big{ template<std::size_t N> class BigUint{ static_assert(!(N % (sizeof(unsigned int) * CHAR_BIT)), "Big::BigUint: N must be a multiple of 'sizeof(unsigned int) * CHAR_BIT'"); std::array<unsigned int, N / (sizeof(unsigned int) * CHAR_BIT)> data; public: constexpr BigUint() = default; constexpr BigUint(const BigUint& other)noexcept; constexpr BigUint(BigUint&& other)noexcept; constexpr BigUint(unsigned long long other)noexcept; constexpr BigUint(float other)noexcept; constexpr BigUint(double other)noexcept; constexpr BigUint(long double other)noexcept; template<std::size_t M> constexpr BigUint(const BigUint<M>& other)noexcept; BigUint& operator=(const BigUint& other)noexcept; BigUint& operator=(BigUint&& other)noexcept; BigUint& operator=(unsigned long long other)noexcept; BigUint& operator=(float other)noexcept; BigUint& operator=(double other)noexcept; BigUint& operator=(long double other)noexcept; void swap(BigUint& other)noexcept; constexpr BigUint& operator~()noexcept; constexpr BigUint& operator+=(const BigUint& rhs)noexcept; constexpr BigUint& operator-=(const BigUint& rhs)noexcept; constexpr BigUint& operator*=(const BigUint& rhs)noexcept; constexpr BigUint& operator/=(const BigUint& rhs)noexcept; constexpr BigUint& operator%=(const BigUint& rhs)noexcept; constexpr BigUint& operator^=(const BigUint& rhs)noexcept; constexpr BigUint& operator&=(const BigUint& rhs)noexcept; constexpr BigUint& operator|=(const BigUint& rhs)noexcept; template <class IntType>constexpr BigUint& operator<<=(IntType shift)noexcept; template <class IntType>constexpr BigUint& operator>>=(IntType shift)noexcept; constexpr BigUint& operator++()noexcept; constexpr BigUint operator++(int)noexcept; constexpr BigUint& operator--()noexcept; constexpr BigUint operator--(int)noexcept; template<std::size_t M> friend std::ostream& operator<<(std::ostream& os, const BigUint<M>& obj); template<std::size_t M> friend std::istream& operator>>(std::istream& is, BigUint<M>& obj); }; template<std::size_t N> std::ostream& operator<<(std::ostream& os, const BigUint<N>& obj){ // write obj to stream return os; } template<std::size_t N> std::istream& operator>>(std::istream& is, BigUint<N>& obj){ // read obj from stream if( /* T could not be constructed */ true ) is.setstate(std::ios::failbit); return is; } template<std::size_t N> void swap(BigUint<N>& x, BigUint<N>& y)noexcept{ x.swap(y); } template<std::size_t N> constexpr BigUint<N> operator+(BigUint<N> lhs, const BigUint<N>& rhs)noexcept{ return lhs += rhs; } template<std::size_t N> constexpr BigUint<N> operator-(BigUint<N> lhs, const BigUint<N>& rhs)noexcept{ return lhs -= rhs; } template<std::size_t N> constexpr BigUint<N> operator*(BigUint<N> lhs, const BigUint<N>& rhs)noexcept{ return lhs *= rhs; } template<std::size_t N> constexpr BigUint<N> operator/(BigUint<N> lhs, const BigUint<N>& rhs)noexcept{ return lhs /= rhs; } template<std::size_t N> constexpr BigUint<N> operator%(BigUint<N> lhs, const BigUint<N>& rhs)noexcept{ return lhs %= rhs; } template<std::size_t N> constexpr BigUint<N> operator^(BigUint<N> lhs, const BigUint<N>& rhs)noexcept{ return lhs ^= rhs; } template<std::size_t N> constexpr BigUint<N> operator&(BigUint<N> lhs, const BigUint<N>& rhs)noexcept{ return lhs &= rhs; } template<std::size_t N> constexpr BigUint<N> operator|(BigUint<N> lhs, const BigUint<N>& rhs)noexcept{ return lhs |= rhs; } template <std::size_t N, class IntType> constexpr BigUint<N> operator<<(const BigUint<N>& lhs, IntType shift)noexcept{ return lhs <<= shift; } template <std::size_t N, class IntType> constexpr BigUint<N> operator>>(const BigUint<N>& lhs, IntType shift)noexcept{ return lhs >>= shift; } template<std::size_t N> constexpr bool operator< (const BigUint<N>& lhs, const BigUint<N>& rhs) noexcept { return false; // TODO } template<std::size_t N> constexpr bool operator> (const BigUint<N>& lhs, const BigUint<N>& rhs) noexcept { return rhs < lhs; } template<std::size_t N> constexpr bool operator<=(const BigUint<N>& lhs, const BigUint<N>& rhs) noexcept { return !(lhs > rhs); } template<std::size_t N> constexpr bool operator>=(const BigUint<N>& lhs, const BigUint<N>& rhs) noexcept { return !(lhs < rhs); } template<std::size_t N> constexpr bool operator==(const BigUint<N>& lhs, const BigUint<N>& rhs) noexcept { return false; } template<std::size_t N> constexpr bool operator!=(const BigUint<N>& lhs, const BigUint<N>& rhs) noexcept { return !(lhs == rhs); } }; #endif /* BIGINT_BIGUINT_HPP */
[ "zueger.peter@icloud.com" ]
zueger.peter@icloud.com
b2261580a5edb6c594a0609140c72747e0ef074d
fc38a55144a0ad33bd94301e2d06abd65bd2da3c
/thirdparty/cgal/CGAL-4.13/include/CGAL/Minkowski_sum_2/Minkowski_sum_by_reduced_convolution_2.h
ef37f9d9336bc1fb96224b6e811a8fe50238c63a
[ "LGPL-2.0-or-later", "LGPL-3.0-or-later", "GPL-1.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-commercial-license", "MIT", "LicenseRef-scancode-free-unknown", "LGPL-3.0-only", "GPL-3.0-only", "LGPL-2.1-or-later", "LicenseRef-scancode-proprietary-license", "Licens...
permissive
bobpepin/dust3d
20fc2fa4380865bc6376724f0843100accd4b08d
6dcc6b1675cb49ef3fac4a58845f9c9025aa4c9f
refs/heads/master
2022-11-30T06:00:10.020207
2020-08-09T09:54:29
2020-08-09T09:54:29
286,051,200
0
0
MIT
2020-08-08T13:45:15
2020-08-08T13:45:14
null
UTF-8
C++
false
false
17,395
h
// Copyright (c) 2015 Tel-Aviv University (Israel). // All rights reserved. // // This file is part of CGAL (www.cgal.org). // 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. // // 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. // // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ // // Author(s): Sebastian Morr <sebastian@morr.cc> #ifndef CGAL_MINKOWSKI_SUM_BY_REDUCED_CONVOLUTION_2_H #define CGAL_MINKOWSKI_SUM_BY_REDUCED_CONVOLUTION_2_H #include <CGAL/license/Minkowski_sum_2.h> #include <CGAL/basic.h> #include <CGAL/Arrangement_with_history_2.h> #include <CGAL/Arr_segment_traits_2.h> #include <CGAL/Minkowski_sum_2/AABB_collision_detector_2.h> #include <queue> #include <boost/unordered_set.hpp> #include <boost/unordered_map.hpp> namespace CGAL { // This algorithm was first described by Evan Behar and Jyh-Ming Lien in "Fast // and Robust 2D Minkowski Sum Using Reduced Convolution", IROS 2011. // This implementation is based on Alon Baram's 2013 master's thesis "Polygonal // Minkowski Sums via Convolution: Theory and Practice" at Tel-Aviv University. template <typename Kernel_, typename Container_> class Minkowski_sum_by_reduced_convolution_2 { private: typedef Kernel_ Kernel; typedef Container_ Container; // Basic types: typedef CGAL::Polygon_2<Kernel, Container> Polygon_2; typedef CGAL::Polygon_with_holes_2<Kernel, Container> Polygon_with_holes_2; typedef typename Kernel::Point_2 Point_2; typedef typename Kernel::Vector_2 Vector_2; typedef typename Kernel::Direction_2 Direction_2; typedef typename Kernel::Triangle_2 Triangle_2; typedef typename Kernel::FT FT; // Segment-related types: typedef Arr_segment_traits_2<Kernel> Traits_2; typedef typename Traits_2::X_monotone_curve_2 Segment_2; typedef std::list<Segment_2> Segment_list; typedef Arr_default_dcel<Traits_2> Dcel; typedef std::pair<int, int> State; // Arrangement-related types: typedef Arrangement_with_history_2<Traits_2, Dcel> Arrangement_history_2; typedef typename Arrangement_history_2::Halfedge_handle Halfedge_handle; typedef typename Arrangement_history_2::Face_iterator Face_iterator; typedef typename Arrangement_history_2::Face_handle Face_handle; typedef typename Arrangement_history_2::Ccb_halfedge_circulator Ccb_halfedge_circulator; typedef typename Arrangement_history_2::Originating_curve_iterator Originating_curve_iterator; typedef typename Arrangement_history_2::Inner_ccb_iterator Inner_ccb_iterator; // Function object types: typename Kernel::Construct_translated_point_2 f_add; typename Kernel::Construct_vector_2 f_vector; typename Kernel::Construct_direction_2 f_direction; typename Kernel::Orientation_2 f_orientation; typename Kernel::Compare_xy_2 f_compare_xy; typename Kernel::Counterclockwise_in_between_2 f_ccw_in_between; public: Minkowski_sum_by_reduced_convolution_2() { // Obtain kernel functors Kernel ker; f_add = ker.construct_translated_point_2_object(); f_vector = ker.construct_vector_2_object(); f_direction = ker.construct_direction_2_object(); f_orientation = ker.orientation_2_object(); f_compare_xy = ker.compare_xy_2_object(); f_ccw_in_between = ker.counterclockwise_in_between_2_object(); } template <typename OutputIterator> void operator()(const Polygon_2& pgn1, const Polygon_2& pgn2, Polygon_2& outer_boundary, OutputIterator holes) const { CGAL_precondition(pgn1.is_simple()); CGAL_precondition(pgn2.is_simple()); CGAL_precondition(pgn1.orientation() == COUNTERCLOCKWISE); CGAL_precondition(pgn2.orientation() == COUNTERCLOCKWISE); const Polygon_with_holes_2 pwh1(pgn1); const Polygon_with_holes_2 pwh2(pgn2); common_operator(pwh1, pwh2, outer_boundary, holes); } template <typename OutputIterator> void operator()(const Polygon_with_holes_2& pgn1, const Polygon_with_holes_2& pgn2, Polygon_2& outer_boundary, OutputIterator holes) const { common_operator(pgn1, pgn2, outer_boundary, holes); } template <typename OutputIterator> void operator()(const Polygon_2& pgn1, const Polygon_with_holes_2& pgn2, Polygon_2& outer_boundary, OutputIterator holes) const { CGAL_precondition(pgn1.is_simple()); CGAL_precondition(pgn1.orientation() == COUNTERCLOCKWISE); const Polygon_with_holes_2 pwh1(pgn1); common_operator(pwh1, pgn2, outer_boundary, holes); } private: template <typename OutputIterator> void common_operator(const Polygon_with_holes_2& pgn1, const Polygon_with_holes_2& pgn2, Polygon_2& outer_boundary, OutputIterator holes) const { // If the outer boundaries of both summands are empty the Minkowski sum is // the entire plane. if (pgn1.outer_boundary().is_empty() && pgn2.outer_boundary().is_empty()) return; // Initialize collision detector. It operates on pgn2 and on the inversed // pgn1: const Polygon_with_holes_2 inversed_pgn1 = transform(Aff_transformation_2<Kernel>(SCALING, -1), pgn1); AABB_collision_detector_2<Kernel, Container> collision_detector(pgn2, inversed_pgn1); // Compute the reduced convolution (see section 4.1 of Alon's master's // thesis) Segment_list reduced_convolution; build_reduced_convolution(pgn1, pgn2, reduced_convolution); // Insert the segments into an arrangement Arrangement_history_2 arr; insert(arr, reduced_convolution.begin(), reduced_convolution.end()); // Trace the outer loop and put it in 'outer_boundary' // If one of the summand does not have an outer boundary, then the Minkowski // sum does not have an outer boundary either. bool is_outer_boundary_empty = pgn1.outer_boundary().is_empty() || pgn2.outer_boundary().is_empty(); if (! is_outer_boundary_empty) get_outer_loop(arr, outer_boundary); // Check for each face whether it is a hole in the M-sum. If it is, add it // to 'holes'. See chapter 3 of of Alon's master's thesis. for (Face_iterator fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) { // Check whether the face is on the M-sum's border. // If the face contains holes, it can't be on the Minkowski sum's border if (0 < fit->number_of_holes()) continue; // The face needs to be orientable if (! test_face_orientation(arr, fit)) continue; // When the reversed polygon 1, translated by a point inside of this face, // collides with polygon 2, this cannot be a hole if (! is_outer_boundary_empty) { Point_2 inner_point = get_point_in_face(fit); if (collision_detector.check_collision(inner_point)) continue; } add_face(fit, holes); } } // Builds the reduced convolution for each pair of loop in the two // polygons-with-holes. void build_reduced_convolution(const Polygon_with_holes_2& pgnwh1, const Polygon_with_holes_2& pgnwh2, Segment_list& reduced_convolution) const { for (std::size_t x = 0; x < 1+pgnwh1.number_of_holes(); ++x) { for (std::size_t y = 0; y < 1+pgnwh2.number_of_holes(); ++y) { if ((x != 0) && (y != 0)) { continue; } Polygon_2 pgn1, pgn2; if (x == 0) { pgn1 = pgnwh1.outer_boundary(); } else { typename Polygon_with_holes_2::Hole_const_iterator it1 = pgnwh1.holes_begin(); for (std::size_t count = 0; count < x-1; count++) { it1++; } pgn1 = *it1; } if (y == 0) { pgn2 = pgnwh2.outer_boundary(); } else { typename Polygon_with_holes_2::Hole_const_iterator it2 = pgnwh2.holes_begin(); for (std::size_t count = 0; count < y-1; count++) { it2++; } pgn2 = *it2; } build_reduced_convolution(pgn1, pgn2, reduced_convolution); } } } // Builds the reduced convolution using a fiber grid approach. For each // starting vertex, try to add two outgoing next states. If a visited // vertex is reached, then do not explore further. This is a BFS-like // iteration beginning from each vertex in the first column of the fiber // grid. void build_reduced_convolution(const Polygon_2& pgn1, const Polygon_2& pgn2, Segment_list& reduced_convolution) const { int n1 = static_cast<int>(pgn1.size()); int n2 = static_cast<int>(pgn2.size()); if ((n1 == 0) || (n2 == 0)) return; std::vector<Point_2> p1_vertices = vertices_of_polygon(pgn1); std::vector<Point_2> p2_vertices = vertices_of_polygon(pgn2); // Init the direcions of both polygons std::vector<Direction_2> p1_dirs = directions_of_polygon(p1_vertices); std::vector<Direction_2> p2_dirs = directions_of_polygon(p2_vertices); // Contains states that were already visited boost::unordered_set<State> visited_states; // Init the queue with vertices from the first column std::queue<State> state_queue; for (int i = n1-1; i >= 0; --i) { state_queue.push(State(i, 0)); } while (state_queue.size() > 0) { State curr_state = state_queue.front(); state_queue.pop(); int i1 = curr_state.first; int i2 = curr_state.second; // If this state was already visited, skip it if (visited_states.count(curr_state) > 0) { continue; } visited_states.insert(curr_state); int next_i1 = (i1+1) % n1; int next_i2 = (i2+1) % n2; int prev_i1 = (n1+i1-1) % n1; int prev_i2 = (n2+i2-1) % n2; // Try two transitions: From (i,j) to (i+1,j) and to (i,j+1). Add // the respective segments, if they are in the reduced convolution. for(int step_in_pgn1 = 0; step_in_pgn1 <= 1; step_in_pgn1++) { int new_i1, new_i2; if (step_in_pgn1) { new_i1 = next_i1; new_i2 = i2; } else { new_i1 = i1; new_i2 = next_i2; } // If the segment's direction lies counterclockwise in between // the other polygon's vertex' ingoing and outgoing directions, // the segment belongs to the full convolution. bool belongs_to_convolution; if (step_in_pgn1) { belongs_to_convolution = f_ccw_in_between(p1_dirs[i1], p2_dirs[prev_i2], p2_dirs[i2]) || p1_dirs[i1] == p2_dirs[i2]; } else { belongs_to_convolution = f_ccw_in_between(p2_dirs[i2], p1_dirs[prev_i1], p1_dirs[i1]) || p2_dirs[i2] == p1_dirs[prev_i1]; } if (belongs_to_convolution) { state_queue.push(State(new_i1, new_i2)); // Only edges added to convex vertices can be on the M-sum's boundary. // This filter only leaves the *reduced* convolution. bool convex; if (step_in_pgn1) { convex = is_convex(p2_vertices[prev_i2], p2_vertices[i2], p2_vertices[next_i2]); } else { convex = is_convex(p1_vertices[prev_i1], p1_vertices[i1], p1_vertices[next_i1]); } if (convex) { Point_2 start_point = get_point(i1, i2, p1_vertices, p2_vertices); Point_2 end_point = get_point(new_i1, new_i2, p1_vertices, p2_vertices); reduced_convolution.push_back(Segment_2(start_point, end_point)); } } } } } // Returns a vector of the polygon's vertices, in case that Container // is std::list and we cannot use vertex(i). std::vector<Point_2> vertices_of_polygon(const Polygon_2& p) const { std::vector<Point_2> vertices; for (typename Polygon_2::Vertex_const_iterator it = p.vertices_begin(); it != p.vertices_end(); it++) { vertices.push_back(*it); } return vertices; } // Returns a sorted list of the polygon's edges std::vector<Direction_2> directions_of_polygon( const std::vector<Point_2>& points) const { std::vector<Direction_2> directions; std::size_t n = points.size(); for (std::size_t i = 0; i < n-1; ++i) { directions.push_back(f_direction(f_vector(points[i], points[i+1]))); } directions.push_back(f_direction(f_vector(points[n-1], points[0]))); return directions; } bool is_convex(const Point_2& prev, const Point_2& curr, const Point_2& next) const { return f_orientation(prev, curr, next) == LEFT_TURN; } // Returns the point corresponding to a state (i,j). Point_2 get_point(int i1, int i2, const std::vector<Point_2>& pgn1, const std::vector<Point_2>& pgn2) const { return f_add(pgn1[i1], Vector_2(Point_2(ORIGIN), pgn2[i2])); } // Put the outer loop of the arrangement in 'outer_boundary' void get_outer_loop(Arrangement_history_2& arr, Polygon_2& outer_boundary) const { Inner_ccb_iterator icit = arr.unbounded_face()->inner_ccbs_begin(); Ccb_halfedge_circulator circ_start = *icit; Ccb_halfedge_circulator circ = circ_start; do { outer_boundary.push_back(circ->source()->point()); } while (--circ != circ_start); } // Determine whether the face orientation is consistent. bool test_face_orientation(const Arrangement_history_2& arr, const Face_handle face) const { // The face needs to be orientable Ccb_halfedge_circulator start = face->outer_ccb(); Ccb_halfedge_circulator circ = start; do if (!do_original_edges_have_same_direction(arr, circ)) return false; while (++circ != start); return true; } // Add a face to 'holes'. template <typename OutputIterator> void add_face(const Face_handle face, OutputIterator holes) const { Polygon_2 pgn_hole; Ccb_halfedge_circulator start = face->outer_ccb(); Ccb_halfedge_circulator circ = start; do pgn_hole.push_back(circ->source()->point()); while (--circ != start); *holes = pgn_hole; ++holes; } // Check whether the convolution's original edge(s) had the same direction as // the arrangement's half edge bool do_original_edges_have_same_direction(const Arrangement_history_2& arr, const Halfedge_handle he) const { Originating_curve_iterator segment_itr; for (segment_itr = arr.originating_curves_begin(he); segment_itr != arr.originating_curves_end(he); ++segment_itr) { if (f_compare_xy(segment_itr->source(), segment_itr->target()) == (Comparison_result)he->direction()) { return false; } } return true; } // Return a point in the face's interior by finding a diagonal Point_2 get_point_in_face(const Face_handle face) const { Ccb_halfedge_circulator current_edge = face->outer_ccb(); Ccb_halfedge_circulator next_edge = current_edge; next_edge++; Point_2 a, v, b; // Move over the face's vertices until a convex corner is encountered: do { a = current_edge->source()->point(); v = current_edge->target()->point(); b = next_edge->target()->point(); current_edge++; next_edge++; } while (!is_convex(a, v, b)); Triangle_2 ear(a, v, b); FT min_distance = -1; const Point_2* min_q = 0; // Of the remaining vertices, find the one inside of the "ear" with minimal // distance to v: while (++next_edge != current_edge) { const Point_2& q = next_edge->target()->point(); if (ear.has_on_bounded_side(q)) { FT distance = squared_distance(q, v); if ((min_q == 0) || (distance < min_distance)) { min_distance = distance; min_q = &q; } } } // If there was no vertex inside of the ear, return it's centroid. // Otherwise, return a point between v and min_q. return (min_q == 0) ? centroid(ear) : midpoint(v, *min_q); } template <typename Transformation> Polygon_with_holes_2 transform(const Transformation& t, const Polygon_with_holes_2& p) const { Polygon_with_holes_2 result(CGAL::transform(t, p.outer_boundary())); typename Polygon_with_holes_2::Hole_const_iterator it = p.holes_begin(); while (it != p.holes_end()) { Polygon_2 p2(it->vertices_begin(), it->vertices_end()); result.add_hole(CGAL::transform(t, p2)); ++it; } return result; } }; } // namespace CGAL #endif
[ "huxingyi@msn.com" ]
huxingyi@msn.com
9b4dc0f311dfe13070d74a507f6b6da8d0d854b8
883ab39434c0a31cb0f04b8fe7f5e7761f1939ca
/main.cpp
30814549176d8e791c19bad9cddd6f0fc072659f
[]
no_license
jiubing/QtDemo
7b88130df00190971ee4c570caa37e4c43cdbbf7
58433760aabfa3689b1b0b28a9c74a847f9aaa23
refs/heads/master
2022-12-04T11:00:33.676335
2020-08-29T01:28:23
2020-08-29T01:28:23
291,176,460
0
0
null
null
null
null
UTF-8
C++
false
false
185
cpp
#include "mainwindow.h" #include <QApplication> //hhhhhhhhhhhhhhhhhhhhhhh int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
[ "1761960198@qq.co" ]
1761960198@qq.co
5b3a5a427fb5c5934e5651f65e84a22cc9474932
20b49a6ef1fa417d67abef2d29a598c9e41c478e
/CSES/Graph Algorithms/highScore.cpp
23f369dd0f7541a0647b7dcefc154b5f83a3e3d1
[]
no_license
switchpiggy/Competitive_Programming
956dac4a71fdf65de2959dd142a2032e2f0710e1
beaaae4ece70889b0af1494d68c630a6e053558a
refs/heads/master
2023-04-15T19:13:12.348433
2021-04-04T06:12:29
2021-04-04T06:12:29
290,905,106
1
3
null
2020-10-05T20:16:53
2020-08-27T23:38:48
C++
UTF-8
C++
false
false
1,782
cpp
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define benq queue #define pbenq priority_queue #define all(x) x.begin(), x.end() #define sz(x) (ll)x.size() #define m1(x) memset(x, 1, sizeof(x)) #define m0(x) memset(x, 0, sizeof(x)) #define mn(x) memset(x, -0x3f, sizeof(x)); #define inf(x) memset(x, 0x3f, sizeof(x)) #define MOD 1000000007 #define INF 0x3f3f3f3f3f3f3f3f #define PI 3.14159265358979323846264338 #define flout cout << fixed << setprecision(12) ll n, m, a, b, x, dist[2507]; vector<pair<pair<ll, ll>, ll>> v; vector<ll> adj[100007], adj2[100007]; bool bad[100007], vis[100007], r[100007]; bool dfs(ll x) { vis[x] = 1; if(bad[x] && r[x]) return 1; for(ll i : adj[x]) { if(vis[i]) continue; if(dfs(i)) return 1; } return 0; } void dfs2(ll x) { vis[x] = r[x] = 1; for(ll i : adj2[x]) { if(vis[i]) continue; dfs2(i); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; mn(dist); for(ll i = 0; i < m; ++i) { cin >> a >> b >> x; v.push_back({{a, b}, x}); adj[b].push_back(a); adj2[a].push_back(b); } dist[1] = 0; for(ll i = 0; i < n - 1; ++i) { for(auto j : v) { if(dist[j.first.first] != -INF) dist[j.first.second] = max(dist[j.first.second], dist[j.first.first] + j.second); } } for(auto j : v) { if(dist[j.first.first] != -INF && dist[j.first.second] < dist[j.first.first] + j.second) { bad[j.first.first] = 1; dist[j.first.second] = dist[j.first.first] + j.second; } } dfs2(1); m0(vis); if(dfs(n)) cout << "-1\n"; else cout << dist[n] << '\n'; return 0; }
[ "switchpiggy@users.noreply.github.com" ]
switchpiggy@users.noreply.github.com
a0ae71ec28c9e9436e81fb0fadabda6d923ddd27
17353cfd2c984f2b57ab09dce5b793f34b051f19
/unsorted_include_todo/Title/Section.h
c34ffd80181d3d4f3e76fde755292d151f5c7e80
[]
no_license
mxygon/pikmin2
573df84b127b27f1c5db6be22680b63fd34565d5
fa16b706d562d3f276406d8a87e01ad541515737
refs/heads/main
2023-09-02T06:56:56.216154
2021-11-12T09:34:26
2021-11-12T09:34:26
427,367,127
1
0
null
2021-11-12T13:19:54
2021-11-12T13:19:53
null
UTF-8
C++
false
false
2,110
h
#ifndef _TITLE_SECTION_H #define _TITLE_SECTION_H namespace Game { struct BaseHIOSection { virtual void _00() = 0; // _00 virtual void _04() = 0; // _04 virtual void _08() = 0; // _08 virtual void _0C() = 0; // _0C virtual void _10() = 0; // _10 virtual void _14() = 0; // _14 virtual void _18() = 0; // _18 virtual void _1C() = 0; // _1C virtual void _20() = 0; // _20 virtual void _24() = 0; // _24 virtual void _28() = 0; // _28 virtual void _2C() = 0; // _2C virtual void _30() = 0; // _30 virtual void _34() = 0; // _34 virtual void _38() = 0; // _38 virtual void _3C() = 0; // _3C virtual void initHIO(HIORootNode*); // _40 virtual void refreshHIO(); // _44 // _00 VTBL }; } // namespace Game namespace Title { struct Section : public BaseHIOSection { virtual ~Section(); // _00 virtual void run(); // _04 virtual void update(); // _08 virtual void draw(Graphics&); // _0C virtual void init(); // _10 virtual void drawInit(Graphics&); // _14 virtual void drawInit(Graphics&, EDrawInitMode); // _18 virtual void doExit(); // _1C virtual void forceFinish(); // _20 virtual void forceReset(); // _24 virtual void getCurrentSection(); // _28 virtual void doLoadingStart(); // _2C virtual void doLoading(); // _30 virtual void doUpdate(); // _34 virtual void doDraw(Graphics&); // _38 virtual void isFinishable(); // _3C virtual void initHIO(HIORootNode*); // _40 virtual void refreshHIO(); // _44 virtual void loadResource(); // _48 // _00 VTBL }; } // namespace Title #endif
[ "84647527+intns@users.noreply.github.com" ]
84647527+intns@users.noreply.github.com
55de33c245258aff29acda728b146e7ccb1cc969
83983b26f3db2963871e6a1ab046c64b2c378dd7
/CHEFINSQ.cpp
49f0a6ccb52c780bdc1eb51e71c78e5f1e1ce1b0
[]
no_license
sakib1913/CODE-CHEF-AND-CODEFORCES-SOLUTIONS-IN-CPP
144fda22091195330ae3baa1c7ce8523804d6d3b
73af645558ce5232a33e99f648840ecf1656f2cf
refs/heads/master
2022-11-12T18:18:51.824547
2020-07-11T13:13:52
2020-07-11T13:13:52
265,778,445
0
0
null
null
null
null
UTF-8
C++
false
false
661
cpp
#include<iostream> #include<algorithm> using namespace std; int fact(int n) { int res = 1; for (int i = 2; i <= n; i++) res = res * i; return res; } int ncr(int n, int r) { return fact(n) / (fact(r) * fact(n - r)); } int main() {int n; cin>>n; int a[n]; for(int i=0;i<n;i++) { cin>>a[i]; } sort(a,a+n); cout<<"\n"; for(int i=0;i<n;i++) { cout<<a[i]<<" "; } int k; cout<<"\nenter the k\n"; cin>>k; int num=a[k-1]; int nis=0; cout<<num<<" "; //totalnumberCnumberinsubarray for(int i=0;i<k;i++) { if(a[i]==num) { nis++; } } int nit=0;//nitCnis for(int i=0;i<n;i++) { if(a[i]==num) { nit++; } } cout<<"\nNCR\n"; cout<<ncr(nit,nis)<<" "; }
[ "noreply@github.com" ]
sakib1913.noreply@github.com
282a40574da52846ce82302f4033862a5e950873
8f726a302a527a43a656c6c8a791fe59a73b029d
/Chapter_1/1.5_One_Away/Levenshtein_distance.cpp
ea7a0e3935f07322a73615bb15ddb56cd688e207
[]
no_license
aaraki/CtCI
f9d22117e6bc495695839ddd193744e5ef1b18c7
6f904251f2e7def3f24e05034ce24341bfc9351f
refs/heads/master
2022-04-18T15:31:33.421149
2020-03-09T02:38:23
2020-03-09T02:38:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,050
cpp
#include <iostream> #include <vector> #include <list> #include <stack> #include <queue> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <string> #include <algorithm> using namespace std; bool oneEditAway(string s, string t) { int n = (int)s.size(); int m = (int)t.size(); vector<vector<int>> dp(n + 1, vector<int>(m + 1, INT32_MAX)); for (int i = 0; i <= n; i++) dp[i][0] = i; for (int i = 0; i <= m; i++) dp[0][i] = i; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1); dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1); dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (s[i - 1] != t[j - 1])); } } return dp[n][m] <= 1; } int main() { cout << oneEditAway("pale", "ple") << endl; // true cout << oneEditAway("pales", "pale") << endl; // true; cout << oneEditAway("pale", "bale") << endl; // true cout << oneEditAway("pale", "bae") << endl; //false return 0; }
[ "tatsuhiro.no.jones@gmail.com" ]
tatsuhiro.no.jones@gmail.com
7c0ba1339830b09e5890de8a9ea60307d9c1aa35
02c506346de40061bc7bf3cc4873bbb19581606c
/client/examonline/scorepaper.h
c379bac39a81426d92e1d91351048eeb197a741a
[]
no_license
787028221/exam
f95327f56e5018257eb16fbe2ad3d869115c2bcc
7203a851a8bab4fe595b093215fe91a8eed42696
refs/heads/master
2019-01-20T07:14:55.384154
2016-05-21T13:34:36
2016-05-21T13:34:58
57,008,066
0
0
null
null
null
null
UTF-8
C++
false
false
359
h
#ifndef SCOREPAPER_H #define SCOREPAPER_H #include <QDialog> #include<QtNetwork> #include<QtNetwork/QTcpSocket> namespace Ui { class scorepaper; } class scorepaper : public QDialog { Q_OBJECT public: explicit scorepaper(QWidget *parent = 0); ~scorepaper(); private: Ui::scorepaper *ui; void showPaper(); }; #endif // SCOREPAPER_H
[ "787028221@qq.com" ]
787028221@qq.com
a878d481ae5d8be7753c0657d55a4a200e43ef93
2b60f6b0c50b5637206c3051be1b9a2d70979406
/src/version.cpp
9dcd85625ccabdfcd39f7ab4563f751c27524b97
[ "MIT" ]
permissive
dogecrap/dogecrap
97976d180b6d73af3176fa43e2aef78ea5b2058a
307721834e9dc525b060414851252927143e5ccb
refs/heads/master
2021-03-12T22:41:19.332301
2014-01-22T21:48:27
2014-01-22T21:48:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,672
cpp
// Copyright (c) 2012 The Bitcoin developers // Copyright (c) 2012 Litecoin Developers // Distributed under the MIT/X11 software license, see the acrapmpanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <string> #include "version.h" // Name of client reported in the 'version' message. Report the same name // for both bitcoind and bitcoin-qt, to make it harder for attackers to // target servers or GUI users specifically. const std::string CLIENT_NAME("Satoshi"); // Client version number #define CLIENT_VERSION_SUFFIX "-foo" // The following part of the code determines the CLIENT_BUILD variable. // Several mechanisms are used for this: // * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is // generated by the build environment, possibly containing the output // of git-describe in a macro called BUILD_DESC // * secondly, if this is an exported version of the code, GIT_ARCHIVE will // be defined (automatically using the export-subst git attribute), and // GIT_COMMIT will contain the commit id. // * then, three options exist for determining CLIENT_BUILD: // * if BUILD_DESC is defined, use that literally (output of git-describe) // * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit] // * otherwise, use v[maj].[min].[rev].[build]-unk // finally CLIENT_VERSION_SUFFIX is added // First, include build.h if requested #ifdef HAVE_BUILD_INFO # include "build.h" #endif // git will put "#define GIT_ARCHIVE 1" on the next line inside archives. $Format:%n#define GIT_ARCHIVE 1$ #ifdef GIT_ARCHIVE # define GIT_COMMIT_ID "$Format:%h$" # define GIT_COMMIT_DATE "$Format:%cD" #endif #define STRINGIFY(s) #s #define BUILD_DESC_FROM_COMMIT(maj,min,rev,build,commit) \ "v" STRINGIFY(maj) "." STRINGIFY(min) "." STRINGIFY(rev) "." STRINGIFY(build) "-g" commit #define BUILD_DESC_FROM_UNKNOWN(maj,min,rev,build) \ "v" STRINGIFY(maj) "." STRINGIFY(min) "." STRINGIFY(rev) "." STRINGIFY(build) "-unk" #ifndef BUILD_DESC # ifdef GIT_COMMIT_ID # define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID) # else # define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD) # endif #endif #ifndef BUILD_DATE # ifdef GIT_COMMIT_DATE # define BUILD_DATE GIT_COMMIT_DATE # else # define BUILD_DATE __DATE__ ", " __TIME__ # endif #endif const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX); const std::string CLIENT_DATE(BUILD_DATE);
[ "you@example.com" ]
you@example.com
ae1c44a7ef3456981492f6cc7a24fd210cec70b7
46622c56ade42ee4ffc7fee9ef55059a5d20bfb8
/Byang Loves Byangette.cpp
b0cc127999361b594743402ac625b37d46da9105
[]
no_license
Abu-Kaisar/Toph-Solutions
4fd6522ebf0d1896efe174ea59cd41e32f9359ff
b0791067ff41ae74a2eb983fda33e4494644bc1c
refs/heads/master
2022-03-03T04:06:27.274970
2019-10-03T19:19:20
2019-10-03T19:19:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,559
cpp
/*** Bismillahir Rahmanir Rahim Read in the name of Allah, who created you!!! Author : Shah Newaj Rabbi Shishir, Department of CSE, City University, Bangladesh. ***/ #include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define ssf sscanf #define spf sprintf #define fsf fscanf #define fpf fprintf #define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define scase sf ("%d",&tc) #define sn sf ("%d",&n) #define whilecase while (tc--) #define eof while (cin >> n) #define forloop for (pos=1; pos<=tc; pos++) #define arrayloop (i=0; i<n; i++) #define cinstr cin >> str #define getstr getline (cin,str) #define pcase pf ("Case %d: ",pos) #define vi vector <int> #define pii pair <int,int> #define mii map <int,int> #define pb push_back #define in insert #define llu unsigned long long #define lld long long #define U unsigned int #define endl "\n" const int MOD = 1000000007; const int MAX = 1000005; int SetBit (int n, int x) { return n | (1 << x); } int ClearBit (int n, int x) { return n & ~(1 << x); } int ToggleBit (int n, int x) { return n ^ (1 << x); } bool CheckBit (int n, int x) { return (bool)(n & (1 << x)); } int main (void) { /* freopen ("input.txt","r",stdin); freopen ("output.txt","w",stdout); */ string str; getline(cin,str); if (str == "Who loves Byang?") cout << "Byangette" << endl; else cout << "Byang" << endl; return 0; }
[ "noreply@github.com" ]
Abu-Kaisar.noreply@github.com
95b16fcf7aba9cffc7917967cffa481ee9bb11be
ed2d635479472dd330176a8624b3189017b0cdc2
/test/SplitterTest.cpp
516353fd646aac96209addd888a923bcc9f3d7b5
[]
no_license
Firobe/Packer
ac16da43e3e86f9401bdabb0f91f986a022d0220
bd6b3cc824028c63e01c51831ebbb4b006a4b351
refs/heads/master
2021-01-21T16:27:47.159457
2017-04-13T22:20:44
2017-04-13T22:20:44
91,887,259
2
0
null
null
null
null
UTF-8
C++
false
false
410
cpp
#include <iostream> #include "Outer.hpp" #include "Splitter.hpp" using namespace std; int main() { int width = 2000, height = 2000, nbSplit = 50; Splitter splitter(width, height); for (int i = 0 ; i < nbSplit ; i++) splitter.split(Point(rand() % width, rand() % height), Point(rand() % width, rand() % height)); Layout l(splitter.getShapes()); cout << debugOutputSVG(l); }
[ "vrobles@enseirb-matmeca.fr" ]
vrobles@enseirb-matmeca.fr
c26c0d55e48228f06762b775339116ab9416d3d1
44f04b8f2b6c0dba51f1e998985d3a9e8540715f
/UESTC/1058/E.cpp
7c2f5cc3302aa1bf9f2566cb30256e55bc3ad123
[]
no_license
GuessEver/ACMICPCSolutions
2dd318a45939711eff1dd208cffc05a029b38130
909927778efd77ca9ec8e18aed3ff22c167d2a33
refs/heads/master
2020-05-18T20:52:32.359955
2015-11-04T08:31:43
2015-11-04T08:31:43
29,720,059
5
3
null
null
null
null
UTF-8
C++
false
false
2,249
cpp
#include <cstdio> #include <cctype> #include <cstring> #include <algorithm> const int N = 100000 + 10; int W, H, n, m; struct Edge{ int x1, x2, y, sign; bool operator < (const Edge &b) const { if(y == b.y) return x1 < b.x1; return y < b.y; } }edge1[N * 2], edge2[N * 2]; int num1, num2; int val[N * 4], len[N * 4]; int nextInt() { char ch; int res = 0; while(!isdigit((ch = getchar()))) ; do res = (res << 3) + (res << 1) + ch - '0'; while(isdigit((ch = getchar()))); return res; } void update(int p, int l, int r) { if(val[p] == 0) { if(l + 1 == r) len[p] = 0; else len[p] = len[p*2] + len[p*2+1]; } else len[p] = r - l; } void insert(int p, int l, int r, int a, int b, int c) { if(a <= l && b >= r) { val[p] += c; update(p, l, r); return; } int mid = (l + r) / 2; if(a < mid) insert(p*2, l, mid, a, b, c); if(b > mid) insert(p*2+1, mid, r, a, b, c); update(p, l, r); } long long solve(Edge *edge, int num, int MAX, int MAXY) { MAX = std::max(1, MAX - (m - 1)); //val[1] = 0; len[1] = 0; memset(val, 0, sizeof(val)); memset(len, 0, sizeof(len)); std::sort(edge+1, edge+num+1); long long res = 0; for(int i = 1; i <= num; i++) { int leny = edge[i+1].y - edge[i].y; //printf("[nowx: %d ~ %d] [nowy = %d] [%s] : leny = %d\n", edge[i].x1, edge[i].x2, edge[i].y, edge[i].sign == 1 ? "+" : "-", leny); insert(1, 1, MAX, edge[i].x1, std::min(MAX, edge[i].x2), edge[i].sign); if(i < num) res += 1ll * leny * len[1]; //printf("covered = %d, sol-res = %lld\n", len[1], res); } return 1ll * (MAX - 1) * (MAXY - 1) - res; } int main() { //scanf("%d%d%d%d", &W, &H, &n, &m); W = nextInt(); H = nextInt(); n = nextInt(); m = nextInt(); W++; H++; for(int i = 1; i <= n; i++) { int x1, x2, y1, y2; //scanf("%d%d%d%d", &x1, &y1, &x2, &y2); x1 = nextInt(); y1 = nextInt(); x2 = nextInt(); y2 = nextInt(); x2++; y2++; edge1[++num1] = (Edge){std::max(1, x1-m+1), x2, y1, 1}; edge1[++num1] = (Edge){std::max(1, x1-m+1), x2, y2, -1}; edge2[++num2] = (Edge){std::max(1, y1-m+1), y2, x1, 1}; edge2[++num2] = (Edge){std::max(1, y1-m+1), y2, x2, -1}; } long long res = 0; res += solve(edge1, num1, W, H); if(m > 1) res += solve(edge2, num2, H, W); printf("%lld\n", res); return 0; }
[ "jiangzh777@163.com" ]
jiangzh777@163.com
c2fc37b3078a98d420aa542049f848fdacf5db5f
040edc2bdbefe7c0d640a18d23f25a8761d62f40
/25/src/densitysimcomp.cpp
aa9f386413385d855a37c4021098bf4a31155edc
[ "BSD-2-Clause" ]
permissive
johnrsibert/tagest
9d3be8352f6bb5603fbd0eb6140589bb852ff40b
0194b1fbafe062396cc32a0f5a4bbe824341e725
refs/heads/master
2021-01-24T00:18:24.231639
2018-01-16T19:10:25
2018-01-16T19:10:25
30,438,830
3
3
null
2016-12-08T17:59:28
2015-02-07T00:05:30
C++
UTF-8
C++
false
false
5,052
cpp
//$Id: halfcomp.cpp 2754 2011-01-02 20:57:07Z jsibert $ #include <fvar.hpp> //#include "trace.h" void assignSeapodym(dmatrix& density, const dmatrix& seapodym) { int i1 = density.rowmin(); int i2 = density.rowmax(); for(int i = i1; i <= i2; i++) { int j1 = density(i).indexmin(); int j2 = density(i).indexmax(); for (int j = j1; j <= j2; j++) { density(i, j) = seapodym(i, j); } } } void startingDensity(dmatrix& density, const dmatrix& initial) { int i1 = density.rowmin(); int i2 = density.rowmax(); for (int i = i1; i <= i2; i++) { int j1 = density(i).indexmin(); int j2 = density(i).indexmax(); for (int j = j1; j <= j2; j++) { density(i, j) = initial(i, j); } } } void initialDensity(const dmatrix& density, const imatrix map, dvector& initial_density) { int i1 = density.rowmin(); int i2 = density.rowmax(); for (int i = i1; i <= i2; i++) { int j1 = density(i).indexmin(); int j2 = density(i).indexmax(); for (int j = j1; j <= j2; j++) { int k = map(i, j); initial_density(k) += density(i, j); } } } void densitycomp(const dmatrix& density, const imatrix map, const double curr_time, dmatrix& zone_density) { int i1 = density.rowmin(); int i2 = density.rowmax(); for (int i = i1; i <= i2; i++) { int j1 = density(i).indexmin(); int j2 = density(i).indexmax(); for (int j = j1; j <= j2; j++) { int k = map(i, j); zone_density(k, int(curr_time)) += density(i, j); } } } void remove_tags(dmatrix& density, const imatrix map, const int region_drop) { int i1 = density.rowmin(); int i2 = density.rowmax(); for (int i = i1; i <= i2; i++) { int j1 = density(i).indexmin(); int j2 = density(i).indexmax(); for (int j = j1; j <= j2; j++) { int k = map(i, j); if ( k == region_drop ) { density(i, j) = 0.0; } } } } void initial_prev_zs(const dvector& sum0, dvector& prev_sum) { int k1 = sum0.indexmin(); int k2 = sum0.indexmax(); for (int k = k1; k <= k2; k++) { prev_sum(k) = sum0(k); } } void halfcomp(const dmatrix& density, dmatrix& prev_density, const double curr_time, double& prev_time, const double half, const dmatrix& ini_density, dmatrix& half_life) { int i1 = density.rowmin(); int i2 = density.rowmax(); for (int i = i1; i <= i2; i++) { int j1 = density(i).indexmin(); int j2 = density(i).indexmax(); for (int j = j1; j <= j2; j++) { if ( (half_life(i,j) < 0.0) && ((density(i,j)/ini_density(i,j)) <= half) ) { double b = (density(i,j)-prev_density(i,j))/(curr_time-prev_time); half_life(i,j) = (b*prev_time + half - prev_density(i,j))/b; } } } prev_density = density; //prev_time = curr_time; } void update_average(const dmatrix& current, dmatrix& average, const double& curr_time, double& prev_time) { double w = curr_time; double w1 = prev_time; int i1 = average.rowmin(); int i2 = average.rowmax(); for (int i = i1; i <= i2; i++) { int j1 = average(i).indexmin(); int j2 = average(i).indexmax(); for (int j = j1; j <= j2; j++) { average(i,j) = (w1*average(i,j)+current(i,j))/w; } } //prev_time = curr_time; } void halfcomp(const dmatrix& density, const imatrix map, dvector& sum0, dvector& prev_sum, dvector& cur_sum, const double cur_time, double& prev_time, const double half, dvector& half_life) { cur_sum.initialize(); int i1 = density.rowmin(); int i2 = density.rowmax(); for (int i = i1; i <= i2; i++) { int j1 = density(i).indexmin(); int j2 = density(i).indexmax(); for (int j = j1; j <= j2; j++) { int k = map(i,j); cur_sum(k) += density(i,j); } } if (sum(sum0) <= 0.0) { sum0 = cur_sum; } else { int k1 = sum0.indexmin(); int k2 = sum0.indexmax(); for (int k = k1; k <= k2; k++) { if ( (half_life(k) < 0.0) && (sum0(k) > 0.0) && (cur_sum(k)/sum0(k) <= half) ) { double yp = prev_sum(k)/sum0(k); double yc = cur_sum(k)/sum0(k); double b = (yp-yc)/(prev_time-cur_time); half_life(k) = (b*prev_time-yp+half)/b; /* if (k == 25) { TTRACE(yp,yc) TTRACE(prev_time,cur_time) TTRACE(b,half_life(k)) } */ } } } //prev_time = cur_time; prev_sum = cur_sum; } void update_average(const dvector& current, dvector& average, const double& curr_time, double& prev_time) { double w = curr_time; double w1 = prev_time; int i1 = average.indexmin(); int i2 = average.indexmax(); for (int i = i1; i <= i2; i++) { //if (current(i) > 0.0) average(i) = (w1*average(i)+current(i))/w; } //prev_time = curr_time; }
[ "thomasp@spc.int" ]
thomasp@spc.int
fad642e3a822a58e175e378996f2695c176435d9
fa2069464c2ab9866fe6d5dd656dc48670037ba0
/include/pixiu/request_utils.hpp
6f005184c6de35bfdf1a3f71605bf6d4895311dc
[ "MIT" ]
permissive
blockspacer/pixiu
2b4f881094f3876dd9a30d8acf431d5020f5a041
a75f06a363df0bdec37ff270b67ee877bfaed03a
refs/heads/master
2022-03-11T08:54:56.031718
2019-08-22T19:20:34
2019-08-22T19:20:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
495
hpp
#pragma once #include "client/request_param.hpp" namespace pixiu { using request_param = client_bits::request_param; constexpr struct MakeRequest { auto operator()( const boost::beast::http::verb method, const std::string& host, boost::string_view target, int version, nlohmann::json param ) const { request_param rp; rp.target = target; rp.method = method; rp.param = std::move(param); return rp.make_request(host, version); } } make_request; }
[ "CHChang810716@gmail.com" ]
CHChang810716@gmail.com
2bb6dc88b93399449964d90f89d4e2deca9788b3
eed6286ba5b50858eeeb113165d87611a3c1dd18
/WordGame/作业2/PlayerClass.cpp
e903f236e2c0bd8fd3fb36c5c19aadd5edadf8b3
[]
no_license
Jiaxin77/University
8270962dbe98d9705105f3e4c1c38483484aa6f1
a6d7ef48114efb589c8b2ee4def84f9e8860ba9c
refs/heads/master
2020-03-22T17:29:13.207436
2018-10-22T02:51:49
2018-10-22T02:51:49
140,394,427
0
0
null
null
null
null
GB18030
C++
false
false
3,424
cpp
#include"PlayerClass.h" using namespace std; void user::setname(string na) { name=na; } void user::setpassword(string pw) { password=pw; } string user::getname() { return name; } string user::getpassword() { return password; } Player::Player() { name="\0"; password="\0"; WStage=1;//等级 WPassedNum=0;//游戏关数 WExp=0;//经验值 } int Player::getWPassedNum() { return WPassedNum; } int Player::getWStage() { return WStage; } int Player::getWExp() { return WExp; } void Player::setWPassedNum(int PassedNum) { WPassedNum=PassedNum; } void Player::setWStage(int Stage) { WStage=Stage; } void Player::setWExp(int exp) { WExp=exp; } void Player::GameBox(word *w,const int WTotal) { int choosecount; choosecount=(((WPassedNum)/3)+1)*3; int timecount; if((WPassedNum+1)%3==1) { timecount=3000;//3s } else if((WPassedNum+1)%3==2) { timecount=2000;//2s } else if((WPassedNum+1)%3==0) { timecount=1000;//1s } int *CW=NULL; CW=new int[choosecount]; int begin=0; srand((unsigned)time(NULL)); begin=rand()%WTotal;//随机选起始位置 for(int choose=0;choose<choosecount;choose++)//取一段区域内的 { if(begin+1>WTotal) { begin=1; } else { begin=begin+1; } CW[choose]=begin-1; } int playcount=0; int correctflag=0; //每次进入游戏,经验值减少一些,这样重复玩一关的次数越多,经验值会比一次通关的人少 if(WExp!=0&&WExp-5>=0) { WExp=WExp-5; } else{ WExp=0; } cout<<"您即将进入第"<<WPassedNum+1<<"关"<<endl; cout<<"此关共有"<<choosecount<<"单词,每个单词停留时间为"<<timecount/1000<<"秒"<<endl<<endl; while(playcount<choosecount&&correctflag==0) { cout<<"第"<<playcount+1<<"单词:"<<endl; w[CW[playcount]].setUseCount(w[CW[playcount]].getUseCount()+1);//单词使用次数+1 cout<<"该单词为:"<<endl; cout<<w[CW[playcount]].getdata()<<endl; Sleep(timecount); string playerWord; system("cls"); int CINFLAG=0; while(CINFLAG==0) { cout<<"请您输入刚才出现的单词"<<endl; cin>>playerWord; if(cin.fail()) { cout<<"您的输入不符合要求!\n"; CINFLAG=0; } else { CINFLAG=1; } } if(playerWord.compare(w[CW[playcount]].getdata())==0) { correctflag=0; cout<<"恭喜您答对了!"<<endl; w[CW[playcount]].setCorrectCount(w[CW[playcount]].getCorrectCount()+1);//正确次数+1 } else { cout<<"很遗憾,本题错误!"<<endl; correctflag=1; } playcount++; } if(correctflag==0) { cout<<"恭喜您,顺利通关!"<<endl; WPassedNum++;//已过关卡数增加 int exptemp=0; for(int t=0;t<choosecount;t++) { exptemp=exptemp+w[CW[t]].getlength();//按照单词长度加经验值 } WExp=WExp+exptemp/choosecount+WPassedNum;//加平均长度 和关卡数 } if(correctflag==1) { cout<<"很遗憾,闯关失败!"<<endl; } changeStage(); cout<<"您当前用户状态为:\n"<<"已过关数:"<<WPassedNum<<"\n经验值:"<<WExp<<"\n等级:"<<WStage<<endl ; } void Player::changeStage() { WStage=WExp/10+1; }
[ "noreply@github.com" ]
Jiaxin77.noreply@github.com
24e73ff935f43b05e51172c2c8b26f94bbd4d2f7
62cd600b3ebceea112d15b0e38b3f9ea246de729
/DirectProgramming/DPC++/StructuredGrids/iso2dfd_dpcpp/src/iso2dfd.cpp
710d87051b19603f4f13180ddddf6da6daa78efe
[ "MIT" ]
permissive
varsha-madananth/oneAPI-samples
4b7637cb32670bad433c5406102a7737c0366adb
9a2afd0154bde806b1373808f8c292431523a605
refs/heads/master
2022-12-02T01:14:18.012862
2020-08-17T17:51:37
2020-08-17T17:51:37
278,158,335
0
0
MIT
2020-07-08T17:55:19
2020-07-08T17:55:18
null
UTF-8
C++
false
false
12,324
cpp
//============================================================== // Copyright © 2019 Intel Corporation // // SPDX-License-Identifier: MIT // ============================================================= // ISO2DFD: Intel® oneAPI DPC++ Language Basics Using 2D-Finite-Difference-Wave // Propagation // // ISO2DFD is a finite difference stencil kernel for solving the 2D acoustic // isotropic wave equation. Kernels in this sample are implemented as 2nd order // in space, 2nd order in time scheme without boundary conditions. Using Data // Parallel C++, the sample will explicitly run on the GPU as well as CPU to // calculate a result. If successful, the output will include GPU device name. // // A complete online tutorial for this code sample can be found at : // https://software.intel.com/en-us/articles/code-sample-two-dimensional-finite-difference-wave-propagation-in-isotropic-media-iso2dfd // // For comprehensive instructions regarding DPC++ Programming, go to // https://software.intel.com/en-us/oneapi-programming-guide // and search based on relevant terms noted in the comments. // // DPC++ material used in this code sample: // // Basic structures of DPC++: // DPC++ Queues (including device selectors and exception handlers) // DPC++ Buffers and accessors (communicate data between the host and the device) // DPC++ Kernels (including parallel_for function and range<2> objects) // #include <fstream> #include <iostream> #include <CL/sycl.hpp> #include <chrono> #include <cmath> #include <cstring> #include <stdio.h> #include "dpc_common.hpp" using namespace cl::sycl; using namespace std; /* * Parameters to define coefficients * half_length: Radius of the stencil * Sample source code is tested for half_length=1 resulting in * 2nd order Stencil finite difference kernel */ constexpr float DT = 0.002f; constexpr float DXY = 20.0f; constexpr unsigned int half_length = 1; /* * Host-Code * Utility function to display input arguments */ void Usage(const string &program_name) { cout << " Incorrect parameters\n"; cout << " Usage: "; cout << program_name << " n1 n2 Iterations\n\n"; cout << " n1 n2 : Grid sizes for the stencil\n"; cout << " Iterations : No. of timesteps.\n"; } /* * Host-Code * Function used for initialization */ void Initialize(float* ptr_prev, float* ptr_next, float* ptr_vel, size_t n_rows, size_t n_cols) { cout << "Initializing ...\n"; // Define source wavelet float wavelet[12] = {0.016387336, -0.041464937, -0.067372555, 0.386110067, 0.812723635, 0.416998396, 0.076488599, -0.059434419, 0.023680172, 0.005611435, 0.001823209, -0.000720549}; // Initialize arrays for (size_t i = 0; i < n_rows; i++) { size_t offset = i * n_cols; for (int k = 0; k < n_cols; k++) { ptr_prev[offset + k] = 0.0f; ptr_next[offset + k] = 0.0f; // pre-compute squared value of sample wave velocity v*v (v = 1500 m/s) ptr_vel[offset + k] = (1500.0f * 1500.0f); } } // Add a source to initial wavefield as an initial condition for (int s = 11; s >= 0; s--) { for (int i = n_rows / 2 - s; i < n_rows / 2 + s; i++) { size_t offset = i * n_cols; for (int k = n_cols / 2 - s; k < n_cols / 2 + s; k++) { ptr_prev[offset + k] = wavelet[s]; } } } } /* * Host-Code * Utility function to print device info */ void PrintTargetInfo(queue& q) { auto device = q.get_device(); auto max_block_size = device.get_info<info::device::max_work_group_size>(); auto max_EU_count = device.get_info<info::device::max_compute_units>(); cout<< " Running on " << device.get_info<info::device::name>()<<"\n"; cout<< " The Device Max Work Group Size is : "<< max_block_size<<"\n"; cout<< " The Device Max EUCount is : " << max_EU_count<<"\n"; } /* * Host-Code * Utility function to calculate L2-norm between resulting buffer and reference * buffer */ bool WithinEpsilon(float* output, float* reference, const size_t dim_x, const size_t dim_y, const unsigned int radius, const float delta = 0.01f) { ofstream err_file; err_file.open("error_diff.txt"); bool error = false; double norm2 = 0; for (size_t iy = 0; iy < dim_y; iy++) { for (size_t ix = 0; ix < dim_x; ix++) { if (ix >= radius && ix < (dim_x - radius) && iy >= radius && iy < (dim_y - radius)) { float difference = fabsf(*reference - *output); norm2 += difference * difference; if (difference > delta) { error = true; err_file<<" ERROR: "<<ix<<", "<<iy<<" "<<*output<<" instead of "<< *reference<<" (|e|="<<difference<<")\n"; } } ++output; ++reference; } } err_file.close(); norm2 = sqrt(norm2); if (error) printf("error (Euclidean norm): %.9e\n", norm2); return error; } /* * Host-Code * CPU implementation for wavefield modeling * Updates wavefield for the number of iterations given in nIteratons parameter */ void Iso2dfdIterationCpu(float* next, float* prev, float* vel, const float dtDIVdxy, int n_rows, int n_cols, int n_iterations) { float* swap; float value = 0.0; int gid = 0; for (unsigned int k = 0; k < n_iterations; k += 1) { for (unsigned int i = 1; i < n_rows - half_length; i += 1) { for (unsigned int j = 1; j < n_cols - half_length; j += 1) { value = 0.0; // Stencil code to update grid gid = j + (i * n_cols); value = 0.0; value += prev[gid + 1] - 2.0 * prev[gid] + prev[gid - 1]; value += prev[gid + n_cols] - 2.0 * prev[gid] + prev[gid - n_cols]; value *= dtDIVdxy * vel[gid]; next[gid] = 2.0f * prev[gid] - next[gid] + value; } } // Swap arrays swap = next; next = prev; prev = swap; } } /* * Device-Code - GPU * SYCL implementation for single iteration of iso2dfd kernel * * Range kernel is used to spawn work-items in x, y dimension * */ void Iso2dfdIterationGlobal(id<2> it, float* next, float* prev, float* vel, const float dtDIVdxy, int n_rows, int n_cols) { float value = 0.0; // Compute global id // We can use the get.global.id() function of the item variable // to compute global id. The 2D array is laid out in memory in row major // order. size_t gid_row = it.get(0); size_t gid_col = it.get(1); size_t gid = (gid_row)*n_cols + gid_col; // Computation to solve wave equation in 2D // First check if gid is inside the effective grid (not in halo) if ((gid_col >= half_length && gid_col < n_cols - half_length) && (gid_row >= half_length && gid_row < n_rows - half_length)) { // Stencil code to update grid point at position given by global id (gid) // New time step for grid point is computed based on the values of the // the immediate neighbors in both the horizontal and vertical // directions, as well as the value of grid point at a previous time step value = 0.0; value += prev[gid + 1] - 2.0 * prev[gid] + prev[gid - 1]; value += prev[gid + n_cols] - 2.0 * prev[gid] + prev[gid - n_cols]; value *= dtDIVdxy * vel[gid]; next[gid] = 2.0f * prev[gid] - next[gid] + value; } } int main(int argc, char* argv[]) { // Arrays used to update the wavefield float* prev_base; float* next_base; float* next_cpu; // Array to store wave velocity float* vel_base; bool error = false; size_t n_rows, n_cols; unsigned int n_iterations; // Read parameters try { n_rows = stoi(argv[1]); n_cols = stoi(argv[2]); n_iterations = stoi(argv[3]); } catch (...) { Usage(argv[0]); return 1; } // Compute the total size of grid size_t n_size = n_rows * n_cols; // Allocate arrays to hold wavefield and velocity prev_base = new float[n_size]; next_base = new float[n_size]; next_cpu = new float[n_size]; vel_base = new float[n_size]; // Compute constant value (delta t)^2 (delta x)^2. To be used in wavefield // update float dtDIVdxy = (DT * DT) / (DXY * DXY); // Initialize arrays and introduce initial conditions (source) Initialize(prev_base, next_base, vel_base, n_rows, n_cols); cout << "Grid Sizes: " << n_rows << " " << n_cols << "\n"; cout << "Iterations: " << n_iterations << "\n\n"; // Define device selector as 'default' default_selector device_selector; // Create a device queue using DPC++ class queue queue q(device_selector, dpc_common::exception_handler); cout << "Computing wavefield in device ..\n"; // Display info about device PrintTargetInfo(q); // Start timer dpc_common::TimeInterval t_offload; { // Begin buffer scope // Create buffers using DPC++ class buffer buffer b_next(next_base, range(n_size)); buffer b_prev(prev_base, range(n_size)); buffer b_vel(vel_base, range(n_size)); // Iterate over time steps for (unsigned int k = 0; k < n_iterations; k += 1) { // Submit command group for execution q.submit([&](auto &h) { // Create accessors auto next = b_next.get_access<access::mode::read_write>(h); auto prev = b_prev.get_access<access::mode::read_write>(h); auto vel = b_vel.get_access<access::mode::read>(h); // Define local and global range auto global_range = range<2>(n_rows, n_cols); // Send a DPC++ kernel (lambda) for parallel execution // The function that executes a single iteration is called // "iso_2dfd_iteration_global" // alternating the 'next' and 'prev' parameters which effectively // swaps their content at every iteration. if (k % 2 == 0) h.parallel_for(global_range, [=](id<2> it) { Iso2dfdIterationGlobal(it, next.get_pointer(), prev.get_pointer(), vel.get_pointer(), dtDIVdxy, n_rows, n_cols); }); else h.parallel_for(global_range, [=](id<2> it) { Iso2dfdIterationGlobal(it, prev.get_pointer(), next.get_pointer(), vel.get_pointer(), dtDIVdxy, n_rows, n_cols); }); }); } // end for } // buffer scope // Wait for commands to complete. Enforce synchronization on the command queue q.wait_and_throw(); // Compute and display time used by device auto time = t_offload.Elapsed(); cout << "Offload time: " << time << " s\n\n"; // Output final wavefield (computed by device) to binary file ofstream out_file; out_file.open("wavefield_snapshot.bin", ios::out | ios::binary); out_file.write(reinterpret_cast<char*>(next_base), n_size * sizeof(float)); out_file.close(); // Compute wavefield on CPU (for validation) cout << "Computing wavefield in CPU ..\n"; // Re-initialize arrays Initialize(prev_base, next_cpu, vel_base, n_rows, n_cols); // Compute wavefield on CPU // Start timer for CPU dpc_common::TimeInterval t_cpu; Iso2dfdIterationCpu(next_cpu, prev_base, vel_base, dtDIVdxy, n_rows, n_cols, n_iterations); // Compute and display time used by CPU time = t_cpu.Elapsed(); cout << "CPU time: " << time << " s\n\n"; // Compute error (difference between final wavefields computed in device and // CPU) error = WithinEpsilon(next_base, next_cpu, n_rows, n_cols, half_length, 0.1f); // If error greater than threshold (last parameter in error function), report if (error) cout << "Final wavefields from device and CPU are different: Error\n"; else cout << "Final wavefields from device and CPU are equivalent: Success\n"; // Output final wavefield (computed by CPU) to binary file out_file.open("wavefield_snapshot_cpu.bin", ios::out | ios::binary); out_file.write(reinterpret_cast<char*>(next_cpu), n_size * sizeof(float)); out_file.close(); cout << "Final wavefields (from device and CPU) written to disk\n"; cout << "Finished.\n"; // Cleanup delete[] prev_base; delete[] next_base; delete[] vel_base; return error ? 1 : 0; }
[ "noreply@github.com" ]
varsha-madananth.noreply@github.com
cdc55fe3b78c98ec20d72136661b2c13507d970b
a46add2ebf128c4dbe8346a59a874f2ce6c833a6
/source/Logger/Level.hpp
c207ff52090b2c040eeecf435ea128be02e27454
[ "MIT" ]
permissive
kurocha/logger
3a0f4c20d8de0e53f97f9d41b0c53c22184d54cd
e34a8b976fc983b904c091a7d75671192d015179
refs/heads/master
2020-12-03T07:52:44.159969
2019-09-14T05:18:57
2019-09-14T05:18:57
95,637,102
0
0
null
null
null
null
UTF-8
C++
false
false
1,308
hpp
// // Level.hpp // File file is part of the "Logger" project and released under the MIT License. // // Created by Samuel Williams on 28/6/2017. // Copyright, 2017, by Samuel Williams. All rights reserved. // #pragma once #include <type_traits> namespace Logger { enum class Level : unsigned { ERROR = 1, WARN = 2, INFO = 4, DEBUG = 8, ALL = (1 | 2 | 4 | 8) }; inline Level operator|(Level lhs, Level rhs) { using T = std::underlying_type<Level>::type; return static_cast<Level>(static_cast<T>(lhs) | static_cast<T>(rhs)); } inline Level& operator|=(Level & lhs, Level rhs) { using T = std::underlying_type<Level>::type; lhs = static_cast<Level>(static_cast<T>(lhs) | static_cast<T>(rhs)); return lhs; } inline bool operator&(Level lhs, Level rhs) { using T = std::underlying_type<Level>::type; return (static_cast<T>(lhs) & static_cast<T>(rhs)) != 0; } inline Level& operator&=(Level & lhs, Level rhs) { using T = std::underlying_type<Level>::type; lhs = static_cast<Level>(static_cast<T>(lhs) & static_cast<T>(rhs)); return lhs; } inline Level operator~(Level rhs) { using T = std::underlying_type<Level>::type; return static_cast<Level>(~static_cast<T>(rhs)); } const char * level_name(Level level) noexcept; }
[ "samuel.williams@oriontransfer.co.nz" ]
samuel.williams@oriontransfer.co.nz
4090a260992308622b1cc2ff12cf77a61c46e34c
c7f14ba53098a55e94780678c0ba815cf7954930
/Project 3 - boulder blast/BoulderBlast/BoulderBlast/backup during exit i really needa nap/Actor.cpp
867f24aca5b30f5d316e9fd26c44c90215bd3081
[]
no_license
TheodoreNguyen/CS32
0a07f29bba944a76e3f8b6b1e1d530ccdd900dc0
9b95a20f8572e439f8d4d97c1d06acdc1c8ffb63
refs/heads/master
2021-01-12T12:35:47.460095
2015-11-06T04:55:03
2015-11-06T04:55:03
31,944,858
0
0
null
null
null
null
UTF-8
C++
false
false
1,527
cpp
#include "Actor.h" #include "StudentWorld.h" // Students: Add code to this file (if you wish), Actor.h, StudentWorld.h, and StudentWorld.cpp void Exit::leveldone() { } void Exit::doSomething() { if (isVisible()) { if (getWorld()->getPlayer->getX() == getX() && getWorld()->getPlayer()->getY() == getY()) { getWorld()->GameWorld::playSound(SOUND_FINISHED_LEVEL); getWorld()->increaseScore(2000); getWorld()->increaseScore(getWorld()->getPlayer()->getBonus()); } } } int Player::getHpPercentage() { double hp = m_hp / 20; hp = 100 * hp; int whole = hp; return whole; } void Player::reduceBonus() { if (m_bonus > 0) m_bonus--; return; } void Player::doSomething() { if (m_hp <= 0) { setDead(); return; } int input = 0; if (this->getWorld()->getKey(input)) { switch (input) { case KEY_PRESS_DOWN: if (getY() > 0 && getWorld()->canIMoveThere(getX(), getY() - 1)) moveTo(getX(), getY() - 1); setDirection(down); break; case KEY_PRESS_UP: if (getY() < VIEW_HEIGHT - 1 && getWorld()->canIMoveThere(getX(), getY() + 1)) moveTo(getX(), getY() + 1); setDirection(up); break; case KEY_PRESS_LEFT: if (getX() > 0 && getWorld()->canIMoveThere(getX() - 1, getY())) moveTo(getX() - 1, getY()); setDirection(left); break; case KEY_PRESS_RIGHT: if (getX() < VIEW_WIDTH - 1 && getWorld()->canIMoveThere(getX() + 1, getY())) moveTo(getX() + 1, getY()); setDirection(right); break; case KEY_PRESS_ESCAPE: setDead(); return; } } }
[ "theodore.h.nguyen@outlook.com" ]
theodore.h.nguyen@outlook.com
8234c7d2a02d2fc33ee3e2b4e27d27e82dff12f3
dcea0b93c838a008367eee386b5eb10531e6d2a7
/src/instructions/src/TESTinstruction.cpp
fb44d4f944cf2f951bdd20a2798dd94ba5a2865e
[]
no_license
lazav94/TwoPassAssembler
084a7ccaa6a4f71737f1db9845e4456faf6d5763
7c3c1de07b8f42af56f1f2e7dc331960cbd7b4d6
refs/heads/master
2021-01-22T06:02:00.675495
2017-02-12T13:59:25
2017-02-12T13:59:25
81,729,123
0
0
null
null
null
null
UTF-8
C++
false
false
1,912
cpp
/* * TESTinstruction.cpp * * Created on: Aug 11, 2016 * Author: laza */ #include "TESTinstruction.h" TEST_instruction::TEST_instruction(int src, int dst) { this->src = src; this->dst = dst; } TEST_instruction::TEST_instruction(string instruction, string name, string condition, bool psw_change, Elf32_Word op_code, int src, int dst) : Instruction(instruction, name, condition, psw_change, op_code) { this->src = src; this->dst = dst; } TEST_instruction::~TEST_instruction() { } Elf32_Word TEST_instruction::read_instruction() { vector<string> words; Format::get_words(instuction, words); int shift_reg_op_code = 19; try { int arg_pos = -1; for (unsigned int i = 0; i < words.size(); i++) if (Parser::is_memonic(words[i])) { arg_pos = i; break; } if (arg_pos == -1) throw INSTRUCTION_NOT_FOUND; unsigned int arg_dst = arg_pos + 1; unsigned int arg_src = arg_pos + 2; if (words.size() - arg_pos != arg_src + 1 - arg_pos) throw EXCESS_ARGUMENTS; if (Instruction_Parser::is_register(words[arg_dst])) { this->dst = Instruction_Parser::read_register(words[arg_dst]); if(this->dst == PC || this->dst == LR || this->dst == PSW) throw NOT_ALLOWED_REG; this->op_code |= this->dst << shift_reg_op_code; } else throw NOT_REG; if (Instruction_Parser::is_register(words[arg_src])) { this->src = Instruction_Parser::read_register(words[arg_src]); if(this->src == PC || this->src == LR || this->src == PSW) throw NOT_ALLOWED_REG; shift_reg_op_code -= 5; this->op_code |= this->src << shift_reg_op_code; } else throw NOT_REG; return op_code; } catch (int id) { cout << "Exception TEST msg: " << exception_msgs[id] << endl; } catch (...) { cout << "TEST " << exception_msgs[UNKNOWN_EXCEPTION] << " Check TEST instruction!" << endl; } return 0; }
[ "lazav94@gmail.com" ]
lazav94@gmail.com
20c06a975fad8ae967c7a546d2cf25409fb0666d
f81664ad23806f837b154cd9c193b4b0a4cbecb9
/vs2003_cd01/Program Files/Microsoft Visual Studio .NET 2003/Vc7/VCWizards/ClassWiz/MFC/Simple/Templates/1033/oproppg.cpp
8b77dde9b7884f85167bcf5583be1c89fdbbd182
[]
no_license
HowlTheHusky/vs2003
7b3c5a412e76025f203b7a2bf93daed546834e68
2f9e0d77ddb69453626459221128d941c31a2330
refs/heads/master
2021-06-28T13:57:57.230418
2017-09-18T13:39:52
2017-09-18T13:39:52
103,944,102
0
4
null
null
null
null
UTF-8
C++
false
false
1,545
cpp
// [!output IMPL_FILE] : implementation file // #include "stdafx.h" #include "[!output PROJECT_NAME].h" #include "[!output HEADER_FILE]" [!if !MERGE_FILE] #ifdef _DEBUG #define new DEBUG_NEW #endif [!endif] // [!output CLASS_NAME] dialog IMPLEMENT_DYNCREATE([!output CLASS_NAME], COlePropertyPage) // Message map BEGIN_MESSAGE_MAP([!output CLASS_NAME], COlePropertyPage) END_MESSAGE_MAP() // Initialize class factory and guid // {[!output CLSID_REGISTRY_FORMAT]} IMPLEMENT_OLECREATE_EX([!output CLASS_NAME], "[!output TYPEID]", [!output CLSID_IMPLEMENT_OLECREATE_FORMAT]) // [!output CLASS_NAME]::[!output CLASS_NAME]Factory::UpdateRegistry - // Adds or removes system registry entries for [!output CLASS_NAME] BOOL [!output CLASS_NAME]::[!output CLASS_NAME]Factory::UpdateRegistry(BOOL bRegister) { // TODO: Define string resource for page type; replace '0' below with ID. if (bRegister) return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(), m_clsid, 0); else return AfxOleUnregisterClass(m_clsid, NULL); } // [!output CLASS_NAME]::[!output CLASS_NAME] - Constructor // TODO: Define string resource for page caption; replace '0' below with ID. [!output CLASS_NAME]::[!output CLASS_NAME]() : COlePropertyPage(IDD, 0) { [!if ACCESSIBILITY] EnableActiveAccessibility(); [!endif] } // [!output CLASS_NAME]::DoDataExchange - Moves data between page and properties void [!output CLASS_NAME]::DoDataExchange(CDataExchange* pDX) { DDP_PostProcessing(pDX); } // [!output CLASS_NAME] message handlers
[ "32062494+HowlTheHusky@users.noreply.github.com" ]
32062494+HowlTheHusky@users.noreply.github.com
4c10f87ba91b73d99b5d4b1c23f14de89de77614
5a54b68c4936c8e2c4af67bb280517c1932e991e
/uavobjectwidget/uavobjectbrowserfactory.cpp
572dc3abfa123cc2ee5c094715c48a0265cda6eb
[]
no_license
519984307/testpilot
538a0384dca703f7c5906f4525854c31a343eecc
798d39afd9d39724049980d619aa4505fc67fab6
refs/heads/master
2023-03-17T03:29:35.283448
2018-02-10T12:30:48
2018-02-10T12:30:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,277
cpp
/** ****************************************************************************** * * @file uavobjectbrowserfactory.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup UAVObjectBrowserPlugin UAVObject Browser Plugin * @{ * @brief The UAVObject Browser gadget plugin *****************************************************************************/ /* * 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, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "uavobjectbrowserfactory.h" #include "uavobjectbrowserwidget.h" #include "uavobjectbrowser.h" #include "uavobjectbrowserconfiguration.h" #include "uavobjectbrowseroptionspage.h" #include <coreplugin/iuavgadget.h> UAVObjectBrowserFactory::UAVObjectBrowserFactory(QObject *parent) : IUAVGadgetFactory(QString("UAVObjectBrowser"), tr("UAVObject Browser"), parent) {} UAVObjectBrowserFactory::~UAVObjectBrowserFactory() {} Core::IUAVGadget *UAVObjectBrowserFactory::createGadget(QWidget *parent) { UAVObjectBrowserWidget *gadgetWidget = new UAVObjectBrowserWidget(parent); return new UAVObjectBrowser(QString("UAVObjectBrowser"), gadgetWidget, parent); } IUAVGadgetConfiguration *UAVObjectBrowserFactory::createConfiguration(QSettings *qSettings) { return new UAVObjectBrowserConfiguration(QString("UAVObjectBrowser"), qSettings); } IOptionsPage *UAVObjectBrowserFactory::createOptionsPage(IUAVGadgetConfiguration *config) { return new UAVObjectBrowserOptionsPage(qobject_cast<UAVObjectBrowserConfiguration *>(config)); }
[ "teching.ko@gmail.com" ]
teching.ko@gmail.com
f7fd718ba06470dca586f0b4f654b2669774b6fd
277a8953fb34dcade615d30b65d5571800fffbe8
/src/main.cpp
28b5915804f40e62f2f3f4107dbbcd66eec63c4b
[]
no_license
julien-besancon/OOP_arcade_2019
528ccd7bed416fdd8bfbab0903c3fca4ebe5e72b
ce2677eb68bf6c2199e0cad135f28df05e219f1d
refs/heads/master
2021-05-26T11:11:26.235031
2020-04-08T18:30:11
2020-04-08T18:30:11
254,108,123
0
0
null
null
null
null
UTF-8
C++
false
false
818
cpp
/* ** EPITECH PROJECT, 2020 ** OOP_arcade_2019 [WSL: Ubuntu] ** File description: ** main */ #include <dlfcn.h> #include <stdio.h> #include "Core.hpp" void launch_game(Core &core) { input c = core.game->game_loop(core); if (c == restart) launch_game(core); if (c == next_game) { core.next_game(); launch_game(core); } if (c == prev_game) { core.prev_game(); launch_game(core); } } int main(int ac, char **av) { if (ac != 2) { std::cerr << "Incorrect number of arguments !" << std::endl << "Usage : ./arcade [Path to Dynamic library]" << std::endl; return (84); } Core core(av[1]); launch_game(core); delete core.graph; delete core.game; dlclose(core._game_handle); dlclose(core._graph_handle); }
[ "yanis.auer@epitech.eu" ]
yanis.auer@epitech.eu
e6fa14bdac9bcd3c0d39dcdebd772db4032f7619
ab86dd1ea843aaf24040bee448f28c9c3ecba33b
/src/dao.cpp
518fc4bd5762cec2da190c437292489b20128929
[ "Apache-2.0" ]
permissive
subbyte/sdld
14253ea51f92c60a9047ed345c5a70f586b9ad4e
39707290fc148ddc935979cbbfdd8639035b9f95
refs/heads/master
2021-01-22T09:54:12.053742
2013-11-07T17:48:35
2013-11-07T17:48:35
14,211,007
2
0
null
null
null
null
UTF-8
C++
false
false
1,668
cpp
#include <fstream> #include <cstdio> #include <dirent.h> #include <unistd.h> #include <sys/stat.h> #include "dao.h" using namespace std; DAO::DAO(char *dirname, uint32_t shingle_len) { m_shingle_len = shingle_len; m_dirname = dirname; read_filelist(); } DAO::~DAO() { for(auto it = m_filenames.begin(); it != m_filenames.end(); ++it) { delete[] *it; } m_filenames.clear(); } void DAO::read_filelist() { char *basename; DIR *dir = opendir(m_dirname); if (dir == NULL) { throw "Directory Invalid."; } struct dirent *direntry; while ((direntry = readdir(dir))) { if (direntry->d_name[0] != '.') // avoid directories such as ".", "..", ".svn" { basename = new char[strlen(direntry->d_name) + 1]; strcpy(basename, direntry->d_name); m_filenames.push_back(basename); } } closedir(dir); m_it = m_filenames.begin(); } FPS * DAO::next() { char *filename; char *basename; ifstream file; uint32_t file_size; char *content; if (m_it == m_filenames.end()) { return NULL; } basename = *m_it; ++m_it; filename = new char[strlen(m_dirname) + strlen("/") + strlen(basename) + 1]; strcpy(filename, m_dirname); strcat(filename, "/"); strcat(filename, basename); file.open(filename, ios::in|ios::binary); file.seekg(0, ios::end); file_size = file.tellg(); file.seekg(0, ios::beg); content = new char[file_size]; file.read(content, file_size); file.close(); return new FPS(basename, content, file_size, m_shingle_len); }
[ "subbyte@gmail.com" ]
subbyte@gmail.com
af2945c2abba4ecc1c062fffaf2a65e8f64b94d7
85b9ce4fb88972d9b86dce594ae4fb3acfcd0a4b
/build/Android/Release/Global Pot/app/src/main/jni/_root.RecipePage.Template3.Template4.cpp
0060301041397bfad94b84abd4a2d533efce5ba3
[]
no_license
bgirr/Global-Pot_App
16431a99e26f1c60dc16223fb388d9fd525cb5fa
c96c5a8fb95acde66fc286bcd9a5cdf160ba8b1b
refs/heads/master
2021-01-09T06:29:18.255583
2017-02-21T23:27:47
2017-02-21T23:27:47
80,985,681
0
0
null
2017-02-21T23:27:48
2017-02-05T10:29:14
C++
UTF-8
C++
false
false
10,435
cpp
// This file was generated based on 'F:\Global Pot_App\.uno\ux11\RecipePage.g.uno'. // WARNING: Changes might be lost if you edit this file directly. #include <_root.GlobalPot_FuseControlsImage_Url_Property.h> #include <_root.GlobalPot_FuseControlsTextControl_Value_Property.h> #include <_root.GlobalPot_UnoUXStringConcatOperator_Right_Property.h> #include <_root.MainView.h> #include <_root.RecipePage.Template3.h> #include <_root.RecipePage.Template3.Template4.h> #include <Fuse.Binding.h> #include <Fuse.Controls.Control.h> #include <Fuse.Controls.DockPanel.h> #include <Fuse.Controls.Grid.h> #include <Fuse.Controls.Image.h> #include <Fuse.Controls.Panel.h> #include <Fuse.Controls.Rectangle.h> #include <Fuse.Controls.Text.h> #include <Fuse.Controls.TextControl.h> #include <Fuse.Drawing.Brush.h> #include <Fuse.Drawing.StaticSolidColor.h> #include <Fuse.Elements.Element.h> #include <Fuse.Font.h> #include <Fuse.Layouts.Dock.h> #include <Fuse.Node.h> #include <Fuse.Reactive.DataBinding-1.h> #include <Fuse.Visual.h> #include <Uno.Bool.h> #include <Uno.Collections.ICollection-1.h> #include <Uno.Collections.IList-1.h> #include <Uno.Float.h> #include <Uno.Float4.h> #include <Uno.Int.h> #include <Uno.Object.h> #include <Uno.String.h> #include <Uno.UX.Property.h> #include <Uno.UX.Property-1.h> #include <Uno.UX.Selector.h> #include <Uno.UX.Size.h> #include <Uno.UX.StringConcatOperator.h> #include <Uno.UX.Unit.h> static uString* STRINGS[7]; static uType* TYPES[3]; namespace g{ // public partial sealed class RecipePage.Template3.Template4 :236 // { // static Template4() :250 static void RecipePage__Template3__Template4__cctor__fn(uType* __type) { RecipePage__Template3__Template4::__selector0_ = ::g::Uno::UX::Selector__op_Implicit(::STRINGS[0/*"Url"*/]); RecipePage__Template3__Template4::__selector1_ = ::g::Uno::UX::Selector__op_Implicit(::STRINGS[1/*"Right"*/]); RecipePage__Template3__Template4::__selector2_ = ::g::Uno::UX::Selector__op_Implicit(::STRINGS[2/*"Value"*/]); RecipePage__Template3__Template4::__selector3_ = ::g::Uno::UX::Selector__op_Implicit(::STRINGS[3/*"__gen9"*/]); } static void RecipePage__Template3__Template4_build(uType* type) { ::STRINGS[0] = uString::Const("Url"); ::STRINGS[1] = uString::Const("Right"); ::STRINGS[2] = uString::Const("Value"); ::STRINGS[3] = uString::Const("__gen9"); ::STRINGS[4] = uString::Const("ingredient.iconUrl"); ::STRINGS[5] = uString::Const("ingredient.nameDe"); ::STRINGS[6] = uString::Const("https://cookingtest-cookingtest.rhcloud.com/static/resource/img/icon/"); ::TYPES[0] = ::g::Fuse::Reactive::DataBinding_typeof()->MakeType(::g::Uno::String_typeof(), NULL); ::TYPES[1] = ::g::Uno::Collections::ICollection_typeof()->MakeType(::g::Fuse::Node_typeof(), NULL); ::TYPES[2] = ::g::Uno::Collections::ICollection_typeof()->MakeType(::g::Fuse::Binding_typeof(), NULL); type->SetFields(2, ::g::Uno::UX::Property1_typeof()->MakeType(::g::Uno::String_typeof(), NULL), offsetof(::g::RecipePage__Template3__Template4, __gen10_Right_inst1), 0, ::g::Uno::UX::Property1_typeof()->MakeType(::g::Uno::String_typeof(), NULL), offsetof(::g::RecipePage__Template3__Template4, __gen9_Url_inst1), 0, ::g::RecipePage__Template3_typeof(), offsetof(::g::RecipePage__Template3__Template4, __parent1), uFieldFlagsWeak, ::g::Fuse::Controls::Rectangle_typeof(), offsetof(::g::RecipePage__Template3__Template4, __parentInstance1), uFieldFlagsWeak, ::g::Uno::UX::Property1_typeof()->MakeType(::g::Uno::String_typeof(), NULL), offsetof(::g::RecipePage__Template3__Template4, temp_Value_inst), 0, ::g::Uno::UX::Selector_typeof(), (uintptr_t)&::g::RecipePage__Template3__Template4::__selector0_, uFieldFlagsStatic, ::g::Uno::UX::Selector_typeof(), (uintptr_t)&::g::RecipePage__Template3__Template4::__selector1_, uFieldFlagsStatic, ::g::Uno::UX::Selector_typeof(), (uintptr_t)&::g::RecipePage__Template3__Template4::__selector2_, uFieldFlagsStatic, ::g::Uno::UX::Selector_typeof(), (uintptr_t)&::g::RecipePage__Template3__Template4::__selector3_, uFieldFlagsStatic); } ::g::Uno::UX::Template_type* RecipePage__Template3__Template4_typeof() { static uSStrong< ::g::Uno::UX::Template_type*> type; if (type != NULL) return type; uTypeOptions options; options.BaseDefinition = ::g::Uno::UX::Template_typeof(); options.FieldCount = 11; options.ObjectSize = sizeof(RecipePage__Template3__Template4); options.TypeSize = sizeof(::g::Uno::UX::Template_type); type = (::g::Uno::UX::Template_type*)uClassType::New("RecipePage.Template3.Template4", options); type->fp_build_ = RecipePage__Template3__Template4_build; type->fp_cctor_ = RecipePage__Template3__Template4__cctor__fn; type->fp_New1 = (void(*)(::g::Uno::UX::Template*, uObject**))RecipePage__Template3__Template4__New1_fn; return type; } // public Template4(RecipePage.Template3 parent, Fuse.Controls.Rectangle parentInstance) :240 void RecipePage__Template3__Template4__ctor_1_fn(RecipePage__Template3__Template4* __this, ::g::RecipePage__Template3* parent, ::g::Fuse::Controls::Rectangle* parentInstance) { __this->ctor_1(parent, parentInstance); } // public override sealed object New() :253 void RecipePage__Template3__Template4__New1_fn(RecipePage__Template3__Template4* __this, uObject** __retval) { ::g::Fuse::Controls::DockPanel* self = ::g::Fuse::Controls::DockPanel::New4(); ::g::Fuse::Controls::Image* __gen91 = ::g::Fuse::Controls::Image::New3(); __this->__gen9_Url_inst1 = ::g::GlobalPot_FuseControlsImage_Url_Property::New1(__gen91, RecipePage__Template3__Template4::__selector0()); ::g::Uno::UX::StringConcatOperator* __gen101 = ::g::Uno::UX::StringConcatOperator::New2(); __this->__gen10_Right_inst1 = ::g::GlobalPot_UnoUXStringConcatOperator_Right_Property::New1(__gen101, RecipePage__Template3__Template4::__selector1()); ::g::Fuse::Controls::Text* temp = ::g::Fuse::Controls::Text::New3(); __this->temp_Value_inst = ::g::GlobalPot_FuseControlsTextControl_Value_Property::New1(temp, RecipePage__Template3__Template4::__selector2()); ::g::Fuse::Controls::Panel* temp1 = ::g::Fuse::Controls::Panel::New3(); ::g::Fuse::Reactive::DataBinding* temp2 = (::g::Fuse::Reactive::DataBinding*)::g::Fuse::Reactive::DataBinding::New1(::TYPES[0/*Fuse.Reactive.DataBinding<string>*/], __this->__gen10_Right_inst1, ::STRINGS[4/*"ingredient....*/]); ::g::Fuse::Controls::Panel* temp3 = ::g::Fuse::Controls::Panel::New3(); ::g::Fuse::Reactive::DataBinding* temp4 = (::g::Fuse::Reactive::DataBinding*)::g::Fuse::Reactive::DataBinding::New1(::TYPES[0/*Fuse.Reactive.DataBinding<string>*/], __this->temp_Value_inst, ::STRINGS[5/*"ingredient....*/]); ::g::Fuse::Drawing::StaticSolidColor* temp5 = ::g::Fuse::Drawing::StaticSolidColor::New2(::g::Uno::Float4__New2(0.0f, 0.2313726f, 0.3490196f, 1.0f)); temp1->MinWidth(::g::Uno::UX::Size__New1(40.0f, 1)); temp1->MinHeight(::g::Uno::UX::Size__New1(30.0f, 1)); temp1->Margin(::g::Uno::Float4__New2(10.0f, 0.0f, 0.0f, 0.0f)); ::g::Fuse::Controls::DockPanel::SetDock(temp1, 0); ::g::Fuse::Controls::Grid::SetColumn(temp1, 2); ::g::Uno::Collections::ICollection::Add_ex(uInterface(uPtr(temp1->Children()), ::TYPES[1/*Uno.Collections.ICollection<Fuse.Node>*/]), __gen91); __gen91->MaxWidth(::g::Uno::UX::Size__New1(30.0f, 1)); __gen91->MaxHeight(::g::Uno::UX::Size__New1(30.0f, 1)); __gen91->Margin(::g::Uno::Float4__New2(5.0f, 0.0f, 0.0f, 0.0f)); __gen91->Name(RecipePage__Template3__Template4::__selector3()); ::g::Fuse::Controls::DockPanel::SetDock(__gen91, 0); ::g::Uno::Collections::ICollection::Add_ex(uInterface(uPtr(__gen91->Bindings()), ::TYPES[2/*Uno.Collections.ICollection<Fuse.Binding>*/]), temp2); __gen101->Left(::STRINGS[6/*"https://coo...*/]); __gen101->Target(__this->__gen9_Url_inst1); temp3->MinWidth(::g::Uno::UX::Size__New1(40.0f, 1)); temp3->MinHeight(::g::Uno::UX::Size__New1(30.0f, 1)); temp3->Margin(::g::Uno::Float4__New2(40.0f, 15.0f, 0.0f, 0.0f)); ::g::Fuse::Controls::Grid::SetColumn(temp3, 1); ::g::Uno::Collections::ICollection::Add_ex(uInterface(uPtr(temp3->Children()), ::TYPES[1/*Uno.Collections.ICollection<Fuse.Node>*/]), temp); temp->Color(::g::Uno::Float4__New2(1.0f, 1.0f, 1.0f, 1.0f)); temp->Margin(::g::Uno::Float4__New2(0.0f, 0.0f, 0.0f, 0.0f)); temp->Font(::g::MainView::Roboto()); ::g::Uno::Collections::ICollection::Add_ex(uInterface(uPtr(temp->Bindings()), ::TYPES[2/*Uno.Collections.ICollection<Fuse.Binding>*/]), temp4); self->Background(temp5); ::g::Uno::Collections::ICollection::Add_ex(uInterface(uPtr(self->Children()), ::TYPES[1/*Uno.Collections.ICollection<Fuse.Node>*/]), temp1); ::g::Uno::Collections::ICollection::Add_ex(uInterface(uPtr(self->Children()), ::TYPES[1/*Uno.Collections.ICollection<Fuse.Node>*/]), temp3); return *__retval = self, void(); } // public Template4 New(RecipePage.Template3 parent, Fuse.Controls.Rectangle parentInstance) :240 void RecipePage__Template3__Template4__New2_fn(::g::RecipePage__Template3* parent, ::g::Fuse::Controls::Rectangle* parentInstance, RecipePage__Template3__Template4** __retval) { *__retval = RecipePage__Template3__Template4::New2(parent, parentInstance); } ::g::Uno::UX::Selector RecipePage__Template3__Template4::__selector0_; ::g::Uno::UX::Selector RecipePage__Template3__Template4::__selector1_; ::g::Uno::UX::Selector RecipePage__Template3__Template4::__selector2_; ::g::Uno::UX::Selector RecipePage__Template3__Template4::__selector3_; // public Template4(RecipePage.Template3 parent, Fuse.Controls.Rectangle parentInstance) [instance] :240 void RecipePage__Template3__Template4::ctor_1(::g::RecipePage__Template3* parent, ::g::Fuse::Controls::Rectangle* parentInstance) { ctor_(NULL, false); __parent1 = parent; __parentInstance1 = parentInstance; } // public Template4 New(RecipePage.Template3 parent, Fuse.Controls.Rectangle parentInstance) [static] :240 RecipePage__Template3__Template4* RecipePage__Template3__Template4::New2(::g::RecipePage__Template3* parent, ::g::Fuse::Controls::Rectangle* parentInstance) { RecipePage__Template3__Template4* obj1 = (RecipePage__Template3__Template4*)uNew(RecipePage__Template3__Template4_typeof()); obj1->ctor_1(parent, parentInstance); return obj1; } // } } // ::g
[ "girr.benjamin@gmail.com" ]
girr.benjamin@gmail.com
12d4cdef2347b1c4ff86778d9047352e24115f01
510da926846b27824b55cb1bcca05907f247eb5f
/ListNodeSerializationCpp/main.cpp
361d66f11b8920bf8cd65f023b31ffe813897919
[]
no_license
VasilchukVV/ListNodeCpp
207c25652c5289cbca0dafa097e485b8b3618a50
3e417231fd58e0c98171b6d66dfeee0452d22ca7
refs/heads/master
2022-11-18T18:19:51.987109
2020-07-20T03:44:12
2020-07-20T03:44:12
281,005,484
0
0
null
null
null
null
UTF-8
C++
false
false
1,540
cpp
#include "stdafx.h" #include <sstream> using namespace list_node_sample; ostream& serialize(ostream& stream, const node_info& node_info); istream& deserialize(istream& stream, node_info& node_info); //------------------------------------------------------------------------------------------------------------- int main() { const auto serializer = create_list_node_serializer(serialize, deserialize); list_node_ptr source; const auto mode = data_generation_mode::all; auto result = generate_list_node(3, mode, source); if (FAILED(result)) return result; list_node_ptr clone; result = serializer->deep_copy(source, clone); if (FAILED(result)) return result; ostringstream oss; result = serializer->serialize(oss, clone); if (FAILED(result)) return result; oss.flush(); const string data = oss.str(); cout << data; std::istringstream iss(data); list_node_ptr copy; result = serializer->deserialize(iss, copy); if (FAILED(result)) return result; cout << source; cout << clone; return 0; } //------------------------------------------------------------------------------------------------------------- ostream& serialize(ostream& stream, const node_info& node_info) { stream << node_info.id << " "; stream << node_info.data << " "; return stream; } //------------------------------------------------------------------------------------------------------------- istream& deserialize(istream& stream, node_info& node_info) { stream >> node_info.id; stream >> node_info.data; return stream; }
[ "VasilchukVV@gmail.com" ]
VasilchukVV@gmail.com
e2c1aab4b03299431f4a066d5b19bfc8f0f52178
78a5c4c4a6881c76816769e3bae4f971c27bed82
/Room.h
c0fe805b4a81edb6cd32feaf6d607dc3fddab919
[]
no_license
StiveMan1/PSS_University_Access_System
56ce0ec6076499aaffce538b034a438c95db19dd
d4dd509e0f198b813b8e55034cc6d26d4dc7b9e4
refs/heads/main
2023-03-19T23:18:33.076015
2021-03-17T13:04:07
2021-03-17T13:04:07
348,708,901
2
0
null
2021-03-17T13:02:47
2021-03-17T12:53:38
C++
UTF-8
C++
false
false
1,981
h
// // Created by 04024 on 05.03.2021. // #ifndef PSS_AS_ROOM_H #define PSS_AS_ROOM_H #include "Users/Person.h" class Room { private: char* name; unsigned int standardAccess = 1; int specialAccessedUsers_len = 0,specialAccessedUsers_count=1; unsigned int* specialAccessedUsers = new unsigned int[1]; void resizeAccess(){ unsigned int* newSpecialAccessedUsers = new unsigned int[specialAccessedUsers_count*2]; for(int i=0;i<specialAccessedUsers_count;i++){ newSpecialAccessedUsers[i] = specialAccessedUsers[i]; } specialAccessedUsers_count<<=1; specialAccessedUsers = newSpecialAccessedUsers; } public: Room(){}; Room(char* Name,int Room_id,unsigned int StandardAccess) { this->name = Name; this->standardAccess = StandardAccess; this->room_id = Room_id; } void addInAccessed(unsigned int id){ for(int i=0;i<specialAccessedUsers_len;i++){ if(specialAccessedUsers[i] == id){ return; } } if(specialAccessedUsers_len + 1 == specialAccessedUsers_count){ resizeAccess(); } specialAccessedUsers[specialAccessedUsers_len] = id; specialAccessedUsers_len++; } void removeAccess(unsigned int id){ unsigned int* newSpecialAccessedUsers = new unsigned int[specialAccessedUsers_count]; for(int i=0,j = 0;i<specialAccessedUsers_len;i++){ if(specialAccessedUsers[i] != id){ newSpecialAccessedUsers[i-j] = specialAccessedUsers[i]; }else{ j++; } } specialAccessedUsers = newSpecialAccessedUsers; specialAccessedUsers_len --; } int room_id; bool canEnter(const Person person); char* getAccessLevel(){ return Person::AccessLevel(this->standardAccess); } char* getName(){ return this->name; } }; #endif //PSS_AS_ROOM_H
[ "39464416+StiveMan1@users.noreply.github.com" ]
39464416+StiveMan1@users.noreply.github.com
bb7eb530f62f5575622455f40d9cdb85a8b46607
b549c903ec613321b16f01818a4a861f22afc41c
/src/QDownloaderPrivate.h
28e4b168dec61a27d19f2b0b504ed666cfa8d6f1
[]
no_license
jeandet/QDownloader
206ba381ee584f6c5910923fe1a0ee71b9da5deb
3725b25223247a60d61e56e572a2cabe6437f533
refs/heads/master
2021-01-23T23:02:37.441686
2017-09-09T13:00:58
2017-09-09T13:00:58
102,950,821
0
0
null
null
null
null
UTF-8
C++
false
false
1,613
h
/*------------------------------------------------------------------------------ -- This file is a part of the QDownloader library -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS -- -- 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 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, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------*/ /*-- Author : Alexis Jeandet -- Mail : alexis.jeandet@member.fsf.org ----------------------------------------------------------------------------*/ #ifndef QDOWNLOADERPRIVATE_H #define QDOWNLOADERPRIVATE_H #include <QNetworkAccessManager> #include <QByteArray> #include <QUrl> class QDownloaderPrivate { public: QDownloaderPrivate(){} QDownloaderPrivate ( const QDownloaderPrivate & ){} QByteArray get(const QUrl& url); void get_async(const QUrl& url, std::function<void(QByteArray data)> callback); private: QNetworkAccessManager p_access_mngr; }; #endif
[ "alexis.jeandet@member.fsf.org" ]
alexis.jeandet@member.fsf.org
5951a6b0505e92a3c624a2e0b1d23de2ffa9f810
e13b9e222a53ff2bd46716c2874944f6a4441ae8
/tcpclientthread.cpp
b3d9c38540b142d9edd438aba9ca84f8f794645c
[]
no_license
lc641777437/collector_manager
ae6f654c6a8b37fede54b6ad47d9a0e98bf4c0f4
6077bb3f7a014d28717583efa4bd5657af9ecf2f
refs/heads/master
2020-04-15T22:44:06.344773
2018-11-18T10:44:54
2018-11-18T10:44:54
68,067,082
0
0
null
null
null
null
UTF-8
C++
false
false
15,629
cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include "tcpclientthread.h" extern QVector<double> times; extern QVector<double> value[16]; // value是一个vector的数组,即二维数组 extern int samplerate; /***************** 初始化 ********************************/ TcpClientThread::TcpClientThread(QString message, QObject *parent) : QThread(parent) , message(message) { pMainWindow = static_cast<MainWindow *>(parent); id = 0; last_second = -1; } TcpClientThread::~TcpClientThread() { this->wait(); qDebug() <<"(tcpclientthread.cpp)"<< this<<"over"; this->exit(); } /***************** 回掉函数 ******************************/ // 设备连接到了网络 回掉函数: void TcpClientThread::socketconnected() { timer->stop(); pMainWindow->changeState(STATE_CONNECT_SOCKET); pMainWindow->ui->pushButton_SocketConnect->setText("断开连接"); } // 接收设备的回复 回掉函数: void TcpClientThread::socketreadyread() { // 设备 对下发的命令字的回复 if(false == pMainWindow->isStartCollect) { CommandData.append(socket->readAll()); while(1){ if(CommandData.length() <= 2)break; // 格式匹配: 找到开始位置 if(CommandData[0] == 0XA6 && CommandData[1] == 0XA6){ timer->stop(); // 设备对 "设置参数" 的回复: 弹出对话框提示ok if(CommandData[2] == CMD_SET_PARAM){ if(CommandData.length() < 3)return;//length is not enough qDebug()<<endl<<endl<<"(tcpclientthread.cpp)============= 设备对 '设置参数' 的回复: ================="<<endl<<endl; QMessageBox::information(pMainWindow, tr("采集分析软件"), tr("设置参数成功!\n")); if(pMainWindow->samplerateTmp != 0)pMainWindow->samplerate = pMainWindow->samplerateTmp; } // 设备对 "获取参数" 的回复: 设备回复上传设置的参数,然后打开 “设置参数” 对话框 else if(CommandData[2] == CMD_GET_PARAM){ if(CommandData.length() < 10)return;//length is not enough qDebug()<<endl<<endl<<"(tcpclientthread.cpp)============= 设备对 '获取参数' 的回复: ================="<<endl<<endl; /********** 工程流水号 ************************/ QByteArray proId; for(int i = 10;i<58;i++){ proId.append(CommandData.at(i)); } QString proIdStr = QString(proId); qDebug()<<"qByte: "<<proId<<endl<<"str: "<<proIdStr<<endl; /********** 项目名称 ************************/ QByteArray proName; for(int i = 58;i<58+48;i++){ proName.append(CommandData.at(i)); } QString proNameStr = QString(proName); qDebug()<<"qByte: "<<proName<<endl<<"str: "<<proNameStr<<endl; /********** 测试点的名称 ************************/ QString testPointNameList[16]; for(int j = 0;j<16;j++){ QByteArray testPointName; for(int i = 10+48*2 + 24*j;i<10+48*2 + 24*(j+1);i++){ testPointName.append(CommandData.at(i)); } QString testPointName_str = QString(testPointName); testPointNameList[j] = testPointName_str; qDebug()<<"测试点"<<j<<"原数据: "<<testPointName<<endl<<"测试点名称: "<<testPointName_str<<endl; } // 根据设备的回复 打开"设置参数"的对话框 Dialog* event = new Dialog(pMainWindow, CommandData[3], CommandData[4], CommandData[5], CommandData[6], CommandData[7], CommandData[8], CommandData[9], proIdStr,proNameStr, testPointNameList); event->setModal(true); event->show(); qDebug()<<"(tcpclientthread.cpp)参数设置对话框"<<endl; } // 设备回复 "开始采集" else if(CommandData[2] == CMD_SEND_START){ if(CommandData.length() < 3)return;//length is not enough pMainWindow->isStartCollect = true; qDebug()<<endl<<endl<<"(tcpclientthread.cpp)============= 设备对 '开始采集' 的回复: ================="<<endl<<endl; QMessageBox::information(pMainWindow, tr("采集分析软件"), tr("已经开始采集!\n")); } // 设备回复 "结束采集" else if(CommandData[2] == CMD_SEND_STOP){ if(CommandData.length() < 3)return;//length is not enough qDebug()<<endl<<endl<<"(tcpclientthread.cpp)============= 设备对 '结束采集' 的回复: ================="<<endl<<endl; QMessageBox::information(pMainWindow, tr("采集分析软件"), tr("已经结束采集!\n")); } // 设备回复 "恢复出厂设置" else if(CommandData[2] == CMD_SET_FACTORY){ if(CommandData.length() < 3)return;//length is not enough qDebug()<<endl<<endl<<"(tcpclientthread.cpp)============= 设备对 '恢复出厂设置' 的回复: ================="<<endl<<endl; QMessageBox::information(pMainWindow, tr("采集分析软件"), tr("设备恢复出厂设置成功!\n")); } // 设备回复 "设置服务器" else if(CommandData[2] == CMD_SET_SERVER){ if(CommandData.length() < 3)return;//length is not enough qDebug()<<endl<<endl<<"(tcpclientthread.cpp)============= 设备对 '设置服务器' 的回复: ================="<<endl<<endl; QMessageBox::information(pMainWindow, tr("采集分析软件"), tr("设置服务器成功!\n")); } if(CommandData[2] == 0x80){ if(CommandData.length() < 3)return;//length is not enough qDebug()<<"(tcpclientthread.cpp)结束包:"<<CommandData<<endl; }else if(CommandData[2] == 0x81){ if(CommandData.length() < 3)return;//length is not enough qDebug()<<"(tcpclientthread.cpp)开始包:"<<CommandData<<endl; } else qDebug()<<"(tcpclientthread.cpp)命令字长度: "<<CommandData.length()<<",回复内容:"<<CommandData.toHex(); // 清空接收buffer CommandData.clear(); break; } else { // 移除掉前面的错误字符,继续判断 CommandData.remove(0,1); } } } // 设备 回复数据 else{ int i = 0; // 读取数据:每次读取4+16*3=52个字节 ReadData.append(socket->readAll()); qDebug()<<endl<<endl<<"(tcpclientthread.cpp)============== 设备 回复数据: ==========="<<endl; // 寻找数据开始点: 0xA5 0xA5 while(1){//remove the nothing header if(i >= ReadData.length()){ i=0; break; } if(ReadData[i] == 0XA5 && ReadData[i+1] == 0XA5){ break; } i++; } // 移除掉前面的非相关数据 if(i != 0){ ReadData.remove(0,i); } qDebug()<<"(tcpclientthread.cpp)数据长度: "<<ReadData.length()<<endl; while(1){ if(ReadData.length() < 54)break; if(ReadData[0] == 0XA5 && ReadData[1] == 0XA5){ if(ReadData[52] == 0XA5 && ReadData[53] == 0XA5){ ADValue_proc(ReadData); ReadData.remove(0,52); }else{ ReadData.remove(0,2); break; } }else{ break; } } } } // tcp连接超时 回掉函数: void TcpClientThread::tcptimeout() { QMessageBox::information(pMainWindow, tr("采集分析软件"), tr(" 设备无响应\n\n请检查设备电源或者网络是否连接正常!\n")); CommandData.clear(); timer->stop(); } /***************** 功能函数 ********************************/ // 将数据填充到画图线程需要的数组中,并保存到文件中 void TcpClientThread::ADValue_proc(QByteArray &ReadBuf) { double data[16] = {0}; double f[16] = {0}; // 扰度值 double V[16] = {0}; // 电压值 int data1,data2,data3; pMainWindow->timeCount++; // 判断哪些通道被选中 (readBuf的第(0,1没用到)2,3个字节用于标识通道是否选择) for(int j = 0; j < 2;j++){ for(int i = 0; i < 8; i++){ if(ReadBuf[j + 2] & (0x01<<(7-i))){ pMainWindow->isChannal[j * 8 + i] = 0; }else{ pMainWindow->isChannal[j * 8 + i] = 1; } } } // 16帧数据,每帧代表每个通道的值 int tmpData = 0; // 计算h值 for(int i = 0;i < 16;i++){ // 接下来的每3个字节组成一帧数据 data1 = ReadBuf[i * 3 + 4 + 0]; data1 = data1<<16; data2 = ReadBuf[i * 3 + 4 + 1]; data2 = data2<<8; data3 = ReadBuf[i * 3 + 4 + 2]; tmpData = (data1&0x00ff0000)|(data2&0x0000ff00)|(data3&0x000000ff); // 负数处理 if(tmpData&0x00800000){ tmpData = -(((~tmpData)&0x00ffffff) + 1); } // 计算H值 double tmp = 0; double coefficient = 0.0; double values = tmpData; for(int i = 0; i < 10; i++){ double tempValue = values - i * 786432.0; switch(i){ case 0: coefficient = pMainWindow->coefficient1; break; case 1: coefficient = pMainWindow->coefficient2; break; case 2: coefficient = pMainWindow->coefficient3; break; case 3: coefficient = pMainWindow->coefficient4; break; case 4: coefficient = pMainWindow->coefficient5; break; case 5: coefficient = pMainWindow->coefficient6; break; case 6: coefficient = pMainWindow->coefficient7; break; case 7: coefficient = pMainWindow->coefficient8; break; case 8: coefficient = pMainWindow->coefficient9; break; case 9: coefficient = pMainWindow->coefficient10; break; } if(tempValue > 786432.0){ tmp += 786432 * coefficient; } else if(tempValue > 0){ tmp += tempValue * coefficient; } else{ break; } } V[i] = tmp / 786432; tmp = (tmp/393216.0 - 4)/16.0*(pMainWindow->PmaxList[i] - pMainWindow->PminList[i]) + pMainWindow->PminList[i]; data[i] = tmp / (9.8 * pMainWindow->Density); // 保存初始H值 if(pMainWindow->readInitialValue){ if(pMainWindow->H[i] == 0) { pMainWindow->H[i] = data[i]; } else{ pMainWindow->H[i] = ( pMainWindow->H[i] + data[i] ) / 2.0; } } } if(pMainWindow->readInitialValue == false){ // 计算挠度值 for(int i = 0;i<16;i++){ f[i] = data[i] - pMainWindow->H[i] - (data[pMainWindow->baseValue] - pMainWindow->H[pMainWindow->baseValue]); } // 将数据添加到画图线程中去,显示画图 if(times[times.length()-1] < MAX_SHOW_TIME){ times.append(pMainWindow->timeCount * 1000.0 / pMainWindow->samplerate); // 将每个通道的值添加到相应的代表通道的数组中 for(int i = 0;i < 16;i++){ value[i].append(f[i]); } }else{ //数据左移,以便能够显示新值 time_MoveLeftInsert(pMainWindow->timeCount * 1000.0 / pMainWindow->samplerate); for(int i = 0;i < 16;i++){ data_MoveLeftInsert(i,f[i]); } } // 将数据写到文件中去 if(!pMainWindow->file.isOpen())pMainWindow->file.open( QIODevice::ReadWrite | QIODevice::Append |QIODevice::Text); QTextStream steam(&pMainWindow->file); // 数据文件保存1: 时分秒,毫秒 steam<<QTime::currentTime().toString()<<":"<<QTime::currentTime().msec()<<","; if(last_second == QTime::currentTime().second()) id++; else { id=0; last_second = QTime::currentTime().second(); } // 数据文件保存1: 递增id steam<<id<<","; // 数据文件保存1: 16个扰度值 for(int i = 0; i < 16; i++){ if(pMainWindow->isChannal[i]) steam<<f[i]<<","<<V[i]<<","; else steam<<"-,-,"; } // 数据文件保存1: 16个平均值 if(0){ for(int i = 0; i < 16; i++){ if(pMainWindow->isChannal[i]){ steam<<(f_avg[i]/200.0)<<","; f_avg[i] = 0; } else steam<<"-,"; } }else{ for(int i = 0; i < 16; i++){ if(pMainWindow->isChannal[i]){ f_avg[i] = f_avg[i] + f[i]; } } } steam<<endl; if(!pMainWindow->vfile.isOpen())pMainWindow->vfile.open( QIODevice::ReadWrite | QIODevice::Append |QIODevice::Text); QTextStream steam2(&pMainWindow->vfile); // 数据文件保存2: 时分秒,毫秒 steam2<<QTime::currentTime().toString()<<":"<<QTime::currentTime().msec()<<","; // 数据文件保存: 保存16个电压值 for(int i = 0; i < 16; i++){ if(pMainWindow->isChannal[i]) steam2<<V[i]<<","; else steam2<<"-,"; } steam2<<endl; } } // 辅助函数 -- 时间值左移 void TcpClientThread::time_MoveLeftInsert(double data) { for(int i = 0;i < times.length()-1;i++){ times[i] = times[i+1]; } times[times.length()-1] = data; } // 辅助函数 -- 数据值左移 void TcpClientThread::data_MoveLeftInsert(int channal, double data) { for(int i = 0;i < times.length()-1;i++){ value[channal][i] = value[channal][i+1]; } value[channal][times.length()-1] = data; }
[ "641777437@qq.com" ]
641777437@qq.com
d1d08d73b8efe9e21c5a868f8d28bcc8798472ca
da99e80d9c88b7783e2a5154ef6b9217fbf611e9
/MyAstroids/MoveComponent.cpp
9990e0a72b2f5059bbfcf6238afac9d69f7abc47
[]
no_license
markvanbuyten/MyAstroids
983d14fc81818b40caf401a10eff506911467687
4d98cb2b9e051c8e2d2f1403057e7152c646468f
refs/heads/master
2020-04-23T17:19:24.295896
2019-02-21T20:04:34
2019-02-21T20:04:34
171,327,780
0
0
null
null
null
null
UTF-8
C++
false
false
797
cpp
#include "MoveComponent.h" #include "Actor.h" MoveComponent::MoveComponent(Actor * owner, int updateOrder) :Component(owner, updateOrder) ,mAngularSpeed(0.0f) ,mForwardSpeed(0.0f) { } void MoveComponent::Update(float deltaTime) { if (!Math::NearZero(mAngularSpeed)) { float rotation = mOwner->GetRotation(); rotation += mAngularSpeed * deltaTime; mOwner->SetRotation(rotation); } if (!Math::NearZero(mForwardSpeed)) { Vector2 position = mOwner->GetPosition(); position += mOwner->GetForward() * mForwardSpeed * deltaTime; if (position.x < 0.0f) { position.x = 1022.0f; } else if (position.x > 1024.0f) { position.x = 2.0f; } if (position.y < 0.0f) { position.y = 766.0f; } else if (position.y > 768.0f) { position.y = 2.0f; } mOwner->SetPosition(position); } }
[ "markvanbuyten@gmail.com" ]
markvanbuyten@gmail.com
d5244461c524a17b9fb42cb7a4295fb6bd4be99b
63f7f32a914a2096a9a82b50dc29dd21a877b84d
/GeneratedFiles/soapBasicHttpBinding_USCOREIRouteServiceObject.h
3fe56bf4d96b75b073f046f4eb81ced6193f9263
[]
no_license
dabiaoluo/VirtualEarthBitmapDownload
069da5ad2ce3e45dde62364691e4529a8eaf5ad0
f886f07431ae66d469c888aa1f54ecf2bb950f7b
refs/heads/master
2021-01-14T12:58:05.021911
2014-11-04T03:42:55
2014-11-04T03:42:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,637
h
/* soapBasicHttpBinding_USCOREIRouteServiceObject.h Generated by gSOAP 2.7.13 from VirtualEarth.h Copyright(C) 2000-2009, Robert van Engelen, Genivia Inc. All Rights Reserved. This part of the software is released under one of the following licenses: GPL, the gSOAP public license, or Genivia's license for commercial use. */ #ifndef soapBasicHttpBinding_USCOREIRouteServiceObject_H #define soapBasicHttpBinding_USCOREIRouteServiceObject_H #include "soapH.h" /******************************************************************************\ * * * Service Object * * * \******************************************************************************/ class BasicHttpBinding_USCOREIRouteServiceService : public soap { public: BasicHttpBinding_USCOREIRouteServiceService() { static const struct Namespace namespaces[] = { {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope", NULL}, {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding", NULL}, {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL}, {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL}, {"ns4", "http://dev.virtualearth.net/webservices/v1/common", NULL, NULL}, {"ns5", "http://schemas.microsoft.com/2003/10/Serialization/", NULL, NULL}, {"ns7", "http://schemas.microsoft.com/2003/10/Serialization/Arrays", NULL, NULL}, {"ns1", "http://s.mappoint.net/mappoint-30/", NULL, NULL}, {"ns10", "http://dev.virtualearth.net/webservices/v1/geocode", NULL, NULL}, {"ns9", "http://dev.virtualearth.net/webservices/v1/geocode/contracts", NULL, NULL}, {"ns13", "http://dev.virtualearth.net/webservices/v1/imagery", NULL, NULL}, {"ns12", "http://dev.virtualearth.net/webservices/v1/imagery/contracts", NULL, NULL}, {"ns16", "http://dev.virtualearth.net/webservices/v1/route", NULL, NULL}, {"ns15", "http://dev.virtualearth.net/webservices/v1/route/contracts", NULL, NULL}, {"ns6", "http://dev.virtualearth.net/webservices/v1/search", NULL, NULL}, {"ns3", "http://dev.virtualearth.net/webservices/v1/search/contracts", NULL, NULL}, {NULL, NULL, NULL, NULL} }; if (!this->namespaces) this->namespaces = namespaces; }; virtual ~BasicHttpBinding_USCOREIRouteServiceService() { }; /// Bind service to port (returns master socket or SOAP_INVALID_SOCKET) virtual SOAP_SOCKET bind(const char *host, int port, int backlog) { return soap_bind(this, host, port, backlog); }; /// Accept next request (returns socket or SOAP_INVALID_SOCKET) virtual SOAP_SOCKET accept() { return soap_accept(this); }; /// Serve this request (returns error code or SOAP_OK) virtual int serve() { return soap_serve(this); }; }; /******************************************************************************\ * * * Service Operations (you should define these globally) * * * \******************************************************************************/ SOAP_FMAC5 int SOAP_FMAC6 __ns1__GetVersionInfo(struct soap*, _ns1__GetVersionInfo *ns1__GetVersionInfo, _ns1__GetVersionInfoResponse *ns1__GetVersionInfoResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns1__GetCountryRegionInfo(struct soap*, _ns1__GetCountryRegionInfo *ns1__GetCountryRegionInfo, _ns1__GetCountryRegionInfoResponse *ns1__GetCountryRegionInfoResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns1__GetEntityTypes(struct soap*, _ns1__GetEntityTypes *ns1__GetEntityTypes, _ns1__GetEntityTypesResponse *ns1__GetEntityTypesResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns1__GetDataSourceInfo(struct soap*, _ns1__GetDataSourceInfo *ns1__GetDataSourceInfo, _ns1__GetDataSourceInfoResponse *ns1__GetDataSourceInfoResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns1__GetGreatCircleDistances(struct soap*, _ns1__GetGreatCircleDistances *ns1__GetGreatCircleDistances, _ns1__GetGreatCircleDistancesResponse *ns1__GetGreatCircleDistancesResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns1__GetClientToken(struct soap*, _ns1__GetClientToken *ns1__GetClientToken, _ns1__GetClientTokenResponse *ns1__GetClientTokenResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns10__Geocode(struct soap*, _ns9__Geocode *ns9__Geocode, _ns9__GeocodeResponse *ns9__GeocodeResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns10__ReverseGeocode(struct soap*, _ns9__ReverseGeocode *ns9__ReverseGeocode, _ns9__ReverseGeocodeResponse *ns9__ReverseGeocodeResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns13__GetImageryMetadata(struct soap*, _ns12__GetImageryMetadata *ns12__GetImageryMetadata, _ns12__GetImageryMetadataResponse *ns12__GetImageryMetadataResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns13__GetMapUri(struct soap*, _ns12__GetMapUri *ns12__GetMapUri, _ns12__GetMapUriResponse *ns12__GetMapUriResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns16__CalculateRoute(struct soap*, _ns15__CalculateRoute *ns15__CalculateRoute, _ns15__CalculateRouteResponse *ns15__CalculateRouteResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns16__CalculateRoutesFromMajorRoads(struct soap*, _ns15__CalculateRoutesFromMajorRoads *ns15__CalculateRoutesFromMajorRoads, _ns15__CalculateRoutesFromMajorRoadsResponse *ns15__CalculateRoutesFromMajorRoadsResponse); SOAP_FMAC5 int SOAP_FMAC6 __ns6__Search(struct soap*, _ns3__Search *ns3__Search, _ns3__SearchResponse *ns3__SearchResponse); #endif
[ "wanglauping@gmail.com" ]
wanglauping@gmail.com
aa600d0ac987f72998e58ebf2aec43749946f30f
5330918e825f8d373d3907962ba28215182389c3
/CMGTools/H2TauTau/interface/DiObjectUpdateFactory.h
86fe248404e18b758d7592c671ceaf7c6fca93de
[]
no_license
perrozzi/cmg-cmssw
31103a7179222c7aa94f65e83d090a5cf2748e27
1f4cfd936da3a6ca78f25959a41620925c4907ca
refs/heads/CMG_PAT_V5_18_from-CMSSW_5_3_22
2021-01-16T23:15:58.556441
2017-05-11T22:43:15
2017-05-11T22:43:15
13,272,641
1
0
null
2017-05-11T22:43:16
2013-10-02T14:05:21
C++
UTF-8
C++
false
false
7,190
h
#ifndef DIOBJECTUPDATEFACTORY_H_ #define DIOBJECTUPDATEFACTORY_H_ #include "CMGTools/H2TauTau/interface/DiTauObjectFactory.h" #include "TLorentzVector.h" #include "DataFormats/Math/interface/deltaR.h" namespace cmg{ // T is for example a di-object<U, S> template< typename T> class DiObjectUpdateFactory : public cmg::Factory< T > { public: DiObjectUpdateFactory(const edm::ParameterSet& ps): // diObjectFactory_( ps ), diObjectLabel_ (ps.getParameter<edm::InputTag>("diObjectCollection")), //metLabel_ (ps.getParameter<edm::InputTag>("metCollection")), nSigma_ (ps.getParameter<double>("nSigma")), uncertainty_ (ps.getParameter<double>("uncertainty")), shift1ProngNoPi0_ (ps.getParameter<double>("shift1ProngNoPi0")), shift1Prong1Pi0_ (ps.getParameter<double>("shift1Prong1Pi0")), ptDependence1Pi0_ (ps.getParameter<double>("ptDependence1Pi0")), shift3Prong_ (ps.getParameter<double>("shift3Prong")), ptDependence3Prong_(ps.getParameter<double>("ptDependence3Prong")), shiftMet_ (ps.getParameter<bool>("shiftMet")), shiftTaus_ (ps.getParameter<bool>("shiftTaus")) {} //need to override from Factory to insert "typename" typedef typename cmg::Factory< T >::event_ptr event_ptr; virtual event_ptr create(const edm::Event&, const edm::EventSetup&); private: // const DiObjectFactory< typename T::type1, typename T::type2 > diObjectFactory_; const edm::InputTag diObjectLabel_; // const edm::InputTag metLabel_; double nSigma_; double uncertainty_; double shift1ProngNoPi0_; double shift1Prong1Pi0_; double ptDependence1Pi0_; double shift3Prong_; double ptDependence3Prong_; bool shiftMet_ ; bool shiftTaus_ ; }; } // namespace cmg template< typename T > typename cmg::DiObjectUpdateFactory<T>::event_ptr cmg::DiObjectUpdateFactory<T>::create(const edm::Event& iEvent, const edm::EventSetup&){ typedef std::vector< T > collection; edm::Handle<collection> diObjects; iEvent.getByLabel(diObjectLabel_,diObjects); edm::Handle< std::vector<reco::GenParticle> > genparticles; iEvent.getByLabel("genParticlesPruned",genparticles); typename cmg::DiObjectUpdateFactory<T>::event_ptr result(new collection); unsigned index = 0; for(typename collection::const_iterator it = diObjects->begin(); it != diObjects->end(); ++it, ++index ){ const T& diObject = *it; // assert( index < metCands->size() ); typename T::type1 leg1(diObject.leg1()); typename T::type2 leg2(diObject.leg2()); // reco::LeafCandidate met = reco::LeafCandidate( metCands->at(index) ); reco::LeafCandidate met = diObject.met(); float shift1 = 0.; float shift2 = 0.; if(typeid(typename T::type1)==typeid(cmg::Tau)) { shift1 = (nSigma_ * uncertainty_); const cmg::Tau& tau1 = dynamic_cast<const cmg::Tau&>(diObject.leg1()); if((tau1.decayMode()==0)&&(shift1ProngNoPi0_!=0)) shift1+=shift1ProngNoPi0_; //Also allow decay mode 2 according to synchronisation twiki if((tau1.decayMode()==1 || tau1.decayMode()==2)&&(shift1Prong1Pi0_!=0)) shift1+=shift1Prong1Pi0_+ptDependence1Pi0_*TMath::Min(TMath::Max(diObject.leg1().pt()-45.,0.),10.); if((tau1.decayMode()==10)&&(shift3Prong_!=0)) shift1+=shift3Prong_+ptDependence3Prong_*TMath::Min(TMath::Max(diObject.leg1().pt()-32.,0.),18.); } if(typeid(typename T::type2)==typeid(cmg::Tau)) { shift2 = (nSigma_ * uncertainty_); const cmg::Tau& tau2 = dynamic_cast<const cmg::Tau&>(diObject.leg2()); if((tau2.decayMode()==0)&&(shift1ProngNoPi0_!=0)) shift2+=shift1ProngNoPi0_; //Also allow decay mode 2 according to synchronisation twiki if((tau2.decayMode()==1 || tau2.decayMode()==2)&&(shift1Prong1Pi0_!=0)) shift2+=shift1Prong1Pi0_+ptDependence1Pi0_*TMath::Min(TMath::Max(diObject.leg2().pt()-45.,0.),10.); if((tau2.decayMode()==10)&&(shift3Prong_!=0)) shift2+=shift3Prong_+ptDependence3Prong_*TMath::Min(TMath::Max(diObject.leg2().pt()-32.,0.),18.); } // the tauES shift must be applied to *real* taus only bool l1genMatched = false ; bool l2genMatched = false ; for ( size_t i=0; i< genparticles->size(); ++i) { const reco::GenParticle &p = (*genparticles)[i]; int id = p.pdgId() ; int status = p.status() ; int motherId = 0 ; if ( p.numberOfMothers()>0 ) { //std::cout << __LINE__ << "]\tnum of mothers " << p.numberOfMothers() << "\tmy mom " << p.mother()->pdgId() << std::endl ; motherId = p.mother()->pdgId() ; } // PDG Id: e 11, mu 13, tau 15, Z 23, h 25, H 35, A 35 if ( status == 3 && abs(id) == 15 && (motherId == 23 || motherId == 25 || motherId == 35 || motherId == 36 )){ // match leg 1 if(typeid(typename T::type1)==typeid(cmg::Tau)){ const cmg::Tau& tau1 = dynamic_cast<const cmg::Tau&>(diObject.leg1()); if (deltaR(tau1.eta(),tau1.phi(),p.eta(),p.phi())<0.3) { l1genMatched = true ; //std::cout << __LINE__ << "]\tleg1 matched to a tau" << std::endl ; } } // match leg 2 if(typeid(typename T::type2)==typeid(cmg::Tau)){ const cmg::Tau& tau2 = dynamic_cast<const cmg::Tau&>(diObject.leg2()); if (deltaR(tau2.eta(),tau2.phi(),p.eta(),p.phi())<0.3) { l2genMatched = true ; //std::cout << __LINE__ << "]\tleg2 matched to a tau" << std::endl ; } } } } reco::Candidate::LorentzVector leg1Vec = diObject.leg1().p4(); reco::Candidate::LorentzVector leg2Vec = diObject.leg2().p4(); reco::Candidate::LorentzVector metVec = met.p4(); float dpx = 0.; float dpy = 0.; // if genMatched compute the transverse momentum variation dpx = l1genMatched * leg1Vec.px() * shift1 + l2genMatched * leg2Vec.px() * shift2; dpy = l1genMatched * leg1Vec.py() * shift1 + l2genMatched * leg2Vec.py() * shift2; // if genMatched apply the shift if (l1genMatched) leg1Vec *= (1. + shift1); if (l2genMatched) leg2Vec *= (1. + shift2); // apply the tranverse momentum correction to the MET math::XYZTLorentzVector deltaTauP4(dpx,dpy,0,0); math::XYZTLorentzVector scaledmetP4 = metVec - deltaTauP4; TLorentzVector metVecNew; metVecNew.SetPtEtaPhiM(scaledmetP4.Pt(),scaledmetP4.Eta(),scaledmetP4.Phi(),0.); if (shiftTaus_ ){ leg1.setP4(leg1Vec); } if (shiftTaus_ ){ leg2.setP4(leg2Vec); } if (shiftMet_ ){ met.setP4(reco::Candidate::LorentzVector(metVecNew.Px(),metVecNew.Py(),metVecNew.Pz(),metVecNew.E())); } // T diObjectNew = T(leg1,leg2); result->push_back(T(diObject)); // diObjectFactory_.set( std::make_pair(leg1, leg2), met, & result->back() ); DiTauObjectFactory< typename T::type1, typename T::type2 >::set( std::make_pair(leg1, leg2), met, &result->back() ); } return result; } #endif /*DIOBJECTUPDATEFACTORY_H_*/
[ "colin.bernet@cern.ch" ]
colin.bernet@cern.ch
aae72d3002da609f42c2d9e6c64dc6b5d837b43f
0f753714aab2b0e90469f17af834e94e2faa9c0f
/src/progs/recon_PBC_real.cpp
36475dcbac8e5a8731c17cb3da6d90fd877d9111
[]
no_license
npadmana/baorecon
b90ee4f2fb3738beb9e8ea1d5e654f6f4a0dc8eb
1147c4b9f3a46c3b84a6c2f25960d70402e57390
refs/heads/master
2016-09-08T01:22:03.082693
2014-11-28T02:40:44
2014-11-28T02:40:44
2,431,362
0
1
null
null
null
null
UTF-8
C++
false
false
7,385
cpp
#include <iostream> #include <cmath> #include <sstream> #include <iomanip> #include "Recon.h" static char help[] = "recon_PBC_real -configfn <configuration file>\n"; using namespace std; int main(int argc, char *args[]) { PetscErrorCode ierr; ierr=PetscInitialize(&argc,&args,(char *) 0, help); CHKERRQ(ierr); // Get MPI rank int rank; MPI_Comm_rank(PETSC_COMM_WORLD, &rank); // Read in configuration file char configfn[200]; PetscBool flg; // See if we need help PetscOptionsHasName(NULL, "-help", &flg); if (flg) exit(0); PetscOptionsGetString(NULL, "-configfn", configfn, 200, &flg); if (!flg) RAISE_ERR(99,"Specify configuration file"); // Read in parameters PBCParams pars(string(configfn), "PBCreal"); // Define the potential solver PotentialSolve psolve(pars.Ngrid, pars.Lbox, pars.recon.maxit); psolve.SetupOperator(REALPBC); // Loop over files list<PBCParams::fn>::iterator files; for (files = pars.fnlist.begin(); files !=pars.fnlist.end(); ++files) { /* ****************************** * First we get the various options and print out useful information * ********************************/ ostringstream hdr; hdr << "# Input file is " << files->in << endl; hdr << "# Output file is " << files->out << endl; hdr << "# Ngrid=" << setw(5) << pars.Ngrid << endl; hdr << "# boxsize=" << setw(8) << fixed << setprecision(2) << pars.Lbox << endl; hdr << "# bias=" << setw(8) << setprecision(2) << pars.recon.bias << endl; hdr << "# smooth=" << setw(8) << setprecision(2) << pars.recon.smooth << endl; hdr << "# " << setw(4) << pars.xi.Nbins << " Xi bins from " << setw(8) << setprecision(2) << pars.xi.rmin << " with spacing of " << pars.xi.dr << endl; hdr << "# " << "Correlation function smoothed with a smoothing scale of" << setw(8) << setprecision(2) << pars.xi.smooth << endl; PetscPrintf(PETSC_COMM_WORLD, (hdr.str()).c_str()); /**************************************** * Read in the particle data here and slab decompose ****************************************/ Particle pp; DensityGrid dg(pars.Ngrid, pars.Lbox); pp.TPMReadSerial(files->in.c_str(), pars.Lbox); PetscPrintf(PETSC_COMM_WORLD,"Read in %i particles.....\n",pp.npart); pp.SlabDecompose(dg); // Test slab decomp bool good = dg.TestSlabDecompose(pp); if (good) {PetscSynchronizedPrintf(PETSC_COMM_WORLD,"Slab decomposition succeeded on process %i\n",rank);} else {PetscSynchronizedPrintf(PETSC_COMM_WORLD,"Slab decomposition FAILED on process %i\n",rank);} PetscSynchronizedFlush(PETSC_COMM_WORLD); if (!good) RAISE_ERR(99, "Slab decomposition failed"); /************************************************* * Now we start working on the grid * ***********************************************/ Vec grid, gridr; PkStruct xi1(pars.xi.rmin, pars.xi.dr, pars.xi.Nbins); grid=dg.Allocate(); //CIC dg.CIC(grid, pp); VecDuplicate(grid, &gridr); VecCopy(grid, gridr); //FFTs are destructive! dg.XiFFT(gridr, pars.xi.smooth, xi1); // Smooth dg.GaussSmooth(grid, pars.recon.smooth); PetscPrintf(PETSC_COMM_WORLD,"Initial correlation function computed....\n"); /************************************************ * Now we solve for the potential ************************************************/ // Allocate potential solver Vec pot; pot = dg.Allocate(); if (psolve.Solve(grid, pot, pars.recon.bias)) { // If the potential calculation converged PetscPrintf(PETSC_COMM_WORLD,"Potential calculated....\n"); /************************************************ * Now we shift data and randoms ************************************************/ // Generate random particles Vec dp, qx, qy, qz; Particle pr; pr.RandomInit(pp.npart*pars.recon.nrandomfac, pars.Lbox, 1931); pr.SlabDecompose(dg); // Compute derivatives at data positions and shift dp = dg.Deriv(pot, 0); qx = dg.Interp3d(dp, pp); _mydestroy(dp); dp = dg.Deriv(pot, 1); qy = dg.Interp3d(dp, pp); _mydestroy(dp); dp = dg.Deriv(pot, 2); qz = dg.Interp3d(dp, pp); _mydestroy(dp); // Print some statistics double sum[3]; VecSum(qx,&sum[0]); VecSum(qy, &sum[1]); VecSum(qz, &sum[2]); for (int ii=0; ii < 3; ++ii) sum[ii] /= pp.npart; PetscPrintf(PETSC_COMM_WORLD, "Mean x,y,z displacements on particles is : %10.4f,%10.4f,%10.4f\n",sum[0],sum[1],sum[2]); VecNorm(qx,NORM_2,&sum[0]); VecNorm(qy, NORM_2,&sum[1]); VecNorm(qz, NORM_2,&sum[2]); for (int ii=0; ii < 3; ++ii) sum[ii] /= sqrt(pp.npart); PetscPrintf(PETSC_COMM_WORLD, "RMS x,y,z displacements on particles is : %10.4f,%10.4f,%10.4f\n",sum[0],sum[1],sum[2]); VecAXPY(pp.px, -1.0, qx); VecAXPY(pp.py, -1.0, qy); VecAXPY(pp.pz, -1.0, qz); // Cleanup _mydestroy(qx); _mydestroy(qy); _mydestroy(qz); // Do the same for the randoms dp = dg.Deriv(pot, 0); qx = dg.Interp3d(dp, pr); _mydestroy(dp); dp = dg.Deriv(pot, 1); qy = dg.Interp3d(dp, pr); _mydestroy(dp); dp = dg.Deriv(pot, 2); qz = dg.Interp3d(dp, pr); _mydestroy(dp); VecSum(qx,&sum[0]); VecSum(qy, &sum[1]); VecSum(qz, &sum[2]); for (int ii=0; ii < 3; ++ii) sum[ii] /= pr.npart; PetscPrintf(PETSC_COMM_WORLD, "Mean x,y,z displacements on randoms is : %10.4f,%10.4f,%10.4f\n",sum[0],sum[1],sum[2]); VecNorm(qx,NORM_2,&sum[0]); VecNorm(qy, NORM_2,&sum[1]); VecNorm(qz, NORM_2,&sum[2]); for (int ii=0; ii < 3; ++ii) sum[ii] /= sqrt(pr.npart); PetscPrintf(PETSC_COMM_WORLD, "RMS x,y,z displacements on randoms is : %10.4f,%10.4f,%10.4f\n",sum[0],sum[1],sum[2]); VecAXPY(pr.px, -1.0, qx); VecAXPY(pr.py, -1.0, qy); VecAXPY(pr.pz, -1.0, qz); PetscPrintf(PETSC_COMM_WORLD,"Displacements calculated....\n"); // Clean up _mydestroy(qx); _mydestroy(qy); _mydestroy(qz); // Shifted data and random grid pp.SlabDecompose(dg); pr.SlabDecompose(dg); dg.CIC(grid, pp); dg.CIC(gridr, pr); VecAXPY(grid, -1.0, gridr); // Correlation fn PkStruct xi2(pars.xi.rmin, pars.xi.dr, pars.xi.Nbins); dg.XiFFT(grid, pars.xi.smooth, xi2); // Outputs FILE *fp; double _rvec, _xi1, _xi2, _n1; PetscFOpen(PETSC_COMM_WORLD,files->out.c_str(),"w", &fp); PetscFPrintf(PETSC_COMM_WORLD, fp, (hdr.str()).c_str()); for (int ii = xi1.lo; ii < xi1.hi; ++ii) { _xi1 = xi1(ii, _rvec, _n1); _xi2 = xi2(ii); if (_n1>0) PetscSynchronizedFPrintf(PETSC_COMM_WORLD, fp, "%6i %9.3f %15.8e %15.8e\n",ii,_rvec,_xi1,_xi2); } PetscSynchronizedFlush(PETSC_COMM_WORLD); PetscFClose(PETSC_COMM_WORLD,fp); } // Cleanup _mydestroy(grid);_mydestroy(gridr); _mydestroy(pot); } // Only call this when everything is out of scope ierr=PetscFinalize(); CHKERRQ(ierr); }
[ "nikhil.padmanabhan@yale.edu" ]
nikhil.padmanabhan@yale.edu
2518b1d9f829e02d4a6f05dadbb1ffce590166fa
6d6865725ceec1287dc18a75ed843e6190d58e66
/String/stringtest.cpp
2462c6a414ff49ab35e483b1bb5078aaf39af8f9
[]
no_license
patrickclark9/Esercizi
0edbdd5e7916f56bd83f2d810e487fd4f07e93e4
44b4f2dbd145a788c1d359098d22db6a8085e0ab
refs/heads/master
2023-03-15T08:44:35.732366
2021-03-16T09:24:44
2021-03-16T09:24:44
346,989,454
1
0
null
null
null
null
UTF-8
C++
false
false
522
cpp
#include <string> #include <iostream> #include "string.hpp" int main() { eostring n; std::string s1 = "ciao"; std::string s2 = "buonasera"; std::string s3 = "latte"; std::string s4 = "caffett"; std::string s5 = "carlot"; std::string s6 = "pari"; char c; n.insertString(s1); n.insertString(s2); n.insertString(s3); n.insertString(s4); n.insertString(s5); n.insertString(s6); n.removeEvenC(); n.nrEven(); n.printOdd(); n.printEven(); return 0; }
[ "patrickclark@outlook.it" ]
patrickclark@outlook.it
541abdb22dfaabbe5de0031df96be623728d4750
a550ff2a385e7a7498c02ac831116e4ff38f2a1c
/c++ sol/USACO/2018-2019/January/Platinum/redistricting.cpp
e021f2f2c7e70bc46358131ab95a41203b47527f
[]
no_license
TausifIqbal/CPcode
28854eca64813bf01369ec553558a8cf87111537
23292111132752f4639037ebada288f338101e32
refs/heads/master
2023-04-07T19:38:52.373971
2021-04-13T23:11:36
2021-04-13T23:11:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
902
cpp
#include <iostream> #include <cstdio> #include <algorithm> #include <set> using namespace std; #define endl '\n' int main(){ freopen("redistricting.in", "r", stdin); freopen("redistricting.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; int dif[n + 1], dp[n + 1]; dif[0] = 0; dp[0] = 0; for(int i = 1; i <= n; i++){ char c; cin >> c; dif[i] = dif[i - 1] + (c == 'H' ? 1 : -1); } multiset<int> bestdp; multiset<int> bestdif[n + 1]; bestdp.insert(0); bestdif[0].insert(0); for(int i = 1; i <= n; i++){ int minv = *bestdp.begin(); dp[i] = minv + (*bestdif[minv].begin() < dif[i] ? 0 : 1); bestdp.insert(dp[i]); bestdif[dp[i]].insert(dif[i]); if(i >= k){ bestdp.erase(bestdp.find(dp[i - k])); bestdif[dp[i - k]].erase(bestdif[dp[i - k]].find(dif[i - k])); } } cout << dp[n] << endl; return 0; }
[ "super_j@att.net" ]
super_j@att.net
f6fdd6f2df29a676f54867054083733d44e3a38c
fda4e3f7ecbb8f7b2e3c92682776c20b013f4e97
/libssoa/src/registry/registryservicerequest.cpp
4c1fbdb5409e5151c98d006afd1cdac9d7d4f046
[]
no_license
antoniomacri/sisop-soa
7f1ae01c6a56013fb38d76fc641ee2c9465e0995
bbe7932ce838ce8cab2bee7c3fc8df4d67b75aac
refs/heads/master
2021-01-11T01:23:02.021624
2016-10-12T21:02:41
2016-10-12T21:02:41
70,739,532
0
1
null
null
null
null
UTF-8
C++
false
false
791
cpp
/* * registryservicerequest.cpp */ #include <ssoa/registry/registryservicerequest.h> #include <sstream> #include <yaml-cpp/yaml.h> using std::string; namespace ssoa { RegistryMessage * RegistryServiceRequest::fromYaml(const YAML::Node& node) { if (node["type"].to<string>() != messageType()) throw std::logic_error("Message type mismatch"); string service = node["service"].to<string>(); return new RegistryServiceRequest(service); } string RegistryServiceRequest::toYaml() const { YAML::Emitter e; e << YAML::BeginMap; e << YAML::Key << "type" << YAML::Value << messageType(); e << YAML::Key << "service" << YAML::Value << service; e << YAML::EndMap; return e.c_str(); } }
[ "ing.antonio.macri@gmail.com" ]
ing.antonio.macri@gmail.com
80ec58caf299bd175668323a90f64d35c139bb96
6680910326e975c20fbe36e1aa31d35539d97c75
/progbase2/build-SR_2_Lukianets_Mykhailo-Desktop_Qt_5_8_0_GCC_64bit-Debug/moc_createdata.cpp
190814ade599af583bcf072ddfb6823bd4b53f28
[]
no_license
TGIfr/courses
9c927ac23921ec9a6f6503e0e7831f47c28060e3
99c4bc9b77a41f731d61bf7d5fa2616c610e737d
refs/heads/master
2020-03-14T08:45:50.322966
2018-05-01T11:35:12
2018-05-01T11:35:12
131,532,044
0
0
null
null
null
null
UTF-8
C++
false
false
2,699
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'createdata.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../SR_2_Lukianets_Mykhailo/createdata.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'createdata.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.8.0. 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_CreateData_t { QByteArrayData data[1]; char stringdata0[11]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_CreateData_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_CreateData_t qt_meta_stringdata_CreateData = { { QT_MOC_LITERAL(0, 0, 10) // "CreateData" }, "CreateData" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_CreateData[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount 0 // eod }; void CreateData::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { Q_UNUSED(_o); Q_UNUSED(_id); Q_UNUSED(_c); Q_UNUSED(_a); } const QMetaObject CreateData::staticMetaObject = { { &QDialog::staticMetaObject, qt_meta_stringdata_CreateData.data, qt_meta_data_CreateData, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *CreateData::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *CreateData::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_CreateData.stringdata0)) return static_cast<void*>(const_cast< CreateData*>(this)); return QDialog::qt_metacast(_clname); } int CreateData::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; return _id; } QT_WARNING_POP QT_END_MOC_NAMESPACE
[ "mihail.lukjanec@gmail.com" ]
mihail.lukjanec@gmail.com
3a149f7f2613ce0141859772dfff7da06f089291
b8eb1b1e8db64dd69bab51a038131c6ef2cb7b1e
/src/Pawn.h
bf92ed9d4c08e59c5e44c6a8ad9a696f15465627
[]
no_license
Gasia44/Advanced-Object-Oriented-Programming
f12252b1e5ab7f1b6b693c7cc6e090ee5e8e5f00
2fbd1464412ac3f94b427a9b54e56692dcbb14d0
refs/heads/master
2021-09-08T13:15:49.928299
2021-09-02T06:21:23
2021-09-02T06:21:23
225,483,804
0
0
null
null
null
null
UTF-8
C++
false
false
270
h
// // Created by gasia on 12/13/19. // #ifndef CHESS_PROJECT_PAWN_H #define CHESS_PROJECT_PAWN_H #pragma once #include "Figure.h" class Pawn: public Figure { public: Pawn(bool); ~Pawn(); bool canMove(Square*, Square*); }; #endif //CHESS_PROJECT_PAWN_H
[ "gasiaatashian@gmail.com" ]
gasiaatashian@gmail.com
6960861ae1ecef55a4b0ec18b60e4fbe1f49d3b2
46f53e9a564192eed2f40dc927af6448f8608d13
/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc
7444d1cc45c7c10fa0f6276dede62472832c8a63
[ "BSD-3-Clause" ]
permissive
sgraham/nope
deb2d106a090d71ae882ac1e32e7c371f42eaca9
f974e0c234388a330aab71a3e5bbf33c4dcfc33c
refs/heads/master
2022-12-21T01:44:15.776329
2015-03-23T17:25:47
2015-03-23T17:25:47
32,344,868
2
2
null
null
null
null
UTF-8
C++
false
false
6,280
cc
// Copyright 2014 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/run_loop.h" #include "content/common/frame_messages.h" #include "content/common/view_message_enums.h" #include "content/public/common/content_constants.h" #include "content/public/test/render_view_test.h" #include "content/renderer/pepper/plugin_power_saver_helper.h" #include "content/renderer/render_frame_impl.h" #include "content/renderer/render_view_impl.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebPluginParams.h" #include "url/gurl.h" namespace content { class PluginPowerSaverHelperTest : public RenderViewTest { public: PluginPowerSaverHelperTest() : sink_(NULL) {} RenderFrameImpl* frame() { return static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame()); } PluginPowerSaverHelper* helper() { return frame()->plugin_power_saver_helper(); } void SetUp() override { RenderViewTest::SetUp(); sink_ = &render_thread_->sink(); } blink::WebPluginParams MakeParams(const std::string& url, const std::string& poster, const std::string& width, const std::string& height) { const size_t size = 3; blink::WebVector<blink::WebString> names(size); blink::WebVector<blink::WebString> values(size); blink::WebPluginParams params; params.url = GURL(url); params.attributeNames.swap(names); params.attributeValues.swap(values); params.attributeNames[0] = "poster"; params.attributeNames[1] = "height"; params.attributeNames[2] = "width"; params.attributeValues[0] = blink::WebString::fromUTF8(poster); params.attributeValues[1] = blink::WebString::fromUTF8(height); params.attributeValues[2] = blink::WebString::fromUTF8(width); return params; } protected: IPC::TestSink* sink_; DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelperTest); }; TEST_F(PluginPowerSaverHelperTest, AllowSameOrigin) { EXPECT_FALSE(helper()->ShouldThrottleContent(GURL(), kFlashPluginName, 100, 100, nullptr)); EXPECT_FALSE(helper()->ShouldThrottleContent(GURL(), kFlashPluginName, 1000, 1000, nullptr)); } TEST_F(PluginPowerSaverHelperTest, DisallowCrossOriginUnlessLarge) { bool cross_origin_main_content = false; EXPECT_TRUE(helper()->ShouldThrottleContent(GURL("http://b.com"), kFlashPluginName, 100, 100, &cross_origin_main_content)); EXPECT_FALSE(cross_origin_main_content); EXPECT_FALSE(helper()->ShouldThrottleContent(GURL("http://b.com"), kFlashPluginName, 1000, 1000, &cross_origin_main_content)); EXPECT_TRUE(cross_origin_main_content); } TEST_F(PluginPowerSaverHelperTest, AlwaysAllowTinyContent) { bool cross_origin_main_content = false; EXPECT_FALSE( helper()->ShouldThrottleContent(GURL(), kFlashPluginName, 1, 1, nullptr)); EXPECT_FALSE(cross_origin_main_content); EXPECT_FALSE(helper()->ShouldThrottleContent(GURL("http://b.com"), kFlashPluginName, 1, 1, &cross_origin_main_content)); EXPECT_FALSE(cross_origin_main_content); EXPECT_FALSE(helper()->ShouldThrottleContent(GURL("http://b.com"), kFlashPluginName, 5, 5, &cross_origin_main_content)); EXPECT_FALSE(cross_origin_main_content); EXPECT_TRUE(helper()->ShouldThrottleContent(GURL("http://b.com"), kFlashPluginName, 10, 10, &cross_origin_main_content)); EXPECT_FALSE(cross_origin_main_content); } TEST_F(PluginPowerSaverHelperTest, TemporaryOriginWhitelist) { bool cross_origin_main_content = false; EXPECT_TRUE(helper()->ShouldThrottleContent(GURL("http://b.com"), kFlashPluginName, 100, 100, &cross_origin_main_content)); EXPECT_FALSE(cross_origin_main_content); // Clear out other messages so we find just the plugin power saver IPCs. sink_->ClearMessages(); helper()->WhitelistContentOrigin(GURL("http://b.com")); EXPECT_FALSE(helper()->ShouldThrottleContent(GURL("http://b.com"), kFlashPluginName, 100, 100, &cross_origin_main_content)); EXPECT_FALSE(cross_origin_main_content); // Test that we've sent an IPC to the browser. ASSERT_EQ(1u, sink_->message_count()); const IPC::Message* msg = sink_->GetMessageAt(0); EXPECT_EQ(FrameHostMsg_PluginContentOriginAllowed::ID, msg->type()); FrameHostMsg_PluginContentOriginAllowed::Param params; FrameHostMsg_PluginContentOriginAllowed::Read(msg, &params); EXPECT_EQ(GURL("http://b.com"), get<0>(params)); } TEST_F(PluginPowerSaverHelperTest, UnthrottleOnExPostFactoWhitelist) { base::RunLoop loop; frame()->RegisterPeripheralPlugin(GURL("http://other.com"), loop.QuitClosure()); std::set<GURL> origin_whitelist; origin_whitelist.insert(GURL("http://other.com")); frame()->OnMessageReceived(FrameMsg_UpdatePluginContentOriginWhitelist( frame()->GetRoutingID(), origin_whitelist)); // Runs until the unthrottle closure is run. loop.Run(); } TEST_F(PluginPowerSaverHelperTest, ClearWhitelistOnNavigate) { helper()->WhitelistContentOrigin(GURL("http://b.com")); EXPECT_FALSE(helper()->ShouldThrottleContent( GURL("http://b.com"), kFlashPluginName, 100, 100, nullptr)); LoadHTML("<html></html>"); EXPECT_TRUE(helper()->ShouldThrottleContent( GURL("http://b.com"), kFlashPluginName, 100, 100, nullptr)); } } // namespace content
[ "scottmg@chromium.org" ]
scottmg@chromium.org
3f245f098ab21aba54b1f6f2150ba888fdddb01e
24f26275ffcd9324998d7570ea9fda82578eeb9e
/extensions/browser/content_verifier/content_hash_unittest.cc
1d560cbe4a012e5c5b3bf2fb4911bfbf6a359e92
[ "BSD-3-Clause" ]
permissive
Vizionnation/chromenohistory
70a51193c8538d7b995000a1b2a654e70603040f
146feeb85985a6835f4b8826ad67be9195455402
refs/heads/master
2022-12-15T07:02:54.461083
2019-10-25T15:07:06
2019-10-25T15:07:06
217,557,501
2
1
BSD-3-Clause
2022-11-19T06:53:07
2019-10-25T14:58:54
null
UTF-8
C++
false
false
8,889
cc
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "extensions/browser/content_verifier/content_hash.h" #include "base/base64url.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/json/json_writer.h" #include "crypto/rsa_private_key.h" #include "crypto/sha2.h" #include "crypto/signature_creator.h" #include "extensions/browser/computed_hashes.h" #include "extensions/browser/content_hash_tree.h" #include "extensions/browser/content_verifier/test_utils.h" #include "extensions/browser/content_verifier_delegate.h" #include "extensions/browser/extension_file_task_runner.h" #include "extensions/browser/extensions_test.h" #include "extensions/browser/verified_contents.h" #include "extensions/common/constants.h" #include "extensions/common/file_util.h" #include "extensions/common/value_builder.h" #include "extensions/test/test_extension_dir.h" namespace extensions { // Helper class to create directory with extension files, including signed // hashes for content verification. class TestExtensionBuilder { public: TestExtensionBuilder() : test_content_verifier_key_(crypto::RSAPrivateKey::Create(2048)), // We have to provide explicit extension id in verified_contents.json. extension_id_(32, 'a') { base::CreateDirectory( extension_dir_.UnpackedPath().Append(kMetadataFolder)); } void WriteManifest() { extension_dir_.WriteManifest(DictionaryBuilder() .Set("manifest_version", 2) .Set("name", "Test extension") .Set("version", "1.0") .ToJSON()); } void WriteResource(base::FilePath::StringType relative_path, std::string contents) { extension_dir_.WriteFile(relative_path, contents); extension_resources_.emplace_back(base::FilePath(std::move(relative_path)), std::move(contents)); } void WriteComputedHashes() { int block_size = extension_misc::kContentVerificationDefaultBlockSize; ComputedHashes::Writer computed_hashes_writer; for (const auto& resource : extension_resources_) { std::vector<std::string> hashes; ComputedHashes::ComputeHashesForContent(resource.contents, block_size, &hashes); computed_hashes_writer.AddHashes(resource.relative_path, block_size, hashes); } ASSERT_TRUE(computed_hashes_writer.WriteToFile( file_util::GetComputedHashesPath(extension_dir_.UnpackedPath()))); } void WriteVerifiedContents() { std::unique_ptr<base::Value> payload = CreateVerifiedContents(); std::string payload_value; ASSERT_TRUE(base::JSONWriter::Write(*payload, &payload_value)); std::string payload_b64; base::Base64UrlEncode( payload_value, base::Base64UrlEncodePolicy::OMIT_PADDING, &payload_b64); std::string signature_sha256 = crypto::SHA256HashString("." + payload_b64); std::vector<uint8_t> signature_source(signature_sha256.begin(), signature_sha256.end()); std::vector<uint8_t> signature_value; ASSERT_TRUE(crypto::SignatureCreator::Sign( test_content_verifier_key_.get(), crypto::SignatureCreator::SHA256, signature_source.data(), signature_source.size(), &signature_value)); std::string signature_b64; base::Base64UrlEncode( std::string(signature_value.begin(), signature_value.end()), base::Base64UrlEncodePolicy::OMIT_PADDING, &signature_b64); std::unique_ptr<base::Value> signatures = ListBuilder() .Append(DictionaryBuilder() .Set("header", DictionaryBuilder().Set("kid", "webstore").Build()) .Set("protected", "") .Set("signature", signature_b64) .Build()) .Build(); std::unique_ptr<base::Value> verified_contents = ListBuilder() .Append(DictionaryBuilder() .Set("description", "treehash per file") .Set("signed_content", DictionaryBuilder() .Set("payload", payload_b64) .Set("signatures", std::move(signatures)) .Build()) .Build()) .Build(); std::string json; ASSERT_TRUE(base::JSONWriter::Write(*verified_contents, &json)); base::FilePath verified_contents_path = file_util::GetVerifiedContentsPath(extension_dir_.UnpackedPath()); ASSERT_EQ( static_cast<int>(json.size()), base::WriteFile(verified_contents_path, json.data(), json.size())); } std::vector<uint8_t> GetTestContentVerifierPublicKey() { std::vector<uint8_t> public_key; test_content_verifier_key_->ExportPublicKey(&public_key); return public_key; } base::FilePath extension_path() const { return extension_dir_.UnpackedPath(); } const ExtensionId& extension_id() const { return extension_id_; } private: struct ExtensionResource { ExtensionResource(base::FilePath relative_path, std::string contents) : relative_path(std::move(relative_path)), contents(std::move(contents)) {} base::FilePath relative_path; std::string contents; }; std::unique_ptr<base::Value> CreateVerifiedContents() { int block_size = extension_misc::kContentVerificationDefaultBlockSize; ListBuilder files; for (const auto& resource : extension_resources_) { base::FilePath::StringType path = VerifiedContents::NormalizeResourcePath(resource.relative_path); std::string tree_hash = ContentHash::ComputeTreeHashForContent(resource.contents, block_size); std::string tree_hash_b64; base::Base64UrlEncode( tree_hash, base::Base64UrlEncodePolicy::OMIT_PADDING, &tree_hash_b64); files.Append(DictionaryBuilder() .Set("path", path) .Set("root_hash", tree_hash_b64) .Build()); } return DictionaryBuilder() .Set("item_id", extension_id_) .Set("item_version", "1.0") .Set("content_hashes", ListBuilder() .Append(DictionaryBuilder() .Set("format", "treehash") .Set("block_size", block_size) .Set("hash_block_size", block_size) .Set("files", files.Build()) .Build()) .Build()) .Build(); } std::unique_ptr<crypto::RSAPrivateKey> test_content_verifier_key_; ExtensionId extension_id_; std::vector<ExtensionResource> extension_resources_; TestExtensionDir extension_dir_; DISALLOW_COPY_AND_ASSIGN(TestExtensionBuilder); }; class ContentHashUnittest : public ExtensionsTest { protected: ContentHashUnittest() = default; std::unique_ptr<ContentHashResult> CreateContentHash( Extension* extension, ContentVerifierDelegate::VerifierSourceType source_type, const std::vector<uint8_t>& content_verifier_public_key) { ContentHash::FetchKey key( extension->id(), extension->path(), extension->version(), mojo::NullRemote() /* url_loader_factory_remote */, GURL() /* fetch_url */, content_verifier_public_key); return ContentHashWaiter().CreateAndWaitForCallback(std::move(key), source_type); } scoped_refptr<Extension> LoadExtension(const TestExtensionBuilder& builder) { std::string error; scoped_refptr<Extension> extension = file_util::LoadExtension( builder.extension_path(), builder.extension_id(), Manifest::INTERNAL, 0 /* flags */, &error); if (!extension) ADD_FAILURE() << " error:'" << error << "'"; return extension; } }; TEST_F(ContentHashUnittest, ExtensionWithSignedHashes) { TestExtensionBuilder builder; builder.WriteManifest(); builder.WriteResource(FILE_PATH_LITERAL("background.js"), "console.log('Nothing special');"); builder.WriteVerifiedContents(); scoped_refptr<Extension> extension = LoadExtension(builder); ASSERT_NE(nullptr, extension); std::unique_ptr<ContentHashResult> result = CreateContentHash( extension.get(), ContentVerifierDelegate::VerifierSourceType::SIGNED_HASHES, builder.GetTestContentVerifierPublicKey()); DCHECK(result); EXPECT_TRUE(result->success); } } // namespace extensions
[ "rjkroege@chromium.org" ]
rjkroege@chromium.org