blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
48fef59eafa0f95c149b4f60025dc9b6301f898c
dc0208a9963e2bb76517b92b1f35029f07c249e0
/Model code/bfs_nhp.cpp
f2466be315f1c0db5b45be1cce228ae77bbbc971
[]
no_license
basvanopheusden/fourinarow
fc39ff1e921a63c0a109519f9b26161e179578bc
d276900ccee7890e9195db592b7fef7c1d39ae54
refs/heads/master
2023-01-11T13:30:52.542395
2023-01-02T16:13:15
2023-01-02T16:13:15
242,221,537
4
4
null
null
null
null
UTF-8
C++
false
false
1,398
cpp
#include "bfs_nhp.h" #define BLACK_WINS 4*BOARD_WIDTH #define WHITE_WINS -4*BOARD_WIDTH #define DRAW 0 using namespace bfs; nhp_node::nhp_node(board bstart,double v,bool p,int d){ b=bstart; depth=d; player=p; child=NULL; parent=NULL; best=NULL; Nchildren=0; iteration=-1; m=0; if(b.black_has_won()) pess=opt=BLACK_WINS-depth,val=10000.0; else if(b.is_full()) pess=opt=0,val=0.0; else val=v,pess=0,opt=BLACK_WINS-depth-1; } void nhp_node::get_opt(){ opt=(player==BLACK?0:BLACK_WINS); for(unsigned int i=0;i<Nchildren;i++) update_opt(child[i]); } void nhp_node::get_pess(){ pess=(player==BLACK?0:BLACK_WINS); for(unsigned int i=0;i<Nchildren;i++) update_pess(child[i]); } void nhp_node::expand(vector<zet> candidate,int n){ Nchildren=candidate.size(); if(Nchildren>0){ iteration = n; child=new node*[Nchildren]; for(unsigned int i=0;i<Nchildren;i++){ if(player==BLACK) child[i]=new nhp_node(b+candidate[i],val+candidate[i].val,!player,depth+1); else child[i]=new nhp_node(b+candidate[i],val-candidate[i].val,!player,depth+1); child[i]->parent=this; child[i]->m=candidate[i].zet_id; } get_opt(); get_pess(); get_val(); if(determined()) get_best_determined(); if(parent) parent->backpropagate(this); } }
[ "svo@PSY-19BY1941A6.pu.win.princeton.edu" ]
svo@PSY-19BY1941A6.pu.win.princeton.edu
a5c435919ca25cb1126785b5139d98899c9a9887
3ad968797a01a4e4b9a87e2200eeb3fb47bf269a
/Advanced MFC Programming/Chap3/3.4/Spw/MainFrm.h
f418c5e7270ad63d67b2a36979303556fe9e97bb
[]
no_license
LittleDrogon/MFC-Examples
403641a1ae9b90e67fe242da3af6d9285698f10b
1d8b5d19033409cd89da3aba3ec1695802c89a7a
refs/heads/main
2023-03-20T22:53:02.590825
2020-12-31T09:56:37
2020-12-31T09:56:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
960
h
#if !defined(AFX_MAINFRM_H__D3F202D6_FC3A_11D0_9C9A_444553540000__INCLUDED_) #define AFX_MAINFRM_H__D3F202D6_FC3A_11D0_9C9A_444553540000__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif #include "SpWnd.h" class CMainFrame : public CFrameWnd { protected: CMainFrame(); DECLARE_DYNCREATE(CMainFrame) protected: MCSplitterWnd m_wndSp; public: //{{AFX_VIRTUAL(CMainFrame) public: virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); //}}AFX_VIRTUAL public: virtual ~CMainFrame(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: CStatusBar m_wndStatusBar; CToolBar m_wndToolBar; //{{AFX_MSG(CMainFrame) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} #endif // !defined(AFX_MAINFRM_H__D3F202D6_FC3A_11D0_9C9A_444553540000__INCLUDED_)
[ "pkedpekr@gmail.com" ]
pkedpekr@gmail.com
ac55be0fcd43d049f628e05dbf448e2dbc7c6a05
41b4adb10cc86338d85db6636900168f55e7ff18
/aws-cpp-sdk-config/source/model/Evaluation.cpp
03a1e8c10dd92acb93f47448051508fb37a77b9d
[ "JSON", "MIT", "Apache-2.0" ]
permissive
totalkyos/AWS
1c9ac30206ef6cf8ca38d2c3d1496fa9c15e5e80
7cb444814e938f3df59530ea4ebe8e19b9418793
refs/heads/master
2021-01-20T20:42:09.978428
2016-07-16T00:03:49
2016-07-16T00:03:49
63,465,708
1
1
null
null
null
null
UTF-8
C++
false
false
3,073
cpp
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <aws/config/model/Evaluation.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Utils::Json; using namespace Aws::Utils; namespace Aws { namespace ConfigService { namespace Model { Evaluation::Evaluation() : m_complianceResourceTypeHasBeenSet(false), m_complianceResourceIdHasBeenSet(false), m_complianceTypeHasBeenSet(false), m_annotationHasBeenSet(false), m_orderingTimestampHasBeenSet(false) { } Evaluation::Evaluation(const JsonValue& jsonValue) : m_complianceResourceTypeHasBeenSet(false), m_complianceResourceIdHasBeenSet(false), m_complianceTypeHasBeenSet(false), m_annotationHasBeenSet(false), m_orderingTimestampHasBeenSet(false) { *this = jsonValue; } Evaluation& Evaluation::operator =(const JsonValue& jsonValue) { if(jsonValue.ValueExists("ComplianceResourceType")) { m_complianceResourceType = jsonValue.GetString("ComplianceResourceType"); m_complianceResourceTypeHasBeenSet = true; } if(jsonValue.ValueExists("ComplianceResourceId")) { m_complianceResourceId = jsonValue.GetString("ComplianceResourceId"); m_complianceResourceIdHasBeenSet = true; } if(jsonValue.ValueExists("ComplianceType")) { m_complianceType = ComplianceTypeMapper::GetComplianceTypeForName(jsonValue.GetString("ComplianceType")); m_complianceTypeHasBeenSet = true; } if(jsonValue.ValueExists("Annotation")) { m_annotation = jsonValue.GetString("Annotation"); m_annotationHasBeenSet = true; } if(jsonValue.ValueExists("OrderingTimestamp")) { m_orderingTimestamp = jsonValue.GetDouble("OrderingTimestamp"); m_orderingTimestampHasBeenSet = true; } return *this; } JsonValue Evaluation::Jsonize() const { JsonValue payload; if(m_complianceResourceTypeHasBeenSet) { payload.WithString("ComplianceResourceType", m_complianceResourceType); } if(m_complianceResourceIdHasBeenSet) { payload.WithString("ComplianceResourceId", m_complianceResourceId); } if(m_complianceTypeHasBeenSet) { payload.WithString("ComplianceType", ComplianceTypeMapper::GetNameForComplianceType(m_complianceType)); } if(m_annotationHasBeenSet) { payload.WithString("Annotation", m_annotation); } if(m_orderingTimestampHasBeenSet) { payload.WithDouble("OrderingTimestamp", m_orderingTimestamp.SecondsWithMSPrecision()); } return payload; } } // namespace Model } // namespace ConfigService } // namespace Aws
[ "henso@amazon.com" ]
henso@amazon.com
0ea5fdd771e04fa0d24d8dee4e4d570f130e2667
0014fb5ce4aa3a6f460128bb646a3c3cfe81eb9e
/testdata/15/10/src/node7.cpp
8d9a2e2f638fda566113954b7b7688ccbe109029
[]
no_license
yps158/randomGraph
c1fa9c531b11bb935d112d1c9e510b5c02921df2
68f9e2e5b0bed1f04095642ee6924a68c0768f0c
refs/heads/master
2021-09-05T05:32:45.210171
2018-01-24T11:23:06
2018-01-24T11:23:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,428
cpp
#include "ros/ros.h" #include "std_msgs/String.h" #include "unistd.h" #include <sstream> #include <random> std::random_device rd; std::mt19937 gen(rd()); std::normal_distribution<> d(0.028334, 0.005); class Node7{ public: Node7(){ sub_2_7_flag = 0; sub_2_7 = n.subscribe("topic_2_7", 1, &Node7::middlemanCallback2,this); sub_3_7_flag = 0; sub_3_7 = n.subscribe("topic_3_7", 1, &Node7::middlemanCallback3,this); sub_4_7_flag = 0; sub_4_7 = n.subscribe("topic_4_7", 1, &Node7::middlemanCallback4,this); pub_7_11 = n.advertise<std_msgs::String>("topic_7_11", 1); pub_7_8 = n.advertise<std_msgs::String>("topic_7_8", 1); } void middlemanCallback2(const std_msgs::String::ConstPtr& msg){ if(sub_3_7_flag == 1 && sub_4_7_flag == 1 && true){ usleep(d(gen)*1000000); ROS_INFO("I'm node7 last from node2, intercepted: [%s]", msg->data.c_str()); pub_7_11.publish(msg); pub_7_8.publish(msg); sub_3_7_flag = 0; sub_4_7_flag = 0; } else{ ROS_INFO("I'm node7, from node2 intercepted: [%s]", msg->data.c_str()); sub_2_7_flag = 1; } } void middlemanCallback3(const std_msgs::String::ConstPtr& msg){ if(sub_2_7_flag == 1 && sub_4_7_flag == 1 && true){ usleep(d(gen)*1000000); ROS_INFO("I'm node7 last from node3, intercepted: [%s]", msg->data.c_str()); pub_7_11.publish(msg); pub_7_8.publish(msg); sub_2_7_flag = 0; sub_4_7_flag = 0; } else{ ROS_INFO("I'm node7, from node3 intercepted: [%s]", msg->data.c_str()); sub_3_7_flag = 1; } } void middlemanCallback4(const std_msgs::String::ConstPtr& msg){ if(sub_2_7_flag == 1 && sub_3_7_flag == 1 && true){ usleep(d(gen)*1000000); ROS_INFO("I'm node7 last from node4, intercepted: [%s]", msg->data.c_str()); pub_7_11.publish(msg); pub_7_8.publish(msg); sub_2_7_flag = 0; sub_3_7_flag = 0; } else{ ROS_INFO("I'm node7, from node4 intercepted: [%s]", msg->data.c_str()); sub_4_7_flag = 1; } } private: ros::NodeHandle n; ros::Publisher pub_7_11; ros::Publisher pub_7_8; int sub_2_7_flag; ros::Subscriber sub_2_7; int sub_3_7_flag; ros::Subscriber sub_3_7; int sub_4_7_flag; ros::Subscriber sub_4_7; }; int main(int argc, char **argv){ ros::init(argc, argv, "node7"); Node7 node7; ros::spin(); return 0; }
[ "sasaki@thinkingreed.co.jp" ]
sasaki@thinkingreed.co.jp
85d9242ca1dcf96409fabdb2c8110d62fd786032
90d253b075c47054ab1d6bf6206f37e810330068
/CALICO/2022_fall/3/3.cpp
a5b2dde8de7ea39a02e8b1aca015251f4123283f
[ "MIT" ]
permissive
eyangch/competitive-programming
45684aa804cbcde1999010332627228ac1ac4ef8
de9bb192c604a3dfbdd4c2757e478e7265516c9c
refs/heads/master
2023-07-10T08:59:25.674500
2023-06-25T09:30:43
2023-06-25T09:30:43
178,763,969
22
8
null
null
null
null
UTF-8
C++
false
false
523
cpp
#include <bits/stdc++.h> #define endl '\n' #define eat cin #define moo cout #define int long long using namespace std; int T, W, O, B, OW, BO, BW; int cost(int x, int y, int a, int b){ return x * a + y * b; } int32_t main(){ eat.tie(0) -> sync_with_stdio(0); eat >> T; while(T--){ eat >> W >> O >> B >> OW >> BO >> BW; OW = min(OW, BO + BW); BO = min(BO, OW + BW); BW = min(BW, OW + BO); int ans = 1e15; ans = min({cost(O, B, OW, BW), cost(W, O, BW, BO), cost(W, B, OW, BO)}); moo << ans << endl; } }
[ "eyangch@gmail.com" ]
eyangch@gmail.com
e2c02fe03755ac463b5257b979b3702d7336ae24
d14ffa7a58ac5f6661ba8dc9503ed7340aad017f
/jetpack/src/codegen/NodeTraverser.h
ebfd48c2b52dc6d9ecf1c8afd5a1ec4b00385dd8
[ "MIT" ]
permissive
prpr2012/jetpack.js
59e4dd510f743d3a100b27b4ad0b514bd63217d4
3ec5fdf9e423539ec57217753735423e5ac23666
refs/heads/master
2023-09-02T17:56:40.316795
2021-11-23T02:46:24
2021-11-23T02:48:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,333
h
/* Generated by Ruby Script! */ #pragma once #include "parser/SyntaxNodes.h" namespace jetpack { class NodeTraverser { public: NodeTraverser() = default; void TraverseNode(SyntaxNode& node); virtual void Traverse(ArrayExpression& node) {} virtual void Traverse(ArrayPattern& node) {} virtual void Traverse(ArrowFunctionExpression& node) {} virtual void Traverse(AssignmentExpression& node) {} virtual void Traverse(AssignmentPattern& node) {} virtual void Traverse(AwaitExpression& node) {} virtual void Traverse(BinaryExpression& node) {} virtual void Traverse(BlockStatement& node) {} virtual void Traverse(BreakStatement& node) {} virtual void Traverse(CallExpression& node) {} virtual void Traverse(CatchClause& node) {} virtual void Traverse(ClassBody& node) {} virtual void Traverse(ClassDeclaration& node) {} virtual void Traverse(ClassExpression& node) {} virtual void Traverse(ConditionalExpression& node) {} virtual void Traverse(ContinueStatement& node) {} virtual void Traverse(DebuggerStatement& node) {} virtual void Traverse(Directive& node) {} virtual void Traverse(DoWhileStatement& node) {} virtual void Traverse(EmptyStatement& node) {} virtual void Traverse(ExportAllDeclaration& node) {} virtual void Traverse(ExportDefaultDeclaration& node) {} virtual void Traverse(ExportNamedDeclaration& node) {} virtual void Traverse(ExportSpecifier& node) {} virtual void Traverse(ExpressionStatement& node) {} virtual void Traverse(ForInStatement& node) {} virtual void Traverse(ForOfStatement& node) {} virtual void Traverse(ForStatement& node) {} virtual void Traverse(FunctionDeclaration& node) {} virtual void Traverse(FunctionExpression& node) {} virtual void Traverse(Identifier& node) {} virtual void Traverse(IfStatement& node) {} virtual void Traverse(Import& node) {} virtual void Traverse(ImportDeclaration& node) {} virtual void Traverse(ImportDefaultSpecifier& node) {} virtual void Traverse(ImportNamespaceSpecifier& node) {} virtual void Traverse(ImportSpecifier& node) {} virtual void Traverse(LabeledStatement& node) {} virtual void Traverse(Literal& node) {} virtual void Traverse(MetaProperty& node) {} virtual void Traverse(MethodDefinition& node) {} virtual void Traverse(Module& node) {} virtual void Traverse(NewExpression& node) {} virtual void Traverse(ObjectExpression& node) {} virtual void Traverse(ObjectPattern& node) {} virtual void Traverse(Property& node) {} virtual void Traverse(RegexLiteral& node) {} virtual void Traverse(RestElement& node) {} virtual void Traverse(ReturnStatement& node) {} virtual void Traverse(Script& node) {} virtual void Traverse(SequenceExpression& node) {} virtual void Traverse(SpreadElement& node) {} virtual void Traverse(MemberExpression& node) {} virtual void Traverse(Super& node) {} virtual void Traverse(SwitchCase& node) {} virtual void Traverse(SwitchStatement& node) {} virtual void Traverse(TaggedTemplateExpression& node) {} virtual void Traverse(TemplateElement& node) {} virtual void Traverse(TemplateLiteral& node) {} virtual void Traverse(ThisExpression& node) {} virtual void Traverse(ThrowStatement& node) {} virtual void Traverse(TryStatement& node) {} virtual void Traverse(UnaryExpression& node) {} virtual void Traverse(UpdateExpression& node) {} virtual void Traverse(VariableDeclaration& node) {} virtual void Traverse(VariableDeclarator& node) {} virtual void Traverse(WhileStatement& node) {} virtual void Traverse(WithStatement& node) {} virtual void Traverse(YieldExpression& node) {} virtual void Traverse(ArrowParameterPlaceHolder& node) {} virtual void Traverse(JSXClosingElement& node) {} virtual void Traverse(JSXElement& node) {} virtual void Traverse(JSXEmptyExpression& node) {} virtual void Traverse(JSXExpressionContainer& node) {} virtual void Traverse(JSXIdentifier& node) {} virtual void Traverse(JSXMemberExpression& node) {} virtual void Traverse(JSXAttribute& node) {} virtual void Traverse(JSXNamespacedName& node) {} virtual void Traverse(JSXOpeningElement& node) {} virtual void Traverse(JSXSpreadAttribute& node) {} virtual void Traverse(JSXText& node) {} virtual void Traverse(TSParameterProperty& node) {} virtual void Traverse(TSDeclareFunction& node) {} virtual void Traverse(TSDeclareMethod& node) {} virtual void Traverse(TSQualifiedName& node) {} virtual void Traverse(TSCallSignatureDeclaration& node) {} virtual void Traverse(TSConstructSignatureDeclaration& node) {} virtual void Traverse(TSPropertySignature& node) {} virtual void Traverse(TSMethodSignature& node) {} virtual void Traverse(TSIndexSignature& node) {} virtual void Traverse(TSAnyKeyword& node) {} virtual void Traverse(TSBooleanKeyword& node) {} virtual void Traverse(TSBigIntKeyword& node) {} virtual void Traverse(TSNeverKeyword& node) {} virtual void Traverse(TSNullKeyword& node) {} virtual void Traverse(TSNumberKeyword& node) {} virtual void Traverse(TSObjectKeyword& node) {} virtual void Traverse(TSStringKeyword& node) {} virtual void Traverse(TSSymbolKeyword& node) {} virtual void Traverse(TSUndefinedKeyword& node) {} virtual void Traverse(TSUnknownKeyword& node) {} virtual void Traverse(TSVoidKeyword& node) {} virtual void Traverse(TSThisType& node) {} virtual void Traverse(TSFunctionType& node) {} virtual void Traverse(TSConstructorType& node) {} virtual void Traverse(TSTypeReference& node) {} virtual void Traverse(TSTypePredicate& node) {} virtual void Traverse(TSTypeQuery& node) {} virtual void Traverse(TSTypeLiteral& node) {} virtual void Traverse(TSArrayType& node) {} virtual void Traverse(TSTupleType& node) {} virtual void Traverse(TSOptionalType& node) {} virtual void Traverse(TSRestType& node) {} virtual void Traverse(TSUnionType& node) {} virtual void Traverse(TSIntersectionType& node) {} virtual void Traverse(TSConditionalType& node) {} virtual void Traverse(TSInferType& node) {} virtual void Traverse(TSParenthesizedType& node) {} virtual void Traverse(TSTypeOperator& node) {} virtual void Traverse(TSIndexedAccessType& node) {} virtual void Traverse(TSMappedType& node) {} virtual void Traverse(TSLiteralType& node) {} virtual void Traverse(TSExpressionWithTypeArguments& node) {} virtual void Traverse(TSInterfaceDeclaration& node) {} virtual void Traverse(TSInterfaceBody& node) {} virtual void Traverse(TSTypeAliasDeclaration& node) {} virtual void Traverse(TSAsExpression& node) {} virtual void Traverse(TSTypeAssertion& node) {} virtual void Traverse(TSEnumDeclaration& node) {} virtual void Traverse(TSEnumMember& node) {} virtual void Traverse(TSModuleDeclaration& node) {} virtual void Traverse(TSModuleBlock& node) {} virtual void Traverse(TSImportType& node) {} virtual void Traverse(TSImportEqualsDeclaration& node) {} virtual void Traverse(TSExternalModuleReference& node) {} virtual void Traverse(TSNonNullExpression& node) {} virtual void Traverse(TSExportAssignment& node) {} virtual void Traverse(TSNamespaceExportDeclaration& node) {} virtual void Traverse(TSTypeAnnotation& node) {} virtual void Traverse(TSTypeParameterInstantiation& node) {} virtual void Traverse(TSTypeParameterDeclaration& node) {} virtual void Traverse(TSTypeParameter& node) {} virtual ~NodeTraverser() = default; }; }
[ "okcdz@diverse.space" ]
okcdz@diverse.space
a03fa8627844de5c80f4b02aea05260c88fed54f
fd6ba461ff7746a5d152576930add08ebfcbb975
/tests/ErrorTests.cc
f1ae1fbf41abc4a91ac286c518c1a3f1329807ec
[ "Zlib" ]
permissive
rbdl/rbdl
658d3b07e420642dd9c9b1106daff24fd43e526f
cbd9371ce822eeea1f0a880d57f71a4c60bc9b8a
refs/heads/master
2023-07-06T02:54:35.529726
2023-06-25T11:11:42
2023-06-25T11:11:42
208,891,294
449
141
NOASSERTION
2023-09-13T16:09:26
2019-09-16T20:24:46
C++
UTF-8
C++
false
false
3,179
cc
#include "rbdl/Logging.h" #include "rbdl/rbdl_errors.h" #include <iostream> #include <exception> #include "rbdl_tests.h" using namespace RigidBodyDynamics::Errors; // Test if each error type can be catched by Base Class TEST_CASE ( __FILE__"_BaseClassCatch", "" ) { //RBDLError try { throw RBDLError("Test RBDLError"); } catch (RBDLError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } //RBDLInvalidParameterError try { throw RBDLInvalidParameterError("Test RBDLInvalidParameterError"); } catch (RBDLError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } //RBDLSizeMismatchError try { throw RBDLSizeMismatchError("Test RBDLSizeMismatchError"); } catch (RBDLError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } //RBDLDofMismatchError try { throw RBDLDofMismatchError("Test RBDLDofMismatchError"); } catch (RBDLError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } //RBDLMissingImplementationError try { throw RBDLMissingImplementationError("Test RBDLMissingImplementationError"); } catch (RBDLError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } //RBDLInvalidFileError try { throw RBDLInvalidFileError("Test RBDLInvalidFileError"); } catch (RBDLError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } //RBDLFileParseError try { throw RBDLFileParseError("Test RBDLFileParseError"); } catch (RBDLFileParseError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } } // Tests to check catching each error type TEST_CASE (__FILE__"_RBDLInvalidParameterErrorTest", "" ) { try { throw RBDLInvalidParameterError("Test RBDLInvalidParameterError"); } catch (RBDLInvalidParameterError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } } TEST_CASE (__FILE__"_RBDLSizeMismatchErrorTest", "" ) { try { throw RBDLSizeMismatchError("Test RBDLSizeMismatchError"); } catch (RBDLSizeMismatchError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } } TEST_CASE (__FILE__"_RBDLDofMismatchErrorTest", "" ) { try { throw RBDLDofMismatchError("Test RBDLDofMismatchError"); } catch (RBDLDofMismatchError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } } TEST_CASE (__FILE__"_RBDLMissingImplementationErrorTest", "") { try { throw RBDLMissingImplementationError("Test RBDLMissingImplementationError"); } catch (RBDLMissingImplementationError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } } TEST_CASE (__FILE__"_RBDLInvalidFileErrorTest", "") { try { throw RBDLInvalidFileError("Test RBDLInvalidFileError"); } catch (RBDLInvalidFileError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } } TEST_CASE (__FILE__"_RBDLFileParseErrorTest", "" ) { try { throw RBDLFileParseError("Test RBDLFileParseError"); } catch (RBDLFileParseError &err) { CHECK(true); } catch (std::exception &e) { CHECK(false); } }
[ "judge@felixrichter.tech" ]
judge@felixrichter.tech
4c75a64c9a7e1efe791b20d23c72c3981f5f78f6
0428c3b8086f12ebbc6de7967ee4437934e2146d
/device/src/tsc2046_interface.cpp
ed7ea5e343a462c7e1332980e4a6aa4fa133fcd1
[]
no_license
cornway/stm32f4-dcmi-probe
e5cf112f83b09ea0d4af23660c12e78b101504e6
9cc677bdb092949d1212ec1fc831b7db3e485fbd
refs/heads/master
2020-04-28T03:16:52.112141
2019-03-11T05:23:51
2019-03-11T05:23:51
174,930,315
2
0
null
null
null
null
UTF-8
C++
false
false
2,530
cpp
#include "tsc2046.h" #include "main.h" #include "gpio.h" gpio::gpio_dsc tsc_busy_pin_dsc = {GPIOD, GPIO_PIN_3}; gpio::gpio_dsc tsc_pen_pin_dsc = {GPIOD, GPIO_PIN_2}; gpio::gpio_dsc tsc_sel_pin_dsc = {GPIOG, GPIO_PIN_15}; void tsc2046Drv::ll_init (bool it_ena) { __GPIOD_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); gpio::init(tsc_busy_pin_dsc, GPIO_MODE_INPUT, GPIO_PULLUP, GPIO_SPEED_HIGH); gpio::init(tsc_sel_pin_dsc, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_HIGH); gpio::init(tsc_pen_pin_dsc, GPIO_MODE_IT_FALLING, GPIO_PULLUP, GPIO_SPEED_HIGH); if (it_ena) { HAL_NVIC_SetPriority(EXTI2_IRQn, 2, 0); HAL_NVIC_EnableIRQ(EXTI2_IRQn); } } void tsc2046Drv::ll_sel (bool sel) { gpio::pin_set(tsc_sel_pin_dsc, sel); } bool tsc2046Drv::ll_busy () { return gpio::pin_read(tsc_busy_pin_dsc); } uint8_t tsc2046Drv::ll_rw (uint8_t data) { while ((SPI1->SR & SPI_FLAG_TXE) == 0){} *(__IO uint8_t *)&SPI1->DR = data; while ((SPI1->SR & SPI_FLAG_RXNE) == 0){} return *(__IO uint8_t *)&SPI1->DR; } #include "fgpu.h" #include "gui.h" extern FontArray fontArray; static GuiEngine<color_t, range_t, COLOR_WHITE> *tsc2046_engine; static GContentPane<color_t, range_t, COLOR_WHITE> *tsc2046_pane; FG_Rect fgRect = {0, 0, TFT_WIDTH, TFT_HEIGHT}; int tsc2046_frame_buffer_open () { tsc2046_engine = new GuiEngine<color_t, range_t, COLOR_WHITE>(fontArray.font_mono, (color_t *)FRAME_MEMORY_BASE, 0, 0, TFT_WIDTH, TFT_HEIGHT); if (tsc2046_engine == nullptr) { return -1; } tsc2046_pane = tsc2046_engine->newContentPane(0, 0, TFT_WIDTH, TFT_HEIGHT); if (tsc2046_pane == nullptr) { delete tsc2046_engine; return -1; } return 0; } void tsc2046_frame_buffer_close () { delete tsc2046_engine; } void tsc2046_frame_buffer_safe_clear () { tsc2046_pane->fill(COLOR_WHITE); gpu_update(fgRect); gpu_wait(); } void tsc2046_frame_buffer_safe_circle_fill (int x, int y, int r) { Box<range_t> box = {(range_t)x, (range_t)y, (range_t)r, (range_t)r}; tsc2046_pane->getGraphic()->circleFilled(box, (float)r, COLOR_GREEN); gpu_update(fgRect); gpu_wait(); } void tsc2046_frame_buffer_safe_draw_string (char * str, int x, int y) { Box<range_t> box = {(range_t)x, (range_t)y, TFT_WIDTH, 30}; tsc2046_pane->getGraphic()->drawString(box, str, 0xf800); gpu_update(fgRect); gpu_wait(); }
[ "romanpustobayev@gmail.com" ]
romanpustobayev@gmail.com
805772a50fe73e2a29788c2b33618ccc4c4b2fb1
a8dead89e139e09733d559175293a5d3b2aef56c
/external/include/ogremain/OgreRenderQueueSortingGrouping.h
62c84abb1eff3924b9b65f7c7e3a8e35091622bb
[ "MIT" ]
permissive
riyanhax/Demi3D
4f3a48e6d76462a998b1b08935b37d8019815474
73e684168bd39b894f448779d41fab600ba9b150
refs/heads/master
2021-12-04T06:24:26.642316
2015-01-29T22:06:00
2015-01-29T22:06:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
25,347
h
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2014 Torus Knot Software Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ #ifndef __RenderQueueSortingGrouping_H__ #define __RenderQueueSortingGrouping_H__ // Precompiler options #include "OgrePrerequisites.h" #include "OgrePass.h" #include "OgreRadixSort.h" namespace Ogre { /** \addtogroup Core * @{ */ /** \addtogroup RenderSystem * @{ */ /** Struct associating a single Pass with a single Renderable. This is used to for objects sorted by depth and thus not grouped by pass. */ struct RenderablePass { /// Pointer to the Renderable details Renderable* renderable; /// Pointer to the Pass Pass* pass; RenderablePass(Renderable* rend, Pass* p) :renderable(rend), pass(p) {} }; /** Visitor interface for items in a QueuedRenderableCollection. @remarks Those wishing to iterate over the items in a QueuedRenderableCollection should implement this visitor pattern, since internal organisation of the collection depends on the sorting method in use. */ class _OgreExport QueuedRenderableVisitor { public: QueuedRenderableVisitor() {} virtual ~QueuedRenderableVisitor() {} /** Called when visiting a RenderablePass, i.e. items in a sorted collection where items are not grouped by pass. @remarks If this is called, neither of the other 2 visit methods will be called. */ virtual void visit(RenderablePass* rp) = 0; /* When visiting a collection grouped by pass, this is called when the grouping pass changes. @remarks If this method is called, the RenderablePass visit method will not be called for this collection. The Renderable visit method will be called for each item underneath the pass grouping level. @return True to continue, false to skip the Renderables underneath */ virtual bool visit(const Pass* p) = 0; /** Visit method called once per Renderable on a grouped collection. @remarks If this method is called, the RenderablePass visit method will not be called for this collection. */ virtual void visit(Renderable* r) = 0; }; /** Lowest level collection of renderables. @remarks To iterate over items in this collection, you must call the accept method and supply a QueuedRenderableVisitor. The order of the iteration, and whether that iteration is over a RenderablePass list or a 2-level grouped list which causes a visit call at the Pass level, and a call for each Renderable underneath. */ class _OgreExport QueuedRenderableCollection : public RenderQueueAlloc { public: /** Organisation modes required for this collection. @remarks This affects the internal placement of the items added to this collection; if only one type of sorting / grouping is to be required, then renderables can be stored only once, whilst if multiple types are going to be needed then internally there will be multiple organisations. Changing the organisation needs to be done when the collection is empty. */ enum OrganisationMode { /// Group by pass OM_PASS_GROUP = 1, /// Sort descending camera distance OM_SORT_DESCENDING = 2, /** Sort ascending camera distance Note value overlaps with descending since both use same sort */ OM_SORT_ASCENDING = 6 }; protected: /// Comparator to order pass groups struct PassGroupLess { bool _OgreExport operator()(const Pass* a, const Pass* b) const { // Sort by passHash, which is pass, then texture unit changes uint32 hasha = a->getHash(); uint32 hashb = b->getHash(); if (hasha == hashb) { // Must differentTransparentQueueItemLessiate by pointer incase 2 passes end up with the same hash return a < b; } else { return hasha < hashb; } } }; /// Comparator to order objects by descending camera distance struct DepthSortDescendingLess { const Camera* camera; DepthSortDescendingLess(const Camera* cam) : camera(cam) { } bool _OgreExport operator()(const RenderablePass& a, const RenderablePass& b) const { if (a.renderable == b.renderable) { // Same renderable, sort by pass hash return a.pass->getHash() < b.pass->getHash(); } else { // Different renderables, sort by depth Real adepth = a.renderable->getSquaredViewDepth(camera); Real bdepth = b.renderable->getSquaredViewDepth(camera); if (Math::RealEqual(adepth, bdepth)) { // Must return deterministic result, doesn't matter what return a.pass < b.pass; } else { // Sort DESCENDING by depth (i.e. far objects first) return (adepth > bdepth); } } } }; /** Vector of RenderablePass objects, this is built on the assumption that vectors only ever increase in size, so even if we do clear() the memory stays allocated, ie fast */ typedef vector<RenderablePass>::type RenderablePassList; typedef vector<Renderable*>::type RenderableList; /** Map of pass to renderable lists, this is a grouping by pass. */ typedef map<Pass*, RenderableList*, PassGroupLess>::type PassGroupRenderableMap; /// Functor for accessing sort value 1 for radix sort (Pass) struct RadixSortFunctorPass { uint32 operator()(const RenderablePass& p) const { return p.pass->getHash(); } }; /// Radix sorter for accessing sort value 1 (Pass) static RadixSort<RenderablePassList, RenderablePass, uint32> msRadixSorter1; /// Functor for descending sort value 2 for radix sort (distance) struct RadixSortFunctorDistance { const Camera* camera; RadixSortFunctorDistance(const Camera* cam) : camera(cam) { } float operator()(const RenderablePass& p) const { // Sort DESCENDING by depth (ie far objects first), use negative distance // here because radix sorter always dealing with accessing sort return static_cast<float>(- p.renderable->getSquaredViewDepth(camera)); } }; /// Radix sorter for sort value 2 (distance) static RadixSort<RenderablePassList, RenderablePass, float> msRadixSorter2; /// Bitmask of the organisation modes requested uint8 mOrganisationMode; /// Grouped PassGroupRenderableMap mGrouped; /// Sorted descending (can iterate backwards to get ascending) RenderablePassList mSortedDescending; /// Internal visitor implementation void acceptVisitorGrouped(QueuedRenderableVisitor* visitor) const; /// Internal visitor implementation void acceptVisitorDescending(QueuedRenderableVisitor* visitor) const; /// Internal visitor implementation void acceptVisitorAscending(QueuedRenderableVisitor* visitor) const; public: QueuedRenderableCollection(); ~QueuedRenderableCollection(); /// Empty the collection void clear(void); /** Remove the group entry (if any) for a given Pass. @remarks To be used when a pass is destroyed, such that any grouping level for it becomes useless. */ void removePassGroup(Pass* p); /** Reset the organisation modes required for this collection. @remarks You can only do this when the collection is empty. @see OrganisationMode */ void resetOrganisationModes(void) { mOrganisationMode = 0; } /** Add a required sorting / grouping mode to this collection when next used. @remarks You can only do this when the collection is empty. @see OrganisationMode */ void addOrganisationMode(OrganisationMode om) { mOrganisationMode |= om; } /// Add a renderable to the collection using a given pass void addRenderable(Pass* pass, Renderable* rend); /** Perform any sorting that is required on this collection. @param cam The camera */ void sort(const Camera* cam); /** Accept a visitor over the collection contents. @param visitor Visitor class which should be called back @param om The organisation mode which you want to iterate over. Note that this must have been included in an addOrganisationMode call before any renderables were added. */ void acceptVisitor(QueuedRenderableVisitor* visitor, OrganisationMode om) const; /** Merge renderable collection. */ void merge( const QueuedRenderableCollection& rhs ); }; /** Collection of renderables by priority. @remarks This class simply groups renderables for rendering. All the renderables contained in this class are destined for the same RenderQueueGroup (coarse groupings like those between the main scene and overlays) and have the same priority (fine groupings for detailed overlap control). @par This class can order solid renderables by a number of criteria; it can optimise them into groups based on pass to reduce render state changes, or can sort them by ascending or descending view depth. Transparent objects are always ordered by descending depth. @par To iterate over items in the collections held by this object you should retrieve the collection in use (e.g. solids, solids with no shadows, transparents) and use the accept() method, providing a class implementing QueuedRenderableVisitor. */ class _OgreExport RenderPriorityGroup : public RenderQueueAlloc { protected: /// Parent queue group RenderQueueGroup* mParent; bool mSplitPassesByLightingType; bool mSplitNoShadowPasses; bool mShadowCastersNotReceivers; /// Solid pass list, used when no shadows, modulative shadows, or ambient passes for additive QueuedRenderableCollection mSolidsBasic; /// Solid per-light pass list, used with additive shadows QueuedRenderableCollection mSolidsDiffuseSpecular; /// Solid decal (texture) pass list, used with additive shadows QueuedRenderableCollection mSolidsDecal; /// Solid pass list, used when shadows are enabled but shadow receive is turned off for these passes QueuedRenderableCollection mSolidsNoShadowReceive; /// Unsorted transparent list QueuedRenderableCollection mTransparentsUnsorted; /// Transparent list QueuedRenderableCollection mTransparents; /// remove a pass entry from all collections void removePassEntry(Pass* p); /// Internal method for adding a solid renderable void addSolidRenderable(Technique* pTech, Renderable* rend, bool toNoShadowMap); /// Internal method for adding a solid renderable void addSolidRenderableSplitByLightType(Technique* pTech, Renderable* rend); /// Internal method for adding an unsorted transparent renderable void addUnsortedTransparentRenderable(Technique* pTech, Renderable* rend); /// Internal method for adding a transparent renderable void addTransparentRenderable(Technique* pTech, Renderable* rend); public: RenderPriorityGroup(RenderQueueGroup* parent, bool splitPassesByLightingType, bool splitNoShadowPasses, bool shadowCastersNotReceivers); ~RenderPriorityGroup() { } /** Get the collection of basic solids currently queued, this includes all solids when there are no shadows, or all solids which have shadow receiving enabled when using modulative shadows, or all ambient passes of solids which have shadow receive enabled for additive shadows. */ const QueuedRenderableCollection& getSolidsBasic(void) const { return mSolidsBasic; } /** Get the collection of solids currently queued per light (only applicable in additive shadow modes). */ const QueuedRenderableCollection& getSolidsDiffuseSpecular(void) const { return mSolidsDiffuseSpecular; } /** Get the collection of solids currently queued for decal passes (only applicable in additive shadow modes). */ const QueuedRenderableCollection& getSolidsDecal(void) const { return mSolidsDecal; } /** Get the collection of solids for which shadow receipt is disabled (only applicable when shadows are enabled). */ const QueuedRenderableCollection& getSolidsNoShadowReceive(void) const { return mSolidsNoShadowReceive; } /** Get the collection of transparent objects currently queued */ const QueuedRenderableCollection& getTransparentsUnsorted(void) const { return mTransparentsUnsorted; } /** Get the collection of transparent objects currently queued */ const QueuedRenderableCollection& getTransparents(void) const { return mTransparents; } /** Reset the organisation modes required for the solids in this group. @remarks You can only do this when the group is empty, i.e. after clearing the queue. @see QueuedRenderableCollection::OrganisationMode */ void resetOrganisationModes(void); /** Add a required sorting / grouping mode for the solids in this group. @remarks You can only do this when the group is empty, i.e. after clearing the queue. @see QueuedRenderableCollection::OrganisationMode */ void addOrganisationMode(QueuedRenderableCollection::OrganisationMode om); /** Set the sorting / grouping mode for the solids in this group to the default. @remarks You can only do this when the group is empty, i.e. after clearing the queue. @see QueuedRenderableCollection::OrganisationMode */ void defaultOrganisationMode(void); /** Add a renderable to this group. */ void addRenderable(Renderable* pRend, Technique* pTech); /** Sorts the objects which have been added to the queue; transparent objects by their depth in relation to the passed in Camera. */ void sort(const Camera* cam); /** Clears this group of renderables. */ void clear(void); /** Sets whether or not the queue will split passes by their lighting type, ie ambient, per-light and decal. */ void setSplitPassesByLightingType(bool split) { mSplitPassesByLightingType = split; } /** Sets whether or not passes which have shadow receive disabled should be separated. */ void setSplitNoShadowPasses(bool split) { mSplitNoShadowPasses = split; } /** Sets whether or not objects which cast shadows should be treated as never receiving shadows. */ void setShadowCastersCannotBeReceivers(bool ind) { mShadowCastersNotReceivers = ind; } /** Merge group of renderables. */ void merge( const RenderPriorityGroup* rhs ); }; /** A grouping level underneath RenderQueue which groups renderables to be issued at coarsely the same time to the renderer. @remarks Each instance of this class itself hold RenderPriorityGroup instances, which are the groupings of renderables by priority for fine control of ordering (not required for most instances). */ class _OgreExport RenderQueueGroup : public RenderQueueAlloc { public: typedef map<ushort, RenderPriorityGroup*, std::less<ushort> >::type PriorityMap; typedef MapIterator<PriorityMap> PriorityMapIterator; typedef ConstMapIterator<PriorityMap> ConstPriorityMapIterator; protected: RenderQueue* mParent; bool mSplitPassesByLightingType; bool mSplitNoShadowPasses; bool mShadowCastersNotReceivers; /// Map of RenderPriorityGroup objects PriorityMap mPriorityGroups; /// Whether shadows are enabled for this queue bool mShadowsEnabled; /// Bitmask of the organisation modes requested (for new priority groups) uint8 mOrganisationMode; public: RenderQueueGroup(RenderQueue* parent, bool splitPassesByLightingType, bool splitNoShadowPasses, bool shadowCastersNotReceivers) : mParent(parent) , mSplitPassesByLightingType(splitPassesByLightingType) , mSplitNoShadowPasses(splitNoShadowPasses) , mShadowCastersNotReceivers(shadowCastersNotReceivers) , mShadowsEnabled(true) , mOrganisationMode(0) { } ~RenderQueueGroup() { // destroy contents now PriorityMap::iterator i; for (i = mPriorityGroups.begin(); i != mPriorityGroups.end(); ++i) { OGRE_DELETE i->second; } } /** Get an iterator for browsing through child contents. */ PriorityMapIterator getIterator(void) { return PriorityMapIterator(mPriorityGroups.begin(), mPriorityGroups.end()); } /** Get a const iterator for browsing through child contents. */ ConstPriorityMapIterator getIterator(void) const { return ConstPriorityMapIterator(mPriorityGroups.begin(), mPriorityGroups.end()); } /** Add a renderable to this group, with the given priority. */ void addRenderable(Renderable* pRend, Technique* pTech, ushort priority) { // Check if priority group is there PriorityMap::iterator i = mPriorityGroups.find(priority); RenderPriorityGroup* pPriorityGrp; if (i == mPriorityGroups.end()) { // Missing, create pPriorityGrp = OGRE_NEW RenderPriorityGroup(this, mSplitPassesByLightingType, mSplitNoShadowPasses, mShadowCastersNotReceivers); if (mOrganisationMode) { pPriorityGrp->resetOrganisationModes(); pPriorityGrp->addOrganisationMode((QueuedRenderableCollection::OrganisationMode)mOrganisationMode); } mPriorityGroups.insert(PriorityMap::value_type(priority, pPriorityGrp)); } else { pPriorityGrp = i->second; } // Add pPriorityGrp->addRenderable(pRend, pTech); } /** Clears this group of renderables. @param destroy If false, doesn't delete any priority groups, just empties them. Saves on memory deallocations since the chances are roughly the same kinds of renderables are going to be sent to the queue again next time. If true, completely destroys. */ void clear(bool destroy = false) { PriorityMap::iterator i, iend; iend = mPriorityGroups.end(); for (i = mPriorityGroups.begin(); i != iend; ++i) { if (destroy) OGRE_DELETE i->second; else i->second->clear(); } if (destroy) mPriorityGroups.clear(); } /** Indicate whether a given queue group will be doing any shadow setup. @remarks This method allows you to inform the queue about a queue group, and to indicate whether this group will require shadow processing of any sort. In order to preserve rendering order, OGRE has to treat queue groups as very separate elements of the scene, and this can result in it having to duplicate shadow setup for each group. Therefore, if you know that a group which you are using will never need shadows, you should preregister the group using this method in order to improve the performance. */ void setShadowsEnabled(bool enabled) { mShadowsEnabled = enabled; } /** Are shadows enabled for this queue? */ bool getShadowsEnabled(void) const { return mShadowsEnabled; } /** Sets whether or not the queue will split passes by their lighting type, ie ambient, per-light and decal. */ void setSplitPassesByLightingType(bool split) { mSplitPassesByLightingType = split; PriorityMap::iterator i, iend; iend = mPriorityGroups.end(); for (i = mPriorityGroups.begin(); i != iend; ++i) { i->second->setSplitPassesByLightingType(split); } } /** Sets whether or not the queue will split passes which have shadow receive turned off (in their parent material), which is needed when certain shadow techniques are used. */ void setSplitNoShadowPasses(bool split) { mSplitNoShadowPasses = split; PriorityMap::iterator i, iend; iend = mPriorityGroups.end(); for (i = mPriorityGroups.begin(); i != iend; ++i) { i->second->setSplitNoShadowPasses(split); } } /** Sets whether or not objects which cast shadows should be treated as never receiving shadows. */ void setShadowCastersCannotBeReceivers(bool ind) { mShadowCastersNotReceivers = ind; PriorityMap::iterator i, iend; iend = mPriorityGroups.end(); for (i = mPriorityGroups.begin(); i != iend; ++i) { i->second->setShadowCastersCannotBeReceivers(ind); } } /** Reset the organisation modes required for the solids in this group. @remarks You can only do this when the group is empty, ie after clearing the queue. @see QueuedRenderableCollection::OrganisationMode */ void resetOrganisationModes(void) { mOrganisationMode = 0; PriorityMap::iterator i, iend; iend = mPriorityGroups.end(); for (i = mPriorityGroups.begin(); i != iend; ++i) { i->second->resetOrganisationModes(); } } /** Add a required sorting / grouping mode for the solids in this group. @remarks You can only do this when the group is empty, ie after clearing the queue. @see QueuedRenderableCollection::OrganisationMode */ void addOrganisationMode(QueuedRenderableCollection::OrganisationMode om) { mOrganisationMode |= om; PriorityMap::iterator i, iend; iend = mPriorityGroups.end(); for (i = mPriorityGroups.begin(); i != iend; ++i) { i->second->addOrganisationMode(om); } } /** Setthe sorting / grouping mode for the solids in this group to the default. @remarks You can only do this when the group is empty, ie after clearing the queue. @see QueuedRenderableCollection::OrganisationMode */ void defaultOrganisationMode(void) { mOrganisationMode = 0; PriorityMap::iterator i, iend; iend = mPriorityGroups.end(); for (i = mPriorityGroups.begin(); i != iend; ++i) { i->second->defaultOrganisationMode(); } } /** Merge group of renderables. */ void merge( const RenderQueueGroup* rhs ) { ConstPriorityMapIterator it = rhs->getIterator(); while( it.hasMoreElements() ) { ushort priority = it.peekNextKey(); RenderPriorityGroup* pSrcPriorityGrp = it.getNext(); RenderPriorityGroup* pDstPriorityGrp; // Check if priority group is there PriorityMap::iterator i = mPriorityGroups.find(priority); if (i == mPriorityGroups.end()) { // Missing, create pDstPriorityGrp = OGRE_NEW RenderPriorityGroup(this, mSplitPassesByLightingType, mSplitNoShadowPasses, mShadowCastersNotReceivers); if (mOrganisationMode) { pDstPriorityGrp->resetOrganisationModes(); pDstPriorityGrp->addOrganisationMode((QueuedRenderableCollection::OrganisationMode)mOrganisationMode); } mPriorityGroups.insert(PriorityMap::value_type(priority, pDstPriorityGrp)); } else { pDstPriorityGrp = i->second; } // merge pDstPriorityGrp->merge( pSrcPriorityGrp ); } } }; /** @} */ /** @} */ } #endif
[ "demiwangya@gmail.com" ]
demiwangya@gmail.com
7cf91c0ca889bc477bb4303982479d57c50146a9
c238d370c8259897b8c3b95a12c81e4d8691de64
/src/rx/material/loader.h
4b3ea393f1bd9bfa0e8926497e7d11ff1c70b162
[ "MIT" ]
permissive
ttvd/rex
4f66966166c422b7c7c356e764bdff3fcf11e800
bfe49a11e255e7be9e739641924adad2fd82a861
refs/heads/main
2022-11-25T23:04:23.994615
2020-08-04T13:55:55
2020-08-04T13:55:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,591
h
#ifndef RX_MATERIAL_LOADER_H #define RX_MATERIAL_LOADER_H #include "rx/core/vector.h" #include "rx/core/map.h" #include "rx/math/transform.h" #include "rx/material/texture.h" namespace Rx { struct JSON; struct Stream; } namespace Rx::Material { struct Loader { RX_MARK_NO_COPY(Loader); Loader(Memory::Allocator& _allocator); Loader(Loader&& loader_); void operator=(Loader&& loader_); bool load(Stream* _stream); bool load(const String& _file_name); bool parse(const JSON& _definition); constexpr Memory::Allocator& allocator() const; Vector<Texture>&& textures(); String&& name(); bool alpha_test() const; bool has_alpha() const; bool no_compress() const; Float32 roughness() const; Float32 metalness() const; const Optional<Math::Transform>& transform() const &; private: template<typename... Ts> bool error(const char* _format, Ts&&... _arguments) const; template<typename... Ts> void log(Log::Level _level, const char* _format, Ts&&... _arguments) const; void write_log(Log::Level _level, String&& message_) const; bool parse_textures(const JSON& _textures); enum { k_alpha_test = 1 << 0, k_has_alpha = 1 << 1, k_no_compress = 1 << 2 }; Memory::Allocator* m_allocator; Vector<Texture> m_textures; String m_name; Uint32 m_flags; Float32 m_roughness; Float32 m_metalness; Optional<Math::Transform> m_transform; }; RX_HINT_FORCE_INLINE constexpr Memory::Allocator& Loader::allocator() const { return *m_allocator; } inline Vector<Texture>&& Loader::textures() { return Utility::move(m_textures); } inline String&& Loader::name() { return Utility::move(m_name); } inline bool Loader::alpha_test() const { return m_flags & k_alpha_test; } inline bool Loader::has_alpha() const { return m_flags & k_has_alpha; } inline bool Loader::no_compress() const { return m_flags & k_no_compress; } inline Float32 Loader::roughness() const { return m_roughness; } inline Float32 Loader::metalness() const { return m_metalness; } inline const Optional<Math::Transform>& Loader::transform() const & { return m_transform; } template<typename... Ts> inline bool Loader::error(const char* _format, Ts&&... _arguments) const { log(Log::Level::k_error, _format, Utility::forward<Ts>(_arguments)...); return false; } template<typename... Ts> inline void Loader::log(Log::Level _level, const char* _format, Ts&&... _arguments) const { write_log(_level, String::format(_format, Utility::forward<Ts>(_arguments)...)); } } // namespace rx::material #endif // RX_MATERIAL_LOADER_H
[ "weilercdale@gmail.com" ]
weilercdale@gmail.com
d8b2f741fbb626787fd10c3f6b95e6c0da0033d7
54d6f751947050ef6af93524901b2d2c84a9397d
/AnnService/inc/SSDServing/SelectHead_BKT/ParameterDefinitionList.h
63884a2f5e2f9fd46b2965bfa005860b72027464
[ "MIT" ]
permissive
raychorn/SPTAG
d3cae939bd9294dd4c68a6d37aefbcea4acc8a1d
c0354f0d743ff92bbeaeaa310b014212999c348f
refs/heads/master
2023-09-05T11:08:33.238527
2021-11-16T07:33:34
2021-11-16T07:33:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,668
h
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #ifdef DefineSelectHeadParameter // DefineSelectHeadParameter(VarName, VarType, DefaultValue, RepresentStr) DefineSelectHeadParameter(m_execute, bool, false, "isExecute") DefineSelectHeadParameter(m_iTreeNumber, int, 1, "TreeNumber") DefineSelectHeadParameter(m_iBKTKmeansK, int, 32, "BKTKmeansK") DefineSelectHeadParameter(m_iBKTLeafSize, int, 8, "BKTLeafSize") DefineSelectHeadParameter(m_iSamples, int, 1000, "SamplesNumber") DefineSelectHeadParameter(m_fBalanceFactor, float, -1.0F, "BKTLambdaFactor") DefineSelectHeadParameter(m_iNumberOfThreads, int, 4, "NumberOfThreads") DefineSelectHeadParameter(m_saveBKT, bool, false, "SaveBKT") DefineSelectHeadParameter(m_analyzeOnly, bool, false, "AnalyzeOnly") DefineSelectHeadParameter(m_calcStd, bool, false, "CalcStd") DefineSelectHeadParameter(m_selectDynamically, bool, true, "SelectDynamically") DefineSelectHeadParameter(m_noOutput, bool, false, "NoOutput") DefineSelectHeadParameter(m_selectThreshold, int, 6, "SelectThreshold") DefineSelectHeadParameter(m_splitFactor, int, 5, "SplitFactor") DefineSelectHeadParameter(m_splitThreshold, int, 25, "SplitThreshold") DefineSelectHeadParameter(m_maxRandomTryCount, int, 8, "SplitMaxTry") DefineSelectHeadParameter(m_ratio, double, 0.2, "Ratio") DefineSelectHeadParameter(m_headVectorCount, int, 0, "Count") DefineSelectHeadParameter(m_recursiveCheckSmallCluster, bool, true, "RecursiveCheckSmallCluster") DefineSelectHeadParameter(m_printSizeCount, bool, true, "PrintSizeCount") DefineSelectHeadParameter(m_selectType, std::string, "BKT", "SelectHeadType") #endif
[ "noreply@github.com" ]
raychorn.noreply@github.com
54d1379e178a242636fd23d2a3a0419b5b00a2af
20698f2460bc8a4d21442cc5d4eac8cca15c105a
/ElDorito/Source/Patches/Hf2pExperimental.cpp
38c7bf183c8bbde557efa491181538a5b311ebe2
[]
no_license
num0005/ElDorito
957318d00dba4c92c2696256700f4acfe48481ec
5c00f797b557dbe112472a20f236bbf5fcc16371
refs/heads/master
2020-12-02T08:09:35.602887
2017-07-08T19:52:56
2017-07-08T19:54:47
96,777,515
3
0
null
2017-07-10T12:56:59
2017-07-10T12:56:59
null
UTF-8
C++
false
false
7,094
cpp
#pragma once #include "Hf2pExperimental.hpp" #include "../Blam/BlamInput.hpp" #include "../Modules/ModuleSettings.hpp" #include "../Modules/ModuleServer.hpp" #include "../ElDorito.hpp" #include "../Patches/Ui.hpp" #include "../Patches/Core.hpp" #include "../Patches/Armor.hpp" #include "../Web/Ui/ScreenLayer.hpp" #include "../Web/Ui/WebTimer.hpp" #include "../ElDorito.hpp" #include "../Blam/BlamPlayers.hpp" #include "../Blam/BlamTime.hpp" namespace { void Hf2pInitHook(); void Hf2pShutdownHook(); void Hf2pTickHook(); void Hf2pLoadPreferencesHook(); void UI_StartMenuScreenWidget_OnDataItemSelectedHook(); void OnMapLoaded(const char *mapPath); } namespace Patches { void Hf2pExperimental::ApplyAll() { Hook(0x200630, Hf2pInitHook).Apply(); // we no longer have sound_config.ps Patch(0x04858, { 0x90, 0x90 }).Apply(); // skip over vfiles_plugin load Patch(0x010F1121, { 0xE9 }).Apply(); // skip anti-cheat, watermark, account stuff Patch(0x200732, { 0xEB }).Apply(); Hook(0x200790, Hf2pShutdownHook).Apply(); Hook(0x105F0D, Hf2pTickHook, HookFlags::IsCall).Apply(); Hook(0x10CB01, Hf2pLoadPreferencesHook, HookFlags::IsCall).Apply(); Hook(0x6F740E, UI_StartMenuScreenWidget_OnDataItemSelectedHook).Apply(); Patches::Core::OnMapLoaded(OnMapLoaded); } } namespace { using namespace Blam::Input; const auto UI_ScreenWidget_Close = (void(__thiscall *)(void *thisptr, int a2))(0x00AB2830); const auto UI_ScreenManager_GetScreenWidget = (void* (__thiscall *)(void *thisptr, int a2, uint32_t nameId))(0x00AAB550); const auto UI_ScreenManager_AnyActiveScreens = (bool(__thiscall *)(void *thisptr, int a2))(0x00AAA970); const auto UI_GetScreenManager = (void*(*)())(0x00AAD930); void Hf2pInitHook() { *(uint32_t*)0x50CCB3C = 0; *(uint32_t*)0x244ED28 = 0; // InitSoundSystem ((void(*)())(0x64E190))(); } void Hf2pShutdownHook() { // ShutdownSoundSystem ((void(*)())(0x652EE0))(); } void SystemMenu() { static auto IsMainMenu = (bool(*)())(0x531E90); if (IsMainMenu()) return; auto uiStartAction = Blam::Input::GetActionState(eGameActionUiStart); if (!(uiStartAction->Flags & eActionStateFlagsHandled) && uiStartAction->Ticks == 1) { auto screenManager = (void*)0x05260F34; if (!UI_ScreenManager_AnyActiveScreens(screenManager, 0)) { uiStartAction->Flags |= eActionStateFlagsHandled; Patches::Ui::ShowDialog(0x10084, 0, 4, 0x1000C); } } } int GetSecondsRemainingUntilPlayerSpawn() { auto playerIndex = Blam::Players::GetLocalPlayer(0); const auto player = Blam::Players::GetPlayers().Get(Blam::Players::GetLocalPlayer(0)); return player ? Pointer(player)(0x2CBC).Read<int32_t>() : 0; } void Hf2pTickHook() { static auto InPrematchState = (bool(*)(char state))(0x005523A0); static auto UpdatePreMatchCamera = (bool(*)())(0x72D580); static auto InitMpDirector = (void(*)())(0x0072D560); static auto IsMapLoading = (bool(*)())(0x005670E0); static auto IsMainMenu = (bool(*)())(0x00531E90); static auto s_MatchStarted = false; static auto s_TimerStarted = false; static auto s_TimerLastTicked = 0; auto secondsUntilPlayerSpawn = GetSecondsRemainingUntilPlayerSpawn(); // update pre-match camera if (InPrematchState(4)) { if (!s_TimerStarted && secondsUntilPlayerSpawn > 0) { s_TimerStarted = true; s_TimerLastTicked = Blam::Time::GetGameTicks(); Web::Ui::WebTimer::Start("startTimer", secondsUntilPlayerSpawn); } s_MatchStarted = UpdatePreMatchCamera(); } else if (s_MatchStarted) { InitMpDirector(); s_MatchStarted = false; } else { if (!s_TimerStarted && secondsUntilPlayerSpawn > 0) { s_TimerStarted = true; s_TimerLastTicked = Blam::Time::GetGameTicks(); Web::Ui::WebTimer::Start("respawnTimer", secondsUntilPlayerSpawn); } } if (s_TimerStarted) { static auto s_LastTimerValue = 0; auto secondsUntilSpawn = GetSecondsRemainingUntilPlayerSpawn(); if (secondsUntilSpawn != s_LastTimerValue) { s_LastTimerValue = secondsUntilSpawn; s_TimerLastTicked = Blam::Time::GetGameTicks(); Web::Ui::WebTimer::Update(secondsUntilSpawn); if (secondsUntilSpawn <= 0) { s_TimerStarted = false; Web::Ui::WebTimer::End(); } } // TODO: find a better game ended indication if (IsMapLoading()) { s_TimerStarted = false; Web::Ui::WebTimer::End(); } } if (!IsMapLoading()) { if (IsMainMenu()) { // armour customizations on mainmenu Patches::Armor::UpdateUiPlayerModelArmor(); } else { // pause menu SystemMenu(); } } } void CloseScreen(void* screenManager, uint32_t id) { const auto screen = UI_ScreenManager_GetScreenWidget(screenManager, 4, id); if (screen) UI_ScreenWidget_Close(screen, 0); } bool StartMenu_OnDataItemSelected(uint32_t nameId) { switch (nameId) { case 0x4055: // control_settings CloseScreen(UI_GetScreenManager(), 0x10084); Web::Ui::ScreenLayer::Show("settings", "{}"); return true; } return false; } __declspec(naked) void UI_StartMenuScreenWidget_OnDataItemSelectedHook() { __asm { push[ebp - 4] call StartMenu_OnDataItemSelected test al, al jz DEFAULT add esp, 4 xor eax, eax pop ebx mov esp, ebp pop ebp retn 0x10 DEFAULT: mov eax, 0xAF7436 jmp eax } } uint32_t LevelStringToInt(const std::string& value) { return value == "low" ? 0 : value == "medium" ? 1 : 2; } void Hf2pLoadPreferencesHook() { static auto Hf2pLoadPreferences = (void(*)())(0x50C830); Hf2pLoadPreferences(); auto preferencesPtr = ElDorito::GetMainTls(0x18)[0]; if (!preferencesPtr) return; auto& moduleSettings = Modules::ModuleSettings::Instance(); int screenResolutionWidth, screenResolutionHeight; moduleSettings.GetScreenResolution(&screenResolutionWidth, &screenResolutionHeight); // a step towards eliminating the need preferences.dat at least for settings preferencesPtr(0x41BCC).Write<uint32_t>(moduleSettings.VarFullscreen->ValueInt); preferencesPtr(0x41C50).Write<uint32_t>(moduleSettings.VarMasterVolume->ValueInt); preferencesPtr(0x41C58).Write<uint32_t>(moduleSettings.VarMusicVolume->ValueInt); preferencesPtr(0x41C54).Write<uint32_t>(moduleSettings.VarSfxVolume->ValueInt); preferencesPtr(0x41BE0).Write<uint32_t>(screenResolutionWidth); preferencesPtr(0x41BE4).Write<uint32_t>(screenResolutionHeight); } void OnMapLoaded(const char* map) { const auto soundSystemPtr = (uint8_t**)(0x018BC9C8); if (!soundSystemPtr) return; const auto& mapStr = std::string(map); const std::string mainmenu("mainmenu"); if (mapStr.length() >= mainmenu.length() && std::equal(mainmenu.rbegin(), mainmenu.rend(), mapStr.rbegin())) { // play main menu music from wigl static auto PlayMainMenuMusic = (void(__thiscall *)(void *thisptr))(0xAD5820); PlayMainMenuMusic((void*)0x5255A0C); // mute ambient sounds on the maim menu *(float*)((*soundSystemPtr) + 0x44) = 0.0f; } else { *(float*)((*soundSystemPtr) + 0x44) = 1.0f; } } }
[ "unk0x4@gmail.com" ]
unk0x4@gmail.com
aab973c0ab2e66dc98f2a15c25e86367777216ce
2292b0a79bbe8b37c244f3fe244e061fc85f9881
/threadsafe_deque.hpp
404f8ee6f6f86d0042cee537035b8d3b787dc5db
[]
no_license
kinglezhuang/threadsafe-stl-container
5701627893c9907a461be96bbd314f7cc7f1f9c4
942ac39a631f6a79e18deebfbe0ea699ecbf8c9d
refs/heads/master
2020-09-15T11:09:29.218556
2020-03-08T09:06:37
2020-03-08T09:06:37
223,429,368
1
0
null
null
null
null
UTF-8
C++
false
false
9,491
hpp
// // threadsafe_stack.hpp // stl_extension // // Created by Kingle Zhuang on 11/20/19. // Copyright © 2019 RingCentral. All rights reserved. // #pragma once #include <mutex> #include <deque> #include <memory> #include <utility> #include <algorithm> #include <functional> #include <shared_mutex> namespace std { template <typename _Tp, typename _Allocator = allocator<_Tp>> class threadsafe_deque { private: typedef std::deque<_Tp, _Allocator> __deque_type; mutable std::shared_timed_mutex __mutex_; __deque_type __internal_queue_; public: typedef _Tp value_type; typedef _Allocator allocator_type; typedef __deque_type deque_type; typedef typename __deque_type::reference reference; typedef typename __deque_type::const_reference const_reference; typedef typename __deque_type::size_type size_type; typedef typename __deque_type::difference_type difference_type; typedef typename __deque_type::pointer pointer; typedef typename __deque_type::const_pointer const_pointer; typedef typename __deque_type::iterator iterator; typedef typename __deque_type::const_iterator const_iterator; typedef typename __deque_type::reverse_iterator reverse_iterator; typedef typename __deque_type::const_reverse_iterator const_reverse_iterator; public: threadsafe_deque() : __internal_queue_() {} explicit threadsafe_deque(size_type __n) : __internal_queue_(__n) {} threadsafe_deque(size_type __n, const value_type& __v) : __internal_queue_(__n, __v) {} threadsafe_deque(const deque_type& __l) : __internal_queue_(__l) {} threadsafe_deque(deque_type&& __l) : __internal_queue_(std::move(__l)) {} threadsafe_deque(initializer_list<value_type> __il) : __internal_queue_(__il) {} template <class _InputIterator> threadsafe_deque(_InputIterator __f, _InputIterator __l) : __internal_queue_(__f, __l) {} threadsafe_deque(const threadsafe_deque&) = delete; threadsafe_deque& operator=(const threadsafe_deque&) = delete; threadsafe_deque(threadsafe_deque&&) = delete; threadsafe_deque& operator=(threadsafe_deque&&) = delete; public: template <class _InputIterator> void assign(_InputIterator __f, _InputIterator __l) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.assign(__f, __l); } void assign(size_type __n, const value_type& __v) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.assign(__n, __v); } void assign(initializer_list<value_type> __il) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.assign(__il); } bool empty() const { std::shared_lock<std::shared_timed_mutex> lock(__mutex_); return __internal_queue_.empty(); } size_type size() const { std::shared_lock<std::shared_timed_mutex> lock(__mutex_); return __internal_queue_.size(); } size_type max_size() const { std::shared_lock<std::shared_timed_mutex> lock(__mutex_); return __internal_queue_.max_size(); } void resize(size_type __n) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.resize(__n); } void resize(size_type __n, const value_type& __v) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.resize(__n, __v); } void shrink_to_fit() { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.shrink_to_fit(); } const value_type& front() { std::shared_lock<std::shared_timed_mutex> lock(__mutex_); return static_cast<const value_type&>(__internal_queue_.front()); } const value_type& back() { std::shared_lock<std::shared_timed_mutex> lock(__mutex_); return static_cast<const value_type&>(__internal_queue_.back()); } void push_front(const value_type& __v) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.push_front(__v); } void push_back(const value_type& __v) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.push_back(__v); } void pop_front() { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.pop_front(); } void pop_back() { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.pop_back(); } void clear() { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_.clear(); } const value_type& operator[](size_type __n) { std::shared_lock<std::shared_timed_mutex> lock(__mutex_); return __internal_queue_[__n]; } const value_type& at(size_type __n) { std::shared_lock<std::shared_timed_mutex> lock(__mutex_); return __internal_queue_.at(__n); } void set(size_type __n, const value_type& __v) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_[__n] = __v; } void operator=(const deque_type& __v) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_ = __v; } void operator=(initializer_list<deque_type> __il) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); __internal_queue_ = __il; } deque_type value() { std::shared_lock<std::shared_timed_mutex> lock(__mutex_); return __internal_queue_; } void erase(std::function<bool(const value_type&)> __comp) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); for (const_iterator it = __internal_queue_.begin(); it != __internal_queue_.end();) { if (__comp(*it)) { it = __internal_queue_.erase(it); } else { ++it; } } } template <typename _Predicate> std::pair<const value_type, bool> find_and_erase(_Predicate __pred) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); const_iterator it = std::find_if(__internal_queue_.begin(), __internal_queue_.end(), __pred); if (it != __internal_queue_.end()) { value_type r = *it; __internal_queue_.erase(it); return std::make_pair(r, true); } return std::make_pair(value_type(), false); } void insert(std::function<const_iterator(const deque_type&)> __pos, const value_type& __v) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); const_iterator pos = __pos(__internal_queue_); __internal_queue_.insert(pos, __v); } void insert(std::function<const_iterator(const deque_type&)> __pos, size_type __n, const value_type& __v) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); const_iterator pos = __pos(__internal_queue_); __internal_queue_.insert(pos, __n, __v); } template <class _InputIterator> void insert(std::function<const_iterator(const deque_type&)> __pos, _InputIterator __f, _InputIterator __l) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); const_iterator pos = __pos(__internal_queue_); __internal_queue_.insert(pos, __f, __l); } void insert(std::function<const_iterator(const deque_type&)> __pos, initializer_list<value_type> __il) { std::unique_lock<std::shared_timed_mutex> lock(__mutex_); const_iterator pos = __pos(__internal_queue_); __internal_queue_.insert(pos, __il); } void for_each(std::function<void(const value_type&)> __bl) { std::shared_lock<std::shared_timed_mutex> lock(__mutex_); for (const auto& v : __internal_queue_) { __bl(v); } } }; }
[ "noreply@github.com" ]
kinglezhuang.noreply@github.com
b7273eb3f0b33b01339f584e15ad96a9e602b51f
e20907553af94eb08b4422ac876c5862c214954c
/2 knapsack/cpp/solvers/greedy.hpp
3a3e4519ca30dc995f58ccf3419a8bf2afcd1a2c
[]
no_license
pooyad359/discrete-optim
74756e9fe923698716e95f4e4c4cbb12e8a38e30
cf848fde53951c651c12882ece3d1bb8146403bf
refs/heads/master
2023-07-08T18:01:16.668841
2021-08-15T09:27:37
2021-08-15T09:27:37
297,077,541
0
0
null
null
null
null
UTF-8
C++
false
false
344
hpp
#ifndef _GREEDY #define _GREEDY #include <vector> #include <algorithm> #include <iterator> #include <string> #include <sstream> #include <iostream> #include "../utils/utils.hpp" #include <stdlib.h> #include <random> #include <ctime> #include "../knapsack.hpp" using std::cout; using std::endl; std::vector<bool> greedySolver(Knapsack); #endif
[ "pooya.darvehei@gmail.com" ]
pooya.darvehei@gmail.com
d5abc0db8e03c630bea178123ab0013434141f2c
98157b3124db71ca0ffe4e77060f25503aa7617f
/codechef/sept16/chmtdv.cpp
dd718764d7fa3d37f947ab499b4264c3684933dc
[]
no_license
wiwitrifai/competitive-programming
c4130004cd32ae857a7a1e8d670484e236073741
f4b0044182f1d9280841c01e7eca4ad882875bca
refs/heads/master
2022-10-24T05:31:46.176752
2022-09-02T07:08:05
2022-09-02T07:08:35
59,357,984
37
4
null
null
null
null
UTF-8
C++
false
false
3,399
cpp
#include <bits/stdc++.h> using namespace std; const int N = 505; const long long inf = 1e9 * N * N + 5; int a[N][N], n, p; int h[N], v[N], ansh[N], ansv[N]; long long ans; long long sumh[N][N], sumv[N][N]; long long sum[N]; int main() { ans = 1e17; int t = 17; scanf("%d %d", &n, &p); p--; for (int i = 0; i < n; i++) { sumh[i][0] = 0; for (int j = 0; j < n; j++) { scanf("%d", a[i]+j); sumh[i][j+1] = sumh[i][j] + a[i][j]; } } for (int i = 0; i < n; i++) { sumv[0][i]; for (int j = 0; j < n; j++) { sumv[j+1][i] = sumv[j][i] + a[j][i]; } } for (int i = 0; i <= p; i++) h[i] = i+1; h[p] = n; v[p] = n; while (t--) { long long lo = 0, hi = inf; while (lo < hi) { long long mid = (lo + hi) >> 1; for (int i = 0; i <= p; i++) sum[i] = 0; int iv = 0; bool ok = true; for (int i = 0; i < n; i++) { bool reset = false; for (int j = 0; j <= p; j++) { sum[j] += sumh[i][h[j]] - sumh[i][j ? h[j-1] : 0]; if (sum[j] > mid) { reset = true; } } if (reset) { for (int j = 0; j <= p; j++) { sum[j] = sumh[i][h[j]] - sumh[i][j ? h[j-1] : 0]; if (sum[j] > mid) ok = false; } v[iv++] = i-1; } if (iv >= p) { ok = false; break; } } if (ok) hi = mid; else lo = mid + 1; } if (ans > lo) { cerr << lo << endl; ans = lo; for (int i = 0; i <= p; i++) { ansv[i] = v[i]; cerr << v[i] << " "; } for (int i = 0; i <= p; i++) { ansh[i] = h[i]; cerr << h[i] << " "; } cerr << endl; } cerr << lo << " "; lo = 0, hi = inf; while (lo < hi) { long long mid = (lo + hi) >> 1; for (int i = 0; i <= p; i++) sum[i] = 0; int ih = 0; bool ok = true; for (int i = 0; i < n; i++) { bool reset = false; for (int j = 0; j <= p; j++) { sum[j] += sumv[v[j]][i] - sumv[j ? v[j-1] : 0][i]; if (sum[j] > mid) { reset = true; } } if (reset) { for (int j = 0; j <= p; j++) { sum[j] = sumv[v[j]][i] - sumv[j ? v[j-1] : 0][i]; if (sum[j] > mid) ok = false; } h[ih++] = i-1; } if (ih >= p) { ok = false; break; } } if (ok) hi = mid; else lo = mid + 1; } cerr << lo << endl; if (ans > lo) { cerr << lo << endl; ans = lo; for (int i = 0; i <= p; i++) { ansv[i] = v[i]; cerr << v[i] << " "; } for (int i = 0; i <= p; i++) { ansh[i] = h[i]; cerr << h[i] << " "; } cerr << endl; } } memcpy(h, ansh, sizeof h); memcpy(v, ansv, sizeof v); h[0] = max(h[0], 1); v[0] = max(v[0], 1); for (int i = 1; i <= p; i++) { h[i] = max(h[i], h[i-1] + 1); v[i] = max(v[i], v[i-1] + 1); } h[p] = v[p] = n; for (int i = p-1; i >= 0; i--) { h[i] = min(h[i], h[i+1]-1); v[i] = min(v[i], v[i+1]-1); } for (int i = 0; i < p; i++) printf("%d ", h[i]); printf("\n"); for (int i = 0; i < p; i++) printf("%d ", v[i]); printf("\n"); return 0; }
[ "wiwitrifai@gmail.com" ]
wiwitrifai@gmail.com
edc38ccb935f6ce1e7f9350d388514807583e65e
fce86a5cb364e3c46a8a8009b1bc4f3441038156
/student.cpp
c6204a13fb4d66dd2a904e9d8b8b9250f13f8c21
[]
no_license
chenqing-xin/studentObject
ff1cfd97b769a80f8f41ae5f7f6a7b7c0fd089b1
86d6dc99c024ac118a5d45c236e0faa5721e5ecb
refs/heads/master
2023-05-22T19:14:46.958464
2021-06-02T16:11:15
2021-06-02T16:11:15
373,228,983
0
0
null
null
null
null
UTF-8
C++
false
false
243
cpp
#ifndef Student_H_ #define Student_H_ #include<string> class Student { private : String name; int age; int GPA; public : student(); Student(string n,int a,int G); ~Student(); string getName(); int getAge(); int getGPA(); }
[ "1506322647@qq.com" ]
1506322647@qq.com
f045c87f6cb90bf1927b4fb8bc1098ed7edc851d
ac227cc22d5f5364e5d029a2cef83816a6954590
/applications/physbam/physbam-lib/Public_Library/PhysBAM_Geometry/Grids_RLE_Interpolation_Collidable/LINEAR_INTERPOLATION_COLLIDABLE_CELL_RLE.h
246f100b03147f88d06ac65cb8a4068a65ef6ae4
[ "BSD-3-Clause" ]
permissive
schinmayee/nimbus
597185bc8bac91a2480466cebc8b337f5d96bd2e
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
refs/heads/master
2020-03-11T11:42:39.262834
2018-04-18T01:28:23
2018-04-18T01:28:23
129,976,755
0
0
BSD-3-Clause
2018-04-17T23:33:23
2018-04-17T23:33:23
null
UTF-8
C++
false
false
5,502
h
//##################################################################### // Copyright 2004-2005, Ron Fedkiw, Geoffrey Irving, Frank Losasso, Andrew Selle, Tamar Shinar. // This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt. //##################################################################### // Class LINEAR_INTERPOLATION_COLLIDABLE_RLE //##################################################################### #ifndef COMPILE_WITHOUT_RLE_SUPPORT #ifndef __LINEAR_INTERPOLATION_COLLIDABLE_CELL_RLE__ #define __LINEAR_INTERPOLATION_COLLIDABLE_CELL_RLE__ #include <PhysBAM_Tools/Interpolation/LINEAR_INTERPOLATION.h> #include <PhysBAM_Geometry/Grids_RLE_Collisions/GRID_BASED_COLLISION_GEOMETRY_RLE.h> namespace PhysBAM{ template<class T_GRID,class T2> class LINEAR_INTERPOLATION_COLLIDABLE_CELL_RLE:public INTERPOLATION_RLE<T_GRID,T2> { typedef typename T_GRID::VECTOR_T TV;typedef typename TV::SCALAR T;typedef typename T_GRID::BLOCK T_BLOCK; typedef typename COLLISION_GEOMETRY_COLLECTION_POLICY<T_GRID>::GRID_BASED_COLLISION_GEOMETRY T_GRID_BASED_COLLISION_GEOMETRY; typedef typename INTERPOLATION_POLICY<T_GRID>::LINEAR_INTERPOLATION_MAC_HELPER T_LINEAR_INTERPOLATION_MAC_HELPER; public: const T_GRID_BASED_COLLISION_GEOMETRY& body_list; const ARRAY<bool>* cell_valid_value_mask; T2 default_cell_replacement_value; bool extrapolate_to_invalid_cell_values; LINEAR_INTERPOLATION_RLE<T_GRID,T2> interpolation; LINEAR_INTERPOLATION_COLLIDABLE_CELL_RLE(const T_GRID_BASED_COLLISION_GEOMETRY& body_list_input,const ARRAY<bool>* cell_valid_value_mask_input,const T2& default_cell_replacement_value_input, const bool extrapolate_to_invalid_cell_values_input=true) :body_list(body_list_input),cell_valid_value_mask(cell_valid_value_mask_input),default_cell_replacement_value(default_cell_replacement_value_input), extrapolate_to_invalid_cell_values(extrapolate_to_invalid_cell_values_input) {} void Set_Default_Replacement_Value(const T2& default_cell_replacement_value_input) {default_cell_replacement_value=default_cell_replacement_value_input;} T2 From_Block_Cell(const T_BLOCK& block,const ARRAY<T2>& u,const TV& X) const PHYSBAM_OVERRIDE {bool interpolation_valid;return From_Block_Cell(block,u,X,interpolation_valid);} T2 From_Block_Cell(const T_BLOCK& block,const ARRAY<T2>& u,const TV& X,bool& interpolation_valid) const {assert(block.Inside(X)); if(!body_list.Occupied_Block(block)){interpolation_valid=true;return T_LINEAR_INTERPOLATION_MAC_HELPER::Interpolate_Cell(block,u,X);} COLLISION_GEOMETRY_ID body_id;int aggregate_id; if(body_list.Inside_Any_Simplex_Of_Any_Body(block,X,body_id,aggregate_id)) return Invalid_Value_Replacement(u,X,block,X,body_id,aggregate_id,interpolation_valid); int valid_mask=0;T2 values[T_GRID::number_of_cells_per_block]; for(int k=0;k<T_GRID::number_of_cells_per_block;k++) values[k]=Trace_And_Get_Value(block,u,X,k,valid_mask,1<<k); if(extrapolate_to_invalid_cell_values) Extrapolate_To_Invalid_Values(u,X,block,values,valid_mask); interpolation_valid=(valid_mask!=0); return LINEAR_INTERPOLATION<T,T2>::Linear(values,(X-block.Minimum_Corner())*block.grid.uniform_grid.one_over_dX);} protected: T2 Trace_And_Get_Value(const T_BLOCK& block,const ARRAY<T2>& u,const TV& X,const int cell_in_block,int& valid_mask,const int mask_value=0) const {TV intersection_point;COLLISION_GEOMETRY_ID body_id;int aggregate_id; assert(cell_valid_value_mask); int cell=block.Cell(cell_in_block); if(body_list.Cell_Center_Intersection(block,cell_in_block,X,body_id,aggregate_id,intersection_point) || !(*cell_valid_value_mask)(cell)) return default_cell_replacement_value; else{valid_mask|=mask_value;return u(cell);}} virtual T2 Invalid_Value_Replacement(const ARRAY<T2>& u,const TV& X,const T_BLOCK& block,const TV& intersection_point, const COLLISION_GEOMETRY_ID body_id,const int aggregate_id,bool& valid,const T ray_t_max=0) const {valid=false;return default_cell_replacement_value;} void Extrapolate_To_Invalid_Values(const ARRAY<T2>& u,const TV& X,const T_BLOCK& block,T2 values[T_GRID::number_of_cells_per_block],int& valid_mask) const {static const int all_valid_mask=(1<<T_GRID::number_of_cells_per_block)-1,neighbor_mask=T_GRID::number_of_cells_per_block-1; if(valid_mask==0) for(int t=0;t<T_GRID::number_of_cells_per_block;t++)values[t]=default_cell_replacement_value; else if(valid_mask!=all_valid_mask){ // not everything is valid for(int t=0;t<T_GRID::number_of_cells_per_block;t++)if(!(valid_mask&(1<<t))){ int ring; for(ring=1;ring<T_GRID::dimension;ring++){ // one ring in 2d, one and then two ring in 3d int ring_mask=ring==2?neighbor_mask:0; T2 sum=T2();int count=0; for(int n=0;n<T_GRID::dimension;n++){ int neighbor=t^(1<<n)^ring_mask; if(valid_mask&(1<<neighbor)){count++;sum+=values[neighbor];}} if(count>0){values[t]=sum/(T)count;break;}} // average valid ring neighbors if(ring==T_GRID::dimension) values[t]=values[t^neighbor_mask];} // final ring (must be valid because valid_mask!=0) valid_mask=all_valid_mask;}} //##################################################################### }; } #endif #endif
[ "quhang@stanford.edu" ]
quhang@stanford.edu
02321d0a6256c2f555951d0c03842bdc5f02d85a
e0f583d286706699da99bc631a31e3f4f2078965
/solutions/0773. Sliding Puzzle/0773.cpp
f079a0a0f87cfe05dc2b4a079c420c560c659029
[]
no_license
T353007/LeetCode-1
4f002d1885358e8beec0c3d59a1549c4c9f0e06d
026713cb8fa25f52851e1432cd71a5518504e3e0
refs/heads/main
2023-02-15T17:03:49.726291
2021-01-12T10:12:25
2021-01-12T10:12:25
328,920,320
0
0
null
2021-01-12T08:29:55
2021-01-12T08:29:55
null
UTF-8
C++
false
false
1,264
cpp
class Solution { public: int slidingPuzzle(vector<vector<int>>& board) { constexpr int m = 2; constexpr int n = 3; const vector<int> dirs{0, 1, 0, -1, 0}; const string goal = "123450"; int steps = 0; string start; // hash 2D vector to string for (int i = 0; i < m; ++i) for (int j = 0; j < n; ++j) start += '0' + board[i][j]; if (start == goal) return 0; queue<string> q{{start}}; unordered_set<string> seen{start}; while (!q.empty()) { ++steps; for (int size = q.size(); size > 0; --size) { string s = q.front(); q.pop(); const int zeroIndex = s.find('0'); const int i = zeroIndex / n; const int j = zeroIndex % n; for (int k = 0; k < 4; ++k) { const int x = i + dirs[k]; const int y = j + dirs[k + 1]; if (x < 0 || x == m || y < 0 || y == n) continue; const int swappedIndex = x * n + y; swap(s[zeroIndex], s[swappedIndex]); if (s == goal) return steps; if (!seen.count(s)) { q.push(s); seen.insert(s); } swap(s[zeroIndex], s[swappedIndex]); } } } return -1; } };
[ "walkccray@gmail.com" ]
walkccray@gmail.com
705c8c74b2ed612dfc5b282dfdd813ef54b1094a
aac6dfe8cb2e289b85aa2bbed56a47b29da59738
/src/SporadicServer.cpp
ca8ef2512504e0432fda4c1c5fe43342369295e3
[ "BSD-4-Clause-UC" ]
permissive
saulopz/rtsim
dfc589d173ed3b0edcb03a1b17b05f184dbcbd7c
fe506cf6015db40daf7c63b9d03883b491c4fb06
refs/heads/master
2023-05-23T09:04:42.977258
2021-06-08T21:53:03
2021-06-08T21:53:03
375,132,324
0
0
null
null
null
null
UTF-8
C++
false
false
217
cpp
#include "SporadicServer.h" SporadicServer::SporadicServer() { ThState = IDLE; TState = IDLE; state = SUSPENDED; BEGIN = 0; END = 0; tr = 0; tf = -1; te = 0; tb = 0; } SporadicServer::~SporadicServer() { }
[ "saulopz@gmail.com" ]
saulopz@gmail.com
aa9b1555fbe4b3079b3499e5409c00a1c27e1c41
d607fa153791e1c37e22e5ae4f3732cc329327ff
/src/CCondition.cpp
99ebe751c746444501a97575404360afe4d703c2
[]
no_license
qiubin2016/ThreadPool
e611c0b11d442e8b918178bdd75ca65ec9fc47a6
4ecb6960d2d29a30270259ae89a5720543a905a2
refs/heads/master
2020-03-21T00:34:26.061601
2018-06-19T17:17:43
2018-06-19T17:17:43
137,899,188
0
0
null
null
null
null
UTF-8
C++
false
false
1,012
cpp
/* * CCondition.cpp * * Created on: 2017年2月16日 * Author: qb */ #include "CCondition.h" CCondition::CCondition() { CondCreate(&m_Cond); } CCondition::~CCondition() { CondDestroy(&m_Cond); } void CCondition::Wait(CMutex &Mutex) { CondWait(&m_Cond, &Mutex.GetMutex()); } void CCondition::Wait(CMutex &Mutex, unsigned int uiMs) { struct timespec Tsp; maketimeout(&Tsp, uiMs); CondTimedWait(&m_Cond, &Mutex.GetMutex(), &Tsp); } void CCondition::Signal() { CondSignal(&m_Cond); } void CCondition::BroadCast() { CondBroadCast(&m_Cond); } void CCondition::maketimeout(struct timespec *pTsp, unsigned int ulMs) { struct timeval now; //get the current time gettimeofday(&now, NULL); // gettimeofday(&now); pTsp->tv_sec = now.tv_sec; //usec to nsec pTsp->tv_nsec = now.tv_usec * 1000; //add the offset to get timeout valude pTsp->tv_nsec += (ulMs % 1000) * 1000000L; pTsp->tv_sec += (ulMs / 1000) + (pTsp->tv_nsec / 1000000000L); pTsp->tv_nsec = pTsp->tv_nsec % 1000000000L; }
[ "cust@custVBOX.(none)" ]
cust@custVBOX.(none)
0e1125153b5c40b9fd4710301bdbcd6d9e9192a9
bc6c37cf0469c6b2778707b76227558b3a040718
/UVA/UVA-Q11413-Fill_the_Containers.cpp
67b137e4fadbb2e6c2823a879f9dc47d9fa3bb0a
[]
no_license
zeroplusone/AlgorithmPractice
241530a5c989f6321543f7bd07a393c405cdf2e6
7fe9182d943bc2066f7fd31cc05096be79dc12cb
refs/heads/master
2022-01-28T21:57:04.393943
2022-01-26T13:46:43
2022-01-26T13:46:43
84,074,414
2
1
null
null
null
null
UTF-8
C++
false
false
753
cpp
#include<iostream> #include<cstdlib> #include<cstdio> using namespace std; #define MAX 1010 long long int milk[MAX]; int n,m; bool canbe(int num) { long long int sum=0; int c=0; for(int i=0;i<n;++i) { if(sum<=num) sum+=milk[i]; else { sum=0; c++; } } if(c<=m) return true; else return false; } int main() { while(scanf("%d %d",&n,&m)!=EOF) { for(int i=0;i<n;++i) scanf("%lld",&milk[i]); long long int left=0,right=0; for(int i=0;i<n;++i) { right+=milk[i]; if(milk[i]>left) left=milk[i]; } int mid; do { mid=(left+right)/2; if(canbe(mid)) right=mid; else left=mid+1; }while(left<right); } return 0; }
[ "a711186@gmail.com" ]
a711186@gmail.com
0e63998fb56cf1e0c322a7022ce80906fbac61af
2cf838b54b556987cfc49f42935f8aa7563ea1f4
/aws-cpp-sdk-quicksight/include/aws/quicksight/model/UpdateDataSetPermissionsResult.h
004dff739191eaad0064de88293354ed59b78780
[ "MIT", "Apache-2.0", "JSON" ]
permissive
QPC-database/aws-sdk-cpp
d11e9f0ff6958c64e793c87a49f1e034813dac32
9f83105f7e07fe04380232981ab073c247d6fc85
refs/heads/main
2023-06-14T17:41:04.817304
2021-07-09T20:28:20
2021-07-09T20:28:20
384,714,703
1
0
Apache-2.0
2021-07-10T14:16:41
2021-07-10T14:16:41
null
UTF-8
C++
false
false
5,572
h
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/quicksight/QuickSight_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace QuickSight { namespace Model { class AWS_QUICKSIGHT_API UpdateDataSetPermissionsResult { public: UpdateDataSetPermissionsResult(); UpdateDataSetPermissionsResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); UpdateDataSetPermissionsResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); /** * <p>The Amazon Resource Name (ARN) of the dataset.</p> */ inline const Aws::String& GetDataSetArn() const{ return m_dataSetArn; } /** * <p>The Amazon Resource Name (ARN) of the dataset.</p> */ inline void SetDataSetArn(const Aws::String& value) { m_dataSetArn = value; } /** * <p>The Amazon Resource Name (ARN) of the dataset.</p> */ inline void SetDataSetArn(Aws::String&& value) { m_dataSetArn = std::move(value); } /** * <p>The Amazon Resource Name (ARN) of the dataset.</p> */ inline void SetDataSetArn(const char* value) { m_dataSetArn.assign(value); } /** * <p>The Amazon Resource Name (ARN) of the dataset.</p> */ inline UpdateDataSetPermissionsResult& WithDataSetArn(const Aws::String& value) { SetDataSetArn(value); return *this;} /** * <p>The Amazon Resource Name (ARN) of the dataset.</p> */ inline UpdateDataSetPermissionsResult& WithDataSetArn(Aws::String&& value) { SetDataSetArn(std::move(value)); return *this;} /** * <p>The Amazon Resource Name (ARN) of the dataset.</p> */ inline UpdateDataSetPermissionsResult& WithDataSetArn(const char* value) { SetDataSetArn(value); return *this;} /** * <p>The ID for the dataset whose permissions you want to update. This ID is * unique per AWS Region for each AWS account.</p> */ inline const Aws::String& GetDataSetId() const{ return m_dataSetId; } /** * <p>The ID for the dataset whose permissions you want to update. This ID is * unique per AWS Region for each AWS account.</p> */ inline void SetDataSetId(const Aws::String& value) { m_dataSetId = value; } /** * <p>The ID for the dataset whose permissions you want to update. This ID is * unique per AWS Region for each AWS account.</p> */ inline void SetDataSetId(Aws::String&& value) { m_dataSetId = std::move(value); } /** * <p>The ID for the dataset whose permissions you want to update. This ID is * unique per AWS Region for each AWS account.</p> */ inline void SetDataSetId(const char* value) { m_dataSetId.assign(value); } /** * <p>The ID for the dataset whose permissions you want to update. This ID is * unique per AWS Region for each AWS account.</p> */ inline UpdateDataSetPermissionsResult& WithDataSetId(const Aws::String& value) { SetDataSetId(value); return *this;} /** * <p>The ID for the dataset whose permissions you want to update. This ID is * unique per AWS Region for each AWS account.</p> */ inline UpdateDataSetPermissionsResult& WithDataSetId(Aws::String&& value) { SetDataSetId(std::move(value)); return *this;} /** * <p>The ID for the dataset whose permissions you want to update. This ID is * unique per AWS Region for each AWS account.</p> */ inline UpdateDataSetPermissionsResult& WithDataSetId(const char* value) { SetDataSetId(value); return *this;} /** * <p>The AWS request ID for this operation.</p> */ inline const Aws::String& GetRequestId() const{ return m_requestId; } /** * <p>The AWS request ID for this operation.</p> */ inline void SetRequestId(const Aws::String& value) { m_requestId = value; } /** * <p>The AWS request ID for this operation.</p> */ inline void SetRequestId(Aws::String&& value) { m_requestId = std::move(value); } /** * <p>The AWS request ID for this operation.</p> */ inline void SetRequestId(const char* value) { m_requestId.assign(value); } /** * <p>The AWS request ID for this operation.</p> */ inline UpdateDataSetPermissionsResult& WithRequestId(const Aws::String& value) { SetRequestId(value); return *this;} /** * <p>The AWS request ID for this operation.</p> */ inline UpdateDataSetPermissionsResult& WithRequestId(Aws::String&& value) { SetRequestId(std::move(value)); return *this;} /** * <p>The AWS request ID for this operation.</p> */ inline UpdateDataSetPermissionsResult& WithRequestId(const char* value) { SetRequestId(value); return *this;} /** * <p>The HTTP status of the request.</p> */ inline int GetStatus() const{ return m_status; } /** * <p>The HTTP status of the request.</p> */ inline void SetStatus(int value) { m_status = value; } /** * <p>The HTTP status of the request.</p> */ inline UpdateDataSetPermissionsResult& WithStatus(int value) { SetStatus(value); return *this;} private: Aws::String m_dataSetArn; Aws::String m_dataSetId; Aws::String m_requestId; int m_status; }; } // namespace Model } // namespace QuickSight } // namespace Aws
[ "aws-sdk-cpp-automation@github.com" ]
aws-sdk-cpp-automation@github.com
cc46adbbddc0d30f0d9c0ac6541108aafee955fb
a6f42311df3830117e9590e446b105db78fdbd3a
/src/framework/gui/Window.hpp
4386fce6b57184b359ba1899e1e22aac488d6762
[]
no_license
wellsoftware/temporal-lightfield-reconstruction
a4009b9da01b93d6d77a4d0d6830c49e0d4e225f
8d0988b5660ba0e53d65e887a51e220dcbc985ca
refs/heads/master
2021-01-17T23:49:05.544012
2011-09-25T10:47:49
2011-09-25T10:47:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,902
hpp
/* * Copyright (c) 2009-2011, NVIDIA Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of NVIDIA Corporation nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include "base/Array.hpp" #include "base/String.hpp" #include "base/Math.hpp" #include "base/Hash.hpp" #include "gui/Keys.hpp" #include "base/DLLImports.hpp" #include "gpu/GLContext.hpp" namespace FW { //------------------------------------------------------------------------ class Window { public: //------------------------------------------------------------------------ enum EventType { EventType_AddListener, /* Listener has been added to a window. */ EventType_RemoveListener, /* Listener has been removed from a window. */ EventType_Close, /* User has tried to close the window. */ EventType_Resize, /* The window has been resized. */ EventType_KeyDown, /* User has pressed a key (or mouse button). */ EventType_KeyUp, /* User has released a key (or mouse button). */ EventType_Char, /* User has typed a character. */ EventType_Mouse, /* User has moved the mouse. */ EventType_Paint, /* Window contents need to be painted. */ EventType_PrePaint, /* Before processing EventType_Paint. */ EventType_PostPaint, /* After processing EventType_Paint. */ }; //------------------------------------------------------------------------ struct Event { EventType type; String key; /* Empty unless EventType_KeyDown or EventType_KeyUp. */ S32 keyUnicode; /* 0 unless EventType_KeyDown or EventType_KeyUp or if special key. */ S32 chr; /* Zero unless EventType_Text. */ bool mouseKnown; /* Unchanged unless EventType_Mouse. */ Vec2i mousePos; /* Unchanged unless EventType_Mouse. */ Vec2i mouseDelta; /* Zero unless EventType_Mouse. */ bool mouseDragging; /* One or more mouse buttons are down. */ Window* window; }; //------------------------------------------------------------------------ class Listener { public: Listener (void) {} virtual ~Listener (void) {} virtual bool handleEvent (const Event& ev) = 0; }; //------------------------------------------------------------------------ public: Window (void); ~Window (void); void setTitle (const String& title); void setSize (const Vec2i& size); Vec2i getSize (void) const; void setVisible (bool visible); bool isVisible (void) const { return m_isVisible; } void setFullScreen (bool isFull); bool isFullScreen (void) const { return m_isFullScreen; } void toggleFullScreen (void) { setFullScreen(!isFullScreen()); } void realize (void); void setGLConfig (const GLContext::Config& config); const GLContext::Config& getGLConfig (void) const { return m_glConfig; } GLContext* getGL (void); // also makes the context current void repaint (void); void repaintNow (void); void requestClose (void); void addListener (Listener* listener); void removeListener (Listener* listener); void removeListeners (void); bool isKeyDown (const String& key) const { return m_keysDown.contains(key); } bool isMouseKnown (void) const { return m_mouseKnown; } bool isMouseDragging (void) const { return (m_mouseDragCount != 0); } const Vec2i& getMousePos (void) const { return m_mousePos; } void showMessageDialog (const String& title, const String& text); String showFileDialog (const String& title, bool save, const String& filters = "", const String& initialDir = "", bool forceInitialDir = false); // filters = "ext:Title,foo;bar:Title" String showFileLoadDialog (const String& title, const String& filters = "", const String& initialDir = "", bool forceInitialDir = false) { return showFileDialog(title, false, filters, initialDir, forceInitialDir); } String showFileSaveDialog (const String& title, const String& filters = "", const String& initialDir = "", bool forceInitialDir = false) { return showFileDialog(title, true, filters, initialDir, forceInitialDir); } void showModalMessage (const String& msg); static void staticInit (void); static void staticDeinit (void); static HWND createHWND (void); static UPTR setWindowLong (HWND hwnd, int idx, UPTR value); static int getNumOpen (void) { return (s_inited) ? s_open->getSize() : 0; } static void realizeAll (void); static void pollMessages (void); private: Event createSimpleEvent (EventType type) { return createGenericEvent(type, "", 0, m_mouseKnown, m_mousePos); } Event createKeyEvent (bool down, const String& key) { return createGenericEvent((down) ? EventType_KeyDown : EventType_KeyUp, key, 0, m_mouseKnown, m_mousePos); } Event createCharEvent (S32 chr) { return createGenericEvent(EventType_Char, "", chr, m_mouseKnown, m_mousePos); } Event createMouseEvent (bool mouseKnown, const Vec2i& mousePos) { return createGenericEvent(EventType_Mouse, "", 0, mouseKnown, mousePos); } Event createGenericEvent (EventType type, const String& key, S32 chr, bool mouseKnown, const Vec2i& mousePos); void postEvent (const Event& ev); void create (void); void destroy (void); void recreate (void); static LRESULT CALLBACK staticWindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); LRESULT windowProc (UINT uMsg, WPARAM wParam, LPARAM lParam); private: Window (const Window&); // forbidden Window& operator= (const Window&); // forbidden private: static bool s_inited; static Array<Window*>* s_open; static bool s_ignoreRepaint; // Prevents re-entering repaintNow() on Win32 or OpenGL failure. HWND m_hwnd; HDC m_hdc; GLContext::Config m_glConfig; bool m_glConfigDirty; GLContext* m_gl; bool m_isRealized; bool m_isVisible; Array<Listener*> m_listeners; String m_title; bool m_isFullScreen; Vec2i m_pendingSize; DWORD m_origStyle; RECT m_origRect; Set<String> m_keysDown; bool m_pendingKeyFlush; bool m_mouseKnown; Vec2i m_mousePos; S32 m_mouseDragCount; S32 m_mouseWheelAcc; Vec2i m_prevSize; }; //------------------------------------------------------------------------ }
[ "jiawen@csail.mit.edu" ]
jiawen@csail.mit.edu
bd7fd36186b469d971926691f6e6e02c581cb4c6
584ca4da32b0e70a2702b5b16222d3d9475cd63a
/src/netfulfilledman.h
ada8bc07c78d28d517e5f9e0c30fc0a15060d869
[ "MIT" ]
permissive
IluminumProject/iluminum
d87e14cbeb0873fc7b1e42968cb039ecf2b4e03d
9685edf64161c66205c89ee72d711b0144733735
refs/heads/master
2020-03-10T08:55:36.095447
2018-04-21T15:56:18
2018-04-21T15:56:18
128,815,453
0
0
MIT
2018-04-12T07:00:53
2018-04-09T18:19:59
C++
UTF-8
C++
false
false
1,536
h
// Copyright (c) 2014-2017 The Iluminum Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef NETFULFILLEDMAN_H #define NETFULFILLEDMAN_H #include "netbase.h" #include "protocol.h" #include "serialize.h" #include "sync.h" class CNetFulfilledRequestManager; extern CNetFulfilledRequestManager netfulfilledman; // Fulfilled requests are used to prevent nodes from asking for the same data on sync // and from being banned for doing so too often. class CNetFulfilledRequestManager { private: typedef std::map<std::string, int64_t> fulfilledreqmapentry_t; typedef std::map<CNetAddr, fulfilledreqmapentry_t> fulfilledreqmap_t; //keep track of what node has/was asked for and when fulfilledreqmap_t mapFulfilledRequests; CCriticalSection cs_mapFulfilledRequests; public: CNetFulfilledRequestManager() {} ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { LOCK(cs_mapFulfilledRequests); READWRITE(mapFulfilledRequests); } void AddFulfilledRequest(CAddress addr, std::string strRequest); // expire after 1 hour by default bool HasFulfilledRequest(CAddress addr, std::string strRequest); void RemoveFulfilledRequest(CAddress addr, std::string strRequest); void CheckAndRemove(); void Clear(); std::string ToString() const; }; #endif
[ "4mindsmine@gmail.com" ]
4mindsmine@gmail.com
ae0a07a12d5b477a2b6feb9f0dc2a56a8ea2fc18
986959b15d763745518085bdb5106daeb4e0b41d
/Volume - 4 (400 - 434)/419 - Middle Number(s).cpp
963611096ff74fd426bebf739c3d0889a698aa91
[]
no_license
Md-Sabbir-Ahmed/Outsbook
a19d314b481d5f2e57478c98b0fe50d08781310c
e3b2c54517de3badff96f96d99d1592db7286513
refs/heads/master
2022-11-07T06:43:37.955730
2020-06-26T20:32:03
2020-06-26T20:32:03
267,264,610
1
0
null
null
null
null
UTF-8
C++
false
false
274
cpp
#include<bits/stdc++.h> using namespace std; int main() { long long n; while(cin>>n) { if(n%2==1) { cout<<(n/2)+1<<"\n"; } else { cout<<(n/2)<<" "<<(n/2)+1<<"\n"; } } return 0; }
[ "sabbir106706@gmail.com" ]
sabbir106706@gmail.com
c89a22d2587ef8a5715cd30a8e5cabd40e9cceba
8075a04ad4d2e8119da438394978c50259b856c2
/src/kernel.cpp
342e228da8dc65214979d87afa64839cad6c0e65
[ "MIT" ]
permissive
coriumplatform/corium
56c29109118708a8cd3cf36b9aa2deb49ef4ee06
4b1faabdcde7383221af51d7655c0ebdc8b17f77
refs/heads/master
2020-03-22T15:50:17.789212
2018-07-10T12:41:24
2018-07-10T12:41:24
140,282,543
0
0
null
null
null
null
UTF-8
C++
false
false
19,606
cpp
/* @flow */ // Copyright (c) 2012-2013 The PPCoin developers // Copyright (c) 2015-2017 The PIVX developers // Copyright (c) 2017 The Corium developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <boost/assign/list_of.hpp> #include <boost/lexical_cast.hpp> #include "db.h" #include "kernel.h" #include "script/interpreter.h" #include "timedata.h" #include "util.h" using namespace std; bool fTestNet = false; //Params().NetworkID() == CBaseChainParams::TESTNET; // Modifier interval: time to elapse before new modifier is computed // Set to 3-hour for production network and 20-minute for test network unsigned int nModifierInterval; int nStakeTargetSpacing = 60; unsigned int getIntervalVersion(bool fTestNet) { if (fTestNet) return MODIFIER_INTERVAL_TESTNET; else return MODIFIER_INTERVAL; } // Hard checkpoints of stake modifiers to ensure they are deterministic static std::map<int, unsigned int> mapStakeModifierCheckpoints = boost::assign::map_list_of(0, 0xfd11f4e7u); // Get time weight int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd) { return nIntervalEnd - nIntervalBeginning - nStakeMinAge; } // Get the last stake modifier and its generation time from a given block static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64_t& nStakeModifier, int64_t& nModifierTime) { if (!pindex) return error("GetLastStakeModifier: null pindex"); while (pindex && pindex->pprev && !pindex->GeneratedStakeModifier()) pindex = pindex->pprev; if (!pindex->GeneratedStakeModifier()) return error("GetLastStakeModifier: no generation at genesis block"); nStakeModifier = pindex->nStakeModifier; nModifierTime = pindex->GetBlockTime(); return true; } // Get selection interval section (in seconds) static int64_t GetStakeModifierSelectionIntervalSection(int nSection) { assert(nSection >= 0 && nSection < 64); int64_t a = getIntervalVersion(fTestNet) * 63 / (63 + ((63 - nSection) * (MODIFIER_INTERVAL_RATIO - 1))); return a; } // Get stake modifier selection interval (in seconds) static int64_t GetStakeModifierSelectionInterval() { int64_t nSelectionInterval = 0; for (int nSection = 0; nSection < 64; nSection++) { nSelectionInterval += GetStakeModifierSelectionIntervalSection(nSection); } return nSelectionInterval; } // select a block from the candidate blocks in vSortedByTimestamp, excluding // already selected blocks in vSelectedBlocks, and with timestamp up to // nSelectionIntervalStop. static bool SelectBlockFromCandidates( vector<pair<int64_t, uint256> >& vSortedByTimestamp, map<uint256, const CBlockIndex*>& mapSelectedBlocks, int64_t nSelectionIntervalStop, uint64_t nStakeModifierPrev, const CBlockIndex** pindexSelected) { bool fModifierV2 = false; bool fFirstRun = true; bool fSelected = false; uint256 hashBest = 0; *pindexSelected = (const CBlockIndex*)0; BOOST_FOREACH (const PAIRTYPE(int64_t, uint256) & item, vSortedByTimestamp) { if (!mapBlockIndex.count(item.second)) return error("SelectBlockFromCandidates: failed to find block index for candidate block %s", item.second.ToString().c_str()); const CBlockIndex* pindex = mapBlockIndex[item.second]; if (fSelected && pindex->GetBlockTime() > nSelectionIntervalStop) break; //if the lowest block height (vSortedByTimestamp[0]) is >= switch height, use new modifier calc if (fFirstRun){ fModifierV2 = pindex->nHeight >= Params().ModifierUpgradeBlock(); fFirstRun = false; } if (mapSelectedBlocks.count(pindex->GetBlockHash()) > 0) continue; // compute the selection hash by hashing an input that is unique to that block uint256 hashProof; if(fModifierV2) hashProof = pindex->GetBlockHash(); else hashProof = pindex->IsProofOfStake() ? 0 : pindex->GetBlockHash(); CDataStream ss(SER_GETHASH, 0); ss << hashProof << nStakeModifierPrev; uint256 hashSelection = Hash(ss.begin(), ss.end()); // the selection hash is divided by 2**32 so that proof-of-stake block // is always favored over proof-of-work block. this is to preserve // the energy efficiency property if (pindex->IsProofOfStake()) hashSelection >>= 32; if (fSelected && hashSelection < hashBest) { hashBest = hashSelection; *pindexSelected = (const CBlockIndex*)pindex; } else if (!fSelected) { fSelected = true; hashBest = hashSelection; *pindexSelected = (const CBlockIndex*)pindex; } } if (GetBoolArg("-printstakemodifier", false)) LogPrintf("SelectBlockFromCandidates: selection hash=%s\n", hashBest.ToString().c_str()); return fSelected; } // Stake Modifier (hash modifier of proof-of-stake): // The purpose of stake modifier is to prevent a txout (coin) owner from // computing future proof-of-stake generated by this txout at the time // of transaction confirmation. To meet kernel protocol, the txout // must hash with a future stake modifier to generate the proof. // Stake modifier consists of bits each of which is contributed from a // selected block of a given block group in the past. // The selection of a block is based on a hash of the block's proof-hash and // the previous stake modifier. // Stake modifier is recomputed at a fixed time interval instead of every // block. This is to make it difficult for an attacker to gain control of // additional bits in the stake modifier, even after generating a chain of // blocks. bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier) { nStakeModifier = 0; fGeneratedStakeModifier = false; if (!pindexPrev) { fGeneratedStakeModifier = true; return true; // genesis block's modifier is 0 } if (pindexPrev->nHeight == 0) { //Give a stake modifier to the first block fGeneratedStakeModifier = true; nStakeModifier = uint64_t("stakemodifier"); return true; } // First find current stake modifier and its generation block time // if it's not old enough, return the same stake modifier int64_t nModifierTime = 0; if (!GetLastStakeModifier(pindexPrev, nStakeModifier, nModifierTime)) return error("ComputeNextStakeModifier: unable to get last modifier"); if (GetBoolArg("-printstakemodifier", false)) LogPrintf("ComputeNextStakeModifier: prev modifier= %s time=%s\n", boost::lexical_cast<std::string>(nStakeModifier).c_str(), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nModifierTime).c_str()); if (nModifierTime / getIntervalVersion(fTestNet) >= pindexPrev->GetBlockTime() / getIntervalVersion(fTestNet)) return true; // Sort candidate blocks by timestamp vector<pair<int64_t, uint256> > vSortedByTimestamp; vSortedByTimestamp.reserve(64 * getIntervalVersion(fTestNet) / nStakeTargetSpacing); int64_t nSelectionInterval = GetStakeModifierSelectionInterval(); int64_t nSelectionIntervalStart = (pindexPrev->GetBlockTime() / getIntervalVersion(fTestNet)) * getIntervalVersion(fTestNet) - nSelectionInterval; const CBlockIndex* pindex = pindexPrev; while (pindex && pindex->GetBlockTime() >= nSelectionIntervalStart) { vSortedByTimestamp.push_back(make_pair(pindex->GetBlockTime(), pindex->GetBlockHash())); pindex = pindex->pprev; } int nHeightFirstCandidate = pindex ? (pindex->nHeight + 1) : 0; reverse(vSortedByTimestamp.begin(), vSortedByTimestamp.end()); sort(vSortedByTimestamp.begin(), vSortedByTimestamp.end()); // Select 64 blocks from candidate blocks to generate stake modifier uint64_t nStakeModifierNew = 0; int64_t nSelectionIntervalStop = nSelectionIntervalStart; map<uint256, const CBlockIndex*> mapSelectedBlocks; for (int nRound = 0; nRound < min(64, (int)vSortedByTimestamp.size()); nRound++) { // add an interval section to the current selection round nSelectionIntervalStop += GetStakeModifierSelectionIntervalSection(nRound); // select a block from the candidates of current round if (!SelectBlockFromCandidates(vSortedByTimestamp, mapSelectedBlocks, nSelectionIntervalStop, nStakeModifier, &pindex)) return error("ComputeNextStakeModifier: unable to select block at round %d", nRound); // write the entropy bit of the selected block nStakeModifierNew |= (((uint64_t)pindex->GetStakeEntropyBit()) << nRound); // add the selected block from candidates to selected list mapSelectedBlocks.insert(make_pair(pindex->GetBlockHash(), pindex)); if (fDebug || GetBoolArg("-printstakemodifier", false)) LogPrintf("ComputeNextStakeModifier: selected round %d stop=%s height=%d bit=%d\n", nRound, DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nSelectionIntervalStop).c_str(), pindex->nHeight, pindex->GetStakeEntropyBit()); } // Print selection map for visualization of the selected blocks if (fDebug || GetBoolArg("-printstakemodifier", false)) { string strSelectionMap = ""; // '-' indicates proof-of-work blocks not selected strSelectionMap.insert(0, pindexPrev->nHeight - nHeightFirstCandidate + 1, '-'); pindex = pindexPrev; while (pindex && pindex->nHeight >= nHeightFirstCandidate) { // '=' indicates proof-of-stake blocks not selected if (pindex->IsProofOfStake()) strSelectionMap.replace(pindex->nHeight - nHeightFirstCandidate, 1, "="); pindex = pindex->pprev; } BOOST_FOREACH (const PAIRTYPE(uint256, const CBlockIndex*) & item, mapSelectedBlocks) { // 'S' indicates selected proof-of-stake blocks // 'W' indicates selected proof-of-work blocks strSelectionMap.replace(item.second->nHeight - nHeightFirstCandidate, 1, item.second->IsProofOfStake() ? "S" : "W"); } LogPrintf("ComputeNextStakeModifier: selection height [%d, %d] map %s\n", nHeightFirstCandidate, pindexPrev->nHeight, strSelectionMap.c_str()); } if (fDebug || GetBoolArg("-printstakemodifier", false)) { LogPrintf("ComputeNextStakeModifier: new modifier=%s time=%s\n", boost::lexical_cast<std::string>(nStakeModifierNew).c_str(), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexPrev->GetBlockTime()).c_str()); } nStakeModifier = nStakeModifierNew; fGeneratedStakeModifier = true; return true; } // The stake modifier used to hash for a stake kernel is chosen as the stake // modifier about a selection interval later than the coin generating the kernel bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake) { nStakeModifier = 0; if (!mapBlockIndex.count(hashBlockFrom)) return error("GetKernelStakeModifier() : block not indexed"); const CBlockIndex* pindexFrom = mapBlockIndex[hashBlockFrom]; nStakeModifierHeight = pindexFrom->nHeight; nStakeModifierTime = pindexFrom->GetBlockTime(); int64_t nStakeModifierSelectionInterval = GetStakeModifierSelectionInterval(); const CBlockIndex* pindex = pindexFrom; CBlockIndex* pindexNext = chainActive[pindexFrom->nHeight + 1]; // loop to find the stake modifier later by a selection interval while (nStakeModifierTime < pindexFrom->GetBlockTime() + nStakeModifierSelectionInterval) { if (!pindexNext) { // Should never happen return error("Null pindexNext\n"); } pindex = pindexNext; pindexNext = chainActive[pindexNext->nHeight + 1]; if (pindex->GeneratedStakeModifier()) { nStakeModifierHeight = pindex->nHeight; nStakeModifierTime = pindex->GetBlockTime(); } } nStakeModifier = pindex->nStakeModifier; return true; } uint256 stakeHash(unsigned int nTimeTx, CDataStream ss, unsigned int prevoutIndex, uint256 prevoutHash, unsigned int nTimeBlockFrom) { //Corium will hash in the transaction hash and the index number in order to make sure each hash is unique ss << nTimeBlockFrom << prevoutIndex << prevoutHash << nTimeTx; return Hash(ss.begin(), ss.end()); } //test hash vs target bool stakeTargetHit(uint256 hashProofOfStake, int64_t nValueIn, uint256 bnTargetPerCoinDay) { //get the stake weight - weight is equal to coin amount uint256 bnCoinDayWeight = uint256(nValueIn) / 100; // Now check if proof-of-stake hash meets target protocol return (uint256(hashProofOfStake) < bnCoinDayWeight * bnTargetPerCoinDay); } //instead of looping outside and reinitializing variables many times, we will give a nTimeTx and also search interval so that we can do all the hashing here bool CheckStakeKernelHash(unsigned int nBits, const CBlock blockFrom, const CTransaction txPrev, const COutPoint prevout, unsigned int& nTimeTx, unsigned int nHashDrift, bool fCheck, uint256& hashProofOfStake, bool fPrintProofOfStake) { //assign new variables to make it easier to read int64_t nValueIn = txPrev.vout[prevout.n].nValue; unsigned int nTimeBlockFrom = blockFrom.GetBlockTime(); if (nTimeTx < nTimeBlockFrom) // Transaction timestamp violation return error("CheckStakeKernelHash() : nTime violation"); if (nTimeBlockFrom + nStakeMinAge > nTimeTx) // Min age requirement return error("CheckStakeKernelHash() : min age violation - nTimeBlockFrom=%d nStakeMinAge=%d nTimeTx=%d", nTimeBlockFrom, nStakeMinAge, nTimeTx); //grab difficulty uint256 bnTargetPerCoinDay; bnTargetPerCoinDay.SetCompact(nBits); //grab stake modifier uint64_t nStakeModifier = 0; int nStakeModifierHeight = 0; int64_t nStakeModifierTime = 0; if (!GetKernelStakeModifier(blockFrom.GetHash(), nStakeModifier, nStakeModifierHeight, nStakeModifierTime, fPrintProofOfStake)) { LogPrintf("CheckStakeKernelHash(): failed to get kernel stake modifier \n"); return false; } //create data stream once instead of repeating it in the loop CDataStream ss(SER_GETHASH, 0); ss << nStakeModifier; //if wallet is simply checking to make sure a hash is valid if (fCheck) { hashProofOfStake = stakeHash(nTimeTx, ss, prevout.n, prevout.hash, nTimeBlockFrom); return stakeTargetHit(hashProofOfStake, nValueIn, bnTargetPerCoinDay); } bool fSuccess = false; unsigned int nTryTime = 0; unsigned int i; int nHeightStart = chainActive.Height(); for (i = 0; i < (nHashDrift); i++) //iterate the hashing { //new block came in, move on if (chainActive.Height() != nHeightStart) break; //hash this iteration nTryTime = nTimeTx + nHashDrift - i; hashProofOfStake = stakeHash(nTryTime, ss, prevout.n, prevout.hash, nTimeBlockFrom); // if stake hash does not meet the target then continue to next iteration if (!stakeTargetHit(hashProofOfStake, nValueIn, bnTargetPerCoinDay)) continue; fSuccess = true; // if we make it this far then we have successfully created a stake hash nTimeTx = nTryTime; if (fDebug || fPrintProofOfStake) { LogPrintf("CheckStakeKernelHash() : using modifier %s at height=%d timestamp=%s for block from height=%d timestamp=%s\n", boost::lexical_cast<std::string>(nStakeModifier).c_str(), nStakeModifierHeight, DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nStakeModifierTime).c_str(), mapBlockIndex[blockFrom.GetHash()]->nHeight, DateTimeStrFormat("%Y-%m-%d %H:%M:%S", blockFrom.GetBlockTime()).c_str()); LogPrintf("CheckStakeKernelHash() : pass protocol=%s modifier=%s nTimeBlockFrom=%u prevoutHash=%s nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", "0.3", boost::lexical_cast<std::string>(nStakeModifier).c_str(), nTimeBlockFrom, prevout.hash.ToString().c_str(), nTimeBlockFrom, prevout.n, nTryTime, hashProofOfStake.ToString().c_str()); } break; } mapHashedBlocks.clear(); mapHashedBlocks[chainActive.Tip()->nHeight] = GetTime(); //store a time stamp of when we last hashed on this block return fSuccess; } // Check kernel hash target and coinstake signature bool CheckProofOfStake(const CBlock block, uint256& hashProofOfStake) { const CTransaction tx = block.vtx[1]; if (!tx.IsCoinStake()) return error("CheckProofOfStake() : called on non-coinstake %s", tx.GetHash().ToString().c_str()); // Kernel (input 0) must match the stake hash target per coin age (nBits) const CTxIn& txin = tx.vin[0]; // First try finding the previous transaction in database uint256 hashBlock; CTransaction txPrev; if (!GetTransaction(txin.prevout.hash, txPrev, hashBlock, true)) return error("CheckProofOfStake() : INFO: read txPrev failed"); //verify signature and script if (!VerifyScript(txin.scriptSig, txPrev.vout[txin.prevout.n].scriptPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker(&tx, 0))) return error("CheckProofOfStake() : VerifySignature failed on coinstake %s", tx.GetHash().ToString().c_str()); CBlockIndex* pindex = NULL; BlockMap::iterator it = mapBlockIndex.find(hashBlock); if (it != mapBlockIndex.end()) pindex = it->second; else return error("CheckProofOfStake() : read block failed"); // Read block header CBlock blockprev; if (!ReadBlockFromDisk(blockprev, pindex->GetBlockPos())) return error("CheckProofOfStake(): INFO: failed to find block"); unsigned int nInterval = 0; unsigned int nTime = block.nTime; if (!CheckStakeKernelHash(block.nBits, blockprev, txPrev, txin.prevout, nTime, nInterval, true, hashProofOfStake, fDebug)) return error("CheckProofOfStake() : INFO: check kernel failed on coinstake %s, hashProof=%s \n", tx.GetHash().ToString().c_str(), hashProofOfStake.ToString().c_str()); // may occur during initial download or if behind on block chain sync return true; } // Check whether the coinstake timestamp meets protocol bool CheckCoinStakeTimestamp(int64_t nTimeBlock, int64_t nTimeTx) { // v0.3 protocol return (nTimeBlock == nTimeTx); } // Get stake modifier checksum unsigned int GetStakeModifierChecksum(const CBlockIndex* pindex) { assert(pindex->pprev || pindex->GetBlockHash() == Params().HashGenesisBlock()); // Hash previous checksum with flags, hashProofOfStake and nStakeModifier CDataStream ss(SER_GETHASH, 0); if (pindex->pprev) ss << pindex->pprev->nStakeModifierChecksum; ss << pindex->nFlags << pindex->hashProofOfStake << pindex->nStakeModifier; uint256 hashChecksum = Hash(ss.begin(), ss.end()); hashChecksum >>= (256 - 32); return hashChecksum.Get64(); } // Check stake modifier hard checkpoints bool CheckStakeModifierCheckpoints(int nHeight, unsigned int nStakeModifierChecksum) { if (fTestNet) return true; // Testnet has no checkpoints if (mapStakeModifierCheckpoints.count(nHeight)) { return nStakeModifierChecksum == mapStakeModifierCheckpoints[nHeight]; } return true; }
[ "coriumplatform@gmail.com" ]
coriumplatform@gmail.com
31403548c56ba7ae4b56d75895189671d3844327
6526a8b50dd4914678ced85d01feb7223f59825a
/application/filesystem/linux-fs-wrapper/source/llist.cpp
935c87352799a7cf7e4ccf0756819eb6822be07d
[]
no_license
jcyuan78/filesystem_model_checking
e43cde33ba50a85c15da09a93aa99a698bd663e3
3665701e652c7e174f319d8e20000298c980caec
refs/heads/master
2023-04-09T12:35:38.000062
2023-03-19T04:46:05
2023-03-19T04:46:05
200,018,811
1
0
null
null
null
null
UTF-8
C++
false
false
2,868
cpp
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "pch.h" // SPDX-License-Identifier: GPL-2.0-only /* * Lock-less NULL terminated single linked list * * The basic atomic operation of this list is cmpxchg on long. On * architectures that don't have NMI-safe cmpxchg implementation, the * list can NOT be used in NMI handlers. So code that uses the list in * an NMI handler should depend on CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG. * * Copyright 2010,2011 Intel Corp. * Author: Huang Ying <ying.huang@intel.com> */ //#include <linux/kernel.h> //#include <linux/export.h> #include "../include/linux_comm.h" #include "../include/llist.h" /** * llist_add_batch - add several linked entries in batch * @new_first: first entry in batch to be added * @new_last: last entry in batch to be added * @head: the head for your lock-less list * * Return whether list is empty before adding. */ bool llist_add_batch(llist_node *new_first, llist_node *new_last, llist_head *head) { llist_node *first; do { // new_last->next = first = READ_ONCE(head->first); new_last->next = first = head->first; } // while (cmpxchg(&head->first, first, new_first) != first); while (InterlockedCompareExchangePointer((PVOID*)(&head->first), new_first, first) != first); return !first; } #if 0 /** * llist_del_first - delete the first entry of lock-less list * @head: the head for your lock-less list * * If list is empty, return NULL, otherwise, return the first entry * deleted, this is the newest added one. * * Only one llist_del_first user can be used simultaneously with * multiple llist_add users without lock. Because otherwise * llist_del_first, llist_add, llist_add (or llist_del_all, llist_add, * llist_add) sequence in another user may change @head->first->next, * but keep @head->first. If multiple consumers are needed, please * use llist_del_all or use lock between consumers. */ struct llist_node *llist_del_first(struct llist_head *head) { struct llist_node *entry, *old_entry, *next; entry = smp_load_acquire(&head->first); for (;;) { if (entry == NULL) return NULL; old_entry = entry; next = READ_ONCE(entry->next); entry = cmpxchg(&head->first, old_entry, next); if (entry == old_entry) break; } return entry; } EXPORT_SYMBOL_GPL(llist_del_first); /** * llist_reverse_order - reverse order of a llist chain * @head: first item of the list to be reversed * * Reverse the order of a chain of llist entries and return the * new first entry. */ struct llist_node *llist_reverse_order(struct llist_node *head) { struct llist_node *new_head = NULL; while (head) { struct llist_node *tmp = head; head = head->next; tmp->next = new_head; new_head = tmp; } return new_head; } EXPORT_SYMBOL_GPL(llist_reverse_order); #endif
[ "bytekiller1978@hotmail.com" ]
bytekiller1978@hotmail.com
701c91da7b4a6c3351b8b092935358885cab2d0b
1ae9432cbb3a2ddf1327eb75c60cf87ab19b7a8f
/HYPlayer/video_player/demux/DemuxLooper.cpp
b17e36089ec09ec4df00d5f908055c7db7df1b6c
[]
no_license
chongbo2013/IOS_HYPlayer
4652e93866d63e385c85866daf3da7aeb165d290
027787c2e21c1e086e4fe0eecedc9346da1054ce
refs/heads/master
2022-04-04T06:35:24.587702
2020-03-01T07:58:42
2020-03-01T07:58:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,229
cpp
// // DemuxLooper.cpp // HYPlayer // // Created by templechen on 2020/2/21. // Copyright © 2020 templechen. All rights reserved. // #include "DemuxLooper.hpp" #include "FFVideoDemux.h" DemuxLooper::DemuxLooper(circle_av_packet_queue *queue, bool isAudio) { this->queue = queue; this->isAudio = isAudio; } DemuxLooper::~DemuxLooper() { } void DemuxLooper::handleMessage(Looper::LooperMessage *msg) { switch (msg->what) { case kMsgDemuxCreated: { if (demux == nullptr) { demux = new FFVideoDemux(); demux->packetQueue = queue; } demux->init((const char *) msg->obj); demux->isDemuxing = true; demux->start(); break; }; case kMsgDemuxSeek: { demux->seek((long) msg->obj); break; } case kMsgDemuxRelease: { demux->release(); quit(); break; } default: { break; } } } long DemuxLooper::getTotalDuration() { if (demux != nullptr) { return static_cast<long>(demux->totalDuration); } return 0L; } void DemuxLooper::pthreadExit() { delete this; }
[ "weichen@narvii.com" ]
weichen@narvii.com
d47f91d2fef49bc32288a1a8c03ea07ccd455bdf
4b73a36745e969cf9d222c111d1baa39cb3d254a
/test/autogen/smp@list@pop_front.cpp
48566830624f309dec745af16159adca7697bfa0
[ "MIT" ]
permissive
Ornito/jln.mp
f3cc94e7b34523d40777171c5d38fdb2c817287e
9553e3d3bc6424f8cfc4e550fdab5ec94d97594e
refs/heads/master
2023-05-05T02:51:29.101364
2021-05-22T22:40:31
2021-05-22T22:40:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
41
cpp
#include "jln/mp/smp/list/pop_front.hpp"
[ "jonathan.poelen@gmail.com" ]
jonathan.poelen@gmail.com
c69ec2b6a19738255961cb7e94cb9b3d5a333362
cf95c635a115d2c5f0f8b2c15ea3cc8061a34887
/TwilveQt/twqcell.h
fde2bbf12fe60edd177548605b1f356b907caaaa
[ "CC-BY-3.0" ]
permissive
degarashi/TwilveQt
49c9cc7247e32cec15e6764f2298a09c3d5e383d
bb98c29487f1088cce71063a4cafc7cd8ab58610
refs/heads/master
2020-12-24T12:01:57.598744
2013-03-14T12:00:25
2013-04-04T01:43:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,429
h
#ifndef TWQCELL_H #define TWQCELL_H #include <QString> #include <QLabel> #include <cstdint> #include <memory> #include "common.h" class QFrame; class QPixmap; class QMouseEvent; class QHBoxLayout; class QVBoxLayout; // QLabelにクリック検知を追加 class CLabel : public QLabel { Q_OBJECT uint64_t _id; //!< TweetID 又は UserID protected: void mousePressEvent(QMouseEvent *e); signals: void clickedUser(UserID id, bool bR); void clickedTweet(TweetID id, bool bR); public: explicit CLabel(uint64_t id); }; class TwqCell; class TwqTL; //! TwqCellの装飾チェック class IFCellChecker { public: virtual ~IFCellChecker() {} virtual bool check(const TwqTL& tl, TweetID id) const = 0; }; //! TwqCellの装飾 class IFCellDecorator { public: virtual ~IFCellDecorator() {} virtual void modify(const TwqTL& tl, TwqCell& cell) const = 0; virtual void unmodify(const TwqTL& tl, TwqCell& cell) const = 0; }; //! CheckFlag + Decorator class CellMod { typedef std::unique_ptr<IFCellChecker> UPCheck; typedef std::unique_ptr<IFCellDecorator> UPDeco; QString _name; uint32_t _priority; UPCheck _checker; UPDeco _deco; public: CellMod(CellMod&& c); //! chkとdecoの所有権を持つ CellMod(const QString& name, uint32_t prio, IFCellChecker* chk, IFCellDecorator* deco); //! 条件判定の後に装飾 void checkAndModify(const TwqTL& tl, TwqCell& cell) const; void unModify(const TwqTL& tl, TwqCell& cell) const; void swap(CellMod& c) noexcept; uint32_t getPrio() const; }; namespace std { template <> inline void swap<CellMod>(CellMod& c0, CellMod& c1) { c0.swap(c1); } } #define DEF_CCHECK(Name) class Name : public IFCellChecker { \ public: \ bool check(const TwqTL& tl, TweetID id) const override; \ }; // HomeTLとSearchTLでは判定方法が異なる //! 他人のRT DEF_CCHECK(CcRT) //! 自分のFav DEF_CCHECK(CcMyFav) //! 自分のRT DEF_CCHECK(CcMyRT) //! 選択中かどうか DEF_CCHECK(CcSelect) //! バックグラウンドを単色で装飾 class CdColor : public IFCellDecorator { QColor _colorBG, _colorText; public: CdColor(QColor colBG=QColor(), QColor colText=QColor()): _colorBG(colBG), _colorText(colText) {} void modify(const TwqTL& tl, TwqCell& cell) const override; void unmodify(const TwqTL& tl, TwqCell& cell) const override; }; //! バーにアイコンを置く装飾 class CdIcon : public IFCellDecorator { private: QPixmap _icon; QString _name; public: CdIcon(const QPixmap& p, const QString& name); void modify(const TwqTL& tl, TwqCell& cell) const override; void unmodify(const TwqTL& tl, TwqCell& cell) const override; }; //! TwqTweetを表示するクラス class TwqCell : public QFrame { Q_OBJECT QHBoxLayout *_loIconTw, *_loSub, *_loTray; QVBoxLayout* _loMainSub; TweetID _twID; // user icon CLabel *_lbIcon; QLabel *_lbTweet, *_lbScreen_name, *_lbName, *_lbSource, *_lbDate; // for Fav/RT icons QFrame* _frIcon; SPVoid _spVoid; protected: void mousePressEvent(QMouseEvent *e); signals: void clicked(TweetID twID, bool bR); void userClicked(UserID uid, bool bR); public: explicit TwqCell(TweetID twID, QWidget* parent=nullptr); void setTweet(TweetID twID); TweetID id() const; int cellHeight(int w) const; QVBoxLayout* boxLayout(); QHBoxLayout* iconTray(); void applyMods(const TwqTL& tl, const std::vector<CellMod>& mods); }; #endif // TWQCELL_H
[ "slice013@gmail.com" ]
slice013@gmail.com
e199a87e1361c92d076d95693bdaca056a455d9c
b5648642fd2e05589cab760a909ce1dc38556d5d
/touchGFX/TGFX-Framework-include/touchgfx/Bitmap.hpp
10cea0476bce70fe8cf349f5227eede8c34227fd
[]
no_license
sunklCoin/MCU
862c8f8ee48872b3fc703d54c2d76bbb74cca1a4
9cc7a45fae3b18821c722f78d901034086ccc98c
refs/heads/master
2021-07-14T00:58:51.259827
2017-10-16T14:12:55
2017-10-16T14:12:55
105,020,651
0
0
null
2017-10-16T14:12:56
2017-09-27T13:19:03
C++
UTF-8
C++
false
false
19,329
hpp
/****************************************************************************** * * @brief This file is part of the TouchGFX 4.8.0 evaluation distribution. * * @author Draupner Graphics A/S <http://www.touchgfx.com> * ****************************************************************************** * * @section Copyright * * Copyright (C) 2014-2016 Draupner Graphics A/S <http://www.touchgfx.com>. * All rights reserved. * * TouchGFX is protected by international copyright laws and the knowledge of * this source code may not be used to write a similar product. This file may * only be used in accordance with a license and should not be re- * distributed in any way without the prior permission of Draupner Graphics. * * This is licensed software for evaluation use, any use must strictly comply * with the evaluation license agreement provided with delivery of the * TouchGFX software. * * The evaluation license agreement can be seen on www.touchgfx.com * * @section Disclaimer * * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Draupner Graphics A/S has * no obligation to support this software. Draupner Graphics A/S is providing * the software "AS IS", with no express or implied warranties of any kind, * including, but not limited to, any implied warranties of merchantability * or fitness for any particular purpose or warranties against infringement * of any proprietary rights of a third party. * * Draupner Graphics A/S can not be held liable for any consequential, * incidental, or special damages, or any other relief, or for any claim by * any third party, arising from your use of this software. * *****************************************************************************/ #ifndef BITMAP_HPP #define BITMAP_HPP #include <cassert> #include <touchgfx/hal/Types.hpp> #ifdef __ARMCC_VERSION // Keil compiler issues irrelevant warning relating to missing ctor initialization for BitmapData. #pragma diag_suppress 368 #endif namespace touchgfx { /** * @typedef uint16_t BitmapId * * @brief This type shall be used by the application to define unique IDs for all bitmaps in the * system. The application shall define bitmap IDs in the range [0, number of bitmaps - * 1]. */ typedef uint16_t BitmapId; const BitmapId BITMAP_ANIMATION_STORAGE = 0xFFFEU; ///< A virtual id representing animation storage. const BitmapId BITMAP_INVALID = 0xFFFFU; ///< Define the bitmapId if an invalid bitmap class BitmapData; /** * @class Bitmap Bitmap.hpp touchgfx/Bitmap.hpp * * @brief This class provides a proxy object for a bitmap image. * * This class provides a proxy object for a bitmap image stored in the application * specific bitmap database. The proxy provides access to the raw bitmap data as well as * metadata. */ class Bitmap { public: /** * @enum BitmapFormat * * @brief Data of a bitmap can be stored in the following formats. * * Data of a bitmap can be stored in the following formats. */ enum BitmapFormat { RGB565, ///< 16-bit, 5 bits for red, 6 bits for green, 5 bits for blue, no alpha channel RGB888, ///< 24-bit, 8 bits for each of red, green and blue, no alpha channel ARGB8888, ///< 32-bit, 8 bits for each of red, green, blue and alpha channel BW, ///< 1-bit, black / white, no alpha channel BW_RLE, ///< 1-bit, black / white, no alpha channel compressed with horizontal RLE GRAY2, ///< 2-bit grayscale GRAY4 ///< 4.bit grayscale }; /** * @struct BitmapData Bitmap.hpp touchgfx/Bitmap.hpp * * @brief Data of a bitmap. * * Data of a bitmap. */ struct BitmapData { const uint8_t* const data; ///< The data of this bitmap const uint8_t* const alphaData; ///< The data of the alpha channel (contains 0 if no alpha channel exist) const uint16_t width; ///< The width of the bitmap const uint16_t height; ///< The height of the bitmap const uint16_t solidRect_x; ///< The x coordinate of the maximum solid rectangle of the bitmap const uint16_t solidRect_y; ///< The y coordinate of the maximum solid rectangle of the bitmap const uint16_t solidRect_width; ///< The width of the maximum solid rectangle of the bitmap const uint16_t solidRect_height : 13; ///< The height of the maximum solid rectangle of the bitmap const uint8_t format : 3; ///< Determine the format of the data }; /** * @struct DynamicBitmapData Bitmap.hpp touchgfx/Bitmap.hpp * * @brief Data of a dynamic bitmap. * * Data of a dynamic bitmap. */ struct DynamicBitmapData { Rect solid; ///< The solidRect of this bitmap uint16_t width; ///< The width of the bitmap uint16_t height; ///< The height of the bitmap uint16_t format; ///< Determine the format of the data uint8_t inuse; ///< zero if not in use uint8_t alpha; ///< true if separate alpha for 565 format (always false) }; /** * @struct CacheTableEntry Bitmap.hpp touchgfx/Bitmap.hpp * * @brief Cache bookkeeping. * * Cache bookkeeping. */ struct CacheTableEntry { uint8_t* data; ///< Pointer to location of image data for this bitmap in the cache. 0 if bitmap not cached. }; /** * @fn explicit Bitmap::Bitmap(const BitmapId id = BITMAP_INVALID) * * @brief Creates and binds a Bitmap instance to the corresponding entry in the BitmapData * array. * * Creates and binds a Bitmap instance to the corresponding entry in the BitmapData * array. * * @param id The unique bitmap identifier. */ explicit Bitmap(const BitmapId id = BITMAP_INVALID) : bitmapId(id) { } /** * @fn BitmapId Bitmap::getId() const * * @brief Gets the id of this Bitmap. * * Gets the id of this Bitmap. * * @return The id of this Bitmap. */ BitmapId getId() const { assert(bitmaps != 0 && "Bitmap database has not been initialized."); return bitmapId; } /** * @fn const uint8_t* Bitmap::getData() const; * * @brief Gets a pointer to the Bitmap data. * * Gets a pointer to the Bitmap data. * * @note If this bitmap is cached, it will return the cached version of bitmap data. * * @return A pointer to the raw bitmap data. */ const uint8_t* getData() const; /** * @fn const uint8_t* Bitmap::getAlphaData() const; * * @brief Gets a pointer to the alpha data, if present in the bitmap. * * Gets a pointer to the alpha data, if present in the bitmap. * * @note If this bitmap is cached, it will return the cached version of alpha data for this * bitmap. * * @return A pointer to the raw alpha channel data. If no alpha channel exist 0 is returned. */ const uint8_t* getAlphaData() const; /** * @fn BitmapFormat Bitmap::getFormat() const; * * @brief Gets the format of how the bitmap is stored. * * Gets the format of how the bitmap is stored. * * @return The format of how the bitmap data is stored. */ BitmapFormat getFormat() const; /** * @fn uint16_t Bitmap::getWidth() const * * @brief Gets the width of the Bitmap in pixels. * * Gets the width of the Bitmap in pixels. * * @return The bitmap width in pixels. */ uint16_t getWidth() const; /** * @fn uint16_t Bitmap::getHeight() const * * @brief Gets the height of the Bitmap in pixels. * * Gets the height of the Bitmap in pixels. * * @return The bitmap height in pixels. */ uint16_t getHeight() const; /** * @fn Rect Bitmap::getRect() const * * @brief Gets the rectangle describing the dimensions of the Bitmap. * * Gets the rectangle describing the dimensions of the Bitmap. * * @return a Rect describing the dimensions of this bitmap. */ Rect getRect() const { return Rect(0, 0, getWidth(), getHeight()); } /** * @fn bool Bitmap::isAlphaPerPixel() const * * @brief Query if this object has an alpha channel. * * Query if this object has an alpha channel. * * @return True if the bitmap contains an alpha channel (an alpha value for each pixel) */ bool isAlphaPerPixel() const { assert(bitmaps != 0 && "Bitmap database has not been initialized."); return ((bitmaps != 0) && (bitmapId < numberOfBitmaps)) ? (bitmaps[bitmapId].alphaData != 0) : false; } /** * @fn Rect Bitmap::getSolidRect() const * * @brief Gets the largest solid rectangle in the bitmap. * * Gets the largest solid, i.e. not transparent, rectangle in the bitmap. * * @return The maximum solid rectangle of the bitmap. */ Rect getSolidRect() const; /** * @fn bool Bitmap::hasTransparentPixels() const * * @brief Query if this object has transparent pixels. * * @return True if this bitmap has transparent pixels. */ bool hasTransparentPixels() const; /** * @fn static void Bitmap::registerBitmapDatabase(const BitmapData* data, const uint16_t n, uint16_t* cachep = 0, uint32_t csize = 0); * * @brief Registers an array of bitmaps. * * Registers an array of bitmaps. All Bitmap instances are bound to this database. * * @param data A reference to the BitmapData storage array. * @param n The number of bitmaps in the array. * @param [in,out] cachep (Optional) Pointer to memory region in which bitmap data can be * cached. * @param csize Size of cache memory region in bytes (0 if unused) * @param numberOfDynamicBitmaps Number of dynamic bitmaps to be allowed in the cache. */ static void registerBitmapDatabase(const BitmapData* data, const uint16_t n, uint16_t* cachep = 0, uint32_t csize = 0, uint32_t numberOfDynamicBitmaps = 0); /** * @fn static bool Bitmap::cache(BitmapId id); * * @brief Cache this bitmap into RAM. * * Cache this bitmap into unused RAM in the bitmap cache. * * @note A memory region large enough to hold this bitmap must be configured and a large * enough part of it must be available. Caching of a bitmap may involve a * defragmentation of the bitmap cache. See TouchGFX documentation for details on * caching. * * @param id The id of the bitmap to cache. * * @return true if caching went well, false otherwise. * * @see registerBitmapDatabase */ static bool cache(BitmapId id); /** * @fn static bool Bitmap::cacheReplaceBitmap(BitmapId out, BitmapId in); * * @brief Replace a bitmap in RAM with another Bitmap. * * Replace a bitmap in RAM with another Bitmap. The Bitmaps must have same size. * * @param out The id of the bitmap to remove from the cache. * @param in The id of the bitmap to cache. * * @return true if the replacement went well, false otherwise. */ static bool cacheReplaceBitmap(BitmapId out, BitmapId in); /** * @fn static bool Bitmap::cacheRemoveBitmap(BitmapId id); * * @brief Remove this bitmap from the RAM cache. * * Remove this bitmap from the RAM cache. * * @note The bitmap will be removed from the RAM cache. Unless the bitmap is otherwise stored * in (slow) RAM it can not be drawn anymore and must be cached again before use. The * RAM freed can be used for caching of another bitmap. See TouchGFX documentation for * details on caching. * * @param id The id of the bitmap to cache. * * @return true if bitmap was found and removed, false otherwise. * * @see registerBitmapDatabase */ static bool cacheRemoveBitmap(BitmapId id); /** * @fn static uint8_t* Bitmap::cacheGetAddress(BitmapId id); * * @brief Get address of cache buffer for this bitmap * * Get address of cache buffer for this bitmap. Note: The address is only valid * until next Bitmap::cache() call. * * @param id The id of the bitmap in cache. * * @return Address if bitmap was found, zero otherwise. */ static uint8_t* cacheGetAddress(BitmapId id); /** * @fn static bool Bitmap::cacheIsCached(BitmapId id); * * @brief Check if the Bitmap is cached. * * Check if the Bitmap is cached. * * @param id The id of the bitmap. * * @return true if bitmap is cached. */ static bool cacheIsCached(BitmapId id); /** * @fn static bool Bitmap::cacheAll(); * * @brief Cache all bitmaps from the Bitmap Database into RAM. * * Cache all bitmaps from the Bitmap Database into RAM. * * @note A memory region large enough to hold all bitmaps must be configured. See TouchGFX * documentation for details on caching. * * @return True if all bitmaps where cached. * * @see cache. */ static bool cacheAll(); /** * @fn static void Bitmap::clearCache(); * * @brief Clears the cached bitmaps from RAM. * * Clears the cached bitmaps from RAM. */ static void clearCache(); /** * @fn static BitmapId Bitmap::dynamicBitmapCreate(const uint16_t width, const uint16_t height, BitmapFormat format); * * @brief Create a dynamic bitmap. * * Create a dynamic bitmap. * * @param width Width of the bitmap. * @param height Height of the bitmap. * @param format Bitmap format of the bitmap. * * @return BitmapId of the new bitmap or BITMAP_INVALID if memory full. * * @note Creation of a new dynamic bitmap may cause existing dynamic bitmaps to be moved in * memory. Do not rely on bitmap memory addresses of dynamic bitmaps obtained from * dynamicBitmapGetAddress() to be valid across calls to dynamicBitmapCreate(). * * @see dynamicBitmapAddress */ static BitmapId dynamicBitmapCreate(const uint16_t width, const uint16_t height, BitmapFormat format); /** * @fn static bool Bitmap::dynamicBitmapDelete(BitmapId id); * * @brief Delete a dynamic bitmap. * * Delete a dynamic bitmap. * * @param id The BitmapId of the dynamic bitmap. * * @return true if it succeeds, false if it fails. */ static bool dynamicBitmapDelete(BitmapId id); /** * @fn static uint8_t* Bitmap::dynamicBitmapGetAddress(BitmapId id); * * @brief Get the address of the dynamic bitmap data. * * Get the address of the dynamic bitmap data. It is important that the address of a * dynamic bitmap is not stored elsewhere as a dynamic bitmap may be moved in memory * when other bitmaps are added and removed. Only store the BitmapId and ask for the * address of the bitmap data when needed. * * @param id The BitmapId of the dynamic bitmap. * * @return null if it fails, else an uint8_t*. * * @note The address of a dynamic bitmap may change when other dynamic bitmaps are added and * removed. Never store the address of dynamic images, only store the BitmapId as that * will not change. */ static uint8_t* dynamicBitmapGetAddress(BitmapId id); /** * @fn static bool Bitmap::dynamicBitmapSetSolidRect(BitmapId id, const Rect& solidRect); * * @brief Set the solid rectangle of a dynamic bitmap * * Set the solid rectangle of a dynamic bitmap. Only relevant for RGBA8888 bitmaps. * The solid part of the bitmap is drawn faster than the transparent parts. * * @param id The identifier. * @param solidRect The solid rectangle. * * @return true if it succeeds, false if it fails. */ static bool dynamicBitmapSetSolidRect(BitmapId id, const Rect& solidRect); /** * @fn bool Bitmap::operator==(const Bitmap& other) const * * @brief Equality operator. * * Equality operator. * * @param other The bitmap to compare with. * * @return True if this bitmap has the same id as the other bitmap. */ bool operator==(const Bitmap& other) const { return (bitmapId == other.bitmapId); } /** * @fn bool Bitmap::operator!=(const Bitmap& other) const * * @brief Inequality operator. * * Inequality operator. * * @param other The bitmap to compare with. * * @return True if this bitmap has a different id than the other bitmap. */ bool operator!=(const Bitmap& other) const { return !(*this == other); } /** * @fn static void Bitmap::setCache(uint16_t* cachep, uint32_t csize, uint32_t numberOfDynamicBitmaps = 0); * * @brief Register a memory region in which bitmap data can be cached. * * Register a memory region in which bitmap data can be cached. * * @param [in,out] cachep Pointer to memory region in which bitmap data can be cached. * @param csize Size of cache memory region in bytes. * @param numberOfDynamicBitmaps Number of dynamic bitmaps to be allowed in the cache. */ static void setCache(uint16_t* cachep, uint32_t csize, uint32_t numberOfDynamicBitmaps = 0); private: /** * @fn static void Bitmap::compactCache(); * * @brief Compact the bitmap cache to get continuous free memory on top. * * Compact the bitmap cache to get continuous free memory on top. * * @note This method is called by Bitmap::cache when required. */ static void compactCache(); static uint32_t getSizeOfBitmap(BitmapId id); static bool copyBitmapToCache(BitmapId id, uint8_t* const dst); BitmapId bitmapId; static const BitmapData* bitmaps; static DynamicBitmapData* dynBitmaps; static CacheTableEntry* cacheTable; //address of allocation point cache static BitmapId* allocationTable; //order of allocations in cache static uint8_t* nextFreeData; static uint16_t nextAllocationIndex; static uint32_t memoryRemaining; static uint32_t totalMemory; static uint16_t numberOfBitmaps; static uint16_t numberOfDynamicBitmaps; static uint16_t uncachedCount; //uncached images, sort of ... }; } // namespace touchgfx #endif // BITMAP_HPP
[ "sunkl.coin@gmail.com" ]
sunkl.coin@gmail.com
3fdf59cf801d57f6d94fd89ef79e10a2f46ca2d5
eaf5c173ec669b26c95f7babad40306f2c7ea459
/abc092/arc093_b.cpp
47154d74ddd515c941a3824cbc5dcc20314cbc9d
[]
no_license
rikuTanide/atcoder_endeavor
657cc3ba7fbf361355376a014e3e49317fe96def
6b5dc43474d5183d8eecb8cb13bf45087c7ed195
refs/heads/master
2023-02-02T11:49:06.679743
2020-12-21T04:51:10
2020-12-21T04:51:10
318,676,396
0
0
null
null
null
null
UTF-8
C++
false
false
2,026
cpp
#include <bits/stdc++.h> #include <cmath> using namespace std; #define rep(i, n) for (ll i = 0; i < (n); ++i) //#define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) ll(x.size()) typedef long long ll; //typedef pair<int, int> P; typedef pair<ll, ll> P; //const double INF = 1e10; const ll INF = 10e15; const ll MINF = -10e10; //const int INF = INT_MAX; #define cmin(x, y) x = min(x, y) #define cmax(x, y) x = max(x, y) //ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt"); //ofstream outfile("log.txt"); //outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl; // std::cout << std::bitset<8>(9); typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK; const int mod = 1000000007; int main() { int a, b; cin >> a >> b; int width = 95; //100 * 100; int cells = width * (width / 5); vector<bool> whites(cells, true); vector<bool> blacks(cells, false); for (int i = 1; i < a; i++) { blacks[i * 2] = true; } for (int i = 1; i < b; i++) { whites[i * 2] = false; } reverse(blacks.begin(), blacks.end()); cout << ((width / 5) * 2 * 2) << ' ' << width + 2 << endl; for (int i = 0; i < cells; i++) { if (i % width == 0) { for (int j = 0; j < width + 2; j++) { cout << '.'; } cout << endl; cout << '.'; } if (whites[i] == true) { cout << '.'; } else { cout << '#'; } if (i % width == width - 1) { cout << '.' << endl; } } for (int i = 0; i < cells; i++) { if (i % width == 0) { cout << '#'; } if (blacks[i] == true) { cout << '.'; } else { cout << '#'; } if (i % width == width - 1) { cout << '#' << endl; for (int j = 0; j < width + 2; j++) { cout << '#'; } cout << endl; } } }
[ "riku@tanide.net" ]
riku@tanide.net
1a756112dae5c81756c6b2af2024c894ef4fdf51
efe782244cba07b683c4ac92df3fd029d538fe5f
/src/pow.cpp
8a6e01178d3c3136518ccaf5f70109819d05838a
[ "MIT" ]
permissive
Kimax89/wallet-unofficial
9fc248f40156e5f49f6cc14cb7e862149883909b
70dfb876366eba4cb5d38d5274f7f1617ae742db
refs/heads/master
2023-02-19T08:16:55.213287
2021-01-24T14:08:27
2021-01-24T14:08:27
332,015,826
0
0
null
null
null
null
UTF-8
C++
false
false
12,003
cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2016 The Bitcoin Core developers // Copyright (c) 2017 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "pow.h" #include "arith_uint256.h" #include "chain.h" #include "primitives/block.h" #include "uint256.h" #include "util.h" /** * Compute the next required proof of work using the legacy Bitcoin difficulty * adjustement + Emergency Difficulty Adjustement (EDA). */ static uint32_t GetNextEDAWorkRequired(const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const Consensus::Params &params) { // Only change once per difficulty adjustment interval uint32_t nHeight = pindexPrev->nHeight + 1; if (nHeight % params.DifficultyAdjustmentInterval() == 0) { // Go back by what we want to be 14 days worth of blocks assert(nHeight >= params.DifficultyAdjustmentInterval()); uint32_t nHeightFirst = nHeight - params.DifficultyAdjustmentInterval(); const CBlockIndex *pindexFirst = pindexPrev->GetAncestor(nHeightFirst); assert(pindexFirst); return CalculateNextWorkRequired(pindexPrev, pindexFirst->GetBlockTime(), params); } const uint32_t nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); if (params.fPowAllowMinDifficultyBlocks) { // Special difficulty rule for tnet: // If the new block's timestamp is more than 2* 10 minutes then allow // mining of a min-difficulty block. if (pblock->GetBlockTime() > pindexPrev->GetBlockTime() + 2 * params.nPowTargetSpacing) { return nProofOfWorkLimit; } // Return the last non-special-min-difficulty-rules-block const CBlockIndex *pindex = pindexPrev; while (pindex->pprev && pindex->nHeight % params.DifficultyAdjustmentInterval() != 0 && pindex->nBits == nProofOfWorkLimit) { pindex = pindex->pprev; } return pindex->nBits; } // We can't go bellow the minimum, so early bail. uint32_t nBits = pindexPrev->nBits; if (nBits == nProofOfWorkLimit) { return nProofOfWorkLimit; } // If producing the last 6 block took less than 12h, we keep the same // difficulty. const CBlockIndex *pindex6 = pindexPrev->GetAncestor(nHeight - 7); assert(pindex6); int64_t mtp6blocks = pindexPrev->GetMedianTimePast() - pindex6->GetMedianTimePast(); if (mtp6blocks < 12 * 3600) { return nBits; } // If producing the last 6 block took more than 12h, increase the difficulty // target by 1/4 (which reduces the difficulty by 20%). This ensure the // chain do not get stuck in case we lose hashrate abruptly. arith_uint256 nPow; nPow.SetCompact(nBits); nPow += (nPow >> 2); // Make sure we do not go bellow allowed values. const arith_uint256 bnPowLimit = UintToArith256(params.powLimit); if (nPow > bnPowLimit) nPow = bnPowLimit; return nPow.GetCompact(); } uint32_t GetNextWorkRequired(const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const Consensus::Params &params) { const int nHeight = pindexPrev->nHeight; // Genesis block if (pindexPrev == nullptr) { return UintToArith256(params.powLimit).GetCompact(); } // Special rule for tnet for first 150 blocks if (params.fPowAllowMinDifficultyBlocks && nHeight <= 150) { return 0x201fffff; } // Special rule for regtest: we never retarget. if (params.fPowNoRetargeting) { return pindexPrev->nBits; } if (pindexPrev->GetMedianTimePast() >= params.coreHardForkActivationTime) { // Get around fork difficulty from Sha256 to Blake2b // (836750 and up + 1 >= 836751) && (836751 through 836760) < 836751 + 10) if (((nHeight + 1) >= params.powBlake2Height) && ((nHeight + 1) < (params.powBlake2Height + 10))) { return 0x1b0ffff0; } // Get around high difficulty from plugging 0x21 version block exploit // If (915000 and up >= 915000) && (915000 through 915034) < 915000 + 35) // if previous height between 915000 and 915034 next height target 1b013833 if ((nHeight >= params.plug0x21ExploitHeight) && (nHeight < (params.plug0x21ExploitHeight + 35))) { return 0x1b013833; } return GetNextCoreWorkRequired(pindexPrev, pblock, params); } return GetNextEDAWorkRequired(pindexPrev, pblock, params); } uint32_t CalculateNextWorkRequired(const CBlockIndex *pindexPrev, int64_t nFirstBlockTime, const Consensus::Params &params) { if (params.fPowNoRetargeting) { return pindexPrev->nBits; } // Limit adjustment step int64_t nActualTimespan = pindexPrev->GetBlockTime() - nFirstBlockTime; if (nActualTimespan < params.nPowTargetTimespan / 4) { nActualTimespan = params.nPowTargetTimespan / 4; } if (nActualTimespan > params.nPowTargetTimespan * 4) { nActualTimespan = params.nPowTargetTimespan * 4; } // Retarget const arith_uint256 bnPowLimit = UintToArith256(params.powLimit); arith_uint256 bnNew; bnNew.SetCompact(pindexPrev->nBits); bnNew *= nActualTimespan; bnNew /= params.nPowTargetTimespan; if (bnNew > bnPowLimit) bnNew = bnPowLimit; return bnNew.GetCompact(); } bool CheckProofOfWork(uint256 hash, uint32_t nBits, const Consensus::Params &params) { bool fNegative; bool fOverflow; arith_uint256 bnTarget; bnTarget.SetCompact(nBits, &fNegative, &fOverflow); // Check range if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) { return false; } // Check proof of work matches claimed amount if (UintToArith256(hash) > bnTarget) { return false; } return true; } /** * Compute the a target based on the work done between 2 blocks and the time * required to produce that work. */ static arith_uint256 ComputeTarget(const CBlockIndex *pindexFirst, const CBlockIndex *pindexLast, const Consensus::Params &params) { assert(pindexLast->nHeight > pindexFirst->nHeight); /** * From the total work done and the time it took to produce that much work, * we can deduce how much work we expect to be produced in the targeted time * between blocks. */ arith_uint256 work = pindexLast->nChainWork - pindexFirst->nChainWork; // In order to avoid difficulty cliffs, we bound the amplitude of the // adjustment we are going to do. assert(pindexLast->nTime > pindexFirst->nTime); int64_t nActualTimespan = pindexLast->nTime - pindexFirst->nTime; // Don't dampen the DAA adjustments on mainnet after 1-min fork if (pindexLast->nHeight < params.oneMinuteBlockHeight) { work *= params.nPowTargetSpacing; if (nActualTimespan > 288 * params.nPowTargetSpacing) { nActualTimespan = 288 * params.nPowTargetSpacing; } else if (nActualTimespan < 72 * params.nPowTargetSpacing) { nActualTimespan = 72 * params.nPowTargetSpacing; } } else { const CBlockIndex *pindex5 = pindexLast->GetAncestor(pindexLast->nHeight - 5); assert(pindex5); int64_t nActualTimespan5 = pindexLast->nTime - pindex5->nTime; int64_t nAdjustedSpacing = params.nPowTargetSpacingOneMinute; // If 5 blocks happened slower than 3x expected, target 100% faster next block. // ie. 5 blocks took >= 15-min if (nActualTimespan5 >= (5 * 3 * params.nPowTargetSpacingOneMinute)) { nAdjustedSpacing /= 2; // Else if 5 blocks happened faster than 3x expected, target 50% slower next. // ie. 5 blocks took <= 1-min 40-sec } else if (nActualTimespan5 <= ( 5 / 3 * params.nPowTargetSpacingOneMinute)) { nAdjustedSpacing *= 2; } work *= nAdjustedSpacing; } work /= nActualTimespan; /** * We need to compute T = (2^256 / W) - 1 but 2^256 doesn't fit in 256 bits. * By expressing 1 as W / W, we get (2^256 - W) / W, and we can compute * 2^256 - W as the complement of W. */ return (-work) / work; } /** * To reduce the impact of timestamp manipulation, we select the block we are * basing our computation on via a median of 3. */ static const CBlockIndex *GetSuitableBlock(const CBlockIndex *pindex) { assert(pindex->nHeight >= 3); /** * In order to avoid a block is a very skewed timestamp to have too much * influence, we select the median of the 3 top most blocks as a starting * point. */ const CBlockIndex *blocks[3]; blocks[2] = pindex; blocks[1] = pindex->pprev; blocks[0] = blocks[1]->pprev; // Sorting network. if (blocks[0]->nTime > blocks[2]->nTime) { std::swap(blocks[0], blocks[2]); } if (blocks[0]->nTime > blocks[1]->nTime) { std::swap(blocks[0], blocks[1]); } if (blocks[1]->nTime > blocks[2]->nTime) { std::swap(blocks[1], blocks[2]); } // We should have our candidate in the middle now. return blocks[1]; } /** * Compute the next required proof of work using a 144-period or 30-period * weighted average of the estimated hashrate per block. * * Using a weighted average ensure that the timestamp parameter cancels out in * most of the calculation - except for the timestamp of the first and last * block. Because timestamps are the least trustworthy information we have as * input, this ensures the algorithm is more resistant to malicious inputs.+ */ uint32_t GetNextCoreWorkRequired(const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const Consensus::Params &params) { // Factor Target Spacing and difficulty adjustment based on 144 or 30 period DAA const int nHeight = pindexPrev->nHeight; int64_t nPowTargetSpacing = params.nPowTargetSpacing; uint32_t nDAAPeriods = 144; if (nHeight > params.oneMinuteBlockHeight) { nPowTargetSpacing = params.nPowTargetSpacingOneMinute; nDAAPeriods = 30; } // This cannot handle the genesis block and early blocks in general. assert(pindexPrev); // Get the last suitable block of the difficulty interval. const CBlockIndex *pindexLast = GetSuitableBlock(pindexPrev); assert(pindexLast); // Get the first suitable block of the difficulty interval. uint32_t nHeightFirst = nHeight - nDAAPeriods; const CBlockIndex *pindexFirst = GetSuitableBlock(pindexPrev->GetAncestor(nHeightFirst)); assert(pindexFirst); // Special difficulty rule for tnet: // If the last 30 blocks took 4 hours on tnet instead of 30-min, // then allow mining of a min-difficulty block. int64_t nActualThirtyBlocksDurationSeconds = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime(); if (params.fPowAllowMinDifficultyBlocks && (nActualThirtyBlocksDurationSeconds > pindexLast->GetBlockTime() + 240 * nPowTargetSpacing)) { return UintToArith256(params.powLimit).GetCompact(); } // Compute the target based on time and work done during the interval. const arith_uint256 nextTarget = ComputeTarget(pindexFirst, pindexLast, params); const arith_uint256 powLimit = UintToArith256(params.powLimit); if (nextTarget > powLimit) { return powLimit.GetCompact(); } return nextTarget.GetCompact(); }
[ "klauskirkeby@hotmail.com" ]
klauskirkeby@hotmail.com
aee43a25137bc556ef9ca6129a17ca6f60064846
aedb5d78cbe6acaf9becea0ea7b43c46a9584f5e
/framework/base/selfwidget/treemode/rtreemodel.h
c62cdb90c0428d84a5b06053729844ad379e9743
[]
no_license
wey580231/Framewrok
60a922d4cc868b0d0b7f87a529eab2724ca3c18f
1050b079997a975dcc7b64e1bfa5eb8acb72d8c4
refs/heads/develop
2023-03-15T04:36:18.608430
2021-03-23T14:30:51
2021-03-23T14:30:51
326,935,482
0
1
null
2021-03-23T14:30:52
2021-01-05T08:31:30
C++
UTF-8
C++
false
false
2,519
h
/*! * @brief 通用树据模型 * @details * @author wey * @version 1.0 * @date 2018.12.25 * @warning * @copyright NanJing RenGu. * @note */ #ifndef NAVIGATEMODEL_H #define NAVIGATEMODEL_H #include <QAbstractItemModel> #include "../../base_global.h" namespace Base { /*! * @brief 单个树节点 * @warning 创建节点时一定要设置节点的parentNode信息 */ struct TreeNode{ TreeNode():parentNode(NULL),nodeLevel(0),nodeData(NULL),nodeChecked(false){} int childIndex() const{ if (parentNode) return parentNode->nodes.indexOf(const_cast<TreeNode*>(this)); return 0; } int nodeId; QString nodeName; int nodeLevel; /*!< 树节点类型 (自定义类型,自行转换成需要的数据类型) >*/ bool nodeChecked; /*!< 是否被勾选(二级功能节点有效) */ void * nodeData; /*!< 节点绑定的数据 */ TreeNode * parentNode; QList<TreeNode *> nodes; }; class BASESHARED_EXPORT RTreeModel : public QAbstractItemModel { Q_OBJECT public: explicit RTreeModel(QObject *parent = Q_NULLPTR); ~RTreeModel(); QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)Q_DECL_OVERRIDE; QVariant headerData(int section, Qt::Orientation orientation,int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; QModelIndex parentIndexFromNode(TreeNode * node); QModelIndex indexFromNode(TreeNode* node); void refreshModel(); void setHeaderData(QStringList headList); void addRootNode(TreeNode *node); void removeRootNode(TreeNode *node); int rootNodeSize(); void clearModel(); void setVirtualRootNode(TreeNode * node); TreeNode *virtualTreeRootNode(){return rootNode;} protected: TreeNode * rootNode; /*!< 虚拟根节点,不参与显示 */ QStringList headList; /*!< 头信息节点 */ }; } //namespace Base #endif // NAVIGATEMODEL_H
[ "407859345@qq.com" ]
407859345@qq.com
5a66f045efaca9f00d4706d5f1c6ab050aefbdf2
13a39681376455c8f47d40084a64265c6bc71d65
/动态规划+/矩阵连乘问题/1.cpp
2e64eba5036128c7d774d776d433b518452031eb
[]
no_license
Jonathan-Jiang/Algorithm
f85bbef96c82861f26d0383ef069761f40b125de
5dc6af8d7854d3ea2ad60237bcc1f21652c728fa
refs/heads/master
2021-05-28T11:40:19.002992
2015-01-07T06:34:34
2015-01-07T06:34:34
null
0
0
null
null
null
null
GB18030
C++
false
false
1,762
cpp
#include <iostream> using namespace std; const int cnt = 5; // A1 A2 A3 A4 A5 // 30 * 15 // 15 * 25 // 25 * 5 // 5 * 10 // 10 * 20 // p0 p1 p2 p3 p4 p5 int p[cnt + 1] = { 30, 15, 25, 5, 10, 20 }; // 递归实现 int less(int i, int j) { if (i == j) return 0; int min = less(i, i) + less(i + 1, j) + p[i - 1] * p[i] * p[j]; for (int k = i + 1; k < j; ++k) { int t = less(i, k) + less(k + 1, j) + p[i - 1] * p[k] * p[j]; if (min > t) min = t; } return min; } // 非递归实现 int v[cnt + 1][cnt + 1]; // 通过 kmap 可以找出计算顺序 int kmap[cnt + 1][cnt + 1]; void less() { memset(v, 0, sizeof(v)); memset(kmap, 0, sizeof(kmap)); for (int i = cnt; i >= 1; --i) { for (int j = 1; j <= cnt; ++j) { if (i >= j) v[i][j] = 0; else { v[i][j] = v[i][i] + v[i + 1][j] + p[i - 1] * p[i] * p[j]; kmap[i][j] = i; for (int k = i + 1; k < j; ++k) { int t = v[i][k] + v[k + 1][j] + p[i - 1] * p[k] * p[j]; if (v[i][j] > t) { v[i][j] = t; kmap[i][j] = k; } } } } } } // print order void DPMatrixChain(int i, int j, int s[][cnt + 1]) { if (i != j) { DPMatrixChain(i, s[i][j], s); DPMatrixChain(s[i][j] + 1, j, s); printf("A[%d : %d]: broken: A[%d : %d] and A[%d : %d]\n", i, j, i, s[i][j], s[i][j] + 1, j); } } int main(int argc, const char* argv[]) { // cout << less(1, 5) << endl; less(); cout << v[1][cnt] << endl; #define DEBUG #ifdef DEBUG for (int i = 1; i <= cnt; ++i) { for (int j = 1; j <= cnt; ++j) { cout << v[i][j] << "\t"; if (j == cnt) cout << endl; } } cout << endl; for (i = 1; i <= cnt; ++i) { for (int j = 1; j <= cnt; ++j) { cout << kmap[i][j] << "\t"; if (j == cnt) cout << endl; } } #endif DPMatrixChain(1, 5, kmap); return 0; }
[ "daishengdong@gmail.com" ]
daishengdong@gmail.com
3f88760e8246435d2068e4dc9092b3ed9091b662
a81c07a5663d967c432a61d0b4a09de5187be87b
/components/viz/common/features.h
337dd335e4387c52960d1339bbd58dd85e824780
[ "BSD-3-Clause" ]
permissive
junxuezheng/chromium
c401dec07f19878501801c9e9205a703e8643031
381ce9d478b684e0df5d149f59350e3bc634dad3
refs/heads/master
2023-02-28T17:07:31.342118
2019-09-03T01:42:42
2019-09-03T01:42:42
205,967,014
2
0
BSD-3-Clause
2019-09-03T01:48:23
2019-09-03T01:48:23
null
UTF-8
C++
false
false
1,085
h
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_VIZ_COMMON_FEATURES_H_ #define COMPONENTS_VIZ_COMMON_FEATURES_H_ #include "components/viz/common/viz_common_export.h" #include "base/feature_list.h" namespace features { VIZ_COMMON_EXPORT extern const base::Feature kEnableVizHitTestSurfaceLayer; VIZ_COMMON_EXPORT extern const base::Feature kUseSkiaForGLReadback; VIZ_COMMON_EXPORT extern const base::Feature kUseSkiaRenderer; VIZ_COMMON_EXPORT extern const base::Feature kRecordSkPicture; VIZ_COMMON_EXPORT extern const base::Feature kVizDisplayCompositor; VIZ_COMMON_EXPORT bool IsVizDisplayCompositorEnabled(); VIZ_COMMON_EXPORT bool IsVizHitTestingDebugEnabled(); VIZ_COMMON_EXPORT bool IsVizHitTestingSurfaceLayerEnabled(); VIZ_COMMON_EXPORT bool IsUsingSkiaForGLReadback(); VIZ_COMMON_EXPORT bool IsUsingSkiaRenderer(); VIZ_COMMON_EXPORT bool IsRecordingSkPicture(); } // namespace features #endif // COMPONENTS_VIZ_COMMON_FEATURES_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
cb7fbe3c44d888eb3570bb9f5b31049e30138ea6
39c1673b3bb230861d2b42bad8d0fbd899d3f4fa
/Contest3/Bai4.cpp
faea58304069a5af5162fe433cb8df406df3f68e
[]
no_license
trickstarcandina/CTDL
69b9b205f1b792cce9db894520d4b1a4c0ad9a4a
5ab3e7e8be6f1a6e2f26e9de880495383d95dd84
refs/heads/master
2022-12-28T05:36:00.146268
2020-10-17T08:51:39
2020-10-17T08:51:39
304,835,997
5
0
null
null
null
null
UTF-8
C++
false
false
3,700
cpp
#include<bits/stdc++.h> using namespace std; const int MOD=1000000007; void nhap(int n,int a[]){ for(int i=0;i<n;i++){ cin>>a[i]; } } long long xuly(int n, int a[]) { sort(a, a + n); long long x = 0, y = 0; for (int i = 0; i < n; i++) { if (i%2==1) x = x*10 + a[i]; else y = y*10 + a[i]; } return x + y; } main(){ int t; cin>>t; while (t--){ int n; cin>>n; int a[n]; nhap(n,a); cout<<xuly(n,a)<<endl; } } /* Trickstar Candina _,add8ba, ,d888888888b, d8888888888888b _,ad8ba,_ d888888888888888) ,d888888888b, I8888888888888888 _________ ,8888888888888b __________`Y88888888888888P"""""""""""baaa,__ ,888888888888888, ,adP"""""""""""9888888888P""^ ^""Y8888888888888888I ,a8"^ ,d888P"888P^ ^"Y8888888888P' ,a8^ ,d8888' ^Y8888888P' a88' ,d8888P' I88P"^ ,d88' d88888P' "b, ,d88' d888888' `b, ,d88' d888888I `b, d88I ,8888888' ___ `b, ,888' d8888888 ,d88888b, ____ `b, d888 ,8888888I d88888888b, ,d8888b, `b ,8888 I8888888I d8888888888I ,88888888b 8, I8888 88888888b d88888888888' 8888888888b 8I d8886 888888888 Y888888888P' Y8888888888, ,8b 88888b I88888888b `Y8888888^ `Y888888888I d88, Y88888b `888888888b, `""""^ `Y8888888P' d888I `888888b 88888888888b, `Y8888P^ d88888 Y888888b ,8888888888888ba,_ _______ `""^ ,d888888 I8888888b, ,888888888888888888ba,_ d88888888b ,ad8888888I `888888888b, I8888888888888888888888b, ^"Y888P"^ ____.,ad88888888888I 88888888888b,`888888888888888888888888b, "" ad888888888888888888888' 8888888888888698888888888888888888888888b_,ad88ba,_,d88888888888888888888888 88888888888888888888888888888888888888888b,`"""^ d8888888888888888888888888I 8888888888888888888888888888888888888888888baaad888888888888888888888888888' Y8888888888888888888888888888888888888888888888888888888888888888888888888P I888888888888888888888888888888888888888888888P^ ^Y8888888888888888888888' `Y88888888888888888P88888888888888888888888888' ^88888888888888888888I `Y8888888888888888 `8888888888888888888888888 8888888888888888888P' `Y888888888888888 `888888888888888888888888, ,888888888888888888P' `Y88888888888888b `88888888888888888888888I I888888888888888888' "Y8888888888888b `8888888888888888888888I I88888888888888888' "Y88888888888P `888888888888888888888b d8888888888888888' ^""""""""^ `Y88888888888888888888, 888888888888888P' "8888888888888888888b, Y888888888888P^ `Y888888888888888888b `Y8888888P"^ "Y8888888888888888P `""""^ `"YY88888888888P' ^""""""""' */
[ "61593963+rinnegan101220@users.noreply.github.com" ]
61593963+rinnegan101220@users.noreply.github.com
0eac78e3a9d4e85cada41bac8bdb334540061c6b
15417ed67cfdfa56e30c53031305d0fc0e01e838
/mango/math/vector128_int16x8.hpp
a87464a38f0fd588ffa9a8e4b40a1376c1b37e3b
[]
no_license
atkurtul/VulkanSample
84bbfe37655139fe7d8076fb4fa491fda6a7c254
f320ed7863f48564669f5415f4f4f0e57c576ae2
refs/heads/master
2023-02-24T03:13:08.369897
2020-07-14T07:55:21
2020-07-14T07:55:21
279,509,861
10
2
null
null
null
null
UTF-8
C++
false
false
8,913
hpp
/* MANGO Multimedia Development Platform Copyright (C) 2012-2020 Twilight Finland 3D Oy Ltd. All rights reserved. */ #pragma once #include "vector.hpp" namespace mango { template <> struct Vector<s16, 8> { using VectorType = simd::s16x8; using ScalarType = s16; enum { VectorSize = 8 }; VectorType m; ScalarType& operator [] (size_t index) { assert(index < VectorSize); return data()[index]; } ScalarType operator [] (size_t index) const { assert(index < VectorSize); return data()[index]; } ScalarType* data() { return reinterpret_cast<ScalarType *>(this); } const ScalarType* data() const { return reinterpret_cast<const ScalarType *>(this); } explicit Vector() {} Vector(s16 s) : m(simd::s16x8_set(s)) { } Vector(s16 s0, s16 s1, s16 s2, s16 s3, s16 s4, s16 s5, s16 s6, s16 s7) : m(simd::s16x8_set(s0, s1, s2, s3, s4, s5, s6, s7)) { } Vector(simd::s16x8 v) : m(v) { } template <typename T, int I> Vector& operator = (const ScalarAccessor<ScalarType, T, I>& accessor) { *this = ScalarType(accessor); return *this; } Vector(const Vector& v) = default; Vector& operator = (const Vector& v) { m = v.m; return *this; } Vector& operator = (simd::s16x8 v) { m = v; return *this; } Vector& operator = (s16 s) { m = simd::s16x8_set(s); return *this; } operator simd::s16x8 () const { return m; } #ifdef int128_is_hardware_vector operator simd::s16x8::vector () const { return m.data; } #endif }; template <> inline Vector<s16, 8> load_low<s16, 8>(const s16 *source) { return simd::s16x8_load_low(source); } static inline void store_low(s16 *dest, Vector<s16, 8> v) { simd::s16x8_store_low(dest, v); } static inline const Vector<s16, 8> operator + (Vector<s16, 8> v) { return v; } static inline Vector<s16, 8> operator - (Vector<s16, 8> v) { return simd::neg(v); } static inline Vector<s16, 8>& operator += (Vector<s16, 8>& a, Vector<s16, 8> b) { a = simd::add(a, b); return a; } static inline Vector<s16, 8>& operator -= (Vector<s16, 8>& a, Vector<s16, 8> b) { a = simd::sub(a, b); return a; } static inline Vector<s16, 8> operator + (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::add(a, b); } static inline Vector<s16, 8> operator - (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::sub(a, b); } static inline Vector<s16, 8> unpacklo(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::unpacklo(a, b); } static inline Vector<s16, 8> unpackhi(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::unpackhi(a, b); } static inline Vector<s16, 8> abs(Vector<s16, 8> a) { return simd::abs(a); } static inline Vector<s16, 8> abs(Vector<s16, 8> a, mask16x8 mask) { return simd::abs(a, mask); } static inline Vector<s16, 8> abs(Vector<s16, 8> a, mask16x8 mask, Vector<s16, 8> value) { return simd::abs(a, mask, value); } static inline Vector<s16, 8> add(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask) { return simd::add(a, b, mask); } static inline Vector<s16, 8> add(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask, Vector<s16, 8> value) { return simd::add(a, b, mask, value); } static inline Vector<s16, 8> sub(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask) { return simd::sub(a, b, mask); } static inline Vector<s16, 8> sub(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask, Vector<s16, 8> value) { return simd::sub(a, b, mask, value); } static inline Vector<s16, 8> adds(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::adds(a, b); } static inline Vector<s16, 8> adds(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask) { return simd::adds(a, b, mask); } static inline Vector<s16, 8> adds(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask, Vector<s16, 8> value) { return simd::adds(a, b, mask, value); } static inline Vector<s16, 8> subs(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::subs(a, b); } static inline Vector<s16, 8> subs(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask) { return simd::subs(a, b, mask); } static inline Vector<s16, 8> subs(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask, Vector<s16, 8> value) { return simd::subs(a, b, mask, value); } static inline Vector<s16, 8> hadd(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::hadd(a, b); } static inline Vector<s16, 8> hsub(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::hsub(a, b); } static inline Vector<s16, 8> hadds(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::hadds(a, b); } static inline Vector<s16, 8> hsubs(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::hsubs(a, b); } static inline Vector<s16, 8> min(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::min(a, b); } static inline Vector<s16, 8> min(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask) { return simd::min(a, b, mask); } static inline Vector<s16, 8> min(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask, Vector<s16, 8> value) { return simd::min(a, b, mask, value); } static inline Vector<s16, 8> max(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::max(a, b); } static inline Vector<s16, 8> max(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask) { return simd::max(a, b, mask); } static inline Vector<s16, 8> max(Vector<s16, 8> a, Vector<s16, 8> b, mask16x8 mask, Vector<s16, 8> value) { return simd::max(a, b, mask, value); } static inline Vector<s16, 8> clamp(Vector<s16, 8> a, Vector<s16, 8> low, Vector<s16, 8> high) { return simd::clamp(a, low, high); } // ------------------------------------------------------------------ // bitwise operators // ------------------------------------------------------------------ static inline Vector<s16, 8> nand(Vector<s16, 8> a, Vector<s16, 8> b) { return simd::bitwise_nand(a, b); } static inline Vector<s16, 8> operator & (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::bitwise_and(a, b); } static inline Vector<s16, 8> operator | (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::bitwise_or(a, b); } static inline Vector<s16, 8> operator ^ (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::bitwise_xor(a, b); } static inline Vector<s16, 8> operator ~ (Vector<s16, 8> a) { return simd::bitwise_not(a); } // ------------------------------------------------------------------ // compare / select // ------------------------------------------------------------------ static inline mask16x8 operator > (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::compare_gt(a, b); } static inline mask16x8 operator >= (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::compare_ge(a, b); } static inline mask16x8 operator < (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::compare_lt(a, b); } static inline mask16x8 operator <= (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::compare_le(a, b); } static inline mask16x8 operator == (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::compare_eq(a, b); } static inline mask16x8 operator != (Vector<s16, 8> a, Vector<s16, 8> b) { return simd::compare_neq(a, b); } static inline Vector<s16, 8> select(mask16x8 mask, Vector<s16, 8> a, Vector<s16, 8> b) { return simd::select(mask, a, b); } // ------------------------------------------------------------------ // shift // ------------------------------------------------------------------ static inline Vector<s16, 8> operator << (Vector<s16, 8> a, int b) { return simd::sll(a, b); } static inline Vector<s16, 8> operator >> (Vector<s16, 8> a, int b) { return simd::sra(a, b); } } // namespace mango
[ "atilkurtulmus@gmail.com" ]
atilkurtulmus@gmail.com
499e15d2a484da02ff68d7a22c7a5a0d2962abc6
0ba2ebb2042fae43162c246888ec666bbfe0fb6f
/Digital_simulation/Generators.cpp
b31e2591501a917fee98a3e64a101d48c60219fc
[]
no_license
PawelKozminskiPoznan/Digital_simulation
b8f063d668e869621dbcfec444b7d2ddd56b6f80
a79ec1837178d451a840a61c0e32a0ee2ca4058f
refs/heads/master
2022-06-04T08:21:05.467486
2020-04-27T14:33:59
2020-04-27T14:33:59
258,534,373
0
0
null
null
null
null
UTF-8
C++
false
false
2,977
cpp
#include "pch.h" #include "Generators.h" #include <iostream> using namespace std; double Generators::generateGrain() { int h =abs(grain / q); grain = a * (grain - q * h) - r * h; if (grain < 0) grain = grain + m; return grain; } double Generators::uniform() { grain = grain * a % m; return abs(static_cast<double>(grain)/m); } int Generators::generateUniform(const int min,const int max) { return (int)uniform()*(max - min) + min; } int Generators::generateNormal(int average, double var) { double k = 0; for(int i=0;i<12;i++) { k += uniform(); } k = k - 6; k = sqrt(var)*k + average; return (int)k; } int Generators::generateExponentinal(double lambda) { lambda = 1 / lambda; return (int)(-(1.0 / lambda)*log(uniform())); } int Generators::generateGeometric(double average) { int k = 1; /* while (uniform()>average) { ++k; } return k; */ while (true) { if (uniform() > average) { k++; continue; } break; } return k; } /* void Generators::testGenerateExponentinal(double lambda,int samples) { double average = 0; int result; lambda = 1 / lambda; cout << "Start Test Exponential Generator." << endl; for (int i = 0; i < samples; ++i) { result = -1 / lambda * log(uniform()); stat->saveStatsToFile(result, "exponential.xls"); average = average + result; } cout << "average : " << average / samples << endl; } void Generators::testGenerateGeometric(double w,int samples) { cout << "Start Test Geometric Generator." << endl; double ave = 0; int result; for (auto i = 0; i < samples; ++i) { result = 1; while (true) { if (uniform() > w) { result++; continue; } break; } stat->saveStatsToFile(result, "geometric.xls"); ave = ave + result; } cout << "w : " << 1 / (ave / samples) << endl; cout << "average : " << double(ave / samples) << endl; } void Generators::testGenerateNormal(const double e, const double ew, const int samples) { cout << "Start Test Normal Generator." << endl; double average = 0; int result; for (auto i = 0; i < samples; ++i) { result = 0; double temp = 0; for (auto index = 0; index < 12; index++) { temp += uniform(); } temp -= 6.0; result= temp * ew + e; stat->saveStatsToFile(result, "normal.xls"); average = average + result; } cout << "average : " << average / samples << endl; } void Generators::testGenerateUniform(int min, int max,int samples) { double average = 0; double numberUniform = 0; cout << "Start Test Uniform Generator." << endl; generateGrain(); for (auto i = 0; i < samples; ++i) { numberUniform = min + (max - min) * uniform(); stat->saveStatsToFile(numberUniform, "uniform.xls"); average = average + numberUniform; } cout << "average : " << average / samples << endl; } */ Generators::Generators()//Statistics *s :stat(s) { m = 2147483647; a = 16807; q = 127773; r = 2836; grain = 1179; } Generators::~Generators() { }
[ "pawel.kozminski.poznan@gmai.com" ]
pawel.kozminski.poznan@gmai.com
b13b8c01ccc269f59e50bd95957cc9848e63e41c
737db09fabf1a6255d80e2c6d42f1c84ac6bc5ff
/test.cpp
c8ee0b2a6a04204614486ecdbf56481dd8c6b9b5
[]
no_license
hyunoklee/pcsetting
b6de82958a6193dac6b1623164af2c1660c65468
6621f9bf2b362138e5fab7f32a5548fdd1f825b3
refs/heads/master
2020-04-06T21:58:43.110027
2019-11-02T01:09:10
2019-11-02T01:09:10
157,820,849
0
0
null
null
null
null
UTF-8
C++
false
false
23,345
cpp
/* * YoloObjectDetector.cpp * * Created on: Dec 19, 2016 * Author: Marko Bjelonic * Institute: ETH Zurich, Robotic Systems Lab */ // yolo object detector #include "darknet_ros/YoloObjectDetector.hpp" // Check for xServer #include <X11/Xlib.h> #ifdef DARKNET_FILE_PATH std::string darknetFilePath_ = DARKNET_FILE_PATH; #else #error Path of darknet repository is not defined in CMakeLists.txt. #endif namespace darknet_ros { char *cfg; char *weights; char *data; char **detectionNames; YoloObjectDetector::YoloObjectDetector(ros::NodeHandle nh) : nodeHandle_(nh), imageTransport_(nodeHandle_), numClasses_(0), classLabels_(0), rosBoxes_(0), rosBoxCounter_(0), imagergb_sub(imageTransport_,"/om_with_tb3/camera/rgb/image_raw",1), //For depth inclussion imagedepth_sub(imageTransport_,"/om_with_tb3/camera/depth/image_raw",1), //For depth inclussion sync_1(MySyncPolicy_1(5), imagergb_sub, imagedepth_sub) //For depth inclussion { ROS_INFO("[YoloObjectDetector] Node started."); // Read parameters from config file. if (!readParameters()) { ros::requestShutdown(); } init(); } YoloObjectDetector::~YoloObjectDetector() { { boost::unique_lock<boost::shared_mutex> lockNodeStatus(mutexNodeStatus_); isNodeRunning_ = false; } yoloThread_.join(); } bool YoloObjectDetector::readParameters() { // Load common parameters. nodeHandle_.param("image_view/enable_opencv", viewImage_, true); nodeHandle_.param("image_view/wait_key_delay", waitKeyDelay_, 3); nodeHandle_.param("image_view/enable_console_output", enableConsoleOutput_, false); // Check if Xserver is running on Linux. if (XOpenDisplay(NULL)) { // Do nothing! ROS_INFO("[YoloObjectDetector] Xserver is running."); } else { ROS_INFO("[YoloObjectDetector] Xserver is not running."); viewImage_ = false; } // Set vector sizes. nodeHandle_.param("yolo_model/detection_classes/names", classLabels_, std::vector<std::string>(0)); numClasses_ = classLabels_.size(); rosBoxes_ = std::vector<std::vector<RosBox_> >(numClasses_); rosBoxCounter_ = std::vector<int>(numClasses_); return true; } void YoloObjectDetector::init() { ROS_INFO("[YoloObjectDetector] init()."); // Initialize deep network of darknet. std::string weightsPath; std::string configPath; std::string dataPath; std::string configModel; std::string weightsModel; // Threshold of object detection. float thresh; nodeHandle_.param("yolo_model/threshold/value", thresh, (float) 0.3); // Path to weights file. nodeHandle_.param("yolo_model/weight_file/name", weightsModel, std::string("yolov2-tiny.weights")); nodeHandle_.param("weights_path", weightsPath, std::string("/default")); weightsPath += "/" + weightsModel; weights = new char[weightsPath.length() + 1]; strcpy(weights, weightsPath.c_str()); // Path to config file. nodeHandle_.param("yolo_model/config_file/name", configModel, std::string("yolov2-tiny.cfg")); nodeHandle_.param("config_path", configPath, std::string("/default")); configPath += "/" + configModel; cfg = new char[configPath.length() + 1]; strcpy(cfg, configPath.c_str()); // Path to data folder. dataPath = darknetFilePath_; dataPath += "/data"; data = new char[dataPath.length() + 1]; strcpy(data, dataPath.c_str()); // Get classes. detectionNames = (char**) realloc((void*) detectionNames, (numClasses_ + 1) * sizeof(char*)); for (int i = 0; i < numClasses_; i++) { detectionNames[i] = new char[classLabels_[i].length() + 1]; strcpy(detectionNames[i], classLabels_[i].c_str()); } // Load network. setupNetwork(cfg, weights, data, thresh, detectionNames, numClasses_, 0, 0, 1, 0.5, 0, 0, 0, 0); yoloThread_ = std::thread(&YoloObjectDetector::yolo, this); // Initialize publisher and subscriber. std::string cameraTopicName; int cameraQueueSize; std::string objectDetectorTopicName; int objectDetectorQueueSize; bool objectDetectorLatch; std::string boundingBoxesTopicName; int boundingBoxesQueueSize; bool boundingBoxesLatch; std::string detectionImageTopicName; int detectionImageQueueSize; bool detectionImageLatch; std::string labelImageTopicName; int labelImageQueueSize; bool labelImageLatch; nodeHandle_.param("subscribers/camera_reading/topic", cameraTopicName, std::string("/camera/image_raw")); nodeHandle_.param("subscribers/camera_reading/queue_size", cameraQueueSize, 1); nodeHandle_.param("publishers/object_detector/topic", objectDetectorTopicName, std::string("found_object")); nodeHandle_.param("publishers/object_detector/queue_size", objectDetectorQueueSize, 1); nodeHandle_.param("publishers/object_detector/latch", objectDetectorLatch, false); nodeHandle_.param("publishers/bounding_boxes/topic", boundingBoxesTopicName, std::string("bounding_boxes")); nodeHandle_.param("publishers/bounding_boxes/queue_size", boundingBoxesQueueSize, 1); nodeHandle_.param("publishers/bounding_boxes/latch", boundingBoxesLatch, false); nodeHandle_.param("publishers/detection_image/topic", detectionImageTopicName, std::string("detection_image")); nodeHandle_.param("publishers/detection_image/queue_size", detectionImageQueueSize, 1); nodeHandle_.param("publishers/detection_image/latch", detectionImageLatch, true); nodeHandle_.param("publishers/label_image/topic", labelImageTopicName, std::string("label_image")); nodeHandle_.param("publishers/label_image/queue_size", labelImageQueueSize, 1); nodeHandle_.param("publishers/label_image/latch", labelImageLatch, true); //imageSubscriber_ = imageTransport_.subscribe(cameraTopicName, cameraQueueSize,&YoloObjectDetector::cameraCallback, this); sync_1.registerCallback(boost::bind(&YoloObjectDetector::cameraCallback,this,_1,_2)); //For depth inclussion objectPublisher_ = nodeHandle_.advertise<std_msgs::Int8>(objectDetectorTopicName, objectDetectorQueueSize, objectDetectorLatch); boundingBoxesPublisher_ = nodeHandle_.advertise<darknet_ros_msgs::BoundingBoxes>( boundingBoxesTopicName, boundingBoxesQueueSize, boundingBoxesLatch); detectionImagePublisher_ = nodeHandle_.advertise<sensor_msgs::Image>(detectionImageTopicName, detectionImageQueueSize, detectionImageLatch); labelImagePublisher_ = nodeHandle_.advertise<sensor_msgs::Image>(labelImageTopicName, labelImageQueueSize, labelImageLatch); // Action servers. std::string checkForObjectsActionName; nodeHandle_.param("actions/camera_reading/topic", checkForObjectsActionName, std::string("check_for_objects")); checkForObjectsActionServer_.reset( new CheckForObjectsActionServer(nodeHandle_, checkForObjectsActionName, false)); checkForObjectsActionServer_->registerGoalCallback( boost::bind(&YoloObjectDetector::checkForObjectsActionGoalCB, this)); checkForObjectsActionServer_->registerPreemptCallback( boost::bind(&YoloObjectDetector::checkForObjectsActionPreemptCB, this)); checkForObjectsActionServer_->start(); } //void YoloObjectDetector::cameraCallback(const sensor_msgs::ImageConstPtr& msg) void YoloObjectDetector::cameraCallback(const sensor_msgs::ImageConstPtr& msg, const sensor_msgs::ImageConstPtr& msgdepth) { ROS_DEBUG("[YoloObjectDetector] USB image received."); cv_bridge::CvImagePtr cam_image; cv_bridge::CvImageConstPtr cam_depth; try { cam_image = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8); cam_depth = cv_bridge::toCvCopy(msgdepth, sensor_msgs::image_encodings::TYPE_32FC1); //cam_depth = cv_bridge::toCvCopy(msgdepth, sensor_msgs::image_encodings::MONO8); } catch (cv_bridge::Exception& e) { ROS_ERROR("cv_bridge exception: %s", e.what()); return; } if (cam_image) { { boost::unique_lock<boost::shared_mutex> lockImageCallback(mutexImageCallback_); imageHeader_ = msg->header; camImageCopy_ = cam_image->image.clone(); } { boost::unique_lock<boost::shared_mutex> lockImageStatus(mutexImageStatus_); imageStatus_ = true; } frameWidth_ = cam_image->image.size().width; frameHeight_ = cam_image->image.size().height; } if (cam_depth) { DepthImageCopy_ = cam_depth->image.clone(); } //ros::Duration(0.1).sleep(); return; } void YoloObjectDetector::checkForObjectsActionGoalCB() { ROS_DEBUG("[YoloObjectDetector] Start check for objects action."); boost::shared_ptr<const darknet_ros_msgs::CheckForObjectsGoal> imageActionPtr = checkForObjectsActionServer_->acceptNewGoal(); sensor_msgs::Image imageAction = imageActionPtr->image; cv_bridge::CvImagePtr cam_image; try { cam_image = cv_bridge::toCvCopy(imageAction, sensor_msgs::image_encodings::BGR8); } catch (cv_bridge::Exception& e) { ROS_ERROR("cv_bridge exception: %s", e.what()); return; } if (cam_image) { { boost::unique_lock<boost::shared_mutex> lockImageCallback(mutexImageCallback_); camImageCopy_ = cam_image->image.clone(); } { boost::unique_lock<boost::shared_mutex> lockImageCallback(mutexActionStatus_); actionId_ = imageActionPtr->id; } { boost::unique_lock<boost::shared_mutex> lockImageStatus(mutexImageStatus_); imageStatus_ = true; } frameWidth_ = cam_image->image.size().width; frameHeight_ = cam_image->image.size().height; } return; } void YoloObjectDetector::checkForObjectsActionPreemptCB() { ROS_DEBUG("[YoloObjectDetector] Preempt check for objects action."); checkForObjectsActionServer_->setPreempted(); } bool YoloObjectDetector::isCheckingForObjects() const { return (ros::ok() && checkForObjectsActionServer_->isActive() && !checkForObjectsActionServer_->isPreemptRequested()); } bool YoloObjectDetector::publishDetectionImage(const cv::Mat& detectionImage) { if (detectionImagePublisher_.getNumSubscribers() < 1) return false; cv_bridge::CvImage cvImage; cvImage.header.stamp = ros::Time::now(); cvImage.header.frame_id = "detection_image"; cvImage.encoding = sensor_msgs::image_encodings::BGR8; cvImage.image = detectionImage; detectionImagePublisher_.publish(*cvImage.toImageMsg()); ROS_DEBUG("Detection image has been published."); return true; } bool YoloObjectDetector::publishLabelImage(const cv::Mat& labelImage) { if (labelImagePublisher_.getNumSubscribers() < 1) return false; cv_bridge::CvImage cvImage; cvImage.header.stamp = ros::Time::now(); cvImage.header.frame_id = "detection_image"; cvImage.encoding = sensor_msgs::image_encodings::TYPE_32SC1; cvImage.image = labelImage; labelImagePublisher_.publish(*cvImage.toImageMsg()); ROS_DEBUG("Label image has been published."); return true; } // double YoloObjectDetector::getWallTime() // { // struct timeval time; // if (gettimeofday(&time, NULL)) { // return 0; // } // return (double) time.tv_sec + (double) time.tv_usec * .000001; // } int YoloObjectDetector::sizeNetwork(network *net) { int i; int count = 0; for(i = 0; i < net->n; ++i){ layer l = net->layers[i]; if(l.type == YOLO || l.type == REGION || l.type == DETECTION){ count += l.outputs; } } return count; } void YoloObjectDetector::rememberNetwork(network *net) { int i; int count = 0; for(i = 0; i < net->n; ++i){ layer l = net->layers[i]; if(l.type == YOLO || l.type == REGION || l.type == DETECTION){ memcpy(predictions_[demoIndex_] + count, net->layers[i].output, sizeof(float) * l.outputs); count += l.outputs; } } } detection *YoloObjectDetector::avgPredictions(network *net, int *nboxes) { int i, j; int count = 0; fill_cpu(demoTotal_, 0, avg_, 1); for(j = 0; j < demoFrame_; ++j){ axpy_cpu(demoTotal_, 1./demoFrame_, predictions_[j], 1, avg_, 1); } for(i = 0; i < net->n; ++i){ layer l = net->layers[i]; if(l.type == YOLO || l.type == REGION || l.type == DETECTION){ memcpy(l.output, avg_ + count, sizeof(float) * l.outputs); count += l.outputs; } } detection *dets = get_network_boxes(net, buff_[0].w, buff_[0].h, demoThresh_, demoHier_, 0, 1, nboxes); return dets; } void *YoloObjectDetector::detectInThread() { running_ = 1; float nms = .4; layer l = net_->layers[net_->n - 1]; float *X = buffLetter_[(buffIndex_ + 2) % 3].data; float *prediction = network_predict(net_, X); rememberNetwork(net_); detection *dets = 0; int nboxes = 0; dets = avgPredictions(net_, &nboxes); if (nms > 0) do_nms_obj(dets, nboxes, l.classes, nms); if (enableConsoleOutput_) { //printf("\033[2J"); //printf("\033[1;1H"); //printf("\nFPS:%.1f\n",fps_); //printf("Objectss:\n\n"); } image display = buff_[(buffIndex_+2) % 3]; cv::Mat label_im(display.h, display.w, CV_32SC1, cv::Scalar::all(0)); draw_detections(display, dets, nboxes, demoThresh_, demoNames_, demoAlphabet_, demoClasses_); // extract the bounding boxes and send them to ROS int i, j; int count = 0; for (i = 0; i < nboxes; ++i) { float xmin = dets[i].bbox.x - dets[i].bbox.w / 2.; float xmax = dets[i].bbox.x + dets[i].bbox.w / 2.; float ymin = dets[i].bbox.y - dets[i].bbox.h / 2.; float ymax = dets[i].bbox.y + dets[i].bbox.h / 2.; if (xmin < 0) xmin = 0; if (ymin < 0) ymin = 0; if (xmax > 1) xmax = 1; if (ymax > 1) ymax = 1; // iterate through possible boxes and collect the bounding boxes for (j = 0; j < demoClasses_; ++j) { if (dets[i].prob[j]) { float x_center = (xmin + xmax) / 2; float y_center = (ymin + ymax) / 2; float BoundingBox_width = xmax - xmin; float BoundingBox_height = ymax - ymin; // define bounding box // BoundingBox must be 1% size of frame (3.2x2.4 pixels) if (BoundingBox_width > 0.01 && BoundingBox_height > 0.01) { // set label image cv::rectangle(label_im, cv::Point(xmin*label_im.cols,ymin*label_im.rows), cv::Point(xmax*label_im.cols,ymax*label_im.rows), cv::Scalar::all(j+1), CV_FILLED); // label using (class number + 1) to reserve 0 for background roiBoxes_[count].x = x_center; roiBoxes_[count].y = y_center; roiBoxes_[count].w = BoundingBox_width; roiBoxes_[count].h = BoundingBox_height; roiBoxes_[count].Class = j; roiBoxes_[count].prob = dets[i].prob[j]; count++; } } } } if (!publishLabelImage(label_im)) { ROS_DEBUG("Label image has not been broadcasted."); } // create array to store found bounding boxes // if no object detected, make sure that ROS knows that num = 0 if (count == 0) { roiBoxes_[0].num = 0; } else { roiBoxes_[0].num = count; } label_im.release(); free_detections(dets, nboxes); demoIndex_ = (demoIndex_ + 1) % demoFrame_; running_ = 0; return 0; } void *YoloObjectDetector::fetchInThread() { IplImageWithHeader_ imageAndHeader = getIplImageWithHeader(); IplImage* ROS_img = imageAndHeader.image; ipl_into_image(ROS_img, buff_[buffIndex_]); headerBuff_[buffIndex_] = imageAndHeader.header; { boost::shared_lock<boost::shared_mutex> lock(mutexImageCallback_); buffId_[buffIndex_] = actionId_; } rgbgr_image(buff_[buffIndex_]); letterbox_image_into(buff_[buffIndex_], net_->w, net_->h, buffLetter_[buffIndex_]); return 0; } void *YoloObjectDetector::displayInThread(void *ptr) { show_image_cv(buff_[(buffIndex_ + 1)%3], "YOLO V3", ipl_); int c = cvWaitKey(waitKeyDelay_); if (c != -1) c = c%256; if (c == 27) { demoDone_ = 1; return 0; } else if (c == 82) { demoThresh_ += .02; } else if (c == 84) { demoThresh_ -= .02; if(demoThresh_ <= .02) demoThresh_ = .02; } else if (c == 83) { demoHier_ += .02; } else if (c == 81) { demoHier_ -= .02; if(demoHier_ <= .0) demoHier_ = .0; } return 0; } void *YoloObjectDetector::displayLoop(void *ptr) { while (1) { displayInThread(0); } } void *YoloObjectDetector::detectLoop(void *ptr) { while (1) { detectInThread(); } } void YoloObjectDetector::setupNetwork(char *cfgfile, char *weightfile, char *datafile, float thresh, char **names, int classes, int delay, char *prefix, int avg_frames, float hier, int w, int h, int frames, int fullscreen) { demoPrefix_ = prefix; demoDelay_ = delay; demoFrame_ = avg_frames; image **alphabet = load_alphabet_with_file(datafile); demoNames_ = names; demoAlphabet_ = alphabet; demoClasses_ = classes; demoThresh_ = thresh; demoHier_ = hier; fullScreen_ = fullscreen; printf("YOLO V3\n"); net_ = load_network(cfgfile, weightfile, 0); set_batch_network(net_, 1); } void YoloObjectDetector::yolo() { const auto wait_duration = std::chrono::milliseconds(2000); while (!getImageStatus()) { printf("Waiting for image.\n"); if (!isNodeRunning()) { return; } std::this_thread::sleep_for(wait_duration); } std::thread detect_thread; std::thread fetch_thread; srand(2222222); int i; demoTotal_ = sizeNetwork(net_); predictions_ = (float **) calloc(demoFrame_, sizeof(float*)); for (i = 0; i < demoFrame_; ++i){ predictions_[i] = (float *) calloc(demoTotal_, sizeof(float)); } avg_ = (float *) calloc(demoTotal_, sizeof(float)); layer l = net_->layers[net_->n - 1]; roiBoxes_ = (darknet_ros::RosBox_ *) calloc(l.w * l.h * l.n, sizeof(darknet_ros::RosBox_)); IplImageWithHeader_ imageAndHeader = getIplImageWithHeader(); IplImage* ROS_img = imageAndHeader.image; buff_[0] = ipl_to_image(ROS_img); buff_[1] = copy_image(buff_[0]); buff_[2] = copy_image(buff_[0]); headerBuff_[0] = imageAndHeader.header; headerBuff_[1] = headerBuff_[0]; headerBuff_[2] = headerBuff_[0]; buffLetter_[0] = letterbox_image(buff_[0], net_->w, net_->h); buffLetter_[1] = letterbox_image(buff_[0], net_->w, net_->h); buffLetter_[2] = letterbox_image(buff_[0], net_->w, net_->h); ipl_ = cvCreateImage(cvSize(buff_[0].w, buff_[0].h), IPL_DEPTH_8U, buff_[0].c); int count = 0; if (!demoPrefix_ && viewImage_) { cvNamedWindow("YOLO V3", CV_WINDOW_NORMAL); if (fullScreen_) { cvSetWindowProperty("YOLO V3", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN); } else { cvMoveWindow("YOLO V3", 0, 0); cvResizeWindow("YOLO V3", 640, 480); } } demoTime_ = what_time_is_it_now(); while (!demoDone_) { buffIndex_ = (buffIndex_ + 1) % 3; fetch_thread = std::thread(&YoloObjectDetector::fetchInThread, this); detect_thread = std::thread(&YoloObjectDetector::detectInThread, this); if (!demoPrefix_) { fps_ = 1./(what_time_is_it_now() - demoTime_); demoTime_ = what_time_is_it_now(); if (viewImage_) { displayInThread(0); } publishInThread(); } else { char name[256]; sprintf(name, "%s_%08d", demoPrefix_, count); save_image(buff_[(buffIndex_ + 1) % 3], name); } fetch_thread.join(); detect_thread.join(); ++count; if (!isNodeRunning()) { demoDone_ = true; } } } IplImageWithHeader_ YoloObjectDetector::getIplImageWithHeader() { boost::shared_lock<boost::shared_mutex> lock(mutexImageCallback_); IplImage* ROS_img = new IplImage(camImageCopy_); IplImageWithHeader_ header = {.image = ROS_img, .header = imageHeader_}; return header; } bool YoloObjectDetector::getImageStatus(void) { boost::shared_lock<boost::shared_mutex> lock(mutexImageStatus_); return imageStatus_; } bool YoloObjectDetector::isNodeRunning(void) { boost::shared_lock<boost::shared_mutex> lock(mutexNodeStatus_); return isNodeRunning_; } void *YoloObjectDetector::publishInThread() { // Publish image. cv::Mat cvImage = cv::cvarrToMat(ipl_); if (!publishDetectionImage(cv::Mat(cvImage))) { ROS_DEBUG("Detection image has not been broadcasted."); } // Publish bounding boxes and detection result. int num = roiBoxes_[0].num; if (num > 0 && num <= 100) { for (int i = 0; i < num; i++) { for (int j = 0; j < numClasses_; j++) { if (roiBoxes_[i].Class == j) { rosBoxes_[j].push_back(roiBoxes_[i]); rosBoxCounter_[j]++; } } } std_msgs::Int8 msg; msg.data = num; objectPublisher_.publish(msg); for (int i = 0; i < numClasses_; i++) { if (rosBoxCounter_[i] > 0) { darknet_ros_msgs::BoundingBox boundingBox; for (int j = 0; j < rosBoxCounter_[i]; j++) { int xmin = (rosBoxes_[i][j].x - rosBoxes_[i][j].w / 2) * frameWidth_; int ymin = (rosBoxes_[i][j].y - rosBoxes_[i][j].h / 2) * frameHeight_; int xmax = (rosBoxes_[i][j].x + rosBoxes_[i][j].w / 2) * frameWidth_; int ymax = (rosBoxes_[i][j].y + rosBoxes_[i][j].h / 2) * frameHeight_; boundingBox.Class = classLabels_[i]; boundingBox.probability = rosBoxes_[i][j].prob; boundingBox.xmin = xmin; boundingBox.ymin = ymin; boundingBox.xmax = xmax; boundingBox.ymax = ymax; boundingBox.X = 1; boundingBox.Y = 1; //boundingBox.Z = Z; /* ROS_DEBUG("ymin %d , ymax %d , xmin %d , xmax %d ( %d , %d ) " , ymin , ymax , xmin, xmax, (int)round((ymin+ymax)/2 ), (int)round( (xmin+xmax)/2 )); if( (((ymin+ymax)/2) < 1080 ) && (((xmin+xmax)/2 ) < 1920)) { boundingBox.Z = (float)DepthImageCopy_.at<float>((ymin+ymax)/2,(xmin+xmax)/2); }*/ //boundingBoxesResults_.bounding_boxes.push_back(boundingBox); //ROS_DEBUG("Z %f , frame h %d , w %d , size h %d, w %d ", boundingBox.Z, frameHeight_, frameWidth_, DepthImageCopy_.rows, DepthImageCopy_.cols); //frame h 1080 , w 1920 , size h 1080, w 1920 } } } boundingBoxesResults_.header.stamp = ros::Time::now(); boundingBoxesResults_.header.frame_id = "detection"; boundingBoxesResults_.image_header = headerBuff_[(buffIndex_ + 1) % 3]; boundingBoxesPublisher_.publish(boundingBoxesResults_); } else { std_msgs::Int8 msg; msg.data = 0; objectPublisher_.publish(msg); } if (isCheckingForObjects()) { ROS_DEBUG("[YoloObjectDetector] check for objects in image."); darknet_ros_msgs::CheckForObjectsResult objectsActionResult; objectsActionResult.id = buffId_[0]; objectsActionResult.bounding_boxes = boundingBoxesResults_; checkForObjectsActionServer_->setSucceeded(objectsActionResult, "Send bounding boxes."); } boundingBoxesResults_.bounding_boxes.clear(); for (int i = 0; i < numClasses_; i++) { rosBoxes_[i].clear(); rosBoxCounter_[i] = 0; } return 0; } } /* namespace darknet_ros*/
[ "noreply@github.com" ]
hyunoklee.noreply@github.com
345f7235edb1008869df8d5f597889e93e53934a
8aa4728c495add431d18af6cca44450fd0e4b6cf
/2d ball game/PhysicsAspect.h
96ca41788f64d60cd1bb0b8d1a5bf36c607e6bcc
[ "MIT" ]
permissive
DennisWandschura/GravBall
bf315ab1ad56dddd9e298cb1976b2d9693ff8d45
f140e304368ce1bfb9a8750c5a5c68ceac4c24bd
refs/heads/master
2021-01-10T18:05:13.938902
2016-01-05T20:20:52
2016-01-05T20:20:52
49,087,114
0
0
null
null
null
null
UTF-8
C++
false
false
2,638
h
#pragma once struct Manifold; struct Circle128C; struct GravityWell; class LevelFile; namespace Physics { struct DynamicCircle; } #include <gamelib/PhysicsAspectBase.h> #include <vxLib/Container/array.h> #include <vxLib/Allocator/LinearAllocator.h> #include <gamelib/DebugAllocator.h> #include <gamelib/AABB.h> struct OnCollisionCallbackData { __m128 dir; PhysicsComponent* c0; PhysicsComponent* c1; }; class PhysicsAspect : public PhysicsAspectBase { OnCollisionCallbackSignature m_onCollisionCallback; vx::array<PhysicsComponent, DebugAllocatorPhysics<Allocator::MainAllocator>> m_dynamicCircleComponents; vx::array<GravityArea, DebugAllocatorPhysics<Allocator::MainAllocator>> m_gravityAreas; vx::array<GravityWell, DebugAllocatorEntity<Allocator::MainAllocator>> m_gravityWells; vx::array<Circle128C, DebugAllocatorPhysics<Allocator::MainAllocator>> m_staticCircles; vx::array<PhysicsComponent, DebugAllocatorPhysics<Allocator::MainAllocator>> m_staticCircleComponents; vx::array<AABB128, DebugAllocatorPhysics<Allocator::MainAllocator>> m_staticRects; vx::array<PhysicsComponent, DebugAllocatorPhysics<Allocator::MainAllocator>> m_staticRectComponents; vx::LinearAllocator m_frameAllocator; vx::array<PhysicsComponent, DebugAllocatorPhysics<Allocator::MainAllocator>> m_tmpDynamicCircleComponents; void accumulateForces(f32 dt); void verlet(f32 dt); void generateCollisions(const vx::array<Physics::DynamicCircle, vx::DelegateAllocator<vx::LinearAllocator>> &dynamicCircles, vx::array<Manifold, vx::DelegateAllocator<vx::LinearAllocator>>* manifolds); void resolveCollisions(const __m128 &dtSquared, const __m128 &invDtSquared, const vx::array<Manifold, vx::DelegateAllocator<vx::LinearAllocator>> &manifolds, vx::array<OnCollisionCallbackData, vx::DelegateAllocator<vx::LinearAllocator>>* callbackData); void reset(); void loadLevel(const LevelFile &level); public: PhysicsAspect(); ~PhysicsAspect(); bool initialize(const PhysicsAspectBaseDesc &desc) override; void shutdow(Allocator::MainAllocator* allocator) override; void update(f32 dt) override; PhysicsComponent* updateComponent(const PhysicsComponent &old) override; PhysicsComponent* addStaticShape(const vx::float2a &p, f32 radius, f32 restitution, void* userData) override; PhysicsComponent* addStaticShape(const vx::float2a &p, const vx::float2a &halfDim, f32 restitution, void* userData) override; PhysicsComponent* addDynamicShape(const vx::float2a &p, f32 radius, f32 mass, f32 restitution, void* userData) override; GravityArea* getGravityArea(size_t i) override; void handleEvent(const Event::Event &evt) override; };
[ "dennis.wandschura@gmx.de" ]
dennis.wandschura@gmx.de
433f644cbb125c01b117cfe36956fa5ab6d18b85
a4e65095b88e3d7765d56e37923954bc41c4fc43
/tomita/config/clearnames.cxx
a46e0d66b8fe42f898ba293200032cb4363f9e58
[]
no_license
Rosdex/rest-category-classificator
8ffd61dadccd50c6ae846aa06779f8b4923c98fe
32d23c57ec11970d867935a414f97d4d312c161e
refs/heads/master
2021-04-15T16:51:32.235505
2018-04-02T10:01:31
2018-04-02T10:01:31
126,369,543
0
0
null
null
null
null
UTF-8
C++
false
false
220
cxx
#encoding "utf-8" #GRAMMAR_ROOT S S -> Adj interp (ProductName.AdjForName) Noun interp (ProductName.Name); S -> Noun interp (ProductName.Name) Adj interp (ProductName.AdjForName); S -> Noun interp (ProductName.Name);
[ "azheleznov88@gmail.com" ]
azheleznov88@gmail.com
19be914743febea00dcac1f24d1787910de0f8a0
0961819a5fe995ba0265d4a050f82551e2bf0663
/Projects/proj4/card.cpp
6f4879c564c8dafb185207670d6b61da104cf6a3
[]
no_license
marinnaricke/CMSC202
2a98be3fccc2edcad587b55cf8ab0943134c9ed2
b538e5fad266c940738a56f61f1b453c9555ae61
refs/heads/master
2021-05-05T05:06:52.177654
2018-01-24T22:01:12
2018-01-24T22:01:12
118,662,608
0
0
null
null
null
null
UTF-8
C++
false
false
2,376
cpp
/* File: card.cpp Project: CMSC 202 Project 4, Spring 2016 Author: Marinna Ricketts-Uy Date: 4/21/16 Section: 17 E-mail: pd12778@umbc.edu CMSC 202 Computer Science II Spring 2016 Project 4 This file has the implemenation of the Card class. */ #include <iostream> #include <sstream> #include <string> using namespace std ; #include "card.h" #include "player.h" #include "game.h" // default constructor // Card::Card() { m_suit = Invalid ; m_points = 0 ; } Card::Card(unsigned int s, unsigned int p) { if (s > Spades) { // sanity check s = Invalid ; } m_suit = s ; if (p > Ace || p == 1) { // sanity check p = 0 ; } m_points = p ; } Card::~Card() { // no dynamically allocated parts } unsigned int Card::getPoints() { return m_points ; } unsigned int Card::getSuit() { return m_suit ; } string Card::toString() { ostringstream oss ; switch ( m_points ) { case 2 : case 3 : case 4 : case 5 : case 6 : case 7 : case 8 : case 9 : case 10 : oss << m_points ; break ; case Jack: oss << "Jack" ; break ; case Queen: oss << "Queen" ; break ; case King: oss << "King" ; break ; case Ace: oss << "Ace" ; break ; default : oss << "INVALID" ; } switch ( m_suit ) { case Clubs : oss << " of Clubs" ; break ; case Diamonds : oss << " of Diamonds" ; break ; case Hearts : oss << " of Hearts" ; break ; case Spades : oss << " of Spades" ; break ; default : oss << "of INVALID SUIT\n" ; } return oss.str() ; } // Can we play this card right now? // Override for action cards! // bool Card::playable(Game *gptr) { if ( m_suit == gptr->currentSuit() ) // matches suit? return true ; if ( m_points == gptr->currentPoints() ) // matches point value? return true ; return false ; } // Normal cards don't do anything to the players. // Action cards can make the player do something // (e.g., draw cards). // void Card::showPlayerToCard(Player *pptr) { return ; } // Not much to do for normal cards. Just set the // suit and point values. // Action cards can override to do more. // Note: pptr points to the player who played this card. // void Card::playCard(Game *gptr, Player *pptr) { gptr->setSuit(m_suit) ; gptr->setPoints(m_points) ; return ; }
[ "pd12778@umbc.edu" ]
pd12778@umbc.edu
a8934f0f54d27d0984b686ba16009058584516ff
e9f0138f349251bdb17ada746ca37726ecc6e29b
/geometry.h
3411d805ad2e8d4ab0e0b5225af5ea817e23bbd1
[]
no_license
sylwiaZon/raytracer
753c0b1cc9c9817b7882f600fe35ad3ac869195f
eaf5bbcf7250b8e8c57982e845535eb0b8ddff74
refs/heads/master
2020-03-19T16:58:03.845081
2018-07-10T22:35:16
2018-07-10T22:35:16
136,738,504
1
0
null
null
null
null
UTF-8
C++
false
false
3,654
h
#ifndef __GEOMETRY_H #define __GEOMETRY_H #include <iostream> #include <cmath> using namespace std; class Point{ public: float x,y,z; Point(); Point(float _x, float _y, float _z); }; class Vector{ public: float x,y,z; Vector(); Vector(float _x, float _y, float _z); Vector(Point start, Point ending); Vector operator+( const Vector &v) const; Vector operator-(const Vector &v) const; Vector operator*(const float &f) const; float dot(const Vector &v) const; Vector vectorProduct(const Vector & v) const; void normalize(); void setLength(float d); float getLength() const; }; Point translate(const Point &p, const Vector &v); float distanceFromPlane(const Point &p1, const float &A,const float &B,const float &C,const float &D); bool onPlane(const Point &p, const float &A,const float &B,const float &C,const float &D); float pointsDistance(const Point &p1,const Point &p2); class Colour { public: float x,y,z; Colour (); Colour (float _x,float _y,float _z); Colour operator+(const Colour &c); Colour operator*(const float &c); Colour operator*(const Colour &c); }; class Object{ public: Colour colour; Point center; Colour emissionColour; float transparency,reflection; virtual bool intersect(const Point &origin,const Vector &direction,float &t0, float &t1)=0; virtual Vector getNormalVector(const Point &hit)=0; }; class Sphere:public Object{ public: float radius; Sphere(); Sphere(const Point &c, const float &rad, const Colour &col,const Colour &emc,const float & tran,const float & relf); virtual bool intersect(const Point &origin,const Vector &direction,float &t0, float &t1); virtual Vector getNormalVector(const Point &hit); }; class Plane:public Object{ Vector normalVector; public: Plane(); Plane(const Point &p,const Vector &v,const Colour &col,const Colour &emc); virtual bool intersect(const Point &origin,const Vector &direction,float &t0, float &t1); virtual Vector getNormalVector(const Point &hit); }; class Cylinder:public Object{ Vector heightVector; Vector baseVector; Point closerPoint(const Vector &v1,const Vector &v2,const Point &origin); float intersectBase(const Point &origin,const Vector &direction,const Point &cent); public: Cylinder(); Cylinder(const Point &p, const Vector &vh,const Vector &vp,const Colour &col,const Colour &em); virtual bool intersect(const Point &origin,const Vector &direction,float &t0, float &t1); virtual Vector getNormalVector(const Point &hit); }; class Cone:public Object { Vector heightVector; float alfa; float height; float intersectBase(const Point &origin,const Vector &direction); public: Cone(); Cone(const Point &p, const Vector &vh,const float& a,const float&h,const Colour &col,const Colour &em); virtual bool intersect(const Point &origin,const Vector &direction,float &t0, float &t1); virtual Vector getNormalVector(const Point &hit); }; class Cube:public Object { Vector a,b,c; float height; float intersectOnPlane(const Point &origin,const Vector &direction,Vector a,Vector b,Vector c); public: Cube(); Cube(const Point &p, const Vector &a,const Vector &b,float h,const Colour &col,const Colour &em); virtual bool intersect(const Point &origin,const Vector &direction,float &t0, float &t1); virtual Vector getNormalVector(const Point &hit); }; class Space{ Object **objects; int objectsCount; public: Space(int n); ~Space(); void addObject(Object *obj); Object* getObject(int i) const; int getSize() const; }; #endif
[ "sylwia.zon@gmail.com" ]
sylwia.zon@gmail.com
a279eb3245152b0511b126dc1904bbf229ed6d31
49e125a9e43d22706cea8f304e88c96dd20197ae
/Codeforces/equalizing by division.cpp
34bfa5236880ba240919255301d5587cffd167ba
[]
no_license
tahsinsoha/Problem-solving-
b0382b7afa539715dafb1fbc40666e4051b5f7db
7049dcc7ab9e4a59977787c2e9052055bff560a8
refs/heads/master
2023-01-06T02:35:56.822736
2020-11-04T12:15:43
2020-11-04T12:15:43
280,789,760
0
0
null
null
null
null
UTF-8
C++
false
false
644
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int n,k,a,cnt; vector<int>v; cin>>n>>k; for(int i=0;i<n;i++){ cin>>a; v.push_back(a); } sort(v.begin(),v.end()); long long ans = 2e9; for(int x=0;x<200001;x++){ cnt = 0; long long now =0; // long long int st=0; for(int i=0;i<n && cnt<k;i++){ if(v[i]<x) continue; else if(v[i]==x) cnt++; else { long long st=0; int tmp = v[i]; while(tmp>x) tmp=tmp/2,st++; if(tmp==x) now = now+st, cnt++; } } if (cnt==k) ans = min(ans,now); } cout<<ans<<endl; return 0; }
[ "soha97368@gmail.com" ]
soha97368@gmail.com
514ed427753c5ee8efbbc7131fa0e9af0c9a0ad9
2be43a52f811e7e225acc81bfa0b922c8bfacc6d
/src/Constraints.cpp
c1ef44b7827fb615e646c0ef0b8ea85dd5fe87e8
[]
no_license
mxgrey/RobotKin
bf790c32b263588b7c276f97fa80b620d3de161c
19cfa0d3e2cd0d01fa75b455f7a7bbe99bdbe39a
refs/heads/master
2021-01-20T23:27:00.997256
2017-03-27T20:49:59
2017-03-27T20:49:59
10,727,792
0
0
null
2013-07-20T05:17:57
2013-06-17T00:59:31
C++
UTF-8
C++
false
false
2,574
cpp
#include "Robot.h" #include "Constraints.h" #include <time.h> using namespace RobotKin; using namespace Eigen; using namespace std; Constraints::Constraints() : performNullSpaceTask(false), hasRestingValues(false), maxIterations(500), dampingConstant(0.05), finalTransform(TRANSFORM::Identity()), convergenceTolerance(0.001), performErrorClamp(true), translationClamp(0.2), rotationClamp(0.15), customErrorClamp(false), useIterativeJacobianSeed(true), maxAttempts(3), rotationScale(0.01), performDeltaClamp(true), deltaClamp(5*M_PI/180), wrapToJointLimits(true), wrapSolutionToJointLimits(true) { } Constraints &Constraints::Defaults() { Constraints* constraints = new Constraints; return *constraints; } void Constraints::restingValues(VectorXd newRestingValues) { performNullSpaceTask = true; hasRestingValues = true; restingValues_ = newRestingValues; } VectorXd& Constraints::restingValues() { return restingValues_; } bool Constraints::nullComplete() { if(!performNullSpaceTask) return true; else return nullComplete_; } VectorXd Constraints::nullSpaceTask(Robot& robot, const MatrixXd& J, const std::vector<size_t> &indices, const VectorXd& values) { VectorXd nullTask = values; nullTask.setZero(); nullComplete_ = true; return nullTask; } void Constraints::errorClamp(Robot &robot, const std::vector<size_t> &indices, SCREW &error) { } void Constraints::iterativeJacobianSeed(Robot& robot, size_t attemptNumber, const std::vector<size_t> &indices, Eigen::VectorXd &values) { if( attemptNumber == 0 ) { // wrapToJointLimits = true; return; } else if( attemptNumber == 1 && hasRestingValues && values.size() == restingValues_.size() ) for(int i=0; i<values.size(); i++) values(i) = restingValues_(i); // else if( attemptNumber == 2 ) // { // wrapToJointLimits = false; // robot.imposeLimits = false; // for(int i=0; i<values.size(); i++) // values(i) = 0; // } else { int resolution = 1000; int randVal = rand(); for(int i=0; i<values.size(); i++) values(i) = ((double)(randVal%resolution))/((double)resolution-1) *(robot.joint(indices[i]).max() - robot.joint(indices[i]).min()) + robot.joint(indices[i]).min(); } }
[ "mxgrey@gatech.edu" ]
mxgrey@gatech.edu
0610ff251dd4e3630fd3b8c2c434352716dec069
9332137e23a3dcb56804371cf1580f1fd988c1aa
/stk/stk/random/wells512_generator.hpp
8cef569497b70e0373090ec002759a19a77fad41
[ "BSL-1.0" ]
permissive
brandon-kohn/simulation_toolkit
5c590030a6b46b1722d3e1417505118e04f4f1c6
8a772f336701d0cdc66d386c4e0927325089b10a
refs/heads/master
2023-09-01T15:37:02.517027
2023-08-16T15:17:55
2023-08-16T15:17:55
85,863,362
0
1
null
2018-05-09T15:45:58
2017-03-22T18:37:51
C++
UTF-8
C++
false
false
2,055
hpp
// //! Copyright © 2018 // Chris Lomont (Public Domain) //! Brandon Kohn (Wrapper and interfaces). // // 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) // // Implementation from Chris Lomont: Lomont_PRNG_2008.pdf which is public domain. // http://lomont.org/Math/Papers/2008/Lomont_PRNG_2008.pdf // #ifndef STK_WELLS512_GENERATOR_HPP #define STK_WELLS512_GENERATOR_HPP #pragma once #include <geometrix/utility/assert.hpp> #include <array> #include <random> #include <cstdint> namespace stk { class wells512_generator { public: wells512_generator(unsigned int seed = 42) { this->seed(seed); } using result_type = std::uint32_t; static BOOST_CONSTEXPR result_type min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0; } static BOOST_CONSTEXPR result_type max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return (std::numeric_limits<result_type>::max)(); } BOOST_FORCEINLINE result_type operator()() { std::uint32_t a = m_state[m_index]; std::uint32_t c = m_state[(m_index+13)&15]; std::uint32_t b = a^c^(a<<16)^(c<<15); c = m_state[(m_index+9)&15]; c ^= (c>>11); a = m_state[m_index] = b^c; std::uint32_t d = a^((a<<5)&0xDA442D24UL); m_index = (m_index + 15)&15; a = m_state[m_index]; m_state[m_index] = a^b^d^(a<<2)^(b<<18)^(c<<28); auto r = m_state[m_index]; GEOMETRIX_ASSERT(r >= (wells512_generator::min)() && r <= (wells512_generator::max)()); return r; } void seed(unsigned int seed = 42) { std::seed_seq seq{seed}; seq.generate(m_state.begin(), m_state.end()); } private: std::array<std::uint32_t, 16> m_state; unsigned int m_index{0}; }; }//! stk; #endif//! STK_WELLS512_GENERATOR_HPP
[ "blkohn@hotmail.com" ]
blkohn@hotmail.com
1aa689eed40c534f035c430b3ee9a2b3e47b9e8f
7980a127f0591ee1dc9a3fc00cf775eac1c4923a
/layers/Sequential.cpp
55594ce388d984d0b10fa1c3855cc023230cceea
[]
no_license
ValenYamamoto/DeepLearningFramework
90de76aa10d523bf9d48e85cde11e1c122ba648d
242076f429d5dc31d522b22e2bb958103d3a77f8
refs/heads/master
2023-02-01T10:37:42.592837
2020-12-21T22:34:55
2020-12-21T22:34:55
316,268,063
0
0
null
null
null
null
UTF-8
C++
false
false
1,090
cpp
#include "../Tensor.hpp" #include "Layer.hpp" #include "Sequential.hpp" Sequential::Sequential( int numLayers, Layer** layers ) : numLayers{numLayers}, layers{new Layer*[numLayers]}, intermediates{new Tensor[ numLayers ]} { int i; for( i=0; i<numLayers; i++ ) { this->layers[i] = layers[i]; } parameters = new Tensor*[numLayers]; for( i=0; i<numLayers; i++ ) { this->parameters[i] = layers[i]->getParameters()[0]; } } Sequential::~Sequential() { delete[] layers; delete[] intermediates; delete[] parameters; } void Sequential::add( Layer *newLayer ) { numLayers++; Layer** newLayers = new Layer*[numLayers]; int i; for( i=0; i<numLayers-1; i++ ) { newLayers[i] = layers[i]; } delete[] layers; layers = newLayers; } Tensor Sequential::forward( Tensor& input ) { Tensor result = layers[0]->forward( input ); if( numLayers == 1 ) { return result; } intermediates[0] = result; int i; for( i=0; i<numLayers-2; i++ ) { intermediates[i+1] = layers[i+1]->forward( intermediates[0] ); } return layers[ numLayers-1 ]->forward( intermediates[ numLayers-2 ] ); }
[ "valenryamamoto@gmail.com" ]
valenryamamoto@gmail.com
6963aec4d277dc5c3b4de4930f508207da54c008
4a2224e862e7d3325c2437e023290d317b686636
/security/permission-utils/src/main/cpp/ezbake_serialization.cpp
6f8c4337d28ad3a2e479614ca4d2dcfcb5ef501b
[ "Apache-2.0" ]
permissive
ezbake/ezbake-common-cpp
b5b0ea1021e307db3e68e747b8dd8e06514d7fbd
871e3947b1279a249607e71e05c2d31b6ef4079c
refs/heads/master
2021-01-01T20:01:21.718923
2015-03-03T21:18:25
2015-03-03T21:19:03
31,560,584
0
1
null
null
null
null
UTF-8
C++
false
false
4,026
cpp
/* Copyright (C) 2013-2015 Computer Sciences Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "ezbake_serialization.hpp" #include "ezbake_serialization.h" #include <memory> #include "EzBakeBase_types.h" #include "exception_to_error_string.hpp" using std::unique_ptr; using ezbake::base::thrift::AdvancedMarkings; using ezbake::base::thrift::Authorizations; using ezbake::base::thrift::EzSecurityToken; using ezbake::base::thrift::PlatformObjectVisibilities; using ezbake::base::thrift::Visibility; using ezbake::deserialize_thrift; visibility_handle_t *ezbake_deserialize_visibility_binary( const uint8_t * const visibility_binary, size_t visibility_binary_length, char **error) { EXCEPTION_TO_ERROR_STRING(NULL, { unique_ptr<Visibility> vis{new Visibility()}; deserialize_thrift( visibility_binary, visibility_binary_length, *vis); return vis.release(); }) } visibility_handle_t *ezbake_deserialize_visibility_base64( const char * const visibility_base64, char **error) { EXCEPTION_TO_ERROR_STRING(NULL, { unique_ptr<Visibility> vis{new Visibility()}; deserialize_thrift(visibility_base64, *vis); return vis.release(); }) } void ezbake_visibility_handle_free(visibility_handle_t *handle) { delete static_cast<Visibility *>(handle); } authorizations_handle_t *ezbake_deserialize_authorizations_binary( const uint8_t * const authorizations_binary, size_t authorizations_binary_length, char **error) { EXCEPTION_TO_ERROR_STRING(NULL, { unique_ptr<Authorizations> auths{new Authorizations()}; deserialize_thrift( authorizations_binary, authorizations_binary_length, *auths); return auths.release(); }) } authorizations_handle_t *ezbake_deserialize_authorizations_base64( const char * const authorizations_base64, char **error) { EXCEPTION_TO_ERROR_STRING(NULL, { unique_ptr<Authorizations> auths{new Authorizations()}; deserialize_thrift(authorizations_base64, *auths); return auths.release(); }) } void ezbake_authorizations_handle_free(authorizations_handle_t *handle) { delete static_cast<Authorizations *>(handle); } token_handle_t *ezbake_deserialize_token_binary( const uint8_t * const token_binary, size_t token_binary_length, char **error) { EXCEPTION_TO_ERROR_STRING(NULL, { unique_ptr<EzSecurityToken> token{new EzSecurityToken()}; deserialize_thrift(token_binary, token_binary_length, *token); return token.release(); }) } token_handle_t *ezbake_deserialize_token_base64( const char * const token_base64, char **error) { EXCEPTION_TO_ERROR_STRING(NULL, { unique_ptr<EzSecurityToken> token{new EzSecurityToken()}; deserialize_thrift(token_base64, *token); return token.release(); }) } void ezbake_token_handle_free(token_handle_t *handle) { delete static_cast<EzSecurityToken *>(handle); } authorizations_handle_t *ezbake_get_authorizations_from_token( const token_handle_t *token_handle, char **error) { EXCEPTION_TO_ERROR_STRING(NULL, { const EzSecurityToken *token = static_cast<const EzSecurityToken *>(token_handle); unique_ptr<Authorizations> auths{new Authorizations( token->authorizations)}; return auths.release(); }) }
[ "jhastings@42six.com" ]
jhastings@42six.com
3545859e1f035c969b05a3eb4ec448bcf6009e58
0400ac52a20058bf13a064b838872473212765ca
/Unity_Code/DinoRun_Final/Temp/il2cppOutput/il2cppOutput/Il2CppCompilerCalculateTypeValues_13Table.cpp
54218c2c04a1ea80c40af6e980759da4580eabdb
[ "Apache-2.0" ]
permissive
BPenzar/SuperDinoBros.
b7e6be07bfc4278d85eeb986f4740c9a91e01689
f46b866c5a1119c6753dbd8e963212f17a4a31d5
refs/heads/master
2021-01-20T04:29:24.503356
2017-07-25T14:58:12
2017-07-25T14:58:12
89,697,299
0
1
null
null
null
null
UTF-8
C++
false
false
43,103
cpp
#include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <cstring> #include <string.h> #include <stdio.h> #include <cmath> #include <limits> #include <assert.h> #include "class-internals.h" #include "codegen/il2cpp-codegen.h" #include "UnityEngine_UnityEngine_SpriteRenderer1209076198.h" #include "UnityEngine_UnityEngine_Sprites_DataUtility4181890362.h" #include "UnityEngine_UnityEngine_Texture2243626319.h" #include "UnityEngine_UnityEngine_Texture2D3542995729.h" #include "UnityEngine_UnityEngine_RenderTexture2666733923.h" #include "UnityEngine_UnityEngine_Time31991979.h" #include "UnityEngine_UnityEngine_HideFlags1434274199.h" #include "UnityEngine_UnityEngine_Object1021602117.h" #include "UnityEngine_UnityEngine_WWW2919945039.h" #include "UnityEngine_UnityEngine_WWWForm3950226929.h" #include "UnityEngine_UnityEngine_WWWTranscoder1124214756.h" #include "UnityEngine_UnityEngine_YieldInstruction3462875981.h" #include "UnityEngine_UnityEngine_Experimental_Director_Play3250302433.h" #include "UnityEngine_UnityEngine_Experimental_Director_Play1502856514.h" #include "UnityEngine_UnityEngine_Experimental_Director_Play3667545548.h" #include "UnityEngine_UnityEngine_Experimental_Director_Scri4067966717.h" #include "UnityEngine_UnityEngine_iOS_CalendarIdentifier259698391.h" #include "UnityEngine_UnityEngine_iOS_CalendarUnit4134400622.h" #include "UnityEngine_UnityEngine_iOS_LocalNotification317971878.h" #include "UnityEngine_UnityEngine_iOS_RemoteNotification2254252895.h" #include "UnityEngine_UnityEngine_SceneManagement_Scene1684909666.h" #include "UnityEngine_UnityEngine_SceneManagement_LoadSceneM2981886439.h" #include "UnityEngine_UnityEngine_SceneManagement_SceneManager90660965.h" #include "UnityEngine_UnityEngine_Experimental_Rendering_Script4271526.h" #include "UnityEngine_UnityEngine_Transform3275118058.h" #include "UnityEngine_UnityEngine_Transform_Enumerator1251553160.h" #include "UnityEngine_UnityEngine_DrivenTransformProperties2488747555.h" #include "UnityEngine_UnityEngine_DrivenRectTransformTracker154385424.h" #include "UnityEngine_UnityEngine_RectTransform3349966182.h" #include "UnityEngine_UnityEngine_RectTransform_ReapplyDrive2020713228.h" #include "UnityEngine_UnityEngine_RectTransform_Edge3306019089.h" #include "UnityEngine_UnityEngine_RectTransform_Axis3420330537.h" #include "UnityEngine_UnityEngine_ControllerColliderHit4070855101.h" #include "UnityEngine_UnityEngine_Collision2876846408.h" #include "UnityEngine_UnityEngine_CollisionFlags4046947985.h" #include "UnityEngine_UnityEngine_QueryTriggerInteraction478029726.h" #include "UnityEngine_UnityEngine_Physics634932869.h" #include "UnityEngine_UnityEngine_ContactPoint1376425630.h" #include "UnityEngine_UnityEngine_Rigidbody4233889191.h" #include "UnityEngine_UnityEngine_Collider3497673348.h" #include "UnityEngine_UnityEngine_RaycastHit87180320.h" #include "UnityEngine_UnityEngine_CharacterController4094781467.h" #include "UnityEngine_UnityEngine_RaycastHit2D4063908774.h" #include "UnityEngine_UnityEngine_Physics2D2540166467.h" #include "UnityEngine_UnityEngine_ContactFilter2D1672660996.h" #include "UnityEngine_UnityEngine_Rigidbody2D502193897.h" #include "UnityEngine_UnityEngine_Collider2D646061738.h" #include "UnityEngine_UnityEngine_ContactPoint2D3659330976.h" #include "UnityEngine_UnityEngine_Collision2D1539500754.h" #include "UnityEngine_UnityEngine_AudioSettings3144015719.h" #include "UnityEngine_UnityEngine_AudioSettings_AudioConfigu3743753033.h" #include "UnityEngine_UnityEngine_AudioClip1932558630.h" #include "UnityEngine_UnityEngine_AudioClip_PCMReaderCallbac3007145346.h" #include "UnityEngine_UnityEngine_AudioClip_PCMSetPositionCal421863554.h" #include "UnityEngine_UnityEngine_AudioListener1996719162.h" #include "UnityEngine_UnityEngine_AudioSource1135106623.h" #include "UnityEngine_UnityEngine_SharedBetweenAnimatorsAttr1565472209.h" #include "UnityEngine_UnityEngine_StateMachineBehaviour2151245329.h" #include "UnityEngine_UnityEngine_AnimationEventSource3560017945.h" #include "UnityEngine_UnityEngine_AnimationEvent2428323300.h" #include "UnityEngine_UnityEngine_AnimationClip3510324950.h" #include "UnityEngine_UnityEngine_AnimationState1303741697.h" #include "UnityEngine_UnityEngine_AnimatorControllerParamete3688495056.h" #include "UnityEngine_UnityEngine_AnimatorClipInfo3905751349.h" #include "UnityEngine_UnityEngine_AnimatorStateInfo2577870592.h" #include "UnityEngine_UnityEngine_AnimatorTransitionInfo2410896200.h" #include "UnityEngine_UnityEngine_Animator69676727.h" #include "UnityEngine_UnityEngine_AnimatorControllerParamete1381019216.h" #include "UnityEngine_UnityEngine_SkeletonBone345082847.h" #include "UnityEngine_UnityEngine_HumanLimit250797648.h" #include "UnityEngine_UnityEngine_HumanBone1529896151.h" #include "UnityEngine_UnityEngine_RuntimeAnimatorController670468573.h" #include "UnityEngine_UnityEngine_Experimental_Director_Anim4078305555.h" #include "UnityEngine_UnityEngine_Experimental_Director_Anim3036622417.h" #include "UnityEngine_UnityEngine_Experimental_Director_Anima641234490.h" #include "UnityEngine_UnityEngine_Experimental_Director_Anim4062767676.h" #include "UnityEngine_UnityEngine_Experimental_Director_Anim1693994278.h" #include "UnityEngine_UnityEngine_Experimental_Director_Anima859920217.h" #include "UnityEngine_UnityEngine_Motion2415020824.h" #include "UnityEngine_UnityEngine_FontStyle2764949590.h" #include "UnityEngine_UnityEngine_TextGenerationError780770201.h" #include "UnityEngine_UnityEngine_TextGenerationSettings2543476768.h" #include "UnityEngine_UnityEngine_TextGenerator647235000.h" #include "UnityEngine_UnityEngine_TextAnchor112990806.h" #include "UnityEngine_UnityEngine_HorizontalWrapMode2027154177.h" #include "UnityEngine_UnityEngine_VerticalWrapMode3668245347.h" #include "UnityEngine_UnityEngine_Font4239498691.h" #include "UnityEngine_UnityEngine_Font_FontTextureRebuildCal1272078033.h" #include "UnityEngine_UnityEngine_UICharInfo3056636800.h" #include "UnityEngine_UnityEngine_UILineInfo3621277874.h" #include "UnityEngine_UnityEngine_UIVertex1204258818.h" #include "UnityEngine_UnityEngine_RectTransformUtility2941082270.h" #include "UnityEngine_UnityEngine_RenderMode4280533217.h" #include "UnityEngine_UnityEngine_Canvas209405766.h" #include "UnityEngine_UnityEngine_Canvas_WillRenderCanvases3522132132.h" #include "UnityEngine_UnityEngine_CanvasGroup3296560743.h" #include "UnityEngine_UnityEngine_CanvasRenderer261436805.h" #include "UnityEngine_UnityEngine_Event3028476042.h" #include "UnityEngine_UnityEngine_EventType3919834026.h" #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1300 = { sizeof (SpriteRenderer_t1209076198), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1301 = { sizeof (DataUtility_t4181890362), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1302 = { sizeof (Texture_t2243626319), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1303 = { sizeof (Texture2D_t3542995729), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1304 = { sizeof (RenderTexture_t2666733923), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1305 = { sizeof (Time_t31991979), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1306 = { sizeof (HideFlags_t1434274199)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1306[10] = { HideFlags_t1434274199::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, 0, 0, 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1307 = { sizeof (Object_t1021602117), sizeof(Object_t1021602117_marshaled_pinvoke), sizeof(Object_t1021602117_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1307[2] = { Object_t1021602117::get_offset_of_m_CachedPtr_0(), Object_t1021602117_StaticFields::get_offset_of_OffsetOfInstanceIDInCPlusPlusObject_1(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1308 = { sizeof (WWW_t2919945039), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1309 = { sizeof (WWWForm_t3950226929), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1309[6] = { WWWForm_t3950226929::get_offset_of_formData_0(), WWWForm_t3950226929::get_offset_of_fieldNames_1(), WWWForm_t3950226929::get_offset_of_fileNames_2(), WWWForm_t3950226929::get_offset_of_types_3(), WWWForm_t3950226929::get_offset_of_boundary_4(), WWWForm_t3950226929::get_offset_of_containsFiles_5(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1310 = { sizeof (WWWTranscoder_t1124214756), -1, sizeof(WWWTranscoder_t1124214756_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1310[8] = { WWWTranscoder_t1124214756_StaticFields::get_offset_of_ucHexChars_0(), WWWTranscoder_t1124214756_StaticFields::get_offset_of_lcHexChars_1(), WWWTranscoder_t1124214756_StaticFields::get_offset_of_urlEscapeChar_2(), WWWTranscoder_t1124214756_StaticFields::get_offset_of_urlSpace_3(), WWWTranscoder_t1124214756_StaticFields::get_offset_of_urlForbidden_4(), WWWTranscoder_t1124214756_StaticFields::get_offset_of_qpEscapeChar_5(), WWWTranscoder_t1124214756_StaticFields::get_offset_of_qpSpace_6(), WWWTranscoder_t1124214756_StaticFields::get_offset_of_qpForbidden_7(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1311 = { sizeof (YieldInstruction_t3462875981), sizeof(YieldInstruction_t3462875981_marshaled_pinvoke), 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1312 = { sizeof (PlayState_t3250302433)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1312[3] = { PlayState_t3250302433::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1313 = { sizeof (PlayableHandle_t1502856514)+ sizeof (Il2CppObject), sizeof(PlayableHandle_t1502856514 ), 0, 0 }; extern const int32_t g_FieldOffsetTable1313[2] = { PlayableHandle_t1502856514::get_offset_of_m_Handle_0() + static_cast<int32_t>(sizeof(Il2CppObject)), PlayableHandle_t1502856514::get_offset_of_m_Version_1() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1314 = { sizeof (Playable_t3667545548), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1314[1] = { Playable_t3667545548::get_offset_of_handle_0(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1315 = { sizeof (ScriptPlayable_t4067966717), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1316 = { sizeof (CalendarIdentifier_t259698391)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1316[12] = { CalendarIdentifier_t259698391::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1317 = { sizeof (CalendarUnit_t4134400622)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1317[12] = { CalendarUnit_t4134400622::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1318 = { sizeof (LocalNotification_t317971878), -1, sizeof(LocalNotification_t317971878_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1318[2] = { LocalNotification_t317971878::get_offset_of_notificationWrapper_0(), LocalNotification_t317971878_StaticFields::get_offset_of_m_NSReferenceDateTicks_1(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1319 = { sizeof (RemoteNotification_t2254252895), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1319[1] = { RemoteNotification_t2254252895::get_offset_of_notificationWrapper_0(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1320 = { sizeof (Scene_t1684909666)+ sizeof (Il2CppObject), sizeof(Scene_t1684909666 ), 0, 0 }; extern const int32_t g_FieldOffsetTable1320[1] = { Scene_t1684909666::get_offset_of_m_Handle_0() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1321 = { sizeof (LoadSceneMode_t2981886439)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1321[3] = { LoadSceneMode_t2981886439::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1322 = { sizeof (SceneManager_t90660965), -1, sizeof(SceneManager_t90660965_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1322[3] = { SceneManager_t90660965_StaticFields::get_offset_of_sceneLoaded_0(), SceneManager_t90660965_StaticFields::get_offset_of_sceneUnloaded_1(), SceneManager_t90660965_StaticFields::get_offset_of_activeSceneChanged_2(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1323 = { sizeof (ScriptableRenderContext_t4271526)+ sizeof (Il2CppObject), sizeof(ScriptableRenderContext_t4271526 ), 0, 0 }; extern const int32_t g_FieldOffsetTable1323[1] = { ScriptableRenderContext_t4271526::get_offset_of_m_Ptr_0() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1324 = { sizeof (Transform_t3275118058), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1325 = { sizeof (Enumerator_t1251553160), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1325[2] = { Enumerator_t1251553160::get_offset_of_outer_0(), Enumerator_t1251553160::get_offset_of_currentIndex_1(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1326 = { sizeof (DrivenTransformProperties_t2488747555)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1326[26] = { DrivenTransformProperties_t2488747555::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1327 = { sizeof (DrivenRectTransformTracker_t154385424)+ sizeof (Il2CppObject), sizeof(DrivenRectTransformTracker_t154385424 ), 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1328 = { sizeof (RectTransform_t3349966182), -1, sizeof(RectTransform_t3349966182_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1328[1] = { RectTransform_t3349966182_StaticFields::get_offset_of_reapplyDrivenProperties_2(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1329 = { sizeof (ReapplyDrivenProperties_t2020713228), sizeof(Il2CppMethodPointer), 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1330 = { sizeof (Edge_t3306019089)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1330[5] = { Edge_t3306019089::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1331 = { sizeof (Axis_t3420330537)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1331[3] = { Axis_t3420330537::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1332 = { sizeof (ControllerColliderHit_t4070855101), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1332[7] = { ControllerColliderHit_t4070855101::get_offset_of_m_Controller_0(), ControllerColliderHit_t4070855101::get_offset_of_m_Collider_1(), ControllerColliderHit_t4070855101::get_offset_of_m_Point_2(), ControllerColliderHit_t4070855101::get_offset_of_m_Normal_3(), ControllerColliderHit_t4070855101::get_offset_of_m_MoveDirection_4(), ControllerColliderHit_t4070855101::get_offset_of_m_MoveLength_5(), ControllerColliderHit_t4070855101::get_offset_of_m_Push_6(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1333 = { sizeof (Collision_t2876846408), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1333[5] = { Collision_t2876846408::get_offset_of_m_Impulse_0(), Collision_t2876846408::get_offset_of_m_RelativeVelocity_1(), Collision_t2876846408::get_offset_of_m_Rigidbody_2(), Collision_t2876846408::get_offset_of_m_Collider_3(), Collision_t2876846408::get_offset_of_m_Contacts_4(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1334 = { sizeof (CollisionFlags_t4046947985)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1334[8] = { CollisionFlags_t4046947985::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1335 = { sizeof (QueryTriggerInteraction_t478029726)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1335[4] = { QueryTriggerInteraction_t478029726::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1336 = { sizeof (Physics_t634932869), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1337 = { sizeof (ContactPoint_t1376425630)+ sizeof (Il2CppObject), sizeof(ContactPoint_t1376425630 ), 0, 0 }; extern const int32_t g_FieldOffsetTable1337[5] = { ContactPoint_t1376425630::get_offset_of_m_Point_0() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint_t1376425630::get_offset_of_m_Normal_1() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint_t1376425630::get_offset_of_m_ThisColliderInstanceID_2() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint_t1376425630::get_offset_of_m_OtherColliderInstanceID_3() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint_t1376425630::get_offset_of_m_Separation_4() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1338 = { sizeof (Rigidbody_t4233889191), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1339 = { sizeof (Collider_t3497673348), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1340 = { sizeof (RaycastHit_t87180320)+ sizeof (Il2CppObject), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1340[6] = { RaycastHit_t87180320::get_offset_of_m_Point_0() + static_cast<int32_t>(sizeof(Il2CppObject)), RaycastHit_t87180320::get_offset_of_m_Normal_1() + static_cast<int32_t>(sizeof(Il2CppObject)), RaycastHit_t87180320::get_offset_of_m_FaceID_2() + static_cast<int32_t>(sizeof(Il2CppObject)), RaycastHit_t87180320::get_offset_of_m_Distance_3() + static_cast<int32_t>(sizeof(Il2CppObject)), RaycastHit_t87180320::get_offset_of_m_UV_4() + static_cast<int32_t>(sizeof(Il2CppObject)), RaycastHit_t87180320::get_offset_of_m_Collider_5() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1341 = { sizeof (CharacterController_t4094781467), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1342 = { sizeof (RaycastHit2D_t4063908774)+ sizeof (Il2CppObject), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1342[6] = { RaycastHit2D_t4063908774::get_offset_of_m_Centroid_0() + static_cast<int32_t>(sizeof(Il2CppObject)), RaycastHit2D_t4063908774::get_offset_of_m_Point_1() + static_cast<int32_t>(sizeof(Il2CppObject)), RaycastHit2D_t4063908774::get_offset_of_m_Normal_2() + static_cast<int32_t>(sizeof(Il2CppObject)), RaycastHit2D_t4063908774::get_offset_of_m_Distance_3() + static_cast<int32_t>(sizeof(Il2CppObject)), RaycastHit2D_t4063908774::get_offset_of_m_Fraction_4() + static_cast<int32_t>(sizeof(Il2CppObject)), RaycastHit2D_t4063908774::get_offset_of_m_Collider_5() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1343 = { sizeof (Physics2D_t2540166467), -1, sizeof(Physics2D_t2540166467_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1343[1] = { Physics2D_t2540166467_StaticFields::get_offset_of_m_LastDisabledRigidbody2D_0(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1344 = { sizeof (ContactFilter2D_t1672660996)+ sizeof (Il2CppObject), sizeof(ContactFilter2D_t1672660996_marshaled_pinvoke), 0, 0 }; extern const int32_t g_FieldOffsetTable1344[9] = { ContactFilter2D_t1672660996::get_offset_of_useTriggers_0() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactFilter2D_t1672660996::get_offset_of_useLayerMask_1() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactFilter2D_t1672660996::get_offset_of_useDepth_2() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactFilter2D_t1672660996::get_offset_of_useNormalAngle_3() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactFilter2D_t1672660996::get_offset_of_layerMask_4() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactFilter2D_t1672660996::get_offset_of_minDepth_5() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactFilter2D_t1672660996::get_offset_of_maxDepth_6() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactFilter2D_t1672660996::get_offset_of_minNormalAngle_7() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactFilter2D_t1672660996::get_offset_of_maxNormalAngle_8() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1345 = { sizeof (Rigidbody2D_t502193897), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1346 = { sizeof (Collider2D_t646061738), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1347 = { sizeof (ContactPoint2D_t3659330976)+ sizeof (Il2CppObject), sizeof(ContactPoint2D_t3659330976 ), 0, 0 }; extern const int32_t g_FieldOffsetTable1347[11] = { ContactPoint2D_t3659330976::get_offset_of_m_Point_0() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint2D_t3659330976::get_offset_of_m_Normal_1() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint2D_t3659330976::get_offset_of_m_RelativeVelocity_2() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint2D_t3659330976::get_offset_of_m_Separation_3() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint2D_t3659330976::get_offset_of_m_NormalImpulse_4() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint2D_t3659330976::get_offset_of_m_TangentImpulse_5() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint2D_t3659330976::get_offset_of_m_Collider_6() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint2D_t3659330976::get_offset_of_m_OtherCollider_7() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint2D_t3659330976::get_offset_of_m_Rigidbody_8() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint2D_t3659330976::get_offset_of_m_OtherRigidbody_9() + static_cast<int32_t>(sizeof(Il2CppObject)), ContactPoint2D_t3659330976::get_offset_of_m_Enabled_10() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1348 = { sizeof (Collision2D_t1539500754), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1348[7] = { Collision2D_t1539500754::get_offset_of_m_Collider_0(), Collision2D_t1539500754::get_offset_of_m_OtherCollider_1(), Collision2D_t1539500754::get_offset_of_m_Rigidbody_2(), Collision2D_t1539500754::get_offset_of_m_OtherRigidbody_3(), Collision2D_t1539500754::get_offset_of_m_Contacts_4(), Collision2D_t1539500754::get_offset_of_m_RelativeVelocity_5(), Collision2D_t1539500754::get_offset_of_m_Enabled_6(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1349 = { sizeof (AudioSettings_t3144015719), -1, sizeof(AudioSettings_t3144015719_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1349[1] = { AudioSettings_t3144015719_StaticFields::get_offset_of_OnAudioConfigurationChanged_0(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1350 = { sizeof (AudioConfigurationChangeHandler_t3743753033), sizeof(Il2CppMethodPointer), 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1351 = { sizeof (AudioClip_t1932558630), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1351[2] = { AudioClip_t1932558630::get_offset_of_m_PCMReaderCallback_2(), AudioClip_t1932558630::get_offset_of_m_PCMSetPositionCallback_3(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1352 = { sizeof (PCMReaderCallback_t3007145346), sizeof(Il2CppMethodPointer), 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1353 = { sizeof (PCMSetPositionCallback_t421863554), sizeof(Il2CppMethodPointer), 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1354 = { sizeof (AudioListener_t1996719162), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1355 = { sizeof (AudioSource_t1135106623), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1356 = { sizeof (SharedBetweenAnimatorsAttribute_t1565472209), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1357 = { sizeof (StateMachineBehaviour_t2151245329), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1358 = { sizeof (AnimationEventSource_t3560017945)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1358[4] = { AnimationEventSource_t3560017945::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1359 = { sizeof (AnimationEvent_t2428323300), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1359[11] = { AnimationEvent_t2428323300::get_offset_of_m_Time_0(), AnimationEvent_t2428323300::get_offset_of_m_FunctionName_1(), AnimationEvent_t2428323300::get_offset_of_m_StringParameter_2(), AnimationEvent_t2428323300::get_offset_of_m_ObjectReferenceParameter_3(), AnimationEvent_t2428323300::get_offset_of_m_FloatParameter_4(), AnimationEvent_t2428323300::get_offset_of_m_IntParameter_5(), AnimationEvent_t2428323300::get_offset_of_m_MessageOptions_6(), AnimationEvent_t2428323300::get_offset_of_m_Source_7(), AnimationEvent_t2428323300::get_offset_of_m_StateSender_8(), AnimationEvent_t2428323300::get_offset_of_m_AnimatorStateInfo_9(), AnimationEvent_t2428323300::get_offset_of_m_AnimatorClipInfo_10(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1360 = { sizeof (AnimationClip_t3510324950), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1361 = { sizeof (AnimationState_t1303741697), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1362 = { sizeof (AnimatorControllerParameterType_t3688495056)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1362[5] = { AnimatorControllerParameterType_t3688495056::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1363 = { sizeof (AnimatorClipInfo_t3905751349)+ sizeof (Il2CppObject), sizeof(AnimatorClipInfo_t3905751349 ), 0, 0 }; extern const int32_t g_FieldOffsetTable1363[2] = { AnimatorClipInfo_t3905751349::get_offset_of_m_ClipInstanceID_0() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorClipInfo_t3905751349::get_offset_of_m_Weight_1() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1364 = { sizeof (AnimatorStateInfo_t2577870592)+ sizeof (Il2CppObject), sizeof(AnimatorStateInfo_t2577870592 ), 0, 0 }; extern const int32_t g_FieldOffsetTable1364[9] = { AnimatorStateInfo_t2577870592::get_offset_of_m_Name_0() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorStateInfo_t2577870592::get_offset_of_m_Path_1() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorStateInfo_t2577870592::get_offset_of_m_FullPath_2() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorStateInfo_t2577870592::get_offset_of_m_NormalizedTime_3() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorStateInfo_t2577870592::get_offset_of_m_Length_4() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorStateInfo_t2577870592::get_offset_of_m_Speed_5() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorStateInfo_t2577870592::get_offset_of_m_SpeedMultiplier_6() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorStateInfo_t2577870592::get_offset_of_m_Tag_7() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorStateInfo_t2577870592::get_offset_of_m_Loop_8() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1365 = { sizeof (AnimatorTransitionInfo_t2410896200)+ sizeof (Il2CppObject), sizeof(AnimatorTransitionInfo_t2410896200_marshaled_pinvoke), 0, 0 }; extern const int32_t g_FieldOffsetTable1365[6] = { AnimatorTransitionInfo_t2410896200::get_offset_of_m_FullPath_0() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorTransitionInfo_t2410896200::get_offset_of_m_UserName_1() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorTransitionInfo_t2410896200::get_offset_of_m_Name_2() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorTransitionInfo_t2410896200::get_offset_of_m_NormalizedTime_3() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorTransitionInfo_t2410896200::get_offset_of_m_AnyState_4() + static_cast<int32_t>(sizeof(Il2CppObject)), AnimatorTransitionInfo_t2410896200::get_offset_of_m_TransitionType_5() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1366 = { sizeof (Animator_t69676727), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1367 = { sizeof (AnimatorControllerParameter_t1381019216), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1367[5] = { AnimatorControllerParameter_t1381019216::get_offset_of_m_Name_0(), AnimatorControllerParameter_t1381019216::get_offset_of_m_Type_1(), AnimatorControllerParameter_t1381019216::get_offset_of_m_DefaultFloat_2(), AnimatorControllerParameter_t1381019216::get_offset_of_m_DefaultInt_3(), AnimatorControllerParameter_t1381019216::get_offset_of_m_DefaultBool_4(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1368 = { sizeof (SkeletonBone_t345082847)+ sizeof (Il2CppObject), sizeof(SkeletonBone_t345082847_marshaled_pinvoke), 0, 0 }; extern const int32_t g_FieldOffsetTable1368[5] = { SkeletonBone_t345082847::get_offset_of_name_0() + static_cast<int32_t>(sizeof(Il2CppObject)), SkeletonBone_t345082847::get_offset_of_parentName_1() + static_cast<int32_t>(sizeof(Il2CppObject)), SkeletonBone_t345082847::get_offset_of_position_2() + static_cast<int32_t>(sizeof(Il2CppObject)), SkeletonBone_t345082847::get_offset_of_rotation_3() + static_cast<int32_t>(sizeof(Il2CppObject)), SkeletonBone_t345082847::get_offset_of_scale_4() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1369 = { sizeof (HumanLimit_t250797648)+ sizeof (Il2CppObject), sizeof(HumanLimit_t250797648 ), 0, 0 }; extern const int32_t g_FieldOffsetTable1369[5] = { HumanLimit_t250797648::get_offset_of_m_Min_0() + static_cast<int32_t>(sizeof(Il2CppObject)), HumanLimit_t250797648::get_offset_of_m_Max_1() + static_cast<int32_t>(sizeof(Il2CppObject)), HumanLimit_t250797648::get_offset_of_m_Center_2() + static_cast<int32_t>(sizeof(Il2CppObject)), HumanLimit_t250797648::get_offset_of_m_AxisLength_3() + static_cast<int32_t>(sizeof(Il2CppObject)), HumanLimit_t250797648::get_offset_of_m_UseDefaultValues_4() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1370 = { sizeof (HumanBone_t1529896151)+ sizeof (Il2CppObject), sizeof(HumanBone_t1529896151_marshaled_pinvoke), 0, 0 }; extern const int32_t g_FieldOffsetTable1370[3] = { HumanBone_t1529896151::get_offset_of_m_BoneName_0() + static_cast<int32_t>(sizeof(Il2CppObject)), HumanBone_t1529896151::get_offset_of_m_HumanName_1() + static_cast<int32_t>(sizeof(Il2CppObject)), HumanBone_t1529896151::get_offset_of_limit_2() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1371 = { sizeof (RuntimeAnimatorController_t670468573), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1372 = { sizeof (AnimatorControllerPlayable_t4078305555), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1373 = { sizeof (AnimationMixerPlayable_t3036622417), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1374 = { sizeof (AnimationLayerMixerPlayable_t641234490), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1375 = { sizeof (AnimationClipPlayable_t4062767676), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1376 = { sizeof (AnimationPlayable_t1693994278), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1377 = { sizeof (AnimationOffsetPlayable_t859920217), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1378 = { sizeof (Motion_t2415020824), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1379 = { sizeof (FontStyle_t2764949590)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1379[5] = { FontStyle_t2764949590::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1380 = { sizeof (TextGenerationError_t780770201)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1380[5] = { TextGenerationError_t780770201::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1381 = { sizeof (TextGenerationSettings_t2543476768)+ sizeof (Il2CppObject), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1381[18] = { TextGenerationSettings_t2543476768::get_offset_of_font_0() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_color_1() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_fontSize_2() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_lineSpacing_3() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_richText_4() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_scaleFactor_5() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_fontStyle_6() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_textAnchor_7() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_alignByGeometry_8() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_resizeTextForBestFit_9() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_resizeTextMinSize_10() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_resizeTextMaxSize_11() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_updateBounds_12() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_verticalOverflow_13() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_horizontalOverflow_14() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_generationExtents_15() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_pivot_16() + static_cast<int32_t>(sizeof(Il2CppObject)), TextGenerationSettings_t2543476768::get_offset_of_generateOutOfBounds_17() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1382 = { sizeof (TextGenerator_t647235000), -1, 0, 0 }; extern const int32_t g_FieldOffsetTable1382[11] = { TextGenerator_t647235000::get_offset_of_m_Ptr_0(), TextGenerator_t647235000::get_offset_of_m_LastString_1(), TextGenerator_t647235000::get_offset_of_m_LastSettings_2(), TextGenerator_t647235000::get_offset_of_m_HasGenerated_3(), TextGenerator_t647235000::get_offset_of_m_LastValid_4(), TextGenerator_t647235000::get_offset_of_m_Verts_5(), TextGenerator_t647235000::get_offset_of_m_Characters_6(), TextGenerator_t647235000::get_offset_of_m_Lines_7(), TextGenerator_t647235000::get_offset_of_m_CachedVerts_8(), TextGenerator_t647235000::get_offset_of_m_CachedCharacters_9(), TextGenerator_t647235000::get_offset_of_m_CachedLines_10(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1383 = { sizeof (TextAnchor_t112990806)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1383[10] = { TextAnchor_t112990806::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, 0, 0, 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1384 = { sizeof (HorizontalWrapMode_t2027154177)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1384[3] = { HorizontalWrapMode_t2027154177::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1385 = { sizeof (VerticalWrapMode_t3668245347)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1385[3] = { VerticalWrapMode_t3668245347::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1386 = { sizeof (Font_t4239498691), -1, sizeof(Font_t4239498691_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1386[2] = { Font_t4239498691_StaticFields::get_offset_of_textureRebuilt_2(), Font_t4239498691::get_offset_of_m_FontTextureRebuildCallback_3(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1387 = { sizeof (FontTextureRebuildCallback_t1272078033), sizeof(Il2CppMethodPointer), 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1388 = { sizeof (UICharInfo_t3056636800)+ sizeof (Il2CppObject), sizeof(UICharInfo_t3056636800 ), 0, 0 }; extern const int32_t g_FieldOffsetTable1388[2] = { UICharInfo_t3056636800::get_offset_of_cursorPos_0() + static_cast<int32_t>(sizeof(Il2CppObject)), UICharInfo_t3056636800::get_offset_of_charWidth_1() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1389 = { sizeof (UILineInfo_t3621277874)+ sizeof (Il2CppObject), sizeof(UILineInfo_t3621277874 ), 0, 0 }; extern const int32_t g_FieldOffsetTable1389[4] = { UILineInfo_t3621277874::get_offset_of_startCharIdx_0() + static_cast<int32_t>(sizeof(Il2CppObject)), UILineInfo_t3621277874::get_offset_of_height_1() + static_cast<int32_t>(sizeof(Il2CppObject)), UILineInfo_t3621277874::get_offset_of_topY_2() + static_cast<int32_t>(sizeof(Il2CppObject)), UILineInfo_t3621277874::get_offset_of_leading_3() + static_cast<int32_t>(sizeof(Il2CppObject)), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1390 = { sizeof (UIVertex_t1204258818)+ sizeof (Il2CppObject), sizeof(UIVertex_t1204258818 ), sizeof(UIVertex_t1204258818_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1390[11] = { UIVertex_t1204258818::get_offset_of_position_0() + static_cast<int32_t>(sizeof(Il2CppObject)), UIVertex_t1204258818::get_offset_of_normal_1() + static_cast<int32_t>(sizeof(Il2CppObject)), UIVertex_t1204258818::get_offset_of_color_2() + static_cast<int32_t>(sizeof(Il2CppObject)), UIVertex_t1204258818::get_offset_of_uv0_3() + static_cast<int32_t>(sizeof(Il2CppObject)), UIVertex_t1204258818::get_offset_of_uv1_4() + static_cast<int32_t>(sizeof(Il2CppObject)), UIVertex_t1204258818::get_offset_of_uv2_5() + static_cast<int32_t>(sizeof(Il2CppObject)), UIVertex_t1204258818::get_offset_of_uv3_6() + static_cast<int32_t>(sizeof(Il2CppObject)), UIVertex_t1204258818::get_offset_of_tangent_7() + static_cast<int32_t>(sizeof(Il2CppObject)), UIVertex_t1204258818_StaticFields::get_offset_of_s_DefaultColor_8(), UIVertex_t1204258818_StaticFields::get_offset_of_s_DefaultTangent_9(), UIVertex_t1204258818_StaticFields::get_offset_of_simpleVert_10(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1391 = { sizeof (RectTransformUtility_t2941082270), -1, sizeof(RectTransformUtility_t2941082270_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1391[1] = { RectTransformUtility_t2941082270_StaticFields::get_offset_of_s_Corners_0(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1392 = { sizeof (RenderMode_t4280533217)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1392[4] = { RenderMode_t4280533217::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1393 = { sizeof (Canvas_t209405766), -1, sizeof(Canvas_t209405766_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1393[1] = { Canvas_t209405766_StaticFields::get_offset_of_willRenderCanvases_2(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1394 = { sizeof (WillRenderCanvases_t3522132132), sizeof(Il2CppMethodPointer), 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1395 = { 0, -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1396 = { sizeof (CanvasGroup_t3296560743), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1397 = { sizeof (CanvasRenderer_t261436805), -1, 0, 0 }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1398 = { sizeof (Event_t3028476042), sizeof(Event_t3028476042_marshaled_pinvoke), sizeof(Event_t3028476042_StaticFields), 0 }; extern const int32_t g_FieldOffsetTable1398[4] = { Event_t3028476042::get_offset_of_m_Ptr_0(), Event_t3028476042_StaticFields::get_offset_of_s_Current_1(), Event_t3028476042_StaticFields::get_offset_of_s_MasterEvent_2(), Event_t3028476042_StaticFields::get_offset_of_U3CU3Ef__switchU24map0_3(), }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1399 = { sizeof (EventType_t3919834026)+ sizeof (Il2CppObject), sizeof(int32_t), 0, 0 }; extern const int32_t g_FieldOffsetTable1399[33] = { EventType_t3919834026::get_offset_of_value___1() + static_cast<int32_t>(sizeof(Il2CppObject)), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #ifdef __clang__ #pragma clang diagnostic pop #endif
[ "bruno.penzar@posteo.de" ]
bruno.penzar@posteo.de
62f1b127b61498593059938a240331d6209360e5
a8fc2294c93177a938e1f026b09e6c8cb24a8512
/SnakeGame.cpp
616e9ee77e2696a5ca1bd4e9e76e5f19132d7ae6
[]
no_license
vedant1771/Hacktober2k21
9b425e5b12a0f9f1676edbcd07f2901b84701c54
61943d6b5ecaf6093a481bc5914a3c9e536567a4
refs/heads/main
2023-08-29T17:41:05.695844
2021-10-29T16:55:49
2021-10-29T16:55:49
412,986,205
0
1
null
2021-10-05T16:01:50
2021-10-03T05:35:43
null
UTF-8
C++
false
false
2,188
cpp
#include<iostream> #include<conio.h> using namespace std; bool gameover; const int width = 20; const int height = 17; int x, y, fruitX, fruitY, score; int tailX[100], tailY[100]; //snake coordinates int nTail; enum eDirecton {STOP = 0, LEFT,RIGHT, UP, DOWN}; // Controls eDirecton dir; void Setup() { gameover = false; dir = STOP; x = width / 2; y = height / 2; fruitX = rand() % width; //display fruit in a random place fruitY = rand() % height; score = 0; } void Draw() { system("cls"); for(int i = 0; i < width+2; i++) cout << "#"; cout << endl ; for (int i = 0; i < height ; i++) { for (int j = 0; j < width; j++) { if (j == 0) cout << "#"; //walls if (i == y && j == x) cout << "*"; // snake tale else if (i == fruitY && j == fruitX ) cout << "%"; // change it to change the fruit else { bool print = false; for (int k = 0; k< nTail ; k++) { if (tailX [k] == j && tailY [k] == i) { cout << "*"; print = true; } } if (!print) cout << " "; } if (j == width -1) cout << "#"; } cout << endl; } for (int i = 0; i< width+2; i++) cout << "#"; cout << endl; cout << "Score:" << score << endl ; } void Input () { if (_kbhit()) { switch (_getch()) { case 'a': dir = LEFT; break; case 'd': dir = RIGHT; break; case 'w': dir = UP; break; case 's': dir = DOWN ; break; case 'x': gameover = true; break; } } } void algorithm() { int prevX = tailX [0]; int prevY = tailY [0]; int prev2X, prev2Y; tailX[0] = x; tailY[0] = y; for(int i = 1;i < nTail ; i++) { prev2X = tailX[i]; prev2Y = tailY[i]; tailX[i] = prevX; tailY[i] = prevY; prevX = prev2X; prevY = prev2Y ; } switch (dir) { case LEFT: x--; break; case RIGHT: x++; break; case UP: y--; break; case DOWN: y++; break; default: break; } if (x >= width) x =0;else if (x <0) x = width -1; if (y >= height) y = 0; else if (y < 0) y = height - 1; for (int i =0; i< nTail ;i++) if (tailX[i] == x && tailY[i] == y) gameover = true; if (x == fruitX && y == fruitY) { score +=10; fruitX = rand() % width; fruitY = rand() % height; nTail ++; } } int main() { Setup(); while (!gameover) { Draw (); Input (); algorithm (); } return 0; }
[ "noreply@github.com" ]
vedant1771.noreply@github.com
a2ce31d7483c3c0c72b486f3ff373bd98d942fef
c6edda04814ffb23df750ce23b81169ec35c0057
/GameEditor/DefaultShaders.h
e7224169680d34d7e4f16fd7bfd5adcadcc15e07
[]
no_license
wlodarczykbart/SunEngine
91d755cca91ca04ef91879ccfd11500f884e5066
04200f084653e88ba332bb260b6964996f35f5a0
refs/heads/master
2023-06-07T02:33:20.668913
2021-07-03T17:31:38
2021-07-03T17:31:38
315,081,186
0
0
null
null
null
null
UTF-8
C++
false
false
58
h
#pragma once #include "Types.h" namespace SunEngine { }
[ "bartwlodarczyk92@gmail.com" ]
bartwlodarczyk92@gmail.com
0f4b9001ab469ce5954dfee5527c28cd842c65b2
da64f2caeedea6c2889621c4c4bbb9ec812b6ba7
/include/MemoryMap.hpp
1589a2d24c9bee5c4abbe59ddff4b3f60d89f7cf
[]
no_license
FelixWeichselgartner/GameBoy-Classic-Emulator
cce53440844eeee098b3b5c31f5a8a71487c500e
495a00f8389af39700dd7d3e436b151921210ff8
refs/heads/master
2021-07-13T07:19:32.846441
2020-06-23T17:18:29
2020-06-23T17:18:29
173,909,929
4
0
null
null
null
null
UTF-8
C++
false
false
1,924
hpp
#ifndef MEMORYMAP_HPP_ #define MEMORYMAP_HPP_ //---------------------------------------------------------------------------------------------- // Memory Map: #define ADDR_ROM_0 0x0000 // 16KB ROM Bank 00 (in cartridge, fixed at bank 00) #define ADDR_ROM_1 0x4000 // 16KB ROM Bank 01...NN (in cartridge, witchable bank number) #define ADDR_VRAM_T_S 0x8000 // VRAM: Tiles and Sprites #define ADDR_VRAM_T_A 0x9000 // VRAM: Tiles Alt #define ADDR_VRAM_T_M_1 0x9800 // VRAM: Tilemap 1 #define ADDR_VRAM_T_M_2 0x9C00 // VRAM: Tilemap 2 #define ADDR_EXT_RAM 0xA000 // 8KB External RAM (in cartridge, switchable bank, if any) #define ADDR_INT_RAM_1 0xC000 // 4KB Work RAM Bank 0 (WRAM) #define ADDR_INT_RAM_2 0xD000 // 4KB Work RAM Bank 1 (WRAM) (switchable bank 1-7 in CGB Mode) #define ADDR_ECHO 0xE000 // Same as C000-DDFF (ECHO) (typically not used) #define ADDR_OAM 0xFE00 // Sprite Attribute Table (OAM) (Can't change during screen redraw) #define ADDR_UNUSABLE 0xFEA0 // Not Usable #define ADDR_IO 0xFF00 // I/O Ports #define ADDR_DIV_REG 0xFF04 // divider register state #define ADDR_TIMA 0xFF05 // current state if the timer counting #define ADDR_TMA 0xFF06 // timer is reset to this value after overflow #define ADDR_TMC 0xFF07 // timer control #define ADDR_INTR_REQ 0xFF0F // Interupt Request Register #define ADDR_HRAM 0xFF80 // High RAM (HRAM) (Stack) #define ADDR_INTR_EN 0xFFFF // Interupt Enable Register //---------------------------------------------------------------------------------------------- // Size of memory regions. const int VRAM_SIZE = ADDR_EXT_RAM - ADDR_VRAM_T_S; const int ECHO_SIZE = ADDR_OAM - ADDR_ECHO; const int OAM_SIZE = ADDR_UNUSABLE - ADDR_OAM; const int IO_SIZE = ADDR_HRAM - ADDR_IO; const int HRAM_SIZE = ADDR_INTR_EN - ADDR_HRAM; //---------------------------------------------------------------------------------------------- #endif
[ "felix.weichselgartner@t-online.de" ]
felix.weichselgartner@t-online.de
1c38da3804637a7fccdc558037369ea3416c9496
8c540a482bdf6217c3f72aebf8a13966a6b48dbe
/containers/_tuple.cpp
aac69ee69b1c4327203d92aaad37bb1d9ecda5bd
[]
no_license
eyupgurel/workbench
6633d131fac470ed981bcd193684b28948af1af6
4af3e71444f96a8ccff6bf594867daca48f2119e
refs/heads/master
2020-04-21T16:17:29.864851
2019-10-16T19:45:30
2019-10-16T19:45:30
169,695,934
0
0
null
null
null
null
UTF-8
C++
false
false
1,747
cpp
// // Created by egl on 6/13/19. // #include "_tuple.h" using namespace containers; std::tuple<int,int,int> rotate(std::tuple<int,int,int> t) { return tuple{std::get<2>(t),std::get<0>(t),std::get<1>(t)}; } void drive_tuple() { int i =1; int j=2; double d=1.2; _tuple<int,int,double> _t1{i,j,d}; _tuple<int,int,double> _t12{1,1,1.2}; vector<int> vec{1,2,3}; _tuple<vector<int>,int,double, int, char,const char*,string,std::vector<int>> t3 {vector<int>{1,2,3}, i,1.1, 42, 'a',"ass","am",vec}; auto _tt = containers::__make_tuple(vector<int>{1,2,3}, i,1.1, 42, 'a',"ass","am",vec); string s = "Hello"; vector<int> v = {1,22,3,4,5}; auto x = make_tuple(s,v,1.2); Tuple<double , int, char> t1 {1.1, 42, 'a'}; cout << t1 << "\n"; cout << Tuple<double ,int,int,int>{1.2,3,5,7} << "\n"; cout << Tuple<double ,int,int>{1.2,3,5} << "\n"; cout << Tuple<double ,int>{1.2,3} << "\n"; cout << Tuple<double>{1.2} << "\n"; cout << Tuple<>{} << "\n"; auto xxx = Tuple{1.2,3,'x',1223}; cout << "{ " // write { 1.1, 42, a } << get<0>(t1) << ", " << get<1>(t1) << ", " << get<2>(t1) << " }\n"; auto xx = get<0>(t1); // xx is a double get<2>(t1)='b'; cout << t1 << "\n"; const Tuple<double , int, char> t2 {1.1, 42, 'a'}; //get<2>(t2) = 'b';// error : t2 is const char cc = get<2>(t2); array<int,7>a={1,2,3,5,8,13,25}; auto x1=get<5>(a);// 13 auto x2 = a[5];// 13 auto sz = tuple_size<decltype(a)>::value;// 7 typename tuple_element<5,decltype(a)>::type x3 = 13;// x3 is an int tuple<int,int,int>t3ints{3,5,8}; auto rotatedexp=rotate(t3ints); auto rotatedimp=rotate({6,8,9}); }
[ "eyupgurel@gmail.com" ]
eyupgurel@gmail.com
d0d21b70fb50eee3236a0a62ed0a435365987373
7850eebcf9cf39c3ad05a3a09ea849a8a47e36a7
/Hardware/Node/ID/ID.ino
109c65dd8120d3d714e4551b4c4a2a0117b540b6
[]
no_license
a84926601/Smart-Keeper
440c3dbec39b28042dc5e4aa76b742ae88b25086
e296597a3bda27484b36f4f4ec2d8431b030592d
refs/heads/master
2020-03-22T01:31:21.671560
2018-09-15T07:29:33
2018-09-15T07:29:33
139,310,734
0
0
null
null
null
null
UTF-8
C++
false
false
360
ino
void setup() { // put your setup code here, to run once: uint32_t checksum = 0; for(uint16_t u = 0; u < 2048; u++) { checksum += * ( (byte *) u );//checksum += the byte number u in the ram } Serial.begin(115200); Serial.println(checksum , HEX); } void loop() { // put your main code here, to run repeatedly: Serial.println("Hello!"); }
[ "jojo.5653@gmail.com" ]
jojo.5653@gmail.com
ccc04ae9bdab9b918a746dcc593fbcdceae1198e
b932134deff2e82f984c267c26b47ce74c521ef5
/leetcode/1462. Course Schedule IV.cpp
815a7da74838c438371a5fd20195b7bf483ec816
[ "MIT" ]
permissive
chamow97/Interview-Prep
db234e0df0bfa6b3358d73ac187d6a132fa14595
9ce13afef6090b1604f72bf5f80a6e1df65be24f
refs/heads/master
2022-11-06T07:06:54.705258
2020-06-21T07:29:14
2020-06-21T07:29:14
112,472,858
1
0
null
null
null
null
UTF-8
C++
false
false
1,168
cpp
class Solution { public: void dfs(int u, int v, vector< vector<int> > &adj, bool &possible, vector<bool> &visited) { visited[u] = true; if(u == v) { possible = true; } for(auto i : adj[u]) { if(!visited[i]) { dfs(i, v, adj, possible, visited); } } } vector<bool> checkIfPrerequisite(int n, vector<vector<int>>& prerequisites, vector<vector<int>>& queries) { vector<bool> visited(n, false); vector< vector<int> > adj(n); for(auto i : prerequisites) { adj[i[0]].push_back(i[1]); } vector<bool> ans; map<pair<int, int>, bool> ms; for(auto i : queries) { int u = i[0]; int v = i[1]; bool possible = false; if(ms.find({u, v}) != ms.end()) { possible = ms[{u, v}]; } else { fill(visited.begin(), visited.end(), false); dfs(u, v, adj, possible, visited); } ms[{u, v}] = possible; ans.push_back(ms[{u, v}]); } return ans; } };
[ "16441513+chamow97@users.noreply.github.com" ]
16441513+chamow97@users.noreply.github.com
c08db44d8285af28c4c596c0dc89d4ca82b07c9f
32a78ca8eb756114b38032b74a4e3a2f74a757a0
/src/gpu/shader_lsq.hh
cfe4cc5a69eb33eb8d3255378b9a40f2947a58fa
[]
no_license
DesignSpaceExplore/gem5-gpu
b0e45b2f5164b7ec0afd837b3f3f3ecd4de9832f
1960a6488d9671110b53184fc64051f7fe755bde
refs/heads/master
2020-12-25T22:48:12.319776
2014-04-28T02:26:46
2014-04-28T02:26:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
16
hh
shader_lsq_lf.hh
[ "vinay@Blackpearl.(none)" ]
vinay@Blackpearl.(none)
63754e1282a4af915b5b0dd8a31a13cb7d01a774
db48761fc3cb0f8c702c5e66dbd4b683172e53cc
/euler40.cpp
84d8865fe758f2d806670a3b3a1ad064ec7ce084
[]
no_license
subrataduttauit/Project_Euler
15e0e6e1dd3182c35fd1833d6ece826c96a2db98
9e9b17d6a7d07db23cb7749689bfdfeb0836e09d
refs/heads/master
2020-04-21T00:37:00.450263
2015-08-24T18:59:45
2015-08-24T18:59:45
40,826,511
1
0
null
null
null
null
UTF-8
C++
false
false
694
cpp
/* * Solution to Project Euler problem 40 * by Subrata Dutta * * University Institute of Technology, Burdwan University * Dept. of Information Technology * https://github.com/subrataduttauit * https://in.linkedin.com/in/subrataduttauit */ #include <stdio.h> #include <math.h> int main(void) { int nth = 1; int i; int d[7], l; int p = 1; for (i = 1, l = 0; l < 7; i++) { int digits = log10(i)+1; int j; for (j = 0; j < digits; j++, nth++) { if (nth == pow(10, l)) { d[l++] = (i / (int)pow(10, digits-j-1)) % 10; /* retrieve i's j-th digit */ } } } for (i = 0; i < l; i++) { p *= d[i]; } printf("%d\n", p); return 0; }
[ "subrataduttauit@gmail.com" ]
subrataduttauit@gmail.com
9af9cb94715cf7a36cd969bf492a57804027aca7
16240579ec9afe943ef9888ed6a161700e69b47e
/main.cpp
13012b271ea635b7da6ad043c85e96a1a4e0c4df
[]
no_license
Artjxm/CppProjects
876cae3c7c304db75daba4921701218a43e84e07
42365877ffc562caf3c7bc852b246fd72ff941e9
refs/heads/master
2022-12-22T02:13:32.275931
2020-09-22T09:08:42
2020-09-22T09:08:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,833
cpp
#include <iostream> #include <stack> #include <algorithm> #include <cmath> bool isOperator(char c) { return c == '+' || c == '-' || c == '*' || c == '/' || c == '^'; } bool isOperand(char c) { return isdigit(c); } int precedence (char c) { if (c == '^') return 3; else if (c == '*' || c == '/') return 2; else if (c == '-' || c == '+') return 1; else return -1; } std::string infixToPrefix(std::stack<char> stack, std::string infix) { std::string prefix; reverse(infix.begin(), infix.end()); for (auto i = 0; i < infix.length(); ++i) { if (infix[i] == '(') infix[i] = ')'; else if (infix[i] == ')') infix[i] = '('; } for (auto i = 0; i < infix.length(); ++i) { if (isOperand(infix[i])) prefix += infix[i]; else if (infix[i] == '(') stack.push(infix[i]); else if (infix[i] == ')') { while (stack.top() != '(' && !stack.empty()) { prefix += stack.top(); stack.pop(); } if (stack.top() == '(') stack.pop(); } else if (isOperator(infix[i])) { if (stack.empty()) stack.push(infix[i]); else { if (precedence(infix[i]) > precedence(stack.top())) stack.push(infix[i]); else if ((precedence(infix[i]) == precedence(stack.top())) && infix[i] == '^') { while ((precedence(infix[i]) == precedence(stack.top())) && infix[i] == '^') { prefix += stack.top(); stack.pop(); } stack.push(infix[i]); } else if (precedence(infix[i]) == precedence(stack.top())) stack.push(infix[i]); else { while (!stack.empty() && precedence(infix[i]) < precedence(stack.top())) { prefix += stack.top(); stack.pop(); } stack.push(infix[i]); } } } } while (!stack.empty()) { prefix += stack.top(); stack.pop(); } std::reverse(prefix.begin(), prefix.end()); return prefix; } int evaluatePrefix(std::string expr) { std::stack<int> stack; for (auto j = expr.length(); j >= 0; --j) { if (isOperand(expr[j])) stack.push(expr[j] - '0'); else { int operand1 = stack.top(); stack.pop(); int operand2 = stack.top(); stack.pop(); switch (expr[j]) { case '+': stack.push(operand1 + operand2); break; case '-': stack.push(operand1 - operand2); break; case '*': stack.push(operand1 * operand2); break; case '/': stack.push(operand1 / operand2); break; case '^': stack.push(pow(operand1, operand2)); break; default: break; } } } return stack.top(); } int main() { std::string infix, prefix; std::cout << "Enter your infix expression, please: "; std::cin >> infix; std::stack <char> stack; prefix = infixToPrefix(stack, infix); std::cout << "\nYour expression but in prefix style: " << prefix; std::cout << "\nThe evaluated result is: " << evaluatePrefix(prefix); }
[ "Shadonspass1" ]
Shadonspass1
621e390438ec4b413b35773fb8684221149a8747
2bf81ffecf07f0d52bcc7adf64605d0fafdc9117
/ThreadContextSwitchScript.cpp
851cdc1233fc53c0709be80cd3022551d1776ad9
[]
no_license
sumitdhoble/OSProject
a08d1ca4dcc9e80e3f16232b101af61908930c67
47ba190204de8d1c17e7bf2f8af1a4b1acc42844
refs/heads/master
2021-01-02T22:57:54.071103
2012-12-12T22:12:45
2012-12-12T22:12:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
317
cpp
#include<iostream> #include<cstdlib> #include<sys/time.h> #include<unistd.h> #include<sys/wait.h> int main(){ int i = 0, iterations = 100; system("g++ -pthread ThreadContextSwitch.cpp -o ThreadContextSwitch"); for(i = 0; i < iterations; i++){ system("./ThreadContextSwitch"); usleep(100); } return 0; }
[ "sumit@vdeshpan-XPS-8300.(none)" ]
sumit@vdeshpan-XPS-8300.(none)
e3272df82eec09c1101ed967e9363894dd0bcc29
ff92645b83f7e344cbf6f1938e0750634c234484
/src/sensor_data/loop_pose.cpp
5508a407a15f1dd8abe6f49ad52619789b1bb6bd
[]
no_license
leidali/lidar_localization
c8507109cc288e11a5bce96d0d0c05cbef8660cf
d7589bed13e85cdc09fbe36597432239c7b01ff7
refs/heads/master
2023-04-08T21:43:36.206233
2021-04-22T08:18:06
2021-04-22T08:18:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
301
cpp
// // Created by zlc on 2021/4/20. // #include "lidar_localization/sensor_data/loop_pose.hpp" namespace lidar_localization { Eigen::Quaternionf LoopPose::GetQuaternion() { Eigen::Quaternionf q; q = pose.block<3,3>(0,0); // 使用旋转矩阵直接给四元数赋值 return q; } }
[ "2731275645@qq.com" ]
2731275645@qq.com
be46126bb0292b53b23f46210c558a3b5edc7a92
3c3b480709b13db0603465de9f6ae0b1e9e46a91
/D3D11_App/D3D11_App/Chapter13_Instancing and Culling/RenderStates.h
cfab003a77072ecaed04ddedf563903e16480803
[]
no_license
skyvoid123/D3D11
6aa6aad03f79519390e855c16b9a2e0853b9beb1
5cee13cfb7612cb31f93e9c3787c12e5fe6cfbbd
refs/heads/master
2020-12-07T11:49:17.747309
2017-04-28T02:20:30
2017-04-28T02:20:30
66,762,534
2
0
null
null
null
null
UTF-8
C++
false
false
625
h
#pragma once #include "d3dUtil.h" class RenderStates { public: static void InitAll(ID3D11Device* device); static void DestroyAll(); // Rasterizer states static ID3D11RasterizerState* WireframeRS; static ID3D11RasterizerState* NoCullRS; static ID3D11RasterizerState* CullClockwiseRS; // Blend states static ID3D11BlendState* AlphaToCoverageBS; static ID3D11BlendState* TransparentBS; static ID3D11BlendState* NoRenderTargetWritesBS; // Depth/stencil states static ID3D11DepthStencilState* MarkMirrorDSS; static ID3D11DepthStencilState* DrawReflectionDSS; static ID3D11DepthStencilState* NoDoubleBlendDSS; };
[ "skyvoid@qq.com" ]
skyvoid@qq.com
9c08e9151ad6598ab7102a2fe683e80d0a5e2323
5e24b93c2eb4e2f4642eb8e1a8a80fb76e3e48c7
/LED_as_sensor.ino
96f1fec9933dbe7df2d9cc136cc7e6fe4a82f50b
[]
no_license
giantsquidaxon/LED_as_light_sensor_attiny85
7c0455ac61d615e0a7118d9bcaef6611e4f1ede7
2243ee2bb37660a2c4b33f63f90ccbe24edfac00
refs/heads/master
2022-12-09T16:49:33.135151
2020-09-07T10:28:16
2020-09-07T10:28:16
293,476,430
0
0
null
null
null
null
UTF-8
C++
false
false
2,375
ino
#define ANODE_PIN_A 3 #define CATHODE_PIN_A 4 #define ANODE_PIN_B 1 #define CATHODE_PIN_B 2 #define MONITOR 0 #define LED_TIMEOUT 100000 #define SAMPLES_TO_AVERAGE 5 void setup() { // put your setup code here, to run once: #ifdef LOGGING Serial.begin(9600); #endif } /** Perform a single on off cycle with the specified duty cycle, between 0 and 4095. */ inline void do_cycle() __attribute__((always_inline)); void do_cycle(uint16_t duty) { PORTB = 1 << ANODE_PIN_A | 1 << ANODE_PIN_B; for (int i = 0; i < duty; i++) { __asm__("nop\n\t"); } PORTB = 0b00000000; for (int i = duty; i <= 4096; i++) { __asm__("nop\n\t"); } return; } /** log a sample to be averaged. return true is a shadow has been detected **/ bool log_sample(long int sample) { static long int previous_count = LED_TIMEOUT; static long int current_count = 0; static int n = 0; current_count += sample; if (++n < SAMPLES_TO_AVERAGE) { return false; } current_count /= n; long int t = previous_count + 2 * (previous_count / 20); previous_count = current_count; n = 0; return (current_count > t); } /** Flash the bug's eyes */ void eyeflash() { DDRB = 1 << ANODE_PIN_A | 1 << CATHODE_PIN_A | 1 << ANODE_PIN_B | 1 << CATHODE_PIN_B; for (uint16_t k = 0; k < 256; k++) { uint16_t duty = (k * k) >> 4 ; do_cycle(duty); } for (uint16_t k = 255; k != 0; k--) { uint16_t duty = (k * k) >> 4 ; for (int i = 0; i < 3; i++) { do_cycle(duty); } } } void loop() { // Charge LED capacitance // Set cathode pin to OUT #ifdef MONITOR DDRB = 1 << ANODE_PIN_A | 1 << CATHODE_PIN_A | 1 << MONITOR; #else DDRB = 1 << ANODE_PIN_A | 1 << CATHODE_PIN_A; #endif // Set cathode to 1, anode to 0. PORTB = 1 << CATHODE_PIN_A; // Wait delay(10); // Set cathode pin to IN / HIGH Z // Disable internal pullup #ifdef MONITOR DDRB = 1 << ANODE_PIN_A | 1 << MONITOR; PORTB = 1 << MONITOR; #else DDRB = 1 << ANODE_PIN_A; PORTB = 0x00; #endif // Read from cathode pin until 0 long int count = 0; while (PINB & 1 << CATHODE_PIN_A && count < LED_TIMEOUT) { count++; } #ifdef MONITOR PORTB = 0x00; #endif #ifdef LOGGING // Write count out to serial Serial.print(count); Serial.print('\n'); #endif // Flash if shadow if (log_sample(count)) { eyeflash(); delay(2000); } }
[ "dasnarrenschiff@gmail.com" ]
dasnarrenschiff@gmail.com
fb8a216ef702f2c85e3126ef8f79eb8b934b9af5
bc90e70ee2139b034c65a5755395ff55faac87d0
/libs/algorithm/test/pop_heap.cpp
52f0ee211adbf01b6ecfcee2b0e028a7746ec030
[ "BSL-1.0" ]
permissive
Manu343726/Sprout
0a8e2d090dbede6f469f6b875d217716d0200bf7
feac3f52c785deb0e5e6cd70c8b4960095b064be
refs/heads/master
2021-01-21T07:20:16.742204
2015-05-28T04:11:39
2015-05-28T04:11:39
37,670,169
0
1
null
2015-06-18T16:09:41
2015-06-18T16:09:41
null
UTF-8
C++
false
false
2,286
cpp
/*============================================================================= Copyright (c) 2011-2015 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout 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) =============================================================================*/ #ifndef SPROUT_LIBS_ALGORITHM_TEST_POP_HEAP_CPP #define SPROUT_LIBS_ALGORITHM_TEST_POP_HEAP_CPP #include <sprout/algorithm/pop_heap.hpp> #include <sprout/array.hpp> #include <sprout/sub_array.hpp> #include <sprout/container.hpp> #include <testspr/tools.hpp> namespace testspr { static void algorithm_pop_heap_test() { using namespace sprout; { SPROUT_STATIC_CONSTEXPR auto arr1 = array<int, 10>{{10, 8, 9, 6, 7, 5, 3, 1, 2, 4}}; // pop heap { SPROUT_STATIC_CONSTEXPR auto heap = sprout::pop_heap( arr1 ); TESTSPR_BOTH_ASSERT(testspr::equal( heap, array<int, 10>{{9, 8, 5, 6, 7, 4, 3, 1, 2, 10}} )); } { SPROUT_STATIC_CONSTEXPR auto heap = sprout::fit::pop_heap( arr1 ); TESTSPR_BOTH_ASSERT(testspr::equal( heap, array<int, 9>{{9, 8, 5, 6, 7, 4, 3, 1, 2}} )); } // pop heap // from sub range { SPROUT_STATIC_CONSTEXPR auto heap = sprout::pop_heap( sprout::sub(arr1, 2, 10) ); TESTSPR_BOTH_ASSERT(testspr::equal( heap, array<int, 8>{{7, 6, 4, 5, 3, 1, 2, 9}} )); TESTSPR_BOTH_ASSERT(testspr::equal( sprout::get_internal(heap), array<int, 10>{{10, 8, 7, 6, 4, 5, 3, 1, 2, 9}} )); } { SPROUT_STATIC_CONSTEXPR auto heap = sprout::fit::pop_heap( sprout::sub(arr1, 2, 10) ); TESTSPR_BOTH_ASSERT(testspr::equal( heap, array<int, 7>{{7, 6, 4, 5, 3, 1, 2}} )); TESTSPR_BOTH_ASSERT(testspr::equal( sprout::get_internal(heap), array<int, 10>{{10, 8, 7, 6, 4, 5, 3, 1, 2, 9}} )); } } } } // namespace testspr #ifndef TESTSPR_CPP_INCLUDE # define TESTSPR_TEST_FUNCTION testspr::algorithm_pop_heap_test # include <testspr/include_main.hpp> #endif #endif // #ifndef SPROUT_LIBS_ALGORITHM_TEST_POP_HEAP_CPP
[ "bolero.murakami@gmail.com" ]
bolero.murakami@gmail.com
74261dfff6080f2f42a2eb66226059a098b1228e
e54b9ff5eaf41ab13d156430554077f133b1be06
/leetcode2134/leetcode2134_2.cpp
6b64f3bbc855501f464e127bfa517ff62dd0dce8
[]
no_license
allpasscool/leetcodes
bb0bd1391d5201baad214e5b4f8089dfe9c782b0
4fd81b4cf9382890cadc6bf8def721cc25eb9949
refs/heads/master
2022-05-21T11:34:06.958063
2022-03-24T08:57:41
2022-03-24T08:57:41
163,725,766
0
0
null
null
null
null
UTF-8
C++
false
false
1,361
cpp
class Solution { public: int minSwaps(vector<int> &nums) { int totalOnes = 0, curOnesInWindow = 0, onesInWindow = 0, n = nums.size(); for (int i = 0; i < n; i++) if (nums[i] == 1) totalOnes++; int left = 0; for (int right = 0; right < n * 2 && left < n; right++) { left = right - totalOnes; // right >= totalOnes means that the window size is as big as totalOnes // so we need to move left // why need to do "nums[left % n]"? consider [0, 0] // when right = 3, totalOnes = 0 // 3 - 0 = 0 => nums[3 % n] if (right >= totalOnes && nums[left % n] == 1) curOnesInWindow--; if (nums[right % n] == 1) curOnesInWindow++; onesInWindow = max(curOnesInWindow, onesInWindow); } return totalOnes - onesInWindow; } }; // Runtime: 96 ms, faster than 88.03% of C++ online submissions for Minimum Swaps to Group All 1's Together II. // Memory Usage: 80.5 MB, less than 52.47% of C++ online submissions for Minimum Swaps to Group All 1's Together II.// time complexity: O(n) // space complexity: O(1) // https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii/discuss/1676865/Python3-Java-C%2B%2B-Easy-Sliding-Window-O(n)
[ "a82012844013@yahoo.com.tw" ]
a82012844013@yahoo.com.tw
5466f9d70ac7b3ba70643682dbc0d5b0d0de0f53
5c2addf99fb73b7a95897eb0486e28e9929fdd08
/Cospro연습문제/Cospro7.cpp
0b6c5f4bdc16abde3c0ca6e7b252be722ed13a55
[]
no_license
UmJaeJeong/Algorithm-DataStruct
902bc7b86dc4b74b8334984a78c0159bd2bc3e5d
51cdd53a7cf815eb20801215d8147fb537d67e59
refs/heads/master
2020-04-03T15:28:36.084262
2019-02-15T01:14:08
2019-02-15T01:14:08
155,363,765
1
0
null
null
null
null
UHC
C++
false
false
1,684
cpp
#include <iostream> #include <string> #include <vector> using namespace std; /*문제7 Cospro 오름차순으로 정렬되어있는 두 배열 arrA, arrB를 하나의 배열로 합치려 합니다. 단, 합친 후의 배열도 오름차순으로 정렬 되어 있어야 합니다. 예를 들어 arrA = [-2, 3, 5, 9], arrB = [0, 1, 5]인 경우 두 배열을 오름차순으로 정렬된 하나의 배열로 합치면 [-2, 0, 1, 3, 5, 5, 9]가 됩니다. 오름차순으로 정렬된 두 배열 arrA와 arrB가 주어졌을 때, 두 배열을 오름차순으로 정렬된 하나의 배열로 합쳐서 return 하 도록 solution 함수를 작성하려 합니다. 빈칸을 채워 전체 코드를 완성해주세요.*/ vector<int> solution(vector<int> arrA, vector<int> arrB) { int arrA_idx = 0, arrB_idx = 0; int arrA_len = arrA.size(); int arrB_len = arrB.size(); vector<int> answer; while (arrA_idx < arrA_len && arrB_idx < arrB_len){ if (arrA[arrA_idx] < arrB[arrB_idx]) { answer.push_back(arrA[arrA_idx++]); } else { answer.push_back(arrB[arrB_idx++]); } } while (arrA_idx < arrA_len) answer.push_back(arrA[arrA_idx++]); while (arrB_idx < arrB_len) answer.push_back(arrB[arrB_idx++]); return answer; } // 아래는 테스트케이스 출력을 해보기 위한 main 함수입니다. int main() { vector<int> arrA = { -2, 3, 5, 9 }; vector<int> arrB = { 0, 1, 5 }; vector<int> ret = solution(arrA, arrB); // [실행] 버튼을 누르면 출력 값을 볼 수 있습니다. cout << "solution 함수의 반환 값은 {"; for (int i = 0; i < ret.size(); i++) { if (i != 0) cout << ", "; cout << ret[i]; } cout << "} 입니다." << endl; }
[ "39511137+UmJaeJeong@users.noreply.github.com" ]
39511137+UmJaeJeong@users.noreply.github.com
0d34501dd71ca848258a11619737c5571c03619a
b6e90a0e63a10e3091d5476e0bbf738d1aa412ef
/source/lec7/mon/ttp2-user.cpp
8308a7aef121e3b2f923a5291eb41efd81f7a899
[ "BSL-1.0" ]
permissive
Cypher1/Cpp_Tuts
53909bc6210b11ceda43d08a7c948f9fc99986f9
e67e8be04ff6e29e620c8245762c05cd27dda974
refs/heads/master
2020-06-28T20:04:18.421631
2017-10-20T03:10:11
2017-10-20T03:10:11
98,940,645
2
0
null
2017-09-16T06:56:31
2017-08-01T00:08:53
C++
UTF-8
C++
false
false
156
cpp
#include <vector> #include "ttpStack.hpp" int main(void) { Stack<int, std::vector > s1; s1.push(1); s1.push(2); std::cout << s1 << std::endl; }
[ "mattstark75@gmail.com" ]
mattstark75@gmail.com
6f7086c09ff33638bfa90d058efb7f50396a5350
e02fa80eef98834bf8a042a09d7cb7fe6bf768ba
/TEST_MyGUI_Source/MyGUIEngine/include/MyGUI_Instance.h
9d50505893548012b5efd58c18987888bca84ee0
[]
no_license
MyGUI/mygui-historical
fcd3edede9f6cb694c544b402149abb68c538673
4886073fd4813de80c22eded0b2033a5ba7f425f
refs/heads/master
2021-01-23T16:40:19.477150
2008-03-06T22:19:12
2008-03-06T22:19:12
22,805,225
2
0
null
null
null
null
UTF-8
C++
false
false
843
h
/*! @file @author Albert Semenov @date 11/2007 @module */ #ifndef __MYGUI_INSTANCE_H__ #define __MYGUI_INSTANCE_H__ #define INSTANCE_HEADER(type) \ private: \ static type* msInstance; \ bool mIsInitialise; \ public: \ type();\ ~type();\ static type& getInstance(void); \ static type* getInstancePtr(void); #define INSTANCE_IMPLEMENT(type) \ type* type::msInstance = 0; \ type* type::getInstancePtr(void) {return msInstance;} \ type& type::getInstance(void) {MYGUI_ASSERT(0 != msInstance, "instance " << #type << " was not created");return (*msInstance);} \ type::type() : mIsInitialise(false) {MYGUI_ASSERT(0 == msInstance, "instance " << #type << " is exsist");msInstance=this;} \ type::~type() {msInstance=0;} \ const std::string INSTANCE_TYPE_NAME(#type); #endif // __MYGUI_INSTANCE_H__
[ "my.name.post@gmail.com" ]
my.name.post@gmail.com
bac7d413b69ea52afdfdb46d988f20d34df1befc
21a7244cc28c301bb38e40208ed0ca70f77c604b
/TJU/1131 - The Circumference of the Circle.cpp
5d6618efaeed6f905967e1c6d300b11a358b0c66
[]
no_license
jhtan/Online-Judge-Solutions
fc18efb8d8310bd06edb96c4b2ea0ac0dc79aae5
7c2d870affda103d57ecd6f0820b9e6fe5c58928
refs/heads/master
2020-12-03T05:10:33.420297
2013-09-10T20:21:03
2013-09-10T20:21:03
15,348,130
1
0
null
null
null
null
UTF-8
C++
false
false
645
cpp
#include <iostream> #include <iomanip> #include <cmath> #define PI 3.141592653589793 using namespace std; int main(){ freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); double x1,y1,x2,y2,x3,y3; double a,b,c,S,R; while(cin>>x1>>y1>>x2>>y2>>x3>>y3){ a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); b=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)); c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)); S=0.5*fabs(x1*y2+x2*y3+x3*y1-y1*x2-y2*x3-y3*x1); R=a*b*c/(4*S); cout<<fixed<<setprecision(2)<<2*PI*R<<endl; } return 0; }
[ "marioyc@marioyc-laptop.(none)" ]
marioyc@marioyc-laptop.(none)
5622f1be6e9b10f5500233c7c86720a1a6e9b0c9
43efb8c60d19d37c2f42805754086f910348a5ae
/Coding/Rough Codes/problm3.cpp
4faaf872bec0a646a4ddd0344bafa989bfdb3626
[]
no_license
akshay2742/Coding-Problems
961399752b30b6a17b72b2c1b2afada9e839a326
838be77b707cc82a9453c964ff8cedce1646dfe8
refs/heads/master
2021-06-26T14:08:39.292052
2020-10-08T18:34:19
2020-10-08T18:34:19
151,247,129
0
1
null
2020-10-08T18:34:21
2018-10-02T11:59:38
C++
UTF-8
C++
false
false
552
cpp
#include<iostream> #include<math.h> #include<cstdio> using namespace std; #define int long long int checkSquare(int a) { int x,valid=1; while(a!=0){ x=a%10; a=a/10; if(x==9||x==4||x==1||x==0) continue; else return 0; } return valid; } main(){ int t,a,b,i,square,count=0; scanf("%lld",&t); while(t--) { scanf("%lld%lld",&a,&b); for(i=sqrt(a);i<=sqrt(b);i++) { if(checkSquare(i*i)){ count++;} } printf("%lld\n",count); count=0; } return 0; }
[ "prateekrishu@yahoo.com" ]
prateekrishu@yahoo.com
ae2710955e94e72f6edca7295e96e49a7808aa59
cadb83f173998f3221cca0aee713fbb722fb7822
/urg_timelapse_4/src/urgTimelapse.cpp
2170edadf1faa4cbfcfe53869b8fa6f55c948d8c
[]
no_license
bensnell/urg-videography
b6d58be10cd2ee52e0ebf44e74fd7b677b89ff07
79611f9109497c00753261dd2c1ba72e914f317d
refs/heads/master
2016-08-11T21:31:46.843383
2016-01-30T16:44:06
2016-01-30T16:44:06
50,728,978
0
0
null
null
null
null
UTF-8
C++
false
false
17,313
cpp
// // urgTimelapse.cpp // urg_timelapse_3 // // Created by Ben Snell on 1/17/16. // // // repeated scans are typically within 15 ms (but make this interval a little bigger) #include "urgTimelapse.h" urgTimelapse::urgTimelapse() { timelapseControls.setName("Timelapse Setup"); timelapseControls.add(alignmentA.set("Frame Align Angle", -3.5, -10., 10.)); timelapseControls.add(startRotateX.set("Start X Rotation", 0, -180, 180)); timelapseControls.add(startRotateY.set("Start Y Rotation", 0, -180, 180)); timelapseControls.add(startRotateZ.set("Start Z Rotation", 0, -180, 180)); cam.setFarClip(15000); } // ----------------------------------------------------------------------- // load csv file into ofFile void urgTimelapse::loadFile(string fileName) { // CSV file placed in bin/data folder with TXY format ofFile file(fileName); cout << "Loading file " + fileName << endl; // alt loading operations? // file = ofFile(fileName); // file.open(ofToDataPath(fileName), ofFile::ReadOnly, false); if (!file.exists()) ofLogError("The file " + fileName + " is missing"); // load buffer with the file buffer = file.readToBuffer(); cout << "File successfully read to buffer" << endl; // alt loading operations? // ofBuffer buffer(filePath); // buffer = ofBufferFromFile(ofToDataPath(filePath)); // ofBufferToFile(ofToDataPath(fileName), buffer); // buffer = ofBuffer(file); // ofBuffer buffer(file); } // ----------------------------------------------------------------------- void urgTimelapse::findFrames(float speed, float periodSize, float startPeriod) { // reset markers frames.clear(); // nScans = -1; long thisScanNumber = 0; frame thisFrame; thisFrame.startTime = -1; // start (zero) condition // holds the current time sought after (to be >=) long searchTime = long(startPeriod * periodSize / speed * 1000.); // ms // loop through all lines to find the frames for (ofBuffer::Line it = buffer.getLines().begin(), end = buffer.getLines().end(); it != end; ++it) { string line = *it; if (line.empty()) { cout << "Empty line found. Stopping at scan # " << thisScanNumber << endl; // nScans = thisScanNumber; break; } // get time now line.resize((int)line.find_first_of(',')); long timeNow = long(ofToDouble(line)); // ms // check if timeNow is greater than searchTime if (timeNow >= searchTime) { // new frame is found, so store existing frame (unless it's the zeroth frame) if (thisFrame.startTime != -1) { // update its length thisFrame.length = thisScanNumber - thisFrame.start; // add it to the frame vector frames.push_back(thisFrame); } // create a new frame with starting values thisFrame.start = thisScanNumber; thisFrame.startTime = float(timeNow / 1000.); // update the search time searchTime = long((startPeriod + frames.size() + 1) * periodSize / speed * 1000.); } // increment the scan number thisScanNumber++; } cout << frames.size() << " frames have been found." << endl; // if (nScans == -1) nScans = thisScanNumber // print all frame info // cout << "*** BEGIN ALL FRAME DATA ***" << endl; // cout << "#" << "\t" << "start" << "\t" << "length" << "\t" << "startTime" << endl; // for (long i = 0, end = frames.size(); i < end; i++) { // cout << i << "\t" << frames[i].start << "\t" << frames[i].length << "\t" << frames[i].startTime << endl; // } // cout << "*** END ALL FRAME DATA ***" << endl; } // ----------------------------------------------------------------------- // fill mesh with the first capture // scans are spaced out according to the speed of the rotations (degrees/sec; default = 225/64) and the timestamp of each step // each period is 180 degrees since we're recording both sides of the lidar every scan void urgTimelapse::fillFirstFrame(float speed, float periodSize, bool bClockwise, float alignmentAngle, float startPeriod) { // clear mesh for good measure firstFrame.clear(); // ------------------------------------ // ------- FIND SCANS IN FRAME -------- // ------------------------------------ // holds first time (in seconds) float timeZero; // interval of interest of the scans long frameStart = -1; long frameLength = -1; // find max interval within which to search one period float overfillAmt = 1.25; long maxSearchInterval = long(periodSize * 1/speed * 10. * overfillAmt); // overfillAmt times ideal number of scans in one frame // start and stop times to search for float startTime = startPeriod * periodSize / speed * 1000.; float stopTime = (startPeriod * periodSize + periodSize) / speed * 1000.; // For the first frame, find the start and stop scans // Note: last line may be empty long thisScanNumber = 0; for (ofBuffer::Line it = buffer.getLines().begin(), end = buffer.getLines().end(); it != end; ++it) { // get the first number (time) in this line string line = *it; if (line.empty()) { cout << "Skipping empty line" << endl; // increment counter here? continue; } line.resize((int)line.find_first_of(',')); float timeNow = ofToFloat(line); // in milliseconds // cout << timeNow << endl; // check if this scan is the start of the frame so long as it has not yet been found if (frameStart == -1) { if (timeNow >= startTime) { frameStart = thisScanNumber; timeZero = timeNow / 1000.; } } // check if it's the end of the interval if (frameStart != -1) { if (timeNow >= stopTime) { frameLength = thisScanNumber - frameStart; break; } } // increment the counter thisScanNumber++; if (thisScanNumber > frameStart + maxSearchInterval) { cout << "Couldn't find end of first frame. Try increasing search interval." << endl; break; } } // ------------------------------------ // --------- FILL FIRST FRAME --------- // ------------------------------------ // reset counter thisScanNumber = 0; // add all scans to the mesh ofBuffer::Line it = buffer.getLines().begin(); advance(it, frameStart); ofBuffer::Line end = buffer.getLines().begin(); advance(end, frameStart + frameLength); for (it; it != end; ++it) { // get this line and split up the measurements string line = *it; if (line.empty()) { cout << "Skipping empty line" << endl; continue; } vector<string> values = ofSplitString(line, ","); // get timeNow float timeNow = ofToFloat(values[0]) / 1000. - timeZero; // in seconds // put all the points in a scan in the mesh for (int i = minIndex; i < maxIndex; i++) { // find the x and y coordinates float px = ofToFloat(values[2 * i + 1]); float py = ofToFloat(values[2 * i + 2]); // find the vector to this point ofVec3f thisPoint(px, py, 0.); // remove points too close double sqDist = thisPoint.distanceSquared(ofVec3f(0.,0.,0.)); if (sqDist < minSqDist2Cam) continue; // rotate this point 90 degrees about the z axis to orient it upwards thisPoint.rotate(90., ofVec3f(0., 0., 1.)); // apply the alignment angle stretch or compression to realign the two chuncks float alignmentFactor = (float)i / 682. * alignmentAngle; thisPoint.rotate(alignmentFactor, ofVec3f(0., 0., 1.)); // rotate this point about the y axis an amount proportional to this scanNumber and the number of scans in this frame (since this changes) float rotationAmt = (float)thisScanNumber / (float)frameLength * periodSize; // cout << rotationAmt << endl; // if clockwise is true, rotate in negative direction if (bClockwise) rotationAmt *= -1.; thisPoint.rotate(rotationAmt, ofVec3f(0., 1., 0.)); // add the point to the mesh with a color firstFrame.addVertex(thisPoint); firstFrame.addColor(ofFloatColor(1.)); } thisScanNumber++; } } // --------------------------------------------------------------------- // graphs 360 degree panorama // slide is the rotation here void urgTimelapse::drawFirstFrame() { // cam.begin(); ofPushMatrix(); // rotate the original frame ofRotate(startRotateX, 1, 0, 0); ofRotate(startRotateY, 0, 1, 0); ofRotate(startRotateZ, 0, 0, 1); firstFrame.drawVertices(); ofPopMatrix(); // cam.end(); } // --------------------------------------------------------------------- void urgTimelapse::reset() { frameNum = 0; } // --------------------------------------------------------------------- void urgTimelapse::run(float speed, float periodSize, bool bClockwise, float alignmentAngle, float startPeriod) { // exit function if frame number is -1 if (frameNum == -1) return; // reset frame (MUST DO THIS) renderedFrame.clear(); // ------------------------------------ // ------------ FILL FRAME ------------ // ------------------------------------ // reset counter int scanNum = 0; // add scans to the mesh as dictated by the frames ofBuffer::Line it = buffer.getLines().begin(); advance(it, frames[frameNum].start); ofBuffer::Line end = buffer.getLines().end(); for (it, end; it != end; ++it) { // get line string line = *it; vector<string> values = ofSplitString(line, ","); // put all the points in a scan in the mesh for (int i = minIndex; i < maxIndex; i++) { // find the x and y coordinates float px = ofToFloat(values[2 * i + 1]); float py = ofToFloat(values[2 * i + 2]); // find the vector to this point ofVec3f thisPoint(px, py, 0.); // remove points too close double sqDist = thisPoint.distanceSquared(ofVec3f(0.,0.,0.)); if (sqDist < minSqDist2Cam) continue; // rotate this point 90 degrees about the z axis to orient it upwards thisPoint.rotate(90., ofVec3f(0., 0., 1.)); // apply the alignment angle stretch or compression to realign the two chuncks float alignmentFactor = (float)i / 682. * alignmentAngle; thisPoint.rotate(alignmentFactor, ofVec3f(0., 0., 1.)); // rotate this point about the y axis an amount proportional to this scanNumber and the number of scans in this frame (since this changes) float rotationAmt = (float)scanNum / (float)frames[frameNum].length * periodSize; // if clockwise is true, rotate in negative direction if (bClockwise) rotationAmt *= -1.; // if period is 180 and frame is odd, rotate 180 degrees if ((int)periodSize == 180 && (frameNum % 2)) rotationAmt += 180.; thisPoint.rotate(rotationAmt, ofVec3f(0., 1., 0.)); // add the point to the mesh with a color renderedFrame.addVertex(thisPoint); renderedFrame.addColor(ofFloatColor(1.)); } scanNum++; if (scanNum >= frames[frameNum].length) break; } cout << "rendered frame # " << frameNum << endl; // increment the frame number frameNum++; if (frameNum >= frames.size()) { // stop running this operation frameNum = -1; } // NOW RENDER ofPushMatrix(); // rotate the original frame ofRotate(startRotateX, 1, 0, 0); ofRotate(startRotateY, 0, 1, 0); ofRotate(startRotateZ, 0, 0, 1); renderedFrame.drawVertices(); ofPopMatrix(); // SAVE IMAGE ofSaveFrame(); } // --------------------------------------------------------------------- //void urgTimelapse::render() { // // ofPushMatrix(); // // // rotate the original frame // ofRotate(startRotateX, 1, 0, 0); // ofRotate(startRotateY, 0, 1, 0); // ofRotate(startRotateZ, 0, 0, 1); // // renderedFrame.drawVertices(); // // ofPopMatrix(); // // ofSaveFrame(); //} // --------------------------------------------------------------------- // fill mesh with a spherical capture // scans are spaced out according to the speed of the rotations (degrees/sec; default = 225/64) and the timestamp of each step // each period is 180 degrees since we're recording both sides of the lidar every scan //void urgDisplay::fillPointMeshTXYSpherical(float speed, float period, bool bClockwise, float startingPeriod, float numPeriods, float alignmentAngle) { // // // clear the mesh // pointMesh.clear(); // // // if either variable is -1, set it to default or max // if (startingPeriod == -1.) startingPeriod = 0; // if (numPeriods == -1.) numPeriods = 99999.; // // // // // set time zero // float timeZero; // // // interval of interest of the scans // int startIndex = -1; // int endIndex = -1; // // // first, find the starting points and ending points for the sphere // for (int i = 0; i < nScans; i++) { // // // find the current time // float timeNow = csv.getFloat(i, 0) / 1000.; // in seconds // // // check if this scan is the start of the interval of interest so long as it has not yet been found // if (startIndex == -1) { // if ((timeNow * speed) >= (startingPeriod * period)) { // startIndex = i; // timeZero = timeNow; // } // } // // // check if it's the end of the interval // if (startIndex != -1) { // if ((timeNow * speed) >= ((startingPeriod + numPeriods) * period)) { // endIndex = i; // break; // } // } // } // // // if endIndex wasn't assigned, assign it to the total number of scans // if (endIndex == -1) endIndex = nScans; // // // ------------------------------------------ // // ---------- FILL THE POINT MESH ----------- // // ------------------------------------------ // // // for every scan within the interval, add it to the mesh // for (int i = startIndex; i < endIndex; i++) { // // // get the current time // float timeNow = csv.getFloat(i, 0) / 1000. - timeZero; // // // put all the points in a scan in the mesh // for (int j = minIndex; j < maxIndex; j++) { // NOTE: I've been doing this wrong (i.e. wrong order of operations... this is why there are so many points at zero, zero)... it's right here now // // // find the x and y coordinates // float px = csv.getFloat(i, 2 * j + 1); // float py = csv.getFloat(i, 2 * j + 2); // // // find the vector to this point // ofVec3f thisPoint(px, py, 0.); // // // // // remove points too close // double sqDist = thisPoint.distanceSquared(ofVec3f(0.,0.,0.)); // // // cout << sqDist << endl; // // if (sqDist < minSqDist2Cam) continue; // // // // if (px < 100. && py < 100.) continue; // // // rotate this point 90 degrees about the z axis to orient it upwards // thisPoint.rotate(90., ofVec3f(0., 0., 1.)); // // // apply the alignment angle stretch or compression to realign the two chuncks // float alignmentFactor = (float)j / 682. * alignmentAngle; // thisPoint.rotate(alignmentFactor, ofVec3f(0., 0., 1.)); // // // rotate the point about the y axis an amount proportional to the elapsed time and the speed // float rotationAmt = timeNow * speed; // // if clockwise is true, rotate in negative direction // if (bClockwise) rotationAmt *= -1.; // thisPoint.rotate(rotationAmt, ofVec3f(0., 1., 0.)); // // // add the point to the mesh with a color // pointMesh.addVertex(thisPoint); // pointMesh.addColor(ofFloatColor(1.)); // } // } //}
[ "bensnellstudio@gmail.com" ]
bensnellstudio@gmail.com
bb3af3e0628bd6708de6f8cf0be9189d4624019d
3552d35a4408055635807b4d3351570be7a5dafa
/System Course/swapknodes/swapknodes/swapknodes.cpp
b40e58eb68eaf736579eaec3940fa34015b569dc
[]
no_license
ramyasree0299/summer2019_GNITS_ramyasree
0d54f65b8a752091df03e8f3faa3208e88036a07
bd408c0caf86bd9116acf6b85d7bb8fd062ae0f5
refs/heads/master
2020-06-01T23:16:56.196222
2019-06-23T13:04:08
2019-06-23T13:04:08
190,962,568
0
0
null
null
null
null
UTF-8
C++
false
false
2,290
cpp
#include "stdafx.h" #include<stdio.h> #include<conio.h> #include<stdlib.h> struct node { int data; struct node *next; }; int n, n1; typedef struct node Node; Node *reverse(Node *head) { Node *temp = head; Node *prev = NULL; Node *next; while (temp != NULL) { next = temp->next; temp->next = prev; prev = temp; temp = next; } head = prev; return head; } Node *foo(Node *head, int k) { Node *t1; Node *thead = NULL; Node *nhead; Node *tlist = head; Node *temp; Node *remain = NULL; int i = 0; if (n%k!=0) n1 = (n1%k)*k; printf("n1 : %d ", n1); temp = head; /*while (i<n1) { temp = temp->next; i++; } remain = temp;*/ while (n1>0) { i = 0; temp = tlist; while (i<k - 1 && temp != NULL) { temp = temp->next; i++; } if (temp != NULL) { nhead = temp->next; temp->next = NULL; tlist = reverse(tlist); if (thead == NULL) thead = tlist; else { t1 = thead; while (t1->next != NULL) t1 = t1->next; t1->next = tlist; } tlist = nhead; } n1 /= k; } i = 0; if (n%k != 0) { temp = thead; while (temp->next != NULL) temp = temp->next; } temp->next = remain; head = thead; return head; } int main() { n = 6; n1 = 6; int k = 3; int i; struct node *head = (struct node*)malloc(sizeof(struct node)); struct node *temp1 = (struct node*)malloc(sizeof(struct node)); struct node *temp2 = (struct node*)malloc(sizeof(struct node)); struct node *temp3 = (struct node*)malloc(sizeof(struct node)); struct node *temp4 = (struct node*)malloc(sizeof(struct node)); struct node *temp5 = (struct node*)malloc(sizeof(struct node)); struct node *temp6 = (struct node*)malloc(sizeof(struct node)); struct node *temp7 = (struct node*)malloc(sizeof(struct node)); temp7->data = 8; temp7->next = NULL; temp6->data = 7; temp6->next = temp7; temp5->data = 6; temp5->next = NULL; temp4->data = 5; temp4->next = temp5; temp3->data = 4; temp3->next = temp4; temp2->data = 3; temp2->next = temp3; temp1->data = 2; temp1->next = temp2; head->data = 1; head->next = temp1; Node *temp; head = foo(head, k); temp = head; printf("%d-->", head); printf("The swapped %d nodes\n", k); while (temp != NULL){ printf("%d\t", temp->data); temp = temp->next; } _getch(); return 0; }
[ "ramyasree0299@gmail.com" ]
ramyasree0299@gmail.com
45f532d4213b6e77002b4b54345993e36943367a
6ca0e27edfb1243e31fbca299cbfbe4f902edb65
/src/KinectBasePanel.h
5a241435c069de4b8a73af0c3e68f2f882483bf9
[ "Apache-2.0" ]
permissive
fusefactory/ofxDepthKinectV2Streaming
5a22a496c241c5b4cef1e7aaa148288009c7b300
9a479f10cc81e90d638ed9e014fe8d3ce2bcffc9
refs/heads/master
2020-05-01T00:28:09.645213
2020-02-18T10:37:10
2020-02-18T10:37:10
177,168,661
2
0
null
null
null
null
UTF-8
C++
false
false
1,044
h
// // KinectBasePanel.hpp // Apologue2047 // // Created by Matteo on 22/03/2019. // #ifndef KinectBasePanel_h #define KinectBasePanel_h #include <stdio.h> #include "ofxGui.h" #include "KinectDevice.h" #include "KinectSettings.h" class KinectBasePanel : public ofxPanel{ public: void addGuiComponents(KinectDevice *kinectDevice); void addGuiComponents(KinectDevice *kinectDevice, KinectSettings kinectSettings); void save(); string &getFilename(){return filename;} protected: KinectDevice *kinectDevice; ofxButton connectReleaseButton; ofxIntSlider minDistanceIntSlider; ofxIntSlider maxDistanceIntSlider; ofxIntSlider leftMarginIntSlider; ofxIntSlider rightMarginIntSlider; ofxIntSlider topMarginIntSlider; ofxIntSlider bottomMarginIntSlider; ofxFloatSlider vertCorrectionFloatSlider; ofxFloatSlider keystoneFloatSlider; ofxButton saveButton; }; #endif /* KinectBasePanel_hpp */
[ "matteo@fusefactory.it" ]
matteo@fusefactory.it
af2130c4063ffe474f0bc033eab3c2ceef646bc1
3b116faba2ffd8ecce218fb8f4540b1cd36b39c1
/Array Manipulation.cpp
211a00efd9f9e45cc70bad4bdd05d14be12af7dd
[ "BSD-2-Clause" ]
permissive
SangeethaPrabhu2021/Algorithms-For-Software-Developers
8b2e6defab179004a8924bc246b7e6e98a6410d3
8ed9f55fb84ca1b7037871ccd0f24ff61e011bdc
refs/heads/main
2023-09-03T05:04:55.500118
2021-10-15T13:50:58
2021-10-15T13:50:58
417,706,411
0
0
BSD-2-Clause
2021-10-16T03:42:38
2021-10-16T03:42:38
null
UTF-8
C++
false
false
2,102
cpp
#include <bits/stdc++.h> using namespace std; string ltrim(const string &); string rtrim(const string &); vector<string> split(const string &); long arrayManipulation(int n, vector<vector<int>> queries) { long a[n]; for(long i=0;i<n;i++) a[i]=0; for(long i=0;i<queries.size();i++){ for(long j=queries[i][0]-1;j<=queries[i][1]-1;j++){ a[j]+=queries[i][2]; } } long max=INT_MIN; for(long i=0;i<n;i++) { if(a[i]>max) max=a[i]; } return max; } int main() { ofstream fout(getenv("OUTPUT_PATH")); string first_multiple_input_temp; getline(cin, first_multiple_input_temp); vector<string> first_multiple_input = split(rtrim(first_multiple_input_temp)); int n = stoi(first_multiple_input[0]); int m = stoi(first_multiple_input[1]); vector<vector<int>> queries(m); for (int i = 0; i < m; i++) { queries[i].resize(3); string queries_row_temp_temp; getline(cin, queries_row_temp_temp); vector<string> queries_row_temp = split(rtrim(queries_row_temp_temp)); for (int j = 0; j < 3; j++) { int queries_row_item = stoi(queries_row_temp[j]); queries[i][j] = queries_row_item; } } long result = arrayManipulation(n, queries); fout << result << "\n"; fout.close(); return 0; } string ltrim(const string &str) { string s(str); s.erase( s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace))) ); return s; } string rtrim(const string &str) { string s(str); s.erase( find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end() ); return s; } vector<string> split(const string &str) { vector<string> tokens; string::size_type start = 0; string::size_type end = 0; while ((end = str.find(" ", start)) != string::npos) { tokens.push_back(str.substr(start, end - start)); start = end + 1; } tokens.push_back(str.substr(start)); return tokens; }
[ "noreply@github.com" ]
SangeethaPrabhu2021.noreply@github.com
0273861ca1686e80408d458ae92cd7016e364dc0
6451521aff7056b83db5864cb0027eb67c125599
/effort/synchronize_keys.h
7e637a129456f0f2a3f5e8890a9494ad591420c6
[]
no_license
tgamblin/libra
0d740484f23542a017b07b7b86f51566c34ad4e5
2acedbe2f8a487a13b01c3d0e7cb2573e1ca6d09
refs/heads/master
2020-12-24T16:31:54.327600
2013-11-03T00:55:50
2013-11-03T01:04:44
763,175
3
2
null
2016-05-23T17:59:36
2010-07-08T03:21:51
C++
UTF-8
C++
false
false
3,171
h
///////////////////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2010, Lawrence Livermore National Security, LLC. // Produced at the Lawrence Livermore National Laboratory // Written by Todd Gamblin, tgamblin@llnl.gov. // LLNL-CODE-417602 // All rights reserved. // // This file is part of Libra. For details, see http://github.com/tgamblin/libra. // Please also read the LICENSE file for further information. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this list of // conditions and the disclaimer below. // * Redistributions in binary form must reproduce the above copyright notice, this list of // conditions and the disclaimer (as noted below) in the documentation and/or other materials // provided with the distribution. // * Neither the name of the LLNS/LLNL nor the names of its contributors may be used to endorse // or promote products derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ///////////////////////////////////////////////////////////////////////////////////////////////// #ifndef SYNCHRONIZE_EFFORT_KEYS_H #define SYNCHRONIZE_EFFORT_KEYS_H #include <mpi.h> #include "effort_data.h" ///\file synchronize_keys.h /// /// Contains declarations for routines involved in global reduction done before /// compression. These routines merge sets of effort keys across processors /// so that all processors end up with the same set in the end. /// /// This is necessary for compression so that all processors end up transforming /// data from the same effort region at the same time. /// namespace effort { /// Receives a set of keys from another processor via PMPI and /// Merges all of them into the supplied effort map. void receive_keys(effort_data& effort_log, int src, MPI_Comm comm); /// Sends a set of effort_keys to another processor via PMPI. void send_keys(effort_data& effort_log, int dest, MPI_Comm comm); /// Reduces effort keys so that all processors have the same keys. void synchronize_effort_keys(effort_data& effort_log, MPI_Comm comm); } // namespace #endif // SYNCHRONIZE_EFFORT_KEYS_H
[ "tgamblin@llnl.gov" ]
tgamblin@llnl.gov
2605b2a54d343f47f8a3eeeb8ff69f468c10a9a0
eeca0485de2fee42f63e902b2412b014ea949126
/fro_duo.ino
941bd61604a13229f052b1f5f1d64f164315e575
[]
no_license
anuejn/ledArdu
fb149cde292e0906e913c2c250e823c2432f45f2
a560d3351c6b1a7f2860b40aeeab4639f9c3e891
refs/heads/master
2021-05-29T09:55:36.159789
2015-04-30T21:14:57
2015-04-30T21:14:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,802
ino
#include <Adafruit_NeoPixel.h> #include <avr/power.h> #include <math.h> #define PIN A0 #define NUMPIXELS 20 #define GOALTIME 20000.0 #define PI 3.1415936 #define MOTORPIN 2 Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); float proces = 0; int starttime = 0; long vcc = 0; void setup() { vcc = readVcc(); pixels.begin(); pinMode(MOTORPIN, OUTPUT); Serial.begin(9600); } void loop() { Serial.println(vcc); if(vcc < 4900) { //this is an evil hack ;) //wehn you reset the arduwino the voltage is lower becouse the leds are glowing and taking current digitalWrite(MOTORPIN, HIGH); starttime = millis(); while(millis() - starttime < 512) { fillWith((millis() - starttime) / 2,0,255- ((millis() - starttime) / 2)); pixels.show(); Serial.println(vcc); } starttime = millis(); while(proces <= 1) { proces = ((millis() - starttime) / GOALTIME); //Serial.println(proces); fillWithTo(0, 255, 0, 255, 0, 0, proces); pixels.show(); Serial.println(vcc); } starttime = millis(); while(millis() - starttime < 1*PI * 1000) { fillWith(0, (cos((millis() - starttime) / 250.0) + 1) * 127.5, 0); pixels.show(); Serial.println(vcc); } digitalWrite(MOTORPIN, LOW); starttime = millis(); while(millis() - starttime < 2550) { fillWith(0, 255 - ((millis() - starttime) / 10), (millis() - starttime) / 10); pixels.show(); Serial.println(vcc); } } else { starttime = millis(); while(millis() - starttime < 2550) { fillWith(0, 0, (millis() - starttime) / 10); pixels.show(); Serial.println(vcc); } } while(true) { fillWith(0, 0, 255); pixels.show(); } }
[ "jaro.habiger@googlemail.com" ]
jaro.habiger@googlemail.com
5ac9603976964a5058f4cb7f26a721232979ebac
dcb345e6ec38d85f82f5557a3054df3f58d6fd40
/iq/temperature_monitor_uc_client.hpp
d13fceaa82d80b814cabaac66ab7d0af68e70504
[ "BSD-3-Clause" ]
permissive
bunnie/iqmotor-c
c4fd76367cb83460adae615b0d16c5bbcb3181fb
18efc6e8d2251456b167712556ad9e2c96917e6a
refs/heads/master
2021-04-06T20:30:22.913439
2020-01-15T23:33:51
2020-01-15T23:33:51
125,386,841
14
2
null
null
null
null
UTF-8
C++
false
false
2,747
hpp
/* Copyright 2019 IQinetics Technologies, Inc support@iq-control.com This file is part of the IQ C++ API. IQ C++ API is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. IQ C++ API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Name: temperature_monitor_uc_client.hpp Last update: 3/7/2019 by Raphael Van Hoffelen Author: Matthew Piccoli Contributors: Raphael Van Hoffelen */ #ifndef TEMPERATURE_MONITOR_UC_CLIENT_HPP_ #define TEMPERATURE_MONITOR_UC_CLIENT_HPP_ #include "client_communication.hpp" const uint8_t kTypeTemperatureMonitorUcClient = 73; class TemperatureMonitorUcClient: public ClientAbstract{ public: TemperatureMonitorUcClient(uint8_t obj_idn): ClientAbstract( kTypeTemperatureMonitorUcClient, obj_idn), uc_temp_( kTypeTemperatureMonitorUcClient, obj_idn, kSubUcTemp), filter_fs_( kTypeTemperatureMonitorUcClient, obj_idn, kSubFilterFs), filter_fc_( kTypeTemperatureMonitorUcClient, obj_idn, kSubFilterFc), otw_( kTypeTemperatureMonitorUcClient, obj_idn, kSubOtw), otlo_( kTypeTemperatureMonitorUcClient, obj_idn, kSubOtlo), derate_( kTypeTemperatureMonitorUcClient, obj_idn, kSubDerate) {}; // Client Entries // Control commands ClientEntry<float> uc_temp_; ClientEntry<uint32_t> filter_fs_; ClientEntry<uint32_t> filter_fc_; ClientEntry<float> otw_; ClientEntry<float> otlo_; ClientEntry<float> derate_; void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { static const uint8_t kEntryLength = kSubDerate+1; ClientEntryAbstract* entry_array[kEntryLength] = { &uc_temp_, // 0 &filter_fs_, // 1 &filter_fc_, // 2 &otw_, // 3 &otlo_, // 4 &derate_ // 5 }; ParseMsg(rx_data, rx_length, entry_array, kEntryLength); } private: static const uint8_t kSubUcTemp = 0; static const uint8_t kSubFilterFs = 1; static const uint8_t kSubFilterFc = 2; static const uint8_t kSubOtw = 3; static const uint8_t kSubOtlo = 4; static const uint8_t kSubDerate = 5; }; #endif /* TEMPERATURE_MONITOR_UC_CLIENT_HPP_ */
[ "bunnie@kosagi.com" ]
bunnie@kosagi.com
8df1ec527a8a0d5b27ab36658b1919417b79f265
8e4015f2e768f8b8edf2b22912c9fcb23db121ee
/jsbridge/jsctx.h
f07571931078b20a4c5d3f9393c0d66f30724050
[]
no_license
JaatSoft/NetOptimist
298f0a4aacecad19ef9da07b27fb9b97b1f253b2
1dd2a421ad1418666605035565e53cc0434c154c
refs/heads/master
2021-09-28T11:34:00.868956
2013-07-20T17:34:02
2013-07-20T17:34:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
360
h
#if !defined(JSBRIDGE_CTX_H) #define JSBRIDGE_CTX_H struct JsData; class DocFormater; class HTMLWindow; class JsCtx { JsData *m_jsdata; public: JsCtx(); ~JsCtx(); void Init(DocFormater *doc); void SetWindow(HTMLWindow *window); void Execute(const char *jscode); void ExecuteStip(const char *jscode); void SourceFile(const char *filename); }; #endif
[ "" ]
b35d2488ca04ea0ef2f1ad8e27003d5383d02fbc
31ac07ecd9225639bee0d08d00f037bd511e9552
/externals/OCCTLib/inc/StepToGeom_MakeVectorWithMagnitude2d.hxx
ad4c7f35f0dd06b5cd48408f2b934a5b520e504b
[]
no_license
litao1009/SimpleRoom
4520e0034e4f90b81b922657b27f201842e68e8e
287de738c10b86ff8f61b15e3b8afdfedbcb2211
refs/heads/master
2021-01-20T19:56:39.507899
2016-07-29T08:01:57
2016-07-29T08:01:57
64,462,604
1
0
null
null
null
null
UTF-8
C++
false
false
1,476
hxx
// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _StepToGeom_MakeVectorWithMagnitude2d_HeaderFile #define _StepToGeom_MakeVectorWithMagnitude2d_HeaderFile #ifndef _Standard_HeaderFile #include <Standard.hxx> #endif #ifndef _Standard_DefineAlloc_HeaderFile #include <Standard_DefineAlloc.hxx> #endif #ifndef _Standard_Macro_HeaderFile #include <Standard_Macro.hxx> #endif #ifndef _Standard_Boolean_HeaderFile #include <Standard_Boolean.hxx> #endif #ifndef _Handle_StepGeom_Vector_HeaderFile #include <Handle_StepGeom_Vector.hxx> #endif #ifndef _Handle_Geom2d_VectorWithMagnitude_HeaderFile #include <Handle_Geom2d_VectorWithMagnitude.hxx> #endif class StepGeom_Vector; class Geom2d_VectorWithMagnitude; //! This class implements the mapping between classes <br> //! Vector from StepGeom which describes a VectorWithMagnitude <br> //! from Prostep and VectorWithMagnitude from Geom2d. <br> class StepToGeom_MakeVectorWithMagnitude2d { public: DEFINE_STANDARD_ALLOC Standard_EXPORT static Standard_Boolean Convert(const Handle(StepGeom_Vector)& SV,Handle(Geom2d_VectorWithMagnitude)& CV) ; protected: private: }; // other Inline functions and methods (like "C++: function call" methods) #endif
[ "litao1009@gmail.com" ]
litao1009@gmail.com
7fa4d6a91110d35f2a5e36b3a302287631e06e5a
85696df622aab676e2b21982ef0940f3b9d49d9d
/sources/crystax/vfs/getdents.cpp
05b4879e7c48d3f2581632e2707808b11bb8cf04
[ "BSD-2-Clause-Views" ]
permissive
Liryna/android-platform-ndk
e6acbdd5b02eae1250fab458c9c83bbcf7225161
c0414a70629341b965f82bd00e27fbad5563f7de
refs/heads/master
2021-01-13T03:46:55.760089
2016-12-23T14:45:41
2016-12-23T14:45:41
77,230,446
1
0
null
2016-12-23T14:28:49
2016-12-23T14:28:49
null
UTF-8
C++
false
false
2,142
cpp
/* * Copyright (c) 2011-2015 CrystaX. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY CrystaX ''AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CrystaX OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of CrystaX. */ #include "fileio/api.hpp" namespace crystax { namespace fileio { CRYSTAX_LOCAL int getdents(unsigned int fd, struct dirent *entry, unsigned int count) { DBG("fd=%u, dirp=%p, count=%u", fd, entry, count); int extfd; driver_t *driver; if (!resolve((int)fd, NULL, &extfd, NULL, &driver)) return -1; return driver->getdents((unsigned int)extfd, entry, count); } } // namespace fileio } // namespace crystax CRYSTAX_GLOBAL int getdents(unsigned int fd, struct dirent *entry, unsigned int count) { return ::crystax::fileio::getdents(fd, entry, count); }
[ "dm@crystax.net" ]
dm@crystax.net
65553866a1d9b03aef3a74bd4909ec8f23e6a2f7
d4c720f93631097ee048940d669e0859e85eabcf
/chrome/browser/ash/web_applications/face_ml_system_web_app_info.cc
b8e9aac25036d59a3b34fc987e72e3bf1c38e6c3
[ "BSD-3-Clause" ]
permissive
otcshare/chromium-src
26a7372773b53b236784c51677c566dc0ad839e4
3b920d87437d9293f654de1f22d3ea341e7a8b55
refs/heads/webnn
2023-03-21T03:20:15.377034
2023-01-25T21:19:44
2023-01-25T21:19:44
209,262,645
18
21
BSD-3-Clause
2023-03-23T06:20:07
2019-09-18T08:52:07
null
UTF-8
C++
false
false
3,251
cc
// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ash/web_applications/face_ml_system_web_app_info.h" #include <memory> #include "ash/constants/ash_features.h" #include "ash/webui/face_ml_app_ui/url_constants.h" #include "ash/webui/grit/ash_face_ml_app_resources.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/browser/ash/web_applications/system_web_app_install_utils.h" #include "chrome/browser/web_applications/user_display_mode.h" #include "chrome/browser/web_applications/web_app_constants.h" #include "chrome/browser/web_applications/web_app_install_info.h" #include "third_party/blink/public/mojom/manifest/display_mode.mojom.h" #include "ui/chromeos/styles/cros_styles.h" #include "ui/display/screen.h" namespace { constexpr gfx::Size DEFAULT_SIZE(800, 600); } // namespace std::unique_ptr<WebAppInstallInfo> CreateWebAppInfoForFaceMLApp() { std::unique_ptr<WebAppInstallInfo> info = std::make_unique<WebAppInstallInfo>(); info->start_url = GURL(ash::kChromeUIFaceMLAppURL); info->scope = GURL(ash::kChromeUIFaceMLAppURL); // TODO(b/239374316): Convert the title to a localized string info->title = u"Face ML"; web_app::CreateIconInfoForSystemWebApp( info->start_url, { {"app_icon_192.png", 192, IDR_ASH_FACE_ML_APP_APP_ICON_192_PNG}, {"app_icon_512.png", 512, IDR_ASH_FACE_ML_APP_APP_ICON_512_PNG}, }, *info); // Support Dark/Light mode. if (ash::features::IsDarkLightModeEnabled()) { info->theme_color = cros_styles::ResolveColor( cros_styles::ColorName::kBgColor, /*is_dark_mode=*/false); info->dark_mode_theme_color = cros_styles::ResolveColor(cros_styles::ColorName::kBgColor, /*is_dark_mode=*/true); info->background_color = info->theme_color; info->dark_mode_background_color = info->dark_mode_theme_color; } else { info->theme_color = 0xffffffff; info->background_color = 0xffffffff; } info->display_mode = blink::mojom::DisplayMode::kStandalone; info->user_display_mode = web_app::UserDisplayMode::kStandalone; return info; } FaceMLSystemAppDelegate::FaceMLSystemAppDelegate(Profile* profile) : ash::SystemWebAppDelegate(ash::SystemWebAppType::FACE_ML, "FaceML", GURL(ash::kChromeUIFaceMLAppURL), profile) {} std::unique_ptr<WebAppInstallInfo> FaceMLSystemAppDelegate::GetWebAppInfo() const { return CreateWebAppInfoForFaceMLApp(); } gfx::Rect FaceMLSystemAppDelegate::GetDefaultBounds(Browser* browser) const { gfx::Rect bounds = display::Screen::GetScreen()->GetDisplayForNewWindows().work_area(); bounds.ClampToCenteredSize(DEFAULT_SIZE); return bounds; } bool FaceMLSystemAppDelegate::IsAppEnabled() const { return base::FeatureList::IsEnabled(ash::features::kFaceMLApp); } bool FaceMLSystemAppDelegate::ShouldCaptureNavigations() const { return true; } bool FaceMLSystemAppDelegate::ShouldShowNewWindowMenuOption() const { return false; }
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
ca57be6f6f8c17353a3ad6995239a5c957d79a47
e4b9850a094570da68a3d4160922b4d91bf50aff
/activity_selection_problem.cpp
9fd3ef90fc798effd7bdd3ff3a6972c66101a63f
[]
no_license
mosiur-csevu/algolab
8beb85123e2ed6c22ea5f0ccaf8c572edcb4f786
d671664c570ffa510f8d000bead97c3c8ab303f5
refs/heads/master
2022-12-19T21:23:20.021730
2020-09-14T07:31:27
2020-09-14T07:31:27
281,621,738
0
0
null
null
null
null
UTF-8
C++
false
false
945
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int start[n], temp; multimap<int,int>finish; map<int,int>::iterator it; for(int i=0;i<n;i++) { cin >> start[i] >> temp; finish.insert(make_pair(temp,i)); } int currentTime=0,activityCount=0, activityList[n]; int i=0; for(it=finish.begin();it!=finish.end();it++) { int currentFinishTime = it->first; int currentActivity = it->second; cout << "item: " << currentActivity << " - " << "fin: " << currentFinishTime << endl; if(start[currentActivity]>currentTime) { currentTime = currentFinishTime; activityCount++; activityList[i++] = currentActivity; } } cout << activityCount << endl; for(int i=0;i<activityCount;i++) cout << activityList[i] << endl; return 0; }
[ "noreply@github.com" ]
mosiur-csevu.noreply@github.com
3411088244be6e1f210a5abd6bc86418ec63795f
bf437a984f4176f99ff1a8c6a7f60a64259b2415
/src/inet/physicallayer/analogmodel/packetlevel/ScalarReception.cc
9492c0e8f17f81a388496b5bc0115292206a1842
[]
no_license
kvetak/ANSA
b8bcd25c9c04a09d5764177e7929f6d2de304e57
fa0f011b248eacf25f97987172d99b39663e44ce
refs/heads/ansainet-3.3.0
2021-04-09T16:36:26.173317
2017-02-16T12:43:17
2017-02-16T12:43:17
3,823,817
10
16
null
2017-02-16T12:43:17
2012-03-25T11:25:51
C++
UTF-8
C++
false
false
1,625
cc
// // Copyright (C) 2013 OpenSim Ltd. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program; if not, see <http://www.gnu.org/licenses/>. // #include "inet/physicallayer/analogmodel/packetlevel/ScalarReception.h" namespace inet { namespace physicallayer { ScalarReception::ScalarReception(const IRadio *radio, const ITransmission *transmission, const simtime_t startTime, const simtime_t endTime, const Coord startPosition, const Coord endPosition, const EulerAngles startOrientation, const EulerAngles endOrientation, Hz carrierFrequency, Hz bandwidth, W power) : FlatReceptionBase(radio, transmission, startTime, endTime, startPosition, endPosition, startOrientation, endOrientation, carrierFrequency, bandwidth), power(power) { } std::ostream& ScalarReception::printToStream(std::ostream& stream, int level) const { stream << "ScalarReception"; if (level >= PRINT_LEVEL_DETAIL) stream << ", power = " << power; return FlatReceptionBase::printToStream(stream, level); } } // namespace physicallayer } // namespace inet
[ "ivesely@fit.vutbr.cz" ]
ivesely@fit.vutbr.cz
01c50f45e49357c8599de3708098b6ddbfd4be84
e06a59d5659a6c4cfd783badf02e662eb3faa633
/matrix.h
8a997b13591879741a17e503ba641aa1fd55d0a9
[]
no_license
lllwwwbbb/MatrixCaculator
543510cd68d64b6b3628dae2972371ae82e65930
61947017510ba58745718bf0d7dd6cd284c65188
refs/heads/master
2020-03-17T17:25:40.269647
2018-05-17T09:07:32
2018-05-17T09:07:32
133,787,859
0
0
null
null
null
null
UTF-8
C++
false
false
542
h
#ifndef MATRIX_H #define MATRIX_H #include <vector> #include <string> using namespace std; //Matrix typedef vector<double> Array; typedef vector<Array> Matrix; //MatrixVariable struct MatrixVar { string varName; Matrix value; bool operator ==(string right) { return this->varName == right; } bool operator ==(MatrixVar& right) { return this->varName == right.varName; } bool operator <(MatrixVar& right) { return this->varName < right.varName; } }; #endif // MATRIX_H
[ "151220068@smail.nju.edu.cn" ]
151220068@smail.nju.edu.cn
e7fa7ef5ade90f4a858558d1d48581938460615b
0b3e67b06db9ef00f2d60815ae7a4709b4359dd7
/gitTest/Source.cpp
d2fa2cafe73a67a46d4266db0e22f381e97ab750
[]
no_license
Nilawyr/gitTest
0284bfb0f8bbdfcd03a07e6a073e49b8ed0c7abd
ed47e49713d44acf284a78653874b6f41bf45fa7
refs/heads/master
2021-01-22T17:33:27.099298
2016-07-11T16:32:39
2016-07-11T16:32:39
63,083,851
0
0
null
null
null
null
UTF-8
C++
false
false
118
cpp
#include<iostream> using namespace std; int main(int argc, char** argv) { cout << "cristian" << end; return 0; }
[ "cristiancarriond@gmail.com" ]
cristiancarriond@gmail.com
511ef3cc508c06c5667bfa50c3b164a18facdc5c
3cf9e141cc8fee9d490224741297d3eca3f5feff
/C++ Benchmark Programs/Benchmark Files 1/classtester/autogen-sources/source-17183.cpp
7c20722a0c8ffa6116a03898a1fa7e7e3bd503fb
[]
no_license
TeamVault/tauCFI
e0ac60b8106fc1bb9874adc515fc01672b775123
e677d8cc7acd0b1dd0ac0212ff8362fcd4178c10
refs/heads/master
2023-05-30T20:57:13.450360
2021-06-14T09:10:24
2021-06-14T09:10:24
154,563,655
0
1
null
null
null
null
UTF-8
C++
false
false
3,677
cpp
struct c0; void __attribute__ ((noinline)) tester0(c0* p); struct c0 { bool active0; c0() : active0(true) {} virtual ~c0() { tester0(this); active0 = false; } virtual void f0(){} }; void __attribute__ ((noinline)) tester0(c0* p) { p->f0(); } struct c1; void __attribute__ ((noinline)) tester1(c1* p); struct c1 : virtual c0 { bool active1; c1() : active1(true) {} virtual ~c1() { tester1(this); c0 *p0_0 = (c0*)(c1*)(this); tester0(p0_0); active1 = false; } virtual void f1(){} }; void __attribute__ ((noinline)) tester1(c1* p) { p->f1(); if (p->active0) p->f0(); } struct c2; void __attribute__ ((noinline)) tester2(c2* p); struct c2 : virtual c0, virtual c1 { bool active2; c2() : active2(true) {} virtual ~c2() { tester2(this); c0 *p0_0 = (c0*)(c2*)(this); tester0(p0_0); c0 *p0_1 = (c0*)(c1*)(c2*)(this); tester0(p0_1); c1 *p1_0 = (c1*)(c2*)(this); tester1(p1_0); active2 = false; } virtual void f2(){} }; void __attribute__ ((noinline)) tester2(c2* p) { p->f2(); if (p->active0) p->f0(); if (p->active1) p->f1(); } struct c3; void __attribute__ ((noinline)) tester3(c3* p); struct c3 : virtual c1, virtual c2, virtual c0 { bool active3; c3() : active3(true) {} virtual ~c3() { tester3(this); c0 *p0_0 = (c0*)(c1*)(c3*)(this); tester0(p0_0); c0 *p0_1 = (c0*)(c2*)(c3*)(this); tester0(p0_1); c0 *p0_2 = (c0*)(c1*)(c2*)(c3*)(this); tester0(p0_2); c0 *p0_3 = (c0*)(c3*)(this); tester0(p0_3); c1 *p1_0 = (c1*)(c3*)(this); tester1(p1_0); c1 *p1_1 = (c1*)(c2*)(c3*)(this); tester1(p1_1); c2 *p2_0 = (c2*)(c3*)(this); tester2(p2_0); active3 = false; } virtual void f3(){} }; void __attribute__ ((noinline)) tester3(c3* p) { p->f3(); if (p->active0) p->f0(); if (p->active1) p->f1(); if (p->active2) p->f2(); } struct c4; void __attribute__ ((noinline)) tester4(c4* p); struct c4 : virtual c1, virtual c2, virtual c0 { bool active4; c4() : active4(true) {} virtual ~c4() { tester4(this); c0 *p0_0 = (c0*)(c1*)(c4*)(this); tester0(p0_0); c0 *p0_1 = (c0*)(c2*)(c4*)(this); tester0(p0_1); c0 *p0_2 = (c0*)(c1*)(c2*)(c4*)(this); tester0(p0_2); c0 *p0_3 = (c0*)(c4*)(this); tester0(p0_3); c1 *p1_0 = (c1*)(c4*)(this); tester1(p1_0); c1 *p1_1 = (c1*)(c2*)(c4*)(this); tester1(p1_1); c2 *p2_0 = (c2*)(c4*)(this); tester2(p2_0); active4 = false; } virtual void f4(){} }; void __attribute__ ((noinline)) tester4(c4* p) { p->f4(); if (p->active0) p->f0(); if (p->active1) p->f1(); if (p->active2) p->f2(); } int __attribute__ ((noinline)) inc(int v) {return ++v;} int main() { c0* ptrs0[25]; ptrs0[0] = (c0*)(new c0()); ptrs0[1] = (c0*)(c1*)(new c1()); ptrs0[2] = (c0*)(c2*)(new c2()); ptrs0[3] = (c0*)(c1*)(c2*)(new c2()); ptrs0[4] = (c0*)(c1*)(c3*)(new c3()); ptrs0[5] = (c0*)(c2*)(c3*)(new c3()); ptrs0[6] = (c0*)(c1*)(c2*)(c3*)(new c3()); ptrs0[7] = (c0*)(c3*)(new c3()); ptrs0[8] = (c0*)(c1*)(c4*)(new c4()); ptrs0[9] = (c0*)(c2*)(c4*)(new c4()); ptrs0[10] = (c0*)(c1*)(c2*)(c4*)(new c4()); ptrs0[11] = (c0*)(c4*)(new c4()); for (int i=0;i<12;i=inc(i)) { tester0(ptrs0[i]); delete ptrs0[i]; } c1* ptrs1[25]; ptrs1[0] = (c1*)(new c1()); ptrs1[1] = (c1*)(c2*)(new c2()); ptrs1[2] = (c1*)(c3*)(new c3()); ptrs1[3] = (c1*)(c2*)(c3*)(new c3()); ptrs1[4] = (c1*)(c4*)(new c4()); ptrs1[5] = (c1*)(c2*)(c4*)(new c4()); for (int i=0;i<6;i=inc(i)) { tester1(ptrs1[i]); delete ptrs1[i]; } c2* ptrs2[25]; ptrs2[0] = (c2*)(new c2()); ptrs2[1] = (c2*)(c3*)(new c3()); ptrs2[2] = (c2*)(c4*)(new c4()); for (int i=0;i<3;i=inc(i)) { tester2(ptrs2[i]); delete ptrs2[i]; } c3* ptrs3[25]; ptrs3[0] = (c3*)(new c3()); for (int i=0;i<1;i=inc(i)) { tester3(ptrs3[i]); delete ptrs3[i]; } c4* ptrs4[25]; ptrs4[0] = (c4*)(new c4()); for (int i=0;i<1;i=inc(i)) { tester4(ptrs4[i]); delete ptrs4[i]; } return 0; }
[ "ga72foq@mytum.de" ]
ga72foq@mytum.de
9f590011574582e179475b9900200e58b7cd8ab4
713c31f3e32b6dd56b6f2a46419f60b102acb87a
/src/bench/bench_bitcoin.cpp
c79428c9d365077cb5b137ae7acb6423432f9a0c
[ "MIT" ]
permissive
bitcoinwallet-project/bitcoinwallet
58e434d8887f8a884cf5ece00751da2c4d000a34
a6daf932f38ca410d03e9d05f9d25afaa490fa2b
refs/heads/master
2022-04-23T04:33:06.310826
2020-04-23T02:44:41
2020-04-23T02:44:41
258,060,170
0
0
null
null
null
null
UTF-8
C++
false
false
4,237
cpp
// Copyright (c) 2015-2018 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <bench/bench.h> #include <crypto/sha256.h> #include <key.h> #include <random.h> #include <util.h> #include <utilstrencodings.h> #include <validation.h> #include <memory> static const int64_t DEFAULT_BENCH_EVALUATIONS = 5; static const char* DEFAULT_BENCH_FILTER = ".*"; static const char* DEFAULT_BENCH_SCALING = "1.0"; static const char* DEFAULT_BENCH_PRINTER = "console"; static const char* DEFAULT_PLOT_PLOTLYURL = "https://cdn.plot.ly/plotly-latest.min.js"; static const int64_t DEFAULT_PLOT_WIDTH = 1024; static const int64_t DEFAULT_PLOT_HEIGHT = 768; static void SetupBenchArgs() { gArgs.AddArg("-?", "Print this help message and exit", false, OptionsCategory::OPTIONS); gArgs.AddArg("-list", "List benchmarks without executing them. Can be combined with -scaling and -filter", false, OptionsCategory::OPTIONS); gArgs.AddArg("-evals=<n>", strprintf("Number of measurement evaluations to perform. (default: %u)", DEFAULT_BENCH_EVALUATIONS), false, OptionsCategory::OPTIONS); gArgs.AddArg("-filter=<regex>", strprintf("Regular expression filter to select benchmark by name (default: %s)", DEFAULT_BENCH_FILTER), false, OptionsCategory::OPTIONS); gArgs.AddArg("-scaling=<n>", strprintf("Scaling factor for benchmark's runtime (default: %u)", DEFAULT_BENCH_SCALING), false, OptionsCategory::OPTIONS); gArgs.AddArg("-printer=(console|plot)", strprintf("Choose printer format. console: print data to console. plot: Print results as HTML graph (default: %s)", DEFAULT_BENCH_PRINTER), false, OptionsCategory::OPTIONS); gArgs.AddArg("-plot-plotlyurl=<uri>", strprintf("URL to use for plotly.js (default: %s)", DEFAULT_PLOT_PLOTLYURL), false, OptionsCategory::OPTIONS); gArgs.AddArg("-plot-width=<x>", strprintf("Plot width in pixel (default: %u)", DEFAULT_PLOT_WIDTH), false, OptionsCategory::OPTIONS); gArgs.AddArg("-plot-height=<x>", strprintf("Plot height in pixel (default: %u)", DEFAULT_PLOT_HEIGHT), false, OptionsCategory::OPTIONS); // Hidden gArgs.AddArg("-h", "", false, OptionsCategory::HIDDEN); gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN); } static fs::path SetDataDir() { fs::path ret = fs::temp_directory_path() / "bench_bitcoinwallet" / fs::unique_path(); fs::create_directories(ret); gArgs.ForceSetArg("-datadir", ret.string()); return ret; } int main(int argc, char** argv) { SetupBenchArgs(); std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str()); return EXIT_FAILURE; } if (HelpRequested(gArgs)) { std::cout << gArgs.GetHelpMessage(); return EXIT_SUCCESS; } // Set the datadir after parsing the bench options const fs::path bench_datadir{SetDataDir()}; SHA256AutoDetect(); RandomInit(); ECC_Start(); SetupEnvironment(); int64_t evaluations = gArgs.GetArg("-evals", DEFAULT_BENCH_EVALUATIONS); std::string regex_filter = gArgs.GetArg("-filter", DEFAULT_BENCH_FILTER); std::string scaling_str = gArgs.GetArg("-scaling", DEFAULT_BENCH_SCALING); bool is_list_only = gArgs.GetBoolArg("-list", false); double scaling_factor; if (!ParseDouble(scaling_str, &scaling_factor)) { fprintf(stderr, "Error parsing scaling factor as double: %s\n", scaling_str.c_str()); return EXIT_FAILURE; } std::unique_ptr<benchmark::Printer> printer(new benchmark::ConsolePrinter()); std::string printer_arg = gArgs.GetArg("-printer", DEFAULT_BENCH_PRINTER); if ("plot" == printer_arg) { printer.reset(new benchmark::PlotlyPrinter( gArgs.GetArg("-plot-plotlyurl", DEFAULT_PLOT_PLOTLYURL), gArgs.GetArg("-plot-width", DEFAULT_PLOT_WIDTH), gArgs.GetArg("-plot-height", DEFAULT_PLOT_HEIGHT))); } benchmark::BenchRunner::RunAll(*printer, evaluations, scaling_factor, regex_filter, is_list_only); fs::remove_all(bench_datadir); ECC_Stop(); return EXIT_SUCCESS; }
[ "leoped.rgs@gmail.com" ]
leoped.rgs@gmail.com
74644224b9c9d2718a6380f8b98f373ceff9b984
f4efea04aca50b20dcdbce803b2fee6a0d3614b2
/BPS/BLE.ino
ac87773340fe24c386398298665547db990ccdf9
[ "MIT" ]
permissive
JohnMacrae/ESP32-BPS-24
ea214a296b07f671d54b2f2ba8eae878be9e04c5
00f7539714845b4bc119299a9b19c3fb8b0fbf43
refs/heads/master
2023-04-07T05:01:42.268759
2021-04-10T05:30:08
2021-04-10T05:30:08
356,477,825
2
0
null
2021-04-10T05:17:29
2021-04-10T05:12:53
null
UTF-8
C++
false
false
2,455
ino
/* BLE Code */ /*class MyServerCallbacks: public BLEServerCallbacks { void onConnect(BLEServer* pServer) { deviceConnected = true; BLEDevice::startAdvertising(); }; void onDisconnect(BLEServer* pServer) { deviceConnected = false; } }; void BLEInit(void) { BLEDevice::init("ESP32"); // Create the BLE Server pServer = BLEDevice::createServer(); pServer->setCallbacks(new MyServerCallbacks()); // Create the BLE Service BLEService *pService = pServer->createService(SERVICE_UUID); // Create a BLE Characteristic pCharacteristic = pService->createCharacteristic( CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_INDICATE ); // https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml // Create a BLE Descriptor pCharacteristic->addDescriptor(new BLE2902()); // Start the service pService->start(); // Start advertising BLEAdvertising *pAdvertising = BLEDevice::getAdvertising(); pAdvertising->addServiceUUID(SERVICE_UUID); pAdvertising->setScanResponse(false); pAdvertising->setMinPreferred(0x0); // set value to 0x00 to not advertise this parameter BLEDevice::startAdvertising(); Serial.println("Waiting a client connection to notify..."); } void BLELoop(void) { if (deviceConnected) { pCharacteristic->setValue((uint8_t*)&value, 4); pCharacteristic->notify(); value++; Serial.println("Connected"); Serial.println("Connected"); Serial.println("Connected"); delay(10); // bluetooth stack will go into congestion, if too many packets are sent, in 6 hours test i was able to go as low as 3ms } // disconnecting if (!deviceConnected && oldDeviceConnected) { delay(500); // give the bluetooth stack the chance to get things ready pServer->startAdvertising(); // restart advertising Serial.println("start advertising"); Serial.println("start advertising"); Serial.println("start advertising"); oldDeviceConnected = deviceConnected; } // connecting if (deviceConnected && !oldDeviceConnected) { // do stuff here on connecting oldDeviceConnected = deviceConnected; } } */
[ "jramacrae@gmail.com" ]
jramacrae@gmail.com
58a0a488fc925af7badb0627c089e67ef2bac3ea
6f46ce977ba07a401a976f4dea4ddcec0b577cb6
/Creative/game/particle_generator.cpp
af7b7aec631a1decd1c6c8887249f3d2593ae8c5
[]
no_license
LOOK2001/Physically-Based-Animation-GLFW
7c1c9eeb1b32f9c7630d97f5db6fab6fa2b63999
a06399b0f4c5809720f0ef69bf6ab6f1689d3a70
refs/heads/master
2020-09-21T20:52:42.301089
2019-12-02T06:38:19
2019-12-02T06:38:19
224,924,854
0
1
null
null
null
null
UTF-8
C++
false
false
3,933
cpp
#include "particle_generator.h" #include "../common.h" #include "../Renderer.h" #include "../pba/core/PbaViewer.h" #include <glad/glad.h> #include <glm/glm.hpp> #include <iostream> ParticleGenerator::ParticleGenerator(unsigned int num, DynamicalState& pq) :PQ(pq), amount(num) { } void ParticleGenerator::OnUpdate(float deltaTime) { size_t size = (amount > PQ->nb()) ? PQ->nb() : amount; // Update all particles for (size_t i = 0; i < size; i++) { Particle& p = this->particles[i]; p.Position = PQ->pos(i); } } void ParticleGenerator::Display() { PbaViewer* _viewer = PbaViewer::Instance(); Renderer renderer; Camera* _camera = _viewer->GetMainCamera(); m_Texture->Bind(); { glm::mat4 projection = glm::perspective(glm::radians(_camera->Zoom), (float)PbaViewer::Instance()->GetScreenWidth() / (float)PbaViewer::Instance()->GetScreenHeight() , 0.1f, 100.0f); m_Shader->SetUniformMat4f("projection", projection); glm::mat4 view = _camera->GetViewMatrix(); m_Shader->SetUniformMat4f("view", view); size_t size = (amount > PQ->nb()) ? PQ->nb() : amount; for (size_t i = 0; i < size; i++) { Particle& p = this->particles[i]; // calculate the model matrix for each object and pass it to shader before drawing glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first model = glm::translate(model, glm::vec3(p.Position.X(), p.Position.Y(), p.Position.Z()) ); float angle = 20.0f * 9; model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.0f, 0.0f)); m_Shader->SetUniformMat4f("model", model); m_Shader->Bind(); renderer.Draw(*m_VAO, *m_IndexBuffer, *m_Shader); } } } void ParticleGenerator::Init() { const float vertices[] = { -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, -0.5f, 0.5f, 0.5f, 1.0f, 0.0f, -0.5f, 0.5f, -0.5f, 1.0f, 1.0f, -0.5f, -0.5f, -0.5f, 0.0f, 1.0f, -0.5f, -0.5f, -0.5f, 0.0f, 1.0f, -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, -0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 0.5f, -0.5f, -0.5f, 0.0f, 1.0f, 0.5f, -0.5f, -0.5f, 0.0f, 1.0f, 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, -0.5f, -0.5f, -0.5f, 0.0f, 1.0f, 0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, -0.5f, -0.5f, -0.5f, 0.0f, 1.0f, -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, -0.5f, 0.5f, -0.5f, 0.0f, 1.0f }; size_t size = sizeof(vertices); unsigned int indices[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 }; m_VAO = std::make_unique<VertexArray>(); m_VertexBuffer = std::make_unique<VertexBuffer>(vertices, size); VertexBufferLayout layout; layout.Push<float>(3); layout.Push<float>(2); m_VAO->AddBuffer(*m_VertexBuffer, layout); m_IndexBuffer = std::make_unique<IndexBuffer>(indices, size / sizeof(float)); m_Shader = std::make_unique<Shader>("res/shaders/Basic3D.shader"); m_Shader->Bind(); m_Texture = std::make_unique<Texture>("res/textures/ChernoLogo.png"); m_Shader->SetUniform1i("texture1", 0); // Create amount default particle instances size_t size_particles = (amount > PQ->nb()) ? PQ->nb() : amount; for (size_t i = 0; i < size_particles; i++) particles.push_back(Particle()); }
[ "shengwang1996@126.com" ]
shengwang1996@126.com
bc4e4689728b72f48b3d3418fc60396eecaf28a8
bb6c669fc1b873caa9f1b89f87a9331e41d9171c
/tracker/frameFactory.cpp
2b31f6b52e2c082bab7bb06034d6f19161bdabf9
[]
no_license
gaurikulkarni/CalvinBall
5826a062c4435121c2656af58ee261040e47a036
370dd001b7f747dae964c382862095c8ccd25fd4
refs/heads/master
2020-12-30T11:40:04.319165
2017-07-13T03:48:44
2017-07-13T03:48:44
91,516,125
0
0
null
null
null
null
UTF-8
C++
false
false
2,818
cpp
#include "frameFactory.h" #include "extractSurface.h" #include "ioManager.h" #include "vector2f.h" FrameFactory::~FrameFactory() { std::map<std::string, SDL_Surface*>::iterator itSurf = surfaces.begin(); while ( itSurf != surfaces.end() ) { SDL_FreeSurface( itSurf->second ); ++itSurf; } std::map<std::string, std::vector<SDL_Surface*> >::iterator surfaces = multiSurfaces.begin(); while ( surfaces != multiSurfaces.end() ) { for (unsigned int i = 0; i < surfaces->second.size(); ++i) { SDL_FreeSurface( surfaces->second[i] ); } ++surfaces; } std::map<std::string, Frame*>::iterator frame = frames.begin(); while ( frame != frames.end() ) { delete frame->second; ++frame; } std::map<std::string, std::vector<Frame*> >::iterator frames = multiFrames.begin(); while ( frames != multiFrames.end() ) { for (unsigned int i = 0; i < frames->second.size(); ++i) { delete frames->second[i]; } ++frames; } } FrameFactory& FrameFactory::getInstance() { static FrameFactory factory; return factory; } Frame* FrameFactory::getFrame(const std::string& name) { std::map<std::string, Frame*>::const_iterator pos = frames.find(name); if ( pos == frames.end() ) { SDL_Surface * const surface = IOManager::getInstance().loadAndSet( gdata.getXmlStr(name+"/file"), gdata.getXmlBool(name+"/transparency")); surfaces[name] = surface; Frame * const frame =new Frame(name, surface); frames[name] = frame; return frame; } else { return pos->second; } } std::vector<Frame*> FrameFactory::getFrames(const std::string& name) { // First search map to see if we've already made it: std::map<std::string, std::vector<Frame*> >::const_iterator pos = multiFrames.find(name); if ( pos != multiFrames.end() ) { return pos->second; } // It wasn't in the map, so we have to make the vector of Frames: SDL_Surface* surface = IOManager:: getInstance().loadAndSet(gdata.getXmlStr(name+"/file"), true); unsigned numberOfFrames = gdata.getXmlInt(name+"/frames"); std::vector<Frame*> frames; std::vector<SDL_Surface*> surfaces; frames.reserve(numberOfFrames); Uint16 srcX = gdata.getXmlInt(name+"/srcX"); Uint16 srcY = gdata.getXmlInt(name+"/srcY"); Uint16 width = gdata.getXmlInt(name+"/width"); Uint16 height = gdata.getXmlInt(name+"/height"); SDL_Surface* surf; for (unsigned i = 0; i < numberOfFrames; ++i) { unsigned frameX = i * width + srcX; surf = ExtractSurface::getInstance(). get(surface, width, height, frameX, srcY); surfaces.push_back( surf ); frames.push_back( new Frame(name, surf) ); } SDL_FreeSurface(surface); multiSurfaces[name] = surfaces; multiFrames[name] = frames; return frames; }
[ "gauri.kulkarni.v@gmail.com" ]
gauri.kulkarni.v@gmail.com
ea8d725f5a66ac7afe3f7ddff11302c4294645a2
1504b15a66e14c960b9b7db7a9ddfcba281bc4e0
/apm_phase5/catkin_ws/src/apm_autonomous/src/local_driver.cpp
6986e8e88bb26b8cf2f84d143059b1bb230de23a
[]
no_license
Kennya-42/Deep-SLAM
62c046501a14a1a01c4d33004865bcbb57a84e8e
b0a1c09ca1b39f99fb5adf0a8f6fd30136ff0049
refs/heads/master
2023-03-15T15:14:54.931547
2018-04-17T15:08:00
2018-04-17T15:08:00
119,864,090
0
0
null
null
null
null
UTF-8
C++
false
false
8,875
cpp
/** * pilot.cpp * Pioneer robot driver - this node takes a set of waypoints * and drives the robot through them * Alex Avery * 2/6/16 */ #include "ros/ros.h" #include "geometry_msgs/Twist.h" #include "geometry_msgs/Point.h" #include "geometry_msgs/Quaternion.h" #include "std_msgs/Float64MultiArray.h" #include "nav_msgs/Odometry.h" #include "nav_msgs/Path.h" #include "geometry_msgs/PoseStamped.h" #include "geometry_msgs/Vector3.h" #include <iostream> #include <fstream> #include <string> #include <math.h> #include <vector> #define TWO_PI 6.283185f #define THREE_PI_OVER_2 4.712388f // Define the desired precision multiplier. For a precision of // .1, multiply by 1/.1 = 10 #define PRECISION_MULT 10 #define ADVANCE_TARGET_RANGE 1.5 using namespace std; // Create current_pos and orient as a globals so they can be set in the callback geometry_msgs::Point current_pos; // See hw3/include/hw3/Point.h geometry_msgs::Quaternion current_orient; bool got_current_position = false; double current_heading = 0; /* * Callback function for receiving odom data */ void odomCallback(const nav_msgs::Odometry::ConstPtr& msg) { // Get positional odom data current_pos.x = msg->pose.pose.position.x; current_pos.y = msg->pose.pose.position.y; // Truncate position values to be accurate to .01 current_pos.x = ((long)(current_pos.x*100)) / 100.0; current_pos.y = ((long)(current_pos.y*100)) / 100.0; //ROS_INFO("Got position: %lf %lf", current_pos.x, current_pos.y); // Get orientation odom data current_orient.z = msg->pose.pose.orientation.z; current_orient.w = msg->pose.pose.orientation.w; current_heading = 2*atan2(current_orient.z, current_orient.w); if (current_heading < 0) { current_heading = TWO_PI + current_heading; } //current_heading = floor(current_heading*100) / 100.0; //ROS_INFO("Got heading: %lf", current_heading); got_current_position = true; } // Array of waypoints std::vector<geometry_msgs::Point> points; // Current target geometry_msgs::Point target; // Index of target int waypoint_index = 1; bool done = false; // Compares two points to see if they are equal. Since the points are doubles, // the point is multiplied to obtain the desired precision then cast to a long bool comparePoints(const geometry_msgs::Point& pt1, const geometry_msgs::Point& pt2){ return ( (((long)(pt1.x*PRECISION_MULT)) == ((long)(pt2.x*PRECISION_MULT))) && (((long)(pt1.y*PRECISION_MULT)) == ((long)(pt2.y*PRECISION_MULT))) ); } // Calculate the distance between two points double dist(const geometry_msgs::Point& pt1, const geometry_msgs::Point& pt2) { double dx = fabs(pt1.x - pt2.x); double dy = fabs(pt1.y - pt2.y); return sqrt( (dx*dx) + (dy*dy) ); } /**********************************************************************************/ int main(int argc, char **argv){ // Get name of file of points from the command line string filename; if (!argv[1]) { ROS_ERROR("Point file not specified. Exiting."); return 1; } // Parse the file and store the waypoints ifstream pointFile(argv[1]); if(!pointFile) { ROS_ERROR("Can't open file. Exiting."); return 1; } string line; vector<geometry_msgs::Point> points; double tmpx, tmpy; while (getline(pointFile,line)) { istringstream is(line); is >> tmpx; is >> tmpy; // Truncate points if the file creater wasn't very nice tmpx = floor(tmpx*10)/10.0; tmpy = floor(tmpy*10)/10.0; geometry_msgs::Point temppoint; temppoint.x = tmpx; temppoint.y = tmpy; points.push_back(temppoint); } pointFile.close(); // Push back the last element (the goal) twice to simplify the // path following control logic later points.push_back(points[points.size()-1]); // Get the first target (this is index 1 b/c index 0 is the start pos.) waypoint_index = 1; target = points[1]; // Initialize the node and get the node handle ros::init(argc, argv, "local_driver_node"); ros::NodeHandle n; // Set up publishers ros::Subscriber odom_sub = n.subscribe("/Odometry", 100, odomCallback); //ros::Subscriber odom_sub = n.subscribe("/r1/odom", 100, odomCallback); // Desired trajectory vector publisher ros::Publisher desired_trajectory_pub = n.advertise<geometry_msgs::Vector3>("desired_trajectory", 10); // Set up subscribers ros::Publisher path_pub = n.advertise<nav_msgs::Path>("/local_path", 10); // Specify frequency to publish (Hz) double pub_rate = 10; ros::Rate loop_rate(pub_rate); // A count of how many messages we have sent. This is used to create a unique string for each int count = 0; // Initialize path message. this is just for visualization nav_msgs::Path path_msg; // Array of stamped poses so that we can display the path in rviz std::vector<geometry_msgs::PoseStamped> pose_path; path_msg.header.frame_id = "odom"; // This is critical for proper display in rviz! for(std::vector<geometry_msgs::Point>::reverse_iterator it=points.rbegin(); it!=points.rend(); ++it) { geometry_msgs::PoseStamped temp_pose; temp_pose.header.frame_id = "odom"; temp_pose.pose.position = *it; pose_path.push_back(temp_pose); } // The desired trajectory message geometry_msgs::Vector3 desired_trajectory_msg; // Some state variables for navigation double deltaX; double deltaY; double target_heading; double heading_error; int turn_dir = 1; // 1 = Left, -1 = Right double turn_velocity = 0; double linear_velocity = 0; // Don't start until we've got our current position and a set of waypoints while ( !got_current_position) { ros::spinOnce(); } while (ros::ok()) { // SpinOnce calls callbacks waiting to be called at this point in time // This will update current_pos ros::spinOnce(); if (done) { goto sleep; } // If we're at the target point, or if we're closer to the next point // than the last, update target if ( (dist(current_pos, points[waypoint_index+1]) < dist(current_pos, points[waypoint_index-1])) || (dist(current_pos, points[waypoint_index]) <= ADVANCE_TARGET_RANGE) ) { // Check and see if we're at the goal (the last point in the vector) if ( comparePoints(current_pos, points[points.size()-1]) ) { ROS_INFO("DONE!"); //ROS_INFO("Position: %lf %lf", current_pos.x, current_pos.y); done = true; //vel_msg.linear.x = 0; //vel_msg.angular.z = 0; //vel_pub.publish(vel_msg); desired_trajectory_msg.x = 0; desired_trajectory_msg.y = 0; desired_trajectory_msg.z = 0; path_pub.publish(path_msg); goto sleep; } //ROS_INFO("TARGET REACHED."); waypoint_index++; target = points[waypoint_index]; // Remove current point from pose path if (!pose_path.empty()) { pose_path.pop_back(); } ROS_INFO("New Target: %lf %lf", target.x, target.y); } // Find angle and distance to target destination deltaX = target.x - current_pos.x; deltaY = target.y - current_pos.y; target_heading = atan2(deltaY, deltaX); // Normalize +/- 2PI to 0-PI if (target_heading < 0) { target_heading = TWO_PI + target_heading; } // Calculate error heading_error = current_heading - target_heading; //ROS_INFO("Target position: %lf %lf", target.x, target.y); //ROS_INFO("Target heading: %lf", target_heading); //ROS_INFO("Angle error: %lf", heading_error); // Determine turning direction based on smallest angle. This is hard because of // wrap around if (current_heading > target_heading) { heading_error = current_heading - target_heading; if (heading_error > M_PI) { turn_dir = 1; // Turn left } else { turn_dir = -1; // Turn right } } else { heading_error = target_heading - current_heading; if (heading_error < M_PI) { turn_dir = 1; // Turn left } else { turn_dir = -1; // Turn right } } // Get the magnitude of heading error if (heading_error > M_PI) { heading_error = TWO_PI - heading_error; } ROS_INFO("Angle error: %lf", turn_dir * heading_error); // Determine desired vector based on heading error // Positive angle is a right turn desired_trajectory_msg.x = 5000 * (cos(turn_dir * heading_error) * M_PI / 180); desired_trajectory_msg.y = 5000 * (sin(turn_dir * heading_error) * M_PI / 180); desired_trajectory_msg.z = 0; desired_trajectory_pub.publish(desired_trajectory_msg); // Publish the path so it can be visualized path_msg.header.stamp = ros::Time::now(); path_msg.poses = pose_path; path_pub.publish(path_msg); sleep: // Sleeps for (1/loop_rate) seconds loop_rate.sleep(); ++count; } // While ros::ok() return 0; }
[ "ksa6262@rit.edu" ]
ksa6262@rit.edu
1f9deac17fdab8d672ee708b8352274db4fc665b
e9ade5ea33cf3382f8ab3ad980e7f6d8cb76faf8
/solved/use_fenwick_tree.cpp
22ff270c2786db56d52db40a095f855e8f83afa4
[]
no_license
Creamy1137689/kyopro
75bc3f92edb7bff2cbf27dc79d384b422a0a4702
dcacbf27defe840ea7998e06a5f3fb78718e7d53
refs/heads/master
2023-05-10T19:28:56.447493
2021-06-03T12:54:11
2021-06-03T12:54:11
266,143,691
0
0
null
null
null
null
UTF-8
C++
false
false
946
cpp
#include <iostream> #include <iomanip> #include <utility> #include <cmath> #include <random> #include <vector> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <string> #include <algorithm> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i<n; ++i) #define REP(i,n) for(int i = 1; i<=n; ++i) #define all(x) begin(x),end(x) #define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;} #define line "----------" typedef long long ll; typedef pair<int,int> P; typedef pair<ll,ll> LP; const int inf = 1001001000; const ll INF = 1LL<<60; const int MOD = (int)1e9 + 7; int main(){ int N, Q, a, com, l, r; cin >> N >> Q; fenwick_tree<ll> fw(N); rep(i,N){ cin >> a; fw.add(i, a); } rep(_,Q){ cin >> com >> l >> r; if(com == 0)fw.add(l, r); else cout << fw.sum(l,r) << endl; } return 0; }
[ "exception031noexist@gmail.com" ]
exception031noexist@gmail.com
db5f8c60061edeba97f8f1737d314aa5320e3204
2fc9e9e46c504827a47dad7b58fb1ecfb23d890f
/Project1COP3530/Project1COP3530.cpp
9a5015753ae2d09b9dc3bce39522067afe8d2be7
[]
no_license
chrisin1/Line-Editor
9c72c4bd58e920f4a688fba56c2e33667b51d1b9
069dc4e23125d8c6dee860816f60c71f4c3d7a18
refs/heads/master
2022-11-30T19:56:08.833507
2020-08-16T14:27:04
2020-08-16T14:27:04
287,962,263
0
0
null
null
null
null
UTF-8
C++
false
false
5,826
cpp
// Project1COP3530.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> #include "LinkedList.h" #include <string> using namespace std; class LineEditor { private: LinkedList<string> document; public: void insertEnd(string text); void insert(int index, string text); void deleteLine(int index); void edit(int index, string text); void print(); void search(string text); string parseText(string& command, string type); }; void LineEditor::insertEnd(string text) { string newText = text; while (newText.length() > 80) { document.AddTail(newText.substr(0, 80)); newText = newText.substr(80, newText.length()); } if (newText.length() <= 80) { document.AddTail(newText); } } void LineEditor::insert(int index, string text) { string newText = text; int startIndex = index - 1; //index is one-indexed if (startIndex <= document.NodeCount()) { while (newText.length() > 80) //cuts up long string into smaller pieces { document.InsertAt(newText.substr(0, 80), startIndex); newText = newText.substr(80, newText.length()); startIndex++; } if (newText.length() <= 80) { document.InsertAt(newText, startIndex); } } } void LineEditor::deleteLine(int index) { document.RemoveAt(index - 1); //index is one-indexed } void LineEditor::edit(int index, string text) { deleteLine(index); //"editing" is the same as deleting it, and adding the new edit in its place insert(index, text); } void LineEditor::print() { document.PrintForward(); } void LineEditor::search(string text) { bool found = false; int searchFactor = (int)((text.length() / 80.0) + 1); // used to determine how to group Nodes to be searched based on input size. 80 or less = search one node at a time. 81-160 = search two at a time. LinkedList<string>::Node* ptr = document.Head(); if (searchFactor > document.NodeCount()) //edge case, search item cannot be found if it is larger than the whole document { cout << "not found" << endl; return; } else if (searchFactor == 1) { for (unsigned int i = 0; i < document.NodeCount(); i++) { if (ptr->data.find(text) != std::string::npos) { cout << (i + 1) << " " << ptr->data << endl; found = true; } ptr = ptr->next; } } else { LinkedList<string>::Node* upperBound = ptr; for (int i = 0; i < searchFactor - 1; i++) //initialize upperBound for grouping purposes { upperBound = upperBound->next; } for (unsigned int i = 0; i < document.NodeCount() && upperBound != nullptr; i++) { string combinedText = ""; //combined text from multiple lines LinkedList<string>::Node* addPtr = ptr; //pointer that is used to traverse ahead and add strings to the big combined string LinkedList<string> currLines; //contains current lines being searched, for printing purposes for (int j = 0; j < searchFactor; j++) //assemble and store current group of searched lines in currLines { combinedText += addPtr->data; currLines.AddTail(addPtr->data); addPtr = addPtr->next; } if (combinedText.find(text) != std::string::npos) { int j = i + 1; for (LinkedList<string>::Node* curr = currLines.Head(); curr != nullptr; curr = curr->next, j++) { cout << j << " " << curr->data << endl; } found = true; } ptr = ptr->next; upperBound = upperBound->next; } } if (!found) { cout << "not found" << endl; } } string LineEditor::parseText(string& command, string type) { string result = ""; if (type.compare("text") == 0) { result = command.substr(command.find("\"") + 1, command.length()); //text starts after index of quotation result = result.substr(0, result.length() - 1); //exculde last quotation mark } else if (type.compare("line number") == 0) { int numStart = command.find(" ") + 1; result = command.substr(numStart, (command.find(" ", numStart)) - numStart); //substring from first digit to last digit } return result; } int main() { LineEditor doc; string command = ""; do { getline(cin, command); if (command.find("insertEnd") != std::string::npos) { string parsedText = doc.parseText(command, "text"); doc.insertEnd(parsedText); } else if (command.find("insert") != std::string::npos) { string parsedInt = doc.parseText(command, "line number"); int index = stoi(parsedInt); string parsedText = doc.parseText(command, "text"); doc.insert(index, parsedText); } else if (command.find("delete") != std::string::npos) { string parsedInt = doc.parseText(command, "line number"); int index = stoi(parsedInt); doc.deleteLine(index); } else if (command.find("edit") != std::string::npos) { string parsedInt = doc.parseText(command, "line number"); int index = stoi(parsedInt); string parsedText = doc.parseText(command, "text"); doc.edit(index, parsedText); } else if (command.find("print") != std::string::npos) { doc.print(); } else if (command.find("search") != std::string::npos) { string parsedText = doc.parseText(command, "text"); doc.search(parsedText); } } while (command.compare("quit") != 0); return 0; } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: // 1. Use the Solution Explorer window to add/manage files // 2. Use the Team Explorer window to connect to source control // 3. Use the Output window to see build output and other messages // 4. Use the Error List window to view errors // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
[ "christopherin12@gmail.com" ]
christopherin12@gmail.com
a54344895506c9ea67cedc81f5b3014b41cc07e6
101321a2edcb45ab1c8c6e4d2583b878589fe96e
/User/UserMenu.h
b4f65205f4cb913a9460b00e0a1db17bf3cc3b4a
[]
no_license
mark2002007/2K1SNP
c3aa8a5cde44c8e2f7efcc872ae7affb71cfc77d
30a75e3fa843eed69f3baad347d494ee6d08c2b2
refs/heads/master
2023-01-22T02:27:57.421457
2020-12-02T09:07:51
2020-12-02T09:07:51
304,910,818
0
0
null
null
null
null
UTF-8
C++
false
false
792
h
#pragma once #include <iostream> #include "Repository.h" #include "BookRepository.h" #include "Author.h" #include "Customer.h" #include "Employee.h" using namespace std; class Menu { private: string pointer; int pPos = 1; string list_ind; string title; Repository<Author> authorRepository = Repository<Author>(true); Repository<Customer> customerRepository = Repository<Customer>(true); Repository<Employee> employeeRepository = Repository<Employee>(true); BookRepository bookRepository = BookRepository(authorRepository, true); public: //ctr Menu(string = "", string = "", string = "<"); void ShowMenu(); void ShowAdd(); void ShowRemove(); void ShowShow(); void ShowSettings(); //Settings Methods void ChangeTitle(); void ChangeIndexation(); void ChangePointer(); };
[ "markmandzak2002@gmail.com" ]
markmandzak2002@gmail.com
997ae853ff481ba40e24fd12ec14a6d0e7a50089
12d9e3ed40f1d5706932a3e44e8a08ca185b52cf
/Sphere Online Judge/PT07Z - Longest path in a tree.cc
9d1d74ff8cd765aafb0582addfe9c5933dd27ea9
[]
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
WINDOWS-1250
C++
false
false
1,036
cc
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> Pii; typedef vector<int> Vi; typedef vector<Pii> VPii; typedef vector<Vi> VVi; typedef vector<VPii> VVPii; #define pb(x) push_back(x) #define MAX 10004 VVi g; bool visit[MAX]; Pii bfs(int x) { queue<Pii> q; q.push(Pii(x,0)); int node=x,y; int dis=0; while(!q.empty()) { x=q.front().first; y=q.front().second; q.pop(); visit[x]=true; if(dis<y) { dis=y; node=x; } for(int i=0;i<g[x].size();i++) if(!visit[g[x][i]]) { visit[g[x][i]]=true; q.push(Pii(g[x][i],y+1)); } } return Pii(node,dis); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n,u,v; cin>>n; g=VVi(n+1); for(int i=0;i<n-1;i++) { cin>>u>>v; g[u].pb(v); g[v].pb(u); } memset(visit,false,sizeof visit); int fur=bfs(1).first; //Primer BFS para encontrar el nodo más lejano a 1 memset(visit,false,sizeof visit); int ans=bfs(fur).second; //Segundo BFS para hallar el diámetro cout<<ans<<"\n"; }
[ "sebastianjmdlc@gmail.com" ]
sebastianjmdlc@gmail.com
80682ac602cda6612e3f24f5427b5003d81d4a15
e557ce74c9fe34aa2b68441254b7def699067501
/src/libtsduck/dtv/descriptors/tsAudioComponentDescriptor.h
f60dca5c61128c292f50a23108cdcbaa15c1e8cc
[ "BSD-2-Clause" ]
permissive
cedinu/tsduck-mod
53d9b4061d0eab9864d40b1d47b34f5908f99d8a
6c97507b63e7882a146eee3613d4184b7e535101
refs/heads/master
2023-05-10T12:56:33.185589
2023-05-02T09:00:57
2023-05-02T09:00:57
236,732,523
0
0
BSD-2-Clause
2021-09-23T08:36:08
2020-01-28T12:41:10
C++
UTF-8
C++
false
false
3,692
h
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2023, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- //! //! @file //! Representation of an ISDB audio_component_descriptor. //! //---------------------------------------------------------------------------- #pragma once #include "tsAbstractDescriptor.h" namespace ts { //! //! Representation of an ISDB audio_component_descriptor. //! @see ARIB STD-B10, Part 2, 6.2.26 //! @ingroup descriptor //! class TSDUCKDLL AudioComponentDescriptor : public AbstractDescriptor { public: // AudioComponentDescriptor public members: uint8_t stream_content; //!< 4 bits, 0x02 by default (audio content). uint8_t component_type; //!< Component type. uint8_t component_tag; //!< Component tag. uint8_t stream_type; //!< Stream type. uint8_t simulcast_group_tag; //!< Group tag. bool main_component; //!< Is main audio component. uint8_t quality_indicator; //!< 2 bits, quality indicator. uint8_t sampling_rate; //!< 3 bits, sampling rate. UString ISO_639_language_code; //!< 3-character language code. UString ISO_639_language_code_2; //!< 3-character optional secondary language code. UString text; //!< Component description. //! //! Default constructor. //! AudioComponentDescriptor(); //! //! Constructor from a binary descriptor //! @param [in,out] duck TSDuck execution context. //! @param [in] bin A binary descriptor to deserialize. //! AudioComponentDescriptor(DuckContext& duck, const Descriptor& bin); // Inherited methods DeclareDisplayDescriptor(); protected: // Inherited methods virtual void clearContent() override; virtual void serializePayload(PSIBuffer&) const override; virtual void deserializePayload(PSIBuffer&) override; virtual void buildXML(DuckContext&, xml::Element*) const override; virtual bool analyzeXML(DuckContext&, const xml::Element*) override; }; }
[ "thierry@lelegard.fr" ]
thierry@lelegard.fr
dbd3c260ea3694f3989ae6088165989d8d91c62f
260e5dec446d12a7dd3f32e331c1fde8157e5cea
/Indi/SDK/Indi_Default_functions.cpp
97ef1a5bb7291880cfbbab717d7f1f07a0e5d5e7
[]
no_license
jfmherokiller/TheOuterWorldsSdkDump
6e140fde4fcd1cade94ce0d7ea69f8a3f769e1c0
18a8c6b1f5d87bb1ad4334be4a9f22c52897f640
refs/heads/main
2023-08-30T09:27:17.723265
2021-09-17T00:24:52
2021-09-17T00:24:52
407,437,218
0
0
null
null
null
null
UTF-8
C++
false
false
342
cpp
// TheOuterWorlds SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "Indi_Default_parameters.hpp" namespace SDK { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "peterpan0413@live.com" ]
peterpan0413@live.com
2bcb3b1abf1f8478fbd9564acc68cc2d30ff82b5
fe5aa6ffd43d5b417a09d9e4788a1ce0fa7c2623
/cmake/Tests/Qt4And5Automoc/main_qt4.cpp
a84ce897fda2a7c6223c2dda366423ed07adc08f
[ "BSD-3-Clause" ]
permissive
soegaard/racket-osx-libs
5356e39d17ff208cb582912307e79e5baa540930
6341cc182c2645ebe9f175f56e7ba0b557eef893
refs/heads/master
2021-01-23T03:58:57.549738
2019-04-28T12:12:14
2019-04-28T12:12:14
14,662,966
5
2
null
2019-04-28T12:12:15
2013-11-24T14:50:34
C
UTF-8
C++
false
false
46
cpp
#include "main.cpp" #include "main_qt4.moc"
[ "jensaxel@soegaard.net" ]
jensaxel@soegaard.net
1c576ed95c289030307072c27d04f68b2820b4c1
5885fd1418db54cc4b699c809cd44e625f7e23fc
/kattis/additiongame.cpp
62eac18c8c9927aa0d05f873ae4a50203a682925
[]
no_license
ehnryx/acm
c5f294a2e287a6d7003c61ee134696b2a11e9f3b
c706120236a3e55ba2aea10fb5c3daa5c1055118
refs/heads/master
2023-08-31T13:19:49.707328
2023-08-29T01:49:32
2023-08-29T01:49:32
131,941,068
2
0
null
null
null
null
UTF-8
C++
false
false
873
cpp
#include <bits/stdc++.h> using namespace std; #define _USE_MATH_DEFINES #include <ext/rope> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_cxx; using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<ld,ld> pdd; typedef complex<ld> pt; const char nl = '\n'; const ll INF = 0x3f3f3f3f; const ll INFLL = 0x3f3f3f3f3f3f3f3f; const ll MOD = 1e9+7; const ld EPS = 1e-13; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); int n; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; } return 0; }
[ "henryxia9999@gmail.com" ]
henryxia9999@gmail.com
2d46ddf330b9495c3468e985e5e9230ee466be9f
35635422101e1c0e4142ca1e176c5d976a6a6ff2
/deps/glm.9.9.5/glm_inn/gtc/noise.hpp
7967168b3caae16fc0216e6c95760d04708d7649
[ "BSD-3-Clause" ]
permissive
wanghaoxin1991/tprPix
e9ac6078dcf104b89e7db8bc6e973b47d4a46bfc
877d2f3bcd2028b28f575deebf37bf7d19d1da52
refs/heads/master
2021-05-25T17:27:13.564129
2020-04-08T22:08:00
2020-04-08T22:08:00
253,843,248
0
0
null
2020-04-07T15:58:08
2020-04-07T15:58:08
null
UTF-8
C++
false
false
3,054
hpp
<<<<<<< HEAD /// @ref gtc_noise /// @file glm/gtc/noise.hpp /// /// @see core (dependence) /// /// @defgroup gtc_noise GLM_GTC_noise /// @ingroup gtc /// /// Include <glm/gtc/noise.hpp> to use the features of this extension. /// /// Defines 2D, 3D and 4D procedural noise functions /// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": /// https://github.com/ashima/webgl-noise /// Following Stefan Gustavson's paper "Simplex noise demystified": /// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf #pragma once // Dependencies #include "../detail/setup.hpp" #include "../detail/qualifier.hpp" #include "../detail/_noise.hpp" #include "../geometric.hpp" #include "../common.hpp" #include "../vector_relational.hpp" #include "../vec2.hpp" #include "../vec3.hpp" #include "../vec4.hpp" #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) # pragma message("GLM: GLM_GTC_noise extension included") #endif namespace glm { /// @addtogroup gtc_noise /// @{ /// Classic perlin noise. /// @see gtc_noise template<length_t L, typename T, qualifier Q> GLM_FUNC_DECL T perlin( vec<L, T, Q> const& p); /// Periodic perlin noise. /// @see gtc_noise template<length_t L, typename T, qualifier Q> GLM_FUNC_DECL T perlin( vec<L, T, Q> const& p, vec<L, T, Q> const& rep); /// Simplex noise. /// @see gtc_noise template<length_t L, typename T, qualifier Q> GLM_FUNC_DECL T simplex( vec<L, T, Q> const& p); /// @} }//namespace glm #include "noise.inl" ======= /// @ref gtc_noise /// @file glm/gtc/noise.hpp /// /// @see core (dependence) /// /// @defgroup gtc_noise GLM_GTC_noise /// @ingroup gtc /// /// Include <glm/gtc/noise.hpp> to use the features of this extension. /// /// Defines 2D, 3D and 4D procedural noise functions /// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": /// https://github.com/ashima/webgl-noise /// Following Stefan Gustavson's paper "Simplex noise demystified": /// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf #pragma once // Dependencies #include "../detail/setup.hpp" #include "../detail/qualifier.hpp" #include "../detail/_noise.hpp" #include "../geometric.hpp" #include "../common.hpp" #include "../vector_relational.hpp" #include "../vec2.hpp" #include "../vec3.hpp" #include "../vec4.hpp" #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) # pragma message("GLM: GLM_GTC_noise extension included") #endif namespace glm { /// @addtogroup gtc_noise /// @{ /// Classic perlin noise. /// @see gtc_noise template<length_t L, typename T, qualifier Q> GLM_FUNC_DECL T perlin( vec<L, T, Q> const& p); /// Periodic perlin noise. /// @see gtc_noise template<length_t L, typename T, qualifier Q> GLM_FUNC_DECL T perlin( vec<L, T, Q> const& p, vec<L, T, Q> const& rep); /// Simplex noise. /// @see gtc_noise template<length_t L, typename T, qualifier Q> GLM_FUNC_DECL T simplex( vec<L, T, Q> const& p); /// @} }//namespace glm #include "noise.inl" >>>>>>> f8aea6f7d63dae77b8d83ba771701e3561278dc4
[ "wanghaoxin8@163.com" ]
wanghaoxin8@163.com