blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
1e5fac0fe7d6c7bb05b5e0cb898eec0bd1a30bbc
f656a43ce5715d2f759df9e7e22341af5d08f446
/Motor3D/ModuleEditor.cpp
37e7d37ab49b75a9d751a61ec4cafe9195afd658
[ "MIT" ]
permissive
AleixBueso/EngineProject
3cc1100917760d137a8f4ea4ea9c6473ce006d6d
6742b31c9b64893f9bd6cb33e0acba394066b553
refs/heads/master
2021-01-10T22:49:55.430142
2016-12-05T12:57:29
2016-12-05T12:57:29
70,346,158
0
0
null
null
null
null
UTF-8
C++
false
false
5,463
cpp
#include "Globals.h" #include "Application.h" #include "ModuleEditor.h" #include "Imgui\imgui.h" #include "Glew\include\glew.h" #include "GameObject Manager.h" #include "glut\glut.h" #include "ComponentTransform.h" ModuleEditor::ModuleEditor(Application* app, bool start_enabled) : Module(app, start_enabled) {}; ModuleEditor::~ModuleEditor() { }; bool ModuleEditor::Start() { LOG("Loading Editor"); bool ret = true; //Set Camera Position App->camera->Move(vec(10.0f, 6.0f, 30.0f)); App->camera->LookAt(vec(0, 0, 0)); ShowTestWindow = false; SelectedObject = App->gameobject_manager->root; return ret; }; bool ModuleEditor::CleanUp() { LOG("Unloading Editor"); return true; }; update_status ModuleEditor::Update(float dt) { //Create World Plane_P grid(0, 1, 0, 0); grid.axis = true; grid.Render(); //Create the menu bar if (ImGui::BeginMainMenuBar()) { if (ImGui::BeginMenu("Tools")) { if (ImGui::MenuItem("GameObjects Editor")) { ShowGameObjects = !ShowGameObjects; } ImGui::EndMenu(); } //View if (ImGui::BeginMenu("View")) { if (ImGui::Checkbox("Test Window", &ShowTestWindow)); if (ImGui::Checkbox("Textures", &App->model_loader->texture_enabled)); ImGui::EndMenu(); } //Help if (ImGui::BeginMenu("Help")) { if (ImGui::MenuItem("Documentation")) App->RequestBrowser("https://github.com/AleixBueso/Motor3D/wiki"); if (ImGui::MenuItem("Download Latest")) App->RequestBrowser("https://github.com/AleixBueso/Motor3D/releases"); if (ImGui::MenuItem("Report a Bug")) App->RequestBrowser("https://github.com/AleixBueso/Motor3D/issues"); if (ImGui::MenuItem("About")) AboutWindow = !AboutWindow; ImGui::EndMenu(); } //Quit if (ImGui::MenuItem("Quit")) return UPDATE_STOP; ImGui::EndMainMenuBar(); } //TestWindow if (ShowTestWindow) ImGui::ShowTestWindow(); //AboutWindow if (AboutWindow) { ImGui::Begin("About"); ImGui::Text("3D Engine"); ImGui::Text("Engine for Motors UPC"); if (ImGui::BeginMenu("Libraries:")) { ImGui::Text("ImGui"); ImGui::Text("Open GL3"); ImGui::Text("MathGeolab"); ImGui::Text("Bullet"); ImGui::Text("SDL"); ImGui::Text("Glew"); ImGui::EndMenu(); } ImGui::MenuItem("License"); ImGui::End(); } //Outliner if (ShowGameObjects) { CreateHierarchy(); } AttributeEditor(); return UPDATE_CONTINUE; }; void ModuleEditor::AttributeEditor() { ImGuiTreeNodeFlags attribute_editor_flags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize; ImGui::Begin("Attribute Editor", 0, attribute_editor_flags); ImGui::SetWindowSize(ImVec2(390, 600)); ImGui::SetWindowPos(ImVec2(1000, 25)); if (SelectedObject == NULL) ImGui::Text("No GameObject Selected."); else { // Change the name //char* new_name = new char[20]; //strcpy(new_name, SelectedObject->name.data()); ImGui::Text("Name: "); ImGui::SameLine(); ImGui::Text(SelectedObject->name.data()); //SelectedObject->name = new_name; //Transformation if (SelectedObject->transform != nullptr) { if (ImGui::CollapsingHeader("Transformation")); SelectedObject->transform->ComponentEditor(); } // Material if (SelectedObject->material != nullptr) { if (ImGui::CollapsingHeader("Material")); SelectedObject->material->ComponentEditor(); } //Mesh if (SelectedObject->mesh != nullptr) { if (ImGui::CollapsingHeader("Mesh")); SelectedObject->mesh->ComponentEditor(); } //Mesh if (SelectedObject->camera != nullptr) { if (ImGui::CollapsingHeader("Camera")); SelectedObject->camera->ComponentEditor(); } } ImGui::End(); } void ModuleEditor::ShowChilds(GameObject* parent) { if (parent->childs.empty() == false) { list<GameObject*>::const_iterator it = parent->childs.begin(); while (it != parent->childs.end()) { if ((*it) == SelectedObject) { ImGuiTreeNodeFlags_Framed; } if ((*it)->childs.size() > 0) { if (ImGui::TreeNodeEx((*it)->name.data(), ImGuiTreeNodeFlags_Framed)) { if (ImGui::IsItemClicked()) { SelectedObject = (*it); } ShowChilds(*it); ImGui::TreePop(); } } else { if (ImGui::TreeNodeEx((*it)->name.data(), ImGuiTreeNodeFlags_Leaf)) { if (ImGui::IsItemClicked()) { SelectedObject = (*it); } ImGui::TreePop(); } } ++it; } } } void ModuleEditor::CreateHierarchy() { ImGuiTreeNodeFlags outliner_flags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize; ImGui::Begin("Outliner", 0, outliner_flags); ImGui::Text("Click the Button to create an empty GameObject"); if (ImGui::Button("CreateGameObject")) App->gameobject_manager->CreateGameObject(SelectedObject); if (ImGui::Checkbox("Show QuadTree", &App->gameobject_manager->show_quadtree)); ImGui::Text("Tree: ----------------------------"); if (App->gameobject_manager->root == NULL) ImGui::Text("No GameObjects on the Scene."); else { if (ImGui::TreeNodeEx(App->gameobject_manager->root->name.data(), ImGuiTreeNodeFlags_Framed)) { if (App->gameobject_manager->root == SelectedObject) { ImGuiTreeNodeFlags_Framed; } if (ImGui::IsItemClicked()) { SelectedObject = (App->gameobject_manager->root); } if(App->gameobject_manager->root->childs.empty() == false) ShowChilds(App->gameobject_manager->root); ImGui::TreePop(); } } ImGui::End(); }
e6635eb0aa4dec7c54d83e51855a1d41960612b9
b298daecf7f0cedadbc0c70e670b0e17450dc2ba
/by_month/01-styczen/sty29.cpp
d67fd83258a26bd40670627a84dee0ac6eb32f15
[]
no_license
lewicki-pk/one_program_a_day
4e8f101ce8a10c77d67d38408120548e1224d0e1
7153cb27d8297d3f0cf68f7b1e20e40af26d6b2d
refs/heads/master
2021-01-09T20:53:35.790369
2016-08-03T19:51:24
2016-08-03T19:51:24
56,932,771
0
0
null
null
null
null
UTF-8
C++
false
false
885
cpp
/* * main.cpp * * Created on: Jan 29, 2016 * Author: lewiatan */ #include <algorithm> #include <vector> #include <iostream> using namespace std; int main() { vector<int> vecNums; vecNums.push_back(25); vecNums.push_back(101); vecNums.push_back(-10); vecNums.push_back(200); auto iEvenNum = find_if( vecNums.cbegin(), vecNums.cend(), [](const int& Num){return ((Num % 2) == 0);}); if (iEvenNum != vecNums.end()) cout << "First even number in collection is :" << *iEvenNum << endl; auto iEvenNum2 = find_if( ++iEvenNum, vecNums.cend(), [](const int& Num){return ((Num % 2) == 0);}); if (iEvenNum2 != vecNums.end()) cout << "First even number in collection is :" << *iEvenNum2 << endl; return 0; }
472a1d0727473eb816a40ae408214f3c691d6510
80e7cc5ede55c2eec705b3960738843f95cd747a
/impeller/aiks/color_source_factory.cc
d2f77c9ef479734ad66e2e1b6dab585a453e81ae
[ "BSD-3-Clause" ]
permissive
schwa423/engine
45206efe746600d8f33e031e28d363fd4d69d3a9
223e1f092dd5ba2cc5b985d577fbad1edcb4b18c
refs/heads/master
2022-11-27T14:15:15.023417
2022-11-16T12:40:33
2022-11-16T12:40:33
46,335,778
0
0
null
2015-11-17T09:12:55
2015-11-17T09:12:54
null
UTF-8
C++
false
false
315
cc
// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "impeller/aiks/color_source_factory.h" namespace impeller { ColorSourceFactory::~ColorSourceFactory() = default; } // namespace impeller
210b61007760440db5f82ca4b04a468a9f8f4f87
5a2e7e0dcb42bff11da8393bc1f87780a8959306
/tictactoe/tictactoe.cpp
a0bfbc911b9d761045381474191824db869742bc
[]
no_license
Grace-H/cplusplus
cb10a787a7a1b2b00e62006e4bbc5dd83e702f17
ac3ef4790303a2feface607581c973ed971f35ae
refs/heads/master
2020-03-27T18:19:34.741830
2019-01-16T16:54:05
2019-01-16T16:54:05
146,914,782
1
0
null
null
null
null
UTF-8
C++
false
false
5,174
cpp
/*TicTacToe game in command line for two players *Author: Grace Hunter *Date: 27 September 2018 */ #include <iostream> #include <cstring> #include <cctype> using namespace std; void printBoard(char** board); void clearBoard(char** board); char turn(char** board, int* move, char player); void getMove(int* move, char player); char checkWin(char** board); const char X = 'X'; const char O = 'O'; const char tie = 'T'; main(){ //pointer to array of pointers which holds board char** board; board = new char*[3]; for (int i = 0; i < 3; i++){ board[i] = new char[3]; } //pointer that points to array that holds where user wants to play int* move = new int[3]; //number of wins for each player int xWins = 0; int oWins = 0; int tieWins = 0; //while the player still want to play bool stillPlaying = true; while(stillPlaying){ //reset board clearBoard(board); bool won = false; char whoseTurn = X; char result = 'N'; //result of checkWin after a turn //while no one has one while(!won){ printBoard(board); //turn result = turn(board, move, whoseTurn); //evaluate result, break out of while if won and display message if(result == X){ printBoard(board); xWins++; won = true; cout << "Congratulations Player " << result << ", you win!" << endl; }else if(result == O){ printBoard(board); oWins++; won = true; cout << "Congratulations Player " << result << ", you win!" << endl; }else if(result == tie){ printBoard(board); tieWins++; won = true; cout << "It's a tie!" << endl; } //change whose turn if(whoseTurn == X){ whoseTurn = O; } else{ whoseTurn = X; } } //tell how many wins and ask to play again cout << "X wins: " << xWins << "\tO wins: " << oWins << "\tTies: " << tieWins << endl; cout << "Would you like to play again? 'y' or 'n'" << endl; char playAgain[256]; cin.get(playAgain, 256); cin.get(); if(playAgain[0] == 'n'){ stillPlaying = false; cout << "Thanks for playing. Goodbye." << endl; } } //delete pointers for(int i = 0; i < 3; i++){ delete[] board[i]; } delete[] board; delete[] move; return 0; } //print out the board like this: /* a b c *1 *2 *3 */ void printBoard(char** board){ cout << " a b c" << endl; for (int i = 0; i < 3; i++){ cout << i + 1 << " " << board[i][0] << " " << board [i][1] << " " << board[i][2] << endl; } } //fill board array with ' ' chars void clearBoard(char** board){ for (int i = 0; i < 3; i++){ for (int j = 0; j < 3; j++){ board[i][j] = ' '; } } } //get a user's move, place in board, and check if someone won char turn(char** board, int* move, char player){ //get move from player bool valid = false; cout << "Player " << player << ", enter a move: " << endl; while(!valid){ getMove(move, player); //check if that spot is blank if(isspace(board[move[0]][move[1]])){ board[move[0]][move[1]] = player; valid = true; } else { cout << "Someone has played there. Please try again:" << endl; } } //return the result of a check for wins return checkWin(board); } //get and evaluate a move from the player and store in move array void getMove(int* move, char player){ bool valid = true; char input[256]; do{ valid = true; //read in a move cin.get(input, 256); cin.get(); input[0] = toupper(input[0]); //check if character is valid if(input[0] == 'A'){ move[1] = 0; } else if(input[0] == 'B'){ move[1] = 1; } else if(input[0] == 'C'){ move[1] = 2; } else{ valid = false; } //check if number is valid if(input[1] == '1'){ move[0] = 0; } else if(input[1] == '2'){ move[0] = 1; } else if(input[1] == '3'){ move[0] = 2; } else{ valid = false; } //ask for another if not vaild if(valid == false){ cout << "Your input was not a valid place to play. Please try again: " << endl; } //run above loop until user enters a valid input } while(!valid); } //check rows, columns, diagonals for wins or ties char checkWin(char** board){ //check rows for(int i = 0; i < 3; i++){ if (board[i][0] == board[i][1] && board[i][1] == board[i][2] && board[i][0] != ' '){ return board[i][0]; } } //check columns for(int i = 0; i < 3; i++){ if(board[0][i] == board[1][i] && board[1][i] == board[2][i] && board[0][i] != ' '){ return board[0][i]; } } //check diagonals if(board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[0][0] != ' '){ return board[0][0]; } if(board[0][2] == board [1][1] && board[1][1] == board[2][0] && board[0][2] != ' '){ return board[0][2]; } //check ties bool isTie = true; for(int i = 0; i < 3; i++){ for(int j = 0; j < 3; j++){ if(isspace(board[i][j])){ isTie = false; } } } //return tie if tie was found if(isTie){ return tie; } //return an N if nothing was found else{ return 'N'; } }
57a6d6c37b927d4db8b55e4a2000d2a8aef19489
2727072679f44891d3340803b52b189e7dfb9f35
/codegen/QtDataVisualization/Q3DBarsSlots.h
222968bf3bb925b08cd4d1a9a97dc829b41a5392
[ "MIT" ]
permissive
MahmoudFayed/Qt5xHb
2a4b11df293986cfcd90df572ee24cf017593cd0
0b60965b06b3d91da665974f5b39edb34758bca7
refs/heads/master
2020-03-22T21:27:02.532270
2018-07-10T16:08:30
2018-07-10T16:08:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
765
h
%% %% Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5 %% %% Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com> %% $header $includes using namespace QtDataVisualization; $beginSlotsClass $signal=|multiSeriesUniformChanged( bool uniform ) $signal=|barThicknessChanged( float thicknessRatio ) $signal=|barSpacingChanged( const QSizeF & spacing ) $signal=|barSpacingRelativeChanged( bool relative ) $signal=|rowAxisChanged( QCategory3DAxis * axis ) $signal=|columnAxisChanged( QCategory3DAxis * axis ) $signal=|valueAxisChanged( QValue3DAxis * axis ) $signal=|primarySeriesChanged( QBar3DSeries * series ) $signal=|selectedSeriesChanged( QBar3DSeries * series ) $signal=|floorLevelChanged( float level ) $endSlotsClass
3814575ebc843bf90928252227a100c2a0220075
6225af0e286c6934c968f2f2d00d5a3365d81f87
/Ns3-Config/fate-cache-redirect2.cc
0c2900f08c1c6becfbe178d357f2badea7ffe52d
[]
no_license
jlmathew/Fate-Ns3
faab3fbb1c2f1ee3108f52bb8618946dc370cbd4
1f38e11067d0e34d19597e3b9b5c7fbda725ca14
refs/heads/master
2020-03-28T16:15:13.853320
2020-02-02T17:40:37
2020-02-02T17:40:37
148,674,637
0
0
null
null
null
null
UTF-8
C++
false
false
24,348
cc
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ns3/core-module.h" #include "ns3/network-module.h" #include "ns3/csma-module.h" #include "ns3/internet-module.h" #include "ns3/point-to-point-module.h" #include "ns3/applications-module.h" #include "ns3/ipv4-global-routing-helper.h" #include "ns3/GlobalModulesNs3.h" #include "ns3/IcnName.h" #include <iostream> #include <ostream> #include <string> #include "ns3/PacketTypeBase.h" #include "ns3/ipv4-address.h" #include "ns3/ipv4-header.h" #include "ns3/udp-header.h" #include "ns3/flow-monitor-module.h" #include "ns3/node.h" #include "ns3/topology-read-module.h" //#include "ns3/ipv4-nix-vector-helper.h" #include "ns3/ipv4-static-routing-helper.h" #include "ns3/global-fate.h" #include "ns3/random-variable-stream.h" #include "ns3/rng-seed-manager.h" #include <fstream> #include "ns3/NodeManager.h" #include "ns3/UtilityExternalModule.h" #include "ns3/UtilityConfigXml.h" #include "ns3/fateIpv4-interface.h" #include "ns3/fate-ipv4protocol.h" #include "ns3/fateipv4-helper.h" /* WHY and limiations This program creates 4 types of nodes. Producers: Producers produce file content. There are nFiles of unique content, and each file consists of nSegments. It is assumed (for now), that 1 files uniquely is produced by one producer. A producer CAN producer more than 1 file content, but there are no redundant sources for file creation (e.g. node 3 and 5 wont be producers for file n5, but node 3 can produce for files n5, n6). preconsumers are 1 hop from consumers (see below). consumers: consumers, due to a poor ns3 implementation, are not included in tx'ing a packet (tracing a packet shows the ns3 application transmits without going through 'the node'). In addition, we need an easy way to identify 1-hop cache node, and since the 'original consumer', due to the poor ns3-fate implementation, wont be able to return an interest packet, requires an extra hop of a consumer (where the preconsumer can cache). For calculations, subtract 1 from TTL or ignore last node name hop. nodes = all nodes, from the map, EXCEPT consumers (as they are added separately, and not part of the original map. ========================================================== Maps: 3 type of maps are supported (Inet, rocketfuel, orbis). rocketfuel is an actual map of an ISP. Inet and Orbis generate ISP-like random topologies. The generator for orbis does not work correctly, so the number of maps is limited. Inet map generation is working correctly. ================================================================== Inputs: input : name of the topology file format : format of the topology file reqRate - How many interest requests in seconds (converted to 1/reqRate) nProd - How many producers of unique content. If nProd >=1 it is the actual # of producers. If it is 0< nProd < 1, then it is the percentage of all nodes, which are producers. e.g. (.25) means 1/4 or 25% of all nodes are producers. nCons - How many consumers. If nCons >=1 it is the actual # of consumers. If it is 0< nCons < 1, then it is the percentage of all nodes, which are consumers. e.g. (.25) means 1/4 or 25% of all nodes are consumers. Inet papers suggest 23% is a good number. pTopo - How producers are selected in the topology. Either a 'Single' producer is choosen (and nProd is the Id of the node, e.g. if pTopo='Single' and nProd=5, then node 5 is the single producer; if 'Random' is choosen, then a node at random is choosen to be producer (with nProd nodes). pTopo - How consumers are selected in the topology. Either by 'Edge', where only those nodes with a single link are choosen (disregarding nCons), or 'Random', which will create nCons random nodes to be selected. nFiles - How many unique files are to be produced/requested in the network. For zipf, file1 is requested most often, and filen is requested least often. numSegments - How many segments per file. assume all files are same length. The purpose of having segments allows prefetching for future experiments, and stress the cache more. */ using namespace ns3; NS_LOG_COMPONENT_DEFINE ("FateExample"); UtilityExternalModule *mod; GlobalModuleTimerNs3 *timer; InternetStackHelper stack; NodeContainer* nc; NetDeviceContainer* ndc; NetDeviceContainer* ndconsumer; PointToPointHelper p2p; Ipv4InterfaceContainer* ipic; NodeContainer nodes; NodeContainer producers, preconsumers, consumers, cachingNodes, nonCachingNodes; uint32_t nFiles, nSeg, reqRate; double alpha; Ipv4AddressHelper address; Ipv4NixVectorHelper nixRouting; Ptr<TopologyReader> inFile ; Ptr<FlowMonitor> flowmon; AsciiTraceHelper ascii; FlowMonitorHelper flowmonHelper; //hook up the consumer applications to pre 'consumer' nodes, since fate doesnt start with the consumer. NetDeviceContainer *preConsumerLink; PointToPointHelper pConsLink; Ipv4InterfaceContainer* preConsInt; int32_t totlinks; ApplicationContainer serverApps; ApplicationContainer clientApps; uint32_t numClientPerNodes; NodeStats *stats=NULL; GlobalModule *global=NULL; DeviceModule *devMod=NULL; std::string logName; uint32_t maxPkts; std::string input; std::string format; double nProd; double nCons; std::string pTopo; std::string cTopo; std::string cacheTopo; uint32_t seed; uint32_t totTime; std::string cConfig; std::string nConfig; std::map<Ipv4Address, std::string> *dns; uint32_t nCaches=10; //1; //20; //NodeContainer availNodes; //NodeContainer consumers; //NodeContainer producers; NodeContainer caches; std::vector<unsigned int> availNodes; std::string sendOff="false"; std::string hashLoc="true"; //Fischer-Yates shuffle void shuffle(std::vector<unsigned int> &v) { int n = v.size(); Ptr<UniformRandomVariable> unifRandom = CreateObject<UniformRandomVariable> (); unifRandom->SetAttribute ("Min", DoubleValue (0)); unifRandom->SetAttribute ("Max", DoubleValue (n-1)); for(int a=n-1; a>0; a--) { int j = unifRandom->GetInteger(0, a); //int j = unifRandom->GetInteger(a, n); int tmp = v[a]; v[a] = v[j]; v[j] = tmp; } } void setProducers(void) { /*uint32_t numProd = producers.GetN(); std::vector<unsigned int> count(nFiles,0); for(unsigned int i=0; i< nFiles; i++) { count[i]=i; } shuffle(count);*/ for(unsigned int i=0; i< producers.GetN(); i++) { UdpFateServerHelper echoServer(100+i); echoServer.SetAttribute("ReturnSize", UintegerValue(500)); ///std::string matchName="/test"+std::to_string(i+1)+"/fileNum="; std::string matchName="/test"+std::to_string(i+1); //std::stringstream out; //out << count[i]+1; //matchName.append(out.str()); echoServer.SetAttribute("MinMatchName", StringValue(matchName)); /*int p; if (nFiles >= numProd) { p = i % numProd; } else { assert(0); }*/ serverApps.Add( echoServer.Install(producers.Get(i))); } NS_LOG_INFO("actual post nFile servers are:" << serverApps.GetN()); } void create1Producers(unsigned int nodeNum) { Ptr<UniformRandomVariable> unifRandom = CreateObject<UniformRandomVariable> (); unifRandom->SetAttribute ("Min", DoubleValue (0)); unifRandom->SetAttribute ("Max", DoubleValue (nodes.GetN() - 1)); producers.Add(nodes.Get(nodeNum)); setProducers(); } void createAllConsumers(void) { // Ptr<Node> newNode = CreateObject<Node>(); //consumers.Add(nodes.Get(0)); //stack.Add(consumers); //stack.InstallAll(); //stack.Install(consumers); //p2p.SetChannelAttribute ("Delay", StringValue ("2ms")); //p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); // //Ipv4GlobalRoutingHelper::PopulateRoutingTables (); for(unsigned int i=0; i<consumers.GetN(); i++) { //add application to each UdpFateZipfClientHelper echoClient(ipic[0].GetAddress (1),9); //based upon the name, it will map to an ip/port echoClient.SetAttribute ("MaxPackets", UintegerValue (maxPkts)); echoClient.SetAttribute ("Interval", TimeValue (Seconds ((double) 1.0/reqRate))); echoClient.SetAttribute ("NumSegments", UintegerValue (nSeg)); echoClient.SetAttribute ("NumFiles", UintegerValue (nFiles)); echoClient.SetAttribute ("AddTimeStamp", BooleanValue(true)); echoClient.SetAttribute ("ZipfAlpha", DoubleValue(alpha)); echoClient.SetAttribute ("NStaticDestination", BooleanValue(true)); //use the static index or not echoClient.SetAttribute ("NStaticDestination", BooleanValue(true)); //use the static index or not echoClient.SetAttribute ("matchByType", StringValue("location")); //filenum, location, segnum bool val = (sendOff=="true" ? true : false); echoClient.SetAttribute("sendToOffPathCache", BooleanValue (val)); val = (hashLoc=="true" ? true : false); echoClient.SetAttribute("hashOnLocation", BooleanValue(val)); //Need to make this variable AND loop for all consumers std::string temp="/test"+std::to_string( (i%producers.GetN())+1); echoClient.SetAttribute("matchString", StringValue(temp)); PktType fatePkt; fatePkt.SetUnsignedNamedAttribute("TtlHop", 128); fatePkt.SetPacketPurpose(PktType::INTERESTPKT); //std::string cacheTrip="10.0.0.13"; //<--redirect cache IP //cacheTrip.push_back(';'); //cacheTrip.append("10.0.0.22"); //cacheTrip += '\n'; //fatePkt.SetPrintedNamedAttribute("DstChain",cacheTrip); //fatePkt.SetPrintedNamedAttribute("ReturnChain",""); IcnName<std::string> pktName; //pktName.SetFullName("/test1/segnum="); pktName.SetFullName(temp); fatePkt.SetName(pktName); std::stringstream out; out << fatePkt; echoClient.SetAttribute ("PktPayload", StringValue(out.str())); //use the static index or not clientApps.Add(echoClient.Install(consumers.Get(i))); //auto app = echoClient.Install(consumers.Get(0)); //i)); //app.SetPktPayload(fatePkt); //clientApps.Add(app); //Ptr<UdpFateZipfClient> zapp = DynamicCast<UdpFateZipfClient>(app.Get(j)); //zapp->SetPktPayload(fatePkt); //seems the only way to preload the packet type, is to do it here } } void createAllCacheNodes() { //Ptr<Node> node = nodes.Get(4); //4 // cachingNodes.Add(node); //nonCachingNodes.Add(node1); } void createSubFateNodes(const std::string &config, const NodeContainer &nodes) { UtilityConfigXml cconfig; //system sed file ? ; TODO FIXME JLM cconfig.FirstNodeFileConfig(config); FateIpv4Helper helper; helper.SetConfigFile(config); //if (!stats) stats= new CustomStats; // if(!global) { GlobalModule *global = new GlobalModule; GlobalModuleTimerNs3 *timer = new GlobalModuleTimerNs3; global->SetGlobalTimer(timer); GlobalModuleLog *log = new CoutModuleLog; global->SetGlobalLog("default", log ); global->dnsEntry = GetDns(); //(void *) (dns); // } helper.SetStats(stats); helper.SetLog(log); helper.SetGlobalModule(global); helper.Install(nodes); } void createFateNodes(const std::string &cConfig, const std::string &nConfig) { //cache only nodes are cConfig, all else are nConfig. //was cancelled out ... necessary? // createSubFateNodes(cConfig, caches); createSubFateNodes(nConfig, producers ); createSubFateNodes(nConfig, consumers ); NodeContainer restNodes; for(unsigned int i=0; i<availNodes.size(); i++) { restNodes.Add(NodeContainer::GetGlobal().Get(availNodes[i])); } createSubFateNodes(nConfig, restNodes ); //non cache/producer/consumer nodes std::cout << " initialized " << caches.GetN() + producers.GetN() + consumers.GetN()+ restNodes.GetN() << "nodes out of " << NodeContainer::GetGlobal().GetN() << "\n"; } void createFateLogs() { std::string name=logName; std::fstream fs; name.append("-fate.stat"); fs.open(name,std::fstream::out ); stats->DumpStats(fs); fs.close(); name=logName; name.append("-server.stat"); std::fstream fs2; fs2.open(name,std::fstream::out ); UdpFateServerHelper echoServer(100); for(unsigned int i=0; i<producers.GetN();i++) { fs2 << "\nProducer Node(p" << i << ":n" << producers.Get(i)->GetId()<< ":n):\n"; echoServer.DumpStats(producers.Get(i), fs2); } fs2 << "\n"; fs2.close(); name=logName; name.append("-client.stat"); std::fstream fs3; fs3.open(name,std::fstream::out ); //preclients.DumpStats(consumers.Get (0),std::cout); UdpFateZipfClientHelper echoConsumer(ipic[0].GetAddress(1),9); for(unsigned int i=0; i<consumers.GetN();i++) { fs3 << "\nConsumer Node(c" << i << ":n" << consumers.Get(i)->GetId()<< "):\n"; echoConsumer.DumpStats(consumers.Get(i), fs3); } fs3 << "\n"; fs3.close(); name=logName; name.append("-cache.stat"); std::fstream fs4; fs4.open(name,std::fstream::out ); //preclients.DumpStats(consumers.Get (0),std::cout); for(unsigned int i=0; i<caches.GetN(); i++) { fs4 << "\nCached Node(cache" << i << ":n" << caches.Get(i)->GetId()<< "):\n"; FateIpv4Helper::DumpStats(caches.Get(i), fs4); } fs4 << "\n"; } //option to enable/disable logging void setLogging() { std::string name=logName; name.append(".tr1"); p2p.EnableAsciiAll(ascii.CreateFileStream(name)); flowmon = flowmonHelper.InstallAll (); flowmon->CheckForLostPackets (); name=logName; name.append(".flowmon"); flowmon->SerializeToXmlFile(name, true, true); name=logName; name.append("-pcap"); p2p.EnablePcapAll (name); Ipv4GlobalRoutingHelper globalRouting; name=logName; name.append(".routes"); Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> (name, std::ios::out); globalRouting.PrintRoutingTableAllAt (Seconds(1.1), routingStream ); } void logInfo() { std::string name = logName; name.append(".info"); std::fstream fs2; fs2.open(name,std::fstream::out | std::fstream::out); fs2 << "Map\tNodes\tLinks\tformat\tReqRate\tnumFilesRq\tnumSegmentsPerFile\tnumConsumersPerNode\tnumConsumerNodes\tnumProducerNodes\tRndSeed\tsimTime\tmaxPktsPerConsumer\tzipfAlpha\tproducerTopology\t\tconsumerTopology\t\tedge-CacheXml\tnonedge-CacheXml\t\tnon-cacheXml\n"; fs2 << input << "\t" << NodeContainer::GetGlobal().GetN() << "\t" << totlinks <<"\t" << format << "\t" << reqRate << "\t" << nFiles << "\t" << nSeg << "\t" << numClientPerNodes << "\t" << consumers.GetN() << "\t" << producers.GetN() << "\t" << seed << "\t" << totTime << "\t" << maxPkts << "\t" << std::setprecision (15) << alpha << "\t" << pTopo << "\t" << cTopo << "\t" << cConfig << "\t" << cConfig << "\t" << nConfig << "\n"; fs2.close(); } void createTopology(std::string input, std::string format, int ratePerSec) { TopologyReaderHelper topoHelp; topoHelp.SetFileName (input); topoHelp.SetFileType (format); inFile = topoHelp.GetTopologyReader (); if (inFile != 0) { nodes = inFile->Read (); } if (inFile->LinksSize () == 0) { NS_LOG_ERROR ("Problems reading the topology file. Failing."); assert(0); } NS_LOG_INFO ("creating internet stack"); // Setup NixVector Routing //stack.SetRoutingHelper (nixRouting); // has effect on the next Install () //stack.SetRoutingHelper(); stack.Install (nodes); NS_LOG_INFO ("creating ip4 addresses"); address.SetBase ("10.0.0.0", "255.255.255.252"); totlinks = inFile->LinksSize (); NS_LOG_INFO ("creating node containers"); nc = new NodeContainer[totlinks]; TopologyReader::ConstLinksIterator iter; int i = 0; for ( iter = inFile->LinksBegin (); iter != inFile->LinksEnd (); iter++, i++ ) { nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ()); } NS_LOG_INFO ("creating net device containers"); ndc = new NetDeviceContainer[totlinks]; for (int i = 0; i < totlinks; i++) { // p2p.SetChannelAttribute ("Delay", TimeValue(MilliSeconds(weight[i]))); //p2p.SetChannelAttribute ("Delay", StringValue ("2ms")); //p2p.SetDeviceAttribute ("DataRate", StringValue ("1000Mbps")); ndc[i] = p2p.Install (nc[i]); } // it crates little subnets, one for each couple of nodes. NS_LOG_INFO ("creating ipv4 interfaces"); ipic = new Ipv4InterfaceContainer[totlinks]; for (int i = 0; i < totlinks; i++) { ipic[i] = address.Assign (ndc[i]); address.NewNetwork (); } } void prepNodes() { //availNodes= NodeContainer::GetGlobal(); for(unsigned int i=0; i<NodeContainer::GetGlobal().GetN() ; i++) { availNodes.push_back(i); } shuffle(availNodes); } void createProducers(unsigned int n) { std::cout << "Producers:"; for(unsigned int i=0; i<n; i++) { unsigned int num=availNodes.back(); producers.Add(NodeContainer::GetGlobal().Get(num)); availNodes.pop_back(); std::cout << num << ","; } std::cout << "\n"; setProducers(); } void createConsumers(unsigned int n) { std::cout << "Consumers:"; for(unsigned int i=0; i<n; i++) { unsigned int num=availNodes.back(); consumers.Add(NodeContainer::GetGlobal().Get(num)); availNodes.pop_back(); std::cout << num << ","; } std::cout << "\n"; } void createCaches(unsigned int n) { std::cout << "Caches:"; for(unsigned int i=0; i<n; i++) { unsigned int num=availNodes.back(); caches.Add(NodeContainer::GetGlobal().Get(num)); availNodes.pop_back(); std::cout << num << ","; } std::cout << "\n"; } void createAllCaches() { caches=NodeContainer::GetGlobal(); } int main (int argc, char *argv[]) { bool verbose = false; Packet::EnablePrinting(); Packet::EnableChecking(); input="scratch/ns3-ATT-topology.txt"; //input="scratch/simple3.orb"; //std::string input("./Inet/inet.3200"); //format= "Orbis"; format= "Inet"; //std::string nput ("./rocketfuel/maps/1239/latencies.intra"); //std::string input ("./src/topology-read/examples/RocketFuel_toposample_1239_weights.txt"); //std::string format ("Rocketfuel"); //std::string input("./src/topology-read/examples/Orbis_toposample.txt"); //std::string format ("Orbis"); reqRate=20; //req in seconds nProd=10; //double nCons=100; nCons=60; //std::string pTopo("Single"); //single, or random //std::string cTopo("Edge"); //edge or random pTopo="Random";//Single"; //single, or random //std::string cTopo("Random"); //edge or random cTopo="Random";//Edge"; //edge or random cacheTopo="Random";//Edge"; //edge or random //std::string cacheTopo("All"); //edge or random nFiles = 50000; logName="logs/default"; nSeg=1; alpha = 1; //std::string cConfig(""); //no config or name of xml file //cConfig="fateXmlConfigFiles/Ns3-node-configC.xml"; //no config or name of xml file cConfig="fateXmlConfigFiles/Lru-reroute3.xml"; //no config or name of xml file //std::string nConfig(""); nConfig="fateXmlConfigFiles/nocache.xml"; bool exclusiveContent=true; //either producers are exclusive in content or they all share the same numClientPerNodes=1; seed = 1; totTime=900; //0; maxPkts=1000000; //000; unsigned int cSize=10; CommandLine cmd; cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose); cmd.AddValue ("format", "Format to use for data input [Orbis|Inet|Rocketfuel].", format); cmd.AddValue ("input", "Name of the input file.", input); cmd.AddValue("reqRate", "Request Rate", reqRate); cmd.AddValue("producerTopo", "How producers are selected from topology", pTopo); cmd.AddValue("numProducers", "How many producer nodes are created", nProd); cmd.AddValue("consumerTopo", "How consumers are selected from topology", cTopo); cmd.AddValue("numConsumers", "How many consumer nodes are created", nCons); cmd.AddValue("cacheSize", "the size of each cache, for hashing", cSize); cmd.AddValue("numFiles", "How many files to request", nFiles); cmd.AddValue("numSegments", "How many Segments per file", nSeg); cmd.AddValue("cacheNodeConfig", "config file name for cache nodes", cConfig); cmd.AddValue("nonCacheNodeConfig", "config file name for non cache nodes", nConfig); cmd.AddValue("exclusiveProducers", "each producer only servers content unique to itself", exclusiveContent); cmd.AddValue("zipfAlpha", "Alpha value for the zipf generator for consumers", alpha); //rnd seed //num client apps per node cmd.AddValue("numClientsPerNode", "How many clients per client-nodes", numClientPerNodes); cmd.AddValue("rndSeed", "Random Seed Value", seed); cmd.AddValue("time", "how long the network simulator should run, in seconds", totTime); cmd.AddValue("logName", "Log name",logName); cmd.AddValue("maxPkts", "maximum number of interest packets to send. '0' = unlimited",maxPkts); cmd.AddValue("sendToOffPathCache", "redirect packets to cache", sendOff); cmd.AddValue("hashOnLocation", "hash to location or by name", hashLoc); cmd.Parse (argc,argv); std::cout << "\nsendOffPath:" << sendOff << ", hashloc:" << hashLoc << "\n"; RngSeedManager::SetSeed(seed); if (!verbose) { LogComponentDisableAll(LOG_PREFIX_ALL); } else { PacketMetadata::Enable (); Packet::EnablePrinting (); LogComponentEnable ("UdpFateZipfClientApplication", LOG_LEVEL_INFO); LogComponentEnable ("UdpFateServerApplication", LOG_LEVEL_INFO); } Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("10Gbps")); p2p.SetQueue("ns3::DropTailQueue"); //Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("1000000")); Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("1ms")); createTopology(input, format, reqRate); //create1Producers(3); prepNodes(); createProducers(nProd); createConsumers(nCons); createCaches(nCaches); createFateNodes(cConfig, nConfig); createAllConsumers(); Ipv4GlobalRoutingHelper::PopulateRoutingTables (); CreateDnsAssociation(); //cache hashing CreateDnsHashAssociation(caches,cSize); dns = GetDns(); //CreateDestAssociation(producers); CreateDestAssociation(NodeContainer::GetGlobal()); //how to do caching /*if (cConfig.size()) { mod = new UtilityExternalModule; timer = new GlobalModuleTimerNs3; //change to ns3 timer stats = new CustomStats; global = new GlobalModule; global->SetGlobalTimer(timer); //(mod->GetGlobalModule ()).SetGlobalLog ("default", new CoutModuleLog); global->SetGlobalLog("default", new Ns3InfoLog); //need a global file devMod = new DeviceModule; devMod->SetNodeStats(stats); global->dnsEntry = (void *) (dns); //createEdgeCacheNodes(); }*/ serverApps.Start (Seconds (1.0)); serverApps.Stop (Seconds (totTime+1.0)); //set as param FIXME //createAllCacheNodes(); clientApps.Start (Seconds (2.0)); clientApps.Stop (Seconds (totTime+.5)); if(verbose) { setLogging(); } Simulator::Stop(Seconds(totTime+4.0)); for(unsigned int i=0; i<nodes.GetN(); i++) { //std::cout << nodes.Get(i)->GetFateNode()->Name() << "\n"; } std::cout << "total nodes: " << NodeContainer::GetGlobal().GetN() << "\n"; std::cout << "total consumers:" << consumers.GetN() << "\n"; Simulator::Run (); logInfo(); createFateLogs(); Simulator::Destroy (); return 0; }
a37911b20c4465118184d4c281b38d2b6ef02802
8a81533bdda9e4eb3eaec982e3d71f8ebdcf4348
/Code/include/neutrino.hpp
1eaf728b45fa3169dabecbb9d781a4c5178a757e
[]
no_license
nicola-giuliani/neutrino
5216d162e84d8e601709f303cdf6eb7764a4e65a
3345c79a0c4a4e1c0319e593f5a25cc8e8875da3
refs/heads/master
2020-08-26T15:33:06.661361
2019-10-23T09:06:49
2019-10-23T09:38:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
22,118
hpp
/// @file neutrino.hpp /// @author Erik ZORZIN /// @date 24OCT2019 /// @brief Declaration of the "neutrino" class and some macros. /// /// @details Neutrino needs a common object to store some information that has to be exchanged /// between different objects. This class also contains common definitions and common utility /// member functions. The neutrino.hpp file must be include in all other Neutrino's classes, as it /// contains a core declaration which are essential to everything in this framework. /// /// **Cells interlinked within cells interlinked /// within one stem. And, dreadfully distinct /// against the dark, a tall white fountain played.** #ifndef neutrino_hpp #define neutrino_hpp #define CL_USE_DEPRECATED_OPENCL_1_2_APIS ///< Allows the usage of "OpenCL 1.2" functions in newer versions. #ifdef WIN32 // Detecting Windows... #define GLFW_EXPOSE_NATIVE_WIN32 ///< Enabling Windows native access functions... #define GLFW_EXPOSE_NATIVE_WGL ///< Enabling Windows native access functions... #endif #ifdef __linux__ // Detecting Linux... #define GLFW_EXPOSE_NATIVE_X11 ///< Enabling Linux native access functions... #define GLFW_EXPOSE_NATIVE_GLX ///< Enabling Linux native access functions... #endif ////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////// TERMINAL PARAMETERS //////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// #define NU_TERMINAL_REFRESH 20000 ///< Terminal refresh time [us]. #define NU_COLOR_NORMAL "\x1B[0m" ///< Default terminal color. #define NU_COLOR_RED "\x1B[31m" ///< Red. #define NU_COLOR_GREEN "\x1B[32m" ///< Green. #define NU_COLOR_YELLOW "\x1B[33m" ///< Yellow. #define NU_COLOR_BLUE "\x1B[34m" ///< Blue. #define NU_COLOR_MAGENTA "\x1B[35m" ///< Magenta. #define NU_COLOR_CYAN "\x1B[36m" ///< Cyan. #define NU_COLOR_WHITE "\x1B[37m" ///< White. #define NU_ERASE "\33[2K\r" ///< Erase character. ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// WINDOW PARAMETERS ///////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// #define NU_ZOOM_INCREMENT 0.1f ///< Mouse wheel zoom increment []. #define NU_ZOOM_INCREMENT_PS4 0.02f ///< PS4 gamepad zoom increment []. #define NU_ZOOM_THRESHOLD_PS4 -0.95f ///< PS4 gamepad zoom threshold []. #define NU_PAN_FACTOR 0.01f ///< Mouse pan translation factor []. #define NU_ROTATION_FACTOR 2.0f ///< Mouse orbit rotation factor []. #define NU_ROTATION_FACTOR_PS4 4.0f ///< PS4 gampad rotation factor []. #define NU_ROTATION_THRESHOLD_PS4 0.1f ///< PS4 gampad rotation thrshold []. #define NU_NEAR_Z_CLIP 0.1f ///< Near z-clipping distance [small, but > 0.0]. #define NU_FAR_Z_CLIP 100.0f ///< Far z-clipping distance [big, but < +inf]. #define NU_FOV 60.0f ///< Field of view [deg]. #define NU_IOD 0.02f ///< Intraocular distance. #define NU_SCREEN_DISTANCE -2.5f ///< Screen distance. #define NU_LINE_WIDTH 3 ///< Line width [px]. #define NU_KERNEL_NAME "thekernel" ///< OpenCL kernel function name. #define NU_MAX_TEXT_SIZE 128 ///< Maximum number of characters in a text string. #define NU_MAX_MESSAGE_SIZE 64 ///< Maximum number of characters in a text message. #define NU_MAX_PATH_SIZE 32768 ///< Maximum number of characters in a text file path. ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// GAMEPAD PARAMETERS //////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// #define NU_GAMEPAD_MIN_DECAYTIME 0.01f ///< Minimum decay time for LP filter [s]. #define NU_GAMEPAD_MAX_DECAYTIME 10.0f ///< Maximum decay time for LP filter [s]. #define NU_GAMEPAD_MIN_AXES -1.0f ///< Minimum axes value. #define NU_GAMEPAD_MAX_AXES 1.0f ///< Maximum axes value. #define NU_GAMEPAD_MIN_ORBIT_RATE 0.01f ///< Minimum orbit angular rate [rev/s]. #define NU_GAMEPAD_MAX_ORBIT_RATE 10.0f ///< Maximum orbit angular rate [rev/s]. #define NU_GAMEPAD_MIN_PAN_RATE 0.01f ///< Minimum orbit angular rate [rev/s]. #define NU_GAMEPAD_MAX_PAN_RATE 10.0f ///< Maximum orbit angular rate [rev/s]. ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////// ENUMS ///////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// // Projection mode: typedef enum { NU_MODE_MONO, ///< Projection mode set as 2D. NU_MODE_STEREO ///< Projection mode set as 3D. } projection_mode; // Shader types: typedef enum { NU_VERTEX, ///< GLSL shader interpretation set as vertex. NU_FRAGMENT, ///< GLSL shader interpretation set as fragment. NU_GEOMETRY ///< GLSL shader interpretation set as geometry. } shader_type; // Kernel modes: typedef enum { NU_WAIT, ///< OpenCL kernel set as blocking mode. NU_DONT_WAIT ///< OpenCL kernel set as non-blocking mode. } kernel_mode; // Compute device types: typedef enum { NU_CPU, ///< OpenCL NU_CPU device. NU_GPU, ///< OpenCL NU_GPU device. NU_ACCELERATOR, ///< OpenCL NU_ACCELERATOR device. NU_DEFAULT, ///< OpenCL NU_DEFAULT device. NU_ALL ///< OpenCL NU_ALL devices. } compute_device_type; ////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////// Standard C/C++ header files ////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// #include <stdlib.h> #include <errno.h> #include <string> #include <iostream> #include <fstream> #include <cerrno> #ifdef __APPLE__ // Detecting Mac OS... #include <math.h> #endif #ifdef __linux__ // Detecting Linux... #include <math.h> #endif #ifdef WIN32 // Detecting Windows... #include <windows.h> #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 ///< Enabling ANSI terminal in Windows... #define DISABLE_NEWLINE_AUTO_RETURN 0x0008 ///< Disabling new line auto return in Windows terminal... #include <cmath> #ifndef M_PI #define M_PI 3.14159265358979323846f #endif #endif ////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////// GLAD header files //////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// #include <glad/glad.h> // https://glad.dav1d.de ////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////// GLFW header files //////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// #include <GLFW/glfw3.h> // https://www.glfw.org #include <GLFW/glfw3native.h> // https://www.glfw.org ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// OpenGL header files /////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef __APPLE__ #include <OpenGL/OpenGL.h> // Apple deprecated the OpenGL framework in 2018, OS-X 10.14 Mojave. #else #include <GL/gl.h> // https://www.opengl.org #endif ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// OpenCL header files /////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef __APPLE__ #include <OpenCL/opencl.h> // Apple deprecated the OpenCL framework in 2018, OS-X 10.14 Mojave. #else #include <CL/cl.h> // https://www.opengl.org #include <CL/cl_gl.h> // https://www.opengl.org #endif ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// Geometry header files ///////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// #include "linear_algebra.hpp" #include "projective_geometry.hpp" ////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////// "neutrino" class /////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// /// @class neutrino /// ### Neutrino baseline. /// Declares a Neutrino baseline object. /// This class contains common definitions and utility functions which are used in various points /// in the code. class neutrino /// @brief **Neutrino baseline.** { private: size_t terminal_time; ///< @brief **Terminal time (for refresh) [us].** public: bool interop; ///< @brief **Use OpenCL-OpenGL interop.** double tic; ///< @brief **Tic time [s].** double toc; ///< @brief **Toc time [s].** double loop_time; ///< @brief **Loop time [s].** size_t q_num; ///< @brief **Number of OpenCL queues.** size_t k_num; ///< @brief **Number of OpenCL kernels.** cl_context context_id; ///< @brief **OpenCL context id.** cl_platform_id platform_id; ///< @brief **OpenCL platform ID.** cl_device_id device_id; ///< @brief **OpenCL device id.** cl_kernel* kernel_id; ///< @brief **OpenCL kernel ID array.** /// @brief **Class constructor.** /// @details Resets interop, tic, toc, loop_time, context_id, platform_id and device_id to their /// default values. neutrino(); /// @brief **Class initializer.** /// @details Initializes Neutrino. void init ( size_t loc_q_num, ///Number of OpenCL queues. size_t loc_k_num, ///Number of OpenCL kernels. bool loc_interop ///< Interoperability flag. ); /// @brief **Getter of "tic" time.** /// @details Gets a "tic" time, which is the value of operating system precision timer at the /// beginning of the application loop. To be used in combination with the "toc" time in order /// to measure the duration of the host PC processes during the application loop. /// This time is also used to manage timing-related operations within the Neutrino GUI, such as /// the low-pass filtering of the gamepad inputs. /// It does not measure the execution time of the kernel on the client GPU. void get_tic (); /// @brief **Getter of "toc" time.** /// @details Gets a "toc" time, which is the value of operating system precision timer at the /// end of the application loop. To be used in combination with the "tic" time in order /// to measure the duration of the host PC processes during the application loop. /// This time is also used to manage timing-related operations within the Neutrino GUI, such as /// the low-pass filtering of the gamepad inputs. /// It does not measure the execution time of the kernel on the client GPU. void get_toc (); /// @brief **Loader file function.** /// @details Loads a file. std::string load_file ( std::string loc_file_name ///< File name. ); /// @brief **Writer file function.** /// @details Writes a file. void write_file ( std::string file_name ///< File name. ); /// @brief **Query numeric input from stdin function.** /// @details Parses a user numeric input from stdin on a terminal console. /// The input number is constrained to stay within a minimum and a maximum. size_t query_numeric ( std::string caption, ///< Text query caption. int min, ///< Minimum queried numeric value. int max ///< Maximum queried numeric value. ); /// @brief **Current stdout terminal line erase function.** /// @details Erases the current line from the stdout of the terminal console. void erase (); /// @brief **Action message function.** /// @details Prints an "action" message on the terminal console. void action ( std::string loc_text ///< User defined text message. ); /// @brief **Error message function.** /// @details Prints an "error" message on the terminal console. void error ( std::string loc_text ///< User defined text message. ); /// @brief **List message function.** /// @details Prints a "list" message on the terminal console. void list ( std::string loc_text, ///< User defined text message. std::string loc_delimiter, ///< User defined text delimiter. size_t loc_tab ///< User defined text tab size. ); /// @brief **Done message function.** /// @details Prints a "done" message on the terminal console. void done (); /// @brief **Terminated message function.** /// @details Prints a "terminated" message on the terminal console. void terminated (); /// @brief **Constrainer function for double numbers.** /// @details Constrains a double number to stay within a minimum and a maximum value. double constrain_double ( double loc_input, ///< Input number to be constrained. double loc_min, ///< Minimum constraint. double loc_max ///< Maximum constraint. ); /// @brief **Constrainer function for float3_structure numbers.** /// @details Constrains a float number to stay within a minimum and a maximum value. float constrain_float ( float loc_input, ///< Input number to be constrained. float loc_min, ///< Minimum constraint. float loc_max ///< Maximum constraint. ); /// @brief **OpenCL error get function.** /// @details Translates an OpenCL numeric error code into a human-readable string. std::string get_error ( cl_int loc_error ///< OpenCL Error code. ); /// @brief **OpenCL error check function.** /// @details Checks for an OpenCL error code and print it to stdout. void check_error ( cl_int loc_error ///< OpenCL Error code. ); /// @brief **Class destructor.** /// @details It deletes the kernel ID array. ~neutrino(); }; #endif
4381a10f956489df749b2ce24d694f588c27f611
d2d1985a16b9fc935729de00d0bade7d6c9fe058
/PerSqr.cpp
2be633433f320e1377ae47f3025c5428054d8d7a
[]
no_license
Josephzppqq/Algorithm
99c2d9df7b26fbbdfce591347645a82cd7ee77de
7264adc07bbfaace5608ddcc3e6fe0fdf17a9df8
refs/heads/master
2020-03-06T23:26:24.705360
2018-03-28T11:51:14
2018-03-28T11:51:14
127,098,841
0
0
null
null
null
null
UTF-8
C++
false
false
1,980
cpp
/* 算法题:完美平方 给一个正整数 n,写一个函数找到若干个完全平方数(比如 1,4,9,...)使得他们的和等于 n。要求为你需要让平方数的个数最少,输出需要的最少的平方数的个数。 格式: 输入每一行输入一个 整数 n,输出每一行输出需要最少的平方数的个数。 样例输入 n = 12 n = 13 样例输出 3   //12 = 4 + 4 + 4 2  //13 = 4 + 9 */ #include <iostream> #include <vector> using namespace std; int main() { while (1) { //flag为小于n的最大平方数的平方根 int n,flag=1,flag2,n2,num,i,nR; vector<int> v; vector<vector<int>> vv,vv2; cout << "请输入一个正整数:"; cin >> n; if (n <= 0) { cout << "input error!" << endl; return 0; } while (1) { if (flag*flag <= n) flag++; else { flag--;break; } } //如果最大平方数正好等于n,则输出 if (flag*flag == n) { cout << flag<<endl; return 0; } //把得到的平方根添加到容器,容器内数据相加等于n,其中每个容器平方根最大为flag flag2 = flag; nR = n; while (flag2) { flag = flag2; n = nR; v.swap(vector<int>()); while ((n - flag*flag >= 0) && (flag - 1>=0)) { n2 = n - flag*flag; if (flag == 0) break; v.push_back(flag); while (1) { if (n2 - flag*flag < 0) --flag; else { n = n2; break; } } } vv.push_back(v); --flag2; } num = vv.size(); flag = vv[0].size(); for (i = 0; i < num; i++) { if (flag >= vv[i].size()) flag = vv[i].size(); } for (i = 0; i < num; i++) { if (vv[i].size() == flag) vv2.push_back(vv[i]); } cout << "个数最少为:" << flag << "个"<<endl; cout << "有" << vv2.size() << "种情况" << endl; for (i = 0; i < vv2.size(); i++) { for (auto j : vv2[i]) cout << j*j << " "; cout << endl; } cout << "==============================="<< endl; } }
324994a4eb01c7b0786db0a5b6d7c673614ca4b9
6e9b9cc7ca07cef655b11a87bf5262cfc15a26ea
/Arduino/eScooterControl/speedometer.h
04e639e546108f76f62699546cf34941fccd917e
[ "MIT" ]
permissive
semlanik/eScooterControl
7582f801eb9fb1b1ca73fcbc1358187148f9b7a9
1aeea03c02b9bd8aac11653520eff9726670160c
refs/heads/master
2021-05-21T02:46:49.553015
2020-10-26T08:27:28
2020-10-26T08:27:28
252,507,528
3
0
null
null
null
null
UTF-8
C++
false
false
1,694
h
/* * MIT License * * Copyright (c) 2020 Alexey Edelev <[email protected]> * * This file is part of eScooterControl project https://github.com/semlanik/eScooterControl * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * software and associated documentation files (the "Software"), to deal in the Software * without restriction, including without limitation the rights to use, copy, modify, * merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #pragma once #if defined(ARDUINO) && ARDUINO >= 100 #include <Arduino.h> #else #include <WProgram.h> #endif #include "singleton.h" class Speedometer : public Singleton<Speedometer> { public: void attachToDisplay(); void incrementHallCounter(); private: Speedometer(); friend class Singleton; byte mMomentSpeed; unsigned long mLastHallTime; byte mHallCounter;//TODO: Not used for now, need for moment speed correction };
51a10d0cb67bc4b10173e8bbdc107c00880d5218
05cb2ebcb579a5d9beb37cd614cb5f15d97d856d
/Simple_trolly/Simple_trolly.ino
413adb44ab8a86462e656ecd1b140ab23f4f751c
[]
no_license
Manav2501/Human_following_Trolly
791455e093eb117a8e11cc1aa9abc45960c77499
a6f244bbc29133784f39d6a88bebf8c784bdb775
refs/heads/master
2023-03-19T20:14:40.156614
2021-03-13T06:06:42
2021-03-13T06:06:42
347,287,415
0
0
null
null
null
null
UTF-8
C++
false
false
1,317
ino
#define trigPin 13 #define echoPin 12 long duration, distance; int x; void setup() { Serial.begin(9600); pinMode(13,OUTPUT); pinMode(12,INPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); pinMode(6,OUTPUT); pinMode(7,OUTPUT); } void loop() { y: { digitalWrite(trigPin, LOW); // Added this line delayMicroseconds(10); // Added this line digitalWrite(trigPin, HIGH); delayMicroseconds(10); // Added this line digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration/2) / 29.1; Serial.print(distance); Serial.println(" cm"); if(distance > 20 && distance <= 60) { digitalWrite(4,LOW); digitalWrite(6,LOW); digitalWrite(5,HIGH); digitalWrite(7,HIGH); delay(100); } else if(distance <= 20 && distance >= 10) { digitalWrite(4,LOW); digitalWrite(6,LOW); digitalWrite(5,LOW); digitalWrite(7,LOW); delay(500); } else if(distance < 10) { digitalWrite(5,LOW); digitalWrite(7,LOW); digitalWrite(4,HIGH); digitalWrite(6,HIGH); delay(100); } if(distance > 60) { digitalWrite(4,LOW); digitalWrite(7,LOW); digitalWrite(5,HIGH); digitalWrite(6,HIGH); delay(500); goto y; } } }
5554de9febb86b2c41908fd69b61bf75f6096475
71ec70eee36a27a55fa520c0c5da3e8fd0f66c2e
/expressions/Div.h
0cb2181616ec2bd53b5ffd455d2fe95812da1994
[]
no_license
shahafMordechay/flight-simulator
63c32ab5b3760df67eeacc90a00dab4ff3811ad6
a00944d2a36db5354d2cc89b3e13adbf7287cd8c
refs/heads/master
2020-04-10T09:19:23.281850
2019-05-01T16:29:10
2019-05-01T16:29:10
160,933,007
0
1
null
2018-12-22T21:36:28
2018-12-08T11:36:02
C++
UTF-8
C++
false
false
288
h
#ifndef FLIGHTSIMULATOR_DIV_H #define FLIGHTSIMULATOR_DIV_H #include "BinaryExpression.h" class Div : public BinaryExpression { public: Div(Expression* left, Expression* right) : BinaryExpression(left, right){}; double calculate() override; }; #endif //FLIGHTSIMULATOR_DIV_H
ae602878514ec69c3197e6dbe60ee49f7dcaeea8
05e6d4d4817ea6cda4fb6f0496ecd32a7d7f1fed
/people.h
acd2b3db9b3eec4f24a71b817f8da97f2ee23770
[]
no_license
khobs99/Project2
fbbf439356a9d6cda594d38f8287027bc1eca823
86f9409947250f70431aacada217b0fb0ee9b6df
refs/heads/master
2020-12-30T00:46:08.760177
2020-02-13T20:52:29
2020-02-13T20:52:29
238,801,498
0
0
null
null
null
null
UTF-8
C++
false
false
400
h
//People Header . Kenneth Hobday . Spring 2020 . CSC231 #include "Person_KJH.h" class people { public: people(); people(const people& source); ~people(); void insert(const person& n); int find(const person& x); void remove(const person& kill); people& operator =(const people& i); people operator +(const people& x); void display(ostream& out); private: person* map; int len; };
da2aedd3ec5e01b0b0410345cbb393ee1f529c78
8da9fd5175fad4f938f3e6c1965254d1d4827cce
/lrlb_reactor/example/testv09/client.cpp
4a1e324893e116e8a569a9b19eb38a5699ff4149
[]
no_license
liangruijin/Lrlb
c80632354d05d5fe70487e20163b5d655ca1cc2a
7cb38c332e5e38f89e433ee7c4ae29f3eef84882
refs/heads/master
2023-06-20T03:19:12.112844
2021-07-09T01:04:40
2021-07-09T01:04:40
329,559,789
1
0
null
null
null
null
UTF-8
C++
false
false
791
cpp
#include "udp_client.h" #include <stdio.h> #include <string.h> //客户端业务 void busi(const char *data, uint32_t len, int msgid, net_connection *conn, void *user_data) { //得到服务端回执的数据 char *str = NULL; str = (char*)malloc(len+1); memset(str, 0, len+1); memcpy(str, data, len); printf("recv server: [%s]\n", str); printf("msgid: [%d]\n", msgid); printf("len: [%d]\n", len); } int main() { event_loop loop; //创建udp客户端 udp_client client(&loop, "192.168.237.128", 7777); //注册消息路由业务 client.add_msg_router(1, busi); //发消息 int msgid = 1; const char *msg = "Hello Lrlb!"; client.send_message(msg, strlen(msg), msgid); loop.event_process(); return 0; }
5f611a6b38ac15b877d2a5d85ce0f5de172ac82a
17d7f3790cdbe3d787d019061f5193f2637860fb
/library/src/include/tree_node_bluestein.h
ad1e3d6fb1c906a713e003d2a85a0fc37d48d7cc
[ "MIT" ]
permissive
feizheng10/rocFFT
de29d0f2c1498016998e244ad03db13bb285f9b9
6651be5767c516e4357e8385d3c9f7bd55c8fff7
refs/heads/master
2023-07-19T04:18:24.057757
2021-11-18T22:04:29
2021-11-18T22:04:29
156,266,985
1
0
MIT
2018-11-05T18:54:53
2018-11-05T18:54:53
null
UTF-8
C++
false
false
3,092
h
// Copyright (c) 2021 - present Advanced Micro Devices, Inc. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #ifndef TREE_NODE_BLUE_H #define TREE_NODE_BLUE_H #include "tree_node.h" /***************************************************** * CS_BLUESTEIN *****************************************************/ class BluesteinNode : public InternalNode { friend class NodeFactory; protected: BluesteinNode(TreeNode* p) : InternalNode(p) { scheme = CS_BLUESTEIN; } #if !GENERIC_BUF_ASSIGMENT void AssignBuffers_internal(TraverseState& state, OperatingBuffer& flipIn, OperatingBuffer& flipOut, OperatingBuffer& obOutBuf) override; #endif void AssignParams_internal() override; void BuildTree_internal() override; }; /***************************************************** * Component of Bluestein * Chirp, XXXMul *****************************************************/ class BluesteinComponentNode : public LeafNode { friend class NodeFactory; protected: BluesteinComponentNode(TreeNode* p, ComputeScheme s) : LeafNode(p, s) { // first PAD MUL: in=parent_in, out=bluestein, must be out-of-place // last RES MUL: in=bluestein, out=parent_out, must be out-of-place // other components, must be blue -> blue if(scheme == CS_KERNEL_PAD_MUL || scheme == CS_KERNEL_RES_MUL) allowInplace = false; else allowOutofplace = false; // RES_MUL must not output to B buffer, while others must output to B buffer if(scheme == CS_KERNEL_RES_MUL) allowedOutBuf = OB_USER_IN | OB_USER_OUT | OB_TEMP | OB_TEMP_CMPLX_FOR_REAL; else { allowedOutBuf = OB_TEMP_BLUESTEIN; allowedOutArrayTypes = {rocfft_array_type_complex_interleaved}; } } void SetupGPAndFnPtr_internal(DevFnCall& fnPtr, GridParam& gp) override; }; #endif // TREE_NODE_BLUE_H
47b556d0f2c95669c1481ae0113c8765db141fca
b9541fba67ebc716dcf25a98f8258b9ca8cd870a
/potd/potd-q33/main.cpp
e54c7f76facb952a215dd8dc10d34b8a98bcfe0c
[]
no_license
kaiwenHong/cs225git
7ba1d9c12bbd0430609801605d898e27ed486682
0e77330cd076cf4dece5443199b5bf20569984c8
refs/heads/master
2021-03-05T13:30:26.066261
2019-11-20T01:41:32
2019-11-20T01:41:32
246,125,485
4
17
null
2020-03-09T19:36:08
2020-03-09T19:36:07
null
UTF-8
C++
false
false
1,380
cpp
#include <iostream> #include "TreeNode.h" using namespace std; void preot(TreeNode *n) { if (n==NULL) cout << "x"; else { cout << "(" << n->val_ << " "; preot(n->left_); cout << " "; preot(n->right_); cout << ")"; } } int main() { TreeNode * n1 = new TreeNode(2); TreeNode * n2 = new TreeNode(5); TreeNode * n3 = new TreeNode(8); TreeNode * n4 = new TreeNode(10); TreeNode * n5 = new TreeNode(13); n4->left_ = n3; n3->parent_ = n4; n4->right_ = n5; n5->parent_ = n4; n3->left_ = n2; n2->parent_ = n3; n2->left_ = n1; n1->parent_ = n2; preot(n4); cout << endl; // Your Code Here (Right or left rotate to balance above tree? ) preot(n4); cout << endl; deleteTree(n4); n1 = new TreeNode(2); n2 = new TreeNode(5); n3 = new TreeNode(8); n4 = new TreeNode(10); n5 = new TreeNode(13); n2->right_ = n3; n3->parent_ = n2; n2->left_ = n1; n1->parent_ = n2; n3->right_ = n4; n4->parent_ = n3; n4->right_ = n5; n5->parent_ = n4; preot(n2); cout << endl; // Your Code Here (Right or left rotate to balance above tree? ) rightRotate(n2); cout << "n4_parent = " << n4->parent_ << endl; cout << "n1 = " << n1 << endl; preot(n2); cout << endl; deleteTree(n2); return 0; }
f927e094ebc7d08629a8af860da4ea08ed6e3086
6f38cf9346360993320d422b8df7a23414cbbb38
/UVA/p10905v0_cpp11.cpp
b5c9ca139d5f148cf61f6b6d6332c83544c469bb
[]
no_license
goldenpython/Contests
8042cec56e9666d7232d86b4d321b4ebc4bea95e
78fa330cf8b522b3f13d0fbcf32e1a28e3dd0f5c
refs/heads/master
2021-07-10T01:28:13.858232
2019-10-05T20:32:08
2019-10-05T20:32:08
5,333,035
1
1
null
2019-10-05T20:32:09
2012-08-07T20:18:48
C++
UTF-8
C++
false
false
1,694
cpp
/******************************************************************************* * Cristian Alexandrescu * * 2163013577ba2bc237f22b3f4d006856 * * 11a4bb2c77aca6a9927b85f259d9af10db791ce5cf884bb31e7f7a889d4fb385 * * bc9a53289baf23d369484f5343ed5d6c * *******************************************************************************/ /* Problem 10905 - Children's Game */ #include <iostream> #include <vector> #include <string> #include <algorithm> #include <numeric> template<typename T> void ReadArray(std::vector<T> &roVectElementsArray) { int nN; std::cin >> nN; roVectElementsArray.reserve(nN); while (nN--) { T oElement; std::cin >> oElement; roVectElementsArray.push_back(std::move(oElement)); } } using namespace std; int main() { while(true) { vector<string> oVecoNumbers; ReadArray(oVecoNumbers); if (!oVecoNumbers.size()) break; sort( oVecoNumbers.begin(), oVecoNumbers.end(), [] (const string &roLHS, const string &roRHS) -> bool { auto nMaxSize = roLHS.size() + roRHS.size(); for (auto oItLHS = roLHS.cbegin(), oItRHS = roRHS.cbegin(); nMaxSize--; ++oItLHS, ++oItRHS) { if (oItLHS == roLHS.cend()) oItLHS = roRHS.cbegin(); if (oItRHS == roRHS.cend()) oItRHS = roLHS.cbegin(); const auto nDiff = *oItLHS - *oItRHS; if (!nDiff) continue; return nDiff > 0; } return false; } ); cout << accumulate(oVecoNumbers.cbegin(), oVecoNumbers.cend(), string()) << endl;; } return 0; }
5e4b3a3035db424f231bafc9418d6fea0948aa15
041530357d9897276f06d795ff1634ff5a4db1a3
/SignUpControl.h
a0ec01120427674d106490a95333179f1cf85f13
[]
no_license
LeeKyeWoong/SEhw33
76c9c716822a532293886c3a28a9532b45c76384
466721848b9a0a0626d7911780aa3052cd2c8832
refs/heads/master
2020-05-31T18:19:40.807294
2019-06-06T06:37:35
2019-06-06T06:37:35
190,431,159
0
1
null
null
null
null
UHC
C++
false
false
830
h
#pragma once #include <iostream> #include <string> using namespace std; class SignUpUI; class MemberCollection; class SignUpControl { //Class: SignUpControl //Description: SignUp의 control class //Created: 2019/05/30 //Author: 이계웅 private: bool checkId; //해당 ID의 중복 여부를 저장하는 변수, 중복이 없으면 True이고, 중복이면 False이다. public: SignUpControl(); // SignInControl의 control 객체의 checkID값을 true값으로 초기화 하는 생성자 void createAccount(string id, string password, string name, string idNum, string memType, bool sessionOn, MemberCollection* memberCollection); // 새 Account를 생성하며, 입력된 ID의 중복 여부를 확인하는 함수 bool getCheckId(); //회원 가입을 시도하는 ID의 중복 여부를 반환하는 함수 };
bd086606e6baa3f5e574e4880b23f3706e5dd50a
2191c476a1cdfecd760bde88d78b29802d79d11b
/webapp.h
59f86211fa55391f95c60a8ae202e3bd31f84737
[]
no_license
shi-yan/Zoidblog
d3d0d2bbd2893f669281b72105c0129ae84801d0
0f64d36df520a670b5f0648bec068aa1a2769800
refs/heads/master
2016-08-04T16:21:49.680930
2011-08-01T08:55:29
2011-08-01T08:55:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
776
h
#ifndef WEBAPP_H #define WEBAPP_H #include <QObject> #include "httpresponse.h" #include "httprequest.h" #include "pathtree.h" class WebApp:public QObject { Q_OBJECT const QString pathSpace; PathTree *pathTree; public: WebApp(const QString &_pathSpace="",QObject *parent =0); WebApp(const WebApp &in):QObject(),pathSpace(in.pathSpace){} bool addGetHandler(const QString &_path,const QString &handlerName); bool addPostHandler(const QString &_path,const QString &handlerName); virtual ~WebApp(){} const QString & getPathSpace() { return pathSpace; } virtual void init(){} virtual void registerPathHandlers()=0; void setPathTree(PathTree *pt) { pathTree=pt; } }; #endif // WEBAPP_H
c6175a22a64a1bda1da758d7b09f1e3bcdc58b9e
72852e07bb30adbee608275d6048b2121a5b9d82
/algorithms/problem_1232/solution.cpp
e689c6e7be18273e916653036f30017e37ae0ca5
[]
no_license
drlongle/leetcode
e172ae29ea63911ccc3afb815f6dbff041609939
8e61ddf06fb3a4fb4a4e3d8466f3367ee1f27e13
refs/heads/master
2023-01-08T16:26:12.370098
2023-01-03T09:08:24
2023-01-03T09:08:24
81,335,609
0
0
null
null
null
null
UTF-8
C++
false
false
2,498
cpp
/* 1232. Check If It Is a Straight Line Easy You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane. */ #include <algorithm> #include <atomic> #include <bitset> #include <cassert> #include <cmath> #include <condition_variable> #include <functional> #include <future> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <thread> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define ll long long #define ull unsigned long long class Solution { public: int gcd(int x, int y) { if (x == 0 || y == 0) return 1; if (y > x) swap(x, y); int mod = x % y; if (mod == 0) return y; return gcd(y, mod); } pair<int, int> get_ratio(int x, int y) { int g = gcd(abs(x), abs(y)); if (x < 0) { x = -x; y = -y; } return make_pair(x/g, y/g); } bool checkStraightLine(vector<vector<int>>& coordinates) { int sz = coordinates.size(); tuple<bool, bool, bool> res{true, true, true}; const auto slop = get_ratio(coordinates[1][1] - coordinates[0][1], coordinates[1][0] - coordinates[0][0]); for (int i = 1; (std::get<0>(res) || std::get<1>(res) || std::get<2>(res)) && i < sz; ++i) { if (coordinates[i][0] != coordinates[0][0]) std::get<0>(res) = false; if (coordinates[i][1] != coordinates[0][1]) std::get<1>(res) = false; if (slop != get_ratio(coordinates[i][1] - coordinates[0][1], coordinates[i][0] - coordinates[0][0])) std::get<2>(res) = false; } return std::get<0>(res) || std::get<1>(res) || std::get<2>(res); } }; int main() { Solution sol; vector<vector<int>> coord; // Expected: true coord = {{-3,-2},{-1,-2},{2,-2},{-2,-2},{0,-2}}; // Expected: true coord = {{0,1},{1,3},{-4,-7},{5,11}}; //coord = {{-4,-3},{1,0},{3,-1},{0,-1},{-5,2}}; coord = {{-2,12},{2,-8},{6,-28},{-10,52},{-7,37},{4,-18},{7,-33},{1,-3},{-1,7},{8,-38}}; cout << "Result: " << sol.checkStraightLine(coord) << endl; return 0; }
b616654f37d99ba7b19388a1ac4d36432b9fba8e
7435c4218f847c1145f2d8e60468fcb8abca1979
/Vaango/src/CCA/Components/Schedulers/Relocate.h
468d9ba601f236ebc836a64ff547a24dfe4c0efc
[]
no_license
markguozhiming/ParSim
bb0d7162803279e499daf58dc8404440b50de38d
6afe2608edd85ed25eafff6085adad553e9739bc
refs/heads/master
2020-05-16T19:04:09.700317
2019-02-12T02:30:45
2019-02-12T02:30:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,729
h
/* * The MIT License * * Copyright (c) 1997-2012 The University of Utah * Copyright (c) 2013-2014 Callaghan Innovation, New Zealand * Copyright (c) 2015- Parresia Research Limited, New Zealand * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #ifndef UINTAH_HOMEBREW_RELOCATE_H #define UINTAH_HOMEBREW_RELOCATE_H #include <Core/Grid/LevelP.h> #include <Core/Grid/Patch.h> #include <Core/Grid/Variables/ComputeSet.h> #include <vector> #include <sci_defs/mpi_defs.h> // For MPIPP_H on SGI namespace Uintah { class DataWarehouse; class LoadBalancer; class ProcessorGroup; class Scheduler; class VarLabel; /************************************** CLASS MPIRelocate Short description... GENERAL INFORMATION Relocate.h Steven G. Parker Department of Computer Science University of Utah Center for the Simulation of Accidental Fires and Explosions (C-SAFE) KEYWORDS Scheduler_Brain_Damaged DESCRIPTION Long description... WARNING ****************************************/ class MPIScatterRecords; // defined in .cc class Relocate { public: Relocate(); virtual ~Relocate(); ////////// // Insert Documentation Here: void scheduleParticleRelocation(Scheduler*, const ProcessorGroup* pg, LoadBalancer* lb, const LevelP& level, const VarLabel* old_posLabel, const std::vector<std::vector<const VarLabel*> >& old_labels, const VarLabel* new_posLabel, const std::vector<std::vector<const VarLabel*> >& new_labels, const VarLabel* particleIDLabel, const MaterialSet* matls); ////////// // Schedule particle relocation without the need to provide pre-relocation labels. Warning: This // is experimental and has not been fully tested yet. Use with caution (tsaad). void scheduleParticleRelocation(Scheduler*, const ProcessorGroup* pg, LoadBalancer* lb, const LevelP& level, const VarLabel* posLabel, const std::vector<std::vector<const VarLabel*> >& otherLabels, const MaterialSet* matls); const MaterialSet* getMaterialSet() const { return reloc_matls;} private: // varlabels created for the modifies version of relocation std::vector<const Uintah::VarLabel*> destroyMe_; ////////// // Callback function for particle relocation that doesn't use pre-Relocation variables. void relocateParticlesModifies(const ProcessorGroup*, const PatchSubset* patches, const MaterialSubset* matls, DataWarehouse* old_dw, DataWarehouse* new_dw, const Level* coarsestLevelwithParticles); void relocateParticles(const ProcessorGroup*, const PatchSubset* patches, const MaterialSubset* matls, DataWarehouse* old_dw, DataWarehouse* new_dw, const Level* coarsestLevelwithParticles); void exchangeParticles(const ProcessorGroup*, const PatchSubset* patches, const MaterialSubset* matls, DataWarehouse* old_dw, DataWarehouse* new_dw, MPIScatterRecords* scatter_records, int total_reloc[3]); void findNeighboringPatches(const Patch* patch, const Level* level, const bool findFiner, const bool findCoarser, Patch::selectType& AllNeighborPatches); void finalizeCommunication(); const VarLabel* reloc_old_posLabel; std::vector<std::vector<const VarLabel*> > reloc_old_labels; const VarLabel* reloc_new_posLabel; std::vector<std::vector<const VarLabel*> > reloc_new_labels; const VarLabel* particleIDLabel_; const MaterialSet* reloc_matls; LoadBalancer* lb; std::vector<char*> recvbuffers; std::vector<char*> sendbuffers; std::vector<MPI_Request> sendrequests; }; } // End namespace Uintah #endif
3df810703bc50ff0a044a0b878eed8f50863a6de
277c1f235da906c0820edff6af574f3cd0152966
/day2/q1.cpp
4e6579ec168bc15d7de698dc692b2e8e6f1c4a61
[]
no_license
ashutosh-ve/Placement
463daa85e988a4c3443d280ada5cc41079e848e5
56e3d5fa60bef6cd0ff8bd1144e409b259b54927
refs/heads/main
2023-06-13T06:43:03.215756
2021-07-07T15:20:17
2021-07-07T15:20:17
382,436,736
0
0
null
null
null
null
UTF-8
C++
false
false
434
cpp
class Solution { public: vector<bool> kidsWithCandies(vector<int>& candies, int extraCandies) { int maxi=INT_MIN; int n=candies.size(); vector<bool>v(n,false); for(int i=0;i<n;i++){ maxi=max(maxi,candies[i]); } for(int i=0;i<n;i++){ if(candies[i]+extraCandies>=maxi) v[i]=true; } return v; } };
710580c55872b05ba6b4b06623853bc8f26c58ee
67c4fd9c7c6e89602b1b184c525fb0102402df14
/i_robot-Aug21/include/i_robot/Left_or_Right.cpp
131fc3d073310572aef567fb08ef059ac584eaef
[]
no_license
WSMao/i_robot
a06a2f2e936d6f8d09822273c2519723a75179d2
3ecfdfce991821ed4ba040138ff91c6684b11d26
refs/heads/master
2020-05-21T20:27:35.529285
2016-10-13T08:42:53
2016-10-13T08:42:53
65,477,019
1
0
null
null
null
null
UTF-8
C++
false
false
985
cpp
#include<iostream> #include "i_robot/line_follower.h" #include <stdio.h> #include <stdlib.h> using namespace std; pwm_struct turn_right (imu_struct imu ,float dst){ pwm_struct pwm; float P=0.45; float D=0.001; static float old_t; static float err_old=0; float new_t; float err_new; float err_rate; float error=dst-imu.yaw; err_new=error; new_t=imu.new_t; err_rate=(err_new-err_old)/(new_t-old_t); pwm.pwm_l=error*P+err_rate*D; pwm.pwm_r=(-error)*P-err_rate*D; cout<<"avoid!!! "<< endl; cout<<"err_new: "<< err_new << endl; cout<<"err_old: "<< err_old << endl; cout<<"err_rate: "<< err_rate << endl; cout<<"pwm_l: "<< pwm.pwm_l << endl; cout<<"pwm_r: "<< pwm.pwm_r << endl; old_t=new_t; err_old=err_new; return pwm; //turn right // MOTOR.Motor_left(0,pwmL); // MOTOR.Motor_right(1,pwmR); } pwm_struct turn_left (imu_struct imu ,float dst){ }
f8d961e9a8d105a7ff20ad4a5cd6ac2e8bb0486a
5a34a43292af5af44498566f88118d71cc730ca1
/02_loopsPattern/largestOfNNumbers.cpp
90441109fd01754eeed2b7d17bed3eb5ee59d7b6
[]
no_license
bhanuraghav/Launchpad17-Fasttrack
ca9171a98035dcd50ee4ac450044acb694bef68a
ca199f6dc1ac397d9190b637f39c075c7cfab77e
refs/heads/master
2021-08-23T14:50:50.028649
2017-12-05T09:03:01
2017-12-05T09:03:01
113,196,271
1
0
null
2017-12-05T15:02:13
2017-12-05T15:02:12
null
UTF-8
C++
false
false
333
cpp
#include <iostream> using namespace std; int main(){ int N; cin >> N; int cur_num = 0; int lar_num = -1000000000; // -infinity as sentinel int cnt = 0; //No of nos read so far while(cnt < N){ cin >> cur_num; if (cur_num > lar_num){ lar_num = cur_num; } // cnt = cnt + 1; ++cnt; } cout << lar_num << endl; }
d73ac9b76e585278a671e6fd61811203dce593c2
0490d1c7ae034d3d646f6828e36416c5195fbbe0
/acmicpc/sw-1-basic/05-dp/15988/cpp_001-fail.cpp
f5db536bef18e6c9dc54022eb39fff94dd2cc920
[]
no_license
gwanduke/coding-test
d57aa7f516991b3ebc2ad041d063f083f3110dc7
5c09bd0de7a0607300c6dc77f7be0fe57c10af0d
refs/heads/main
2021-06-25T23:56:08.320411
2020-12-23T01:27:07
2020-12-23T02:29:45
300,499,186
1
0
null
null
null
null
UTF-8
C++
false
false
587
cpp
/** * https://www.acmicpc.net/problem/15988 * * 1, 2, 3 더하기 3 */ #include <iostream> using namespace std; int memo[1000001]; int go(int n) { if (n == 1) { memo[n] = 1; } if (n == 2) { memo[n] = 2; } if (n == 3) { memo[n] = 4; } if (memo[n] > 0) return memo[n]; memo[n] = (go(n - 1) + go(n - 2) + go(n - 3)); return memo[n]; } int main() { int t; cin >> t; while (t--) { int n; cin >> n; std::cout << go(n) % 1000000009 << '\n'; } return 0; }
c3fcb7d7e6952977c498b1fd66841cdcaed3d3f9
a15497a4da8bb752cd823cce3d71b4af79999364
/lang/clang33/files/patch-tools_clang_lib_Analysis_PrintfFormatString.cpp
a53bf85a108ab2dbba758f42d2cd7c64b1a686d4
[]
no_license
ejc123/DPorts
15bedf0b301850a9bd7e14338b5598260e98efeb
0caaf45c6dccdf085b42231576380a287a70a1de
refs/heads/master
2020-12-28T23:46:27.032156
2015-04-01T15:32:40
2015-04-01T15:32:40
33,254,468
0
0
null
2015-04-01T15:06:44
2015-04-01T15:06:44
null
UTF-8
C++
false
false
1,612
cpp
$FreeBSD: head/lang/clang33/files/patch-tools_clang_lib_Analysis_PrintfFormatString.cpp 340725 2014-01-22 17:40:44Z mat $ --- tools/clang/lib/Analysis/PrintfFormatString.cpp.orig +++ tools/clang/lib/Analysis/PrintfFormatString.cpp @@ -198,9 +198,10 @@ case '@': k = ConversionSpecifier::ObjCObjArg; break; // Glibc specific. case 'm': k = ConversionSpecifier::PrintErrno; break; - // Apple-specific + + // Apple-specific (and one FreeBSD) case 'D': - if (Target.getTriple().isOSDarwin()) + if (Target.getTriple().isOSDarwin() || Target.getTriple().isOSFreeBSD()) k = ConversionSpecifier::DArg; break; case 'O': @@ -211,11 +212,29 @@ if (Target.getTriple().isOSDarwin()) k = ConversionSpecifier::UArg; break; + + // FreeBSD-specific + case 'b': + if (Target.getTriple().isOSFreeBSD()) + k = ConversionSpecifier::bArg; + break; + case 'r': + if (Target.getTriple().isOSFreeBSD()) + k = ConversionSpecifier::xArg; + break; + case 'y': + if (Target.getTriple().isOSFreeBSD()) + k = ConversionSpecifier::iArg; + break; } PrintfConversionSpecifier CS(conversionPosition, k); FS.setConversionSpecifier(CS); if (CS.consumesDataArgument() && !FS.usesPositionalArg()) FS.setArgIndex(argIndex++); + // FreeBSD extension + if (Target.getTriple().isOSFreeBSD() && (k == ConversionSpecifier::bArg || + k == ConversionSpecifier::DArg)) + argIndex++; if (k == ConversionSpecifier::InvalidSpecifier) { // Assume the conversion takes one argument.
6c6e0e91cb1abad07f2320080e6700dbc31204f2
3a76ca9315406c7497503357756d893301de706a
/src/net.cpp
00b761aea15ff830f4e2ab6231f27bcb4daa139f
[ "MIT" ]
permissive
PETERDAVID12/pc4567
7f6281ed6fbd6b9246d7606bf55a97be98309ee3
5298ae9c56a1160a7b4340107484bb8b6c8533a2
refs/heads/master
2021-01-15T18:40:48.355390
2017-08-09T10:45:08
2017-08-09T10:45:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
62,231
cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "irc.h" #include "db.h" #include "net.h" #include "init.h" #include "strlcpy.h" #include "addrman.h" #include "ui_interface.h" #ifdef WIN32 #include <string.h> #endif #ifdef USE_UPNP #include <miniupnpc/miniwget.h> #include <miniupnpc/miniupnpc.h> #include <miniupnpc/upnpcommands.h> #include <miniupnpc/upnperrors.h> #endif using namespace std; using namespace boost; static const int MAX_OUTBOUND_CONNECTIONS = 16; void ThreadMessageHandler2(void* parg); void ThreadSocketHandler2(void* parg); void ThreadOpenConnections2(void* parg); void ThreadOpenAddedConnections2(void* parg); #ifdef USE_UPNP void ThreadMapPort2(void* parg); #endif void ThreadDNSAddressSeed2(void* parg); bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false); struct LocalServiceInfo { int nScore; int nPort; }; // // Global state variables // bool fDiscover = true; bool fUseUPnP = false; uint64_t nLocalServices = NODE_NETWORK; static CCriticalSection cs_mapLocalHost; static map<CNetAddr, LocalServiceInfo> mapLocalHost; static bool vfReachable[NET_MAX] = {}; static bool vfLimited[NET_MAX] = {}; static CNode* pnodeLocalHost = NULL; CAddress addrSeenByPeer(CService("0.0.0.0", 0), nLocalServices); uint64_t nLocalHostNonce = 0; boost::array<int, THREAD_MAX> vnThreadsRunning; static std::vector<SOCKET> vhListenSocket; CAddrMan addrman; vector<CNode*> vNodes; CCriticalSection cs_vNodes; map<CInv, CDataStream> mapRelay; deque<pair<int64_t, CInv> > vRelayExpiration; CCriticalSection cs_mapRelay; map<CInv, int64_t> mapAlreadyAskedFor; static deque<string> vOneShots; CCriticalSection cs_vOneShots; set<CNetAddr> setservAddNodeAddresses; CCriticalSection cs_setservAddNodeAddresses; static CSemaphore *semOutbound = NULL; void AddOneShot(string strDest) { LOCK(cs_vOneShots); vOneShots.push_back(strDest); } unsigned short GetListenPort() { return (unsigned short)(GetArg("-port", GetDefaultPort())); } void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd) { // Filter out duplicate requests if (pindexBegin == pindexLastGetBlocksBegin && hashEnd == hashLastGetBlocksEnd) return; pindexLastGetBlocksBegin = pindexBegin; hashLastGetBlocksEnd = hashEnd; PushMessage("getblocks", CBlockLocator(pindexBegin), hashEnd); } // find 'best' local address for a particular peer bool GetLocal(CService& addr, const CNetAddr *paddrPeer) { if (fNoListen) return false; int nBestScore = -1; int nBestReachability = -1; { LOCK(cs_mapLocalHost); for (map<CNetAddr, LocalServiceInfo>::iterator it = mapLocalHost.begin(); it != mapLocalHost.end(); it++) { int nScore = (*it).second.nScore; int nReachability = (*it).first.GetReachabilityFrom(paddrPeer); if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore)) { addr = CService((*it).first, (*it).second.nPort); nBestReachability = nReachability; nBestScore = nScore; } } } return nBestScore >= 0; } // get best local address for a particular peer as a CAddress CAddress GetLocalAddress(const CNetAddr *paddrPeer) { CAddress ret(CService("0.0.0.0",0),0); CService addr; if (GetLocal(addr, paddrPeer)) { ret = CAddress(addr); ret.nServices = nLocalServices; ret.nTime = GetAdjustedTime(); } return ret; } bool RecvLine(SOCKET hSocket, string& strLine) { strLine = ""; while (true) { char c; int nBytes = recv(hSocket, &c, 1, 0); if (nBytes > 0) { if (c == '\n') continue; if (c == '\r') return true; strLine += c; if (strLine.size() >= 9000) return true; } else if (nBytes <= 0) { if (fShutdown) return false; if (nBytes < 0) { int nErr = WSAGetLastError(); if (nErr == WSAEMSGSIZE) continue; if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS) { MilliSleep(10); continue; } } if (!strLine.empty()) return true; if (nBytes == 0) { // socket closed printf("socket closed\n"); return false; } else { // socket error int nErr = WSAGetLastError(); printf("recv failed: %d\n", nErr); return false; } } } } // used when scores of local addresses may have changed // pushes better local address to peers void static AdvertizeLocal() { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { if (pnode->fSuccessfullyConnected) { CAddress addrLocal = GetLocalAddress(&pnode->addr); if (addrLocal.IsRoutable() && (CService)addrLocal != (CService)pnode->addrLocal) { pnode->PushAddress(addrLocal); pnode->addrLocal = addrLocal; } } } } void SetReachable(enum Network net, bool fFlag) { LOCK(cs_mapLocalHost); vfReachable[net] = fFlag; if (net == NET_IPV6 && fFlag) vfReachable[NET_IPV4] = true; } // learn a new local address bool AddLocal(const CService& addr, int nScore) { if (!addr.IsRoutable()) return false; if (!fDiscover && nScore < LOCAL_MANUAL) return false; if (IsLimited(addr)) return false; printf("AddLocal(%s,%i)\n", addr.ToString().c_str(), nScore); { LOCK(cs_mapLocalHost); bool fAlready = mapLocalHost.count(addr) > 0; LocalServiceInfo &info = mapLocalHost[addr]; if (!fAlready || nScore >= info.nScore) { info.nScore = nScore + (fAlready ? 1 : 0); info.nPort = addr.GetPort(); } SetReachable(addr.GetNetwork()); } AdvertizeLocal(); return true; } bool AddLocal(const CNetAddr &addr, int nScore) { return AddLocal(CService(addr, GetListenPort()), nScore); } /** Make a particular network entirely off-limits (no automatic connects to it) */ void SetLimited(enum Network net, bool fLimited) { if (net == NET_UNROUTABLE) return; LOCK(cs_mapLocalHost); vfLimited[net] = fLimited; } bool IsLimited(enum Network net) { LOCK(cs_mapLocalHost); return vfLimited[net]; } bool IsLimited(const CNetAddr &addr) { return IsLimited(addr.GetNetwork()); } /** vote for a local address */ bool SeenLocal(const CService& addr) { { LOCK(cs_mapLocalHost); if (mapLocalHost.count(addr) == 0) return false; mapLocalHost[addr].nScore++; } AdvertizeLocal(); return true; } /** check whether a given address is potentially local */ bool IsLocal(const CService& addr) { LOCK(cs_mapLocalHost); return mapLocalHost.count(addr) > 0; } /** check whether a given address is in a network we can probably connect to */ bool IsReachable(const CNetAddr& addr) { LOCK(cs_mapLocalHost); enum Network net = addr.GetNetwork(); return vfReachable[net] && !vfLimited[net]; } bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const char* pszKeyword, CNetAddr& ipRet) { SOCKET hSocket; if (!ConnectSocket(addrConnect, hSocket)) return error("GetMyExternalIP() : connection to %s failed", addrConnect.ToString().c_str()); send(hSocket, pszGet, strlen(pszGet), MSG_NOSIGNAL); string strLine; while (RecvLine(hSocket, strLine)) { if (strLine.empty()) // HTTP response is separated from headers by blank line { while (true) { if (!RecvLine(hSocket, strLine)) { closesocket(hSocket); return false; } if (pszKeyword == NULL) break; if (strLine.find(pszKeyword) != string::npos) { strLine = strLine.substr(strLine.find(pszKeyword) + strlen(pszKeyword)); break; } } closesocket(hSocket); if (strLine.find("<") != string::npos) strLine = strLine.substr(0, strLine.find("<")); strLine = strLine.substr(strspn(strLine.c_str(), " \t\n\r")); while (strLine.size() > 0 && isspace(strLine[strLine.size()-1])) strLine.resize(strLine.size()-1); CService addr(strLine,0,true); printf("GetMyExternalIP() received [%s] %s\n", strLine.c_str(), addr.ToString().c_str()); if (!addr.IsValid() || !addr.IsRoutable()) return false; ipRet.SetIP(addr); return true; } } closesocket(hSocket); return error("GetMyExternalIP() : connection closed"); } // We now get our external IP from the IRC server first and only use this as a backup bool GetMyExternalIP(CNetAddr& ipRet) { CService addrConnect; const char* pszGet; const char* pszKeyword; for (int nLookup = 0; nLookup <= 1; nLookup++) for (int nHost = 1; nHost <= 2; nHost++) { // We should be phasing out our use of sites like these. If we need // replacements, we should ask for volunteers to put this simple // php file on their web server that prints the client IP: // <?php echo $_SERVER["REMOTE_ADDR"]; ?> if (nHost == 1) { addrConnect = CService("216.146.43.70",80); // checkip.dyndns.org if (nLookup == 1) { CService addrIP("checkip.dyndns.org", 80, true); if (addrIP.IsValid()) addrConnect = addrIP; } pszGet = "GET / HTTP/1.1\r\n" "Host: checkip.dyndns.org\r\n" "User-Agent: Playcoin\r\n" "Connection: close\r\n" "\r\n"; pszKeyword = "Address:"; } else if (nHost == 2) { addrConnect = CService("74.208.43.192", 80); // www.showmyip.com if (nLookup == 1) { CService addrIP("www.showmyip.com", 80, true); if (addrIP.IsValid()) addrConnect = addrIP; } pszGet = "GET /simple/ HTTP/1.1\r\n" "Host: www.showmyip.com\r\n" "User-Agent: Playcoin\r\n" "Connection: close\r\n" "\r\n"; pszKeyword = NULL; // Returns just IP address } if (GetMyExternalIP2(addrConnect, pszGet, pszKeyword, ipRet)) return true; } return false; } void ThreadGetMyExternalIP(void* parg) { // Make this thread recognisable as the external IP detection thread RenameThread("playcoin-ext-ip"); CNetAddr addrLocalHost; if (GetMyExternalIP(addrLocalHost)) { printf("GetMyExternalIP() returned %s\n", addrLocalHost.ToStringIP().c_str()); AddLocal(addrLocalHost, LOCAL_HTTP); } } void AddressCurrentlyConnected(const CService& addr) { addrman.Connected(addr); } CNode* FindNode(const CNetAddr& ip) { { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) if ((CNetAddr)pnode->addr == ip) return (pnode); } return NULL; } CNode* FindNode(std::string addrName) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) if (pnode->addrName == addrName) return (pnode); return NULL; } CNode* FindNode(const CService& addr) { { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) if ((CService)pnode->addr == addr) return (pnode); } return NULL; } CNode* ConnectNode(CAddress addrConnect, const char *pszDest) { if (pszDest == NULL) { if (IsLocal(addrConnect)) return NULL; // Look for an existing connection CNode* pnode = FindNode((CService)addrConnect); if (pnode) { pnode->AddRef(); return pnode; } } /// debug print printf("trying connection %s lastseen=%.1fhrs\n", pszDest ? pszDest : addrConnect.ToString().c_str(), pszDest ? 0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0); // Connect SOCKET hSocket; if (pszDest ? ConnectSocketByName(addrConnect, hSocket, pszDest, GetDefaultPort()) : ConnectSocket(addrConnect, hSocket)) { addrman.Attempt(addrConnect); /// debug print printf("connected %s\n", pszDest ? pszDest : addrConnect.ToString().c_str()); // Set to non-blocking #ifdef WIN32 u_long nOne = 1; if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) printf("ConnectSocket() : ioctlsocket non-blocking setting failed, error %d\n", WSAGetLastError()); #else if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR) printf("ConnectSocket() : fcntl non-blocking setting failed, error %d\n", errno); #endif // Add node CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false); pnode->AddRef(); { LOCK(cs_vNodes); vNodes.push_back(pnode); } pnode->nTimeConnected = GetTime(); return pnode; } else { return NULL; } } void CNode::CloseSocketDisconnect() { fDisconnect = true; if (hSocket != INVALID_SOCKET) { printf("disconnecting node %s\n", addrName.c_str()); closesocket(hSocket); hSocket = INVALID_SOCKET; // in case this fails, we'll empty the recv buffer when the CNode is deleted TRY_LOCK(cs_vRecvMsg, lockRecv); if (lockRecv) vRecvMsg.clear(); } } void CNode::PushVersion() { /// when NTP implemented, change to just nTime = GetAdjustedTime() int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime()); CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0))); CAddress addrMe = GetLocalAddress(&addr); RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); printf("send version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString().c_str(), addrYou.ToString().c_str(), addr.ToString().c_str()); PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe, nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight); } std::map<CNetAddr, int64_t> CNode::setBanned; CCriticalSection CNode::cs_setBanned; void CNode::ClearBanned() { setBanned.clear(); } bool CNode::IsBanned(CNetAddr ip) { bool fResult = false; { LOCK(cs_setBanned); std::map<CNetAddr, int64_t>::iterator i = setBanned.find(ip); if (i != setBanned.end()) { int64_t t = (*i).second; if (GetTime() < t) fResult = true; } } return fResult; } bool CNode::Misbehaving(int howmuch) { if (addr.IsLocal()) { printf("Warning: Local node %s misbehaving (delta: %d)!\n", addrName.c_str(), howmuch); return false; } nMisbehavior += howmuch; if (nMisbehavior >= GetArg("-banscore", 100)) { int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban printf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior); { LOCK(cs_setBanned); if (setBanned[addr] < banTime) setBanned[addr] = banTime; } CloseSocketDisconnect(); return true; } else printf("Misbehaving: %s (%d -> %d)\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior); return false; } #undef X #define X(name) stats.name = name void CNode::copyStats(CNodeStats &stats) { X(nServices); X(nLastSend); X(nLastRecv); X(nTimeConnected); X(addrName); X(nVersion); X(strSubVer); X(fInbound); X(nStartingHeight); X(nMisbehavior); } #undef X // requires LOCK(cs_vRecvMsg) bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes) { while (nBytes > 0) { // get current incomplete message, or create a new one if (vRecvMsg.empty() || vRecvMsg.back().complete()) vRecvMsg.push_back(CNetMessage(SER_NETWORK, nRecvVersion)); CNetMessage& msg = vRecvMsg.back(); // absorb network data int handled; if (!msg.in_data) handled = msg.readHeader(pch, nBytes); else handled = msg.readData(pch, nBytes); if (handled < 0) return false; pch += handled; nBytes -= handled; } return true; } int CNetMessage::readHeader(const char *pch, unsigned int nBytes) { // copy data to temporary parsing buffer unsigned int nRemaining = 24 - nHdrPos; unsigned int nCopy = std::min(nRemaining, nBytes); memcpy(&hdrbuf[nHdrPos], pch, nCopy); nHdrPos += nCopy; // if header incomplete, exit if (nHdrPos < 24) return nCopy; // deserialize to CMessageHeader try { hdrbuf >> hdr; } catch (std::exception &e) { return -1; } // reject messages larger than MAX_SIZE if (hdr.nMessageSize > MAX_SIZE) return -1; // switch state to reading message data in_data = true; return nCopy; } int CNetMessage::readData(const char *pch, unsigned int nBytes) { unsigned int nRemaining = hdr.nMessageSize - nDataPos; unsigned int nCopy = std::min(nRemaining, nBytes); if (vRecv.size() < nDataPos + nCopy) { // Allocate up to 256 KiB ahead, but never more than the total message size. vRecv.resize(std::min(hdr.nMessageSize, nDataPos + nCopy + 256 * 1024)); } memcpy(&vRecv[nDataPos], pch, nCopy); nDataPos += nCopy; return nCopy; } // requires LOCK(cs_vSend) void SocketSendData(CNode *pnode) { std::deque<CSerializeData>::iterator it = pnode->vSendMsg.begin(); while (it != pnode->vSendMsg.end()) { const CSerializeData &data = *it; assert(data.size() > pnode->nSendOffset); int nBytes = send(pnode->hSocket, &data[pnode->nSendOffset], data.size() - pnode->nSendOffset, MSG_NOSIGNAL | MSG_DONTWAIT); if (nBytes > 0) { pnode->nLastSend = GetTime(); pnode->nSendOffset += nBytes; if (pnode->nSendOffset == data.size()) { pnode->nSendOffset = 0; pnode->nSendSize -= data.size(); it++; } else { // could not send full message; stop sending more break; } } else { if (nBytes < 0) { // error int nErr = WSAGetLastError(); if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) { printf("socket send error %d\n", nErr); pnode->CloseSocketDisconnect(); } } // couldn't send anything at all break; } } if (it == pnode->vSendMsg.end()) { assert(pnode->nSendOffset == 0); assert(pnode->nSendSize == 0); } pnode->vSendMsg.erase(pnode->vSendMsg.begin(), it); } void ThreadSocketHandler(void* parg) { // Make this thread recognisable as the networking thread RenameThread("playcoin-net"); try { vnThreadsRunning[THREAD_SOCKETHANDLER]++; ThreadSocketHandler2(parg); vnThreadsRunning[THREAD_SOCKETHANDLER]--; } catch (std::exception& e) { vnThreadsRunning[THREAD_SOCKETHANDLER]--; PrintException(&e, "ThreadSocketHandler()"); } catch (...) { vnThreadsRunning[THREAD_SOCKETHANDLER]--; throw; // support pthread_cancel() } printf("ThreadSocketHandler exited\n"); } void ThreadSocketHandler2(void* parg) { printf("ThreadSocketHandler started\n"); list<CNode*> vNodesDisconnected; unsigned int nPrevNodeCount = 0; while (true) { // // Disconnect nodes // { LOCK(cs_vNodes); // Disconnect unused nodes vector<CNode*> vNodesCopy = vNodes; BOOST_FOREACH(CNode* pnode, vNodesCopy) { if (pnode->fDisconnect || (pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0 && pnode->ssSend.empty())) { // remove from vNodes vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end()); // release outbound grant (if any) pnode->grantOutbound.Release(); // close socket and cleanup pnode->CloseSocketDisconnect(); // hold in disconnected pool until all refs are released if (pnode->fNetworkNode || pnode->fInbound) pnode->Release(); vNodesDisconnected.push_back(pnode); } } // Delete disconnected nodes list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected; BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy) { // wait until threads are done using it if (pnode->GetRefCount() <= 0) { bool fDelete = false; { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) { TRY_LOCK(pnode->cs_mapRequests, lockReq); if (lockReq) { TRY_LOCK(pnode->cs_inventory, lockInv); if (lockInv) fDelete = true; } } } } if (fDelete) { vNodesDisconnected.remove(pnode); delete pnode; } } } } if (vNodes.size() != nPrevNodeCount) { nPrevNodeCount = vNodes.size(); uiInterface.NotifyNumConnectionsChanged(vNodes.size()); } // // Find which sockets have data to receive // struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 50000; // frequency to poll pnode->vSend fd_set fdsetRecv; fd_set fdsetSend; fd_set fdsetError; FD_ZERO(&fdsetRecv); FD_ZERO(&fdsetSend); FD_ZERO(&fdsetError); SOCKET hSocketMax = 0; bool have_fds = false; BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) { FD_SET(hListenSocket, &fdsetRecv); hSocketMax = max(hSocketMax, hListenSocket); have_fds = true; } { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { if (pnode->hSocket == INVALID_SOCKET) continue; { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) { // do not read, if draining write queue if (!pnode->vSendMsg.empty()) FD_SET(pnode->hSocket, &fdsetSend); else FD_SET(pnode->hSocket, &fdsetRecv); FD_SET(pnode->hSocket, &fdsetError); hSocketMax = max(hSocketMax, pnode->hSocket); have_fds = true; } } } } vnThreadsRunning[THREAD_SOCKETHANDLER]--; int nSelect = select(have_fds ? hSocketMax + 1 : 0, &fdsetRecv, &fdsetSend, &fdsetError, &timeout); vnThreadsRunning[THREAD_SOCKETHANDLER]++; if (fShutdown) return; if (nSelect == SOCKET_ERROR) { if (have_fds) { int nErr = WSAGetLastError(); printf("socket select error %d\n", nErr); for (unsigned int i = 0; i <= hSocketMax; i++) FD_SET(i, &fdsetRecv); } FD_ZERO(&fdsetSend); FD_ZERO(&fdsetError); MilliSleep(timeout.tv_usec/1000); } // // Accept new connections // BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) if (hListenSocket != INVALID_SOCKET && FD_ISSET(hListenSocket, &fdsetRecv)) { struct sockaddr_storage sockaddr; socklen_t len = sizeof(sockaddr); SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len); CAddress addr; int nInbound = 0; if (hSocket != INVALID_SOCKET) if (!addr.SetSockAddr((const struct sockaddr*)&sockaddr)) printf("Warning: Unknown socket family\n"); { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) if (pnode->fInbound) nInbound++; } if (hSocket == INVALID_SOCKET) { int nErr = WSAGetLastError(); if (nErr != WSAEWOULDBLOCK) printf("socket error accept failed: %d\n", nErr); } else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS) { closesocket(hSocket); } else if (CNode::IsBanned(addr)) { printf("connection from %s dropped (banned)\n", addr.ToString().c_str()); closesocket(hSocket); } else { printf("accepted connection %s\n", addr.ToString().c_str()); CNode* pnode = new CNode(hSocket, addr, "", true); pnode->AddRef(); { LOCK(cs_vNodes); vNodes.push_back(pnode); } } } // // Service each socket // vector<CNode*> vNodesCopy; { LOCK(cs_vNodes); vNodesCopy = vNodes; BOOST_FOREACH(CNode* pnode, vNodesCopy) pnode->AddRef(); } BOOST_FOREACH(CNode* pnode, vNodesCopy) { if (fShutdown) return; // // Receive // if (pnode->hSocket == INVALID_SOCKET) continue; if (FD_ISSET(pnode->hSocket, &fdsetRecv) || FD_ISSET(pnode->hSocket, &fdsetError)) { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) { if (pnode->GetTotalRecvSize() > ReceiveFloodSize()) { if (!pnode->fDisconnect) printf("socket recv flood control disconnect (%u bytes)\n", pnode->GetTotalRecvSize()); pnode->CloseSocketDisconnect(); } else { // typical socket buffer is 8K-64K char pchBuf[0x10000]; int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT); if (nBytes > 0) { if (!pnode->ReceiveMsgBytes(pchBuf, nBytes)) pnode->CloseSocketDisconnect(); pnode->nLastRecv = GetTime(); } else if (nBytes == 0) { // socket closed gracefully if (!pnode->fDisconnect) printf("socket closed\n"); pnode->CloseSocketDisconnect(); } else if (nBytes < 0) { // error int nErr = WSAGetLastError(); if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) { if (!pnode->fDisconnect) printf("socket recv error %d\n", nErr); pnode->CloseSocketDisconnect(); } } } } } // // Send // if (pnode->hSocket == INVALID_SOCKET) continue; if (FD_ISSET(pnode->hSocket, &fdsetSend)) { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) SocketSendData(pnode); } // // Inactivity checking // if (pnode->vSendMsg.empty()) pnode->nLastSendEmpty = GetTime(); if (GetTime() - pnode->nTimeConnected > 60) { if (pnode->nLastRecv == 0 || pnode->nLastSend == 0) { printf("socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0); pnode->fDisconnect = true; } else if (GetTime() - pnode->nLastSend > 90*60 && GetTime() - pnode->nLastSendEmpty > 90*60) { printf("socket not sending\n"); pnode->fDisconnect = true; } else if (GetTime() - pnode->nLastRecv > 90*60) { printf("socket inactivity timeout\n"); pnode->fDisconnect = true; } } } { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodesCopy) pnode->Release(); } MilliSleep(10); } } #ifdef USE_UPNP void ThreadMapPort(void* parg) { // Make this thread recognisable as the UPnP thread RenameThread("playcoin-UPnP"); try { vnThreadsRunning[THREAD_UPNP]++; ThreadMapPort2(parg); vnThreadsRunning[THREAD_UPNP]--; } catch (std::exception& e) { vnThreadsRunning[THREAD_UPNP]--; PrintException(&e, "ThreadMapPort()"); } catch (...) { vnThreadsRunning[THREAD_UPNP]--; PrintException(NULL, "ThreadMapPort()"); } printf("ThreadMapPort exited\n"); } void ThreadMapPort2(void* parg) { printf("ThreadMapPort started\n"); std::string port = strprintf("%u", GetListenPort()); const char * multicastif = 0; const char * minissdpdpath = 0; struct UPNPDev * devlist = 0; char lanaddr[64]; #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0); #else /* miniupnpc 1.6 */ int error = 0; devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error); #endif struct UPNPUrls urls; struct IGDdatas data; int r; r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); if (r == 1) { if (fDiscover) { char externalIPAddress[40]; r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress); if(r != UPNPCOMMAND_SUCCESS) printf("UPnP: GetExternalIPAddress() returned %d\n", r); else { if(externalIPAddress[0]) { printf("UPnP: ExternalIPAddress = %s\n", externalIPAddress); AddLocal(CNetAddr(externalIPAddress), LOCAL_UPNP); } else printf("UPnP: GetExternalIPAddress failed.\n"); } } string strDesc = "Playcoin " + FormatFullVersion(); #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0); #else /* miniupnpc 1.6 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0"); #endif if(r!=UPNPCOMMAND_SUCCESS) printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", port.c_str(), port.c_str(), lanaddr, r, strupnperror(r)); else printf("UPnP Port Mapping successful.\n"); int i = 1; while (true) { if (fShutdown || !fUseUPnP) { r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0); printf("UPNP_DeletePortMapping() returned : %d\n", r); freeUPNPDevlist(devlist); devlist = 0; FreeUPNPUrls(&urls); return; } if (i % 600 == 0) // Refresh every 20 minutes { #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0); #else /* miniupnpc 1.6 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0"); #endif if(r!=UPNPCOMMAND_SUCCESS) printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", port.c_str(), port.c_str(), lanaddr, r, strupnperror(r)); else printf("UPnP Port Mapping successful.\n");; } MilliSleep(2000); i++; } } else { printf("No valid UPnP IGDs found\n"); freeUPNPDevlist(devlist); devlist = 0; if (r != 0) FreeUPNPUrls(&urls); while (true) { if (fShutdown || !fUseUPnP) return; MilliSleep(2000); } } } void MapPort() { if (fUseUPnP && vnThreadsRunning[THREAD_UPNP] < 1) { if (!NewThread(ThreadMapPort, NULL)) printf("Error: ThreadMapPort(ThreadMapPort) failed\n"); } } #else void MapPort() { // Intentionally left blank. } #endif // DNS seeds // Each pair gives a source name and a seed name. // The first name is used as information source for addrman. // The second name should resolve to a list of seed addresses. static const char *strDNSSeed[][2] = { {"walletbuilders.com", "node.walletbuilders.com"}, }; void ThreadDNSAddressSeed(void* parg) { // Make this thread recognisable as the DNS seeding thread RenameThread("playcoin-dnsseed"); try { vnThreadsRunning[THREAD_DNSSEED]++; ThreadDNSAddressSeed2(parg); vnThreadsRunning[THREAD_DNSSEED]--; } catch (std::exception& e) { vnThreadsRunning[THREAD_DNSSEED]--; PrintException(&e, "ThreadDNSAddressSeed()"); } catch (...) { vnThreadsRunning[THREAD_DNSSEED]--; throw; // support pthread_cancel() } printf("ThreadDNSAddressSeed exited\n"); } void ThreadDNSAddressSeed2(void* parg) { printf("ThreadDNSAddressSeed started\n"); int found = 0; if (!fTestNet) { printf("Loading addresses from DNS seeds (could take a while)\n"); for (unsigned int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) { if (HaveNameProxy()) { AddOneShot(strDNSSeed[seed_idx][1]); } else { vector<CNetAddr> vaddr; vector<CAddress> vAdd; if (LookupHost(strDNSSeed[seed_idx][1], vaddr)) { BOOST_FOREACH(CNetAddr& ip, vaddr) { int nOneDay = 24*3600; CAddress addr = CAddress(CService(ip, GetDefaultPort())); addr.nTime = GetTime() - 3*nOneDay - GetRand(4*nOneDay); // use a random age between 3 and 7 days old vAdd.push_back(addr); found++; } } addrman.Add(vAdd, CNetAddr(strDNSSeed[seed_idx][0], true)); } } } printf("%d addresses found from DNS seeds\n", found); } unsigned int pnSeed[] = { }; void DumpAddresses() { int64_t nStart = GetTimeMillis(); CAddrDB adb; adb.Write(addrman); printf("Flushed %d addresses to peers.dat %"PRId64"ms\n", addrman.size(), GetTimeMillis() - nStart); } void ThreadDumpAddress2(void* parg) { vnThreadsRunning[THREAD_DUMPADDRESS]++; while (!fShutdown) { DumpAddresses(); vnThreadsRunning[THREAD_DUMPADDRESS]--; MilliSleep(600000); vnThreadsRunning[THREAD_DUMPADDRESS]++; } vnThreadsRunning[THREAD_DUMPADDRESS]--; } void ThreadDumpAddress(void* parg) { // Make this thread recognisable as the address dumping thread RenameThread("playcoin-adrdump"); try { ThreadDumpAddress2(parg); } catch (std::exception& e) { PrintException(&e, "ThreadDumpAddress()"); } printf("ThreadDumpAddress exited\n"); } void ThreadOpenConnections(void* parg) { // Make this thread recognisable as the connection opening thread RenameThread("playcoin-opencon"); try { vnThreadsRunning[THREAD_OPENCONNECTIONS]++; ThreadOpenConnections2(parg); vnThreadsRunning[THREAD_OPENCONNECTIONS]--; } catch (std::exception& e) { vnThreadsRunning[THREAD_OPENCONNECTIONS]--; PrintException(&e, "ThreadOpenConnections()"); } catch (...) { vnThreadsRunning[THREAD_OPENCONNECTIONS]--; PrintException(NULL, "ThreadOpenConnections()"); } printf("ThreadOpenConnections exited\n"); } void static ProcessOneShot() { string strDest; { LOCK(cs_vOneShots); if (vOneShots.empty()) return; strDest = vOneShots.front(); vOneShots.pop_front(); } CAddress addr; CSemaphoreGrant grant(*semOutbound, true); if (grant) { if (!OpenNetworkConnection(addr, &grant, strDest.c_str(), true)) AddOneShot(strDest); } } void static ThreadStakeMiner(void* parg) { printf("ThreadStakeMiner started\n"); CWallet* pwallet = (CWallet*)parg; try { vnThreadsRunning[THREAD_STAKE_MINER]++; StakeMiner(pwallet); vnThreadsRunning[THREAD_STAKE_MINER]--; } catch (std::exception& e) { vnThreadsRunning[THREAD_STAKE_MINER]--; PrintException(&e, "ThreadStakeMiner()"); } catch (...) { vnThreadsRunning[THREAD_STAKE_MINER]--; PrintException(NULL, "ThreadStakeMiner()"); } printf("ThreadStakeMiner exiting, %d threads remaining\n", vnThreadsRunning[THREAD_STAKE_MINER]); } void ThreadOpenConnections2(void* parg) { printf("ThreadOpenConnections started\n"); // Connect to specific addresses if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) { for (int64_t nLoop = 0;; nLoop++) { ProcessOneShot(); BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"]) { CAddress addr; OpenNetworkConnection(addr, NULL, strAddr.c_str()); for (int i = 0; i < 10 && i < nLoop; i++) { MilliSleep(500); if (fShutdown) return; } } MilliSleep(500); } } // Initiate network connections int64_t nStart = GetTime(); while (true) { ProcessOneShot(); vnThreadsRunning[THREAD_OPENCONNECTIONS]--; MilliSleep(500); vnThreadsRunning[THREAD_OPENCONNECTIONS]++; if (fShutdown) return; vnThreadsRunning[THREAD_OPENCONNECTIONS]--; CSemaphoreGrant grant(*semOutbound); vnThreadsRunning[THREAD_OPENCONNECTIONS]++; if (fShutdown) return; // Add seed nodes if IRC isn't working if (addrman.size()==0 && (GetTime() - nStart > 60) && !fTestNet) { std::vector<CAddress> vAdd; for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++) { // It'll only connect to one or two seed nodes because once it connects, // it'll get a pile of addresses with newer timestamps. // Seed nodes are given a random 'last seen time' of between one and two // weeks ago. const int64_t nOneWeek = 7*24*60*60; struct in_addr ip; memcpy(&ip, &pnSeed[i], sizeof(ip)); CAddress addr(CService(ip, GetDefaultPort())); addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek; vAdd.push_back(addr); } addrman.Add(vAdd, CNetAddr("127.0.0.1")); } // // Choose an address to connect to based on most recently seen // CAddress addrConnect; // Only connect out to one peer per network group (/16 for IPv4). // Do this here so we don't have to critsect vNodes inside mapAddresses critsect. int nOutbound = 0; set<vector<unsigned char> > setConnected; { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { if (!pnode->fInbound) { setConnected.insert(pnode->addr.GetGroup()); nOutbound++; } } } int64_t nANow = GetAdjustedTime(); int nTries = 0; while (true) { // use an nUnkBias between 10 (no outgoing connections) and 90 (8 outgoing connections) CAddress addr = addrman.Select(10 + min(nOutbound,8)*10); // if we selected an invalid address, restart if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr)) break; // If we didn't find an appropriate destination after trying 100 addresses fetched from addrman, // stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates // already-connected network ranges, ...) before trying new addrman addresses. nTries++; if (nTries > 100) break; if (IsLimited(addr)) continue; // only consider very recently tried nodes after 30 failed attempts if (nANow - addr.nLastTry < 600 && nTries < 30) continue; // do not allow non-default ports, unless after 50 invalid addresses selected already if (addr.GetPort() != GetDefaultPort() && nTries < 50) continue; addrConnect = addr; break; } if (addrConnect.IsValid()) OpenNetworkConnection(addrConnect, &grant); } } void ThreadOpenAddedConnections(void* parg) { // Make this thread recognisable as the connection opening thread RenameThread("playcoin-opencon"); try { vnThreadsRunning[THREAD_ADDEDCONNECTIONS]++; ThreadOpenAddedConnections2(parg); vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--; } catch (std::exception& e) { vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--; PrintException(&e, "ThreadOpenAddedConnections()"); } catch (...) { vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--; PrintException(NULL, "ThreadOpenAddedConnections()"); } printf("ThreadOpenAddedConnections exited\n"); } void ThreadOpenAddedConnections2(void* parg) { printf("ThreadOpenAddedConnections started\n"); if (mapArgs.count("-addnode") == 0) return; if (HaveNameProxy()) { while(!fShutdown) { BOOST_FOREACH(string& strAddNode, mapMultiArgs["-addnode"]) { CAddress addr; CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(addr, &grant, strAddNode.c_str()); MilliSleep(500); } vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--; MilliSleep(120000); // Retry every 2 minutes vnThreadsRunning[THREAD_ADDEDCONNECTIONS]++; } return; } vector<vector<CService> > vservAddressesToAdd(0); BOOST_FOREACH(string& strAddNode, mapMultiArgs["-addnode"]) { vector<CService> vservNode(0); if(Lookup(strAddNode.c_str(), vservNode, GetDefaultPort(), fNameLookup, 0)) { vservAddressesToAdd.push_back(vservNode); { LOCK(cs_setservAddNodeAddresses); BOOST_FOREACH(CService& serv, vservNode) setservAddNodeAddresses.insert(serv); } } } while (true) { vector<vector<CService> > vservConnectAddresses = vservAddressesToAdd; // Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry // (keeping in mind that addnode entries can have many IPs if fNameLookup) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) for (vector<vector<CService> >::iterator it = vservConnectAddresses.begin(); it != vservConnectAddresses.end(); it++) BOOST_FOREACH(CService& addrNode, *(it)) if (pnode->addr == addrNode) { it = vservConnectAddresses.erase(it); it--; break; } } BOOST_FOREACH(vector<CService>& vserv, vservConnectAddresses) { CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(CAddress(*(vserv.begin())), &grant); MilliSleep(500); if (fShutdown) return; } if (fShutdown) return; vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--; MilliSleep(120000); // Retry every 2 minutes vnThreadsRunning[THREAD_ADDEDCONNECTIONS]++; if (fShutdown) return; } } // if successful, this moves the passed grant to the constructed node bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound, const char *strDest, bool fOneShot) { // // Initiate outbound network connection // if (fShutdown) return false; if (!strDest) if (IsLocal(addrConnect) || FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) || FindNode(addrConnect.ToStringIPPort().c_str())) return false; if (strDest && FindNode(strDest)) return false; vnThreadsRunning[THREAD_OPENCONNECTIONS]--; CNode* pnode = ConnectNode(addrConnect, strDest); vnThreadsRunning[THREAD_OPENCONNECTIONS]++; if (fShutdown) return false; if (!pnode) return false; if (grantOutbound) grantOutbound->MoveTo(pnode->grantOutbound); pnode->fNetworkNode = true; if (fOneShot) pnode->fOneShot = true; return true; } void ThreadMessageHandler(void* parg) { // Make this thread recognisable as the message handling thread RenameThread("playcoin-msghand"); try { vnThreadsRunning[THREAD_MESSAGEHANDLER]++; ThreadMessageHandler2(parg); vnThreadsRunning[THREAD_MESSAGEHANDLER]--; } catch (std::exception& e) { vnThreadsRunning[THREAD_MESSAGEHANDLER]--; PrintException(&e, "ThreadMessageHandler()"); } catch (...) { vnThreadsRunning[THREAD_MESSAGEHANDLER]--; PrintException(NULL, "ThreadMessageHandler()"); } printf("ThreadMessageHandler exited\n"); } void ThreadMessageHandler2(void* parg) { printf("ThreadMessageHandler started\n"); SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL); while (!fShutdown) { vector<CNode*> vNodesCopy; { LOCK(cs_vNodes); vNodesCopy = vNodes; BOOST_FOREACH(CNode* pnode, vNodesCopy) pnode->AddRef(); } // Poll the connected nodes for messages CNode* pnodeTrickle = NULL; if (!vNodesCopy.empty()) pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())]; BOOST_FOREACH(CNode* pnode, vNodesCopy) { if (pnode->fDisconnect) continue; // Receive messages { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) if (!ProcessMessages(pnode)) pnode->CloseSocketDisconnect(); } if (fShutdown) return; // Send messages { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) SendMessages(pnode, pnode == pnodeTrickle); } if (fShutdown) return; } { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodesCopy) pnode->Release(); } // Wait and allow messages to bunch up. // Reduce vnThreadsRunning so StopNode has permission to exit while // we're sleeping, but we must always check fShutdown after doing this. vnThreadsRunning[THREAD_MESSAGEHANDLER]--; MilliSleep(100); if (fRequestShutdown) StartShutdown(); vnThreadsRunning[THREAD_MESSAGEHANDLER]++; if (fShutdown) return; } } bool BindListenPort(const CService &addrBind, string& strError) { strError = ""; int nOne = 1; #ifdef WIN32 // Initialize Windows Sockets WSADATA wsadata; int ret = WSAStartup(MAKEWORD(2,2), &wsadata); if (ret != NO_ERROR) { strError = strprintf("Error: TCP/IP socket library failed to start (WSAStartup returned error %d)", ret); printf("%s\n", strError.c_str()); return false; } #endif // Create socket for listening for incoming connections struct sockaddr_storage sockaddr; socklen_t len = sizeof(sockaddr); if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len)) { strError = strprintf("Error: bind address family for %s not supported", addrBind.ToString().c_str()); printf("%s\n", strError.c_str()); return false; } SOCKET hListenSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP); if (hListenSocket == INVALID_SOCKET) { strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %d)", WSAGetLastError()); printf("%s\n", strError.c_str()); return false; } #ifdef SO_NOSIGPIPE // Different way of disabling SIGPIPE on BSD setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int)); #endif #ifndef WIN32 // Allow binding if the port is still in TIME_WAIT state after // the program was closed and restarted. Not an issue on windows. setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int)); #endif #ifdef WIN32 // Set to non-blocking, incoming connections will also inherit this if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR) #else if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR) #endif { strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError()); printf("%s\n", strError.c_str()); return false; } // some systems don't have IPV6_V6ONLY but are always v6only; others do have the option // and enable it by default or not. Try to enable it, if possible. if (addrBind.IsIPv6()) { #ifdef IPV6_V6ONLY #ifdef WIN32 setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int)); #else setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int)); #endif #endif #ifdef WIN32 int nProtLevel = 10 /* PROTECTION_LEVEL_UNRESTRICTED */; int nParameterId = 23 /* IPV6_PROTECTION_LEVEl */; // this call is allowed to fail setsockopt(hListenSocket, IPPROTO_IPV6, nParameterId, (const char*)&nProtLevel, sizeof(int)); #endif } if (::bind(hListenSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR) { int nErr = WSAGetLastError(); if (nErr == WSAEADDRINUSE) strError = strprintf(_("Unable to bind to %s on this computer. Playcoin is probably already running."), addrBind.ToString().c_str()); else strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %d, %s)"), addrBind.ToString().c_str(), nErr, strerror(nErr)); printf("%s\n", strError.c_str()); return false; } printf("Bound to %s\n", addrBind.ToString().c_str()); // Listen for incoming connections if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR) { strError = strprintf("Error: Listening for incoming connections failed (listen returned error %d)", WSAGetLastError()); printf("%s\n", strError.c_str()); return false; } vhListenSocket.push_back(hListenSocket); if (addrBind.IsRoutable() && fDiscover) AddLocal(addrBind, LOCAL_BIND); return true; } void static Discover() { if (!fDiscover) return; #ifdef WIN32 // Get local host IP char pszHostName[1000] = ""; if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) { vector<CNetAddr> vaddr; if (LookupHost(pszHostName, vaddr)) { BOOST_FOREACH (const CNetAddr &addr, vaddr) { AddLocal(addr, LOCAL_IF); } } } #else // Get local host ip struct ifaddrs* myaddrs; if (getifaddrs(&myaddrs) == 0) { for (struct ifaddrs* ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next) { if (ifa->ifa_addr == NULL) continue; if ((ifa->ifa_flags & IFF_UP) == 0) continue; if (strcmp(ifa->ifa_name, "lo") == 0) continue; if (strcmp(ifa->ifa_name, "lo0") == 0) continue; if (ifa->ifa_addr->sa_family == AF_INET) { struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr); CNetAddr addr(s4->sin_addr); if (AddLocal(addr, LOCAL_IF)) printf("IPv4 %s: %s\n", ifa->ifa_name, addr.ToString().c_str()); } else if (ifa->ifa_addr->sa_family == AF_INET6) { struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr); CNetAddr addr(s6->sin6_addr); if (AddLocal(addr, LOCAL_IF)) printf("IPv6 %s: %s\n", ifa->ifa_name, addr.ToString().c_str()); } } freeifaddrs(myaddrs); } #endif // Don't use external IPv4 discovery, when -onlynet="IPv6" if (!IsLimited(NET_IPV4)) NewThread(ThreadGetMyExternalIP, NULL); } void StartNode(void* parg) { // Make this thread recognisable as the startup thread RenameThread("playcoin-start"); if (semOutbound == NULL) { // initialize semaphore int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, (int)GetArg("-maxconnections", 125)); semOutbound = new CSemaphore(nMaxOutbound); } if (pnodeLocalHost == NULL) pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices)); Discover(); // // Start threads // if (!GetBoolArg("-dnsseed", true)) printf("DNS seeding disabled\n"); else if (!NewThread(ThreadDNSAddressSeed, NULL)) printf("Error: NewThread(ThreadDNSAddressSeed) failed\n"); // Map ports with UPnP if (fUseUPnP) MapPort(); // Get addresses from IRC and advertise ours if (!NewThread(ThreadIRCSeed, NULL)) printf("Error: NewThread(ThreadIRCSeed) failed\n"); // Send and receive from sockets, accept connections if (!NewThread(ThreadSocketHandler, NULL)) printf("Error: NewThread(ThreadSocketHandler) failed\n"); // Initiate outbound connections from -addnode if (!NewThread(ThreadOpenAddedConnections, NULL)) printf("Error: NewThread(ThreadOpenAddedConnections) failed\n"); // Initiate outbound connections if (!NewThread(ThreadOpenConnections, NULL)) printf("Error: NewThread(ThreadOpenConnections) failed\n"); // Process messages if (!NewThread(ThreadMessageHandler, NULL)) printf("Error: NewThread(ThreadMessageHandler) failed\n"); // Dump network addresses if (!NewThread(ThreadDumpAddress, NULL)) printf("Error; NewThread(ThreadDumpAddress) failed\n"); // Mine proof-of-stake blocks in the background if (!GetBoolArg("-staking", true)) printf("Staking disabled\n"); else if (!NewThread(ThreadStakeMiner, pwalletMain)) printf("Error: NewThread(ThreadStakeMiner) failed\n"); } bool StopNode() { printf("StopNode()\n"); fShutdown = true; nTransactionsUpdated++; int64_t nStart = GetTime(); if (semOutbound) for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++) semOutbound->post(); do { int nThreadsRunning = 0; for (int n = 0; n < THREAD_MAX; n++) nThreadsRunning += vnThreadsRunning[n]; if (nThreadsRunning == 0) break; if (GetTime() - nStart > 20) break; MilliSleep(20); } while(true); if (vnThreadsRunning[THREAD_SOCKETHANDLER] > 0) printf("ThreadSocketHandler still running\n"); if (vnThreadsRunning[THREAD_OPENCONNECTIONS] > 0) printf("ThreadOpenConnections still running\n"); if (vnThreadsRunning[THREAD_MESSAGEHANDLER] > 0) printf("ThreadMessageHandler still running\n"); if (vnThreadsRunning[THREAD_RPCLISTENER] > 0) printf("ThreadRPCListener still running\n"); if (vnThreadsRunning[THREAD_RPCHANDLER] > 0) printf("ThreadsRPCServer still running\n"); #ifdef USE_UPNP if (vnThreadsRunning[THREAD_UPNP] > 0) printf("ThreadMapPort still running\n"); #endif if (vnThreadsRunning[THREAD_DNSSEED] > 0) printf("ThreadDNSAddressSeed still running\n"); if (vnThreadsRunning[THREAD_ADDEDCONNECTIONS] > 0) printf("ThreadOpenAddedConnections still running\n"); if (vnThreadsRunning[THREAD_DUMPADDRESS] > 0) printf("ThreadDumpAddresses still running\n"); if (vnThreadsRunning[THREAD_STAKE_MINER] > 0) printf("ThreadStakeMiner still running\n"); while (vnThreadsRunning[THREAD_MESSAGEHANDLER] > 0 || vnThreadsRunning[THREAD_RPCHANDLER] > 0) MilliSleep(20); MilliSleep(50); DumpAddresses(); return true; } class CNetCleanup { public: CNetCleanup() { } ~CNetCleanup() { // Close sockets BOOST_FOREACH(CNode* pnode, vNodes) if (pnode->hSocket != INVALID_SOCKET) closesocket(pnode->hSocket); BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) if (hListenSocket != INVALID_SOCKET) if (closesocket(hListenSocket) == SOCKET_ERROR) printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError()); #ifdef WIN32 // Shutdown Windows Sockets WSACleanup(); #endif } } instance_of_cnetcleanup; void RelayTransaction(const CTransaction& tx, const uint256& hash) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss.reserve(10000); ss << tx; RelayTransaction(tx, hash, ss); } void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataStream& ss) { CInv inv(MSG_TX, hash); { LOCK(cs_mapRelay); // Expire old relay messages while (!vRelayExpiration.empty() && vRelayExpiration.front().first < GetTime()) { mapRelay.erase(vRelayExpiration.front().second); vRelayExpiration.pop_front(); } // Save original serialized message so newer versions are preserved mapRelay.insert(std::make_pair(inv, ss)); vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv)); } RelayInventory(inv); }
d965b4e28fc1c7f97084da291f15ee95aea7d080
2bf472740ebe529edb0b1ba75865d9b0cf88a11c
/deps/v8/test/base-unittests/platform/platform-unittest.cc
3530ff8073a386c72ed8ebcb2de350c33227569e
[ "MIT", "bzip2-1.0.6", "BSD-3-Clause" ]
permissive
phantasien/bastian
550c07712f56e2a30c2581d778c0b8754186fc9a
2a9e739962f2fdf042581cdbfa6669aec8909b98
refs/heads/master
2022-12-15T16:03:24.846018
2015-07-08T12:39:13
2015-07-08T12:39:13
35,559,177
0
1
MIT
2022-12-08T16:57:57
2015-05-13T16:04:18
C++
UTF-8
C++
false
false
2,781
cc
// Copyright 2014 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/base/platform/platform.h" #if V8_OS_POSIX #include <unistd.h> // NOLINT #endif #if V8_OS_WIN #include "src/base/win32-headers.h" #endif #include "testing/gtest/include/gtest/gtest.h" namespace v8 { namespace base { TEST(OS, GetCurrentProcessId) { #if V8_OS_POSIX EXPECT_EQ(static_cast<int>(getpid()), OS::GetCurrentProcessId()); #endif #if V8_OS_WIN EXPECT_EQ(static_cast<int>(::GetCurrentProcessId()), OS::GetCurrentProcessId()); #endif } TEST(OS, NumberOfProcessorsOnline) { EXPECT_GT(OS::NumberOfProcessorsOnline(), 0); } namespace { class SelfJoinThread V8_FINAL : public Thread { public: SelfJoinThread() : Thread(Options("SelfJoinThread")) {} virtual void Run() V8_OVERRIDE { Join(); } }; } TEST(Thread, SelfJoin) { SelfJoinThread thread; thread.Start(); thread.Join(); } namespace { class ThreadLocalStorageTest : public Thread, public ::testing::Test { public: ThreadLocalStorageTest() : Thread(Options("ThreadLocalStorageTest")) { for (size_t i = 0; i < ARRAY_SIZE(keys_); ++i) { keys_[i] = Thread::CreateThreadLocalKey(); } } ~ThreadLocalStorageTest() { for (size_t i = 0; i < ARRAY_SIZE(keys_); ++i) { Thread::DeleteThreadLocalKey(keys_[i]); } } virtual void Run() V8_FINAL V8_OVERRIDE { for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { CHECK(!Thread::HasThreadLocal(keys_[i])); } for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { Thread::SetThreadLocal(keys_[i], GetValue(i)); } for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { CHECK(Thread::HasThreadLocal(keys_[i])); } for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { CHECK_EQ(GetValue(i), Thread::GetThreadLocal(keys_[i])); CHECK_EQ(GetValue(i), Thread::GetExistingThreadLocal(keys_[i])); } for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { Thread::SetThreadLocal(keys_[i], GetValue(ARRAY_SIZE(keys_) - i - 1)); } for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { CHECK(Thread::HasThreadLocal(keys_[i])); } for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { CHECK_EQ(GetValue(ARRAY_SIZE(keys_) - i - 1), Thread::GetThreadLocal(keys_[i])); CHECK_EQ(GetValue(ARRAY_SIZE(keys_) - i - 1), Thread::GetExistingThreadLocal(keys_[i])); } } private: static void* GetValue(size_t x) { return reinterpret_cast<void*>(static_cast<uintptr_t>(x + 1)); } Thread::LocalStorageKey keys_[256]; }; } TEST_F(ThreadLocalStorageTest, DoTest) { Run(); Start(); Join(); } } // namespace base } // namespace v8
b55eb73060a3dfefa9ba0087afe6369f86c6ca1b
212475eb02be86949cfd3e61544279ba21605eb9
/kratos/applications/SolidMechanicsApplication/custom_processes/fix_scalar_dof_process.h
4103115d5892c15457b884bd41a24c8d849d9b4a
[ "BSD-2-Clause" ]
permissive
esiwgnahz/kratos
d8e4177f4e44ac9271296faf6b8debf58973aab2
7aab56de51b1f55c4cbe47a416793d53e5cf168e
refs/heads/master
2021-06-01T17:31:35.762046
2016-10-11T18:17:22
2016-10-11T18:17:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,150
h
// // Project Name: KratosSolidMechanicsApplication $ // Created by: $Author: JMCarbonell $ // Last modified by: $Co-Author: $ // Date: $Date: August 2016 $ // Revision: $Revision: 0.0 $ // // #if !defined(KRATOS_FIX_SCALAR_DOF_PROCESS_H_INCLUDED ) #define KRATOS_FIX_SCALAR_DOF_PROCESS_H_INCLUDED // System includes // External includes // Project includes #include "includes/model_part.h" #include "includes/kratos_parameters.h" #include "processes/process.h" namespace Kratos { ///@name Kratos Classes ///@{ /// The base class for fixing scalar variable Dof or array_1d component Dof processes in Kratos. /** This function fix the variable dof belonging to all of the nodes in a given mesh */ class FixScalarDofProcess : public Process { public: ///@name Type Definitions ///@{ /// Pointer definition of FixScalarDofProcess KRATOS_CLASS_POINTER_DEFINITION(FixScalarDofProcess); ///@} ///@name Life Cycle ///@{ FixScalarDofProcess(ModelPart& model_part, Parameters rParameters ) : Process() , mr_model_part(model_part) { KRATOS_TRY Parameters default_parameters( R"( { "model_part_name":"PLEASE_CHOOSE_MODEL_PART_NAME", "mesh_id": 0, "variable_name": "PLEASE_PRESCRIBE_VARIABLE_NAME" } )" ); // Validate against defaults -- this ensures no type mismatch rParameters.ValidateAndAssignDefaults(default_parameters); mmesh_id = rParameters["mesh_id"].GetInt(); mvariable_name = rParameters["variable_name"].GetString(); if( KratosComponents< VariableComponent< VectorComponentAdaptor<array_1d<double, 3> > > >::Has(mvariable_name) ) //case of component variable { typedef VariableComponent< VectorComponentAdaptor<array_1d<double, 3> > > component_type; component_type var_component = KratosComponents< component_type >::Get(mvariable_name); if( model_part.GetNodalSolutionStepVariablesList().Has( var_component.GetSourceVariable() ) == false ) { KRATOS_THROW_ERROR(std::runtime_error,"trying to set a variable that is not in the model_part - variable name is ",mvariable_name); } } else if( KratosComponents< Variable<double> >::Has( mvariable_name ) ) //case of double variable { if( model_part.GetNodalSolutionStepVariablesList().Has( KratosComponents< Variable<double> >::Get( mvariable_name ) ) == false ) { KRATOS_THROW_ERROR(std::runtime_error,"trying to set a variable that is not in the model_part - variable name is ",mvariable_name); } } else if( KratosComponents< Variable<int> >::Has( mvariable_name ) ) //case of int variable { if( model_part.GetNodalSolutionStepVariablesList().Has( KratosComponents< Variable<int> >::Get( mvariable_name ) ) == false ) { KRATOS_THROW_ERROR(std::runtime_error,"trying to set a variable that is not in the model_part - variable name is ",mvariable_name); } } else if( KratosComponents< Variable<bool> >::Has( mvariable_name ) ) //case of bool variable { if( model_part.GetNodalSolutionStepVariablesList().Has(KratosComponents< Variable<bool> >::Get( mvariable_name ) ) == false ) { KRATOS_THROW_ERROR(std::runtime_error,"trying to set a variable that is not in the model_part - variable name is ",mvariable_name); } } KRATOS_CATCH(""); } FixScalarDofProcess(ModelPart& model_part, const Variable<double>& rVariable, std::size_t mesh_id ) : Process(), mr_model_part(model_part), mmesh_id(mesh_id) { KRATOS_TRY; if( model_part.GetNodalSolutionStepVariablesList().Has( rVariable ) == false ) { KRATOS_THROW_ERROR(std::runtime_error,"trying to set a variable that is not in the model_part - variable name is ",rVariable); } mvariable_name = rVariable.Name(); KRATOS_CATCH(""); } FixScalarDofProcess(ModelPart& model_part, const VariableComponent<VectorComponentAdaptor<array_1d<double, 3> > >& rVariable, std::size_t mesh_id ) : Process(), mr_model_part(model_part), mmesh_id(mesh_id) { KRATOS_TRY; if( model_part.GetNodalSolutionStepVariablesList().Has( rVariable.GetSourceVariable() ) == false ) { KRATOS_THROW_ERROR(std::runtime_error,"trying to set a variable that is not in the model_part - variable name is ",rVariable); } mvariable_name = rVariable.Name(); KRATOS_CATCH(""); } FixScalarDofProcess(ModelPart& model_part, const Variable< int >& rVariable, std::size_t mesh_id ) : Process(), mr_model_part(model_part), mmesh_id(mesh_id) { KRATOS_TRY; if( model_part.GetNodalSolutionStepVariablesList().Has( rVariable ) == false ) { KRATOS_THROW_ERROR(std::runtime_error,"Trying to set a variable that is not in the model_part - variable name is ",rVariable); } mvariable_name = rVariable.Name(); KRATOS_CATCH(""); } FixScalarDofProcess(ModelPart& model_part, const Variable< bool >& rVariable, std::size_t mesh_id ) : Process(), mr_model_part(model_part), mmesh_id(mesh_id) { KRATOS_TRY; if( model_part.GetNodalSolutionStepVariablesList().Has( rVariable ) == false ) { KRATOS_THROW_ERROR(std::runtime_error,"Trying to set a variable that is not in the model_part - variable name is ",rVariable); } mvariable_name = rVariable.Name(); KRATOS_CATCH(""); } /// Destructor. virtual ~FixScalarDofProcess() {} ///@} ///@name Operators ///@{ /// This operator is provided to call the process as a function and simply calls the Execute method. void operator()() { Execute(); } ///@} ///@name Operations ///@{ /// Execute method is used to execute the FixScalarDofProcess algorithms. virtual void Execute() { KRATOS_TRY; if( KratosComponents< VariableComponent< VectorComponentAdaptor<array_1d<double, 3> > > >::Has(mvariable_name) ) //case of component variable { typedef VariableComponent< VectorComponentAdaptor<array_1d<double, 3> > > component_type; component_type var_component = KratosComponents< component_type >::Get(mvariable_name); InternalFixDof< component_type >(var_component); } else if( KratosComponents< Variable<double> >::Has( mvariable_name ) ) //case of double variable { InternalFixDof<>(KratosComponents< Variable<double> >::Get(mvariable_name)); } else { KRATOS_THROW_ERROR(std::logic_error, "Not able to set the variable. Attempting to set variable:",mvariable_name); } KRATOS_CATCH(""); } /// this function is designed for being called at the beginning of the computations /// right after reading the model and the groups virtual void ExecuteInitialize() { } /// this function is designed for being execute once before the solution loop but after all of the /// solvers where built virtual void ExecuteBeforeSolutionLoop() { } /// this function will be executed at every time step BEFORE performing the solve phase virtual void ExecuteInitializeSolutionStep() { } /// this function will be executed at every time step AFTER performing the solve phase virtual void ExecuteFinalizeSolutionStep() { } /// this function will be executed at every time step BEFORE writing the output virtual void ExecuteBeforeOutputStep() { } /// this function will be executed at every time step AFTER writing the output virtual void ExecuteAfterOutputStep() { } /// this function is designed for being called at the end of the computations /// right after reading the model and the groups virtual void ExecuteFinalize() { } ///@} ///@name Access ///@{ ///@} ///@name Inquiry ///@{ ///@} ///@name Input and output ///@{ /// Turn back information as a string. virtual std::string Info() const { return "FixScalarDofProcess"; } /// Print information about this object. virtual void PrintInfo(std::ostream& rOStream) const { rOStream << "FixScalarDofProcess"; } /// Print object's data. virtual void PrintData(std::ostream& rOStream) const { } ///@} ///@name Friends ///@{ ///@} protected: ///@name Protected static Member Variables ///@{ ///@} ///@name Protected member Variables ///@{ ///@} ///@name Protected Operators ///@{ /// Copy constructor. FixScalarDofProcess(FixScalarDofProcess const& rOther); ///@} ///@name Protected Operations ///@{ ///@} ///@name Protected Access ///@{ ///@} ///@name Protected Inquiry ///@{ ///@} ///@name Protected LifeCycle ///@{ ///@} private: ///@name Static Member Variables ///@{ ///@} ///@name Member Variables ///@{ ModelPart& mr_model_part; std::string mvariable_name; std::size_t mmesh_id; ///@} ///@name Private Operators ///@{ template< class TVarType > void InternalFixDof(TVarType& rVar) { const int nnodes = mr_model_part.GetMesh(mmesh_id).Nodes().size(); if(nnodes != 0) { ModelPart::NodesContainerType::iterator it_begin = mr_model_part.GetMesh(mmesh_id).NodesBegin(); #pragma omp parallel for for(int i = 0; i<nnodes; i++) { ModelPart::NodesContainerType::iterator it = it_begin + i; it->Fix(rVar); } } } ///@} ///@name Private Operations ///@{ ///@} ///@name Private Access ///@{ /// Assignment operator. FixScalarDofProcess& operator=(FixScalarDofProcess const& rOther); ///@} ///@name Serialization ///@{ ///@name Private Inquiry ///@{ ///@} ///@name Un accessible methods ///@{ ///@} }; // Class FixScalarDofProcess ///@} ///@name Type Definitions ///@{ ///@} ///@name Input and output ///@{ /// input stream function inline std::istream& operator >> (std::istream& rIStream, FixScalarDofProcess& rThis); /// output stream function inline std::ostream& operator << (std::ostream& rOStream, const FixScalarDofProcess& rThis) { rThis.PrintInfo(rOStream); rOStream << std::endl; rThis.PrintData(rOStream); return rOStream; } ///@} } // namespace Kratos. #endif // KRATOS_FIX_SCALAR_DOF_PROCESS_H_INCLUDED defined
[ "cpuigbo@4358b7d9-91ec-4505-bf62-c3060f61107a" ]
cpuigbo@4358b7d9-91ec-4505-bf62-c3060f61107a
da956d0fd941cbd7857bf2af3bbbb4b2330b59a1
7f9f4d1fe75dc02e462d2c0871f5272fdd2b73f4
/vivado/lab4.srcs/sources_1/bd/system/ip/system_auto_us_0/src/axi_dwidth_converter.cpp
e58c5371734430860a3f7c0a65f41f6d4bb2c7d4
[]
no_license
Alec-Bakholdin-Rutgers/embedded-lab-5-for-real
54f1015a6a90cab5e46114a1d133fc699574bde7
4292c315ed511ecfffb36c3fe4e69c37e00de3cd
refs/heads/main
2023-09-01T23:54:42.338688
2021-11-11T03:01:32
2021-11-11T03:01:32
426,853,005
0
0
null
null
null
null
UTF-8
C++
false
false
21,007
cpp
// (c) Copyright 1995-2021 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. // // DO NOT MODIFY THIS FILE. #include "axi_dwidth_converter.h" #define PAYLOAD_LOG_LEVEL 3 axi_dwidth_converter::axi_dwidth_converter(sc_core::sc_module_name p_name, xsc::common_cpp::properties& m_properties) : sc_core::sc_module(p_name), m_wr_trans(nullptr), m_rd_trans(nullptr), m_response_list( nullptr),m_logger((std::string) (p_name)) { initiator_rd_socket = new xtlm::xtlm_aximm_initiator_socket( "rd_trace_socket", 32); initiator_wr_socket = new xtlm::xtlm_aximm_initiator_socket( "wr_trace_socket", 32); target_rd_socket = new xtlm::xtlm_aximm_target_socket("rd_trace_socket", 32); target_wr_socket = new xtlm::xtlm_aximm_target_socket("wr_trace_socket", 32); rd_target_util = new xtlm::xtlm_aximm_target_rd_socket_util("rd_tar_util", xtlm::aximm::TRANSACTION, 32); wr_target_util = new xtlm::xtlm_aximm_target_wr_socket_util("wr_tar_util", xtlm::aximm::TRANSACTION, 32); rd_initiator_util = new xtlm::xtlm_aximm_initiator_rd_socket_util( "rd_ini_util", xtlm::aximm::TRANSACTION, 32); wr_initiator_util = new xtlm::xtlm_aximm_initiator_wr_socket_util( "wr_ini_util", xtlm::aximm::TRANSACTION, 32); target_rd_socket->bind(rd_target_util->rd_socket); target_wr_socket->bind(wr_target_util->wr_socket); rd_initiator_util->rd_socket.bind(*initiator_rd_socket); wr_initiator_util->wr_socket.bind(*initiator_wr_socket); mem_manager = new xtlm::xtlm_aximm_mem_manager(); SI_DATA_WIDTH = m_properties.getLongLong("C_S_AXI_DATA_WIDTH")/8; MI_DATA_WIDTH = m_properties.getLongLong("C_M_AXI_DATA_WIDTH")/8; FIFO_MODE = m_properties.getLongLong("C_FIFO_MODE"); ratio = 0; //SI_DATA_WIDTH/MI_DATA_WIDTH; if(FIFO_MODE!=2) { m_axi_aclk(clk); m_axi_aresetn(resetn); } SC_METHOD(wr_handler); dont_initialize(); sensitive << wr_target_util->transaction_available; sensitive << event_trig_wr_handler; SC_METHOD(rd_handler); dont_initialize(); sensitive << rd_target_util->addr_available; sensitive << event_trig_rd_handler; SC_METHOD(m_downsize_interface_txn_sender); sensitive << event_downsize_trig_txn_sender; sensitive << wr_initiator_util->transaction_sampled; sensitive << rd_initiator_util->transaction_sampled; dont_initialize(); SC_METHOD(m_upsize_interface_txn_sender); sensitive << event_upsize_trig_txn_sender; dont_initialize(); SC_METHOD(m_downsize_interface_response_sender); dont_initialize(); sensitive << wr_initiator_util->resp_available; sensitive << rd_initiator_util->data_available; sensitive << rd_target_util->data_sampled; sensitive << wr_target_util->resp_sampled; SC_METHOD(m_upsize_interface_response_sender); dont_initialize(); sensitive << wr_initiator_util->resp_available; sensitive << rd_initiator_util->data_available; sensitive << rd_target_util->data_sampled; sensitive << wr_target_util->resp_sampled; } void axi_dwidth_converter::wr_handler() { if(wr_initiator_util->is_slave_ready() && wr_target_util->is_trans_available() ) { m_wr_trans = wr_target_util->get_transaction(); m_log_msg = "Sampled Write transaction on slave interface : " + std::to_string(m_wr_trans->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::001",m_log_msg.c_str(), DEBUG); ratio = m_wr_trans->get_burst_size() / MI_DATA_WIDTH; if (ratio <= 1) wr_upsizing(); else wr_downsizing(); } } void axi_dwidth_converter::rd_handler() { if(rd_initiator_util->is_slave_ready() && rd_target_util->is_trans_available() ) { m_rd_trans = rd_target_util->get_transaction(); m_log_msg = "Sampled Read transaction on slave interface : " + std::to_string( m_rd_trans->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::001",m_log_msg.c_str(), DEBUG); ratio = m_rd_trans->get_burst_size() / MI_DATA_WIDTH; if (ratio <= 1) rd_upsizing(); else rd_downsizing(); } } void axi_dwidth_converter::rd_downsizing() { auto beat_l = m_rd_trans->get_burst_length(); auto data = m_rd_trans->get_data_ptr(); auto new_beat_l = beat_l * (ratio); auto strb = m_rd_trans->get_byte_enable_ptr(); auto s_addr = m_rd_trans->get_address(); auto num_byte_counter = 0; auto total_num_bytes = beat_l * m_rd_trans->get_burst_size(); auto cur_beat_l = 0; auto t_total_txns = 0; std::string payload_log; m_rd_trans->get_log(payload_log, PAYLOAD_LOG_LEVEL); m_log_msg = "Down Sizing input transaction : " + payload_log; XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::002",m_log_msg.c_str(), DEBUG); m_response_list = new std::list<xtlm::aximm_payload*>; do { if (new_beat_l > 256) cur_beat_l = 256; else cur_beat_l = new_beat_l; xtlm::aximm_payload* t_trans = mem_manager->get_payload(); t_trans->acquire(); t_trans->deep_copy_from(*m_rd_trans); t_trans->set_address(s_addr + num_byte_counter); t_trans->set_data_ptr(data + num_byte_counter, cur_beat_l * MI_DATA_WIDTH); t_trans->set_burst_size(MI_DATA_WIDTH); if (strb != nullptr) t_trans->set_byte_enable_ptr(strb + num_byte_counter, cur_beat_l * MI_DATA_WIDTH); t_trans->set_burst_length(cur_beat_l); num_byte_counter += cur_beat_l * MI_DATA_WIDTH ; m_interface_rd_payload_queue.push(t_trans); m_response_list->push_back(t_trans); t_total_txns++; std::string payload_log; t_trans->get_log(payload_log, PAYLOAD_LOG_LEVEL); m_log_msg = "Down sized output transaction : " + payload_log; XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::002",m_log_msg.c_str(), DEBUG); } while (num_byte_counter < total_num_bytes); m_response_mapper_downsize[m_rd_trans] = m_response_list; event_downsize_trig_txn_sender.notify(); } void axi_dwidth_converter::wr_downsizing() { auto beat_l = m_wr_trans->get_burst_length(); auto data = m_wr_trans->get_data_ptr(); auto strb = m_wr_trans->get_byte_enable_ptr(); auto new_beat_l = beat_l * (ratio); auto s_addr = m_wr_trans->get_address(); auto num_byte_counter = 0; auto total_num_bytes = beat_l * m_wr_trans->get_burst_size(); auto cur_beat_l = 0; auto t_total_txns = 0; m_response_list = new std::list<xtlm::aximm_payload*>; std::string payload_log; m_wr_trans->get_log(payload_log, PAYLOAD_LOG_LEVEL); m_log_msg = "Down Sizing input transaction : " + payload_log; XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::002",m_log_msg.c_str(), DEBUG); do { if (new_beat_l > 256) cur_beat_l = 256; else cur_beat_l = new_beat_l; xtlm::aximm_payload* t_trans = mem_manager->get_payload(); t_trans->acquire(); t_trans->deep_copy_from(*m_wr_trans); t_trans->set_address(s_addr + num_byte_counter); t_trans->set_data_ptr(data + num_byte_counter, cur_beat_l * MI_DATA_WIDTH); if (strb != nullptr) t_trans->set_byte_enable_ptr(strb + num_byte_counter, cur_beat_l * MI_DATA_WIDTH ); t_trans->set_burst_size(MI_DATA_WIDTH ); t_trans->set_burst_length(cur_beat_l); num_byte_counter += cur_beat_l * MI_DATA_WIDTH; m_interface_wr_payload_queue.push(t_trans); m_response_list->push_back(t_trans); t_total_txns++; std::string payload_log; t_trans->get_log(payload_log, PAYLOAD_LOG_LEVEL); m_log_msg = "Down sized output transaction : " + payload_log; XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::002",m_log_msg.c_str(), DEBUG); } while (num_byte_counter < total_num_bytes); m_response_mapper_downsize[m_wr_trans] = m_response_list; event_downsize_trig_txn_sender.notify(); } void axi_dwidth_converter::m_downsize_interface_txn_sender() { sc_core::sc_time zero_delay = SC_ZERO_TIME; if (wr_initiator_util->is_slave_ready() && (m_interface_wr_payload_queue.size() != 0)) { m_log_msg = "Sending Write transaction " + std::to_string(m_interface_wr_payload_queue.front()->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::003",m_log_msg.c_str(), DEBUG); wr_initiator_util->send_transaction( *m_interface_wr_payload_queue.front(), zero_delay); m_interface_wr_payload_queue.pop(); } //For Read transaction zero_delay = SC_ZERO_TIME; if (rd_initiator_util->is_slave_ready() && (m_interface_rd_payload_queue.size() != 0)) { m_log_msg = "Sending Read transaction " + std::to_string(m_interface_rd_payload_queue.front()->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::003",m_log_msg.c_str(), DEBUG); rd_initiator_util->send_transaction( *m_interface_rd_payload_queue.front(), zero_delay); m_interface_rd_payload_queue.pop(); } } void axi_dwidth_converter::m_downsize_interface_response_sender() { if (ratio <= 1) return; if (wr_initiator_util->is_resp_available() && (m_response_mapper_downsize.size() != 0) && (wr_target_util->is_master_ready())) { xtlm::aximm_payload* response_payld = wr_initiator_util->get_resp(); m_log_msg = "Sampled Response for Write : " + std::to_string(response_payld->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::003",m_log_msg.c_str(), DEBUG); std::list<xtlm::aximm_payload*>::iterator itrlist; std::map<xtlm::aximm_payload*, std::list<xtlm::aximm_payload*>*>::iterator itr; for (itr = m_response_mapper_downsize.begin(); itr != m_response_mapper_downsize.end(); itr++) { itrlist = (std::find(itr->second->begin(), itr->second->end(), response_payld)); if (itrlist != itr->second->end()) { itr->second->remove(response_payld); if (itr->second->size() == 0) { sc_core::sc_time zero_delay = SC_ZERO_TIME; itr->first->set_axi_response_status( response_payld->get_axi_response_status()); m_log_msg = "Sending Response for Write : " + std::to_string(itr->first->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::003",m_log_msg.c_str(), DEBUG); wr_target_util->send_resp(*(itr->first), zero_delay); delete (itr->second); m_response_mapper_downsize.erase(itr); event_trig_wr_handler.notify(sc_core::SC_ZERO_TIME); break; } response_payld->release(); } } } if (rd_initiator_util->is_data_available() && (m_response_mapper_downsize.size() != 0) && (rd_target_util->is_master_ready())) { xtlm::aximm_payload* response_payld = rd_initiator_util->get_data(); m_log_msg = "Sampled Response for Read : " + std::to_string(response_payld->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::003",m_log_msg.c_str(), DEBUG); std::list<xtlm::aximm_payload*>::iterator itrlist; std::map<xtlm::aximm_payload*, std::list<xtlm::aximm_payload*>*>::iterator itr; for (itr = m_response_mapper_downsize.begin(); itr != m_response_mapper_downsize.end(); itr++) { itrlist = (std::find(itr->second->begin(), itr->second->end(), response_payld)); if (itrlist != itr->second->end()) { itr->second->remove(response_payld); if (itr->second->size() == 0) { sc_core::sc_time zero_delay = SC_ZERO_TIME; itr->first->set_axi_response_status( response_payld->get_axi_response_status()); m_log_msg = "Sending Response for Read : " + std::to_string(itr->first->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::003",m_log_msg.c_str(), DEBUG); rd_target_util->send_data(*(itr->first), zero_delay); delete (itr->second); event_trig_rd_handler.notify(sc_core::SC_ZERO_TIME); m_response_mapper_downsize.erase(itr); break; } //Release the transaction to memory manager response_payld->release(); } } } } void axi_dwidth_converter::wr_upsizing() { auto si_addr = m_wr_trans->get_address(); auto si_burst_len = m_wr_trans->get_burst_length(); auto si_burst_size = m_wr_trans->get_burst_size(); auto strb = m_wr_trans->get_byte_enable_ptr(); auto data = m_wr_trans->get_data_ptr(); auto aligned_start = (si_addr / MI_DATA_WIDTH) * MI_DATA_WIDTH; auto aligned_end = ((((si_addr / SI_DATA_WIDTH) * SI_DATA_WIDTH) + (si_burst_len - 1) * si_burst_size) / MI_DATA_WIDTH) * MI_DATA_WIDTH; auto mi_len = (aligned_end - aligned_start) / MI_DATA_WIDTH + 1; xtlm::aximm_payload* t_trans = mem_manager->get_payload(); t_trans->acquire(); t_trans->deep_copy_from(*m_wr_trans); t_trans->set_address(si_addr); t_trans->set_data_ptr(data, mi_len * MI_DATA_WIDTH ); if (strb != nullptr) t_trans->set_byte_enable_ptr(strb, mi_len * MI_DATA_WIDTH); t_trans->set_burst_size(MI_DATA_WIDTH ); t_trans->set_burst_length(mi_len); m_upsize_wr_payld_queue.push(t_trans); m_response_mapper_upsize[t_trans] = m_wr_trans; m_log_msg = "Upsizing input Txn "; std::string payload_log; m_wr_trans->get_log(payload_log, PAYLOAD_LOG_LEVEL); m_log_msg += payload_log; XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::004",m_log_msg.c_str(), DEBUG); m_log_msg = "Upsized output Txn "; t_trans->get_log(payload_log, PAYLOAD_LOG_LEVEL); m_log_msg += payload_log; XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::004",m_log_msg.c_str(), DEBUG); event_upsize_trig_txn_sender.notify(); } void axi_dwidth_converter::rd_upsizing() { auto si_addr = m_rd_trans->get_address(); auto si_burst_len = m_rd_trans->get_burst_length(); auto si_burst_size = m_rd_trans->get_burst_size(); auto strb = m_rd_trans->get_byte_enable_ptr(); auto data = m_rd_trans->get_data_ptr(); auto aligned_start = (si_addr / MI_DATA_WIDTH) * MI_DATA_WIDTH; auto aligned_end = ((((si_addr / SI_DATA_WIDTH) * SI_DATA_WIDTH) + (si_burst_len - 1) * si_burst_size) / MI_DATA_WIDTH) * MI_DATA_WIDTH; auto mi_len = (aligned_end - aligned_start) / MI_DATA_WIDTH + 1; xtlm::aximm_payload* t_trans = mem_manager->get_payload(); t_trans->acquire(); t_trans->deep_copy_from(*m_rd_trans); t_trans->set_address(si_addr); t_trans->set_data_ptr(data, mi_len * MI_DATA_WIDTH ); if (strb != nullptr) t_trans->set_byte_enable_ptr(strb, mi_len * MI_DATA_WIDTH); t_trans->set_burst_size(MI_DATA_WIDTH); t_trans->set_burst_length(mi_len); m_upsize_rd_payld_queue.push(t_trans); m_response_mapper_upsize[t_trans] = m_rd_trans; m_log_msg = "Upsizing input Txn "; std::string payload_log; m_rd_trans->get_log(payload_log, PAYLOAD_LOG_LEVEL); m_log_msg += payload_log; XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::004",m_log_msg.c_str(), DEBUG); m_log_msg = "Upsized output Txn "; t_trans->get_log(payload_log, PAYLOAD_LOG_LEVEL); m_log_msg += payload_log; XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::004",m_log_msg.c_str(), DEBUG); event_upsize_trig_txn_sender.notify(); } void axi_dwidth_converter::m_upsize_interface_txn_sender() { sc_core::sc_time zero_delay = SC_ZERO_TIME; if (wr_initiator_util->is_slave_ready() && (m_upsize_wr_payld_queue.size() != 0)) { m_log_msg = "Sending Write transaction " + std::to_string(m_upsize_wr_payld_queue.front()->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::005",m_log_msg.c_str(), DEBUG); wr_initiator_util->send_transaction(*m_upsize_wr_payld_queue.front(), zero_delay); m_upsize_wr_payld_queue.pop(); } //For Read transaction zero_delay = SC_ZERO_TIME; if (rd_initiator_util->is_slave_ready() && (m_upsize_rd_payld_queue.size() != 0)) { m_log_msg = "Sending Read transaction " + std::to_string(m_upsize_rd_payld_queue.front()->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::005",m_log_msg.c_str(), DEBUG); rd_initiator_util->send_transaction(*m_upsize_rd_payld_queue.front(), zero_delay); m_upsize_rd_payld_queue.pop(); } } void axi_dwidth_converter::m_upsize_interface_response_sender() { if (ratio > 1) return; if (wr_initiator_util->is_resp_available() && (m_response_mapper_upsize.size() != 0) && (wr_target_util->is_master_ready())) { xtlm::aximm_payload* response_payld = wr_initiator_util->get_resp(); m_log_msg = "Sampled Response for Write : " + std::to_string(response_payld->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::006",m_log_msg.c_str(), DEBUG); std::map<xtlm::aximm_payload*, xtlm::aximm_payload*>::iterator itr; itr = (m_response_mapper_upsize.find(response_payld)); if (itr != m_response_mapper_upsize.end()) { sc_core::sc_time zero_delay = SC_ZERO_TIME; m_response_mapper_upsize[response_payld]->set_axi_response_status( response_payld->get_axi_response_status()); m_log_msg = "Sending Response for Write : " + std::to_string(m_response_mapper_upsize[response_payld]->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::006",m_log_msg.c_str(), DEBUG); wr_target_util->send_resp(*m_response_mapper_upsize[response_payld], zero_delay); response_payld->release(); m_response_mapper_upsize.erase(response_payld); event_trig_wr_handler.notify(sc_core::SC_ZERO_TIME); } } if (rd_initiator_util->is_data_available() && (m_response_mapper_upsize.size() != 0) && (rd_target_util->is_master_ready())) { xtlm::aximm_payload* response_payld = rd_initiator_util->get_data(); m_log_msg = "Sampled Response for Read : " + std::to_string(response_payld->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::006",m_log_msg.c_str(), DEBUG); std::map<xtlm::aximm_payload*, xtlm::aximm_payload*>::iterator itr; itr = m_response_mapper_upsize.find(response_payld); if (itr != m_response_mapper_upsize.end()) { sc_core::sc_time zero_delay = SC_ZERO_TIME; m_response_mapper_upsize[response_payld]->set_axi_response_status( response_payld->get_axi_response_status()); m_log_msg = "Sending Response for Read : " + std::to_string(m_response_mapper_upsize[response_payld]->get_address()); XSC_REPORT_INFO_VERB(m_logger, "DWIDTH::006",m_log_msg.c_str(), DEBUG); rd_target_util->send_data(*m_response_mapper_upsize[response_payld], zero_delay); response_payld->release(); m_response_mapper_upsize.erase(response_payld); event_trig_rd_handler.notify(sc_core::SC_ZERO_TIME); } } } axi_dwidth_converter::~axi_dwidth_converter() { delete mem_manager; delete target_rd_socket; delete target_wr_socket; delete initiator_rd_socket; delete initiator_wr_socket; delete rd_target_util; delete wr_target_util; delete wr_initiator_util; delete rd_initiator_util; delete m_rd_trans; delete m_wr_trans; }
d4ba9180de3749753e9006ab6a64c6f41b20fb7f
0bb6c07fa67ad833c5419cf927e5561813c70d88
/led_cube/patterns/shooting_star/shooting_star.ino
5bc57720285c3fdb57d26773d9e6c1230745f7f3
[]
no_license
KCY1999/Arduino-LEDCUBE
568a511dda035d35bec199101b6daf9655a7064d
bb3896028fd5bb5c569749a68f9d1ce6bc45957c
refs/heads/master
2023-08-19T07:50:12.879071
2021-10-10T15:46:56
2021-10-10T15:46:56
415,628,672
0
0
null
null
null
null
UTF-8
C++
false
false
12,764
ino
//4x4x4 LED Cube Show 1 //This one was written by someone else, i dont know who, however if you want credit, message me! #include <avr/pgmspace.h> // allows use of PROGMEM to store patterns in flash #define CUBESIZE 4 #define PLANESIZE CUBESIZE*CUBESIZE #define PLANETIME 2000 // time each plane is displayed in us -> 100 Hz refresh #define TIMECONST 10// multiplies DisplayTime to get ms - why not =100? // LED Pattern Table in PROGMEM - last column is display time in 100ms units // TODO this could be a lot more compact but not with binary pattern representation const unsigned char PROGMEM PatternTable[] = { // blink on and off //Floor: //1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 //Row: //1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 //Marius shoting star B0000,B0000,B0000,B0100 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0100 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0100 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0100 , 10, B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 , 10, B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 , 10, B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 , 10, B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 , 10, B0000,B0000,B0100,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0100,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0100,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0100,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 , 10, B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0001,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0001,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 , 10, B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 , 10, B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 , 10, B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0001,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 , 10, B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0001,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0100,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0100,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0100,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 , 10, B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0001,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0001,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0001,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 , 10, B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 , 10, B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0001,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B1000,B0000 , 10, B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 ,B0000,B0000,B0000,B0000 , 10, B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B0000 ,B0000,B0000,B0000,B1000 , 10, // this is a dummy element for end of table (duration=0) aka !!!DO NOT TOUCH!!! B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 0 }; /* ** Defining pins in array makes it easier to rearrange how cube is wired ** Adjust numbers here until LEDs flash in order - L to R, T to B ** Note that analog inputs 0-5 are also digital outputs 14-19! ** Pin DigitalOut0 (serial RX) and AnalogIn5 are left open for future apps */ int LEDPin[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, A0, A1}; int PlanePin[] = {A4, A5, A2, A3}; // initialization void setup() { int pin; // loop counter // set up LED pins as output (active HIGH) for (pin=0; pin<PLANESIZE; pin++) { pinMode( LEDPin[pin], OUTPUT ); } // set up plane pins as outputs (active LOW) for (pin=0; pin<CUBESIZE; pin++) { pinMode( PlanePin[pin], OUTPUT ); } } // display pattern in table until DisplayTime is zero (then repeat) void loop() { // declare variables byte PatternBuf[PLANESIZE]; // saves current pattern from PatternTable int PatternIdx; byte DisplayTime; // time*100ms to display pattern unsigned long EndTime; int plane; // loop counter for cube refresh int patbufidx; // indexes which byte from pattern buffer int ledrow; // counts LEDs in refresh loop int ledcol; // counts LEDs in refresh loop int ledpin; // counts LEDs in refresh loop // Initialize PatternIdx to beginning of pattern table PatternIdx = 0; // loop over entries in pattern table - while DisplayTime>0 do { // read pattern from PROGMEM and save in array memcpy_P( PatternBuf, PatternTable+PatternIdx, PLANESIZE ); PatternIdx += PLANESIZE; // read DisplayTime from PROGMEM and increment index DisplayTime = pgm_read_byte_near( PatternTable + PatternIdx++ ); // compute EndTime from current time (ms) and DisplayTime EndTime = millis() + ((unsigned long) DisplayTime) * TIMECONST; // loop while DisplayTime>0 and current time < EndTime while ( millis() < EndTime ) { patbufidx = 0; // reset index counter to beginning of buffer // loop over planes for (plane=0; plane<CUBESIZE; plane++) { // turn previous plane off if (plane==0) { digitalWrite( PlanePin[CUBESIZE-1], LOW ); } else { digitalWrite( PlanePin[plane-1], LOW ); } // load current plane pattern data into ports ledpin = 0; for (ledrow=0; ledrow<CUBESIZE; ledrow++) { for (ledcol=0; ledcol<CUBESIZE; ledcol++) { digitalWrite( LEDPin[ledpin++], PatternBuf[patbufidx] & (1 << ledcol) ); } patbufidx++; } // turn current plane on digitalWrite( PlanePin[plane], HIGH ); // delay PLANETIME us delayMicroseconds( PLANETIME ); } // for plane } // while <EndTime } while (DisplayTime > 0); // read patterns until time=0 which signals end }
844c60919aab298b0ec2a816db0eccac5b72a128
30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a
/contest/1542591540.cpp
2b5ae6b8521f719d8d4e03d9a47fbd0d4bb8d61d
[]
no_license
thegamer1907/Code_Analysis
0a2bb97a9fb5faf01d983c223d9715eb419b7519
48079e399321b585efc8a2c6a84c25e2e7a22a61
refs/heads/master
2020-05-27T01:20:55.921937
2019-11-20T11:15:11
2019-11-20T11:15:11
188,403,594
2
1
null
null
null
null
UTF-8
C++
false
false
629
cpp
#include<bits/stdc++.h> #define x first #define y second #define m_p make_pair using namespace std; typedef long long LL; int main(void){ char s1,s2; s1=getchar(); s2=getchar(); int n; scanf("%d",&n); bool h1=false,h2=false; for (int i=1;i<=n;i++){ char c=getchar(); char n1,n2; while(c==10){ c=getchar(); } n1=c; n2=getchar(); if (n1==s1&&n2==s2){ printf("YES"); return 0; } if (n1==s2) h1=1; if (n2==s1) h2=1; } if (h1&&h2){ printf("YES"); } else{ printf("NO"); } return 0; }
bc97f98ac42dd9b1f8ac6788afa30e0f5ff686a3
4ad2ec9e00f59c0e47d0de95110775a8a987cec2
/_infoarena/---.Tarnacop/main.cpp
bd00212ba2cc7d31697ead5fa930357bf3daee8a
[]
no_license
atatomir/work
2f13cfd328e00275672e077bba1e84328fccf42f
e8444d2e48325476cfbf0d4cfe5a5aa1efbedce9
refs/heads/master
2021-01-23T10:03:44.821372
2021-01-17T18:07:15
2021-01-17T18:07:15
33,084,680
2
1
null
2015-08-02T20:16:02
2015-03-29T18:54:24
C++
UTF-8
C++
false
false
1,801
cpp
#include <iostream> #include <cstdio> #include <vector> #include <stack> #include <algorithm> using namespace std; #define maxN 100011 #define mp make_pair #define xx first #define yy second long n,m,s,d,i,C,I,x,y; vector<long> list[maxN],rlist[maxN]; vector<pair<long,long> > mb,ans; bool used[maxN]; stack<long> S; long ap[maxN],def; void dfs(long node){ used[node] = true; for(long i=0;i<list[node].size();i++){ long newNode = list[node][i]; if(used[newNode]) continue; dfs(newNode); } S.push(node); } void dfs2(long node){ ap[node]=def; for(long i=0;i<rlist[node].size();i++){ long newNode = rlist[node][i]; if(ap[newNode]) continue; dfs2(newNode); } } void Strong(){ long i; for(i=1;i<=n;i++){ if(used[i]) continue; dfs(i); } while(!S.empty()){ long node = S.top(); S.pop(); if(ap[node]) continue; def++; dfs2(node); } } int main() { freopen("tarnacop.in","r",stdin); freopen("tarnacop.out","w",stdout); scanf("%ld%ld%ld%ld",&n,&m,&s,&d); for(i=1;i<=m;i++){ scanf("%ld%ld%ld%ld",&x,&y,&C,&I); if(C==0) continue; if(C==I) { mb.push_back(mp(x,y)); list[y].push_back(x); rlist[x].push_back(y); } else { list[x].push_back(y); if(I) list[y].push_back(x); if(I)rlist[x].push_back(y); rlist[y].push_back(x); } } Strong(); for(i=0;i<mb.size();i++){ pair<long,long> edge=mb[i]; if(ap[edge.xx]!=ap[edge.yy]) ans.push_back(edge); } sort(ans.begin(),ans.end()); printf("%ld\n",ans.size()); for(i=0;i<ans.size();i++) printf("%ld %ld\n",ans[i].xx,ans[i].yy); return 0; }
c0ff526f2ae8240fddbc4b8a445371cd9390e18d
eaa3f1fc2ee639a5cbcad36407c1e6525be51f2f
/BSM207 - VERİ YAPILARI/lab12-heap_ağacı/Lab12-Heap Ağacı/src/Test.cpp
3b6938b93fd220091b818e16bbffcf6ea0a25fb5
[]
no_license
Universite-Ders-Notlari/Sakarya-Universitesi-Ders-Notlari
77001f5632bc74433ed94ab32d860bb065e4e615
806297db9c5b6fdd61e626a559dbabf4b13b5805
refs/heads/main
2023-04-22T10:08:37.470892
2021-05-08T22:03:22
2021-05-08T22:03:22
365,607,527
8
0
null
null
null
null
UTF-8
C++
false
false
510
cpp
#include "HeapTree.hpp" #include <cstdlib> int main(){ HeapTree *heapAgaci = new HeapTree(100); int *dizi = new int[25]; cout<<"Dizi ilk Hali:"<<endl; for(int i=0;i<25;i++){ dizi[i] = rand()%100 + 1; heapAgaci->Ekle(dizi[i]); cout<<dizi[i]<<" "; } int indeks=0; while(!heapAgaci->Bosmu()) dizi[indeks++]=heapAgaci->EnKucuguCikar(); cout<<endl<<"Dizi Siralanmis Hali:"<<endl; for(int i=0;i<25;i++){ cout<<dizi[i]<<" "; } cout<<endl; delete heapAgaci; return 0; }
8bff420bc0e0608a6536481ce448ba5cda101b33
89d5cda3b789dca4e587812b1153cba55084118d
/src/RcppExports.cpp
34ff9da14184b3b0a4bec4eae6773eae8ee2d70b
[]
no_license
yechchi/M2algorithmique
21fc4ec6f0c3420ca0523cdf80fa3b4509bfc319
93044c3bce2d4386ac9352b43a3157bb86b27f9c
refs/heads/main
2023-01-03T20:04:56.045453
2020-11-04T16:37:00
2020-11-04T16:37:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,034
cpp
// Generated by using Rcpp::compileAttributes() -> do not edit by hand // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 #include <Rcpp.h> using namespace Rcpp; // insertion_sort_Rcpp std::vector<double> insertion_sort_Rcpp(std::vector<double> v); RcppExport SEXP _M2algorithmique_insertion_sort_Rcpp(SEXP vSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< std::vector<double> >::type v(vSEXP); rcpp_result_gen = Rcpp::wrap(insertion_sort_Rcpp(v)); return rcpp_result_gen; END_RCPP } // build_heap_Rcpp NumericVector build_heap_Rcpp(NumericVector heap, unsigned int i, unsigned int n); RcppExport SEXP _M2algorithmique_build_heap_Rcpp(SEXP heapSEXP, SEXP iSEXP, SEXP nSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< NumericVector >::type heap(heapSEXP); Rcpp::traits::input_parameter< unsigned int >::type i(iSEXP); Rcpp::traits::input_parameter< unsigned int >::type n(nSEXP); rcpp_result_gen = Rcpp::wrap(build_heap_Rcpp(heap, i, n)); return rcpp_result_gen; END_RCPP } // heap_sort_Rcpp NumericVector heap_sort_Rcpp(NumericVector v); RcppExport SEXP _M2algorithmique_heap_sort_Rcpp(SEXP vSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< NumericVector >::type v(vSEXP); rcpp_result_gen = Rcpp::wrap(heap_sort_Rcpp(v)); return rcpp_result_gen; END_RCPP } static const R_CallMethodDef CallEntries[] = { {"_M2algorithmique_insertion_sort_Rcpp", (DL_FUNC) &_M2algorithmique_insertion_sort_Rcpp, 1}, {"_M2algorithmique_build_heap_Rcpp", (DL_FUNC) &_M2algorithmique_build_heap_Rcpp, 3}, {"_M2algorithmique_heap_sort_Rcpp", (DL_FUNC) &_M2algorithmique_heap_sort_Rcpp, 1}, {NULL, NULL, 0} }; RcppExport void R_init_M2algorithmique(DllInfo *dll) { R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); R_useDynamicSymbols(dll, FALSE); }
4c803d1ff895fc2ffa2f43af6fcb0b619ad3e480
1cedf5abe49887cf7a3b733231880413ec209252
/TinyGame/Poker/FCSolver/FCSRandomDFSSolvingAlgorithm.h
fc7e79925698c1dd01210c4a0f7381b357bc0b51
[]
no_license
uvbs/GameProject
67d9f718458e0da636be4ad293c9e92a721a8921
0105e36971950916019a970df1b4955835e121ce
refs/heads/master
2020-04-14T22:35:24.643887
2015-09-02T06:55:54
2015-09-02T06:55:54
42,047,051
1
0
null
2015-09-07T10:34:34
2015-09-07T10:34:33
null
UTF-8
C++
false
false
9,247
h
#ifndef FCS_RANDOM_DFS_SOLVING_ALGORITHM_H #define FCS_RANDOM_DFS_SOLVING_ALGORITHM_H //////////////////////////////////////////////// ///\file FCSRandomDFSSolvingAlgorithm.h ///\brief This file contains the FCSRandomDFSSolvingAlgorithm class ///\author Michael Mann ///\version 1.0 ///\date August 2002 //////////////////////////////////////////////// #include <stdlib.h> #include "FCSSoftDFSSolvingAlgorithm.h" #include "FCSRandom.h" #include "FCHelpingAlgorithms.h" ///Random DFS method solver template <class SolvingAlgorithmType> class FCSRandomDFSSolvingAlgorithm : public FCSSoftDFSSolvingAlgorithm<SolvingAlgorithmType> { public: ///Constructor with command line interface FCSRandomDFSSolvingAlgorithm(FCCommandLineArguments* CommandLine); ///Destructor virtual ~FCSRandomDFSSolvingAlgorithm(); protected: ///\brief Default constructor FCSRandomDFSSolvingAlgorithm(); ///\brief The "real" default constructor void InitFCSRandomDFSSolvingAlgorithm(); ///\brief Solve or resume solving a game /// ///\param Depth to continue at depth ///\return Solving return code virtual FCSStateSolvingReturnCodes SolveOrResume(int Depth); ///\brief Increase the max depth and the affected structures virtual void IncreaseDFSMaxDepth(); ///Array of maximum sizes for the array of random derived states int* m_SoftDFSDerivedStatesRandomIndexesMaxSize; ///Array of random dervied states int** m_SoftDFSDerivedStatesRandomIndexes; ///Random number generator FCSRandom* m_RandomGenerator; }; template <class SolvingAlgorithmType> FCSRandomDFSSolvingAlgorithm<SolvingAlgorithmType>::FCSRandomDFSSolvingAlgorithm() : FCSSoftDFSSolvingAlgorithm<SolvingAlgorithmType>() { InitFCSRandomDFSSolvingAlgorithm(); } template <class SolvingAlgorithmType> void FCSRandomDFSSolvingAlgorithm<SolvingAlgorithmType>::InitFCSRandomDFSSolvingAlgorithm() { m_SoftDFSDerivedStatesRandomIndexesMaxSize = NULL; m_SoftDFSDerivedStatesRandomIndexes = NULL; m_RandomGenerator = NULL; } template <class SolvingAlgorithmType> FCSRandomDFSSolvingAlgorithm<SolvingAlgorithmType>::FCSRandomDFSSolvingAlgorithm(FCCommandLineArguments* CommandLine) : FCSSoftDFSSolvingAlgorithm<SolvingAlgorithmType>(CommandLine) { InitFCSRandomDFSSolvingAlgorithm(); m_RandomGenerator = new FCSRandom(CommandLine->GetSeed()); } template <class SolvingAlgorithmType> FCSRandomDFSSolvingAlgorithm<SolvingAlgorithmType>::~FCSRandomDFSSolvingAlgorithm() { int Depth; for(Depth=0;Depth<m_NumberOfSolutionStates-1;Depth++) delete [] m_SoftDFSDerivedStatesRandomIndexes[Depth]; for(;Depth<m_DFSMaxDepth;Depth++) if (m_SoftDFSDerivedStatesLists[Depth].m_MaxNumberOfStates) delete [] m_SoftDFSDerivedStatesRandomIndexes[Depth]; delete [] m_SoftDFSDerivedStatesRandomIndexes; m_SoftDFSDerivedStatesRandomIndexes = NULL; delete [] m_SoftDFSDerivedStatesRandomIndexesMaxSize; m_SoftDFSDerivedStatesRandomIndexesMaxSize = NULL; delete m_RandomGenerator; } template <class SolvingAlgorithmType> FCSStateSolvingReturnCodes FCSRandomDFSSolvingAlgorithm<SolvingAlgorithmType>::SolveOrResume(int Depth) { FCSStateWithLocations *StateWithLocations, *RecursiveStateWithLocations; int a, j; FCSStateSolvingReturnCodes Check; //The main loop. while (Depth >= 0) { // Increase the "maximal" depth if it about to be exceeded. if (Depth+1 >= m_DFSMaxDepth) IncreaseDFSMaxDepth(); // All the resultant states in the last test conducted were covered if (m_SoftDFSCurrentStateIndexes[Depth] == m_SoftDFSDerivedStatesLists[Depth].m_NumberOfStates) { if (m_SoftDFSTestIndexes[Depth] >= m_TestsOrderNumber) { // Backtrack to the previous depth. Depth--; continue; // Just to make sure depth is not -1 now } m_SoftDFSDerivedStatesLists[Depth].m_NumberOfStates = 0; StateWithLocations = m_SolutionStates->Get(Depth, 0); // If this is the first test, then count the number of unoccupied // freecells and stacks and check if we are done. if (m_SoftDFSTestIndexes[Depth] == 0) { int NumberOfFreeStacks = 0, NumberOfFreecells = 0; m_DebugDisplayInfo->Display(m_StateType, m_NumberOfCheckedStates, Depth, StateWithLocations, ((Depth == 0) ? 0 : m_SolutionStates->Get(Depth-1, 0)->m_VisitIterations), m_NumberOfStatesInCollection); // Count the free-cells for(a=0;a<m_NumberOfFreecells;a++) if (StateWithLocations->GetFreecellCardNumber(a) == 0) NumberOfFreecells++; // Count the number of unoccupied stacks for(a=0;a<m_NumberOfStacks;a++) if (StateWithLocations->GetStackLength(a) == 0) NumberOfFreeStacks++; // Check if we have reached the empty state if ((NumberOfFreeStacks == m_NumberOfStacks) && (NumberOfFreecells == m_NumberOfFreecells)) { m_FinalState = StateWithLocations; return FCS_STATE_WAS_SOLVED; } // Cache num_freecells and num_freestacks in their // appropriate stacks, so they won't be calculated over and over again. m_SoftDFSNumberOfFreecells[Depth] = NumberOfFreecells; m_SoftDFSNumberOfFreestacks[Depth] = NumberOfFreeStacks; } if (m_SoftDFSTestIndexes[Depth] < m_TestsOrderNumber) { do { Check = RunTest(m_TestsOrder[m_SoftDFSTestIndexes[Depth]] & FCS_TEST_ORDER_NO_FLAGS_MASK, StateWithLocations, Depth, m_SoftDFSNumberOfFreestacks[Depth], m_SoftDFSNumberOfFreecells[Depth], &(m_SoftDFSDerivedStatesLists[Depth])); if ((Check == FCS_STATE_BEGIN_SUSPEND_PROCESS) || (Check == FCS_STATE_EXCEEDS_MAX_NUM_TIMES) || (Check == FCS_STATE_SUSPEND_PROCESS)) { // Have this test be re-performed m_SoftDFSDerivedStatesLists[Depth].m_NumberOfStates = 0; m_SoftDFSCurrentStateIndexes[Depth] = 0; m_NumberOfSolutionStates = Depth+1; return FCS_STATE_SUSPEND_PROCESS; } // Move the counter to the next test m_SoftDFSTestIndexes[Depth]++; } while ( // Make sure we do not exceed the number of tests (m_SoftDFSTestIndexes[Depth] < m_TestsOrderNumber) && // We are still on a random group (m_TestsOrder[m_SoftDFSTestIndexes[Depth]] & FCS_TEST_ORDER_FLAG_RANDOM) && // A new random group did not start (! (m_TestsOrder[m_SoftDFSTestIndexes[Depth]] & FCS_TEST_ORDER_FLAG_START_RANDOM_GROUP))); } int SwapSave, *RandomArray; if (m_SoftDFSDerivedStatesLists[Depth].m_NumberOfStates > m_SoftDFSDerivedStatesRandomIndexesMaxSize[Depth]) { Realloc<int>(&m_SoftDFSDerivedStatesRandomIndexes[Depth], m_SoftDFSDerivedStatesRandomIndexesMaxSize[Depth]+1, m_SoftDFSDerivedStatesLists[Depth].m_NumberOfStates); m_SoftDFSDerivedStatesRandomIndexesMaxSize[Depth] = m_SoftDFSDerivedStatesLists[Depth].m_NumberOfStates; } RandomArray = m_SoftDFSDerivedStatesRandomIndexes[Depth]; for (a=0;a<m_SoftDFSDerivedStatesLists[Depth].m_NumberOfStates;a++) RandomArray[a] = a; // If we just conducted the tests for a random group - randomize. // Else - keep those indexes as the unity vector. if (m_TestsOrder[m_SoftDFSTestIndexes[Depth]-1] & FCS_TEST_ORDER_FLAG_RANDOM) { a = m_SoftDFSDerivedStatesLists[Depth].m_NumberOfStates-1; while (a > 0) { j = m_RandomGenerator->GetRandomNumber() % (a+1); SwapSave = RandomArray[a]; RandomArray[a] = RandomArray[j]; RandomArray[j] = SwapSave; a--; } } // We just performed a test, so the index of the first state that // ought to be checked in this depth is 0. m_SoftDFSCurrentStateIndexes[Depth] = 0; } while (m_SoftDFSCurrentStateIndexes[Depth] < m_SoftDFSDerivedStatesLists[Depth].m_NumberOfStates) { RecursiveStateWithLocations = m_SoftDFSDerivedStatesLists[Depth].m_States[ m_SoftDFSDerivedStatesRandomIndexes[Depth][ m_SoftDFSCurrentStateIndexes[Depth]]]; m_SoftDFSCurrentStateIndexes[Depth]++; if (!RecursiveStateWithLocations->m_Visited) { m_NumberOfCheckedStates++; RecursiveStateWithLocations->m_Visited = FCS_VISITED_VISITED; RecursiveStateWithLocations->m_VisitIterations = m_NumberOfCheckedStates; m_SolutionStates->Set(Depth+1, RecursiveStateWithLocations); // I'm using current_state_indexes[depth]-1 because we already // increased it by one, so now it refers to the next state. Depth++; m_SoftDFSTestIndexes[Depth] = 0; m_SoftDFSCurrentStateIndexes[Depth] = 0; m_SoftDFSDerivedStatesLists[Depth].m_NumberOfStates = 0; break; } } } m_NumberOfSolutionStates = 0; return FCS_STATE_IS_NOT_SOLVEABLE; } template <class SolvingAlgorithmType> void FCSRandomDFSSolvingAlgorithm<SolvingAlgorithmType>::IncreaseDFSMaxDepth() { int NewDFSMaxDepth = m_DFSMaxDepth + INCREASE_DFS_MAX_DEPTH_BY; Realloc<int*>(&m_SoftDFSDerivedStatesRandomIndexes, m_DFSMaxDepth, NewDFSMaxDepth); Realloc<int>(&m_SoftDFSDerivedStatesRandomIndexesMaxSize, m_DFSMaxDepth, NewDFSMaxDepth); for(int d=m_DFSMaxDepth; d<NewDFSMaxDepth; d++) { m_SoftDFSDerivedStatesRandomIndexes[d] = NULL; m_SoftDFSDerivedStatesRandomIndexesMaxSize[d] = 0; } //this is the function that saves the "new" m_DFSMaxDepth FCSSoftDFSSolvingAlgorithm<SolvingAlgorithmType>::IncreaseDFSMaxDepth(); } #endif
46a99640c8a53da9204ce884221ab796e5a814db
4503b4ec29e9a30d26c433bac376f2bddaefd9e5
/XtreamToolkit/v16.4.0/Source/ReportControl/XTPReportSections.h
13299eba8c270db3341614e9cf200c29aff3303d
[]
no_license
SwunZH/ecocommlibs
0a872e0bbecbb843a0584fb787cf0c5e8a2a270b
4cff09ff1e479f5f519f207262a61ee85f543b3a
refs/heads/master
2021-01-25T12:02:39.067444
2018-02-23T07:04:43
2018-02-23T07:04:43
123,447,012
1
0
null
2018-03-01T14:37:53
2018-03-01T14:37:53
null
UTF-8
C++
false
false
6,427
h
// XTPReportSections.h: interface for the CXTPReportSections class. // // This file is a part of the XTREME REPORTCONTROL MFC class library. // (c)1998-2013 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // [email protected] // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// //{{AFX_CODEJOCK_PRIVATE #if !defined(__XTPREPORTSECTIONS_H__) #define __XTPREPORTSECTIONS_H__ //}}AFX_CODEJOCK_PRIVATE #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CXTPReportControl; class CXTPReportSection; class CXTPMarkupContext; enum XTPReportSection { xtpReportSectionHeader = 0, // Index of header section xtpReportSectionBody = 1, // Index of body section xtpReportSectionFooter = 2, // Index of footer section xtpReportSectionCount = 3 // Number of default sections }; //----------------------------------------------------------------------- // Summary: // Collection of sections. //----------------------------------------------------------------------- class _XTP_EXT_CLASS CXTPReportSections : public CXTPCmdTarget { public: //----------------------------------------------------------------------- // Summary: // Constructs the collection and default sections. //----------------------------------------------------------------------- CXTPReportSections(CXTPReportControl *pControl); //----------------------------------------------------------------------- // Summary: // Destructs the collection and sections. //----------------------------------------------------------------------- ~CXTPReportSections(); public: int Add(CXTPReportSection *pSection) { return (int)m_arrSections.Add(pSection); } CXTPReportSection* GetAt(int nIndex) const { CXTPReportSection *pSection = NULL; if (GetSize() > nIndex) // Valid index { pSection = m_arrSections.GetAt(nIndex); } return pSection; } int GetSize() const { return int(m_arrSections.GetSize()); } void RemoveAll() { m_arrSections.RemoveAll(); } public: //----------------------------------------------------------------------- // Summary: // Ensures that a report control row is at least partially visible. // Parameters: // pRow - A pointer to the row that is to be visible. // Remarks: // Ensures that a report row item is at least partially visible. // The list view control is scrolled if necessary. // See Also: MoveDown, MoveUp, MovePageDown, MovePageUp, MoveFirst, MoveLast //----------------------------------------------------------------------- virtual BOOL EnsureVisible(CDC *pDC, CXTPReportRow *pRow); //----------------------------------------------------------------------- // Summary: // Retrieves a pointer to the row that currently has focus // Returns: // Returns pointer to the focused row, or NULL otherwise. //----------------------------------------------------------------------- CXTPReportRow* GetFocusedRow() const; //----------------------------------------------------------------------- // Summary: // Returns the current rectangle for the sections. // Returns: // Current rectangle for the sections. //----------------------------------------------------------------------- CRect GetRect() const; //----------------------------------------------------------------------- // Summary: // Determines which section, if any, is at a specified position. // Parameters: // pt - A point to test. // Returns: // The section at the position specified by pt, otherwise NULL //----------------------------------------------------------------------- CXTPReportSection* HitTest(CPoint pt) const; //----------------------------------------------------------------------- // Summary: // Draws the sections to the device context. //----------------------------------------------------------------------- virtual void Draw(CDC *pDC); //----------------------------------------------------------------------- // Summary: // Adjusts section areas depending on current control size. //----------------------------------------------------------------------- virtual void AdjustLayout(CDC *pDC, CRect rcSections); //----------------------------------------------------------------------- // Summary: // Sets the markup context. //----------------------------------------------------------------------- void SetMarkupContext(CXTPMarkupContext *pMarkupContext); //----------------------------------------------------------------------- // Summary: // Re-sorts the rows of all sections. //----------------------------------------------------------------------- virtual void ReSortRows(); //----------------------------------------------------------------------- // Summary: // Recalculates indexes of all rows. // Parameters: // bAdjustLayout - If TRUE, layout is adjusted. // bReverseOrder - If TRUE, row indices are updated in reverse order, // starting from the last row. //----------------------------------------------------------------------- virtual void RefreshIndexes(BOOL bAdjustLayout); virtual void ResetContent(); protected: CXTPReportSection *FindSection(CXTPReportRow *pRow) const; protected: CArray<CXTPReportSection*, CXTPReportSection*> m_arrSections; CRect m_rcSections; // Sections rectangle CXTPReportControl *m_pControl; // Parent control. private: #ifdef _XTP_ACTIVEX DECLARE_OLETYPELIB_EX(CXTPReportSections); DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() int OleGetCount() const { return GetSize(); } LPDISPATCH OleGetSection(int nIndex) const; #endif // _XTP_ACTIVEX }; #endif //#if !defined(__XTPREPORTSECTIONS_H__)
[ "kwkang@3e9e098e-e079-49b3-9d2b-ee27db7392fb" ]
kwkang@3e9e098e-e079-49b3-9d2b-ee27db7392fb
87454ff1b4eea70432b26be38be7e8e3ec0624e4
c18ecd8ab305e21c3e6b8870105ad987113cfda5
/hdu/4497.cpp
278327a3000db54a0ac463aafdcd8ce03e9d29e5
[]
no_license
stmatengss/ICPC_practice_code
4db71e5c54129901794d4d0df6a04ebd73818759
c09f95495d8b57eb6fa2602f0bd66bd30c8e4a0c
refs/heads/master
2021-01-12T05:58:59.350393
2016-12-24T04:35:19
2016-12-24T04:35:19
77,265,840
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
2,503
cpp
////////////////////System Comment//////////////////// ////Welcome to Hangzhou Dianzi University Online Judge ////http://acm.hdu.edu.cn ////////////////////////////////////////////////////// ////Username: stmatengss ////Nickname: Stmatengss ////Run ID: ////Submit time: 2015-10-27 12:37:21 ////Compiler: GUN C++ ////////////////////////////////////////////////////// ////Problem ID: 4497 ////Problem Title: ////Run result: Accept ////Run time:0MS ////Run memory:1596KB //////////////////System Comment End////////////////// #include <iostream> #include <cmath> using namespace std; typedef long long ll; //int pow_mod(int a,int i,int n) //{ // if(i==0)return 1%n; // int temp=pow_mod(a,i>>1,n); // temp=temp*temp%n; // if(i&1)temp=(ll)temp*a%n; // return temp; //} // //bool test(int n,int a,int d) //{ // if(n==2)return true; // if(n==a)return true; // if((n&1)==0)return false; // while(!(d&1))d=d>>1; // int t=pow_mod(a,d,n); // while((d!=n-1)&&(t!=1)&&(t!=n-1)) // { // t=(ll)t*t*n; // d=d<<1; // } // return (t==n-1||(d&1)==1); //} // //bool isprime(int n) //{ // if(n<2)return false; // int a[]={2,3,61}; // for(int i=0;i<=2;i++) // if(!test(n,a[i],n-1))return false; // return true; //} int isprime(int x) //Åж¨ÊÇËØÊý { if(x==1)return 0; int flag=1,i; for(i=2;i<=sqrt(x+0.5);i++) if(x%i==0) { flag=0; break; } return flag; } ll g,l; ll n; ll res,counter; int main() { int i; int t; cin>>t; while(t--) { cin>>g>>l; if(l%g!=0)cout<<"0"<<endl; else { n=l/g; res=1; if(isprime(n)) { cout<<"6"<<endl; } else { for(i=2;i<=sqrt(l/g+0.5);i++) { if(n%i==0&&isprime(i)) { counter=0; while(n%i==0) { n=n/i; counter++; } res=counter*6*res; } } if(n>1)res*=6; cout<<res<<endl; } } } // cout << "Hello world!" << endl; return 0; }
651a63a72dc52a0c68f28e199cd925f26a5b46cd
7908c9b6eb8856e20e4ca34b8b304d6fd6afd01c
/HomeStreetInvader2/Invader.h
15c480c8dd1931c256daf157b3e74dcb72ca6b60
[]
no_license
bb2002/HomeStreetInvader
11f942f167052c081db6a019505c86c28bb9c0cb
4d7ff69008f30cef2d098b138a1cc04c98ad47cf
refs/heads/master
2020-09-04T20:33:30.423425
2019-11-20T12:01:50
2019-11-20T12:01:50
218,428,350
0
0
null
null
null
null
UTF-8
C++
false
false
992
h
#pragma once #include "Core/GameObject.h" #include "Core/AABBCollider.h" enum class EInvaderType : int { E_INVADER_1 = 0, E_INVADER_2 = 1, E_INVADER_3 = 2 }; class Invader : public GameObject { public: Invader(EInvaderType InvaderType); virtual void Initialize(); inline const wchar_t* GetPathFromType(EInvaderType Type) { switch (Type) { case EInvaderType::E_INVADER_1: return L"./Resources/Invader1.png"; case EInvaderType::E_INVADER_2: return L"./Resources/Invader2.png"; case EInvaderType::E_INVADER_3: default: return L"./Resources/Invader3.png"; } } void StartInvader(); void UpdateWithDelta(float DeltaTime) override; inline AABBCollider& GetCollision() { return Collision; } ~Invader(); private: bool bIsInvaderRunning = false; float InvaderAttackDelay = 0; float NextDelay = 0; int InvaderLevel = 0; AABBCollider Collision = AABBCollider(*transform, Vector2(60.0F, 60.0F)); EInvaderType InvaderType = EInvaderType::E_INVADER_1; };
d717210f0a317c9c6fe3551c54a2b743a98546f7
050c8a810d34fe125aecae582f9adfd0625356c6
/onishit/lot/arici/solutions/full_but_no_bitset.cpp
e0c411dfb860147cd5a2758723d9dc05ab5a0020
[]
no_license
georgerapeanu/c-sources
adff7a268121ae8c314e846726267109ba1c62e6
af95d3ce726325dcd18b3d94fe99969006b8e138
refs/heads/master
2022-12-24T22:57:39.526205
2022-12-21T16:05:01
2022-12-21T16:05:01
144,864,608
11
0
null
null
null
null
UTF-8
C++
false
false
3,734
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T> void check_min(T &a, const T &b){ a = (a < b) ? a : b; } template<class T> void check_max(T &a, const T &b){ a = (a > b) ? a : b; } #define all(x) (x).begin(), (x).end() const int N = 15e3 + 3; int n, dp[N]; array<int, 3> p[N]; vector<bool> b[N]; vector<int> l[N]; struct Fenwick{ int a[N]; void update(int i, int val){ ++i; for(; i < N; i += i & -i) check_max(a[i], val); } int query(int i){ ++i; int res = 0; for(; i >= 1; i -= i & -i) check_max(res, a[i]); return res; } } f; void or_arr(vector<bool> &l, vector<bool> &a, vector<bool> &b){ for(int i = 0; i < N; ++i) l[i] = a[i] | b[i]; } void eq_arr(vector<bool> &l, vector<bool> &a){ for(int i = 0; i < N; ++i) l[i] = a[i]; } void shift_arr(vector<bool> &l, vector<bool> &a, int sh){ for(int i = N - 1; i >= sh; --i) l[i] = a[i - sh]; for(int i = sh - 1; i >= 0; --i) l[i] = 0; } pair<int, int> collectFruits(int _N, std::vector<int> x, std::vector<int> y, std::vector<int> z){ n = _N; p[0] = {0, 0, 0}; for(int i = 1; i <= n; ++i){ p[i][0] = x[i - 1]; p[i][1] = y[i - 1]; p[i][2] = z[i - 1]; --p[i][2]; } sort(p, p + 1 + n); for(int i = 1; i <= n; ++i){ dp[i] = f.query(p[i][1]) + 1; f.update(p[i][1], dp[i]); } for(int i = 0; i <= n; ++i) l[dp[i]].push_back(i); int sum = 0; for(int i = 0; i <= n; ++i) check_max(sum, dp[i]); static vector<bool> gl[N], gr[N]; for(int i = 0; i < N; ++i){ gl[i].resize(N); gr[i].resize(N); b[i].resize(N); } b[0][0] = true; for(int i = 1; i <= sum; ++i){ vector<pair<int, int>> range; int ptr_l = 0, ptr_r = -1; for(int j = 0; j < l[i].size(); ++j){ while(ptr_r + 1 < l[i - 1].size() && p[l[i - 1][ptr_r + 1]][0] <= p[l[i][j]][0]) ++ptr_r; while(ptr_l < l[i - 1].size() && p[l[i - 1][ptr_l]][1] > p[l[i][j]][1]) ++ptr_l; range.push_back({ptr_l, ptr_r}); } int j = 0; while(j < l[i].size()){ int nxt = j; for(; nxt < l[i].size(); ++nxt){ if(range[nxt].first > range[j].second){ break; } } --nxt; int mid = range[j].second; eq_arr(gl[mid], b[l[i - 1][mid]]); for(int k = mid - 1; k >= range[j].first; --k) or_arr(gl[k], b[l[i - 1][k]], gl[k + 1]); if(range[nxt].second > mid){ eq_arr(gr[mid + 1], b[l[i - 1][mid + 1]]); for(int k = mid + 2; k <= range[nxt].second; ++k) or_arr(gr[k], b[l[i - 1][k]], gr[k - 1]); } for(int k = j; k <= nxt; ++k){ if(range[k].second == range[j].second){ shift_arr(b[l[i][k]], gl[range[k].first], p[l[i][k]][2]); } else{ or_arr(b[l[i][k]], gl[range[k].first], gr[range[k].second]); shift_arr(b[l[i][k]], b[l[i][k]], p[l[i][k]][2]); } } j = nxt + 1; } } for(int i = 1; i < l[sum].size(); ++i) or_arr(b[l[sum][0]], b[l[sum][0]], b[l[sum][i]]); auto poss = b[l[sum][0]]; int best; for(int i = sum / 2; i >= 0; --i){ if(poss[i] || poss[sum - i]){ best = i; break; } } int diff = abs(best - (sum - best)); return {sum, diff}; }
f40e5e6f57760ba214369ab08e66dd9914cede77
9a137bfc0d5f8e52fa6465cd9de86b946be7a231
/test/BinaryTree_test.cpp
f2adeb89433738f2df87643709033372d42b2ffd
[]
no_license
abdullahw01/Datastructures
9e3dbbd86b332b5fc6315ad2cdf7412d31ee31a1
734bc81a6aba102f2139933dbb5aa8693ca72a3f
refs/heads/main
2023-03-20T23:27:31.081080
2021-02-15T07:05:28
2021-02-15T07:05:28
328,411,845
0
0
null
null
null
null
UTF-8
C++
false
false
700
cpp
/* * BinaryTree_test.cpp * * Created on: Feb 7, 2021 * Author: abdulwaheed */ #include "BinaryTree.h" int main() { BinaryTree *tree = new BinaryTree(); tree->insertNode(tree->root, 9); tree->insertNode(tree->root, 8); tree->insertNode(tree->root, 2); tree->insertNode(tree->root, 1); tree->insertNode(tree->root, 3); int val; cout << "Enter value to search: "; cin >> val; if (tree->findValue (tree->root, val)) { //if given key found then return that node. cout << "Given number is found" << endl; return 0; } else //if given key is not found. cout << "Given number is not found" << endl; delete tree; return -1; }
216a5f5c82d4e213dcb3f445fb6b9f4c6c3b5089
6b50e35b60a7972ff3c3ac60a1d928b43591901c
/SignalProcessing/LDA_Truong_Tung/jni/kernel/src/kernel/player/ovkCMessageWithData.h
189d26d73b7196bb6c606f0f086ce917a1413ac7
[]
no_license
damvanhuong/eeglab411
4a384fe06a3f5a9767c4dc222d9946640b168875
0aca0e64cd8e90dcde7dd021078fa14b2d61f0c9
refs/heads/master
2020-12-28T20:19:50.682128
2015-05-06T10:36:07
2015-05-06T10:36:07
35,154,165
1
0
null
2015-05-06T10:48:11
2015-05-06T10:48:10
null
UTF-8
C++
false
false
2,451
h
#ifndef __OpenViBEKernel_Kernel_Player_CMessageWithData_H__ #define __OpenViBEKernel_Kernel_Player_CMessageWithData_H__ #include "../ovkTKernelObject.h" #include "ovkTMessage.h" #include <map> #include <openvibe/ov_all.h> namespace OpenViBE { namespace Kernel { class CMessageWithData : public OpenViBE::Kernel::TMessage<OpenViBE::Kernel::TKernelObject<OpenViBE::Kernel::IMessageWithData> > { public: CMessageWithData(const OpenViBE::Kernel::IKernelContext& rKernelContext); ~CMessageWithData(); // Getters // Note that returned pointers are invalid after processMessage() scope has passed. bool getValueUint64(const CString &key, OpenViBE::uint64& rValueOut) const; bool getValueFloat64(const CString &key, OpenViBE::float64& rValueOut) const; bool getValueCString(const CString &key, const OpenViBE::CString** pValueOut) const; bool getValueIMatrix(const CString &key, const OpenViBE::IMatrix** pValueOut) const; // Setters bool setValueUint64(const CString &key, uint64 valueIn); bool setValueFloat64(const CString &key, float64 valueIn); bool setValueCString(const CString &key, const CString &valueIn); bool setValueIMatrix(const CString &key, const IMatrix &valueIn); // Getters for key tokens virtual const OpenViBE::CString* getFirstCStringToken() const; virtual const OpenViBE::CString* getFirstUInt64Token() const; virtual const OpenViBE::CString* getFirstFloat64Token() const; virtual const OpenViBE::CString* getFirstIMatrixToken() const; // Functions to iterate over key tokens, start with NULL. virtual const OpenViBE::CString* getNextCStringToken(const OpenViBE::CString &previousToken) const; virtual const OpenViBE::CString* getNextUInt64Token(const OpenViBE::CString &previousToken) const; virtual const OpenViBE::CString* getNextFloat64Token(const OpenViBE::CString &previousToken) const; virtual const OpenViBE::CString* getNextIMatrixToken(const OpenViBE::CString &previousToken) const; private: // Data definitions std::map<CString, uint64> m_oUint64s; std::map<CString, CString > m_oStrings; std::map<CString, float64> m_oFloat64s; std::map<CString, IMatrix* > m_oMatrices; _IsDerivedFromClass_Final_(OpenViBE::Kernel::TMessage<OpenViBE::Kernel::TKernelObject<OpenViBE::Kernel::IMessageWithData> >, OVK_ClassId_Kernel_Player_MessageWithData); }; }; }; #endif // __OpenViBEKernel_Kernel_Player_CMessageWithData_H__
1aff407793fb0cd54886e886b60d33defd0f3031
ecc5ebdbadeda88dbe68f86d6ab53932a06d09d3
/include/ctre/flags_and_modes.hpp
f92a567f0f557c16ca3fcacb19a8abcb4f352b71
[ "LLVM-exception", "Apache-2.0" ]
permissive
Ryan-rsm-McKenzie/compile-time-regular-expressions
8113d844bdfe4ba3acac20bbebfce3f0e9427add
a0c016c6b9e5c4dc96f4564d827472ee978f5d45
refs/heads/main
2023-07-05T10:58:28.512895
2021-08-17T08:22:20
2021-08-17T08:22:20
397,120,300
1
0
Apache-2.0
2021-08-17T05:49:13
2021-08-17T05:49:13
null
UTF-8
C++
false
false
816
hpp
#ifndef CTRE_V2__CTRE__FLAGS_AND_MODES__HPP #define CTRE_V2__CTRE__FLAGS_AND_MODES__HPP namespace ctre { struct singleline { }; struct multiline { }; struct flags { bool block_empty_match = false; bool multiline = false; constexpr CTRE_FORCE_INLINE flags(ctre::singleline) { } constexpr CTRE_FORCE_INLINE flags(ctre::multiline): multiline{true} { } }; constexpr CTRE_FORCE_INLINE auto not_empty_match(flags f) { f.block_empty_match = true; return f; } constexpr CTRE_FORCE_INLINE auto consumed_something(flags f, bool condition = true) { if (condition) f.block_empty_match = false; return f; } constexpr CTRE_FORCE_INLINE bool cannot_be_empty_match(flags f) { return f.block_empty_match; } constexpr CTRE_FORCE_INLINE bool multiline_mode(flags f) { return f.multiline; } } // namespace ctre #endif
b244fc9019a66c1623c6113d89db46c3d5961740
fab3feebd2a17837cffcf800b6b8c12d9aaea20c
/buffer.cpp
92f6730cd1ad6b4e4754db187ab32da2792c135b
[]
no_license
suyuchen123/MiniSQL
86c6ba1b8794e5430b5d2a630664bd39557caad1
42b8d5d1d0936c1ac034e5b27ab32f1debef1622
refs/heads/master
2016-09-06T20:17:55.421433
2015-03-10T13:57:13
2015-03-10T13:57:13
31,959,793
1
0
null
null
null
null
GB18030
C++
false
false
16,080
cpp
#include "buffer.h" #include "CatalogManager.h" #include <iostream> #include <string> #include <fstream> using namespace std; //class CatalogManager; #define UNKNOWN_FILE 8 #define TABLE_FILE 9 #define INDEX_FILE 10 extern CatalogManager catalogM; buffer::buffer() { nowBlock=0; nowFile=0; fileHead = NULL; for (int i = 0; i < MAX_FILE_ACTIVE; i++) { file[i].type = 0; file[i].fileName = ""; file[i].recordAmount = -1; file[i].usage = -1; file[i].recordLength = -1; file[i].next = NULL; file[i].firstBlock=-1; } for (int i = 0; i < MAX_BLOCK; i++) { //分配文件块数据存储空间,并置0 block[i].address = new char[BLOCK_LEN]; memset(block[i].address, 0, BLOCK_LEN); //为文件块初始化变量 block[i].offset = -1; block[i].dirty = 0; block[i].lock = 0; block[i].id = i; block[i].lrutime = 0; block[i].usage = -1; block[i].nextBlock = -1; block[i].preBlock = -1; block[i].file = NULL; } } buffer::~buffer() { for (int i = 0; i < MAX_BLOCK; i++) { if (block[i].file!=NULL && block[i].usage!=-1) freeBlock(block[i].file->fileName, i, block[i].dirty); } } //put the file into list of file and return the number of block it have int buffer::getNumberOfBlocks(string aimfile) { fileInfo *fp; int bp; for (fp = fileHead; fp != NULL; fp = fp->next) { if (fp->fileName == aimfile) // that file is in memeory then return it { return ((get_file_size (aimfile.c_str())/ BLOCK_LEN )); } } if (nowFile < MAX_FILE_ACTIVE) { for (int i = nowFile; i < MAX_FILE_ACTIVE; i++) { if (file[i].usage == -1) { fp = &file[i]; break; } } nowFile++; fp->usage = 0; fp->fileName = aimfile; // put it into the top of the link if (fileHead != NULL) { fp->next = fileHead; fileHead = fp; } else // if filehead is not null set fp in to file head { fp->next = NULL; fileHead = fp; } } else // nowfile==MAX { fp = fileHead; string oldname = fp->fileName; fp->fileName = aimfile; // set the top as the file block for (bp = fp->firstBlock; bp != NULL; bp = block[bp].nextBlock) { block[bp].usage = 0; if (freeBlock(oldname,bp,block[bp].dirty)==0) { cout << "Fail to flush block" << endl; return NULL; } } fp->firstBlock = NULL; // the file got no block here. } // Wait the catalog function to put in //get information data from dict function int imformation[3]; catalogM.getfileinfo(aimfile, imformation); // get the information of the file //if it is a table if (imformation[0] == TABLE_FILE) { fp->type = TABLE_FILE; fp->recordAmount = imformation[1]; fp->recordLength = imformation[2]; } //if index file else if (imformation[0] == INDEX_FILE) { fp->type = INDEX_FILE; fp->recordLength = -1; fp->recordAmount = -1; } //do not have such file else { cout << "File not found" << endl; return NULL; } return (get_file_size(aimfile.c_str()) / BLOCK_LEN); } char * buffer::getBlockAddress(string fileName, int blockNo) { // the block is not suit for the file if (block[blockNo].file == NULL) return NULL; if (block[blockNo].usage == -1 || block[blockNo].file->fileName != fileName) { return NULL; } return block[blockNo].address; } char * buffer::getoffsetBlockAddress(string fileName, int offset) { blockInfo * LRUBlock; int bp; fileInfo * fp; fileInfo * temfp; LRUBlock = NULL; temfp = NULL; for (int i = 0; i < MAX_BLOCK; i++) // if that block is already in memory { if (block[i].file == NULL || block[i].usage == -1) continue; if (block[i].file->fileName == fileName && block[i].offset == offset) { return block[i].address; } } // start to find empty one and read for (int i = 0; i < MAX_BLOCK; i++) { if (block[i].usage == -1) { LRUBlock = &block[i]; break; } } if (LRUBlock == NULL) //get an empty block; { int flag = 100000; for (fp = fileHead; fp != NULL; fp = fp->next) for (bp = fp->firstBlock; bp != NULL; bp = block[bp].nextBlock) { if (block[bp].lrutime < flag && block[bp].lock != 1) { flag = block[bp].lrutime; LRUBlock = &block[bp]; temfp = fp; } } if (LRUBlock->dirty) { freeBlock(temfp->fileName, LRUBlock->id, 1); LRUBlock->dirty = 0; nowBlock++; } } //clear the address memset(LRUBlock->address, 0, BLOCK_LEN); LRUBlock->offset = offset; LRUBlock->dirty = 0; LRUBlock->lock = 0; LRUBlock->lrutime = 0; LRUBlock->usage = 0; LRUBlock->nextBlock = -1; LRUBlock->preBlock = -1; LRUBlock->file = getFile(fileName); FILE * fileread; blockInfo * bpp; bpp = LRUBlock; if (fileread = fopen(fileName.c_str(), "rb+")) { fseek(fileread, bpp->offset*BLOCK_LEN, 0); //if read over then return null if (fread(bpp->address, 1, BLOCK_LEN, fileread) == 0) //if read nothing { fclose(fileread); bpp->offset = 0; return NULL; } fclose(fileread); } // set position block[getFile(fileName)->firstBlock].preBlock = bpp->id; LRUBlock->nextBlock = getFile(fileName)->firstBlock; getFile(fileName)->firstBlock = bpp->id; bpp->usage = findUsage(fileName.c_str(), bpp->address); return bpp->address; //return that id } //create new file void buffer::createNewFile(string aimfile) { fileInfo *fp; int bp; for (fp = fileHead; fp != NULL; fp = fp->next) { if (fp->fileName == aimfile) // that file is in memeory then return { return; } } system("pause"); //create file FILE *filetowite; filetowite = fopen(aimfile.c_str(), "rb+"); if (filetowite == NULL) { //then create the file; //fclose(filetowite); filetowite = fopen(aimfile.c_str(), "w"); if (filetowite != NULL) { cout << aimfile << " file has been created"<<endl; } else { cout << aimfile << "file create failed"<<endl; } } else { cout << "The file has exsit" << endl; } //give a place in the list for the file if (nowFile < MAX_FILE_ACTIVE) { for (int i = nowFile; i < MAX_FILE_ACTIVE; i++) { if (file[i].usage == -1) { fp = &file[i]; break; } } nowFile++; fp->usage = 0; fp->fileName = aimfile; // put it into the top of the link if (fileHead != NULL) { fp->next = fileHead; fileHead = fp; } else // if filehead is not null set fp in to file head { fp->next = NULL; fileHead = fp; } } else // nowfile==MAX { fp = fileHead; string oldname = fp->fileName; fp->fileName = aimfile; // set the top as the file block for (bp = fp->firstBlock; bp != NULL; bp = block[bp].nextBlock) { block[bp].usage = 0; if (!freeBlock(oldname, bp, block[bp].dirty)) { cout << "Fail to flush block" << endl; } return ; } fp->firstBlock = NULL; // the file got no block here. } // Wait the catalog function to put in //get information data from dict function int imformation[3]; catalogM.getfileinfo(aimfile, imformation); // get the information of the file //if it is a table if (imformation[0] == TABLE_FILE) { fp->type = TABLE_FILE; fp->recordAmount = imformation[1]; fp->recordLength = imformation[2]; } //if index file else if (imformation[0] == INDEX_FILE) { fp->type = INDEX_FILE; fp->recordLength = -1; fp->recordAmount = -1; } //do not have such file else { cout << "File not found" << endl; return ; } return; } int buffer::freeBlock(string aimfile, int blockNo, bool isDirty) { //make sure the blook are for the right aimfile if (blockNo < 0) return 0; if (block[blockNo].file == NULL) { return 0; } if (block[blockNo].usage == -1 || block[blockNo].file->fileName != aimfile) { return 0; } if (isDirty == 1) { FILE *fp; if (fp = fopen(aimfile.c_str(), "rb+")) { fseek(fp, block[blockNo].offset*BLOCK_LEN, 0); //get to the positon of the file if (fwrite(block[blockNo].address, BLOCK_LEN, 1, fp) == -1) { cout << "write erro" << endl; return 0; //write earro } fclose(fp); } else { cout << "Fail to open the block of file " << aimfile << endl; return 0; } isDirty = 0; } /* if (block[blockNo].preBlock > 0) { block[block[blockNo].preBlock].nextBlock = block[blockNo].nextBlock; } if (block[blockNo].nextBlock > 0) { block[block[blockNo].nextBlock].preBlock = block[blockNo].preBlock; } block[blockNo].usage = -1; nowBlock--;*/ return 1; } int buffer::freeBlock_static(string aimfile, int static_block, bool isDirty) // static_block--->the offset of the file ,first find the block in memory { int blockNo; for (int i = 0; i < MAX_BLOCK; i++) // if that block is already in memory { if (block[i].file == NULL || block[i].usage == -1) continue; if (block[i].file->fileName == aimfile && block[i].offset == static_block) { blockNo = i; } } //make sure the blook are for the right aimfile if (block[blockNo].file == NULL) { return 0; } if (block[blockNo].usage == -1 || block[blockNo].file->fileName != aimfile) { return 0; } if (isDirty == 1) { FILE *fp; if (fp = fopen(aimfile.c_str(), "rb+")) { fseek(fp, block[blockNo].offset*BLOCK_LEN, 0); //get to the positon of the file if (fwrite(block[blockNo].address, BLOCK_LEN, 1, fp) == -1) { cout << "write erro" << endl; return 0; //write earro } fclose(fp); } else { cout << "Fail to open the block of file " << aimfile << endl; return 0; } isDirty = 0; } /* if (block[blockNo].preBlock > 0) { block[block[blockNo].preBlock].nextBlock = block[blockNo].nextBlock; } if (block[blockNo].nextBlock > 0) { block[block[blockNo].nextBlock].preBlock = block[blockNo].preBlock; } block[blockNo].usage = -1; nowBlock--;*/ return 1; } int buffer::findnextblock(string fileName) //get a new block for some file; { blockInfo * LRUBlock; int bp; fileInfo * fp; fileInfo * temfp; LRUBlock = NULL; temfp = NULL; for (int i = 0; i < MAX_BLOCK; i++) { if (block[i].usage == -1) { LRUBlock = &block[i]; break; } } if (LRUBlock == NULL) //get an empty block; { int flag = 100000; for (fp = fileHead; fp != NULL; fp = fp->next) for (bp = fp->firstBlock; bp != NULL; bp = block[bp].nextBlock) { if (block[bp].lrutime < flag && block[bp].lock != 1) { flag = block[bp].lrutime; LRUBlock = &block[bp]; temfp = fp; } } if (LRUBlock->dirty) { freeBlock(temfp->fileName, LRUBlock->id, 1); LRUBlock->dirty = 0; nowBlock++; } } //clear the address memset(LRUBlock->address, 0, BLOCK_LEN); if ((getFile(fileName)->firstBlock) > 0) { LRUBlock->offset = block[getFile(fileName)->firstBlock].offset + 1; } else { LRUBlock->offset = 0; } LRUBlock->dirty = 0; LRUBlock->lock = 0; LRUBlock->lrutime = 0; LRUBlock->usage = -1;; LRUBlock->nextBlock = -1; LRUBlock->preBlock = -1; FILE * fileread; blockInfo * bpp; bpp = LRUBlock; if (fileread = fopen(fileName.c_str(), "rb+")) { fseek(fileread, bpp->offset*BLOCK_LEN, 0); //if read over then return null if (fread(bpp->address, 1, BLOCK_LEN, fileread) == 0) //if read nothing { fclose(fileread); bpp->offset = 0; return -1; } fclose(fileread); } // set position LRUBlock->file = getFile(fileName); //set status after makesure LRUBlock->usage = 0; block[getFile(fileName)->firstBlock].preBlock = bpp->id; LRUBlock->nextBlock = getFile(fileName)->firstBlock; getFile(fileName)->firstBlock = bpp->id; bpp->usage = findUsage(fileName.c_str(), bpp->address); return bpp->id; //return that id } int buffer::addNewBlock(string fileName) //get a new block for some file; { blockInfo * LRUBlock; int bp; fileInfo * fp; fileInfo * temfp; LRUBlock = NULL; temfp = NULL; for (int i = 0; i < MAX_BLOCK; i++) { if (block[i].usage == -1) { LRUBlock = &block[i]; break; } } if (LRUBlock == NULL) //get an empty block; { int flag = 100000; for (fp = fileHead; fp != NULL; fp = fp->next) for (bp = fp->firstBlock; bp != NULL; bp = block[bp].nextBlock) { if (block[bp].lrutime < flag && block[bp].lock != 1) { flag = block[bp].lrutime; LRUBlock = &block[bp]; temfp = fp; } } if (LRUBlock->dirty) { freeBlock(temfp->fileName, LRUBlock->id, 1); LRUBlock->dirty = 0; nowBlock++; } } if ((getFile(fileName)->firstBlock) > 0) { LRUBlock->offset = block[getFile(fileName)->firstBlock].offset + 1; } else { LRUBlock->offset = 0; } //clear the address memset(LRUBlock->address, 0, BLOCK_LEN); LRUBlock->dirty = 0; LRUBlock->lock = 0; LRUBlock->lrutime = 0; LRUBlock->usage = 0; LRUBlock->nextBlock = -1; LRUBlock->preBlock = -1; LRUBlock->file = getFile(fileName); FILE * fileread; blockInfo * bpp; bpp = LRUBlock; int filelength = get_file_size(fileName.c_str()); bpp->offset = filelength / BLOCK_LEN; if (fileread = fopen(fileName.c_str(), "rb+")) { fseek(fileread, bpp->offset*BLOCK_LEN, 0); fwrite(bpp->address, BLOCK_LEN, 1, fileread); //write empty thing in ; fclose(fileread); } // set position block[getFile(fileName)->firstBlock].preBlock = bpp->id; bpp->nextBlock = getFile(fileName)->firstBlock; getFile(fileName)->firstBlock = bpp->id; bpp->usage = findUsage(fileName.c_str(), bpp->address); return bpp->id; //return that id } void buffer::deleteFile(string fileName) { for (int i = 0; i <= MAX_BLOCK; i++) { if (block[i].file == NULL) continue; if (block[i].usage != -1 && block[i].file->fileName == fileName) { freeBlock(fileName, i, block[i].dirty); } } remove(fileName.c_str()); return; } // get file struct of aimfilename fileInfo * buffer::getFile(string aimfilename) { fileInfo *fp; int bp; for (fp = fileHead; fp != NULL; fp = fp->next) { if (fp->fileName == aimfilename) return fp; } if (fp == NULL) { if (nowFile < MAX_FILE_ACTIVE) { for (int i = nowFile; i < MAX_FILE_ACTIVE; i++) { if (file[i].usage == -1) { fp = &file[i]; break; } } nowFile++; fp->usage = 0; fp->fileName = aimfilename; // put it into the top of the link if (fileHead != NULL) { fp->next = fileHead; fileHead = fp; } else // if filehead is not null set fp in to file head { fp->next = NULL; fileHead = fp; } } else // nowfile==MAX { fp = fileHead; fp->fileName = aimfilename; // set the top as the file block for (bp = fp->firstBlock; bp != NULL; bp = block[bp].nextBlock) { block[bp].usage = 0; if (freeBlock(aimfilename,bp,block[bp].dirty)==1) { cout << "Fail to flush block" << endl; return NULL; } } fp->firstBlock = NULL; // the file got no block here. } } // Wait the catalog function to put in //get information data from dict function int imformation[3]; catalogM.getfileinfo(aimfilename, imformation); // get the information of the file //if it is a table if (imformation[0] == TABLE_FILE) { fp->type = TABLE_FILE; fp->recordAmount = imformation[1]; fp->recordLength = imformation[2]; } //if index file else if (imformation[0] == INDEX_FILE) { fp->type = INDEX_FILE; fp->recordLength = -1; fp->recordAmount = -1; } //do not have such file else { cout << "File not found" << endl; return NULL; } return fp; } int buffer::findUsage(const char * fileName, const char * address) { string s(fileName); int recordLen; recordLen = catalogM.getrecordLength(s); const char * p; p = address; // route get length while (p - address<BLOCK_LEN) { const char * tmp; tmp = p; int i; for (i = 0; i<recordLen; i++) { if (*tmp != 0) break; tmp++; } if (i == recordLen) break; p = p + recordLen; } return p - address; } /* int main() { bm.createNewFile("testfile2"); cout << bm.getFile("testfile2")->fileName<<endl; int i=bm.addNewBlock("testfile2"); cout << bm.getNumberOfBlocks("testfile1") << endl;; //cout << bm.block[i].address<<endl; system("pause"); }*/
2605aa2082542f00ee84bd89219e974d463b8d33
e907aedbe9517a06cf73246ec5a0542dc1d119f0
/CompundInterestCalculator/CompundInterestCalculator/main.cpp
b8b14a545744d0cbbe9147121fb1fa7ed7fa7a75
[]
no_license
prv1/Data-Structures-Alghorithms
06b891d49e0af74610add7d8895ac5ea56b00832
a5beca208884f2f4ebc2506f6270510c2de2429f
refs/heads/master
2020-07-03T19:49:37.929988
2016-11-19T20:56:31
2016-11-19T20:56:31
74,234,938
0
0
null
null
null
null
UTF-8
C++
false
false
401
cpp
#include <iostream> #include <string> using namespace std; int inputValue, result; int input(string); int main() { result = input("Please enter an integer number to square: > "); cout << "You input " << inputValue << " is squared " << result << endl; system("pause"); return 0; } int input(string text) { cout << text; cin >> inputValue; return inputValue * inputValue; }
6f4571eec6561878408ebb670c66249081bc4e12
91c323ef35ab112d10bbd36455c983d46e80ad8f
/Project/cs380_gabriel.m_project/source/src/utils/generate_noise.cpp
6908fa8b76a6688eff05918978739823df051c86
[]
no_license
gabrielmaneru/AI-Hydraulic-Erosion
fa2595cfe61af7d71512418c64c07ef14f2cf642
ad92bef8f33aa2670a2dea7032a67f1bc47c851d
refs/heads/master
2022-02-18T18:28:31.537676
2019-09-06T07:26:49
2019-09-06T07:26:49
186,166,236
0
0
null
null
null
null
UTF-8
C++
false
false
1,608
cpp
#include "generate_noise.h" static vec2 random_offset{ 0.0f, 0.0f }; void randomize_noise() { random_offset.x = rand() * rand() / (float)RAND_MAX; random_offset.y = rand() * rand() / (float)RAND_MAX ; } map2d<float> generate_noise(size_t size, float scale, int iterations, float persistance, float lacunarity, float lowerbound, float upperbound, vec2 falloff) { map2d<float> noise_map{ size, size }; if (scale <= 0.0f) scale = FLT_EPSILON; float min_value{ FLT_MAX }, max_value{ -FLT_MAX }; noise_map.loop( [&](size_t x, size_t y, float) -> float { float amplitude{ 1.0f }; float frequency{ 1.0f }; float noise_value{ 0.0f }; for (int i = 0; i < iterations; ++i) { float sampler_x = x / (size - 1.0f) * frequency; float sampler_y = y / (size - 1.0f) * frequency; noise_value += coef(-1.0f, 1.0f, glm::perlin(random_offset + scale * vec2{ sampler_x, sampler_y })) * amplitude; amplitude *= persistance; frequency *= lacunarity; } float x__ = lerp(0.001f, 1.0f, glm::abs(coef<float>(0.0f, size / 2.0f, x) - 1)); float y__ = lerp(0.001f, 1.0f, glm::abs(coef<float>(0.0f, size / 2.0f, y) - 1)); float dist = glm::pow(glm::sqrt(x__*x__ + y__*y__),falloff.x); noise_value = lerp(noise_value, noise_value*(1-dist), falloff.y); if (noise_value < min_value) min_value = noise_value; if (noise_value > max_value) max_value = noise_value; return noise_value; } ); noise_map.loop( [&](size_t, size_t, float prev) -> float { return map(prev, min_value, max_value, lowerbound, upperbound); } ); return noise_map; }
20aca42603484e67babc69887969d0aa266b75c5
c4deb1e54321e2659f0052c4cfc95f09a4feb94a
/QtClassClient/Reliable/DataUnit/CPeerPacket.h
2296d696098bae8a99fee376b0ac58c5a007dcab
[]
no_license
ideallx/serveree
f7c6fb1d08055796d5903c6a89a6a1f8d45cb81d
4cfa021f45cf8f6b75e3db6d4115d67acc44f061
refs/heads/master
2021-01-10T19:15:51.555335
2014-12-29T01:54:38
2014-12-29T01:54:38
23,220,456
1
0
null
null
null
null
UTF-8
C++
false
false
1,409
h
/* * CBlock.h * * Created on: 2014-6-13 * Author: root */ #ifndef PACKET_H_ #define PACKET_H_ #include "../Stdafx.h" #include "CMessage.h" class CPeerPacket { protected: ts_msg* _msg; sockaddr_in peerAddr; public: CPeerPacket(const ts_msg& msg) { int size = ((TS_MESSAGE_HEAD*) &msg)->size + sizeof (TS_MESSAGE_HEAD); _msg = static_cast<ts_msg*>(malloc(size)); memcpy(_msg, &msg, size); totalSize = size; } CPeerPacket(TS_PEER_MESSAGE& pmsg) : peerAddr(pmsg.peeraddr) { CPeerPacket(pmsg.msg); } CPeerPacket() {}; virtual ~CPeerPacket() { free(_msg); } inline ts_msg* msg() { return _msg; } inline const char* body() { return _msg->Body; } const inline int seq() const { return ((TS_MESSAGE_HEAD*) _msg)->sequence; } inline TS_UINT64 rserved() const { return ((TS_MESSAGE_HEAD*) _msg)->reserved; } inline TS_UINT64 time() const { return ((TS_MESSAGE_HEAD*) _msg)->time; } inline TS_UINT64 uid() const { return ((TS_MESSAGE_HEAD*) _msg)->UID; } inline sockaddr_in addr() const { return peerAddr; } inline unsigned char type() const { return ((TS_MESSAGE_HEAD*) _msg)->type; } inline void setAddr(sockaddr_in in) { peerAddr = in; } inline int size() const { return totalSize; } inline void copy(CPeerPacket* p) { memcpy(&peerAddr, &p->peerAddr, sizeof(sockaddr_in)); memcpy(&_msg, &p->_msg, totalSize); } private: int totalSize; }; #endif /* BLOCK_H_ */
833498df9618499335ec38cf37903b63e7de234e
547adef34dbaf8d92662ec367d9dd4b5bf7164e5
/c pro converted into cpp/ca38do.cpp
91d89aaf69fc5cb130ffc57b1f91deeb29282814
[]
no_license
pooja4034/cpp-programs
1c02a578f37ccbcdb609568db671a81594e89c0a
a36158eece6b0d3f0d03bff6a7414199c82f7309
refs/heads/main
2023-04-05T12:31:07.080610
2023-04-03T17:26:06
2023-04-03T17:26:06
327,210,135
0
0
null
null
null
null
UTF-8
C++
false
false
267
cpp
#include<iostream> #include<stdio.h> using namespace std; int main() { int n,r,s=0; cout<<"Enter the no: "; cin>>n; do { r=n%10; s=s*10+r; n=n/10; }while(n>0); cout<<"rev= "<<s; return 0; }
887611b4966efe38e9dea55b72d1e6c5933b5a6b
69bdd4914ac1a014a089325d468bf0c0ab2fd458
/RENT.cpp
a1e15ef303d35fc9836d5c02f5163f1866d6082e
[]
no_license
ab1hi2shek/SPOJ-Solutions
f0185f8758fca2e4daa633e66739a17fc68d8f9d
d80da26241f19bf75f77c369d520b19e2520cd91
refs/heads/master
2021-07-04T01:37:56.219641
2017-09-26T17:23:50
2017-09-26T17:23:50
103,300,870
0
0
null
null
null
null
UTF-8
C++
false
false
1,603
cpp
/* CODE BY - ABHISHEK KUMAR NIT DURGAPUR */ #include <bits/stdc++.h> using namespace std; //data types #define ll int #define ull unsigned long long //stl typedef vector<ll> vi; typedef vector<vi> vvi; typedef pair<ll,ll> pii; typedef map<ll,ll> mpll; #define pb push_back #define all(c) (c).begin(),(c).end() #define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) #define present(c,x) ((c).find(x) != (c).end()) #define cpresent(c,x) (find(all(c),x) != (c).end()) //loops #define loop(i,a,b) for(ll i=a;i<=b;i++) #define loopr(i,a,b) for(ll i=a;i>=b;i--) //others #define isPowerOfTwo(S) !(S & (S - 1)) #define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5))) #define nline cout<<endl #define M0D 1000000007 #define MAXM 10005 struct node{ ll st; ll dur; ll price; }; node arr[MAXM]; bool accompare(node a, node b) { if(a.st < b.st) return true; return false; } ll find(ll n, ll val) { if(arr[n-1].st < val) return n; ll low = 0, high = n-1; while(low < high) { ll mid = low + (high-low)/2; if(arr[mid].st >= val) high = mid; else low = mid+1; } return high; } int main() { std::ios::sync_with_stdio(false); ll t; cin>>t; while(t--) { ll n; cin>>n; loop(i,0,n-1) cin>>arr[i].st>>arr[i].dur>>arr[i].price; sort(arr, arr+n, accompare); ll dp[n+1]; dp[n] = 0; for(ll i=n-1; i>=0 ;i--){ //cout<<find(n,arr[i].st + arr[i].dur)<<endl; dp[i] = max(dp[i+1], dp[find(n, arr[i].st + arr[i].dur)] + arr[i].price); //cout<<dp[i]<<endl; } cout<<dp[0]<<endl; } return 0; }
5561077504c10c4ded25034a8fc6fb9ed5927bec
215111e92a3dfc535ce1c1ce25a35fb6003ab575
/cf/subregional_2013/i.cpp
3297ba0cd5c85f02fa0b60b60b475391a73fcd14
[]
no_license
emanueljuliano/Competitive_Programming
6e65aa696fb2bb0e2251e5a68657f4c79cd8f803
86fefe4d0e3ee09b5766acddc8c78ed8b60402d6
refs/heads/master
2023-06-23T04:52:43.910062
2021-06-26T11:34:42
2021-06-26T11:34:42
299,115,304
0
0
null
null
null
null
UTF-8
C++
false
false
948
cpp
#include <bits/stdc++.h> using namespace std; #define _ ios_base::sync_with_stdio(0);cin.tie(0); #define endl '\n' #define f first #define s second #define pb push_back typedef long long ll; typedef pair<int, int> ii; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const int MAX = 1e3+10; int dp[MAX]; int n, c, t1, t2; int fim; vector<int> v; int solve(int at){ if(at==n) return 0; int &ret = dp[at]; if(ret!=-1) return ret; int at1=at; while(at1<n and v[at1]<=v[at]+t1) at1++; ret = t1+solve(at1); int at2=at; while(at2<n and v[at2]<=v[at]+t2) at2++; ret = min(ret, t2+solve(at2)); return ret; } int main(){ _ cin >> n >> c >> t1 >> t2; v.resize(n); for(auto &i:v) cin >> i; int ans = INF; for(int i=0;i <n; i++){ vector<int> w; for(int j=i; j<n+i; j++) w.pb((v[j%n]-v[i]+c)%c); for(int j=0; j<=n; j++) dp[j] = -1; v = w; ans = min(ans, solve(0)); } cout << ans << endl; exit(0); }
087ca2eeae09f954e6b88d00de5db6ce35079a7c
4f90f04d74c3f20d4b86670f14ecbdda469c528c
/runtime/Engine.cpp
456dc1d749c32b563822d79d9ee5d8fd484ac23d
[ "MIT" ]
permissive
petecoup/clorene
7e39d2ca7124541d1ef0db704e428494a767b0b0
c35bf81c6a8b2fb4849a685c956b9b8f8993dda8
refs/heads/master
2021-01-01T17:37:09.635282
2011-10-20T13:13:20
2011-10-20T13:13:20
2,606,095
4
1
null
null
null
null
UTF-8
C++
false
false
1,795
cpp
/* * Copyright (C) 2011 Peter Couperus * * 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 "Poco/ThreadPool.h" #include "Engine.h" #include "Worker.h" #include "FunctionRunner.h" namespace clorene { Engine::Engine(int numWorkers) : pool_(new Poco::ThreadPool(numWorkers, 2*numWorkers)) { } Engine::~Engine() { waitForIdle(); delete pool_; } void Engine::addWorkGroup(Kernel* kernel, size_t numWorkItems) { FunctionRunner* runner = new FunctionRunner(kernel); for(size_t i = 0; i < numWorkItems; i++) { addWorker(runner, i); } } void Engine::addWorker(FunctionRunner* runner, int id) { Worker* worker = new Worker(runner, id); pool_->start(*worker); } void Engine::waitForIdle() { pool_->joinAll(); } }
[ "peter@peter-VirtualBox.(none)" ]
peter@peter-VirtualBox.(none)
36fe5dd451ddeafebb4ef3deb2ce0be3c5b19ec3
b4032b8b9b5b5b0728e51f3ae5c964b637949487
/project_v5/src/project_v5.ino
eb4b21a8b10e2ef1106f8ff5afef91f35e4312dd
[]
no_license
niklasbuhl/Particle-Photon-Aqubiq-Sensor
e079d9623246a6e29e705148b794f1cadaa2075e
7df682b78b8254384ae7bfb2806bf35463f4f03c
refs/heads/master
2021-06-19T02:24:23.646270
2017-06-23T16:31:23
2017-06-23T16:31:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,219
ino
/* * Project project_v4 * Description: * Author: * Date: */ #include "data.h" #include "sd.h" //SYSTEM_MODE(MANUAL); int light; unsigned long timer; unsigned long sequence; reading_structure data; SD sd; // setup() runs once, when the device is first turned on. void setup() { // Put initialization like pinMode and begin functions here. //WiFi.setCredentials(SSID, PASSWORD); //WiFi.setCredentials("nbxyzmobile", "orangepanda"); //Particle.connect(); pinMode(A0, INPUT); light = analogRead(A0); Particle.variable("Light", light); timer = millis(); sd.setup(A2,D0,D1,D2,D3); sequence = 1; } // loop() runs over and over again, as quickly as it can execute. void loop() { // The core of your code will likely live here. //sd.update(); sd.draw(); if(millis() > timer) { timer += 4000; data.count = analogRead(A0); data.sequence_number = sequence; data.timestamp = millis(); //(double)Time.now() + (double)(millis()) / 1000; data.is_send = false; sd.write_data(data); sequence = sequence + 1; } /* if(millis() > connectTimer && Particle.connected() == false) { connectTimer += 60000; Particle.connect(); } */ }
d1ce1951f022a2f14adc14239eee0308654b9f8a
7a09dca02a321ce47c1ff450fd3a3963c3460985
/程式/MEGA/02/02.ino
b045d7cee04458d62e0a76ea26bd141932ee1810
[]
no_license
Blinhy0131/Arduino-robot-arm
a67063750c8b48db3f7cd9432fbaa1c657740707
baeffb5b9a23aa810fb82b17f3f8aaf5720f0e30
refs/heads/main
2023-05-10T14:38:11.377101
2021-06-13T06:06:33
2021-06-13T06:06:33
376,455,351
0
1
null
null
null
null
UTF-8
C++
false
false
5,375
ino
#include "PS2X_lib.h" #include <Servo.h> PS2X ps2x; Servo bottom_Spin; Servo bottom_Rotate; Servo sec_Rotate; Servo sec_Spin; Servo arm_Spin; Servo arm_Rotate; Servo jaw_Contral; Servo jaw_Rotate; int error=0; byte type=0; byte vibrate=0; unsigned long ps2x_tick = 0; // 宣告計時參數 void setup() { bottom_Spin.attach(9); //大臂旋轉 bottom_Rotate.attach(8);//大臂自轉 sec_Rotate.attach(7); //二臂旋轉 sec_Spin.attach(6); //二臂自轉 arm_Spin.attach(5); //手腕自轉 arm_Rotate.attach(4); //手腕旋轉 jaw_Rotate.attach(3); //夾爪自轉 jaw_Contral.attach(2); //夾爪控制 pinMode(22,OUTPUT); pinMode(23,OUTPUT); pinMode(24,OUTPUT); pinMode(25,OUTPUT); Serial.begin(9600); // 控制器接腳設置並驗證是否有錯誤: GamePad(時脈腳位, 命令腳位, 選取腳位, 資料腳位, 是否支援類比按鍵, 是否支援震動) error = ps2x.config_gamepad(13,11,10,12, true, true); if(error == 0) { // 如果控制器連接沒有問題,就顯示底下的訊息。 digitalWrite(22,HIGH); } else if(error == 1){ // 找不到控制器,顯示底下的錯誤訊息。 digitalWrite(23,HIGH); } else if(error == 2) {// 發現控制器,但不接受命令,請參閱程式作者網站的除錯說明。 digitalWrite(24,HIGH); } else if(error == 3){ // 控制器拒絕進入類比感測壓力模式,或許是此控制器不支援的緣故。 digitalWrite(25,LOW);; } } int jawr=90; //馬達角度 int jawc=90; int armr=90; int arms=90; int secs=90; int secr=90; int botr=90; int bots=90; int ss=analogRead(PSS_RX); int sr=analogRead(PSS_RY); int bs=analogRead(PSS_LX); int br=analogRead(PSS_LY); int set_nember=1; int jawr_set[]={1,2,3,4,5,6}; //自動重複 int jawc_set[]={1,2,3,4,5,6}; int armr_set[]={1,2,3,4,5,6}; int arms_set[]={1,2,3,4,5,6}; int secs_set[]={1,2,3,4,5,6}; int secr_set[]={1,2,3,4,5,6}; int botr_set[]={1,2,3,4,5,6}; int bots_set[]={1,2,3,4,5,6}; void loop() { if(error == 1) // 如果沒發現任何控制器,則跳出迴圈。 return; ps2x.read_gamepad(false, 0); if(ps2x.ButtonPressed(PSB_START)==true){ // 系統歸零 *角度代設定* bottom_Spin.write(90); bottom_Rotate.write(90); sec_Rotate.write(90); sec_Spin.write(90); arm_Spin.write(90); arm_Rotate.write(90); jaw_Rotate.write(90); jaw_Contral.write(90); jawc=90; jawr=90; armr=90; arms=90; secs=90; secr=90; botr=90; bots=90; } secs=map(ss, 0, 255,0,180); //二臂旋轉 sec_Spin.write(secs); secr=map(sr, 0, 255,0,180); //二臂自轉 sec_Rotate.write(secr); bots=map(bs, 0, 255,0,180); //大臂旋轉 bottom_Spin.write(bots); botr=map(br, 0, 255,0,180); //大臂自轉 bottom_Rotate.write(botr); if(ps2x.ButtonPressed(PSB_R2)==true){ //夾爪合,待確認 if(jawc<180){ jawc=jawc+1; jaw_Contral.write(jawc); delay(50); } digitalWrite(23,HIGH); delay(1000); digitalWrite(23,LOW); } if(ps2x.ButtonPressed(PSB_L2)==true){ //夾爪開,待確認 if(jawc>0){ jawc=jawc-1; jaw_Contral.write(jawc); } } if(ps2x.Button(PSB_PAD_LEFT)){ //手腕旋轉 if(arms>0){ arms=arms-5; arm_Spin.write(arms); } } if(ps2x.Button(PSB_PAD_RIGHT)){ if(arms<180){ arms=arms+5; arm_Spin.write(arms); } } if(ps2x.Button(PSB_PAD_UP)){ //手腕上下擺動 if(armr<180){ armr=armr+5; arm_Rotate.write(armr); } } if(ps2x.Button(PSB_PAD_DOWN)){ if(armr>0){ armr=armr-5; arm_Rotate.write(armr); } } if(ps2x.Button(PSB_R1)){ //手腕轉動 if(jawr<180){ jawr=jawr+5; jaw_Rotate.write(jawr); } } if(ps2x.Button(PSB_L1)){ if(jawr>0){ jawr=jawr-5; jaw_Rotate.write(jawr); } } if(ps2x.Button(PSB_SELECT)){ //連續做動設定 if (set_nember<=6){ jawr_set[set_nember]=jawr; jawc_set[set_nember]=jawc; armr_set[set_nember]=armr; arms_set[set_nember]=arms; secs_set[set_nember]=secs; secr_set[set_nember]=secr; bots_set[set_nember]=bots; botr_set[set_nember]=botr; set_nember++; }else{ for(int set_error=1;set_error<=3;set_error++){ digitalWrite(22,HIGH); digitalWrite(23,HIGH); digitalWrite(24,HIGH); digitalWrite(25,HIGH); delay(500); digitalWrite(22,LOW); digitalWrite(23,LOW); digitalWrite(24,LOW); digitalWrite(25,LOW); delay(500); } } } if(ps2x.ButtonPressed(PSB_GREEN)){ //連續做動 for(int repeat_time=1;repeat_time<=10;repeat_time++) for(int repeat=1;repeat<=set_nember;repeat++){ bottom_Spin.write(bots_set[repeat]); bottom_Rotate.write(botr_set[repeat]); sec_Rotate.write(secr_set[repeat]); sec_Spin.write(secs_set[repeat]); arm_Spin.write(arms_set[repeat]); arm_Rotate.write(armr_set[repeat]); jaw_Rotate.write(jawr_set[repeat]); jaw_Contral.write(jawc_set[repeat]); delay(1000); } } }
11e35b048c618c1053a7b945fcd4719df66815f2
85b690ce5b5952b6d886946e0bae43b975004a11
/Application/Input/openfoam-org/processor3/0.85/phi
7c3282b96dd2330aea72e84b06f5482d97442f0e
[]
no_license
pace-gt/PACE-ProvBench
c89820cf160c0577e05447d553a70b0e90d54d45
4c55dda0e9edb4a381712a50656855732af3e51a
refs/heads/master
2023-03-12T06:56:30.228126
2021-02-25T22:49:07
2021-02-25T22:49:07
257,307,245
1
0
null
null
null
null
UTF-8
C++
false
false
49,727
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 5.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class surfaceScalarField; location "0.85"; object phi; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 3 -1 0 0 0 0]; internalField nonuniform List<scalar> 3782 ( 2.57357e-05 3.48247e-05 2.5788e-05 3.53123e-05 2.56859e-05 3.50673e-05 2.55122e-05 3.43102e-05 2.53116e-05 3.32261e-05 2.51012e-05 3.19667e-05 2.48785e-05 3.0652e-05 2.46286e-05 2.93734e-05 2.43298e-05 2.81965e-05 2.39577e-05 2.71627e-05 2.34894e-05 2.62929e-05 2.29048e-05 2.559e-05 2.21884e-05 2.50425e-05 2.13303e-05 2.46278e-05 2.03262e-05 2.43151e-05 1.91772e-05 2.4069e-05 1.78897e-05 2.38512e-05 1.64745e-05 2.36235e-05 1.49464e-05 2.3349e-05 1.33232e-05 2.29938e-05 1.16253e-05 2.25284e-05 9.87536e-06 2.19279e-05 8.09722e-06 2.11731e-05 6.31596e-06 2.02514e-05 4.55728e-06 1.91567e-05 2.84715e-06 1.78908e-05 1.21139e-06 1.64633e-05 -3.25045e-07 1.48927e-05 -1.73889e-06 1.3206e-05 -3.00963e-06 1.14385e-05 -4.12047e-06 9.63277e-06 -5.05963e-06 7.83757e-06 -5.82162e-06 6.10567e-06 -6.4082e-06 4.49097e-06 -6.82894e-06 3.04491e-06 -7.10126e-06 1.8124e-06 -7.2496e-06 8.27521e-07 -7.30364e-06 1.09426e-07 -7.29549e-06 -3.41111e-07 -7.25624e-06 -5.43823e-07 -7.21202e-06 -5.38583e-07 -7.18064e-06 -3.81441e-07 -1.36216e-07 3.40922e-05 2.33345e-05 3.29464e-05 2.20043e-05 3.14151e-05 2.03145e-05 1.82826e-05 2.95542e-05 3.48987e-05 2.37481e-05 3.41042e-05 2.27987e-05 3.2921e-05 2.14978e-05 1.98485e-05 3.13551e-05 3.48329e-05 2.39826e-05 3.42398e-05 2.33919e-05 3.32603e-05 2.24773e-05 2.12337e-05 3.18751e-05 3.41684e-05 2.41243e-05 3.36879e-05 2.38724e-05 3.28318e-05 2.33333e-05 2.24962e-05 3.15693e-05 3.31319e-05 2.42186e-05 3.27204e-05 2.42839e-05 3.19527e-05 2.4101e-05 2.36551e-05 3.07939e-05 3.19045e-05 2.42808e-05 3.15502e-05 2.46382e-05 3.08664e-05 2.47849e-05 2.47025e-05 2.98189e-05 3.06265e-05 2.43062e-05 3.03379e-05 2.49269e-05 2.97527e-05 2.53701e-05 2.5615e-05 2.88403e-05 2.94016e-05 2.42781e-05 2.9199e-05 2.51295e-05 2.87375e-05 2.58315e-05 2.63612e-05 2.79912e-05 2.83012e-05 2.41734e-05 2.82101e-05 2.52206e-05 2.79007e-05 2.61409e-05 2.69097e-05 2.73522e-05 2.73683e-05 2.39678e-05 2.74143e-05 2.51746e-05 2.72836e-05 2.62717e-05 2.72331e-05 2.69601e-05 2.66219e-05 2.36388e-05 2.68275e-05 2.4969e-05 2.6897e-05 2.62022e-05 2.73113e-05 2.68187e-05 2.60608e-05 2.3168e-05 2.64432e-05 2.45866e-05 2.67281e-05 2.59173e-05 2.71323e-05 2.69071e-05 2.56684e-05 2.25421e-05 2.62386e-05 2.40164e-05 2.6747e-05 2.54089e-05 2.66916e-05 2.71877e-05 2.54161e-05 2.17538e-05 2.61789e-05 2.32537e-05 2.6912e-05 2.46757e-05 2.59922e-05 2.76114e-05 2.52675e-05 2.08014e-05 2.62213e-05 2.22999e-05 2.7174e-05 2.3723e-05 2.50438e-05 2.81225e-05 2.51814e-05 1.9689e-05 2.6319e-05 2.11623e-05 2.74802e-05 2.25619e-05 2.38615e-05 2.86624e-05 2.51148e-05 1.84254e-05 2.64239e-05 1.98532e-05 2.77775e-05 2.12083e-05 2.24657e-05 2.91733e-05 2.50249e-05 1.7024e-05 2.6489e-05 1.83891e-05 2.80148e-05 1.96824e-05 2.08802e-05 2.96003e-05 2.48714e-05 1.55016e-05 2.64704e-05 1.67901e-05 2.81451e-05 1.80077e-05 1.91319e-05 2.98934e-05 2.46176e-05 1.38778e-05 2.63289e-05 1.50788e-05 2.81268e-05 1.62098e-05 1.72499e-05 3.00089e-05 2.42315e-05 1.21747e-05 2.60305e-05 1.32798e-05 2.79243e-05 1.43161e-05 1.52641e-05 2.991e-05 2.36867e-05 1.04159e-05 2.55475e-05 1.1419e-05 2.75087e-05 1.23549e-05 1.32056e-05 2.95673e-05 2.2963e-05 8.626e-06 2.48586e-05 9.52336e-06 2.68582e-05 1.03552e-05 1.11052e-05 2.89586e-05 2.20466e-05 6.83078e-06 2.39496e-05 7.62032e-06 2.59584e-05 8.34644e-06 8.99419e-06 2.80693e-05 2.09312e-05 5.05631e-06 2.28138e-05 5.73773e-06 2.48021e-05 6.35807e-06 6.90366e-06 2.68927e-05 1.96182e-05 3.32886e-06 2.14524e-05 3.9035e-06 2.3391e-05 4.41956e-06 4.86454e-06 2.54301e-05 1.81177e-05 1.67451e-06 1.98758e-05 2.14533e-06 2.17352e-05 2.56017e-06 2.90761e-06 2.36921e-05 1.64485e-05 1.18657e-07 1.81036e-05 4.90289e-07 1.98551e-05 8.08604e-07 1.06317e-06 2.16996e-05 1.46394e-05 -1.31479e-06 1.61656e-05 -1.0359e-06 1.77818e-05 -8.07598e-07 -6.39462e-07 1.94845e-05 1.27281e-05 -2.60444e-06 1.41021e-05 -2.40982e-06 1.55575e-05 -2.26301e-06 -2.17278e-06 1.70908e-05 1.07607e-05 -3.73241e-06 1.19625e-05 -3.61157e-06 1.32351e-05 -3.53556e-06 -3.51241e-06 1.45747e-05 8.7908e-06 -4.68564e-06 9.80533e-06 -4.62608e-06 1.08778e-05 -4.60803e-06 -4.63877e-06 1.20042e-05 6.87737e-06 -5.45732e-06 7.69608e-06 -5.4448e-06 8.55796e-06 -5.46988e-06 -5.53909e-06 9.4583e-06 5.08173e-06 -6.04807e-06 5.70407e-06 -6.06715e-06 6.35333e-06 -6.11913e-06 -6.20968e-06 7.02393e-06 3.46365e-06 -6.46682e-06 3.89825e-06 -6.50175e-06 4.34301e-06 -6.56392e-06 -6.65797e-06 4.79129e-06 2.07656e-06 -6.73097e-06 2.34175e-06 -6.76694e-06 2.60124e-06 -6.82343e-06 -6.90388e-06 2.84714e-06 9.62435e-07 -6.86586e-06 1.08584e-06 -6.89034e-06 1.19015e-06 -6.92775e-06 -6.9801e-06 1.26637e-06 1.46542e-07 -6.90295e-06 1.63338e-07 -6.90714e-06 1.51788e-07 -6.91618e-06 -6.93054e-06 1.0223e-07 -3.67111e-07 -6.87695e-06 -4.1739e-07 -6.85687e-06 -4.99736e-07 -6.83383e-06 -6.8067e-06 -6.23579e-07 -5.98956e-07 -6.82181e-06 -6.77086e-07 -6.77875e-06 -7.84789e-07 -6.72614e-06 -6.66144e-06 -9.30037e-07 -5.94243e-07 -6.76615e-06 -6.67106e-07 -6.70591e-06 -7.61538e-07 -6.63173e-06 -6.54018e-06 -8.82789e-07 -4.188e-07 -6.72879e-06 -4.65241e-07 -6.65947e-06 -5.22531e-07 -6.57445e-06 -6.47016e-06 -5.92571e-07 -1.48295e-07 -1.62395e-07 -1.78497e-07 -1.96272e-07 2.71139e-05 1.76395e-05 2.42812e-05 1.44441e-05 2.12829e-05 1.12855e-05 1.8398e-05 8.32339e-06 1.54319e-05 5.60148e-06 1.26609e-05 3.65591e-06 1.11836e-05 2.85544e-06 1.0275e-05 2.24654e-06 9.51972e-06 1.73417e-06 8.49367e-06 1.17627e-06 6.87029e-06 6.15505e-07 4.51305e-06 8.42601e-07 1.56222e-06 2.33432e-06 -1.93723e-06 4.57996e-06 -5.72771e-06 6.93672e-06 -9.71397e-06 8.69788e-06 -1.33452e-05 1.01462e-05 -1.66496e-05 1.07907e-05 -1.9518e-05 1.08512e-05 -2.18642e-05 1.10157e-05 -2.36124e-05 1.12602e-05 -2.47517e-05 1.11227e-05 -2.51307e-05 1.06856e-05 -2.45809e-05 9.97941e-06 -2.30786e-05 8.7947e-06 -2.0689e-05 6.81749e-06 -1.75224e-05 3.78994e-06 -1.37622e-05 1.28093e-07 -9.46011e-06 -4.06923e-06 -4.58891e-06 -8.95107e-06 8.05882e-07 -1.48887e-05 6.54404e-06 -2.22065e-05 1.22103e-05 -3.12685e-05 1.71558e-05 -4.25767e-05 2.05366e-05 -5.63586e-05 2.15978e-05 -7.24005e-05 2.00237e-05 -8.96282e-05 1.59971e-05 -0.000106563 9.52532e-06 -0.00012254 -0.000136302 2.9157e-05 1.98377e-05 2.64933e-05 1.71078e-05 2.34761e-05 1.43027e-05 2.02205e-05 1.15789e-05 1.6745e-05 9.07699e-06 1.32975e-05 7.10344e-06 1.03222e-05 5.83071e-06 7.63751e-06 4.93127e-06 5.00732e-06 4.36436e-06 2.16359e-06 4.01999e-06 -8.65288e-07 3.64437e-06 -4.12798e-06 4.10529e-06 -7.64673e-06 5.85305e-06 -1.10484e-05 7.98162e-06 -1.4171e-05 1.00593e-05 -1.71468e-05 1.16737e-05 -1.97922e-05 1.27916e-05 -2.21331e-05 1.31316e-05 -2.41897e-05 1.29078e-05 -2.57121e-05 1.25382e-05 -2.64941e-05 1.20421e-05 -2.65882e-05 1.12169e-05 -2.59592e-05 1.00566e-05 -2.45346e-05 8.55477e-06 -2.23272e-05 6.58731e-06 -1.94575e-05 3.94783e-06 -1.6123e-05 4.55431e-07 -1.24102e-05 -3.58474e-06 -8.28348e-06 -8.19596e-06 -3.68281e-06 -1.35517e-05 1.33549e-06 -1.9907e-05 6.59162e-06 -2.74626e-05 1.17299e-05 -3.64068e-05 1.61184e-05 -4.69652e-05 1.90182e-05 -5.92583e-05 1.98934e-05 -7.32757e-05 1.84929e-05 -8.82277e-05 1.47686e-05 -0.000102838 8.6845e-06 -0.000116456 -0.000127617 2.98317e-05 2.18811e-05 2.72643e-05 1.96752e-05 2.42267e-05 1.73404e-05 2.07922e-05 1.50135e-05 1.70315e-05 1.28377e-05 1.31241e-05 1.10109e-05 9.30308e-06 9.65172e-06 5.56208e-06 8.67228e-06 1.87619e-06 8.05026e-06 -1.77954e-06 7.67573e-06 -5.47383e-06 7.33865e-06 -9.1973e-06 7.82874e-06 -1.28605e-05 9.51619e-06 -1.61595e-05 1.12806e-05 -1.89807e-05 1.28805e-05 -2.1424e-05 1.41171e-05 -2.34075e-05 1.4775e-05 -2.50068e-05 1.47309e-05 -2.6237e-05 1.4138e-05 -2.69329e-05 1.32341e-05 -2.69606e-05 1.20699e-05 -2.63228e-05 1.05791e-05 -2.50134e-05 8.74711e-06 -2.30112e-05 6.55256e-06 -2.03487e-05 3.92488e-06 -1.71856e-05 7.84699e-07 -1.37875e-05 -2.94268e-06 -1.01059e-05 -7.26632e-06 -6.11809e-06 -1.21838e-05 -1.84033e-06 -1.78295e-05 2.64677e-06 -2.43941e-05 7.18786e-06 -3.20037e-05 1.15161e-05 -4.0735e-05 1.51586e-05 -5.06078e-05 1.75384e-05 -6.16381e-05 1.8198e-05 -7.39352e-05 1.68571e-05 -8.68868e-05 1.33953e-05 -9.93764e-05 7.80621e-06 -0.000110867 -0.000119811 2.96505e-05 2.37999e-05 2.71837e-05 2.2142e-05 2.41941e-05 2.03299e-05 2.07347e-05 1.84729e-05 1.68823e-05 1.66901e-05 1.27759e-05 1.51173e-05 8.57777e-06 1.38499e-05 4.35613e-06 1.28939e-05 2.06716e-07 1.21997e-05 -3.66083e-06 1.15433e-05 -7.56713e-06 1.12449e-05 -1.15474e-05 1.1809e-05 -1.51495e-05 1.31183e-05 -1.82572e-05 1.43883e-05 -2.08326e-05 1.54559e-05 -2.2855e-05 1.61394e-05 -2.43358e-05 1.62559e-05 -2.53559e-05 1.57509e-05 -2.59355e-05 1.47176e-05 -2.5997e-05 1.32956e-05 -2.54714e-05 1.15443e-05 -2.43521e-05 9.4598e-06 -2.2645e-05 7.04003e-06 -2.03625e-05 4.27002e-06 -1.7548e-05 1.11046e-06 -1.42941e-05 -2.46923e-06 -1.07764e-05 -6.46043e-06 -7.09193e-06 -1.09508e-05 -3.26695e-06 -1.60088e-05 6.84849e-07 -2.17813e-05 4.68639e-06 -2.83956e-05 8.58744e-06 -3.59047e-05 1.21429e-05 -4.42905e-05 1.49607e-05 -5.34256e-05 1.66842e-05 -6.33616e-05 1.69727e-05 -7.42237e-05 1.5506e-05 -8.54202e-05 1.21858e-05 -9.60563e-05 7.02035e-06 -0.000105701 -0.000112791 2.90047e-05 2.5589e-05 2.66755e-05 2.44712e-05 2.38175e-05 2.31879e-05 2.04717e-05 2.18187e-05 1.67107e-05 2.0451e-05 1.2652e-05 1.9176e-05 8.43501e-06 1.80669e-05 4.15671e-06 1.71722e-05 -6.02967e-08 1.64167e-05 -3.96476e-06 1.54477e-05 -7.75642e-06 1.50366e-05 -1.15847e-05 1.56372e-05 -1.50096e-05 1.65432e-05 -1.78942e-05 1.72729e-05 -2.01777e-05 1.77394e-05 -2.18423e-05 1.7804e-05 -2.29337e-05 1.73474e-05 -2.35218e-05 1.6339e-05 -2.36383e-05 1.48342e-05 -2.32628e-05 1.292e-05 -2.23717e-05 1.06533e-05 -2.0969e-05 8.05709e-06 -1.9072e-05 5.14306e-06 -1.67104e-05 1.90844e-06 -1.39364e-05 -1.66356e-06 -1.08193e-05 -5.58636e-06 -7.41492e-06 -9.86477e-06 -3.81852e-06 -1.45472e-05 -9.8453e-08 -1.97288e-05 3.62317e-06 -2.55029e-05 7.17249e-06 -3.1945e-05 1.04238e-05 -3.91561e-05 1.32305e-05 -4.70971e-05 1.52961e-05 -5.54912e-05 1.63935e-05 -6.4459e-05 1.62258e-05 -7.4056e-05 1.45091e-05 -8.37035e-05 1.12167e-05 -9.27638e-05 6.36886e-06 -0.000100854 -0.000106422 2.81867e-05 2.72212e-05 2.60465e-05 2.66114e-05 2.34029e-05 2.58315e-05 2.02881e-05 2.49335e-05 1.67651e-05 2.3974e-05 1.29333e-05 2.30078e-05 8.92232e-06 2.20779e-05 4.86003e-06 2.12345e-05 9.50186e-07 2.03265e-05 -2.78386e-06 1.91818e-05 -6.3954e-06 1.86481e-05 -9.89613e-06 1.91379e-05 -1.29969e-05 1.9644e-05 -1.55532e-05 1.98292e-05 -1.75035e-05 1.96897e-05 -1.88443e-05 1.91449e-05 -1.96195e-05 1.81226e-05 -1.98883e-05 1.66078e-05 -1.96907e-05 1.46365e-05 -1.90377e-05 1.22671e-05 -1.79347e-05 9.55027e-06 -1.63979e-05 6.5203e-06 -1.44531e-05 3.1982e-06 -1.2136e-05 -4.08613e-07 -9.49636e-06 -4.3032e-06 -6.59094e-06 -8.49177e-06 -3.46861e-06 -1.29871e-05 -1.86658e-07 -1.78291e-05 3.17133e-06 -2.30868e-05 6.48924e-06 -2.88208e-05 9.62064e-06 -3.50764e-05 1.2355e-05 -4.18905e-05 1.44644e-05 -4.92065e-05 1.58502e-05 -5.68769e-05 1.63724e-05 -6.49813e-05 1.5737e-05 -7.34206e-05 1.37627e-05 -8.17292e-05 1.045e-05 -8.94512e-05 5.83922e-06 -9.62428e-05 -0.000100582 2.74048e-05 2.86567e-05 2.55108e-05 2.85054e-05 2.31599e-05 2.81824e-05 2.03774e-05 2.7716e-05 1.72146e-05 2.71368e-05 1.37502e-05 2.64722e-05 1.00972e-05 2.57309e-05 6.45502e-06 2.48767e-05 3.05925e-06 2.37223e-05 -3.40212e-07 2.25812e-05 -3.74879e-06 2.20567e-05 -6.86814e-06 2.22573e-05 -9.53054e-06 2.23064e-05 -1.16756e-05 2.19743e-05 -1.32614e-05 2.12755e-05 -1.42881e-05 2.01716e-05 -1.47918e-05 1.86262e-05 -1.48201e-05 1.66361e-05 -1.44146e-05 1.4231e-05 -1.36011e-05 1.14537e-05 -1.24011e-05 8.35027e-06 -1.08395e-05 4.95867e-06 -8.9465e-06 1.30524e-06 -6.75957e-06 -2.59554e-06 -4.32482e-06 -6.73794e-06 -1.69304e-06 -1.11235e-05 1.08391e-06 -1.5764e-05 3.94407e-06 -2.06893e-05 6.80041e-06 -2.59432e-05 9.54614e-06 -3.15666e-05 1.20563e-05 -3.75865e-05 1.41649e-05 -4.39992e-05 1.56772e-05 -5.07187e-05 1.65124e-05 -5.77121e-05 1.65062e-05 -6.49751e-05 1.54407e-05 -7.2355e-05 1.32232e-05 -7.95117e-05 9.86346e-06 -8.60914e-05 5.42155e-06 -9.18009e-05 -9.51609e-05 2.67962e-05 2.98517e-05 2.52038e-05 3.00978e-05 2.32156e-05 3.01705e-05 2.08537e-05 3.0078e-05 1.81616e-05 2.98289e-05 1.52064e-05 2.94274e-05 1.20834e-05 2.88538e-05 8.94858e-06 2.80116e-05 5.91087e-06 2.676e-05 2.93495e-06 2.55572e-05 -5.71916e-08 2.50489e-05 -2.70955e-06 2.49096e-05 -4.89459e-06 2.44914e-05 -6.60049e-06 2.36802e-05 -7.81213e-06 2.24871e-05 -8.53506e-06 2.08945e-05 -8.79809e-06 1.88893e-05 -8.63998e-06 1.6478e-05 -8.09853e-06 1.36895e-05 -7.20579e-06 1.0561e-05 -5.99057e-06 7.13506e-06 -4.48239e-06 3.45048e-06 -2.71349e-06 -4.63655e-07 -7.21459e-07 -4.58756e-06 1.4497e-06 -8.90908e-06 3.75095e-06 -1.34248e-05 6.12811e-06 -1.81412e-05 8.51572e-06 -2.30769e-05 1.08307e-05 -2.82581e-05 1.29725e-05 -3.37084e-05 1.48237e-05 -3.94377e-05 1.62517e-05 -4.54272e-05 1.71529e-05 -5.16199e-05 1.74149e-05 -5.79742e-05 1.68804e-05 -6.44407e-05 1.54031e-05 -7.08777e-05 1.29254e-05 -7.70339e-05 9.4731e-06 -8.26392e-05 5.12078e-06 -8.74486e-05 -9.00401e-05 2.64375e-05 3.07664e-05 2.51925e-05 3.13428e-05 2.36205e-05 3.17425e-05 2.17416e-05 3.19569e-05 1.95944e-05 3.19761e-05 1.72362e-05 3.17856e-05 1.47369e-05 3.13531e-05 1.21485e-05 3.06e-05 9.47289e-06 2.94356e-05 6.88194e-06 2.81481e-05 4.42572e-06 2.75051e-05 2.33039e-06 2.7005e-05 6.5366e-07 2.61682e-05 -6.06675e-07 2.49405e-05 -1.44891e-06 2.33293e-05 -1.88264e-06 2.13283e-05 -1.9306e-06 1.89372e-05 -1.62413e-06 1.61715e-05 -9.95908e-07 1.30613e-05 -7.91614e-08 9.64422e-06 1.09474e-06 5.96119e-06 2.49456e-06 2.05066e-06 4.08738e-06 -2.05645e-06 5.83581e-06 -6.33598e-06 7.69742e-06 -1.07707e-05 9.62452e-06 -1.53519e-05 1.1563e-05 -2.00797e-05 1.34488e-05 -2.49627e-05 1.52046e-05 -3.00139e-05 1.67402e-05 -3.5244e-05 1.7955e-05 -4.06526e-05 1.87456e-05 -4.62178e-05 1.90179e-05 -5.18922e-05 1.86724e-05 -5.76286e-05 1.7592e-05 -6.33603e-05 1.56796e-05 -6.89653e-05 1.29024e-05 -7.42567e-05 9.29608e-06 -7.90328e-05 4.94347e-06 -8.3096e-05 -8.50966e-05 2.63566e-05 3.137e-05 2.549e-05 3.22094e-05 2.43649e-05 3.28676e-05 2.2999e-05 3.33228e-05 2.14234e-05 3.35516e-05 1.96816e-05 3.35274e-05 1.78194e-05 3.32153e-05 1.58527e-05 3.25667e-05 1.37321e-05 3.15562e-05 1.15296e-05 3.03507e-05 9.60158e-06 2.94331e-05 8.07089e-06 2.85357e-05 6.89708e-06 2.7342e-05 6.06596e-06 2.57716e-05 5.57526e-06 2.38201e-05 5.41281e-06 2.14907e-05 5.55827e-06 1.87918e-05 5.98603e-06 1.57438e-05 6.66688e-06 1.23805e-05 7.56944e-06 8.74163e-06 8.66267e-06 4.86799e-06 9.91548e-06 7.97846e-07 1.12953e-05 -3.43621e-06 1.27656e-05 -7.80629e-06 1.42859e-05 -1.2291e-05 1.58106e-05 -1.68766e-05 1.72877e-05 -2.15568e-05 1.8657e-05 -2.6332e-05 1.98484e-05 -3.12052e-05 2.07826e-05 -3.61782e-05 2.1375e-05 -4.12449e-05 2.15378e-05 -4.63805e-05 2.11885e-05 -5.15429e-05 2.02454e-05 -5.66855e-05 1.86248e-05 -6.17398e-05 1.62635e-05 -6.6604e-05 1.31509e-05 -7.1144e-05 9.3303e-06 -7.52122e-05 4.88888e-06 -7.86545e-05 -8.02077e-05 2.6546e-05 3.16427e-05 2.60735e-05 3.26818e-05 2.54057e-05 3.35354e-05 2.45561e-05 3.41725e-05 2.35466e-05 3.45611e-05 2.24054e-05 3.46686e-05 2.11578e-05 3.44629e-05 1.98089e-05 3.39156e-05 1.83341e-05 3.3031e-05 1.67665e-05 3.19183e-05 1.5401e-05 3.07986e-05 1.43635e-05 2.95732e-05 1.36356e-05 2.80699e-05 1.31931e-05 2.62141e-05 1.30229e-05 2.39903e-05 1.31087e-05 2.14049e-05 1.34284e-05 1.8472e-05 1.39575e-05 1.52146e-05 1.46688e-05 1.16693e-05 1.55332e-05 7.87716e-06 1.65215e-05 3.87974e-06 1.76037e-05 -2.84353e-07 1.87483e-05 -4.58078e-06 1.99206e-05 -8.97863e-06 2.10825e-05 -1.34529e-05 2.21913e-05 -1.79853e-05 2.31985e-05 -2.25641e-05 2.40491e-05 -2.71826e-05 2.46806e-05 -3.18368e-05 2.50244e-05 -3.6522e-05 2.50077e-05 -4.12282e-05 2.45571e-05 -4.593e-05 2.36037e-05 -5.05895e-05 2.20819e-05 -5.51637e-05 1.99331e-05 -5.9591e-05 1.71196e-05 -6.37905e-05 1.36454e-05 -6.76699e-05 9.55965e-06 -7.11265e-05 4.95004e-06 -7.40449e-05 -7.52577e-05 2.69743e-05 3.15755e-05 2.68987e-05 3.27573e-05 2.66838e-05 3.37503e-05 2.63382e-05 3.45181e-05 2.5875e-05 3.50243e-05 2.53095e-05 3.52342e-05 2.46539e-05 3.51185e-05 2.39105e-05 3.4659e-05 2.30769e-05 3.38646e-05 2.21971e-05 3.2798e-05 2.14402e-05 3.15555e-05 2.09062e-05 3.01072e-05 2.06073e-05 2.83689e-05 2.05298e-05 2.62916e-05 2.06577e-05 2.38623e-05 2.09726e-05 2.109e-05 2.14519e-05 1.79927e-05 2.20696e-05 1.45969e-05 2.27994e-05 1.09395e-05 2.3614e-05 7.0625e-06 2.44861e-05 3.00767e-06 2.53875e-05 -1.18574e-06 2.62883e-05 -5.48163e-06 2.71564e-05 -9.8467e-06 2.79564e-05 -1.42529e-05 2.86492e-05 -1.8678e-05 2.91906e-05 -2.31055e-05 2.95314e-05 -2.75234e-05 2.96169e-05 -3.19223e-05 2.93879e-05 -3.6293e-05 2.87821e-05 -4.06225e-05 2.77404e-05 -4.48883e-05 2.62064e-05 -4.90555e-05 2.41289e-05 -5.30861e-05 2.14665e-05 -5.69286e-05 1.82027e-05 -6.05267e-05 1.43501e-05 -6.38174e-05 9.95923e-06 -6.67356e-05 5.11434e-06 -6.92e-05 -7.01434e-05 2.7594e-05 3.11692e-05 2.79081e-05 3.24433e-05 2.81316e-05 3.35267e-05 2.82689e-05 3.43809e-05 2.8326e-05 3.49672e-05 2.83092e-05 3.52509e-05 2.82232e-05 3.52045e-05 2.807e-05 3.48123e-05 2.78573e-05 3.40772e-05 2.76232e-05 3.30322e-05 2.74584e-05 3.17203e-05 2.74306e-05 3.0135e-05 2.75594e-05 2.82401e-05 2.78389e-05 2.60121e-05 2.82548e-05 2.34464e-05 2.87888e-05 2.0556e-05 2.94184e-05 1.73631e-05 3.01182e-05 1.38972e-05 3.08622e-05 1.01955e-05 3.1625e-05 6.29976e-06 3.23806e-05 2.25208e-06 3.31027e-05 -1.90785e-06 3.37636e-05 -6.14252e-06 3.43337e-05 -1.04168e-05 3.47809e-05 -1.47001e-05 3.50699e-05 -1.8967e-05 3.51615e-05 -2.31971e-05 3.50123e-05 -2.73743e-05 3.45751e-05 -3.14851e-05 3.37992e-05 -3.55171e-05 3.26331e-05 -3.94563e-05 3.1028e-05 -4.32832e-05 2.89415e-05 -4.6969e-05 2.63326e-05 -5.04773e-05 2.31757e-05 -5.37718e-05 1.94674e-05 -5.68184e-05 1.5226e-05 -5.95759e-05 1.04994e-05 -6.2009e-05 5.36498e-06 -6.40656e-05 -6.47784e-05 2.83478e-05 3.04328e-05 2.90359e-05 3.17553e-05 2.96756e-05 3.2887e-05 3.02679e-05 3.37886e-05 3.08136e-05 3.44215e-05 3.1313e-05 3.47515e-05 3.17659e-05 3.47515e-05 3.21726e-05 3.44056e-05 3.25397e-05 3.37101e-05 3.28921e-05 3.26798e-05 3.32778e-05 3.13346e-05 3.37361e-05 2.96767e-05 3.42812e-05 2.7695e-05 3.49097e-05 2.53836e-05 3.56075e-05 2.27486e-05 3.63556e-05 1.98079e-05 3.71324e-05 1.65864e-05 3.7914e-05 1.31156e-05 3.86756e-05 9.43384e-06 3.93927e-05 5.58262e-06 4.0041e-05 1.60383e-06 4.05958e-05 -2.46262e-06 4.10315e-05 -6.57821e-06 4.13212e-05 -1.07065e-05 4.14361e-05 -1.48151e-05 4.1345e-05 -1.88759e-05 4.10134e-05 -2.28656e-05 4.04039e-05 -2.67647e-05 3.94761e-05 -3.05573e-05 3.81879e-05 -3.42289e-05 3.64967e-05 -3.77651e-05 3.43628e-05 -4.11493e-05 3.17531e-05 -4.43593e-05 2.864e-05 -4.73642e-05 2.50111e-05 -5.01429e-05 2.08684e-05 -5.26756e-05 1.62327e-05 -5.49402e-05 1.11482e-05 -5.69245e-05 5.68268e-06 -5.86001e-05 -5.90957e-05 2.91727e-05 2.93825e-05 3.02121e-05 3.07159e-05 3.12394e-05 3.18597e-05 3.22527e-05 3.27753e-05 3.3249e-05 3.34252e-05 3.42245e-05 3.37759e-05 3.5175e-05 3.38011e-05 3.60973e-05 3.34833e-05 3.69921e-05 3.28154e-05 3.78708e-05 3.18011e-05 3.87558e-05 3.04495e-05 3.96648e-05 2.87676e-05 4.06032e-05 2.67566e-05 4.15645e-05 2.44224e-05 4.2534e-05 2.17791e-05 4.34929e-05 1.8849e-05 4.44183e-05 1.5661e-05 4.52873e-05 1.22467e-05 4.60761e-05 8.64501e-06 4.67613e-05 4.89748e-06 4.73196e-05 1.04554e-06 4.77279e-05 -2.87099e-06 4.79628e-05 -6.81304e-06 4.79997e-05 -1.07434e-05 4.7813e-05 -1.46284e-05 4.73752e-05 -1.84381e-05 4.66564e-05 -2.21468e-05 4.56247e-05 -2.5733e-05 4.42462e-05 -2.91788e-05 4.2486e-05 -3.24687e-05 4.031e-05 -3.5589e-05 3.76863e-05 -3.85256e-05 3.45891e-05 -4.12621e-05 3.10042e-05 -4.37793e-05 2.69262e-05 -4.60649e-05 2.23606e-05 -4.811e-05 1.73295e-05 -4.99091e-05 1.18728e-05 -5.14678e-05 6.0472e-06 -5.27745e-05 -5.30485e-05 3.0004e-05 2.80409e-05 3.13664e-05 2.93535e-05 3.2747e-05 3.0479e-05 3.41419e-05 3.13804e-05 3.55453e-05 3.20217e-05 3.69501e-05 3.23712e-05 3.83482e-05 3.24029e-05 3.97324e-05 3.20991e-05 4.10975e-05 3.14503e-05 4.24428e-05 3.04558e-05 4.37724e-05 2.912e-05 4.50892e-05 2.74508e-05 4.63898e-05 2.5456e-05 4.76625e-05 2.31497e-05 4.88905e-05 2.05511e-05 5.00538e-05 1.76857e-05 5.11296e-05 1.45852e-05 5.20943e-05 1.1282e-05 5.29243e-05 7.81504e-06 5.35965e-05 4.22529e-06 5.40886e-05 5.53428e-07 5.43788e-05 -3.16117e-06 5.4445e-05 -6.87927e-06 5.4265e-05 -1.05634e-05 5.38156e-05 -1.41791e-05 5.30727e-05 -1.76951e-05 5.20105e-05 -2.10846e-05 5.06017e-05 -2.43243e-05 4.88182e-05 -2.73953e-05 4.66317e-05 -3.02822e-05 4.4015e-05 -3.29723e-05 4.09441e-05 -3.54547e-05 3.74009e-05 -3.77189e-05 3.33774e-05 -3.97558e-05 2.88736e-05 -4.15612e-05 2.38992e-05 -4.31356e-05 1.84767e-05 -4.44865e-05 1.26412e-05 -4.56324e-05 6.439e-06 -4.65723e-05 -4.66095e-05 3.07787e-05 2.64356e-05 3.24308e-05 2.77014e-05 3.41262e-05 2.87836e-05 3.58592e-05 2.96474e-05 3.7622e-05 3.0259e-05 3.94045e-05 3.05886e-05 4.11956e-05 3.06119e-05 4.29835e-05 3.03112e-05 4.47574e-05 2.96764e-05 4.65082e-05 2.8705e-05 4.82276e-05 2.74005e-05 4.99074e-05 2.57711e-05 5.15346e-05 2.38287e-05 5.30934e-05 2.15909e-05 5.4564e-05 1.90805e-05 5.59245e-05 1.63253e-05 5.71519e-05 1.33578e-05 5.82213e-05 1.02126e-05 5.91083e-05 6.92802e-06 5.979e-05 3.54364e-06 6.02443e-05 9.91092e-08 6.045e-05 -3.3668e-06 6.03858e-05 -6.81513e-06 6.0031e-05 -1.02086e-05 5.93644e-05 -1.35124e-05 5.83643e-05 -1.6695e-05 5.70081e-05 -1.97284e-05 5.52726e-05 -2.25888e-05 5.31345e-05 -2.52571e-05 5.05708e-05 -2.77186e-05 4.75608e-05 -2.99623e-05 4.40869e-05 -3.19808e-05 4.01376e-05 -3.37696e-05 3.57092e-05 -3.53275e-05 3.08061e-05 -3.6658e-05 2.5441e-05 -3.77706e-05 1.96368e-05 -3.86822e-05 1.34245e-05 -3.94201e-05 6.84069e-06 -3.99885e-05 -3.97688e-05 3.14378e-05 2.45981e-05 3.3343e-05 2.57962e-05 3.53116e-05 2.6815e-05 3.73366e-05 2.76224e-05 3.94083e-05 2.81873e-05 4.15145e-05 2.84823e-05 4.36414e-05 2.8485e-05 4.57735e-05 2.81791e-05 4.78952e-05 2.75548e-05 4.99908e-05 2.66094e-05 5.20446e-05 2.53467e-05 5.40397e-05 2.37759e-05 5.5957e-05 2.19114e-05 5.77753e-05 1.97726e-05 5.94717e-05 1.73841e-05 6.10219e-05 1.4775e-05 6.24013e-05 1.19784e-05 6.3584e-05 9.02995e-06 6.4545e-05 5.96701e-06 6.52606e-05 2.82799e-06 6.57085e-05 -3.48712e-07 6.58668e-05 -3.52511e-06 6.57146e-05 -6.66296e-06 6.52315e-05 -9.72553e-06 6.43974e-05 -1.26783e-05 6.3192e-05 -1.54896e-05 6.15952e-05 -1.81315e-05 5.95866e-05 -2.05803e-05 5.71468e-05 -2.28173e-05 5.42574e-05 -2.48291e-05 5.09026e-05 -2.66074e-05 4.70705e-05 -2.81487e-05 4.27548e-05 -2.94539e-05 3.7956e-05 -3.05287e-05 3.2682e-05 -3.1384e-05 2.69482e-05 -3.20368e-05 2.07775e-05 -3.25116e-05 1.41979e-05 -3.28405e-05 7.23805e-06 -3.30286e-05 -3.25308e-05 3.19286e-05 2.25628e-05 3.40481e-05 2.36767e-05 3.62465e-05 2.46166e-05 3.85157e-05 2.53531e-05 4.0845e-05 2.58581e-05 4.32204e-05 2.61069e-05 4.56259e-05 2.60795e-05 4.80436e-05 2.57614e-05 5.04539e-05 2.51444e-05 5.28368e-05 2.42265e-05 5.51711e-05 2.30124e-05 5.74347e-05 2.15123e-05 5.96039e-05 1.97422e-05 6.16536e-05 1.7723e-05 6.35574e-05 1.54802e-05 6.52887e-05 1.30437e-05 6.68204e-05 1.04467e-05 6.81257e-05 7.7246e-06 6.91787e-05 4.9141e-06 6.99542e-05 2.05249e-06 7.04285e-05 -8.23053e-07 7.05789e-05 -3.67542e-06 7.03833e-05 -6.46737e-06 6.98208e-05 -9.16306e-06 6.88712e-05 -1.17287e-05 6.75146e-05 -1.41331e-05 6.57321e-05 -1.6349e-05 6.35054e-05 -1.83536e-05 6.08176e-05 -2.01295e-05 5.7654e-05 -2.16655e-05 5.4003e-05 -2.29565e-05 4.98574e-05 -2.40031e-05 4.52153e-05 -2.48118e-05 4.00813e-05 -2.53947e-05 3.44666e-05 -2.57694e-05 2.83891e-05 -2.59594e-05 2.18722e-05 -2.59947e-05 1.49417e-05 -2.591e-05 7.6202e-06 -2.57071e-05 -2.49106e-05 3.22058e-05 2.03659e-05 3.44993e-05 2.13832e-05 3.68834e-05 2.22325e-05 3.93493e-05 2.28872e-05 4.18852e-05 2.33222e-05 4.44762e-05 2.35159e-05 4.71049e-05 2.34508e-05 4.97515e-05 2.31148e-05 5.23944e-05 2.25015e-05 5.50103e-05 2.16106e-05 5.7575e-05 2.04477e-05 6.00628e-05 1.90246e-05 6.24468e-05 1.73581e-05 6.46993e-05 1.54705e-05 6.67915e-05 1.3388e-05 6.86944e-05 1.11409e-05 7.03789e-05 8.76213e-06 7.18168e-05 6.28679e-06 7.298e-05 3.75085e-06 7.38419e-05 1.19066e-06 7.43765e-05 -1.35765e-06 7.45589e-05 -3.85781e-06 7.43652e-05 -6.27372e-06 7.37728e-05 -8.57066e-06 7.27601e-05 -1.07159e-05 7.13066e-05 -1.26796e-05 6.93932e-05 -1.44356e-05 6.70026e-05 -1.59629e-05 6.41197e-05 -1.72466e-05 6.07324e-05 -1.82783e-05 5.68327e-05 -1.90568e-05 5.24174e-05 -1.95877e-05 4.74887e-05 -1.98831e-05 4.20551e-05 -1.99611e-05 3.61313e-05 -1.98456e-05 2.97379e-05 -1.9566e-05 2.28994e-05 -1.91562e-05 1.56405e-05 -1.86511e-05 7.97928e-06 -1.80459e-05 -1.69313e-05 3.22316e-05 1.80442e-05 3.46587e-05 1.89562e-05 3.71847e-05 1.97064e-05 3.98005e-05 2.02714e-05 4.24936e-05 2.06291e-05 4.52488e-05 2.07608e-05 4.80477e-05 2.06519e-05 5.087e-05 2.02926e-05 5.36927e-05 1.96788e-05 5.64913e-05 1.88119e-05 5.92397e-05 1.76993e-05 6.19106e-05 1.63538e-05 6.44751e-05 1.47936e-05 6.69038e-05 1.30418e-05 6.91664e-05 1.11255e-05 7.12321e-05 9.07516e-06 7.30703e-05 6.92397e-06 7.46504e-05 4.70666e-06 7.59425e-05 2.45878e-06 7.69171e-05 2.16023e-07 7.75456e-05 -1.98612e-06 7.77998e-05 -4.11203e-06 7.76529e-05 -6.12677e-06 7.70792e-05 -7.99696e-06 7.60546e-05 -9.69137e-06 7.45568e-05 -1.11818e-05 7.25655e-05 -1.24444e-05 7.00632e-05 -1.34606e-05 6.70357e-05 -1.42191e-05 6.3473e-05 -1.47156e-05 5.93701e-05 -1.49538e-05 5.47272e-05 -1.49449e-05 4.95508e-05 -1.47067e-05 4.38533e-05 -1.42636e-05 3.76531e-05 -1.36454e-05 3.09737e-05 -1.28865e-05 2.38414e-05 -1.20239e-05 1.62811e-05 -1.10908e-05 8.30855e-06 -1.00733e-05 -8.62276e-06 3.19763e-05 1.56352e-05 3.44968e-05 1.64357e-05 3.7122e-05 1.70813e-05 3.98423e-05 1.75511e-05 4.26453e-05 1.78261e-05 4.55156e-05 1.78905e-05 4.84351e-05 1.77323e-05 5.13832e-05 1.73445e-05 5.43371e-05 1.67249e-05 5.7272e-05 1.5877e-05 6.01615e-05 1.48098e-05 6.29777e-05 1.35376e-05 6.56914e-05 1.20799e-05 6.82723e-05 1.04609e-05 7.06893e-05 8.70846e-06 7.29106e-05 6.85384e-06 7.4904e-05 4.93062e-06 7.66368e-05 2.97382e-06 7.80765e-05 1.01909e-06 7.91904e-05 -8.97889e-07 7.99459e-05 -2.74162e-06 8.03108e-05 -4.47695e-06 8.02541e-05 -6.07002e-06 7.97459e-05 -7.48883e-06 7.87585e-05 -8.70397e-06 7.72664e-05 -9.68965e-06 7.5247e-05 -1.0425e-05 7.26817e-05 -1.08954e-05 6.95566e-05 -1.1094e-05 6.58633e-05 -1.10223e-05 6.15995e-05 -1.06899e-05 5.67691e-05 -1.01145e-05 5.13827e-05 -9.32031e-06 4.54568e-05 -8.33778e-06 3.90136e-05 -7.20228e-06 3.20799e-05 -5.95273e-06 2.4684e-05 -4.62812e-06 1.68507e-05 -3.25744e-06 8.59279e-06 -1.81541e-06 -2.99393e-08 3.1418e-05 1.31758e-05 3.39924e-05 1.38613e-05 3.66749e-05 1.43987e-05 3.94561e-05 1.47699e-05 4.23237e-05 1.49585e-05 4.5263e-05 1.49512e-05 4.82563e-05 1.4739e-05 5.12841e-05 1.43168e-05 5.43242e-05 1.36848e-05 5.73528e-05 1.28483e-05 6.03444e-05 1.18182e-05 6.32717e-05 1.06103e-05 6.61063e-05 9.24541e-06 6.88181e-05 7.74906e-06 7.1376e-05 6.15052e-06 7.37477e-05 4.48221e-06 7.58994e-05 2.77887e-06 7.77966e-05 1.07662e-06 7.94035e-05 -5.87815e-07 8.06833e-05 -2.17774e-06 8.15987e-05 -3.65697e-06 8.21122e-05 -4.99052e-06 8.21875e-05 -6.14531e-06 8.17894e-05 -7.09077e-06 8.08851e-05 -7.79968e-06 7.94448e-05 -8.24936e-06 7.74429e-05 -8.42306e-06 7.4859e-05 -8.31144e-06 7.16788e-05 -7.91384e-06 6.78954e-05 -7.23886e-06 6.35094e-05 -6.30389e-06 5.85287e-05 -5.13388e-06 5.29685e-05 -3.76008e-06 4.68496e-05 -2.21889e-06 4.01981e-05 -5.50761e-07 3.30437e-05 1.20166e-06 2.54172e-05 2.99838e-06 1.73445e-05 4.81525e-06 8.84006e-06 6.68907e-06 8.81014e-06 3.05422e-05 1.07029e-05 3.31317e-05 1.12718e-05 3.58311e-05 1.16994e-05 3.8631e-05 1.197e-05 4.152e-05 1.20695e-05 4.44841e-05 1.19871e-05 4.75072e-05 1.17158e-05 5.05711e-05 1.12529e-05 5.36554e-05 1.06004e-05 5.67382e-05 9.76551e-06 5.97959e-05 8.76053e-06 6.28031e-05 7.60301e-06 6.5733e-05 6.31548e-06 6.85571e-05 4.92504e-06 7.12447e-05 3.46284e-06 7.37636e-05 1.96333e-06 7.6079e-05 4.63444e-07 7.81539e-05 -9.98313e-07 7.99488e-05 -2.38274e-06 8.1422e-05 -3.6509e-06 8.25302e-05 -4.76514e-06 8.32297e-05 -5.69002e-06 8.34773e-05 -6.39296e-06 8.32313e-05 -6.8448e-06 8.24526e-05 -7.02096e-06 8.11061e-05 -6.9029e-06 7.91624e-05 -6.47938e-06 7.65988e-05 -5.74783e-06 7.34007e-05 -4.71574e-06 6.95628e-05 -3.4009e-06 6.50891e-05 -1.83023e-06 5.99926e-05 -3.73555e-08 5.42931e-05 1.93932e-06 4.80164e-05 4.0579e-06 4.11919e-05 6.27367e-06 3.38524e-05 8.54119e-06 2.60308e-05 1.082e-05 1.77564e-05 1.30897e-05 9.04938e-06 1.53961e-05 1.78595e-05 2.93426e-05 8.25298e-06 3.1909e-05 8.70538e-06 3.45853e-05 9.02315e-06 3.73629e-05 9.19239e-06 4.02312e-05 9.20114e-06 4.31778e-05 9.04053e-06 4.61882e-05 8.70538e-06 4.92464e-05 8.19468e-06 5.23347e-05 7.51207e-06 5.5434e-05 6.66619e-06 5.85236e-05 5.67091e-06 6.15813e-05 4.54534e-06 6.45829e-05 3.31385e-06 6.75023e-05 2.00569e-06 7.03105e-05 6.54604e-07 7.29756e-05 -7.01814e-07 7.5462e-05 -2.02294e-06 7.77299e-05 -3.26619e-06 7.97353e-05 -4.38815e-06 8.14305e-05 -5.34616e-06 8.27652e-05 -6.09985e-06 8.36878e-05 -6.61256e-06 8.41468e-05 -6.85196e-06 8.40923e-05 -6.79039e-06 8.34779e-05 -6.40651e-06 8.22624e-05 -5.68743e-06 8.04123e-05 -4.62923e-06 7.79024e-05 -3.23792e-06 7.47178e-05 -1.5312e-06 7.08555e-05 4.61444e-07 6.6324e-05 2.70125e-06 6.11422e-05 5.14449e-06 5.5336e-05 7.74547e-06 4.89362e-05 1.04578e-05 4.19759e-05 1.3234e-05 3.44898e-05 1.60273e-05 2.65123e-05 1.87975e-05 1.80749e-05 2.15272e-05 9.20139e-06 2.42696e-05 2.70609e-05 2.78207e-05 5.86229e-06 3.03262e-05 6.19996e-06 3.29401e-05 6.40921e-06 3.56549e-05 6.47766e-06 3.84611e-05 6.39491e-06 4.1348e-05 6.15355e-06 4.43037e-05 5.74969e-06 4.73149e-05 5.18349e-06 5.03673e-05 4.45967e-06 5.34456e-05 3.58796e-06 5.6533e-05 2.58342e-06 5.96117e-05 1.46665e-06 6.26616e-05 2.64001e-07 6.56598e-05 -9.92538e-07 6.858e-05 -2.2656e-06 7.13912e-05 -3.51303e-06 7.4057e-05 -4.68873e-06 7.65348e-05 -5.74392e-06 7.87753e-05 -6.62874e-06 8.07236e-05 -7.29442e-06 8.23199e-05 -7.69615e-06 8.35027e-05 -7.79534e-06 8.42109e-05 -7.56016e-06 8.43849e-05 -6.96445e-06 8.39693e-05 -5.9909e-06 8.29167e-05 -4.63481e-06 8.11897e-05 -2.90217e-06 7.87609e-05 -8.09185e-07 7.56154e-05 1.61429e-06 7.17528e-05 4.32405e-06 6.71881e-05 7.26597e-06 6.19486e-05 1.03841e-05 5.6068e-05 1.36261e-05 4.95823e-05 1.69434e-05 4.25277e-05 2.02886e-05 3.49391e-05 2.36158e-05 2.68512e-05 2.68854e-05 1.82964e-05 3.0082e-05 9.30364e-06 3.32624e-05 3.63646e-05 2.59876e-05 3.56685e-06 2.83943e-05 3.79324e-06 3.09066e-05 3.89686e-06 3.35179e-05 3.86644e-06 3.62202e-05 3.6926e-06 3.9005e-05 3.36876e-06 4.1863e-05 2.89167e-06 4.47845e-05 2.26199e-06 4.77593e-05 1.48484e-06 5.07769e-05 5.70386e-07 5.38259e-05 -4.65606e-07 5.68938e-05 -1.60122e-06 5.99658e-05 -2.80798e-06 6.30239e-05 -4.05059e-06 6.60452e-05 -5.28697e-06 6.90009e-05 -6.46873e-06 7.18544e-05 -7.54214e-06 7.456e-05 -8.44954e-06 7.70625e-05 -9.13127e-06 7.9297e-05 -9.52887e-06 8.11914e-05 -9.59054e-06 8.26716e-05 -9.27554e-06 8.36656e-05 -8.55419e-06 8.41025e-05 -7.40135e-06 8.39156e-05 -5.80401e-06 8.30516e-05 -3.77084e-06 8.14712e-05 -1.3217e-06 7.91453e-05 1.51669e-06 7.60587e-05 4.70088e-06 7.2215e-05 8.16777e-06 6.76386e-05 1.18424e-05 6.2369e-05 1.56537e-05 5.64502e-05 1.95448e-05 4.9923e-05 2.34707e-05 4.28239e-05 2.73878e-05 3.51856e-05 3.12541e-05 2.70399e-05 3.50311e-05 1.84195e-05 3.87024e-05 9.3578e-06 4.23241e-05 4.57224e-05 2.38641e-05 1.40233e-06 2.61346e-05 1.5228e-06 2.85059e-05 1.52555e-06 3.09724e-05 1.39995e-06 3.35279e-05 1.13704e-06 3.61663e-05 7.30379e-07 3.88814e-05 1.76593e-07 4.16674e-05 -5.24031e-07 4.45191e-05 -1.36685e-06 4.74316e-05 -2.3421e-06 5.04e-05 -3.43401e-06 5.34187e-05 -4.61986e-06 5.64798e-05 -5.86911e-06 5.95719e-05 -7.14267e-06 6.26775e-05 -8.3926e-06 6.57712e-05 -9.56237e-06 6.8817e-05 -1.0588e-05 7.1767e-05 -1.13995e-05 7.45586e-05 -1.19229e-05 7.71139e-05 -1.20841e-05 7.93436e-05 -1.18202e-05 8.1157e-05 -1.1089e-05 8.2472e-05 -9.86922e-06 8.32041e-05 -8.13345e-06 8.32707e-05 -5.87054e-06 8.26145e-05 -3.11468e-06 8.11982e-05 9.46507e-08 7.89922e-05 3.72262e-06 7.59818e-05 7.71131e-06 7.21751e-05 1.19745e-05 6.76098e-05 1.64077e-05 6.23441e-05 2.09193e-05 5.64349e-05 2.5454e-05 4.99231e-05 2.99826e-05 4.28428e-05 3.4468e-05 3.5219e-05 3.88779e-05 2.70763e-05 4.31738e-05 1.84459e-05 4.73329e-05 9.3661e-06 5.14039e-05 5.50885e-05 2.14832e-05 -5.96353e-07 2.35801e-05 -5.74167e-07 2.57709e-05 -6.65161e-07 2.80507e-05 -8.79865e-07 3.04151e-05 -1.22741e-06 3.28603e-05 -1.71482e-06 3.53834e-05 -2.34651e-06 3.7983e-05 -3.12359e-06 4.06591e-05 -4.043e-06 4.34136e-05 -5.09655e-06 4.62492e-05 -6.26959e-06 4.91688e-05 -7.53949e-06 5.21738e-05 -8.87411e-06 5.52615e-05 -1.02303e-05 5.84218e-05 -1.1553e-05 6.16347e-05 -1.27752e-05 6.48665e-05 -1.38198e-05 6.80685e-05 -1.46015e-05 7.1172e-05 -1.50264e-05 7.40816e-05 -1.49938e-05 7.66831e-05 -1.44217e-05 7.8861e-05 -1.32669e-05 8.05309e-05 -1.15391e-05 8.15905e-05 -9.19311e-06 8.19298e-05 -6.2098e-06 8.14941e-05 -2.67904e-06 8.02574e-05 1.3314e-06 7.81873e-05 5.79272e-06 7.52692e-05 1.06294e-05 7.15235e-05 1.57203e-05 6.70071e-05 2.09241e-05 6.18009e-05 2.61255e-05 5.59715e-05 3.12834e-05 4.95478e-05 3.64063e-05 4.2568e-05 4.14479e-05 3.50368e-05 4.64091e-05 2.69661e-05 5.12445e-05 1.8384e-05 5.5915e-05 9.33461e-06 6.04533e-05 6.44231e-05 1.88905e-05 -2.39598e-06 2.07779e-05 -2.46159e-06 2.27489e-05 -2.63619e-06 2.47997e-05 -2.93063e-06 2.69271e-05 -3.35478e-06 2.91293e-05 -3.91706e-06 3.14066e-05 -4.62383e-06 3.37618e-05 -5.47875e-06 3.62006e-05 -6.4818e-06 3.8732e-05 -7.62793e-06 4.13677e-05 -8.90526e-06 4.41209e-05 -1.02928e-05 4.70045e-05 -1.17577e-05 5.00272e-05 -1.32529e-05 5.31889e-05 -1.47147e-05 5.6477e-05 -1.60633e-05 5.98627e-05 -1.72055e-05 6.33013e-05 -1.80401e-05 6.67246e-05 -1.84497e-05 7.00148e-05 -1.8284e-05 7.30215e-05 -1.74283e-05 7.55879e-05 -1.58333e-05 7.76416e-05 -1.35928e-05 7.90591e-05 -1.06105e-05 7.96782e-05 -6.82894e-06 7.94734e-05 -2.47422e-06 7.84605e-05 2.34426e-06 7.65354e-05 7.71782e-06 7.36813e-05 1.34835e-05 7.00361e-05 1.93655e-05 6.57047e-05 2.52555e-05 6.07112e-05 3.1119e-05 5.50432e-05 3.69514e-05 4.87816e-05 4.26679e-05 4.19955e-05 4.8234e-05 3.46427e-05 5.37619e-05 2.67178e-05 5.91694e-05 1.82441e-05 6.43886e-05 9.27135e-06 6.9426e-05 7.36944e-05 1.61452e-05 -3.96642e-06 1.77896e-05 -4.10598e-06 1.95036e-05 -4.35024e-06 2.12837e-05 -4.71071e-06 2.31275e-05 -5.19854e-06 2.50345e-05 -5.82415e-06 2.70075e-05 -6.59679e-06 2.90527e-05 -7.52391e-06 3.1181e-05 -8.61012e-06 3.34086e-05 -9.85552e-06 3.57567e-05 -1.12534e-05 3.82506e-05 -1.27867e-05 4.0917e-05 -1.44241e-05 4.37789e-05 -1.61148e-05 4.68499e-05 -1.77858e-05 5.0128e-05 -1.93414e-05 5.35912e-05 -2.06687e-05 5.72064e-05 -2.16552e-05 6.09128e-05 -2.21561e-05 6.45626e-05 -2.19339e-05 6.79901e-05 -2.08558e-05 7.09814e-05 -1.88247e-05 7.34315e-05 -1.6043e-05 7.51562e-05 -1.23351e-05 7.60156e-05 -7.68842e-06 7.59659e-05 -2.42455e-06 7.50436e-05 3.26661e-06 7.32339e-05 9.52751e-06 7.0545e-05 1.61724e-05 6.71434e-05 2.2767e-05 6.32554e-05 2.91435e-05 5.8752e-05 3.56224e-05 5.35136e-05 4.21899e-05 4.76029e-05 4.85786e-05 4.10696e-05 5.47673e-05 3.3992e-05 6.08395e-05 2.62972e-05 6.68641e-05 1.8006e-05 7.26798e-05 9.17023e-06 7.82618e-05 8.28646e-05 1.33205e-05 -5.28268e-06 1.4693e-05 -5.47854e-06 1.61169e-05 -5.77411e-06 1.75879e-05 -6.18168e-06 1.91033e-05 -6.71392e-06 2.06628e-05 -7.38366e-06 2.22697e-05 -8.20371e-06 2.39322e-05 -9.18637e-06 2.56645e-05 -1.03425e-05 2.74888e-05 -1.16798e-05 2.94352e-05 -1.31998e-05 3.15421e-05 -1.48936e-05 3.38526e-05 -1.67346e-05 3.64093e-05 -1.86716e-05 3.92462e-05 -2.06227e-05 4.23788e-05 -2.24739e-05 4.57767e-05 -2.40666e-05 4.94079e-05 -2.52865e-05 5.32439e-05 -2.59921e-05 5.71004e-05 -2.57905e-05 6.08648e-05 -2.46202e-05 6.43612e-05 -2.23211e-05 6.72087e-05 -1.88905e-05 6.91851e-05 -1.43115e-05 7.02316e-05 -8.73497e-06 7.02366e-05 -2.42953e-06 6.91976e-05 4.30557e-06 6.73739e-05 1.13512e-05 6.49293e-05 1.86169e-05 6.1912e-05 2.57843e-05 5.83405e-05 3.2715e-05 5.43251e-05 3.96378e-05 4.99686e-05 4.65464e-05 4.50257e-05 5.35215e-05 3.92664e-05 6.05266e-05 3.26972e-05 6.74087e-05 2.54315e-05 7.41298e-05 1.74986e-05 8.06127e-05 8.95091e-06 8.68094e-05 9.18155e-05 1.05031e-05 -6.32747e-06 1.15827e-05 -6.55817e-06 1.26906e-05 -6.88202e-06 1.38209e-05 -7.31193e-06 1.49688e-05 -7.86187e-06 1.61321e-05 -8.54697e-06 1.7312e-05 -9.38364e-06 1.85151e-05 -1.03895e-05 1.97553e-05 -1.15827e-05 2.10569e-05 -1.29814e-05 2.2457e-05 -1.45999e-05 2.40072e-05 -1.64437e-05 2.57717e-05 -1.84991e-05 2.78208e-05 -2.07207e-05 3.02071e-05 -2.3009e-05 3.29542e-05 -2.5221e-05 3.60319e-05 -2.71443e-05 3.93059e-05 -2.85606e-05 4.28173e-05 -2.95034e-05 4.66672e-05 -2.96404e-05 5.07392e-05 -2.86922e-05 5.47687e-05 -2.63506e-05 5.82762e-05 -2.23979e-05 6.083e-05 -1.68654e-05 6.21799e-05 -1.00848e-05 6.23268e-05 -2.57654e-06 6.13915e-05 5.24091e-06 5.96014e-05 1.31413e-05 5.72381e-05 2.09802e-05 5.44022e-05 2.86202e-05 5.09465e-05 3.61707e-05 4.71076e-05 4.34768e-05 4.33094e-05 5.03446e-05 3.94198e-05 5.7411e-05 3.51231e-05 6.48232e-05 2.98063e-05 7.27256e-05 2.34795e-05 8.04566e-05 1.63036e-05 8.77886e-05 8.3994e-06 9.47137e-05 0.000100215 7.79067e-06 -7.09421e-06 8.56751e-06 -7.33503e-06 9.34535e-06 -7.65988e-06 1.01151e-05 -8.08166e-06 1.0868e-05 -8.61483e-06 1.15968e-05 -9.2758e-06 1.22965e-05 -1.00834e-05 1.29665e-05 -1.10595e-05 1.36137e-05 -1.223e-05 1.42579e-05 -1.36255e-05 1.49387e-05 -1.52807e-05 1.57221e-05 -1.72272e-05 1.67007e-05 -1.94777e-05 1.79659e-05 -2.19859e-05 1.9585e-05 -2.46281e-05 2.15018e-05 -2.71379e-05 2.36019e-05 -2.92444e-05 2.60288e-05 -3.09875e-05 2.89296e-05 -3.24042e-05 3.25605e-05 -3.32714e-05 3.68931e-05 -3.30248e-05 4.14533e-05 -3.09108e-05 4.56482e-05 -2.65928e-05 4.88551e-05 -2.00723e-05 5.07082e-05 -1.1938e-05 5.12653e-05 -3.13365e-06 5.08006e-05 5.70559e-06 4.95108e-05 1.44312e-05 4.75374e-05 2.29536e-05 4.49478e-05 3.12097e-05 4.18891e-05 3.92295e-05 3.8533e-05 4.68328e-05 3.5069e-05 5.38086e-05 3.1873e-05 6.0607e-05 2.86147e-05 6.80815e-05 2.4825e-05 7.65153e-05 1.99408e-05 8.53408e-05 1.40342e-05 9.36952e-05 7.27339e-06 0.000101474 0.000107488 5.28703e-06 -7.58996e-06 5.76623e-06 -7.81425e-06 6.2163e-06 -8.10996e-06 6.62348e-06 -8.48886e-06 6.97287e-06 -8.96425e-06 7.24845e-06 -9.55137e-06 7.43342e-06 -1.02683e-05 7.5119e-06 -1.11379e-05 7.4734e-06 -1.21915e-05 7.32263e-06 -1.34747e-05 7.09489e-06 -1.50529e-05 6.87332e-06 -1.70057e-05 6.78101e-06 -1.93854e-05 6.91966e-06 -2.21246e-05 7.25485e-06 -2.49633e-05 7.70138e-06 -2.75844e-05 8.35348e-06 -2.98964e-05 9.55874e-06 -3.21927e-05 1.15861e-05 -3.44316e-05 1.47498e-05 -3.64351e-05 1.89056e-05 -3.71806e-05 2.33258e-05 -3.5331e-05 2.75056e-05 -3.07726e-05 3.12709e-05 -2.38377e-05 3.40834e-05 -1.47504e-05 3.55807e-05 -4.63093e-06 3.60668e-05 5.21951e-06 3.57168e-05 1.47811e-05 3.46494e-05 2.4021e-05 3.2967e-05 3.28921e-05 3.08315e-05 4.13651e-05 2.83544e-05 4.93099e-05 2.55813e-05 5.65817e-05 2.29459e-05 6.32424e-05 2.04951e-05 7.05324e-05 1.80708e-05 7.89395e-05 1.48592e-05 8.85525e-05 1.05756e-05 9.79788e-05 5.41352e-06 0.000106637 0.000112902 3.09485e-06 -7.83767e-06 3.29976e-06 -8.01916e-06 3.44521e-06 -8.25541e-06 3.51176e-06 -8.55543e-06 3.4763e-06 -8.92879e-06 3.31053e-06 -9.38561e-06 2.9796e-06 -9.93741e-06 2.44209e-06 -1.06004e-05 1.65581e-06 -1.14052e-05 5.94184e-07 -1.24131e-05 -7.24575e-07 -1.37342e-05 -2.20271e-06 -1.55275e-05 -3.68692e-06 -1.79012e-05 -5.08318e-06 -2.07283e-05 -6.53512e-06 -2.35113e-05 -7.94009e-06 -2.61794e-05 -8.83578e-06 -2.90008e-05 -8.8622e-06 -3.21663e-05 -7.73609e-06 -3.55577e-05 -5.27204e-06 -3.88991e-05 -1.84272e-06 -4.061e-05 1.82334e-06 -3.89971e-05 5.65754e-06 -3.46068e-05 9.49548e-06 -2.76756e-05 1.3122e-05 -1.83769e-05 1.58476e-05 -7.35654e-06 1.76306e-05 3.43659e-06 1.85312e-05 1.38805e-05 1.86888e-05 2.38635e-05 1.82466e-05 3.33343e-05 1.73525e-05 4.22592e-05 1.60945e-05 5.05678e-05 1.45159e-05 5.81603e-05 1.26796e-05 6.50787e-05 1.11277e-05 7.20843e-05 9.75087e-06 8.03164e-05 8.06351e-06 9.02399e-05 5.62243e-06 0.00010042 2.30624e-06 0.000109953 0.000115208 1.30575e-06 -7.87706e-06 1.27964e-06 -7.99305e-06 1.16737e-06 -8.14315e-06 9.43703e-07 -8.33176e-06 5.76594e-07 -8.56167e-06 2.35159e-08 -8.83254e-06 -7.73504e-07 -9.14039e-06 -1.89126e-06 -9.48269e-06 -3.4203e-06 -9.87617e-06 -5.44041e-06 -1.0393e-05 -7.97398e-06 -1.12006e-05 -1.09154e-05 -1.25861e-05 -1.40373e-05 -1.47793e-05 -1.74101e-05 -1.73555e-05 -2.09464e-05 -1.99751e-05 -2.41582e-05 -2.29676e-05 -2.62983e-05 -2.68607e-05 -2.71289e-05 -3.13358e-05 -2.66798e-05 -3.60068e-05 -2.51997e-05 -4.03793e-05 -2.29427e-05 -4.28669e-05 -1.99794e-05 -4.19604e-05 -1.65774e-05 -3.80089e-05 -1.30141e-05 -3.12389e-05 -9.28104e-06 -2.211e-05 -5.69647e-06 -1.09411e-05 -2.88722e-06 6.27353e-07 -8.76975e-07 1.18702e-05 4.5665e-07 2.25298e-05 1.25978e-06 3.25312e-05 1.64692e-06 4.18721e-05 1.68799e-06 5.05267e-05 1.41097e-06 5.84373e-05 8.16989e-07 6.56727e-05 3.12746e-07 7.25885e-05 -1.9862e-07 8.08278e-05 -6.73813e-07 9.07151e-05 -1.47094e-06 0.000101217 -3.07081e-06 0.000111553 0.000112137 -1.16003e-08 -7.76324e-06 -2.06368e-07 -7.7983e-06 -5.0568e-07 -7.84384e-06 -9.39258e-07 -7.89817e-06 -1.54643e-06 -7.9545e-06 -2.3823e-06 -7.99668e-06 -3.52752e-06 -7.99517e-06 -5.09891e-06 -7.9113e-06 -7.249e-06 -7.72608e-06 -1.01353e-05 -7.50675e-06 -1.38482e-05 -7.48766e-06 -1.83048e-05 -8.12959e-06 -2.32795e-05 -9.80454e-06 -2.87901e-05 -1.18449e-05 -3.43284e-05 -1.44369e-05 -3.88808e-05 -1.84151e-05 -4.1925e-05 -2.38166e-05 -4.33851e-05 -2.98757e-05 -4.35299e-05 -3.58619e-05 -4.29416e-05 -4.09677e-05 -4.18687e-05 -4.39398e-05 -3.9985e-05 -4.38441e-05 -3.73816e-05 -4.06122e-05 -3.43783e-05 -3.42422e-05 -3.1061e-05 -2.54273e-05 -2.73058e-05 -1.46964e-05 -2.40116e-05 -2.66687e-06 -2.12988e-05 9.15748e-06 -1.91188e-05 2.03498e-05 -1.73106e-05 3.0723e-05 -1.57936e-05 4.0355e-05 -1.45572e-05 4.92903e-05 -1.3598e-05 5.74782e-05 -1.28166e-05 6.48913e-05 -1.24764e-05 7.22483e-05 -1.22472e-05 8.05985e-05 -1.18924e-05 9.03603e-05 -1.13585e-05 0.000100683 -1.04893e-05 0.000110683 0.000101648 -8.24378e-07 -7.56244e-06 -1.11061e-06 -7.51207e-06 -1.5066e-06 -7.44785e-06 -2.04345e-06 -7.36131e-06 -2.76295e-06 -7.23501e-06 -3.72534e-06 -7.03428e-06 -5.02403e-06 -6.69649e-06 -6.8069e-06 -6.12844e-06 -9.28977e-06 -5.24321e-06 -1.27286e-05 -4.06795e-06 -1.73349e-05 -2.8813e-06 -2.31717e-05 -2.29286e-06 -3.00008e-05 -2.97542e-06 -3.74071e-05 -4.43858e-06 -4.4479e-05 -7.36494e-06 -4.9885e-05 -1.30092e-05 -5.33808e-05 -2.03208e-05 -5.51817e-05 -2.80748e-05 -5.58476e-05 -3.51961e-05 -5.60191e-05 -4.07961e-05 -5.59897e-05 -4.39692e-05 -5.55582e-05 -4.42757e-05 -5.44861e-05 -4.16842e-05 -5.2576e-05 -3.61524e-05 -5.01109e-05 -2.78924e-05 -4.72277e-05 -1.75795e-05 -4.41122e-05 -5.78232e-06 -4.13831e-05 6.42837e-06 -3.89747e-05 1.79414e-05 -3.66311e-05 2.83794e-05 -3.43444e-05 3.80683e-05 -3.21883e-05 4.71342e-05 -3.0273e-05 5.55628e-05 -2.88224e-05 6.34407e-05 -2.79561e-05 7.1382e-05 -2.7249e-05 7.98915e-05 -2.6341e-05 8.94522e-05 -2.43481e-05 9.86903e-05 -1.85706e-05 0.000104906 8.30774e-05 -1.14824e-06 -7.34423e-06 -1.44266e-06 -7.21767e-06 -1.83491e-06 -7.0556e-06 -2.35274e-06 -6.84348e-06 -3.03293e-06 -6.55482e-06 -3.92767e-06 -6.13956e-06 -5.11982e-06 -5.50436e-06 -6.75554e-06 -4.49273e-06 -9.0879e-06 -2.91085e-06 -1.24755e-05 -6.80318e-07 -1.73179e-05 1.96102e-06 -2.3975e-05 4.36424e-06 -3.22783e-05 5.3279e-06 -4.13574e-05 4.64053e-06 -4.93221e-05 5.99768e-07 -5.47125e-05 -7.6188e-06 -5.75029e-05 -1.75303e-05 -5.86302e-05 -2.69475e-05 -5.92475e-05 -3.45788e-05 -6.02365e-05 -3.98071e-05 -6.17963e-05 -4.24095e-05 -6.36036e-05 -4.24683e-05 -6.51112e-05 -4.01766e-05 -6.54525e-05 -3.58112e-05 -6.46858e-05 -2.86591e-05 -6.32896e-05 -1.89757e-05 -6.16559e-05 -7.41597e-06 -5.99116e-05 4.68409e-06 -5.79914e-05 1.60212e-05 -5.59638e-05 2.63519e-05 -5.38028e-05 3.59072e-05 -5.15436e-05 4.4875e-05 -4.94071e-05 5.34263e-05 -4.77563e-05 6.17899e-05 -4.66333e-05 7.02589e-05 -4.57327e-05 7.89909e-05 -4.37956e-05 8.7515e-05 -3.87358e-05 9.36306e-05 -2.51029e-05 9.12729e-05 5.79745e-05 -1.05767e-06 -7.16935e-06 -1.28561e-06 -6.98973e-06 -1.58122e-06 -6.76001e-06 -1.96302e-06 -6.46169e-06 -2.45458e-06 -6.06327e-06 -3.08617e-06 -5.50798e-06 -3.90088e-06 -4.68966e-06 -4.98252e-06 -3.4111e-06 -6.54502e-06 -1.34837e-06 -9.00637e-06 1.78102e-06 -1.29644e-05 5.91906e-06 -1.93318e-05 1.07317e-05 -2.86866e-05 1.46827e-05 -3.96786e-05 1.56325e-05 -4.81827e-05 9.10387e-06 -5.18915e-05 -3.90996e-06 -5.17485e-05 -1.76733e-05 -5.03752e-05 -2.83207e-05 -4.97291e-05 -3.52249e-05 -5.09181e-05 -3.86181e-05 -5.42937e-05 -3.90338e-05 -5.95399e-05 -3.72221e-05 -6.54479e-05 -3.42686e-05 -7.02969e-05 -3.09621e-05 -7.27795e-05 -2.61765e-05 -7.37922e-05 -1.79631e-05 -7.49905e-05 -6.21763e-06 -7.59183e-05 5.61191e-06 -7.60102e-05 1.61132e-05 -7.50655e-05 2.54072e-05 -7.35636e-05 3.44052e-05 -7.16116e-05 4.2923e-05 -6.96712e-05 5.14858e-05 -6.80076e-05 6.01264e-05 -6.64953e-05 6.87466e-05 -6.44378e-05 7.69334e-05 -5.9678e-05 8.27553e-05 -4.88908e-05 8.28433e-05 -2.73536e-05 6.97357e-05 3.06209e-05 -6.88217e-07 -7.07371e-06 -8.05695e-07 -6.87225e-06 -9.48577e-07 -6.61714e-06 -1.12026e-06 -6.29002e-06 -1.32301e-06 -5.86054e-06 -1.55566e-06 -5.27533e-06 -1.81027e-06 -4.43507e-06 -2.07155e-06 -3.14983e-06 -2.35922e-06 -1.06071e-06 -3.01978e-06 2.44158e-06 -4.62718e-06 7.52645e-06 -8.7744e-06 1.48789e-05 -1.86351e-05 2.45434e-05 -3.29636e-05 2.99609e-05 -4.2022e-05 1.81623e-05 -4.10301e-05 -4.90179e-06 -3.58646e-05 -2.28389e-05 -3.10643e-05 -3.3121e-05 -2.83817e-05 -3.79075e-05 -2.8441e-05 -3.85588e-05 -3.17851e-05 -3.56897e-05 -3.9045e-05 -2.99622e-05 -5.00569e-05 -2.32567e-05 -6.17908e-05 -1.92282e-05 -6.94398e-05 -1.85274e-05 -7.36207e-05 -1.37822e-05 -8.06676e-05 8.29262e-07 -8.72724e-05 1.22168e-05 -9.1555e-05 2.03957e-05 -9.27141e-05 2.65662e-05 -9.20499e-05 3.3741e-05 -9.03142e-05 4.11873e-05 -8.79138e-05 4.90854e-05 -8.51165e-05 5.7329e-05 -8.16234e-05 6.52535e-05 -7.60963e-05 7.14063e-05 -6.66418e-05 7.33008e-05 -5.03689e-05 6.65704e-05 -2.59927e-05 4.53596e-05 4.62823e-06 -2.16855e-07 -2.36134e-07 -2.49744e-07 -2.49466e-07 -2.1987e-07 -1.31224e-07 7.29891e-08 4.80503e-07 1.12353e-06 2.26554e-06 3.6358e-06 4.43993e-06 -2.28086e-06 -2.82592e-05 -2.85787e-05 -2.11768e-05 -1.3356e-05 -8.5531e-06 -5.8766e-06 -4.36677e-06 -3.93304e-06 -5.96608e-06 -1.30988e-05 -2.60188e-05 -4.24434e-05 -5.70729e-05 -7.04489e-05 -8.74356e-05 -0.000101069 -0.0001044 -0.000103837 -0.000101563 -9.65921e-05 -8.98222e-05 -8.20061e-05 -7.20992e-05 -5.92325e-05 -4.2486e-05 -2.019e-05 ) ; boundaryField { leftWall { type calculated; value nonuniform 0(); } rightWall { type calculated; value uniform 0; } lowerWall { type calculated; value nonuniform 0(); } atmosphere { type calculated; value nonuniform List<scalar> 45 ( -7.16997e-06 -6.71673e-06 -6.64538e-06 -6.55835e-06 -6.45239e-06 -7.05313e-06 -6.85297e-06 -6.60353e-06 -6.29031e-06 -5.89014e-06 -5.36398e-06 -4.63929e-06 -3.55735e-06 -1.70374e-06 1.29956e-06 6.15619e-06 1.40748e-05 3.12642e-05 5.59393e-05 1.84817e-05 -1.23038e-05 -3.06596e-05 -3.79239e-05 -4.0584e-05 -4.00686e-05 -3.61234e-05 -2.79292e-05 -1.6124e-05 -6.30826e-06 -2.10281e-06 8.47306e-07 1.42053e-05 2.92035e-05 3.4029e-05 2.98973e-05 3.31783e-05 3.89132e-05 4.41143e-05 5.05592e-05 5.74374e-05 6.14994e-05 6.04342e-05 4.98239e-05 2.30636e-05 -1.55617e-05 ) ; } defaultFaces { type empty; value nonuniform 0(); } procBoundary3to1 { type processor; value nonuniform List<scalar> 45 ( -2.5399e-05 -2.2602e-05 -2.08585e-05 -1.87832e-05 -1.64217e-05 -1.51992e-05 -1.16113e-05 -8.28719e-06 -5.43845e-06 -2.63532e-06 -8.8495e-07 -1.37814e-06 -1.33801e-06 -9.78899e-07 -1.50259e-07 1.00788e-06 1.51466e-06 6.1652e-07 -1.0805e-06 -3.14624e-06 -4.71163e-06 -6.51504e-06 -7.48625e-06 -7.98277e-06 -8.66946e-06 -9.51194e-06 -9.98339e-06 -1.03066e-05 -1.05292e-05 -1.0297e-05 -9.20705e-06 -6.95654e-06 -3.88827e-06 -2.32923e-07 4.07987e-06 9.49392e-06 1.64683e-05 2.56023e-05 3.76312e-05 5.29778e-05 7.13393e-05 9.12022e-05 0.000110589 0.000129012 0.000145827 ) ; } procBoundary3to2 { type processor; value nonuniform List<scalar> 43 ( -3.51614e-05 -3.53646e-05 -3.49652e-05 -3.41363e-05 -3.30255e-05 -3.17563e-05 -3.04293e-05 -2.91236e-05 -2.78976e-05 -2.67908e-05 -2.58246e-05 -2.50054e-05 -2.43262e-05 -2.37697e-05 -2.3311e-05 -2.292e-05 -2.25637e-05 -2.22083e-05 -2.18208e-05 -2.13706e-05 -2.08306e-05 -2.01779e-05 -1.9395e-05 -1.84701e-05 -1.7398e-05 -1.61806e-05 -1.48275e-05 -1.33562e-05 -1.17921e-05 -1.01678e-05 -8.52192e-06 -6.89832e-06 -5.34359e-06 -3.90436e-06 -2.62414e-06 -1.54002e-06 -6.79153e-07 -5.54789e-08 3.32835e-07 5.04505e-07 4.94404e-07 3.50166e-07 1.25566e-07 ) ; } } // ************************************************************************* //
961a75df84c0140204b9668afbec5d88630a3d46
89de5c4c0163578ae4bbae98c58c53665e8a5c20
/Cross-Compiled Approach/Camera/SettingsScreen.h
3de70bf9378231e97579776441423ecc7fb16116
[]
no_license
wizard88mc/EnergyConsumptionCrossPlatformFrameworks
665789b7a2ea5427bdc2756f4729be2a5b37ddf5
3a1879d750c54f2b34714047bcd2510c4abfdea4
refs/heads/master
2021-01-12T17:07:36.050555
2016-10-04T15:56:42
2016-10-04T15:56:42
69,974,567
0
0
null
null
null
null
UTF-8
C++
false
false
1,791
h
/* Copyright (C) 2011 MoSync AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file SettingsScreen.h * @author Ali Sarrafi * * This application provides a very basic example of how to work * with Native UI and the Camera API */ // Include MoSync syscalls. #include <maapi.h> // Include NativeUI class interface #include <NativeUI/Widgets.h> #ifndef SETTINGSSCREEN_H_ #define SETTINGSSCREEN_H_ using namespace NativeUI; /** * A class that encapsulates the behavior of Settings Screen */ class SettingsScreen : public ButtonListener { public: SettingsScreen(); virtual ~SettingsScreen(); virtual void buttonClicked(Widget* button); void initializeUI(StackScreen* stackScreen); void createUI(); void setFlashSupported(bool flashSupported); void pushSettingsScreen(); int getCurrentCamera(); void setCurrentCamera(int cameraIndex); const char* getFlashMode(); const char* getModeForIndex(int index); private: bool mFlashSupported; int mFlashModeIndex; int mNumCameras; int mCurrentCamera; Screen* mScreen; Button* mSwapCameraButton; Button* mOKButton; Button* mFlashModeButton; VerticalLayout *mMainLayoutWidget; StackScreen* mStackScreen; }; #endif /* SETTINGSSCREEN_H_ */
a74aeaf9c5d4513a213d0749f14da99601930bc8
d59527d12c7d36dcdc22bfa659c8b47db44fb308
/src/renderer/shader_program.cpp
bcf445f012fcdecc97ef7847ad58f2aa440f01f9
[]
no_license
sillypog/spinning-cubes
f94821cc09da890e3b020c025ea587ace3c066bc
ac6354b5b92808763c81e2752f9e97181c7f6fdb
refs/heads/master
2021-01-10T03:20:44.062154
2018-05-14T03:12:55
2018-05-14T03:12:55
43,730,046
0
0
null
2018-05-14T03:12:56
2015-10-06T04:36:24
C++
UTF-8
C++
false
false
2,165
cpp
#include <iostream> #include <numeric> #include "./shader_program.h" #include "../util/deleter.cpp" using namespace std; ShaderProgram::ShaderProgram(){} void ShaderProgram::addFragmentShader(string filename){ unique_ptr<Shader> s(new Shader(filename, GL_FRAGMENT_SHADER)); shaders.push_back(move(s)); } void ShaderProgram::addVertexShader(string filename){ unique_ptr<Shader> s(new Shader(filename, GL_VERTEX_SHADER)); shaders.push_back(move(s)); } void ShaderProgram::link(){ shaderProgram = glCreateProgram(); for (auto const &s:shaders){ // Have to use references here or unique_ptr copy constructor will be illegally invoked glAttachShader(shaderProgram, s->getShader()); } glLinkProgram(shaderProgram); // Saves changes glUseProgram(shaderProgram); // Only one can be used at a time } // If this took all of the attributes at once, I wouldn't need to pass in total size and could have my running total as a local variable // Can I pass in an array of tuples for this? void ShaderProgram::defineAttributes(vector<pair<string, int>> attributes){ // Can I use a std::algorithm to sum the total length of the attribute sizes? Need it for the 5th param // Would I need a std::vector (or std::array) for this? int totalAttributeLength = accumulate(attributes.begin(), attributes.end(), 0, [](int lhs, const pair<string, int> & rhs){ return lhs += rhs.second; }); cout << "totalAttributeLength: " << totalAttributeLength << endl; int currentLength = 0; for(auto attributePair : attributes){ cout << "currentLength: " << currentLength << endl; GLint attributeAddress = glGetAttribLocation(shaderProgram, attributePair.first.c_str()); glVertexAttribPointer(attributeAddress, attributePair.second, GL_FLOAT, GL_FALSE, totalAttributeLength * sizeof(float), (void*)(currentLength * sizeof(float))); // Better way to cast to void pointer? glEnableVertexAttribArray(attributeAddress); currentLength += attributePair.second; } } GLint ShaderProgram::uniform(const char* uniform) { return glGetUniformLocation(shaderProgram, uniform); } ShaderProgram::~ShaderProgram(){ glDeleteProgram(shaderProgram); }
f80eb7ee02232b2ea33bc3a63ff4e7e6cec33644
24bac176ec2543a1c2f77ebb11af446d561437e4
/Exercicio41.cpp
14eb3bb502ddcd2bdb5c803a32f6dd72f762c4a5
[]
no_license
CarlosAbolis/TPA
11b1eda0f2072ae5195715b54566d8934cd1ef77
487c87012edac3b8cd9a950decfb76d7e90d8224
refs/heads/master
2020-08-02T23:19:28.951218
2019-12-05T23:27:07
2019-12-05T23:27:07
211,542,050
0
0
null
null
null
null
ISO-8859-1
C++
false
false
982
cpp
/* Função: Ler 5 valores e colocá-los em ordem crescente e decrescente. Autor: Carlos Alberto Gonçalves da Silva Neto Data de criação: 2019/12/01 Data de finalização: 2019/12/02 */ #include <stdio.h> #include <windows.h> #include <locale.h> #include <stdlib.h> int main(){ setlocale(LC_ALL, ""); int numero[5], i, dc = 4, alternar, ordem1 = 1, ordem2 = 1; printf("O programa vai ler 5 valores e exibir a ordem crescente e decrescente deles.\n"); for(i = 0; i < 5; i ++){ printf("\nInsira um número: \n"); scanf("%i", &numero[i]); } while(dc >= 0){ for(i = 0; i < 4; i ++){ if(numero[i] > numero[i + 1]){ numero[i + 1] = alternar; numero[i] = numero[i + 1]; alternar = numero[i]; } } dc --; } printf("\nOrdem crescente: \n"); for(i = 0; i < 5; i ++){ printf("%iº %i \n", ordem1 ++, numero[i]); } printf("\nOrdem decrescente: \n"); for(i = 4; i > -1; i --){ printf("%iº %i \n", ordem2 ++, numero[i]); } system("pause"); }
88e78e1f98b786d16af8a3d5b2c66362de772c88
2464d2667453811a4e48edb8590c34a1e47542f1
/Arduino_OLED128x64_I2C_1.3.ino
19faad4637c2829aa4b835beec6f923a974b209a
[]
no_license
myarduinosale/sensor1
149b0426a8c6b97df7e7223498bb39289aa48e1f
12508230e74bb427d0f58810ad21a80f68be8755
refs/heads/master
2022-12-23T21:33:30.916404
2022-12-19T10:31:34
2022-12-19T10:31:34
126,945,591
0
2
null
null
null
null
UTF-8
C++
false
false
541
ino
#include "SPI.h" #include "Wire.h" #include "Adafruit_GFX.h" #include "Adafruit_SH1106.h" #define OLED_RESET 4 Adafruit_SH1106 display(OLED_RESET); void setup() { display.begin(SH1106_SWITCHCAPVCC, 0x3C); display.clearDisplay(); display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0, 5); display.println("WELCOME to Myarduino"); display.println(); display.setTextSize(2); display.println("Myarduino"); display.setTextSize(1); display.println("...OLED 1.3 TESTER..."); display.display(); delay(5000); } void loop() { }
cc41a3339dded5eb7313f4d299f57a36c5459b06
087dea2f7147663ba90a213f59b70ddd59f6aec4
/main/stltest/copy3.cpp
609d8a7832085b600a3ee33de739fd5f6256b006
[ "MIT" ]
permissive
stormbrew/stir
b5c3bcaf7c7e8c3a95dd45bf1642c83b6291a408
2d39364bfceb87106daa2338f9dfe6362a811347
refs/heads/master
2022-05-24T17:52:26.908960
2022-04-28T03:39:42
2022-04-28T03:39:42
1,130,258
0
0
null
null
null
null
UTF-8
C++
false
false
550
cpp
#ifndef SINGLE // An adapted ObjectSpace example for use with SGI STL #include <vector> #include <algorithm> #include <iostream> #ifdef MAIN #define copy3_test main #endif #endif int copy3_test(int, char**) { std::cout<<"Results of copy3_test:"<<std::endl; std::vector <int> v1(10); for(int i = 0; i < v1.size(); i++) v1[i] = i; std::vector <int> v2(10); std::copy(v1.begin(), v1.end(), v2.begin()); std::ostream_iterator<int> iter(std::cout, " "); std::copy(v2.begin(), v2.end(), iter); std::cout << std::endl; return 0; }
153d05db55b6b7dc78a347d80dc229b5672c6291
04b1803adb6653ecb7cb827c4f4aa616afacf629
/third_party/blink/renderer/core/testing/callback_function_test.h
37cf10e131664ff82f7e5435bf5d7140ee148c55
[ "BSD-3-Clause", "LGPL-2.0-only", "BSD-2-Clause", "LGPL-2.1-only", "LGPL-2.0-or-later", "GPL-1.0-or-later", "MIT", "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer", "GPL-2.0-only", "LicenseRef-scancode-other-copyleft" ]
permissive
Samsung/Castanets
240d9338e097b75b3f669604315b06f7cf129d64
4896f732fc747dfdcfcbac3d442f2d2d42df264a
refs/heads/castanets_76_dev
2023-08-31T09:01:04.744346
2021-07-30T04:56:25
2021-08-11T05:45:21
125,484,161
58
49
BSD-3-Clause
2022-10-16T19:31:26
2018-03-16T08:07:37
null
UTF-8
C++
false
false
1,917
h
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_CALLBACK_FUNCTION_TEST_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_CALLBACK_FUNCTION_TEST_H_ #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/vector.h" namespace blink { class ExceptionState; class HTMLDivElement; class V8TestCallback; class V8TestEnumCallback; class V8TestInterfaceCallback; class V8TestReceiverObjectCallback; class V8TestSequenceCallback; class CallbackFunctionTest final : public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); public: String testCallback(V8TestCallback*, const String&, const String&, ExceptionState&); String testNullableCallback(V8TestCallback*, const String&, const String&, ExceptionState&); void testInterfaceCallback(V8TestInterfaceCallback*, HTMLDivElement*, ExceptionState&); void testReceiverObjectCallback(V8TestReceiverObjectCallback*, ExceptionState&); Vector<String> testSequenceCallback(V8TestSequenceCallback*, const Vector<int>& numbers, ExceptionState&); void testEnumCallback(V8TestEnumCallback*, const String& enum_value, ExceptionState&); }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_CALLBACK_FUNCTION_TEST_H_
96ceaa0938f6c8482a9b2063bbb13a24234e6bf2
1b5c69d3d3c8c5dc4de9735b93a4d91ca7642a42
/abc121-140/abc124c.cpp
4927fa3d6e4d34ed1e666bbc328a528e6f84c2c7
[]
no_license
ritsuxis/kyoupro
19059ce166d2c35f643ce52aeb13663c1acece06
ce0a4aa0c18e19e038f29d1db586258970b35b2b
refs/heads/master
2022-12-23T08:25:51.282513
2020-10-02T12:43:16
2020-10-02T12:43:16
232,855,372
0
0
null
null
null
null
UTF-8
C++
false
false
547
cpp
#include<bits/stdc++.h> using namespace std; int gcd(int a, int b) { int c; if (a < b) { a+=b; b=a-b; a-=b; } while (b != 0) { c = a % b; a = b; b = c; } return a; } int main(void){ string str; cin >> str; int stringSize = str.size(), ans = 0; for(int i = 0; i < stringSize; i++){ if(i % 2 == 0 && str[i] == '0') ans++; else if(i % 2 != 0 && str[i] == '1') ans++; } if(ans > stringSize - ans) ans = stringSize - ans; cout << ans << endl; }
8dd86b3f8386fdd98e1fc5a0b5bfe5a8d112e009
9ba9480fa379a4a0485f10e631a56934f1a20e80
/File.hpp
ec638609c0281148daac2d40b0c23462768a11d2
[]
no_license
3dik/bkoder
e80b283765d471291ea3513b0fbe0c8e389c9811
50e5ce88d8e2ab2a1817438356b01b05b50eebe3
refs/heads/master
2016-09-06T14:53:17.265644
2013-06-14T00:49:07
2013-06-14T00:49:07
9,902,001
2
1
null
null
null
null
UTF-8
C++
false
false
219
hpp
#pragma once #include <fstream> #include "Err.hpp" //Opens a file for reading. Creates if it does not exist template <class T> void OpenCreateRO (std::string Path, std::basic_ifstream<T> *File); #include "File.inl"
b8b707b4ebebeccf92f8bcf2d31ed1a265ab9ee7
d472e41335d0e579eacc120ec4c66e76167b305e
/bit7/bitmap-font.h
2223a352edd28f04820245aa999009136288b066
[]
no_license
jrr/tom7misc
034a12cab2051fd7d7b963114117f208a55b108b
1087b9d81f4f33e663036baa758ef92524ceb988
refs/heads/master
2023-04-23T20:00:58.103760
2021-05-03T03:22:05
2021-05-03T03:22:05
363,817,809
1
0
null
2021-05-08T05:48:39
2021-05-03T04:40:53
C++
UTF-8
C++
false
false
1,406
h
// Self-contained bitmap font. // Only use C++ builtins/std. // XXX export to cc-lib? // XXX Still need to figure out the right interface for loading these guys, // and probably a version where W/H are not fixed (... rename this to FixedBitmapFont?) #include <vector> template<int W, int H> struct BitmapFont { static constexpr int CHAR_WIDTH = W; static constexpr int CHAR_HEIGHT = H; bool GetBit(int c, int x, int y) const { return bits[c * (CHAR_WIDTH * CHAR_HEIGHT) + y * CHAR_WIDTH + x]; } // Draw the bits using custom pixel-drawing functions. SetBit and // ClearBit are called (if non-null) for each pixel. They should be // callable like SetPixel(int x, int y). template<class FS, class FC> void Blit(int c, int x, int y, FS SetPixel, // TODO: Looks like supplying a default lambda here does not // actually work (can't infer type parameter?) FC ClearPixel = [](int, int){}) const { for (int sy = 0; sy < CHAR_HEIGHT; sy++) { for (int sx = 0; sx < CHAR_WIDTH; sx++) { if (GetBit(c, sx, sy)) { SetPixel(x + sx, y + sy); } else { ClearPixel(x + sx, y + sy); } } } } explicit BitmapFont(std::vector<bool> bits) : bits(std::move(bits)) {} private: // Bits are arranged as if all the characters are in one tall column // with width W. // This improves cache locality somewhat. const std::vector<bool> bits; };
[ "tom7@be8137f2-001b-0410-b4be-9de0ac3fc846" ]
tom7@be8137f2-001b-0410-b4be-9de0ac3fc846
580264910568677005ae8e423b9ef1dae871ee7a
214355db2ebb44a0c63a993d96cd759e0061a33b
/EmptyProject/Explosion3D.h
0b590e8cf348a2d921b88cdf559ead1a0edde11b
[]
no_license
JeongTaeLee/Gleise-518D
b59e24a2f5722155c732adc346ace087cd66c691
b9f69cb33b63f4a4e25e6399d8915e35daf95df9
refs/heads/master
2020-05-02T21:31:55.350658
2019-04-02T05:47:45
2019-04-02T05:47:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
283
h
#pragma once #include "GameObject.h" class Explosion3D : public GameObject { public: float fDelay = 0.f; float fElapsed = 0.f; public: Explosion3D(); virtual ~Explosion3D(); virtual void Set3DExplosion(RefV3 vPos, RefV3 vScale, RefStr keys, int min, int max, float fS); };
ea80ce2bcbd0c04d34b8aab2682e5d750c517501
210bd6c47465ba1e73c432909df37a9791133c5e
/UVA/12187.cpp
d045fac39984db61d33b633bbfc430f8f0d78ee0
[]
no_license
engyebrahim/CompetitiveProgramming
a5458502da53f3b5d5f9fc0b057c36045c3b8e0d
38379283f84007413a2a2b84dc9de2285e0e6e1e
refs/heads/master
2021-01-11T15:12:17.245288
2018-10-10T06:49:50
2018-10-10T06:49:50
80,691,258
3
0
null
null
null
null
UTF-8
C++
false
false
838
cpp
#include <iostream> using namespace std; int main () { int n,r,c,k; int arr[101][101]; int ar[101][101]; while(cin>>n>>r>>c>>k&&n+c+r+k!=0) { for(int i=0;i<r;i++) for(int j=0;j<c;j++) cin>>arr[i][j]; for(int t=0;t<k;t++) { for(int i=0;i<r;i++) for(int j=0;j<c;j++) if(j+1!=c&&arr[i][j]==arr[i][j+1]+1||j!=0&&arr[i][j]==arr[i][j-1]+1||i!=0&&arr[i][j]==arr[i-1][j]+1||i+1!=r&&arr[i][j]==arr[i+1][j]+1) ar[i][j]=arr[i][j]-1; else if(arr[i][j]==0&&(j+1!=c&&arr[i][j+1]==n-1||j!=0&&arr[i][j-1]==n-1||i+1!=r&&arr[i+1][j]==n-1||i!=0&&arr[i-1][j]==n-1)) ar[i][j]=n-1; else ar[i][j]=arr[i][j]; for(int i=0;i<r;i++) for(int j=0;j<c;j++) arr[i][j]=ar[i][j]; } for(int i=0;i<r;i++) { for(int j=0;j<c;j++) {cout<<arr[i][j]; if(j+1!=c) cout<<" ";} cout<<endl; } } }
3bd5cbc1e68ed3372034cfddf8f691ced5766a82
6f918f1b26d113acd4d1d63a8066e607c62a45db
/Tanker.h
74a56b804451a0ec52fbe6af9b09deb189eaeeb3
[]
no_license
allenxyz/lapras
e9d2e23b6d0f4b216773823039b8a23e48660f22
7c18edb6d9eaee1c4dfac47c664312105fc5cac9
refs/heads/master
2016-09-05T16:27:46.455907
2015-04-06T04:37:34
2015-04-06T04:37:34
33,463,910
0
0
null
null
null
null
UTF-8
C++
false
false
2,600
h
#ifndef TANKER_H #define TANKER_H /* A Tanker is a ship with a large corgo capacity for fuel. It can be told an Island to load fuel at, and an Island to unload at. Once it is sent to the loading destination, it will start shuttling between the loading and unloading destination. At the loading destination, it will first refuel then wait until its cargo hold is full, then it will go to the unloading destination. Initial values: fuel capacity and initial amount 100 tons, maximum speed 10., fuel consumption 2.tons/nm, resistance 0, cargo capacity 1000 tons, initial cargo is 0 tons. */ /* This skeleton file shows the required public and protected interface for the class, which you may not modify. If no protected members are shown, there must be none in your version. If any protected or private members are shown here, then your class must also have them and use them as intended. You should delete this comment. */ #include "Ship.h" #include <string> #include <memory> class Island; class Point; class Tanker : public Ship { public: // initialize, the output constructor message Tanker(const std::string& name_, Point position_); // output destructor message // ~Tanker(); // This class overrides these Ship functions so that it can check if this Tanker has assigned cargo destinations. // if so, throw an Error("Tanker has cargo destinations!"); otherwise, simply call the Ship functions. void set_destination_position_and_speed(Point destination, double speed) override; void set_course_and_speed(double course, double speed) override; // Set the loading and unloading Island destinations // if both cargo destination are already set, throw Error("Tanker has cargo destinations!"). // if they are the same, leave at the set values, and throw Error("Load and unload cargo destinations are the same!") // if both destinations are now set, start the cargo cycle void set_load_destination(std::shared_ptr<Island>) override; void set_unload_destination(std::shared_ptr<Island>) override; // when told to stop, clear the cargo destinations and stop void stop() override; void update() override; void describe() const override; private: enum class Tanker_state {NO_CARGO_DESTINATION, MOVING_TO_LOAD, LOADING, MOVING_TO_UNLOAD, UNLOADING}; Tanker_state tanker_state; std::shared_ptr<Island> load; std::shared_ptr<Island> unload; const double max_cargo; double cargo; /* private member functions */ void set_destination_helper(std::shared_ptr<Island> island_ptr); void reset_to_no_cargo_destination(); }; #endif
24caac214f7067ea85c5cdb4d63f4e8779d93004
160403964d064a66cbe1f0ae33e8c4c161f7154f
/loj/1390.cpp
18db38db54a18a41432dba3be7429cec957652fc
[]
no_license
dezhonger/Algorithm
27e762e4fa707f620fc75d8ab9a5a640dc6b0551
73836afc26c6e79b92e706c8b1f472e035527d1d
refs/heads/master
2021-07-11T00:38:51.427893
2020-07-30T16:33:58
2020-07-30T16:33:58
178,549,118
0
0
null
null
null
null
UTF-8
C++
false
false
777
cpp
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 200020; int n, phi[N], p[N]; LL sum[N]; int tot; bool used[N]; //预处理出素数 欧拉函数 欧拉函数前缀和 void init(LL n) { phi[1] = 0; for (int i = 2; i <= n; i++) { if (!used[i]) { phi[i] = i - 1; p[++tot] = i; } for (int j = 1; p[j] * i <= n; j++) { used[p[j] * i] = true; if (i % p[j] == 0) { phi[i * p[j]] = phi[i] * p[j]; break; } phi[i * p[j]] = phi[i] * (p[j] - 1); } } for (int i = 1; i <= n; i++) sum[i] = sum[i-1] + phi[i]; } LL cal(LL x) { LL res = 0; for (int i = 1; i <= x; i++) { int t = x / i; res += 1LL * sum[t] * i; } return res; } int main() { int x; cin >> x; init(x); cout << cal(x) << endl; return 0; }
4fe6f10f9e8e20ce21b8d586dc3eeb4b5ebafdf3
cf8ddfc720bf6451c4ef4fa01684327431db1919
/SDK/ARKSurvivalEvolved_PrimalItemConsumable_Egg_Quetz_Gen2_classes.hpp
0deac102d1fc79a404544bc6d465e31de80ef0f5
[ "MIT" ]
permissive
git-Charlie/ARK-SDK
75337684b11e7b9f668da1f15e8054052a3b600f
c38ca9925309516b2093ad8c3a70ed9489e1d573
refs/heads/master
2023-06-20T06:30:33.550123
2021-07-11T13:41:45
2021-07-11T13:41:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
907
hpp
#pragma once // ARKSurvivalEvolved (329.9) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_PrimalItemConsumable_Egg_Quetz_Gen2_structs.hpp" namespace sdk { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass PrimalItemConsumable_Egg_Quetz_Gen2.PrimalItemConsumable_Egg_Quetz_Gen2_C // 0x0000 (0x0AF8 - 0x0AF8) class UPrimalItemConsumable_Egg_Quetz_Gen2_C : public UPrimalItemConsumable_Egg_Quetz_C { public: static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass PrimalItemConsumable_Egg_Quetz_Gen2.PrimalItemConsumable_Egg_Quetz_Gen2_C"); return ptr; } void ExecuteUbergraph_PrimalItemConsumable_Egg_Quetz_Gen2(int EntryPoint); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
51e461659ff82892a5586108b953d6c1bfc9bd4d
1c4f30839fa4a91694a320f1722962f03a34d6ab
/moveit_planners/ompl/ompl_interface/src/parameterization/model_based_state_space_factory.cpp
29dad8be2ebd5ce026e6b944dae3926263bb6cb7
[]
no_license
wkentaro/moveit
9874ca22b30192b893b9e3fd69724cf5ccfccbf4
727e4b6eedd588ac03c27146506db483707360d1
refs/heads/kinetic-devel
2021-01-18T17:22:58.671062
2016-08-16T19:39:06
2016-08-16T19:39:06
65,875,143
2
0
null
2016-08-17T04:09:01
2016-08-17T04:09:00
null
UTF-8
C++
false
false
2,142
cpp
/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2012, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of Willow Garage nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ /* Author: Ioan Sucan */ #include <moveit/ompl_interface/parameterization/model_based_state_space_factory.h> ompl_interface::ModelBasedStateSpacePtr ompl_interface::ModelBasedStateSpaceFactory::getNewStateSpace(const ModelBasedStateSpaceSpecification &space_spec) const { ModelBasedStateSpacePtr ss = allocStateSpace(space_spec); ss->computeLocations(); return ss; }
24cf3c6a08e90c8e68a7d23e8e8918e2a8d4730e
c88493888dbcadd2195825c28c1064d8088420a0
/Kamera/practicalsocket.h
a758c0988b239e65e4532fd182db1f3d2a49ec26
[]
no_license
martakuzak/ASOD1
c92b99027ca63b7ba2ee316152ae821059a2e554
24427b4e1c8795d0fb422b5026c3cbbea1c252d6
refs/heads/master
2020-05-19T11:42:59.906744
2014-04-12T19:14:41
2014-04-12T19:14:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,786
h
/* * C++ sockets on Unix and Windows * Copyright (C) 2002 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __PRACTICALSOCKET_INCLUDED__ #define __PRACTICALSOCKET_INCLUDED__ #include <string> // For string #include <exception> // For exception class #pragma warning(disable:4290) using namespace std; /** * Signals a problem with the execution of a socket call. */ class SocketException : public exception { public: /** * Construct a SocketException with a explanatory message. * @param message explanatory message * @param incSysMsg true if system message (from strerror(errno)) * should be postfixed to the user provided message */ SocketException(const string &message, bool inclSysMsg = false) throw(); /** * Provided just to guarantee that no exceptions are thrown. */ ~SocketException() throw(); /** * Get the exception message * @return exception message */ const char *what() const throw(); private: string userMessage; // Exception message }; /** * Base class representing basic communication endpoint */ class Socket { public: /** * Close and deallocate this socket */ ~Socket(); /** * Get the local address * @return local address of socket * @exception SocketException thrown if fetch fails */ string getLocalAddress() throw(SocketException); /** * Get the local port * @return local port of socket * @exception SocketException thrown if fetch fails */ unsigned short getLocalPort() throw(SocketException); /** * Set the local port to the specified port and the local address * to any interface * @param localPort local port * @exception SocketException thrown if setting local port fails */ void setLocalPort(unsigned short localPort) throw(SocketException); /** * Set the local port to the specified port and the local address * to the specified address. If you omit the port, a random port * will be selected. * @param localAddress local address * @param localPort local port * @exception SocketException thrown if setting local port or address fails */ void setLocalAddressAndPort(const string &localAddress, unsigned short localPort = 0) throw(SocketException); /** * If WinSock, unload the WinSock DLLs; otherwise do nothing. We ignore * this in our sample client code but include it in the library for * completeness. If you are running on Windows and you are concerned * about DLL resource consumption, call this after you are done with all * Socket instances. If you execute this on Windows while some instance of * Socket exists, you are toast. For portability of client code, this is * an empty function on non-Windows platforms so you can always include it. * @param buffer buffer to receive the data * @param bufferLen maximum number of bytes to read into buffer * @return number of bytes read, 0 for EOF, and -1 for error * @exception SocketException thrown WinSock clean up fails */ static void cleanUp() throw(SocketException); /** * Resolve the specified service for the specified protocol to the * corresponding port number in host byte order * @param service service to resolve (e.g., "http") * @param protocol protocol of service to resolve. Default is "tcp". */ static unsigned short resolveService(const string &service, const string &protocol = "tcp"); private: // Prevent the user from trying to use value semantics on this object Socket(const Socket &sock); void operator=(const Socket &sock); protected: int sockDesc; // Socket descriptor Socket(int type, int protocol) throw(SocketException); Socket(int sockDesc); }; /** * Socket which is able to connect, send, and receive */ class CommunicatingSocket : public Socket { public: /** * Establish a socket connection with the given foreign * address and port * @param foreignAddress foreign address (IP address or name) * @param foreignPort foreign port * @exception SocketException thrown if unable to establish connection */ void connect(const string &foreignAddress, unsigned short foreignPort) throw(SocketException); /** * Write the given buffer to this socket. Call connect() before * calling send() * @param buffer buffer to be written * @param bufferLen number of bytes from buffer to be written * @exception SocketException thrown if unable to send data */ void send(const void *buffer, int bufferLen) throw(SocketException); /** * Read into the given buffer up to bufferLen bytes data from this * socket. Call connect() before calling recv() * @param buffer buffer to receive the data * @param bufferLen maximum number of bytes to read into buffer * @return number of bytes read, 0 for EOF, and -1 for error * @exception SocketException thrown if unable to receive data */ int recv(void *buffer, int bufferLen) throw(SocketException); /** * Get the foreign address. Call connect() before calling recv() * @return foreign address * @exception SocketException thrown if unable to fetch foreign address */ string getForeignAddress() throw(SocketException); /** * Get the foreign port. Call connect() before calling recv() * @return foreign port * @exception SocketException thrown if unable to fetch foreign port */ unsigned short getForeignPort() throw(SocketException); protected: CommunicatingSocket(int type, int protocol) throw(SocketException); CommunicatingSocket(int newConnSD); }; /** * TCP socket for communication with other TCP sockets */ class TCPSocket : public CommunicatingSocket { public: /** * Construct a TCP socket with no connection * @exception SocketException thrown if unable to create TCP socket */ TCPSocket() throw(SocketException); /** * Construct a TCP socket with a connection to the given foreign address * and port * @param foreignAddress foreign address (IP address or name) * @param foreignPort foreign port * @exception SocketException thrown if unable to create TCP socket */ TCPSocket(const string &foreignAddress, unsigned short foreignPort) throw(SocketException); private: // Access for TCPServerSocket::accept() connection creation friend class TCPServerSocket; TCPSocket(int newConnSD); }; /** * TCP socket class for servers */ class TCPServerSocket : public Socket { public: /** * Construct a TCP socket for use with a server, accepting connections * on the specified port on any interface * @param localPort local port of server socket, a value of zero will * give a system-assigned unused port * @param queueLen maximum queue length for outstanding * connection requests (default 5) * @exception SocketException thrown if unable to create TCP server socket */ TCPServerSocket(unsigned short localPort, int queueLen = 5) throw(SocketException); /** * Construct a TCP socket for use with a server, accepting connections * on the specified port on the interface specified by the given address * @param localAddress local interface (address) of server socket * @param localPort local port of server socket * @param queueLen maximum queue length for outstanding * connection requests (default 5) * @exception SocketException thrown if unable to create TCP server socket */ TCPServerSocket(const string &localAddress, unsigned short localPort, int queueLen = 5) throw(SocketException); /** * Blocks until a new connection is established on this socket or error * @return new connection socket * @exception SocketException thrown if attempt to accept a new connection fails */ TCPSocket *accept() throw(SocketException); private: void setListen(int queueLen) throw(SocketException); }; /** * UDP socket class */ class UDPSocket : public CommunicatingSocket { public: /** * Construct a UDP socket * @exception SocketException thrown if unable to create UDP socket */ UDPSocket() throw(SocketException); /** * Construct a UDP socket with the given local port * @param localPort local port * @exception SocketException thrown if unable to create UDP socket */ UDPSocket(unsigned short localPort) throw(SocketException); /** * Construct a UDP socket with the given local port and address * @param localAddress local address * @param localPort local port * @exception SocketException thrown if unable to create UDP socket */ UDPSocket(const string &localAddress, unsigned short localPort) throw(SocketException); /** * Unset foreign address and port * @return true if disassociation is successful * @exception SocketException thrown if unable to disconnect UDP socket */ void disconnect() throw(SocketException); /** * Send the given buffer as a UDP datagram to the * specified address/port * @param buffer buffer to be written * @param bufferLen number of bytes to write * @param foreignAddress address (IP address or name) to send to * @param foreignPort port number to send to * @return true if send is successful * @exception SocketException thrown if unable to send datagram */ void sendTo(const void *buffer, int bufferLen, const string &foreignAddress, unsigned short foreignPort) throw(SocketException); /** * Read read up to bufferLen bytes data from this socket. The given buffer * is where the data will be placed * @param buffer buffer to receive data * @param bufferLen maximum number of bytes to receive * @param sourceAddress address of datagram source * @param sourcePort port of data source * @return number of bytes received and -1 for error * @exception SocketException thrown if unable to receive datagram */ int recvFrom(void *buffer, int bufferLen, string &sourceAddress, unsigned short &sourcePort) throw(SocketException); /** * Set the multicast TTL * @param multicastTTL multicast TTL * @exception SocketException thrown if unable to set TTL */ void setMulticastTTL(unsigned char multicastTTL) throw(SocketException); /** * Join the specified multicast group * @param multicastGroup multicast group address to join * @exception SocketException thrown if unable to join group */ void joinGroup(const string &multicastGroup) throw(SocketException); /** * Leave the specified multicast group * @param multicastGroup multicast group address to leave * @exception SocketException thrown if unable to leave group */ void leaveGroup(const string &multicastGroup) throw(SocketException); private: void setBroadcast(); }; #endif
1ccf73f1071a4d30cd60a862fb696803f6040b32
974a20e0f85d6ac74c6d7e16be463565c637d135
/trunk/packages/dScene/dNodeInfo.h
19d70b75c2237ae2e5eba78f0d761aab1ed151ff
[]
no_license
Naddiseo/Newton-Dynamics-fork
cb0b8429943b9faca9a83126280aa4f2e6944f7f
91ac59c9687258c3e653f592c32a57b61dc62fb6
refs/heads/master
2021-01-15T13:45:04.651163
2011-11-12T04:02:33
2011-11-12T04:02:33
2,759,246
0
0
null
null
null
null
UTF-8
C++
false
false
5,378
h
///////////////////////////////////////////////////////////////////////////// // Name: dNodeInfo.h // Purpose: // Author: Julio Jerez // Modified by: // Created: 22/05/2010 08:02:08 // RCS-ID: // Copyright: Copyright (c) <2010> <Newton Game Dynamics> // License: // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely ///////////////////////////////////////////////////////////////////////////// #ifndef _D_NODEINFO_H_ #define _D_NODEINFO_H_ #include "dScene.h" #include "dVariable.h" #define NE_MAX_NAME_SIZE 64 class dNodeInfo; #define D_DEFINE_CLASS_NODE_ESSENCIALS(className,baseClass) \ dAddRtti(baseClass); \ virtual dNodeInfo* MakeCopy () const \ { \ return new className(*this); \ } \ virtual dNodeInfo* MetaFunction(dScene* const world) const \ { \ return new className(world); \ } \ static const char* BaseClassName () \ { \ return #baseClass; \ } \ static const className& GetSingleton() \ { \ return m_singletonClass; \ } \ static className m_singletonClass; #define D_DEFINE_CLASS_NODE(className,baseClass) \ virtual const char* GetClassName () const \ { \ return #className; \ } \ D_DEFINE_CLASS_NODE_ESSENCIALS(className,baseClass) #define D_IMPLEMENT_CLASS_NODE(className) \ dInitRtti(className); \ className className::m_singletonClass; \ static className::dRegisterSingleton m_registerSingletonAgent (#className, &className::m_singletonClass); #define SerialiseBase(baseClass,rootNode) \ TiXmlElement* baseClassNode = new TiXmlElement (#baseClass); \ rootNode->LinkEndChild(baseClassNode); \ baseClass::Serialize(baseClassNode); #define DeserialiseBase(baseClass,rootNode,revision) \ TiXmlElement* baseClassNode = (TiXmlElement*) rootNode->FirstChild (baseClass::GetClassName()); \ baseClass::Deserialize (baseClassNode, revision); class dNodeInfo: public dClassInfo, public dVariableList { public: enum dGizmoMode { m_selection, m_translation, m_rotation, m_scale }; enum dGizmoHandle { m_noHandle, m_xHandle, m_yHandle, m_zHandle, m_xyHandle, m_yzHandle, m_zxHandle, m_xyzHandle }; class dRegisterSingleton { public: dRegisterSingleton (const char* const className, const dNodeInfo* const singleton); }; dNodeInfo(); dNodeInfo(const dNodeInfo& me); virtual ~dNodeInfo(void); virtual dNodeInfo* MakeCopy () const; virtual const char* GetClassName () const; virtual const char* GetBaseClassName () const; virtual dNodeInfo* MetaFunction(dScene* const world) const; virtual const char* GetName () const; virtual void SetName (const char* name); virtual void SerializeBinary (FILE* const file) const; virtual void Serialize (TiXmlElement* const rootNode) const; virtual bool Deserialize (TiXmlElement* const rootNode, int revisionNumber); // draw scene in wire frame mode virtual void DrawWireFrame(dScene* const world, dScene::dTreeNode* const myNode, const dVector& color) const{}; // draw scene in solid wire frame mode virtual void DrawSolidWireFrame(dScene* const world, dScene::dTreeNode* const myNode, const dVector& color) const{}; // draw scene in Gouraud shaded virtual void DrawGouraudShaded(dScene* const world, dScene::dTreeNode* const myNode, const dVector& color) const{}; // draw scene in using shaders virtual void DrawShaded(dScene* const world, dScene::dTreeNode* const myNode, const dVector& color) const{}; // Draw selection gizmo virtual void DrawGizmo(dScene* const world, dScene::dTreeNode* const myNode, const dMatrix& coordinaSystem, const dVector& color, dGizmoMode mode, dFloat size) const{}; virtual dGizmoHandle GetHighlightedGizmoHandle(dScene* const world, dScene::dTreeNode* const myNode, const dMatrix& coordinaSystem, const dVector& screenPosition, dGizmoMode mode, dFloat size) const {return m_noHandle;} virtual void DrawGizmoHandle(dScene* world, const dMatrix& coordinaSystem, dGizmoMode mode, dGizmoHandle handle, const dVector& color, dFloat size) const {}; virtual void BakeTransform (const dMatrix& transform){}; virtual unsigned GetUniqueID() const {return m_uniqueID;} // virtual dVariableList& GetVariableList(); // virtual dVariable* CreateVariable (const char* name); // virtual dVariable* FindVariable(const char* name) const; static dNodeInfo* CreateFromClassName (const char* className, dScene* world); static dTree<const dNodeInfo*, dCRCTYPE>& GetSingletonDictionary(); static void ReplaceSingletonClass (const char* const className, const dNodeInfo* const singleton); dAddRtti(dClassInfo); private: char m_name[NE_MAX_NAME_SIZE]; // dVariableList m_variables; unsigned m_uniqueID; static unsigned m_uniqueIDCounter; }; #endif
[ "[email protected]@b7a2f1d6-d59d-a8fe-1e9e-8d4888b32692" ]
[email protected]@b7a2f1d6-d59d-a8fe-1e9e-8d4888b32692
fd85e2fd837bfa6a19af4a792ec15b863408297f
545dc4ffb79cd1c3be65897b1527c4f668da3ba6
/Space.h
df7b8461ca0822c2ea393283f8a0da32d9bf296c
[]
no_license
Wiluski/space-debris-collision-detection
42d21f9801e4e5430bf671ec58492ed78824d9eb
0bb20d91df920aca07ea2f4c2bf2867f7061bbd4
refs/heads/master
2021-05-24T17:53:44.889483
2020-04-05T07:59:04
2020-04-05T07:59:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
288
h
#pragma once #ifndef SPACE_H #define SPACE_H #include "SpaceObject.h" class Space { public: Space(int amountOfDebris0 = 0); Space(const Space& rf); ~Space(); void initializeObjects(); private: SpaceObject *debris; SpacePoint limit[7]; int amountOfDebris; }; #endif /* !SPACE_H*/
464a8c96625ff0f062747849c09fed0f4ce9583d
0bd538b351d216bd5129227c781a748bbaa6c75d
/Ponteiros-02/Origem.cpp
f9c49e6b7e2423700196dedec53e5350f6791233
[]
no_license
rfribeiro/ponteiros
984a345766381f202140520d7d939c721f89b284
edcf767db2864ec9d20d60c2d5a2564dd0aa1fa6
refs/heads/main
2022-12-24T15:14:00.638969
2020-10-06T01:29:44
2020-10-06T01:29:44
301,583,569
0
0
null
null
null
null
ISO-8859-1
C++
false
false
643
cpp
// Tecnoservice-Curso.cpp : Este arquivo contém a função 'main'. A execução do programa começa e termina ali. // #include <iostream> #define MAX_VECTOR_SIZE 10 void alterar(int* vec) { for (int i = 0; i < MAX_VECTOR_SIZE; i += 2) { vec[i] *= 100; } } int main() { int* vec = NULL; vec = (int*)malloc(MAX_VECTOR_SIZE * sizeof(int)); memset(vec, 0, MAX_VECTOR_SIZE * sizeof(int)); for (int i = 0; i < MAX_VECTOR_SIZE; i++) { vec[i] = 10 * i; } alterar(vec); for (int i = 0; i < MAX_VECTOR_SIZE; i++) { std::cout << vec[i] << std::endl; } free(vec); }
c79855fa5dd3c4eb3a73c7788c9aac8cd9ef3dd4
230b7714d61bbbc9a75dd9adc487706dffbf301e
/third_party/blink/renderer/core/script/classic_script.h
e64a2118b1e284013ee33acff62788f3610407dd
[ "LGPL-2.0-only", "BSD-2-Clause", "LGPL-2.1-only", "LGPL-2.0-or-later", "GPL-1.0-or-later", "MIT", "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer", "GPL-2.0-only", "LicenseRef-scancode-other-copyleft", "BSD-3-Clause" ]
permissive
byte4byte/cloudretro
efe4f8275f267e553ba82068c91ed801d02637a7
4d6e047d4726c1d3d1d119dfb55c8b0f29f6b39a
refs/heads/master
2023-02-22T02:59:29.357795
2021-01-25T02:32:24
2021-01-25T02:32:24
197,294,750
1
2
BSD-3-Clause
2019-09-11T19:35:45
2019-07-17T01:48:48
null
UTF-8
C++
false
false
1,774
h
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_SCRIPT_CLASSIC_SCRIPT_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_SCRIPT_CLASSIC_SCRIPT_H_ #include "third_party/blink/renderer/bindings/core/v8/sanitize_script_errors.h" #include "third_party/blink/renderer/bindings/core/v8/script_source_code.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/loader/resource/script_resource.h" #include "third_party/blink/renderer/core/script/script.h" #include "third_party/blink/renderer/platform/loader/fetch/script_fetch_options.h" namespace blink { class CORE_EXPORT ClassicScript final : public Script { public: ClassicScript(const ScriptSourceCode& script_source_code, const KURL& base_url, const ScriptFetchOptions& fetch_options, SanitizeScriptErrors sanitize_script_errors) : Script(fetch_options, base_url), script_source_code_(script_source_code), sanitize_script_errors_(sanitize_script_errors) {} void Trace(Visitor*) override; const ScriptSourceCode& GetScriptSourceCode() const { return script_source_code_; } private: mojom::ScriptType GetScriptType() const override { return mojom::ScriptType::kClassic; } void RunScript(LocalFrame*, const SecurityOrigin*) override; void RunScriptOnWorker(WorkerGlobalScope&) override; String InlineSourceTextForCSP() const override { return script_source_code_.Source().ToString(); } const ScriptSourceCode script_source_code_; const SanitizeScriptErrors sanitize_script_errors_; }; } // namespace blink #endif
77b78bac9e8e8d1f633a3a80cca05bba8d165aa6
204d2f69a4f06fa6e55c6bd16bee5aba21f32b12
/0324实验题_1/0324实验题_1/0324实验题_1.cpp
cd504bf69851d71fafda6c744ad62dd370358a37
[]
no_license
WHuiM/-
b5ee0ca0159ff7ab2b3c841556ee399375eee5a3
9931207ca3452ba95f8c13f977bf25f05bff9b0a
refs/heads/master
2021-05-18T02:49:14.086963
2020-07-09T05:10:06
2020-07-09T05:10:06
251,055,451
0
0
null
null
null
null
GB18030
C++
false
false
4,660
cpp
// 0324实验题_1.cpp : 定义应用程序的类行为。 // #include "stdafx.h" #include "afxwinappex.h" #include "afxdialogex.h" #include "0324实验题_1.h" #include "MainFrm.h" #include "0324实验题_1Doc.h" #include "0324实验题_1View.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMy0324实验题_1App BEGIN_MESSAGE_MAP(CMy0324实验题_1App, CWinApp) ON_COMMAND(ID_APP_ABOUT, &CMy0324实验题_1App::OnAppAbout) // 基于文件的标准文档命令 ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen) END_MESSAGE_MAP() // CMy0324实验题_1App 构造 CMy0324实验题_1App::CMy0324实验题_1App() { // 支持重新启动管理器 m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; #ifdef _MANAGED // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); #endif // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 //为 CompanyName.ProductName.SubProduct.VersionInformation SetAppID(_T("0324实验题_1.AppID.NoVersion")); // TODO: 在此处添加构造代码, // 将所有重要的初始化放置在 InitInstance 中 } // 唯一的一个 CMy0324实验题_1App 对象 CMy0324实验题_1App theApp; // CMy0324实验题_1App 初始化 BOOL CMy0324实验题_1App::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); // 初始化 OLE 库 if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // 使用 RichEdit 控件需要 AfxInitRichEdit2() // AfxInitRichEdit2(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) // 注册应用程序的文档模板。 文档模板 // 将用作文档、框架窗口和视图之间的连接 CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMy0324实验题_1Doc), RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 RUNTIME_CLASS(CMy0324实验题_1View)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 分析标准 shell 命令、DDE、打开文件操作的命令行 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 调度在命令行中指定的命令。 如果 // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 if (!ProcessShellCommand(cmdInfo)) return FALSE; // 唯一的一个窗口已初始化,因此显示它并对其进行更新 m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; } int CMy0324实验题_1App::ExitInstance() { //TODO: 处理可能已添加的附加资源 AfxOleTerm(FALSE); return CWinApp::ExitInstance(); } // CMy0324实验题_1App 消息处理程序 // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 class CAboutDlg : public CDialogEx { public: CAboutDlg(); // 对话框数据 #ifdef AFX_DESIGN_TIME enum { IDD = IDD_ABOUTBOX }; #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 // 实现 protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) END_MESSAGE_MAP() // 用于运行对话框的应用程序命令 void CMy0324实验题_1App::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } // CMy0324实验题_1App 消息处理程序
81510d9d84aeb9a8bece53258cfca9c608156614
711e5c8b643dd2a93fbcbada982d7ad489fb0169
/XPSP1/NT/inetsrv/query/qutil/qresult/qmemser.cxx
19c0bd42b0fa3d413385931975c7a501d6b2b71b
[]
no_license
aurantst/windows-XP-SP1
629a7763c082fd04d3b881e0d32a1cfbd523b5ce
d521b6360fcff4294ae6c5651c539f1b9a6cbb49
refs/heads/master
2023-03-21T01:08:39.870106
2020-09-28T08:10:11
2020-09-28T08:10:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,948
cxx
//+------------------------------------------------------------------------- // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1992 - 1992. // // File: MemSer.cxx // // History: 29-Jul-94 KyleP Created // //-------------------------------------------------------------------------- #include <pch.cxx> #pragma hdrstop #include <qmemser.hxx> CQMemSerStream::CQMemSerStream( unsigned cb ) : _cb( cb ) { _pb = (BYTE *) GlobalAlloc( GPTR | GMEM_DDESHARE, cb ); if ( _pb == 0 ) THROW ( CException( E_OUTOFMEMORY ) ); _pbCurrent = _pb; } CQMemSerStream::CQMemSerStream( BYTE * pb ) : _cb( 0 ), _pb( pb ), _pbCurrent( _pb ) { } CQMemSerStream::~CQMemSerStream() { if ( _cb > 0 ) GlobalFree( _pb ); } BYTE *CQMemSerStream::AcqBuf() { BYTE *pTmp = _pb; _pb = 0; _cb = 0; return (pTmp) ; } void CQMemSerStream::PutByte( BYTE b ) { *_pbCurrent = b; _pbCurrent += 1; } void CQMemSerStream::PutChar( char const * pc, ULONG cc ) { memcpy( _pbCurrent, pc, cc ); _pbCurrent += cc; } void CQMemSerStream::PutWChar( WCHAR const * pwc, ULONG cc ) { WCHAR * pwcTemp = AlignWCHAR(_pbCurrent); memcpy( pwcTemp, pwc, cc * sizeof(WCHAR) ); _pbCurrent = (BYTE *)(pwcTemp + cc); } void CQMemSerStream::PutUShort( USHORT us ) { USHORT * pus = AlignUSHORT(_pbCurrent); *pus = us; _pbCurrent = (BYTE *)(pus + 1); } void CQMemSerStream::PutULong( ULONG ul ) { ULONG * pul = AlignULONG(_pbCurrent); *pul = ul; _pbCurrent = (BYTE *)(pul + 1); } void CQMemSerStream::PutLong( long l ) { long * pl = AlignLong(_pbCurrent); *pl = l; _pbCurrent = (BYTE *)(pl + 1); } void CQMemSerStream::PutFloat( float f ) { float * pf = AlignFloat(_pbCurrent); *pf = f; _pbCurrent = (BYTE *)(pf + 1); } void CQMemSerStream::PutDouble( double d ) { double * pd = AlignDouble(_pbCurrent); *pd = d; _pbCurrent = (BYTE *)(pd + 1); } void CQMemSerStream::PutString( char const * psz ) { ULONG len = strlen(psz); ULONG * pul = AlignULONG(_pbCurrent); *pul = len; _pbCurrent = (BYTE *)(pul + 1); memcpy(_pbCurrent, psz, len); _pbCurrent += len; } void CQMemSerStream::PutWString( WCHAR const * pwsz ) { ULONG len = wcslen(pwsz); ULONG * pul = AlignULONG(_pbCurrent); *pul = len; len *= sizeof(WCHAR); _pbCurrent = (BYTE *)(pul + 1); memcpy(_pbCurrent, pwsz, len ); _pbCurrent += len; } void CQMemSerStream::PutBlob( BYTE const * pb, ULONG cb ) { memcpy( _pbCurrent, pb, cb ); _pbCurrent += cb; } void CQMemSerStream::PutGUID( GUID const & guid ) { GUID * pguid = (GUID *)AlignGUID(_pbCurrent); memcpy( pguid, &guid, sizeof(guid) ); _pbCurrent = (BYTE *)(pguid + 1); }
d88b2f6281af4cb75856706fafb2a5b45598e354
c704f3bfbe003e7058b5916a28029514814cc23c
/src/Data.h
09becc54c852e8ab22a70f1acdea540f89f7126a
[]
no_license
brown-ccv/SpheroidSegmentation
2d68ccc55fd4e8ac87714dada1b92f7c082af045
ef4782f53940b64666758277dc70ff2117dc554d
refs/heads/master
2020-08-23T14:48:29.965750
2019-10-21T19:15:28
2019-10-21T19:15:28
216,643,731
0
0
null
null
null
null
UTF-8
C++
false
false
5,310
h
// ---------------------------------- // Copyright © 2015, Brown University, Providence, RI. // // All Rights Reserved // // Use of the software is provided under the terms of the GNU General Public License version 3 // as published by the Free Software Foundation at http://www.gnu.org/licenses/gpl-3.0.html, provided // that this copyright notice appear in all copies and that the name of Brown University not be used in // advertising or publicity pertaining to the use or distribution of the software without specific written // prior permission from Brown University. // // See license.txt for further information. // // BROWN UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE WHICH IS // PROVIDED “AS IS”, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR ANY PARTICULAR PURPOSE. IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE FOR ANY // SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR FOR ANY DAMAGES WHATSOEVER RESULTING // FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR // OTHER TORTIOUS ACTION, OR ANY OTHER LEGAL THEORY, ARISING OUT OF OR IN CONNECTION // WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // ---------------------------------- // ///\file Data.h ///\author Benjamin Knorlein ///\date 11/22/2017 #pragma once #ifndef DATA_H #define DATA_H #include <memory> #include "Volume.h" #include "IcoSphereCreator.h" #include <vector> #include <opencv2/core/mat.hpp> #ifdef WITH_UI #include <QObject> #endif namespace conf { #ifdef WITH_UI class DataEmitter : public QObject { Q_OBJECT public: signals : void volume_updated(); void mesh_updated(); void texture_updated(); void active_point_changed(); void updateSliceView(); void render_threshold_changed(float val); void render_multiplier_changed(float val); }; #endif template<class T> class Data { public: static std::unique_ptr<Data <T> > &getInstance(){ if (!m_instance) { m_instance.reset(new Data<T>()); } return m_instance; } ~Data() { } std::vector<cv::Mat> &image_r() { return m_image_r; } std::vector<cv::Mat> &image_g() { return m_image_g; } std::vector<cv::Mat> &distancemap() { return m_distancemap; } std::unique_ptr< Volume <T> > &volume(){ return m_volume; } void generateVolume() { m_volume.reset(new conf::Volume<unsigned short>(m_image_r[0].cols, m_image_r[0].rows, m_image_r.size(), 0.645, 0.645, 5, 3)); //TODO offset variable //fill vol and points std::vector <cv::Point3d> pts; for (int x = 0; x < m_volume->get_width(); x++) { for (int y = 0; y < m_volume->get_height(); y++) { for (int z = 0; z < m_volume->get_depth(); z++) { *(m_volume->get(x, y, z, 0)) = m_image_r[z].at<unsigned short>(y, x); *(m_volume->get(x, y, z, 1)) = m_image_g[z].at<unsigned short>(y, x); } } } #ifdef WITH_UI emit m_emitter.volume_updated(); #endif } void setModel(std::vector<double> &center, double max_distance, bool updateMesh) { m_max_distance = max_distance; m_center = center; if (updateMesh){ m_mesh_indices.clear(); m_mesh_points.clear(); IcoSphereCreator creator; creator.create(4, m_mesh_indices, m_mesh_points); for (auto &pt : m_mesh_points) { pt.x = pt.x * m_max_distance + m_center[0]; pt.y = pt.y * m_max_distance + m_center[1]; pt.z = pt.z * m_max_distance + m_center[2]; } #ifdef WITH_UI emit m_emitter.mesh_updated(); #endif } } const std::vector<double> &center() const { return m_center; } double max_distance() const { return m_max_distance; } #ifdef WITH_UI DataEmitter *emitter() { return &m_emitter; } #endif std::vector<TriangleIndices> &mesh_indices() { return m_mesh_indices; } std::vector<Point> &mesh_points() { return m_mesh_points; } unsigned texture_id() const { return m_texture_id; } void set_texture_id(const unsigned texture_id) { m_texture_id = texture_id; } int active_point() const { return m_active_point; } void set_active_point(const int active_point) { this->m_active_point = active_point; } int region_size() const { return m_region_size; } void set_region_size(const double region_size) { this->m_region_size = region_size; } std::vector<std::vector<double> > &results() { return m_results; } private: Data<T>() : m_active_point(-1), m_max_distance(0){}; static std::unique_ptr<Data <T> > m_instance; std::unique_ptr< Volume <T> > m_volume; std::vector <cv::Mat> m_image_r; std::vector <cv::Mat> m_image_g; std::vector <cv::Mat> m_distancemap; double m_max_distance; std::vector <double> m_center; std::vector <TriangleIndices> m_mesh_indices; std::vector <Point> m_mesh_points; // Red (pixel normalized) - Red (region normalized)- Red - Green - NbPixel - sd Red (normalized) - sd Red - sd Green std::vector <std::vector <double> > m_results; double m_region_size; int m_active_point; private: #ifdef WITH_UI DataEmitter m_emitter; #endif unsigned int m_texture_id; }; template<class T> std::unique_ptr< Data <T> > Data <T>::m_instance = nullptr; } #endif // DATA_H
2a4f83bc9751050e6fcc78f3be2c401c01dddb39
f00f2b22d82ba93e9e73f1642bbd1eaf40c9d02e
/GlobalLogParameters.h
921bb63273b69adebaf98a976d0502428df3a989
[]
no_license
marcelra/plingtheory
a09708bc917f9af70e69960984174f219fd6ea7c
66d175b5fd6d125302fb3b9ab216c800ba8a555d
refs/heads/master
2021-05-16T03:04:29.445126
2015-08-29T21:03:40
2015-08-29T21:03:40
16,084,299
1
1
null
null
null
null
UTF-8
C++
false
false
3,611
h
#ifndef GLOBALLOGPARAMETERS_H #define GLOBALLOGPARAMETERS_H #include "Msg.h" /// TODO: try use forward declare? #include <map> /** * @class GlobalLogParameters * @brief Singleton class that holds the global logging parameters. */ class GlobalLogParameters { public: /** * Get the singleton instance. */ static const GlobalLogParameters& getInstance(); ~GlobalLogParameters(); /** * Set global threshold. */ void setThreshold( Msg::LogLevel m_threshold ); /** * Use predefined configuration for regression. */ void setRegressionConfig(); /** * Set use colors. */ void setUseColors( bool useColors ); /** * Set whether or not to display logger IDs. */ void setDoDisplayLoggerIds( bool displayLoggerId ); /** * Open file stream. */ void openFileStream( const std::string& fileName ); /** * Get global threshold. */ const Msg::LogLevel& getThreshold( size_t loggerId ) const; /** * Get the field width in which the name is displayed. */ size_t getNameFieldWidth() const; /** * Get the field width in which the level is displayed. */ size_t getLevelFieldWidth() const; /** * Get the field width in which the logger id is displayed. */ size_t getLoggerIdFieldWidth() const; /** * Get the number of spaces between the fields. */ size_t getSpacerWidth() const; /** * Get color configuration. */ bool getUseColors() const; /** * Returns whether or not to display the logger ids. */ bool doDisplayLoggerIds() const; /** * Override local logger threshold. This means that all logger instances will use the global logger threshold. */ bool doOverrideLocalThresholds() const; /** * Gets the ostream to write to. */ std::ostream& getStream() const; /** * Logger ID versus LogLevel. */ typedef std::map< size_t, Msg::LogLevel > InspectMap; /** * Set verbosity for particular logger IDs. */ void setInspectMap( const InspectMap& inspectMap ); /** * Is this logger instance inspected? */ bool isInspected( size_t loggerId ) const; private: /** * Constructor */ GlobalLogParameters(); static GlobalLogParameters* s_theInstance; //! Singleton instance private: size_t m_nameFieldWidth; //! Width of the name field size_t m_levelFieldWidth; //! Width of the level field size_t m_loggerIdFieldWidth; //! Width of the logger id field size_t m_spacerWidth; //! Number of spaces between fields Msg::LogLevel m_threshold; //! Global threshold bool m_useColors; //! Flag whether or not to display colors bool m_displayLoggerId; //! Flag to indicate whether or not to display the logger ID bool m_overrideLocalThresholds;//! Override logger instance thresholds mutable std::ostream* m_stream; //! Stream to terminal window mutable std::fstream* m_fstream; //! Stream to file std::map< size_t, Msg::LogLevel > m_inspectMap; //! Logger ID vs. LogLevel. Overrides of global log level. }; #endif // GLOBALLOGPARAMETERS_H
893631cc48099ee75048e3c3a66624f2d6d461fb
0fa285030cb7e56b99fb886036e7099e79a97528
/I/w7/66-tko+/data/popStruct.cc
8052e7edfc8b70a5cc474974728d0b7b4ec11da6
[]
no_license
TjallingO/cPlusPlusCourse
2c41c92680e29029f1b26e7331e481fd39d1ac60
f086a4c48863bafc6eeaabc1825046216da8d3df
refs/heads/master
2020-03-28T03:41:49.695426
2019-04-04T09:40:40
2019-04-04T09:40:40
147,664,507
1
2
null
2018-10-21T11:54:18
2018-09-06T11:37:45
C++
UTF-8
C++
false
false
512
cc
#include "data.ih" void data::popStruct(char c, size_t n) // Populate element n within { // struct nB, calling enumChar switch(n) // on the passed char first { case 0: d_nB.nb1 = charToEnum(c); break; case 1: d_nB.nb2 = charToEnum(c); break; case 2: d_nB.nb3 = charToEnum(c); break; case 3: d_nB.nb4 = charToEnum(c); break; default: break; } }
8311b6339521b08a09a7b66b8c92a0997eb542bd
f323f95af22e56cb117d5323d434c563404fc3da
/src/Uuid.cpp
4fda15897db4a4918a45f11a0a7a2f34db4a4693
[ "Zlib" ]
permissive
Akaito/csaru-uuid-cpp
63a9d12b4bba0102ae55c33b63f744175cf5f9c7
ad796b53fd35cf5f3271361ad4b700042edc5c11
refs/heads/master
2021-01-22T17:28:50.142874
2017-01-13T16:32:49
2017-01-13T16:32:49
60,448,660
0
0
null
null
null
null
UTF-8
C++
false
false
30
cpp
#include "exported/Uuid.hpp"
ffaad16934eee17c2f8d11e97687b2ac619fffdb
c1ac0ceca12bd24c2e341ece0882fb922e64bc8e
/Qt5Practice/Qt5_test15Paint2D/widget.cpp
10c6d81015d702a00c59245493945b1ee98fbf05
[ "Apache-2.0" ]
permissive
whuer-xiaojie/Qt_Test
23e74d263f21c51a99e84a83cb6f8465567ffbd9
5d3477f4f59c1c084a448a8a12bf536af5cad274
refs/heads/master
2020-04-14T15:42:27.133484
2019-01-03T07:04:21
2019-01-03T07:04:21
163,935,304
0
0
null
null
null
null
UTF-8
C++
false
false
1,470
cpp
#include "widget.h" #include "ui_widget.h" #include<QPainter> #include<QLinearGradient> #include<QRadialGradient> #include<QConicalGradient> Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); } Widget::~Widget() { delete ui; } void Widget::paintEvent(QPaintEvent *event) { //线性渐变 QLinearGradient linearGradient(QPointF(10,20),QPointF(20,100)); linearGradient.setColorAt(0,Qt::yellow); linearGradient.setColorAt(0.5,Qt::red); linearGradient.setColorAt(1,Qt::green); linearGradient.setSpread(QGradient::RepeatSpread); QPainter painter(this); painter.setBrush(linearGradient); painter.drawRect(0,0,width(),height()); //辐射渐变 QRadialGradient radialGredient(QPointF(10,20),50,QPointF(20,10)); radialGredient.setColorAt(0.3,Qt::white); radialGredient.setColorAt(0.5,Qt::blue); radialGredient.setSpread(QGradient::RepeatSpread); QPen pen; pen.setColor(Qt::white); painter.setPen(pen); painter.setBrush(radialGredient); painter.drawEllipse(QPointF(200,200),100,50); //锥形渐变 QConicalGradient conicalGradient(QPointF(200,100),0); conicalGradient.setColorAt(0,Qt::black); conicalGradient.setColorAt(0.3,Qt::cyan); conicalGradient.setColorAt(0.7,Qt::yellow); painter.setBrush(conicalGradient); painter.drawEllipse(QPointF(200,100),50,50); } void Widget::on_pushButton_clicked() { update(); }
9f5501e6d0a34a359d94c0bf090153186d7abb81
fb6251837c15a0ee0b28b15d214599165e11de83
/Algorithms and Data Structures/bipartitematching.cpp
a7d3bf0f3a4702d667bc74a02b743174acd33823
[]
no_license
CDPS/Competitive-Programming
de72288b8dc02ca2a45ed40491ce1839e983b765
24c046cbde7fea04a6c0f22518a688faf7521e2e
refs/heads/master
2023-08-09T09:57:15.368959
2023-08-05T00:44:41
2023-08-05T00:44:41
104,966,014
0
0
null
null
null
null
UTF-8
C++
false
false
813
cpp
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> node; int blacks,whites; typedef vector<int> VI; typedef vector<VI> VVI; bool FindMatch(int i, const VVI &w, VI &mc, VI &seen) { for (int j = 0; j < w[i].size(); j++) { if (!seen[ w[i][j] ]) { seen[ w[i][j] ] = true; if (mc[ w[i][j] ] < 0 || FindMatch(mc[ w[i][j] ], w, mc, seen)) { mc[w[i][j] ] = i; return true; } } } return false; } //return the maximun bipartite matching on a graph //using whites as |A| and blacks as |B| int BipartiteMatching(const VVI &w) { VI mc = VI(blacks, -1); int ct = 0; for (int i = 0; i < whites; i++) { VI seen(blacks); if (FindMatch(i, w,mc, seen)) ct++; } return ct; }
aceb9fec266c2b6f098ddd27c38e40061afe719b
495e7343fd2a82c4fc78a9f26ccbc7fb75ebe992
/include/ui/ruiEvents.hpp
68aff6ac03a44061a1629f55db9d4f3f6046a2a4
[]
no_license
matthewcpp/recondite
fd12bd36f25113cad485aea3baf4cd5b60eae49d
2a10964dd6c6f9ae8bc61b90df459bbcd2d4f740
refs/heads/master
2021-04-12T04:29:47.611629
2017-03-07T14:15:11
2017-03-07T14:15:11
5,922,213
2
1
null
null
null
null
UTF-8
C++
false
false
2,322
hpp
#ifndef RUI_EVENTS_HPP #define RUI_EVENTS_HPP #include "rEvent.hpp" #include "rEventHandler.hpp" #include "input/rMouse.hpp" #include "ui/ruiMenu.hpp" #include "input/rKeyboard.hpp" class ruiWidget; enum ruiEventType{ ruiEVT_MOUSE_DOWN, ruiEVT_MOUSE_UP, ruiEVT_MOUSE_MOTION, ruiEVT_MOUSE_WHEEL, ruiEVT_MOUSE_ENTER, ruiEVT_MOUSE_LEAVE, ruiEVT_KEY_DOWN, ruiEVT_KEY_UP, ruiEVT_TOUCH_DOWN, ruiEVT_TOUCH_MOVE, ruiEVT_TOUCH_UP, ruiEVT_MENU, ruiEVENT_BUTTON_CLICK, ruiEVENT_CHECKBOX_CHANGE, ruiEVENT_SLIDER_CHANGE, ruiEVENT_SLIDER_DRAG_BEGIN, ruiEVENT_SLIDER_DRAG_MOVE, ruiEVENT_SLIDER_DRAG_END, ruiEVENT_PICKER_CHANGE }; class ruiMouseEvent : public rEvent{ public: ruiMouseEvent(const rPoint& position) : m_button(rMOUSE_BUTTON_NONE), m_buttonState(rBUTTON_STATE_NONE), m_position(position), m_wheelDirection(rMOUSEWHEEL_NONE){} ruiMouseEvent(rMouseButton button, rButtonState buttonState, const rPoint& position) : m_button(button), m_buttonState(buttonState), m_position(position), m_wheelDirection(rMOUSEWHEEL_NONE) {} ruiMouseEvent(rMouseWheelDirection wheelDirection, const rPoint& position) : m_button(rMOUSE_BUTTON_NONE), m_buttonState(rBUTTON_STATE_NONE), m_position(position), m_wheelDirection(wheelDirection){} rMouseButton Button() const {return m_button;} rMouseWheelDirection WheelDirection() const {return m_wheelDirection;} rPoint Position () const {return m_position;} private: rMouseButton m_button; rPoint m_position; rMouseWheelDirection m_wheelDirection; rButtonState m_buttonState; }; class ruiWidgetEvent : public rEvent{ public: ruiWidgetEvent(ruiWidget* widget) : m_widget(widget){} ruiWidget* Widget() const { return m_widget; } private: ruiWidget* m_widget; }; class ruiMenuEvent : public rEvent{ public: ruiMenuEvent(ruiMenu* menu, int selection): m_menu(menu), m_selection(selection) {} ruiMenu* Menu() const {return m_menu;} int Selection() const {return m_selection;} private: ruiMenu* m_menu; int m_selection; }; class ruiKeyEvent : public rEvent{ public: ruiKeyEvent(rKey key, rKeyState state) : _key(key), _state(state){} rKey Key() const { return _key; } rKeyState State() const { return _state; } private: rKey _key; rKeyState _state; }; #endif
75f84d4d80ac85cb3c8f8675ea6639f98d57312f
f2ba1cbe1c3e7651b0748d24aab9b1cff9b954f9
/SP7/mainwindow.cpp
6d74b0d6d5caafde4d5c7d79b96b9cd4e10a87f0
[]
no_license
sancousic/OSIS
c3c187c3c3b44ed95055f204dbe6272f37939df1
2e9a56e028da6f4cd0aa8434502ef845530aaf37
refs/heads/master
2022-04-24T16:37:08.019661
2020-04-18T15:48:26
2020-04-18T15:48:26
256,740,285
0
0
null
null
null
null
UTF-8
C++
false
false
1,604
cpp
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { QListWidget *list1 = ui->listWidget; QString str = ui->lineEdit->text(); bool flag = true; for (int i = 0; i < list1->count(); i++) { QListWidgetItem *it = list1->item(i); if(str == it->text()) { flag = false; break; } } if(flag) list1->addItem(str); } void MainWindow::on_pushButton_3_clicked() { ui->listWidget->clear(); ui->listWidget_2->clear(); } void MainWindow::on_pushButton_2_clicked() { if(ui->listWidget->currentItem() != nullptr) { ui->listWidget->removeItemWidget(ui->listWidget->currentItem()); delete ui->listWidget->currentItem(); } if(ui->listWidget_2->currentItem() != nullptr) { ui->listWidget_2->removeItemWidget(ui->listWidget_2->currentItem()); delete ui->listWidget_2->currentItem(); } } void MainWindow::on_pushButton_4_clicked() { QListWidgetItem *currentItem = ui->listWidget->currentItem(); bool flag = true; if(currentItem != nullptr) { for(int i = 0; i < ui->listWidget_2->count(); i++) { if(currentItem->text() == ui->listWidget_2->item(i)->text()) { flag = false; break; } } if(flag) ui->listWidget_2->addItem(currentItem->text()); } }
f3ae5bdc4a6bec4f3a34549fe3580f3cd6d5d80d
64359e38f9d7920688f4ac39e7f2e9c76f6a6602
/src/011ContainerWithMostWater.cpp
ae0161c6bd3d245a0423bec5874a85cfec771675
[]
no_license
willsonlsw/myleetcode
876dc1214e217789c4b1652e364cad74bcaa0818
0a6cd89ba888380ad0fdca205fe08cf1f4f657c9
refs/heads/master
2021-01-21T14:43:26.469041
2016-07-09T10:50:57
2016-07-09T10:50:57
59,169,869
0
0
null
null
null
null
UTF-8
C++
false
false
973
cpp
#include <iostream> #include <cstdlib> #include <algorithm> #include <vector> using namespace std; class Solution { public: bool cmp(pair<int, int> &a, pair<int, int> &b) { return a.first < b.first; } int maxArea(vector<int>& height) { vector<pair<int, int> > ps; for (int i = 0; i < height.size(); ++i) { pair<int, int> p(height[i], i); ps.push_back(p); } sort(ps.begin(), ps.end(), cmp); int area = 0, i = 0, re = -1, le = 0x7fffffff; while (i < ps.size()) { int h = ps[i].first; while (i < ps.size() && ps[i].first == h) { le = ps[i].second < le ? ps[i].second : le; re = ps[i].second < le ? le : ps[i].second; i += 1; } int tmparea = (re - le) * h; area = area > tmparea ? area : tmparea; if (ps[i].first == h) i++; } return area; } }; int main() { vector<int> a; int x; for (int i = 0; i < 10; ++i) { cin >> x; a.push_back(x); } Solution sc; cout << "area:" << sc.maxArea(a) << endl; return 0; }
f58740983cc5fb995ab14c0cc676ce459610a5ee
1b007c93818700d5bca9fed6f11393f296d8e4c6
/cpp/src/arrow/stl.h
1e31ca769ae0b6ce7d2654a8325aa5c3850e5c71
[ "Apache-2.0", "CC0-1.0", "BSL-1.0", "BSD-2-Clause", "BSD-3-Clause", "MIT" ]
permissive
dremio/arrow
0e575e102f2e66778c043e935675b5e7b734cec0
d55177b7d840dc661516dc8561e9e51d5ccca2f0
refs/heads/dremio
2023-08-23T11:10:56.189074
2018-05-17T18:20:45
2018-10-19T02:41:32
53,646,043
36
29
Apache-2.0
2023-09-11T14:12:19
2016-03-11T06:48:10
C++
UTF-8
C++
false
false
5,671
h
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. #ifndef ARROW_STL_H #define ARROW_STL_H #include <memory> #include <string> #include <tuple> #include <vector> #include "arrow/type.h" namespace arrow { class Schema; namespace stl { /// Traits meta class to map standard C/C++ types to equivalent Arrow types. template <typename T> struct ConversionTraits {}; #define ARROW_STL_CONVERSION(c_type, ArrowType_) \ template <> \ struct ConversionTraits<c_type> { \ using ArrowType = ArrowType_; \ constexpr static bool nullable = false; \ }; ARROW_STL_CONVERSION(bool, BooleanType) ARROW_STL_CONVERSION(int8_t, Int8Type) ARROW_STL_CONVERSION(int16_t, Int16Type) ARROW_STL_CONVERSION(int32_t, Int32Type) ARROW_STL_CONVERSION(int64_t, Int64Type) ARROW_STL_CONVERSION(uint8_t, UInt8Type) ARROW_STL_CONVERSION(uint16_t, UInt16Type) ARROW_STL_CONVERSION(uint32_t, UInt32Type) ARROW_STL_CONVERSION(uint64_t, UInt64Type) ARROW_STL_CONVERSION(float, FloatType) ARROW_STL_CONVERSION(double, DoubleType) ARROW_STL_CONVERSION(std::string, StringType) template <typename value_c_type> struct ConversionTraits<std::vector<value_c_type>> { using ArrowType = meta::ListType<typename ConversionTraits<value_c_type>::ArrowType>; constexpr static bool nullable = false; }; /// Build an arrow::Schema based upon the types defined in a std::tuple-like structure. /// /// While the type information is available at compile-time, we still need to add the /// column names at runtime, thus these methods are not constexpr. template <typename Tuple, std::size_t N = std::tuple_size<Tuple>::value> struct SchemaFromTuple { using Element = typename std::tuple_element<N - 1, Tuple>::type; using ArrowType = typename ConversionTraits<Element>::ArrowType; // Implementations that take a vector-like object for the column names. /// Recursively build a vector of arrow::Field from the defined types. /// /// In most cases MakeSchema is the better entrypoint for the Schema creation. static std::vector<std::shared_ptr<Field>> MakeSchemaRecursion( const std::vector<std::string>& names) { std::vector<std::shared_ptr<Field>> ret = SchemaFromTuple<Tuple, N - 1>::MakeSchemaRecursion(names); ret.push_back(field(names[N - 1], std::make_shared<ArrowType>(), ConversionTraits<Element>::nullable)); return ret; } /// Build a Schema from the types of the tuple-like structure passed in as template /// parameter assign the column names at runtime. /// /// An example usage of this API can look like the following: /// /// \code{.cpp} /// using TupleType = std::tuple<int, std::vector<std::string>>; /// std::shared_ptr<Schema> schema = /// SchemaFromTuple<TupleType>::MakeSchema({"int_column", "list_of_strings_column"}); /// \endcode static std::shared_ptr<Schema> MakeSchema(const std::vector<std::string>& names) { return std::make_shared<Schema>(MakeSchemaRecursion(names)); } // Implementations that take a tuple-like object for the column names. /// Recursively build a vector of arrow::Field from the defined types. /// /// In most cases MakeSchema is the better entrypoint for the Schema creation. template <typename NamesTuple> static std::vector<std::shared_ptr<Field>> MakeSchemaRecursionT( const NamesTuple& names) { std::vector<std::shared_ptr<Field>> ret = SchemaFromTuple<Tuple, N - 1>::MakeSchemaRecursionT(names); ret.push_back(field(std::get<N - 1>(names), std::make_shared<ArrowType>(), ConversionTraits<Element>::nullable)); return ret; } /// Build a Schema from the types of the tuple-like structure passed in as template /// parameter assign the column names at runtime. /// /// An example usage of this API can look like the following: /// /// \code{.cpp} /// using TupleType = std::tuple<int, std::vector<std::string>>; /// std::shared_ptr<Schema> schema = /// SchemaFromTuple<TupleType>::MakeSchema({"int_column", "list_of_strings_column"}); /// \endcode template <typename NamesTuple> static std::shared_ptr<Schema> MakeSchema(const NamesTuple& names) { return std::make_shared<Schema>(MakeSchemaRecursionT<NamesTuple>(names)); } }; template <typename Tuple> struct SchemaFromTuple<Tuple, 0> { static std::vector<std::shared_ptr<Field>> MakeSchemaRecursion( const std::vector<std::string>& names) { std::vector<std::shared_ptr<Field>> ret; ret.reserve(names.size()); return ret; } template <typename NamesTuple> static std::vector<std::shared_ptr<Field>> MakeSchemaRecursionT( const NamesTuple& names) { std::vector<std::shared_ptr<Field>> ret; ret.reserve(std::tuple_size<NamesTuple>::value); return ret; } }; /// @endcond } // namespace stl } // namespace arrow #endif // ARROW_STL_H
883989e08002ca52c7a8816ae74c0d59639f1af0
40e5895e9a68ef19fd328de1183fddcfc56b7a86
/megasectcal/megasectcal/Pk_MainOutPut.h
725635d872a08b7cc51ff37c63d2a9c6d0da0a62
[]
no_license
diablozhuzhu/megacal
ad2c155470eed28885a03287cc8d3e9faa05d313
f7d36c534b49a130c053a4d1de5141049b662efd
refs/heads/master
2020-03-07T15:06:36.903216
2018-04-01T14:00:25
2018-04-01T14:00:25
127,545,389
0
1
null
null
null
null
ISO-8859-7
C++
false
false
8,186
h
#pragma once #include "IGenerateText.h" #include "ICalculationReport.h" //#include "Param_MainParam.h" #include "ConfigGen.h" #include "Loaddef.h" //#include "StructBaseInfo.h" class TextTool { public: static const CString Eng; public: TextTool(); ~TextTool(); public: bool readJson(); public: void Set(sd::IGenerateText* pT1,sd::PARAGRAPH_FORMAT* pF1); void SetGenerateText(sd::IGenerateText* pT1); void SetTEXT_FORMAT(sd::TEXT_FORMAT tf1); void SetPARAGRAPH_FORMAT(sd::PARAGRAPH_FORMAT* pF1); void BeginP(); void EndP(); CString format(double,int npre); void Txt(CString str1); void Txt(int nC,int nAt); void TxSub(CString str1); void TxUp(CString str1); void TxSub(CString str1,CString up,CString sign = ""); void TxUp(CString str1,CString sub,CString sign = ""); void TxUpSub(CString str1,CString up,CString sub,CString sign = ""); void TxV(double f,int nPre = 0); void TxV(int n); void m(); void m(double ff,int nPre = 0); void m(double ff,int nPre ,int _n10n); void mm3(); void mm3(double ff,int nPre = 0); void mm3(double ff,int nPre ,int _n10n); void mm2(); void mm2(double ff,int nPre = 0); void m$s2(); void m$s2(double ff,int nPre = 0); void mm(); void mm(double ff,int nPre = 0); void mm4(); void mm4(double ff,int nPre = 0 ,int _n10n=4); void kg$m(); void kg$m(double ff,int nPre = 0); void MPa(); void MPa(double ff,int nPre = 0); void C(int CXX); void days(int ndy); void kN(); void kN(double ff,int nPre = 0); void kN(double ff,int nPre,int _n10n=4); void N(); void N(double ff,int nPre = 0); void kNm(); void kNm(double ff,int nPre = 0); void Nmm2(); void Nmm2(double ff,int nPre = 0); void kNm2(); void kNm2(double ff,int nPre = 0); void kNm2(double ff,int nPre,int _n10n=4); void N$mm(); void N$mm(double ff,int nPre = 0); void kN$m(); void kN$m(double ff,int nPre = 0); void N$m(); void N$m(double ff,int nPre = 0); void studs$1m(); void studs$1m(double ff,int nPre = 0); void SpTab______(int n=2); private: Json::Value jsDocs; Json::Value jsLang; Json::Value jsC; Json::Value jsAt; private: sd::IGenerateText* pT; sd::PARAGRAPH_FORMAT* pF; private: sd::TEXT_FORMAT tf; sd::TEXT_FORMAT tfsub; sd::TEXT_FORMAT tfup; sd::TEXT_FORMAT tfUpSub; }; class CPk_MainOutPut { enum { DRAWPAGE_NULL = 0, DRAWPAGE_HORI = 1, DRAWPAGE_VERI = 2 }; enum { PATH_EXE_FOLDER = 0, PATH_WORKDIR = 1 }; private: static TextTool stt; public: static const TCHAR* configXmlPrefix; static CString configXml; static TCHAR* CalculationReportXml; static TCHAR* wordFileName; static const TCHAR* pathCalcTemp; static int m_doctype; static int m_drawHoriVeri; public: struct CombStress { int id; double M1,N1,V1,M2,N2,V2; }; struct BeamM { CString wanju1; CString wanju2; double MDown[7],MUp[7]; double M1,M2,M3,M4,M5,M6,M7; }; struct BeamNao { CString naodu; double nao[7]; }; struct WindColumnStree { int id; double My,N,V; }; //static int s_PicIndex; public: CPk_MainOutPut(void); ~CPk_MainOutPut(void); static bool initReportTool(); static bool dlgConfig(); static bool prepareT(); static bool ProgressPrepair(int np); static bool outputRoutine(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool GENERAL_PARAMETERS(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool CODE_STANDARD(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool CROSS_SECTION(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool Material_properties(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool Creep_coefficient_concrete(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool Load_cases(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool Load_case(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool Load_case_one(sd::IGenerateText* ,const sd::REPORT_ITEM&, const mega_loads& ldCase); static bool Calculation_parameters(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool Load_combinations(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool ULTIMATE_LIMIT_STATES(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool RESISTANCE_OF_THE_CROSS_SECTION_AXIAL(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool RESISTANCE_OF_THE_CROSS_SECTION_TO_SHEAR_RESISTANCE(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool RESISTANCE_OF_THE_CROSS_SECTION_TO_COMBINED_ACTIONS_M_N(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool RESISTANCE_OF_THE_CROSS_SECTION_TO_COMBINED_ACTIONS_M_N2(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool BUCKLING_RESISTANCE_TO_AXIAL_FORCE(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool AMPLIFICATION_OF_DESIGN_MOMENT_OF_COMBINED_ACTION_M_N_CONSIDERING(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool INTERFACE_SHEAR_CONNECTION(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool SYNTHESIS_OF_VERIFICATIONS(sd::IGenerateText* ,const sd::REPORT_ITEM&); static bool SYNTHESIS_OF_VERIFICATIONS_CUSTOM(sd::IGenerateText* ,const sd::REPORT_ITEM&); static void DrawingFiberPDM_Points(sd::IGenerateText* pGenerateText, const sd::REPORT_ITEM& mReportItem ); /////////////////////////////////////////////////////// static void DrawingFunc(sd::IGenerateText* pGenerateText, const sd::GRAPHIC_ITEM& mReportItem,CString fileName, sd::PGRAPHIC_FORMAT pFormat,int wid = 110,int nPreEmptyLine = 1); static void DrawingFuncEmbed(sd::IGenerateText* pGenerateText, const sd::GRAPHIC_ITEM& mReportItem,CString fileName, sd::PGRAPHIC_FORMAT pFormat,int wid = 75); static bool drawingRoutine( sd::IGenerateText* pGenerateText, const sd::GRAPHIC_ITEM& mReportItem); static bool GenDrawingName(const sd::GRAPHIC_ITEM& mReportItem,CString& DrawName,bool resetIndex=false); static bool ClearCal_T(); static bool ClearCalcTemp(); static bool CopyInCalcTemp(CString fileName,CString newName ); static bool CopyToCalcTemp(CString fileName,CString newName,bool delori=false); static bool subt(sd::IGenerateText* pT,const sd::REPORT_ITEM& mReportItem,CString str1); static bool upt(sd::IGenerateText* pT,const sd::REPORT_ITEM& mReportItem,CString str1); //Αυ static bool SERVICEABILITY_LIMIT_STATES(sd::IGenerateText* pGenerateText ,const sd::REPORT_ITEM& mReportItem); static bool INTERNAL_FORCES(sd::IGenerateText* pGenerateText ,const sd::REPORT_ITEM& mReportItem); static bool CRACK_CHECK(sd::IGenerateText* pGenerateText ,const sd::REPORT_ITEM& mReportItem); static bool MEMBER_CHECK1(sd::IGenerateText* pGenerateText ,const sd::REPORT_ITEM& mReportItem); static bool MEMBER_CHECK2(sd::IGenerateText* pGenerateText ,const sd::REPORT_ITEM& mReportItem); static bool MEMBER_CHECK3(sd::IGenerateText* pGenerateText ,const sd::REPORT_ITEM& mReportItem); static bool MEMBER_CHECK4(sd::IGenerateText* pGenerateText ,const sd::REPORT_ITEM& mReportItem); static void MTable( sd::IGenerateText* pGenerateText, const sd::REPORT_ITEM& mReportItem,int currentcomb,const int yz); static void TrussModelTable(sd::IGenerateText* pGenerateText, const sd::REPORT_ITEM& mReportItem,int side); static void LoadCaseTable(sd::IGenerateText* pGenerateText, const sd::REPORT_ITEM& mReportItem,int caseno); static void LoadCombTable(sd::IGenerateText* pGenerateText, const sd::REPORT_ITEM& mReportItem); static void DrawPicJPG(sd::IGenerateText* pGenerateText, const sd::REPORT_ITEM& mReportItem,CString filename,int PathType=PATH_EXE_FOLDER,int wid=150 ); static bool Drawing_Fiber_1(sd::IGenerateText* pGenerateText, const sd::GRAPHIC_ITEM& mReportItem,CConfigGenCalc& config); static bool Drawing_PDM_1(sd::IGenerateText* pGenerateText, const sd::GRAPHIC_ITEM& mReportItem,CConfigGenCalc& config); static bool Drawing_Fiber_2(sd::IGenerateText* pGenerateText, const sd::GRAPHIC_ITEM& mReportItem,CConfigGenCalc& config); static bool Drawing_PDM_2(sd::IGenerateText* pGenerateText, const sd::GRAPHIC_ITEM& mReportItem,CConfigGenCalc& config); static bool Drawing_Sect(sd::IGenerateText* pGenerateText, const sd::GRAPHIC_ITEM& mReportItem,CConfigGenCalc& config); //static bool clickIconRoutine( NODE_KEY key,OPTION_TYPE eType,SD_POINT pt); };
37f03c4a29c4c605b0cb0d47cf33dc87dea116e2
f73086d9ccac3120883c9e528b512828d78642e5
/src/filter.cpp
45aa64061d0f9c357f3d6e98ca87661c98f53134
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
ip-gpu/qgrep
1704969053aa9694debb8e9e5cb2d5e7d5df3225
3046bbff440f8206314bfdbef74f4472023f03ef
refs/heads/master
2021-07-18T20:09:48.574672
2017-09-25T05:44:06
2017-09-25T05:44:06
108,592,434
0
0
null
2017-10-27T20:24:58
2017-10-27T20:24:58
null
UTF-8
C++
false
false
11,696
cpp
#include "common.hpp" #include "filter.hpp" #include "output.hpp" #include "search.hpp" #include "regex.hpp" #include "stringutil.hpp" #include "highlight.hpp" #include "fuzzymatch.hpp" #include <memory> #include <algorithm> #include <limits.h> struct FilterOutput { FilterOutput(Output* output, unsigned int options, unsigned int limit): output(output), options(options), limit(limit) { } Output* output; unsigned int options; unsigned int limit; }; struct FilterHighlightBuffer { std::vector<int> posbuf; std::vector<HighlightRange> ranges; std::string result; }; static void processMatch(const char* path, size_t pathLength, FilterOutput* output) { if (output->options & SO_VISUALSTUDIO) { char* buffer = static_cast<char*>(alloca(pathLength)); std::transform(path, path + pathLength, buffer, BackSlashTransformer()); path = buffer; } output->output->rawprint(path, pathLength); output->output->rawprint("\n", 1); } static void processMatch(const FilterEntry& entry, const char* buffer, FilterOutput* output) { processMatch(buffer + entry.offset, entry.length, output); } static unsigned int dumpEntries(const FilterEntries& entries, FilterOutput* output) { unsigned int count = std::min(output->limit, entries.entryCount); for (unsigned int i = 0; i < count; ++i) processMatch(entries.entries[i], entries.buffer, output); return count; } template <typename Pred> static void filterRegex(const FilterEntries& entries, Regex* re, unsigned int limit, Pred pred) { const char* range = re->rangePrepare(entries.buffer, entries.bufferSize); const char* begin = range; const char* end = begin + entries.bufferSize; unsigned int matches = 0; while (RegexMatch match = re->rangeSearch(begin, end - begin)) { size_t matchOffset = match.data - range; // find first file entry with offset > matchOffset const FilterEntry* entry = std::upper_bound(entries.entries, entries.entries + entries.entryCount, matchOffset, [](size_t l, const FilterEntry& r) { return l < r.offset; }); // find last file entry with offset <= matchOffset assert(entry > entries.entries); entry--; // print match pred(entry - entries.entries); // move to next line const char* lend = findLineEnd(match.data + match.size, end); if (lend == end) break; begin = lend + 1; matches++; if (matches >= limit) break; } re->rangeFinalize(range); } static void processMatchHighlightRegex(Regex* re, FilterHighlightBuffer& hlbuf, const FilterEntry& entry, size_t offset, const char* buffer, FilterOutput* output) { const char* data = entry.offset + buffer; hlbuf.ranges.clear(); highlightRegex(hlbuf.ranges, re, data, entry.length, nullptr, offset); hlbuf.result.clear(); highlight(hlbuf.result, data, entry.length, hlbuf.ranges.empty() ? nullptr : &hlbuf.ranges[0], hlbuf.ranges.size(), kHighlightMatch); processMatch(hlbuf.result.c_str(), hlbuf.result.size(), output); } static unsigned int filterRegex(const FilterEntries& entries, const FilterEntries& matchEntries, const char* string, FilterOutput* output) { unsigned int result = 0; std::unique_ptr<Regex> re(createRegex(string, getRegexOptions(output->options))); FilterHighlightBuffer hlbuf; filterRegex(matchEntries, re.get(), output->limit, [&](unsigned int i) { const FilterEntry& e = entries.entries[i]; if (output->options & SO_HIGHLIGHT_MATCHES) processMatchHighlightRegex(re.get(), hlbuf, e, e.length - matchEntries.entries[i].length, entries.buffer, output); else processMatch(e, entries.buffer, output); result++; }); return result; } struct VisualAssistFragment { std::string text; std::unique_ptr<Regex> re; bool ispath; }; static void processMatchHighlightVisualAssist(const std::vector<VisualAssistFragment>& fragments, FilterHighlightBuffer& hlbuf, const FilterEntry& entry, const char* entryBuffer, const FilterEntry& nameEntry, const char* nameBuffer, FilterOutput* output) { const char* data = entryBuffer + entry.offset; hlbuf.ranges.clear(); for (auto& f: fragments) highlightRegex(hlbuf.ranges, f.re.get(), data, entry.length, nullptr, f.ispath ? 0 : entry.length - nameEntry.length); hlbuf.result.clear(); highlight(hlbuf.result, data, entry.length, hlbuf.ranges.empty() ? nullptr : &hlbuf.ranges[0], hlbuf.ranges.size(), kHighlightMatch); processMatch(hlbuf.result.c_str(), hlbuf.result.size(), output); } static unsigned int filterVisualAssist(const FilterEntries& entries, const FilterEntries& names, const char* string, FilterOutput* output) { std::vector<VisualAssistFragment> fragments; for (auto& s: split(string, isspace)) { fragments.emplace_back(); VisualAssistFragment& f = fragments.back(); f.text = s; f.re.reset(createRegex(s.c_str(), getRegexOptions(output->options | SO_LITERAL))); f.ispath = s.find_first_of("/\\") != std::string::npos; } if (fragments.empty()) return dumpEntries(entries, output); // sort name components first, path components last, larger components first std::sort(fragments.begin(), fragments.end(), [](const VisualAssistFragment& lhs, const VisualAssistFragment& rhs) { return (lhs.ispath != rhs.ispath) ? lhs.ispath < rhs.ispath : lhs.text.length() > rhs.text.length(); }); // gather files by first component std::vector<unsigned int> results; filterRegex(fragments[0].ispath ? entries : names, fragments[0].re.get(), (fragments.size() == 1) ? output->limit : ~0u, [&](unsigned int i) { results.push_back(i); }); // filter results by subsequent components for (size_t i = 1; i < fragments.size(); ++i) { const VisualAssistFragment& f = fragments[i]; results.erase(std::remove_if(results.begin(), results.end(), [&](unsigned int i) -> bool { const FilterEntries& matchEntries = f.ispath ? entries : names; const FilterEntry& me = matchEntries.entries[i]; return f.re->search(matchEntries.buffer + me.offset, me.length).size == 0; }), results.end()); } // trim results according to limit if (results.size() > output->limit) results.resize(output->limit); // output results FilterHighlightBuffer hlbuf; for (auto& i: results) { const FilterEntry& e = entries.entries[i]; if (output->options & SO_HIGHLIGHT_MATCHES) processMatchHighlightVisualAssist(fragments, hlbuf, e, entries.buffer, names.entries[i], names.buffer, output); else processMatch(e, entries.buffer, output); } return results.size(); } static void processMatchHighlightFuzzy(FuzzyMatcher& matcher, bool ranked, FilterHighlightBuffer& hlbuf, const FilterEntry& entry, const char* buffer, FilterOutput* output) { const char* data = buffer + entry.offset; assert(matcher.size() > 0); hlbuf.posbuf.resize(matcher.size()); if (ranked) matcher.rank(data, entry.length, &hlbuf.posbuf[0]); else matcher.match(data, entry.length, &hlbuf.posbuf[0]); hlbuf.ranges.resize(hlbuf.posbuf.size()); for (size_t i = 0; i < hlbuf.posbuf.size(); ++i) hlbuf.ranges[i] = std::make_pair(hlbuf.posbuf[i], 1); hlbuf.result.clear(); highlight(hlbuf.result, data, entry.length, hlbuf.ranges.empty() ? nullptr : &hlbuf.ranges[0], hlbuf.ranges.size(), kHighlightMatch); processMatch(hlbuf.result.c_str(), hlbuf.result.size(), output); } static unsigned int filterFuzzy(const FilterEntries& entries, const char* string, FilterOutput* output) { FuzzyMatcher matcher(string); typedef std::pair<int, const FilterEntry*> Match; std::vector<Match> matches; unsigned int perfectMatches = 0; for (size_t i = 0; i < entries.entryCount; ++i) { const FilterEntry& e = entries.entries[i]; const char* data = entries.buffer + e.offset; if (matcher.match(data, e.length)) { int score = matcher.rank(data, e.length); assert(score != INT_MAX); matches.push_back(std::make_pair(score, &e)); if (score == 0) { perfectMatches++; if (perfectMatches >= output->limit) break; } } } auto compareMatches = [](const Match& l, const Match& r) { return l.first == r.first ? l.second < r.second : l.first < r.first; }; if (matches.size() <= output->limit) std::sort(matches.begin(), matches.end(), compareMatches); else { std::partial_sort(matches.begin(), matches.begin() + output->limit, matches.end(), compareMatches); matches.resize(output->limit); } FilterHighlightBuffer hlbuf; for (auto& m: matches) { const FilterEntry& e = *m.second; if (output->options & SO_HIGHLIGHT_MATCHES) processMatchHighlightFuzzy(matcher, /* ranked= */ true, hlbuf, e, entries.buffer, output); else processMatch(e, entries.buffer, output); } return matches.size(); } static void buildNameBuffer(FilterEntries& names, const FilterEntries& entries, std::unique_ptr<FilterEntry[]>& entryptr, std::unique_ptr<char[]>& bufferptr) { // fill entries entryptr.reset(new FilterEntry[entries.entryCount]); names.entries = entryptr.get(); names.entryCount = entries.entryCount; size_t offset = 0; for (unsigned int i = 0; i < entries.entryCount; ++i) { const FilterEntry& e = entries.entries[i]; const char* path = entries.buffer + e.offset; const char* name = path + e.length; while (name > path && name[-1] != '/' && name[-1] != '\\') name--; FilterEntry& n = names.entries[i]; n.offset = offset; n.length = path + e.length - name; offset += n.length + 1; } // fill name buffer bufferptr.reset(new char[offset]); names.buffer = bufferptr.get(); names.bufferSize = offset; char* buffer = bufferptr.get(); for (unsigned int i = 0; i < entries.entryCount; ++i) { const FilterEntry& e = entries.entries[i]; const FilterEntry& n = names.entries[i]; memcpy(buffer + n.offset, entries.buffer + e.offset + e.length - n.length, n.length); buffer[n.offset + n.length] = '\n'; } } static const FilterEntries& getNameBuffer(const FilterEntries* namesOpt, FilterEntries& names, const FilterEntries& entries, std::unique_ptr<FilterEntry[]>& entryptr, std::unique_ptr<char[]>& bufferptr) { if (namesOpt) return *namesOpt; buildNameBuffer(names, entries, entryptr, bufferptr); return names; } unsigned int filter(Output* output_, const char* string, unsigned int options, unsigned int limit, const FilterEntries& entries, const FilterEntries* namesOpt) { assert(!namesOpt || namesOpt->entryCount == entries.entryCount); FilterEntries names = {}; std::unique_ptr<FilterEntry[]> nameEntries; std::unique_ptr<char[]> nameBuffer; FilterOutput output(output_, options, limit); if (*string == 0) return dumpEntries(entries, &output); else if (options & SO_FILE_NAMEREGEX) return filterRegex(entries, getNameBuffer(namesOpt, names, entries, nameEntries, nameBuffer), string, &output); else if (options & SO_FILE_PATHREGEX) return filterRegex(entries, entries, string, &output); else if (options & SO_FILE_VISUALASSIST) return filterVisualAssist(entries, getNameBuffer(namesOpt, names, entries, nameEntries, nameBuffer), string, &output); else if (options & SO_FILE_FUZZY) return filterFuzzy(entries, string, &output); else { output_->error("Unknown file search type\n"); return 0; } }
2164c1f6e58041652446736c023ecef97c85b29c
1addd3a7ba3cc0fe89b75d3d888c41487345cd2d
/C++Course/Access_Modifiers/Account.h
496935802581c941082a9553ee9e945b2a2e1909
[]
no_license
Nathraichean/Cpp-Discovery
51ad20b507b831df5d9e0101569de2949fa143e9
db5a122264d5b110b6bfa1811360fed40f511980
refs/heads/master
2022-11-30T13:42:21.954422
2020-08-13T07:45:18
2020-08-13T07:45:18
287,213,190
0
0
null
null
null
null
UTF-8
C++
false
false
315
h
#pragma once #include <string> class Account { private: std::string name; double balance; public: void set_balance(double bal) { balance = bal; }; double get_balance() { return balance; } void set_name(std::string n); std::string get_name(); bool deposit(double amount); bool withdraw(double amount); };
a367249ff3aba0f9137a0917d1de94ae938149d2
2a546fa1fdcdbb27cdc24d017f5cddfbd01dff4a
/CubeTestApp/Color2.cpp
244516ee8c825c6ffb54a06ef6fdbbc8d3b98bab
[]
no_license
1HappyTeddybear/exampleApplications
89dfb605fd1a92065a10a0ff01cf9192f30d2630
1e952134834cc8da485804353c26b6c664c7f5e5
refs/heads/master
2020-07-19T07:42:57.449077
2020-05-06T16:15:32
2020-05-06T16:15:32
206,404,482
1
0
null
2019-09-04T20:09:43
2019-09-04T20:09:43
null
UTF-8
C++
false
false
228
cpp
// // Created by WS on 06.05.2020. // #include "Color2.h" Color2::Color2() :Color(){} Color2::Color2(uint8_t brightness) :Color(brightness){} Color2::Color2(uint8_t red, uint8_t green, uint8_t blue) :Color(red, green, blue){}
96c0759690415a8e08d68b2798a0fd740c0d3eee
d0fb46aecc3b69983e7f6244331a81dff42d9595
/eflo/include/alibabacloud/eflo/model/UpdateErRequest.h
b784a5bfd72a88737d3b9fb83e60ca4690b2fd3f
[ "Apache-2.0" ]
permissive
aliyun/aliyun-openapi-cpp-sdk
3d8d051d44ad00753a429817dd03957614c0c66a
e862bd03c844bcb7ccaa90571bceaa2802c7f135
refs/heads/master
2023-08-29T11:54:00.525102
2023-08-29T03:32:48
2023-08-29T03:32:48
115,379,460
104
82
NOASSERTION
2023-09-14T06:13:33
2017-12-26T02:53:27
C++
UTF-8
C++
false
false
1,641
h
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ALIBABACLOUD_EFLO_MODEL_UPDATEERREQUEST_H_ #define ALIBABACLOUD_EFLO_MODEL_UPDATEERREQUEST_H_ #include <alibabacloud/eflo/EfloExport.h> #include <alibabacloud/core/RpcServiceRequest.h> #include <string> #include <vector> #include <map> namespace AlibabaCloud { namespace Eflo { namespace Model { class ALIBABACLOUD_EFLO_EXPORT UpdateErRequest : public RpcServiceRequest { public: UpdateErRequest(); ~UpdateErRequest(); std::string getErId() const; void setErId(const std::string &erId); std::string getDescription() const; void setDescription(const std::string &description); std::string getErName() const; void setErName(const std::string &erName); std::string getRegionId() const; void setRegionId(const std::string &regionId); private: std::string erId_; std::string description_; std::string erName_; std::string regionId_; }; } // namespace Model } // namespace Eflo } // namespace AlibabaCloud #endif // !ALIBABACLOUD_EFLO_MODEL_UPDATEERREQUEST_H_
14f856a93241e541af7989da11389b370d5cece2
52d0a310fe98cee5f843c60a87d743da03cb004c
/Surface.h
4e7aec89220fa966457507e36a4aec4c001912b3
[]
no_license
woodenToaster/kirpsquest
5bd7f03e7b24bcd68d376a124302e2305baa8bde
c76f2c1d414f79456b04aa6373c643af8c2619ed
refs/heads/master
2020-04-23T17:52:50.925149
2013-07-19T18:30:38
2013-07-19T18:30:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,319
h
/** @file Surface.h */ #ifndef KQ_SURFACE_H #define KQ_SURFACE_H #include "Common.h" #include "Drawable.h" #include "Rectangle.h" #include "SDL.h" #include "Color.h" /** @brief Finished */ class Surface: public Drawable { // low-level classes allowed to directly manipulate the internal SDL surface encapsulated friend class TextSurface; friend class VideoManager; friend class PixelBits; private: SDL_Surface* internal_surface; /**< the SDL_Surface encapsulated */ bool internal_surface_created; /**< indicates that internal_surface was allocated from this class */ uint32_t get_pixel32(int idx_pixel); SDL_Surface* get_internal_surface(); uint32_t get_mapped_pixel(int idx_pixel, SDL_PixelFormat* dst_format); protected: //virtual functions from Drawable void raw_draw(Surface& dst_surface, const Rectangle& dst_position); void raw_draw_region(const Rectangle& region, Surface& dst_surface, const Rectangle& dst_position); void draw_transition(Transition& transition); public: /** * @brief The base directory to use when opening image files. */ enum ImageDirectory { DIR_DATA, /**< the root directory of the data package */ DIR_SPRITES, /**< the sprites subdirectory of the data package (default) */ DIR_LANGUAGE /**< the language-specific image directory of the data package for the current language. */ }; Surface(int width = KQ_SCREEN_WIDTH, int height = KQ_SCREEN_HEIGHT); Surface(const Rectangle& size); Surface(const std::string& file_name, ImageDirectory base_directory = DIR_SPRITES); Surface(SDL_Surface* internal_surface); Surface(const Surface& other); ~Surface(); int get_width() const; int get_height() const; const Rectangle get_size() const; Color get_transparency_color(); void set_transparency_color(const Color& color); void set_opacity(int opacity); void set_clipping_rectangle(const Rectangle& clipping_rectangle = Rectangle()); void fill_with_color(Color& color); void fill_with_color(Color& color, const Rectangle& where); void draw_region(const Rectangle& src_position, Surface& dst_surface); void draw_region(const Rectangle& src_position, Surface& dst_surface, const Rectangle& dst_position); const std::string& get_lua_type_name() const; }; #endif
e49243e54ee5356fcca75bd9c73115fc8c0f4c20
6bdeefa16065fcad160c47c188c3de44ecaea6aa
/XJOI/1002/A/mk.cpp
e012b933710ffa97b280ae63b1140030a838d8fc
[]
no_license
DolaBMOon/CodeerStf
6fdbe830cab3d4e23035537ce0cbb6ef8d3a89cb
3ee7b66e1c28c48fae72a5f65a9b8270c41127da
refs/heads/master
2021-09-25T16:27:51.952473
2018-10-24T06:35:20
2018-10-24T06:35:20
146,592,777
0
0
null
null
null
null
UTF-8
C++
false
false
615
cpp
#include<cstdio> #include<cstring> #include<cassert> #include<iostream> #include<algorithm> using namespace std; #define Whats(x) cout<<#x<<" is "<<(x)<<endl #define DivHim() cout<<">>>>>>>>>>>>>>>"<<endl #define DivHer() cout<<"<<<<<<<<<<<<<<<"<<endl #define Oops() cout<<"!!!!!!!!!!!!!!!"<<endl template<typename T> bool GetMin(T &a,T b) { return ((a<=b)?false:(a=b,true)); } template<typename T> bool GetMax(T &a,T b) { return ((a>=b)?false:(a=b,true)); } /* -<Unlimited Blade Works>- */ int n,m; int G[N][N]; int main() { n=100; m=2500; cout<<n<<" "<<m<<endl; for(int i=1;i<=n;++i) return 0; }
b3bb2f44be39136c0c93753deff64adb0521f682
f140d489a1d5bb0e5221b7ef72b1b8d1441c7834
/thrift/compiler/test/fixtures/frozen-struct/gen-cpp2/module_metadata.cpp
8b7325ed33a3ca1016a80be6f5b00175a0aae166
[ "Apache-2.0" ]
permissive
terrorizer1980/fbthrift
aa9ebacfb97de312fc05a903d75dfe36fb48a6a3
9fe9e1ed327e9480e5aeb63d84cb5e00adf97b21
refs/heads/master
2023-04-10T19:11:13.606785
2020-08-16T05:10:56
2020-08-17T03:22:12
288,077,464
0
0
Apache-2.0
2023-04-04T00:05:10
2020-08-17T03:46:11
null
UTF-8
C++
false
false
4,030
cpp
/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ #include <thrift/lib/cpp2/gen/module_metadata_cpp.h> #include "thrift/compiler/test/fixtures/frozen-struct/gen-cpp2/module_metadata.h" namespace apache { namespace thrift { namespace detail { namespace md { using ThriftMetadata = ::apache::thrift::metadata::ThriftMetadata; using ThriftPrimitiveType = ::apache::thrift::metadata::ThriftPrimitiveType; using ThriftType = ::apache::thrift::metadata::ThriftType; using ThriftService = ::apache::thrift::metadata::ThriftService; using ThriftServiceContext = ::apache::thrift::metadata::ThriftServiceContext; using ThriftFunctionGenerator = void (*)(ThriftMetadata&, ThriftService&); void EnumMetadata<::some::ns::EnumB>::gen(ThriftMetadata& metadata) { auto res = metadata.enums.emplace("module.EnumB", ::apache::thrift::metadata::ThriftEnum{}); if (!res.second) { return; } ::apache::thrift::metadata::ThriftEnum& enum_metadata = res.first->second; enum_metadata.name = "module.EnumB"; using EnumTraits = TEnumTraits<::some::ns::EnumB>; for (std::size_t i = 0; i < EnumTraits::size; ++i) { enum_metadata.elements.emplace(static_cast<int32_t>(EnumTraits::values[i]), EnumTraits::names[i].str()); } } void StructMetadata<::some::ns::ModuleA>::gen(ThriftMetadata& metadata) { auto res = metadata.structs.emplace("module.ModuleA", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return; } ::apache::thrift::metadata::ThriftStruct& module_ModuleA = res.first->second; module_ModuleA.name = "module.ModuleA"; module_ModuleA.is_union = false; static const std::tuple<int32_t, const char*, bool, std::unique_ptr<MetadataTypeInterface>> module_ModuleA_fields[] = { std::make_tuple(1, "i32Field", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::make_tuple(2, "strField", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::make_tuple(3, "listField", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I16_TYPE))), std::make_tuple(4, "mapField", false, std::make_unique<Map>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE))), std::make_tuple(5, "inclAField", false, std::make_unique<Struct< ::some::ns::IncludedA>>("include1.IncludedA")), std::make_tuple(6, "inclBField", false, std::make_unique<Struct< ::some::ns::IncludedB>>("include2.IncludedB")), }; for (const auto& f : module_ModuleA_fields) { ::apache::thrift::metadata::ThriftField field; field.id = std::get<0>(f); field.name = std::get<1>(f); field.is_optional = std::get<2>(f); std::get<3>(f)->writeAndGenType(field.type, metadata); module_ModuleA.fields.push_back(std::move(field)); } } void StructMetadata<::some::ns::ModuleB>::gen(ThriftMetadata& metadata) { auto res = metadata.structs.emplace("module.ModuleB", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return; } ::apache::thrift::metadata::ThriftStruct& module_ModuleB = res.first->second; module_ModuleB.name = "module.ModuleB"; module_ModuleB.is_union = false; static const std::tuple<int32_t, const char*, bool, std::unique_ptr<MetadataTypeInterface>> module_ModuleB_fields[] = { std::make_tuple(1, "i32Field", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::make_tuple(2, "inclEnumB", false, std::make_unique<Enum< ::some::ns::EnumB>>("module.EnumB")), }; for (const auto& f : module_ModuleB_fields) { ::apache::thrift::metadata::ThriftField field; field.id = std::get<0>(f); field.name = std::get<1>(f); field.is_optional = std::get<2>(f); std::get<3>(f)->writeAndGenType(field.type, metadata); module_ModuleB.fields.push_back(std::move(field)); } } } // namespace md } // namespace detail } // namespace thrift } // namespace apache
7d07aa390f97d3772b6997a7bf0fedc3baf84d6a
4c4c3fdcf8fd6db9412a97e5d006f6e5ae773938
/Mandelbrot/complex.h
00d91c8a45763215f6ebdcbe8a230854823c2801
[]
no_license
Sven-yarsh/Mandelbrot
ff1fc07e7d79a3f17b595184c99b82815cc452e3
1575ff952a4508be9bd79c6d65043ef88d4115cd
refs/heads/master
2020-04-17T08:56:55.385719
2016-09-05T18:23:26
2016-09-05T18:23:26
67,285,442
0
0
null
null
null
null
UTF-8
C++
false
false
1,289
h
#pragma once // TODO: // const complex& z //using namespace std; class complex { public: double real; double imag; complex() {} complex(double a, double b) : real(a), imag(b) {} complex operator+ (complex z) { complex result; result.real = real + z.real; result.imag = imag + z.imag; return result; } complex operator- (complex z) { complex result; result.real = real - z.real; result.imag = imag - z.imag; return result; } complex operator* (complex z) { complex result; result.real = real*z.real - imag*z.imag; result.imag = real*z.imag + imag*z.real; return result; } complex operator= (complex z) { real = z.real; imag = z.imag; return *this; } //complex negate(complex& z) { // z.real = -z.real; // z.imag = -z.imag; // return z; //} complex conj() { imag = -imag; return *this; } double sq_len() { return real*real + imag*imag; } }; //int main2() { // complex z1 = { 1, 2 }; // complex z2 = { 3, 8 }; // complex z; // z = z1 * z2; // cout << "hello\n" << z.real << " " << z.imag << '\n'; // z1.negate(z); // cout << "hello\n" << z.real << " " << z.imag << '\n'; // return 0; //}
7ea205773c2bb578d1aa745fe67f2aa52ef73fe4
5ef02af85412d3ce490003b6410dfed91e9a73ad
/test/c++/g0_checks.cpp
a1bcc4fc7c7b94bbb76e2bd7e162a9b3c45a59ea
[]
no_license
amoutenet/QMC_LO_basis
a094083dd609b74efd872e07d70f5ca25285d2e0
9c194ed4314812bae3e9574c5437c4dacb053b29
refs/heads/master
2022-12-09T12:16:10.156399
2020-09-09T10:01:27
2020-09-09T10:01:27
294,068,617
2
0
null
null
null
null
UTF-8
C++
false
false
723
cpp
#include <iostream> #include <triqs/test_tools/gfs.hpp> #include "g0_semi_circ.hpp" using namespace triqs::gfs; TEST(Ctdet_LO, g0_checks) { mpi::communicator world; std::pair<gf<refreq>, gf<refreq>> g0 = make_g0_semi_circular(10, 0.5 * 0.5, 100, 1000, 0.2); // Save the results if (world.rank() == 0) { triqs::h5::file G_file("g0_checks.out.h5", 'w'); h5_write(G_file, "G_R", std::get<0>(g0)); h5_write(G_file, "G_K", std::get<1>(g0)); } gf<refreq> g_r; gf<refreq> g_k; if (world.rank() == 0) { triqs::h5::file G_file("g0_checks.ref.h5", 'r'); h5_read(G_file, "G_R", g_r); h5_read(G_file, "G_K", g_k); EXPECT_GF_NEAR(std::get<0>(g0), g_r); EXPECT_GF_NEAR(std::get<1>(g0), g_k); } } MAKE_MAIN
5aec1f7c1c72845e92f826ef0fa2ee5da2653b4d
66873135f86c300d4e362b33f5387b147d66c20f
/src/leapserial/IArchiveImplV0.cpp
b71d770947a556a1e1d03890780012f4ca080502
[ "Apache-2.0" ]
permissive
gabrielPeart/leapserial
2f0bf6ebb440788d1f8791700dd57a3c3c52330e
ae86dcc3057e409ff13a8e1ca3c399a8d109917c
refs/heads/master
2021-01-16T22:44:49.072808
2016-02-10T21:02:58
2016-02-10T21:02:58
52,526,282
2
0
null
2016-02-25T13:29:26
2016-02-25T13:29:25
null
UTF-8
C++
false
false
788
cpp
// Copyright (C) 2012-2015 Leap Motion, Inc. All rights reserved. #include "stdafx.h" #include "IArchiveImplV0.h" #include "field_serializer.h" #include "serial_traits.h" #include "ProtobufType.h" #include "Utility.hpp" #include <iostream> #include <sstream> using namespace leap; IArchiveImplV0::IArchiveImplV0(IInputStream& is) : IArchiveImpl(is) { } IArchiveImplV0::IArchiveImplV0(std::istream& is) : IArchiveImpl(is) {} void IArchiveImplV0::ReadArray(IArrayAppender&& ary) { // Read the number of entries first: uint32_t nEntries; ReadByteArray(&nEntries, sizeof(nEntries)); ary.reserve(nEntries); // Now loop until we get the desired number of entries from the stream for (size_t i = 0; i < nEntries; i++) ary.serializer.deserialize(*this, ary.allocate(), 0); }
9abb8a28b7307134077825d1b0ee1f6f85ce1cc9
7c27fa97a0c4603dd86c5d960cce5d101368f15a
/sc_main.cpp
889efd5d8775cd63e13c3d7fc8498705d804511c
[]
no_license
ckaanakyol/pagerank
47e32c63fb08f45ff451f5b525f8dcd76e5891f4
55ed60b675d5dd7f4764c6ef717c58101835fa9c
refs/heads/master
2021-05-06T17:24:53.726256
2019-06-24T13:47:50
2019-06-24T13:47:50
111,830,196
0
0
null
null
null
null
UTF-8
C++
false
false
1,906
cpp
#include "systemc.h" #include "soa_struct.h" #include "VtxDataRequester.cpp" #include "VtxDataResponder.cpp" #include <vector> //extern struct VertexTable vertexTable; //extern int rownum; int rownum = 16; VertexTable vt; int sc_main(int argc, char* argv[]) { //rownum = 16; cout << "\n\nInitializing VertexTable............\n"; vt.initVertexTable(); printf("%d\n", vt.vid[0]); vt.vid[0] = 11000; printf("%d\n", vt.vid[0]); cout << "\n\nCreating Modules............\n"; VtxDataRequester vdreq("vdreq"); VtxDataResponder vdres("vdres"); sc_signal<double> ScaledRank{"scaledrank"}; sc_signal<double> OneOverInDegree{"oneoverindegree"}; sc_signal<int> NeighCount{"neighcount"}; sc_signal<int> StartIndex{"startindex"}; sc_signal<int> InEdgeCount{"inedgecount"}; sc_signal<int> OutEdgeCount{"outedgecount"}; sc_signal<int> VertexData{"vertexdata"}; sc_signal<int> RespondID{"respondid"}; sc_signal<int> inID{"inid"}; //Comes from outside sc_signal<int> requestID{"requestID"}; //request sc_signal<int> rowId{"rowid"}; sc_clock clk; vdreq.ScaledRank(ScaledRank); vdreq.OneOverInDegree(OneOverInDegree); vdreq.NeighCount(NeighCount); vdreq.StartIndex(StartIndex); vdreq.InEdgeCount(InEdgeCount); vdreq.OutEdgeCount(OutEdgeCount); vdreq.VertexData(VertexData); vdreq.RespondID(RespondID); vdreq.inID(inID); vdreq.requestID(requestID); vdreq.rowId(rowId); vdreq.Port_CLK(clk); vdres.ScaledRank(ScaledRank); vdres.OneOverInDegree(OneOverInDegree); vdres.NeighCount(NeighCount); vdres.StartIndex(StartIndex); vdres.InEdgeCount(InEdgeCount); vdres.OutEdgeCount(OutEdgeCount); vdres.VertexData(VertexData); vdres.Out_Id(RespondID); vdres.Port_CLK(clk); vdres.In_Id(requestID); sc_start(50000, SC_PS); for (int i = 0 ; i < 9; ++i) std::cout << vt.vid[i] << ' '; return 0; }
751b1c0a46eb6bd0604d31fac9ec940eee7f3850
244307b25f80400bfd1a19def6bd5e8ab29673a3
/l-r-values/main.cpp
67824500cd3cc49da163a41fc5d0102e2ddb6dd3
[]
no_license
yay/cpp
e2ac32577b046dbe28e1f8969a6f8b9f285ceb7c
fcfa6916e957f3bb548a0d437890169588830b9c
refs/heads/master
2023-01-24T18:27:14.767080
2020-12-06T20:17:46
2020-12-06T20:17:46
267,719,760
0
0
null
null
null
null
UTF-8
C++
false
false
1,960
cpp
#include <iostream> auto getRvalue() -> int { return 10; } auto getLvalueReference() -> int & { static int value = 10; return value; } // It's best to make the name a const reference, so that the function // could take both lvalue AND rvalue references as parameters. // As it is, the function only accepts lvalue references. void print_lvalue_name(std::string &name) { std::cout << name << std::endl; } // This function only accepts rvalue references. void print_rvalue_name(std::string &&name) { std::cout << name << std::endl; } void print_name(std::string &name) { std::cout << "lvalue: " << name << std::endl; } // An overloaded function like this gives us the ability to detect temporary // values and do something with them. This is very useful for move semantics. void print_name(std::string &&name) { std::cout << "rvalue: " << name << std::endl; } auto main() -> int { // i is an lvalue // 10 is an rvalue // can't assign to a temporary value 10 int i = 10; int j = getRvalue(); getLvalueReference() = 5; std::cout << getLvalueReference() << std::endl; // 5 // can't take an lvalue reference from an rvalue: // int &a = 10; // error: initial value of reference to non-const must be an // lvalue const int &a = 10; // valid, the compiler is probably creating a temp var to put 10 // into under the hood, then gets a reference of that std::string first_name = "Vitaly"; std::string last_name = "Kravchenko"; // print_lvalue_name(first_name + last_name); // error: first_name + // last_name is an rvalue print_rvalue_name(first_name + last_name); // works // print_rvalue_name(first_name); // error: an rvalue reference cannot be // bound to an lvalue print_name(first_name); // lvalue: Vitaly print_name(first_name + last_name); // rvalue: VitalyKravchenko print_name("hello"); // rvalue: hello }
b433eb5c3042a7ae989da22f2e10e05b1e75d4e1
ad30e314cd917671330cd71ee412d0ae7e2ab949
/engine.h
d2c6a0f57706aabb8bd2cbd3466e0e1b2174b1a6
[]
no_license
bgibers/2DFinal
019793597291ce9a26a085b1cdffbf3911178b91
df77cc98ac1965a397722b30aa3fb0b33188e93e
refs/heads/master
2021-01-19T22:23:36.743731
2017-04-28T21:22:35
2017-04-28T21:22:35
88,806,932
0
0
null
null
null
null
UTF-8
C++
false
false
1,137
h
#include <vector> #include <SDL.h> //#include "ioMod.h" #include "renderContext.h" //#include "clock.h" #include "hud.h" #include "world.h" #include "viewport.h" #include "player.h" #include "multisprite.h" #include "smartSprite.h" #include "sound.h" class CollisionStrategy; class Engine { public: Engine (); ~Engine (); void play(); void switchSprite(); void checkForCollisions(); int getDeathcnt() const {return deathCount;} private: const RenderContext* rc; const IOmod& io; Clock& clock; Hud& hud; SDLSound& sound; SDL_Renderer * const renderer; World mtns; World mid; World sand; Player player; Player sit; MultiSprite dad; SmartSprite follower; Viewport& viewport; std::vector<Drawable*> sprites; std::vector<Drawable*> wildabeasts; std::vector<Drawable*> playerSprites; std::vector<Drawable*> smartSprites; int currentSprite; bool makeVideo; CollisionStrategy* strategy; int deathCount; bool godMode; bool gameOver; void draw() const; void update(Uint32); void reset(); Engine(const Engine&) = delete; Engine& operator=(const Engine&) = delete; };
b5ccda257eb28bb4fbeb4ec464e80131d5901bbf
2cb5646fdded8ea162fce7c171eb891d9a9495ac
/exportNF/release/windows/obj/src/flixel/ui/FlxSpriteButton.cpp
15ae4ea70a139bb0870759a92efe2012578a1d14
[ "BSD-3-Clause" ]
permissive
roythearsonist/NekoFreakMod-FridayNightFunkin
89b815177c82ef21e09d81268fb8aeff0e8baf01
232bcb08234cfe881fd6d52b13e6ae443e105fd1
refs/heads/main
2023-04-23T08:22:18.886103
2021-05-17T07:13:05
2021-05-17T07:13:05
null
0
0
null
null
null
null
UTF-8
C++
false
true
8,473
cpp
// Generated by Haxe 4.2.1+bf9ff69 #include <hxcpp.h> #ifndef INCLUDED_flixel_FlxBasic #include <flixel/FlxBasic.h> #endif #ifndef INCLUDED_flixel_FlxG #include <flixel/FlxG.h> #endif #ifndef INCLUDED_flixel_FlxObject #include <flixel/FlxObject.h> #endif #ifndef INCLUDED_flixel_FlxSprite #include <flixel/FlxSprite.h> #endif #ifndef INCLUDED_flixel_graphics_FlxGraphic #include <flixel/graphics/FlxGraphic.h> #endif #ifndef INCLUDED_flixel_graphics_frames_FlxFramesCollection #include <flixel/graphics/frames/FlxFramesCollection.h> #endif #ifndef INCLUDED_flixel_graphics_frames_FlxImageFrame #include <flixel/graphics/frames/FlxImageFrame.h> #endif #ifndef INCLUDED_flixel_input_IFlxInput #include <flixel/input/IFlxInput.h> #endif #ifndef INCLUDED_flixel_math_FlxPoint #include <flixel/math/FlxPoint.h> #endif #ifndef INCLUDED_flixel_math_FlxRect #include <flixel/math/FlxRect.h> #endif #ifndef INCLUDED_flixel_system_frontEnds_BitmapFrontEnd #include <flixel/system/frontEnds/BitmapFrontEnd.h> #endif #ifndef INCLUDED_flixel_text_FlxText #include <flixel/text/FlxText.h> #endif #ifndef INCLUDED_flixel_text_FlxTextBorderStyle #include <flixel/text/FlxTextBorderStyle.h> #endif #ifndef INCLUDED_flixel_ui_FlxSpriteButton #include <flixel/ui/FlxSpriteButton.h> #endif #ifndef INCLUDED_flixel_ui_FlxTypedButton_flixel_FlxSprite #include <flixel/ui/FlxTypedButton_flixel_FlxSprite.h> #endif #ifndef INCLUDED_flixel_util_IFlxDestroyable #include <flixel/util/IFlxDestroyable.h> #endif #ifndef INCLUDED_flixel_util_IFlxPooled #include <flixel/util/IFlxPooled.h> #endif #ifndef INCLUDED_openfl_display_BitmapData #include <openfl/display/BitmapData.h> #endif #ifndef INCLUDED_openfl_display_IBitmapDrawable #include <openfl/display/IBitmapDrawable.h> #endif HX_DEFINE_STACK_FRAME(_hx_pos_222d410d6e05a421_26_new,"flixel.ui.FlxSpriteButton","new",0xdb67b173,"flixel.ui.FlxSpriteButton.new","flixel/ui/FlxSpriteButton.hx",26,0x7f25dbfd) HX_LOCAL_STACK_FRAME(_hx_pos_222d410d6e05a421_46_createTextLabel,"flixel.ui.FlxSpriteButton","createTextLabel",0xb0bc08fe,"flixel.ui.FlxSpriteButton.createTextLabel","flixel/ui/FlxSpriteButton.hx",46,0x7f25dbfd) namespace flixel{ namespace ui{ void FlxSpriteButton_obj::__construct(::hx::Null< Float > __o_X,::hx::Null< Float > __o_Y, ::flixel::FlxSprite Label, ::Dynamic OnClick){ Float X = __o_X.Default(0); Float Y = __o_Y.Default(0); HX_STACKFRAME(&_hx_pos_222d410d6e05a421_26_new) HXLINE( 27) super::__construct(X,Y,OnClick); HXLINE( 29) { HXLINE( 29) int _g = 0; HXDLIN( 29) ::Array< ::Dynamic> _g1 = this->labelOffsets; HXDLIN( 29) while((_g < _g1->length)){ HXLINE( 29) ::flixel::math::FlxPoint point = _g1->__get(_g).StaticCast< ::flixel::math::FlxPoint >(); HXDLIN( 29) _g = (_g + 1); HXLINE( 30) point->set((point->x - ( (Float)(1) )),(point->y + 4)); } } HXLINE( 32) this->set_label(Label); } Dynamic FlxSpriteButton_obj::__CreateEmpty() { return new FlxSpriteButton_obj; } void *FlxSpriteButton_obj::_hx_vtable = 0; Dynamic FlxSpriteButton_obj::__Create(::hx::DynamicArray inArgs) { ::hx::ObjectPtr< FlxSpriteButton_obj > _hx_result = new FlxSpriteButton_obj(); _hx_result->__construct(inArgs[0],inArgs[1],inArgs[2],inArgs[3]); return _hx_result; } bool FlxSpriteButton_obj::_hx_isInstanceOf(int inClassId) { if (inClassId<=(int)0x596ee395) { if (inClassId<=(int)0x2c01639b) { if (inClassId<=(int)0x19c9b491) { return inClassId==(int)0x00000001 || inClassId==(int)0x19c9b491; } else { return inClassId==(int)0x2c01639b; } } else { return inClassId==(int)0x596ee395; } } else { return inClassId==(int)0x7ccf8994 || inClassId==(int)0x7dab0655; } } static ::flixel::input::IFlxInput_obj _hx_flixel_ui_FlxSpriteButton__hx_flixel_input_IFlxInput= { ( bool (::hx::Object::*)())&::flixel::ui::FlxSpriteButton_obj::get_justReleased, ( bool (::hx::Object::*)())&::flixel::ui::FlxSpriteButton_obj::get_released, ( bool (::hx::Object::*)())&::flixel::ui::FlxSpriteButton_obj::get_pressed, ( bool (::hx::Object::*)())&::flixel::ui::FlxSpriteButton_obj::get_justPressed, }; void *FlxSpriteButton_obj::_hx_getInterface(int inHash) { switch(inHash) { case (int)0x52baf533: return &_hx_flixel_ui_FlxSpriteButton__hx_flixel_input_IFlxInput; } return super::_hx_getInterface(inHash); } ::flixel::ui::FlxSpriteButton FlxSpriteButton_obj::createTextLabel(::String Text,::String font,::hx::Null< int > __o_size,::hx::Null< int > __o_color,::String __o_align){ int size = __o_size.Default(8); int color = __o_color.Default(3355443); ::String align = __o_align; if (::hx::IsNull(__o_align)) align = HX_("center",d5,25,db,05); HX_GC_STACKFRAME(&_hx_pos_222d410d6e05a421_46_createTextLabel) HXLINE( 47) if (::hx::IsNotNull( Text )) { HXLINE( 49) ::flixel::text::FlxText text = ::flixel::text::FlxText_obj::__alloc( HX_CTX ,0,0,this->frameWidth,Text,null(),null()); HXLINE( 50) text->setFormat(font,size,color,align,null(),null(),null()); HXLINE( 51) text->set_alpha(this->labelAlphas->__get(this->status)); HXLINE( 52) text->drawFrame(true); HXLINE( 53) ::openfl::display::BitmapData labelBitmap = text->graphic->bitmap->clone(); HXLINE( 54) ::String labelKey = text->graphic->key; HXLINE( 55) text->destroy(); HXLINE( 57) if (::hx::IsNull( this->label )) { HXLINE( 58) this->set_label( ::flixel::FlxSprite_obj::__alloc( HX_CTX ,null(),null(),null())); } HXLINE( 60) ::flixel::graphics::FlxGraphic labelGraphic = ::flixel::FlxG_obj::bitmap->add(labelBitmap,false,labelKey); HXLINE( 61) ::flixel::FlxSprite _hx_tmp = this->label; HXDLIN( 61) _hx_tmp->set_frames(::flixel::graphics::frames::FlxImageFrame_obj::fromGraphic(labelGraphic,null())); } HXLINE( 64) return ::hx::ObjectPtr<OBJ_>(this); } HX_DEFINE_DYNAMIC_FUNC5(FlxSpriteButton_obj,createTextLabel,return ) ::hx::ObjectPtr< FlxSpriteButton_obj > FlxSpriteButton_obj::__new(::hx::Null< Float > __o_X,::hx::Null< Float > __o_Y, ::flixel::FlxSprite Label, ::Dynamic OnClick) { ::hx::ObjectPtr< FlxSpriteButton_obj > __this = new FlxSpriteButton_obj(); __this->__construct(__o_X,__o_Y,Label,OnClick); return __this; } ::hx::ObjectPtr< FlxSpriteButton_obj > FlxSpriteButton_obj::__alloc(::hx::Ctx *_hx_ctx,::hx::Null< Float > __o_X,::hx::Null< Float > __o_Y, ::flixel::FlxSprite Label, ::Dynamic OnClick) { FlxSpriteButton_obj *__this = (FlxSpriteButton_obj*)(::hx::Ctx::alloc(_hx_ctx, sizeof(FlxSpriteButton_obj), true, "flixel.ui.FlxSpriteButton")); *(void **)__this = FlxSpriteButton_obj::_hx_vtable; __this->__construct(__o_X,__o_Y,Label,OnClick); return __this; } FlxSpriteButton_obj::FlxSpriteButton_obj() { } ::hx::Val FlxSpriteButton_obj::__Field(const ::String &inName,::hx::PropertyAccess inCallProp) { switch(inName.length) { case 15: if (HX_FIELD_EQ(inName,"createTextLabel") ) { return ::hx::Val( createTextLabel_dyn() ); } } return super::__Field(inName,inCallProp); } #ifdef HXCPP_SCRIPTABLE static ::hx::StorageInfo *FlxSpriteButton_obj_sMemberStorageInfo = 0; static ::hx::StaticInfo *FlxSpriteButton_obj_sStaticStorageInfo = 0; #endif static ::String FlxSpriteButton_obj_sMemberFields[] = { HX_("createTextLabel",6b,57,91,a9), ::String(null()) }; ::hx::Class FlxSpriteButton_obj::__mClass; void FlxSpriteButton_obj::__register() { FlxSpriteButton_obj _hx_dummy; FlxSpriteButton_obj::_hx_vtable = *(void **)&_hx_dummy; ::hx::Static(__mClass) = new ::hx::Class_obj(); __mClass->mName = HX_("flixel.ui.FlxSpriteButton",01,7c,d7,41); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &::hx::Class_obj::GetNoStaticField; __mClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField; __mClass->mStatics = ::hx::Class_obj::dupFunctions(0 /* sStaticFields */); __mClass->mMembers = ::hx::Class_obj::dupFunctions(FlxSpriteButton_obj_sMemberFields); __mClass->mCanCast = ::hx::TCanCast< FlxSpriteButton_obj >; #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = FlxSpriteButton_obj_sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = FlxSpriteButton_obj_sStaticStorageInfo; #endif ::hx::_hx_RegisterClass(__mClass->mName, __mClass); } } // end namespace flixel } // end namespace ui