blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
โŒ€
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
โŒ€
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
โŒ€
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
819d9acf3713eb67fe12a22deab73a08126bdefa
65ece8de4e4f0b440454c316e6e4fc8702221894
/chapter2/ex2.5.2.cpp
2454709fcd50b773c57a1063ec0180b3ca4b44bd
[]
no_license
bobchin/self-study-cpp
da765839cb0b2a5cbd1f03c68988b7e6bacb88ef
fd244d915ebe29eca66aeabff3c0e751553e4157
refs/heads/master
2021-01-15T08:32:10.456531
2016-10-11T05:03:52
2016-10-11T05:03:52
68,779,098
0
0
null
null
null
null
UTF-8
C++
false
false
915
cpp
ex2.5.2.cpp
#include <iostream> using namespace std; // ๅ…ฑ็”จไฝ“ใฎใ‚ตใƒณใƒ—ใƒซ // d ใจ c ใŒๅŒใ˜ใ‚‚ใฎใ‚’ๆŒ‡ใ—ใฆใ„ใ‚‹ // ๅ€คใฎ่จญๅฎšใฏ d(double) ใ‚’ไฝฟ็”จใ—ใ€ // ใƒ“ใƒƒใƒˆๅ‚็…งใ™ใ‚‹ใจใใฏ c(char้…ๅˆ—) ใ‚’ไฝฟ็”จใ—ใฆใ„ใ‚‹ union bits { bits(double n); void show_bits(); double d; unsigned char c[sizeof(double)]; }; bits::bits(double b) { d = b; } void bits::show_bits() { int i, j; // double ๅž‹8ใƒใ‚คใƒˆใฎใƒซใƒผใƒ— for (j = sizeof(double) - 1; j >= 0; j--) { cout << "ใƒใ‚คใƒˆๅ˜ไฝใฎใƒ“ใƒƒใƒˆใƒ‘ใ‚ฟใƒผใƒณ " << j << ": "; // ๅ„ใƒใ‚คใƒˆใฎใƒ“ใƒƒใƒˆใ‚’ไธŠไฝใ‹ใ‚‰่กจ็คบ for (i = 128; i; i >>= 1) { if (i & c[j]) { cout << "1"; } else { cout << "0"; } } cout << "\n"; } } int main() { bits ob(1991.829); ob.show_bits(); return 0; }
e9106fec9fc07c2e944a3c86cd52af905b7360da
70e6d082005b9e00cdca5c0f95d363c11e8ff39a
/introduction-into-cpp--stolyarov/3_1-extern-c.cpp
5b5b9d1324c6dddd83ac3178b2084147eda562cb
[]
no_license
maxja/cpp-classes
40ea8906a2e54c0db716b1b024490973487acdf3
75a8f6bbef4c90800948c1d56e1cd2aaaf3c7578
refs/heads/main
2023-02-02T13:45:53.605516
2020-12-22T20:13:46
2020-12-22T20:13:46
319,045,032
0
0
null
null
null
null
UTF-8
C++
false
false
165
cpp
3_1-extern-c.cpp
#ifndef FOO_H_SENTRY #define FOO_H_SENTRY #ifdef __cplusplus extern "C" { #endif #include "foo.h"; double foo(double a, int b); #ifdef __cplusplus } #endif #endif
dd2087b63b4c2c8e41c9f29c3cda31fccb918212
99a25308270b4177a20743f6db5fcc677ed6cd75
/src/Omega_h_kokkos.hpp
f7c4a390bd73a21e6c507f727e8c92244df1e378
[ "BSD-2-Clause", "BSD-2-Clause-Views" ]
permissive
Aeroglyphic/omega_h
a43625ca03f955b1fea0b11f8c0a00bdfa1a2c65
5c2ba4347598265c2e7bc60e6242b7e9c9368d98
refs/heads/master
2020-03-28T16:37:40.191326
2018-09-13T18:54:33
2018-09-13T18:54:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
905
hpp
Omega_h_kokkos.hpp
#ifndef OMEGA_H_KOKKOS_HPP #define OMEGA_H_KOKKOS_HPP #include <Omega_h_config.h> #include <Omega_h_macros.h> #include <Omega_h_defines.hpp> OMEGA_H_SYSTEM_HEADER #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #if (__GNUC__ >= 7) #pragma GCC diagnostic ignored "-Wint-in-bool-context" #pragma GCC diagnostic ignored "-Wduplicated-branches" #endif #endif #include <Kokkos_Core.hpp> #ifdef __GNUC__ #pragma GCC diagnostic pop #endif #if defined(KOKKOS_HAVE_CUDA) && !defined(OMEGA_H_USE_CUDA) #error "Kokkos has CUDA, please reconfigure with Omega_h_USE_CUDA=ON" #endif namespace Omega_h { using ExecSpace = Kokkos::DefaultExecutionSpace; using StaticSched = Kokkos::Schedule<Kokkos::Static>; using Policy = Kokkos::RangePolicy<ExecSpace, StaticSched, Omega_h::LO>; inline Policy policy(LO n) { return Policy(0, n); } } // namespace Omega_h #endif
a24c5d01186797c26e7c6060285fb741ff608120
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5686275109552128_0/C++/whoami/B.cpp
233ec55e7a22e0702a6632f9bf49c191d95c3446
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
740
cpp
B.cpp
#include <stdio.h> int n,pancake[1001],remain[1001]; bool check(int time){ for(int sp=0; sp<time; sp++){ int eat_time = time-sp, cnt=0; for(int i=0;i<n;i++){ cnt += (pancake[i]+eat_time-1)/eat_time-1; } if(cnt<=sp) return true; } return false; } int main(){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); int testt; scanf("%d",&testt); for(int test=1; test<=testt; test++){ scanf("%d", &n); for(int i=0; i<n; i++) scanf("%d",&pancake[i]); int low=0, high=1005, mid, print; while(low<=high){ mid = (low+high)>>1; if(check(mid)){ print=mid; high=mid-1; } else low=mid+1; } printf("Case #%d: %d\n",test,print); } return 0; }
333960a89471597cb2a5283acdfc8af847d27f8f
f127bdc25a4672793e4aedea61470b3dbfe065cb
/Learn/src/MainDeferred.h
db59bf4e7c0cfadd934f2ce410de1869b096a563
[]
no_license
hefanzhou/LearnOpenGL
b9741659eb3c6459ee0d8ec2736ceae0272785af
3dc423676af1c638a2688fb1ce9a7ed177cefaf1
refs/heads/master
2022-11-13T21:07:11.566526
2020-06-21T08:04:44
2020-06-21T08:04:44
269,851,963
0
0
null
null
null
null
UTF-8
C++
false
false
52
h
MainDeferred.h
#pragma once namespace MainDeferred { int main(); }
273a6b76fe556b63941b29799c136d1cb8b89f03
0e693b0f2ef8eb7fa7fdc33aa225a8849a80ad14
/src/dsmanage/MainWindow.cc
7be67773c2ad16b2bf0637e768548369d2ba8058
[]
no_license
ncareol/zebra
b40bed1845bc5741cabf50cad7244d61156895e3
1f9f2e7cf99db82cab840536245e90a9ac95bdff
refs/heads/master
2022-05-07T02:36:45.619871
2022-03-24T21:35:56
2022-03-24T21:35:56
124,604,310
0
0
null
null
null
null
UTF-8
C++
false
false
4,878
cc
MainWindow.cc
// // The main program window. // /* Copyright (C) 1987,88,89,90,91,92 by UCAR * University Corporation for Atmospheric Research * All rights reserved * * No part of this work covered by the copyrights herein may be reproduced * or used in any form or by any means -- graphic, electronic, or mechanical, * including photocopying, recording, taping, or information storage and * retrieval systems -- without permission of the copyright owner. * * This software and any accompanying written materials are provided "as is" * without warranty of any kind. UCAR expressly disclaims all warranties of * any kind, either express or implied, including but not limited to the * implied warranties of merchantibility and fitness for a particular purpose. * UCAR does not indemnify any infringement of copyright, patent, or trademark * through use or modification of this software. UCAR does not provide * maintenance or updates for its software. */ # ifdef hpux # include <sys/sigevent.h> # endif # include <stdio.h> # include <iostream> # include <stdlib.h> # include <DataStore.h> extern "C" { # include <X11/Intrinsic.h> # include <X11/Shell.h> # include <X11/StringDefs.h> # include <X11/Xaw/AsciiText.h> # include <X11/Xaw/Command.h> # include <X11/Xaw/Form.h> # include <X11/Xaw/Label.h> # include <X11/Xaw/Toggle.h> # include <X11/Xaw/Viewport.h> } # include "dsmanage.h" # include "dsmWindows.h" # include "Dialog.h" static char *rcsid = "$Id: MainWindow.cc,v 1.12 2002-12-18 00:24:13 granger Exp $"; // // Externs. // extern void DoTBDelete (Widget, XtPointer, XtPointer); extern void LoadData (Widget, XtPointer, XtPointer); extern void Quit (Widget, XtPointer, XtPointer); void DoIndex (Widget, XtPointer, XtPointer); void ReallyDoIndex (const char *); dsMainWindow::dsMainWindow (const dsDisplay &disp) : dsWindow ("Zeb Disk Manager", disp, 1) // // Make the window. // { Arg args[10]; int n; Widget left, above; // // Add our label to the top. // n = 0; XtSetArg (args[n], XtNlabel, "Zebra Data Store Manager"); n++; above = XtCreateManagedWidget ("title", labelWidgetClass, dw_form, args, n); // // The free space line. // n = 0; XtSetArg (args[n], XtNborderWidth, 0); n++; XtSetArg (args[n], XtNfromVert, above); n++; spaceLabel = XtCreateManagedWidget ("spaceLabel", labelWidgetClass, dw_form, args, n); UpdateSpace(); // // New line // left = NULL; above = spaceLabel; // // Look at platforms and files. // n = 0; XtSetArg (args[n], XtNlabel, "Disk space cleanup"); n++; XtSetArg (args[n], XtNfromVert, above); n++; XtSetArg (args[n], XtNfromHoriz, left); n++; AddConstraints (args, &n); left = XtCreateManagedWidget ("pandfile", commandWidgetClass, dw_form, args, n); XtAddCallback (left, XtNcallback, DoTBDelete, 0); // // Load data. // n = 0; XtSetArg (args[n], XtNlabel, "Load data"); n++; XtSetArg (args[n], XtNfromVert, above); n++; XtSetArg (args[n], XtNfromHoriz, left); n++; AddConstraints (args, &n); left = XtCreateManagedWidget ("load", commandWidgetClass, dw_form, args, n); XtAddCallback (left, XtNcallback, LoadData, 0); // // Do indexing. // if (getenv ("DSMANAGE_GURU")) { n = 0; XtSetArg (args[n], XtNlabel, "Generate file index"); n++; XtSetArg (args[n], XtNfromVert, above); n++; XtSetArg (args[n], XtNfromHoriz, left); n++; AddConstraints (args, &n); left = XtCreateManagedWidget ("index", commandWidgetClass, dw_form, args, n); XtAddCallback (left, XtNcallback, DoIndex, 0); } // // A quit button. // n = 0; XtSetArg (args[n], XtNlabel, "Quit"); n++; XtSetArg (args[n], XtNfromVert, above); n++; XtSetArg (args[n], XtNfromHoriz, left); n++; AddConstraints (args, &n); left = XtCreateManagedWidget ("quit", commandWidgetClass, dw_form, args, n); XtAddCallback (left, XtNcallback, Quit, 0); // // Put it up. // XtRealizeWidget (dw_shell); } dsMainWindow::~dsMainWindow () { /* yawn */ } void dsMainWindow::UpdateSpace () // // Tweak the "space available" line. // { char label[200]; float space; SourceInfo dsi; Arg args[1]; extern unsigned int FreeSpace (const char *dirname); ds_GetSourceInfo (SrcId, &dsi); space = FreeSpace (dsi.src_Name) / (float)(1024 * 1024); sprintf (label, "Source '%s': %.2f MB free in %s.", dsi.src_Name, space, dsi.src_Dir); XtSetArg (args[0], XtNlabel, label); XtSetValues (spaceLabel, args, 1); } //----------------------------------------------------------- // // Generate an index. // void DoIndex (Widget w, XtPointer junk1, XtPointer junk2) // // Create an index. // { dsDialog *dialog = new dsDialog ("Index generation", "Enter index file name:", ReallyDoIndex, NULL); dialog->popup (); } void ReallyDoIndex (const char *file) // // Create the index in the given file. // { std::cout << "Make index in " << file << ".\n"; MakeLocalIndex (file); }
1f6f7f2bf3210e7d46df8072f726ef717f062ffd
0f2635f18d7b47323332ab733f34c9308888e851
/BZOJ/[PA2014]Bohater.cpp
2910451a67ff1c593373ab572136a28b89f9a2cc
[]
no_license
stevebraveman/Code
2e48b3638272126653c5a2baabac3438db781157
4205dd6c4c2f87a8d8554a21efac39616672004e
refs/heads/master
2020-06-30T21:55:41.313296
2019-11-13T22:57:51
2019-11-13T22:57:51
178,631,305
1
0
null
null
null
null
UTF-8
C++
false
false
633
cpp
[PA2014]Bohater.cpp
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define MAXN 100010 struct Monster { int d, a, id; }m[MAXN]; bool cmp(Monster a, Monster b) { return a.a > b.a || (a.a == b.a && b.d < a.d); } int n, z, cnt, ss[MAXN]; int main() { scanf("%d%d", &n, &z); for (int i = 1; i <= n; i++) { scanf("%d%d", &m[i].d, &m[i].a); m[i].id = i; } std::sort(m + 1, m + 1 + n, cmp); for (int i = 1; i <= n; i++) { z -= m[i].d; if (m[i].d < 0) break; z += m[i].a; ss[++cnt] = m[i].id; } if (cnt == n) { printf("TAK\n"); for (int i = 1; i <= cnt; i++) { printf("%d ", ss[i]); } } return 0; }
03cb1db5de7fa2fbb88da7d97e4b6cad386a4610
e0a0d45181c1d0b0f0aa3d4dd977fc7bec4d21bb
/numerics/line_search.cc
18c76e210ab562845cc4d4e2b29159968be1711c
[ "MIT" ]
permissive
jpanikulam/experiments
71004ff701f4552c932eb6958a0bcd3de76ee383
be36319a89f8baee54d7fa7618b885edb7025478
refs/heads/master
2021-01-12T01:35:15.817397
2020-01-24T00:59:12
2020-01-24T00:59:17
78,386,199
1
1
MIT
2018-12-29T00:54:28
2017-01-09T02:24:16
C++
UTF-8
C++
false
false
1,002
cc
line_search.cc
#include "numerics/line_search.hh" namespace numerics { LinesearchResult line_search(const OptimizationState& current_state, const Eigen::VectorXd& direction, const OptimizationProblem& problem) { Eigen::VectorXd best_x = current_state.x; double best_cost_so_far = problem.objective(best_x, nullptr, nullptr); bool did_decrease = false; // for (const double alpha : {0.001, 0.2, 0.5, 1.0, 5.0, 9.0, 25.0}) { for (const double alpha : {0.001, 0.2, 0.5, 1.0}) { const Eigen::VectorXd evaluation_pt = current_state.x - (alpha * direction); const double cost_at_alpha = problem.objective(evaluation_pt, nullptr, nullptr); if (cost_at_alpha < best_cost_so_far) { best_cost_so_far = cost_at_alpha; best_x = evaluation_pt; did_decrease = true; } } const LinesearchResult result( {.valid = did_decrease, .cost = best_cost_so_far, .best_x = best_x}); return result; } } // namespace numerics
c7309b7a39e96f2deebc2402eb38830278860d1c
13a40fd9b30a3c21d5c9faba051a4b28a43a89e8
/helloLawrence.ino
3fa7f7c4f7c7fc6cd6a498ed2f6c876b189bdfef
[]
no_license
markgrebe/haskino-examples
700c68542be3792a5659241758e27241efe82824
64e6d6f81274de63c992528f981413892e6faca7
refs/heads/master
2021-01-20T06:36:05.451267
2017-08-27T16:09:52
2017-08-27T16:09:52
101,509,885
1
1
null
null
null
null
UTF-8
C++
false
false
11,026
ino
helloLawrence.ino
#include "HaskinoRuntime.h" void haskinoMain(); #define HASKINOMAIN_STACK_SIZE 200 byte haskinoMainTcb[sizeof(TCB) + HASKINOMAIN_STACK_SIZE]; void setup() { haskinoMemInit(); createTask(255, haskinoMainTcb, HASKINOMAIN_STACK_SIZE, haskinoMain); scheduleTask(255, 0); startScheduler(); } void loop() { } uint8_t ref0; uint8_t ref1; uint8_t ref2; bool ref3; void haskinoMain() { uint8_t bind1; uint8_t bind3; uint8_t bind4; uint8_t bind6; uint8_t bind7; uint8_t bind9; uint8_t bind10; uint8_t bind12; uint8_t bind13; uint8_t bind15; ref0 = 0; ref1 = 0; ref2 = 0; ref3 = 1; if (1) { pinMode(10,1); } else { } pinMode(8,1); pinMode(9,1); pinMode(4,1); pinMode(5,1); pinMode(6,1); pinMode(7,1); delayMilliseconds(50); digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,(51 >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(51 & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); delayMilliseconds(5); digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,(50 >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(50 & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,(((32 | (1 < 2) ? 8 : 0) | 0 ? 4 : 0) >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(((32 | (1 < 2) ? 8 : 0) | 0 ? 4 : 0) & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); bind1 = ref1; if (0) { ref1 = setBW8(bind1,1); } else { ref1 = clrBW8(bind1,1); } bind3 = ref1; digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,((8 | bind3) >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,((8 | bind3) & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); bind4 = ref1; if (0) { ref1 = setBW8(bind4,0); } else { ref1 = clrBW8(bind4,0); } bind6 = ref1; digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,((8 | bind6) >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,((8 | bind6) & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); bind7 = ref0; if (1) { ref0 = setBW8(bind7,1); } else { ref0 = clrBW8(bind7,1); } bind9 = ref0; digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,((8 | bind9) >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,((8 | bind9) & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); bind10 = ref0; if (0) { ref0 = setBW8(bind10,0); } else { ref0 = clrBW8(bind10,0); } bind12 = ref0; digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,((8 | bind12) >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,((8 | bind12) & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,(2 >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(2 & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); delayMicroseconds(200); digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,(1 >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(1 & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); delayMicroseconds(200); bind13 = ref1; if (1) { ref1 = setBW8(bind13,2); } else { ref1 = clrBW8(bind13,2); } bind15 = ref1; digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,((8 | bind15) >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,((8 | bind15) & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); if (1) { digitalWrite(10,1); } else { } while (1) { uint8_t * bind19; uint8_t * bind21; uint8_t * bind23; digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,(2 >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(2 & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); delayMicroseconds(200); listAssign(&bind19, (uint8_t * ) (const byte[]) {255, 7,82,111,99,107,32,32,32}); while (1) { if ((list8Len(bind19) == 0)) { break; } else { digitalWrite(8,1); digitalWrite(9,0); digitalPortWrite(4,(list8Elem(bind19,0) >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(list8Elem(bind19,0) & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); listAssign(&bind19, list8Slice(bind19,1,0)); } } delayMilliseconds(1500); digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,(2 >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(2 & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); delayMicroseconds(200); listAssign(&bind21, (uint8_t * ) (const byte[]) {255, 7,67,104,97,108,107,32,32}); while (1) { if ((list8Len(bind21) == 0)) { break; } else { digitalWrite(8,1); digitalWrite(9,0); digitalPortWrite(4,(list8Elem(bind21,0) >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(list8Elem(bind21,0) & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); listAssign(&bind21, list8Slice(bind21,1,0)); } } delayMilliseconds(1500); digitalWrite(8,0); digitalWrite(9,0); digitalPortWrite(4,(2 >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(2 & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); delayMicroseconds(200); listAssign(&bind23, (uint8_t * ) (const byte[]) {255, 7,74,97,121,104,97,119,107}); while (1) { if ((list8Len(bind23) == 0)) { break; } else { digitalWrite(8,1); digitalWrite(9,0); digitalPortWrite(4,(list8Elem(bind23,0) >> 4),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); digitalPortWrite(4,(list8Elem(bind23,0) & 15),15); digitalWrite(9,0); delayMicroseconds(1); digitalWrite(9,1); delayMicroseconds(1); digitalWrite(9,0); delayMicroseconds(2000); listAssign(&bind23, list8Slice(bind23,1,0)); } } delayMilliseconds(1500); } taskComplete(); }
e3713ea5acda9a7eb442aa3211cd8a9673ea2d06
08ccee0a917cd1eccf7e34ee721ec89cb8983613
/main_thermometer.cpp
187ebd14fc38b5049324854586dcf4b147917270
[]
no_license
Carlo6464/API_Thermometer_Projekt
ad93836ec2663a5f61bd9a5b8b5883d57b6bad5a
8768ce2d589ac8eec5bee17731fd7116297c8809
refs/heads/master
2021-01-19T21:19:49.275537
2017-04-18T15:37:39
2017-04-18T15:37:39
88,640,543
0
0
null
null
null
null
UTF-8
C++
false
false
443
cpp
main_thermometer.cpp
//------------------------------------------------------------------------------------------------- // TU Braunschweig API Programmierprojekt SS 2017 // Gruppenmitglieder: Carl Wagner-Douglas, Sina Gabor, Niklas Gรผnther, Fabian ___, Fatih Mustafa // Filename: main_thermometer.cpp // created: 18-04-2017 // last edited: 18-04-2017 // ------------------------------------------------------------------------------------------------
6c1ef5c6548687fca140cf136f1586d25ece45d8
d874c7ddddeed0854f0795249c2203465f3a9029
/cc/sort/Joseph.cc
dc076dca809ddc0fb3c8d9a620797f84ce9de9a9
[]
no_license
colinblack/algorithm
69c09b8a435c8b0d3f7ebb38a620b2a7964cc52a
c6b8402253c2a529606da4a17ba3fad7aa3b6c9e
refs/heads/master
2020-07-24T19:42:58.773382
2019-09-12T10:48:26
2019-09-12T10:48:26
null
0
0
null
null
null
null
GB18030
C++
false
false
598
cc
Joseph.cc
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> int main(void) { int people[11] = {0}, num; int i = 0, num_s = 0; printf("ๆŠฅๆ•ฐๆ•ฐๅญ— \n"); scanf("%d", &num); int out = 0; //็”จไบŽไฟๅญ˜ๅ‰ฉไธ‹็š„ไบบๆ•ฐ๏ผ› while (1) { if (people[num_s] == 0) { if (i == 3) { printf("%d \n", num_s); people[num_s] = 1; out++; i = 0; } if (num_s >= 10) num_s = 1; else num_s++; i++; } if (people[num_s] == 1) { if (num_s >= 10) num_s = 1; else num_s++; } if (out == 10) break; } system("pause"); return 0; }
fc748e332a32df44c037e0d85cd918108e125b13
d3e9d146401afb5cb1f4aa2ae63e66744888dccb
/src/config/include/kalman_param.h
4d2084be288491e5ccd63c17053afe1083e1f8d5
[ "MIT" ]
permissive
apennisi/mctracker
598f3c562b82d307accc7c5cb6b30181dd513a8e
29a89046f796f84eac922b2dc9cf4cd6c7aebb6b
refs/heads/master
2020-06-29T01:53:16.648862
2020-05-16T09:39:04
2020-05-16T09:39:04
200,403,012
18
3
null
null
null
null
UTF-8
C++
false
false
5,588
h
kalman_param.h
/* * Written by Andrea Pennisi */ #ifndef _KALMAN_PARAM_H_ #define _KALMAN_PARAM_H_ #include <iostream> #include <fstream> #include <algorithm> #include <boost/algorithm/string.hpp> namespace mctracker { namespace config { class KalmanParam { public: /** * @brief Constructor class KalmanParam */ KalmanParam() { ; } /** * @brief set the number of times after which a track is accepted * @param propagate unsigned integer containing the value of the propagation */ void setMinPropagate(uint propagate) { min_propagate = propagate; } /** * @brief get the number of times after which a track is accepted * @return the number of times after which a track is accepted */ inline const uint getMinpropagate() const { return min_propagate; } /** * @brief set the dt value for the transition matrix * @param dt float containing the value of the sample frequency */ void setDt(const float& dt) { d_t = dt; } /** * @brief get the dt value of the transition matrix * @return the dt value */ inline const float getDt() const { return d_t; } /** * @brief get the association dummy cost value for the lienar assignment cost * @return the value of the association cost */ inline const uint getAssocdummycost() const { return assoc_dummy_cost; } /** * @brief set the association dummy cost for the lienar assignment cost * @param ass unsigned integer containing the association value */ void setAssociationDummyCost(uint ass) { assoc_dummy_cost = ass; } /** * @brief set the dummy cost for new hypothesis in the linear assignment cost * @param nydc value containing the cost */ void setNewHypDummyCost(uint nydc) { new_hyp_dummy_cost = nydc; } /** * @brief get the dymmy cost for the new hypothesis in the linear assignment cost * @return the value for the new hypothesis cost */ inline const uint getNewhypdummycost() const { return new_hyp_dummy_cost; } /** * @brief set the maximum number of times after which a track is deleted * @param missed the value containing the maximum number of times after which a track is deleted */ void setMaxMissed(uint missed) { max_missed = missed; } /** * @brief get the maximum number of times after which a track is deleted * @return the value containing the maximum number of times after which a track is deleted */ inline const uint getMaxmissed() const { return max_missed; } /** * @brief copy operator * @param _param object to copy * @return the pointer to the current instance */ KalmanParam& operator=(const KalmanParam& _param) { this->min_propagate = _param.getMinpropagate(); this->d_t = _param.getDt(); this->assoc_dummy_cost = _param.getAssocdummycost(); this->new_hyp_dummy_cost = _param.getNewhypdummycost(); this->max_missed = _param.getMaxmissed(); return *this; } /** * @brief print all the parameters */ void print() { std::cout << "[MINPROPAGATE]: " << min_propagate << std::endl; std::cout << "[MAXMISSED]: " << max_missed << std::endl; std::cout << "[ASSOCDUMMYCOST]: " << assoc_dummy_cost << std::endl; std::cout << "[NEW_HYP_DUMMY_COST]: " << new_hyp_dummy_cost << std::endl; std::cout << "[DT]: " << d_t << std::endl; } private: uint max_missed; uint min_propagate; float d_t; uint assoc_dummy_cost; uint new_hyp_dummy_cost; }; } } #endif
4e589488a0a2603448f6d0b5260c0a680931862f
742352c998e046c8261828fa836966c26d42dda9
/tools/assembler/assembler.cpp
38d5484194b4cb5c600d9f87b9713291990d0ee7
[]
no_license
SimonFang1/Pipeline-RISC-CPU
9aed048529e2aa87616d6a035e6277e2031688f1
c97c34c78636a16e5da40122dd0ff4a0813842d8
refs/heads/master
2021-01-19T12:14:49.980743
2017-05-09T15:27:36
2017-05-09T15:27:36
88,023,435
1
1
null
null
null
null
UTF-8
C++
false
false
4,229
cpp
assembler.cpp
#include <iostream> #include <string> #include <sstream> using namespace std; #define INIT_ALL_MEM #ifdef INIT_ALL_MEM #define TOTAL_DEPTH 256 #endif #include "opcode.h" #define DOLLAR ch #define COMMA ch #define R1 r1 #define R2 r2 #define R3 r3 #define VAL2 val2 #define VAL3 val3 #define IMDT immediate #include "expression.h" string getBin(int n, int bits) { string bin; for (int i = bits - 1; i >= 0; i--) { bin += (n & (1 << i)) ? '1': '0'; } return bin; } int main() { string asmbl, op, machineCode; stringstream ss; char ch; int r1, r2, r3; int val2, val3, immediate; int line = 0; while (getline(cin, asmbl)) { ss << asmbl; ss >> op; if (op == "nop") { machineCode = NOP + getBin(0, 11); } else if (op == "halt") { machineCode = HALT + getBin(0, 11); } else if (op == "load") { ss >> R1_R2_V3; machineCode = LOAD + getBin(r1, 3) + getBin(r2, 4) + getBin(val3, 4); } else if (op == "store") { ss >> R1_R2_V3; machineCode = STORE + getBin(r1, 3) + getBin(r2, 4) + getBin(val3, 4); } else if (op == "ldih") { ss >> R1_IM; machineCode = LDIH + getBin(r1, 3) + getBin(immediate, 8); } else if (op == "mov" || op == "ldi") { ss >> R1_IM; machineCode = MOV + getBin(r1, 3) + getBin(immediate, 8); } else if (op == "add") { ss >> R1_R2_R3; machineCode = ADD + getBin(r1, 3) + getBin(r2, 4) + getBin(r3, 4); } else if (op == "addi") { ss >> R1_IM; machineCode = ADDI + getBin(r1, 3) + getBin(immediate, 8); } else if (op == "addc") { ss >> R1_R2_R3; machineCode = ADDC + getBin(r1, 3) + getBin(r2, 4) + getBin(r3, 4); } else if (op == "sub") { ss >> R1_R2_R3; machineCode = SUB + getBin(r1, 3) + getBin(r2, 4) + getBin(r3, 4); } else if (op == "subi") { ss >> R1_IM; machineCode = SUBI + getBin(r1, 3) + getBin(immediate, 8); } else if (op == "subc") { ss >> R1_R2_R3; machineCode = SUBC + getBin(r1, 3) + getBin(r2, 4) + getBin(r3, 4); } else if (op == "cmp") { ss >> R2_R3; machineCode = CMP + getBin(0, 3) + getBin(r2, 4) + getBin(r3, 4); } else if (op == "and") { ss >> R1_R2_R3; machineCode = AND + getBin(r1, 3) + getBin(r2, 4) + getBin(r3, 4); } else if (op == "or") { ss >> R1_R2_R3; machineCode = OR + getBin(r1, 3) + getBin(r2, 4) + getBin(r3, 4); } else if (op == "xor") { ss >> R1_R2_R3; machineCode = XOR + getBin(r1, 3) + getBin(r2, 4) + getBin(r3, 4); } else if (op == "not") { ss >> R1_R2; machineCode = NOT + getBin(r1, 3) + getBin(r2, 4) + getBin(0, 4); } else if (op == "sll") { ss >> R1_R2_V3; machineCode = SLL + getBin(r1, 3) + getBin(r2, 4) + getBin(val3, 4); } else if (op == "sla") { ss >> R1_R2_V3; machineCode = SLA + getBin(r1, 3) + getBin(r2, 4) + getBin(val3, 4); } else if (op == "srl") { ss >> R1_R2_V3; machineCode = SRL + getBin(r1, 3) + getBin(r2, 4) + getBin(val3, 4); } else if (op == "sra") { ss >> R1_R2_V3; machineCode = SRA + getBin(r1, 3) + getBin(r2, 4) + getBin(val3, 4); } else if (op == "jump" || op == "j") { ss >> immediate; machineCode = JUMP + getBin(0, 3) + getBin(immediate, 8); } else if (op == "jmpr" || op == "jr") { ss >> R1_IM; machineCode = JMPR + getBin(r1, 3) + getBin(immediate, 8); } else if (op == "bz") { ss >> R1_IM; machineCode = BZ + getBin(r1, 3) + getBin(immediate, 8); } else if (op == "bnz") { ss >> R1_IM; machineCode = BNZ + getBin(r1, 3) + getBin(immediate, 8); } else if (op == "bn") { ss >> R1_IM; machineCode = BN + getBin(r1, 3) + getBin(immediate, 8); } else if (op == "bnn") { ss >> R1_IM; machineCode = BNN + getBin(r1, 3) + getBin(immediate, 8); } else if (op == "bc") { ss >> R1_IM; machineCode = BC + getBin(r1, 3) + getBin(immediate, 8); } else if (op == "bnc") { ss >> R1_IM; machineCode = BNC + getBin(r1, 3) + getBin(immediate, 8); } else { cerr << line + 1 << ": unknown instruction \"" << asmbl << "\""<< endl; machineCode = NOP + getBin(0, 11); } cout << machineCode << endl; line++; ss.clear(); ss.str(""); } #ifdef INIT_ALL_MEM int rest = TOTAL_DEPTH - line; string fxxk = getBin(0, 16) + '\n'; while (rest--) { cout << fxxk; } cout << flush; #endif return 0; }
4e2411037fd78e0b20a92bca4cf773b513d0bfbc
4dd5d885768d911484954e084592efe369724637
/Source/Core/DeviceChild.hpp
84f284a898a5aca0f21b3b84cdd8a679bc22034e
[ "MIT" ]
permissive
glowing-chemist/Bell
d160f71b905da0629fb67378352ad1a0fd014057
610078a36c831f11c923f34f3e72be0009fcf6a6
refs/heads/master
2022-01-16T22:59:59.179596
2021-12-23T11:28:16
2021-12-23T11:28:16
160,046,575
18
4
null
null
null
null
UTF-8
C++
false
false
373
hpp
DeviceChild.hpp
#ifndef DEVICECHILD_HPP #define DEVICECHILD_HPP #include <memory> #include <optional> #include <vector> class RenderDevice; class DeviceChild { public: DeviceChild(RenderDevice* dev) : mDevice{dev} {} RenderDevice* getDevice() { return mDevice; } const RenderDevice* getDevice() const { return mDevice; } private: RenderDevice* mDevice; }; #endif
fa1ee6868268f8f555698a79662e7f8fe1d94810
f230813dc330f60058acdcc44f7ee5bdaf7c9229
/C++/Dynamic Programmng/Countsubsequences of type a^i b^j c^k .cpp
05fe138262717731a8ac1903ac0b83f8a0a798d8
[]
no_license
lakshyabatman/algorithms-stew
986279a6b38a33818b5da13b643225d55d131d49
5073bb8cbf9c90ca0cf438c8fbcc9d2d087d6553
refs/heads/master
2022-11-26T21:32:23.376126
2020-11-28T17:00:08
2020-11-28T17:00:08
184,299,032
17
22
null
2022-11-10T06:48:28
2019-04-30T16:50:50
C++
UTF-8
C++
false
false
521
cpp
Countsubsequences of type a^i b^j c^k .cpp
/** * * https://practice.geeksforgeeks.org/problems/count-subsequences-of-type-ai-bj-ck/0 * * * */ #include <iostream> using namespace std; int main() { //code int test; cin >> test; while(test--) { string s; cin >> s; int c =0; int bc =0; int a = 0; for(char ch : s) { if(ch == 'a') { a = 1+ 2*a; }else if(ch == 'b') { bc = a+ 2*bc; }else { c = bc+2*c; } } cout << c<<endl; } return 0; }
a96794dfced0c938afa1c10bbd1129fcf81d50b6
caf6a8ac778eeb3183a7a35523044a5905519b76
/AuthServer/lib/arda2/util/utlPair.h
b85b676aa85fefec1f928f155934187670ff3e5e
[]
no_license
odasm/coh-original-server-vs2010
ec8ddd227d6d99e08e562b2c0b08df20e06eb02c
479e4baccd5b2688c216674492c4b87e4562595c
refs/heads/master
2020-05-16T07:21:09.364167
2019-04-22T03:21:57
2019-04-22T03:21:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,801
h
utlPair.h
/***************************************************************************** created: 2002/04/03 copyright: 2002, NCSoft. All Rights Reserved author(s): Ryan M. Prescott purpose: *****************************************************************************/ #ifndef INCLUDED_utlPair_h #define INCLUDED_utlPair_h #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 template <typename T> class utlPair { public: utlPair(){}; utlPair(const T& first, const T& second){m_First=first; m_Second=second;} utlPair<T> operator+(const corPair<T>& tup) const; utlPair<T> operator-(const corPair<T>& tup) const; utlPair<T> operator/(const T& val) const; utlPair<T> operator%(const T& val) const; bool operator==(const corPair<T>& val) const; T m_First; T m_Second; }; template <typename T> utlPair<T> corPair<T>::operator+(const corPair<T>& tup) const { corPair<T> temp; temp.m_First = m_First + tup.m_First; temp.m_Second= m_Second+ tup.m_Second; return temp; } template <typename T> bool utlPair<T>::operator==(const utlPair<T>& val) const { return ((m_First == val.m_First) && (m_Second == val.m_Second)); } template <typename T> utlPair<T> utlPair<T>::operator-(const utlPair<T>& tup) const { utlPair<T> temp; temp.m_First = m_First - tup.m_First; temp.m_Second= m_Second- tup.m_Second; return temp; } template <typename T> utlPair<T> utlPair<T>::operator/(const T& val) const { utlPair<T> temp; temp.m_First = m_First / val; temp.m_Second= m_Second / val; return temp; } template <typename T> utlPair<T> utlPair<T>::operator%(const T& val) const { utlPair<T> temp; temp.m_First = m_First % val; temp.m_Second= m_Second% val; return temp; } #endif // INCLUDED_utlPair_h
43afc317a5699ca0e297a1b94149a3d1c2708437
36c31b485a5906ab514c964491b8f001a70a67f5
/CSES/Problemset/DP/minicoin.cpp
4e2f9e789e1253c2e5bb1871e0682d2a52b269d1
[]
no_license
SMiles02/CompetitiveProgramming
77926918d5512824900384639955b31b0d0a5841
035040538c7e2102a88a2e3587e1ca984a2d9568
refs/heads/master
2023-08-18T22:14:09.997704
2023-08-13T20:30:42
2023-08-13T20:30:42
277,504,801
25
5
null
2022-11-01T01:34:30
2020-07-06T09:54:44
C++
UTF-8
C++
false
false
604
cpp
minicoin.cpp
#include <bits/stdc++.h> #define ll long long #define sz(x) (int)(x).size() using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,x; cin>>n>>x; int c[n]; for (int i=0;i<n;++i) { cin>>c[i]; } int dp[x+1]={0}; for (int i=1;i<=x;++i) { for (int j=0;j<n;++j) { if (i-c[j]>0) { if (dp[i-c[j]]>0) { if (dp[i]) { dp[i]=min(dp[i],dp[i-c[j]]+1); } else { dp[i]=dp[i-c[j]]+1; } } } else if (i-c[j]==0) { dp[i]=1; } } } if (dp[x]==0) { cout<<-1; return 0; } cout<<dp[x]; return 0; }
924268698d39deb131e33099011d186ebe2c2533
6d40480ec818c61ca44a33c5eabdfae7c79d908a
/Arkanoid_v1/Values.h
b5032f5588c58270e2b2ab594a925dbbaee158cf
[]
no_license
Neexol/Arkanoid
16c2718d5efa3f54ee412aebc2a4e494909d43bf
ad832f3bd27168846519eafb89b90381fa09500d
refs/heads/master
2020-05-05T00:24:40.497668
2019-05-20T14:36:20
2019-05-20T14:36:20
179,573,781
0
0
null
null
null
null
UTF-8
C++
false
false
796
h
Values.h
#pragma once #include <SFML/Graphics.hpp> namespace valueNS { constexpr int windowWidth = 800; constexpr int windowHeight = 800; constexpr int paddleWidth = 100; constexpr int paddleHeight = 21; constexpr int paddleRectWidth = 80; constexpr int paddleBorderRadius = 10; const sf::Vector2f paddleSpeed { 600, 0 }; constexpr int brickWidth = 80; constexpr int brickHeight = 37; constexpr int ballSize = 12; const sf::Vector2f ballSpeed{ 300, -300 }; constexpr int ballVelocity = 71; constexpr int fireBallSpeed = 500; constexpr int wallWidth = 800; constexpr int wallHeight = 64; constexpr int brickTableWidth = 9; constexpr int brickTableHeight = 7; constexpr int arrowWidth = 40; constexpr int arrowHeight = 50; constexpr int health = 3; constexpr int maxLevel = 3; }
b067e396f0195259f268fe1234ecc1d995592771
f23e74b37905ff1ffdf89d93bba7e408ad2632eb
/RegArch17/RegArchLib/cStudentResiduals.h
503e16bc728703078867f5aa39d22128cd91c5cd
[]
no_license
fellajim/ResidualsStats
27bb8b10e8c1a09f25ed13b804e002c67c0e9800
fef9f62d508030e1b2f3b182bcd163a161c4a0cd
refs/heads/master
2021-01-24T20:40:14.480364
2018-03-18T19:52:58
2018-03-18T19:52:58
123,254,720
2
0
null
null
null
null
UTF-8
C++
false
false
2,331
h
cStudentResiduals.h
#pragma once #ifndef _CSTUDENTRESIDUALS_H_ #define _CSTUDENTRESIDUALS_H_ #include <gsl/gsl_sf_gamma.h> #include <gsl/gsl_sf_psi.h> #include "cAbstResiduals.h" #include "cRegArchValue.h" #include "cRegArchGradient.h" /*! \file cStudentResiduals.h \brief Definition of the class for Student conditional distribution. \author Jean-Baptiste DURAND, Ollivier TARAMASCO \date dec-18-2006 - Last change feb-18-2011 */ namespace RegArchLib { /*! * \class cStudentResiduals * \brief Class to implement a Student distribution with unitary variance for residuals */ class cStudentResiduals: public cAbstResiduals { public : cStudentResiduals(double theDof, bool theSimulFlag=true) ; ///< A constructor cStudentResiduals(cDVector* theDistrParameter=NULL, bool theSimulFlag=true) ; ///< A constructor virtual ~cStudentResiduals() ; ///< A simple destructor virtual cAbstResiduals* PtrCopy() const ; /// < Return a copy of *this #ifdef _RDLL_ void Print(void); #else void Print(ostream& theOut) const; ///< Print the distribution type #endif // _RDLL_ void SetDefaultInitPoint(void) ; void Generate(const uint theNSample, cDVector& theYt) const; ///< Draw a sample from residual distribution double LogDensity(double theX) const ; /** Return the number of parameters in distribution */ uint GetNParam(void) const ; /** Compute the derivative of log density with respect to the random variable (theGradData[0]) \e and the gradient of log density with respect to the model parameters (other components in theGradData) */ double DiffLogDensity(double theX) const; void ComputeGrad(uint theDate, const cRegArchValue& theData, cRegArchGradient& theGradData) const; void RegArchParamToVector(cDVector& theDestVect, uint theIndex) const ; void VectorToRegArchParam(const cDVector& theSrcVect, uint theIndex = 0) ; double ComputeEspAbsEps(void) ; void ComputeGradBetaEspAbsEps(cDVector &theGrad) ; double Diff2LogDensity(double theX) const; void GradDiffLogDensity(double theX, const cDVector& theDistrParam, cDVector& theGrad); void ComputeHess(uint theDate, const cRegArchValue& theData, cRegArchGradient& theGradData, cRegArchHessien& theHessData, cAbstResiduals* theResiduals); void GetParamName(uint theIndex, char** theName); }; } #endif //_CSTUDENTRESIDUALS_H_
7f7763511537e7754f2188f5726eba929796c73c
5d417d772f6fa78d3f8b8aa09d50e480d951bc9b
/Test1/Source/Test1_Class.cpp
7d446ba326b317fba11673818ef528fe574c4d02
[]
no_license
bennetyf/CPP_Practice
22246cbfa400a86d25aa4f4b0ec2c1d9c392f9ea
05d552dfabbbe79b0beb3f82e2475805387ed115
refs/heads/master
2021-01-23T16:52:12.701767
2017-06-20T23:47:46
2017-06-20T23:47:46
93,307,524
0
0
null
null
null
null
UTF-8
C++
false
false
1,529
cpp
Test1_Class.cpp
// // Created by Travis Bennet on 16/6/17. // #include "Test1_Class.h" #include <iostream> using std::to_string; using std::string; Date::Date(int dd, int mm, int yy) :cache_valid{false},cache{""} { d=dd?dd:default_date.d; m=mm?mm:default_date.m; y=yy?yy:default_date.y; } Date& Date::addyear(int n) { y+=n; return *this; } Date& Date::addmonth(int n) { m+=n; return *this; } Date& Date::addday(int n) { d+=n; return *this; } string Date::date_rep() const { if(!cache_valid) { cache=to_string(d)+"/"+to_string(m)+"/"+to_string(y); cache_valid=true; } return cache; } int Date::year() const { return y; } int Date::month() const { return m; } int Date::day() const { return d; } void Date::set_default_date(int dd, int mm, int yy) { default_date.d=dd; default_date.m=mm; default_date.y=yy; } void OutterClass::Op_Outter() { // a=1000; //Error! Cannot access inner class member from the outter class // b=2000; //Error! // std::cout << "This is from Op_Outter:" << a << std::endl; } void OutterClass::InnerClass::Op_Inner(OutterClass& Outter) { //A=2; // Error! Cannot access non-static outter class member, because inner class doesn't // have access to the outter class object Outter.A=20; //Correct! Outter.B=3; std::cout << "This is from Op_Inner:" << Outter.A <<std::endl; } void OutterClass::Outter_Fun(OutterClass& Outter) { InnerClass Inner{}; Inner.Op_Inner(Outter); }
a7ef0544f77a74b63da4e912efef73d7443eac81
26870790cfcc9b0967a1dd56433f5bd5fabbb05a
/M04/ex01/PowerFist.cpp
24417d9dc9c465bbbbb2a4856c3e96905f3da91e
[]
no_license
Zera57/CPPModules
e87bd7bcc683f64f3726217c7326fb60186ecd16
0c588ddfc2b4193fca8c7c1cb75deb83d8ef8e03
refs/heads/master
2023-05-30T10:13:11.074873
2021-06-20T17:00:09
2021-06-20T17:00:09
358,862,884
0
0
null
null
null
null
UTF-8
C++
false
false
337
cpp
PowerFist.cpp
#include "PowerFist.hpp" PowerFist::PowerFist() : AWeapon("Power Fist", 8, 50) { } PowerFist::~PowerFist() { } PowerFist::PowerFist(const PowerFist& p) : AWeapon(p) { } void PowerFist::operator= (const PowerFist& s) { AWeapon::operator=(s); } void PowerFist::attack() const { std::cout << "* pschhh... SBAM! *" << std::endl; }
92a9dfe54b28dba9bd2e11afbb4c4f50944c7af0
93b73a6500e58314e8a15e80e7490518593057bc
/C/C Programs/cpp/Point.cpp
d999e9c95702936db7e2cbad9fa7caea3a95f736
[]
no_license
MadhuriTeli/Assignments
45bc800db5fe6f4c82c05fa4f7307d27286fa7cc
85cca67dfea60f6b21c6bc4c36d53eef6e934978
refs/heads/main
2023-08-18T18:02:36.322485
2021-10-04T20:22:31
2021-10-04T20:22:31
372,739,870
0
0
null
null
null
null
UTF-8
C++
false
false
1,036
cpp
Point.cpp
/* 4. Create a class Point with data members as x,y. Create Default and Parameterized constructors. Write getters and setters for all the data members. Also ax the display function. Create the object of this class in main method and invoke all the methods in that class. */ #include <iostream> using namespace std; class Point { private: int x; int y; public: Point() { this->x = 0; this->y = 0; } Point(int xd, int Dy) { this->x = xd; this->y = Dy; } int getX() { return this->x; } void setX(int xay) { this->x = xay; } int getY() { return this->y; } void setY(int dy) { this->y = dy; } void display() { cout << "---------------- Details-------------------" << endl; cout << "x: " << this->x << endl; cout << "y : " << this->y << endl; } }; int main() { Point p1; Point p2(4, 9); p1.display(); p2.display(); p1.setX(15); p1.setY(15); p1.display(); cout << "X: " << p1.getX() << endl; cout << "Y : " << p1.getY() << endl; }
b5a8830feb6536481a32b6b98ca7799ab159d9f3
3b23fcd9297a01e8efd6f601cd3a61af79516270
/source/config.cpp
b082818ae5681286705add6ebcd003cd1945567c
[]
no_license
markadamo/tempest
c1ab6eaeb32fb77b62af49c9c464785534492f0d
6187dc5d18fefd3b73943753ccd0274487c08ca7
refs/heads/master
2021-01-15T15:41:53.798472
2016-09-15T15:54:57
2016-09-15T15:54:57
43,511,733
3
0
null
null
null
null
UTF-8
C++
false
false
5,753
cpp
config.cpp
#include "tempest.hpp" extern void Tempest::parse_config() { FILE* fp; char sLine[STRING_SIZE]; char sParam[STRING_SIZE]; char sTemp[STRING_SIZE]; if((fp = (FILE*) fopen(Tempest::args.sConfig, "r")) == NULL) { fprintf( stderr, "ERROR\tUnable to open config file %s: %s\n", Tempest::args.sParams, strerror(errno) ); Tempest::tempest_exit(EXIT_FAILURE); } while (fgets(sLine, sizeof(sLine), fp)) { //change > to null terminator to stop parsing line at comment symbol for (int i=0; i<STRING_SIZE; i++) { if (sLine[i] == '>') sLine[i] = '\0'; if (sLine[i] == '\0') break; } if (sscanf(sLine, "%s", sParam) == -1) continue; if (strcmp(sParam, "platform") == 0) { if (Tempest::args.deviceOverride) continue; if (Tempest::config.iPlatform != -1) { fprintf(stderr, "\nERROR: Multiple platform definitions:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } if (sscanf(sLine, "platform %d \n", &Tempest::config.iPlatform) != 1) { fprintf(stderr, "\nERROR: Could not parse platform definition:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } } else if (strcmp(sParam, "device") == 0) { if (Tempest::args.deviceOverride) continue; int deviceID; if (sscanf(sLine, "device %d \n", &deviceID) != 1) { fprintf(stderr, "\nERROR: Could not parse device definition:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } Tempest::config.iDevices.push_back(deviceID); } else if (strcmp(sParam, "max_host_mem") == 0) { if (Tempest::args.hostMemOverride) continue; float maxMem; if (sscanf(sLine, "max_host_mem %f %s\n", &maxMem, sTemp) != 2) { fprintf(stderr, "\nERROR: Could not parse max_host_mem definition:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } if (maxMem < 0) { fprintf(stderr, "\nERROR: Negative value in parse max_host_mem definition:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } char unit = tolower(sTemp[0]); if (unit!='b' && unit!='k' && unit!='m' && unit!='g') { fprintf(stderr, "\nERROR: Invalid units in parse max_host_mem definition:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } int factor; if (unit == 'k') factor = KB; else if (unit == 'm') factor = MB; else if (unit == 'g') factor = GB; else factor = 1; Tempest::config.maxHostMem = (size_t)(maxMem*factor); } else if (strcmp(sParam, "max_device_mem") == 0) { if (Tempest::args.deviceMemOverride) continue; float maxMem; if (sscanf(sLine, "max_device_mem %f %s\n", &maxMem, sTemp) != 2) { fprintf(stderr, "\nERROR: Could not parse max_device_mem definition\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } if (maxMem < 0) { fprintf(stderr, "\nERROR: Invalid value in parse max_device_mem definition\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } char unit = tolower(sTemp[0]); if (unit!='b' && unit!='k' && unit!='m' && unit!='g') { fprintf(stderr, "\nERROR: Invalid units in parse max_device_mem definition\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } int factor; if (unit == 'k') factor = KB; else if (unit == 'm') factor = MB; else if (unit == 'g') factor = GB; else factor = 1; Tempest::config.maxDeviceMem = (size_t)(maxMem*factor); } else if (strcmp(sParam, "min_work_size") == 0) { if (sscanf(sLine, "min_work_size %d \n", &Tempest::config.minWorkSize) != 1) { fprintf(stderr, "\nERROR: Could not parse min_work_size:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } } else if (strcmp(sParam, "parallel_reduce") == 0) { int temp; if (sscanf(sLine, "parallel_reduce %d\n", &temp) != 1) { fprintf(stderr, "\nERROR: Could not parse parallel_reduce flag:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } if (temp != 0 && temp != 1) { fprintf(stderr, "\nERROR: Invalid value in parallel_reduce flag:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } else Tempest::config.parallelReduce = temp; } else if (strcmp(sParam, "profile") == 0) { int temp; if (sscanf(sLine, "profile %d\n", &temp) != 1) { fprintf(stderr, "\nERROR: Could not parse profile flag:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } if (temp != 0 && temp != 1) { fprintf(stderr, "\nERROR: Invalid value in profile flag:\n\t>%s", sLine); Tempest::tempest_exit(EXIT_FAILURE); } else Tempest::config.profile = temp; } else fprintf(stderr, "\nWARNING: unknown config parameter: '%s'\n", sParam); } }
f4360af17f5ca7daf5de8d25df04cb1101e80917
54a72cffb4bd57c703ad0ccca400dc6edcc095ba
/boost/call_stack/symbol.hpp
36b9e4ff98ddef2df644ab61317e00b04c3968cf
[ "BSL-1.0" ]
permissive
lainproliant/Boost-Call_stack
793c929d13853b46ba02c85dff7b4f1e3f6e9e34
3fe2ce9601738e9375168b557837bf44ca812508
refs/heads/master
2020-06-08T07:27:58.235701
2018-10-19T16:47:00
2018-10-19T16:47:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,003
hpp
symbol.hpp
/* * Copyright 2013 Aurelian Melinte. * * Use, modification and distribution are subject to the Boost Software License, * Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt). */ #if !defined(BOOST_CALL_STACK_SYMBOL_HPP) #define BOOST_CALL_STACK_SYMBOL_HPP #if defined(_MSC_VER) && _MSC_VER >= 1200 # pragma once #endif #if !defined(BOOST_CALL_STACK_HPP) # error "This header cannot be included directly. Include <boost/call_stack/call_stack.hpp>" #endif #include <boost/call_stack/detail/platform.hpp> #include <boost/static_assert.hpp> #include <boost/move/move.hpp> /* * */ namespace boost { namespace call_stack { /* * */ typedef detail::address_type address_type; static const address_type null_address = detail::null_address; typedef detail::delta_type delta_type; static const delta_type null_delta = detail::null_delta; /** * Adapters for the address of an object or function. Not for methods, * even less for virtual ones. */ template< class T > address_type addressof(const T& arg) { address_type addr(0); addr = reinterpret_cast<address_type>( &const_cast<char&>( reinterpret_cast<const volatile char&>(arg))); return addr; } template< class T > address_type addressof(const T* arg) { address_type addr(0); addr = reinterpret_cast<address_type>(arg); return addr; } /** * Symbol resolver interface to plaftorm-specific resolvers. */ template < typename Resolver > class symbol_resolver : protected Resolver { public: symbol_resolver(const address_type addr = null_address) noexcept : Resolver(addr) { } /** * Constructors on an arbitrary address of an object or a function. * Not necessarily a good idea, use with care. The underlying platform * resolver might be able to resolve the given address or not. * @see addressof. */ template < typename T > symbol_resolver(const T& arg) noexcept : Resolver(addressof(arg)) { } template < typename T > symbol_resolver(const T* arg) noexcept : Resolver(addressof(arg)) { } symbol_resolver(const symbol_resolver& other) noexcept : Resolver(other.addr()) { } #if (__cplusplus >= 201103L) symbol_resolver(symbol_resolver&& other) noexcept : Resolver() { swap(other); } #endif symbol_resolver& operator=(symbol_resolver other) noexcept { swap(other); return *this; } void resolve(const address_type& addr) noexcept { Resolver::resolve(addr); } const address_type addr() const noexcept { return Resolver::addr(); } const char* binary_file() const noexcept { return Resolver::binary_file(); } const char* raw_name() const noexcept { return Resolver::raw_name(); } const char* demangled_name() const noexcept { return Resolver::demangled_name(); } /** * Displacement of \ref addr() from symbol address. Some platforms have * only a positive displacement. */ delta_type delta() const noexcept { return Resolver::delta(); } const char* source_file() const noexcept { return Resolver::source_file(); } unsigned int line_number() const noexcept { return Resolver::line_number(); } void swap(symbol_resolver& other) noexcept { Resolver::swap(other); } template < typename OutputFormatter > friend inline std::ostream& operator<<(std::ostream& os, const symbol_resolver& sym) { OutputFormatter::print(sym, os); return os; } template < typename OutputFormatter > std::string as_string() const { std::ostringstream s; OutputFormatter::print(*this, s); return s.str(); } }; //symbol_resolver template < typename Resolver > inline void swap(symbol_resolver<Resolver>& left, symbol_resolver<Resolver>& right) noexcept { BOOST_ASSERT(&left != &right); left.swap(right); } /** * Plain symbol info. No memory allocation permitted when resolving the * symbol, hence, typically, not much information made available; typically, * no symbol information. Might be useful for tracking down issues in a * memory-tight situation. */ typedef symbol_resolver<detail::null_symbol_resolver> null_symbol_resolver; /** * Best resolution offered by libraries always installed with the OS. */ typedef symbol_resolver<detail::basic_symbol_resolver> basic_symbol_resolver; /** * Best resolution for the platform. Might require additional/optional * libraries. If \def BOOST_CALL_STACK_NO_OPTIONAL_LIBS is defined, this * resolver is equivalent to \ref boost::call_stack::basic_symbol_resolver. */ typedef symbol_resolver<detail::extended_symbol_resolver> extended_symbol_resolver; /** * Binds together a \ref symbol_resolver and a formatter for the symbol * information. * * @tparam AddrResolver See \ref symbol_resolver * @tparam OutputFormatter See \ref terse_symbol_formatter, \ref fancy_symbol_formatter */ template < typename AddrResolver , typename OutputFormatter > class symbol_info : public AddrResolver { public: typedef AddrResolver symbol_resolver_type; typedef OutputFormatter symbol_formatter_type; symbol_info(const address_type& addr = null_address) noexcept : symbol_resolver_type(addr) {} /** * Constructors on an arbitrary address of an object or a function. * Not necessarily a good idea, use with care. The underlying platform * resolver might be able to resolve the given address or not. * @see addressof. */ template < typename T > symbol_info(const T& arg) noexcept : symbol_resolver_type(addressof(arg)) { } template < typename T > symbol_info(const T* arg) noexcept : symbol_resolver_type(addressof(arg)) { } #if (__cplusplus >= 201103L) symbol_info(symbol_info&& other) noexcept { swap(other); } #endif symbol_info(const symbol_info& other) noexcept {} symbol_info& operator=(symbol_info other) noexcept { swap(other); return *this; } void swap(symbol_info& other) noexcept { symbol_resolver_type::swap(other); } friend inline std::ostream& operator<<(std::ostream& os, const symbol_info& sym) { symbol_formatter_type:: template print< symbol_resolver_type >(sym, os); return os; } std::string as_string() const { std::ostringstream s; s << *this; return s.str(); } }; template < typename AddrResolver , typename OutputFormatter > inline void swap(symbol_info< AddrResolver, OutputFormatter >& left, symbol_info< AddrResolver, OutputFormatter >& right) noexcept { BOOST_ASSERT(&left != &right); left.swap(right); } /** * How to format \ref symbol_info information. */ struct terse_symbol_formatter { template < typename SymbolResolver > static void print(SymbolResolver const& sym, std::ostream& os) { os << "[" << std::hex << sym.addr() << "] " << sym.demangled_name() << (sym.delta() >= 0 ? '+' : '-') << "0x" << std::hex << sym.delta() << " (" << sym.binary_file() << ")" << " in " << sym.source_file() << ":" << std::dec << sym.line_number() ; } }; /** * How to format \ref symbol_info information. */ struct fancy_symbol_formatter { template < typename SymbolResolver > static void print(SymbolResolver const& sym, std::ostream& os) { os << "[" << std::hex << sym.addr() << "] " << sym.demangled_name() << (sym.delta() >= 0 ? '+' : '-') << "0x" << std::hex << sym.delta() << "\n\tAt " << sym.source_file() << ":" << std::dec << sym.line_number() << "\n\tIn " << sym.binary_file() ; } }; }} //namespace boost::call_stack namespace std { template < typename Resolver > inline void swap(boost::call_stack::symbol_resolver<Resolver>& left, boost::call_stack::symbol_resolver<Resolver>& right) noexcept { boost::call_stack::swap(left, right); } template < typename AddrResolver , typename OutputFormatter > inline void swap(boost::call_stack::symbol_info< AddrResolver, OutputFormatter >& left, boost::call_stack::symbol_info< AddrResolver, OutputFormatter >& right) noexcept { BOOST_ASSERT(&left != &right); left.swap(right); } } //namespace std #endif //#if !defined(BOOST_CALL_STACK_SYMBOL_HPP)
8a30a6f8378c3d399a8a9f90c8b014a77dd964f4
619b10e5767af68e1d7096574a5ee920b22705da
/01.ObjectOrientation/Game.h
d49d3d80771d0544dd049b7eb38028abb96bf037
[]
no_license
toruSIF378/test
66e7b4681f435dccec802b0379ff9c2ad7dac708
65ea0b9838f8b8594ba0e978eeb8f87f896e5498
refs/heads/master
2020-08-29T21:16:11.184239
2020-01-22T04:14:24
2020-01-22T04:14:24
218,176,284
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
371
h
Game.h
#pragma once #include"DxLib.h" class Player; class EnemyManager; class Shot; class Game { public: int Initialize();//ๅˆๆœŸๅŒ– void Finalize(); //็ต‚ไบ†ๅ‡ฆ็† void Update();//ๆ›ดๆ–ฐ void Draw();//ๆ็”ป // ใƒ—ใƒฌใ‚คใƒคใƒผใ‚’็”Ÿๆˆ. Player* player; //// ้šœๅฎณ็‰ฉใ‚’็”Ÿๆˆ. EnemyManager* enemyManager; //*ๅผพใ‚’็”Ÿๆˆ Shot* shot; };
796a0f84a0d2c297dea95f0d228ac1e59d64fe02
2f3e514598851d6747ea31bdbca308983a8c86f1
/app/src/include/sma/ccn/blockref.hpp
b466c20b8ba51d3ec81a99399a6bdbd68c3331a5
[]
no_license
culiu/sma
f2110a4b2649085528f852c1a590adf24f9f4eab
fc6f12fbd70bbe9194db0c2212acb74c4d87b1ac
refs/heads/master
2020-12-31T06:09:18.285213
2015-11-19T12:33:28
2015-11-19T12:33:28
45,673,430
0
0
null
null
null
null
UTF-8
C++
false
false
1,125
hpp
blockref.hpp
#pragma once #include <sma/util/hash.hpp> #include <sma/util/serial.hpp> #include <cstdint> #include <cstdlib> #include <ostream> #include <functional> namespace sma { using BlockIndex = std::uint16_t; struct BlockRef { TRIVIALLY_SERIALIZABLE(BlockRef, hash, index); BlockRef(Hash hash, BlockIndex index) : hash(hash) , index(index) { } bool operator==(BlockRef const& rhs) const { return hash == rhs.hash && index == rhs.index; } bool operator!=(BlockRef const& rhs) const { return !(*this == rhs); } Hash hash; BlockIndex index; }; inline std::ostream& operator<<(std::ostream& os, BlockRef const& ref) { return os << "(" << std::string(ref.hash) << ")[" << ref.index << "]"; } } namespace std { template <> struct hash<sma::BlockRef> { size_t operator()(sma::BlockRef const& block) const { return 37 * hash<sma::Hash>()(block.hash) + block.index; } }; template <> struct less<sma::BlockRef> { using arg_type = sma::BlockRef; bool operator()(arg_type const& lhs, arg_type const& rhs) const { return (lhs.hash < rhs.hash) && (lhs.index < rhs.index); } }; }
6855f7f7f277ce3d5722ae36e241708d37ed253e
2ea984ee5114382724502f2667b236f2e1136560
/ๅˆถไฝœใ‚ฒใƒผใƒ /FMSTG01/project/src/SceneManager/Scene/GameMain/cGameMain.cpp
4fcc752f7c15bcbe7d5daa538e63bade69d5a00c
[]
no_license
s-kosugi/FMGameBase
06cce9670025769e0a41b45cfc295372d72817e5
595a845135b1b5691bd22274fa0496fb97df76bf
refs/heads/master
2022-12-30T07:10:42.897526
2020-10-05T23:40:01
2020-10-05T23:40:01
292,718,517
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
6,940
cpp
cGameMain.cpp
/*==============================================================================*/ /* */ /* @file title : cGameMain.cpp */ /* @brief : ใ‚ฒใƒผใƒ ใƒกใ‚คใƒณใ‚ทใƒผใƒณ */ /* @written : s.kosugi */ /* @create : 2018/12/02 */ /* */ /*==============================================================================*/ #include "..\..\..\cGame.h" #include "cGameMain.h" #include "..\..\cSceneManager.h" #include "..\..\..\Input\Keyboard\cKeyboard.h" #include "..\..\..\BaseObject\cSpriteObject.h" #include <DxLib.h> #include "..\..\..\BaseObject\GameObject\BackGround\cBackGroundManager.h" #include "..\..\..\BaseObject\GameObject\Player\cPlayer.h" #include "..\..\..\BaseObject\GameObject\Enemy\cEnemyManager.h" #include "..\..\..\BaseObject\GameObject\Bullet\cBulletManager.h" #include "..\..\..\EventManager\cEventManager.h" #include "..\..\..\BaseObject\GameObject\Effect\cEffectManager.h" #include "..\..\..\BaseObject\GameObject\SpEffect\cSpEffectManager.h" #include "..\..\..\BaseObject\GameObject\UI\cUIManager.h" #include "..\..\..\ScoreManager\cScoreManager.h" #include "..\..\..\Input\cControllerManager.h" #include "..\..\..\Pause\cPause.h" #include "..\..\..\SoundCtrl\cSoundCtrl.h" //========================================================================================== // ใ‚ณใƒณใ‚นใƒˆใƒฉใ‚ฏใ‚ฟ //========================================================================================== cGameMain::cGameMain(IBaseObject * parent) : IBaseObject(parent, "GameMain") { } //========================================================================================== // ใƒ‡ใ‚นใƒˆใƒฉใ‚ฏใ‚ฟ //========================================================================================== cGameMain::~cGameMain(void) { } //========================================================================================== // ๅˆๆœŸๅŒ– //========================================================================================== void cGameMain::Initialize(void) { // ่ƒŒๆ™ฏใƒžใƒใƒผใ‚ธใƒฃใƒผใฎ่ฟฝๅŠ  AddChild(&cBackGroundManager::GetInstance()); // ใƒ—ใƒฌใ‚คใƒคใƒผใ‚ญใƒฃใƒฉใ‚ฏใ‚ฟใƒผใฎ็”Ÿๆˆ CreateObject<cPlayer>(this); // ๆ•ตใƒžใƒใƒผใ‚ธใƒฃใƒผใฎ่ฟฝๅŠ  AddChild(&cEnemyManager::GetInstance()); // ๅผพใƒžใƒใƒผใ‚ธใƒฃใƒผใฎ่ฟฝๅŠ  AddChild(&cBulletManager::GetInstance()); // ใ‚คใƒ™ใƒณใƒˆใƒžใƒใƒผใ‚ธใƒฃใƒผใฎ่ฟฝๅŠ  AddChild(&cEventManager::GetInstance()); // ใ‚นใƒ†ใƒผใ‚ธ๏ผ‘ใฎใ‚คใƒ™ใƒณใƒˆใ‚’้–‹ๅง‹ cEventManager::GetInstance().StartEvent(1); // ใ‚จใƒ•ใ‚งใ‚ฏใƒˆใƒžใƒใƒผใ‚ธใƒฃใƒผใฎ่ฟฝๅŠ  AddChild(&cEffectManager::GetInstance()); // ใ‚นใƒ—ใƒฉใ‚คใƒˆใ‚จใƒ•ใ‚งใ‚ฏใƒˆใƒžใƒใƒผใ‚ธใƒฃใƒผใฎ่ฟฝๅŠ  AddChild(&cSpEffectManager::GetInstance()); // UIใƒžใƒใƒผใ‚ธใƒฃใƒผใฎ่ฟฝๅŠ  AddChild(&cUIManager::GetInstance()); // ใ‚นใ‚ณใ‚ขใƒชใ‚ปใƒƒใƒˆ cScoreManager::GetInstance().ResetScore(); IBaseObject::Initialize(); } //========================================================================================== // ๆ›ดๆ–ฐ //========================================================================================== void cGameMain::Update(void) { IBaseObject::Update(); // ๅฝ“ใŸใ‚Šๅˆคๅฎšๅ‡ฆ็† CheckHitProc(); // ใƒใƒผใ‚บ้–‹ๅง‹ๅ‡ฆ็† if (cControllerManager::GetInstance().CheckTriger(cControllerManager::KEY_PAUSE)) cPause::GetInstance().StartPause(); #ifdef DEBUG // ใ‚ฟใ‚คใƒˆใƒซใ‚ทใƒผใƒณใธ cKeyboard key = cKeyboard::GetInstance(); if (key.CheckTriger(KEY_INPUT_RETURN)) { cSceneManager* sm = (cSceneManager*)GetParent(); sm->ChangeScene(SCENE_ID_TITLE); } #endif } //========================================================================================== // ็ ดๆฃ„ //========================================================================================== IBaseObject* cGameMain::Finalize(void) { // โ€ปใƒ•ใ‚งใƒผใƒ‰ใ‚ขใ‚ฆใƒˆ้–ขๆ•ฐใ‚’ไฝœใฃใŸใปใ†ใŒใ„ใ„ใ‹ใ‚‚ใ€‚ cSoundCtrl::GetInstance().BGMStop(); IBaseObject::Finalize(); return this; } //========================================================================================== // ๅฝ“ใŸใ‚Šๅˆคๅฎšๅ‡ฆ็† //========================================================================================== void cGameMain::CheckHitProc(void) { // ่‡ชๆฉŸใจๆ•ตใฎๅฝ“ใŸใ‚Šๅˆคๅฎšๅ‡ฆ็† CheckHitPlayer(); // ๆ•ตใฎๅฝ“ใŸใ‚Šๅˆคๅฎšๅ‡ฆ็† CheckHitEnemy(); } //========================================================================================== // ่‡ชๆฉŸใจๆ•ตใฎๅฝ“ใŸใ‚Šๅˆคๅฎš // ่‡ชๆฉŸVSๆ•ต ่‡ชๆฉŸVSๆ•ตใฎๅผพ //========================================================================================== void cGameMain::CheckHitPlayer(void) { cPlayer* player = (cPlayer*)FindChild("Player"); if (nullptr == player) return; cEnemyManager& em = cEnemyManager::GetInstance(); std::list<IBaseObject*>::iterator it = em.GetChildList()->begin(); std::list<IBaseObject*>::iterator end = em.GetChildList()->end(); while (it != end) { cHitObject* obj = (cHitObject*)(*it); // ๆ•ตใจใƒ—ใƒฌใ‚คใƒคใƒผใฎๅฝ“ใŸใ‚Šๅˆคๅฎšใ‚’ใ™ใ‚‹ if (player->CheckHitObject(*obj)) { // ๅฝ“ใŸใฃใŸ return; } it++; } cBulletManager& bm = cBulletManager::GetInstance(); std::list<IBaseObject*>::iterator bit = bm.GetChildList()->begin(); std::list<IBaseObject*>::iterator bend = bm.GetChildList()->end(); while (bit != bend) { cHitObject* obj = (cHitObject*)(*bit); if (obj->GetHitCate() == cHitObject::HIT_ENEMY) { // ใƒ—ใƒฌใ‚คใƒคใƒผใจๆ•ตใฎๅผพใฎๅฝ“ใŸใ‚Šๅˆคๅฎšใ‚’ใ™ใ‚‹ if (player->CheckHitObject(*obj)) { // ๅฝ“ใŸใฃใŸ return; } } bit++; } } //========================================================================================== // ๆ•ตใจ่‡ชๆฉŸใฎๅผพใฎๅฝ“ใŸใ‚Šๅˆคๅฎš //========================================================================================== void cGameMain::CheckHitEnemy(void) { cEnemyManager& em = cEnemyManager::GetInstance(); std::list<IBaseObject*>::iterator it = em.GetChildList()->begin(); std::list<IBaseObject*>::iterator end = em.GetChildList()->end(); cBulletManager& bm = cBulletManager::GetInstance(); std::list<IBaseObject*>::iterator bit = bm.GetChildList()->begin(); std::list<IBaseObject*>::iterator bend = bm.GetChildList()->end(); while (it != end) { cHitObject* obj = (cHitObject*)(*it); while (bit != bend) { cHitObject* bobj = (cHitObject*)(*bit); if (bobj->GetHitCate() == cHitObject::HIT_PLAYER) { // ๅ…จใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆใจๅฝ“ใŸใ‚Šๅˆคๅฎšใ‚’ใ™ใ‚‹ obj->CheckHitObject(*bobj); // ๆ•ตใจใƒ—ใƒฌใ‚คใƒคใƒผใฎๅผพๅฝ“ใŸใ‚Šๅˆคๅฎšใ‚’ใ™ใ‚‹ //if (obj->CheckHitObject(*bobj)) //{ // // ๅฝ“ใŸใฃใŸ // break; //} } bit++; } bit = bm.GetChildList()->begin(); it++; } }
d022dda98efcbdf8b4173d9fb5568f64cf4cf3d3
0f2b08b31fab269c77d4b14240b8746a3ba17d5e
/onnxruntime/core/providers/cuda/nn/shrink.h
088fb74a99054532653e17ac414a4fbdf53f147f
[ "MIT" ]
permissive
microsoft/onnxruntime
f75aa499496f4d0a07ab68ffa589d06f83b7db1d
5e747071be882efd6b54d7a7421042e68dcd6aff
refs/heads/main
2023-09-04T03:14:50.888927
2023-09-02T07:16:28
2023-09-02T07:16:28
156,939,672
9,912
2,451
MIT
2023-09-14T21:22:46
2018-11-10T02:22:53
C++
UTF-8
C++
false
false
862
h
shrink.h
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #include "core/providers/cuda/cuda_kernel.h" namespace onnxruntime { namespace cuda { template <typename T> class Shrink final : public CudaKernel { public: Shrink(const OpKernelInfo& info) : CudaKernel(info) { float bias_temp; // if the attribute exists, use the value if (info.GetAttr<float>("bias", &bias_temp).IsOK()) bias_ = bias_temp; float lambd_temp; // if the attribute exists, use the value if (info.GetAttr<float>("lambd", &lambd_temp).IsOK()) lambd_ = lambd_temp; } Status ComputeInternal(OpKernelContext* p_op_kernel_context) const; private: float bias_ = 0.0f; // default as per spec float lambd_ = 0.5f; // default as per spec }; } // namespace cuda } // namespace onnxruntime
28d857d1dd7ad07fcd6cdf0e2628b3772b88da6c
6788029cea91510eef3ad0df197c7a0ebd7ba8c1
/Common/Utils/src/Threading/Executor.cpp
b9c2aa5fd11bf42d8e9d56293d12c8d7dc8a4f01
[]
no_license
hiepnguyen57/smart_speaker_sdk
7d60f370cf06e020cc72efddd9a067c80dc3ca21
6048a12db00014fe15db8cacbad85d1ebe2a07a8
refs/heads/master
2020-05-06T12:13:29.482107
2019-09-07T08:54:31
2019-09-07T08:54:31
180,109,853
1
0
null
null
null
null
UTF-8
C++
false
false
1,783
cpp
Executor.cpp
#include "Common/Utils/Memory/Memory.h" #include "Common/Utils/Threading/Executor.h" namespace deviceClientSDK { namespace common { namespace utils { namespace threading { Executor::~Executor() { shutdown(); } Executor::Executor(const std::chrono::milliseconds& delayExit) : m_threadRunning{false}, m_timeout{delayExit}, m_shutdown{false} { } void Executor::waitForSubmittedTasks() { std::unique_lock<std::mutex> lock{m_queueMutex}; if (m_threadRunning) { // wait for thread to exit. std::promise<void> flushedPromise; auto flushedFuture = flushedPromise.get_future(); m_queue.emplace_back([&flushedPromise]() { flushedPromise.set_value(); }); lock.unlock(); m_delayedCondition.notify_one(); flushedFuture.wait(); } } std::function<void()> Executor::pop() { std::lock_guard<std::mutex> lock{m_queueMutex}; if (!m_queue.empty()) { auto task = std::move(m_queue.front()); m_queue.pop_front(); return task; } return std::function<void()>(); } bool Executor::hasNext() { std::unique_lock<std::mutex> lock{m_queueMutex}; m_delayedCondition.wait_for(lock, m_timeout, [this] { return !m_queue.empty() || m_shutdown; }); m_threadRunning = !m_queue.empty(); return m_threadRunning; } bool Executor::runNext() { auto task = pop(); if (task) { task(); } return hasNext(); } void Executor::shutdown() { std::unique_lock<std::mutex> lock{m_queueMutex}; m_queue.clear(); m_shutdown = true; lock.unlock(); waitForSubmittedTasks(); } bool Executor::isShutdown() { return m_shutdown; } } // namespace threading } // namespace utils } // namespace common } // namespace deviceClientSDK
29ecb24cbf502fed9bf20c2fb621998003203096
cdf92aa3a8a49dc044306c125356cca26910dbda
/incoming/BitBucket-INDI1/trunk186/INDI2/EIRlibs/eirType/VariantDom.cpp
80f92d8f3487b37d647a2a3dc79b38a391b0f651
[ "MIT" ]
permissive
eirTony/INDI1
b7c5d2ba0922a509b32d9d411938ecdc0f725109
07fe9eff4fb88c6c2d636c94267ea8734d295223
refs/heads/master
2020-01-23T21:22:49.833055
2016-11-26T07:43:06
2016-11-26T07:43:06
74,568,244
0
0
null
null
null
null
UTF-8
C++
false
false
488
cpp
VariantDom.cpp
#include "VariantDom.h" #include <QDomElement> #include "DataType.h" VariantDom::VariantDom(const QDomElement & de) { QString elementTag = de.tagName(); if (DataType::elementTag_s == elementTag) { QString dataType = de.attribute(DataType::attribute_s); DataType dt(dataType); if (dt.isValid()) QVariant::setValue(dt.variantDom(dt, de)); } } VariantDom::operator QVariant (void) { return QVariant(*this); }
5f24027eebaa09f520a7cbc9be43a796b0ecbb9b
cf9b32b532ac0db1193dfe93b7e734f1e91f6d44
/sp2/labyGame.cpp
f278a06f0bfaf800806efbcc815ca7160b2483ad
[]
no_license
AnicetNgrt/C-labyrinthe-moebius
20959ef73b7e98e6416c2d3c8e6856eb90dcf7bb
068f71a34f15626d764f64c63d77bd5607d3e798
refs/heads/master
2022-12-13T19:35:18.994034
2020-09-01T08:45:49
2020-09-01T08:45:49
229,442,937
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
1,253
cpp
labyGame.cpp
#include "labyGame.h" #define PILE_CAP 10 #define PILE_PAS 1 /** * @brief Parcours du labyrinthe par le dragon */ void MissionDragon() { Laby laby; Pile pile; char path[] = "inSmall.txt"; bool plan_found = false; Vec3 courant = tuple(0, 0, 0); initialiser(path, laby); initialiser(PILE_CAP, PILE_PAS, pile); empiler(laby.crd_dragon, pile); /*while (!plan_found && !est_vide(pile)) {*/ for (unsigned int k = 0; k < 10; ++k) { courant = sommet(pile); depiler(pile); if (read_case(courant, laby).type != PLAN) { for (int i = 0; i < NBDEPL; ++i) { Vec3 translation = from_list(DEPL[i]); if (courant.y == 0 && translation.y == -1) { continue; } if (laby.faces[courant.z].nbL <= courant.y + translation.y) { continue; } Vec3 translate = translation_moebius(courant, translation, laby); if (est_connexe(courant, translate, laby)) { empiler(translate, pile); } } Case* ca = get_case(courant, laby); ca->visite = true; ca->ordre = k; } else { plan_found = true; } } /*if (read_case(courant, laby).type == PLAN) { std::cout << "trouvรฉ"; afficher(courant); std::cout << "\n"; } else { std::cout << "non\n"; }*/ afficher(laby); std::cout << "\n"; }
3cd4969bdb827eb2c19ce4a658c3598327ee1cbd
27e917a5e9aba4f638127b78cc70bdd0d496df68
/1)28.11.2018/exemplu if.cpp
4dc82adbefbff7dc4bd34cbaaef57b0434c84f35
[]
no_license
MihaiAnghelin/StepIT-C
e90797bafd7600b65b9a615892867f655e8ddb41
d2d55d4d58f6620d1e33590b83122e8d7776ba8c
refs/heads/master
2020-06-07T03:23:48.134478
2019-06-20T12:08:29
2019-06-20T12:08:29
192,909,901
0
0
null
2020-05-13T17:05:41
2019-06-20T11:44:52
C++
UTF-8
C++
false
false
767
cpp
exemplu if.cpp
//Program teste instructiunea if #include<cstdio> #include<cstdlib> int main() { int n = 1; int a = 26, b = 2; float div; while (n != 0) { printf("Introduceti numarul de la tastatura:\n"); scanf_s("%d", &n); if (0 == n) break; if (n % 2 == 0) { if ((n >= 10) && (n <= 20)) printf("Numarul e par si mai mare decat 10 si mai mic decat 20\n"); else printf("Numarul nu este in parametrii [10,20]"); } else { printf("Numarul este impar\n"); } } if (b != 0) { div = (float)a / b; printf("rezultatul impartirii %.2f\n", div); } system("PAUSE"); return 0; }
224446da27b0cabe96eb84aa8db5682b2a42a51b
36f008546cf833df7230c1c23f3d81dd8651d601
/zad4/generator.hxx
f5a5647e64602ce67fa5d78b0fe4db7c3c766873
[]
no_license
j000/MonteCarlo
e898a29c2fbad54d388f1ae9a9d63ded1641acea
c17ca2e14657489bcc95bbfb05b669fc12d48ef6
refs/heads/main
2023-04-06T02:49:27.009510
2021-04-12T07:33:00
2021-04-12T07:33:00
343,377,290
1
0
null
null
null
null
UTF-8
C++
false
false
350
hxx
generator.hxx
#ifndef GENERATOR_HXX #define GENERATOR_HXX #include <gsl/gsl_randist.h> class Generator { public: Generator(unsigned long seed = 0); ~Generator(); double operator()(); double get_pos(); unsigned long get_int(unsigned long max); private: static gsl_rng* m_generator; #pragma omp threadprivate(m_generator) }; #endif /* GENERATOR_HXX */
b3a87a2cd2e1e25c86ac618a20e6510662ccd22a
30681dae0ff67c25216c688c1117f77895da8080
/Ch07/ex0753.cpp
8912613f084ca1cae498e761b43b008f8b087476
[]
no_license
deng25/Cpp-Primer-5th
17b3747214cf2a66dbec6662ee3e56e27141bc85
8a6d63eda154eb34eed740fc76980b883173519b
refs/heads/master
2020-12-24T12:40:29.920775
2017-01-07T12:11:01
2017-01-07T12:11:01
72,964,690
0
0
null
null
null
null
UTF-8
C++
false
false
517
cpp
ex0753.cpp
class Debug { public: constexpr Debug(bool b = true) : _hw(b), _io(b), _other(b) { } constexpr Debug(bool hw, bool io, bool other) : _hw(hw), _io(io), _other(other) { } public: constexpr bool Any() { return _hw || _io || _other; } // ๅช่ฆๅ‡บ็Žฐไปปไฝ•ไธ€็ง้”™่ฏฏ void set_hw(bool b) { _hw = b; } void set_io(bool b) { _io = b; } void set_other(bool b) { _other = b; } private: bool _hw; // ็กฌไปถ้”™่ฏฏ bool _io; // IO้”™่ฏฏ bool _other; // ๅ…ถไป–้”™่ฏฏ };
d85244c630b7f4cf409e6a3dfaee1c91c56beafb
bd03d2c5712fe5005640569b2221ef12bad9477e
/Example/src/BoundingBox.h
b89430734f7c646d90409d7e61cd6e722efe5f63
[ "MIT" ]
permissive
13269252368/Brep
ea68450fea3f33fe1f5186f01095fde07c3a29bf
3a5b87dd1ca5bc5ab6d376feae1812547e6b0d11
refs/heads/master
2022-03-18T21:12:37.589228
2017-11-25T08:51:07
2017-11-25T08:51:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
272
h
BoundingBox.h
#ifndef _BOUNDINGBOX_H_ #define _BOUNDINGBOX_H_ #include "math/Vec3.h" class BoundingBox { public: BoundingBox() { }; BoundingBox(const Vec3& pMin, const Vec3& pMax) { this->pMin = pMin; this->pMax = pMax; } Vec3 pMin, pMax; }; #endif
f55ad8163fcafcad3cfdb224fd3c34137b9f9a49
cfb08ea75d4f4a51c7a6a0bb6098e2e8c7ee28ff
/Generators/ClockGenerator.cc
84d4330a38eaa04314cffb9fd045898465f8d84f
[]
no_license
ganlubbq/C-
9f557faa9d2e29762148d5277c50b636fdc96f59
86ef8abd142775a237f90ec13b38854b6a2c3a3a
refs/heads/master
2021-05-31T21:13:46.029059
2016-07-26T05:36:31
2016-07-26T05:36:31
108,728,692
1
0
null
2017-10-29T11:34:42
2017-10-29T11:34:42
null
UTF-8
C++
false
false
9,522
cc
ClockGenerator.cc
/******************************************************************************** * * * This class generates clock data. The default behavior is that after reset * * the clock puts out a high (1), and then a 0 after the high period (depends * * on the duty cycle. * * * * File: /User/frank/C++/Generators/ClockGenerator.h * * * * Revision History: * * 1. 10/10/00 - Started. * ********************************************************************************/ #include <stdio.h> #include "ClockGenerator.h" #ifndef YES #define YES 1 #define NO 0 #endif #define MAX(a,b) ( ((a)>(b)) ? (a) : (b) ) #define MIN(a,b) ( ((a)>(b)) ? (b) : (a) ) // ############################ Private Function ################################### // driftClockPeriod - Drift the clock high and low periods. // Input: None // Output: None // // Notes: // 1. _driftRate is given in Hertz/sec. // 2. The instance variables, _highPeriod and _lowPeriod are modified if _driftRate != 0 // 3. We should probably ensure that clock period does not drift lower than sample period. // Still need to do this. // ############################ Private Function ################################### void ClockGenerator::driftClockPeriod() { double drift_freq, freq_ratio; double old_freq, old_period; double high_freq, low_freq; // // Calculate drift for current sample period: // old_period = _highPeriod + _lowPeriod; if( (_highPeriod > 0.) && (_lowPeriod > 0.) ) { old_freq = 1./old_period; drift_freq = _driftRate*_samplePeriod; // # of Hertz of drift freq_ratio = drift_freq/old_freq; high_freq = 1./_highPeriod; // use reciprocals to avoid round off high_freq += high_freq*freq_ratio; if(high_freq > 0.) _highPeriod = 1./high_freq; low_freq = 1./_lowPeriod; // use reciprocals to avoid round off low_freq += low_freq*freq_ratio; if(low_freq > 0.) _lowPeriod = 1./low_freq; } return; } // ############################# Class Constructor ################################# // ClockGenerator -- Constructor for the ClockGenerator class // Input: period: Full cycle period of the clock in seconds // sampling: Sampling frequency in Hz // Output: None // ############################# Class Constructor ################################# ClockGenerator::ClockGenerator(double period, double samplingFreq) { // // Initialize instance variables: // setDriftRate(0.); setDutyCycle(0.5); setClockPeriod(period); setSampleFrequency(samplingFreq); setTruncateClockPeriod(YES); initClock(); return; } // ############################# Class Destructor ############################### // ClockGenerator -- Destructor for the ClockGenerator class // Input: None // Output: None // // NOTES: // 1. Deletes are done in the subclasses // ############################# Class Destructor ############################### ClockGenerator::~ClockGenerator() { return; } // ############################ Public Function ################################### // initClock - Initializes the clock generator. // Input: None // Output: None // // Notes: // ############################ Public Function ################################### void ClockGenerator::initClock() { _clockTimer = -_samplePeriod; // Makes first clock high period OK _clockValue = 1; _highPeriod = _dutyCycle*_clockPeriod; // This gets drifted _lowPeriod = _clockPeriod - _highPeriod; // This also gets drifted return; } // ############################ Public Function ################################### // setDriftRate - Sets a new clock drift rate in Hz/sec. // Input: drift: New drift in Hz/sec // Output: None // // Notes: // ############################ Public Function ################################### void ClockGenerator::setDriftRate(float drift) { _driftRate = drift; return; } // ############################ Public Function ################################### // setDutyCycle - Sets a new duty cycle in [0,1]. // Input: duty: New duty cycle as a fraction of 1 // Output: None // // Notes: // 1. A duty cycle of 0.8 will mean that the clock stays high 80% of the time. // ############################ Public Function ################################### void ClockGenerator::setDutyCycle(float duty) { _dutyCycle = MAX(MIN_DUTY, duty); _dutyCycle = MIN(MAX_DUTY, _dutyCycle); return; } // ############################ Public Function ################################### // setClockPeriod - Sets a new full cycle period in seconds. // Input: period: New full cycle period in seconds // Output: None // // Notes: // ############################ Public Function ################################### void ClockGenerator::setClockPeriod(double period) { _clockPeriod = MAX(MIN_PERIOD, period); return; } // ############################ Public Function ################################### // setClockFrequency - Sets a new clock frequency in Hertz. // Input: frequency: New clock frequency in Hertz // Output: None // // Notes: // 1. This is a convenience method for those who don't want to convert frequency to // time // ############################ Public Function ################################### void ClockGenerator::setClockFrequency(double frequency) { if(frequency > 0.) setClockPeriod(1./frequency); return; } // ############################ Public Function ################################### // setSamplePeriod - Sets the underlying sampling clock period in seconds. // Input: period: New sampling clock period in seconds // Output: None // // Notes: // 1. There is no error checking to insure that the sampling clock period is shorter // then the clock generator clock period. // ############################ Public Function ################################### void ClockGenerator::setSamplePeriod(double period) { _samplePeriod = MAX(MIN_PERIOD, period); return; } // ############################ Public Function ################################### // setSampleFrequency - Sets the underlying sampling frequency in Hertz. // Input: frequency: New sampling frequency in Hertz // Output: None // // Notes: // 1. This is a convenience method for those who don't want to convert frequency to // time // ############################ Public Function ################################### void ClockGenerator::setSampleFrequency(double frequency) { if(frequency > 0.) setSamplePeriod(1./frequency); return; } // ############################ Public Function ################################### // setTruncateClockPeriod - Sets whether or not to truncate the clock period to the // next lowest sample period. // Input: flag: If TRUE, truncate, otherwise round // Output: None // // Notes: // ############################ Public Function ################################### void ClockGenerator::setTruncateClockPeriod(LOGICAL flag) { _truncNotRound = flag; return; } // ############################ Public Function ################################### // newData - Gets a new clock output from the generator. // Input: None // Output: New clock data: 0 or 1 // // Notes: // // ############################ Public Function ################################### int ClockGenerator::newData() { // // Update the counter: // _clockTimer += _samplePeriod; // // Update the clock value based on counter: // if(_clockValue == 1) { if(_clockTimer > _highPeriod) // This works for rounded or trunc behavior { _clockTimer -= _highPeriod; // Reset timer with remainder _clockValue = 0; } else if(!_truncNotRound) // Rounded behavior { if( (_highPeriod - _clockTimer) < _samplePeriod/2.) { _clockTimer -= _highPeriod; _clockValue = 0; } } } else // Clock value == 0 { if(_clockTimer > _lowPeriod) // This works for rounded or trunc behavior { _clockTimer -= _lowPeriod; // Reset timer with remainder _clockValue = 1; } else if(!_truncNotRound) // Rounded behavior { if( (_lowPeriod - _clockTimer) < _samplePeriod/2.) { _clockTimer -= _lowPeriod; _clockValue = 1; } } } // // Update the clock period based on drift: // driftClockPeriod(); // // Return the current value of the clock: // return _clockValue; }
26e54fbf73ee12fead6fc52dd8008ee9540bfaa0
c13e0c4d183eaa3910dee9b8f2312fe290de61c5
/170911162/dslab56/PrefixEval.cpp
945ceeffbf9bd798656f1cab89d7f3eafb9f60a2
[]
no_license
JyotinderSingh/DS-Lab-Sem-III
82584d008286e349c7d581ede7ec9652dc2c27f6
5b00589e42b8d4e320c81a4bf90df74c0e668d5d
refs/heads/master
2020-04-01T02:18:25.800646
2018-11-23T21:07:56
2018-11-23T21:07:56
152,773,641
5
2
null
2018-10-23T14:07:16
2018-10-12T15:44:59
C++
UTF-8
C++
false
false
1,883
cpp
PrefixEval.cpp
//PREFIX EVAL #include<iostream> #include<math.h> #include<string.h> #include<stdio.h> #include<conio.h> #define SIZE 20 using namespace std; class eval{ private: int top; int a[20]; public: char pfix[20] , pf[20]; eval() { top=-1; } void push(int ele) { if(top==SIZE-1) cout<<"stack overflow"; else a[++top]=ele; } int pop() { if(top==-1) { cout<<"empty"; return 0; } else return a[top--]; } void read() { int l,i,j=0; cout<<"enter the prefix expression"; gets(pf); l=strlen(pf); for(i=l-1;i>=0;i--) { pfix[j++]=pf[i]; } pfix[j]='\0'; cout<<"reversed expression"; puts(pfix); } int isoperand(char z) { switch(z) { case '+': case '-': case'*': case '/': case'^': case'$': {return 0; break; } default: { return 1; break; } } } int operation(int s,char t,int r) { switch(t) { case '+': { return (s+r); break; } case'-': { return(s-r); break; } case'*': { return(s*r); break; } case '/': { return (s/r); break; } case '^': case '$': { return( pow(s,r)); break; } } } void con() { char a; int op1,op2,i; int res; for(i=0;pfix[i]!='\0';i++) { a=pfix[i]; if(isoperand(a)==1) { push(a-'0'); } else { op2=pop(); op1=pop(); res=operation(op2,a,op1); push(res); } } cout<<"prefix evaluation "<<pop(); } }; int main() { eval s; s.read(); s.con(); return 0; }
5fe34fab700f3d420fae04e53e5a9055f310238b
48ae7ba3a8de20542cebeeb7d6eb804c40e72713
/token/include/user.h
a36c5e0e59eff7fac02880eb78a5d4a487f71368
[]
no_license
rupesh-papneja/am
bdeae83fa90f05a24b6e0f4c6bc7b7ca39aa3d91
cd3774d884204fc450291e2c9f6371b9dbcc78dd
refs/heads/master
2021-08-27T20:56:02.696077
2020-02-11T13:32:22
2020-02-11T13:32:22
171,128,160
0
0
null
2021-08-13T15:32:07
2019-02-17T13:55:41
JavaScript
UTF-8
C++
false
false
384
h
user.h
#ifndef USER_H #define USER_H #ifdef _MSC_VER #pragma once #endif // _MSC_VER #include <string> namespace Service { class User { private: std::string user; std::string password; public: User(); ~User(); std::string _user(); User* _setUser(std::string); std::string _password(); User* _setPassword(std::string); std::string _json(); }; } // namespace User #endif
99a3299cfdfe3328dc3bc08291a3182ea5b43562
3f7028cc89a79582266a19acbde0d6b066a568de
/source/extensions/transport_sockets/tls/context_impl.h
8654d44e706e6e6b283d01694b1ea31254f95044
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
envoyproxy/envoy
882d3c7f316bf755889fb628bee514bb2f6f66f0
72f129d273fa32f49581db3abbaf4b62e3e3703c
refs/heads/main
2023-08-31T09:20:01.278000
2023-08-31T08:58:36
2023-08-31T08:58:36
65,214,191
21,404
4,756
Apache-2.0
2023-09-14T21:56:37
2016-08-08T15:07:24
C++
UTF-8
C++
false
false
9,242
h
context_impl.h
#pragma once #include <openssl/safestack.h> #include <array> #include <deque> #include <functional> #include <memory> #include <string> #include <vector> #include "envoy/network/transport_socket.h" #include "envoy/ssl/context.h" #include "envoy/ssl/context_config.h" #include "envoy/ssl/private_key/private_key.h" #include "envoy/ssl/ssl_socket_extended_info.h" #include "envoy/stats/scope.h" #include "envoy/stats/stats_macros.h" #include "source/common/common/matchers.h" #include "source/common/stats/symbol_table.h" #include "source/extensions/transport_sockets/tls/cert_validator/cert_validator.h" #include "source/extensions/transport_sockets/tls/context_manager_impl.h" #include "source/extensions/transport_sockets/tls/ocsp/ocsp.h" #include "source/extensions/transport_sockets/tls/stats.h" #include "absl/synchronization/mutex.h" #include "openssl/ssl.h" #include "openssl/x509v3.h" namespace Envoy { #ifndef OPENSSL_IS_BORINGSSL #error Envoy requires BoringSSL #endif namespace Extensions { namespace TransportSockets { namespace Tls { struct TlsContext { // Each certificate specified for the context has its own SSL_CTX. `SSL_CTXs` // are identical with the exception of certificate material, and can be // safely substituted via SSL_set_SSL_CTX() during the // SSL_CTX_set_select_certificate_cb() callback following ClientHello. bssl::UniquePtr<SSL_CTX> ssl_ctx_; bssl::UniquePtr<X509> cert_chain_; std::string cert_chain_file_path_; Ocsp::OcspResponseWrapperPtr ocsp_response_; bool is_ecdsa_{}; bool is_must_staple_{}; Ssl::PrivateKeyMethodProviderSharedPtr private_key_method_provider_{}; std::string getCertChainFileName() const { return cert_chain_file_path_; }; bool isCipherEnabled(uint16_t cipher_id, uint16_t client_version); Envoy::Ssl::PrivateKeyMethodProviderSharedPtr getPrivateKeyMethodProvider() { return private_key_method_provider_; } void loadCertificateChain(const std::string& data, const std::string& data_path); void loadPrivateKey(const std::string& data, const std::string& data_path, const std::string& password); void loadPkcs12(const std::string& data, const std::string& data_path, const std::string& password); void checkPrivateKey(const bssl::UniquePtr<EVP_PKEY>& pkey, const std::string& key_path); }; class ContextImpl : public virtual Envoy::Ssl::Context, protected Logger::Loggable<Logger::Id::config> { public: virtual bssl::UniquePtr<SSL> newSsl(const Network::TransportSocketOptionsConstSharedPtr& options); /** * Logs successful TLS handshake and updates stats. * @param ssl the connection to log */ void logHandshake(SSL* ssl) const; SslStats& stats() { return stats_; } /** * The global SSL-library index used for storing a pointer to the SslExtendedSocketInfo * class in the SSL instance, for retrieval in callbacks. */ static int sslExtendedSocketInfoIndex(); static int sslSocketIndex(); // Ssl::Context absl::optional<uint32_t> daysUntilFirstCertExpires() const override; Envoy::Ssl::CertificateDetailsPtr getCaCertInformation() const override; std::vector<Envoy::Ssl::CertificateDetailsPtr> getCertChainInformation() const override; absl::optional<uint64_t> secondsUntilFirstOcspResponseExpires() const override; std::vector<Ssl::PrivateKeyMethodProviderSharedPtr> getPrivateKeyMethodProviders(); // Validate cert asynchronously for a QUIC connection. ValidationResults customVerifyCertChainForQuic( STACK_OF(X509)& cert_chain, Ssl::ValidateResultCallbackPtr callback, bool is_server, const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options, const CertValidator::ExtraValidationContext& validation_context, const std::string& host_name); static void keylogCallback(const SSL* ssl, const char* line); protected: friend class ContextImplPeer; ContextImpl(Stats::Scope& scope, const Envoy::Ssl::ContextConfig& config, TimeSource& time_source); /** * The global SSL-library index used for storing a pointer to the context * in the SSL instance, for retrieval in callbacks. */ static int sslContextIndex(); // A SSL_CTX_set_custom_verify callback for asynchronous cert validation. static enum ssl_verify_result_t customVerifyCallback(SSL* ssl, uint8_t* out_alert); bool parseAndSetAlpn(const std::vector<std::string>& alpn, SSL& ssl); std::vector<uint8_t> parseAlpnProtocols(const std::string& alpn_protocols); void incCounter(const Stats::StatName name, absl::string_view value, const Stats::StatName fallback) const; // Helper function to validate cert for TCP connections asynchronously. ValidationResults customVerifyCertChain( Envoy::Ssl::SslExtendedSocketInfo* extended_socket_info, const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options, SSL* ssl); void populateServerNamesMap(TlsContext& ctx, const int pkey_id); // This is always non-empty, with the first context used for all new SSL // objects. For server contexts, once we have ClientHello, we // potentially switch to a different CertificateContext based on certificate // selection. std::vector<TlsContext> tls_contexts_; CertValidatorPtr cert_validator_; Stats::Scope& scope_; SslStats stats_; std::vector<uint8_t> parsed_alpn_protocols_; bssl::UniquePtr<X509> cert_chain_; std::string cert_chain_file_path_; TimeSource& time_source_; const unsigned tls_max_version_; mutable Stats::StatNameSetPtr stat_name_set_; const Stats::StatName unknown_ssl_cipher_; const Stats::StatName unknown_ssl_curve_; const Stats::StatName unknown_ssl_algorithm_; const Stats::StatName unknown_ssl_version_; const Stats::StatName ssl_ciphers_; const Stats::StatName ssl_versions_; const Stats::StatName ssl_curves_; const Stats::StatName ssl_sigalgs_; const Ssl::HandshakerCapabilities capabilities_; const Network::Address::IpList tls_keylog_local_; const Network::Address::IpList tls_keylog_remote_; AccessLog::AccessLogFileSharedPtr tls_keylog_file_; }; using ContextImplSharedPtr = std::shared_ptr<ContextImpl>; class ClientContextImpl : public ContextImpl, public Envoy::Ssl::ClientContext { public: ClientContextImpl(Stats::Scope& scope, const Envoy::Ssl::ClientContextConfig& config, TimeSource& time_source); bssl::UniquePtr<SSL> newSsl(const Network::TransportSocketOptionsConstSharedPtr& options) override; private: int newSessionKey(SSL_SESSION* session); const std::string server_name_indication_; const bool allow_renegotiation_; const bool enforce_rsa_key_usage_; const size_t max_session_keys_; absl::Mutex session_keys_mu_; std::deque<bssl::UniquePtr<SSL_SESSION>> session_keys_ ABSL_GUARDED_BY(session_keys_mu_); bool session_keys_single_use_{false}; }; enum class OcspStapleAction { Staple, NoStaple, Fail, ClientNotCapable }; class ServerContextImpl : public ContextImpl, public Envoy::Ssl::ServerContext { public: ServerContextImpl(Stats::Scope& scope, const Envoy::Ssl::ServerContextConfig& config, const std::vector<std::string>& server_names, TimeSource& time_source); // Select the TLS certificate context in SSL_CTX_set_select_certificate_cb() callback with // ClientHello details. This is made public for use by custom TLS extensions who want to // manually create and use this as a client hello callback. enum ssl_select_cert_result_t selectTlsContext(const SSL_CLIENT_HELLO* ssl_client_hello); private: // Currently, at most one certificate of a given key type may be specified for each exact // server name or wildcard domain name. using PkeyTypesMap = absl::flat_hash_map<int, std::reference_wrapper<TlsContext>>; // Both exact server names and wildcard domains are part of the same map, in which wildcard // domains are prefixed with "." (i.e. ".example.com" for "*.example.com") to differentiate // between exact and wildcard entries. using ServerNamesMap = absl::flat_hash_map<std::string, PkeyTypesMap>; void populateServerNamesMap(TlsContext& ctx, const int pkey_id); using SessionContextID = std::array<uint8_t, SSL_MAX_SSL_SESSION_ID_LENGTH>; int alpnSelectCallback(const unsigned char** out, unsigned char* outlen, const unsigned char* in, unsigned int inlen); int sessionTicketProcess(SSL* ssl, uint8_t* key_name, uint8_t* iv, EVP_CIPHER_CTX* ctx, HMAC_CTX* hmac_ctx, int encrypt); bool isClientEcdsaCapable(const SSL_CLIENT_HELLO* ssl_client_hello); bool isClientOcspCapable(const SSL_CLIENT_HELLO* ssl_client_hello); OcspStapleAction ocspStapleAction(const TlsContext& ctx, bool client_ocsp_capable); SessionContextID generateHashForSessionContextId(const std::vector<std::string>& server_names); const std::vector<Envoy::Ssl::ServerContextConfig::SessionTicketKey> session_ticket_keys_; const Ssl::ServerContextConfig::OcspStaplePolicy ocsp_staple_policy_; ServerNamesMap server_names_map_; bool has_rsa_; bool full_scan_certs_on_sni_mismatch_; }; } // namespace Tls } // namespace TransportSockets } // namespace Extensions } // namespace Envoy
3b237cd5dff220393e53991249f48112a11125ed
560b4adabd602cc8177dce8db16d6cf27c6b9798
/Samples/Server/NativeServer.Tests/PeerConductorTests.cpp
afd50b88b3437d6dae15a1619b91b5489e12f4e5
[ "MIT" ]
permissive
NateQI/3DStreamingToolkit
39969b83de91ab238a692fdd5cfecae9192f1d80
f1d205bb4c036e4fbf3c49e3373eced6d514953c
refs/heads/master
2021-03-08T06:30:12.548708
2020-02-22T06:07:16
2020-02-22T06:07:16
246,326,461
1
0
MIT
2020-03-10T14:41:58
2020-03-10T14:41:57
null
UTF-8
C++
false
false
15,615
cpp
PeerConductorTests.cpp
#include <gtest\gtest.h> #include <gmock\gmock.h> #include "peer_conductor.h" #include "multi_peer_conductor.h" using namespace ::testing; class PeerConductorFixture : public PeerConductor { public: PeerConductorFixture(scoped_refptr<PeerConnectionFactoryInterface> peer_factory) : PeerConductorFixture(-1, "", make_shared<WebRTCConfig>(), peer_factory, [](const std::string&) {}) { } PeerConductorFixture(scoped_refptr<PeerConnectionFactoryInterface> peer_factory, const function<void(const string&)>& send_func) : PeerConductorFixture(-1, "", make_shared<WebRTCConfig>(), peer_factory, send_func) { } PeerConductorFixture(int id, const string& name, shared_ptr<WebRTCConfig> webrtc_config, scoped_refptr<PeerConnectionFactoryInterface> peer_factory, const function<void(const string&)>& send_func) : PeerConductor(id, name, webrtc_config, peer_factory, send_func) { } void Test_SetPeerConnection(rtc::scoped_refptr<webrtc::PeerConnectionInterface> pc) { peer_connection_ = pc; } MOCK_METHOD0(AllocateVideoCapturer, unique_ptr<cricket::VideoCapturer>()); }; class VideoCapturerFixture : public cricket::VideoCapturer { public: MOCK_METHOD1(Start, cricket::CaptureState(const cricket::VideoFormat&)); MOCK_METHOD0(Stop, void()); MOCK_METHOD0(IsRunning, bool()); MOCK_CONST_METHOD0(IsScreencast, bool()); MOCK_METHOD1(GetPreferredFourccs, bool(std::vector<uint32_t>*)); }; class MultiPeerConductorFixture : public MultiPeerConductor { public: // internal peer conductor fixture to always return true for IsConnected class IntPeerConductorFixture : public PeerConductorFixture { public: IntPeerConductorFixture(scoped_refptr<PeerConnectionFactoryInterface> peer_factory) : PeerConductorFixture(peer_factory) { } virtual const bool IsConnected() const override { return true; } }; MultiPeerConductorFixture(scoped_refptr<PeerConnectionFactoryInterface> peer_factory) : MultiPeerConductor(make_shared<FullServerConfigFixture>(), peer_factory) { } virtual void OnMessage(rtc::Message*) override {} virtual scoped_refptr<PeerConductor> SafeAllocatePeerMapEntry(int peer_id) override { // use an int fixture so that IsConnected can be truthy auto intFixture = new RefCountedObject<IntPeerConductorFixture>(peer_factory_); // mirror the workload of storing in peers connected_peers_[peer_id] = intFixture; // fire the counter hook so we can validate calls SafeAllocatePeerMapEntry_Counter(); return connected_peers_[peer_id]; } MOCK_METHOD0(SafeAllocatePeerMapEntry_Counter, void()); private: struct FullServerConfigFixture : public FullServerConfig { FullServerConfigFixture() { server_config = make_shared<ServerConfig>(); webrtc_config = make_shared<WebRTCConfig>(); } }; }; class PeerConnectionFactoryInterfaceFixture : public PeerConnectionFactoryInterface { public: MOCK_METHOD1(SetOptions, void(const PeerConnectionFactoryInterface::Options&)); // see https://stackoverflow.com/questions/7616475/can-google-mock-a-method-with-a-smart-pointer-return-type // to understand this mocking pattern and why it's a requirement here virtual scoped_refptr<PeerConnectionInterface> CreatePeerConnection( const PeerConnectionInterface::RTCConfiguration& configuration, std::unique_ptr<cricket::PortAllocator> allocator, std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, PeerConnectionObserver* observer) { return CreatePeerConnection_RawPtr(configuration, allocator.get(), cert_generator.get(), observer); } MOCK_METHOD4(CreatePeerConnection_RawPtr, rtc::scoped_refptr<PeerConnectionInterface>( const PeerConnectionInterface::RTCConfiguration&, cricket::PortAllocator*, rtc::RTCCertificateGeneratorInterface*, PeerConnectionObserver*)); virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( const PeerConnectionInterface::RTCConfiguration& configuration, const MediaConstraintsInterface* constraints, std::unique_ptr<cricket::PortAllocator> allocator, std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, PeerConnectionObserver* observer) { return CreatePeerConnection_RawPtr(configuration, constraints, allocator.get(), cert_generator.get(), observer); } MOCK_METHOD5(CreatePeerConnection_RawPtr, rtc::scoped_refptr<PeerConnectionInterface>( const PeerConnectionInterface::RTCConfiguration&, const MediaConstraintsInterface*, cricket::PortAllocator*, rtc::RTCCertificateGeneratorInterface*, PeerConnectionObserver*)); virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource( std::unique_ptr<cricket::VideoCapturer> capturer, const MediaConstraintsInterface* constraints) { return CreateVideoSource_RawPtr(capturer.get(), constraints); } MOCK_METHOD2(CreateVideoSource_RawPtr, rtc::scoped_refptr<VideoTrackSourceInterface>( cricket::VideoCapturer*, const MediaConstraintsInterface*)); MOCK_METHOD1(CreateLocalMediaStream, rtc::scoped_refptr<MediaStreamInterface>(const std::string&)); MOCK_METHOD1(CreateAudioSource, rtc::scoped_refptr<AudioSourceInterface>(const cricket::AudioOptions&)); MOCK_METHOD1(CreateAudioSource, rtc::scoped_refptr<AudioSourceInterface>(const MediaConstraintsInterface*)); MOCK_METHOD2(CreateVideoTrack, rtc::scoped_refptr<VideoTrackInterface>(const std::string&, VideoTrackSourceInterface*)); MOCK_METHOD2(CreateAudioTrack, rtc::scoped_refptr<AudioTrackInterface>(const std::string&, AudioSourceInterface*)); MOCK_METHOD2(StartAecDump, bool(rtc::PlatformFile, int64_t)); MOCK_METHOD0(StopAecDump, void()); MOCK_METHOD2(StartRtcEventLog, bool(rtc::PlatformFile, int64_t)); MOCK_METHOD1(StartRtcEventLog, bool(rtc::PlatformFile)); MOCK_METHOD0(StopRtcEventLog, void()); }; class PeerConnectionInterfaceFixture : public PeerConnectionInterface { public: MOCK_METHOD0(local_streams, rtc::scoped_refptr<webrtc::StreamCollectionInterface>()); MOCK_METHOD0(remote_streams, rtc::scoped_refptr<webrtc::StreamCollectionInterface>()); MOCK_METHOD1(AddStream, bool(webrtc::MediaStreamInterface*)); MOCK_METHOD1(RemoveStream, void(webrtc::MediaStreamInterface*)); MOCK_METHOD2(AddTrack, rtc::scoped_refptr<webrtc::RtpSenderInterface>( webrtc::MediaStreamTrackInterface*, std::vector<webrtc::MediaStreamInterface*>)); MOCK_METHOD1(RemoveTrack, bool(webrtc::RtpSenderInterface*)); MOCK_METHOD1(CreateDtmfSender, rtc::scoped_refptr<webrtc::DtmfSenderInterface>( webrtc::AudioTrackInterface*)); MOCK_METHOD3(GetStats, bool(webrtc::StatsObserver*, webrtc::MediaStreamTrackInterface*, webrtc::PeerConnectionInterface::StatsOutputLevel)); MOCK_METHOD2(CreateDataChannel, rtc::scoped_refptr<webrtc::DataChannelInterface>( const std::string&, const webrtc::DataChannelInit*)); MOCK_CONST_METHOD0(local_description, webrtc::SessionDescriptionInterface*()); MOCK_CONST_METHOD0(remote_description, webrtc::SessionDescriptionInterface*()); MOCK_METHOD2(SetLocalDescription, void(webrtc::SetSessionDescriptionObserver*, webrtc::SessionDescriptionInterface* desc)); MOCK_METHOD2(SetRemoteDescription, void(webrtc::SetSessionDescriptionObserver*, webrtc::SessionDescriptionInterface*)); MOCK_METHOD1(AddIceCandidate, bool(const webrtc::IceCandidateInterface*)); MOCK_METHOD1(RegisterUMAObserver, void(webrtc::UMAObserver*)); MOCK_METHOD1(SetBitrate, webrtc::RTCError( const webrtc::PeerConnectionInterface::BitrateParameters&)); MOCK_METHOD0(signaling_state, webrtc::PeerConnectionInterface::SignalingState()); MOCK_METHOD0(ice_connection_state, webrtc::PeerConnectionInterface::IceConnectionState()); MOCK_METHOD0(ice_gathering_state, webrtc::PeerConnectionInterface::IceGatheringState()); MOCK_METHOD0(Close, void()); MOCK_METHOD2(CreateAnswer, void(webrtc::CreateSessionDescriptionObserver*, const webrtc::MediaConstraintsInterface*)); }; class SessionDescriptionInterfaceFixture : public SessionDescriptionInterface { public: MOCK_METHOD0(description, cricket::SessionDescription*()); MOCK_CONST_METHOD0(description, cricket::SessionDescription*()); MOCK_CONST_METHOD0(session_id, std::string()); MOCK_CONST_METHOD0(session_version, std::string()); MOCK_CONST_METHOD0(type, std::string()); MOCK_METHOD1(AddCandidate, bool(const IceCandidateInterface*)); MOCK_METHOD1(RemoveCandidates, size_t(const std::vector<cricket::Candidate>&)); MOCK_CONST_METHOD0(number_of_mediasections, size_t()); MOCK_CONST_METHOD1(candidates, IceCandidateCollection*(size_t)); MOCK_CONST_METHOD1(ToString, bool(std::string*)); }; class IceCandidateInterfaceFixture : public IceCandidateInterface { public: MOCK_CONST_METHOD0(sdp_mid, std::string()); MOCK_CONST_METHOD0(sdp_mline_index, int()); MOCK_CONST_METHOD0(candidate, cricket::Candidate&()); MOCK_CONST_METHOD0(server_url, std::string()); MOCK_CONST_METHOD1(ToString, bool(std::string*)); }; class MediaStreamInterfaceFixture : public MediaStreamInterface { public: MOCK_CONST_METHOD0(label, std::string()); MOCK_METHOD0(GetAudioTracks, AudioTrackVector()); MOCK_METHOD0(GetVideoTracks, VideoTrackVector()); MOCK_METHOD1(FindAudioTrack, rtc::scoped_refptr<AudioTrackInterface> (const std::string&)); MOCK_METHOD1(FindVideoTrack, rtc::scoped_refptr<VideoTrackInterface> (const std::string&)); MOCK_METHOD1(AddTrack, bool(webrtc::AudioTrackInterface*)); MOCK_METHOD1(AddTrack, bool(webrtc::VideoTrackInterface*)); MOCK_METHOD1(RemoveTrack, bool(webrtc::AudioTrackInterface*)); MOCK_METHOD1(RemoveTrack, bool(webrtc::VideoTrackInterface*)); MOCK_METHOD1(RegisterObserver, void(ObserverInterface*)); MOCK_METHOD1(UnregisterObserver, void(ObserverInterface*)); }; TEST(PeerConductorTests, PeerConductor_Alloc_Success) { auto factoryFixture = new rtc::RefCountedObject<PeerConnectionFactoryInterfaceFixture>(); auto streamFixture = new rtc::RefCountedObject<MediaStreamInterfaceFixture>(); auto connFixture = new rtc::RefCountedObject<PeerConnectionInterfaceFixture>(); auto fixture = new rtc::RefCountedObject<PeerConductorFixture>(factoryFixture); // the following is the underlying allocation flow, mocked, and in order { InSequence seq; EXPECT_CALL(*factoryFixture, CreatePeerConnection_RawPtr(_, _, _, _, _)) .Times(Exactly(1)) .WillOnce(Invoke([&](const PeerConnectionInterface::RTCConfiguration& configuration, const webrtc::MediaConstraintsInterface* constraints, cricket::PortAllocator* allocator, rtc::RTCCertificateGeneratorInterface* cert_generator, PeerConnectionObserver* observer) { return connFixture; })); EXPECT_CALL(*fixture, AllocateVideoCapturer()) .Times(Exactly(1)); EXPECT_CALL(*factoryFixture, CreateVideoSource_RawPtr(_, _)) .Times(Exactly(1)); EXPECT_CALL(*factoryFixture, CreateVideoTrack(_, _)) .Times(Exactly(1)); EXPECT_CALL(*factoryFixture, CreateLocalMediaStream(_)) .WillOnce(Invoke([&](std::string) { return streamFixture; })); EXPECT_CALL(*streamFixture, AddTrack(A<webrtc::VideoTrackInterface*>())) .Times(Exactly(1)); EXPECT_CALL(*connFixture, AddStream(A<webrtc::MediaStreamInterface*>())) .Times(Exactly(1)); } // alloc a conn fixture->AllocatePeerConnection(); // assert that the conn is now there ASSERT_EQ(fixture->Streams().size(), 1); } TEST(PeerConductorTests, PeerConductor_SDPGeneration_Success) { auto expectedContents = std::string("test message contents"); auto expectedSdp = "{\n \"password\" : \"\",\n \"sdp\" : \"" + expectedContents + "\",\n \"type\" : \"\",\n \"uri\" : \"\",\n \"username\" : \"\"\n}\n"; auto wasSendFuncCalled = false; auto mockSendFunc = [&](const std::string& message) { wasSendFuncCalled = true; ASSERT_STREQ(message.c_str(), expectedSdp.c_str()); }; auto factoryFixture = new rtc::RefCountedObject<PeerConnectionFactoryInterfaceFixture>(); auto connFixture = new rtc::RefCountedObject<PeerConnectionInterfaceFixture>(); auto fixture = new rtc::RefCountedObject<PeerConductorFixture>(factoryFixture, mockSendFunc); fixture->Test_SetPeerConnection(connFixture); SessionDescriptionInterfaceFixture sdp; EXPECT_CALL(sdp, ToString(_)) .Times(Exactly(1)) .WillOnce(Invoke([&](std::string* s) { s->assign(expectedContents); return true; })); // generates sdp offer fixture->OnSuccess(&sdp); // can assert sendfunc success ASSERT_TRUE(wasSendFuncCalled); } TEST(PeerConductorTests, PeerConductor_ICEGeneration_Success) { auto expectedContents = std::string("test message contents"); auto expectedIce = "{\n \"candidate\" : \"" + expectedContents + "\",\n \"sdpMLineIndex\" : 0,\n \"sdpMid\" : \"\"\n}\n"; auto wasSendFuncCalled = false; auto mockSendFunc = [&](const std::string& message) { wasSendFuncCalled = true; ASSERT_STREQ(message.c_str(), expectedIce.c_str()); }; auto factoryFixture = new rtc::RefCountedObject<PeerConnectionFactoryInterfaceFixture>(); auto fixture = new rtc::RefCountedObject<PeerConductorFixture>(factoryFixture, mockSendFunc); IceCandidateInterfaceFixture ice; EXPECT_CALL(ice, ToString(_)) .Times(Exactly(1)) .WillOnce(Invoke([&](std::string* s) { s->assign(expectedContents); return true; })); // generates ice candidate msg fixture->OnIceCandidate(&ice); // can assert sendfunc success ASSERT_TRUE(wasSendFuncCalled); } TEST(PeerConductorTests, PeerConductor_HandleMessage_Success) { auto expectedContents = std::string("candidate:4029998969 1 udp 41361151 40.69.184.50 50017 typ relay raddr 0.0.0.0 rport 0 generation 0 ufrag fKSq network-id 1 network-cost 50"); auto expectedIce = "{\n \"candidate\" : \"" + expectedContents + "\",\n \"sdpMLineIndex\" : 0,\n \"sdpMid\" : \"\"\n}\n"; auto factoryFixture = new rtc::RefCountedObject<PeerConnectionFactoryInterfaceFixture>(); auto connFixture = new rtc::RefCountedObject<PeerConnectionInterfaceFixture>(); auto fixture = new rtc::RefCountedObject<PeerConductorFixture>(factoryFixture); fixture->Test_SetPeerConnection(connFixture); EXPECT_CALL(*connFixture, AddIceCandidate(_)) .Times(Exactly(1)) .WillOnce(Return(true)); // simulate handing msg ASSERT_TRUE(fixture->HandlePeerMessage(expectedIce)); } TEST(PeerConductorTests, PeerConductor_HandleMessage_CreateOffer) { auto expectedContents = std::string("v=0\no=- 4489647023841143573 2 IN IP4 127.0.0.1\ns=-\nt=0 0\n"); auto expectedIce = "{\n \"sdp\" : \"" + expectedContents + "\",\n \"type\" : \"offer\",\n \"sdpMid\" : \"\"\n}\n"; auto factoryFixture = new rtc::RefCountedObject<PeerConnectionFactoryInterfaceFixture>(); auto connFixture = new rtc::RefCountedObject<PeerConnectionInterfaceFixture>(); auto fixture = new rtc::RefCountedObject<PeerConductorFixture>(factoryFixture); fixture->Test_SetPeerConnection(connFixture); EXPECT_CALL(*connFixture, SetRemoteDescription(_, _)) .Times(Exactly(1)); EXPECT_CALL(*connFixture, CreateAnswer(_, _)) .Times(Exactly(1)); // simulate handing msg ASSERT_TRUE(fixture->HandlePeerMessage(expectedIce)); } TEST(PeerConductorTests, PeerConductor_MultiPeer_Alloc_Success) { auto factoryFixture = new rtc::RefCountedObject<PeerConnectionFactoryInterfaceFixture>(); auto condFixture = new rtc::RefCountedObject<PeerConductorFixture>(factoryFixture); auto connFixture = new rtc::RefCountedObject<PeerConnectionInterfaceFixture>(); auto fixture = new rtc::RefCountedObject<MultiPeerConductorFixture>(factoryFixture); condFixture->Test_SetPeerConnection(connFixture); EXPECT_CALL(*fixture, SafeAllocatePeerMapEntry_Counter()) .Times(Exactly(3)); fixture->ConnectToPeer(0); fixture->ConnectToPeer(1); fixture->ConnectToPeer(2); ASSERT_EQ(fixture->Peers().size(), 3); }
5ddb4280de046437675b6ed75b26cb06ff39c083
46180125263f4f935a8fcf68084036d5aaa219e1
/~QuadSerial.h
83ba58e5dc2552d4102c7fbbac5f67c16a97a08d
[]
no_license
RBDLAB/Drones-Mission-Control
666dd420c2ae46abfd4268c0108915c01b90f8d3
f68714915b0dd0f2eabcbbaccfcde715e3e57833
refs/heads/master
2021-01-19T15:21:30.214140
2017-08-20T21:57:20
2017-08-20T21:57:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,038
h
~QuadSerial.h
#pragma once #include <string> #include <stdio.h> // Standard input/output definitions #include <stdlib.h> #include <string.h> // String function definitions //#include <unistd.h> // for usleep() //#include <getopt.h> #include <fcntl.h> // File control definitions #include <errno.h> // Error number definitions //#include <termios.h> // POSIX terminal control definitions //#include <sys/ioctl.h> #include <iostream> //#include "arduino-serial-lib.h" #include "SerialClass.h" #include "Serial.h" #define ASCII_MODE 1 #define BINARY_MODE 2 #define NO_ARDUINO_MODE 3 #define CHANNEL_MIN 1000 #define CHANNEL_MAX 2000 #define CHANNEL_ARDUINO_MIN 0 #define CHANNEL_ARDUINO_MAX 128 #define START_BIT 255 using namespace std; const float CHANNEL_RANGE = CHANNEL_MAX - CHANNEL_MIN; const float CHANNEL_ARDUINO_RANGE = CHANNEL_ARDUINO_MAX - CHANNEL_ARDUINO_MIN; const float RANGES_RATIO = CHANNEL_ARDUINO_RANGE / CHANNEL_RANGE; class QuadSerial{ public: char* portNo; int mode; char terminator; int timeout; int inputBufferSize; string readAsyncMode; int dataBits; string parity; string flowControl; int stopBits; int baudRate; int serialFD; //Serial serial; SRL::Serial* serial2; bool result; char *data; QuadSerial( ) : portNo("COM1") , mode(BINARY_MODE) , terminator(0) , timeout(10) , inputBufferSize(1000) , readAsyncMode("manual") , dataBits(8) , parity("none") , flowControl("none") , stopBits(1) , baudRate(115200) , serialFD(0), data(new char[30]) {} //QuadSerial(char* port) : mode(BINARY_MODE), terminator(0), timeout(10), inputBufferSize(1000) // , readAsyncMode("manual"), dataBits(8), parity("none"), flowControl("none"), stopBits(1), baudRate(115200), serialFD(0), data(new char[30]), serial() //{ // result = false; // portNo = port; //} //QuadSerial() : portNo("COM1"), mode(BINARY_MODE), terminator(0), timeout(10), inputBufferSize(1000) // , readAsyncMode("manual"), dataBits(8), parity("none"), flowControl("none"), stopBits(1), baudRate(115200), serialFD(0), data(new char[30]), serial() {} ~QuadSerial() { delete data; } unsigned char symaBuffer[8]; unsigned char dummyBuffer[1024]; void convertRange( float oldVal[4] ){ for (int i = 0; i < 4; ++i){ oldVal[i] = ((oldVal[i] - CHANNEL_MIN) * RANGES_RATIO ) + CHANNEL_ARDUINO_MIN; } } void setMode(int _mode) { mode = _mode; } void setPort(char* com) { portNo = com; } void open(){ if ( serialFD != 0 ){ close(); } //serialFD = serialport_init( portNo , baudRate ); //cout << "serialFD: " << serialFD << endl; //result = serial.Open(portNo); int binary = 1; int iparity = NOPARITY; int flowc = RTS_CONTROL_DISABLE; serial2 = new SRL::Serial(portNo, iparity, dataBits, flowc, stopBits, inputBufferSize, binary, timeout, readAsyncMode.compare("manual"), baudRate); } void close(){ // serial.Close(); delete serial2; } //void closeAll(); void flush(){ cout << "not available"; //if ( serialFD != 0 ) // serialport_flush(serialFD); } void writeSyma(float toSend[4], bool picture, bool video); void write( float toSend[4] ){ //if ( serialFD == 0 ) //{ // cout << "exiting because serialFD == 0"; // return; //} int len; switch( mode ){ case BINARY_MODE: //cout << "trying to print binary" << endl; len = sprintf(data, "%c%c%c%c%c", START_BIT, (char)toSend[0], (char)toSend[1], (char)toSend[2], (char)toSend[3]); break; case ASCII_MODE: cout << "trying to print ascii" << endl; len = sprintf( data , "input: %f,%f,%f,%f\n" , toSend[0] , toSend[1] , toSend[2] , toSend[3] ); break; default: printf("Error writing data to Arduino"); break; } if ( data != 0 ) { //serial.WriteData(data, len); serial2->write(data, len); } else cout << "data = 0" << endl; } void writeLadyBird( float data[4] ){ convertRange( data ); write( data ); } void test(){ float data[4] = { 1000.0 , 1200.0 , 1500.0 , 2000.0 }; open(); writeLadyBird( data ); close(); } };
6d6ebb1f7d1913b407794f45b9c0829b4fca1ff5
614271c1d726a4f51bf47b8d163e84a19c52acd0
/driver/driver.cpp
6f2e714fc5cb8fafefc2f6e9b5eebcd5495a74cd
[]
no_license
VadimSokolov/polaris_io
8edfa901b6e30072ab0ec4439eb3e6ab3f357ab1
a67e2fe4f59166033937afa0cc9f572d4adf150a
refs/heads/master
2020-04-15T04:14:42.407555
2013-02-27T00:32:04
2013-02-27T00:32:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,960
cpp
driver.cpp
#include <memory> // std::auto_ptr #include <odb/database.hxx> #include <odb/transaction.hxx> #include "database.h" // create_database #include "InputContext.h" #include "InputContext-odb.hxx" #include <time.h> #include <iostream> #include <fstream> using namespace std; using namespace odb::core; using namespace pio; //using odb::database; //using odb::transaction; // typedef odb::query<Node> node_query; typedef odb::result<Node> node_result; __int64 AddGeoColumn(string table_name, string geo_type, string epsg, auto_ptr<database> db) { char buff[500]; __int64 ret; char *err_msg = NULL; sprintf_s(buff, "SELECT AddGeometryColumn ( '%s', 'GEO', %s, '%s', 2 );", table_name.c_str(), epsg.c_str(), geo_type.c_str()); connection_ptr c (db->connection ()); ret = c->execute(buff); sprintf_s(buff, "lalal hahah ( '%s', 'GEO', %s, '%s', 2 );", table_name.c_str(), epsg.c_str(), geo_type.c_str()); if (ret != SQLITE_OK) { fprintf (stderr, "AddGeometryColumn error: %s\n", err_msg); return ret; } return SQLITE_OK; } static int callback(void *NotUsed, int n_columns, char **columns, char **column_names) { int id; id = atoi(columns[0]); if (id % 100000 == 0) printf("%s = %d\n", column_names[0], atoi(columns[0])); return 0; } static void profile_callback(void *log_file, const char* content, sqlite3_uint64 wall_time) { ofstream *fh = new ofstream(); fh = reinterpret_cast<ofstream*>(log_file); *fh << content << "\n"; *fh << "Wall time is (in sec): " << wall_time/1000000000 << "\n"; } static void trace_callback(void *log_file, const char* content) { ofstream *fh = new ofstream(); fh = reinterpret_cast<ofstream*>(log_file); *fh << content << "\n"; } int TestReadTripsSQL(string path_to_database) { sqlite3* db_handler; int ret; string sql; char *err_msg = NULL; ret = sqlite3_open(path_to_database.c_str(), &db_handler); sql = "select * from Trip"; clock_t now = clock(); ret = sqlite3_exec(db_handler, sql.c_str(), callback, 0, &err_msg); clock_t later = clock(); printf("%.3f trip table access (raw sql)\n",(double)(later-now)/(double)CLOCKS_PER_SEC); return 0; } template<class TripClass> int TestReadTrips(string path_to_database) { typedef odb::query<TripClass> query; typedef odb::result<TripClass> result; //int a,b, c, dest, origin; int a; int res; ofstream fh, fh1; fh.open("sql_trace.txt"); fh1.open("sql_profile.txt"); a = 0; Trip trip; auto_ptr<database> db (open_sqlite_database (path_to_database)); //sqlite3* db_handle = ((odb::sqlite::database*)db.get())->connection()->handle(); //sqlite3_profile(db_handle,profile_callback, fh1); //sqlite3_trace(db_handle,trace_callback, fh); transaction t (db->begin ()); result r(db->query<TripClass> (query::true_expr, true)); clock_t now = clock(); for (result::iterator it (r.begin()); it!=r.end(); ++it) { a++; res = it->getAuto_id(); //it.load(); //res = it.id(); if (a % 100000 ==0) cout << a << "\n"; } clock_t later = clock(); printf("%.3f trip table access\n",(double)(later-now)/(double)CLOCKS_PER_SEC); t.commit(); fh.close(); fh1.close(); cout << "OK\n"; return 0; } void test_location() { auto_ptr<database> db (open_sqlite_database ("C:\\Users\\vsokolov\\usr\\polaris_io\\Transims2Polaris\\chicago_with_demand.sqlite")); typedef odb::query<pio::Location> query; typedef odb::result<pio::Location> result; transaction t (db->begin ()); result r(db->query<pio::Location> (query::location==82434, true)); shared_ptr<pio::Link> l = r.begin()->getLink(); } int main (int argc, char *argv []) { //TestReadTrips<Trip>("C:\\Users\\vsokolov\\usr\\polaris_io\\Transims2Polaris\\TestNet50.sqlite"); //TestReadTrips<TripNoRef>("C:\\Users\\vsokolov\\usr\\polaris_io\\Transims2Polaris\\chicago_with_demand.sqlite"); //TestReadTripsSQL("C:\\Users\\vsokolov\\usr\\polaris_io\\Transims2Polaris\\chicago_with_demand.sqlite"); test_location(); cout << "Press any key...\n"; getchar(); return 0; }
4e96f603d620a703a673861585982eb327c9c31f
3f4fda02e838f6f1f412625e849950ec372f251c
/src/uml/src_gen/uml/impl/CallEventImpl.cpp
8cdb06d9d2559089ee96560e6540e1d20be1cbfb
[ "MIT", "EPL-1.0" ]
permissive
MichaelBranz/MDE4CPP
692a2f124d3078d6f328532616e4a28e024b1903
5b918850a37e9cee54f6c3b92f381b0458451724
refs/heads/master
2020-06-11T06:35:28.102220
2019-05-16T10:55:30
2019-05-16T10:55:30
193,877,716
0
0
MIT
2019-06-26T09:54:32
2019-06-26T09:54:31
null
UTF-8
C++
false
false
11,168
cpp
CallEventImpl.cpp
#include "uml/impl/CallEventImpl.hpp" #ifdef NDEBUG #define DEBUG_MESSAGE(a) /**/ #else #define DEBUG_MESSAGE(a) a #endif #ifdef ACTIVITY_DEBUG_ON #define ACT_DEBUG(a) a #else #define ACT_DEBUG(a) /**/ #endif //#include "util/ProfileCallCount.hpp" #include <cassert> #include <iostream> #include <sstream> #include "abstractDataTypes/Bag.hpp" #include "abstractDataTypes/Subset.hpp" #include "abstractDataTypes/SubsetUnion.hpp" #include "abstractDataTypes/Union.hpp" #include "abstractDataTypes/SubsetUnion.hpp" #include "ecore/EAnnotation.hpp" #include "ecore/EClass.hpp" #include "uml/impl/UmlPackageImpl.hpp" //Forward declaration includes #include "persistence/interfaces/XLoadHandler.hpp" // used for Persistence #include "persistence/interfaces/XSaveHandler.hpp" // used for Persistence #include "uml/UmlFactory.hpp" #include "uml/UmlPackage.hpp" #include <exception> // used in Persistence #include "uml/Comment.hpp" #include "uml/Dependency.hpp" #include "ecore/EAnnotation.hpp" #include "uml/Element.hpp" #include "uml/MessageEvent.hpp" #include "uml/Namespace.hpp" #include "uml/Operation.hpp" #include "uml/Package.hpp" #include "uml/StringExpression.hpp" #include "uml/TemplateParameter.hpp" #include "ecore/EcorePackage.hpp" #include "ecore/EcoreFactory.hpp" #include "uml/UmlPackage.hpp" #include "uml/UmlFactory.hpp" #include "ecore/EAttribute.hpp" #include "ecore/EStructuralFeature.hpp" using namespace uml; //********************************* // Constructor / Destructor //********************************* CallEventImpl::CallEventImpl() { //********************************* // Attribute Members //********************************* //********************************* // Reference Members //********************************* //References //Init references } CallEventImpl::~CallEventImpl() { #ifdef SHOW_DELETION std::cout << "-------------------------------------------------------------------------------------------------\r\ndelete CallEvent "<< this << "\r\n------------------------------------------------------------------------ " << std::endl; #endif } //Additional constructor for the containments back reference CallEventImpl::CallEventImpl(std::weak_ptr<uml::Namespace > par_namespace) :CallEventImpl() { m_namespace = par_namespace; m_owner = par_namespace; } //Additional constructor for the containments back reference CallEventImpl::CallEventImpl(std::weak_ptr<uml::Element > par_owner) :CallEventImpl() { m_owner = par_owner; } //Additional constructor for the containments back reference CallEventImpl::CallEventImpl(std::weak_ptr<uml::Package > par_owningPackage) :CallEventImpl() { m_owningPackage = par_owningPackage; m_namespace = par_owningPackage; } //Additional constructor for the containments back reference CallEventImpl::CallEventImpl(std::weak_ptr<uml::TemplateParameter > par_owningTemplateParameter) :CallEventImpl() { m_owningTemplateParameter = par_owningTemplateParameter; m_owner = par_owningTemplateParameter; } CallEventImpl::CallEventImpl(const CallEventImpl & obj):CallEventImpl() { //create copy of all Attributes #ifdef SHOW_COPIES std::cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\ncopy CallEvent "<< this << "\r\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ " << std::endl; #endif m_name = obj.getName(); m_qualifiedName = obj.getQualifiedName(); m_visibility = obj.getVisibility(); //copy references with no containment (soft copy) std::shared_ptr<Bag<uml::Dependency>> _clientDependency = obj.getClientDependency(); m_clientDependency.reset(new Bag<uml::Dependency>(*(obj.getClientDependency().get()))); m_namespace = obj.getNamespace(); m_operation = obj.getOperation(); m_owner = obj.getOwner(); m_owningPackage = obj.getOwningPackage(); m_owningTemplateParameter = obj.getOwningTemplateParameter(); m_templateParameter = obj.getTemplateParameter(); //Clone references with containment (deep copy) std::shared_ptr<Bag<ecore::EAnnotation>> _eAnnotationsList = obj.getEAnnotations(); for(std::shared_ptr<ecore::EAnnotation> _eAnnotations : *_eAnnotationsList) { this->getEAnnotations()->add(std::shared_ptr<ecore::EAnnotation>(std::dynamic_pointer_cast<ecore::EAnnotation>(_eAnnotations->copy()))); } #ifdef SHOW_SUBSET_UNION std::cout << "Copying the Subset: " << "m_eAnnotations" << std::endl; #endif if(obj.getNameExpression()!=nullptr) { m_nameExpression = std::dynamic_pointer_cast<uml::StringExpression>(obj.getNameExpression()->copy()); } #ifdef SHOW_SUBSET_UNION std::cout << "Copying the Subset: " << "m_nameExpression" << std::endl; #endif std::shared_ptr<Bag<uml::Comment>> _ownedCommentList = obj.getOwnedComment(); for(std::shared_ptr<uml::Comment> _ownedComment : *_ownedCommentList) { this->getOwnedComment()->add(std::shared_ptr<uml::Comment>(std::dynamic_pointer_cast<uml::Comment>(_ownedComment->copy()))); } #ifdef SHOW_SUBSET_UNION std::cout << "Copying the Subset: " << "m_ownedComment" << std::endl; #endif } std::shared_ptr<ecore::EObject> CallEventImpl::copy() const { std::shared_ptr<CallEventImpl> element(new CallEventImpl(*this)); element->setThisCallEventPtr(element); return element; } std::shared_ptr<ecore::EClass> CallEventImpl::eStaticClass() const { return UmlPackageImpl::eInstance()->getCallEvent_EClass(); } //********************************* // Attribute Setter Getter //********************************* //********************************* // Operations //********************************* //********************************* // References //********************************* std::shared_ptr<uml::Operation > CallEventImpl::getOperation() const { //assert(m_operation); return m_operation; } void CallEventImpl::setOperation(std::shared_ptr<uml::Operation> _operation) { m_operation = _operation; } //********************************* // Union Getter //********************************* std::weak_ptr<uml::Namespace > CallEventImpl::getNamespace() const { return m_namespace; } std::shared_ptr<Union<uml::Element>> CallEventImpl::getOwnedElement() const { return m_ownedElement; } std::weak_ptr<uml::Element > CallEventImpl::getOwner() const { return m_owner; } std::shared_ptr<CallEvent> CallEventImpl::getThisCallEventPtr() const { return m_thisCallEventPtr.lock(); } void CallEventImpl::setThisCallEventPtr(std::weak_ptr<CallEvent> thisCallEventPtr) { m_thisCallEventPtr = thisCallEventPtr; setThisMessageEventPtr(thisCallEventPtr); } std::shared_ptr<ecore::EObject> CallEventImpl::eContainer() const { if(auto wp = m_namespace.lock()) { return wp; } if(auto wp = m_owner.lock()) { return wp; } if(auto wp = m_owningPackage.lock()) { return wp; } if(auto wp = m_owningTemplateParameter.lock()) { return wp; } return nullptr; } //********************************* // Structural Feature Getter/Setter //********************************* Any CallEventImpl::eGet(int featureID, bool resolve, bool coreType) const { switch(featureID) { case UmlPackage::CALLEVENT_EREFERENCE_OPERATION: return eAny(getOperation()); //19713 } return MessageEventImpl::eGet(featureID, resolve, coreType); } bool CallEventImpl::internalEIsSet(int featureID) const { switch(featureID) { case UmlPackage::CALLEVENT_EREFERENCE_OPERATION: return getOperation() != nullptr; //19713 } return MessageEventImpl::internalEIsSet(featureID); } bool CallEventImpl::eSet(int featureID, Any newValue) { switch(featureID) { case UmlPackage::CALLEVENT_EREFERENCE_OPERATION: { // BOOST CAST std::shared_ptr<uml::Operation> _operation = newValue->get<std::shared_ptr<uml::Operation>>(); setOperation(_operation); //19713 return true; } } return MessageEventImpl::eSet(featureID, newValue); } //********************************* // Persistence Functions //********************************* void CallEventImpl::load(std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler) { std::map<std::string, std::string> attr_list = loadHandler->getAttributeList(); loadAttributes(loadHandler, attr_list); // // Create new objects (from references (containment == true)) // // get UmlFactory std::shared_ptr<uml::UmlFactory> modelFactory = uml::UmlFactory::eInstance(); int numNodes = loadHandler->getNumOfChildNodes(); for(int ii = 0; ii < numNodes; ii++) { loadNode(loadHandler->getNextNodeName(), loadHandler, modelFactory); } } void CallEventImpl::loadAttributes(std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler, std::map<std::string, std::string> attr_list) { try { std::map<std::string, std::string>::const_iterator iter; std::shared_ptr<ecore::EClass> metaClass = this->eClass(); // get MetaClass iter = attr_list.find("operation"); if ( iter != attr_list.end() ) { // add unresolvedReference to loadHandler's list loadHandler->addUnresolvedReference(iter->second, loadHandler->getCurrentObject(), metaClass->getEStructuralFeature("operation")); // TODO use getEStructuralFeature() with id, for faster access to EStructuralFeature } } catch (std::exception& e) { std::cout << "| ERROR | " << e.what() << std::endl; } catch (...) { std::cout << "| ERROR | " << "Exception occurred" << std::endl; } MessageEventImpl::loadAttributes(loadHandler, attr_list); } void CallEventImpl::loadNode(std::string nodeName, std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler, std::shared_ptr<uml::UmlFactory> modelFactory) { MessageEventImpl::loadNode(nodeName, loadHandler, modelFactory); } void CallEventImpl::resolveReferences(const int featureID, std::list<std::shared_ptr<ecore::EObject> > references) { switch(featureID) { case UmlPackage::CALLEVENT_EREFERENCE_OPERATION: { if (references.size() == 1) { // Cast object to correct type std::shared_ptr<uml::Operation> _operation = std::dynamic_pointer_cast<uml::Operation>( references.front() ); setOperation(_operation); } return; } } MessageEventImpl::resolveReferences(featureID, references); } void CallEventImpl::save(std::shared_ptr<persistence::interfaces::XSaveHandler> saveHandler) const { saveContent(saveHandler); MessageEventImpl::saveContent(saveHandler); EventImpl::saveContent(saveHandler); PackageableElementImpl::saveContent(saveHandler); NamedElementImpl::saveContent(saveHandler); ParameterableElementImpl::saveContent(saveHandler); ElementImpl::saveContent(saveHandler); ecore::EModelElementImpl::saveContent(saveHandler); ObjectImpl::saveContent(saveHandler); ecore::EObjectImpl::saveContent(saveHandler); } void CallEventImpl::saveContent(std::shared_ptr<persistence::interfaces::XSaveHandler> saveHandler) const { try { std::shared_ptr<uml::UmlPackage> package = uml::UmlPackage::eInstance(); // Add references saveHandler->addReference("operation", this->getOperation()); } catch (std::exception& e) { std::cout << "| ERROR | " << e.what() << std::endl; } }
9423c8ea72fa79a5b69e71593b3d1ecd9d391325
a3667a872aab3cb9ac09351fb6daa5848df2e338
/ssd_ros_tracking/src/ssd_visualize_ekf.cpp
650fcc83bf06b70b0c5dedc85a19232338aea083
[ "MIT" ]
permissive
Sadaku1993/ssd_ros
2faa2c2790bb2570edcb9c4c90d7262563d1f460
88e280678e6a6b1814ed811bee7d0eaaafd97b56
refs/heads/master
2020-03-18T00:53:59.612624
2018-06-22T06:54:46
2018-06-22T06:54:46
134,118,060
0
1
null
null
null
null
UTF-8
C++
false
false
8,123
cpp
ssd_visualize_ekf.cpp
#include "ssd_ros_tracking/ssd_ekf.h" #include <sensor_msgs/PointCloud.h> #include <visualization_msgs/MarkerArray.h> #include <Eigen/Dense> // dynamic detector param #define CONFIDENCE 0 using namespace std; // using namespace Eigen; void coloring(int color_id, double& r, double& g, double& b) { float colors[10][3] = {{255, 0, 0}, {0,255,0}, {0,0,255}, {255,255,0}, {0,255,255}, {255,0,255}, {255,255,255}, {128,0,128}, {128,128,128}, {128,128,0}}; // float colors[10][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 1}, {0.5, 0, 0.5}, {0.5, 0.5, 0.5}, {0.5, 0.5, 0}}; r = colors[color_id % 10][0]; g = colors[color_id % 10][1]; b = colors[color_id % 10][2]; } void visualizeArrowIn3D(ros::Publisher& pub, std::vector<clusterInfo>& clusters) { int arrow_num = clusters.size(); double yaw; double cluster_vel; double r = 0.0; double g = 0.0; double b = 0.0; visualization_msgs::MarkerArray arrows; visualization_msgs::Marker arrow; arrows.markers.resize(arrow_num); for (int i=0; i<arrow_num; i++){ // Set the frame ID and timestamp. arrow.header.frame_id = "/centerlaser_"; arrow.header.stamp = ros::Time::now(); // Set the namespace and id for this marker. This serves to create a unique ID arrow.ns = "velocity"; arrow.id = i; // Set the marker type. arrow.type = visualization_msgs::Marker::ARROW; // Set the marker action. Options are ADD and DELETE arrow.action = visualization_msgs::Marker::ADD; // Set the pose of the marker. arrow.pose.position.x = clusters[i].x(0); arrow.pose.position.y = clusters[i].x(1); arrow.pose.position.z = -1.3; // yaw = atan2(clusters[i].x(2),clusters[i].x(3)); // yaw = atan2(clusters[i].x(3),clusters[i].x(2)); yaw = clusters[i].x(2); cluster_vel = clusters[i].u(0); arrow.pose.orientation.x = 0.0; arrow.pose.orientation.y = 0.0; arrow.pose.orientation.z = sin(yaw*0.5); arrow.pose.orientation.w = cos(yaw*0.5); if(clusters[i].confidence < 3 || clusters[i].label == 0){ // label 0:static 1:dynamic // if (0.1 < cluster_vel && cluster_vel < 5){ arrow.scale.x = 0.001; arrow.scale.y = 0.001; arrow.scale.z = 0.001; } else { arrow.scale.x = 0.4; arrow.scale.y = 0.4; arrow.scale.z = 0.1; // cout<<"clusters["<<i<<"].confidence = "<<clusters[i].confidence<<" label = "<<clusters[i].label<<endl; } coloring(clusters[i].color_id, r, g, b); arrow.color.r = r; arrow.color.g = g; arrow.color.b = b; arrow.color.a = 1.0; int init_num = -1; int pre_size = clusters[i].pre_position.size(); // cout<<"pre_size = "<<pre_size<<endl; // cout<<"pre_size = "<<clusters[i].pre_position.size()<<endl; for (int j=0; j<pre_size; j++){ // cout<<"label = "<<clusters[i].label<<endl; // if(clusters[i].confidence > (CONFIDENCE-1) && clusters[i].label == 1){ // label 0:static 1:dynamic if(init_num != i){ cout<<" clusters["<<i<<"] "<<endl; // cout<<"i = "<<i<<" confidence = "<<clusters[i].confidence<<" now_pos["<<j<<"] x = "<<clusters[i].x(0)<<" y = "<<clusters[i].x(1)<<" label = "<<clusters[i].label<<endl; cout<<"i = "<<i<<" confidence = "<<clusters[i].confidence<<" now_pos["<<j<<"] x = "<<clusters[i].x(0)<<" y = "<<clusters[i].x(1)<<" vel = "<<clusters[i].velocity<<endl; init_num = i; } cout<<"i = "<<i<<" confidence = "<<clusters[i].confidence<<" pre_pos["<<j<<"] x = "<<clusters[i].pre_position[j].x<<" y = "<<clusters[i].pre_position[j].y<<endl; // } } arrow.lifetime = ros::Duration(0.1); arrows.markers[i] = arrow; } cout<<"-------------------------------------------------------------"<<endl; // Publish the marker pub.publish(arrows); } // void visualizeErrorEllipse(ros::Publisher& pub, std::vector<clusterInfo>& clusters)/*{{{*/ // { // float chi = 5.99;//97%:7.01;//99%:9.21 // float a=0, b=0, rot_angle = 0; // int big_id = 1, small_id = 0, ee_num = 200; // Vector2f e_val; // MatrixXf e_vec; // sensor_msgs::PointCloud ees; //ErroEllipses // ees.header.frame_id = "/centerlaser_"; // // ees.header.frame_id = "centerlaser_"; // ees.header.stamp = ros::Time::now(); // ees.points.resize(clusters.size()*ee_num); // // ees.points.resize(ee_num);//the number of points constituting ellipse // // if (clusters.size()){ // for (size_t id=0; id<clusters.size(); ++id){ // //get long length and short length of ellipse // Eigen::SelfAdjointEigenSolver<Matrix2f> es(clusters[id].P.block(0,0,2,2)); // e_val = es.eigenvalues(); //get eigenvalues // e_vec = es.eigenvectors(); //get eigenvectors // if (e_val(0)>=e_val(1)){ // big_id = 0; // small_id = 1; // } // else { // big_id = 1; // small_id = 0; // } // // a = sqrt(e_val(big_id)*chi); // // b = sqrt(e_val(small_id)*chi); // a = 0.8; // b = 0.8; // clusters[id].r=a; // // //large ellipse is not drawn // // if (clusters[id].r<MAX_R){ // //ellipse : center(0,0) // float theta = 0, r=0; // for (int i=0; i<ee_num; ++i){ // theta =(float)((2.0 * M_PI)/ee_num)*i; // r = b * b / (a + sqrt(a*a-b*b)); // ees.points[i+id*ee_num].x = r * cos(theta); // ees.points[i+id*ee_num].y = r * sin(theta); // ees.points[i+id*ee_num].z = -1.3; // } // //rotate and shift ellipse // rot_angle = atan2(e_vec(1,big_id), e_vec(0,big_id)); // for (size_t i=id*ee_num; i<(id+1)*ee_num; i++){ // float temp_x = ees.points[i].x; // ees.points[i].x = temp_x * cos(rot_angle) + ees.points[i].y * sin(rot_angle) + clusters[id].x(0); // ees.points[i].y = -temp_x * sin(rot_angle) + ees.points[i].y * cos(rot_angle)+ clusters[id].x(1); // } // // } // } // } // else { // ees.points.resize(1); // ees.points[0].x=0; // ees.points[0].y=0; // ees.points[0].z=-1000; // } // pub.publish(ees); // }/*}}}*/ // void visualize_tracking_trajectory(ros::Publisher& pub, std::vector<clusterInfo>& clusters)/*{{{*/ // { // int clusters_num = clusters.size(); // double r = 0.0; // double g = 0.0; // double b = 0.0; // // visualization_msgs::Marker point, line_strip; // visualization_msgs::MarkerArray points, line_strips; // // points.markers.resize(clusters_num); // line_strips.markers.resize(clusters_num); // // for (int i=0; i<clusters_num; i++){ // // point.header.frame_id = line_strip.header.frame_id = "/centerlaser_"; // point.header.stamp = line_strip.header.stamp = ros::Time::now(); // point.ns = line_strip.ns = "trajectory"; // point.action = line_strip.action = visualization_msgs::Marker::ADD; // point.pose.orientation.w = line_strip.pose.orientation.w = 1.0; // // point.id = i; // line_strip.id = i + clusters_num; // // point.type = visualization_msgs::Marker::POINTS; // line_strip.type = visualization_msgs::Marker::LINE_STRIP; // // point.scale.x = 0.2; // point.scale.y = 0.2; // // line_strip.scale.x = 0.1; // // // Points are green // // point.color.g = 1.0f; // // point.color.a = 1.0f; // coloring(i, r, g, b); // point.color.r = r; // point.color.g = g; // point.color.a = b; // // // Line strip is blue // line_strip.color.b = 1.0; // line_strip.color.a = 1.0; // // int pre_size = clusters[i].pre_position.size(); // // for (int j=0; j<pre_size; j++){ // geometry_msgs::Point p; // // if (clusters[i].pre_position[j].x != 0 && clusters[i].pre_position[j].y != 0){ // p.x = clusters[i].pre_position[j].x; // p.y = clusters[i].pre_position[j].y; // p.z = -1.3; // // cout<<"pre_pos["<<j<<"] x = "<<clusters[i].pre_position[j].x<<" y = "<<clusters[i].pre_position[j].y<<endl; // } // // point.points.push_back(p); // line_strip.points.push_back(p); // } // // // point.lifetime = ros::Duration(0.1); // point.lifetime = ros::Duration(1.0); // line_strip.lifetime = ros::Duration(0.1); // // // cout<<" ----------------> array"<<endl; // // points.markers[i] = point; // line_strips.markers[i] = line_strip; // // } // // pub.publish(points); // // pub.publish(line_strips); // }/*}}}*/
fdcd1dc14a2669a15476fed8444018947fcd6e4a
8420523466c9f6ab0edf6ff556c09c5a49edc1cb
/mk/msvc/apptranstool_static_static_glue_app_CRYSTAL.cpp
21199a4b0c38ea39d640176d0b6eec35f1dc5f99
[]
no_license
huigou/planeshift
fb31a43ff1fad0e1b69d9683d0e1e8a0945d8fd3
78afce50bccf755ec4ded0c6bc91ae3c80bc5eba
refs/heads/master
2020-05-25T15:47:26.462741
2016-06-15T20:34:37
2016-06-15T20:34:37
64,410,081
2
3
null
null
null
null
UTF-8
C++
false
false
267
cpp
apptranstool_static_static_glue_app_CRYSTAL.cpp
// This file is automatically generated. #include "cssysdef.h" struct CS_IMPORT_SYM _Bind_transtool_static_plugins_CRYSTAL { _Bind_transtool_static_plugins_CRYSTAL (); }; namespace { _Bind_transtool_static_plugins_CRYSTAL bind_transtool_static_plugins_CRYSTAL; }
b7998bc52cd7c22f2de2c549b1cdcb67dc86c28e
ec0c10f6c207a3ad1832fabe824767f406a992e0
/17406.cpp
32c158dfd94a13465529adc25cba48e5a791db28
[]
no_license
luck2901/Algorithm
5f8e88f6fa6d49e11ce880a2550d5ed8c4c57b05
3462c77d1aa6af3da73c4f10b6dd7bb7a8e8a9b4
refs/heads/main
2023-07-14T09:32:33.963583
2021-08-26T02:10:09
2021-08-26T02:10:09
339,104,020
1
0
null
null
null
null
UTF-8
C++
false
false
2,516
cpp
17406.cpp
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <string.h> using namespace std; int N, M, K, minvalue = 987654321; int arr[51][51]; int rarr[51][51]; int check[51]; vector<pair<pair<int, int>, int> > v; void sequence() { do { for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) arr[i][j] = rarr[i][j]; for (int i = 0; i < K; i++) { int r = v[i].first.first - 1; int c = v[i].first.second - 1; int s = v[i].second; int cnt = 0, idx = 1, line = 3; int y, x; while (cnt != s) { int tmp = arr[r - idx][c - idx]; y = r - idx; x = c - idx; for (int j = x + 1; j < x + line; j++) { int tmp2 = arr[y][j]; arr[y][j] = tmp; tmp = tmp2; } x = x + line - 1; for (int j = y + 1; j < y + line; j++) { int tmp2 = arr[j][x]; arr[j][x] = tmp; tmp = tmp2; } y = y + line - 1; for (int j = x - 1; j > x - line; j--) { int tmp2 = arr[y][j]; arr[y][j] = tmp; tmp = tmp2; } x = x - line + 1; for (int j = y - 1; j > y - line; j--) { int tmp2 = arr[j][x]; arr[j][x] = tmp; tmp = tmp2; } cnt++; line += 2; idx += 1; } } for (int i = 0; i < N; i++) { int sum = 0; for (int j = 0; j < M; j++) { sum += arr[i][j]; } minvalue = min(sum, minvalue); } } while (next_permutation(v.begin(), v.end())); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> N >> M >> K; for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) cin >> rarr[i][j]; for (int i = 0; i < K; i++) { int r, c, s; cin >> r >> c >> s; v.push_back(make_pair(make_pair(r, c), s)); } sort(v.begin(), v.end()); sequence(); cout << minvalue << endl; }
60739711af4890166664fb3df7ff269e61010276
8c13dfc7745ca53c43da0138534665538d4966d3
/tests/basic/basic.cpp
105a9ceeded8ff653b7f4ed364adc02ac3fd46d6
[]
no_license
inlinechan/finder
99eff276d7da778cb3e149cc112cbc0e338235c5
91d53ce207707f4dddfa137f80543993ce638eea
refs/heads/master
2021-01-12T06:51:33.721029
2016-12-26T07:10:55
2016-12-26T07:19:57
76,842,919
0
0
null
null
null
null
UTF-8
C++
false
false
265
cpp
basic.cpp
int increment(int v); int add(int v1, int v2); int main(int, char *[]) { int v1, v2, v3, v4; v1 = 10; v2 = 15; v3 = add(v1, v2); v4 = increment(v3); return 0; } int increment(int v) { return v + 1; } int add(int v1, int v2) { return v1 + v2; }
66e848d9c47723072aa88c6b6e2eb136d43c10b6
3ba7bfc1a5544afd9f55a1cecab686e8e62b0d6c
/vmTools/src/CBits/CBit32.h
fe46bbea818bdf2257de325d565752b163ac03cc
[ "BSD-3-Clause" ]
permissive
vincentma0001/vmTools
45c3f22763503787215ea625f60a098247a65d50
4dec6c20e6305fdab3a70d7af9ee127aa129add1
refs/heads/master
2021-06-07T03:30:55.220101
2020-04-20T12:36:30
2020-04-20T12:36:52
58,296,227
0
0
null
null
null
null
GB18030
C++
false
false
13,386
h
CBit32.h
///////////////////////////////////////////////////////////////////////////////////////// // // File name : CBit32.h // Version : 1.0.0.0 // Brief : // Author : v.m. // Create time : 2020/01/06 00:51:24 // Modify time : 2020/01/06 00:51:24 // Note : // ///////////////////////////////////////////////////////////////////////////////////////// // // Copyright : this file is copyright by v.m.'s tools lib // ///////////////////////////////////////////////////////////////////////////////////////// // compile macro definition #if defined (_MSC_VER) && (_MSC_VER >= 1300) #pragma once #endif #ifndef __CBIT32_H__ #define __CBIT32_H__ ///////////////////////////////////////////////////////////////////////////////////////// // Include files : // Standard c/c++ files included // Config files included #ifndef __VM_CFG_H__ # error this file need #include <vmCfg.h> #endif // __VM_CFG_H__ // Platform files included // Used files included #ifndef __VM_UTIL_H__ # error this file need #include <vmLibBase/vmUtil.h> #endif // __VM_UTIL_H__ ///////////////////////////////////////////////////////////////////////////////////////// // using namespace namespace vm{ ///////////////////////////////////////////////////////////////////////////////////////// // // class CBit32 : ๆญค็ฑปๅฐ่ฃ…ไบ†32ไฝBitๅญ—่Š‚ๆ“ไฝœ // ///////////////////////////////////////////////////////////////////////////////////////// class CBit32 { ///////////////////////////////////////////////////////////////////////////////////////// // Types define : public: typedef struct stBit32 { unsigned int bit00 : 1; unsigned int bit01 : 1; unsigned int bit02 : 1; unsigned int bit03 : 1; unsigned int bit04 : 1; unsigned int bit05 : 1; unsigned int bit06 : 1; unsigned int bit07 : 1; unsigned int bit08 : 1; unsigned int bit09 : 1; unsigned int bit10 : 1; unsigned int bit11 : 1; unsigned int bit12 : 1; unsigned int bit13 : 1; unsigned int bit14 : 1; unsigned int bit15 : 1; unsigned int bit16 : 1; unsigned int bit17 : 1; unsigned int bit18 : 1; unsigned int bit19 : 1; unsigned int bit20 : 1; unsigned int bit21 : 1; unsigned int bit22 : 1; unsigned int bit23 : 1; unsigned int bit24 : 1; unsigned int bit25 : 1; unsigned int bit26 : 1; unsigned int bit27 : 1; unsigned int bit28 : 1; unsigned int bit29 : 1; unsigned int bit30 : 1; unsigned int bit31 : 1; }; typedef enum emBitPos { PosFF = 0xFFFFFFFF, Pos00 = 0x00000000, Pos01 = 0x00000001, Pos02 = 0x00000002, Pos03 = 0x00000004, Pos04 = 0x00000008, Pos05 = 0x00000010, Pos06 = 0x00000020, Pos07 = 0x00000040, Pos08 = 0x00000080, Pos09 = 0x00000100, Pos10 = 0x00000200, Pos11 = 0x00000400, Pos12 = 0x00000800, Pos13 = 0x00001000, Pos14 = 0x00002000, Pos15 = 0x00004000, Pos16 = 0x00008000, Pos17 = 0x00010000, Pos18 = 0x00020000, Pos19 = 0x00040000, Pos20 = 0x00080000, Pos21 = 0x00100000, Pos22 = 0x00200000, Pos23 = 0x00400000, Pos24 = 0x00800000, Pos25 = 0x01000000, Pos26 = 0x02000000, Pos27 = 0x04000000, Pos28 = 0x08000000, Pos29 = 0x10000000, Pos30 = 0x20000000, Pos31 = 0x40000000, Pos32 = 0x80000000 }; ///////////////////////////////////////////////////////////////////////////////////////// // Construct && Destruct public: // Construct define inline CBit32(long& cVal) :mBit(*((unsigned long*)&cVal)) {}; inline CBit32(unsigned long& cVal) :mBit(cVal) {}; // Destruct define inline virtual ~CBit32() {}; public: // Copy construct define inline CBit32(const CBit32& obj) :mBit(obj.mBit) {}; // Assignment define inline CBit32& operator = (const CBit32& obj) { mBit = obj.mBit; return *this; }; public: // ไฝไธŽ่ฟ็ฎ—็ฌฆ(&) [00000011 & 00000101 = 00000001] inline CBit32& operator&(const CBit32& obj) { mBit = mBit & obj.mBit; return *this; }; inline CBit32& operator&(const long cVal) { mBit = mBit & cVal; return *this; }; // ไฝๆˆ–่ฟ็ฎ—็ฌฆ(|) [00000011 | 00000101 = 00000111] inline CBit32& operator|(const CBit32& obj) { mBit = mBit | obj.mBit; return *this; }; inline CBit32& operator|(const long cVal) { mBit = mBit | cVal; return *this; }; // ไฝๅผ‚ๆˆ–่ฟ็ฎ—็ฌฆ(^) [00000011 | 00000101 = 00000110] inline CBit32& operator^(const CBit32& obj) { mBit = mBit ^ obj.mBit; return *this; }; inline CBit32& operator^(const long cVal) { mBit = mBit ^ cVal; return *this; }; // ไฝๅ–ๅ่ฟ็ฎ—็ฌฆ(~) [~00000101 = 11111010] inline CBit32& operator~() { mBit = ~mBit; return *this; }; ///////////////////////////////////////////////////////////////////////////////////////// // Members : private: unsigned long& mBit; ///////////////////////////////////////////////////////////////////////////////////////// // Functions : public: // ่ฟ”ๅ›žๅฝ“ๅ‰Bit็ฑปๅ†…ๅญ˜ๅคงๅฐ inline unsigned int size() { return sizeof(mBit); }; // ้‡็ฝฎBitๆ•ฐๅ€ผ inline void reset() { mBit = 0; }; // ่ฟ”ๅ›žๅฝ“ๅ‰ๅ€ผ inline long toLong() { return mBit; }; inline unsigned long toULong() { return mBit; }; // ่ฎพ็ฝฎbitๅ€ผ inline void Set(const long cVal) { mBit = cVal; }; inline void Set(const unsigned long cVal) { mBit = cVal; }; inline void Set01() { ((stBit32*)&mBit)->bit00 = 1; }; inline void Set02() { ((stBit32*)&mBit)->bit01 = 1; }; inline void Set03() { ((stBit32*)&mBit)->bit02 = 1; }; inline void Set04() { ((stBit32*)&mBit)->bit03 = 1; }; inline void Set05() { ((stBit32*)&mBit)->bit04 = 1; }; inline void Set06() { ((stBit32*)&mBit)->bit05 = 1; }; inline void Set07() { ((stBit32*)&mBit)->bit06 = 1; }; inline void Set08() { ((stBit32*)&mBit)->bit07 = 1; }; inline void Set09() { ((stBit32*)&mBit)->bit08 = 1; }; inline void Set10() { ((stBit32*)&mBit)->bit09 = 1; }; inline void Set11() { ((stBit32*)&mBit)->bit10 = 1; }; inline void Set12() { ((stBit32*)&mBit)->bit11 = 1; }; inline void Set13() { ((stBit32*)&mBit)->bit12 = 1; }; inline void Set14() { ((stBit32*)&mBit)->bit13 = 1; }; inline void Set15() { ((stBit32*)&mBit)->bit14 = 1; }; inline void Set16() { ((stBit32*)&mBit)->bit15 = 1; }; inline void Set17() { ((stBit32*)&mBit)->bit16 = 1; }; inline void Set18() { ((stBit32*)&mBit)->bit17 = 1; }; inline void Set19() { ((stBit32*)&mBit)->bit18 = 1; }; inline void Set20() { ((stBit32*)&mBit)->bit19 = 1; }; inline void Set21() { ((stBit32*)&mBit)->bit20 = 1; }; inline void Set22() { ((stBit32*)&mBit)->bit21 = 1; }; inline void Set23() { ((stBit32*)&mBit)->bit22 = 1; }; inline void Set24() { ((stBit32*)&mBit)->bit23 = 1; }; inline void Set25() { ((stBit32*)&mBit)->bit24 = 1; }; inline void Set26() { ((stBit32*)&mBit)->bit25 = 1; }; inline void Set27() { ((stBit32*)&mBit)->bit26 = 1; }; inline void Set28() { ((stBit32*)&mBit)->bit27 = 1; }; inline void Set29() { ((stBit32*)&mBit)->bit28 = 1; }; inline void Set30() { ((stBit32*)&mBit)->bit29 = 1; }; inline void Set31() { ((stBit32*)&mBit)->bit30 = 1; }; inline void Set32() { ((stBit32*)&mBit)->bit31 = 1; }; // ๅ–ๆถˆbitๅ€ผ่ฎพ็ฝฎ inline void unSet(const long cVal) { mBit = cVal; }; inline void unSet(const unsigned long cVal) { mBit = cVal; }; inline void unSet01() { ((stBit32*)&mBit)->bit00 = 0; }; inline void unSet02() { ((stBit32*)&mBit)->bit01 = 0; }; inline void unSet03() { ((stBit32*)&mBit)->bit02 = 0; }; inline void unSet04() { ((stBit32*)&mBit)->bit03 = 0; }; inline void unSet05() { ((stBit32*)&mBit)->bit04 = 0; }; inline void unSet06() { ((stBit32*)&mBit)->bit05 = 0; }; inline void unSet07() { ((stBit32*)&mBit)->bit06 = 0; }; inline void unSet08() { ((stBit32*)&mBit)->bit07 = 0; }; inline void unSet09() { ((stBit32*)&mBit)->bit08 = 0; }; inline void unSet10() { ((stBit32*)&mBit)->bit09 = 0; }; inline void unSet11() { ((stBit32*)&mBit)->bit10 = 0; }; inline void unSet12() { ((stBit32*)&mBit)->bit11 = 0; }; inline void unSet13() { ((stBit32*)&mBit)->bit12 = 0; }; inline void unSet14() { ((stBit32*)&mBit)->bit13 = 0; }; inline void unSet15() { ((stBit32*)&mBit)->bit14 = 0; }; inline void unSet16() { ((stBit32*)&mBit)->bit15 = 0; }; inline void unSet17() { ((stBit32*)&mBit)->bit16 = 0; }; inline void unSet18() { ((stBit32*)&mBit)->bit17 = 0; }; inline void unSet19() { ((stBit32*)&mBit)->bit18 = 0; }; inline void unSet20() { ((stBit32*)&mBit)->bit19 = 0; }; inline void unSet21() { ((stBit32*)&mBit)->bit20 = 0; }; inline void unSet22() { ((stBit32*)&mBit)->bit21 = 0; }; inline void unSet23() { ((stBit32*)&mBit)->bit22 = 0; }; inline void unSet24() { ((stBit32*)&mBit)->bit23 = 0; }; inline void unSet25() { ((stBit32*)&mBit)->bit24 = 0; }; inline void unSet26() { ((stBit32*)&mBit)->bit25 = 0; }; inline void unSet27() { ((stBit32*)&mBit)->bit26 = 0; }; inline void unSet28() { ((stBit32*)&mBit)->bit27 = 0; }; inline void unSet29() { ((stBit32*)&mBit)->bit28 = 0; }; inline void unSet30() { ((stBit32*)&mBit)->bit29 = 0; }; inline void unSet31() { ((stBit32*)&mBit)->bit30 = 0; }; inline void unSet32() { ((stBit32*)&mBit)->bit31 = 0; }; // ๅˆคๆ–ญBitไฝๆ˜ฏ้ž่ขซ่ฎพ็ฝฎ inline bool isSet(const long cVal) { mBit&cVal ? true : false; }; inline bool isSet01() { return (((stBit32*)&mBit)->bit00 & 1) ? true : false; }; inline bool isSet02() { return (((stBit32*)&mBit)->bit01 & 1) ? true : false; }; inline bool isSet03() { return (((stBit32*)&mBit)->bit02 & 1) ? true : false; }; inline bool isSet04() { return (((stBit32*)&mBit)->bit03 & 1) ? true : false; }; inline bool isSet05() { return (((stBit32*)&mBit)->bit04 & 1) ? true : false; }; inline bool isSet06() { return (((stBit32*)&mBit)->bit05 & 1) ? true : false; }; inline bool isSet07() { return (((stBit32*)&mBit)->bit06 & 1) ? true : false; }; inline bool isSet08() { return (((stBit32*)&mBit)->bit07 & 1) ? true : false; }; inline bool isSet09() { return (((stBit32*)&mBit)->bit08 & 1) ? true : false; }; inline bool isSet10() { return (((stBit32*)&mBit)->bit09 & 1) ? true : false; }; inline bool isSet11() { return (((stBit32*)&mBit)->bit10 & 1) ? true : false; }; inline bool isSet12() { return (((stBit32*)&mBit)->bit11 & 1) ? true : false; }; inline bool isSet13() { return (((stBit32*)&mBit)->bit12 & 1) ? true : false; }; inline bool isSet14() { return (((stBit32*)&mBit)->bit13 & 1) ? true : false; }; inline bool isSet15() { return (((stBit32*)&mBit)->bit14 & 1) ? true : false; }; inline bool isSet16() { return (((stBit32*)&mBit)->bit15 & 1) ? true : false; }; inline bool isSet17() { return (((stBit32*)&mBit)->bit16 & 1) ? true : false; }; inline bool isSet18() { return (((stBit32*)&mBit)->bit17 & 1) ? true : false; }; inline bool isSet19() { return (((stBit32*)&mBit)->bit18 & 1) ? true : false; }; inline bool isSet20() { return (((stBit32*)&mBit)->bit19 & 1) ? true : false; }; inline bool isSet21() { return (((stBit32*)&mBit)->bit20 & 1) ? true : false; }; inline bool isSet22() { return (((stBit32*)&mBit)->bit21 & 1) ? true : false; }; inline bool isSet23() { return (((stBit32*)&mBit)->bit22 & 1) ? true : false; }; inline bool isSet24() { return (((stBit32*)&mBit)->bit23 & 1) ? true : false; }; inline bool isSet25() { return (((stBit32*)&mBit)->bit24 & 1) ? true : false; }; inline bool isSet26() { return (((stBit32*)&mBit)->bit25 & 1) ? true : false; }; inline bool isSet27() { return (((stBit32*)&mBit)->bit26 & 1) ? true : false; }; inline bool isSet28() { return (((stBit32*)&mBit)->bit27 & 1) ? true : false; }; inline bool isSet29() { return (((stBit32*)&mBit)->bit28 & 1) ? true : false; }; inline bool isSet30() { return (((stBit32*)&mBit)->bit29 & 1) ? true : false; }; inline bool isSet31() { return (((stBit32*)&mBit)->bit30 & 1) ? true : false; }; inline bool isSet32() { return (((stBit32*)&mBit)->bit31 & 1) ? true : false; }; ///////////////////////////////////////////////////////////////////////////////////////// // Friends define: friend class CBitStr; }; // End of class CBit32 ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// } // End of namespace vm ///////////////////////////////////////////////////////////////////////////////////////// #endif // __CBIT32_H__ ///////////////////////////////////////////////////////////////////////////////////////// // usage : /* //*/ ///////////////////////////////////////////////////////////////////////////////////////// // End of file CBit32.h /////////////////////////////////////////////////////////////////////////////////////////
bd9a308395ffbdfca6574edd6f1945b2cd6b7087
1fe28a6caaa5dad11751fa7f2a2acec1379fcf2d
/instructions/lds.cc
7c151104b16f5ad15c7910a7ca7470d8201c30d3
[]
no_license
aghoward/avr-emu
6a9acac919700df4b94ce91b6ae97c04813ab4c9
75021e38c9d2d32f19860515b98ddd7efb4077c1
refs/heads/master
2023-06-09T13:43:15.147197
2021-07-02T19:46:58
2021-07-02T19:46:58
344,144,167
0
0
null
2021-07-02T19:46:59
2021-03-03T13:55:52
C++
UTF-8
C++
false
false
1,137
cc
lds.cc
#include "instructions/lds.h" #include "instructions/opcodes.h" #include <cstdint> namespace avr { uint16_t LDSInstruction::GetImmediate(ExecutionContext& ctx) const { auto out = static_cast<uint16_t>(0u); for (auto i = 0u; i < sizeof(out); i++) out |= static_cast<uint16_t>(ctx.progMem[ctx.cpu.PC++] << (i * 8u)); return out; } uint8_t& LDSInstruction::GetDestinationRegister(CPU& cpu, uint16_t opcode) const { auto mask = 0x01F0u; auto index = static_cast<uint16_t>((opcode & mask) >> 4); return cpu.R[index]; } uint32_t LDSInstruction::Execute(uint16_t opcode, ExecutionContext& ctx) const { auto& rd = GetDestinationRegister(ctx.cpu, opcode); auto k = GetImmediate(ctx); _clock.ConsumeCycle(); rd = ctx.ram[k]; _clock.ConsumeCycle(); return _cyclesConsumed; } bool LDSInstruction::Matches(uint16_t opcode) const { auto op = static_cast<uint16_t>(OpCode::LDS); auto mask = static_cast<uint16_t>(OpCodeMask::LDS); return (opcode & mask) == op; } }
5ccdefc42f23107a50f5c16d764400528248fa68
6a9c422f963e1fd79f6ceda23a6e147565b43624
/LEETCODE-50.Pow(x,n).cpp
a1ff188a02719ce91a51d55e7419e5ed504372c3
[]
no_license
sidhantchadha/LEETCODE
6605d07b30c06d47d81b0d6d84673c31ea0cc9e1
d67e210d396a015b2dd6980ffd2a82b9e0cf2d73
refs/heads/master
2020-03-07T01:37:28.592703
2018-06-22T20:32:11
2018-06-22T20:32:11
127,188,143
1
0
null
null
null
null
UTF-8
C++
false
false
854
cpp
LEETCODE-50.Pow(x,n).cpp
//============================================================================ // Name : Pow(x,n).cpp // Author : Sidhant Chadha // Version : // Copyright : // Description : Pow(x,n) in C++, Ansi-style //============================================================================ //RECURSIVE class Solution { public: double myPow(double x, int n) { if(n==0) return 1; double t=myPow(x,n/2); if(n%2) return n<0 ? (1/x)*t*t : x*t*t; else return t*t; } }; //NON Recursive// class Solution { public: double myPow(double x, int n) { double ans = 1; unsigned long long p; if (n < 0) { p = -n; x = 1 / x; } else { p = n; } while (p) { if (p & 1) ans *= x; x *= x; p >>= 1; } return ans; } };
a6f3e4d1c8b38a2490689c648594960ae25fd993
f435c4a55c90c0122154622b6e4c09c549468dfb
/libs/utils/timestamp.h
5802944cc2d30541bf8c24ca1812f53f927f4896
[]
no_license
alexsaker/bazel-cpp-example
afb6f54f92cfca7d36055a582ac276545ef4228d
7414eba3a5322cfe0417a30afbea11eec5284cb6
refs/heads/master
2022-12-29T02:32:33.514833
2020-10-19T19:24:06
2020-10-19T19:24:06
297,257,260
1
0
null
null
null
null
UTF-8
C++
false
false
179
h
timestamp.h
#include <iostream> struct Timestamp { public: unsigned long int timestamp; static std::string toJson(); }; Timestamp GetTimestamp();
bb2f6ff6c9ab6d5814c71e7ac307f7864ee20fbb
e9bcf82d4a49a5348999458ca4956aa099fd4818
/Project2/aieBootstrap/project2D/PauseState.cpp
9829605faa43a0c2ccb6e049ba794d935cbfe46b
[ "MIT" ]
permissive
AnonUser676/Game_Project
90e2888db55ccbb51352e22223bb63bc7ecced94
5690b0ef411fadbbf8f02ac9a6325c93c4859d96
refs/heads/master
2021-01-22T12:17:45.040886
2017-06-27T07:37:31
2017-06-27T07:37:31
92,711,732
0
0
null
null
null
null
UTF-8
C++
false
false
2,442
cpp
PauseState.cpp
#include "PauseState.h" PauseState::PauseState() { m_background = new Texture("./textures/Pause/MenuBG.png"); m_ResumeOFF = new Texture("./textures/Pause/Resume.png"); m_ResumeOn = new Texture("./textures/Pause/Resume_Pressed.png"); m_OptionsOff = new Texture("./textures/Pause/Options.png"); m_OptionsOn = new Texture("./textures/Pause/Options_Pressed.png"); m_ExitOff = new Texture("./textures/Pause/Exit.png"); m_ExitOn = new Texture("./textures/Pause/Exit_Pressed.png"); m_Resume = m_ResumeOFF; m_Options = m_OptionsOff; m_Exit = m_ExitOff; } PauseState::~PauseState() { delete m_background; delete m_ResumeOFF; delete m_ResumeOn; delete m_OptionsOff; delete m_OptionsOn; delete m_ExitOff; delete m_ExitOn; } void PauseState::onEnter() { time = 0.0f; } void PauseState::onDraw(Renderer2D* renderer2D) { renderer2D->drawSprite(m_background, 118.0f, 118.0f, 1044.0f, 484.0f, 0, 98.0f, 0, 0); renderer2D->drawSprite(m_Resume, 413.0f, 440.0f, 454.0f, 130.0f, 0.0f, 50.0f, 0.0f, 0.0f); renderer2D->drawSprite(m_Options, 413.0f, 290.0f, 454.0f, 130.0f, 0.0f, 50.0f, 0.0f, 0.0f); renderer2D->drawSprite(m_Exit, 413.0f, 140.0f, 454.0f, 130.0f, 0.0f, 50.0f, 0.0f, 0.0f); } void PauseState::onUpdate(float deltaTIme, StateMachine* State) { time += deltaTIme; m_Input = Input::getInstance(); if ((m_Input->getMouseX() > 413.0f) && (m_Input->getMouseX() < 867.0f)) { if ((m_Input->getMouseY() > 440.0f) && (m_Input->getMouseY() < 570.0f)) { m_Resume = m_ResumeOn; if (m_Input->isMouseButtonDown(INPUT_MOUSE_BUTTON_LEFT)) if (m_Input->isMouseButtonDown(INPUT_MOUSE_BUTTON_LEFT)|| m_Input->wasKeyPressed(INPUT_KEY_ESCAPE)) { State->bDrawLowerState = false; State->PopState(); } } else if ((m_Input->getMouseY() > 290.0f) && (m_Input->getMouseY() < 420.0f)) m_Options = m_OptionsOn; else if ((m_Input->getMouseY() > 140.0f) && (m_Input->getMouseY() < 270.0f)) { m_Exit = m_ExitOn; if (m_Input->isMouseButtonDown(INPUT_MOUSE_BUTTON_LEFT)) { State->bDrawLowerState = false; State->PopState(); State->PushState(STATE_MENU); } } else { m_Resume = m_ResumeOFF; m_Options = m_OptionsOff; m_Exit = m_ExitOff; } } else { m_Resume = m_ResumeOFF; m_Options = m_OptionsOff; m_Exit = m_ExitOff; } } void PauseState::onExit() { time = 0.0f; }
a961420cf9245a348186143ae287f8c55c374c58
5d5894224564cfa3bbc7afd038e41d8db8ff528e
/Gateware/Interface/G_Core/GBroadcasting.h
9c8e2880aa5cc5b43c633f809d440b213d62e284
[ "MIT" ]
permissive
LiamMMurray/ProjectCreation
8cc37afbb905935fbf5118467d10fa0cbb6a5d9c
5fe8371b1ada375ba68f76bbea49a08985586626
refs/heads/master
2022-03-08T15:45:51.838752
2019-11-09T17:35:49
2019-11-09T17:35:49
185,449,669
0
1
null
2019-05-25T17:12:54
2019-05-07T17:35:16
C
UTF-8
C++
false
false
2,509
h
GBroadcasting.h
#ifndef GBROADCASTING_H #define GBROADCASTING_H /*! File: GBroadcasting.h Purpose: A Gateware interface that allows an object derived from GListener to receive select events from a GBroadcaster. Author: Lari H. Norri Contributors: N/A Last Modified: 10/13/2016 Interface Status: Final Copyright: 7thGate Software LLC. License: MIT */ #include "GListener.h" //! The core namespace to which all Gateware interfaces/structures/defines must belong. namespace GW { //! The core namespace to which all Gateware fundamental interfaces must belong. namespace CORE { //! Unique Identifier for this interface. {FF23C564-940B-44A2-9E5F-CE264659D69A} static const GUUIID GBroadcastingUUIID = { 0xff23c564, 0x940b, 0x44a2,{ 0x9e, 0x5f, 0xce, 0x26, 0x46, 0x59, 0xd6, 0x9a } }; //! The GBroadcasting Interface is capable of registering & deregistering GListener interfaces. /*! * The GBroadcaster will notify all registered listeners with the listeners OnEvent function. * The events being registered for can be filtered with the _eventMask (optional). * GBroadcasting Inherits directly from GMultiThreaded, therefore its implementation * must be thread safe. */ class GBroadcasting : public GMultiThreaded { // All Gateware API interfaces contain no variables & are pure virtual. public: //! Any listener added to this class must receive all events unless otherwise specified by the _eventMask (optional). /*! * Listeners registered to a broadcaster will have their reference counts increased by one until deregistered. * * * \param [in] _addListener The listener object that is registering for messages. * \param [in] _eventMask The events the listener is registering for. 0 will register for all events. * * \retval SUCCESS The listener was successfully registered. * \retval REDUNDANT_OPERATION The listener has already been registered by a previous call. */ virtual GReturn RegisterListener(GListener* _addListener, unsigned long long _eventMask) = 0; //! A successfully deregistered listener will no longer receive events and have its reference count decremented by one. /*! * \param [in] _removeListener The listener to deregister from events. * * \retval SUCCESS The listener was successfully deregistered. */ virtual GReturn DeregisterListener(GListener* _removeListener) = 0; }; }// end CORE namespace };// end GW namespace #endif
556504a44f4c5bf08c2f9576213c409a66f94b7e
ce920bd897afa6135f3f1a3c777416eb390555cb
/include/scope_guard.hh
55059872740022ba573e967fea7f38313e60ef2c
[]
no_license
ivankp/server_old_1
64095f03ed58c8599ebf1d5e9709a657a4f70e2e
fa7e4bb53751190057aabe571b8bfb7dbb1e8f03
refs/heads/master
2023-05-01T00:08:17.345373
2021-05-18T17:46:30
2021-05-18T17:46:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
635
hh
scope_guard.hh
#ifndef IVANP_SCOPE_GUARD_HH #define IVANP_SCOPE_GUARD_HH namespace ivanp { template <typename F> class scope_guard { F f; public: explicit scope_guard(F&& f): f(std::forward<F>(f)) { } scope_guard() = delete; scope_guard(const scope_guard&) = delete; scope_guard(scope_guard&&) = delete; scope_guard& operator=(const scope_guard&) = delete; scope_guard& operator=(scope_guard&&) = delete; ~scope_guard() { f(); } const F& operator*() const noexcept { return f; } F& operator*() noexcept { return f; } const F* operator->() const noexcept { return &f; } F* operator->() noexcept { return &f; } }; } #endif
ace91d04a517f8458b4bb146b74a798f3858592d
8ea8db0f19261d849444fd1033ecc64e4bb2e768
/model/character/HighPunchHitting.cpp
dfd6488d4db58bc6dbfb166e1d75f3804c074063
[]
no_license
alkatena/mortalKombat-taller1C2015
c93dd23019cb7ab0384143dc9030c43f0b8860b9
b347400697f0fb16d2e4a9a4cfea0e7a8fcec9f1
refs/heads/master
2021-01-12T14:00:28.321640
2015-10-28T02:29:14
2015-10-28T02:29:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,428
cpp
HighPunchHitting.cpp
#include "HighPunchHitting.h" #include "CharacterStance.h" #include "ReceivingDuckingKick.h" #include "RecevingHit.h" #include "ReceivingDuckingPunch.h" #include "BeingOverPassedRight.h" #include "BeingOverPassedLeft.h" #include "TeleportationDoing.h" #include "../../view/SoundManager.h" #include "WeaponHittingIce.h" #include "FatalityHitting.h" #include "BeingPushed.h" HighPunchHitting::HighPunchHitting() { this->timer = 40; SoundManager::getInstance()->playSound("hit1"); } HighPunchHitting::~HighPunchHitting() { } void HighPunchHitting::update(MKCharacter *character, Events aEvent) { switch (aEvent) { case ReceiveHit: character->setState(new RecevingHit()); break; case ReceiveDuckingKick: character->setState(new ReceivingDuckingKick()); break; case ReceiveDuckingPunch: character->setState(new ReceivingDuckingPunch()); break; case ReceiveWeapon: character->setState(new ReceivingDuckingPunch()); break; case OverPassed: if (character->getCharacterSide() == 'l') { character->setState(new BeingOverPassedLeft()); } else { character->setState(new BeingOverPassedRight()); }; break; case Teleportation: character->setState(new TeleportationDoing()); break; case WeaponHitIce: if (character->getName() == "raiden"){ character->setState(new WeaponHittingIce()); } break; case FatalityHit: if (character->getFatalityEnable()) character->setState(new FatalityHitting()); break; case ReceivingFlyHit: if (character->getName() == "scorpion") { character->setState(new BeingPushed()); } break; default: break; } } float HighPunchHitting::getWidth() { return 1.55; } string HighPunchHitting::getName() { return "HighPunchHitting"; } void HighPunchHitting::refreshTimer(MKCharacter* character) { if (this->timer == 0) { character->setState(new CharacterStance()); this->timer = 40; } this->timer -= 1; } bool HighPunchHitting::isHitting() { return true; } bool HighPunchHitting::impact() { return (this->timer == 20); }
e7799a16ca627f071872293f13f22f06e403d95b
8a9a16f3445fdba16020973e4f832a46c208271b
/4.27.17/4.27.17/Source.cpp
00dabe40924ad58e71ce4ddc250399d74f02bf2e
[]
no_license
Robowerewolf/AprilCode
0b277256b8dfca751c4707ffc52e4116af52e94b
90cd0c721f2a1f07a925f69f8931ea7557072b67
refs/heads/master
2021-01-19T03:56:09.179924
2018-03-22T19:18:07
2018-03-22T19:18:07
87,342,756
0
1
null
null
null
null
UTF-8
C++
false
false
700
cpp
Source.cpp
#include <iostream> using namespace std; double attack(double level,double a,double d,double power, double modifier); int main() { double level = 0; double a = 0; double d = 0; double power = 0; double modifier; cout << "whats the level" << endl; cin >> level; cout << "attack?" << endl; cin >> a; cout << "power?" << endl; cin >> power; cout << "defence?" << endl; cin >> d; cout << "modifier?" << endl; cin >> modifier; cout << "you did " << attack(level, a, d, power, modifier) << " damage" << endl; } double attack(double level, double a, double d, double power, double modifier) { double damage = ((((2 * level / 5) + 2)*power*(a / d) / 50) + 2)*modifier; return damage; }
3d9982280d0dd41ed8651bc32dcf53f82f66381c
da33b9e1f4e00d283d9bd30a64b57d2f5a52379f
/rotate2d.cpp
b8b60ac6107f1d2d3eb714d869a244cd08f914bd
[]
no_license
mahima-manik/Competitive-Programming
0003264adfbb038e5b61ca5130dbc342784ce1e1
d955d4d36924f6cf07129fe2d333e1c7e11da951
refs/heads/master
2020-03-23T09:17:15.560257
2018-10-03T16:28:46
2018-10-03T16:28:46
141,378,451
0
0
null
null
null
null
UTF-8
C++
false
false
1,440
cpp
rotate2d.cpp
/* You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). You need to do this in place. Note that if you end up using an additional array, you will only receive partial score. Example: If the array is 1 2 3 4 5 6 7 8 9 Then the rotated array becomes: 7 4 1 8 5 2 9 6 3 Input: The first line contains an integer 'T' denoting the total number of test cases. In each test cases, the first line contains an integer 'N' denoting the size of the 2D square matrix. And in the second line, the elements of the matrix A[][], each separated by a space in row major form. Output: For each test case, print the elements of the rotated array row wise, each element separated by a space. Print the output of each test case in a new line. Constraints: 1 โ‰ค T โ‰ค 70 1 โ‰ค N โ‰ค 10 1 โ‰ค A [ i ][ j ] โ‰ค 100 Example: Input: 2 3 1 2 3 4 5 6 7 8 9 2 56 96 91 54 Output: 7 4 1 8 5 2 9 6 3 91 56 54 96 */ #include<iostream> #include<vector> using namespace std; int main() { int t, n, temp; cin >> t; while (t > 0) { cin >> n; vector <vector<int>> a(n, vector<int>(n, 0)); for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { cin >> temp; a[j][n-i-1] = temp; } } for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { cout << a[i][j] << " "; } } cout << endl; t--; } return 0; }
bbfc5d5b95b8139bb16087e116542f7882b772a1
9178c14c6977c10706cec7d3928159cbb0eab566
/Game/Game/Item/InventoryItem/InventoryBow.cpp
8ae7b8d8d6bfec7723172bdc6722ce908973d676
[]
no_license
osumaru/Game
bdac76f375e621f05ee50cca0d1913ac7c13ca84
6ae23ce622bd1911604e84af318b92fc609f7650
refs/heads/master
2023-03-07T11:40:17.907500
2021-02-20T09:56:50
2021-02-20T09:56:50
125,951,546
0
0
null
null
null
null
UTF-8
C++
false
false
327
cpp
InventoryBow.cpp
#include "InventoryBow.h" void CInventoryBow::Init(const wchar_t* itemName, const wchar_t* textureFilePath) { m_itemName = itemName; m_textureFilePath = textureFilePath; CTexture* texture = TextureResource().LoadTexture(textureFilePath); m_itemSprite.Init(texture); } void CInventoryBow::Draw() { m_itemSprite.Draw(); }
037761d5bc25cd279036ef897714cf6b7be60ec1
507bfa523de24ae9ae5969c1ea3d9b078ce186bb
/tests/source/init.cpp
acf7823127b17f464d53b151139ac00e20cbab84
[]
no_license
simplydesigner/BinarySearchTree
b5596441215bd7d0a656e0d3242ed80ddfc73061
9c4684f1c38ae42ec8984a2a306e44b69afa356d
refs/heads/master
2021-01-01T03:37:15.494854
2016-05-16T11:03:52
2016-05-16T11:03:52
58,455,375
0
0
null
2016-05-10T11:23:42
2016-05-10T11:23:40
null
UTF-8
C++
false
false
9,696
cpp
init.cpp
#include <BinarySearchTree.hpp> #include <catch.hpp> #include <fstream> SCENARIO("BST init with initializer list", "[init]") { BinarySearchTree<int> tree = {8}; REQUIRE( tree.size() == 1 ); } SCENARIO("BST search inserted element", "[search]") { BinarySearchTree<int> tree = {8, 4, 3}; REQUIRE( tree.find(4) ); } SCENARIO("BST search non inserted element", "[search]") { BinarySearchTree<int> tree = {8, 4, 3}; REQUIRE( !tree.find(5) ); } SCENARIO("BST delete non inserted element", "[delete]") { BinarySearchTree<int> tree = {8}; REQUIRE( !tree.remove(4) ); REQUIRE( !tree.isEmpty() ); } // +----+ // |-08-| * // +----+ // // // 08 // ----> SCENARIO("BST delete root without children", "[delete]") { BinarySearchTree<int> tree = {8}; REQUIRE( tree.remove(8) ); REQUIRE( tree.isEmpty() ); } // +----+ +----+ // |-08-| | 04 | // +----+ +----+ // / / // / / // +----+ +----+ // | 04 | | 03 | // +----+ +----+ // / // / // +----+ 08 // | 03 | ----> // +----+ SCENARIO("BST delete root with one child", "[delete]") { BinarySearchTree<int> tree = {8, 4, 3}; REQUIRE( tree.remove(8) ); REQUIRE( tree == BinarySearchTree<int>({4, 3}) ); } // +----+ +----+ // |-08-| | 09 | // +----+ +----+ // /\ /\ // / \ / \ // +----+ +----+ +----+ +----+ // | 04 | | 10 | | 04 | | 10 | // +----+ +----+ +----+ +----+ // / /\ / \ // / / \ / \ // +----+ +----+ +----+ 08 +----+ +----+ // | 03 | | 09 | | 13 | ----> | 03 | | 13 | // +----+ +----+ +----+ +----+ +----+ // / / // / / // +----+ +----+ // | 11 | | 11 | // +----+ +----+ // \ \ // \ \ // +----+ +----+ // | 12 | | 12 | // +----+ +----+ SCENARIO("BST delete root with children", "[delete]") { BinarySearchTree<int> tree = {8, 4, 3, 10, 9, 13, 11, 12}; REQUIRE( tree.remove(8) ); REQUIRE( tree == BinarySearchTree<int>({9, 4, 3, 10, 13, 11, 12}) ); } // +----+ +----+ // | 08 | | 08 | // +----+ +----+ // /\ /\ // / \ / \ // +----+ +----+ +----+ +----+ // | 04 | | 10 | | 04 | | 10 | // +----+ +----+ +----+ +----+ // / /\ /\ // / / \ / \ // +----+ +----+ +----+ 03 +----+ +----+ // |-03-| | 09 | | 13 | ----> | 09 | | 13 | // +----+ +----+ +----+ +----+ +----+ // / / // / / // +----+ +----+ // | 11 | | 11 | // +----+ +----+ // \ \ // \ \ // +----+ +----+ // | 12 | | 12 | // +----+ +----+ SCENARIO("BST delete non root without children", "[delete]") { BinarySearchTree<int> tree = {8, 4, 3, 10, 9, 13, 11, 12}; REQUIRE( tree.remove(3) ); REQUIRE( tree == BinarySearchTree<int>({8, 4, 10, 9, 13, 11, 12}) ); } // +----+ +----+ // | 08 | | 08 | // +----+ +----+ // /\ /\ // / \ / \ // +----+ +----+ +----+ +----+ // | 04 | | 10 | | 04 | | 10 | // +----+ +----+ +----+ +----+ // / /\ / /\ // / / \ / / \ // +----+ +----+ +----+ 11 +----+ +----+ +----+ // | 03 | | 09 | | 13 | ----> | 03 | | 09 | | 13 | // +----+ +----+ +----+ +----+ +----+ +----+ // / / // / / // +----+ +----+ // |-11-| | 12 | // +----+ +----+ // \ // \ // +----+ // | 12 | // +----+ SCENARIO("BST delete non root with one child", "[delete]") { BinarySearchTree<int> tree = {8, 4, 3, 10, 9, 13, 11, 12}; REQUIRE( tree.remove(11) ); REQUIRE( tree == BinarySearchTree<int>({8, 4, 3, 10, 9, 13, 12}) ); } // +----+ +----+ // | 08 | | 08 | // +----+ +----+ // /\ /\ // / \ / \ // +----+ +----+ +----+ +----+ // | 04 | |-10-| | 04 | | 11 | // +----+ +----+ +----+ +----+ // / /\ / /\ // / / \ / / \ // +----+ +----+ +----+ 10 +----+ +----+ +----+ // | 03 | | 09 | | 13 | ----> | 03 | | 09 | | 13 | // +----+ +----+ +----+ +----+ +----+ +----+ // / / // / / // +----+ +----+ // | 11 | | 12 | // +----+ +----+ // \ // \ // +----+ // | 12 | // +----+ SCENARIO("BST delete non root with children", "[delete]") { BinarySearchTree<int> tree = {8, 4, 3, 10, 9, 13, 11, 12}; REQUIRE( tree.remove(10) ); REQUIRE( tree == BinarySearchTree<int>({8, 4, 3, 11, 9, 13, 12}) ); }
f7c5c07610c3f0cf930b6aa2a5e5d28b731efbc1
cf4edc2a34c4627d45c47feeacf2acf079aa596f
/source/QAbstractTextDocumentLayout.cpp
fd7ae2a5bea2237ad4865bb795b85c695260f16f
[ "MIT" ]
permissive
diegopego/Qt4xHb
eeb7c3e33b570193469bfca47d7d1835c2efbc38
5f96614f794cc8392b4d97f7dcd80b2fbf46ab65
refs/heads/master
2021-01-09T05:55:50.167467
2017-02-01T22:44:30
2017-02-01T22:44:30
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
5,477
cpp
QAbstractTextDocumentLayout.cpp
/* Qt4xHb - bibliotecas de ligaรงรฃo entre Harbour/xHarbour e Qt Framework 4 Copyright (C) 2012-2017 Marcos Antonio Gambeta <marcosgambeta@uol.com.br> */ #include <QAbstractTextDocumentLayout> #include "hbapi.h" #include "hbapiitm.h" #include "hbapierr.h" #include "hbvm.h" #include "hbstack.h" #ifndef __XHARBOUR__ #include "hbapicls.h" #define ISNIL HB_ISNIL #define ISLOG HB_ISLOG #define ISNUM HB_ISNUM #define ISCHAR HB_ISCHAR #define ISPOINTER HB_ISPOINTER #define ISOBJECT HB_ISOBJECT #define ISARRAY HB_ISARRAY #endif #include "qt4xhb_clsid.h" #include "qt4xhb_utils.h" /* QString anchorAt ( const QPointF & position ) const */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_ANCHORAT ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { QPointF * par1 = (QPointF *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ); QString str1 = obj->anchorAt ( *par1 ); hb_retc( (const char *) str1.toLatin1().data() ); } } /* virtual QRectF blockBoundingRect ( const QTextBlock & block ) const = 0 */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_BLOCKBOUNDINGRECT ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { QTextBlock * par1 = (QTextBlock *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ); QRectF * ptr = new QRectF( obj->blockBoundingRect ( *par1 ) ); _qt4xhb_createReturnClass ( ptr, "QRECTF", true ); } } /* QTextDocument * document () const */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_DOCUMENT ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { QTextDocument * ptr = obj->document ( ); _qt4xhb_createReturnClass ( ptr, "QTEXTDOCUMENT" ); } } /* virtual QSizeF documentSize () const = 0 */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_DOCUMENTSIZE ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { QSizeF * ptr = new QSizeF( obj->documentSize ( ) ); _qt4xhb_createReturnClass ( ptr, "QSIZEF", true ); } } /* virtual QRectF frameBoundingRect ( QTextFrame * frame ) const = 0 */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_FRAMEBOUNDINGRECT ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { QTextFrame * par1 = (QTextFrame *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ); QRectF * ptr = new QRectF( obj->frameBoundingRect ( par1 ) ); _qt4xhb_createReturnClass ( ptr, "QRECTF", true ); } } /* QTextObjectInterface * handlerForObject ( int objectType ) const */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_HANDLERFOROBJECT ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { int par1 = hb_parni(1); QTextObjectInterface * ptr = obj->handlerForObject ( par1 ); _qt4xhb_createReturnClass ( ptr, "QTEXTOBJECTINTERFACE" ); } } /* virtual int hitTest ( const QPointF & point, Qt::HitTestAccuracy accuracy ) const = 0 */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_HITTEST ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { QPointF * par1 = (QPointF *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ); int par2 = hb_parni(2); int i = obj->hitTest ( *par1, (Qt::HitTestAccuracy) par2 ); hb_retni( i ); } } /* virtual int pageCount () const = 0 */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_PAGECOUNT ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { int i = obj->pageCount ( ); hb_retni( i ); } } /* QPaintDevice * paintDevice () const */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_PAINTDEVICE ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { QPaintDevice * ptr = obj->paintDevice ( ); _qt4xhb_createReturnClass ( ptr, "QPAINTDEVICE" ); } } /* void registerHandler ( int objectType, QObject * component ) */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_REGISTERHANDLER ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { int par1 = hb_parni(1); QObject * par2 = (QObject *) hb_itemGetPtr( hb_objSendMsg( hb_param(2, HB_IT_OBJECT ), "POINTER", 0 ) ); obj->registerHandler ( par1, par2 ); } hb_itemReturn( hb_stackSelfItem() ); } /* void setPaintDevice ( QPaintDevice * device ) */ HB_FUNC( QABSTRACTTEXTDOCUMENTLAYOUT_SETPAINTDEVICE ) { QAbstractTextDocumentLayout * obj = (QAbstractTextDocumentLayout *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) ); if( obj ) { QPaintDevice * par1 = (QPaintDevice *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ); obj->setPaintDevice ( par1 ); } hb_itemReturn( hb_stackSelfItem() ); }
320493c3d565993d40636bb565da8bb296f9d1cb
5261689e7c9114dfd89786358edc0a35e69ab57f
/cf-644b.cpp
9d7f162e6ed0b38a3fde6839fbecb3b133815fde
[]
no_license
shobhitkrsks/cp
bec5f36d5a8ff9684321099dc3244284f517ab43
e551af079b4c1a4c1803b555ab9d3eec194910c5
refs/heads/master
2023-06-06T19:52:31.999545
2021-07-05T18:57:52
2021-07-05T18:57:52
248,814,534
0
0
null
null
null
null
UTF-8
C++
false
false
565
cpp
cf-644b.cpp
#include<iostream> #include<bits/stdc++.h> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int tc; cin>>tc; while(tc--) { int n; cin>>n; int ar[n]; for(int i=0;i<n;i++) cin>>ar[i]; sort(ar,ar+n); int diff[n]; diff[0]=INT_MAX; for(int i=1;i<n;i++) { diff[i]=ar[i]-ar[i-1]; } cout<<*min_element(diff+1,diff+n)<<"\n"; } return 0; }
fdf82a5a380a6eb68f5bd9d30213f426bae23017
fb283e5049c58ed19679d710d1635a897a4f68a9
/include/SDLpp/meta/is_sdlpp_flag.hpp
a9ff4ba0199d7c668cd95782445ceb4f934b32b2
[ "MIT" ]
permissive
rbrugo/SDLpp
d84ad77058d5ded1b46cf9511a4b35d65a69f901
0387589065ac0a31d93945c0546f64330d824bf9
refs/heads/master
2023-03-21T23:21:52.418712
2018-04-29T23:22:58
2018-04-29T23:22:58
125,532,038
0
0
null
null
null
null
UTF-8
C++
false
false
612
hpp
is_sdlpp_flag.hpp
/** * @author : Riccardo Brugo (brugo.riccardo@gmail.com) * @file : meta * @created : Tuesday Mar 27, 2018 11:53:11 CEST * @license : MIT * */ #ifndef SDLPP_META_IS_SDLPP_FLAG_HPP #define SDLPP_META_IS_SDLPP_FLAG_HPP #include <type_traits> #include "../init_flags.hpp" #include "../img_flags.hpp" namespace SDLpp { namespace meta { template <class T> constexpr bool is_sdlpp_flag = std::is_same_v<std::decay_t<T>,flag::init> || std::is_same_v<std::decay_t<T>,flag::img>; } // namespace meta } // namespace SDLpp #endif /* SDLPP_META_IS_SDLPP_FLAG_HPP */
e611901493d6f4c65149d69795333ca5e637a7de
846dbab53e69d39ad4b4afb3c52f311ca6fee96f
/AMR_NB_COVER/coder/huangmethod.cpp
c00e7bb25abbb7410fcd741a469d420503573d28
[]
no_license
ToughmanL/ENCODE_AMR_NB-WB
bb6b7852337d38eeceade1dc1ad564a14005a421
cac229b0c0f7d0d8fc21f943ae0a3cf897469283
refs/heads/master
2020-05-24T07:39:18.445743
2019-05-17T07:45:59
2019-05-17T07:45:59
187,164,989
5
0
null
null
null
null
UTF-8
C++
false
false
26
cpp
huangmethod.cpp
#include "huangmethod.h"
b7fefb3cc070967a748712c7f6cd907b29d76b5e
6b2a39df2cd6e626ca042b80d98003f9e47a0b02
/Leetcode/StrobogrammaticNumber.cpp
8e2f42dcb37528127ecbcf89350c9d2ac61bf733
[]
no_license
ShuhengLi/LeetCode
0b7db0eaee71b13a8c6324cd837324db31560247
f882fc0fd58857dafdd4b41b1b89c10e56a3f23d
refs/heads/master
2021-06-07T21:15:54.639277
2020-10-20T22:02:46
2020-10-20T22:02:46
28,899,606
0
0
null
null
null
null
UTF-8
C++
false
false
825
cpp
StrobogrammaticNumber.cpp
/* A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number is strobogrammatic. The number is represented as a string. For example, the numbers "69", "88", and "818" are all strobogrammatic. Author: Shuheng Li */ public class Solution { public boolean isStrobogrammatic(String num) { for (int i = 0; i <= num.length() / 2; i++) { char a = num.charAt(i); char b = num.charAt(num.length() - 1 - i); if (!isValid(a, b)) { return false; } } return true; } private boolean isValid(char c, char b) { switch (c) { case '1': return b == '1'; case '6': return b == '9'; case '9': return b == '6'; case '8': return b == '8'; case '0': return b == '0'; default: return false; } } }
5babe17549c4701f42d3b087d87188a224fcf6bf
83c0700a9b14dbd2eed4ad9abe7594a8ff12ce0a
/services/audiopolicy/common/managerdefinitions/include/AudioProfile.h
404e27d5600fd389a30efaa7a090d75b7872a961
[ "LicenseRef-scancode-unicode", "Apache-2.0" ]
permissive
PixelExperience/frameworks_av
e5ab74641a88237ac84ff698539c95033a3aa09f
10d08c030053cbcb30d114630b3276fddce96a45
refs/heads/oreo-mr1
2023-08-05T20:29:20.970331
2018-12-04T20:38:27
2018-12-04T20:38:27
130,521,429
8
167
NOASSERTION
2023-07-15T06:06:36
2018-04-22T00:10:21
C++
UTF-8
C++
false
false
12,243
h
AudioProfile.h
/* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "policy.h" #include <utils/String8.h> #include <utils/SortedVector.h> #include <utils/RefBase.h> #include <utils/Errors.h> #include <system/audio.h> #include <cutils/config_utils.h> namespace android { typedef SortedVector<uint32_t> SampleRateVector; typedef SortedVector<audio_channel_mask_t> ChannelsVector; typedef Vector<audio_format_t> FormatVector; template <typename T> bool operator == (const SortedVector<T> &left, const SortedVector<T> &right); class AudioProfile : public virtual RefBase { public: AudioProfile(audio_format_t format, audio_channel_mask_t channelMasks, uint32_t samplingRate) : mName(String8("")), mFormat(format) { mChannelMasks.add(channelMasks); mSamplingRates.add(samplingRate); } AudioProfile(audio_format_t format, const ChannelsVector &channelMasks, const SampleRateVector &samplingRateCollection) : mName(String8("")), mFormat(format), mChannelMasks(channelMasks), mSamplingRates(samplingRateCollection) {} audio_format_t getFormat() const { return mFormat; } void setChannels(const ChannelsVector &channelMasks) { if (mIsDynamicChannels) { mChannelMasks = channelMasks; } } const ChannelsVector &getChannels() const { return mChannelMasks; } void setSampleRates(const SampleRateVector &sampleRates) { if (mIsDynamicRate) { mSamplingRates = sampleRates; } } const SampleRateVector &getSampleRates() const { return mSamplingRates; } bool isValid() const { return hasValidFormat() && hasValidRates() && hasValidChannels(); } void clear() { if (mIsDynamicChannels) { mChannelMasks.clear(); } if (mIsDynamicRate) { mSamplingRates.clear(); } } inline bool supportsChannels(audio_channel_mask_t channels) const { return mChannelMasks.indexOf(channels) >= 0; } inline bool supportsRate(uint32_t rate) const { return mSamplingRates.indexOf(rate) >= 0; } status_t checkExact(uint32_t rate, audio_channel_mask_t channels, audio_format_t format) const; status_t checkCompatibleChannelMask(audio_channel_mask_t channelMask, audio_channel_mask_t &updatedChannelMask, audio_port_type_t portType, audio_port_role_t portRole) const; status_t checkCompatibleSamplingRate(uint32_t samplingRate, uint32_t &updatedSamplingRate) const; bool hasValidFormat() const { return mFormat != AUDIO_FORMAT_DEFAULT; } bool hasValidRates() const { return !mSamplingRates.isEmpty(); } bool hasValidChannels() const { return !mChannelMasks.isEmpty(); } void setDynamicChannels(bool dynamic) { mIsDynamicChannels = dynamic; } bool isDynamicChannels() const { return mIsDynamicChannels; } void setDynamicRate(bool dynamic) { mIsDynamicRate = dynamic; } bool isDynamicRate() const { return mIsDynamicRate; } void setDynamicFormat(bool dynamic) { mIsDynamicFormat = dynamic; } bool isDynamicFormat() const { return mIsDynamicFormat; } bool isDynamic() { return mIsDynamicFormat || mIsDynamicChannels || mIsDynamicRate; } void dump(int fd, int spaces) const; private: String8 mName; audio_format_t mFormat; ChannelsVector mChannelMasks; SampleRateVector mSamplingRates; bool mIsDynamicFormat = false; bool mIsDynamicChannels = false; bool mIsDynamicRate = false; }; class AudioProfileVector : public Vector<sp<AudioProfile> > { public: ssize_t add(const sp<AudioProfile> &profile) { ssize_t index = Vector::add(profile); // we sort from worst to best, so that AUDIO_FORMAT_DEFAULT is always the first entry. // TODO: compareFormats could be a lambda to convert between pointer-to-format to format: // [](const audio_format_t *format1, const audio_format_t *format2) { // return compareFormats(*format1, *format2); // } sort(compareFormats); return index; } // This API is intended to be used by the policy manager once retrieving capabilities // for a profile with dynamic format, rate and channels attributes ssize_t addProfileFromHal(const sp<AudioProfile> &profileToAdd) { // Check valid profile to add: if (!profileToAdd->hasValidFormat()) { return -1; } if (!profileToAdd->hasValidChannels() && !profileToAdd->hasValidRates()) { FormatVector formats; formats.add(profileToAdd->getFormat()); setFormats(FormatVector(formats)); return 0; } if (!profileToAdd->hasValidChannels() && profileToAdd->hasValidRates()) { setSampleRatesFor(profileToAdd->getSampleRates(), profileToAdd->getFormat()); return 0; } if (profileToAdd->hasValidChannels() && !profileToAdd->hasValidRates()) { setChannelsFor(profileToAdd->getChannels(), profileToAdd->getFormat()); return 0; } // Go through the list of profile to avoid duplicates for (size_t profileIndex = 0; profileIndex < size(); profileIndex++) { const sp<AudioProfile> &profile = itemAt(profileIndex); if (profile->isValid() && profile == profileToAdd) { // Nothing to do return profileIndex; } } profileToAdd->setDynamicFormat(true); // set the format as dynamic to allow removal return add(profileToAdd); } sp<AudioProfile> getFirstValidProfile() const { for (size_t i = 0; i < size(); i++) { if (itemAt(i)->isValid()) { return itemAt(i); } } return 0; } bool hasValidProfile() const { return getFirstValidProfile() != 0; } status_t checkExactProfile(uint32_t samplingRate, audio_channel_mask_t channelMask, audio_format_t format) const; status_t checkCompatibleProfile(uint32_t &samplingRate, audio_channel_mask_t &channelMask, audio_format_t &format, audio_port_type_t portType, audio_port_role_t portRole) const; FormatVector getSupportedFormats() const { FormatVector supportedFormats; for (size_t i = 0; i < size(); i++) { if (itemAt(i)->hasValidFormat()) { supportedFormats.add(itemAt(i)->getFormat()); } } return supportedFormats; } bool hasDynamicProfile() const { for (size_t i = 0; i < size(); i++) { if (itemAt(i)->isDynamic()) { return true; } } return false; } bool hasDynamicFormat() const { return getProfileFor(gDynamicFormat) != 0; } bool hasDynamicChannelsFor(audio_format_t format) const { for (size_t i = 0; i < size(); i++) { sp<AudioProfile> profile = itemAt(i); if (profile->getFormat() == format && profile->isDynamicChannels()) { return true; } } return false; } bool hasDynamicRateFor(audio_format_t format) const { for (size_t i = 0; i < size(); i++) { sp<AudioProfile> profile = itemAt(i); if (profile->getFormat() == format && profile->isDynamicRate()) { return true; } } return false; } // One audio profile will be added for each format supported by Audio HAL void setFormats(const FormatVector &formats) { // Only allow to change the format of dynamic profile sp<AudioProfile> dynamicFormatProfile = getProfileFor(gDynamicFormat); if (dynamicFormatProfile == 0) { return; } for (size_t i = 0; i < formats.size(); i++) { sp<AudioProfile> profile = new AudioProfile(formats[i], dynamicFormatProfile->getChannels(), dynamicFormatProfile->getSampleRates()); profile->setDynamicFormat(true); profile->setDynamicChannels(dynamicFormatProfile->isDynamicChannels()); profile->setDynamicRate(dynamicFormatProfile->isDynamicRate()); add(profile); } } void clearProfiles() { for (size_t i = size(); i != 0; ) { sp<AudioProfile> profile = itemAt(--i); if (profile->isDynamicFormat() && profile->hasValidFormat()) { removeAt(i); continue; } profile->clear(); } } void dump(int fd, int spaces) const { const size_t SIZE = 256; char buffer[SIZE]; snprintf(buffer, SIZE, "%*s- Profiles:\n", spaces, ""); write(fd, buffer, strlen(buffer)); for (size_t i = 0; i < size(); i++) { snprintf(buffer, SIZE, "%*sProfile %zu:", spaces + 4, "", i); write(fd, buffer, strlen(buffer)); itemAt(i)->dump(fd, spaces + 8); } } private: void setSampleRatesFor(const SampleRateVector &sampleRates, audio_format_t format) { for (size_t i = 0; i < size(); i++) { sp<AudioProfile> profile = itemAt(i); if (profile->getFormat() == format && profile->isDynamicRate()) { if (profile->hasValidRates()) { // Need to create a new profile with same format sp<AudioProfile> profileToAdd = new AudioProfile(format, profile->getChannels(), sampleRates); profileToAdd->setDynamicFormat(true); // need to set to allow cleaning add(profileToAdd); } else { profile->setSampleRates(sampleRates); } return; } } } void setChannelsFor(const ChannelsVector &channelMasks, audio_format_t format) { for (size_t i = 0; i < size(); i++) { sp<AudioProfile> profile = itemAt(i); if (profile->getFormat() == format && profile->isDynamicChannels()) { if (profile->hasValidChannels()) { // Need to create a new profile with same format sp<AudioProfile> profileToAdd = new AudioProfile(format, channelMasks, profile->getSampleRates()); profileToAdd->setDynamicFormat(true); // need to set to allow cleaning add(profileToAdd); } else { profile->setChannels(channelMasks); } return; } } } sp<AudioProfile> getProfileFor(audio_format_t format) const { for (size_t i = 0; i < size(); i++) { if (itemAt(i)->getFormat() == format) { return itemAt(i); } } return 0; } static int compareFormats(const sp<AudioProfile> *profile1, const sp<AudioProfile> *profile2); }; bool operator == (const AudioProfile &left, const AudioProfile &right); }; // namespace android
e74059502f037aaa343980ed36df293bd9b44683
d0a41eaec94af083ad540662a302e74f667972a7
/BZOJ1631.cpp
ad518766ef81d783107345518aa5b1bba1b02954
[]
no_license
fstqwq/BZOJ
0ee9c2a89592a63b1e4f8a1953f21ffb1cb35e4f
5b68a148013889a585bed219cd524119f9ea54e4
refs/heads/master
2021-01-12T09:59:44.182167
2016-12-13T10:31:47
2016-12-13T10:31:47
76,328,920
0
0
null
null
null
null
UTF-8
C++
false
false
1,984
cpp
BZOJ1631.cpp
/* Never stop fighting for what you believe in. */ #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <ctime> #include <cstdlib> #include <algorithm> #include <queue> #include <string> using namespace std; int ch=0; inline void read(int &a) { while (ch<'0' || ch>'9') ch=getchar(); a=0; while (ch>='0' && ch<='9') {a=a*10+ch-'0';ch=getchar();} } #define MAXN 1005 #define MAXM 100005 struct Readedge { int u,v,w; }re[MAXM]; struct edge { int next,to,w; }e[MAXM<<1]; /*#define TOP 1023 struct queue { int v[TOP+1],head,tail; queue():head(1048576),tail(1048576){} int &operator [](int x) {return v[x];} void push_back(int x) { v[(tail++)&TOP]=x; } void push_front(int x) { v[(--head)&TOP]=x; } void pop_front() { head++; } bool empty() { return head>=tail; } int front() { return v[head&TOP]; } }q;*/ queue<int> q; int n,m,ecnt,X,dis[MAXN],head[MAXN],dd[MAXN],ans=0; inline void add(int u,int v,int w) { e[++ecnt].to=v; e[ecnt].next=head[u]; e[ecnt].w=w; head[u]=ecnt; } bool inq[MAXN]; void spfa() { memset(dis,0x7f,sizeof(dis)); dis[X]=0; q.push(X); while (!q.empty()) { int x=q.front();q.pop(); inq[x]=0; for (int now=head[x];now;now=e[now].next) { if (dis[x]+e[now].w<dis[e[now].to]) { dis[e[now].to]=dis[x]+e[now].w; if (!inq[e[now].to]) { inq[e[now].to]=1; if (dis[e[now].to]<dis[q.front()]) q.push(e[now].to); else q.push(e[now].to); } } } } } int main() { read(n);read(m);read(X); for (int i=1;i<=m;i++) { read(re[i].u);read(re[i].v);read(re[i].w); } ecnt=0; for (int i=1;i<=m;i++) { add(re[i].u,re[i].v,re[i].w); } spfa(); for (int i=1;i<=n;i++) dd[i]=dis[i]; memset(head,0,sizeof(head)); ecnt=0; for (int i=1;i<=m;i++) { add(re[i].v,re[i].u,re[i].w); } spfa(); for (int i=1;i<=n;i++) ans=max(ans,dd[i]+dis[i]); printf("%d\n",ans); return 0; }
63dc10ee1ae1acc9739a4ea3bfcfaa4cd32dbbfa
718b1f214497b13cdcabd529c0310298420876f1
/CleanMac/Pods/MMKV/iOS/MMKV/MMKV/aes/openssl/openssl_cfb128.cpp
0b0192fb762700e5e1075739d395291f5655cd79
[ "BSD-3-Clause", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "OpenSSL", "Zlib", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
helinyu/Mac_app
3da9df6a86cb6593981710865ff7f39d34789736
7e92c2a63c1687151e5cf2d5e390136b5df0bbbf
refs/heads/master
2021-08-22T11:42:32.513969
2020-06-17T11:52:35
2020-06-17T11:52:35
195,726,888
8
3
MIT
2019-07-16T12:43:29
2019-07-08T03:01:16
Objective-C
UTF-8
C++
false
false
4,254
cpp
openssl_cfb128.cpp
/* * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include "openssl_aes.h" #include "openssl_modes.h" #include <string.h> namespace openssl { /* * The input and output encrypted as though 128bit cfb mode is being used. * The extra state information to record how much of the 128bit block we have * used is contained in *num; */ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, unsigned char ivec[16], int *num, int enc, block128_f block) { unsigned int n; size_t l = 0; n = *num; if (enc) { #if !defined(OPENSSL_SMALL_FOOTPRINT) if (16 % sizeof(size_t) == 0) { /* always true actually */ do { while (n && len) { *(out++) = ivec[n] ^= *(in++); --len; n = (n + 1) % 16; } # if defined(STRICT_ALIGNMENT) if (((size_t)in | (size_t)out | (size_t)ivec) % sizeof(size_t) != 0) break; # endif while (len >= 16) { (*block) (ivec, ivec, key); for (; n < 16; n += sizeof(size_t)) { *(size_t *)(out + n) = *(size_t *)(ivec + n) ^= *(size_t *)(in + n); } len -= 16; out += 16; in += 16; n = 0; } if (len) { (*block) (ivec, ivec, key); while (len--) { out[n] = ivec[n] ^= in[n]; ++n; } } *num = n; return; } while (0); } /* the rest would be commonly eliminated by x86* compiler */ #endif while (l < len) { if (n == 0) { (*block) (ivec, ivec, key); } out[l] = ivec[n] ^= in[l]; ++l; n = (n + 1) % 16; } *num = n; } else { #if !defined(OPENSSL_SMALL_FOOTPRINT) if (16 % sizeof(size_t) == 0) { /* always true actually */ do { while (n && len) { unsigned char c; *(out++) = ivec[n] ^ (c = *(in++)); ivec[n] = c; --len; n = (n + 1) % 16; } # if defined(STRICT_ALIGNMENT) if (((size_t)in | (size_t)out | (size_t)ivec) % sizeof(size_t) != 0) break; # endif while (len >= 16) { (*block) (ivec, ivec, key); for (; n < 16; n += sizeof(size_t)) { size_t t = *(size_t *)(in + n); *(size_t *)(out + n) = *(size_t *)(ivec + n) ^ t; *(size_t *)(ivec + n) = t; } len -= 16; out += 16; in += 16; n = 0; } if (len) { (*block) (ivec, ivec, key); while (len--) { unsigned char c; out[n] = ivec[n] ^ (c = in[n]); ivec[n] = c; ++n; } } *num = n; return; } while (0); } /* the rest would be commonly eliminated by x86* compiler */ #endif while (l < len) { unsigned char c; if (n == 0) { (*block) (ivec, ivec, key); } out[l] = ivec[n] ^ (c = in[l]); ivec[n] = c; ++l; n = (n + 1) % 16; } *num = n; } } } // namespace openssl
4709c665767820ecdfbb3c203c88a71c7866fc4a
0f5507dba517e8cab3a8a3c66c3eec18746b8d87
/List_contact.h
b7a3a1222b06f0e928bc247a926554bfac2eb689
[]
no_license
Priyanka-Manchanda/Phone_book_management
b53385e801cdfb5e67cf3e48ad654864597d8905
d1eac75088f13de174169b4243793c20c31780f7
refs/heads/main
2023-01-10T06:42:05.631382
2020-11-02T17:39:37
2020-11-02T17:39:37
309,447,396
0
0
null
null
null
null
UTF-8
C++
false
false
205
h
List_contact.h
#pragma once #include<vector> #include "Contact.h" class List_contact:public Contact { public: void add_contact(); void display_contact(); protected: std::vector<Contact> contact_info; };
7584db0b6ed8224bf423e6a1cedbfd39c3dd3cae
338a1d3e2adf05e51c795decac3a9c71d1fd28ac
/WildcardMatching.cpp
1f7426af3721f447e2a0a09fc98eb6c31ad766b2
[]
no_license
devanshdalal/leetcode-solutions
84e3da0cad20792d05770b5467e51947f7d0c166
b8d164c5f968b87562e91eecec09f299bb94bbc7
refs/heads/master
2021-03-27T10:20:53.195292
2017-02-12T08:36:46
2017-02-12T08:36:46
81,712,752
0
0
null
null
null
null
UTF-8
C++
false
false
975
cpp
WildcardMatching.cpp
class Solution { public: bool equal(char c1,char c2){ return c1==c2 or c2=='?' or c1=='?'; } bool isMatch(string s, string p) { int n = s.length(); int m = p.length(); bool d[n+1][m+1]; // dp(i,j) = isMatch(s[0:i-1],p[0:j-1]) d[0][0]=1; for(int i=1;i<=n;i++){ d[i][0]= 0; } for(int j=1;j<=m;j++){ d[0][j]= d[0][j-1] && p[j-1]=='*'; } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ d[i][j]=0; if( p[j-1]!='*' ){ d[i][j]= (d[i-1][j-1] and equal(s[i-1],p[j-1]) ); }else{ d[i][j]= (d[i][j-1] or d[i-1][j] ); } } } return d[n][m]; } };
d095cff3fddac3cd457cd503260d8b8320d39935
f3b7e8dcab9f7ef2f833a555bfa5d411b3e46f47
/jcx/thread/IThreadImp.h
4c35428bd8a81af95cfb89e49b7ca23eed82f8bc
[]
no_license
yunccll/jcx
4589b02ef552dd621cb78127e56357d24b89f343
84ff67c2195a8cb06529cf8418cb20086c9bd704
refs/heads/master
2020-04-16T01:59:17.128651
2019-07-08T09:36:17
2019-07-08T09:36:17
165,193,734
0
0
null
null
null
null
UTF-8
C++
false
false
785
h
IThreadImp.h
#ifndef JCX_THREAD_ITHREADIMP_H #define JCX_THREAD_ITHREADIMP_H #include <jcx/base/Macro.h> namespace jcx { namespace thread { typedef void * (*ThreadEntry)(void * ctx); class IThreadImp { public: IThreadImp() {} virtual ~IThreadImp() {} virtual IThreadImp & entry(ThreadEntry entry) = 0; virtual ThreadEntry entry() const = 0; //virtual int id() = 0; //TODO: virtual int create(void * ctx) = 0; virtual int join() = 0; virtual int detach() = 0; static IThreadImp * newInstance(); static int id(); static unsigned int sleep(unsigned int sec); static int usleep(unsigned long long sec); private: JCX_NO_COPY_CTORS(IThreadImp); }; } // namespace thread } // namespace jcx #endif /* JCX_THREAD_ITHREADIMP_H */
1c409121d4f28d5002d4564b37b77373e9c32abf
27abcab06ef2c704347eef38477b9e15b8e94cb6
/tsc-support.cpp
9a8607000d16c152c4cb3e3ecd82722a54d0d0e6
[ "MIT" ]
permissive
travisdowns/avx-turbo
b5d439abb6dcf088b3bb62030b2b2507b9fb97f5
4a04a454feedb6402cd9d85fa6fda4d9c7ba47b4
refs/heads/master
2023-05-31T23:33:47.143323
2021-10-27T17:45:39
2021-10-27T17:45:39
145,263,040
155
19
MIT
2023-05-15T08:44:15
2018-08-19T01:01:28
C++
UTF-8
C++
false
false
3,320
cpp
tsc-support.cpp
/* * tsc-support.cpp */ #include "tsc-support.hpp" #include "cpuid.hpp" #include <cinttypes> #include <string> #include <cstdio> #include <cassert> #include <array> #include <algorithm> #include <numeric> #include <error.h> #include <time.h> using std::uint32_t; uint64_t get_tsc_from_cpuid_inner() { if (cpuid_highest_leaf() < 0x15) { std::printf("CPUID doesn't support leaf 0x15, falling back to manual TSC calibration.\n"); return 0; } auto cpuid15 = cpuid(0x15); std::printf("cpuid = %s\n", cpuid15.to_string().c_str()); if (cpuid15.ecx) { // the crystal frequency was present in ECX return (uint64_t)cpuid15.ecx * cpuid15.ebx / cpuid15.eax; } // ecx == 0 means we have to use a hard-coded frequency based on the model and table provided by Intel // in 18.7.3 auto family = get_family_model(); std::printf("cpu: %s\n", family.to_string().c_str()); if (family.family == 6) { if (family.model == 0x4E || family.model == 0x5E || family.model == 0x8E || family.model == 0x9E) { // skylake client or kabylake return (int64_t)24000000 * cpuid15.ebx / cpuid15.eax; // 24 MHz crystal clock } } else { std::printf("CPU family not 6 (perhaps AMD or old Intel), falling back to manual TSC calibration.\n"); } return 0; } uint64_t get_tsc_from_cpuid() { static auto cached = get_tsc_from_cpuid_inner(); return cached; } namespace Clock { static inline uint64_t nanos() { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return (uint64_t)ts.tv_sec * 1000000000 + ts.tv_nsec; } } constexpr size_t SAMPLES = 101; constexpr uint64_t DELAY_NANOS = 10000; // nanos 1us uint64_t do_sample() { _mm_lfence(); uint64_t nsbefore = Clock::nanos(); uint64_t tscbefore = rdtsc(); while (nsbefore + DELAY_NANOS > Clock::nanos()) ; uint64_t nsafter = Clock::nanos(); uint64_t tscafter = rdtsc(); return (tscafter - tscbefore) * 1000000000u / (nsafter - nsbefore); } uint64_t tsc_from_cal() { std::array<uint64_t, SAMPLES * 2> samples; for (size_t s = 0; s < SAMPLES * 2; s++) { samples[s] = do_sample(); } // throw out the first half of samples as a warmup std::array<uint64_t, SAMPLES> second_half; std::copy(samples.begin() + SAMPLES, samples.end(), second_half.begin()); std::sort(second_half.begin(), second_half.end()); // average the middle quintile auto third_quintile = second_half.begin() + 2 * SAMPLES/5; uint64_t sum = std::accumulate(third_quintile, third_quintile + SAMPLES/5, (uint64_t)0); return sum / (SAMPLES/5); } /** * TSC frequency detection is described in * Intel SDM Vol3 18.7.3: Determining the Processor Base Frequency * * Nominal TSC frequency = ( CPUID.15H.ECX[31:0] * CPUID.15H.EBX[31:0] ) รท CPUID.15H.EAX[31:0] */ uint64_t get_tsc_freq(bool force_calibrate) { uint64_t tsc; if (!force_calibrate && (tsc = get_tsc_from_cpuid())) { return tsc; } return tsc_from_cal(); } const char* get_tsc_cal_info(bool force_calibrate) { if (!force_calibrate && get_tsc_from_cpuid()) { return "from cpuid leaf 0x15"; } else { return "from calibration loop"; } }
248fa774c1673d4e275fb47523f87250e231d5f4
18d1ee0abc51a641c14b4292c22f5f7ea9b30c15
/Praktikum3_Aufgabe4/Numbers.h
f1fc7cdc9a12bebb731a82d95d0c9834ffa22db0
[]
no_license
KatharinaBergen/Praktikum3_Aufgabe4
3f586b3c107468a95d20e3806beb25ed67c1ed74
3a957c125f84be3c0efe453fcc5e6ada20c22f64
refs/heads/master
2022-10-09T08:03:19.897590
2020-06-14T10:42:42
2020-06-14T10:42:42
272,181,469
0
0
null
null
null
null
UTF-8
C++
false
false
926
h
Numbers.h
/* Author: Kat Bergen 12.06.2020 V1 header Numbers class, handeling input, sum calculation, output details: 1 User to input numbers stored in vector. 2 User to input index up to which the numbers in the vector will be added 3 function to add numbers returns result 4 output of all numbers so as to visualize caluclation operation to user 5 final output see main() P3A4 */ #pragma once #include <iostream> #include <vector> class Numbers { private: std::vector<double> numbers; unsigned int index; public: Numbers(); //standard constructor Numbers(const std::vector<double>&, const unsigned int&); //test case constructor unsigned int getIndex(); void inputNumbers(); //user input add number to vector void inputIndex(); //user input index up to which the numbers in vector to be added double result(); //calculation add numbers of vector up to index passed void print(); //print n numbers of vector };
690e0befa0e774bb292756fe9a9d5dfaee55a961
51e93691228d4212b91b6c61b4d83eb6a730d62e
/Solution/GUI/TextWidget.h
5a870d12ceaabe3c86ec6fbef50755e436300a40
[]
no_license
LastVision/DistortionGamesGrad
ec5bd7feafeb7c7741508a256ce834b8139b4087
329f39c3d6ca6497482643b6298c44d40a1ae0aa
refs/heads/master
2021-03-24T12:27:44.713118
2016-06-14T13:42:36
2016-06-14T13:42:36
57,017,978
0
1
null
null
null
null
UTF-8
C++
false
false
422
h
TextWidget.h
#pragma once #include "Widget.h" namespace GUI { class TextWidget : public Widget { public: TextWidget(XMLReader* aReader, tinyxml2::XMLElement* anXMLElement); ~TextWidget(); void Render(const CU::Vector2<float>& aParentPosition, float anAlpha) override; void OnResize(const CU::Vector2<float>& aNewSize, const CU::Vector2<float>& anOldSize) override; private: std::string myText; }; }
d684a058836225de1ecabfad411e74bedb3bdc45
b09de87297dde13c874d24db2541817d788b2594
/directX/sceneX.cpp
7daa0676d72ef75c4acedf308ed718ceced9e572
[]
no_license
tnbmi/TGS_20150327
f28e84aa846594c5753f249147376b350e916011
5e4f4ab119648207b6fe05c5819102f4a907845e
refs/heads/master
2020-03-31T02:13:59.268880
2015-03-29T15:38:51
2015-03-29T15:38:51
31,594,249
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
3,911
cpp
sceneX.cpp
//***************************************************************************** // // CSceneXใ‚ฏใƒฉใ‚น [sceneX.cpp] // Author :MAI TANABE // //***************************************************************************** //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // ใ‚คใƒณใ‚ฏใƒซใƒผใƒ‰ใƒ•ใ‚กใ‚คใƒซ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #include "sceneX.h" //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // ใƒžใ‚ฏใƒญๅฎš็พฉ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //============================================================================= // ใ‚ณใƒณใ‚นใƒˆใƒฉใ‚ฏใ‚ฟ //============================================================================= CSceneX::CSceneX(int priority, OBJTYPE objType) : CScene(priority, objType) { m_xFile.mesh = NULL; m_xFile.buffMat = NULL; m_rot = D3DXVECTOR3(0.0f, 0.0f, 0.0f); m_pos = D3DXVECTOR3(0.0f, 0.0f, 0.0f); m_scl = D3DXVECTOR3(1.0f, 1.0f, 1.0f); m_size = D3DXVECTOR3(1.0f, 1.0f, 1.0f); m_color = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); m_parent = NULL; } //============================================================================= // ็”Ÿๆˆ //============================================================================= CSceneX* CSceneX::Create(LPDIRECT3DDEVICE9 device, CImport::XFILES xFile) { CSceneX* pointer = new CSceneX; pointer->Init(device, xFile); return pointer; } //============================================================================= // ๅˆๆœŸๅŒ– //============================================================================= HRESULT CSceneX::Init(LPDIRECT3DDEVICE9 device, CImport::XFILES xFile) { //---------------------------- // ใƒ‡ใƒใ‚คใ‚นๅ–ๅพ— //---------------------------- m_device = device; //---------------------------- // ใƒขใƒ‡ใƒซๅ–ๅพ— //---------------------------- m_xFile = CImport::GetXFile(xFile); return S_OK; } //============================================================================= // ็ต‚ไบ† //============================================================================= void CSceneX::Uninit(void) { // ้–‹ๆ”พ CScene::Delete(); } //============================================================================= // ๆ›ดๆ–ฐ //============================================================================= void CSceneX::Update(void) { } //============================================================================= // ๆ็”ป //============================================================================= void CSceneX::Draw(void) { //---------------------------- // ใƒฏใƒผใƒซใƒ‰ใƒžใƒˆใƒชใƒƒใ‚ฏใ‚น //---------------------------- D3DXMATRIX scl, rot, translate; // ใƒฏใƒผใƒซใƒ‰ใƒžใƒˆใƒชใƒƒใ‚ฏใ‚นใฎๅˆๆœŸๅŒ– D3DXMatrixIdentity(&m_world); // ใ‚นใ‚ฑใƒผใƒซใฎๅๆ˜  D3DXMatrixScaling(&scl, m_scl.x, m_scl.y, m_scl.z); D3DXMatrixMultiply(&m_world, &m_world, &scl); // ๅ›ž่ปขใฎๅๆ˜  D3DXMatrixRotationYawPitchRoll(&rot, m_rot.y, m_rot.x, m_rot.z); D3DXMatrixMultiply(&m_world, &m_world, &rot); // ไฝ็ฝฎใฎๅๆ˜  D3DXMatrixTranslation(&translate, m_pos.x, m_pos.y, m_pos.z); D3DXMatrixMultiply(&m_world, &m_world, &translate); //่ฆชใŒๅญ˜ๅœจใ™ใ‚‹ๅ ดๅˆใฏ่ฆชใƒžใƒˆใƒชใ‚ฏใ‚นใ‚’ๅˆๆˆ if(m_parent) { D3DXMatrixMultiply(&m_world, &m_world, &m_parent->m_world); } // ใƒฏใƒผใƒซใƒ‰ใƒžใƒˆใƒชใƒƒใ‚ฏใ‚นใฎ่จญๅฎš m_device->SetTransform(D3DTS_WORLD, &m_world); //---------------------------- // ใƒขใƒ‡ใƒซใฎๆ็”ป //---------------------------- D3DMATERIAL9 matDef; m_device->GetMaterial(&matDef); // ็พๅœจใฎใƒžใƒ†ใƒชใ‚ขใƒซใ‚’ๅ–ๅพ— for(unsigned int cntMat = 0; cntMat < m_xFile.numMat; cntMat++) { m_device->SetMaterial(&m_xFile.mat[cntMat].MatD3D); m_device->SetTexture(0, m_xFile.tex[cntMat]); m_xFile.mesh->DrawSubset(cntMat); } m_device->SetMaterial(&matDef); // ใƒžใƒ†ใƒชใ‚ขใƒซใ‚’ๅ…ƒใซๆˆปใ™ }
833206335f10edabc35dbe495b40e6b7d6b35849
c2c3de55d08f5ef29043b97cf2de3304d029b878
/BaseScene.cpp
538f55cb704feab0e6bd65978bd39f79e2c66018
[]
no_license
qnpfrehdtks/DirectX11
c5de2a1d5a5c0c72e78e523b785fa0acafcaefa1
164e17ebd4cc6af75c2db1c6a07eb54aff5b048a
refs/heads/master
2020-03-29T08:24:37.016892
2018-09-21T04:34:15
2018-09-21T04:34:15
149,709,752
0
0
null
null
null
null
UTF-8
C++
false
false
367
cpp
BaseScene.cpp
#include "DXUT.h" #include "BaseScene.h" cBaseScene::cBaseScene(ID3D11Device* device, ID3D11DeviceContext * dc, ID3D11RenderTargetView * rtv, ID3D11DepthStencilView * dsv) : m_pDevice(device), m_pDC(dc), m_pDSV(dsv), m_pRTV(rtv) { } cBaseScene::~cBaseScene() { SAFE_RELEASE(m_pDevice); SAFE_RELEASE(m_pDC); SAFE_RELEASE(m_pDSV); SAFE_RELEASE(m_pRTV); }
b599db91a6f7ff2cbd3e0d1242c2bde743d998b0
4787ec00fc613eaa77256f35056bc6ad32a177dd
/course_work/Problem_1/Program.cpp
e22cae1100b4376963fe945af1dbeb58a7f58cec
[ "MIT" ]
permissive
pavelhristov/cplusplus
ad1c63b060a0ceedff6f7b8f0561837b2fe3f0ce
3731815fd5681cbc53b4415e2df2f42fc74aaef1
refs/heads/master
2020-06-07T07:10:33.291003
2019-06-20T17:30:17
2019-06-20T17:30:17
192,958,556
0
0
null
null
null
null
UTF-8
C++
false
false
350
cpp
Program.cpp
#include "ConsoleReader.h" #include "ConsoleWriter.h" #include "FileWriter.h" #include "FileReader.h" #include "Program.h" void Program::run(ConsoleReader& cReader, ConsoleWriter& cWriter, FileReader& fReader, FileWriter& fWriter) { Program program(cReader, cWriter, fReader, fWriter); program.initialaze(); program.start(); }
f0335ed5d4baa905e3f8752cbcc2742745c87c09
1a02d5ec307d643b00f1eb7315e179bc1b8e1e53
/testing/library_tests/game_class_tests.cpp
32cba9d74616516906f83d785ba65f219ab7f36f
[ "MIT" ]
permissive
devopsmi/ParallelisingConwaysGameOfLife
70b2f0e6d5009bee31988c7fc52f190d74ab94bd
ed91370f1c049a278f04db08e76eac22d72a6ead
refs/heads/master
2021-06-16T15:34:12.760823
2017-05-18T21:07:00
2017-05-18T21:07:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
897
cpp
game_class_tests.cpp
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #include <catch.hpp> #include "conway.h" TEST_CASE("ConwaysGameOfLife", "[conway_lib]") { size_t gridWidth = 2; size_t gridHeight = 1; cgol::GameGridSharedPtrT grid = std::make_shared<cgol::GameGrid>(gridWidth, gridHeight); cgol::ConwaysGameOfLife game(grid); // TODO: simple 3x3 board SECTION("Constructor") { cgol::GameGridSharedPtrT nullGame; REQUIRE_THROWS_AS(cgol::ConwaysGameOfLife(nullGame), std::runtime_error); } SECTION("Run Nullptr Strategy") { REQUIRE_THROWS_AS(game.run(nullptr, 1), std::runtime_error); } SECTION("Run Negative Steps") { REQUIRE_THROWS_AS(game.run(cgol::strategyCPU, -1), std::runtime_error); } SECTION("Strategy CPU - Game Logic") { game.run(cgol::strategyCPU, 5); } }
a560e52610c92f9b82c8cbfe2980de71725ae356
95e051bc96bd3f765ce1cec4868535b667be81b6
/ExplodedVolume/UserInterface/GeneratedFiles/qrc_UserInterface.cpp
2840b2a13e061e410605d11bd11d1ccc4275f4f5
[]
no_license
fabio-miranda/exploded
6aacdb5ca1250b676990572ef028fcbc0af93b1a
12ca185b161b78d0b903c86fb5a08cee3ed87362
refs/heads/master
2021-05-29T09:06:03.007813
2010-02-26T04:40:32
2010-02-26T04:40:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
740
cpp
qrc_UserInterface.cpp
/**************************************************************************** ** Resource object code ** ** Created: Thu 28. Jan 23:55:55 2010 ** by: The Resource Compiler for Qt version 4.6.1 ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include <QtCore/qglobal.h> QT_BEGIN_NAMESPACE QT_END_NAMESPACE int QT_MANGLE_NAMESPACE(qInitResources_UserInterface)() { return 1; } Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources_UserInterface)) int QT_MANGLE_NAMESPACE(qCleanupResources_UserInterface)() { return 1; } Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources_UserInterface))
98003b779843b452673cb84fe94897f0f748af7c
9a46b275537b13233542eb0c186752bf1b4f92cf
/src/msb.cpp
9831ab4c0faa5a7de7aa756e41d21f9d05a056da
[]
no_license
ironliuyi/Par-BF
6d3c6f741f5000c21f54e78bff03299d24a1d439
0f4d9726c8d59d297efb297e293969e6c173950c
refs/heads/master
2021-01-22T07:39:16.545825
2015-11-24T03:48:05
2015-11-24T03:48:05
31,349,292
3
1
null
null
null
null
UTF-8
C++
false
false
1,797
cpp
msb.cpp
/* * msb.cpp * * Created on: Oct 22, 2012 * Author: ubuntu */ #include "msb.h" /* Highest bit set in a byte */ const char bytemsb[0x100] = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, }; /* Least set bit (ffs) */ const char bytelsb[0x100] = { 0, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 8, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, };
14b2c2e7a4ec18e2a98062b75040c3045a8709d9
d213f2a47aa902f8b2f208850e131ab3e34ad17b
/Game1/PickupDef.cpp
86505ce409b95477f2e231ba3f4b1a960bbee756
[]
no_license
ntaylorbishop/HGAM_Roguelike
0f653bcd596b4e062db89c99ac2060cd1ee9857c
668c80f2171c5788543bddf04044b28170a72048
refs/heads/master
2020-04-26T09:57:11.557294
2015-03-25T22:16:13
2015-03-25T22:16:13
29,994,982
0
0
null
null
null
null
UTF-8
C++
false
false
901
cpp
PickupDef.cpp
#include "PickupDef.h" //STRUCTORS PickupDef::PickupDef() { this->tile = 0; this->name = name; this->desc = "NULL"; this->type = type; this->useEffect = [](){}; this->removeEffect = [](){}; } PickupDef::PickupDef(int tile, string name, int type, function<void()> useEffect) { this->tile = tile; this->name = name; this->desc = "NULL"; this->type = type; this->useEffect = useEffect; this->removeEffect = [](){}; } PickupDef::PickupDef(int tile, string name, string desc, int type, function<void()> useEffect, function<void()> removeEffect) { this->tile = tile; this->name = name; this->desc = desc; this->type = type; this->useEffect = useEffect; this->removeEffect = removeEffect; } //GETTERS / SETTERS int PickupDef::getTile() { return tile; } string PickupDef::getName() { return name; } string PickupDef::getDESC() { return desc; } int PickupDef::getType() { return type; }
2d5693f1b2f284f887992c7b68907d154b0da222
399b447bf4d82712ff85d8d1971b87737cc782ed
/src/Graphic.cpp
254ece7dfe6e05910b5ed7b5c685c30f6d9abfce
[]
no_license
zahrasadeghi/FinalProject
dd90a687faf9748ae0e8af649a871c344d23e81c
25448dbf607c3ecc6827238c7e7611aa172b4f20
refs/heads/master
2020-12-25T01:38:58.514803
2016-06-30T07:49:43
2016-06-30T07:49:43
62,124,572
0
0
null
2016-06-28T08:40:52
2016-06-28T08:40:52
null
UTF-8
C++
false
false
1,309
cpp
Graphic.cpp
#include "Graphic.h" Graphic::Graphic() { window = new sf::RenderWindow(sf::VideoMode(800, 600), "NetWars"); window->setFramerateLimit(30); isOpen = true; } void Graphic::start() { } void Graphic::main() { eventHandler(); drawObjects(); } Event Graphic::getEvent() { Event tmp; eventQmutex.lock(); if(!eventQ.empty()) { tmp = eventQ.front(); eventQ.pop(); } eventQmutex.unlock(); return tmp; } void Graphic::eventHandler() { sf::Event event; Event output; while(window->pollEvent(event)) { if(event.type == sf::Event::Closed) { isOpen = false; } } if(sf::Mouse::isButtonPressed(sf::Mouse::Left)) { output.clicked = true; } output.mousePos = window->mapPixelToCoords(sf::Mouse::getPosition(*window)); if(lastEvent != output) { eventQmutex.lock(); eventQ.push(output); eventQmutex.unlock(); lastEvent = output; } } void Graphic::draw(sf::Drawable* object) { objects.push_back(object); } void Graphic::drawObjects() { window->clear(); for(auto obj : objects) { window->draw(*obj); } window->display(); }
ebb7042f0a7d643ac5eab8046d0a3bdaa30e866f
05ba7a6a30f4a3453adcd882401dfd5a231f7f41
/Question48.cpp
61b318398a98a9586e5d9db5b3f5d2e8f66ba562
[]
no_license
MadhusmitaBehera/lab-3
7092fb074198d686f041c7c7a8a2dc31a7396c7e
3b193d496096a45874f2438c8dbe421f0e06f553
refs/heads/master
2021-01-23T19:33:48.176525
2017-09-14T11:32:07
2017-09-14T11:32:07
102,827,537
0
0
null
null
null
null
UTF-8
C++
false
false
470
cpp
Question48.cpp
#include <iostream> using namespace std; int main() { int N,i,j,isPrime,n; cout<<"\n Enter the value of N."; cin>>N; for(i=2;i<=N;i++) { isPrime==0; { for(j=2;j<=i/2;j++) if(i%j==0) { isPrime=1; break; } } if(isPrime==0 && N!=1) cout<<i<<""<<endl; } return 0; }
3d7f6914519b233b150300c64c6e9b840de21c13
5953564e57ed35973dac8b35b78ac524f978b709
/emc/hemcraw.h
d17bb30cf7c7989cbc3c606dbb331979ac2c2aff
[]
no_license
wesmail/hydra2-fwdet
ca9266b5f069d5c6d3a899d993f0248ce22b7329
f55563466c1145c46bdfc4d045a2e042417cfab3
refs/heads/master
2020-04-11T08:59:37.349179
2018-07-25T13:56:27
2018-07-25T13:56:27
161,662,474
0
0
null
null
null
null
UTF-8
C++
false
false
4,432
h
hemcraw.h
#ifndef HEMCRAW_H #define HEMCRAW_H ///////////////////////////////////////////////////////////// // // HEmcRaw // // Event data structure for HADES Electromagnetic Calorimeter (EMC). // first sketch bei I.Koenig 2017, // continued by JAM (j.adamczewski@gsi.de) 23-apr-2018 // ///////////////////////////////////////////////////////////// #include "TObject.h" #define NTIMESEMCRAW 10 class HEmcHit_t : public TObject { private: Float_t fLeadingEdgeTime; Float_t fTrailingEdgeTime; public: HEmcHit_t(Float_t leading=0., Float_t trailing=0.): fLeadingEdgeTime(leading), fTrailingEdgeTime(trailing){} Float_t getLeadingTime() const { return fLeadingEdgeTime; } Float_t getTrailingTime() const { return fTrailingEdgeTime; } void setTimes(Float_t leading, Float_t trailing) { fLeadingEdgeTime = leading; fTrailingEdgeTime = trailing; } void setTimes(HEmcHit_t& hit) { fLeadingEdgeTime = hit.getLeadingTime(); fTrailingEdgeTime = hit.getTrailingTime(); } Float_t getToT() const { if(fLeadingEdgeTime==0 || fTrailingEdgeTime==0) return -1; // detect incomplete edges return (fTrailingEdgeTime - fLeadingEdgeTime); } void clear() { fLeadingEdgeTime = 0; fTrailingEdgeTime = 0;} ClassDef(HEmcHit_t, 1) // object keeping leading and trailing edge times }; class HEmcRaw : public TObject { private: Char_t fSector; // sector number UChar_t fCell; // cell number Char_t fRow; // row number (0..14) Char_t fColumn; // column number (0..16) HEmcHit_t fFastHits[NTIMESEMCRAW]; HEmcHit_t fSlowHits[NTIMESEMCRAW]; UInt_t fnFast; UInt_t fnSlow; public: HEmcRaw() :fSector(-1),fCell(0),fRow(0),fColumn(0) {clearHits();} virtual ~HEmcRaw() {} Char_t getSector() const { return fSector; } UChar_t getCell() const { return fCell; } Char_t getRow(void) const {return fRow;} Char_t getColumn(void) const {return fColumn;} UInt_t getFastMultiplicity() const { return fnFast; } UInt_t getSlowMultiplicity() const { return fnSlow; } Float_t getFastTimeLeading(UInt_t n) const; Float_t getFastTimeTrailing(UInt_t n) const; Float_t getSlowTimeLeading(UInt_t n) const; Float_t getSlowTimeTrailing(UInt_t n) const; Float_t getFastWidth(UInt_t n) const; Float_t getSlowWidth(UInt_t n) const; void getFastTimeAndWidth(UInt_t n, Float_t& s, Float_t& c) const; void getSlowTimeAndWidth(UInt_t n, Float_t& s, Float_t& c) const; void getAddress(Int_t& s, Int_t& c, Char_t& ro, Char_t& co) const; void setSector(Char_t s) { fSector = s; } void setCell(UChar_t c) { fCell = c; } void setRow(Char_t r) { fRow = r;} void setColumn(Char_t c) { fColumn = c;} void setAddress(Int_t s, Int_t c, Char_t ro, Char_t co); void clear() ; void clearHits(); void addFastHit(HEmcHit_t theHit) { if(fnFast<NTIMESEMCRAW) { fFastHits[fnFast].setTimes(theHit); fnFast++;} } void addFastHit(Float_t leading, Float_t trailing) { if(fnFast<NTIMESEMCRAW) { fFastHits[fnFast].setTimes(leading,trailing); fnFast++;}} void addSlowHit(HEmcHit_t theHit) { if(fnSlow<NTIMESEMCRAW) { fSlowHits[fnSlow].setTimes(theHit); fnSlow++;} } void addSlowHit(Float_t leading, Float_t trailing) { if(fnSlow<NTIMESEMCRAW) { fSlowHits[fnSlow].setTimes(leading,trailing); fnSlow++;} } ClassDef(HEmcRaw, 1) // raw data of EMC detector using TRB3 for readout }; inline void HEmcRaw::clear(void) { fSector = -1; fCell = 0; fRow = 0; fColumn = 0; for(Int_t i=0;i<NTIMESEMCRAW; i++){ fFastHits[i].clear(); fSlowHits[i].clear(); } fnFast = 0; fnSlow = 0; } inline void HEmcRaw::clearHits(void) { for(Int_t i=0;i<NTIMESEMCRAW; i++){ fFastHits[i].clear(); fSlowHits[i].clear(); } fnFast = 0; fnSlow = 0; } inline void HEmcRaw::getAddress(Int_t& s, Int_t& c, Char_t& ro, Char_t& co) const { s = fSector; c = fCell; ro= fRow; co= fColumn; } inline void HEmcRaw::setAddress(Int_t s, Int_t c,Char_t ro, Char_t co) { fSector = static_cast<Char_t>(s); fCell = static_cast<UChar_t>(c); fRow = ro; fColumn = co; } #endif /* ! HEMCRAW_H */
44868ffde82116f6b4d5f12fdeb54df52e71c069
2a2c909ca11664fbfe3bbac77b60d9ff68c6f3d4
/C_C++_Projects/BAPS Contest/echo/pyramidhotel.cpp
d5de1bf84123de4d27e5f6ee8ff8cfc5ffa20184
[ "MIT" ]
permissive
sunjerry019/RandomCodes
d8049ca188d7f0daeee4a9b43d119ab026a9027c
4402604aaeee63bb1ce6fa962c496b438bb17e50
refs/heads/master
2021-01-12T14:32:02.077792
2019-05-19T15:42:48
2019-05-19T15:42:48
70,065,532
0
0
null
null
null
null
UTF-8
C++
false
false
512
cpp
pyramidhotel.cpp
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define sz(x) (int)(x).size() #define all(x) (x).begin(),(x).end() #define pb push_back #define UNIQUE(x) (x).resize(distance((x).begin(),unique(all(x)))) int n,a[1000005],mem[1000005]; int main() { scanf("%d",&n); for (int i=0;i<n;i++) scanf("%d",&a[i]); mem[n-1]=1; for (int i=n-2;i>=0;i--) { if (a[i]>mem[i+1]) mem[i]=mem[i+1]+1; else mem[i]=a[i]; } printf("%d\n",*max_element(mem,mem+n)); }
26031ebab7b959f771af21c868d936dddb34214e
61d75c697efc330cfd420396851fc4a4db341b22
/XmlParser/XmlParser/xpath_parsing.cpp
61c838637e1102f17ca7e73e8e73faf0b77fe38b
[ "MIT" ]
permissive
startrunner/fmi-intro-programming-xml-parser
17c82375937a31e8ac92bcfb3b18819fc58db2f3
461b0f740c507a53f7e272232476d5bd3a1c5c1e
refs/heads/master
2020-04-17T08:55:05.827551
2019-01-19T19:23:51
2019-01-19T19:23:51
166,433,641
1
0
null
null
null
null
UTF-8
C++
false
false
7,477
cpp
xpath_parsing.cpp
#include "pch.h" #include <sstream> #include "xpath_parsing.h" #include "text_token_stream.h" #include "xpath_token_stream.h" using namespace std; bool remove_forward_slashes(cached_token_stream &tokenStream); bool try_parse_segment(cached_token_stream &tokenStream, xpath_query_segment &segment); xpath_query parse_xpath_query(cached_token_stream &tokenStream); bool try_parse_attribute_filter(cached_token_stream &tokenStream, xpath_attribute_filter &filter); bool try_parse_index(cached_token_stream &tokenStream, optional<int> &index); bool try_parse_identifier(cached_token_stream &tokenStream, string &identifier, bool allowAsterisk = false); bool try_parse_attribute_selector(cached_token_stream &tokenStream, string &attributeSelector); bool try_parse_qualifier_set( cached_token_stream &tokenStream, optional<int> &index, vector<string> &attributeSelectors, vector<string> &mandatoryAttributes, vector<xpath_attribute_filter> &attributeFilters ); xpath_query parse_xpath_query(const std::string & queryString) { stringstream queryStringStream{ queryString }; return parse_xpath_query(queryStringStream); } xpath_query parse_xpath_query(std::istream &queryStringStream) { text_token_stream textTokenStream{ queryStringStream }; xpath_token_stream xpathTokenStream{ textTokenStream }; cached_token_stream cachedTokenStream{ xpathTokenStream }; return parse_xpath_query(cachedTokenStream); } xpath_query parse_xpath_query(cached_token_stream &tokenStream) { if (tokenStream.eof())throw runtime_error("empty xpath request!"); bool isRelativeToRoot = (tokenStream.peek(0).type == token_type::FORWARD_SLASH); vector<xpath_query_segment> segments; xpath_query_segment segment; remove_forward_slashes(tokenStream); while (try_parse_segment(tokenStream, segment)) { segments.push_back(segment); remove_forward_slashes(tokenStream); } return xpath_query{ isRelativeToRoot, segments }; } bool remove_forward_slashes(cached_token_stream &tokenStream) { while (tokenStream.try_cache(1) && tokenStream.peek(0).type == token_type::FORWARD_SLASH) { tokenStream.next_token(); } return !tokenStream.eof(); } bool try_parse_segment(cached_token_stream &tokenStream, xpath_query_segment &segment) { string identifier; if (!try_parse_identifier(tokenStream, identifier, true))return false; segment.index = nullptr; segment.attributeSelectors.clear(); segment.attributeExistenceRequirements.clear(); segment.attributeValueFiters.clear(); try_parse_qualifier_set( tokenStream, segment.index, segment.attributeSelectors, segment.attributeExistenceRequirements, segment.attributeValueFiters ); segment.elementName = identifier; return true; } bool try_parse_qualifier_set( cached_token_stream &tokenStream, optional<int> &index, vector<string> &attributeSelectors, vector<string> &mandatoryAttributes, vector<xpath_attribute_filter> &attributeFilters ) { bool validOpeningSquare = tokenStream.try_cache(1) && tokenStream.peek(0).type == token_type::OPENING_SQUARE; if (!validOpeningSquare)return false; bool immediatelyClosed = tokenStream.try_cache(2) && tokenStream.peek(1).type == token_type::CLOSING_SQUARE; if (immediatelyClosed) { for (int i = 0; i < 2; i++)tokenStream.next_token(); return true; } string mandatoryAttribute; string attributeSelector; xpath_attribute_filter filter; bool parsedAnything; token openingSquare = tokenStream.next_token(); do { if (try_parse_attribute_selector(tokenStream, attributeSelector)) { attributeSelectors.push_back(attributeSelector); } else if (try_parse_attribute_filter(tokenStream, filter)) { attributeFilters.push_back(filter); } else if (try_parse_identifier(tokenStream, mandatoryAttribute)) { mandatoryAttributes.push_back(mandatoryAttribute); } else if (try_parse_index(tokenStream, index)) {} ///... else throw runtime_error("unexpected tokens"); } while (!tokenStream.eof() && tokenStream.peek(0).type != token_type::CLOSING_SQUARE); if (tokenStream.eof())throw runtime_error("unexpected eof"); token closingSquare = tokenStream.next_token(); return true; } const map<pair<token_type, token_type>, xpath_filter_type> comparisons{ {{token_type::EQUALS_SIGN, token_type::LITERAL_NUMBER}, xpath_filter_type::EQUALS_NUMERIC}, {{token_type::EQUALS_SIGN, token_type::LITERAL_STRING}, xpath_filter_type::EQUALS_TEXT}, {{token_type::OPENING_SHARP, token_type::LITERAL_NUMBER}, xpath_filter_type::LESS_THAN_NUMERIC}, {{token_type::OPENING_SHARP, token_type::LITERAL_STRING}, xpath_filter_type::LESS_THAN_TEXT}, {{token_type::CLOSING_SHARP, token_type::LITERAL_NUMBER}, xpath_filter_type::GREATER_THAN_NUMERIC}, {{token_type::OPENING_SHARP, token_type::LITERAL_STRING}, xpath_filter_type::GREATER_THAN_TEXT} }; bool try_parse_attribute_filter(cached_token_stream &tokenStream, xpath_attribute_filter &filter) { bool success = tokenStream.try_cache(3) && tokenStream.peek(0).type == token_type::IDENTIFIER && (tokenStream.peek(1).type == token_type::EQUALS_SIGN || tokenStream.peek(1).type == token_type::OPENING_SHARP || tokenStream.peek(1).type == token_type::CLOSING_SHARP) && (tokenStream.peek(2).type == token_type::LITERAL_NUMBER || tokenStream.peek(2).type == token_type::LITERAL_STRING); if (!success)return false; token identifier = tokenStream.next_token(); token comparison = tokenStream.next_token(); token literal = tokenStream.next_token(); filter.attributeName = identifier.text(); filter.filterType = comparisons.at({ comparison.type, literal.type }); filter.queryValue = literal.get_literal_value(); return true; } bool try_parse_attribute_selector(cached_token_stream &tokenStream, string &attributeSelector) { bool success = tokenStream.try_cache(2) && tokenStream.peek(0).type == token_type::AT_SIGN&& tokenStream.peek(1).type == token_type::IDENTIFIER; if (!success)return false; token atSign = tokenStream.next_token(); token identifier = tokenStream.next_token(); attributeSelector = identifier.text(); return true; } bool try_parse_index(cached_token_stream &tokenStream, optional<int> &index) { bool success = tokenStream.try_cache(1) && tokenStream.peek(0).type == token_type::LITERAL_NUMBER; if (!success)return false; index = stoi(tokenStream.next_token().text()); return true; } bool try_parse_identifier(cached_token_stream &tokenStream, string &identifier, bool allowAsterisk) { bool validIdentifier = tokenStream.try_cache(1) && (tokenStream.peek(0).type == token_type::IDENTIFIER || (allowAsterisk &&tokenStream.peek(0).type == token_type::ASTERISK)); if (!validIdentifier)return false; identifier = tokenStream.next_token().text(); if (identifier == "*" && allowAsterisk) { if (tokenStream.try_cache(1) && tokenStream.peek(0).type == token_type::ASTERISK) { identifier += tokenStream.next_token().text(); } } return true; }
2085a60841f24e91c8cfcf841cea8f84b3cba58e
5bc96f9f57fd7a676bb36633dc261ee888f2af8b
/node2edge.h
f4049288423b6772ddd963bfeb2525cc93a5ed95
[]
no_license
bdwoods/hamcycles
2c61938b830e5fec4794d451a6ee3dd40168a873
c90b74eb7c3591abbb675912f44969e6cc966449
refs/heads/master
2021-01-10T19:42:18.848613
2014-05-13T01:00:06
2014-05-13T01:00:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
273
h
node2edge.h
#ifndef NODE2EDGE_H #define NODE2EDGE_H #include <iostream> #include <vector> #include "instance.h" #include "tour_generator.h" #include "triple_generator.h" using namespace std; void node2edge(Instance& inst, TourList& tList, TripleList& tripList, string fName); #endif
1608473940f43ba70322c4d6ffd464fec22e9ea0
1f1046c7540b51b300edef70582299ab9ad18cab
/Ponteiro/Ponteiro - Ponteiro com valores.cpp
b9fe915ebe25ea3d7643558907129abf694f8cec
[]
no_license
PedroTorres10/Estudos-C
d5056fd430ae09c50c9a406edb824321dc91fe30
b115c4c37d30e3f78a52f4555a9e8a1bb8b01dcb
refs/heads/master
2022-04-15T05:03:59.512027
2020-03-25T14:17:41
2020-03-25T14:17:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
320
cpp
Ponteiro - Ponteiro com valores.cpp
#include <stdio.h> #include <stdlib.h> #include <locale.h> int main() { /*vetores com ponteiro*/ setlocale(LC_ALL,"Portuguese"); int *ptr,i,vet[5] = {44,12,96,31,28}; ptr = vet; for(i=0;i<=4;i++) { printf("\n Vet[%d] eh %d ptr = %d",i,vet[i],*ptr); ptr++; } }
27b61e83ec1b585cc9508bb1ea9f5da8a63a6512
acc86b0196216f3eac41b5d5bd1b90bd3b5bffd8
/computer-vision/main-f2d.cpp
e199543a74a98a8674e35367f838308788473a88
[]
no_license
berkealgul/Some-little-stuff
5090521888056eae895c12e4e3ddcc095cbc19f3
0470e162d530a2c788ca6789d9ca903f4254aa81
refs/heads/master
2022-12-16T18:00:37.448156
2022-12-03T19:43:43
2022-12-03T19:43:43
170,331,655
2
1
null
null
null
null
UTF-8
C++
false
false
5,087
cpp
main-f2d.cpp
// // Created by berkealgul on 20.01.2021. // #include <iostream> #include <string> #include <vector> #include <opencv2/opencv.hpp> using namespace cv; /* // 1366x768 std::string RES = "1366_768"; Rect ROI_RECT(Point(810, 15), Point(1110, 75)); //1280_960 int ICON_SIZE = 28; */ // 1280x960 std::string RES = "1280_960"; const Rect cells[] = { Rect(Point(819, 19), Point(871, 71)), Rect(Point(880, 19), Point(932, 71)), Rect(Point(936, 19), Point(988, 71)), Rect(Point(995, 19), Point(1047, 71)), Rect(Point(1053, 19), Point(1105, 71)) }; /* // 1280x720 std::string RES = "1280_720"; Rect ROI_RECT(Point(771, 16), Point(990, 52)); //1280_720 int ICON_SIZE = 27; */ Ptr<FeatureDetector> detector = ORB::create(); Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create(DescriptorMatcher::BRUTEFORCE); const float RATIO_TRESH = .99; const int minMatches = 2; class Agent { public: std::string name; Mat icon; Agent(std::string name, std::string imgPath) { this->name = name; icon = imread(imgPath, 0); //pyrDown(icon, icon, Size(icon.cols/2, icon.rows/2)); //imshow(name, icon); } }; void initialize_agents(std::vector<Agent> &agents, std::string path) { agents.emplace_back("Sage", path + "/Sage_icon.png"); agents.emplace_back("Viper", path + "/Viper_icon.png"); agents.emplace_back("Yoru", path + "/Yoru_icon.png"); agents.emplace_back("Jett", path + "/Jett_icon.png"); agents.emplace_back("Breach", path + "/Breach_icon.png"); agents.emplace_back("Cypher", path + "/Cypher_icon.png"); agents.emplace_back("Killjoy", path + "/Killjoy_icon.png"); agents.emplace_back("Omen", path + "/Omen_icon.png"); agents.emplace_back("Phoenix", path + "/Phoenix_icon.png"); agents.emplace_back("Raze", path + "/Raze_icon.png"); agents.emplace_back("Reyna", path + "/Reyna_icon.png"); agents.emplace_back("Skye", path + "/Skye_icon.png"); agents.emplace_back("Sova", path + "/Sova_icon.png"); } void detect(Mat frame, Mat ref, int &matchCount) { cvtColor(frame, frame, COLOR_BGR2GRAY); GaussianBlur(frame, frame, Size(5, 5),0); pyrUp(frame, frame, Size(frame.cols*2, frame.rows*2)); // pyrUp(frame, frame, Size(frame.cols*2, frame.rows*2)); std::vector<KeyPoint> keypoints1, keypoints2; Mat descriptors1, descriptors2; detector->detectAndCompute(frame, noArray(), keypoints1, descriptors1 ); detector->detectAndCompute(ref, noArray(), keypoints2, descriptors2 ); //descriptors1.convertTo(descriptors1, CV_32F); //descriptors1.convertTo(descriptors2, CV_32F); if(keypoints1.size() == 0 || keypoints2.size() == 0) { matchCount = 0; return; } std::vector< std::vector<DMatch> > knn_matches; matcher->knnMatch( descriptors1, descriptors2, knn_matches, 2 ); //-- Filter matches using the Lowe's ratio test std::vector<DMatch> good_matches; for(auto& knn_matche : knn_matches) { if (knn_matche[0].distance < RATIO_TRESH * knn_matche[1].distance) { good_matches.push_back(knn_matche[0]); } } /* drawMatches(frame, keypoints1, ref, keypoints2, good_matches, img_matches, Scalar::all(-1), Scalar::all(-1), std::vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );*/ matchCount = good_matches.size(); /* imshow("f", frame); imshow("ref", ref); waitKey();*/ } int main(int argc, char **argv) { std::string imgPath = "/home/berkealgul/Masaรผstรผ/volorant/ingame_dataset/" + RES; std::vector<Agent> agents; initialize_agents(agents, "/home/berkealgul/Masaรผstรผ/volorant/icons"); std::vector<std::string> imageNames; glob(imgPath+"/*.png", imageNames); // each image for(std::string imgName : imageNames) { //"/home/berkealgul/Masaรผstรผ/volorant/1607667456.png" Mat frame = imread(imgName); std::string names[] = {"_", "_", "_", "_", "_"}; // each cell for(int i = 0; i < 5; i++) { Mat roi = frame(cells[i]); int maxMatches = 0; // each agent for(Agent a : agents) { int matches; rectangle(frame, cells[i], Scalar::all(0), 2, 8, 0 ); detect(roi, a.icon, matches); std::cout << matches << "\n"; if(matches < minMatches) continue; // if we have better result if(matches > maxMatches) { maxMatches = matches; names[i] = a.name; } } } std::string nameText = names[0] + " " + names[1] + " " + names[2]+ " " + names[3]+ " " + names[4]; putText(frame, nameText, Point(cells[0].x-30,cells[0].y+cells[0].height+50), FONT_HERSHEY_SIMPLEX, 1, Scalar::all(0), 2); std::cout << nameText << "\n"; imshow("frame", frame); waitKey(50); } return 0; }
8c71de4c7d012e1d76c5b8e657afb055b35f0357
d9c7b2eddc18b9732c81795667b96783a43ded11
/Layer.h
7ca092086578b69eeff98f4452ff471da1f41f0f
[]
no_license
CrayonProof/neuraNet
86ef88995a929f596e37efb27fae9d5b0188412e
5f46eb6e1b1f174632f65e5e6c856c768b85fded
refs/heads/master
2020-04-13T00:24:36.389983
2019-01-12T21:45:58
2019-01-12T21:45:58
162,844,698
0
0
null
null
null
null
UTF-8
C++
false
false
309
h
Layer.h
#pragma once #include<ctime> #include<vector> #include<string> class Layer { public: Layer(int nodeCount); Layer(std::vector<double> weights); void setWeight(int index, double value); std::string toString(); private: std::vector<double> weights; std::vector<double> biases; };
923732c80a61440dba21dd1c638a64cde1075221
83abad6209b7bad655116788a491151282dd13e4
/lab13 - csp/cpp/ex1.cpp
de226caddd91d0867c2266ad00c75b3424b334d4
[]
no_license
usmanayubsh/ec102-lab
914c253e9cbfdf82583d68357b534083e44eb525
de81401791183bcf065aff36ab428b8c838a99c0
refs/heads/master
2021-01-10T02:04:17.479998
2016-02-05T09:39:13
2016-02-05T09:39:13
48,316,041
1
0
null
null
null
null
UTF-8
C++
false
false
401
cpp
ex1.cpp
// demonstrates return values, converts pounds to kg #include <iostream> using namespace std; float lbstokgs(float); // declaration int main() { float lbs, kgs; cout << "Enter your weight in pounds: "; cin >> lbs; kgs = lbstokgs(lbs); cout << kgs << endl; // 4 cout << lbs; // 3 return 0; } float lbstokgs(float pounds) { float pounds = pounds + 1; return pounds; }
05d04733982599561bef902c6d04a82a7eb9a5c3
69e8af5defbb694794a0437084be69c10319b0d9
/threading/packaged_task.cpp
4aeca8913ef94327a98ef3b44bc883fc6f6cc42b
[]
no_license
OpsRaven/SenecaOOP345-attic
64e79ff5313e1eed69c787182218f5b5e3b826d5
b8f9c2bae3c10e24e17e5d037172bcad8a21563b
refs/heads/master
2021-01-16T20:49:13.917549
2016-02-12T18:22:16
2016-02-12T18:22:16
52,182,396
2
0
null
2016-02-21T00:08:34
2016-02-21T00:08:34
null
UTF-8
C++
false
false
1,862
cpp
packaged_task.cpp
// http://naipc.uchicago.edu/2014/ref/cppreference/en/cpp/thread/packaged_task.html // GB changed pow to ipow. 'pow' generated syntax errors. // GB added direct and function object calls #include <iostream> #include <cmath> #include <thread> #include <future> #include <functional> int ipow(int a, int b) { return (int) pow(double(a), double(b)); } class function_object // functor or function object class with overloaded operator() { public : int operator () (int a, int b) const { return ipow(a,b); } }; void task_direct() { std::packaged_task<int(int,int)> task(ipow); task(2, 1); std::cout << "task_direct:\t" << task.get_future().get() << '\n'; task.reset(); task(2, 2); std::cout << "task_direct:\t" << task.get_future().get() << '\n'; } void task_fo() { function_object fo; std::packaged_task<int(int,int)> task(fo); task(2, 3); std::cout << "task_fo:\t" << task.get_future().get() << '\n'; task.reset(); task(2, 4); std::cout << "task_fo:\t" << task.get_future().get() << '\n'; } void task_lambda() { auto f = [](int a, int b) { return ipow(a, b); }; std::packaged_task<int(int,int)> task(f); task(2, 5); std::cout << "task_lambda:\t" << task.get_future().get() << '\n'; task.reset(); task(2, 6); std::cout << "task_lambda:\t" << task.get_future().get() << '\n'; } void task_bind() { std::packaged_task<int()> task(std::bind(ipow, 2, 7)); task(); std::cout << "task_bind:\t" << task.get_future().get() << '\n'; } void task_thread() { std::packaged_task<int(int,int)> task(ipow); std::thread task_td(std::move(task), 2, 8); task_td.join(); std::cout << "task_thread:\t" << task.get_future().get() << '\n'; } int main() { task_direct(); task_fo(); task_lambda(); task_bind(); task_thread(); }
066981402fc636eb327b06d720d8fbf6b98f33db
cc9486b5164831b3d725382a2b2fa73350509262
/test/test.cpp
6798db4fef162453258d95a4f1b9145dda17ba7b
[]
no_license
andrea321123/Probably-Monopoly
8100cccd55f32ae94629b2a0e9a3253a77cfdee2
48e093d5452e2ab53f864da19d1dd50db0beafe6
refs/heads/master
2023-01-30T03:43:18.174357
2020-12-08T12:04:50
2020-12-08T12:04:50
291,329,165
0
0
null
null
null
null
UTF-8
C++
false
false
128
cpp
test.cpp
// Test.cpp // Version 1.0 // #define CATCH_CONFIG_MAIN #include "catch.hpp" TEST_CASE("Test", "[test]"){ REQUIRE (true); }
6d6c178d8a270ae3cc3200633352de68ac079a33
6bc3f5955699fcdac540823c51354bc21919fb06
/USACO/1.2/dualpal/dualpal.cpp
0e123199dd88e356102c661d9c6093a21f4efbca
[]
no_license
soroush-tabesh/Competitive-Programming
e1a265e2224359962088c74191b7dc87bbf314bf
a677578c2a0e21c0510258933548a251970d330d
refs/heads/master
2021-09-24T06:36:43.037300
2018-10-04T14:12:00
2018-10-04T14:12:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,048
cpp
dualpal.cpp
/* ID: soroosh4 LANG: C++11 TASK: dualpal */ //In The Name of God #include <bits/stdc++.h> #define Init ios_base::sync_with_stdio(0),cin.tie(0) #define WFile freopen("dualpal.in","r",stdin),freopen("dualpal.out","w",stdout) #define forar(i,n) for(int i = 0; i < n;i++) #define fori(i,a,b) for(long long int i = a; i < b;i++) #define ford(i,a,b) for(long long int i = a; i > b;i--) #define Log(x) cout << "Log: " << x << endl; #define F first #define S second #define pb push_back #define pf push_front using namespace std; typedef long long int ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll mod = 1e9+7; const int M = 100*1000+5; void Solution(); int main() { Init; WFile; Solution(); return 0; } bool ispal(int n,int b){ int a = n; int t = 0; while(n>0){ t*=b; t+=n%b; n/=b; } return (a-t == 0); } void Solution(){ int n,s; cin >> n >> s; while(n > 0){ s++; int k = 0; fori(r,2,11){ if(ispal(s,r)){ k++; } } if(k > 1){ cout << s << '\n'; n--; } } }
522280f9f8c22dfae92e585b0423e998f8878bc0
92e7773ec876c6a3522b4ba4715a1367086efae4
/src/TestReader.cpp
35ece13f5da9552aa12deceaf35c36ef0b96cc7d
[]
no_license
pentifica/hydrolix
15c84abd3be365a347ab7974c028cfb5ddc07470
b2304db95585661836098da87983674c5ab0b027
refs/heads/main
2023-02-10T05:08:49.621172
2020-12-23T22:55:49
2021-01-05T19:59:02
322,294,495
0
0
null
null
null
null
UTF-8
C++
false
false
907
cpp
TestReader.cpp
#include <TestReader.h> #include <Factory.h> #include <vector> namespace { using namespace example; std::vector<Token> tokens { Token(Token::Type::document_start, "", ""), Token(Token::Type::record_start, "", ""), Token(Token::Type::list_start, "list", ""), Token(Token::Type::key_value, "key", "value"), Token(Token::Type::list_end, "", ""), Token(Token::Type::record_start, "record", ""), Token(Token::Type::record_end, "", ""), Token(Token::Type::record_end, "", ""), Token(Token::Type::document_end, "", ""), Token(Token::Type::null, "", "") }; bool const registered = example::Factory::RegisterReader("test", example::TestReader::Factory); } namespace example { std::unique_ptr<Reader> TestReader::Factory(std::istream& is) { return std::make_unique<TestReader>(is); } Token TestReader::operator()() { return tokens[next_++ % tokens.size()]; } }
a86d10576ebed62a56908c38696689d68741b116
54a5252386764b04c2a4589c4633d012c6e92a28
/Reitai_Action/maingame.h
120a7c360aa24cf57e60cd774573f0e2a6aa82b7
[]
no_license
dameboshi/Reitai_action
5fd4040277b1d1a2b0e381c339e5d0dace0baa01
975e0a3af86d47d90ee3e508e7dd44816c1a1d8a
refs/heads/master
2021-01-20T23:31:44.533627
2014-12-23T15:09:15
2014-12-23T15:09:15
28,269,465
2
0
null
null
null
null
UTF-8
C++
false
false
264
h
maingame.h
#include "basestate.h" enum STAGENUMBER{ s1_1, s1_2, s1_3, s1_4, s1_5, s1_b, }; class MainGame : public BaseState{ private: int stagenumber; int limit_time; public: MainGame(int sn); void Init(); void Calc(); void Draw(); void Load(); int End(); };
0e443dbabd6848e7a7bb1f7e2f79c20d2ae2d561
460fab5f4b3456b03415e75a4a21c174b34548b3
/CubeSat_GPS/RTC.ino
c975e829643b6ec46bc1c7062c09e14b47bb75c4
[]
no_license
wusatteam/WUSATP1
b4ed01c117af8dba2a87cced30a2487a93c28e4e
d80e3d070fab4f89d036d88bf26038a7afd4a5bf
refs/heads/master
2020-06-03T19:38:59.567460
2013-04-13T12:04:15
2013-04-13T12:04:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
902
ino
RTC.ino
void RTC_init() { Wire.begin(); RTC.begin(); if (! RTC.isrunning()) { // following line sets the RTC to the date & time this sketch was compiled RTC.adjust(DateTime(__DATE__, __TIME__)); #ifdef DEBUG_ON Serial.println(F("\tRTC: Batt Error")); #endif } } void RTC_timestamp(){ // char timestamp[]="2010/00/00 00:00:00"; DateTime now = RTC.now(); // Year timestamp[3] = '0' + now.year() % 10; // Month timestamp[5] = '0' + now.month() / 10; timestamp[6] = '0' + now.month() % 10; // Day timestamp[8] = '0' + now.day() / 10; timestamp[9] = '0' + now.day() % 10; // Hour timestamp[11] = '0' + now.hour() / 10; timestamp[12] = '0' + now.hour() % 10; // Minute timestamp[14] = '0' + now.minute() / 10; timestamp[15] = '0' + now.minute() % 10; // Second timestamp[17] = '0' + now.second() / 10; timestamp[18] = '0' + now.second() % 10; }
9a1249aad8cbac7636b45fcabb51b65437f936fd
1bf751bd9f1f0fd2c1eaa7939ec65681fc194e65
/apps/myApps/Furakut/src/FractSrc.cpp
c3f083c048d6b3472412af0ae1cf94129a995f51
[ "MIT" ]
permissive
SatoshiSann/OpenFrameWorks
599e1e9f130c0e5cb4eeff11bbccfe0b8752387a
b650552449a8909e650b9899580433b1628ea03a
refs/heads/master
2020-04-26T11:24:51.479076
2015-08-15T21:16:02
2015-08-15T21:16:02
40,785,122
0
0
null
null
null
null
UTF-8
C++
false
false
2,565
cpp
FractSrc.cpp
#include "FractSrc.h" void FRACT::Saiki(int n,ofPoint p1,ofPoint p2,ofPoint p6 ,ofPoint p7){ ofPoint p3,p4,p5,p8,p9,p10; float WIDTH_HARF = ofGetWidth()/2; float HEIGHT_HARF = ofGetHeight()/2; float xRadi = 360/300; float zRadi = 360/135; float xRadi2 = 360/200; float zRadi2 = 360/67; if(n > 0){ p3 = (2 * p1 + 3 * p2) / 5.0; //ๅ†…ๅˆ†็‚น n:mใฎๆฏ”ใงๅ†…ๅˆ†็‚นใ‚’ไธ‰ๆฌกๅ…ƒใงใจใ‚‹ๅ ดๅˆ็‚นaใƒป็‚นbใจใ™ใ‚‹ใจใ€€(na+mb/(m+n)) p4 = (2 * p2 + p1) / 3.0; //ๅ†…ๅˆ†็‚น p5.y = p3.y + (p4.y - p3.y) * cos(PI/xRadi) - (p4.z - p3.z) * sin(PI/xRadi); p5.z = p3.z + (p4.y - p3.y) * sin(PI/xRadi) + (p4.z - p3.z) * cos(PI/xRadi); p5.x = p3.x + (p4.x - p3.x) * cos(PI/zRadi) - (p4.y - p3.y) * sin(PI/zRadi); p5.y = p3.y + (p4.x - p3.x) * sin(PI/zRadi) + (p4.y - p3.y) * cos(PI/zRadi); p8 = (2 * p6 + p7) / 3.0; //ๅ†…ๅˆ†็‚น n:mใฎๆฏ”ใงๅ†…ๅˆ†็‚นใ‚’ไธ‰ๆฌกๅ…ƒใงใจใ‚‹ๅ ดๅˆ็‚นaใƒป็‚นbใจใ™ใ‚‹ใจใ€€(na+mb/(m+n)) p9 = (6 * p7 + p6) / 7.0; //ๅ†…ๅˆ†็‚น p10.y = p8.y + (p9.y - p8.y) * cos(PI/xRadi2) - (p9.z - p8.z) * sin(PI/xRadi2); p10.z = p8.z + (p9.y - p8.y) * sin(PI/xRadi2) + (p9.z - p8.z) * cos(PI/xRadi2); p10.x = p8.x + (p9.x - p8.x) * cos(PI/zRadi2) - (p9.y - p8.y) * sin(PI/zRadi2); p10.y = p8.y + (p9.x - p8.x) * sin(PI/zRadi2) + (p9.y - p8.y) * cos(PI/zRadi2); ofPushMatrix(); // ofTranslate(WIDTH_HARF,HEIGHT_HARF); // ofRotateX(frameCount % 360); // ofTranslate(-WIDTH_HARF,-HEIGHT_HARF); ofSetColor(bcolor); ofLine(p3,p4); ofLine(p8,p9); ofSetColor(color); ofLine(p1,p3); ofLine(p3,p5); ofLine(p5,p4); Saiki(n-1,p1,p3,p5,p4); ofLine(p3,p5); ofLine(p5,p4); ofLine(p4,p2); Saiki(n-1,p3,p5,p4,p2); ofLine(p5,p4); ofLine(p4,p2); ofLine(p2,p6); Saiki(n-1,p5,p4,p2,p6); ofLine(p4,p2); ofLine(p2,p6); ofLine(p6,p8); Saiki(n-1,p4,p2,p6,p8); ofLine(p2,p6); ofLine(p6,p8); ofLine(p8,p10); Saiki(n-1,p2,p6,p8,p10); ofLine(p6,p8); ofLine(p8,p10); ofLine(p10,p9); Saiki(n-1,p6,p8,p10,p9); ofLine(p8,p10); ofLine(p10,p9); ofLine(p9,p7); Saiki(n-1,p8,p10,p9,p7); ofPopMatrix(); } }
eee1617397dc5dc16934f2e99951440f0c1660ef
c58f59f978f3977d004f748a178696820d5ac095
/Div2A/441A.cpp
1ecc8a7862ffd6d821d123ce460113b40b4b64bd
[]
no_license
Shreyas14398/CF
39b828b413fd70adb3338ad6df42846ddd02ac25
cdbc4de96a31cbe8fd191901a38569837121fa5f
refs/heads/main
2023-01-20T16:17:23.807179
2020-11-30T02:25:50
2020-11-30T02:25:50
313,029,918
0
0
null
null
null
null
UTF-8
C++
false
false
646
cpp
441A.cpp
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fs first #define sc second using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin) ; freopen("output.txt", "w", stdout) ; #endif ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; std::vector<int> v; cin >> n >> k; for (int i = 0; i < n; i++) { int y, j, s; bool f = false; cin >> y; for (j = 0; j < y; j++) { cin >> s; if (!f && k > s) { v.pb(i); f = true; } } } cout << v.size() << endl; for (int x = 0; x < v.size(); x++) cout << v[x] + 1 << " "; cout << endl; return 0; }
c8a79112e8be607eccb539f3adb462407b3bfc3c
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
/NT/windows/advcore/ctf/aimm1.2/aimmwrap/atom.cpp
9315023ebbb4e71506c56d948784944963afa1c2
[]
no_license
jjzhang166/WinNT5_src_20201004
712894fcf94fb82c49e5cd09d719da00740e0436
b2db264153b80fbb91ef5fc9f57b387e223dbfc2
refs/heads/Win2K3
2023-08-12T01:31:59.670176
2021-10-14T15:14:37
2021-10-14T15:14:37
586,134,273
1
0
null
2023-01-07T03:47:45
2023-01-07T03:47:44
null
UTF-8
C++
false
false
1,459
cpp
atom.cpp
/*++ Copyright (c) 1985 - 1999, Microsoft Corporation Module Name: atom.cpp Abstract: This file implements the CAtomObject class. Author: Revision History: Notes: --*/ #include "private.h" #include "atom.h" #include "globals.h" //+--------------------------------------------------------------------------- // // CAtomObject // //---------------------------------------------------------------------------- HRESULT CAtomObject::_InitAtom( LPCTSTR lpString ) { HRESULT hr; size_t cch; if (m_AtomName) return S_OK; hr = StringCchLength(lpString, 255, &cch); if (hr != S_OK) return hr; m_AtomName = new TCHAR[cch+1]; if (m_AtomName == NULL) return E_OUTOFMEMORY; hr = StringCchCopy(m_AtomName, cch+1, lpString); return hr; } HRESULT CAtomObject::_Activate() { EnterCriticalSection(g_cs); int ref = ++m_AtomRefCount; if (ref == 1) { // // Add AIMM1.2 ATOM // m_Atom = AddAtom(m_AtomName); } LeaveCriticalSection(g_cs); return S_OK; } HRESULT CAtomObject::_Deactivate() { EnterCriticalSection(g_cs); int ref = --m_AtomRefCount; if (ref == 0) { // // Delete AIMM1.2 ATOM // DeleteAtom(m_Atom); m_Atom = 0; } LeaveCriticalSection(g_cs); return S_OK; }
1cc551e9ba7ec1850ed9f5dafeb8cde02146f4fb
d9b296cb9b821fc8b6f9506b2e887773116e4555
/chap3/c++ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ•ํ„ฐ3 ์‹ค์ „๋ฌธ์ œ 7.cpp
e692b376341d54805436b2a3705a1a498f3f09b7
[]
no_license
studyinggggggggg/c-study
2aada67d186dbcf297f2bc97a0ce5cea310d7654
d5ac07443cd4d37c09b407f6ff7201c49fc0d3b3
refs/heads/master
2022-11-23T11:19:42.991525
2020-07-08T13:32:24
2020-07-08T13:32:24
276,918,023
0
0
null
2020-07-03T14:26:44
2020-07-03T14:24:21
null
UHC
C++
false
false
984
cpp
c++ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ•ํ„ฐ3 ์‹ค์ „๋ฌธ์ œ 7.cpp
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; class Random { public: Random(); int n; int next(); int nextInrange(int x, int y); }; Random::Random() { srand((unsigned int)time(0)); } int Random::next() { while (true) { n = rand(); if (n % 2 == 0) { break; } else { n = rand(); } } return n; } int Random::nextInrange(int a, int b) { while (true) { n = rand() % (b - a + 1) + a; if (n % 2 == 1) { break; } else { n = rand() % (b - a + 1) + a; } } return n; } int main() { Random r; cout << "-- 0์—์„œ " << RAND_MAX << "๊นŒ์ง€์˜ ์ง์ˆ˜ ๋žœ๋ค ์ •์ˆ˜ 10๊ฐœ--" << endl; for (int i = 0; i < 10; i++) { int a = r.next(); cout << a << " "; } cout << endl << endl << "-- 2์—์„œ " << "9 ๊นŒ์ง€์˜ ๋žœ๋ค ํ™€์ˆ˜ ์ •์ˆ˜ 10๊ฐœ --" << endl; for (int i = 0; i < 10; i++) { int a = r.nextInrange(2, 10); cout << a << " "; } cout << endl; }