blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
0a6fd1237514f5ac21959c6d18543d9bd35315eb
34f2081361c2cdb28649db5c311b23ae45729867
/Uva/1_Introduction/AdHocPart1/InterestingRealLifeProblemsHarder/12342-tax-calculator.cpp
4c64a2248275c3b47d6b5c7332709bcec2a934fc
[]
no_license
shashank21j/CompetitiveProgramming
bd7d1516bda0047162293f62e78a8f3134021454
5e905ad7f59f36541baaa669391eba667f291a45
refs/heads/master
2022-02-14T08:12:05.656586
2022-01-30T02:56:15
2022-01-30T02:56:15
14,283,517
4
1
null
null
null
null
UTF-8
C++
false
false
867
cpp
12342-tax-calculator.cpp
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; int idx = 0; while (t--) { cout<<"Case "<<++idx<<": "; long long int tax = 0LL; int n; cin >> n; // cout<<n<<endl; if (n <= 180000) { cout<<0<<endl; continue; } // first slab n = n - min(n, 180000); // second slab tax += (long long int)min(n, 300000) * 10; n -= min(n, 300000); // third slab tax += (long long int)min(n, 400000) * 15; n -= min(n, 400000); // fourth slab tax += (long long int)min(n, 300000) * 20; n -= min(n, 300000); // fifth slab tax += (long long int)(n) * 25; tax = tax/100 + (int)(tax%100 != 0); cout << max(tax, 2000LL)<<endl; } return 0; }
0c2b64c3f1610cde4ee90f25b0b52c2e797f02bf
47ce55bba7a39f9a689c113d0127029bb30d20d0
/HEAD_650/pkgsrc/print/lilypond/patches/patch-lily_span-bar-stub-engraver.cc
1491ab846da6342c4c16ed40810c06de1074da2b
[]
no_license
CyberSys/qnxpkgsrcmirror
f1e8747ef7e46d6a16f2e6fba4f437ef640595a1
472534e11d14da5573bb86b12246d00e3ca87fb6
refs/heads/master
2022-12-19T09:31:48.664692
2015-01-30T16:05:07
2015-01-30T16:05:07
299,015,271
0
2
null
null
null
null
UTF-8
C++
false
false
366
cc
patch-lily_span-bar-stub-engraver.cc
$NetBSD: patch-lily_span-bar-stub-engraver.cc,v 1.1 2013/06/16 20:46:52 joerg Exp $ --- lily/span-bar-stub-engraver.cc.orig 2013-06-16 19:21:44.000000000 +0000 +++ lily/span-bar-stub-engraver.cc @@ -17,6 +17,7 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ +#include "config.hh" #include <algorithm> #include "align-interface.hh"
aed0e921effb5bfc7d581a02a01ddf41c7389e5d
737a0c2b00621b69c806f151a4a7c9ca5ef23793
/src/textureslice.cpp
80279c9dea8a55232c9a62812b35eea342b12e85
[]
no_license
ABI-Software/capclient
525219a5d1695f2a60c0a711e1298ef160169ec0
a4a8fa5a4200a5c6da372d42f6e2961bef14f1d3
refs/heads/master
2020-03-18T10:54:53.636926
2012-10-12T00:45:35
2012-10-12T00:45:35
134,640,147
0
0
null
null
null
null
UTF-8
C++
false
false
834
cpp
textureslice.cpp
#include "textureslice.h" #include "utils/debug.h" namespace cap { TextureSlice::TextureSlice(Material *material, std::vector<Cmiss_field_image_id> fieldImages) : material_(material) , fieldImages_(fieldImages) { } TextureSlice::~TextureSlice() { std::vector<Cmiss_field_image_id>::iterator it = fieldImages_.begin(); for (; it != fieldImages_.end(); it++) Cmiss_field_image_destroy(&(*it)); fieldImages_.clear(); delete material_; } void TextureSlice::ChangeTexture(unsigned int index) { if (index < fieldImages_.size()) { material_->ChangeTexture(fieldImages_.at(index)); } } void TextureSlice::ChangeTextureNearestTo(double value) { if (value < 0.0) value = 0.0; if (value > 1.0) value = 1.0; unsigned int index = static_cast<unsigned int>(value*(fieldImages_.size()-1)+0.5); ChangeTexture(index); } }
1ba959061e2ce58c281d62b565317fce253fcab4
b998e99f2856ec2b5002c12b183c7631e22912e1
/KaKao/KaKao2021/무지의_먹방라이브.cpp
f8102141d2687115c6f547db06054c455d93ad73
[]
no_license
geunwoobaek/Problem_solving
e31554ab3232da6436d26a934526fdc2781ddc77
2c43304232f043fd28608e2d76a4e26c395b8597
refs/heads/master
2023-05-23T13:40:43.588085
2021-06-13T13:24:18
2021-06-13T13:24:18
265,751,395
2
0
null
null
null
null
UTF-8
C++
false
false
1,054
cpp
무지의_먹방라이브.cpp
#include<bits/stdc++.h> using namespace std; #define ll long long map<int,int> foodMap; vector<int> foodVec; ll findSum(vector<int>& vec,int target){ ll sum=0; for(int i:vec){ if(target>=i) sum+=i; else sum+=target; } return sum; } int solution(vector<int> food_times, long long k) { k++; for(auto it=foodMap.begin();it!=foodMap.end();it++) //벡터에 구간합 구하기 foodVec.push_back(it->first); for(auto food:food_times){ foodMap[food]++; } int left=0; int right=foodVec.back(); while(left<right){ int mid=(left+right)>>1; ll midSum=findSum(food_times,mid); if(midSum>=k) right=mid; else left=mid+1; } //1 4 10 11 5-> 10 ll temp=findSum(food_times,left); if(temp>=k) k-=findSum(food_times,--left); else k-=temp; //k<0 k>0 cout<<"k="<<k<<", height="<<left; for(int i=0;i<food_times.size();i++){ int food=food_times[i]; if(food>left) k--; if(k==0) return i+1; } return -1; }
412d0b734d1cea262fa3ccbb322a3939001bc6de
fb0b1861e134fca8f09240ffaaca271ca749e1c8
/sketchup/LoopInput.hpp
4094c28ffbbaf44f28e31cafa628d55c32524917
[]
no_license
saedrna/remesh_skp_files
0b7f3ee55bbdfe8dad6952e419a8d0f99a1787e5
3364ff17da82afdbfe1dfc456fd3b9a7b598038e
refs/heads/master
2021-01-20T00:30:23.019732
2017-04-23T13:39:21
2017-04-23T13:39:21
89,144,708
5
0
null
null
null
null
UTF-8
C++
false
false
4,892
hpp
LoopInput.hpp
// // LoopInput.hpp // // Sketchup C++ Wrapper for C API // Copyright (C) 2016 Hidetomo (Tom) Kaneko // // 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/>. // #ifndef LoopInput_hpp #define LoopInput_hpp #include <stdio.h> #include <vector> #include <SketchUpAPI/model/geometry_input.h> namespace CW { // Forward declarations class GeometryInput; class Edge; class Curve; class Material; class Layer; /** * Struct holds information for an edge that was added to a vertex. */ struct InputEdgeProperties { bool hidden = false; bool soft = false; bool smooth = false; Material material(); Layer layer(); }; class LoopInput { private: SULoopInputRef m_loop_input; size_t m_edge_num = 0; bool m_attached; /** Array holds information about the added edges of the vertex. This is to allow the copying of this object. std::vector<std::pair<size_t, InputEdgeProperties>> m_edge_properties; */ //std::vector<Edge> m_edges; //std::vector<Curve> m_curves; static SULoopInputRef create_loop_input_ref(); public: /** * Create empty LoopInput object */ LoopInput(); /** * Create LoopInput object from preexisting SULoopInputRef object */ LoopInput(SULoopInputRef loop_input, bool attached = false); /** * Create LoopInput object from vector of edges that can form a loop. * @param loop_edges - vector of edges from which properties will be copied into the new loop input. * @param vertex_index - 0 by default. This is the first index of the vertex to be added to the loop. Only when using SUGeometryInputRef object would you use an index higher than 0. */ LoopInput(std::vector<Edge> loop_edges, size_t vertex_index = 0); /** Copy constructor */ LoopInput(const LoopInput& other); ~LoopInput(); /** Copy assignment operator **/ LoopInput& operator=(const LoopInput& other); /* * Returns the stored SULoopInputRef object. */ SULoopInputRef ref() const; /* * The class object can be converted to a SULoopInputRef without loss of data. */ operator SULoopInputRef() const; operator SULoopInputRef*(); /** * Indicates whether a LoopInput is valid, or empty. * @return true if valid and has three or more vertices (the minimum for a loop). Returns false if invalid or has two or less vertices. */ operator bool() const; /** * Adds a vertex index to the loop. LoopInput does not hold the point locations of vertices. It holds information on the edges that form the loop. * @param index - the vertex index of the loop. When used with SUCreateFace(), it would be a zero-based index. When used with SUGeometryInputAddFace(), the vertex index would need to correspond to specific indices of the vertices that have been added to SUGeometryInputRef object. */ LoopInput& add_vertex_index(const size_t index); LoopInput& set_edge_hidden(const size_t edge_index, const bool hidden); LoopInput& set_edge_soft(const size_t edge_index, const bool soft); LoopInput& set_edge_smooth(const size_t edge_index, const bool smooth); LoopInput& set_edge_material(const size_t edge_index, const Material& material); LoopInput& set_edge_layer(const size_t edge_index, const Layer& layer); /** * Creates a LoopInput object, which will store the properties of the sequence of Edge objects. */ //LoopInput(std::vector<Edge> edges); /* * Creates a Loop object which is used as a LoopInputRef object (i.e. it is not attached to a Face yet) * @param vector of SUPoint3D objects, tracing the outline of the loop. */ /* * Returns the stored m_edges array. */ //std::vector<Edge> get_edges(); /* * Returns an array of vertices that represent the loop. */ //std::vector<Point3D> get_vertices(); /* * Adds the loop to the given */ // TODO: det //SU_RESULT add_to_geometry_input(GeometryInput &geom_input); /* * Adds a series of vertices that represent the loop. */ //LoopInput& add_vertices(std::vector<Point3D> points); /* * Adds an edge on the end of the Loop */ /* LoopInput& add_edge(Edge edge); LoopInput& add_edges(std::vector<Edge> edges); */ //LoopInput& add_curve(Curve curve); //LoopInput& add_curves(std::vector<Curve> curves); }; } /* namespace CW */ #endif /* LoopInput_hpp */
d2b10aea346b6a92522cbb91e6cc9f5c3435c4b0
7133ef383fa618d4fe72dd058729cf8428784e17
/BasicDataStructure/BST.cpp
730b3809bc5183ce96559846d11d3147a20228de
[]
no_license
supermcu/DataStructure-Algorithm
0d7bd946c0d64a4ff567fe2d4f7e979ebc405cef
70100344654024306f6d398f8e3caaf4bf31129b
refs/heads/master
2022-01-31T19:34:09.986257
2019-06-13T03:13:24
2019-06-13T03:13:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,160
cpp
BST.cpp
// // BinarySerachTree.cpp // test // // Created by KevinLiu on 16/12/22. // Copyright © 2016年 KevinLiu. All rights reserved. // #include <iostream> typedef struct node { int value; node * pLeft; node * pRight; node(int val = 0) { value = val; pRight = NULL; pLeft = NULL; } }node; void insert(node ** pRoot, int val) { if(*pRoot == NULL) *pRoot = new node(val); else if((*pRoot)->value <= val) insert(&((*pRoot)->pRight), val); else if((*pRoot)->value > val) insert(&((*pRoot)->pLeft), val); } node * getBST(int * arr, int size) { node * pRoot = NULL; for(int i = 0; i < size; i++) insert(&pRoot, arr[i]); return pRoot; } void inOrderTraversal(node * pRoot) { if(pRoot && pRoot->pLeft) inOrderTraversal(pRoot->pLeft); if(pRoot) std::cout<<pRoot->value<<" , "; if(pRoot && pRoot->pRight) inOrderTraversal(pRoot->pRight); } int main() { int arr[] = {10,5,15,5,6,7,8,89}; node * pRoot = getBST(arr, sizeof(arr)/sizeof(int)); inOrderTraversal(pRoot); std::cout<<std::endl; return 0; }
c78be39b27991b5bed543b1182e2e143270210c3
b80e33d275e7df6c2ddd48bcba1ee51e26480338
/RC car code/RC_car.ino
a036a01d6322dcba2fa94c186bedae398a470bc6
[]
no_license
kholoudsamy97/ASUMobiCarG48
8b5af57de4625ea813e33ccfd7211ac853b92198
d5f1f0922760348f5ad92f236753dafc02f62901
refs/heads/master
2021-04-30T03:53:44.083387
2018-07-08T09:54:00
2018-07-08T09:54:00
121,524,512
0
5
null
2018-07-06T21:17:23
2018-02-14T15:11:00
C++
UTF-8
C++
false
false
3,661
ino
RC_car.ino
//our L298N control pins const int LeftMotorForward = 8; const int LeftMotorBackward = 12; const int RightMotorForward = 4; const int RightMotorBackward = 7; int getDistance ; #define RF 4 //right forward #define RB 7 // right backward #define LF 8 //left forward #define LB 12 //left backward char x ; byte de=11,in=6; float k=255; const int trigPin = 2 ; const int echoPin = 3 ; void forward(){ digitalWrite(RF, HIGH); digitalWrite(RB, LOW); digitalWrite(LF, HIGH); digitalWrite(LB, LOW); Serial.println("forword"); } void backward(){ digitalWrite(RF, LOW); digitalWrite(RB, HIGH); digitalWrite(LF, LOW); digitalWrite(LB, HIGH); Serial.println("backward"); } void right(){ digitalWrite(RF, HIGH); digitalWrite(RB, LOW); digitalWrite(LF, LOW); digitalWrite(LB, LOW); Serial.println("right"); } void left(){ digitalWrite(RF, LOW); digitalWrite(RB, LOW); digitalWrite(LF, HIGH); digitalWrite(LB, LOW); Serial.println("left"); } void stop_motor(){ digitalWrite(RF, LOW); digitalWrite(RB, LOW); digitalWrite(LF, LOW); digitalWrite(LB, LOW); Serial.println("stop"); } void setup() { pinMode(RF , OUTPUT); pinMode(RB , OUTPUT); pinMode(LF , OUTPUT); pinMode(LB , OUTPUT); pinMode(de , OUTPUT); pinMode(in , OUTPUT); analogWrite(de,255); analogWrite(in,255); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); Serial.begin(9600); // put your setup code here, to run once: } void loop() { /*digitalWrite(trigPin,LOW); delayMicroseconds(2); digitalWrite(trigPin,HIGH); delayMicroseconds(10); digitalWrite(trigPin,LOW); long duration = pulseIn(echoPin,HIGH);*/ int duration, distance; //Adding duration and distance digitalWrite(trigPin, HIGH); //triggering the wave(like blinking an LED) delay(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); //a special function for listening and waiting for the wave distance = (duration/2) / 29.1; //transforming the number to cm(if you want inches, you have to change the 29.1 with a suitable number Serial.print(distance); //printing the numbers Serial.print("cm"); //and the unit Serial.println(" "); //just printing to a new line if(distance == 100) { stop_motor(); delay(5000); } //IF YOU WANT THE PORGRAM SPITTING OUT INFORMATION SLOWER, JUST UNCOMMENT(DELETE THE 2 //) THE NEXT LINE AND CHANGE THE NUMBER //delay(500); if (Serial.available()){ x = Serial.read() ; Serial.print(x); if (x=='1'){ forward(); }else if(x=='2'){ backward(); }else if (x == '4'){ left(); }else if (x=='3'){ right(); }else if ( x=='5'){ stop_motor(); } else if(x=='6'&&k==255){ analogWrite(in,127.5); analogWrite(de,127.5); k=127.5; Serial.print(k); } else if(x=='6'&&k==127.5){ analogWrite(in,63.75); analogWrite(de,63.75); k=63.75; Serial.print(k); } else if(x=='6'&&k==63.75){ analogWrite(in,31.875); analogWrite(de,31.875); k=31.875; Serial.print(k); } else if(x=='7'&&k==31.875){ analogWrite(in,63.75); analogWrite(de,63.75); k=63.75; Serial.print(k);} else if(x=='7'&&k==63.75){ analogWrite(in,127.5); analogWrite(de,127.5); k=127.5; Serial.print(k); } else if(x=='7'&&k==127.5){ analogWrite(in,255); analogWrite(de,255); k=255; Serial.print(k); } } } // put your main code here, to run repeatedly:
8d9d8c47faad366efea21cb68307ba96c0a7e497
6c2bddf5b07d154fa866e42ff55e2370cf4a7a3a
/LabkiGosia/MateuszWleklinski/Lab06/functions.cpp
9bdb3c1552ad66c7701882ca9ca7a6ef3938656a
[]
no_license
FizHubWasTaken/Cpp
a0a13eb8976bc8bda53e101afe7906d5d83cd867
64483e8b8828f093eb6babbb740a76804b26eec5
refs/heads/main
2023-01-29T03:27:21.288446
2020-12-02T18:52:15
2020-12-02T18:52:15
317,952,849
0
0
null
null
null
null
UTF-8
C++
false
false
1,572
cpp
functions.cpp
#include "headers.h" void SumTest() { Debug("1. Testing summing parameters.."); bool test1 = sum(1.0, 2.0, 5.0) == 1.0 + 2.0 + 5.0; Debug("\t1.0 + 2.0 + 5.0 = ", ""); Debug(1.0+2.0+5.0); bool test2 = sum(3.14, 9.81, 21.37, 7.0) == 3.14+9.81+21.37+7; Debug("\t3.14 + 9.81 + 21.37 + 7.0 = ", ""); Debug(3.14+9.81+21.37+7); if (test1 && test2) Debug("\tTest Passed!\n"); else Debug("\tTest Failed!\n"); } void OperationTest() { Debug("2. Testing different operators..."); bool test1 = (operation<int>(1))(1, 2) == -1; bool test2 = (operation<int>(2))(1, 2) == 2; bool test3 = (operation<int>(3))(4, 2) == 2; if (test1 && test2 && test3) Debug("\tTest Passed!\n"); else Debug("\tTest Failed!\n"); } void FunctionCallsTest() { Debug("3. Test multiple functionCalls"); int tab[7] = {1, 2, 3, 4, 5, 6, 7}; bool test1 = functionCalls(tab, 7) == 7; if (test1) { Debug("\t Test Passed!\n"); } } void CompareTableTest() { Debug("4. Test comparing Tables"); int tab[5] = {1, 1, 2, 3, 5}; bool ltab[5] = {1, 1, 0, 1, 0}; int newtab[5]; //newtab = compareTables(tab, ltab, 5); } void MaxValueTest() { Debug("5. Test max value..."); bool test1 = max(1, 3.14, 9.81, 2.88, 4) == 9.81; Debug("\tmax of: 1, 3.14, 9.81, 2.88, 4 is ", ""); Debug(max(1, 3.14, 9.81, 2.88, 4)); bool test2 = max(-5, -9.4, 12, 3.14, 3) == 12; Debug("\tmax of: -5, -9.4, 12, 3.14, 3 is ", ""); Debug(max(-5, -9.4, 12, 3.14, 3)); if (test1 && test2) Debug("\tTest Passed!\n"); else Debug("\tTest Failed\n"); }
6b2fa1ac8ac07f8bddff211ffd4dbbd2e4837a6e
4c0c5c29e0a736b636e669fb810eb23836da6b48
/projek.cpp
4c8e9f487711d2a9a4aca078f06b4bffd58a2c8a
[]
no_license
rifkistwn/Pemrograman-Terstruktur
4a73c5604bb6136415d32b2d676ff0171a38aa78
7f3c6f809d335b4c551738414486f4e9edb24e35
refs/heads/master
2020-03-11T18:22:44.759855
2018-04-23T04:41:20
2018-04-23T04:41:20
130,175,741
0
0
null
null
null
null
UTF-8
C++
false
false
197
cpp
projek.cpp
#include <iostream> #include <string.h> using namespace std; void array(){ for (i=0;i<10;i++){ for (j=0;j<10:j++){ string int main(){ cout<<"Hello world"<<endl; return 0; }
6119762d683aff7a8a66f1c726ab75f7da61e039
573ab921dd30de38b7e37d7157fa05201b1bb8d9
/src/design-patterns/visitor1-cpp17.cpp
a833f814b6e0e75cc26ab1780965a53837fe8c18
[]
no_license
ilovelibai/C-Cpp-Notes
4cab2320e34fc9991d2e16c0eb4bdc10fad35231
cea44f898b06215e127f63375282905568feda14
refs/heads/master
2022-11-30T23:55:48.541167
2020-08-18T17:50:26
2020-08-18T17:50:26
289,960,881
1
0
null
2020-08-24T15:06:38
2020-08-24T15:06:38
null
UTF-8
C++
false
false
4,496
cpp
visitor1-cpp17.cpp
// Brief: Generic visitor pattern implemented with C++17 variants // Author: Caio Rodrigues //------------------------------------------------------------------ #include <iostream> #include <cstdio> #include <string> #include <memory> #include <functional> #include<type_traits> // C++17 Variant std::variant and std::visit #include <variant> class Circle{ public: double radius; Circle(double radius): radius(radius) { } }; class Square{ public: double side; Square(double side): side(side) { } }; class Blob{ public: Blob(){} }; // ======== Generic Visitor =============// /** Basic visitor */ struct PrintNameVisitor{ void operator()(const Circle& sh){ std::cout << " SHAPE = Circle of radius " << sh.radius << std::endl; } void operator()(const Square& sh){ std::cout << " SHAPE = Square of radius " << sh.side << std::endl; } void operator()(const Blob&){ std::cout << " SHAPE = Blob - no one knows how it looks like. " << std::endl; } }; /** Visitor which adpts a function */ template<typename Result> class FunctionVisitor{ private: template<typename Input> using FN = std::function<Result (const Input&)>; FN<Circle> fn_circle; FN<Square> fn_square; FN<Blob> fn_blob; public: //Result result; FunctionVisitor(FN<Circle> fnCircle, FN<Square> fnSquare, FN<Blob> fnBlob) : fn_circle(fnCircle) ,fn_square(fnSquare) ,fn_blob(fnBlob){ } //Result get() const { return result; } Result operator()(const Circle& sh){ return fn_circle(sh); } Result operator()(const Square& sh){ return fn_square(sh); } Result operator()(const Blob& sh){ return fn_blob(sh); } }; template<typename Input, typename Result> using FnVisit = std::function<Result (const Input&)>; /** Make a visitor using a functional-programming way * Visitor with lambdas look like "pattern matching" * from functional languages. */ template<typename Result = void> auto makeVisitor(FnVisit<Circle, Result> fnCircle, FnVisit<Square, Result> fnSquare, FnVisit<Blob, Result> fnBlob ){ return [=](auto&& a){ using C = std::decay_t<decltype(a)>; if constexpr(std::is_same_v<C, Circle>){ return fnCircle(a); } if constexpr(std::is_same_v<C, Square>){ return fnSquare(a); } if constexpr(std::is_same_v<C, Blob>){ return fnBlob(a); } std::cerr << "WARNING - Not returned valid result"; return Result{}; }; } //-- EoF makeVisitor ----// int main() { using Shape = std::variant<Circle, Square, Blob>; // Sample shapes Shape s1 = Circle(3.0); Shape s2 = Square(4.0); Shape s3 = Blob(); auto printVisitor = PrintNameVisitor(); std::puts("\n === EXPERIMENT 1 ================="); std::visit(printVisitor, s1); std::visit(printVisitor, s2); std::visit(printVisitor, s3); std::puts("\n === EXPERIMENT 2 ================="); auto visitorGetName = FunctionVisitor<std::string>{ [](const Circle& ) { return "circle"; }, [](const Square& ) { return "square"; }, [](const Blob& ) { return "blob"; } }; std::cout << "Type of shape 1 = " << std::visit(visitorGetName, s1) << "\n"; std::cout << "Type of shape 2 = " << std::visit(visitorGetName, s2) << "\n"; std::cout << "Type of shape 3 = " << std::visit(visitorGetName, s3) << "\n"; std::puts("\n === EXPERIMENT 3 ================="); // Creates operation to compute shape perimeter auto visitorGetArea = FunctionVisitor<double>{ [](const Circle& s){ return 3.1415 * s.radius * s.radius ; }, [](const Square& s){ return s.side * s.side; }, [](const Blob& ){ return 0.0 / 0.0; /* NAN Not a number */ }, }; std::cout << "Area of shape 1 = " << std::visit(visitorGetArea, s1) << "\n"; std::cout << "Area of shape 2 = " << std::visit(visitorGetArea, s2) << "\n"; std::cout << "Area of shape 3 = " << std::visit(visitorGetArea, s3) << "\n"; std::puts("\n === EXPERIMENT 4 ================="); auto fnVisitorArea = makeVisitor<double>( [](const Circle& s){ return 3.1415 * s.radius * s.radius ; } ,[](const Square& s){ return s.side * s.side; } ,[](const Blob& ){ return 0.0 / 0.0; /* NAN Not a number */ } ); std::cout << "Area of shape 1 = " << std::visit(fnVisitorArea, s1) << "\n"; std::cout << "Area of shape 2 = " << std::visit(fnVisitorArea, s2) << "\n"; std::cout << "Area of shape 3 = " << std::visit(fnVisitorArea, s3) << "\n"; return 0; }
3912c3d9a93ea2e7dfded42c2fc8bb6386da73a9
9cfb5e0fd4af48b28fe8b2ebf12d64503d877a3e
/sequence_to_set/c++/solution.cpp
2a0664b785bbc2eee946ca8293971cfd641f49e3
[]
no_license
dnuffer/dpcode
ca5547ee42adef5fbe9e9171d65ffb84bd25d8bb
0c772f1f4e86b1c8e21547a3865e0d1259dd020b
refs/heads/master
2021-01-10T18:38:09.582635
2018-02-21T14:57:53
2018-02-21T14:57:53
4,272,218
35
5
null
null
null
null
UTF-8
C++
false
false
1,304
cpp
solution.cpp
#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE scratch #include <boost/test/unit_test.hpp> #include <set> #include <iterator> #include <vector> #include <array> template <typename C> auto make_set(const C& seq) -> std::set<typename std::iterator_traits<decltype(std::begin(seq))>::value_type> { typedef typename std::iterator_traits<decltype(std::begin(seq))>::value_type value_type; return std::set<value_type>(std::begin(seq), std::end(seq)); } BOOST_AUTO_TEST_CASE(test_create_set_from_vector) { auto test_set = make_set(std::vector<int>{1,2,3}); BOOST_CHECK_EQUAL(test_set.size(), 3); BOOST_CHECK_EQUAL(test_set.count(1), 1); BOOST_CHECK_EQUAL(test_set.count(2), 1); BOOST_CHECK_EQUAL(test_set.count(3), 1); } BOOST_AUTO_TEST_CASE(test_create_set_from_int_array) { int ints[] = {1,2,3}; auto test_set = make_set(ints); BOOST_CHECK_EQUAL(test_set.size(), 3); BOOST_CHECK_EQUAL(test_set.count(1), 1); BOOST_CHECK_EQUAL(test_set.count(2), 1); BOOST_CHECK_EQUAL(test_set.count(3), 1); } BOOST_AUTO_TEST_CASE(test_create_set_from_std_array) { std::array<int, 3> ints = {1,2,3}; auto test_set = make_set(ints); BOOST_CHECK_EQUAL(test_set.size(), 3); BOOST_CHECK_EQUAL(test_set.count(1), 1); BOOST_CHECK_EQUAL(test_set.count(2), 1); BOOST_CHECK_EQUAL(test_set.count(3), 1); }
9d30a4c940a99ba9b3237892468873a7a9503d85
de8566db6f92103165b07a24ceacf8b20a7ac542
/blang/bcode/v2/bcode.cc
95b1ccce74200de8143799054b0c95a4046ba1a3
[]
no_license
Irwin1985/cerbo
a786ab8af9e4b2f139898bd1ddf557fb6d89b5dd
559df220dc842318c4c2d81100b56bf6587c91a6
refs/heads/master
2022-09-01T15:46:17.400733
2020-05-27T19:21:37
2020-05-27T19:21:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,876
cc
bcode.cc
#include <cassert> #include <fstream> #include <cstddef> #include <functional> #include <iomanip> #include <iostream> #include <sstream> #include <stack> #include <string> #include <string.h> #include <vector> using namespace std; typedef vector<uint8_t> bytes; /////////////////////////////////////////////////////////////////////// // address labels // The addresses of labels you create via the L command uint8_t labels[256]; // what addresses refer to those labels typedef struct { uint8_t label_name; uint8_t position; } lref_t; vector<lref_t> label_refs; void resolve_labels(bytes &bcode) { constexpr bool debug = false; for(const auto& lref:label_refs) { bcode[lref.position] = labels[lref.label_name]; if(debug) { cout << "resolve_labels:name:" << lref.label_name << ",label position:" << int(labels[lref.label_name]) << ",ref position:" << int(lref.position) << "\n"; } } } /////////////////////////////////////////////////////////////////////// // the stack stack<int64_t> stk; int64_t pop_stack() { int64_t v = stk.top(); stk.pop(); return v; } void push_stack(int64_t v) { stk.push(v); } /////////////////////////////////////////////////////////////////////// // An extensible collection of functions. // The idea is that you write more functions here that are relevant // to your application. void dup() { push_stack(stk.top()); } void emit() { int c = pop_stack(); putchar(c); } void hello() { puts("hello world"); } void incr() { stk.top() += 1; } void subt() // a b -- a-b { int64_t tmp = pop_stack(); stk.top() -= tmp; } typedef struct { string name; function<void()> fn; } func_desc; vector<func_desc> vecfns = { {"dupe", dup}, {"emit", emit}, {"hell", hello}, {"incr", incr}, {"subt", subt} }; int find_vecfn(string name) { for(int i = 0 ; i<vecfns.size(); ++i) if(vecfns[i].name == name) return i; cerr << "find_vecfn:unknown function:" << name << "\n"; exit(1); } /////////////////////////////////////////////////////////////////////// // Convenience and utility functions template< typename T > std::string int_to_hex( T i ) { std::stringstream stream; stream << "0x" << setfill ('0') << setw(sizeof(T)*2) << hex << i; return stream.str(); } /////////////////////////////////////////////////////////////////////// void pushchar(bytes& bs, char c) { bs.push_back(c); } template<class T> void push64(bytes& bs, T v) { int64_t v64 = v; uint8_t b[8]; *b = v64; //cout << "push64 function pointer: " << int_to_hex(v64) << "\n"; for(int i = 0; i<8 ; ++i) bs.push_back(b[i]); } int main() { // read program stringstream sstr; sstr << cin.rdbuf(); string prog = sstr.str(); // compile bytes bcode; for(int i = 0 ; i < prog.size(); ++i) { char c = prog[i]; switch(c) { case ' ': // ignore white space case '\r': case '\t': case '\n': break; case '#': // ignore comments while(prog[++i] != '\n'); break; case '0' : pushchar(bcode, '0'); break; case '<': pushchar(bcode, '<'); label_refs.push_back({prog[++i], (uint8_t) bcode.size()}); pushchar(bcode, '?'); // placeholder for an address to be resolved later break; case 'L': labels[prog[++i]] = bcode.size(); break; case 'p' :{ pushchar(bcode, 'p'); auto val = (prog[++i] -'0') * 100 + (prog[++i]-'0')*10 +(prog[ ++i]- '0'); //cout << "compiling p:" << val << "\n"; push64(bcode, val); } break; case 'x': { pushchar(bcode, 'x'); string function_name = { prog[++i], prog[++i], prog[++i], prog[++i]}; pushchar(bcode, find_vecfn(function_name)); break; } default: cerr << "Compile error: Unknown code at position " << i << ":" << c << "\n"; exit(1); } } resolve_labels(bcode); ofstream bin; bin.open("bin.out"); for(auto b:bcode) bin << b; bin.close(); cout << "wrote bin.out\n"; //exit(1); // now run the byte code int pc = 0; bool running = true; while(running) { uint8_t b = bcode[pc]; switch(b) { case '0': running = false; break; case '<': // jump if negative { auto v = pop_stack(); ++pc; if(v<0) pc = bcode[pc]; else ++pc; } break; case 'p': { uint8_t b[8]; for(int i = 0 ; i <8; ++i) b[i] = bcode[++pc]; int64_t v64 = *b; push_stack(v64); pc++; } break; case 'x': { auto fn_idx = bcode[++pc]; auto fn = vecfns[fn_idx].fn; fn(); pc++; } break; default: cerr << "Illegal instruction at PC " << pc << ":" << b << "\n"; exit(1); } } cout << "bcode halted\n"; cout << "Stack contents:"; while(stk.size()> 0) cout << " " << pop_stack(); cout << "\n"; return 0; }
d4e98a2cec3d53c89d5b5ec053c148b55209d1b5
aa0cd440b6e08f09e305caf3f3eda21c18ce8b94
/src/core/test/random.cc
8f00482c01a74b72f1d81c0135f0e19ef42f9436
[ "BSD-2-Clause" ]
permissive
StevenLOL/bob
adc74d675dae3fa2be986e37fb40c95cb4346706
0659829943f5b18ed0b6513ad25fa3999e4cf59c
refs/heads/master
2020-04-01T13:53:16.896558
2014-09-12T11:24:29
2014-09-12T11:24:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
966
cc
random.cc
/** * @date Thu Mar 3 20:17:53 2011 +0100 * @author Laurent El Shafey <Laurent.El-Shafey@idiap.ch> * * @brief Test the random functions * * Copyright (C) Idiap Research Institute, Martigny, Switzerland */ #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE core-random Tests #define BOOST_TEST_MAIN #include <boost/test/unit_test.hpp> #include <blitz/array.h> #include <bob/core/check.h> #include <bob/core/array_random.h> struct T { }; BOOST_FIXTURE_TEST_SUITE( test_setup, T ) BOOST_AUTO_TEST_CASE( test_blitz_array_random ) { blitz::Array<double,2> x(1000,1000); boost::mt19937 rng; const double mean_ref = 1.; const double std_ref = 2.; bob::core::array::randn(rng, x, mean_ref, std_ref); double mean = blitz::mean(x); double std = sqrt(blitz::mean(blitz::pow2(x - mean))); BOOST_CHECK( bob::core::isClose( mean, mean_ref, 1e-2, 1e-2) ); BOOST_CHECK( bob::core::isClose( std, std_ref, 1e-2, 1e-2) ); } BOOST_AUTO_TEST_SUITE_END()
cbed4e9bfa4b782b461877f54df458fc702dc1aa
47a4b9901faf9742273b02ba14444d8d555b65a4
/CodeChef/XXOR.cpp
8593e1fae3c1b12fac05bf801f6c4b2606e2ef38
[]
no_license
Aulene/Competitive-Programming-Solutions
a028b7b96e024d8547e2ff66801e5377d7fb76cd
81d2705263313755399f2e3b6e01e029d40f61a6
refs/heads/master
2021-06-27T20:03:53.657351
2019-04-25T19:48:29
2019-04-25T19:48:29
101,798,734
3
0
null
null
null
null
UTF-8
C++
false
false
1,019
cpp
XXOR.cpp
#include <bits/stdc++.h> using namespace std; #define int long long int #define mod 1000000007 #define p push #define pb push_back #define mp make_pair #define f first #define s second int a[100007]; int bitz[100007][37]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, q, i, j, l, r, v, ans; int u = pow(2, 31) - 1; // cout << u << endl; cin >> n >> q; for(i = 1; i <= n; i++) cin >> a[i]; for(i = 1; i <= n; i++) { v = a[i]; for(j = 0; j < 31; j++) { bitz[i][j] = v % 2; v /= 2; } } for(i = 2; i <= n; i++) for(j = 0; j < 31; j++) bitz[i][j] += bitz[i - 1][j]; while(q--) { ans = 0; cin >> l >> r; v = 1, m = (r - l + 1); for(i = 0; i < 31; i++) { int a = bitz[r][i] - bitz[l - 1][i]; int diff = m - a; // cout << a << " " << diff << " " << v << " " << ans << endl; if(a < diff) ans += v; v *= 2; } cout << ans << endl; } return 0; }
1601bb18c0fe3b737a43eafc769b2469fee95d02
0ef4c9b88c10391c733b789d3260441c45c00400
/RPG/src/RPG.cpp
195743223dc1787f67d9a81ece17020cbb53eaa9
[]
no_license
imed-elhadef/RPG
d4cbb6aaa6b09339e40c6710c02b07d88bcb5395
34a4ed002593c3f6be07a9fed46f6cb76f064a08
refs/heads/master
2021-01-10T09:43:16.887310
2016-01-18T22:30:57
2016-01-18T22:30:57
48,595,588
0
0
null
null
null
null
UTF-8
C++
false
false
1,105
cpp
RPG.cpp
//============================================================================ // Name : RPG.cpp // Author : Imed Elhadef // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> #include <string> #include "Warrior.h" using namespace std; int main() { //Creation of Warriors Warrior *A(0),*B(0),*C(0); A= new Warrior(); B= new Warrior("Imed",200); C= new Warrior("Haroun",300); // Fight!! cout << "Fight!!!" << endl; A->attack(B); B->drinkPotionofLife(20); B->attack(C); A->magicattack(C); A->changeWeapon(100); B->attack(A); A->drinkPotionofLife(50); A->magicattack(C); //Number of warriors cout << "Number of Warriors is: " << Warrior::instance_nbr() << " Warriors" << endl; //Game Over cout << "A" << endl; A->displayStatus(); cout << endl << "B" << endl; B->displayStatus(); cout << endl << "C" << endl; C->displayStatus(); return 0; }
4ec652ef7f8f8cff7e2b39f3718ac9b54e0cd63b
ad4e2b9ef0dadca8dad8b5283b87dc15f4eb95e5
/CPP/guessing game/guessing_game.cpp
fa9798d7976cedbf9d423620626384b649ef5b71
[]
no_license
bamcod/PubCodeHub
0491b7f360b4012b78d9693322f25d8732d70ab9
d41e4aeeeb49e3ed82d4ec97850415a36698cb28
refs/heads/master
2021-01-18T03:09:35.129796
2013-09-03T15:09:37
2013-09-03T15:09:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,321
cpp
guessing_game.cpp
/** Guessing Game Copyright 2009 Travis Crowder travis.crowder@spechal.com Published under the MIT License */ #include <iostream> int main(int argc, char* argv[]){ /** Create our variable to hold the guess made */ int guess = 0; /** Let's keep track of the number of guesses made. */ int guesses = 0; /** Set the secret to be a random number between 1 and 100 Remember to seed the random number generator */ srand(time(0)); int secret = rand() % 100 + 1; /** while our guess is not the secret, get a guess */ while(guess != secret){ std::cout << "Enter your guess, between 1 and 100: "; std::cin >> guess; guesses++; if(guess == secret){ /** guess was correct */ std::cout << "You've figured out the secret in " << guesses; if(guesses == 1) std::cout << " guess"; else std::cout << " guesses"; std::cout << "! It was " << secret << "!" << std::endl; } else if(guess > secret){ /** guess was too high */ std::cout << "Your guess was too high! Try again!" << std::endl; } else { /** our guess can only be lower, logically */ std::cout << "Your guess was too low! Try again!" << std::endl; } } return 0; }
db1cc186cb1d2b195e6dd9d2bf726805895e275b
718fe3d88edc3413df945392d71fe2061945f8d4
/lab3/Задача 1.cpp
d2c808187df8d80f840ecdac7b7b9de372123c51
[]
no_license
AlekhinKirill/C-_labs
d93066bac1f9939770645a7490d0259d4a5d4da3
802635a19fe81410b83fe00a1dcff3ff1bce4dc7
refs/heads/main
2023-06-02T15:56:10.762903
2021-06-24T08:57:07
2021-06-24T08:57:07
334,904,041
0
0
null
null
null
null
UTF-8
C++
false
false
385
cpp
Задача 1.cpp
#include <iostream> using namespace std; int main() { int N, i, Answer; float mean, Sum_1; Sum_1 = 0; Answer = 0; cin >> N; int* arr = new int[N]; for (i = 0; i <= N - 1; i++) { cin >> arr[i]; Sum_1 += arr[i]; } mean = Sum_1 / N; for (i = 0; i <= N - 1; i++) { if (arr[i] > mean) { Answer += arr[i]; } } cout << Answer << endl; }
4939637195e48d1fec1af5b85faf9d7b4dd22dfb
7b75c44f2f80d215a85a8c0d98eb8945c5eacd9b
/TCPtest/src/server.cpp
716cbba4e77d77a3306c1ff8ec90fbee2ba376d2
[]
no_license
wangxizhe/TCPtest
2c77319e12aad0ddbdb6fe01c588137f7d3831ec
b028ce1c2459a75d8f2d7b19059ac0edc4044a0e
refs/heads/main
2023-01-10T03:49:56.203980
2020-11-10T10:46:07
2020-11-10T10:46:07
311,626,142
5
0
null
null
null
null
UTF-8
C++
false
false
5,615
cpp
server.cpp
/**************************** * 文件名:server.cpp * 创建人:东北大学-王希哲 * 描 述:东北大学无人驾驶实验室、TCP/IP、服务端 * 日 期:2020-11-5 * 版 本:1.0.0 ***************************/ #include "stdlib.h" #include <ros/ros.h> #include <pcl_ros/point_cloud.h> #include <pcl_ros/transforms.h> #include <tf/transform_listener.h> // PCL specific includes #include <sensor_msgs/PointCloud2.h> #include <pcl_conversions/pcl_conversions.h> #include <pcl/point_cloud.h> #include <pcl/point_types.h> #include <pcl/filters/voxel_grid.h> #include <pcl/filters/crop_box.h> #include <iostream> #include <pcl/filters/passthrough.h> #include <math.h> #include "std_msgs/String.h" //ros定义的String数据类型 #include <stdlib.h> #include <geometry_msgs/TwistWithCovarianceStamped.h> #include <nav_msgs/Odometry.h> #include <string> ////TCP // ROS #include <ros/ros.h> #include <string.h> #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> // ROS messages #include <sensor_msgs/NavSatFix.h> #include <sensor_msgs/Imu.h> #include <sensor_msgs/TimeReference.h> #include <geometry_msgs/TwistWithCovarianceStamped.h> #include <nav_msgs/Odometry.h> #include <std_msgs/String.h> #include<string> // Tf #include <tf/LinearMath/Quaternion.h> #include <tf/transform_datatypes.h> // UTM conversion //#include <gps_common/conversions.h> // Ethernet #include <arpa/inet.h> #include <sys/socket.h> #include <iconv.h> #include "dispatch.h" // UINT16_MAX is not defined by default in Ubuntu Saucy #ifndef UINT16_MAX #define UINT16_MAX (65535) #endif using namespace Eigen; using namespace std; static double pubHz = 1.0; using namespace std; class MMW_lidar { public: MMW_lidar() { sub_Yolo = nh.subscribe("/class_and_area", 1, &MMW_lidar::send_LL, this); //Set TCP std::string interface_tcp_server = ""; priv_nh.getParam("interface_tcp_server", interface_tcp_server); std::string ip_addr_tcp_server = "192.168.8.100"; priv_nh.getParam("ip_addr_tcp_server", ip_addr_tcp_server); int port_tcp_server = 65500; priv_nh.getParam("port_tcp_server", port_tcp_server); std::string interface_tcp_client = ""; priv_nh.getParam("interface_tcp_client", interface_tcp_client); std::string ip_addr_tcp_client = "192.168.8.101"; priv_nh.getParam("ip_addr_tcp_client", ip_addr_tcp_client); int port_tcp_client = 65500; priv_nh.getParam("port_tcp_client", port_tcp_client); priv_nh.getParam("pubHz", pubHz); countSet = (size_t)(100.0 / pubHz); // Variables Packet packet; sockaddr source; bool first = true; int fd; sockaddr_in sock; //Set TCP int server_sockfd; sockaddr_in server_sock; sockaddr_in client_sock; bool sendTCPPacket = false; char buf[BUFSIZ]; //BUFSIZ system defalut cache size. if(openTCPServerSocket(interface_tcp_server,ip_addr_tcp_server, port_tcp_server,&server_sockfd,&server_sock)){ if(listen(server_sockfd,5) < 0){ ROS_FATAL("Listen error"); }else{ socklen_t sin_size = sizeof (client_sock); if((client_sockfd = accept(server_sockfd,(struct sockaddr*)&client_sock, &sin_size)) < 0) { ROS_FATAL("Accept error"); }else{ sendTCPPacket= true; } } }else{ ROS_FATAL("Failed to open socketTCP"); } ROS_INFO("TCP link has been setup!"); } int recive_LL(); void send_LL(const std_msgs::String::ConstPtr& msg); bool openTCPServerSocket(const std::string &interface, const std::string &ip_addr, uint16_t port, int *fd_ptr, sockaddr_in *sock_ptr); private: ros::NodeHandle nh; ros::NodeHandle priv_nh; ros::Subscriber sub_Yolo ; int client_sockfd; int count2 = 0; int countSet = 500; int good = 0; }; bool MMW_lidar::openTCPServerSocket(const std::string &interface, const std::string &ip_addr, uint16_t port, int *fd_ptr, sockaddr_in *sock_ptr) { int fd; fd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); if(fd != -1){ if (interface.length()) { if (!setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, interface.c_str(), interface.length()) == 0) { close(fd); return false; } } memset(sock_ptr, 0, sizeof(sockaddr_in)); sock_ptr->sin_family = AF_INET; sock_ptr->sin_port = htons(port); if (!inet_aton(ip_addr.c_str(), &sock_ptr->sin_addr)) { sock_ptr->sin_addr.s_addr = INADDR_ANY; // Invalid address, use ANY } if (bind(fd, (sockaddr*)sock_ptr, sizeof(sockaddr)) == 0) { *fd_ptr = fd; return true; } } return false; } void MMW_lidar::send_LL(const std_msgs::String::ConstPtr& msg) { if(recive_LL()>0) { std::string result; result = msg->data.c_str(); const char* buffer = result.data(); if(send(client_sockfd, buffer,strlen(buffer), 0) < 0)//(char*)&buffer, sizeof(buffer) { ROS_FATAL("Write error"); } } } int MMW_lidar::recive_LL() { char recvBuf[1024]; memset(recvBuf, 0, sizeof(recvBuf)); recv(client_sockfd, recvBuf, sizeof(recvBuf), 0); return strlen(recvBuf); } int main(int argc, char** argv) { ros::init(argc, argv, "MMW_lidar"); MMW_lidar start_detec; ros::spin(); }
fe736cad45c8531fd4bf6c64bb8a0e553be0e16e
02e3fdee2aa285df6680f3ecfacc131ed60e71cd
/source/Sprite/Sprite.cpp
8f234e248ca11d8da296d0b8dfc4a763ecdb32f6
[ "MIT" ]
permissive
shyam-king/2DGame-engine
bf62e557a5f8caebfc72ce61e3d8010a9d43754a
9fb33cf33abeef86dbe26e18a3b8e380e0d5e961
refs/heads/master
2020-05-22T07:10:16.511761
2019-05-13T07:13:44
2019-05-13T07:13:44
186,258,256
1
0
null
null
null
null
UTF-8
C++
false
false
1,263
cpp
Sprite.cpp
#include<SDL.h> #include<SDL_image.h> #include<iostream> #include<vector> #include "Sprite.h" using namespace std; Sprite::Sprite(SDL_Renderer *Renderer, const char* ImageStrip, uint8_t n){ SDL_Surface *sur = IMG_Load(ImageStrip); nFrames = n; renderer = Renderer; int w = sur->w / nFrames; int h = sur->h; for (int i = 0; i < nFrames; i++){ SDL_Surface *f = SDL_CreateRGBSurface(0, w, h, sur->format->BitsPerPixel, sur->format->Rmask, sur->format->Gmask, sur->format->Bmask, sur->format->Amask); SDL_Rect src; src.x = w * i; src.y = 0; src.w = w; src.h = h; SDL_BlitSurface(sur, &src, f, NULL); frames.push_back(SDL_CreateTextureFromSurface(renderer, f)); SDL_FreeSurface(f); } frames.push_back(SDL_CreateTextureFromSurface(renderer, sur)); SDL_FreeSurface(sur); } Sprite::Sprite(SDL_Renderer* Renderer, const char *files[], uint8_t n){ nFrames = n; renderer = Renderer; for (int i = 0; i < n; i++){ SDL_Surface *sur = IMG_Load(files[i]); frames.push_back(SDL_CreateTextureFromSurface(renderer, sur)); SDL_FreeSurface(sur); } } Sprite::~Sprite(){ } void Sprite::drawFrame(uint8_t f, SDL_Rect *dest){ SDL_RenderCopy(renderer, frames.at(f), NULL, dest); }
81101719becb57cc90333af60d2330e1b3a21660
e9047b26c1633476c1326fb4a1ee3526e9bb69a0
/lab_4/test_1/test_1.cpp
271f71218216272a2ff5affa1f75a0dfcc21d21b
[]
no_license
manunia/labs_c
0a66112579198c26d91746916ba0905db99f2ec0
95a18e7cee2b1bae66334d2503c76a5871903841
refs/heads/master
2020-05-27T16:32:49.612816
2019-05-26T17:31:12
2019-05-26T17:31:12
188,702,034
0
0
null
null
null
null
UTF-8
C++
false
false
5,965
cpp
test_1.cpp
// test_1.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы. // #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdlib> using namespace std; //typedef int DataType; typedef std::string mark; typedef std::string country; typedef int year; typedef int volume; typedef int gas; typedef float price; typedef int num; class Element // класс, описывающий элемент односвязного списка { public: mark mark; country country; year year; volume volume; gas gas; price price; num count; Element* Next; Element() //конструктор элемента { Next = NULL; } }; class List // класс, описывающий односвязный список { Element* Begin, * End; public: List() //конструктор списка { Begin = End = NULL; } ~List() //деструктор списка { Element *Rex; while (Begin) { Rex = Begin; Begin = Begin->Next; delete Rex; } } void Add(char* file) //метод добавления элемента в конец списка { FILE* f; system("CLS"); if ((f = fopen(file, "ab")) == NULL) /* открываем для дозаписи */ { perror("Error open file"); system("pause"); return; } Element *Rex = new Element; cout << endl << "\tADD:" <<endl; cout << "\t\tEnter mark = "; cin >> Rex->mark; cout << "\t\tEnter country = "; cin >> Rex->country; cout << "\t\tEnter year = "; cin >> Rex->year; cout << "\t\tEnter volume = "; cin >> Rex->volume; cout << "\t\tEnter gas = "; cin >> Rex->gas; cout << "\t\tEnter price = "; cin >> Rex->price; cout << "\t\tEnter count = "; cin >> Rex->count; cout << "\tPress any key..." << endl << endl; if (Begin == NULL) { Begin = Rex; } else { End->Next = Rex; } End = Rex; fwrite(&Rex, sizeof(Rex), 1, f); fclose(f); } void Show (char* file) //печать списка { FILE* f; Element *Rex; int k = 0; system("CLS"); if ((f = fopen(file, "rb")) == NULL) /* открываем файл для чтения */ { perror("Error open file"); system("pause"); return; } cout << endl << "\tSHOW:" <<endl; if(!Begin) { cout << "\t\tList is empty!" << endl; cout << "\tPress any key..." << endl << endl; system("pause"); return; } cout << "\t\tMark" << "\t\tCountry" << "\t\tYear" << "\t\tVolume" << "\t\tGas" << "\t\tPrice" << "\t\tCount" << endl; Rex = Begin; while (fread(&Rex, sizeof(Rex), 1, f) == 1) { //while (Rex) { cout << "\t\t" << Rex->mark << "\t\t" << Rex->country << "\t\t" << Rex->year << "\t\t" << Rex->volume << "\t\t" << Rex->gas << "\t\t" << Rex->price << "\t\t" << Rex->count << endl; Rex = Rex->Next; //} } cout << "\tPress any key..." << endl << endl; fclose(f); system("pause"); } void print_one(Element* Rex) { cout << "\t\t" << Rex->mark << "\t\t" << Rex->country << "\t\t" << Rex->year << "\t\t" << Rex->volume << "\t\t" << Rex->gas << "\t\t" << Rex->price << "\t\t" << Rex->count << endl; } void Edit(char* file) { FILE* f; Element* Rex; float price, prise2; char yes; system("CLS"); if ((f = fopen(file, "rb+")) == NULL) // открываем файл для чтения и редактирования { perror("Error open file"); system("pause"); return; } Rex = Begin; printf("Price: "); fflush(stdin); scanf("%f", &price); while (fread(&Rex, sizeof(Rex), 1, f)) { if (Rex->price == price) // если совпадает { print_one(Rex); puts("\nRedact? (y/n)"); do { yes = getchar(); } while (yes != 'y' && yes != 'Y' && yes != 'n' && yes != 'N'); if (yes == 'y' || yes == 'Y') { // редактирование cout << "\t\tEnter new price = "; cin >> Rex->price; fseek(f, sizeof(Rex), SEEK_CUR); fwrite(&Rex, sizeof(Rex), 1, f); fseek(f, 0, SEEK_CUR); Rex = Rex->Next; } } } system("pause"); fclose(f); } void Search (char* file) { FILE* f; Element* Rex; int volume; system("CLS"); if ((f = fopen(file, "rb")) == NULL) // открываем файл для чтения { perror("Error open file"); system("pause"); return; } Rex = Begin; printf("Volume: "); fflush(stdin); scanf("%d", &volume); while (fread(&Rex, sizeof(Rex), 1, f)) { if (Rex->volume == volume) // если совпадает { print_one(Rex); Rex = Rex->Next; } } system("pause"); fclose(f); } void Min_gas(char* file) { FILE* f; Element* Rex; int min_gas = 0; system("CLS"); if ((f = fopen(file, "rb")) == NULL) // открываем файл для чтения { perror("Error open file"); system("pause"); return; } Rex = Begin; min_gas = Rex->gas; while (fread(&Rex, sizeof(Rex), 1, f)) { if (Rex->gas < min_gas) { min_gas = Rex->gas; } } cout << "\tMark with min gas: " << Rex->mark << endl; cout << "\tPress any key..." << endl << endl; system("pause"); fclose(f); } }; int main() { List L; char file[50]; char menu; puts("Name of file:"); gets_s(file); do { system("CLS"); puts("1. Add"); puts("2. Edit"); puts("3. Show"); puts("4. Search"); puts("5. Search mark with min gas"); puts("6. Exit"); menu = getchar(); switch (menu) { case '1': L.Add(file); break; case '2': L.Edit(file); break; case '3': L.Show(file); break; case '4': L.Search(file); break; case '5': L.Min_gas(file); } } while (menu != '6'); return 0; }
43eff9fcb5574643daa8fde36f2c5215739529bd
4f80e47a9ccf9e43362daa7a9b5c50d6c3f2b3ee
/ui.h
3231249f6fe1a89af3f5f9b6f2ba453849d35ab8
[]
no_license
cybaer/derMehrschritt
23a4b83091762f75a6965efc753850decc49c75b
83958cb237b915be52bfa34def56b332b9183429
refs/heads/master
2020-04-05T22:57:50.078978
2019-01-11T17:36:41
2019-01-11T17:36:41
41,742,806
2
0
null
null
null
null
UTF-8
C++
false
false
2,640
h
ui.h
/* * ui.h * * Created on: 17.11.2015 * Author: cybaer */ #ifndef UI_H_ #define UI_H_ #include "HardwareConfig.h" using namespace avrlib; class App; static const bool GREEN = false; static const bool RED = true; // Switch_Row_Column static const uint32_t SW_1_1 = 0x00000001; static const uint32_t SW_1_2 = 0x00000002; static const uint32_t SW_1_3 = 0x00000004; static const uint32_t SW_1_4 = 0x00000008; static const uint32_t SW_2_1 = 0x00000100; static const uint32_t SW_2_2 = 0x00000200; static const uint32_t SW_2_3 = 0x00000400; static const uint32_t SW_2_4 = 0x00000800; static const uint32_t SW_3_1 = 0x00010000; static const uint32_t SW_3_2 = 0x00020000; static const uint32_t SW_3_3 = 0x00040000; static const uint32_t SW_3_4 = 0x00080000; static const uint32_t SW_4_1 = 0x01000000; static const uint32_t SW_4_2 = 0x02000000; static const uint32_t SW_4_3 = 0x04000000; static const uint32_t SW_4_4 = 0x08000000; static const uint32_t SW_COLUMN4 = SW_1_4 | SW_2_4 | SW_3_4 | SW_4_4; static const uint32_t SW_1_AND_4_COLUMN4 = SW_1_4 | SW_4_4; static const uint32_t SW_1_AND_4_COLUMN3 = SW_1_3 | SW_4_3; class Ui { public: Ui(void); void init(void); void poll(void); void doEvents(void); void OnClock(void); LedRow_1 m_LedRow_1; LedRow_2 m_LedRow_2; LedRow_3 m_LedRow_3; LedRow_4 m_LedRow_4; LEDGroupBase* m_LedRows[4]; LED_17 m_SuperLed; //LED_16 led16; SwitchRow_1 m_SwitchRow_1; SwitchRow_2 m_SwitchRow_2; SwitchRow_3 m_SwitchRow_3; SwitchRow_4 m_SwitchRow_4; SwitchGroupBase* m_SwitchRows[4]; typedef union { uint8_t Array[4]; uint32_t Int;} SwitchActive_t; SwitchActive_t m_SwitchesActive; SWITCH_17 m_SuperSwitch; //Display m_Display; Encoder m_Encoder; private: void readSwitchMatrix(void); void testSwitchLED(void); bool isScanMode(void); int8_t m_Xcrement; int16_t m_Encoder_hold_time; class IUiState { public: //** Empty Constructor */ IUiState(void) {} virtual void onEntry(Ui&) const {} virtual void onExit(Ui&) const {} virtual void onClick(Ui&, int8_t row, int8_t index) const {} private: /** Forbidden */ DISALLOW_COPY_AND_ASSIGN (IUiState); }; /** * State machine */ class CXYState: public IUiState { public: static CXYState& getInstance(void) { static CXYState s_instance; return s_instance; } virtual void onEntry(Ui&) const; virtual void onModeClick(Ui&, int8_t index) const; }; void setState(IUiState& state) { m_State->onExit(*this); m_State = &state; m_State->onEntry(*this); } IUiState* m_State; }; extern Ui ui; #endif
dc2b140b1ae894b1a67c2eafd80f964e3cbbedf9
af82fd89093f68794e854838f1f511869a3a19b4
/src/gui/Album/Filter/guiAlbumFilter.h
17bdf5cf3ee72acf0f76f60407142275c781c53c
[]
no_license
Beber7310/BoomGUI
6f76054aa52f1c42de4712b3f8abddd2ac9038e7
758c61dcbd6ca93133b72b34f10b3666de106f34
refs/heads/master
2023-03-30T02:22:31.159385
2021-03-27T16:50:56
2021-03-27T16:50:56
103,022,181
0
0
null
null
null
null
UTF-8
C++
false
false
582
h
guiAlbumFilter.h
/* * guiAlbumFilter.h * * Created on: Sep 14, 2017 * Author: dosdab */ #ifndef SRC_GUI_ALBUM_GUIALBUMFILTER_H_ #define SRC_GUI_ALBUM_GUIALBUMFILTER_H_ #include <guiBase.h> #include <guiList.h> #include <guiButton.h> #include <guiItemFilter.h> class guiAlbumFilter: public guiBase { public: guiAlbumFilter(); virtual ~guiAlbumFilter(); void selectAll(bool sel); void event(int x, int y, int button); guiItemFilter* AddFilter(char* szGenre); guiList* wndLstFlt; guiButton* wndBtnBack; }; #endif /* SRC_GUI_ALBUM_GUIALBUMFILTER_H_ */
8ef84363f170bbb269aadbf954135bd4ea314263
e3e93008a40c0e8f5945a146fb22ab97c0520495
/GeneralGUI/GeneralGUI/GGUIInputProcess.cpp
da56f4a8cb06e73a28f73651fbdfca3dcea293ae
[]
no_license
cnsuhao/GeneralGUI
32c0a74702982d2d59abc1cf0bf0d718a368295b
cb42bd3eb39729fc4597329ea79510222cf6f1e1
refs/heads/master
2021-05-31T23:27:46.203540
2016-04-10T10:53:30
2016-04-10T10:53:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,026
cpp
GGUIInputProcess.cpp
//----------------------------------------------------------------------------- // GGUI处理用户的输入 // (C) oil // 2012-09-26 //----------------------------------------------------------------------------- #include "GGUIStdAfx.h" #include "GGUIInputProcess.h" #include "GGUIWindow.h" #include "GGUIWindowManager.h" //----------------------------------------------------------------------------- namespace GGUI { //----------------------------------------------------------------------------- GGUIInputProcess::GGUIInputProcess() :m_eCurrentMouseOpState(MouseOp_None) ,m_fMousePosX(0.0f) ,m_fMousePosY(0.0f) ,m_theWindowContainMouse(Invalid_WindowID) { } //----------------------------------------------------------------------------- GGUIInputProcess::~GGUIInputProcess() { ReleaseInputProcess(); } //----------------------------------------------------------------------------- bool GGUIInputProcess::InitInputProcess() { return true; } //----------------------------------------------------------------------------- void GGUIInputProcess::ReleaseInputProcess() { } //----------------------------------------------------------------------------- bool GGUIInputProcess::OnMouseMove(SoFloat fNewPosX, SoFloat fNewPosY) { m_fMousePosX = fNewPosX; m_fMousePosY = fNewPosY; // bool bResult = false; //判断鼠标是否落在了用户窗口的外面。 bool bOutOfScreen = IsMouseOutOfScreen(fNewPosX, fNewPosY); //判断鼠标落在了哪个窗口内部。 WindowID theOldWindowWhoContainMouse = m_theWindowContainMouse; WindowID theNewWindowWhoContainMouse = Invalid_WindowID; if (!bOutOfScreen) { //如果之前鼠标落在了一个窗口内,则先判断鼠标是否仍然落在那个窗口内。 //这里没有考虑那个窗口是否有子窗口。 if (theOldWindowWhoContainMouse != Invalid_WindowID) { GGUIWindow* pOldWindow = GGUIWindowManager::GetInstance()->GetUIWindow(theOldWindowWhoContainMouse); if (pOldWindow && pOldWindow->GetVisible() && pOldWindow->CheckMouseInWindowArea(fNewPosX, fNewPosY)) { theNewWindowWhoContainMouse = theOldWindowWhoContainMouse; } } //如果不确定鼠标落在哪个窗口内,则遍历所有的窗口。 if (theNewWindowWhoContainMouse == Invalid_WindowID) { theNewWindowWhoContainMouse = GetWindowWhoContainMouse(fNewPosX, fNewPosY); } } //处理“鼠标落入了一个窗口矩形范围”的逻辑。 if (theOldWindowWhoContainMouse != theNewWindowWhoContainMouse) { m_theWindowContainMouse = theNewWindowWhoContainMouse; if (theOldWindowWhoContainMouse != Invalid_WindowID) { MouseLeaveWindowArea(theOldWindowWhoContainMouse); bResult = true; } if (theNewWindowWhoContainMouse != Invalid_WindowID) { MouseEnterWindowArea(theNewWindowWhoContainMouse); bResult = true; } } // return bResult; } //----------------------------------------------------------------------------- bool GGUIInputProcess::OnMouseLeftButtonDown() { bool bResult = false; if (m_theWindowContainMouse != Invalid_WindowID) { GGUIWindow* pTheWindow = GGUIWindowManager::GetInstance()->GetUIWindow(m_theWindowContainMouse); if (pTheWindow && pTheWindow->GetEnable()) { pTheWindow->OnMouseLeftButtonClickDown(); } } return bResult; } //----------------------------------------------------------------------------- bool GGUIInputProcess::OnMouseLeftButtonUp() { bool bResult = false; if (m_theWindowContainMouse != Invalid_WindowID) { GGUIWindow* pTheWindow = GGUIWindowManager::GetInstance()->GetUIWindow(m_theWindowContainMouse); if (pTheWindow && pTheWindow->GetEnable()) { pTheWindow->OnMouseLeftButtonClickUp(); } } return bResult; } //----------------------------------------------------------------------------- void GGUIInputProcess::MouseEnterWindowArea(WindowID theWindow) { GGUIWindow* pWindow = GGUIWindowManager::GetInstance()->GetUIWindow(theWindow); if (pWindow) { pWindow->OnMouseEnterWindowArea(); } } //----------------------------------------------------------------------------- void GGUIInputProcess::MouseLeaveWindowArea(WindowID theWindow) { GGUIWindow* pWindow = GGUIWindowManager::GetInstance()->GetUIWindow(theWindow); if (pWindow) { pWindow->OnMouseLeaveWindowArea(); } } //----------------------------------------------------------------------------- WindowID GGUIInputProcess::GetWindowWhoContainMouse(SoFloat fMousePosX, SoFloat fMousePosY) { WindowID theResult = Invalid_WindowID; GGUIWindowManager* pWindowContainer = GGUIWindowManager::GetInstance(); SoInt nIndex = 0; GGUIWindow* pWindow = NULL; while (pWindowContainer->Next(nIndex, pWindow)) { if (pWindow->GetVisible() && pWindow->CheckMouseInWindowArea(fMousePosX, fMousePosY)) { theResult = pWindow->GetWindowID(); break; } } return theResult; } } //-----------------------------------------------------------------------------
177b77bf5669e54f0db34db20b8178b393cfdb93
af0ecafb5428bd556d49575da2a72f6f80d3d14b
/CodeJamCrawler/dataset/10_119_76.cpp
b332a69141dd066a0a63254851c14318e864ed93
[]
no_license
gbrlas/AVSP
0a2a08be5661c1b4a2238e875b6cdc88b4ee0997
e259090bf282694676b2568023745f9ffb6d73fd
refs/heads/master
2021-06-16T22:25:41.585830
2017-06-09T06:32:01
2017-06-09T06:32:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,557
cpp
10_119_76.cpp
#include <iostream> #include <cstdio> using namespace std; int main(){ int T, R, k, N; int gs[1001]= {0}; bool sign[1001] = {false}; int ns[1001] = {0}; int nsum[1001] = {0}; int next[1001] = {0}; cin >> T; for(int i = 1; i <= T; ++i){ cin >> R >> k >> N; for(int jx = 0; jx < N; ++jx){ cin >> gs[jx]; sign[jx] = false; } int j = 0, loopS =0, loopLen = 0; for(int nn = 1; nn <= (N+1); ++nn){ if (sign[j]){ loopS = j; loopLen = nn - ns[j]; break; }else sign[j] = true; int tk = k - gs[j]; int m = (j + 1) % N; while(m != j && tk >= gs[m]){ tk -= gs[m]; m = m + 1; if(m >= N) m -= N; } next[j] = m; nsum[j] = k - tk ; ns[j] = nn; j = m; } int sum = 0, loopSum = 0, beforeLoopSum = 0, beforeLoopNum = 0; bool visited = false; int csn = 1; for(int m = 0; m < N && csn <= R; m = next[m], ++csn){ if (m == loopS){ if (visited){ loopSum = sum; break; } beforeLoopSum = sum; beforeLoopNum = csn - 1; sum = 0; visited = true; } sum += nsum[m]; nsum[m] = sum; } __int64 res = 0; if (csn > R) res = sum + beforeLoopSum; else{ int x = (R - beforeLoopNum) % loopLen; __int64 nx = (R - beforeLoopNum) / loopLen; res = beforeLoopSum + nx * loopSum; if (x > 0){ int stop = loopS, xx = 1; for(; xx < x ; ++xx) stop = next[stop]; res += nsum[stop]; } } printf("Case #%d: %I64d\n", i, res); } }
b6a46213c653b98f37c0c0afd968cd44c69ebc62
a457cab53804a9eb9a8f6a4da1f05f00ab2917ad
/lib/JsonStaticString/JsonStaticString.h
9d72dc14c0b4f3444ff7c25fcc8c50801237a54f
[ "MIT" ]
permissive
vt77/WeatherStation-outdoor-sensor
5ca595cd8a501492c0de24e8d0380a69bfdbfcc0
c5a91794a421ece85844a93664c20745f1657e8a
refs/heads/main
2023-08-21T19:20:31.104365
2021-10-14T16:05:14
2021-10-14T16:05:14
390,832,290
2
0
null
null
null
null
UTF-8
C++
false
false
1,500
h
JsonStaticString.h
#ifndef __JSON_STATIC_STRING #define __JSON_STATIC_STRING #include <string.h> namespace vt77 { #define MAX_STRING_VALUE_LEN 96 template <unsigned S> class JsonStaticString { private: char buffer[S]; bool _append_pair(const char * key, const char * value) { if(strlen(buffer) + strlen(key) + strlen(value) + 4 >= S) return false; if(strlen(buffer)>1) strcat(buffer,", "); char * ptr = buffer + strlen(buffer); sprintf(ptr,"\"%s\":%s",key,value); return true; } public: bool insert(const char * key, const char * value){ char tmp[MAX_STRING_VALUE_LEN]; sprintf(tmp,"\"%s\"",value); return _append_pair(key,tmp); } bool insert(const char * key, const int value){ char number[16]; sprintf(number,"%d",value); return _append_pair(key,number); } bool insert(const char * key, double value, int precision=2){ char format[16]; char number[16]; sprintf(format,"%%.%df",precision); sprintf(number,format,value); return _append_pair(key,number); } void start() { strcpy(buffer,"{"); } void close() { strcat(buffer,"}"); } operator const char*()const { return buffer; } }; } #endif
c8ee20434a09933ede269d377e2f9219fe824e25
e07399ac7a4b7928e62a1b59155ee0d04e423d4f
/clients/include/blas1/testing_rotm_strided_batched.hpp
c22155a1d89822412f854832cf49655869e23da4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
zaliu/rocBLAS
bf5cca20c7af9004034a00489d5bc3956abf07a3
a42b39f2651d6995eb88a4df3bacb1e77f0df41f
refs/heads/master
2021-10-27T15:01:06.651380
2021-08-31T19:07:01
2021-08-31T19:07:01
124,825,140
0
0
MIT
2018-03-12T02:52:00
2018-03-12T02:52:00
null
UTF-8
C++
false
false
14,693
hpp
testing_rotm_strided_batched.hpp
/* ************************************************************************ * Copyright 2018-2021 Advanced Micro Devices, Inc. * ************************************************************************ */ #pragma once #include "cblas_interface.hpp" #include "norm.hpp" #include "rocblas.hpp" #include "rocblas_init.hpp" #include "rocblas_math.hpp" #include "rocblas_random.hpp" #include "rocblas_test.hpp" #include "rocblas_vector.hpp" #include "unit.hpp" #include "utility.hpp" template <typename T> void testing_rotm_strided_batched_bad_arg(const Arguments& arg) { const bool FORTRAN = arg.fortran; auto rocblas_rotm_strided_batched_fn = FORTRAN ? rocblas_rotm_strided_batched<T, true> : rocblas_rotm_strided_batched<T, false>; rocblas_int N = 100; rocblas_int incx = 1; rocblas_stride stride_x = 1; rocblas_int incy = 1; rocblas_stride stride_y = 1; rocblas_stride stride_param = 1; rocblas_int batch_count = 5; static const size_t safe_size = 100; rocblas_local_handle handle{arg}; device_vector<T> dx(safe_size); device_vector<T> dy(safe_size); device_vector<T> dparam(safe_size); CHECK_DEVICE_ALLOCATION(dx.memcheck()); CHECK_DEVICE_ALLOCATION(dy.memcheck()); CHECK_DEVICE_ALLOCATION(dparam.memcheck()); CHECK_ROCBLAS_ERROR(rocblas_set_pointer_mode(handle, rocblas_pointer_mode_device)); EXPECT_ROCBLAS_STATUS( (rocblas_rotm_strided_batched_fn( nullptr, N, dx, incx, stride_x, dy, incy, stride_y, dparam, stride_param, batch_count)), rocblas_status_invalid_handle); EXPECT_ROCBLAS_STATUS((rocblas_rotm_strided_batched_fn(handle, N, nullptr, incx, stride_x, dy, incy, stride_y, dparam, stride_param, batch_count)), rocblas_status_invalid_pointer); EXPECT_ROCBLAS_STATUS((rocblas_rotm_strided_batched_fn(handle, N, dx, incx, stride_x, nullptr, incy, stride_y, dparam, stride_param, batch_count)), rocblas_status_invalid_pointer); EXPECT_ROCBLAS_STATUS( (rocblas_rotm_strided_batched_fn( handle, N, dx, incx, stride_x, dy, incy, stride_y, nullptr, stride_param, batch_count)), rocblas_status_invalid_pointer); } template <typename T> void testing_rotm_strided_batched(const Arguments& arg) { const bool FORTRAN = arg.fortran; auto rocblas_rotm_strided_batched_fn = FORTRAN ? rocblas_rotm_strided_batched<T, true> : rocblas_rotm_strided_batched<T, false>; rocblas_int N = arg.N; rocblas_int incx = arg.incx; rocblas_int stride_x = arg.stride_x; rocblas_int stride_y = arg.stride_y; rocblas_int stride_param = arg.stride_c; rocblas_int incy = arg.incy; rocblas_int batch_count = arg.batch_count; rocblas_local_handle handle{arg}; double gpu_time_used, cpu_time_used; double norm_error_host_x = 0.0, norm_error_host_y = 0.0, norm_error_device_x = 0.0, norm_error_device_y = 0.0; const T rel_error = std::numeric_limits<T>::epsilon() * 1000; // check to prevent undefined memory allocation error if(N <= 0 || batch_count <= 0) { CHECK_ROCBLAS_ERROR(rocblas_set_pointer_mode(handle, rocblas_pointer_mode_device)); EXPECT_ROCBLAS_STATUS((rocblas_rotm_strided_batched_fn(handle, N, nullptr, incx, stride_x, nullptr, incy, stride_y, nullptr, stride_param, batch_count)), rocblas_status_success); return; } rocblas_int abs_incx = incx >= 0 ? incx : -incx; rocblas_int abs_incy = incy >= 0 ? incy : -incy; size_t size_x = N * size_t(abs_incx) + size_t(stride_x) * size_t(batch_count - 1); size_t size_y = N * size_t(abs_incy) + size_t(stride_y) * size_t(batch_count - 1); size_t size_param = 5 + size_t(stride_param) * size_t(batch_count - 1); device_vector<T> dx(size_x); device_vector<T> dy(size_y); device_vector<T> dparam(size_param); CHECK_DEVICE_ALLOCATION(dx.memcheck()); CHECK_DEVICE_ALLOCATION(dy.memcheck()); CHECK_DEVICE_ALLOCATION(dparam.memcheck()); // Initial Data on CPU host_vector<T> hx(size_x); host_vector<T> hy(size_y); host_vector<T> hdata(4 * batch_count); host_vector<T> hparam(size_param); rocblas_seedrand(); if(rocblas_isnan(arg.alpha)) { rocblas_init_nan<T>(hx, 1, N, abs_incx, stride_x, batch_count); rocblas_init_nan<T>(hy, 1, N, abs_incy, stride_y, batch_count); rocblas_init_nan<T>(hdata, 1, 4, 1, 4, batch_count); } else { rocblas_init<T>(hx, 1, N, abs_incx, stride_x, batch_count); rocblas_init<T>(hy, 1, N, abs_incy, stride_y, batch_count); rocblas_init<T>(hdata, 1, 4, 1, 4, batch_count); } // CPU BLAS reference data for(int b = 0; b < batch_count; b++) cblas_rotmg<T>(hdata + b * 4, hdata + b * 4 + 1, hdata + b * 4 + 2, hdata + b * 4 + 3, hparam + b * stride_param); constexpr int FLAG_COUNT = 4; const T FLAGS[FLAG_COUNT] = {-1, 0, 1, -2}; for(int i = 0; i < FLAG_COUNT; i++) { for(int b = 0; b < batch_count; b++) (hparam + b * stride_param)[0] = FLAGS[i]; host_vector<T> cx = hx; host_vector<T> cy = hy; cpu_time_used = get_time_us_no_sync(); for(int b = 0; b < batch_count; b++) { cblas_rotm<T>( N, cx + b * stride_x, incx, cy + b * stride_y, incy, hparam + b * stride_param); } cpu_time_used = get_time_us_no_sync() - cpu_time_used; if(arg.unit_check || arg.norm_check) { // Test rocblas_pointer_mode_host // TODO: THIS IS NO LONGER SUPPORTED // { // CHECK_ROCBLAS_ERROR(rocblas_set_pointer_mode(handle, rocblas_pointer_mode_host)); // CHECK_HIP_ERROR(hipMemcpy(dx, hx, sizeof(T) * size_x, hipMemcpyHostToDevice)); // CHECK_HIP_ERROR(hipMemcpy(dy, hy, sizeof(T) * size_y, hipMemcpyHostToDevice)); // CHECK_ROCBLAS_ERROR((rocblas_rotm_strided_batched_fn( // handle, N, dx, incx, stride_x, dy, incy, stride_y, hparam, batch_count))); // host_vector<T> rx(size_x); // host_vector<T> ry(size_y); // CHECK_HIP_ERROR(hipMemcpy(rx, dx, sizeof(T) * size_x, hipMemcpyDeviceToHost)); // CHECK_HIP_ERROR(hipMemcpy(ry, dy, sizeof(T) * size_y, hipMemcpyDeviceToHost)); // if(arg.unit_check) // { // T rel_error = std::numeric_limits<T>::epsilon() * 1000; // near_check_general<T,T>(1, N, batch_count, incx, stride_x, cx, rx, rel_error); // near_check_general<T,T>(1, N, batch_count, incy, stride_y, cy, ry, rel_error); // } // if(arg.norm_check) // { // norm_error_host_x // = norm_check_general<T>('F', 1, N, incx, stride_x, batch_count, cx, rx); // norm_error_host_y // = norm_check_general<T>('F', 1, N, incy, stride_x, batch_count, cy, ry); // } // } // Test rocblas_pointer_mode_device { CHECK_ROCBLAS_ERROR(rocblas_set_pointer_mode(handle, rocblas_pointer_mode_device)); CHECK_HIP_ERROR(hipMemcpy(dx, hx, sizeof(T) * size_x, hipMemcpyHostToDevice)); CHECK_HIP_ERROR(hipMemcpy(dy, hy, sizeof(T) * size_y, hipMemcpyHostToDevice)); CHECK_HIP_ERROR( hipMemcpy(dparam, hparam, sizeof(T) * size_param, hipMemcpyHostToDevice)); CHECK_ROCBLAS_ERROR((rocblas_rotm_strided_batched_fn(handle, N, dx, incx, stride_x, dy, incy, stride_y, dparam, stride_param, batch_count))); host_vector<T> rx(size_x); host_vector<T> ry(size_y); CHECK_HIP_ERROR(hipMemcpy(rx, dx, sizeof(T) * size_x, hipMemcpyDeviceToHost)); CHECK_HIP_ERROR(hipMemcpy(ry, dy, sizeof(T) * size_y, hipMemcpyDeviceToHost)); //when (input vectors are initialized with NaN's) the resultant output vector for both the cblas and rocBLAS are NAn's. The `near_check_general` function compares the output of both the results (i.e., Nan's) and //throws an error. That is the reason why it is enclosed in an `if(!rocblas_isnan(arg.alpha))` loop to skip the check. if(!rocblas_isnan(arg.alpha)) { if(arg.unit_check) { near_check_general<T>( 1, N, abs_incx, stride_x, cx, rx, batch_count, rel_error); near_check_general<T>( 1, N, abs_incy, stride_y, cy, ry, batch_count, rel_error); } } if(arg.norm_check) { norm_error_device_x += norm_check_general<T>( 'F', 1, N, abs_incx, stride_x, cx, rx, batch_count); norm_error_device_y += norm_check_general<T>( 'F', 1, N, abs_incy, stride_y, cy, ry, batch_count); } } } } if(arg.timing) { // Initializing flag value to -1 for all the batches of hparam for(int b = 0; b < batch_count; b++) { (hparam + b * stride_param)[0] = FLAGS[0]; } int number_cold_calls = arg.cold_iters; int number_hot_calls = arg.iters; CHECK_ROCBLAS_ERROR(rocblas_set_pointer_mode(handle, rocblas_pointer_mode_device)); CHECK_HIP_ERROR(hipMemcpy(dx, hx, sizeof(T) * size_x, hipMemcpyHostToDevice)); CHECK_HIP_ERROR(hipMemcpy(dy, hy, sizeof(T) * size_y, hipMemcpyHostToDevice)); CHECK_HIP_ERROR(hipMemcpy(dparam, hparam, sizeof(T) * size_param, hipMemcpyHostToDevice)); for(int iter = 0; iter < number_cold_calls; iter++) { rocblas_rotm_strided_batched_fn(handle, N, dx, incx, stride_x, dy, incy, stride_y, dparam, stride_param, batch_count); } hipStream_t stream; CHECK_ROCBLAS_ERROR(rocblas_get_stream(handle, &stream)); gpu_time_used = get_time_us_sync(stream); // in microseconds for(int iter = 0; iter < number_hot_calls; iter++) { rocblas_rotm_strided_batched_fn(handle, N, dx, incx, stride_x, dy, incy, stride_y, dparam, stride_param, batch_count); } gpu_time_used = (get_time_us_sync(stream) - gpu_time_used); ArgumentModel<e_N, e_incx, e_incy, e_stride_x, e_stride_y, e_batch_count>{}.log_args<T>( rocblas_cout, arg, gpu_time_used, rotm_gflop_count<T>(N, (hparam + 0 * stride_param)[0]), rotm_gbyte_count<T>(N, (hparam + 0 * stride_param)[0]), cpu_time_used, norm_error_device_x, norm_error_device_y); } }
fc6242a92bd954cb83921bba28094c6d35e996d5
3ae56c7a147fc50a3b7cb1b8285aec38624a60b6
/src/game.h
c94d4916943b507d4a2b4c526ecbf9698c37a9eb
[]
no_license
SS47816/CppND-Capstone-Snake-Game
e87056c01f7a962b6786fffd96bc298d731949ba
6c415b31a8f773d58e9188ce604ce4ec91bdea44
refs/heads/master
2022-10-11T18:58:48.737337
2020-06-13T23:23:24
2020-06-13T23:23:24
271,861,281
0
0
null
2020-06-12T18:06:12
2020-06-12T18:06:11
null
UTF-8
C++
false
false
639
h
game.h
#ifndef GAME_H #define GAME_H #include <random> #include <memory> #include "SDL.h" #include "controller.h" #include "renderer.h" #include "snake.h" #include "food.h" #include "obstacle.h" class Game { public: Game(std::size_t grid_width, std::size_t grid_height); void Run(Controller const &controller, Renderer &renderer, std::size_t target_frame_duration); int GetScore() const; int GetSize() const; private: std::shared_ptr<Snake> snake; std::shared_ptr<Food> food; std::shared_ptr<Obstacle> obstacles; int grid_width; int grid_height; int score{0}; void PlaceFood(); void Update(); }; #endif
4652f6135e07f967bbef68d73ad67f37ce50b62c
15a35df4de841aa5c504dc4f8778581c00397c87
/Server1/Engine/Ext/netdsdk/include/EpollReactor.inl
af8e229daefb45f01db374fcf106c9af146cc2e0
[]
no_license
binbin88115/server
b6197fef8f35276ff7bdf471a025091d65f96fa9
e3c178db3b6c6552c60b007cac8ffaa6d3c43c10
refs/heads/master
2021-01-15T13:49:38.647852
2014-05-05T12:47:20
2014-05-05T12:47:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,961
inl
EpollReactor.inl
inline EpollReactorHandlerRepository::EpollReactorHandlerRepository () : max_size_ (0) , handlers_ (0) { } inline int EpollReactorHandlerRepository::is_invalid_handle (NDK_HANDLE handle) const { if (handle < 0 || handle >= this->max_size_) return 1; return 0; } inline int EpollReactorHandlerRepository::handle_in_range (NDK_HANDLE handle) const { if (handle >= 0 && handle < this->max_size_) return 1; return 0; } inline void EpollReactorHandlerRepository::mask (NDK_HANDLE handle, ReactorMask mask) { if (this->handle_in_range (handle)) this->handlers_[handle].mask = mask; } inline ReactorMask EpollReactorHandlerRepository::mask (NDK_HANDLE handle) { if (this->handle_in_range (handle)) return this->handlers_[handle].mask; return EventHandler::NULL_MASK; } //---------------------------------------------------------------------------- inline EpollEventTuple::EpollEventTuple () : event_handler (0) , mask (EventHandler::NULL_MASK) { } //---------------------------------------------------------------------------- inline int EpollReactor::upcall (EventHandler *event_handler, int (EventHandler::*callback)(NDK_HANDLE), NDK_HANDLE handle) { return (event_handler->*callback)(handle); } inline int EpollReactor::notify (EventHandler *event_handler/* = 0*/, ReactorMask mask/* = EventHandler::EXCEPT_MASK*/, const TimeValue *timeout/* = 0*/) { return this->notify_handler_->notify (event_handler, mask, timeout); } //--------------------------------------------------------------------------------- inline EpollReactor::TokenGuard::TokenGuard (ReactorToken &token) : token_(token) , owner_ (0) { } inline EpollReactor::TokenGuard::~TokenGuard () { this->release_token (); } inline void EpollReactor::TokenGuard::release_token () { if (this->owner_ == 1) { this->token_.release (); this->owner_ = 0; } } inline int EpollReactor::TokenGuard::is_owner () { return this->owner_; }
5cde2adb7d9dd32030f5852f96fca828ff2ad04a
d8dcee749abdc9d7d9541bc7fbcdfad393399ec6
/DataFillers/interface/FillerEventInfo.hh
d7d09a0f7a53098a3ca4dff529f2430b4ed43479
[]
no_license
xmniu/ZCounting
c6e4263baa651fb8301df0a77d327b798442ad17
ad7302c39a430ec8c4600b47d968d871d5a7d1d6
refs/heads/master
2021-01-20T09:44:43.724094
2017-05-05T13:08:31
2017-05-05T13:08:31
90,280,104
0
0
null
null
null
null
UTF-8
C++
false
false
1,914
hh
FillerEventInfo.hh
#ifndef ZCOUNTING_DATAFILLERS_FILLEREVENTINFO_HH #define ZCOUNTING_DATAFILLERS_FILLEREVENTINFO_HH #include <string> #include "FWCore/Framework/interface/Frameworkfwd.h" // declaration of EDM types #include "FWCore/Framework/interface/EDAnalyzer.h" // EDAnalyzer class #include "FWCore/ParameterSet/interface/ParameterSet.h" // Parameters #include "FWCore/Utilities/interface/InputTag.h" #include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" #include "FWCore/Framework/interface/MakerMacros.h" // definitions for declaring plug-in modules #include "FWCore/Framework/interface/ConsumesCollector.h" #include "DataFormats/BeamSpot/interface/BeamSpot.h" // forward class declarations #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "ZCounting/DataFormats/interface/MiniBaconDefs.hh" namespace trigger { class TriggerEvent; } namespace baconhep { class TEventInfo; // foward declaration class FillerEventInfo { public: FillerEventInfo(const edm::ParameterSet &iConfig,edm::ConsumesCollector && iC); ~FillerEventInfo(); void fill(TEventInfo *evtInfo, // output object to be filled const edm::Event &iEvent, // EDM event info const reco::Vertex &pv, // event primary vertex const bool hasGoodPV, // flag for if PV passing cuts is found const TriggerBits triggerBits);//, // bits for corresponding fired triggers // TSusyGen *susyGen=0); // output for SUSY objects protected: // EDM object collection names std::string fPUInfoName; edm::EDGetTokenT<std::vector<PileupSummaryInfo> > fPUInfoName_token; std::string fBSName; edm::EDGetTokenT<reco::BeamSpot> fBSName_token; }; } #endif
8493622996d043d2171f7095b6e1cbacf9449534
44594e9517af2fb8e858f2e8f5da88ecfc701ddd
/custom-moos/MOOS_Jul0519/MOOSCore/Core/libMOOS/DB/ATLASLinkConsumer.cpp
98a8a98f8b7e4372f84c2dc4f0c095149db96092
[]
no_license
jrharbin-york/atlas-middleware
1dd53bc0531d17aeabcaa00d85ec4ca1ce7a3787
cfbd357746b0214483a367439c3efff9b8e2e3a1
refs/heads/master
2022-08-15T03:06:14.479239
2021-05-20T21:21:19
2021-05-20T21:21:19
212,563,034
0
3
null
2020-12-04T03:36:25
2019-10-03T11:27:46
C++
UTF-8
C++
false
false
3,712
cpp
ATLASLinkConsumer.cpp
#include <activemq/core/ActiveMQConnectionFactory.h> #include <activemq/library/ActiveMQCPP.h> #include <activemq/util/Config.h> #include <cms/BytesMessage.h> #include <cms/Connection.h> #include <cms/ExceptionListener.h> #include <cms/MapMessage.h> #include <cms/MessageListener.h> #include <cms/Session.h> #include <cms/TextMessage.h> #include <decaf/lang/Integer.h> #include <decaf/lang/Long.h> #include <decaf/lang/Runnable.h> #include <decaf/lang/System.h> #include <decaf/lang/Thread.h> #include <decaf/util/concurrent/CountDownLatch.h> #include <iostream> #include <memory> #include <regex> #include <stdio.h> #include <stdlib.h> #include "MOOS/libMOOS/DB/ATLASLinkConsumer.h" using namespace activemq::core; using namespace decaf::util::concurrent; using namespace decaf::util; using namespace decaf::lang; using namespace cms; using namespace std; ATLASLinkConsumer::ATLASLinkConsumer(CMOOSDB_ATLAS *db, const std::string &brokerURI, const std::string &atlas_link_extraname) { this->db_atlas = db; // Create a ConnectionFactory auto_ptr<ConnectionFactory> connectionFactory( ConnectionFactory::createCMSConnectionFactory(brokerURI)); // Create a Connection connection = connectionFactory->createConnection(); connection->start(); // connection->setExceptionListener(this); // Create a Session if (this->sessionTransacted == true) { session = connection->createSession(Session::SESSION_TRANSACTED); } else { session = connection->createSession(Session::AUTO_ACKNOWLEDGE); } // Determine the topic name ostringstream topicname; topicname << "FAULTS-SIM-TO-ATLAS"; if (!atlas_link_extraname.empty()) topicname << "-" << atlas_link_extraname; // Create the destination (Topic or Queue) destination = session->createTopic(topicname.str()); // Create a MessageConsumer from the Session to the Topic or Queue consumer = session->createConsumer(destination); consumer->setMessageListener(this); } ATLASLinkConsumer::~ATLASLinkConsumer() { cleanup(); } void ATLASLinkConsumer::cleanup() { if (connection != NULL) { try { connection->close(); } catch (cms::CMSException &ex) { ex.printStackTrace(); } } // Destroy resources. try { delete destination; destination = NULL; delete consumer; consumer = NULL; delete session; session = NULL; delete connection; connection = NULL; } catch (CMSException &e) { e.printStackTrace(); } } void ATLASLinkConsumer::onMessage(const Message *message) { try { const TextMessage *textMessage = dynamic_cast<const TextMessage *>(message); string text = ""; if (textMessage != NULL) { text = textMessage->getText(); smatch matches; std::regex tempRegex("(.+)\\|(\\w+)=(.+)"); // Parse the text from the message // Message format e.g. (time_double)|m=v if (std::regex_search(text, matches, tempRegex)) { double endTime = stod(matches[1]); string key = matches[2]; string val = matches[3]; CMOOSMsg *moosemsg = new CMOOSMsg(MOOS_STRING, key, val); if (db_atlas) db_atlas->fromMQ(*moosemsg, endTime); delete moosemsg; } else { cout << "No match" << endl; } } else { cout << "Not a text message" << endl; } } catch (CMSException &e) { e.printStackTrace(); } catch (invalid_argument &ia) { cout << "Exception: invalid time" << endl; } // Commit all messages. if (this->sessionTransacted) { session->commit(); } // No matter what, tag the count down latch until done. // doneLatch.countDown(); }
0afac05a0622c53ea88c6406652b6cd6e9bbbcfe
563274f7013cd9c3bee34b0a579c6d1a32609a08
/folktest/clientclass.cc
bbe7ba442f9c4621bac9d32d533c8b8d5b9d4d0e
[]
no_license
HideinBushes/MessagingSystemWXZ
4c777212612d57e01aec75c0fd5ba36d589a62e8
3297c1a2e54ea9213a02d0ff044041bc01ba0683
refs/heads/master
2021-01-10T17:49:52.271373
2015-12-16T19:36:34
2015-12-16T19:36:34
45,877,741
0
0
null
null
null
null
UTF-8
C++
false
false
1,434
cc
clientclass.cc
#include <iostream> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdlib.h> #include <unistd.h> #include <netdb.h> using namespace std; #define bufsize 1024 class Client{ private: int sockfd; int portNum; char buffer[bufsize]; struct sockaddr_in server_addr; public: Client(int portNum): portNum(portNum){ //socket() sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) { cout << "\nError establishing socket..." << endl; exit(1); } cout << "\n=> Socket client has been created..." << endl; } void clientinit(){ bzero(&server_addr, sizeof(server_addr)); server_addr.sin_family = AF_INET; server_addr.sin_port = htons(portNum); } void clientconn(){ if (connect(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) == 0) cout << "=> Connection to the server port number: " << portNum << endl; } void str_cli(){ //client write to socket cout << "client: "; cin >> buffer; write(sockfd, buffer, bufsize); //client read from socket cout << "server: "; read(sockfd, buffer, bufsize); cout << buffer << " "; } void clientclose(){ close(sockfd); } }; int main(){ Client c1(1510); c1.clientinit(); c1.clientconn(); c1.str_cli(); c1.clientclose(); }
697070502a59a68ef0f2190ec9685bd36dbbd223
b25bc563dbb37a12244d2375c5816de9231c6c63
/PowerPlant/_In Progress/_Constructor Additions/LInPlaceHostView.cp
2040408be259425a51ef1a5d977d7c6ce0850eb7
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "ISC" ]
permissive
mattgallagher/Mines
cae97a293bea9431c173b62fbc6a7115bfa4828d
cb159c358b12787dca9b8328d7f6083f07377b52
refs/heads/master
2021-01-13T13:00:09.404274
2018-10-24T12:15:04
2018-10-24T12:15:04
78,709,769
28
3
null
null
null
null
WINDOWS-1252
C++
false
false
10,261
cp
LInPlaceHostView.cp
// Copyright ©2005, 2006 Freescale Semiconductor, Inc. // Please see the License for the specific language governing rights and // limitations under the License. // =========================================================================== // LInPlaceHostView.cp PowerPlant 2.2.2 ©1996-2005 Metrowerks Inc. // =========================================================================== #ifdef PowerPlant_PCH #include PowerPlant_PCH #endif #include <LInPlaceHostView.h> #include <LInPlaceEditField.h> #include <LEditField.h> #include <LStream.h> #include <UDrawingUtils.h> #include <UTextTraits.h> #include <LFastArrayIterator.h> #include <UNewTextDrawing.h> PP_Begin_Namespace_PowerPlant // --------------------------------------------------------------------------- // ¥ LInPlaceHostView Stream Constructor [public] // --------------------------------------------------------------------------- LInPlaceHostView::LInPlaceHostView( LStream* inStream) : LView(inStream) { InitHostView(); // Read stream data (matches edit field stream data). inStream->ReadPString(mText); *inStream >> mTextTraitsID; *inStream >> mMaxChars; *inStream >> mEditFieldAttributes; SInt8 keyFilterID; *inStream >> keyFilterID; mKeyFilter = UKeyFilters::SelectTEKeyFilter(keyFilterID); } // --------------------------------------------------------------------------- // ¥ LInPlaceHostView Default Constructor [public] // --------------------------------------------------------------------------- LInPlaceHostView::LInPlaceHostView() { InitHostView(); } // --------------------------------------------------------------------------- // ¥ ~LInPlaceHostView Destructor [public] // --------------------------------------------------------------------------- LInPlaceHostView::~LInPlaceHostView() { delete mEditField; } #pragma mark - // --------------------------------------------------------------------------- // ¥ GetDescriptor // --------------------------------------------------------------------------- // Return the text that would be edited (if no IPE active) // or the current text (if active). StringPtr LInPlaceHostView::GetDescriptor( Str255 outDescriptor) const { if (mEditField != nil) { return mEditField->GetDescriptor(outDescriptor); } else { return LString::CopyPStr(mText, outDescriptor); } } // --------------------------------------------------------------------------- // ¥ SetDescriptor // --------------------------------------------------------------------------- // Change the text value of this edit field. void LInPlaceHostView::SetDescriptor( ConstStringPtr inDescriptor) { // Stash text for future drawing. mText = inDescriptor; Refresh(); // Relay new text to in-place editor (if one exists). if (mEditField != nil) mEditField->SetDescriptor(inDescriptor); // Cache frame rect of new text for hit testing. UpdateCachedFrame(); } // --------------------------------------------------------------------------- // ¥ GetValue // --------------------------------------------------------------------------- SInt32 LInPlaceHostView::GetValue() const { SInt32 theNumber = 0; Str255 str; GetDescriptor(str); if (str[0] > 0) { ::StringToNum(str, &theNumber); } return theNumber; } // --------------------------------------------------------------------------- // ¥ SetValue // --------------------------------------------------------------------------- void LInPlaceHostView::SetValue( SInt32 inValue) { Str255 numberAsString; ::NumToString(inValue, numberAsString); SetDescriptor(numberAsString); } // --------------------------------------------------------------------------- // ¥ SetValueMessage // --------------------------------------------------------------------------- // Set the message which is broadcast when the in-place editor // detects a change in the value. void LInPlaceHostView::SetValueMessage( MessageT inValueMessage) { mValueMessage = inValueMessage; if (mEditField != nil) mEditField->SetValueMessage(inValueMessage); } // --------------------------------------------------------------------------- // ¥ IsHitBy // --------------------------------------------------------------------------- // Return true if the in-place editor would be hit by this port location. Boolean LInPlaceHostView::IsHitBy( SInt32 inHorizPort, SInt32 inVertPort) { // If we have an in-place editor, just use it. if (mEditField != nil) { return mEditField->IsHitBy(inHorizPort, inVertPort); } // Convert point to local coordinates. Point localPt; localPt.h = (SInt16) inHorizPort; localPt.v = (SInt16) inVertPort; PortToLocalPoint(localPt); // Compare with cached text frame rect. return (::MacPtInRect(localPt, &mTextLocalFrame) && IsEnabled()); } // --------------------------------------------------------------------------- // ¥ CalcPortTextRect // --------------------------------------------------------------------------- // Return the location of the static text in port coordinates. void LInPlaceHostView::CalcPortTextRect( Rect& outFrame) { outFrame = mTextLocalFrame; LocalToPortPoint(topLeft(outFrame)); LocalToPortPoint(botRight(outFrame)); } #pragma mark - // --------------------------------------------------------------------------- // ¥ DrawSelf [protected] // --------------------------------------------------------------------------- // Draw the text value of this field unless we have actually // instantiated an edit field. Then the edit field draws the text instead. void LInPlaceHostView::DrawSelf() { // If we have an edit field, it will draw the text. if (mEditField != nil) return; // Otherwise, we draw the text in exactly the same location as it would // appear when edited. Rect frame; CalcLocalFrameRect(frame); if (mEditFieldAttributes & editAttr_Box) ::MacInsetRect(&frame, 3, 2); else ::MacInsetRect(&frame, 1, 0); SInt16 just = UTextTraits::SetPortTextTraits(mTextTraitsID); RGBColor textColor; ::GetForeColor(&textColor); ApplyForeAndBackColors(); ::RGBForeColor(&textColor); UTextDrawing::DrawWithJustification((Ptr) &mText[1], mText[0], frame, just); } // --------------------------------------------------------------------------- // ¥ RemoveSubPane [protected] // --------------------------------------------------------------------------- // If the edit field is the pane being removed, cancel references to it. void LInPlaceHostView::RemoveSubPane( LPane* inSub) { if (inSub == mEditField) { LStr255 value; mEditField->GetDescriptor(value); SetDescriptor(value); mEditField = nil; } LView::RemoveSubPane(inSub); } #pragma mark - // --------------------------------------------------------------------------- // ¥ ClickSelf [protected] // --------------------------------------------------------------------------- // Start in-place editing by defualt. You may want to override this to // add a delay before editing (like the Finder). void LInPlaceHostView::ClickSelf( const SMouseDownEvent& /* inMouseDown */) { SpawnInPlaceEditor(); } // --------------------------------------------------------------------------- // ¥ SpawnInPlaceEditor [protected] // --------------------------------------------------------------------------- // Create an in-place edit field. Normally this method will not be overriden. void LInPlaceHostView::SpawnInPlaceEditor() { // Fill in default pane info. Rect editRect; CalcLocalFrameRect(editRect); SPaneInfo paneInfo = { 0, // paneID (SInt16) (editRect.right - editRect.left), // width (SInt16) (editRect.bottom - editRect.top), // height true, // visible true, // enabled { true, true, true, true }, // bindings editRect.left, // left editRect.top, // top 0, // userCon this }; // superView // Create edit field. mEditField = new LInPlaceEditField( paneInfo, // inPaneInfo mText, // inString mTextTraitsID, // inTextTraitsID mMaxChars, // inMaxChars mEditFieldAttributes, // inAttributes mKeyFilter, // inKeyFilter this); // inSuper ThrowIfNil_(mEditField); mEditField->FinishCreate(); mEditField->AdjustSize(); SwitchTarget(mEditField); // Set up listener relationships for edit field. mEditField->SetValueMessage(mValueMessage); LFastArrayIterator iter(mListeners); LListener* listener; while (iter.Next(&listener)) { mEditField->AddListener(listener); } } #pragma mark - // --------------------------------------------------------------------------- // ¥ UpdateCachedFrame [protected] // --------------------------------------------------------------------------- // Update the mLocalTextFrame member so that it reflects the location // of the text to be displayed. void LInPlaceHostView::UpdateCachedFrame() { // Cache frame rect of new text for hit testing. Rect frame; CalcLocalFrameRect(frame); if (mEditFieldAttributes & editAttr_Box) ::MacInsetRect(&frame, 3, 2); else ::MacInsetRect(&frame, 1, 0); SInt16 just = UTextTraits::SetPortTextTraits(mTextTraitsID); UNewTextDrawing::MeasureWithJustification((Ptr) &mText[1], mText[0], frame, just, mTextLocalFrame, true); } // --------------------------------------------------------------------------- // ¥ FinishCreateSelf [protected] // --------------------------------------------------------------------------- // Overridden to ensure that the cached text frame is correctly initialized. void LInPlaceHostView::FinishCreateSelf() { LView::FinishCreateSelf(); UpdateCachedFrame(); } #pragma mark - // --------------------------------------------------------------------------- // ¥ InitHostView [private] // --------------------------------------------------------------------------- // Common initializer for LInPlaceHostView constructors. void LInPlaceHostView::InitHostView() { mEditField = nil; mEditFieldAttributes = editAttr_Box; mKeyFilter = &UKeyFilters::PrintingCharField; mMaxChars = 255; mTextTraitsID = 0; mValueMessage = mPaneID; } PP_End_Namespace_PowerPlant
a7ad5db1add3004929439e71da1e1161a1dc755a
41530cf71c1777e2066440f252c25d257269749a
/RealTimeScheduling/HelperRobot.cpp
544055f673b1c2f9b33b1db0921035ca3cf9e0ff
[]
no_license
aazim18/CPlusPlus
5420190090aebba3671f37e67ec2e07704967796
f558c68458b88d88af4e584a790cbe67043fcff3
refs/heads/master
2020-06-15T10:40:24.503561
2019-07-04T16:50:24
2019-07-04T16:50:24
195,275,386
0
0
null
null
null
null
UTF-8
C++
false
false
304
cpp
HelperRobot.cpp
/* * HelperRobot.cpp * * Created on: Mar 23, 2015 * Author: azim1866 */ #include <iostream> #include <string> #include "HelperRobot.h" #include <fstream> using namespace std; HelperRobot::HelperRobot() { this->inprogress=2; this->queued=2; } int HelperRobot :: FinishWork() { queued--; }
dea0c5b31ae966d597c91a9b8e6a9921ec06bb17
1c23e8800c4751077a1695b89ae7aae601dd91ab
/Source/SlapKnight_Legacy/Units/Worker.h
0e7f1feb246042db99b2010aada4ddbab517de83
[]
no_license
Paxton89/SlapKnight_Legacy
e5fd4e9fafabd658267013f85c02c542f5c8f4a0
b0305b6e70346d901f84b0ea5b442dad363c6be4
refs/heads/main
2023-08-31T08:06:59.580717
2021-10-26T14:31:06
2021-10-26T14:31:06
411,214,574
0
0
null
null
null
null
UTF-8
C++
false
false
211
h
Worker.h
// J #pragma once #include "CoreMinimal.h" #include "SlapKnight_Legacy/Units/BaseUnit.h" #include "Worker.generated.h" UCLASS() class SLAPKNIGHT_LEGACY_API AWorker : public ABaseUnit { GENERATED_BODY() };
67481abd5109ecf6e00ba7b9e383160f3b2531c3
966715244b0f937e48305f2753ebde5544809325
/include/Dlink/vector.hpp
ca3a76137beea8717eb564829a22400c8b8e01df
[ "MIT" ]
permissive
DlinkLang/Dlink
970569fb4e0be8bdf79948e418178ef3e110137c
bbe36adf3f1591bd27ad6edcd45d5ad33fcb1781
refs/heads/master
2020-03-22T20:09:47.423408
2018-11-19T12:13:39
2018-11-19T12:14:19
140,577,462
6
0
null
null
null
null
UTF-8
C++
false
false
11,408
hpp
vector.hpp
#ifndef DLINK_HEADER_VECTOR_HPP #define DLINK_HEADER_VECTOR_HPP #include <vector> #ifdef DLINK_MULTITHREADING # include <initializer_list> # include <memory> # include <utility> # include <mutex> #endif namespace dlink { #ifdef DLINK_MULTITHREADING template<typename Ty_, typename Allocator_ = std::allocator<Ty_>> class vector { template<typename Ty_, typename Allocator_> friend void swap(vector<Ty_, Allocator_>& lhs, vector<Ty_, Allocator_>& rhs); private: using data_type_ = std::vector<Ty_, Allocator_>; using my_ = vector<Ty_, Allocator_>; public: using value_type = Ty_; using allocator_type = Allocator_; using size_type = typename data_type_::size_type; using difference_type = typename data_type_::difference_type; using reference = typename data_type_::reference; using const_reference = typename data_type_::const_reference; using pointer = typename data_type_::pointer; using const_pointer = typename data_type_::const_pointer; using iterator = typename data_type_::iterator; using const_iterator = typename data_type_::const_iterator; using reverse_iterator = typename data_type_::reverse_iterator; using const_reverse_iterator = typename data_type_::const_reverse_iterator; public: vector() noexcept(noexcept(Allocator_())) {} explicit vector(const Allocator_& allocator) noexcept : data_(allocator) {} vector(size_type count, const Ty_& value, const Allocator_& allocator = Allocator_()) : data_(count, value, allocator) {} explicit vector(size_type count, const Allocator_& allocator = Allocator_()) : data_(count, allocator) {} template<typename Iterator_> vector(Iterator_ first, Iterator_ last, const Allocator_& allocator = Allocator_()) : data_(first, last, allocator) {} vector(const data_type_& vector) : data_(vector) {} vector(data_type_&& vector) : data_(std::move(vector)) {} vector(const my_& vector) : data_(vector.data_) {} vector(const my_& vector, const Allocator_& allocator) : data_(vector.data_, allocator) {} vector(my_&& vector) noexcept : data_(std::move(vector.data_)) {} vector(my_&& vector, const Allocator_& allocator) : data_(std::move(vector), allocator) {} vector(std::initializer_list<Ty_> init, const Allocator_& allocator = Allocator_()) : data_(init, allocator) {} ~vector() = default; public: my_& operator=(const my_& other) { if (this == &other) return *this; std::lock_guard<std::mutex> guard(mutex_); std::lock_guard<std::mutex> guard_other(other.mutex_); data_ = other.data_; return *this; } my_& operator=(my_&& other) noexcept(noexcept(data_ = std::move(other.data_))) { if (this == &other) return *this; std::lock_guard<std::mutex> guard(mutex_); std::lock_guard<std::mutex> guard_other(other.mutex_); data_ = std::move(other.data_); return *this; } my_& operator=(std::initializer_list<Ty_> init) { std::lock_guard<std::mutex> guard(mutex_); data_ = init; return *this; } bool operator==(const my_& other) const { if (this == &other) return true; std::lock_guard<std::mutex> guard(mutex_); std::lock_guard<std::mutex> guard_other(other.mutex_); return data_ == other.data_; } bool operator!=(const my_& other) const { if (this == &other) return false; std::lock_guard<std::mutex> guard(mutex_); std::lock_guard<std::mutex> guard_other(other.mutex_); return data_ != other.data_; } bool operator>(const my_& other) const { if (this == &other) return false; std::lock_guard<std::mutex> guard(mutex_); std::lock_guard<std::mutex> guard_other(other.mutex_); return data_ > other.data_; } bool operator>=(const my_& other) const { if (this == &other) return true; std::lock_guard<std::mutex> guard(mutex_); std::lock_guard<std::mutex> guard_other(other.mutex_); return data_ >= other.data_; } bool operator<(const my_& other) const { if (this == &other) return false; std::lock_guard<std::mutex> guard(mutex_); std::lock_guard<std::mutex> guard_other(other.mutex_); return data_ < other.data_; } bool operator<=(const my_& other) const { if (this == &other) return true; std::lock_guard<std::mutex> guard(mutex_); std::lock_guard<std::mutex> guard_other(other.mutex_); return data_ <= other.data_; } const_reference operator[](size_type index) const { std::lock_guard<std::mutex> guard(mutex_); return data_[index]; } reference operator[](size_type index) { std::lock_guard<std::mutex> guard(mutex_); return data_[index]; } public: void assign(size_type count, const Ty_& value) { std::lock_guard<std::mutex> guard(mutex_); data_.assign(count, value); } template<typename Iterator_> void assign(Iterator_ first, Iterator_ last) { std::lock_guard<std::mutex> guard(mutex_); data_.assign(first, last); } void assign(std::initializer_list<Ty_> init) { std::lock_guard<std::mutex> guard(mutex_); data_.assign(init); } const_reference at(size_type index) const { std::lock_guard<std::mutex> guard(mutex_); return data_.at(index); } reference at(size_type index) { std::lock_guard<std::mutex> guard(mutex_); return data_.at(index); } public: allocator_type get_allocator() const { std::lock_guard<std::mutex> guard(mutex_); return data_.get_allocator(); } bool empty() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.empty(); } size_type size() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.size(); } size_type max_size() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.max_size(); } void reserve(size_type new_capacity) { std::lock_guard<std::mutex> guard(mutex_); data_.reserve(new_capacity); } size_type capacity() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.capacity(); } void shrink_to_fit() { std::lock_guard<std::mutex> guard(mutex_); data_.shrink_to_fit(); } void resize(size_type count) { std::lock_guard<std::mutex> guard(mutex_); data_.resize(count); } void resize(size_type count, const Ty_& value) { std::lock_guard<std::mutex> guard(mutex_); data_.resize(count, value); } void clear() noexcept { std::lock_guard<std::mutex> guard(mutex_); data_.clear(); } iterator insert(const_iterator pos, const Ty_& value) { std::lock_guard<std::mutex> guard(mutex_); return data_.insert(pos, value); } iterator insert(const_iterator pos, Ty_&& value) { std::lock_guard<std::mutex> guard(mutex_); return data_.insert(pos, std::move(value)); } iterator insert(const_iterator pos, size_type count, const Ty_& value) { std::lock_guard<std::mutex> guard(mutex_); return data_.insert(pos, count, value); } template<typename Iterator_> iterator insert(const_iterator pos, Iterator_ first, Iterator_ last) { std::lock_guard<std::mutex> guard(mutex_); return data_.insert(pos, first, last); } iterator insert(const_iterator pos, std::initializer_list<Ty_> init) { std::lock_guard<std::mutex> guard(mutex_); return data_.insert(pos, init); } const_reference front() const { std::lock_guard<std::mutex> guard(mutex_); return data_.front(); } reference front() { std::lock_guard<std::mutex> guard(mutex_); return data_.front(); } const_reference back() const { std::lock_guard<std::mutex> guard(mutex_); return data_.back(); } reference back() { std::lock_guard<std::mutex> guard(mutex_); return data_.back(); } const_pointer data() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.data(); } pointer data() noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.data(); } iterator begin() noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.begin(); } const_iterator begin() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.begin(); } const_iterator cbegin() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.cbegin(); } iterator end() noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.end(); } const_iterator end() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.end(); } const_iterator cend() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.cend(); } reverse_iterator rbegin() noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.rbegin(); } const_reverse_iterator rbegin() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.rbegin(); } const_reverse_iterator crbegin() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.crbegin(); } reverse_iterator rend() noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.rend(); } const_reverse_iterator rend() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.rend(); } const_reverse_iterator crend() const noexcept { std::lock_guard<std::mutex> guard(mutex_); return data_.crend(); } template<typename... Args_> iterator emplace(const_iterator pos, Args_&&... args) { std::lock_guard<std::mutex> guard(mutex_); return data_.emplace(pos, std::forward<Args_>(args)...); } iterator erase(const_iterator pos) { std::lock_guard<std::mutex> guard(mutex_); return data_.erase(pos); } iterator erase(const_iterator first, const_iterator last) { std::lock_guard<std::mutex> guard(mutex_); return data_.erase(first, last); } void push_back(const Ty_& value) { std::lock_guard<std::mutex> guard(mutex_); data_.push_back(value); } void push_back(Ty_&& value) { std::lock_guard<std::mutex> guard(mutex_); data_.push_back(std::move(value)); } template<typename... Args_> reference emplace_back(Args_&&... args) { std::lock_guard<std::mutex> guard(mutex_); return data_.emplace_back(std::forward<Args_>(args)...); } void pop_back() { std::lock_guard<std::mutex> guard(mutex_); data_.pop_back(); } void swap(my_& other) noexcept(data_.swap(other.data_)) { if (this == &other) return; std::lock_guard<std::mutex> guard(mutex_); std::lock_guard<std::mutex> guard_other(other.mutex_); data_.swap(other.data_); } protected: const data_type_& data_stl() const noexcept { return data_; } data_type_& data_stl() noexcept { return data_; } std::mutex& mutex() const noexcept { return mutex_; } private: data_type_ data_; mutable std::mutex mutex_; }; #else template<typename Ty_, typename Allocator_ = std::allocator<Ty_>> using vector = std::vector<Ty_, Allocator_>; #endif template<typename Ty_, typename Allocator_> void swap(vector<Ty_, Allocator_>& lhs, vector<Ty_, Allocator_>& rhs) { if (&lhs == &rhs) return; #ifdef DLINK_MULTITHREADING std::lock_guard<std::mutex> guard(lhs.mutex_); std::lock_guard<std::mutex> guard_other(rhs.mutex_); std::swap(lhs.data_, rhs.data_); #else std::swap(lhs, rhs); #endif } } #endif
422a719f19bd5af2ffe5eeb5d42384885d6712e6
ff93b3d44693687f0e8dd9dec525ce4ac08c317c
/agents/minilibs/Route.h
29188feeac4145f578c4fc7776e9395193f14f99
[]
no_license
agiordana/HAT
6ea2b5a6b3a635e6702ccf8573133a65c8c14c9a
f61f0783c8d9f9d4e3b1374eb6475f4d88f95ff9
refs/heads/master
2020-12-24T07:54:07.078444
2018-10-01T12:39:05
2018-10-01T12:39:05
59,103,594
3
0
null
null
null
null
UTF-8
C++
false
false
1,738
h
Route.h
#ifndef new_soap_Router_h #define new_soap_Router_h #include <iostream> #include <vector> #include <string> #include <regex.h> #include "../tinyxml/tinyxml.h" #include "../libjson/libjson.h" using namespace std; // superclasse che prefissa tutte le classi che dovranno ricevere un uri da eseguire class RouterExec { public: std::string name; RouterExec(std::string n) { name = n; }; //* metodo che process gli uri // 1) parametro: uri, 2) parametro: vettore di parametri contenete le variabili estratte dall'uri, // 3) parametro: il metodo interno che deve essere utilizzato virtual MMessage exec(std::string uri, std::vector<std::string> params, std::string method, string body="") { return name; }; }; //contiene le stringhe estratte dalla descrizione xml che specificano i vincoli sui parametri class Condition { public: std::string param; std::string regexp; }; // descrive uno delle possibili vie che può accogliere un uri class Route { public: NameList _template; std::string format; std::string method; // POST, GET, PUT, DELETE std::vector<Condition> conditions; //vettore delle condizioni che deve soddisfare l'uri std::string called_method; // metodo che deve essere chiamato nella class prefissato con RouterExec RouterExec* target; // classe che dovra` elaborare l'uri (chiamata target->exec(...) ) static bool match_regexp(std::string reg, std::string s); }; class RoutingMap : public std::vector<Route> { public: MMessage route(std::string uri, std::string method, std::string body=""); RoutingMap(std::string file); protected: virtual void loadClasses(); bool load(std::string); std::vector<RouterExec*> instances; }; #endif
a999ba82e043e62a872dbd59781b02e6186fddee
115b07b4ca5bae4d1dd567e8cb5a1366cbf72c9b
/Source/Flopnite/Private/FNAnimInstance.cpp
06da74f53e5dfe2b001cd875271475fb47af66e5
[ "MIT" ]
permissive
BEASTSM96/flopnite-ue4
7cc6c9c86c9448a79a99d7aeb5d93435b99a0fb7
76193544a6b7fe6b969864e74409b6b5a43f3d7a
refs/heads/v2
2023-05-25T02:48:23.277991
2020-10-10T16:20:02
2020-10-10T16:20:02
301,183,398
0
0
MIT
2021-06-06T14:50:56
2020-10-04T17:13:54
C++
UTF-8
C++
false
false
1,132
cpp
FNAnimInstance.cpp
// #include "FNAnimInstance.h" #include "GameFramework/CharacterMovementComponent.h" #include "FNCharacter.h" UFNAnimInstance::UFNAnimInstance() { /* */ IsInAir = false; Direction = 0.0; } void UFNAnimInstance::NativeUpdateAnimation( float DeltaSeconds ) { Super::NativeUpdateAnimation( DeltaSeconds ); if ( TryGetPawnOwner() != nullptr ) { Speed = TryGetPawnOwner()->GetVelocity().Size(); Direction = CalculateDirection( TryGetPawnOwner()->GetVelocity(), TryGetPawnOwner()->GetActorRotation() ); AFNCharacter * OwningChar = Cast< AFNCharacter >( TryGetPawnOwner() ); if (OwningChar != nullptr) { IsInAir = OwningChar->GetCharacterMovement()->IsFalling(); } } } void UFNAnimInstance::NOTIFY_Jump() { AFNCharacter * OwningChar = Cast< AFNCharacter >( TryGetPawnOwner() ); if (EnableJump) { OwningChar->Jump(); } } void UFNAnimInstance::NOTIFY_JogStart() { AFNCharacter * OwningChar = Cast< AFNCharacter >( TryGetPawnOwner() ); EnableJump = false; //SomeThing here }
190e509046ac8f2efdb76d6e50e676c197f94aa2
ecee6bbff0dea9c54f01f2c72462d694dbde4e7a
/SteeringEquation/SteeringEquation.ino
1d278980a236de469ff7febe6eb04f187adeaabd
[]
no_license
BigOto2/2015-16
a958b01015ba66f0c8a5ae5fa1c1683e6c11a2a1
5724a659943e8db6c66f66b9e95ca4c338232434
refs/heads/master
2021-01-14T10:21:18.095442
2015-11-22T00:16:32
2015-11-22T00:16:32
46,627,711
0
0
null
2015-11-21T18:22:48
2015-11-21T18:22:48
null
UTF-8
C++
false
false
2,215
ino
SteeringEquation.ino
#define ANGLE_MAX 100 //The maximum angle in either direction that the rover should pivot (in radians) #define ANGLE_MIN .01 //The angle at which we approximate it as going straight (in radians) #define LENGTH_TO_PIVOT 100 //The straight line distance from the pivot point to the point between the wheels (the axle) #define LENGTH_BETWEEN_WHEELS 100 //The distance between the wheels on the chassis (width of the rover) #define CALCULATING_FREQ 100 //How many times we run the loop in a second double angle; //Our desired angle void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: } /** * @return the tangential speed as given by our joystick input */ double getYValue() { return y; } /** * @return the change in our desired pivot angle as given by our joystic input */ double getXValue() { return x; } /** * @return the potentiometer angle value */ double getPotValue() { return potValue; } /** * Sets the angle value */ void setAngle() { angle = getPotValue(); double x = getXValue(); angle = angle + (x / CALCULATING_FREQ); } /** * Clips the angle variable to safe values */ void clipAngle() { if (angle > ANGLE_MAX) { angle = ANGLE_MAX; } else if (angle < -ANGLE_MAX) { angle = -ANGLE_MAX; } if ((-ANGLE_MIN < angle) && (angle < ANGLE_MIN)) { angle = 0; } } /** * @return the rate in radians per second that the rover will travel around the circle */ double getAngularVelocity() { double angVel; double y = getYValue(); angVel = y * (1 - cos(angle)); angVel = angVel / (LENGTH_TO_PIVOT); angVel = angVel / (sin(angle) - angle); return angVel; } /** * @return left motor speed */ double getLeftMotorSpeed() { double y = getYValue(); double angVel = getAngularVelocity(); double leftVel; leftVel = y - angVel * LENGTH_BETWEEN_WHEELS / 2; return leftVel; } /** * @return right motor speed */ double getRightMotorSpeed() { double y = getYValue(); double angVel = getAngularVelocity(); double rightVel; rightVel = y + angVel * LENGTH_BETWEEN_WHEELS / 2; return rightVel; }
cd4c6d746eebb44b59c784ccdbff72b729a57ad1
144e322915d5b1be5ff4e1c8188ee589f337cd39
/CS179.14B_FinalProject/GameServer/GameServer.cpp
16533f1b76b8eb0708357db6681c1b8449b7656c
[]
no_license
raphaelreventar/CS179.14B_Finals
a0159b61d82fecb65b366e3fceef4f1c9d117855
f0b76af04c28535ed1d17ca984a69e3d05b05f24
refs/heads/master
2021-06-02T09:28:33.151659
2016-06-17T04:54:33
2016-06-17T04:54:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,013
cpp
GameServer.cpp
#include <string> #include <system_error> #include <iostream> #include <vector> #include <chrono> #include <array> #include <functional> #include <algorithm> #include <unordered_map> #include <atomic> #include <boost/asio.hpp> #include "GameMessage.h" using namespace std; typedef chrono::steady_clock Clock; const auto time_beforeDC = 6.0f; atomic<ID> id_counter(0); struct Client{ ID client_id; boost::asio::ip::udp::endpoint endpoint; boost::asio::ip::udp::socket &socket; chrono::time_point<Clock> last_packet; std::vector<uint8_t> send_buf; void send(MessageType message_type, BroadcastType broadcast_type, const void *data, size_t length) { send_buf.resize(sizeof(Message) + length); auto p = reinterpret_cast<Message*>(send_buf.data()); p->message_type = message_type; p->broadcast_type = broadcast_type; p->size = length; memcpy(p->data, data, length); // cout << "Sending data of total size: " << send_buf.size() << endl; socket.async_send_to(boost::asio::buffer(send_buf), endpoint, [this](auto error, auto size) { // cout << "Send success\n"; }); } }; unordered_map<ID, Client> clients; int main(int argc, char **argv) { int port = 8080; if (argc > 1) { port = strtoul(argv[1], 0, 10); } std::array<uint8_t, 1024> recv_buffer; try { boost::asio::io_service service; boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::udp::v6(),port); boost::asio::ip::udp::socket socket(service, endpoint);/*server stuff*/ boost::asio::ip::udp::endpoint source; /*server's endpoint*/ std::function<void(boost::system::error_code, size_t)> handler = [&](boost::system::error_code err, size_t length) { auto message = reinterpret_cast<const Message*>(recv_buffer.data()); // cout << "INCOMING" << endl; switch (message->message_type) { case MessageType::Connect: { ID id = id_counter++; auto result = clients.emplace(id, Client{ id, source, socket,Clock::now() }); result.first->second.send(message->message_type, BroadcastType::None, &id, sizeof(id)); break; } case MessageType::Disconnect: { if (message->size == sizeof(ID)) { auto id = *reinterpret_cast<const ID*>(message->data); auto it = clients.find(id); clients.erase(it); } break; } case MessageType::Broadcast: { // cout << "Recevied Status Message from: " << pm->id << endl; for (auto &client : clients) { if (client.first != message->origin) { client.second.send(message->message_type, message->broadcast_type, message->data, message->size); } else { client.second.last_packet = Clock::now(); client.second.endpoint = source; } } break; } } socket.async_receive_from(boost::asio::buffer(recv_buffer.data(), recv_buffer.size()), source, handler); }; socket.async_receive_from(boost::asio::buffer(recv_buffer.data(), recv_buffer.size()), source, handler); service.run(); } catch (exception e) { cerr << e.what() << endl; } return 0; }
67e23b1b317ef456ece3a6861d9481fb885c6c3f
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/git/gumtree/git_old_hunk_91.cpp
bca9ea86f488d08c90933cb3d7dc5b9b713ba8ba
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
595
cpp
git_old_hunk_91.cpp
append_signoff(&sb, ignore_footer, 0); } if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len) die_errno(_("could not write commit template")); strbuf_release(&sb); /* This checks if committer ident is explicitly given */ strbuf_addstr(&committer_ident, git_committer_info(IDENT_STRICT)); if (use_editor && include_status) { int ident_shown = 0; int saved_color_setting; char *ai_tmp, *ci_tmp; if (whence != FROM_COMMIT) { if (cleanup_mode == CLEANUP_SCISSORS) wt_status_add_cut_line(s->fp); status_printf_ln(s, GIT_COLOR_NORMAL, whence == FROM_MERGE ? _("\n"
f29e6963fcdf2d01c770919dc19cca336c808eea
44227276cdce0d15ee0cdd19a9f38a37b9da33d7
/alien/standalone/src/core/alien/handlers/profiler/BaseMatrixProfiler.h
5f1764679363bf4f940bd0ef92075866082b7875
[ "Apache-2.0" ]
permissive
arcaneframework/framework
7d0050f0bbceb8cc43c60168ba74fff0d605e9a3
813cfb5eda537ce2073f32b1a9de6b08529c5ab6
refs/heads/main
2023-08-19T05:44:47.722046
2023-08-11T16:22:12
2023-08-11T16:22:12
357,932,008
31
21
Apache-2.0
2023-09-14T16:42:12
2021-04-14T14:21:07
C++
UTF-8
C++
false
false
3,412
h
BaseMatrixProfiler.h
/* * Copyright 2020 IFPEN-CEA * * 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. * * SPDX-License-Identifier: Apache-2.0 */ #pragma once #include <vector> #include <alien/data/IMatrix.h> namespace Arccore { class ITraceMng; namespace MessagePassing { class IMessagePassingMng; } } // namespace Arccore /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ namespace Alien { /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ template <typename Scalar> class SimpleCSRMatrix; /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ namespace Common { /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ template <typename ValueT = Real> class MatrixProfilerT { public: explicit MatrixProfilerT(IMatrix& matrix); virtual ~MatrixProfilerT(); void addMatrixEntry(Integer iIndex, Integer jIndex); void allocate(); private: IMatrix& m_matrix; SimpleCSRMatrix<ValueT>* m_matrix_impl; //! @internal data structure for a vector. typedef std::vector<Integer> VectorDefinition; //! @internal data structure for matrix adjency graph. typedef UniqueArray<VectorDefinition> MatrixDefinition; //! @internal data structure for matrix values (CSR) MatrixDefinition m_def_matrix; //! Global matrix informations. Integer m_local_offset = 0; Integer m_global_size = 0; Integer m_local_size = 0; bool m_square_matrix = false; Integer m_col_local_offset = 0; Integer m_col_global_size = 0; Integer m_col_local_size = 0; Integer m_nproc = 1; IMessagePassingMng* m_parallel_mng = nullptr; ITraceMng* m_trace = nullptr; bool m_allocated = false; private: void _startTimer() {} void computeProfile(); void _stopTimer() {} }; /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ } // namespace Common /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ } // namespace Alien /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ #include "MatrixProfilerT.h" /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
f0579d0822cae8803980fb3a1bb57f91b6f88d26
7367f0562cc9edb6a040c39733a902b576be18e3
/8x8/Arduino/sketch_apr14a/sketch_apr14a.ino
50b78fd0c43893651860fdf5885b2160cda5c8fd
[]
no_license
depli-ds/Labo-Depli-DS
97dbbbdb7095f74fe4b8416a28541955c2ac19c0
be764df4d0be14d44f1b636963a7a6a36ccebc83
refs/heads/master
2020-05-17T05:55:03.397647
2014-08-21T11:57:59
2014-08-21T11:57:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,857
ino
sketch_apr14a.ino
#include <Rainbowduino.h> byte display[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; char vel[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; unsigned char RED[64] = { 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,238,221,204,188,171,154,137,119,102,85, 68,51,34,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,35,52}; unsigned char GREEN[64] = { 0,17,34,51,68,85,102,119,136,153,170,187,204,221,238,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,238,221,204,188,170,154,136,120,102,86,68,52,34,18,0,0,0,0}; unsigned char BLUE[64] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,34,52,68,86,102,120,136,154,170,188, 204,221,238,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255}; void setup() { Rb.init(); for (unsigned char c = 0; c < 64; c++) { display[c] = (c % 8) + (c / 8) & B01111111; vel[c] = 1; } } void loop() { for (unsigned char x = 0; x < 8; x++) { for (unsigned char y = 0; y < 8; y++) { unsigned char ofs = (y << 3) + x; unsigned char hue = display[ofs]; uint32_t colour = ((uint32_t)RED[hue] << 16) | ((uint32_t)GREEN[hue] << 8) | BLUE[hue]; Rb.setPixelXY(x, y, colour); hue = hue+vel[ofs]; if (hue < 0 || hue > 63) { vel[ofs] = -vel[ofs]; hue += vel[ofs]; } display[ofs] = hue; } } delay(100); }
fa9019931b24ddcfe1bf75d6e9bd663f28a6232e
5f1b3538c48c95674f9a378b9d3f715abb6221d6
/Punteros_6.cpp
f68c43fd9c84236dcf69ade9ba42fda61a6c8728
[]
no_license
danivivi/Taller2_StrucII
0141219033a25f61f5d744c16c6e45b52ba5dcc3
a874c33108112546bc453b4f6e3fe761849fd610
refs/heads/master
2021-04-09T17:55:22.955301
2018-03-18T03:59:00
2018-03-18T03:59:00
125,690,804
0
0
null
null
null
null
ISO-8859-10
C++
false
false
1,150
cpp
Punteros_6.cpp
#include <stdio.h> #include<stdlib.h> /*programa que usa una funcion para almacenar numeros en un arrglo dinamico posteriormente en otra funcion buscar un numero en particular*/ void leer_arreglo(); void buscar(); int *v1; int num; int main() { leer_arreglo(); return 0; } void leer_arreglo(){ printf("Ingrese Tamaņo del Arreglo: "); scanf("%d",&num); v1=new int[num]; printf("\nIngrese Elementos del Arreglo: \n"); for(int i=0;i<num;i++){ scanf("%d",&v1[i]); } printf("\nMostrando Arreglo: \n"); for(int i=0;i<num;i++){ printf("%d ",*(v1+i)); } buscar(); delete[]v1; } void buscar(){ int inf,sup,dato,mitad; char band = 'F'; printf ("\nIngrese Elemento a buscar: \n"); scanf ("%d",&dato); inf = 0; sup = num; while((inf <= sup) && (band == 'F')) { mitad =((inf+sup)/2); if(v1[mitad]==dato){ band = 'V'; } else if(v1[mitad]>dato){ sup = mitad - 1; } else{ inf = mitad + 1; } } if(band == 'F'){ printf("\nEl Elemento no esta en el Arreglo.\n"); } else if(band=='V'){ printf("\nElemento encontrado, en la pos: %i",mitad+1); } }
89741216e661a15829236b4e7491e408c02fce4a
000cef8bf769732c20d5412f68b0fba102a48b66
/singleCPU/heatEquation2d/heat2d.cpp
e79e2d5ca7ba68a04062ad63b557a35f38e59d6c
[ "MIT" ]
permissive
Cxb1993/Matlab2CPP
31fcef8e7af7db308b6174eb7cec148acc34d853
b4a865fbcb006a342fb76acab12bd1a5d80a5339
refs/heads/master
2021-06-20T14:12:38.918251
2017-08-09T01:35:40
2017-08-09T01:35:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,127
cpp
heat2d.cpp
#include "heat2d.h" void Manage_Memory(int phase, int tid, float **h_u, float **h_un){ size_t domainSize; if (phase==0) { // Allocate whole domain variable h_u on host computer (master thread) domainSize= NX*NY*sizeof(float); *h_u = (float*)malloc(domainSize); *h_un= (float*)malloc(domainSize); } if (phase==1) { // Free the whole domain variables (master thread) free(*h_u); free(*h_un); } } /******************************/ /* TEMPERATURE INITIALIZATION */ /******************************/ void Set_IC(float * __restrict u0){ int i, j, o, IC; // select IC IC=2; switch (IC) { case 1: { for (j = 0; j < NY; j++) { for (i = 0; i < NX; i++) { // set all domain's cells equal to zero o = i+NX*j; u0[o] = 0.0; // set BCs in the domain if (j==0) u0[o] = 0.0; // bottom if (i==0) u0[o] = 0.0; // left if (j==NY-1) u0[o] = 1.0; // top if (i==NX-1) u0[o] = 1.0; // right } } break; } case 2: { float u_bl = 0.7f; float u_br = 1.0f; float u_tl = 0.7f; float u_tr = 1.0f; for (j = 0; j < NY; j++) { for (i = 0; i < NX; i++) { // set all domain's cells equal to zero o = i+NX*j; u0[o] = 0.0; // set BCs in the domain if (j==0) u0[o] = u_bl + (u_br-u_bl)*i/(NX+1); // bottom if (j==NY-1) u0[o] = u_tl + (u_tr-u_tl)*i/(NX+1); // top if (i==0) u0[o] = u_bl + (u_tl-u_bl)*j/(NY+1); // left if (i==NX-1) u0[o] = u_br + (u_tr-u_br)*j/(NY+1); // right } } break; } case 3: { for (j = 0; j < NY; j++) { for (i = 0; i < NX; i++) { // set all domain's cells equal to zero o = i+NX*j; u0[o] = 0.0; // set left wall to 1 if (i==NX-1) u0[o] = 1.0; } } break; } // here to add another IC } } void Call_Init(float **u0){ // Load the initial condition Set_IC(*u0); } void Laplace2d(float *u,float *un){ // Using (i,j) = [i+N*j] indexes int o, n, s, e, w; for (int j = 0; j < NY; j++) { for (int i = 0; i < NX; i++) { o = i + NX*j ; // node( j,i ) n n = i+NX*(j+1); // node(j+1,i) | s = i+NX*(j-1); // node(j-1,i) w--o--e e = (i+1)+NX*j; // node(j,i+1) | w = (i-1)+NX*j; // node(j,i-1) s // only update "interior" nodes if(i>0 && i<NX-1 && j>0 && j<NY-1) { un[o] = u[o] + KX*(u[e]-2*u[o]+u[w]) + KY*(u[n]-2*u[o]+u[s]); } else { un[o] = u[o]; } } } } void Call_Laplace(float **u, float **un){ // Produce one iteration of the laplace operator Laplace2d(*u,*un); } void Update_Domain(float *u, float *un){ // Explicitly copy data arrays for (int j = 0; j < NY; j++) { for (int i = 0; i < NX; i++) { u[i+NX*j] = un[i+NX*j]; } } } void Call_Update(float **u, float **un){ // produce explicitly: u=un; Update_Domain(*u,*un); } void Save_Results(float *u){ // print result to txt file FILE *pFile = fopen("result.txt", "w"); if (pFile != NULL) { for (int j = 0; j < NY; j++) { for (int i = 0; i < NX; i++) { fprintf(pFile, "%d\t %d\t %g\n",j,i,u[i+NX*j]); } } fclose(pFile); } else { printf("Unable to save to file\n"); } }
00b6cd05791e2a1f8e8f87609bd66151b23b6146
06c4be5d8aa3ef41c7ece9b3df49887dd69dbd52
/KernSem.h
f3b60d47683c85af389517575d4874a1d8ce314d
[]
no_license
sofijaf/os1
4a6d4d8d7ea543aa16b0e1f47a2720ac4659cda0
d4b1a70c9edcd038534d1f3165351906825ce3cf
refs/heads/main
2023-01-05T07:09:58.075479
2020-10-25T12:49:28
2020-10-25T12:49:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
390
h
KernSem.h
/* * KernSem.h * * Created on: Oct 18, 2019 * Author: OS1 */ #ifndef KERNSEM_H_ #define KERNSEM_H_ #include "semaphor.h" class Queue; class SQueue; class KernelSem { public: KernelSem(int init, Semaphore* s); virtual ~KernelSem(); int wait(Time maxTimeToWait); int signal(int n); int val(); int value; Semaphore* mySem; Queue* myQueue; }; #endif /* KERNSEM_H_ */
b5654740cd9c5813124c5303a0e04c8c908445d6
89bf144a6777b1b51fa704dab02e16fcb0870bdc
/6_motion_control_PID/heading_controller/heading_controller.ino
a5bfabf25f9d34e2c3cb7de8f9fd62931e038c24
[]
no_license
fznsakib/arduino
4002d850cf591123c62d87b71765ffefe05d0c85
f105a0e0b6aab8b3b2f074c4c771213145f23571
refs/heads/master
2020-09-06T16:56:33.330586
2019-12-11T11:29:37
2019-12-11T11:29:37
220,486,318
0
0
null
null
null
null
UTF-8
C++
false
false
3,418
ino
heading_controller.ino
#include "encoders.h" #include "pid.h" #define L_PWM_PIN 10 #define L_DIR_PIN 16 #define R_PWM_PIN 9 #define R_DIR_PIN 15 #define DIR_FWD LOW #define DIR_BKD HIGH #define OUTPUT_LIMIT 215.0 // Proportional, Integral and Derivative gains for position controller #define kp_left 0.5 #define ki_left 0.0 #define kd_left 12.0 #define kp_right 0.5 #define ki_right 0.0 #define kd_right 12.0 #define kp_heading 1.0 #define ki_heading 0.0 #define kd_heading 0.0 // Position controllers for left/right wheel position PID left_pid(kp_left, ki_left, kd_left); PID right_pid(kp_right, ki_right, kd_right); PID heading_pid(kp_heading, ki_heading, kd_heading); float wheel_update_ts; float heading_update_ts; float demand_switch_ts; float demand; float heading_demand; float heading_output; void setup() { setupMotors(); // Initialise your other globals variables // and devices. setupLeftEncoder(); setupRightEncoder(); demand = 1000.0; heading_demand = 0.0; heading_output = 0.0; wheel_update_ts = millis(); heading_update_ts = millis(); demand_switch_ts = millis(); // Initialise the Serial communication Serial.begin( 9600 ); delay(1000); Serial.println("***RESET***"); } void loop() { // HEADING CONTROLLER: Update at a smaller interval of 100ms than wheels // to avoid over compensating for bias. float elapsed_time = millis() - heading_update_ts; if (elapsed_time > 50) { heading_update_ts = millis(); // Heading demand for a straight line requires equal counts for both wheel float heading_measurement = count_right_e - count_left_e; heading_output = heading_pid.update(heading_demand, heading_measurement); } elapsed_time = millis() - wheel_update_ts; // WHEELS: Call pid.update() on at a regular time interval of 10ms if (elapsed_time > 10) { wheel_update_ts = millis(); float left_demand = demand - heading_output/2; float right_demand = demand + heading_output/2; // output_signal <----PID---- demand, measurement float left_output = left_pid.update(left_demand, count_left_e); float right_output = right_pid.update(right_demand, count_right_e); Serial.print(heading_output); Serial.print(", "); Serial.print(count_left_e); Serial.print(", "); Serial.print(count_right_e); Serial.print(", "); Serial.print(left_output); Serial.print(", "); Serial.println(right_output); updateSpeed(left_output, right_output); } // DEMAND: Switch every 3 seconds elapsed_time = millis() - demand_switch_ts; if (elapsed_time > 3000) { demand_switch_ts = millis(); demand = -demand; } } void updateSpeed(float left_new_speed, float right_new_speed) { if (left_new_speed < 0) { left_new_speed = left_new_speed * -1; digitalWrite( L_DIR_PIN, DIR_BKD ); } else { digitalWrite( L_DIR_PIN, DIR_FWD ); } if (right_new_speed < 0) { right_new_speed = right_new_speed * -1; digitalWrite( R_DIR_PIN, DIR_BKD ); } else { digitalWrite( R_DIR_PIN, DIR_FWD ); } analogWrite( L_PWM_PIN, left_new_speed ); analogWrite( R_PWM_PIN, right_new_speed ); } void setupMotors() { pinMode( L_PWM_PIN, OUTPUT ); pinMode( L_DIR_PIN, OUTPUT ); pinMode( R_PWM_PIN, OUTPUT ); pinMode( R_DIR_PIN, OUTPUT ); // Set initial direction for l and r wheels digitalWrite( L_DIR_PIN, DIR_FWD ); digitalWrite( R_DIR_PIN, DIR_FWD ); }
444a84574dada67f6fff47f90de74747d04af98c
a75d9471acfc74a84455ab0809b062e42becb8c7
/ch04/SpeedFactory/Odometer.cpp
afaa2558e83e2214e524be4a71cec405f0a5a455
[ "MIT" ]
permissive
ajunlonglive/Hands-On-Design-Patterns-with-Qt-5
035e57e0d06f1cc6e831d614cb4ac4753001ee5b
00f3f7de9ce75f86e056bf9be942d169bb96d7ff
refs/heads/master
2023-08-14T14:18:48.868284
2021-09-21T23:22:00
2021-09-21T23:22:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
630
cpp
Odometer.cpp
#include "Odometer.h" #include "Blackboard.h" #include <QTimer> Odometer::Odometer(QWidget *parent) : QLCDNumber(parent), KnowledgeSource() { setDigitCount(7); setSmallDecimalPoint(true); setDecMode(); } Odometer::~Odometer() { } void Odometer::setBlackboard(Blackboard *a_blackboard) { KnowledgeSource::setBlackboard(a_blackboard); QTimer::singleShot(250, this, &Odometer::doTimedUpdate); } void Odometer::doTimedUpdate() { auto val = m_blackboard->inspect("distance").data.toDouble(); display(QString::number(val, 'f', 1)); QTimer::singleShot(250, this, &Odometer::doTimedUpdate); }
5ed71211d77bfe18dc855da25232e93c998d9a1f
2e1dd0d5557e8945e87602b010675eacc67b088c
/Dfs(wr)_단지번호붙이기.cpp
27bbc0dcf21437715f89bcc28a836a73251c104d
[]
no_license
overnew/CodeSaving
7df25fd386f19fdb133601b14c493730e55bae0e
f0a1a4ccb69e4f34364cfea786b8a4cbe62bb2a8
refs/heads/master
2023-08-11T00:13:35.955455
2023-07-29T11:00:57
2023-07-29T11:00:57
243,216,637
1
0
null
null
null
null
UTF-8
C++
false
false
1,265
cpp
Dfs(wr)_단지번호붙이기.cpp
//https://www.acmicpc.net/problem/2667 /* bfs로도 풀수 있는 문제. DFS의 경우 -> 스택을 활용해 최근에 넣은 것을 pop해 4가지로 뻗어 나감. BFS의 경우 -> 큐를 활용: 먼저 넣은 것을 먼저 pop해서 4가지 분류를 큐의 뒤에 */ #include <iostream> #include<string> #include<string.h> #include<algorithm> #include<vector> using namespace std; int n,cnt; //int arr[25][25]; string arr[25]; bool visited[25][25]; vector<int> ans; int change_x[4] = {0,1,0,-1}; int change_y[4] = {-1,0,1,0}; void Dfs(int x,int y){ visited[x][y] = true; cnt++; for(int i=0; i<4; ++i){ int nx = x+change_x[i]; int ny = y+change_y[i]; if( 0<= nx && nx< n && 0<= ny && ny< n) if(arr[nx][ny] =='1' && visited[nx][ny]==false) Dfs(nx,ny); } } int main() { cin>>n; memset(visited, false, sizeof(visited)); for(int i=0; i<n ; ++i){ cin>>arr[i]; } for(int i=0; i<n ; ++i){ for(int j=0; j<n ; ++j){ if(arr[i][j] == '1' && visited[i][j]==false){ cnt=0; Dfs(i, j); ans.push_back(cnt); } } } sort(ans.begin(), ans.end()); cout<<ans.size()<<'\n'; for(int i=0; i<ans.size() ;++i){ cout<<ans[i] <<'\n'; } return 0; }
53db9e8c3e5b4123992c9a7b9d3864faa729c86d
0ded9cc64bb71c088f39db0c71ac85144627920c
/pwx/probe/ibase/pxw-users/pwx-users.cpp
a947e656de2f389b08ef2f83b058ee1d3a41e7e4
[]
no_license
povloid/projects_before_2007
fd09063922ed3dbc73b58217752961784ce86b94
2a672b97df21aec9be65b1a6e38601311dacee91
refs/heads/master
2020-06-05T02:41:56.916028
2014-11-02T08:42:39
2014-11-02T08:42:39
null
0
0
null
null
null
null
KOI8-R
C++
false
false
7,534
cpp
pwx-users.cpp
#include <ibase.h> #include <iostream> #include <string> using namespace std; //Эта структура предназначена для хранения переменных типа SQL_VARYING #define SQL_VARCHAR(len) struct {short vary_length; char vary_string[(len)+1];} //Начало главной процедуры программы int main (void) { //Константы, необходимые для работы с базой данных //char *dbname = "192.168.0.77:/home/fdb/PWCRDB.FDB"; char *dbname = "192.168.0.2:c:\\PowerNew\\PWCRDB.FDB"; char *uname = "sysdba"; char *upass = "masterkey"; char *query = "select us, passw from us"; //Переменные для работы с базой данных isc_db_handle db_handle = NULL; isc_tr_handle transaction_handle = NULL; isc_stmt_handle statment_handle = NULL; char dpb_buffer[256], *dpb, *p; short dpb_length; ISC_STATUS status_vector[20]; XSQLDA *isqlda, *osqlda; long fetch_code; short o_ind[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //Остальные переменные SQL_VARCHAR(20) us_us; SQL_VARCHAR(20) us_passw; //вывод сообщения на экран cout<<"Начали"<<endl; //Подключаемся к базе данных в два этапа: // 1. Создаем такназываемый database parametr buffer, необходимый // для подключения к базе данных dpb=dpb_buffer; *dpb++ = isc_dpb_version1; *dpb++ = isc_dpb_user_name; *dpb++ = strlen(uname); for (p=uname; *p;) *dpb++ = *p++; *dpb++ = isc_dpb_password; *dpb++ = strlen(upass); for (p=upass; *p;) *dpb++ = *p++; dpb_length = dpb- dpb_buffer; // 2. Подключаемся к базе денных isc_attach_database(status_vector, strlen(dbname), dbname, &db_handle, dpb_length, dpb_buffer); //Далее идет проверка стандартная для большенства API-функций проверка и анализ результата if (status_vector[0] == 1 && status_vector[1]) { cout<<"Ошибка!"<<endl; isc_print_status(status_vector); cout<<"Приложение завершено с ошибкой."<<endl; return (1); //Выход из приложения } //Если подключение к базе денных произошло успешно, начинается транзакция if (db_handle) { isc_start_transaction(status_vector, &transaction_handle, 1, &db_handle, 0, NULL); //Проверка на ошибку if (status_vector[0] == 1 && status_vector[1]) { cout<<"Ошибка!"<<endl; isc_print_status(status_vector); cout<<"Приложение завершено с ошибкой."<<endl; return (1); } } //Далее инициализируются структуры, которые будут заполняться результатами //запроса osqlda = (XSQLDA *) malloc (XSQLDA_LENGTH(6)); osqlda->version=SQLDA_VERSION1; osqlda->sqln=2; //Имя пользователя osqlda->sqlvar[0].sqldata = (char *)&us_us; osqlda->sqlvar[0].sqltype = SQL_VARYING; osqlda->sqlvar[0].sqlind = &o_ind[0]; //Пароль osqlda->sqlvar[1].sqldata = (char *)&us_passw; osqlda->sqlvar[1].sqltype = SQL_VARYING; osqlda->sqlvar[1].sqlind = &o_ind[1]; //Подготовка к выполнению запроса сервером isc_dsql_allocate_statement( status_vector, &db_handle, &statment_handle); //Проверка на ошибку if (status_vector[0] == 1 && status_vector[1]) { cout<<"Ошибка!"<<endl; isc_print_status(status_vector); cout<<"Приложение завершено с ошибкой."<<endl; return (1); } isc_dsql_prepare( status_vector, &transaction_handle, &statment_handle, 0, query, SQL_DIALECT_V6, osqlda); //Проверка на ошибку if (status_vector[0] == 1 && status_vector[1]) { cout<<"Ошибка!"<<endl; isc_print_status(status_vector); cout<<"Приложение завершено с ошибкой."<<endl; return (1); } isc_dsql_execute2( status_vector, &transaction_handle, &statment_handle, 1, NULL, NULL); //Проверка на ошибку if (status_vector[0] == 1 && status_vector[1]) { cout<<"Ошибка!"<<endl; isc_print_status(status_vector); cout<<"Приложение завершено с ошибкой."<<endl; return (1); } //здесь начинается таблица HTML-документа cout<<"Результат запроса:"<<endl; cout<<"Ном.\tПольз.\t\tПароль"<<endl; //После исполнения запроса сервер готов к передаче данных. "Доставкой" дан- //ных занимается функция isc_dsql_fetch(): int index=0; while ((fetch_code = isc_dsql_fetch( status_vector, &statment_handle, 1, osqlda))==0) //Для строковых переменных требуется корректно установить длину, так как размер //возвращаемых данных не всегда соответствуем максимально возможному, и если этого //не сделать, то вместе с реальными данными можно получить "мусор" из памяти или остатки //предидущих строк: { us_us.vary_string[us_us.vary_length]='\0'; us_passw.vary_string[us_passw.vary_length]='\0'; cout<<index++<<"\t"<<us_us.vary_string<<"\t"<<us_passw.vary_string<<endl; } //После вывода всех данных необходимо завершить документ cout<<"\n Запрос выполнен."<<endl; //Проверка на ошибку if (status_vector[0] == 1 && status_vector[1]) { cout<<"Ошибка!"<<endl; isc_print_status(status_vector); cout<<"Приложение завершено с ошибкой."<<endl; return (1); } free(osqlda); isc_dsql_free_statement(status_vector,&statment_handle,DSQL_drop); //Проверка на ошибку if (status_vector[0] == 1 && status_vector[1]) { cout<<"Ошибка!"<<endl; isc_print_status(status_vector); cout<<"Приложение завершено с ошибкой."<<endl; return (1); } //Затем завершить транзакцию и выйти if (transaction_handle) { isc_commit_transaction(status_vector,&transaction_handle); } //Проверка на ошибку if (status_vector[0] == 1 && status_vector[1]) { cout<<"Ошибка!"<<endl; isc_print_status(status_vector); cout<<"Приложение завершено с ошибкой."<<endl; return (1); } if (db_handle) isc_detach_database(status_vector,&db_handle); //Проверка на ошибку if (status_vector[0] == 1 && status_vector[1]) { cout<<"Ошибка!"<<endl; isc_print_status(status_vector); cout<<"Приложение завершено с ошибкой."<<endl; return (1); } cout<<"Транзакция завершена."<<endl; return 0; }// end of main
e881404cfeeb3bfe3503a675477f12ee7658a789
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5652388522229760_1/C++/mgch/main.cpp
67c79282c8822411aa0dd2efb19175586bef4e7b
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,052
cpp
main.cpp
#include <stdio.h> #include <algorithm> #include <assert.h> #include <set> #include <map> #include <complex> #include <iostream> #include <time.h> #include <stack> #include <stdlib.h> #include <memory.h> #include <bitset> #include <math.h> #include <string> #include <string.h> #include <queue> #include <vector> using namespace std; const int MaxN = 1e5 + 10; const int INF = 1e9; const int MOD = 1e9 + 7; set < int > st; void f(long long x) { while (x > 0) { st.insert(x % 10); x /= 10; } } int main() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); int t; scanf("%d", &t); for (int it = 1; it <= t; ++it) { int n; scanf("%d", &n); printf("Case #%d: ", it); if (n == 0) { printf("INSOMNIA\n"); } else { st.clear(); int val = 0; while (true) { val += n; f(val); if (st.size() == 10) { break; } } printf("%d\n", val); } } return 0; }
f3fd97f7f1368dec0cc06d337a44fd524a58dffc
4a6eb31b6efd60be0f3d4c32b3a88e02cc1885ac
/jcpp/src/main/cpp/jcpp/lang/JString.cpp
c80d8c122654c9cc13d5264b373f97d0b4d9c871
[]
no_license
jeffedlund/rpc
3f84389973651ff77ad09b53459778953843e310
17cba8f2ab4fce50361693db8f59ccf46c19ae78
refs/heads/master
2021-01-10T20:14:04.687475
2013-06-10T09:16:29
2013-06-10T09:16:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,707
cpp
JString.cpp
#include "JString.h" #include "JClass.h" #include "JSerializable.h" #include "Collections.h" #include "QString" #include <algorithm> #include "JObject.h" #include "JBits.h" using namespace jcpp::io; using namespace jcpp::util; namespace jcpp{ namespace lang{ class JStringClass : public JClass{ public: JStringClass(){ this->canonicalName="java.lang.String"; this->name="java.lang.String"; this->simpleName="String"; this->serialVersionUID=-6849794470754667710ULL; addInterface(JSerializable::getClazz()); addInterface(JComparable::getClazz()); addInterface(JCloneable::getClazz()); } JClass* getSuperclass(){ return JObject::getClazz(); } JObject* newInstance(){ return new JString(); } }; static JClass* clazz; JClass* JString::getClazz(){ if (clazz==NULL){ clazz=new JStringClass(); } return clazz; } static map<JString,JString*>* internStrings=NULL; JString* JString::intern(JString s){ getClazz()->lock(); if (internStrings==NULL){ internStrings=new map<JString,JString*>(); } JString* js=getFromMap(internStrings,s); if (js==NULL){ js=new JString(s); internStrings->insert(pair<JString,JString*>(*js,js)); } getClazz()->unlock(); return js; } jint JString::hashCode(JString s){ jint h=0; for (jint i=0;i<s.length();i++){ h=31*h+(jint)s.charAt(i); } return h; } jint JString::compare(JString s1,JString s2){ jint len1 = s1.length(); jint len2 = s2.length(); jint lim = (len1<len2?len1:len2); jint k = 0; while (k < lim) { jchar c1 = s1.charAt(k); jchar c2 = s1.charAt(k); if (c1 != c2) { return c1 - c2; } k++; } return len1 - len2; } JString JString::valueOf(JObject* obj){ return (obj==NULL ? "null" : obj->toString()); } JString::JString(): JObject(false){ } JString::JString(string str): JObject(false){ this->str=str; } JString::JString(JString* str): JObject(false){ this->str=string(str->str); } JString::JString(const char* c): JObject(false){ this->str=string(c); } JString::JString(jchar* c,jint offset,jint length):JObject(false){ char* cs=new char[length+1]; for (jint i=0;i<length;i++){ cs[i+offset]=(char)c[i]; } cs[length] = '\0'; this->str=string(cs);//TODO encoding + test delete cs; } JString::JString(vector<jbyte>* bytes):JObject(false){ this->str=string(bytes->begin(),bytes->end());//TODO encoding + test } JString::JString(vector<jchar>* chars):JObject(false){ jchar* jc=new jchar[chars->size()];//not extra for (unsigned int i=0;i<chars->size();i++){ jc[i]=chars->at(i); } char* cs=new char[chars->size()+1];//TODO encoding+test cs[chars->size()] = '\0'; JBits::putCharFromJChar(cs,jc,0,chars->size()); this->str=string(cs); } JString::JString(const JString& s):JObject(false){ this->str=string(s.str); } JString::JString(jchar c):JObject(false){ this->str=string(); str.push_back(c);//TODO encoding + test } JClass* JString::getClass(){ return JString::getClazz(); } jint JString::length(){ return str.size(); } jbool JString::isEmpty(){ return str.size()==0; } jchar JString::charAt(jint index){ return (jchar)str.at(index); } void JString::setCharAt(jint index,jchar c){ str.assign(index,c); } void JString::deleteChar(jint start,jint end){ str.erase(str.begin()+start,str.begin()+end); } void JString::insertChar(jint index,jchar c){ str.insert(index,1,c); } jint JString::indexOf(JString str){ return this->str.find(str.str,0); } jint JString::indexOf(JString str,jint from){ return this->str.find(str.str,from); } jint JString::lastIndexOf(JString str,jint from){ return this->str.find_last_of(str.str,from); } JString JString::reverse(){ string s=string(str); std::reverse(s.begin(),s.end()); return JString(s); } JString& JString::operator=(JString s){ str=s.str; return *this; } JString& JString::operator=(const char* s){ str=string(s); return *this; } JString& JString::operator+=(JString s){ str+=s.str; return *this; } jbool JString::operator<(JString other) const{ return str<other.str; } jbool JString::operator>(JString other){ return str>other.str; } jbool JString::operator!=(JString other){ return str!=other.str; } jbool JString::operator<=(JString other){ return str<=other.str; } jbool JString::operator>=(JString other){ return str>=other.str; } jbool JString::operator==(JString other){ return str==other.str; } jbool JString::operator==(const char* c){ return str==string(c); } JString JString::operator+(JString s){ JString ss=JString(str); ss<<s; return ss; } JString& JString::operator<<(JString s){ str+=s.str; return *this; } JString& JString::operator<<(jbyte l){ stringstream ss; ss<<str<<l; str=ss.str(); return *this; } JString& JString::operator<<(jchar l){ stringstream ss; ss<<str<<l; str=ss.str(); return *this; } JString& JString::operator<<(char l){ stringstream ss; ss<<str<<l; str=ss.str(); return *this; } JString& JString::operator<<(jdouble l){ stringstream ss; ss<<str<<l; str=ss.str(); return *this; } JString& JString::operator<<(jfloat l){ stringstream ss; ss<<str<<l; str=ss.str(); return *this; } JString& JString::operator<<(jint l){ stringstream ss; ss<<str<<l; str=ss.str(); return *this; } JString& JString::operator<<(jlong l){ stringstream ss; ss<<str<<l; str=ss.str(); return *this; } JString& JString::operator<<(jshort l){ stringstream ss; ss<<str<<l; str=ss.str(); return *this; } bool JString::equals(JObject* other){ if (other->getClass()==getClazz()){ JString* s=dynamic_cast<JString*>(other); return (str==s->str); } return false; } jbool JString::equals(JString other){ return str==other.str; } string JString::getString(){ return str; } void JString::getChars(jint srcBegin, jint srcEnd, jchar dst[], jint dstBegin){ string s=str.substr(srcBegin,srcEnd); const char* cs = s.c_str();//TODO encoding+test JBits::putJCharFromChar(dst,cs,dstBegin,srcEnd-srcBegin); } JString JString::replace(jchar oldchar,jchar newchar){ string s=this->str; std::replace(s.begin(),s.end(),oldchar,newchar); return JString(s); } JString JString::substring(jint start){ return JString(this->str.substr(start,str.size())); } JString JString::substring(jint start,jint end){ return JString(this->str.substr(start,end)); } void JString::setString(string str) { this->str = str; } jint JString::compareTo(JObject* o){ JString* s=dynamic_cast<JString*>(o); return compare(str,s->str); } JString* JString::clone(){ JString* jstr=new JString(this); return jstr; } jint JString::hashCode(){ return hashCode(str); } JString JString::toString(){ return JString(this); } JString::~JString(){ } } } JString jcpp::lang::operator+(string s,jcpp::lang::JString str) { JString ss=JString(s); ss<<str; return ss; } JString jcpp::lang::operator+(const char* s,jcpp::lang::JString str) { JString ss=JString(s); ss<<str; return ss; } ostream& jcpp::lang::operator<<(ostream& os,jcpp::lang::JString o) { os<<o.getString(); return os; }
8ca8a337e43d4b1d3c6aa8f266830b531921efa3
424937067222cef3c416fcc2a7754efd37ba856b
/src/tools/tools.hpp
71d9e83777deceaf3aa51a05065ef7a3d1555a63
[]
no_license
zkerriga/irc-server
e3723621b6f6686fcdbe928dfa035c522ec8dd0f
0cdf6236b8a911a9e4f763ad8be1125465fe0d27
refs/heads/main
2023-03-26T23:36:01.264731
2021-04-01T17:18:43
2021-04-01T17:18:43
330,881,280
1
3
null
2021-04-01T17:18:43
2021-01-19T06:07:30
C++
UTF-8
C++
false
false
5,912
hpp
tools.hpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* tools.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: zkerriga <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/01/25 22:59:42 by zkerriga #+# #+# */ /* Updated: 2021/01/25 22:59:42 by zkerriga ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once #include <iostream> #include <netdb.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <set> #include <algorithm> #include <cstring> #include "types.hpp" #include "ISocketKeeper.hpp" #include "BigLogger.hpp" #include "ACommand.hpp" namespace tools { template <class Container, typename SearchType> typename Container::value_type find(const Container & container, const SearchType & val, bool (*pred)(typename Container::value_type, const SearchType &)) { typename Container::const_iterator it = container.begin(); typename Container::const_iterator ite = container.end(); while (it != ite) { if (pred(*it, val)) { return *it; } ++it; } return nullptr; } template <typename SocketKeeper> bool compareBySocket(SocketKeeper * obj, const socket_type & socket) { if (obj) { return obj->getSocket() == socket; } return false; } bool areSocketsEqual(const ISocketKeeper * sk1, const ISocketKeeper * sk2); template <typename Container> typename Container::value_type findNearestObjectBySocket(const Container & cont, const socket_type socket, const size_t localHopCount) { typename Container::const_iterator it = cont.begin(); typename Container::const_iterator ite = cont.end(); for (; it != ite; ++it) { if ((*it)->getSocket() == socket && (*it)->getHopCount() == localHopCount) { return *it; } } return nullptr; } class socketComparator_t : public std::unary_function<const ISocketKeeper *, bool> { const socket_type c_socket; public: ~socketComparator_t() {} socketComparator_t(const socket_type socket) : c_socket(socket) {} result_type operator()(argument_type socketKeeper) const; static bool socketComparator(socket_type socket, const ISocketKeeper * socketKeeper); }; class senderComparator_t : public std::unary_function<ISocketKeeper *, bool> { socket_type _senderSocket; public: senderComparator_t(socket_type socket) : _senderSocket(socket) {} ~senderComparator_t() {} result_type operator()(argument_type socketKeeper) { if (socketKeeper) { return socketKeeper->getSocket() == _senderSocket; } return false; } }; template <class Container> std::list<typename Container::value_type> getAllSocketKeepersBySocket(const Container & container, socket_type socket) { std::list<typename Container::value_type> result; std::copy_if( container.begin(), container.end(), std::inserter(result, result.begin()), socketComparator_t(socket) ); return result; } template <typename Container> std::set<typename Container::value_type> findObjectsOnFdBranch(const Container & cont, const socket_type socket) { std::set<typename Container::value_type> objSet; typename Container::const_iterator it = cont.begin(); typename Container::const_iterator ite = cont.end(); for (; it != ite ; ++it) { if ((*it)->getSocket() == socket) objSet.insert(*it); } return objSet; } template <typename SocketKeeperPointer> socket_type objectToSocket(const SocketKeeperPointer & obj) { if (!obj) { return 0; } return obj->getSocket(); } template <class SocketKeeperContainer> std::set<socket_type> getUniqueSocketsFromContainer(const SocketKeeperContainer & container) { std::set<socket_type> sockets; std::transform( container.begin(), container.end(), std::inserter(sockets, sockets.begin()), tools::objectToSocket<typename SocketKeeperContainer::value_type> ); return sockets; } template <class ServerNameKeeper> bool compareByServerName(ServerNameKeeper * obj, const std::string & serverName) { if (obj) { return obj->getName() == serverName; } return false; } socket_type configureListenerSocket(const std::string & port); socket_type configureConnectSocket(const std::string & host, const std::string & port); template <class UserNameKeeper> bool compareByName(UserNameKeeper * obj, const std::string & name) { if (obj) { return obj->getName() == name; } return false; } void * getAddress(struct sockaddr *sa); template <class ObjectPointer> void deleteObject(const ObjectPointer obj) { delete obj; } template <class Container> inline void deleteElementsFromContainer(const Container & container) { std::for_each( container.begin(), container.end(), deleteObject<typename Container::value_type> ); } std::string timeToString(time_t time); std::string uptimeToString(time_t time); time_t getModifyTime(const std::string & path); std::string getLinkName(const IServerForCmd & server, socket_type socket); bool sameSocketCompare(const ISocketKeeper * sk1, const ISocketKeeper * sk2); void sumRepliesBuffers(ACommand::replies_container & dst, const ACommand::replies_container & src); } //namespace tools template <typename AbleToString> typename std::enable_if<std::is_integral<AbleToString>::value,std::string>::type operator+(const std::string & str, const AbleToString & add) { return (str + std::to_string(add)); }
afd7cabafb17c4bab2b37aadb1feb24cd205d40a
c47d35768ccf61ac69076d13d50f4a02afe1cfc1
/src/Memory/AlignedMallocator.hpp
bc587a1a266a84ed775e61c8068b45bc441b2cb0
[ "MIT" ]
permissive
epicbrownie/Epic
8eaecc7624739bd91ec86d1cf830cebded068c3c
c54159616b899bb24c6d59325d582e73f2803ab6
refs/heads/master
2020-04-12T06:43:21.216759
2018-04-15T20:33:49
2018-04-15T20:33:49
64,624,266
0
0
MIT
2018-04-20T13:25:18
2016-08-01T00:59:25
C++
UTF-8
C++
false
false
2,582
hpp
AlignedMallocator.hpp
////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2016 Ronnie Brohn (EpicBrownie) // // Distributed under The MIT License (MIT). // (See accompanying file License.txt or copy at // https://opensource.org/licenses/MIT) // // Please report any bugs, typos, or suggestions to // https://github.com/epicbrownie/Epic/issues // ////////////////////////////////////////////////////////////////////////////// #pragma once #include <Epic/Memory/MemoryBlock.hpp> #include <cstdint> #include <cstddef> #include <malloc.h> ////////////////////////////////////////////////////////////////////////////// namespace Epic { class AlignedMallocator; } ////////////////////////////////////////////////////////////////////////////// /// AlignedMallocator class Epic::AlignedMallocator { public: using Type = Epic::AlignedMallocator; public: static constexpr size_t Alignment = alignof(std::max_align_t); static constexpr size_t MinAllocSize = 0; static constexpr size_t MaxAllocSize = _HEAP_MAXREQ; static constexpr bool IsShareable = true; public: constexpr AlignedMallocator() noexcept = default; constexpr AlignedMallocator(const Type&) noexcept = default; constexpr AlignedMallocator(Type&&) noexcept = default; AlignedMallocator& operator = (const Type&) noexcept = default; AlignedMallocator& operator = (Type&&) noexcept = default; public: /* Returns whether or not this allocator is responsible for the block Blk. */ constexpr bool Owns(const Blk& blk) const noexcept { // We don't track allocated blocks and don't discriminate based on block size. // Therefore, we can only return true here. return true; } public: /* Returns a block of uninitialized memory (using ::_aligned_malloc). If sz is zero, the returned block's pointer is null. */ Blk AllocateAligned(size_t sz, size_t alignment = Alignment) const noexcept; /* Attempts to reallocate the memory of blk (aligned to alignment) to the new size sz (using ::_realloc_malloc) If the block's pointer is null, this is equivalent to calling AllocateAligned(sz, alignment) If sz is zero, the returned block's pointer is malloc-implementation-specific. Note: According to ::_realloc_malloc, it is an error to reallocate memory and change the alignment of a block. */ bool ReallocateAligned(Blk& blk, size_t sz, size_t alignment = Alignment) const; public: /* Frees the memory for blk (using ::_aligned_free). */ void DeallocateAligned(const Blk& blk); };
c2c22a29b0386e3e0a47fbfc390a292da1cded25
f455f24b30f3ec8d252682a7d453a82d2bc4e5ba
/src/Circle.cpp
5ec501f20786f00a883262ba61572ea8551e2fbb
[]
no_license
is-xuwei/cpplearning
3ca97556946abd6133371fc844f6bb2232ba8742
001ef639e928d5cb8562b0010c0e62a0f6146560
refs/heads/master
2023-07-21T18:29:18.672121
2018-07-17T14:52:33
2018-07-17T14:52:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
347
cpp
Circle.cpp
#include "Circle.h" #include <iostream> using namespace std; Circle::Circle() { //ctor } Circle::~Circle() { //dtor } int Circle::do_draw() { cout<<"Circle do_draw"<<endl; return 0; } int Circle::do_erase() { cout<<"Circle do_erase"<<endl; return 0; } int Circle::do_sum(int a, int b, int c) { return a + b + c; }
6a4d66ef264456a6d7317e2ef02435772c9b9518
488d475a9dbf18ff76acded0625b7bba9f7fb335
/Urok3Modul6DZ/Funkcii.cpp
5f3405adf0ed3e38bab462c64c3600c3e88ad404
[]
no_license
medvedev1990/Urok3Modul6DZ
4feaa712040583555efd8cb9890a400d3ad01b1a
da96fa099ac7d7a8ce8679d65f28e436d0adde65
refs/heads/master
2020-04-07T13:44:29.647459
2018-03-07T10:08:14
2018-03-07T10:08:14
124,216,927
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
1,324
cpp
Funkcii.cpp
#include<iostream> #include<stdio.h> #include<time.h> #include<locale.h> #include<stdarg.h> #include"Header.h" int i; int ploshad(int *a, int *b) { return *a * *b; } int ploshad(int *a, int *b, int *am, int*bm) { return ((*am * 100) + *a) * ((*bm * 100) + *b); } int u(int *a, int *b) { return *a + *b; } double v (double *a, double *b) { return *a * *b; } double f(double *c, double *q) { double a, b; a = *c*(cos(90-*q)); b = *c*(sin(90-*q)); printf("katet 1 = %f\t katet 2 = %f\n", a, b); return 0; } void rec(int *a, int *q, int *qa) { int chek = 0; int summ = *a; *a = *a - *q; chek++; summ += *a; if (chek < *qa) rec(a,q,qa); printf("n член прогрессии = %d\n сумма n членнов прогресии = %d\n", *a, summ); } void ZappMass(int *mass, int val) { for (i = 0;i < val;i++) { mass[i] = -20 + rand() % 50; } } void PrintMass(int *mass, int val) { for (i = 0;i < val;i++) { printf("%d\t", mass[i]); } printf("\n"); } void summMass(int *mass, int val) { int summPolozh = 0; int summOtr = 0; for (i = 0;i < val;i++) { if (mass[i] < 0) summOtr += mass[i]; else summPolozh += mass[i]; } printf("сумма отрицательных элементов = %d\n сумма положительных элементов = %d\n", summOtr, summPolozh); }
b3e7895209657b6e209d35b13e6d03244e7f3b99
90001cbbb5fd5b5048cc6f9f1265a583c6147ad4
/design model/8. strategy patten/stategy.cpp
d2c4464eb5f1cdfe81baee7c14d7e67db09993da
[]
no_license
Toursar/mycode
44fd6c905ca1a861cef6e3d4a8bc52425a45eb88
c3b5cb6210cf4a16d74c310f6865aeaa24cec0e2
refs/heads/master
2023-02-12T23:14:22.836529
2021-01-09T02:58:50
2021-01-09T02:58:50
289,463,849
1
0
null
null
null
null
UTF-8
C++
false
false
1,462
cpp
stategy.cpp
#include<iostream> using namespace std; //策略模式,类似于状态模式,策略模式侧重于对同一个操作产生不同的方法完成 //状态模式则是,不同状态会产生不同操作 class strategy { public: strategy(){} virtual ~strategy(){} virtual void using_strategy() = 0; }; class version1_strategy : public strategy { public: version1_strategy(){} ~version1_strategy(){} void using_strategy() override { cout << "using strategy model one" << endl; } }; class version2_strategy : public strategy { public: version2_strategy(){} ~version2_strategy(){} void using_strategy() override { cout << "using strategy model two" << endl; } }; class context { private: strategy *stg; public: context(){ stg = nullptr; }; virtual ~context(){ if (stg != nullptr) { delete stg; stg = nullptr; } }; virtual void change_model(strategy* stg1) { if (stg != nullptr) { delete stg; } stg = stg1; stg->using_strategy(); } }; int main() { strategy *test1 = new version1_strategy; strategy *test2 = new version2_strategy; context *context1 = new context; context1->change_model(test1); context1->change_model(test2); if (context1 != nullptr) { delete context1; context1 = nullptr; } return 0; }
cc30d6422ad6c34c8a33bd578a6d69925c0c2a66
89c7bead0bfb7b3b4d3d53450cc69bc4db47b7c2
/SD4/MineCraftClone/Code/Game/General/Utils/Neighborhood.hpp
5e8a2ac1f16e32b798aba9351f327dd1e6a160b7
[]
no_license
itsdrell/SoftwareDevelopment
73fb218ae002a4dc3cd9bbed8f50ccc1a2d8a2f4
546b0d59e21f25a9b951ca0adc38783c1305f7ab
refs/heads/master
2020-03-19T00:43:23.348211
2019-05-08T17:21:37
2019-05-08T17:21:37
135,498,540
0
0
null
null
null
null
UTF-8
C++
false
false
1,817
hpp
Neighborhood.hpp
#pragma once #include "Engine/Math/Vectors/IntVector2.hpp" #include <vector> //==================================================================================== // Forward Declare //==================================================================================== //==================================================================================== // Type Defs + Defines //==================================================================================== //==================================================================================== // ENUMS //==================================================================================== //==================================================================================== // Structs //==================================================================================== //==================================================================================== // Classes //==================================================================================== class Neighborhood { public: Neighborhood(int radius); public: std::vector<IntVector2> m_blockCoords; }; bool SortBlockCoordsByDistanceFromOrigin(IntVector2 a, IntVector2 b); //==================================================================================== // Standalone C Functions //==================================================================================== //==================================================================================== // Externs //==================================================================================== //==================================================================================== // Written by Zachary Bracken : [2/16/2019] //====================================================================================
002c4e1c19c129f7eb6ea1a13835222faf44117a
aa7f08e2a11774e462c36c644a93103c747a6b30
/Source/CeleX5Demo_Client/mainwindow.cpp
9a887dadb88ab22eac10948dc5cc55ca9ac0be29
[ "Apache-2.0" ]
permissive
CelePixel/CeleX5-ZYNQ
55d12d25a606ed9086ed7721c45c611f1c0f2596
de1058cb4905984f2a1279ec612105d70a7c117b
refs/heads/master
2021-07-03T23:10:22.572553
2020-09-09T07:14:47
2020-09-09T07:14:47
168,104,471
1
3
null
null
null
null
UTF-8
C++
false
false
822
cpp
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QCloseEvent> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , m_pCX5Widget(NULL) { ui->setupUi(this); this->move(10, 10); bool bCeleX5Device = true; if (bCeleX5Device) { this->setWindowTitle("CeleX5-Demo"); if (!m_pCX5Widget) { m_pCX5Widget = new CeleX5Widget(this); m_pCX5Widget->setGeometry(0, 0, 1860, 1000); } m_pCX5Widget->show(); setCentralWidget(m_pCX5Widget); } this->showMaximized(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::closeEvent(QCloseEvent *event) { cout << "MainWindow::closeEvent" << endl; if (m_pCX5Widget) m_pCX5Widget->closeEvent(event); }
fb8a7bb901dbdc5b2e451ae2817b69b126b5ffbb
813c4a4fac8c27ef56f47d2e30f3f6b907ee8f5f
/ifcrypt/memp.h
6cf5f75ca43056408ee38da6c0b416754cbd415e
[]
no_license
bhlzlx/MyOpenGLProjects
8bae13956f6a641ca7cad097c078d9897115c1e4
57e12866d4f847f56f1310ffcda592b3c008ca77
refs/heads/master
2020-12-24T05:40:16.897897
2017-10-13T10:32:44
2017-10-13T10:32:44
92,964,636
1
2
null
null
null
null
GB18030
C++
false
false
5,921
h
memp.h
#pragma once #include <cstdio> #include <mutex> #include <cstdint> #include <mutex> #include <cassert> namespace iflib { class MEMPException { public: enum MemOper { MemOperAlloc, MemOperFree, }; MemOper oper; }; template < class T, uint8_t ALIGN = 3 > // 默认8字节对齐 class MEMP { private: static const size_t UNITSIZE = (sizeof(T) + (2 << ALIGN) - 1)&~((2 << ALIGN) - 1); private: std::mutex mtx; // #pragma pack( push, 4 ) template< class T > struct Unit { uint8_t data[UNITSIZE]; union { uint32_t flag; uint32_t next; }; void MakeAllocated() { flag |= FLAG_ALLOCATED; } void MakeFree() { flag &= FLAG_FREE; } uint8_t IsAllocated() { return flag&FLAG_ALLOCATED; } Unit() { flag = 0; } const static int FLAG_ALLOCATED = 0x1; const static int FLAG_FREE = ~FLAG_ALLOCATED; }; template< class T > struct Block { uint32_t size; uint32_t free; uint32_t freeId; Block<T>* next; Unit<T> units[0]; static Block<T> * NewBlock(size_t _nUnit) { void * ptr = nullptr; while (! (ptr = malloc(sizeof(Block<T>) * sizeof(Unit<T>) * _nUnit)) ); Block<T>* block = (Block<T>*)ptr; Unit<T> * unitArry = new(block->units)Unit<T>[_nUnit]; // 调用每个Unit的默认构造函数 for (size_t i = 0; i < _nUnit-1; ++i) { block->units[i].next = i + 1; } block->units[_nUnit - 1].next = 0xffffffff; block->free = _nUnit; block->freeId = 0; block->size = _nUnit; block->next = nullptr; return block; } Unit<T>* Alloc() { if (free) { --free; Unit<T> * unit = &units[freeId]; freeId = units[freeId].next; unit->MakeAllocated(); return unit; } return nullptr; } bool Free(uint8_t * _ptr) { if (_ptr < units[0].data || _ptr > units[size-1].data ) { return false; } size_t loc = (_ptr - &units[0].data[0]) / sizeof(Unit<T>); Unit<T>* unit = (Unit<T>*)_ptr; if ( (_ptr == (loc * sizeof(Unit<T>) + &units[0].data[0])) && unit->IsAllocated() ) { unit->MakeFree(); unit->next = freeId; freeId = loc; ++free; return true; } else { // 回收的指针在内存块中,但是指针可能已经被回收了,或者指针根本没有对齐到结构体上 MEMPException except; except.oper = MEMPException::MemOperFree; throw except; return false; } } }; #pragma pack( pop ) private: Block<T>* head; Block<T>* last; uint32_t blockCount; uint32_t initSize; uint32_t growSize; public: MEMP( size_t _init, size_t _grow ) { initSize = _init; growSize = _grow; last = head = Block<T>::NewBlock( _init ); last->next = nullptr; blockCount = 1; } void Grow() { last->next = Block<T>::NewBlock(growSize); last = last->next; ++this->blockCount; } template< class PARAM > T* Alloc( PARAM _param ) { std::lock_guard<std::mutex> lock(mtx); Block<T> * block = head; Unit<T>* ptr = nullptr; while (block) { if (block->free) { ptr = block->Alloc(); return new(ptr)T( std::forward<PARAM>(_param) ); //return (T*)ptr; } block = block->next; } Grow(); ptr = last->Alloc(); return new(ptr)T(std::forward<PARAM>(_param)); } template< class PARAM1, class PARAM2 > T* Alloc(PARAM1 _param1, PARAM2 _param2 ) { std::lock_guard<std::mutex> lock(mtx); Block<T> * block = head; Unit<T>* ptr = nullptr; while (block) { if (block->free) { ptr = block->Alloc(); return new(ptr)T(std::forward<PARAM1>(_param1), std::forward<PARAM2>(_param2)); //return (T*)ptr; } block = block->next; } Grow(); ptr = last->Alloc(); return new(ptr)T(std::forward<PARAM1>(_param1), std::forward<PARAM2>(_param2)); } template< class PARAM1, class PARAM2, class PARAM3> T* Alloc(PARAM1 _param1, PARAM2 _param2, PARAM3 _param3) { std::lock_guard<std::mutex> lock(mtx); Block<T> * block = head; Unit<T>* ptr = nullptr; while (block) { if (block->free) { ptr = block->Alloc(); return new(ptr)T(std::forward<PARAM1>(_param1), std::forward<PARAM2>(_param2), std::forward<PARAM3>(_param3)); //return (T*)ptr; } block = block->next; } Grow(); ptr = last->Alloc(); return new(ptr)T(std::forward<PARAM1>(_param1), std::forward<PARAM2>(_param2), std::forward<PARAM3>(_param3)); } template< class PARAM1, class PARAM2, class PARAM3, class PARAM4> T* Alloc(PARAM1 _param1, PARAM2 _param2, PARAM3 _param3, PARAM4 _param4) { std::lock_guard<std::mutex> lock(mtx); Block<T> * block = head; Unit<T>* ptr = nullptr; while (block) { if (block->free) { ptr = block->Alloc(); return new(ptr)T(std::forward<PARAM1>(_param1), std::forward<PARAM2>(_param2), std::forward<PARAM3>(_param3), std::forward<PARAM3>(_param4)); //return (T*)ptr; } block = block->next; } Grow(); ptr = last->Alloc(); return new(ptr)T(std::forward<PARAM1>(_param1), std::forward<PARAM2>(_param2), std::forward<PARAM3>(_param3), std::forward<PARAM3>(_param4)); } T* Alloc() { std::lock_guard<std::mutex> lock(mtx); Block<T> * block = head; Unit<T>* ptr = nullptr; while (block) { if (block->free) { ptr = block->Alloc(); return (T*)ptr; } block = block->next; } Grow(); ptr = last->Alloc(); return (T*)ptr; } bool Free( T* _ptr ) { std::lock_guard<std::mutex> lock(mtx); Block<T> * block = head; while (block) { if (block->Free((uint8_t*)_ptr)) { return true; } block = block->next; } return false; } ~MEMP() { Block<T> * block = head; while (block) { Block<T> * next = block->next; free(block); block = next; } } }; }
e196d74413ded09938babc9b8c736bf00eea627b
67b68b6b5197ee30f54333fc2cec9d01644fe8a8
/rowgenerator.cpp
42e5a626ec44a1388d6de80e64746d1898897d5b
[]
no_license
Leofierus/skyscraper-ps
376dbf53ab0b69ce8b16bc518a3df07665dbe628
769388c2b52b3ac8b3c23ec78f91457cc3f2f020
refs/heads/master
2021-06-01T02:22:24.442962
2016-07-15T16:34:28
2016-07-15T16:34:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,092
cpp
rowgenerator.cpp
#include "rowgenerator.h" #include "ui_RowGenerator.h" #include <QFileDialog> #include <QTextStream> #include <QMessageBox> RowGenerator::RowGenerator(QWidget *parent) : QDialog(parent), ui(new Ui::RowGenerator) { ui->setupUi(this); } RowGenerator::RowGenerator(list<vector<SkyScraper> >& possible, QWidget *parent) : QDialog(parent), ui(new Ui::RowGenerator) { ui->setupUi(this); this->possible = possible; //ui->treeWidget->setHeaderHidden(true); ui->treeWidget->setColumnCount(2); if(QTreeWidgetItem* header = ui->treeWidget->headerItem()) { header->setText(0,"Type"); header->setText(1,"Size"); } root = new QTreeWidgetItem(ui->treeWidget); root->setText(0,"All"); root->setText(1, QString::number(possible.size())); ui->treeWidget->addTopLevelItem(root); ui->treeWidget->expandAll(); generateTree(); generateRows(); } RowGenerator::~RowGenerator() { delete ui; } void RowGenerator::generateRows() { QListWidget* listwidget = ui->listWidget; QString numbers = ""; rowIterator begin = possible.begin(), end = possible.end(); for(; begin!=end; begin++) { numbers = ""; for(unsigned int i=0; i<begin->size(); i++) { int num = (*begin)[i]; numbers.append(QString::number(num) + " "); } QListWidgetItem *newItem = new QListWidgetItem; newItem->setText(numbers); newItem->setFont (QFont ("Courier", 20)); listwidget->addItem(newItem); } } void RowGenerator::generateTree() { rowIterator begin = possible.begin(), end = possible.end(); int typenum(0), count(0); while(begin!=end) { QTreeWidgetItem* item = new QTreeWidgetItem(); root->addChild(item); typenum = (*begin)[0]; item->setText(0,QString::number(typenum)); while((*begin)[0]==typenum) { count++; begin++; } item->setText(1,QString::number(count)); count = 0; } } void RowGenerator::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column) { int number = item->text(0).toInt(); QListWidget* listwidget = ui->listWidget; listwidget->clear(); QString numbers = ""; rowIterator begin = possible.begin(), end = possible.end(); for(; begin!=end; begin++) { //If number is zero then it mean they selected all. if(!number || (*begin)[0]==number) { numbers = ""; for(unsigned int i=0; i<begin->size(); i++) { int num = (*begin)[i]; numbers.append(QString::number(num) + " "); } QListWidgetItem *newItem = new QListWidgetItem; newItem->setText(numbers); newItem->setFont (QFont ("Courier", 20)); listwidget->addItem(newItem); } } } void RowGenerator::on_pushButton_clicked() { QFileDialog fileDialog(this); fileDialog.setDefaultSuffix("csv"); fileDialog.setNameFilter("CVS files (*.csv);; Text files (*.txt)"); fileDialog.setDirectory(QApplication::applicationFilePath()); fileDialog.setAcceptMode(QFileDialog::AcceptSave); fileDialog.exec(); QString filename = fileDialog.selectedFiles().first(); QFile file( filename ); if(filename!="" && file.open( QIODevice::WriteOnly )) { QTextStream out(&file); rowIterator begin = possible.begin(), end = possible.end(); for(; begin!=end; begin++) { for(unsigned int i=0; i<begin->size(); i++) { int num = (*begin)[i]; out<< QString::number(num); } out<<"\n"; } file.close(); QMessageBox messageBox; messageBox.information(0,"Saved Filed","The file has been saved successfully!"); messageBox.setFixedSize(500,200); } else { return; } }
c62d023b31ae36d0728d7694b34170cdbdea1b3d
61f661ee029c4aaf113350483ac9cd4d53f674dc
/NEUPlateR_server-master/Business/TollStation/toll_station.cpp
913a71b0d51c8b19022ec0b947dfb74c01630f5f
[]
no_license
jingma-git/NEUPlate
17488cf06c4679b0502bf280c0817e25ec557c2d
79bf7c001e3d395a82e131414d22954f70ff8029
refs/heads/master
2023-08-14T06:40:59.921182
2021-09-25T06:57:08
2021-09-25T06:57:08
409,620,951
0
0
null
null
null
null
UTF-8
C++
false
false
1,613
cpp
toll_station.cpp
#include "toll_station.h" CTollStation::CTollStation() { } CTollStation::CTollStation(const QString &id, const QString &name, QString &province, std::vector<CLane>& lanes): m_id(id),m_name(name),m_province(province),m_lanes(lanes){} CTollStation::CTollStation(QJsonObject &obj){ m_id = obj.value("id").toString(); m_name = obj.value("name").toString(); m_province = obj.value("province").toString(); QJsonArray lane_array = obj.value("lanes").toArray(); for(const QJsonValue &val: lane_array){ CLane lane(val.toObject()); m_lanes.push_back(lane); } } QJsonObject CTollStation::toJSON() const{ QJsonObject station_json; station_json.insert("id", m_id); station_json.insert("name",m_name); station_json.insert("province", m_province); QJsonArray lane_array; int size = m_lanes.size(); for(int i=0; i<size; i++){ lane_array.append(m_lanes[i].toJSON()); } station_json.insert("lanes", lane_array); return station_json; } QString CTollStation::id() const{ return this->m_id; } void CTollStation::setId(const QString &id){ this->m_id = id; } QString CTollStation::name() const{ return this->m_name; } void CTollStation::setName(const QString &name){ this->m_name = name; } QString CTollStation::province() const{ return this->m_province; } void CTollStation::setProvince(const QString &province){ this->m_province = province; } std::vector<CLane> CTollStation::lanes() const{ return this->m_lanes; } void CTollStation::setLanes(const std::vector<CLane> &lanes){ this->m_lanes = lanes; }
bb19c2fcf951bc5c8f6400938c30361bedc127e9
ea91bffc446ca53e5942a571c2f7090310376c9d
/unittests/utils/ReverseIterationTest.cpp
3adf1f6d0bbc5476ca29a29ae83118380e7463f4
[]
no_license
macro-l/polarphp
f7b1dc4b609f1aae23b4618fc1176b8c26531722
f6608c4dc26add94e61684ed0edd3d5c7e86e768
refs/heads/master
2022-07-21T23:37:02.237733
2019-08-15T10:32:06
2019-08-15T10:32:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,893
cpp
ReverseIterationTest.cpp
// This source file is part of the polarphp.org open source project // // Copyright (c) 2017 - 2019 polarphp software foundation // Copyright (c) 2017 - 2019 zzu_softboy <zzu_softboy@163.com> // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://polarphp.org/LICENSE.txt for license information // See https://polarphp.org/CONTRIBUTORS.txt for the list of polarphp project authors // // Created by polarboy on 2018/07/15. #include "polarphp/utils/ReverseIteration.h" #include "polarphp/basic/adt/DenseMap.h" #include "polarphp/basic/adt/DenseMapInfo.h" #include "gtest/gtest.h" using namespace polar; using namespace polar::utils; using namespace polar::basic; namespace { TEST(ReverseIterationTest, testDenseMapTest1) { static_assert(polar::utils::internal::IsPointerLike<int *>::value, "int * is pointer-like"); static_assert(polar::utils::internal::IsPointerLike<uintptr_t>::value, "uintptr_t is pointer-like"); static_assert(!polar::utils::internal::IsPointerLike<int>::value, "int is not pointer-like"); static_assert(polar::utils::internal::IsPointerLike<void *>::value, "void * is pointer-like"); struct IncompleteType; static_assert(polar::utils::internal::IsPointerLike<IncompleteType *>::value, "incomplete * is pointer-like"); // For a DenseMap with non-pointer-like keys, forward iteration equals // reverse iteration. DenseMap<int, int> map; int keys[] = { 1, 2, 3, 4 }; // Insert keys into the DenseMap. for (auto key: keys) { map[key] = 0; } // Note: This is the observed order of keys in the DenseMap. // If there is any change in the behavior of the DenseMap, this order // would need to be adjusted accordingly. int iterKeys[] = { 2, 4, 1, 3 }; // Check that the DenseMap is iterated in the expected order. for (const auto &Tuple : zip(map, iterKeys)) { ASSERT_EQ(std::get<0>(Tuple).first, std::get<1>(Tuple)); } // Check operator++ (post-increment). int i = 0; for (auto iter = map.begin(), end = map.end(); iter != end; iter++, ++i) { ASSERT_EQ(iter->first, iterKeys[i]); } } } // anonymous namespace // Define a pointer-like int. struct PtrLikeInt { int value; }; namespace polar { namespace basic { template<> struct DenseMapInfo<PtrLikeInt *> { static PtrLikeInt *getEmptyKey() { static PtrLikeInt EmptyKey; return &EmptyKey; } static PtrLikeInt *getTombstoneKey() { static PtrLikeInt tombstoneKey; return &tombstoneKey; } static int getHashValue(const PtrLikeInt *P) { return P->value; } static bool isEqual(const PtrLikeInt *lhs, const PtrLikeInt *rhs) { return lhs == rhs; } }; } // basic } // end namespace polar namespace { TEST(ReverseIterationTest, testDenseMapTest2) { static_assert(polar::utils::internal::IsPointerLike<PtrLikeInt *>::value, "PtrLikeInt * is pointer-like"); PtrLikeInt a = {4}, b = {8}, c = {12}, d = {16}; PtrLikeInt *keys[] = { &a, &b, &c, &d }; // Insert keys into the DenseMap. DenseMap<PtrLikeInt *, int> map; for (auto *key : keys) { map[key] = key->value; } // Note: If there is any change in the behavior of the DenseMap, // the observed order of keys would need to be adjusted accordingly. if (should_reverse_iterate<PtrLikeInt *>()) { std::reverse(&keys[0], &keys[4]); } // Check that the DenseMap is iterated in the expected order. for (const auto &Tuple : zip(map, keys)) { ASSERT_EQ(std::get<0>(Tuple).second, std::get<1>(Tuple)->value); } // Check operator++ (post-increment). int i = 0; for (auto iter = map.begin(), end = map.end(); iter != end; iter++, ++i) { ASSERT_EQ(iter->second, keys[i]->value); } } } // anonymous namespace
fa311eb9c790c0ee1b538f5739b4bb0b5583d8d4
5e76ce59592bf5f959eb3ca48e50626eac03d3ec
/tests/compatibility.cc
95a4394e10d08fcef21a5a74ffd666c6ae5f7a3d
[ "MIT" ]
permissive
minkezhang/giga
2d8607c6ca52c68b7ea14f876b2a0e493d8fe0a8
bae6fe295e417b132ba5b6064fb25906188e3cbe
refs/heads/master
2021-05-27T07:08:57.423281
2014-10-03T04:23:59
2014-10-03T04:23:59
20,339,954
1
1
null
null
null
null
UTF-8
C++
false
false
570
cc
compatibility.cc
#include <map> #include <vector> #include "libs/catch/catch.hpp" TEST_CASE("giga|compatibility") { { INFO("WARNING: system does not support files larger than 4GB"); CHECK(sizeof(size_t) > 4); } { std::vector<uint8_t> v; REQUIRE(v.size() == 0); v.push_back(1); v.clear(); REQUIRE(v.size() == 0); // cf. http://bit.ly/1oZIz1e std::vector<uint8_t>().swap(v); INFO("WARNING: vector does not manually resize capacity"); CHECK(v.capacity() == 0); } { INFO("WARNING: RAND_MAX is below recommended size"); CHECK(RAND_MAX >= 2147483647); } }
0861cce4ef63acb95dfc161da631e37633db368a
2e359b413caee4746e931e01807c279eeea18dca
/2210. Count Hills and Valleys in an Array.cpp
7aab39fc8d2468d542b621a528787c8af59fd65e
[]
no_license
fsq/leetcode
3a8826a11df21f8675ad1df3632d74bbbd758b71
70ea4138caaa48cc99bb6e6436afa8bcce370db3
refs/heads/master
2023-09-01T20:30:51.433499
2023-08-31T03:12:30
2023-08-31T03:12:30
117,914,925
7
3
null
null
null
null
UTF-8
C++
false
false
413
cpp
2210. Count Hills and Valleys in an Array.cpp
class Solution { public: int countHillValley(vector<int>& a) { int i = 1, ans = 0; while (i+1 < a.size()) { int pre = a[i-1]; while (i+1<a.size() && a[i]==a[i+1]) ++i; if (i+1==a.size()) break; if (a[i]>pre && a[i]>a[i+1] || a[i]<pre && a[i]<a[i+1]) { ++ans; } ++i; } return ans; } };
6cebddac195f0a2814189fa5b89e80d0a160fb5f
b428bd322c86e27044d7a30fedd671cedc995239
/Cocos2d-x/PandaGhost/Classes/GameScene.cpp
1eab7d827999c3a086a8d17a5e5d874bd13bd714
[]
no_license
JoregeSanz/MyRepo
497f18f0d2730bc90859342541be4f8796b297f5
7ea6c91a006f5d544e9734e2fd20dc1ba685f1cc
refs/heads/master
2021-01-10T16:39:32.949602
2015-11-09T22:34:19
2015-11-09T22:34:19
45,870,063
0
0
null
null
null
null
UTF-8
C++
false
false
58,739
cpp
GameScene.cpp
// // GameScene.cpp // PacMan // // Created by jyn on 1/31/14. // // #include "GameScene.h" #include "SimpleAudioEngine.h" //#include "Config.h" #include "WinScene.h" #include "GameOverScene.h" #include "TitleScene.h" using namespace CocosDenshion; #define Accelerometer_Interval 1.0/10.0 #define Update_Interval 1.0/30.0f #define Eat_GhostTime 6.0 #define Appear_ItemTime 10.0 #define Man_Speed 1.5*300*Update_Interval #define Ghost_Speed 1.5*280*Update_Interval #define Item_Speed 1.5*200*Update_Interval #define OnePea_Score 10 #define BigPea_Score 25 //#define Ghost_Score 125 #define Life_Score 25000 #define TEXT_COLOR ccc3(255,255,255)//(64, 41, 229) ,(76,81,163) #define PAUSESCR_PADDING_RATE 0.05 #define SCORE_PADDING_RATE 0.2 #define PANDA_LIFE_PADDING_RATE 0.0 int g_nCurLevel = 0; int g_nTotalScore = 0; float g_fMarginTop; float g_fMarginLeft; float g_gridWidth; float g_gridHeight; int direct[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; int bonusScore[MAX_LEVEL] = {250, 500, 750, 1000, 1500, 2000, 2500, 5000}; bool g_bEatLevelBonus[MAX_LEVEL]; //modified by dukce.pak int g_nGhostScore[4] = {125,250,500, 1000}; int GameScene::m_nLives; float GameScene::m_itemXPos; //----- GameSprite* GameSprite::create(const char *pszFileName) { GameSprite *pobSprite = new GameSprite(); pobSprite->bGhostDied = false; if (pobSprite && pobSprite->initWithFile(pszFileName)) { pobSprite->autorelease(); return pobSprite; } CC_SAFE_DELETE(pobSprite); return NULL; } void GameSprite::setGhostState(int n) { ghostState = n; if (ghostState == GhostStateFadeIn) { this->runAction(CCSequence::create(CCFadeOut::create(0.3f), CCFadeIn::create(0.3f), CCCallFunc::create(this, callfunc_selector(GameSprite::findPath)), NULL)); } else if(ghostState == GhostStateAngel) goHome(); } void GameSprite::findPath() { bFinedPath = false; setGhostState(GhostStateAngel); } void GameSprite::setPandaState(int n) { pandaState = n; if (pandaState == PandaStateReady) { moveEnum = GameMoveNoneEnum; schedule(schedule_selector(GameSprite::pandaReady), 2); } } void GameSprite::pandaReady() { unschedule(schedule_selector(GameSprite::pandaReady)); setPandaState(PandaStateNormal); } void GameSprite::setSpeed(float f) { speed = f; } void GameSprite::setEndPoint(CCPoint pt) { endPoint = pt; } void GameSprite::moveToNextPoint() { CCPoint center = this->getPosition(); if (endPoint.x != center.x) { if (center.x < endPoint.x) { center.x += speed; if (center.x > endPoint.x) center.x = endPoint.x; } else { center.x -= speed; if (center.x < endPoint.x) center.x = endPoint.x; } } if (endPoint.y != center.y) { if (center.y < endPoint.y) { center.y += speed; if (center.y > endPoint.y) center.y = endPoint.y; } else { center.y -= speed; if (center.y < endPoint.y) center.y = endPoint.y; } } this->moveToPoint(center); } void GameSprite::moveToPoint(CCPoint p) { this->setPosition(p); } bool GameSprite::canMove() { CCPoint center = this->getPosition(); if (center.x == endPoint.x && center.y == endPoint.y) { return false; } return true; } void GameSprite::findShortestPath(char* mapInfo, int startx, int starty, int endx, int endy, int row, int col) { bFinedPath = true; int nSize = row*col; vis = new bool[nSize]; memset(vis, 0, sizeof(bool) * nSize); pathx = new int[nSize]; pathy = new int[nSize]; qx = new int[nSize]; qy = new int[nSize]; step = new int[nSize]; map = mapInfo; stx = startx; sty = starty; zx = endx; zy = endy; rows = row; cols = col; int head = 0, tail = 0; qx[tail] = stx, qy[tail] = sty; tail ++; int i; int curx = stx, cury = sty; int x, y; char passchar[]="X *pm.Z"; char c; step[curx + cury * cols ] = 0; vis[curx + cury * cols] = true; while( head < tail ) { curx = qx[head], cury = qy[head]; if( curx == zx && cury == zy ) break; head ++; for( i = 0; i < 4; i ++) { x = curx + direct[i][0]; y = cury + direct[i][1]; // if (x < 0 || x >= rows || y < 0 || y >= cols) // continue; if( vis[x + y * cols] ) continue; c = map[x + y * cols]; if( strchr(passchar, c) ) // check { pathx[x + y * cols] = curx; pathy[x + y * cols] = cury; step[x + y * cols] = step[curx + cury * cols] + 1; qx[tail] = x; qy[tail] = y; vis[x + y * cols] = true; tail ++; } } } nStep = step[curx+cury*cols]+1; rltx = new int[nStep]; rlty = new int[nStep]; nIdx = 0; outpath(curx, cury); rltx[nIdx] = stx; rlty[nIdx] = sty - 2; nIdx++; delete vis; delete pathx; delete pathy; delete qx; delete qy; delete step; // solve(); } void GameSprite::solve() { } void GameSprite::goHome() { CCArray* aryAction = CCArray::create(); for (int i = 0; i < nIdx; i++) { float x = rltx[i]*g_gridWidth + g_gridWidth/2 + g_fMarginLeft; float y = rlty[i]*g_gridHeight + g_gridHeight/2 + g_fMarginTop; CCPoint pt = CCPoint(x, y); float time = 0.13;//(g_gridWidth / speed)/60; if (i == nIdx - 1) { time = time*2; } CCMoveTo* mv = CCMoveTo::create(time, pt); aryAction->addObject(mv); } CCCallFunc* call = CCCallFunc::create(this, callfunc_selector(GameSprite::onRecovery)); aryAction->addObject(call); runAction(CCSequence::create(aryAction)); } void GameSprite::onRecovery() { int x = rltx[nIdx-1]; int y = rlty[nIdx-1]; CCPoint centerP = ccp(x * g_gridWidth + g_gridWidth / 2 + g_fMarginLeft, y * g_gridHeight + g_gridHeight / 2 + g_fMarginTop); setEndPoint(centerP); moveToPoint(centerP); delete rltx; delete rlty; setGhostState(GhostStateNormal); } void GameSprite::outpath(int curx, int cury) { if( curx == stx && cury == sty) return; rltx[nIdx] = curx; rlty[nIdx] = cury; nIdx++; outpath(pathx[curx + cury* cols], pathy[curx + cury * cols]); } GameScene::~GameScene() { removeAllChildrenWithCleanup(true); } CCScene* GameScene::scene() { // 'scene' is an autorelease object CCScene *scene = CCScene::create(); // 'layer' is an autorelease object GameScene *layer = GameScene::create(); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; } // on "init" you need to initialize your instance bool GameScene::init() { ////////////////////////////// // 1. super init first if ( !CCLayer::init() ) { return false; } // setAccelerometerEnabled(true); //If using cocos2d-x ver 2.0.2 or later.. setTouchEnabled(true); // CCSwipeGestureRecognizer * swipe = CCSwipeGestureRecognizer::create(); // swipe->setTarget(this, callfuncO_selector(HelloWorld::didSwipe)); // swipe->setDirection(kSwipeGestureRecognizerDirectionRight | kSwipeGestureRecognizerDirectionLeft); // swipe->setCancelsTouchesInView(true); // this->addChild(swipe); //dukce.pak 2014 - 04 - 10 CCTextureCache::sharedTextureCache()->removeUnusedTextures(); CCShaderCache::sharedShaderCache()->purgeSharedShaderCache(); CCDirector::sharedDirector()->purgeCachedData(); //---- CCSize winSize = CCDirector::sharedDirector()->getWinSize(); // Set scale ratio Config::setScaleFactor(winSize); m_map = NULL; m_arrayPea = new CCArray; m_arrayGhost = new CCArray; m_arrayLife = new CCArray; SimpleAudioEngine::sharedEngine()->stopAllEffects(); removeAllChildrenWithCleanup(true); m_teBlueGhost = CCTextureCache::sharedTextureCache()->addImage("ghost5.png"); m_teSkelGhost = CCTextureCache::sharedTextureCache()->addImage("ghost6.png"); m_teAngelGhost = CCTextureCache::sharedTextureCache()->addImage("ghost7.png"); m_spLoseSkel = CCSprite::create("skel.png"); Config::setScale(m_spLoseSkel); m_spLoseSkel->setPosition(ccp(winSize.width / 2, winSize.height / 2)); this->addChild(m_spLoseSkel, zOrderBigItem); m_spLoseSkel->setVisible(false); //modified by dukce.pak manAteGhostNum = 0; m_spDyingPanda = CCSprite::create("dyingPanda.png"); Config::setScale(m_spDyingPanda); m_spDyingPanda->setScaleX(m_spDyingPanda->getScaleY()); m_spDyingPanda->setPosition(ccp(winSize.width / 2, winSize.height / 2)); this->addChild(m_spDyingPanda, zOrderBigItem); CCRect rcPac = CCRect(0, 0, m_spDyingPanda->getContentSize().width, m_spDyingPanda->getContentSize().height); CCArray *manFrames = CCArray::create(); manFrames->addObject(CCSpriteFrame::create("dyingPanda.png", rcPac)); manFrames->addObject(CCSpriteFrame::create("dyingPanda2.png", rcPac)); CCAnimation *walkAnim = CCAnimation::createWithSpriteFrames(manFrames, 0.25f); m_spDyingPanda->runAction(CCRepeatForever::create(CCAnimate::create(walkAnim))); m_spDyingPanda->setVisible(false); m_bColorMaze = false; // m_bItemAppear = false; //modified by ducke.pak itemState = BonusNone; setLevel(g_nCurLevel); // m_nLife = Init_LifeNum; for (int i = 0; i < GameScene::Lives() - 1; i++) { CCSprite* sprite = CCSprite::create("pacman2.png"); Config::setScale(sprite); sprite->setPosition(ccp(sprite->getContentSize().width * sprite->getScaleX()*0.8* (i) + sprite->getContentSize().width/2 * sprite->getScaleX() + g_fMarginLeft, g_fMarginTop - sprite->getContentSize().height / 2 * sprite->getScaleY() - sprite->getContentSize().height * PANDA_LIFE_PADDING_RATE * sprite->getScaleY())); float height = sprite->getContentSize().height; height *= sprite->getScaleY(); this->addChild(sprite, zOrderPel); m_arrayLife->addObject(sprite); } layoutGameSprites(); m_spPause = CCSprite::create("pause.png"); Config::setScale(m_spPause); float fY = 0; // if (winSize.height == 1136) if (winSize.width == 768 && winSize.height == 1024) fY = 0; else fY = 50*Config::getyScale(); m_spPause->setPosition(ccp(winSize.width * 0.5, m_spPause->getContentSize().height/2 + fY)); this->addChild(m_spPause, zOrderPel); loadHighScores(); updateHighScore(); //modified by dukce.pak m_nScore = g_nTotalScore; //-------- updateScore(); m_spReady = CCSprite::create("ready.png"); m_spReady->setPosition(CCPointMake(winSize.width*0.5, winSize.height*0.5)); Config::setScale(m_spReady); addChild(m_spReady, zOrderMan+1); m_spReadyNum = CCSprite::create("num3.png"); m_spReadyNum->setPosition(CCPointMake(m_spReady->getContentSize().width*0.5, - m_spReady->getContentSize().height/2)); Config::setScale(m_spReadyNum); m_spReady->addChild(m_spReadyNum, zOrderMan+1); preloadSound(); stopGame(); getReady(); return true; } void GameScene::deleteArray() { delete m_arrayPea; delete m_arrayGhost; delete m_arrayLife; delete m_arrHighScore; delete m_arrScore; } void GameScene::preloadSound() { SimpleAudioEngine::sharedEngine()->preloadEffect(SND_LEVEL(m_nLevel + 1)); SimpleAudioEngine::sharedEngine()->preloadEffect(SND_POWER(m_nLevel + 1)); SimpleAudioEngine::sharedEngine()->preloadEffect(SND_BIGCHOMP); SimpleAudioEngine::sharedEngine()->preloadEffect(SND_COINDROP); SimpleAudioEngine::sharedEngine()->preloadEffect(SND_DEATH); SimpleAudioEngine::sharedEngine()->preloadEffect(SND_GATE); SimpleAudioEngine::sharedEngine()->preloadEffect(SND_COMPLETE); SimpleAudioEngine::sharedEngine()->preloadEffect(SND_NEON); SimpleAudioEngine::sharedEngine()->preloadEffect(SND_SMALLPELLET); } void GameScene::getReady() { m_bColorMaze = false; manEatGhostTime = 0; manMoveEnum = GameMoveNoneEnum; m_isPlaying = false; man->setPandaState(PandaStateReady); man->setEndPoint(man->startPoint); man->moveToPoint(man->startPoint); man->moveEnum = GameMoveNoneEnum; man->setRotation(0); for (int i = 0; i < m_arrayGhost->count(); i++) { GameSprite* ghost = (GameSprite*)m_arrayGhost->objectAtIndex(i); ghost->setTexture(ghost->oriTexture); ghost->setEndPoint(ghost->startPoint); ghost->moveToPoint(ghost->startPoint); } m_spReady->setVisible(true); m_spReadyNum->setTexture(CCTextureCache::sharedTextureCache()->addImage("num3.png")); m_nReadyNum = 3; schedule(schedule_selector(GameScene::startGame), 1.0); playBGSound(true); } void GameScene::playBGSound(bool bPlay) { if(bPlay) { SimpleAudioEngine::sharedEngine()->playBackgroundMusic(SND_LEVEL(m_nLevel + 1), true); m_nowPlayingLevel = true; } else SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(); } void GameScene::startGame() { m_nReadyNum--; if (m_nReadyNum == 0) { m_nReadyNum = 3; m_isPlaying = true; m_spReady->setVisible(false); unschedule(schedule_selector(GameScene::startGame)); schedule(schedule_selector(GameScene::updateInterval), Update_Interval); } else{ char temp[20] = {0}; sprintf(temp, "num%d.png", m_nReadyNum); m_spReadyNum->setTexture(CCTextureCache::sharedTextureCache()->addImage(temp)); } } void GameScene::stopGame() { manEatGhostTime = 0; manMoveEnum = GameMoveNoneEnum; m_isPlaying = false; SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(); SimpleAudioEngine::sharedEngine()->stopAllEffects(); unschedule(schedule_selector(GameScene::updateInterval)); } void GameScene::updateEatItems() { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); GameScene::setItemXPos(winSize.width - g_gridWidth - g_fMarginLeft); for (int i = 0; i <= m_nLevel; i++) { if (g_bEatLevelBonus[i] == true) { char temp[20] = {0}; sprintf(temp, "item%02d.png", i + 1); CCSprite* sprite = CCSprite::create(temp); Config::setScale(sprite); float x = GameScene::itemXPos() - sprite->getContentSize().width/2 * sprite->getScaleX(); GameScene::setItemXPos(x - sprite->getContentSize().width / 2 * sprite->getScaleX()); // float y = g_fMarginTop - g_gridHeight - sprite->getContentSize().height / 2 - sprite->getContentSize().height / 10; float y = g_fMarginTop - sprite->getContentSize().height / 2 * sprite->getScaleY() - sprite->getContentSize().height * PANDA_LIFE_PADDING_RATE * sprite->getScaleY(); if(g_bEatLevelBonus[m_nLevel] == true){ if(i == m_nLevel){ sprite->setPosition(ccp(x, y)); this->addChild(sprite, zOrderPel); } } else{ sprite->setPosition(ccp(x, y)); this->addChild(sprite, zOrderPel); } } } } void GameScene::setLevel(int nLevel) { m_nLevel = nLevel; if (nLevel == 0) { for (int i = 0; i < MAX_LEVEL; i++) { g_bEatLevelBonus[i] = false; } } updateEatItems(); //read m_map info from file. char mapName[20] = {0}; sprintf(mapName, "level%d.map", nLevel+1); std::string fullPath = CCFileUtils::sharedFileUtils()->fullPathForFilename(mapName); unsigned long size = 0; unsigned char * pBytes = CCFileUtils::sharedFileUtils()->getFileData(fullPath.c_str(), "rb", &size); char* mapTemp = new char[size]; int nLen = 0; m_nRow = 0; m_nCol = 0; for (int i = 0; i < size; i++) { if (pBytes[i] != 0x0A) { mapTemp[nLen] = pBytes[i]; nLen ++; } else m_nRow ++; } m_nRow ++; m_nCol = size / m_nRow; int nExit = 0; char* mapTemp2 = new char[size]; memset(mapTemp2, 0, size); for (int i = 0; i < m_nRow; i++) { for (int j = 0; j < m_nCol; j++) { char ch = mapTemp[(m_nRow - 1 - i) * m_nCol + j]; mapTemp2[i * m_nCol + j] = ch; if(ch == 'q'){ // m_ptExit[nExit] = CCPoint(j, i); //modified by dukce.pak m_outDoor[nExit].xx = j; m_outDoor[nExit].yy = i; GameMoveEnum enterDirection = GameMoveNoneEnum; if(i == 0) enterDirection = GameMoveTopEnum; else if( i == m_nRow - 1) enterDirection = GameMoveBottomEnum; else if( j == 0) enterDirection = GameMoveRightEnum; else if( j == m_nCol - 1) enterDirection = GameMoveLeftEnum; m_outDoor[nExit].enterDirection = enterDirection; nExit++; } else if(ch == 'Z'){ m_ptGhostHome = CCPoint(j, i); } } } mapTemp2[size] = 0; delete mapTemp; if (m_map) delete m_map; m_map = mapTemp2; delete pBytes; CCSize winSize = CCDirector::sharedDirector()->getWinSize(); if(winSize.width/winSize.height == 768.0/1024.0f) g_fMarginLeft = 60 * Config::getxScale(); else g_fMarginLeft = 0; g_gridWidth = (winSize.width - g_fMarginLeft * 2)/m_nCol; g_fMarginTop = (winSize.height - g_gridWidth * (float)m_nRow) / (float)2.0f;// 100 * Config::getyScale(); g_gridHeight = g_gridWidth;//(winSize.height - g_fMarginTop * 2) / m_nRow; } // Modified by dukce.pak 2014.02.11.17.50 void GameScene::drawWallPath(int x, int y, float margins, XTDirection d) { float fx = x * g_gridWidth + g_fMarginLeft; float fy = (y+1) * g_gridHeight + g_fMarginTop; ccColor4F red = ccc4f(1, 0, 0, 1.0); if (m_bColorMaze) { if (d == LEFT) ccDrawSolidRect(ccp(fx - g_gridWidth * 0.27, fy + g_gridHeight * margins), ccp(fx + g_gridWidth * 0.27, fy - g_gridHeight - g_gridHeight * margins), red); else if (d == RIGHT) ccDrawSolidRect(ccp(fx + g_gridWidth * 0.73, fy + g_gridHeight * margins), ccp(fx + g_gridWidth * 1.27, fy - g_gridHeight - g_gridHeight * margins), red); else if (d == UP) ccDrawSolidRect(ccp(fx - g_gridWidth * margins, fy + g_gridHeight * 0.27 ), ccp(fx + g_gridWidth + g_gridWidth * margins, fy - g_gridHeight * 0.27), red); else if (d == DOWN) ccDrawSolidRect(ccp(fx - g_gridWidth * margins, fy - g_gridWidth * 0.73), ccp(fx + g_gridWidth + g_gridWidth * margins, fy - g_gridHeight * 1.27), red); else if (d == NONE) ccDrawSolidRect(ccp(fx- g_gridWidth * 0.27, fy + g_gridHeight * 0.27), ccp(fx + g_gridWidth * 1.27, fy - g_gridHeight * 1.27), red); } } void GameScene::addPeaWithPoint(int x, int y, bool bBig) { if (x < 0 || y < 0 || x >= m_nCol || y >= m_nRow) { return; } GameSprite *pea; if (!bBig) pea = GameSprite::create("small_pellet.png"); else pea = GameSprite::create("large_pellet.png"); pea->isBig = bBig; pea->setPosition(ccp(x * g_gridWidth + g_gridWidth / 2 + g_fMarginLeft, y * g_gridHeight + g_gridHeight / 2 + g_fMarginTop)); Config::setScale(pea); this->addChild(pea, zOrderPel); m_arrayPea->addObject(pea); } void GameScene::addManWithPoint(int x, int y) { if (x < 0 || y < 0 || x >= m_nCol || y >= m_nRow) { return; } man = GameSprite::create("pacman1.png"); Config::setScale(man); man->setScaleX(man->getScaleY()); man->setRotation(0); this->addChild(man, zOrderMan); CCRect rcPac = CCRect(0, 0, man->getContentSize().width, man->getContentSize().height); CCArray *manFrames = CCArray::create(); manFrames->addObject(CCSpriteFrame::create("pacman1.png", rcPac)); manFrames->addObject(CCSpriteFrame::create("pacman2.png", rcPac)); // Create the animation object CCAnimation *walkAnim = CCAnimation::createWithSpriteFrames(manFrames, 0.3f); man->runAction(CCRepeatForever::create(CCAnimate::create(walkAnim))); CCPoint centerP = ccp(x * g_gridWidth + g_gridWidth / 2 + g_fMarginLeft, y * g_gridHeight + g_gridHeight / 2 + g_fMarginTop); man->startPoint = centerP; man->setEndPoint(centerP); man->moveToPoint(centerP); man->setSpeed(Man_Speed + 15 * m_nLevel * Update_Interval); man->setPandaState(PandaStateReady); } void GameScene::addGhostWithPoint(int x, int y) { if (x < 0 || y < 0 || x >= m_nCol || y >= m_nRow) { return; } int nGhost = m_arrayGhost->count(); char lp[20] = {0}; sprintf(lp, "ghost%d.png", nGhost + 1); GameSprite* ghost = GameSprite::create(lp); Config::setScale(ghost); this->addChild(ghost, zOrderGhost); CCPoint centerP = ccp(x * g_gridWidth + g_gridWidth / 2 + g_fMarginLeft, y * g_gridHeight + g_gridHeight / 2 + g_fMarginTop); ghost->index = nGhost; ghost->startPoint = centerP; ghost->setEndPoint(centerP); ghost->moveToPoint(centerP); ghost->setSpeed(Ghost_Speed + m_nLevel * 15 * Update_Interval); ghost->oriTexture = ghost->getTexture(); m_arrayGhost->addObject(ghost); } void GameScene::addItem() { // int x = m_ptExit[1].x; int y = m_ptExit[1].y; //modified by dukce.pak int door = arc4random() % 2; int x = m_outDoor[door].xx; int y = m_outDoor[door].yy; char lp[20] = {0}; sprintf(lp, "item%02d.png", m_nLevel + 1); m_spBonus = GameSprite::create(lp); m_spBonus->moveEnum = m_outDoor[door].enterDirection; //------- Config::setScale(m_spBonus); this->addChild(m_spBonus, zOrderGhost); CCPoint centerP = ccp(x * g_gridWidth + g_gridWidth / 2 + g_fMarginLeft, y * g_gridHeight + g_gridHeight / 2 + g_fMarginTop); m_spBonus->index = m_nLevel; m_spBonus->setEndPoint(centerP); m_spBonus->moveToPoint(centerP); m_spBonus->setSpeed(Item_Speed /*+ m_nLevel * 30 * Update_Interval*/); m_spBonus->oriTexture = m_spBonus->getTexture(); CCPoint gridPoint = getGridPointWithPoint(m_spBonus->endPoint); GameRoleEnum roleEnum = getRoleEnumByPoint(gridPoint.x, gridPoint.y); if (roleEnum != GameRoleWallEnum){ CCPoint center = this->getCenterWithPoint(gridPoint.x, gridPoint.y); m_spBonus->setEndPoint(center); m_spBonus->moveToPoint(center); } } CCPoint GameScene::getCenterWithPoint(float px, float py) { float x = px*g_gridWidth + g_gridWidth/2 + g_fMarginLeft; float y = py*g_gridHeight + g_gridHeight/2 + g_fMarginTop; CCPoint pt = CCPoint(x, y); return pt; } CCPoint GameScene::getGridPointWithPoint(CCPoint p) { float x = (p.x - g_fMarginLeft)/g_gridWidth; float y = (p.y - g_fMarginTop)/g_gridHeight; CCPoint pt = CCPoint((int)x, (int)y); return pt; } GameRoleEnum GameScene::getRoleEnumByPoint(float px, float py) { if (px < 0 || px >= m_nCol) { return GameRoleWallEnum; } if (py < 0 || py >= m_nRow) { return GameRoleWallEnum; } int num = px + (py * m_nCol); return getRoleEnum(m_map[num]); } bool GameScene::isCrossPointWithSprite(GameSprite* spirit) { CCPoint pt = spirit->endPoint; CCPoint gridPoint = getGridPointWithPoint(pt); GameRoleEnum roleEnum = getRoleEnumByPoint(gridPoint.x, gridPoint.y); if (roleEnum == GameRoleCrossEnum){ // switch (spirit->moveEnum) { // case GameMoveTopEnum: // pt.y += spirit->speed; // break; // case GameMoveBottomEnum: // pt.y -= spirit->speed; // break; // case GameMoveLeftEnum: // pt.x -= spirit->speed; // break; // case GameMoveRightEnum: // pt.x += spirit->speed; // break; // default: // break; // } // CCPoint gridPoint2 = getGridPointWithPoint(pt); // if (gridPoint.x != gridPoint2.x || gridPoint.y != gridPoint2.y) return true; } return false; } bool GameScene::isTopPointWithSprite(GameSprite* spirit) { CCPoint pt = spirit->endPoint; CCPoint gridPoint = getGridPointWithPoint(pt); GameRoleEnum roleEnum = getRoleEnumByPoint(gridPoint.x, gridPoint.y); if (roleEnum == GameRoleTopWayEnum || roleEnum == GameRoleHomeEnum) return true; return false; } //added by dukce.pak void GameScene::panda_visible_true() { if(man) man->setVisible(true); } //---------- // move the spirit left/right/up/down bool GameScene::moveSpiritWidthOrientation(GameSprite* spirit, GameMoveEnum move, bool trans) { CCPoint gridPoint = getGridPointWithPoint(spirit->endPoint); float fDeltaAngle = 0; switch (move) { case GameMoveTopEnum: gridPoint.y += 1; fDeltaAngle = M_PI/2; break; case GameMoveBottomEnum: gridPoint.y -= 1; fDeltaAngle = -M_PI/2; break; case GameMoveLeftEnum: gridPoint.x -= 1; fDeltaAngle = 1; break; case GameMoveRightEnum: gridPoint.x += 1; break; default: break; } CCRotateTo *rotate = CCRotateTo::create(0.1, fDeltaAngle * 180); GameRoleEnum roleEnum = getRoleEnumByPoint(gridPoint.x, gridPoint.y); if ((roleEnum == GameRoleTopWayEnum || roleEnum == GameRoleHomeEnum) && spirit->moveEnum == GameMoveBottomEnum) { return false; } else if (roleEnum == GameRoleExitEnum) { //modified by dukce.pak if ((gridPoint.x == m_outDoor[0].xx && gridPoint.y == m_outDoor[0].yy) || (gridPoint.x == m_outDoor[1].xx && gridPoint.y == m_outDoor[1].yy)) { GameMoveEnum enterDirection = GameMoveNoneEnum; if(man == spirit) man->setVisible(false); if(gridPoint.x == m_outDoor[0].xx && gridPoint.y == m_outDoor[0].yy) { gridPoint.setPoint(m_outDoor[1].xx, m_outDoor[1].yy); enterDirection = m_outDoor[1].enterDirection; } else if(gridPoint.x == m_outDoor[1].xx && gridPoint.y == m_outDoor[1].yy) { gridPoint.setPoint(m_outDoor[0].xx, m_outDoor[0].yy); enterDirection = m_outDoor[0].enterDirection; } // GameRoleEnum roleEnum = getRoleEnumByPoint(gridPoint.x, gridPoint.y); // if (roleEnum != GameRoleWallEnum){ CCPoint center = this->getCenterWithPoint(gridPoint.x, gridPoint.y); spirit->setEndPoint(center); spirit->moveToPoint(center); // } if(man == spirit) manMoveEnum = enterDirection; //------- return true; } } else if (roleEnum != GameRoleWallEnum) { // if (roleEnum != GameRoleWallEnum) { spirit->moveEnum = move;//manMoveEnum;//move; spirit->setEndPoint(this->getCenterWithPoint(gridPoint.x, gridPoint.y)); if(spirit == man) { if (trans) { float scx = spirit->getScaleX(); if (fDeltaAngle == 1) { spirit->runAction(CCSequence::create(CCRotateTo::create(0.1, 0),CCCallFunc::create(this,callfunc_selector(GameScene::panda_visible_true)),NULL)); if(scx >= 0) spirit->setScaleX(-1 * scx); } else{ if(scx < 0) spirit->setScaleX(-1 * scx); spirit->runAction(CCSequence::create(rotate,CCCallFunc::create(this,callfunc_selector(GameScene::panda_visible_true)),NULL)); } } } else { if (trans) { float scx = spirit->getScaleX(); if (fDeltaAngle == 1) { spirit->runAction(CCRotateTo::create(0.1, 0)); if(scx >= 0) spirit->setScaleX(-1 * scx); } else{ if(scx < 0) spirit->setScaleX(-1 * scx); spirit->runAction(rotate); } } } return true; } return false; } //modifed by dukce. pak void GameScene::updateHighScore() { // CCSize winSize = CCDirector::sharedDirector()->getWinSize(); char lpHigh[50] = {0}; sprintf(lpHigh, "%d", m_nHighScores[0]); if(!m_spHighScore) { m_spHighScore = CCSprite::create("highscore.png"); Config::setScale(m_spHighScore); m_spHighScore->setScaleX(m_spHighScore->getScaleX() * 0.7); m_spHighScore->setScaleY(m_spHighScore->getScaleY() * 0.7); m_spHighScore->setPosition(ccp(m_spHighScore->getContentSize().width/2 * m_spHighScore->getScaleX() + g_fMarginLeft + g_gridWidth * 1.5, m_nRow * g_gridHeight + g_fMarginTop + m_spHighScore->getContentSize().height/2 * m_spHighScore->getScaleY())); addChild(m_spHighScore, 5); } if(!m_arrHighScore) { m_arrHighScore = new CCArray(); } else { for (int id = m_arrHighScore->count() - 1; id >= 0; id--) { CCSprite* ccsnum = (CCSprite*)m_arrHighScore->objectAtIndex(id); removeChild(ccsnum); m_arrHighScore->removeObject(ccsnum); } } float ccsNum_xPos = m_spHighScore->getPositionX() + m_spHighScore->getContentSize().width/2 * m_spHighScore->getScaleX() + m_spHighScore->getContentSize().width * m_spHighScore->getScaleX() * SCORE_PADDING_RATE; int i = 0; while(lpHigh[i]) { char number[20] = {0}; int num = lpHigh[i] - 0x30; sprintf(number, "num_%d.png", num); CCSprite * ccsNum = CCSprite::create(number); Config::setScale(ccsNum); ccsNum->setScaleX(ccsNum->getScaleX() * 0.7); ccsNum->setScaleY(ccsNum->getScaleY() * 0.7); ccsNum->setPosition(CCPointMake(ccsNum_xPos + ccsNum->getContentSize().width/2 * ccsNum->getScaleY(), m_nRow * g_gridHeight + g_fMarginTop + ccsNum->getContentSize().height/2 * ccsNum->getScaleY())); ccsNum_xPos += ccsNum->getContentSize().width * ccsNum->getScaleX(); addChild(ccsNum, 5); m_arrHighScore->addObject(ccsNum); i++; } } //modifed by dukce. pak void GameScene::updateScore() { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); char score[50] = {0}; sprintf(score, "%d", m_nScore); if(!m_spScore) { m_spScore = CCSprite::create("score.png"); Config::setScale(m_spScore); m_spScore->setScaleX(m_spScore->getScaleX() * 0.7); m_spScore->setScaleY(m_spScore->getScaleY() * 0.7); m_spScore->setPosition(CCPointMake(winSize.width*0.65 , m_nRow * g_gridHeight + g_fMarginTop + m_spScore->getContentSize().height/2 * m_spScore->getScaleY())); addChild(m_spScore, 5); } if(!m_arrScore) m_arrScore = new CCArray(); else { for (int id = m_arrScore->count() - 1; id >= 0; id--) { CCSprite* ccsnum = (CCSprite*)m_arrScore->objectAtIndex(id); removeChild(ccsnum); m_arrScore->removeObject(ccsnum); } } float ccsNum_xPos = m_spScore->getPositionX() + m_spScore->getContentSize().width/ 2 * m_spHighScore->getScaleX() + m_spScore->getContentSize().width * m_spScore->getScaleX() * SCORE_PADDING_RATE; int i = 0; while(score[i]) { char number[20] = {0}; int num = score[i] - 0x30; sprintf(number, "num_%d.png", num); CCSprite * ccsNum = CCSprite::create(number); Config::setScale(ccsNum); ccsNum->setScaleX(ccsNum->getScaleX() * 0.7); ccsNum->setScaleY(ccsNum->getScaleY() * 0.7); ccsNum->setPosition(CCPointMake(ccsNum_xPos + ccsNum->getContentSize().width/2 * ccsNum->getScaleY(), m_nRow * g_gridHeight + g_fMarginTop + ccsNum->getContentSize().height/2 * ccsNum->getScaleY())); ccsNum_xPos += ccsNum->getContentSize().width * ccsNum->getScaleX(); addChild(ccsNum, 5); m_arrScore->addObject(ccsNum); i++; } /* CCSize winSize = CCDirector::sharedDirector()->getWinSize(); char temp[30] = {0}; sprintf(temp, "Score : %d", m_nScore); if (m_pScoreLabel == NULL) { m_pScoreLabel = CCLabelTTF::create("Score : 0","Marker Felt.ttf", 37); m_pScoreLabel->setFontFillColor(TEXT_COLOR, true); float fY = 0; // if (winSize.height == 1136) fY = g_gridHeight * 2; m_pScoreLabel->setPosition(CCPointMake(winSize.width*0.75, m_nRow * g_gridHeight + g_fMarginTop + m_pScoreLabel->getContentSize().height/2)); Config::setScale(m_pScoreLabel); addChild(m_pScoreLabel, 5); } m_pScoreLabel->setString((const char *)temp); */ } // update & refresh void GameScene::updateInterval() { if (man == NULL || man->pandaState == PandaStateDie || man->pandaState == PandaStateReady) return; manEatGhostTime -= Update_Interval; //added by dukce.pak if(itemState == BonusAppear) { itemAppearTime -= Update_Interval; if( itemAppearTime <= 0) { itemState = BonusOut; //Item delete this->removeChild(m_spBonus, true); m_spBonus = NULL; } } // ---- if (manEatGhostTime < 0){ manEatGhostTime = 0; if(!m_nowPlayingLevel) { SimpleAudioEngine::sharedEngine()->playBackgroundMusic(SND_LEVEL(m_nLevel + 1), true); m_nowPlayingLevel = true; } m_bColorMaze = false; } else{ int nUpateMaze = 60; if (((int)manEatGhostTime * 60 / nUpateMaze) % 2 == 0) m_bColorMaze = false; else m_bColorMaze = true; } { bool bManInCrossPoint = isCrossPointWithSprite(man); if (bManInCrossPoint && man->moveEnum != manMoveEnum) man->moveEnum = manMoveEnum; if (man->canMove()) { man->moveToNextPoint(); } else { if(this->moveSpiritWidthOrientation(man, manMoveEnum, true) == false) this->moveSpiritWidthOrientation(man, man->moveEnum, true); } // CCRect rectPlayer = man->boundingBox(); //Pellet for (int i = m_arrayPea->count() - 1; i >= 0; i--) { GameSprite* pea = (GameSprite*)m_arrayPea->objectAtIndex(i); CCRect rcPea = pea->boundingBox(); if(rcPea.containsPoint(man->getPosition()) == true) { if(pea->isBig){ pauseSchedulerAndActions(); if(m_nowPlayingLevel) { SimpleAudioEngine::sharedEngine()->playBackgroundMusic(SND_POWER(m_nLevel + 1), true); m_nowPlayingLevel = false; } manEatGhostTime = Eat_GhostTime; m_bColorMaze = true; addScore(BigPea_Score, pea->getPosition(), false); for (int i = m_arrayGhost->count() - 1; i >= 0; i--) { GameSprite* ghost = (GameSprite*)m_arrayGhost->objectAtIndex(i); ghost->bGhostDied = false; } resumeSchedulerAndActions(); } else{ SimpleAudioEngine::sharedEngine()->playEffect(SND_SMALLPELLET); addScore(OnePea_Score, pea->getPosition(), false); } removeChild(pea); m_arrayPea->removeObject(pea); if (m_arrayPea->count() == 0) { stopGame(); SimpleAudioEngine::sharedEngine()->playEffect(SND_COMPLETE); scheduleOnce(schedule_selector(GameScene::win), 2.0); } break; } } } //Item Process { if (m_spBonus != NULL){ if (isCrossPointWithSprite(m_spBonus)) { GameMoveEnum e = m_spBonus->moveEnum; while (true) { GameMoveEnum m = (GameMoveEnum)(arc4random()%4 + 1); if ((e == GameMoveTopEnum && m != GameMoveBottomEnum) || (e == GameMoveBottomEnum && m != GameMoveTopEnum) || (e == GameMoveLeftEnum && m != GameMoveRightEnum) || (e == GameMoveRightEnum && m != GameMoveLeftEnum) ) { m_spBonus->moveEnum = m; break; } } } if (m_spBonus->canMove()) { m_spBonus->moveToNextPoint(); } else { GameMoveEnum e = m_spBonus->moveEnum; while (true) { if (e != GameMoveNoneEnum) { if (this->moveSpiritWidthOrientation(m_spBonus, e, false)) { break; } } e = (GameMoveEnum)(arc4random()%4 + 1); } } CCRect rectPlayer = man->boundingBox(); if (rectPlayer.containsPoint(m_spBonus->getPosition())) { addScore(bonusScore[m_nLevel], m_spBonus->getPosition(), true); removeChild(m_spBonus, true); m_spBonus = NULL; // m_bItemAppear = false; itemState = BonusOut; SimpleAudioEngine::sharedEngine()->playEffect(SND_BIGCHOMP); char lp[20] = {0}; sprintf(lp, "bigItem%02d.png", m_nLevel + 1); GameSprite* big = GameSprite::create(lp); Config::setScale(big); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); big->setPosition(ccp(winSize.width / 2, winSize.height/2)); this->addChild(big, zOrderBigItem); CCSequence* seq = CCSequence::create(CCFadeIn::create(0.75), CCFadeOut::create(0.75), NULL); big->runAction(seq); g_bEatLevelBonus[m_nLevel] = true; updateEatItems(); } } } //Ghost Process { for (int i = m_arrayGhost->count() - 1; i >= 0; i--) { GameSprite* ghost = (GameSprite*)m_arrayGhost->objectAtIndex(i); if (ghost->ghostState == GhostStateFadeIn || ghost->ghostState == GhostStateAngel) { } else{ if (manEatGhostTime){ if(!ghost->bGhostDied) { if(m_bColorMaze) ghost->setTexture(m_teSkelGhost); else ghost->setTexture( m_teBlueGhost); } else ghost->setTexture(ghost->oriTexture); } else { ghost->setTexture(ghost->oriTexture); //modified by dukce.pak ghost->bGhostDied = false; manAteGhostNum = 0; } if (isCrossPointWithSprite(ghost)) { GameMoveEnum e = ghost->moveEnum; while (true) { GameMoveEnum m = (GameMoveEnum)(arc4random()%4 + 1); if ((e == GameMoveTopEnum && m != GameMoveBottomEnum) || (e == GameMoveBottomEnum && m != GameMoveTopEnum) || (e == GameMoveLeftEnum && m != GameMoveRightEnum) || (e == GameMoveRightEnum && m != GameMoveLeftEnum) ) { ghost->moveEnum = m; break; } } } if (isTopPointWithSprite(ghost)) { ghost->moveEnum = GameMoveTopEnum; } if (ghost->canMove()) { ghost->moveToNextPoint(); } else { GameMoveEnum e = ghost->moveEnum; while (true) { if (e != GameMoveNoneEnum) { if (this->moveSpiritWidthOrientation(ghost, e, false)) { break; } } e = (GameMoveEnum)(arc4random()%4 + 1); } } CCRect rectPlayer = man->boundingBox(); if (rectPlayer.containsPoint(ghost->getPosition()) && ghost->ghostState != GhostStateAngel) { if (manEatGhostTime && !ghost->bGhostDied) { //modified by dukce.pak manAteGhostNum ++; ghost->bGhostDied = true; ghost->setTexture(m_teAngelGhost); ghost->setGhostState(GhostStateFadeIn); //come back to ghost's home if (ghost->bFinedPath == false) { CCPoint ptG = getGridPointWithPoint(ghost->endPoint); ghost->findShortestPath(m_map, m_ptGhostHome.x, m_ptGhostHome.y, (int)ptG.x, (int)ptG.y, m_nRow, m_nCol); // CCPoint ptS = getGridPointWithPoint(ghost->startPoint); // ghost->findShortestPath(m_map, ptS.x, ptS.y, (int)ptG.x, (int)ptG.y, m_nRow, m_nCol); } //modified by dukce.pak int score; int score_id = (manAteGhostNum - 1 ) % 4; score = g_nGhostScore[score_id]; SimpleAudioEngine::sharedEngine()->playEffect(SND_GATE); addScore(score, ghost->getPosition(), true); //-- if (itemState == BonusNone) { itemState = BonusAppear; //modified by dukce.pak itemAppearTime = Appear_ItemTime; addItem(); } } else { if (man->pandaState == PandaStateNormal ) { pandaDied(); } } break; } } } } } void GameScene::pandaDied() { man->setPandaState(PandaStateDie); SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(); SimpleAudioEngine::sharedEngine()->playEffect(SND_DEATH); m_isPlaying = false; m_spLoseSkel->setVisible(true); m_spDyingPanda->setVisible(true); float fInteval = 0.3; CCSequence* seq = CCSequence::create(CCRotateBy::create(fInteval, 90), CCRotateBy::create(fInteval, 0), CCRotateBy::create(fInteval, 90), CCRotateBy::create(fInteval, 0), CCRotateBy::create(fInteval, 90), CCRotateBy::create(fInteval, 0), CCRotateBy::create(fInteval, 90), CCRotateBy::create(fInteval, 0), CCCallFunc::create(this, callfunc_selector(GameScene::finishLoseAnimation)), NULL); m_spDyingPanda->runAction(seq); } void GameScene::addScore(int nScore, CCPoint pt, bool bPopup) { int oldScore = m_nScore; m_nScore += nScore; if (bPopup) { char temp[20] = {0}; sprintf(temp, "+%d", nScore); CCLabelTTF* lb = CCLabelTTF::create(temp, "Marker Felt.ttf", 20); lb->setPosition(ccp(pt.x, pt.y + g_gridHeight * 3)); lb->runAction(CCSequence::create(CCFadeIn::create(1), CCFadeOut::create(1), NULL)); addChild(lb); } updateScore(); int nTemp = m_nScore / Life_Score; if (nTemp > 0 && oldScore < nTemp * Life_Score && m_nScore >= nTemp * Life_Score) { addLife(); } } void GameScene::addLife() { //modified by dukce.pak int lives = GameScene::Lives(); CCSprite* sprite = CCSprite::create("pacman2.png"); Config::setScale(sprite); sprite->setPosition(ccp(sprite->getContentSize().width * sprite->getScaleX() *0.8* (lives - 1) + sprite->getContentSize().width/2 * sprite->getScaleX() + g_fMarginLeft , g_fMarginTop - sprite->getContentSize().height / 2 * sprite->getScaleY() - sprite->getContentSize().height * PANDA_LIFE_PADDING_RATE * sprite->getScaleY())); this->addChild(sprite, zOrderPel); m_arrayLife->addObject(sprite); //modified by dukce.pak lives++; GameScene::SetLives(lives); //--------- } void GameScene::finishLoseAnimation() { //modified by dukce.pak int lives = GameScene::Lives(); lives --; GameScene::SetLives(lives); if (lives > 0) { getReady(); CCSprite* sp = (CCSprite*)m_arrayLife->objectAtIndex(lives - 1); m_arrayLife->removeObject(sp); removeChild(sp); } else{ // removeChild(man); // man = NULL; saveHighScores(); scheduleOnce(schedule_selector(GameScene::gameOver), 2.0); } m_spLoseSkel->setVisible(false); m_spDyingPanda->setVisible(false); } void GameScene::gameOver() { removeAllChildrenWithCleanup(true); deleteArray(); CCDirector::sharedDirector()->replaceScene(GameOverScene::scene()); } void GameScene::win() { g_nCurLevel++; removeAllChildrenWithCleanup(true); //added by dukce.pak saveHighScores(); deleteArray(); CCDirector::sharedDirector()->replaceScene(WinScene::scene()); } void GameScene::loadHighScores() { for(int i = 0; i< HIGHSCORE_NUM; i++) { char temp[20] = {0}; sprintf(temp, "high%dst",i); m_nHighScores[i] = CCUserDefault::sharedUserDefault()->getIntegerForKey(temp,0); } } void GameScene::saveHighScores() { int n = HIGHSCORE_NUM; for (int i = 0; i < n; i++) { if (m_nScore > m_nHighScores[i]) { for (int j = n - 1; j > i; j--) { m_nHighScores[j] = m_nHighScores[j - 1]; } m_nHighScores[i] = m_nScore; break; } } g_nTotalScore = m_nScore; for(int i = 0; i < HIGHSCORE_NUM; i++) { char temp[20] = {0}; sprintf(temp, "high%dst",i); CCUserDefault::sharedUserDefault()->setIntegerForKey(temp, m_nHighScores[i]); } } void GameScene::layoutGameSprites(void) { if (m_map != NULL) { for (int i = m_arrayPea->count() - 1; i >= 0; i--) removeChild((CCSprite*)m_arrayPea->objectAtIndex(i), true); m_arrayPea->removeAllObjects(); for (int i = m_arrayGhost->count() - 1; i >= 0; i--) removeChild((CCSprite*)m_arrayGhost->objectAtIndex(i), true); m_arrayGhost->removeAllObjects(); for (int i=0; i<m_nRow * m_nCol; i++) { char s = m_map[i]; GameRoleEnum roleEnum = getRoleEnum(s); int x = i%m_nCol; int y = i/m_nCol; switch (roleEnum) { case GameRoleManEnum: addManWithPoint(x, y); break; case GameRoleGhostEnum: addGhostWithPoint(x, y); break; case GameRoleSmallPeaEnum: addPeaWithPoint(x, y, false); break; case GameRoleCrossEnum: addPeaWithPoint(x, y, false); break; case GameRoleBigPeaEnum: addPeaWithPoint(x, y, true); break; case GameRoleWallEnum: addPeace(x, y, s); default: break; } } } } void GameScene::addPeace(int x, int y, char s) { if (x < 0 || y < 0 || x >= m_nCol || y >= m_nRow) { return; } float fx = x * g_gridWidth + g_gridWidth/2 + g_fMarginLeft; float fy = y * g_gridHeight + g_fMarginTop + g_gridHeight/2; if (s != 'e') { CCSprite* sp = NULL; char lpCurve[20] = {0}; char lpPiece[20] = {0}; sprintf(lpCurve, "curve%d.png", m_nLevel+1); sprintf(lpPiece, "piece%d.png", m_nLevel+1); //modified by dukce.pak if (s == 'H' || s == 'h' || s == 'V' || s == 'v' ) { sp = CCSprite::create(lpPiece); sp->setScale(g_gridWidth / (sp->getContentSize().width )); sp->setScaleX(sp->getScaleX() * 1.53); } else if (s == 'L'|| s == 'l' || s == 'R' || s == 'r' || s == 'Y' || s == 'y' || s == 'G' || s == 'g') { sp = CCSprite::create(lpCurve); sp->setScale(g_gridWidth / sp->getContentSize().width); } if (sp) { // sp->setScale(g_gridWidth / sp->getContentSize().width); //------- if (s=='V' || s == 'v') sp->setRotation(90); else if(s=='R' || s == 'r') sp->setScaleX(-1* sp->getScaleX()); else if(s=='Y' || s == 'y') sp->setScaleY(-1* sp->getScaleY()); else if(s=='G' || s == 'g'){ sp->setScaleX(-1* sp->getScaleX()); sp->setScaleY(-1* sp->getScaleY()); } addChild(sp); sp->setPosition(ccp(fx, fy)); } } } void GameScene::draw(void) { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); ccDrawSolidRect(CCPoint(0, 0), CCPoint(winSize.width, winSize.height), ccc4f(35/255.f, 31/255.f, 32/255.f, 1.f)); // if (winSize.height == 1136) { float fw =3;//g_gridHeight / 4.0; glLineWidth(fw); for (int i = 0; i < 8; i++) { if(i <= m_nLevel) ccDrawColor4F(g_drawLevelLineColor[i].r, g_drawLevelLineColor[i].g, g_drawLevelLineColor[i].b, 1.f); else ccDrawColor4F(g_borderColor.r, g_borderColor.g, g_borderColor.b, 1.f); ccDrawLine(ccp(0, fw * ((8 - i)*2)), ccp(winSize.width, fw * ((8 - i)*2))); ccDrawLine(ccp(0, winSize.height - fw * ((8 - i)*2)), ccp(winSize.width, winSize.height - fw * ((8 - i)*2))); } } if (m_map != NULL) { for (int i=0; i<m_nRow * m_nCol; i++) { if (m_map[i] == 0) { break; } char s = m_map[i]; GameRoleEnum roleEnum = getRoleEnum(s); int x = i%m_nCol; int y = i/m_nCol; //modified by dukce.pak if (roleEnum == GameRoleWallEnum && s != 'e') { float inner_margin = 0.73; float outter_margin = 0.27; if (x - 1 < 0 || y - 1 < 0 || x + 1 >= m_nCol || y + 1 >= m_nRow) { continue; } char sl = m_map[y * m_nCol + x - 1]; char sr = m_map[y * m_nCol + x + 1]; char st = m_map[(y+1) * m_nCol + x]; char sb = m_map[(y-1) * m_nCol + x]; if( s == 'V') { if(sl == '_' || sl == 'Y' || sl == 'G' || sl == 'L' || sl == 'R'|| sl == 'V') { if(st == 'L' || sb == 'Y') drawWallPath(x, y, inner_margin, LEFT); else drawWallPath(x, y, outter_margin, LEFT); } else if(sr == '_' || sr == 'Y' || sr == 'G' || sr == 'L' || sr == 'R'|| sr == 'V') { if(st == 'R' || sb == 'G') drawWallPath(x, y, inner_margin, RIGHT); else drawWallPath(x, y, outter_margin, RIGHT); } } else if(s == 'H') { if(st == '_' || st == 'Y' || st == 'G' || st == 'L' || st == 'R'|| st == 'H') { if(sl == 'L' || sr == 'R') drawWallPath(x, y, inner_margin, UP); else drawWallPath(x, y, outter_margin, UP); } else if(sb == '_' || sb == 'Y' || sb == 'G' || sb == 'L' || sb == 'R' || sb == 'H') { if(sl == 'Y' || sr == 'G') drawWallPath(x, y, inner_margin, DOWN); else drawWallPath(x, y, outter_margin, DOWN); } } else if( s == '_') drawWallPath(x, y, outter_margin, NONE); // --------- } } } // if (m_isPlaying) // updateInterval(); } void GameScene::onResume() { removeChild(m_spPauseScreen, true); m_isPlaying = true; preloadSound(); schedule(schedule_selector(GameScene::updateInterval), Update_Interval); } void GameScene::onRestart() { g_nCurLevel = 0; g_nTotalScore = 0; removeAllChildrenWithCleanup(true); //modified by dukce.pak GameScene::SetLives(Init_LifeNum); deleteArray(); CCDirector::sharedDirector()->replaceScene(GameScene::scene()); } //added by dukce.pak void GameScene::onQuit() { // SimpleAudioEngine::sharedEngine()->playEffect(SND_COINDROP); removeAllChildrenWithCleanup(true); deleteArray(); CCDirector::sharedDirector()->replaceScene(TitleScene::scene()); } // Override of touches void GameScene::ccTouchesBegan(cocos2d::CCSet* _touches, cocos2d::CCEvent* event) { m_bDrag = false; CCTouch* touch; touch = (CCTouch*)_touches->anyObject(); m_ptPrev = touch->getLocationInView(); } void GameScene::ccTouchesMoved(cocos2d::CCSet* _touches, cocos2d::CCEvent* event) { m_bDrag = true; } void GameScene::ccTouchesEnded(cocos2d::CCSet* _touches, cocos2d::CCEvent* event) { CCTouch* touch; touch = (CCTouch*)_touches->anyObject(); CCPoint pt = touch->getLocationInView(); if (m_isPlaying) { if (m_bDrag) { float dx = fabsf(pt.x - m_ptPrev.x); float dy = fabsf(pt.y - m_ptPrev.y); if (dx > dy) { if (pt.x > m_ptPrev.x) manMoveEnum = GameMoveRightEnum; else manMoveEnum = GameMoveLeftEnum; } else{ if (pt.y < m_ptPrev.y) manMoveEnum = GameMoveTopEnum; else manMoveEnum = GameMoveBottomEnum; } } else{ CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCRect rcPause = m_spPause->boundingBox(); pt.y = winSize.height - pt.y; if (rcPause.containsPoint(pt)) { m_isPlaying = false; m_spPauseScreen = CCSprite::create("background.png"); Config::setScale(m_spPauseScreen); m_spPauseScreen->setPosition(ccp(winSize.width/2, winSize.height/2)); m_spPauseScreen->setOpacity(200); addChild(m_spPauseScreen, zOrderMan+100); //added by dukce.pak CCMenuItemImage *restartItem = CCMenuItemImage::create("restart.png", "restart.png", "restart.png",this, menu_selector(GameScene::onRestart)); // Config::setScale(restartItem); CCMenuItemImage *resumeItem = CCMenuItemImage::create("resume.png", "resume.png", "resume.png",this, menu_selector(GameScene::onResume)); // Config::setScale(resumeItem); CCPoint pos(m_spPauseScreen->getPosition()); CCMenuItemImage *quitItem = CCMenuItemImage::create("quit.png", "quit.png", "quit.png",this, menu_selector(GameScene::onQuit)); // Config::setScale(quitItem); CCMenu *pauseMenu = CCMenu::create(resumeItem,restartItem, quitItem, NULL); pauseMenu->alignItemsVerticallyWithPadding(winSize.height * PAUSESCR_PADDING_RATE); pauseMenu->setPosition(ccp(m_spPauseScreen->getContentSize().width/2 ,m_spPauseScreen->getContentSize().height/2)); m_spPauseScreen->addChild(pauseMenu); unschedule(schedule_selector(GameScene::updateInterval)); } } } } void GameScene::didAccelerate(cocos2d::CCAcceleration* pAccelerationValue) { // pAccelerationValue>x; //horizontal acceleration // pAccelerationValue>y; //vertical acceleration // //If you want to move sprite then can use it to change the position.. // sprite>setPosition.x+pAccelerationValue>x*3,sprite->getPosition().y)); //I have not tested it but to move sprite horizontally with some speed like x*6..you can change it as accordingly.. // if (m_isPlaying) { // if (fabsf(pAccelerationValue->x) > fabsf(pAccelerationValue->y)) // manMoveEnum = (pAccelerationValue->x > 0)?GameMoveRightEnum:GameMoveLeftEnum; // else // manMoveEnum = (pAccelerationValue->y > 0)?GameMoveTopEnum:GameMoveBottomEnum; // } }
7f745721b779934df33d2fa02cfaa95cb52d4a8d
f23e378e2b8a2c91841b054c559c0d0696f811fd
/chaper3/vector/318.cc
23f7ee2eecf9d85079bc504197a866e9945c763a
[]
no_license
linw/Cpp_Primer
3cfa80c7b25af8a2b98617f581ef53d2c8378f3f
bfdc8ee8be9463ba5070a8cfdf5ce5bf29ad4c7e
refs/heads/master
2021-01-23T16:30:33.930374
2011-10-25T02:49:45
2011-10-25T02:49:45
2,570,157
0
0
null
null
null
null
UTF-8
C++
false
false
667
cc
318.cc
/* * MODULE NAME: 318.cc * PROJECT: cpp_primer vector * AUTHOR: 林炜 * DATE: October 23, 2011 * DESCRIPTION: 习题 3.18 */ #include <iostream> #include <vector> #include <string> using std::cout; using std::cin; using std::endl; using std::vector; using std::string; int main() { vector<int> ivec; for(vector<int>::size_type index = 0; index < 10; ++index){ int k; cin>>k; ivec.push_back(k); } for(vector<int>::iterator iter = ivec.begin(); iter != ivec.end(); ++iter){ *iter *= 2; } for(vector<int>::const_iterator iter = ivec.begin(); iter != ivec.end(); ++iter){ cout<<*iter<<endl; } }
9beda632ebbd75041a3ce09116e46ac8c941c6c4
0ad79ae1e3367cce9d0ba8962af4c4a72d88c02d
/A Maths Engine/MEMatrices.h
5715a108ffc9a0b7de1150a5567d917ab6813add
[]
no_license
JoshuaJWatt/A-Maths-Engine
0a83ff8bd8bdcebaa4f53fbe620c78ec01c39710
088952299a5bd70320eebd259dd855ac408bd893
refs/heads/main
2023-04-07T20:31:20.890230
2021-04-03T16:06:34
2021-04-03T16:06:34
354,333,594
0
0
null
null
null
null
UTF-8
C++
false
false
1,207
h
MEMatrices.h
#pragma once #ifndef MEMATRICES_H_ #define MEMATRICES_H_ #include <iostream> //#include "MEVectors.h" namespace MathsEngine{ class matrix2x2 { public: float matrixData[4]; matrix2x2(); matrix2x2(float m0, float m1, float m2, float m3); float det(); }; class matrix { public: float matrixData[9]; matrix(); matrix(float m0, float m1, float m2, float m3, float m4, float m5, float m6, float m7, float m8); void Show(); matrix Identity(); void becomeIdentity(); vector3 operator*(const vector3 &v); matrix operator*(const float &k); matrix operator*(const matrix& m); void operator*=(const float &k); void operator*=(const matrix& m); matrix operator/(const float k); matrix operator+(const matrix &m); matrix operator-(const matrix &m); friend std::ostream& operator<<(std::ostream& os, const matrix &m); matrix matrixOfMinors(); matrix cofactor(); void becomeTranspose(); matrix transpose(); float det(); matrix inverse(bool debug = 0); vector3 transform(const vector3& v); }; // // class newmatrix { // public: // float matrixData; // int rows; // int columns; // // newmatrix(); // newmatrix(int x, int y, float md[]); // }; } #endif
7b5ffe7a825952db3eaddea5f5fa3d82f047d2ac
1f84fd078570475d2510339bab2439b5193af03d
/source/vxEngineLib/Graphics/Font.cpp
c7414358bf8d52071d1e6ddb6e25c0fd1f19c619
[ "MIT" ]
permissive
DennisWandschura/vxEngine
df138077cdb9f40461c83e99a8851de593b098f2
1396a65f7328aaed50dd34634c65cac561271b9e
refs/heads/master
2021-01-16T00:17:47.703611
2015-10-11T10:44:53
2015-10-11T10:44:53
32,484,686
1
0
null
null
null
null
UTF-8
C++
false
false
1,710
cpp
Font.cpp
/* The MIT License (MIT) Copyright (c) 2015 Dennis Wandschura 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 <vxEngineLib/Graphics/font.h> namespace Graphics { Font::Font() :m_texture(nullptr), m_atlas() { } Font::Font(const Texture* texture, FontAtlas &&fontAtlas) : m_texture(texture), m_atlas(std::move(fontAtlas)) { } Font::Font(Font &&rhs) : m_texture(rhs.m_texture), m_atlas(std::move(rhs.m_atlas)) { } Font::~Font() { } Font& Font::operator=(Font &&rhs) { if (this != &rhs) { std::swap(m_texture, rhs.m_texture); m_atlas = std::move(rhs.m_atlas); } return *this; } const FontAtlasEntry* Font::getAtlasEntry(u32 code) const { return m_atlas.getEntry(code); } }
de8a85070910254662124587556356ebce1d59f9
1ed1ed934e4175bb20024311a007d60ae784b046
/PALPAR/PALPAR.cpp
7771e93a405c0738076f790e8c53c3eecee12833
[]
no_license
kkkcoder/Code_in_thptchuyen.ntucoder.net
f568cddc01b641c9a6a3c033a4b48ca59bb6435e
c4c0e19ea56a6560014cbb6e4d7489fb16e8aad7
refs/heads/master
2023-07-16T16:15:39.421817
2021-08-29T15:56:35
2021-08-29T15:56:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,651
cpp
PALPAR.cpp
// Một cách tách xâu 𝑆 thành nhiều xâu con khác rỗng 𝑤1, 𝑤2, … , 𝑤𝑘 mà 𝑤1 = 𝑤𝑘, 𝑤2 = 𝑤𝑘−1, … // được gọi là PALPAR bậc 𝑘. // Yêu cầu: Cho xâu 𝑆 tìm cách tách PALPAR có bậc lớn nhất. // Input // - Dòng đầu chứa số nguyên 𝑇 (𝑇 ≤ 10); // // - Tiếp theo là 𝑇 dòng, mỗi dòng chứa một xâu chỉ gồm các kí tự ‘a’ đến ‘z’ #include <bits/stdc++.h> using namespace std; const int nmax = 1e6 + 5; const long long B = 1000000007; const int A = 26; long long poww[nmax], hashs[nmax]; int t; string s; int gethash(int i, int j) { return (hashs[j] - hashs[i - 1] * poww[j - i + 1] + B * B) % B; } int kqua(string s) { int n = s.size(); s = " " + s; for (int i = 1; i <= n; i++) hashs[i] = (hashs[i - 1] * A + s[i] - 'a') % B; int l = 1, r = n, dem = 0; while (l <= r) { int res = 0; for (int i = 1; i <= (r - l + 1) / 2; i++) if (gethash(l, l + i - 1) == gethash(r - i + 1, r)) { res = i; break; } if (res == 0) return dem + 1; else { l = l + res; r = r - res; dem += 2; } } return dem; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("main.inp","r",stdin); //freopen("main.out","w",stdout); cin >> t; poww[0] = 1; for (int i = 1; i < nmax; i++) poww[i] = (poww[i - 1] * A) % B; while (t--) { cin >> s; cout << kqua(s) << '\n'; } }
f9dcac263154a7bd4a52eaea55c51e474b21b8f4
2045ab194dccdf69ca312589cf968278248e9a27
/ts-messages/messages/UATADSBData.h
b6c09edef6d43da4b6ffc2d380592aab0988dfdb
[]
no_license
manish-drake/ts-wrap
427d1e7cf2e1cfa3d63b4bde576eead9a06d0c04
c165024102985aea9942f6ca2f217acdaf737ce5
refs/heads/master
2020-08-28T04:10:03.493253
2020-01-29T15:48:04
2020-01-29T15:48:04
217,583,116
0
0
null
null
null
null
UTF-8
C++
false
false
15,577
h
UATADSBData.h
#ifndef __UATADSBData_h #define __UATADSBData_h #include <stdio.h> #include <stdlib.h> #include <string> #include "TServerMessage.h" class CUATADSBData:public TServerMessage { const int mFormatVersion = 2; char* json_string; public: static const unsigned int mCmdID=0x1; CUATADSBData(void) { setCmdID(mCmdID); } CUATADSBData(Json::Value obj):TServerMessage(obj) { set(obj); setCmdID(mCmdID); } void setAddress(unsigned int value) { write("Address",value); } unsigned int getAddress(void) { return getUInt("Address"); } bool isAddressValid(void) { return isValid("Address"); } void setAddressType(unsigned int value) { write("AddressType",value); } unsigned int getAddressType(void) { return getUInt("AddressType"); } bool isAddressTypeValid(void) { return isValid("AddressType"); } void setLatitude(float value) { write("Latitude",value); } float getLatitude(void) { return getFloat("Latitude"); } bool isLatitudeValid(void) { return isValid("Latitude"); } void setLongitude(float value) { write("Longitude",value); } float getLongitude(void) { return getFloat("Longitude"); } bool isLongitudeValid(void) { return isValid("Longitude"); } void setAltitude(int value) { write("Altitude",value); } int getAltitude(void) { return getInt("Altitude"); } bool isAltitudeValid(void) { return isValid("Altitude"); } void setAltitudeType(unsigned int value) { write("AltitudeType",value); } unsigned int getAltitudeType(void) { return getUInt("AltitudeType"); } bool isAltitudeTypeValid(void) { return isValid("AltitudeType"); } void setNIC(unsigned int value) { write("NIC",value); } unsigned int getNIC(void) { return getUInt("NIC"); } bool isNICValid(void) { return isValid("NIC"); } void setAirGroundState(unsigned int value) { write("AirGroundState",value); } unsigned int getAirGroundState(void) { return getUInt("AirGroundState"); } bool isAirGroundStateValid(void) { return isValid("AirGroundState"); } void setNorthVel(int value) { write("NorthVel",value); } int getNorthVel(void) { return getInt("NorthVel"); } bool isNorthVelValid(void) { return isValid("NorthVel"); } void setEastVel(int value) { write("EastVel",value); } int getEastVel(void) { return getInt("EastVel"); } bool isEastVelValid(void) { return isValid("EastVel"); } void setGroundspeed(unsigned int value) { write("Groundspeed",value); } unsigned int getGroundspeed(void) { return getUInt("Groundspeed"); } bool isGroundspeedValid(void) { return isValid("Groundspeed"); } void setHeadingTrack(float value) { write("HeadingTrack",value); } float getHeadingTrack(void) { return getFloat("HeadingTrack"); } bool isHeadingTrackValid(void) { return isValid("HeadingTrack"); } void setAngleType(unsigned int value) { write("AngleType",value); } unsigned int getAngleType(void) { return getUInt("AngleType"); } bool isAngleTypeValid(void) { return isValid("AngleType"); } void setVerticalVelocity(int value) { write("VerticalVelocity",value); } int getVerticalVelocity(void) { return getInt("VerticalVelocity"); } bool isVerticalVelocityValid(void) { return isValid("VerticalVelocity"); } void setVerticalVelocitySource(unsigned int value) { write("VerticalVelocitySource",value); } unsigned int getVerticalVelocitySource(void) { return getUInt("VerticalVelocitySource"); } bool isVerticalVelocitySourceValid(void) { return isValid("VerticalVelocitySource"); } void setAVSize(unsigned int value) { write("AVSize",value); } unsigned int getAVSize(void) { return getUInt("AVSize"); } bool isAVSizeValid(void) { return isValid("AVSize"); } void setGPSOffsetLateral(int value) { write("GPSOffsetLateral",value); } int getGPSOffsetLateral(void) { return getInt("GPSOffsetLateral"); } bool isGPSOffsetLateralValid(void) { return isValid("GPSOffsetLateral"); } void setGPSOffsetLongitudinal(unsigned int value) { write("GPSOffsetLongitudinal",value); } unsigned int getGPSOffsetLongitudinal(void) { return getUInt("GPSOffsetLongitudinal"); } bool isGPSOffsetLongitudinalValid(void) { return isValid("GPSOffsetLongitudinal"); } void setGPSOffsetSensorApplied(unsigned int value) { write("GPSOffsetSensorApplied",value); } unsigned int getGPSOffsetSensorApplied(void) { return getUInt("GPSOffsetSensorApplied"); } bool isGPSOffsetSensorAppliedValid(void) { return isValid("GPSOffsetSensorApplied"); } void setUTCCoupling(unsigned int value) { write("UTCCoupling",value); } unsigned int getUTCCoupling(void) { return getUInt("UTCCoupling"); } bool isUTCCouplingValid(void) { return isValid("UTCCoupling"); } void setUplinkFeedback(unsigned int value) { write("UplinkFeedback",value); } unsigned int getUplinkFeedback(void) { return getUInt("UplinkFeedback"); } bool isUplinkFeedbackValid(void) { return isValid("UplinkFeedback"); } void setEmitterCategory(unsigned int value) { write("EmitterCategory",value); } unsigned int getEmitterCategory(void) { return getUInt("EmitterCategory"); } bool isEmitterCategoryValid(void) { return isValid("EmitterCategory"); } void setCallsign(std::string value) { write("Callsign",value); } std::string getCallsign(void) { return getString("Callsign"); } bool isCallsignValid(void) { return isValid("Callsign"); } void setFlightID(std::string value) { write("FlightID",value); } std::string getFlightID(void) { return getString("FlightID"); } bool isFlightIDValid(void) { return isValid("FlightID"); } void setEmergencyStatus(unsigned int value) { write("EmergencyStatus",value); } unsigned int getEmergencyStatus(void) { return getUInt("EmergencyStatus"); } bool isEmergencyStatusValid(void) { return isValid("EmergencyStatus"); } void setMOPSVersion(unsigned int value) { write("MOPSVersion",value); } unsigned int getMOPSVersion(void) { return getUInt("MOPSVersion"); } bool isMOPSVersionValid(void) { return isValid("MOPSVersion"); } void setSIL(unsigned int value) { write("SIL",value); } unsigned int getSIL(void) { return getUInt("SIL"); } bool isSILValid(void) { return isValid("SIL"); } void setTXMSO(unsigned int value) { write("TXMSO",value); } unsigned int getTXMSO(void) { return getUInt("TXMSO"); } bool isTXMSOValid(void) { return isValid("TXMSO"); } void setSDA(unsigned int value) { write("SDA",value); } unsigned int getSDA(void) { return getUInt("SDA"); } bool isSDAValid(void) { return isValid("SDA"); } void setNACp(unsigned int value) { write("NACp",value); } unsigned int getNACp(void) { return getUInt("NACp"); } bool isNACpValid(void) { return isValid("NACp"); } void setNACv(unsigned int value) { write("NACv",value); } unsigned int getNACv(void) { return getUInt("NACv"); } bool isNACvValid(void) { return isValid("NACv"); } void setNICBaro(unsigned int value) { write("NICBaro",value); } unsigned int getNICBaro(void) { return getUInt("NICBaro"); } bool isNICBaroValid(void) { return isValid("NICBaro"); } void setUATIn(bool value) { write("UATIn",value); } bool getUATIn(void) { return getBool("UATIn"); } bool isUATInValid(void) { return isValid("UATIn"); } void setES1090In(bool value) { write("ES1090In",value); } bool getES1090In(void) { return getBool("ES1090In"); } bool isES1090InValid(void) { return isValid("ES1090In"); } void setTCASOperational(bool value) { write("TCASOperational",value); } bool getTCASOperational(void) { return getBool("TCASOperational"); } bool isTCASOperationalValid(void) { return isValid("TCASOperational"); } void setOperationalModes(unsigned int value) { write("OperationalModes",value); } unsigned int getOperationalModes(void) { return getUInt("OperationalModes"); } bool isOperationalModesValid(void) { return isValid("OperationalModes"); } void setTCASResolutionAdvisory(bool value) { write("TCASResolutionAdvisory",value); } bool getTCASResolutionAdvisory(void) { return getBool("TCASResolutionAdvisory"); } bool isTCASResolutionAdvisoryValid(void) { return isValid("TCASResolutionAdvisory"); } void setIdentActive(bool value) { write("IdentActive",value); } bool getIdentActive(void) { return getBool("IdentActive"); } bool isIdentActiveValid(void) { return isValid("IdentActive"); } void setATCServices(bool value) { write("ATCServices",value); } bool getATCServices(void) { return getBool("ATCServices"); } bool isATCServicesValid(void) { return isValid("ATCServices"); } void setCallsignID(unsigned int value) { write("CallsignID",value); } unsigned int getCallsignID(void) { return getUInt("CallsignID"); } bool isCallsignIDValid(void) { return isValid("CallsignID"); } void setSILSupplement(unsigned int value) { write("SILSupplement",value); } unsigned int getSILSupplement(void) { return getUInt("SILSupplement"); } bool isSILSupplementValid(void) { return isValid("SILSupplement"); } void setGeometricVerticalAccuracy(unsigned int value) { write("GeometricVerticalAccuracy",value); } unsigned int getGeometricVerticalAccuracy(void) { return getUInt("GeometricVerticalAccuracy"); } bool isGeometricVerticalAccuracyValid(void) { return isValid("GeometricVerticalAccuracy"); } void setSingleAntenna(unsigned int value) { write("SingleAntenna",value); } unsigned int getSingleAntenna(void) { return getUInt("SingleAntenna"); } bool isSingleAntennaValid(void) { return isValid("SingleAntenna"); } void setNICSupp(unsigned int value) { write("NICSupp",value); } unsigned int getNICSupp(void) { return getUInt("NICSupp"); } bool isNICSuppValid(void) { return isValid("NICSupp"); } void setSecondaryAltitude(int value) { write("SecondaryAltitude",value); } int getSecondaryAltitude(void) { return getInt("SecondaryAltitude"); } bool isSecondaryAltitudeValid(void) { return isValid("SecondaryAltitude"); } void setSelectedAltitude(unsigned int value) { write("SelectedAltitude",value); } unsigned int getSelectedAltitude(void) { return getUInt("SelectedAltitude"); } bool isSelectedAltitudeValid(void) { return isValid("SelectedAltitude"); } void setSelectedAltitudeType(unsigned int value) { write("SelectedAltitudeType",value); } unsigned int getSelectedAltitudeType(void) { return getUInt("SelectedAltitudeType"); } bool isSelectedAltitudeTypeValid(void) { return isValid("SelectedAltitudeType"); } void setBaroSetting(float value) { write("BaroSetting",value); } float getBaroSetting(void) { return getFloat("BaroSetting"); } bool isBaroSettingValid(void) { return isValid("BaroSetting"); } void setSelectedHeading(float value) { write("SelectedHeading",value); } float getSelectedHeading(void) { return getFloat("SelectedHeading"); } bool isSelectedHeadingValid(void) { return isValid("SelectedHeading"); } void setMCPFCUStatus(bool value) { write("MCPFCUStatus",value); } bool getMCPFCUStatus(void) { return getBool("MCPFCUStatus"); } bool isMCPFCUStatusValid(void) { return isValid("MCPFCUStatus"); } void setModeAutoPilotEngaged(bool value) { write("ModeAutoPilotEngaged",value); } bool getModeAutoPilotEngaged(void) { return getBool("ModeAutoPilotEngaged"); } bool isModeAutoPilotEngagedValid(void) { return isValid("ModeAutoPilotEngaged"); } void setModeVNAV(bool value) { write("ModeVNAV",value); } bool getModeVNAV(void) { return getBool("ModeVNAV"); } bool isModeVNAVValid(void) { return isValid("ModeVNAV"); } void setModeAltitudeHold(bool value) { write("ModeAltitudeHold",value); } bool getModeAltitudeHold(void) { return getBool("ModeAltitudeHold"); } bool isModeAltitudeHoldValid(void) { return isValid("ModeAltitudeHold"); } void setModeApproach(bool value) { write("ModeApproach",value); } bool getModeApproach(void) { return getBool("ModeApproach"); } bool isModeApproachValid(void) { return isValid("ModeApproach"); } void setModeLNAV(bool value) { write("ModeLNAV",value); } bool getModeLNAV(void) { return getBool("ModeLNAV"); } bool isModeLNAVValid(void) { return isValid("ModeLNAV"); } void setMessage(std::string jsonstring) { TServerMessage::setMessage(jsonstring); } void set(Json::Value obj) { TServerMessage::set(obj); } std::string getMessage(void) { return TServerMessage::getMessage(); } Json::Value get(void) { return TServerMessage::get(); } }; #endif
31c0a0a975facb35eaa29506b132262952c8dd76
690873d5e074175f931a5232db30a789b31d867a
/scene_edit_polyhedron_item_automoc.cpp
8f232e403838b5a824f5fd9bc46f8082af5b4d04
[]
no_license
Dwgjjdxq/MyCGAL
0c3f9a4b7a9283614ec40c86b8fab2d9389cef26
348155deb322b71dacfd24fbc1779c2d6c32fc62
refs/heads/master
2021-01-01T16:18:47.314896
2017-07-20T08:05:16
2017-07-20T08:05:16
97,808,432
0
0
null
null
null
null
UTF-8
C++
false
false
91
cpp
scene_edit_polyhedron_item_automoc.cpp
/* This file is autogenerated, do not edit*/ #include "moc_Scene_edit_polyhedron_item.cpp"
c633a2fc44aa9d41f64b85dda3bae43952eb7464
002c4552f31d579cbfafd99998d7c8e1ee373e26
/Spiral Matrix II .cpp
20e8a8e24f982fb8170348a5f4c7052b9abf403c
[]
no_license
ranshiwei/Leetcode-new
4e7499fefc7be57425c1e34b2bd5a78afccdbcd4
c300a375dab1c3e0571cb648966d51b5f556102a
refs/heads/master
2020-04-05T22:44:40.471080
2015-04-22T11:47:22
2015-04-22T11:47:22
31,878,571
0
0
null
null
null
null
UTF-8
C++
false
false
1,251
cpp
Spiral Matrix II .cpp
#include <iostream> #include "header.h" using namespace std; class Solution { public: vector<vector<int> > generateMatrix(int n) { if(n<=0) return result; for(int i=0;i<n;i++){ vector<int> t(n); result.push_back(t); } //result(n,vector<int>(n)); int start=0,end=n; int curnum=1; while(start*2<n){ for(int i=start;i<end;i++){ result[start][i]=curnum++; } for(int i=start+1;i<end;i++){ result[i][end-1]=curnum++; } for(int i=end-2;i>=start;i--){ result[end-1][i]=curnum++; } for(int i=end-2;i>start;i--){ result[i][start]=curnum++; } start++; end--; } return result; } private: vector<vector<int> > result; }; int main(){ Solution s; vector<vector<int> > rrr=s.generateMatrix(5); vector<vector<int> >::iterator iibegin=rrr.begin(),iiend=rrr.end(); for(;iibegin!=iiend;iibegin++){ vector<int> tt=*iibegin; int size=tt.size(); int j=0; while(j<size) cout<<tt[j++]<<' ';; cout<<endl<<endl;; } }
92f897306d79b870dc292ed9b1f396bbd6809d6d
d4b969fe1378e424f95a7631de95c795fc1959b4
/Samples/BatchSupport/BatchSupport/SampleHelper.h
70ab61e04d1b70ea13099a4d252ea9542600ba84
[ "MIT" ]
permissive
ceejliu/Windows-Machine-Learning
412a376be0666797014991d4918c898f70d06ee7
c5639799f27dace488606ff6ccdc9edd72cf3cb7
refs/heads/master
2021-05-20T00:14:27.900404
2020-03-31T21:53:58
2020-03-31T21:53:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
996
h
SampleHelper.h
#pragma once #include <string> #include <unknwn.h> #include <winrt/Windows.Media.h> #include <winrt/Windows.Graphics.Imaging.h> #include "FileHelper.h" namespace SampleHelper { // Convert SoftwareBitmap to std::vector<float> std::vector<float> SoftwareBitmapToFloatVector( winrt::Windows::Graphics::Imaging::SoftwareBitmap softwareBitmap); // Load Image File as VideoFrame winrt::Windows::Media::VideoFrame LoadImageFile( winrt::hstring filePath); // Load object detection labels std::vector<std::string> LoadLabels(std::string labelsFilePath); // Create input Tensorfloats with 3 images. winrt::Windows::AI::MachineLearning::TensorFloat CreateInputTensorFloat(); // Create input VideoFrames with 3 images winrt::Windows::Foundation::Collections::IVector<winrt::Windows::Media::VideoFrame> CreateVideoFrames(); winrt::hstring GetModelPath(std::string modelType); void PrintResults(winrt::Windows::Foundation::Collections::IVectorView<float> results); }
6c9c0b2fde670097fa433de51a86c21e34d32448
98cc94789c971c991965da547b845fd4365a68bc
/client/src/mapwindow.h
9f8d93d3f2174d6d03ecd18ec0fd7b4cbb3469af
[]
no_license
FrancoLiberali/Worms-TallerI
218b27f9dbc1c51ef3a8b39c86c60f146519cece
3f5ba4480ffcc657d9e068ead99a88abd2c78318
refs/heads/master
2020-03-18T07:13:06.841713
2018-06-26T19:12:53
2018-06-26T19:12:53
134,439,457
0
1
null
null
null
null
UTF-8
C++
false
false
676
h
mapwindow.h
#ifndef MAPWINDOW_H #define MAPWINDOW_H #include <QDialog> #include "ProxyClient.h" #include "Room.h" #include <map> namespace Ui { class mapWindow; } class ProxyClient; class mapWindow : public QDialog{ Q_OBJECT private: bool verifyValid(const std::string& str, const char* errorMsj); Ui::mapWindow *ui; ProxyClient& proxy; bool done; std::map<int, Room*> rooms; public: explicit mapWindow(ProxyClient& proxy, QWidget *parent = 0); ~mapWindow(); void addMap(std::string& map); void addRoom(Room* room); void run(); private slots: void on_btn_unirse_clicked(); void on_btn_crear_clicked(); }; #endif // MAPWINDOW_H
5ef768eeacfa5374f1154bed276a70102bb432bd
6301e2e3669b5f194253e099527212cfe5e4fc92
/剑指offer/无缓存交换/无缓存交换.cpp
7c963f335dc08859a7c51765026d7be21d04da0c
[]
no_license
jiongdu/Algorithm
253ff365d812aefdd12f25970530775cb3b75e4d
14e58057da7439d9818cfb9547d4b5713c1e1e26
refs/heads/master
2021-06-05T10:18:01.631658
2021-05-02T06:58:54
2021-05-02T06:58:54
62,377,889
4
3
null
null
null
null
UTF-8
C++
false
false
423
cpp
无缓存交换.cpp
/************************************** * @author dujiong * @date 2016.10.23 * @version V0.1 **************************************/ class Exchange { public: vector<int> exchangeAB(vector<int> AB) { // write code here //std::reverse(AB.begin(), AB.end()); //return AB; AB[0]=AB[0]^AB[1]; AB[1]=AB[1]^AB[0]; AB[0]=AB[0]^AB[1]; return AB; } };
76c1240db4a59c76243a5f4104849a171f3ed5dc
da0eeef79ee2a97840dfba53a3bb8996e44ab077
/imagelabelclass.h
e4e2cef4f4255851c2457f3562f94a23f5f52660
[]
no_license
lppop6/project_2
f7645b607c69a63433b3a797782874eb647cb9ac
f897b7a480600ea535f741f0fa2aa27e2d5fbcda
refs/heads/master
2023-05-14T04:32:06.311276
2021-06-08T02:06:23
2021-06-08T02:06:23
368,118,403
0
0
null
null
null
null
UTF-8
C++
false
false
6,740
h
imagelabelclass.h
#ifndef IMAGELABELCLASS_H #define IMAGELABELCLASS_H #include <QWidget> #include <QDebug> #include <QWheelEvent> #include <QMouseEvent> #include <QLabel> #include <QKeyEvent> #include <QApplication> #include <QImage> #include <QPainter> #include <QThread> #include <screenshotthread.h> #include <QVector> #include <QScopedPointer> #include <imageprocessingclass.h> /* * 该类用于自定义Label控件,分为普通模式和特殊模式 * 普通模式功能: * 按ctrl+滚轮可以将从MainWindow传进来的图片于鼠标位置进行放大缩小并传回MainWindow进行显示 * 长按鼠标中键拖动可以拖动图片 * * 特殊模式功能: * 面对畸变分析,可以预选取角点坐标,并画图显示。 * 面对色差分析和畸变分析可以进行截屏操作,并显示截屏图片。 */ class ImageLabelClass : public QLabel { Q_OBJECT public: explicit ImageLabelClass(QWidget *parent = nullptr); ~ImageLabelClass(); private: virtual void wheelEvent(QWheelEvent *event); virtual void mouseMoveEvent(QMouseEvent *ev); virtual void mousePressEvent(QMouseEvent *ev); virtual void mouseReleaseEvent(QMouseEvent *ev); virtual void resizeEvent(QResizeEvent *event); void reInitImagelabel(); //当窗口大小变化的时候再次初始化label里面的事件 signals: // void send_ZoomIn(QImage); // void send_ZoomOut(QImage); void send_ZoomOrTransfer(QImage); void sendSpecialModeDraw(QImage,int,int,int,int); //特殊模式画图信号,传递画图背景,四个顶点坐标 void sendSpecialModeStyle(int); //特殊模式类型信号 void sendFullColor(QImage,int,int,int,int); //发送信号给thread使颜色覆盖角点搜索范围 void sendReslt_Dis(double); //发送结果给MainWindow,畸变 void sendResult_Chro(double); //发送结果给MianWindow,色差 public slots: void get_Image(QImage); void Choose_Angular_Point(); //角点范围选取模式开启 void cutPicture(); //截图模式开启 void chooseChromatic(); //选取色块模式 void getMarkedImageFromThread(QImage); //从线程中获取标记后的图片(用于特殊模式) void dealThreadClose(); //绘画线程关闭进行的处理 void quitSpecialMode(); //用于接受MainWindow的信号来退出特殊模式 void completeScreenShot(); //用于接受MainWindow的信号来完成截图并显示 void firstPaintOnQImage(QImage); //用于导入图片时,对图片进行绘图,把图片放置再透明背景的中间部分 double startTesting_Dis(); //开始进行畸变检测 //void chromaticComplete(); //色差选择完成 QVector<int> startTesting_Chro(); //开始进行色差检测 void reChoosesAngular(); //重新选取四个顶点 private: QImage imageprocessed; //用于保存待处理的图像,就是从MainWindow那边来的图像 QImage ss = QImage(1700 ,743 ,QImage::Format_ARGB32); //透明的画布,1391和743是最大化状态的QImage //const QImage ss = QImage(2000,1000,QImage::Format_ARGB32_Premultiplied); // const QImage ss = QImage(2000, 1000,QImage::Format::allGray()); double multiple; //缩放的倍数 int imagewidth; int imageheight; //图像的长和宽 int positionx; int positiony; //鼠标的位置 double nextx2, nexty2; //此处是图像的左上角顶点坐标 int curpositionx; //记录鼠标左键释放的位置(用于图像平移,普通模式) int curpositiony; int prepositionx; //记录鼠标左键按压时的位置(用于图像平移,普通模式) int prepositiony; int curpositionx_1; //记录鼠标左键释放和按压的位置(用于图片截取,选取色差位置之类的,就是特殊模式的操作) int curpositiony_1; int prepositionx_1; int prepositiony_1; int specialstyle; //特殊模式类型 // int curlabelwidth; // int curlabelheight; //记录当前label的大小 bool angularmode; //用作判断是否为角点选择模式的bool值,true是为角点选择模式,false是为普通模式 bool cutpicturemode; //用于判断是否为截屏模式,用来截取图片的部分,并用来显示,true为截屏模式 bool cutchromaticmode; //用于判断是否为色差选取模式,用来截取色差测试图卡的各个色块的范围,用于后面的色差分析,true图卡色块选取模式 bool isleftpress; //用于判断左键是否进行按压,按压时的值为true,在左键释放的时候该位置位false bool isendmarked; //用于判断是否确认本次角点范围 bool isendmarked_1; //用于判断本次角点范围确定后是否复制 QImage tempcopy; //作为拖动图像时用的复制件 QImage drawcopy; //作为标记特殊模式的背景复制件 QImage angularcopy; //作为角点范围选取的备份件,因为要选取四个角点 QImage angulartempcopy; //作为角点范围选取的临时备份件。 ScreenShotThread* screenshotthread; //截屏的线程实例,并绘制截屏的区域 QThread* shotthread; QVector<int> angularvector; //记录角点范围的数组 QVector<int> chrovector; //记录色差块范围的数组 }; #endif // IMAGELABELCLASS_H
5947259c8630bcd6f86227426ee4928b6c52c5cd
e9d25873a3ad52f77938bae1789bb2f95a877bce
/indra/llmath/llbboxlocal.cpp
2582003b3fb85dfabfc28219f83b35503d0c06a8
[]
no_license
Shyotl/SingularityViewer
e9267237a93a13f68c7c6f538a59990f08ddc332
ab5bce69ee11b116e4e57639532d8c0a49af23fd
refs/heads/master
2021-01-17T05:59:12.026799
2020-05-17T03:52:08
2020-05-17T03:52:08
1,090,174
14
5
null
null
null
null
UTF-8
C++
false
false
1,740
cpp
llbboxlocal.cpp
/** * @file llbboxlocal.cpp * @brief General purpose bounding box class (Not axis aligned). * * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ #include "linden_common.h" #include "llbboxlocal.h" #include "m4math.h" void LLBBoxLocal::addPoint(const LLVector3& p) { mMin.mV[VX] = llmin( p.mV[VX], mMin.mV[VX] ); mMin.mV[VY] = llmin( p.mV[VY], mMin.mV[VY] ); mMin.mV[VZ] = llmin( p.mV[VZ], mMin.mV[VZ] ); mMax.mV[VX] = llmax( p.mV[VX], mMax.mV[VX] ); mMax.mV[VY] = llmax( p.mV[VY], mMax.mV[VY] ); mMax.mV[VZ] = llmax( p.mV[VZ], mMax.mV[VZ] ); } void LLBBoxLocal::expand( F32 delta ) { mMin.mV[VX] -= delta; mMin.mV[VY] -= delta; mMin.mV[VZ] -= delta; mMax.mV[VX] += delta; mMax.mV[VY] += delta; mMax.mV[VZ] += delta; } LLBBoxLocal operator*(const LLBBoxLocal &a, const LLMatrix4 &b) { return LLBBoxLocal( a.mMin * b, a.mMax * b ); }
0391edbcdd94e8908aa76187f66a34bc4dd5c317
b16de68e851c6dc498a2c00203477502f1db172a
/src/MicroKernel/handlers.cpp
f5b1bffe206565e3ab1fe65ccbe462233af3ccd8
[ "MIT" ]
permissive
intigonzalez/playing_with_qemu
27d18ff0842d9f8cbce46e06014eeb54ab474fa7
26ef765535142e3adc0472b934eed44e93371f65
refs/heads/master
2016-09-08T02:05:01.484973
2014-09-24T21:57:34
2014-09-24T21:57:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,512
cpp
handlers.cpp
#include "includes/global.h" #include "kernel.h" #include <system_calls.h> #include "video.h" #include "ThreadControl.h" /** * * */ static const char * messages[] ={ "0 - Divide Error", "1 - Debug Exception", "2 - NMI Interrupt", "3 - Breakpoint", "4 - Overflow", "5 - Bound Range Exceeded", "6 - Invalid Opcode", "7 - Device not available", "8 - Double Fault", "9 - Co-processor segment", "10 - Invalid TSS", "11 - Segment not Present", "12 - Stack Segment-Fault", "13 - General Protection", "14 - Page Fault", "15 - Intel Reserved", "16 - x87 FPU error", "17 - Alignment Check", "18 - Machine Check", "19 - SIMD Floating Point" }; /** * Los id de los hilos para realizar llamadas, este arreglo contiene el hilo * que debe ser interrumpido cuando se produce una excepcion * 0 es valor que indica que ningun hilo debe ser interrumpido. * Los valores de 0 son asignados por el GRUB, Creo. * */ static TID _ids[256]; /** * \brief Envia un ipc al hilo que se encarga de manejar una interrupcion en especifico * \param value - Que interrupcion es */ int DoThreadInterrupt(const unsigned char value) { //printf("Ocurrio la interrupcion %x",value); if (_ids[value] == 0) return 0; if (!threadControl.SendHardwareIPC(_ids[value], value)) { _ids[value] = 0; return 0; } return 1; } /** * \brief Establece que hilo debe interrumpirse cuando ocurre una interrupcion dada * \param interrupt - Interrupcion * \param thread - Id del hilo a interrumpir */ void RegistreThreadToInterrupt(const unsigned char interrupt, TID thread) { _ids[interrupt] = thread; } /** * \brief * \param cs * \param eip */ static void debug_exception(unsigned cs, unsigned eip) { printf("Debugging step at %x:%x\n",cs,eip); } static void page_fault(unsigned cs, unsigned eip,unsigned error_code) { printf("%s\n Estado :%x:%x\nError Code : %x\n",messages[14],cs,eip,error_code); int addr; __asm__("movl %%cr2,%%eax; \ movl %%eax,%0;" :"=r"(addr) : :"%eax"); if (error_code & 0x01) printf("The fault was caused by a page-level protection violation.\n"); else printf("The fault was caused by a non-present page.\n"); if (error_code & 0x02) printf("The access causing the fault was a write.\n"); else printf("The access causing the fault was a read.\n"); if (error_code & 0x04) printf("The access causing the fault originated when the processor was executing in user mode.\n"); else printf("The access causing the fault originated when the processor was executing in supervisor mode.\n"); if (error_code & 0x08) printf("The fault was caused by a page-level protection violation.\n"); else printf("The fault was not caused by reserved bit violation.\n"); if (error_code & 0x10) printf("The fault was caused by an instruction fetch.\n"); else printf("The fault was not caused by an instruction fetch.\n"); printf("La direccion que causo el fallo de pagina fue %x \n",addr); while (1); } /** * \brief Esta funcion es usada para las interrupciones de 0 a 19, es decir las * producidas dentro del procesador, SEGmentation Fault, Page Fault y esas * \param number - El numero de la interrupcion * \param cs - El segmento de codigo donde se ejecutaba * \param eip - El eip donde se ejecutaba al ocurrir la interrupcion * \param error_code - El codigo de error si existe */ void high_level_handler_faults(unsigned number, unsigned cs, unsigned eip, unsigned error_code) { switch (number) { case 1: debug_exception(cs,eip); break; case 0: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 15: case 16: case 17: case 18: case 19: printf("%s\n Estado :%x:%x\nError Code : %x\n",messages[number],cs,eip,error_code); if (eip == 0xAC) { printf("Que cosa mas loca (el hilo es %d)\n",activeThread->tid); } while (true); break; case 14: // Page Fault page_fault(cs,eip,error_code); break; default: printf("Esto que cosa es %s(%d)\n",__FILE__,__LINE__); while (true); break; } } /** * \brief Esta funcion es el handler general de toda interrupcion * \param number - Numero de la interrupcion ocurrida */ void high_level_handler(unsigned number) { if (DoThreadInterrupt(number)) return; // Ocurre una interrupcion, debo atenderla printf("Interrupt Handler At %x\n",number); while (true); } /** * Es llamada por el procedimiento de atencion a la interrupcion SYS_CALL_VECTOR * es la forma en que los hilos realizan peticiones al microkernel */ void microkernel_syscall(unsigned type) { if (type == 43){ printf("Ha entrado correctamenta a FastSysCall\n"); return; } switch (activeThread->eax) { case THREAD_CONTROL: // ThreadControl //printf("Se produce una ThreadControl\n"); //printf("Area utcb creada %x\n", activeThread->edx); threadControl.CreateThread(activeThread->ebx,activeThread->ecx, activeThread->edx,activeThread->page_directory); //printf("ThreadControl Done!!!\n"); break; case INTERRUPT_CONTROL: // InterruptControl //printf("\n\nOcurre un registro%x %d\n\n",activeThread->ebx,activeThread->tid); RegistreThreadToInterrupt(activeThread->ebx,activeThread->tid); break; case IPC: // IPC threadControl.ipc(activeThread->ebx, activeThread->ecx, activeThread); break; default: //printf("Calls %d\n",activeThread->eax); break; } }
709365828a310e06fefc349151f12c1e44424d6f
be3d7eae5479326ef90bdcbef0a0beecb71fec3e
/InterviewBit-Solutions/Strings/Palindromic_String.cpp
7838b60201c677ca89e01618b80964084b20cc5b
[]
no_license
SurajChadha/dayzzofCode
0fa6752259615704c79436bd53a83cedf72e5872
ff36c128c9cac33233b109da3fd320a3a24d4786
refs/heads/master
2023-08-24T21:51:31.734866
2020-09-10T17:26:28
2020-09-10T17:26:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
370
cpp
Palindromic_String.cpp
int Solution::isPalindrome(string A) { string curr = ""; for(auto x : A){ if(isalpha(x)){ curr += tolower(x); } else if(isdigit(x)) curr += x; } int i = 0 , j = curr.size()-1; // cout << curr << endl; while( i < j){ if(curr[i++] != curr[j--]) return 0; } return 1; }
e2a828fb90eab5ae0bb4d2639017339a28481fe5
c1b03b59b3974058e3dc4e3aa7a46a7ab9cc3b29
/src/module-ml_linear/Feature.cpp
b517f597d7a494fec678a19d8c5f02d92a0749d7
[]
no_license
gura-lang/gura
972725895c93c22e0ec87c17166df4d15bdbe338
03aff5e2b7fe4f761a16400ae7cc6fa7fec73a47
refs/heads/master
2021-01-25T08:04:38.269289
2020-05-09T12:42:23
2020-05-09T12:42:23
7,141,465
25
0
null
null
null
null
UTF-8
C++
false
false
2,429
cpp
Feature.cpp
#include "stdafx.h" #include "Feature.h" Gura_BeginModuleScope(ml_linear) //----------------------------------------------------------------------------- // Feature //----------------------------------------------------------------------------- Feature::Feature() : _cntRef(1), _nNodes(0), _nodes(nullptr) { } Feature *Feature::Create(Environment &env, const ValueList &valList) { AutoPtr<Feature> pFeature(new Feature()); if (!pFeature->Store(env, valList)) return nullptr; return pFeature.release(); } bool Feature::Store(Environment &env, const ValueList &valList) { if (!valList.empty() && valList.GetValueTypeOfElements() != VTYPE_list) { env.SetError( ERR_TypeError, "wrong format for feature initialization: the list must consist of pairs of two numbers"); return false; } _nNodes = static_cast<int>(valList.size()) + 2; _nodes.reset(new struct feature_node [_nNodes]); size_t iNode = 0; foreach_const (ValueList, pValue, valList) { const ValueList &valListPair = pValue->GetList(); if (valListPair.GetValueTypeOfElements() != VTYPE_number || valListPair.size() != 2) { env.SetError( ERR_TypeError, "wrong format for feature initialization: the list must consist of pairs of two numbers"); return false; } int index = valListPair[0].GetInt(); size_t iNodeSet = iNode; // Search for a proper position to set the node if it has an index smaller than // the previous one, for ( ; iNodeSet > 0 && _nodes[iNodeSet - 1].index >= index; iNodeSet--) { if (_nodes[iNodeSet - 1].index == index) { env.SetError( ERR_IndexError, "wrong format for feature initialization: duplicated index"); return false; } } if (iNodeSet < iNode) { ::memmove(&_nodes[iNodeSet + 1], &_nodes[iNodeSet], sizeof(_nodes[0]) * (iNode - iNodeSet)); } _nodes[iNodeSet].index = index; _nodes[iNodeSet].value = valListPair[1].GetDouble(); iNode++; } // append nodes of bias and terminator. for (size_t i = 0; i < 2; i++, iNode++) { _nodes[iNode].index = -1; _nodes[iNode].value = 0; } return true; } void Feature::ClearBias() { if (_nNodes >= 2) { size_t iNode = _nNodes - 2; _nodes[iNode].index = -1; _nodes[iNode].value = 0; } } void Feature::SetBias(int indexForBias, double bias) { if (_nNodes >= 2) { size_t iNode = _nNodes - 2; _nodes[iNode].index = indexForBias; _nodes[iNode].value = bias; } } Gura_EndModuleScope(ml_linear)
acc0967a203df38388c0a4c617f59ab547a0a3ec
551de85294d3c314df8b69a3049a2b0e9247660e
/leet/heap/reorganize-string.cpp
8b48a192abda18d39ea1e8066a168794ef730b61
[]
no_license
rehassachdeva/coding-practice
078adaf9df8c8e6bd39875453cff39cc1e5af41e
7a41c62638d61f203faf305328bbefe9ab31dc2c
refs/heads/master
2022-12-17T16:52:56.889261
2020-09-25T10:34:24
2020-09-25T10:34:24
278,559,965
0
0
null
null
null
null
UTF-8
C++
false
false
966
cpp
reorganize-string.cpp
class Solution { public: string reorganizeString(string S) { map<char, int> m; int n=S.size(); for (auto& c : S) m[c]++; for (auto& [k,v] : m) { if (v>(n/2+n%2)) return ""; } priority_queue<pair<int, char>> pq; for (auto& [k,v] : m) pq.emplace(v,k); string ans=""; while (pq.size()>1) { auto f = pq.top(); pq.pop(); auto s = pq.top(); pq.pop(); ans += f.second; ans += s.second; f.first--; s.first--; if (f.first) pq.emplace(f.first, f.second); if (s.first) pq.emplace(s.first, s.second); } if (pq.empty()) return ans; return ans + pq.top().second; return ans; } };
2b8e962b0cdb5def0f558c1f8f820eae9946aae0
c07694d7005784539fd96ef93120c1d9dd477498
/hackerrank/algorithms/warmup/the_love_letter_mystery/the_love_letter_mystery.cpp
ba95b7d7bd8a2f10748f84b7889039fc4ebde443
[]
no_license
edran/code-exercises
31355ca25c6758ab77efe120c87f4d7ae326cde8
3c1475c132f4e912d228fbd8142722ba7430ff84
refs/heads/master
2021-01-17T11:03:43.905019
2017-02-05T19:52:07
2017-02-05T19:52:07
30,782,078
0
0
null
null
null
null
UTF-8
C++
false
false
385
cpp
the_love_letter_mystery.cpp
#include <vector> #include <iostream> #include <cmath> using namespace std; int op_palindrome(string s) { int sum = 0; for (int i = 0; i < s.size()/2; i++) { sum += abs(s[i] - s[s.size() - 1 - i]); } return sum; } int main() { string word; int t; cin >> t; for (int i=0; i<t; i++) { cin >> word; cout << op_palindrome(word) << endl; } return 0; }
b3f3229ebf219c5884ee0b0ab5623a2ce24b4ccc
46f2e7a10fca9f7e7b80b342240302c311c31914
/2_lids_driven_flow/cavity/0.0738/U
876a291eb25afeaf34b6fc82c81b358fc139a787
[]
no_license
patricksinclair/openfoam_warmups
696cb1950d40b967b8b455164134bde03e9179a1
03c982f7d46b4858e3b6bfdde7b8e8c3c4275df9
refs/heads/master
2020-12-26T12:50:00.615357
2020-02-04T20:22:35
2020-02-04T20:22:35
237,510,814
0
0
null
null
null
null
UTF-8
C++
false
false
61,421
U
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "0.0738"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 2500 ( (0.290244 -0.152406 0) (0.389514 -0.128226 0) (0.565392 -0.0747285 0) (0.683223 -0.042232 0) (0.752832 -0.0245348 0) (0.797874 -0.0148978 0) (0.829081 -0.00959334 0) (0.851602 -0.00657216 0) (0.868464 -0.00474949 0) (0.881487 -0.00357544 0) (0.891778 -0.00277183 0) (0.900044 -0.00219329 0) (0.906763 -0.00175999 0) (0.912268 -0.00142554 0) (0.916804 -0.00116132 0) (0.920552 -0.000948707 0) (0.92365 -0.000774927 0) (0.926205 -0.000630879 0) (0.928303 -0.000509829 0) (0.930008 -0.000406634 0) (0.931374 -0.000317249 0) (0.932439 -0.000238393 0) (0.933235 -0.000167329 0) (0.933784 -0.000101696 0) (0.934101 -3.93924e-05 0) (0.934196 2.15321e-05 0) (0.934068 8.30657e-05 0) (0.933715 0.000147047 0) (0.933125 0.000215502 0) (0.93228 0.000290678 0) (0.931154 0.000375148 0) (0.929712 0.000471983 0) (0.927906 0.000584981 0) (0.925678 0.000718993 0) (0.922951 0.000880411 0) (0.919622 0.00107792 0) (0.915563 0.0013237 0) (0.910598 0.00163555 0) (0.904494 0.00204052 0) (0.896925 0.00258207 0) (0.887424 0.00333422 0) (0.875299 0.00443128 0) (0.859461 0.00613189 0) (0.83811 0.00895675 0) (0.808192 0.0139658 0) (0.764438 0.0232509 0) (0.695915 0.0407742 0) (0.577939 0.0737475 0) (0.398041 0.128742 0) (0.293865 0.153782 0) (0.00107737 -0.294871 0) (0.0168366 -0.298595 0) (0.152304 -0.213015 0) (0.282862 -0.145342 0) (0.388077 -0.0996754 0) (0.471364 -0.0698668 0) (0.536875 -0.05053 0) (0.588458 -0.0377419 0) (0.62945 -0.0289909 0) (0.662406 -0.0227751 0) (0.689188 -0.0182047 0) (0.711148 -0.0147415 0) (0.729285 -0.0120504 0) (0.744342 -0.00991534 0) (0.756885 -0.00819169 0) (0.767351 -0.00677941 0) (0.776081 -0.00560689 0) (0.783344 -0.00462126 0) (0.789353 -0.00378241 0) (0.79428 -0.00305905 0) (0.798258 -0.0024261 0) (0.801395 -0.00186293 0) (0.803771 -0.00135203 0) (0.805448 -0.000878145 0) (0.806465 -0.000427472 0) (0.806847 1.2894e-05 0) (0.806598 0.00045556 0) (0.805708 0.0009132 0) (0.804147 0.00139922 0) (0.80187 0.00192835 0) (0.798806 0.00251737 0) (0.794862 0.00318608 0) (0.789919 0.00395864 0) (0.783818 0.00486541 0) (0.77636 0.00594562 0) (0.767289 0.00725132 0) (0.756273 0.00885356 0) (0.742884 0.010852 0) (0.726555 0.0133911 0) (0.70653 0.0166869 0) (0.681784 0.0210754 0) (0.6509 0.0270981 0) (0.611902 0.0356603 0) (0.562021 0.0483136 0) (0.497524 0.0677172 0) (0.413952 0.0981743 0) (0.306404 0.145796 0) (0.170553 0.21731 0) (0.0269058 0.307195 0) (0.00518353 0.303002 0) (-0.032922 -0.250361 0) (-0.0615894 -0.344027 0) (-0.0114653 -0.310613 0) (0.0708973 -0.251592 0) (0.159085 -0.196101 0) (0.241708 -0.15156 0) (0.314409 -0.117881 0) (0.376491 -0.0927951 0) (0.428847 -0.0740096 0) (0.472825 -0.0597461 0) (0.509758 -0.0487319 0) (0.540819 -0.0400796 0) (0.566987 -0.0331719 0) (0.589065 -0.0275761 0) (0.607703 -0.0229831 0) (0.62343 -0.0191681 0) (0.636675 -0.0159641 0) (0.647789 -0.0132437 0) (0.657056 -0.0109081 0) (0.664707 -0.00887848 0) (0.670929 -0.00709047 0) (0.675871 -0.00549038 0) (0.679647 -0.00403206 0) (0.682343 -0.00267474 0) (0.684018 -0.00138126 0) (0.684704 -0.000116586 0) (0.684409 0.00115345 0) (0.683117 0.0024636 0) (0.680787 0.00385043 0) (0.677348 0.00535388 0) (0.672701 0.00701916 0) (0.666714 0.00889916 0) (0.659213 0.0110576 0) (0.649978 0.0135734 0) (0.638731 0.0165467 0) (0.625125 0.0201077 0) (0.60872 0.0244295 0) (0.588968 0.0297468 0) (0.565172 0.0363854 0) (0.536457 0.0448056 0) (0.501722 0.05567 0) (0.459607 0.0699427 0) (0.408496 0.0890264 0) (0.346638 0.114919 0) (0.272602 0.150266 0) (0.186519 0.197831 0) (0.0924235 0.258149 0) (0.00192894 0.323367 0) (-0.0569045 0.361569 0) (-0.0321671 0.263989 0) (-0.0267681 -0.190598 0) (-0.0654014 -0.333012 0) (-0.0644707 -0.351559 0) (-0.0273339 -0.319367 0) (0.0298997 -0.272171 0) (0.094149 -0.225683 0) (0.157724 -0.185378 0) (0.216818 -0.152162 0) (0.269912 -0.125307 0) (0.316707 -0.103683 0) (0.357498 -0.0862104 0) (0.392823 -0.0719928 0) (0.42329 -0.0603239 0) (0.449487 -0.0506602 0) (0.471952 -0.0425854 0) (0.491158 -0.0357788 0) (0.507514 -0.0299906 0) (0.521369 -0.0250236 0) (0.533019 -0.0207196 0) (0.542709 -0.016949 0) (0.550643 -0.013604 0) (0.556985 -0.0105923 0) (0.561864 -0.00783373 0) (0.565376 -0.00525613 0) (0.567588 -0.00279314 0) (0.568536 -0.00038164 0) (0.568228 0.00204034 0) (0.566644 0.0045358 0) (0.563732 0.00717095 0) (0.55941 0.0100178 0) (0.55356 0.0131571 0) (0.546028 0.0166823 0) (0.536616 0.0207043 0) (0.525076 0.0253578 0) (0.511102 0.0308101 0) (0.494323 0.0372732 0) (0.47429 0.0450194 0) (0.450465 0.054404 0) (0.422213 0.0658953 0) (0.388806 0.0801134 0) (0.349441 0.0978771 0) (0.303317 0.120248 0) (0.249809 0.148536 0) (0.188835 0.184173 0) (0.121557 0.228232 0) (0.0516512 0.280034 0) (-0.0128373 0.333835 0) (-0.0576852 0.372341 0) (-0.0646306 0.356001 0) (-0.0272789 0.204823 0) (-0.0178409 -0.14917 0) (-0.0530662 -0.302984 0) (-0.0735189 -0.355007 0) (-0.0663934 -0.350462 0) (-0.0371071 -0.319882 0) (0.00512627 -0.280616 0) (0.0530971 -0.241246 0) (0.10204 -0.205387 0) (0.149111 -0.17415 0) (0.192803 -0.147505 0) (0.232462 -0.124978 0) (0.26793 -0.105976 0) (0.299323 -0.0899218 0) (0.326895 -0.0763108 0) (0.350956 -0.0647159 0) (0.37183 -0.0547832 0) (0.389827 -0.0462208 0) (0.405234 -0.0387871 0) (0.418305 -0.03228 0) (0.429262 -0.0265289 0) (0.438294 -0.0213874 0) (0.445557 -0.0167276 0) (0.451175 -0.0124355 0) (0.455243 -0.00840719 0) (0.457825 -0.00454566 0) (0.458955 -0.000757739 0) (0.458639 0.0030486 0) (0.456852 0.00696702 0) (0.453538 0.0110958 0) (0.44861 0.015541 0) (0.441947 0.0204204 0) (0.433389 0.0258684 0) (0.422739 0.0320413 0) (0.409754 0.0391249 0) (0.394149 0.0473438 0) (0.375587 0.0569727 0) (0.353686 0.0683509 0) (0.328023 0.0818988 0) (0.298155 0.0981361 0) (0.263655 0.117695 0) (0.224196 0.141317 0) (0.17969 0.169811 0) (0.130546 0.203899 0) (0.0780742 0.243855 0) (0.0250859 0.288702 0) (-0.0233385 0.334615 0) (-0.0591682 0.372048 0) (-0.0718176 0.381408 0) (-0.0542756 0.3283 0) (-0.0186349 0.162515 0) (-0.0114172 -0.120936 0) (-0.0402127 -0.270054 0) (-0.0677135 -0.340345 0) (-0.077538 -0.357624 0) (-0.0685764 -0.344431 0) (-0.0456234 -0.316254 0) (-0.0138639 -0.282473 0) (0.0224325 -0.248233 0) (0.0601489 -0.216064 0) (0.0972192 -0.187003 0) (0.132386 -0.161299 0) (0.164956 -0.138817 0) (0.19461 -0.119256 0) (0.221265 -0.102266 0) (0.244976 -0.0874983 0) (0.265877 -0.0746322 0) (0.284143 -0.0633803 0) (0.299957 -0.0534897 0) (0.313503 -0.0447385 0) (0.324952 -0.0369309 0) (0.334453 -0.0298935 0) (0.342138 -0.0234698 0) (0.34811 -0.0175176 0) (0.352451 -0.0119042 0) (0.355215 -0.00650409 0) (0.356429 -0.00119531 0) (0.356094 0.00414331 0) (0.354182 0.00963531 0) (0.35064 0.0154098 0) (0.34538 0.0216053 0) (0.338289 0.0283734 0) (0.329221 0.0358839 0) (0.317999 0.0443305 0) (0.304415 0.0539369 0) (0.288235 0.0649643 0) (0.269203 0.0777196 0) (0.247056 0.0925626 0) (0.221544 0.109911 0) (0.192473 0.130237 0) (0.159766 0.154047 0) (0.123575 0.181827 0) (0.0844381 0.213912 0) (0.0435192 0.250235 0) (0.00291888 0.289842 0) (-0.0339905 0.330051 0) (-0.0623607 0.365105 0) (-0.0760801 0.384238 0) (-0.0692414 0.369612 0) (-0.04224 0.295509 0) (-0.0121728 0.133051 0) (-0.00746025 -0.100964 0) (-0.0303784 -0.239846 0) (-0.0584886 -0.318361 0) (-0.0767119 -0.350643 0) (-0.0809654 -0.352228 0) (-0.0727685 -0.335584 0) (-0.0551423 -0.309462 0) (-0.0312488 -0.279475 0) (-0.00382238 -0.248958 0) (0.0250342 -0.219735 0) (0.0538273 -0.192696 0) (0.0815613 -0.168177 0) (0.107616 -0.146207 0) (0.131639 -0.126654 0) (0.153463 -0.109309 0) (0.173041 -0.0939335 0) (0.190401 -0.0802866 0) (0.205618 -0.0681364 0) (0.218787 -0.0572652 0) (0.230012 -0.0474712 0) (0.239394 -0.0385673 0) (0.247024 -0.0303798 0) (0.252977 -0.0227454 0) (0.257314 -0.0155092 0) (0.260072 -0.00852157 0) (0.26127 -0.0016359 0) (0.260902 0.00529464 0) (0.258941 0.0124199 0) (0.255335 0.0198958 0) (0.250007 0.0278878 0) (0.24286 0.0365749 0) (0.233772 0.0461532 0) (0.222604 0.0568403 0) (0.209202 0.0688798 0) (0.193406 0.0825446 0) (0.175065 0.0981388 0) (0.154055 0.115996 0) (0.130316 0.136468 0) (0.103902 0.159901 0) (0.0750535 0.186585 0) (0.0443013 0.216653 0) (0.0126064 0.249904 0) (-0.0184733 0.285511 0) (-0.0466176 0.321543 0) (-0.0686711 0.354256 0) (-0.0808326 0.377162 0) (-0.079303 0.38002 0) (-0.061894 0.348276 0) (-0.0326922 0.264107 0) (-0.008117 0.111733 0) (-0.00512268 -0.0863305 0) (-0.023473 -0.213619 0) (-0.0497384 -0.294262 0) (-0.0714798 -0.335833 0) (-0.0837298 -0.348681 0) (-0.0860233 -0.342295 0) (-0.0796611 -0.324158 0) (-0.0666369 -0.299657 0) (-0.0490282 -0.272405 0) (-0.0286592 -0.244681 0) (-0.00698522 -0.217837 0) (0.0149048 -0.192606 0) (0.0362373 -0.169329 0) (0.0564904 -0.148106 0) (0.075332 -0.128892 0) (0.0925688 -0.111562 0) (0.108104 -0.0959503 0) (0.121907 -0.0818694 0) (0.133986 -0.0691274 0) (0.144378 -0.0575333 0) (0.153127 -0.0469008 0) (0.16028 -0.0370495 0) (0.165881 -0.0278049 0) (0.169963 -0.018997 0) (0.172548 -0.0104588 0) (0.173641 -0.00202455 0) (0.173231 0.00647265 0) (0.171292 0.0152033 0) (0.167778 0.0243438 0) (0.162627 0.0340796 0) (0.155765 0.0446074 0) (0.147104 0.056138 0) (0.136551 0.0688985 0) (0.124015 0.0831325 0) (0.10942 0.0990996 0) (0.0927229 0.11707 0) (0.0739408 0.137311 0) (0.0531864 0.160066 0) (0.0307203 0.185509 0) (0.00701791 0.213669 0) (-0.0171477 0.244313 0) (-0.0406127 0.276757 0) (-0.0617383 0.309577 0) (-0.0783805 0.34022 0) (-0.0880002 0.364498 0) (-0.0880469 0.376055 0) (-0.0766966 0.366023 0) (-0.0541611 0.323268 0) (-0.0258505 0.235947 0) (-0.00569334 0.0957505 0) (-0.00372462 -0.0751547 0) (-0.018704 -0.191116 0) (-0.0424838 -0.270416 0) (-0.0652048 -0.317061 0) (-0.0820199 -0.337851 0) (-0.0914438 -0.33979 0) (-0.0936058 -0.328971 0) (-0.0895224 -0.310195 0) (-0.0805834 -0.286992 0) (-0.0682005 -0.261812 0) (-0.053628 -0.236278 0) (-0.0378973 -0.211408 0) (-0.0218115 -0.187795 0) (-0.00596852 -0.165747 0) (0.00920352 -0.145384 0) (0.0234109 -0.126701 0) (0.036462 -0.10962 0) (0.0482397 -0.0940142 0) (0.0586796 -0.0797324 0) (0.0677528 -0.0666076 0) (0.0754522 -0.054466 0) (0.081783 -0.0431312 0) (0.0867544 -0.0324262 0) (0.0903743 -0.0221738 0) (0.0926454 -0.0121971 0) (0.0935623 -0.00231773 0) (0.0931098 0.00764462 0) (0.0912626 0.0178742 0) (0.0879851 0.0285606 0) (0.0832336 0.0399004 0) (0.0769589 0.0520982 0) (0.0691112 0.0653676 0) (0.0596472 0.0799298 0) (0.0485409 0.0960113 0) (0.0357977 0.113837 0) (0.021475 0.13362 0) (0.00570881 0.155537 0) (-0.0112512 0.179697 0) (-0.0289975 0.206086 0) (-0.046914 0.234481 0) (-0.0641221 0.264326 0) (-0.0794362 0.294561 0) (-0.0913534 0.323377 0) (-0.0981164 0.347938 0) (-0.0979207 0.364067 0) (-0.0893429 0.36603 0) (-0.0719855 0.346573 0) (-0.0473854 0.297502 0) (-0.0210401 0.211136 0) (-0.00422775 0.0832729 0) (-0.00285811 -0.0662542 0) (-0.0153826 -0.171691 0) (-0.0367658 -0.247755 0) (-0.0592562 -0.296542 0) (-0.078519 -0.322519 0) (-0.0926509 -0.330785 0) (-0.101068 -0.326161 0) (-0.104066 -0.312744 0) (-0.102435 -0.293773 0) (-0.0971578 -0.271667 0) (-0.0892175 -0.248159 0) (-0.0794989 -0.224433 0) (-0.0687473 -0.201263 0) (-0.0575618 -0.179122 0) (-0.0464058 -0.15827 0) (-0.035627 -0.138818 0) (-0.0254778 -0.120776 0) (-0.0161366 -0.104084 0) (-0.00772505 -0.0886372 0) (-0.00032385 -0.0743028 0) (0.00601537 -0.0609282 0) (0.0112601 -0.0483491 0) (0.0153891 -0.0363939 0) (0.0183871 -0.024886 0) (0.0202401 -0.0136451 0) (0.0209327 -0.00248756 0) (0.0204466 0.00877355 0) (0.01876 0.020329 0) (0.0158486 0.0323736 0) (0.0116873 0.0451065 0) (0.00625471 0.0587306 0) (-0.00046183 0.0734506 0) (-0.00845762 0.0894699 0) (-0.0176995 0.106984 0) (-0.028111 0.126168 0) (-0.0395527 0.147163 0) (-0.0517985 0.170045 0) (-0.0645066 0.194784 0) (-0.0771869 0.221189 0) (-0.0891696 0.24882 0) (-0.0995803 0.276874 0) (-0.107338 0.304041 0) (-0.111195 0.328329 0) (-0.109852 0.346875 0) (-0.102195 0.355802 0) (-0.0876829 0.350194 0) (-0.0668372 0.324333 0) (-0.0417995 0.272321 0) (-0.0176159 0.189251 0) (-0.00330511 0.0731382 0) (-0.00229798 -0.0588971 0) (-0.0130304 -0.154696 0) (-0.0323467 -0.226527 0) (-0.0541019 -0.27547 0) (-0.0745627 -0.304486 0) (-0.0917429 -0.31728 0) (-0.104671 -0.317609 0) (-0.113151 -0.308875 0) (-0.117504 -0.293936 0) (-0.118329 -0.275056 0) (-0.116327 -0.253956 0) (-0.112197 -0.23189 0) (-0.106576 -0.209739 0) (-0.100011 -0.188092 0) (-0.0929545 -0.16732 0) (-0.0857677 -0.147629 0) (-0.0787321 -0.129109 0) (-0.0720621 -0.111765 0) (-0.065918 -0.095543 0) (-0.0604178 -0.0803458 0) (-0.0556475 -0.0660478 0) (-0.0516695 -0.052503 0) (-0.0485298 -0.0395514 0) (-0.0462631 -0.0270231 0) (-0.044897 -0.0147412 0) (-0.0444544 -0.00252291 0) (-0.0449552 0.00981849 0) (-0.0464162 0.0224733 0) (-0.0488502 0.0356344 0) (-0.0522633 0.0494953 0) (-0.0566509 0.0642486 0) (-0.0619915 0.0800814 0) (-0.0682387 0.0971694 0) (-0.0753098 0.115667 0) (-0.0830728 0.135695 0) (-0.0913293 0.157314 0) (-0.0997956 0.1805 0) (-0.108082 0.205098 0) (-0.115673 0.230767 0) (-0.121915 0.256898 0) (-0.126014 0.282527 0) (-0.127066 0.306216 0) (-0.124124 0.325942 0) (-0.116333 0.338994 0) (-0.103152 0.341935 0) (-0.084669 0.330697 0) (-0.0619387 0.300869 0) (-0.0372811 0.248268 0) (-0.0151191 0.169786 0) (-0.00269449 0.0646291 0) (-0.00192113 -0.0526192 0) (-0.0113343 -0.139584 0) (-0.0289532 -0.206677 0) (-0.0498237 -0.254446 0) (-0.0707746 -0.284884 0) (-0.0899015 -0.300694 0) (-0.106054 -0.304786 0) (-0.118724 -0.299944 0) (-0.12789 -0.288622 0) (-0.133835 -0.272866 0) (-0.137003 -0.254307 0) (-0.1379 -0.234196 0) (-0.13703 -0.213457 0) (-0.134859 -0.192748 0) (-0.131796 -0.172516 0) (-0.128185 -0.153042 0) (-0.12431 -0.134482 0) (-0.120399 -0.116897 0) (-0.116632 -0.10028 0) (-0.113152 -0.0845721 0) (-0.110066 -0.0696751 0) (-0.107459 -0.0554654 0) (-0.105394 -0.0417989 0) (-0.103921 -0.0285175 0) (-0.103077 -0.0154526 0) (-0.10289 -0.00242822 0) (-0.103378 0.0107364 0) (-0.104555 0.024225 0) (-0.10642 0.0382218 0) (-0.108963 0.0529085 0) (-0.112155 0.0684603 0) (-0.115948 0.0850403 0) (-0.120261 0.102791 0) (-0.124974 0.121821 0) (-0.129918 0.142192 0) (-0.134858 0.163893 0) (-0.139484 0.186806 0) (-0.143398 0.210674 0) (-0.146104 0.235038 0) (-0.147013 0.259181 0) (-0.145458 0.282051 0) (-0.14074 0.302182 0) (-0.132211 0.31763 0) (-0.119402 0.325935 0) (-0.102212 0.32415 0) (-0.0811477 0.308981 0) (-0.0575299 0.277079 0) (-0.0336306 0.225498 0) (-0.0132484 0.152292 0) (-0.0022698 0.0572942 0) (-0.00165885 -0.0471154 0) (-0.0100911 -0.125921 0) (-0.0263491 -0.188041 0) (-0.0463535 -0.233745 0) (-0.0674116 -0.264404 0) (-0.0877693 -0.282006 0) (-0.10622 -0.288807 0) (-0.122075 -0.28706 0) (-0.135073 -0.278844 0) (-0.145249 -0.26596 0) (-0.15283 -0.249905 0) (-0.158143 -0.231873 0) (-0.161557 -0.212787 0) (-0.16344 -0.193331 0) (-0.164138 -0.173998 0) (-0.163958 -0.155117 0) (-0.163165 -0.136896 0) (-0.161986 -0.119443 0) (-0.160603 -0.10279 0) (-0.159169 -0.0869115 0) (-0.157804 -0.0717401 0) (-0.156605 -0.0571742 0) (-0.155647 -0.0430884 0) (-0.154988 -0.0293397 0) (-0.154671 -0.015772 0) (-0.154727 -0.00222059 0) (-0.155173 0.0114846 0) (-0.156013 0.0255157 0) (-0.15724 0.0400433 0) (-0.158826 0.0552322 0) (-0.160726 0.0712358 0) (-0.162868 0.0881889 0) (-0.165146 0.106198 0) (-0.16742 0.125328 0) (-0.169496 0.145583 0) (-0.171129 0.166887 0) (-0.172007 0.189048 0) (-0.171753 0.211729 0) (-0.169924 0.234395 0) (-0.166024 0.256268 0) (-0.159535 0.276274 0) (-0.149965 0.292992 0) (-0.136934 0.304627 0) (-0.120285 0.309013 0) (-0.100238 0.303679 0) (-0.0775549 0.286003 0) (-0.0536576 0.253462 0) (-0.0306623 0.203994 0) (-0.0118101 0.1364 0) (-0.00196117 0.0508379 0) (-0.00147139 -0.042178 0) (-0.0091676 -0.113373 0) (-0.024348 -0.170428 0) (-0.0435758 -0.213468 0) (-0.0645483 -0.24346 0) (-0.0856785 -0.261883 0) (-0.105773 -0.270492 0) (-0.124046 -0.271106 0) (-0.140075 -0.265462 0) (-0.153715 -0.255121 0) (-0.165013 -0.241424 0) (-0.17414 -0.225478 0) (-0.181338 -0.208167 0) (-0.186876 -0.190173 0) (-0.191026 -0.172002 0) (-0.194047 -0.154017 0) (-0.196172 -0.136455 0) (-0.19761 -0.119461 0) (-0.198536 -0.103098 0) (-0.199102 -0.0873712 0) (-0.19943 -0.0722389 0) (-0.199621 -0.0576223 0) (-0.199757 -0.0434156 0) (-0.199898 -0.0294927 0) (-0.200091 -0.015713 0) (-0.200365 -0.00192619 0) (-0.200735 0.0120236 0) (-0.2012 0.0262931 0) (-0.20174 0.0410357 0) (-0.202319 0.0563959 0) (-0.202876 0.0725031 0) (-0.203325 0.0894626 0) (-0.203546 0.107345 0) (-0.203386 0.126174 0) (-0.202647 0.145906 0) (-0.201088 0.166409 0) (-0.198418 0.187438 0) (-0.194303 0.2086 0) (-0.188371 0.22932 0) (-0.180235 0.248805 0) (-0.169527 0.266005 0) (-0.155947 0.279595 0) (-0.139341 0.287964 0) (-0.119797 0.289249 0) (-0.0977506 0.281411 0) (-0.0741075 0.262384 0) (-0.0502927 0.230283 0) (-0.0282271 0.183668 0) (-0.0106792 0.12182 0) (-0.0017287 0.045059 0) (-0.00133471 -0.037661 0) (-0.00847445 -0.101684 0) (-0.0228072 -0.153653 0) (-0.0413711 -0.193623 0) (-0.0621733 -0.222291 0) (-0.0837862 -0.240776 0) (-0.105063 -0.250446 0) (-0.125175 -0.252768 0) (-0.143597 -0.249185 0) (-0.160053 -0.241032 0) (-0.174451 -0.229487 0) (-0.186832 -0.215555 0) (-0.19732 -0.200057 0) (-0.206093 -0.183648 0) (-0.213348 -0.16683 0) (-0.219288 -0.149973 0) (-0.224109 -0.133335 0) (-0.22799 -0.11708 0) (-0.231092 -0.101299 0) (-0.233555 -0.0860188 0) (-0.235498 -0.0712208 0) (-0.237021 -0.0568471 0) (-0.238202 -0.0428112 0) (-0.239104 -0.029005 0) (-0.239772 -0.0153047 0) (-0.240231 -0.00157624 0) (-0.240494 0.0123193 0) (-0.240553 0.0265213 0) (-0.240383 0.0411637 0) (-0.239936 0.0563693 0) (-0.239144 0.0722426 0) (-0.237911 0.0888605 0) (-0.236115 0.106261 0) (-0.233598 0.124432 0) (-0.230172 0.143289 0) (-0.225615 0.162663 0) (-0.21967 0.18227 0) (-0.212058 0.201689 0) (-0.202491 0.220336 0) (-0.190693 0.237433 0) (-0.176435 0.251994 0) (-0.159588 0.262815 0) (-0.140181 0.268484 0) (-0.118479 0.267425 0) (-0.0950645 0.257978 0) (-0.0709075 0.238527 0) (-0.0473822 0.207669 0) (-0.0262117 0.164405 0) (-0.00977355 0.108325 0) (-0.00154864 0.0398146 0) (-0.00123361 -0.0334596 0) (-0.00795028 -0.0906582 0) (-0.0216194 -0.137555 0) (-0.0396318 -0.174176 0) (-0.0602383 -0.201035 0) (-0.0821524 -0.218987 0) (-0.104287 -0.229107 0) (-0.125803 -0.232578 0) (-0.146115 -0.23059 0) (-0.164851 -0.224274 0) (-0.181815 -0.214652 0) (-0.19694 -0.202615 0) (-0.210253 -0.188911 0) (-0.221846 -0.174149 0) (-0.231846 -0.15881 0) (-0.240399 -0.143258 0) (-0.247658 -0.127756 0) (-0.25377 -0.112479 0) (-0.258874 -0.0975338 0) (-0.263094 -0.0829659 0) (-0.266539 -0.068774 0) (-0.269301 -0.054919 0) (-0.271455 -0.0413324 0) (-0.273058 -0.0279236 0) (-0.274153 -0.0145861 0) (-0.274762 -0.00120337 0) (-0.274891 0.0123458 0) (-0.274528 0.0261819 0) (-0.273642 0.040419 0) (-0.272182 0.0551581 0) (-0.270072 0.0704798 0) (-0.267216 0.086435 0) (-0.263491 0.103034 0) (-0.258751 0.120235 0) (-0.252822 0.137926 0) (-0.245511 0.155911 0) (-0.236605 0.173887 0) (-0.22589 0.191428 0) (-0.213159 0.207961 0) (-0.198243 0.222755 0) (-0.181041 0.234906 0) (-0.161563 0.243346 0) (-0.139984 0.246859 0) (-0.116698 0.244132 0) (-0.0923727 0.233826 0) (-0.0679981 0.214685 0) (-0.0448717 0.185669 0) (-0.0245321 0.146088 0) (-0.00903813 0.0957303 0) (-0.00140625 0.0349998 0) (-0.00115809 -0.0294968 0) (-0.00755198 -0.0801431 0) (-0.0207033 -0.121998 0) (-0.0382669 -0.155075 0) (-0.0586833 -0.179762 0) (-0.0807859 -0.19672 0) (-0.10355 -0.206797 0) (-0.126143 -0.210945 0) (-0.147945 -0.210142 0) (-0.168521 -0.205337 0) (-0.187594 -0.197404 0) (-0.205013 -0.187121 0) (-0.220724 -0.175155 0) (-0.234742 -0.162059 0) (-0.247131 -0.14828 0) (-0.257982 -0.134164 0) (-0.267406 -0.119966 0) (-0.275515 -0.105865 0) (-0.282423 -0.0919759 0) (-0.288234 -0.0783549 0) (-0.293044 -0.0650149 0) (-0.296932 -0.0519322 0) (-0.299968 -0.0390543 0) (-0.302202 -0.0263073 0) (-0.30367 -0.0136017 0) (-0.304391 -0.00083837 0) (-0.304366 0.012086 0) (-0.303579 0.0252731 0) (-0.301994 0.0388175 0) (-0.299556 0.0527995 0) (-0.296192 0.067278 0) (-0.291807 0.0822816 0) (-0.286285 0.0977986 0) (-0.279493 0.113765 0) (-0.271283 0.130052 0) (-0.261494 0.14645 0) (-0.249964 0.162654 0) (-0.236541 0.178248 0) (-0.2211 0.192694 0) (-0.203567 0.205319 0) (-0.183952 0.215318 0) (-0.16238 0.221761 0) (-0.139136 0.223619 0) (-0.114701 0.21981 0) (-0.0897939 0.209264 0) (-0.0653937 0.191011 0) (-0.042713 0.164281 0) (-0.0231267 0.128603 0) (-0.00843542 0.0838903 0) (-0.00129203 0.0305346 0) (-0.00110134 -0.0257152 0) (-0.00724869 -0.0700223 0) (-0.0199979 -0.106869 0) (-0.0372017 -0.136265 0) (-0.0574482 -0.158508 0) (-0.07967 -0.174113 0) (-0.1029 -0.183751 0) (-0.126323 -0.188185 0) (-0.1493 -0.188215 0) (-0.171355 -0.184629 0) (-0.19215 -0.178164 0) (-0.211468 -0.169489 0) (-0.22919 -0.159185 0) (-0.245265 -0.147745 0) (-0.259702 -0.135573 0) (-0.272542 -0.122985 0) (-0.283854 -0.110224 0) (-0.293717 -0.0974634 0) (-0.302217 -0.0848162 0) (-0.309439 -0.0723467 0) (-0.315461 -0.0600771 0) (-0.320351 -0.0479955 0) (-0.324168 -0.0360635 0) (-0.326954 -0.024222 0) (-0.32874 -0.0123975 0) (-0.329539 -0.000507684 0) (-0.329347 0.0115334 0) (-0.328145 0.0238096 0) (-0.325895 0.0363971 0) (-0.322542 0.0493574 0) (-0.318013 0.0627311 0) (-0.31222 0.0765288 0) (-0.305061 0.0907226 0) (-0.296418 0.105235 0) (-0.286172 0.119929 0) (-0.274198 0.134595 0) (-0.260383 0.148937 0) (-0.244637 0.162567 0) (-0.226909 0.174992 0) (-0.207211 0.185611 0) (-0.185642 0.193722 0) (-0.162421 0.19853 0) (-0.137913 0.199178 0) (-0.112659 0.194786 0) (-0.0874027 0.184506 0) (-0.0630955 0.167591 0) (-0.0408665 0.143476 0) (-0.0219506 0.111843 0) (-0.00793937 0.0726825 0) (-0.00119966 0.026356 0) (-0.00105862 -0.0220713 0) (-0.00701799 -0.0602048 0) (-0.0194566 -0.0920752 0) (-0.0363763 -0.117692 0) (-0.0564788 -0.137287 0) (-0.0787771 -0.151262 0) (-0.102355 -0.160144 0) (-0.126418 -0.164546 0) (-0.15032 -0.165113 0) (-0.173554 -0.16249 0) (-0.195743 -0.157293 0) (-0.216618 -0.150084 0) (-0.236004 -0.14136 0) (-0.2538 -0.13155 0) (-0.269964 -0.121006 0) (-0.284494 -0.110014 0) (-0.297422 -0.0987927 0) (-0.308794 -0.0875034 0) (-0.318672 -0.076255 0) (-0.327117 -0.0651127 0) (-0.334192 -0.054104 0) (-0.339953 -0.0432261 0) (-0.344445 -0.0324517 0) (-0.347705 -0.0217351 0) (-0.349754 -0.0110174 0) (-0.350601 -0.000231625 0) (-0.350239 0.0106919 0) (-0.348644 0.0218207 0) (-0.345778 0.0332142 0) (-0.341588 0.044918 0) (-0.336005 0.0569576 0) (-0.32895 0.0693304 0) (-0.320333 0.0819983 0) (-0.310059 0.0948782 0) (-0.298034 0.107833 0) (-0.284172 0.120663 0) (-0.268406 0.133095 0) (-0.250702 0.144777 0) (-0.231076 0.15527 0) (-0.20961 0.164055 0) (-0.186481 0.170529 0) (-0.161975 0.174031 0) (-0.136519 0.173855 0) (-0.110694 0.169296 0) (-0.0852471 0.159688 0) (-0.061099 0.144463 0) (-0.0393013 0.123207 0) (-0.0209707 0.0957092 0) (-0.00753167 0.0620034 0) (-0.00112482 0.022413 0) (-0.00102655 -0.0185319 0) (-0.00684345 -0.0506193 0) (-0.0190444 -0.0775416 0) (-0.035743 -0.0993093 0) (-0.0557281 -0.116102 0) (-0.0780767 -0.128231 0) (-0.101915 -0.13611 0) (-0.12647 -0.140222 0) (-0.151094 -0.141081 0) (-0.175262 -0.139207 0) (-0.198565 -0.135102 0) (-0.220696 -0.12923 0) (-0.241438 -0.122005 0) (-0.260648 -0.113788 0) (-0.27824 -0.10488 0) (-0.294179 -0.0955291 0) (-0.308459 -0.0859261 0) (-0.321101 -0.0762147 0) (-0.332142 -0.0664945 0) (-0.341624 -0.0568273 0) (-0.349592 -0.0472427 0) (-0.356089 -0.0377438 0) (-0.361151 -0.0283122 0) (-0.364805 -0.0189134 0) (-0.367067 -0.00950141 0) (-0.367939 -2.33256e-05 0) (-0.36741 0.009576 0) (-0.365456 0.0193492 0) (-0.362039 0.0293414 0) (-0.357107 0.0395852 0) (-0.350597 0.0500943 0) (-0.34244 0.0608578 0) (-0.332561 0.0718329 0) (-0.320884 0.0829376 0) (-0.307343 0.0940435 0) (-0.291886 0.104968 0) (-0.27449 0.115469 0) (-0.255169 0.125239 0) (-0.233996 0.133901 0) (-0.211113 0.141017 0) (-0.186754 0.146086 0) (-0.161263 0.148567 0) (-0.135107 0.147894 0) (-0.10889 0.143509 0) (-0.0833591 0.134899 0) (-0.0593987 0.121635 0) (-0.0379936 0.103416 0) (-0.0201633 0.0801073 0) (-0.00719934 0.0517632 0) (-0.00106454 0.0186628 0) (-0.00100272 -0.0150709 0) (-0.00671296 -0.0412095 0) (-0.0187348 -0.063207 0) (-0.0352647 -0.0810742 0) (-0.0551576 -0.0949485 0) (-0.0775399 -0.105068 0) (-0.101573 -0.111751 0) (-0.126503 -0.115369 0) (-0.151682 -0.116322 0) (-0.176576 -0.115021 0) (-0.200753 -0.11186 0) (-0.223878 -0.107212 0) (-0.2457 -0.101411 0) (-0.266043 -0.0947494 0) (-0.284788 -0.0874767 0) (-0.301868 -0.0797969 0) (-0.31725 -0.0718712 0) (-0.330932 -0.0638215 0) (-0.342926 -0.0557341 0) (-0.353259 -0.047664 0) (-0.361962 -0.0396399 0) (-0.369064 -0.0316678 0) (-0.374592 -0.0237362 0) (-0.378565 -0.0158199 0) (-0.380993 -0.00788414 0) (-0.381873 0.000111664 0) (-0.381191 0.00820965 0) (-0.378923 0.0164496 0) (-0.375029 0.0248646 0) (-0.369461 0.0334768 0) (-0.362164 0.0422919 0) (-0.353077 0.0512948 0) (-0.342139 0.0604431 0) (-0.329294 0.0696617 0) (-0.314499 0.0788372 0) (-0.297735 0.087812 0) (-0.279013 0.0963801 0) (-0.258392 0.104284 0) (-0.235988 0.111215 0) (-0.211992 0.116813 0) (-0.186686 0.120678 0) (-0.160452 0.122381 0) (-0.133787 0.121479 0) (-0.107311 0.117544 0) (-0.0817603 0.110186 0) (-0.0579892 0.0990884 0) (-0.0369255 0.0840377 0) (-0.0195111 0.0649487 0) (-0.00693318 0.0418818 0) (-0.00101672 0.0150683 0) (-0.000985393 -0.011668 0) (-0.00661768 -0.0319303 0) (-0.0185078 -0.0490215 0) (-0.0349129 -0.0629514 0) (-0.0547361 -0.0738221 0) (-0.0771414 -0.0818093 0) (-0.101318 -0.087148 0) (-0.126525 -0.0901144 0) (-0.152121 -0.0910085 0) (-0.177564 -0.0901374 0) (-0.202406 -0.0878017 0) (-0.226291 -0.084284 0) (-0.248945 -0.0798416 0) (-0.270165 -0.0747013 0) (-0.289806 -0.0690567 0) (-0.307778 -0.0630681 0) (-0.324024 -0.0568634 0) (-0.338522 -0.05054 0) (-0.351268 -0.0441679 0) (-0.362274 -0.0377926 0) (-0.371556 -0.031439 0) (-0.379135 -0.0251143 0) (-0.385029 -0.0188116 0) (-0.38925 -0.0125134 0) (-0.391802 -0.00619436 0) (-0.392679 0.000175078 0) (-0.391866 0.00662573 0) (-0.389334 0.0131864 0) (-0.385048 0.0198802 0) (-0.378962 0.0267214 0) (-0.371026 0.0337111 0) (-0.361189 0.0408332 0) (-0.3494 0.0480502 0) (-0.335622 0.055299 0) (-0.319833 0.0624859 0) (-0.302038 0.0694836 0) (-0.28228 0.0761275 0) (-0.26065 0.0822143 0) (-0.237301 0.0875023 0) (-0.212461 0.0917144 0) (-0.186446 0.0945441 0) (-0.159668 0.095666 0) (-0.132644 0.0947497 0) (-0.106001 0.0914779 0) (-0.0804659 0.0855673 0) (-0.0568662 0.0767913 0) (-0.0360842 0.0650022 0) (-0.0190015 0.0501485 0) (-0.00672666 0.0322863 0) (-0.000979884 0.0115969 0) (-0.000973348 -0.00830678 0) (-0.00655122 -0.022745 0) (-0.0183492 -0.0349436 0) (-0.0346663 -0.0449105 0) (-0.0544398 -0.052716 0) (-0.0768606 -0.0584812 0) (-0.101137 -0.0623677 0) (-0.126542 -0.0645662 0) (-0.152435 -0.0652848 0) (-0.178271 -0.0647373 0) (-0.203592 -0.063134 0) (-0.228029 -0.0606738 0) (-0.251288 -0.0575385 0) (-0.273147 -0.0538894 0) (-0.293446 -0.0498649 0) (-0.312073 -0.0455802 0) (-0.328956 -0.0411277 0) (-0.344057 -0.0365784 0) (-0.35736 -0.0319837 0) (-0.368863 -0.0273777 0) (-0.378575 -0.0227794 0) (-0.386507 -0.0181954 0) (-0.39267 -0.0136219 0) (-0.397073 -0.0090475 0) (-0.399713 -0.00445514 0) (-0.400583 0.000175245 0) (-0.399664 0.00486454 0) (-0.396929 0.00963204 0) (-0.392343 0.0144929 0) (-0.385863 0.0194556 0) (-0.377443 0.024519 0) (-0.367039 0.0296695 0) (-0.354612 0.0348777 0) (-0.340136 0.0400958 0) (-0.323607 0.0452544 0) (-0.30505 0.0502598 0) (-0.284528 0.0549923 0) (-0.26216 0.0593053 0) (-0.238126 0.0630259 0) (-0.21268 0.0659572 0) (-0.186162 0.0678833 0) (-0.159005 0.0685768 0) (-0.131739 0.0678087 0) (-0.104992 0.065361 0) (-0.0794867 0.0610415 0) (-0.0560264 0.0546986 0) (-0.0354602 0.046236 0) (-0.018626 0.0356246 0) (-0.00657522 0.0229086 0) (-0.000953028 0.00821848 0) (-0.000965748 -0.0049734 0) (-0.00650921 -0.0136229 0) (-0.0182487 -0.0209383 0) (-0.0345099 -0.0269249 0) (-0.0542516 -0.0316241 0) (-0.0766819 -0.0351066 0) (-0.101023 -0.0374671 0) (-0.126553 -0.0388175 0) (-0.152638 -0.0392801 0) (-0.178728 -0.0389812 0) (-0.20436 -0.0380451 0) (-0.229154 -0.0365899 0) (-0.252807 -0.034724 0) (-0.275085 -0.0325438 0) (-0.295815 -0.0301323 0) (-0.314872 -0.0275589 0) (-0.332175 -0.0248795 0) (-0.347673 -0.0221371 0) (-0.361343 -0.0193632 0) (-0.373175 -0.0165789 0) (-0.38317 -0.013796 0) (-0.391335 -0.0110191 0) (-0.397676 -0.00824644 0) (-0.402197 -0.00547148 0) (-0.404893 -0.00268452 0) (-0.405755 0.000126068 0) (-0.404764 0.00297235 0) (-0.401891 0.00586538 0) (-0.397101 0.00881369 0) (-0.390355 0.0118217 0) (-0.38161 0.0148878 0) (-0.370827 0.018003 0) (-0.357975 0.0211488 0) (-0.343035 0.0242954 0) (-0.326016 0.0274 0) (-0.306955 0.0304054 0) (-0.285932 0.0332391 0) (-0.263082 0.0358124 0) (-0.238602 0.0380216 0) (-0.212764 0.0397491 0) (-0.185925 0.0408667 0) (-0.158528 0.0412398 0) (-0.131112 0.0407339 0) (-0.104308 0.0392218 0) (-0.0788301 0.0365918 0) (-0.0554677 0.0327572 0) (-0.0350475 0.0276637 0) (-0.0183787 0.0212967 0) (-0.00647581 0.0136844 0) (-0.000935469 0.00490534 0) (-0.000962073 -0.00165606 0) (-0.00648886 -0.00453699 0) (-0.0182 -0.00697486 0) (-0.0344341 -0.00897146 0) (-0.0541603 -0.0105404 0) (-0.0765952 -0.0117051 0) (-0.100967 -0.0124967 0) (-0.126559 -0.0129519 0) (-0.152738 -0.0131114 0) (-0.178952 -0.0130166 0) (-0.204736 -0.0127089 0) (-0.229707 -0.0122273 0) (-0.253554 -0.0116079 0) (-0.27604 -0.0108827 0) (-0.296982 -0.0100795 0) (-0.316252 -0.00922126 0) (-0.333763 -0.00832681 0) (-0.349459 -0.00741058 0) (-0.363311 -0.00648313 0) (-0.375306 -0.00555158 0) (-0.385443 -0.00462001 0) (-0.393723 -0.00368997 0) (-0.400152 -0.00276097 0) (-0.404731 -0.00183093 0) (-0.407455 -0.000896681 0) (-0.408313 4.55763e-05 0) (-0.407284 0.000999787 0) (-0.40434 0.00196955 0) (-0.399448 0.00295761 0) (-0.392569 0.00396531 0) (-0.383661 0.00499203 0) (-0.372688 0.00603457 0) (-0.359623 0.00708661 0) (-0.344452 0.00813804 0) (-0.327188 0.00917442 0) (-0.307877 0.0101765 0) (-0.286606 0.01112 0) (-0.263517 0.0119753 0) (-0.238818 0.0127079 0) (-0.212788 0.0132785 0) (-0.185792 0.0136446 0) (-0.158279 0.0137618 0) (-0.130793 0.0135858 0) (-0.103963 0.0130745 0) (-0.0785006 0.0121916 0) (-0.0551886 0.0109086 0) (-0.034842 0.00920823 0) (-0.0182558 0.00708591 0) (-0.00642655 0.00455138 0) (-0.000926789 0.00163085 0) (-0.000962073 0.00165606 0) (-0.00648886 0.00453702 0) (-0.0182 0.0069749 0) (-0.0344341 0.00897151 0) (-0.0541603 0.0105405 0) (-0.0765952 0.0117052 0) (-0.100967 0.0124967 0) (-0.126559 0.012952 0) (-0.152738 0.0131114 0) (-0.178952 0.0130167 0) (-0.204736 0.0127089 0) (-0.229707 0.0122273 0) (-0.253554 0.0116079 0) (-0.27604 0.0108828 0) (-0.296982 0.0100795 0) (-0.316252 0.00922126 0) (-0.333763 0.00832681 0) (-0.349459 0.00741056 0) (-0.363311 0.00648311 0) (-0.375306 0.00555154 0) (-0.385443 0.00461996 0) (-0.393723 0.00368992 0) (-0.400152 0.00276091 0) (-0.404731 0.00183087 0) (-0.407455 0.000896615 0) (-0.408313 -4.56434e-05 0) (-0.407284 -0.000999855 0) (-0.40434 -0.00196962 0) (-0.399448 -0.00295768 0) (-0.392569 -0.00396537 0) (-0.383661 -0.00499208 0) (-0.372688 -0.00603462 0) (-0.359623 -0.00708665 0) (-0.344452 -0.00813807 0) (-0.327188 -0.00917445 0) (-0.307877 -0.0101766 0) (-0.286606 -0.0111201 0) (-0.263517 -0.0119754 0) (-0.238818 -0.0127079 0) (-0.212788 -0.0132785 0) (-0.185792 -0.0136446 0) (-0.158279 -0.0137618 0) (-0.130793 -0.0135857 0) (-0.103963 -0.0130745 0) (-0.0785007 -0.0121916 0) (-0.0551886 -0.0109086 0) (-0.034842 -0.00920822 0) (-0.0182558 -0.0070859 0) (-0.00642655 -0.00455137 0) (-0.000926789 -0.00163084 0) (-0.000965748 0.00497341 0) (-0.00650921 0.0136229 0) (-0.0182487 0.0209383 0) (-0.0345099 0.026925 0) (-0.0542516 0.0316242 0) (-0.0766819 0.0351067 0) (-0.101023 0.0374672 0) (-0.126553 0.0388176 0) (-0.152638 0.0392802 0) (-0.178728 0.0389812 0) (-0.20436 0.0380451 0) (-0.229154 0.03659 0) (-0.252807 0.0347241 0) (-0.275085 0.0325439 0) (-0.295815 0.0301324 0) (-0.314872 0.0275589 0) (-0.332174 0.0248795 0) (-0.347673 0.0221371 0) (-0.361343 0.0193632 0) (-0.373175 0.0165788 0) (-0.38317 0.013796 0) (-0.391335 0.0110191 0) (-0.397676 0.00824638 0) (-0.402197 0.00547142 0) (-0.404893 0.00268445 0) (-0.405755 -0.000126135 0) (-0.404764 -0.00297241 0) (-0.401891 -0.00586544 0) (-0.397101 -0.00881375 0) (-0.390355 -0.0118217 0) (-0.38161 -0.0148879 0) (-0.370827 -0.0180031 0) (-0.357975 -0.0211489 0) (-0.343035 -0.0242954 0) (-0.326016 -0.0274 0) (-0.306955 -0.0304054 0) (-0.285932 -0.0332391 0) (-0.263082 -0.0358124 0) (-0.238602 -0.0380216 0) (-0.212764 -0.0397491 0) (-0.185925 -0.0408667 0) (-0.158528 -0.0412398 0) (-0.131112 -0.0407339 0) (-0.104308 -0.0392218 0) (-0.0788301 -0.0365918 0) (-0.0554677 -0.0327572 0) (-0.0350475 -0.0276637 0) (-0.0183787 -0.0212967 0) (-0.00647581 -0.0136844 0) (-0.000935469 -0.00490534 0) (-0.000973348 0.00830679 0) (-0.00655122 0.0227451 0) (-0.0183492 0.0349436 0) (-0.0346663 0.0449105 0) (-0.0544398 0.0527161 0) (-0.0768605 0.0584813 0) (-0.101137 0.0623678 0) (-0.126542 0.0645663 0) (-0.152435 0.0652849 0) (-0.178271 0.0647374 0) (-0.203592 0.063134 0) (-0.228029 0.0606738 0) (-0.251288 0.0575386 0) (-0.273147 0.0538895 0) (-0.293446 0.0498649 0) (-0.312073 0.0455802 0) (-0.328956 0.0411277 0) (-0.344057 0.0365784 0) (-0.35736 0.0319837 0) (-0.368863 0.0273776 0) (-0.378575 0.0227794 0) (-0.386507 0.0181954 0) (-0.39267 0.0136219 0) (-0.397073 0.00904744 0) (-0.399713 0.00445507 0) (-0.400583 -0.000175311 0) (-0.399664 -0.0048646 0) (-0.396929 -0.00963211 0) (-0.392343 -0.014493 0) (-0.385863 -0.0194557 0) (-0.377443 -0.0245191 0) (-0.367039 -0.0296695 0) (-0.354612 -0.0348777 0) (-0.340136 -0.0400959 0) (-0.323607 -0.0452544 0) (-0.30505 -0.0502598 0) (-0.284528 -0.0549923 0) (-0.26216 -0.0593053 0) (-0.238126 -0.0630259 0) (-0.21268 -0.0659572 0) (-0.186162 -0.0678833 0) (-0.159005 -0.0685768 0) (-0.131739 -0.0678086 0) (-0.104992 -0.065361 0) (-0.0794867 -0.0610415 0) (-0.0560264 -0.0546986 0) (-0.0354602 -0.046236 0) (-0.018626 -0.0356246 0) (-0.00657522 -0.0229086 0) (-0.000953028 -0.00821848 0) (-0.000985393 0.0116681 0) (-0.00661767 0.0319303 0) (-0.0185078 0.0490215 0) (-0.0349129 0.0629515 0) (-0.0547361 0.0738221 0) (-0.0771414 0.0818094 0) (-0.101318 0.087148 0) (-0.126525 0.0901144 0) (-0.152121 0.0910085 0) (-0.177564 0.0901375 0) (-0.202406 0.0878017 0) (-0.226291 0.0842841 0) (-0.248945 0.0798417 0) (-0.270165 0.0747013 0) (-0.289806 0.0690567 0) (-0.307778 0.0630681 0) (-0.324024 0.0568634 0) (-0.338522 0.05054 0) (-0.351268 0.0441678 0) (-0.362274 0.0377926 0) (-0.371556 0.031439 0) (-0.379135 0.0251142 0) (-0.385029 0.0188116 0) (-0.38925 0.0125133 0) (-0.391802 0.0061943 0) (-0.392679 -0.000175142 0) (-0.391866 -0.0066258 0) (-0.389334 -0.0131864 0) (-0.385048 -0.0198803 0) (-0.378962 -0.0267215 0) (-0.371026 -0.0337111 0) (-0.361189 -0.0408332 0) (-0.3494 -0.0480503 0) (-0.335622 -0.055299 0) (-0.319833 -0.062486 0) (-0.302038 -0.0694836 0) (-0.28228 -0.0761275 0) (-0.26065 -0.0822143 0) (-0.237301 -0.0875023 0) (-0.212461 -0.0917144 0) (-0.186446 -0.0945441 0) (-0.159668 -0.095666 0) (-0.132644 -0.0947497 0) (-0.106001 -0.0914779 0) (-0.0804659 -0.0855673 0) (-0.0568662 -0.0767913 0) (-0.0360842 -0.0650022 0) (-0.0190015 -0.0501485 0) (-0.00672666 -0.0322863 0) (-0.000979884 -0.0115969 0) (-0.00100272 0.0150709 0) (-0.00671296 0.0412095 0) (-0.0187347 0.063207 0) (-0.0352647 0.0810742 0) (-0.0551575 0.0949486 0) (-0.0775399 0.105068 0) (-0.101573 0.111751 0) (-0.126503 0.115369 0) (-0.151682 0.116323 0) (-0.176576 0.115021 0) (-0.200753 0.11186 0) (-0.223878 0.107212 0) (-0.2457 0.101411 0) (-0.266043 0.0947494 0) (-0.284788 0.0874768 0) (-0.301868 0.0797969 0) (-0.31725 0.0718712 0) (-0.330932 0.0638215 0) (-0.342926 0.055734 0) (-0.353259 0.047664 0) (-0.361962 0.0396398 0) (-0.369064 0.0316677 0) (-0.374592 0.0237362 0) (-0.378565 0.0158199 0) (-0.380993 0.00788408 0) (-0.381873 -0.000111728 0) (-0.381191 -0.00820971 0) (-0.378923 -0.0164496 0) (-0.375029 -0.0248647 0) (-0.369461 -0.0334768 0) (-0.362164 -0.042292 0) (-0.353077 -0.0512949 0) (-0.342139 -0.0604431 0) (-0.329294 -0.0696617 0) (-0.314499 -0.0788372 0) (-0.297735 -0.087812 0) (-0.279013 -0.0963801 0) (-0.258392 -0.104284 0) (-0.235988 -0.111215 0) (-0.211992 -0.116813 0) (-0.186686 -0.120678 0) (-0.160452 -0.122381 0) (-0.133787 -0.121479 0) (-0.107311 -0.117544 0) (-0.0817603 -0.110186 0) (-0.0579892 -0.0990884 0) (-0.0369255 -0.0840377 0) (-0.0195111 -0.0649487 0) (-0.00693318 -0.0418818 0) (-0.00101672 -0.0150683 0) (-0.00102655 0.0185319 0) (-0.00684344 0.0506193 0) (-0.0190444 0.0775416 0) (-0.035743 0.0993093 0) (-0.0557281 0.116102 0) (-0.0780767 0.128231 0) (-0.101915 0.13611 0) (-0.12647 0.140222 0) (-0.151094 0.141081 0) (-0.175262 0.139207 0) (-0.198565 0.135102 0) (-0.220696 0.12923 0) (-0.241438 0.122005 0) (-0.260648 0.113788 0) (-0.27824 0.10488 0) (-0.294178 0.0955291 0) (-0.308459 0.0859261 0) (-0.321101 0.0762147 0) (-0.332142 0.0664945 0) (-0.341624 0.0568273 0) (-0.349592 0.0472427 0) (-0.356089 0.0377437 0) (-0.361151 0.0283121 0) (-0.364805 0.0189133 0) (-0.367067 0.00950135 0) (-0.367939 2.32623e-05 0) (-0.36741 -0.00957606 0) (-0.365456 -0.0193492 0) (-0.362039 -0.0293415 0) (-0.357107 -0.0395852 0) (-0.350597 -0.0500944 0) (-0.34244 -0.0608579 0) (-0.332561 -0.0718329 0) (-0.320884 -0.0829376 0) (-0.307343 -0.0940436 0) (-0.291886 -0.104968 0) (-0.27449 -0.115469 0) (-0.255169 -0.125239 0) (-0.233996 -0.133901 0) (-0.211113 -0.141017 0) (-0.186754 -0.146086 0) (-0.161263 -0.148567 0) (-0.135107 -0.147894 0) (-0.10889 -0.143509 0) (-0.0833591 -0.134899 0) (-0.0593987 -0.121635 0) (-0.0379936 -0.103416 0) (-0.0201633 -0.0801073 0) (-0.00719935 -0.0517632 0) (-0.00106454 -0.0186628 0) (-0.00105862 0.0220713 0) (-0.00701799 0.0602048 0) (-0.0194566 0.0920752 0) (-0.0363763 0.117692 0) (-0.0564788 0.137287 0) (-0.0787771 0.151262 0) (-0.102355 0.160144 0) (-0.126418 0.164546 0) (-0.15032 0.165113 0) (-0.173554 0.16249 0) (-0.195743 0.157293 0) (-0.216618 0.150084 0) (-0.236004 0.14136 0) (-0.2538 0.13155 0) (-0.269964 0.121006 0) (-0.284494 0.110014 0) (-0.297421 0.0987927 0) (-0.308794 0.0875033 0) (-0.318672 0.076255 0) (-0.327117 0.0651127 0) (-0.334192 0.0541039 0) (-0.339953 0.043226 0) (-0.344445 0.0324517 0) (-0.347705 0.0217351 0) (-0.349754 0.0110173 0) (-0.350601 0.000231564 0) (-0.350239 -0.010692 0) (-0.348644 -0.0218208 0) (-0.345778 -0.0332142 0) (-0.341588 -0.0449181 0) (-0.336005 -0.0569576 0) (-0.32895 -0.0693305 0) (-0.320333 -0.0819983 0) (-0.310059 -0.0948782 0) (-0.298034 -0.107833 0) (-0.284172 -0.120663 0) (-0.268406 -0.133095 0) (-0.250702 -0.144777 0) (-0.231076 -0.15527 0) (-0.20961 -0.164055 0) (-0.186481 -0.170529 0) (-0.161975 -0.174031 0) (-0.136519 -0.173855 0) (-0.110694 -0.169296 0) (-0.0852471 -0.159688 0) (-0.061099 -0.144463 0) (-0.0393013 -0.123207 0) (-0.0209707 -0.0957092 0) (-0.00753167 -0.0620034 0) (-0.00112482 -0.022413 0) (-0.00110134 0.0257152 0) (-0.00724868 0.0700223 0) (-0.0199979 0.106869 0) (-0.0372017 0.136265 0) (-0.0574482 0.158508 0) (-0.07967 0.174113 0) (-0.1029 0.183751 0) (-0.126323 0.188185 0) (-0.1493 0.188215 0) (-0.171354 0.184629 0) (-0.192149 0.178164 0) (-0.211468 0.169489 0) (-0.22919 0.159185 0) (-0.245265 0.147745 0) (-0.259702 0.135573 0) (-0.272542 0.122985 0) (-0.283854 0.110224 0) (-0.293717 0.0974634 0) (-0.302217 0.0848162 0) (-0.309439 0.0723467 0) (-0.315461 0.060077 0) (-0.320351 0.0479955 0) (-0.324168 0.0360634 0) (-0.326954 0.0242219 0) (-0.32874 0.0123974 0) (-0.329539 0.000507628 0) (-0.329347 -0.0115334 0) (-0.328145 -0.0238097 0) (-0.325895 -0.0363971 0) (-0.322542 -0.0493575 0) (-0.318013 -0.0627312 0) (-0.31222 -0.0765289 0) (-0.305061 -0.0907227 0) (-0.296418 -0.105235 0) (-0.286172 -0.119929 0) (-0.274198 -0.134595 0) (-0.260383 -0.148937 0) (-0.244637 -0.162567 0) (-0.226909 -0.174992 0) (-0.207211 -0.185611 0) (-0.185642 -0.193722 0) (-0.162421 -0.19853 0) (-0.137913 -0.199178 0) (-0.112659 -0.194786 0) (-0.0874027 -0.184506 0) (-0.0630955 -0.167591 0) (-0.0408665 -0.143476 0) (-0.0219506 -0.111843 0) (-0.00793937 -0.0726825 0) (-0.00119966 -0.026356 0) (-0.00115809 0.0294968 0) (-0.00755197 0.0801431 0) (-0.0207033 0.121998 0) (-0.0382669 0.155075 0) (-0.0586833 0.179762 0) (-0.0807859 0.19672 0) (-0.10355 0.206797 0) (-0.126143 0.210945 0) (-0.147945 0.210142 0) (-0.168521 0.205337 0) (-0.187594 0.197404 0) (-0.205013 0.187121 0) (-0.220724 0.175155 0) (-0.234742 0.162059 0) (-0.247131 0.14828 0) (-0.257982 0.134164 0) (-0.267406 0.119966 0) (-0.275515 0.105865 0) (-0.282423 0.0919759 0) (-0.288234 0.0783548 0) (-0.293044 0.0650149 0) (-0.296932 0.0519322 0) (-0.299968 0.0390543 0) (-0.302202 0.0263073 0) (-0.30367 0.0136017 0) (-0.304391 0.000838317 0) (-0.304366 -0.012086 0) (-0.303579 -0.0252732 0) (-0.301994 -0.0388176 0) (-0.299556 -0.0527995 0) (-0.296192 -0.067278 0) (-0.291807 -0.0822816 0) (-0.286285 -0.0977987 0) (-0.279493 -0.113765 0) (-0.271283 -0.130052 0) (-0.261494 -0.14645 0) (-0.249964 -0.162654 0) (-0.236541 -0.178248 0) (-0.2211 -0.192694 0) (-0.203567 -0.205319 0) (-0.183952 -0.215318 0) (-0.16238 -0.221761 0) (-0.139136 -0.223619 0) (-0.114701 -0.21981 0) (-0.0897939 -0.209264 0) (-0.0653937 -0.191011 0) (-0.042713 -0.164281 0) (-0.0231267 -0.128603 0) (-0.00843543 -0.0838903 0) (-0.00129203 -0.0305345 0) (-0.00123361 0.0334596 0) (-0.00795027 0.0906582 0) (-0.0216194 0.137555 0) (-0.0396318 0.174176 0) (-0.0602383 0.201035 0) (-0.0821524 0.218987 0) (-0.104287 0.229107 0) (-0.125803 0.232578 0) (-0.146115 0.23059 0) (-0.164851 0.224274 0) (-0.181815 0.214652 0) (-0.196939 0.202615 0) (-0.210253 0.188911 0) (-0.221846 0.174149 0) (-0.231846 0.15881 0) (-0.240399 0.143258 0) (-0.247658 0.127756 0) (-0.25377 0.112479 0) (-0.258874 0.0975338 0) (-0.263094 0.0829659 0) (-0.266539 0.068774 0) (-0.269301 0.054919 0) (-0.271455 0.0413324 0) (-0.273058 0.0279235 0) (-0.274153 0.014586 0) (-0.274762 0.00120332 0) (-0.274891 -0.0123458 0) (-0.274528 -0.0261819 0) (-0.273642 -0.040419 0) (-0.272181 -0.0551582 0) (-0.270072 -0.0704799 0) (-0.267216 -0.0864351 0) (-0.263491 -0.103034 0) (-0.258751 -0.120235 0) (-0.252822 -0.137926 0) (-0.245511 -0.155911 0) (-0.236605 -0.173887 0) (-0.22589 -0.191428 0) (-0.213159 -0.207961 0) (-0.198243 -0.222755 0) (-0.181041 -0.234906 0) (-0.161563 -0.243346 0) (-0.139984 -0.246859 0) (-0.116698 -0.244132 0) (-0.0923727 -0.233826 0) (-0.0679981 -0.214685 0) (-0.0448717 -0.185669 0) (-0.0245321 -0.146088 0) (-0.00903814 -0.0957303 0) (-0.00140625 -0.0349998 0) (-0.00133471 0.037661 0) (-0.00847444 0.101685 0) (-0.0228072 0.153653 0) (-0.0413711 0.193623 0) (-0.0621733 0.222291 0) (-0.0837862 0.240776 0) (-0.105063 0.250446 0) (-0.125175 0.252768 0) (-0.143597 0.249185 0) (-0.160053 0.241032 0) (-0.174451 0.229488 0) (-0.186832 0.215555 0) (-0.19732 0.200057 0) (-0.206093 0.183648 0) (-0.213348 0.16683 0) (-0.219288 0.149973 0) (-0.224109 0.133335 0) (-0.22799 0.11708 0) (-0.231092 0.101299 0) (-0.233555 0.0860188 0) (-0.235498 0.0712207 0) (-0.237021 0.056847 0) (-0.238202 0.0428112 0) (-0.239104 0.029005 0) (-0.239771 0.0153046 0) (-0.240231 0.0015762 0) (-0.240494 -0.0123194 0) (-0.240553 -0.0265213 0) (-0.240383 -0.0411637 0) (-0.239936 -0.0563694 0) (-0.239144 -0.0722427 0) (-0.237911 -0.0888605 0) (-0.236115 -0.106261 0) (-0.233598 -0.124432 0) (-0.230172 -0.143289 0) (-0.225615 -0.162663 0) (-0.21967 -0.18227 0) (-0.212058 -0.201689 0) (-0.202491 -0.220336 0) (-0.190693 -0.237433 0) (-0.176435 -0.251994 0) (-0.159588 -0.262815 0) (-0.140181 -0.268484 0) (-0.118479 -0.267425 0) (-0.0950645 -0.257978 0) (-0.0709075 -0.238527 0) (-0.0473822 -0.207669 0) (-0.0262117 -0.164405 0) (-0.00977355 -0.108325 0) (-0.00154864 -0.0398146 0) (-0.00147139 0.042178 0) (-0.00916759 0.113373 0) (-0.0243479 0.170428 0) (-0.0435758 0.213468 0) (-0.0645483 0.24346 0) (-0.0856785 0.261883 0) (-0.105773 0.270492 0) (-0.124046 0.271106 0) (-0.140075 0.265462 0) (-0.153714 0.255121 0) (-0.165013 0.241424 0) (-0.17414 0.225478 0) (-0.181338 0.208167 0) (-0.186876 0.190173 0) (-0.191026 0.172002 0) (-0.194046 0.154017 0) (-0.196172 0.136455 0) (-0.19761 0.119461 0) (-0.198536 0.103098 0) (-0.199101 0.0873712 0) (-0.199429 0.0722389 0) (-0.199621 0.0576223 0) (-0.199757 0.0434156 0) (-0.199898 0.0294927 0) (-0.200091 0.015713 0) (-0.200365 0.00192615 0) (-0.200735 -0.0120236 0) (-0.2012 -0.0262931 0) (-0.20174 -0.0410357 0) (-0.202319 -0.056396 0) (-0.202876 -0.0725031 0) (-0.203325 -0.0894626 0) (-0.203546 -0.107345 0) (-0.203386 -0.126174 0) (-0.202647 -0.145906 0) (-0.201088 -0.166409 0) (-0.198418 -0.187438 0) (-0.194303 -0.2086 0) (-0.188371 -0.22932 0) (-0.180235 -0.248805 0) (-0.169527 -0.266005 0) (-0.155947 -0.279595 0) (-0.139341 -0.287964 0) (-0.119797 -0.289249 0) (-0.0977506 -0.281411 0) (-0.0741075 -0.262384 0) (-0.0502927 -0.230283 0) (-0.0282271 -0.183668 0) (-0.0106792 -0.12182 0) (-0.0017287 -0.045059 0) (-0.00165885 0.0471154 0) (-0.0100911 0.125921 0) (-0.0263491 0.188041 0) (-0.0463535 0.233745 0) (-0.0674115 0.264404 0) (-0.0877692 0.282006 0) (-0.10622 0.288807 0) (-0.122075 0.28706 0) (-0.135073 0.278844 0) (-0.145249 0.26596 0) (-0.15283 0.249905 0) (-0.158143 0.231873 0) (-0.161557 0.212787 0) (-0.16344 0.193331 0) (-0.164138 0.173998 0) (-0.163957 0.155117 0) (-0.163165 0.136896 0) (-0.161985 0.119443 0) (-0.160603 0.102789 0) (-0.159169 0.0869114 0) (-0.157804 0.07174 0) (-0.156605 0.0571741 0) (-0.155647 0.0430884 0) (-0.154988 0.0293397 0) (-0.154671 0.015772 0) (-0.154727 0.00222056 0) (-0.155173 -0.0114847 0) (-0.156013 -0.0255158 0) (-0.15724 -0.0400434 0) (-0.158826 -0.0552322 0) (-0.160726 -0.0712358 0) (-0.162868 -0.0881889 0) (-0.165146 -0.106198 0) (-0.16742 -0.125328 0) (-0.169496 -0.145583 0) (-0.171129 -0.166887 0) (-0.172007 -0.189048 0) (-0.171753 -0.211729 0) (-0.169924 -0.234395 0) (-0.166024 -0.256268 0) (-0.159535 -0.276274 0) (-0.149965 -0.292992 0) (-0.136934 -0.304627 0) (-0.120285 -0.309013 0) (-0.100238 -0.303679 0) (-0.0775549 -0.286003 0) (-0.0536576 -0.253462 0) (-0.0306623 -0.203994 0) (-0.0118101 -0.1364 0) (-0.00196117 -0.0508379 0) (-0.00192113 0.0526192 0) (-0.0113343 0.139584 0) (-0.0289532 0.206677 0) (-0.0498237 0.254446 0) (-0.0707745 0.284884 0) (-0.0899014 0.300694 0) (-0.106053 0.304786 0) (-0.118724 0.299944 0) (-0.12789 0.288622 0) (-0.133835 0.272866 0) (-0.137003 0.254307 0) (-0.1379 0.234196 0) (-0.13703 0.213457 0) (-0.134859 0.192748 0) (-0.131796 0.172516 0) (-0.128185 0.153042 0) (-0.12431 0.134482 0) (-0.120399 0.116897 0) (-0.116632 0.10028 0) (-0.113152 0.0845721 0) (-0.110066 0.0696751 0) (-0.107459 0.0554654 0) (-0.105394 0.0417989 0) (-0.103921 0.0285175 0) (-0.103077 0.0154525 0) (-0.10289 0.00242819 0) (-0.103378 -0.0107364 0) (-0.104555 -0.024225 0) (-0.10642 -0.0382218 0) (-0.108963 -0.0529085 0) (-0.112155 -0.0684604 0) (-0.115948 -0.0850403 0) (-0.120261 -0.102791 0) (-0.124974 -0.121821 0) (-0.129918 -0.142192 0) (-0.134858 -0.163893 0) (-0.139484 -0.186806 0) (-0.143398 -0.210674 0) (-0.146104 -0.235038 0) (-0.147013 -0.259181 0) (-0.145458 -0.282051 0) (-0.14074 -0.302182 0) (-0.132211 -0.31763 0) (-0.119402 -0.325935 0) (-0.102212 -0.32415 0) (-0.0811477 -0.308981 0) (-0.0575299 -0.277079 0) (-0.0336306 -0.225498 0) (-0.0132484 -0.152292 0) (-0.0022698 -0.0572942 0) (-0.00229798 0.0588971 0) (-0.0130304 0.154696 0) (-0.0323467 0.226527 0) (-0.0541019 0.27547 0) (-0.0745627 0.304486 0) (-0.0917429 0.31728 0) (-0.104671 0.317609 0) (-0.11315 0.308875 0) (-0.117504 0.293936 0) (-0.118329 0.275056 0) (-0.116327 0.253956 0) (-0.112197 0.23189 0) (-0.106576 0.209739 0) (-0.100011 0.188092 0) (-0.0929545 0.16732 0) (-0.0857676 0.147629 0) (-0.078732 0.129109 0) (-0.072062 0.111765 0) (-0.0659179 0.095543 0) (-0.0604177 0.0803458 0) (-0.0556474 0.0660478 0) (-0.0516694 0.052503 0) (-0.0485297 0.0395514 0) (-0.0462631 0.0270231 0) (-0.044897 0.0147411 0) (-0.0444544 0.00252289 0) (-0.0449552 -0.00981852 0) (-0.0464162 -0.0224734 0) (-0.0488501 -0.0356344 0) (-0.0522632 -0.0494954 0) (-0.0566509 -0.0642487 0) (-0.0619915 -0.0800814 0) (-0.0682387 -0.0971695 0) (-0.0753098 -0.115667 0) (-0.0830728 -0.135695 0) (-0.0913293 -0.157314 0) (-0.0997956 -0.1805 0) (-0.108082 -0.205098 0) (-0.115673 -0.230767 0) (-0.121915 -0.256898 0) (-0.126014 -0.282527 0) (-0.127066 -0.306216 0) (-0.124124 -0.325942 0) (-0.116333 -0.338994 0) (-0.103152 -0.341935 0) (-0.084669 -0.330697 0) (-0.0619387 -0.300869 0) (-0.0372811 -0.248268 0) (-0.0151191 -0.169786 0) (-0.00269449 -0.0646291 0) (-0.00285811 0.0662542 0) (-0.0153826 0.171691 0) (-0.0367658 0.247755 0) (-0.0592562 0.296542 0) (-0.0785189 0.322519 0) (-0.0926508 0.330785 0) (-0.101068 0.326161 0) (-0.104066 0.312744 0) (-0.102435 0.293773 0) (-0.0971578 0.271667 0) (-0.0892175 0.248159 0) (-0.0794988 0.224433 0) (-0.0687472 0.201263 0) (-0.0575617 0.179122 0) (-0.0464058 0.15827 0) (-0.0356269 0.138818 0) (-0.0254777 0.120776 0) (-0.0161365 0.104084 0) (-0.00772497 0.0886372 0) (-0.00032378 0.0743028 0) (0.00601544 0.0609282 0) (0.0112601 0.0483491 0) (0.0153892 0.0363939 0) (0.0183872 0.024886 0) (0.0202401 0.0136451 0) (0.0209327 0.00248754 0) (0.0204467 -0.00877357 0) (0.0187601 -0.020329 0) (0.0158486 -0.0323736 0) (0.0116874 -0.0451065 0) (0.00625474 -0.0587306 0) (-0.000461805 -0.0734506 0) (-0.0084576 -0.0894699 0) (-0.0176995 -0.106984 0) (-0.0281109 -0.126168 0) (-0.0395527 -0.147163 0) (-0.0517985 -0.170045 0) (-0.0645066 -0.194784 0) (-0.0771869 -0.221189 0) (-0.0891696 -0.24882 0) (-0.0995803 -0.276874 0) (-0.107338 -0.304041 0) (-0.111195 -0.328329 0) (-0.109852 -0.346875 0) (-0.102195 -0.355802 0) (-0.0876829 -0.350194 0) (-0.0668372 -0.324333 0) (-0.0417995 -0.272321 0) (-0.0176159 -0.189251 0) (-0.00330511 -0.0731382 0) (-0.00372462 0.0751547 0) (-0.018704 0.191116 0) (-0.0424838 0.270416 0) (-0.0652048 0.317061 0) (-0.0820199 0.337851 0) (-0.0914438 0.33979 0) (-0.0936057 0.328971 0) (-0.0895224 0.310195 0) (-0.0805834 0.286992 0) (-0.0682004 0.261812 0) (-0.0536279 0.236278 0) (-0.0378973 0.211408 0) (-0.0218114 0.187795 0) (-0.00596845 0.165747 0) (0.00920359 0.145384 0) (0.023411 0.126701 0) (0.0364621 0.10962 0) (0.0482398 0.0940142 0) (0.0586797 0.0797324 0) (0.0677528 0.0666076 0) (0.0754523 0.054466 0) (0.0817831 0.0431312 0) (0.0867544 0.0324262 0) (0.0903743 0.0221738 0) (0.0926454 0.0121971 0) (0.0935623 0.00231772 0) (0.0931099 -0.00764464 0) (0.0912626 -0.0178742 0) (0.0879852 -0.0285606 0) (0.0832337 -0.0399004 0) (0.0769589 -0.0520983 0) (0.0691112 -0.0653676 0) (0.0596472 -0.0799298 0) (0.0485409 -0.0960113 0) (0.0357978 -0.113837 0) (0.0214751 -0.13362 0) (0.00570882 -0.155537 0) (-0.0112512 -0.179697 0) (-0.0289975 -0.206086 0) (-0.046914 -0.234481 0) (-0.0641221 -0.264326 0) (-0.0794362 -0.294561 0) (-0.0913534 -0.323377 0) (-0.0981164 -0.347938 0) (-0.0979207 -0.364067 0) (-0.0893429 -0.36603 0) (-0.0719855 -0.346573 0) (-0.0473854 -0.297502 0) (-0.0210401 -0.211136 0) (-0.00422775 -0.0832729 0) (-0.00512268 0.0863305 0) (-0.023473 0.213619 0) (-0.0497384 0.294262 0) (-0.0714798 0.335833 0) (-0.0837297 0.348681 0) (-0.0860233 0.342295 0) (-0.079661 0.324158 0) (-0.0666369 0.299657 0) (-0.0490281 0.272405 0) (-0.0286591 0.244681 0) (-0.00698516 0.217837 0) (0.0149048 0.192606 0) (0.0362374 0.169329 0) (0.0564904 0.148106 0) (0.0753321 0.128892 0) (0.0925688 0.111562 0) (0.108104 0.0959503 0) (0.121907 0.0818694 0) (0.133987 0.0691274 0) (0.144378 0.0575333 0) (0.153127 0.0469008 0) (0.16028 0.0370495 0) (0.165881 0.0278049 0) (0.169964 0.018997 0) (0.172548 0.0104588 0) (0.173641 0.00202454 0) (0.173231 -0.00647266 0) (0.171292 -0.0152033 0) (0.167778 -0.0243438 0) (0.162627 -0.0340796 0) (0.155765 -0.0446074 0) (0.147104 -0.0561381 0) (0.136551 -0.0688985 0) (0.124015 -0.0831325 0) (0.10942 -0.0990996 0) (0.092723 -0.11707 0) (0.0739408 -0.137311 0) (0.0531864 -0.160066 0) (0.0307203 -0.185509 0) (0.00701791 -0.213669 0) (-0.0171477 -0.244313 0) (-0.0406127 -0.276757 0) (-0.0617383 -0.309577 0) (-0.0783805 -0.34022 0) (-0.0880002 -0.364498 0) (-0.0880469 -0.376055 0) (-0.0766966 -0.366023 0) (-0.0541611 -0.323268 0) (-0.0258505 -0.235947 0) (-0.00569334 -0.0957505 0) (-0.00746025 0.100964 0) (-0.0303784 0.239846 0) (-0.0584886 0.318361 0) (-0.0767118 0.350643 0) (-0.0809653 0.352228 0) (-0.0727685 0.335584 0) (-0.0551422 0.309462 0) (-0.0312487 0.279475 0) (-0.00382232 0.248958 0) (0.0250343 0.219735 0) (0.0538274 0.192696 0) (0.0815614 0.168177 0) (0.107616 0.146207 0) (0.131639 0.126654 0) (0.153463 0.109309 0) (0.173041 0.0939335 0) (0.190401 0.0802866 0) (0.205618 0.0681364 0) (0.218787 0.0572652 0) (0.230012 0.0474712 0) (0.239394 0.0385673 0) (0.247024 0.0303798 0) (0.252977 0.0227454 0) (0.257314 0.0155091 0) (0.260072 0.00852156 0) (0.26127 0.0016359 0) (0.260902 -0.00529465 0) (0.258941 -0.0124199 0) (0.255335 -0.0198958 0) (0.250007 -0.0278878 0) (0.24286 -0.0365749 0) (0.233772 -0.0461532 0) (0.222604 -0.0568403 0) (0.209202 -0.0688798 0) (0.193406 -0.0825446 0) (0.175065 -0.0981388 0) (0.154055 -0.115996 0) (0.130316 -0.136468 0) (0.103902 -0.159901 0) (0.0750535 -0.186585 0) (0.0443013 -0.216653 0) (0.0126064 -0.249904 0) (-0.0184733 -0.285511 0) (-0.0466176 -0.321543 0) (-0.0686711 -0.354256 0) (-0.0808326 -0.377162 0) (-0.079303 -0.38002 0) (-0.061894 -0.348276 0) (-0.0326922 -0.264107 0) (-0.008117 -0.111733 0) (-0.0114172 0.120936 0) (-0.0402127 0.270054 0) (-0.0677135 0.340345 0) (-0.0775379 0.357624 0) (-0.0685764 0.344431 0) (-0.0456233 0.316254 0) (-0.0138638 0.282472 0) (0.0224326 0.248233 0) (0.060149 0.216064 0) (0.0972193 0.187003 0) (0.132386 0.161299 0) (0.164956 0.138817 0) (0.19461 0.119256 0) (0.221265 0.102266 0) (0.244976 0.0874983 0) (0.265877 0.0746322 0) (0.284143 0.0633803 0) (0.299957 0.0534897 0) (0.313504 0.0447385 0) (0.324952 0.0369309 0) (0.334453 0.0298935 0) (0.342138 0.0234698 0) (0.34811 0.0175176 0) (0.352451 0.0119042 0) (0.355215 0.00650408 0) (0.356429 0.00119531 0) (0.356094 -0.00414331 0) (0.354182 -0.00963531 0) (0.35064 -0.0154098 0) (0.34538 -0.0216053 0) (0.338289 -0.0283734 0) (0.329221 -0.035884 0) (0.317999 -0.0443306 0) (0.304415 -0.0539369 0) (0.288235 -0.0649643 0) (0.269203 -0.0777196 0) (0.247056 -0.0925626 0) (0.221544 -0.109911 0) (0.192473 -0.130237 0) (0.159766 -0.154047 0) (0.123575 -0.181827 0) (0.0844381 -0.213912 0) (0.0435192 -0.250235 0) (0.00291888 -0.289842 0) (-0.0339905 -0.330051 0) (-0.0623607 -0.365105 0) (-0.0760801 -0.384238 0) (-0.0692414 -0.369612 0) (-0.04224 -0.295509 0) (-0.0121728 -0.133051 0) (-0.0178409 0.14917 0) (-0.0530661 0.302984 0) (-0.0735188 0.355007 0) (-0.0663933 0.350462 0) (-0.037107 0.319882 0) (0.00512634 0.280616 0) (0.0530971 0.241246 0) (0.10204 0.205387 0) (0.149111 0.17415 0) (0.192804 0.147505 0) (0.232462 0.124978 0) (0.26793 0.105976 0) (0.299323 0.0899218 0) (0.326895 0.0763108 0) (0.350956 0.0647159 0) (0.37183 0.0547832 0) (0.389827 0.0462208 0) (0.405234 0.0387871 0) (0.418305 0.03228 0) (0.429262 0.0265289 0) (0.438294 0.0213874 0) (0.445557 0.0167276 0) (0.451175 0.0124355 0) (0.455243 0.00840719 0) (0.457825 0.00454565 0) (0.458955 0.000757737 0) (0.458639 -0.0030486 0) (0.456852 -0.00696702 0) (0.453538 -0.0110958 0) (0.44861 -0.015541 0) (0.441947 -0.0204204 0) (0.433389 -0.0258684 0) (0.422739 -0.0320413 0) (0.409754 -0.0391249 0) (0.394149 -0.0473438 0) (0.375587 -0.0569727 0) (0.353686 -0.0683509 0) (0.328023 -0.0818988 0) (0.298155 -0.0981361 0) (0.263655 -0.117695 0) (0.224196 -0.141317 0) (0.17969 -0.169811 0) (0.130546 -0.203899 0) (0.0780742 -0.243855 0) (0.0250859 -0.288702 0) (-0.0233385 -0.334615 0) (-0.0591682 -0.372048 0) (-0.0718176 -0.381408 0) (-0.0542756 -0.3283 0) (-0.0186349 -0.162515 0) (-0.0267681 0.190598 0) (-0.0654013 0.333012 0) (-0.0644706 0.351559 0) (-0.0273338 0.319367 0) (0.0298998 0.272171 0) (0.0941491 0.225683 0) (0.157724 0.185378 0) (0.216818 0.152162 0) (0.269912 0.125307 0) (0.316707 0.103683 0) (0.357498 0.0862104 0) (0.392823 0.0719928 0) (0.42329 0.0603239 0) (0.449487 0.0506602 0) (0.471952 0.0425854 0) (0.491158 0.0357788 0) (0.507514 0.0299906 0) (0.521369 0.0250236 0) (0.533019 0.0207196 0) (0.542709 0.016949 0) (0.550643 0.013604 0) (0.556985 0.0105923 0) (0.561864 0.00783373 0) (0.565376 0.00525613 0) (0.567588 0.00279314 0) (0.568536 0.00038164 0) (0.568228 -0.00204034 0) (0.566644 -0.0045358 0) (0.563732 -0.00717095 0) (0.55941 -0.0100178 0) (0.55356 -0.0131571 0) (0.546028 -0.0166824 0) (0.536616 -0.0207043 0) (0.525076 -0.0253578 0) (0.511102 -0.0308101 0) (0.494323 -0.0372732 0) (0.47429 -0.0450194 0) (0.450465 -0.054404 0) (0.422213 -0.0658953 0) (0.388806 -0.0801134 0) (0.349441 -0.0978771 0) (0.303317 -0.120248 0) (0.249809 -0.148536 0) (0.188835 -0.184173 0) (0.121557 -0.228232 0) (0.0516512 -0.280034 0) (-0.0128373 -0.333835 0) (-0.0576852 -0.372341 0) (-0.0646306 -0.356001 0) (-0.0272789 -0.204823 0) (-0.032922 0.250361 0) (-0.0615893 0.344027 0) (-0.0114652 0.310613 0) (0.0708974 0.251592 0) (0.159085 0.1961 0) (0.241708 0.15156 0) (0.314409 0.117881 0) (0.376491 0.0927951 0) (0.428847 0.0740096 0) (0.472825 0.0597461 0) (0.509758 0.0487319 0) (0.540819 0.0400796 0) (0.566988 0.0331719 0) (0.589065 0.0275761 0) (0.607703 0.0229831 0) (0.62343 0.0191681 0) (0.636675 0.0159641 0) (0.647789 0.0132437 0) (0.657056 0.0109081 0) (0.664707 0.00887848 0) (0.670929 0.00709047 0) (0.675871 0.00549038 0) (0.679647 0.00403206 0) (0.682343 0.00267474 0) (0.684018 0.00138127 0) (0.684704 0.000116587 0) (0.684409 -0.00115345 0) (0.683117 -0.0024636 0) (0.680787 -0.00385043 0) (0.677348 -0.00535388 0) (0.672701 -0.00701916 0) (0.666714 -0.00889916 0) (0.659213 -0.0110576 0) (0.649978 -0.0135734 0) (0.638731 -0.0165467 0) (0.625125 -0.0201077 0) (0.60872 -0.0244295 0) (0.588968 -0.0297468 0) (0.565172 -0.0363854 0) (0.536457 -0.0448056 0) (0.501722 -0.05567 0) (0.459607 -0.0699427 0) (0.408496 -0.0890264 0) (0.346638 -0.114919 0) (0.272602 -0.150266 0) (0.186519 -0.197831 0) (0.0924235 -0.258149 0) (0.00192894 -0.323367 0) (-0.0569045 -0.361569 0) (-0.0321671 -0.263989 0) (0.00107748 0.294871 0) (0.0168368 0.298595 0) (0.152304 0.213015 0) (0.282862 0.145342 0) (0.388077 0.0996754 0) (0.471364 0.0698667 0) (0.536875 0.05053 0) (0.588458 0.0377419 0) (0.62945 0.0289909 0) (0.662406 0.0227751 0) (0.689188 0.0182047 0) (0.711149 0.0147415 0) (0.729285 0.0120504 0) (0.744342 0.00991534 0) (0.756885 0.00819169 0) (0.767351 0.00677941 0) (0.776081 0.00560689 0) (0.783344 0.00462126 0) (0.789353 0.00378241 0) (0.79428 0.00305905 0) (0.798258 0.0024261 0) (0.801395 0.00186293 0) (0.803771 0.00135203 0) (0.805448 0.000878146 0) (0.806465 0.000427473 0) (0.806847 -1.28929e-05 0) (0.806598 -0.000455559 0) (0.805708 -0.000913199 0) (0.804148 -0.00139922 0) (0.80187 -0.00192835 0) (0.798806 -0.00251737 0) (0.794862 -0.00318608 0) (0.789919 -0.00395864 0) (0.783818 -0.00486541 0) (0.77636 -0.00594562 0) (0.767289 -0.00725132 0) (0.756273 -0.00885356 0) (0.742884 -0.010852 0) (0.726555 -0.0133911 0) (0.70653 -0.0166869 0) (0.681784 -0.0210754 0) (0.6509 -0.0270981 0) (0.611902 -0.0356603 0) (0.562021 -0.0483136 0) (0.497524 -0.0677172 0) (0.413952 -0.0981743 0) (0.306404 -0.145796 0) (0.170553 -0.21731 0) (0.0269058 -0.307195 0) (0.00518353 -0.303002 0) (0.290244 0.152406 0) (0.389514 0.128226 0) (0.565392 0.0747284 0) (0.683223 0.042232 0) (0.752832 0.0245348 0) (0.797874 0.0148978 0) (0.829081 0.00959334 0) (0.851602 0.00657216 0) (0.868464 0.00474949 0) (0.881487 0.00357544 0) (0.891778 0.00277184 0) (0.900044 0.00219329 0) (0.906763 0.00175999 0) (0.912268 0.00142554 0) (0.916804 0.00116133 0) (0.920552 0.000948708 0) (0.92365 0.000774928 0) (0.926205 0.00063088 0) (0.928303 0.00050983 0) (0.930008 0.000406635 0) (0.931374 0.000317249 0) (0.932439 0.000238393 0) (0.933235 0.00016733 0) (0.933784 0.000101697 0) (0.934102 3.93923e-05 0) (0.934196 -2.15322e-05 0) (0.934068 -8.30654e-05 0) (0.933715 -0.000147046 0) (0.933125 -0.000215503 0) (0.93228 -0.000290679 0) (0.931154 -0.000375149 0) (0.929712 -0.000471984 0) (0.927906 -0.000584982 0) (0.925678 -0.000718994 0) (0.922951 -0.000880411 0) (0.919622 -0.00107792 0) (0.915563 -0.00132371 0) (0.910598 -0.00163555 0) (0.904494 -0.00204052 0) (0.896925 -0.00258207 0) (0.887424 -0.00333422 0) (0.875299 -0.00443128 0) (0.859461 -0.00613189 0) (0.83811 -0.00895675 0) (0.808192 -0.0139658 0) (0.764438 -0.0232509 0) (0.695915 -0.0407742 0) (0.577939 -0.0737475 0) (0.398041 -0.128742 0) (0.293865 -0.153782 0) ) ; boundaryField { movingWallTop { type fixedValue; value uniform (1 0 0); } movingWallBottom { type fixedValue; value uniform (1 0 0); } fixedWalls { type noSlip; } frontAndBack { type empty; } } // ************************************************************************* //
c6a2562c24e222c5ad1040b8fc52f03e56a58351
b70b6ae1f1707d03ae5b8ea0c8f64fe995874faf
/SimpleGameFramework/Vector.cpp
ffc5fb52be4a8790f85e6996aa15b55d4f7b3bb3
[]
no_license
Qiao712/SimpleGameFramework
cdaf2c52ed5eae2ac1f53e308eaf08fea87cd5c6
50f687f04e3610a8c19f51f1279b3e8844a50766
refs/heads/master
2023-03-10T20:05:38.830170
2021-02-26T13:36:27
2021-02-26T13:36:27
336,698,707
3
0
null
null
null
null
UTF-8
C++
false
false
1,223
cpp
Vector.cpp
#include "Vector.h" #include <cmath> void Vector::round() { x = ::round(x); y = ::round(y); } Vector Vector::operator+(const Vector& rhs) const { return Vector(x + rhs.x, y + rhs.y); } Vector Vector::operator-(const Vector& rhs) const { return Vector(x - rhs.x, y - rhs.y); } double Vector::operator*(const Vector& rhs) const { return x*rhs.x + y*rhs.y; } Vector Vector::operator*(double scale) const { return Vector(x*scale, y*scale); } Vector Vector::operator/(double scale) const { return Vector(x/scale, y/scale); } Vector& Vector::operator+=(const Vector& rhs) { x += rhs.x; y += rhs.y; return *this; } Vector& Vector::operator-=(const Vector& rhs) { x -= rhs.x; y -= rhs.y; return *this; } Vector& Vector::operator*=(double scale) { x *= scale; y *= scale; return *this; } Vector& Vector::operator/=(double scale) { x /= scale; y /= scale; return *this; } bool Vector::operator==(const Vector& rhs) const { return x == rhs.x && y == rhs.y; } bool Vector::operator!=(const Vector& rhs) const { return x != rhs.x || y != rhs.y; } double Vector::length() const { return sqrt(x*x + y*y); } double Vector::projection(const Vector& rhs) const { return operator*(rhs) / rhs.length(); }
fa9b6412408a3655c805aa0ff92c460b990d2315
0fb3f2465fb86f83e61ffc3e5cc2806851f7bc97
/main.cpp
75fff3c0bd04e6c2b8349c061a4e608790d11cc5
[]
no_license
Gumisia/FirstCpp
e42de4b5ab9126d045f5c9bcdd5d76e3d512c81f
a09e2238b11f455ec39c4c4aae26848f6a8e2b1b
refs/heads/master
2020-04-01T09:41:18.256157
2018-10-15T09:20:28
2018-10-15T09:20:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,115
cpp
main.cpp
#include <iostream> #include <string> using std::cout; using std::string; using std::endl; struct student { int index; int semestr; string name; }; enum marka { szkoda=1, bentlej=1, bwm=3 }; struct samochod { int przebieg; marka marka; }; student create(); void to_string(student); student create(){ student student1; student1.index = 1234; student1.name = "Kasia"; student1.semestr = 3; return student1; } void to_string(student student1){ cout << endl << "index: " << student1.index << endl << "semstr: " << student1.semestr << endl << "name: " << student1.name << endl; } union X { int integer; float floating; }; int main() { samochod samochod1, samochod2; samochod1.marka = szkoda; samochod2.marka = bentlej; if (samochod1.marka == samochod2.marka){ cout << "the same"; } student student1 = create(); to_string(student1); X x; x.integer = 3; x.floating = 3.14f; std::cout << x.integer << std::endl; std::cout << x.floating << std::endl; return 0; }
c78d79625da665fba6851788271f1f00810c5370
0577a46d8d28e1fd8636893bbdd2b18270bb8eb8
/components/ad_blocker/adblock_rule_service_storage.cc
4b38c4f681376b51f3717ea582fe744f44921b8c
[ "BSD-3-Clause" ]
permissive
ric2b/Vivaldi-browser
388a328b4cb838a4c3822357a5529642f86316a5
87244f4ee50062e59667bf8b9ca4d5291b6818d7
refs/heads/master
2022-12-21T04:44:13.804535
2022-12-17T16:30:35
2022-12-17T16:30:35
86,637,416
166
41
BSD-3-Clause
2021-03-31T18:49:30
2017-03-29T23:09:05
null
UTF-8
C++
false
false
20,280
cc
adblock_rule_service_storage.cc
// Copyright (c) 2019 Vivaldi Technologies AS. All rights reserved #include "components/ad_blocker/adblock_rule_service_storage.h" #include <map> #include <utility> #include <vector> #include "base/files/file_util.h" #include "base/json/json_file_value_serializer.h" #include "base/json/json_string_value_serializer.h" #include "base/json/values_util.h" #include "base/time/time.h" #include "components/ad_blocker/adblock_known_sources_handler.h" #include "components/ad_blocker/adblock_rule_service.h" namespace adblock_filter { namespace { const char kTrackingRulesKey[] = "tracking-rules"; const char kAdBlockingRulesKey[] = "ad-blocking-rules"; const char kExceptionsTypeKey[] = "exceptions-type"; const char kProcessListKey[] = "process_list"; const char kExemptListKey[] = "exempt_list"; const char kEnabledKey[] = "enabled"; const char kIndexChecksum[] = "index-checksum"; const char kRuleSourcesKey[] = "rule-sources"; const char kKnownSourcesKey[] = "known-sources"; const char kDeletedPresetsKey[] = "deleted-presets"; const char kSourceUrlKey[] = "source-url"; const char kSourceFileKey[] = "source-file"; const char kGroupKey[] = "group"; const char kAllowAbpSnippets[] = "allow-abp-snippets"; const char kRulesListChecksumKey[] = "rules-list-checksum"; const char kLastUpdateKey[] = "last-upate"; const char kNextFetchKey[] = "next-fetch"; const char kLastFetchResultKey[] = "last-fetch-result"; const char kHasTrackerInfosKey[] = "has-tracker-infos"; const char kValidRulesCountKey[] = "valid-rules-count"; const char kUnsupportedRulesCountKey[] = "unsupported-rules-count"; const char kInvalidRulesCountKey[] = "invalid-rules-count"; const char kTitleKey[] = "title"; const char kHomePageKey[] = "homepage"; const char kLicenseKey[] = "license"; const char kRedirectKey[] = "redirect"; const char kVersionKey[] = "version"; const char kExpiresKey[] = "expires"; const char kBlockedDomainsCountersKey[] = "blocked-domain-counters"; const char kBlockedForOriginCountersKey[] = "blocked-for-origin-counters"; const char kBlockedReportingStartKey[] = "blocked-reporting-start"; const char kPresetIdKey[] = "preset-id"; const int kCurrentStorageVersion = 6; const base::FilePath::CharType kSourcesFileName[] = FILE_PATH_LITERAL("AdBlockState"); // Extension used for backup files (copy of main file created during startup). const base::FilePath::CharType kBackupExtension[] = FILE_PATH_LITERAL("bak"); // How often we save. const int kSaveDelay = 10; // seconds void BackupCallback(const base::FilePath& path) { base::FilePath backup_path = path.ReplaceExtension(kBackupExtension); base::CopyFile(path, backup_path); } void LoadCounters(const base::Value& counters_value, std::map<std::string, int>& counters) { DCHECK(counters_value.is_dict()); for (const auto counter : counters_value.DictItems()) { if (!counter.second.is_int()) continue; counters[counter.first] = counter.second.GetInt(); } } void LoadSourcesList(base::Value& sources_list, RuleSources& rule_sources) { DCHECK(sources_list.is_list()); for (auto& source_value : sources_list.GetList()) { if (!source_value.is_dict()) continue; const std::string* source_file = source_value.FindStringKey(kSourceFileKey); const std::string* source_url_string = source_value.FindStringKey(kSourceUrlKey); absl::optional<int> group = source_value.FindIntKey(kGroupKey); // The rule must have its group set if (!group || group.value() < static_cast<int>(RuleGroup::kFirst) || group.value() > static_cast<int>(RuleGroup::kLast)) continue; GURL source_url; if (source_url_string) { source_url = GURL(*source_url_string); if (!source_url.is_valid() || source_url.is_empty()) continue; rule_sources.emplace_back(source_url, RuleGroup(group.value())); } else if (source_file) { rule_sources.emplace_back(base::FilePath::FromUTF8Unsafe(*source_file), RuleGroup(group.value())); } else { // The rules must either come form a file or a URL continue; } absl::optional<bool> allow_abp_snippets = source_value.FindBoolKey(kAllowAbpSnippets); if (allow_abp_snippets && allow_abp_snippets.value()) rule_sources.back().allow_abp_snippets = true; std::string* rules_list_checksum = source_value.FindStringKey(kRulesListChecksumKey); if (rules_list_checksum) rule_sources.back().rules_list_checksum = std::move(*rules_list_checksum); absl::optional<base::Time> last_update = base::ValueToTime(source_value.FindKey(kLastUpdateKey)); if (last_update) { rule_sources.back().last_update = last_update.value(); } absl::optional<base::Time> next_fetch = base::ValueToTime(source_value.FindKey(kNextFetchKey)); if (next_fetch) { rule_sources.back().next_fetch = next_fetch.value(); } absl::optional<int> last_fetch_result = source_value.FindIntKey(kLastFetchResultKey); if (last_fetch_result && last_fetch_result.value() >= static_cast<int>(FetchResult::kFirst) && last_fetch_result.value() <= static_cast<int>(FetchResult::kLast)) rule_sources.back().last_fetch_result = FetchResult(last_fetch_result.value()); absl::optional<bool> has_tracker_infos = source_value.FindBoolKey(kHasTrackerInfosKey); if (has_tracker_infos) rule_sources.back().has_tracker_infos = has_tracker_infos.value(); absl::optional<int> valid_rules_count = source_value.FindIntKey(kValidRulesCountKey); if (valid_rules_count) rule_sources.back().rules_info.valid_rules = *valid_rules_count; absl::optional<int> unsupported_rules_count = source_value.FindIntKey(kUnsupportedRulesCountKey); if (unsupported_rules_count) rule_sources.back().rules_info.unsupported_rules = *unsupported_rules_count; absl::optional<int> invalid_rules_count = source_value.FindIntKey(kInvalidRulesCountKey); if (invalid_rules_count) rule_sources.back().rules_info.invalid_rules = *invalid_rules_count; std::string* title = source_value.FindStringKey(kTitleKey); if (title) rule_sources.back().unsafe_adblock_metadata.title = std::move(*title); const std::string* homepage = source_value.FindStringKey(kHomePageKey); if (homepage) rule_sources.back().unsafe_adblock_metadata.homepage = GURL(*homepage); const std::string* license = source_value.FindStringKey(kLicenseKey); if (license) rule_sources.back().unsafe_adblock_metadata.license = GURL(*license); const std::string* redirect = source_value.FindStringKey(kRedirectKey); if (redirect) rule_sources.back().unsafe_adblock_metadata.redirect = GURL(*redirect); absl::optional<int64_t> version = base::ValueToInt64(source_value.FindKey(kVersionKey)); if (version) rule_sources.back().unsafe_adblock_metadata.version = *version; absl::optional<base::TimeDelta> expires = base::ValueToTimeDelta(source_value.FindKey(kExpiresKey)); if (last_update) { rule_sources.back().unsafe_adblock_metadata.expires = expires.value(); } } } void LoadStringSetFromList(base::Value& list, std::set<std::string>& string_set) { DCHECK(list.is_list()); for (auto& item : list.GetList()) { if (!item.is_string()) continue; string_set.insert(std::move(item.GetString())); } } void LoadKnownSources(base::Value& sources_list, std::vector<KnownRuleSource>& known_sources) { DCHECK(sources_list.is_list()); for (auto& source_value : sources_list.GetList()) { if (!source_value.is_dict()) continue; const std::string* source_file = source_value.FindStringKey(kSourceFileKey); const std::string* source_url_string = source_value.FindStringKey(kSourceUrlKey); absl::optional<int> group = source_value.FindIntKey(kGroupKey); // The rule must have its group set if (!group || group.value() < static_cast<int>(RuleGroup::kFirst) || group.value() > static_cast<int>(RuleGroup::kLast)) continue; GURL source_url; if (source_url_string) { source_url = GURL(*source_url_string); if (!source_url.is_valid() || source_url.is_empty()) continue; known_sources.emplace_back(source_url, RuleGroup(group.value())); } else if (source_file) { known_sources.emplace_back(base::FilePath::FromUTF8Unsafe(*source_file), RuleGroup(group.value())); } else { // The rules must either come form a file or a URL continue; } absl::optional<bool> allow_abp_snippets = source_value.FindBoolKey(kAllowAbpSnippets); if (allow_abp_snippets && allow_abp_snippets.value()) known_sources.back().allow_abp_snippets = true; std::string* preset_id = source_value.FindStringKey(kPresetIdKey); if (preset_id) known_sources.back().preset_id = std::move(*preset_id); } } void LoadRulesGroup(RuleGroup group, base::Value& rule_group_value, RuleServiceStorage::LoadResult& load_result) { DCHECK(rule_group_value.is_dict()); absl::optional<int> active_exception_list = rule_group_value.FindIntKey(kExceptionsTypeKey); if (active_exception_list && active_exception_list >= RuleManager::kFirstExceptionList && active_exception_list <= RuleManager::kLastExceptionList) { load_result.active_exceptions_lists[static_cast<size_t>(group)] = RuleManager::ExceptionsList(active_exception_list.value()); } base::Value* process_list = rule_group_value.FindListKey(kProcessListKey); if (process_list) LoadStringSetFromList(*process_list, load_result.exceptions[static_cast<size_t>(group)] [RuleManager::kProcessList]); base::Value* exempt_list = rule_group_value.FindListKey(kExemptListKey); if (exempt_list) LoadStringSetFromList(*exempt_list, load_result.exceptions[static_cast<size_t>(group)] [RuleManager::kExemptList]); absl::optional<bool> enabled = rule_group_value.FindBoolKey(kEnabledKey); if (enabled) load_result.groups_enabled[static_cast<size_t>(group)] = enabled.value(); std::string* index_checksum = rule_group_value.FindStringKey(kIndexChecksum); if (index_checksum) load_result.index_checksums[static_cast<size_t>(group)] = std::move(*index_checksum); base::Value* sources_list = rule_group_value.FindListKey(kRuleSourcesKey); if (sources_list) LoadSourcesList(*sources_list, load_result.rule_sources[static_cast<size_t>(group)]); base::Value* known_sources_list = rule_group_value.FindListKey(kKnownSourcesKey); if (known_sources_list) LoadKnownSources(*known_sources_list, load_result.known_sources[static_cast<size_t>(group)]); base::Value* deleted_presets_list = rule_group_value.FindListKey(kDeletedPresetsKey); if (deleted_presets_list) LoadStringSetFromList( *deleted_presets_list, load_result.deleted_presets[static_cast<size_t>(group)]); base::Value* blocked_domains_counters = rule_group_value.FindDictKey(kBlockedDomainsCountersKey); if (blocked_domains_counters) LoadCounters( *blocked_domains_counters, load_result.blocked_domains_counters[static_cast<size_t>(group)]); base::Value* blocked_for_origin_counters = rule_group_value.FindDictKey(kBlockedForOriginCountersKey); if (blocked_for_origin_counters) LoadCounters( *blocked_for_origin_counters, load_result.blocked_for_origin_counters[static_cast<size_t>(group)]); } RuleServiceStorage::LoadResult DoLoad(const base::FilePath& path) { RuleServiceStorage::LoadResult load_result; JSONFileValueDeserializer serializer(path); std::unique_ptr<base::Value> root(serializer.Deserialize(nullptr, nullptr)); if (root.get() && root->is_dict()) { base::Value* tracking_rules = root->FindDictKey(kTrackingRulesKey); if (tracking_rules) { LoadRulesGroup(RuleGroup::kTrackingRules, *tracking_rules, load_result); } base::Value* ad_blocking_rules = root->FindDictKey(kAdBlockingRulesKey); if (ad_blocking_rules) { LoadRulesGroup(RuleGroup::kAdBlockingRules, *ad_blocking_rules, load_result); } absl::optional<base::Time> blocked_reporting_start = base::ValueToTime(root->FindKey(kBlockedReportingStartKey)); if (blocked_reporting_start) load_result.blocked_reporting_start = *blocked_reporting_start; absl::optional<int> version = root->FindIntKey(kVersionKey); if (version) load_result.storage_version = std::max(0, std::min(kCurrentStorageVersion, version.value())); } return load_result; } base::Value SerializeCounters(const std::map<std::string, int>& counters) { base::Value::Dict buffer; for (const auto& counter : counters) { buffer.Set(counter.first, counter.second); } return base::Value(std::move(buffer)); } base::Value::List SerializeSourcesList( const std::map<uint32_t, RuleSource>& rule_sources) { base::Value::List sources_list; for (const auto& map_entry : rule_sources) { const RuleSource& rule_source = map_entry.second; base::Value::Dict source_dict; if (rule_source.is_from_url) source_dict.Set(kSourceUrlKey, rule_source.source_url.spec()); else source_dict.Set(kSourceFileKey, rule_source.source_file.AsUTF8Unsafe()); source_dict.Set(kGroupKey, static_cast<int>(rule_source.group)); source_dict.Set(kAllowAbpSnippets, rule_source.allow_abp_snippets); source_dict.Set(kRulesListChecksumKey, rule_source.rules_list_checksum); source_dict.Set(kLastUpdateKey, base::TimeToValue(rule_source.last_update)); source_dict.Set(kNextFetchKey, base::TimeToValue(rule_source.next_fetch)); source_dict.Set(kValidRulesCountKey, rule_source.rules_info.valid_rules); source_dict.Set(kUnsupportedRulesCountKey, rule_source.rules_info.unsupported_rules); source_dict.Set(kInvalidRulesCountKey, rule_source.rules_info.invalid_rules); source_dict.Set(kLastFetchResultKey, static_cast<int>(rule_source.last_fetch_result)); source_dict.Set(kHasTrackerInfosKey, rule_source.has_tracker_infos); source_dict.Set(kTitleKey, rule_source.unsafe_adblock_metadata.title); source_dict.Set(kHomePageKey, rule_source.unsafe_adblock_metadata.homepage.spec()); source_dict.Set(kLicenseKey, rule_source.unsafe_adblock_metadata.license.spec()); source_dict.Set(kRedirectKey, rule_source.unsafe_adblock_metadata.redirect.spec()); source_dict.Set( kVersionKey, base::Int64ToValue(rule_source.unsafe_adblock_metadata.version)); source_dict.Set( kExpiresKey, base::TimeDeltaToValue(rule_source.unsafe_adblock_metadata.expires)); sources_list.Append(std::move(source_dict)); } return sources_list; } base::Value SerializeStringSetToList(const std::set<std::string>& string_set) { base::Value list(base::Value::Type::LIST); for (const auto& item : string_set) { list.Append(item); } return list; } base::Value::List SerializeKnownSourcesList( const KnownRuleSources& rule_sources) { base::Value::List sources_list; for (const auto& map_entry : rule_sources) { const KnownRuleSource& rule_source = map_entry.second; if (!rule_source.removable) continue; base::Value::Dict source; if (rule_source.is_from_url) source.Set(kSourceUrlKey, rule_source.source_url.spec()); else source.Set(kSourceFileKey, rule_source.source_file.AsUTF8Unsafe()); source.Set(kGroupKey, static_cast<int>(rule_source.group)); source.Set(kAllowAbpSnippets, rule_source.allow_abp_snippets); if (!rule_source.preset_id.empty()) source.Set(kPresetIdKey, rule_source.preset_id); sources_list.Append(std::move(source)); } return sources_list; } base::Value::Dict SerializeRuleGroup(RuleService* service, RuleGroup group) { base::Value::Dict rule_group; rule_group.Set(kExceptionsTypeKey, service->GetRuleManager()->GetActiveExceptionList(group)); rule_group.Set(kProcessListKey, SerializeStringSetToList( service->GetRuleManager()->GetExceptions( group, RuleManager::kProcessList))); rule_group.Set(kExemptListKey, SerializeStringSetToList( service->GetRuleManager()->GetExceptions( group, RuleManager::kExemptList))); rule_group.Set(kEnabledKey, service->IsRuleGroupEnabled(group)); rule_group.Set( kRuleSourcesKey, SerializeSourcesList(service->GetRuleManager()->GetRuleSources(group))); rule_group.Set(kKnownSourcesKey, SerializeKnownSourcesList( service->GetKnownSourcesHandler()->GetSources(group))); rule_group.Set( kDeletedPresetsKey, SerializeStringSetToList( service->GetKnownSourcesHandler()->GetDeletedPresets(group))); rule_group.Set(kIndexChecksum, service->GetRulesIndexChecksum(group)); rule_group.Set( kBlockedDomainsCountersKey, SerializeCounters(service->GetBlockerUrlsReporter() ->GetBlockedDomains()[static_cast<size_t>(group)])); rule_group.Set(kBlockedForOriginCountersKey, SerializeCounters( service->GetBlockerUrlsReporter() ->GetBlockedForOrigin()[static_cast<size_t>(group)])); return rule_group; } } // namespace RuleServiceStorage::LoadResult::LoadResult() = default; RuleServiceStorage::LoadResult::~LoadResult() = default; RuleServiceStorage::LoadResult::LoadResult(LoadResult&& load_result) = default; RuleServiceStorage::LoadResult& RuleServiceStorage::LoadResult::operator=( LoadResult&& load_result) = default; RuleServiceStorage::RuleServiceStorage( const base::FilePath& profile_path, RuleService* rule_service, scoped_refptr<base::SequencedTaskRunner> file_io_task_runner) : file_io_task_runner_(std::move(file_io_task_runner)), rule_service_(rule_service), writer_(profile_path.Append(kSourcesFileName), file_io_task_runner_, base::Seconds(kSaveDelay)), weak_factory_(this) { DCHECK(rule_service_); file_io_task_runner_->PostTask( FROM_HERE, base::BindOnce(&BackupCallback, writer_.path())); } RuleServiceStorage::~RuleServiceStorage() { if (writer_.HasPendingWrite()) writer_.DoScheduledWrite(); } void RuleServiceStorage::Load(LoadingDoneCallback loading_done_callback) { loading_done_callback_ = std::move(loading_done_callback); file_io_task_runner_->PostTaskAndReplyWithResult( FROM_HERE, base::BindOnce(&DoLoad, writer_.path()), base::BindOnce(&RuleServiceStorage::OnLoadFinished, weak_factory_.GetWeakPtr())); } void RuleServiceStorage::OnLoadFinished(LoadResult load_result) { std::move(loading_done_callback_).Run(std::move(load_result)); } void RuleServiceStorage::ScheduleSave() { writer_.ScheduleWrite(this); } void RuleServiceStorage::OnRuleServiceShutdown() { if (writer_.HasPendingWrite()) writer_.DoScheduledWrite(); } bool RuleServiceStorage::SerializeData(std::string* output) { base::Value::Dict root; root.Set(kTrackingRulesKey, SerializeRuleGroup(rule_service_, RuleGroup::kTrackingRules)); root.Set(kAdBlockingRulesKey, SerializeRuleGroup(rule_service_, RuleGroup::kAdBlockingRules)); root.Set(kBlockedReportingStartKey, base::TimeToValue( rule_service_->GetBlockerUrlsReporter()->GetReportingStart())); root.Set(kVersionKey, kCurrentStorageVersion); JSONStringValueSerializer serializer(output); serializer.set_pretty_print(true); return serializer.Serialize(root); } } // namespace adblock_filter
51c69ca6e10699875c9c61e8ac6cdef7e6c23c03
3dd2e3c133ac404ec041ba961cef1cd231ce8bc3
/RealtimeMasking/EasyBitmap.h
ca74964ad55c4031090226a2fcaed916bb7cad83
[ "MIT" ]
permissive
webrtcman/RealtimeMasking
f5cbe5a1b422a0586cf7c111ed4685b94a3fed4a
09c7e57209a47d760b5b7a4edae551cdee3411c4
refs/heads/main
2023-06-08T16:30:03.894862
2021-07-04T11:34:17
2021-07-04T11:34:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
585
h
EasyBitmap.h
#include "stdafx.h" #include <gdiplus.h> class EasyBitmap: public Gdiplus::Bitmap { public: EasyBitmap(int width, int height, int format); BOOL EasyLock(); void EasyUnlock(); BOOL EasyGetPixel(const int& x, const int& y, COLORREF& colorout); BOOL EasySetPixel(const int& x, const int& y, const COLORREF& colorin); BOOL EasyFill(const int& x, const int& y, const int& width, const int& height, const COLORREF& colorin); BOOL EasyErase(int x0, int y0, int width, int height); protected: std::auto_ptr<Gdiplus::BitmapData> pBitmapData; BOOL locked; };
0e5f793af86f9bc021cf17f1cd26d1cb7289bcf6
8f1ff728f3f2323bdf07223e57e9538f22c7e1d0
/text render/sort_app.cpp
4af8f5edb385886407c49cce2fc8d5b55e847243
[]
no_license
dizuo/xrender
aded8dd71d9bf3ead64a457647b4c93535fadee2
e067126d041307aef70c55f88acde81b8582ad00
refs/heads/master
2021-01-13T02:10:33.799223
2015-11-04T13:35:09
2015-11-04T13:35:09
7,849,218
3
0
null
null
null
null
GB18030
C++
false
false
2,176
cpp
sort_app.cpp
// peteryfren 2013/6/18 // 归并排序,函数指针 #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAX_SEED 50 void produceSeed(int*); void printSeed(int*); void transformSeeds(int* buffer, int length, void(*pfunc)(int*)); void mergeSort(int* buffer, int beg, int end); void merge(int* buffer, int beg, int mid, int end); int myStr2Int(char* str) { char* ptr = str; int retValue = 0; while (*ptr) { retValue = retValue*10 + (*ptr++ - '0'); } return retValue; } int uglyStr2Int(char* str) { char* ptr = str; int buffer[100]; int count = 0; while (*ptr) { buffer[count++] = *ptr++ - '0'; } --count; int factor = 1; int retValue = 0; while (count >= 0) { retValue = buffer[count--]*factor + retValue; factor *= 10; } return retValue; } int main() { srand((int)time(0)); int buffer[10]; /* transformSeeds(buffer, 10, produceSeed); transformSeeds(buffer, 10, printSeed); printf("\n"); mergeSort(buffer, 0, 9); transformSeeds(buffer, 10, printSeed); printf("\n");*/ char str[] = "123"; // printf("%d\n", myStr2Int(str)); printf("%d\n", uglyStr2Int(str)); getchar(); return 0; } void produceSeed(int* ptr) { *ptr = rand() % MAX_SEED; } void printSeed(int* ptr) { printf("%d ", *ptr); } void transformSeeds(int* buffer, int length, void(*pfunc)(int*)) { for (int idx=0; idx < length; idx++) { (*pfunc)(buffer+idx); } } // 分治 递归调用 // 递归结束条件 void mergeSort(int* buffer, int beg, int end) { if (beg < end) { int mid = ( (beg+end)>>1 ); mergeSort(buffer, beg, mid); mergeSort(buffer, mid+1, end); merge(buffer, beg, mid, end); } } // [beg1, end1], [beg2, end2] // [beg1, end2] void merge(int* buffer, int beg, int mid, int end) { // 临时数组 int tempBuffer[100]; int idx = 0; int idx1 = beg; int idx2 = mid+1; while (idx1 <= mid && idx2 <= end) { tempBuffer[idx++] = buffer[idx1] < buffer[idx2] ? buffer[idx1++] : buffer[idx2++]; } while (idx1 <= mid) { tempBuffer[idx++] = buffer[idx1++]; } while (idx2 <= end) { tempBuffer[idx++] = buffer[idx2++]; } idx1 = beg; while (idx1 <= end) { buffer[idx1++] = tempBuffer[idx1-beg]; } }
97f555350ca8ebbc5c190d84e4bea2fea3376f6e
6c190188c80a2e65a33db8d033aff3e27b60aa7f
/Assembly line 2/Untitled1.cpp
60542faf70afb7596e63c27aa73f059a5465d97c
[]
no_license
NasimulNabil/Algorithms
ed8cbc5c876b747aba31df70abf6bacec5e27917
0efdb69e57307e1f62a82ccbc6a54cf3a9d7a439
refs/heads/master
2020-09-15T11:32:56.505251
2019-11-22T15:33:54
2019-11-22T15:33:54
223,432,793
0
0
null
null
null
null
UTF-8
C++
false
false
1,234
cpp
Untitled1.cpp
#include<bits/stdc++.h> #define COL 5 int min(int a,int b) { if(a<b) { return a; } else { return b; } //return (a<b)? a:b; } int assembly(int a[][COL],int t[][COL],int e[],int x[]) { int T1[COL],T2[COL],i; T1[0]=e[0]+a[0][0]; T2[0]=e[1]+a[1][0]; for(i=1;i<COL;i++) { T1[i]=min(T1[i-1]+a[0][i],T2[i-1]+t[1][i]+a[0][i]); T2[i]=min(T2[i-1]+a[1][i],T1[i-1]+t[0][i]+a[1][i]); } return min(T1[COL-1]+x[0],T2[COL-1]+x[1]); } int main() { int a[10][COL],row,i,j,n; int t[10][COL]; int e[100],x[100]; printf("Row:"); scanf("%d",&row); printf("Number of entry and out cost:"); scanf("%d",&n); printf("Activity cost:"); for(i=0;i<row;i++) { for(j=0;j<COL;j++) { scanf("%d",&a[i][j]); } } printf("Transition cost:"); for(i=0;i<row;i++) { for(j=0;j<COL;j++) { scanf("%d",&t[i][j]); } } printf("Entry cost:"); for(i=0;i<n;i++) { scanf("%d",&e[i]); } printf("Out cost:"); for(i=0;i<n;i++) { scanf("%d",&x[i]); } printf("Minimum cost:%d",assembly(a,t,e,x)); return 0; }
f269a397cce71200076f128f70ff44a5c0ff0663
ab5650c5b95d312eec138dab34d17ecc443b21d0
/src/iptcpport.cpp
81418e7a537eb6977bb01db38337c2672b0479fe
[]
no_license
vehar/la10cee
b3fa956ef6ed9e440a17d29be2ec9ed189340e69
6a165833a245ff0479f3750557b191ca86fb8c7a
refs/heads/master
2023-03-17T15:23:12.112901
2015-02-18T16:00:58
2015-02-18T16:00:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
580
cpp
iptcpport.cpp
#include "iptcpport.h" const int IPTCPPort::operator<(const IPTCPPort& rhs) const { bool ipAEquals = (ipA() == rhs.ipA()); bool ipBEquals = (ipB() == rhs.ipB()); bool portAEquals = (portA() == rhs.portA()); bool portBEquals = (portB() == rhs.portB()); if(ipAEquals && ipBEquals && portAEquals && portBEquals) { return 0; } else if(ipAEquals && ipBEquals && portAEquals) { return portB() < rhs.portB(); } else if(ipAEquals && ipBEquals) { return portA() < rhs.portA(); } else if(ipAEquals) { return ipB() < rhs.ipB(); } else { return ipA() < rhs.ipA(); } }
230bbaa5dbcc0d0630b98bdd307be198844849d4
ee1423adcd4bfeb2703464996171d103542bad09
/dali-adaptor/dali-adaptor-c84ae21/adaptors/tizen/public-api/adaptor-framework/common/timer.cpp
5ca256f374cbe7c290375c8717213526959d37df
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-flora-1.1" ]
permissive
sak0909/Dali
26ac61a521ab1de26a7156c51afd3cc839cb705a
0b383fc316b8b57afcf9a9e8bac6e24a4ba36e49
refs/heads/master
2020-12-30T12:10:51.930311
2017-05-16T21:56:24
2017-05-16T21:57:14
91,505,804
0
1
null
null
null
null
UTF-8
C++
false
false
1,955
cpp
timer.cpp
// // Copyright (c) 2014 Samsung Electronics Co., Ltd. // // Licensed under the Flora License, Version 1.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://floralicense.org/license/ // // 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. // // CLASS HEADER #include <dali/public-api/adaptor-framework/common/timer.h> // EXTERNAL INCLUDES #include <dali/public-api/common/dali-common.h> // INTERNAL INCLUDES #include <internal/common/timer-impl.h> namespace Dali { Timer::Timer() { } Timer Timer::New( unsigned int milliSec ) { Internal::Adaptor::TimerPtr internal = Internal::Adaptor::Timer::New( milliSec ); return Timer(internal.Get()); } Timer::Timer( const Timer& timer ) : BaseHandle(timer) { } Timer& Timer::operator=( const Timer& timer ) { // check self assignment if( *this != timer ) { BaseHandle::operator=(timer); } return *this; } Timer::~Timer() { } void Timer::Start() { Internal::Adaptor::GetImplementation(*this).Start(); } void Timer::Stop() { Internal::Adaptor::GetImplementation(*this).Stop(); } void Timer::SetInterval( unsigned int interval ) { Internal::Adaptor::GetImplementation(*this).SetInterval( interval ); } unsigned int Timer::GetInterval() const { return Internal::Adaptor::GetImplementation(*this).GetInterval(); } bool Timer::IsRunning() const { return Internal::Adaptor::GetImplementation(*this).IsRunning(); } Timer::TimerSignalV2& Timer::TickSignal() { return Internal::Adaptor::GetImplementation(*this).TickSignal(); } Timer::Timer(Internal::Adaptor::Timer* timer) : BaseHandle(timer) { } } // namespace Dali
e16dc4f06f41e221db6d73f0f26576d424d71b1b
39adfee7b03a59c40f0b2cca7a3b5d2381936207
/codeforces/100923/F.cpp
75450ee67703d0f0def9dd2b6a6a09905f4bf3a2
[]
no_license
ngthanhtrung23/CompetitiveProgramming
c4dee269c320c972482d5f56d3808a43356821ca
642346c18569df76024bfb0678142e513d48d514
refs/heads/master
2023-07-06T05:46:25.038205
2023-06-24T14:18:48
2023-06-24T14:18:48
179,512,787
78
22
null
null
null
null
UTF-8
C++
false
false
2,622
cpp
F.cpp
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; ++i) #define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; --i) #define REP(i,a) for(int i=0,_a=(a); i < _a; ++i) #define DEBUG(X) { cout << #X << " = " << (X) << endl; } #define PR(A,n) { cout << #A << " = "; FOR(_,1,n) cout << A[_] << ' '; cout << endl; } #define PR0(A,n) { cout << #A << " = "; REP(_,n) cout << A[_] << ' '; cout << endl; } #define sqr(x) ((x) * (x)) #define ll long long #define __builtin_popcount __builtin_popcountll #define SZ(x) ((int) (x).size()) using namespace std; const int MN = 300111; const int INF = 1e9; vector< pair<int,int> > it[1100111], all; int n; void build(int i, int l, int r) { it[i].push_back(make_pair(INF, INF)); if (l == r) return ; int mid = (l + r) >> 1; build(i<<1, l, mid); build(i<<1|1, mid+1, r); } void update(int i, int l, int r, int u, int v, int val) { if (v < l || r < u) return ; if (u <= l && r <= v) { it[i].push_back(make_pair(val, min(val, it[i].back().second))); return ; } int mid = (l + r) >> 1; update(i<<1, l, mid, u, v, val); update(i<<1|1, mid+1, r, u, v, val); } void rem(int i, int l, int r, int u, int v) { if (v < l || r < u) return ; if (u <= l && r <= v) { it[i].pop_back(); return ; } int mid = (l + r) >> 1; rem(i<<1, l, mid, u, v); rem(i<<1|1, mid+1, r, u, v); } int get(int i, int l, int r, int u) { if (l == r) return it[i].back().second; int res = it[i].back().second; int mid = (l + r) >> 1; if (u <= mid) res = min(res, get(i<<1, l, mid, u)); else res = min(res, get(i<<1|1, mid+1, r, u)); return res; } int main() { ios :: sync_with_stdio(0); cin.tie(0); cout << (fixed) << setprecision(9); freopen("invazia.in", "r", stdin); freopen("invazia.out", "w", stdout); int q; scanf("%d%d", &n, &q); build(1, 1, n); while (q--) { char c = ' '; while (c < 'A' || c > 'Z') scanf("%c", &c); if (c == 'I') { int u, v, val; scanf("%d%d%d", &u, &v, &val); update(1, 1, n, u, v, val); all.push_back(make_pair(u, v)); } else if (c == 'R') { int u; scanf("%d", &u); int t = get(1, 1, n, u); if (t == INF) puts("GUITZZZ!"); else printf("%d\n", get(1, 1, n, u)); } else { rem(1, 1, n, all.back().first, all.back().second); all.pop_back(); } } }
6b2d1a297f2a181a87f176d775ab0fac529ed83c
bfde4011af07835e900aa6ea43b6bd39df0ec122
/Castlevania/Flame.cpp
7173ca4946d9c47424a545bd38c161985f5a5b92
[]
no_license
giaphat12/Castlevania
85e85c7f3c07574128ecf1879e1cd4535285404f
abb8076cb45d02c6c48f5df54d2dbea2f4783d05
refs/heads/main
2022-12-31T19:41:06.332085
2020-10-26T02:24:42
2020-10-26T02:24:42
307,237,735
0
0
null
null
null
null
UTF-8
C++
false
false
228
cpp
Flame.cpp
#include "Flame.h" void Flame::Render() { if (isDestroy) { return; } animations[0]->Render(0, x, y); } void Flame::Update(DWORD dt, Scene* scene, vector<LPGAMEOBJECT>* coObject) { Effect::Update(dt, scene, coObject); }
328af4ddb18234ac56b13a5e96d7727c466908b8
7cd98c72046c66558b747ec4820dfdcc1ea14c7e
/src/messages/messageInterface.h
8c686a69c6f7ef1818b27a2721163a4c7384cce3
[]
no_license
zeegleho/livenasal
0970ad975b53deea70bc9d403071e0c7258508f8
3389ef0428ca5f682bd2e86eab25f4e219e934eb
refs/heads/master
2020-04-20T21:52:39.501039
2016-01-08T06:22:31
2016-01-08T06:24:35
38,202,301
0
0
null
null
null
null
UTF-8
C++
false
false
991
h
messageInterface.h
/* * Copyright (c) 2015, zeegle.ho@gmail.com, He Zhigang, Beijing * All rights reserved. * LiveNasal, a simulator of nasal, created by zeegle.ho/he zhigang. */ #ifndef MESSAGEINTERFACE_H #define MESSAGEINTERFACE_H #include "messageSeverityType.h" #include "messageDef.h" #include "messages.h" class MessageInterface { public: MessageInterface(); static void setMsgInterface( MessageInterface *msgInterface_ ); static MessageInterface * getMsgInterface(); void printLog( char* str ); void printLog( int i ); void print( char* fmt, ... ); void print( message_id_type msg_id, ... ); void print( MessageDef* msg, ... ); void printMsg( char* str, ... ); static NSIdent* getStage(); static void setStage(NSIdent* ); static void initProcInfo(); static void caculateProcInfo(); static void showProcInfo(pid_t p); private: static MessageInterface *msgInterface_; static NSIdent* stage_; }; #endif //MESSAGEINTERFACE_H
59fa198d360a62661a13ac8282046bd5b15ad598
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/xgboost/xgboost-gumtree/dmlc_xgboost_old_hunk_734.cpp
6f1d649618faf1cad9f1ddec27034af2c4d40725
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
566
cpp
dmlc_xgboost_old_hunk_734.cpp
// linear boost automatically set do reboost if (booster_type == 1) do_reboost = 1; } if (!strcmp("num_pbuffer", name)) num_pbuffer = atoi(val); if (!strcmp("do_reboost", name)) do_reboost = atoi(val); if (!strcmp("bst:num_roots", name)) num_roots = atoi(val); if (!strcmp("bst:num_feature", name)) num_feature = atoi(val); } }; /*! \brief training parameters */
db3725f75462c65e062a9108148465c8c0a6da04
90846161ccce5a881dff1762b733c26f5d32db26
/main.cpp
7a4f14ac890a6a338d6df11e462c90ec40a1fd09
[]
no_license
ecepanagiotisntua/polynomial
40c54ac16cc1a1f4aa920431e50067ad1bce98b1
3970f5ad423c869bd0002c376f1e93a6dddebe09
refs/heads/master
2022-04-23T18:23:51.766273
2020-04-30T10:47:05
2020-04-30T10:47:05
258,971,004
0
0
null
null
null
null
UTF-8
C++
false
false
2,726
cpp
main.cpp
#include <iostream> #include <cmath> using namespace std; class Polynomial { protected: class Term { int exponent; int coefficient; Term *next; Term(int exp, int coeff, Term *n): exponent(exp), coefficient(coeff), next(n) {} ~Term() { delete next; } friend class Polynomial; friend ostream; }; int size; Term *first; public: Polynomial(){ first=nullptr; first->next=nullptr; } Polynomial(const Polynomial &p){ Term *q = p.first; first = nullptr; while (q != nullptr) { this->addTerm(q->exponent, q->coefficient); q = q->next; } } ~Polynomial(){ delete first; } Polynomial & operator = (const Polynomial &p) { delete first; Term *q = p.first; first = nullptr; while (q != nullptr) { this->addTerm(q->exponent, q->coefficient); q = q->next; } return *this; } void addTerm(int expon, int coeff){ Term *p = new Term(expon, coeff, nullptr); if (first->next != nullptr) first->next = p; else first = p; } double evaluate(double x){ double result = 0; for ( Term *p = first; p != nullptr; p = p-> next){ double part = (p->coefficient) * pow(x , p->exponent); result = result + part; } return result; } friend Polynomial operator+ (const Polynomial &p, const Polynomial &q){ Polynomial c; Term *a = p.first, *b = q.first; if (a == nullptr && b == nullptr) return c; if (a == nullptr){ return q; } if (b == nullptr){ return p; } do{ if (a->exponent == b->exponent){ c.addTerm(a->exponent, (a->coefficient)+(b->coefficient)); a = a->next; b = b->next; }else if(a->exponent > b->exponent){ c.addTerm(a->exponent, a->coefficient); a = a->next; }else { c.addTerm(b->exponent, b->coefficient); b = b->next; } }while(a!=nullptr && b!=nullptr) return c; } friend Polynomial operator* (const Polynomial &p, const Polynomial &q){ Polynomial poly; Term *a = p.first; Term *b = q.first; while (a != nullptr) { while (b != nullptr) { poly.addTerm(a->exponent + b->exponent, a->coefficient * b->coefficient); b = b->next; } b = q.first; a = a->next; } return poly; } friend ostream & operator << (ostream &out, const Polynomial &p){ Term *a ; if (a->coefficient > 0){ out<< a->coefficient<<"x^"<<a->exponent<<" "; a =a->next; } if (a->coefficient < 0) { out<<"- "<<a->coefficient<<"x^"<<a->exponent<<" "; a =a->next; } for(a = p.first; a!=nullptr; a=a->next){ if (a->coefficient == 0) continue; if (a->coefficient > 0) out << " "<<a->coefficient << "x^" <<a->exponent<< " "; if (a->coefficient < 0) out << " - "<<a->coefficient<<"x^"<<a->exponent<<" "; } return out; } };
8c9642af8113d9e9bdea95b4d5e7e37094c096eb
a1595e54ca38f03adec6c1e288baff269d409ec9
/Bit Manipulation/subsets.cpp
348d145579522f24743aee15f0846a5dad3c4f21
[]
no_license
biswa1612/Data-Structure-And-Algorithm
4bbe400ef262e0afc92e2fcb795727dc1dc82d85
afbef87036497da13be11765dafacf16aef25fc7
refs/heads/master
2023-07-06T16:14:37.124474
2021-08-15T20:54:13
2021-08-15T20:54:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
458
cpp
subsets.cpp
#include<bits/stdc++.h> using namespace std; void subsets(int arr[], int n){ for(int i=0;i<(1<<n);i++){ //2 to the power n is equal to 1<<n....for 2 to the power 2 =4 ....1<<2 = 0100 for(int j=0;j<n;j++){ if(i & (1<<j)){ cout<<arr[j]<<" "; } }cout<<endl; } } int main(){ int n; cin>>n; int arr[n]; for(int i=0;i<n;i++){ cin>>arr[i]; } subsets(arr, n); }
8e5f7587688927f180444acf065eb096daa391c1
5b3bf81b22f4eb78a1d9e801b2d1d6a48509a236
/codeforces/round_526/kvass2.cc
0ea0dcdad3396e3d162b5243862479ccfe6f3e19
[]
no_license
okoks9011/problem_solving
42a0843cfdf58846090dff1a2762b6e02362d068
e86d86bb5e3856fcaaa5e20fe19194871d3981ca
refs/heads/master
2023-01-21T19:06:14.143000
2023-01-08T17:45:16
2023-01-08T17:45:16
141,427,667
1
1
null
null
null
null
UTF-8
C++
false
false
572
cc
kvass2.cc
#include <iostream> #include <vector> #include <algorithm> #include <cstdlib> using std::cout; using std::endl; using std::cin; using std::vector; using std::min_element; using std::min; int main() { int n; long long s; cin >> n >> s; vector<int> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; long long sum = 0; for (auto& vi : v) sum += vi; if (s > sum) { cout << "-1" << endl; return 0; } long long min_v = *min_element(v.begin(), v.end()); cout << min((sum-s) / n, min_v) << endl; }
b775763af0f11c7398e669a874eea58bb061829b
1fddc0f5ebe01106ebe718ad1dc2475dbdcfc47e
/SPOJ/P172PROH - ROUND 2H.cpp
b79f34d92cf4f0a4186bf948795bc111ad702940
[]
no_license
not-a-wjbu-war/Source-Code
15e253334c0a7a81a8218ef14f0a4d6d14005984
3eec0a26e665ebda5c6cbf0dc178100076d00a64
refs/heads/master
2023-06-01T11:12:29.844593
2021-06-14T17:44:51
2021-06-14T17:44:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,060
cpp
P172PROH - ROUND 2H.cpp
// // Code By CodeWar :3 #include <bits/stdc++.h> #define pb push_back; typedef long long i64; const int mod = 1e9+7; using namespace std; string s; void input(){ cin >> s; } void solve(){ int cnt = 0; for(int i = 0 ; i < s.length() ;i++){ if(s[i] == 'c' && (s[i + 1] == '=' || s[i+1] == '-')){ cnt++; i += 2; } else if (s[i] == 'd' && s[i+1] == 'z' && s[i+2] == '='){ cnt+=2; i += 3; } else if(s[i] == 'd' && s[i+1] == '-'){ cnt++; i += 2; } else if((s[i] == 'l' || s[i] == 'n' )&& s[i+1] == 'j'){ cnt+=2; i += 2; } else if((s[i] == 's' || s[i] == 'z') && s[i+1] == '='){ cnt++; i += 2; } else{ cnt++; } } cout << cnt ; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while(t--){ input();solve(); } return 0; } // Code By CodeWar :3
8e199b5ebbf0ae0a80220bb55f96a82a35f9149d
37639d9fb2e1c3c06f51dc749ea16e9d75b40538
/Hache.hpp
60e97b2671f3fc55c91b267a1d39450eb9144d3d
[]
no_license
vgiauffret/BasicRPG_VG
d06ed8f741902330093c49e404a58ac0199ec95d
18e5dcd779fd8bd4bdc824d09a3315d2fbcdbce7
refs/heads/master
2021-05-20T10:49:54.414812
2020-04-03T12:51:57
2020-04-03T12:51:57
252,258,063
0
0
null
null
null
null
UTF-8
C++
false
false
559
hpp
Hache.hpp
#ifndef __HACHE_HPP #define __HACHE_HPP // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// // STL #include <string> #include <Weapon.hpp> class Hache: public Weapon { protected: public: Hache (); Hache (const std::string& iName,const std::string& iType, const int& iFreq); virtual ~Hache(); void coup(); void lancer(); void supercoup(); private: }; #endif // __HACHE_HPP