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
541597d224477c69cb5eac8687a36733fbc53f2f
a184fb8252cb4f20d730babdbf8374ba2a1fdeff
/c_module_source/sim/src/drivers/bPhysics/objects/compound.h
254479b13a27680ef866d8a1a4d8b89f3d789ad0
[]
no_license
AtheeshThanaseelan/py-simpleSim
4f0674ea3704d3167fa673f319a58ed92f7badb2
540fe226cbc84f2e0152f509a6e9e4f03f640f7e
refs/heads/master
2023-07-18T04:00:13.861909
2021-08-27T22:59:05
2021-08-27T22:59:05
287,454,817
0
0
null
null
null
null
UTF-8
C++
false
false
730
h
compound.h
#pragma once #include <array> #include <vector> #include <string> #include "../bPhysics.h" #include "../../../interfaces/object_interface.h" //class worldComposite; //enum direction { up, down, front, back, l_left, l_right, y_left, y_right, neutral }; class bPhys_compound: public object_interface { public: //Node pointers btRigidBody* main_body; btCollisionShape* m_wheelShape; btHinge2Constraint* pHingeStore[4]; btRigidBody* pBodyB[4]; btCompoundShape* compound; bPhys_compound(bPhysics* bPhys); void direct(direction dir); std::array<float, 7> getTransform_qat(); std::string getProperties(); void setTransform_qat(std::array<float, 7> transform_qat); void update(); };
47032e505c2f85ed9ac82a7e59a9438d87dafb78
3333dd52c91331597c0a785c1ae8e663ae12dfdd
/CNT/Semester 4/CNT453/ICA6/ICA6/Int.cpp
6de7b2e4592f7048bb08ce78f517f94f1ab56e7c
[]
no_license
mtikoian/School
2e20f2fc1d6992d0047bc8686c8ac34be4369c3c
901d5ea0fd384c1713f6a7415401f15cbc75e274
refs/heads/master
2020-12-03T08:44:16.261018
2018-01-31T16:22:19
2018-01-31T16:22:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
41
cpp
Int.cpp
#include "StdAfx.h" #include "Int.h"
54e98e8d17e5b0d670e4d0417b6722305137c5da
db4ec38e3078df1b908dd2ffebea2a3f5ad400b3
/lab1/example1/main.cpp
f2229f5accad95cbc5fc6ad8244c088d5821422e
[]
no_license
JohnVonNeumann/swe20004
9fa2ebbc1f9c16319b26469ec5268fe489842705
82fda502724c06e16df21521d3750760f2436734
refs/heads/master
2023-04-22T02:54:58.925932
2021-05-05T08:45:05
2021-05-05T08:45:05
347,026,370
0
0
null
null
null
null
UTF-8
C++
false
false
150
cpp
main.cpp
#include <iostream> using namespace std; int main() { cout << "Subject\t\tMarks\nMathematics\t90\nComputer\t77\nChemistry\t69"; return 0; }
20f3fc5c25ef2e4f66beb6f0ab0af64552f23198
250101ffb5bd6c4bcfe328854284338772e9aab5
/map_server/map_moudle/ai_moudle/AIBTCName.cpp
1f6729bf34972bd0e7221840c7f2af98c53d9547
[]
no_license
MENGJIANGTAO/GameServer-2
aa1299e9442e221a1a2d26457c18396d5e4c54bd
be261b565a1f823d8d17235a21dd1f2431c0a30d
refs/heads/master
2021-09-17T22:45:10.621608
2018-07-06T05:15:47
2018-07-06T05:15:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,758
cpp
AIBTCName.cpp
/* * AIBTCName.cpp * * Created on: Jun 24, 2013 * Author: peizhibi */ #include "AIBTCName.h" /* * ai precondition * */ std::string AIBTCName::AutoPre = "auto_pre"; std::string AIBTCName::DiePre = "die_pre"; std::string AIBTCName::SleepPre = "sleep_pre"; std::string AIBTCName::PatrolPre = "patrol_pre"; std::string AIBTCName::NoAimPre = "no_aim_pre"; std::string AIBTCName::HaveAimPre = "hava_aim_pre"; std::string AIBTCName::SelectModeA = "select_mode_a"; std::string AIBTCName::SelectModeB = "select_mode_b"; std::string AIBTCName::SelectModeC = "select_mode_c"; std::string AIBTCName::SelectModeD = "select_mode_d"; std::string AIBTCName::SelectModeNpc = "select_mode_npc"; std::string AIBTCName::SelectModeE = "select_mode_e"; std::string AIBTCName::SelectModeF = "select_mode_f"; std::string AIBTCName::SelectModeG = "select_mode_g"; std::string AIBTCName::SelectModeOutside = "select_mode_outside"; std::string AIBTCName::SelectModeMonsterLowBlood = "select_mode_low_blood_monster"; std::string AIBTCName::BackPre = "back_pre"; std::string AIBTCName::IdleBackPre = "idle_back_pre"; std::string AIBTCName::ChasePre = "chase_pre"; std::string AIBTCName::AttackPre = "attack_pre"; std::string AIBTCName::RecycleTickPre = "recycle_tick_pre"; std::string AIBTCName::CircleChasePre = "circle_chase_pre"; std::string AIBTCName::AttackIntervalPre = "attack_interavel_pre"; std::string AIBTCName::FollowPre = "follow_pre"; std::string AIBTCName::AimDistancePre = "aim_distance_pre"; std::string AIBTCName::NearInnerPre = "near_inner_pre"; std::string AIBTCName::PausePre = "pause_pre"; std::string AIBTCName::SelectModeMonster = "select_mode_monster"; std::string AIBTCName::AreaRecyclePre = "area_recycle_pre"; std::string AIBTCName::CheckNearLeaguePre = "check_nearleague_pre"; std::string AIBTCName::CheckNearPlayerPre = "check_nearplayer_pre"; std::string AIBTCName::NotSinglePre = "not_single_monster_pre"; std::string AIBTCName::PlayerAlivePre = "player_alive_pre"; std::string AIBTCName::AIDistancePre = "ai_distance_pre"; std::string AIBTCName::AIIntervalPre = "ai_interval_pre"; std::string AIBTCName::AIWithinDistancePre = "ai_within_dist_pre"; std::string AIBTCName::AIBeyondDistancePre = "ai_beyond_dist_pre"; std::string AIBTCName::AllRoleDistancePre = "all_role_distance_pre"; std::string AIBTCName::RelAiDiePre = "rel_ai_die_pre"; std::string AIBTCName::ChaseBeyondDistancePre = "chase_beyond_dist_pre"; std::string AIBTCName::QIXIRUNAWAYPre = "qixi_runaway_pre"; /* * ai action * */ std::string AIBTCName::AutoAction = "auto_action"; std::string AIBTCName::DieAction = "die_action"; std::string AIBTCName::SleepAction = "sleep_action"; std::string AIBTCName::RecycleAction = "recycle_action"; std::string AIBTCName::AliveRecycleAction = "alive_recycle_action"; std::string AIBTCName::PatrolAction = "patrol_action"; std::string AIBTCName::BackAction = "back_action"; std::string AIBTCName::IdleBackAction = "idle_back_action"; std::string AIBTCName::AttackAction = "attack_action"; std::string AIBTCName::ChaseAction = "chase_action"; std::string AIBTCName::SelectAction = "select_action"; std::string AIBTCName::PatrolRouteAction = "patrol_route_action"; std::string AIBTCName::PatrolRouteBAction = "patrol_route_b_action"; std::string AIBTCName::SelectNpcAction = "select_npc_action"; std::string AIBTCName::FollowAction = "follow_action"; std::string AIBTCName::KeepAwayAction = "keep_away_action"; std::string AIBTCName::MoveAction = "move_action"; std::string AIBTCName::PauseAction = "pause_action"; std::string AIBTCName::MovetoAction = "moveto_action"; std::string AIBTCName::ComboAttackAction = "combo_attack_action"; std::string AIBTCName::NormalAttackAction = "normal_attack_action"; std::string AIBTCName::IntervalFinAction = "interval_fin_action"; std::string AIBTCName::RemoveBuffAction = "remove_buff_action"; std::string AIBTCName::AddBuffAction = "add_buff_action"; std::string AIBTCName::RelAddSkillAction = "reladdskill_action"; std::string AIBTCName::AddSkillAction = "addskill_action"; std::string AIBTCName::DirectChaseAction = "direct_chase_action"; std::string AIBTCName::GenGiftboxAction = "gen_giftbox_action"; std::string AIBTCName::LimitDisChaseAction = "limit_dis_chase_action"; std::string AIBTCName::ReturnPatrolAction = "return_patrol_action"; std::string AIBTCName::NotifyBossRemoveAttr = "notify_boss_remove_attr_action"; std::string AIBTCName::NotifyShowBoss = "notify_show_boss_action"; std::string AIBTCName::QIXIRUNAWAY = "qixi_run_away_action"; std::string AIBTCName::QIXIPatrolAction = "qixi_patrol_action"; /* * ai condition flag * */ std::string AIBTCName::NO_MOVE = "no_move"; std::string AIBTCName::NO_ATTACK = "no_attack"; std::string AIBTCName::NO_BE_ATTACKED = "no_be_attacked"; std::string AIBTCName::NO_AIM = "no_aim"; std::string AIBTCName::RECYCLE_ON_ATTACKED = "recycle_on_attacked"; /* * ai field name * */ std::string AIBTCName::RECYCLE_TICK_FIELD = "recycle_tick"; std::string AIBTCName::NPC_SORT_FIELD = "npc_sort"; std::string AIBTCName::PATROL_PATH_FIELD = "patrol_path"; std::string AIBTCName::ATTACK_INTERVAL_FIELD = "auto_attack_tick"; std::string AIBTCName::SELECT_C_RADIUS_FIELD = "select_c_radius"; std::string AIBTCName::CIRCLE_CHASE_FIELD = "circle_chase_raius"; std::string AIBTCName::MAX_CHASE_RADIUS_FIELD = "max_chase_radius"; std::string AIBTCName::ATTACK_DISTANCE_FIELD = "attack_distance"; std::string AIBTCName::AI_DISTANCE_FIELD = "ai_distance"; std::string AIBTCName::AI_NORMAL_SKILL = "normal_skill"; std::string AIBTCName::AI_COMBO_SKILL_LIST = "combo_skill_list"; std::string AIBTCName::AI_RANDOM_COMBO_SKILL_LIST = "random_combo_skill"; std::string AIBTCName::AI_ADD_BUFF = "add_buff"; std::string AIBTCName::AI_REMOVE_BUFF = "remove_buff";
4987cdaba221304a199da75a55a772d0e96ebd38
75a7f186809e5129b219469aba2406358980b149
/SUPER-PING-PONG/Classes/ObjectTags.h
89c4d483471036f5f5735e3c08479fcbc8b40b67
[]
no_license
tsu-trpo/ping-pong
09cd74b82274afe74a763bc631ce081148eb02aa
dd58f583736b56131955159fe729df0fb95f290a
refs/heads/master
2021-10-16T04:29:29.550910
2017-12-28T03:00:18
2017-12-28T03:00:18
103,905,267
11
1
null
2019-02-07T19:08:43
2017-09-18T07:11:46
C++
UTF-8
C++
false
false
341
h
ObjectTags.h
#pragma once #include "cocos2d.h" using namespace cocos2d; const std::string ballTag = "ball"; const std::string paddleTag = "paddle"; const std::string brickTag = "brick"; const std::string bonusTag = "bonus"; inline bool isTagEqualTo(const PhysicsShape *shape, const std::string &tag) { return shape->getBody()->getName() == tag; }
32552e61e02cd1679059275c41ffbb16251fe447
e5d703474d37bead76fb749f260d10011b0aeba4
/_Archiv/ToDoList/ToDoList/RecurringTaskEdit.h
e2e4d84164b280cd7664bb1caa5e761ba8c03a5e
[]
no_license
jithuin/infogeezer
d87e68366c155d0da35f3ec8b845c1fc517287cf
4b83e7e04429dd305954039ce0dae3ee0c1f4924
refs/heads/master
2021-01-10T09:10:06.215280
2014-11-16T23:13:22
2014-11-16T23:13:22
51,506,142
1
0
null
null
null
null
UTF-8
C++
false
false
8,232
h
RecurringTaskEdit.h
// RecurrenceEdit.h: interface for the CRecurringTaskEdit class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_RECURRENCEEDIT_H__4EE655E3_F4B1_44EA_8AAA_39DD459AD8A8__INCLUDED_) #define AFX_RECURRENCEEDIT_H__4EE655E3_F4B1_44EA_8AAA_39DD459AD8A8__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "..\shared\enedit.h" #include "..\shared\propertypagehost.h" #include "..\shared\weekdaycombobox.h" #include "..\shared\monthcombobox.h" #include "..\Shared\WeekdayCheckListBox.h" #include "ToDoCtrlData.h" class CTDLRecurringTaskEdit : public CEnEdit { public: CTDLRecurringTaskEdit(); virtual ~CTDLRecurringTaskEdit(); void GetRecurrenceOptions(TDIRECURRENCE& tr) const; void SetRecurrenceOptions(const TDIRECURRENCE& tr); void SetDefaultDate(const COleDateTime& date) { m_dtDefault = date; } BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0); BOOL DoEdit(BOOL bForce = FALSE); static CString GetRegularity(const TDIRECURRENCE& tr, BOOL bIncOnce = TRUE); static int CalcMaxRegularityWidth(CDC* pDC, BOOL bIncOnce = TRUE); static void SetDefaultButtonTip(LPCTSTR szOption); protected: TDIRECURRENCE m_tr; BOOL m_bReadOnly; COleDateTime m_dtDefault; BOOL m_bInOnSetReadOnly; static CString s_sOptionsBtnTip; protected: virtual void OnBtnClick(UINT nID); virtual void PreSubclassWindow(); // Implementation protected: // Generated message map functions //{{AFX_MSG(CRecurringTaskEdit) // NOTE: the ClassWizard will add member functions here //}}AFX_MSG afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); afx_msg LRESULT OnSetReadOnly(WPARAM wp, LPARAM lp); afx_msg void OnStyleChanging(int nStyleType, LPSTYLESTRUCT lpStyleStruct); afx_msg BOOL OnReflectChangeDisplayText(); DECLARE_MESSAGE_MAP() protected: static BOOL IsDefaultString(const CString& sRegularity); static CString GetRegularity(TDI_REGULARITY nRegularity, BOOL bIncOnce = TRUE); }; #endif ///////////////////////////////////////////////////////////////////////////// // CTDLRecurringTaskDailyOptionPage dialog class CTDLRecurringTaskDailyOptionPage : public CPropertyPage { // Construction public: CTDLRecurringTaskDailyOptionPage(const TDIRECURRENCE& tr, const COleDateTime& dtDefault); ~CTDLRecurringTaskDailyOptionPage(); void GetRecurrenceOptions(TDIRECURRENCE& tr) const; protected: // Dialog Data //{{AFX_DATA(CTDLRecurringTaskDailyOptionPage) int m_nEveryNumDays; int m_RecreateAfterNumDays; int m_nDailyOption; //}}AFX_DATA // Overrides // ClassWizard generate virtual function overrides //{{AFX_VIRTUAL(CTDLRecurringTaskDailyOptionPage) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnInitDialog(); //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CTDLRecurringTaskDailyOptionPage) // NOTE: the ClassWizard will add member functions here //}}AFX_MSG afx_msg void OnChangeDailyValues(); DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// // CTDLRecurringTaskWeeklyOptionPage dialog class CTDLRecurringTaskWeeklyOptionPage : public CPropertyPage { // Construction public: CTDLRecurringTaskWeeklyOptionPage(const TDIRECURRENCE& tr, const COleDateTime& dtDefault); ~CTDLRecurringTaskWeeklyOptionPage(); void GetRecurrenceOptions(TDIRECURRENCE& tr) const; protected: // Dialog Data //{{AFX_DATA(CTDLRecurringTaskWeeklyOptionPage) int m_nWeeklyOption; int m_nEveryNumWeeks; int m_nRecreateAfterNumWeeks; //}}AFX_DATA DWORD m_dwWeekdays; CWeekdayCheckListBox m_lbWeekdays; // Overrides // ClassWizard generate virtual function overrides //{{AFX_VIRTUAL(CTDLRecurringTaskWeeklyOptionPage) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnInitDialog(); //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CTDLRecurringTaskWeeklyOptionPage) // NOTE: the ClassWizard will add member functions here //}}AFX_MSG afx_msg void OnChangeWeeklyValues(); DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// // CTDLRecurringTaskMonthlyOptionPage dialog class CTDLRecurringTaskMonthlyOptionPage : public CPropertyPage { // Construction public: CTDLRecurringTaskMonthlyOptionPage(const TDIRECURRENCE& tr, const COleDateTime& dtDefault); ~CTDLRecurringTaskMonthlyOptionPage(); void GetRecurrenceOptions(TDIRECURRENCE& tr) const; protected: // Dialog Data //{{AFX_DATA(CTDLRecurringTaskMonthlyOptionPage) int m_nEveryDayOfMonth; int m_nEveryNumMonths; int m_nSpecificNumber; int m_nSpecificDayOfWeek; int m_nSpecificNumMonths; int m_nRecreateAfterNumMonths; int m_nMonthlyOption; //}}AFX_DATA CWeekdayComboBox m_cbWeekdays; // Overrides // ClassWizard generate virtual function overrides //{{AFX_VIRTUAL(CTDLRecurringTaskMonthlyOptionPage) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnInitDialog(); //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CTDLRecurringTaskMonthlyOptionPage) // NOTE: the ClassWizard will add member functions here //}}AFX_MSG afx_msg void OnChangeMonthlyValues(); DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// // CTDLRecurringTaskYearlyOptionPage dialog class CTDLRecurringTaskYearlyOptionPage : public CPropertyPage { // Construction public: CTDLRecurringTaskYearlyOptionPage(const TDIRECURRENCE& tr, const COleDateTime& dtDefault); ~CTDLRecurringTaskYearlyOptionPage(); void GetRecurrenceOptions(TDIRECURRENCE& tr) const; protected: // Dialog Data //{{AFX_DATA(CTDLRecurringTaskYearlyOptionPage) int m_nYearlyOption; int m_nEveryDayOfMonth; int m_nSpecificNumber; int m_nRecreateAfterNumYears; int m_nSpecificMonth; int m_nSpecificDayOfWeek; int m_nEveryMonth; //}}AFX_DATA CMonthComboBox m_cbSpecificMonthList; CWeekdayComboBox m_cbDaysOfWeek; CMonthComboBox m_cbEveryMonthList; // Overrides // ClassWizard generate virtual function overrides //{{AFX_VIRTUAL(CTDLRecurringTaskYearlyOptionPage) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnInitDialog(); //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CTDLRecurringTaskYearlyOptionPage) // NOTE: the ClassWizard will add member functions here //}}AFX_MSG afx_msg void OnChangeYearlyValues(); DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// // CRecurringTaskOptionDlg dialog class CTDLRecurringTaskOptionDlg : public CDialog { // Construction public: CTDLRecurringTaskOptionDlg(const TDIRECURRENCE& tr, const COleDateTime& dtDefault, CWnd* pParent = NULL); // standard constructor void GetRecurrenceOptions(TDIRECURRENCE& tr) const; protected: // Dialog Data //{{AFX_DATA(CRecurringTaskOptionDlg) int m_nRecalcFrom; int m_nReuse; //}}AFX_DATA CTDLRecurringTaskDailyOptionPage m_pageDaily; CTDLRecurringTaskWeeklyOptionPage m_pageWeekly; CTDLRecurringTaskMonthlyOptionPage m_pageMonthly; CTDLRecurringTaskYearlyOptionPage m_pageYearly; CPropertyPageHost m_ppHost; TDI_REGULARITY m_nFrequency; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CRecurringTaskOptionDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual void OnOK(); //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CRecurringTaskOptionDlg) afx_msg void OnSelchangeFrequency(); virtual BOOL OnInitDialog(); //}}AFX_MSG DECLARE_MESSAGE_MAP() protected: BOOL HasValidData(); };
65c8343040c8bbb5ccf6201f8937b8d3bbac0d8e
456f377593db81bd32990009e3c8f8b0c0babc5e
/CA/CA Project/ca project.cpp
06840f53a2de10901d349dbb8ce973910d338be4
[]
no_license
EishaMazhar/Semester5-Resources
34f577265f01854c36d6d5969bdfe00cb49a61e6
ab5af4e9ff77d3b7e831cca831f635a111b57d6c
refs/heads/master
2022-12-07T14:26:45.476753
2020-08-27T22:27:12
2020-08-27T22:27:12
290,894,452
10
1
null
null
null
null
UTF-8
C++
false
false
4,229
cpp
ca project.cpp
#include<iostream> #include<math.h> #include<fstream> using namespace std; double nhit=0,nmiss=0,missrate,hitrate; ofstream out; static int s=0; void print_2d(int **array,int rows,int cols) { if(s>0) { out.open("Output.txt",ios::app); } else out.open("Output.txt"); s++; for(int i=0; i<rows; i++) { out<<"set number"<<i<<" : "; for(int j=0; j<cols; j++) { if(array[i][j]!=INT_MIN) out<<(array[i][j]); out<<" "; } out<<"\n"; } out.close(); } int ishit(int **array,int size,int row,int num) //row has mod(setNo) { int i=0; for(i=0; i<size; i++) { if(array[row][i]==num) { return i; //return column number where hit } } return -1; //return -1 if miss } int minindex(int **array,int size,int row) { int min_index=0; int min=array[row][0]; for(int i=1; i<size; i++) { if(array[row][i]<min) { min=array[row][i]; min_index=i; } } return min_index; } int maxindex(int **array,int size,int row) { int max_index=0; int max=array[row][0]; for(int i=1; i<size; i++) { if(array[row][i]>max) { max=array[row][i]; max_index=i; } } return max_index; } void LRU(int set_no,int **sets,int **index,int rows,int n_way,int num) { int i,j,min_index=0,max_index=0; bool status=false; max_index=maxindex(index,n_way,set_no); //find max index from INDEX array int hit_index=ishit(sets,n_way,set_no,num); //check if hit exists in the set if(hit_index!=-1) { nhit++; index[set_no][hit_index]=index[set_no][max_index]+1; } else { nmiss++; for(i=0; i<n_way; i++) { if(sets[set_no][i] == INT_MIN) //when block is empty { sets[set_no][i]=num; //num is placed in first empty space if(i!=0) index[set_no][i]=index[set_no][i-1]+1; //Indez status incremented status=true; //when no replacement needed and value is places in block break; } } if(!status) { min_index=minindex(index,n_way,set_no); //return column LRU sets[set_no][min_index]=num; index[set_no][min_index]=index[set_no][max_index]+1; } } print_2d(sets,rows,n_way); } int main() { long long int mainmemorysize,cashesize,blocksize,associativity,totalblocks,totalsets,physicalbits; cout<<"Enter Main Memory size : "; cin>>mainmemorysize; physicalbits=log2(mainmemorysize); cout<<"Enter Cashe size : "; cin>>cashesize; if(cashesize>mainmemorysize) { cout<<"cashesize should be less than main memory size"; exit(0); } cout<<"Enter Block size : "; cin>>blocksize; cout<<"Enter associativity : "; cin>>associativity; totalblocks=cashesize/blocksize; totalsets=totalblocks/associativity; cout<<"Cashe size is : "<<cashesize<<endl; cout<<"Block size is : "<<blocksize<<endl; cout<<"associativity is : "<<associativity<<endl; cout<<"Total blocks are : "<<totalblocks<<endl; cout<<"Total sets are : "<<totalsets<<endl; cout<<"Physical adrees bits are : "<<physicalbits<<endl; long long int offsetbits=log2(blocksize); cout<<"Total offset bits are : "<<offsetbits<<endl; long long int indexbits=log2(totalsets); cout<<"Total index bits are : "<<indexbits<<endl; int Tagbits=physicalbits-offsetbits-indexbits; cout<<"Total tag bits are : "<<Tagbits<<endl; //Values int **temp=new int*[totalsets]; for(int i = 0; i < totalsets; ++i) { temp[i] = new int[associativity]; } //Indexing int **index=new int*[totalsets]; for(int i = 0; i < totalsets; ++i) { index[i] = new int[associativity]; } for(int i=0; i<totalsets; i++) { for(int j=0; j<associativity; j++) { index[i][j]=0; temp[i][j]=INT_MIN; } } long long int n,b,sn; cout<<"Enter how many block numbers you want to enter : "; cin>>n; for(int i=0;i<n;i++) { cin>>b; sn=b%totalsets; LRU(sn,temp,index,totalsets,associativity,b); } hitrate=nhit/(nhit+nmiss); missrate=nmiss/(nhit+nmiss); cout<<"Number of misses are : "<<nmiss<<endl; cout<<"Number of hits are : "<<nhit<<endl; cout<<"Miss rate is : "<<missrate<<endl; cout<<"Hit rate is : "<<hitrate<<endl; }
0d70ff1b0d1403f5e5d9c256428e450402663519
9c1971ad1e4ba01d7177a8e63fbb67203a0a03df
/problems/1779/solution.cpp
ce57a4fc8ae93f1ba27475cfd9bb94c318ed4b09
[]
no_license
virtyaluk/leetcode
cb5a7d0957be353125861b1b9d41606f4729248a
2a1496e5deaf45b28647e713a82b1f5b456888fa
refs/heads/master
2023-07-07T16:52:23.152194
2023-06-24T00:50:09
2023-06-24T00:50:09
166,505,868
1
0
null
null
null
null
UTF-8
C++
false
false
517
cpp
solution.cpp
class Solution { public: int nearestValidPoint(int x, int y, vector<vector<int>>& points) { int ans = -1; auto md = [&](const vector<int>& p) { return abs(x - p[0]) + abs(y - p[1]); }; for (int i = 0; i < size(points); i++) { if (points[i][0] == x or points[i][1] == y) { if (ans == -1 or md(points[ans]) > md(points[i])) { ans = i; } } } return ans; } };
cce7f3aad5327f3ac51bfad84e00a0d81eae4525
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/24/131a43a94df7d6/main.cpp
94d3c1bb5f8069db8795e08600305fdaf40589e1
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
299
cpp
main.cpp
#include <iostream> using namespace std; using A = struct { auto _x() { auto p = this; struct B { using this_type = decltype(p); }; return B{}; } using this_type = decltype(A{}._x())::this_type; }; int main() { // your code goes here return 0; }
7b74469ddfdd305a1076199e116fe83f983bb099
2bfddaf9c0ceb7bf46931f80ce84a829672b0343
/examples/xtd.forms.examples/applications/application/src/application.cpp
1f10722ffae50918c4f55ba237de05ef1878ac75
[ "MIT" ]
permissive
gammasoft71/xtd
c6790170d770e3f581b0f1b628c4a09fea913730
ecd52f0519996b96025b196060280b602b41acac
refs/heads/master
2023-08-19T09:48:09.581246
2023-08-16T20:52:11
2023-08-16T20:52:11
170,525,609
609
53
MIT
2023-05-06T03:49:33
2019-02-13T14:54:22
C++
UTF-8
C++
false
false
134
cpp
application.cpp
#include <xtd/forms/application> #include <xtd/forms/form> auto main()->int { xtd::forms::application::run(xtd::forms::form {}); }
9f34a1fad0e862ce138910af62e376708ed63176
badf5496f1025a66cc44bc37890baf545d058ae2
/testBuzzer/testBuzzer.ino
26aff225e3cf8e74b3bc9e664e1c6568d7fd0a48
[]
no_license
1164513233/catMini
b683f7bbc12e992819939e929b24352b97412c9a
125c3c8455c7418e31feee8858116d045b468fa9
refs/heads/master
2021-10-16T08:56:14.510669
2019-02-09T14:57:11
2019-02-09T14:57:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,331
ino
testBuzzer.ino
// Customized music player // Rongzhong Li // August 2017 #define BUZZER 4 void beep(int note, float duration = 10, int pause = 0, byte repeat = 1 ) { if (note == 0) { analogWrite(BUZZER, 0); delay(duration); return; } int freq = 220 * pow(1.059463, note); float period = 1000000.0 / freq / 2.0; for (byte r = 0; r < repeat; r++) { for (float t = 0; t < duration * 1000; t += period * 2) { analogWrite(BUZZER, 150); // Almost any value can be used except 0 and 255 // experiment to get the best tone delayMicroseconds(period); // wait for a delayms ms analogWrite(BUZZER, 0); // 0 turns it off delayMicroseconds(period); // wait for a delayms ms } delay(pause); } } void playMelody(byte m[], int len) { for (int i = 0; i < len; i++) beep(m[i], 1000 / m[len + i], 100); } void setup() //opening music { Serial.begin(57600); pinMode(BUZZER, OUTPUT); } int a=0; void loop() { // tone: pause,1, 2, 3, 4, 5, 6, 7, 1, 2 // code: 0, 1, 3, 5, 6, 8, 10, 12, 13, 15 byte melody[] = {8, 13, 10, 13, 8, 0, 5, 8, 3, 5, 8, 8, 8, 32, 32, 8, 32, 32, 32, 32, 32, 8 //8,8,16,16,8,16,16,16,16,8 }; playMelody(melody, sizeof(melody) / 2); Serial.println(a++); }
a36038e3d0125a731ea98db713f280d4d8c8ff12
ffa7ed2f4fc1cd1dd36f1022d9760831e7d07491
/codes/Greedy/LightOJ 1219 - Mafia.cpp
71b4d17aebd509b7bf9320b66a8106ea3c727dc5
[]
no_license
Zylophone/lightoj-solutions
7113b144b9b2918f1ce37fe4811ff197c42e994c
cf49bcf17980290d0d2e58b57ad5643beff640d6
refs/heads/master
2021-07-15T09:55:41.261731
2017-10-13T06:09:54
2017-10-13T06:09:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,331
cpp
LightOJ 1219 - Mafia.cpp
/** * Author : sjsakib.bd * Lang : C++ * Date : 2016-02-29 16:48:08 * Problem : 1219 - Mafia * CPU : 0.008 * Memory : 2012 **/ /* * sjsakib */ #include <bits/stdc++.h> #define stream istringstream #define rep(i,n) for(int i=0; i<(int)n; i++) #define repv(i,n) for(int i=n-1; i>=0; i--) #define repl(i,n) for(int i=1; i<=(int)n; i++) #define replv(i,n) for(int i=n; i>=1; i--) #define INF (1<<28) #define PI 3.14159265358979323846264338327950 #define pb(x) push_back(x) #define ppb pop_back #define all(x) x.begin(),x.end() #define mem(x,y) memset(x,y,sizeof(x)) #define eps 1e-9 #define pii pair<int,int> #define pmp make_pair #define sdi(x) scanf("%d",&x) #define sdii(x,y) scanf("%d%d",&x,&y) #define sdc(x) scanf("%c",&x) #define SDs(x) scanf("%s",x) #define uu first #define vv second using namespace std; template<class T> inline T gcd(T a,T b) {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);} template<class T> inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));} template<class T> inline T sqr(T x){return x*x;} template<class T> T power(T N,T P){ return (P==0)? 1: N*power(N,P-1); } typedef long long i64; typedef unsigned long long ui64; #define cl list<char> #define READ(f) freopen(f, "r", stdin) #define WRITE(f) freopen(f, "w", stdout) //bool operator < ( const node& p ) const { return dist > p.dist; } int fx[]={0,0,-1,+1,-1,-1,+1,+1}; int fy[]={-1,+1,0,0,-1,+1,-1,+1}; int n; vector<int> edges[10001]; int nodes[10001]; bool dpvis[10001]; int dp[10001]; int count(int x) { if(dpvis[x] == true) return dp[x]; int r = nodes[x]-1; rep(i,edges[x].size()) { r+=count(edges[x][i]); } dp[x] = r; dpvis[x] = true; return r; } int main() { //READ("in"); int t; sdi(t); int v,d,x; int sum; rep(i,t) { sdi(n); rep(j,n) { sdi(v); edges[v].clear(); sdi(nodes[v]); sdi(d); rep(k,d) { sdi(x); edges[v].push_back(x); } } sum = 0; memset(dpvis,false,sizeof(dpvis[0])*n+1); repl(j,n) { sum+=abs(count(j)); } printf("Case %d: %d\n",i+1,sum); } return 0; }
11680e92d842a30de4018f7dba2fb0f9673a66fb
590c1d80050092bc1e11afe1fd099adeb0b3476a
/src/GEV_UDM/light_control.ino
75fdcec5ddb6393f04666884d98e2f1c450d45a3
[]
no_license
GanzYouthWorkshop/GEV-UDM
d2f81c276a526a0d29f9d2c79068f49a8df14639
f094667ef45b1259b1dcaa86127476f41c456a8d
refs/heads/master
2021-04-01T11:18:25.553148
2020-03-18T10:09:32
2020-03-18T10:09:32
248,185,285
0
0
null
null
null
null
UTF-8
C++
false
false
1,503
ino
light_control.ino
#ifdef USE_LIGHT_CONTROLLER //*************************************************************************************** //Configurations //*************************************************************************************** //Configuring the Light controller channels #define MAX_LIGHT_CHANNELS 6 //*************************************************************************************** //Global variables //*************************************************************************************** volatile byte pwm_set[MAX_LIGHT_CHANNELS] = {255, 50, 10, 255, 0, 0}; volatile byte pwm[MAX_LIGHT_CHANNELS] = {255, 65, 10, 255, 129, 0}; byte pwmPin [MAX_LIGHT_CHANNELS] = {25, 26, 36, 36, 36, 36}; TaskHandle_t RealTimeThread; //*************************************************************************************** //Methods //*************************************************************************************** void initLightControl() { xTaskCreatePinnedToCore(realtime, "Realtime", 10000, NULL, 0, &RealTimeThread, 0); } void realtime(void* parameter) { for(int i = 0; i < MAX_LIGHT_CHANNELS; i++) { pinMode(pwmPin[i], OUTPUT); } while(true) { for(int step = 0; step < 255; step++) { for(int i = 0; i < MAX_LIGHT_CHANNELS; i++) { if(step == 0) { digitalWrite(pwmPin[i], 0); } if(pwm[i] > step) { digitalWrite(pwmPin[i], 1); } } delayMicroseconds(10); } } } #endif
e9443c9299e86580ad74d3acd21efb86f6549600
c3b979ea12f7ee64162af0eb67f35417fca15603
/geometria/include/piramide.h
1265c3791c66a43dd435637c550527e6e080f93f
[]
no_license
toiinnn/lab02
84aad7d3b82f543971bd6de108104dbd5392cd27
71120b73e936c3e21ad6a66b13eae7b4f2051513
refs/heads/master
2020-03-12T08:18:25.097356
2018-04-22T20:51:11
2018-04-22T20:51:11
130,524,832
0
0
null
null
null
null
UTF-8
C++
false
false
844
h
piramide.h
/* *@file piramide.h *@brief arquivo de cabecalho do objeto piramide *@author Antonio Marcos de Oliveira *@since 18/04/1997 *@date 21/04/1997 */ #ifndef PIRAMIDE_H #define PIRAMIDE_H #include <iostream> using std::cout; using std::endl; class Piramide { private: float m_area_base; float m_area_lateral; float m_altura; public: Piramide(); ~Piramide(); float calcular_area_piramide(float area_base, float area_lateral); float calcular_volume_piramide(float area_base, float altura); void mostrar_area_piramide(float area_base, float area_lateral); void mostrar_volume_piramide(float area_base, float altura); float get_area_base(); void set_area_base(float area_base); float get_area_lateral(); void set_area_lateral(float area_lateral); float get_altura(); void set_altura(float altura); }; #endif /*PIRAMIDE_H*/
05e3e5d98a477c2903ccde52b637c5d05dc3e4e0
2a6ed0f4ac4d83f66f14a286f57e279d2dc2cff7
/src/Blocks/BlockSnow.h
299ec9f6292aab5dbe2eba8e8f8f5addd4444dbd
[ "Apache-2.0" ]
permissive
npresley0506/cuberite
ea9d09da2ca17246db623d6ab4f6c06261e6d13f
4cb9ef8c578aaa769110c74466f3e3b61d0117c0
refs/heads/master
2023-04-14T15:21:52.665595
2021-04-22T22:04:09
2021-04-22T22:04:09
357,432,195
0
0
NOASSERTION
2021-04-22T14:48:58
2021-04-13T05:17:05
C++
UTF-8
C++
false
false
3,435
h
BlockSnow.h
#pragma once #include "BlockHandler.h" class cBlockSnowHandler final : public cBlockHandler { using Super = cBlockHandler; public: using Super::Super; private: enum { FullBlockMeta = 7 // Meta value of a full-height snow block }; virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer & a_Player, const Vector3i a_PlacedBlockPos, eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) const override { a_BlockType = m_BlockType; // Check if incrementing existing snow height: BLOCKTYPE BlockBeforePlacement; NIBBLETYPE MetaBeforePlacement; a_ChunkInterface.GetBlockTypeMeta(a_PlacedBlockPos, BlockBeforePlacement, MetaBeforePlacement); if ((BlockBeforePlacement == E_BLOCK_SNOW) && (MetaBeforePlacement < FullBlockMeta)) { // Only increment if: // - A snow block was already there (not first time placement) AND // - Height is smaller than the maximum possible a_BlockMeta = MetaBeforePlacement + 1; return true; } // First time placement, check placement is valid a_BlockMeta = 0; BLOCKTYPE BlockBelow; NIBBLETYPE MetaBelow; return ( (a_PlacedBlockPos.y > 0) && a_ChunkInterface.GetBlockTypeMeta(a_PlacedBlockPos.addedY(-1), BlockBelow, MetaBelow) && CanBeOn(BlockBelow, MetaBelow) ); } virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const override { if ((a_Player.GetEquippedItem().m_ItemType == E_BLOCK_SNOW) && (a_Meta < FullBlockMeta)) { return true; // If a player is holding a (thin) snow block and it's size can be increased, return collision ignored } if (a_Meta == 0) { return true; // If at normal snowfall height (lowest), we ignore collision } return false; } virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override { // No drop unless dug up with a shovel if ((a_Tool == nullptr) || !ItemCategory::IsShovel(a_Tool->m_ItemType)) { return {}; } if (ToolHasSilkTouch(a_Tool)) { return cItem(m_BlockType, 1, 0); } else { // Drop as many snowballs as there were "layers" of snow: return cItem(E_ITEM_SNOWBALL, 1 + (a_BlockMeta & 0x07), 0); } } virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override { if (a_RelPos.y <= 0) { return false; } auto BelowPos = a_RelPos.addedY(-1); auto BlockBelow = a_Chunk.GetBlock(BelowPos); auto MetaBelow = a_Chunk.GetMeta(BelowPos); return CanBeOn(BlockBelow, MetaBelow); } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { UNUSED(a_Meta); return 14; } virtual bool IsInsideBlock(const Vector3d a_RelPosition, const NIBBLETYPE a_BlockMeta) const override { return a_RelPosition.y < (cBlockInfo::GetBlockHeight(m_BlockType) * (a_BlockMeta & 0x07)); } private: /** Returns true if snow can be placed on top of a block with the given type and meta. */ static bool CanBeOn(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { // If block below is snowable, or it is a thin slow block and is a full thin snow block, say yay return ( cBlockInfo::IsSnowable(a_BlockType) || ( (a_BlockType == E_BLOCK_SNOW) && (a_BlockMeta == FullBlockMeta) ) ); } } ;
6a5937c36533c5a9f98de06c83c45ce52837691e
46f596af05f000408fd6932e5b96dbf124af49f8
/homework/Fedotova/01/sum_by_cols.cpp
38b3a245d21f5d0fb7f0e8ae2602fff000eeb798
[ "MIT" ]
permissive
fsatka/msu_cpp_spring_2018
157d5e56587e53b441126fd5e793f93db6bc211b
b5d84447f9b8c7f3615b421c51cf4192f1b90342
refs/heads/master
2020-03-29T12:47:11.411708
2018-06-25T22:06:53
2018-06-25T22:06:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,050
cpp
sum_by_cols.cpp
#include <chrono> #include <iostream> #include <cstdlib> #include <ctime> #define SIZE_r 10000 #define SIZE_c 10000 using namespace std; class Timer { public: Timer() : start_(std::chrono::high_resolution_clock::now()) { } ~Timer() { const auto finish = std::chrono::high_resolution_clock::now(); std::cout << std::chrono::duration_cast<std::chrono::microseconds>(finish - start_).count() << " us" << std::endl; } private: const std::chrono::high_resolution_clock::time_point start_; }; int main() { srand(time(NULL)); int **a = new int *[SIZE_r]; for (int i = 0; i < SIZE_r; i++) { a[i] = new int[SIZE_c]; for (int j = 0; j < SIZE_c; j++) a[i][j] = rand(); } int sum = 0; Timer t; for (int i = 0; i < SIZE_c; i++) for (int j = 0; j < SIZE_r; j++) sum += a[j][i]; cout << sum << endl; for (int i = 0; i < SIZE_r; i++) delete[] a[i]; delete[] a; return 0; }
fc82c87554e3b9164ff66163204773c4051aca40
ad57c463b06a650f61777221c55def11b6575427
/contrib/jmcddn/ssac_tornado/NewRefCountSimpleCO.H
69fe65d6b84a5131c77b89cf7c6bc01587b41033
[ "MIT" ]
permissive
dschatzberg/EBBlib
1fc6ceff17065b0ed2eeb380843aa739ad5a14b7
63ebaf134dfc59a8133111b589f351b5073c01c9
refs/heads/master
2021-01-20T23:40:42.307695
2012-04-27T01:41:09
2012-04-27T01:41:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,438
h
NewRefCountSimpleCO.H
#ifndef NEWREFCOUNTSIMPLECO_DEFH #define NEWREFCOUNTSIMPLECO_DEFH /****************************************************************************** * * Tornado:[COMPONENT] * * University of Toronto * Copyright 1994,1995 * * This software is free for all non-commercial use, and anyone in this * category may freely copy, modify, and redistribute any portion of it, * provided they retain this disclaimer and author list. * The authors do not accept responsibility for any consequences of * using this program, nor do they in any way guarantee its correct operation. * * $Id: NewRefCountSimpleCO.H,v 1.2 1998/01/03 05:13:02 jonathan Exp $ *****************************************************************************/ /***************************************************************************** * Module Description: * **************************************************************************/ #include <tornado/ClusteredObject.H> #include "lock/Lock.H" class RefCountSimpleCO; typedef RefCountSimpleCO **RefCountSimpleCORef; class RefCountSimpleCO : public COSimple { protected: int _localcount; SimpleSpinBlockLock _lock; public: RefCountSimpleCO(int i=0); virtual ~RefCountSimpleCO(); virtual TornStatus inc(); virtual TornStatus dec(); virtual TornStatus val(int&); }; #endif /* REFCOUNTSIMPLECO_DEFH */
d2af0de961cdbb13996dcd9c5b090b9bc1e5c383
b7d4fc29e02e1379b0d44a756b4697dc19f8a792
/deps/boost/libs/qvm/test/row_test.cpp
972e0762c8dcde3118dcf905e72e721291294dbc
[ "GPL-1.0-or-later", "MIT", "BSL-1.0" ]
permissive
vslavik/poedit
45140ca86a853db58ddcbe65ab588da3873c4431
1b0940b026b429a10f310d98eeeaadfab271d556
refs/heads/master
2023-08-29T06:24:16.088676
2023-08-14T15:48:18
2023-08-14T15:48:18
477,156
1,424
275
MIT
2023-09-01T16:57:47
2010-01-18T08:23:13
C++
UTF-8
C++
false
false
2,505
cpp
row_test.cpp
//Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <boost/qvm/map_mat_vec.hpp> #include <boost/qvm/vec_traits_array.hpp> #include <boost/qvm/mat_operations.hpp> #include <boost/qvm/vec_operations.hpp> #include <boost/qvm/vec.hpp> #include "test_qvm.hpp" #include "test_qvm_matrix.hpp" #include "gold.hpp" namespace { template <int Rows,int Cols,int Row> void test() { using namespace boost::qvm; test_qvm::matrix<M1,Rows,Cols> x(42,1); float r1[Cols]; for( int i=0; i!=Cols; ++i ) r1[i]=x.a[Row][i]; float r2[Cols]; assign(r2,row<Row>(x)); BOOST_QVM_TEST_EQ(r1,r2); row<Row>(x) *= 2; for( int i=0; i!=Cols; ++i ) r1[i]=x.a[Row][i]; assign(r2,row<Row>(x)); BOOST_QVM_TEST_EQ(r1,r2); row<Row>(x) + row<Row>(x); -row<Row>(x); } } int main() { test<2,1,0>(); test<2,1,1>(); test<3,1,0>(); test<3,1,1>(); test<3,1,2>(); test<4,1,0>(); test<4,1,1>(); test<4,1,2>(); test<4,1,3>(); test<5,1,0>(); test<5,1,1>(); test<5,1,2>(); test<5,1,3>(); test<5,1,4>(); test<2,2,0>(); test<2,2,1>(); test<3,2,0>(); test<3,2,1>(); test<3,2,2>(); test<4,2,0>(); test<4,2,1>(); test<4,2,2>(); test<4,2,3>(); test<5,2,0>(); test<5,2,1>(); test<5,2,2>(); test<5,2,3>(); test<5,2,4>(); test<2,3,0>(); test<2,3,1>(); test<3,3,0>(); test<3,3,1>(); test<3,3,2>(); test<4,3,0>(); test<4,3,1>(); test<4,3,2>(); test<4,3,3>(); test<5,3,0>(); test<5,3,1>(); test<5,3,2>(); test<5,3,3>(); test<5,3,4>(); test<2,4,0>(); test<2,4,1>(); test<3,4,0>(); test<3,4,1>(); test<3,4,2>(); test<4,4,0>(); test<4,4,1>(); test<4,4,2>(); test<4,4,3>(); test<5,4,0>(); test<5,4,1>(); test<5,4,2>(); test<5,4,3>(); test<5,4,4>(); test<2,5,0>(); test<2,5,1>(); test<3,5,0>(); test<3,5,1>(); test<3,5,2>(); test<4,5,0>(); test<4,5,1>(); test<4,5,2>(); test<4,5,3>(); test<5,5,0>(); test<5,5,1>(); test<5,5,2>(); test<5,5,3>(); test<5,5,4>(); return boost::report_errors(); }
82b84f73ffadbb40192e036cd2dc18eb32e2130b
07970b2985deb90ea75c7d449b7f08c7870e93f0
/DroneStatsServer/mainwindow.h
1ef645e75b1b942af796e8bc1f186a586a82c595
[]
no_license
kola1197/DroneApp
28c2a80e34fc3a26a2418baaecd1a7c42116e536
4f10666575c79988120897eef565892098f29bc7
refs/heads/master
2023-06-18T07:55:17.127116
2021-07-01T18:21:40
2021-07-01T18:21:40
268,465,774
0
0
null
2020-06-14T05:44:15
2020-06-01T08:27:11
C++
UTF-8
C++
false
false
1,931
h
mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include "statsclient.h" #include <QMainWindow> #include <mutex> #include "../Utils/MutexBool.h" QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); void setTestImage(); public slots: void setWarningText(QString text); void setLeftImage(QImage value); void setRightImage(QImage value); void setOnboardVideoCaptureMode(bool mode); void setVideoStreamMode(bool mode); void setConnected(bool connected); //on server tcp connection on/off changes void setPing(QString q); void updateImages(); void setRamData(double ramSize, double ramFree); void setCPUData(double CPUTemp, double avgLoad, QVector<double> coreLoad); private slots: void on_connectButton_released(); void on_getImageStreamButton_pressed(); void on_onBoardVideoCapture_released(); void getCoordinatespoint(CvPoint3D32f point); void onnnTargetXEditingFinished(); void onnnTargetYEditingFinished(); void onnnTargetZEditingFinished(); void checkTargetPosition(); void on_setTargetPointButton_released(); void on_ConnectToPX4_released(); void on_startFlightButton_released(); void on_SetCurrentPointAsZerroButton_released(); void on_horizontalSlider_valueChanged(int value); void on_horizontalSlider_rangeChanged(int min, int max); void setVehicleModeValue(); void setTargetPosition(); void updatePX4Data(); signals: void transmitUpdateLabels(); private: Ui::MainWindow *ui; StatsClient client; QImage leftImage; QImage rightImage; MutexBool hasVideoStream{false}; MutexBool onboardVideoRecordingMode{false}; std::mutex imageMutex; QImage getLeftImage(); QImage getRightImage(); }; #endif // MAINWINDOW_H
e67074a2d28f18217e78ef2a368856fb71d9f1c0
e1353001aa6323eabbd13a95869b4141e85173bc
/1.ino
71009b9abaf5dbcb1e0742248fb18d14e29fdd54
[]
no_license
DustinMathia/Arduino-Lessons
45acfc968ab9e297a3a91f1b97c0a79107589706
d22715e6a06b3506c272d9b107bcc3eb525122d0
refs/heads/master
2020-03-18T05:46:25.058072
2018-05-22T04:31:01
2018-05-22T04:31:01
134,360,613
0
0
null
null
null
null
UTF-8
C++
false
false
313
ino
1.ino
void setup() { // put your setup code here, to run once: Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission Serial.println("Hello World!"); //Prints data to the serial port } void loop() { // put your main code here, to run repeatedly: }
04c1403521b5e1dd5c0251049972ed4601ea25bf
8bb7f6bb1c4b2134e734159083b1a42982c0671c
/gatewaySeu.ino
df9efb9e4bc71bc2d4c93319ff3ca82ae747d5f2
[]
no_license
charlesochoa/gatewaySeu
e92586272850edc59b8df8426e3b97bdb1fc2d05
3e18fa86678d294edab9b29b7840c80922c5046d
refs/heads/main
2023-05-29T16:56:49.042756
2021-06-09T23:59:53
2021-06-09T23:59:53
373,569,751
0
0
null
null
null
null
UTF-8
C++
false
false
10,101
ino
gatewaySeu.ino
/** @file EnigmaIOTGatewayDummy.ino @version 0.9.7 @date 04/02/2021 @author German Martin @brief Gateway based on EnigmaIoT over ESP-NOW with dummy output module to serve as start for new gateways */ #include <Arduino.h> #include <GwOutput_generic.h> #include "GwOutput_dummy.h" #ifdef ESP32 #include <WiFi.h> #include <AsyncTCP.h> // Comment to compile for ESP8266 #include <Update.h> #include <SPIFFS.h> #include "esp_system.h" #include "esp_event.h" #include "esp_tls.h" #include "soc/soc.h" // Disable brownout problems #include "soc/rtc_cntl_reg.h" // Disable brownout problems #elif defined(ESP8266) #include <ESP8266WiFi.h> #include <ESPAsyncTCP.h> // Comment to compile for ESP32 #include <Hash.h> #include <SPI.h> #endif // ESP32 #include <CayenneLPP.h> #include <FS.h> #include <EnigmaIOTGateway.h> #include <helperFunctions.h> #include <EnigmaIOTdebug.h> #include <espnow_hal.h> #include <Curve25519.h> #include <ChaChaPoly.h> #include <Poly1305.h> #include <SHA256.h> #include <ArduinoJson.h> #include <DNSServer.h> #include <ESPAsyncWebServer.h> #include <ESPAsyncWiFiManager.h> #ifndef BUILTIN_LED #define BUILTIN_LED 5 #endif // BUILTIN_LED #define DEBUG_LEVEL 5 #define BLUE_LED BUILTIN_LED #define RED_LED BUILTIN_LED #ifdef ESP32 TimerHandle_t connectionLedTimer; #elif defined(ESP8266) ETSTimer connectionLedTimer; #endif // ESP32 const int connectionLed = BUILTIN_LED; boolean connectionLedFlashing = false; void flashConnectionLed (void* led) { //digitalWrite (*(int*)led, !digitalRead (*(int*)led)); digitalWrite (BUILTIN_LED, !digitalRead (BUILTIN_LED)); } void startConnectionFlash (int period) { #ifdef ESP32 if (!connectionLedFlashing) { connectionLedFlashing = true; connectionLedTimer = xTimerCreate ("led_flash", pdMS_TO_TICKS (period), pdTRUE, (void*)0, flashConnectionLed); xTimerStart (connectionLedTimer, 0); } #elif defined (ESP8266) ets_timer_disarm (&connectionLedTimer); if (!connectionLedFlashing) { connectionLedFlashing = true; ets_timer_arm_new (&connectionLedTimer, period, true, true); } #endif // ESP32 } bool sendDataToLeonardo(char * payload) { char confMsg[] = "ok"; char input[100]; for ( int s = 0; s < 4; s++ ) { Serial.write(payload); bool received = false; int i = 0; for (int t = 0; t < 1000 ; t++) { if (Serial.available() ) { char inChar = (char)Serial.read(); // add it to the inputString: input[i] = inChar; i++; if (inChar == 'k') { return strcmp (confMsg, input) == 0; } if (i == 99) { return false; } } } } } void stopConnectionFlash () { #ifdef ESP32 if (connectionLedFlashing) { connectionLedFlashing = false; xTimerStop (connectionLedTimer, 0); xTimerDelete (connectionLedTimer, 0); } #elif defined(ESP8266) if (connectionLedFlashing) { connectionLedFlashing = false; ets_timer_disarm (&connectionLedTimer); digitalWrite (connectionLed, HIGH); } #endif // ESP32 } void wifiManagerExit (boolean status) { GwOutput.configManagerExit (status); } void wifiManagerStarted () { GwOutput.configManagerStart (&EnigmaIOTGateway); } void processRxControlData (char* macStr, uint8_t* data, uint8_t length) { if (data) { DEBUG_INFO ("Data received"); DEBUG_INFO ("%s", macStr); GwOutput.outputControlSend (macStr, data, length); } } void processRxData (uint8_t* mac, uint8_t* buffer, uint8_t length, uint16_t lostMessages, bool control, gatewayPayloadEncoding_t payload_type, char* nodeName = NULL) { //uint8_t *addr = mac; size_t pld_size; const int PAYLOAD_SIZE = 512; char payload[PAYLOAD_SIZE]; //char payload = (char*)malloc (PAYLOAD_SIZE); char mac_str[ENIGMAIOT_ADDR_LEN * 3]; mac2str (mac, mac_str); if (control) { processRxControlData (nodeName ? nodeName : mac_str, buffer, length); return; } char* netName = EnigmaIOTGateway.getNetworkName (); if (payload_type == CAYENNELPP) { const int capacity = JSON_ARRAY_SIZE (25) + 25 * JSON_OBJECT_SIZE (4); DynamicJsonDocument jsonBuffer (capacity); JsonArray root = jsonBuffer.createNestedArray (); CayenneLPP cayennelpp (MAX_DATA_PAYLOAD_SIZE); cayennelpp.decode ((uint8_t*)buffer, length, root); uint8_t error = cayennelpp.getError (); if (error != LPP_ERROR_OK) { DEBUG_ERROR ("Error decoding CayenneLPP data: %d", error); return; } pld_size = serializeJson (root, payload, PAYLOAD_SIZE); } else if (payload_type == MSG_PACK) { const int capacity = JSON_ARRAY_SIZE (25) + 25 * JSON_OBJECT_SIZE (4); DynamicJsonDocument jsonBuffer (capacity); DeserializationError error = deserializeMsgPack (jsonBuffer, buffer, length); if (error != DeserializationError::Ok) { DEBUG_ERROR ("Error decoding MSG Pack data: %s", error.c_str ()); return; } pld_size = serializeJson (jsonBuffer, payload, PAYLOAD_SIZE); } else if (payload_type == RAW) { if (length <= PAYLOAD_SIZE) { memcpy (payload, buffer, length); pld_size = length; } else { // This will not happen but may lead to errors in case of using another physical transport memcpy (payload, buffer, PAYLOAD_SIZE); pld_size = PAYLOAD_SIZE; } } GwOutput.outputDataSend (mac_str, payload, pld_size); DEBUG_INFO ("Published data message from %s: %s", mac_str, payload); sendDataToLeonardo(payload); if (lostMessages > 0) { pld_size = snprintf (payload, PAYLOAD_SIZE, "%u", lostMessages); GwOutput.outputDataSend (mac_str, payload, pld_size, GwOutput_data_type::lostmessages); //DEBUG_INFO ("Published MQTT from %s: %s", mac_str, payload); } pld_size = snprintf (payload, PAYLOAD_SIZE, "{\"per\":%e,\"lostmessages\":%u,\"totalmessages\":%u,\"packetshour\":%.2f}", EnigmaIOTGateway.getPER ((uint8_t*)mac), EnigmaIOTGateway.getErrorPackets ((uint8_t*)mac), EnigmaIOTGateway.getTotalPackets ((uint8_t*)mac), EnigmaIOTGateway.getPacketsHour ((uint8_t*)mac)); GwOutput.outputDataSend (mac_str, payload, pld_size, GwOutput_data_type::status); //DEBUG_INFO ("Published MQTT from %s: %s", mac_str, payload); //free (payload); } void onDownlinkData (uint8_t* address, char* nodeName, control_message_type_t msgType, char* data, unsigned int len) { //char* buffer; char buffer[1024]; unsigned int bufferLen = len; if (nodeName) { DEBUG_INFO ("DL Message for %s. Type 0x%02X", nodeName, msgType); } else { DEBUG_INFO ("DL Message for " MACSTR ". Type 0x%02X", MAC2STR (address), msgType); } DEBUG_DBG ("Data: %.*s", len, data); //buffer = (char*)malloc (len + 1); sprintf (buffer, "%.*s", len, data); bufferLen++; if (!EnigmaIOTGateway.sendDownstream (address, (uint8_t*)buffer, bufferLen, msgType)) { DEBUG_ERROR ("Error sending esp_now message to " MACSTR, MAC2STR (address)); } else { DEBUG_DBG ("Esp-now message sent or queued correctly"); } //free (buffer); } void newNodeConnected (uint8_t* mac, uint16_t node_id, char* nodeName = NULL) { if (nodeName) { if (!GwOutput.newNodeSend (nodeName, node_id)) { DEBUG_WARN ("Error sending new node %s", nodeName); } else { DEBUG_DBG ("New node %s message sent", nodeName); } } else { char macstr[ENIGMAIOT_ADDR_LEN * 3]; mac2str (mac, macstr); if (!GwOutput.newNodeSend (macstr, node_id)) { DEBUG_WARN ("Error sending new node %s", macstr); } else { DEBUG_DBG ("New node %s message sent", macstr); } } } void nodeDisconnected (uint8_t* mac, gwInvalidateReason_t reason) { char macstr[ENIGMAIOT_ADDR_LEN * 3]; mac2str (mac, macstr); Serial.printf ("Node %s disconnected. Reason %u\n", macstr, reason); if (!GwOutput.nodeDisconnectedSend (macstr, reason)) { DEBUG_WARN ("Error sending node disconnected %s reason %d", macstr, reason); } else { DEBUG_DBG ("Node %s disconnected message sent. Reason %d", macstr, reason); } } void setup () { Serial.begin (115200); Serial.println (); Serial.println (); ets_timer_setfn (&connectionLedTimer, flashConnectionLed, (void*)&connectionLed); pinMode (BUILTIN_LED, OUTPUT); digitalWrite (BUILTIN_LED, HIGH); startConnectionFlash (100); if (!GwOutput.loadConfig ()) { DEBUG_WARN ("Error reading config file"); } EnigmaIOTGateway.setRxLed (BLUE_LED); EnigmaIOTGateway.setTxLed (RED_LED); EnigmaIOTGateway.onNewNode (newNodeConnected); EnigmaIOTGateway.onNodeDisconnected (nodeDisconnected); EnigmaIOTGateway.onWiFiManagerStarted (wifiManagerStarted); EnigmaIOTGateway.onWiFiManagerExit (wifiManagerExit); EnigmaIOTGateway.onDataRx (processRxData); EnigmaIOTGateway.begin (&Espnow_hal); #if CONNECT_TO_WIFI_AP == 1 WiFi.mode (WIFI_AP_STA); WiFi.begin (); EnigmaIOTGateway.configWiFiManager (); #else //WiFi.mode (WIFI_AP); #endif // CONNECT_TO_WIFI_AP WiFi.softAP (EnigmaIOTGateway.getNetworkName (), EnigmaIOTGateway.getNetworkKey ()); stopConnectionFlash (); DEBUG_INFO ("STA MAC Address: %s", WiFi.macAddress ().c_str ()); DEBUG_INFO ("AP MAC Address: %s", WiFi.softAPmacAddress ().c_str ()); DEBUG_INFO ("BSSID Address: %s", WiFi.BSSIDstr ().c_str ()); DEBUG_INFO ("IP address: %s", WiFi.localIP ().toString ().c_str ()); DEBUG_INFO ("AP IP address: %s", WiFi.softAPIP ().toString ().c_str ()); DEBUG_INFO ("WiFi Channel: %d", WiFi.channel ()); DEBUG_INFO ("WiFi SSID: %s", WiFi.SSID ().c_str ()); DEBUG_INFO ("Network Name: %s", EnigmaIOTGateway.getNetworkName ()); GwOutput.setDlCallback (onDownlinkData); GwOutput.begin (); #ifdef ESP32 //xTaskCreate (EnigmaIOTGateway_handle, "handle", 10000, NULL, 1, &xEnigmaIOTGateway_handle); //xTaskCreatePinnedToCore (EnigmaIOTGateway_handle, "handle", 4096, NULL, 0, &xEnigmaIOTGateway_handle, 1); //xTaskCreatePinnedToCore (GwOutput_handle, "gwoutput", 10000, NULL, 2, &gwoutput_handle, 1); #endif } void loop () { GwOutput.loop (); EnigmaIOTGateway.handle (); }
6d0574c8033b0dfeade13232583b10bf10ffe756
c24ec8c8d0ed754174ceb001c63e26e966490254
/WifiBluetoothService.h
412ce446f01c9e243cde4203848cbd5c7db3d0a5
[]
no_license
ErcanSencanoglu/MicroHome-Esp32-02.2021
7c5b1a4c4ac1a0d66e82c007ca51c8a0b43e058e
755c891534f4ed883f9e62220539891f595e5a49
refs/heads/main
2023-03-14T11:08:26.039400
2021-02-28T10:19:55
2021-02-28T10:19:55
343,073,365
0
0
null
null
null
null
UTF-8
C++
false
false
491
h
WifiBluetoothService.h
class WifiBluetoothService{ public: static void connectWifi(){ /*IPAddress ip =WiFi.localIP();//WiFi.localIP();// WiFi.softAPIP(); IPAddress gateway(192,168,1,1); IPAddress subnet(255,255,255,0); */ //IPAddress dns(8,8,8,8); WiFi.begin(Config::ssid,Config::password); //WiFi.config(ip,gateway, subnet); while(WiFi.status() != WL_CONNECTED){ delay(1000); Serial.println("Connecting to WiFi.."); } Serial.println(WiFi.localIP()); } };
f56e393aa70405f882f262ef42aef412a2ab86d7
746bbef0f5ab866864ce47f57fb31220816a91d7
/RX65x/RTK5_LOGGER/root_menu.hpp
b6a297b7e087853dd9463e715538b2db683f6d7f
[ "MIT", "BSD-3-Clause", "LicenseRef-scancode-free-unknown" ]
permissive
hirakuni45/RX
baf64286b70132eb41db7ed52c6a2f9b70cf0f45
679878b98d0c03597e16431e87e75a9a24f5c8d1
refs/heads/master
2023-05-04T13:27:26.894545
2023-04-18T13:54:06
2023-04-18T13:54:06
14,785,870
65
19
BSD-3-Clause
2023-09-14T01:41:49
2013-11-28T20:27:58
C++
UTF-8
C++
false
false
3,580
hpp
root_menu.hpp
#pragma once //=====================================================================// /*! @file @brief ルート・メニュー @author 平松邦仁 (hira@rvf-rc45.net) @copyright Copyright (C) 2018 Kunihito Hiramatsu @n Released under the MIT license @n https://github.com/hirakuni45/RX/blob/master/LICENSE */ //=====================================================================// #include "common/scene.hpp" #include "scenes_base.hpp" #include "common/format.hpp" #include "common/time.h" namespace app { //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// /*! @brief ルート・メニュー・クラス */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// class root_menu : public utils::scene { public: //-------------------------------------------------------------// /*! @brief コンストラクター */ //-------------------------------------------------------------// root_menu() { } //-------------------------------------------------------------// /*! @brief 初期化 */ //-------------------------------------------------------------// void init() override { at_scenes_base().at_menu().clear(); at_scenes_base().at_menu().set_gap(20); at_scenes_base().at_menu().set_space(vtx::spos(12, 8)); at_scenes_base().at_menu().add("Lap Time"); at_scenes_base().at_menu().add("Recall"); at_scenes_base().at_menu().add("Setup"); at_scenes_base().at_menu().add("G.P.S."); } //-------------------------------------------------------------// /*! @brief サービス */ //-------------------------------------------------------------// void service() override { at_scenes_base().at_render().clear(graphics::def_color::Black); { static const int16_t LOC_Y = scenes_base::RENDER::glc_type::height - 16; auto& nmea = at_scenes_base().at_nmea(); char tmp[32]; auto stn = nmea.get_satellite_num(); utils::sformat("%d", tmp, sizeof(tmp)) % stn; at_scenes_base().at_render().draw_text(vtx::spos(0, LOC_Y), tmp); if(stn > 0) { auto t = nmea.get_gmtime(); struct tm *m = localtime(&t); utils::sformat("%s %s %d %02d:%02d:%02d %4d\n", tmp, sizeof(tmp)) % get_wday(m->tm_wday) % get_mon(m->tm_mon) % static_cast<uint32_t>(m->tm_mday) % static_cast<uint32_t>(m->tm_hour) % static_cast<uint32_t>(m->tm_min) % static_cast<uint32_t>(m->tm_sec) % static_cast<uint32_t>(m->tm_year + 1900); } else { strcpy(tmp, "--- --- - --:--:-- ----"); } at_scenes_base().at_render().draw_text(vtx::spos(24, LOC_Y), tmp); } const auto& touch = at_scenes_base().at_touch(); bool t = touch.get_touch_num() == 1 ? true : false; const auto& p = touch.get_touch_pos(0); bool trg = at_scenes_base().at_menu().render(p.pos, t); if(trg) { auto pos = at_scenes_base().at_menu().get_pos(); // utils::format("Menu: %d\n") % static_cast<int>(pos); switch(pos) { case 0: change_scene(scene_id::laptime); break; case 1: change_scene(scene_id::recall); break; case 2: change_scene(scene_id::setup); break; case 3: change_scene(scene_id::gps); break; } } } //-------------------------------------------------------------// /*! @brief シーンの終了 */ //-------------------------------------------------------------// void exit() override { } }; }
2697c8f1fd3c0f82da70ab55bfc0990ece4ce619
60e8af170f4693c5e7dc6071f70d31364fef48f2
/massiveProject/updateitemdialogue.cpp
cad495d5815fe286a3b4316074a83844cca0ca35
[]
no_license
AzrealWenttoMarket/CS106
414c8f8a6f76c968491e99d7b8621de6d6cd898f
64a1f4dbcbac757dcb69279d1d0d019ccd336e1b
refs/heads/main
2023-08-19T06:28:04.635987
2021-10-05T06:13:00
2021-10-05T06:13:00
410,766,853
0
0
null
null
null
null
UTF-8
C++
false
false
285
cpp
updateitemdialogue.cpp
#include "updateitemdialogue.h" #include "ui_updateitemdialogue.h" UpdateItemDialogue::UpdateItemDialogue(QWidget *parent) : QDialog(parent), ui(new Ui::UpdateItemDialogue) { ui->setupUi(this); } UpdateItemDialogue::~UpdateItemDialogue() { delete ui; }
98394e098f5d00f4c5c8c9b531b11ea78c778658
292e5e486d217173c20d9639089ddb84a42b3c4e
/DataStructureAndAlgorithm/LinearList/chain.hpp
5f378389fe037c6e8edcb07794ad2471607b600b
[]
no_license
AKL-FIRE/DataStructureAndAlgorithm
86ade6893195ff3e702a11af739364ec20936090
08c0d13fb4c8849275cbe56e2d9ca3bb2814efc7
refs/heads/master
2021-05-10T16:39:36.273591
2020-02-12T05:20:41
2020-02-12T05:20:41
118,583,094
0
0
null
null
null
null
UTF-8
C++
false
false
5,582
hpp
chain.hpp
// // chain.hpp // DataStructureAndAlgorithm // // Created by Apple on 23/01/2018. // Copyright © 2018 lcy. All rights reserved. // #ifndef chain_hpp #define chain_hpp #include "linearList.hpp" template <typename T> struct chainNode { T element; chainNode<T>* next; chainNode() {} chainNode(const T &element) {this->element = element;} chainNode(const T &element, chainNode<T> *next) {this->element = element; this->next = next;} }; template <typename T> class chain : virtual public linearList<T> { public: chain(int initialCapacity = 10); chain(const chain<T>&); ~chain(); bool empty() const {return listSize == 0;} int size() const {return listSize;} T& get(int theIndex) const; int indexOf(const T&) const; template <typename Comp> int indexOf(const T&, Comp equal) const; void erase(int theIndex); void insert(int theIndex,const T &theElement); void output(std::ostream &out) const; class iterator { public: iterator(chainNode<T> *theNode = nullptr) {node = theNode;} T& operator*() const {return node->element;} T* operator->() const {return &node->element;} iterator& operator++() {node = node->next; return *this;} //++node iterator operator++(int) {iterator old = *this; node = node->next; return old;} //node++ bool operator!=(const iterator right) const {return node != right.node;} bool operator==(const iterator right) const {return node == right.node;} protected: chainNode<T> *node; }; iterator begin() {return iterator(firstNode);} //iterator end() {return iterator(nullptr);} protected: void checkIndex(int theIndex) const; chainNode<T> *firstNode; int listSize; }; template <typename T> chain<T>::chain(int initialCapacity) { if(initialCapacity < 1) { std::strstream s; s << "Initial capacity = " << initialCapacity << "must be > 0."; throw illegalParameterValue(s.str()); } firstNode = nullptr; listSize = 0; } template <typename T> void chain<T>::checkIndex(int theIndex) const { if(theIndex < 0 || theIndex >= listSize) { std::strstream s; s << "index = " << theIndex << " size = " << listSize; throw illegalParameterValue(s.str()); } } template <typename T> chain<T>::chain(const chain<T> &theList) { listSize = theList.listSize; if(listSize == 0) { firstNode = nullptr; return; } chainNode<T> *sourceNode = theList.firstNode; firstNode = new chainNode<T>(sourceNode->element); sourceNode = sourceNode->next; chainNode<T> *targetNode = firstNode; while(sourceNode != nullptr) { targetNode->next = new chainNode<T>(sourceNode->element); targetNode = targetNode->next; sourceNode = sourceNode->next; } targetNode->next = nullptr; } template <typename T> chain<T>::~chain() { while(firstNode != nullptr) { chainNode<T> *nextNode = firstNode->next; delete firstNode; firstNode = nextNode; } } template <typename T> T& chain<T>::get(int theIndex) const { checkIndex(theIndex); chainNode<T> *currentNode = firstNode; for(int i = 0; i < theIndex; i++) currentNode = currentNode->next; return currentNode->element; } template <typename T> int chain<T>::indexOf(const T &theElement) const { chainNode<T> *currentNode = firstNode; int index = 0; while(currentNode != nullptr && currentNode->element != theElement) { currentNode = currentNode->next; index++; } if(currentNode == nullptr) return -1; else return index; } template<typename T> template<typename Comp> int chain<T>::indexOf(const T &theElement, Comp equal) const { chainNode<T> *currentNode = firstNode; int index = 0; while(currentNode != nullptr && !equal(currentNode->element, theElement)) { currentNode = currentNode->next; index++; } if(currentNode == nullptr) return -1; else return index; } template <typename T> void chain<T>::erase(int theIndex) { checkIndex(theIndex); chainNode<T> *deleteNode; if(theIndex == 0) { deleteNode = firstNode; firstNode = firstNode->next; }else { chainNode<T> *p = firstNode; for(int i = 0; i < theIndex - 1; i++) p = p->next; deleteNode = p->next; p->next = p->next->next; } listSize--; delete deleteNode; } template <typename T> void chain<T>::insert(int theIndex, const T &theElement) { if(theIndex < 0 || theIndex > listSize) { std::strstream s; s << "index = " << theIndex << " size = " << listSize; throw illegalParameterValue(s.str()); } if(theIndex == 0) firstNode = new chainNode<T>(theElement, firstNode); else { chainNode<T> *p = firstNode; for(int i = 0; i < theIndex - 1; i++) p = p->next; p->next = new chainNode<T>(theElement, p->next); } listSize++; } template <typename T> void chain<T>::output(std::ostream &out) const { for(chainNode<T> *currentNode = firstNode; currentNode != nullptr; currentNode = currentNode->next) out << currentNode->element << " "; } template <typename T> std::ostream& operator<<(std::ostream &out, const chain<T> &x) { x.output(out); return out; } #endif /* chain_hpp */
7bdf352d3f1d8b9d0ee9bd8d1826b9de6852b9ca
24004e1c3b8005af26d5890091d3c207427a799e
/Win32/NXOPEN/NXOpen/CAM_InspectionLinearMoveToPointBuilder.hxx
d0fc75965fb432e64cdb02b9517e7b8895a51c96
[]
no_license
15831944/PHStart
068ca6f86b736a9cc857d7db391b2f20d2f52ba9
f79280bca2ec7e5f344067ead05f98b7d592ae39
refs/heads/master
2022-02-20T04:07:46.994182
2019-09-29T06:15:37
2019-09-29T06:15:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,550
hxx
CAM_InspectionLinearMoveToPointBuilder.hxx
#ifndef NXOpen_CAM_INSPECTIONLINEARMOVETOPOINTBUILDER_HXX_INCLUDED #define NXOpen_CAM_INSPECTIONLINEARMOVETOPOINTBUILDER_HXX_INCLUDED //-------------------------------------------------------------------------- // Header for C++ interface to JA API //-------------------------------------------------------------------------- // // Source File: // CAM_InspectionLinearMoveToPointBuilder.ja // // Generated by: // apiwrap // // WARNING: // This file is automatically generated - do not edit by hand // #ifdef _MSC_VER #pragma once #endif #include <NXOpen/NXDeprecation.hxx> #include <vector> #include <NXOpen/NXString.hxx> #include <NXOpen/Callback.hxx> #include <NXOpen/CAM_InspectionMoveBuilder.hxx> #include <NXOpen/CAM_InspectionLinearMoveToPointBuilder.hxx> #include <NXOpen/SelectObject.hxx> #include <NXOpen/libnxopencpp_cam_exports.hxx> #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4996) #endif #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif namespace NXOpen { namespace CAM { class InspectionLinearMoveToPointBuilder; } namespace CAM { class InspectionMoveBuilder; } class Point; class SelectPoint; namespace CAM { class _InspectionLinearMoveToPointBuilderBuilder; class InspectionLinearMoveToPointBuilderImpl; /** Represents the builder for the CMM Inspection sub-operation Linear Move To Point. <br> To create a new instance of this class, use @link CAM::InspectionMoveCollection::CreateInspectionLinearMoveToPointBuilder CAM::InspectionMoveCollection::CreateInspectionLinearMoveToPointBuilder@endlink <br> <br> Created in NX7.0.0. <br> */ class NXOPENCPP_CAMEXPORT InspectionLinearMoveToPointBuilder : public CAM::InspectionMoveBuilder { /** specifies the method used to define a point */ public: enum PointTypeEnums { PointTypeEnumsExistingPoint/** Select an existing point */, PointTypeEnumsDeltaXYZ/** Enter in a delta value from a point */, PointTypeEnumsPointConstructor/** Use the Point Constructor */ }; private: InspectionLinearMoveToPointBuilderImpl * m_inspectionlinearmovetopointbuilder_impl; private: friend class _InspectionLinearMoveToPointBuilderBuilder; protected: InspectionLinearMoveToPointBuilder(); public: ~InspectionLinearMoveToPointBuilder(); /**Returns the point type enum <br> Created in NX7.5.0. <br> <br> License requirements : None */ public: NXOpen::CAM::InspectionLinearMoveToPointBuilder::PointTypeEnums PointTypeEnum ( ); /**Sets the point type enum <br> Created in NX7.5.0. <br> <br> License requirements : insp_programming ("INSPECTION PROGRAMMING") */ public: void SetPointTypeEnum ( NXOpen::CAM::InspectionLinearMoveToPointBuilder::PointTypeEnums pointTypeEnum /** pointtypeenum */ ); /**Returns the point <br> Created in NX7.0.0. <br> <br> License requirements : None */ public: NXOpen::Point * TargetPoint ( ); /**Sets the point <br> Created in NX7.0.0. <br> <br> License requirements : None */ public: void SetTargetPoint ( NXOpen::Point * point /** point */ ); /**Returns the select existing point <br> Created in NX7.5.0. <br> <br> License requirements : None */ public: NXOpen::SelectPoint * SelectExistingPoint ( ); /**Returns the point X coordinate <br> Created in NX7.5.0. <br> <br> License requirements : None */ public: double PointX ( ); /**Sets the point X coordinate <br> Created in NX7.5.0. <br> <br> License requirements : insp_programming ("INSPECTION PROGRAMMING") */ public: void SetPointX ( double pointX /** pointx */ ); /**Returns the point Y coordinate <br> Created in NX7.5.0. <br> <br> License requirements : None */ public: double PointY ( ); /**Sets the point Y coordinate <br> Created in NX7.5.0. <br> <br> License requirements : insp_programming ("INSPECTION PROGRAMMING") */ public: void SetPointY ( double pointY /** pointy */ ); /**Returns the point Z coordinate <br> Created in NX7.5.0. <br> <br> License requirements : None */ public: double PointZ ( ); /**Sets the point Z coordinate <br> Created in NX7.5.0. <br> <br> License requirements : insp_programming ("INSPECTION PROGRAMMING") */ public: void SetPointZ ( double pointZ /** pointz */ ); }; } } #ifdef _MSC_VER #pragma warning(pop) #endif #ifdef __GNUC__ #ifndef NX_NO_GCC_DEPRECATION_WARNINGS #pragma GCC diagnostic warning "-Wdeprecated-declarations" #endif #endif #undef EXPORTLIBRARY #endif
656aeb611a816880b0b77b4f75e8a77aec64fb92
8888fb4af4000f02903299bda0ecc954c402452a
/BOJ/1697.cpp
5e000cf47a9dc75ad2264462b6d84d968ce7b248
[ "MIT" ]
permissive
ReinforceIII/Algorithm
48122e826c60a433cdfb5bb1283db3b3d1be64d1
355f6e19f8deb6a76f82f5283d7c1987acd699a6
refs/heads/master
2020-07-26T03:57:36.567702
2019-09-16T11:46:02
2019-09-16T11:46:02
208,526,939
0
0
null
null
null
null
UTF-8
C++
false
false
910
cpp
1697.cpp
/* 1697 숨바꼭질 */ #include <iostream> #include <string> #include <algorithm> #include <vector> #include <queue> #include <cstring> #define MAX_SIZE 100001 using namespace std; int resolve[MAX_SIZE]; int main() { int n,k; cin>>n>>k; queue<int> q; memset(resolve,-1,sizeof(resolve)); q.push(n); resolve[n] = 0; while(!q.empty()) { int now = q.front(); q.pop(); //1. 순간이동 if(now*2 < MAX_SIZE) { if(resolve[now*2] == -1) { q.push(now*2); resolve[now*2] = resolve[now] + 1; } } //2. 뒤로한칸 if(now -1 >= 0) { if(resolve[now-1] == -1) { q.push(now -1); resolve[now-1] = resolve[now] + 1; } } //3. 앞으로 한칸 if(now +1 < MAX_SIZE) { if(resolve[now+1] == -1) { q.push(now + 1); resolve[now+1] = resolve[now] + 1; } } } cout<<resolve[k]; return 0; }
5cc2742e78148a90c4262dbd9e1bfd0704769180
b6bbf84f88a876809777c0a84ea1ec6ffbc9133b
/fixed report/src/a11/main.h
5a30c27f02865678076e9c279234ef0dd0a08c70
[]
no_license
franksnightmare/c-3week2
11fd22df1111b5d5f3b4030164bf0e5633b87448
d04cc4e1e3db727e7282c037c538ba64edf5f1c3
refs/heads/master
2021-01-23T07:51:18.358991
2017-02-08T14:48:20
2017-02-08T14:48:20
80,518,072
0
0
null
null
null
null
UTF-8
C++
false
false
424
h
main.h
#ifndef MAIN_H #define MAIN_H template <size_t constant, size_t mask, size_t power> struct PrintBin { enum { value = power * ((constant & mask) == mask) + PrintBin<constant, mask << 1, power * 10>::value }; }; template <size_t constant, size_t power> struct PrintBin<constant, 0, power> { enum { value = 0 }; }; template <size_t constant> struct Bin { enum { value = PrintBin<constant, 1, 1>::value }; }; #endif
03108189c3bfa95fde91dc0ab0cc7914f09dcb10
78e2fb22adb4f2139a84d4798cd35b614cbe0b62
/MusicChallenge/candidate_libs/MIDITrail (2)/MIDITrail/MTAboutDlg.cpp
3d7b21575f6bb0fe21b112c3b6eb99c456091dd8
[ "BSD-3-Clause" ]
permissive
leomrocha/musicapps
c0a9277a65d4fdba2d02b245a83afc3a25d8d053
ea59fef71f266603911a445e5dcca23391b76a4f
refs/heads/master
2020-03-13T16:51:09.134309
2018-10-13T20:41:25
2018-10-13T20:41:25
131,207,250
0
1
null
null
null
null
SHIFT_JIS
C++
false
false
4,401
cpp
MTAboutDlg.cpp
//****************************************************************************** // // MIDITrail / MTAboutDlg // // バージョン情報ダイアログクラス // // Copyright (C) 2010-2014 WADA Masashi. All Rights Reserved. // //****************************************************************************** #include "StdAfx.h" #include "YNBaseLib.h" #include "MIDITrailVersion.h" #include "MTAboutDlg.h" using namespace YNBaseLib; //****************************************************************************** // ウィンドウプロシージャ制御用パラメータ設定 //****************************************************************************** MTAboutDlg* MTAboutDlg::m_pThis = NULL; //****************************************************************************** // コンストラクタ //****************************************************************************** MTAboutDlg::MTAboutDlg(void) { m_pThis = this; } //****************************************************************************** // デストラクタ //****************************************************************************** MTAboutDlg::~MTAboutDlg(void) { } //****************************************************************************** // ウィンドウプロシージャ //****************************************************************************** INT_PTR CALLBACK MTAboutDlg::_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { return m_pThis->_WndProcImpl(hWnd, message, wParam, lParam); } //****************************************************************************** // ウィンドウプロシージャ:実装 //****************************************************************************** INT_PTR MTAboutDlg::_WndProcImpl( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { int result = 0; BOOL bresult = FALSE; UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_INITDIALOG: result = _OnInitDlg(hDlg); if (result != 0) goto EXIT; bresult = TRUE; break; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); bresult = TRUE; } break; } EXIT:; return (INT_PTR)bresult; } //****************************************************************************** // 表示 //****************************************************************************** int MTAboutDlg::Show( HWND hParentWnd ) { int result = 0; INT_PTR dresult = 0; HINSTANCE hInstance = NULL; //アプリケーションインスタンスハンドルを取得 hInstance = (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hParentWnd, GWLP_HINSTANCE); if (hInstance == NULL) { result = YN_SET_ERR("Windows API error.", GetLastError(), 0); goto EXIT; } //ダイアログ表示 dresult = DialogBox( hInstance, //インスタンスハンドル MAKEINTRESOURCE(IDD_ABOUTBOX), //ダイアログボックステンプレート hParentWnd, //親ウィンドウハンドル _WndProc //ダイアログボックスプロシージャ ); if ((dresult == 0) || (dresult == -1)) { result = YN_SET_ERR("Windows API error.", GetLastError(), 0); goto EXIT; } EXIT:; return result; } //****************************************************************************** // ダイアログ表示直前初期化 //****************************************************************************** int MTAboutDlg::_OnInitDlg( HWND hDlg ) { int result = 0; BOOL bresult = FALSE; TCHAR* pVersion = NULL; TCHAR* pCopyright = NULL; //バージョン文字列 #ifdef _WIN64 //64bit pVersion = MIDITRAIL_VERSION_STRING_X64; #else //32bit pVersion = MIDITRAIL_VERSION_STRING_X86; #endif //コピーライト文字列 pCopyright = MIDITRAIL_COPYRIGHT; //バージョン文字列設定 bresult = SetWindowText(GetDlgItem(hDlg, IDC_TEXT_VERSION), pVersion); if (!bresult) { result = YN_SET_ERR("Windows API error.", GetLastError(), 0); goto EXIT; } //コピーライト文字列設定 bresult = SetWindowText(GetDlgItem(hDlg, IDC_TEXT_COPYRIGHT), pCopyright); if (!bresult) { result = YN_SET_ERR("Windows API error.", GetLastError(), 0); goto EXIT; } EXIT:; return result; }
a927a7c06a8f4cacc187e65509594fc487b92312
74ff6c167963a0d78b43a63d2da73cfcc8a1ff7a
/AnalyseurXSLT/documentxsl.cpp
7a5f0af4015b623d1e10632ef2897b50ec327386
[]
no_license
Hexaflou/ProcesseurXML
09b918f971ac986d67d7bd6ef07c192f4a1c28d3
e4c07cb83c673979ff42e8eb010e5bf4a9d147f9
refs/heads/master
2021-01-10T21:16:52.273146
2012-11-14T08:35:49
2012-11-14T08:35:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
66
cpp
documentxsl.cpp
#include <string> #include <iostream> #include "documentxsl.h"
29f7ff147371f10dcee7b1ed82ed19e6726f1a50
8cf9be3830ffecfad9102f5f293e5d340a761d4c
/span.h
e31d92e68fffbbc38385e77aa6af7ce3352acafc
[]
no_license
larrynow/NCMalloc
81a8325d72d877d51269192c1ce07aacb18e5f36
6ae73748e8d25086ebe1e04ac103673c0079e519
refs/heads/master
2022-12-24T08:29:07.685705
2020-09-24T13:03:28
2020-09-24T13:03:28
298,279,162
0
0
null
null
null
null
UTF-8
C++
false
false
1,224
h
span.h
#ifndef _NC_MALLOC_SPAN_H_ #define _NC_MALLOC_SPAN_H_ #include "nc_malloc.h" #include<set> namespace NCMalloc { // struct Span for a string of pages. // Span may exisits in span list(in centralFreeList) or page heap. struct Span { PageID start;// start page number. PageNum length;// pages num in span. Span* next; Span* prev; union { void* objects;// free objects. char iter_space[sizeof(SpanSet::iterator)];//Iterator point back to SpanSet. }; unsigned int refcount : 16;// How many used objects in this span. unsigned int sizeClass : 8; unsigned int status : 2; // Span enum SpanStatus { IN_USE, ON_NORMAL_LIST, ON_RETURNED_LIST, IN_HEAP }; }; /*PageHeap*/ // Use set to store large spans. struct SpanPtr { explicit SpanPtr(Span* s) : span(s), length(s->length) {} Span* span; PageNum length; }; // Compare span by their length(less). struct SpanPtrCompare { bool operator()(SpanPtr a, SpanPtr b) const { if (a.length < b.length) return true; if (a.length > b.length) return false; return a.span->start < b.span->start; //Choose spans with samller adress. } }; using SpanSet = std::set<SpanPtr, SpanPtrCompare>; } #endif // !_NC_MALLOC_SPAN_H_
5f17d8944700fde6ed4a1d6c7affec63a6a9158c
26f7d65fab41986228344ed9be221b870d8b1efa
/Models/include/class.h
243aa49a03748eed006eef4af79d93755cd39cc4
[ "MIT" ]
permissive
jeremydumais/TeacherHelper
a01d1c8bd5f864fd0bc95238fd013fc1223e0503
f90db9c18a74ca3020c26d79eb2160a0c4e53efb
refs/heads/master
2023-03-27T07:43:30.418046
2021-03-28T17:04:24
2021-03-28T17:04:24
260,787,000
0
0
MIT
2021-03-28T15:14:47
2020-05-02T22:33:02
C++
UTF-8
C++
false
false
953
h
class.h
#pragma once #include "school.h" #include "student.h" #include <list> #include <string> #ifdef _WIN32 #ifdef MODELS_EXPORTS #define CLASS_API __declspec(dllexport) #else #define CLASS_API __declspec(dllimport) #endif #else #define CLASS_API #endif class CLASS_API Class { public: Class(const std::string &name, const School &school); Class(size_t id, const std::string &name, const School &school); size_t getId() const; const std::string &getName() const; const School &getSchool() const; const std::list<Student> &getMembers() const; void setName(const std::string &name); void setSchool(const School &school); void addMember(const Student &student); void removeMember(const Student &student); void clearMembers(); private: size_t id; std::string name; School school; std::list<Student> members; };
0a5e515b0a8ac9fdc3eb16c29867c1e592d7ebb0
851d12adffa6dcdc85816c2ee6f6af129c5542b6
/TDEngine2/source/ecs/CEntityManager.cpp
5c12a3d72c8350d7b59e1da669c52d241d9d907d
[ "Apache-2.0" ]
permissive
bnoazx005/TDEngine2
775c018e1aebfe4a42f727e132780e52a80f6a96
ecc1683aac5df5b1581a56b6d240893f5c79161b
refs/heads/master
2023-08-31T08:07:19.288783
2022-05-12T16:41:06
2022-05-12T16:45:02
149,013,665
6
2
null
null
null
null
UTF-8
C++
false
false
6,384
cpp
CEntityManager.cpp
#include "../../include/ecs/CEntityManager.h" #include "../../include/ecs/CEntity.h" #include "../../include/ecs/CTransform.h" #include "../../include/core/IEventManager.h" #include "../../include/editor/CPerfProfiler.h" namespace TDEngine2 { CEntityManager::CEntityManager() : CBaseObject(), mpEventManager(nullptr) { } E_RESULT_CODE CEntityManager::Init(IEventManager* pEventManager, IComponentManager* pComponentManager) { std::lock_guard<std::mutex> lock(mMutex); if (mIsInitialized) { return RC_FAIL; } if (!pComponentManager || !pEventManager) { return RC_INVALID_ARGS; } mpComponentManager = pComponentManager; mpEventManager = pEventManager; mNextIdValue = 0; mIsInitialized = true; return RC_OK; } E_RESULT_CODE CEntityManager::_onFreeInternal() { E_RESULT_CODE result = DestroyAllImmediately(); /// \note Remove all reserved entities while (!mDestroyedEntities.empty()) { if (CEntity* pReservedEntity = mDestroyedEntities.front()) { pReservedEntity->Free(); } mDestroyedEntities.pop_front(); } return result; } CEntity* CEntityManager::Create() { std::lock_guard<std::mutex> lock(mMutex); return _createEntity(_constructDefaultEntityName(mNextIdValue)); } CEntity* CEntityManager::Create(const std::string& name) { std::lock_guard<std::mutex> lock(mMutex); return _createEntity(name); } E_RESULT_CODE CEntityManager::Destroy(CEntity* pEntity) { if (!pEntity) { return RC_INVALID_ARGS; } E_RESULT_CODE result = mpComponentManager->RemoveComponents(pEntity->GetId()); if (result != RC_OK) { return result; } TOnEntityRemovedEvent onEntityRemoved; { std::lock_guard<std::mutex> lock(mMutex); TEntityId id = pEntity->GetId(); onEntityRemoved.mRemovedEntityId = id; mActiveEntities[static_cast<U32>(id)] = nullptr; mDestroyedEntities.push_back(pEntity); mEntitiesHashTable.erase(id); } mpEventManager->Notify(&onEntityRemoved); return RC_OK; } E_RESULT_CODE CEntityManager::DestroyImmediately(CEntity* pEntity) { std::lock_guard<std::mutex> lock(mMutex); return _destroyImmediatelyInternal(pEntity); } E_RESULT_CODE CEntityManager::DestroyAllEntities() { std::lock_guard<std::mutex> lock(mMutex); E_RESULT_CODE result = RC_OK; for (CEntity* pEntity : mActiveEntities) { if (!pEntity) { continue; } if ((result = Destroy(pEntity)) != RC_OK) { return result; } } return RC_OK; } E_RESULT_CODE CEntityManager::DestroyAllImmediately() { std::lock_guard<std::mutex> lock(mMutex); E_RESULT_CODE result = RC_OK; for (CEntity* pEntity : mActiveEntities) { if (!pEntity) { continue; } if ((result = _destroyImmediatelyInternal(pEntity)) != RC_OK) { return result; } } return RC_OK; } IComponent* CEntityManager::AddComponent(TEntityId entityId, TypeId componentTypeId) { std::lock_guard<std::mutex> lock(mMutex); IComponent* pComponentInstance = mpComponentManager->CreateComponent(entityId, componentTypeId); _notifyOnAddComponent(entityId, componentTypeId); return pComponentInstance; } E_RESULT_CODE CEntityManager::RemoveComponents(TEntityId id) { std::lock_guard<std::mutex> lock(mMutex); return mpComponentManager->RemoveComponents(id); } std::vector<IComponent*> CEntityManager::GetComponents(TEntityId id) const { std::lock_guard<std::mutex> lock(mMutex); return mpComponentManager->GetComponents(id); } CEntity* CEntityManager::GetEntity(TEntityId entityId) const { TDE2_PROFILER_SCOPE("CEntityManager::GetEntity"); std::lock_guard<std::mutex> lock(mMutex); TEntitiesHashTable::const_iterator entityIter = mEntitiesHashTable.find(entityId); if (entityIter == mEntitiesHashTable.cend()) { return nullptr; } return mActiveEntities[(*entityIter).second]; } std::string CEntityManager::_constructDefaultEntityName(U32 id) const { return std::move(std::string("Entity").append(std::to_string(id))); } CEntity* CEntityManager::_createEntity(const std::string& name) { E_RESULT_CODE result = RC_OK; TEntityId id = TEntityId(mNextIdValue); CEntity* pEntity = CreateEntity(id, name, this, result); if (result != RC_OK) { return nullptr; } size_t currStorageSize = mActiveEntities.size(); if (mNextIdValue + 1 >= currStorageSize) { mActiveEntities.resize(currStorageSize + 10); /// \todo 10 is just a magic constant that should be replaced in some way } TOnEntityCreatedEvent onEntityCreated; onEntityCreated.mCreatedEntityId = id; mEntitiesHashTable[id] = mNextIdValue; mActiveEntities[mNextIdValue++] = pEntity; /// create basic component CTransform CTransform* pTransform = pEntity->AddComponent<CTransform>(); pTransform->SetOwnerId(id); mpEventManager->Notify(&onEntityCreated); return pEntity; } E_RESULT_CODE CEntityManager::_destroyImmediatelyInternal(CEntity* pEntity) { if (!pEntity) { return RC_INVALID_ARGS; } E_RESULT_CODE result = mpComponentManager->RemoveComponents(pEntity->GetId()); if (result != RC_OK) { return result; } TEntityId id = pEntity->GetId(); TOnEntityRemovedEvent onEntityRemoved; onEntityRemoved.mRemovedEntityId = id; if (RC_OK != (result = pEntity->Free())) /// \note Release the memory { return result; } mActiveEntities[static_cast<U32>(id)] = nullptr; mEntitiesHashTable.erase(id); mpEventManager->Notify(&onEntityRemoved); return RC_OK; } void CEntityManager::_notifyOnAddComponent(TEntityId entityId, TypeId componentTypeId) { TOnComponentCreatedEvent onComponentCreated; onComponentCreated.mEntityId = entityId; onComponentCreated.mCreatedComponentTypeId = componentTypeId; mpEventManager->Notify(&onComponentCreated); } void CEntityManager::_notifyOnRemovedComponent(TEntityId entityId, TypeId componentTypeId) { TOnComponentRemovedEvent onComponentRemoved; onComponentRemoved.mEntityId = entityId; onComponentRemoved.mRemovedComponentTypeId = componentTypeId; mpEventManager->Notify(&onComponentRemoved); } CEntityManager* CreateEntityManager(IEventManager* pEventManager, IComponentManager* pComponentManager, E_RESULT_CODE& result) { return CREATE_IMPL(CEntityManager, CEntityManager, result, pEventManager, pComponentManager); } }
bb768f87d28cd50405c1161616fb701ab291a827
3d85474e3ca2c9de7941477d0e06d7bdb867e6af
/115-distinct-subsequences.cpp
88193e5920c518e7497f32fd00dc933077dfe366
[ "MIT" ]
permissive
nave7693/leetcode
9dd7c14d27e8f3abc974a50028709c236bdc03ef
8ff388cb17e87aa9053eaed3b84e7dc2be3e2e49
refs/heads/master
2020-05-22T08:02:27.292507
2017-08-28T18:20:46
2017-08-28T18:20:46
51,724,795
0
0
null
null
null
null
UTF-8
C++
false
false
1,181
cpp
115-distinct-subsequences.cpp
// https://leetcode.com/problems/distinct-subsequences class Solution { public: int numDistinct(string s, string t) { int lens = s.length(); int lent = t.length(); vector<vector<int>> dp(lent+1, vector<int>(lens+1, 0)); // For an empty t, any s would need to delete all its characters, if any, to achieve t for (int j = 0; j <= lens; j++) { dp[0][j] = 1; } for (int j = 1; j <= lens; j++) { for (int i = 1; i <= lent; i++) { dp[i][j] = dp[i][j-1] + (t[i-1] == s[j-1] ? dp[i-1][j-1] : 0); } } return dp[lent][lens]; } }; // space-optimized class Solution { public: int numDistinct(string s, string t) { int m = t.length(), n = s.length(); vector<int> cur(m + 1, 0); cur[0] = 1; for (int j = 1; j <= n; j++) { int pre = 1; for (int i = 1; i <= m; i++) { int temp = cur[i]; cur[i] = cur[i] + (t[i - 1] == s[j - 1] ? pre : 0); pre = temp; } } return cur[m]; } };
3c8e9514b21cee4aeed3d9b724d77960a02f2a48
1cf3c0bda1eeec186c21363ee514957d4215c9cb
/backgrounds/complete_search/subset_sum_backtracking_r1.cpp
ea7df1f9211a33e855c9cc93e4ba35f9085f2189
[]
no_license
jaguarcode/algorithms
5aeb6d6a46e6658a9fbc04186313f46d4135ac86
222b65dcfb245292ad10663039a8406871cb2a43
refs/heads/master
2023-05-04T08:09:24.246394
2021-05-27T23:32:40
2021-05-27T23:32:40
307,350,248
0
0
null
null
null
null
UTF-8
C++
false
false
1,110
cpp
subset_sum_backtracking_r1.cpp
#include <bits/stdc++.h> using namespace std; static int total_nodes; void printSubset(int a[], int size) { for(int i = 0; i < size; i++) cout << a[i] << " "; cout << "\n"; } void subsetSum(int s[], int t[], size_t s_size, size_t t_size, int sum, int ite, const int target_sum) { total_nodes++; if(target_sum == sum) { printSubset(t, t_size); subsetSum(s, t, s_size, t_size-1, sum-s[ite], ite+1, target_sum); return; } else { for(int i = ite; i < s_size; i++) { t[t_size] = s[i]; subsetSum(s, t, s_size, t_size+1, sum+s[i], i+1, target_sum); } } } void generateSubsets(int s[], int size, int target_num) { int *tuple_vector = new int[200]; subsetSum(s, tuple_vector, size, 0, 0, 0, target_num); free(tuple_vector); } int main() { ios::sync_with_stdio(false); cin.tie(0); int weights[] = { 10, 7, 5, 18, 12, 20, 15 }; int size = sizeof(weights) / sizeof(weights[0]); generateSubsets(weights, size, 35); cout << "Nodes generated " << total_nodes << "\n"; return 0; }
9c4848be70d5f45dd9d6937bb6cebc178d9d23d6
f8284997c161c6eba896da4d479577608d83e74a
/src/hamming/compute.cpp
3de67799f42c327d80234de86fbbabce75d507ba
[]
no_license
vsai121/Privacy-preserving-biometrics
bb35fe6f3bca4b7496d9030cd2ea622e4ee82c5d
17647df37e97af8011d86ef3ca32ed1dda03f17c
refs/heads/master
2020-04-26T03:38:12.645415
2019-04-05T18:59:14
2019-04-05T18:59:14
173,273,575
0
1
null
null
null
null
UTF-8
C++
false
false
3,127
cpp
compute.cpp
#include <cstring> #include <helib/EncryptedArray.h> #include <helib/FHE.h> #include <fstream> #include <NTL/ZZX.h> #include <iostream> #include <vector> using namespace std; //script to read ciphertexts and compute Ctxt hamming_dist(Ctxt enc1, Ctxt enc2, int numbits) { Ctxt enc11 = enc1; Ctxt enc22 = enc2; NTL::ZZX con; con.SetLength(numbits); for(int i=0;i<numbits;i++) con[i] = 1; enc11.multByConstant(con); enc22.multByConstant(con); Ctxt hammingenc = enc1; hammingenc *= enc2; hammingenc.multByConstant(NTL::ZZX(2)); hammingenc -= enc11; hammingenc -= enc22; hammingenc.multByConstant(NTL::ZZX(-1)); return hammingenc; } int main(int argc, char **argv) { // Read the public key from disk fstream pubKeyFile("pubkey.txt", fstream::in); assert(pubKeyFile.is_open()); unsigned long m, p, r; vector<long> gens, ords; int nslots = 2; readContextBase(pubKeyFile, m, p, r, gens, ords); FHEcontext context(m, p, r, gens, ords); pubKeyFile >> context; FHEPubKey publicKey(context); pubKeyFile >> publicKey; pubKeyFile.close(); std::cout << "Read cipher 1" << std::endl; fstream ctext1file("ciphertext.txt", fstream::in); int numd1; seekPastChar(ctext1file, '['); ctext1file >> numd1; seekPastChar(ctext1file, ']'); /* vector<Ctxt> client_des; for(int i = 0; i < numd1; i++) { Ctxt des(publicKey); ctext1file >> des; client_des.push_back(des); } */ std::unique_ptr<Ctxt> cdesc[numd1]; for(int i = 0; i < numd1; i++) { cdesc[i].reset(new Ctxt(publicKey)); ctext1file >> *cdesc[i]; } ctext1file.close(); std::cout << "Read cipher 1" << std::endl; fstream ctext2file("ciphertext2.txt", fstream::in); int numd2; seekPastChar(ctext2file, '['); ctext2file >> numd2; seekPastChar(ctext2file, ']'); std::unique_ptr<Ctxt> sdesc[numd1]; for(int i = 0; i < numd2; i++) { sdesc[i].reset(new Ctxt(publicKey)); ctext2file >> *sdesc[i]; } ctext2file.close(); /* std::cout << "Read cipher" << std::endl; fstream ctext2file("ciphertext2.txt", fstream::in); seekPastChar(ctext2file, '['); int numd2; ctext2file >> numd2; seekPastChar(ctext2file, ']'); vector<Ctxt> server_des; for(int i = 0; i < numd2; i++) { Ctxt des(publicKey); ctext2file >> des; server_des.push_back(des); } ctext2file.close(); */ /* std::cout << "Started computing" << std::endl; vector<Ctxt> computed; for(int i=0; i<numd1; i++) { Ctxt c1 = client_des.at(i); for(int j=0; j<numd2; j++) { computed.push_back(hamming_dist(c1, server_des.at(j), 256)); } } fstream computed2file("computed.txt", fstream::out); computed2file << "[" << numd1 << "]" << endl; computed2file << "[" << numd2 << "]" << endl; for (int i = 0; i < numd1*numd2; i++) { computed2file << computed.at(i); } computed2file.close(); */ fstream resfp("computed.txt", fstream::out); resfp << "[ " << numd1 << " ]" << endl; resfp << "[ " << numd2 << " ]" << endl; std::cout << "Started computing" << std::endl; for(int i = 0; i < numd1; i++) { for(int j = 0; j < numd2; j++) { Ctxt sol = hamming_dist(*cdesc[i],*sdesc[j],nslots*8); resfp << sol; } } resfp.close(); }
05369c0c0774baef2d73e9bf750f4fc0e1a7a624
c6d109a9bf019e29aa07c5cd5159eb5f3b407fe3
/sheaves/support/rc_any.h
6a2c3b04a50d3260858facc4c29ee35be8a050b4
[ "Apache-2.0" ]
permissive
LimitPointSystems/SheafSystem
883effa60ec9533a085e2d1442c83df721e8d264
617faf00175b1422be648b85146e43d2fc54f662
refs/heads/master
2020-09-12T20:01:59.763743
2017-05-02T20:48:52
2017-05-02T20:48:52
16,596,740
2
3
null
2017-05-02T20:48:52
2014-02-06T22:44:58
C++
UTF-8
C++
false
false
2,201
h
rc_any.h
// // Copyright (c) 2014 Limit Point Systems, 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. // /// @file /// Interface for class rc_any #ifndef RC_ANY_H #define RC_ANY_H #ifndef SHEAF_DLL_SPEC_H #include "SheafSystem/sheaf_dll_spec.h" #endif #ifndef ANY_H #include "SheafSystem/any.h" #endif #ifndef STD_IOSTREAM_H #include "SheafSystem/std_iostream.h" #endif namespace sheaf { /// /// Base class for reference counting /// class SHEAF_DLL_SPEC rc_any : public any { // =========================================================== /// @name RC_ANY FACET // =========================================================== //@{ public: /// /// Default constructor /// rc_any(); /// /// Constructor /// rc_any(const rc_any& xother); /// /// Assignment operator /// rc_any& operator=(const rc_any& xother); /// /// Destructor /// ~rc_any(); /// /// Increment the reference count /// void add_reference(); /// /// Decrement the reference count. Delete this object if /// the reference count is zero. /// void remove_reference(); /// /// True if the reference count is greater than one. /// bool is_shared() const; /// /// Return the reference count /// size_type ref_ct() const; protected: /// /// Reference count /// size_type _ref_ct; private: //@} }; // =========================================================== // NON-MEMBER FUNCTIONS // =========================================================== /// /// Insert rc_any rc into ostream os. /// SHEAF_DLL_SPEC std::ostream& operator << (std::ostream &os, const rc_any& rc); } // namespace sheaf #endif // ifndef RC_ANY_H
30eed9db4c5a105f15f393b1cbc5f106581e71fa
4048dc505f87f5dc27fd8a8c920e51cd72e44aa2
/applications/MapReduce/branches/MapReduce.terasort/external/factory/type_list.hpp
9d502046a4816d09a76e6abd73d8c8fca53bc05d
[]
no_license
saga-project/saga-cpp-legacy-projects
007af3860994a3f10c7163b4b271cccd7eb10eb8
2874ff6714776ee721a46f5b68f317e0d1dbfbf9
refs/heads/master
2023-04-05T00:47:38.636238
2023-03-31T14:47:42
2023-03-31T14:47:42
5,780,249
0
3
null
2023-03-31T14:47:43
2012-09-12T13:38:02
TeX
UTF-8
C++
false
false
3,166
hpp
type_list.hpp
/*============================================================================= Copyright (c) 2007-2008 Marco Costalba Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #ifndef TYPE_LIST_HPP #define TYPE_LIST_HPP namespace factory_ns { namespace detail { namespace type_list { static const int begin = -2; static const int end = -1; struct null_type; /* Simple trait to check for null_type */ template<class T> struct is_null { static const bool value = false; }; template<> struct is_null<null_type> { static const bool value = true; }; /* A simplified type list */ template<class H, class T> struct TL; /* Get the n-th element of a type_list, first is at 0 */ template<int n, class TL> struct at_c; template<int n, class H, class T> struct at_c<n, TL<H, T> > : at_c<n - 1, T> {}; template<class H, class T> struct at_c<0, TL<H, T> > { typedef H head; typedef T tail; }; /* Increment list iterator skipping uninteresting items */ template<typename T> struct skip; // to be specialized for types to skip template<int id, class T, bool skip> struct next_id_impl { static const int value = id; }; template<int id> struct next_id_impl<id, null_type, true> { static const int value = end; }; template<int id, class H, class T> struct next_id_impl<id, TL<H, T>, true> : next_id_impl<id + 1, T, skip<H>::value> {}; template<int id, class TL> struct next_id : next_id_impl<id, typename at_c<id, TL>::tail, true> {}; template<class H, class T> struct next_id<begin, TL<H, T> > : next_id_impl<0, T, skip<H>::value> {}; /* Helper to build up a type list */ template<class T1, class T2, class T3, class T4, class T5, class T6> struct make { typedef TL<T1, typename make<T2, T3, T4, T5, T6, null_type>::type> type; }; template<> struct make<null_type, null_type, null_type, null_type, null_type, null_type> { typedef null_type type; }; }}} /* Simple utility to pass arguments by reference instead of const * reference. This could be necessary as example when arguments * are modified inside object constructors. * * Needed only when quering for objects at runtime, i.e. only when * using factory::get_by_key() */ namespace factory_ns { namespace detail { namespace ref_wrapper { template<typename T> struct wrapper { explicit wrapper(T& v) : value(v) {} T& value; wrapper& operator=(wrapper const&); // fix a warning with MSVC /W4 }; template<typename T> struct unwrap { static const T& value(T const& v) { return v; } }; template<typename U> struct unwrap<wrapper<U> > { static U& value(wrapper<U> const& v) { return v.value; } }; /* Our public API here */ template<typename T> inline wrapper<T> byRef(T& v) { return wrapper<T>(v); } }}} #endif
014977dc5322812351706ca7ec0040ae6ea3d459
c3b96fe11153527a27a4dd20adaa3f93c8dad2de
/5sem/MADM/lab7/models/figure.h
555c8549216225f50208e869ea6d154a1c45ca3e
[]
no_license
azhi/BSUIR_labs
0905682c9b8194dcce35c5fabe82c72009f4f798
928506a416db656fc3c03181c053207a9aec963b
refs/heads/master
2021-01-13T01:36:19.772612
2014-11-30T17:44:59
2014-11-30T17:45:11
5,731,963
1
5
null
null
null
null
UTF-8
C++
false
false
2,763
h
figure.h
#ifndef FIGURE_H #define FIGURE_H #include <SDL/SDL.h> #define min(x,y) ((x) < (y) ? (x) : (y)) #define max(x,y) ((x) > (y) ? (x) : (y)) struct Point { int x,y; Point() : x(0), y(0) {} Point(int x, int y) : x(x), y(y) {} }; struct Range { int p1, p2; Range() : p1(0), p2(0) {}; Range(int p1, int p2) : p1(p1), p2(p2) {}; }; struct Rect_range { Range xrange, yrange; }; #define T_LINE 1 #define T_ELLIPSE 2 #define T_RECTANGLE 3 class Figure { public: Figure(short type) : type(type) {}; virtual ~Figure() {}; void set_surface(SDL_Surface* surface) { this->surface = surface; }; short get_type() { return type; }; virtual void draw() {}; virtual Rect_range get_rect_space() {}; bool is_above(Figure* other) { Rect_range my_range = get_rect_space(); Rect_range other_range = other->get_rect_space(); if ( abs( my_range.yrange.p2 - other_range.yrange.p1 ) < 20 || my_range.yrange.p2 < other_range.yrange.p1 ) return true; else return false; }; bool is_left(Figure* other) { Rect_range my_range = get_rect_space(); Rect_range other_range = other->get_rect_space(); if ( abs( my_range.xrange.p2 - other_range.xrange.p1 ) < 20 || my_range.xrange.p2 < other_range.xrange.p1 ) return true; else return false; }; bool is_inside(Figure* other) { Rect_range my_range = get_rect_space(); Rect_range other_range = other->get_rect_space(); if ( (my_range.xrange.p1 > other_range.xrange.p1 - 20) && (my_range.xrange.p1 < other_range.xrange.p2) && (my_range.xrange.p2 < other_range.xrange.p2 + 20) && (my_range.xrange.p2 > other_range.xrange.p1) && (my_range.yrange.p1 > other_range.yrange.p1 - 20) && (my_range.yrange.p1 < other_range.yrange.p2) && (my_range.yrange.p2 < other_range.yrange.p2 + 20) && (my_range.yrange.p2 > other_range.yrange.p1) ) return true; else return false; }; bool is_rigth_beneath(Figure* other) { Rect_range my_range = get_rect_space(); Rect_range other_range = other->get_rect_space(); if ( abs( my_range.yrange.p1 - other_range.yrange.p2 ) < 20 ) return true; else return false; }; bool is_under(Figure* other) { Rect_range my_range = get_rect_space(); Rect_range other_range = other->get_rect_space(); if ( abs( my_range.yrange.p1 - other_range.yrange.p2 ) < 20 || my_range.yrange.p1 > other_range.yrange.p2 ) return true; else return false; }; protected: SDL_Surface* surface; short type; }; #endif // FIGURE_H
4688062516a1f95929218f55cb78ee18a4a7bf20
fb4ebb51b46ce0912458fc4e6891a288c1ad20c1
/c,c++/schholconstructor.cpp
4f13d74fd5815207117c57a7bf12e3132af9bc5d
[]
no_license
pratyush220498/Data_Structure-CPP
982cfd3d0f689670a2b88d8913cce459d9f6b67d
92638b99527f3a5e47cdb54d6e03595c89c868c6
refs/heads/master
2022-11-04T00:14:27.336093
2020-06-17T12:21:09
2020-06-17T12:21:09
272,966,059
1
0
null
null
null
null
UTF-8
C++
false
false
547
cpp
schholconstructor.cpp
#include<iostream> #include<string.h> using namespace std; class school { char name[20],city[20]; int num; public: school() { strcpy(name,"pratyush"); strcpy(city,"indore"); } school(char name1[20],char city1[20]) { strcpy(name,name1); strcpy(city,city1); } school(school&s) { strcpy(name,s.name); strcpy(city,s.city); } void output() { cout<<name<<"\t"<<city<<endl; } }; int main() { school l1; school l2("kanika","bhopal"); school l3(l2); l1.output(); l2.output(); l3.output(); return 0; }
94be95f3510051df3ff311212c35927346991d46
71b85ad0abf67300993244462a5a9d1abae33091
/Drill 10/Drill 10.cpp
a77b013b8aded0651127383c8bfaff2477a04221
[]
no_license
wangweiao/HLPL1_Lab
fa320e3bb68d3d82167d5ec11b1e0621598dfc97
e81a0f6e222a21e563f10838dc94a9a5358136ad
refs/heads/main
2023-04-21T19:06:55.773947
2021-05-06T20:14:17
2021-05-06T20:14:17
338,542,403
0
1
null
null
null
null
UTF-8
C++
false
false
1,967
cpp
Drill 10.cpp
#include "std_lib_facilities.h" //10.1. Define the data type Point that has two coordinate members x and y. class Point { public: int x; int y; }; ostream& operator<<(ostream& os, Point& p) { return os << '(' << p.x << ',' << p.y << ')'; } int main() try { //10.2. Prompt the user to input seven(x,y) pairs and store them in a vector. cout << "Please input seven(x,y) pairs:" << endl; vector<Point> original_points; int i = 1; for (i = 1; i <= 7; i++) { char ch1, ch2, ch3; int xx, yy; cin >> ch1 >> xx >> ch2 >> yy >> ch3; original_points.push_back(Point{xx, yy}); } //10.3. Print out the original points. cout << "Print out the original points:" << endl; for (auto e : original_points) cout << e << " "; cout << endl; //10.4. Output the points to a file. string fname = "mydata.txt"; ofstream opp{ fname }; if (!opp) error("Cannot open file: ", fname); for (Point p : original_points) opp << p; //10.5. Close the ofstream and open an ifstream to further process the data. opp.close(); vector<Point> processed_points; ifstream ipp{ fname }; if (!ipp) error("Cannot open input file: ", fname); for (i = 1; i <= 7; i++) { int xx, yy; char ch1, ch2, ch3; ipp >> ch1 >> xx >> ch2 >> yy >> ch3; processed_points.push_back(Point{ xx,yy }); } //10.6. Print out the processed points. cout << "Print out the processed points:" << endl; for (auto e : processed_points) cout << e << " "; cout << endl; //10.7. Compare the two vectors. if (original_points.size() != processed_points.size()) cout << "Something's wrong! " << endl; } catch (exception& e) { cerr << e.what() << endl; return 1; } catch (...) { cerr << "An error occured!" << endl; return 2; }
831dc2ac2d4463cf942b0f307e2c9d9c4fdbcbff
e4d3401272488fb9009a490ace609649e9b9fa12
/Classes/MenuScene.cpp
b92eede9f965f425300b86793839afdbc16c5534
[]
no_license
amrzagloul/BBB
30807ef8892c07fd8dae49e52efcf26380994ebd
31f5e44426e502b63ecfec56dc125845e5e1f19c
refs/heads/master
2021-01-15T19:40:37.759945
2012-05-27T04:33:23
2012-05-27T04:33:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,755
cpp
MenuScene.cpp
#include "MenuScene.h" #include "GameScene.h" USING_NS_CC; CCScene* Menu::scene() { CCScene *scene = CCScene::node(); Menu *layer = Menu::node(); scene->addChild(layer); return scene; } bool Menu::init() { if ( !CCLayer::init() ) { return false; } CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage( "CloseNormal.png", "CloseSelected.png", this, menu_selector(Menu::menuCloseCallback) ); pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) ); CCMenuItemImage *pGameItem = CCMenuItemImage::itemFromNormalImage( "menu/StartButton-off.png", "menu/StartButton-on.png", this, menu_selector(Menu::menuStartCallback) ); float x=CCDirector::sharedDirector()->getWinSize().width/ 2 - pGameItem->getContentSize().width/2; float y=CCDirector::sharedDirector()->getWinSize().height/ 2 - pGameItem->getContentSize().height/2; pGameItem->setPosition( ccp(x, y) ); CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, pGameItem,NULL); pMenu->setPosition( CCPointZero ); this->addChild(pMenu, 1); CCSize size = CCDirector::sharedDirector()->getWinSize(); CCSprite* pSprite = CCSprite::spriteWithFile("menu/GameMenu.png"); pSprite->setPosition( ccp(size.width/2, size.height/2) ); this->addChild(pSprite, 0); return true; } void Menu::menuCloseCallback(CCObject* pSender) { CCDirector::sharedDirector()->end(); } void Menu::menuStartCallback(CCObject* pSender) { CCDirector *pDirector = CCDirector::sharedDirector(); CCScene *pScene = GameScene::scene(); // run pDirector->replaceScene(pScene); }
e21ff2b1d1b45cd8256d922e116faa0ca93cdf8f
aa844675da09cccaf9d63f94301b212080f9cef3
/pascal_triangle.cpp
65da14ebe80890db9ae5d32f168847612ba1005e
[]
no_license
aniketbiswas21/codechef
1e57432c231a1ac6e846f76f6e7399bab9db842b
72e7be1e43af1c258931675854d72d196eb41cbd
refs/heads/master
2020-12-20T16:11:33.557139
2020-03-13T13:36:58
2020-03-13T13:36:58
236,133,141
0
0
null
null
null
null
UTF-8
C++
false
false
402
cpp
pascal_triangle.cpp
#include<iostream> using namespace std; int fact(int t){ int ans=1; for(int i=1;i<=t;i++){ ans=ans*i; } return ans; } int facto(int o,int p){ int g=fact(o)/(fact(o-p)*fact(p)); return g; } int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ for(int s=1;s<=n-i;s++){ cout<<" "; } for(int j=1;j<=i;j++){ cout<<facto(i-1,j-1)<<" "; } cout<<endl; } return 0; }
1e8bb17dae9ea05afba40db391f6595635649416
b5317b08ddec6620382bdd85b791000752766760
/application/tools/bufferinglog.h
dc4dfbc8ebad4725e2f2ad1a64617fecb4160c0c
[ "Apache-2.0" ]
permissive
hmsgit/campvis
49379dedfb0143e086183c7b89de6efaa6f0dfed
d97de6a86323866d6a8f81d2a641e3e0443a6b39
refs/heads/master
2021-04-26T13:16:05.224811
2016-02-10T13:56:18
2016-02-10T13:56:18
121,310,766
5
0
null
null
null
null
UTF-8
C++
false
false
3,177
h
bufferinglog.h
// ================================================================================================ // // This file is part of the CAMPVis Software Framework. // // If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved, // Christian Schulte zu Berge <christian.szb@in.tum.de> // Chair for Computer Aided Medical Procedures // Technische Universitaet Muenchen // Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany // // For a full list of authors and contributors, please refer to the file "AUTHORS.txt". // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file // except in compliance with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software distributed under the // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions // and limitations under the License. // // ================================================================================================ #ifndef BUFFERINGLOG_H__ #define BUFFERINGLOG_H__ #include "tbb/mutex.h" #include "cgt/logmanager.h" #include "application/applicationapi.h" #include <deque> #include <QObject> namespace campvis { /** * BufferingLog stores up to the specified number of messages in memory. */ class CAMPVIS_APPLICATION_API BufferingLog : public QObject, public cgt::Log { Q_OBJECT public: /** * Creates a new BufferingLog. * * When the BufferingLog reaches its maximum capacity and is asked to store * additional messages, it discards old ones according to the least recently * used policy. * * \param maxSize the maximum number of messages this log should store * \param dateStamping should logged messages be date-stamped * \param timeStamping should logged messages be time-stamped * \param showCat should the category be printed along with the messages * \param showLevel should the LogLevel be printed along with the messages */ explicit BufferingLog(unsigned int maxSize, QObject* parent = 0, bool dateStamping = true, bool timeStamping = true, bool showCat = true, bool showLevel = true); virtual ~BufferingLog() {} bool isOpen() { return true; } signals: /** * Signal invoked when a new message has been appended to the log. * * \param message the new log message * \param level Log level */ void s_messageAppended(const QString& message, int level); protected: unsigned int _maxSize; tbb::mutex _localMutex; std::deque<std::string> _buffer; void logFiltered(const std::string &cat, cgt::LogLevel level, const std::string& msg, const std::string& extendedInfo=""); }; } #endif // BUFFERINGLOG_H__
a74b5829669ddbf438431b080bf7de3bcef4de31
3872538fc515f9bb806ea0d433d549951c7b4472
/sql_res.hpp
5fa08681ad00a5bed531ebc1d3c80dd637fafd67
[]
no_license
kspine/mysqlcp
b97e1a6906dbb90b34a50fc9d9f25c3b8ef25498
f261edf75f757d56cd0716010b11b0f77b4f0401
refs/heads/master
2021-01-21T17:29:23.864955
2015-06-04T08:11:53
2015-06-04T08:11:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,860
hpp
sql_res.hpp
/// sql_res.hpp -- sql results decls /// Author: Zhang Yichao <echaozh@gmail.com> /// Created: 2011-08-03 /// #ifndef INCLUDED_SQL_RES_HPP #define INCLUDED_SQL_RES_HPP #include "exception.hpp" #include "sql_stmt.hpp" #include <cppzmq.hpp> #include <string> struct sql_res { sql_res () : empty (true), id (0), err (success), txn_seq (0) {} sql_res (sql_res &&rhs) : empty (rhs.empty), addr (std::move (rhs.addr)), id (rhs.id), err (rhs.err), msg (rhs.msg), txn_seq (rhs.txn_seq), res (std::move (rhs.res)) {} sql_res (cppzmq::packet_t &&a, size_t txn, error e, const std::string &m = "") : empty (false), addr (a), id (0), err (e), msg (m), txn_seq (txn) { if (msg.empty ()) msg = err_to_str (err); } sql_res (sql_stmt &&stmt, const std::string &&r = "") : empty (false), addr (std::move (stmt.addr)), id (stmt.id), err (stmt.err), msg (stmt.msg), txn_seq (stmt.txn_seq), res (r) { if (msg.empty ()) msg = err_to_str (err); } sql_res (sql_stmt &&stmt, error e, const std::string &m = "") : empty (false), addr (std::move (stmt.addr)), id (stmt.id), err (e), msg (m), txn_seq (stmt.txn_seq) { if (msg.empty ()) msg = err_to_str (err); } sql_res &operator = (sql_res &&rhs) { empty = rhs.empty; addr = std::move (rhs.addr); id = rhs.id; err = rhs.err; msg = rhs.msg; txn_seq = rhs.txn_seq; res = std::move (rhs.res); return *this; } bool empty; cppzmq::packet_t addr; size_t id; error err; std::string msg; size_t txn_seq; std::string res; }; #endif // INCLUDED_SQL_RES_HPP
8ee251ffb7b96967e621d6e76da9c3875a0d1763
80a96581255056a03f126e19b081276d5a66dd2e
/RulerCornerView.h
7161c7279d3504ae269c007b3f4f367936881235
[]
no_license
patchell/FrontCad
6c1c9e4e7642eafe8a8a556c17e098f32077c548
b2567d6d0b57b22a29efa64aa42d583cd1a457b8
refs/heads/master
2023-07-07T04:24:40.368564
2023-06-29T03:42:46
2023-06-29T03:42:46
75,502,957
0
0
null
null
null
null
UTF-8
C++
false
false
765
h
RulerCornerView.h
#pragma once ///////////////////////////////////////////////////////////////////////////// // CRulerCornerView view class CRulerCornerView : public CView { CRulerInfo *m_pRulerInfo;; protected: CRulerCornerView(); // protected constructor used by dynamic creation virtual ~CRulerCornerView(); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); virtual void OnDraw(CDC* pDC); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif DECLARE_DYNCREATE(CRulerCornerView) afx_msg void OnSetFocus(CWnd* pOldWnd); DECLARE_MESSAGE_MAP() public: void SetRulersInfo(CRulerInfo *pInfo) { m_pRulerInfo = pInfo; } CRulerInfo* GetRulerInfo() { return m_pRulerInfo; } afx_msg void OnSize(UINT nType, int cx, int cy); };
16001b68a11dda132c4b8613cbd5c3f61fa6aba0
400ade5b6d9cd0559c5b3ef4004ef458878c4083
/simply plot/plot/instruction.hpp
90ebcf96df78a72d25b3a44b3efae816547a04d8
[]
no_license
blackfm/simply-plot
a1ee31841bcd56452d47d83f38c4b29ec249cc92
cc4af9a77bf0353d6eefa5f510969987a4c1a8f5
refs/heads/master
2021-01-01T03:45:35.157749
2016-05-15T08:39:49
2016-05-15T08:39:49
55,958,918
0
0
null
null
null
null
UTF-8
C++
false
false
1,978
hpp
instruction.hpp
// // instruction.hpp // simply plot // // Created by Andrey Denisov on 05/05/16. // Copyright © 2016 Andrey Denisov. All rights reserved. // // Instructions are basic commands (text, path, etc.) that are passed // to the plotter to be converted to the format-specific instruction // written into the final figure file #ifndef instruction_hpp #define instruction_hpp #include <stdio.h> #include <vector> #include <string> #include "plotter.hpp" #include "coordinate.hpp" #include "dimensions.hpp" namespace simplot { class Plotter; class Instruction { public: virtual ~Instruction() = 0; virtual int render(Plotter& plotter) = 0; private: }; class Path : public Instruction { // path is a set of sections to be plot public: Path(); ~Path(); Path(std::vector<Coordinate> points); // initialising the Path with a given set of points int addPoint(Coordinate value); std::vector<std::vector<Coordinate>> getPoints() const {return points;} int render(Plotter& plotter); private: std::vector<std::vector<Coordinate>> points; // each subpath is drawn, the section between two subpaths is not // LineStyle style }; class Text : public Instruction { // text consists of multiple labels, e.g. labels for axis ticks public: int render(Plotter& plotter); private: std::vector<std::string> labels; // text labels std::vector<Coordinate> positions; // positions of each label // TextStyle style ; }; class SetSize : public Instruction { // setting size of the whole plot public: SetSize(); SetSize(float width, float height); SetSize(Dimensions dimensions); ~SetSize(); int render(Plotter& plotter); float getWidth() const {return dimensions.getWidth();} float getHeight() const {return dimensions.getHeight();} std::string getUnit() const {return dimensions.getUnit();} private: Dimensions dimensions; }; } #endif /* instruction_hpp */
5b5c536f3cd34a58bc798933213719c296a5364d
17bf8eca8ece516e65118a91d60134092a8f68e4
/C++/300. Longest Increasing Subsequence/solWithOutput.cpp
e8475352ac2cf6516e04dd918b98e0688d4dcf31
[]
no_license
HaelC/LeetCode
a433bb49e62a3b331982cb6fa337a72726c45a11
549c0217e771726611287f7bcd43c704190a60f1
refs/heads/master
2022-12-29T16:53:56.159942
2020-10-11T05:50:25
2020-10-11T05:50:25
177,907,987
1
0
null
null
null
null
UTF-8
C++
false
false
1,312
cpp
solWithOutput.cpp
class Solution { private: void output(vector<int>& nums, vector<int>& position, int index) { vector<int> seq{nums[index]}; while (position[index] != index) { index = position[index]; seq.insert(seq.begin(), nums[index]); } for (auto i : seq) { cout << i << " "; } cout << endl; } public: int lengthOfLIS(vector<int>& nums) { if (nums.empty()) return 0; vector<int> dp(nums.size()); vector<int> position(nums.size()); dp[0] = 1; position[0] = 0; for (int i = 1; i < nums.size(); i++) { int max = 1; position[i] = i; for (int j = 0; j < i; j++) { if (nums[j] < nums[i]) { if (max < dp[j] + 1) { max = dp[j] + 1; position[i] = j; } } } dp[i] = max; } int result = 0, index = -1; for (int i = 0; i < dp.size(); i++) { if (result < dp[i]) { result = dp[i]; index = i; } } output(nums, position, index); return result; } };
98bae5fc1acc9b57ced1ce09fc099140127e36d8
208c9c4fc8d8ad06f1ca56a0a68470927534c190
/Cpp_Primer_Plus/Chapter2/carrots.cpp
7a29774b4480d8592acb7bc51758fe25d4484674
[]
no_license
Tenderest/CPP-Learning
e367adf5c0abb497992c0d4f5c8ce2289db0faf9
7fc92c96b00f9ecf8c27f68039a6fea4bb1fbb8d
refs/heads/main
2022-10-15T19:36:29.384763
2022-05-27T08:55:27
2022-05-27T08:55:27
233,337,137
0
0
null
null
null
null
UTF-8
C++
false
false
620
cpp
carrots.cpp
// 程序清单2.2 carrots.cpp // carrots.cpp -- food processing program // uses and displays a variable #include <iostream> int main(void) { using std::cout; using std::cin; using std::endl; // using namespace std; int carrots; // 声明一个整数变量 carrots = 25; // 为变量赋值 cout << "I have "; cout << carrots; // 显示变量的值 cout << " carrots."; cout << endl; carrots = carrots - 1; // 修改变量 cout << "Crunch, crunch, Now I have " << carrots << " carrots." << endl; return 0; }
fa8c52e297a9a117f562a7495f78cc6dbbb884ae
12d9e3ed40f1d5706932a3e44e8a08ca185b52cf
/UVa Online Judge/UVA 469 - Wetlands of Florida.cc
d9fcaa6fb0a3f7431d2640b6b0c852aa757ff0ea
[]
no_license
SebastianJM/Competitive-Programming
25f83ceb607fcc3d95fa35c5f06cb7894413b857
5cd9de9485ae3f882a7c85292a77e5d662fce08f
refs/heads/master
2020-03-23T21:25:42.970408
2018-11-20T05:06:46
2018-11-20T05:06:46
142,105,914
1
0
null
null
null
null
UTF-8
C++
false
false
840
cc
UVA 469 - Wetlands of Florida.cc
#include <bits/stdc++.h> using namespace std; int n,c,res; int x[8]={0,0,1,1,1,-1,-1,-1}; int y[8]={1,-1,-1,0,1,-1,0,1}; vector<string> m,mm; void filll(int i,int j) { res++; mm[i][j]='L'; for(int e=0;e<8;e++) if(i+x[e]>=0 && i+x[e]<n && j+y[e]>=0 && j+y[e]<c && mm[i+x[e]][j+y[e]]=='W') { mm[i+x[e]][j+y[e]]='L'; filll(i+x[e],j+y[e]); } } int main() { int t=0; string a; cin>>t; getchar(); getchar(); while(t--) { n=0; m=vector<string>(); while(1) { getline(cin,a); if(a[0]!='L' && a[0]!='W') break; m.push_back(a); n++; } c=m[n-1].size(); int u,v; while(1) { sscanf(&a[0u], "%d %d", &u, &v); res=0; mm=m; if(m[u-1][v-1]=='W') filll(u-1,v-1); cout<<res<<endl; getline(cin,a); if(a.size()==0) break; } if(t!=0) cout<<endl; } return 0; }
85090b06be1ff0aa3dea430164e49d563013fab2
c6bb08d0587b240f0afb1da7d797a3f6704837c4
/v2/src/core/training/training_executor.h
0c2aa1f4dab3cd867002e83c7181514b7199f236
[]
no_license
Flatta/jumanpp
e5304914874d7b294beecbe429064e9ce208fd8f
531867b8d371680629c50e3c5e345954f1d257a6
refs/heads/v2
2020-07-18T20:07:06.481051
2017-06-14T12:55:08
2017-06-14T13:00:29
94,327,860
0
0
null
2017-06-14T12:19:47
2017-06-14T12:19:47
null
UTF-8
C++
false
false
1,784
h
training_executor.h
// // Created by Arseny Tolmachev on 2017/04/06. // #ifndef JUMANPP_TRAINING_EXECUTOR_H #define JUMANPP_TRAINING_EXECUTOR_H #include "scw.h" #include "trainer.h" #include <atomic> #include <condition_variable> #include <mutex> #include <thread> namespace jumanpp { namespace core { namespace training { struct TrainingExecutionResult { OwningTrainer* trainer; Status processStatus; }; enum class ExecutorThreadState { Initialization, WaitingForInput, HaveInput, RunningComputation, ComputationFinished, Exiting }; class TrainingExecutorThread { const analysis::ScorerDef* scoreConf_; Status processStatus_; std::thread thread_; std::mutex mutex_; std::condition_variable input_ready_; OwningTrainer* trainer_; std::atomic<ExecutorThreadState> state_{ExecutorThreadState::Initialization}; void run(); // an entry poinf the the thread static void runMain(TrainingExecutorThread* ctx) { ctx->run(); } public: explicit TrainingExecutorThread(const analysis::ScorerDef* conf); void publishTrainer(OwningTrainer* trainer); TrainingExecutionResult waitForTrainer(); ~TrainingExecutorThread(); }; class TrainingExecutor { std::vector<std::unique_ptr<TrainingExecutorThread>> threads_; u32 head_; u32 tail_; public: Status initialize(const analysis::ScorerDef* sconf, u32 nthreads); u32 capacity() const { return (u32)threads_.size(); } u32 used() const { return head_ - tail_; } u32 available() const { return capacity() - used(); } bool nonProcessedExist() const { return head_ != tail_; } bool runNext(OwningTrainer* next, TrainingExecutionResult* result); TrainingExecutionResult waitOne(); }; } // namespace training } // namespace core } // namespace jumanpp #endif // JUMANPP_TRAINING_EXECUTOR_H
2f4cf545e6af31cba1749b2e3bdaa9f42201adb5
f8bf15d4181b45999722896f60523b2f8780f0b3
/Day06/ex01/include/serialize.h
1568b3a8f5516716638d90bc94b8963b4dc39124
[]
no_license
Etheram68/Piscine_cpp
6551e33e50d3aef2f7c8a8ad8a75b38a1a1fa7b5
d711a488e1ff5f1727d067297782960714d655d7
refs/heads/master
2022-11-30T02:05:56.585138
2020-08-13T15:38:37
2020-08-13T15:38:37
275,828,542
0
0
null
null
null
null
UTF-8
C++
false
false
1,169
h
serialize.h
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* serialize.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: frfrey <frfrey@student.42lyon.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/08/11 19:18:55 by frfrey #+# #+# */ /* Updated: 2020/08/11 19:18:55 by frfrey ### ########lyon.fr */ /* */ /* ************************************************************************** */ #ifndef SERIALIZE_H # define SERIALIZE_H # include <string> # define EXIT_SUCCESS 0 # define EXIT_FAILURE 1 struct Data { std::string s1; int n; std::string s2; }; Data * deserialize(void * raw); void * serialize(void); #endif
736f2ec43684d1f0c8656d7ba18b69b42750a28a
593dc85e82e69e74493e8190d655ceeed63f763e
/libtomo3d/src/projection1d.cpp
6fa6f9bae8987c4ccbb3c8cf1f5cd3be1188965f
[ "MIT" ]
permissive
olegabr/tomo3d
2b7d24842898fcc5f87835ba40db58d8da7443a2
36ffca69aba8556170ec7330271eb58ebaf7459b
refs/heads/master
2021-01-22T01:33:33.749009
2018-02-12T16:31:11
2018-02-12T16:31:11
23,263,172
8
1
null
null
null
null
UTF-8
C++
false
false
4,242
cpp
projection1d.cpp
//projection1d.cpp /* * the projection1d class impl * (C) 2004 olegabr. All rights reserved. */ #include "projection1d.h" #include "ro_filtrate.h" #include <iostream> using std::cout; using std::endl; #include <algorithm> #include <numeric> #include <cmath> #include <cassert> #include <boost/lambda/lambda.hpp> projection1d::projection1d(size1d_t size, point1d point_size) : size_(size), point_size_(point_size) { //cout << "projection1d(size)" << endl; data_.reserve(size); std::fill_n ( std::back_inserter(data_), size, 0. ); //data_.resize(size_); //clear(); } projection1d::projection1d(const projection1d& other) : size_(other.size_), point_size_(other.point_size_) { //cout << "projection1d(projection1d)" << endl; if (&other != this) { if (data_.size() < other.data_.size()) { //cout << "projection1d(projection1d): data_.resize\n"; //<< "data_.size() = " << data_.size() << endl //<< "other.data_.size() = " << other.data_.size() << endl; data_.resize(size_); } std::copy(other.data_.begin(), other.data_.end(), data_.begin()); } } projection1d& projection1d::operator =(const projection1d& other) { //cout << "projection1d::operator =(const projection1d& other)" << endl; if (&other != this) { point_size_ = other.point_size_; size_ = other.size_; if (data_.size() < other.data_.size()) { //cout << "projection1d::operator =(projection1d): data_.resize\n"; //<< "data_.size() = " << data_.size() << endl //<< "other.data_.size() = " << other.data_.size() << endl; data_.resize(size_); } std::copy(other.data_.begin(), other.data_.end(), data_.begin()); } return *this; } //g = f-g projection1d& projection1d::assign_difference(const projection1d& f_) { assert(f_.point_size_ == point_size_); projection1d::data_type::difference_type w = (f_.size_ - size_)/2; projection1d::iterator p = data_.begin(), e = data_.end(); projection1d::const_iterator fp = f_.data_.begin(), fe = f_.data_.end(); if (w > 0) std::advance(fp, w); else if (w < 0) std::advance( p, -w); for(; p != e && fp != fe; ++p, ++fp) *p = *fp - *p; return *this; } std::ostream& operator <<(std::ostream& os, const projection1d& sh) { std::copy ( sh.data_.begin(), sh.data_.end(), std::ostream_iterator<projection1d::value_type>(os, "\t") ); return os; } void projection1d::clear() { std::fill(data_.begin(), data_.end(), 0.0); } void projection1d::ro_filtrate() { util::ro_filtrate(data_); if (point_size_ != 1) std::transform ( data_.begin(), data_.end(), data_.begin(), boost::lambda::_1/point_size_ ); } point1d projection1d::get_point_gt(point1d l) const { return get_Rmin_() + point_size_*std::ceil((l-get_Rmin_())/point_size_); } pixel1d projection1d::point2index_(point1d R) const { return static_cast<pixel1d>(util::round((R - get_Rmin_())/point_size_)); } void projection1d::add_value(pixel1d i, projection1d::value_type value) { if (in_grid(i, size_)) data_[i] += value; } void projection1d::add_value(point1d R, projection1d::value_type value) { add_value(point2index_(R), value); } void projection1d::set_value(pixel1d i, projection1d::value_type value) { if (in_grid(i, size_)) data_[i] = value; } void projection1d::set_value(point1d R, projection1d::value_type value) { set_value(point2index_(R), value); } projection1d::value_type projection1d::get_value(pixel1d i) const { assert(in_grid(i, size_)); return data_[i]; } projection1d::value_type operator *(const projection1d& sh, const projection1d& fsh) { assert(sh.get_size() == fsh.get_size() ); assert(sh.get_point_size() == fsh.get_point_size()); projection1d::const_iterator is = sh.data_.begin(), e = sh.data_.end(), ifs = fsh.data_.begin(); return ( .5*(*is * *ifs + *sh.data_.rbegin() * *fsh.data_.rbegin()) + std::inner_product (++is, --e, ++ifs, 0.) )*sh.get_point_size(); } std::pair<projection1d::value_type, projection1d::value_type> projection1d::get_min_max_() const { /* named return value optimization :) */ std::pair<projection1d::value_type, projection1d::value_type> result(*std::min_element(data_.begin(), data_.end()), *std::max_element(data_.begin(), data_.end())); return result; }
8c89f9039ba99c2be2f5d94f00a31f4907ce5014
8aa9a970895b0b2cf639f75738e33b0a4487208e
/ArrayAndString/pascal_triangle.cpp
1501b4abee6c4854fc44a3e401f581ef96aa4737
[]
no_license
VladAdGad/leetcode-solutions
09d24c3cdd1f95ea45746a67a71ebfb944933152
0431f983ab86a53b5a22dc9deca62746c877e7e7
refs/heads/master
2023-01-30T16:14:37.235018
2020-12-11T19:24:45
2020-12-11T19:24:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
659
cpp
pascal_triangle.cpp
#include "iostream" #include "vector" #include "../Utils/print.h" using namespace std; vector<vector<int>> generate(int numRows) { vector<vector<int>> result(numRows); for (int i = 0; i < numRows; ++i) { result.at(i).resize(i + 1); result.at(i).at(0) = 1; result.at(i).at(i) = 1; } for (int i = 2; i < numRows; ++i) { for (int j = 1; j < i; ++j) { result.at(i).at(j) = result.at(i - 1).at(j - 1) + result.at(i - 1).at(j); } } return result; } //int main() { // vector<vector<int>> result1 = generate(5); // // printf("%s", print(result1).c_str()); // // return 0; //}
de3cc0da27aa3335817bb7be87fbe2f5e344e5e9
c51febc209233a9160f41913d895415704d2391f
/YorozuyaGSLib/source/CMapDataDetail.cpp
1d2dac911b4e035e810b9a3331686162ffc66510
[ "MIT" ]
permissive
roussukke/Yorozuya
81f81e5e759ecae02c793e65d6c3acc504091bc3
d9a44592b0714da1aebf492b64fdcb3fa072afe5
refs/heads/master
2023-07-08T03:23:00.584855
2023-06-29T08:20:25
2023-06-29T08:20:25
463,330,454
0
0
MIT
2022-02-24T23:15:01
2022-02-24T23:15:00
null
UTF-8
C++
false
false
34,565
cpp
CMapDataDetail.cpp
#include <CMapDataDetail.hpp> #include <common/ATFCore.hpp> START_ATF_NAMESPACE namespace Detail { Info::CMapDatactor_CMapData2_ptr CMapDatactor_CMapData2_next(nullptr); Info::CMapDatactor_CMapData2_clbk CMapDatactor_CMapData2_user(nullptr); Info::CMapDataCheckCenterPosDummy4_ptr CMapDataCheckCenterPosDummy4_next(nullptr); Info::CMapDataCheckCenterPosDummy4_clbk CMapDataCheckCenterPosDummy4_user(nullptr); Info::CMapDataConvertLocal6_ptr CMapDataConvertLocal6_next(nullptr); Info::CMapDataConvertLocal6_clbk CMapDataConvertLocal6_user(nullptr); Info::CMapDataConvertLocalToWorldDummy8_ptr CMapDataConvertLocalToWorldDummy8_next(nullptr); Info::CMapDataConvertLocalToWorldDummy8_clbk CMapDataConvertLocalToWorldDummy8_user(nullptr); Info::CMapDataEnterMap10_ptr CMapDataEnterMap10_next(nullptr); Info::CMapDataEnterMap10_clbk CMapDataEnterMap10_user(nullptr); Info::CMapDataExitMap12_ptr CMapDataExitMap12_next(nullptr); Info::CMapDataExitMap12_clbk CMapDataExitMap12_user(nullptr); Info::CMapDataGetBspInfo14_ptr CMapDataGetBspInfo14_next(nullptr); Info::CMapDataGetBspInfo14_clbk CMapDataGetBspInfo14_user(nullptr); Info::CMapDataGetDummyPostion16_ptr CMapDataGetDummyPostion16_next(nullptr); Info::CMapDataGetDummyPostion16_clbk CMapDataGetDummyPostion16_user(nullptr); Info::CMapDataGetLevelLimit18_ptr CMapDataGetLevelLimit18_next(nullptr); Info::CMapDataGetLevelLimit18_clbk CMapDataGetLevelLimit18_user(nullptr); Info::CMapDataGetLinkPortal20_ptr CMapDataGetLinkPortal20_next(nullptr); Info::CMapDataGetLinkPortal20_clbk CMapDataGetLinkPortal20_user(nullptr); Info::CMapDataGetMapCode22_ptr CMapDataGetMapCode22_next(nullptr); Info::CMapDataGetMapCode22_clbk CMapDataGetMapCode22_user(nullptr); Info::CMapDataGetPortal24_ptr CMapDataGetPortal24_next(nullptr); Info::CMapDataGetPortal24_clbk CMapDataGetPortal24_user(nullptr); Info::CMapDataGetPortal26_ptr CMapDataGetPortal26_next(nullptr); Info::CMapDataGetPortal26_clbk CMapDataGetPortal26_user(nullptr); Info::CMapDataGetPortalInx28_ptr CMapDataGetPortalInx28_next(nullptr); Info::CMapDataGetPortalInx28_clbk CMapDataGetPortalInx28_user(nullptr); Info::CMapDataGetRaceTown30_ptr CMapDataGetRaceTown30_next(nullptr); Info::CMapDataGetRaceTown30_clbk CMapDataGetRaceTown30_user(nullptr); Info::CMapDataGetRandPosInDummy32_ptr CMapDataGetRandPosInDummy32_next(nullptr); Info::CMapDataGetRandPosInDummy32_clbk CMapDataGetRandPosInDummy32_user(nullptr); Info::CMapDataGetRandPosInRange34_ptr CMapDataGetRandPosInRange34_next(nullptr); Info::CMapDataGetRandPosInRange34_clbk CMapDataGetRandPosInRange34_user(nullptr); Info::CMapDataGetRandPosVirtualDum36_ptr CMapDataGetRandPosVirtualDum36_next(nullptr); Info::CMapDataGetRandPosVirtualDum36_clbk CMapDataGetRandPosVirtualDum36_user(nullptr); Info::CMapDataGetRandPosVirtualDumExcludeStdRange38_ptr CMapDataGetRandPosVirtualDumExcludeStdRange38_next(nullptr); Info::CMapDataGetRandPosVirtualDumExcludeStdRange38_clbk CMapDataGetRandPosVirtualDumExcludeStdRange38_user(nullptr); Info::CMapDataGetRectInRadius40_ptr CMapDataGetRectInRadius40_next(nullptr); Info::CMapDataGetRectInRadius40_clbk CMapDataGetRectInRadius40_user(nullptr); Info::CMapDataGetResDummySector42_ptr CMapDataGetResDummySector42_next(nullptr); Info::CMapDataGetResDummySector42_clbk CMapDataGetResDummySector42_user(nullptr); Info::CMapDataGetSecInfo44_ptr CMapDataGetSecInfo44_next(nullptr); Info::CMapDataGetSecInfo44_clbk CMapDataGetSecInfo44_user(nullptr); Info::CMapDataGetSectorIndex46_ptr CMapDataGetSectorIndex46_next(nullptr); Info::CMapDataGetSectorIndex46_clbk CMapDataGetSectorIndex46_user(nullptr); Info::CMapDataGetSectorListObj48_ptr CMapDataGetSectorListObj48_next(nullptr); Info::CMapDataGetSectorListObj48_clbk CMapDataGetSectorListObj48_user(nullptr); Info::CMapDataGetSectorListPlayer50_ptr CMapDataGetSectorListPlayer50_next(nullptr); Info::CMapDataGetSectorListPlayer50_clbk CMapDataGetSectorListPlayer50_user(nullptr); Info::CMapDataGetSectorListTower52_ptr CMapDataGetSectorListTower52_next(nullptr); Info::CMapDataGetSectorListTower52_clbk CMapDataGetSectorListTower52_user(nullptr); Info::CMapDataGetSectorNumByLayerIndex54_ptr CMapDataGetSectorNumByLayerIndex54_next(nullptr); Info::CMapDataGetSectorNumByLayerIndex54_clbk CMapDataGetSectorNumByLayerIndex54_user(nullptr); Info::CMapDataInit56_ptr CMapDataInit56_next(nullptr); Info::CMapDataInit56_clbk CMapDataInit56_user(nullptr); Info::CMapDataIsMapIn58_ptr CMapDataIsMapIn58_next(nullptr); Info::CMapDataIsMapIn58_clbk CMapDataIsMapIn58_user(nullptr); Info::CMapDataLoadDummy60_ptr CMapDataLoadDummy60_next(nullptr); Info::CMapDataLoadDummy60_clbk CMapDataLoadDummy60_user(nullptr); Info::CMapDataLoadHolySystemDummy62_ptr CMapDataLoadHolySystemDummy62_next(nullptr); Info::CMapDataLoadHolySystemDummy62_clbk CMapDataLoadHolySystemDummy62_user(nullptr); Info::CMapDataOnLoop64_ptr CMapDataOnLoop64_next(nullptr); Info::CMapDataOnLoop64_clbk CMapDataOnLoop64_user(nullptr); Info::CMapDataOpenMap66_ptr CMapDataOpenMap66_next(nullptr); Info::CMapDataOpenMap66_clbk CMapDataOpenMap66_user(nullptr); Info::CMapDataUpdateSecterList68_ptr CMapDataUpdateSecterList68_next(nullptr); Info::CMapDataUpdateSecterList68_clbk CMapDataUpdateSecterList68_user(nullptr); Info::CMapData_LoadBind70_ptr CMapData_LoadBind70_next(nullptr); Info::CMapData_LoadBind70_clbk CMapData_LoadBind70_user(nullptr); Info::CMapData_LoadBspSec72_ptr CMapData_LoadBspSec72_next(nullptr); Info::CMapData_LoadBspSec72_clbk CMapData_LoadBspSec72_user(nullptr); Info::CMapData_LoadMonBlk74_ptr CMapData_LoadMonBlk74_next(nullptr); Info::CMapData_LoadMonBlk74_clbk CMapData_LoadMonBlk74_user(nullptr); Info::CMapData_LoadPortal76_ptr CMapData_LoadPortal76_next(nullptr); Info::CMapData_LoadPortal76_clbk CMapData_LoadPortal76_user(nullptr); Info::CMapData_LoadQuest78_ptr CMapData_LoadQuest78_next(nullptr); Info::CMapData_LoadQuest78_clbk CMapData_LoadQuest78_user(nullptr); Info::CMapData_LoadResource80_ptr CMapData_LoadResource80_next(nullptr); Info::CMapData_LoadResource80_clbk CMapData_LoadResource80_user(nullptr); Info::CMapData_LoadSafe82_ptr CMapData_LoadSafe82_next(nullptr); Info::CMapData_LoadSafe82_clbk CMapData_LoadSafe82_user(nullptr); Info::CMapData_LoadStart84_ptr CMapData_LoadStart84_next(nullptr); Info::CMapData_LoadStart84_clbk CMapData_LoadStart84_user(nullptr); Info::CMapData_LoadStoreDummy86_ptr CMapData_LoadStoreDummy86_next(nullptr); Info::CMapData_LoadStoreDummy86_clbk CMapData_LoadStoreDummy86_user(nullptr); Info::CMapDatadtor_CMapData92_ptr CMapDatadtor_CMapData92_next(nullptr); Info::CMapDatadtor_CMapData92_clbk CMapDatadtor_CMapData92_user(nullptr); void CMapDatactor_CMapData2_wrapper(struct CMapData* _this) { CMapDatactor_CMapData2_user(_this, CMapDatactor_CMapData2_next); }; bool CMapDataCheckCenterPosDummy4_wrapper(struct CMapData* _this, struct _dummy_position* pPos) { return CMapDataCheckCenterPosDummy4_user(_this, pPos, CMapDataCheckCenterPosDummy4_next); }; bool CMapDataConvertLocal6_wrapper(struct CMapData* _this, struct _dummy_position* pPos) { return CMapDataConvertLocal6_user(_this, pPos, CMapDataConvertLocal6_next); }; bool CMapDataConvertLocalToWorldDummy8_wrapper(struct CMapData* _this, struct CDummyPosTable* pPosTable, bool bCheckCenter) { return CMapDataConvertLocalToWorldDummy8_user(_this, pPosTable, bCheckCenter, CMapDataConvertLocalToWorldDummy8_next); }; void CMapDataEnterMap10_wrapper(struct CMapData* _this, struct CGameObject* pObj, unsigned int dwSecIndex) { CMapDataEnterMap10_user(_this, pObj, dwSecIndex, CMapDataEnterMap10_next); }; void CMapDataExitMap12_wrapper(struct CMapData* _this, struct CGameObject* pObj, unsigned int dwSecIndex) { CMapDataExitMap12_user(_this, pObj, dwSecIndex, CMapDataExitMap12_next); }; struct _bsp_info* CMapDataGetBspInfo14_wrapper(struct CMapData* _this) { return CMapDataGetBspInfo14_user(_this, CMapDataGetBspInfo14_next); }; struct _dummy_position* CMapDataGetDummyPostion16_wrapper(struct CMapData* _this, char* pszDummyCode) { return CMapDataGetDummyPostion16_user(_this, pszDummyCode, CMapDataGetDummyPostion16_next); }; int CMapDataGetLevelLimit18_wrapper(struct CMapData* _this) { return CMapDataGetLevelLimit18_user(_this, CMapDataGetLevelLimit18_next); }; struct _portal_dummy* CMapDataGetLinkPortal20_wrapper(struct CMapData* _this, char* pPortalCode) { return CMapDataGetLinkPortal20_user(_this, pPortalCode, CMapDataGetLinkPortal20_next); }; char CMapDataGetMapCode22_wrapper(struct CMapData* _this) { return CMapDataGetMapCode22_user(_this, CMapDataGetMapCode22_next); }; struct _portal_dummy* CMapDataGetPortal24_wrapper(struct CMapData* _this, char* pPortalCode) { return CMapDataGetPortal24_user(_this, pPortalCode, CMapDataGetPortal24_next); }; struct _portal_dummy* CMapDataGetPortal26_wrapper(struct CMapData* _this, int nPortalIndex) { return CMapDataGetPortal26_user(_this, nPortalIndex, CMapDataGetPortal26_next); }; int CMapDataGetPortalInx28_wrapper(struct CMapData* _this, char* pPortalCode) { return CMapDataGetPortalInx28_user(_this, pPortalCode, CMapDataGetPortalInx28_next); }; char CMapDataGetRaceTown30_wrapper(struct CMapData* _this, float* fPos, char byRaceCode) { return CMapDataGetRaceTown30_user(_this, fPos, byRaceCode, CMapDataGetRaceTown30_next); }; bool CMapDataGetRandPosInDummy32_wrapper(struct CMapData* _this, struct _dummy_position* pPos, float* pNewPos, bool bRePos) { return CMapDataGetRandPosInDummy32_user(_this, pPos, pNewPos, bRePos, CMapDataGetRandPosInDummy32_next); }; bool CMapDataGetRandPosInRange34_wrapper(struct CMapData* _this, float* pStdPos, int nRange, float* pNewPos) { return CMapDataGetRandPosInRange34_user(_this, pStdPos, nRange, pNewPos, CMapDataGetRandPosInRange34_next); }; bool CMapDataGetRandPosVirtualDum36_wrapper(struct CMapData* _this, float* pStdPos, int nRange, float* pNewPos) { return CMapDataGetRandPosVirtualDum36_user(_this, pStdPos, nRange, pNewPos, CMapDataGetRandPosVirtualDum36_next); }; bool CMapDataGetRandPosVirtualDumExcludeStdRange38_wrapper(struct CMapData* _this, float* pStdPos, int nRange, int iExcludeRange, float* pNewPos) { return CMapDataGetRandPosVirtualDumExcludeStdRange38_user(_this, pStdPos, nRange, iExcludeRange, pNewPos, CMapDataGetRandPosVirtualDumExcludeStdRange38_next); }; void CMapDataGetRectInRadius40_wrapper(struct CMapData* _this, struct _pnt_rect* pRect, int nRadius, int nSecNum) { CMapDataGetRectInRadius40_user(_this, pRect, nRadius, nSecNum, CMapDataGetRectInRadius40_next); }; int CMapDataGetResDummySector42_wrapper(struct CMapData* _this, int nDummyIndex, float* pCurPos) { return CMapDataGetResDummySector42_user(_this, nDummyIndex, pCurPos, CMapDataGetResDummySector42_next); }; struct _sec_info* CMapDataGetSecInfo44_wrapper(struct CMapData* _this) { return CMapDataGetSecInfo44_user(_this, CMapDataGetSecInfo44_next); }; int CMapDataGetSectorIndex46_wrapper(struct CMapData* _this, float* pPos) { return CMapDataGetSectorIndex46_user(_this, pPos, CMapDataGetSectorIndex46_next); }; struct CObjectList* CMapDataGetSectorListObj48_wrapper(struct CMapData* _this, uint16_t wLayerIndex, unsigned int dwSecIndex) { return CMapDataGetSectorListObj48_user(_this, wLayerIndex, dwSecIndex, CMapDataGetSectorListObj48_next); }; struct CObjectList* CMapDataGetSectorListPlayer50_wrapper(struct CMapData* _this, uint16_t wLayerIndex, unsigned int dwSecIndex) { return CMapDataGetSectorListPlayer50_user(_this, wLayerIndex, dwSecIndex, CMapDataGetSectorListPlayer50_next); }; struct CObjectList* CMapDataGetSectorListTower52_wrapper(struct CMapData* _this, uint16_t wLayerIndex, unsigned int dwSecIndex) { return CMapDataGetSectorListTower52_user(_this, wLayerIndex, dwSecIndex, CMapDataGetSectorListTower52_next); }; int CMapDataGetSectorNumByLayerIndex54_wrapper(struct CMapData* _this, uint16_t wLayerIndex) { return CMapDataGetSectorNumByLayerIndex54_user(_this, wLayerIndex, CMapDataGetSectorNumByLayerIndex54_next); }; void CMapDataInit56_wrapper(struct CMapData* _this, struct _map_fld* pMapSet) { CMapDataInit56_user(_this, pMapSet, CMapDataInit56_next); }; bool CMapDataIsMapIn58_wrapper(struct CMapData* _this, float* fPos) { return CMapDataIsMapIn58_user(_this, fPos, CMapDataIsMapIn58_next); }; bool CMapDataLoadDummy60_wrapper(struct CMapData* _this, char* pszDummyCode, struct _dummy_position* pPos) { return CMapDataLoadDummy60_user(_this, pszDummyCode, pPos, CMapDataLoadDummy60_next); }; bool CMapDataLoadHolySystemDummy62_wrapper(struct CMapData* _this, char* pszDummyCode, struct _dummy_position* pPos) { return CMapDataLoadHolySystemDummy62_user(_this, pszDummyCode, pPos, CMapDataLoadHolySystemDummy62_next); }; void CMapDataOnLoop64_wrapper(struct CMapData* _this) { CMapDataOnLoop64_user(_this, CMapDataOnLoop64_next); }; bool CMapDataOpenMap66_wrapper(struct CMapData* _this, char* pszMapCode, struct _map_fld* pMapSet, bool bUse) { return CMapDataOpenMap66_user(_this, pszMapCode, pMapSet, bUse, CMapDataOpenMap66_next); }; bool CMapDataUpdateSecterList68_wrapper(struct CMapData* _this, struct CGameObject* pObj, unsigned int dwOldSec, unsigned int dwNewSec) { return CMapDataUpdateSecterList68_user(_this, pObj, dwOldSec, dwNewSec, CMapDataUpdateSecterList68_next); }; bool CMapData_LoadBind70_wrapper(struct CMapData* _this, char* pszMapCode) { return CMapData_LoadBind70_user(_this, pszMapCode, CMapData_LoadBind70_next); }; bool CMapData_LoadBspSec72_wrapper(struct CMapData* _this, char* pszMapCode) { return CMapData_LoadBspSec72_user(_this, pszMapCode, CMapData_LoadBspSec72_next); }; bool CMapData_LoadMonBlk74_wrapper(struct CMapData* _this, char* pszMapCode, struct _map_fld* pMapFld) { return CMapData_LoadMonBlk74_user(_this, pszMapCode, pMapFld, CMapData_LoadMonBlk74_next); }; bool CMapData_LoadPortal76_wrapper(struct CMapData* _this, char* pszMapCode) { return CMapData_LoadPortal76_user(_this, pszMapCode, CMapData_LoadPortal76_next); }; bool CMapData_LoadQuest78_wrapper(struct CMapData* _this, char* pszMapCode) { return CMapData_LoadQuest78_user(_this, pszMapCode, CMapData_LoadQuest78_next); }; bool CMapData_LoadResource80_wrapper(struct CMapData* _this, char* pszMapCode) { return CMapData_LoadResource80_user(_this, pszMapCode, CMapData_LoadResource80_next); }; bool CMapData_LoadSafe82_wrapper(struct CMapData* _this, char* pszMapCode) { return CMapData_LoadSafe82_user(_this, pszMapCode, CMapData_LoadSafe82_next); }; bool CMapData_LoadStart84_wrapper(struct CMapData* _this, char* pszMapCode) { return CMapData_LoadStart84_user(_this, pszMapCode, CMapData_LoadStart84_next); }; bool CMapData_LoadStoreDummy86_wrapper(struct CMapData* _this, char* pszMapCode) { return CMapData_LoadStoreDummy86_user(_this, pszMapCode, CMapData_LoadStoreDummy86_next); }; void CMapDatadtor_CMapData92_wrapper(struct CMapData* _this) { CMapDatadtor_CMapData92_user(_this, CMapDatadtor_CMapData92_next); }; ::std::array<hook_record, 44> CMapData_functions = { _hook_record { (LPVOID)0x140180050L, (LPVOID *)&CMapDatactor_CMapData2_user, (LPVOID *)&CMapDatactor_CMapData2_next, (LPVOID)cast_pointer_function(CMapDatactor_CMapData2_wrapper), (LPVOID)cast_pointer_function((void(CMapData::*)())&CMapData::ctor_CMapData) }, _hook_record { (LPVOID)0x1401855d0L, (LPVOID *)&CMapDataCheckCenterPosDummy4_user, (LPVOID *)&CMapDataCheckCenterPosDummy4_next, (LPVOID)cast_pointer_function(CMapDataCheckCenterPosDummy4_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(struct _dummy_position*))&CMapData::CheckCenterPosDummy) }, _hook_record { (LPVOID)0x140185100L, (LPVOID *)&CMapDataConvertLocal6_user, (LPVOID *)&CMapDataConvertLocal6_next, (LPVOID)cast_pointer_function(CMapDataConvertLocal6_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(struct _dummy_position*))&CMapData::ConvertLocal) }, _hook_record { (LPVOID)0x140185050L, (LPVOID *)&CMapDataConvertLocalToWorldDummy8_user, (LPVOID *)&CMapDataConvertLocalToWorldDummy8_next, (LPVOID)cast_pointer_function(CMapDataConvertLocalToWorldDummy8_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(struct CDummyPosTable*, bool))&CMapData::ConvertLocalToWorldDummy) }, _hook_record { (LPVOID)0x140184d30L, (LPVOID *)&CMapDataEnterMap10_user, (LPVOID *)&CMapDataEnterMap10_next, (LPVOID)cast_pointer_function(CMapDataEnterMap10_wrapper), (LPVOID)cast_pointer_function((void(CMapData::*)(struct CGameObject*, unsigned int))&CMapData::EnterMap) }, _hook_record { (LPVOID)0x140184ec0L, (LPVOID *)&CMapDataExitMap12_user, (LPVOID *)&CMapDataExitMap12_next, (LPVOID)cast_pointer_function(CMapDataExitMap12_wrapper), (LPVOID)cast_pointer_function((void(CMapData::*)(struct CGameObject*, unsigned int))&CMapData::ExitMap) }, _hook_record { (LPVOID)0x1401843c0L, (LPVOID *)&CMapDataGetBspInfo14_user, (LPVOID *)&CMapDataGetBspInfo14_next, (LPVOID)cast_pointer_function(CMapDataGetBspInfo14_wrapper), (LPVOID)cast_pointer_function((struct _bsp_info*(CMapData::*)())&CMapData::GetBspInfo) }, _hook_record { (LPVOID)0x140186440L, (LPVOID *)&CMapDataGetDummyPostion16_user, (LPVOID *)&CMapDataGetDummyPostion16_next, (LPVOID)cast_pointer_function(CMapDataGetDummyPostion16_wrapper), (LPVOID)cast_pointer_function((struct _dummy_position*(CMapData::*)(char*))&CMapData::GetDummyPostion) }, _hook_record { (LPVOID)0x140186690L, (LPVOID *)&CMapDataGetLevelLimit18_user, (LPVOID *)&CMapDataGetLevelLimit18_next, (LPVOID)cast_pointer_function(CMapDataGetLevelLimit18_wrapper), (LPVOID)cast_pointer_function((int(CMapData::*)())&CMapData::GetLevelLimit) }, _hook_record { (LPVOID)0x1401846e0L, (LPVOID *)&CMapDataGetLinkPortal20_user, (LPVOID *)&CMapDataGetLinkPortal20_next, (LPVOID)cast_pointer_function(CMapDataGetLinkPortal20_wrapper), (LPVOID)cast_pointer_function((struct _portal_dummy*(CMapData::*)(char*))&CMapData::GetLinkPortal) }, _hook_record { (LPVOID)0x1400c2cd0L, (LPVOID *)&CMapDataGetMapCode22_user, (LPVOID *)&CMapDataGetMapCode22_next, (LPVOID)cast_pointer_function(CMapDataGetMapCode22_wrapper), (LPVOID)cast_pointer_function((char(CMapData::*)())&CMapData::GetMapCode) }, _hook_record { (LPVOID)0x140184550L, (LPVOID *)&CMapDataGetPortal24_user, (LPVOID *)&CMapDataGetPortal24_next, (LPVOID)cast_pointer_function(CMapDataGetPortal24_wrapper), (LPVOID)cast_pointer_function((struct _portal_dummy*(CMapData::*)(char*))&CMapData::GetPortal) }, _hook_record { (LPVOID)0x1401846a0L, (LPVOID *)&CMapDataGetPortal26_user, (LPVOID *)&CMapDataGetPortal26_next, (LPVOID)cast_pointer_function(CMapDataGetPortal26_wrapper), (LPVOID)cast_pointer_function((struct _portal_dummy*(CMapData::*)(int))&CMapData::GetPortal) }, _hook_record { (LPVOID)0x140184600L, (LPVOID *)&CMapDataGetPortalInx28_user, (LPVOID *)&CMapDataGetPortalInx28_next, (LPVOID)cast_pointer_function(CMapDataGetPortalInx28_wrapper), (LPVOID)cast_pointer_function((int(CMapData::*)(char*))&CMapData::GetPortalInx) }, _hook_record { (LPVOID)0x1401862d0L, (LPVOID *)&CMapDataGetRaceTown30_user, (LPVOID *)&CMapDataGetRaceTown30_next, (LPVOID)cast_pointer_function(CMapDataGetRaceTown30_wrapper), (LPVOID)cast_pointer_function((char(CMapData::*)(float*, char))&CMapData::GetRaceTown) }, _hook_record { (LPVOID)0x1401857a0L, (LPVOID *)&CMapDataGetRandPosInDummy32_user, (LPVOID *)&CMapDataGetRandPosInDummy32_next, (LPVOID)cast_pointer_function(CMapDataGetRandPosInDummy32_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(struct _dummy_position*, float*, bool))&CMapData::GetRandPosInDummy) }, _hook_record { (LPVOID)0x140185b10L, (LPVOID *)&CMapDataGetRandPosInRange34_user, (LPVOID *)&CMapDataGetRandPosInRange34_next, (LPVOID)cast_pointer_function(CMapDataGetRandPosInRange34_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(float*, int, float*))&CMapData::GetRandPosInRange) }, _hook_record { (LPVOID)0x140185c70L, (LPVOID *)&CMapDataGetRandPosVirtualDum36_user, (LPVOID *)&CMapDataGetRandPosVirtualDum36_next, (LPVOID)cast_pointer_function(CMapDataGetRandPosVirtualDum36_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(float*, int, float*))&CMapData::GetRandPosVirtualDum) }, _hook_record { (LPVOID)0x140185ee0L, (LPVOID *)&CMapDataGetRandPosVirtualDumExcludeStdRange38_user, (LPVOID *)&CMapDataGetRandPosVirtualDumExcludeStdRange38_next, (LPVOID)cast_pointer_function(CMapDataGetRandPosVirtualDumExcludeStdRange38_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(float*, int, int, float*))&CMapData::GetRandPosVirtualDumExcludeStdRange) }, _hook_record { (LPVOID)0x1401843e0L, (LPVOID *)&CMapDataGetRectInRadius40_user, (LPVOID *)&CMapDataGetRectInRadius40_next, (LPVOID)cast_pointer_function(CMapDataGetRectInRadius40_wrapper), (LPVOID)cast_pointer_function((void(CMapData::*)(struct _pnt_rect*, int, int))&CMapData::GetRectInRadius) }, _hook_record { (LPVOID)0x140184950L, (LPVOID *)&CMapDataGetResDummySector42_user, (LPVOID *)&CMapDataGetResDummySector42_next, (LPVOID)cast_pointer_function(CMapDataGetResDummySector42_wrapper), (LPVOID)cast_pointer_function((int(CMapData::*)(int, float*))&CMapData::GetResDummySector) }, _hook_record { (LPVOID)0x1401843a0L, (LPVOID *)&CMapDataGetSecInfo44_user, (LPVOID *)&CMapDataGetSecInfo44_next, (LPVOID)cast_pointer_function(CMapDataGetSecInfo44_wrapper), (LPVOID)cast_pointer_function((struct _sec_info*(CMapData::*)())&CMapData::GetSecInfo) }, _hook_record { (LPVOID)0x140184790L, (LPVOID *)&CMapDataGetSectorIndex46_user, (LPVOID *)&CMapDataGetSectorIndex46_next, (LPVOID)cast_pointer_function(CMapDataGetSectorIndex46_wrapper), (LPVOID)cast_pointer_function((int(CMapData::*)(float*))&CMapData::GetSectorIndex) }, _hook_record { (LPVOID)0x140184890L, (LPVOID *)&CMapDataGetSectorListObj48_user, (LPVOID *)&CMapDataGetSectorListObj48_next, (LPVOID)cast_pointer_function(CMapDataGetSectorListObj48_wrapper), (LPVOID)cast_pointer_function((struct CObjectList*(CMapData::*)(uint16_t, unsigned int))&CMapData::GetSectorListObj) }, _hook_record { (LPVOID)0x1401848d0L, (LPVOID *)&CMapDataGetSectorListPlayer50_user, (LPVOID *)&CMapDataGetSectorListPlayer50_next, (LPVOID)cast_pointer_function(CMapDataGetSectorListPlayer50_wrapper), (LPVOID)cast_pointer_function((struct CObjectList*(CMapData::*)(uint16_t, unsigned int))&CMapData::GetSectorListPlayer) }, _hook_record { (LPVOID)0x140184910L, (LPVOID *)&CMapDataGetSectorListTower52_user, (LPVOID *)&CMapDataGetSectorListTower52_next, (LPVOID)cast_pointer_function(CMapDataGetSectorListTower52_wrapper), (LPVOID)cast_pointer_function((struct CObjectList*(CMapData::*)(uint16_t, unsigned int))&CMapData::GetSectorListTower) }, _hook_record { (LPVOID)0x1401866d0L, (LPVOID *)&CMapDataGetSectorNumByLayerIndex54_user, (LPVOID *)&CMapDataGetSectorNumByLayerIndex54_next, (LPVOID)cast_pointer_function(CMapDataGetSectorNumByLayerIndex54_wrapper), (LPVOID)cast_pointer_function((int(CMapData::*)(uint16_t))&CMapData::GetSectorNumByLayerIndex) }, _hook_record { (LPVOID)0x140180d40L, (LPVOID *)&CMapDataInit56_user, (LPVOID *)&CMapDataInit56_next, (LPVOID)cast_pointer_function(CMapDataInit56_wrapper), (LPVOID)cast_pointer_function((void(CMapData::*)(struct _map_fld*))&CMapData::Init) }, _hook_record { (LPVOID)0x140184b40L, (LPVOID *)&CMapDataIsMapIn58_user, (LPVOID *)&CMapDataIsMapIn58_next, (LPVOID)cast_pointer_function(CMapDataIsMapIn58_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(float*))&CMapData::IsMapIn) }, _hook_record { (LPVOID)0x140184250L, (LPVOID *)&CMapDataLoadDummy60_user, (LPVOID *)&CMapDataLoadDummy60_next, (LPVOID)cast_pointer_function(CMapDataLoadDummy60_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*, struct _dummy_position*))&CMapData::LoadDummy) }, _hook_record { (LPVOID)0x140183e30L, (LPVOID *)&CMapDataLoadHolySystemDummy62_user, (LPVOID *)&CMapDataLoadHolySystemDummy62_next, (LPVOID)cast_pointer_function(CMapDataLoadHolySystemDummy62_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*, struct _dummy_position*))&CMapData::LoadHolySystemDummy) }, _hook_record { (LPVOID)0x140181510L, (LPVOID *)&CMapDataOnLoop64_user, (LPVOID *)&CMapDataOnLoop64_next, (LPVOID)cast_pointer_function(CMapDataOnLoop64_wrapper), (LPVOID)cast_pointer_function((void(CMapData::*)())&CMapData::OnLoop) }, _hook_record { (LPVOID)0x140180d80L, (LPVOID *)&CMapDataOpenMap66_user, (LPVOID *)&CMapDataOpenMap66_next, (LPVOID)cast_pointer_function(CMapDataOpenMap66_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*, struct _map_fld*, bool))&CMapData::OpenMap) }, _hook_record { (LPVOID)0x140184be0L, (LPVOID *)&CMapDataUpdateSecterList68_user, (LPVOID *)&CMapDataUpdateSecterList68_next, (LPVOID)cast_pointer_function(CMapDataUpdateSecterList68_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(struct CGameObject*, unsigned int, unsigned int))&CMapData::UpdateSecterList) }, _hook_record { (LPVOID)0x1401832e0L, (LPVOID *)&CMapData_LoadBind70_user, (LPVOID *)&CMapData_LoadBind70_next, (LPVOID)cast_pointer_function(CMapData_LoadBind70_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*))&CMapData::_LoadBind) }, _hook_record { (LPVOID)0x1401815a0L, (LPVOID *)&CMapData_LoadBspSec72_user, (LPVOID *)&CMapData_LoadBspSec72_next, (LPVOID)cast_pointer_function(CMapData_LoadBspSec72_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*))&CMapData::_LoadBspSec) }, _hook_record { (LPVOID)0x140181850L, (LPVOID *)&CMapData_LoadMonBlk74_user, (LPVOID *)&CMapData_LoadMonBlk74_next, (LPVOID)cast_pointer_function(CMapData_LoadMonBlk74_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*, struct _map_fld*))&CMapData::_LoadMonBlk) }, _hook_record { (LPVOID)0x1401825b0L, (LPVOID *)&CMapData_LoadPortal76_user, (LPVOID *)&CMapData_LoadPortal76_next, (LPVOID)cast_pointer_function(CMapData_LoadPortal76_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*))&CMapData::_LoadPortal) }, _hook_record { (LPVOID)0x140183b60L, (LPVOID *)&CMapData_LoadQuest78_user, (LPVOID *)&CMapData_LoadQuest78_next, (LPVOID)cast_pointer_function(CMapData_LoadQuest78_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*))&CMapData::_LoadQuest) }, _hook_record { (LPVOID)0x1401835b0L, (LPVOID *)&CMapData_LoadResource80_user, (LPVOID *)&CMapData_LoadResource80_next, (LPVOID)cast_pointer_function(CMapData_LoadResource80_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*))&CMapData::_LoadResource) }, _hook_record { (LPVOID)0x140183f80L, (LPVOID *)&CMapData_LoadSafe82_user, (LPVOID *)&CMapData_LoadSafe82_next, (LPVOID)cast_pointer_function(CMapData_LoadSafe82_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*))&CMapData::_LoadSafe) }, _hook_record { (LPVOID)0x140182ee0L, (LPVOID *)&CMapData_LoadStart84_user, (LPVOID *)&CMapData_LoadStart84_next, (LPVOID)cast_pointer_function(CMapData_LoadStart84_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*))&CMapData::_LoadStart) }, _hook_record { (LPVOID)0x140182a10L, (LPVOID *)&CMapData_LoadStoreDummy86_user, (LPVOID *)&CMapData_LoadStoreDummy86_next, (LPVOID)cast_pointer_function(CMapData_LoadStoreDummy86_wrapper), (LPVOID)cast_pointer_function((bool(CMapData::*)(char*))&CMapData::_LoadStoreDummy) }, _hook_record { (LPVOID)0x140180590L, (LPVOID *)&CMapDatadtor_CMapData92_user, (LPVOID *)&CMapDatadtor_CMapData92_next, (LPVOID)cast_pointer_function(CMapDatadtor_CMapData92_wrapper), (LPVOID)cast_pointer_function((void(CMapData::*)())&CMapData::dtor_CMapData) }, }; }; // end namespace Detail END_ATF_NAMESPACE
f0f6a32c64622f02593633241dff16e73d7cfcc1
56d2fdabaee1425b5c553afeef802750792a2ae6
/Utility.cpp
8a3db14e4c10375b1784676ba6fb75c9b592ccfd
[]
no_license
Wimacs/ElecSim
b808f1f8d8ba68ece34bfead01da127b02585cca
16c55a4e1b46aaf5636862d790d02c9dfdc9fc84
refs/heads/master
2021-04-08T04:49:53.737174
2020-03-20T11:48:02
2020-03-20T11:48:02
248,741,807
0
0
null
null
null
null
UTF-8
C++
false
false
2,471
cpp
Utility.cpp
#include "Utility.h" #include <SFML/Graphics.hpp> #include <SFML/Window.hpp> #include <SFML/OpenGL.hpp> #include <cmath> #include <iostream> using namespace sf ; using namespace std ; void interpolation(float &x, float const& y, float const& time, float const& deltaTime) { x += (2.f*(y-x)*deltaTime)/time ; } float determinant(Vector2f const& u, Vector2f const& v) { float result = u.x*v.y - u.y*v.x ; return result ; } float dotProduct(Vector2f const& u, Vector2f const& v) { return u.x*v.x + u.y*v.y ; } float Angle(Vector2f const& v1, Vector2f const& v2) { float angle = atan2(determinant(v1,v2), dotProduct(v1,v2))*180/PI ; if(angle<0) angle = 360 + angle ; return angle ; } void drawPoint(Vector2f const& p, float const& radius, RenderWindow &window, Color const& color) { CircleShape c(radius) ; c.setFillColor(color) ; c.setPosition(p) ; c.setOrigin(radius,radius) ; window.draw(c) ; } void drawLine(Vector2f const& pos, Vector2f const& dir, RenderWindow &window, Color const& color) { VertexArray line(Lines, 2) ; line[0].position = pos ; line[0].color = color ; line[1].position = dir ; line[1].color = color ; window.draw(line) ; } float Distance(Vector2f const& u, Vector2f const& v) { return sqrt(pow(u.x-v.x,2)+pow(u.y-v.y,2)) ; } Vector2f rotatePoint(Vector2f const& point, Vector2f const& center, float const& angle) { float x = center.x + (point.x - center.x)*cos(angle*(PI/180)) - (point.y - center.y)*sin(angle*(PI/180)) ; float y = center.y + (point.x - center.x)*sin(angle*(PI/180)) + (point.y - center.y)*cos(angle*(PI/180)) ; return Vector2f(x,y) ; } float Norm (Vector2f const& v) { float result = sqrt(pow(v.x,2)+pow(v.y,2)) ; return result ; } bool mouseClickedOnce(Mouse::Button const& button, bool &clickedLastFrame) { bool result = false ; if(Mouse::isButtonPressed(button) && clickedLastFrame == false) { result = true ; clickedLastFrame = true ; } else if (Mouse::isButtonPressed(button) && clickedLastFrame == true) { result = false ; clickedLastFrame = true ; } else { result = false ; clickedLastFrame = false ; } return result ; } float clamp(float value, float min, float max) { float result ; if(value > max) result = max ; else if(value < min) result = min ; else result = value ; return result ; } Vector2f normalized(Vector2f const& vec) { return Vector2f(vec.x * 16/ sqrt(vec.x*vec.x + vec.y *vec.y), vec.y * 16/ sqrt(vec.x*vec.x + vec.y* vec.y)); }
3c69d82ad0c9e93908f878df9859814a26fb81a3
e48491a9186c5f4cef38fc0f5670dfa1d9c959cc
/wall_generation/extract_contours.cc
3eb40160b9fb6383da6c34d3ff5e28eb1a11ec84
[ "MIT" ]
permissive
GKrafft2/Inflatables
2431555ebd6b1b953dcf12dd425d79d4fec10847
6941fb1bf4a2f61a847605aea37adef97bf05d76
refs/heads/master
2023-08-12T12:49:41.283283
2021-10-07T23:05:46
2021-10-07T23:05:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,034
cc
extract_contours.cc
#include "extract_contours.hh" #include <MeshFEM/TriMesh.hh> #include <MeshFEM/MSHFieldWriter.hh> #include <list> #include <map> void extract_contours(const std::vector<MeshIO::IOVertex > &vertices, const std::vector<MeshIO::IOElement> &triangles, const std::vector<double> &sdf, const double targetEdgeSpacing, const double minContourLen, // length below which contours are removed Eigen::MatrixX3d &outVertices, std::vector<std::pair<size_t, size_t>> &outEdges) { constexpr size_t NONE = std::numeric_limits<size_t>::max(); std::vector<MeshIO::IOVertex > contourVertices; std::vector<MeshIO::IOElement> contourEdges; // The *primary* half-edge for each edge stores the point splitting the edge (if any) struct HalfEdgeData { size_t contourPt = NONE; }; struct BoundaryEdgeData { bool visited = false; }; using Mesh = TriMesh<TMEmptyData, HalfEdgeData, TMEmptyData, TMEmptyData, BoundaryEdgeData>; Mesh mesh(triangles, vertices.size()); std::vector<int> halfedgeForContourVertex; // index of the halfedge from which a vtx in contourVertices originated // Extract contour edges one triangle at a time. ("Marching triangles") { // index into contourVertices of the contour point for each half-edge // of a triangle (if any) std::vector<size_t> contourPtIdx; for (const auto tri : mesh.tris()) { contourPtIdx.clear(); for (const auto he : tri.halfEdges()) { size_t i = he.tail().index(), j = he. tip().index(); double vi = sdf.at(i), vj = sdf.at(j); if (vi * vj >= 0) continue; // no contour on this edge size_t idx = he.primary()->contourPt; if (idx == NONE) { // If this edge's contour point hasn't been created yet, do it now. // (1 - alpha) * vi + alpha * vj == 0 // ==> alpha = vi / (vi - vj) double alpha = vi / (vi - vj); Eigen::Vector3d pi = vertices[i].point, pj = vertices[j].point; auto p = ((1 - alpha) * pi + alpha * pj).eval(); // Construct a new contour vertex. idx = contourVertices.size(); contourVertices.emplace_back(p); halfedgeForContourVertex.push_back(he.primary().index()); he.primary()->contourPt = idx; } contourPtIdx.push_back(idx); } const size_t n = contourPtIdx.size(); if ((n == 1) || (n == 3)) throw std::runtime_error("Invalid field encountered"); if (n == 2) contourEdges.emplace_back(contourPtIdx[0], contourPtIdx[1]); } } std::cout << "Extracted " << contourVertices.size() << " contour points" << std::endl; // MeshIO::save("initial_contours.obj", contourVertices, contourEdges); std::list<std::vector<Eigen::Vector3d>> polylines; // There are often small contours incident the boundary due to noise; we must ensure // that when these contours are filtered out, the attached contour points on the boundaries // are cleared--otherwise the boundary resampling will retain arbitrarily close vertices. std::list<std::array<size_t, 2>> incidentBdryHEsOfPolyline; // Decompose the extracted contours into polylines that start and end at boundary intersections // (which much be preserved as "feature points"). For stripes not intersecting the boundary, // the closed polygon is represented by a polyline whose start and endpoint is an arbitrary // vertex on the boundary). // Note: contour vertices are guaranteed to be valence 2 (interior contour point) or 1 // (boundary contour point) since the boundary loops are not treated as contours. struct VTXAdjacencies { VTXAdjacencies() : adjIdx{{NONE, NONE}} { } void add(size_t idx) { if (adjIdx[0] == NONE) { adjIdx[0] = idx; return; } if (adjIdx[1] == NONE) { adjIdx[1] = idx; return; } throw std::runtime_error("Non-manifold contour vertex"); } size_t valence() const { return (adjIdx[0] != NONE) + (adjIdx[1] != NONE); } size_t next(size_t prevIdx) const { if (adjIdx[0] == prevIdx) return adjIdx[1]; if (adjIdx[1] == prevIdx) return adjIdx[0]; throw std::runtime_error("Prev contour vtx passed is not actually adjacent."); } std::array<size_t, 2> adjIdx; }; const size_t ncv = contourVertices.size(); std::vector<VTXAdjacencies> adjacency(ncv); for (size_t ei = 0; ei < contourEdges.size(); ++ei) { const auto &e = contourEdges[ei]; for (size_t i = 0; i < 2; ++i) { try { // std::cout << "Adding adjacency " << e[i] << ", " << e[(i + 1) % 2] << std::endl; adjacency[e[i]].add(e[(i + 1) % 2]); } catch (std::runtime_error &error) { size_t vi = e[i]; std::cout << "Exception while processing vertex " << vi << " adjacency" << std::endl; std::cout << "For contour edge " << ei << ": " << e[0] << ", " << e[1] << std::endl; std::cout << "Existing adjacency: " << adjacency[vi].adjIdx[0] << ", " << adjacency[vi].adjIdx[1] << std::endl; throw error; } } } // Get polylines starting at the boundary. These polylines must also end at // the boundary, so we simply stop when we reach another valence 1 vertex. std::vector<bool> added(ncv, false); for (size_t i = 0; i < ncv; ++i) { if (added[i]) continue; size_t val = adjacency[i].valence(); if (val == 0) throw std::runtime_error("Dangling vertex"); if (val == 2) continue; // Skip interior vertices // Construct the polyline starting at "i" polylines.emplace_back(); size_t heStart = halfedgeForContourVertex[i]; if (!mesh.halfEdge(heStart).isBoundary()) { std::cout << contourVertices[i].point.transpose() << std::endl; std::cout << mesh.halfEdge(heStart).tail().index() << " --> " << mesh.halfEdge(heStart).tip().index() << std::endl; throw std::runtime_error("Halfedge for start boundary contour vertex is not boundary."); } incidentBdryHEsOfPolyline.emplace_back(std::array<size_t, 2>{{heStart, NONE}}); auto &polyline = polylines.back(); { size_t last; for (size_t curr = i, prev = NONE; curr != NONE; std::tie(curr, prev) = std::make_pair(adjacency[curr].next(prev), curr)) { polyline.push_back(contourVertices[curr].point); assert(!added[curr]); added[curr] = true; last = curr; } size_t heEnd = halfedgeForContourVertex[last]; if (!mesh.halfEdge(heEnd).isBoundary()) throw std::runtime_error("Halfedge for end boundary contour vertex is not boundary."); incidentBdryHEsOfPolyline.back()[1] = heEnd; } } // Get closed polygons in the interior, starting at an arbitrary vertex. for (size_t i = 0; i < ncv; ++i) { if (added[i]) continue; polylines.emplace_back(); incidentBdryHEsOfPolyline.emplace_back(std::array<size_t, 2>{{NONE, NONE}}); auto &polyline = polylines.back(); size_t curr, prev; for (curr = i, prev = adjacency[i].adjIdx[0]; // traverse in an arbitrary direction !added[curr]; std::tie(curr, prev) = std::make_pair(adjacency[curr].next(prev), curr)) { polyline.push_back(contourVertices[curr].point); added[curr] = true; } assert(curr == i); // we better have returned to the starting point... polyline.push_back(contourVertices[i].point); // close the polyline by adding a second copy of the starting point. } { // Filter the small polylines std::list<std::vector<Eigen::Vector3d>> filteredPolylines; auto line_it = polylines.begin(); auto bhe_it = incidentBdryHEsOfPolyline.begin(); for (; line_it != polylines.end(); ++line_it, ++bhe_it) { if (bhe_it == incidentBdryHEsOfPolyline.end()) throw std::runtime_error("Zipper mismatch"); const auto &line = *line_it; const auto &bhe = *bhe_it; const size_t n = line.size(); double len = 0.0; for (size_t i = 1; i < n; ++i) len += (line[i] - line[i - 1]).norm(); if (len < minContourLen) { // Erase contour points on the boundary due to small polylines bool isBoundaryIncident = (bhe[0] != NONE); if (isBoundaryIncident != (bhe[1] != NONE)) throw std::runtime_error("Conflicting boundary incidence"); if (isBoundaryIncident) { mesh.halfEdge(bhe[0])->contourPt = NONE; mesh.halfEdge(bhe[1])->contourPt = NONE; } // Discard small polyline continue; } filteredPolylines.emplace_back(std::move(*line_it)); } if (bhe_it != incidentBdryHEsOfPolyline.end()) throw std::runtime_error("Zipper mismatch"); polylines = std::move(filteredPolylines); } // Extract the mesh boundary loop curves as well, conforming to the channel walls. // Start each boundary component traversal on an edge split by a contour. // Each step of the boundary loop traversal adds the current boundary // edge's contour point (if any) and the tip vertex--the tail vertex is added by // the previous edge. The contour points divide the boundary loop into individual polylines. bool firstPolyline = true; // Is this the first polyline for the current boundary loop? auto processBoundaryContourPt = [&](size_t ptIdx) { if (ptIdx == NONE) return; const auto &pt = contourVertices.at(ptIdx).point; if (!firstPolyline) // contour point ends the old polyline... polylines.back().push_back(pt); firstPolyline = false; polylines.emplace_back(); // ... and starts a new one. polylines.back().push_back(pt); }; // Contour point indices are stored on the halfedges: auto getBoundaryContourPt = [](decltype(mesh.boundaryEdge(0)) be) { return be.volumeHalfEdge()->contourPt; }; // Iterate over boundary loops for (auto be : mesh.boundaryEdges()) { if (be->visited) continue; // Start at a contour point auto start = be; do { if (getBoundaryContourPt(start) != NONE) break; } while ((start = start.next()) != be); if (getBoundaryContourPt(start) == NONE) throw std::runtime_error("Couldn't find contour-boundary intersection"); firstPolyline = true; auto curr = start; for (; !(curr->visited); curr = curr.next()) { processBoundaryContourPt(getBoundaryContourPt(curr)); polylines.back().push_back(vertices[curr.tip().volumeVertex().index()].point); curr->visited = true; } assert(curr == start); // We have now returned to the first boundary edge of the loop whose tail // vertex and contour point are needed to finalize the current polyline. polylines.back().push_back(vertices[curr.tail().volumeVertex().index()].point); polylines.back().push_back(contourVertices.at(getBoundaryContourPt(curr)).point); } std::cout << "Extracted " << polylines.size() << " distinct contour/boundary polylines" << std::endl; // Resample each polyline at targetEdgeSpacing std::list<std::vector<Eigen::Vector3d>> processedPolylines; size_t polylineIdx = 0; for (std::vector<Eigen::Vector3d> &line : polylines) { ++polylineIdx; const size_t n = line.size(); double len = 0.0; for (size_t i = 1; i < n; ++i) len += (line[i] - line[i - 1]).norm(); if (targetEdgeSpacing < std::numeric_limits<double>::max()) { const bool isPolygon = (line.front() - line.back()).norm() < 1e-16; const size_t newEdges = std::max<size_t>(isPolygon ? 3 : 1, // Prevent polygons degenerating into lines std::round(len / targetEdgeSpacing)); // Approximate target spacing const double spacing = len / newEdges; std::vector<Eigen::Vector3d> newPoints; newPoints.reserve(newEdges + 1); newPoints.push_back(line.front()); double distToNextPoint = spacing; for (size_t i = 1; i < n; ++i) { // Traverse original curve double distAlongEdge = 0; // Start at beginning of edge const auto &p0 = line[i - 1], &p1 = line[i ]; const double elen = (p1 - p0).norm(); while (distAlongEdge + distToNextPoint <= elen) { distAlongEdge += distToNextPoint; double alpha = distAlongEdge / elen; if (newPoints.size() == newEdges) { // The last point will be inserted at the end... // but verify we have actually reached the last point properly assert(i == n - 1); if (std::abs(elen - distAlongEdge) > 1e-10 * targetEdgeSpacing) throw std::runtime_error("Did not reach last point"); distToNextPoint = 0; goto traversalFinished; } newPoints.push_back((1.0 - alpha) * p0 + alpha * p1); distToNextPoint = spacing; } distToNextPoint -= (elen - distAlongEdge); // Move to the next edge assert(distToNextPoint > 0); } traversalFinished: // std::cout << "Finished line resampling at spacing " << spacing << " with final gap " << distToNextPoint << std::endl; assert(newPoints.size() == newEdges); // We should have already inserted all the points except the last... // ... and we should have reached the last point's location (up to machine precision). if (std::abs(distToNextPoint) > 1e-10 * targetEdgeSpacing) throw std::runtime_error("Did not reach last point"); newPoints.push_back(line.back()); line = std::move(newPoints); // replace the old polyline with the newly resampled one. } processedPolylines.emplace_back(std::move(line)); } // Generate output vertices and edges, removing duplicate vertices using Pt = std::tuple<double, double, double>; using PointGluingMap = std::map<Pt, size_t>; PointGluingMap indexForPoint; std::vector<Eigen::Vector3d> gluedVertices; auto addPoint = [&](Eigen::Vector3d pt) { auto key = std::make_tuple(pt[0], pt[1], pt[2]); auto it = indexForPoint.lower_bound(key); if ((it != indexForPoint.end()) && (it->first == key)) return it->second; size_t idx = gluedVertices.size(); gluedVertices.emplace_back(pt); indexForPoint.emplace_hint(it, key, idx); return idx; }; outEdges.clear(); for (const auto &line : processedPolylines) { size_t prevIdx = NONE; for (const auto &pt : line) { size_t idx = addPoint(pt); if (prevIdx != NONE) outEdges.emplace_back(prevIdx, idx); prevIdx = idx; } } outVertices.resize(gluedVertices.size(), 3); for (size_t i = 0; i < gluedVertices.size(); ++i) outVertices.row(i) = gluedVertices[i]; }
1d210b4d1f41877f3cf418400b874d5e67fa3a00
5824ebd4d6deca39646beff01989fec5998b24d3
/string_conversion.cpp
811aebe5b677d84a6995f4c74f73df9b2ac2ed24
[]
no_license
the-dagger/DS_progs
f4963388a8131ec5fb6b5945f26e65587c402bd5
2e51ab4fd7227a2376e3945e6a0aa090fc0f8bdf
refs/heads/master
2020-04-27T15:34:43.080806
2015-02-20T11:39:25
2015-02-20T11:39:25
30,927,833
1
1
null
null
null
null
UTF-8
C++
false
false
374
cpp
string_conversion.cpp
#include<iostream> #include<stdio.h> #include<string.h> using namespace std; char convert(char*); main() {char str[50]; cout<<"Enter the string in lowercarse\n"; gets(str); convert(str); } char convert(char s[]) { int i=0; for(i=0;i<strlen(s);i++) { if(s[i]=='e') s[i]='i'; s[i]=toupper(s[i]); } cout<<"The modified string is "<<s; }
3fbbb11e973ed961257af0a7f09f0e09ac1ca806
2d9937d9cbffc63ac12a136b7121e1a05798d2c7
/WordTree.cpp
a60ab45767ff662b3578f7654593eec94c290f73
[]
no_license
jsanchez2388/CSIT832-Final-Word-List
a8b99857d5048e8916e91d9e60a87fc2818d194a
66505976cc7a6f4552467a98da2e7d492e7157e5
refs/heads/master
2020-04-11T20:31:53.164375
2018-12-17T04:34:37
2018-12-17T04:34:37
162,074,327
0
0
null
null
null
null
UTF-8
C++
false
false
4,081
cpp
WordTree.cpp
#include "wordtree.h" WordTree::WordTree(const WordTree & rhs) { copyTree(root, rhs.root); //Call helper function to copy the tree } void WordTree::copyTree(WordNode*& copy, const WordNode* og) { if (og == nullptr) //if root of original tree is null { copy = nullptr; //set root of new tree to null } else { copy = new WordNode(og->m_data); //Create new WordNode and copy data copy->count = og->count; //Copy Count if (og->m_left != nullptr) { copyTree(copy->m_left, og->m_left); //Recursive call for left pointer } if (og->m_right != nullptr) { copyTree(copy->m_right, og->m_right); //Recursive call for right pointer } } } const WordTree& WordTree::operator=(const WordTree & rhs) { if (&rhs == this) //if right and left side are equal { return *this; } deleteTree(root); //Delete the tree copyTree(root, rhs.root); //Copy new values return *this; } void WordTree::add(ItemType v) { addNodePrivate(root, v); //Call helper function } void WordTree::addNodePrivate(WordNode* r, ItemType v) { if (root == nullptr) //If tree is empty { root = createNode(v); //Create a new node and point root to it } else if (v.compare(r->m_data) < 0) //If tree not empty, and value passed is less than value of node { if (r->m_left != nullptr) //If there is a left node { addNodePrivate(r->m_left, v); //Recursive call to function, passing same value and left pointer } else { r->m_left = createNode(v); //If there is not a left node, create one } } else if (v.compare(r->m_data) > 0) //If tree not empty, and value pass is greater than value of node { if (r->m_right != nullptr) //If there is a right node { addNodePrivate(r->m_right, v); //Recurvise vall to function, passing same value and right pointer } else { r->m_right = createNode(v); //If there is not a right node, create one } } else //If value passed is equal to value of node, update count { r->count += 1; } } WordNode * WordTree::createNode(ItemType v) { WordNode* temp = new WordNode(v); return temp; } unsigned int WordTree::CountNodes(WordNode* r) const { //Pre-order traversal to count nodes unsigned int count = 1; if (r->m_left != nullptr) { count += CountNodes(r->m_left); } if (r->m_right != nullptr) { count += CountNodes(r->m_right); } return count; } unsigned int WordTree::distinctWords() const { if (root == nullptr) { return 0; //If root is null, tree is empty. } return CountNodes(root); //Call helper function and return value } unsigned int WordTree::totalWords() const { unsigned int tCount = 0; //Variable used to store count return getTotal(root, tCount); //Call helper function and return value } unsigned int WordTree::getTotal(WordNode* r, unsigned int c) const { //Pre-order traversal to add up total words if (r == nullptr) { return 0; } c = r->count; if (r->m_left != nullptr) { c += getTotal(r->m_left, c); } if (r->m_right != nullptr) { c += getTotal(r->m_right, c); } return c; } ostream & operator<<(ostream & out, const WordTree & rhs) { rhs.printTree(out); //Call helper function return out; } const void WordTree::printTree(ostream& outFile) const { printTreePrivate(root, outFile); //Call private helper function } const void WordTree::printTreePrivate(WordNode* r, ostream& out) const { if (r != nullptr) //If node not null { if (r->m_left != nullptr) //If left node not null { printTreePrivate(r->m_left, out); //Recursive call to print out left node } out << r->m_data << " " << r->count << " "; //print out node value if (r->m_right != nullptr) //If right node not null { printTreePrivate(r->m_right, out); //Recursive call to print out left node } } } WordTree::~WordTree() { deleteTree(root); //Call helper function } void WordTree::deleteTree(WordNode *r) { //Post-Order traversal to delete tree if (r == nullptr) //If tree is empty just return { return; } deleteTree(r->m_left); //Recursive call to delete left node deleteTree(r->m_right); //Recursive call to delete right node delete r; //Delete node }
02d93a40cc57104d724a5a94baf999f4a061e27d
de390163287fda86b73df015d6b6a3dc5e1bf736
/Codechef/Jan 2020/Long Challenge/brute.cpp
867e53f337569fee457a969fdb6a09ac3c9c3795
[]
no_license
iamarshsingh/Competative_programming
fb71a7b62d4ba2846deae25203f9087f31a0b675
09418842d029b20d2df0f5b5a5e87619f44a18b3
refs/heads/master
2020-06-26T14:39:59.199295
2020-03-28T14:05:26
2020-03-28T14:05:26
97,026,462
1
0
null
null
null
null
UTF-8
C++
false
false
1,324
cpp
brute.cpp
#include <bits/stdc++.h> #define ld long double #define MOD 1000000007 #define N 1000006 #define F first #define S second #define all(x) x.begin(),x.end() #define INF 1000000000000000000 #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); #define randright srand(chrono::steady_clock::now().time_since_epoch().count()); using namespace std; // int my_rand(){ int a=rand(); int b=rand(); return a*(RAND_MAX+1)+b; } #define int long long int template<class T> ostream& operator<<(ostream& cout,vector<T> V) {cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';} template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P) {return cout<<'('<<P.x<<','<< P.y<<')';} int n,sum,ans=0; void check(multiset<int> arr, int curr){ if(arr.size()<=n){ if(curr==sum) ans++; return; } for(int i:arr){ cout<<i<<"\n"; arr.erase(i); check(arr, curr+i); arr.insert(i); } } void solve(){ int a; sum=0; cin>>n; multiset<int> arr; // unordered_map<int,int> freq; // set<int> un; for(int i=0;i<2*n;i++){ cin>>a; arr.insert(a); sum += a; } sum = sum/(n+1); check(arr,0); cout<<ans<<"\n"; } signed main(){ // fastio int t; cin>>t; while(t--){ solve(); } }
4b4d20a8f8030dd2e90609b12af4c400063b68eb
838a7cfeb7e4a9f79710f636a038b8e5b82e1ec2
/practica1/Euclides (1).cpp
8efadb03041173afd7f06cb18d810af467941280
[]
no_license
dianapao/Analisis-Algoritmos
6fc8cd834a28664d2ac067bcddbad0f5b60c5087
f8b1559b82a62a84903f783972401a2145cae2c4
refs/heads/main
2023-02-11T22:39:40.144182
2021-01-10T04:21:44
2021-01-10T04:21:44
328,301,579
0
0
null
null
null
null
ISO-8859-1
C++
false
false
788
cpp
Euclides (1).cpp
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ INSTITUTO POLITÉCNICO NACIONAL ESCUELA SUPERIOR DE CÓMPUTO Análisis de Algoritmos GRUPO: 3CV1 ALUMNOS: - De la Cruz Sierra Diana Paola - Raya Chávez Samuel Antonio TITULO: Algoritmo de Euclides para M.c.d. PROFESOR: Benjamín Luna Benoso FECHA: 20-10-2020 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */ #include <iostream> int main(){ int n, m, constante, mod1, mod=1, nCopia, mCopia; std::cout<<"Ingrese el valor de m\n"; std::cin>>m; std::cout<<"Ingrese el valor de n\n"; std::cin>>n; nCopia=n; mCopia=m; while(n!=0){ mod=m % n; m=n; //n=m*division+mod n=mod; } printf("El maximo comin divisor de %d y %d es %d",mCopia, nCopia, m); return 1; }
e26e96fe032e70bb6af1c8aa4636b4918d172be7
b848d4f79256c7738b0923420d8548a0121ceb81
/src/attributes/MetaDataAttributes.cc
64705725df776d04b2d4997eccb5ae018dcdf86b
[ "Zlib", "LGPL-2.0-or-later", "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "xlock", "LicenseRef-scancode-unknown-license-reference" ]
permissive
ecmwf/magics
57f5be3f4dcf339203688e7ce2bee92d9bc11318
ba612c99a681547d111e4088ddc722cfb77b0666
refs/heads/develop
2023-08-19T02:56:24.734190
2023-08-04T07:37:52
2023-08-04T07:37:52
160,882,537
50
14
Apache-2.0
2023-06-22T10:35:22
2018-12-07T22:39:04
Jupyter Notebook
UTF-8
C++
false
false
3,906
cc
MetaDataAttributes.cc
/****************************** LICENSE ******************************* * (C) Copyright 1996-2017 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation nor * does it submit to any jurisdiction. ******************************* LICENSE *******************************/ /*! \\file MetaDataAttributes.h \\brief Definition of MetaData Attributes class. This file is automatically generated. Do Not Edit! */ #include "MetaDataAttributes.h" #include "MagicsParameter.h" #include "ParameterSettings.h" using namespace magics; MetaDataAttributes::MetaDataAttributes(): path_(ParameterManager::getString("metadata_path")), javascript_(ParameterManager::getString("javascript_path")), profile_(ParameterManager::getString("profile_path")), world_file_(ParameterManager::getString("world_file_path")), wms_file_(ParameterManager::getString("metadata_wms_file")), efi_(ParameterManager::getString("efi_path")), efi_template_(ParameterManager::getString("efi_template")) { } MetaDataAttributes::~MetaDataAttributes() { } void MetaDataAttributes::set(const std::map<string, string>& params) { vector<string> prefix(1); int i = 0; prefix[i++] = "metadata"; setAttribute(prefix, "metadata_path", path_, params); setAttribute(prefix, "javascript_path", javascript_, params); setAttribute(prefix, "profile_path", profile_, params); setAttribute(prefix, "world_file_path", world_file_, params); setAttribute(prefix, "metadata_wms_file", wms_file_, params); setAttribute(prefix, "efi_path", efi_, params); setAttribute(prefix, "efi_template", efi_template_, params); } void MetaDataAttributes::copy(const MetaDataAttributes& other) { path_ = other.path_; javascript_ = other.javascript_; profile_ = other.profile_; world_file_ = other.world_file_; wms_file_ = other.wms_file_; efi_ = other.efi_; efi_template_ = other.efi_template_; } bool MetaDataAttributes::accept(const string& node) { if ( magCompare(node, "meta") ) return true; return false; } void MetaDataAttributes::set(const XmlNode& node) { bool apply = false; if ( this->accept(node.name()) == false ) return; if ( magCompare(node.name(), "meta") ) apply = true; if ( apply ) set(node.attributes()); else { } for (auto &elt : node.elements()) { } } void MetaDataAttributes::print(ostream& out) const { out << "Attributes["; out << " path = " << path_; out << " javascript = " << javascript_; out << " profile = " << profile_; out << " world_file = " << world_file_; out << " wms_file = " << wms_file_; out << " efi = " << efi_; out << " efi_template = " << efi_template_; out << "]" << "\n"; } void MetaDataAttributes::toxml(ostream& out) const { out << "\"meta\""; out << ", \"metadata_path\":"; niceprint(out,path_); out << ", \"javascript_path\":"; niceprint(out,javascript_); out << ", \"profile_path\":"; niceprint(out,profile_); out << ", \"world_file_path\":"; niceprint(out,world_file_); out << ", \"metadata_wms_file\":"; niceprint(out,wms_file_); out << ", \"efi_path\":"; niceprint(out,efi_); out << ", \"efi_template\":"; niceprint(out,efi_template_); } static MagicsParameter<string> metadata_path("metadata_path", ""); static MagicsParameter<string> javascript_path("javascript_path", ""); static MagicsParameter<string> profile_path("profile_path", ""); static MagicsParameter<string> world_file_path("world_file_path", ""); static MagicsParameter<string> metadata_wms_file("metadata_wms_file", ""); static MagicsParameter<string> efi_path("efi_path", ""); static MagicsParameter<string> efi_template("efi_template", "efi_template.js");
33f886b479b0326ff49d2bddade82bafbdbf9865
27d834e71940822e8bf08a2c63164524adcd6512
/structural/excercise.cpp
cd0f23f9388ca82f28605bc6ef824961bcebdb57
[]
no_license
sinigr54/DesignPatterns
8cf1edd878af118ea0f025ad7aa667526b30ef04
e427ec0a7d7627b314809b2092bccef2aa9c6ee0
refs/heads/master
2020-03-13T19:14:21.117012
2018-09-07T11:20:02
2018-09-07T11:20:02
131,249,648
0
0
null
null
null
null
UTF-8
C++
false
false
1,389
cpp
excercise.cpp
// // Created by Alexander Chekh on 05.05.2018. // #include <string> #include <sstream> #include <iostream> #include <typeinfo> using namespace std; struct Flower { virtual string str() = 0; }; struct Rose : Flower { string str() override { // todo return "A rose"; } }; struct RedFlower : Flower { Flower &flower; RedFlower(Flower &flower) : flower(flower) { } string str() override { ostringstream oss; if (typeid(flower) == typeid(Rose)) { oss << flower.str() << " thar is red"; } else if (typeid(flower) != typeid(RedFlower)) { oss << " and red"; } return oss.str(); } }; struct BlueFlower : Flower { Flower &flower; BlueFlower(Flower &flower) : flower(flower) { } string str() override { ostringstream oss; oss << flower.str(); if (typeid(flower) == typeid(Rose)) { oss << " thar is blue"; } else if (typeid(flower) != typeid(BlueFlower)) { oss << " and blue"; } return oss.str(); } }; void structural_exercise() { Rose rose; RedFlower redRose{rose}; RedFlower redRedRose{redRose}; BlueFlower blueRedRose{redRose}; cout << rose.str() << endl; cout << redRose.str() << endl; cout << redRedRose.str() << endl; cout << blueRedRose.str() << endl; }
28dfe396aa873dbf185567e7806332c9e08f6247
54df463fd68c1925401c4fcdb6612040b09d4749
/LearnCPP/BookLibrary.h
ddf9e27a0d4d3281292646a90e47c3730311fe66
[]
no_license
Arbint/LearnCPP
61de5c6152f81f9a32334b0a1716ef29d1fdd36d
644ea9476a6ef29b9101ab3f026fe1be3ae2fc1d
refs/heads/master
2021-01-13T03:38:09.473507
2018-11-16T03:05:00
2018-11-16T03:05:00
77,300,976
0
0
null
2016-12-25T00:55:12
2016-12-24T21:38:39
C++
UTF-8
C++
false
false
703
h
BookLibrary.h
#pragma once #include "UniversialInclude.h" //Forward declarations class Book; class Patron; class Date; struct Transaction; class BookLibrary { public: BookLibrary(); ~BookLibrary(); //API void AddBook(Book bookToAdd); void AddPatron(Patron patronToAdd); void checkOutBook(Book& bookToCheckOut, Patron& PatronCheckingIt, Date date); std::vector<Patron> getPatronOwesFee(); private: std::vector<Book> books; std::vector<Patron> patrons; std::vector<Transaction> transactions; private: bool isBookAvaliable(Book& bookToCheck); bool isPatronRegistered(Patron& patronToCheck); bool isPatronOwesFee(Patron& patronToCheck); void AddTransaction(Book& book, Patron& patron, Date& Date); };
5f87400f15f38702b8e0c8fe55ef1ea92a84c3e8
8ac232d9d039fc53f2d090852c2b28e0d9809ce5
/Websites/Codeforces/706B.cpp
bb49912fabfd03287e8b4b43dcced69b17a8869e
[ "MIT" ]
permissive
rem1niscence/Algorithms
43a6319dfc1fe438a7c81d59cbde41d0d3db3f91
4c9ec4119b0d92d5889f85b89fcb24f885a82373
refs/heads/master
2021-09-06T06:14:40.326863
2018-02-03T03:19:34
2018-02-03T03:19:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
821
cpp
706B.cpp
#include <iostream> #include <algorithm> #include <vector> #include <climits> #include <cmath> #include <map> #include <set> using namespace std; int binary_search_simple(int lo, int hi); bool check(int); vector<int> shops; int money; int main() { int numShops; cin >> numShops; for (int i = 0; i < numShops; i++) { int shop; cin >> shop; shops.push_back(shop); } int days; cin >> days; sort(shops.begin(), shops.end()); for (int i = 0; i < days; i++) { cin >> money; int buy; auto value = upper_bound(shops.begin(), shops.end(), money); if (value != shops.end() || *value != money) buy = distance(shops.begin(), value); else buy = -1; cout << buy << endl; } return 0; }
9afe8b9b13f04ccb1fce7d73be61766e3248198f
80cb092b8bdc1753a5d10740a0a940ca834d747e
/src/notification_manager.h
66c1151da0a171cf5b2f2406a8cca172e01ce893
[ "MIT" ]
permissive
macosunity/MagicalGirlMica
64cc39353d74729b2dd202cd7ed4267534a23562
45aedb4e21ae8f6fae0cdbfd1882c59551a44326
refs/heads/master
2021-01-21T23:33:56.962217
2015-04-01T20:36:17
2015-04-07T14:14:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,032
h
notification_manager.h
/* * notification_manager.h * * Copyright (C) 2014-2015 Ming Tsang, Nathan Ng * Refer to LICENSE for details */ #pragma once #include <deque> #include <memory> #include "event_stage_scene.h" namespace cocos2d { class Node; } namespace mica { class Notification; } namespace mica { /** * Manage and show Notification on screen * * @see Notification */ class NotificationManager final { public: NotificationManager(); ~NotificationManager(); /** * Push a new notification to the queue to be shown some time in the future * * @param notification */ void addNotifiction(std::unique_ptr<Notification> &&notification); /** * Remove the current notification and show the next one. Not necessary to * call after addNotifiction() as it's already been done */ void next(); private: void initSceneListener(); void showNext(); std::deque<std::unique_ptr<Notification>> m_queue; bool m_is_active; bool m_is_no_screen; cocos2d::Node *m_view; EventStageScene::Listener *m_scene_listener; }; }
118282ce9d3e848523c3bcac538e0e9405cda2e2
d4d321b6a8949627c537b904d8ece588009929bc
/cpp-version/Cube.h
751a44a1f5261e7dec86c7059c289b705456a97b
[]
no_license
benjaminhuanghuang/opgl-solar-sys
929efe923415ce1efd7d12d0efae50f57e04b990
5feae9f4d9a589974eef0a512f23342b2ece8d90
refs/heads/master
2023-03-27T02:36:11.046939
2021-03-30T02:25:07
2021-03-30T02:25:07
351,169,197
0
0
null
null
null
null
UTF-8
C++
false
false
138
h
Cube.h
#pragma once #include "Entity.h" #include <string> class Cube : public Entity { public: Cube(class SolarSystem *solar); ~Cube(); };
f6ee8c75b13c253d56fedb89b2e2ea6933c6420a
39cdb6ff35231538ef25c565181981ccf237cc30
/BOJ/4963.cpp
3e44ec6c090c0d2ff277c175e795068289f30ef2
[]
no_license
dittoo8/algorithm_cpp
51b35321f6cf16c8c1c259af746a9f35d5ba8b76
d9cdda322d3658ffc07744e4080c71faeee6370c
refs/heads/master
2023-08-03T14:49:08.808253
2021-02-16T04:13:53
2021-02-16T04:13:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,119
cpp
4963.cpp
#include <iostream> #include <string> using namespace std; int w, h; int map[52][52]; bool check[52][52]; int dx[] = {-1,-1,-1,0,0,0,1,1,1}, dy[] = {-1,0,1,-1,0,1,-1,0,1}; void dfs(int x, int y){ check[x][y] = 1; for(int i=0;i<9;i++){ int nx = x+ dx[i], ny = y + dy[i]; if(nx <0 || nx >= h|| ny <0 ||ny >=w) continue; if(map[nx][ny] && !check[nx][ny]) { dfs(nx,ny); } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); while(1){ cin >> w >> h; if (w == 0 && h == 0) break; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ map[i][j]= 0; check[i][j] = 0; } } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin >> map[i][j]; } } int cnt = 0; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(!check[i][j] && map[i][j]){ dfs(i,j); cnt++; } } } cout << cnt << endl; } return 0; }
a21ec70c15e5c9cb9516d66bd67520797a8bdb20
1dc301c61445e9ae3fb6c9ee7b54f0b30ebc711e
/RMQ_one_dimesion.cpp
a2845a77086982ff011f2ce4ae6acd841463b679
[]
no_license
royss7/cplusplus_algs
811d1317f3e12b74a9b03025c050de6b6877a767
a63871b72e114fa7a96fbf739d1c8faf63b5f3ad
refs/heads/main
2021-01-01T06:50:24.519627
2014-10-13T07:15:03
2014-10-13T07:15:03
25,119,700
0
0
null
null
null
null
UTF-8
C++
false
false
3,642
cpp
RMQ_one_dimesion.cpp
/* RMQ 是ST(sparse table 稀疏表)算法,可以再预处理时间复杂度 O(nlogn),查找时间O(1)的复杂度情况下完成数组中的范围最值查找。 比如n长度的数组A,查找A[i, j](A中i到j范围内的最大值). 方法1. 顺序遍历一次,O(n),缺点在于多次查找时时间代价太大 方法2. DP,用O(n*n)的空间存储所有范围内最值,缺点在于空间复杂度过大 方法3. RMQ,时间复杂度O(1),预处理O(nlogn)只要一次,空间复杂度O(nlogn) 方法4. 线段树 算法说明网站 http://comzyh.com/blog/archives/273/ 有动画演示,非常清晰。 二维RMQ from likunjk http://www.likunjk.com/article/1399210862.html */ #include <iostream> #include <cstdlib> #include <cmath> using namespace std; const int N = 9; // 数组大小 void rand_array(int *a) { for (int i = 0; i < N; ++ i) a[i] = static_cast<int>(rand()) % 100; } void show(int *a) { for (int i = 0; i < N; ++ i) cout << a[i] << " "; cout << endl; } // 顺序查找,O(n) int sequece_search(int *a, int i, int j) { int max = a[i]; for (int k = i + 1; k <= j; ++ k) { max = (max < a[k] ? a[k] : max); } return max; } // 普通DP int dp[N][N]; // dp[i][j] (j >= i) 表示i-j中的最大值 void initial_dp(int *a) { for (int i = 0; i < N; ++ i) dp[i][i] = a[i]; // 从下往上求去DP for (int j = N - 2; j >= 0; --j) { for (int k = j + 1; k < N; ++ k) { dp[j][k] = max(dp[j+1][k], dp[j][k-1]); } } } int dp_search(int *a, int i, int j) { return dp[i][j]; } // RMQ // 计算n以2为底数的log值 int logtwo(int n) { if (n == 0) return 0; int re = 0; while(n) { ++ re; n >>= 1; } return (re-1); } int **rmq_dp; void initial(int *a) { int row = logtwo(N) + 1; int column = N; // allocate rmq_dp rmq_dp = new int*[row]; for (int i = 0; i < row; ++ i) rmq_dp[i] = new int[column]; // 初始化 // f(i, 0) for (int i = 0; i < column; ++ i) rmq_dp[0][i] = a[i]; // f(i, j) int size = 1; for (int i = 1; i < row; ++ i) { size *= 2; // pow(2, i) for (int j = 0; j + size <= N; ++ j) { // f(i, j + 1) = max(f(i, j), f(i + size, j)) rmq_dp[i][j] = max(rmq_dp[i-1][j], rmq_dp[i-1][j + size >> 1]); } } /* // show for (int i = 0; i < N; ++ i) cout << i + 1 << "\t"; cout << endl; for (int i = 0 ;i < row; ++ i) { for (int j = 0; j < column; ++ j) cout << rmq_dp[i][j] << "\t"; cout << endl; } */ } int rmq_search(int *a, int i, int j) { int len = j - i + 1; int row = logtwo(len); return max(rmq_dp[row][i], rmq_dp[row][j - (1<<row)]); } // 测试 void test(int *a, int func(int *, int , int)) { cout << "max in 1, 9 : " << func(a, 0, 8) << endl; cout << "max in 2, 5 : " << func(a, 1, 4) << endl; cout << "max in 6, 6 : " << func(a, 5, 5) << endl; } int main() { int a[N]; // 随机产生一组N大小的数组 rand_array(a); show(a); // 顺序测试 cout << "顺序查找测试:" << endl; test(a, sequece_search); // 普通DP测试 cout << "普通DP查找测试:" << endl; initial_dp(a); test(a, dp_search); // rmq_dp test cout << "RMQ查找测试:" << endl; initial(a); test(a, rmq_search); // clear for (int i = 0; i <= logtwo(N); ++ i) delete []rmq_dp[i]; delete []rmq_dp; return 0; }
136cc09b5a3bc4639cfca1d2b519a5c5d765f241
480e33f95eec2e471c563d4c0661784c92396368
/DQMOffline/CalibCalo/interface/DQMSourceEleCalib.h
c6584b99bb980f45e16990b0be6d89d2038d4444
[ "Apache-2.0" ]
permissive
cms-nanoAOD/cmssw
4d836e5b76ae5075c232de5e062d286e2026e8bd
4eccb8a758b605875003124dd55ea58552b86af1
refs/heads/master-cmsswmaster
2021-01-23T21:19:52.295420
2020-08-27T08:01:20
2020-08-27T08:01:20
102,867,729
7
14
Apache-2.0
2022-05-23T07:58:09
2017-09-08T14:03:57
C++
ISO-8859-1
C++
false
false
2,346
h
DQMSourceEleCalib.h
#ifndef DQMSourceEleCalib_H #define DQMSourceEleCalib_H /** \class DQMSourceEleCalib * * * DQM Source for phi symmetry stream * * \author Stefano Argiro' * Andrea Gozzelino - Universita  e INFN Torino * */ #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "DQMServices/Core/interface/DQMEDAnalyzer.h" #include "DQMServices/Core/interface/DQMStore.h" #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" class DQMSourceEleCalib : public DQMEDAnalyzer { public: DQMSourceEleCalib(const edm::ParameterSet &); ~DQMSourceEleCalib() override; protected: void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; void analyze(const edm::Event &e, const edm::EventSetup &c) override; private: //! find the MOX DetId findMaxHit(const std::vector<std::pair<DetId, float>> &, const EcalRecHitCollection *, const EcalRecHitCollection *); //! fills local occupancy graphs void fillAroundBarrel(const EcalRecHitCollection *, int, int); void fillAroundEndcap(const EcalRecHitCollection *, int, int); int eventCounter_; //! Number of recHits per electron MonitorElement *recHitsPerElectron_; //! Number of electrons MonitorElement *ElectronsNumber_; //! ESCoP MonitorElement *ESCoP_; //! Occupancy MonitorElement *OccupancyEB_; MonitorElement *OccupancyEEP_; MonitorElement *OccupancyEEM_; MonitorElement *LocalOccupancyEB_; MonitorElement *LocalOccupancyEE_; //! recHits over associated recHits MonitorElement *HitsVsAssociatedHits_; /// object to monitor edm::EDGetTokenT<EcalRecHitCollection> productMonitoredEB_; /// object to monitor edm::EDGetTokenT<EcalRecHitCollection> productMonitoredEE_; //! electrons to monitor edm::EDGetTokenT<reco::GsfElectronCollection> productMonitoredElectrons_; /// Monitor every prescaleFactor_ events unsigned int prescaleFactor_; /// DQM folder name std::string folderName_; /// Write to file bool saveToFile_; /// Output file name if required std::string fileName_; }; #endif
5d8a0f9c0a001d64b4c3f909aeca2bb7d6a45eb8
f6a31b5e7487f79531d9e797357559496a7049ec
/src/stopcondition.cc
78f76172596b1feb3941f35a6aa64b080bd2ea56
[ "MIT" ]
permissive
RSkinderowicz/GPUBasedACS
290bfde4f55cc34e416ef8bc4e10a1c3e0a7a059
f2c85cd5bf10321b1e1a19ca8d1ecb3bd0054fb1
refs/heads/master
2021-01-20T12:27:56.160096
2017-05-05T10:32:42
2017-05-05T10:32:42
90,363,516
1
3
null
null
null
null
UTF-8
C++
false
false
606
cc
stopcondition.cc
#include <algorithm> #include "stopcondition.h" TimeoutStopCondition::TimeoutStopCondition(double max_seconds) : max_seconds_(std::max(0.0, max_seconds)), iteration_(0) { } void TimeoutStopCondition::init() { start_time_ = std::chrono::steady_clock::now(); iteration_ = 0; } void TimeoutStopCondition::next_iteration() { ++iteration_; } bool TimeoutStopCondition::is_reached() { auto now = std::chrono::steady_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(now - start_time_); return (elapsed.count() / 1.0e6) >= max_seconds_; }
fa87b3dc0f2a4c8cae9fce96c4e4e8b6a4f5bb2f
b4f7073600455d0938d153a902e4e1a9d0b990ff
/practical_exercises/10_day_practice/day2/递归1.cpp
d03c2abfa0dc6a3002e6979f078e8f3c6d1140d6
[]
no_license
Neflibatata/CPPThings
34784cb0d13b79484874e53e6f791a6448d283c2
52c5794f529396d438e447f5800836f56413cef5
refs/heads/master
2023-03-29T12:07:21.258987
2021-04-02T05:48:14
2021-04-02T05:48:14
353,918,825
5
0
null
null
null
null
UTF-8
C++
false
false
309
cpp
递归1.cpp
#include<iostream> using namespace std; int f(int n); int main(int argc, char const *argv[]) { cout<<"input x:"; int x; cin>>x; cout<<f(x)<<endl; system("pause"); return 0; } int f(int n) { if(n==0) { return 1; } else { return n*f(n-1); } }
233467d736bf09d0cceac07ef11826b690d44009
85a07135265b8b10afb8a9c33124b83ab6b96aae
/trajectory_planner/include/trajectory_planner/circle_trajectory.h
8582e2e22cb5970dedacd72f9b2c7f17640721b2
[]
no_license
sven-cremer/robot_utilities-dev
f183a99a4da7bbe8f9a7e50a32f76a1d07a92359
5d020257c22e449316f0534d10a0faae5bf81ed5
refs/heads/master
2021-07-13T04:08:57.957948
2016-03-14T06:36:06
2016-03-14T06:36:06
107,212,508
0
0
null
null
null
null
UTF-8
C++
false
false
1,299
h
circle_trajectory.h
/*! * \name CircleTrajectory * \brief Generates a circular trajectory * \details Generates a set of position and velocity vectors that represent a circular trajectory * \author Rommel Alonzo * \version 1.0 * \date January 22, 2016 * \pre First initialize the system. * \warning Improper use can crash your application * \copyright BSD License */ #ifndef CIRCULAR_TRAJECTORY_H_ #define CIRCULAR_TRAJECTORY_H_ // ROS #include <ros/ros.h> #include <geometry_msgs/Pose.h> #include <geometry_msgs/PoseArray.h> #include <apc_msgs/TrajectoryGenerate.h> #include <cmath> class CircleTrajectory { //This public section is for enum declaration only public: enum AXIS{ XY, XZ, YZ }; private: //!ROS Handle /*! ROS Handle */ ros::NodeHandle nh; std::vector<geometry_msgs::Pose> trajectory_positions; //geometry_msgs::Pose[] trajectory_positions; //geometry_msgs::PoseArray trajectory_positions; std::vector<double> trajectory_velocities; double radius; double max_theta; double max_azumith; int resolution; int sphere; AXIS axis; bool ready; public: CircleTrajectory(); ~CircleTrajectory(); void generate(); bool call(apc_msgs::TrajectoryGenerate::Request &req,apc_msgs::TrajectoryGenerate::Response &res); }; #endif
595ea550ab57343e618fcaf0fc887b60989a0bf4
3373dda63def755baebbebc5780ab8f421cf8836
/src/Texture2D.cpp
4db4fab7118506c0ba2bd28705600f5d0b5bd8f9
[]
no_license
TNielsen92pro/openGL
9a5bfb0ca24ed15addf4f68c29b18c4afb4b8637
c5df8827f6bfb4f19978af328cc19e56635b1223
refs/heads/master
2020-12-03T08:47:13.931518
2020-01-06T11:19:03
2020-01-06T11:19:03
231,259,021
0
0
null
null
null
null
UTF-8
C++
false
false
1,357
cpp
Texture2D.cpp
#include "Texture2D.h" #include <glad/glad.h> #include <GLFW/glfw3.h> #include <GL/gl.h> #include <iostream> Texture2D::Texture2D(int width, int height, GLuint gl_internal_format, GLuint gl_format, GLuint gl_type, void* data) { width_ = width; height_ = height; glGenTextures(1, &gl_location_); glBindTexture(GL_TEXTURE_2D, gl_location_); glTexImage2D(GL_TEXTURE_2D, 0, gl_internal_format, width, height, 0, gl_format, gl_type, data); unbind(); } Texture2D::~Texture2D() { glDeleteTextures(1, &gl_location_); } void Texture2D::bind() { glBindTexture(GL_TEXTURE_2D, gl_location_); } void Texture2D::bind(GLuint texture_location) { glActiveTexture(GL_TEXTURE0 + texture_location); bind(); } void Texture2D::unbind() { glBindTexture(GL_TEXTURE_2D, 0); } void Texture2D::set_wrap_s(GLuint wrap) { bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); unbind(); } void Texture2D::set_wrap_t(GLuint wrap) { bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); unbind(); } void Texture2D::set_min_filter(GLuint filter) { bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); unbind(); } void Texture2D::set_mag_filter(GLuint filter) { bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); unbind(); }
82500cfe9ab733285f293713c3c95847c83ff006
0f08276e557de8437759659970efc829a9cbc669
/problems/p78.h
d3a86ca400cbdbd8a95c159618b2c27e989a460d
[]
no_license
petru-d/leetcode-solutions-reboot
4fb35a58435f18934b9fe7931e01dabcc9d05186
680dc63d24df4c0cc58fcad429135e90f7dfe8bd
refs/heads/master
2023-06-14T21:58:53.553870
2021-07-11T20:41:57
2021-07-11T20:41:57
250,795,996
0
0
null
null
null
null
UTF-8
C++
false
false
713
h
p78.h
#pragma once #include <bitset> #include <vector> #include <cmath> namespace p78 { class Solution { public: std::vector<std::vector<int>> subsets(std::vector<int>& nums) { std::vector<std::vector<int>> pset; size_t p = static_cast<size_t>(pow(2, nums.size())); for (size_t i = 0; i < p; ++i) { std::bitset<32> bits(i); std::vector<int> subset; for (size_t b = 0; b < nums.size(); ++b) if (bits[b]) subset.push_back(nums[b]); pset.emplace_back(std::move(subset)); } return pset; } }; }
299e3dbe677bb8ab5f67f8791a4cb60a7f1c8605
11e772891abd7f7ff023b9d242234fee54958528
/include/Arithmetic.h
08b0d76fe9b3de84ee753fe46559b07d7785317d
[ "MIT" ]
permissive
atskajita/Halide-elements
e9daf6841350c5f493d1643db52e03549109ac0f
e3daf255a88996b290796b5f0f010e1e30f928e3
refs/heads/master
2021-08-23T12:33:53.596118
2017-11-12T20:14:45
2017-11-12T20:14:45
110,607,825
0
0
null
2017-11-13T22:04:19
2017-11-13T22:04:19
null
UTF-8
C++
false
false
894
h
Arithmetic.h
#ifndef HALIDE_ELEMENT_ARITHMETIC_H #define HALIDE_ELEMENT_ARITHMETIC_H #include "Halide.h" namespace Halide { namespace Element { template<typename T> Halide::Func add(Halide::Func src0, Halide::Func src1) { using namespace Halide; Var x, y; Func dst("dst"); Expr srcval0 = cast<uint64_t>(src0(x, y)), srcval1 = cast<uint64_t>(src1(x, y)); Expr dstval = min(srcval0 + srcval1, cast<uint64_t>(type_of<T>().max())); dst(x, y) = cast<T>(dstval); return dst; } template<typename T> Halide::Func add_scalar(Halide::Func src0, Halide::Expr val) { using namespace Halide; Var x, y; Func dst("dst"); Expr srcval0 = cast<uint64_t>(src0(x, y)), srcval1 = cast<uint64_t>(val); Expr dstval = min(srcval0 + srcval1, cast<uint64_t>(type_of<T>().max())); dst(x, y) = cast<T>(dstval); return dst; } } } #endif
5cc933b00309640b8f970b24fd2ce861ce7cfb01
5cbb7a94f5470f5107ed5dfb386c4bd59050200c
/code/unitTest/UT_LiangZhu/src/test/file_system_ut.cpp
6bf8adad9a35f6e8d7ac1ab687394a2c97746d95
[]
no_license
hill9932/OpenTaker
d339e03029b28e907eb3351e82071d09cc31715a
3b497a4fbf86248cf8bb717c6a4e495172e5e287
refs/heads/master
2021-01-25T07:18:45.690675
2015-06-15T14:51:12
2015-06-15T14:51:12
27,569,793
0
0
null
null
null
null
UTF-8
C++
false
false
2,618
cpp
file_system_ut.cpp
#include "file_system.h" #include "gtest/gtest.h" using namespace LiangZhu; /** * @Function: Test function of IsFileExist() **/ TEST(FileSystem_TestCase, IsFileExist_Test) { CStdString fileName = "./noexist/FileSystemTest.txt"; DeletePath(fileName); ASSERT_FALSE(IsFileExist(fileName)); CreateFilePath(fileName); ASSERT_TRUE(IsFileExist(fileName)); DeletePath(fileName); ASSERT_FALSE(IsFileExist(fileName)); DeletePath("./noexist"); } /** * @Function: Test function of IsDirExist() **/ TEST(FileSystem_TestCase, IsDirExist_Test) { CStdString dirPath = "./dir1/dir2/dir3"; ASSERT_FALSE(IsDirExist(dirPath)); CreateAllDir(dirPath); ASSERT_TRUE(IsDirExist(dirPath)); DeletePath(dirPath); ASSERT_FALSE(IsDirExist(dirPath)); ASSERT_TRUE(IsDirExist("./dir1/dir2")); ASSERT_TRUE(IsDirExist("./dir1")); RemoveDir("./dir1"); ASSERT_FALSE(IsDirExist("./dir1/dir2")); ASSERT_FALSE(IsDirExist("./dir1")); } /** * @Function: Test function of GetFilePath() **/ TEST(FileSystem_TestCase, GetFilePath_Test) { CStdString filePath = "./dir1/dir2/dir3/file_name.txt"; ASSERT_STREQ(GetFilePath(filePath).c_str(), "./dir1/dir2/dir3"); filePath = "./dir1/dir2/dir3/"; ASSERT_STREQ(GetFilePath(filePath).c_str(), "./dir1/dir2/dir3"); filePath = "./dir1/"; ASSERT_STREQ(GetFilePath(filePath).c_str(), "./dir1"); filePath = "./dir1////"; ASSERT_STREQ(GetFilePath(filePath).c_str(), "./dir1"); filePath = "./dir1/\\\\//"; ASSERT_STREQ(GetFilePath(filePath).c_str(), "./dir1"); filePath = "//"; ASSERT_STREQ(GetFilePath(filePath).c_str(), "/"); filePath = "\\"; ASSERT_STREQ(GetFilePath(filePath).c_str(), "\\"); filePath = "D:"; ASSERT_STREQ(GetFilePath(filePath).c_str(), ""); filePath = "D:/"; ASSERT_STREQ(GetFilePath(filePath).c_str(), "D:"); } /** * @Function: Test function of GetFileName() **/ TEST(FileSystem_TestCase, GetFileName_Test) { CStdString filePath = "./dir1/dir2/dir3/file_name.txt"; ASSERT_STREQ(GetFileName(filePath).c_str(), "file_name.txt"); filePath = "./dir1/dir2/dir3/"; ASSERT_STREQ(GetFileName(filePath).c_str(), ""); filePath = "./dir1/"; ASSERT_STREQ(GetFileName(filePath).c_str(), ""); filePath = "./dir1////"; ASSERT_STREQ(GetFileName(filePath).c_str(), ""); filePath = "./dir1/\\\\//"; ASSERT_STREQ(GetFileName(filePath).c_str(), ""); filePath = "//"; ASSERT_STREQ(GetFileName(filePath).c_str(), ""); filePath = "\\"; ASSERT_STREQ(GetFileName(filePath).c_str(), ""); }
5adfcb4da5f7bfd70ca5b68cd8284ab0b8373007
3ffd3e1de13455159c3e2c2706650e1662cecf10
/arm/o.le-v7-g/.moc/moc_SendVcard.cpp
6e970db0cbc23b2ac6fb871dfc53bfb0b3e34b03
[]
no_license
jtokuah/NFCPaymentApp
247ce7fdae6aa6b2b3f445d5ad8e8fa6f2005ce1
9de2fe344ce11d68cdc9fca24809121dcb5d80bb
refs/heads/master
2020-05-18T06:08:24.742988
2013-11-07T00:37:13
2013-11-07T00:37:13
12,140,990
1
1
null
null
null
null
UTF-8
C++
false
false
7,337
cpp
moc_SendVcard.cpp
/**************************************************************************** ** Meta object code from reading C++ file 'SendVcard.hpp' ** ** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.5) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../../src/SendVcard.hpp" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'SendVcard.hpp' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 63 #error "This file was generated using the moc from 4.8.5. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_SendVcard[] = { // content: 6, // revision 0, // classname 0, 0, // classinfo 15, 14, // methods 5, 89, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 7, // signalCount // signals: signature, parameters, type, tag, flags 11, 10, 10, 10, 0x05, 18, 10, 10, 10, 0x05, 43, 10, 10, 10, 0x05, 67, 10, 10, 10, 0x05, 90, 10, 10, 10, 0x05, 111, 10, 10, 10, 0x05, 133, 10, 10, 10, 0x05, // slots: signature, parameters, type, tag, flags 148, 10, 10, 10, 0x0a, 155, 10, 10, 10, 0x0a, 190, 179, 10, 10, 0x0a, 218, 179, 10, 10, 0x0a, 253, 245, 10, 10, 0x0a, 285, 279, 10, 10, 0x0a, 316, 309, 10, 10, 0x0a, 341, 10, 10, 10, 0x0a, // properties: name, type, flags 368, 360, 0x0a495003, 380, 360, 0x0a495003, 391, 360, 0x0a495003, 400, 360, 0x0a495003, 407, 360, 0x0a495003, // properties: notify_signal_id 1, 2, 3, 4, 5, 0 // eod }; static const char qt_meta_stringdata_SendVcard[] = { "SendVcard\0\0back()\0detectFirstNameChanged()\0" "detectLastNameChanged()\0detectAddressChanged()\0" "detectEmailChanged()\0detectMobileChanged()\0" "showEventLog()\0show()\0startSendVcardProcess()\0" "first_name\0onFirstNameChanged(QString)\0" "onLastNameChanged(QString)\0address\0" "onAddressChanged(QString)\0email\0" "onEmailChanged(QString)\0mobile\0" "onMobileChanged(QString)\0backFromEventLog()\0" "QString\0_first_name\0_last_name\0_address\0" "_email\0_mobile\0" }; void SendVcard::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { Q_ASSERT(staticMetaObject.cast(_o)); SendVcard *_t = static_cast<SendVcard *>(_o); switch (_id) { case 0: _t->back(); break; case 1: _t->detectFirstNameChanged(); break; case 2: _t->detectLastNameChanged(); break; case 3: _t->detectAddressChanged(); break; case 4: _t->detectEmailChanged(); break; case 5: _t->detectMobileChanged(); break; case 6: _t->showEventLog(); break; case 7: _t->show(); break; case 8: _t->startSendVcardProcess(); break; case 9: _t->onFirstNameChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 10: _t->onLastNameChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 11: _t->onAddressChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 12: _t->onEmailChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 13: _t->onMobileChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 14: _t->backFromEventLog(); break; default: ; } } } const QMetaObjectExtraData SendVcard::staticMetaObjectExtraData = { 0, qt_static_metacall }; const QMetaObject SendVcard::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_SendVcard, qt_meta_data_SendVcard, &staticMetaObjectExtraData } }; #ifdef Q_NO_DATA_RELOCATION const QMetaObject &SendVcard::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION const QMetaObject *SendVcard::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } void *SendVcard::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_SendVcard)) return static_cast<void*>(const_cast< SendVcard*>(this)); return QObject::qt_metacast(_clname); } int SendVcard::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 15) qt_static_metacall(this, _c, _id, _a); _id -= 15; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = getFirstName(); break; case 1: *reinterpret_cast< QString*>(_v) = getLastName(); break; case 2: *reinterpret_cast< QString*>(_v) = getAddress(); break; case 3: *reinterpret_cast< QString*>(_v) = getEmail(); break; case 4: *reinterpret_cast< QString*>(_v) = getMobile(); break; } _id -= 5; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setFirstName(*reinterpret_cast< QString*>(_v)); break; case 1: setLastName(*reinterpret_cast< QString*>(_v)); break; case 2: setAddress(*reinterpret_cast< QString*>(_v)); break; case 3: setEmail(*reinterpret_cast< QString*>(_v)); break; case 4: setMobile(*reinterpret_cast< QString*>(_v)); break; } _id -= 5; } else if (_c == QMetaObject::ResetProperty) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 5; } #endif // QT_NO_PROPERTIES return _id; } // SIGNAL 0 void SendVcard::back() { QMetaObject::activate(this, &staticMetaObject, 0, 0); } // SIGNAL 1 void SendVcard::detectFirstNameChanged() { QMetaObject::activate(this, &staticMetaObject, 1, 0); } // SIGNAL 2 void SendVcard::detectLastNameChanged() { QMetaObject::activate(this, &staticMetaObject, 2, 0); } // SIGNAL 3 void SendVcard::detectAddressChanged() { QMetaObject::activate(this, &staticMetaObject, 3, 0); } // SIGNAL 4 void SendVcard::detectEmailChanged() { QMetaObject::activate(this, &staticMetaObject, 4, 0); } // SIGNAL 5 void SendVcard::detectMobileChanged() { QMetaObject::activate(this, &staticMetaObject, 5, 0); } // SIGNAL 6 void SendVcard::showEventLog() { QMetaObject::activate(this, &staticMetaObject, 6, 0); } QT_END_MOC_NAMESPACE
f84d2bf24fb4c19abfdac5118d0b56a59e55ad73
e9e89d9b19b2ba900b5ac890cbd5c63116d0d461
/src/common.h
9eeaa8ff130b1b444d94ceba2eb0c2ae88a9d826
[ "MIT" ]
permissive
waty2246/SimpleEngine
f10b4902e457c081e3571cf06835cc5851f44bb3
64bce381b14ee087ec96b9d86491640d5277753f
refs/heads/master
2023-07-22T17:58:00.694097
2021-09-09T10:31:47
2021-09-09T10:46:37
404,663,753
0
0
null
null
null
null
UTF-8
C++
false
false
315
h
common.h
#pragma once #include <functional> #include <typeindex> #include <algorithm> #include <type_traits> #include <iterator> #include <exception> #include <chrono> #include <typeinfo> #include <sstream> #include <string> #include <memory> #include <vector> #include <map> #include <Windows.h> #include <windowsx.h>
ea8f34b4829ca62493fe5c4166ce7454fd782385
23ae9e82e348ec74482e43ca451e92d0e25e5218
/HeapOfStudents/HeapAddress.cpp
089d38aeab13d5c367e2aa12abf6e13f173b0a5d
[]
no_license
JoshEwart/portfolio
c2e4c7a59ede317f84628df5b37e0aab92e9454b
1135ff81410b6eedaa9fa9b052c4c936919c94b4
refs/heads/master
2020-03-27T04:16:38.760939
2018-06-28T18:23:50
2018-06-28T18:23:50
145,916,611
0
0
null
null
null
null
UTF-8
C++
false
false
1,220
cpp
HeapAddress.cpp
//HeapAddress.cpp #include <iostream> #include <string> #include "HeapAddress.h" using namespace std; //HeapAddress constructor HeapAddress::HeapAddress(){ HeapAddress:line1 = "Line1"; HeapAddress::line2 = "Line2"; HeapAddress::city = "city"; HeapAddress::state = "state"; HeapAddress::zip = "zipcode"; }; //get/set functions defined void HeapAddress::setLine1(string line1){ HeapAddress::line1 = line1; }//end setline1 string HeapAddress::getLine1(){ return line1; }//end getline1 void HeapAddress::setLine2(string line2){ HeapAddress::line2 = line2; }//end setline2 string HeapAddress::getLine2(){ return line2; }//end getline2 void HeapAddress::setCity(string city){ HeapAddress::city = city; }//end set city string HeapAddress::getCity(){ return city; }//end getcity void HeapAddress::setState(string state){ HeapAddress::state = state; }//end state string HeapAddress::getState(){ return state; }//end getstate void HeapAddress::setZip(string zip){ HeapAddress::zip = zip; }//end setzip string HeapAddress::getZip(){ return zip; }//end getzip string HeapAddress::printAddreses(){ return line1 + "," + line2 + '\n' + city + "," + state + "," + zip; }; //HeapAddress::~HeapAddress(){ //};
ae1396c2e9379b690727e5bd9ac2dd82a25e4f19
69a956af96416defc4ed9b0a684638bd9b027e36
/database/databaselab/form.h
db370dcb0095dfc3d84f3be443be4fdb81d5866d
[]
no_license
SJ110/some_course_of_three_second
f7664eb8c37435f15732d42d68d00ca32eadeb75
1970cf50999f72163c429b7e9b27507ac668f53e
refs/heads/master
2020-04-28T11:14:14.833315
2019-08-17T15:42:39
2019-08-17T15:42:39
175,229,818
0
0
null
null
null
null
UTF-8
C++
false
false
836
h
form.h
#ifndef FORM_H #define FORM_H /* * 参考自https://blog.csdn.net/qiufenpeng/article/details/81259344 * */ #include <QWidget> #include<QDateTime> #include<QMessageBox> #include"dbconnector.h" #include"showdingd.h" #include"mycombobox.h" #pragma execution_character_set("utf-8") namespace Ui { class Form; } class Form : public QWidget { Q_OBJECT public: explicit Form(QWidget *parent = 0); ~Form(); private slots: void on_retButton_clicked(); void on_sureButton_clicked(); private: Ui::Form *ui; showDingD* dingd; dbConnect db; QString str0; QString str1; private slots: void boxid(); void boxname(); void reshow(); void on_lineEdit_editingFinished(); signals: void sendsignal3(); void sendsignal4(); // void sendString(QString &s); }; #endif // FORM_H
9f4768684b90e9e98fafda2203677e8ff69a1314
210706db16a8e9572b3beb410a5b6c3c85603a2a
/Factory/AbstractFactory.hpp
4d9b437976a6e2911865554d6341014ce50be8c9
[]
no_license
Rezerol/designpatterns
53ff458a2dfc92fc09a9ebc6b8f541a37a6ce197
8ded661a2ffccdd84cd7cfed0c7b9ec1dc57b644
refs/heads/main
2023-04-05T00:50:38.740919
2021-04-15T16:16:21
2021-04-15T16:16:21
353,878,853
0
0
null
null
null
null
UTF-8
C++
false
false
465
hpp
AbstractFactory.hpp
//AbstractProduct_t is abstract product template<class AbstractProduct_t> class AbstractFactory { public: virtual AbstractProduct_t *create_product() = 0; virtual ~AbstractFactory(){} }; //ConcreteProduct_t is concrete product template<class AbstractProduct_t, class ConcreteProduct_t> class ConcreteFactory : public AbstractFactory<AbstractProduct_t> { public: AbstractProduct_t *create_product() { return new ConcreteProduct_t(); } };
4f9a12b07eb49da8f597ecbbad339bc8f3f5777a
a0bdedcc814dfcbf6f1742c398b64a31619af4df
/ideccmbd/CrdIdecScf/PnlIdecScfQcd.cpp
3b5a84a6471c6c2c21fb9ccc9881dbad82c3ea31
[ "BSD-2-Clause" ]
permissive
mpsitech/idec_public
ec7231939b8987fd66482d99276609e16d4ad3f7
a74cf1c7095e08ee61b237fddc1642f83dbb852d
refs/heads/master
2021-05-13T20:43:55.046131
2018-06-09T16:11:30
2018-06-09T16:11:30
116,916,593
0
0
null
null
null
null
UTF-8
C++
false
false
7,946
cpp
PnlIdecScfQcd.cpp
/** * \file PnlIdecScfQcd.cpp * job handler for job PnlIdecScfQcd (implementation) * \author Alexander Wirthmueller * \date created: 30 Dec 2017 * \date modified: 30 Dec 2017 */ #ifdef IDECCMBD #include <Ideccmbd.h> #else #include <Idecd.h> #endif #include "PnlIdecScfQcd.h" #include "PnlIdecScfQcd_blks.cpp" #include "PnlIdecScfQcd_evals.cpp" /****************************************************************************** class PnlIdecScfQcd ******************************************************************************/ PnlIdecScfQcd::PnlIdecScfQcd( XchgIdec* xchg , DbsIdec* dbsidec , const ubigint jrefSup , const uint ixIdecVLocale ) : JobIdec(xchg, VecIdecVJob::PNLIDECSCFQCD, jrefSup, ixIdecVLocale) { jref = xchg->addJob(this); feedFPupFan.tag = "FeedFPupFan"; VecVJobIdecQcdacqFan::fillFeed(ixIdecVLocale, feedFPupFan); jobqcdacq = NULL; jobspotfind = NULL; // IP constructor.cust1 --- IBEGIN muteRefresh = false; // IP constructor.cust1 --- IEND jobqcdacq = new JobIdecQcdacq(xchg, dbsidec, jref, ixIdecVLocale, true); jobspotfind = new JobIdecSpotfind(xchg, dbsidec, jref, ixIdecVLocale, true); // IP constructor.cust2 --- INSERT set<uint> moditems; refresh(dbsidec, moditems); xchg->addClstn(VecIdecVCall::CALLIDECSTGCHG, jref, Clstn::VecVJobmask::IMM, 0, Arg(), Clstn::VecVJactype::LOCK); xchg->addClstn(VecIdecVCall::CALLIDECMASTSLVCHG, jref, Clstn::VecVJobmask::IMM, 0, Arg(), Clstn::VecVJactype::LOCK); // IP constructor.cust3 --- INSERT }; PnlIdecScfQcd::~PnlIdecScfQcd() { // IP destructor.spec --- INSERT // IP destructor.cust --- INSERT xchg->removeJobByJref(jref); }; // IP cust --- INSERT DpchEngIdec* PnlIdecScfQcd::getNewDpchEng( set<uint> items ) { DpchEngIdec* dpcheng = NULL; if (items.empty()) { dpcheng = new DpchEngIdecConfirm(true, jref, ""); } else { insert(items, DpchEngData::JREF); dpcheng = new DpchEngData(jref, &contiac, &continf, &feedFPupFan, &statshr, items); }; return dpcheng; }; void PnlIdecScfQcd::refresh( DbsIdec* dbsidec , set<uint>& moditems ) { StatShr oldStatshr(statshr); // IP refresh --- RBEGIN // contiac ContIac oldContiac(contiac); contiac.TxfLam = to_string(xchg->stgjobidecqcdacq.lam0); contiac.TxfDlm = to_string(xchg->stgjobidecqcdacq.dlam); contiac.ChkAon = xchg->stgjobidecqcdacq.on; contiac.SldTof = xchg->stgjobidecqcdacq.tturnoff; contiac.SldTmp = xchg->stgjobidecqcdacq.Tdet; contiac.numFPupFan = feedFPupFan.getNumByIx(xchg->stgjobidecqcdacq.ixVFan); contiac.SldFmd = xchg->stgjobidecqcdacq.Tdet; contiac.SldVdd = xchg->stgjobidecqcdacq.Vdd; // contiac.ChkVd2; contiac.SldVrf = xchg->stgjobidecqcdacq.Vref; contiac.UpdAsl = xchg->stgjobidecspotfind.seqlen; contiac.SldAmo = xchg->stgjobidecspotfind.Pmax; contiac.ChkAad = xchg->stgjobidecspotfind.adapt; if (contiac.diff(&oldContiac).size() != 0) insert(moditems, DpchEngData::CONTIAC); // continf ContInf oldContinf(continf); continf.ButMasterOn = true; if (jobqcdacq) continf.ButMasterOn = (jobqcdacq->jref == jobqcdacq->jrefMast); if (continf.ButMasterOn && jobspotfind) continf.ButMasterOn = (jobspotfind->jref == jobspotfind->jrefMast); if (continf.diff(&oldContinf).size() != 0) insert(moditems, DpchEngData::CONTINF); // statshr statshr.TxfLamActive = evalTxfLamActive(dbsidec); statshr.TxfDlmActive = evalTxfDlmActive(dbsidec); statshr.ChkAonActive = evalChkAonActive(dbsidec); statshr.SldTofActive = evalSldTofActive(dbsidec); statshr.SldTmpActive = evalSldTmpActive(dbsidec); statshr.PupFanActive = evalPupFanActive(dbsidec); statshr.SldFmdActive = evalSldFmdActive(dbsidec); statshr.SldVddActive = evalSldVddActive(dbsidec); statshr.ChkVd2Active = evalChkVd2Active(dbsidec); statshr.SldVrfActive = evalSldVrfActive(dbsidec); statshr.UpdAslActive = evalUpdAslActive(dbsidec); statshr.SldAmoActive = evalSldAmoActive(dbsidec); statshr.ChkAadActive = evalChkAadActive(dbsidec); // IP refresh --- REND if (statshr.diff(&oldStatshr).size() != 0) insert(moditems, DpchEngData::STATSHR); }; void PnlIdecScfQcd::handleRequest( DbsIdec* dbsidec , ReqIdec* req ) { if (req->ixVBasetype == ReqIdec::VecVBasetype::CMD) { reqCmd = req; if (req->cmd == "cmdset") { } else { cout << "\tinvalid command!" << endl; }; if (!req->retain) reqCmd = NULL; } else if (req->ixVBasetype == ReqIdec::VecVBasetype::REGULAR) { if (req->dpchapp->ixIdecVDpch == VecIdecVDpch::DPCHAPPIDECINIT) { handleDpchAppIdecInit(dbsidec, (DpchAppIdecInit*) (req->dpchapp), &(req->dpcheng)); } else if (req->dpchapp->ixIdecVDpch == VecIdecVDpch::DPCHAPPIDECSCFQCDDATA) { DpchAppData* dpchappdata = (DpchAppData*) (req->dpchapp); if (dpchappdata->has(DpchAppData::CONTIAC)) { handleDpchAppDataContiac(dbsidec, &(dpchappdata->contiac), &(req->dpcheng)); }; } else if (req->dpchapp->ixIdecVDpch == VecIdecVDpch::DPCHAPPIDECSCFQCDDO) { DpchAppDo* dpchappdo = (DpchAppDo*) (req->dpchapp); if (dpchappdo->ixVDo != 0) { if (dpchappdo->ixVDo == VecVDo::BUTMASTERCLICK) { handleDpchAppDoButMasterClick(dbsidec, &(req->dpcheng)); }; }; }; }; }; void PnlIdecScfQcd::handleDpchAppIdecInit( DbsIdec* dbsidec , DpchAppIdecInit* dpchappidecinit , DpchEngIdec** dpcheng ) { *dpcheng = getNewDpchEng({DpchEngData::ALL}); }; void PnlIdecScfQcd::handleDpchAppDataContiac( DbsIdec* dbsidec , ContIac* _contiac , DpchEngIdec** dpcheng ) { set<uint> diffitems; set<uint> moditems; diffitems = _contiac->diff(&contiac); // IP handleDpchAppDataContiac --- IBEGIN if (has(diffitems, ContIac::TXFLAM)) contiac.TxfLam = _contiac->TxfLam; if (has(diffitems, ContIac::TXFDLM)) contiac.TxfDlm = _contiac->TxfDlm; if (has(diffitems, ContIac::CHKAON)) contiac.ChkAon = _contiac->ChkAon; if (has(diffitems, ContIac::SLDTOF)) contiac.SldTof = _contiac->SldTof; if (has(diffitems, ContIac::SLDTMP)) contiac.SldTmp = _contiac->SldTmp; if (has(diffitems, ContIac::NUMFPUPFAN)) contiac.numFPupFan = _contiac->numFPupFan; if (has(diffitems, ContIac::SLDFMD)) contiac.SldFmd = _contiac->SldFmd; if (has(diffitems, ContIac::SLDVDD)) contiac.SldVdd = _contiac->SldVdd; if (has(diffitems, ContIac::CHKVD2)) contiac.ChkVd2 = _contiac->ChkVd2; if (has(diffitems, ContIac::SLDVRF)) contiac.SldVrf = _contiac->SldVrf; if (has(diffitems, ContIac::UPDASL)) contiac.UpdAsl = _contiac->UpdAsl; if (has(diffitems, ContIac::SLDAMO)) contiac.SldAmo = _contiac->SldAmo; if (has(diffitems, ContIac::CHKAAD)) contiac.ChkAad = _contiac->ChkAad; // IP handleDpchAppDataContiac --- IEND insert(moditems, DpchEngData::CONTIAC); *dpcheng = getNewDpchEng(moditems); }; void PnlIdecScfQcd::handleDpchAppDoButMasterClick( DbsIdec* dbsidec , DpchEngIdec** dpcheng ) { // IP handleDpchAppDoButMasterClick --- IBEGIN muteRefresh = true; if (jobqcdacq) if (jobqcdacq->jref != jobqcdacq->jrefMast) xchg->claimMaster(dbsidec, jobqcdacq->jref); if (jobspotfind) if (jobspotfind->jref != jobspotfind->jrefMast) xchg->claimMaster(dbsidec, jobspotfind->jref); refreshWithDpchEng(dbsidec, dpcheng); muteRefresh = false; // IP handleDpchAppDoButMasterClick --- IEND }; void PnlIdecScfQcd::handleCall( DbsIdec* dbsidec , Call* call ) { if (call->ixVCall == VecIdecVCall::CALLIDECSTGCHG) { call->abort = handleCallIdecStgChg(dbsidec, call->jref); } else if (call->ixVCall == VecIdecVCall::CALLIDECMASTSLVCHG) { call->abort = handleCallIdecMastslvChg(dbsidec, call->jref); }; }; bool PnlIdecScfQcd::handleCallIdecStgChg( DbsIdec* dbsidec , const ubigint jrefTrig ) { bool retval = false; // IP handleCallIdecStgChg --- INSERT return retval; }; bool PnlIdecScfQcd::handleCallIdecMastslvChg( DbsIdec* dbsidec , const ubigint jrefTrig ) { bool retval = false; // IP handleCallIdecMastslvChg --- IBEGIN if (!muteRefresh) refreshWithDpchEng(dbsidec); // IP handleCallIdecMastslvChg --- IEND return retval; };
9c933a7bc660d289a2940f049bb16346645f6e4a
2a6dfb243bc2d8a6cbb1374605046afcfde1b545
/xtcurve.cc
05fdd5817f893e2981b61162651dc865d9c395c9
[]
no_license
sakah/hs_cosmic
8cd03e9e96dcf2a4c68305d15bfdc6d79a377c9f
7b594379e9ade35f4ffd3a91819c6304c63a3efd
refs/heads/master
2021-01-21T13:21:42.794860
2016-03-16T12:29:04
2016-03-16T12:29:04
52,138,073
0
0
null
null
null
null
UTF-8
C++
false
false
5,932
cc
xtcurve.cc
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "TCanvas.h" #include "TLine.h" #include "TH2F.h" #include "TGraph.h" #include "config.h" #include "xtcurve.h" //__________________________________________________ XTcurve::XTcurve() { } int XTcurve::GetXTcurveType(const char* xt_curve_name) { int xt_curve_type=-1; if (strcmp(xt_curve_name, "XT_CONST")==0) xt_curve_type = XT_CONST; else if (strcmp(xt_curve_name, "XT_PARAM_POL4")==0) xt_curve_type = XT_PARAM_POL4; else { fprintf(stderr, "ERROR: XTcurve unkonwn xt_curve_name '%s'\n", xt_curve_name); } return xt_curve_type; } double XTcurve::GetX(int cid, double T, int left_or_right) { return 0; } double XTcurve::GetT(int cid, double X) { return 0; } double XTcurve::GetSigmaR(int cid, double X) { return 0; } //__________________________________________________ XTcurveConst::XTcurveConst(double drift_velocity, double sigma_r) { drift_velocity_ = drift_velocity; sigma_r_ = sigma_r; } double XTcurveConst::GetX(int cid, double T, int left_or_right) { int sign=1; if (left_or_right==XTcurve::LEFT) { sign = -1; } return sign * T * drift_velocity_; } double XTcurveConst::GetT(int cid, double X) { return X/drift_velocity_; } double XTcurveConst::GetSigmaR(int cid, double X) { return sigma_r_; } double XTcurveConst::GetDriftVelocity(int cid) { return drift_velocity_; } void XTcurveConst::DrawXTcurve(int cid) { double x1 = -8.0; double x2 = 8.0; double y1 = GetT(cid, x1); double y2 = GetT(cid, x2); TLine* l1 = new TLine(0, 0, x1, y1); TLine* l2 = new TLine(0, 0, x2, y2); l1->Draw(); l2->Draw(); } //__________________________________________________ XTcurvePol4::XTcurvePol4(const char* xt_param_path, double sigma_r) { for (int cid=0; cid<MAX_LAYER; cid++) { pol4_left_[cid] = NULL; pol4_left_inverse_x_[cid] = NULL; pol4_right_[cid] = NULL; } printf("XTcurvePol4::XTcurvePol4. xt_param_path %s\n", xt_param_path); if (strcmp(xt_param_path, "NOT_USED")==0) { fprintf(stderr, "xt_param_path is not set. exit.\n"); exit(1); } sigma_r_ = sigma_r; FILE* fp = fopen(xt_param_path, "r"); if (fp==NULL) { fprintf(stderr, "ERROR: cannot open file %s\n", xt_param_path); exit(1); } char line[128]; int cid; int left_or_right; double pol0; double pol1; double pol2; double pol3; double pol4; while(fgets(line, sizeof(line), fp)) { sscanf(line, "%d %d %lf %lf %lf %lf %lf", &cid, &left_or_right, &pol0, &pol1, &pol2, &pol3, &pol4); printf("%d %d %lf %lf %lf %lf %lf\n", cid, left_or_right, pol0, pol1, pol2, pol3, pol4); if (left_or_right == XTcurve::LEFT) { pol4_left_[cid] = new TF1(Form("pol4_left_%d", cid), "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", -8, 0); pol4_left_[cid]->SetParameters(pol0, pol1, pol2, pol3, pol4); pol4_left_[cid]->SetNpx(1000); pol4_left_[cid]->SetLineColor(kBlue); pol4_left_inverse_x_[cid] = new TF1(Form("pol4_left_inverse_x_%d", cid), "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 8); pol4_left_inverse_x_[cid]->SetParameters(pol0, -pol1, pol2, -pol3, pol4); // x -> -x pol4_left_inverse_x_[cid]->SetNpx(1000); pol4_left_inverse_x_[cid]->SetLineColor(kBlue); for (int ns=0; ns<300; ns++) { tx_left_[cid][ns] = pol4_left_[cid]->GetX(ns); } } else { pol4_right_[cid] = new TF1(Form("pol4_right_%d", cid), "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 8); pol4_right_[cid]->SetParameters(pol0, pol1, pol2, pol3, pol4); pol4_right_[cid]->SetNpx(1000); pol4_right_[cid]->SetLineColor(kRed); for (int ns=0; ns<300; ns++) { tx_right_[cid][ns] = pol4_right_[cid]->GetX(ns); } } } fclose(fp); } double XTcurvePol4::GetX(int cid, double T, int left_or_right) { double x = -1e10; int ns = T; if (left_or_right==XTcurve::LEFT) { if (T<0) x = 0; else if (T>=300) x = -tx_left_[cid][299]; else x = -tx_left_[cid][ns]; } else { if (T<0) x = 0; else if (T>=300) x = tx_right_[cid][299]; else x = tx_right_[cid][ns]; } return x; } double XTcurvePol4::GetT(int cid, double X) { double t = -1e10; if (X<0) { if (pol4_left_[cid]) { t = pol4_left_[cid]->Eval(X); } } if (pol4_right_[cid]) { t = pol4_right_[cid]->Eval(X); } return t; } double XTcurvePol4::GetSigmaR(int cid, double X) { return sigma_r_; } void XTcurvePol4::DrawXTcurve(int cid) { if (pol4_left_[cid]) pol4_left_[cid]->Draw("same"); if (pol4_right_[cid]) pol4_right_[cid]->Draw("same"); } void XTcurvePol4::DrawXTcurve2(int cid) { if (pol4_left_[cid]==NULL) return; TCanvas* c1 = new TCanvas("c1-drawxtcurve2"); c1->SetGrid(); TH2F *h2 = new TH2F(Form("drawxtcurve2-%d", cid), "", 100, 0, 10, 100, 0, 500); h2->SetTitle(Form("LayerNumber %d; R [mm]; T [ns]", cid)); h2->SetStats(0); h2->Draw(); if (pol4_left_inverse_x_[cid]) pol4_left_inverse_x_[cid]->Draw("same"); if (pol4_right_[cid]) pol4_right_[cid]->Draw("same"); } void XTcurvePol4::DrawXTcurveDiff(int cid) { if (pol4_left_[cid]==NULL) return; const int num = 1000; double x[num]; double y[num]; double step = 8.0/num; for (int ix=0; ix<num; ix++) { x[ix] = ix*step; y[ix] = pol4_right_[cid]->Eval(x[ix]) - pol4_left_inverse_x_[cid]->Eval(x[ix]); } TGraph* gr = new TGraph(num, x, y); gr->SetLineColor(kRed); gr->SetMarkerColor(kRed); TCanvas* c1 = new TCanvas("c1-drawxtxurvediff"); c1->SetGrid(); TH2F *h2 = new TH2F(Form("drawxtcurvediff-%d", cid), "", 100, 0, 10, 100, -20, 20); h2->SetTitle(Form("LayerNumber %d; R [mm]; T_right - T_left [ns]", cid)); h2->SetStats(0); h2->Draw(); gr->Draw("pl same"); }
d2b855f54130184fb63665240d06e954c65aefd0
96cb8fc3f97c7f1db554fa7184ca1ec4c107a22c
/daemon/actors/PlayerActor.h
323dade9acd0fea0d038120e548ea8725d4d3722
[ "BSD-2-Clause" ]
permissive
Zackmon/SeventhUmbral
f8493a4ae62f6fe10e656d49b999dd3fb63582be
25580111b361d2fdc2c15fd2cd150e4c763ca774
refs/heads/master
2022-01-11T12:43:26.081530
2021-12-23T17:01:28
2021-12-23T17:01:28
439,861,352
0
0
NOASSERTION
2021-12-19T12:46:13
2021-12-19T12:46:12
null
UTF-8
C++
false
false
1,795
h
PlayerActor.h
#pragma once #include "Actor.h" #include "mysql/Client.h" #include "../Character.h" struct INVENTORY_ITEM { INVENTORY_ITEM(uint32 itemId, uint32 itemDefId) : itemId(itemId), itemDefId(itemDefId) { } uint32 itemId = 0; uint32 itemDefId = 0; }; typedef std::vector<INVENTORY_ITEM> Inventory; class CPlayerActor : public CActor { public: CPlayerActor(uint32); virtual ~CPlayerActor(); void Update(float) override; const CCharacter& GetCharacter() const; const Inventory& GetInventory() const; void SetSelection(uint32); void ProcessCommandRequest(uint32, const PacketData&); void ProcessCommandForced(uint32); void ProcessCommandDefault(uint32); private: typedef std::map<uint32, uint8> WeaponJobMap; typedef std::map<uint8, uint32> JobSkillMap; typedef std::map<uint32, uint32> SkillAnimationMap; enum { EMPTY_LOCKON_ID = 0xE0000000, }; void EquipItem(const PacketData&); void DoEmote(const PacketData&); void TrashItem(const PacketData&); void SwitchToActiveMode(); void SwitchToPassiveMode(); void ExecuteBattleSkill(uint32); void ProcessAutoAttack(float); void ProcessCast(float); void DealDamageToTarget(uint32); Framework::MySql::CClient m_dbConnection; bool m_isActiveMode = false; float m_autoAttackTimer = 0; uint32 m_castCommandId = 0; float m_castTimer = 0; uint32 m_lockOnId = EMPTY_LOCKON_ID; CCharacter m_character; Inventory m_inventory; uint32 m_characterId = 0; static const WeaponJobMap m_weaponJobs; static const JobSkillMap m_jobSkills; static const SkillAnimationMap m_skillAnimations; };
df9b262c62e8ca0661f8bd5ec19d76e7765de832
2692e11c292fea05510830af9712b91a03428ac9
/toonz/sources/toonzqt/gutil.cpp
6e63e35ed16397e89a3fa17060ed45436b9cc8ac
[ "BSD-3-Clause" ]
permissive
manongjohn/OTX
92b72589fbcf26867f18997862e8cdb8ef5a1af6
a80fe827b7a6316480974d712f9175d970729f04
refs/heads/master
2021-06-15T09:33:57.878785
2021-05-13T16:01:59
2021-05-13T16:01:59
188,602,761
20
9
NOASSERTION
2019-08-05T01:06:23
2019-05-25T19:02:45
C++
UTF-8
C++
false
false
25,133
cpp
gutil.cpp
#include "toonzqt/gutil.h" #include "toonz/preferences.h" // TnzQt includes #include "toonzqt/dvdialog.h" // TnzCore includes #include "traster.h" #include "tpixelutils.h" #include "tfilepath.h" #include "tfiletype.h" #include "tstroke.h" #include "tcurves.h" #include "trop.h" #include "tmsgcore.h" // Qt includes #include <QPixmap> #include <QImage> #include <QPainter> #include <QPainterPath> #include <QIcon> #include <QString> #include <QApplication> #include <QMouseEvent> #include <QTabletEvent> #include <QKeyEvent> #include <QUrl> #include <QFileInfo> #include <QDesktopWidget> #include <QSvgRenderer> using namespace DVGui; //----------------------------------------------------------------------------- QString fileSizeString(qint64 size, int precision) { if (size < 1024) return QString::number(size) + " Bytes"; else if (size < 1024 * 1024) return QString::number(size / (1024.0), 'f', precision) + " KB"; else if (size < 1024 * 1024 * 1024) return QString::number(size / (1024 * 1024.0), 'f', precision) + " MB"; else return QString::number(size / (1024 * 1024 * 1024.0), 'f', precision) + " GB"; } //---------------------------------------------------------------- QImage rasterToQImage(const TRasterP &ras, bool premultiplied, bool mirrored) { if (TRaster32P ras32 = ras) { QImage image(ras->getRawData(), ras->getLx(), ras->getLy(), premultiplied ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32); if (mirrored) return image.mirrored(); return image; } else if (TRasterGR8P ras8 = ras) { QImage image(ras->getRawData(), ras->getLx(), ras->getLy(), ras->getWrap(), QImage::Format_Indexed8); static QVector<QRgb> colorTable; if (colorTable.size() == 0) { int i; for (i = 0; i < 256; i++) colorTable.append(QColor(i, i, i).rgb()); } image.setColorTable(colorTable); if (mirrored) return image.mirrored(); return image; } return QImage(); } //----------------------------------------------------------------------------- QPixmap rasterToQPixmap(const TRaster32P &ras, bool premultiplied, bool setDevPixRatio) { QPixmap pixmap = QPixmap::fromImage(rasterToQImage(ras, premultiplied)); if (setDevPixRatio) { pixmap.setDevicePixelRatio(getDevPixRatio()); } return pixmap; } //----------------------------------------------------------------------------- TRaster32P rasterFromQImage( QImage image, bool premultiply, bool mirror) // no need of const& - Qt uses implicit sharing... { QImage copyImage = mirror ? image.mirrored() : image; TRaster32P ras(image.width(), image.height(), image.width(), (TPixelRGBM32 *)copyImage.bits(), false); if (premultiply) TRop::premultiply(ras); return ras->clone(); } //----------------------------------------------------------------------------- TRaster32P rasterFromQPixmap( QPixmap pixmap, bool premultiply, bool mirror) // no need of const& - Qt uses implicit sharing... { QImage image = pixmap.toImage(); return rasterFromQImage(image, premultiply, mirror); } //----------------------------------------------------------------------------- void drawPolygon(QPainter &p, const std::vector<QPointF> &points, bool fill, const QColor colorFill, const QColor colorLine) { if (points.size() == 0) return; p.setPen(colorLine); QPolygonF E0Polygon; int i = 0; for (i = 0; i < (int)points.size(); i++) E0Polygon << QPointF(points[i]); E0Polygon << QPointF(points[0]); QPainterPath E0Path; E0Path.addPolygon(E0Polygon); if (fill) p.fillPath(E0Path, QBrush(colorFill)); p.drawPath(E0Path); } //----------------------------------------------------------------------------- void drawArrow(QPainter &p, const QPointF a, const QPointF b, const QPointF c, bool fill, const QColor colorFill, const QColor colorLine) { std::vector<QPointF> pts; pts.push_back(a); pts.push_back(b); pts.push_back(c); drawPolygon(p, pts, fill, colorFill, colorLine); } //----------------------------------------------------------------------------- QPixmap scalePixmapKeepingAspectRatio(QPixmap pixmap, QSize size, QColor color) { if (pixmap.isNull()) return pixmap; if (pixmap.devicePixelRatio() > 1.0) size *= pixmap.devicePixelRatio(); if (pixmap.size() == size) return pixmap; QPixmap scaledPixmap = pixmap.scaled(size.width(), size.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); QPixmap newPixmap(size); newPixmap.fill(color); QPainter painter(&newPixmap); painter.drawPixmap(double(size.width() - scaledPixmap.width()) * 0.5, double(size.height() - scaledPixmap.height()) * 0.5, scaledPixmap); newPixmap.setDevicePixelRatio(pixmap.devicePixelRatio()); return newPixmap; } //----------------------------------------------------------------------------- QPixmap svgToPixmap(const QString &svgFilePath, const QSize &size, Qt::AspectRatioMode aspectRatioMode, QColor bgColor) { static int devPixRatio = getDevPixRatio(); QSvgRenderer svgRenderer(svgFilePath); QSize pixmapSize; QRectF renderRect; if (size.isEmpty()) { pixmapSize = svgRenderer.defaultSize() * devPixRatio; renderRect = QRectF(QPointF(), QSizeF(pixmapSize)); } else { pixmapSize = size * devPixRatio; if (aspectRatioMode == Qt::KeepAspectRatio || aspectRatioMode == Qt::KeepAspectRatioByExpanding) { QSize imgSize = svgRenderer.defaultSize(); QPointF scaleFactor((float)pixmapSize.width() / (float)imgSize.width(), (float)pixmapSize.height() / (float)imgSize.height()); float factor = (aspectRatioMode == Qt::KeepAspectRatio) ? std::min(scaleFactor.x(), scaleFactor.y()) : std::max(scaleFactor.x(), scaleFactor.y()); QSizeF renderSize(factor * (float)imgSize.width(), factor * (float)imgSize.height()); QPointF topLeft( ((float)pixmapSize.width() - renderSize.width()) * 0.5f, ((float)pixmapSize.height() - renderSize.height()) * 0.5f); renderRect = QRectF(topLeft, renderSize); } else { // Qt::IgnoreAspectRatio: renderRect = QRectF(QPointF(), QSizeF(pixmapSize)); } } QPixmap pixmap(pixmapSize); QPainter painter; pixmap.fill(bgColor); painter.begin(&pixmap); svgRenderer.render(&painter, renderRect); painter.end(); pixmap.setDevicePixelRatio(devPixRatio); return pixmap; } //----------------------------------------------------------------------------- int getDevPixRatio() { static int devPixRatio = QApplication::desktop()->devicePixelRatio(); return devPixRatio; } //----------------------------------------------------------------------------- QString getIconThemePath(const QString &fileSVGPath) { // Use as follows: // QPixmap pixmapIcon = getIconThemePath("path/to/file.svg"); // Is equal to: :icons/*theme*/path/to/file.svg // Set themeable directory static QString theme = Preferences::instance()->getIconTheme() ? ":icons/dark/" : ":icons/light/"; // If no file in light icon theme directory, fallback to dark directory if (!QFile::exists(QString(theme + fileSVGPath))) theme = ":icons/dark/"; return theme + fileSVGPath; } //----------------------------------------------------------------------------- QPixmap compositePixmap(QPixmap pixmap, const qreal &opacity, const QSize &size, const int leftAdj, const int topAdj, QColor bgColor) { static int devPixRatio = getDevPixRatio(); // Sets size of destination pixmap for source to be drawn onto, if size is // empty use source pixmap size, else use custom size. QPixmap destination(size.isEmpty() ? pixmap.size() : size * devPixRatio); destination.setDevicePixelRatio(devPixRatio); destination.fill(bgColor); if (!pixmap.isNull()) { QPainter p(&destination); pixmap = pixmap.scaled(pixmap.size(), Qt::KeepAspectRatio); pixmap.setDevicePixelRatio(devPixRatio); p.setBackgroundMode(Qt::TransparentMode); p.setBackground(QBrush(Qt::transparent)); p.eraseRect(pixmap.rect()); p.setOpacity(opacity); p.drawPixmap(leftAdj, topAdj, pixmap); } return destination; } //----------------------------------------------------------------------------- QPixmap recolorPixmap(QPixmap pixmap, QColor color) { // Change black pixels to any chosen color QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); for (int y = 0; y < img.height(); y++) { QRgb *pixel = reinterpret_cast<QRgb *>(img.scanLine(y)); QRgb *end = pixel + img.width(); for (; pixel != end; pixel++) { // Only recolor zero value (black) pixels if (QColor::fromRgba(*pixel).value() == 0) *pixel = QColor(color.red(), color.green(), color.blue(), qAlpha(*pixel)) .rgba(); } } pixmap = QPixmap::fromImage(img); return pixmap; } //----------------------------------------------------------------------------- QIcon createQIcon(const char *iconSVGName, bool useFullOpacity, bool isForMenuItem) { static int devPixRatio = getDevPixRatio(); QIcon themeIcon = QIcon::fromTheme(iconSVGName); // Get icon dimensions QSize iconSize(0, 0); for (QList<QSize> sizes = themeIcon.availableSizes(); !sizes.isEmpty(); sizes.removeFirst()) if (sizes.first().width() > iconSize.width()) iconSize = sizes.first() * devPixRatio; // Control lightness of the icons const qreal activeOpacity = 1; const qreal baseOpacity = useFullOpacity ? 1 : 0.8; const qreal disabledOpacity = 0.15; // Psuedo state name strings QString overStr = QString(iconSVGName) + "_over"; QString onStr = QString(iconSVGName) + "_on"; //---------- // Base pixmap QPixmap themeIconPixmap(recolorPixmap(themeIcon.pixmap(iconSize))); if (!themeIconPixmap.isNull()) { // suppress message themeIconPixmap.setDevicePixelRatio(devPixRatio); themeIconPixmap = themeIconPixmap.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); } // Over pixmap QPixmap overPixmap(recolorPixmap(QIcon::fromTheme(overStr).pixmap(iconSize))); if (!overPixmap.isNull()) { // suppress message overPixmap.setDevicePixelRatio(devPixRatio); overPixmap = overPixmap.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); } // On pixmap QPixmap onPixmap(recolorPixmap(QIcon::fromTheme(onStr).pixmap(iconSize))); if (!onPixmap.isNull()) { // suppress message onPixmap.setDevicePixelRatio(devPixRatio); onPixmap = onPixmap.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); } //---------- QIcon icon; #ifdef _WIN32 bool showIconInMenu = Preferences::instance()->getBoolValue(showIconsInMenu); // set transparent icon if (isForMenuItem && themeIconPixmap.size() == QSize(16 * devPixRatio, 16 * devPixRatio) && !showIconInMenu) { static QPixmap emptyPm(16 * devPixRatio, 16 * devPixRatio); emptyPm.fill(Qt::transparent); icon.addPixmap(emptyPm, QIcon::Normal, QIcon::Off); icon.addPixmap(emptyPm, QIcon::Normal, QIcon::On); icon.addPixmap(emptyPm, QIcon::Disabled, QIcon::Off); icon.addPixmap(emptyPm, QIcon::Disabled, QIcon::On); icon.addPixmap(emptyPm, QIcon::Active); } else #endif { // Base icon icon.addPixmap(compositePixmap(themeIconPixmap, baseOpacity), QIcon::Normal, QIcon::Off); icon.addPixmap(compositePixmap(themeIconPixmap, disabledOpacity), QIcon::Disabled, QIcon::Off); // Over icon icon.addPixmap(!overPixmap.isNull() ? compositePixmap(overPixmap, activeOpacity) : compositePixmap(themeIconPixmap, activeOpacity), QIcon::Active); // On icon if (!onPixmap.isNull()) { icon.addPixmap(compositePixmap(onPixmap, activeOpacity), QIcon::Normal, QIcon::On); icon.addPixmap(compositePixmap(onPixmap, disabledOpacity), QIcon::Disabled, QIcon::On); } else { icon.addPixmap(compositePixmap(themeIconPixmap, activeOpacity), QIcon::Normal, QIcon::On); icon.addPixmap(compositePixmap(themeIconPixmap, disabledOpacity), QIcon::Disabled, QIcon::On); } } //---------- // For icons intended for menus that are 16x16 in dimensions, to repurpose // them for use in toolbars that are set for 20x20 we want to draw them onto a // 20x20 pixmap so they don't get resized in the GUI, they will be loaded into // the icon along with the original 16x16 pixmap. if (themeIconPixmap.size() == QSize(16 * devPixRatio, 16 * devPixRatio)) { const QSize drawOnSize(20, 20); const int x = (drawOnSize.width() - 16) / 2; // left adjust const int y = (drawOnSize.height() - 16) / 2; // top adjust // Base icon icon.addPixmap( compositePixmap(themeIconPixmap, baseOpacity, drawOnSize, x, y), QIcon::Normal, QIcon::Off); icon.addPixmap( compositePixmap(themeIconPixmap, disabledOpacity, drawOnSize, x, y), QIcon::Disabled, QIcon::Off); // Over icon icon.addPixmap( !overPixmap.isNull() ? compositePixmap(overPixmap, activeOpacity, drawOnSize, x, y) : compositePixmap(themeIconPixmap, activeOpacity, drawOnSize, x, y), QIcon::Active); // On icon if (!onPixmap.isNull()) { icon.addPixmap(compositePixmap(onPixmap, activeOpacity, drawOnSize, x, y), QIcon::Normal, QIcon::On); icon.addPixmap( compositePixmap(onPixmap, disabledOpacity, drawOnSize, x, y), QIcon::Disabled, QIcon::On); } else { icon.addPixmap( compositePixmap(themeIconPixmap, activeOpacity, drawOnSize, x, y), QIcon::Normal, QIcon::On); icon.addPixmap( compositePixmap(themeIconPixmap, disabledOpacity, drawOnSize, x, y), QIcon::Disabled, QIcon::On); } } return icon; } //----------------------------------------------------------------------------- QIcon createQIconPNG(const char *iconPNGName) { QString normal = QString(":Resources/") + iconPNGName + ".png"; QString click = QString(":Resources/") + iconPNGName + "_click.png"; QString over = QString(":Resources/") + iconPNGName + "_over.png"; QIcon icon; icon.addFile(normal, QSize(), QIcon::Normal, QIcon::Off); icon.addFile(click, QSize(), QIcon::Normal, QIcon::On); icon.addFile(over, QSize(), QIcon::Active); return icon; } //----------------------------------------------------------------------------- QIcon createQIconOnOffPNG(const char *iconPNGName, bool withOver) { QString on = QString(":Resources/") + iconPNGName + "_on.png"; QString off = QString(":Resources/") + iconPNGName + "_off.png"; QString over = QString(":Resources/") + iconPNGName + "_over.png"; QIcon icon; icon.addFile(off, QSize(), QIcon::Normal, QIcon::Off); icon.addFile(on, QSize(), QIcon::Normal, QIcon::On); if (withOver) icon.addFile(over, QSize(), QIcon::Active); else icon.addFile(on, QSize(), QIcon::Active); return icon; } //----------------------------------------------------------------------------- QIcon createTemporaryIconFromName(const char *commandName) { const int visibleIconSize = 20; const int menubarIconSize = 16; const qreal activeOpacity = 1; const qreal baseOpacity = 0.8; const qreal disabledOpacity = 0.15; QString name(commandName); QList<QChar> iconChar; for (int i = 0; i < name.length(); i++) { QChar c = name.at(i); if (c.isUpper() && iconChar.size() < 2) iconChar.append(c); else if (c.isDigit()) { if (iconChar.isEmpty()) iconChar.append(c); else if (iconChar.size() <= 2) { if (iconChar.size() == 2) iconChar.removeLast(); iconChar.append(c); break; } } } if (iconChar.isEmpty()) iconChar.append(name.at(0)); QString iconStr; for (auto c : iconChar) iconStr.append(c); QIcon icon; // prepare for both normal and high dpi for (int devPixelRatio = 1; devPixelRatio <= 2; devPixelRatio++) { QPixmap transparentPm(menubarIconSize * devPixelRatio, menubarIconSize * devPixelRatio); transparentPm.fill(Qt::transparent); int pxSize = visibleIconSize * devPixelRatio; QPixmap pixmap(pxSize, pxSize); QPainter painter; pixmap.fill(Qt::transparent); painter.begin(&pixmap); painter.setPen(Preferences::instance()->getIconTheme() ? Qt::black : Qt::white); QRect rect(0, -2, pxSize, pxSize); if (iconStr.size() == 2) { painter.scale(0.6, 1.0); rect.setRight(pxSize / 0.6); } QFont font = painter.font(); font.setPixelSize(pxSize); painter.setFont(font); painter.drawText(rect, Qt::AlignCenter, iconStr); painter.end(); // For menu only icon.addPixmap(transparentPm, QIcon::Normal, QIcon::Off); icon.addPixmap(transparentPm, QIcon::Active); icon.addPixmap(transparentPm, QIcon::Normal, QIcon::On); icon.addPixmap(transparentPm, QIcon::Disabled, QIcon::Off); icon.addPixmap(transparentPm, QIcon::Disabled, QIcon::On); // For toolbars icon.addPixmap(compositePixmap(pixmap, baseOpacity), QIcon::Normal, QIcon::Off); icon.addPixmap(compositePixmap(pixmap, disabledOpacity), QIcon::Disabled, QIcon::Off); icon.addPixmap(compositePixmap(pixmap, activeOpacity), QIcon::Active); icon.addPixmap(compositePixmap(pixmap, activeOpacity), QIcon::Normal, QIcon::On); icon.addPixmap(compositePixmap(pixmap, disabledOpacity), QIcon::Disabled, QIcon::On); } return icon; } //----------------------------------------------------------------------------- QString toQString(const TFilePath &path) { return QString::fromStdWString(path.getWideString()); } //----------------------------------------------------------------------------- bool isSpaceString(const QString &str) { int i; QString space(" "); for (i = 0; i < str.size(); i++) if (str.at(i) != space.at(0)) return false; return true; } //----------------------------------------------------------------------------- bool isValidFileName(const QString &fileName) { if (fileName.isEmpty() || fileName.contains(":") || fileName.contains("\\") || fileName.contains("/") || fileName.contains(">") || fileName.contains("<") || fileName.contains("*") || fileName.contains("|") || fileName.contains("\"") || fileName.contains("?") || fileName.trimmed().isEmpty()) return false; return true; } //----------------------------------------------------------------------------- bool isValidFileName_message(const QString &fileName) { return isValidFileName(fileName) ? true : (DVGui::error( QObject::tr("The file name cannot be empty or contain any " "of the following " "characters: (new line) \\ / : * ? \" |")), false); } //----------------------------------------------------------------------------- bool isReservedFileName(const QString &fileName) { #ifdef _WIN32 std::vector<QString> invalidNames{ "AUX", "CON", "NUL", "PRN", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"}; if (std::find(invalidNames.begin(), invalidNames.end(), fileName) != invalidNames.end()) return true; #endif return false; } //----------------------------------------------------------------------------- bool isReservedFileName_message(const QString &fileName) { return isReservedFileName(fileName) ? (DVGui::error(QObject::tr( "That is a reserved file name and cannot be used.")), true) : false; } //----------------------------------------------------------------------------- QString elideText(const QString &srcText, const QFont &font, int width) { QFontMetrics metrix(font); int srcWidth = metrix.width(srcText); if (srcWidth < width) return srcText; int tilde = metrix.width("~"); int block = (width - tilde) / 2; QString text(""); int i; for (i = 0; i < srcText.size(); i++) { text += srcText.at(i); if (metrix.width(text) > block) break; } text[i] = '~'; QString endText(""); for (i = srcText.size() - 1; i >= 0; i--) { endText.push_front(srcText.at(i)); if (metrix.width(endText) > block) break; } endText.remove(0, 1); text += endText; return text; } //----------------------------------------------------------------------------- QString elideText(const QString &srcText, const QFontMetrics &fm, int width, const QString &elideSymbol) { QString text(srcText); for (int i = text.size(); i > 1 && fm.width(text) > width;) text = srcText.left(--i).append(elideSymbol); return text; } //----------------------------------------------------------------------------- QUrl pathToUrl(const TFilePath &path) { return QUrl::fromLocalFile(QString::fromStdWString(path.getWideString())); } //----------------------------------------------------------------------------- bool isResource(const QString &path) { const TFilePath fp(path.toStdWString()); TFileType::Type type = TFileType::getInfo(fp); return (TFileType::isViewable(type) || type & TFileType::MESH_IMAGE || type == TFileType::AUDIO_LEVEL || type == TFileType::TABSCENE || type == TFileType::TOONZSCENE || fp.getType() == "tpl"); } //----------------------------------------------------------------------------- bool isResource(const QUrl &url) { return isResource(url.toLocalFile()); } //----------------------------------------------------------------------------- bool isResourceOrFolder(const QUrl &url) { struct locals { static inline bool isDir(const QString &path) { return QFileInfo(path).isDir(); } }; // locals const QString &path = url.toLocalFile(); return (isResource(path) || locals::isDir(path)); } //----------------------------------------------------------------------------- bool acceptResourceDrop(const QList<QUrl> &urls) { int count = 0; for (const QUrl &url : urls) { if (isResource(url)) ++count; else return false; } return (count > 0); } //----------------------------------------------------------------------------- bool acceptResourceOrFolderDrop(const QList<QUrl> &urls) { int count = 0; for (const QUrl &url : urls) { if (isResourceOrFolder(url)) ++count; else return false; } return (count > 0); } //----------------------------------------------------------------------------- QPainterPath strokeToPainterPath(TStroke *stroke) { QPainterPath path; int i, chunkSize = stroke->getChunkCount(); for (i = 0; i < chunkSize; i++) { const TThickQuadratic *q = stroke->getChunk(i); if (i == 0) path.moveTo(toQPointF(q->getThickP0())); path.quadTo(toQPointF(q->getThickP1()), toQPointF(q->getThickP2())); } return path; } //============================================================================= // TabBarContainter //----------------------------------------------------------------------------- TabBarContainter::TabBarContainter(QWidget *parent) : QFrame(parent) { setObjectName("TabBarContainer"); setFrameStyle(QFrame::StyledPanel); } //----------------------------------------------------------------------------- void TabBarContainter::paintEvent(QPaintEvent *event) { QPainter p(this); p.setPen(getBottomAboveLineColor()); p.drawLine(0, height() - 2, width(), height() - 2); p.setPen(getBottomBelowLineColor()); p.drawLine(0, height() - 1, width(), height() - 1); } //============================================================================= // ToolBarContainer //----------------------------------------------------------------------------- ToolBarContainer::ToolBarContainer(QWidget *parent) : QFrame(parent) { setObjectName("ToolBarContainer"); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); } //----------------------------------------------------------------------------- void ToolBarContainer::paintEvent(QPaintEvent *event) { QPainter p(this); } //============================================================================= QString operator+(const QString &a, const TFilePath &fp) { return a + QString::fromStdWString(fp.getWideString()); }
a1f4c63552e954dbe7506832f721bc07f0fcc51a
d4b46e5856a720f2a91f2765956432ee399977fb
/Candy/src/Candy/Engine/PtnVisual.cpp
5d954aa452104da3cd7bd755e23fad3f111536b0
[]
no_license
Danvil/Darwin
6c647f90dd714c6da756fdb386c74fc66f91b542
32b23e8fed350138de4f3b0312792265cbac3176
refs/heads/master
2021-01-19T18:14:02.672004
2014-07-24T21:36:56
2014-07-24T21:36:56
4,684,809
9
1
null
null
null
null
UTF-8
C++
false
false
416
cpp
PtnVisual.cpp
#include "PtnVisual.h" #include "Resources.h" using namespace std; namespace Candy { PtnVisual::PtnVisual(Ptr(PTN::Mesh) mesh, const std::string& frag, const std::string& vert, const std::string& tex_name) { mesh_ = mesh; shader_ = Candy::CreatePtnShader(frag, vert, tex_name); } PtnVisual::~PtnVisual() { } void PtnVisual::Render() { shader_->Apply(); mesh_->Render(); } }
ba34f30a039abe342731502260a4adbf99986fac
ebd585fdafb22d31fcd6d04b209f81e88d1a2083
/modem_proc/modem/datamodem/interface/dss/src/DSS_NetworkStateHandler.h
7a1a4770732ff1802cb4c67672f83f4c99b83dcd
[ "Apache-2.0" ]
permissive
xusl/android-wilhelm
fd28144253cd9d7de0646f96ff27a1f4a9bec6e3
13c59cb5b0913252fe0b5c672d8dc2bf938bb720
refs/heads/master
2018-04-03T21:46:10.195170
2017-04-20T10:17:49
2017-04-20T10:17:49
88,847,837
11
10
null
null
null
null
UTF-8
C++
false
false
1,314
h
DSS_NetworkStateHandler.h
#ifndef __DSS_NETWORKSTATEHANDLER_H__ #define __DSS_NETWORKSTATEHANDLER_H__ /*==================================================== FILE: DSS_NetworkStateHandler.h SERVICES: Handle network down event. ===================================================== Copyright (c) 2008 - 2012 QUALCOMM Technologies Incorporated. All Rights Reserved. Qualcomm Confidential and Proprietary =====================================================*/ /*=========================================================================== EDIT HISTORY FOR MODULE Please notice that the changes are listed in reverse chronological order. $Header: //source/qcom/qct/modem/datamodem/interface/dss/main/latest/src/DSS_NetworkStateHandler.h#6 $ $DateTime: 2012/06/24 07:43:13 $$Author: ylefel $ when who what, where, why ---------- --- ------------------------------------------------------------ 2010-04-13 en History added. ===========================================================================*/ #include "DSS_EventHandlerNetApp.h" class DSSNetworkStateHandler : public DSSEventHandlerNetApp { protected: virtual void EventOccurred(); virtual AEEResult RegisterIDL(); public: static DSSNetworkStateHandler* CreateInstance(); DSSNetworkStateHandler(); }; #endif // __DSS_NETWORKSTATEHANDLER_H__
e1a1d917f91e0be0452361441ef3bfed27fb4e5e
31936db8f4e4d38075e2b6690b124f623261d623
/day3A/K.cpp
dfca72684cecbf10a2ccc296c0e74c406082b340
[]
no_license
vladvlad00/MIPT-2020
dc8b51c0bed835ad8fde82195ce54c775ac2f0ae
a11c58c3167fad9d44d612ec9f74eaa0d6d34289
refs/heads/master
2023-01-30T12:46:57.969288
2020-12-11T18:33:24
2020-12-11T18:33:24
320,651,607
0
0
null
null
null
null
UTF-8
C++
false
false
4,199
cpp
K.cpp
#define _CRT_SECURE_NO_WARNINGS #include <vector> #include <utility> #include <iostream> #include <queue> #include <cstring> #include <algorithm> #include <unordered_map> #include <cmath> #define NMAX 5005 #define SOURCE -1 #define NOT_VISITED -2 #define NOT_FOUND -3 using namespace std; struct Muchie { int x, y, id, color; }; struct GroundSetElement { Muchie edge; bool in_independent_set; int independent_set_pos; int bfs_parent; }; int n, m; bool color_used[NMAX]; bool edge_exists[NMAX]; bool uz[NMAX]; int cmp[NMAX]; bool can_replace[NMAX][NMAX]; int nr_cmp; vector<GroundSetElement> ground_set; vector<int> independent_set; vector<pair<int,int>> L[NMAX]; void reset_color() { for (int i = 1; i <= m; i++) color_used[i] = false; for (int i : independent_set) color_used[ground_set[i].edge.color] = true; } bool color_ok(int inserted) { int color = ground_set[inserted].edge.color; return !color_used[color]; } bool color_ok(int inserted, int removed) { int color_insert = ground_set[inserted].edge.color; int color_remove = ground_set[removed].edge.color; if (!color_used[color_insert]) return true; return color_insert == color_remove; } void DFS(int nod) { cmp[nod] = nr_cmp; for (auto[vec,id] : L[nod]) { if (!edge_exists[id]) continue; if (!cmp[vec]) DFS(vec); } } void reset_cycle() { for (int i = 1; i <= m; i++) edge_exists[i] = false; for (int i : independent_set) { auto muchie = ground_set[i].edge; edge_exists[muchie.id] = true; } for (int i : independent_set) { auto muchie = ground_set[i].edge; edge_exists[muchie.id] = false; nr_cmp = 0; for (int j = 1; j <= n; j++) cmp[j] = 0; for (int j = 1; j <= n; j++) if (!cmp[j]) { nr_cmp++; DFS(j); } for (int i=0;i<m;i++) { auto muchie2 = ground_set[i].edge; if (cmp[muchie2.x] != cmp[muchie2.y]) can_replace[muchie.id][muchie2.id] = true; else can_replace[muchie.id][muchie2.id] = false; } edge_exists[muchie.id] = true; } for (int j = 1; j <= n; j++) cmp[j] = 0; for (int j = 1; j <= n; j++) if (!cmp[j]) { nr_cmp++; DFS(j); } } bool cycle_ok(int inserted) { auto muchie = ground_set[inserted].edge; return cmp[muchie.x] != cmp[muchie.y]; } bool cycle_ok(int inserted, int removed) { auto muchie_insert = ground_set[inserted].edge; auto muchie_remove = ground_set[removed].edge; return can_replace[muchie_remove.id][muchie_insert.id]; } bool augment() { reset_color(); reset_cycle(); for (auto& elem : ground_set) elem.bfs_parent = NOT_VISITED; int end = NOT_FOUND; queue<int> Q; for (int i=0;i<ground_set.size();i++) if (color_ok(i)) { ground_set[i].bfs_parent = SOURCE; Q.push(i); } while (!Q.empty()) { int current = Q.front(); Q.pop(); if (ground_set[current].in_independent_set) { for (int next=0;next<ground_set.size();next++) { if (ground_set[next].bfs_parent != NOT_VISITED) continue; if (!color_ok(next, current)) continue;; ground_set[next].bfs_parent = current; Q.push(next); } } else { if (cycle_ok(current)) { end = current; break; } for (auto next : independent_set) { if (ground_set[next].bfs_parent != NOT_VISITED) continue; if (!cycle_ok(current, next)) continue; ground_set[next].bfs_parent = current; Q.push(next); } } } if (end == NOT_FOUND) return false; do { ground_set[end].in_independent_set = !ground_set[end].in_independent_set; end = ground_set[end].bfs_parent; } while (end != SOURCE); independent_set.clear(); for (int i=0;i<ground_set.size();i++) if (ground_set[i].in_independent_set) { ground_set[i].independent_set_pos = independent_set.size(); independent_set.push_back(i); } return true; } int main() { cin >> n >> m; for (int i=1;i<=m;i++) { int x, y, color; cin >> x >> y >> color; GroundSetElement elem; elem.edge = { x,y,i,color }; elem.in_independent_set = false; ground_set.push_back(elem); L[x].emplace_back(y, i); L[y].emplace_back(x, i); } while (augment()); cout << independent_set.size() << '\n'; for (int i : independent_set) cout << i+1 << ' '; cout << '\n'; return 0; }
1275774833983ea66905f93a990b7e577a8992e1
c8cb66c031a47bb06e8c7b0bc9bbef1cad8da356
/src/OptimisationTrajectoire/OptimisationTrajectoire/QLearning.h
e4764ca1aa859b027d029d8d2dd7e49cb4064ecf
[]
no_license
ChevalierP/PIP
2a3b190979ffbc28371beef22a429f2a9791f460
6dda4e8088879d328dfe23bf6f30b54b749658b7
refs/heads/master
2020-05-31T18:15:53.458080
2015-06-28T13:17:38
2015-06-28T13:17:38
29,702,814
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,990
h
QLearning.h
#ifndef _PIP_QLEARNING_H_ #define _PIP_QLEARNING_H_ #include <map> #include "State.h" #include "Vehicule.h" #include "Track.h" #include "Config.h" // Politique de récompense class SpeedAxisReward { public: SpeedAxisReward(Config& config); float GetReward(const Observation& obs, const Command& command, const Command& last, const Vehicule& veh, const Track& track) const; protected: Config& mConfig; }; // Matrice de qualité class Quality { public: using CommandQuality = std::map<Command, float>; using CommandMap = std::map<Command, CommandQuality>; using SensorQuality = std::map<Observation, CommandMap>; // Associations (état, action) pour une observation donnée CommandMap& GetCommandMap(const Observation& obs); // Qualité des actions à partir d'un état donné CommandQuality& GetCommandQuality(const Observation& obs, const Command& current); // Meilleure récompense à partir d'un état donné float GetBestReward(const Observation& obs, const Command& current, float def = 0); // Meilleure commande à partir d'un état donné const Command& GetBestCommand(const Observation& obs, const Command& current, const Command& def = Command()); void UpdateCommandReward(const Observation& obs, const Command& from, const Command& to, float q); // Qualité d'un couple (état, action) float Get(const Observation& obs, const Command& from, const Command& to) { return mQuality[obs][from][to]; } private: SensorQuality mQuality; }; enum class StateChoicePolicy { Exploration, Exploitation }; template<class T> class QLearning { public: QLearning(Config& config, StateSpace& ss, Quality& quality, Vehicule& veh, const Track& track, const T& rewardPolicy); bool Sim(const Vehicule::StateType& position, const Command& command, StateChoicePolicy scp); private: Config& mConfig; StateSpace& mStateSpace; Quality& mQuality; Vehicule& mVehicule; const Track& mTrack; const T& mRewardPolicy; }; #include "QLearning.inl" #endif // !_PIP_QLEARNING_H_
e78cdfe72aec1a5ffb82da4a0ad52477dc871e55
a9e96f0081d2ee2c5934ff93a35dfa4727b35219
/src/engine/hitablelist.h
47f03325ff119e192d4ab5add50161bd1257af6c
[]
no_license
jsberbel/SawassRayTracer
713d1b6bf2960c354810a2d7b4eacec49a6ef7ac
b4132394bcb98f6be6c02c73a865fd6f1fcfa28c
refs/heads/master
2021-07-02T21:08:10.862865
2018-12-07T01:37:26
2018-12-07T01:37:26
133,870,192
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
3,547
h
hitablelist.h
// ====================================================================== // File: world.h // Revision: 1.0 // Creation: 05/22/2018 - jsberbel // Notice: Copyright © 2018 by Jordi Serrano Berbel. All Rights Reserved. // ====================================================================== #pragma once #include "core/utils.h" #include "engine/hitable.h" #include "core/math/aabb.h" class HitableList : public Hitable { public: inline HitableList(u32 _capacity); constexpr HitableList(const HitableList&) noexcept = delete; constexpr HitableList& operator=(const HitableList&) noexcept = delete; inline HitableList(HitableList&& _other) noexcept; constexpr HitableList& operator=(HitableList&& _other) noexcept; virtual inline ~HitableList(); constexpr Hitable*& add(Hitable* _h); constexpr Hitable*& operator[](usize _idx) const; constexpr Hitable** get_buffer() const; constexpr u32 get_size() const; inline b32 hit(const Ray& _ray, f32 _time, f32 _zmin, f32 _zmax, Hit* hit_) const override; inline b32 compute_aabb(f32 _time, AABB* aabb_) const override; inline b32 compute_aabb(f32 _t0, f32 _t1, AABB* aabb_) const override; private: Hitable** m_hitables = nullptr; u32 m_size = 0u; u32 m_capacity = 0u; }; inline HitableList::HitableList(u32 _capacity) : m_hitables(new Hitable*[_capacity]) , m_size(0u) , m_capacity(_capacity) { } inline HitableList::HitableList(HitableList&& _other) noexcept : m_hitables(std::exchange(_other.m_hitables, nullptr)) , m_size(_other.m_size) , m_capacity(_other.m_capacity) { } inline constexpr HitableList& HitableList::operator=(HitableList&& _other) noexcept { if (this != std::addressof(_other)) { m_hitables = std::exchange(_other.m_hitables, nullptr); m_size = _other.m_size; m_capacity = _other.m_capacity; } return *this; } inline HitableList::~HitableList() { for (usize idx = 0; idx < m_size; ++idx) util::safe_del(m_hitables[idx]); } constexpr Hitable*& HitableList::add(Hitable* _h) { sws_assert(m_size < m_capacity); return (m_hitables[m_size++] = _h); } inline constexpr Hitable*& HitableList::operator[](usize _idx) const { sws_assert(_idx < m_size); return m_hitables[_idx]; } inline constexpr Hitable** HitableList::get_buffer() const { return m_hitables; } inline constexpr u32 HitableList::get_size() const { return m_size; } inline b32 HitableList::hit(const Ray& _ray, f32 _time, f32 _zmin, f32 _zmax, Hit* hit_) const { sws_assert(hit_); Hit tmp_hit; b32 has_hit_anything = false; f32 closest_dist = _zmax; for (usize idx = 0; idx < m_size; ++idx) { if (m_hitables[idx]->hit(_ray, _time, _zmin, closest_dist, &tmp_hit)) { has_hit_anything = true; closest_dist = tmp_hit.distance; *hit_ = std::move(tmp_hit); } } return has_hit_anything; } inline b32 HitableList::compute_aabb(f32 _time, AABB* aabb_) const { return false; }; inline b32 HitableList::compute_aabb(f32 _t0, f32 _t1, AABB* aabb_) const { if (m_size == 0) return false; AABB tmp_aabb; if (!m_hitables[0]->compute_aabb(_t0, _t1, &tmp_aabb)) return false; *aabb_ = tmp_aabb; for (usize idx = 1u; idx < m_size; ++idx) { if (!m_hitables[idx]->compute_aabb(_t0, _t1, &tmp_aabb)) return false; *aabb_ = AABB::get_surrounding_box(*aabb_, tmp_aabb); } return true; }
8feae4433d3aa3dca6eb54fa2c06ef10ffa7189c
76d97141373d29e94f068a66342445ad7fe57063
/core/addrmng.h
1de48a7bb5127fcf9ea244ee816effc208d92724
[]
no_license
likelibhub/likelib
7e76dea7ee4cb9e3d5d829f9ce34b9d9c9fedb2c
c69d27a853dc66cf907178f9301adc9314e9bf22
refs/heads/master
2020-08-16T09:24:01.666316
2019-10-17T02:44:57
2019-10-17T02:44:57
215,485,190
0
0
null
null
null
null
UTF-8
C++
false
false
773
h
addrmng.h
/***************************************************************************** * * FileName: addrmng.h * * Author: Tom Hui, tomhui1009@yahoo.com, 8613760232170 * * Create Date: Wed Oct 03 21:18 2018 * * Brief: * * *****************************************************************************/ #ifndef __ADDRMNG_H__ #define __ADDRMNG_H__ #include <huibase.h> #include "lktmap.h" #include "block.h" class CAddrMng { public: CAddrMng () { } virtual ~ CAddrMng( ) { } public: HRET OverBlockChain (const CBlockIndexMap& index_map); virtual HRET OverNewBlock (const CBlock& block) = 0; protected: virtual HRET overBlock (const CBlock& block) = 0; virtual HRET overEntry (const CEntry& entry) = 0; }; #endif //__ADDRMNG_H__
77a87006ce34085f1df768bff6dce6947db1c136
5d439adace85071d68aeee6ba6d50ecd8216a74f
/Server/LogicServer/LogicFrame/Logicserver_FrameBase.cpp
078accdfdb139ea8cc959c3dd23495545aec08fc
[]
no_license
gong782008371/IceBurning
4de69395e69c1d4b8e09dc4f6a325b685f9903e2
e9ea9e85d67679957c68535392b24c23f4f1b29d
refs/heads/master
2021-01-22T07:48:28.371128
2016-05-01T13:07:18
2016-05-01T13:07:18
54,826,000
0
0
null
null
null
null
UTF-8
C++
false
false
680
cpp
Logicserver_FrameBase.cpp
#include "Logicserver_FrameBase.h" NS_LS_BEGIN CFrameRegister* CFrameRegister::instance = NULL; CFrameRegister* CFrameRegister::Instance() { if (instance == NULL) { instance = new CFrameRegister(); } return instance; } int32_t CFrameRegister::RegistFrame(int32_t msgID, CFrameBase* frame) { if (msgID_to_Frame.find(msgID) != msgID_to_Frame.end()) { TRACE_WARN("regist the same msgID(%d) with different frame", msgID); return fail; } msgID_to_Frame[msgID] = frame; return success; } CFrameBase* CFrameRegister::GetFrame(int32_t msgID) { return msgID_to_Frame[msgID]; } NS_LS_END
4ffb749d45bdcd7d988aae3c737ba424a1469141
34541ea972c7e8fae951d3ba053be9af35a572cc
/unit 4/BinaryTreeM.h
58a475c15ca6545fb5c0b2707601eba13ebf7683
[ "MIT" ]
permissive
dakshayh/Data-Structures
0d48da88cea9a4f2a72ca05b4773c14c1c025baf
042e0e66578efdba3369a140537ed1567c89d216
refs/heads/master
2021-04-15T13:11:35.110967
2018-01-29T08:35:55
2018-01-29T08:35:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,974
h
BinaryTreeM.h
#include<iostream> #include "stackLinkedList.h" using namespace std; template<class T> class BTree; template<class T> class BTnode { T data; BTnode<T> *lc,*rc; public: BTnode(T d,BTnode<T> *l,BTnode<T> *r) { data=d; rc=r;lc=l; } friend class BTree<T>; }; template<class T> class BTree { BTnode<T> *root; public: BTree(); BTree(T,BTree<T> &,BTree<T> &); void Traversal(); bool isEmpty(); BTree<T>* leftSubtree(); BTree<T>* rightSubtree(); void preorder(BTnode<T> *); void postorder(BTnode<T> *); void inorder(BTnode<T> *); void levelorder(); int height(); int nodes(); int height_r(BTnode<T> *); int nodes_r(BTnode<T> *); void preorder_nr(); void postorder_nr(); void inorder_nr(); }; template<class T> int BTree<T>::height() { return height_r(root); } template<class T> int BTree<T>::nodes() { return nodes_r(root); } template<class T> BTree<T>::BTree() { root=NULL; } template<class T> BTree<T>::BTree(T val,BTree<T> &l,BTree<T> &r) { root=new BTnode<T>(val,l.root,r.root); l.root=r.root=NULL; } template<class T> void BTree<T>::Traversal() { cout<<"\nPreorder:\n"; preorder(root); cout<<"\nPostorder:\n"; postorder(root); cout<<"\nInorder:\n"; inorder(root); /* cout<<"\nLevelorder:\n"; levelorder();*/ } template<class T> void BTree<T>:: preorder(BTnode<T> *p) { if(p) { cout<<p->data; preorder(p->lc); preorder(p->rc); } } template<class T> void BTree<T>:: postorder(BTnode<T> *p) { if(p) { postorder(p->lc); postorder(p->rc); cout<<p->data; } } template<class T> void BTree<T>:: inorder(BTnode<T> *p) { if(p) { inorder(p->lc); cout<<p->data; inorder(p->rc); } } template<class T> bool BTree<T>::isEmpty() { return (root==NULL); } template<class T> int BTree<T>::nodes_r(BTnode<T> *p) { if(p==NULL) return 0; else if(p->lc==NULL&&p->rc==NULL) return 1; else return (1+nodes_r(p->lc)+nodes_r(p->rc)); } template<class T> BTree<T> * BTree<T>::leftSubtree() { BTree<T> *temp=new BTree<T>; temp->root=root->lc; return temp; } template<class T> BTree<T> * BTree<T>::rightSubtree() { BTree<T> *temp=new BTree<T>; temp->root=root->rc; return temp; } template<class T> int BTree<T>::height_r(BTnode<T> *p) { if(p==NULL) return 0; else if(p->lc==NULL&&p->rc!=NULL) return 1+height_r(p->lc); else if(p->lc!=NULL&&p->rc==NULL) return 1+height_r(p->lc); else if(p->lc!=NULL&&p->rc!=NULL) { if(height_r(p->lc)>height_r(p->rc)) return 1+height_r(p->lc); else return 1+height_r(p->rc); } else return 1; } template<class T> void BTree<T>::inorder_nr() { BTnode<T> *p=root; StackLL <BTnode<T> *>s; while(1) { while(p) { s.push(p); p=p->lc; } if(s.isEmpty()) break; p=s.pop(); cout<<p->data; p=p->rc; } } template<class T> void BTree<T>::preorder_nr() { BTnode<T> *p=root; StackLL <BTnode<T> *>s; while(1) { while(p) { s.push(p); cout<<p->data; p=p->lc; } if(s.isEmpty()) break; p=s.pop(); p=p->rc; } }
0dd0259171d0fe4deec3216eb869119d73a0862f
53afd84307ad7e2c69a3c4fdece590c31e865281
/keyboard.cpp
ae9b2a7bf3c7b8616ece85c1f012a367f8cf76dc
[ "MIT" ]
permissive
asmorgan24/login_marketplace
2151229c21a486d9acdfca71cc115e38b2c5c908
828e742e69ca2fb73318f273851be93fcc5f6ddf
refs/heads/master
2021-01-19T13:15:56.853079
2018-11-05T23:47:46
2018-11-05T23:47:46
82,372,537
0
0
null
null
null
null
UTF-8
C++
false
false
5,424
cpp
keyboard.cpp
#include "keyboard.h" #include <iostream> #include <QGridLayout> #include <QSignalMapper> #include <QPushButton> #include "QDesktopWidget" #define NEXT_ROW_MARKER 0 struct KeyboardLayoutEntry{ int key; const char *label; }; KeyboardLayoutEntry keyboardLayout[] = { { Qt::Key_1, "1" }, { Qt::Key_2, "2" }, { Qt::Key_3, "3" }, { Qt::Key_4, "4" }, { Qt::Key_5, "5" }, { Qt::Key_6, "6" }, { Qt::Key_7, "7" }, { Qt::Key_8, "8" }, { Qt::Key_9, "9" }, { Qt::Key_0, "0" }, { Qt::Key_Backspace, "<-" }, { NEXT_ROW_MARKER, 0 }, { Qt::Key_Q, "q" }, { Qt::Key_W, "w" }, { Qt::Key_E, "e" }, { Qt::Key_R, "r" }, { Qt::Key_T, "t" }, { Qt::Key_Y, "y" }, { Qt::Key_U, "u" }, { Qt::Key_I, "i" }, { Qt::Key_O, "o" }, { Qt::Key_P, "p" }, { NEXT_ROW_MARKER, 0 }, { Qt::Key_A, "a" }, { Qt::Key_S, "s" }, { Qt::Key_D, "d" }, { Qt::Key_F, "f" }, { Qt::Key_G, "g" }, { Qt::Key_H, "h" }, { Qt::Key_J, "j" }, { Qt::Key_K, "k" }, { Qt::Key_L, "l" }, { NEXT_ROW_MARKER, 0 }, { Qt::Key_Z, "z" }, { Qt::Key_X, "x" }, { Qt::Key_C, "c" }, { Qt::Key_V, "v" }, { Qt::Key_B, "b" }, { Qt::Key_N, "n" }, { Qt::Key_M, "m" }, { Qt::Key_Enter, "Enter" }, { NEXT_ROW_MARKER, 0 } }; const static int layoutSize = (sizeof(keyboardLayout) / sizeof(KeyboardLayoutEntry)); static QString keyToCharacter(int key) { for (int i = 0; i < layoutSize; ++i) { if (keyboardLayout[i].key == key) return QString::fromLatin1(keyboardLayout[i].label); } return QString(); } Keyboard::Keyboard(QWidget *parent) : QWidget(parent) { setWindowFlags(Qt::WindowDoesNotAcceptFocus | Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::BypassWindowManagerHint); QGridLayout *gridLayout = new QGridLayout(this); blue.setColor(QPalette::Background, Qt::blue); white.setColor(QPalette::Background, Qt::white); QSignalMapper *mapper = new QSignalMapper(this); connect(mapper, SIGNAL(mapped(int)), SLOT(buttonClicked(int))); int row = 0; int column = 0; QDesktopWidget desktop; for (int i = 0; i < layoutSize; ++i) { if (keyboardLayout[i].key == NEXT_ROW_MARKER) { row++; rowLengths.push_back(column); std:: cout << "Columns: " << column << std::endl; column = 0; continue; } QPushButton *button = new QPushButton; button->setFixedWidth(desktop.width()/13); button->setFixedHeight(desktop.height()/2/6); button->setText(QString::fromLatin1(keyboardLayout[i].label)); button->setFocusPolicy(Qt::FocusPolicy::NoFocus); mapper->setMapping(button, keyboardLayout[i].key); connect(button, SIGNAL(clicked()), mapper, SLOT(map())); buttonVec.push_back(button); gridLayout->addWidget(button, row, column); column++; } buttonVec.at(position)->setPalette(blue); } void Keyboard::showKeyboard() { QWidget::show(); } void Keyboard::hideKeyboard() { QWidget::hide(); } bool Keyboard::keyboardVisible() const { return QWidget::isVisible(); } void Keyboard::up(){ buttonVec.at(position)->setPalette(white); std::cout << "Size of row: " << rowLengths.at(getRow()) << std::endl; if (position > rowLengths.at(0)) { position = position-rowLengths.at(getRow()-1); } buttonVec.at(position)->setPalette(blue); std::cout << "New position " << position << std::endl << std::endl; } void Keyboard::down(){ buttonVec.at(position)->setPalette(white); std::cout << "Size of row: " << rowLengths.at(getRow()) << std::endl; if (position <= buttonVec.length()-rowLengths.at(3)) { position = position+rowLengths.at(getRow()); } buttonVec.at(position)->setPalette(blue); std::cout << "New position " << position << std::endl << std::endl; } void Keyboard::right(){ buttonVec.at(position)->setPalette(white); if (position < buttonVec.length()-1) { position++; } buttonVec.at(position)->setPalette(blue); std::cout << "New position " << position << std::endl << std::endl; } void Keyboard::left(){ buttonVec.at(position)->setPalette(white); position--; if (position < 0) { position = 0; } buttonVec.at(position)->setPalette(blue); std::cout << "New position " << position << std::endl << std::endl; } void Keyboard::select(){ if (buttonVec.at(position)->text().toStdString() == "Enter" || buttonVec.at(position)->text().toStdString() == "<-") { emit specialKeyClicked(keyboardLayout[position+getRow()].key); } else { emit keyClicked(keyToCharacter(keyboardLayout[position+getRow()].key)); } } /** * @brief Keyboard::getRow * @return zero based index of current row based on position variable */ int Keyboard::getRow() const { int tmpPosition = position; int row = -1; for (QVector<int>::const_iterator it = rowLengths.begin(); it != rowLengths.end() && tmpPosition >= 0; ++it) { tmpPosition -= *it; row++; } return row >= 0 ? row : 0; } void Keyboard::buttonClicked(int key) { if ((key == Qt::Key_Enter) || (key == Qt::Key_Backspace)) { emit specialKeyClicked(key); } else { emit keyClicked(keyToCharacter(key)); } }
342c5f906851ed4cdb5d7b67cf999d65de849413
b88db70bf12d97fa2ddb1c79e46fc4dd2727ca54
/source/plugins/ass/Ass.cpp
a09cf3f523543a402db13e76f53ea1bc7be3ad52
[]
no_license
RenolY2/RiiStudio
12ed41e0fb2b4f6f1e4c6158a00e5cee49c6f7aa
480fd8bd530b33423f80ff830ae7eaaa732e7839
refs/heads/master
2022-04-23T14:28:50.171276
2020-04-21T11:24:20
2020-04-21T11:24:20
257,517,879
0
0
null
2020-04-21T07:42:46
2020-04-21T07:42:45
null
UTF-8
C++
false
false
26,192
cpp
Ass.cpp
// Assimp importer. #include <glm/glm.hpp> #include <glm/gtx/matrix_decompose.hpp> #include <core/3d/i3dmodel.hpp> #include <core/kpi/Node.hpp> #include <vendor/assimp/Importer.hpp> #include <vendor/assimp/cimport.h> #include <vendor/assimp/postprocess.h> #include <vendor/assimp/scene.h> #include <plugins/gc/Export/IndexedPolygon.hpp> #include <plugins/j3d/Scene.hpp> #include <algorithm> #include <map> #include <vendor/stb_image.h> #undef min namespace riistudio::ass { #pragma region Utility static glm::vec3 getVec(const aiVector3D& vec) { return {vec.x, vec.y, vec.z}; } static glm::vec2 getVec2(const aiVector3D& vec) { return {vec.x, vec.y}; } static libcube::gx::Color getClr(const aiColor4D& clr) { libcube::gx::ColorF32 fclr{clr.r, clr.g, clr.b, clr.a}; return fclr; } static glm::mat4 getMat4(const aiMatrix4x4& mtx) { glm::mat4 out; out[0][0] = mtx.a1; out[1][0] = mtx.a2; out[2][0] = mtx.a3; out[3][0] = mtx.a4; out[0][1] = mtx.b1; out[1][1] = mtx.b2; out[2][1] = mtx.b3; out[3][1] = mtx.b4; out[0][2] = mtx.c1; out[1][2] = mtx.c2; out[2][2] = mtx.c3; out[3][2] = mtx.c4; out[0][3] = mtx.d1; out[1][3] = mtx.d2; out[2][3] = mtx.d3; out[3][3] = mtx.d4; return out; } struct IdCounter { u32 boneId = 0; u32 meshId = 0; u32 matId = 0; std::map<const aiNode*, u32> nodeToBoneIdMap; std::map<u32, u32> matIdToMatIdMap; }; // Actual data we can respect enum class ImpTexType { Diffuse, // Base color Specular, // Attenuate spec lighting or env lighting Ambient, // We can't mix with amb color, but we can just add it on. Emissive, // We also add this on. Perhaps later in the pipeline. Bump, // We use the height map as a basic bump map. // We do not support normal maps. Perhaps convert to Bump. // We do not support shininess. In setups with two env maps, we could // use this to attenuate the specular one. For now, though, it is // unsupported. Opacity, // This can actually be useful. For example, combining CMPR + // I8. Displacement, // Effectively the same as bump maps, but attenuate the // single diffuse component. // Treated as second diffuse, for now // LightMap, // Any second diffuse image gets moved here // We don't support reflection. // Base Color -> Diffuse // Normal Camera -> Unsupported // Emission Color -> Emissive // Metalness -> Ignored for now. We can tint specular to achieve this. // Diffuse Roughness -> Invert for specular eventually // AO -> ANother LightMap // Unknown -> Treat as diffuse, if beyond first slot, LightMap }; struct ImpSampler { ImpTexType type; std::string path; u32 uv_channel; libcube::gx::TextureWrapMode wrap; }; struct ImpMaterial { std::vector<ImpSampler> samplers; }; void CompileMaterial(libcube::IGCMaterial& out, const ImpMaterial& in, std::set<std::string>& texturesToImport) { // Vertex Lighting: // Ambient* + (Diffuse* x LightMap x DIFFUSE_LIGHT) // + (Specular* x SPECULAR_LIGHT) -> Replace with opacity, not attenuate // Env Lighting: // Ambient* + (Diffuse* x LightMap x DIFFUSE_TEX*(Bump)) + // (Specular* x SPECULAR_TEX*(Bump)) -> Replace with opacity // Current, lazy setup: // Diffuse x Diffuse.. -> Replace with opacity // WIP, just supply a pure color.. auto& data = out.getMaterialData(); if (!in.samplers.empty()) { data.samplers.push_back( std::move(std::make_unique<j3d::Material::SamplerData>())); data.samplers[0]->mTexture = in.samplers[0].path; texturesToImport.insert(in.samplers[0].path); data.texMatrices.push_back( std::move(std::make_unique<j3d::Material::TexMatrix>())); data.texGens.push_back({}); } libcube::gx::TevStage wip; wip.texMap = wip.texCoord = 0; wip.colorStage.d = libcube::gx::TevColorArg::texc; wip.alphaStage.d = libcube::gx::TevAlphaArg::texa; data.tevColors[0] = {0xaa, 0xbb, 0xcc, 0xff}; data.shader.mStages[0] = wip; } std::tuple<aiString, unsigned int, aiTextureMapMode> GetTexture(aiMaterial* pMat, int t, int j) { aiString path; // No support for anything non-uv -- already processed away by the time // we get it aiTextureMapping mapping; unsigned int uvindex = 0; // We don't support blend/op. // All the data here *could* be translated to TEV, // but it isn't practical. // ai_real blend; // aiTextureOp op; // No decal support u32 mapmode = aiTextureMapMode_Wrap; pMat->GetTexture(static_cast<aiTextureType>(t), j, &path, nullptr, &uvindex, nullptr, nullptr, nullptr //(aiTextureMapMode*)&mapmode ); return {path, uvindex, (aiTextureMapMode)mapmode}; } #pragma endregion constexpr libcube::gx::VertexAttribute PNM = libcube::gx::VertexAttribute::PositionNormalMatrixIndex; struct AssImporter { IdCounter ctr; IdCounter* boneIdCtr = &ctr; const aiScene* pScene = nullptr; j3d::CollectionAccessor out_collection; j3d::ModelAccessor out_model_ac; j3d::Model& out_model; AssImporter(const aiScene* scene, kpi::IDocumentNode* mdl) : pScene(scene), out_collection({mdl}), out_model_ac(out_collection.addModel()), out_model(out_model_ac.get()) { } int get_bone_id(const aiNode* pNode) { return boneIdCtr->nodeToBoneIdMap.find(pNode) != boneIdCtr->nodeToBoneIdMap.end() ? boneIdCtr->nodeToBoneIdMap[pNode] : -1; } // Only call if weighted u16 add_weight_matrix_low(const j3d::DrawMatrix& drw) { const auto found = std::find(out_model.mDrawMatrices.begin(), out_model.mDrawMatrices.end(), drw); if (found != out_model.mDrawMatrices.end()) { return found - out_model.mDrawMatrices.begin(); } else { out_model.mDrawMatrices.push_back(drw); return out_model.mDrawMatrices.size() - 1; } } u16 add_weight_matrix(int v, const aiMesh* pMesh, j3d::DrawMatrix* pDrwOut = nullptr) { j3d::DrawMatrix drw; for (int j = 0; j < pMesh->mNumBones; ++j) { const auto* pBone = pMesh->mBones[j]; for (int k = 0; k < pBone->mNumWeights; ++k) { const auto* pWeight = &pBone->mWeights[k]; if (pWeight->mVertexId == v) { const auto boneid = get_bone_id(pBone->mNode); assert(boneid != -1); drw.mWeights.emplace_back(boneid, pWeight->mWeight); break; } } } if (pDrwOut != nullptr) *pDrwOut = drw; return add_weight_matrix_low(drw); }; void ProcessMeshTrianglesStatic(const aiNode* singleInfluence, j3d::Shape& poly_data, std::vector<libcube::IndexedVertex>&& vertices) { auto& mp = poly_data.mMatrixPrimitives[poly_data.addMatrixPrimitive()]; // Copy triangle data // We will do triangle-stripping in a post-process auto& tris = mp.mPrimitives.emplace_back(); tris.mType = libcube::gx::PrimitiveType::Triangles; tris.mVertices = std::move(vertices); const int boneId = get_bone_id(singleInfluence); assert(boneId > 0); j3d::DrawMatrix drw{{{static_cast<u32>(boneId), 1.0f}}}; const auto mtx = add_weight_matrix_low(drw); mp.mCurrentMatrix = mtx; mp.mDrawMatrixIndices.push_back(mtx); } void ProcessMeshTrianglesWeighted(j3d::Shape& poly_data, std::vector<libcube::IndexedVertex>&& vertices) { // At this point, the mtx index of vertices is global. // We need to convert it to a local palette index. // Tolerence should be implemented here, eventually. std::vector<u16> matrix_indices; for (auto& v : vertices) { const auto mtx_idx = v[PNM]; // Hack: We will come across data as such (assume 3-wide sweep) // (A B B) (C A D) // To prevent this transforming into // (A B C) (D) // Where references to A in the second sweep will fail, // we simply don't compress across sweeps: // (A B B) (C A D) // (A B C) (A D) // It's far from optimal, but the current choice: const std::size_t sweep_id = matrix_indices.size() / 10; const std::size_t sweep_begin = sweep_id * 10; const std::size_t sweep_end = std::min(matrix_indices.size(), (sweep_id + 1) * 10); const auto found = std::find(matrix_indices.begin() + sweep_begin, matrix_indices.begin() + sweep_end, mtx_idx); if (found == matrix_indices.end()) { matrix_indices.push_back(mtx_idx); } } auto vertex_sweep_index = [&](int v, int sweep) -> int { const auto found = std::find(matrix_indices.begin() + sweep * 10, matrix_indices.begin() + std::min(static_cast<int>(matrix_indices.size()), (sweep + 1) * 10), vertices[v][PNM]); if (found == matrix_indices.end()) return -1; const auto idx = std::distance(matrix_indices.begin(), found); // Old code not based on sweep-specific search // if (idx >= sweep * 10 && idx < (sweep + 1) * 10) { // // We're inside the sweep; // return idx - sweep * 10; // } // We're outside the sweep: // return -1; return idx; }; assert(vertices.size() % 3 == 0); int sweep_wave = 0; bool reversed = false; int last_sweep_vtx = 0; for (int f = 0; f < vertices.size() / 3; ++f) { const int v0 = f * 3 + 0; const int v1 = f * 3 + 1; const int v2 = f * 3 + 2; const int s0 = vertex_sweep_index(v0, sweep_wave); const int s1 = vertex_sweep_index(v1, sweep_wave); const int s2 = vertex_sweep_index(v2, sweep_wave); if (s0 < 0 || s1 < 0 || s2 < 0) { assert(s0 != -2 && s1 != -2 && s2 != -2 && "matrix_indices has not been properly filled"); // But submit what we have so far, first: auto& mp = poly_data.mMatrixPrimitives[poly_data.addMatrixPrimitive()]; auto& tris = mp.mPrimitives.emplace_back(); tris.mType = libcube::gx::PrimitiveType::Triangles; std::copy(vertices.begin() + last_sweep_vtx, vertices.begin() + v0, std::back_inserter(tris.mVertices)); last_sweep_vtx = v0; mp.mCurrentMatrix = -1; const auto sweep_begin = sweep_wave * 10; const auto sweep_end = std::min( (sweep_wave + 1) * 10, static_cast<int>(matrix_indices.size())); std::copy(matrix_indices.begin() + sweep_begin, matrix_indices.begin() + sweep_end, std::back_inserter(mp.mDrawMatrixIndices)); // Reverse one step, but in the next wave: assert(!reversed && "matrix_indices is unsorted"); --f; ++sweep_wave; reversed = true; continue; } reversed = false; vertices[v0][PNM] = s0; vertices[v0][PNM] = s1; vertices[v0][PNM] = s2; } } void ProcessMeshTriangles(j3d::Shape& poly_data, const aiMesh* pMesh, const aiNode* pNode, std::vector<libcube::IndexedVertex>&& vertices) { // Determine if we need to do matrix processing if (poly_data.mVertexDescriptor.mBitfield & (1 << (int)PNM)) { ProcessMeshTrianglesWeighted(poly_data, std::move(vertices)); } else { // If one bone, bind to that; otherwise, bind to the node itself. const aiNode* single_influence = pMesh->HasBones() ? pMesh->mBones[0]->mNode : pNode; ProcessMeshTrianglesStatic(single_influence, poly_data, std::move(vertices)); } } void ImportMesh(const aiMesh* pMesh, const aiNode* pNode) { assert(pMesh->mPrimitiveTypes == aiPrimitiveType_TRIANGLE); auto poly = out_model_ac.addShape(); auto& poly_data = poly.get(); poly_data.mode = j3d::ShapeData::Mode::Skinned; poly.get().bbox.min = {pMesh->mAABB.mMin.x, pMesh->mAABB.mMin.y, pMesh->mAABB.mMin.z}; poly.get().bbox.max = {pMesh->mAABB.mMax.x, pMesh->mAABB.mMax.y, pMesh->mAABB.mMax.z}; // TODO: Sphere auto add_attribute = [&](auto type, bool direct = false) { poly_data.mVertexDescriptor.mAttributes[type] = direct ? libcube::gx::VertexAttributeType::Direct : libcube::gx::VertexAttributeType::Short; }; add_attribute(libcube::gx::VertexAttribute::Position); if (pMesh->HasNormals()) add_attribute(libcube::gx::VertexAttribute::Normal); for (int j = 0; j < 2; ++j) { if (pMesh->HasVertexColors(j)) add_attribute(libcube::gx::VertexAttribute::Color0 + j); } for (int j = 0; j < 8; ++j) { if (pMesh->HasTextureCoords(j)) { add_attribute(libcube::gx::VertexAttribute::TexCoord0 + j); assert(pMesh->mNumUVComponents[j] == 2); } } auto add_to_buffer = [&](const auto& entry, auto& buf) -> u16 { const auto found = std::find(buf.begin(), buf.end(), entry); if (found != buf.end()) { return found - buf.begin(); } buf.push_back(entry); return buf.size() - 1; }; auto add_position = [&](int v, const j3d::DrawMatrix* wt = nullptr) { glm::vec3 pos = getVec(pMesh->mVertices[v]); // If rigid, transform into bone-space // This assumes that meshes will not be influenced by their children? This // could be a bad assumption.. if (wt != nullptr && wt->mWeights.size() == 1) { const auto& acting_influence = out_model_ac.getJointRaw(wt->mWeights[0].boneId); pos = glm::vec4(pos, 0) * glm::inverse(acting_influence.calcSrtMtx( &out_model_ac.getJoints())); } return add_to_buffer(pos, out_model_ac.get().mBufs.pos.mData); }; auto add_normal = [&](int v) { return add_to_buffer(getVec(pMesh->mNormals[v]), out_model_ac.get().mBufs.norm.mData); }; auto add_color = [&](int v, int j) { return add_to_buffer(getClr(pMesh->mColors[j][v]), out_model_ac.get().mBufs.color[j].mData); }; auto add_uv = [&](int v, int j) { return add_to_buffer(getVec2(pMesh->mTextureCoords[j][v]), out_model_ac.get().mBufs.uv[j].mData); }; // More than one bone -> Assume multi mtx, unless zero influence // With one weight, must be singlebound! no partial / null weight bool multi_mtx = pMesh->HasBones() && pMesh->mNumBones > 1; if (multi_mtx) add_attribute(PNM); poly_data.mVertexDescriptor.calcVertexDescriptorFromAttributeList(); std::vector<libcube::IndexedVertex> vertices; for (int f = 0; f < pMesh->mNumFaces; ++f) { for (int fv = 0; fv < 3; ++fv) { const auto v = pMesh->mFaces[f].mIndices[fv]; libcube::IndexedVertex vtx{}; j3d::DrawMatrix drw; const auto weightInfo = pMesh->HasBones() ? add_weight_matrix(v, pMesh, &drw) : 0; if (multi_mtx) { vtx[PNM] = weightInfo * 3; } vtx[libcube::gx::VertexAttribute::Position] = add_position(v, &drw); if (pMesh->HasNormals()) vtx[libcube::gx::VertexAttribute::Normal] = add_normal(v); for (int j = 0; j < 2; ++j) { if (pMesh->HasVertexColors(j)) vtx[libcube::gx::VertexAttribute::Color0 + j] = add_color(v, j); } for (int j = 0; j < 8; ++j) { if (pMesh->HasTextureCoords(j)) { vtx[libcube::gx::VertexAttribute::TexCoord0 + j] = add_uv(v, j); } } vertices.push_back(vtx); } } ProcessMeshTriangles(poly_data, pMesh, pNode, std::move(vertices)); } void ImportNode(const aiNode* pNode, lib3d::Bone* parent = nullptr) { // Create a bone (with name) auto joint = out_model_ac.addJoint(); joint.get().setName(pNode->mName.C_Str()); const glm::mat4 xf = getMat4(pNode->mTransformation); lib3d::SRT3 srt; glm::quat rotation; glm::vec3 skew; glm::vec4 perspective; glm::decompose(xf, srt.scale, rotation, srt.translation, skew, perspective); srt.rotation = {glm::degrees(glm::eulerAngles(rotation).x), glm::degrees(glm::eulerAngles(rotation).y), glm::degrees(glm::eulerAngles(rotation).z)}; joint.get().setSRT(srt); IdCounter localBoneIdCtr; if (boneIdCtr == nullptr) boneIdCtr = &localBoneIdCtr; joint.get().id = boneIdCtr->boneId++; boneIdCtr->nodeToBoneIdMap[pNode] = joint.get().id; joint.get().setBoneParent(parent != nullptr ? parent->getId() : -1); if (parent != nullptr) parent->addChild(joint.get().getId()); // Mesh data for (int i = 0; i < pNode->mNumMeshes; ++i) { // Can these be duplicated? const auto* pMesh = pScene->mMeshes[pNode->mMeshes[i]]; assert(boneIdCtr->matIdToMatIdMap.find(pMesh->mMaterialIndex) != boneIdCtr->matIdToMatIdMap.end()); const auto matId = boneIdCtr->matIdToMatIdMap[pMesh->mMaterialIndex]; joint.get().addDisplay({matId, boneIdCtr->meshId++, 0}); ImportMesh(pMesh, pNode); } for (int i = 0; i < pNode->mNumChildren; ++i) { ImportNode(pNode->mChildren[i], &joint.get()); } } void ImportAss() { const auto* root = pScene->mRootNode; assert(root != nullptr); std::set<std::string> texturesToImport; for (unsigned int i = 0; i < pScene->mNumMaterials; ++i) { auto* pMat = pScene->mMaterials[i]; auto& mr = out_model_ac.addMaterialRaw(); mr.id = i; const auto name = pMat->GetName(); mr.name = name.C_Str(); if (mr.name == "") { mr.name = "Material"; mr.name += std::to_string(i); } boneIdCtr->matIdToMatIdMap[i] = mr.id; ImpMaterial impMat; for (int t = aiTextureType_DIFFUSE; t <= aiTextureType_UNKNOWN; ++t) { for (int j = 0; j < pMat->GetTextureCount((aiTextureType)t); ++j) { const auto [path, uvindex, mapmode] = GetTexture(pMat, t, j); ImpTexType impTexType = ImpTexType::Diffuse; switch (t) { case aiTextureType_DIFFUSE: impTexType = ImpTexType::Diffuse; break; /** The texture is combined with the result of the specular * lighting equation. */ case aiTextureType_SPECULAR: impTexType = ImpTexType::Specular; break; /** The texture is combined with the result of the ambient * lighting equation. */ case aiTextureType_AMBIENT: impTexType = ImpTexType::Ambient; break; /** The texture is added to the result of the lighting * calculation. It isn't influenced by incoming light. */ case aiTextureType_EMISSIVE: impTexType = ImpTexType::Emissive; break; /** The texture is a height map. * * By convention, higher gray-scale values stand for * higher elevations from the base height. */ case aiTextureType_HEIGHT: impTexType = ImpTexType::Bump; break; /** The texture is a (tangent space) normal-map. * * Again, there are several conventions for tangent-space * normal maps. Assimp does (intentionally) not * distinguish here. */ case aiTextureType_NORMALS: impTexType = ImpTexType::Diffuse; // TODO break; /** The texture defines the glossiness of the material. * * The glossiness is in fact the exponent of the specular * (phong) lighting equation. Usually there is a conversion * function defined to map the linear color values in the * texture to a suitable exponent. Have fun. */ case aiTextureType_SHININESS: impTexType = ImpTexType::Diffuse; // TODO break; /** The texture defines per-pixel opacity. * * Usually 'white' means opaque and 'black' means * 'transparency'. Or quite the opposite. Have fun. */ case aiTextureType_OPACITY: impTexType = ImpTexType::Opacity; break; /** Displacement texture * * The exact purpose and format is application-dependent. * Higher color values stand for higher vertex displacements. */ case aiTextureType_DISPLACEMENT: impTexType = ImpTexType::Displacement; break; /** Lightmap texture (aka Ambient Occlusion) * * Both 'Lightmaps' and dedicated 'ambient occlusion maps' are * covered by this material property. The texture contains a * scaling value for the final color value of a pixel. Its * intensity is not affected by incoming light. */ case aiTextureType_LIGHTMAP: impTexType = ImpTexType::Diffuse; // TODO break; /** Reflection texture * * Contains the color of a perfect mirror reflection. * Rarely used, almost never for real-time applications. */ case aiTextureType_REFLECTION: impTexType = ImpTexType::Diffuse; // TODO break; /** PBR Materials * PBR definitions from maya and other modelling packages now use * this standard. This was originally introduced around 2012. * Support for this is in game engines like Godot, Unreal or * Unity3D. Modelling packages which use this are very common now. */ case aiTextureType_BASE_COLOR: impTexType = ImpTexType::Diffuse; break; case aiTextureType_NORMAL_CAMERA: impTexType = ImpTexType::Diffuse; // TODO break; case aiTextureType_EMISSION_COLOR: impTexType = ImpTexType::Emissive; break; case aiTextureType_METALNESS: impTexType = ImpTexType::Diffuse; // TODO break; case aiTextureType_DIFFUSE_ROUGHNESS: impTexType = ImpTexType::Diffuse; // TODO break; case aiTextureType_AMBIENT_OCCLUSION: impTexType = ImpTexType::Diffuse; // LM break; /** Unknown texture * * A texture reference that does not match any of the definitions * above is considered to be 'unknown'. It is still imported, * but is excluded from any further post-processing. */ case aiTextureType_UNKNOWN: impTexType = ImpTexType::Diffuse; break; } libcube::gx::TextureWrapMode impWrapMode = libcube::gx::TextureWrapMode::Repeat; switch (mapmode) { case aiTextureMapMode_Decal: case aiTextureMapMode_Clamp: impWrapMode = libcube::gx::TextureWrapMode::Clamp; break; case aiTextureMapMode_Wrap: impWrapMode = libcube::gx::TextureWrapMode::Repeat; break; case aiTextureMapMode_Mirror: impWrapMode = libcube::gx::TextureWrapMode::Mirror; break; } ImpSampler impSamp{impTexType, path.C_Str(), uvindex, impWrapMode}; impMat.samplers.push_back(impSamp); } } CompileMaterial(mr, impMat, texturesToImport); } for (auto& tex : texturesToImport) { printf("Importing texture: %s\n", tex.c_str()); auto& data = out_collection.addTextureRaw(); data.mName = tex; int width, height, channels; unsigned char* image = stbi_load((tex).c_str(), &width, &height, &channels, STBI_rgb_alpha); assert(image); data.mFormat = (int)libcube::gx::TextureFormat::CMPR; data.setWidth(width); data.setHeight(height); data.setMipmapCount(0); data.resizeData(); data.encode(image); stbi_image_free(image); } ImportNode(root); } }; inline bool ends_with(const std::string& value, const std::string& ending) { return ending.size() <= value.size() && std::equal(ending.rbegin(), ending.rend(), value.rbegin()); } struct AssReader { std::string canRead(const std::string& file, oishii::BinaryReader& reader) const { const std::array<std::string, 3> supported_endings = {".dae", ".obj", ".fbx"}; if (std::find_if(supported_endings.begin(), supported_endings.end(), [&](const std::string& ending) { return ends_with(file, ending); }) == supported_endings.end()) { return ""; } return typeid(lib3d::Scene).name(); } void read(kpi::IDocumentNode& node, oishii::BinaryReader& reader) const { const u32 ass_flags = aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_ValidateDataStructure | aiProcess_RemoveRedundantMaterials | aiProcess_PopulateArmatureData | aiProcess_FindDegenerates | aiProcess_FindInvalidData | aiProcess_GenUVCoords | aiProcess_FindInstances | aiProcess_OptimizeMeshes | aiProcess_Debone | aiProcess_GenBoundingBoxes | aiProcess_FlipUVs | aiProcess_FlipWindingOrder; Assimp::Importer importer; const auto* pScene = importer.ReadFileFromMemory( reader.getStreamStart(), reader.endpos(), ass_flags, reader.getFile()); AssImporter assConverter(pScene, &node); assConverter.ImportAss(); } }; void Install() { auto& installer = *kpi::ApplicationPlugins::spInstance; installer.addDeserializer<AssReader>(); } } // namespace riistudio::ass
a558ae86a68113516f62e757e94012287165c44f
6f53c35cd526a8b72190bb9d84dc1b0f9954db33
/Random_Codes/nbinstrings.cpp
0ea09da5b8eace837444954bda8f0c59df8021bb
[]
no_license
k-raghav/Coding
8158196a2f671652dde61e72a73130482388c537
b00aff9537f1f24b6186dc54eb3a1ddbc935230a
refs/heads/master
2021-01-10T09:34:26.621649
2019-03-19T14:38:32
2019-03-19T14:38:32
46,981,755
0
0
null
2019-03-21T13:13:37
2015-11-27T13:30:14
C++
UTF-8
C++
false
false
367
cpp
nbinstrings.cpp
#include<bits/stdc++.h> using namespace std; void helper(int n, int k , string &curr) { if(n == 0) { cout << curr << endl; return; } for(int i = 0 ; i < k ; i++ ) { char c = i + '0'; curr.push_back(c); helper(n-1,k,curr); curr.pop_back(); } } void nbinstrings(int n,int k) { string curr=""; helper(n,k,curr); } int main() { nbinstrings(5,3); }
d458c879dd0c31145fb381a0133a4c248d93b966
f016cafc82547942fcb40fa16bf8b2b3cdd4ece4
/cpp/packet/edns.cpp
d8910bbd50e9d7222f5aa6f65ef3fb054e94a942
[]
no_license
FlyingWithJerome/DNS-measurement-cpp
fb91337e20785fde6083e31b1e5fda0037556c4b
5509eb29cc74f493d844a593bb3e4bad81ab3c3e
refs/heads/master
2020-04-22T06:20:05.252994
2019-09-21T14:32:25
2019-09-21T14:32:25
170,186,905
0
0
null
null
null
null
UTF-8
C++
false
false
2,399
cpp
edns.cpp
#include "edns.hpp" EDNS::EDNS(const Tins::DNS& incoming_packet) { if (incoming_packet.additional_count() > 0) { Tins::DNS::resource EDNS_record = incoming_packet.additional()[incoming_packet.additional_count()-1]; if (EDNS_record.type() != 41) { goto No_EDNS_Support; } else { EDNS0_payload = EDNS_record.query_class(); support_EDNS0 = true; support_DNSSEC = (EDNS_record.ttl() & 32768) >> 15; // get the 17th bit (do flag) std::string ECS_data = EDNS_record.data(); bool may_support_ECS = ECS_data.size() != 0; if (may_support_ECS) { uint16_t op_code = (uint8_t)ECS_data[0] << 8 | (uint8_t)ECS_data[1]; uint16_t op_len = (uint8_t)ECS_data[2] << 8 | (uint8_t)ECS_data[3]; uint16_t family = (uint8_t)ECS_data[4] << 8 | (uint8_t)ECS_data[5]; support_ECS = op_code == 8; if (support_ECS and family == 1) { ECS_subnet_mask = (int)ECS_data[6]; uint32_t subnet_address = 0; for(int index = 7; index < ECS_data.size(); index++) subnet_address = (subnet_address << 8) | (uint8_t)ECS_data[index]; subnet_address <<= (32 - ECS_subnet_mask); std::ostringstream address_builder; address_builder << ((subnet_address >> 24) & 0xFF) << "." << ((subnet_address >> 16) & 0xFF) << "." << ((subnet_address >> 8) & 0xFF) << "." << (subnet_address & 0xFF); ECS_subnet_address = address_builder.str(); goto Full_Support; } else { goto No_ECS_Support; } } else { goto No_ECS_Support; } } } No_EDNS_Support: support_EDNS0 = false; support_DNSSEC = false; EDNS0_payload = -1; No_ECS_Support: support_ECS = false; ECS_subnet_mask = 0; ECS_subnet_address = "0.0.0.0"; Full_Support: ; }
d8c654af83a4d364973f7337b1ba43dea86482dd
ccb6a24f65af2848b271dcd8707271d54be2efbf
/src/Chapter11/vect.cpp
53566ea60ac1486a2469251dadda457fc86ad90d
[]
no_license
linxiaoyi0724/CppProcessTestUbuntu
94856b95fb7671af6c0b8d42d85fede638a521a8
ee68857928abc18880c1cda7156990290e05a62f
refs/heads/master
2021-07-12T04:40:08.415250
2020-08-24T16:06:06
2020-08-24T16:06:06
194,497,783
1
0
null
null
null
null
UTF-8
C++
false
false
1,822
cpp
vect.cpp
#include "vect.h" #include <cmath> namespace VECTOR { const double Rad_To_deg = 57.2957795130823; // void Vector::set_mag() // { // mag = std::sqrt(x * x + y*y); // } // void Vector::set_ang() // { // if(x == 0.0 && y == 0.0) // { // ang = 0.0; // } // else // { // ang = atan2(y,x); // } // } void Vector::set_x() { x = mag * cos(ang); } void Vector::set_y() { y = mag * sin(ang); } Vector::Vector() { x = y = mag = ang = 0.0; mode = 'r'; } Vector::Vector(double n1, double n2, char form) { mode = form; if(mode == 'r') { x = n1; y = n2; // set_mag(); // set_ang(); } else if(mode == 'p') { mag = n1; ang = n2 / Rad_To_deg; set_x(); set_y(); } } void Vector::set(double n1, double n2, char form) { mode = form; if(mode == 'r') { x = n1; y = n2; // set_mag(); // set_ang(); } else if(mode == 'p') { mag = n1; ang = n2 /Rad_To_deg; set_x(); set_y(); } } double Vector::magval() { mag = std::sqrt(x * x + y*y); return mag; } double Vector::angval() { if(x == 0.0 && y == 0.0) { ang = 0.0; } else { ang = atan2(y,x); } return ang; } Vector operator+(Vector v1, Vector v2) { Vector result(v1.x + v2.x , v1.y + v2.y, 'r'); return result; } }
9064fe81c7e16b612a6d3e4b1e55b9a11a081624
5fb73487b78a786821c00c93222a06812d3652cf
/installer_py/additional_files/Inc/NN.h
b0074965bd0f5a7147180d4878a7d8b54d97f1d0
[]
no_license
GiorgioCozza/AOS_AI_Movement_Recognition
69536d380903a847d100e0229d683479628f9aff
d08ec8435e61fd36bb875147ab0c21a49a998572
refs/heads/master
2022-04-19T22:21:42.038908
2020-04-19T18:46:42
2020-04-19T18:46:42
229,559,581
0
0
null
null
null
null
UTF-8
C++
false
false
3,161
h
NN.h
/** ******************************************************************************* * @file NN.h * @author Cozza Giorgio, Liu Jiaqi * @date 08/04/19 * @version 1.0 * @brief Class in charge of managing a neural network instance. ******************************************************************************* This is a free software released into public domain. Anyone is free to copy, modify, publish, use, compile or distribute this software, either in source code form or as compiled binary 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 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************** */ #ifndef NN_H #define NN_H /*----------------- INCLUDES --------------------------------*/ #include <stdio.h> #include "network.h" #include "network_data.h" #include "miosix.h" #include "data_proc.h" #include "main_config.h" class NN { public: NN() {}; ~NN() { }; /** * Method that creates the neural network. * \param net ai_handle reference. * \return bool. */ bool nnCreate(ai_handle * net); /** * Method that initializes the neural network. * \param net ai_handle reference. * \param ai_input reference that contains network parameters * \param activations array reference * \return the result of the operation. */ bool nnInit(ai_handle net, ai_network_params* net_par, ai_u8 * activations); /** * Initializes input and output of the neural network. * \param net ai_handle reference. * \param ai_input an ai_buffer to store processed input * \param ai_output ai_buffer to store prediction results * \param in_data ai_float input pointer * \param out_data ai_float output pointer * \return the result of the operation. */ bool prepareData(data_proc* ds_pp, ai_float* in_data, ai_float* out_data, ai_buffer* ai_input, ai_buffer* ai_output, const ai_u16 batches); /** * Runs the neural network. * \param net ai_handle reference. * \param ai_input an ai_buffer reference that contains processed input segment * \param ai_output ai_buffer reference to store results * \return the result of the operation. */ int nnRun(ai_handle net, const ai_buffer* ai_input, ai_buffer* ai_output, const ai_u16 batch_size); /** * Method that destroys the neural network. * \param net ai_handle reference. * \return the reference of the deleted network. */ bool nnDestroy(ai_handle net); /** * Show neural network info. * \param net ai_handle reference. */ void showNNInfo(const ai_handle net); protected: private: ai_network_params* params=nullptr; ai_error last_error_rep; ai_network_report* report=nullptr; }; #endif