blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
sequencelengths
1
1
author_id
stringlengths
0
158
78c936ee22070e7987fc6ca1ad204b127c4f6093
6bdffe79068a4299e17991e36ad0115da0e0777e
/Algorithm_C/Algorithm_C/First/ConvertBinarySearchTree/ConvertBinarySearchTree.hpp
276d1603f3de85f9350175893e80bdc35e55f4ee
[]
no_license
chm994483868/AlgorithmExample
f1f5746a3fe2915d2df6d97f946e2a1e72907bb8
d44fb7d408abd3a1c7c720670cd827de8e96f2e0
refs/heads/master
2023-05-30T17:00:28.902320
2021-06-25T22:31:11
2021-06-25T22:31:11
230,116,960
0
0
null
null
null
null
UTF-8
C++
false
false
473
hpp
// // ConvertBinarySearchTree.hpp // Algorithm_C // // Created by CHM on 2020/7/20. // Copyright © 2020 CHM. All rights reserved. // #ifndef ConvertBinarySearchTree_hpp #define ConvertBinarySearchTree_hpp #include <stdio.h> #include <cstdio> using namespace std; struct BinaryTreeNode { int m_nValue; BinaryTreeNode* m_pLeft; BinaryTreeNode* m_pRight; }; BinaryTreeNode* convert(BinaryTreeNode* pRootOfTree); #endif /* ConvertBinarySearchTree_hpp */
65d8a3839d3e63662ae3501418960fef81edd4c7
9a191e6af8be8d2dd6cdd799bbbd4d532f8d6230
/process_camera/form_detector_ocv/form_det_track_svm.cpp
874c3d13c9477319f9466da4c1539f5f3c168c2a
[]
no_license
VolDonets/iron_turtle
89d2b35bcfc0f85a4081c91b203f5d00b2f973b7
68cd28a79bc83b0f9c588c93323bced95e4399b8
refs/heads/master
2023-01-04T05:16:17.578302
2020-10-19T17:13:38
2020-10-19T17:13:38
289,016,488
3
0
null
null
null
null
UTF-8
C++
false
false
4,833
cpp
// // Created by biba_bo on 2020-09-11. // #include "form_detection_processor.h" #include <chrono> FormDetectionProcessor::FormDetectionProcessor() { mutexProc.lock(); processRecognition(); } FormDetectionProcessor::~FormDetectionProcessor() { } void FormDetectionProcessor::add_frame(cv::Mat frame) { mutexRes.lock(); if (queueFrames.size() > MAX_MATS_LIST_SIZE) { queueFrames.pop_front(); queueFrames.push_back(frame); } else queueFrames.push_back(frame); mutexProc.unlock(); mutexRes.unlock(); } void FormDetectionProcessor::processRecognition() { recognitionProcessThread = std::thread([this]() { cv::Ptr<cv::Tracker> tracker; bool isNotDetectedImage = true; typedef dlib::scan_fhog_pyramid<dlib::pyramid_down<6>> image_scanner_type; dlib::object_detector<image_scanner_type> detector; dlib::deserialize(SVM_MODEL_PATH) >> detector; cv::Mat currentFrame, resizedFrame; dlib::array2d<unsigned char> dlibFormattedFrame; std::vector<cv::Rect> *tmpFormsCoords = nullptr; int newWidth = 320, newHeight = 240; double scaleCoefficient; int middle; mutexProc.lock(); mutexRes.lock(); scaleCoefficient = queueFrames.front().rows / newHeight; middle = queueFrames.front().cols / 2; mutexRes.unlock(); mutexProc.unlock(); std::chrono::steady_clock::time_point begin; std::chrono::steady_clock::time_point end; unsigned int duration; const unsigned int framerate = 1000000 / 15; while (true) { begin = std::chrono::steady_clock::now(); mutexProc.lock(); mutexRes.lock(); currentFrame = queueFrames.front(); queueFrames.pop_front(); mutexRes.unlock(); tmpFormsCoords = new std::vector<cv::Rect>(); cv::resize(currentFrame, resizedFrame, cv::Size(newWidth, newHeight)); cv::cvtColor(resizedFrame, resizedFrame, cv::COLOR_BGRA2GRAY); if (isNotDetectedImage) { dlib::assign_image(dlibFormattedFrame, dlib::cv_image<unsigned char>(resizedFrame)); std::vector<dlib::rectangle> dlibDetRectLst = detector(dlibFormattedFrame); for (int inx = 0; inx < dlibDetRectLst.size(); inx++) { tmpFormsCoords->push_back(cv::Rect(dlibDetRectLst[inx].left() * scaleCoefficient, dlibDetRectLst[inx].top() * scaleCoefficient, (dlibDetRectLst[inx].right() - dlibDetRectLst[inx].left()) * scaleCoefficient, (dlibDetRectLst[inx].bottom() - dlibDetRectLst[inx].top()) * scaleCoefficient)); } if (tmpFormsCoords->size() > 0) { isNotDetectedImage = false; cv::cvtColor(currentFrame, currentFrame, cv::COLOR_BGRA2BGR); tracker = cv::TrackerKCF::create(); tracker->init(currentFrame, cv::Rect2d(tmpFormsCoords->operator[](0).x, tmpFormsCoords->operator[](0).y, tmpFormsCoords->operator[](0).width, tmpFormsCoords->operator[](0).height)); } } else { cv::Rect2d trackedRect; cv::cvtColor(currentFrame, currentFrame, cv::COLOR_BGRA2BGR); isNotDetectedImage = !tracker->update(currentFrame, trackedRect); if (!isNotDetectedImage) { tmpFormsCoords->push_back(cv::Rect(trackedRect.x, trackedRect.y, trackedRect.width, trackedRect.height)); } } formsCoords = tmpFormsCoords; tmpFormsCoords = nullptr; end = std::chrono::steady_clock::now(); duration = std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count(); if (duration < framerate) { std::this_thread::sleep_for(std::chrono::microseconds(framerate - duration)); } else { std::this_thread::sleep_for(std::chrono::milliseconds(2)); } if (!queueFrames.empty()) mutexProc.unlock(); if (queueFrames.size() == -100) // stupid lines of code for CLion return; // } }); } std::vector<cv::Rect> *FormDetectionProcessor::getLastDetectedFaces() { return formsCoords; }
6f8631b588fca454da551c5a8922c0109d6b0cf3
6c3e97ec19839d9367432a1c4a648a06bc001a03
/AutoCorrelation/Varying p value/p95/ising.cpp
ec12379545fcaba8e32907d5661ae4a482f352d7
[]
no_license
ahxmeds/summer-project-2015
da02b85c3af3a46ea842303a7e6674ca74a12fd4
009f7834810163cc0ec1d86cd2f756ab4be0b947
refs/heads/master
2022-09-15T00:32:04.648073
2019-04-08T06:54:32
2019-04-08T06:54:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
20,201
cpp
#include<iostream> #include<stdio.h> #include<time.h> #include<fstream> #include<math.h> #include<stdlib.h> #include<string> using namespace std; //structure for Lattice type struct LATTICE { int x; int y; }; //declaring and initializing global variables const int L = 20; //length of the lattice const int N = L*L; //number of spins const int TempCounts = 501; //number of discrete temperatures used double Lattice[L][L]; //2D array to store the lattice float V[TempCounts][16]; //2D array to store the number of congfigurations at each temperature float C[TempCounts][2]; //2D array to store specific heat for the purpose of calculating entropy float Tri[TempCounts][2];//2D array to store the number of triangles with 3 unhappy and 1 unhappy bonds float T; const int monte_carlo_steps = 100000; //number of monte carlo steps int transient_steps = 5000; //number of steps to achieve equilibrium float T_begin = 5.0; //value of temperature at which we begin simulation float T_steps = 0.01; //value by which we decrement the temperature at each iteration long int seed = 2147483647; //seed value for random number generator double J1 = 0.95; //coupling constant for diagonal bonds double J2 = 1.0; //coupling constant for nearest neighbour interactions, always set to 1 double p = floor(float(J1/J2)*100 + 0.5)/100; //value of J1/J2 to two decimal places double CorrE[monte_carlo_steps]; double CorrE2[monte_carlo_steps]; //function to print the lattice, if need be void print_lattice() { for(int i=0; i<L; i++) { for(int j=0; j<L; j++) { if(Lattice[i][j]==1) cout<<"+"<<" "; else cout<<"-"<<" "; } cout<<"\n"; } cout<<"\n"; } //function to initialize the lattice randomly using an almost uniform random number generator void initialize_lattice(double Lattice[L][L]) { int i,j; double RN; for(i=0; i<L; i++) { for(j=0; j<L; j++) { RN = (double)rand()/(double)RAND_MAX; if(RN<0.5) Lattice[i][j] = 1; if(RN>=0.5) Lattice[i][j] = -1; } } } //modulus function to return positive values always int mod(int a, int b) { int r; r = a%b; if(r<0) r = r+b; return r; } //function to choose a point on the lattice randomly void choose_random_position(LATTICE &pos) { pos.x= mod(rand(),L); pos.y= mod(rand(),L); } //function to return the 2xenergy at point (x,y) double Energy_at_xy(LATTICE &position) { double Energy; Energy = Lattice[position.x][position.y]*(J2*(Lattice[position.x][mod(position.y+1,L)]+Lattice[position.x][mod(position.y-1, L)] + Lattice[mod(position.x-1,L)][position.y] + Lattice[mod(position.x+1,L)][position.y]) + J1*(Lattice[mod(position.x-1,L)][mod(position.y-1,L)] + Lattice[mod(position.x+1, L)][mod(position.y+1, L)])); return Energy; } //function to check whether flip is valid or not bool test_flip(LATTICE position, double &Del_E) { Del_E = -2*Energy_at_xy(position);//this is the change in the energy; not in 2xenergy if(Del_E<=0) //this should be Del_E <= 0 -- close to Ts, we expect to have many moves which cost zero energy return true; else if ((float)rand()/(float)((unsigned)RAND_MAX) < exp(-(float)Del_E/T)) return true; else return false; } //function to flip the spin at site (x,y) void flip_at_xy(LATTICE position) { Lattice[position.x][position.y] = -Lattice[position.x][position.y]; } //function to attain equilibrium at each temperature for 'transient steps' number of iterations void transient(void) { LATTICE position; double de = 0, t,i; for(t=1; t<=transient_steps; t++) { for (i=1; i<=N; i++) { choose_random_position(position); if(test_flip(position, de)) { flip_at_xy(position); } } } } //function to initialize the array V void initialize_V_to_zero(float V[TempCounts][16]) { int i,j; for(i=0; i<TempCounts; i++) { for(j=0; j<16; j++) V[i][j] = 0; } } //function to initialize the array Tri void initialize_Tri_to_zero(float Tri[TempCounts][2]) { int i,j; for(i=1; i<TempCounts; i++) { Tri[i][0] = 0; Tri[i][1] = 0; } } //function to return the total magnetisation of the system double Sum_Magnetisation() { int i,j; double M=0.0; for(i=0; i<L; i++) { for(j=0; j<L; j++) { M = M + pow(-1, abs(i-j))*Lattice[i][j]; } } return M; } //function to return 2x(total energy) of the system double Sum_Energy() { LATTICE position; int x,y; double E=0.0; for(x=0; x<L; x++) { position.x = x; for(y=0; y<L; y++) { position.y = y; E = E + Energy_at_xy(position); } } return E; } //function to calculate and store the number of squares with various configuration at different temperatures void HistogramVector() { int i,j; int t = round(T*int(1/T_steps)); double Lat[L][L]; //copying lattice to lat for(i=0; i<L; i++) { for(j=0; j<L; j++) { Lat[i][j] = Lattice[i][j]; } } for(i=0; i<L; i++) { for(j=0; j<L; j++) { if((i+j)%2==0) //if squares are unshaded { if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][0]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][1]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][2]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][3]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][4]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][5]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][6]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][7]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][8]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][9]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][10]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][11]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][12]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][13]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][14]++; else V[t][15]++; } else //if squares are shaded { Lat[i][j] = -1*Lat[i][j]; Lat[i][mod(j+1,L)] = -1*Lat[i][mod(j+1,L)]; Lat[mod(i+1,L)][j] = -1*Lat[mod(i+1,L)][j]; Lat[mod(i+1,L)][mod(j+1,L)] = -1*Lat[mod(i+1,L)][mod(j+1,L)]; if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][0]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][1]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][2]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][3]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][4]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][5]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][6]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][7]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][8]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][9]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][10]++; else if(Lat[i][j]==-1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][11]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==-1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][12]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==1 && Lat[mod(i+1,L)][mod(j+1,L)]==-1) V[t][13]++; else if(Lat[i][j]==1 && Lat[i][mod(j+1,L)]==1 && Lat[mod(i+1,L)][j]==-1 && Lat[mod(i+1,L)][mod(j+1,L)]==1) V[t][14]++; else V[t][15]++; Lat[i][j] = -1*Lat[i][j]; Lat[i][mod(j+1,L)] = -1*Lat[i][mod(j+1,L)]; Lat[mod(i+1,L)][j] = -1*Lat[mod(i+1,L)][j]; Lat[mod(i+1,L)][mod(j+1,L)] = -1*Lat[mod(i+1,L)][mod(j+1,L)]; } } } } //function to calculate and store the value of number of triangles with 3 unhappy/1 unhappy bond(s) at different temperatures /*void HistoTri() { int i,j; int t = round(T*int(1/T_steps)); for(i=0; i<L; i++) { for(j=0; j<L; j++) { if(Lattice[i][j] == Lattice[i][mod(j+1,L)] && Lattice[i][mod(j+1,L)] == Lattice[mod(i+1,L)][mod(j+1,L)]) Tri[t][0]++; if(Lattice[i][j] == Lattice[i][mod(j+1,L)] && Lattice[i][mod(j+1,L)] == -1*Lattice[mod(i+1,L)][mod(j+1,L)]) Tri[t][1]++; if(Lattice[i][j] == -1*Lattice[i][mod(j+1,L)] && Lattice[i][mod(j+1,L)] == Lattice[mod(i+1,L)][mod(j+1,L)]) Tri[t][1]++; if(Lattice[i][j] == -1*Lattice[i][mod(j+1,L)] && Lattice[i][mod(j+1,L)] == -1*Lattice[mod(i+1,L)][mod(j+1,L)]) Tri[t][1]++; if(Lattice[i][j] == Lattice[mod(i+1,L)][j] && Lattice[mod(i+1,L)][j] == Lattice[mod(i+1,L)][mod(j+1,L)]) Tri[t][0]++; if(Lattice[i][j] == Lattice[mod(i+1,L)][j] && Lattice[mod(i+1,L)][j] == -1*Lattice[mod(i+1,L)][mod(j+1,L)]) Tri[t][1]++; if(Lattice[i][j] == -1*Lattice[mod(i+1,L)][j] && Lattice[mod(i+1,L)][j] == Lattice[mod(i+1,L)][mod(j+1,L)]) Tri[t][1]++; if(Lattice[i][j] == -1*Lattice[mod(i+1,L)][j] && Lattice[mod(i+1,L)][j] == -1*Lattice[mod(i+1,L)][mod(j+1,L)]) Tri[t][1]++; } } } */ double avg_of_array(double A[monte_carlo_steps]) { double sum = 0.0; for(int i=0; i<monte_carlo_steps; i++) { sum += A[i]; } return sum/(double)monte_carlo_steps; } //driver function int main() { //seeding the srand function srand(seed); //declaring the file pointers and variables to store file names ofstream file1, file2, file3, file4, file5, file6, file7, file8, file9, file10, file11; string fileName1,fileName2,fileName3,fileName4,fileName5,fileName6,fileName7,fileName8,fileName9, fileName10, fileName11; //intializing the file names fileName1 = "E_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; fileName2 = "E2_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; fileName3 = "M_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; fileName4 = "Mabs_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; fileName5 = "Cv_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; fileName6 = "Chi_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; fileName7 = "BiCu_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; fileName8 = "Hist_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; fileName9 = "S_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; fileName10 = "Tri_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; fileName11 = "AutoCorr_L="+ to_string(L) +"_p="+ to_string(p)+".csv"; //opening files for storing various data file1.open(fileName1.c_str(), ios::out); file2.open(fileName2.c_str(), ios::out); file3.open(fileName3.c_str(), ios::out); file4.open(fileName4.c_str(), ios::out); file5.open(fileName5.c_str(), ios::out); file6.open(fileName6.c_str(), ios::out); file7.open(fileName7.c_str(), ios::out); file8.open(fileName8.c_str(), ios::out); file9.open(fileName9.c_str(), ios::out); file10.open(fileName10.c_str(), ios::out); file11.open(fileName11.c_str(), ios::out); //declaring and initializing various variables for storing the value of observables double Energy=0, Energy_avg=0, Energy_sq_avg=0, Energy_sum=0, Energy_sq_sum=0; double Mag=0, Mag_avg=0, Mag_sq_avg=0, Mag_sum=0, Mag_sq_sum=0; double Mag_abs=0, Mag_abs_avg=0, Mag_q_avg=0, Mag_abs_sum=0, Mag_q_sum=0; double Specific_Heat, Mag_Susceptibility, Binder_Cumulant, BiCuE; double Entropy; double CorrE_avg, CorrE2_avg, Corr, CC, CC_avg;; int t; double de=0; int i,j; LATTICE position; //initialize_Tri_to_zero(Tri); initialize_V_to_zero(V); initialize_lattice(Lattice); //this will write the first line to the file10, which stores the number of triangles with 3 unhappy/1 unhappy bonds file10<<"T"<<"\t"<<"No. of tri with 3 UH bonds"<<"\t"<<"No. of tri with 1 UH bond"<<"\n"; //Temperature loop for(T=T_begin; T>0.001; T = (round(int(1/T_steps)*(T - T_steps))/int(1/T_steps))) { cout<<"Beginning Temp="<<T<<"\n"; transient(); Energy = Sum_Energy(); //this stores 2xenergy Mag = Sum_Magnetisation(); Mag_abs = fabs(Mag); //initializing the summation variables of each observable to zero Energy_sum=0; Energy_sq_sum=0; Mag_sum=0; Mag_sq_sum=0; Mag_abs_sum=0; Mag_q_sum=0; //start of MonteCarlo loop for(i=1; i<=monte_carlo_steps; i++) { //start of Metropolis loop for(j=1; j<=N; j++) { choose_random_position(position); if(test_flip(position,de)) { flip_at_xy(position); //updating the value of observables Energy = Energy + 2*de; // de is the change in energy; however, Energy stores 2xenergy. We should have Energy = Energy + 2.*de; Mag = Mag + 2*pow(-1, abs(position.x-position.y))*Lattice[position.x][position.y]; Mag_abs = Mag_abs + fabs(Lattice[position.x][position.y]); } } //adding the observables to the summation variables Energy_sum += Energy/2.0; // CorrE[i-1] = Energy/2.0; Energy_sq_sum += (Energy/2.0)*(Energy/2.0); //CorrE2[i-1] = (Energy/2.0)*(Energy/2.0); Mag_sum += Mag; Mag_sq_sum += Mag*Mag; Mag_q_sum += Mag*Mag*Mag*Mag; Mag_abs_sum += sqrt(Mag*Mag); // accumulate_correlations(); } //averaging the observables per unit spin //CorrE_avg = avg_of_array(CorrE)/N; //CorrE2_avg = avg_of_array(CorrE2)/N; Energy_avg = Energy_sum/((float)monte_carlo_steps*N); Energy_sq_avg = Energy_sq_sum/((float)monte_carlo_steps*N); Mag_avg = Mag_sum/((float)monte_carlo_steps*N); Mag_sq_avg = Mag_sq_sum/((float)monte_carlo_steps*N); Mag_abs_avg = Mag_abs_sum/((float)monte_carlo_steps*N); Mag_q_avg = Mag_q_sum/((float)monte_carlo_steps*N); file11<<"T="<<T<<"\n"; //Calculation of Autocorrelation function for each monte carlo step for a fixed Temp T /* for(int t=0; t<monte_carlo_steps; t++) { CC = 0; for(int i=0; i<(monte_carlo_steps-t); i++) { CC += CorrE[i]*CorrE[i+t]; } CC_avg = CC/(monte_carlo_steps-t); Corr = (CC_avg - Energy_avg*Energy_avg)/(Energy_sq_avg - Energy_avg*Energy_avg); cout<<t<<"\t"<<Corr<<"\n"; file11<<t<<"\t"<<Corr<<"\n"; } file11<<"\n\n"; */ //calling functions that are used for storing the values to plot histograms // HistogramVector(); // HistoTri(); //writing to file8, which stores the number of squares with various configurations //file8<<"Config"<<"\t"<<"T = "<<T<<"\n"; t = round(T*int(1/T_steps)); //writing the values to file8 again, the number of squares in the lattice pertaining to particular configurations, at a particular temp /* for(int k=0; k<=15; k++) { file8<<k<<"\t"<<V[t][k]<<"\n"; } file8<<"\n"; */ //writing the values to file10, whose first column stores the value of temperature, T, second column stores number of triangles with //3 unhappy bonds and third column stores number of triangles with 1 unhappy bond //file10<<T<<"\t"<<Tri[t][0]<<"\t"<<Tri[t][1]<<"\n"; //calculating other observables based of the values obtained so far Specific_Heat = (Energy_sq_avg - Energy_avg*Energy_avg*N)/(T*T); Mag_Susceptibility = (Mag_sq_avg - Mag_avg*Mag_avg*N)/(T); Binder_Cumulant = 1.0 - (Mag_q_avg)/(3.0*Mag_sq_avg*Mag_sq_avg*N); //compute_autocorrelation_times(); //putting values into the C array, which will be used latter to calculate entropy C[t][0] = T; C[t][1] = Specific_Heat; //writing data to various files file1<<T<<"\t"<<Energy_avg<<"\n"; file2<<T<<"\t"<<Energy_sq_avg<<"\n"; file3<<T<<"\t"<<Mag_avg<<"\n"; file4<<T<<"\t"<<Mag_abs_avg<<"\n"; file5<<T<<"\t"<<Specific_Heat<<"\n"; file6<<T<<"\t"<<Mag_Susceptibility<<"\n"; file7<<T<<"\t"<<Binder_Cumulant<<"\n"; // file11<<T<<"\t"<<tau_e<<"\n"; // file12<<T<<"\t"<<tau_m<<"\n"; //printing a flag on the screen after the run for specific T is over cout<<"L="<<L<<"\t"<<"p="<<p<<"\t"<<"Temp = "<<T<<" is done\n"; //function call to print the lattice obtained at the end of each iteration. This also becomes the input lattice for the next interation. //comment out this function call if it takes too much time while running the code print_lattice(); } //calculating and writing data to file9, which stores the entropy at different temperatures. //the array C has been used for the purpose of calculation for(i=1; i<=TempCounts-1; i++) { Entropy = 0.0; file9<<C[i][0]<<"\t"; for(j=i; j<=TempCounts-1; j++) { Entropy += T_steps*(double((C[j][1])/(C[j][0]))); } file9<<log(2.0)-Entropy<<"\n"; } //closing the files file1.close(); file2.close(); file3.close(); file4.close(); file5.close(); file6.close(); file7.close(); file8.close(); file9.close(); file10.close(); return 0; }
6db40a5aac34e5bd1caef6b2110ac1128a3787a4
1b0cb2f91267fd688dc6b0938110eb130c36b2ec
/Blockchain.h
525e8b7b3ac8d32bc980d2ad2f39d126c08fe11d
[]
no_license
hyunsoojeon0103/Blockcpphain-with-concepts
9fcd0bfb568c6d113a2af328d7c2a01532059551
644a31898194b17e3d86f069a12ae33bc46ccb7f
refs/heads/master
2022-06-07T18:33:43.537392
2020-05-03T18:25:11
2020-05-03T18:25:11
256,936,254
0
0
null
2020-04-19T07:05:44
2020-04-19T07:05:44
null
UTF-8
C++
false
false
1,023
h
#pragma once #include <iostream> #include <vector> #include <cassert> #include <algorithm> #include "Block.h" #include "json.hpp" #include "uint256.h" template <class T> class Blockchain { public: Blockchain(const uint64_t difficulty = 6); ~Blockchain(); void add_block(Block<T> b_new); void set_n_difficulty(const uint64_t difficulty); uint64_t get_n_difficulty() const; size_t size() const; Block<T>& operator[](const uint64_t idx); const Block<T>& operator[](const uint64_t idx) const; std::vector<Block<T>>::iterator begin(); std::vector<Block<T>>::iterator end(); std::vector<Block<T>>::const_iterator cbegin() const; std::vector<Block<T>>::const_iterator cend() const; bool valid() const; template <class U> friend std::ostream& operator<<(std::ostream& out, const Blockchain<U>& bc); private: std::vector<Block<T>> v_chain; uint64_t n_difficulty; Block<T> get_last_block() const; }; #include "Blockchain.cpp"
cd2d9c2d0003c318be08ea5605ddafee4c9fcbd3
361e6e07c2c56be949ec029919d67a772620d14c
/A/lab9/main.cpp
f06517dccb5593f042f3badb1fdf93fb55112993
[]
no_license
cgmcname/Uark
f00a22ceaaa9eb916fad52543fa2cb3bdce1aa51
09cbf0550e464eeb1b18c36b44b9afca4b523e94
refs/heads/master
2020-03-19T04:36:26.459142
2018-06-26T16:19:28
2018-06-26T16:19:28
135,845,723
0
0
null
null
null
null
UTF-8
C++
false
false
1,083
cpp
#include <cstdlib> #include <iostream> using namespace std; int factorial(int n); int fibonacci(int n); void sort (int * seq, int size); void display(int * seq, int size); int main(int argc, char** argv) { int array[] = {8, 4, 2, 3, 9}; cout << "fac = " << factorial(7) << endl; cout << "fib = " << fibonacci(5) << endl; sort(array, 5); display(array, 5); return 0; } int factorial(int n) { if (n == 1) return 1; else return n * factorial(n-1); } int fibonacci(int n) { if (n == 0 || n == 1) return 1; else return fibonacci(n-1) + fibonacci(n-2); } void sort (int * seq, int size) { int tmp; if (size == 1) return; for(int i = 0; i < size; i++) if (seq[i] < seq[0]) { tmp = seq[i]; seq[i] = seq[0]; seq[0] = tmp; } sort(seq+1, size-1); } void display(int * seq, int size) { for (int i = 0; i < size; i++) cout << seq[i] << ", "; cout << endl; }
4e4f2f787732124a102b857dd8e2ab8285552715
0d616b8bd6c4688db70ef6b1523be6fcac87945d
/135/lab3/minmax.cpp
30d685c4d4c7240c59c76529a82ef404596ed13d
[]
no_license
JasonWu00/cs-master
88f1ab0918f395d751c03bb6e394e849d2f8c76e
41236bce5ed945e70bad6870cf2b71fee0ebc767
refs/heads/main
2023-04-30T12:32:01.292636
2021-05-20T16:20:35
2021-05-20T16:20:35
369,269,136
0
0
null
null
null
null
UTF-8
C++
false
false
1,071
cpp
//Modified by: Ze Hong Wu (Jason) //Email: [email protected] //Date: February 24, 2021 //Lab 3b #include <iostream> #include <cstring> #include <fstream> #include <cstdlib> #include <climits> using namespace std; int main() { ifstream fin("Current_Reservoir_Levels.tsv"); if (fin.fail()) { cerr << "File cannot be opened for reading." << endl; exit(1); // exit if failed to open the file } string junk; // new string variable getline(fin, junk); // read one line from the file double minCap = 1000; double maxCap = 0; string date; double eastSt, eastEl, westSt, westEl; //setting up vars while(fin >> date >> eastSt >> eastEl >> westSt >> westEl) { if (eastSt > maxCap) {//check for max maxCap = eastSt; } if (eastSt < minCap && eastSt) {//check for min minCap = eastSt; } } //return answers cout << "Returning max and min values " << endl; cout << "Minimum: " << minCap << endl; cout << "Maximum: " << maxCap << endl; return 0; }
0ee2bbe1f8a04e847dc4c6b100af5b50119a74f7
dfb2ab0e663534497f63c20b55580ecc12be8ce1
/red/5 week/concurrent_map.cpp
adb43f4730ea2241ab90aa9bd685d6a6c607e7a2
[]
no_license
Panda06/c-plus-plus-modern-development
192a20cf281bc8a9e5401bc0586f5e91b942c5d8
c9b80f2906e76dc5f15f21e341ca90844d6365b1
refs/heads/master
2020-03-30T22:08:55.130676
2018-10-12T04:56:17
2018-10-12T04:56:17
151,656,284
1
0
null
null
null
null
UTF-8
C++
false
false
3,323
cpp
#include "test_runner.h" #include "profile.h" #include <algorithm> #include <future> #include <mutex> #include <numeric> #include <random> #include <string> #include <vector> using namespace std; template <typename K, typename V> class ConcurrentMap { public: static_assert(is_integral_v<K>, "ConcurrentMap supports only integer keys"); struct Access { V& ref_to_value; mutex& m; ~Access() { m.unlock(); } }; explicit ConcurrentMap(size_t bucket_count): maps(vector<map<K, V>>(bucket_count)), threads(vector<mutex>(bucket_count)){} Access operator[](const K& key) { const K new_key = key >= 0 ? key : -key; threads[new_key % maps.size()].lock(); return {maps[new_key % maps.size()][key], threads[new_key % maps.size()]}; } map<K, V> BuildOrdinaryMap() { map<K, V> result; for (size_t i = 0; i < threads.size(); ++i) { threads[i].lock(); result.insert(maps[i].begin(), maps[i].end()); threads[i].unlock(); } return result; } private: vector<map<K, V>> maps; vector<mutex> threads; }; void RunConcurrentUpdates( ConcurrentMap<int, int>& cm, size_t thread_count, int key_count ) { auto kernel = [&cm, key_count](int seed) { vector<int> updates(key_count); iota(begin(updates), end(updates), -key_count / 2); shuffle(begin(updates), end(updates), default_random_engine(seed)); for (int i = 0; i < 2; ++i) { for (auto key : updates) { cm[key].ref_to_value++; } } }; vector<future<void>> futures; for (size_t i = 0; i < thread_count; ++i) { futures.push_back(async(kernel, i)); } } void TestConcurrentUpdate() { const size_t thread_count = 3; const size_t key_count = 50000; ConcurrentMap<int, int> cm(thread_count); RunConcurrentUpdates(cm, thread_count, key_count); const auto result = cm.BuildOrdinaryMap(); ASSERT_EQUAL(result.size(), key_count); for (auto& [k, v] : result) { AssertEqual(v, 6, "Key = " + to_string(k)); } } void TestReadAndWrite() { ConcurrentMap<size_t, string> cm(5); auto updater = [&cm] { for (size_t i = 0; i < 50000; ++i) { cm[i].ref_to_value += 'a'; } }; auto reader = [&cm] { vector<string> result(50000); for (size_t i = 0; i < result.size(); ++i) { result[i] = cm[i].ref_to_value; } return result; }; auto u1 = async(updater); auto r1 = async(reader); auto u2 = async(updater); auto r2 = async(reader); u1.get(); u2.get(); for (auto f : {&r1, &r2}) { auto result = f->get(); ASSERT(all_of(result.begin(), result.end(), [](const string& s) { return s.empty() || s == "a" || s == "aa"; })); } } void TestSpeedup() { { ConcurrentMap<int, int> single_lock(1); LOG_DURATION("Single lock"); RunConcurrentUpdates(single_lock, 4, 50000); } { ConcurrentMap<int, int> many_locks(100); LOG_DURATION("100 locks"); RunConcurrentUpdates(many_locks, 4, 50000); } } int main() { TestRunner tr; RUN_TEST(tr, TestConcurrentUpdate); RUN_TEST(tr, TestReadAndWrite); RUN_TEST(tr, TestSpeedup); }
2e706a0975bda8b31b77f365adaef4ec587dcd8e
74e75430e4ca2bf422017c7035580ae973c2c42e
/src/test/prevector_tests.cpp
380891f06cef09322d955ae050a66b6362185937
[ "MIT" ]
permissive
j00v/Lightcoin
9e55bad2d3e38f4c3781f62f915828cde0e51bc9
a8555320bebbf95545bc8c2841f1fadc38f5bd53
refs/heads/main
2023-05-09T07:13:28.031313
2021-06-08T22:11:45
2021-06-08T22:11:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,539
cpp
// Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <vector> #include "prevector.h" #include "random.h" #include "serialize.h" #include "streams.h" #include "test/test_Lightcoin.h" #include <boost/test/unit_test.hpp> BOOST_FIXTURE_TEST_SUITE(PrevectorTests, TestingSetup) template<unsigned int N, typename T> class prevector_tester { typedef std::vector<T> realtype; realtype real_vector; realtype real_vector_alt; typedef prevector<N, T> pretype; pretype pre_vector; pretype pre_vector_alt; typedef typename pretype::size_type Size; void test() { const pretype& const_pre_vector = pre_vector; BOOST_CHECK_EQUAL(real_vector.size(), pre_vector.size()); BOOST_CHECK_EQUAL(real_vector.empty(), pre_vector.empty()); for (Size s = 0; s < real_vector.size(); s++) { BOOST_CHECK(real_vector[s] == pre_vector[s]); BOOST_CHECK(&(pre_vector[s]) == &(pre_vector.begin()[s])); BOOST_CHECK(&(pre_vector[s]) == &*(pre_vector.begin() + s)); BOOST_CHECK(&(pre_vector[s]) == &*((pre_vector.end() + s) - real_vector.size())); } // BOOST_CHECK(realtype(pre_vector) == real_vector); BOOST_CHECK(pretype(real_vector.begin(), real_vector.end()) == pre_vector); BOOST_CHECK(pretype(pre_vector.begin(), pre_vector.end()) == pre_vector); size_t pos = 0; for (const T& v : pre_vector) { BOOST_CHECK(v == real_vector[pos++]); } pos = 0; for (const T& v : const_pre_vector) { BOOST_CHECK(v == real_vector[pos++]); } CDataStream ss1(SER_DISK, 0); CDataStream ss2(SER_DISK, 0); ss1 << real_vector; ss2 << pre_vector; BOOST_CHECK_EQUAL(ss1.size(), ss2.size()); for (Size s = 0; s < ss1.size(); s++) { BOOST_CHECK_EQUAL(ss1[s], ss2[s]); } } public: void resize(Size s) { real_vector.resize(s); BOOST_CHECK_EQUAL(real_vector.size(), s); pre_vector.resize(s); BOOST_CHECK_EQUAL(pre_vector.size(), s); test(); } void reserve(Size s) { real_vector.reserve(s); BOOST_CHECK(real_vector.capacity() >= s); pre_vector.reserve(s); BOOST_CHECK(pre_vector.capacity() >= s); test(); } void insert(Size position, const T& value) { real_vector.insert(real_vector.begin() + position, value); pre_vector.insert(pre_vector.begin() + position, value); test(); } void insert(Size position, Size count, const T& value) { real_vector.insert(real_vector.begin() + position, count, value); pre_vector.insert(pre_vector.begin() + position, count, value); test(); } template<typename I> void insert_range(Size position, I first, I last) { real_vector.insert(real_vector.begin() + position, first, last); pre_vector.insert(pre_vector.begin() + position, first, last); test(); } void erase(Size position) { real_vector.erase(real_vector.begin() + position); pre_vector.erase(pre_vector.begin() + position); test(); } void erase(Size first, Size last) { real_vector.erase(real_vector.begin() + first, real_vector.begin() + last); pre_vector.erase(pre_vector.begin() + first, pre_vector.begin() + last); test(); } void update(Size pos, const T& value) { real_vector[pos] = value; pre_vector[pos] = value; test(); } void push_back(const T& value) { real_vector.push_back(value); pre_vector.push_back(value); test(); } void pop_back() { real_vector.pop_back(); pre_vector.pop_back(); test(); } void clear() { real_vector.clear(); pre_vector.clear(); } void assign(Size n, const T& value) { real_vector.assign(n, value); pre_vector.assign(n, value); } Size size() { return real_vector.size(); } Size capacity() { return pre_vector.capacity(); } void shrink_to_fit() { pre_vector.shrink_to_fit(); test(); } void swap() { real_vector.swap(real_vector_alt); pre_vector.swap(pre_vector_alt); test(); } void move() { real_vector = std::move(real_vector_alt); real_vector_alt.clear(); pre_vector = std::move(pre_vector_alt); pre_vector_alt.clear(); } void copy() { real_vector = real_vector_alt; pre_vector = pre_vector_alt; } }; BOOST_AUTO_TEST_CASE(PrevectorTestInt) { for (int j = 0; j < 64; j++) { prevector_tester<8, int> test; for (int i = 0; i < 2048; i++) { int r = InsecureRand32(); if ((r % 4) == 0) { test.insert(InsecureRand32() % (test.size() + 1), InsecureRand32()); } if (test.size() > 0 && ((r >> 2) % 4) == 1) { test.erase(InsecureRand32() % test.size()); } if (((r >> 4) % 8) == 2) { int new_size = std::max<int>(0, std::min<int>(30, test.size() + (InsecureRand32() % 5) - 2)); test.resize(new_size); } if (((r >> 7) % 8) == 3) { test.insert(InsecureRand32() % (test.size() + 1), 1 + (InsecureRand32() % 2), InsecureRand32()); } if (((r >> 10) % 8) == 4) { int del = std::min<int>(test.size(), 1 + (InsecureRand32() % 2)); int beg = InsecureRand32() % (test.size() + 1 - del); test.erase(beg, beg + del); } if (((r >> 13) % 16) == 5) { test.push_back(InsecureRand32()); } if (test.size() > 0 && ((r >> 17) % 16) == 6) { test.pop_back(); } if (((r >> 21) % 32) == 7) { int values[4]; int num = 1 + (InsecureRand32() % 4); for (int i = 0; i < num; i++) { values[i] = InsecureRand32(); } test.insert_range(InsecureRand32() % (test.size() + 1), values, values + num); } if (((r >> 26) % 32) == 8) { int del = std::min<int>(test.size(), 1 + (InsecureRand32() % 4)); int beg = InsecureRand32() % (test.size() + 1 - del); test.erase(beg, beg + del); } r = InsecureRand32(); if (r % 32 == 9) { test.reserve(InsecureRand32() % 32); } if ((r >> 5) % 64 == 10) { test.shrink_to_fit(); } if (test.size() > 0) { test.update(InsecureRand32() % test.size(), InsecureRand32()); } if (((r >> 11) % 1024) == 11) { test.clear(); } if (((r >> 21) % 512) == 12) { test.assign(InsecureRand32() % 32, InsecureRand32()); } if (((r >> 15) % 8) == 3) { test.swap(); } if (((r >> 15) % 16) == 8) { test.copy(); } if (((r >> 15) % 32) == 18) { test.move(); } } } } BOOST_AUTO_TEST_SUITE_END()
5b950335f4a6b14b8f9b2b8500f3ef750e1fa376
4c445a6cbe82b626755999e4dcad424d7057a42e
/WrapperClasses/LTexture/LTexture.cpp
f7a2a35d662ff9a7f1348879545f9c0abfa8c223
[]
no_license
ShiniDev/SDL2_Lazy_Foo
421f3803b84da1043e753d0e18f5c45fb5652e29
99543f05b5f2ad7a0e03a6ea04a4dc53015fbacd
refs/heads/main
2023-06-22T22:06:07.786822
2021-03-15T03:28:14
2021-03-15T03:28:14
342,863,179
1
0
null
null
null
null
UTF-8
C++
false
false
3,286
cpp
#include "LTexture.hpp" LTexture::LTexture() :texture(nullptr),imgwidth(0),imgheight(0) {} LTexture::~LTexture() { free(); } bool LTexture::load_from_file_trans(SDL_Renderer*& rend,const std::string &filepath,Uint8 r,Uint8 g,Uint8 b) { free(); SDL_Surface* loaded_surface = IMG_Load(filepath.c_str()); if(!loaded_surface) { std::cerr << "Unable to load image " << filepath << "! SDL Error: " << SDL_GetError() << '\n'; return false; } SDL_SetColorKey(loaded_surface,SDL_TRUE,SDL_MapRGB(loaded_surface->format,r,g,b)); texture = SDL_CreateTextureFromSurface(rend,loaded_surface); if(!texture) { std::cerr << "Unable to create texture from " << filepath << "! SDL Error: " << SDL_GetError() << '\n'; return false; } imgwidth = loaded_surface->w; imgheight = loaded_surface->h; SDL_FreeSurface(loaded_surface); return true; } bool LTexture::load_from_file(SDL_Renderer *&rend, const std::string &filepath) { free(); SDL_Surface* loaded_surface = IMG_Load(filepath.c_str()); if(!loaded_surface) { std::cerr << "Unable to load image " << filepath << "! SDL Error: " << SDL_GetError() << '\n'; return false; } texture = SDL_CreateTextureFromSurface(rend,loaded_surface); if(!texture) { std::cerr << "Unable to create texture from " << filepath << "! SDL Error: " << SDL_GetError() << '\n'; return false; } imgwidth = loaded_surface->w; imgheight = loaded_surface->h; SDL_FreeSurface(loaded_surface); return true; } #if defined(SDL_TTF_MAJOR_VERSION) bool LTexture::load_from_rendered_text(SDL_Renderer*& renderer,TTF_Font *&font, const std::string &text, SDL_Color color) { free(); SDL_Surface* text_surface = TTF_RenderText_Solid(font,text.c_str(),color); if(!text_surface) { std::cerr << "Unable to render text surface! SDL_ttf Error: " << TTF_GetError() << '\n'; return false; } texture = SDL_CreateTextureFromSurface(renderer,text_surface); if(!texture) { std::cerr << "Unable to create texture from rendered text! SDL Error : " << SDL_GetError() << '\n'; return false; } imgwidth = text_surface->w; imgheight = text_surface->h; SDL_FreeSurface(text_surface); return texture!=nullptr; } #endif void LTexture::free() { if(texture) { SDL_DestroyTexture(texture); texture = nullptr; imgwidth = 0; imgheight = 0; } } void LTexture::set_color(Uint8 r, Uint8 g, Uint8 b) { SDL_SetTextureColorMod(texture,r,g,b); } void LTexture::set_alpha(Uint8 alpha) { SDL_SetTextureAlphaMod(texture,alpha); } void LTexture::set_blend_mode(SDL_BlendMode blending) { SDL_SetTextureBlendMode(texture,blending); } void LTexture::render(SDL_Renderer *& rend, int x, int y, SDL_Rect *clip, double angle, SDL_Point *center, SDL_RendererFlip flip) { SDL_Rect img_properties = {x,y,imgwidth,imgheight}; if(clip) { img_properties.w = clip->w; img_properties.h = clip->h; } SDL_RenderCopyEx(rend,texture,clip,&img_properties,angle,center,flip); } int LTexture::get_width() { return imgwidth; } int LTexture::get_height() { return imgheight; }
b4d2094c7d41bb622254e5166671d922c0dd3b91
e47ebafd139ab4763d2ddac0d71784c92a7e6d8d
/thtfit/LinuxBaseLib/Include/MediaDataPacket.h
3938b34cdc8ba101c845a410d391ab2f59951925
[]
no_license
franzluo/codeCap
7362f61c3bab6dfb32d43c3e36e37ae8a7fac8a8
4d2bdb48750593a88545de2bf425b2bd60100fe8
refs/heads/master
2021-01-11T01:42:36.327163
2020-02-17T05:45:00
2020-02-17T05:45:00
70,659,058
0
1
null
null
null
null
UTF-8
C++
false
false
801
h
#ifndef _MEDIA_DATA_PACKET_H_ #define _MEDIA_DATA_PACKET_H_ //#include <utils/RefBase.h> #include <BaseTypeDef.h> #include <MediaDataType.h> class CMediaDataPacket { public: CMediaDataPacket(); CMediaDataPacket(size_t PreAllocSize); virtual ~CMediaDataPacket(); virtual operator PBYTE (); virtual size_t getDataBufSize(); virtual INT_t setAvailableDataSize(size_t AvailableDataSize); virtual size_t getAvailableDataSize(); virtual INT_t setMediaDataPacketType(MEDIA_DATA_PACKET_TYPE eMediaDataPacketType); virtual INT_t getMediaDataPacketType(MEDIA_DATA_PACKET_TYPE & OUT eMediaDataPacketType); protected: PBYTE m_pDataBuf; size_t m_DataBufSize; size_t m_AvailableDataSize; MEDIA_DATA_PACKET_TYPE m_eMediaDataPacketType; }; #endif //_MEDIA_DATA_PACKET_H_
a98964103444df5c5edfa5cff3803698e4543b7a
0146fc5b0769c14f78d8dc369a573feafb2f4a74
/robot_scan_matcher/src/robot_scan_matcher_plugins.cpp
fc0817a8de71902989e8f05741896e1916948108
[ "BSD-3-Clause" ]
permissive
Forrest-Z/distributed_teb_multi_robot
b570d04d4b404cf9ead1cf2e47c0688e535b92ee
3d785980d254d19722936dd53e9f2fdfd1cceefa
refs/heads/main
2023-07-11T00:56:58.255970
2021-08-16T00:18:43
2021-08-16T00:18:43
402,268,377
3
0
BSD-3-Clause
2021-09-02T02:45:39
2021-09-02T02:45:38
null
UTF-8
C++
false
false
12,350
cpp
/********************************************************************* * * Author: Yiu-Ming Chung ([email protected]) * * * *********************************************************************/ #include <robot_scan_matcher/robot_scan_matcher_plugins.h> #include <pcl/point_cloud.h> #include <pcl/point_types.h> #include <pcl_conversions/pcl_conversions.h> #include <pluginlib/class_list_macros.h> PLUGINLIB_EXPORT_CLASS(robot_scan_matcher_plugins::NavieMatcher, robot_scan_matcher_base::BaseMatcher) namespace robot_scan_matcher_plugins { void NavieMatcher::initialize(ros::NodeHandle nh, tf2_ros::Buffer* tf, std::string global_frame, std::string local_frame, std::string laserScan_topic, double costmap_SizeInMetersX, double costmap_SizeInMetersY, std::string obst_topic) { if(!initialized_) { tf_ = tf; global_frame_ = global_frame; local_frame_ = local_frame; ROS_INFO_STREAM("LaserScan is transformed to planner frame: "<< global_frame_); laserScan_sub_.subscribe(nh, laserScan_topic, 2); laser_filter_ = new tf2_ros::MessageFilter<sensor_msgs::LaserScan>(laserScan_sub_, tfBuffer_, global_frame_, 5, 0); laser_filter_->registerCallback( boost::bind(&NavieMatcher::laserScanCB, this, _1) ); obst_msg_sub_ = nh.subscribe(obst_topic, 1, &NavieMatcher::obstSubCB, this); costmap_SizeInMetersX_ = costmap_SizeInMetersX; costmap_SizeInMetersY_ = costmap_SizeInMetersY; std::string ns = ""; { using namespace ros; ns = this_node::getNamespace(); } cloud_pub_ = nh.advertise<sensor_msgs::PointCloud2>(ns+"/PointCloud_filtered",5); scan_pub_ = nh.advertise<sensor_msgs::LaserScan>(ns+"/base_scan_filtered",5); nh.param("enable_filtering", parameter_.enable_filtering_, true); nh.param("removal_distance", parameter_.removal_distance_, 0.1); nh.param("translation_threshold", parameter_.translation_threshold_, 0.1); parameter_buffered_ = parameter_; // setup dynamic reconfigure dynamic_recfg_ = new dynamic_reconfigure::Server<robot_scan_matcher::robot_scan_matcherConfig>(nh); dynamic_reconfigure::Server<robot_scan_matcher::robot_scan_matcherConfig>::CallbackType cb = boost::bind(&NavieMatcher::reconfigureCB, this, _1, _2); dynamic_recfg_->setCallback(cb); initialized_ = true; ROS_DEBUG("robot_scan_matcher plugin initialized."); } else { ROS_WARN("robot_scan_matcher plugin has already been initialized, doing nothing."); } } void NavieMatcher::laserScanCB(const sensor_msgs::LaserScan::ConstPtr& laserScan_msg) { boost::mutex::scoped_lock l(laserScan_mutex_); try { sensor_msgs::LaserScan temp; temp = *laserScan_msg; // remove any leading slash if('/' == temp.header.frame_id.front()) { temp.header.frame_id.erase(temp.header.frame_id.begin()); } scan_pub_.publish(temp); projector_.transformLaserScanToPointCloud(global_frame_, temp, cloud_, tfBuffer_, INFINITY, laser_geometry::channel_option::Intensity); cloud_.header.stamp = temp.header.stamp; } catch (tf::TransformException& e) { std::cout << e.what(); return; } } void NavieMatcher::obstSubCB(const teb_local_planner::ObstacleWithTrajectoryArray::ConstPtr& obst_msg) { boost::mutex::scoped_lock l(obst_mutex_); obstacles_raw_ = *obst_msg; } void NavieMatcher::compute() { { //copy from dynamic reconfigure boost::mutex::scoped_lock lock(parameter_mutex_); parameter_ = parameter_buffered_; } pcl::PointCloud<pcl::PointXYZI> pclpc; boost::mutex::scoped_lock l(laserScan_mutex_); // Convert to PCL data type pcl::fromROSMsg(cloud_, pclpc); boost::mutex::scoped_lock l_obst(obst_mutex_); if (!obstacles_raw_.obstacles.empty()) { for (size_t i=0; i<obstacles_raw_.obstacles.size(); ++i) { teb_local_planner::ObstacleWithTrajectory& curr_obstacle = obstacles_raw_.obstacles.at(i); teb_local_planner::ObstaclePtr obstPtr = createObstacleFromMsg(curr_obstacle); if (parameter_.enable_filtering_) { auto it = pclpc.begin(); while (it != pclpc.end()) { if (obstPtr->getMinimumDistance(Eigen::Vector2d(it->x, it->y)) <= parameter_.removal_distance_) { it = pclpc.erase(it); } else { it++; } } } } } pcl::toROSMsg(pclpc, cloud_filtered_); cloud_filtered_.header.stamp = cloud_.header.stamp; cloud_pub_.publish(cloud_filtered_); } teb_local_planner::ObstaclePtr NavieMatcher::createObstacleFromMsg(teb_local_planner::ObstacleWithTrajectory& obstacleMsg) { // We only use the global header to specify the obstacle coordinate system instead of individual ones geometry_msgs::TransformStamped obstacle_to_map; try { obstacle_to_map = tf_->lookupTransform(global_frame_, ros::Time(0), obstacleMsg.header.frame_id, ros::Time(0), obstacleMsg.header.frame_id, ros::Duration(0.1)); } catch (tf::TransformException ex) { ROS_ERROR("%s",ex.what()); } double theta_offset = tf::getYaw(obstacle_to_map.transform.rotation); //time passed since the creation of message ros::Duration time_offset = ros::Time::now() - obstacleMsg.header.stamp; //make a copy from the original message, otherwise will be recursely offset in incorrect way std::vector<teb_local_planner::TrajectoryPointSE2, std::allocator<teb_local_planner::TrajectoryPointSE2>> trajectory_copy (obstacleMsg.trajectory); //compute relative time from now, and transform pose for (unsigned int j = 0; j < trajectory_copy.size(); j++) { trajectory_copy.at(j).time_from_start -= time_offset; // T = T2*T1 = (R2 t2) (R1 t1) = (R2*R1 R2*t1+t2) // (0 1) (0 1) (0 1) trajectory_copy.at(j).pose.x = obstacleMsg.trajectory.at(j).pose.x*cos(theta_offset) - obstacleMsg.trajectory.at(j).pose.y*sin(theta_offset) + obstacle_to_map.transform.translation.x; trajectory_copy.at(j).pose.y = obstacleMsg.trajectory.at(j).pose.x*sin(theta_offset) + obstacleMsg.trajectory.at(j).pose.y*cos(theta_offset) + obstacle_to_map.transform.translation.y; trajectory_copy.at(j).pose.theta = obstacleMsg.trajectory.at(j).pose.theta + theta_offset; } teb_local_planner::ObstaclePtr obst_ptr(NULL); if (obstacleMsg.footprint.type == teb_local_planner::ObstacleFootprint::CircularObstacle) // circle { teb_local_planner::PoseSE2 pose_init; Eigen::Vector2d speed_init; teb_local_planner::CircularObstacle* obstacle = new teb_local_planner::CircularObstacle; obstacle->setTrajectory(trajectory_copy, obstacleMsg.footprint.holonomic); obstacle->predictPoseFromTrajectory(0, pose_init, speed_init); obstacle->x() = pose_init.x(); obstacle->y() = pose_init.y(); obstacle->radius() = obstacleMsg.footprint.radius; obstacle->setCentroidVelocity(speed_init); obst_ptr = teb_local_planner::ObstaclePtr(obstacle); } else if (obstacleMsg.footprint.type == teb_local_planner::ObstacleFootprint::PointObstacle ) // point { teb_local_planner::PoseSE2 pose_init; Eigen::Vector2d speed_init; teb_local_planner::PointObstacle* obstacle = new teb_local_planner::PointObstacle; obstacle->setTrajectory(trajectory_copy, obstacleMsg.footprint.holonomic); obstacle->predictPoseFromTrajectory(0, pose_init, speed_init); obstacle->x() = pose_init.x(); obstacle->y() = pose_init.y(); obstacle->setCentroidVelocity(speed_init); obst_ptr = teb_local_planner::ObstaclePtr(obstacle); } else if (obstacleMsg.footprint.type == teb_local_planner::ObstacleFootprint::LineObstacle ) // line { Eigen::Vector2d start_robot( obstacleMsg.footprint.point1.x, obstacleMsg.footprint.point1.y); Eigen::Vector2d end_robot( obstacleMsg.footprint.point2.x, obstacleMsg.footprint.point2.y); teb_local_planner::PoseSE2 pose_init; Eigen::Vector2d speed_init; teb_local_planner::LineObstacle* obstacle = new teb_local_planner::LineObstacle; Eigen::Vector2d start; Eigen::Vector2d end; obstacle->setTrajectory(trajectory_copy, obstacleMsg.footprint.holonomic); obstacle->predictPoseFromTrajectory(0, pose_init, speed_init); obstacle->transformToWorld(pose_init, start_robot, end_robot, start, end); obstacle->setStart(start); obstacle->setEnd(end); obstacle->setCentroidVelocity(speed_init); obst_ptr = teb_local_planner::ObstaclePtr(obstacle); } else if (obstacleMsg.footprint.type == teb_local_planner::ObstacleFootprint::PillObstacle ) // pill { Eigen::Vector2d start_robot( obstacleMsg.footprint.point1.x, obstacleMsg.footprint.point1.y); Eigen::Vector2d end_robot( obstacleMsg.footprint.point2.x, obstacleMsg.footprint.point2.y); teb_local_planner::PoseSE2 pose_init; Eigen::Vector2d speed_init; teb_local_planner::PillObstacle* obstacle = new teb_local_planner::PillObstacle; Eigen::Vector2d start; Eigen::Vector2d end; obstacle->setTrajectory(trajectory_copy, obstacleMsg.footprint.holonomic); obstacle->predictPoseFromTrajectory(0, pose_init, speed_init); obstacle->transformToWorld(pose_init, start_robot, end_robot, start, end); obstacle->setStart(start); obstacle->setEnd(end); obstacle->setRadius(obstacleMsg.footprint.radius); obstacle->setCentroidVelocity(speed_init); obst_ptr = teb_local_planner::ObstaclePtr(obstacle); } else if(obstacleMsg.footprint.type == teb_local_planner::ObstacleFootprint::PolygonObstacle ) // polygon { teb_local_planner::Point2dContainer vertices_robocentric; for (size_t j=0; j<obstacleMsg.footprint.polygon.points.size(); ++j) { Eigen::Vector2d pos( obstacleMsg.footprint.polygon.points[j].x, obstacleMsg.footprint.polygon.points[j].y); vertices_robocentric.push_back( pos ); } teb_local_planner::PoseSE2 pose_init; Eigen::Vector2d speed_init; teb_local_planner::Point2dContainer vertices; teb_local_planner::PolygonObstacle* polyobst = new teb_local_planner::PolygonObstacle; polyobst->setTrajectory(trajectory_copy, obstacleMsg.footprint.holonomic); polyobst->predictPoseFromTrajectory(0, pose_init, speed_init); polyobst->setCentroidVelocity(speed_init); polyobst->transformToWorld(pose_init, vertices_robocentric, vertices); for (size_t j=0; j<vertices.size(); ++j) { polyobst->pushBackVertex( vertices.at(j) ); } polyobst->finalizePolygon(); obst_ptr = teb_local_planner::ObstaclePtr(polyobst); } else { ROS_WARN("Invalid custom obstacle received. Invalid Type. Skipping..."); } return obst_ptr; } void NavieMatcher::reconfigureCB(robot_scan_matcher::robot_scan_matcherConfig& config, uint32_t level) { boost::mutex::scoped_lock lock(parameter_mutex_); parameter_buffered_.enable_filtering_ = config.enable_filtering; parameter_buffered_.removal_distance_ = config.removal_distance; parameter_buffered_.translation_threshold_ = config.removal_distance; parameter_buffered_.rate_ = config.rate; if (parameter_buffered_.rate_ != parameter_.rate_){worker_timer_.setPeriod(ros::Duration(1.0/parameter_buffered_.rate_), false);} } }
3c174bb0e4993676564b6f16a71fbfb048348910
384343cbaa4d93d7c06b061d41b9fc770dd994ae
/sparql/SparqlListener.cpp
09308e84c0a4a685f4ef453a37485d790b69e413
[]
no_license
Mahone-h/sparqlTest
bd84157ccfcc6e48ee0138df2fd748c73c78da49
0259e77062fade390857fe7760b031398c2f6c93
refs/heads/master
2023-05-31T07:08:56.039191
2021-07-01T10:43:26
2021-07-01T10:43:26
347,312,590
0
0
null
null
null
null
UTF-8
C++
false
false
76
cpp
// Generated from ./Sparql.g4 by ANTLR 4.9 #include "SparqlListener.h"
ca2a76132d8762d9b36e052807a687022cc55d0a
536656cd89e4fa3a92b5dcab28657d60d1d244bd
/components/download/public/common/download_url_parameters.h
fd614fd18e6be66d2144093e2a7f4168ad44cc51
[ "BSD-3-Clause" ]
permissive
ECS-251-W2020/chromium
79caebf50443f297557d9510620bf8d44a68399a
ac814e85cb870a6b569e184c7a60a70ff3cb19f9
refs/heads/master
2022-08-19T17:42:46.887573
2020-03-18T06:08:44
2020-03-18T06:08:44
248,141,336
7
8
BSD-3-Clause
2022-07-06T20:32:48
2020-03-18T04:52:18
null
UTF-8
C++
false
false
15,725
h
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_URL_PARAMETERS_H_ #define COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_URL_PARAMETERS_H_ #include <stdint.h> #include <memory> #include <string> #include <utility> #include <vector> #include "base/callback.h" #include "base/macros.h" #include "base/optional.h" #include "components/download/public/common/download_interrupt_reasons.h" #include "components/download/public/common/download_save_info.h" #include "components/download/public/common/download_source.h" #include "net/base/network_isolation_key.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "net/url_request/url_request.h" #include "services/network/public/cpp/resource_request_body.h" #include "services/network/public/mojom/fetch_api.mojom-shared.h" #include "storage/browser/blob/blob_data_handle.h" #include "url/gurl.h" #include "url/origin.h" namespace download { class DownloadItem; // Pass an instance of DownloadUrlParameters to DownloadManager::DownloadUrl() // to download the content at |url|. All parameters with setters are optional. // |referrer| and |referrer_encoding| are the referrer for the download. If // |prefer_cache| is true, then if the response to |url| is in the HTTP cache it // will be used without revalidation. If |post_id| is non-negative, then it // identifies the post transaction used to originally retrieve the |url| // resource - it also requires |prefer_cache| to be |true| since re-post'ing is // not done. |save_info| specifies where the downloaded file should be saved, // and whether the user should be prompted about the download. If not null, // |callback| will be called when the download starts, or if an error occurs // that prevents a download item from being created. We send a pointer to // content::ResourceContext instead of the usual reference so that a copy of the // object isn't made. class COMPONENTS_DOWNLOAD_EXPORT DownloadUrlParameters { public: // An OnStartedCallback is invoked when a response is available for the // download request. For new downloads, this callback is invoked after the // OnDownloadCreated notification is issued by the DownloadManager. If the // download fails, then the DownloadInterruptReason parameter will indicate // the failure. // // DownloadItem* may be nullptr if no DownloadItem was created. DownloadItems // are not created when a resource throttle or a resource handler blocks the // download request. I.e. the download triggered a warning of some sort and // the user chose to not to proceed with the download as a result. typedef base::OnceCallback<void(DownloadItem*, DownloadInterruptReason)> OnStartedCallback; typedef std::pair<std::string, std::string> RequestHeadersNameValuePair; typedef std::vector<RequestHeadersNameValuePair> RequestHeadersType; using BlobStorageContextGetter = base::OnceCallback<storage::BlobStorageContext*()>; using UploadProgressCallback = base::RepeatingCallback<void(uint64_t bytes_uploaded)>; // Constructs a download not associated with a frame. // // It is not safe to have downloads not associated with a frame and // this should only be done in a limited set of cases where the download URL // has been previously vetted. A download that's initiated without // associating it with a frame don't receive the same security checks // as a request that's associated with one. Hence, downloads that are not // associated with a frame should only be made for URLs that are either // trusted or URLs that have previously been successfully issued using a // non-privileged frame. DownloadUrlParameters( const GURL& url, const net::NetworkTrafficAnnotationTag& traffic_annotation, const net::NetworkIsolationKey& network_isolation_key); // The RenderView routing ID must correspond to the RenderView of the // RenderFrame, both of which share the same RenderProcess. This may be a // different RenderView than the WebContents' main RenderView. DownloadUrlParameters( const GURL& url, int render_process_host_id, int render_view_host_routing_id, int render_frame_host_routing_id, const net::NetworkTrafficAnnotationTag& traffic_annotation, const net::NetworkIsolationKey& network_isolation_key); ~DownloadUrlParameters(); // Should be set to true if the download was initiated by a script or a web // page. I.e. if the download request cannot be attributed to an explicit user // request for a download, then set this value to true. void set_content_initiated(bool content_initiated) { content_initiated_ = content_initiated; } void add_request_header(const std::string& name, const std::string& value) { request_headers_.push_back(make_pair(name, value)); } // HTTP Referrer, referrer policy and encoding. void set_referrer(const GURL& referrer) { referrer_ = referrer; } void set_referrer_policy(net::URLRequest::ReferrerPolicy referrer_policy) { referrer_policy_ = referrer_policy; } void set_referrer_encoding(const std::string& referrer_encoding) { referrer_encoding_ = referrer_encoding; } // The origin of the context which initiated the request. See // net::URLRequest::initiator(). void set_initiator(const base::Optional<url::Origin>& initiator) { initiator_ = initiator; } // If this is a request for resuming an HTTP/S download, |last_modified| // should be the value of the last seen Last-Modified response header. void set_last_modified(const std::string& last_modified) { last_modified_ = last_modified; } // If this is a request for resuming an HTTP/S download, |etag| should be the // last seen Etag response header. void set_etag(const std::string& etag) { etag_ = etag; } // If the "If-Range" header is used in a partial request. void set_use_if_range(bool use_if_range) { use_if_range_ = use_if_range; } // HTTP method to use. void set_method(const std::string& method) { method_ = method; } // Body of the HTTP POST request. void set_post_body(scoped_refptr<network::ResourceRequestBody> post_body) { post_body_ = post_body; } // The blob storage context to be used for uploading blobs, if any. void set_blob_storage_context_getter(BlobStorageContextGetter blob_getter) { blob_storage_context_getter_ = std::move(blob_getter); } // If |prefer_cache| is true and the response to |url| is in the HTTP cache, // it will be used without validation. If |method| is POST, then |post_id_| // shoud be set via |set_post_id()| below to the identifier of the POST // transaction used to originally retrieve the resource. void set_prefer_cache(bool prefer_cache) { prefer_cache_ = prefer_cache; } // See set_prefer_cache() above. void set_post_id(int64_t post_id) { post_id_ = post_id; } // See OnStartedCallback above. void set_callback(OnStartedCallback callback) { callback_ = std::move(callback); } // If not empty, specifies the full target path for the download. This value // overrides the filename suggested by a Content-Disposition headers. It // should only be set for programmatic downloads where the caller can verify // the safety of the filename and the resulting download. void set_file_path(const base::FilePath& file_path) { save_info_.file_path = file_path; } // Suggested filename for the download. The suggestion can be overridden by // either a Content-Disposition response header or a |file_path|. void set_suggested_name(const base::string16& suggested_name) { save_info_.suggested_name = suggested_name; } // If |offset| is non-zero, then a byte range request will be issued to fetch // the range of bytes starting at |offset|. void set_offset(int64_t offset) { save_info_.offset = offset; } // Sets the offset to start writing to the file. If set, The data received // before |file_offset| are discarded or are used for validation purpose. void set_file_offset(int64_t file_offset) { save_info_.file_offset = file_offset; } // If |offset| is non-zero, then |hash_of_partial_file| contains the raw // SHA-256 hash of the first |offset| bytes of the target file. Only // meaningful if a partial file exists and is identified by either the // |file_path()| or |file()|. void set_hash_of_partial_file(const std::string& hash_of_partial_file) { save_info_.hash_of_partial_file = hash_of_partial_file; } // If |offset| is non-zero, then |hash_state| indicates the SHA-256 hash state // of the first |offset| bytes of the target file. In this case, the prefix // hash will be ignored since the |hash_state| is assumed to be correct if // provided. void set_hash_state(std::unique_ptr<crypto::SecureHash> hash_state) { save_info_.hash_state = std::move(hash_state); } // If |prompt| is true, then the user will be prompted for a filename. Ignored // if |file_path| is non-empty. void set_prompt(bool prompt) { save_info_.prompt_for_save_location = prompt; } void set_file(base::File file) { save_info_.file = std::move(file); } void set_do_not_prompt_for_login(bool do_not_prompt) { do_not_prompt_for_login_ = do_not_prompt; } // If |cross_origin_redirects| is kFollow, we will follow cross origin // redirects while downloading. If it is kManual, then we'll attempt to // navigate to the URL or cancel the download. If it is kError, then we will // fail the download (kFail). void set_cross_origin_redirects( network::mojom::RedirectMode cross_origin_redirects) { cross_origin_redirects_ = cross_origin_redirects; } // Sets whether to download the response body even if the server returns // non-successful HTTP response code, like "HTTP NOT FOUND". void set_fetch_error_body(bool fetch_error_body) { fetch_error_body_ = fetch_error_body; } // A transient download will not be shown in the UI, and will not prompt // to user for target file path determination. Transient download should be // cleared properly through DownloadManager to avoid the database and // in-memory DownloadItem objects accumulated for the user. void set_transient(bool transient) { transient_ = transient; } // Sets the optional guid for the download, the guid serves as the unique // identitfier for the download item. If no guid is provided, download // system will automatically generate one. void set_guid(const std::string& guid) { guid_ = guid; } // For downloads originating from custom tabs, this records the origin // of the custom tab. void set_request_origin(const std::string& origin) { request_origin_ = origin; } // Sets the download source, which will be used in metrics recording. void set_download_source(DownloadSource download_source) { download_source_ = download_source; } // Sets the callback to run if there are upload progress updates. void set_upload_progress_callback( const UploadProgressCallback& upload_callback) { upload_callback_ = upload_callback; } // Sets whether the download will require safety checks for its URL chain and // downloaded content. void set_require_safety_checks(bool require_safety_checks) { require_safety_checks_ = require_safety_checks; } OnStartedCallback& callback() { return callback_; } bool content_initiated() const { return content_initiated_; } const std::string& last_modified() const { return last_modified_; } const std::string& etag() const { return etag_; } bool use_if_range() const { return use_if_range_; } const std::string& method() const { return method_; } scoped_refptr<network::ResourceRequestBody> post_body() { return post_body_; } int64_t post_id() const { return post_id_; } bool prefer_cache() const { return prefer_cache_; } const GURL& referrer() const { return referrer_; } net::URLRequest::ReferrerPolicy referrer_policy() const { return referrer_policy_; } const std::string& referrer_encoding() const { return referrer_encoding_; } const base::Optional<url::Origin>& initiator() const { return initiator_; } const std::string& request_origin() const { return request_origin_; } BlobStorageContextGetter get_blob_storage_context_getter() { return std::move(blob_storage_context_getter_); } // These will be -1 if the request is not associated with a frame. See // the constructors for more. int render_process_host_id() const { return render_process_host_id_; } int render_view_host_routing_id() const { return render_view_host_routing_id_; } int render_frame_host_routing_id() const { return render_frame_host_routing_id_; } void set_frame_tree_node_id(int id) { frame_tree_node_id_ = id; } int frame_tree_node_id() const { return frame_tree_node_id_; } const RequestHeadersType& request_headers() const { return request_headers_; } const base::FilePath& file_path() const { return save_info_.file_path; } const base::string16& suggested_name() const { return save_info_.suggested_name; } int64_t offset() const { return save_info_.offset; } const std::string& hash_of_partial_file() const { return save_info_.hash_of_partial_file; } bool prompt() const { return save_info_.prompt_for_save_location; } const GURL& url() const { return url_; } void set_url(GURL url) { url_ = std::move(url); } bool do_not_prompt_for_login() const { return do_not_prompt_for_login_; } network::mojom::RedirectMode cross_origin_redirects() const { return cross_origin_redirects_; } bool fetch_error_body() const { return fetch_error_body_; } bool is_transient() const { return transient_; } std::string guid() const { return guid_; } bool require_safety_checks() const { return require_safety_checks_; } const net::NetworkIsolationKey& network_isolation_key() const { return network_isolation_key_; } // STATE CHANGING: All save_info_ sub-objects will be in an indeterminate // state following this call. DownloadSaveInfo GetSaveInfo() { return std::move(save_info_); } const net::NetworkTrafficAnnotationTag& GetNetworkTrafficAnnotation() { return traffic_annotation_; } DownloadSource download_source() const { return download_source_; } const UploadProgressCallback& upload_callback() const { return upload_callback_; } private: OnStartedCallback callback_; bool content_initiated_; RequestHeadersType request_headers_; std::string last_modified_; std::string etag_; bool use_if_range_; std::string method_; scoped_refptr<network::ResourceRequestBody> post_body_; BlobStorageContextGetter blob_storage_context_getter_; int64_t post_id_; bool prefer_cache_; GURL referrer_; net::URLRequest::ReferrerPolicy referrer_policy_; base::Optional<url::Origin> initiator_; std::string referrer_encoding_; int render_process_host_id_; int render_view_host_routing_id_; int render_frame_host_routing_id_; int frame_tree_node_id_; DownloadSaveInfo save_info_; GURL url_; bool do_not_prompt_for_login_; network::mojom::RedirectMode cross_origin_redirects_; bool fetch_error_body_; bool transient_; std::string guid_; const net::NetworkTrafficAnnotationTag traffic_annotation_; std::string request_origin_; DownloadSource download_source_; UploadProgressCallback upload_callback_; bool require_safety_checks_; net::NetworkIsolationKey network_isolation_key_; DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters); }; } // namespace download #endif // COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_URL_PARAMETERS_H_
749b8853410f5ba3051aceb9c3dc6499a51a78fa
37e26258afd17c79380132747574ab9d08ca65f8
/wrapper/TriangleMesh.h
9384ddfdcd34e7301c9d51063750508da531bfdd
[]
no_license
slyandys/test_triangleMesh
042edf5731c18400f15ad7a34fe0d6310a81a25c
449e900285758d608319d6b9f15be9d48c07fccd
refs/heads/master
2016-09-10T22:48:17.711234
2014-05-23T15:06:08
2014-05-23T15:06:08
20,102,330
1
0
null
null
null
null
UTF-8
C++
false
false
3,450
h
// ========================================================================== // $Id: TriangleMesh.h 3765 2013-03-15 19:25:00Z jlang $ // Wrapper code to interface TriangleMesh // TriangleMesh implementation must support VRML reading, normal // generation, setting of normals, vertex (node) access. // ========================================================================== // (C)opyright: // // Jochen Lang // SITE, University of Ottawa // 800 King Edward Ave. // Ottawa, On., K1N 6N5 // Canada. // http://www.site.uottawa.ca // // Creator: Jochen Lang // Email: [email protected] // ========================================================================== // $Rev: 3765 $ // $LastChangedBy: jlang $ // $LastChangedDate: 2013-03-15 15:25:00 -0400 (Fri, 15 Mar 2013) $ // ========================================================================== #ifndef WRAPPER_TRIANGLE_MESH_H #define WRAPPER_TRIANGLE_MESH_H #include "TriMeshSimple.h" #include <vector> using std::vector; #include <set> using std::set; using std::multiset; #include <iostream> using std::cout; using std::endl; #include <fstream> using std::ifstream; using std::ofstream; #include <string> #include "g_Part.h" #include "g_Vector.h" #include "geodesic_algorithm_exact.h" // typedef g_Container<g_PEdge *> g_PEdgeContainer; // typedef g_Container<g_Node *> g_NodeContainer; template <class T> struct svector:vector<T> { inline svector() : vector<T>() {} inline svector(int n) : vector<T>(n) {} // already in vector // T operator[](int); }; // Should use a namespace class Coordinate : public TriMeshSimple::Point { // point is really a vec3f which is a typedef from VectorT // geometry subpackage public: inline double x() { return (*this)[0]; } inline double y() { return (*this)[1]; } inline double z() { return (*this)[2]; } inline double DistanceTo(const g_Vector& _oVec) const { return g_Vector(*this).DistanceTo(_oVec); } /* should just work inline Coordinate operator-(Coordinate&) { } */ }; // Should this be a g_Node? /* class Node { */ /* public: */ /* Coordinate coordinate(); */ /* }; */ class Color : public TriMeshSimple::Color { public: inline Color() : TriMeshSimple::Color() {}; inline Color( float _r, float _g, float _b ) : TriMeshSimple::Color( _r, _g, _b ) {} inline Color( const TriMeshSimple::Color& _oCol ) : TriMeshSimple::Color( _oCol ) {} }; class TriangleMesh : public g_Part { private: geodesic::Mesh d_geo_mesh; TriMeshSimple* d_tms; TriMeshSimple::VertexHandle* d_vhandleA; void calcTriMeshSimple(bool addColor=false, bool addNormals=false); svector<g_Vector> d_normals; svector<Color> d_color; public: TriangleMesh(); TriangleMesh( const g_Part& ); TriangleMesh( const TriangleMesh& ); ~TriangleMesh(); TriangleMesh& operator=( const TriangleMesh& ); void init( ifstream&, const std::string& _ext = ".PLY" ); void exportVRML( ofstream&, const std::string& _ext = ".PLY"); void setColorToMesh(svector<Color>&); void calculateVertexNormals( bool _keep = true ); void initGeodesicDistanceCalculation(); double getGeodesicDistance(int, double&, svector<double>&); size_t getNumberOfTriangles(); double getMeshResolution(); void SetNormals(int _id, int _dim, double _val ); void Normals_Resize(); // get normal at node with id g_Vector getNormalAtNode(int _id); }; #endif
b9c14e5d86e7e688cbce9fd8feee69174497b061
d2878f67ea60824d18092360354d190c8b273179
/src/eBirdCompiler.cpp
3b3e7afeb02da8f03fdf5cb373a4b3d4a738742a
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
KerryL/eBirdCompiler
6246a7e084b3e265ea6bf4dd75e5e9c309961bdd
edb81400778f67b06a41b16580088fd419568710
refs/heads/master
2023-06-11T15:39:30.378500
2021-07-07T23:29:43
2021-07-07T23:29:43
307,507,092
0
0
null
null
null
null
UTF-8
C++
false
false
8,610
cpp
// File: eBirdCompiler.cpp // Date: 10/25/2020 // Auth: K. Loux // Desc: Class for compiling summary data from separate eBird checklists. // Local headers #include "eBirdCompiler.h" #include "eBirdChecklistParser.h" #include "htmlRetriever.h" #include "robotsParser.h" #include "taxonomyOrder.h" // Standard C++ headers #include <sstream> #include <iomanip> #include <set> #include <algorithm> #include <cassert> #include <cmath> #include <map> const std::string EBirdCompiler::userAgent("eBird Compiler"); const std::string EBirdCompiler::taxonFileName("eBird_Taxonomy_v2019.csv"); #include <iostream> bool EBirdCompiler::Update(const std::string& checklistString) { errorString.clear(); summary = SummaryInfo(); std::set<std::string> urlList;// Use set to avoid duplicates std::string url; std::istringstream ss(checklistString); while (ss >> url) { if (url.find("ebird.org/") == std::string::npos && url.front() == 'S')// Allow checkilist IDs to be used and generate full URL automatically urlList.insert("https://ebird.org/checklist/" + url); else if (!url.empty()) urlList.insert(url); } if (urlList.empty()) { errorString = "Failed to find any URLs"; return false; } TaxonomyOrder taxonomicOrder(userAgent); if (!taxonomicOrder.Parse(taxonFileName)) { errorString = taxonomicOrder.GetErrorString(); return false; } HTMLRetriever htmlClient(userAgent); const auto baseURL(RobotsParser::GetBaseURL(*urlList.begin())); RobotsParser robotsTxtParser(htmlClient, baseURL); std::chrono::steady_clock::duration crawlDelay; if (robotsTxtParser.RetrieveRobotsTxt()) crawlDelay = robotsTxtParser.GetCrawlDelay(); else crawlDelay = std::chrono::seconds(1);// Default value htmlClient.SetCrawlDelay(crawlDelay); std::vector<ChecklistInfo> checklistInfo; for (const auto& u : urlList) { std::string html; if (!htmlClient.GetHTML(u, html)) { errorString = "Failed to download checklist from " + u; return false; } checklistInfo.push_back(ChecklistInfo()); EBirdChecklistParser parser(taxonomicOrder); if (!parser.Parse(html, checklistInfo.back())) { errorString = parser.GetErrorString(); return false; } } std::set<std::string> locationSet; unsigned int anonUserCount(0); std::map<unsigned int, std::vector<std::string>> checklistsByDateCode; for (const auto& ci : checklistInfo) { summary.totalDistance += ci.distance; summary.totalTime += ci.duration; const auto dateCode(GetDateCode(ci)); checklistsByDateCode[dateCode].push_back(ci.identifier); for (const auto& b : ci.birders) { if (std::find(summary.participants.begin(), summary.participants.end(), b) == summary.participants.end()) summary.participants.push_back(b); } if (std::find(ci.birders.begin(), ci.birders.end(), std::string("Anonymous eBirder")) != ci.birders.end()) ++anonUserCount; locationSet.insert(ci.location); for (const auto& checklistSpecies : ci.species) { bool found(false); for (auto& summarySpecies : summary.species) { if (summarySpecies.name == checklistSpecies.name) { summarySpecies.count += checklistSpecies.count; found = true; break; } } if (!found) summary.species.push_back(checklistSpecies); } } RemoveSubspeciesFromSummary(); SortTaxonomically(summary.species); summary.includesMoreThanOneAnonymousUser = anonUserCount > 1; summary.locationCount = locationSet.size(); if (checklistsByDateCode.size() > 1) { // Try to be helpful about reporting these potential errors: // - If there is a date code that includes > 80% of the checklists, identify the checklists that make up the 20% // - Otherwise, report the number of checklists given for each date for (const auto& cl : checklistsByDateCode) { if (cl.second.size() > 0.8 * checklistInfo.size()) { std::ostringstream ss; ss << "The following checklists are not from the same date as the others:\n"; for (const auto& cl2 : checklistsByDateCode) { if (cl2.first != cl.first) { for (const auto &id : cl2.second) ss << id << '\n'; } } errorString = ss.str(); break; } } if (errorString.empty()) { std::ostringstream ss; ss << "Not all checklists are from the same date:\n"; for (const auto& cl : checklistsByDateCode) ss << GetDateFromCode(cl.first) << " - " << cl.second.size() << " checklists\n"; errorString = ss.str(); } } return true; } std::string EBirdCompiler::GetSummaryString() const { unsigned int totalIndividuals(0); for (const auto& s : summary.species) totalIndividuals += s.count; const unsigned int timeHour(static_cast<unsigned int>(floor(summary.totalTime / 60.0))); const unsigned int timeMin(static_cast<unsigned int>(summary.totalTime - timeHour * 60.0)); std::ostringstream ss; ss.precision(1); ss << "\nParticipants: " << summary.participants.size(); if (summary.includesMoreThanOneAnonymousUser) ss << " (participant count may be inexact due to anonymous checklists)"; ss << "\nTotal distance: " << std::fixed << summary.totalDistance * 0.621371 << " miles" << "\nTotal time: "; if (timeHour > 0) { ss << timeHour << " hr"; if (timeMin > 0) ss << ", " << timeMin << " min"; } else ss << timeMin << " min"; unsigned int speciesCount, otherTaxaCount; CountSpecies(summary.species, speciesCount, otherTaxaCount); ss<< "\n# Locations: " << summary.locationCount << "\n# Species: " << speciesCount; if (otherTaxaCount > 0) ss << " (+ " << otherTaxaCount << " other taxa.)"; ss << "\n# Individuals: " << totalIndividuals << "\n\n"; std::string::size_type maxNameLength(0); for (const auto& s : summary.species) maxNameLength = std::max(maxNameLength, s.name.length()); const unsigned int extraSpace([this]() { unsigned int maxLength(0); for (const auto& s : summary.species) { const unsigned int length(log10(s.count) + 1); if (length > maxLength) maxLength = length; } return maxLength + 3;// Three extra spaces to make it look nice }()); ss << "Species list:\n"; for (const auto& s : summary.species) { ss << " " << s.name << std::setw(maxNameLength + extraSpace - s.name.length()) << std::setfill(' '); if (s.count == 0) ss << 'X'; else ss << s.count; ss << '\n'; } return ss.str(); } unsigned int EBirdCompiler::GetDateCode(const ChecklistInfo& info) { assert(info.month > 0 && info.month <= 12); assert(info.day > 0 && info.day <= 31); assert(info.year > 1700); return (info.year - 1700) + info.month * 1000 + info.day * 100000; } std::string EBirdCompiler::GetDateFromCode(const unsigned int& code) { const unsigned int day(code / 100000); const unsigned int month((code - day * 100000) / 1000); const unsigned int year(code - day * 100000 - month * 1000 + 1700); std::ostringstream ss; ss << month << '/' << day << '/' << year; return ss.str(); } void EBirdCompiler::CountSpecies(const std::vector<SpeciesInfo>& species, unsigned int& speciesCount, unsigned int& otherTaxaCount) { std::set<std::string> fullSpecies; std::set<std::string> otherTaxa; for (const auto& s : species) { const auto cleanedName(StripSubspecies(s.name)); if (IsSpuhOrSlash(cleanedName)) otherTaxa.insert(cleanedName); else fullSpecies.insert(cleanedName); } speciesCount = fullSpecies.size(); otherTaxaCount = otherTaxa.size(); } std::string EBirdCompiler::StripSubspecies(const std::string& name) { const auto parenStart(name.find('(')); if (parenStart == std::string::npos) return name; return name.substr(0, parenStart - 1); } bool EBirdCompiler::IsSpuhOrSlash(const std::string& name) { const std::string spuh("sp."); if (name.find(spuh) != std::string::npos) return true; else if (name.find('/') != std::string::npos) return true; return false; } void EBirdCompiler::SortTaxonomically(std::vector<SpeciesInfo>& species) { auto sortPredicate([](const SpeciesInfo& a, const SpeciesInfo& b) { return a.taxonomicOrder < b.taxonomicOrder; }); std::sort(species.begin(), species.end(), sortPredicate); } void EBirdCompiler::RemoveSubspeciesFromSummary() { for (auto& s : summary.species) s.name = StripSubspecies(s.name); for (unsigned int i = 0; i < summary.species.size(); ++i) { for (unsigned int j = i + 1; j < summary.species.size(); ++j) { if (summary.species[i].name == summary.species[j].name) { summary.species[i].count += summary.species[j].count; summary.species.erase(summary.species.begin() + j); --j; } } } }
547a2d1d4124194c049f6f34e4a150cb6b993a51
1d7dec86d300249efbfcb5a2ac8436a44522f6ba
/SmartShutters/sketch_feb19a.ino
eea70d1bf3da577bc05a9a825cfb1bb1d90aa6a8
[]
no_license
atafoa/smartshutters
4ee9c3ddc39f672d147e308b6c3efcee606a0b24
f3437a321a9504153aab89e29ceedf6c05a173b3
refs/heads/master
2022-11-26T22:06:39.357961
2020-05-15T03:54:45
2020-05-15T03:54:45
283,282,512
0
0
null
null
null
null
UTF-8
C++
false
false
6,933
ino
#include <BLEDevice.h> #include <BLEUtils.h> #include <BLEServer.h> #define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b" #define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8" #define speed 2 // Speed Range 10 to 2 10 = lowest , 2 = highest #define clockwise 0 // Clockwise direction #define c_clockwise 1 // Counter clockwise direction #define Motor_data1 26 // Inputs for motor controller 32 33 25 28 #define Motor_data2 25 #define Motor_data3 33 #define Motor_data4 32 #define Degree_Range 180 // Max Number of degrees #define ADC_Rotary_input 32 // ADC input from rotary sensor #define ADC_Rotary_power 33 // Power / Voltage for rotary sensor int Location = 0; int CurrentLocation = 0; String a; void full_drive (int direction){ // Function to drive motor if (direction == c_clockwise){ //motor_data = 0b0011; digitalWrite(Motor_data1, HIGH); digitalWrite(Motor_data2, HIGH); digitalWrite(Motor_data3, LOW); digitalWrite(Motor_data4, LOW); delay(speed); //motor_data = 0b0110; digitalWrite(Motor_data1, LOW); digitalWrite(Motor_data2, HIGH); digitalWrite(Motor_data3, HIGH); digitalWrite(Motor_data4, LOW); delay(speed); //motor_data = 0b1100; digitalWrite(Motor_data1, LOW); digitalWrite(Motor_data2, LOW); digitalWrite(Motor_data3, HIGH); digitalWrite(Motor_data4, HIGH); delay(speed); //motor_data = 0b1001; digitalWrite(Motor_data1, HIGH); digitalWrite(Motor_data2, LOW); digitalWrite(Motor_data3, LOW); digitalWrite(Motor_data4, HIGH); delay(speed); ///////////////// digitalWrite(Motor_data1, LOW); digitalWrite(Motor_data2, LOW); digitalWrite(Motor_data3, LOW); digitalWrite(Motor_data4, LOW); } if (direction == clockwise){ //motor_data = 0b1100; digitalWrite(Motor_data1, LOW); digitalWrite(Motor_data2, LOW); digitalWrite(Motor_data3, HIGH); digitalWrite(Motor_data4, HIGH); delay(speed); //motor_data = 0b0110; digitalWrite(Motor_data1, LOW); digitalWrite(Motor_data2, HIGH); digitalWrite(Motor_data3, HIGH); digitalWrite(Motor_data4, LOW); delay(speed); //motor_data = 0b0011; digitalWrite(Motor_data1, HIGH); digitalWrite(Motor_data2, HIGH); digitalWrite(Motor_data3, LOW); digitalWrite(Motor_data4, LOW); delay(speed); //motor_data = 0b1001; digitalWrite(Motor_data1, HIGH); digitalWrite(Motor_data2, LOW); digitalWrite(Motor_data3, LOW); digitalWrite(Motor_data4, HIGH); delay(speed); ///////////////// digitalWrite(Motor_data1, LOW); digitalWrite(Motor_data2, LOW); digitalWrite(Motor_data3, LOW); digitalWrite(Motor_data4, LOW); } } void moveto(int newLocation){ // Function for moving the shutter if (CurrentLocation != newLocation){ // Turn on motor while (CurrentLocation > newLocation){ full_drive(c_clockwise); CurrentLocation--; } while (CurrentLocation < newLocation){ full_drive(clockwise); CurrentLocation++; } // Turn off motor } } class MyCallbacks: public BLECharacteristicCallbacks { void onWrite(BLECharacteristic *pCharacteristic) { std::string value = pCharacteristic->getValue(); if (value.length() > 0) { digitalWrite(ADC_Rotary_power, HIGH); // Turn on power for the rotary sensor CurrentLocation = Degree_Range*analogRead(ADC_Rotary_input)/4095; // Read Value from the rotary sensor digitalWrite(ADC_Rotary_power, LOW); // Turn off power for the rotary sensor Serial.println("**********"); a=value.c_str(); Location = a.toInt(); if (a == "Battery\r\n") { // turn on switch for battery check // check battery status // turn off switch for battery check Serial.print("Battery Level: "); if (CurrentLocation > 45){ // WILL NEED TO BE CHANGED LATER / current location used for testing Serial.print("Good"); pCharacteristic->setValue("Battery Level: Good"); } if (CurrentLocation < 46){ // WILL NEED TO BE CHANGED LATER / current location used for testing Serial.print("Bad"); pCharacteristic->setValue("Battery Level: Bad"); } pCharacteristic->notify(); // Send the text to the app! Location = -1; // Placed to skip next if statement } if (Location >= 0 && Location <= Degree_Range) { Serial.print("Desired Position: "); Serial.print(a); Serial.print("Current Position: "); Serial.print(CurrentLocation); Serial.print("\n Difference : "); Serial.print(Location - CurrentLocation); moveto(Location); //Serial.print("\n New Position : "); //Serial.print(CurrentLocation); pCharacteristic->setValue("Moving to "); pCharacteristic->notify(); pCharacteristic->setValue(value); pCharacteristic->notify(); } Serial.println(); Serial.println("**********"); //pCharacteristic->setValue(a); //pCharacteristic->notify(); } } }; void setup() { Serial.begin(115200); pinMode(Motor_data1, OUTPUT); pinMode(Motor_data2, OUTPUT); pinMode(Motor_data3, OUTPUT); pinMode(Motor_data4, OUTPUT); pinMode(ADC_Rotary_power, OUTPUT); Serial.println("\nConnect to ESP32 Motor\n"); BLEDevice::init("ESP32 Motor"); BLEServer *pServer = BLEDevice::createServer(); BLEService *pService = pServer->createService(SERVICE_UUID); BLECharacteristic *pCharacteristic = pService->createCharacteristic( CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristic->setCallbacks(new MyCallbacks()); pCharacteristic->setValue("Hello World"); pService->start(); BLEAdvertising *pAdvertising = pServer->getAdvertising(); pAdvertising->start(); } void loop() { //put your main code here, to run repeatedly: //digitalWrite(ADC_Rotary_power, HIGH); //delay(50); //CurrentLocation = Degree_Range*analogRead(ADC_Rotary_input)/4095; //digitalWrite(ADC_Rotary_power, LOW); //Serial.println(CurrentLocation); //delay(1000); }
15acb97fa7205bb35d82958eb7b7e549d72c8185
a5dabb4d6c34f22ca76c9b342a5af5c45aec75f1
/src_modified/kernel.h
2e9a57f11a64e315dd32c194f4e16b1f69ab57b6
[]
no_license
lea-and-anthony/ParallelComputing
b351d8f52ec396423a9f3419f6e8a6b87f282188
718a3d1011b3248edb0dda3408f81466d9e29de3
refs/heads/master
2021-01-10T08:08:03.416429
2016-02-02T14:20:51
2016-02-02T14:20:51
45,913,556
0
0
null
null
null
null
UTF-8
C++
false
false
378
h
#ifndef KERNEL_H #define KERNEL_H #include "NoPointerFunctions.h" using namespace vision; void kernel(Sample<FeatureType> &sample, NodeGPU *tree, uint32_t *histograms, FeatureType *features, FeatureType *features_integral, int16_t height, int16_t width, int16_t height_integral, int16_t width_integral, size_t numLabels, int lPXOff, int lPYOff, unsigned int *result); #endif
db1c616e4bf512b74dd31905a17f52ca3d42f1d2
27a58c678a63637efea9d88ce1bcafececf94d8e
/OS_Paint/CreateToolsMenu.cpp
b8181153081015554fe0932aede31ff86ec7fca0
[]
no_license
phillipnitskiy/OS_Paint
757a6c0b69a711672875ddd56c69d21baed6d079
0934253402132dd90babe15dd4bb887eb71079d7
refs/heads/master
2021-01-11T03:39:15.830927
2016-10-15T11:57:04
2016-10-15T11:57:04
69,970,574
1
0
null
null
null
null
UTF-8
C++
false
false
3,226
cpp
#include "stdafx.h" #include "CreateToolsMenu.h" #include "ToolsID.h" HMENU CreateMainMenu() { HMENU hMainMenu = CreateMenu(); int i = 0; CreateMenuItem(hMainMenu, L"File", i++, 0, CreateFileMenu(), FALSE, MFT_STRING); CreateMenuItem(hMainMenu, L"Shape", i++, 0, CreateShapeMenu(), FALSE, MFT_STRING); CreateMenuItem(hMainMenu, L"Action", i++, 0, CreateActionMenu(), FALSE, MFT_STRING); CreateMenuItem(hMainMenu, L"Help", i++, 0, CreateHelpMenu(), FALSE, MFT_STRING); return hMainMenu; } BOOL CreateMenuItem(HMENU hMenu, LPWSTR str, UINT uIns, UINT uCom, HMENU hSubMenu, BOOL flag, UINT fType) { MENUITEMINFO mii; mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_STATE | MIIM_TYPE | MIIM_SUBMENU | MIIM_ID; mii.fType = fType; mii.fState = MFS_ENABLED; mii.dwTypeData = str; mii.cch = sizeof(str); mii.wID = uCom; mii.hSubMenu = hSubMenu; return InsertMenuItem(hMenu, uIns, flag, &mii); } HMENU CreateFileMenu() { HMENU hFileMenu = CreatePopupMenu(); int i = 0; CreateMenuItem(hFileMenu, L"New", i++, ID_NEW, NULL, FALSE, MFT_STRING); CreateMenuItem(hFileMenu, L"Load", i++, ID_LOAD, NULL, FALSE, MFT_STRING); CreateMenuItem(hFileMenu, L"Save", i++, ID_SAVE, NULL, FALSE, MFT_STRING); CreateMenuItem(hFileMenu, L"Print", i++, ID_PRINT, NULL, FALSE, MFT_STRING); CreateMenuItem(hFileMenu, L"Exit", i++, ID_EXIT, NULL, FALSE, MFT_STRING); return hFileMenu; } HMENU CreateShapeMenu(){ HMENU hShapeMenu = CreatePopupMenu(); int i = 0; CreateMenuItem(hShapeMenu, L"Pen", i++, ID_PEN, NULL, FALSE, MFT_STRING); CreateMenuItem(hShapeMenu, L"Line", i++, ID_LINE, NULL, FALSE, MFT_STRING); CreateMenuItem(hShapeMenu, L"Polyline", i++, ID_POLYLINE, NULL, FALSE, MFT_STRING); CreateMenuItem(hShapeMenu, L"Rectangle", i++, ID_RECTANGLE, NULL, FALSE, MFT_STRING); CreateMenuItem(hShapeMenu, L"Ellipse", i++, ID_ELLIPSE, NULL, FALSE, MFT_STRING); CreateMenuItem(hShapeMenu, L"Triangle", i++, ID_TRIANGLE, NULL, FALSE, MFT_STRING); CreateMenuItem(hShapeMenu, L"Rhombus", i++, ID_RHOMBUS, NULL, FALSE, MFT_STRING); CreateMenuItem(hShapeMenu, L"Text", i++, ID_TEXT, NULL, FALSE, MFT_STRING); return hShapeMenu; } HMENU CreateActionMenu(){ HMENU hActionMenu = CreatePopupMenu(); int i = 0; CreateMenuItem(hActionMenu, L"Color", i++, ID_COLOR, NULL, FALSE, MFT_STRING); CreateMenuItem(hActionMenu, L"Fill", i++, ID_FILL, NULL, FALSE, MFT_STRING); CreateMenuItem(hActionMenu, L"Width", i++, 0, CreateWidthMenu(), FALSE, MFT_STRING); CreateMenuItem(hActionMenu, L"Cancel", i++, ID_CANCEL, NULL, FALSE, MFT_STRING); return hActionMenu; } HMENU CreateWidthMenu() { HMENU hWidthMenu = CreatePopupMenu(); int i = 0; CreateMenuItem(hWidthMenu, L"1", i++, ID_WIDTH_1, NULL, FALSE, MFT_STRING); CreateMenuItem(hWidthMenu, L"2", i++, ID_WIDTH_2, NULL, FALSE, MFT_STRING); CreateMenuItem(hWidthMenu, L"3", i++, ID_WIDTH_3, NULL, FALSE, MFT_STRING); CreateMenuItem(hWidthMenu, L"4", i++, ID_WIDTH_4, NULL, FALSE, MFT_STRING); CreateMenuItem(hWidthMenu, L"5", i++, ID_WIDTH_5, NULL, FALSE, MFT_STRING); return hWidthMenu; } HMENU CreateHelpMenu() { HMENU hHelpMenu = CreatePopupMenu(); int i = 0; CreateMenuItem(hHelpMenu, L"About", i++, ID_ABOUT, NULL, FALSE, MFT_STRING); return hHelpMenu; }
f7defc9f1d991ec62b6fc4467fe231fba7597df3
58210a4f2745b96340190f1d6d295d44f93dbe6a
/flash-graph/messaging.cpp
1f75a7d66b4a4893f1f5e78faebd5bda642b52be
[ "Apache-2.0" ]
permissive
Smerity/FlashGraph
3a6be2af79d4e62b7f2471a75aa3f1715a3e7e6f
9c3509ad8e97236eab273b4db27f03c55a7887d8
refs/heads/graph-release
2023-06-25T14:28:13.374922
2014-12-06T00:54:57
2014-12-06T00:54:57
30,141,913
10
4
null
2015-02-01T09:32:29
2015-02-01T09:32:29
null
UTF-8
C++
false
false
2,629
cpp
/** * Copyright 2014 Open Connectome Project (http://openconnecto.me) * Written by Da Zheng ([email protected]) * * This file is part of FlashGraph. * * 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 "messaging.h" int multicast_msg_sender::flush() { if (buf.is_empty()) { assert(mmsg == NULL); return 0; } this->mmsg = NULL; this->num_dests = 0; dest_list.clear(); queue->add(&buf, 1); if (buf.get_num_objs() > 1) printf("there are %d objs in the msg\n", buf.get_num_objs()); // We have to make sure all messages have been sent to the queue. assert(buf.is_empty()); message tmp(alloc.get()); buf = tmp; return 1; } bool multicast_msg_sender::add_dest(local_vid_t id) { int ret = buf.inc_msg_size(sizeof(id.id)); if (ret == 0) { flush(); multicast_message *mmsg_template = (multicast_message *) mmsg_temp_buf; vertex_message *p = (vertex_message *) buf.add(*mmsg_template); // We just add the buffer. We should be able to add the new message. assert(p); this->mmsg = multicast_message::convert2multicast(p); dest_list = this->mmsg->get_dest_list(); buf.inc_msg_size(sizeof(id.id)); } num_dests++; dest_list.add_dest(id); return true; } int multicast_msg_sender::add_dests(local_vid_t ids[], int num) { int orig_num = num; while (num > 0) { int num_allowed = min(buf.get_remaining_size(), num * sizeof(ids[0].id)) / sizeof(ids[0].id); if (num_allowed == 0) { flush(); multicast_message *mmsg_template = (multicast_message *) mmsg_temp_buf; vertex_message *p = (vertex_message *) buf.add(*mmsg_template); // We just add the buffer. We should be able to add the new message. assert(p); this->mmsg = multicast_message::convert2multicast(p); dest_list = this->mmsg->get_dest_list(); num_allowed = min(buf.get_remaining_size(), num * sizeof(ids[0].id)) / sizeof(ids[0].id); assert(num_allowed > 0); } buf.inc_msg_size(num_allowed * sizeof(ids[0].id)); num_dests += num_allowed; dest_list.add_dests(ids, num_allowed); ids += num_allowed; num -= num_allowed; assert(num >= 0); } return orig_num; }
2baf4360ca33f3237af63ba163f81efb77a42215
f1724a7d2f8bdf964b49b42e14b30d198aa84388
/src/GetCookies.cpp
ecf3097ba95688372d51680ce660d4fb74219bcc
[ "MIT" ]
permissive
parndt/capybara-webkit
874847d4a85dd6e75823395eefdc81d2ee55c4ec
5adab74465f42efcf286f0f94ed5a5d1a04ce6cd
refs/heads/master
2020-12-30T18:51:06.473270
2011-12-07T00:30:04
2011-12-07T00:30:04
2,339,317
0
2
null
null
null
null
UTF-8
C++
false
false
652
cpp
#include "GetCookies.h" #include "WebPage.h" #include "NetworkCookieJar.h" GetCookies::GetCookies(WebPage *page, QObject *parent) : Command(page, parent) { m_buffer = ""; } void GetCookies::start(QStringList &arguments) { Q_UNUSED(arguments); NetworkCookieJar *jar = qobject_cast<NetworkCookieJar*>(page() ->networkAccessManager() ->cookieJar()); foreach (QNetworkCookie cookie, jar->getAllCookies()) { m_buffer.append(cookie.toRawForm()); m_buffer.append("\n"); } emit finished(new Response(true, m_buffer)); }
39bbeed9511c14c0f86c4c874b27a10ca465f18f
b480c710a2a17d5738380ceb4fb07d4c91369bac
/H4lCutFlow/Root/.svn/text-base/CutParticleMuon.cxx.svn-base
22dff28bcecfa1ca2142f1adc25afa42cc015d28
[]
no_license
MittalMonika/VBSZZ4l
36783dfd489966295a29a63f98f598d762720cb4
1b2dd019b7a8a5520901f1bcea7a4863d3dfe9a7
refs/heads/master
2021-01-13T13:41:04.987774
2017-06-22T10:56:15
2017-06-22T10:56:15
95,105,662
0
1
null
null
null
null
UTF-8
C++
false
false
6,852
#include "H4lCutFlow/CutParticleMuon.h" using namespace std; CutParticleMuon::CutParticleMuon(EventContainer* eventcont) : CutParticleBase(eventcont) { m_cutFlowName = "muons"; m_muonSelector = ToolHandle<CP::IMuonSelectionTool>("MuonSelectionTool"); if(m_muonSelector.retrieve().isFailure()) { LOG(logERROR) <<"CutParticleMuon::CutParticleMuon() - cannot retrieve CP::IMuonSelectionTool"; exit(1); } } CutParticleMuon::~CutParticleMuon() { clearVars(); } // For cutflow void CutParticleMuon::initCutFlow() { for(Int_t i = 0; i <= muCut::OverLap; i++) { m_cutName.push_back(""); } for (auto sysListItr:m_eventCont->m_sysList){ m_rawCutFlow[sysListItr].reserve(m_cutName.size()); m_weightCutFlow[sysListItr].reserve(m_cutName.size()); for(Int_t i = 0; i < (Int_t) m_cutName.size(); i++) { m_rawCutFlow[sysListItr].push_back(0); m_weightCutFlow[sysListItr].push_back(0); } } m_cutName[muCut::Total] = "Total"; m_cutName[muCut::Preselection] = "Preselection"; m_cutName[muCut::Trigger] = "Trigger"; m_cutName[muCut::ID] = "mu_ID"; m_cutName[muCut::Pt] = "Pt"; m_cutName[muCut::D0] = "D0"; m_cutName[muCut::OverLap] = "OverLap"; } // Function to smear each individual event Bool_t CutParticleMuon::processParticle(const ParticleVar* currPart) { if(currPart->getPartType() != ParticleType::Muon) { LOG(logERROR)<<"CutParticleMuon::processParticle - Particle Type not supported"; LOG(logERROR)<<"Particle Type: "<<currPart->getPartType(); exit(1); } // For keeping track //static Int_t printInfo = 0; // get the xAOD Jet const xAOD::Muon *mu = dynamic_cast<const xAOD::Muon*>(currPart->getParticle()); // Treat Sili muons combined for now //if(mu->muonType() == xAOD::Muon::MuonStandAlone || mu->muonType() == xAOD::Muon::SiliconAssociatedForwardMuon) if(mu->muonType() == xAOD::Muon::MuonStandAlone) return processStandAloneMuon(mu); else if (mu->muonType() == xAOD::Muon::CaloTagged) return processCaloMuon(mu); else return processCombinedMuon(mu); return true; } // Staco Muons cuts Bool_t CutParticleMuon::processCombinedMuon(const xAOD::Muon* currMuon) { // get the xAOD Muon const xAOD::Muon *mu_i = currMuon; //if(!mu_i->primaryTrackParticle()) //{ // LOG(logERROR)<<"Event number: "<<m_eventCont->eventInfo->eventNumber(); //} // To get the track informations const xAOD::TrackParticle* track_i = mu_i->primaryTrackParticle(); // If there is no track, return false.. if(!track_i) return false; const xAOD::VertexContainer* vertexCont = 0; m_eventCont->getEvent()->retrieve( vertexCont, "PrimaryVertices" ).isSuccess(); // Assume this is the primary vertex const xAOD::Vertex* pvx = vertexCont->at(0); Double_t currZ0 = track_i->z0() + track_i->vz() - pvx->z(); currZ0 = currZ0 * sin(track_i->theta()); LOG(logDEBUG)<<"Combined muon"; LOG(logDEBUG)<<"Mu pT: "<<mu_i->pt(); LOG(logDEBUG)<<"Mu author: "<<mu_i->author(); LOG(logDEBUG)<<"Mu quality: "<<m_muonSelector->getQuality(*mu_i); LOG(logDEBUG)<<"Mu currZ0: "<<currZ0; // For filling for plots m_eventCont->outTree->updateHistVar("muStacoPTHist", mu_i->pt()); m_eventCont->outTree->updateHistVar("muStacoEtaHist", mu_i->eta()); // Muon selector tool Cut if(!(bool)m_muonSelector->accept(*mu_i)) return false; updateCutFlow(1, muCut::ID); // Kinematic Cut // Pt Double_t pTCut = 5 * 1000; if(mu_i->pt() > pTCut) {updateCutFlow(1, muCut::Pt);} else return false; // D0 cut if(fabs(track_i->d0()) < 1 && fabs(currZ0) < 0.5) {updateCutFlow(1,muCut::D0);} else return false; m_eventCont->outTree->updateHistVar("muStacoPTHistAfterSel", mu_i->pt()); m_eventCont->outTree->updateHistVar("muStacoEtaHistAfterSel", mu_i->eta()); //LOG(logDEBUG)<<"This combined muon passed"; return true; } // Calo muon cuts Bool_t CutParticleMuon::processCaloMuon(const xAOD::Muon* currMuon) { LOG(logDEBUG)<<"Calo muons"; // get the xAOD Muon const xAOD::Muon *mu_i = currMuon; // To get the track informations const xAOD::TrackParticle* track_i = mu_i->primaryTrackParticle(); const xAOD::VertexContainer* vertexCont = 0; m_eventCont->getEvent()->retrieve( vertexCont, "PrimaryVertices" ).isSuccess(); // Assume this is the primary vertex const xAOD::Vertex* pvx = vertexCont->at(0); Double_t currZ0 = track_i->z0() + track_i->vz() - pvx->z(); currZ0 = currZ0 * sin(track_i->theta()); LOG(logDEBUG)<<"Calo muons"; LOG(logDEBUG)<<"Mu pT: "<<mu_i->pt(); LOG(logDEBUG)<<"Mu author: "<<mu_i->author(); LOG(logDEBUG)<<"Mu quality: "<<m_muonSelector->getQuality(*mu_i); // For filling for plots m_eventCont->outTree->updateHistVar("muCaloPTHist", mu_i->pt()); m_eventCont->outTree->updateHistVar("muCaloEtaHist", mu_i->eta()); // Muon selector tool Cut if(!(bool)m_muonSelector->accept(*mu_i)) return false; updateCutFlow(1, muCut::ID); // Kinematic Cut if(mu_i->pt() > 15 * 1000) {updateCutFlow(1, muCut::Pt);} else return false; if(fabs(track_i->d0()) < 1 && fabs(currZ0) < 0.5) {updateCutFlow(1, muCut::D0);} else return false; m_eventCont->outTree->updateHistVar("muCaloPTHistAfterSel", mu_i->pt()); m_eventCont->outTree->updateHistVar("muCaloEtaHistAfterSel", mu_i->eta()); //LOG(logDEBUG)<<"This calo muon passed"; return true; } // StandAlone cuts Bool_t CutParticleMuon::processStandAloneMuon(const xAOD::Muon* currMuon) { LOG(logDEBUG)<<"StandAlone muons"; // get the xAOD Muon const xAOD::Muon *mu_i = currMuon; LOG(logDEBUG)<<"Standalone muons"; LOG(logDEBUG)<<"Mu pT: "<<mu_i->pt(); LOG(logDEBUG)<<"Mu author: "<<mu_i->author(); LOG(logDEBUG)<<"Mu quality: "<<m_muonSelector->getQuality(*mu_i); m_eventCont->outTree->updateHistVar("muSAPTHist", mu_i->pt()); m_eventCont->outTree->updateHistVar("muSAEtaHist", mu_i->eta()); if(!(bool)m_muonSelector->accept(*mu_i)) return false; updateCutFlow(1, muCut::ID); // Kinematic Cut Double_t pTCut = 5 * 1000; if(mu_i->pt() > pTCut) {updateCutFlow(1, muCut::Pt);} else return false; updateCutFlow(1, muCut::D0); m_eventCont->outTree->updateHistVar("muSAPTHistAfterSel", mu_i->pt()); m_eventCont->outTree->updateHistVar("muSAEtaHistAfterSel", mu_i->eta()); //LOG(logDEBUG)<<"Standalone muon passed"; return true; }
2bd31a55e8a2dc3c5284ac82a7b93f2013b57e44
de363f14b8027d705309611e1e2c8d1800719c35
/src/core/uff_par.h
66d446b27e1309566d2b14f53319033ff8c77bf4
[]
no_license
conradhuebler/curcuma
422c344a17c13b5acd9de02e116c9704055b488a
7cc945f2b06878f46e365c2a6f9b7abac95e005f
refs/heads/master
2023-09-05T21:30:14.155790
2023-07-11T12:02:03
2023-07-11T12:02:03
231,378,992
12
1
null
null
null
null
UTF-8
C++
false
false
16,092
h
/* * <Simple UFF implementation for Cucuma. > * Copyright (C) 2022 Conrad Hübler <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /* * originally published at: J. Am. Chem. Soc. (1992) 114(25) p. 10024-10035. * as universal force field parameters */ #pragma once #include "json.hpp" #include <Eigen/Dense> #include <vector> using json = nlohmann::json; static const std::vector<double> CoordinationNumber = { -1, // leading index 1, // H 0, // He 1, // Li 2, // Be 3, // B 4, // C 5, // N 2, // O 1, // F 0, // Ne 1, // Na 2, // Mg 3, // Al 4, // Si 5, // P 6, // S 1, // Cl 0, // Ar 1, // K 2, // Ca 3, // Sc 4, // Ti 5, // V 6, // Cr 7, // Mn 3, // Fe 3, // Co 3, // Ni 2, // Cu 2, // Zn 3, // Ga 4, // Ge 5, // As 6, // Se 1, // Br 0, // Kr 1, // Rb 2, // Sr 3, // Y 4, // Zr 5, // Nb 6, // Mo 1.28, // Tc 1.25, // Ru 1.25, // Rh 1.20, // Pd 1.28, // Ag 1.36, // Cd 1.42, // In 1.40, // Sn 1.40, // Sb 1.36, // Te 1.33, // I 1.31, // Xe 2.32, // Cs 1.96, // Ba 1.69, // La 1.69, // Ce - taken from La 1.69, // Pr - taken from La 1.69, // Nd - taken from La 1.69, // Pm - taken from La 1.69, // Sm - taken from La 1.69, // Eu - taken from La 1.69, // Gd - taken from La 1.69, // Tb - taken from La 1.69, // Dy - taken from La 1.69, // Ho - taken from La 1.69, // Er - taken from La 1.69, // Tm - taken from La 1.69, // Yb - taken from La 1.60, // Lu 1.50, // Hf 1.38, // Ta 1.46, // W 1.59, // Re 1.28, // Os 1.37, // Ir 1.28, // Pt 1.44, // Au 1.49, // Hg 1.48, // Tl 1.47, // Pb 1.46, // Bi 1.46, // Po - taken from Bi 1.46 // At - taken from Bi }; const std::vector<std::vector<double>> UFFParameters{ { 0.01, 180, 0.4, 5000, 12, 10.0, 0, 0, 9.66, 14.92, 0.7 }, // Du 0 { 0.354, 180, 2.886, 0.044, 12, 0.712, 0, 0, 4.528, 6.9452, 0.371 }, // H_ 1 { 0.354, 180, 2.886, 0.044, 12, 0.712, 0, 0, 4.528, 6.9452, 0.371 }, // D 2 { 0.46, 83.5, 2.886, 0.044, 12, 0.712, 0, 0, 4.528, 6.9452, 0.371 }, // H_b 3 { 0.849, 90, 2.362, 0.056, 15.24, 0.098, 0, 0, 9.66, 14.92, 1.3 }, // He4+4 4 { 1.336, 180, 2.451, 0.025, 12, 1.026, 0, 2, 3.006, 2.386, 1.557 }, // Li 5 { 1.074, 109.47, 2.745, 0.085, 12, 1.565, 0, 2, 4.877, 4.443, 1.24 }, // Be3+2 6 { 0.838, 109.47, 4.083, 0.18, 12.052, 1.755, 0, 2, 5.11, 4.75, 0.822 }, // B_3 7 { 0.828, 120, 4.083, 0.18, 12.052, 1.755, 0, 2, 5.11, 4.75, 0.822 }, // B_2 8 { 0.757, 109.47, 3.851, 0.105, 12.73, 1.912, 2.119, 2, 5.343, 5.063, 0.759 }, // C_3 9 { 0.729, 120, 3.851, 0.105, 12.73, 1.912, 0, 2, 5.343, 5.063, 0.759 }, // C_R 10 { 0.732, 120, 3.851, 0.105, 12.73, 1.912, 0, 2, 5.343, 5.063, 0.759 }, // C_2 11 { 0.706, 180, 3.851, 0.105, 12.73, 1.912, 0, 2, 5.343, 5.063, 0.759 }, // C_1 12 { 0.7, 106.7, 3.66, 0.069, 13.407, 2.544, 0.45, 2, 6.899, 5.88, 0.715 }, // N_3 13 { 0.699, 120, 3.66, 0.069, 13.407, 2.544, 0, 2, 6.899, 5.88, 0.715 }, // N_R 14 { 0.685, 111.2, 3.66, 0.069, 13.407, 2.544, 0, 2, 6.899, 5.88, 0.715 }, // N_2 15 { 0.656, 180, 3.66, 0.069, 13.407, 2.544, 0, 2, 6.899, 5.88, 0.715 }, // N_1 16 { 0.658, 104.51, 3.5, 0.06, 14.085, 2.3, 0.018, 2, 8.741, 6.682, 0.669 }, // O_3 17 { 0.528, 146, 3.5, 0.06, 14.085, 2.3, 0.018, 2, 8.741, 6.682, 0.669 }, // O_3_z 18 { 0.68, 110, 3.5, 0.06, 14.085, 2.3, 0, 2, 8.741, 6.682, 0.669 }, // O_R 19 { 0.634, 120, 3.5, 0.06, 14.085, 2.3, 0, 2, 8.741, 6.682, 0.669 }, // O_2 20 { 0.639, 180, 3.5, 0.06, 14.085, 2.3, 0, 2, 8.741, 6.682, 0.669 }, // O_1 21 { 0.668, 180, 3.364, 0.05, 14.762, 1.735, 0, 2, 10.874, 7.474, 0.706 }, // F_ 22 { 0.92, 90, 3.243, 0.042, 15.44, 0.194, 0, 2, 11.04, 10.55, 1.768 }, // Ne4+4 23 { 1.539, 180, 2.983, 0.03, 12, 1.081, 0, 1.25, 2.843, 2.296, 2.085 }, // Na 24 { 1.421, 109.47, 3.021, 0.111, 12, 1.787, 0, 1.25, 3.951, 3.693, 1.5 }, // Mg3+2 25 { 1.244, 109.47, 4.499, 0.505, 11.278, 1.792, 0, 1.25, 4.06, 3.59, 1.201 }, // Al3 26 { 1.117, 109.47, 4.295, 0.402, 12.175, 2.323, 1.225, 1.25, 4.168, 3.487, 1.176 }, // Si3 27 { 1.101, 93.8, 4.147, 0.305, 13.072, 2.863, 2.4, 1.25, 5.463, 4, 1.102 }, // P_3+3 28 { 1.056, 109.47, 4.147, 0.305, 13.072, 2.863, 2.4, 1.25, 5.463, 4, 1.102 }, // P_3+5 29 { 1.056, 109.47, 4.147, 0.305, 13.072, 2.863, 2.4, 1.25, 5.463, 4, 1.102 }, // P_3+q 30 { 1.064, 92.1, 4.035, 0.274, 13.969, 2.703, 0.484, 1.25, 6.928, 4.486, 1.047 }, // S_3+2 31 { 1.049, 103.2, 4.035, 0.274, 13.969, 2.703, 0.484, 1.25, 6.928, 4.486, 1.047 }, // S_3+4 32 { 1.027, 109.47, 4.035, 0.274, 13.969, 2.703, 0.484, 1.25, 6.928, 4.486, 1.047 }, // S_3+6 33 { 1.077, 92.2, 4.035, 0.274, 13.969, 2.703, 0, 1.25, 6.928, 4.486, 1.047 }, // S_R 34 { 0.854, 120, 4.035, 0.274, 13.969, 2.703, 0, 1.25, 6.928, 4.486, 1.047 }, // S_2 35 { 1.044, 180, 3.947, 0.227, 14.866, 2.348, 0, 1.25, 8.564, 4.946, 0.994 }, // Cl 36 { 1.032, 90, 3.868, 0.185, 15.763, 0.3, 0, 1.25, 9.465, 6.355, 2.108 }, // Ar4+4 37 { 1.953, 180, 3.812, 0.035, 12, 1.165, 0, 0.7, 2.421, 1.92, 2.586 }, // K_ 38 { 1.761, 90, 3.399, 0.238, 12, 2.141, 0, 0.7, 3.231, 2.88, 2 }, // Ca6+2 39 { 1.513, 109.47, 3.295, 0.019, 12, 2.592, 0, 0.7, 3.395, 3.08, 1.75 }, // Sc3+3 40 { 1.412, 109.47, 3.175, 0.017, 12, 2.659, 0, 0.7, 3.47, 3.38, 1.607 }, // Ti3+4 41 { 1.412, 90, 3.175, 0.017, 12, 2.659, 0, 0.7, 3.47, 3.38, 1.607 }, // Ti6+4 42 { 1.402, 109.47, 3.144, 0.016, 12, 2.679, 0, 0.7, 3.65, 3.41, 1.47 }, // V_3+5 43 { 1.345, 90, 3.023, 0.015, 12, 2.463, 0, 0.7, 3.415, 3.865, 1.402 }, // Cr6+3 44 { 1.382, 90, 2.961, 0.013, 12, 2.43, 0, 0.7, 3.325, 4.105, 1.533 }, // Mn6+2 45 { 1.27, 109.47, 2.912, 0.013, 12, 2.43, 0, 0.7, 3.76, 4.14, 1.393 }, // Fe3+2 46 { 1.335, 90, 2.912, 0.013, 12, 2.43, 0, 0.7, 3.76, 4.14, 1.393 }, // Fe6+2 47 { 1.241, 90, 2.872, 0.014, 12, 2.43, 0, 0.7, 4.105, 4.175, 1.406 }, // Co6+3 48 { 1.164, 90, 2.834, 0.015, 12, 2.43, 0, 0.7, 4.465, 4.205, 1.398 }, // Ni4+2 49 { 1.302, 109.47, 3.495, 0.005, 12, 1.756, 0, 0.7, 4.2, 4.22, 1.434 }, // Cu3+1 50 { 1.193, 109.47, 2.763, 0.124, 12, 1.308, 0, 0.7, 5.106, 4.285, 1.4 }, // Zn3+2 51 { 1.26, 109.47, 4.383, 0.415, 11, 1.821, 0, 0.7, 3.641, 3.16, 1.211 }, // Ga3+3 52 { 1.197, 109.47, 4.28, 0.379, 12, 2.789, 0.701, 0.7, 4.051, 3.438, 1.189 }, // Ge3 53 { 1.211, 92.1, 4.23, 0.309, 13, 2.864, 1.5, 0.7, 5.188, 3.809, 1.204 }, // As3+3 54 { 1.19, 90.6, 4.205, 0.291, 14, 2.764, 0.335, 0.7, 6.428, 4.131, 1.224 }, // Se3+2 55 { 1.192, 180, 4.189, 0.251, 15, 2.519, 0, 0.7, 7.79, 4.425, 1.141 }, // Br 56 { 1.147, 90, 4.141, 0.22, 16, 0.452, 0, 0.7, 8.505, 5.715, 2.27 }, // Kr4+4 57 { 2.26, 180, 4.114, 0.04, 12, 1.592, 0, 0.2, 2.331, 1.846, 2.77 }, // Rb 58 { 2.052, 90, 3.641, 0.235, 12, 2.449, 0, 0.2, 3.024, 2.44, 2.415 }, // Sr6+2 59 { 1.698, 109.47, 3.345, 0.072, 12, 3.257, 0, 0.2, 3.83, 2.81, 1.998 }, // Y_3+3 60 { 1.564, 109.47, 3.124, 0.069, 12, 3.667, 0, 0.2, 3.4, 3.55, 1.758 }, // Zr3+4 61 { 1.473, 109.47, 3.165, 0.059, 12, 3.618, 0, 0.2, 3.55, 3.38, 1.603 }, // Nb3+5 62 { 1.467, 90, 3.052, 0.056, 12, 3.4, 0, 0.2, 3.465, 3.755, 1.53 }, // Mo6+6 63 { 1.484, 109.47, 3.052, 0.056, 12, 3.4, 0, 0.2, 3.465, 3.755, 1.53 }, // Mo3+6 64 { 1.322, 90, 2.998, 0.048, 12, 3.4, 0, 0.2, 3.29, 3.99, 1.5 }, // Tc6+5 65 { 1.478, 90, 2.963, 0.056, 12, 3.4, 0, 0.2, 3.575, 4.015, 1.5 }, // Ru6+2 66 { 1.332, 90, 2.929, 0.053, 12, 3.5, 0, 0.2, 3.975, 4.005, 1.509 }, // Rh6+3 67 { 1.338, 90, 2.899, 0.048, 12, 3.21, 0, 0.2, 4.32, 4, 1.544 }, // Pd4+2 68 { 1.386, 180, 3.148, 0.036, 12, 1.956, 0, 0.2, 4.436, 3.134, 1.622 }, // Ag1+1 69 { 1.403, 109.47, 2.848, 0.228, 12, 1.65, 0, 0.2, 5.034, 3.957, 1.6 }, // Cd3+2 70 { 1.459, 109.47, 4.463, 0.599, 11, 2.07, 0, 0.2, 3.506, 2.896, 1.404 }, // In3+3 71 { 1.398, 109.47, 4.392, 0.567, 12, 2.961, 0.199, 0.2, 3.987, 3.124, 1.354 }, // Sn3 72 { 1.407, 91.6, 4.42, 0.449, 13, 2.704, 1.1, 0.2, 4.899, 3.342, 1.404 }, // Sb3+3 73 { 1.386, 90.25, 4.47, 0.398, 14, 2.882, 0.3, 0.2, 5.816, 3.526, 1.38 }, // Te3+2 74 { 1.382, 180, 4.5, 0.339, 15, 2.65, 0, 0.2, 6.822, 3.762, 1.333 }, // I_ 75 { 1.267, 90, 4.404, 0.332, 12, 0.556, 0, 0.2, 7.595, 4.975, 2.459 }, // Xe4+4 76 { 2.57, 180, 4.517, 0.045, 12, 1.573, 0, 0.1, 2.183, 1.711, 2.984 }, // Cs { 2.277, 90, 3.703, 0.364, 12, 2.727, 0, 0.1, 2.814, 2.396, 2.442 }, // Ba6+2 { 1.943, 109.47, 3.522, 0.017, 12, 3.3, 0, 0.1, 2.8355, 2.7415, 2.071 }, // La3+3 { 1.841, 90, 3.556, 0.013, 12, 3.3, 0, 0.1, 2.774, 2.692, 1.925 }, // Ce6+3 { 1.823, 90, 3.606, 0.01, 12, 3.3, 0, 0.1, 2.858, 2.564, 2.007 }, // Pr6+3 { 1.816, 90, 3.575, 0.01, 12, 3.3, 0, 0.1, 2.8685, 2.6205, 2.007 }, // Nd6+3 { 1.801, 90, 3.547, 0.009, 12, 3.3, 0, 0.1, 2.881, 2.673, 2 }, // Pm6+3 { 1.78, 90, 3.52, 0.008, 12, 3.3, 0, 0.1, 2.9115, 2.7195, 1.978 }, // Sm6+3 { 1.771, 90, 3.493, 0.008, 12, 3.3, 0, 0.1, 2.8785, 2.7875, 2.227 }, // Eu6+3 { 1.735, 90, 3.368, 0.009, 12, 3.3, 0, 0.1, 3.1665, 2.9745, 1.968 }, // Gd6+3 { 1.732, 90, 3.451, 0.007, 12, 3.3, 0, 0.1, 3.018, 2.834, 1.954 }, // Tb6+3 { 1.71, 90, 3.428, 0.007, 12, 3.3, 0, 0.1, 3.0555, 2.8715, 1.934 }, // Dy6+3 { 1.696, 90, 3.409, 0.007, 12, 3.416, 0, 0.1, 3.127, 2.891, 1.925 }, // Ho6+3 { 1.673, 90, 3.391, 0.007, 12, 3.3, 0, 0.1, 3.1865, 2.9145, 1.915 }, // Er6+3 { 1.66, 90, 3.374, 0.006, 12, 3.3, 0, 0.1, 3.2514, 2.9329, 2 }, // Tm6+3 { 1.637, 90, 3.355, 0.228, 12, 2.618, 0, 0.1, 3.2889, 2.965, 2.158 }, // Yb6+3 { 1.671, 90, 3.64, 0.041, 12, 3.271, 0, 0.1, 2.9629, 2.4629, 1.896 }, // Lu6+3 { 1.611, 109.47, 3.141, 0.072, 12, 3.921, 0, 0.1, 3.7, 3.4, 1.759 }, // Hf3+4 { 1.511, 109.47, 3.17, 0.081, 12, 4.075, 0, 0.1, 5.1, 2.85, 1.605 }, // Ta3+5 { 1.392, 90, 3.069, 0.067, 12, 3.7, 0, 0.1, 4.63, 3.31, 1.538 }, // W_6+6 { 1.526, 109.47, 3.069, 0.067, 12, 3.7, 0, 0.1, 4.63, 3.31, 1.538 }, // W_3+4 { 1.38, 109.47, 3.069, 0.067, 12, 3.7, 0, 0.1, 4.63, 3.31, 1.538 }, // W_3+6 { 1.372, 90, 2.954, 0.066, 12, 3.7, 0, 0.1, 3.96, 3.92, 1.6 }, // Re6+5 { 1.314, 109.47, 2.954, 0.066, 12, 3.7, 0, 0.1, 3.96, 3.92, 1.6 }, // Re3+7 { 1.372, 90, 3.12, 0.037, 12, 3.7, 0, 0.1, 5.14, 3.63, 1.7 }, // Os6+6 { 1.371, 90, 2.84, 0.073, 12, 3.731, 0, 0.1, 5, 4, 1.866 }, // Ir6+3 { 1.364, 90, 2.754, 0.08, 12, 3.382, 0, 0.1, 4.79, 4.43, 1.557 }, // Pt4+2 { 1.262, 90, 3.293, 0.039, 12, 2.625, 0, 0.1, 4.894, 2.586, 1.618 }, // Au4+3 { 1.34, 180, 2.705, 0.385, 12, 1.75, 0, 0.1, 6.27, 4.16, 1.6 }, // Hg1+2 { 1.518, 120, 4.347, 0.68, 11, 2.068, 0, 0.1, 3.2, 2.9, 1.53 }, // Tl3+3 { 1.459, 109.47, 4.297, 0.663, 12, 2.846, 0.1, 0.1, 3.9, 3.53, 1.444 }, // Pb3 { 1.512, 90, 4.37, 0.518, 13, 2.47, 1, 0.1, 4.69, 3.74, 1.514 }, // Bi3+3 { 1.5, 90, 4.709, 0.325, 14, 2.33, 0.3, 0.1, 4.21, 4.21, 1.48 }, // Po3+2 { 1.545, 180, 4.75, 0.284, 15, 2.24, 0, 0.1, 4.75, 4.75, 1.47 }, // At { 1.42, 90, 4.765, 0.248, 16, 0.583, 0, 0.1, 5.37, 5.37, 2.2 }, // Rn4+4 { 2.88, 180, 4.9, 0.05, 12, 1.847, 0, 0, 2, 2, 2.3 }, // Fr { 2.512, 90, 3.677, 0.404, 12, 2.92, 0, 0, 2.843, 2.434, 2.2 }, // Ra6+2 { 1.983, 90, 3.478, 0.033, 12, 3.9, 0, 0, 2.835, 2.835, 2.108 }, // Ac6+3 { 1.721, 90, 3.396, 0.026, 12, 4.202, 0, 0, 3.175, 2.905, 2.018 }, // Th6+4 { 1.711, 90, 3.424, 0.022, 12, 3.9, 0, 0, 2.985, 2.905, 1.8 }, // Pa6+4 { 1.684, 90, 3.395, 0.022, 12, 3.9, 0, 0, 3.341, 2.853, 1.713 }, // U_6+4 { 1.666, 90, 3.424, 0.019, 12, 3.9, 0, 0, 3.549, 2.717, 1.8 }, // Np6+4 { 1.657, 90, 3.424, 0.016, 12, 3.9, 0, 0, 3.243, 2.819, 1.84 }, // Pu6+4 { 1.66, 90, 3.381, 0.014, 12, 3.9, 0, 0, 2.9895, 3.0035, 1.942 }, // Am6+4 { 1.801, 90, 3.326, 0.013, 12, 3.9, 0, 0, 2.8315, 3.1895, 1.9 }, // Cm6+3 { 1.761, 90, 3.339, 0.013, 12, 3.9, 0, 0, 3.1935, 3.0355, 1.9 }, // Bk6+3 { 1.75, 90, 3.313, 0.013, 12, 3.9, 0, 0, 3.197, 3.101, 1.9 }, // Cf6+3 { 1.724, 90, 3.299, 0.012, 12, 3.9, 0, 0, 3.333, 3.089, 1.9 }, // Es6+3 { 1.712, 90, 3.286, 0.012, 12, 3.9, 0, 0, 3.4, 3.1, 1.9 }, // Fm6+3 { 1.689, 90, 3.274, 0.011, 12, 3.9, 0, 0, 3.47, 3.11, 1.9 }, // Md6+3 { 1.679, 90, 3.248, 0.011, 12, 3.9, 0, 0, 3.475, 3.175, 1.9 }, // No6+3 { 1.698, 90, 3.236, 0.011, 12, 3.9, 0, 0, 3.5, 3.2, 1.9 } // Lw6+3 }; const std::vector<int> Conjugated = { 10, 11, 14, 15, 19, 20 }; const std::vector<int> Triples = { 12, 16, 21 }; const int cR = 0; const int cTheta0 = 1; const int cx = 2; const int cD = 3; const int cZeta = 4; const int cZ = 5; const int cV = 6; const int cU = 7; const int cXi = 8; const int cHard = 9; const int cRadius = 10; struct UFFBond { int i, j; double r0, kij; }; struct UFFAngle { int i, j, k; double kijk, C0, C1, C2; }; struct UFFDihedral { int i, j, k, l; double V, n, phi0; }; struct UFFInversion { int i, j, k, l; double kijkl, C0, C1, C2; }; struct UFFvdW { int i, j; double Dij, xij; }; typedef std::array<double, 3> v; inline std::array<double, 3> AddVector(const v& x, const v& y) { return std::array<double, 3>{ x[0] + y[0], x[1] + y[1], x[2] + y[2] }; } inline Eigen::Vector3d AddVector(const Eigen::Vector3d& x, const Eigen::Vector3d& y) { return x + y; } inline std::array<double, 3> SubVector(const v& x, const v& y) { return std::array<double, 3>{ x[0] - y[0], x[1] - y[1], x[2] - y[2] }; } inline Eigen::Vector3d SubVector(const Eigen::Vector3d& x, const Eigen::Vector3d& y) { return x - y; } class TContainer { public: TContainer() = default; bool insert(std::vector<int> vector) { m_storage.push_back(vector); return true; } inline void clean() { std::set<std::vector<int>> s; unsigned size = m_storage.size(); for (unsigned i = 0; i < size; ++i) s.insert(m_storage[i]); m_storage.assign(s.begin(), s.end()); } const std::vector<std::vector<int>>& Storage() const { return m_storage; } private: std::vector<std::vector<int>> m_storage, m_sorted; }; const json UFFParameterJson{ { "bond_scaling", 1 }, { "angle_scaling", 1 }, { "dihedral_scaling", 1 }, { "inversion_scaling", 1 }, { "vdw_scaling", 1 }, { "rep_scaling", 1 }, { "coulomb_scaling", 1 }, { "bond_force", 664.12 }, { "angle_force", 664.12 }, { "differential", 1e-7 }, { "h4_scaling", 0 }, { "hh_scaling", 0 }, { "h4_oh_o", 2.32 }, { "h4_oh_n", 3.10 }, { "h4_nh_o", 1.07 }, { "h4_nh_n", 2.01 }, { "h4_wh_o", 0.42 }, { "h4_nh4", 3.61 }, { "h4_coo", 1.41 }, { "hh_rep_k", 0.42 }, { "hh_rep_e", 12.7 }, { "hh_rep_r0", 2.3 }, { "d4", 0 }, { "d3", 0 }, { "d_s6", 1.00 }, { "d_s8", 1.20065498 }, { "d_s10", 0 }, { "d_s9", 1 }, { "d_a1", 0.40085597 }, { "d_a2", 5.02928789 }, { "d_alp", 16 }, { "d_func", "pbe0" }, { "d_atm", true }, { "param_file", "none" }, { "uff_file", "none" }, { "writeparam", "none" }, { "writeuff", "none" }, { "verbose", false }, { "rings", false }, { "threads", 1 }, { "gradient", 0 } };
7b8b5f3fbe9e574e65c329cd4c23b6a425f37e67
f95cd23d01ebc53c872052a299ffdbe26736c449
/1. Algorithmic Toolbox/week_5/primitive_calculator/primitive_calculator.cpp
0131b5382c8bd8582c118b9704fe399249064c5f
[ "MIT" ]
permissive
manparvesh/coursera-ds-algorithms
4126492a1ea46694c6a5cfab843addac68c21749
99e08921c0c0271e66a9aea42e7d38b7df494007
refs/heads/master
2021-06-18T15:22:35.467761
2020-10-05T02:54:33
2020-10-05T02:54:33
101,484,382
63
50
MIT
2023-06-16T20:11:58
2017-08-26T12:28:34
C++
UTF-8
C++
false
false
605
cpp
#include <iostream> #include <vector> #include <algorithm> using std::vector; vector<int> optimal_sequence(int n) { std::vector<int> sequence; while (n >= 1) { sequence.push_back(n); if (n % 3 == 0) { n /= 3; } else if (n % 2 == 0) { n /= 2; } else { n = n - 1; } } reverse(sequence.begin(), sequence.end()); return sequence; } int main() { int n; std::cin >> n; vector<int> sequence = optimal_sequence(n); std::cout << sequence.size() - 1 << std::endl; for (size_t i = 0; i < sequence.size(); ++i) { std::cout << sequence[i] << " "; } }
dce64912610b431ca1c0bbfc1375f25323513f5d
053309314b081dcb3fca08fc5ea15e6e8596141d
/day12/source/std/post.cpp
7d3e2e4e96d25570f0364ba605658940c5b28bb4
[]
no_license
cppascalinux/jinanjixun
a6283e1bbdc4cac938131e8061a8b5290f6bb1dc
555a95c7baf940c38236ac559f0a2c11a34edd0c
refs/heads/master
2020-05-29T14:46:31.982813
2019-06-14T07:14:19
2019-06-14T07:14:19
189,192,981
2
1
null
null
null
null
UTF-8
C++
false
false
4,475
cpp
#include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++) #define per(i,a,n) for (int i=n-1;i>=a;i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef vector<int> VI; typedef long long ll; typedef pair<int,int> PII; const ll mod=1000000007; ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} // head const int N=200010; int n,c,segl[N]; ll l,a[N*2],sa[N*2],ans; vector<int> prv[N],ansr; vector<ll> vdp[N]; ll weight(int x,int y) { // x...y if (x>y) return 0; int md=(x+y)/2; return (sa[y]-sa[md-1])-(y-md+1)*a[md]+a[md]*(md-x)-(sa[md-1]-sa[x-1]); } //dp: for i = 1 to n : f[i]= min_{0<=j<i} {f[j]+w(j,i)} ll f[N]; int opt[N]; ll val(int j,int i); //let val(j,i) = f[j]+w(j,i) int solve(ll c,int ty=0){ static int vo[N],po[N]; int p=1,q=0; f[0]=0; auto val=[&](int j,int i) { return f[j]+weight(j+1,i)+c; }; auto check=[&](int p,int q,int r) { return (ty==0)?val(p,r)<=val(q,r):val(p,r)<val(q,r); }; rep(i,0,n){ while(p<=q && check(i,vo[q],po[q]))q--;// if(p>q)po[++q]=i+1,vo[q]=i; else{ int l=po[q],r=n; while(l<=r){ int mid=(l+r)>>1; if(check(i,vo[q],mid))r=mid-1;// else l=mid+1; } if(l<=n) po[++q]=l,vo[q]=i; } while(p<q && i+1>=po[p+1])p++; f[i+1]=val(vo[p],i+1); opt[i+1]=vo[p]; } int x=n,cnt=0;; while (x!=0) x=opt[x],cnt++; return cnt; } VI getway() { VI p; int x=n; while (x!=0) x=opt[x],p.pb(x); reverse(all(p)); p.pb(n); return p; } void gao(int id,int fl,int fr,int l,int r) { if (l>r) return; int md=(l+r)>>1; ll minv=1ll<<60; int minp=-1; for (int i=fl;i<=fr;i++) { ll v=vdp[id-1][i-segl[id-1]]+weight(i+1,md); if (v<minv) { minv=v; minp=i; } } vdp[id][md-segl[id]]=minv; prv[id][md-segl[id]]=minp; if (l<md) gao(id,fl,minp,l,md-1); if (md<r) gao(id,minp,fr,md+1,r); } void solve(VI &p,VI &q) { if (p[0]>q[0]) return; VI mid(c); mid[0]=(p[0]+q[0])/2; // printf("%d %d %d\n",p[0],q[0],mid[0]); ll ret=1ll<<60; if (c>1) { rep(i,p[1],q[1]+1) { prv[1][i-segl[1]]=mid[0]; vdp[1][i-segl[1]]=weight(mid[0]+1,i); } rep(i,2,c) { gao(i,p[i-1],q[i-1],p[i],q[i]); } rep(i,p[c-1],q[c-1]+1) { ll v=vdp[c-1][i-segl[c-1]]+weight(i+1,mid[0]+n); if (v<ret) { ret=v; mid[c-1]=i; } } per(i,0,c-1) { mid[i]=prv[i+1][mid[i+1]-segl[i+1]]; } } else { ret=weight(mid[0]+1,mid[0]+n); } if (ret<ans) { ans=ret; ansr=mid; } if (p[0]<mid[0]) { --mid[0]; solve(p,mid); ++mid[0]; } if (mid[0]<q[0]) { ++mid[0]; solve(mid,q); --mid[0]; } } int main() { freopen("post.in","r",stdin); freopen("post.out","w",stdout); scanf("%d%d%lld",&n,&c,&l); rep(i,1,n+1) scanf("%lld",a+i); rep(i,1,n+1) a[i+n]=a[i]+l; rep(i,1,2*n+1) sa[i]=sa[i-1]+a[i]; ll pl=0,pr=l*n/c+1; ll pres=0; rep(i,1,c+1) pres+=weight((ll)(i-1)*n/c+1,(ll)i*n/c); pr=min(pr,pres+10); while (pl+1<pr) { ll md=(pl+pr)>>1; int w=solve(md,0); // dp[w]=f[n]-md*c if (w==c) { pl=md; break; } if (w>c) pl=md; else pr=md; ll dpw=f[n]-md*w; if (w>c) pl=max(pl,dpw/(n-w+1)-10); // fprintf(stderr,"%lld %lld %lld\n",pl,pr,md); } solve(pl,0); VI seg=getway(); if (SZ(seg)-1>c) { solve(pl,1); VI s2=getway(); bool suc=0; rep(i,0,SZ(s2)-1) { int j=SZ(seg)-(c-i)-1; if (j>=0&&j<SZ(seg)-1&&s2[i]<=seg[j]&&seg[j+1]<=s2[i+1]) { VI ss; rep(k,0,i+1) ss.pb(s2[k]); rep(k,j+1,SZ(seg)) ss.pb(seg[k]); assert(SZ(ss)==c+1); suc=1; seg=ss; break; } } assert(suc); } assert(SZ(seg)==c+1); int ming=n; rep(i,0,c) ming=min(ming,seg[i+1]-seg[i]); seg.resize(2*c+1); rep(i,1,c+1) seg[i+c]=seg[i]+n; VI fl(c,0),fr(c,0); rep(i,0,c) if (seg[i+1]-seg[i]==ming) { rep(j,0,c) { fl[j]=seg[i+j],fr[j]=seg[i+j+1]; segl[j]=fl[j]; } break; } rep(i,0,c) { prv[i]=VI(fr[i]-fl[i]+1,0); vdp[i]=vector<ll>(fr[i]-fl[i]+1,0); } ans=1ll<<60; solve(fl,fr); printf("%lld\n",ans); ansr.pb(ansr[0]+n); vector<ll> shop(c); rep(i,0,c) { shop[i]=a[(ansr[i]+ansr[i+1]+1)/2]%l; } sort(all(shop)); rep(i,0,c) printf("%lld%c",shop[i]," \n"[i==c-1]); }
4157c0d17ac1dfe820d12adde99eb7becd0506db
cdfb3b68cd5f9a666bca6da5128e600ffe44646f
/OCT20B/ADDSQURE.cpp
d89268fa6ffb3259d0d237c9309a48e0fa278a55
[]
no_license
tombro27/Codechef_long
cbb1e533a90e7801938bad97375b74debfdbee79
c9f0868706a8248df773c37d01a14f3d93498275
refs/heads/master
2023-02-04T22:21:37.553562
2020-12-19T14:17:23
2020-12-19T14:17:23
281,933,749
0
0
null
null
null
null
UTF-8
C++
false
false
1,456
cpp
#include <bits/stdc++.h> #include<algorithm> using namespace std; int func(int arr1[], int arr2[], int n, int m) { unordered_map<int, int> m1, m2; int D,res=0; for (int i=0;i<n;i++) { for (int j=i+1;j<n;j++) { D=arr1[i]-arr1[j]; if(D<0) D*=-1; m1[D]++; } } for (int i=0;i<m;i++) { for (int j = i + 1; j < m; j++){ D=arr2[i]-arr2[j]; if(D<0) D*=-1; m2[D]++; } } for (auto it=m1.begin();it!=m1.end();it++){ if (m2.find(it->first)!=m2.end()) { res+=1; } } return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int w,h,n,m; cin>>w>>h>>n>>m; vector<int> A; int arr1[n],arr2[m+1]; for(int i=0;i<n;i++) cin>>arr1[i]; for(int j=0;j<m;j++) cin>>arr2[j]; sort(arr1,arr1+n); sort(arr2,arr2+m); int x=arr1[n-1]-arr1[0]; x+=arr2[m-1]; A.push_back(func(arr1,arr2,n,m+1)); for(int i=1;i<=h;i++){ int l=0,u=m-1,cntr; bool chk=false; while(l<=u){ cntr=(l+u)/2; if(arr2[cntr]==i) { chk=true; break; } else if(arr2[cntr]<i) l=cntr+1; else u=cntr-1; } if(!chk) { arr2[m]=i; A.push_back(func(arr1, arr2, n, m+1)); } } int max=*max_element(A.begin(), A.end()); cout<<max; return 0; }
958da609a1aca6e901ca9fc6f660491335277bfb
ecf03e3c8598d756f862ffe85734ac8fecb78862
/src/caffe/layers/base_data_layer.cpp
6cfa607d3a2a300bd1e8846ec591dbf7788903c0
[ "LicenseRef-scancode-generic-cla", "BSD-2-Clause", "LicenseRef-scancode-public-domain" ]
permissive
NEWPLAN/nvcaffe-dlbooster
a33b2a7745e618760684e0f2aae9d550b6f808c3
fec2c5519ef566a905ab03aaf10cbb7e4cf0a8c3
refs/heads/master
2022-11-01T01:34:30.947888
2018-08-17T01:27:44
2018-08-17T01:27:44
139,375,846
0
1
NOASSERTION
2022-10-16T22:50:26
2018-07-02T01:22:55
C++
UTF-8
C++
false
false
6,941
cpp
#include <map> #include "caffe/proto/caffe.pb.h" #include "caffe/common.hpp" #include "caffe/blob.hpp" #include "caffe/data_transformer.hpp" #include "caffe/internal_thread.hpp" #include "caffe/layer.hpp" #include "caffe/layers/base_data_layer.hpp" #include "caffe/parallel.hpp" namespace caffe { template<typename Ftype, typename Btype> size_t BasePrefetchingDataLayer<Ftype, Btype>::threads(const LayerParameter& param) { if (param.type().compare("ImageData") == 0 && param.has_image_data_param()) { return param.image_data_param().threads(); } // Check user's override in prototxt file size_t threads = param.data_param().threads(); if (!auto_mode(param) && threads == 0U) { threads = 1U; // input error fix } // 1 thread for test net return (auto_mode(param) || param.phase() == TEST || threads == 0U) ? 1U : threads; } template<typename Ftype, typename Btype> size_t BasePrefetchingDataLayer<Ftype, Btype>::parser_threads(const LayerParameter& param) { // Check user's override in prototxt file size_t parser_threads = param.data_param().parser_threads(); if (!auto_mode(param) && parser_threads == 0U) { parser_threads = 1U; // input error fix } // 1 thread for test net return (auto_mode(param) || param.phase() == TEST || parser_threads == 0U) ? 1U : parser_threads; } template<typename Ftype, typename Btype> bool BasePrefetchingDataLayer<Ftype, Btype>::auto_mode(const LayerParameter& param) { // Both should be set to positive for manual mode const DataParameter& dparam = param.data_param(); bool auto_mode = !dparam.has_threads() && !dparam.has_parser_threads(); return auto_mode; } template<typename Ftype, typename Btype> BaseDataLayer<Ftype, Btype>::BaseDataLayer(const LayerParameter& param, size_t transf_num) : Layer<Ftype, Btype>(param), transform_param_(param.transform_param()) {} template<typename Ftype, typename Btype> void BaseDataLayer<Ftype, Btype>::LayerSetUp(const vector<Blob*>& bottom, const vector<Blob*>& top) { output_labels_ = top.size() != 1; // Subclasses should setup the size of bottom and top DataLayerSetUp(bottom, top); } template<typename Ftype, typename Btype> BasePrefetchingDataLayer<Ftype, Btype>::BasePrefetchingDataLayer(const LayerParameter& param, size_t solver_rank) : BaseDataLayer<Ftype, Btype>(param, threads(param)), InternalThread(Caffe::current_device(), solver_rank, threads(param), false), auto_mode_(Caffe::mode() == Caffe::GPU && this->phase_ == TRAIN && auto_mode(param)), parsers_num_(parser_threads(param)), transf_num_(threads(param)), queues_num_(transf_num_ * parsers_num_), batch_transformer_(make_shared<BatchTransformer<Ftype, Btype>>(Caffe::current_device(), solver_rank, queues_num_, param.transform_param(), is_gpu_transform())), iter0_(true) { CHECK_EQ(transf_num_, threads_num()); batch_size_ = param.data_param().batch_size(); // We begin with minimum required ResizeQueues(); base_solver=solver_rank; } template<typename Ftype, typename Btype> BasePrefetchingDataLayer<Ftype, Btype>::~BasePrefetchingDataLayer() { batch_transformer_->StopInternalThread(); } template<typename Ftype, typename Btype> void BasePrefetchingDataLayer<Ftype, Btype>::LayerSetUp(const vector<Blob*>& bottom, const vector<Blob*>& top) { bottom_init_ = bottom; top_init_ = top; BaseDataLayer<Ftype, Btype>::LayerSetUp(bottom, top); for (int i = 0; i < transf_num_; ++i) { bwd_data_transformers_.emplace_back( make_shared<DataTransformer<Btype>>(this->transform_param_, this->phase_)); fwd_data_transformers_.emplace_back( make_shared<DataTransformer<Ftype>>(this->transform_param_, this->phase_)); } const Solver* psolver = this->parent_solver(); const uint64_t random_seed = (psolver == nullptr || static_cast<uint64_t>(psolver->param().random_seed()) == Caffe::SEED_NOT_SET) ? Caffe::next_seed() : static_cast<uint64_t>(psolver->param().random_seed()); StartInternalThread(false, random_seed); } template<typename Ftype, typename Btype> void BasePrefetchingDataLayer<Ftype, Btype>::InternalThreadEntry() { InternalThreadEntryN(0U); } template<typename Ftype, typename Btype> void BasePrefetchingDataLayer<Ftype, Btype>::InternalThreadEntryN(size_t thread_id) { const bool auto_mode = this->auto_mode(); if (auto_mode) { iter0_.wait_reset(); // sample reader first } else if (this->phase_ == TRAIN) { iter0_.wait(); } if (auto_mode && this->net_inititialized_flag_ != nullptr) { this->net_inititialized_flag_->wait(); } InitializePrefetch(); start_reading(); try { while (!must_stop(thread_id)) { const size_t qid = this->queue_id(thread_id); shared_ptr<Batch> batch = batch_transformer_->prefetched_pop_free(qid); CHECK_EQ((size_t) -1L, batch->id()); load_batch(batch.get(), thread_id, qid); if (must_stop(thread_id)) { break; } batch_transformer_->prefetched_push_full(qid, batch); if (auto_mode) { iter0_.set(); break; } //newplan if(0) { LOG_EVERY_N(INFO, 10) << "in dating read thread " << thread_id << " and QID " << qid << " @ rank " << base_solver;//gettid(); } } } catch (boost::thread_interrupted&) { } } template<typename Ftype, typename Btype> void BasePrefetchingDataLayer<Ftype, Btype>::ResizeQueues() { size_t size = batch_ids_.size(); if (transf_num_ > size) { batch_ids_.resize(transf_num_); for (size_t i = size; i < transf_num_; ++i) { batch_ids_[i] = i; } } size = this->bwd_data_transformers_.size(); if (transf_num_ > size) { for (size_t i = size; i < transf_num_; ++i) { this->bwd_data_transformers_.emplace_back( make_shared<DataTransformer<Btype>>(this->transform_param_, this->phase_)); } } size = this->fwd_data_transformers_.size(); if (transf_num_ > size) { for (size_t i = size; i < transf_num_; ++i) { this->fwd_data_transformers_.emplace_back( make_shared<DataTransformer<Ftype>>(this->transform_param_, this->phase_)); } } } template<typename Ftype, typename Btype> void BasePrefetchingDataLayer<Ftype, Btype>::InitializePrefetch() { ResizeQueues(); this->DataLayerSetUp(bottom_init_, top_init_); } template<typename Ftype, typename Btype> void BasePrefetchingDataLayer<Ftype, Btype>::Forward_cpu(const vector<Blob*>& bottom, const vector<Blob*>& top) { // Note: this function runs in one thread per object and one object per one Solver thread shared_ptr<Batch> batch = this->batch_transformer_->processed_pop(); top[0]->Swap(*batch->data_); if (this->output_labels_) { top[1]->Swap(*batch->label_); } this->batch_transformer_->processed_push(batch); } INSTANTIATE_CLASS_FB(BaseDataLayer); INSTANTIATE_CLASS_FB(BasePrefetchingDataLayer); } // namespace caffe
935fef26f7a57d52356752bce603f1fc47e4c48d
a29f360e966c3defa4f5b87bb623e86c2d5267c6
/CoherentNoise/generic_noise.hpp
b204305df5645b22c149f4831da39092aba74a43
[]
no_license
kosumosu/coherent-noise
05711043705342831b72f9f3a28ab17da99cf024
8d0dc19c278eff6f9c963ea210a549bb9ab340cd
refs/heads/master
2021-01-23T20:40:44.759079
2015-06-27T17:22:46
2015-06-27T17:22:46
9,812,170
3
0
null
null
null
null
UTF-8
C++
false
false
274
hpp
#pragma once #include "vector.hpp" namespace noise { template <std::size_t DIMENSIONS, typename TSpace> class generic_noise { public: virtual void initialize(unsigned int seed) = 0; virtual TSpace evaluate(const vector<TSpace, DIMENSIONS> & point) const = 0; }; }
2055915dee9576fc5191596abc9726c3c1dc348d
6b569d6e97823e24b60f5b1d14c1086b5ce61574
/exp. c++/ques8.cpp
32de18a12f9686d4a4950c475cceb6f8e9768e09
[]
no_license
as-iF-30/c-
214a654d837004f40a3fc66002c9d46d1f8549bb
393b9e5fa8f130b42cbdd82e4c795f3a7ce956c7
refs/heads/master
2022-11-26T23:05:38.396183
2020-07-31T12:40:43
2020-07-31T12:40:43
284,033,859
1
0
null
null
null
null
UTF-8
C++
false
false
358
cpp
#include<iostream> using namespace std; int main() { int i,n,sum=0; cout<<"Enter how many enteries you want to give: "; cin>>n; int *a=new int[n]; cout<<"enter the numbers of student"; for(i=1;i<=n;i++) { cin>>a[i]; } for(i=1;i<=n;i++) { sum=sum+a[i]; } cout<<"average is:"<<sum/n; delete(a); }
06da00d34ffe47451608d3833891c5590f58b841
af46c38cf1e425e46a34f8f74f0cacfad2030837
/hxemu/src/virtualserial.h
978a0e7a6dd75b2624ab47cb7f49bd289170cbc3
[ "MIT" ]
permissive
hx20er/HXEmu
4b233bad42633386f7dfff5aef61801cfd557022
9764886879309d58cde125aeb0d3523a8983c17a
refs/heads/master
2020-03-27T03:46:38.817915
2015-01-29T09:18:51
2015-01-29T09:18:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
705
h
// ============================================================================= // @author Pontus Rodling <[email protected]> // @license MIT license - See LICENSE for more information // ============================================================================= #ifndef __VIRTUALSERIAL_H__ #define __VIRTUALSERIAL_H__ #include <stdint.h> #include "serial.h" class VirtualSerial : public Serial { public: VirtualSerial(); virtual ~VirtualSerial(); void reset(); void send(uint8_t c); void _recv(uint8_t c); uint8_t recv(); uint8_t peek(); private: uint8_t *buf; uint16_t buflen; void buffer_append(uint8_t c); uint8_t buffer_pop(); }; #endif
bda881589e5828d7b15ac5e6cd75a8a5abd14d23
d09092dbe69c66e916d8dd76d677bc20776806fe
/.libs/puno_automatic_generated/inc/types/com/sun/star/bridge/oleautomation/PropertyPutArgument.hpp
2d7ea3d624710eee5f3ea8ae382854d831743819
[]
no_license
GXhua/puno
026859fcbc7a509aa34ee857a3e64e99a4568020
e2f8e7d645efbde5132b588678a04f70f1ae2e00
refs/heads/master
2020-03-22T07:35:46.570037
2018-07-11T02:19:26
2018-07-11T02:19:26
139,710,567
0
0
null
2018-07-04T11:03:58
2018-07-04T11:03:58
null
UTF-8
C++
false
false
2,156
hpp
#ifndef INCLUDED_COM_SUN_STAR_BRIDGE_OLEAUTOMATION_PROPERTYPUTARGUMENT_HPP #define INCLUDED_COM_SUN_STAR_BRIDGE_OLEAUTOMATION_PROPERTYPUTARGUMENT_HPP #include "sal/config.h" #include "com/sun/star/bridge/oleautomation/PropertyPutArgument.hdl" #include "com/sun/star/uno/Any.hxx" #include "com/sun/star/uno/Type.hxx" #include "cppu/unotype.hxx" #include "sal/types.h" #include "typelib/typeclass.h" #include "typelib/typedescription.h" namespace com { namespace sun { namespace star { namespace bridge { namespace oleautomation { inline PropertyPutArgument::PropertyPutArgument() : Value() { } inline PropertyPutArgument::PropertyPutArgument(const ::css::uno::Any& Value_) : Value(Value_) { } inline bool operator==(const PropertyPutArgument& the_lhs, const PropertyPutArgument& the_rhs) { return the_lhs.Value == the_rhs.Value; } inline bool operator!=(const PropertyPutArgument& the_lhs, const PropertyPutArgument& the_rhs) { return !operator==(the_lhs, the_rhs); } } } } } } namespace com { namespace sun { namespace star { namespace bridge { namespace oleautomation { inline ::css::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::css::bridge::oleautomation::PropertyPutArgument const *) { //TODO: On certain platforms with weak memory models, the following code can result in some threads observing that the_type points to garbage static ::typelib_TypeDescriptionReference * the_type = 0; if (the_type == 0) { ::typelib_TypeDescriptionReference * the_members[] = { ::cppu::UnoType< ::css::uno::Any >::get().getTypeLibType() }; ::typelib_static_struct_type_init(&the_type, "com.sun.star.bridge.oleautomation.PropertyPutArgument", 0, 1, the_members, 0); } return *reinterpret_cast< ::css::uno::Type * >(&the_type); } } } } } } SAL_DEPRECATED("use cppu::UnoType") inline ::css::uno::Type const & SAL_CALL getCppuType(SAL_UNUSED_PARAMETER ::css::bridge::oleautomation::PropertyPutArgument const *) { return ::cppu::UnoType< ::css::bridge::oleautomation::PropertyPutArgument >::get(); } #endif // INCLUDED_COM_SUN_STAR_BRIDGE_OLEAUTOMATION_PROPERTYPUTARGUMENT_HPP
c9ff15b229985e01c57343c69e90b2ed03f79258
d8e69f3deb2403211dbbcd919170966bb9fe6f88
/include/diagnostics.hpp
00c8f47b77f8cc7bdd5d37e7daec68a1a9d2a242
[ "Apache-2.0" ]
permissive
ipsch/kielflow
dd793fa0ddbc7c1684f70197e87ceeaf9b70ad29
54f3ac1903b17bb3f14e67c3cbba341dff55158a
refs/heads/master
2020-04-06T13:55:09.347213
2016-11-23T02:09:04
2016-11-23T02:09:04
49,132,639
0
0
null
null
null
null
UTF-8
C++
false
false
1,018
hpp
#ifndef DIAGNOSTICS_HPP #define DIAGNOSTIVS_HPP //#include <complex.h> // simple arithmetics with complex numbers (defines symbol "I" for imaginary unit) #include <stdio.h> /* printf, scanf, puts, NULL */ #include <cmath> #include "fftw3.h" #include <iostream> #include "grid.hpp" #include "field.hpp" #include "o_math.hpp" class diagnostics { public : diagnostics(); void analyze(const field_real &that); double get_supremum(void) {return supremum;} double get_infinum(void) {return infinum;} int get_i_supremum(void) {return i_supremum;} int get_j_supremum(void) {return j_supremum;} int get_k_supremum(void) {return k_supremum;} int get_i_infinum(void) {return i_infinum;} int get_j_infinum(void) {return j_infinum;} int get_k_infinum(void) {return k_infinum;} //void set_ijk(int index, int &i, int &j, int &k); double supremum; int i_supremum; int j_supremum; int k_supremum; double infinum; int i_infinum; int j_infinum; int k_infinum; }; # endif // ende der Diagnose-tool Klasse
6ed6ae51ec7f426d0e099da33300d8f3306bdc52
19eb97436a3be9642517ea9c4095fe337fd58a00
/private/inet/mshtml/src/site/miscelem/generic.cxx
3f0d3e3ac1431c87cecf93391b05b5aea5800280
[]
no_license
oturan-boga/Windows2000
7d258fd0f42a225c2be72f2b762d799bd488de58
8b449d6659840b6ba19465100d21ca07a0e07236
refs/heads/main
2023-04-09T23:13:21.992398
2021-04-22T11:46:21
2021-04-22T11:46:21
360,495,781
2
0
null
null
null
null
UTF-8
C++
false
false
8,567
cxx
//+--------------------------------------------------------------------- // // File: generic.cxx // // Contents: Extensible tags classes // // Classes: CGenericElement // //------------------------------------------------------------------------ #include "headers.hxx" #ifndef X_ELEMENT_HXX_ #define X_ELEMENT_HXX_ #include "element.hxx" #endif #ifndef X_GENERIC_HXX_ #define X_GENERIC_HXX_ #include "generic.hxx" #endif #ifndef X_XMLNS_HXX_ #define X_XMLNS_HXX_ #include "xmlns.hxx" #endif #ifndef X_STRBUF_HXX_ #define X_STRBUF_HXX_ #include "strbuf.hxx" // for CStreamWriteBuf #endif #ifndef X_DMEMBMGR_HXX_ #define X_DMEMBMGR_HXX_ #include "dmembmgr.hxx" // for CDataMemberMgr #endif #ifndef X_DBTASK_HXX_ #define X_DBTASK_HXX_ #include "dbtask.hxx" // for CDataBindTask #endif #define _cxx_ #include "generic.hdl" MtDefine(CGenericElement, Elements, "CGenericElement") /////////////////////////////////////////////////////////////////////////// // // misc // /////////////////////////////////////////////////////////////////////////// const CElement::CLASSDESC CGenericElement::s_classdesc = { { &CLSID_HTMLGenericElement, // _pclsid 0, // _idrBase #ifndef NO_PROPERTY_PAGE s_apclsidPages, // _apClsidPages #endif // NO_PROPERTY_PAGE s_acpi, // _pcpi ELEMENTDESC_XTAG, // _dwFlags &IID_IHTMLGenericElement, // _piidDispinterface &s_apHdlDescs, // _apHdlDesc }, (void *)s_apfnIHTMLGenericElement, //_apfnTearOff NULL, // _pAccelsDesign NULL // _pAccelsRun }; /////////////////////////////////////////////////////////////////////////// // // CGenericElement methods // /////////////////////////////////////////////////////////////////////////// //+------------------------------------------------------------------------ // // Method: CGenericElement::CreateElement // //------------------------------------------------------------------------- HRESULT CGenericElement::CreateElement( CHtmTag * pht, CDoc * pDoc, CElement ** ppElement) { Assert(ppElement); *ppElement = new CGenericElement(pht, pDoc); return *ppElement ? S_OK : E_OUTOFMEMORY; } //+------------------------------------------------------------------------ // // Method: CGenericElement constructor // //------------------------------------------------------------------------- CGenericElement::CGenericElement (CHtmTag * pht, CDoc * pDoc) : CElement(pht->GetTag(), pDoc) { #ifndef VSTUDIO7 LPTSTR pchColon; LPTSTR pchStart; Assert(IsGenericTag(pht->GetTag())); Assert(pht->GetPch()); if (pht->GetPch()) { pchColon = StrChr(pht->GetPch(), _T(':')); if (pchColon) { pchStart = pht->GetPch(); IGNORE_HR(_cstrNamespace.Set(pchStart, PTR_DIFF(pchColon, pchStart))); IGNORE_HR(_cstrTagName.Set(pchColon + 1)); } else { IGNORE_HR(_cstrTagName.Set(pht->GetPch())); } } #endif //VSTUDIO7 } //+------------------------------------------------------------------------ // // Method: CGenericElement::Init2 // //------------------------------------------------------------------------- HRESULT CGenericElement::Init2(CInit2Context * pContext) { HRESULT hr; LPTSTR pchNamespace; #ifdef VSTUDIO7 if (pContext && pContext->_pht) { hr = THR(SetTagNameAndScope(pContext->_pht)); if (hr) goto Cleanup; } #endif //VSTUDIO7 hr = THR(super::Init2(pContext)); if (hr) goto Cleanup; if (pContext) { pchNamespace = (LPTSTR) Namespace(); if (pchNamespace && pContext->_pTargetMarkup) { CXmlNamespaceTable * pNamespaceTable = pContext->_pTargetMarkup->GetXmlNamespaceTable(); LONG urnAtom; if (pNamespaceTable) // (we might not have pNamespaceTable if the namespace if "PUBLIC:") { hr = THR(pNamespaceTable->GetUrnAtom(pchNamespace, &urnAtom)); if (hr) goto Cleanup; if (-1 != urnAtom) { hr = THR(PutUrnAtom(urnAtom)); } } } } Cleanup: RRETURN (hr); } //+------------------------------------------------------------------------ // // Method: CGenericElement::Notify // //------------------------------------------------------------------------- void CGenericElement::Notify(CNotification *pnf) { Assert(pnf); super::Notify(pnf); switch (pnf->Type()) { case NTYPE_ELEMENT_ENTERTREE: // the <XML> tag can act as a data source for databinding. Whenever such // a tag is added to the document, we should tell the databinding task // to try again. Something might work now that didn't before. if (0 == FormsStringCmp(TagName(), _T("xml"))) { Doc()->GetDataBindTask()->SetWaiting(); } break; default: break; } } //+------------------------------------------------------------------------ // // Method: CGenericElement::Save // //------------------------------------------------------------------------- HRESULT CGenericElement::Save (CStreamWriteBuff * pStreamWriteBuff, BOOL fEnd) { HRESULT hr; DWORD dwOldFlags; if (ETAG_GENERIC_LITERAL != Tag()) { hr = THR(super::Save(pStreamWriteBuff, fEnd)); if (hr) goto Cleanup; } else // if (ETAG_GENERIC_LITERAL == Tag()) { Assert (ETAG_GENERIC_LITERAL == Tag()); dwOldFlags = pStreamWriteBuff->ClearFlags(WBF_ENTITYREF); pStreamWriteBuff->SetFlags(WBF_SAVE_VERBATIM | WBF_NO_WRAP); pStreamWriteBuff->BeginPre(); hr = THR(super::Save(pStreamWriteBuff, fEnd)); if (hr) goto Cleanup; if (!fEnd && !pStreamWriteBuff->TestFlag(WBF_SAVE_PLAINTEXT) && ETAG_GENERIC_LITERAL == Tag()) { hr = THR(pStreamWriteBuff->Write(_cstrContents)); if (hr) goto Cleanup; } pStreamWriteBuff->EndPre(); pStreamWriteBuff->RestoreFlags(dwOldFlags); } Cleanup: RRETURN(hr); } //+--------------------------------------------------------------------------- // // Member: CGenericElement::namedRecordset // // Synopsis: returns an ADO Recordset for the named data member. Tunnels // into the hierarchy using the path, if given. // // Arguments: bstrDataMember name of data member (NULL for default) // pvarHierarchy BSTR path through hierarchy (optional) // pRecordSet where to return the recordset. // // //---------------------------------------------------------------------------- HRESULT CGenericElement::namedRecordset(BSTR bstrDatamember, VARIANT *pvarHierarchy, IDispatch **ppRecordSet) { HRESULT hr; CDataMemberMgr *pdmm; #ifndef NO_DATABINDING EnsureDataMemberManager(); pdmm = GetDataMemberManager(); if (pdmm) { hr = pdmm->namedRecordset(bstrDatamember, pvarHierarchy, ppRecordSet); if (hr == S_FALSE) hr = S_OK; } else { hr = E_FAIL; } #else *pRecordSet = NULL; hr = S_OK; #endif NO_DATABINDING RRETURN (SetErrorInfo(hr)); } //+--------------------------------------------------------------------------- // // Member: CGenericElement::getRecordSet // // Synopsis: returns an ADO Recordset pointer if this site is a data // source control // // Arguments: IDispatch ** pointer to a pointer to a record set. // // //---------------------------------------------------------------------------- HRESULT CGenericElement::get_recordset(IDispatch **ppRecordSet) { return namedRecordset(NULL, NULL, ppRecordSet); }
85de9165763d76a2c3d1c298548adcbad7939820
4555d708139e791afc5cf1709455f1b5125a6af7
/PINDTest/PINDTest.ino
f5cd6f3b0683eb3619659d51c2fcb913a15a89a0
[]
no_license
HugoMeder/Arduino
e2de325f01d705482798f4e1d23c8864f9e86d5e
be0fcf8590aca44792592b61e9d1533158e79206
refs/heads/master
2020-05-22T10:34:52.341345
2019-05-17T17:10:48
2019-05-17T17:10:48
186,313,491
0
0
null
null
null
null
UTF-8
C++
false
false
362
ino
void setup() { Serial.begin ( 250000 ) ; pinMode ( 2, INPUT_PULLUP ) ;//1 pinMode ( 3, INPUT_PULLUP ) ;//2 pinMode ( 4, INPUT_PULLUP ) ;//3 pinMode ( 5, INPUT_PULLUP ) ;//4 pinMode ( 6, INPUT_PULLUP ) ;//5 pinMode ( 7, INPUT_PULLUP ) ;//6 //DDRD = 0xFF ; } void loop() { byte reg = PIND ; Serial.println ( reg ) ; delay ( 1000 ) ; }
753bc50e00a0f2231034f6e30b6434d56a8fc326
3cfc6a2fe8c161664f8180831a0922fcdbac4165
/_MODEL_FOLDERS_/facing_VIEW/facing_VIEW_RENDER.cpp
d4e172fc28e6554a57e41086d4975289d3ae53eb
[]
no_license
marcclintdion/a8a_Ch_TURNTABLE
1ae6e6d57326b76c81034ad631dc6651e297b6d3
f45e87d58f09c586207df5248e7b990114f7f881
refs/heads/master
2021-01-10T07:11:56.090624
2015-09-30T14:05:37
2015-09-30T14:05:37
43,436,555
0
0
null
null
null
null
UTF-8
C++
false
false
2,729
cpp
glBindBuffer(GL_ARRAY_BUFFER, facing_VIEW_backWall_VBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, facing_VIEW_backWall_INDEX_VBO); Translate(modelView, facing_VIEW_POSITION[0], facing_VIEW_POSITION[1], facing_VIEW_POSITION[2]); Rotate(modelView, facing_VIEW_ROTATE[0], facing_VIEW_ROTATE[1], facing_VIEW_ROTATE[2], facing_VIEW_ROTATE[3]); //================================================================================================================= SelectShader(shaderNumber); //================================================================================================================= glActiveTexture ( GL_TEXTURE3 ); glBindTexture(GL_TEXTURE_2D, shadowMap_TEXTURE); //--- glActiveTexture ( GL_TEXTURE2 ); glBindTexture(GL_TEXTURE_2D, facing_VIEW_HEIGHT); //--- glActiveTexture ( GL_TEXTURE1 ); glBindTexture(GL_TEXTURE_2D, facing_VIEW_NORMALMAP); //--- glActiveTexture (GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, facing_VIEW_TEXTUREMAP ); //---------------------------------------------------------------------------------------------------------------------------------------------------|__DRAW glDrawElements(GL_TRIANGLES, 102, GL_UNSIGNED_INT, 0);
5791dc91a2a43acdce1cd9219613cbb2d5fa63a0
3070feebf8f3d97bd28598102d66a90585944d61
/Queues/Array implementation.cpp
9065bdc755702b2b4ed74d9ef85dc1c2e84df151
[]
no_license
mohit2308jain/Data-Structures
cc22cc656fe24a904f5d555a3a7cfabefaa339bc
ec24d4f84fc99defddf10cbd04b69d6e8a5d0207
refs/heads/master
2020-04-17T08:57:10.530444
2019-08-05T17:44:45
2019-08-05T17:44:45
166,435,819
0
0
null
null
null
null
UTF-8
C++
false
false
1,174
cpp
#include<bits/stdc++.h> using namespace std; #define MAX 1000 template <class T> class Queue { int front, rear; public: T a[MAX]; //Maximum size of Stack Queue() { front = -1; rear = -1; } bool enqueue(T x){ if(front==-1){ front++; } if(rear>=(MAX-1)){ cout<<"Queue Overflow"; } else{ a[++rear] = x; cout<<x<<" pushed to the queue"<<endl; return true; } } T dequeue(){ T d = a[front]; front++; return (d); } void disp(){ for(int i=front;i<=rear;i++){ cout<<a[i]<<" "; } } }; int main() { class Queue<int> s; s.enqueue(10); s.enqueue(20); s.enqueue(30); cout<<s.dequeue() << " Popped from stack\n"; s.disp(); cout<<endl; class Queue<double> s1; s1.enqueue(10.1); s1.enqueue(20.1); s1.enqueue(30.1); cout<<s1.dequeue() << " Popped from stack\n"; s1.disp(); cout<<endl; class Queue<char> s2; s2.enqueue('a'); s2.enqueue('b'); s2.enqueue('c'); cout<<s2.dequeue() << " Popped from stack\n"; s2.disp(); cout<<endl; return 0; }
050875d544731cbf80e062ea6dd90a40ac00469c
ba2c3c4ca011784dfa2cd183a6f6e52587367b6d
/src/hex_hav/PlayerRaveNast2.hpp
6d2fe861f7ea8695dec04b23e1128c57f356a50e
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
fteytaud/hex_hav
b73d3697f65be246e658122e4ef8ea5e233f140f
634a494f5be8ec6604ebb315c30669f9496d4c6b
refs/heads/master
2021-01-19T10:39:30.895973
2017-04-01T09:10:15
2017-04-01T09:10:19
82,200,406
6
1
null
null
null
null
UTF-8
C++
false
false
2,780
hpp
/* BSD 3-Clause License Copyright (c) 2017, Fabien Teytaud, Julien Dehos, Joris Duguépéroux and Ahmad Mazyad All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PLAYER_RAVE_NAST2_HPP_ #define PLAYER_RAVE_NAST2_HPP_ #include <hex_hav/PlayerRave.hpp> // The n-Gram average sampling technique record. A record is a n-gram seq of // action, associated with the total reward and number of visits. Here n = 2. class PlayerRaveNast2 : public PlayerRave { private: // record structure for 2-grams struct Record { int _action1; int _action2; int _wins; int _sims; double _cdf; Record() = delete; void updateCdf(double & cdf); }; protected: // board indices of the full game played by the last call to // computeSimulation, first move: root node, ... std::map<int,Record> _nastRecords; Prng _prngNast2Cdf; public: PlayerRaveNast2() = default; void newTurn(const BOARD_TYPE & refBoard) override; protected: cell_t computeSimulation(NodeRave *ptrNode) override; void computeBackpropagation(NodeRave *ptrNode, cell_t winnerCellt) override; #ifdef LOG virtual void printLog() override; #endif // LOG }; #endif // PLAYER_RAVE_NAST2_HPP_
478583a273861b30ede610f4835bdc7d0f6c9f5b
8c26828d4e487771699c07905d986d4b5cb0580b
/Tinka/tinca con funciones 3.cpp
607ee35c6d0cdb4d82862f99b06b54397842c8cc
[]
no_license
jguillermo/cpp
5f0aa0f70183cebe7d602580c824927d50b62c21
13b9d68b4d13df424c669df66f21dfe5128172dc
refs/heads/master
2023-06-27T15:47:38.116675
2021-07-24T21:10:58
2021-07-24T21:10:58
389,202,306
0
0
null
null
null
null
UTF-8
C++
false
false
3,541
cpp
#include<conio.h> #include<iostream.h> #include <stdlib.h> #include <stdio.h> #include <string.h> ordenar(int r[8]); mensaje(int k); llenado(int k[8]); numjuego(int n[41]); resultado(int n[41],int k[8],int r[8]); mayormenor(int k[8],int i); repite(int k[8],int i); ejecuta(); double contrasena(); titulo(); presentacion(); main(){randomize(); ejecuta();} //*************************************************************** mensaje(int k){ gotoxy(6,19); if(k==6)cout<<"ganaste la tinka"; if(k<6&&k>1)cout<<"obtubiste "<<k<<" haciertos que son :"; if(k==1)cout<<"obtubiste 1 hacierto que es :" ; if(k<1)cout<<"obtubiste 0 haciertos "; } //************************************** llenado(int k[8]){ clrscr(); titulo(); for(int i=1;i<=6;i++){mayormenor(k,i);repite(k,i);} } //****************************************************** numjuego(int n[41]){ int x,y,uxi; //for(int f=1;f<=40;f++)n[f]=f; for(int f=1;f<=40;f++)n[f]=f; for(int ca=1;ca<=3000;ca++){ x=random(39)+1;y=random(39)+1; uxi=n[x];n[x]=n[y];n[y]=uxi;} } //****************************************************** resultado(int n[41],int k[8],int r[8]){ int k1=0; clrscr(); titulo(); for(int ju=1;ju<=6;ju++)r[ju]=0; cout<<"\n\n\tTu jugada es : \n\n\n"; for(int f=1;f<=6;f++)cout<<" "<<k[f]; cout<<"\n\n\n\n\tLa jugada ganadora es : \n\n\n"; for(int f=1;f<=6;f++)cout<<" "<<n[f]; for (int i=1;i<=6;i++) {for (int j=1;j<=6;j++) {if (k[i]==n[j]){k1=k1+1;r[i]=k[i];}} } mensaje(k1); if(k1>=1&&k1<6){ordenar(r);for (int hu=1;hu<=k1;hu++){cout<<" "<<r[hu];}} } //*********************************** mayormenor(int k[8],int i){ do{ gotoxy(8,i+5);cout<<"ingrese el numero ( "<<i<<" ) = ";cin>>k[i]; gotoxy(1,22);clreol(); if(k[i]>40||k[i]<1){gotoxy(34,i+5);clreol();} gotoxy(10,22); if(k[i]<1)cout<<"\a El numero debe ser mayor o igual a 1"; if(k[i]>40)cout<<"\a El numero debe der menor o igual a 40"; }while(k[i]>40||k[i]<1); } //*********************** repite(int k[8],int i){ int a; do{ a=0; for(int j=1;j<i;j++){if(k[i]==k[j]){a=1;} } if(a==1) {gotoxy(10,22);cout<<"\aYa ingreso el numero "<<k[i]<<" por favor ingrese otro numero "; gotoxy(34,i+5);clreol(); mayormenor(k,i); } }while(a==1); } //************************** ejecuta(){ double cont; char op; do{cont=contrasena();}while(cont!=0); presentacion(); do{ int n[41],k[8],r[8]; llenado(k); numjuego(n); resultado(n,k,r); cout<<"\n\n\n Para salir presione S, para continuar presione cualquier tecla "; op=getch(); }while(op!='s'); } //************************** double contrasena(){clrscr(); titulo(); char mi[10]={"guillermo"},co[30]; gotoxy(8,11);cout<<"ingrese contrasena = ";gets(co); return strcmp(co,mi); } //************************** titulo(){ gotoxy(25,2);cout<<"SIMULACRO DEL JUEGO LA TINKA"; gotoxy(25,3);cout<<"----------------------------"; } //**************************** presentacion(){ clrscr(); titulo(); gotoxy(33,11);cout<<"UNI - PERU 2007 "; gotoxy(20,21);cout<<"Presione cualquier tecla para continuar"; gotoxy(1,24);cout<<"programa creado por jg_antony "; getch(); } //********************************* ordenar(int r[8]){ int j,i,aux; for (i=1;i<6;i++) {for(j=i+1;j<=6;j++) {if(r[i]<r[j]) {aux=r[i]; r[i]=r[j]; r[j]=aux;} } } }
746e387f946fb5559fabf78b16bdfdc72197891b
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/inetsrv/query/h/catadmin.hxx
16f5ba1b39df9761ab02c4450e580e76d6a39234
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,909
hxx
//+--------------------------------------------------------------------------- // // Microsoft Windows // Copyright (c) Microsoft Corporation, 1997 - 1998. // // File: CatAdmin.hxx // // Contents: Catalog administration API // // History: 28-Jan-97 KyleP Created // //---------------------------------------------------------------------------- #pragma once #include <fsciexps.hxx> #include <smartsvc.hxx> // // Constants used for performance tuning // const WORD wDedicatedServer = 0; const WORD wUsedOften = 1; const WORD wUsedOccasionally = 2; const WORD wNeverUsed = 3; const WORD wCustom = 4; const WORD wLowPos = 1; const WORD wMidPos = 2; const WORD wHighPos = 3; // // Forward declarations // class CCatalogAdmin; class CCatalogEnum; class CScopeEnum; class CScopeAdmin; // // Utility routines // void AssembleScopeValueString( WCHAR const * pwszAlias, BOOL fExclude, WCHAR const * pwszLogon, XGrowable<WCHAR> & xLine ); SCODE IsScopeValid( WCHAR const * pwszScope, unsigned len, BOOL fLocal ); //+--------------------------------------------------------------------------- // // Class: CMachineAdmin // // Purpose: Administer CI on a given machine // // History: 28-Jan-97 KyleP Created. // //---------------------------------------------------------------------------- class CMachineAdmin { public: CMachineAdmin( WCHAR const * pwszMachine = 0, // NULL --> Current machine BOOL fWrite = TRUE ); ~CMachineAdmin(); // // Service manipulation // BOOL IsCIStarted(); BOOL IsCIStopped(); BOOL IsCIPaused(); BOOL StartCI(); BOOL StopCI(); BOOL PauseCI(); BOOL IsCIEnabled(); BOOL EnableCI(); BOOL DisableCI(); // // Catalog manipulation // void AddCatalog( WCHAR const * pwszCatalog, WCHAR const * pwszDataLocation ); void RemoveCatalog( WCHAR const * pwszCatalog, BOOL fRemoveData = TRUE ); // FALSE --> Don't delete directory void RemoveCatalogFiles( WCHAR const * pwszCatalog ); CCatalogEnum * QueryCatalogEnum(); CCatalogAdmin * QueryCatalogAdmin( WCHAR const * pwszCatalog ); BOOL GetDWORDParam( WCHAR const * pwszParam, DWORD & dwValue ); void SetDWORDParam( WCHAR const * pwszParam, DWORD dwValue ); void SetSZParam( WCHAR const * pwszParam, WCHAR const * pwszVal, DWORD cbLen ); BOOL GetSZParam( WCHAR const * pwszParam, WCHAR * pwszVal, DWORD cbLen ); BOOL RegisterForNotification( HANDLE hEvent ); BOOL IsLocal() { return ( (HKEY_LOCAL_MACHINE == _hkeyLM) || (_xwcsMachName[0] == L'.' && _xwcsMachName[1] == 0) ); } void CreateSubdirs( WCHAR const * pwszPath ); // Performance Tuning void TunePerformance(BOOL fServer, WORD wIndexingPerf, WORD wQueryingPerf); private: BOOL OpenSCM(); void TuneFilteringParameters(BOOL fServer, WORD wIndexingPerf, WORD wQueryingPerf); void TuneMergeParameters(BOOL fServer, WORD wIndexingPerf, WORD wQueryingPerf); void TunePropCacheParameters(BOOL fServer, WORD wIndexingPerf, WORD wQueryingPerf); void TuneMiscellaneousParameters(BOOL fServer, WORD wIndexingPerf, WORD wQueryingPerf); // Wait on service BOOL WaitForSvcStateChange( SERVICE_STATUS *pss, int iSecs = 120); HKEY _hkeyLM; // HKEY_LOCAL_MACHINE (may be remote) HKEY _hkeyContentIndex; // Content Index key (top level) BOOL _fWrite; // Writable access to the registry // // Service handles (for start and stop) // CServiceHandle _xSCRoot; CServiceHandle _xSCCI; XGrowable<WCHAR,MAX_COMPUTERNAME_LENGTH> _xwcsMachName; // Name of machine }; //+--------------------------------------------------------------------------- // // Class: CCatStateInfo // // Purpose: maintains catalog state information // // History: 4-3-98 mohamedn created // //---------------------------------------------------------------------------- class CCatStateInfo { public: CCatStateInfo(CCatalogAdmin &catAdmin) : _catAdmin(catAdmin), _sc(S_OK) { RtlZeroMemory( &_state, sizeof(CI_STATE) ); } BOOL LokUpdate(void); BOOL IsValid(void) { return ( S_OK == _sc ); } SCODE GetErrorCode(void) { return _sc; } DWORD GetWordListCount(void) { return _state.cWordList; } DWORD GetPersistentIndexCount(void) { return _state.cPersistentIndex; } DWORD GetQueryCount(void) { return _state.cQueries; } DWORD GetDocumentsToFilter(void) { return _state.cDocuments; } DWORD GetFreshTestCount(void) { return _state.cFreshTest; } DWORD PctMergeComplete(void) { return _state.dwMergeProgress; } DWORD GetStateInfo(void) { return _state.eState; } DWORD GetFilteredDocumentCount(void){ return _state.cFilteredDocuments; } DWORD GetTotalDocumentCount(void) { return _state.cTotalDocuments; } DWORD GetPendingScanCount(void) { return _state.cPendingScans; } DWORD GetIndexSize(void) { return _state.dwIndexSize; } DWORD GetUniqueKeyCount(void) { return _state.cUniqueKeys; } DWORD GetDelayedFilterCount(void) { return _state.cSecQDocuments; } private: CCatalogAdmin & _catAdmin; CI_STATE _state; SCODE _sc; }; //+--------------------------------------------------------------------------- // // Class: CCatalogAdmin // // Purpose: Administer a catalog // // History: 28-Jan-97 KyleP Created. // //---------------------------------------------------------------------------- class CCatalogAdmin { public: ~CCatalogAdmin(); // // Service manipulation // BOOL IsStarted(); BOOL IsStopped(); BOOL IsPaused(); BOOL Start(); BOOL Stop(); BOOL Pause(); // // Scope manipulation // void AddScope( WCHAR const * pwszScope, WCHAR const * pwszAlias = 0, BOOL fExclude = FALSE, WCHAR const * pwszLogon = 0, WCHAR const * pwszPassword = 0 ); void RemoveScope( WCHAR const * pwszScope ); BOOL IsPathInScope( WCHAR const * pwszPath ); // // Properties // void AddCachedProperty(CFullPropSpec const & fps, ULONG vt, ULONG cb, DWORD dwStoreLevel = SECONDARY_STORE, BOOL fModifiable = TRUE); // // Parameters // void TrackIIS( BOOL fTrackIIS ); BOOL IsTrackingIIS(); BOOL IsCatalogInactive(); CScopeEnum * QueryScopeEnum(); CScopeAdmin* QueryScopeAdmin( WCHAR const * pwszPath); void DeleteRegistryParamNoThrow( WCHAR const * pwszParam ); BOOL GetDWORDParam( WCHAR const * pwszParam, DWORD & dwValue ); void SetDWORDParam( WCHAR const * pwszParam, DWORD dwValue ); WCHAR const * GetMachName() { return _xwcsMachName.Get(); } WCHAR const * GetName() { return _wcsCatName; } WCHAR const * GetLocation(); BOOL IsLocal() const { return ( L'.' == _xwcsMachName[0] && 0 == _xwcsMachName[1] ); } void AddOrReplaceSecret( WCHAR const * pwcUser, WCHAR const * pwcPW ); CCatStateInfo & State(void) { return _catStateInfo; } private: friend class CMachineAdmin; friend class CCatalogEnum; CCatalogAdmin( HKEY hkeyLM, WCHAR const * pwszMachine, WCHAR const * pwszCatalog, BOOL fWrite ); HKEY _hkeyCatalog; // Root of catalog BOOL _fWrite; // Write access CCatStateInfo _catStateInfo; // catalog state info XGrowable<WCHAR,MAX_COMPUTERNAME_LENGTH> _xwcsMachName; // Name of machine WCHAR _wcsCatName[MAX_PATH]; // Name of catalog WCHAR _wcsLocation[MAX_PATH]; // Catalog location WCHAR _wcsDriveOfLocation[_MAX_DRIVE]; // Drive where catalog is located }; //+--------------------------------------------------------------------------- // // Class: CCatalogEnum // // Purpose: Enumerates available catalogs // // History: 28-Jan-97 KyleP Created. // //---------------------------------------------------------------------------- class CCatalogEnum { public: WCHAR const * Name() { return _awcCurrentCatalog; } CCatalogAdmin * QueryCatalogAdmin(); BOOL Next(); ~CCatalogEnum(); private: friend class CMachineAdmin; CCatalogEnum( HKEY hkeyLM, WCHAR const * pwcsMachine, BOOL fWrite ); HKEY _hkeyLM; // Root of machine (not owned) HKEY _hkeyCatalogs; // Root of catalog area DWORD _dwIndex; // Index of NEXT entry BOOL _fWrite; // TRUE for writable access XGrowable<WCHAR,MAX_COMPUTERNAME_LENGTH> _xawcCurrentMachine; WCHAR _awcCurrentCatalog[MAX_PATH]; }; //+--------------------------------------------------------------------------- // // Class: CScopeEnum // // Purpose: Enumerates available scopes // // History: 28-Jan-97 KyleP Created. // //---------------------------------------------------------------------------- class CScopeEnum { public: ~CScopeEnum(); WCHAR const * Path() { return _awcCurrentScope; } CScopeAdmin * QueryScopeAdmin(); BOOL Next(); private: friend class CCatalogAdmin; CScopeEnum( HKEY hkeyCatalog, BOOL fIsLocal, BOOL fWrite ); SRegKey _xkeyCatalog; SRegKey _xkeyScopes; // Root of scope area DWORD _dwIndex; // Index of NEXT entry WCHAR * _pwcsAlias; // Points into Data at alias WCHAR * _pwcsLogon; // Points into Data at logon BOOL _fExclude; // TRUE for exclude scope BOOL _fVirtual; // TRUE for virtual place-holder BOOL _fShadowAlias; // TRUE for shadow alias place-holder BOOL _fIsLocal; // TRUE if the local machine BOOL _fWrite; // TRUE for writable access WCHAR _awcCurrentScope[MAX_PATH]; }; //+--------------------------------------------------------------------------- // // Class: CScopeAdmin // // Purpose: Set/Get scope properties // // History: 12-10-97 mohamedn created // //---------------------------------------------------------------------------- class CScopeAdmin { public: WCHAR const * GetPath() { return _awcScope; } WCHAR const * GetAlias(); WCHAR const * GetLogon() { return _awcLogon; } BOOL IsExclude() { return _fExclude; } BOOL IsVirtual() { return _fVirtual; } BOOL IsShadowAlias() { return _fShadowAlias; } BOOL IsLocal() { return _fIsLocal; } void SetPath (WCHAR const *pwszPath); void SetAlias (WCHAR const *pwszAlias); void SetExclude (BOOL fExclude); void SetLogonInfo(WCHAR const *pwszLogon, WCHAR const *pwszPassword, CCatalogAdmin & pCatAdmin); private: friend class CScopeEnum; void SetScopeValueString(); CScopeAdmin( HKEY hkeyCatalog, WCHAR const * pwszScope, WCHAR const * pwszAlias, WCHAR const * pwszLogon, BOOL fExclude, BOOL fVirtual, BOOL fShadowAlias, BOOL fIsLocal, BOOL fWrite, BOOL fValidityCheck = TRUE ); SRegKey _xkeyScopes; BOOL _fExclude; // TRUE for exclude scope BOOL _fVirtual; // TRUE for virtual place-holder BOOL _fShadowAlias; // TRUE for shadow alias place-holder BOOL _fWrite; // TRUE if writable access BOOL _fIsLocal; // TRUE if the scope is on the local machine WCHAR _awcScope[MAX_PATH]; WCHAR _awcAlias[MAX_PATH]; // Points into Data at alias WCHAR _awcLogon[MAX_PATH]; // Points into Data at logon }; //+--------------------------------------------------------------------------- // // Member: CScopeAdmin::GetAlias, public // // Returns: Alias to scope (or scope itself if it is a UNC path) // // History: 9-May-97 KyleP Created // //---------------------------------------------------------------------------- inline WCHAR const * CScopeAdmin::GetAlias() { return _awcAlias; }
fdcc8831ad710ca73bd4db13b5c68ab897342c1b
a22bf3e5c20c5cb3f70af4594ff3766f76f83f02
/enemy.cc
4a05293ae03ae874e0f67c4281783ab617dfc6f4
[]
no_license
chenglinyue/chamber-crawler
51925b5384c116b2db5b7e3e3efa88c72baf45e7
d5d7ad4596e246bb3826c965daaf03380918bd47
refs/heads/master
2021-07-03T20:57:00.966894
2017-09-22T19:10:05
2017-09-22T19:10:05
104,509,456
0
0
null
null
null
null
UTF-8
C++
false
false
3,298
cc
#include "enemy.h" #include "shade.h" #include "drow.h" #include "goblin.h" #include "troll.h" #include "vampire.h" #include <stdlib.h> using namespace std; // 3 param ctor Enemy::Enemy(Controller &controller, std::pair<int, int>location, char id):Character(controller, location, id) { isHostile = true; } // Enemy attacks Player of race Goblin void Enemy::attack(Goblin &goblin) { int miss = rand() % 2; if (isHostile) { if (miss == 0) { int dmg = ceil((100.0/(100 + goblin.getDef()))*atk); goblin.takeDamage(dmg); doDamage(dmg); } else { missed(); } } } // Enemy attacks Player of race Shade void Enemy::attack(Shade &shade) { int miss = rand() % 2; if (isHostile) { if (miss == 0) { int dmg = ceil((100.0/(100 + shade.getDef()))*atk); shade.takeDamage(dmg); doDamage(dmg); } else { missed(); } } } // Enemy attacks Player of race Drow void Enemy::attack(Drow &drow) { int miss = rand() % 2; if (isHostile) { if (miss == 0) { int dmg = ceil((100.0/(100 + drow.getDef()))*atk); drow.takeDamage(dmg); doDamage(dmg); } else { missed(); } } } // Enemy attacks Player of race Troll void Enemy::attack(Troll &troll) { int miss = rand() % 2; if (isHostile) { if (miss == 0) { int dmg = ceil((100.0/(100 + troll.getDef()))*atk); troll.takeDamage(dmg); doDamage(dmg); } else { missed(); } } } // Enemy attacks Player of race Vampire void Enemy::attack(Vampire &vampire) { int miss = rand() % 2; if (isHostile) { if (miss == 0) { int dmg = ceil((100.0/(100 + vampire.getDef()))*atk); vampire.takeDamage(dmg); doDamage(dmg); } else { missed(); } } } // Notify controller to update action string void Enemy::doDamage(const int dmg) { stringstream action; string enemyID; enemyID.push_back(charID); action << controller->getAction() << enemyID << " deals " << dmg << " damage to PC. "; controller->setAction(action.str()); } // Enemies have 50% chance to miss against player // Notify controller to update action string void Enemy::missed() { stringstream action; string enemyID; enemyID.push_back(charID); action << controller->getAction() << enemyID << " attacked PC. " << enemyID<< " missed! "; controller->setAction(action.str()); } // Notify controller that enemy died void Enemy::dead() { stringstream action; action << controller->getAction() << "PC has slain " << charID << ". "; // Dead enemies randomly drop a small (value 1) or normal (value 2) // pile of gold that is directly picked up by player int amount = rand() % 2 + 1; action << "PC obtained " << amount << " gold. "; controller->setGold(controller->getGold() + amount); controller->setAction(action.str()); controller->enemyDead(*this); } // setter for hostile field void Enemy::setIsHostile(bool hostile) { isHostile = hostile; } // getter for hostile field bool Enemy::getIsHostile() { return isHostile; }
bb475d3a1ce89ea23d0ea04be79d6d7496bd8577
c3a79a4708a9e99fe22964a6291990b861313b7d
/B_Big_Vova.cpp
0e854fdccda3aa405ce495be2babe640b40b0633
[]
no_license
parthkris13/CC-Solutions
d04ef8f15e5c9e019d2cf8d84ca1649d84b4f51d
d190294bfb44449b803799819ee1f06f5f6c5a17
refs/heads/main
2023-04-11T11:04:11.042172
2021-04-29T14:15:33
2021-04-29T14:15:33
323,133,672
0
0
null
null
null
null
UTF-8
C++
false
false
921
cpp
#include <stdio.h> #include <bits/stdc++.h> using namespace std; #define int long long int #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int gcd(int x, int y) {return y == 0 ? x : gcd(y, x % y);} int32_t main(){ IOS; int t; cin >> t; while(t--){ int n; cin >> n; int arr[n]; int c[n] = {0}; bool used[n] = {0}; for(int i = 0; i<n; i++) cin >> arr[i]; c[0] = 0; for(int i = 0; i < n; i++) { int p = -1; int bst = -1; for (int j = 0; j < n; j++){ if (used[j]) continue; int x = gcd(arr[j], c[i]); if (x > bst) { bst = x; p = j; } } used[p] = 1; cout << arr[p] << " "; c[i + 1] = bst; } cout << endl; } return 0; }
8d5669b89674c0a82c967dcf6664f56f73bc02fa
3bbd9fd74a2b3870ab1db7966069878f90589ede
/cpp/binary_negate.cpp
438439cd06f856d22eccb0b21aaa74501d90550a
[]
no_license
yjwoo14/TIL
a590dc6ccbe23866c59b970a84e4101e44884404
0d8794e5292e58f8752beaab9aa2eed3a6cfdcf1
refs/heads/master
2021-01-11T02:55:16.072232
2020-05-11T22:07:59
2020-05-11T22:12:44
70,891,055
0
0
null
null
null
null
UTF-8
C++
false
false
367
cpp
#include <iostream> #include <functional> struct BinaryOperator { template <typename T> bool operator()(T const & a, T const & b) { return std::less<T>()(a, b); } }; int main(int argc, const char *argv[]) { int a = 1, b = 2; BinaryOperator op1; std::binary_negate<BinaryOperator> op2; std::cout << op1(a, b) << " " << op2(a, b) << std::endl; return 0; }
ff966a638726508f78e7ab6e9a152a03c4a3aa29
af655d411b09be03a5e78b909e9ad1ec80b9da6d
/src/tools/utils.cpp
094e5bee0a6949346d032234a517180c45cf2c54
[ "Unlicense" ]
permissive
dankozitza/mc
cf58c1790489a3dd79ccc95dec29f9e4922fb7b8
84e8080d0a0667d09c92a012e4c9a38f0ee80588
refs/heads/master
2022-05-06T22:31:50.426094
2022-04-16T00:34:10
2022-04-16T00:34:10
37,784,187
0
0
null
null
null
null
UTF-8
C++
false
false
1,891
cpp
// // utils.cpp // // utility functions for mc // // Created by Daniel Kozitza // #include <fstream> #include "../sorters.hpp" #include "../tools.hpp" bool CalledAtexit = false; // get_vfnmkmc_conf // // Reads vnfmake.conf variables into 'config'. // bool tools::get_vfnmkmc_conf(map<string, string>& config) { ifstream fh; fh.open("vfnmkmc.conf", ifstream::in); if (!fh.is_open()) { cout << "tools::get_vfnmkmc_conf: couldn't open vfnmkmc.conf." << endl; return false; } while(fh.peek() != EOF) { string line; getline(fh, line); string m[3]; if (pmatches(m, line, R"(^\s*([^:]*):\s*(.*)$)")) config[m[1]] = m[2]; } fh.close(); return true; } bool tools::save_vfnmkmc_conf(map<string, string>& config) { FILE * pFile; pFile = fopen("vfnmkmc.conf", "w"); for (auto& pair : config) { string tmp = pair.first + ":"; fprintf(pFile, "%-20s%s\n", tmp.c_str(), pair.second.c_str()); } fclose(pFile); return true; } vector<string> Targets; // this function can be handed to atexit. It will remove all the file names // in the targets vector. void destroy_targets() { for (const auto fname : Targets) { cout << "tools::destroy_targets: removing `" << fname << "`\n"; remove(fname.c_str()); } } string tools::get_src_files(string src_dir) { string src_files; vector<string> files; cout << "tools::get_src_files: calling list_dir_r(\"" << src_dir << "\")\n"; require(list_dir_r(src_dir, files)); sorters::radix(files); if (files.size() > 0) { for (int i = 0; i < files.size() - 1; ++i) { if (pmatches(files[i], R"((\.cpp|\.c|\.hpp|\.h)$)")) src_files += files[i] + " "; } if (pmatches(files[files.size() - 1], R"((\.cpp|\.c|\.hpp|\.h)$)")) src_files += files[files.size() - 1]; } return src_files; }
2aed9c4f776c6a46dda30750e859c72ce9e277b2
bd18edfafeec1470d9776f5a696780cbd8c2e978
/SlimDX/source/direct3d9/FunctionDescription.h
b8be3f867d837b1ccb71c7982c9b037904c02eb8
[ "MIT" ]
permissive
MogreBindings/EngineDeps
1e37db6cd2aad791dfbdfec452111c860f635349
7d1b8ecaa2cbd8e8e21ec47b3ce3a5ab979bdde7
refs/heads/master
2023-03-30T00:45:53.489795
2020-06-30T10:48:12
2020-06-30T10:48:12
276,069,149
0
1
null
2021-04-05T16:05:53
2020-06-30T10:33:46
C++
UTF-8
C++
false
false
4,107
h
/* * Copyright (c) 2007-2010 SlimDX Group * * 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. */ #pragma once namespace SlimDX { namespace Direct3D9 { /// <summary> /// Describes a function used by an effect. /// </summary> /// <unmanaged>D3DXFUNCTION_DESC</unmanaged> public value class FunctionDescription : System::IEquatable<FunctionDescription> { public: /// <summary> /// The name of the function. /// </summary> property System::String^ Name; /// <summary> /// The number of annotation contained by the function. /// </summary> property int Annotations; /// <summary> /// Tests for equality between two objects. /// </summary> /// <param name="left">The first value to compare.</param> /// <param name="right">The second value to compare.</param> /// <returns><c>true</c> if <paramref name="left"/> has the same value as <paramref name="right"/>; otherwise, <c>false</c>.</returns> static bool operator == ( FunctionDescription left, FunctionDescription right ); /// <summary> /// Tests for inequality between two objects. /// </summary> /// <param name="left">The first value to compare.</param> /// <param name="right">The second value to compare.</param> /// <returns><c>true</c> if <paramref name="left"/> has a different value than <paramref name="right"/>; otherwise, <c>false</c>.</returns> static bool operator != ( FunctionDescription left, FunctionDescription right ); /// <summary> /// Returns the hash code for this instance. /// </summary> /// <returns>A 32-bit signed integer hash code.</returns> virtual int GetHashCode() override; /// <summary> /// Returns a value that indicates whether the current instance is equal to a specified object. /// </summary> /// <param name="obj">Object to make the comparison with.</param> /// <returns><c>true</c> if the current instance is equal to the specified object; <c>false</c> otherwise.</returns> virtual bool Equals( System::Object^ obj ) override; /// <summary> /// Returns a value that indicates whether the current instance is equal to the specified object. /// </summary> /// <param name="other">Object to make the comparison with.</param> /// <returns><c>true</c> if the current instance is equal to the specified object; <c>false</c> otherwise.</returns> virtual bool Equals( FunctionDescription other ); /// <summary> /// Determines whether the specified object instances are considered equal. /// </summary> /// <param name="value1">The first value to compare.</param> /// <param name="value2">The second value to compare.</param> /// <returns><c>true</c> if <paramref name="value1"/> is the same instance as <paramref name="value2"/> or /// if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns> static bool Equals( FunctionDescription% value1, FunctionDescription% value2 ); }; } }
[ "Michael@localhost" ]
Michael@localhost
f7e489b682c961c1dd9dbaba1f81ffc79bd9fccd
a1a8b69b2a24fd86e4d260c8c5d4a039b7c06286
/build/iOS/Debug/include/Fuse.Controls.ScrollView.h
8fe2a5c061006037b76a3c1d6957902928b83d84
[]
no_license
epireve/hikr-tute
df0af11d1cfbdf6e874372b019d30ab0541c09b7
545501fba7044b4cc927baea2edec0674769e22c
refs/heads/master
2021-09-02T13:54:05.359975
2018-01-03T01:21:31
2018-01-03T01:21:31
115,536,756
0
0
null
null
null
null
UTF-8
C++
false
false
1,729
h
// This file was generated based on /usr/local/share/uno/Packages/Fuse.Controls.ScrollView/1.4.2/ScrollView.ux.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Fuse.Animations.IResize.h #include <Fuse.Binding.h #include <Fuse.Controls.Native.IScrollViewHost.h #include <Fuse.Controls.ScrollViewBase.h #include <Fuse.IActualPlacement.h #include <Fuse.INotifyUnrooted.h #include <Fuse.IProperties.h #include <Fuse.ITemplateSource.h #include <Fuse.Node.h #include <Fuse.Scripting.IScriptObject.h #include <Fuse.Triggers.Actions.ICollapse.h #include <Fuse.Triggers.Actions.IHide.h #include <Fuse.Triggers.Actions.IShow.h #include <Fuse.Visual.h #include <Uno.Collections.ICollection-1.h #include <Uno.Collections.IEnumerable-1.h #include <Uno.Collections.IList-1.h #include <Uno.UX.IPropertyListener.h namespace g{namespace Fuse{namespace Controls{struct ScrollView;}}} namespace g{namespace Uno{namespace UX{struct Selector;}}} namespace g{ namespace Fuse{ namespace Controls{ // public partial sealed class ScrollView :58 // { ::g::Fuse::Controls::ScrollViewBase_type* ScrollView_typeof(); void ScrollView__ctor_7_fn(ScrollView* __this); void ScrollView__InitializeUX_fn(ScrollView* __this); void ScrollView__New4_fn(ScrollView** __retval); void ScrollView__OnRooted_fn(ScrollView* __this); void ScrollView__OnUnrooted_fn(ScrollView* __this); struct ScrollView : ::g::Fuse::Controls::ScrollViewBase { static ::g::Uno::UX::Selector __selector0_; static ::g::Uno::UX::Selector& __selector0() { return ScrollView_typeof()- Init(), __selector0_; } void ctor_7(); void InitializeUX(); static ScrollView* New4(); }; // } }}} // ::g::Fuse::Controls
a5249d251a7d8458876f0cf58ecb585186eb7849
d50b3cf185f19206cc04657efb39e441f8e5ac59
/GameTemplate/Game/Enemy/State/IEnemyState.cpp
c11d41cedf2d267482175312ae62a86dc3e27cb1
[]
no_license
kaito1111/GameTemplete
bf908fe837c7777dd8e6b34dc9a2399f8e044646
b752228adae4913c831c32270a9a700e72b597fd
refs/heads/master
2023-08-24T21:10:48.896577
2021-10-14T05:21:51
2021-10-14T05:21:51
278,224,007
0
0
null
null
null
null
UTF-8
C++
false
false
43
cpp
#include "pch.h" #include "IEnemyState.h"
cfd52a418d86c79e149c87d8e2ad1bc471d02b67
d199bf1638447d61aa07da67a7c265e2f3f4bbbe
/w07_h01_flowFieldDynamic/src/ofApp.h
9a8999695a4db567be5f13bdd7eb23256d61ae0a
[]
no_license
segoj297/UmiSyam_OFanimation2015
8299173dabb10f3c490ff5b8c97d339850044b10
3368ec009b73424b0c556a78a7510302a8628319
refs/heads/master
2021-01-22T13:14:00.699585
2015-05-13T03:45:03
2015-05-13T03:45:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
569
h
#pragma once #include "ofMain.h" #include "flowField.h" class ofApp : public ofBaseApp{ public: void setup(); void update(); void draw(); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); float w,h,res; ofVideoGrabber vid; flowField flowField; };
3429407a2c383a1b2900b482b2544f8f4e9de681
a88564964a2d891bc527f43f99a40b8ae96cf11c
/extern/plog/include/plog/Init.h
c8cbf4f7dad099e66cb74f65260bb23a4d3eb530
[ "MIT", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference", "MPL-1.1", "MPL-2.0" ]
permissive
jameskr97/etterna
f09dca2777f307e1f9ed9444e26792890920f9e2
5acb2a3be336bc6f92b96ef8dd73743f92e84552
refs/heads/master
2023-02-20T10:45:06.686289
2023-01-09T07:46:49
2023-01-09T07:46:49
173,903,384
0
3
MIT
2019-05-04T02:30:57
2019-03-05T08:11:58
C++
UTF-8
C++
false
false
3,825
h
#pragma once #include <plog/Logger.h> #include <plog/Formatters/CsvFormatter.h> #include <plog/Formatters/TxtFormatter.h> #include <plog/Appenders/RollingFileAppender.h> #include <cstring> namespace plog { namespace { bool isCsv(const util::nchar* fileName) { const util::nchar* dot = util::findExtensionDot(fileName); #ifdef _WIN32 return dot && 0 == std::wcscmp(dot, L".csv"); #else return dot && 0 == std::strcmp(dot, ".csv"); #endif } } ////////////////////////////////////////////////////////////////////////// // Empty initializer / one appender template<int instanceId> inline Logger<instanceId>& init(Severity maxSeverity = none, IAppender* appender = NULL) { static Logger<instanceId> logger(maxSeverity); return appender ? logger.addAppender(appender) : logger; } inline Logger<PLOG_DEFAULT_INSTANCE_ID>& init(Severity maxSeverity = none, IAppender* appender = NULL) { return init<PLOG_DEFAULT_INSTANCE_ID>(maxSeverity, appender); } ////////////////////////////////////////////////////////////////////////// // RollingFileAppender with any Formatter template<class Formatter, int instanceId> inline Logger<instanceId>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) { static RollingFileAppender<Formatter> rollingFileAppender(fileName, maxFileSize, maxFiles); return init<instanceId>(maxSeverity, &rollingFileAppender); } template<class Formatter> inline Logger<PLOG_DEFAULT_INSTANCE_ID>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) { return init<Formatter, PLOG_DEFAULT_INSTANCE_ID>(maxSeverity, fileName, maxFileSize, maxFiles); } ////////////////////////////////////////////////////////////////////////// // RollingFileAppender with TXT/CSV chosen by file extension template<int instanceId> inline Logger<instanceId>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) { return isCsv(fileName) ? init<CsvFormatter, instanceId>(maxSeverity, fileName, maxFileSize, maxFiles) : init<TxtFormatter, instanceId>(maxSeverity, fileName, maxFileSize, maxFiles); } inline Logger<PLOG_DEFAULT_INSTANCE_ID>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) { return init<PLOG_DEFAULT_INSTANCE_ID>(maxSeverity, fileName, maxFileSize, maxFiles); } ////////////////////////////////////////////////////////////////////////// // CHAR variants for Windows #ifdef _WIN32 template<class Formatter, int instanceId> inline Logger<instanceId>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) { return init<Formatter, instanceId>(maxSeverity, util::toWide(fileName).c_str(), maxFileSize, maxFiles); } template<class Formatter> inline Logger<PLOG_DEFAULT_INSTANCE_ID>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) { return init<Formatter, PLOG_DEFAULT_INSTANCE_ID>(maxSeverity, fileName, maxFileSize, maxFiles); } template<int instanceId> inline Logger<instanceId>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) { return init<instanceId>(maxSeverity, util::toWide(fileName).c_str(), maxFileSize, maxFiles); } inline Logger<PLOG_DEFAULT_INSTANCE_ID>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) { return init<PLOG_DEFAULT_INSTANCE_ID>(maxSeverity, fileName, maxFileSize, maxFiles); } #endif }
c144218ac81c29cf34bfbdd06c5947aac990dd6a
88e764cb43d6ba43ef67fc9e4e63445caaa1b4d9
/S13E13 - Prova/main.cpp
5645b49ed0bbd9268967178a2a3114c1502de281
[]
no_license
adanbueno/POO_2018.2
93bbc65dfb83645abf4f50010f6360cc508f26c2
cb957bdab8838d92ead46e37acb23df16d292b06
refs/heads/master
2020-03-26T14:50:16.639451
2018-12-06T19:51:41
2018-12-06T19:51:41
145,007,565
0
0
null
null
null
null
UTF-8
C++
false
false
8,214
cpp
#include <iostream> #include <sstream> #include <vector> #include <map> using namespace std; class Entry { bool favorited; public: virtual string getId() = 0; virtual void setFavorited(bool value) = 0; virtual bool isFavorited() = 0; virtual string toString() = 0; }; class Note : public Entry { string id; bool favorited = false; vector<string> itens; public: Note(string id = ""){ this->id = id; } string getId(){ return id; } void addItem(string item){ itens.push_back(item); } void rmItem(int indice){ itens.erase(itens.begin()+indice); } string toString(){ int i = 0; string saida = id+" N [ "; for(auto item : itens){ saida += to_string(i++) +": "+item + " "; } saida +="]"; if(favorited){ saida+=" - Favorito: true"; }else{ saida+=" - Favorito: false"; } return saida; } void setFavorited(bool fv){ favorited = fv; } bool isFavorited(){ return favorited; } }; class Fone { public: string id; string number; Fone(string id = "", string number = ""){ this->id = id; this->number = number; } static bool validate(string number) { string data = "1234567890()- "; for(auto c : number) if(data.find(c) == string::npos) return false; return true; } }; class Contato : public Entry{ string name; bool favorited = false; vector<Fone> fones; public: void setFavorited(bool fv){ favorited = fv; } bool isFavorited(){ return favorited; } Contato(string name = ""){ this->name = name; } string getId(){ return name; } void addFone(Fone fone){ if(!Fone::validate(fone.number)) throw string("fone " + fone.number + " invalido"); fones.push_back(fone); } void rmFone(size_t indice){ if(indice < 0 || indice >= fones.size()) throw string("indice " + to_string(indice) + " nao existe"); fones.erase(fones.begin() + indice); } vector<Fone> getFones(){ vector<Fone> resp; for(auto fone: fones) resp.push_back(fone); return resp; } string toString(){ string saida = this->name + " C "; int i = 0; for(auto fone : getFones()) saida += "[" + to_string(i++) + ":" + fone.id + ":" + fone.number + "]"; if(favorited){ saida+=" - Favorito: true"; }else{ saida+=" - Favorito: false"; } return saida; } }; class Agenda { // map<string, Contato> contatos; // map<string, Contato*> favoritos; public: map<string, Entry*> m_entries; map<string, Entry*> m_favorities; void addEntry(Entry * entry){ m_entries.insert(make_pair(entry->getId(), entry)); } void rmEntry(string id){ m_entries.erase(id); } void favorite(string idEntry){ auto it = m_entries.find(idEntry); if(it != m_entries.end()){ m_entries.at(idEntry)->setFavorited(true); m_favorities.insert(make_pair(idEntry, m_entries.at(idEntry))); }else{ cout << "fail: Entrada inexistente." << endl; } } void unfavorite(string idEntry){ auto it = m_entries.find(idEntry); if(it != m_entries.end()){ m_entries.at(idEntry)->setFavorited(false); m_favorities.erase(idEntry); }else{ cout << "fail: Entrada inexistente." << endl; } } vector<Entry*> getFavorited(){ vector<Entry*> favoritos; for(auto it : m_favorities){ favoritos.push_back(it.second); } return favoritos; } Entry * getEntry(string id){ auto it = m_entries.find(id); if(it != m_entries.end()){ return m_entries.at(id); }else{ cout << "fail: Entrada inexistente." << endl; } } vector<Entry*> getEntries(){ vector<Entry*> entradas; for(auto it : m_entries){ entradas.push_back(it.second); } return entradas; } string toString(){ stringstream ss; for(auto it : m_entries){ ss << it.second->toString()<<endl; } return ss.str(); } }; class AgendaMaster : public Agenda{ public: Contato * getContato(string id){ if(Contato *contato = dynamic_cast<Contato*>(getEntry(id))){ return contato; } return nullptr; } Note * getNote(string id){ if(Note *note = dynamic_cast<Note*>(getEntry(id))){ return note; } return nullptr; } }; class Controller { AgendaMaster agenda; public: void shell(string line){ stringstream ss(line); string op; ss >> op; if(op == "addContato"){ string name, id_number; ss >> name; string id, fone; agenda.addEntry(new Contato(name)); while(ss >> id_number){ stringstream ssfone(id_number); getline(ssfone, id, ':'); ssfone >> fone; } Contato *contato = agenda.getContato(name); contato->addFone(Fone(id, fone)); //agenda.addContato(cont); }else if(op == "addNote"){ string name; ss >> name; agenda.addEntry(new Note(name)); }else if(op == "rmNote"){ string name; ss >> name; agenda.rmEntry(name); }else if(op == "addFone"){ string name, id_number; ss >> name; string id, fone; while(ss >> id_number){ stringstream ssfone(id_number); getline(ssfone, id, ':'); ssfone >> fone; } Contato *contato = agenda.getContato(name); contato->addFone(Fone(id, fone)); }else if(op == "rmFone"){ string name; int indice; ss >> name >> indice; //agenda.getContato(name)->rmFone(indice); Contato *contato = agenda.getContato(name); contato->rmFone(indice); }else if(op == "addItem"){ string name, anotacao="", comando; ss >> name; while(ss >> comando){ anotacao+=comando+" "; } Note *note = agenda.getNote(name); note->addItem(anotacao); }else if(op == "rmItem"){ string name; int indice; ss >> name; ss >> indice; Note *note = agenda.getNote(name); note->rmItem(indice); }else if(op == "rmContato"){ string name; ss >> name; agenda.rmEntry(name); }else if(op == "agenda"){ cout << agenda.toString(); }else if(op == "search"){ string pattern; ss >> pattern; auto it = agenda.getEntry(pattern); cout << it->toString() << endl; }else if(op == "fav"){ string name; ss >> name; agenda.favorite(name); }else if(op == "desfav"){ string name; ss >> name; agenda.unfavorite(name); }else if(op == "showFav"){ for(auto *it : agenda.getFavorited()){ cout << it->toString() << endl; } }else cout << "comando invalido" << endl; } void exec() { string line = ""; while(true){ getline(cin, line); cout << "$" << line << endl; if(line == "end") return; try { shell(line); } catch(const string& e) { cout << e << endl; } } } }; int main(){ Controller controller; controller.exec(); return 0; }
8a17edb9ed8cc68eb68066472ab6326b771577f2
8cce708c237041daa227063fefdd7965e0b81434
/Resources/Slim/trunk/bass/db/FicDbFile.cpp
8cf6d4c8c96ad3b9e8196b9535d6a939b4900050
[ "Apache-2.0" ]
permissive
arcchitjain/Mistle
21842571646a181d3854a6341372a624826d67ff
60d810046a6856860ac6dbb61f0b54a6d8b73e84
refs/heads/master
2023-03-12T21:18:40.961852
2021-03-01T09:44:51
2021-03-01T09:44:51
218,982,946
1
0
null
null
null
null
UTF-8
C++
false
false
15,375
cpp
#include "../Bass.h" #include "Database.h" #include "ClassedDatabase.h" #include "../itemstructs/ItemSet.h" #include "../isc/ItemTranslator.h" #include <StringUtils.h> #include <logger/Log.h> #if (defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))) #include <glibc_s.h> #include <tr1/cinttypes> #endif #if defined (__GNUC__) #include <cstring> #endif #include "FicDbFile.h" FicDbFile::FicDbFile() { } FicDbFile::~FicDbFile() { } Database *FicDbFile::Read(string filename) { ECHO(2, printf("** Database :: \n")); uint32 pos = (uint32) filename.find_last_of("\\/"); ECHO(2, printf(" * File:\t\t%s\n", pos==string::npos ? (filename.length()>55 ? filename.substr(filename.length()-55,filename.length()-1).c_str() : filename.c_str()) : filename.substr(pos+1,filename.length()-1).c_str())); string intdt = ItemSet::TypeToFullName(mPreferredDataType); FILE *fp = NULL; char *bp = NULL, *buffer = new char[FICDBFILE_BUFFER_LENGTH + 1]; if(fopen_s(&fp, filename.c_str(), "r") != 0) throw string("FicDbFile::Read() --- Could not open file for reading."); uint32 numRows = 0, alphaSize = 0, prunedBelow = 0, maxSetLength = 0, numColumns = 0, numTransactions = 0, dummyInt; uint32 *abNumRows = NULL, *abCounts = NULL; uint64 numItems = 0; double stdDbSize; bool hasColDef = false, hasBinSizes = false, isClassedDB = false, calcAbNumRows = false, hasTransactionIds = false, abWarn = false; alphabet *a = new alphabet(); ItemSet **data = NULL; ItemSet **colDef = NULL; Database *db = NULL; ClassedDatabase *cdb = NULL; if(fp != NULL) { uint32 versionMajor = 0, versionMinor = 0; ECHO(3, printf(" * Reading header:\tin progress...")); if(fscanf_s(fp, "fic-%d.%d\n", &versionMajor, &versionMinor) < 2) throw string("Can only read fic database files."); if(versionMajor!=1 || (versionMinor!=2 && versionMinor!=3 && versionMinor!=4 && versionMinor!=5 && versionMinor!=6)) throw string("Can only read fic database version 1.2-1.6 files."); if(versionMinor == 2) // 1.2 fscanf_s(fp, "%d %" I64d " %d %lf %d %d\n", &numRows, &numItems, &alphaSize, &stdDbSize, &prunedBelow, &maxSetLength); else if (versionMinor == 3) { // 1.3 uint32 uintBinSize; fscanf_s(fp, "%d %" I64d " %d %lf %d %d %d\n", &numRows, &numItems, &alphaSize, &stdDbSize, &prunedBelow, &maxSetLength, &uintBinSize); hasBinSizes = uintBinSize==0 ? false : true; } else if (versionMinor == 4) { // 1.4 uint32 uintBinSize, uintClasses; fscanf_s(fp, "%d %" I64d " %d %lf %d %d %d %d\n", &numRows, &numItems, &alphaSize, &stdDbSize, &prunedBelow, &maxSetLength, &uintBinSize, &uintClasses); hasBinSizes = uintBinSize==0 ? false : true; isClassedDB = uintClasses==0 ? false : true; } else if (versionMinor == 5) { // 1.5 uint32 uintBinSize, uintClasses; fscanf_s(fp, "mi: nR=%d nT=%d nI=%" I64d " aS=%d sS=%lf mL=%d b?=%d c?=%d\n", &numRows, &numTransactions, &numItems, &alphaSize, &stdDbSize, &maxSetLength, &uintBinSize, &uintClasses); hasBinSizes = uintBinSize==0 ? false : true; isClassedDB = uintClasses==0 ? false : true; } else { // 1.6 uint32 uintBinSize, uintClasses, uintTids; fscanf_s(fp, "mi: nR=%d nT=%d nI=%" I64d " aS=%d sS=%lf mL=%d b?=%d c?=%d tid?=%d\n", &numRows, &numTransactions, &numItems, &alphaSize, &stdDbSize, &maxSetLength, &uintBinSize, &uintClasses, &uintTids); hasBinSizes = uintBinSize==0 ? false : true; isClassedDB = uintClasses==0 ? false : true; hasTransactionIds = uintTids==0? false : true; } if(isClassedDB) { cdb = new ClassedDatabase(); db = cdb; } else db = new Database(); // Path & filename string path, ext; Database::DeterminePathFileExt(path, filename, ext, DbFileTypeFic); db->SetPath(path); db->SetFilename(filename); // Some statistics db->SetNumRows(numRows); db->SetNumItems(numItems); db->SetStdDbSize(stdDbSize); db->SetMaxSetLength(maxSetLength); db->SetHasBinSizes(hasBinSizes); db->SetHasTransactionIds(hasTransactionIds); // New Stylee (v1.5+) Header Reading if(versionMinor >= 5) { fgets(buffer, FICDBFILE_BUFFER_LENGTH, fp); while(buffer[0] <= 'z' && buffer[0] >= 'a' && buffer[1] <= 'z' && buffer[1] >= 'a' && buffer[2] == ':') { string three(buffer,3); // Alphabet -- implicitly assumes the next line to contain the Alphabet Counts if(three.compare("ab:") == 0) { uint16* abItems = StringUtils::TokenizeUint16(buffer+4, dummyInt, " "); fgets(buffer, FICDBFILE_BUFFER_LENGTH, fp); abCounts = StringUtils::TokenizeUint32(buffer+4, dummyInt, " "); for(uint32 i=0; i<alphaSize; i++) a->insert(alphabetEntry(abItems[i], abCounts[i])); db->SetAlphabet(a); delete[] abItems; if(alphaSize > 128 && mPreferredDataType == BM128ItemSetType) { mPreferredDataType = Uint16ItemSetType; abWarn = true; } } // Alphabet Row Counts else if(three.compare("ar:") == 0) { // abNumRows = StringUtils::TokenizeUint32(buffer+4, dummyInt); // db->SetAlphabetNumRows(abNumRows); ; } // Item Translator else if(three.compare("it:") == 0) { db->SetItemTranslator(new ItemTranslator(StringUtils::TokenizeUint16(buffer+4, dummyInt), alphaSize)); } // Column Definition else if(three.compare("cd:") == 0) { hasColDef = true; string* colDefStrAr = StringUtils::Tokenize(buffer+4, numColumns, ",", " "); colDef = new ItemSet*[numColumns]; for(uint32 i=0; i<numColumns; i++) { uint32 colLength = 0; uint16 *iset = StringUtils::TokenizeUint16(colDefStrAr[i], colLength, " ", ""); colDef[i] = ItemSet::Create(mPreferredDataType, iset, colLength, alphaSize, 1); delete[] iset; } delete[] colDefStrAr; db->SetColumnDefinition(colDef, numColumns); } // Classes else if(three.compare("cl:") == 0) { uint32 numClasses = 0; uint16 *classes = StringUtils::TokenizeUint16(buffer+4, numClasses); db->SetClassDefinition(numClasses, classes); } // Read next line, while-loop exists when no header-element is present if(fgets(buffer, FICDBFILE_BUFFER_LENGTH, fp) == NULL) break; } if(abNumRows != NULL) { // - AbNumRows reeds geladen calcAbNumRows = false; delete[] abCounts; } else { // - AbNumRows niet geladen if(hasBinSizes) { // - AbNumRows moet uitgerekend worden calcAbNumRows = true; abNumRows = abCounts; } else { // - AbNumRows kan gekopieerd worden calcAbNumRows = false; db->SetAlphabetNumRows(abCounts); } } } else { // Old Stylee (< v1.5), only for backward compatibility // Read alphabet elements fgets(buffer, FICDBFILE_BUFFER_LENGTH, fp); string ab = StringUtils::Trim(buffer, " "); abCounts = StringUtils::TokenizeUint32(ab, dummyInt, " "); for(uint32 i=0; i<alphaSize; i++) a->insert(alphabetEntry(i, abCounts[i])); db->SetAlphabet(a); if(hasBinSizes) { calcAbNumRows = true; abNumRows = abCounts; } else { db->SetAlphabetNumRows(abCounts); } // Read ItemTranslator fgets(buffer, FICDBFILE_BUFFER_LENGTH, fp); string it = StringUtils::Trim(buffer," "); db->SetItemTranslator(new ItemTranslator(StringUtils::TokenizeUint16(it, dummyInt), alphaSize)); if(isClassedDB) { fgets(buffer, FICDBFILE_BUFFER_LENGTH, fp); bp = buffer; uint32 numClasses = atoi(bp); while(*bp != ' ') bp++; bp++; uint16* cls = new uint16[numClasses]; for(uint32 i=0; i<numClasses; i++) { cls[i] = atoi(bp); while(*bp != ' ') bp++; bp++; } cdb->SetClassDefinition(numClasses, cls); } fgets(buffer, FICDBFILE_BUFFER_LENGTH, fp); // first data row } ECHO(3, printf("\r * Reading header:\tdone. \n")); db->ComputeStdLengths(); ECHO(2, printf(" * Database:\t\t%dt %dr, %" I64d "i, %.2lfbits\n", numTransactions, numRows, numItems, stdDbSize)); ECHO(2, printf(" * \t\t\tpruned below support %d, maximum set length %d\n", prunedBelow, maxSetLength)); if(hasBinSizes) { ECHO(2, printf(" * \t\t\tdatabase has bin sizes.\n")); } if(hasTransactionIds) { ECHO(2, printf(" * \t\t\tdatabase has transaction id's.\n")); } ECHO(2, printf(" * Alphabet:\t\t%d items\n", alphaSize)); ECHO(2, printf(" * Internal datatype:\t%s\n", intdt.c_str())); if(abWarn == true || (alphaSize > 128 && mPreferredDataType == BM128ItemSetType)) { LOG_WARNING("|ab| > 128 : won't fit in BM128, using Uint16"); mPreferredDataType = Uint16ItemSetType; } if(calcAbNumRows) { for(uint32 i=0; i<alphaSize; i++) abNumRows[i] = 0; } ECHO(3, printf(" * Reading data:\tin progress...")); data = new ItemSet *[numRows]; uint16 *row = NULL; uint32 curRow=0, rowLen=0, cnt=1, numTransactions = hasBinSizes ? 0 : numRows; uint16 val = 0; uint64 tid = 0; uint16 *classLabels = NULL; if(isClassedDB) classLabels = new uint16[numRows]; while(curRow<numRows) { if(strlen(buffer) > 0) { bp = buffer; if(versionMinor >= 5) { if(hasTransactionIds) { ++bp; // '[' #if defined (_WINDOWS) tid = _atoi64(bp); #elif (defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))) tid = atoll(bp); #endif while(*bp != ' ') ++bp; ++bp; // ' ' } rowLen = atoi(bp); while(*bp != ':') ++bp; ++bp; // ':' ++bp; // ' ' } else { rowLen = this->CountCols(buffer); if(hasBinSizes) rowLen--; if(isClassedDB) rowLen--; } row = new uint16[rowLen]; for(uint32 col=0; col<rowLen; col++) { val = atoi(bp); row[col] = val; while(*bp != ' ') ++bp; ++bp; if(calcAbNumRows) abNumRows[val]++; } if(hasBinSizes) { while(*bp != '(') ++bp; ++bp; cnt = atoi(bp); numTransactions += cnt; } if(isClassedDB) { while(*bp != '[') ++bp; ++bp; classLabels[curRow] = atoi(bp); } data[curRow] = ItemSet::Create(mPreferredDataType, row, rowLen, (uint32) a->size(), cnt); if(hasTransactionIds) data[curRow]->SetID(tid); delete[] row; } fgets(buffer, FICDBFILE_BUFFER_LENGTH, fp); curRow++; } if(curRow != numRows) throw string("Did not read numRows rows. Invalid database."); if(ferror(fp)) throw string("Error while reading DB."); fclose(fp); if(calcAbNumRows) // alleen voor oude file versie db->SetAlphabetNumRows(abNumRows); db->SetRows(data); db->SetNumTransactions(numTransactions); db->SetDataType(mPreferredDataType); if(isClassedDB) cdb->SetClassLabels(classLabels); ECHO(3, printf("\r * Reading data:\tdone \n")); } else { // File open error! delete[] buffer; delete a; throw string("Could not read database: ") + filename; } delete[] buffer; ECHO(3, printf("** Finished reading database.\n")); ECHO(2, printf("\n")); return db; } bool FicDbFile::Write(Database *db, const string &fullpath) { ECHO(2, printf("** Writing FIC database to file\n")); size_t pos = fullpath.find_last_of("\\/"); // Print max 55 characters of `fullpath`, if that long and includes a directory-separator cut off at that spot. ECHO(2, printf(" * File:\t\t%s\n", (fullpath.length() > 55 ? (pos == string::npos ? fullpath.substr(fullpath.length()-55,fullpath.length()-1) : fullpath.substr(pos+1,fullpath.length()-1)) : fullpath).c_str() )); db->ComputeEssentials(); // zouden al computed moeten zijn, maar soit FILE *fp; if(fopen_s(&fp, fullpath.c_str(), "w") != 0) throw string("Could not write database."); // Path & filename string path, filename = fullpath, ext; Database::DeterminePathFileExt(path, filename, ext, DbFileTypeFic); db->SetPath(path); db->SetFilename(filename); bool isDbClassed = db->GetType() == DatabaseClassed; ClassedDatabase *cdb = NULL; if(isDbClassed) cdb = (ClassedDatabase *)(db); ////////////////////////////////////////////////////////////////////////// // :: Header :: ////////////////////////////////////////////////////////////////////////// // mi: Meta Information (mandatory) alphabet *a = db->GetAlphabet(); bool hasBinSizes = db->HasBinSizes(); bool hasTransactionIds = db->HasTransactionIds(); fprintf(fp, "fic-1.6\n"); uint64 ni = db->GetNumItems(); fprintf(fp, "mi: nR=%d nT=%d nI=%" I64d " aS=%d sS=%.5lf mL=%d b?=%d c?=%d tid?=%d\n", db->GetNumRows(), db->GetNumTransactions(), ni, a->size(), db->GetStdDbSize(), db->GetMaxSetLength(), hasBinSizes?1:0, isDbClassed?1:0, hasTransactionIds?1:0); // mi: MetaInfo // ab: Alphabet (mandatory) size_t abLen = a->size(); fprintf(fp, "ab: "); uint32 i=0; for(alphabet::iterator iter = a->begin(); iter != a->end(); i++, ++iter) fprintf(fp, "%d%s", iter->first, i<abLen-1 ? " " : ""); fprintf(fp, "\n"); // ac: Alpabet Counts (mandatory) fprintf(fp, "ac: "); i=0; for(alphabet::iterator iter = a->begin(); iter != a->end(); i++, ++iter) fprintf(fp, "%d%s", iter->second, i<abLen-1 ? " " : ""); fprintf(fp, "\n"); // ar: Alphabet Row Counts (optional, very much preferred if binned db) if(db->GetAlphabetNumRows() != NULL) { uint32 *abNuRo = db->GetAlphabetNumRows(); fprintf(fp, "ar: "); for(uint32 i=0; i<abLen; i++) fprintf(fp, "%d%s", abNuRo[i], i<abLen-1 ? " " : ""); fprintf(fp, "\n"); } // it: Item Translator (optional) if(db->GetItemTranslator() != NULL) fprintf(fp, "it: %s\n", db->GetItemTranslator()->ToString().c_str()); // cd: Column Definition (optional) if(db->HasColumnDefinition() && db->GetNumColumns() > 1) { fprintf(fp, "cd: "); uint32 numCol = db->GetNumColumns(); ItemSet **colDef = db->GetColumnDefinition(); for(uint32 i=0; i<numCol; i++) fprintf(fp, "%s%s", colDef[i]->ToString(false,false).c_str(), (i<numCol-1) ? ", " : ""); fprintf(fp, "\n"); } // cl: Classes (optional) if(db->GetNumClasses() > 0) { uint32 num = db->GetNumClasses(); uint16* cls = db->GetClassDefinition(); fprintf(fp, "cl: "); for(uint32 i=0; i<num; i++) fprintf(fp, "%d%s", cls[i], (i<num-1 ? " " : "")); fprintf(fp, "\n"); } // dc: Data Integrity Code (optional?) /*if(db->HasDataIntegrityCode()) { }*/ // ////////////////////////////////////////////////////////////////////////// // :: Data :: ////////////////////////////////////////////////////////////////////////// ItemSet *is; uint32 *vals = new uint32[db->GetMaxSetLength()]; uint32 islen; for(uint32 i=0; i<db->GetNumRows(); i++) { is = db->GetRow(i); islen = is->GetLength(); if(islen == 0) continue; #if defined (_MSC_VER) && defined (_WINDOWS) if(hasTransactionIds) fprintf(fp, "[%I64u] ", is->GetID()); #elif defined (__GNUC__) && (defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))) if(hasTransactionIds) fprintf(fp, "[%lu] ", is->GetID()); #endif fprintf(fp, "%d: %s", islen, is->ToString(false,false).c_str()); if(hasBinSizes) fprintf(fp, " (%d)", is->GetUsageCount()); if(isDbClassed) fprintf(fp, " [%d]", cdb->GetClassLabel(i)); fprintf(fp, "\n"); } delete[] vals; fclose(fp); ECHO(2, printf("** Finished writing database.\n\n")); return true; } uint32 FicDbFile::CountCols(char *buffer) { uint32 count = 0, index = 0; while(buffer[index] != '\n') { if(buffer[index++] == ' ') count++; } if(index != 0 && buffer[index] == '\n' && buffer[index-1] != ' ') count++; return count; }
771f1352f99e7657f3fce29fd761ec1a68a11f77
66b66a041667f51f60cf3c457c1e61c23ee3c6dd
/src/media.cpp
cd2070a35672b84e742481398a93b1000f6e8f2a
[]
no_license
ArneDJ/game
5a7250ccf38ca1febb265fa1501fe81c67f81357
bb35ba0df6322559b7feb3b3eabbb1e8c5211cf4
refs/heads/main
2023-06-09T23:12:09.094697
2021-07-10T12:03:20
2021-07-10T12:03:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,297
cpp
#include <string> #include <map> #include <vector> #include <iostream> #include <fstream> #include <map> #include <GL/glew.h> #include <GL/gl.h> #include <glm/glm.hpp> #include <glm/vec3.hpp> #include <glm/vec4.hpp> #include <glm/mat4x4.hpp> #include <glm/gtc/type_ptr.hpp> #include "geometry/geom.h" #include "util/image.h" #include "graphics/texture.h" #include "graphics/mesh.h" #include "graphics/model.h" #include "media.h" std::string MediaManager::basepath; std::map<uint64_t, gfx::Texture*> MediaManager::textures; std::map<uint64_t, gfx::Model*> MediaManager::models; static inline bool file_access(const std::string &filepath) { std::ifstream file(filepath.c_str()); return file.good(); } void MediaManager::change_path(const std::string &path) { basepath = path + "media/"; } void MediaManager::teardown(void) { // delete textures for (auto it = textures.begin(); it != textures.end(); it++) { gfx::Texture *texture = it->second; delete texture; } // delete models for (auto it = models.begin(); it != models.end(); it++) { gfx::Model *model = it->second; delete model; } } const gfx::Model* MediaManager::load_model(const std::string &relpath) { std::string filepath = basepath + "models/" + relpath; uint64_t ID = std::hash<std::string>()(filepath); auto mit = models.find(ID); // model not found in map // load new one if (mit == models.end()) { gfx::Model *model = new gfx::Model { filepath }; std::vector<const gfx::Texture*> materials; // load diffuse texture if present std::string diffusepath = relpath.substr(0, relpath.find_last_of('.')) + ".dds"; if (file_access(basepath + "textures/" + diffusepath)) { materials.push_back(load_texture(diffusepath)); } model->load_materials(materials); models.insert(std::make_pair(ID, model)); return model; } return mit->second; } const gfx::Texture* MediaManager::load_texture(const std::string &relpath) { std::string filepath = basepath + "textures/" + relpath; uint64_t ID = std::hash<std::string>()(filepath); auto mit = textures.find(ID); // texture not found in map // load new one if (mit == textures.end()) { gfx::Texture *texture = new gfx::Texture { filepath }; textures.insert(std::make_pair(ID, texture)); return texture; } return mit->second; }
673bf25194b5061830b6c40e5ce45f9cb57a2328
b9c1098de9e26cedad92f6071b060dfeb790fbae
/src/tools/progress_callback_helpers.h
47e36928051891a4c0a43b1f09ca90812996804f
[]
no_license
vitamin-caig/zxtune
2a6f38a941f3ba2548a0eb8310eb5c61bb934dbe
9940f3f0b0b3b19e94a01cebf803d1a14ba028a1
refs/heads/master
2023-08-31T01:03:45.603265
2023-08-27T11:50:45
2023-08-27T11:51:26
13,986,319
138
13
null
2021-09-13T13:58:32
2013-10-30T12:51:01
C++
UTF-8
C++
false
false
1,678
h
/** * * @file * * @brief Progress callback helpers * * @author [email protected] * **/ #pragma once // common includes #include <progress_callback.h> // library includes #include <math/scale.h> //! @brief Namespace is used for logging and other informational purposes namespace Log { //! @brief Progress receiver class PercentProgressCallback : public ProgressCallback { public: PercentProgressCallback(uint_t total, ProgressCallback& delegate) : ToPercent(total, 100) , Delegate(delegate) {} void OnProgress(uint_t current) override { Delegate.OnProgress(ToPercent(current)); } void OnProgress(uint_t current, StringView message) override { Delegate.OnProgress(ToPercent(current), message); } private: const Math::ScaleFunctor<uint_t> ToPercent; ProgressCallback& Delegate; }; class NestedProgressCallback : public ProgressCallback { public: NestedProgressCallback(uint_t total, uint_t done, ProgressCallback& delegate) : ToPercent(total, 100) , Start(ToPercent(done)) , Range(ToPercent(done + 1) - Start) , Delegate(delegate) {} void OnProgress(uint_t current) override { Delegate.OnProgress(Scale(current)); } void OnProgress(uint_t current, StringView message) override { Delegate.OnProgress(Scale(current), message); } private: uint_t Scale(uint_t nested) const { return Start + Math::Scale(nested, 100, Range); } private: const Math::ScaleFunctor<uint_t> ToPercent; const uint_t Start; const uint_t Range; ProgressCallback& Delegate; }; } // namespace Log
56424f5fc384281ad2bfbece7fbabf3a08e57884
bfa3975d6cbc2f50869d5cb2c8529c83752cbf05
/Configure.cpp
d59135c7cfc6dc83ab1390faad8b04fd623809f3
[]
no_license
jackieju/cs
1306bd6278658cc8b9d800ffeda81e59d61735c2
bb81eee7081bbccedeb7c488e81880f418a53d63
refs/heads/master
2021-01-13T16:25:55.452683
2012-02-26T08:46:35
2012-02-26T08:46:35
1,492,148
2
0
null
null
null
null
UTF-8
C++
false
false
23
cpp
#include "Configure.h"
9209e2b80f3767ced8b4efb450873fb79e20501d
35b929181f587c81ad507c24103d172d004ee911
/Bundles/LeafUI/uiVisuQt/include/uiVisuQt/PointEditor.hpp
d500c458d5eb41f1b9addc2b53403ad0915e8ca9
[]
no_license
hamalawy/fw4spl
7853aa46ed5f96660123e88d2ba8b0465bd3f58d
680376662bf3fad54b9616d1e9d4c043d9d990df
refs/heads/master
2021-01-10T11:33:53.571504
2015-07-23T08:01:59
2015-07-23T08:01:59
50,699,438
2
1
null
null
null
null
UTF-8
C++
false
false
1,859
hpp
/* ***** BEGIN LICENSE BLOCK ***** * FW4SPL - Copyright (C) IRCAD, 2009-2012. * Distributed under the terms of the GNU Lesser General Public License (LGPL) as * published by the Free Software Foundation. * ****** END LICENSE BLOCK ****** */ #ifndef _UIVISUQT_POINT_EDITOR_HPP #define _UIVISUQT_POINT_EDITOR_HPP #include <QObject> #include <QLineEdit> #include <QPointer> #include <fwTools/Failed.hpp> #include <fwData/Point.hpp> #include <gui/editor/IEditor.hpp> #include "uiVisuQt/config.hpp" namespace uiVisu { /** * @brief PointEditor service allows to display point information. * @class PointEditor * * @date 2010. */ class UIVISUQT_CLASS_API PointEditor : public QObject, public ::gui::editor::IEditor { Q_OBJECT public : fwCoreServiceClassDefinitionsMacro ( (PointEditor)(::gui::editor::IEditor) ) ; /// Constructor. Do nothing. UIVISUQT_API PointEditor() throw() ; /// Destructor. Do nothing. UIVISUQT_API virtual ~PointEditor() throw() ; protected: typedef ::fwRuntime::ConfigurationElement::sptr Configuration; ///This method launches the IEditor::starting method. virtual void starting() throw(::fwTools::Failed); ///This method launches the IEditor::stopping method. virtual void stopping() throw(::fwTools::Failed); /// Management of observations ( overrides ) virtual void receiving( CSPTR(::fwServices::ObjectMsg) _msg ) throw(::fwTools::Failed); void updating() throw(::fwTools::Failed); void swapping() throw(::fwTools::Failed); void configuring() throw( ::fwTools::Failed); /// Overrides virtual void info( std::ostream &_sstream ) ; private: QPointer< QLineEdit > m_textCtrl_x; QPointer< QLineEdit > m_textCtrl_y; QPointer< QLineEdit > m_textCtrl_z; }; } // uiData #endif /*_UIVISUQT_POINT_EDITOR_HPP_*/
e577f45020a0696db8a9473dd46f688b690585b6
edfdb97e31c75b7a21704db998023b3d7583f4fb
/iOS/Classes/Native/mscorlib_System_Array_InternalEnumerator_1_gen3989553520.h
b72202f02d8fa39d74f84aa96613cb072f66288f
[]
no_license
OmnificenceTeam/ICA_Iron_App
b643ab80393e17079031d64fec6fa95de0de0d81
7e4c8616ec2e2b358d68d446d4b40d732c085ca9
refs/heads/master
2021-07-16T06:53:58.273883
2017-10-23T10:52:21
2017-10-23T10:52:21
107,165,753
0
0
null
null
null
null
UTF-8
C++
false
false
1,444
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include "mscorlib_System_ValueType3507792607.h" // System.Array struct Il2CppArray; #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Array/InternalEnumerator`1<System.Xml.XPath.XPathItem> struct InternalEnumerator_1_t3989553520 { public: // System.Array System.Array/InternalEnumerator`1::array Il2CppArray * ___array_0; // System.Int32 System.Array/InternalEnumerator`1::idx int32_t ___idx_1; public: inline static int32_t get_offset_of_array_0() { return static_cast<int32_t>(offsetof(InternalEnumerator_1_t3989553520, ___array_0)); } inline Il2CppArray * get_array_0() const { return ___array_0; } inline Il2CppArray ** get_address_of_array_0() { return &___array_0; } inline void set_array_0(Il2CppArray * value) { ___array_0 = value; Il2CppCodeGenWriteBarrier(&___array_0, value); } inline static int32_t get_offset_of_idx_1() { return static_cast<int32_t>(offsetof(InternalEnumerator_1_t3989553520, ___idx_1)); } inline int32_t get_idx_1() const { return ___idx_1; } inline int32_t* get_address_of_idx_1() { return &___idx_1; } inline void set_idx_1(int32_t value) { ___idx_1 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
cf5e60e4e62c30bfc69c1c577fac2d871323184c
2017f78c94ad409666a866cde69f47cb1bdba32c
/UIMaterialNodeAbs.h
ff0943f2e4dd718365688d362b4cc8ba2ed3098a
[]
no_license
solaxu/Simple-Visual-Material-Editor
4ed6a356abd829ca0154df9d040ff8ab8bca057d
abaf05840343c30cfdf1427848760c267f361160
refs/heads/master
2021-01-17T16:02:37.154462
2017-07-05T12:00:03
2017-07-05T12:00:03
95,457,067
1
0
null
null
null
null
UTF-8
C++
false
false
2,146
h
#pragma once #include "UIMgr.h" namespace ShaderEditor { class UINodeAbs : public SUIWindow { public: UINodeAbs(float x, float y, float width, float heigth, UIObject* parent) : SUIWindow(x, y, width, heigth, UIDrawParams::DefaultBorderWidth, parent) { m_nodeType = new SUILabel(x, y + heigth, width, heigth, UIDrawParams::DefaultBorderWidth, this); m_nodeType->Name = CString(_T("Abs")); m_nodeType->ShowBorder(TRUE); m_body = new SUILabel(x, y + heigth * 2, width, 40, UIDrawParams::DefaultBorderWidth, this); m_body->ShowBorder(TRUE); float InY = y + heigth * 2 + 5; float OutY = InY; SUIButton* inputX = new SUIButton(x + width, InY, 40, 20, 2, this); InY += 30; inputX->Name = CString(_T("f")); inputX->ID = UIMgr::GenerateUIID(); inputX->Usage = SUIButton::LINK_IN; ////////////////////////////////////////////////////////////////////////// SUIButton* OutputX = new SUIButton(x - 40, OutY, 40, 20, 2, this); OutY += 30; OutputX->Name = CString(_T("f")); OutputX->ID = UIMgr::GenerateUIID(); OutputX->Usage = SUIButton::LINK_OUT; } virtual ~UINodeAbs() { for each (auto ptr in Children) { if (ptr) { delete ptr; ptr = NULL; } } } virtual void Draw(LPDIRECT3DDEVICE9 device, LPD3DXFONT font) { SUIWindow::Draw(device, font); for each (auto ptr in Children) { ptr->Draw(device, font); } } virtual CString SyntaxTreeGenCode(DWORD sh /* = PSH_CODE */) { CString s; CString str = _T("float "); str += Name; str += _T(" = abs("); int i = 0; for each (auto ptr in M_INPUTS) { auto btn = dynamic_cast<SUIButton*>(ptr); auto IN_WND = dynamic_cast<SUIWindow*>(btn->IN_BTN[0]->Parent); if (IN_WND) { if (!IN_WND->M_VISITED) s += IN_WND->SyntaxTreeGenCode(sh); if (IN_WND->isStruct) { str += IN_WND->Name; str += _T("."); str += btn->IN_BTN[0]->Name; } else str += IN_WND->Name; ++i; } } str += _T(");\n"); return s + str; } public: SUILabel* m_nodeType = NULL; SUILabel* m_body = NULL; }; }
879cddef6feca9656fff3019c8d5ea2528cd32f5
dd80a584130ef1a0333429ba76c1cee0eb40df73
/external/chromium_org/third_party/skia/include/gpu/gl/SkMesaGLContext.h
55235fa6032ab4848a7bbf4970e4590fdcf3ec58
[ "MIT", "BSD-3-Clause", "GPL-1.0-or-later", "LGPL-2.0-or-later", "Apache-2.0" ]
permissive
karunmatharu/Android-4.4-Pay-by-Data
466f4e169ede13c5835424c78e8c30ce58f885c1
fcb778e92d4aad525ef7a995660580f948d40bc9
refs/heads/master
2021-03-24T13:33:01.721868
2017-02-18T17:48:49
2017-02-18T17:48:49
81,847,777
0
2
MIT
2020-03-09T00:02:12
2017-02-13T16:47:00
null
UTF-8
C++
false
false
975
h
/* * Copyright 2011 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkMesaGLContext_DEFINED #define SkMesaGLContext_DEFINED #include "SkGLContextHelper.h" #if SK_MESA class SkMesaGLContext : public SkGLContextHelper { private: typedef intptr_t Context; public: SkMesaGLContext(); virtual ~SkMesaGLContext(); virtual void makeCurrent() const SK_OVERRIDE; virtual void swapBuffers() const SK_OVERRIDE; class AutoContextRestore { public: AutoContextRestore(); ~AutoContextRestore(); private: Context fOldContext; GrGLint fOldWidth; GrGLint fOldHeight; GrGLint fOldFormat; void* fOldImage; }; protected: virtual const GrGLInterface* createGLContext() SK_OVERRIDE; virtual void destroyGLContext() SK_OVERRIDE; private: Context fContext; GrGLubyte *fImage; }; #endif #endif
7dbaf2c26b8c6abd460727f14017446c6a8ae07b
19751429b4c772b2c8155bded3312b56dd12cb24
/src/MenuHandler.h
ae4518974eade13aac9acec2b3c06d705fdff17e
[ "MIT" ]
permissive
kosmaz/MorseCoder
d23ac16c98dc8fd5e4d63597f8ce2de9f81a91fc
58a6108c07b98ffbd2e093f71c3701d40bbb246e
refs/heads/master
2021-01-13T16:56:26.579886
2017-01-26T12:46:58
2017-01-26T12:46:58
78,757,830
1
0
null
null
null
null
UTF-8
C++
false
false
134
h
#ifndef MENUHANDLER_H #define MENUHANDLER_H class MenuHandler { public: void RunProgram(); }; #endif //MENUHANDLER_H
faca0ca54585103ab585cc42fae97de6837a70af
bd1fea86d862456a2ec9f56d57f8948456d55ee6
/000/064/110/CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_loop_81a.cpp
b8f80084937316a521dcea68fa410fe006693494
[]
no_license
CU-0xff/juliet-cpp
d62b8485104d8a9160f29213368324c946f38274
d8586a217bc94cbcfeeec5d39b12d02e9c6045a2
refs/heads/master
2021-03-07T15:44:19.446957
2020-03-10T12:45:40
2020-03-10T12:45:40
246,275,244
0
1
null
null
null
null
UTF-8
C++
false
false
2,743
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_loop_81a.cpp Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE805.string.label.xml Template File: sources-sink-81a.tmpl.cpp */ /* * @description * CWE: 121 Stack Based Buffer Overflow * BadSource: Set data pointer to the bad buffer * GoodSource: Set data pointer to the good buffer * Sinks: loop * BadSink : Copy string to data using a loop * Flow Variant: 81 Data flow: data passed in a parameter to an virtual method called via a reference * * */ #include "std_testcase.h" #include "CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_loop_81.h" namespace CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_loop_81 { #ifndef OMITBAD void bad() { char * data; char dataBadBuffer[50]; char dataGoodBuffer[100]; /* FLAW: Set a pointer to a "small" buffer. This buffer will be used in the sinks as a destination * buffer in various memory copying functions using a "large" source buffer. */ data = dataBadBuffer; data[0] = '\0'; /* null terminate */ const CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_loop_81_base& baseObject = CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_loop_81_bad(); baseObject.action(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ static void goodG2B() { char * data; char dataBadBuffer[50]; char dataGoodBuffer[100]; /* FIX: Set a pointer to a "large" buffer, thus avoiding buffer overflows in the sinks. */ data = dataGoodBuffer; data[0] = '\0'; /* null terminate */ const CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_loop_81_base& baseObject = CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_loop_81_goodG2B(); baseObject.action(data); } void good() { goodG2B(); } #endif /* OMITGOOD */ } /* close namespace */ /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_loop_81; /* so that we can use good and bad easily */ int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
a0627d98da1346ef0f5cc4b750c58986914e23f2
bb7119c350090918378359743ab7803d0954f7cc
/Lab5/labfive.cpp
24444eb5d7c30458276482b5b7a77678cc7ecddb
[]
no_license
JuliaGrandury/cse332-lab5
3c65cc425c70a65f5161cc6bb6198148409342de
ea132308a4fc17fe79ba6d170ef4865d914cfa6f
refs/heads/master
2023-09-03T23:18:47.598110
2021-11-07T23:42:46
2021-11-07T23:42:46
425,635,700
1
0
null
null
null
null
UTF-8
C++
false
false
3,353
cpp
// labfive.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> #include "SimpleFileSystem.h" #include "SimpleFileFactory.h" #include<algorithm> #include<iterator> #include "ReadFileVisitor.h" #include "HierarchicalFileSystem.h" #include "HierarchicalFileFactory.h" #include "CommandPrompt.h" #include "TouchCommand.h" #include "CDCommand.h" #include "LSCommand.h" #include "RemoveCommand.h" #include "ImageFile.h" #include "TextFile.h" #include "DisplayCommand.h" #include "CatCommand.h" #include "CopyCommand.h" #include "SymbolicLinkCommand.h" using namespace std; int main(int argc, char* arg[]) { // allocate all objects needed AbstractFileFactory* ff = new HierarchicalFileFactory(); AbstractFileSystem* fs = new HierarchicalFileSystem(); AbstractCommand* com = new TouchCommand(ff, fs); AbstractCommand* com1 = new CDCommand(fs); AbstractCommand* com2 = new LSCommand(fs); AbstractCommand* com3 = new RemoveCommand(fs); AbstractCommand* com4 = new DisplayCommand(fs); AbstractCommand* com5 = new CatCommand(fs); AbstractCommand* com6 = new CopyCommand(fs); AbstractCommand* com7 = new SymbolicLinkCommand(fs); AbstractFile* t = new TextFile("t.txt"); vector<char> x = { 'h', 'o' }; t->write(x); //cout << t->getSize(); //cout << t->getName(); fs->addFile("root/t.txt", t); AbstractFile* i = new ImageFile("i.img"); vector<char> s = { 'X', ' ', 'X', ' ', 'X', ' ', 'X',' ', 'X', '3' }; i->write(s); fs->addFile("root/i.img", i); AbstractFile* d = new DirectoryFile("dir"); fs->addFile("root/dir", d); AbstractFile* im = new ImageFile("im.img"); AbstractFile* te = new TextFile("te.txt"); vector<char> xz = { 'h', 'o' }; te->write(xz); fs->addFile("root/dir/im.img", im); fs->addFile("root/dir/te.txt", te); fs->openFile("root/dir/te.txt"); //AbstractFileSystem* dir = new HierarchicalFileSystem; //fs->addFile("root/dir/t.txt", t); // create command prompt and configure // NOTE: the above commands will not work with a SimpleFileSystem, it would need a new set of commands // or a second CommandPrompt class CommandPrompt cmd; cmd.setFileSystem(fs); cmd.setFileFactory(ff); cmd.addCommand("touch", com); cmd.addCommand("cd", com1); cmd.addCommand("ls", com2); cmd.addCommand("rm", com3); cmd.addCommand("ds", com4); cmd.addCommand("cat", com5); cmd.addCommand("cp", com6); cmd.addCommand("sym", com7); // run the command prompt cmd.run(); // clean up dynamically allocated resources delete ff; delete fs; // all files are destroyed here (in the file system destructor) delete com; delete com1; delete com2; delete com3; delete com4; delete com5; delete com6; delete com7; return 0; } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: // 1. Use the Solution Explorer window to add/manage files // 2. Use the Team Explorer window to connect to source control // 3. Use the Output window to see build output and other messages // 4. Use the Error List window to view errors // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
112c79347f8ad73d78cdd7ab3884391530c29562
c1813e996e272a854514b11299047692e5557238
/src/xe/xe/Forward.hpp
dba83403356ad207c80323942836b4a7069acda1
[]
no_license
fapablazacl-old/xe.old
0b6048a67346c88d7ceaf128bc3c1d989a3f6e5e
8031f7baea0fe67fa63696cc363679f25eefe2e3
refs/heads/master
2021-08-27T17:20:23.953297
2017-05-25T05:54:11
2017-05-25T05:54:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
188
hpp
#pragma once #ifndef __XE_FORWARD_HPP__ #define __XE_FORWARD_HPP__ #include <xe/PreDef.hpp> namespace xe { class XE_API Core; class XE_API Buffer; } #endif
ef4c17cf304fc4b70b787a3f18e3665c3ae0daac
5a02eac79d5b8590a88209dcc6cd5741323bb5de
/PAT/第一轮/第九章_树/哈夫曼树/codeup5068_e/使用小顶堆/main.cpp
5351116dcc07495d6c63cfd8053c8859bb648778
[]
no_license
qiatongxueshaonianC/CaiZebin-Code_warehouse
ddac8252afb207d9580856cfbb7e14f868432716
25e1f32c7d86d81327a0d9f08cd7462209e9fec2
refs/heads/master
2023-03-20T03:36:49.088871
2021-03-16T15:40:11
2021-03-16T15:40:11
348,395,087
0
0
null
null
null
null
GB18030
C++
false
false
973
cpp
#include<bits/stdc++.h> using namespace std; const int maxn=10010; int n,x,y,ans,heap[maxn]; void downAdjust(int low,int high){ int i=low,j=2*i; while(j<=high){ if(j+1<=high&&heap[j+1]<heap[j]) j=j+1; if(heap[j]<heap[i]){ swap(heap[j],heap[i]); i=j; j=2*i; }else break; } } void createHeap(){ for(int i=n/2;i>=1;i--) downAdjust(i,n); } void upAdjust(int low,int high){ int i=high,j=i/2; while(j>=low){ if(heap[i]<heap[j]){ //待调整结点值小于父节点,小顶堆所以交换 swap(heap[i],heap[j]); i=j; j=i/2; }else break; } } int main() { cin>>n; for(int i=1;i<=n;i++) scanf("%d",&heap[i]); createHeap(); int k=n; while(k>=2){ x=heap[1]; swap(heap[1],heap[k]); downAdjust(1,--k); //不是downAdjust(heap[1],heap[--k])!!!!!,是对下标操作 y=heap[1]; swap(heap[1],heap[k]); downAdjust(1,k-1); heap[k]=x+y; upAdjust(1,k); ans+=x+y; } printf("%d\n",ans); return 0; } /* 3 1 2 9 */
6d4cad9c72aca2c421ea62a34a50d4231b31f0e2
df2d4fb830c1ce06498982b4e7c6fd8527219462
/usaco/2.4.4/2.4.4.cpp
1a0993be6b9535dc2f921f71fd753da23694600d
[]
no_license
WZSLYF/oi
bc1702b93b1ffd75fcfa5d43f386426ac933a176
2de469b2667c6b43dcddc2f7dec8c6ddf81903ff
refs/heads/master
2022-12-04T23:38:06.726839
2022-11-19T04:28:36
2022-11-19T04:28:36
196,857,905
0
0
null
null
null
null
UTF-8
C++
false
false
1,194
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 55; const int INF = 1e6; int dat[maxn][maxn]; bool isVis[maxn]; int P; int calc(char ch) { if(ch >= 'a' && ch <= 'z') return ch - 'a'; return ch - 'A' + 26; } int main() { scanf("%d", &P); for(int i = 0; i < maxn; ++i) { for(int j = 0; j < maxn; ++j) dat[i][j] = INF; } //char ch = getchar(); //while(ch != '\n') ch = getchar(); for(int i = 0; i < P; ++i) { char ch1, ch2; int val; scanf("\n%c %c %d", &ch1, &ch2, &val); //printf("%c %c %d\n", ch1, ch2, val); int a = calc(ch1), b = calc(ch2); dat[a][b] = min(dat[a][b], val); dat[b][a] = min(dat[b][a], val); //ch = getchar(); //while(ch != '\n') ch = getchar(); } for(int k = 0; k < maxn; ++k) { for(int i = 0; i < maxn; ++i) { for(int j = 0; j < maxn; ++j) if(dat[i][j] > dat[i][k] + dat[k][j]) dat[i][j] = dat[i][k] + dat[k][j]; } } int Min = INF, ind = 0; for(int i = 26; i < maxn; ++i) if(i != 51 && dat[51][i] < Min) Min = dat[51][i], ind = i; printf("%c %d\n", ind- 26 + 'A', Min); return 0; }
84284ba49491e6ee6fc0ebfe5ce3203101cf8fdd
36e96448fd52efc8186c7d94d07b6dca03ad0d1c
/find-replace-algorithm/BrutalFind.cpp
27e4cd3c3016db8df2a270a5a85b5f2fe23b6071
[]
no_license
shesl-meow/Tools
36de1214d7b50d76f0f2f1d59747c3e9065ec2c6
3b685305c9da6277e75fd598f2ad1edb572774a6
refs/heads/master
2020-03-10T12:12:22.884536
2019-04-25T08:57:50
2019-04-25T08:57:50
129,372,146
1
0
null
2019-03-31T15:26:11
2018-04-13T08:23:05
C
UTF-8
C++
false
false
1,129
cpp
#include "BrutalFind.h" std::vector<std::string::iterator> BrutalFind::FindIter()const { std::vector<std::string::iterator> result; for (auto iter=OriginStr->begin(); iter != OriginStr->end(); iter++) { auto it = iter, jt = PatternStr->begin(); while (jt != PatternStr->end()) if (*jt++ != *it++) break; if (jt == PatternStr->end()) result.push_back(iter); } return result; } std::vector<std::string::size_type> BrutalFind::FindIndex()const { std::vector<std::string::size_type> result; for (std::string::size_type iter = 0; iter < OriginStr->length(); ++iter) { std::string::size_type i = iter, j = 0; while (j < PatternLen) if (OriginStr->at(i++) != PatternStr->at(j++)) break; if (j >= PatternLen) result.push_back(iter); } return result; } void BrutalFind::ReplaceAll() { for (auto iter = OriginStr->begin(); iter != OriginStr->end(); iter++) { auto it = iter, jt = PatternStr->begin(); while (jt != PatternStr->end()) if (*jt++ != *it++) break; if (jt == PatternStr->end()) { OriginStr->replace(iter, iter + PatternLen, *this->ReplaceStr); iter = iter + ReplaceLen; } } }
6ecc49ac72d1b28f1f502c4b4c9aeec162be4cb3
81bb77804b2481a92c0d48ad2f76e5b79d29e9ec
/src/evm/libethereum/Transaction.cpp
bf8effcd2ddb6133e4b93fcb8177e3701b73770e
[ "MIT" ]
permissive
AndrewJEON/qtum
a5216a67c25e818b11266366f37d0b7bcf5a573f
5373115c4550a9dbd99f360dd50cc4f67722dc91
refs/heads/master
2021-06-11T16:50:00.126511
2017-03-14T17:12:40
2017-03-14T17:12:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,963
cpp
/* This file is part of cpp-ethereum. cpp-ethereum 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. cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. */ /** @file Transaction.cpp * @author Gav Wood <[email protected]> * @date 2014 */ #include <libdevcore/vector_ref.h> #include <libdevcore/Log.h> #include <libdevcore/CommonIO.h> #include <libdevcrypto/Common.h> #include <libethcore/Exceptions.h> #include <libevm/VMFace.h> //#include "Interface.h" #include "Transaction.h" using namespace std; using namespace dev; using namespace dev::eth; #define ETH_ADDRESS_DEBUG 0 std::ostream& dev::eth::operator<<(std::ostream& _out, ExecutionResult const& _er) { _out << "{" << _er.gasUsed << ", " << _er.newAddress << ", " << toHex(_er.output) << "}"; return _out; } TransactionException dev::eth::toTransactionException(Exception const& _e) { // Basic Transaction exceptions if (!!dynamic_cast<RLPException const*>(&_e)) return TransactionException::BadRLP; if (!!dynamic_cast<OutOfGasIntrinsic const*>(&_e)) return TransactionException::OutOfGasIntrinsic; if (!!dynamic_cast<InvalidSignature const*>(&_e)) return TransactionException::InvalidSignature; // Executive exceptions if (!!dynamic_cast<OutOfGasBase const*>(&_e)) return TransactionException::OutOfGasBase; if (!!dynamic_cast<InvalidNonce const*>(&_e)) return TransactionException::InvalidNonce; if (!!dynamic_cast<NotEnoughCash const*>(&_e)) return TransactionException::NotEnoughCash; if (!!dynamic_cast<BlockGasLimitReached const*>(&_e)) return TransactionException::BlockGasLimitReached; // VM execution exceptions if (!!dynamic_cast<BadInstruction const*>(&_e)) return TransactionException::BadInstruction; if (!!dynamic_cast<BadJumpDestination const*>(&_e)) return TransactionException::BadJumpDestination; if (!!dynamic_cast<OutOfGas const*>(&_e)) return TransactionException::OutOfGas; if (!!dynamic_cast<OutOfStack const*>(&_e)) return TransactionException::OutOfStack; if (!!dynamic_cast<StackUnderflow const*>(&_e)) return TransactionException::StackUnderflow; return TransactionException::Unknown; } std::ostream& dev::eth::operator<<(std::ostream& _out, TransactionException const& _er) { switch (_er) { case TransactionException::None: _out << "None"; break; case TransactionException::BadRLP: _out << "BadRLP"; break; case TransactionException::InvalidFormat: _out << "InvalidFormat"; break; case TransactionException::OutOfGasIntrinsic: _out << "OutOfGasIntrinsic"; break; case TransactionException::InvalidSignature: _out << "InvalidSignature"; break; case TransactionException::InvalidNonce: _out << "InvalidNonce"; break; case TransactionException::NotEnoughCash: _out << "NotEnoughCash"; break; case TransactionException::OutOfGasBase: _out << "OutOfGasBase"; break; case TransactionException::BlockGasLimitReached: _out << "BlockGasLimitReached"; break; case TransactionException::BadInstruction: _out << "BadInstruction"; break; case TransactionException::BadJumpDestination: _out << "BadJumpDestination"; break; case TransactionException::OutOfGas: _out << "OutOfGas"; break; case TransactionException::OutOfStack: _out << "OutOfStack"; break; case TransactionException::StackUnderflow: _out << "StackUnderflow"; break; default: _out << "Unknown"; break; } return _out; } Transaction::Transaction(bytesConstRef _rlpData, CheckTransaction _checkSig): TransactionBase(_rlpData, _checkSig) { }
d4c217474524f48cce81ec1f816d4c3f28b6877f
bb6ebff7a7f6140903d37905c350954ff6599091
/third_party/skia/src/gpu/GrBufferAllocPool.cpp
03d43c9b9328cdbbf9514197f2b3fd7f111035f4
[ "LGPL-2.0-or-later", "GPL-1.0-or-later", "MIT", "Apache-2.0", "BSD-3-Clause" ]
permissive
PDi-Communication-Systems-Inc/lollipop_external_chromium_org
faa6602bd6bfd9b9b6277ce3cd16df0bd26e7f2f
ccadf4e63dd34be157281f53fe213d09a8c66d2c
refs/heads/master
2022-12-23T18:07:04.568931
2016-04-11T16:03:36
2016-04-11T16:03:36
53,677,925
0
1
BSD-3-Clause
2022-12-09T23:46:46
2016-03-11T15:49:07
C++
UTF-8
C++
false
false
16,248
cpp
/* * Copyright 2010 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "GrBufferAllocPool.h" #include "GrDrawTargetCaps.h" #include "GrGpu.h" #include "GrIndexBuffer.h" #include "GrTypes.h" #include "GrVertexBuffer.h" #ifdef SK_DEBUG #define VALIDATE validate #else static void VALIDATE(bool = false) {} #endif // page size #define GrBufferAllocPool_MIN_BLOCK_SIZE ((size_t)1 << 12) GrBufferAllocPool::GrBufferAllocPool(GrGpu* gpu, BufferType bufferType, bool frequentResetHint, size_t blockSize, int preallocBufferCnt) : fBlocks(SkTMax(8, 2*preallocBufferCnt)) { SkASSERT(NULL != gpu); fGpu = gpu; fGpu->ref(); fGpuIsReffed = true; fBufferType = bufferType; fFrequentResetHint = frequentResetHint; fBufferPtr = NULL; fMinBlockSize = SkTMax(GrBufferAllocPool_MIN_BLOCK_SIZE, blockSize); fBytesInUse = 0; fPreallocBuffersInUse = 0; fPreallocBufferStartIdx = 0; for (int i = 0; i < preallocBufferCnt; ++i) { GrGeometryBuffer* buffer = this->createBuffer(fMinBlockSize); if (NULL != buffer) { *fPreallocBuffers.append() = buffer; } } } GrBufferAllocPool::~GrBufferAllocPool() { VALIDATE(); if (fBlocks.count()) { GrGeometryBuffer* buffer = fBlocks.back().fBuffer; if (buffer->isMapped()) { buffer->unmap(); } } while (!fBlocks.empty()) { destroyBlock(); } fPreallocBuffers.unrefAll(); releaseGpuRef(); } void GrBufferAllocPool::releaseGpuRef() { if (fGpuIsReffed) { fGpu->unref(); fGpuIsReffed = false; } } void GrBufferAllocPool::reset() { VALIDATE(); fBytesInUse = 0; if (fBlocks.count()) { GrGeometryBuffer* buffer = fBlocks.back().fBuffer; if (buffer->isMapped()) { buffer->unmap(); } } // fPreallocBuffersInUse will be decremented down to zero in the while loop int preallocBuffersInUse = fPreallocBuffersInUse; while (!fBlocks.empty()) { this->destroyBlock(); } if (fPreallocBuffers.count()) { // must set this after above loop. fPreallocBufferStartIdx = (fPreallocBufferStartIdx + preallocBuffersInUse) % fPreallocBuffers.count(); } // we may have created a large cpu mirror of a large VB. Reset the size // to match our pre-allocated VBs. fCpuData.reset(fMinBlockSize); SkASSERT(0 == fPreallocBuffersInUse); VALIDATE(); } void GrBufferAllocPool::unmap() { VALIDATE(); if (NULL != fBufferPtr) { BufferBlock& block = fBlocks.back(); if (block.fBuffer->isMapped()) { block.fBuffer->unmap(); } else { size_t flushSize = block.fBuffer->gpuMemorySize() - block.fBytesFree; this->flushCpuData(fBlocks.back().fBuffer, flushSize); } fBufferPtr = NULL; } VALIDATE(); } #ifdef SK_DEBUG void GrBufferAllocPool::validate(bool unusedBlockAllowed) const { if (NULL != fBufferPtr) { SkASSERT(!fBlocks.empty()); if (fBlocks.back().fBuffer->isMapped()) { GrGeometryBuffer* buf = fBlocks.back().fBuffer; SkASSERT(buf->mapPtr() == fBufferPtr); } else { SkASSERT(fCpuData.get() == fBufferPtr); } } else { SkASSERT(fBlocks.empty() || !fBlocks.back().fBuffer->isMapped()); } size_t bytesInUse = 0; for (int i = 0; i < fBlocks.count() - 1; ++i) { SkASSERT(!fBlocks[i].fBuffer->isMapped()); } for (int i = 0; i < fBlocks.count(); ++i) { size_t bytes = fBlocks[i].fBuffer->gpuMemorySize() - fBlocks[i].fBytesFree; bytesInUse += bytes; SkASSERT(bytes || unusedBlockAllowed); } SkASSERT(bytesInUse == fBytesInUse); if (unusedBlockAllowed) { SkASSERT((fBytesInUse && !fBlocks.empty()) || (!fBytesInUse && (fBlocks.count() < 2))); } else { SkASSERT((0 == fBytesInUse) == fBlocks.empty()); } } #endif void* GrBufferAllocPool::makeSpace(size_t size, size_t alignment, const GrGeometryBuffer** buffer, size_t* offset) { VALIDATE(); SkASSERT(NULL != buffer); SkASSERT(NULL != offset); if (NULL != fBufferPtr) { BufferBlock& back = fBlocks.back(); size_t usedBytes = back.fBuffer->gpuMemorySize() - back.fBytesFree; size_t pad = GrSizeAlignUpPad(usedBytes, alignment); if ((size + pad) <= back.fBytesFree) { usedBytes += pad; *offset = usedBytes; *buffer = back.fBuffer; back.fBytesFree -= size + pad; fBytesInUse += size + pad; VALIDATE(); return (void*)(reinterpret_cast<intptr_t>(fBufferPtr) + usedBytes); } } // We could honor the space request using by a partial update of the current // VB (if there is room). But we don't currently use draw calls to GL that // allow the driver to know that previously issued draws won't read from // the part of the buffer we update. Also, the GL buffer implementation // may be cheating on the actual buffer size by shrinking the buffer on // updateData() if the amount of data passed is less than the full buffer // size. if (!createBlock(size)) { return NULL; } SkASSERT(NULL != fBufferPtr); *offset = 0; BufferBlock& back = fBlocks.back(); *buffer = back.fBuffer; back.fBytesFree -= size; fBytesInUse += size; VALIDATE(); return fBufferPtr; } int GrBufferAllocPool::currentBufferItems(size_t itemSize) const { VALIDATE(); if (NULL != fBufferPtr) { const BufferBlock& back = fBlocks.back(); size_t usedBytes = back.fBuffer->gpuMemorySize() - back.fBytesFree; size_t pad = GrSizeAlignUpPad(usedBytes, itemSize); return static_cast<int>((back.fBytesFree - pad) / itemSize); } else if (fPreallocBuffersInUse < fPreallocBuffers.count()) { return static_cast<int>(fMinBlockSize / itemSize); } return 0; } int GrBufferAllocPool::preallocatedBuffersRemaining() const { return fPreallocBuffers.count() - fPreallocBuffersInUse; } int GrBufferAllocPool::preallocatedBufferCount() const { return fPreallocBuffers.count(); } void GrBufferAllocPool::putBack(size_t bytes) { VALIDATE(); // if the putBack unwinds all the preallocated buffers then we will // advance the starting index. As blocks are destroyed fPreallocBuffersInUse // will be decremented. I will reach zero if all blocks using preallocated // buffers are released. int preallocBuffersInUse = fPreallocBuffersInUse; while (bytes) { // caller shouldnt try to put back more than they've taken SkASSERT(!fBlocks.empty()); BufferBlock& block = fBlocks.back(); size_t bytesUsed = block.fBuffer->gpuMemorySize() - block.fBytesFree; if (bytes >= bytesUsed) { bytes -= bytesUsed; fBytesInUse -= bytesUsed; // if we locked a vb to satisfy the make space and we're releasing // beyond it, then unmap it. if (block.fBuffer->isMapped()) { block.fBuffer->unmap(); } this->destroyBlock(); } else { block.fBytesFree += bytes; fBytesInUse -= bytes; bytes = 0; break; } } if (!fPreallocBuffersInUse && fPreallocBuffers.count()) { fPreallocBufferStartIdx = (fPreallocBufferStartIdx + preallocBuffersInUse) % fPreallocBuffers.count(); } VALIDATE(); } bool GrBufferAllocPool::createBlock(size_t requestSize) { size_t size = SkTMax(requestSize, fMinBlockSize); SkASSERT(size >= GrBufferAllocPool_MIN_BLOCK_SIZE); VALIDATE(); BufferBlock& block = fBlocks.push_back(); if (size == fMinBlockSize && fPreallocBuffersInUse < fPreallocBuffers.count()) { uint32_t nextBuffer = (fPreallocBuffersInUse + fPreallocBufferStartIdx) % fPreallocBuffers.count(); block.fBuffer = fPreallocBuffers[nextBuffer]; block.fBuffer->ref(); ++fPreallocBuffersInUse; } else { block.fBuffer = this->createBuffer(size); if (NULL == block.fBuffer) { fBlocks.pop_back(); return false; } } block.fBytesFree = size; if (NULL != fBufferPtr) { SkASSERT(fBlocks.count() > 1); BufferBlock& prev = fBlocks.fromBack(1); if (prev.fBuffer->isMapped()) { prev.fBuffer->unmap(); } else { flushCpuData(prev.fBuffer, prev.fBuffer->gpuMemorySize() - prev.fBytesFree); } fBufferPtr = NULL; } SkASSERT(NULL == fBufferPtr); // If the buffer is CPU-backed we map it because it is free to do so and saves a copy. // Otherwise when buffer mapping is supported: // a) If the frequently reset hint is set we only map when the requested size meets a // threshold (since we don't expect it is likely that we will see more vertex data) // b) If the hint is not set we map if the buffer size is greater than the threshold. bool attemptMap = block.fBuffer->isCPUBacked(); if (!attemptMap && GrDrawTargetCaps::kNone_MapFlags != fGpu->caps()->mapBufferFlags()) { if (fFrequentResetHint) { attemptMap = requestSize > GR_GEOM_BUFFER_MAP_THRESHOLD; } else { attemptMap = size > GR_GEOM_BUFFER_MAP_THRESHOLD; } } if (attemptMap) { fBufferPtr = block.fBuffer->map(); } if (NULL == fBufferPtr) { fBufferPtr = fCpuData.reset(size); } VALIDATE(true); return true; } void GrBufferAllocPool::destroyBlock() { SkASSERT(!fBlocks.empty()); BufferBlock& block = fBlocks.back(); if (fPreallocBuffersInUse > 0) { uint32_t prevPreallocBuffer = (fPreallocBuffersInUse + fPreallocBufferStartIdx + (fPreallocBuffers.count() - 1)) % fPreallocBuffers.count(); if (block.fBuffer == fPreallocBuffers[prevPreallocBuffer]) { --fPreallocBuffersInUse; } } SkASSERT(!block.fBuffer->isMapped()); block.fBuffer->unref(); fBlocks.pop_back(); fBufferPtr = NULL; } void GrBufferAllocPool::flushCpuData(GrGeometryBuffer* buffer, size_t flushSize) { SkASSERT(NULL != buffer); SkASSERT(!buffer->isMapped()); SkASSERT(fCpuData.get() == fBufferPtr); SkASSERT(flushSize <= buffer->gpuMemorySize()); VALIDATE(true); if (GrDrawTargetCaps::kNone_MapFlags != fGpu->caps()->mapBufferFlags() && flushSize > GR_GEOM_BUFFER_MAP_THRESHOLD) { void* data = buffer->map(); if (NULL != data) { memcpy(data, fBufferPtr, flushSize); buffer->unmap(); return; } } buffer->updateData(fBufferPtr, flushSize); VALIDATE(true); } GrGeometryBuffer* GrBufferAllocPool::createBuffer(size_t size) { if (kIndex_BufferType == fBufferType) { return fGpu->createIndexBuffer(size, true); } else { SkASSERT(kVertex_BufferType == fBufferType); return fGpu->createVertexBuffer(size, true); } } //////////////////////////////////////////////////////////////////////////////// GrVertexBufferAllocPool::GrVertexBufferAllocPool(GrGpu* gpu, bool frequentResetHint, size_t bufferSize, int preallocBufferCnt) : GrBufferAllocPool(gpu, kVertex_BufferType, frequentResetHint, bufferSize, preallocBufferCnt) { } void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize, int vertexCount, const GrVertexBuffer** buffer, int* startVertex) { SkASSERT(vertexCount >= 0); SkASSERT(NULL != buffer); SkASSERT(NULL != startVertex); size_t offset = 0; // assign to suppress warning const GrGeometryBuffer* geomBuffer = NULL; // assign to suppress warning void* ptr = INHERITED::makeSpace(vertexSize * vertexCount, vertexSize, &geomBuffer, &offset); *buffer = (const GrVertexBuffer*) geomBuffer; SkASSERT(0 == offset % vertexSize); *startVertex = static_cast<int>(offset / vertexSize); return ptr; } bool GrVertexBufferAllocPool::appendVertices(size_t vertexSize, int vertexCount, const void* vertices, const GrVertexBuffer** buffer, int* startVertex) { void* space = makeSpace(vertexSize, vertexCount, buffer, startVertex); if (NULL != space) { memcpy(space, vertices, vertexSize * vertexCount); return true; } else { return false; } } int GrVertexBufferAllocPool::preallocatedBufferVertices(size_t vertexSize) const { return static_cast<int>(INHERITED::preallocatedBufferSize() / vertexSize); } int GrVertexBufferAllocPool::currentBufferVertices(size_t vertexSize) const { return currentBufferItems(vertexSize); } //////////////////////////////////////////////////////////////////////////////// GrIndexBufferAllocPool::GrIndexBufferAllocPool(GrGpu* gpu, bool frequentResetHint, size_t bufferSize, int preallocBufferCnt) : GrBufferAllocPool(gpu, kIndex_BufferType, frequentResetHint, bufferSize, preallocBufferCnt) { } void* GrIndexBufferAllocPool::makeSpace(int indexCount, const GrIndexBuffer** buffer, int* startIndex) { SkASSERT(indexCount >= 0); SkASSERT(NULL != buffer); SkASSERT(NULL != startIndex); size_t offset = 0; // assign to suppress warning const GrGeometryBuffer* geomBuffer = NULL; // assign to suppress warning void* ptr = INHERITED::makeSpace(indexCount * sizeof(uint16_t), sizeof(uint16_t), &geomBuffer, &offset); *buffer = (const GrIndexBuffer*) geomBuffer; SkASSERT(0 == offset % sizeof(uint16_t)); *startIndex = static_cast<int>(offset / sizeof(uint16_t)); return ptr; } bool GrIndexBufferAllocPool::appendIndices(int indexCount, const void* indices, const GrIndexBuffer** buffer, int* startIndex) { void* space = makeSpace(indexCount, buffer, startIndex); if (NULL != space) { memcpy(space, indices, sizeof(uint16_t) * indexCount); return true; } else { return false; } } int GrIndexBufferAllocPool::preallocatedBufferIndices() const { return static_cast<int>(INHERITED::preallocatedBufferSize() / sizeof(uint16_t)); } int GrIndexBufferAllocPool::currentBufferIndices() const { return currentBufferItems(sizeof(uint16_t)); }
600eec03056c46b03aff4f5c0b7d40d9ac083ea7
53e8ee333251f323ce53cea47ba3aeeab096cf7f
/include/zapi/ds/ArrayItemProxy.h
4e622d5a9493c935cbe27c45595bf397f7bba483
[ "Apache-2.0" ]
permissive
Shies/zendapi
aa6fd11c6b8e746d81d412364119e4b803575ab7
815e8ba4532b9318d28d84320ecef0426344d350
refs/heads/master
2021-06-28T13:52:58.481938
2017-09-12T15:32:35
2017-09-12T15:32:35
103,348,899
2
2
null
2017-09-13T03:30:03
2017-09-13T03:30:03
null
UTF-8
C++
false
false
4,703
h
// Copyright 2017-2018 zzu_softboy <[email protected]> // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Created by softboy on 2017/08/15. #ifndef ZAPI_DS_INTERNAL_ARRAY_ITEM_PROXY_H #define ZAPI_DS_INTERNAL_ARRAY_ITEM_PROXY_H #include "zapi/Global.h" // forward declare with namespace namespace zapi { namespace ds { namespace internal { class ArrayItemProxyPrivate; } // internal class ArrayItemProxy; class Variant; class NumericVariant; class DoubleVariant; class StringVariant; class BoolVariant; class ArrayVariant; using internal::ArrayItemProxyPrivate; using zapi::lang::Type; } // ds extern bool array_unset(ds::ArrayItemProxy &&arrayItem); extern bool array_isset(ds::ArrayItemProxy &&arrayItem); } // zapi // end forward declare namespace zapi { namespace ds { class ZAPI_DECL_EXPORT ArrayItemProxy final { public: using KeyType = std::pair<zapi_ulong, std::shared_ptr<std::string>>; public: ArrayItemProxy(zval *array, const KeyType &requestKey, ArrayItemProxy *parent = nullptr); ArrayItemProxy(zval *array, const std::string &key, ArrayItemProxy *parent = nullptr); ArrayItemProxy(zval *array, zapi_ulong index, ArrayItemProxy *parent = nullptr); ArrayItemProxy(const ArrayItemProxy &other); // shadow copy ArrayItemProxy(ArrayItemProxy &&other) ZAPI_DECL_NOEXCEPT; ~ArrayItemProxy(); // operators ArrayItemProxy &operator =(const ArrayItemProxy &other); ArrayItemProxy &operator =(ArrayItemProxy &&other) ZAPI_DECL_NOEXCEPT; ArrayItemProxy &operator =(const Variant &value); ArrayItemProxy &operator =(const NumericVariant &value); ArrayItemProxy &operator =(const DoubleVariant &value); ArrayItemProxy &operator =(const StringVariant &value); ArrayItemProxy &operator =(const BoolVariant &value); ArrayItemProxy &operator =(const ArrayVariant &value); ArrayItemProxy &operator =(NumericVariant &&value); ArrayItemProxy &operator =(DoubleVariant &&value); ArrayItemProxy &operator =(StringVariant &&value); ArrayItemProxy &operator =(BoolVariant &&value); ArrayItemProxy &operator =(ArrayVariant &&value); ArrayItemProxy &operator =(const char *value); ArrayItemProxy &operator =(const char value); ArrayItemProxy &operator =(const std::string &value); template <typename T, typename Selector = typename std::enable_if<std::is_arithmetic<T>::value>::type> ArrayItemProxy &operator =(T value); template <size_t arrayLength> ArrayItemProxy &operator =(char (&value)[arrayLength]); // cast operators operator Variant(); operator NumericVariant(); operator DoubleVariant(); operator StringVariant(); operator BoolVariant(); operator ArrayVariant(); Variant toVariant(); NumericVariant toNumericVariant(); DoubleVariant toDoubleVariant(); StringVariant toStringVariant(); BoolVariant toBoolVariant(); ArrayVariant toArrayVariant(); // nest assign ArrayItemProxy operator [](zapi_long index); ArrayItemProxy operator [](const std::string &key); protected: bool ensureArrayExistRecusive(zval *&childArrayPtr, const KeyType &childRequestKey, ArrayItemProxy *mostDerivedProxy); void checkExistRecursive(bool &stop, zval *&checkExistRecursive, ArrayItemProxy *mostDerivedProxy, bool quiet = false); bool isKeychianOk(bool quiet = false); zval *retrieveZvalPtr(bool quiet = false) const; protected: friend bool zapi::array_unset(ArrayItemProxy &&arrayItem); friend bool zapi::array_isset(ds::ArrayItemProxy &&arrayItem); ZAPI_DECLARE_PRIVATE(ArrayItemProxy) std::shared_ptr<ArrayItemProxyPrivate> m_implPtr; }; template <typename T, typename Selector> ArrayItemProxy &ArrayItemProxy::operator =(T value) { return operator =(Variant(value)); } template <size_t arrayLength> ArrayItemProxy &ArrayItemProxy::operator =(char (&value)[arrayLength]) { return operator =(Variant(value)); } } // ds } // zapi #endif // ZAPI_DS_INTERNAL_ARRAY_ITEM_PROXY_H
1aa2d38d8d36da67159b7621452018451d88adfa
f9376571d54d2d3aa54505aa863ed452a0140558
/sparseRRT/src/display_trajectory.cpp
79378aaf0ffd6dee0de47700524e2a258f3ee7f7
[]
no_license
gnunoe/Cf_ROS
f63ddc45655caa5d332a4a61e789aa23399d000a
7299bef22bd853d41326f7e45865782f2fb549f9
refs/heads/master
2021-01-21T14:01:17.355897
2015-06-26T18:59:09
2015-06-26T18:59:09
38,109,928
0
1
null
null
null
null
UTF-8
C++
false
false
6,196
cpp
#include <ros/ros.h> //#include <ros/console.h> #include <visualization_msgs/Marker.h> #include <visualization_msgs/MarkerArray.h> #include <geometry_msgs/Point.h> #include <cstdlib> #include <cmath> #include <iostream> #include <fstream> #include <sstream> #include <vector> #include <stdio.h> #include <stdlib.h> #include "std_msgs/MultiArrayLayout.h" #include "std_msgs/MultiArrayDimension.h" #include "std_msgs/Float64MultiArray.h" #include <geometry_msgs/PoseStamped.h> using namespace std; int main( int argc, char** argv ) { ros::init(argc, argv, "display_trajectory"); ros::NodeHandle n; std::string path_file = argv[1]; std::string name_file = argv[2]; //-----------------------ROS STUFF-----------------------------// //Create Publisher for RVIZ ros::Publisher marker_array_pub = n.advertise<visualization_msgs::MarkerArray>("trajectory", 10); bool publish = false; int count = 0; double ** traj; int n_elements = 12; int n_rows = 0; int array_index = 0; //Open the file //ROS_INFO_STREAM("opening file..."); std::string command = path_file + name_file; ifstream myFile(command.c_str()); //ifstream myFile ("/home/estevez/catkin_ws/src/sparseRRT/bin/trajectory.csv"); if (! myFile.is_open()) { ROS_INFO_STREAM("Could not open the file!"); return 1; } //get number of lines std::string line; while (std::getline(myFile,line)) { ++ n_rows; } //Reset buffer and point to the beginning of the document myFile.clear(); myFile.seekg(0,ios::beg); //Save all the values in a vector std::vector<double> array; std::string val; double d_val; while (myFile.good()) { getline(myFile,val,','); d_val = atof(val.c_str()); array.push_back(d_val); } //And close file //ROS_INFO_STREAM("closing file..."); myFile.close(); //Allocate matrix to sort the numbers traj = new double*[n_rows]; for (int i=0; i<n_rows; i++) { traj[i] = new double [n_elements]; } //And sort the vector in a 2D array for (int i=0; i<n_rows; i++) { for (int j=0; j<n_elements; j++) { traj[i][j] = array[array_index]; array_index ++; } } /* //Finally display the array for (int i=0; i<n_rows; i++) { for (int j=0; j<n_elements; j++) { cout << traj[i][j] <<" "; } cout << "\n"; } */ ros::Rate r(1); while (ros::ok() && !publish){ //Create messages for Publishers visualization_msgs::MarkerArray ma; visualization_msgs::Marker points; //visualization_msgs::Marker arrow; //VISUALIZATION POINTS //Fill marker_msgs fields necessary for the representation points.header.frame_id = "/mocap"; points.header.stamp = ros::Time::now(); points.ns = "trajectory_mocap"; points.action = visualization_msgs::Marker::ADD; //each figure one unique id points.id = 2; points.type = visualization_msgs::Marker::POINTS; // Cubes are grey points.color.r = 1.0f; points.color.g = 0.5; points.color.b = 0.5; points.color.a = 1.0f; //Fixed orientation points.pose.orientation.x = 0.0; points.pose.orientation.y = 0.0; points.pose.orientation.z = 0.0; points.pose.orientation.w = 1.0; //and fixed scale points.scale.x = 0.05; points.scale.y = 0.05; /* //VISUALIZATION ARROW //Fill marker_msgs fields necessary for the representation arrow.header.frame_id = "/mocap"; arrow.header.stamp = ros::Time::now(); arrow.ns = "trajectory_mocap"; arrow.action = visualization_msgs::Marker::ADD; //each figure one unique id arrow.id = 3; arrow.type = visualization_msgs::Marker::ARROW; // Cubes are grey arrow.color.r = 1.0; arrow.color.g = 0.0; arrow.color.b = 0.0; arrow.color.a = 1.0; //Fixed orientation //arrow.pose.orientation.x = 0.0; //arrow.pose.orientation.y = 0.0; //arrow.pose.orientation.z = 0.0; //arrow.pose.orientation.w = 1.0; //and fixed scale arrow.scale.x = 0.05; arrow.scale.y = 0.05; arrow.scale.z = 0.05; */ for (int i=0;i<n_rows;i++) { geometry_msgs::Point p; p.x = traj[i][0]; p.y = traj[i][1]; p.z = traj[i][2]; points.points.push_back(p); //arrow.points.push_back(p); //geometry_msgs::Point pp; //pp.x = traj[i][0] + traj[i][3]; //pp.y = traj[i][1] + traj[i][4]; //pp.z = traj[i][2] + traj[i][5]; //arrow.points.push_back(pp); //ma.markers.push_back(arrow); //marker_array_pub.publish(ma); //arrow.id ++; } ma.markers.push_back(points); //ma.markers.push_back(arrow); marker_array_pub.publish(ma); for (int i=1;i<n_rows-1;i++) { visualization_msgs::Marker arrow; //VISUALIZATION ARROW //Fill marker_msgs fields necessary for the representation arrow.header.frame_id = "/mocap"; arrow.header.stamp = ros::Time::now(); arrow.ns = "trajectory_mocap"; arrow.action = visualization_msgs::Marker::ADD; //each figure one unique id arrow.id =i+ 3; arrow.type = visualization_msgs::Marker::ARROW; // Cubes are grey arrow.color.r = 1.0; arrow.color.g = 0.0; arrow.color.b = 0.0; arrow.color.a = 1.0; //Fixed orientation //arrow.pose.orientation.x = 0.0; //arrow.pose.orientation.y = 0.0; //arrow.pose.orientation.z = 0.0; //arrow.pose.orientation.w = 1.0; //and fixed scale arrow.scale.x = 0.01; arrow.scale.y = 0.03; arrow.scale.z = 0.08; geometry_msgs::Point ps; geometry_msgs::Point pg; ps.x = traj[i][0]; ps.y = traj[i][1]; ps.z = traj[i][2]; pg.x = (traj[i][0]+traj[i][3]/6); pg.y = (traj[i][1]+traj[i][4]/6); pg.z = (traj[i][2]+traj[i][5]/6); arrow.points.push_back(ps); arrow.points.push_back(pg); ma.markers.push_back(arrow); marker_array_pub.publish(ma); } //ma.markers.push_back(arrow); //ma.markers.push_back(arrow); //marker_array_pub.publish(ma); count ++; if (count == 3) { publish = true; } r.sleep(); } }
64a425a594640ac4757ce7f79bafd0526eda3ae6
62678b50ddb1fcda4f8561d73667852220463632
/Source Code/06_parameters/06_03.cpp
ad16e5f98b9947acece0ed28c8293bd175143077
[ "MIT" ]
permissive
rushone2010/CS_A150
3979a78a1f0774b5a3e999a3abcbcb34cf50d351
0acab19e69c051f67b8dafe904ca77de0431958d
refs/heads/master
2021-01-22T10:36:00.742028
2017-03-17T20:05:11
2017-03-17T20:05:11
82,015,810
2
0
null
null
null
null
UTF-8
C++
false
false
2,528
cpp
// Determines which of two pizza sizes is the best buy. #include <iostream> using namespace std; const double PI = 3.14159; void getData(int& smallDiameter, double& priceSmall, int& largeDiameter, double& priceLarge); double unitPrice(int diameter, double price); //Returns the price per square inch of a pizza. //Precondition: The diameter parameter is the diameter of the pizza //in inches. The price parameter is the price of the pizza. void outputResults(int smallDiameter, double priceSmall, int largeDiameter, double priceLarge); int main() { int diameterSmall, diameterLarge; double priceSmall, priceLarge; getData(diameterSmall, priceSmall, diameterLarge, priceLarge); outputResults(diameterSmall, priceSmall, diameterLarge, priceLarge); cout << endl; cin.ignore(); cin.get(); return 0; } void getData(int& smallDiameter, double& priceSmall, int& largeDiameter, double& priceLarge) { cout << "Welcome to the Pizza Consumers Union.\n"; cout << "\nEnter diameter of a small pizza (in inches): "; cin >> smallDiameter; cout << "Enter the price of a small pizza: $"; cin >> priceSmall; cout << "\nEnter diameter of a large pizza (in inches): "; cin >> largeDiameter; cout << "Enter the price of a large pizza: $"; cin >> priceLarge; } void outputResults(int smallDiameter, double priceSmall, int largeDiameter, double priceLarge) { double unitPriceSmall = unitPrice(smallDiameter, priceSmall); double unitPriceLarge = unitPrice(largeDiameter, priceLarge); cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << "\nSmall pizza:\n" << " Diameter = " << smallDiameter << " inches\n" << " Price = $" << priceSmall << " per square inch = $" << unitPriceSmall << endl << "\nLarge pizza:\n" << " Diameter = " << largeDiameter << " inches\n" << " Price = $" << priceLarge << " per square inch = $" << unitPriceLarge << endl; if (unitPriceLarge < unitPriceSmall) cout << "\nThe large one is the better buy.\n"; else cout << "\nThe small one is the better buy.\n"; cout << "\nBuon Appetito!\n"; } double unitPrice(int diameter, double price) { // the radius is half the diameter double radius = diameter / 2.0; double area = PI * radius * radius; return (price / area); }
57b8142830644ee7f37716e2a4c439b5d9d045d1
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
/NT/admin/wmi/wbem/winmgmt/stdprov/crc32.cpp
87f99a2717191b0f0d47cbb118915d3be5d78b32
[]
no_license
jjzhang166/WinNT5_src_20201004
712894fcf94fb82c49e5cd09d719da00740e0436
b2db264153b80fbb91ef5fc9f57b387e223dbfc2
refs/heads/Win2K3
2023-08-12T01:31:59.670176
2021-10-14T15:14:37
2021-10-14T15:14:37
586,134,273
1
0
null
2023-01-07T03:47:45
2023-01-07T03:47:44
null
UTF-8
C++
false
false
4,605
cpp
/*++ Copyright (C) 1997-2001 Microsoft Corporation Module Name: CRC32.CPP Abstract: Standard CRC-32 implementation History: raymcc 07-Jul-97 Createada --*/ #include "precomp.h" #include <stdio.h> #include <crc32.h> static DWORD CrcTable[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; DWORD UpdateCRC32( LPBYTE pSrc, // Points to buffer int nBytes, // Number of bytes to compute DWORD dwOldCrc // Must be 0xFFFFFFFF if no previous CRC ) { if(nBytes == 0) return dwOldCrc; DWORD dwNewCrc = 0; for (int n = 0; n < nBytes; n++) { dwNewCrc = CrcTable[ BYTE(dwOldCrc ^ DWORD(pSrc[n]))] ^ ((dwOldCrc >> 8) & 0x00FFFFFF); dwOldCrc = dwNewCrc; } return dwNewCrc; } /* void main(int argc, char **argv) { if (argc < 2) { return; } FILE *f = fopen(argv[1], "rb"); DWORD dwCrc = STARTING_CRC32_VALUE; int nBytes = 0; while (1) { BYTE Buf[256]; int nRes = fread(Buf, 1, 256, f); nBytes += nRes; if (nRes == 0) break; if (nRes != 0) { dwCrc = UpdateCRC32(Buf, nRes, dwCrc); } } FINALIZE_CRC32(dwCrc); fclose(f); printf("Bytes = %d\n", nBytes); printf("CRC32 is 0x%X\n", dwCrc); } */
588548a1db1541d74665df22b52226f4b386a00a
7061d9e82a8d614a376fd33eae77c6b16b1ff4b1
/Calendar.cpp
ac828d3e9f8f34c035851bce46333030d2287c44
[]
no_license
geekgeekvm/Calendar
abbe1a7c0031064a42c39b8d2d2c50c6292064c8
90ce66eb748ae800734dd457054694d8b7bd77f1
refs/heads/master
2021-07-08T10:36:42.317620
2017-10-09T05:25:11
2017-10-09T05:25:11
106,239,742
0
0
null
null
null
null
UTF-8
C++
false
false
29,884
cpp
#include<stdio.h> #include<time.h> #include<iostream.h> #include<conio.h> #include<process.h> #include<string.h> #include<ctype.h> #include<graphics.h> #include<fstream.h> #include<stdlib.h> #include<dos.h> void today(); void mainscreen(); void dispcalendar(); void options(); void dispmonth(); int pass(); fstream file; class event { public: char month[10]; int date; char name[200]; void getdata(char [],int); void putdata(); void modify(); void Delete(); }; void event::getdata(char m[], int mn) { strcpy(month,m); int dc = 0; while(dc == 0) { cout<<"Enter the date:"; cin>>date; if(mn == 1 && date>=1 && date<=31) { dc =1; break; } else if(mn ==2 && date>=1 && date<=29) { dc = 1; break; } else if(mn == 3 && date >=1 && date<=31) { dc=1; break; } else if(mn == 4 && date>=1 && date<=30) { dc = 1; break; } else if(mn == 5 && date>=1 && date<=31) { dc = 1; break; } else if(mn == 6 && date>=1 && date<=30) { dc = 1; break; } else if(mn == 7 && date>=1 && date<=31) { dc = 1; break; } else if(mn == 8 && date>=1 && date<=31) { dc =1; break; } else if(mn == 9 && date>=1 && date<=30) { dc = 1; break; } else if(mn == 10 && date>=1 && date<=31) { dc = 1; break; } else if(mn == 11 && date>1 && date<=30) { dc = 1; break; } else if(mn == 12 && date>1 && date<=31) { dc = 1; break; } else { cout<<"INVALID DATE. ENTER AGAIN: "<<endl; dc = 0; } } cout<<"Enter event:"; gets(name); } void event::putdata() { cout<<"Month is:"<<month<<endl; cout<<"Date is:"<<date<<endl; cout<<"Event:"<<name<<endl; } void event::Delete() { clrscr(); event ev; cout<<"All Events"<<endl<<endl; fstream file("event.txt",ios::in|ios::binary); while(!file.eof()) { file.read((char *)& ev, sizeof(ev)); if(file.eof()) break; ev.putdata(); } file.close(); char n[10]; int md, dd; event e; fstream efile; fstream dfile; dm: cout<<"Enter the month to delete record:(1 to 12) "; cin>>md; if(cin.fail()) { cout<<"Invalid option entered!"<<endl; cin.clear(); cin.ignore(); delay(2000); clrscr(); goto dm; } ddate: cout<<"Enter the date to delete: "; cin>>dd; if(cin.fail()) { cout<<"Invalid option entered!"<<endl; cin.clear(); cin.ignore(); delay(2000); clrscr(); goto ddate; } if((md == 1) && (dd>=1) && (dd<=31)) strcpy(n, "JANUARY"); else if((md == 2) && (dd>=1) && (dd<=28)) strcpy(n, "FEBRUARY"); else if((md == 3) && (dd>=1) && (dd<=31)) strcpy(n,"MARCH"); else if((md == 4) && (dd>=1) && (dd<=30)) strcpy(n, "APRIL"); else if((md == 5) && (dd>=1) && (dd<=31)) strcpy(n, "MAY"); else if((md == 6) && (dd>=1) && (dd<=30)) strcpy(n, "JUNE"); else if((md == 7) && (dd>=1) && (dd<=31)) strcpy(n, "JULY"); else if((md == 8) && (dd>=1) && (dd<=31)) strcpy(n,"AUGUST"); else if((md == 9) && (dd>=1) && (dd<=30)) strcpy(n,"SEPTEMBER"); else if((md == 10)&& (dd>=1) && (dd<=31)) strcpy(n,"OCTOBER"); else if((md == 11)&&(dd>=1) && (dd<=30)) strcpy(n, "NOVEMBER"); else if((md == 12)&&(dd>=1) && (dd<31)) strcpy(n,"DECEMBER"); else cout<<"INVALID ENTRY. CANNOT DELETE THE RECORD. "; dfile.open("new.dat",ios::out|ios::binary); efile.open("event.txt",ios::in|ios::binary); if(!efile) { cout<<"File not found"; exit(0); } else { int found=0; efile.read((char *) &e, sizeof(e)); while(!efile.eof()) { if(dd == e.date && strcmp(n, e.month)==0 ) { found=1; cout<<"Press any key...:"<<endl; getch(); } else { dfile.write((char *)&e, sizeof(e)); } efile.read((char *)&e,sizeof(e)); } if(found==0) cout<<" Event not found."<<endl; else cout<<"Event Deleted."<<endl; } dfile.close(); efile.close(); remove("event.txt"); rename("new.dat", "event.txt"); } void event::modify() { clrscr(); /*event e1; cout<<"All Events"<<endl<<endl; fstream file("event.txt",ios::in|ios::binary); while(!file.eof()) { file.read((char *)& e1, sizeof(e1)); if(file.eof()) break; e1.putdata(); } file.close(); */ char mm[50]; strcpy(mm,month); int dd=date; cout<<"Event being modified:"<<endl; cout<<"Month:"<<month<<endl; cout<<"Date:"<<date<<endl; cout<<"Event:"<<name<<endl<<endl; cout<<"Enter new details:"<<endl; char ev[30]; int mon,day,temp=0; cout<<"New month(press'0' to retain old one)"<<endl; cin>>mon; cout<<"New date(press '0' to retain old one)"<<endl; cin>>day; cout<<"New event name(press '0' to retain old one)"<<endl; gets(ev); if(mon!=0) { if((mon == 1) && (day>=0) && (day<=31)) strcpy(month, "JANUARY"); else if((mon == 2) && (day>=0) && (day<=28)) strcpy(month, "FEBRUARY"); else if((mon == 3) && (day>=0) && (day<=31)) strcpy(month, "MARCH"); else if((mon == 4) && (day>=0) && (day<=30)) strcpy(month, "APRIL"); else if((mon == 5) && (day>=0) && (day<=31)) strcpy(month, "MAY"); else if((mon == 6) && (day>=0) && (day<=30)) strcpy(month, "JUNE"); else if((mon == 7) && (day>=0) && (day<=31)) strcpy(month, "JULY"); else if((mon == 8) && (day>=0) && (day<=31)) strcpy(month,"AUGUST"); else if((mon == 9) && (day>=0) && (day<=30)) strcpy(month,"SEPTEMBER"); else if((mon == 10)&& (day>=0) && (day<=31)) strcpy(month,"OCTOBER"); else if((mon == 11)&& (day>=0) && (day<=30)) strcpy(month, "NOVEMBER"); else if((mon == 12)&& (day>=0) && (day<=31)) strcpy(month,"DECEMBER"); else { temp=1; cout<<"INVALID ENTRY."<<endl; cout<<"RETAINING OLD DETAILS."<<endl; strcpy(month,mm); date=dd; } } if(day!=0&&temp!=1) { date=day; } if(strcmp(ev,"0")!=0&&temp!=1) { strcpy(name,ev); } } void main() { clrscr(); mainscreen(); today(); dispcalendar(); getch(); clrscr(); today(); options(); } void today() { time_t t; time(&t); textcolor(WHITE); cout<<"\t \t Today's date and time: "<<ctime(&t); } void options() { clrscr(); today(); cout<<'\a'; //setbkcolor(BLUE); int o; textcolor(GREEN); cputs(" \t \t \t YEAR PLANNER 2016 \t \t \t"); cout<<endl<<endl<<endl<<endl<<endl<<endl; cout<<"1.Enter a Month"<<endl; cout<<endl; cout<<"2.List of Holidays and Festivals"<<endl; cout<<endl; cout<<"3.Task Manager"<<endl; cout<<endl; cout<<"4.Back to Calender"<<endl; cout<<endl; cout<<"5.Quit"<<endl; cin>>o; switch(o) { case 1: dispmonth(); cout<<"Press any key to go back to main menu..."<<endl; getch(); today(); options(); break; case 2: ifstream fin("Holiday.txt"); char ch[50]; clrscr(); if(!fin) { cout<<"FILE NOT FOUND: "<<endl; exit(0); } textcolor(WHITE); while(!fin.eof()) { fin.getline(ch,50); if(strcmp(ch,"MONTH")!=0) cout<<ch<<endl; else getch(); } fin.close(); cout<<"Press any key to go back to main menu..."<<endl; getch(); today(); options(); break; case 3: clrscr(); char yesno; int mno,op,count=1; do { menu: clrscr(); cout<<" WELCOME TO THE TASK MANAGER"<<endl<<endl; cout<<"Choose an option:"<<endl<<endl; cout<<"1.Add an event"<<endl<<endl; cout<<"2.View all events"<<endl<<endl; cout<<"3.Delete an event"<<endl<<endl; cout<<"4.Modify an event"<<endl<<endl; cout<<"5.Go back to Main Menu"<<endl<<endl; cout<<"6.Quit"<<endl<<endl; cin>>op; if(cin.fail()) { cout<<"Invalid option entered!"<<endl; cin.clear(); cin.ignore(); delay(2000); clrscr(); goto menu; } event e; if(op==1) { fstream efile; dam: cout<<"Enter Month Number:(1 to 12)"<<endl; cin>>mno; if(cin.fail()) { cout<<"Invalid option entered!"<<endl; cin.clear(); cin.ignore(); delay(2000); clrscr(); goto dam; } switch(mno) { case 1: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("JANUARY", mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 2: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("FEBRUARY", mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 3: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("MARCH", mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 4: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("APRIL",mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 5: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("MAY", mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 6: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("JUNE",mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 7: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("JULY",mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 8: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("AUGUST",mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 9: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("SEPTEMBER",mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 10: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("OCTOBER",mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 11: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("NOVEMBER",mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; case 12: efile.open("event.txt",ios::in|ios::out|ios::ate|ios::binary); cout<<"Enter Details:"<<endl; e.getdata("DECEMBER",mno); efile.write((char *)& e,sizeof(e)); efile.close(); break; default: cout<<"SUCH A MONTH DOESN'T EXIST."<<endl; break; } } else if(op==2) { clrscr(); cout<<"All Events"<<endl; fstream efile("event.txt",ios::in|ios::binary); while(!efile.eof()) { efile.read((char *)& e, sizeof(e)); if(efile.eof()) break; e.putdata(); } efile.close(); } else if(op==3) { e.Delete(); } else if(op==4) { fstream file("event.txt",ios::in|ios::out|ios::binary); int md,dd,found=0; long pos; char n[50]; event ev; cout<<"Enter details of event to be modified:"<<endl; am: cout<<"Enter month number (1-12):"<<endl; cin>>md; if(cin.fail()) { cout<<"Invalid option entered!"<<endl; cin.clear(); cin.ignore(); delay(2000); clrscr(); goto am; } ad: cout<<"Enter date:"<<endl; cin>>dd; if(cin.fail()) { cout<<"Invalid option entered!"<<endl; cin.clear(); cin.ignore(); delay(2000); clrscr(); goto ad; } if((md == 1) && (dd>=0) && (dd<=31)) strcpy(n, "JANUARY"); else if((md == 2) && (dd>=0) && (dd<=28)) strcpy(n, "FEBRUARY"); else if((md == 3) && (dd>=0) && (dd<=31)) strcpy(n,"MARCH"); else if((md == 4) && (dd>=0) && (dd<=30)) strcpy(n, "APRIL"); else if((md == 5) && (dd>=0) && (dd<=31)) strcpy(n, "MAY"); else if((md == 6) && (dd>=0) && (dd<=30)) strcpy(n, "JUNE"); else if((md == 7) && (dd>=0) && (dd<=31)) strcpy(n, "JULY"); else if((md == 8) && (dd>=0) && (dd<=31)) strcpy(n,"AUGUST"); else if((md == 9) && (dd>=0) && (dd<=30)) strcpy(n,"SEPTEMBER"); else if((md == 10)&& (dd>=0) && (dd<=31)) strcpy(n,"OCTOBER"); else if((md == 11)&&(dd>=0) && (dd<=30)) strcpy(n, "NOVEMBER"); else if((md == 12)&&(dd>=0) && (dd<=31)) strcpy(n,"DECEMBER"); else cout<<"INVALID ENTRY. CANNOT MODIFY THE RECORD. "; pos=file.tellg(); file.read((char *)& ev, sizeof(ev)); while(!file.eof()) { //cout<<pos; if(strcmp(n,ev.month)==0 &&dd==ev.date) { ev.modify(); file.seekg(pos); file.write((char*)&ev,sizeof(ev)); found=1; break; } pos=file.tellg(); file.read((char *)& ev,sizeof(ev)); } if(found==0) cout<<"RECORD NOT FOUND."<<endl; else cout<<"RECORD MODIFIED."<<endl; file.close(); } else if(op==5) { clrscr(); options(); } else if(op==6) exit(0); else cout<<"Option does not exist"<<endl; do { cout<<"Do you want to continue?(y/n)"<<endl; cin>>yesno; if(yesno == 'y' || yesno == 'n' || yesno == 'Y' || yesno == 'N') break; }while((yesno!='y') || (yesno!= 'Y') || (yesno!='n') || (yesno != 'N')); if(yesno == 'y' || yesno == 'Y') count = 1; else count = 0; }while(count==1); break; case 4: clrscr(); dispcalendar(); cout<<"Enter any key to continue..."<<endl; getch(); today(); options(); break; case 5: exit(0); } getch(); } void dispmonth() { char month[10]; cout<<"Enter month name:"<<endl; gets(month); int l=strlen(month); for(int j=0; j<l; j++) { month[j]=tolower(month[j]); } clrscr(); if(strcmp(month,"january")==0) { textcolor(WHITE); cputs(" JANUARY"); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" S M T W T F S "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 3 4 5 6 7 8 9 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 10 11 12 13 14 15 16 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 17 18 19 20 21 22 23 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 24 25 26 27 28 29 30 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 31 "); cout<<endl; } if(strcmp(month,"february")==0) { textcolor(WHITE); cputs(" FEBRUARY"); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" S M T W T F S "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } if(strcmp(month,"march")==0) { textcolor(WHITE); cputs(" MARCH"); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" M T W T F S S "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 30 31 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } if(strcmp(month,"april")==0) { textcolor(WHITE); cputs(" APRIL"); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" T F S S M T W "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 30 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } if(strcmp(month,"may")==0) { textcolor(WHITE); cputs(" MAY "); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" S S M T W T F "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 30 31 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } if(strcmp(month,"june")==0) { textcolor(WHITE); cputs(" JUNE"); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" T W T F S S M "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 30 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } if(strcmp(month,"july")==0) { textcolor(WHITE); cputs(" JULY "); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" T F S S M T W "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 30 31 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } if(strcmp(month,"august")==0) { textcolor(WHITE); cputs(" AUGUST "); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" S M T W T F S "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 30 31 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } if(strcmp(month,"september")==0) { textcolor(WHITE); cputs(" SEPTEMBER"); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" W T F S S M T "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 30 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } if(strcmp(month,"october")==0) { textcolor(WHITE); cputs(" OCTOBER"); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" F S S M T W T "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 30 31 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } if(strcmp(month,"november")==0) { textcolor(WHITE); cputs(" NOVEMBER"); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" M T W T F S S "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 30 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } if(strcmp(month,"december")==0) { textcolor(WHITE); cputs(" DECEMBER"); cout<<endl<<endl<<endl<<endl; textcolor(GREEN); cputs(" W T F S S M T "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 1 2 3 4 5 6 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 7 8 9 10 11 12 13 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 14 15 16 17 18 19 20 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 21 22 23 24 25 26 27 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" 28 29 30 31 "); cout<<endl<<endl<<endl; textcolor(WHITE); cputs(" "); cout<<endl; } } void dispcalendar() { textcolor(GREEN); cputs("\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t CALENDAR 2016 \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t"); //cout<<endl; cout<<" ------------------------------------------------------------------------------"<<endl; cout<<"| "; textcolor(GREEN); cputs("JANUARY"); cout<<" |"; cout<<" "; textcolor(GREEN); cputs("FEBRUARY"); cout<<" |"; cout<<" "; textcolor(GREEN); cputs(" MARCH "); cout<<" |"; cout<<endl; cout<<"| "; textcolor(WHITE); cputs(" S M T W T F S "); cout<<"|"; textcolor(WHITE); cputs(" S M T W T F S "); cout<<" |"; textcolor(WHITE); cputs(" S M T W T F S "); cout<<" |"; cout<<endl; cout<<"| "; textcolor(YELLOW); cputs(" 1 2 "); cout<<"|"; textcolor(YELLOW); cputs(" 1 2 3 4 5 6 "); cout<<" |"; textcolor(YELLOW); cputs(" 1 2 3 "); cout<<" |"; cout<<"| "; textcolor(YELLOW); cputs(" 3 4 5 6 7 8 9 "); cout<<"|"; textcolor(YELLOW); cputs(" 7 8 9 10 11 12 13 "); cout<<" |"; textcolor(YELLOW); cputs(" 3 4 5 6 7 8 9 "); cout<<" |"; cout<<"| "; textcolor(YELLOW); cputs(" 10 11 12 13 14 15 16 "); cout<<"|"; textcolor(YELLOW); cputs(" 14 15 16 17 18 19 20 "); cout<<" |"; textcolor(YELLOW); cputs(" 10 11 12 13 14 15 16 "); cout<<" |"; cout<<"| "; textcolor(YELLOW); cputs(" 17 18 19 20 21 22 23 "); cout<<"|"; textcolor(YELLOW); cputs(" 21 22 23 24 25 26 27 "); cout<<" |"; textcolor(YELLOW); cputs(" 17 18 19 20 21 22 23 "); cout<<" |"; cout<<"| "; textcolor(YELLOW); cputs(" 24 25 26 27 28 29 30 "); cout<<"|"; textcolor(YELLOW); cputs(" 28 29 "); cout<<" |"; textcolor(YELLOW); cputs(" 24 25 26 27 28 29 30 "); cout<<" |"; cout<<"| "; textcolor(YELLOW); cputs(" 31 "); cout<<"|"; textcolor(YELLOW); cputs(" "); cout<<" |"; textcolor(YELLOW); cputs(" 31 "); cout<<" |"; cout<<" ------------------------------------------------------------------------------"<<endl; cout<<"| "; textcolor(GREEN); cputs(" APRIL "); cout<<" |"; cout<<" "; textcolor(GREEN); cputs(" MAY "); cout<<" |"; cout<<" "; textcolor(GREEN); cputs(" JUNE "); cout<<" |"; cout<<endl; cout<<"| "; textcolor(WHITE); cputs(" S M T W T F S "); cout<<"|"; textcolor(WHITE); cputs(" S M T W T F S "); cout<<" |"; textcolor(WHITE); cputs(" S M T W T F S "); cout<<" |"; cout<<endl; cout<<"| "; textcolor(YELLOW); cputs(" 1 2 "); cout<<"|"; textcolor(YELLOW); cputs(" 1 2 3 4 5 6 7 "); cout<<" |"; textcolor(YELLOW); cputs(" 1 2 3 4 "); cout<<" |"; cout<<"| "; textcolor(YELLOW); cputs(" 3 4 5 6 7 8 9 "); cout<<"|"; textcolor(YELLOW); cputs(" 8 9 10 11 12 13 14 "); cout<<" |"; textcolor(YELLOW); cputs(" 5 6 7 8 9 10 11 "); cout<<" |"; cout<<"| "; textcolor(YELLOW); cputs(" 10 11 12 13 14 15 16 "); cout<<"|"; textcolor(YELLOW); cputs(" 15 16 17 18 19 20 21 "); cout<<" |"; textcolor(YELLOW); cputs(" 12 13 14 15 16 17 18 "); cout<<" |"; cout<<"| "; textcolor(YELLOW); cputs(" 17 18 19 20 21 22 23 "); cout<<"|"; textcolor(YELLOW); cputs(" 22 23 24 25 26 27 28 "); cout<<" |"; textcolor(YELLOW); cputs(" 19 20 21 22 23 24 25 "); cout<<" |"; cout<<"| "; textcolor(YELLOW); cputs(" 24 25 26 27 28 29 30 "); cout<<"|"; textcolor(YELLOW); cputs(" 29 30 31 "); cout<<" |"; textcolor(YELLOW); cputs(" 26 27 28 29 30 "); cout<<" |"; cout<<" ------------------------------------------------------------------------------"<<endl; cout<<"Press Any key to proceed to next page"; int koch; if(koch=getche()) { clrscr(); cout<<" ------------------------------------------------------------------------------"<<endl; cout<<"| "; textcolor(GREEN); cputs(" JULY "); cout<<" |"; cout<<" "; textcolor(GREEN); cputs(" AUGUST"); cout<<" |"; cout<<" "; textcolor(GREEN); cputs("SEPTEMBER"); cout<<" |"; cout<<endl; cout<<"| "; textcolor(WHITE); cputs(" S M T W T F S "); cout<<"|"; textcolor(WHITE); cputs(" S M T W T F S "); cout<<" |"; textcolor(WHITE); cputs(" S M T W T F S "); cout<<" |"; cout<<endl; cout<<"| "; textcolor(YELLOW); cputs(" 1 2 "); cout<<"|"; textcolor(YELLOW); cputs(" 1 2 3 4 5 6 "); cout<<" |"; textcolor(YELLOW); cputs(" 1 2 3 "); cout<<" |";
5953ba53be3e6dbb550ff7ccde17621571c7b5c6
d184f4ef149f547f7b59bda6dd1ab28c28c42e2f
/Source/RebellionsHope/Public/Bullet.h
0bbfa2f8b4a06b0457304fc4417a9d676f15e136
[]
no_license
herrlegno/rebellions_hope
657223042849ca377e688ca08f0e043d162cdb23
5d27ff831ef52ee759d80dbef0d666713155f616
refs/heads/main
2023-03-20T01:44:15.839177
2021-03-04T18:17:56
2021-03-04T18:17:56
310,693,269
0
0
null
null
null
null
UTF-8
C++
false
false
1,177
h
// Herrlegno #pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "Bullet.generated.h" UENUM(BlueprintType) enum class EBulletType: uint8 { EnemyBullet UMETA(DisplayName = "Enemy"), PlayerBullet UMETA(DisplayName = "Player"), }; UCLASS() class REBELLIONSHOPE_API ABullet : public AActor { GENERATED_BODY() public: UPROPERTY(Category = "Mesh", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) class UStaticMeshComponent* Mesh = nullptr; UPROPERTY(EditAnywhere, Category = "Properties", meta=(ClampMin = "0")) float Velocity = 1000.f; UPROPERTY(EditAnywhere) EBulletType BulletType; // Sets default values for this actor's properties ABullet(); // Called every frame virtual void Tick(float DeltaTime) override; protected: // Called when the game starts or when spawned virtual void BeginPlay() override; private: static constexpr const TCHAR* DefaultStaticMeshPath = TEXT("StaticMesh'/Engine/EngineMeshes/Sphere.Sphere'"); UPROPERTY() class USceneComponent* Root = nullptr; void CreateHierarchy(); void SetMesh() const; virtual void NotifyActorBeginOverlap(AActor* OtherActor) override; };
6431b38782b537e69a3d5e6f40f1d5b91d1a59c0
ef23e388061a637f82b815d32f7af8cb60c5bb1f
/src/mess/includes/pc1350.h
d68aef465f804e07c563564a9b8248c53386727f
[]
no_license
marcellodash/psmame
76fd877a210d50d34f23e50d338e65a17deff066
09f52313bd3b06311b910ed67a0e7c70c2dd2535
refs/heads/master
2021-05-29T23:57:23.333706
2011-06-23T20:11:22
2011-06-23T20:11:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,139
h
/***************************************************************************** * * includes/pc1350.h * * Pocket Computer 1350 * ****************************************************************************/ #ifndef PC1350_H_ #define PC1350_H_ #define PC1350_CONTRAST (input_port_read(machine, "DSW0") & 0x07) class pc1350_state : public driver_device { public: pc1350_state(running_machine &machine, const driver_device_config_base &config) : driver_device(machine, config) { } UINT8 m_outa; UINT8 m_outb; int m_power; UINT8 m_reg[0x1000]; }; /*----------- defined in machine/pc1350.c -----------*/ void pc1350_outa(device_t *device, int data); void pc1350_outb(device_t *device, int data); void pc1350_outc(device_t *device, int data); int pc1350_brk(device_t *device); int pc1350_ina(device_t *device); int pc1350_inb(device_t *device); MACHINE_START( pc1350 ); NVRAM_HANDLER( pc1350 ); /*----------- defined in video/pc1350.c -----------*/ READ8_HANDLER(pc1350_lcd_read); WRITE8_HANDLER(pc1350_lcd_write); SCREEN_UPDATE( pc1350 ); int pc1350_keyboard_line_r(running_machine &machine); #endif /* PC1350_H_ */
[ "Mike@localhost" ]
Mike@localhost
b14509becd56a4bc6ef1e109f8e520aabcefa0c3
631847fafbcfa07bf33eee078d9b59b464ce4b50
/optimization/pta_maa_optimization/tight_analyses/analysis_tight_pta100_maa650/Build/SampleAnalyzer/User/Analyzer/user.cpp
08c2d9ae0c8315794971643e24d4ccf6e61a2e70
[ "MIT" ]
permissive
sheride/axion_pheno
7b46aeb7cc562800d78edd9048504fdbc0f5fa42
7d3fc08f5ae5b17a3500eba19a2e43f87f076ce5
refs/heads/master
2021-07-01T08:47:59.981416
2021-02-03T23:03:50
2021-02-03T23:03:50
219,261,636
0
0
null
null
null
null
UTF-8
C++
false
false
8,742
cpp
#include "SampleAnalyzer/User/Analyzer/user.h" using namespace MA5; bool user::Initialize(const MA5::Configuration& cfg, const std::map<std::string,std::string>& parameters) { // Initializing PhysicsService for MC PHYSICS->mcConfig().Reset(); // definition of the multiparticle "hadronic" PHYSICS->mcConfig().AddHadronicId(-5); PHYSICS->mcConfig().AddHadronicId(-4); PHYSICS->mcConfig().AddHadronicId(-3); PHYSICS->mcConfig().AddHadronicId(-2); PHYSICS->mcConfig().AddHadronicId(-1); PHYSICS->mcConfig().AddHadronicId(1); PHYSICS->mcConfig().AddHadronicId(2); PHYSICS->mcConfig().AddHadronicId(3); PHYSICS->mcConfig().AddHadronicId(4); PHYSICS->mcConfig().AddHadronicId(5); PHYSICS->mcConfig().AddHadronicId(21); // definition of the multiparticle "invisible" PHYSICS->mcConfig().AddInvisibleId(-16); PHYSICS->mcConfig().AddInvisibleId(-14); PHYSICS->mcConfig().AddInvisibleId(-12); PHYSICS->mcConfig().AddInvisibleId(12); PHYSICS->mcConfig().AddInvisibleId(14); PHYSICS->mcConfig().AddInvisibleId(16); PHYSICS->mcConfig().AddInvisibleId(1000022); // ===== Signal region ===== // Manager()->AddRegionSelection("myregion"); // ===== Selections ===== // Manager()->AddCut("1_( sdETA ( jets[1] jets[2] ) > 3.6 or sdETA ( jets[1] jets[2] ) < -3.6 ) and M ( jets[1] jets[2] ) > 1250.0"); Manager()->AddCut("2_PT ( a[1] ) > 100.0 and M ( a[1] a[2] ) > 650.0"); // ===== Histograms ===== // // No problem during initialization return true; } bool user::Execute(SampleFormat& sample, const EventFormat& event) { MAfloat32 __event_weight__ = 1.0; if (weighted_events_ && event.mc()!=0) __event_weight__ = event.mc()->weight(); if (sample.mc()!=0) sample.mc()->addWeightedEvents(__event_weight__); Manager()->InitializeForNewEvent(__event_weight__); // Clearing particle containers { _P_jets_I1I_PTorderingfinalstate_REG_.clear(); _P_jets_I2I_PTorderingfinalstate_REG_.clear(); _P_a_I1I_PTorderingfinalstate_REG_.clear(); _P_a_I2I_PTorderingfinalstate_REG_.clear(); _P_jetsPTorderingfinalstate_REG_.clear(); _P_aPTorderingfinalstate_REG_.clear(); } // Filling particle containers { for (MAuint32 i=0;i<event.mc()->particles().size();i++) { if (isP__jetsPTorderingfinalstate((&(event.mc()->particles()[i])))) _P_jetsPTorderingfinalstate_REG_.push_back(&(event.mc()->particles()[i])); if (isP__aPTorderingfinalstate((&(event.mc()->particles()[i])))) _P_aPTorderingfinalstate_REG_.push_back(&(event.mc()->particles()[i])); } } // Sorting particles // Sorting particle collection according to PTordering // for getting 1th particle _P_jets_I1I_PTorderingfinalstate_REG_=SORTER->rankFilter(_P_jetsPTorderingfinalstate_REG_,1,PTordering); // Sorting particle collection according to PTordering // for getting 2th particle _P_jets_I2I_PTorderingfinalstate_REG_=SORTER->rankFilter(_P_jetsPTorderingfinalstate_REG_,2,PTordering); // Sorting particle collection according to PTordering // for getting 1th particle _P_a_I1I_PTorderingfinalstate_REG_=SORTER->rankFilter(_P_aPTorderingfinalstate_REG_,1,PTordering); // Sorting particle collection according to PTordering // for getting 2th particle _P_a_I2I_PTorderingfinalstate_REG_=SORTER->rankFilter(_P_aPTorderingfinalstate_REG_,2,PTordering); // Event selection number 1 // * Cut: select ( sdETA ( jets[1] jets[2] ) > 3.6 or sdETA ( jets[1] jets[2] ) < -3.6 ) and M ( jets[1] jets[2] ) > 1250.0, regions = [] { std::vector<MAbool> filter(3,false); { { MAuint32 ind[2]; std::vector<std::set<const MCParticleFormat*> > combis; for (ind[0]=0;ind[0]<_P_jets_I1I_PTorderingfinalstate_REG_.size();ind[0]++) { for (ind[1]=0;ind[1]<_P_jets_I2I_PTorderingfinalstate_REG_.size();ind[1]++) { if (_P_jets_I2I_PTorderingfinalstate_REG_[ind[1]]==_P_jets_I1I_PTorderingfinalstate_REG_[ind[0]]) continue; // Checking if consistent combination std::set<const MCParticleFormat*> mycombi; for (MAuint32 i=0;i<2;i++) { mycombi.insert(_P_jets_I1I_PTorderingfinalstate_REG_[ind[i]]); mycombi.insert(_P_jets_I2I_PTorderingfinalstate_REG_[ind[i]]); } MAbool matched=false; for (MAuint32 i=0;i<combis.size();i++) if (combis[i]==mycombi) {matched=true; break;} if (matched) continue; else combis.push_back(mycombi); if ((_P_jets_I1I_PTorderingfinalstate_REG_[ind[0]]->eta()-_P_jets_I2I_PTorderingfinalstate_REG_[ind[1]]->eta())>3.6) {filter[0]=true; break;} } } } } { { MAuint32 ind[2]; std::vector<std::set<const MCParticleFormat*> > combis; for (ind[0]=0;ind[0]<_P_jets_I1I_PTorderingfinalstate_REG_.size();ind[0]++) { for (ind[1]=0;ind[1]<_P_jets_I2I_PTorderingfinalstate_REG_.size();ind[1]++) { if (_P_jets_I2I_PTorderingfinalstate_REG_[ind[1]]==_P_jets_I1I_PTorderingfinalstate_REG_[ind[0]]) continue; // Checking if consistent combination std::set<const MCParticleFormat*> mycombi; for (MAuint32 i=0;i<2;i++) { mycombi.insert(_P_jets_I1I_PTorderingfinalstate_REG_[ind[i]]); mycombi.insert(_P_jets_I2I_PTorderingfinalstate_REG_[ind[i]]); } MAbool matched=false; for (MAuint32 i=0;i<combis.size();i++) if (combis[i]==mycombi) {matched=true; break;} if (matched) continue; else combis.push_back(mycombi); if ((_P_jets_I1I_PTorderingfinalstate_REG_[ind[0]]->eta()-_P_jets_I2I_PTorderingfinalstate_REG_[ind[1]]->eta())<-3.6) {filter[1]=true; break;} } } } } { { MAuint32 ind[2]; std::vector<std::set<const MCParticleFormat*> > combis; for (ind[0]=0;ind[0]<_P_jets_I1I_PTorderingfinalstate_REG_.size();ind[0]++) { for (ind[1]=0;ind[1]<_P_jets_I2I_PTorderingfinalstate_REG_.size();ind[1]++) { if (_P_jets_I2I_PTorderingfinalstate_REG_[ind[1]]==_P_jets_I1I_PTorderingfinalstate_REG_[ind[0]]) continue; // Checking if consistent combination std::set<const MCParticleFormat*> mycombi; for (MAuint32 i=0;i<2;i++) { mycombi.insert(_P_jets_I1I_PTorderingfinalstate_REG_[ind[i]]); mycombi.insert(_P_jets_I2I_PTorderingfinalstate_REG_[ind[i]]); } MAbool matched=false; for (MAuint32 i=0;i<combis.size();i++) if (combis[i]==mycombi) {matched=true; break;} if (matched) continue; else combis.push_back(mycombi); ParticleBaseFormat q; q+=_P_jets_I1I_PTorderingfinalstate_REG_[ind[0]]->momentum(); q+=_P_jets_I2I_PTorderingfinalstate_REG_[ind[1]]->momentum(); if (q.m()>1250.0) {filter[2]=true; break;} } } } } MAbool filter_global = ((filter[0] || filter[1]) && filter[2]); if(!Manager()->ApplyCut(filter_global, "1_( sdETA ( jets[1] jets[2] ) > 3.6 or sdETA ( jets[1] jets[2] ) < -3.6 ) and M ( jets[1] jets[2] ) > 1250.0")) return true; } // Event selection number 2 // * Cut: select PT ( a[1] ) > 100.0 and M ( a[1] a[2] ) > 650.0, regions = [] { std::vector<MAbool> filter(2,false); { { MAuint32 ind[1]; for (ind[0]=0;ind[0]<_P_a_I1I_PTorderingfinalstate_REG_.size();ind[0]++) { if (_P_a_I1I_PTorderingfinalstate_REG_[ind[0]]->pt()>100.0) {filter[0]=true; break;} } } } { { MAuint32 ind[2]; std::vector<std::set<const MCParticleFormat*> > combis; for (ind[0]=0;ind[0]<_P_a_I1I_PTorderingfinalstate_REG_.size();ind[0]++) { for (ind[1]=0;ind[1]<_P_a_I2I_PTorderingfinalstate_REG_.size();ind[1]++) { if (_P_a_I2I_PTorderingfinalstate_REG_[ind[1]]==_P_a_I1I_PTorderingfinalstate_REG_[ind[0]]) continue; // Checking if consistent combination std::set<const MCParticleFormat*> mycombi; for (MAuint32 i=0;i<2;i++) { mycombi.insert(_P_a_I1I_PTorderingfinalstate_REG_[ind[i]]); mycombi.insert(_P_a_I2I_PTorderingfinalstate_REG_[ind[i]]); } MAbool matched=false; for (MAuint32 i=0;i<combis.size();i++) if (combis[i]==mycombi) {matched=true; break;} if (matched) continue; else combis.push_back(mycombi); ParticleBaseFormat q; q+=_P_a_I1I_PTorderingfinalstate_REG_[ind[0]]->momentum(); q+=_P_a_I2I_PTorderingfinalstate_REG_[ind[1]]->momentum(); if (q.m()>650.0) {filter[1]=true; break;} } } } } MAbool filter_global = (filter[0] && filter[1]); if(!Manager()->ApplyCut(filter_global, "2_PT ( a[1] ) > 100.0 and M ( a[1] a[2] ) > 650.0")) return true; } return true; } void user::Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files) { }
2f54b91aa78766f58d4be518eb777fbe2e4a6a15
9157350c4ba838631aad8922d457da97efd07eaf
/LISTA-1/exercicio1.cpp
bf5632709fb37f99c90e5f785f5d7816912671a2
[]
no_license
GabrielInacio03/EXERCICIOS_C
992e7674dfc99fe4707a908cf6a16d7cc62b5d85
84abc5f44ce6e4bfba364b09920ef21f3b05494d
refs/heads/master
2023-01-08T01:03:30.682788
2020-11-03T13:58:35
2020-11-03T13:58:35
309,702,331
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
297
cpp
#include <stdio.h> int main(){ int n,ant,suc; printf("Exercicio 1:"); printf("\n"); printf("Escreva um valor inteiro:"); scanf("%d", &n); ant = n - 1; suc = n + 1; printf("O antecessor de %d é:%d", n, ant); printf("\n"); printf("O Sucessor de %d é: %d", n, suc); return 0; }
bd982a1bcdfc890473b1aecd2e79592f2d777ec9
70a793f950d8d5deecc21afea344cd2ec119d9ba
/CODES/sept long/third.cpp
51f4b6f8f0f476bc08e61410145c4c30c48f8bce
[]
no_license
PrshntS/CODES
a5f30ba778606091edbc39550897aa46fd17977f
8b31cd1020ce8c3f1cb97d2df83d458d48ca4c63
refs/heads/main
2023-03-08T08:54:06.144711
2021-02-27T09:58:53
2021-02-27T09:58:53
342,825,115
0
0
null
null
null
null
UTF-8
C++
false
false
812
cpp
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif int t; cin >> t; while(t--){ ll n; cin>>n; ll a[n]; for(ll i=0;i<n;i++) { cin>>a[i]; } vector<ll> v; for(ll i=0;i<n;i++) { ll count=1; for(ll j=0;j<n;j++) { if(i!=j) { if(j<i) { if(a[j]>a[i]) { count++; for(ll k=j+1;k<n;k++) { if(a[k]<a[j]&&k!=i) { count++; } } } } else if(j>i) { if(a[j]<a[i]) { count++; } } } } v.push_back(count); } cout<<*min_element(v.begin(),v.end())<<" "<<*max_element(v.begin(),v.end())<<endl; } return 0; }
c74a1104bda953802c31af20b55e3a8538777f1a
07d23cf641c9d606ae192da44672ce472f479abd
/Advantech2/Control_Advantech.h
ce54c97568f3e77e435450dba6d1bd698967b4e2
[]
no_license
Strongc/Laser2D
bd2915c080fb6ed18ef8ac0048d0d1ec83735a7d
3effedb1da5639df45763c505e99cfa4794d5f4b
refs/heads/master
2021-01-12T22:08:39.925817
2015-09-29T08:05:44
2015-09-29T08:05:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,114
h
//--------------------------------------------------------------------------- #ifndef Control_AdvantechH #define Control_AdvantechH //--------------------------------------------------------------------------- #include <Classes.hpp> #include "bdaqctrl.h" #include "compatibility.h" #pragma hdrstop using namespace Automation::BDaq; //--------------------------------------------------------------------------- class Control_Advantech : public TThread { private: InstantAoCtrl * Analog_Output; InstantDiCtrl * Digital_Input; InstantAiCtrl * Analog_Input; InstantDoCtrl * Digital_Output; Byte DI_Data; double AI_Data[16]; Byte DO_Data; double Valor_Set_Volante, Valor_Set_Acelerador, Dato_AO_0, Dato_AO_1; bool Fin; protected: void __fastcall Execute(); public: __fastcall Control_Advantech(bool CreateSuspended); void SetVolante(double voltaje); void SetAcelerador(double voltaje); void Finalizar(); Byte Get_DI_Data(); double Get_AI_Data(int n); void Set_DO_Data(Byte Valor); }; //--------------------------------------------------------------------------- #endif
ef5a444f7fa6fa831c0803945e057713d32074b6
a68475af4ec94fa346627c4e3879ccba8d8a67f8
/classes/3_this_pointer.cpp
7a431c1cfa9a1888ba7195136ed8135ec36afa0f
[]
no_license
mkbn-consultancy/basic_cpp
b888cd9058fcf4236d60976cef36dca00a62b36a
599f3fa988a956e76e4efb7451a957e0aaffbe9a
refs/heads/main
2023-05-12T07:04:08.800536
2021-05-29T20:47:53
2021-05-29T20:47:53
341,968,990
0
0
null
null
null
null
UTF-8
C++
false
false
285
cpp
class MyClass { public: int getMultBy(int y) { return _x*y; } //==> The compiler provides: // int getByMult(this,int){ // return this->_x * y; // } int _x; }; int main() { MyClass m; m._x = 3; m.getMultBy(6); // ==> The compiler provides: getMultBy(&m,6); }
96c11944cf950ba0903fdbdda603043b25cbcae0
c7ba708c8ed7e056f16f382b2326cd5df1ffa641
/Memory/FlashW25Q64t.h
728de2101e133cacdb193c713e99b94ea2f9d96d
[]
no_license
Kreyl/Drivers
b556de8ff774b06d05bd9c7cec4a585d14f1d019
ab6cd428bc010e6d48d56c11ae676532d4a37232
refs/heads/master
2022-08-21T16:49:41.492034
2022-07-27T08:31:53
2022-07-27T08:31:53
89,774,060
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,458
h
/* * FlashW25Q64t.h * * Created on: 28 ÿíâ. 2016 ã. * Author: Kreyl */ #pragma once #include "ch.h" #include "hal.h" #include "kl_lib.h" #include "board.h" #define MEM_TIMEOUT 45000000 #define MEM_PAGE_SZ 256 // Defined in datasheet #define MEM_PAGE_CNT 32768 #define MEM_PAGES_IN_SECTOR_CNT 16 #define MEM_SECTOR_SZ 4096 // 16 pages #define MEM_SECTOR_CNT 2048 // 2048 blocks of 16 pages each // DMA #define MEM_RX_DMA_MODE STM32_DMA_CR_CHSEL(0) | /* dummy */ \ DMA_PRIORITY_HIGH | \ STM32_DMA_CR_MSIZE_BYTE | \ STM32_DMA_CR_PSIZE_BYTE | \ STM32_DMA_CR_MINC | /* Memory pointer increase */ \ STM32_DMA_CR_DIR_P2M | /* Direction is peripheral to memory */ \ STM32_DMA_CR_TCIE /* Enable Transmission Complete IRQ */ class FlashW25Q64_t { private: Spi_t ISpi; binary_semaphore_t BSemaphore; void WriteEnable(); uint8_t BusyWait(); uint8_t EraseSector4k(uint32_t Addr); uint8_t WritePage(uint32_t Addr, uint8_t *PBuf, uint32_t ALen); void ISendCmdAndAddr(uint8_t Cmd, uint32_t Addr); public: bool IsReady = false; void Init(); uint8_t Read(uint32_t Addr, uint8_t *PBuf, uint32_t ALen); uint8_t EraseAndWriteSector4k(uint32_t Addr, uint8_t *PBuf); void Reset(); void PowerDown(); }; extern FlashW25Q64_t Mem;
9ee59f0c89d135ed925f90abe4ec6bb26680b12d
a8f3633285bb944804f73ff97ebe57dd668b8038
/csv/csv_dim.h
f5b6852081cf2061d3775fbcec575d7de2bc3b82
[]
no_license
beavillata/Bancomat
af0b2adb3b89d8d155607fabdc5d03a557f8b1c5
30e377744b047b349ea603fca3da9e17ef91c167
refs/heads/master
2023-02-24T06:42:34.495238
2021-01-19T07:44:24
2021-01-19T07:44:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,687
h
#ifndef CSVDIM_H #define CSVDIM_H #include <vector> #include "csv_cell.h" /* CSVDimension is a parent class of both CSVRow and CSVCol. * While CSVCol is much more powerful than CSVRow, both support some * basic operations that are provided by this class */ class CSVDimension { public: CSVDimension* append(CSVCell*); CSVCell* getCell(const int) const; std::vector<CSVCell*> getCells() const; int getSize() const; void clear(); // Unused, for now CSVDimension& operator<<(CSVCell&); protected: // Has to be accessible from CSVRow and CSVCol std::vector<CSVCell*> cellsVector; }; class CSVCol: public CSVDimension { public: // has() and first() can be used with std::string, int or double. // By default there is no limit to the amount of matches it looks for and // wants the cell's content to be exactly the _target_ value. std::vector<int> has(std::string, int limit = -1, int options = HAS_EXACT) const; std::vector<int> has(double target, int limit = -1, int options = HAS_EXACT) const { return has(std::to_string(target)); }; std::vector<int> has(int target, int limit = -1, int options = HAS_EXACT) const { return has(std::to_string(target)); }; bool first(std::string, int&, int options = HAS_EXACT) const; bool first(double target, int& dest, int options = HAS_EXACT) const { return first(std::to_string(target), dest, options); }; bool first(int target, int& dest, int options = HAS_EXACT) const { return first(std::to_string(target), dest, options); }; static inline const int HAS_EXACT = 0, HAS_BEGIN = 1, HAS_END = 2; }; class CSVRow: public CSVDimension { public: ~CSVRow(); }; #endif
569a3328b1c66d223cc5565d44fa62724d138a59
34a0bbc28342c40e1567ad7c06967147fc70ff5d
/include/thread/scheduler.h
3d22e156a4b239e499f4538794f6237b0d9ba75a
[]
no_license
Meldanor/OS
87db0a6a5f68d731e6dea0d83099339076fc27fa
b16f38bfde3f7376d3a55caa86f7333e21125ff2
refs/heads/master
2021-04-22T13:45:46.939883
2013-07-11T21:28:46
2013-07-11T21:28:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,248
h
/*---------------------------------------------------------------------------* * Operating Systems I * *---------------------------------------------------------------------------* * * * S C H E D U L E R * * * *---------------------------------------------------------------------------*/ #ifndef __schedule_include__ #define __schedule_include__ #include "thread/dispatch.h" #include "thread/thread.h" #include <deque> /** * \~english * \brief Basic Scheduler * * This class represent a simple FIFO-Scheduler. It holds a list of the * currently available threads. Through the \ref Scheduler::resume method it * can issue a context switch to another ready thread. The resulting context * switch may also switch to the same thread if the ready list is empty. * **/ class Scheduler : protected Dispatcher { private: /** * \~english * \brief Queue of threads that are ready to be processed **/ std::deque<Thread*> threads; /** * \~english * \brief Type definition of thread iterator **/ typedef std::deque<Thread*>::iterator ThreadIterator; public: /** \brief Start the scheduling by starting the first thread of the system * * \param first The first thread of the system **/ void schedule(Thread& first); /** \brief Insert the specified thread into the queue * * of threads that are ready to be processed. * * @param that reference to the thread to be inserted **/ void ready(Thread& that); /** \brief Remove the currently active thread from the queue * * of thread and resumes with the next thread. If there are no * more threads the scheduler starts an idle loop. **/ void exit(); /** \brief Remove the specified thread from the queue of processes. * * @param that reference of the thread to be killed. */ void kill(Thread& that); /** \brief Use the scheduling algorithm to get the next thread and * resumes with that thread. **/ void resume(); }; #endif
53fb2bb96a61021c64eb5900d969814566b1b8c6
b6dcd7d9681a77fbf05afdd55164a9cd053615ab
/Chapter_13/usebrass3.cpp
9f7c09d89da5facd5d9bb4b4505013681b8b43ab
[]
no_license
BBlack-Hun/cpplearn
756648e87a44350ea0da91a23fd14769b1a16031
22be6dd5d57c52cddf44985dac84ba02e3213d28
refs/heads/master
2022-12-28T10:03:03.159000
2020-10-13T07:34:23
2020-10-13T07:34:23
303,619,570
0
0
null
null
null
null
UTF-8
C++
false
false
1,764
cpp
// usebrass3.cpp -- 추상적 기호 클래스를 사용하는 다양한 단계의 사례 // acctabc.cpp와 컴파일한다. #include <iostream> #include <string> #include "acctabc.h" const int CLIENTS = 4; int main() { using std::cin; using std::cout; using std::endl; AcctABC * P_clients[CLIENTS]; std::string temp; long tempnum; double tempbal; char kind; for (int i = 0; i < CLIENTS; i++) { cout << "고객의 이름을 입력한다: "; getline(cin, temp); cout << "고객의 은행계좌 번호를 입력한다: "; cin >> tempnum; cout << "계좌 개설을 입력한다: $"; cin >> tempbal; cout << "Brass 계좌에 1번을 입력한다. 또는," << "BrassPlus 계좌에 2번을 입력한다. "; while (cin >> kind && (kind != '1' && kind !='2')) cout << "1 또는 2를 입력한다."; if (kind=='1') P_clients[i] = new Brass(temp, tempnum, tempbal); else { double tmax, trate; cout << "당좌대월 한계를 입력한다 : $"; cin >> tmax; cout << "이자율을 입력한다." << "소수점을 사용한다: "; cin >> trate; P_clients[i] = new BrassPlus(temp, tempnum, tempbal, tmax, trate); } while (cin.get() != '\n') continue; } cout << endl; for (int i = 0; i < CLIENTS; i++) { P_clients[i] -> ViewAcct(); cout << endl; } for (int i = 0; i < CLIENTS; i++) { delete P_clients[i]; // 가용 메모리 } cout << "프로그램을 종료합니다. \n"; return 0; }
4f464496e5c976f28be1a27bb0c393ebd9aa1350
30a7c93890bfa9c00d51a242b4bb1d7c35e03ef9
/Shoothing/TitleCanvas.cpp
294b0af795a1e92d6b51dc9e3cdee4450d2dbd4e
[]
no_license
Dem-36/DxLibTest
4acf02f51a9d038aa01cff9ba7485d788b2c1696
4c70ea1aade58333e04d22b83c480297e922a801
refs/heads/master
2022-11-04T22:54:34.755822
2020-06-30T15:34:45
2020-06-30T15:34:45
269,000,856
0
0
null
null
null
null
UTF-8
C++
false
false
847
cpp
#include "TitleCanvas.h" #include"GameObject\Score.h" TitleCanvas::TitleCanvas() { } void TitleCanvas::Initialize() { backGroundImage = new Image("TitleBack.png"); backGroundImage->transform.position = Vector2(HALF_SPRITE_X(backGroundImage->transform), HALF_SPRITE_Y(backGroundImage->transform)); AddUIObject(backGroundImage); titleText = new Text("Space Shooter"); titleText->SetFontData("Orbitron", 70, 3); titleText->transform.position = Vector2(25.0f, 50.0f); AddUIObject(titleText); pressText = new Text("Press Z Key"); pressText->SetFontData("Orbitron", 50, 3); pressText->transform.position = Vector2(150, 350); AddUIObject(pressText); } void TitleCanvas::Update() { BaseCanvas::Update(); } void TitleCanvas::Draw(Renderer* renderer) { BaseCanvas::Draw(renderer); } void TitleCanvas::Release() { BaseCanvas::Release(); }
acc5a7da6717901a7fab38294d120ac8ba10765a
08bbc404469c0f335731962cf00a91719b148ea8
/src/qt/tokentransactionrecord.h
7913ebd890148eb251ba824c47098c1243f2feb7
[ "MIT", "GPL-3.0-only" ]
permissive
alexander3636/btcbam-core-1
62796184787139f71b67354452d6726e65e8b830
2565b3b110d049e8f188b57ea42e84466f307f35
refs/heads/main
2023-08-14T20:36:06.478025
2021-08-03T15:51:50
2021-08-03T15:51:50
413,112,625
0
0
MIT
2021-10-03T15:10:48
2021-10-03T15:10:47
null
UTF-8
C++
false
false
2,804
h
#ifndef BTCBAM_QT_TOKENTRANSACTIONRECORD_H #define BTCBAM_QT_TOKENTRANSACTIONRECORD_H #include <amount.h> #include <uint256.h> #include <util/convert.h> #include <QList> #include <QString> namespace interfaces { class Wallet; struct TokenTx; } /** UI model for token transaction status. The token transaction status is the part of a token transaction that will change over time. */ class TokenTransactionStatus { public: TokenTransactionStatus(): countsForBalance(false), sortKey(""), status(Unconfirmed), depth(0), cur_num_blocks(-1) { } enum Status { Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/ /// Normal (sent/received) token transactions Unconfirmed, /**< Not yet mined into a block **/ Confirming /**< Confirmed, but waiting for the recommended number of confirmations **/ }; /// Token transaction counts towards available balance bool countsForBalance; /// Sorting key based on status std::string sortKey; /** @name Reported status @{*/ Status status; qint64 depth; /**@}*/ /** Current number of blocks (to know whether cached status is still valid) */ int cur_num_blocks; }; /** UI model for a token transaction. A core token transaction can be represented by multiple UI token transactions if it has multiple outputs. */ class TokenTransactionRecord { public: enum Type { Other, SendToAddress, SendToOther, RecvWithAddress, RecvFromOther, SendToSelf }; /** Number of confirmation recommended for accepting a token transaction */ static const int RecommendedNumConfirmations = 10; TokenTransactionRecord(): hash(), txid(), time(0), type(Other), address(""), debit(0), credit(0), label("") { } /** Decompose Token transaction into a record. */ static QList<TokenTransactionRecord> decomposeTransaction(interfaces::Wallet &wallet, const interfaces::TokenTx &wtx); /** @name Immutable token transaction attributes @{*/ uint256 hash; uint256 txid; qint64 time; Type type; std::string address; dev::s256 debit; dev::s256 credit; std::string tokenSymbol; uint8_t decimals; std::string label; /**@}*/ /** Return the unique identifier for this transaction (part) */ QString getTxID() const; /** Status: can change with block chain update */ TokenTransactionStatus status; /** Update status from core wallet tx. */ void updateStatus(int block_number, int num_blocks); /** Return whether a status update is needed. */ bool statusUpdateNeeded(int numBlocks); }; #endif // BITCOIN_QT_TRANSACTIONRECORD_H
be1b368aa50c3482e2aff3cb0a09103a8f4f3411
f98c4a193927da5b2b560934cee1904d04cca65b
/cplusplus_tutorial/ 5_1_AC_3.cpp
b7fb157f527368d77a3f06b44d282fb2aca4c6d7
[]
no_license
jimmixliu/book_note
19d448bc71c43fd92ba75f867fc308051c47d461
d8b7368d181ca8fc7c162edea428902e28ba7cba
refs/heads/master
2020-04-05T23:10:25.938857
2016-08-17T00:47:01
2016-08-17T00:47:01
39,748,123
0
0
null
null
null
null
UTF-8
C++
false
false
833
cpp
//template classes #include <iostream> using namespace std; template<class T> class A{ T value1,value2; public: A(T a, T b); T getmax(); }; template<class T> A<T>::A(T a, T b) { value1 = a; value2 = b; } template<class T> T A<T>::getmax() { return 0; } template<> class A<int>{ int value1,value2; public: A(int a, int b) { value1 = a; value2 = b; } int getmax() { int result; result = (value1 > value2) ? value1:value2; return result; } }; //template<> //A<int>::A(int a, int b) //{ // value1 = a; // value2 = b; //} //template<> //int A<int>::getmax() //{ // int result; // result = (value1 > value2) ? value1:value2; // return result; //} int main() { A<int> my_pair(100,105); A<float> my_pair1(3.2,3.5); cout<<my_pair.getmax()<<endl; cout<<my_pair1.getmax()<<endl; }
0a556db9e978bd9f7043a9a22825b4730fda692d
61aa2a4b75806901e9abe8c4a32cb581affbd2bb
/ESP8266Part/ProjectFirstCommunication/ProjectFirstCommunication.ino
69df413689181fc0e1a9636dafa004be93482aa7
[]
no_license
IvanFilipov/IoT-Project-FMI
b1fd362b4135cd361ed94fb95b16210b6d775e89
44569405abeaa9631b8437d3db6b3cc80461639b
refs/heads/master
2021-01-21T07:30:52.664564
2017-07-11T01:42:43
2017-07-11T01:42:43
91,617,216
4
2
null
null
null
null
UTF-8
C++
false
false
1,714
ino
#include <ESP.h> #include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h> #define ssid "" // Your network name here #define password "" // Your network password here void SendData(); void setup() { Serial.begin(115200); while (!Serial); // wait for serial attach // Connect to WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(1000); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); IPAddress ip = WiFi.localIP(); Serial.println(ip); // delay(15000); for(int i = 0 ; i < 10 ; i++){ delay(1000); SentData(); } } void SentData(){ String s("unic_id="); s += ESP.getChipId(); HTTPClient http; // http.begin("http://10.110.200.196/iot/public/php/pushData.php"); http.begin("http://192.168.2.100:8080"); //http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //http.addHeader("Connection", "close"); // http.addHeader("Content-Length", strlen(data)); // int httpCode = http.POST(s); int httpCode = http.GET(); //Serial.print("POST payload: "); //Serial.println(s); if(httpCode > 0){ Serial.print("HTTP POST Response: "); Serial.println(httpCode); // HTTP code 200 means ok } else{ Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); } // delay(10000); http.end(); } void loop() { }
0e3f54c3b4e369a3352ad5f3a5f8a32521e66aef
9a5d488121ab0b538ea6dae4212709cf73e94a83
/DFS.cpp
d96b25cf213d60f7425e3bcdf723c0a0d65f398e
[]
no_license
jhasudhakar/PA1
f28b50618bfd81213ec96915f2ac174efc068f81
64edec3b1e755571bc357c3c4ee099c6cd961d2e
refs/heads/master
2020-12-03T10:36:41.909455
2016-02-02T10:05:46
2016-02-02T10:05:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
388
cpp
// CSE 101 Winter 2016, PA 1 // // Name: TODO put both partners' info if applicable // PID: TODO // Sources of Help: TODO // Due: 1/22/2016 at 11:59 PM #ifndef __DFS_CPP__ #define __DFS_CPP__ #include "Graph.hpp" #include <set> // include more libraries as needed template <class T> std::set<T> dfs(Graph<T>& g, T t){ std::set<T> visited; // TODO return visited; } #endif
909efb5eb737df088cf76c57ea5b32b98e4a679c
871698741689e4fc2a12e1ebe83b18d5e3afb5fa
/espoir/debug.cpp
53e71ce6422c3f69706f7e47cea2d2cd75776fda
[ "BSD-2-Clause" ]
permissive
volvicgeyser/espoir
fb9e3fd30719483818ae4664ccf97aa6262ae722
fd8a3a057a0de5ec5987d1067129675f3a699eca
refs/heads/master
2021-01-22T16:38:20.208012
2013-02-01T15:39:59
2013-02-01T15:39:59
3,368,220
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
744
cpp
#include"stdafx.h" #include"debug.h" namespace espoir{ espoir::DStreamBuf::DStreamBuf(){ ZeroMemory(acBuf_, sizeof(acBuf_)); } espoir::DStreamBuf::~DStreamBuf(){} Int_type espoir::DStreamBuf::overflow(Int_type iChar){ if(iChar != EOF){ acBuf_[0] = iChar; //デバッガに出力 OutputDebugString(acBuf_); } return iChar; } espoir::DOut::~DOut(){ } //エラー用のダイアログ表示関数 void ShowError(const String& str) { MessageBox(NULL, str.c_str(), _T(""), MB_OK || MB_ICONEXCLAMATION); } void ShowError(const String& str, const String& so, const String& line){ const String s = str + _T(" source: ") + so + _T("line: ") + line; MessageBox(NULL, s.c_str(), _T(""), MB_OK || MB_ICONEXCLAMATION); } }
[ "Fenrir@.(none)" ]
Fenrir@.(none)
bbe664cc55005322e0f15c15b34e5813900436ea
25471e3ea2ac7577108b1e7f05178578cd96b11d
/cpp/reserve.cpp
7b3de8906e3a77dcbfc3fad9b4b698bb853c9318
[ "MIT" ]
permissive
lindsayad/misc_programming
30c1626b6eaafc39dfd06f5e84c8404b44a7f979
06d759aa83cadeb32a3f33f52f1ed7528764ea11
refs/heads/master
2023-07-06T13:18:03.467838
2023-06-22T19:33:04
2023-06-22T19:33:04
42,606,159
0
0
null
null
null
null
UTF-8
C++
false
false
529
cpp
#include <iostream> #include <vector> int main() { std::vector<int> x; x.reserve(50); std::vector<int> y = {1, 2, 3, 4, 5}; x = y; std::cout << x.capacity() << std::endl; std::vector<int> z = x; std::cout << z.capacity() << std::endl; std::cout << z.size() << std::endl; std::vector<int> a = std::move(x); std::cout << a.capacity() << std::endl; std::cout << a.size() << std::endl; std::vector<int> b; b = std::move(a); std::cout << b.capacity() << std::endl; std::cout << b.size() << std::endl; }
29edfbb660319d00e7528b3cd2ad104d1cb77cce
19b9a19009a35d215f8aca35cece521525d46154
/cppapp/main.cpp
12837e6321c71b355c34d5b5565d0b1773a14264
[]
no_license
sslakshmi/chrome-extension-tutorial
1d3e85262e2d56fd810deb11abce328451260467
0bf7d7d166b2898ebf7360ca5239113f1b4ddf23
refs/heads/master
2023-03-18T21:53:30.917234
2018-08-31T14:25:19
2018-08-31T14:25:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,243
cpp
#include <iostream> #include <string> #include <stdio.h> #include <stdlib.h> int main() { unsigned int length = 0; /////////////////////////////// // read the first four bytes // /////////////////////////////// for (int index = 0; index < 4; index++) { unsigned int read_char = getchar(); length = length | (read_char << index*8); } //////////////////////////// // DO WHATEVER YOU DESIRE // //////////////////////////// ///////////////////////////////////////// // read the message form the extension // ///////////////////////////////////////// std::string message = ""; for (int index = 0; index < length; index++) { message += getchar(); } //////////////////////////////////////// // collect the length of the message // //////////////////////////////////////// unsigned int len = message.length(); //////////////////////////////////////////// // send the 4 bytes of length information // //////////////////////////////////////////// printf("%c%c%c%c", (char) (len & 0xff), (char) (len << 8 & 0xff), (char) (len << 16 & 0xff), (char) (len << 24 & 0xff)); ///////////////////////// // output the message // ///////////////////////// printf("%s", message.c_str()); return 0; }
a01a57c87826418357244c6fe91c133c8b8f6e91
a82dfb61b17fa66b9c75fe871401cff77aa77f56
/libmcell/api/surface_class.cpp
3b8711a0adb42b2335e15aaa7f3cf73d4d57ac52
[ "MIT" ]
permissive
mcellteam/mcell
49ca84048a091de8933adccc083d31b7bcb1529e
3920aec22c55013b78f7d6483b81f70a0d564d22
refs/heads/master
2022-12-23T15:01:51.931150
2021-09-29T16:49:14
2021-09-29T16:49:14
10,253,341
29
12
NOASSERTION
2021-07-08T01:56:40
2013-05-23T20:59:54
C++
UTF-8
C++
false
false
930
cpp
/****************************************************************************** * * Copyright (C) 2020 by * The Salk Institute for Biological Studies * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ******************************************************************************/ #include "api/surface_class.h" #include "api/surface_property.h" #include <set> using namespace std; namespace MCell { namespace API { bool SurfaceClass::__eq__(const SurfaceClass& other) const { if (!eq_nonarray_attributes(other)) { return false; } // are surface properties the same? std::set<SurfaceProperty> s1; for (auto& c: properties) { s1.insert(*c); } std::set<SurfaceProperty> s2; for (auto& c: other.properties) { s2.insert(*c); } return s1 == s2; } } // namespace API } // namespace MCell
bd5629be383d269180911806522b885843c1da42
f1631707cc3206fb36367a0375b9fc0de10010ed
/comm/src/libcl_acp/cla_statistics.h
4afe5fd5eec5b6d6a56ebd396a8e396c9c0ec025
[]
no_license
hcl777/tcpproxy
8a38181788e934619b08265a9dd30368cc787d0a
bc261a1c60cf8e1ef42ef4392dcad9f24221b9c5
refs/heads/master
2020-03-23T14:31:04.139996
2018-07-20T08:29:50
2018-07-20T08:29:50
141,681,315
0
0
null
null
null
null
GB18030
C++
false
false
628
h
#pragma once #include "cla_timer.h" #include "cl_speedometer.h" #include "cl_ntypes.h" #include "cla_singleton.h" class cla_statistics: public cla_timerHandler { public: cla_statistics(void); ~cla_statistics(void); public: int init(); void fini(); virtual void on_timer(int e); unsigned int get_max_sendsize(); unsigned int get_max_recvsize(); private: unsigned int get_max_limit(int second_limit,int last); public: cl_speedometer<uint64> m_sendspeed; //总发送速度 cl_speedometer<uint64> m_recvspeed; //总接收速度 private: DWORD m_last_tick; }; typedef cla_singleton<cla_statistics> cla_statisticsSngl;
4359959bc7a5decbc16b005a7dd36505290218b1
b6f3cdbe8de6142f48ea5b6a0ef4a118bf300c15
/FractalTree-master/RPNCalcPlus/RPNCalcPlus/MainPage.xaml.h
c89b00db70d8013c8a215eb9a98a8e736057ba02
[]
no_license
jwang320/Engine
182042cc2b5ea8bb71fe45022296aa00dbbc4e13
5fe1d23fc695f5b43f5a484297b6448c5a446f5a
refs/heads/master
2023-01-01T12:25:18.545583
2020-10-28T00:45:05
2020-10-28T00:45:05
307,857,598
0
0
null
null
null
null
UTF-8
C++
false
false
4,595
h
// // MainPage.xaml.h // Declaration of the MainPage class. // #pragma once #include "MainPage.g.h" class Calculator; namespace RPNCalcPlus { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public ref class MainPage sealed { public: MainPage(); protected: virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override; private: bool shiftDown; bool clearNext; Calculator* calculator; void Click1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Click2(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Click3(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Click4(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Number5_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Number6_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Number7_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Number8_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Number9_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void EqualsButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void PlusButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Number0_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void UpdateTextBox(double newInput); void Grid_KeyDown_1(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); void AddDigit(double d); void AddString(Platform::String^ s); double GetTextNumber(); void UpdateStackView(); void SinButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void MinusButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void MultiplicationButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void DivisionButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void DecimalButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void NegateButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void SquareButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void SquareRootButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void RootButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void PowerButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void CosButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void TanButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void InverseButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void ASinButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void ACosButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void ATanButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void UnaryClick(double(unaryFunc())); void BinaryClick(double(binaryFunc())); void EqualsButton_LostFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void MainGrid_GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void ViewLandScape_PointerPressed(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e); void ApplicationViewStates_CurrentStateChanged(Platform::Object^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs^ e); void thePage_SizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e); void DeleteButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void MainGrid_KeyUp(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); void Exp10Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Exponential_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Log10Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void NaturalLogButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void piebutton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void EButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); }; }
aeb488e83cae9658fae58b5d4946f3c26aae39ce
cccaf2e09305959d5e6d2548793e7f16ae23dae7
/xmscore/python/misc/detail/Listener.cpp
b00f80e977a5eb3d46b21f21a9268fc00d29c1f4
[ "BSD-2-Clause" ]
permissive
Aquaveo/xmscore
713b68d186260e8c31eaf2384bc31c1d464d18ad
fcd6c86ef336c4d45a1581956a45d58baea4c73c
refs/heads/master
2023-08-18T18:04:24.129280
2023-05-14T05:52:05
2023-05-14T05:52:43
124,573,200
3
5
BSD-2-Clause
2023-05-14T05:52:45
2018-03-09T17:37:38
C++
UTF-8
C++
false
false
6,266
cpp
//------------------------------------------------------------------------------ /// \file /// \ingroup misc/detail /// \copyright (C) Copyright Aquaveo 2018. Distributed under FreeBSD License /// (See accompanying file LICENSE or https://aqaveo.com/bsd/license.txt) //------------------------------------------------------------------------------ //----- Included files --------------------------------------------------------- // 1. Precompiled header // 2. My own header #include <xmscore/python/misc/detail/Listener.h> // 3. Standard library headers #include <chrono> // 4. External library headers // 5. Shared code headers #include <xmscore/misc/XmError.h> // 6. Non-shared code headers #include <xmscore/python/misc/PublicProgressListener.h> #include <xmscore/stl/vector.h> //----- Forward declarations --------------------------------------------------- //----- External globals ------------------------------------------------------- //----- Namespace declaration -------------------------------------------------- namespace xms { //----- Constants / Enumerations ----------------------------------------------- //----- Classes / Structs ------------------------------------------------------ //----- Internal functions ----------------------------------------------------- //----- Class / Function definitions ------------------------------------------- using namespace std::chrono; //////////////////////////////////////////////////////////////////////////////// /// \class Listener::impl /// \brief Implementation of the ProgressListener class. This is used in the /// python interface. //////////////////////////////////////////////////////////////////////////////// class Listener::impl { public: impl(PublicProgressListener* a_, int a_updateDelaySeconds) : m_parent(a_) , m_delay(a_updateDelaySeconds){} PublicProgressListener* m_parent; ///< parent class that holds this instance int m_delay; ///< time to delay messages in seconds VecStr m_operations; ///< vector of the "begin operation" strings ///< time used for delaying messages so we are not so chatty steady_clock::time_point m_lastMsgTime; }; //////////////////////////////////////////////////////////////////////////////// /// \class Listener /// \brief Implementation of the ProgressListener class. This is used in the /// python interface. //////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------ /// \brief Constructor /// \param[in] a_parent: the parent class /// \param[in] a_updateDelaySeconds: time for delay in updating //------------------------------------------------------------------------------ Listener::Listener(PublicProgressListener *a_, int a_updateDelaySeconds /*3*/) : m_p(new Listener::impl(a_, a_updateDelaySeconds)) { } // Listener::Listener //------------------------------------------------------------------------------ /// \brief Destructor //------------------------------------------------------------------------------ Listener::~Listener() { try { delete(m_p); m_p = nullptr; } catch (...) { } } // Listener::~Listener //------------------------------------------------------------------------------ /// \brief Set the update delay /// \param[in] a_delay: time for delay in message updating //------------------------------------------------------------------------------ void Listener::SetUpdateDelaySeconds(int a_delay) { m_p->m_delay = a_delay; } // Listener::SetUpdateDelaySeconds //------------------------------------------------------------------------------ /// \brief Listen to progress status /// \param[in] a_stackIndex: the ID for progress stack (0 for first) /// \param[in] a_fractionComplete: amount complete from 0.0 to 1.0 //------------------------------------------------------------------------------ void Listener::OnProgressStatus(int a_stackIndex, double a_fractionComplete) { auto t = steady_clock::now(); int elapsed = (int)duration_cast<seconds>(t - m_p->m_lastMsgTime).count(); if (elapsed >= m_p->m_delay) { m_p->m_parent->on_progress_status(a_stackIndex, a_fractionComplete); m_p->m_lastMsgTime = t; } } // Listener::OnProgressStatus //------------------------------------------------------------------------------ /// \brief Listen to when operation begins /// \param[in] a_operation: the name of the operation /// \return the ID for progress stack (0 for first) //------------------------------------------------------------------------------ int Listener::OnBeginOperationString(const std::string& a_operation) { m_p->m_lastMsgTime = steady_clock::now(); m_p->m_operations.push_back(a_operation); m_p->m_parent->on_begin_operation_string(a_operation); return static_cast<int>(m_p->m_operations.size()); } // Listener::OnBeginOperationString //------------------------------------------------------------------------------ /// \brief Listen to when operation ends /// \param[in] a_stackIndex: the ID for progress stack (0 for first) //------------------------------------------------------------------------------ void Listener::OnEndOperation(int a_stackIndex) { m_p->m_lastMsgTime = steady_clock::now(); m_p->m_parent->on_end_operation(a_stackIndex); if (!m_p->m_operations.empty()) m_p->m_operations.pop_back(); } // Listener::OnEndOperation //------------------------------------------------------------------------------ /// \brief Listen to when operation ends /// \param[in] a_stackIndex: the ID for progress stack (0 for first) /// \param[in] a_message: the new message for an operation //------------------------------------------------------------------------------ void Listener::OnUpdateMessage(int a_stackIndex, const std::string& a_message) { auto t = steady_clock::now(); int elapsed = (int)duration_cast<seconds>(t - m_p->m_lastMsgTime).count(); if (elapsed >= m_p->m_delay) { m_p->m_parent->on_update_message(a_stackIndex, a_message); m_p->m_lastMsgTime = t; } } // Listener::OnUpdateMessage } // namespace xms
f08d6d5ec51ac20e9874e271bea1b83be1ff749f
9030ce2789a58888904d0c50c21591632eddffd7
/SDK/ARKSurvivalEvolved_ProjSpear_Carrot_functions.cpp
ee6a25aefd2e70829914f14724ad3e91b3d73623
[ "MIT" ]
permissive
2bite/ARK-SDK
8ce93f504b2e3bd4f8e7ced184980b13f127b7bf
ce1f4906ccf82ed38518558c0163c4f92f5f7b14
refs/heads/master
2022-09-19T06:28:20.076298
2022-09-03T17:21:00
2022-09-03T17:21:00
232,411,353
14
5
null
null
null
null
UTF-8
C++
false
false
1,422
cpp
// ARKSurvivalEvolved (332.8) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_ProjSpear_Carrot_parameters.hpp" namespace sdk { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function ProjSpear_Carrot.ProjSpear_Carrot_C.UserConstructionScript // () void AProjSpear_Carrot_C::UserConstructionScript() { static auto fn = UObject::FindObject<UFunction>("Function ProjSpear_Carrot.ProjSpear_Carrot_C.UserConstructionScript"); AProjSpear_Carrot_C_UserConstructionScript_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ProjSpear_Carrot.ProjSpear_Carrot_C.ExecuteUbergraph_ProjSpear_Carrot // () // Parameters: // int EntryPoint (Parm, ZeroConstructor, IsPlainOldData) void AProjSpear_Carrot_C::ExecuteUbergraph_ProjSpear_Carrot(int EntryPoint) { static auto fn = UObject::FindObject<UFunction>("Function ProjSpear_Carrot.ProjSpear_Carrot_C.ExecuteUbergraph_ProjSpear_Carrot"); AProjSpear_Carrot_C_ExecuteUbergraph_ProjSpear_Carrot_Params params; params.EntryPoint = EntryPoint; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
3d6ab94a7b78fc620fe71097edf506424a1bb62c
0988ce5a7709670e10be8f1882de21117e4c54ff
/include/desola/file-access/mtl_complex.hpp
ad683dd9167cad55642f72579b3e5a310f3b5164
[ "Artistic-1.0", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-other-permissive", "FSFUL", "MTLL", "Apache-2.0", "Artistic-2.0" ]
permissive
FrancisRussell/desola
d726987bff31d8da2dc8204b29b1ee6672713892
a469428466e4849c7c0e2009a0c50b89184cae01
refs/heads/master
2021-01-23T11:20:26.873081
2014-03-29T13:24:16
2014-03-29T13:24:16
18,237,824
2
0
null
null
null
null
UTF-8
C++
false
false
215
hpp
// This is a modified file from the Matrix Template Library. See LICENSE for details. // Modified 2006, Francis Russell #include <complex> /* namespace polution from <sys/sysmacros.h> */ #undef major #undef minor
e31f4eaf8715d53bc36ddb4c6e66936bb91b49b6
4fa1e0711c3023a94035b58f6a66c9acd4a7f424
/Microsoft/SAMPLES/MFC/PHONEBK/VIEW.H
4f810c2424a917150462048395496927edc72b0f
[ "MIT" ]
permissive
tig/Tigger
4d1f5a2088468c75a7c21b103705445a93ec571c
8e06d117a5b520c5fc9e37a710bf17aa51a9958c
refs/heads/master
2023-06-09T01:59:43.167371
2020-08-19T15:21:53
2020-08-19T15:21:53
3,426,737
1
2
null
2023-05-31T18:56:36
2012-02-13T03:05:18
C
UTF-8
C++
false
false
441
h
#ifndef __VIEW_H__ #define __VIEW_H__ class CMainWindow : public CFrameWnd { public: // Constructor CMainWindow() ; afx_msg void OnPaint() ; // Handler function for About dlg. afx_msg void OnAbout() ; // Macro to declare message map // DECLARE_MESSAGE_MAP() } ; class CTheApp : public CWinApp { public: // Override InitInstance BOOL InitInstance() ; } ; #endif
9baa149e821f2f9d9641dccb9fe092eb0434edd8
683537fa4613aa5a404520cd5cc9dab2d85c9ef7
/tp4_ESIR/third-party/visp-3.1.0-build/include/visp3/core/vpRzyzVector.h
1205706318c80d8ff262302de02307ee08838458
[]
no_license
SuperRonan/IMM
caac5a2e7fd87af81ecac63119640ade61914d2a
0b88dd11213c0bf99bc371a5b50412c8eccffcfb
refs/heads/master
2020-11-23T20:49:37.482881
2019-12-19T09:59:57
2019-12-19T09:59:57
227,814,002
0
0
null
null
null
null
UTF-8
C++
false
false
5,368
h
/**************************************************************************** * * This file is part of the ViSP software. * Copyright (C) 2005 - 2017 by Inria. All rights reserved. * * This software 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. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact Inria about acquiring a ViSP Professional * Edition License. * * See http://visp.inria.fr for more information. * * This software was developed at: * Inria Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * * If you have questions regarding the use of this file, please contact * Inria at [email protected] * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Description: * Euler angles parameterization for the rotation. * Rzyz(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(z,psi) * * Authors: * Eric Marchand * Fabien Spindler * *****************************************************************************/ #ifndef vpRzyzVector_h #define vpRzyzVector_h /*! \file vpRzyzVector.h \brief class that consider the case of the Rzyz angles parameterization for the rotation Rzyz(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(z,psi) */ class vpRotationMatrix; class vpThetaUVector; #include <visp3/core/vpRotationMatrix.h> #include <visp3/core/vpRotationVector.h> /*! \class vpRzyzVector \ingroup group_core_transformations \brief Implementation of a rotation vector as \f$R(z,y,z)\f$ Euler angle minimal representation. Class that consider the case of the Euler \f$(\varphi,\theta,\psi)\f$ angles using the z-y-z convention, where \f$(\varphi,\theta,\psi)\f$ are respectively the rotation angles around the \f$z\f$, \f$y\f$ and \f$z\f$ axis. \f[R_{zyz}(\varphi,\theta,\psi) = R_z(\varphi) \; R_y(\theta) \; R_z(\psi)\f] with \f[ R_{z}(\varphi) = \left( \begin{array}{ccc} \cos \varphi & -\sin\varphi & 0\\ \sin\varphi &\cos \varphi& 0 \\ 0 & 0 & 1 \end{array} \right) \; R_{y}(\theta) = \left( \begin{array}{ccc} \cos \theta & 0 & \sin\theta\\ 0 & 1 & 0 \\ -\sin\theta & 0 &\cos \theta \end{array} \right) \; R_{z}(\psi) = \left( \begin{array}{ccc} \cos \psi & -\sin\psi & 0\\ \sin\psi &\cos \psi& 0 \\ 0 & 0 & 1 \end{array} \right) \f] The rotation matrix corresponding to the z-y-z convention is given by: \f[ R_{zyz}(\varphi,\theta,\psi) = \left( \begin{array}{ccc} \cos\varphi \cos\theta \cos\psi - \sin\varphi\sin\psi & -\cos\varphi \cos\theta \sin\psi -\sin\varphi\cos\psi & \cos\varphi \sin\theta \\ \sin\varphi \cos\theta \cos\psi + \cos\varphi\sin\psi & -\sin\varphi \cos\theta \sin\psi +\cos\varphi\cos\psi & \sin\varphi \sin\theta \\ -\sin\theta \cos\psi & \sin\theta \sin\psi & \cos\theta \end{array} \right) \f] The vpRzyzVector class is derived from vpRotationVector. The code below shows first how to initialize this representation of Euler angles, than how to contruct a rotation matrix from a vpRzyzVector and finaly how to extract the vpRzyzVector Euler angles from the build rotation matrix. \code #include <visp3/core/vpMath.h> #include <visp3/core/vpRotationMatrix.h> #include <visp3/core/vpRzyzVector.h> int main() { vpRzyzVector rzyz; // Initialise the Euler angles rzyz[0] = vpMath::rad( 45.f); // phi angle in rad/s around z axis rzyz[1] = vpMath::rad(-30.f); // theta angle in rad/s around y axis rzyz[2] = vpMath::rad( 90.f); // psi angle in rad/s around z axis // Construct a rotation matrix from the Euler angles vpRotationMatrix R(rzyz); // Extract the Euler angles around z,y,z axis from a rotation matrix rzyz.buildFrom(R); // Print the extracted Euler angles. Values are the same than the // one used for initialization std::cout << rzyz; // Since the rotation vector is 3 values column vector, the // transpose operation produce a row vector. vpRowVector rzyz_t = rzyz.t(); // Print the transpose row vector std::cout << rzyz_t << std::endl; } \endcode */ class VISP_EXPORT vpRzyzVector : public vpRotationVector { public: vpRzyzVector(); vpRzyzVector(const vpRzyzVector &rzyz); // initialize a Rzyz vector from a rotation matrix explicit vpRzyzVector(const vpRotationMatrix &R); // initialize a Rzyz vector from a ThetaU vector explicit vpRzyzVector(const vpThetaUVector &tu); vpRzyzVector(const double phi, const double theta, const double psi); explicit vpRzyzVector(const vpColVector &rzyz); //! Destructor. virtual ~vpRzyzVector(){}; // convert a rotation matrix into Rzyz vector vpRzyzVector buildFrom(const vpRotationMatrix &R); // convert a ThetaU vector into a Rzyz vector vpRzyzVector buildFrom(const vpThetaUVector &R); void buildFrom(const double phi, const double theta, const double psi); vpRzyzVector &operator=(const vpColVector &rzyz); vpRzyzVector &operator=(double x); }; #endif
064e4ddef5f8a67c97b410bd76c875fe545b2922
4d3369acc301201d553159a7f83d888ab7e24e75
/lib/regi/sim_metrics_2d/jhmrImgSimMetric2DNCCOCL.cpp
7774a3ac355bc7b9ece99647b4cb1777c5d8aa9e
[ "MIT" ]
permissive
yjsyyyjszf/jhmr-v2
0e224b1b96ca2a543ecc45c5227fe9dfb3e5ef67
e8ff7d0405169542237a9aebc4154566ce52fba6
refs/heads/master
2022-12-11T05:50:07.490180
2020-09-11T01:06:04
2020-09-11T01:06:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,753
cpp
/* * MIT License * * Copyright (c) 2020 Robert Grupp * * 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. */ #include "jhmrImgSimMetric2DNCCOCL.h" #include <boost/compute/utility/source.hpp> // ITK pollutes the global namespace with a macro, and causes // a compile failure with vienna cl #ifdef vcl_size_t #undef vcl_size_t #endif #ifdef vcl_ptrdiff_t #undef vcl_ptrdiff_t #endif #include <viennacl/matrix.hpp> #include <viennacl/vector.hpp> #include <viennacl/linalg/prod.hpp> #include "jhmrOpenCLMiscKernels.h" namespace { const std::size_t kWORK_GROUP_DIV_FACTOR = 1; const char* kNCC_OPENCL_SRC = BOOST_COMPUTE_STRINGIZE_SOURCE( __kernel void SubMeanAndSquareKernel(__global float* sub_from_mean_imgs, __global float* sub_from_mean_sq_imgs, __global const float* means, const uint num_imgs, const uint img_len, const uint proj_off) { const uint global_inc = get_global_size(0); const uint img_idx = get_global_id(1); if (img_idx < num_imgs) { // this is typically from the ray caster buffer, which can be split up amongst different sim // metrics and thus why we need projection offset. __global float* cur_sub_from_mean_img = sub_from_mean_imgs + ((proj_off + img_idx) * img_len); // this buffer is local to this sim metric and we can just use the beginning section; no need // to worry about projection offset __global float* cur_sub_from_mean_sq_img = sub_from_mean_sq_imgs + (img_idx * img_len); const float cur_mean = means[img_idx]; for (uint pixel_idx = get_global_id(0); pixel_idx < img_len; pixel_idx += global_inc) { const float pix_minus_mean = cur_sub_from_mean_img[pixel_idx] - cur_mean; cur_sub_from_mean_img[pixel_idx] = pix_minus_mean; cur_sub_from_mean_sq_img[pixel_idx] = pix_minus_mean * pix_minus_mean; } } } __kernel void NCCElemsKernel(__global float* sub_from_mean_mov_imgs, __global const float* mov_std_devs, __global const float* fixed_minus_mean_over_std_dev, const uint num_imgs, const uint img_len, const uint proj_off) { const uint global_inc = get_global_size(0); const uint img_idx = get_global_id(1); if (img_idx < num_imgs) { __global float* cur_sub_from_mean_mov_img = sub_from_mean_mov_imgs + ((proj_off + img_idx) * img_len); const float cur_mov_std_dev = max(1.0e-6f, sqrt(mov_std_devs[img_idx])); for (uint pixel_idx = get_global_id(0); pixel_idx < img_len; pixel_idx += global_inc) { cur_sub_from_mean_mov_img[pixel_idx] *= fixed_minus_mean_over_std_dev[pixel_idx] / cur_mov_std_dev; } } } ); } // un-named jhmr::ImgSimMetric2DNCCOCL::ImgSimMetric2DNCCOCL(const boost::compute::device& gpu) : ImgSimMetric2DOCL(gpu) { } jhmr::ImgSimMetric2DNCCOCL::ImgSimMetric2DNCCOCL(const boost::compute::context& ctx, const boost::compute::command_queue& queue) : ImgSimMetric2DOCL(ctx, queue) { } void jhmr::ImgSimMetric2DNCCOCL::allocate_resources() { namespace bc = boost::compute; // the parent call to allocate resources can trigger a call to process_mask, // so we need to make sure we have these buffers allocated ahead of time // compile, and create custom kernels std::stringstream ss; ss << DivideBufElemsOutOfPlaceKernelSrc << kNCC_OPENCL_SRC; bc::program prog = bc::program::create_with_source(ss.str(), this->ctx_); try { prog.build(); } catch (bc::opencl_error &e) { std::cerr << "OpenCL Kernel Compile Error (ImgSimMetric2DNCCOCL):\n" << prog.build_log() << std::endl; throw; } div_elems_krnl_ = prog.create_kernel("DivideBufElemsOutOfPlace"); sub_mean_sq_krnl_ = prog.create_kernel("SubMeanAndSquareKernel"); ncc_elem_krnl_ = prog.create_kernel("NCCElemsKernel"); const size_type num_pix_per_img = this->num_pix_per_proj(); // Populate and compute the appropriate fixed image buffers // we'll use this now to store temp calculations on the fixed image // and later use it on the moving images tmp_mov_imgs_dev_.reset(new DevBuf(this->ctx_)); tmp_mov_imgs_dev_->resize(num_pix_per_img * this->num_mov_imgs_, this->queue_); fixed_img_mean_dev_.reset(new DevPixelScalarBuf(this->ctx_)); fixed_img_stddev_dev_.reset(new DevPixelScalarBuf(this->ctx_)); one_over_n_dev_.reset(new DevBuf(this->ctx_)); one_over_n_minus_1_dev_.reset(new DevBuf(this->ctx_)); // MOVING IMAGE Buffer creation mov_img_means_dev_.reset(new DevBuf(ctx_)); mov_img_means_dev_->resize(this->num_mov_imgs_, queue_); mov_img_std_devs_dev_.reset(new DevBuf(ctx_)); mov_img_std_devs_dev_->resize(this->num_mov_imgs_, queue_); nccs_dev_.reset(new DevBuf(ctx_)); nccs_dev_->resize(this->num_mov_imgs_, queue_); ImgSimMetric2DOCL::allocate_resources(); // setup static kernel parameters ncc_elem_krnl_.set_arg(0, *this->mov_imgs_buf_); ncc_elem_krnl_.set_arg(1, *mov_img_std_devs_dev_); ncc_elem_krnl_.set_arg(2, *this->fixed_img_ocl_buf_); ncc_elem_krnl_.set_arg(4, bc::uint_(num_pix_per_img)); // allocate similarity score buffer this->sim_vals_.assign(this->num_mov_imgs_, 0); } void jhmr::ImgSimMetric2DNCCOCL::compute() { namespace bc = boost::compute; namespace vcl = viennacl; this->pre_compute(); const size_type num_pix_per_img = this->num_pix_per_proj(); // wrap the existing GPU buffers with vienna CL objects; this first matrix represents // the maximal allocation; we'll take a sub-block of this. vcl::matrix<float> imgs_mat(this->mov_imgs_buf_->get_buffer().get(), this->sim_vals_.size(), // maximum allocated number of moving images num_pix_per_img); // this is a sub-matrix of the entire buffer for the projections represented by // not the maximal allocation, but the current offset and number of moving images vcl::matrix_range<vcl::matrix<float>> imgs_mat2(imgs_mat, vcl::range(this->proj_off_, this->proj_off_ + this->num_mov_imgs_), vcl::range(0, num_pix_per_img)); vcl::vector<float> avg_vec(one_over_n_dev_->get_buffer().get(), num_pix_per_img); vcl::vector<float> n_minus_one_vec(one_over_n_minus_1_dev_->get_buffer().get(), num_pix_per_img); vcl::vector<float> means_vec(mov_img_means_dev_->get_buffer().get(), this->num_mov_imgs_); vcl::matrix<float> tmp_imgs_mat(this->tmp_mov_imgs_dev_->get_buffer().get(), this->num_mov_imgs_, num_pix_per_img); vcl::vector<float> std_devs_vec(mov_img_std_devs_dev_->get_buffer().get(), this->num_mov_imgs_); vcl::vector<float> nccs_vec(nccs_dev_->get_buffer().get(), this->num_mov_imgs_); // compute means vcl::linalg::prod_impl(imgs_mat2, avg_vec, means_vec); // compute std devs // first subtract mean from each element and square sub_mean_sq_krnl_.set_arg(3, bc::uint_(this->num_mov_imgs_)); sub_mean_sq_krnl_.set_arg(5, bc::uint_(this->proj_off_)); std::size_t global_size[2] = { num_pix_per_img / kWORK_GROUP_DIV_FACTOR, this->num_mov_imgs_ }; this->queue_.enqueue_nd_range_kernel(sub_mean_sq_krnl_, 2, 0, global_size, 0).wait(); // now compute std dev. vcl::linalg::prod_impl(tmp_imgs_mat, n_minus_one_vec, std_devs_vec); // the sqrt is computed in the next kernel // compute ncc elems ncc_elem_krnl_.set_arg(3, bc::uint_(this->num_mov_imgs_)); ncc_elem_krnl_.set_arg(5, bc::uint_(this->proj_off_)); this->queue_.enqueue_nd_range_kernel(ncc_elem_krnl_, 2, 0, global_size, 0).wait(); // reduce into NCC scores vcl::linalg::prod_impl(imgs_mat2, avg_vec, nccs_vec); bc::copy(nccs_dev_->begin(), nccs_dev_->begin() + this->num_mov_imgs_, this->sim_vals_.begin(), this->queue_); // TODO: parallel transform? std::transform(this->sim_vals_.begin(), this->sim_vals_.begin() + this->num_mov_imgs_, this->sim_vals_.begin(), [] (const Scalar& x) { return 0.5 * (1 - x); }); } void jhmr::ImgSimMetric2DNCCOCL::process_mask() { namespace bc = boost::compute; namespace vcl = viennacl; ImgSimMetric2DOCL::process_mask(); const size_type num_pix_per_img = this->num_pix_per_proj(); if (this->mask_) { one_over_n_dev_->resize(num_pix_per_img, this->queue_); one_over_n_minus_1_dev_->resize(num_pix_per_img, this->queue_); const Scalar num_pix_float = static_cast<Scalar>(this->num_pix_per_proj_after_mask_); std::size_t global_size = this->mask_ocl_buf_->size(); div_elems_krnl_.set_arg(0, *this->mask_ocl_buf_); div_elems_krnl_.set_arg(3, bc::ulong_(this->mask_ocl_buf_->size())); div_elems_krnl_.set_arg(1, *one_over_n_dev_); div_elems_krnl_.set_arg(2, num_pix_float); this->queue_.enqueue_nd_range_kernel(div_elems_krnl_, 1, nullptr, &global_size, nullptr).wait(); div_elems_krnl_.set_arg(1, *one_over_n_minus_1_dev_); div_elems_krnl_.set_arg(2, num_pix_float - Scalar(1)); this->queue_.enqueue_nd_range_kernel(div_elems_krnl_, 1, nullptr, &global_size, nullptr).wait(); } else { one_over_n_dev_->assign(num_pix_per_img, 1.0f / num_pix_per_img, this->queue_); one_over_n_minus_1_dev_->assign(num_pix_per_img, 1.0f / (num_pix_per_img - 1.0f), this->queue_); } // wrap the existing GPU buffers with vienna CL objects vcl::matrix<float> fixed_img_mat(this->fixed_img_ocl_buf_->get_buffer().get(), 1, num_pix_per_img); vcl::matrix<float> tmp_fixed_img_mat(tmp_mov_imgs_dev_->get_buffer().get(), 1, num_pix_per_img); vcl::vector<float> fixed_img_mean_vec(fixed_img_mean_dev_->get_buffer().get(), 1); vcl::vector<float> fixed_img_stddev_vec(fixed_img_stddev_dev_->get_buffer().get(), 1); vcl::vector<float> avg_vec(one_over_n_dev_->get_buffer().get(), num_pix_per_img); vcl::vector<float> n_minus_one_vec(one_over_n_minus_1_dev_->get_buffer().get(), num_pix_per_img); // compute mean of fixed image vcl::linalg::prod_impl(fixed_img_mat, avg_vec, fixed_img_mean_vec); // setup and exec kernel to subtract mean from fixed image, and compute squares sub_mean_sq_krnl_.set_arg(0, *this->fixed_img_ocl_buf_); sub_mean_sq_krnl_.set_arg(1, *tmp_mov_imgs_dev_); sub_mean_sq_krnl_.set_arg(2, fixed_img_mean_dev_->get_buffer()); sub_mean_sq_krnl_.set_arg(3, bc::uint_(1)); // num_mov_imgs_ sub_mean_sq_krnl_.set_arg(4, bc::uint_(num_pix_per_img)); sub_mean_sq_krnl_.set_arg(5, bc::uint_(0)); // proj_off_ std::size_t global_size[2] = { num_pix_per_img / kWORK_GROUP_DIV_FACTOR, 1 }; this->queue_.enqueue_nd_range_kernel(sub_mean_sq_krnl_, 2, 0, global_size, 0).wait(); // compute std dev vcl::linalg::prod_impl(tmp_fixed_img_mat, n_minus_one_vec, fixed_img_stddev_vec); const float fixed_std_dev_host = std::max(1.0e-6f, std::sqrt(fixed_img_stddev_dev_->read(this->queue_))); // divide by std dev fixed_img_mat /= fixed_std_dev_host; // Set parameters for the kernel that are specific for the moving images sub_mean_sq_krnl_.set_arg(0, *this->mov_imgs_buf_); sub_mean_sq_krnl_.set_arg(1, *tmp_mov_imgs_dev_); sub_mean_sq_krnl_.set_arg(2, *mov_img_means_dev_); }
a30da6efecde40e7a73404fac63dd8222254721a
9a4253889bffd6c633a27c899424b74740b5add3
/src/oatpp-test/UnitTest.cpp
dad63bbb8541b7ac3fa9013d41fe5dea48b0debe
[ "Apache-2.0" ]
permissive
nuvo-legrand/oatpp
4971f57160d088a8456b181e3e6e35507c71a652
b9ecdb6be67884bece9d2b41f6e8b8b152d293ac
refs/heads/feature-eliot-cloud
2020-05-26T13:26:54.955464
2019-05-30T12:49:19
2019-05-30T12:49:19
188,246,417
0
0
Apache-2.0
2019-05-31T18:41:31
2019-05-23T14:06:56
C++
UTF-8
C++
false
false
2,394
cpp
/*************************************************************************** * * Project _____ __ ____ _ _ * ( _ ) /__\ (_ _)_| |_ _| |_ * )(_)( /(__)\ )( (_ _)(_ _) * (_____)(__)(__)(__) |_| |_| * * * Copyright 2018-present, Leonid Stryzhevskyi <[email protected]> * * 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 "UnitTest.hpp" #include "oatpp/core/base/memory/MemoryPool.hpp" #include <chrono> namespace oatpp { namespace test { void UnitTest::run(v_int32 times) { OATPP_LOGD(TAG, "\033[1mSTART\033[0m..."); v_counter objectsCount = base::Environment::getObjectsCount(); v_counter objectsCreated = base::Environment::getObjectsCreated(); v_int64 ticks = base::Environment::getMicroTickCount(); for(v_int32 i = 0; i < times; i++){ onRun(); } v_int64 millis = base::Environment::getMicroTickCount() - ticks; v_counter leakingObjects = base::Environment::getObjectsCount() - objectsCount; v_counter objectsCreatedPerTest = base::Environment::getObjectsCreated() - objectsCreated; if(leakingObjects == 0){ OATPP_LOGD(TAG, "\033[1mFINISHED\033[0m - \033[1;32msuccess!\033[0m"); OATPP_LOGD(TAG, "\033[33m%d(micro), %d(objs)\033[0m\n", millis, objectsCreatedPerTest); }else{ OATPP_LOGD(TAG, "\033[1mFINISHED\033[0m - \033[1;31mfailed\033[0m, leakingObjects = %d", leakingObjects); auto POOLS = oatpp::base::memory::MemoryPool::POOLS; auto it = POOLS.begin(); while (it != POOLS.end()) { auto pool = it->second; if(pool->getObjectsCount() != 0) { OATPP_LOGD("Pool", "name: '%s' [%d(objs)]", pool->getName().c_str(), pool->getObjectsCount()); } it ++; } exit(EXIT_FAILURE); } } }}
5c97b8c507af2b4c3ddd35ef0199410518bda831
9ac102f48ec6d74653c42da983343bcecc8b6792
/GUI/main.cpp
feeef5c3c384c9fa6c2c83622ec7df9012420584
[]
no_license
Drome/C4Linux
8252baf175abb02937b4c1e912efecb2e56b5cce
12b02d8a4227b3eded9e6d95ffba28c45e4eefb0
refs/heads/master
2021-01-13T01:31:13.829333
2013-07-12T13:56:16
2013-07-12T13:56:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
221
cpp
#include <QApplication> #include <memfs.h> #include "editorwindow.h" int main(int argc, char *argv[]) { MemFUSE::init(); QApplication a(argc, argv); editorWindow w; w.show(); return a.exec(); }