blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
cc422acda0dca587f4f1930417bd0c57132034d8
f608a08bb7a238e26e6335335fa8b1e065d8d7ef
/Open62541CppWrapper/MVC/AbstractModelObserver.hh
8a47d221bb732d1c5068f29ce4ba6d6eafa28438
[ "BSD-3-Clause" ]
permissive
Servicerobotics-Ulm/Open62541CppWrapper
fb93c612b322bb658e5f0fb749e45b536a0cf421
710d3bb76c82d6ae3d4707a2785236eb6924770f
refs/heads/master
2021-07-05T18:42:19.616089
2020-10-30T08:55:28
2020-10-30T08:55:28
200,660,396
5
4
BSD-3-Clause
2019-09-09T07:41:57
2019-08-05T13:26:27
C++
UTF-8
C++
false
false
1,556
hh
AbstractModelObserver.hh
//-------------------------------------------------------------------------- // Code generated by the SmartSoft MDSD Toolchain // The SmartSoft Toolchain has been developed by: // // Service Robotics Research Center // University of Applied Sciences Ulm // Prittwitzstr. 10 // 89075 Ulm (Germany) // // Information about the SmartSoft MDSD Toolchain is available at: // www.servicerobotik-ulm.de // // Please do not modify this file. It will be re-generated // running the code generator. //-------------------------------------------------------------------------- #ifndef ABSTRACTMODELOBSERVER_H_ #define ABSTRACTMODELOBSERVER_H_ #include "AbstractModel.hh" namespace Smart { // forward declaration class AbstractModel; /** * This class defines the abstract base-class for the ModelObserver part * of the Model-View-Controller (MVC) design pattern. From this class, * the View and the Controller classes are derived. The abstract method * update() must implement the respective update strategy of the derived class. */ class AbstractModelObserver { protected: AbstractModel *model; public: /** * Default constructor attaches this class * to the given model (in case the model is not null). */ AbstractModelObserver(AbstractModel *model=0); /** * Default destructor detaches this class from the * internal model (in case the model is not null). */ virtual ~AbstractModelObserver(); /// implement this method in derived classes virtual void update() = 0; }; } /* namespace Smart */ #endif /* ABSTRACTMODELOBSERVER_H_ */
a76ed9d9c78e9484c3db4562cc93c827ad798581
630e9438530e5b15353cc9b7c013889fa0f7e80d
/C++/CS1580/Lab10/lab10_functions.cpp
9e3e7702679cd5e61d5a0483634219d8241a91da
[]
no_license
dmgardiner25/CS-Classes
0402c1d04c4d3cc50a91d7f1d27a7b7d291f0c5e
b6eaa2101db532ab986aefb48e531308d795d4bd
refs/heads/master
2021-06-02T07:44:32.878122
2017-11-01T16:13:04
2017-11-01T16:13:04
80,837,900
0
0
null
null
null
null
UTF-8
C++
false
false
1,107
cpp
lab10_functions.cpp
/* Programmer: David Gardiner, 12447993 Instructor: Rushiraj Section: E Date: 10/26/16 File: lab10_functions.cpp Description: Function defintions to encrypt a given name using an NTCA. */ #include <iostream> #include <cctype> #include "lab10.h" using namespace std; void greeting() { cout << "Welcome to the Enigma Machine 2.0, now with less security!" << endl; return; } void getInput(char arr[]) { cout << "\n\nEnter your name: "; cin.getline(arr, DATA_SIZE-1); return; } void encrypt(char arr[]) { bool nullFound = false; short i = 0; short ASCIIVal; while(!nullFound) { ASCIIVal = arr[i]; if(arr[i] == 0) nullFound = true; else if(isalpha(arr[i])) { if(isupper(ASCIIVal) && ASCIIVal < 88) arr[i] = ASCIIVal + 3; else if(islower(ASCIIVal) && ASCIIVal < 120) arr[i] = ASCIIVal + 3; else arr[i] = ASCIIVal - 23; } i++; } return; } void showOutput(char arr[]) { cout << arr << endl; return; } void signoff() { cout << "\n\nThank you for using the budget Enigma Machine!" << endl; return; }
cd80f42b9bca7630bc5a37d38c3c05ccb050344c
88bb5d5d01507cdab698087f03b669ec2f336663
/base/queue/queue_dic_comm.h
6c30cfc2d054e9047480c8bcd79ddda9f1e7da8b
[]
no_license
flaght/mylib
419d246e2d8e9b8acbc9a607d236cb2c2c32eb2c
389d61e76ee8a9ca4eaad86421bed86a6bc8a97f
refs/heads/master
2021-06-18T17:21:00.207043
2019-07-14T06:16:21
2019-07-14T06:16:21
51,120,734
0
3
null
2017-08-21T08:41:12
2016-02-05T02:21:52
C++
UTF-8
C++
false
false
678
h
queue_dic_comm.h
/* * queue_dic_comm.h * * Created on: 2015年1月3日 * Author: kerry */ #ifndef QUEUE_DIC_COMM_H_ #define QUEUE_DIC_COMM_H_ #include "config/config_info.h" #include <list> namespace base_queue{ class QueueDicComm{ public: QueueDicComm(); ~QueueDicComm(); public: static void Init(std::list<base::ConnAddr>& addrlist); static void Dest(); public: static bool AddBlockQueueMessage(const std::string& key,const std::string& str); static bool GetBlockQueueMessage(const std::string& key,std::list<std::string>& list, const int32 count = 1); static bool GetBlockQueueMessage(const std::string& key,std::string& str); }; } #endif /* QUEUE_DIC_COMM_H_ */
2f68729d1f5ac17fa588c0dc2ce4115ba7e466a7
d8f7532fea9ccc4276cd22544b6da28d769d1158
/Relay.h
a05aa66c2ee8b29d47c793554f8c3c5d696666e0
[]
no_license
nikuz/ivy-esp32
58cbc2859c19a6c2a7d59418bec0122bbb6eeb20
9d68469a6b42be4c3aabcca08028401780bddaba
refs/heads/master
2020-05-30T17:56:54.156892
2020-05-17T16:49:46
2020-05-17T16:49:46
189,886,805
0
0
null
null
null
null
UTF-8
C++
false
false
439
h
Relay.h
#ifndef Relay_h #define Relay_h #include <Arduino.h> class Relay { public: Relay(); ~Relay(); static void parseSerialCommand(const char *command, const char *param); // heating static bool isHeatingEnabled(); static void heatingOn(); static void heatingOff(); // watering static bool isWateringEnabled(); static void wateringOn(); static void wateringOff(); }; #endif /* Relay_h */
66e450438705d7aafdd08a735c8c9355300d8b50
a49df76344a106c8e6cf7badf3d2ee5d0f203c05
/oldone/client/getViewer.cpp
d3cf33bf161afdcf2f5b263d6631cdd183721575
[]
no_license
wangfeilong321/osgSystem
a5c2b5e08660255087cd4da5464c9b3ad7e07071
c47e2be610353545e167ad8c043adcf7b661c22a
refs/heads/master
2020-06-20T20:59:14.731227
2016-09-19T07:55:22
2016-09-19T07:55:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,970
cpp
getViewer.cpp
#include "client.h" using namespace std; bool return_flag = false; PickHandler::PickHandler(int *sockfd) { client_sockfd = sockfd; } float * PickHandler::getpickArray() { return pickArray; } void PickHandler::getMessage() { /*if(pickArray[0] != 16) { for(int i=0;i<5;i++) { cout<<pickArray[i]<< " "; } cout << endl; } */ /* if(pickArray[0] == 32 | pickArray[0]) { printf("Esc pressed! : 65307\n"); } */ if(pickArray[1] == ESCAPE_NUM) return_flag = true; char recvMsg[BUFFER_SIZE]; send(*client_sockfd , (char *)&pickArray , sizeof(pickArray) , 0); recv(*client_sockfd , recvMsg , sizeof(recvMsg) , 0); printf("%s\n" , recvMsg); } bool PickHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) { osgViewer::Viewer *viewer = dynamic_cast<osgViewer::Viewer*>(&aa); if(!viewer) return false; switch(ea.getEventType()) { case(osgGA::GUIEventAdapter::KEYDOWN): { pickArray[0]=osgGA::GUIEventAdapter::KEYDOWN; pickArray[1]=ea.getKey(); pickArray[2]=(ea.getXmin()+ea.getXmax())*0.5; pickArray[3]=(ea.getYmin()+ea.getYmax())*0.5; getMessage(); return false; break; } case(osgGA::GUIEventAdapter::KEYUP): { pickArray[0]=osgGA::GUIEventAdapter::KEYUP; pickArray[1]=ea.getKey(); pickArray[2]=(ea.getXmin()+ea.getXmax())*0.5; pickArray[3]=(ea.getYmin()+ea.getYmax())*0.5; getMessage(); return false; break; } case(osgGA::GUIEventAdapter::RESIZE): { pickArray[0]=ea.getEventType(); pickArray[1]=0; pickArray[2]=ea.getWindowWidth(); pickArray[3]=ea.getWindowHeight(); getMessage(); return true; break; } case(osgGA::GUIEventAdapter::CLOSE_WINDOW): { pickArray[0]=ea.getEventType(); pickArray[1]=0; pickArray[2]=0; pickArray[3]=0; getMessage(); return true; break; } case(osgGA::GUIEventAdapter::QUIT_APPLICATION): { pickArray[0]=ea.getEventType(); pickArray[1]=0; pickArray[2]=0; pickArray[3]=0; getMessage(); return true; break; } case(osgGA::GUIEventAdapter::FRAME): { pickArray[0]=ea.getEventType(); pickArray[1]=0; pickArray[2]=0; pickArray[3]=0; pickArray[4]=ea.getTime(); return true; break; } case(osgGA::GUIEventAdapter::PEN_PRESSURE): { pickArray[0]=ea.getEventType(); pickArray[1]=ea.getPenPressure(); pickArray[2]=0; pickArray[3]=0; pickArray[4]=ea.getTime(); return true; break; } case(osgGA::GUIEventAdapter::PEN_ORIENTATION): { pickArray[0]=ea.getEventType(); pickArray[1]=ea.getPenRotation(); pickArray[2]=ea.getPenTiltX(); pickArray[3]=ea.getPenTiltY(); pickArray[4]=ea.getTime(); return true; break; } case(osgGA::GUIEventAdapter::PEN_PROXIMITY_ENTER): { pickArray[0]=ea.getEventType(); pickArray[1]=ea.getTabletPointerType(); pickArray[2]=0; pickArray[3]=0; pickArray[4]=ea.getTime(); return true; break; } case(osgGA::GUIEventAdapter::PEN_PROXIMITY_LEAVE): { pickArray[0]=ea.getEventType(); pickArray[1]=ea.getTabletPointerType(); pickArray[2]=0; pickArray[3]=0; pickArray[4]=ea.getTime(); return true; break; } case(osgGA::GUIEventAdapter::SCROLL): { pickArray[0]=ea.getEventType(); pickArray[1]=ea.getScrollingMotion(); pickArray[2]=ea.getX(); pickArray[3]=ea.getY(); pickArray[4]=ea.getTime(); getMessage(); return true; break; } case(osgGA::GUIEventAdapter::DRAG): { pickArray[0]=ea.getEventType(); pickArray[1]=ea.getButtonMask(); pickArray[2]=ea.getX(); pickArray[3]=ea.getY(); pickArray[4]=ea.getTime(); getMessage(); return true; break; } default : { pickArray[0]=ea.getEventType(); pickArray[1]=ea.getButton(); pickArray[2]=ea.getX(); pickArray[3]=ea.getY(); pickArray[4]=ea.getTime(); getMessage(); return true; break; } } return false; } volatile bool read_image_lock_flag = false; // false: can not read volatile bool write_image_lock_flag = false;// false: can not write void * data_thread_function(void *arg) { // 为recv image创建线程 int data_sockfd, client_data_sockfd; struct sockaddr_in data_address, server_address; client_data_sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if(client_data_sockfd < 0){ printf("create data socket error!\n"); return NULL; } data_address.sin_family = AF_INET; data_address.sin_addr.s_addr = INADDR_ANY; data_address.sin_port = htons(CLIENT_DATA_PORT); //设置close()后无需TIME_WAIT linger lin; lin.l_onoff = 1; lin.l_linger = 0; if(setsockopt(client_data_sockfd,SOL_SOCKET,SO_LINGER,(const char*)&lin,sizeof(linger)) == -1) printf("set_so_linger error: %s\n" , strerror(errno)); int data_len = sizeof(data_address); if(bind(client_data_sockfd, (struct sockaddr*)&data_address, data_len) < 0){ printf("client_getViewer line 133: bind socket error!:%s\n",strerror(errno)); close(client_data_sockfd); return NULL; } listen(client_data_sockfd, MAX_CONNECTION); int server_len = sizeof(server_address); data_sockfd = accept(client_data_sockfd, (struct sockaddr*)&server_address,(socklen_t *)&server_len); if(data_sockfd < 0){ printf("accept server data error!\n"); close(data_sockfd); pthread_exit((void*)"thread exit"); return NULL; } char recvMsg[BUFFER_SIZE]; int * data_sockfd_tmp = (int *) &data_sockfd; int cnt = 0; while(1) { //一直接收服务器传输的图片 cnt ++; if(recv_Image(data_sockfd_tmp , cnt) == 0) { write_image_lock_flag = false; read_image_lock_flag = true; //printf("getViewer line 157: read_image_lock_flag is %d\n" , read_image_lock_flag); while(write_image_lock_flag == false) {} } recv(*data_sockfd_tmp , recvMsg , sizeof(recvMsg) , 0); //printf("%d: %s\n" , cnt, recvMsg); send(*data_sockfd_tmp , "continue" , sizeof(recvMsg) , 0); if(strcmp(recvMsg , "close") == 0) break; } //服务器停止send后关闭线程 close(*data_sockfd_tmp); close(client_data_sockfd); /* printf("recv %d images\n" , cnt); printf("close client data socket!\n"); printf("exit process thread!\n"); pthread_exit((void*)"thread exit"); */ } void init() { return_flag = false; read_image_lock_flag = false; write_image_lock_flag = false; } int create_new_data_thread(int *client_sockfd) { char recvMsg[BUFFER_SIZE]; int res; pthread_t d_thread; void* thread_result; res = pthread_create(&d_thread, NULL, data_thread_function, /*(void*)*/NULL); if(res != 0){ printf("data thread create error!\n"); return -1; }else { printf("create data thread success!\n"); send(*client_sockfd , "create data thread success" , 111 , 0); } recv(*client_sockfd , recvMsg , sizeof(recvMsg) , 0); return 0; } int create_new_osgViewer(int *client_sockfd) { while(read_image_lock_flag == false) {} osgViewer::Viewer viewer; osg::ref_ptr<osg::DrawPixels> bmp = new osg::DrawPixels; bmp->setPosition(osg::Vec3(0.0f, 0.0f, 0.0f)); char image_file_path[BUFFER_SIZE] = "../files/recvImage/recv_image"; strcat(image_file_path , IMAGE_FORMAT); FILE *fp = NULL; bmp->setImage(osgDB::readImageFile(image_file_path)); write_image_lock_flag = true; read_image_lock_flag = false; /*fp = fopen(image_file_path, "rb"); if(0 == flock(fileno(fp), LOCK_EX)) { printf("getViewer line 207: Lock()\n"); bmp->setImage(osgDB::readImageFile(image_file_path)); flock(fileno(fp), LOCK_UN); printf("getViewer line 210: unLock()\n"); fclose(fp); } else { printf("client_getViewer line 223: lock failed\n"); fclose(fp); }*/ osg::ref_ptr<osg::Group> root = new osg::Group; osg::ref_ptr<osg::Geode> geode = new osg::Geode; geode->addDrawable(bmp.get()); root->addChild(geode.get()); viewer.setSceneData(root.get()); viewer.setCameraManipulator(new osgGA::TrackballManipulator()); osg::ref_ptr<PickHandler> eventPickHandler = new PickHandler(client_sockfd); viewer.addEventHandler(eventPickHandler) ; // 旋转一定角度(弧度值)。 viewer.realize(); osg::Matrix trans; trans.makeTranslate( -1, -1, 0); double angle( 0. ); //开始渲染 while (!viewer.done()) { // 创建旋转矩阵。 bmp = new osg::DrawPixels; osg::Matrix rot; rot.makeRotate( angle, osg::Vec3( 0, 0, 0 ) ); angle += 0.01; // 设置视口矩阵(旋转矩阵和平移矩阵连乘) viewer.getCamera()->setProjectionMatrix(rot * trans ); root->removeChild(geode); //printf("getViewer line 316: %f %f\n" , cpPickArray[0] , cpPickArray[1]); while(read_image_lock_flag == false){ //if(*(eventPickHandler->getpickArray() + 1) == ESCAPE_NUM) if(return_flag == true) return 0; } bmp->setImage(osgDB::readImageFile(image_file_path)); write_image_lock_flag = true; read_image_lock_flag = false; /*osg::ref_ptr<osg::Geode>*/ geode = new osg::Geode; geode->addDrawable(bmp.get()); viewer.setSceneData(geode.get()); viewer.getCamera()->setViewMatrix( rot * trans ); //geode->addDrawable(bmp.get()); //viewer.setSceneData(geode.get()); //viewer.realize(); viewer.frame(); } // viewer.realize(); // viewer.run(); return 0; } int get_Viewer(int *client_sockfd) { init(); //创建新的data的线程 if(create_new_data_thread(client_sockfd) == -1) return -1; create_new_osgViewer(client_sockfd); //阻塞进程,避免读图片先于写图片 return 0; }
ba381dcd0cf1cb171f85c5b2315370f3c69c380a
6ea1329f30ec0a8cdea9f33314e0757a7565d65d
/src/ArduScan.cpp
b01334f2b5f3c0661b87ca9cbdd9be0837f5c1bf
[]
no_license
arduino/arduino-usb-scanner
7d2ae6d65dd287ecdc5c6942032564a806b602eb
06f9749c22e15926541a89bcc39ab811bc6d8efc
refs/heads/master
2021-01-22T19:21:50.870657
2011-09-26T16:16:39
2011-09-26T16:16:39
2,461,504
20
4
null
null
null
null
UTF-8
C++
false
false
6,790
cpp
ArduScan.cpp
/* * ArduScan * Sept 2011 by Bill Westfield ("WestfW") * * Scan a windows system and try to figure out which COM ports * look like they might be Arduinos. * * This is based on the article here: * http://www.codeproject.com/KB/system/serial_portsenum_fifo.aspx * by Vladimir Afanasyev, which explains how to use the device manager * API to enumerate all the COM ports on a system, and * these forum entries: * http://www.microchip.com/forums/tm.aspx?high=&m=559736&mpage=1#560699 * http://www.microchip.com/forums/tm.aspx?high=&m=364903&mpage=1#365029 * Which explain how to get the USB Vendor/Product info from the same api. * * Currently this is set up to run in a CMD or other shell window, and * writes its findings to stdout. * * * It should compile fine under cygin, including mingw versions: * * g++ -mno-cygwin ArduScan.cpp -lsetupapi -o ArduScan.exe * * * Vladimir's code is distributed according to the terms of "The Code * Project Open License (CPOL)" http://www.codeproject.com/info/cpol10.aspx * and Bill thinks that sounds fine, and doesn't add any terms for his own code. */ #include <windows.h> #include <setupapi.h> #include <stdio.h> /* * USB Vendor IDs that are somewhat likely to be Arduinos. */ #define VENDOR_FTDI 0x403 #define VENDOR_ARDUINO 0x2341 /* * Vladamir's code for enumerating COM ports. Slightly modifed. */ #define MAX_NAME_PORTS 7 #define RegDisposition_OpenExisting (0x00000001) // open key only if exists #define CM_REGISTRY_HARDWARE (0x00000000) typedef DWORD WINAPI (* CM_Open_DevNode_Key)(DWORD, DWORD, DWORD, DWORD, ::PHKEY, DWORD); HANDLE BeginEnumeratePorts(VOID) { BOOL guidTest=FALSE; DWORD RequiredSize=0; HDEVINFO DeviceInfoSet; char* buf; guidTest=SetupDiClassGuidsFromNameA("Ports",(LPGUID)0,0,&RequiredSize); if(RequiredSize < 1) return (HANDLE) -1; buf=(char *)malloc(RequiredSize*sizeof(GUID)); guidTest=SetupDiClassGuidsFromNameA( "Ports",(_GUID *)buf,RequiredSize*sizeof(GUID),&RequiredSize); if(!guidTest) return (HANDLE) -1; DeviceInfoSet=SetupDiGetClassDevs( (_GUID*)buf,NULL,NULL,DIGCF_PRESENT); free(buf); if(DeviceInfoSet == INVALID_HANDLE_VALUE) return (HANDLE) -1; return DeviceInfoSet; } BOOL EnumeratePortsNext(HANDLE DeviceInfoSet, LPTSTR lpBuffer, int *index) { static CM_Open_DevNode_Key OpenDevNodeKey=NULL; static HINSTANCE CfgMan; int res1; char DevName[MAX_NAME_PORTS]={0}; static int numDev=0; int numport; SP_DEVINFO_DATA DeviceInfoData={0}; DeviceInfoData.cbSize=sizeof(SP_DEVINFO_DATA); if(!DeviceInfoSet || !lpBuffer) return -1; if(!OpenDevNodeKey) { CfgMan=LoadLibrary("cfgmgr32"); if(!CfgMan) return FALSE; OpenDevNodeKey= (CM_Open_DevNode_Key)GetProcAddress(CfgMan,"CM_Open_DevNode_Key"); if(!OpenDevNodeKey) { FreeLibrary(CfgMan); return FALSE; } } while(TRUE){ HKEY KeyDevice; DWORD len; res1=SetupDiEnumDeviceInfo( DeviceInfoSet,numDev,&DeviceInfoData); if(!res1) { SetupDiDestroyDeviceInfoList(DeviceInfoSet); FreeLibrary(CfgMan); OpenDevNodeKey=NULL; return FALSE; } res1=OpenDevNodeKey(DeviceInfoData.DevInst,KEY_QUERY_VALUE,0, RegDisposition_OpenExisting,&KeyDevice,CM_REGISTRY_HARDWARE); if(res1 != ERROR_SUCCESS) return FALSE; len=MAX_NAME_PORTS; res1=RegQueryValueEx( KeyDevice, // handle of key to query "portname", // address of name of value to query NULL, // reserved NULL, // address of buffer for value type (BYTE*)DevName, // address of data buffer &len // address of data buffer size ); RegCloseKey(KeyDevice); if(res1 != ERROR_SUCCESS) return FALSE; /* * Return the index too, so we can look up other info */ *index = numDev; numDev++; if(memcmp(DevName, "COM", 3)) continue; numport=atoi(DevName+3); if(numport > 0 && numport <= 256) { strcpy(lpBuffer,DevName); return TRUE; } FreeLibrary(CfgMan); OpenDevNodeKey=NULL; return FALSE; } } BOOL EndEnumeratePorts(HANDLE DeviceInfoSet) { if(SetupDiDestroyDeviceInfoList(DeviceInfoSet)) return TRUE; else return FALSE; } /* * End of Vladimir's code */ /* * Ascii HEX number to integer. Stop at invalid hex char */ int htoi(char *p) { int n = 0; while (*p) { char c = *p; if (c >= '0' && c <= '9') { n = n * 16 + (c - '0'); } else if (c >= 'a' && c <= 'z') { n = n * 16 + ((c+10) - 'a'); } else if (c >= 'A' && c <= 'Z') { n = n * 16 + ((c+10) - 'A'); } else break; p++; } return n; } /* * main program * enumerate the COM ports and split out any USB Vendor and Product info. * If the vendor is a likely Arduino (FTDI or Arduino), print out the info. */ //int WinMain(HINSTANCE, HINSTANCE, LPSTR, int) int main(int argc, _TCHAR* argv[]) { HANDLE h; SP_DEVINFO_DATA devInfo; int vendor, product; int deviceIndex; /* * Evil fixed-length strings; should allow variable length, * should allow univode. Bad non-windows programmer! */ char portname[50] = {0}; char idstring[100] = {0}; char infostring[100]; char *sernostr; char *infop = infostring; h = BeginEnumeratePorts(); /* * h now has handle from deviceInfoSet (SetupDiGetClassDevs) */ devInfo.cbSize = sizeof(SP_DEVINFO_DATA); while (EnumeratePortsNext(h, portname, &deviceIndex)) { char *p; SetupDiEnumDeviceInfo(h, deviceIndex, &devInfo); // SetupDiGetDeviceInstanceId(h, &devInfo, NULL, 0, &di_size); SetupDiGetDeviceInstanceId(h, &devInfo, idstring, sizeof(idstring)-1, NULL); infop = infostring; p = strstr(idstring, "VID_"); /* See if there is a vendor ID */ if (p) { vendor = htoi(p+4); } else { vendor = 0; } p = strstr(idstring, "PID_"); /* See if there is a Product ID */ if (p) { product = htoi(p+4); sernostr = p+9; /* The Serial number is everything past the PID */ } else { product = 0; sernostr = NULL; } if (vendor == VENDOR_FTDI || vendor == VENDOR_ARDUINO) { // sprintf(infop, "Possible Arduino on %s, VID 0x%04x PID 0x%04x\n Serno %s", // portname, vendor, product, sernostr); // MessageBox(NULL, infop, "ArduinoFinder", 0); printf("\nPossible Arduino on %s, VID 0x%04x PID 0x%04x\n Serno %s", portname, vendor, product, sernostr); } } }
17a88a9ba68f409072fc1941bdb056b28dfd7d6c
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5738606668808192_0/C++/FrozenWinters/coin.cc
b34a7bf9dc8565b4c6b64fff56501a42a8985193
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,944
cc
coin.cc
#include <fstream> using namespace std; // Methedology: if the sum of digits is divisible by 6, then 2, 3, or 6 is a // divisor in bases 10, 9, 7, 5, 4, 3. It remains to check bases 8, 6, and 2. // We check composite-ness by dividing by the first 2000 primes. int primes[2000]; __int128 expan = 0; __int128 pow(int A, int B){ if(B == 0){ return 1; } else{ return pow(A, B-1) * A; } } int check(long long Z, int B){ expan = 0; for(int j=0; j<100; j++){ if((Z & 1) == 1){ expan += pow(B, j); } Z = Z >> 1; if(Z == 0){ break; } } bool prime = true; int factor; for(int j=0; j<2000; j++){ if(expan % primes[j] == 0){ prime = false; factor = primes[j]; break; } } if(prime){ return -1; } return factor; } long long next(long long Z){ long long R = Z & (-Z); if((Z & (R << 1)) != 0){ return (next((Z ^ R) >> 1) << 1) + 1; } else{ return Z ^ (R+(R << 1)); } } int main(int argc, char* argv[]){ ifstream in(argv[1]); ofstream out("coin.out"); primes[0] = 2; int j = 1; for(int i = 3; i < 17392; i++){ bool t = true; for(int k = 0; k<j; k++){ if(i % primes[k] == 0){ t = false; break; } } if(t){ primes[j] = i; j++; } } int T, N, J; in >> T; for(int i = 1; i<=T; i++){ in >> N >> J; out << "Case #" << i << ":" << endl; int num = 0; long long mid = 15; long long one = 1; int F2, F6, F8; for(int k = 0; k<100000000; k++){ long long cand = ((one << (N-1)) + (mid << 1) + 1); F2 = check(cand, 2); F6 = check(cand, 6); F8 = check(cand, 8); if(F2 != -1 && F6 != -1 && F8 != -1){ num++; string st = ""; while(true){ if(cand % 2 == 0){ st = "0" + st; } else{ st = "1" + st; } cand /= 2; if(cand == 0){ break; } } out << st << " " << F2 << " 2 3 2 " << F6 << " 6 " << F8 << " 2 3" << endl; if(num == J){ break; } } mid = next(mid); } } }
4337534aa9f4039dc7c8f785b0fa11ec67f5606b
1673134fde1cfe01edb8101638954ccb2e889e63
/Desc.cpp
25f6f2da23baa6d4089535823cc3c1a4965f550e
[]
no_license
LordSputnik/opengrow
b6452e4a88d257a182b568913261c3ea8996a835
4fee1779df3994bd5b5c0d4186a6c0b44af3b1a0
refs/heads/master
2016-09-05T21:31:02.409808
2012-10-31T10:35:41
2012-10-31T10:35:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,822
cpp
Desc.cpp
#include "og_pch.hpp" #include "Desc.hpp" namespace og { void BranchDesc::SetFromNode(const pugi::xml_node & level) { pugi::xml_node attrib_set = level.child("mid"); for( pugi::xml_node node = attrib_set.first_child(); node; node = node.next_sibling() ) { if( strcmp( node.name(), "geotropism" ) == 0) { mid.light_attraction = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "first_split" ) == 0) { mid.first_split_distance = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "segment_length" ) == 0) { mid.segment_length = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "split_frequency" ) == 0) { mid.split_frequency = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "length" ) == 0) { mid.total_length = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "split_angle" ) == 0) { mid.split_angle = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "bud_growth_samples" ) == 0) { mid.bud_growth_samples = StrToStd<uint16_t>( node.child_value() ); } } attrib_set = level.child("var"); for( pugi::xml_node node = attrib_set.first_child(); node; node = node.next_sibling() ) { if( strcmp( node.name(), "geotropism" ) == 0) { var.light_attraction = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "first_split" ) == 0) { var.first_split_distance = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "segment_length" ) == 0) { var.segment_length = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "split_frequency" ) == 0) { var.split_frequency = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "length" ) == 0) { var.total_length = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "split_angle" ) == 0) { var.split_angle = StrToStd<float>( node.child_value() ); } else if( strcmp( node.name(), "bud_growth_samples" ) == 0) { var.bud_growth_samples = StrToStd<uint16_t>( node.child_value() ); } } } BranchDesc::BranchDesc(const pugi::xml_node & node) { SetFromNode(node); } BranchDesc::BranchDesc(const pugi::xml_node & node, const BranchDesc & defaults) : mid(defaults.mid), var(defaults.var) { SetFromNode(node); } TreeDesc::TreeDesc(const pugi::xml_node & tree_root) { species = tree_root.child_value("species"); max_levels = static_cast<uint8_t>(StrToStd<uint32_t>(tree_root.child_value("max_levels"))); //Need to interpret as int then cast, otherwise it's read as ASCII char. // Allocate memory to hold the midpoint and variation for the values in each branch level. levels.resize(max_levels); const pugi::xml_node data_node = tree_root.child ( "data" ); pugi::xml_node node = data_node.child ( "base_splits" ); base_splits[MID] = StrToStd<float> ( node.child_value ( "mid" ) ); base_splits[VAR] = StrToStd<float> ( node.child_value ( "var" ) ); node = data_node.child ( "defaults" ); defaults.reset(new BranchDesc(node)); node = data_node.child ( "levels" ); for( pugi::xml_node level = node.first_child(); level; level = level.next_sibling() ) { size_t index = level.attribute ( "id" ).as_uint(); if ( index >= max_levels ) continue; /* Set the level to the default values */ levels[index].reset(new BranchDesc(level,(*defaults))); } } }
ffea8e3d239ac123a18f2ceacab0cada28cebc25
a387c9fa08abba6089a09e511765c3e8d5ad61df
/Lab/大三(上)/算法分析与设计_2013/贪心法/Greed/Greed/mapcolor.cpp
519b72b788e94631785305fb0ae3209b875ddd6f
[]
no_license
linjinze999/BUPTSSE2013
ab5153a8a544a8e1f3337bbc8c89b3bf23788d05
00abfac8c51cbca4cfcc936d6441424e15d656fd
refs/heads/master
2021-01-19T01:12:17.275203
2019-11-28T01:57:03
2019-11-28T02:00:11
63,605,859
4
3
null
2019-11-28T02:00:12
2016-07-18T13:36:01
JavaScript
GB18030
C++
false
false
941
cpp
mapcolor.cpp
#include"mapcolor.h" #include<iostream> #include<vector> #include<time.h> bool MapColor(int number,int *map,int *result,int count,int color,int max_color)//着色图 { bool can=false; for(int n=0;n<number;n++) result[n]=-1; for(int i=0;i<max_color;i++){//遍历所有颜色 for(int j=0;j<number;j++){//遍历所有顶点 if(result[j]==-1){//顶点未着色 can=true; for(int n=0;n<number;n++)//检查是否冲突 if(map[j*number+n]==1){ if(result[n]==i){ can=false; break; } } if(can) result[j]=i; } } } for(int n=0;n<number;n++) if(result[n]==-1) return false; return true; }; void setMap(int count,int *map)//随机生成无向图 { srand((int)time(0)); int r=rand()%100; for(int i=0;i<count;i++) for(int n=0;n<count;n++){ if(n==i) map[i*count+n]=0; else if(n>i){ map[i*count+n]=r%2; map[n*count+i]=r%2; r=((r+1)*157)%100; } } };
6ef2e0ed0a12e6584e9d4edee590aadf2349b368
b089c1a7b787cc27bb0512b3ac40d9590d95d3ef
/uint_custom.h
d04d8d46d8b32a1beca954498c7c3ffcc63e6ab5
[]
no_license
NunchuckBradley/btm
e388f1adfddf2bb451b32c65a48e38ca6263387a
fa1301acd0ab16b7655488be4a3290425899335b
refs/heads/master
2023-03-15T02:56:14.341155
2021-03-01T21:42:34
2021-03-01T21:42:34
343,564,691
0
0
null
null
null
null
UTF-8
C++
false
false
7,112
h
uint_custom.h
// code influenced from bitcoin source code #ifndef UINT_CUSTOM_H #define UINT_CUSTOM_H #include <cstring> #include <sstream> #include "crypto.h" //#include <cryptopp/filters.h> //#include <cryptopp/hex.h> template<unsigned int BITS> class uint256 { protected: static constexpr int WIDTH = BITS / 8; uint8_t m_data[WIDTH]; public: // uint256(unsigned char* data) { // int i = 0; // while(i < WIDTH) { // m_data[i] = data[i]; // } // } // uint8_t & operator [](int i) {return m_data[i];} uint8_t operator [](int i) const {return m_data[i];} uint8_t & operator [](int i) {return m_data[i];} uint8_t & at(int i) {return m_data[i];} void operator = (const unsigned int num) { memcpy(&m_data, &num, WIDTH); // reverseOrder(); } void operator = (unsigned char* data) { memcpy(&m_data, data, WIDTH); // reverseOrder(); } void setUnsignedIntArray(unsigned int* data, const int length) { for(int f = 0; f < length; f++) { for(int i=0;i<4;i++) { m_data[(f << 2)+i] = (data[f] << (i << 3)) >> 24; } // unsigned int tmp = data[f]; // int tmp2 = 0; // while (tmp != 0) { // m_data[(f * 4)+tmp2] = (data[f] << (tmp<<3)) >> 24; // tmp >>= 8; // tmp2++; // } // memcpy(&m_data[f << 2], &data[f], 4); // for (int i = 0; i < 4; i++) { // m_data[(f << 2)+i] = (data[f] << (i<<3)) >> 24; // } } // unsigned int tmp = data[f]; // int tmp2 = 0; // for (int i = 0; i < 4; i++) { // } } void combine(uint256<256> comb1, uint256<256> comb2) { if (BITS == 512) { int i = 0; while(i < WIDTH / 2) { m_data[i] = comb2[i]; m_data[WIDTH/2+i] = comb1[i]; i++; } // memcpy(&m_data, &comb1, WIDTH/2); // memcpy(&m_data+WIDTH/2, &comb2, WIDTH/2); } } int length() {return sizeof(m_data);} unsigned char asChar() { unsigned char tmp; memset(&tmp, 0, WIDTH); memcpy(&tmp, &m_data, WIDTH); // unsigned char* tmp2 = (unsigned char*)tmp; // int i = 0; // while(i < WIDTH) { // tmp[i] = m_data[WIDTH - 1 - i]; // i++; // } // memset(out, WIDTH); // memcpy(out, &tmp, WIDTH); // out = tmp; return tmp; } // void operator = (const CryptoPP::byte* bytes) { // memcpy(&m_data, bytes, WIDTH); // } // void addBytes(const CryptoPP::byte* bytes) // { // memcpy(m_data, bytes, WIDTH); // std::cout << "adding bytes to 256int" << std::endl; // CryptoPP::byte* edata = (CryptoPP::byte*)bytes; // int i = 0; // while(i < WIDTH) { // m_data[i] = bytes[i]; // i++; // } // } void reverseOrder() { // swap byte order int e = 0; int s = WIDTH-1; while (s > e) { uint8_t tmp = m_data[s]; m_data[s] = m_data[e]; m_data[e] = tmp; s--; e++; } } static uint8_t reverse(uint8_t* data) { uint8_t tmp; uint8_t *pnt = &tmp; int i = 0; while(i < WIDTH) { pnt[i] = data[WIDTH - 1 - i]; i++; } return tmp; } // https://stackoverflow.com/questions/8406148/how-to-do-reverse-memcmp static int reversememcmp(const void *s1, const void *s2, size_t n) { if(n == 0) return 0; // Grab pointers to the end and walk backwards const unsigned char *p1 = (const unsigned char*)s1 + n - 1; const unsigned char *p2 = (const unsigned char*)s2 + n - 1; while(n > 0) { // If the current characters differ, return an appropriately signed // value; otherwise, keep searching backwards if(*p1 != *p2) return *p1 - *p2; p1--; p2--; n--; } return 0; } inline int Compare(const uint256& other) const { return reversememcmp(m_data, other.m_data, sizeof(m_data)); // return memcmp((uint8_t*)reverse((uint8_t*)m_data), (uint8_t*)reverse((uint8_t*)other.m_data), sizeof(m_data)); } friend inline bool operator==(const uint256& a, const uint256& b) { return a.Compare(b) == 0; } friend inline bool operator!=(const uint256& a, const uint256& b) { return a.Compare(b) != 0; } friend inline bool operator<(const uint256& a, const uint256& b) { return a.Compare(b) < 0; } friend inline bool operator>(const uint256& a, const uint256& b) { return a.Compare(b) > 0; } void write32BitAt(const int pos, unsigned int* val) { uint8_t* data = m_data; for(int i = 0; i < 4; i++) { data[pos+i] = (*val << (i<<3)) >> 24; } } void shiftLeft(int shift) { for(int s = 0; s < shift; s++) { for(int i = 0; i < WIDTH-1; i++) { m_data[i] = m_data[i+1]; } m_data[WIDTH-1] = 0; } } std::string decToHex(int dec) { std::stringstream ss; ss<< std::hex << dec; // int decimal_value std::string res ( ss.str() ); return res; } unsigned int stringHexToInt(std::string str) { unsigned int x; std::stringstream ss; ss << std::hex << str; ss >> x; return x; } std::string getHex(bool bigendian = true) { std::string out; for (int i = 0; i < WIDTH; ++i) { int index; if (bigendian) { index = WIDTH - 1 - i; } else { index = i; } // for 'empty' uint8 if (m_data[index] == 00) { out += '0'; out += '0'; } else { // for almost 'empty' uint8 // now handled by decToHex <- no if (m_data[index] < 16) { out += '0'; } out += decToHex(m_data[index]); } } return out; } void setHex(const char* psz) { if (sizeof(psz) > 0) { int i = 0; while (i < WIDTH) { std::string tmp = std::string() + psz[i*2] + psz[(i*2)+1]; // std::cout << "comverting " << i << "/" << WIDTH - 1 - i << " : " << tmp << " to " << Crypto::stringHexToInt(tmp) << std::endl; m_data[WIDTH - 1 - i] = stringHexToInt(tmp); i++; } } } void setHex(const std::string& str) { setHex(str.c_str()); } std::string toString(){ return getHex(); } void writeData(int i, uint8_t data) { m_data[i] = data; } void clear() { delete[] m_data; } }; #endif // UINT_CUSTOM_H
e4b385412b526dd2e161e1bd6f6d33daa209b749
5d8e8a7d2c54d35d104c752d4cee27932758fde5
/cdt/CTcpClient.h
698189952b179d4af49ff12cad8373275c9b3a6f
[]
no_license
MWjie/RemoteWITH_3AnalogScreen
c05baac93db788ac58458e48d7f5ff34f937b7ca
78d8ae1eca58a1f043200873398157fa71c709a7
refs/heads/master
2020-03-09T16:14:44.793981
2018-04-17T13:43:33
2018-04-17T13:43:33
128,879,532
1
0
null
null
null
null
WINDOWS-1250
C++
false
false
437
h
CTcpClient.h
#ifndef NET_H #define NET_H #include <iostream> #include <windows.h> #include <winsock2.h> #include "type.h" using namespace std; class CTcpClient { private: SOCKET m_sock; //socketĚ×˝Ó×Ö public: char* m_host; ushort m_port; public: int open(char* host, ushort port); int close(); int read(char* buf, int size); int write(char* buf, int size); }; #endif
3332d4f651bf9195df50d0e58c3d61a3f76732a7
279d3947563bcba72f4effe293a0b0e62dfc1051
/Understanding_the_RGB_LED.cpp
bbdbc5229fefe02318d86107b545b04a7f335854
[]
no_license
SRCinVA/Arduino
ee0ed5470cb556372f8e7ba6afe03a416f9cd894
ba0650e2edb2133f5457f283ccada3e158fe29b8
refs/heads/main
2023-08-20T14:24:31.954548
2021-09-27T00:55:54
2021-09-27T00:55:54
318,236,680
0
0
null
null
null
null
UTF-8
C++
false
false
1,466
cpp
Understanding_the_RGB_LED.cpp
// Understanding the RGB LED int redPin=8; int greenPin=9; int bluePin=10; String myColor; String msg="Which color would you like?"; void setup() { Serial.begin(9600); pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); } void loop() { //ask Serial.println(msg); //wait while (Serial.available() == 0){ // to just keep it hanging out } //read myColor = Serial.readString(); // to populate the empty variable we declared above if (myColor=="red"){ digitalWrite(redPin, HIGH); digitalWrite(greenPin, LOW); digitalWrite(bluePin, LOW); } if (myColor == "green"){ digitalWrite(redPin, LOW); digitalWrite(greenPin, HIGH); digitalWrite(bluePin, LOW); } if (myColor == "blue"){ digitalWrite(redPin, LOW); digitalWrite(greenPin, LOW); digitalWrite(bluePin, HIGH); } if (myColor == "off"){ digitalWrite(redPin, LOW); digitalWrite(greenPin, LOW); digitalWrite(bluePin, LOW); } if (myColor == "aqua"){ digitalWrite(redPin, LOW); analogWrite(greenPin, 255); //use a number between 0 and 255 analogWrite(bluePin, 125); } if (myColor == "yellow"){ analogWrite(redPin, 255); analogWrite(greenPin, 100); analogWrite(bluePin, 0); } if (myColor == "cyan"){ analogWrite(redPin, 0); analogWrite(greenPin, 255); analogWrite(bluePin, 255); } if (myColor == "magenta"){ analogWrite(redPin, 255); analogWrite(greenPin, 0); analogWrite(bluePin, 100); } }
c7c9f52c3d0ae74c1fed64490f8deb69ce2dd890
e2a07d08787f6bcc37267648e8d176248282d913
/will/DataPreparer.h
0978e1618b27552717a367dbaeeed6fdf452d888
[]
no_license
willdla/cccc-lite
3d7bdfdf5dc7df653c875c85495df78da84c1174
9f809fa2c87320007e52adb754a3707db8a7386f
refs/heads/master
2023-08-19T14:37:43.377302
2021-10-29T16:31:38
2021-10-29T16:31:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,647
h
DataPreparer.h
#pragma once #include "Matrix.h" #include "Neural.h" #include "Option.h" #include "Random.h" namespace cccc { class DataPreparer : public Neural { public: friend class DataPreparerFactory; public: DataPreparer(); virtual ~DataPreparer(); protected: void init(); virtual void init2() {} int getFillGroup(); //virtual void destroy() {} public: virtual void fillData(Matrix& X, Matrix& Y) {} void transData(const Matrix& X0, const Matrix& Y0, Matrix& X1, Matrix& Y1, const std::vector<int>& fill_queue); virtual void transOne(Matrix& X1, Matrix& Y1) {} virtual void showData(Matrix& X, Matrix& Y, int number) {} protected: std::string getSection() { return section_; } private: std::string create_by_dll_; public: void reload(); void shuffleQueue(std::vector<int>& train_queue); void prepareData(int epoch, const std::string& info, Matrix& X, Matrix& Y, Matrix& X_cpu, Matrix& Y_cpu); void initData(Matrix& X, Matrix& Y); static void readTxt(const std::string& filename, Matrix& X, Matrix& Y); static void readBin(const std::string& file_bin_x, const std::string& file_bin_y, Matrix& X, Matrix& Y); static void readOneBin(const std::string& file_bin, Matrix& data); static void writeBin(const std::string& file_bin, const Matrix& data); void resetDataDim(Matrix& X, Matrix& Y); protected: int shuffle_ = 1; //是否乱序训练集 int trans_ = 0; //是否变换 int fill_ = 0; //是否填充 int fill_group_ = 0; //填充的组数 std::string section_ = "data_preparer"; Option* option_; Random<double> rand_; //图的尺寸 std::vector<int> dim0_, dim1_; std::vector<int> train_queue_origin_; //填充的顺序 int trained_in_origin_ = 0; //已经处理的部分 protected: std::vector<std::string> message_; public: std::string getMessage(int i); int isFill() { return fill_; } protected: //以下函数仅用于简化读取 template <typename T> static void fillNumVector(std::vector<T>& v, double value, int size) { for (int i = v.size(); i < size; i++) { v.push_back(T(value)); } } //去掉下划线,使输出略为美观 static std::string removeEndUnderline(const std::string& str) { if (!str.empty() && str.back() == '_') { return str.substr(0, str.size() - 1); } return str; } }; //以下宏仅用于简化准备器的参数的读取,不可用于其他 #define NAME_STR(a) (removeEndUnderline(#a).c_str()) #define OPTION_GET_INT(a) \ do { \ a = option_->getInt(section_, #a, a); \ LOG("{} = {}\n", NAME_STR(a), a); \ } while (0) #define OPTION_GET_INT2(a, v) \ do { \ a = option_->getInt(section_, #a, v); \ LOG("{} = {}\n", NAME_STR(a), a); \ } while (0) #define OPTION_GET_REAL(a) \ do { \ a = option_->getReal(section_, #a, a); \ LOG("{} = {}\n", NAME_STR(a), a); \ } while (0) #define OPTION_GET_REAL2(a, v) \ do { \ a = option_->getReal(section_, #a, v); \ LOG("{} = {}\n", NAME_STR(a), a); \ } while (0) #define OPTION_GET_STRING(a) \ do { \ a = option_->getString(section_, #a, ""); \ LOG("{} = {}\n", NAME_STR(a), a); \ } while (0) #define OPTION_GET_NUMVECTOR(a, v, n, d) \ do { \ a.clear(); \ convert::findNumbers(option_->getString(section_, #a, v), a); \ a.resize(n, d); \ LOG("{} = {}\n", NAME_STR(a), a); \ } while (0) } // namespace cccc
8e9a1e4d2dcd259e6bb489a1b33478966bc49bb0
cd37631e066e69f87883b41bbfaaf7a2e3e3a914
/server/Server.cpp
9dcd902d68847296666bf72b7be812831786525d
[]
no_license
ballinhuang/CSAAS
a8906c4f16fb20d63ecee7a9567fcf66711a9b41
041c59db7e93e87318b501e7f00b5ae41ccfb145
refs/heads/master
2021-01-21T17:09:41.483838
2018-06-06T08:40:23
2018-06-06T08:40:23
91,935,329
1
1
null
2017-10-05T14:30:25
2017-05-21T05:29:48
C++
UTF-8
C++
false
false
10,708
cpp
Server.cpp
#include "Server.hpp" #include <iostream> #include <json.hpp> #include "c_socket.hpp" #include "Message.hpp" #include <unistd.h> #include "s_nbsocket.hpp" #include "s_socket.hpp" using json = nlohmann::json; using namespace std; #include <fstream> extern int debug; extern ofstream *debug_file; Server::Server() { } void Server::set_server_attr(string ip, string port) { svr_ip = ip; svr_port = port; } void Server::set_scheduler_attr(string ip, string port) { sch_ip = ip; sch_port = port; } void Server::notify(int msg) { // msg == 0 notitfy newjob, msg == 1 notitfy schedual finish if (msg == 0) { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server notify(0): Requset to schedual!" << endl; else if (debug == 2) cout << "Server ---> Server notify(0): Requset to schedual!" << endl; } do_schedual_tex.lock(); do_schedual = true; do_schedual_tex.unlock(); } else if (msg == 1) { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server notify(1): Schedualer finish schedual!" << endl; else if (debug == 2) cout << "Server ---> Server notify(1): Schedualer finish schedual!" << endl; } schedual_busy_tex.lock(); schedual_busy = false; schedual_busy_tex.unlock(); } } void Server::attach_success() { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server attach_success():Attach success." << endl; else if (debug == 2) cout << "Server ---> Server attach_success():Attach success." << endl; } } void Server::check_schedule() { now_time = time(NULL); if (next_schedule - now_time <= 0) { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server check_schedulen(): Trigger to do scheduale." << endl; else if (debug == 2) cout << "Server ---> Server check_schedulen(): Trigger to do scheduale." << endl; } do_schedual_tex.lock(); do_schedual = true; do_schedual_tex.unlock(); } } void Server::start_accept_thread(string ip, string port, ThreadPool *pool) { pool = new ThreadPool(10); HandlerFactory *factory = new HandlerFactory(); s_nbsocket *s = new s_nbsocket(); vector<Event> *events; if (s->setConnection(ip, port) != 1) { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server start_accept_thread(): setConnection() Error!" << endl; else if (debug == 2) cout << "Server ---> Server start_accept_thread(): setConnection() Error!" << endl; } } while (true) { events = s->getevent(); for (vector<Event>::iterator it = events->begin(); it != events->end(); it++) { pool->enqueue(&readrequest, *it, factory); } } } void Server::readrequest(Event event, HandlerFactory *factory) { if (event.data == "") return; json request = json::parse(event.data); s_socket *s = new s_socket(); s->setconn_port(event.socket_fd); //cout << event.socket_fd << " " << request["SENDER"] << " " << request["REQUEST"] << endl; IHandler *handler = factory->getHandler(request, s); if (handler == NULL) return; handler->handle(); } void Server::run() { server_pool = new ThreadPool(1); server_pool->enqueue(start_accept_thread, svr_ip, svr_port, request_pool); sched_iteration = 60; //1 min now_time = time(NULL); next_schedule = now_time + sched_iteration; int count = 0; while (1) { check_schedule(); do_schedual_tex.lock(); if (do_schedual) { next_schedule = now_time + sched_iteration; schedual_busy_tex.lock(); if (!schedual_busy) { if (debug > 0) { if (debug == 1) *debug_file << "conut:" << count << ": Server ---> Server run(): Start send cmd to schedual." << endl; else if (debug == 2) cout << "conut:" << count << ": Server ---> Server run(): Start send cmd to schedual." << endl; count++; } if (contact_scheduler() == 1) { do_schedual = false; do_schedual_tex.unlock(); schedual_busy = true; schedual_busy_tex.unlock(); if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server run(): Contact_scheduler() sccess." << endl; else if (debug == 2) cout << "Server ---> Server run(): Contact_scheduler() sccess." << endl; } } else { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server run(): Contact_scheduler() fail." << endl; else if (debug == 2) cout << "Server ---> Server run(): Contact_scheduler() fail." << endl; } schedual_busy_tex.unlock(); do_schedual = false; do_schedual_tex.unlock(); } } else { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server run(): Scheduler is busy." << endl; else if (debug == 2) cout << "Server ---> Server run(): Scheduler is busy." << endl; } schedual_busy_tex.unlock(); do_schedual = false; do_schedual_tex.unlock(); } } else { do_schedual_tex.unlock(); } } } int Server::contact_scheduler() { c_socket s; Message do_schedule_msg; if (s.setConnection(sch_ip, sch_port) != 1) { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server contact_scheduler(): Server client socket creat error !" << endl; else if (debug == 2) cout << "Server ---> Server contact_scheduler(): Server client socket creat error !" << endl; } return 0; } if (s.connect2server() != 1) { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server contact_scheduler(): Server client socket connect error !" << endl; else if (debug == 2) cout << "Server ---> Server contact_scheduler(): Server client socket connect error !" << endl; } return 0; } do_schedule_msg.initMessage(); do_schedule_msg.msg["IP"] = svr_ip; do_schedule_msg.msg["PORT"] = svr_port; do_schedule_msg.encode_Header("server", "scheduler", "do_schedule"); s.send(do_schedule_msg.encode_Message()); s.closeConnection(); return 1; } string Server::getsvr_ip() { return svr_ip; } string Server::getsvr_port() { return svr_port; } /* void Server::readrequest(s_socket *s, HandlerFactory *factory) { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server readrequest():Start read request." << endl; else if (debug == 2) cout << "Server ---> Server readrequest():Start read request." << endl; } while (1) { string res = ""; res = s->readmessage(); if (res == "") { break; } if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server readrequest():Receive request = " << endl << res << endl; else if (debug == 2) cout << "Server ---> Server readrequest():Receive request = " << endl << res << endl; } json request = json::parse(res); IHandler *handler = factory->getHandler(request, s); if (handler == NULL) { break; } handler->handle(); if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server readrequest():End read request." << endl; else if (debug == 2) cout << "Server ---> Server readrequest():End read request." << endl; } } s->closeConnection(); } void Server::start_accept_thread(string ip, string port, ThreadPool *pool) { pool = new ThreadPool(10); HandlerFactory *factory = new HandlerFactory(); while (1) { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server start_accept_thread(): Creat new socket." << endl; else if (debug == 2) cout << "Server ---> Server start_accept_thread(): Creat new socket." << endl; } s_socket *s = new s_socket(); if (s->setConnection(ip, port) != 1) { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server start_accept_thread(): setConnection() Error!" << endl; else if (debug == 2) cout << "Server ---> Server start_accept_thread(): setConnection() Error!" << endl; } continue; } if (s->acceptClinet()) { if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server start_accept_thread(): Accept client success." << endl; else if (debug == 2) cout << "Server ---> Server start_accept_thread(): Accept client success." << endl; } s->setacceptreuse(); s->closebind(); pool->enqueue(&readrequest, s, factory); if (debug > 0) { if (debug == 1) *debug_file << "Server ---> Server start_accept_thread(): Enque readrequest() to process_pool success." << endl; else if (debug == 2) cout << "Server ---> Server start_accept_thread(): Enque readrequest() to process_pool success." << endl; } } } } */
df10759cffa694b384bf8daad4679a7993ac0ef8
79cd3aed34bdff83575ea0b5973812e396fc089b
/TehnikeProgramiranja/Tutorijali/T7/Z7.cpp
8834aaef0dc21ef17bef0be9989c5d50ce9bc110
[]
no_license
lmujic1/CppCode
42be834f9e170d00a8843f316dce9205637e5c1a
628a21c3b16e3906160589b97cec25c46af654e8
refs/heads/master
2023-08-14T03:49:38.149481
2021-09-20T23:56:51
2021-09-20T23:56:51
407,698,782
0
0
null
null
null
null
UTF-8
C++
false
false
1,032
cpp
Z7.cpp
// // Created by 38760 on 18. 9. 2021.. // /* TP 16/17 (Tutorijal 7, Zadatak 7) Autotestove pisao Elmir Hodzic. Sva pitanja, prijave gresaka i sugestije slati na mail ehodzic3@etf.unsa.ba Vrsit ce se provjera na prepisivanje tutorijala. */ #include <iostream> #include <set> template <typename t> std::set<t> Unija (std::set<t> s1,std::set<t> s2) { for(t x:s2) s1.insert(x); return s1; } template <typename t> std::set<t> Presjek(std::set<t> s1,std::set<t> s2) { std::set<t> novi; for(auto x:s1) { for(auto y:s2) { if(x==y) novi.insert(x); } } return novi; } int main () { return 0; } /* Napišite generičke funkcije “Unija” i “Presjek” koje kao parametre primaju dva skupa (tj. objekta tipa “set”) proizvoljnog ali istog tipa elemenata, i koje kao rezultat daju novi skup koji predstavlja njihovu uniju, odnosno presjek. Napisane funkcije demonstrirajte u testnom programu koji nalazi uniju i presjek dva fiksna skupa čiji su elementi stringovi */
aa45003332b5d1d198509fb3f0ea6793f0d6b6d1
0abdd25bc1b6456765344da544e1c3b768203314
/dependency/DataServerEngine/src/utils/variant.cpp
96f4938ae1e6f97d18b6c73a63214393a1b6d267
[]
no_license
fahram/DataServer
351d938d386a2c6c415433897c1b28b039b5ab18
1183cb7462bd95d3152262073e137d327e093df5
refs/heads/master
2021-01-21T19:45:12.884077
2011-12-02T09:01:29
2011-12-02T09:01:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,191
cpp
variant.cpp
#include "utils/variant.h" #include "utils/string_algorithm.h" #include <boost/assert.hpp> #include <../../opc_foundation/opcda.h> string_t TypeAsString(VARTYPE vt) { switch (vt) { case VT_EMPTY: return "VT_EMPTY"; case VT_NULL: return "VT_NULL"; case VT_I2: return "VT_I2"; case VT_I4: return "VT_I4"; case VT_R4: return "VT_R4"; case VT_R8: return "VT_R8"; case VT_CY: return "VT_CY"; case VT_DATE: return "VT_DATE"; case VT_BSTR: return "VT_BSTR"; case VT_DISPATCH: return "VT_DISPATCH"; case VT_ERROR: return "VT_ERROR"; case VT_BOOL: return "VT_BOOL"; case VT_VARIANT: return "VT_VARIANT"; case VT_DECIMAL: return "VT_DECIMAL"; case VT_RECORD: return "VT_RECORD"; case VT_UNKNOWN: return "VT_UNKNOWN"; case VT_I1: return "VT_I1"; case VT_UI1: return "VT_UI1"; case VT_UI2: return "VT_UI2"; case VT_UI4: return "VT_UI4"; case VT_INT: return "VT_INT"; case VT_UINT: return "VT_UINT"; case VT_VOID: return "VT_VOID"; case VT_HRESULT: return "VT_HRESULT"; case VT_PTR: return "VT_PTR"; case VT_SAFEARRAY: return "VT_SAFEARRAY"; case VT_CARRAY: return "VT_CARRAY"; case VT_USERDEFINED: return "VT_USERDEFINED"; case VT_LPSTR: return "VT_LPSTR"; case VT_LPWSTR: return "VT_LPWSTR"; case VT_BLOB: return "VT_BLOB"; case VT_STREAM: return "VT_STREAM"; case VT_STORAGE: return "VT_STORAGE"; case VT_STREAMED_OBJECT: return "VT_STREAMED_OBJECT"; case VT_STORED_OBJECT: return "VT_STORED_OBJECT"; case VT_BLOB_OBJECT: return "VT_BLOB_OBJECT"; case VT_CF: // Clipboard Format return "VT_CF"; case VT_CLSID: return "VT_CLSID"; case VT_VECTOR: return "VT_VECTOR"; case VT_ARRAY: return "VT_ARRAY"; //case VT_BYREF: //return "VT_BYREF"; case VT_BYREF|VT_DECIMAL: return "VT_BYREF|VT_DECIMAL"; //case VT_ARRAY|*: //return "VT_ARRAY|*"; case VT_BYREF|VT_UI1: return "VT_BYREF|VT_UI1"; case VT_BYREF|VT_I2: return "VT_BYREF|VT_I2"; case VT_BYREF|VT_I4: return "VT_BYREF|VT_I4"; case VT_BYREF|VT_R4: return "VT_BYREF|VT_R4"; case VT_BYREF|VT_R8: return "VT_BYREF|VT_R8"; case VT_BYREF|VT_BOOL: return "VT_BYREF|VT_BOOL"; case VT_BYREF|VT_ERROR: return "VT_BYREF|VT_ERROR"; case VT_BYREF|VT_CY: return "VT_BYREF|VT_CY"; case VT_BYREF|VT_DATE: return "VT_BYREF|VT_DATE"; case VT_BYREF|VT_BSTR: return "VT_BYREF|VT_BSTR"; case VT_BYREF|VT_UNKNOWN: return "VT_BYREF|VT_UNKNOWN"; case VT_BYREF|VT_DISPATCH: return "VT_BYREF|VT_DISPATCH"; //case VT_ARRAY|*: //return "VT_ARRAY|*"; case VT_BYREF|VT_VARIANT: return "VT_BYREF|VT_VARIANT"; //Generic case ByRef: //return "ByRef"; case VT_BYREF|VT_I1: return "VT_BYREF|VT_I1"; case VT_BYREF|VT_UI2: return "VT_BYREF|VT_UI2"; case VT_BYREF|VT_UI4: return "VT_BYREF|VT_UI4"; case VT_BYREF|VT_INT: return "VT_BYREF|VT_INT"; case VT_BYREF|VT_UINT: return "VT_BYREF|VT_UINT"; default: return "Unknown type"; } } ComVariant::ComVariant() { init(); value.vt = VT_EMPTY; } ComVariant::ComVariant( const ComVariant &rVal ) { init(); *this = rVal; } ComVariant::ComVariant( bool cValue ) { init(); *this = cValue; } ComVariant::ComVariant( char cValue ) { init(); *this = cValue; } ComVariant::ComVariant( unsigned char cValue ) { init(); *this = cValue; } ComVariant::ComVariant( short cValue ) { init(); *this = cValue; } ComVariant::ComVariant( unsigned short cValue ) { init(); *this = cValue; } ComVariant::ComVariant( int cValue ) { init(); *this = cValue; } ComVariant::ComVariant( unsigned int cValue ) { init(); *this = cValue; } ComVariant::ComVariant( long cValue ) { init(); *this = cValue; } ComVariant::ComVariant( unsigned long cValue ) { init(); *this = cValue; } ComVariant::ComVariant( __int64 cValue ) { init(); *this = cValue; } ComVariant::ComVariant( unsigned __int64 cValue ) { init(); *this = cValue; } ComVariant::ComVariant( float cValue ) { init(); *this = cValue; } ComVariant::ComVariant( double cValue ) { init(); *this = cValue; } ComVariant::ComVariant( CY cValue ) { init(); *this = cValue; } ComVariant::ComVariant( const FILETIME &cValue ) { init(); *this = cValue; } ComVariant::ComVariant( const string_t& cValue ) { init(); *this = cValue; } ComVariant::ComVariant( const VARIANT& cValue ) { init(); *this = cValue; } ComVariant::~ComVariant() { clear(); } void ComVariant::init() { ::ZeroMemory( &value, sizeof(VARIANT) ); } void ComVariant::clear() { ComVariant::variantClear( &value ); } void ComVariant::variantClear( VARIANT *ptr ) { if( ptr == NULL ) return; ::VariantClear( ptr ); ::ZeroMemory( ptr, sizeof(VARIANT) ); } const VARTYPE& ComVariant::getType() const { return value.vt; } VARIANT& ComVariant::getRef() { return value; } const VARIANT& ComVariant::getConstRef() const { return value; } VARIANT* ComVariant::getPtr() { return &value; } HRESULT ComVariant::variantCopy( VARIANT *dst, const VARIANT *src ) { if( dst == NULL || src == NULL ) return E_FAIL; return ::VariantCopy( dst, (VARIANT*)src ); } HRESULT ComVariant::variantCopy( VARIANT &dst, const VARIANT &src ) { return ::VariantCopy( &dst, (VARIANT*)&src ); } ComVariant& ComVariant::operator=( const ComVariant &rVal ) { if( this == &rVal ) return *this; clear(); ComVariant::variantCopy( &value, &rVal.value ); return *this; } ComVariant& ComVariant::operator=( bool rVal ) { clear(); value.vt = VT_BOOL; value.boolVal = ( rVal ) ? VARIANT_TRUE : VARIANT_FALSE; return *this; } ComVariant& ComVariant::operator=( char rVal ) { clear(); value.vt = VT_I1; value.cVal = rVal; return *this; } ComVariant& ComVariant::operator=( unsigned char rVal ) { clear(); value.vt = VT_UI1; value.bVal = rVal; return *this; } ComVariant& ComVariant::operator=( short rVal ) { clear(); value.vt = VT_I2; value.iVal = rVal; return *this; } ComVariant& ComVariant::operator=( unsigned short rVal ) { clear(); value.vt = VT_UI2; value.uiVal = rVal; return *this; } ComVariant& ComVariant::operator=( int rVal ) { clear(); value.vt = VT_I4; value.lVal = rVal; return *this; } ComVariant& ComVariant::operator=( unsigned int rVal ) { clear(); value.vt = VT_UI4; value.ulVal = rVal; return *this; } ComVariant& ComVariant::operator=( long rVal ) { clear(); value.vt = VT_I4; value.lVal = rVal; return *this; } ComVariant& ComVariant::operator=( unsigned long rVal ) { clear(); value.vt = VT_UI4; value.ulVal = rVal; return *this; } ComVariant& ComVariant::operator=( __int64 rVal ) { clear(); value.vt = VT_I8; value.llVal = rVal; return *this; } ComVariant& ComVariant::operator=( unsigned __int64 rVal ) { clear(); value.vt = VT_UI8; value.llVal = rVal; return *this; } ComVariant& ComVariant::operator=( float rVal ) { clear(); value.vt = VT_R4; value.fltVal = rVal; return *this; } ComVariant& ComVariant::operator=( double rVal ) { clear(); value.vt = VT_R8; value.dblVal = rVal; return *this; } ComVariant& ComVariant::operator=( const CY &rVal ) { clear(); value.vt = VT_CY; value.cyVal = rVal; return *this; } ComVariant& ComVariant::operator=( const FILETIME &rVal ) { clear(); value.vt = VT_DATE; SYSTEMTIME st; if( ! :: FileTimeToSystemTime( &rVal, &st ) ) { //FRL_THROW_SYSAPI_S(); } if( ! ::SystemTimeToVariantTime( &st, &value.date ) ) { //FRL_THROW_S(); } return *this; } ComVariant& ComVariant::operator=( const string_t& rVal ) { clear(); value.vt = VT_BSTR; #if( UNICODE ) value.bstrVal = SysAllocString( rVal.c_str() ); #else value.bstrVal = SysAllocString( widen( rVal ).c_str() ); #endif return *this; } ComVariant& ComVariant::operator=( const VARIANT& rVal ) { clear(); variantCopy( &value, &rVal ); return *this; } //Variant::operator bool() const //{ // BOOST_ASSERT( value.vt == VT_BOOL ); // return ( value.boolVal ) ? true : false; //} //Variant::operator char() const //{ // BOOST_ASSERT( value.vt == VT_I1 ); // return value.cVal; //} //Variant::operator unsigned char() const //{ // BOOST_ASSERT( value.vt == VT_UI1 ); // return value.bVal; //} //Variant::operator short() const //{ // BOOST_ASSERT( value.vt == VT_I2 ); // return value.iVal; //} //Variant::operator unsigned short() const //{ // BOOST_ASSERT( value.vt == VT_UI2 ); // return value.uiVal; //} //Variant::operator int() const //{ // BOOST_ASSERT( value.vt == VT_I4 ); // return value.lVal; //} //Variant::operator unsigned int() const //{ // BOOST_ASSERT( value.vt == VT_UI4 ); // return ( unsigned int )value.ullVal; //} //Variant::operator long() const //{ // BOOST_ASSERT( value.vt == VT_I4 ); // return value.lVal; //} //Variant::operator unsigned long() const //{ // BOOST_ASSERT( value.vt == VT_UI4 ); // return value.ulVal; //} //Variant::operator __int64() const //{ // BOOST_ASSERT( value.vt == VT_I8 ); // return value.llVal; //} //Variant::operator unsigned __int64() const //{ // BOOST_ASSERT( value.vt == VT_UI8 ); // return value.ullVal; //} //Variant::operator float() const //{ // BOOST_ASSERT( value.vt == VT_R4 ); // return value.fltVal; //} //Variant::operator double() const //{ // BOOST_ASSERT( value.vt == VT_R8 ); // return value.dblVal; //} //Variant::operator CY() const //{ // BOOST_ASSERT( value.vt == VT_CY ); // return value.cyVal; //} //Variant::operator FILETIME() const //{ // BOOST_ASSERT( value.vt == VT_DATE ); // SYSTEMTIME st; // BOOST_ASSERT( ::VariantTimeToSystemTime( value.date, &st ) ); // FILETIME ft; // BOOST_ASSERT( ::SystemTimeToFileTime( &st, &ft ) ); // return ft; //} //Variant::operator string_t() const //{ // BOOST_ASSERT( value.vt == VT_BSTR ); // #if( UNICODE ) // return value.bstrVal; // #else // return wstring2string( value.bstrVal ); // #endif //} ComVariant::operator const VARIANT&() const { return value; } bool ComVariant::isEqual( const VARIANT &val1, const VARIANT &val2 ) { if ( val1.vt != val2.vt ) return false; switch (val1.vt) { case VT_EMPTY: return val1.vt == val2.vt; case VT_I1: return val1.cVal == val2.cVal; case VT_UI1: return val1.bVal == val2.bVal; case VT_I2: return val1.iVal == val2.iVal; case VT_UI2: return val1.uiVal == val2.uiVal; case VT_I4: return val1.lVal == val2.lVal; case VT_UI4: return val1.ulVal == val2.ulVal; case VT_I8: return val1.llVal == val2.llVal; case VT_UI8: return val1.ullVal == val2.ullVal; case VT_R4: return val1.fltVal == val2.fltVal; case VT_R8: return val1.dblVal == val2.dblVal; case VT_CY: return (val1.cyVal.int64 == val2.cyVal.int64); case VT_DATE: return val1.date == val2.date; case VT_BOOL: return val1.boolVal == val2.boolVal; case VT_BSTR: if( val1.bstrVal != NULL && val2.bstrVal != NULL ) return wcscmp(val1.bstrVal, val2.bstrVal) == 0; return ( val1.bstrVal == val2.bstrVal ); } return false; } void ComVariant::setType( VARTYPE type ) { //::VariantChangeType( &value, &value, 0, type ); ::VariantChangeType( &value, &value, VARIANT_ALPHABOOL, type ); } HRESULT ComVariant::copyTo( VARIANT &dst ) const { return ComVariant::variantCopy( dst, value ); } HRESULT ComVariant::copyTo( VARIANT *dst ) const { return ComVariant::variantCopy( dst, &value ); } string_t ComVariant::valueAsString() const { if (value.vt != VT_BSTR) { ComVariant tmp = *this; tmp.setType(VT_BSTR); return tmp.valueAsString(); } return narrow(value.bstrVal); } string_t ComVariant::typeAsString() const { return TypeAsString(value.vt); } bool ComVariant::AsBool() const { BOOST_ASSERT( value.vt == VT_BOOL ); return ( value.boolVal ) ? true : false; } char ComVariant::AsChar() const { BOOST_ASSERT( value.vt == VT_I1 ); return value.cVal; } unsigned char ComVariant::AsUChar() const { BOOST_ASSERT( value.vt == VT_UI1 ); return value.bVal; } short ComVariant::AsShort() const { BOOST_ASSERT( value.vt == VT_I2 ); return value.iVal; } unsigned short ComVariant::AsUShort() const { BOOST_ASSERT( value.vt == VT_UI2 ); return value.uiVal; } int ComVariant::AsInt() const { BOOST_ASSERT( value.vt == VT_I4 ); return value.lVal; } unsigned int ComVariant::AsUInt() const { BOOST_ASSERT( value.vt == VT_UI4 ); return ( unsigned int )value.ullVal; } long ComVariant::AsLong() const { BOOST_ASSERT( value.vt == VT_I4 ); return value.lVal; } unsigned long ComVariant::AsULong() const { BOOST_ASSERT( value.vt == VT_UI4 ); return value.ulVal; } long long ComVariant::AsLongLong() const { BOOST_ASSERT( value.vt == VT_I8 ); return value.llVal; } unsigned long long ComVariant::AsULongLong() const { BOOST_ASSERT( value.vt == VT_UI8 ); return value.ullVal; } float ComVariant::AsFloat() const { BOOST_ASSERT( value.vt == VT_R4 ); return value.fltVal; } double ComVariant::AsDouble() const { BOOST_ASSERT( value.vt == VT_R8 ); return value.dblVal; } CY ComVariant::AsCY() const { BOOST_ASSERT( value.vt == VT_CY ); return value.cyVal; } FILETIME ComVariant::AsFILETIME() const { BOOST_ASSERT( value.vt == VT_DATE ); SYSTEMTIME st; BOOST_ASSERT( ::VariantTimeToSystemTime( value.date, &st ) ); FILETIME ft; BOOST_ASSERT( ::SystemTimeToFileTime( &st, &ft ) ); return ft; } string_t ComVariant::AsString() const { BOOST_ASSERT( value.vt == VT_BSTR ); #if( UNICODE ) return value.bstrVal; #else return narrow( value.bstrVal ); #endif }
6524e4d64aa39d44b2068ef882dee846ae3fb265
9b755c63514867f4d6c47a061db180d99c83b7d9
/src/homework/tic_tac_toe/tic_tac_toe_manager.h
02837ace385f4593a935906e2da0b3a88adad3f8
[ "MIT" ]
permissive
acc-cosc-1337-spring-2020/acc-cosc-1337-spring-2020-connorstack1891
6e95f9b714c48fd4bbbdc5e613c4f4c7b42c32dc
ba03e746a61491a43e7483e95ddf8435d19b67ae
refs/heads/master
2020-12-20T01:12:19.997261
2020-05-12T23:39:35
2020-05-12T23:39:35
235,910,226
0
0
null
null
null
null
UTF-8
C++
false
false
626
h
tic_tac_toe_manager.h
//h #include "tic_tac_toe.h" //include <iostream> #ifndef MANAGER_H #define MANAGER_H #include <memory> #include "tic_tac_toe_data.h" class TicTacToeManager { public: TicTacToeManager() = default; void save_game(std::unique_ptr<Game> &b); friend std::ostream& operator<<(std::ostream& out, const TicTacToeManager & manager); void get_winner_total(int& o, int& w, int& t); //~TicTacToeManager(); private: std::vector<std::unique_ptr<Game>>games{}; int x_win{ 0 }; int o_win{ 0 }; int ties{ 0 }; void update_winner_count(std::string winner); }; #endif //std::vector<std::reference_wrapper<Game>> games;
0c109994aa85425f88c3263571255cae9a7a922e
94143c13148e4124575b4525fbb12719e5071a4e
/src/sequential_heap.cpp
5ff52c40ec940639ceecde88427df738e55cbd22
[]
no_license
shubhammitt/Accelerating-Concurrent-Heap-On-GPU
eb94365671a159449336ef924f68e56ccff8fa78
345a2b6f7761ace807b671ebbf7bd0d641a4f103
refs/heads/master
2023-08-21T22:17:41.514785
2021-10-21T13:05:40
2021-10-21T13:05:40
399,451,022
0
1
null
null
null
null
UTF-8
C++
false
false
1,741
cpp
sequential_heap.cpp
/* * Author: Shubham Mittal * IIITD, 2018101 * GPU Project: Accelerating Concurrent Heap on GPUs */ #include "sequential_heap.h" CPU_Heap::CPU_Heap(int _capacity) { capacity = _capacity + 1; arr = new int[capacity]; size = 0; } bool CPU_Heap::is_full() { return size + 1 == capacity; } bool CPU_Heap::is_empty() { return size == 0; } void CPU_Heap::push(int key) { if (is_full()) { cout << "Heap Full!\n"; return; } ++size; int par = size >> 1; int child = size; arr[child] = key; while(child != 1) { if(arr[par] <= arr[child]) return; swap(arr[par], arr[child]); child = par; par >>= 1; } } int CPU_Heap::pop() { if (is_empty()) { cout << "Heap empty!"; return -1; } int key = arr[1]; arr[1] = arr[size--]; int par = 1; int left_child = par << 1; int right_child = left_child + 1; int idx = 0; while(left_child <= size) { idx = left_child; if(right_child <= size and arr[left_child] > arr[right_child]) idx = right_child; if(arr[par] > arr[idx]) { swap(arr[par], arr[idx]); par = idx; left_child = par << 1; right_child = left_child + 1; } else break; } return key; } // int main(int argc, char *argv[]) { // int n = 5; // if(argc > 1) n = atoi(argv[1]); // CPU_Heap obj(n); // for(int i = 0 ; i < n; i++) { // int x = rand() % 10; // obj.push(x); // cout << x << " "; // } // cout << "\n"; // for(int i = 0; i < n ; i++) { // cout << obj.pop() << " "; // } // cout << "\n"; // }
25564125252c152dce5a444001efa9daf612fe6c
102beccb4a386876dfeaea493209537c9a0db742
/TelepathyIMModule/TelepathyIM/GMainLoopThread.cpp
04b5f55172ef87e6df869dad941e5a28b39a257a
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
Chiru/naali
cc4150241d37849dde1b9a1df983e41a53bfdab1
b0fb756f6802ac09a7cd9733e24e4db37d5c1b7e
refs/heads/master
2020-12-25T05:03:47.606650
2010-09-16T14:08:42
2010-09-17T08:34:19
1,290,932
1
1
null
null
null
null
UTF-8
C++
false
false
751
cpp
GMainLoopThread.cpp
// For conditions of distribution and use, see copyright notice in license.txt #include "StableHeaders.h" #include "DebugOperatorNew.h" #include "GMainLoopThread.h" #include "MemoryLeakCheck.h" namespace TelepathyIM { GMainLoopThread::GMainLoopThread() { g_main_loop_ = g_main_loop_new (NULL, FALSE); } void GMainLoopThread::run() { LogDebug("g_main_loop started."); try { g_main_loop_run (g_main_loop_); } catch(...) { LogError("EXCEPTION inside gmainloop!"); } LogDebug("g_main_loop ended."); } void GMainLoopThread::StopLoop() { g_main_loop_quit(g_main_loop_); } } // end of namespace: TelepathyIM
181c1902969a481d1291081084a375af0469d71d
8f0c928a727c2b287a76a0e6fd107d4080a4cf39
/generic-ros-catkin-cplusplus-services-cmake-example/src/server.cpp
1cf7d683591e10ed55da2eb8b58f94964b87ecae
[ "MIT" ]
permissive
nikolausmayer/cmake-templates
d3194a108334ff89ef9b13df015f7d2bdd6fde9d
50f4253d3a72a24084a7bfbf3de0d7e3c11af860
refs/heads/master
2020-12-24T17:35:24.296994
2019-09-12T08:39:45
2019-09-12T08:39:45
31,466,186
53
18
null
null
null
null
UTF-8
C++
false
false
907
cpp
server.cpp
#include <string> // ROS #include <ros/ros.h> #include <std_msgs/String.h> // THIS PACKAGE'S SERVICES #include "generic_package/GenericService.h" bool genericServiceCallback(generic_package::GenericService::Request &request, generic_package::GenericService::Response &response) { ROS_INFO("GenericService server got request: \"%s\"", request.request_string.c_str()); response.response_string = "EHLO back from server!"; return true; } int main(int argc, char** argv) { ros::init(argc, argv, "generic_server"); ROS_INFO("generic_server initialized"); ros::NodeHandle nh; ros::ServiceServer server = nh.advertiseService("generic_service_server", genericServiceCallback); ros::spin(); /// Tidy up ROS_INFO("generic_server exiting..."); ros::shutdown(); /// Bye! return EXIT_SUCCESS; }
9e486d0f4b723b8b6226a2e3fea059ba1876b470
0af8311127fad8d854b2e4b9c80f2a20d95663d1
/map2.cpp
1182f2d12e6b933fcffcba06935af9220e7aeb2f
[]
no_license
RakibulIslamRakib/Data_Structure_in_c-
2a8bc35b4685447e12ee75b2762cb9d61b98b873
61e4803e47921e4fc59357b9d053399ebbe04580
refs/heads/master
2021-06-25T04:21:51.081608
2021-04-11T09:28:27
2021-04-11T09:28:27
215,605,728
1
0
null
null
null
null
UTF-8
C++
false
false
670
cpp
map2.cpp
#include <bits/stdc++.h> using namespace std; map<string,string>mp; vector<string>v; map<string,string>::iterator it; bool isvalid(string email){ int len = email.size(),indx=0; bool valid = true; string s="@gmail.com"; for(int i=len-10;i<len;i++){ if(email[i]!=s[indx++]){ valid = false; } } return valid; } int main() { int n;cin>>n; string name,email; for(int i=0;i<n;i++){ cin>>name>>email; if(isvalid(email)){ mp[email]=name; } } for(it = mp.begin();it!=mp.end();it++){ v.push_back(it->second); } sort(v.begin(),v.end()); for(int i=0;i<v.size();i++){ cout<<v[i]<<endl; } }
bb657a899f77dd5b0a67b0d17c0485dc9c578c58
3580c727e8845175dee5feee9fa82fabeaea91d0
/direct/Transceivers/GenomeTransceiver.h
cfeb13140f94f6f1c162a5be55d36d39e65d4a6b
[]
no_license
karinemiras/evolvable_morphologies
51b187f63061baff9d91c155501058d89d1a130e
1a63eb614ea7f7e3e18184bc2f545400b2049eb2
refs/heads/master
2021-01-20T02:33:42.057479
2018-01-04T13:28:18
2018-01-04T13:28:18
83,816,888
1
1
null
2017-05-16T12:57:19
2017-03-03T16:11:28
C++
UTF-8
C++
false
false
456
h
GenomeTransceiver.h
// // GenomeTransceiver.h // RobotController // // Created by Berend Weel on 10/04/15. // Copyright (c) 2015 Berend Weel. All rights reserved. // #ifndef __RobotController__GenomeTransceiver__ #define __RobotController__GenomeTransceiver__ class GenomeTransceiver { public: virtual void broadcastGenome() = 0; virtual void receive() = 0; virtual void step() = 0; }; #endif /* defined(__RobotController__GenomeTransceiver__) */
2f881121aa90fde3464d958c7a8d3970d54f1353
70dac8aa405f41a2ec46b9317307ef7df850c233
/CuentaLargoPlazo.h
2fc04e4d4196a025f32b71544f576ca4f824cba8
[]
no_license
6abriel1chiro/cpp-oop-bank-system
77879563d0d12e76bab9a0e59ed643b819e17ae4
3e8db761668e8473dbc24a3bf1a7fed88ba9a70a
refs/heads/main
2023-03-30T10:45:33.600650
2021-03-30T04:59:23
2021-03-30T04:59:23
352,874,873
0
0
null
null
null
null
UTF-8
C++
false
false
395
h
CuentaLargoPlazo.h
#pragma once #include "Cuenta.h" class CuentaLargoPlazo : public Cuenta { private: string fechaIni; string fechaFin; float interesAnual; public: CuentaLargoPlazo(string id, float saldo,string moneda, string fechaIni, string fechaFin, float interesAnual); ~CuentaLargoPlazo(); void actualizacion(); void opciones(); void mostrar(); };
5f2f14b9251ab5c20c867df85cf38824189b6053
0cfb43cd7ead4fefa9babc41b5b0c49b857134e5
/Game.cpp
a01c6d374ca93365d01bb3dac87a4db8d44bc824
[]
no_license
GaliaGrayevsky/OOD-Final-Project
1b7877673362aa0015464723dab221e5d15d2dcc
b8b16e2eded97671cd501d7515432bd348bf0bd9
refs/heads/master
2022-11-19T05:14:31.589944
2020-07-18T04:24:08
2020-07-18T04:24:08
280,105,624
0
0
null
null
null
null
UTF-8
C++
false
false
11,428
cpp
Game.cpp
#include "Game.h" #include <iostream> #include "InitGameState.h" #include "PlayTurnGameState.h" #include "CheckGameState.h" #include "EndGameState.h" CGame::CGame() { m_semaphore = new CSemaphore(); m_gameState[INIT_STATE] = new CInitGameState(); m_gameState[PLAY_TURN_STATE] = new CPlayTurnGameState(); m_gameState[CHECK_GAME_STATE] = new CCheckGameState(); m_gameState[WIN_GAME_STATE] = new CEndGameState(); m_gameState[END_GAME_STATE] = new CEndGameState(); m_player1 = NULL; m_player2 = NULL; } void CGame::InitGame(CGameController* a_gameController) { m_gameController = a_gameController; } void CGame::InitGameUpdate() { GAME_STATUS gameStatus; BuildGameStatus(gameStatus); // Notify GameController m_gameController->UpdateGameStatus(gameStatus); } int CGame::PlayAGame() { // Init Board m_board.InitBoard(); SetState(INIT_STATE); while(m_currentState != END_GAME_STATE) { m_gameState[m_currentState]->HandleStateActivity(this); } printf("DBG: Ended game!\n"); return 0; } void CGame::ExecuteTurn(PLAYER_e a_player, int a_dstCol) { CDisc* disc = new CDisc(); disc->SetDiscParams(a_player); m_board.SetDiscInPlace(*disc, a_dstCol); m_semaphore->notify(); } void CGame::BuildGameStatus(GAME_STATUS& a_gameStatus) { a_gameStatus.state = m_currentState; m_board.GetBoardState(a_gameStatus.bord); a_gameStatus.colorTurn = m_currentPlayerTurn; } void CGame::SetState(GAME_STATE_e a_gameState) { m_currentState = a_gameState; } bool CGame::CheckIsThereAWinner() { bool WinnerFound = false; PLAYER_e WinningPlayer; BOARD_SNAPSHOT board; int a_startRaw = 0; int a_endRaw = 0; int a_startCol = 0; int a_endCol = 0; m_board.GetBoardState(board); for (int rawIdx = 0; rawIdx < NUM_RAW; rawIdx++) { // Check Raws if (WinnerFound = CheckOneRaw(board, rawIdx, 0, RAW, WinningPlayer, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; // Check Left Diagonals if (rawIdx > 2) { if (WinnerFound = CheckOneRaw(board, rawIdx, 0, DIAG_LEFT, WinningPlayer, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; } // Check Right Diagonals if (rawIdx < 3) { if (WinnerFound = CheckOneRaw(board, rawIdx, 0, DIAG_RIGHT, WinningPlayer, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; } } if (false == WinnerFound) { for (int colIdx = 0; colIdx < NUM_COL; colIdx++) { // Check Columns if (WinnerFound = CheckOneRaw(board, 0, colIdx, COL, WinningPlayer, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; // Check Left Diagonals if (colIdx < 4) { if (WinnerFound = CheckOneRaw(board, NUM_RAW - 1, colIdx, DIAG_LEFT, WinningPlayer, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; } // Check Right Diagonals if (colIdx < 4) { if (WinnerFound = CheckOneRaw(board, 0, colIdx, DIAG_RIGHT, WinningPlayer, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; } } } return WinnerFound; } bool CGame::CheckOneRaw(BOARD_SNAPSHOT& a_bord, int a_raw, int a_col, ORIENTATION_e a_orientation, PLAYER_e& a_color, int& a_startRaw, int& a_endRaw, int& a_startCol, int& a_endCol) { int ColStep = 0; int RawStep = 0; int maxCol = 0; int maxRaw = 0; switch (a_orientation) { case RAW: RawStep = 0; maxRaw = a_raw+1; ColStep = 1; maxCol = NUM_COL; break; case COL: RawStep = 1; maxRaw = NUM_RAW; ColStep = 0; maxCol = a_col+1; break; case DIAG_LEFT: RawStep = -1; maxRaw = 0; ColStep = 1; maxCol = NUM_COL; break; case DIAG_RIGHT: RawStep = 1; maxRaw = NUM_RAW; ColStep = 1; maxCol = NUM_COL; break; } int counter = 0; PLAYER_e currentPlayer; int rawIdx = a_raw; int colIdx = a_col; while (rawIdx != maxRaw && colIdx != maxCol) { if (true == a_bord.disc[rawIdx][colIdx].taken) { if (counter == 0) { currentPlayer = a_bord.disc[rawIdx][colIdx].player; a_startRaw = rawIdx; a_startCol = colIdx; counter++; } else { if (currentPlayer == a_bord.disc[rawIdx][colIdx].player) { counter++; } else { currentPlayer = a_bord.disc[rawIdx][colIdx].player; counter = 1; a_startRaw = rawIdx; a_startCol = colIdx; } if (counter == 4) { a_color = currentPlayer; a_endRaw = rawIdx; a_endCol = colIdx; printf("\n #### WE HAVE A WINNER!!! %s IS THE WINNER!!! #### \n", currentPlayer == PLAYER1 ? "PLAYER1" : "PLAYER2"); printf("\n #### Index (%d,%d)-(%d,%d) #### \n", a_startRaw, a_startCol, a_endRaw, a_endCol); return true; } } } else { counter = 0; } rawIdx += RawStep; colIdx += ColStep; } return false; } void CGame::InitGameAck(int m_numManPlayers, PLAYER_LEVEL_e a_gameLevel) { switch (m_numManPlayers) { case 0: CPlayerAuto * playerAuto1 = new CPlayerAuto(a_gameLevel); playerAuto1->InitPlayer(PLAYER1); CPlayerAuto* playerAuto2 = new CPlayerAuto(a_gameLevel); playerAuto2->InitPlayer(PLAYER2); m_gameController->SetPlayers(playerAuto1, playerAuto2); break; case 1: CPlayerManual* playerMan1 = new CPlayerManual(); playerMan1->InitPlayer(PLAYER1); CPlayerAuto* playerAuto1 = new CPlayerAuto(a_gameLevel); playerAuto1->InitPlayer(PLAYER2); m_gameController->SetPlayers(playerMan1, playerAuto1); break; case 2: CPlayerManual * playerMan1 = new CPlayerManual(); playerMan1->InitPlayer(PLAYER1); CPlayerManual* playerMan2 = new CPlayerManual(); playerMan2->InitPlayer(PLAYER2); m_gameController->SetPlayers(playerMan1, playerMan2); break; default: CPlayerAuto* playerAuto1 = new CPlayerAuto(a_gameLevel); playerAuto1->InitPlayer(PLAYER1); CPlayerAuto* playerAuto2 = new CPlayerAuto(a_gameLevel); playerAuto2->InitPlayer(PLAYER2); m_gameController->SetPlayers(playerAuto1, playerAuto2); break; } } /* OLD OLD #include "Game.h" #include <iostream> #include "InitGameState.h" #include "PlayTurnGameState.h" #include "CheckGameState.h" #include "EndGameState.h" CGame::CGame() { m_semaphore = new CSemaphore(); m_gameState[INIT_STATE] = new CInitGameState(); m_gameState[PLAY_TURN_STATE] = new CPlayTurnGameState(); m_gameState[CHECK_GAME_STATE] = new CCheckGameState(); m_gameState[END_GAME_STATE] = new CEndGameState(); m_numRegistered = 0; } void CGame::InitGame() { // Notify GameController } int CGame::PlayAGame() { if (m_numRegistered != MAX_NUM_PLAYERS) { printf("StartNewGame FAILED. Only %d players registered!", m_numRegistered); return NOT_OK; } // Init Bord m_bord.InitBord(); GAME_STATE gameState; // Play turns until one of the players win or the bord is full while (false == m_bord.IsBordFull()) { m_bord.GetBordState(gameState.bord); gameState.colorTurn = m_currentColorTurn; for (int i = 0; i < MAX_NUM_PLAYERS; i++) { m_registeredObservers[i]->Notify(gameState); } m_semaphore->wait(); // Check game after playing m_bord.PrintBord(); // TEMP if (true == CheckIsThereAWinner()) { // NOTIFY PLAYERS! break; } m_currentColorTurn = COLOR_e((m_currentColorTurn + 1) % NUM_COLORS); } printf("\n *************GAME OVER***************\n"); return 0; } void CGame::ExecuteTurn(COLOR_e a_color, int a_dstCol) { CDisc* disc = new CDisc(); disc->SetDiscParams(a_color); m_bord.SetDiscInPlace(*disc, a_dstCol); m_semaphore->notify(); } RETCODE_e CGame::RegisterToSubject(IGameObserver* a_observer) { if (m_numRegistered >= 0 && m_numRegistered < MAX_NUM_PLAYERS) { m_registeredObservers[m_numRegistered] = a_observer; m_numRegistered++; return OK; } return NOT_OK; } void CGame::SetState(GAME_STATE_e a_gameState) { m_currentState = a_gameState; } bool CGame::CheckIsThereAWinner() { bool WinnerFound = false; COLOR_e WinningColor; BORD_STATE bord; int a_startRaw = 0; int a_endRaw = 0; int a_startCol = 0; int a_endCol = 0; m_bord.GetBordState(bord); for (int rawIdx = 0; rawIdx < NUM_RAW; rawIdx++) { // Check Raws if (WinnerFound = CheckOneRaw(bord, rawIdx, 0, RAW, WinningColor, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; // Check Left Diagonals if (rawIdx > 2) { if (WinnerFound = CheckOneRaw(bord, rawIdx, 0, DIAG_LEFT, WinningColor, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; } // Check Right Diagonals if (rawIdx < 3) { if (WinnerFound = CheckOneRaw(bord, rawIdx, 0, DIAG_RIGHT, WinningColor, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; } } if (false == WinnerFound) { for (int colIdx = 0; colIdx < NUM_COL; colIdx++) { // Check Columns if (WinnerFound = CheckOneRaw(bord, 0, colIdx, COL, WinningColor, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; // Check Left Diagonals if (colIdx < 4) { if (WinnerFound = CheckOneRaw(bord, NUM_RAW - 1, colIdx, DIAG_LEFT, WinningColor, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; } // Check Right Diagonals if (colIdx < 4) { if (WinnerFound = CheckOneRaw(bord, 0, colIdx, DIAG_RIGHT, WinningColor, a_startRaw, a_endRaw, a_startCol, a_endCol) == true) break; } } } return WinnerFound; } bool CGame::CheckOneRaw(BORD_STATE& a_bord, int a_raw, int a_col, ORIENTATION_e a_orientation, COLOR_e& a_color, int& a_startRaw, int& a_endRaw, int& a_startCol, int& a_endCol) { int ColStep = 0; int RawStep = 0; int maxCol = 0; int maxRaw = 0; switch (a_orientation) { case RAW: RawStep = 0; maxRaw = a_raw + 1; ColStep = 1; maxCol = NUM_COL; break; case COL: RawStep = 1; maxRaw = NUM_RAW; ColStep = 0; maxCol = a_col + 1; break; case DIAG_LEFT: RawStep = -1; maxRaw = 0; ColStep = 1; maxCol = NUM_COL; break; case DIAG_RIGHT: RawStep = 1; maxRaw = NUM_RAW; ColStep = 1; maxCol = NUM_COL; break; } int counter = 0; COLOR_e currentColor; int rawIdx = a_raw; int colIdx = a_col; while (rawIdx != maxRaw && colIdx != maxCol) { if (true == a_bord.disc[rawIdx][colIdx].taken) { if (counter == 0) { currentColor = a_bord.disc[rawIdx][colIdx].color; a_startRaw = rawIdx; a_startCol = colIdx; counter++; } else { if (currentColor == a_bord.disc[rawIdx][colIdx].color) { counter++; } else { currentColor = a_bord.disc[rawIdx][colIdx].color; counter = 1; a_startRaw = rawIdx; a_startCol = colIdx; } if (counter == 4) { a_color = currentColor; a_endRaw = rawIdx; a_endCol = colIdx; printf("\n #### WE HAVE A WINNER!!! %s IS THE WINNER!!! #### \n", currentColor == BLACK ? "BLACK" : "WHITE"); printf("\n #### Index (%d,%d)-(%d,%d) #### \n", a_startRaw, a_startCol, a_endRaw, a_endCol); return true; } } } else { counter = 0; } rawIdx += RawStep; colIdx += ColStep; } return false; } */
13316404a867296464b84e141f5390832bf72750
8b9d62f665770666e11079cbfcaf133f4ad4e19c
/hazelcast/include/hazelcast/client/internal/nearcache/impl/store/HeapNearCacheRecordMap.h
9945883138a42ce7d47a63a4661f1266d37a150f
[ "Apache-2.0" ]
permissive
ihsandemir/hazelcast-cpp-client
d30fee3a8f421d50f3f3e1cffbcd60d014c6e418
cef6d68e47afb9ab91a3c73d2c8da9c08bf5d868
refs/heads/master
2023-08-17T15:27:35.847711
2023-08-14T17:56:02
2023-08-14T17:56:02
45,042,631
0
1
Apache-2.0
2020-03-26T13:12:22
2015-10-27T13:25:02
C++
UTF-8
C++
false
false
8,869
h
HeapNearCacheRecordMap.h
/* * Copyright (c) 2008-2023, Hazelcast, Inc. 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. */ #pragma once #include <stdint.h> #include "hazelcast/client/internal/eviction/Evictable.h" #include "hazelcast/client/internal/nearcache/impl/SampleableNearCacheRecordMap.h" #include "hazelcast/client/serialization/serialization.h" #include "hazelcast/util/SampleableConcurrentHashMap.h" #include "hazelcast/client/internal/eviction/EvictionCandidate.h" #include "hazelcast/client/internal/eviction/EvictionListener.h" #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) #pragma warning(push) #pragma warning(disable : 4251) // for dll export #endif namespace hazelcast { namespace client { namespace internal { namespace nearcache { namespace impl { namespace store { /** * @param R A type that extends NearCacheRecord */ template<typename K, typename V, typename KS, typename R> class HeapNearCacheRecordMap : public util::SampleableConcurrentHashMap<K, V, KS, R> , public SampleableNearCacheRecordMap<K, V, KS, R> { public: typedef eviction::EvictionCandidate<K, V, KS, R> C; HeapNearCacheRecordMap(serialization::pimpl::SerializationService& ss, int32_t initial_capacity) : util::SampleableConcurrentHashMap<K, V, KS, R>(initial_capacity) , serialization_service_(ss) {} ~HeapNearCacheRecordMap() override = default; class NearCacheEvictableSamplingEntry : public util::SampleableConcurrentHashMap<K, V, KS, R>::SamplingEntry , public C { public: NearCacheEvictableSamplingEntry( const std::shared_ptr<KS>& key, const std::shared_ptr<R>& value, serialization::pimpl::SerializationService& ss) : util::SampleableConcurrentHashMap<K, V, KS, R>::SamplingEntry(key, value) , serialization_service_(ss) {} ~NearCacheEvictableSamplingEntry() override = default; std::shared_ptr<KS> get_accessor() const override { return util::SampleableConcurrentHashMap<K, V, KS, R>:: SamplingEntry::key_; } std::shared_ptr<R> get_evictable() const override { return util::SampleableConcurrentHashMap<K, V, KS, R>:: SamplingEntry::value_; } std::shared_ptr<K> get_key() const override { return serialization_service_.to_shared_object<K>( util::SampleableConcurrentHashMap<K, V, KS, R>::SamplingEntry:: key_); } std::shared_ptr<V> get_value() const override { return std::shared_ptr<V>( serialization_service_.to_shared_object<V>( util::SampleableConcurrentHashMap<K, V, KS, R>::SamplingEntry:: value_->get_value())); } int64_t get_creation_time() const override { return util::SampleableConcurrentHashMap<K, V, KS, R>:: SamplingEntry::value_->get_creation_time(); } int64_t get_last_access_time() const override { return util::SampleableConcurrentHashMap<K, V, KS, R>:: SamplingEntry::value_->get_last_access_time(); } int64_t get_access_hit() const override { return util::SampleableConcurrentHashMap<K, V, KS, R>:: SamplingEntry::value_->get_access_hit(); } private: serialization::pimpl::SerializationService& serialization_service_; }; int evict(std::vector<std::shared_ptr<C>>* eviction_candidates, eviction::EvictionListener<KS, R>* eviction_listener) override { if (eviction_candidates == NULL) { return 0; } int actualEvictedCount = 0; for (typename std::vector<std::shared_ptr<C>>::const_iterator it = eviction_candidates->begin(); it != eviction_candidates->end(); ++it) { const std::shared_ptr<C>& evictionCandidate = *it; if (util::SynchronizedMap<std::shared_ptr<KS>, R>::remove( evictionCandidate->get_accessor()) .get() != NULL) { actualEvictedCount++; if (eviction_listener != NULL) { eviction_listener->on_evict( evictionCandidate->get_accessor(), evictionCandidate->get_evictable(), false); } } } return actualEvictedCount; } std::unique_ptr<util::Iterable<eviction::EvictionCandidate<K, V, KS, R>>> sample(int32_t sample_count) const { std::unique_ptr<util::Iterable< typename util::SampleableConcurrentHashMap<K, V, KS, R>::E>> samples = util::SampleableConcurrentHashMap<K, V, KS, R>::get_random_samples( sample_count); if (NULL == samples.get()) { return std::unique_ptr< util::Iterable<eviction::EvictionCandidate<K, V, KS, R>>>(); } return std::unique_ptr< util::Iterable<eviction::EvictionCandidate<K, V, KS, R>>>( new EvictionCandidateAdapter(samples)); } class EvictionCandidateAdapter : public util::Iterable<eviction::EvictionCandidate<K, V, KS, R>> { public: EvictionCandidateAdapter( std::unique_ptr<util::Iterable< typename util::SampleableConcurrentHashMap<K, V, KS, R>::E>>& samples_iterable) : adapted_iterable_(std::move(samples_iterable)) { adapted_iterator_ = std::unique_ptr< util::Iterator<eviction::EvictionCandidate<K, V, KS, R>>>( new EvictionCandidateIterator(*adapted_iterable_->iterator())); } class EvictionCandidateIterator : public util::Iterator<eviction::EvictionCandidate<K, V, KS, R>> { public: EvictionCandidateIterator( util::Iterator< typename util::SampleableConcurrentHashMap<K, V, KS, R>::E>& adapted_iterator) : it_(adapted_iterator) {} bool has_next() override { return it_.has_next(); } std::shared_ptr<eviction::EvictionCandidate<K, V, KS, R>> next() override { std::shared_ptr< typename util::SampleableConcurrentHashMap<K, V, KS, R>::E> obj = it_.next(); std::shared_ptr<NearCacheEvictableSamplingEntry> heapObj = std::static_pointer_cast<NearCacheEvictableSamplingEntry>( obj); return std::static_pointer_cast< eviction::EvictionCandidate<K, V, KS, R>>(heapObj); } void remove() override { it_.remove(); } private: util::Iterator< typename util::SampleableConcurrentHashMap<K, V, KS, R>::E>& it_; }; util::Iterator<eviction::EvictionCandidate<K, V, KS, R>>* iterator() override { return adapted_iterator_.get(); } private: std::unique_ptr<util::Iterable< typename util::SampleableConcurrentHashMap<K, V, KS, R>::E>> adapted_iterable_; std::unique_ptr< util::Iterator<eviction::EvictionCandidate<K, V, KS, R>>> adapted_iterator_; }; protected: std::shared_ptr< typename util::SampleableConcurrentHashMap<K, V, KS, R>::SamplingEntry> create_sampling_entry(std::shared_ptr<KS>& key, std::shared_ptr<R>& value) const override { return std::shared_ptr< typename util::SampleableConcurrentHashMap<K, V, KS, R>:: SamplingEntry>(new NearCacheEvictableSamplingEntry( key, value, serialization_service_)); } private: serialization::pimpl::SerializationService& serialization_service_; }; } // namespace store } // namespace impl } // namespace nearcache } // namespace internal } // namespace client } // namespace hazelcast #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) #pragma warning(pop) #endif
1615d104f84a4f4887e7251fabdba09aa2e8ef4c
6ae89591b5498836415b6389cbd7c2705896d012
/GeeksForGeeks/Graph/Graph_and_its_representations/Graph_and_its_representations/main.cpp
49df7f761db53117ee6ecb7b3e31b8f9f5a5986e
[]
no_license
Developer199239/C-Programming
7ba2858ad2d447d72a7cc1e142f602b766ec1f9b
0ee8bdf63b47880d5c34a6f5716545637cc76952
refs/heads/master
2020-03-27T19:47:27.570650
2019-09-03T18:54:40
2019-09-03T18:54:40
147,011,482
0
0
null
null
null
null
UTF-8
C++
false
false
886
cpp
main.cpp
// // main.cpp // Graph_and_its_representations // // Created by MURTUZA on 26/4/19. // Copyright © 2019 MURTUZA. All rights reserved. // #include <iostream> #include <vector> #include <stdio.h> using namespace std; void addEdge(vector<int>adj[],int u, int v) { adj[u].push_back(v); adj[v].push_back(u); } void printGraph(vector<int>adj[],int vertices) { for(int v = 0; v<vertices; v++) { cout<<"Adjecenecy list of vertex "<<v<<endl; for(int i = 0; i<adj[v].size(); i++) { cout<<adj[v][i]<<" "; } cout<<endl; } } int main(int argc, const char * argv[]) { int V = 5; vector<int> adj[V]; addEdge(adj, 0, 1); addEdge(adj, 0, 4); addEdge(adj, 1, 2); addEdge(adj, 1, 3); addEdge(adj, 1, 4); addEdge(adj, 2, 3); addEdge(adj, 3, 4); printGraph(adj,V); return 0; }
d79e5e89eb7e96a200bd56accaf84769ec79e4f5
d932716790743d0e2ae7db7218fa6d24f9bc85dc
/chrome/browser/ui/views/omnibox/omnibox_result_view.cc
aff68fc9c801574b0e5d4e3d531f17d431fe392f
[ "BSD-3-Clause" ]
permissive
vade/chromium
c43f0c92fdede38e8a9b858abd4fd7c2bb679d9c
35c8a0b1c1a76210ae000a946a17d8979b7d81eb
refs/heads/Syphon
2023-02-28T00:10:11.977720
2017-05-24T16:38:21
2017-05-24T16:38:21
80,049,719
19
3
null
2017-05-24T19:05:34
2017-01-25T19:31:53
null
UTF-8
C++
false
false
33,270
cc
omnibox_result_view.cc
// Copyright (c) 2012 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. // For WinDDK ATL compatibility, these ATL headers must come first. #include "build/build_config.h" #if defined(OS_WIN) #include <atlbase.h> // NOLINT #include <atlwin.h> // NOLINT #endif #include "base/macros.h" #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" #include <limits.h> #include <algorithm> // NOLINT #include "base/i18n/bidi_line_iterator.h" #include "base/metrics/field_trial_params.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" #include "chrome/grit/generated_resources.h" #include "components/grit/components_scaled_resources.h" #include "components/omnibox/browser/omnibox_field_trial.h" #include "components/omnibox/browser/omnibox_popup_model.h" #include "components/omnibox/browser/vector_icons.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/material_design/material_design_controller.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/image/image.h" #include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/range/range.h" #include "ui/gfx/render_text.h" #include "ui/gfx/text_utils.h" #include "ui/native_theme/native_theme.h" using ui::NativeTheme; namespace { // The padding that should be placed between content and description in a // vertical layout. static const int kVerticalPadding = 3; // A mapping from OmniboxResultView's ResultViewState/ColorKind types to // NativeTheme colors. struct TranslationTable { ui::NativeTheme::ColorId id; OmniboxResultView::ResultViewState state; OmniboxResultView::ColorKind kind; } static const kTranslationTable[] = { { NativeTheme::kColorId_ResultsTableNormalBackground, OmniboxResultView::NORMAL, OmniboxResultView::BACKGROUND }, { NativeTheme::kColorId_ResultsTableHoveredBackground, OmniboxResultView::HOVERED, OmniboxResultView::BACKGROUND }, { NativeTheme::kColorId_ResultsTableSelectedBackground, OmniboxResultView::SELECTED, OmniboxResultView::BACKGROUND }, { NativeTheme::kColorId_ResultsTableNormalText, OmniboxResultView::NORMAL, OmniboxResultView::TEXT }, { NativeTheme::kColorId_ResultsTableHoveredText, OmniboxResultView::HOVERED, OmniboxResultView::TEXT }, { NativeTheme::kColorId_ResultsTableSelectedText, OmniboxResultView::SELECTED, OmniboxResultView::TEXT }, { NativeTheme::kColorId_ResultsTableNormalDimmedText, OmniboxResultView::NORMAL, OmniboxResultView::DIMMED_TEXT }, { NativeTheme::kColorId_ResultsTableHoveredDimmedText, OmniboxResultView::HOVERED, OmniboxResultView::DIMMED_TEXT }, { NativeTheme::kColorId_ResultsTableSelectedDimmedText, OmniboxResultView::SELECTED, OmniboxResultView::DIMMED_TEXT }, { NativeTheme::kColorId_ResultsTableNormalUrl, OmniboxResultView::NORMAL, OmniboxResultView::URL }, { NativeTheme::kColorId_ResultsTableHoveredUrl, OmniboxResultView::HOVERED, OmniboxResultView::URL }, { NativeTheme::kColorId_ResultsTableSelectedUrl, OmniboxResultView::SELECTED, OmniboxResultView::URL }, }; struct TextStyle { ui::ResourceBundle::FontStyle font; ui::NativeTheme::ColorId colors[OmniboxResultView::NUM_STATES]; gfx::BaselineStyle baseline; }; // Returns the styles that should be applied to the specified answer text type. // // Note that the font value is only consulted for the first text type that // appears on an answer line, because RenderText does not yet support multiple // font sizes. Subsequent text types on the same line will share the text size // of the first type, while the color and baseline styles specified here will // always apply. The gfx::INFERIOR baseline style is used as a workaround to // produce smaller text on the same line. The way this is used in the current // set of answers is that the small types (TOP_ALIGNED, DESCRIPTION_NEGATIVE, // DESCRIPTION_POSITIVE and SUGGESTION_SECONDARY_TEXT_SMALL) only ever appear // following LargeFont text, so for consistency they specify LargeFont for the // first value even though this is not actually used (since they're not the // first value). TextStyle GetTextStyle(int type) { switch (type) { case SuggestionAnswer::TOP_ALIGNED: return {ui::ResourceBundle::LargeFont, {NativeTheme::kColorId_ResultsTableNormalDimmedText, NativeTheme::kColorId_ResultsTableHoveredDimmedText, NativeTheme::kColorId_ResultsTableSelectedDimmedText}, gfx::SUPERIOR}; case SuggestionAnswer::DESCRIPTION_NEGATIVE: return {ui::ResourceBundle::LargeFont, {NativeTheme::kColorId_ResultsTableNegativeText, NativeTheme::kColorId_ResultsTableNegativeHoveredText, NativeTheme::kColorId_ResultsTableNegativeSelectedText}, gfx::INFERIOR}; case SuggestionAnswer::DESCRIPTION_POSITIVE: return {ui::ResourceBundle::LargeFont, {NativeTheme::kColorId_ResultsTablePositiveText, NativeTheme::kColorId_ResultsTablePositiveHoveredText, NativeTheme::kColorId_ResultsTablePositiveSelectedText}, gfx::INFERIOR}; case SuggestionAnswer::PERSONALIZED_SUGGESTION: return {ui::ResourceBundle::BaseFont, {NativeTheme::kColorId_ResultsTableNormalText, NativeTheme::kColorId_ResultsTableHoveredText, NativeTheme::kColorId_ResultsTableSelectedText}, gfx::NORMAL_BASELINE}; case SuggestionAnswer::ANSWER_TEXT_MEDIUM: return {ui::ResourceBundle::BaseFont, {NativeTheme::kColorId_ResultsTableNormalDimmedText, NativeTheme::kColorId_ResultsTableHoveredDimmedText, NativeTheme::kColorId_ResultsTableSelectedDimmedText}, gfx::NORMAL_BASELINE}; case SuggestionAnswer::ANSWER_TEXT_LARGE: return {ui::ResourceBundle::LargeFont, {NativeTheme::kColorId_ResultsTableNormalDimmedText, NativeTheme::kColorId_ResultsTableHoveredDimmedText, NativeTheme::kColorId_ResultsTableSelectedDimmedText}, gfx::NORMAL_BASELINE}; case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_SMALL: return {ui::ResourceBundle::LargeFont, {NativeTheme::kColorId_ResultsTableNormalDimmedText, NativeTheme::kColorId_ResultsTableHoveredDimmedText, NativeTheme::kColorId_ResultsTableSelectedDimmedText}, gfx::INFERIOR}; case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_MEDIUM: return {ui::ResourceBundle::BaseFont, {NativeTheme::kColorId_ResultsTableNormalDimmedText, NativeTheme::kColorId_ResultsTableHoveredDimmedText, NativeTheme::kColorId_ResultsTableSelectedDimmedText}, gfx::NORMAL_BASELINE}; case SuggestionAnswer::SUGGESTION: // Fall through. default: return {ui::ResourceBundle::BaseFont, {NativeTheme::kColorId_ResultsTableNormalText, NativeTheme::kColorId_ResultsTableHoveredText, NativeTheme::kColorId_ResultsTableSelectedText}, gfx::NORMAL_BASELINE}; } } } // namespace //////////////////////////////////////////////////////////////////////////////// // OmniboxResultView, public: // This class is a utility class for calculations affected by whether the result // view is horizontally mirrored. The drawing functions can be written as if // all drawing occurs left-to-right, and then use this class to get the actual // coordinates to begin drawing onscreen. class OmniboxResultView::MirroringContext { public: MirroringContext() : center_(0), right_(0) {} // Tells the mirroring context to use the provided range as the physical // bounds of the drawing region. When coordinate mirroring is needed, the // mirror point will be the center of this range. void Initialize(int x, int width) { center_ = x + width / 2; right_ = x + width; } // Given a logical range within the drawing region, returns the coordinate of // the possibly-mirrored "left" side. (This functions exactly like // View::MirroredLeftPointForRect().) int mirrored_left_coord(int left, int right) const { return base::i18n::IsRTL() ? (center_ + (center_ - right)) : left; } // Given a logical coordinate within the drawing region, returns the remaining // width available. int remaining_width(int x) const { return right_ - x; } private: int center_; int right_; DISALLOW_COPY_AND_ASSIGN(MirroringContext); }; OmniboxResultView::OmniboxResultView(OmniboxPopupContentsView* model, int model_index, const gfx::FontList& font_list) : model_(model), model_index_(model_index), font_list_(font_list), font_height_(std::max( font_list.GetHeight(), font_list.DeriveWithWeight(gfx::Font::Weight::BOLD).GetHeight())), mirroring_context_(new MirroringContext()), keyword_icon_(new views::ImageView()), animation_(new gfx::SlideAnimation(this)) { CHECK_GE(model_index, 0); keyword_icon_->set_owned_by_client(); keyword_icon_->EnableCanvasFlippingForRTLUI(true); keyword_icon_->SetImage(GetVectorIcon(omnibox::kKeywordSearchIcon)); keyword_icon_->SizeToPreferredSize(); } OmniboxResultView::~OmniboxResultView() { } SkColor OmniboxResultView::GetColor( ResultViewState state, ColorKind kind) const { for (size_t i = 0; i < arraysize(kTranslationTable); ++i) { if (kTranslationTable[i].state == state && kTranslationTable[i].kind == kind) { return GetNativeTheme()->GetSystemColor(kTranslationTable[i].id); } } NOTREACHED(); return gfx::kPlaceholderColor; } void OmniboxResultView::SetMatch(const AutocompleteMatch& match) { match_ = match; match_.PossiblySwapContentsAndDescriptionForDisplay(); animation_->Reset(); answer_image_ = gfx::ImageSkia(); AutocompleteMatch* associated_keyword_match = match_.associated_keyword.get(); if (associated_keyword_match) { if (!keyword_icon_->parent()) AddChildView(keyword_icon_.get()); } else if (keyword_icon_->parent()) { RemoveChildView(keyword_icon_.get()); } Invalidate(); if (GetWidget()) Layout(); } void OmniboxResultView::ShowKeyword(bool show_keyword) { if (show_keyword) animation_->Show(); else animation_->Hide(); } void OmniboxResultView::Invalidate() { const ResultViewState state = GetState(); if (state == NORMAL) { set_background(nullptr); } else { const SkColor bg_color = GetColor(state, BACKGROUND); set_background(new BackgroundWith1PxBorder(bg_color, bg_color)); } // While the text in the RenderTexts may not have changed, the styling // (color/bold) may need to change. So we reset them to cause them to be // recomputed in OnPaint(). contents_rendertext_.reset(); description_rendertext_.reset(); separator_rendertext_.reset(); keyword_contents_rendertext_.reset(); keyword_description_rendertext_.reset(); } void OmniboxResultView::OnSelected() { DCHECK_EQ(SELECTED, GetState()); // Notify assistive technology when results with answers attached are // selected. The non-answer text is already accessible as a consequence of // updating the text in the omnibox but this alert and GetAccessibleNodeData // below make the answer contents accessible. if (match_.answer) NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); } gfx::Size OmniboxResultView::GetPreferredSize() const { int height = GetTextHeight() + (2 * GetVerticalMargin()); if (match_.answer) height += GetAnswerHeight() + kVerticalPadding; return gfx::Size(0, height); } void OmniboxResultView::GetAccessibleNodeData(ui::AXNodeData* node_data) { node_data->SetName(match_.answer ? l10n_util::GetStringFUTF16( IDS_OMNIBOX_ACCESSIBLE_ANSWER, match_.contents, match_.answer->second_line().AccessibleText()) : match_.contents); } void OmniboxResultView::OnNativeThemeChanged(const ui::NativeTheme* theme) { Invalidate(); SchedulePaint(); } //////////////////////////////////////////////////////////////////////////////// // OmniboxResultView, protected: OmniboxResultView::ResultViewState OmniboxResultView::GetState() const { if (model_->IsSelectedIndex(model_index_)) return SELECTED; return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; } int OmniboxResultView::GetTextHeight() const { return font_height_; } void OmniboxResultView::PaintMatch(const AutocompleteMatch& match, gfx::RenderText* contents, gfx::RenderText* description, gfx::Canvas* canvas, int x) const { int y = text_bounds_.y() + GetVerticalMargin(); if (!separator_rendertext_) { const base::string16& separator = l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); separator_rendertext_ = CreateRenderText(separator); separator_rendertext_->SetColor(GetColor(GetState(), DIMMED_TEXT)); separator_width_ = separator_rendertext_->GetContentWidth(); } contents->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); if (description) description->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); int contents_max_width, description_max_width; OmniboxPopupModel::ComputeMatchMaxWidths( contents->GetContentWidth(), separator_width_, description ? description->GetContentWidth() : 0, mirroring_context_->remaining_width(x), match.answer != nullptr, !AutocompleteMatch::IsSearchType(match.type), &contents_max_width, &description_max_width); int after_contents_x = DrawRenderText(match, contents, CONTENTS, canvas, x, y, contents_max_width); if (description_max_width != 0) { if (match.answer) { y += GetTextHeight() + kVerticalPadding; if (!answer_image_.isNull()) { int answer_icon_size = GetAnswerHeight(); canvas->DrawImageInt( answer_image_, 0, 0, answer_image_.width(), answer_image_.height(), GetMirroredXInView(x), y, answer_icon_size, answer_icon_size, true); // TODO(dschuyler): Perhaps this should be based on the font size // instead of hardcoded to 2 dp (e.g. by adding a space in an // appropriate font to the beginning of the description, then reducing // the additional padding here to zero). const int kAnswerIconToTextPadding = 2; x += answer_icon_size + kAnswerIconToTextPadding; } } else { x = DrawRenderText(match, separator_rendertext_.get(), SEPARATOR, canvas, after_contents_x, y, separator_width_); } DrawRenderText(match, description, DESCRIPTION, canvas, x, y, description_max_width); } } int OmniboxResultView::DrawRenderText( const AutocompleteMatch& match, gfx::RenderText* render_text, RenderTextType render_text_type, gfx::Canvas* canvas, int x, int y, int max_width) const { DCHECK(!render_text->text().empty()); const int remaining_width = mirroring_context_->remaining_width(x); int right_x = x + max_width; // Tail suggestions should appear with the leading ellipses vertically // stacked. if (render_text_type == CONTENTS && match.type == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) { // When the directionality of suggestion doesn't match the UI, we try to // vertically stack the ellipsis by restricting the end edge (right_x). const bool is_ui_rtl = base::i18n::IsRTL(); const bool is_match_contents_rtl = (render_text->GetDisplayTextDirection() == base::i18n::RIGHT_TO_LEFT); const int offset = GetDisplayOffset(match, is_ui_rtl, is_match_contents_rtl); std::unique_ptr<gfx::RenderText> prefix_render_text( CreateRenderText(base::UTF8ToUTF16( match.GetAdditionalInfo(kACMatchPropertyContentsPrefix)))); const int prefix_width = prefix_render_text->GetContentWidth(); int prefix_x = x; const int max_match_contents_width = model_->max_match_contents_width(); if (is_ui_rtl != is_match_contents_rtl) { // RTL tail suggestions appear near the left edge in LTR UI, while LTR // tail suggestions appear near the right edge in RTL UI. This is // against the natural horizontal alignment of the text. We reduce the // width of the box for suggestion display, so that the suggestions appear // in correct confines. This reduced width allows us to modify the text // alignment (see below). right_x = x + std::min(remaining_width - prefix_width, std::max(offset, max_match_contents_width)); prefix_x = right_x; // We explicitly set the horizontal alignment so that when LTR suggestions // show in RTL UI (or vice versa), their ellipses appear stacked in a // single column. render_text->SetHorizontalAlignment( is_match_contents_rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT); } else { // If the dropdown is wide enough, place the ellipsis at the position // where the omitted text would have ended. Otherwise reduce the offset of // the ellipsis such that the widest suggestion reaches the end of the // dropdown. const int start_offset = std::max(prefix_width, std::min(remaining_width - max_match_contents_width, offset)); right_x = x + std::min(remaining_width, start_offset + max_width); x += start_offset; prefix_x = x - prefix_width; } prefix_render_text->SetDirectionalityMode(is_match_contents_rtl ? gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR); prefix_render_text->SetHorizontalAlignment( is_match_contents_rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT); prefix_render_text->SetDisplayRect( gfx::Rect(mirroring_context_->mirrored_left_coord( prefix_x, prefix_x + prefix_width), y, prefix_width, GetTextHeight())); prefix_render_text->Draw(canvas); } // Set the display rect to trigger elision. int height = (render_text_type == DESCRIPTION && match.answer) ? GetAnswerHeight() : GetTextHeight(); render_text->SetDisplayRect( gfx::Rect(mirroring_context_->mirrored_left_coord(x, right_x), y, right_x - x, height)); render_text->Draw(canvas); return right_x; } std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateRenderText( const base::string16& text) const { std::unique_ptr<gfx::RenderText> render_text( gfx::RenderText::CreateInstance()); render_text->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); render_text->SetCursorEnabled(false); render_text->SetElideBehavior(gfx::ELIDE_TAIL); render_text->SetFontList(font_list_); render_text->SetText(text); return render_text; } std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateClassifiedRenderText( const base::string16& text, const ACMatchClassifications& classifications, bool force_dim) const { std::unique_ptr<gfx::RenderText> render_text(CreateRenderText(text)); const size_t text_length = render_text->text().length(); for (size_t i = 0; i < classifications.size(); ++i) { const size_t text_start = classifications[i].offset; if (text_start >= text_length) break; const size_t text_end = (i < (classifications.size() - 1)) ? std::min(classifications[i + 1].offset, text_length) : text_length; const gfx::Range current_range(text_start, text_end); // Calculate style-related data. if (classifications[i].style & ACMatchClassification::MATCH) render_text->ApplyWeight(gfx::Font::Weight::BOLD, current_range); ColorKind color_kind = TEXT; if (classifications[i].style & ACMatchClassification::URL) { color_kind = URL; // Consider logical string for domain "ABC.comי/hello" where ABC are // Hebrew (RTL) characters. This string should ideally show as // "CBA.com/hello". If we do not force LTR on URL, it will appear as // "com/hello.CBA". // With IDN and RTL TLDs, it might be okay to allow RTL rendering of URLs, // but it still has some pitfalls like : // ABC.COM/abc-pqr/xyz/FGH will appear as HGF/abc-pqr/xyz/MOC.CBA which // really confuses the path hierarchy of the URL. // Also, if the URL supports https, the appearance will change into LTR // directionality. // In conclusion, LTR rendering of URL is probably the safest bet. render_text->SetDirectionalityMode(gfx::DIRECTIONALITY_FORCE_LTR); } else if (force_dim || (classifications[i].style & ACMatchClassification::DIM)) { color_kind = DIMMED_TEXT; } render_text->ApplyColor(GetColor(GetState(), color_kind), current_range); } return render_text; } int OmniboxResultView::GetMatchContentsWidth() const { InitContentsRenderTextIfNecessary(); contents_rendertext_->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); return contents_rendertext_->GetContentWidth(); } void OmniboxResultView::SetAnswerImage(const gfx::ImageSkia& image) { answer_image_ = image; SchedulePaint(); } // TODO(skanuj): This is probably identical across all OmniboxResultView rows in // the omnibox dropdown. Consider sharing the result. int OmniboxResultView::GetDisplayOffset( const AutocompleteMatch& match, bool is_ui_rtl, bool is_match_contents_rtl) const { if (match.type != AutocompleteMatchType::SEARCH_SUGGEST_TAIL) return 0; const base::string16& input_text = base::UTF8ToUTF16( match.GetAdditionalInfo(kACMatchPropertySuggestionText)); int contents_start_index = 0; base::StringToInt(match.GetAdditionalInfo(kACMatchPropertyContentsStartIndex), &contents_start_index); std::unique_ptr<gfx::RenderText> input_render_text( CreateRenderText(input_text)); const gfx::Range& glyph_bounds = input_render_text->GetGlyphBounds(contents_start_index); const int start_padding = is_match_contents_rtl ? std::max(glyph_bounds.start(), glyph_bounds.end()) : std::min(glyph_bounds.start(), glyph_bounds.end()); return is_ui_rtl ? (input_render_text->GetContentWidth() - start_padding) : start_padding; } const char* OmniboxResultView::GetClassName() const { return "OmniboxResultView"; } gfx::ImageSkia OmniboxResultView::GetIcon() const { const gfx::Image image = model_->GetIconIfExtensionMatch(model_index_); if (!image.IsEmpty()) return image.AsImageSkia(); return GetVectorIcon(model_->IsStarredMatch(match_) ? omnibox::kStarIcon : AutocompleteMatch::TypeToVectorIcon(match_.type)); } gfx::ImageSkia OmniboxResultView::GetVectorIcon( const gfx::VectorIcon& icon) const { // For selected rows, paint the icon the same color as the text. SkColor color = GetColor(GetState(), TEXT); if (GetState() != SELECTED) color = color_utils::DeriveDefaultIconColor(color); return gfx::CreateVectorIcon(icon, 16, color); } bool OmniboxResultView::ShowOnlyKeywordMatch() const { return match_.associated_keyword && (keyword_icon_->x() <= icon_bounds_.right()); } void OmniboxResultView::InitContentsRenderTextIfNecessary() const { if (!contents_rendertext_) { if (match_.answer) { contents_rendertext_ = CreateAnswerText(match_.answer->first_line(), font_list_); } else { contents_rendertext_ = CreateClassifiedRenderText( match_.contents, match_.contents_class, false); } } } void OmniboxResultView::Layout() { const int horizontal_padding = GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING) + LocationBarView::kIconInteriorPadding; // The horizontal bounds we're given are the outside bounds, so we can match // the omnibox border outline shape exactly in OnPaint(). We have to inset // here to keep the icons lined up. const int start_x = BackgroundWith1PxBorder::kLocationBarBorderThicknessDip + horizontal_padding; const int end_x = width() - start_x; const gfx::ImageSkia icon = GetIcon(); const int icon_y = GetVerticalMargin() + (GetTextHeight() - icon.height()) / 2; icon_bounds_.SetRect(start_x, icon_y, icon.width(), icon.height()); const int text_x = start_x + LocationBarView::kIconWidth + horizontal_padding; int text_width = end_x - text_x; if (match_.associated_keyword.get()) { const int max_kw_x = end_x - keyword_icon_->width(); const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x); const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; text_width = kw_x - text_x - horizontal_padding; keyword_text_bounds_.SetRect( kw_text_x, 0, std::max(end_x - kw_text_x, 0), height()); keyword_icon_->SetPosition( gfx::Point(kw_x, (height() - keyword_icon_->height()) / 2)); } text_bounds_.SetRect(text_x, 0, std::max(text_width, 0), height()); } void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) { animation_->SetSlideDuration(width() / 4); } void OmniboxResultView::OnPaint(gfx::Canvas* canvas) { View::OnPaint(canvas); // NOTE: While animating the keyword match, both matches may be visible. if (!ShowOnlyKeywordMatch()) { canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_), icon_bounds_.y()); int x = GetMirroredXForRect(text_bounds_); mirroring_context_->Initialize(x, text_bounds_.width()); InitContentsRenderTextIfNecessary(); if (!description_rendertext_) { if (match_.answer) { description_rendertext_ = CreateAnswerText(match_.answer->second_line(), GetAnswerFont()); } else if (!match_.description.empty()) { description_rendertext_ = CreateClassifiedRenderText( match_.description, match_.description_class, true); } } PaintMatch(match_, contents_rendertext_.get(), description_rendertext_.get(), canvas, x); } AutocompleteMatch* keyword_match = match_.associated_keyword.get(); if (keyword_match) { int x = GetMirroredXForRect(keyword_text_bounds_); mirroring_context_->Initialize(x, keyword_text_bounds_.width()); if (!keyword_contents_rendertext_) { keyword_contents_rendertext_ = CreateClassifiedRenderText( keyword_match->contents, keyword_match->contents_class, false); } if (!keyword_description_rendertext_ && !keyword_match->description.empty()) { keyword_description_rendertext_ = CreateClassifiedRenderText( keyword_match->description, keyword_match->description_class, true); } PaintMatch(*keyword_match, keyword_contents_rendertext_.get(), keyword_description_rendertext_.get(), canvas, x); } } void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) { Layout(); SchedulePaint(); } const gfx::FontList& OmniboxResultView::GetAnswerFont() const { // This assumes that the first text type in the second answer line can be used // to specify the font for all the text fields in the line. For now this works // but eventually it will be necessary to get RenderText to support multiple // font sizes or use multiple RenderTexts. int text_type = match_.answer && !match_.answer->second_line().text_fields().empty() ? match_.answer->second_line().text_fields()[0].type() : SuggestionAnswer::SUGGESTION; return ui::ResourceBundle::GetSharedInstance().GetFontList( GetTextStyle(text_type).font); } int OmniboxResultView::GetAnswerHeight() const { // If the answer specifies a maximum of 1 line we can simply return the answer // font height. if (match_.answer->second_line().num_text_lines() == 1) return GetAnswerFont().GetHeight(); // Multi-line answers require layout in order to determine the number of lines // the RenderText will use. if (!description_rendertext_) { description_rendertext_ = CreateAnswerText(match_.answer->second_line(), GetAnswerFont()); } description_rendertext_->SetDisplayRect(gfx::Rect(text_bounds_.width(), 0)); description_rendertext_->GetStringSize(); return GetAnswerFont().GetHeight() * description_rendertext_->GetNumLines(); } int OmniboxResultView::GetVerticalMargin() const { // Regardless of the text size, we ensure a minimum size for the content line // here. This minimum is larger for hybrid mouse/touch devices to ensure an // adequately sized touch target. using Md = ui::MaterialDesignController; const int kIconVerticalPad = base::GetFieldTrialParamByFeatureAsInt( omnibox::kUIExperimentVerticalMargin, OmniboxFieldTrial::kUIVerticalMarginParam, Md::GetMode() == Md::MATERIAL_HYBRID ? 8 : 4); const int min_height = LocationBarView::kIconWidth + 2 * kIconVerticalPad; return std::max(kVerticalPadding, (min_height - GetTextHeight()) / 2); } std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerText( const SuggestionAnswer::ImageLine& line, const gfx::FontList& font_list) const { std::unique_ptr<gfx::RenderText> destination = CreateRenderText(base::string16()); destination->SetFontList(font_list); for (const SuggestionAnswer::TextField& text_field : line.text_fields()) AppendAnswerText(destination.get(), text_field.text(), text_field.type()); if (!line.text_fields().empty()) { constexpr int kMaxDisplayLines = 3; const SuggestionAnswer::TextField& first_field = line.text_fields().front(); if (first_field.has_num_lines() && first_field.num_lines() > 1 && destination->MultilineSupported()) { destination->SetMultiline(true); destination->SetMaxLines( std::min(kMaxDisplayLines, first_field.num_lines())); } } const base::char16 space(' '); const auto* text_field = line.additional_text(); if (text_field) { AppendAnswerText(destination.get(), space + text_field->text(), text_field->type()); } text_field = line.status_text(); if (text_field) { AppendAnswerText(destination.get(), space + text_field->text(), text_field->type()); } return destination; } void OmniboxResultView::AppendAnswerText(gfx::RenderText* destination, const base::string16& text, int text_type) const { // TODO(dschuyler): make this better. Right now this only supports unnested // bold tags. In the future we'll need to flag unexpected tags while adding // support for b, i, u, sub, and sup. We'll also need to support HTML // entities (&lt; for '<', etc.). const base::string16 begin_tag = base::ASCIIToUTF16("<b>"); const base::string16 end_tag = base::ASCIIToUTF16("</b>"); size_t begin = 0; while (true) { size_t end = text.find(begin_tag, begin); if (end == base::string16::npos) { AppendAnswerTextHelper(destination, text.substr(begin), text_type, false); break; } AppendAnswerTextHelper(destination, text.substr(begin, end - begin), text_type, false); begin = end + begin_tag.length(); end = text.find(end_tag, begin); if (end == base::string16::npos) break; AppendAnswerTextHelper(destination, text.substr(begin, end - begin), text_type, true); begin = end + end_tag.length(); } } void OmniboxResultView::AppendAnswerTextHelper(gfx::RenderText* destination, const base::string16& text, int text_type, bool is_bold) const { if (text.empty()) return; int offset = destination->text().length(); gfx::Range range(offset, offset + text.length()); destination->AppendText(text); const TextStyle& text_style = GetTextStyle(text_type); // TODO(dschuyler): follow up on the problem of different font sizes within // one RenderText. Maybe with destination->SetFontList(...). destination->ApplyWeight( is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); destination->ApplyColor( GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); destination->ApplyBaselineStyle(text_style.baseline, range); }
fe53527bade934774eef27abcaca8bb444cf74b1
a157e49f1abae34fb2ce8cb99342a05682726ebf
/src/bot/Malware/SharedKernel/Systems/Windows/windowsmodulerepository.cpp
642cb51e9f2fcdc3c40acb61bada3daf25ebcec5
[ "MIT" ]
permissive
jsdelivrbot/eductional-botnet
05c5e1b40e967221d12e96bf4f0e66036a8ad70a
7cd021c176331cc0642f4b92a5a7b598df610c37
refs/heads/master
2020-04-10T09:22:25.918455
2018-12-08T07:26:51
2018-12-08T07:26:51
160,934,522
0
0
MIT
2018-12-08T11:57:08
2018-12-08T11:57:07
null
UTF-8
C++
false
false
1,308
cpp
windowsmodulerepository.cpp
#include <windows.h> #include <tlhelp32.h> #include <tchar.h> #include "windowsmodulerepository.h" using namespace std; namespace systems { namespace windows { vector<QString> WindowsModuleRepository::getAllModulesForProcess(Process process) { vector<QString> modules; HANDLE hModuleSnap = INVALID_HANDLE_VALUE; MODULEENTRY32 me32; // Take a snapshot of all modules in the specified process. hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, process.id()); if( hModuleSnap == INVALID_HANDLE_VALUE ) { return modules; } // Set the size of the structure before using it. me32.dwSize = sizeof( MODULEENTRY32 ); // Retrieve information about the first module, // and exit if unsuccessful if( !Module32First( hModuleSnap, &me32 ) ) { CloseHandle( hModuleSnap ); // clean the snapshot object return modules; } // Now walk the module list of the process, // and display information about each module do { modules.push_back(QString::fromStdWString(me32.szModule)); } while( Module32Next( hModuleSnap, &me32 ) ); CloseHandle( hModuleSnap ); return modules; } }}
0aa018d18e65b4bcf62c92cac3465940081efa35
4cb210dad55139d4d2db787524beba685a39ff65
/CodeChef/src/y2015/m03/challenge/SignWave.cpp
457a71dda3682879afdb20d3bf4a064250a3b7ba
[]
no_license
pavel-zeman/CodeChef
7e0d4b97d9032647a922bc5991a33e66ce8d5483
a8a6b7638d3af4ed9fe7f64843a86e218882194a
refs/heads/master
2021-04-12T02:49:21.699583
2018-11-03T19:03:04
2018-11-03T19:03:04
9,584,588
0
0
null
null
null
null
UTF-8
C++
false
false
1,380
cpp
SignWave.cpp
// Cosine functions never intersect each other at x-axis, so they can add up to 1 intersection. The number of intersections of l sine functions is 2^(s-l) (+ 2 points (0, 2*pi) with exactly s intersections). // http://www.codechef.com/MARCH15/problems/SIGNWAVE #include <stdio.h> #include <string.h> #include <limits.h> #include <math.h> #include <stdlib.h> #include <ctype.h> #include <assert.h> #include <vector> #include <map> using namespace std; #define FOR(c, m) for(int c=0;c<(m);c++) #define FORE(c, f, t) for(int c=(f);c<(t);c++) char c = 0; int getInt() { int r = 0; while (!(c >= '0' && c <= '9')) c = getc_unlocked(stdin); while (c >= '0' && c <= '9') { r = r * 10 + (c - '0'); c = getc_unlocked(stdin); } return r; } int main(void) { int t = getInt(); FOR(tt, t) { int s = getInt(); int c = getInt(); int k = getInt(); long long int total = 0; if (s == 0) { if (k == 1) total = (1LL << (c + 1)) - 2; } else { if (k == 1) { int m = s; if (c + 1 > m) m = c + 1; total = (1LL << m) + 1; } else if (k <= s) { total = (1LL << (s - k + 1)) - 1 + 2; if (c > s - k) total += 1LL << (s - k + 1); } } printf("%lld\n", total); } }
71856763f85e3ec4cdcce23be33af4e83a8f00bf
d0daf29f2fb5ff8630694b129aaac51bcdbbd50e
/aoapc_uva/aoapc-code/ch03/UVa10340-2.cpp
ab396944db60eb0402d1749af0980f98e3d6e84b
[]
no_license
fengshen024/Algorithm
9ce95258ef8e4a20b298d0c476c0c67aa8e3e56e
4d5c99f5a91d4a8dfcededa9d2da4b375080fb4e
refs/heads/master
2021-01-26T02:47:25.033358
2020-02-21T15:06:51
2020-02-21T15:06:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
618
cpp
UVa10340-2.cpp
#include<bits/stdc++.h> using namespace std; string s, t; int main() { while(cin >>s && cin >>t) { bool isSub = false; // 记录是否为子序列 int i = 0, j = 0; // 双指针 while (i < s.size() && j < t.size()) { // 以s为参照,遍历s,t if (s[i] == t[j]) { // 找到相等 if (i == s.size() - 1) { isSub = true; break; } i ++; j ++; } while (j < t.size() && s[i] != t[j]) j ++; } printf("%s\n", isSub ? "Yes" : "No"); } return 0; }
0052ed501e8d93e6b7bb7f070bc2fa028fdaef35
3f11bd61f282e161fa062c54a7d5d0be0c245e20
/treaning0410.cpp
68205f5290f94171b2c61139df240a4d476613e6
[]
no_license
Satoru830624/Traning
dd72d0931abd1e7e3d8ec82b3cf2730f1deda4a9
516ac8e1503a8e7ed868f157d8b4af1d428ac0d7
refs/heads/master
2020-03-07T13:54:03.073755
2018-04-25T11:08:58
2018-04-25T11:08:58
127,513,202
0
0
null
null
null
null
UTF-8
C++
false
false
757
cpp
treaning0410.cpp
#include <iostream> #include <vector> void g1(std::vector<int> v){ v[0] = 100; //パラメータの変更 } int g2(const std::vector<int>& v) { //v[0] = 1000; //error(v is const) return v[0]; } void g3(std::vector<int> v) { v[0] = 1000; } auto h(){ std::vector<int> v{11,13,17,19}; return v; } int main(){ std::vector<int> v1{2,3,5,7}; g1(v1); std::cout << v1[0] << std::endl;//出漁地2 std::cout << g2(v1) << std::endl;//g2はv1を変更しない g3(v1); std::cout << v1[0] << std::endl; auto v2 = h(); //h()で構築したvectorお受け取る //auto v2 = h(); //OK for(auto x : v2){ std::cout << x << ", "; } std::cout << std::endl; return 0; }
7a3a632a5284d730aaa6d9e06be65137e5bbaa0b
6ebb505b3d9beff9a81304c74dc4cfff7dd3cb0a
/structure-2/src/Path.cpp
a34fbb14ae7ed106788a7caf10e546b36b098992
[]
no_license
mathieu-reymond/structure-of-computer-programs-2
dd55365a9d94cff532c274af776efe08908e732c
be4fa080cf022f7ff577a9cd8c96140003cb9c07
refs/heads/master
2016-09-06T07:09:53.931330
2014-01-17T11:35:39
2014-01-17T11:35:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,500
cpp
Path.cpp
/* * Path.cpp * * Created on: Dec 6, 2013 * Author: Mathieu */ #include "Path.h" #include <iostream> #include <sstream> #include <string> #include <sstream> /** * Makes a new, empty Path */ Path::Path() { } Path::~Path() { } /** * Checks if this Path is on the same level as path. * The Path must be the same except the last value. * @param path the compared path * @return true if on same level, false otherwise */ bool Path::isOnSameLevel(const Path& path) const { if(path.size() != size()) return false; else { const_iterator it = begin(); const_iterator pathIt = path.begin(); bool result = true; for(int i = 1; i < size(); ++i) { result = result && (*(it++) == *(pathIt++)); } return result; } } /** * Makes a string representation of this Path * @return the string representation */ std::string Path::print() { if(!empty()) { const_iterator it = begin(); std::stringstream strm; strm << (*it); ++it; for(const_iterator i = it; i != end(); ++i) { strm << "."; strm << (*i); } return strm.str(); } else return ""; } /** * Convert what's in the input stream to a Path * @param in the input stream * @param p the converted Path * @return the modified stream */ std::istream& operator>>(std::istream& in, Path& p) { std::string nb; std::string word; in >> word; std::stringstream stream(word); while(std::getline(stream, nb, '.')) { int num; std::stringstream s(nb); s >> num; p.push_back(num); } return in; }
e6454c76e317216d9bd95e8d0cb5e004a5bed543
e5f4f37d941ceb8145d65f92028cc54658b1ac01
/Code/Engine/Core/World/Implementation/SettingsComponentManager_inl.h
2e708747c302dc701abe97767e48432d44617cb4
[ "MIT" ]
permissive
ezEngine/ezEngine
19983d2733a5409fb2665c6c3a0a575dadcefb50
c46e3b4b2cd46798e4abb4938fbca281c054b039
refs/heads/dev
2023-09-06T02:17:28.152665
2023-09-05T18:25:43
2023-09-05T18:25:43
18,179,848
1,050
165
MIT
2023-09-14T21:44:39
2014-03-27T15:02:16
C++
UTF-8
C++
false
false
2,706
h
SettingsComponentManager_inl.h
template <typename ComponentType> ezSettingsComponentManager<ComponentType>::ezSettingsComponentManager(ezWorld* pWorld) : ezComponentManagerBase(pWorld) { } template <typename ComponentType> ezSettingsComponentManager<ComponentType>::~ezSettingsComponentManager() { for (auto& component : m_Components) { DeinitializeComponent(component.Borrow()); } } template <typename ComponentType> EZ_ALWAYS_INLINE ComponentType* ezSettingsComponentManager<ComponentType>::GetSingletonComponent() { for (const auto& pComponent : m_Components) { // retrieve the first component that is active if (pComponent->IsActive()) return pComponent.Borrow(); } return nullptr; } template <typename ComponentType> EZ_ALWAYS_INLINE const ComponentType* ezSettingsComponentManager<ComponentType>::GetSingletonComponent() const { for (const auto& pComponent : m_Components) { // retrieve the first component that is active if (pComponent->IsActive()) return pComponent.Borrow(); } return nullptr; } // static template <typename ComponentType> EZ_ALWAYS_INLINE ezWorldModuleTypeId ezSettingsComponentManager<ComponentType>::TypeId() { return ComponentType::TypeId(); } template <typename ComponentType> void ezSettingsComponentManager<ComponentType>::CollectAllComponents(ezDynamicArray<ezComponentHandle>& out_allComponents, bool bOnlyActive) { for (auto& component : m_Components) { if (!bOnlyActive || component->IsActive()) { out_allComponents.PushBack(component->GetHandle()); } } } template <typename ComponentType> void ezSettingsComponentManager<ComponentType>::CollectAllComponents(ezDynamicArray<ezComponent*>& out_allComponents, bool bOnlyActive) { for (auto& component : m_Components) { if (!bOnlyActive || component->IsActive()) { out_allComponents.PushBack(component.Borrow()); } } } template <typename ComponentType> ezComponent* ezSettingsComponentManager<ComponentType>::CreateComponentStorage() { if (!m_Components.IsEmpty()) { ezLog::Warning("A component of type '{0}' is already present in this world. Having more than one is not allowed.", ezGetStaticRTTI<ComponentType>()->GetTypeName()); } m_Components.PushBack(EZ_NEW(GetAllocator(), ComponentType)); return m_Components.PeekBack().Borrow(); } template <typename ComponentType> void ezSettingsComponentManager<ComponentType>::DeleteComponentStorage(ezComponent* pComponent, ezComponent*& out_pMovedComponent) { out_pMovedComponent = pComponent; for (ezUInt32 i = 0; i < m_Components.GetCount(); ++i) { if (m_Components[i].Borrow() == pComponent) { m_Components.RemoveAtAndCopy(i); break; } } }
d535ce116f01b33b320e064e60b18b7f8b9cbefb
4f74a1d00e8253d229907d5c640e1a2eb5fd589a
/Accepted Code/UVA/336 - A Node Too Far.cpp
dc272397d5e63584f2b75034d199f156d50e7b40
[]
no_license
sunkuet02/problem-solving
012ea9d94412bf0400223e2af73c95bff049d0c9
49b24477acdf2bdffa9c78a907c9e06532403d40
refs/heads/master
2022-02-20T12:39:54.573009
2019-09-29T03:58:59
2019-09-29T03:58:59
63,452,400
2
0
null
null
null
null
UTF-8
C++
false
false
2,107
cpp
336 - A Node Too Far.cpp
#include<iostream> #include<map> #include<vector> #include<queue> #include<set> using namespace std; vector<int>node[500]; map<int,int>mp; int bfs(int source,int ttl) { queue<int>qu; qu.push(source); int taken[100]={0},distance[100]; distance[source]=0; taken[source]=1; int reach=0; while(!qu.empty()) { int u=qu.front(); for(int i=0;i<node[u].size();i++) { int v=node[u][i]; if(!taken[v]) { distance[v]=distance[u]+1; if(distance[v]<=ttl) reach++; taken[v]=1; qu.push(v); } } qu.pop(); } return reach; } int main() { int i,j=0,m,node1,node2,notreach,reach,source,TTL; set<int>num_node; vector<int>v1,v2; set<int>::iterator it_set; while(1) { cin>>m; if(m==0) break; int a=1; for(i=1;i<=m;i++) { cin>>node1>>node2; v1.push_back(node1); v2.push_back(node2); num_node.insert(node1); num_node.insert(node2); } for(it_set=num_node.begin();it_set!=num_node.end();it_set++) { mp[*it_set]=(a++); } for(int i=0;i<m;i++) { node[mp.find(v1[i])->second].push_back(mp.find(v2[i])->second); node[mp.find(v2[i])->second].push_back(mp.find(v1[i])->second); } for(;;) { cin>>source>>TTL; if(source==0 && TTL==0 ) break; j++; int sourc=mp.find(source)->second; reach=bfs(sourc,TTL); notreach=num_node.size()-reach-1; cout<<"Case "<<j<<": "<<notreach<<" nodes not reachable from node "<<source<<" with TTL = "<<TTL<<"."<<endl; } mp.clear(); num_node.clear(); v1.clear(); v2.clear(); for(int i=0;i<=30;i++) { node[i].clear(); } } return 0; }
afc631ac7c945473b6ecd995f8bcb3aca7c115b1
5095bbe94f3af8dc3b14a331519cfee887f4c07e
/Shared/general/test/TestIniFile.h
727332473a019cc611eb63232c9461b4d0d608c0
[]
no_license
sativa/apsim_development
efc2b584459b43c89e841abf93830db8d523b07a
a90ffef3b4ed8a7d0cce1c169c65364be6e93797
refs/heads/master
2020-12-24T06:53:59.364336
2008-09-17T05:31:07
2008-09-17T05:31:07
64,154,433
0
0
null
null
null
null
UTF-8
C++
false
false
1,303
h
TestIniFile.h
//--------------------------------------------------------------------------- #ifndef TestIniFileH #define TestIniFileH #include <cppunit\testcase.h> #include <cppunit\extensions\HelperMacros.h> #include <string> #include <general\inifile.h> //--------------------------------------------------------------------------- class TestIniFile : public CppUnit::TestCase { public: virtual void setUp(); virtual void tearDown(); void testReadSectionNames(void); void testReadSection(void); void testRead(void); void testWriteSection(void); void testWrite(void); void testDeleteKey(void); void testDeleteSection(void); void testGetKeysInSection(void); void testRenameSection(void); void testRenameKey(void); CPPUNIT_TEST_SUITE(TestIniFile); CPPUNIT_TEST(testReadSectionNames); CPPUNIT_TEST(testReadSection); CPPUNIT_TEST(testRead); CPPUNIT_TEST(testWriteSection); CPPUNIT_TEST(testWrite); CPPUNIT_TEST(testDeleteKey); CPPUNIT_TEST(testDeleteSection); CPPUNIT_TEST(testGetKeysInSection); CPPUNIT_TEST(testRenameSection); CPPUNIT_TEST(testRenameKey); CPPUNIT_TEST_SUITE_END(); private: IniFile ini; }; #endif
541e944ef6655affd3aae1dedd34ce569aac5555
974d04d2ea27b1bba1c01015a98112d2afb78fe5
/paddle/fluid/framework/ir/xpu/multi_encoder_xpu_fuse_pass.h
7c7595a8564cde592273a72b42a7bf37e8c9e5c0
[ "Apache-2.0" ]
permissive
PaddlePaddle/Paddle
b3d2583119082c8e4b74331dacc4d39ed4d7cff0
22a11a60e0e3d10a3cf610077a3d9942a6f964cb
refs/heads/develop
2023-08-17T21:27:30.568889
2023-08-17T12:38:22
2023-08-17T12:38:22
65,711,522
20,414
5,891
Apache-2.0
2023-09-14T19:20:51
2016-08-15T06:59:08
C++
UTF-8
C++
false
false
6,027
h
multi_encoder_xpu_fuse_pass.h
// Copyright (c) 2023 PaddlePaddle Authors. 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. #pragma once #include <string> #include "paddle/fluid/framework/ir/fuse_pass_base.h" #include "paddle/fluid/framework/ir/pass.h" namespace phi { class DenseTensor; } // namespace phi namespace paddle { namespace framework { class Scope; } // namespace framework } // namespace paddle namespace paddle { namespace framework { namespace ir { /* step1: fuse single ops to single_encoder_xpu step2: fuse mutitl single_encoder_xpu to multi_encoder_xpu 1. step1 Origin subgraph: ------------ input_variable* | / | \ | / | \ | v_matmul q_matmul k_matmul | | | | | | | | | v_add q_add add | | | | | | | | | v_reshape q_reshape k_reshape | | | | | | | | | v_transpose q_transpose k_transpose | | | | | | | (scale) | | \ / | | qk_matmul | | | | | | | | qk_add | | | | | | | | qk_softmax | | | | | | | ---------qkv_matmul_0 | | | | | qkv_transpose | | | | | qkv_reshape | | | | | qkv_matmul_1 | | | | | qkv_add_0 | | | | ----------------------qkv_add_1 | | layer_norm_1 / \ | | | qkv_matmul_2 | | | | | qkv_add_2 | | | | | qkv_act | | | | | qkv_matmul_3 | | | | | qkv_add_3 | | \ / qkv_add_4 | layer_norm Fused subgraph: single_encoder_xpu 2. step2 Origin subgraph: ... | single_encoder_xpu | (single_encoder_xpu) | (single_encoder_xpu) | ... Fused subgraph: multi_encoder_xpu */ struct PatternParam { std::string act_type; // "gelu", "relu" std::string matmul_type_0; // "matmul_v2", "matmul", "mul" std::string matmul_type_1; // "matmul_v2", "matmul" std::string matmul_type_2; // "matmul_v2", "matmul" bool norm_before; bool with_q_scale; bool with_mask; }; class MultiEncoderXPUFusePass : public FusePassBase { protected: void ApplyImpl(ir::Graph* graph) const override; private: int ApplySingleEncoderXPUFuse(ir::Graph* graph, const std::string& act_type, const std::string& matmul_type_0, const std::string& matmul_type_1, const std::string& matmul_type_2, bool norm_before, bool with_q_scale, bool with_mask) const; bool ApplyMultiEncoderXPUFuse(ir::Graph* graph) const; // Mask must be fp32 even if model is fp16 int CastMask(ir::Graph* graph) const; // 1. Transpose q_w, k_w, v_w // 2. Concat q_w, k_w, v_w // 3. Generate qkv_w_max tensor // 4. Quant qkv_w to int16 void PrepareQKVWeight(Graph* graph, Scope* scope, BlockDesc* block, Node* q_w, Node* k_w, Node* v_w, Node** qkv_w, Node** qkv_w_max) const; // 1. Cast bias to fp32 // 2. Concat q/k/v bias void PrepareQKVBias(Graph* graph, Scope* scope, BlockDesc* block, Node* q_bias, Node* k_bias, Node* v_bias, Node** qkv_bias) const; // Iterating all attrs costs too much time. // Just provide several cases. std::vector<PatternParam> GeneratePatternParams() const; const std::string name_scope_{"multi_encoder_xpu_fuse_pass"}; }; } // namespace ir } // namespace framework } // namespace paddle
c8d6c26897c1c02c86b5302888c1a9c9f1cecb79
6a3a50538c544c9f8d65bcb8f96d4e3b68a4e848
/Sources/Pattern/Factory.hpp
20e1492d0975c752c9602dea2c6e0b01d6ed8a40
[]
no_license
lejard-h/cpp_bomberman
8f2d7eabebc1b872e189f066caeee78bc2550569
3ba7dcbc77ac87fb47be006446c537da7055b2dc
refs/heads/master
2016-09-06T08:57:09.230787
2014-07-11T08:55:12
2014-07-11T08:55:12
21,691,750
0
1
null
null
null
null
UTF-8
C++
false
false
1,049
hpp
Factory.hpp
/* ** Factory.hpp for Bomberman in /home/lejard_h/rendu/cpp_bomberman/Pattern ** ** Made by hadrien lejard ** Login <lejard_h@epitech.net> ** ** Started on mar. mai 20 14:50:49 2014 hadrien lejard ** Last update mar. mai 20 14:50:49 2014 hadrien lejard */ #ifndef __FACTORY_HPP__ # define __FACTORY_HPP__ #include <map> #include <string> #include "Prototype.hh" namespace Pattern { template <class Object, class Key = std::string> class Factory { private: static std::map<Key, Object *> map; public: static void Register(Key key,Object* obj) { if (map.find(key) == map.end()) map[key] = obj; } Object* Create(const Key& key) { Object *tmp = 0; typename std::map<Key, Object*>::iterator it = map.find(key); if (it != map.end()) tmp = ((*it).second)->Clone(); return tmp; } }; template <typename Object, typename Key> std::map<Key,Object*> Factory<Object,Key>::map = std::map<Key, Object*>(); } #endif /* __FACTORY_HPP__ */
49e611571b4e7da77bc48847d933a5c12c17d79f
9e87545cf914b6951badf7d7a8e4124c76427f2e
/main.cpp
b7624a962db0bf953b6d4d389818e1fc4982c593
[]
no_license
marktube/Simple-Sudoku
210ecb341ebe8a697a0829ce68277e7cab32cf4e
e5cbd688423fec139560944eb603246b937209ae
refs/heads/master
2020-09-21T13:34:43.759268
2015-04-02T03:04:26
2015-04-02T03:04:26
33,286,221
0
0
null
null
null
null
UTF-8
C++
false
false
3,452
cpp
main.cpp
// // main.cpp // Sudoku // // Created by 刘彦超 on 14/11/1. // Copyright (c) 2014年 刘彦超. All rights reserved. // #include <iostream> #include <stdio.h> #include <vector> #include <string.h> #include <algorithm> //#define MYDEBUG using namespace std; int grid[9][9]; int solutionCnt = 0; int record[9][9]; int rowcheck[9][10]; int colcheck[9][10]; int matcheck[9][10]; struct Sustate { int row; int col; int mat; int cnt; }; typedef struct Sustate Sustate; vector<Sustate> pos; void printSudoku(); bool placeNum(int num, Sustate state); bool myCmp(Sustate s1,Sustate s2); void findSolution(int visit); int main() { //freopen("data.in", "r", stdin); int testcase = 0, No_puzzle = 0, index = 0; char inputChar; scanf("%d", &testcase); while (testcase--) { No_puzzle++; index = 0; solutionCnt = 0; pos.clear(); memset(rowcheck, 0, sizeof(rowcheck)); memset(colcheck, 0, sizeof(colcheck)); memset(matcheck, 0, sizeof(matcheck)); while (index < 81) { inputChar = getchar(); if (inputChar == '_') { Sustate tmp; tmp.row=index/9; tmp.col=index%9; tmp.mat=(tmp.row/3)*3+(tmp.col/3); tmp.cnt=0; grid[tmp.row][tmp.col] = 0; pos.push_back(tmp); index++; } else if (inputChar > '0' && inputChar <= '9') { int row = index / 9; int col = index % 9; int mat = (row / 3) * 3 + (col / 3); grid[row][col] = inputChar - '0'; rowcheck[row][grid[row][col]] = 1; rowcheck[row][0]++; colcheck[col][grid[row][col]] = 1; colcheck[col][0]++; matcheck[mat][grid[row][col]] = 1; matcheck[mat][0]++; index++; } } if (pos.empty()) { printf("Puzzle %d solution is\n",No_puzzle); memcpy(record, grid, sizeof(grid)); printSudoku(); }else{ for (int i=0; i<(int)pos.size(); i++) { pos[i].cnt+=rowcheck[pos[i].row][0]+colcheck[pos[i].col][0]+matcheck[pos[i].mat][0]; } sort(pos.begin(), pos.end(),myCmp); findSolution(0); if (solutionCnt == 1) { printf("Puzzle %d solution is\n", No_puzzle); printSudoku(); } else { printf("Puzzle %d has ", No_puzzle); if (solutionCnt == 0) printf("no solution\n"); else printf("%d solutions\n", solutionCnt); } } #ifdef MYDEBUG printf("time past: %.2fs\n",(double)clock()/CLOCKS_PER_SEC); #endif if (testcase != 0) printf("\n"); } return 0; } void printSudoku() { for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { printf("%d", record[i][j]); } printf("\n"); } } bool placeNum(int num, Sustate state) { return !(rowcheck[state.row][num] || colcheck[state.col][num] || matcheck[state.mat][num]); } void findSolution(int visit) { int num = 1; if (visit < (int) pos.size()) { while (num <= 9) { if (placeNum(num, pos[visit])) { if (visit >= (int) pos.size() - 1) { grid[pos[visit].row][pos[visit].col] = num; if (solutionCnt == 0) { memcpy(record, grid, sizeof(grid)); } solutionCnt++; return; } else{ rowcheck[pos[visit].row][num] = 1; colcheck[pos[visit].col][num] = 1; matcheck[pos[visit].mat][num] = 1; grid[pos[visit].row][pos[visit].col] = num; findSolution(visit + 1); rowcheck[pos[visit].row][num] = 0; colcheck[pos[visit].col][num] = 0; matcheck[pos[visit].mat][num] = 0; } //grid[row][col] = 0; } num++; } } } bool myCmp(Sustate s1,Sustate s2){ return s1.cnt>s2.cnt; }
c1a3ed31ba63fea259cc02768b08444ea1e12064
2812bd3736fb271f0c62f7e8beeed4958d5971e5
/examples/service/AndroidServiceTest/testservice.h
47f51677761a2de74dd177d858942c19d0e27544
[ "BSD-3-Clause" ]
permissive
Skycoder42/QtService
1c44fb6404e13e2db6c752e19e908ad45843ff57
b8f3862fda6c7d58bc21e03060ecee099668ab89
refs/heads/master
2022-11-05T01:17:18.424736
2022-10-27T05:18:31
2022-10-27T05:18:31
134,629,576
138
52
BSD-3-Clause
2022-08-01T05:40:14
2018-05-23T21:56:29
C++
UTF-8
C++
false
false
599
h
testservice.h
#ifndef TESTSERVICE_H #define TESTSERVICE_H #include <QtService/Service> #include <QAndroidIntent> #include <QAndroidBinder> class TestService : public QtService::Service { Q_OBJECT public: explicit TestService(int &argc, char **argv); protected: CommandResult onStart() override; CommandResult onStop(int &exitCode) override; int onStartCommand(const QAndroidIntent &intent, int flags, int startId); QAndroidBinder *onBind(const QAndroidIntent &intent); private: void doStartNotify(); }; Q_DECLARE_METATYPE(QAndroidIntent) Q_DECLARE_METATYPE(QAndroidBinder*) #endif // TESTSERVICE_H
cd15ca8fa9eeef64ec059d94c1023996df90f852
2bd30e0416979e2c1e6c6fd6af4eec0a8ff80fdf
/media/MediaManagement.h
290d553120cbca2102d1b2c7ca1817505406eaa8
[]
no_license
mutex42/kirjasto
edef77acdcf6f2c8a97448349e241d67c53522ac
67fc3c6a648cf0739f18219e7a3a69985a074cc0
refs/heads/master
2021-01-11T12:09:28.305945
2017-04-08T03:02:03
2017-04-08T03:02:03
79,385,084
0
0
null
null
null
null
UTF-8
C++
false
false
1,379
h
MediaManagement.h
#ifndef MEDIAMANAGEMENT_H #define MEDIAMANAGEMENT_H #include <stdlib.h> #include <stdio.h> #include <string> #include <sqlite3.h> #include <iostream> #include "Person.h" #include "Article.h" using namespace std; class MediaManagement { public: static MediaManagement& getMM(){ static MediaManagement mm; return mm; } int getMediaUID(); int getPersonUID(); int getJournalUID(); int getPublisherUID(); void addPerson(Person); void addPersonSpelling(Person); void addAuthor(Person, Medium); void addEditor(Person, Medium); void addLink(Medium, string); private: MediaManagement(); ~MediaManagement(); static MediaManagement* mm; int lastMediaUID; int lastPersonUID; int lastJournalUID; int lastPublisherUID; sqlite3 *db; char *zErrMsg; int rc; string sql; void createPersonTable(); void createAuthorsTable(); void createEditorsTable(); void createJournalsTable(); void createPublishersTable(); void createJournalArticlesTable(); void createArticlesTable(); void createBooksTable(); void createTitleTable(); void createLinksTable(); int getlastMediaUID(); int getlastPersonUID(); int getlastJournalUID(); int getlastPublisherUID(); static int callback(void*, int, char**, char**); }; #endif // MEDIAMANAGEMENT_H
b1153661d4d545f4e9693a4bdab08b6f94f1b95f
451270b39c078f40f6c0a099e26318920be16949
/12/单独数字.cpp
87c5fe18562ceccda98dcc101fbc6382b713271c
[]
no_license
Lethe0616/w.x
e659848527753095718b4beb799fec6428999606
53f0a954204f0e12f03c777d867861110c278afe
refs/heads/master
2020-05-19T20:07:36.735167
2019-07-30T11:47:40
2019-07-30T11:47:40
185,195,885
0
0
null
null
null
null
GB18030
C++
false
false
323
cpp
单独数字.cpp
#include <stdio.h> #include <stdlib.h> int main() { int one = 0, i = 0; int arr[] = { 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 }; one = arr[0]; for (i = 1; i < sizeof(arr) / sizeof(arr[0]); i++) { one = one ^ arr[i]; //遍历数组将元素异或,留下单一数字 } printf("%d\n", one); system("pause"); return 0; }
7a5dfa3166d426b355b7c6bca6b0b941d8cf1786
5583acfa0fac2f29ebd6615ad7a101ff6b74f4b9
/SteampunkFriends/CPPGameWorld/PlayerCollision.h
3d523cbd132d45a39c0b5286c942df65e160f952
[]
no_license
Roarw/SteampunkFriends
aaa1edb1df415a243b06fafc71f6f46c5fb168e4
ca3b9a39daed782edf9d238d1737b4745860f8e8
refs/heads/master
2021-01-19T12:14:44.148541
2017-02-24T15:29:58
2017-02-24T15:29:58
82,297,439
0
0
null
null
null
null
UTF-8
C++
false
false
580
h
PlayerCollision.h
#ifndef PLAYERCOLLISION_H #define PLAYERCOLLISION_H #include "Component.h" #include "Vector2.h" #include "RectangleF.h" class Transform; class Collider; class Physics; class PlayerCollision : public Component { private: Transform * transform; Collider * collider; Physics * physics; bool CollidingAt(Collider * other, Vector2 velocity); public: void CheckCollision(Collider * other); std::string GetName(); PlayerCollision(GameObject * gameObject, Transform * transform, Collider * collider, Physics * physics); ~PlayerCollision(); }; #endif // !PLAYERCOLLISION_H
303bf98913d63e506b3da404d6028d01ef3e5b71
bbe6faa8c616ccf5e7c9733ff3f9e20494b4c066
/cmake-3.12.20181002-g18d20/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.cpp
0529426fe6e80fac146f303f479e06dba7387ae4
[ "BSD-3-Clause" ]
permissive
helinyu/source_view
7d685f11dbd192b654188edf8ca132d7d5ad519c
6799043f6df66e6f491756c7b28c05f3e31064b6
refs/heads/master
2020-04-24T23:19:16.431516
2019-02-25T14:11:36
2019-02-25T14:11:36
172,340,220
1
0
null
null
null
null
UTF-8
C++
false
false
88
cpp
StyleD.cpp
#include "StyleD.hpp" QStyle* StyleD::create(const QString& key) { return 0; }
4c7b0e9ddf315b1a3f8f86be7af5b88b1522c239
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
/Engine/Plugins/Editor/AudioCapture/Source/AudioCapture/Private/AudioRecordingManager.h
e48aedab32c5d76b86c754b1b19423a45a44a4ab
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
windystrife/UnrealEngine_NVIDIAGameWorks
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
b50e6338a7c5b26374d66306ebc7807541ff815e
refs/heads/4.18-GameWorks
2023-03-11T02:50:08.471040
2022-01-13T20:50:29
2022-01-13T20:50:29
124,100,479
262
179
MIT
2022-12-16T05:36:38
2018-03-06T15:44:09
C++
UTF-8
C++
false
false
3,202
h
AudioRecordingManager.h
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "HAL/ThreadSafeBool.h" #include "Engine/EngineTypes.h" #if PLATFORM_WINDOWS #include "WindowsHWrapper.h" #endif THIRD_PARTY_INCLUDES_START #include "RtAudio.h" THIRD_PARTY_INCLUDES_END class USoundWave; DECLARE_LOG_CATEGORY_EXTERN(LogMicManager, Log, All); /** * FAudioRecordingManager * Singleton Mic Recording Manager -- generates recordings, stores the recorded data and plays them back */ class FAudioRecordingManager { public: // Retrieves the singleton recording manager static FAudioRecordingManager& Get(); // Starts a new recording with the given name and optional duration. // If set to -1.0f, a duration won't be used and the recording length will be determined by StopRecording(). USoundWave* StartRecording(const FDirectoryPath& Directory, const FString& AssetName, float RecordingDurationSec, float GainDB, int32 InputBufferSize); // Stops recording if the recording manager is recording. If not recording but has recorded data (due to set duration), it will just return the generated USoundWave. USoundWave* StopRecording(); // Called by RtAudio when a new audio buffer is ready to be supplied. int32 OnAudioCapture(void* InBuffer, uint32 InBufferFrames, double StreamTime, bool bOverflow); private: // Private Constructor FAudioRecordingManager(); // Private Destructor ~FAudioRecordingManager(); // Saves raw PCM data recorded to a wave file format void SerializeWaveFile(TArray<uint8>& OutWaveFileData, const uint8* InPCMData, const int32 NumBytes); // The default mic sample rate const int32 WAVE_FILE_SAMPLERATE = 44100; // RtAudio ADC object -- used to interact with low-level audio device. RtAudio ADC; // Stream parameters to initialize the ADC RtAudio::StreamParameters StreamParams; // Critical section used to stop and retrieve finished audio buffers. FCriticalSection CriticalSection; // The current recording name that is actively recording. Empty string if nothing is currently recording. FString CurrentRecordingName; // Where to store the current recording. FDirectoryPath CurrentRecordingDirectory; // The data which is currently being recorded to, if the manager is actively recording. This is not safe to access while recording. TArray<int16> CurrentRecordedPCMData; // Buffer to store sample rate converted PCM data TArray<int16> ConvertedPCMData; // Reusable raw wave data buffer to generate .wav file formats TArray<uint8> RawWaveData; // The number of frames that have been recorded int32 NumRecordedSamples; // The number of frames to record if recording a set duration int32 NumFramesToRecord; // Recording block size (number of frames per callback block) int32 RecordingBlockSize; // The sample rate used in the recording float RecordingSampleRate; // Num input channels int32 NumInputChannels; // A linear gain to apply on mic input float InputGain; // Whether or not the manager is actively recording. FThreadSafeBool bRecording; // Number of overflows detected while recording int32 NumOverflowsDetected; // Whether or not we have an error uint32 bError : 1; };
18fd38896c515e59348ee7fefc6e3aaef8de8829
c34aab07030a058bf6cc2dc4f20874737e37a775
/src/renderer/TextureCache.cpp
66535423ffcb273ffe74fbd77fdf1dab8a89ebbf
[ "LicenseRef-scancode-khronos", "MIT" ]
permissive
appelsdev/bouteagle-rewrite
6d905c52c89f5d9d1ac3ec4dcfb9a7726b21bb24
a557867babbf43d635ff0e93f0937985b0a022ec
refs/heads/master
2020-12-23T10:14:35.481052
2020-01-29T23:36:16
2020-01-29T23:36:16
237,110,568
2
2
null
null
null
null
UTF-8
C++
false
false
766
cpp
TextureCache.cpp
#define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <GL/gl.h> #include "Log.h" #include "resource/ResourceManager.h" #include "renderer/TextureCache.h" namespace TextureCache { void Init() { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); Build(); } void Build() { for (auto const& it : ResourceManager::GetTextures()) { // Log::Log(Log::INFO, "%s", it.first.c_str()); TextureResource* tex = it.second; tex->createGLTexture(); } } void RebuildWhereNecessary() { for (auto const& it : ResourceManager::GetTextures()) { TextureResource* tex = it.second; if (GL_INVALID_VALUE == tex->texId) tex->createGLTexture(); } } }
10d81e4bfd3be601bc3166561ca5f9fc1f709c20
0f3032e4ecb5e0518bda8027cc9ba164f37ebfef
/src/Shader.cpp
0cd1519292f7cd909ff9c4fdfe525aaaabe68bf4
[]
no_license
mijara/MokaEngine
c573bc52858cc762be45a7b6a8ef37e022063450
fb7a7bd755499c94a28fdea1e4e0f8e85f2c3eee
refs/heads/master
2021-01-15T10:58:49.967804
2015-01-20T17:53:00
2015-01-20T17:53:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,201
cpp
Shader.cpp
#include "Shader.h" namespace util { std::string LoadFileText(const std::string& filePath) { std::ifstream file(filePath); std::string output; std::string line; if(file.is_open()) while(file.good()) { std::getline(file, line); output.append(line + "\n"); } return output; } static void CheckShaderError(GLuint shader, GLuint flag, bool isProgram, const std::string& errorMessage) { GLint success = 0; GLchar error[1024] = {0}; if(isProgram) glGetProgramiv(shader, flag, &success); else glGetShaderiv(shader, flag, &success); if(!success) { if(isProgram) glGetProgramInfoLog(shader, sizeof(error), NULL, error); else glGetShaderInfoLog(shader, sizeof(error), NULL, error); fprintf(stderr, "%s: '%s'\n", errorMessage.c_str(), error); } } GLuint CreateShader(const std::string& text, GLenum type) { GLuint shader = glCreateShader(type); if(!shader) std::cerr << "Error: Shader creation failed: " << type << std::endl; const GLchar* source = text.c_str(); const GLint length = text.length(); glShaderSource(shader, 1, &source, &length); glCompileShader(shader); CheckShaderError(shader, GL_COMPILE_STATUS, false, "Error: Shader compilation failed"); return shader; } } Shader::Shader(const std::string& name) : defaultNormalMap("res/textures/default_normal.jpg") { program = glCreateProgram(); vertex = util::CreateShader(util::LoadFileText("res/shaders/f-vertex.glsl"), GL_VERTEX_SHADER); fragment = util::CreateShader(util::LoadFileText("res/shaders/f-frag-" + name + ".glsl"), GL_FRAGMENT_SHADER); glAttachShader(program, vertex); glAttachShader(program, fragment); // this is not extremely necessary, but can prevent some weird bugs. glBindAttribLocation(program, 0, "position0"); glBindAttribLocation(program, 1, "texCoord0"); glBindAttribLocation(program, 2, "normal0"); glBindAttribLocation(program, 3, "tangent0"); glLinkProgram(program); util::CheckShaderError(program, GL_LINK_STATUS, true, "Error: Shader linking failed."); glValidateProgram(program); util::CheckShaderError(program, GL_VALIDATE_STATUS, true, "Error: Shader validation failed."); } Shader::~Shader() { glDetachShader(program, vertex); glDeleteShader(vertex); glDetachShader(program, fragment); glDeleteShader(fragment); glDeleteProgram(program); } void Shader::Bind() { glUseProgram(program); } void Shader::Update(const Transform &transform, Material& material) { glm::mat4 model = transform.GetModel(); material.GetTexture().Bind(); SetUniform("u_normalMap", 1); if(material.HasNormalMap()) material.GetNormalMap().Bind(1); else defaultNormalMap.Bind(1); SetUniform("u_model", model); SetUniform("u_color", material.GetColor()); SetUniform("u_specularIntensity", material.GetSpecularIntensity()); SetUniform("u_specularExponent", material.GetSpecularExponent()); SetUniform("u_tiling", material.GetTilingX(), material.GetTilingY()); } void Shader::SetUniform(std::string uniform, const glm::mat4 values) { glUniformMatrix4fv(GetUniformLocation(uniform), 1, GL_FALSE, &values[0][0]); } void Shader::SetUniform(std::string uniform, const glm::vec3 value) { glUniform3f(GetUniformLocation(uniform), value.x, value.y, value.z); } void Shader::SetUniform(std::string uniform, const glm::vec4 value) { glUniform4f(GetUniformLocation(uniform), value.x, value.y, value.z, value.w); } void Shader::SetUniform(std::string uniform, const int value) { glUniform1i(GetUniformLocation(uniform), value); } void Shader::SetUniform(std::string uniform, const float value) { glUniform1f(GetUniformLocation(uniform), value); } void Shader::SetUniform(std::string uniform, const float x, const float y) { glUniform2f(GetUniformLocation(uniform), x, y); } GLint Shader::GetUniformLocation(const std::string& uniform) { std::map<std::string, GLint>::iterator it = uniforms.find(uniform); GLint location = 0; if(it != uniforms.end()) location = it->second; else { location = glGetUniformLocation(program, uniform.c_str()); if(location == -1) std::cerr << "[Ignore] No uniform with name: " << uniform << std::endl; uniforms[uniform] = location; } return location; }
4e54e093efccbb08919edde22f7a1e379fc5d463
45f28d1eb69a471161328f2218a8a833f823184a
/CodeBook_code/Graph/minimum_mean_cycle.cpp
d004dbb79486fed759a1e0496ee0e58c8529b2d9
[]
no_license
johntsung/Programming-Contest
eb0566fe6619d3eb4d2155fcbe6f692e502755aa
c273408405cf5f5cb951125b7e8924c1cb184378
refs/heads/master
2022-02-20T06:38:38.490508
2022-02-13T13:48:21
2022-02-13T13:48:21
231,524,210
4
0
null
null
null
null
UTF-8
C++
false
false
1,463
cpp
minimum_mean_cycle.cpp
# include <stdio.h> # include <vector> # include <queue> # include <algorithm> using namespace std ; struct edge{ int to,w; edge(int a=0,int b=0): to(a),w(b){} }; vector<edge> g[1024]; int dp[1024][1024], inq[1024][1024]; const int MAXE=1000 ; void solve(int source,int N){ for(int i=0;i<N;i++) for (int j=0;j<=MAXE;j++) dp[i][j]=0x3f3f3f3f; queue<int> X,E; int u,v,w,e; dp[source][0]=0 ; X.push(source),E.push(0); while(!X.empty()) { u=X.front(),X.pop(); e=E.front(),E.pop(); inq[u][e]= 0 ; if(e==MAXE) continue ; for (int i=0;i<g[u].size();i++){ v=g[u][i].to,w=g[u][i].w; if(dp[v][e+1]>dp[u][e]+w) { dp[v][e+ 1]=dp[u][e]+w; if(!inq[v][e+1]){ inq[v][e+1]=1; X.push(v),E.push(e+1); } } } } } int main () { int N,M,S,Q; int x,y,w; while(scanf("%d %d %d",&N,&M,&S)==3){ for (int i=0;i<N;i++) g[i].clear(); for(int i=0;i<M;i++) { scanf ("%d %d %d",&x,&y,&w); g[x].push_back(edge(y,w)); } solve(S,N); scanf("%d" ,&Q); while(Q--){ scanf("%d",&x); double ret= 1e+30 ; int e=-1 ; if(x==S) ret=0,e=0 ; else{ for(int i=1;i<=MAXE;i++){ if(dp[x][i]!=0x3f3f3f3f){ if((double)dp[x][i]/i<ret){ ret=(double)dp[x][i]/i; e=i; } } } } if (e==-1) puts("No Path"); else printf ("%.4lf %d\n",ret,e); } puts(""); } return 0 ; }
12c959319c29b5adeab2c31daab4e5d2232a536e
5b41e312db8aeb5532ba59498c93e2ec1dccd4ff
/SMC_DBClasses/CGC_DELAY_GROUP.cpp
67fc4ce6ae2ec4ee566087816b828c57e06c857c
[]
no_license
frankilfrancis/KPO_HMI_vs17
10d96c6cb4aebffb83254e6ca38fe6d1033eba79
de49aa55eccd8a7abc165f6057088a28426a1ceb
refs/heads/master
2020-04-15T16:40:14.366351
2019-11-14T15:33:25
2019-11-14T15:33:25
164,845,188
0
1
null
null
null
null
UTF-8
C++
false
false
2,373
cpp
CGC_DELAY_GROUP.cpp
//## Copyright (C) 2009 SMS Siemag AG, Germany //## Version generated by DBClassCodeUtility BETA 0.6.3 //## ALL METHODS MARKED AS - //##DBClassCodeUtility - WILL BE OVERWRITTEN, IF DB CLASS RE-GENERATED //## MANUALLY IMPLEMENTED METHODS MUST BE LOCATED BELOW THE MARK - "YOUR-CODE" - #include "CGC_DELAY_GROUP.h" //##DBClassCodeUtility ! DO NOT EDIT ! const std::string CGC_DELAY_GROUP::GROUPNO("GROUPNO"); //##DBClassCodeUtility ! DO NOT EDIT ! const std::string CGC_DELAY_GROUP::GROUPNAME("GROUPNAME"); //##DBClassCodeUtility ! DO NOT EDIT ! CGC_DELAY_GROUP::CGC_DELAY_GROUP(cCBS_StdConnection* Connection) :CSMC_DBData("GC_DELAY_GROUP",Connection) { //please implement virtual method, to initialize your members doOnConstruct(); } //##DBClassCodeUtility ! DO NOT EDIT ! CGC_DELAY_GROUP::CGC_DELAY_GROUP(cCBS_Connection* Connection) :CSMC_DBData("GC_DELAY_GROUP",Connection) { //please implement virtual method, to initialize your members doOnConstruct(); } //##DBClassCodeUtility ! DO NOT EDIT ! CGC_DELAY_GROUP::CGC_DELAY_GROUP() :CSMC_DBData("GC_DELAY_GROUP") { //please implement virtual method, to initialize your members doOnConstruct(); } //##DBClassCodeUtility ! DO NOT EDIT ! CGC_DELAY_GROUP::~CGC_DELAY_GROUP() { //please implement virtual method, to destruct your members doOnDestruct(); } //##DBClassCodeUtility ! DO NOT EDIT ! long CGC_DELAY_GROUP::getGROUPNO(long Row) { return getLong(CGC_DELAY_GROUP::GROUPNO, Row); } //##DBClassCodeUtility ! DO NOT EDIT ! void CGC_DELAY_GROUP::setGROUPNO(long value) { setLong(CGC_DELAY_GROUP::GROUPNO, value); } //##DBClassCodeUtility ! DO NOT EDIT ! std::string CGC_DELAY_GROUP::getGROUPNAME(long Row) { return getString(CGC_DELAY_GROUP::GROUPNAME, Row); } //##DBClassCodeUtility ! DO NOT EDIT ! void CGC_DELAY_GROUP::setGROUPNAME(const std::string& value) { setString(CGC_DELAY_GROUP::GROUPNAME, value); } //##DBClassCodeUtility ! DO NOT EDIT ! bool CGC_DELAY_GROUP::select(long GROUPNO) { cleanWhereStatement(); m_Statement = "Select * from " + m_TableName; addWhereClause(CGC_DELAY_GROUP::GROUPNO,GROUPNO); m_Statement += getWhereStatement() + ";"; return CSMC_DBData::select(); } //## ------------------------------------END-GENERATED-CODE---------------------- //## ------------------------------------YOUR-CODE-------------------------------
4393e43862591b91be7b37561da42979d78bae7b
9e548d7b078c187d9ec04797a9eeb0dd1e4e9aa5
/Highly_Important_Backup/JPEG_Thesis_2/Final_PR/HUFFMAN_SYSTEM_SDK/HUFFMAN_SYSTEM_SDK.sdk/HUFFMAN_REV2_IP_TEST/src/main.cc
5dacbe2e5d41e5a61b132e58bcb1cf18a99ce856
[]
no_license
yisea123/FPGA_Research
b4d7912806da6f44cc5cb51e296e093f119bec2d
5e018ab1d1168c2a0d275cc93cb72e1e747338c4
refs/heads/master
2020-08-27T16:40:40.128967
2017-11-28T10:37:16
2017-11-28T10:37:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,777
cc
main.cc
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <time.h> #include "xparameters.h" #include "xil_printf.h" #include "xil_cache.h" #include "ff.h" #include "xdevcfg.h" #include "xil_io.h" #include "xil_types.h" #include "xbasic_types.h" #include "xil_exception.h" #include "xsdps.h" #include "math.h" #include "string.h" using namespace std; const int image_size = 512; FRESULT result; // FRESULT variable // Generic variables int sample_block[64*64][64]; short int dc_value[64*64]; // Huffman variables unsigned int bit_length=0; int huffman_encoded_out [64*64][16]; unsigned short int huffman_last_bit[64*64]; int sample_data[64]={0x4,0x0,0xffd,0x5,0xfff,0xf,0x0,0x4,0xfff,0xd,0xfff,0x0,0x0}; int *huffman = (int*)XPAR_HUFFMAN_REV2_IP_0_S00_AXI_BASEADDR; int get_huffman() { *(huffman + 0) = 0x0; // Activate Reset for(int i = 1000; i >0; i--){;} // 10k original, 1000 gives 13 us delay *(huffman+129)=0xd; // Inputs to RLE Module for(int idx = 0; idx <13; idx ++) { *(huffman + 1+ idx) = sample_data[idx]; } for(int idx = 13; idx <128; idx ++) { *(huffman + 1+ idx) = 0x0; } *(huffman + 0) = 0x1; // Reactive Reset and start sending input signals for(int i = 1000; i >0; i--){;} // 10k original, 1000 gives 13 us delay while(!(*(huffman + 259)==1));// Check Valid Signal is active or not huffman_last_bit[0] = *(huffman+258); printf("huffman_last_bit: %d\n", huffman_last_bit[0]); // Sample the Outputs for(int m=0;m<16; m++) { huffman_encoded_out[0][m] = *(huffman + m + 130); printf("huff_data: 0x%x\n",huffman_encoded_out[0][m]); } *(huffman + 0) = 0x0; // Activate Reset for(int i = 1000; i >0; i--){;} // 10k original, 1000 gives 13 us delay return 0; } int main() { get_huffman(); return 0; }
1ae6f239ddb8c2606627230093e3a9dfd97fe7f9
45a27173885387e89f9a5a22390229ec93b512ff
/PhysUtils/interface/TrackVertex.hpp
4b2ee9908af196abf568e2e0266c603b00418049
[ "MIT" ]
permissive
yimuchen/UserUtils
a15c53c1d364bb0a40774584cd293449cf4aeb11
041030abbf4f1fb65d12d1c76f021713f7059fe1
refs/heads/master
2022-07-22T16:41:36.622119
2022-07-07T16:41:02
2022-07-07T16:41:02
134,058,566
0
1
null
null
null
null
UTF-8
C++
false
false
485
hpp
TrackVertex.hpp
/** * @file ObjectExtendedVars.hpp * @author [Yi-Mu "Enoch" Chen](https://github.com/yimuchen/) * @brief additional calculation of track and vertex related values */ #ifndef USERUTILS_PHYSUTILS_TRACKVERTEX_HPP #define USERUTILS_PHYSUTILS_TRACKVERTEX_HPP #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" #include "TLorentzVector.h" /** * @addtogroup extendedvar * @{ */ extern TLorentzVector TransientVertexP4( const TransientVertex& ); /** @} */ #endif
67299d5341f3d4affd5c2dc860c021fb70690283
e48a40b19ebe1ca64d877885f9f19e9a78b192c3
/Examples/Cxx/WidgetsTour/Widgets/vtkKWRadioButton.cxx
f2b26890eae2d932c2cfbbcfbf18846fdefe2b91
[]
no_license
SIVICLab/KWWidgets
dbe2034caf065c30eafed92d73e9df9ff60a6565
f5a3e16063db773eaf79736ec31314d392fa934d
refs/heads/master
2021-01-18T20:08:02.372034
2017-04-01T20:57:19
2017-04-01T20:57:19
86,941,196
1
0
null
2017-04-01T20:34:24
2017-04-01T20:34:23
null
UTF-8
C++
false
false
5,120
cxx
vtkKWRadioButton.cxx
#include "vtkKWRadioButton.h" #include "vtkKWRadioButtonSet.h" #include "vtkKWApplication.h" #include "vtkKWWindow.h" #include "vtkKWIcon.h" #include <vtksys/stl/string> #include "vtkKWWidgetsTourExample.h" class vtkKWRadioButtonItem : public KWWidgetsTourItem { public: virtual int GetType(); virtual void Create(vtkKWWidget *parent, vtkKWWindow *); }; void vtkKWRadioButtonItem::Create(vtkKWWidget *parent, vtkKWWindow *) { vtkKWApplication *app = parent->GetApplication(); // ----------------------------------------------------------------------- // Create two radiobuttons. // They share the same variable name and each one has a different internal // value. vtkKWRadioButton *radiob1 = vtkKWRadioButton::New(); radiob1->SetParent(parent); radiob1->Create(); radiob1->SetText("A radiobutton"); radiob1->SetValueAsInt(123); vtkKWRadioButton *radiob1b = vtkKWRadioButton::New(); radiob1b->SetParent(parent); radiob1b->Create(); radiob1b->SetText("Another radiobutton"); radiob1b->SetValueAsInt(456); radiob1->SetSelectedState(1); radiob1b->SetVariableName(radiob1->GetVariableName()); app->Script("pack %s -side top -anchor nw -expand n -padx 2 -pady 2", radiob1->GetWidgetName()); app->Script("pack %s -side top -anchor nw -expand n -padx 2 -pady 2", radiob1b->GetWidgetName()); // ----------------------------------------------------------------------- // Create two radiobuttons. Use icons // They share the same variable name and each one has a different internal // value. vtkKWRadioButton *radiob2 = vtkKWRadioButton::New(); radiob2->SetParent(parent); radiob2->Create(); radiob2->SetImageToPredefinedIcon(vtkKWIcon::IconPlus); radiob2->IndicatorVisibilityOff(); radiob2->SetValue("foo"); vtkKWRadioButton *radiob2b = vtkKWRadioButton::New(); radiob2b->SetParent(parent); radiob2b->Create(); radiob2b->SetImageToPredefinedIcon(vtkKWIcon::IconMinus); radiob2b->IndicatorVisibilityOff(); radiob2b->SetValue("bar"); radiob2->SetSelectedState(1); radiob2b->SetVariableName(radiob2->GetVariableName()); app->Script("pack %s -side top -anchor nw -expand n -padx 2 -pady 2", radiob2->GetWidgetName()); app->Script("pack %s -side top -anchor nw -expand n -padx 2 -pady 2", radiob2b->GetWidgetName()); // ----------------------------------------------------------------------- // Create two radiobuttons. Use both labels and icons // They share the same variable name and each one has a different internal // value. vtkKWRadioButton *radiob3 = vtkKWRadioButton::New(); radiob3->SetParent(parent); radiob3->Create(); radiob3->SetText("Linear"); radiob3->SetImageToPredefinedIcon(vtkKWIcon::IconGridLinear); radiob3->SetCompoundModeToLeft(); radiob3->IndicatorVisibilityOff(); radiob3->SetValue("foo"); vtkKWRadioButton *radiob3b = vtkKWRadioButton::New(); radiob3b->SetParent(parent); radiob3b->Create(); radiob3b->SetText("Log"); radiob3b->SetImageToPredefinedIcon(vtkKWIcon::IconGridLog); radiob3b->SetCompoundModeToLeft(); radiob3b->IndicatorVisibilityOff(); radiob3b->SetValue("bar"); radiob3->SetSelectedState(1); radiob3b->SetVariableName(radiob3->GetVariableName()); app->Script("pack %s -side top -anchor nw -expand n -padx 2 -pady 2", radiob3->GetWidgetName()); app->Script("pack %s -side top -anchor nw -expand n -padx 2 -pady 2", radiob3b->GetWidgetName()); // ----------------------------------------------------------------------- // Create a set of radiobutton // An easy way to create a bunch of related widgets without allocating // them one by one vtkKWRadioButtonSet *radiob_set = vtkKWRadioButtonSet::New(); radiob_set->SetParent(parent); radiob_set->Create(); radiob_set->SetBorderWidth(2); radiob_set->SetReliefToGroove(); char buffer[50]; for (int id = 0; id < 4; id++) { sprintf(buffer, "Radiobutton %d", id); vtkKWRadioButton *radiob = radiob_set->AddWidget(id); radiob->SetText(buffer); radiob->SetBalloonHelpString( "This radiobutton is part of a unique set (a vtkKWRadioButtonSet), " "which provides an easy way to create a bunch of related widgets " "without allocating them one by one. The widgets can be layout as a " "NxM grid. This classes automatically set the same variable name " "among all radiobuttons, as well as a unique value."); } radiob_set->GetWidget(0)->SetSelectedState(1); app->Script( "pack %s -side top -anchor nw -expand n -padx 2 -pady 6", radiob_set->GetWidgetName()); radiob1->Delete(); radiob1b->Delete(); radiob2->Delete(); radiob2b->Delete(); radiob3->Delete(); radiob3b->Delete(); radiob_set->Delete(); // ----------------------------------------------------------------------- // TODO: use vtkKWRadioButtonSetWithLabel and callbacks } int vtkKWRadioButtonItem::GetType() { return KWWidgetsTourItem::TypeCore; } KWWidgetsTourItem* vtkKWRadioButtonEntryPoint() { return new vtkKWRadioButtonItem(); }
e1734ffae4561ab83aa82685ddd36e4dfe5069b8
b7461a64f31f5d556863b572c31693e98474132f
/Pipelined-IF.h
4475af5b10ec046d6d240c66b351c420f4b0e1de
[ "MIT" ]
permissive
dirkcgrunwald/dirkdlx-systemc
a55e5b050c26c903801bcc18f31051fe9da75bb0
e07f3c183bdd1afff18ef3971b94ba75601ad260
refs/heads/master
2021-01-10T12:05:57.393031
2015-10-13T18:09:40
2015-10-13T18:09:40
44,195,250
0
0
null
null
null
null
UTF-8
C++
false
false
577
h
Pipelined-IF.h
//-*-c++-*- #ifndef _Pipelined_IF_h_ #define _Pipelined_IF_h_ #include "systemc.h" #include "Pipelined.h" #include "DLXMemory.h" #include "DLXMachineState.h" struct Pipelined_IF : public sc_module { // // Define ports // sc_out<StateIF2ID> to_decode; sc_out<bool> decode_ready; sc_in<State2IF> from_wb; sc_in<bool> reset; sc_in_clk clock; sc_inout<bool> ready; bool debug; bool wasDelayedBranch; SC_CTOR(Pipelined_IF) { debug = false; SC_CTHREAD(fetch, clock.pos()); watching(reset.delayed() == true); } void fetch(); }; #endif
36f65558b15a1b15989badb280f4fd1aa29ffbb2
1076f51d61d68609af23cde5145d6a7a5b80d175
/scene.h
651c61484e6b9ca10c8c951e50e0ff79d94ad9f5
[]
no_license
TheZino/DistributedRayTracer
f488d84ac70adee3270452767bee803fa165267a
91eec6777cf41bd478f697510826bbd0676bb766
refs/heads/master
2021-01-23T17:35:57.321202
2018-03-01T14:51:57
2018-03-01T14:51:57
102,768,369
0
0
null
null
null
null
UTF-8
C++
false
false
1,022
h
scene.h
#ifndef SCENE_H #define SCENE_H #include <opencv2/opencv.hpp> #include <vector> #include <glm/glm.hpp> #include <typeinfo> #include <math.h> #include <random> #include <cmath> #include <chrono> #include "objects.h" #include "elements.h" #include "utils.h" class Scene { public: std::vector<Object*> objs; std::vector<Light*> lights; bool soft_shadows; Scene(bool soft_shadows_): soft_shadows(soft_shadows_){}; void add(Object *obj); void add_light(Light *l); int objs_number(); Scene world_to_camera(glm::mat4 Mwc); ObjIntersection intersect(ray r); glm::vec3 trace(ray r, glm::vec3 eye); glm::vec3 shade(ObjIntersection intr, ray r, glm::vec3 eye, int recursionDepth, double n1); glm::vec3 reflection(ObjIntersection intr, ray r, int recursionDepth, double n1); glm::vec3 refraction(ObjIntersection intr, ray r, int recursionDepth, double n1); ray random_shadow_ray(glm::vec3 s_position, Light l); ray random_glossy_ray(glm::vec3 s_position, glm::vec3 ref_dir, float density); }; #endif
039b77cce01c2c488f777d1649e8f530ca317f69
94e952fb11e9724dadc83cc0b25386748a782e83
/audio/Music.cpp
39e8bafcefffe0f97c8386576ff37a427dbd51fd
[]
no_license
Towerthousand/VoxelGame
1dc1fdb000192df52ff62a8b1045a8344b448f18
607f2987adeda36d8527e2b2fceb8cc8e9f8cbbe
refs/heads/master
2020-05-17T07:48:51.750442
2014-11-04T23:44:45
2014-11-04T23:44:45
8,186,861
1
0
null
2013-05-20T22:08:51
2013-02-13T20:12:33
C
UTF-8
C++
false
false
242
cpp
Music.cpp
#include "Music.hpp" Music::Music() { } Music::~Music() { } bool Music::loadFromFile(const std::string& filePath) { if (!track.openFromFile(filePath)) { return false; } return true; } sf::Music& Music::getTrack() { return track; }
0bd2916fc8a6f8abdd308fe7c440aa02bc8f9a55
f45e5c33352cc17420226b13a542c60234232663
/DevSprint3/CharacterMovement.h
4cd54830abbeaf195d362ec56e8e12c0d0e3f4cc
[]
no_license
theisen1337/LogicCapStone
3509e0a65c407dba4ae5f7a31dd2b712f4705f7f
b37c8461d22433b85fcbfceb050d99c45f939e7a
refs/heads/master
2021-05-05T09:26:52.132853
2018-05-02T19:21:35
2018-05-02T19:21:35
119,344,162
3
0
null
2018-02-23T22:55:33
2018-01-29T06:56:34
C++
UTF-8
C++
false
false
1,233
h
CharacterMovement.h
#pragma once // Standard Includes #include <vector> #include <math.h> // Custom Includes #include "GlobalStatics.h" #include "World.h" #include "Tile.h" //! Directional Structure struct Compass { bool N; bool E; bool S; bool W; }; class CharacterMovement { public: //! Default Constructor CharacterMovement(); //! Constructor with starting position parameters CharacterMovement(int xPosition, int yPosition); //! Get the x position of the character int & getCharacterXPosition(); //! Set the x position of the character void setCharacterXPosition(int x); //! Get the y position of the character int & getCharacterYPosition(); //! Set the y position of the character void setCharacterYPosition(int y); //! velocity in y direction int vy = 0; //! velocity in x direction int vx = 0; //! move the character horizontally void moveCharacterX(); //! move the character vertically void moveCharacterY(); //! get the speed of the character int getSpeed(); //!direction of player; Compass CharCompass; private: //! y position for the character int characterYPosition = 0; //! x position for the character int characterXPosition = 0; //! speed for how fast the character will move int speed = 5; };
b08fbfad308b9e2b8657c8356839a67bd0c99045
95675b15b654f66bbb1a2ff94b2aeda1edecd84d
/C++_Pro/STL/Hello_STL.cpp
6243ce25cced012bb299436240a54279a776ac5c
[]
no_license
CooperXJ/VScode
ba1a4545438a6ee306d6bc0e5f7793b2e1ebbda5
ef014b1be87ccadd9fee6c28c7ee0013f8b6a835
refs/heads/master
2020-12-28T03:31:00.803698
2020-05-30T13:09:12
2020-05-30T13:09:12
238,139,254
0
0
null
null
null
null
UTF-8
C++
false
false
652
cpp
Hello_STL.cpp
#include <iostream> #include <math.h> #include <vector> #include <algorithm> using namespace std; void print_vector(int val) { cout<<val<<" "; } void test() { vector<int> v; v.push_back(10); v.push_back(20); v.push_back(30); //容器的迭代器 这里指定类型是因为每种数据类型++或者--不同 vector<int>::iterator pBegin = v.begin(); vector<int>::iterator pEnd = v.end(); //容器中可能存放基础的数据类型,也可能存放用户自定义的类型 //因此需要自己提供打印的方法 for_each(pBegin,pEnd,print_vector); } int main() { test(); system("pause"); }
231cfc64c5b6405295474df56505514ff3105d30
0e01a7797a99638f6a9b4db9df06a5c8d94aa7f7
/src/morgana/fmk/resources/images/imagedecoder.h
293d3c5c4101fbd7aa788d0826475b792277a860
[]
no_license
cslobodeanu/hits
c0310a4e0cfa308b353d38e301187e7bc5063555
1cb6663b59cb6c8ee5576d5db276c3828490a110
refs/heads/master
2021-05-11T15:29:42.300945
2018-02-01T19:43:32
2018-02-01T19:43:32
117,730,282
0
0
null
null
null
null
UTF-8
C++
false
false
863
h
imagedecoder.h
#ifndef __MORGANA_FMK_RESOURCES_IMAGES_IMAGE_DECODER_H__ #define __MORGANA_FMK_RESOURCES_IMAGES_IMAGE_DECODER_H__ #include "reflection.h" #include "meio.h" namespace MorganaEngine { namespace Framework { namespace Resources { namespace Images { class ImageFile; class ImageDecoder : public MEObject { __declare_class_abstract(ImageDecoder, MEObject); public: ImageDecoder() {} virtual ~ImageDecoder() {} struct ImageHeader_t { unsigned int width, height, bits, mipmaps; }; virtual bool CanDecode(Stream* s) = 0; virtual bool CanEncode(Stream* s) { return false; } virtual void ReadHeader(Stream* s, ImageHeader_t& header) = 0; virtual void ReadPixels(Stream* s, ImageFile* img) = 0; virtual void WritePixels(Stream* s, ImageFile* img) {}; }; } } } } #endif
c352dc56a194ea7e28249cd847c2dec85172ef2d
2e6b32a56b8f6e09d91d80f88b0a4062b7e51a77
/include/nxsimd/nx_avx_float.hpp
5f11db6eb0d3200a70f5ce6e2868767af642491a
[ "BSD-3-Clause" ]
permissive
mywoodstock/nxsimd
fe99ef05f3ba7a9d77c8b24d133d7a5b6656d92a
ad2c7d73f99f24beee3f00c7176b49f50045777f
refs/heads/master
2021-01-17T07:24:59.271754
2016-03-04T00:20:55
2016-03-04T00:20:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,821
hpp
nx_avx_float.hpp
// // Copyright (c) 2016 Johan Mabille // // All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. // #ifndef NX_AVX_FLOAT_HPP #define NX_AVX_FLOAT_HPP #include "nx_simd_base.hpp" namespace nxsimd { class vector8fb : public simd_vector_bool<vector8fb> { public: vector8fb(); vector8fb(bool b); vector8fb(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7); vector8fb(const __m256& rhs); vector8fb& operator=(const __m256& rhs); operator __256() const; private: __m256 m_value; }; vector8fb operator&(const vector8fb& lhs, const vector8fb& rhs); vector8fb operator|(const vector8fb& lhs, const vector8fb& rhs); vector8fb operator^(const vector8fb& lhs, const vector8fb& rhs); vector8fb operator~(const vector8fb& rhs); vector8fb operator==(const vector8fb& lhs, const vector8fb& rhs); vector8fb operator!=(const vector8fb& lhs, const vector8fb& rhs); class vector8f; template <> struct simd_vector_traits<vector8f> { using value_type = float; using vector_bool = vector8fb; }; class vector8f : public simd_vector<vector8f> { public: vector8f(); vector8f(float f); vector8f(float f0, float f1, float f2, float f3, float f4, float f5, float f6, float f7); vector8f(const __m128& rhs); vector8f& operator=(const __m128& rhs); operator __m128() const; vector8f& load_aligned(const float* src); vector8f& load_unaligned(const float* src); void store_aligned(float* dst) const; void store_unaligned(float* dst) const; private: __m128 m_value; }; vector8f operator-(const vector8f& rhs); vector8f operator+(const vector8f& lhs, const vector8f& rhs); vector8f operator-(const vector8f& lhs, const vector8f& rhs); vector8f operator*(const vector8f& lhs, const vector8f& rhs); vector8f operator/(const vector8f& lhs, const vector8f& rhs); vector8fb operator==(const vector8f& lhs, const vector8f& rhs); vector8fb operator!=(const vector8f& lhs, const vector8f& rhs); vector8fb operator<(const vector8f& lhs, const vector8f& rhs); vector8fb operator<=(const vector8f& lhs, const vector8f& rhs); vector8f operator&(const vector8f& lhs, const vector8f& rhs); vector8f operator|(const vector8f& lhs, const vector8f& rhs); vector8f operator^(const vector8f& lhs, const vector8f& rhs); vector8f operator~(const vector8f& rhs); vector8f min(const vector8f& lhs, const vector8f& rhs); vector8f max(const vector8f& lhs, const vector8f& rhs); vector8f abs(const vector8f& rhs); vector8f fma(const vector8f& x, const vector8f& y, const vector8f& z); vector8f sqrt(const vector8f& rhs); float hadd(const vector8f& rhs); vector8f haddp(const vector8f* row); vector8f select(const vector8fb& cond, const vector8f& a, const vector8f& b); /****************************** * vector8fb implementation ******************************/ inline vector8fb::vector8fb() { } inline vector8fb::vector8fb(bool b) : m_value(_mm256_castsi256_ps(_mm256_set1_epi32(-(int)b))) { } inline vector8fb::vector8fb(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7) : m_value(_mm256_castsi256_ps( _mm256_setr_epi32(-(int)b0, -(int)b1, -(int)b2, -(int)b3, -(int)b4, -(int)b5, -(int)b6, -(int)b7))) { } inline vector8fb::vector8fb(const __m256& rhs) : m_value(rhs) { } inline vector8fb& vector8fb::operator=(const __m256& rhs) { m_value = rhs; return *this; } inline vector8fb::operator __256() const { return m_value; } inline vector8fb operator&(const vector8fb& lhs, const vector8fb& rhs) { return _mm256_and_ps(lhs, rhs); } inline vector8fb operator|(const vector8fb& lhs, const vector8fb& rhs) { return _mm256_or_ps(lhs, rhs); } inline vector8fb operator^(const vector8fb& lhs, const vector8fb& rhs) { return _mm256_xor_ps(lhs, rhs); } inline vector8fb operator~(const vector8fb& rhs) { return _mm256_xor_ps(rhs, _mm256_castsi256_ps(_mm256_set1_epi32(-1))); } inline vector8fb operator==(const vector8fb& lhs, const vector8fb& rhs) { return _mm256_cmp_ps(lhs, rhs, _CMP_EQ_OQ); } inline vector8fb operator!=(const vector8fb& lhs, const vector8fb& rhs) { return _mm256_cmp_ps(lhs, rhs, _CMP_NEQ_OQ); } /***************************** * vector8f implementation *****************************/ inline vector8f::vector8f() { } inline vector8f::vector8f(float f) : m_value(_mm256_set1_ps(f)) { } inline vector8f::vector8f(float f0, float f1, float f2, float f3, float f4, float f5, float f6, float f7) : m_value(_mm256_setr_ps(f0, f1, f2, f3, f4, f5, f6, f7)) { } inline vector8f::vector8f(const __m128& rhs) : m_value(rhs) { } inline vector8f& vector8f::operator=(const __m128& rhs) { m_value = rhs; return *this; } inline vector8f::operator __m128() const { return m_value; } inline vector8f& vector8f::load_aligned(const float* src) { m_value = _mm256_load_ps(src); return *this; } inline vector8f& vetcor8f::load_unaligned(const float* src) { m_value = _mm256_loadu_ps(src); return *this; } inline void vector8f::store_aligned(float* dst) const { _mm256_store_ps(dst, m_value); } inline void vector8f::store_unaligned(float* dst) const { _mm256_store_ps(dst, m_value); } inline vector8f operator-(const vector8f& rhs) { return _mm256_xor_ps(rhs, _mm256_castsi256_ps(_mm256_set1_epi32(0x80000000))); } inline vector8f operator+(const vector8f& lhs, const vector8f& rhs) { return _mm256_add_ps(lhs, rhs); } inline vector8f operator-(const vector8f& lhs, const vector8f& rhs) { return _mm256_sub_ps(lhs, rhs); } inline vector8f operator*(const vector8f& lhs, const vector8f& rhs) { return _mm256_mul_ps(lhs, rhs); } inline vector8f operator/(const vector8f& lhs, const vector8f& rhs) { return _mm256_div_ps(lhs, rhs); } inline vector8fb operator==(const vector8f& lhs, const vector8f& rhs) { return _mm256_cmp_ps(lhs, rhs, _CMP_EQ_OQ); } inline vector8fb operator!=(const vector8f& lhs, const vector8f& rhs) { return _mm256_cmp_ps(lhs, rhs, _CMP_NEQ_OQ); } inline vector8fb operator<(const vector8f& lhs, const vector8f& rhs) { return _mm256_cmp_ps(lhs, rhs, _CMP_LT_OQ); } inline vector8fb operator<=(const vector8f& lhs, const vector8f& rhs) { return _mm256_cmp_ps(lhs, rhs, _CMP_LE_OQ); } inline vector8f operator&(const vector8f& lhs, const vector8f& rhs) { return _mm256_and_ps(lhs, rhs); } inline vector8f operator|(const vector8f& lhs, const vector8f& rhs) { return _mm256_or_ps(lhs, rhs); } inline vector8f operator^(const vector8f& lhs, const vector8f& rhs) { return _mm256_xor_ps(lhs, rhs); } inline vector8f operator~(const vector8f& rhs) { return _mm256_xor_ps(rhs, _mm256_castsi256_ps(_mm256_set1_epi32(-1))); } inline vector8f min(const vector8f& lhs, const vector8f& rhs) { return _mm256_min_ps(lhs, rhs); } inline vector8f max(const vector8f& lhs, const vector8f& rhs) { return _mm256_max_ps(lhs, rhs); } inline vector8f abs(const vector8f& rhs) { __m256 sign_mask = _mm256_set1_ps(-0.f); // -0.f = 1 << 31 return _mm256_andnot_ps(sign_mask, rhs); } inline vector8f fma(const vector8f& x, const vector8f& y, const vector8f& z) { #ifdef __FMA__ return _mm256_fmadd_ps(x, y, z); #else return x * y + z; #endif } inline vector8f sqrt(const vector8f& rhs) { return _mm256_sqrt_ps(rhs); } inline float hadd(const vector8f& rhs) { // Warning about _mm256_hadd_ps: // _mm256_hadd_ps(a,b) gives // (a0+a1,a2+a3,b0+b1,b2+b3,a4+a5,a6+a7,b4+b5,b6+b7). Hence we can't // rely on a naive use of this method // rhs = (x0, x1, x2, x3, x4, x5, x6, x7) // tmp = (x4, x5, x6, x7, x0, x1, x2, x3) __m256 tmp = _mm256_permute2f128_ps(rhs, rhs, 1); // tmp = (x4+x0, x5+x1, x6+x2, x7+x3, x0+x4, x1+x5, x2+x6, x3+x7) tmp = _mm256_add_ps(rhs, tmp); // tmp = (x4+x0+x5+x1, x6+x2+x7+x3, -, -, -, -, -, -) tmp = _mm256_hadd_ps(tmp, tmp); // tmp = (x4+x0+x5+x1+x6+x2+x7+x3, -, -, -, -, -, -, -) tmp = _mm256_hadd_ps(tmp, tmp); return _mm_cvtss_f32(_mm256_extractf128_ps(tmp, 0)); } inline vector8f haddp(const vector8f* row) { // row = (a,b,c,d,e,f,g,h) // tmp0 = (a0+a1, a2+a3, b0+b1, b2+b3, a4+a5, a6+a7, b4+b5, b6+b7) __m256 tmp0 = _mm256_hadd_ps(row[0], row[1]); // tmp1 = (c0+c1, c2+c3, d1+d2, d2+d3, c4+c5, c6+c7, d4+d5, d6+d7) __m256 tmp1 = _mm256_hadd_ps(row[2], row[3]); // tmp1 = (a0+a1+a2+a3, b0+b1+b2+b3, c0+c1+c2+c3, d0+d1+d2+d3, // a4+a5+a6+a7, b4+b5+b6+b7, c4+c5+c6+c7, d4+d5+d6+d7) tmp1 = _mm256_hadd_ps(tmp0, tmp1); // tmp0 = (e0+e1, e2+e3, f0+f1, f2+f3, e4+e5, e6+e7, f4+f5, f6+f7) tmp0 = _mm256_hadd_ps(row[4], row[5]); // tmp2 = (g0+g1, g2+g3, h0+h1, h2+h3, g4+g5, g6+g7, h4+h5, h6+h7) __m256 tmp2 = _mm256_hadd_ps(row[6], row[7]); // tmp2 = (e0+e1+e2+e3, f0+f1+f2+f3, g0+g1+g2+g3, h0+h1+h2+h3, // e4+e5+e6+e7, f4+f5+f6+f7, g4+g5+g6+g7, h4+h5+h6+h7) tmp2 = _mm256_hadd_ps(tmp0, tmp2); // tmp0 = (a0+a1+a2+a3, b0+b1+b2+b3, c0+c1+c2+c3, d0+d1+d2+d3, // e4+e5+e6+e7, f4+f5+f6+f7, g4+g5+g6+g7, h4+h5+h6+h7) tmp0 = _mm256_blend_ps(tmp1, tmp2, 0b11110000); // tmp1 = (a4+a5+a6+a7, b4+b5+b6+b7, c4+c5+c6+c7, d4+d5+d6+d7, // e0+e1+e2+e3, f0+f1+f2+f3, g0+g1+g2+g3, h0+h1+h2+h3) tmp1 = _mm256_permute2f128_ps(tmp1, tmp2, 0x21); return _mm256_add_ps(tmp0, tmp1); } inline vector8f select(const vector8fb& cond, const vector8f& a, const vector8f& b) { return _mm256_blendv_ps(b, a, cond); } } #endif
ac7e38730934211626e1d18392d7cea0ca6c0a46
3c085d6386aa79de4c1b94cbddba5552761c6714
/Fin/src/fin/audio/iaudio.h
d78ae0d0e0391fe2b456aefb50a318cab4e66699
[]
no_license
MeltyPlayer/FinRpg
971840c5ab8fed746f9a293b4e2140d8ae241830
d147067840f97166c5310952457cce4099835010
refs/heads/master
2021-04-26T04:15:44.448591
2018-11-04T02:58:57
2018-11-04T02:58:57
106,984,049
0
0
null
null
null
null
UTF-8
C++
false
false
218
h
iaudio.h
#pragma once #include "fin/app/iservice.h" #include "ilistener.h" namespace fin::audio { class IAudio : public app::IService { public: virtual ~IAudio() {} virtual IListener* get_listener() = 0; }; }
a2b9975438837c9dbb2c071447b25e5056f3fdb6
6257c3de3420e452585365bc86cdd5692935505b
/arrayQuestions/PermutationOfTheOthers.cpp
f56a7a61a0aeae770196a7bd991099555d836898
[]
no_license
VNgwazini/Interview-Prep
f0b4861487afaa420bde84316553363947868f04
839830c5c6b7cfb78ebbaee977635320d911b052
refs/heads/master
2023-06-07T03:04:32.986308
2021-06-30T18:25:52
2021-06-30T18:25:52
380,136,984
0
0
null
null
null
null
UTF-8
C++
false
false
1,050
cpp
PermutationOfTheOthers.cpp
// Given two strings, check if one is a permutiation of the other // i.e cba is permutation of abc #include <iostream> #include <string> #include <vector> #include <algorithm> bool isPermutation(std::string &str1, std::string &str2){ if(str1.size() != str2.size()){ return false; } std::sort(str1.begin(), str1.end()); std::sort(str2.begin(), str2.end()); for(int i = 0; i < str1.size(); i++){ if(str1[i] != str2[i]){ return false; } } return true; } int main(){ std::vector<std::string> myStrings; myStrings.push_back("abc"); myStrings.push_back("cba"); myStrings.push_back("xyz"); myStrings.push_back("abcdefghijklmnopqrstuvwxyz"); for(int i = 1; i < myStrings.size(); i++){ try{ throw isPermutation(myStrings[0], myStrings[i]); } catch(bool result){ if(result){ std::cout << myStrings[i] << " IS permutation of " << myStrings[0] << "\n"; } else{ std::cout << myStrings[i] << " IS NOT permutation of " << myStrings[0] << "\n"; } } } }
91769e03db01dc1b6ffb7f4813650928286460a7
7685e9822983b65187fba2ca6c269cc0f8a88890
/clang/Power/Power.cpp
0054a83197f3ec65ed607e14d7aaefb92bbe0e34
[]
no_license
eush77/mix-examples
1e13b0eb272a3e9d5c60959516877f8b70cf4e69
309fa8f6bbef7dfbcb74688b519c9bc3f60d2d54
refs/heads/main
2023-08-22T14:19:30.342708
2021-09-25T23:41:38
2021-09-25T23:41:38
167,862,084
2
1
null
null
null
null
UTF-8
C++
false
false
1,128
cpp
Power.cpp
#include "../Compiler.h" #include "PowerLin.h" #include "PowerLog.h" #include "benchmark/benchmark.h" #include <string> namespace { void BM_PowerLin(benchmark::State &S) { unsigned N = S.range(0); for (auto _ : S) benchmark::DoNotOptimize(powerLin(2, N)); } void BM_PowerLinMix(benchmark::State &S) { unsigned N = S.range(0); Compiler C("PowerLin." + std::to_string(N)); C.setFunction(mixPowerLin(&C.getContext(), N)); auto *F = reinterpret_cast<int (*)(int)>(C.compile()); for (auto _ : S) benchmark::DoNotOptimize(F(2)); } void BM_PowerLog(benchmark::State &S) { unsigned N = S.range(0); for (auto _ : S) benchmark::DoNotOptimize(powerLog(2, N)); } void BM_PowerLogMix(benchmark::State &S) { unsigned N = S.range(0); Compiler C("PowerLog." + std::to_string(N)); C.setFunction(mixPowerLog(&C.getContext(), N)); auto *F = reinterpret_cast<int (*)(int)>(C.compile()); for (auto _ : S) benchmark::DoNotOptimize(F(2)); } BENCHMARK(BM_PowerLin)->Arg(10); BENCHMARK(BM_PowerLinMix)->Arg(10); BENCHMARK(BM_PowerLog)->Arg(10); BENCHMARK(BM_PowerLogMix)->Arg(10); } // namespace
efcc83ff6d9e63f0867d4c5f96237e6f5e6e3414
5a1d3819eb0179b8571868216fbf7c35fe163c9a
/09_10_strings_dynamic_memory/01/01.cpp
82a8f77491eb5c73637c5c2fb44ecc38524836e4
[ "MIT" ]
permissive
SurPichuk/intro-to-programming-labs
2aa60b9694c9cef4cb170fa64f07fd0487633db9
083bfaad1fdb423c0d8320b3e882316fa56c0bf8
refs/heads/main
2023-02-27T19:08:00.379893
2021-02-07T17:14:39
2021-02-07T17:14:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
236
cpp
01.cpp
#include <iostream> const int MAX_LEN = 129; int main() { char first_name[MAX_LEN]; char last_name[MAX_LEN]; std::cin >> first_name; std::cin >> last_name; std::cout << last_name << ", " << first_name << "\n"; }
16d62141b9061daa7a3d9eb69fcb02ffd2e4a128
a4a158161808c77cdd4dd5a992b93a6e4ca6894c
/check_files.cpp
6d608497019bd0538949cbcd474ac24ccc7c128c
[]
no_license
clmello/dropbox
472b2ef1b80e6ead6f4667861e9257e2ef00b826
90aeaf4d0a82c4f685d14cc68616aeaf82705ec7
refs/heads/master
2020-05-14T22:56:31.522002
2019-07-01T11:20:52
2019-07-01T11:20:52
181,987,400
0
0
null
null
null
null
UTF-8
C++
false
false
4,830
cpp
check_files.cpp
#include <iostream> #include <unistd.h> #include <string.h> #include <dirent.h> #include <sys/stat.h> #include <vector> using namespace std; int time_between_checks = 10; struct file{time_t mtime; string name;}; vector<file> watched_files; string path = "/home/alack/alack_syncdir"; void check_files() { int err = 0; // If files are already being watched if(watched_files.size()>0) { DIR* dir = opendir(path.c_str()); if(dir == NULL) cout << "\nerror opening folder\n"; // For each watched file for(unsigned int n = 0; n < watched_files.size(); n++) { // Looks for it in the folder bool found = false; for(struct dirent *d_struct = NULL; (d_struct = readdir(dir)) != NULL; ) { string fileName = d_struct->d_name; if(fileName == watched_files[n].name) { found = true; string file_ = path + "/" + d_struct->d_name; struct stat fileattrib; if(stat(file_.c_str(), &fileattrib) < 0) cout << "\nstat error\n"; // Checks if file was changed if(difftime(watched_files[n].mtime, fileattrib.st_mtime)) { cout << "\n\nthe file " << d_struct->d_name << " has changed!\n It should be uploaded!\n"; watched_files[n].mtime = fileattrib.st_mtime; } } } // If file isn't found, then it has been deleted if(!found) { cout << "\n\nthe file " << watched_files[n].name << " has been deleted!\n It should be deleted on the server!\n"; watched_files.erase(watched_files.begin()+n); } // Reset the position of the directory stream rewinddir(dir); } // Checks for new files rewinddir(dir); if(dir == NULL) cout << "\nerror opening folder\n"; // For every file in the folder for(struct dirent *d_struct = NULL; (d_struct = readdir(dir)) != NULL; ) { // Looks for the file in the vector bool found = false; if(d_struct->d_name[0] != '.') { for(unsigned int n = 0; n < watched_files.size(); n++) { string fileName = d_struct->d_name; if(fileName == watched_files[n].name) { found = true; break; } } if(!found) { cout << "\n\nthe file " << d_struct->d_name << " is new!\n It should be uploaded!\n"; // Start watching file string file_ = path + "/" + d_struct->d_name; struct stat fileattrib; if(stat(file_.c_str(), &fileattrib) < 0) cout << "\nstat error\n"; file newFile; newFile.name = d_struct->d_name; newFile.mtime = fileattrib.st_mtime; watched_files.push_back(newFile); } } } closedir(dir); } // If no files are watched else { DIR* dir = opendir(path.c_str()); if(dir == NULL) cout << "\nerror opening folder\n"; // Loops through files in sync_dir for(struct dirent *d_struct = NULL; (d_struct = readdir(dir)) != NULL; ) { // If there is a file if(d_struct->d_name[0] != '.') { // Start watching file string file_name = path + "/" + d_struct->d_name; struct stat fileattrib; if(stat(file_name.c_str(), &fileattrib) < 0) cout << "\nstat error\n"; file newFile; newFile.name = d_struct->d_name; newFile.mtime = fileattrib.st_mtime; watched_files.push_back(newFile); cout << "\n\nthe file " << d_struct->d_name << " is new!\n It should be uploaded!\n"; } } closedir(dir); } } void printWatchedFiles() { if(watched_files.size() > 0) { cout << "\n\nWATCHED FILES:\n"; for(unsigned int i = 0; i < watched_files.size(); i++) { cout << watched_files[i].name << endl; } cout << endl; } else cout << "\nThere are no watched files\n"; } int main() { printWatchedFiles(); check_files(); sleep(time_between_checks); check_files(); printWatchedFiles(); }
667ad7d9c51873c80582f4e5a9c9345cb8966254
63935269eb5ebc37b63255aaa90cbd9798f3fcc9
/CSC17A SPR14/Assignment 033114/CSC17A_Chap11_Prob5_032614/main.cpp
f1aa50a62f1d79e3f20d7fbe2431cb51ccfbdffc
[]
no_license
ttendohv/vh2436779
13f1ae76f2d2bd0a356515358f5207034d9f09e6
54bf58fbde45b087acf565f2f3bd65995f401bc4
refs/heads/master
2021-04-09T17:19:55.086782
2014-06-09T19:39:16
2014-06-09T19:39:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,268
cpp
main.cpp
/* * File: main.cpp * Author: Victoria Hodnett * Created on March 26, 2014, 1:44 PM * Gaddis Chapter 11 Problem 5 * Weather Statistics */ //System Libraries #include <iostream> #include <iomanip> using namespace std; //User-Defined Libraries #include "WthrStats.h" //Global Constants //Function Prototypes void inpData(WthrData[],int); float rainfall(WthrData[],int,float&,float&); void sort(WthrData[],int[],int[],int); string monthN(int); //Execution int main(int argc, char** argv) { //Declare variables int SIZE=12; WthrData year1[SIZE]; float avgRain,totRain,avgTmp; int highTmp[SIZE],lowTmp[SIZE]; //Input inpData(year1,SIZE); for(int i=0;i<SIZE;i++){ highTmp[i]=i; lowTmp[i]=i; } //Totals and averages avgRain=rainfall(year1,SIZE,totRain,avgTmp); //Sort temperatures sort(year1,highTmp,lowTmp,SIZE); //Print cout << "Testing: " << APRIL+1 << " " << year1[APRIL].totRain << endl; cout << setprecision(2) << fixed << showpoint; cout << "Average monthly rainfall: " << avgRain << endl; cout << "Total rainfall for the year: " << totRain << endl; cout << "Highest temperature for the year: " << year1[highTmp[0]].highTmp << " in " << monthN(highTmp[0]) << endl; cout << "Lowest temperature for the year: " << year1[lowTmp[0]].lowTmp << " in " << monthN(lowTmp[0]) << endl; cout << "Average temperature for the year: " << avgTmp << endl; //Exit return 0; } string monthN(int m){ switch(m){ case JANUARY: return "January"; break; case FEBRUARY: return "February"; break; case MARCH: return "March"; break; case APRIL: return "April"; break; case MAY: return "May"; break; case JUNE: return "June"; break; case JULY: return "July"; break; case AUGUST: return "August"; break; case SEPTEMBER: return "September"; break; case OCTOBER: return "October"; break; case NOVEMBER: return "November"; break; case DECEMBER: return "December"; break; } } void inpData(WthrData a[],int size){ //Month index=JANUARY; cout << "Please enter weather data for the " "entire year, starting with January\n" "(Temperatures must be between -100 and 145" "degrees Fahrenheiht) " << endl << endl; for(int index=JANUARY;index<size;index++){ cout << "Month " << index+1 << ": " << endl; cout << "Total Rainfall: "; cin >> a[index].totRain; do{ cout << "High Temperature: "; cin >> a[index].highTmp; }while(a[index].highTmp>145||a[index].highTmp<-100); do{ cout << "Low Temperature: "; cin >> a[index].lowTmp; }while(a[index].lowTmp>145||a[index].lowTmp<-100); a[index].avgTmp=((a[index].highTmp+a[index].lowTmp)/2.0); cout << setprecision(2) << fixed << showpoint; cout << "Average Temperature: " << a[index].avgTmp << endl; cout << endl; } } float rainfall(WthrData a[],int size,float &total,float &temp){ float sum=0.0; for(int index=JANUARY;index<size;index++){ sum+=a[index].avgTmp; } temp=sum/size; sum=0.0; for(int index=JANUARY;index<size;index++) sum+=a[index].totRain; total=sum; return sum/size; } void sort(WthrData a[],int indx[],int indx1[],int size){ for(int i=0;i<size-1;i++){ for(int j=i+1;j<size;j++){ if((a[indx[i]].highTmp)<(a[indx[j]].highTmp)){ int temp=indx[i]; indx[i]=indx[j]; indx[j]=temp; } } } for(int i=0;i<size-1;i++){ for(int j=i+1;j<size;j++){ if((a[indx1[i]].lowTmp)>(a[indx1[j]].lowTmp)){ int temp=indx1[i]; indx1[i]=indx1[j]; indx1[j]=temp; } } } }
3f73da50686ea375e568dafa6457bd01cd0b7716
eca2965b6f3c9b887acf4842b7c4a5437ebbef6e
/1/wallFilmRegion/deltaf
c4668e0db2763d7518ae917c0d06b8b5c680f9f4
[]
no_license
canesin/CasoSuperficiePlana
9c2fa7a7c73bffa2b18d9647618178c38d85ea03
bbfa4013c702ae7f2e895867297b096c9015b4d5
refs/heads/master
2016-09-05T23:07:15.957094
2012-06-27T21:37:21
2012-06-27T21:37:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
46,111
deltaf
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.1.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "1"; object deltaf; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 0 0 0 0 0]; internalField nonuniform List<scalar> 2828 ( 2.195462715e-06 3.004735056e-06 9.881051358e-06 2.181294251e-05 3.47861615e-05 1.42583922e-05 1.615878843e-05 3.627946087e-05 3.762938032e-05 1.695441723e-06 3.88863904e-06 1.40548615e-05 2.755562495e-05 3.911232147e-05 4.794319767e-05 5.592331609e-05 6.121690294e-05 1.738217182e-05 2.668102114e-05 2.483333939e-05 2.844391339e-05 3.384441862e-05 3.014351099e-05 1.50591477e-06 5.7625744e-06 1.840010107e-05 3.170914312e-05 4.020238081e-05 4.463446342e-05 4.723245468e-05 6.024611338e-05 6.47769854e-05 7.067903143e-05 1.747788982e-05 1.951256442e-05 3.377349897e-05 4.047063404e-05 3.993828133e-05 3.133787689e-05 2.085729001e-05 1.965728318e-06 8.50457462e-06 2.047225157e-05 2.951345627e-05 3.285473313e-05 3.301155907e-05 3.2636269e-05 7.435946964e-05 8.836769191e-05 8.260552638e-05 9.273008007e-05 0.0001121962667 3.467239087e-05 2.66427923e-05 2.57196532e-05 3.691660969e-05 4.635847716e-05 4.277846267e-05 2.732875293e-05 1.521717236e-05 3.90904554e-06 1.242577402e-05 2.011425578e-05 2.325621039e-05 2.398363068e-05 2.639365343e-05 3.457847074e-05 6.591307885e-05 0.0001112797329 0.000118301463 0.0001216520311 0.0001389012995 0.0001511236054 5.506467787e-05 3.167538348e-05 2.139413287e-05 2.25806142e-05 3.680549833e-05 3.948287585e-05 3.489243905e-05 1.909776911e-05 1.186236335e-05 1.009850893e-05 1.722200659e-05 1.899082472e-05 1.883400262e-05 2.236052638e-05 3.190155077e-05 5.262993338e-05 4.769864581e-05 8.836525768e-05 0.0001255214277 0.0001422176722 0.0001619757121 0.0001739386306 0.0001673976028 7.084688686e-05 4.431067041e-05 1.765190132e-05 1.008482363e-05 1.209164491e-05 3.466236777e-05 2.624896086e-05 2.221372081e-05 2.306658334e-05 9.115805195e-06 1.633785898e-05 2.043873102e-05 1.890558036e-05 1.946347722e-05 2.690793056e-05 3.955310609e-05 5.509146748e-05 5.764913963e-05 8.126876819e-05 0.0001119087998 0.0001399723233 0.0001673127428 0.0001812302874 0.0001707867585 6.727541291e-05 6.51221148e-05 2.866747478e-05 8.553981302e-06 3.613163113e-06 3.972217564e-06 2.254476891e-05 1.46129132e-05 1.21744174e-05 0.0002256656868 7.139298633e-06 1.515461823e-05 1.866130207e-05 1.850626104e-05 2.167764003e-05 3.087795756e-05 4.282269316e-05 5.5504612e-05 7.19208471e-05 8.721438947e-05 0.0001054507287 0.0001304805556 0.0001588175022 0.000172604055 0.0001583148991 0.0001310789958 5.763491414e-05 4.410062652e-05 1.742128914e-05 4.820965084e-06 1.333818804e-06 7.490929337e-07 5.353843511e-06 7.111677017e-06 3.660998365e-06 2.423626475e-05 5.038168127e-06 1.10725447e-05 1.397969966e-05 1.663590708e-05 2.476384366e-05 3.846204351e-05 5.242804098e-05 6.390281859e-05 7.433813673e-05 8.578564967e-05 0.0001000614389 0.0001208252931 0.0001454106139 0.0001543956155 0.0001345987519 0.0001063833586 9.116794137e-05 3.488852404e-05 3.850413584e-05 2.416782347e-05 9.718710642e-06 3.172411132e-06 1.355369762e-06 1.480965994e-06 2.957445279e-07 2.892064275e-06 2.980696383e-06 2.843729524e-06 6.278015397e-06 8.628481546e-06 1.116362064e-05 1.876112959e-05 3.298152577e-05 5.215708062e-05 7.123348874e-05 8.534329817e-05 9.349398091e-05 9.854815329e-05 0.0001046815121 0.0001171129852 0.0001330465295 0.0001326290225 0.0001060705902 7.775597063e-05 7.118483702e-05 2.237278763e-05 2.114611364e-05 1.175518654e-05 4.970138844e-06 3.086856559e-06 8.981291283e-06 1.9286162e-05 1.682397576e-07 5.286299017e-07 2.252972197e-06 3.03414625e-06 4.961535856e-06 7.170410057e-06 1.368492088e-05 4.770530692e-05 5.488578509e-05 6.313131534e-05 8.253622789e-05 0.0001021380789 0.0001138129803 0.0001163155426 0.000114995699 0.0001174239428 0.0001216010491 0.0001098340698 7.824520935e-05 5.212420747e-05 4.851135156e-05 1.239843917e-05 1.147929421e-05 7.585117896e-06 4.391038176e-06 5.7371552e-06 2.219405293e-05 3.858021568e-05 4.050832477e-08 6.823990762e-08 8.602172241e-07 2.11579522e-06 4.2605862e-06 1.216928493e-05 2.97056148e-05 8.589874804e-05 0.0001062643914 8.285504062e-05 8.726148946e-05 0.0001065308969 0.0001227880877 0.0001276135842 0.0001226360284 0.0001159005621 0.0001077557587 8.630503196e-05 5.426385036e-05 3.306666136e-05 3.055800371e-05 3.680827349e-05 4.299037241e-06 5.161201222e-06 5.485514304e-06 6.002514446e-06 8.633393272e-06 3.603295743e-05 3.793727457e-05 4.699510426e-08 2.567790995e-09 5.745443207e-07 2.133332262e-06 8.266604234e-06 2.432290114e-05 5.489152793e-05 6.869597795e-05 0.0001093581548 0.0001078576264 9.95841294e-05 0.0001114282943 0.0001260003688 0.0001310216081 0.0001227425387 0.0001074353571 8.85445844e-05 6.219258604e-05 3.508176886e-05 2.020128262e-05 1.708071611e-05 2.221943565e-05 1.601367603e-05 1.591800966e-06 1.403769677e-06 3.295038033e-06 1.084883835e-05 1.99449054e-05 4.699848276e-05 2.149242565e-05 3.384054002e-07 3.676858397e-09 6.823851912e-07 2.946397874e-06 1.275068886e-05 2.72726107e-05 4.577640352e-05 7.017749888e-05 8.784280681e-05 0.0001016982515 0.0001113676427 0.0001207868424 0.0001302808938 0.000129744787 0.0001140646491 8.987698127e-05 6.379941213e-05 3.858932905e-05 1.995788956e-05 1.08848586e-05 7.152478209e-06 6.499915948e-06 4.607262708e-05 2.100990572e-05 9.532136982e-06 5.936671873e-06 3.143037453e-06 1.833562721e-05 3.146878754e-05 8.083534789e-06 1.36636895e-05 1.355791313e-06 1.761553685e-06 6.484030112e-06 1.559965651e-05 2.749039647e-05 4.316503192e-05 6.365973287e-05 8.660985805e-05 0.0001063840033 0.0001185586853 0.0001277396647 0.000133009818 0.0001221146351 9.548400769e-05 6.461329998e-05 3.730959279e-05 1.8071483e-05 8.322174282e-06 3.557667355e-06 1.654573091e-06 1.269006193e-06 5.274477993e-05 1.866967205e-05 2.239816449e-06 9.238012036e-08 1.526469514e-07 1.406885289e-06 6.033731512e-06 1.573850333e-06 1.555294391e-05 1.556267028e-05 4.91290501e-06 1.242859844e-05 2.349193374e-05 3.685089529e-05 5.26325549e-05 7.055523307e-05 9.085387271e-05 0.0001100152872 0.0001213577858 0.0001307396566 0.0001294153815 0.0001036463211 6.761889353e-05 3.712241054e-05 1.568363097e-05 5.043337302e-06 2.349193564e-06 8.371380205e-07 3.81471329e-07 3.39742122e-07 5.606416939e-05 2.33951937e-05 3.654178867e-06 2.479825018e-07 7.568491935e-09 4.442469338e-09 8.632876806e-09 4.664138925e-08 1.251436705e-07 1.700467111e-06 7.600953799e-06 1.914431318e-05 3.525853298e-05 5.308983802e-05 6.987040964e-05 8.487243317e-05 0.0001029979734 0.0001193344685 0.0001243253362 0.0001308480454 0.0001150625996 7.302099108e-05 3.649251576e-05 1.52214359e-05 3.854600112e-06 1.219027929e-06 1.063481184e-06 9.975080141e-07 5.155279301e-07 6.233819703e-07 4.822674419e-05 2.582639103e-05 5.852223716e-06 6.301443938e-07 5.575103679e-08 2.967970544e-08 3.543059615e-08 4.182227375e-08 5.367079876e-08 3.696633608e-06 1.321846809e-05 2.880170038e-05 4.870202256e-05 6.836831825e-05 8.296474549e-05 9.524214211e-05 0.0001155706898 0.0001268814265 0.0001216751957 0.0001238895491 8.581158402e-05 3.638285944e-05 1.251428641e-05 4.296934001e-06 2.726436469e-06 3.624444662e-06 7.387235315e-06 1.758068265e-05 2.299540129e-05 2.412476215e-05 2.92259955e-05 1.424854905e-05 4.322886923e-06 2.5715963e-07 9.498523016e-08 7.582804291e-08 6.262347525e-08 7.637185307e-08 7.94331786e-06 2.166598378e-05 4.129350889e-05 6.262098753e-05 7.960548033e-05 8.792612709e-05 9.977366067e-05 0.0001233792306 0.0001203898486 0.0001078143796 0.0001050422547 4.662898436e-05 9.022237876e-06 2.889813033e-06 2.594412636e-06 4.975666283e-06 8.474079503e-06 1.119911619e-05 9.025065521e-06 8.329108239e-06 8.967406728e-06 4.851251995e-05 3.440458676e-05 2.183730797e-05 1.305320348e-05 3.734969791e-06 1.19704879e-07 9.659932846e-08 7.018825476e-06 1.513878454e-05 3.320396103e-05 5.56648121e-05 7.509471486e-05 8.549908967e-05 8.532141404e-05 0.000102427341 0.000115876172 9.428029337e-05 8.369390089e-05 7.35760711e-05 3.333373745e-05 5.207528233e-06 1.719135896e-06 1.47301834e-06 1.279240884e-06 1.47718095e-06 2.299981147e-06 3.946403682e-06 6.420214474e-06 8.560905585e-06 4.812655332e-05 4.587000955e-05 3.99897052e-05 2.390923843e-05 1.668679226e-05 4.886930375e-06 1.971173219e-06 8.262918067e-06 2.434677899e-05 4.767097163e-05 6.994522985e-05 8.302619548e-05 8.387276125e-05 7.519192772e-05 0.0001068018309 7.4522237e-05 7.238758962e-05 4.354574396e-05 4.791595538e-05 7.912581735e-05 8.867823125e-06 1.370908068e-06 4.332551411e-07 1.545821729e-07 1.390623475e-07 5.235377445e-07 3.169398927e-06 8.759529246e-06 2.196915389e-05 4.308399317e-05 3.643688398e-05 1.771417828e-05 3.487546071e-06 3.402311232e-06 1.52915183e-05 3.844429542e-05 6.404888597e-05 8.060225629e-05 8.299124339e-05 7.359862824e-05 5.885572293e-05 0.000122365906 1.150412348e-05 7.504173315e-05 9.719486904e-06 6.69966642e-05 9.976802716e-05 1.679260593e-05 4.115899821e-06 1.569984149e-07 8.205235683e-08 1.671617777e-07 1.207804938e-06 1.409125963e-06 7.859316683e-07 9.695914802e-06 2.711658328e-05 2.721499426e-05 1.46138713e-05 2.078399395e-06 6.902242621e-06 2.74897161e-05 5.685738944e-05 7.839345382e-05 8.288236803e-05 7.289937031e-05 5.61392408e-05 3.974944727e-05 0.000135565095 4.792550153e-07 9.328360285e-05 1.120527709e-05 0.0001159658416 5.509748361e-05 2.205613109e-05 1.01053631e-05 3.224368089e-07 1.2734981e-07 3.365514361e-07 1.723026513e-06 3.939405787e-07 1.952542696e-05 2.102593165e-05 2.087693618e-05 3.197064892e-06 1.457260984e-05 4.696777944e-05 7.632617126e-05 8.422004825e-05 7.305954968e-05 5.400144519e-05 3.576623646e-05 2.291115087e-05 2.448762874e-05 9.721295538e-05 0.0001379975055 0.000205749004 4.751411554e-05 3.759417121e-05 2.841791281e-05 1.341557769e-05 3.198912625e-06 2.311913618e-07 6.805752902e-07 2.187795282e-06 1.091810314e-06 1.716095497e-06 1.147340941e-05 2.011839429e-05 3.186571587e-06 3.082575673e-05 7.362452609e-05 8.825995355e-05 7.47959317e-05 5.18493111e-05 3.168402724e-05 1.801157324e-05 1.476249678e-05 2.350811759e-05 0.0001493046206 1.574236438e-05 9.192713381e-05 4.192092444e-05 3.688213357e-05 3.524740068e-05 2.166816648e-05 4.422019457e-06 3.241587556e-07 1.140937851e-06 2.666308673e-06 7.945172498e-07 1.9082855e-05 2.27323212e-06 6.560079224e-05 9.819159653e-05 7.970557202e-05 4.938250264e-05 2.662830114e-05 1.326547715e-05 6.774144248e-06 3.994533132e-05 4.813237867e-05 5.60455906e-05 1.661587807e-06 5.557283503e-06 3.234306268e-05 2.813057061e-05 3.655617675e-05 3.323013981e-05 1.06956665e-05 3.963145902e-07 1.683493244e-06 7.683725409e-07 1.157561041e-07 0.0001262829196 9.247868359e-05 4.532262355e-05 1.947058568e-05 7.992888764e-06 3.197630728e-06 2.370044063e-06 1.49838355e-05 2.578308903e-06 1.284638609e-06 5.856276609e-06 2.817523363e-06 6.345407855e-06 1.35731216e-05 2.598469001e-05 4.084030661e-05 3.030989668e-05 4.721056673e-07 0.0001361641156 3.092852532e-05 7.945102421e-06 2.316378887e-06 6.436306355e-07 1.519697213e-05 1.878126162e-05 2.039812131e-05 1.492699903e-06 1.193017757e-06 1.936332569e-06 9.155042078e-07 4.448386639e-07 2.14305686e-06 6.41817414e-06 2.209341466e-05 9.391144713e-05 3.525297198e-07 3.261602061e-07 2.002013714e-09 1.180172224e-06 0.0001835865642 3.38790616e-05 2.918910745e-05 2.168654468e-06 1.021576126e-06 1.292037102e-06 7.158528909e-08 7.652897945e-08 1.217318775e-07 5.590488011e-08 2.550280879e-06 7.599628356e-06 4.51604438e-05 4.927690638e-05 5.298206072e-06 1.06393792e-06 8.865762245e-07 1.044031882e-07 6.068210845e-08 3.029424411e-05 3.729945067e-05 4.188704963e-05 3.979836268e-05 1.544193763e-05 1.379852123e-05 1.995561655e-06 1.614916874e-06 1.598632766e-06 3.320625989e-06 6.712907439e-06 5.736353369e-06 1.165819302e-05 1.775932019e-05 1.539091508e-05 2.437278179e-05 3.095626263e-05 2.84323632e-05 3.706887901e-05 4.207519319e-05 4.592833624e-05 4.971493722e-05 5.412632035e-05 2.471091116e-05 2.250615057e-05 1.676271868e-05 1.634634216e-05 1.23506129e-05 2.271943358e-05 3.317460717e-05 2.933671712e-05 5.335725713e-05 5.732069723e-05 5.852170834e-05 6.125269722e-05 6.503288931e-05 6.480052842e-05 6.617049951e-05 6.856667805e-05 1.39266677e-05 1.707677645e-05 2.38011009e-05 2.234366175e-05 7.258849336e-05 7.833324481e-05 7.546104278e-05 8.567795708e-05 2.972852581e-05 2.574936572e-05 2.101225113e-05 2.363999459e-05 2.210453032e-05 1.627797859e-05 0.0001059977606 0.0001150199943 0.0001017910363 0.0001239243225 0.0001325672443 5.070650846e-05 4.430273197e-05 3.980783584e-05 0.0001627126367 0.000163711974 6.876158896e-05 6.607993309e-05 6.166775031e-05 0.0001705359277 0.0001611317669 7.14918228e-05 7.127180335e-05 5.634899962e-05 6.323843386e-05 0.0001661398851 0.0001521153639 0.000157412908 0.0001390139096 6.337185601e-05 6.571622931e-05 7.168358907e-05 0.0001199012284 0.0001089032127 0.0001194656175 4.61254216e-05 5.255090507e-05 8.107719524e-05 2.824864985e-05 3.101195576e-05 3.878913297e-05 5.893053849e-05 6.014757827e-05 6.875582854e-05 1.505920523e-05 1.764603052e-05 1.797196668e-05 2.394517243e-05 3.906945975e-05 4.478175357e-05 5.262430409e-05 4.469461337e-05 5.859004846e-06 1.006948662e-05 2.95768709e-05 7.66706777e-06 3.643499775e-06 3.539252264e-06 1.40380196e-05 1.333592358e-05 3.234322754e-05 1.932482964e-05 6.625693782e-06 2.898760597e-06 3.02750182e-06 6.900034105e-06 4.916208101e-05 3.417190082e-05 3.383349077e-05 6.159638312e-07 5.860697946e-07 1.236786015e-06 5.540171454e-05 3.991992685e-05 3.700217322e-05 2.207769491e-07 2.144942344e-07 3.267923373e-07 5.298958909e-05 4.222193167e-05 4.206377205e-05 5.453591038e-06 7.511698827e-06 9.130381783e-07 4.052096647e-05 4.286951193e-05 1.255926014e-05 2.214825656e-05 3.920866438e-05 3.770838257e-05 8.80522365e-06 4.849362347e-05 4.061691178e-05 3.631849839e-05 4.173317357e-05 6.962241454e-06 8.849479402e-06 7.980650667e-06 4.902416204e-05 5.228674834e-05 4.748808295e-05 7.524849602e-06 8.675709885e-06 1.071745342e-05 1.440519603e-05 2.409360286e-05 4.436421862e-07 9.119831583e-06 2.144582513e-05 1.917971925e-05 2.193911644e-07 1.717956525e-07 2.434507052e-07 3.03189088e-05 1.463223858e-06 7.862571788e-06 2.004827619e-05 2.410777157e-06 2.165837642e-06 1.98374993e-06 1.89066415e-05 1.026871569e-05 2.832939382e-06 2.381822701e-06 3.218654676e-05 1.873398329e-05 1.813079961e-06 2.473166528e-06 1.917868382e-06 3.602320948e-07 5.449759203e-07 0.0001686712324 9.192008125e-05 5.371464776e-05 2.285727829e-08 2.846487947e-08 4.545319248e-07 1.119103189e-06 0.0003002080227 1.774848493e-07 6.90957525e-08 6.392001978e-05 3.238211739e-07 5.897655394e-07 4.42407929e-05 7.177277761e-07 4.350301787e-07 2.314545138e-07 6.697487038e-08 3.210895403e-08 4.089586788e-07 4.660809496e-09 6.214741121e-08 7.182388409e-09 2.476607012e-09 9.416395753e-07 2.314726195e-07 7.380642756e-08 1.149072759e-07 9.424858575e-07 4.36824858e-06 2.428414294e-05 1.851245592e-05 4.971768863e-05 7.307966074e-05 6.271946973e-05 6.429542294e-05 3.201517908e-05 2.118212087e-05 9.284729857e-06 2.519995194e-06 1.568975171e-06 1.283041379e-06 1.046157885e-06 1.020900518e-06 8.915976742e-07 7.871119781e-07 4.65053395e-08 3.510925826e-05 3.749293724e-05 3.971467384e-05 3.444265284e-05 4.666664923e-06 5.65521149e-06 1.548672421e-06 1.863623167e-06 1.689432103e-06 4.709559695e-06 9.858954853e-06 8.194489189e-06 1.642212025e-05 2.354482704e-05 2.078655858e-05 3.02779606e-05 3.600934053e-05 3.37356069e-05 4.065271207e-05 4.447019989e-05 4.374522532e-05 4.773387434e-05 5.067504784e-05 5.204126063e-05 3.070370718e-05 3.347406017e-05 2.738970074e-05 3.319049706e-05 3.078326922e-05 2.288745849e-05 3.468509188e-05 3.582136716e-05 3.449953455e-05 3.261416863e-05 3.126787253e-05 3.466107939e-05 2.533950078e-05 3.738776361e-06 3.899570955e-06 1.618569224e-06 2.794944088e-06 2.201445751e-06 7.014759779e-06 1.308394017e-05 1.152097047e-05 1.977732394e-05 2.615819731e-05 2.544717336e-05 3.14209064e-05 3.513609112e-05 3.662934833e-05 3.737897118e-05 3.8556185e-05 4.275322067e-05 3.914995238e-05 3.971443821e-05 4.618788282e-05 3.934858107e-05 5.236043914e-05 5.376407286e-05 6.569756099e-05 7.136172204e-05 6.330313722e-05 7.089597688e-05 7.00963499e-05 6.787925022e-05 2.294228918e-05 2.765023262e-05 2.547053586e-05 3.58805816e-05 4.223977267e-05 3.864051736e-05 4.510917062e-05 4.198382267e-05 3.776102138e-05 4.290466141e-05 3.714557653e-05 3.689475372e-05 2.971844319e-05 2.257642006e-05 2.723454778e-05 1.745700598e-05 4.295768893e-06 3.928850287e-06 2.638321185e-06 5.2165876e-06 3.738124306e-06 1.030239353e-05 1.578735571e-05 1.451291952e-05 2.052789936e-05 2.414815972e-05 2.564214911e-05 2.653177387e-05 2.768551092e-05 3.185452442e-05 2.793430207e-05 2.791299419e-05 3.30400515e-05 2.824897998e-05 3.038312093e-05 3.363277958e-05 3.039673084e-05 4.995173578e-05 5.242538944e-05 7.504251401e-05 9.666783917e-05 8.724861548e-05 0.0001065518142 0.0001048157068 8.422315436e-05 0.000100428054 0.0001005336118 8.606643068e-05 3.613095643e-05 2.937636315e-05 3.024608505e-05 2.575003244e-05 2.460081477e-05 2.509494431e-05 2.573335899e-05 2.988340582e-05 2.962212087e-05 3.708226963e-05 4.352279708e-05 4.386627046e-05 4.425810154e-05 4.038912656e-05 4.276785797e-05 3.983250923e-05 3.256583428e-05 3.589672985e-05 2.381103893e-05 1.283313429e-05 1.754502201e-05 1.357970045e-05 6.332242159e-06 4.991176849e-06 6.320786465e-06 1.051947363e-05 7.451859114e-06 1.480157886e-05 1.788661627e-05 1.690237544e-05 1.950133919e-05 2.014598715e-05 2.213329552e-05 2.047964827e-05 2.093675594e-05 2.372463344e-05 2.201598889e-05 2.428034248e-05 2.470648443e-05 2.792767486e-05 3.761828668e-05 3.170648845e-05 4.372409756e-05 4.341233776e-05 4.5827775e-05 5.467090789e-05 7.646926511e-05 9.084398116e-05 0.0001018973213 0.0001200455901 0.0001192974391 0.0001272849648 0.0001300945604 0.0001175699793 0.0001349681784 0.0001430217556 0.0001296786884 0.0001521483306 0.00015976454 0.0001454918029 5.188592201e-05 3.598956059e-05 4.287171243e-05 2.464856181e-05 1.826702678e-05 2.471378685e-05 1.549960534e-05 1.52564961e-05 2.076751138e-05 1.748380165e-05 2.357389169e-05 2.767535712e-05 3.626367635e-05 3.917034493e-05 4.166415874e-05 3.309192363e-05 2.954933829e-05 3.564048937e-05 2.879039885e-05 2.041872006e-05 2.718153823e-05 1.452202679e-05 7.164235431e-06 9.28357963e-06 1.038179139e-05 1.077547187e-05 8.598788887e-06 1.40338717e-05 1.745787878e-05 1.411745563e-05 1.929260556e-05 1.952493664e-05 1.877454336e-05 1.880121012e-05 1.815436523e-05 1.87057062e-05 1.859739924e-05 2.063792686e-05 1.991850539e-05 2.440202247e-05 2.975309475e-05 2.640670998e-05 3.633949163e-05 4.995166232e-05 4.525417374e-05 5.627711718e-05 4.700723226e-05 4.370377116e-05 4.827793142e-05 6.046992484e-05 6.414721167e-05 8.025017656e-05 0.0001013514641 0.0001110398603 0.0001182987603 0.0001311951414 0.0001341061912 0.000143056828 0.0001553069005 0.0001519271377 0.0001669507338 0.0001758001242 0.0001699645404 0.0001798322499 0.0001782314066 0.0001718058544 3.623002825e-05 2.102416348e-05 2.801151462e-05 1.221312416e-05 7.899159332e-06 1.228860796e-05 6.132442612e-06 5.939935174e-06 9.976233672e-06 7.445782007e-06 1.269303767e-05 1.841461718e-05 3.03249786e-05 3.495330228e-05 3.692876007e-05 1.991988993e-05 1.743711417e-05 2.318824145e-05 1.585512279e-05 1.239978436e-05 1.364380541e-05 9.460110305e-05 5.614692118e-06 5.893297858e-06 7.8460281e-06 1.154388259e-05 1.181707779e-05 1.654280991e-05 1.950992698e-05 1.944901733e-05 2.021568445e-05 1.967662778e-05 1.993152395e-05 1.894997356e-05 1.900919598e-05 1.843520982e-05 2.066379409e-05 2.410600498e-05 2.234150599e-05 2.900277399e-05 3.486536517e-05 3.277972999e-05 4.12876011e-05 4.813329085e-05 4.971343511e-05 5.412224178e-05 6.175557559e-05 5.392880979e-05 6.996405044e-05 7.800661029e-05 6.724281237e-05 8.676957075e-05 9.691103547e-05 9.696562722e-05 0.0001084407274 0.0001213310281 0.0001259248103 0.0001355317033 0.0001503924865 0.0001542005672 0.0001642083861 0.0001744198082 0.0001770462855 0.0001785646838 0.0001755158948 0.0001788817233 5.483654443e-05 3.798174214e-05 4.715644285e-05 2.24266242e-05 1.198717942e-05 1.571795597e-05 6.261444657e-06 3.433313397e-06 5.100267046e-06 2.128101663e-06 1.647474908e-06 3.25025565e-06 1.787467311e-06 3.141134744e-06 7.200941619e-06 1.315486858e-05 2.638944911e-05 3.193102869e-05 1.038758078e-05 9.518252675e-06 1.275001164e-05 1.926333792e-05 0.0001031331149 4.209553434e-05 0.0002181127204 6.410518369e-05 1.611207629e-05 1.10816263e-05 9.325164606e-06 1.04597226e-05 1.303623892e-05 1.536380806e-05 1.787726941e-05 1.633026132e-05 1.682782516e-05 1.857681909e-05 1.755853257e-05 1.934711337e-05 1.93039416e-05 2.278029278e-05 2.774238475e-05 2.568309713e-05 3.36615721e-05 3.990816934e-05 3.672026335e-05 4.605415946e-05 5.196917907e-05 4.906938981e-05 5.777655621e-05 6.374532325e-05 6.364087488e-05 7.009713929e-05 7.69153949e-05 7.957279833e-05 8.426413373e-05 9.23298924e-05 9.564835495e-05 0.0001015161879 0.0001123487377 0.0001170353712 0.0001250700884 0.0001390197881 0.0001450499832 0.0001522023865 0.0001615751855 0.0001689168541 0.0001642479509 0.0001590569145 0.0001686705872 0.0001474876687 0.0001331337755 0.0001448029344 4.909653433e-05 4.383431452e-05 5.557094506e-05 3.356140446e-05 2.231851418e-05 2.969805134e-05 1.325381362e-05 7.312687051e-06 9.343995206e-06 3.857488235e-06 1.971979603e-06 2.475046685e-06 1.045287693e-06 6.871339756e-07 8.525055229e-07 5.858763029e-07 4.868047712e-07 1.05667559e-06 1.20701687e-06 1.019498113e-05 1.850903442e-05 4.669912181e-06 4.317810074e-06 6.215817983e-06 3.106769231e-06 2.331289414e-06 2.459583863e-06 2.205697914e-06 3.812259161e-06 3.027801436e-06 5.668186698e-06 7.859706804e-06 8.249476777e-06 9.682931502e-06 1.101316351e-05 1.290630472e-05 1.215934012e-05 1.364553773e-05 1.497828152e-05 1.655545673e-05 2.136967474e-05 1.977849902e-05 2.814731249e-05 3.634472743e-05 3.123544151e-05 4.51554674e-05 5.378276323e-05 4.570039661e-05 6.160105952e-05 6.826876763e-05 5.845408134e-05 7.37810019e-05 7.841046097e-05 6.909283076e-05 8.255354182e-05 8.656811004e-05 7.985311332e-05 9.074607499e-05 9.543971876e-05 9.237005247e-05 0.0001011971483 0.0001086761445 0.0001094498509 0.0001181914589 0.0001290247705 0.0001335112837 0.0001389850661 0.0001448332353 0.0001533483808 0.0001437195969 0.0001349017504 0.0001475446576 0.0001205380336 0.0001048493511 0.0001195102917 9.206989723e-05 8.461437299e-05 9.799123139e-05 2.873949283e-05 2.322070726e-05 3.257936406e-05 1.675206841e-05 1.10488877e-05 1.599269072e-05 6.8750816e-06 4.220289611e-06 5.614233241e-06 2.798396705e-06 2.446182867e-06 1.860957056e-06 3.228534419e-06 5.072173339e-06 1.393400682e-06 6.015575852e-06 2.990640903e-06 8.988326014e-07 1.598602131e-07 1.015187947e-06 3.768595802e-06 1.536843041e-06 2.544665765e-06 3.213985703e-06 2.799065903e-06 2.446252914e-06 2.48199224e-06 3.222259632e-06 4.790267359e-06 4.597748423e-06 5.960707875e-06 6.786316315e-06 7.566251071e-06 7.64885342e-06 9.000004359e-06 9.690469226e-06 1.139001724e-05 1.473430087e-05 1.336934106e-05 2.736173136e-05 3.427169841e-05 2.511689507e-05 4.043195867e-05 4.840132693e-05 4.221376689e-05 5.79615357e-05 6.830260575e-05 6.206538595e-05 7.856038913e-05 8.787153638e-05 7.909251941e-05 9.551345762e-05 0.0001011069073 9.003375557e-05 0.0001047029841 0.0001066934202 9.617514644e-05 0.0001076673145 0.0001083609534 0.0001011510958 0.000109661449 0.0001124478265 0.0001098899356 0.0001171021054 0.0001228375889 0.0001255847874 0.0001273873025 0.0001276544965 0.0001362776789 0.0001213167967 0.0001084315701 0.0001217219952 9.181974002e-05 7.582427012e-05 9.003998382e-05 6.424242345e-05 5.878181396e-05 7.129988859e-05 1.55997928e-05 1.229956839e-05 1.654006741e-05 8.95516876e-06 6.150908585e-06 7.775524168e-06 4.202044843e-06 3.382610717e-06 3.376653921e-06 4.264724089e-06 8.07429402e-06 4.603694892e-06 1.653837971e-05 2.843296498e-05 1.605019395e-05 3.228135523e-05 1.75461529e-05 9.938306676e-06 8.872218889e-08 9.014989773e-08 2.334387244e-07 2.272334426e-07 1.022957509e-06 1.843492689e-06 1.454260696e-06 1.774689492e-06 2.182793994e-06 2.493404154e-06 3.310322489e-06 4.107601122e-06 4.203738478e-06 5.593749621e-06 5.822581075e-06 8.281919384e-06 1.268823768e-05 9.588689405e-06 1.940150255e-05 2.677781181e-05 1.86376028e-05 7.284187792e-05 8.6311391e-05 5.533841379e-05 7.984116484e-05 7.182330956e-05 5.693987789e-05 7.056340865e-05 7.566297046e-05 7.215490343e-05 8.455756737e-05 9.500887129e-05 9.293519937e-05 0.0001052172122 0.0001137552896 0.0001092344719 0.0001196952384 0.0001227238769 0.0001159928768 0.0001231298689 0.0001217053841 0.0001156301062 0.0001195844923 0.000117913713 0.0001154387204 0.0001172691373 0.0001170224976 0.0001202043895 0.0001152069129 0.0001093711383 0.0001187711692 9.816706493e-05 8.256428937e-05 9.531330025e-05 6.566713047e-05 5.11949231e-05 6.276140633e-05 4.171528232e-05 3.791064762e-05 4.757915945e-05 7.621136472e-06 8.307505718e-06 1.260711685e-05 8.158455113e-06 7.543485003e-06 9.634777673e-06 6.688950516e-06 5.773837059e-06 5.719611521e-06 5.057581243e-06 5.068444764e-06 4.090853788e-06 7.034140589e-06 1.357291146e-05 1.097430355e-05 2.857754184e-05 4.578287491e-05 3.726100191e-05 4.116438573e-05 1.824774777e-05 1.887575578e-05 3.227140618e-08 5.97151015e-09 2.484064439e-08 1.333020098e-08 7.583149162e-08 3.721913829e-07 6.294154047e-07 1.295838056e-06 1.429743026e-06 2.028168701e-06 3.098208536e-06 2.953141066e-06 5.553352519e-06 1.079614583e-05 7.053630335e-06 1.847103954e-05 2.755461693e-05 1.91598595e-05 4.345828778e-05 6.04127583e-05 4.117395334e-05 8.176213252e-05 0.0001050058199 0.00010738882 0.000117326824 0.0001111904473 9.30118471e-05 9.782832624e-05 9.087747457e-05 8.16384535e-05 9.245534259e-05 9.925671613e-05 9.640026312e-05 0.0001082112202 0.0001171568712 0.0001157816114 0.00012445542 0.0001289332191 0.0001267686504 0.0001300481368 0.0001280190066 0.0001258798192 0.0001237389568 0.00011838154 0.0001190785396 0.0001127466654 0.000106654172 0.0001126690269 9.891704695e-05 8.819887483e-05 9.922535011e-05 7.42809117e-05 5.869108935e-05 7.032193697e-05 4.40885041e-05 3.28664737e-05 4.125419916e-05 2.600258536e-05 2.311209432e-05 2.979516923e-05 2.332171914e-05 2.598219811e-05 3.417071809e-05 2.254206016e-06 2.585428553e-06 4.942799044e-06 2.697663664e-06 2.738679802e-06 5.289651257e-06 3.395968036e-06 5.117989088e-06 5.737807893e-06 7.514898856e-06 9.353620784e-06 6.450768576e-06 1.234276785e-05 2.317733323e-05 1.700029266e-05 4.348333368e-05 4.93249545e-05 5.063886788e-05 3.038621182e-05 1.225616616e-05 1.555503149e-05 9.52779915e-08 6.868494658e-09 3.773588421e-09 2.735280445e-09 7.623783057e-09 5.409538932e-09 5.89025952e-07 1.457872172e-06 1.320024252e-06 2.39097931e-06 5.259797855e-06 3.801416822e-06 1.107529076e-05 1.853032845e-05 1.543639197e-05 2.718611614e-05 3.682737141e-05 3.426088487e-05 5.545844354e-05 7.047711593e-05 7.459526267e-05 6.078268909e-05 7.494026705e-05 8.784525764e-05 9.46775497e-05 0.0001063983116 0.0001156609953 0.0001072917448 0.0001053961928 0.0001002995824 0.000106260314 0.000110165055 0.0001041922929 0.0001159662247 0.0001224062222 0.0001192588302 0.0001280090069 0.0001312273665 0.0001302229125 0.0001309334926 0.0001268432142 0.0001282946117 0.000119563757 0.0001102137298 0.0001154896517 9.97978259e-05 8.870169021e-05 9.868371727e-05 7.672327783e-05 6.370852082e-05 7.630000369e-05 5.020967202e-05 3.752113526e-05 4.774379585e-05 2.709396153e-05 1.97818501e-05 2.581240674e-05 1.527506239e-05 1.277899285e-05 1.75525638e-05 1.16625468e-05 1.179783874e-05 1.853875375e-05 7.660412655e-06 4.29615647e-06 9.760357068e-07 5.140547051e-06 7.276060179e-06 2.109461732e-06 9.869943891e-06 1.213686559e-05 5.922457562e-06 1.333958993e-05 1.782093786e-05 1.518454722e-05 2.482635442e-05 3.600842286e-05 3.196079026e-05 4.263646045e-05 3.008116879e-05 4.15802239e-05 1.37586581e-05 7.828900998e-06 9.508376498e-06 2.714061121e-06 1.920599825e-07 2.118524234e-08 1.69902571e-07 1.880588722e-07 2.220884689e-08 9.066470754e-07 2.375859357e-06 1.759077826e-06 4.197879057e-06 8.533206721e-06 7.025671523e-06 1.38463796e-05 1.988058614e-05 1.955219078e-05 2.667408741e-05 3.445485419e-05 3.596306545e-05 4.346660745e-05 5.376981131e-05 5.455018914e-05 7.09559093e-05 8.299749409e-05 8.064759923e-05 9.138718253e-05 9.899610225e-05 9.504688998e-05 0.000105929077 0.000111605177 0.0001069889983 0.0001161557615 0.0001203846588 0.0001157809108 0.0001249076921 0.0001293241984 0.0001260386363 0.000132175178 0.0001317441568 0.0001319077659 0.0001270159204 0.000118110059 0.0001235611021 0.0001060672305 9.228470738e-05 0.0001024647385 7.796094956e-05 6.384316491e-05 7.692065056e-05 5.038550028e-05 3.812546674e-05 5.079553164e-05 2.770239233e-05 1.95156703e-05 2.806881786e-05 1.36271744e-05 9.786810704e-06 1.447875496e-05 6.900121672e-06 4.929405832e-06 8.567139402e-06 3.745767224e-06 3.125055319e-06 6.485462716e-06 1.711448463e-05 6.494941862e-06 1.296555729e-05 2.214422292e-06 6.566957797e-07 7.934528529e-06 2.088737634e-07 2.474227193e-07 3.344824948e-06 6.655403122e-07 2.070956319e-06 6.971905462e-06 7.442737781e-06 1.73314057e-05 3.00149374e-05 1.790449007e-05 9.458171156e-06 1.856452985e-05 4.125764875e-06 5.173882744e-06 7.003485271e-06 2.499695427e-05 1.464772057e-05 4.763997173e-06 5.898126002e-06 8.479622568e-06 1.12719792e-06 3.870793067e-06 5.629396172e-06 3.628712605e-06 9.45547996e-06 1.378405713e-05 1.059879117e-05 1.883769682e-05 2.450544354e-05 2.119831264e-05 3.086111827e-05 3.806809664e-05 3.473335382e-05 4.624702569e-05 5.541719091e-05 5.285229341e-05 6.550386173e-05 7.631064875e-05 7.512927375e-05 8.743990778e-05 9.81719822e-05 9.731068707e-05 0.0001074730921 0.000114598281 0.0001133374808 0.0001199459489 0.0001247698195 0.0001231340363 0.0001295499964 0.0001328747945 0.0001316584756 0.0001322518449 0.0001260293735 0.0001300186225 0.0001144488224 9.922150618e-05 0.000110082612 8.248387188e-05 6.596917335e-05 7.993276489e-05 5.066333686e-05 3.705052935e-05 5.023838083e-05 2.548208296e-05 1.649179194e-05 2.642768501e-05 1.033334415e-05 6.594116673e-06 1.218654667e-05 4.480732642e-06 3.205971818e-06 5.892908252e-06 1.5340796e-06 9.049727371e-07 2.2310096e-06 7.338051338e-07 6.56728763e-07 1.391414571e-06 2.103247531e-05 8.511486536e-06 7.100243275e-06 2.963111744e-06 8.171096134e-07 5.253127256e-07 1.391326216e-07 1.729406211e-08 5.607797834e-08 7.103984036e-09 8.791378943e-09 4.579908665e-07 1.612745802e-08 4.007385741e-08 4.097697215e-06 7.994576056e-07 8.083511993e-07 3.565393882e-06 3.70214341e-07 7.349959693e-07 2.363569711e-06 1.07400528e-06 5.564870488e-06 3.849134969e-05 7.885053593e-06 5.093085775e-06 5.394951848e-06 6.155540092e-06 9.922027974e-06 7.689869281e-06 1.5510964e-05 2.19945141e-05 1.768905447e-05 2.90822061e-05 3.667100368e-05 2.9867631e-05 4.465596263e-05 5.287406927e-05 4.445690797e-05 6.109912494e-05 6.924369593e-05 6.131630069e-05 7.759806222e-05 8.661761683e-05 8.044126394e-05 9.640335297e-05 0.0001061805819 0.0001011373721 0.0001142226473 0.0001194127396 0.0001165383759 0.0001230276265 0.000127221913 0.0001260660394 0.0001313265125 0.0001314046919 0.0001329008602 0.0001239104937 0.000108951373 0.0001191674868 8.968678676e-05 6.979200222e-05 8.561039018e-05 5.185585422e-05 3.700417204e-05 5.128035649e-05 2.502214317e-05 1.553477516e-05 2.522962998e-05 8.383550664e-06 4.164681372e-06 8.965856546e-06 2.384602209e-06 1.737167241e-06 3.153059697e-06 1.50779172e-06 1.371186488e-06 1.90909483e-06 5.545537882e-07 2.85260803e-07 4.581843965e-07 2.379058051e-07 2.228577075e-07 3.520832496e-07 2.464962357e-05 1.130375001e-05 1.003783966e-05 4.20847041e-06 1.296243079e-06 1.130541663e-06 3.30751616e-07 6.578373701e-08 3.253620223e-08 1.585740796e-08 9.675744181e-09 4.835254867e-09 9.420261879e-09 1.294640829e-08 4.909454489e-09 2.222441246e-08 2.644007781e-08 1.021801888e-08 4.423649074e-08 1.027964103e-07 6.483594033e-07 1.12959758e-07 5.515654015e-07 3.30406451e-07 2.451316434e-06 5.595837116e-06 4.084249348e-06 1.008361048e-05 1.607525828e-05 1.26078461e-05 2.358138971e-05 3.232044924e-05 2.682212473e-05 4.184327933e-05 5.163568047e-05 4.412432431e-05 6.116430091e-05 6.990657525e-05 6.17948349e-05 7.741647814e-05 8.397413854e-05 7.732460403e-05 9.094480092e-05 9.958166292e-05 9.339031964e-05 0.0001096042283 0.0001188796217 0.000112463413 0.0001240649927 0.0001243700198 0.0001224660367 0.0001242029321 0.0001270962386 0.0001278006412 0.0001286007946 0.0001210374846 0.0001277163882 0.0001023565891 7.794621571e-05 9.513783092e-05 5.468875049e-05 3.612130095e-05 5.28032452e-05 2.295950373e-05 1.436867824e-05 2.43549697e-05 8.250384165e-06 4.275723156e-06 8.438884791e-06 2.409612429e-06 1.653197396e-06 1.860211482e-06 1.365519408e-06 1.363474805e-06 1.040584778e-06 1.857795408e-06 3.290435036e-06 1.287177857e-06 3.124100681e-06 2.717634654e-06 6.057892262e-07 2.865777618e-06 3.659084876e-06 5.067581036e-07 2.801964012e-05 1.740263761e-05 1.352044964e-05 9.421270229e-06 4.01736581e-06 2.04720448e-06 1.074908631e-06 3.040775824e-07 1.782667033e-07 1.587200117e-07 1.223059915e-07 3.166703042e-08 9.707226756e-08 8.015189942e-08 3.243787903e-08 7.389031543e-08 7.359326236e-08 3.817702515e-08 7.561844915e-08 8.661340466e-08 4.404161994e-08 1.579217649e-07 1.650018614e-06 9.777255153e-07 5.429438711e-06 1.047262367e-05 7.728666949e-06 1.705199239e-05 2.521721496e-05 2.027355808e-05 3.473470628e-05 4.511453699e-05 3.845836571e-05 5.569169103e-05 6.5734695e-05 5.889052441e-05 7.454526347e-05 8.153907759e-05 7.653515942e-05 8.641775596e-05 9.077754414e-05 8.844835635e-05 9.799300857e-05 0.0001090795384 0.000104747815 0.0001204360615 0.0001272845919 0.0001242759399 0.0001261390596 0.0001190858208 0.0001236481764 0.000116188464 0.0001195098581 0.0001244820868 0.0001161479693 9.685179012e-05 0.0001107651415 6.640368778e-05 3.813081625e-05 5.832362605e-05 2.034788494e-05 1.055060032e-05 2.148667549e-05 5.872202913e-06 4.003404285e-06 7.616331146e-06 2.941433122e-06 3.592767473e-06 2.940909559e-06 6.376508634e-06 1.019375141e-05 3.098259816e-06 1.569138239e-05 2.311009956e-05 4.754357659e-06 3.22663688e-05 4.114336371e-05 1.229872746e-05 4.403964358e-05 3.731642479e-05 2.116902633e-05 2.603114622e-05 1.769839874e-05 2.527916251e-05 3.306748545e-05 2.640315191e-05 2.107982681e-05 2.051883978e-05 1.528577853e-05 8.754914733e-06 1.061868751e-05 6.606305437e-06 1.27461071e-06 2.854602508e-06 3.703209518e-07 1.398817873e-07 1.500445965e-07 9.871352221e-08 7.856867272e-08 8.532247339e-08 8.09553467e-08 7.136553611e-08 7.289907238e-08 7.389833725e-08 5.93593271e-08 1.069210916e-07 5.571861243e-06 3.342665493e-06 1.115128075e-05 1.822481133e-05 1.397364315e-05 2.705863209e-05 3.732127576e-05 3.091692493e-05 4.833811874e-05 5.92588894e-05 5.212429519e-05 6.921055806e-05 7.743052947e-05 7.200452356e-05 8.335390181e-05 8.666113041e-05 8.493837461e-05 8.756940337e-05 9.03415754e-05 9.131083614e-05 0.0001011179573 0.0001161456803 0.0001129008824 0.0001227175842 0.0001181075103 0.0001260189379 0.0001091832122 9.823213281e-05 0.000110282545 9.699830895e-05 0.0001002742027 0.0001117276393 9.064619052e-05 6.363216772e-05 8.02848643e-05 3.152997655e-05 8.953691752e-06 2.022591572e-05 4.444561398e-06 2.856108587e-06 4.364681324e-06 2.151608493e-06 2.120006315e-06 2.645294722e-06 2.058169392e-06 2.026852217e-06 3.439524611e-06 2.055337845e-06 2.190132241e-06 6.865236363e-06 2.467374351e-06 2.932110845e-06 1.017677985e-05 3.52026206e-06 4.195883607e-06 1.046289669e-05 4.997071954e-06 5.959557928e-06 8.39885553e-06 7.091252513e-06 8.1256265e-06 8.592414185e-06 3.29158551e-05 2.932616709e-05 2.81448225e-05 2.441737636e-05 1.911534443e-05 1.7097425e-05 1.585447926e-05 1.37062074e-05 9.268762064e-06 1.125178281e-05 8.173224134e-06 2.707928952e-07 3.805465968e-07 1.307079568e-07 1.007736601e-07 1.113692028e-07 4.087174535e-06 1.026140634e-07 6.444032901e-06 1.157629278e-05 9.552684712e-06 1.914247086e-05 2.885607285e-05 2.321666901e-05 4.006615229e-05 5.180915168e-05 4.433333087e-05 6.299344725e-05 7.260163874e-05 6.621258515e-05 7.984969364e-05 8.427612598e-05 8.165154503e-05 8.574492312e-05 8.44050936e-05 8.653628909e-05 8.116556769e-05 8.442924673e-05 8.802044569e-05 0.0001041060127 0.0001168453376 0.000118023138 0.0001001639699 7.64227467e-05 0.0001015310194 8.0256435e-05 7.400004167e-05 8.532341241e-05 6.654501362e-05 6.078296124e-05 8.365560847e-05 5.605061097e-05 5.303060051e-05 5.011609226e-05 5.442713511e-05 1.758217135e-05 1.083911507e-05 6.438688861e-06 3.242712243e-06 3.084634609e-06 1.316278406e-06 1.144335066e-06 1.622251599e-06 9.064682745e-07 7.209682128e-07 1.343477139e-06 6.070156366e-07 5.828536633e-07 1.316910508e-06 6.453479339e-07 8.352776233e-07 1.793034945e-06 1.233567251e-06 1.952659769e-06 3.018017792e-06 3.130332552e-06 4.792742357e-06 5.051615599e-06 5.909236023e-05 6.616920102e-05 4.535906634e-05 6.978754115e-05 6.599241559e-05 3.176009521e-05 5.330955755e-05 4.268875515e-05 2.077069453e-05 2.966720027e-05 2.060645677e-05 1.35260086e-05 1.43367687e-05 6.673730647e-07 9.171063885e-08 2.126512164e-06 5.443786237e-06 3.92641446e-06 1.123567485e-05 1.980270839e-05 1.507552341e-05 3.079076903e-05 4.323605803e-05 3.55391475e-05 5.580351238e-05 6.711059487e-05 5.953315559e-05 7.601478342e-05 8.17927667e-05 7.796742914e-05 8.419141316e-05 8.337363687e-05 8.494256588e-05 7.979604157e-05 7.407215198e-05 8.021629295e-05 6.763141294e-05 7.365015905e-05 7.963228465e-05 0.0001118472082 9.388149585e-05 0.0001099715113 4.193366197e-05 2.205026048e-05 4.717264441e-05 7.173335505e-05 5.435175119e-05 6.458121184e-05 1.690550827e-05 2.487452312e-05 3.58569171e-05 5.048510279e-05 6.504365518e-05 5.896585557e-05 9.747147387e-05 3.73946261e-05 2.784075414e-05 1.273311408e-05 5.914887866e-06 3.926345921e-06 2.099087896e-06 5.52691756e-07 8.035191487e-07 1.602439855e-07 8.42261796e-08 2.405032845e-07 8.666652196e-08 9.957768175e-08 1.235308486e-07 1.37609226e-07 2.693851952e-07 2.235741715e-07 8.160921729e-07 2.309332623e-06 1.401829612e-06 4.370771649e-06 5.549130039e-06 5.662736962e-06 1.141481749e-05 2.066073732e-05 3.196608027e-05 2.980010959e-05 3.207155566e-05 4.509358174e-05 2.718684328e-05 1.911572667e-05 2.618961157e-05 1.130175588e-05 5.926681397e-06 1.212581987e-05 1.84782922e-06 1.840687762e-06 2.059049932e-06 4.747709713e-06 1.089960523e-05 7.772404065e-06 2.06035946e-05 3.321795782e-05 2.581144185e-05 4.721597495e-05 6.06747309e-05 5.173344234e-05 7.182972014e-05 7.946880701e-05 7.398100646e-05 8.30827156e-05 8.280377874e-05 8.355485435e-05 7.922258567e-05 7.317475502e-05 7.943260849e-05 6.55572042e-05 5.716941452e-05 6.624443571e-05 4.936275319e-05 5.757555836e-05 6.638559649e-05 0.0001460161971 8.237938129e-06 6.382005618e-05 5.742855381e-07 3.25782047e-06 7.15536609e-06 8.245975036e-05 1.388300506e-05 3.336122603e-05 1.000715031e-05 6.131307487e-05 3.308072219e-05 9.238242279e-05 7.444374432e-05 7.120327188e-05 8.297875385e-05 3.692573894e-05 4.067657046e-05 1.976438447e-05 1.258630888e-05 9.129347605e-06 7.219701739e-06 2.178342601e-06 5.457465049e-07 2.333803841e-07 8.012515968e-08 7.10391392e-08 9.656909835e-08 1.347414575e-07 1.063994553e-07 2.314542031e-07 5.542302802e-07 3.783029638e-07 1.48220789e-06 1.196299343e-06 2.8242699e-06 6.392028058e-07 4.397739879e-07 9.70369501e-07 2.452362916e-05 2.741665891e-05 3.02541741e-05 2.643761033e-05 2.342166282e-05 2.115178341e-05 1.868013087e-05 1.055844934e-05 6.680895866e-06 2.651107707e-06 3.870178287e-06 2.628271505e-06 1.004940691e-05 2.124219335e-05 1.525914325e-05 3.62244531e-05 5.239608773e-05 4.210826657e-05 6.685176602e-05 7.736150483e-05 6.949267349e-05 8.284079174e-05 8.331425079e-05 8.282514635e-05 7.958560845e-05 7.283776175e-05 7.924655181e-05 6.430347981e-05 5.506154773e-05 6.488071468e-05 4.596995322e-05 3.764223236e-05 4.741890039e-05 3.073739709e-05 3.39778561e-05 4.709239126e-05 0.0002219037864 6.161426363e-05 1.451683767e-05 9.183826292e-06 2.785832568e-05 5.168983518e-06 0.0001130226811 4.255259718e-05 2.082293461e-05 6.646514769e-05 0.0002338815745 0.0001131714743 0.0001266363328 5.087462278e-05 6.574587306e-05 3.873972455e-05 3.103780758e-05 3.169215506e-05 2.481136069e-05 1.776552119e-05 1.545279807e-05 1.105440556e-05 5.530658501e-06 6.404725403e-06 8.696959943e-07 1.722318261e-07 1.123362962e-07 1.77942611e-07 2.6114397e-07 1.848574698e-07 4.876878022e-07 1.083470607e-06 7.947647443e-07 1.959856074e-06 1.850836811e-06 1.490795098e-06 1.212358232e-05 1.714498565e-05 2.194835607e-05 2.037027606e-05 1.955697273e-05 1.608104933e-05 3.316903783e-06 7.939404571e-06 5.567886553e-06 2.11420443e-05 4.005144726e-05 2.932085655e-05 5.963509551e-05 7.517104762e-05 6.369535949e-05 8.400720603e-05 8.577726116e-05 8.320352132e-05 8.169676817e-05 7.366334077e-05 8.034863743e-05 6.357042263e-05 5.293937306e-05 6.385617486e-05 4.280756245e-05 3.378770179e-05 4.442360477e-05 2.624395848e-05 2.057085665e-05 2.851250548e-05 1.726374833e-05 1.568873463e-05 1.859184023e-05 1.497723925e-05 2.14705797e-05 4.594154366e-05 0.0001536157228 8.889109753e-05 7.444031459e-05 9.042096201e-05 0.0002100668066 0.0001029319482 0.0002168770477 9.44432439e-05 0.0001454766177 4.180058735e-05 3.738353456e-05 3.875926454e-05 3.807177907e-05 3.652996308e-05 3.415417505e-05 3.211919853e-05 2.526412617e-05 2.106419285e-05 1.699378752e-05 9.005254543e-06 7.001889784e-06 3.118362273e-06 1.332476562e-07 1.606958144e-07 2.805455911e-07 4.831048847e-07 3.623069412e-07 9.017415755e-07 1.677403047e-06 1.38844817e-06 1.113899222e-05 1.709091095e-05 1.639584559e-05 1.980180789e-05 1.88216969e-05 2.032185679e-05 2.830152038e-06 1.815027439e-05 1.16900185e-05 4.509164508e-05 7.102950033e-05 5.393282925e-05 8.742402137e-05 9.212228345e-05 8.536899452e-05 8.73052785e-05 7.668494927e-05 8.38791263e-05 6.368149923e-05 5.069098821e-05 6.349245876e-05 3.905901786e-05 2.933593025e-05 4.104772792e-05 2.158347504e-05 1.56400472e-05 2.396905582e-05 1.14721368e-05 1.027442373e-05 1.435999279e-05 1.95674998e-05 4.480581156e-05 1.926300676e-05 6.816448282e-05 0.0001148361098 5.768692825e-05 0.0001754364819 0.0001419687184 6.720826429e-05 6.35079851e-06 6.719955067e-06 5.084095381e-05 1.811442996e-05 5.396324993e-05 7.959054312e-05 4.400928296e-05 3.044674626e-05 3.46444806e-05 3.353025256e-05 3.646418735e-05 3.74897159e-05 3.70254753e-05 3.412975719e-05 2.983088866e-05 2.724092133e-05 1.715716975e-05 1.234242309e-05 6.722609512e-06 7.539630782e-08 1.027425546e-07 3.622766126e-07 7.561955982e-07 6.166530765e-07 1.395722485e-06 2.289825319e-06 1.961774023e-06 1.727558281e-05 1.004594153e-05 1.555116651e-05 1.427238291e-06 5.14467294e-05 2.983498657e-05 9.33662553e-05 0.0001081648343 9.024937045e-05 0.0001015869459 8.452845684e-05 9.271143387e-05 6.514603177e-05 4.773806667e-05 6.420857466e-05 3.38198177e-05 2.34140959e-05 3.672006582e-05 1.594654081e-05 1.072564284e-05 1.894065903e-05 7.139065644e-06 4.780478049e-06 9.211729242e-06 3.825331175e-06 7.951435113e-06 8.440388817e-06 1.666809048e-05 1.119636183e-05 5.186218803e-05 5.769532358e-06 3.83046392e-06 4.643495504e-05 6.270757329e-06 1.35960347e-05 5.454238581e-05 6.183987595e-06 1.886188821e-06 2.08059229e-06 3.966748806e-06 7.163554582e-06 2.081224704e-05 1.15487246e-05 1.594024582e-05 2.451964677e-05 2.112979846e-05 2.702378257e-05 3.301405095e-05 3.299839624e-05 3.764317988e-05 3.719206483e-05 3.850851943e-05 3.242158996e-05 2.379276141e-05 1.768546858e-05 3.786625486e-08 5.36451679e-08 4.315376715e-07 1.05543777e-06 8.988330305e-07 0.0001527573952 0.0001066284151 0.0001175231155 6.758474633e-05 4.095982841e-05 6.647152894e-05 2.43801808e-05 1.445943261e-05 2.996682115e-05 8.605450631e-06 5.124486175e-06 1.252097824e-05 3.039794974e-06 1.810368115e-06 5.070065484e-06 1.196243683e-06 1.301028642e-06 2.191507438e-06 2.499554352e-06 3.598682488e-05 1.463630315e-05 1.699141037e-05 6.398342639e-06 8.162713146e-06 1.472216492e-06 6.945635558e-07 5.274789138e-07 1.107969675e-06 2.073747717e-06 4.019640187e-06 2.938292603e-06 4.04379925e-07 7.258952795e-07 1.828184962e-06 1.577421499e-06 4.140557394e-06 2.542212922e-06 4.310183809e-06 9.429558465e-06 6.81192919e-06 1.057040537e-05 1.905354939e-05 1.62914223e-05 2.481931819e-05 3.387637895e-05 3.661174399e-05 4.995946589e-05 4.232261371e-05 1.878387519e-08 8.6765949e-12 1.538296907e-05 1.96208815e-12 3.764482142e-13 4.25172009e-06 5.893784269e-14 9.287496738e-15 1.221878393e-06 1.825114664e-07 5.45680612e-05 5.347072634e-07 0.0004632143859 0.0001140923695 6.094566103e-06 2.761932574e-05 3.691111616e-05 3.246153066e-05 2.408176235e-05 8.124489425e-06 6.896906448e-06 1.707520612e-06 8.880729556e-07 8.457378466e-07 1.13307552e-06 1.446007382e-06 1.690812255e-06 1.533458527e-06 1.066453672e-06 5.537880457e-07 1.235841758e-07 5.91939713e-08 3.197902091e-07 1.218499183e-07 4.101141561e-11 1.3337604e-06 1.233637735e-11 7.28807317e-13 3.670265439e-06 3.275496976e-08 2.182149106e-07 1.168265797e-05 2.122438853e-06 4.186667553e-06 4.728465407e-06 9.480985904e-06 1.838523325e-05 1.642762943e-05 3.94565415e-05 5.141779555e-05 4.313599339e-05 3.690609159e-05 1.397887754e-05 1.022472531e-05 3.135614089e-06 1.093880658e-06 9.24784078e-07 9.770763371e-07 1.090339774e-06 1.230976353e-06 1.116807381e-06 1.207314356e-06 1.435759084e-06 8.204375156e-08 4.357349779e-08 3.877855003e-08 ) ; boundaryField { dominio_ascii { type zeroGradient; } wallFilmFaces_top { type zeroGradient; } region0_to_wallFilmRegion_wallFilmFaces { type zeroGradient; } } // ************************************************************************* //
04e3ae9cd6028cc4232dcfcd2baba16ef7cfeb26
fc9ec32670150cce44432b6b43dca6ae7e9a56bc
/codeforces/364/3-3.cc
a339ba95738e469000ca871769b988285067e937
[]
no_license
ArthurEmidio/programming-problems
e3efc16ad826a6f4b43277b72ef90189aec868c7
16a8c3883649efaf1ab0475036f017638bfe343f
refs/heads/master
2020-12-04T12:37:06.643514
2017-06-27T07:49:10
2017-06-27T07:49:10
65,958,563
2
0
null
null
null
null
UTF-8
C++
false
false
1,308
cc
3-3.cc
#include <iostream> #include <limits> #include <cmath> #include <vector> #include <set> #include <map> using namespace std; #define ll long long int main() { int n; cin >> n; vector<char> seq; set<char> pokemons; for (int i = 0; i < n; i++) { char c; cin >> c; seq.push_back(c); pokemons.insert(c); } int lp = 0; int rp = 1; int dist = (pokemons.size() == 1) ? 1 : numeric_limits<int>::max(); map<char, int> seen; seen[seq[lp]] = 1; while (rp < n) { while (lp < rp - 1 && seen[seq[lp]] > 1) { seen[seq[lp]]--; lp++; } if (seq[lp] != seq[rp]) { char lc = seq[lp]; char rc = seq[rp]; if (seen.count(rc) == 0) seen[rc] = 0; seen[rc]++; if (seen.size() == pokemons.size()) { dist = min(rp - lp + 1, dist); if (seen[lc] == 1) { seen.erase(lc); } else { seen[lc]--; } lp++; } } else { lp++; } rp++; } cout << dist << endl; return 0; }
9a5f5c149ba5d3165a72cb446ae33f5de6459a4d
c7c70c3177c7724be8775da5e85c5cb62f02e262
/src/DgLocList.cpp
3e53853304b686a98b8a6d89c1837c0862b5ca7c
[ "LGPL-2.0-or-later", "MIT", "LicenseRef-scancode-public-domain", "AGPL-3.0-only" ]
permissive
pieterprovoost/dggridR
190c658ac2284169d4006b82aceb70fc53a2d738
c99eb5f97f90b919984a61815823266528372e19
refs/heads/master
2022-05-02T04:40:18.765693
2022-03-18T04:56:41
2022-03-18T04:56:41
239,110,945
0
0
MIT
2020-02-08T10:38:56
2020-02-08T10:38:56
null
UTF-8
C++
false
false
6,789
cpp
DgLocList.cpp
#ifndef DGGRIDR #define DGGRIDR #endif /******************************************************************************* Copyright (C) 2021 Kevin Sahr This file is part of DGGRID. DGGRID is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. DGGRID 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. *******************************************************************************/ //////////////////////////////////////////////////////////////////////////////// // // DgLocList.cpp: DgLocList class implementation // //////////////////////////////////////////////////////////////////////////////// #include <algorithm> #include "DgLocation.h" #include "DgLocList.h" #include "DgRFBase.h" //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// DgLocList::~DgLocList (void) { if (isOwner()) destroy(); clear(); } // DgLocList::~DgLocList //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// void DgLocList::destroy (void) { if (isOwner()) { list<DgLocBase*>::iterator it; for (it = begin(); it != end(); it++) { (*it)->clearAddress(); delete (*it); } } clear(); } // DgLocList::destroy //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// void DgLocList::clearAddress (void) { list<DgLocBase*>::iterator it; for (it = begin(); it != end(); it++) { (*it)->clearAddress(); } clear(); } // DgLocList::clearAddress /* //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// bool DgLocList::thin (float dMin, bool clear) // // Apply the appropriate line reduction algorithms to all the drawables. // Returns true if some portion of this object still remains after the thinning // and false if the entire object has been thinned away. // //////////////////////////////////////////////////////////////////////////////// { list<DgLocBase*>::iterator it; for (it = begin(); it != end(); it++) { (*it)->thin(dMin, clear); } return true; } // bool DgLocList::thin */ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// int DgLocList::cardinality (void) const // // Return the total number of elements in this tree. // //////////////////////////////////////////////////////////////////////////////// { int card = 0; list<DgLocBase*>::const_iterator it; for (it = begin(); it != end(); it++) card += (*it)->cardinality(); return card; } // int DgLocList::cardinality //////////////////////////////////////////////////////////////////////////////// DgLocList& DgLocList::operator= (const DgLocList& list) { if (&list != this) { clearAddress(); rf_ = &list.rf(); copy(list.begin(), list.end(), this->begin()); } return *this; } // DgLocList& DgLocList::operator= //////////////////////////////////////////////////////////////////////////////// /* bool DgLocList::operator== (const DgLocList& list) const { if (this == &list) return true; } // DgLocList::operator== */ //////////////////////////////////////////////////////////////////////////////// string DgLocList::asString (void) const { string str; str = "[[\n"; list<DgLocBase*>::const_iterator it; for (it = begin(); it != end(); it++) str += (*it)->asString(); str += "]]\n"; return str; } // DgLocList::asString //////////////////////////////////////////////////////////////////////////////// string DgLocList::asString (char delimiter) const { string str; list<DgLocBase*>::const_iterator it; for (it = begin(); it != end(); it++) str += (*it)->asString(delimiter); return str; } // DgLocList::asString //////////////////////////////////////////////////////////////////////////////// const char* DgLocList::fromString (const char* str, char delimiter) { destroy(); setIsOwner(true); const char* tmp = str; while (*tmp) { DgLocation* tloc = new DgLocation(rf()); tmp = tloc->fromString(tmp, delimiter); push_back(tloc); if (*tmp == delimiter) tmp++; } return tmp; } // DgLocList::fromString //////////////////////////////////////////////////////////////////////////////// string DgLocList::asAddressString (void) const { string str; str = "[[\n"; list<DgLocBase*>::const_iterator it; for (it = begin(); it != end(); it++) str += (*it)->asAddressString(); str += "]]\n"; return str; } // DgLocList::asAddressString //////////////////////////////////////////////////////////////////////////////// string DgLocList::asAddressString (char delimiter) const { string str; list<DgLocBase*>::const_iterator it; for (it = begin(); it != end(); it++) str += (*it)->asAddressString(delimiter); return str; } // DgLocList::asAddressString //////////////////////////////////////////////////////////////////////////////// void DgLocList::convertTo (const DgRFBase& rfIn) { if (!rf_ || rf() != rfIn) { rf_ = &rfIn; list<DgLocBase*>::iterator it; for (it = begin(); it != end(); it++) (*it)->convertTo(rfIn); } } // DgLocList::convertTo //////////////////////////////////////////////////////////////////////////////// void DgLocList::push_back (DgLocBase* loc) { rf().convert(loc); list<DgLocBase*>::push_back(loc); } //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// ostream& operator<< (ostream& stream, const DgLocList& list) { //stream << "[[\n"; DgLocList::const_iterator it; for (it = list.begin(); it != list.end(); it++) stream << **it << "\n"; stream << "]]\n"; return stream; } // ostream& operator<< ////////////////////////////////////////////////////////////////////////////////
ead7200c9aa80c20a0a5aecfdb79b706d67136bf
7f5b70e077be31580c729e552adab3d706b5c5db
/CFile.cpp
d26dfee82b55476a0b75e8f2d2cdd2bf2c3e730a
[]
no_license
Rubberbandits/1337io
af25b3f9c159f794d02848ccf80fb48e2f6425ec
859bbb94222e8a5e4cf91fa6b049a66820190c36
refs/heads/master
2021-01-11T19:46:33.244719
2017-01-18T23:05:23
2017-01-18T23:05:23
79,393,725
1
0
null
null
null
null
UTF-8
C++
false
false
6,875
cpp
CFile.cpp
#include "CFile.h" //note: i got lazy in the end // will fix soon CFile::CFile(lua_State* state) { CreateNewInstance(state); } CFile::~CFile() { } int CFile::gcDeleteWrapper(lua_State* state) { using namespace GarrysMod::Lua; UserData* pUserData = static_cast<UserData*>(LUA->GetUserdata(1)); if (pUserData == nullptr || pUserData->type != TYPE_FILE) return 0; auto pFile = static_cast<CFile*>(pUserData->data); if (pFile == nullptr) return 0; pFile->OnRemove(state); delete pFile; return 0; } static int iUserMeta = 0; void CFile::CreateMetaTable(lua_State* state){ LUA->CreateTable(); LUA->PushCFunction(gcDeleteWrapper); LUA->SetField(-2, "__gc"); iUserMeta = LUA->ReferenceCreate(); } void CFile::CreateNewInstance(lua_State* state) { using namespace GarrysMod::Lua; if (iUserMeta == 0) CreateMetaTable(state); UserData* pUserData = static_cast<UserData*>(LUA->NewUserdata(sizeof(UserData))); pUserData->data = this; pUserData->type = TYPE_FILE; int iReference = LUA->ReferenceCreate(); LUA->ReferencePush(iReference); LUA->ReferencePush(iUserMeta); LUA->SetMetaTable(-2); LUA->Pop(); LUA->CreateTable(); LUA->PushCFunction(Close); LUA->SetField(-2, "Close"); LUA->PushCFunction(Write); LUA->SetField(-2, "Write"); LUA->PushCFunction(Append); LUA->SetField(-2, "Append"); LUA->PushCFunction(Read); LUA->SetField(-2, "Read"); LUA->PushCFunction(Flush); LUA->SetField(-2, "Flush"); LUA->PushCFunction(Clear); LUA->SetField(-2, "Clear"); LUA->PushCFunction(Length); LUA->SetField(-2, "Length"); LUA->ReferencePush(iReference); LUA->SetField(-2, "__usrdata_ref"); LUA->ReferenceFree(iReference); } void CFile::OnRemove(lua_State* state) { _Close(); DeleteFileName(); } /* raw functions */ void CFile::DeleteFileName() { if (m_pszFileName == nullptr) return; delete[] m_pszFileName; m_pszFileName = nullptr; } void CFile::SetFile(const char* pszFileName) { DeleteFileName(); m_pszFileName = new char[strlen(pszFileName) + 1]; strcpy(m_pszFileName, pszFileName); } const char* CFile::GetFile() { return m_pszFileName; } FILE_OPERATION CFile::_Open(const char* pszFileName, bool bNoOverride) { if (m_ofFile.is_open()) return FILE_ALREADY_OPEN; m_ofFile.open(pszFileName, std::ios_base::out | std::ios_base::app); if (!m_ofFile.is_open()) return FILE_CANT_OPEN; // lol im lazy if (!bNoOverride) { SetFile(pszFileName); } return FILE_OK; } FILE_OPERATION CFile::_Close() { if (!m_ofFile.is_open()) return FILE_NOT_OPEN; //_Flush(); m_ofFile.close(); return FILE_OK; } FILE_OPERATION CFile::_Write(const char* pszText) { if (!m_ofFile.is_open()) return FILE_NOT_OPEN; m_ofFile << pszText; return FILE_OK; } FILE_OPERATION CFile::_Read(std::stringstream& rStringStream) { if (!m_ofFile.is_open()) return FILE_NOT_OPEN; auto _result = _Close(); if (_result != FILE_OK) return _result; std::ifstream tempstream; // this from stackoverflow tempstream.open(GetFile(), std::ios_base::in); if (!tempstream.is_open()) return FILE_NOT_OPEN; rStringStream << tempstream.rdbuf(); tempstream.close(); _result = _Open(GetFile(), true); return _result; } FILE_OPERATION CFile::_Flush() { if (!m_ofFile.is_open()) return FILE_NOT_OPEN; m_ofFile.flush(); return FILE_OK; } FILE_OPERATION CFile::_Clear() { if (!m_ofFile.is_open()) return FILE_NOT_OPEN; auto _result = _Close(); if (_result != FILE_OK) return _result; std::ofstream tempstream; tempstream.open(GetFile(), std::ios_base::out | std::ios_base::trunc); tempstream.close(); _result = _Open(GetFile(), true); return FILE_OK; } FILE_OPERATION CFile::_Length(long& rnSize) { if (!m_ofFile.is_open()) return FILE_NOT_OPEN; auto _result = _Close(); if (_result != FILE_OK) return _result; std::ifstream tempstream; // this from stackoverflow tempstream.open(GetFile(), std::ios_base::in | std::ios_base::binary); if (!tempstream.is_open()) return FILE_NOT_OPEN; tempstream.ignore(std::numeric_limits<std::streamsize>::max()); rnSize = tempstream.gcount(); tempstream.close(); _result = _Open(GetFile(), true); return _result; } /* funcs for lua */ CFile* CFile::UnpackMe(lua_State* state) { using namespace GarrysMod::Lua; LUA->GetField(1, "__usrdata_ref"); UserData* pUserData = static_cast<UserData*>(LUA->GetUserdata(-1)); LUA->Pop(); if (pUserData == nullptr || pUserData->type != TYPE_FILE) return nullptr; auto pFile = static_cast<CFile*>(pUserData->data); if (pFile == nullptr) return nullptr; return pFile; } int CFile::Close(lua_State* state) { FILE_OPERATION _result = FILE_NULLPTR; auto pFile = UnpackMe(state); if (pFile != nullptr) _result = pFile->_Close(); LUA->PushNumber(_result); return 1; } int CFile::Write(lua_State* state) { using namespace GarrysMod::Lua; FILE_OPERATION _result = FILE_NULLPTR; auto pFile = UnpackMe(state); if (pFile != nullptr) { if (!LUA->IsType(2, Type::STRING)) { LUA->ThrowError("NO STRING TO WRITE"); _result = FILE_MISSING_ARGUMENTS; } else { _result = pFile->_Clear(); if (_result != FILE_OK) goto breakout; _result = pFile->_Write(LUA->GetString(2)); } } breakout: LUA->PushNumber(_result); return 1; } int CFile::Append(lua_State* state) { using namespace GarrysMod::Lua; FILE_OPERATION _result = FILE_NULLPTR; auto pFile = UnpackMe(state); if (pFile != nullptr) { if (!LUA->IsType(2, Type::STRING)) { LUA->ThrowError("NO STRING TO WRITE"); _result = FILE_MISSING_ARGUMENTS; } else { _result = pFile->_Write(LUA->GetString(2)); } } LUA->PushNumber(_result); return 1; } int CFile::Read(lua_State* state) { FILE_OPERATION _result = FILE_NULLPTR; std::stringstream tempstream; auto pFile = UnpackMe(state); if (pFile != nullptr) _result = pFile->_Read(tempstream); LUA->PushString(tempstream.str().c_str()); LUA->PushNumber(_result); return 2; } int CFile::Flush(lua_State* state) { FILE_OPERATION _result = FILE_NULLPTR; auto pFile = UnpackMe(state); if (pFile != nullptr) _result = pFile->_Flush(); LUA->PushNumber(_result); return 1; } int CFile::Clear(lua_State* state) { // HACKISH?? FILE_OPERATION _result = FILE_NULLPTR; auto pFile = UnpackMe(state); if (pFile != nullptr) _result = pFile->_Clear(); LUA->PushNumber(_result); return 1; } int CFile::Length(lua_State* state) { FILE_OPERATION _result = FILE_NULLPTR; long nSize = -1; auto pFile = UnpackMe(state); if (pFile != nullptr) _result = pFile->_Length(nSize); LUA->PushNumber(nSize); LUA->PushNumber(_result); return 2; }
bd8ac32eab57ab919ff97658869e7044377f924b
675ad919b372939fcc4cd2ccffd62817522caaad
/source/base/math/fourier/dft.hpp
aa604331bffcbf880051eda0a2640d9ee6e169d8
[]
no_license
lineCode/sprout
2308ff7de515c6499ffb5bf6889bf9ccebc6b2bd
ffaefc1c6ffd5f8fb6da3acbe98d05555586791e
refs/heads/master
2020-04-05T06:15:25.954312
2018-11-07T09:41:57
2018-11-07T09:41:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
705
hpp
dft.hpp
#ifndef SU_BASE_MATH_FOURIER_DFT_HPP #define SU_BASE_MATH_FOURIER_DFT_HPP #include "math/vector.hpp" namespace thread { class Pool; } namespace math { int32_t dft_size(int32_t num); void dft_1d(float2* result, float const* source, int32_t num); void idft_1d(float* result, float2 const* source, int32_t num); void dft_2d(float2* result, float const* source, int32_t width, int32_t height, thread::Pool& pool); void dft_2d(float2* result, float const* source, float2* temp, int32_t width, int32_t height, thread::Pool& pool); void idft_2d(float* result, float2 const* source, float2* temp, int32_t width, int32_t height, thread::Pool& pool); } // namespace math #endif
ed5831a94fef39e435cc022761fe148def0cc135
f17ea5ae47d234dda1232b3e24a7c10cde9f69a5
/Homework1/MaximumElem.cpp
3bf920c4bd07801c4b41e9e121b933d7db00dc91
[]
no_license
georgiharak/SDA-Homeworks
f6614ca702b418e087d1ab0cadfeafe4035bef2a
130d5d75a1762b9f77a64420c76020030f1974c8
refs/heads/master
2021-08-10T17:46:13.578970
2017-11-12T21:10:29
2017-11-12T21:10:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,172
cpp
MaximumElem.cpp
<<<<<<< HEAD #include <iostream> #include <cassert> #include <queue> using namespace std; template <typename T> struct node { T data; node* next; }; template <typename T> class LStack { private: node<T>* topNode; void copy(node<T>* toCopy); void eraseStack(); void copyStack(LStack const&); public: LStack(); // създаване на празен стек LStack(LStack const&); // Конструктор за копиране LStack& operator=(LStack const&); // операция за присвояване ~LStack(); // деструктор bool empty() const; void push(T const& x); T pop(); T top() const; void print(); T maxelem(); }; template <typename T> LStack<T>::LStack() : topNode(nullptr) {} template <typename T> bool LStack<T>::empty() const { return topNode == nullptr; } template <typename T> void LStack<T>::push(T const& x) { node<T>* p = new node<T>; p->data = x; p->next = topNode; topNode = p; } template <typename T> T LStack<T>::pop() { if (empty()) { cerr << "празен стек!\n"; return 0; } node<T>* p = topNode; topNode = topNode->next; T x = p->data; delete p; return x; } template <typename T> T LStack<T>::top() const { if (empty()) { cerr << "празен стек!\n"; return 0; } return topNode->data; } template <typename T> void LStack<T>::eraseStack() { while (!empty()) pop(); } template <typename T> LStack<T>::~LStack() { eraseStack(); } template <typename T> void LStack<T>::copy(node<T>* toCopy) //Рекурсия , ЧИКИ БРИКИ { if (toCopy == nullptr) return; copy(toCopy->next); push(toCopy->data); //добавямe първия елемент отгоре } template <typename T> void LStack<T>::copyStack(LStack const& ls) { topNode = nullptr; copy(ls.topNode); } template <typename T> LStack<T>::LStack(LStack const& ls) { copyStack(ls); } template <typename T> LStack<T>& LStack<T>::operator=(LStack const& ls) { if (this != &ls) { eraseStack(); copyStack(ls); } return *this; } template <typename T> void LStack<T>::print() { node<T> *p = topNode; while(p!= NULL) { cout<<p->data<<endl; p = p->next; } } template <typename T> T LStack<T>::maxelem() { T maxElem = top(); node<T> *p = topNode; while(p!= NULL) { if(maxElem < p->data) maxElem = p->data; p = p->next; } return maxElem; } int main() { LStack<int> Bomb1 , Bomb2; int n,m; cin>>n; for(int i=0 ; i<n ;i++) { cin>>m; switch(m) { case 1: int x; cin>>x; if(Bomb1.empty()) { Bomb1.push(x); Bomb2.push(x); } else { Bomb1.push(x); if(x >= Bomb2.top()) { Bomb2.push(x); } } break; case 2: if (Bomb1.empty()) break; if(Bomb1.top() == Bomb2.top()) { Bomb1.pop(); Bomb2.pop(); } else Bomb1.pop(); break; case 3: cout<<Bomb2.top()<<endl; break; } }; return 0; } ======= #include <iostream> #include <cassert> #include <queue> using namespace std; template <typename T> struct node { T data; node* next; }; template <typename T> class LStack { private: node<T>* topNode; void copy(node<T>* toCopy); void eraseStack(); void copyStack(LStack const&); public: LStack(); // създаване на празен стек LStack(LStack const&); // Конструктор за копиране LStack& operator=(LStack const&); // операция за присвояване ~LStack(); // деструктор bool empty() const; void push(T const& x); T pop(); T top() const; void print(); T maxelem(); }; template <typename T> LStack<T>::LStack() : topNode(nullptr) {} template <typename T> bool LStack<T>::empty() const { return topNode == nullptr; } template <typename T> void LStack<T>::push(T const& x) { node<T>* p = new node<T>; p->data = x; p->next = topNode; topNode = p; } template <typename T> T LStack<T>::pop() { if (empty()) { cerr << "празен стек!\n"; return 0; } node<T>* p = topNode; topNode = topNode->next; T x = p->data; delete p; return x; } template <typename T> T LStack<T>::top() const { if (empty()) { cerr << "празен стек!\n"; return 0; } return topNode->data; } template <typename T> void LStack<T>::eraseStack() { while (!empty()) pop(); } template <typename T> LStack<T>::~LStack() { eraseStack(); } template <typename T> void LStack<T>::copy(node<T>* toCopy) //Рекурсия , ЧИКИ БРИКИ { if (toCopy == nullptr) return; copy(toCopy->next); push(toCopy->data); //добавямe първия елемент отгоре } template <typename T> void LStack<T>::copyStack(LStack const& ls) { topNode = nullptr; copy(ls.topNode); } template <typename T> LStack<T>::LStack(LStack const& ls) { copyStack(ls); } template <typename T> LStack<T>& LStack<T>::operator=(LStack const& ls) { if (this != &ls) { eraseStack(); copyStack(ls); } return *this; } template <typename T> void LStack<T>::print() { node<T> *p = topNode; while(p!= NULL) { cout<<p->data<<endl; p = p->next; } } template <typename T> T LStack<T>::maxelem() { T maxElem = top(); node<T> *p = topNode; while(p!= NULL) { if(maxElem < p->data) maxElem = p->data; p = p->next; } return maxElem; } int main() { LStack<int> Bomb1 , Bomb2; int n,m; cin>>n; for(int i=0 ; i<n ;i++) { cin>>m; switch(m) { case 1: int x; cin>>x; if(Bomb1.empty()) { Bomb1.push(x); Bomb2.push(x); } else { Bomb1.push(x); if(x >= Bomb2.top()) { Bomb2.push(x); } } break; case 2: if (Bomb1.empty()) break; if(Bomb1.top() == Bomb2.top()) { Bomb1.pop(); Bomb2.pop(); } else Bomb1.pop(); break; case 3: cout<<Bomb2.top()<<endl; break; } }; return 0; } >>>>>>> c8c2a42dae3e0da5982935dc1bee34aee7aac52e
93eea9c928cbb07b2da730f9c7343bb1abe2253c
98157b3124db71ca0ffe4e77060f25503aa7617f
/icpc/acpc2015/dna-evolution.cpp
23c4500e8ad21818dcad0026bc1cafebf051a11c
[]
no_license
wiwitrifai/competitive-programming
c4130004cd32ae857a7a1e8d670484e236073741
f4b0044182f1d9280841c01e7eca4ad882875bca
refs/heads/master
2022-10-24T05:31:46.176752
2022-09-02T07:08:05
2022-09-02T07:08:35
59,357,984
37
4
null
null
null
null
UTF-8
C++
false
false
1,560
cpp
dna-evolution.cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int a[N], b[N]; char s[N], cset[] = {'A', 'C', 'G', 'T'}; int idx[256]; bool isnot[N][5]; int main() { for(int i = 0; i<4; i++) idx[cset[i]] = i; int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); for(int i = 0; i<n; i++) scanf("%d", a+i); s[0] = cset[0]; int now = 1; bool possible = true; memset(isnot, false, sizeof isnot); for(int i = 1; i<n; i++) { if((i + a[i]) > n) possible = false; if(!possible) break; while(now < (i + a[i])) { s[now] = s[now-i]; now++; } isnot[i+a[i]][idx[s[a[i]]]] = true; if(now == i) { possible = false; for(int j = 0; j<4; j++) if(!isnot[i][j]) { s[now] = cset[j]; possible = true; now++; break; } } } s[n] = '\0'; b[0] = n; if(b[0] != a[0]) possible = false; int l, r; l = r = 0; for(int i = 1; i<n && possible; i++) { if(i > r) { l = r = i; while(r < n && s[r-l] == s[r]) r++; b[i] = r-l; r--; } else { int k = i-l; if(b[k] < r-i+1) b[i] = b[k]; else { l = i; while(r < n && s[r-l] == s[r]) r++; b[i] = r-l; r--; } } if(b[i] != a[i]) { possible = false; break; } } s[n] = '\0'; printf("%s\n", possible ? s : "Impossible"); } return 0; }
f0da228ddbef5adf3c9ffa0f0a8d3fbc74ca05c9
c8c31755a952e8fb424922cdd2b1cd59e0c3e9dd
/sessie_0/include/Labo1.h
c236592004eb153da027ed142010e85e83b57159
[]
no_license
BramObbels/2018_LaboBeeldinterpretatie_BramObbels
5237f1c04e17e8c3e79ba94d6beb5b5c6417e1ee
964e5d2d04d7bbbca8a65697c84de7dce9943937
refs/heads/master
2020-04-01T23:05:35.955430
2019-01-07T21:35:26
2019-01-07T21:35:26
153,741,435
0
0
null
null
null
null
UTF-8
C++
false
false
155
h
Labo1.h
#ifndef LABO1_H #define LABO1_H class Labo1 { public: Labo1(); virtual ~Labo1(); protected: private: }; #endif // LABO1_H
21957334e13bcae2cb33b90eb71c19588efdceed
fb190dbcf224654567091f3e4bcb513d83343333
/1035.cpp
8a8aca5c5993a61afaba3a3bae8d16993c323ab9
[]
no_license
SakhawatCoU/My-LightOJ-code
eb282729e15d49d24f42549f2d7450fed477d8ba
797096c8ac2e771638d24b3638ef450a42d90b8b
refs/heads/master
2020-04-05T04:08:51.951941
2019-04-19T06:53:44
2019-04-19T06:53:44
156,539,423
0
0
null
null
null
null
UTF-8
C++
false
false
1,960
cpp
1035.cpp
#include<bits/stdc++.h> #define lli long long int #define scf(n) scanf("%lld",&n) #define rep1(n) for(int i=1;i<=n;i++) #define prf(n) printf("%lld",n) #define sci(n) scanf("%d",&n) #define pri(n) printf("%d",n) #define prl(n) printf("%lld",n) #define scl(n) scanf("%lld",&n) #define nl printf("\n") #define spc printf(" ") #define file freopen("in.txt","rt",stdin) #define pii pair<int,int> #define piii pair<int,string> using namespace std; struct PrimeFact { long long int n; vector<long long int> primeFactors; PrimeFact (long long int n) : n(n) {} void generatePrimeFactor() { // primeFactors.clear(); while(n%2==0) { primeFactors.push_back(2); n/=2; } for(long long int i=3; i<=sqrt(n); i+=2) { while(n%i==0) { primeFactors.push_back(i); n/=i; } } if(n>2) primeFactors.push_back(n); } }; int main() { long long int n,m; set<lli> st; set<lli>::iterator it; lli cnt[500]; int test; scanf("%d",&test); for(int k=1; k<=test; k++) { scanf("%lld",&m); memset(cnt,0,sizeof cnt); st.clear(); for(lli i=2; i<=m; i++) { n = i; PrimeFact T(n); T.generatePrimeFactor(); for(int i=0; i<T.primeFactors.size(); i++) { st.insert(T.primeFactors[i]); cnt[T.primeFactors[i]]++; } } printf("Case %d: %lld =",k,m); int c = 0; for(it=st.begin();it!=st.end();++it) { if(c==0) { printf(" "); } else { printf(" * "); } c++; lli v = *it; printf("%lld (%lld)",v,cnt[v]); } printf("\n"); } return 0; }
d622c2bb50bf8c38d0d03939be7a6074a094621c
9e3c7efe760da59c53095cbfa264ad2b35112e44
/videos/037_50_million_primes_in_5_seconds_segmented_sieve_of_eratosthenes/sieve_erat.cpp
5a690e4e8208a4492a0f0ab7d4f936b1340d92ed
[ "MIT" ]
permissive
omerkulahci/VideosSampleCode
ea95272f7e9d9982691b3ed9b085798f16179d05
666f1e7aca47c1dc3b5445ab5b79746247bf3040
refs/heads/master
2023-08-28T12:06:42.982336
2021-10-23T14:28:30
2021-10-23T14:28:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,812
cpp
sieve_erat.cpp
#include <string> #include <vector> #include <iostream> #include <fstream> #include <exception> #include <cstdlib> #include <algorithm> using Int = uint64_t; template <typename T, typename = std::enable_if_t<std::is_integral_v<T> && std::is_unsigned_v<T>>> constexpr T largest_squarable() { return (static_cast<T>(1) << (std::numeric_limits<T>::digits >> 1)) - static_cast<T>(1); } constexpr Int smallest_multiple_of_n_geq_m(const Int n, const Int m) { if (m % n == 0) { return m; } return m + (n - (m % n)); } class SegmentedPrimes { public: SegmentedPrimes() : primes{2, 3, 5, 7}, end_segment{1}, is_prime_buffer{} { } void reserve(const std::size_t n) { primes.reserve(n); } std::size_t size() const { return primes.size(); } Int nth_prime(const std::size_t n) const { return primes[n]; } Int count_primes_leq(const Int n) const { return std::upper_bound(primes.begin(), primes.end(), n) - primes.begin(); } void push_back_until_size_geq(const Int n) { while (primes.size() < n) { push_back_next_segment_of_primes(); } } void push_back_until_max_geq(const Int n) { while (primes.back() < n) { push_back_next_segment_of_primes(); } } /* push_back new primes in the range [p_k^2, p_{k+n}^2) to the primes vector, where k == end_segment and n is at least 1 The range [p_k^2, p_{k+n}^2) is sieved by [p_0, ..., p_{k+n-1}] because if a composite number n has all prime factors >= p_{k+n}, then n >= p_{k+n}^2. Precondition: primes contains all primes in the range [2, p_k^2) and no more before writing. Postcondition: primes contains all primes in the range [2, p_{k+n}^2) and no more. */ void push_back_at_most_n_segments_of_primes(const std::size_t n) { const std::size_t n_segments = std::min(n, primes.size() - 1 - end_segment); const Int p = primes[end_segment]; const Int q = primes[end_segment + n_segments]; if (p > largest_squarable<Int>() || q > largest_squarable<Int>()) { throw std::overflow_error("square"); } const Int segment_min = p * p; const Int segment_max = q * q - 1; std::size_t segment_len = static_cast<std::size_t>(segment_max - segment_min + 1); // >= 4p+4 is_prime_buffer.clear(); is_prime_buffer.resize(segment_len, 1); for (std::size_t i = 0; i <= end_segment + n_segments; ++i) { const Int test_prime = primes[i]; const Int start = smallest_multiple_of_n_geq_m(test_prime, segment_min); for (std::size_t idx = static_cast<std::size_t>(start - segment_min); idx < is_prime_buffer.size(); idx += test_prime) { is_prime_buffer[idx] = 0; } } for (std::size_t i = 0; i < is_prime_buffer.size(); ++i) { if (is_prime_buffer[i]) { primes.push_back(i + segment_min); } } end_segment += n_segments; } void push_back_next_segment_of_primes() { push_back_at_most_n_segments_of_primes(1); } auto get_primes() const -> const std::vector<Int> & { return primes; } private: std::vector<Int> primes; // primes is all primes in [2, p_k^2) where k == last_segment std::size_t end_segment; std::vector<int> is_prime_buffer; }; void write_segment(const std::vector<Int> &primes, const std::size_t start, const std::size_t end, std::ostream &out) { return; for (std::size_t i = start; i != end; ++i) { out << primes[i] << '\n'; } } void write_first_n_primes(const std::size_t n, std::ostream &out) { SegmentedPrimes primes; try { // primes.reserve(n); primes.push_back_until_size_geq(n); } catch (const std::bad_alloc &) { if (primes.size() < n) { std::cerr << "Error: not enough memory, only able to compute " << primes.size() << " primes" << std::endl; write_segment(primes.get_primes(), 0, primes.size(), out); std::exit(EXIT_FAILURE); } } catch (const std::length_error &) { if (primes.size() < n) { std::cerr << "Error: not enough memory, only able to compute " << primes.size() << " primes" << std::endl; write_segment(primes.get_primes(), 0, primes.size(), out); std::exit(EXIT_FAILURE); } } catch (const std::overflow_error &) { std::cerr << "Error: overflow detected, quitting early with " << primes.size() << " primes" << std::endl; write_segment(primes.get_primes(), 0, primes.size(), out); std::exit(EXIT_FAILURE); } write_segment(primes.get_primes(), 0, n, out); } void usage() { std::cerr << "usage: sieve_erat.exe n_primes [filename]" << std::endl; } int main(int argc, char *argv[]) { if (argc < 2 || argc > 3) { usage(); return EXIT_FAILURE; } std::size_t how_many = std::stoul(std::string(argv[1])); // std::ostream *out_ptr = nullptr; // std::ofstream out; // if (argc == 3) // { // out.open(argv[2]); // if (!out.is_open()) // { // std::cerr << "Error: could not open file for writing" << std::endl; // return EXIT_FAILURE; // } // out_ptr = &out; // } // else // { // out_ptr = &std::cout; // } // write_first_n_primes(how_many, *out_ptr); SegmentedPrimes primes; primes.push_back_until_size_geq(how_many); return EXIT_SUCCESS; }
1f1e98a28d48a640f2efff979838a5f17da6909a
31ef5e4afc9f3392e3110a2fb62e1a5d5032e119
/src/moaicore/MOAITextLayout.h
5461db85081419840f7eb2fa2532a422487f2277
[]
no_license
kengonakajima/moai-dev
f16597c6369ff8846b50141da684d7278d8e153f
f1995014a9f30e1c9bf23a3823d9bbf8bd30a608
refs/heads/master
2021-01-16T22:52:14.755836
2012-01-20T21:31:48
2012-01-20T21:31:48
3,116,345
4
0
null
null
null
null
UTF-8
C++
false
false
1,357
h
MOAITextLayout.h
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved. // http://getmoai.com #ifndef MOAITEXTLAYOUT_H #define MOAITEXTLAYOUT_H class MOAIGlyph; //================================================================// // MOAITextSprite //================================================================// class MOAITextSprite { private: friend class MOAITextLayout; friend class MOAIFont; friend class MOAITextFrame; float mX; float mY; u32 mIdx; // index in source text stream u32 mRGBA; const MOAIGlyph* mGlyph; float mPoints; public: //----------------------------------------------------------------// bool operator < ( const MOAITextSprite& rhs ) const { return this->mIdx < rhs.mIdx; } }; //================================================================// // MOAITextLayout //================================================================// class MOAITextLayout : public USLeanStack < MOAITextSprite, 64 > { public: //----------------------------------------------------------------// void Draw ( u32 reveal ); bool GetBoundsForRange ( u32 idx, u32 size, USRect& rect ); void PushGlyph ( const MOAIGlyph* glyph, u32 idx, float x, float y, float points, u32 rgba ); void SetColorForRange ( u32 idx, u32 size, u32 rgba ); }; #endif
3ccb811b521551e17d6340ddf617f9b1aca91928
8ec52fb474c6f754c548cb99bd2e389213443ef5
/include/http/HttpClientBase.hpp
89d7452056df596891132d84fa0bc8a1896a8d0f
[ "MIT" ]
permissive
sroycode/identt
443cb55ad43f5903e1d06543ded28864cbaa6bf8
40bffa3d8db69c810c4d6707b9eb32f983539c99
refs/heads/master
2022-03-08T09:52:07.487528
2019-11-16T12:46:03
2019-11-16T12:46:03
105,420,001
4
0
null
null
null
null
UTF-8
C++
false
false
6,215
hpp
HttpClientBase.hpp
/** * @project identt * @file include/http/HttpClientBase.hpp * @author S Roychowdhury <sroycode AT gmail DOT com> * @version 1.0.0 * * @section LICENSE * * Copyright (c) 2017 S Roychowdhury. * * 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. * * @section DESCRIPTION * * HttpClientBase.hpp : Http Client base * */ #ifndef _IDENTT_HTTP_CLIENTBASE_HPP_ #define _IDENTT_HTTP_CLIENTBASE_HPP_ #include <map> #include <random> #include "ClientResponse.hpp" namespace identt { namespace http { template <class socket_type> class ClientBase { public: using Response = ClientResponse<socket_type>; using RespPtr = std::shared_ptr<Response>; RespPtr request( const std::string& request_type, const std::string& path="/", const std::map<std::string, std::string>& header=std::map<std::string, std::string>()) { std::stringstream empty_ss; return request(request_type, path, empty_ss, header); } RespPtr request(const std::string& request_type, const std::string& path, std::ostream& content, const std::map<std::string, std::string>& header=std::map<std::string, std::string>()) { std::string corrected_path=path; if(corrected_path=="") corrected_path="/"; content.seekp(0, std::ios::end); size_t content_length=content.tellp(); content.seekp(0, std::ios::beg); boost::asio::streambuf write_buffer; std::ostream write_stream(&write_buffer); write_stream << request_type << " " << corrected_path << " HTTP/1.1\r\n"; write_stream << "Host: " << host << "\r\n"; for(auto& h: header) { write_stream << h.first << ": " << h.second << "\r\n"; } if(content_length>0) write_stream << "Content-Length: " << std::to_string(content_length) << "\r\n"; write_stream << "\r\n"; if(content_length>0) write_stream << content.rdbuf(); RespPtr response(new Response()); try { connect(); boost::asio::write(*socket, write_buffer); size_t bytes_transferred = boost::asio::read_until(*socket, response->content_buffer, "\r\n\r\n"); size_t num_additional_bytes=response->content_buffer.size()-bytes_transferred; parse_response_header(response, response->content); if(response->header.count("Content-Length")>0) { boost::asio::read(*socket, response->content_buffer, boost::asio::transfer_exactly(stoull(response->header["Content-Length"])-num_additional_bytes)); } else if(response->header.count("Transfer-Encoding")>0 && response->header["Transfer-Encoding"]=="chunked") { boost::asio::streambuf streambuf; std::ostream content(&streambuf); size_t length; std::string buffer; do { size_t bytes_transferred = boost::asio::read_until(*socket, response->content_buffer, "\r\n"); std::string line; getline(response->content, line); bytes_transferred-=line.size()+1; line.pop_back(); length=stoull(line, 0, 16); size_t num_additional_bytes=response->content_buffer.size()-bytes_transferred; if((2+length)>num_additional_bytes) { boost::asio::read(*socket, response->content_buffer, boost::asio::transfer_exactly(2+length-num_additional_bytes)); } buffer.resize(length); response->content.read(&buffer[0], length); content.write(&buffer[0], length); //Remove "\r\n" response->content.get(); response->content.get(); } while(length>0); std::ostream response_content_output_stream(&response->content_buffer); response_content_output_stream << content.rdbuf(); } } catch(const std::exception& e) { socket_error=true; throw std::invalid_argument(e.what()); } return response; } protected: boost::asio::io_service asio_io_service; boost::asio::ip::tcp::endpoint asio_endpoint; boost::asio::ip::tcp::resolver asio_resolver; std::shared_ptr<socket_type> socket; bool socket_error; std::string host; unsigned short port; ClientBase(const std::string& host_port, unsigned short default_port) : asio_resolver(asio_io_service), socket_error(false) { size_t host_end=host_port.find(':'); if(host_end==std::string::npos) { host=host_port; port=default_port; } else { host=host_port.substr(0, host_end); port=(unsigned short)stoul(host_port.substr(host_end+1)); } asio_endpoint=boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port); } virtual void connect()=0; void parse_response_header(RespPtr response, std::istream& stream) const { std::string line; getline(stream, line); size_t version_end=line.find(' '); if(version_end!=std::string::npos) { response->http_version=line.substr(5, version_end-5); response->status_code=line.substr(version_end+1, line.size()-version_end-2); getline(stream, line); size_t param_end=line.find(':'); while(param_end!=std::string::npos) { size_t value_start=param_end+1; if(line[value_start]==' ') value_start++; response->header[line.substr(0, param_end)]=line.substr(value_start, line.size()-value_start-1); getline(stream, line); param_end=line.find(':'); } } } }; } // namespace webserver } // namespace identt #endif /* _IDENTT_HTTP_CLIENTBASE_HPP_ */
0838b6efb91d9275405c6a9570c36630a499a3d3
4781859a7843d1cf3f29b735971759b298dca4f1
/test.cpp
a5d87fc6ad013e8a0629541669c577456d0041d3
[]
no_license
Nipuna-Sankalpa/concurrent_lab_4_5
5cac3edc5cd072d26b5ed6d361bd9688c62b27b3
5c8f2fe3bc4695f8fbaeb2c7ef833fd7c9acc66b
refs/heads/master
2020-02-26T17:08:15.887964
2016-10-09T02:20:59
2016-10-09T02:20:59
69,781,647
0
1
null
null
null
null
UTF-8
C++
false
false
3,855
cpp
test.cpp
//#include <iostream> //#include <vector> //#include <omp.h> //#include <emmintrin.h> //#include <immintrin.h> // // //#define size 1000 ////#define block_size 100 // // //double a[size][size]; //double b[size][size]; //double transpose[size][size]; //double output[size][size]; //double count_1 = 0; // //int main() { // // for (int i = 0; i < 35; ++i) { //#pragma omp parallel for collapse(2) // for (int i = 0; i < size; ++i) { // for (int j = 0; j < size; ++j) { // a[i][j] = (double)rand() / rand(); // b[i][j] = (double)rand() / rand(); // // } // } // //// std::cout << "A Output" << std::endl; //// //// for (int l = 0; l < size; ++l) { //// for (int i = 0; i < size; ++i) { //// std::cout << a[l][i] << "\t"; //// } //// std::cout << std::endl; //// } //// std::cout << "B Output" << std::endl; //// //// for (int l = 0; l < size; ++l) { //// for (int i = 0; i < size; ++i) { //// std::cout << b[l][i] << "\t"; //// } //// std::cout << std::endl; //// } // // // double begin_transpose = omp_get_wtime(); //#pragma omp parallel for num_threads(8) collapse(2) // for (int l = 0; l < size; ++l) { // for (int i = 0; i < size; ++i) { // transpose[l][i] = b[i][l]; // } // } // //#pragma omp parallel for // for (int i = 0; i < size; i++) { // for (int j = 0; j < size; j++) { // __m256d c = _mm256_setzero_pd(); // for (int k = 0; k < size; k += 4) { // c = _mm256_add_pd(c, _mm256_mul_pd(_mm256_load_pd(&a[i][k]), _mm256_load_pd(&transpose[j][k]))); // } // c = _mm256_hadd_pd(c, c); // // __m128d acc1 = _mm256_extractf128_pd(c, 0); // __m128d acc2 = _mm256_extractf128_pd(c, 1); // // acc1 = _mm_add_sd(acc1, acc2); // _mm_store_sd(&output[i][j], acc1); // // } // } // double end_transpose = omp_get_wtime(); // count_1 += (end_transpose - begin_transpose); //// std::cout << "Parallel(Transpose) Elapsed Time : " << (end_transpose - begin_transpose) << " secs" << std::endl; // } // // std::cout << "Parallel(Transpose) Elapsed Time : " << (count_1 / 35) << " secs" << std::endl; // //// for (int _i = 0; _i < size; _i += block_size) { //// for (int _j = 0; _j < size; _j += block_size) { //// for (int _k = 0; _k < size; _k += block_size) { //// for (int i = _i; i < ((_i + block_size > size) ? size : _i + block_size); i++) { //// for (int j = _j; j < ((_j + block_size > size) ? size : _j + block_size); j++) { //// __m256d c = _mm256_setzero_pd(); //// for (int k = _k; k < ((_k + block_size > size) ? size : _k + block_size); k += 4) { //// c = _mm256_add_pd(c, _mm256_mul_pd(_mm256_load_pd(&a[i][k]), //// _mm256_load_pd(&transpose[j][k]))); //// //// //// } //// c = _mm256_hadd_pd(c, c); //// //// __m128d acc1 = _mm256_extractf128_pd(c, 0); //// __m128d acc2 = _mm256_extractf128_pd(c, 1); //// //// acc1 = _mm_add_sd(acc1, acc2); //// _mm_store_sd(&output[i][j], acc1); //// //// } //// } //// //// } //// } //// } // // // //// for (int l = 0; l < size; ++l) { //// for (int i = 0; i < size; ++i) { //// std::cout << output[l][i] << "\t"; //// } //// std::cout << std::endl; //// } // return 0; //}
2a6b43bfde1b3640c1670fe7444419f38320751e
0f2b08b31fab269c77d4b14240b8746a3ba17d5e
/onnxruntime/core/providers/cpu/math/top_k.cc
96d1f7a7578cf3a1358ab93f004deb4d1450cabb
[ "MIT" ]
permissive
microsoft/onnxruntime
f75aa499496f4d0a07ab68ffa589d06f83b7db1d
5e747071be882efd6b54d7a7421042e68dcd6aff
refs/heads/main
2023-09-04T03:14:50.888927
2023-09-02T07:16:28
2023-09-02T07:16:28
156,939,672
9,912
2,451
MIT
2023-09-14T21:22:46
2018-11-10T02:22:53
C++
UTF-8
C++
false
false
27,416
cc
top_k.cc
/** * Copyright (c) 2016-present, Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "core/providers/cpu/math/top_k.h" #include "core/providers/common.h" #include "core/common/common.h" #include "core/common/exceptions.h" #include "core/framework/op_kernel.h" #include "core/framework/tensor.h" #include "core/platform/threadpool.h" #include "core/util/math_cpuonly.h" #include <queue> #include <algorithm> #include <cmath> #include <core/common/safeint.h> namespace onnxruntime { template <typename T> struct GreaterValueCmp { using DataType = T; GreaterValueCmp(const T* data = nullptr) : data_(data) { } bool operator()(const int64_t lhs_idx, const int64_t rhs_idx) const { return (data_[lhs_idx] > data_[rhs_idx] || // when values are equal, we want lhs to get higher "priority" // if its corresponding index comes first (i.e.) is lower (data_[lhs_idx] == data_[rhs_idx] && lhs_idx < rhs_idx)); } bool CompareValueOnly(const T& lhs, const T& rhs) const { return lhs > rhs; } private: const T* data_; }; template <typename T> struct LesserValueCmp { using DataType = T; LesserValueCmp(const T* data = nullptr) : data_(data) { } bool operator()(const int64_t lhs_idx, const int64_t rhs_idx) const { return (data_[lhs_idx] < data_[rhs_idx] || // when values are equal, we want lhs to get higher "priority" // if its corresponding index comes first (i.e.) is lower (data_[lhs_idx] == data_[rhs_idx] && lhs_idx < rhs_idx)); } bool CompareValueOnly(const T& lhs, const T& rhs) const { return lhs < rhs; } private: const T* data_; }; /* Maintain a binary heap where HeapComp of the parent with either child is false. e.g. if the comparison is 'greater than', the parent is smaller than both children. There is no ordering within a level. NOTE: The comparison is backwards compared to std::priority_queue as we use the same comparator for this as for nth_element in SelectTopK. As such for a heap selecting the largest values the comparator is 'greater than'. */ template <class HeapCmp> static void HeapifyIthPosition(int64_t* heap, size_t i, size_t k, const HeapCmp& heap_cmp) { while (true) { size_t left = 2 * i + 1; size_t right = left + 1; if (right < k) { // need to check both left and right children as either could be replaced // check if we should move child up. check left node as well as whether left is preferred over right. // if 'i' can replace left, check whether right would replace left (if so, i replaces left as it's the weakest) bool i_replaces_left = heap_cmp(heap[i], heap[left]); if (i_replaces_left && heap_cmp(heap[right], heap[left])) { // left is going to be pushed up as both i and right beat it // NOTE: std::swap is slower as it uses std::move auto tmp = heap[i]; heap[i] = heap[left]; heap[left] = tmp; i = left; } else if (i_replaces_left || heap_cmp(heap[i], heap[right])) { // i_replaces_left implies left replaces right due to 'if' so replace right with i as right is the weakest. // also check if i only beats right auto tmp = heap[i]; heap[i] = heap[right]; heap[right] = tmp; i = right; } else break; } else if ((left < k) && heap_cmp(heap[i], heap[left])) { auto tmp = heap[i]; heap[i] = heap[left]; heap[left] = tmp; i = left; } else break; } } // Static helpers that implement the core logic for each of the 'TopK' operator flavor // Selects the top k elements (largest or smallest based on template parameter) template <class Comparator> static void SelectTopK(const Comparator& comparer, int64_t row_offset, int64_t num_blocks, int64_t block_slice, int64_t inter_block_offset, const unsigned k, bool sort_top_k, std::vector<int64_t>& data_holder) { for (size_t l = 0; l < onnxruntime::narrow<size_t>(num_blocks); ++l) { data_holder[l] = (row_offset + (l * block_slice + inter_block_offset)); } // find the top k (largest or smallest) elements in the data holder - O(n) average. O(n*n) worst case. // See https://en.wikipedia.org/wiki/Quickselect std::nth_element(data_holder.begin(), data_holder.begin() + (k - 1), data_holder.end(), comparer); // sort the top k elements if needed - O (k log k) if (sort_top_k) { std::sort(data_holder.begin(), data_holder.begin() + k, comparer); } // the data_holder now contains the indices of the top k elements in the first k elements } // Given an input tensor 'input' and metadata values - 'k' and 'axis_parsed', // this method will extract the sorted top k largest/smallest elements and place them in the output tensor 'values' // along with the metadata output 'indices' template <class Comparator> static void FindTopKElements(const Tensor* input, const TensorShape& input_shape, Tensor* values, Tensor* indices, const TensorShape& output_shape, const unsigned k, bool sorted, const unsigned axis_parsed, concurrency::ThreadPool* threadpool) { // Cache some values that will be used in the implementation below const int64_t rows = input_shape.SizeToDimension(static_cast<size_t>(axis_parsed)); const int64_t cols = input->Shape().Size() / rows; const auto* input_data = input->Data<typename Comparator::DataType>(); // Use Eigen maps for convenient indexing into the 2d tensors like Values_map(i,j) const int64_t reduced_cols = output_shape.SizeFromDimension(static_cast<size_t>(axis_parsed)); auto* values_data = values->MutableData<typename Comparator::DataType>(); auto* indices_data = indices->MutableData<int64_t>(); auto values_map = EigenMatrixMapRowMajor<typename Comparator::DataType>(values_data, onnxruntime::narrow<size_t>(rows), onnxruntime::narrow<size_t>(reduced_cols)); auto indices_map = EigenMatrixMapRowMajor<int64_t>(indices_data, onnxruntime::narrow<size_t>(rows), onnxruntime::narrow<size_t>(reduced_cols)); // This is basically the number of elements within each of the "k" rows const int64_t num_blocks = input_shape[axis_parsed]; const int64_t block_slice = reduced_cols / k; int64_t tp_threads = concurrency::ThreadPool::DegreeOfParallelism(threadpool); int64_t num_threads = std::min(tp_threads, rows); // split on rows so can't have more threads than rows // rough attempt to make sure there's enough work for each thread. if there's insufficient work the usage of // too many threads degrades performance. // TODO: May want a different calculation for each branch below instead. int64_t threads_needed = static_cast<int64_t>(std::floor(input_shape.Size() * k / (128 * 1024))); num_threads = std::max(std::min(threads_needed, num_threads), static_cast<int64_t>(1)); // from testing various batch sizes relative to k, the following appears to work well as a selector. // tested with following combinations // batch_size = [ 8, 16, 32, 64, 128, 256, 512, 1024, 2048 ] // k = [ 1, 2, 4, 6, 8, 16, 24, 32, 48, 64, 128 ] bool use_priority_queue = k != 1 && (k < 4 || (std::log2(k) / std::log2(num_blocks)) < 0.725); std::function<void(std::ptrdiff_t batch)> find_top_k; if (k == 1) { // just need to compare values and not indexes as the first instance of the best value is always selected find_top_k = [num_threads, rows, block_slice, num_blocks, input_data, cols, &values_map, &indices_map](std::ptrdiff_t batch) { auto work = concurrency::ThreadPool::PartitionWork(batch, onnxruntime::narrow<size_t>(num_threads), onnxruntime::narrow<size_t>(rows)); Comparator comparer(input_data); for (auto i = work.start; i < work.end; ++i) { auto row_offset = i * cols; for (int64_t j = 0; j < block_slice; ++j) { int64_t cur_idx = row_offset + j; const auto* cur_value = input_data + cur_idx; // using pointer to data is faster than input_data[cur_idx] auto best = *cur_value; // save best value so we only have one load in the CompareValueOnly call int64_t top_idx = cur_idx; for (int64_t l = 1; l < num_blocks; ++l) { cur_value += block_slice; if (comparer.CompareValueOnly(*cur_value, best)) { best = *cur_value; top_idx = cur_value - input_data; } } values_map(i, onnxruntime::narrow<size_t>(j)) = best; // convert overall index to result index // avoid '/' if possible for perf reasons indices_map(i, onnxruntime::narrow<size_t>(j)) = block_slice == 1 ? (top_idx - row_offset - j) : (top_idx - row_offset - j) / block_slice; } } }; } else if (use_priority_queue) { find_top_k = [num_threads, rows, block_slice, num_blocks, k, sorted, input_data, cols, &values_map, &indices_map](std::ptrdiff_t batch) { auto work = concurrency::ThreadPool::PartitionWork(batch, onnxruntime::narrow<size_t>(num_threads), onnxruntime::narrow<size_t>(rows)); Comparator comparer(input_data); // the heap is stored in indices_data. each iteration overwrites the old data when it adds the // initial k values, so we don't need to clear it. std::vector<int64_t> indices_data(k); int64_t* indices = indices_data.data(); // raw pointer is slightly faster for HeapifyIthPosition for (auto i = work.start; i < work.end; ++i) { const auto row_offset = i * cols; for (int64_t j = 0; j < block_slice; ++j) { int64_t l = 0; auto cur_idx = row_offset + j; // add first k items starting from the bottom up for (; l < k; ++l) { indices[k - l - 1] = cur_idx; HeapifyIthPosition(indices, k - SafeInt<size_t>(l) - 1, k, comparer); cur_idx += block_slice; } // insert remainder if the next value would replace the top of the heap (current worst top k value) // save top so we only have one load in the CompareValueOnly call auto top = input_data[indices[0]]; for (; l < num_blocks; ++l) { // we can compare value only. if the current value is equal to the top of the heap it won't // replace it as the index will be higher. if (comparer.CompareValueOnly(input_data[cur_idx], top)) { indices[0] = cur_idx; HeapifyIthPosition(indices, 0, k, comparer); top = input_data[indices[0]]; } cur_idx += block_slice; } if (sorted) { // Extract these k elements and place them in the results placeholder for (l = 0; l < k; ++l) { auto idx = indices[0]; auto col_index = (k - l - 1) * block_slice + j; values_map(i, onnxruntime::narrow<size_t>(col_index)) = input_data[idx]; // convert overall index to result index. avoid '/' if possible for perf reasons indices_map(i, onnxruntime::narrow<size_t>(col_index)) = block_slice == 1 ? (idx - row_offset - j) : (idx - row_offset - j) / block_slice; // put the last value at the top of the heap to replace the removed one, and push it into // place in a heap one smaller. indices[0] = indices[k - SafeInt<size_t>(l) - 1]; HeapifyIthPosition(indices, 0, k - SafeInt<size_t>(l) - 1, comparer); } } else { for (l = 0; l < k; ++l) { int64_t idx = indices[l]; auto col_index = l * block_slice + j; values_map(i, onnxruntime::narrow<size_t>(col_index)) = input_data[idx]; // convert overall index to result index. avoid '/' if possible for perf reasons indices_map(i, onnxruntime::narrow<size_t>(col_index)) = block_slice == 1 ? (idx - row_offset - j) : (idx - row_offset - j) / block_slice; } } } } }; } else { find_top_k = [num_threads, rows, block_slice, num_blocks, k, sorted, input_data, cols, &values_map, &indices_map](std::ptrdiff_t batch) { auto work = concurrency::ThreadPool::PartitionWork(batch, onnxruntime::narrow<size_t>(num_threads), onnxruntime::narrow<size_t>(rows)); Comparator comparer(input_data); // we re-use a single data_holder for performance. avoids allocating memory on each iteration. // the call to SelectTopK overwrites any existing data so we don't need to clear on each iteration. std::vector<int64_t> data_holder(onnxruntime::narrow<size_t>(num_blocks)); for (auto i = work.start; i < work.end; ++i) { auto row_offset = i * cols; for (int64_t j = 0; j < block_slice; ++j) { SelectTopK<Comparator>(comparer, row_offset, num_blocks, block_slice, j, k, sorted, data_holder); // Insert the top 'k' (largest or smallest) elements into the final output buffers for (int64_t l = 0; l < k; ++l) { int64_t idx = data_holder[onnxruntime::narrow<size_t>(l)]; auto col_index = l * block_slice + j; values_map(i, onnxruntime::narrow<size_t>(col_index)) = input_data[idx]; // convert overall index to result index. avoid the cost of the '/' is possible indices_map(i, onnxruntime::narrow<size_t>(col_index)) = block_slice == 1 ? (idx - row_offset - j) : (idx - row_offset - j) / block_slice; } } } }; } if (num_threads <= 1) { find_top_k(0); } else { // we want to re-use the storage variables in each lambda as much as possible to minimize allocations // on each iteration, so the lambda does multiple rows. e.g. the data_holder and indices_data vectors. // the alternative would be to use TryBatchParallelFor with the lambda doing one row. // Use TrySimpleParallelFor so openmp is supported correctly concurrency::ThreadPool::TrySimpleParallelFor(threadpool, onnxruntime::narrow<ptrdiff_t>(num_threads), find_top_k); } } // Wrapper over core TopK implementation template <typename T> static Status TopKImpl(OpKernelContext* p_op_kernel_context, const Tensor* input, const int axis, const unsigned k, bool largest = true, bool sorted = true) { const TensorShape& input_shape = input->Shape(); // Will return axis_ as is if positive or fixes it in case it is negative const auto axis_parsed = HandleNegativeAxis(axis, static_cast<int64_t>(input_shape.NumDimensions())); // Check to ensure k is within the bounds of what is available in that specific axis if (input_shape[onnxruntime::narrow<size_t>(axis_parsed)] < k) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "k argument [", k, "] should not be greater than specified axis dim value [", input_shape[onnxruntime::narrow<size_t>(axis_parsed)], "]"); } // Resize output tensors to be the same shape as the input except // for the specified dimension ((i.e.) axis_parsed), which will be of size k. E.x. for an input tensor // of shape [3, 4, 5] and k=2 with axis_parsed=1, both of the outputs will be shape [3, 2, 5] TensorShape output_shape = input_shape; output_shape[onnxruntime::narrow<size_t>(axis_parsed)] = k; auto* values = p_op_kernel_context->Output(0, output_shape); auto* indices = p_op_kernel_context->Output(1, output_shape); if (values == nullptr || indices == nullptr) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "output count mismatch, expected 2 outputs to be present for TopK operator"); } // no-op - no output buffers to fill - return silently if (k == 0) { return Status::OK(); } auto* threadpool = p_op_kernel_context->GetOperatorThreadPool(); if (largest) { FindTopKElements<GreaterValueCmp<T>>(input, input_shape, values, indices, output_shape, k, sorted, gsl::narrow_cast<unsigned>(axis_parsed), threadpool); } else { FindTopKElements<LesserValueCmp<T>>(input, input_shape, values, indices, output_shape, k, sorted, gsl::narrow_cast<unsigned>(axis_parsed), threadpool); } return Status::OK(); } // Wrapper over core TopK implementation template <typename T> Status GetTopK(const Tensor* input, const int axis, const unsigned k, bool largest, bool sorted, AllocatorPtr allocator, onnxruntime::concurrency::ThreadPool* threadpool, Tensor& output_values, Tensor& output_indices) { const TensorShape& input_shape = input->Shape(); // Will return axis_ as is if positive or fixes it in case it is negative const auto axis_parsed = HandleNegativeAxis(axis, static_cast<int64_t>(input_shape.NumDimensions())); // Check to ensure k is within the bounds of what is available in that specific axis if (input_shape[onnxruntime::narrow<size_t>(axis_parsed)] < k) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "k argument [", k, "] should not be greater than specified axis dim value [", input_shape[onnxruntime::narrow<size_t>(axis_parsed)], "]"); } // Resize output tensors to be the same shape as the input except // for the specified dimension ((i.e.) axis_parsed), which will be of size k. E.x. for an input tensor // of shape [3, 4, 5] and k=2 with axis_parsed=1, both of the outputs will be shape [3, 2, 5] TensorShape output_shape = input_shape; output_shape[onnxruntime::narrow<size_t>(axis_parsed)] = k; output_values = Tensor(input->DataType(), output_shape, allocator); output_indices = Tensor(DataTypeImpl::GetType<int64_t>(), output_shape, allocator); // no-op - no output buffers to fill - return silently if (k == 0) { return Status::OK(); } if (largest) { FindTopKElements<GreaterValueCmp<T>>(input, input_shape, &output_values, &output_indices, output_shape, k, sorted, gsl::narrow_cast<unsigned>(axis_parsed), threadpool); } else { FindTopKElements<LesserValueCmp<T>>(input, input_shape, &output_values, &output_indices, output_shape, k, sorted, gsl::narrow_cast<unsigned>(axis_parsed), threadpool); } return Status::OK(); } // explicit instantiation template Status GetTopK<float>(const Tensor* input, const int axis, const unsigned k, bool largest, bool sorted, AllocatorPtr allocator, onnxruntime::concurrency::ThreadPool* threadpool, Tensor& output_values, Tensor& output_indices); // Opset ver - 1 to 9 static void TopkOpset9ConstructorCommon(const OpKernelInfo& op_kernel_info, int& axis, unsigned int& k) { int64_t k_temp; ORT_ENFORCE(op_kernel_info.GetAttr<int64_t>("k", &k_temp).IsOK()); ORT_ENFORCE(k_temp > 0); k = gsl::narrow_cast<unsigned>(k_temp); int64_t axis_temp; ORT_ENFORCE(op_kernel_info.GetAttr<int64_t>("axis", &axis_temp).IsOK()); axis = gsl::narrow_cast<int>(axis_temp); } template <typename T> static Status ComputeImplOpset9(OpKernelContext* p_op_kernel_context, int axis, int k) { const auto* X = p_op_kernel_context->Input<Tensor>(0); if (X == nullptr) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "input count mismatch, expected 1 input - the tensor to be processed"); } return TopKImpl<T>(p_op_kernel_context, X, axis, k); } template <> TopK<9, float>::TopK(const OpKernelInfo& op_kernel_info) : OpKernel(op_kernel_info) { TopkOpset9ConstructorCommon(op_kernel_info, axis_, k_); } template <> TopK<9, double>::TopK(const OpKernelInfo& op_kernel_info) : OpKernel(op_kernel_info) { TopkOpset9ConstructorCommon(op_kernel_info, axis_, k_); } template <> Status TopK<9, float>::Compute(OpKernelContext* p_op_kernel_context) const { return ComputeImplOpset9<float>(p_op_kernel_context, axis_, k_); } template <> Status TopK<9, double>::Compute(OpKernelContext* p_op_kernel_context) const { return ComputeImplOpset9<double>(p_op_kernel_context, axis_, k_); } // Opset ver - 10 static void TopkOpset10ConstructorCommon(const OpKernelInfo& op_kernel_info, int& axis) { int64_t axis_temp; ORT_ENFORCE(op_kernel_info.GetAttr<int64_t>("axis", &axis_temp).IsOK()); axis = gsl::narrow_cast<int>(axis_temp); } template <typename T> static Status ComputeImplOpset1011(OpKernelContext* p_op_kernel_context, int axis, bool is_largest, bool is_sorted) { const auto* X = p_op_kernel_context->Input<Tensor>(0); const auto* Y = p_op_kernel_context->Input<Tensor>(1); if (X == nullptr || Y == nullptr) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "input count mismatch, expected 2 inputs - " "the tensor to be processed and a tensor containing k value"); } auto y_shape = Y->Shape().GetDims(); if (y_shape.size() != 1 || y_shape[0] != 1) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "k tensor should be a 1D tensor of size 1"); } auto parsed_input_k = Y->Data<int64_t>()[0]; if (parsed_input_k < 0) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "value of k must not be negative"); } return TopKImpl<T>(p_op_kernel_context, X, axis, gsl::narrow_cast<unsigned>(parsed_input_k), is_largest, is_sorted); } template <> TopK<10, float>::TopK(const OpKernelInfo& op_kernel_info) : OpKernel(op_kernel_info) { TopkOpset10ConstructorCommon(op_kernel_info, axis_); } template <> TopK<10, double>::TopK(const OpKernelInfo& op_kernel_info) : OpKernel(op_kernel_info) { TopkOpset10ConstructorCommon(op_kernel_info, axis_); } template <> Status TopK<10, float>::Compute(OpKernelContext* p_op_kernel_context) const { return ComputeImplOpset1011<float>(p_op_kernel_context, axis_, true, true); } template <> Status TopK<10, double>::Compute(OpKernelContext* p_op_kernel_context) const { return ComputeImplOpset1011<double>(p_op_kernel_context, axis_, true, true); } // Opset ver - 11 static void TopkOpset11ConstructorCommon(const OpKernelInfo& op_kernel_info, int& axis, bool& largest, bool& sorted) { int64_t axis_temp; ORT_ENFORCE(op_kernel_info.GetAttr<int64_t>("axis", &axis_temp).IsOK()); axis = gsl::narrow_cast<int>(axis_temp); int64_t largest_temp; ORT_ENFORCE(op_kernel_info.GetAttr<int64_t>("largest", &largest_temp).IsOK()); largest = largest_temp == 1 ? true : false; int64_t sorted_temp; ORT_ENFORCE(op_kernel_info.GetAttr<int64_t>("sorted", &sorted_temp).IsOK()); sorted = sorted_temp == 1 ? true : false; } template <> TopK<11, float>::TopK(const OpKernelInfo& op_kernel_info) : OpKernel(op_kernel_info) { TopkOpset11ConstructorCommon(op_kernel_info, axis_, largest_, sorted_); } template <> TopK<11, double>::TopK(const OpKernelInfo& op_kernel_info) : OpKernel(op_kernel_info) { TopkOpset11ConstructorCommon(op_kernel_info, axis_, largest_, sorted_); } template <> TopK<11, int32_t>::TopK(const OpKernelInfo& op_kernel_info) : OpKernel(op_kernel_info) { TopkOpset11ConstructorCommon(op_kernel_info, axis_, largest_, sorted_); } template <> TopK<11, int64_t>::TopK(const OpKernelInfo& op_kernel_info) : OpKernel(op_kernel_info) { TopkOpset11ConstructorCommon(op_kernel_info, axis_, largest_, sorted_); } // Opset ver - 11 template <> Status TopK<11, float>::Compute(OpKernelContext* p_op_kernel_context) const { return ComputeImplOpset1011<float>(p_op_kernel_context, axis_, largest_, sorted_); } template <> Status TopK<11, double>::Compute(OpKernelContext* p_op_kernel_context) const { return ComputeImplOpset1011<double>(p_op_kernel_context, axis_, largest_, sorted_); } template <> Status TopK<11, int32_t>::Compute(OpKernelContext* p_op_kernel_context) const { return ComputeImplOpset1011<int32_t>(p_op_kernel_context, axis_, largest_, sorted_); } template <> Status TopK<11, int64_t>::Compute(OpKernelContext* p_op_kernel_context) const { return ComputeImplOpset1011<int64_t>(p_op_kernel_context, axis_, largest_, sorted_); } // Register necessary kernels // spec https://github.com/onnx/onnx/blob/main/docs/Operators.md#TopK #define REGISTER_TOPK_VERSIONED_TYPED_KERNEL(OPSET1, OPSET2, TYPE) \ ONNX_CPU_OPERATOR_VERSIONED_TYPED_KERNEL(TopK, OPSET1, OPSET2, TYPE, \ KernelDefBuilder() \ .TypeConstraint("T", DataTypeImpl::GetTensorType<TYPE>()) \ .TypeConstraint("I", DataTypeImpl::GetTensorType<int64_t>()), \ TopK<OPSET2, TYPE>); #define REGISTER_TOPK_TYPED_KERNEL(OPSET, TYPE) \ ONNX_CPU_OPERATOR_TYPED_KERNEL(TopK, \ OPSET, \ TYPE, \ KernelDefBuilder() \ .TypeConstraint("T", DataTypeImpl::GetTensorType<TYPE>()) \ .TypeConstraint("I", DataTypeImpl::GetTensorType<int64_t>()), \ TopK<OPSET, TYPE>); REGISTER_TOPK_VERSIONED_TYPED_KERNEL(1, 9, float); REGISTER_TOPK_VERSIONED_TYPED_KERNEL(1, 9, double); REGISTER_TOPK_VERSIONED_TYPED_KERNEL(10, 10, float); REGISTER_TOPK_VERSIONED_TYPED_KERNEL(10, 10, double); REGISTER_TOPK_TYPED_KERNEL(11, float); REGISTER_TOPK_TYPED_KERNEL(11, double); REGISTER_TOPK_TYPED_KERNEL(11, int64_t); REGISTER_TOPK_TYPED_KERNEL(11, int32_t); } // namespace onnxruntime
2953a26cdc5a02d83ecd07ce4460d5c534f76ace
dffe85dc3aa2ba6bc3f71ff37ed0b9258f95c56d
/WordCounts/WordCounts.cpp
a760d63562e6f18d3aa5cb36107f006e7c55655e
[]
no_license
assuntad23/COMP302
c3919e497437abdeca003f11c8afec07e773ee9c
97faceff2aea89739aa5144b8f1d27a7be33fd5f
refs/heads/master
2020-11-24T03:09:47.603964
2019-12-14T00:06:48
2019-12-14T00:06:48
227,940,543
0
0
null
null
null
null
UTF-8
C++
false
false
609
cpp
WordCounts.cpp
/* * WordCounts.cpp * * Created on: Nov 12, 2017 * Author: Assunta */ #include <map> #include <string> #include "IOFile.h" #include "EditingAndCounting.h" #include <fstream> int main(int argc, char **argv) { //creating instances of each class IOFile newFile; EditingAndCounting changingFile; //checks if a file exists and opens it for reading, // then counts the words in the file std::map<std::string, int> V = changingFile.countUniqueWords(newFile.OpeningForReading()); // Writes the word count to a new file newFile.OpeningAndWriting(V); return 0; }
3b7fb076f66aec54ec6471bf2bda33da2ca3ebfb
24624d31f20eb22aafbf8b2e7a6941438d4f511d
/TG/SHA-3/keccak_tests.cpp
8634ed693f19de87fa4403d88c68e9f47609a45d
[]
no_license
quenio/INE5429
360bb4754a86e1227af0010bf3c25e99f180cddc
bc4dc2306b796fffb256187a178b1391400bfb94
refs/heads/master
2021-03-30T17:32:51.731737
2016-07-10T22:59:15
2016-07-10T22:59:15
56,092,006
0
0
null
null
null
null
UTF-8
C++
false
false
1,244
cpp
keccak_tests.cpp
// Copyright (c) 2016 Quenio Cesar Machado dos Santos. All rights reserved. #include "min_unit.h" #include "keccak.h" #include "samples.h" const char * rnd_SA2() { using SA2 = StateArray<2>; using BS50 = BitString<50>; const char *s1 = "01100110011001100110011001100110011001100110011001"; const char *s2 = "01100101110111100111000111000011000000010000101100"; SA2 a { BS50 { s1 } }; SA2 b = rnd(a, 0); mu_assert(b.to_string() == s2); return NULL; } const char * rnd_SA64() { using SA64 = StateArray<64>; SA64 a { hex_to_bs<1600>(MSG5_XOR) }; SA64 b = rnd(a, 0); mu_assert(b.to_hex() == MSG5_IOTA0); SA64 c { hex_to_bs<1600>(MSG5_IOTA9) }; SA64 d = rnd(c, 10); mu_assert(d.to_hex() == MSG5_IOTA10); return NULL; } const char * keccak_f_SA64() { using BS1600 = BitString<1600>; BS1600 input = hex_to_bs<1600>(MSG5_XOR); BS1600 output = keccak_f(input); mu_assert(output.to_hex() == MSG5_IOTA23); return NULL; } const char * keccak_test() { stringstream message("12345"); keccak<32>(message, 16); return NULL; } void all_tests() { mu_test(rnd_SA2); mu_test(rnd_SA64); mu_test(keccak_f_SA64); mu_test(keccak_test); }
bea9352474c82daaf4f75b5416fe67c0286532db
089a304d34a65c8411ffcae8326bfe5efa7599e5
/lab1/Class_Truba.cpp
8f94119523ec79070a78f249a39542895d1dc0d4
[]
no_license
Kirill0077/lab1
fb796efb388ce4b58db5c591015f701232eb959a
510e7ce754e69d14d5b3fc99a4a776c272c6e80e
refs/heads/master
2023-02-22T13:10:09.411464
2021-01-18T09:55:57
2021-01-18T09:55:57
296,062,923
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
1,701
cpp
Class_Truba.cpp
#include "Class_Truba.h" #include "utils.h" using namespace std; int Class_Truba::MaxID = 0; Class_Truba::Class_Truba() { id = ++MaxID; Length = 0.0; Diameter = 0; repair = false; start = -1; finish = -1; wt = 0.0; } int Class_Truba::getid() const { return id; } int Class_Truba::getMaxID() { return MaxID; } bool Class_Truba::getrepair() const { return repair; } int Class_Truba::getwt() const { return wt; } int Class_Truba::getLength() const { return Length; } int Class_Truba::getDiameter() const { return Diameter; } void Class_Truba::setStart(int new_start) { start = new_start; } void Class_Truba::setFinish(int new_finish) { finish = new_finish; } int Class_Truba::getStart() const { return start; } int Class_Truba::getFinish() const { return finish; } void Class_Truba::ChangeStatus() { repair = !repair; } istream& operator >> (istream& in, Class_Truba& t) { t.Length = GetCorrectNumber( "Введите длину трубы ", 0.0, 1000.0); t.Diameter = GetCorrectNumber("Введите диаметр трубы ", 0, 2500); t.repair = false; return in; } ostream& operator << (ostream& out, const Class_Truba& t) { out << "\nИнтендификатор трубы: " << t.id << "\n" << "Длина трубы: " << t.Length << "\n" << "Диаметр трубы: " << t.Diameter << "\n" << "Статус трубы " << t.repair << endl; return out; } ifstream& operator>>(ifstream& fin, Class_Truba& t) { fin >> t.id >> t.Length >> t.Diameter >> t.repair; return fin; } ofstream& operator<<(ofstream& fout, const Class_Truba& t) { fout << t.id << endl << t.Length << endl<< t.Diameter << endl << t.repair << endl; return fout; }
81ff5bd226c05d66bcdb9a13e9cda082b1d5e5cd
17a8158b5f01f9a2389528a6a8987ea582f34255
/project_graph/network.h
ff379f51e6d7493c3b4d63755b6ac62ad0bac1b4
[]
no_license
HaoPai/my_algorithm
2d272e971912fcdb73bf1e78b878531ab1684008
75fedf03db6fdbb07590a857deee17ca3f71f7b6
refs/heads/master
2020-04-25T14:10:56.504341
2019-08-03T11:36:16
2019-08-03T11:36:16
172,832,735
1
0
null
null
null
null
UTF-8
C++
false
false
6,683
h
network.h
#ifndef _GRAGH_H_ #define _GRAGH_H_ #define N 100 #define COMMAND_N 20 #include <iostream> #include <string> #include "extended_queue.h" #include "linked_list.h" struct Edge_node{ int node_one; int node_two; int weight; Edge_node *link_one; Edge_node *link_two; Edge_node(); }; Edge_node :: Edge_node(){ node_one = node_two = weight = -1; link_one = link_two = NULL; } struct V_node{ string name; Edge_node *first_edge; V_node(); }; V_node :: V_node() { first_edge = NULL; } class Graph{ public: Graph(); void add_vertice(); void add_link(); void print(); int norder; string command[COMMAND_N]; void (Graph:: *method[COMMAND_N])(); void BFS(); void DFS(); private: int len; V_node vertices[N]; void print_vertices(); void recursive_dfs(int vertice,bool visited[]); void auxiliary_bfs(int vertice,bool visited[]); void make_order(int &i,int &j); int compare(int node, Edge_node *p,Edge_node *q); void link(int node,Edge_node *p,Edge_node *q); Edge_node * get_next(int node,Edge_node *p); int get_index(int node,Edge_node *p); }; Graph::Graph() { norder = 5; command[0] = "print"; command[1] = "add_vertice"; command[2] = "add_link"; command[3] = "DFS"; command[4] = "BFS"; method[0] = &Graph::print; method[1] = &Graph::add_vertice; method[2] = &Graph::add_link; method[3] = &Graph::DFS; method[4] = &Graph::BFS; len = 0; } void Graph::make_order(int &i, int &j) { if(i>j){ int temp = i; i = j; j = temp; } } int Graph::compare(int node,Edge_node *p,Edge_node *q){ int first,second; if(node == p->node_one){ first = p->node_two; }else{ first = p->node_one; } if(node == q->node_one){ second = q->node_two; }else{ second = q->node_one; } return first - second; } void Graph::link(int node,Edge_node *p,Edge_node *q) { if(node == p->node_one) p->link_one = q; else p->link_two = q; } Edge_node* Graph:: get_next(int node,Edge_node *p) { if(p->node_one == node) return p->link_one; else return p->link_two; } int Graph::get_index(int node,Edge_node *p) { if(node == p->node_one) return p->node_two; else return p->node_one; } void Graph::BFS() { bool *visited = new bool[len]; for(int i=0;i<len;i++) visited[i] = false; for(int i=0;i<len;i++) if(!visited[i]) auxiliary_bfs(i,visited); delete []visited; cout << endl; } void Graph::auxiliary_bfs(int index,bool visited[]) { Queue<int> q; q.append(index); while(!q.empty()){ int i; q.retrieve(i); q.serve(); if(!visited[i]){ cout << vertices[i].name << " "; visited[i] = true; } Edge_node *p = vertices[i].first_edge; while(p!=NULL){ int j = get_index(i,p); if(!visited[j]) q.append(j); p = get_next(i,p); } } } void Graph::DFS() { bool *visited = new bool[len]; for(int i=0;i<len;i++) visited[i] = false; for(int i=0;i<len;i++) if(!visited[i]) recursive_dfs(i,visited); delete []visited; cout << endl; } void Graph::recursive_dfs(int index,bool visited[]) { cout << vertices[index].name<<" "; visited[index] = true; Edge_node *p = vertices[index].first_edge; while(p!=NULL){ int j = get_index(index,p); if(!visited[j]) recursive_dfs(j,visited); p = get_next(index,p); } } void Graph::add_vertice() { cout << "input a vertice name: "; cin >> vertices[len++].name; } void Graph::print_vertices() { for(int i=0;i<len;i++) cout << i << " " << vertices[i].name<< endl; } void Graph:: add_link() { int i,j; cout << "input the indices of two vertices: "; cin >> i >> j; if(i==j){ cout << "wrong link, can not link to itself!" << endl; return; } Edge_node *new_edge = new Edge_node(); Edge_node *previous,*p; make_order(i,j); new_edge->node_one = i; new_edge->node_two = j; if(vertices[i].first_edge == NULL){ vertices[i].first_edge = new_edge; }else if(compare(i,new_edge,vertices[i].first_edge)<0){ link(i,new_edge,vertices[i].first_edge); vertices[i].first_edge = new_edge; }else if(compare(i,new_edge,vertices[i].first_edge)>0){ previous = vertices[i].first_edge; p = get_next(i,previous); while(p!=NULL&&compare(i,new_edge,p)>0){ previous = p; p = get_next(i,previous); } if(p!=NULL && compare(i,new_edge,p)==0) cout << "add_link error, you have added the link already!" <<endl; else{ link(i,new_edge,p); link(i,previous,new_edge); } }else cout << "add_link error, you have added the link already!" <<endl; if(vertices[j].first_edge == NULL){ vertices[j].first_edge = new_edge; }else if(compare(j,new_edge,vertices[j].first_edge)<0){ link(j,new_edge,vertices[j].first_edge); vertices[j].first_edge = new_edge; }else if(compare(j,new_edge,vertices[j].first_edge)>0){ previous = vertices[j].first_edge; p = get_next(j,previous); while(p!=NULL&&compare(j,new_edge,p)>0){ previous = p; p = get_next(j,previous); } if(p!=NULL && compare(j,new_edge,p)==0) cout << "add_link error, you have added the link already!" <<endl; else{ link(j,new_edge,p); link(j,previous,new_edge); } }else cout << "add_link error, you have added the link already!" <<endl; } void Graph::print() { print_vertices(); cout << endl; for(int i=0;i<len;i++){ //cout << vertices[i].name <<":"<<endl; Edge_node *p = vertices[i].first_edge; while(p!=NULL){ if(p->node_one == i) cout << vertices[p->node_one].name << "————" <<vertices[p->node_two].name << endl; p = get_next(i,p); } } // for(int i=0;i<len;i++){ // Cross_node *p = vertices[i].in; // while(p!=NULL){ // cout <<vertices[p->head].name << "<————" << vertices[p->tail].name << endl; // p = p-> t_link; // } // } } #endif
e2ab4e651bf2aec4d11f7f2f7b7d03e328cf11bd
f512c5399ebdee530c0afd353a3ba60e485005bc
/DataLink-20210102T112455Z-001/DataLink/DLFIT.CPP
3bc296362eb84e6ac9307bcdb922e289fc045039
[]
no_license
AlexShu88/DieboldEmbedded
4714d919c290a8e49d6dec79f970220d54ddd831
38430dd4c9553770c7dbb988f6de9cc52477cc29
refs/heads/master
2023-02-06T07:25:07.442766
2021-01-02T11:31:25
2021-01-02T11:31:25
326,168,748
0
0
null
null
null
null
UTF-8
C++
false
false
1,384
cpp
DLFIT.CPP
/****************************************************************************** * * * DLfit.cpp: Defines the variables access from fit.ini * * * ******************************************************************************/ #include <windows.h> #include "DataLinkPre.h" // Track3 Message DECLARE_SHARED_MEM_ARRAY( FitTrack3Message, 120, "" ) // Track2 Message DECLARE_SHARED_MEM_ARRAY( FitTrack2Message, 120, "" ) //Maximum withdraw amount limit for each time DECLARE_SHARED_MEM_ARRAY( FitMaxWthAmount, 7, "" ) //For ICBC_HQ Begin Add by lijun //Pin input length DECLARE_SHARED_MEM_ARRAY( FitCardPinLength, 2, "" ) //Pin max attempt. Used fro recover the pin retry times on Track3 DECLARE_SHARED_MEM_ARRAY( FitPinMaxAttempt, 2, "" ) //For ICBC_HQ End Add // Individual account identifier in Track2 or Track3 DECLARE_SHARED_MEM_ARRAY( FitAccNo, 25, "" ) // Individual account identifier in Track2 or Track3, for Receipt printing DECLARE_SHARED_MEM_ARRAY( FitPrrAccNo, 25, "" ) // handle dpkey for 0-abc saving card; 1-abc credit card; 2-other bank's saving card;3-other bank's credit card; 9-visa card DECLARE_SHARED_MEM_ARRAY( FitCardType, 5, "") #include "DataLinkPost.h"
300646049ecc5b9bb12e66d615e3638df9a445a5
3b135513722e6c9ce54e20cf90567b3215256686
/PingPongBuffer.cpp
e70206a69464bfe41042e01c14988371510aaf53
[]
no_license
frozenbanana/simpleComputeShader
de83b956cc7d5071ef23467eb35582896f816d07
e17b99b70d628d686fded374bbb26a684a552eff
refs/heads/master
2021-01-25T11:55:53.367565
2018-03-30T11:37:28
2018-03-30T11:37:28
123,443,214
0
0
null
null
null
null
UTF-8
C++
false
false
3,379
cpp
PingPongBuffer.cpp
#include "PingPongBuffer.hpp" #include "GLOBALS.hpp" //Private void PingPongBuffer::createBuffer(GLuint buffer_id) { //Bind2DTextureTo(buffer_id, COMPUTE_TEX); //glBindTexture(GL_TEXTURE_2D, buffer_id); glTexImage2D( GL_TEXTURE_2D, 0, //Mipmaps GL_RGBA, //Internal format //GL_RGB16F this->m_texture_width, this->m_texture_height, 0, //Frontier stuff GL_RGBA, //Format read //GL_RGB GL_UNSIGNED_BYTE, //Type of values in read format //GL_FLOAT NULL //source ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //When shrunk go blurry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //When enlarged go blurry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); //Set wrapping to clamp to edge glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //Set wrapping to clamp to edge //glBindTexture(GL_TEXTURE_2D, 0); } void PingPongBuffer::bindAndCompute(GLuint source_buffer, GLuint target_buffer) { glBindImageTexture( 0, //Always bind to slot 0 source_buffer, 0, GL_FALSE, 0, GL_READ_ONLY, //Only read from this texture GL_RGBA8 //GL_RGBA32F //GL_RGB16F ); glBindImageTexture( 1, //Always bind to slot 1 target_buffer, 0, GL_FALSE, 0, GL_WRITE_ONLY, //Only write to this texture GL_RGBA8 //GL_RGBA32F //GL_RGB16F ); glDispatchCompute(this->m_texture_width / 10, this->m_texture_height / 10, 1); glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); } //Public PingPongBuffer::PingPongBuffer(int texture_width, int texture_height) {//, GLint xy_uniform_id) { this->m_texture_width = texture_width; this->m_texture_height = texture_height; //this->m_xy_uniLoc = xy_uniform_id; glGenTextures(2, this->m_buffers); glBindTexture(GL_TEXTURE_2D, this->m_buffers[0]); this->createBuffer(this->m_buffers[0]); glBindTexture(GL_TEXTURE_2D, this->m_buffers[1]); this->createBuffer(this->m_buffers[1]); } PingPongBuffer::~PingPongBuffer() { } void PingPongBuffer::DoPingPong(int n_passes, GLuint src_buffer) { int n = n_passes * 2; //Each iteration of the blur includes both x and y axis //Also ensures that pingpongBuffer[0] is always written to last int x = 1; int y = 0; //Do a first pass if there are supposed to be passes at all if(n_passes > 0){ //glUniform2i(this->m_xy_uniLoc, y, x); //Update uniform vector this->bindAndCompute(src_buffer, this->m_buffers[1]); } for (int i = 1; i < n; i++) { //Loop starts at 1 as the first pass has been done //glUniform2i(this->m_xy_uniLoc, x, y); //Update uniform vector this->bindAndCompute(this->m_buffers[x], this->m_buffers[y]); //Send in alternating buffers //Swap so x = 0 or 1 //and y = 1 or 0 x = !x; y = !y; } } void PingPongBuffer::BindResult() { Bind2DTextureTo(this->m_buffers[0], COMP_TEX); //glBindImageTexture( // COMP_TEX, //Slot 1 // this->m_buffers[0], // 0, // GL_FALSE, // 0, // GL_READ_WRITE, //Only read from this texture // GL_RGBA8 //GL_RGB16F //); }
7de85f689df638ae15a3a2c90e6eaea27d9f97af
c3753013b2cca01be0e4d099258316a54fb753b7
/src/surqueue.cpp
dea49c3d2a159839832aa25e1e989f2062c5bfd6
[]
no_license
gamedolphin/Sur
18d713205f64b183d2678ba6c06efcc7659e0b2e
ef67808fd0dd9a025a2e248c744eca893a977d14
refs/heads/master
2021-01-10T11:13:23.335996
2015-11-17T19:57:49
2015-11-17T19:57:49
46,120,060
1
0
null
null
null
null
UTF-8
C++
false
false
1,047
cpp
surqueue.cpp
#include "surqueue.h" int num = 0; void Sur::thread_ChangeQueue(Sur::Queue *q, AVPacket *packet, Sur::queue_modify state) { std::lock_guard<std::mutex> guard(q->lockQueue); switch(state) { case Sur::INSERT: q->packetList.push_back(packet); break; case Sur::REMOVE: if(q->packetList.empty()) { break; } packet = q->packetList.front(); q->packetList.pop_front(); break; case Sur::DELETEALL: if(q->packetList.empty()) { break; } for (auto s: q->packetList) { if(!s) continue; av_free_packet(s); } q->packetList.clear(); break; default: return; } } void Sur::InsertIntoSurQueue(Sur::Queue* q, AVPacket* p) { std::thread t(Sur::thread_ChangeQueue, q, p, Sur::INSERT); t.join(); } void Sur::RetrieveFromSurQueue(Sur::Queue *q, AVPacket *p) { std::thread t(Sur::thread_ChangeQueue, q, p, Sur::REMOVE); t.join(); } void Sur::EndQueue(Sur::Queue *q) { AVPacket *p; std::thread t(Sur::thread_ChangeQueue, q, p, Sur::DELETEALL); t.join(); }
9e9d571cc10824d8b8e09544bb282da5df481f15
eb7f2f5953dfd0d066ed6727df3a554b705ce8cc
/sw/src/uquad/control/blocks/pe/ekf2/RingBuffer.h
8387a97c952011b7761baa810b7431eb5b5e97e7
[]
no_license
zangel/uquad
3de785a04ad9bd6e5a146caf1eefa186ba58efd4
7a314f1a2f2a0db549251c48aba991c5cce4d585
refs/heads/master
2021-01-21T12:58:12.805486
2016-06-02T22:21:35
2016-06-02T22:21:35
51,906,573
0
0
null
null
null
null
UTF-8
C++
false
false
2,092
h
RingBuffer.h
#ifndef UQUAD_CONTROL_EKF2_RING_BUFFER_H #define UQUAD_CONTROL_EKF2_RING_BUFFER_H #include "../Config.h" #include "../../base/Time.h" namespace uquad { namespace control { namespace ekf2 { template <typename T, int N> class RingBuffer { public: RingBuffer() : m_Head(N - 1) , m_Size(0) { } ~RingBuffer() { } inline void push(T const &v) { std::size_t const pos = (m_Head + 1) % N; m_Buffer[pos] = v; m_Head = pos; m_Size = std::min<std::size_t>(m_Size + 1, N); } inline bool empty() const { return m_Size == 0; } inline bool full() const { return m_Size == N; } inline std::size_t size() const { return m_Size; } inline T& oldest() { return m_Buffer[(m_Head + N + 1 - m_Size) % N]; } inline T const& oldest() const { return m_Buffer[(m_Head + N + 1 - m_Size) % N]; } inline T& newest() { return m_Buffer[m_Head]; } inline T const& newest() const { return m_Buffer[m_Head]; } inline bool popOlderThan(uint64_t t, T &v) { for(std::size_t i = 0; i < m_Size; ++i) { std::size_t const pos = (m_Head + N - i) % N; if(t >= m_Buffer[pos].time_us && t - m_Buffer[pos].time_us < 100000) { v = m_Buffer[pos]; m_Size = i; return true; } } return false; } private: std::size_t m_Head; std::size_t m_Size; T m_Buffer[N]; }; } //namespace ekf2 } //namespace control } //namespace uquad #endif //UQUAD_CONTROL_EKF2_RING_BUFFER_H
814103a98900ce4a8c116ac75d86f0530f72c78f
ea401c3e792a50364fe11f7cea0f35f99e8f4bde
/hackathon/itk_vaa3d_plugins/examples/Segmentation/DeformableModel2.cxx
b59b6e5712fd8ef2fb323f0189b47192ecd82d6d
[ "MIT" ]
permissive
Vaa3D/vaa3d_tools
edb696aa3b9b59acaf83d6d27c6ae0a14bf75fe9
e6974d5223ae70474efaa85e1253f5df1814fae8
refs/heads/master
2023-08-03T06:12:01.013752
2023-08-02T07:26:01
2023-08-02T07:26:01
50,527,925
107
86
MIT
2023-05-22T23:43:48
2016-01-27T18:19:17
C++
UTF-8
C++
false
false
5,664
cxx
DeformableModel2.cxx
/*========================================================================= * * Copyright Insight Software Consortium * * 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.txt * * 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. * *=========================================================================*/ // Software Guide : BeginLatex // // This example illustrates the use of the \doxygen{DeformableMesh3DFilter}. // An initial mesh is created using the \doxygen{SphereMeshSource} filter. // // \index{Deformable Models} // \index{DeformableMesh3DFilter} // \index{SphereMeshSource} // // Software Guide : EndLatex // Software Guide : BeginCodeSnippet #include "itkDeformableMesh3DFilter.h" #include "itkGradientRecursiveGaussianImageFilter.h" #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h" #include "itkSphereMeshSource.h" #include "itkImageFileReader.h" int main(int argc, char * argv [] ) { if( argc < 7 ) { std::cerr << "Usage: DeformableModel2 inputImage sigma " << std::endl; std::cerr << " numberOfIterations timeStep externalFoceScale stiffness" << std::endl; return 1; } const char *inputFileName = argv[1]; const float sigma = atof( argv[2] ); // Suggested value = 5 * pixel spacing const int numberOfIterations = atoi( argv[3] ); // Suggested value = 100 const float timeStep = atof( argv[4] ); // Suggested value = 0.1 const float externalForceScale = atof( argv[5] ); // Suggested value = 10 (linked to stiffness) const float stiffness = atof( argv[6] ); // Suggested value = 0.1 (linked to force scale) typedef double MeshPixelType; typedef itk::Mesh< MeshPixelType > MeshType; unsigned const int Dimension = 3; typedef float PixelType; typedef itk::Image<PixelType, Dimension> ImageType; typedef itk::GradientRecursiveGaussianImageFilter< ImageType > GradientFilterType; typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< ImageType,ImageType> GradientMagnitudeFilterType; typedef itk::DeformableMesh3DFilter<MeshType,MeshType> DeformableFilterType; typedef itk::ImageFileReader< ImageType > ReaderType; ReaderType::Pointer imageReader = ReaderType::New(); imageReader->SetFileName( inputFileName ); GradientMagnitudeFilterType::Pointer gradientMagnitudeFilter = GradientMagnitudeFilterType::New(); try { imageReader->Update(); } catch( itk::ExceptionObject & excep ) { std::cerr << "Problem found while reading file " << inputFileName << std::endl; std::cerr << "Exception Caught !" << std::endl; std::cerr << excep << std::endl; } ImageType::ConstPointer inputImage = imageReader->GetOutput(); gradientMagnitudeFilter->SetInput( inputImage ); gradientMagnitudeFilter->SetSigma( sigma ); GradientFilterType::Pointer gradientMapFilter = GradientFilterType::New(); gradientMapFilter->SetInput( gradientMagnitudeFilter->GetOutput()); gradientMapFilter->SetSigma( sigma ); gradientMapFilter->Update(); DeformableFilterType::Pointer deformableModelFilter = DeformableFilterType::New(); typedef itk::SphereMeshSource< MeshType > MeshSourceType; MeshSourceType::Pointer meshSource = MeshSourceType::New(); // Set the initial sphere in the center of the image // const ImageType::SpacingType spacing = inputImage->GetSpacing(); ImageType::PointType origin = inputImage->GetOrigin(); ImageType::SizeType size = inputImage->GetBufferedRegion().GetSize(); MeshType::PointType center; center[0] = origin[0] + spacing[0] * size[0] / 2.0; center[1] = origin[1] + spacing[1] * size[1] / 2.0; center[2] = origin[2] + spacing[2] * size[2] / 2.0; meshSource->SetCenter( center ); MeshType::PointType radius; radius[0] = spacing[0] * size[0] / 4.0; radius[1] = spacing[1] * size[1] / 4.0; radius[2] = spacing[2] * size[2] / 4.0; meshSource->SetScale( radius ); meshSource->SetResolutionX( 50 ); meshSource->SetResolutionY( 50 ); meshSource->Update(); deformableModelFilter->SetInput( meshSource->GetOutput() ); deformableModelFilter->SetGradient( gradientMapFilter->GetOutput() ); typedef itk::CovariantVector<double, 2> StiffnessType; StiffnessType stiffnessVector; stiffnessVector[0] = stiffness; stiffnessVector[1] = stiffness; deformableModelFilter->SetTimeStep( timeStep ); deformableModelFilter->SetStiffness( stiffnessVector ); deformableModelFilter->SetStepThreshold( numberOfIterations ); deformableModelFilter->SetGradientMagnitude( externalForceScale ); try { deformableModelFilter->Update(); } catch( itk::ExceptionObject & excep ) { std::cerr << "Exception Caught !" << std::endl; std::cerr << excep << std::endl; } return 0; } // Software Guide : EndCodeSnippet
0951da6a418456a39af556c7ee609616c8a1991c
e6979549bf0f2af86b5bdd52a1e25853f2506e8a
/1085/Main.cpp
2ad10b9572f3ae5b1955897bc723086f7cf2c2df
[]
no_license
guithin/BOJ
9a3becbbae58c03130c1545cdb0985efd2563f63
d525f441e864fc07a21649d39273f0ac1e3158ac
refs/heads/master
2021-07-05T19:25:18.547317
2020-08-03T01:47:34
2020-08-03T01:47:34
144,382,439
1
0
null
null
null
null
UTF-8
C++
false
false
166
cpp
Main.cpp
#include<bits/stdc++.h> using namespace std; int main(){ int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); printf("%d\n", min({a, b, c-a, d-b})); return 0; }
102d85d2ecb34a4baf67500d2e4363485459e091
91ab2d7a747ceb93a0345af6de1b1a4a1075d095
/Assignment 2 CK/Student.h
eb6127f092c6f8c4e4b5ff340a9863b74b0d5bbd
[]
no_license
kimballc/Assignment-4-CK
3355fa2eb99a0a70596f0d6723af7ffe3a9bd3d3
3589cde4f598d3ef40134f553d9b86df3d0ea8d4
refs/heads/master
2021-07-25T20:41:28.798556
2017-11-07T23:21:33
2017-11-07T23:21:33
109,900,303
0
0
null
null
null
null
UTF-8
C++
false
false
714
h
Student.h
#ifndef STUDENT_H #define STUDENT_H #include <string> using std::string; class Student { public: //Default Constructor Student(); //Initializer Constructor Student(int, const string &, int, const string &, const string &); ~Student(); //Getters string getName() { return name; } int getYear() { return year; } string getMajor() { return major; } string getCourse() { return course; } int getId() { return id; } //Setters void setName(const string &); void setYear(int); void setMajor(const string &); void setCourse(const string &); void setId(int); //return formatted string string display(); private: int id; string name; int year; string major; string course; }; #endif // !STUDENT_H
ea6074573bfed3bf28dc04206a4c2f3ad6b53e31
6ce049ad0073d7d5e14efde081c94d9432a15d35
/Gi/codeforces/546A.cpp
6bb08cdc6576730135d531a3039cd7bfa697b557
[]
no_license
yancouto/maratona-sua-mae
0f1377c2902375dc3157e6895624e198f52151e0
75f5788f981b3baeb6488bbf3483062fa355c394
refs/heads/master
2020-05-31T03:26:21.233601
2016-08-19T03:28:22
2016-08-19T03:28:37
38,175,020
6
2
null
null
null
null
UTF-8
C++
false
false
443
cpp
546A.cpp
#include <cstdio> #include <cstring> #include <cmath> #include <vector> #include <iostream> #include <map> #include <string> #include <algorithm> #include <climits> #include <queue> using namespace std; int main () { long long n, k, m; scanf("%lld %lld %lld", &k, &m, &n); long long cost = (1 + n)*n/2; m-= k*cost; if (m >= 0) printf("0\n"); else printf("%lld\n", -m); return 0; } //http://codeforces.com/contest/546/problem/A
102e20a940876e08ee5f61694edc692d8977d220
52650478ba94d5d693953eefa896b56fc3b62523
/squirrel_tracer/Squirrel tracer.h
c16116c5dfc5c5d8f540636501f0a86921f6e5e0
[]
no_license
brliron/Thcrap-patches
418e591202ef6e80f06aadedc6178523288279be
d7177a0b7d0e83ef025dd409759463529a49f031
refs/heads/master
2021-04-28T10:42:06.422832
2018-04-20T14:30:44
2018-04-23T06:55:26
122,072,203
0
0
null
null
null
null
UTF-8
C++
false
false
2,615
h
Squirrel tracer.h
/** * Touhou Community Reliant Automatic Patcher * Squirrel tracing plugin * * ---- * * Main include file. */ #pragma once #include <thcrap.h> #include <stdio.h> #ifdef Yield # undef Yield #endif #include <new> #define private public #include "squirrel\include\squirrel.h" #include "squirrel\squirrel\sqvm.h" #include "squirrel\squirrel\sqstate.h" #include "squirrel\squirrel\sqobject.h" #include "squirrel\squirrel\sqarray.h" #include "squirrel\squirrel\sqtable.h" #include "squirrel\squirrel\sqclass.h" #include "squirrel\squirrel\sqfuncproto.h" #include "squirrel\squirrel\sqclosure.h" #include "squirrel\squirrel\sqstring.h" #include "squirrel\squirrel\squserdata.h" #undef private #ifdef __cplusplus #include <map> #include <stack> class ObjectDump { private: HANDLE hMap; void *pointer; size_t size; json_t *json; size_t json_dump_size; void map(); void release(); public: ObjectDump(); ObjectDump(const ObjectDump& other); ObjectDump(const void *pointer, size_t size, json_t *json); ~ObjectDump(); ObjectDump& operator=(const ObjectDump& other); operator bool(); void set(const void *pointer, size_t size, json_t *json); bool equal(const void *mem_dump, size_t size); bool equal(const json_t *json); void writeToFile(FILE *file); void unmap(); }; class ObjectDumpCollection { private: std::map<void*, ObjectDump> map; std::stack<ObjectDump*> mappedObjects; public: ObjectDumpCollection(); ~ObjectDumpCollection(); ObjectDump& operator[](void* key); void unmapAll(); }; class ClosureDB : public std::map<SQClosure*, std::string> { private: SQClosure * lastClosure; // Closure for the last instruction. std::string lastClosureFn; // File name for the last instruction. Used for caching. public: std::string lastFileName; // File name of the last nut file loaded. ClosureDB(); ~ClosureDB(); const std::string& get(SQClosure *closure); }; enum ArgType; class SquirrelTracer { private: CRITICAL_SECTION cs; FILE *file; ObjectDumpCollection objs_list; bool enabled; SQVM *vm; std::string fn; json_t *arg_to_json(ArgType type, uint32_t arg); json_t *add_obj(SQObject *o); template<typename T> json_t *add_refcounted(T *o); template<typename T> json_t *obj_to_json(T *o); public: ClosureDB closureDB; SquirrelTracer(); ~SquirrelTracer(); void enter(SQVM *vm); void leave(); void add_instruction(SQInstruction *_i_); json_t *add_STK(int i) { return add_obj(&this->vm->_stack._vals[this->vm->_stackbase + i]); } }; #endif #ifdef __cplusplus extern "C" { #endif int __stdcall thcrap_plugin_init(); #ifdef __cplusplus } #endif
230eb70221c6e58a4e0ba8470ee4f87f21e6839c
3f7028cc89a79582266a19acbde0d6b066a568de
/source/extensions/filters/http/on_demand/on_demand_update.cc
2325f81d47f3d5eb9da685227704b8fd4bd5dc4a
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
envoyproxy/envoy
882d3c7f316bf755889fb628bee514bb2f6f66f0
72f129d273fa32f49581db3abbaf4b62e3e3703c
refs/heads/main
2023-08-31T09:20:01.278000
2023-08-31T08:58:36
2023-08-31T08:58:36
65,214,191
21,404
4,756
Apache-2.0
2023-09-14T21:56:37
2016-08-08T15:07:24
C++
UTF-8
C++
false
false
9,305
cc
on_demand_update.cc
#include "source/extensions/filters/http/on_demand/on_demand_update.h" #include "source/common/common/assert.h" #include "source/common/common/enum_to_int.h" #include "source/common/common/logger.h" #include "source/common/config/xds_resource.h" #include "source/common/http/codes.h" #include "source/common/http/utility.h" #include "source/extensions/filters/http/well_known_names.h" namespace Envoy { namespace Extensions { namespace HttpFilters { namespace OnDemand { namespace { class RdsDecodeHeadersBehavior : public DecodeHeadersBehavior { public: void decodeHeaders(OnDemandRouteUpdate& filter) override { filter.handleMissingRoute(); } }; class RdsCdsDecodeHeadersBehavior : public DecodeHeadersBehavior { public: RdsCdsDecodeHeadersBehavior(Upstream::OdCdsApiHandlePtr odcds, std::chrono::milliseconds timeout) : odcds_(std::move(odcds)), timeout_(timeout) {} void decodeHeaders(OnDemandRouteUpdate& filter) override { auto route = filter.handleMissingRoute(); if (!route.has_value()) { return; } filter.handleOnDemandCds(route.value(), *odcds_, timeout_); } private: Upstream::OdCdsApiHandlePtr odcds_; std::chrono::milliseconds timeout_; }; } // namespace DecodeHeadersBehaviorPtr DecodeHeadersBehavior::rds() { return std::make_unique<RdsDecodeHeadersBehavior>(); } DecodeHeadersBehaviorPtr DecodeHeadersBehavior::cdsRds(Upstream::OdCdsApiHandlePtr odcds, std::chrono::milliseconds timeout) { return std::make_unique<RdsCdsDecodeHeadersBehavior>(std::move(odcds), timeout); } namespace { DecodeHeadersBehaviorPtr createDecodeHeadersBehavior( OptRef<const envoy::extensions::filters::http::on_demand::v3::OnDemandCds> odcds_config, Upstream::ClusterManager& cm, ProtobufMessage::ValidationVisitor& validation_visitor) { if (!odcds_config.has_value()) { return DecodeHeadersBehavior::rds(); } Upstream::OdCdsApiHandlePtr odcds; if (odcds_config->resources_locator().empty()) { odcds = cm.allocateOdCdsApi(odcds_config->source(), absl::nullopt, validation_visitor); } else { auto locator = Config::XdsResourceIdentifier::decodeUrl(odcds_config->resources_locator()); odcds = cm.allocateOdCdsApi(odcds_config->source(), locator, validation_visitor); } // If changing the default timeout, please update the documentation in on_demand.proto too. auto timeout = std::chrono::milliseconds(PROTOBUF_GET_MS_OR_DEFAULT(odcds_config.ref(), timeout, 5000)); return DecodeHeadersBehavior::cdsRds(std::move(odcds), timeout); } template <typename ProtoConfig> OptRef<const envoy::extensions::filters::http::on_demand::v3::OnDemandCds> getOdCdsConfig(const ProtoConfig& proto_config) { if (!proto_config.has_odcds()) { return absl::nullopt; } return proto_config.odcds(); } } // namespace OnDemandFilterConfig::OnDemandFilterConfig(DecodeHeadersBehaviorPtr behavior) : behavior_(std::move(behavior)) {} OnDemandFilterConfig::OnDemandFilterConfig( const envoy::extensions::filters::http::on_demand::v3::OnDemand& proto_config, Upstream::ClusterManager& cm, ProtobufMessage::ValidationVisitor& validation_visitor) : OnDemandFilterConfig( createDecodeHeadersBehavior(getOdCdsConfig(proto_config), cm, validation_visitor)) {} OnDemandFilterConfig::OnDemandFilterConfig( const envoy::extensions::filters::http::on_demand::v3::PerRouteConfig& proto_config, Upstream::ClusterManager& cm, ProtobufMessage::ValidationVisitor& validation_visitor) : OnDemandFilterConfig( createDecodeHeadersBehavior(getOdCdsConfig(proto_config), cm, validation_visitor)) {} OnDemandRouteUpdate::OnDemandRouteUpdate(OnDemandFilterConfigSharedPtr config) : config_(std::move(config)) { if (config_ == nullptr) { // if config is nil, fall back to rds only config_ = std::make_shared<OnDemandFilterConfig>(DecodeHeadersBehavior::rds()); } } OptRef<const Router::Route> OnDemandRouteUpdate::handleMissingRoute() { if (auto route = callbacks_->route(); route != nullptr) { filter_iteration_state_ = Http::FilterHeadersStatus::Continue; return *route; } // decodeHeaders() is interrupted. decode_headers_active_ = true; route_config_updated_callback_ = std::make_shared<Http::RouteConfigUpdatedCallback>(Http::RouteConfigUpdatedCallback( [this](bool route_exists) -> void { onRouteConfigUpdateCompletion(route_exists); })); filter_iteration_state_ = Http::FilterHeadersStatus::StopIteration; callbacks_->downstreamCallbacks()->requestRouteConfigUpdate(route_config_updated_callback_); // decodeHeaders() is completed. decode_headers_active_ = false; return makeOptRefFromPtr(callbacks_->route().get()); } Http::FilterHeadersStatus OnDemandRouteUpdate::decodeHeaders(Http::RequestHeaderMap&, bool) { auto config = getConfig(); config->decodeHeadersBehavior().decodeHeaders(*this); return filter_iteration_state_; } // Passed route pointer here is not null. void OnDemandRouteUpdate::handleOnDemandCds(const Router::Route& route, Upstream::OdCdsApiHandle& odcds, std::chrono::milliseconds timeout) { if (callbacks_->clusterInfo() != nullptr) { // Cluster already exists, so nothing to do here. filter_iteration_state_ = Http::FilterHeadersStatus::Continue; return; } const auto entry = route.routeEntry(); if (entry == nullptr) { // No entry? Nothing we can do here. filter_iteration_state_ = Http::FilterHeadersStatus::Continue; return; } const auto cluster_name = entry->clusterName(); if (cluster_name.empty()) { // Empty cluster name may be a result of a missing HTTP header // used for getting the cluster name. Nothing we can do here. filter_iteration_state_ = Http::FilterHeadersStatus::Continue; return; } filter_iteration_state_ = Http::FilterHeadersStatus::StopIteration; auto callback = std::make_unique<Upstream::ClusterDiscoveryCallback>( [this](Upstream::ClusterDiscoveryStatus cluster_status) { onClusterDiscoveryCompletion(cluster_status); }); cluster_discovery_handle_ = odcds.requestOnDemandClusterDiscovery(cluster_name, std::move(callback), timeout); } const OnDemandFilterConfig* OnDemandRouteUpdate::getConfig() { auto config = Http::Utility::resolveMostSpecificPerFilterConfig<OnDemandFilterConfig>(callbacks_); if (config != nullptr) { return config; } return config_.get(); } Http::FilterDataStatus OnDemandRouteUpdate::decodeData(Buffer::Instance&, bool) { return filter_iteration_state_ == Http::FilterHeadersStatus::StopIteration ? Http::FilterDataStatus::StopIterationAndWatermark : Http::FilterDataStatus::Continue; } Http::FilterTrailersStatus OnDemandRouteUpdate::decodeTrailers(Http::RequestTrailerMap&) { return Http::FilterTrailersStatus::Continue; } void OnDemandRouteUpdate::setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks& callbacks) { callbacks_ = &callbacks; } // A weak_ptr copy of the route_config_updated_callback_ is kept by RdsRouteConfigProviderImpl in // config_update_callbacks_. Same about cluster_discovery_callback kept by ClusterDiscoveryManager // in pending_clusters_. By resetting the pointers in onDestroy() callback we ensure that this // filter/filter-chain will not be resumed if the corresponding has been closed. void OnDemandRouteUpdate::onDestroy() { route_config_updated_callback_.reset(); cluster_discovery_handle_.reset(); } // This is the callback which is called when an update requested in requestRouteConfigUpdate() // has been propagated to workers, at which point the request processing is restarted from the // beginning. void OnDemandRouteUpdate::onRouteConfigUpdateCompletion(bool route_exists) { filter_iteration_state_ = Http::FilterHeadersStatus::Continue; // Don't call continueDecoding in the middle of decodeHeaders() if (decode_headers_active_) { return; } if (route_exists && // route can be resolved after an on-demand // VHDS update !callbacks_->decodingBuffer() && // Redirects with body not yet supported. callbacks_->recreateStream(/*headers=*/nullptr)) { return; } // route cannot be resolved after an on-demand VHDS update or // recreating stream failed, continue the filter-chain callbacks_->continueDecoding(); } void OnDemandRouteUpdate::onClusterDiscoveryCompletion( Upstream::ClusterDiscoveryStatus cluster_status) { filter_iteration_state_ = Http::FilterHeadersStatus::Continue; cluster_discovery_handle_.reset(); if (cluster_status == Upstream::ClusterDiscoveryStatus::Available && !callbacks_->decodingBuffer()) { // Redirects with body not yet supported. const Http::ResponseHeaderMap* headers = nullptr; if (callbacks_->recreateStream(headers)) { callbacks_->downstreamCallbacks()->clearRouteCache(); return; } } // Cluster still does not exist or we failed to recreate the // stream. Either way, continue with the filter-chain. callbacks_->continueDecoding(); } } // namespace OnDemand } // namespace HttpFilters } // namespace Extensions } // namespace Envoy
ee46be100c49250a2aa1886330d364ce32c7f8c6
9eb6dc0cf2553b29bba51ab8143081f6175c5c10
/Arduino/UDOOGrove01bis_irDistance/UDOOGrove01bis_irDistance.ino
866df0d3d2d59cebc4d2fedc1ae3b6696ee4b819
[]
no_license
gionji/UDOOGroveLamp
fc1f095a6c91b3699a8b7681c7684a4b78a9a644
fd57e78a613dda65f7c6d5c496653373cb8e1824
refs/heads/master
2021-03-12T21:18:12.764405
2017-06-28T16:54:28
2017-06-28T16:54:28
91,459,258
0
0
null
null
null
null
UTF-8
C++
false
false
1,063
ino
UDOOGrove01bis_irDistance.ino
#define IR_DISTANCE_PIN A0 #define DIST_IN_TH 100 #define CYCLES_TH 4 #define IR_CLOSEST_VALUE 775 #define IR_FAREST_VALUE 200 void setup() { Serial.begin(9600); Serial.println("UDOO Grove Happy Lamp! Step O1: IR distance sensor"); } int cyclesUnderTh = 0; int lightIntensity = 255; void loop() { Serial.print("Raw distance: "); Serial.println(analogRead(A0)); bool isIntensityChanged = controlDistance(IR_DISTANCE_PIN, &lightIntensity); if(isIntensityChanged){ Serial.print("New light intensity: "); Serial.println(lightIntensity); } delay(500); } // IR distance sensor methods int getIrDistanceInCm(int pin){ int a = analogRead(pin); return map(a, IR_CLOSEST_VALUE, IR_FAREST_VALUE, 10, 100); } int controlDistance(int pin, int* intensity){ int irDistance = getIrDistanceInCm(pin); int a = 0; if(irDistance < DIST_IN_TH) cyclesUnderTh++; else cyclesUnderTh = 0; if(cyclesUnderTh > CYCLES_TH){ *intensity = map(irDistance, 0, 100, 0 , 255); return 1; } return 0; }
7ee879333c7e159f8d11198f4621c545a5a42c51
6d427c7b04cb92cee6cc8d37df07cf8b129fdada
/100 - 999/495.cpp
252d20bd1120e548b058b7c2a165f23e831c53ac
[]
no_license
FForhad/Online-Judge-Ex.-Uva-Solutions
3c5851d72614274cafac644bcdbc9e065fd5d8d8
b7fdf62d274a80333dec260f5a420f9d6efdbdaf
refs/heads/master
2023-03-20T23:47:30.116053
2021-03-10T02:07:49
2021-03-10T02:07:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
963
cpp
495.cpp
#include<bits/stdc++.h> using namespace std; vector < string > fi; string s="1"; string s2="1"; void fibo(int n); int main() { fi.push_back("0"); fi.push_back(s); fi.push_back(s2); fibo(3); int t; while(scanf("%d",&t)==1)cout<<"The Fibonacci number for "<<t<<" is "<<fi[t]<<endl; return 0; } void fibo(int n) { if(n==5001)return; char st[1100]; reverse(s.begin(),s.end()); reverse(s2.begin(),s2.end()); int len1=s.size(); int len2=s2.size(); int rem=0,a=0,b=0,c=0,e=0,mx=max(len1,len2); for(int i=0; i<mx; i++) { if(i<len1)a=s[i]-'0'; else a=0; if(i<len2)b=s2[i]-'0'; else b=0; c=a+b+rem; rem=0; if(c>9){st[i]=c%10+'0';rem=c/10;} else st[i]=c+'0'; e++; } if(rem)st[e++]=rem+'0'; st[e]=0; s=s2; s2=st; reverse(s.begin(),s.end()); reverse(s2.begin(),s2.end()); fi.push_back(s2); fibo(n+1); }
c5cd0995cf5ec5bb823115a13da83a7a17555c4c
287f3f626f6df4a9ca7ce0b2525709287598d021
/lab3/MyData.h
16cd852b992aa462dad2a5b75b65d87660cfd333
[]
no_license
OlegFilatovS/Cpp_C20
709447bf3104c8bc8e14d08aacc52d4c1dad21e0
a00179662d1e26aa4e31f2aee5cba57642227d71
refs/heads/master
2021-01-19T23:57:47.457028
2017-04-23T20:12:43
2017-04-23T20:12:43
89,057,442
0
0
null
null
null
null
UTF-8
C++
false
false
557
h
MyData.h
#pragma once #include "MyString.h" #include <iostream> enum Sex { MALE, FMALE }; class MyData { Sex m_sex; size_t m_age; MyString m_job; float m_salary; public: MyData():m_sex(MALE), m_age(0), m_job("Homeless"), m_salary(0) {} MyData(Sex s, size_t age, const char* job, float sal):m_sex(s), m_age(age), m_job(job), m_salary(sal) {} friend std::ostream& operator<<(std::ostream& os, const MyData& d); //MyData(const MyData& d); //MyData & operator=(const MyData& d); // // //MyData(MyData&& d); //MyData & operator=(MyData&& d); };
42ab9d0cb3e536b7a2fb43fee86353d7134b0f89
078a91271cee72c9bdee5c15adcc995164d51cc4
/coinChangingMinimumCoin.CPP
f87ea71a1c5cf96ff0512c7bb826e0f83597e573
[]
no_license
PurushottamParakh/DynamicProgramming
854a33b28c0def7cdbee80e8179408dd501149e0
6fdb4f6758221e28571218b45b43ccf98c88daa1
refs/heads/master
2020-03-06T23:05:39.024907
2018-04-03T14:44:41
2018-04-03T14:44:41
127,123,305
0
0
null
null
null
null
UTF-8
C++
false
false
1,351
cpp
coinChangingMinimumCoin.CPP
// Example program // Example program #include <iostream> #include <string> #include <vector> #include <climits> using namespace std; int minimumCoinBottomUp(const vector<int> &coins, int total, vector<int> &R){ vector<int> T(total+1,INT_MAX-1); // INT_MAX - 1 is very important because of comparison T[i] > 1 + T[ i-coins[j] ], 1 + INT_MAX = INT_MIN T[0] = 0; //T[i] = number of coins required to get i //R[i] = last coin needed to get T[i] for(int j=0; j<coins.size(); ++j){ for(int i=0; i<=total; ++i){ if(i>=coins[j]){ if(T[i] > 1 + T[ i-coins[j] ]){ T[i] = 1 + T[ i-coins[j] ]; R[i] = j; } } } } return T[total]; } void printCoinCombination(vector<int>& R, vector<int>& coins,int total){ if(R[total] == -1){ cout << "no solution is possible" << endl; return; } cout << "{ "; while(total!=0){ cout << coins[R[total]] << ", "; total = total-coins[R[total]]; } cout << "}" << endl; } int main(){ vector<int> coins = {7,2,3,6}; int total = 13; vector<int> R(total+1, -1); cout << minimumCoinBottomUp(coins,total,R) << endl; printCoinCombination(R,coins,total); return 0; }
3667c2d8c7431ae618b6173de81982ac1c8aee55
da5ef784a276d243b57027b6bb4872059baff110
/oop_eng/e1/sub1/sub1/task1.cpp
3ed5eedc41ce3244416d98e3e97c1424d0172a22
[]
no_license
xlujiax/ii
485999a432dff0ab02b3486205de6be113655dde
e5d788c6fc2fbcc2f74838354b10bb5aa33574a3
refs/heads/master
2021-01-16T21:41:32.691493
2012-04-30T14:56:21
2012-04-30T14:56:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
229
cpp
task1.cpp
// This program is made by Maciej Pacut #include <iostream> #include <string> int main( unsigned int nrargs, char* args [] ) { std::string name = "Maciej Pacut"; std::cout << "good morning, " << name << "\n"; return 0; }
836098dfccfd3c0b41c3e5ed9dcbdda1bfa0e939
b6d354b56e62b32223a928c515366af3eee7ecc8
/E.T. Phone Home/E.T. Phone Home/Movable.cpp
362735ca5a7271e4f68d28983b102972c4343d31
[ "MIT" ]
permissive
SamuelKnox/Galaxa
b38b48ce74cccb465dabc31d7a9639d35ea60785
7c775708a2472d77daae3004d9d76ec80d8a8585
refs/heads/master
2021-01-22T02:59:05.587288
2015-12-05T06:11:31
2015-12-05T06:11:31
46,824,809
0
1
null
null
null
null
UTF-8
C++
false
false
327
cpp
Movable.cpp
#include "Movable.h" Movable::Movable() { } Movable::~Movable() { } void Movable::Update() { Collidable::Update(); UpdatePosition(); } void Movable::UpdatePosition() { Vector2D oldPosition = GetPosition(); float newX = oldPosition.x + velocity.x; float newY = oldPosition.y + velocity.y; SetPosition(newX, newY); }
c66f4f1d99e16234bcfe0e55e88ded0b2ef11492
236af97167b740004b9264505f4ac4b720910bcd
/GameManager.h
5f7b38c5779c26c539c4817605c54b64e242db11
[]
no_license
AdamFilet/FPS-Simulator
f8c000c243f742d9916bf45774a61a601f645fe9
17b00aab1ba3c7eb30b4970b53b06c9fa2fe36ba
refs/heads/main
2023-01-20T04:14:11.734555
2020-11-25T22:52:49
2020-11-25T22:52:49
313,433,235
0
1
null
2020-11-25T22:39:57
2020-11-16T21:37:25
C++
UTF-8
C++
false
false
957
h
GameManager.h
#pragma once #include <iostream> #include <vector> #include "Player.h" #include "Team.h" #include "weapon.h" #include "config.h" #include "fight.h" #include <iomanip> class GameManager { private: std::vector<Fight> _fights; Team _team1; Team _team2; int32_t _team1Score; int32_t _team2Score; int32_t _roundCount; bool _isPlanted; bool _isDefused; bool t1Won; bool t2Won; int32_t _fightsSincePlanted; public: GameManager(); bool IsRoundOver(); void Matchmake(); void SimulateRound(); bool IsGameOver(); int Score(); void PrintScore(); void SwitchSides(); bool IsPlanted(); bool IsDefused(); void ResetRound(); void StartFights(); void BombPlanted(); void BombDefused(); void PrintStats(); void PrintRoundStats(); private: void handleExtraPlayers(Team& team, std::vector<Player*> eligibleFighters); void addTeam1Score(); void addTeam2Score(); };
a25f48ffe4b20b0a340208968796148a01d89552
f853bbc7e34f8838ef413c1ef2c03012f537e203
/zad3-zalazek/inc/wektor.hh
ddb3489947f9cad40b6e1b9b9da06c7781e5358b
[]
no_license
Kazlouski255912/Zadanie3
e0214ea754d8dcf94da0621ba021c0a29dd39a5c
46e59112af3d2845fd51435bed798cdf7dec610a
refs/heads/master
2022-04-23T00:51:50.032996
2020-04-27T21:00:22
2020-04-27T21:00:22
259,452,200
0
0
null
null
null
null
UTF-8
C++
false
false
365
hh
wektor.hh
#include<iostream> #include"size.hh" class wektor { protected: int arr[SIZE];//inicjalizacja wektora wyrazow wolnych float niew[SIZE];//inicjalizacja wektora znaczen niewiadomych float Eps[SIZE];//inicjalizacja wektora blada public: //protypy funkcyj void Wyswietl() ; int & operator[](int n); void Wpisz(); void indeks(); };