blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 986
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 23
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 145
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 122
values | content
stringlengths 3
10.4M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
158
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9e21773fcad6bbe4fe4159eb57266258628d6878 | aed4412def678da83397ed4b16eaace3a6194c2c | /ip/mem_prj/solution1/.autopilot/db/mem.pp.0.cpp.ap-line.cpp.CXX | 4444fb9b99024ce193e2c57de95464494364cd39 | [] | no_license | AlexMontgomerie/memory_io_unit | 6b47fc23d46424b4474fc8c4c00f2db4fa94219b | 3a478d166c27d829e9a6c39aa438519353946c38 | refs/heads/master | 2020-03-19T08:28:34.071837 | 2018-06-11T17:58:34 | 2018-06-11T17:58:34 | 136,207,478 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 75,976 | cxx | #pragma line 1 "mem.cpp" ::: 0
#pragma line 1 "mem.cpp" 1 ::: 1
#pragma line 1 "<built-in>" 1 ::: 2
#pragma line 1 "<built-in>" 3 ::: 3
#pragma line 155 "<built-in>" 3 ::: 4
#pragma line 1 "<command line>" 1 ::: 5
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_op.h" 1 ::: 11
#pragma line 145 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_op.h" ::: 64
#pragma line 156 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_op.h" ::: 67
#pragma line 413 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_op.h" ::: 197
#pragma line 427 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_op.h" ::: 200
#pragma line 7 "<command line>" 2 ::: 202
#pragma line 1 "<built-in>" 2 ::: 203
#pragma line 1 "mem.cpp" 2 ::: 204
#pragma line 1 "./mem.h" 1 ::: 205
#pragma line 1 "/usr/include/assert.h" 1 3 4 ::: 209
#pragma line 35 "/usr/include/assert.h" 3 4 ::: 230
#pragma line 1 "/usr/include/features.h" 1 3 4 ::: 231
#pragma line 122 "/usr/include/features.h" 3 4 ::: 328
#pragma line 156 "/usr/include/features.h" 3 4 ::: 353
#pragma line 180 "/usr/include/features.h" 3 4 ::: 355
#pragma line 191 "/usr/include/features.h" 3 4 ::: 358
#pragma line 343 "/usr/include/features.h" 3 4 ::: 389
#pragma line 1 "/usr/include/stdc-predef.h" 1 3 4 ::: 393
#pragma line 52 "/usr/include/stdc-predef.h" 3 4 ::: 428
#pragma line 346 "/usr/include/features.h" 2 3 4 ::: 435
#pragma line 1 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 1 3 4 ::: 458
#pragma line 49 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 499
#pragma line 80 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 505
#pragma line 106 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 523
#pragma line 119 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 529
#pragma line 131 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 533
#pragma line 147 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 535
#pragma line 165 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 539
#pragma line 192 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 549
#pragma line 252 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 602
#pragma line 305 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 643
#pragma line 346 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 668
#pragma line 410 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 ::: 692
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 ::: 693
#pragma line 11 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 3 4 ::: 695
#pragma line 411 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 2 3 4 ::: 697
#pragma line 368 "/usr/include/features.h" 2 3 4 ::: 698
#pragma line 1 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 1 3 4 ::: 723
#pragma line 1 "/usr/include/x86_64-linux-gnu/gnu/stubs-64.h" 1 3 4 ::: 734
#pragma line 11 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 2 3 4 ::: 739
#pragma line 392 "/usr/include/features.h" 2 3 4 ::: 740
#pragma line 36 "/usr/include/assert.h" 2 3 4 ::: 741
#pragma line 66 "/usr/include/assert.h" 3 4 ::: 753
#pragma line 100 "/usr/include/assert.h" 3 4 ::: 774
#pragma line 5 "./mem.h" 2 ::: 780
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_axi_sdata.h" 1 ::: 781
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int.h" 1 ::: 868
#pragma line 60 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int.h" ::: 920
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/hls_half.h" 1 ::: 921
#pragma line 32 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/hls_half.h" ::: 942
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cmath" 1 3 ::: 943
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cmath" 3 ::: 985
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 1 3 ::: 987
#pragma line 63 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 3 ::: 1030
#pragma line 76 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 3 ::: 1034
#pragma line 91 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 3 ::: 1038
#pragma line 102 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 3 ::: 1040
#pragma line 208 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 3 ::: 1107
#pragma line 255 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 3 ::: 1109
#pragma line 307 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 3 ::: 1120
#pragma line 326 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 3 ::: 1126
#pragma line 352 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 3 ::: 1128
#pragma line 390 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 3 ::: 1158
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/os_defines.h" 1 3 ::: 1163
#pragma line 394 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 2 3 ::: 1201
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/cpu_defines.h" 1 3 ::: 1205
#pragma line 397 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++config.h" 2 3 ::: 1234
#pragma line 43 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cmath" 2 3 ::: 2085
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/cpp_type_traits.h" 1 3 ::: 2086
#pragma line 36 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/cpp_type_traits.h" 3 ::: 2123
#pragma line 198 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/cpp_type_traits.h" 3 ::: 2268
#pragma line 422 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/cpp_type_traits.h" 3 ::: 2479
#pragma line 44 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cmath" 2 3 ::: 2481
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/type_traits.h" 1 3 ::: 2482
#pragma line 33 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/type_traits.h" 3 ::: 2516
#pragma line 45 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cmath" 2 3 ::: 2696
#pragma line 1 "/usr/include/math.h" 1 3 4 ::: 2697
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/math-vector.h" 1 3 4 ::: 2729
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h" 1 3 4 ::: 2755
#pragma line 26 "/usr/include/x86_64-linux-gnu/bits/math-vector.h" 2 3 4 ::: 2787
#pragma line 32 "/usr/include/math.h" 2 3 4 ::: 2788
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/huge_val.h" 1 3 4 ::: 2793
#pragma line 36 "/usr/include/math.h" 2 3 4 ::: 2818
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/huge_valf.h" 1 3 4 ::: 2820
#pragma line 38 "/usr/include/math.h" 2 3 4 ::: 2845
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/huge_vall.h" 1 3 4 ::: 2846
#pragma line 39 "/usr/include/math.h" 2 3 4 ::: 2865
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/inf.h" 1 3 4 ::: 2869
#pragma line 42 "/usr/include/math.h" 2 3 4 ::: 2893
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/nan.h" 1 3 4 ::: 2897
#pragma line 45 "/usr/include/math.h" 2 3 4 ::: 2922
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/mathdef.h" 1 3 4 ::: 2927
#pragma line 26 "/usr/include/x86_64-linux-gnu/bits/mathdef.h" 3 4 ::: 2944
#pragma line 41 "/usr/include/x86_64-linux-gnu/bits/mathdef.h" 3 4 ::: 2950
#pragma line 49 "/usr/include/math.h" 2 3 4 ::: 2957
#pragma line 83 "/usr/include/math.h" 3 4 ::: 2963
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/mathcalls.h" 1 3 4 ::: 2964
#pragma line 84 "/usr/include/math.h" 2 3 4 ::: 3348
#pragma line 93 "/usr/include/math.h" 3 4 ::: 3349
#pragma line 104 "/usr/include/math.h" 3 4 ::: 3352
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/mathcalls.h" 1 3 4 ::: 3353
#pragma line 105 "/usr/include/math.h" 2 3 4 ::: 3737
#pragma line 139 "/usr/include/math.h" 3 4 ::: 3738
#pragma line 151 "/usr/include/math.h" 3 4 ::: 3741
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/mathcalls.h" 1 3 4 ::: 3742
#pragma line 152 "/usr/include/math.h" 2 3 4 ::: 4126
#pragma line 167 "/usr/include/math.h" 3 4 ::: 4127
#pragma line 248 "/usr/include/math.h" 3 4 ::: 4194
#pragma line 268 "/usr/include/math.h" 3 4 ::: 4196
#pragma line 282 "/usr/include/math.h" 3 4 ::: 4198
#pragma line 304 "/usr/include/math.h" 3 4 ::: 4208
#pragma line 318 "/usr/include/math.h" 3 4 ::: 4210
#pragma line 346 "/usr/include/math.h" 3 4 ::: 4226
#pragma line 411 "/usr/include/math.h" 3 4 ::: 4280
#pragma line 428 "/usr/include/math.h" 3 4 ::: 4282
#pragma line 448 "/usr/include/math.h" 3 4 ::: 4286
#pragma line 470 "/usr/include/math.h" 3 4 ::: 4301
#pragma line 534 "/usr/include/math.h" 3 4 ::: 4357
#pragma line 46 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cmath" 2 3 ::: 4359
#pragma line 76 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cmath" 3 ::: 4365
#pragma line 480 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cmath" 3 ::: 4757
#pragma line 730 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cmath" 3 ::: 4760
#pragma line 33 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/hls_half.h" 2 ::: 4874
#pragma line 3272 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/hls_half.h" ::: 4897
#pragma line 61 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int.h" 2 ::: 4973
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" 1 ::: 4974
#pragma line 68 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 5026
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/iostream" 1 3 ::: 5027
#pragma line 37 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/iostream" 3 ::: 5065
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ostream" 1 3 ::: 5068
#pragma line 38 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ostream" 3 ::: 5107
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ios" 1 3 ::: 5109
#pragma line 37 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ios" 3 ::: 5147
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/iosfwd" 1 3 ::: 5149
#pragma line 38 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/iosfwd" 3 ::: 5188
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stringfwd.h" 1 3 ::: 5191
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stringfwd.h" 3 ::: 5231
#pragma line 82 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stringfwd.h" 3 ::: 5263
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/iosfwd" 2 3 ::: 5268
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/postypes.h" 1 3 ::: 5269
#pragma line 40 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/postypes.h" 3 ::: 5310
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwchar" 1 3 ::: 5312
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwchar" 3 ::: 5354
#pragma line 1 "/usr/include/wchar.h" 1 3 4 ::: 5359
#pragma line 31 "/usr/include/wchar.h" 3 4 ::: 5381
#pragma line 1 "/usr/include/stdio.h" 1 3 4 ::: 5388
#pragma line 43 "/usr/include/stdio.h" 3 4 ::: 5410
#pragma line 63 "/usr/include/stdio.h" 3 4 ::: 5417
#pragma line 37 "/usr/include/wchar.h" 2 3 4 ::: 5420
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stdarg.h" 1 3 4 ::: 5424
#pragma line 40 "/usr/include/wchar.h" 2 3 4 ::: 5473
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/wchar.h" 1 3 4 ::: 5475
#pragma line 42 "/usr/include/wchar.h" 2 3 4 ::: 5507
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 1 3 4 ::: 5518
#pragma line 56 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 3 4 ::: 5554
#pragma line 52 "/usr/include/wchar.h" 2 3 4 ::: 5561
#pragma line 63 "/usr/include/wchar.h" 3 4 ::: 5565
#pragma line 73 "/usr/include/wchar.h" 3 4 ::: 5568
#pragma line 116 "/usr/include/wchar.h" 3 4 ::: 5603
#pragma line 125 "/usr/include/wchar.h" 3 4 ::: 5605
#pragma line 1 "/usr/include/xlocale.h" 1 3 4 ::: 5665
#pragma line 184 "/usr/include/wchar.h" 2 3 4 ::: 5708
#pragma line 409 "/usr/include/wchar.h" 3 4 ::: 5906
#pragma line 688 "/usr/include/wchar.h" 3 4 ::: 6149
#pragma line 744 "/usr/include/wchar.h" 3 4 ::: 6170
#pragma line 894 "/usr/include/wchar.h" 3 4 ::: 6313
#pragma line 46 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwchar" 2 3 ::: 6322
#pragma line 63 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwchar" 3 ::: 6330
#pragma line 136 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwchar" 3 ::: 6337
#pragma line 258 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwchar" 3 ::: 6452
#pragma line 42 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/postypes.h" 2 3 ::: 6464
#pragma line 69 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/postypes.h" 3 ::: 6469
#pragma line 98 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/postypes.h" 3 ::: 6491
#pragma line 241 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/postypes.h" 3 ::: 6626
#pragma line 42 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/iosfwd" 2 3 ::: 6628
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ios" 2 3 ::: 6797
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/exception" 1 3 ::: 6798
#pragma line 35 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/exception" 3 ::: 6834
#pragma line 40 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ios" 2 3 ::: 6950
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/char_traits.h" 1 3 ::: 6951
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/char_traits.h" 3 ::: 6991
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 1 3 ::: 6993
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/functexcept.h" 1 3 ::: 7055
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/exception_defines.h" 1 3 ::: 7097
#pragma line 42 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/functexcept.h" 2 3 ::: 7134
#pragma line 62 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 2 3 ::: 7199
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/numeric_traits.h" 1 3 ::: 7202
#pragma line 32 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/numeric_traits.h" 3 ::: 7235
#pragma line 53 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/numeric_traits.h" 3 ::: 7246
#pragma line 98 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/numeric_traits.h" 3 ::: 7271
#pragma line 65 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 2 3 ::: 7305
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_pair.h" 1 3 ::: 7306
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/move.h" 1 3 ::: 7367
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/concept_check.h" 1 3 ::: 7402
#pragma line 33 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/concept_check.h" 3 ::: 7436
#pragma line 35 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/move.h" 2 3 ::: 7447
#pragma line 109 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/move.h" 3 ::: 7464
#pragma line 61 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_pair.h" 2 3 ::: 7500
#pragma line 85 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_pair.h" 3 ::: 7508
#pragma line 196 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_pair.h" 3 ::: 7534
#pragma line 245 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_pair.h" 3 ::: 7573
#pragma line 270 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_pair.h" 3 ::: 7586
#pragma line 66 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 2 3 ::: 7595
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator_base_types.h" 1 3 ::: 7596
#pragma line 63 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator_base_types.h" 3 ::: 7660
#pragma line 162 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator_base_types.h" 3 ::: 7738
#pragma line 67 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 2 3 ::: 7803
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator_base_funcs.h" 1 3 ::: 7804
#pragma line 63 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator_base_funcs.h" 3 ::: 7868
#pragma line 200 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator_base_funcs.h" 3 ::: 7982
#pragma line 68 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 2 3 ::: 7984
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator.h" 1 3 ::: 7985
#pragma line 68 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator.h" 3 ::: 8045
#pragma line 444 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator.h" 3 ::: 8406
#pragma line 534 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator.h" 3 ::: 8481
#pragma line 648 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_iterator.h" 3 ::: 8578
#pragma line 69 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 2 3 ::: 8833
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/debug/debug.h" 1 3 ::: 8835
#pragma line 71 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 2 3 ::: 8894
#pragma line 135 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 3 ::: 8950
#pragma line 319 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 3 ::: 9119
#pragma line 357 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 3 ::: 9137
#pragma line 494 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 3 ::: 9237
#pragma line 522 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 3 ::: 9250
#pragma line 552 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 3 ::: 9264
#pragma line 669 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_algobase.h" 3 ::: 9340
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/char_traits.h" 2 3 ::: 9879
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwchar" 1 3 ::: 9881
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwchar" 3 ::: 9923
#pragma line 1 "/usr/include/wchar.h" 1 3 4 ::: 9928
#pragma line 900 "/usr/include/wchar.h" 3 4 ::: 9950
#pragma line 46 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwchar" 2 3 ::: 9953
#pragma line 43 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/char_traits.h" 2 3 ::: 9954
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ios" 2 3 ::: 10285
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/localefwd.h" 1 3 ::: 10286
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/localefwd.h" 3 ::: 10326
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++locale.h" 1 3 ::: 10329
#pragma line 40 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++locale.h" 3 ::: 10370
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/clocale" 1 3 ::: 10372
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/clocale" 3 ::: 10414
#pragma line 1 "/usr/include/locale.h" 1 3 4 ::: 10417
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 1 3 4 ::: 10446
#pragma line 56 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 3 4 ::: 10471
#pragma line 29 "/usr/include/locale.h" 2 3 4 ::: 10474
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/locale.h" 1 3 4 ::: 10475
#pragma line 30 "/usr/include/locale.h" 2 3 4 ::: 10493
#pragma line 52 "/usr/include/locale.h" 3 4 ::: 10499
#pragma line 120 "/usr/include/locale.h" 3 4 ::: 10560
#pragma line 184 "/usr/include/locale.h" 3 4 ::: 10599
#pragma line 44 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/clocale" 2 3 ::: 10622
#pragma line 42 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++locale.h" 2 3 ::: 10637
#pragma line 88 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++locale.h" 3 ::: 10672
#pragma line 42 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/localefwd.h" 2 3 ::: 10698
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cctype" 1 3 ::: 10700
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cctype" 3 ::: 10742
#pragma line 1 "/usr/include/ctype.h" 1 3 4 ::: 10745
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/types.h" 1 3 4 ::: 10772
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 ::: 10800
#pragma line 11 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 3 4 ::: 10802
#pragma line 28 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4 ::: 10804
#pragma line 116 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4 ::: 10865
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/typesizes.h" 1 3 4 ::: 10872
#pragma line 26 "/usr/include/x86_64-linux-gnu/bits/typesizes.h" 3 4 ::: 10890
#pragma line 77 "/usr/include/x86_64-linux-gnu/bits/typesizes.h" 3 4 ::: 10895
#pragma line 122 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4 ::: 10906
#pragma line 27 "/usr/include/ctype.h" 2 3 4 ::: 10975
#pragma line 1 "/usr/include/endian.h" 1 3 4 ::: 10989
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/endian.h" 1 3 4 ::: 11026
#pragma line 37 "/usr/include/endian.h" 2 3 4 ::: 11028
#pragma line 59 "/usr/include/endian.h" 3 4 ::: 11032
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 1 3 4 ::: 11035
#pragma line 28 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 3 4 ::: 11053
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 ::: 11054
#pragma line 11 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 3 4 ::: 11056
#pragma line 29 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 2 3 4 ::: 11058
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/byteswap-16.h" 1 3 4 ::: 11066
#pragma line 36 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 2 3 4 ::: 11084
#pragma line 56 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 3 4 ::: 11087
#pragma line 96 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 3 4 ::: 11090
#pragma line 61 "/usr/include/endian.h" 2 3 4 ::: 11092
#pragma line 40 "/usr/include/ctype.h" 2 3 4 ::: 11093
#pragma line 106 "/usr/include/ctype.h" 3 4 ::: 11139
#pragma line 244 "/usr/include/ctype.h" 3 4 ::: 11197
#pragma line 347 "/usr/include/ctype.h" 3 4 ::: 11247
#pragma line 44 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cctype" 2 3 ::: 11249
#pragma line 63 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cctype" 3 ::: 11255
#pragma line 44 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/localefwd.h" 2 3 ::: 11272
#pragma line 42 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ios" 2 3 ::: 11419
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/ios_base.h" 1 3 ::: 11420
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/ios_base.h" 3 ::: 11460
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/atomicity.h" 1 3 ::: 11462
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr.h" 1 3 ::: 11497
#pragma line 158 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr.h" 3 ::: 11641
#pragma line 170 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr.h" 3 ::: 11645
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr-default.h" 1 3 ::: 11646
#pragma line 1 "/usr/include/pthread.h" 1 3 4 ::: 11688
#pragma line 1 "/usr/include/sched.h" 1 3 4 ::: 11712
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 1 3 4 ::: 11741
#pragma line 56 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 3 4 ::: 11766
#pragma line 29 "/usr/include/sched.h" 2 3 4 ::: 11769
#pragma line 1 "/usr/include/time.h" 1 3 4 ::: 11775
#pragma line 74 "/usr/include/time.h" 3 4 ::: 11796
#pragma line 118 "/usr/include/time.h" 3 4 ::: 11799
#pragma line 35 "/usr/include/sched.h" 2 3 4 ::: 11807
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/sched.h" 1 3 4 ::: 11817
#pragma line 27 "/usr/include/x86_64-linux-gnu/bits/sched.h" 3 4 ::: 11836
#pragma line 39 "/usr/include/x86_64-linux-gnu/bits/sched.h" 3 4 ::: 11838
#pragma line 71 "/usr/include/x86_64-linux-gnu/bits/sched.h" 3 4 ::: 11840
#pragma line 201 "/usr/include/x86_64-linux-gnu/bits/sched.h" 3 4 ::: 11901
#pragma line 44 "/usr/include/sched.h" 2 3 4 ::: 11910
#pragma line 117 "/usr/include/sched.h" 3 4 ::: 11946
#pragma line 24 "/usr/include/pthread.h" 2 3 4 ::: 11957
#pragma line 1 "/usr/include/time.h" 1 3 4 ::: 11958
#pragma line 29 "/usr/include/time.h" 3 4 ::: 11979
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 1 3 4 ::: 11989
#pragma line 56 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 3 4 ::: 12014
#pragma line 38 "/usr/include/time.h" 2 3 4 ::: 12017
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/time.h" 1 3 4 ::: 12022
#pragma line 60 "/usr/include/x86_64-linux-gnu/bits/time.h" 3 4 ::: 12070
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/timex.h" 1 3 4 ::: 12100
#pragma line 70 "/usr/include/x86_64-linux-gnu/bits/timex.h" 3 4 ::: 12156
#pragma line 84 "/usr/include/x86_64-linux-gnu/bits/timex.h" 3 4 ::: 12158
#pragma line 105 "/usr/include/x86_64-linux-gnu/bits/timex.h" 3 4 ::: 12160
#pragma line 89 "/usr/include/x86_64-linux-gnu/bits/time.h" 2 3 4 ::: 12162
#pragma line 42 "/usr/include/time.h" 2 3 4 ::: 12170
#pragma line 58 "/usr/include/time.h" 3 4 ::: 12173
#pragma line 90 "/usr/include/time.h" 3 4 ::: 12176
#pragma line 102 "/usr/include/time.h" 3 4 ::: 12179
#pragma line 132 "/usr/include/time.h" 3 4 ::: 12182
#pragma line 181 "/usr/include/time.h" 3 4 ::: 12220
#pragma line 25 "/usr/include/pthread.h" 2 3 4 ::: 12471
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 1 3 4 ::: 12473
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 ::: 12495
#pragma line 11 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 3 4 ::: 12497
#pragma line 22 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 2 3 4 ::: 12499
#pragma line 58 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4 ::: 12500
#pragma line 88 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4 ::: 12523
#pragma line 125 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4 ::: 12545
#pragma line 220 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4 ::: 12622
#pragma line 27 "/usr/include/pthread.h" 2 3 4 ::: 12653
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/setjmp.h" 1 3 4 ::: 12654
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 ::: 12681
#pragma line 11 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 3 4 ::: 12683
#pragma line 27 "/usr/include/x86_64-linux-gnu/bits/setjmp.h" 2 3 4 ::: 12685
#pragma line 28 "/usr/include/pthread.h" 2 3 4 ::: 12691
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 ::: 12692
#pragma line 11 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 3 4 ::: 12694
#pragma line 29 "/usr/include/pthread.h" 2 3 4 ::: 12696
#pragma line 112 "/usr/include/pthread.h" 3 4 ::: 12750
#pragma line 154 "/usr/include/pthread.h" 3 4 ::: 12771
#pragma line 657 "/usr/include/pthread.h" 3 4 ::: 13165
#pragma line 680 "/usr/include/pthread.h" 3 4 ::: 13173
#pragma line 715 "/usr/include/pthread.h" 3 4 ::: 13193
#pragma line 1159 "/usr/include/pthread.h" 3 4 ::: 13627
#pragma line 42 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr-default.h" 2 3 ::: 13629
#pragma line 1 "/usr/include/unistd.h" 1 3 4 ::: 13630
#pragma line 49 "/usr/include/unistd.h" 3 4 ::: 13664
#pragma line 66 "/usr/include/unistd.h" 3 4 ::: 13671
#pragma line 99 "/usr/include/unistd.h" 3 4 ::: 13695
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/posix_opt.h" 1 3 4 ::: 13803
#pragma line 206 "/usr/include/unistd.h" 2 3 4 ::: 13992
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/environments.h" 1 3 4 ::: 13997
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 ::: 14020
#pragma line 11 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 3 4 ::: 14022
#pragma line 23 "/usr/include/x86_64-linux-gnu/bits/environments.h" 2 3 4 ::: 14024
#pragma line 210 "/usr/include/unistd.h" 2 3 4 ::: 14063
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 1 3 4 ::: 14084
#pragma line 56 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 3 4 ::: 14109
#pragma line 230 "/usr/include/unistd.h" 2 3 4 ::: 14112
#pragma line 270 "/usr/include/unistd.h" 3 4 ::: 14142
#pragma line 324 "/usr/include/unistd.h" 3 4 ::: 14186
#pragma line 348 "/usr/include/unistd.h" 3 4 ::: 14201
#pragma line 404 "/usr/include/unistd.h" 3 4 ::: 14243
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/confname.h" 1 3 4 ::: 14453
#pragma line 613 "/usr/include/unistd.h" 2 3 4 ::: 15129
#pragma line 1 "/usr/include/getopt.h" 1 3 4 ::: 15392
#pragma line 48 "/usr/include/getopt.h" 3 4 ::: 15424
#pragma line 122 "/usr/include/getopt.h" 3 4 ::: 15458
#pragma line 185 "/usr/include/getopt.h" 3 4 ::: 15489
#pragma line 875 "/usr/include/unistd.h" 2 3 4 ::: 15494
#pragma line 1008 "/usr/include/unistd.h" 3 4 ::: 15618
#pragma line 1029 "/usr/include/unistd.h" 3 4 ::: 15631
#pragma line 1038 "/usr/include/unistd.h" 3 4 ::: 15633
#pragma line 1094 "/usr/include/unistd.h" 3 4 ::: 15681
#pragma line 1113 "/usr/include/unistd.h" 3 4 ::: 15691
#pragma line 43 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr-default.h" 2 3 ::: 15734
#pragma line 81 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr-default.h" 3 ::: 15746
#pragma line 118 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr-default.h" 3 ::: 15753
#pragma line 183 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr-default.h" 3 ::: 15791
#pragma line 239 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr-default.h" 3 ::: 15802
#pragma line 657 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr-default.h" 3 ::: 15816
#pragma line 800 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr-default.h" 3 ::: 15936
#pragma line 171 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/gthr.h" 2 3 ::: 16011
#pragma line 35 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/atomicity.h" 2 3 ::: 16020
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/atomic_word.h" 1 3 ::: 16021
#pragma line 36 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/atomicity.h" 2 3 ::: 16067
#pragma line 63 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/atomicity.h" 3 ::: 16085
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/ios_base.h" 2 3 ::: 16132
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_classes.h" 1 3 ::: 16134
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_classes.h" 3 ::: 16174
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/string" 1 3 ::: 16177
#pragma line 38 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/string" 3 ::: 16216
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/allocator.h" 1 3 ::: 16221
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++allocator.h" 1 3 ::: 16270
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/new_allocator.h" 1 3 ::: 16305
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/new" 1 3 ::: 16340
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/new" 3 ::: 16380
#pragma line 35 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/new_allocator.h" 2 3 ::: 16454
#pragma line 117 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ext/new_allocator.h" 3 ::: 16529
#pragma line 35 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/c++allocator.h" 2 3 ::: 16546
#pragma line 49 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/allocator.h" 2 3 ::: 16547
#pragma line 237 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/allocator.h" 3 ::: 16682
#pragma line 43 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/string" 2 3 ::: 16684
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/ostream_insert.h" 1 3 ::: 16687
#pragma line 33 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/ostream_insert.h" 3 ::: 16721
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/cxxabi_forced.h" 1 3 ::: 16724
#pragma line 34 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/cxxabi_forced.h" 3 ::: 16759
#pragma line 36 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/ostream_insert.h" 2 3 ::: 16784
#pragma line 46 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/string" 2 3 ::: 16876
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_function.h" 1 3 ::: 16880
#pragma line 508 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_function.h" 3 ::: 17376
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/backward/binders.h" 1 3 ::: 17601
#pragma line 732 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_function.h" 2 3 ::: 17772
#pragma line 50 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/string" 2 3 ::: 17773
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/range_access.h" 1 3 ::: 17776
#pragma line 33 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/range_access.h" 3 ::: 17810
#pragma line 53 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/string" 2 3 ::: 17811
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 1 3 ::: 17812
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 17852
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/initializer_list" 1 3 ::: 17856
#pragma line 33 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/initializer_list" 3 ::: 17890
#pragma line 43 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 2 3 ::: 17891
#pragma line 519 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 18341
#pragma line 593 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 18387
#pragma line 704 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 18462
#pragma line 762 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 18508
#pragma line 896 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 18608
#pragma line 958 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 18659
#pragma line 1024 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 18714
#pragma line 1076 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 18749
#pragma line 1160 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 18822
#pragma line 1207 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 18854
#pragma line 1663 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 19291
#pragma line 2417 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.h" 3 ::: 19995
#pragma line 54 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/string" 2 3 ::: 20330
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.tcc" 1 3 ::: 20331
#pragma line 42 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.tcc" 3 ::: 20374
#pragma line 241 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_string.tcc" 3 ::: 20565
#pragma line 55 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/string" 2 3 ::: 21491
#pragma line 42 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_classes.h" 2 3 ::: 21492
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_classes.tcc" 1 3 ::: 22274
#pragma line 37 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_classes.tcc" 3 ::: 22312
#pragma line 823 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_classes.h" 2 3 ::: 22547
#pragma line 43 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/ios_base.h" 2 3 ::: 22548
#pragma line 43 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ios" 2 3 ::: 23481
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/streambuf" 1 3 ::: 23482
#pragma line 37 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/streambuf" 3 ::: 23520
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/streambuf.tcc" 1 3 ::: 24292
#pragma line 38 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/streambuf.tcc" 3 ::: 24331
#pragma line 808 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/streambuf" 2 3 ::: 24468
#pragma line 44 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ios" 2 3 ::: 24469
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h" 1 3 ::: 24470
#pragma line 35 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h" 3 ::: 24506
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.h" 1 3 ::: 24510
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.h" 3 ::: 24550
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwctype" 1 3 ::: 24552
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwctype" 3 ::: 24594
#pragma line 51 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwctype" 3 ::: 24595
#pragma line 1 "/usr/include/wctype.h" 1 3 4 ::: 24596
#pragma line 31 "/usr/include/wctype.h" 3 4 ::: 24618
#pragma line 1 "/usr/include/wchar.h" 1 3 4 ::: 24622
#pragma line 900 "/usr/include/wchar.h" 3 4 ::: 24644
#pragma line 34 "/usr/include/wctype.h" 2 3 4 ::: 24647
#pragma line 71 "/usr/include/wctype.h" 3 4 ::: 24673
#pragma line 52 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwctype" 2 3 ::: 24918
#pragma line 81 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cwctype" 3 ::: 24925
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.h" 2 3 ::: 24953
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cctype" 1 3 ::: 24954
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/cctype" 3 ::: 24996
#pragma line 42 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.h" 2 3 ::: 24997
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/ctype_base.h" 1 3 ::: 24998
#pragma line 43 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.h" 2 3 ::: 25063
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/streambuf_iterator.h" 1 3 ::: 25070
#pragma line 35 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/streambuf_iterator.h" 3 ::: 25106
#pragma line 50 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.h" 2 3 ::: 25472
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/x86_64-unknown-linux-gnu/bits/ctype_inline.h" 1 3 ::: 26935
#pragma line 1512 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.h" 2 3 ::: 27012
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.tcc" 1 3 ::: 28109
#pragma line 35 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.tcc" 3 ::: 28145
#pragma line 731 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.tcc" 3 ::: 28824
#pragma line 1026 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.tcc" 3 ::: 29101
#pragma line 1153 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.tcc" 3 ::: 29220
#pragma line 2608 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/locale_facets.h" 2 3 ::: 29428
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h" 2 3 ::: 29429
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.tcc" 1 3 ::: 29864
#pragma line 34 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.tcc" 3 ::: 29899
#pragma line 473 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h" 2 3 ::: 30053
#pragma line 45 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ios" 2 3 ::: 30054
#pragma line 40 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ostream" 2 3 ::: 30055
#pragma line 585 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ostream" 3 ::: 30581
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/ostream.tcc" 1 3 ::: 30585
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/ostream.tcc" 3 ::: 30625
#pragma line 588 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ostream" 2 3 ::: 30994
#pragma line 40 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/iostream" 2 3 ::: 30995
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/istream" 1 3 ::: 30996
#pragma line 38 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/istream" 3 ::: 31035
#pragma line 856 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/istream" 3 ::: 31834
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/istream.tcc" 1 3 ::: 31838
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/istream.tcc" 3 ::: 31878
#pragma line 859 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/istream" 2 3 ::: 32932
#pragma line 41 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/iostream" 2 3 ::: 32933
#pragma line 69 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" 2 ::: 32971
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/limits.h" 1 3 ::: 32976
#pragma line 1 "/usr/include/limits.h" 1 3 4 ::: 33015
#pragma line 116 "/usr/include/limits.h" 3 4 ::: 33051
#pragma line 142 "/usr/include/limits.h" 3 4 ::: 33065
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/posix1_lim.h" 1 3 4 ::: 33068
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/local_lim.h" 1 3 4 ::: 33229
#pragma line 37 "/usr/include/x86_64-linux-gnu/bits/local_lim.h" 3 4 ::: 33253
#pragma line 1 "/usr/include/linux/limits.h" 1 3 4 ::: 33256
#pragma line 39 "/usr/include/x86_64-linux-gnu/bits/local_lim.h" 2 3 4 ::: 33257
#pragma line 161 "/usr/include/x86_64-linux-gnu/bits/posix1_lim.h" 2 3 4 ::: 33318
#pragma line 144 "/usr/include/limits.h" 2 3 4 ::: 33328
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/posix2_lim.h" 1 3 4 ::: 33332
#pragma line 87 "/usr/include/x86_64-linux-gnu/bits/posix2_lim.h" 3 4 ::: 33393
#pragma line 148 "/usr/include/limits.h" 2 3 4 ::: 33395
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/xopen_lim.h" 1 3 4 ::: 33399
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/stdio_lim.h" 1 3 4 ::: 33433
#pragma line 34 "/usr/include/x86_64-linux-gnu/bits/xopen_lim.h" 2 3 4 ::: 33450
#pragma line 119 "/usr/include/x86_64-linux-gnu/bits/xopen_lim.h" 3 4 ::: 33510
#pragma line 131 "/usr/include/x86_64-linux-gnu/bits/xopen_lim.h" 3 4 ::: 33512
#pragma line 152 "/usr/include/limits.h" 2 3 4 ::: 33514
#pragma line 39 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/limits.h" 2 3 ::: 33515
#pragma line 60 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/limits.h" 3 ::: 33520
#pragma line 90 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/limits.h" 3 ::: 33522
#pragma line 102 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/limits.h" 3 ::: 33524
#pragma line 74 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" 2 ::: 33529
#pragma line 111 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 33547
#pragma line 129 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 33550
#pragma line 147 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 33552
#pragma line 184 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 33565
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_dt.def" 1 ::: 33566
#pragma line 185 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" 2 ::: 34605
#pragma line 603 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 34606
#pragma line 646 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 34608
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_bits.h" 1 ::: 34609
#pragma line 98 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_bits.h" ::: 34662
#pragma line 108 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_bits.h" ::: 34664
#pragma line 129 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_bits.h" ::: 34666
#pragma line 143 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_bits.h" ::: 34671
#pragma line 156 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_bits.h" ::: 34674
#pragma line 192 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_bits.h" ::: 34676
#pragma line 358 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_bits.h" ::: 34678
#pragma line 647 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" 2 ::: 34680
#pragma line 881 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 34906
#pragma line 920 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 34935
#pragma line 1567 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 35575
#pragma line 1686 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 35682
#pragma line 1820 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 35808
#pragma line 2044 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 36017
#pragma line 2107 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 36072
#pragma line 2509 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 36467
#pragma line 2628 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 36575
#pragma line 2762 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 36701
#pragma line 2991 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 36914
#pragma line 3054 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 36969
#pragma line 3368 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37258
#pragma line 3403 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37280
#pragma line 3428 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37286
#pragma line 3462 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37299
#pragma line 3498 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37317
#pragma line 3534 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37335
#pragma line 3574 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37353
#pragma line 3628 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37371
#pragma line 3684 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37400
#pragma line 3731 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37429
#pragma line 3798 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37477
#pragma line 3823 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37495
#pragma line 3848 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37513
#pragma line 3893 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37545
#pragma line 4048 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37559
#pragma line 4074 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int_syn.h" ::: 37577
#pragma line 62 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int.h" 2 ::: 37594
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" 1 ::: 37595
#pragma line 62 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 37648
#pragma line 81 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 37652
#pragma line 1322 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 38884
#pragma line 1406 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 38955
#pragma line 1424 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 38965
#pragma line 1555 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39059
#pragma line 1600 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39078
#pragma line 1658 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39099
#pragma line 1690 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39117
#pragma line 1759 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39156
#pragma line 1773 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39159
#pragma line 1808 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39174
#pragma line 1820 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39176
#pragma line 1868 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39195
#pragma line 1882 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39198
#pragma line 1912 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39213
#pragma line 1959 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39247
#pragma line 2232 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39511
#pragma line 2350 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39561
#pragma line 2400 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39579
#pragma line 2485 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39634
#pragma line 2525 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_fixed_syn.h" ::: 39652
#pragma line 63 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_int.h" 2 ::: 39667
#pragma line 87 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/ap_axi_sdata.h" 2 ::: 40141
#pragma line 6 "./mem.h" 2 ::: 40171
#pragma line 1 "/usr/include/stdlib.h" 1 3 4 ::: 40173
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 1 3 4 ::: 40206
#pragma line 56 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 3 4 ::: 40231
#pragma line 33 "/usr/include/stdlib.h" 2 3 4 ::: 40234
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/waitflags.h" 1 3 4 ::: 40244
#pragma line 39 "/usr/include/x86_64-linux-gnu/bits/waitflags.h" 3 4 ::: 40273
#pragma line 42 "/usr/include/stdlib.h" 2 3 4 ::: 40291
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/waitstatus.h" 1 3 4 ::: 40292
#pragma line 66 "/usr/include/x86_64-linux-gnu/bits/waitstatus.h" 3 4 ::: 40348
#pragma line 43 "/usr/include/stdlib.h" 2 3 4 ::: 40381
#pragma line 57 "/usr/include/stdlib.h" 3 4 ::: 40387
#pragma line 83 "/usr/include/stdlib.h" 3 4 ::: 40392
#pragma line 96 "/usr/include/stdlib.h" 3 4 ::: 40394
#pragma line 302 "/usr/include/stdlib.h" 3 4 ::: 40571
#pragma line 1 "/usr/include/x86_64-linux-gnu/sys/types.h" 1 3 4 ::: 40585
#pragma line 70 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 ::: 40646
#pragma line 104 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 ::: 40653
#pragma line 115 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 ::: 40655
#pragma line 140 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 ::: 40664
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 1 3 4 ::: 40672
#pragma line 56 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 3 4 ::: 40697
#pragma line 147 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 ::: 40700
#pragma line 186 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 ::: 40710
#pragma line 1 "/usr/include/x86_64-linux-gnu/sys/select.h" 1 3 4 ::: 40745
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/select.h" 1 3 4 ::: 40776
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 ::: 40799
#pragma line 11 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 3 4 ::: 40801
#pragma line 23 "/usr/include/x86_64-linux-gnu/bits/select.h" 2 3 4 ::: 40803
#pragma line 31 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4 ::: 40804
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/sigset.h" 1 3 4 ::: 40808
#pragma line 34 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4 ::: 40848
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/time.h" 1 3 4 ::: 40861
#pragma line 46 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4 ::: 40883
#pragma line 220 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 ::: 40970
#pragma line 1 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 1 3 4 ::: 40974
#pragma line 58 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 3 4 ::: 41010
#pragma line 223 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 ::: 41014
#pragma line 262 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 ::: 41036
#pragma line 315 "/usr/include/stdlib.h" 2 3 4 ::: 41049
#pragma line 465 "/usr/include/stdlib.h" 3 4 ::: 41192
#pragma line 1 "/usr/include/alloca.h" 1 3 4 ::: 41221
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 1 3 4 ::: 41246
#pragma line 56 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/lnx64/tools/clang/bin/../lib/clang/3.1/include/stddef.h" 3 4 ::: 41271
#pragma line 25 "/usr/include/alloca.h" 2 3 4 ::: 41274
#pragma line 493 "/usr/include/stdlib.h" 2 3 4 ::: 41289
#pragma line 629 "/usr/include/stdlib.h" 3 4 ::: 41417
#pragma line 651 "/usr/include/stdlib.h" 3 4 ::: 41431
#pragma line 683 "/usr/include/stdlib.h" 3 4 ::: 41455
#pragma line 705 "/usr/include/stdlib.h" 3 4 ::: 41468
#pragma line 1 "/usr/include/x86_64-linux-gnu/bits/stdlib-float.h" 1 3 4 ::: 41719
#pragma line 955 "/usr/include/stdlib.h" 2 3 4 ::: 41737
#pragma line 967 "/usr/include/stdlib.h" 3 4 ::: 41740
#pragma line 8 "./mem.h" 2 ::: 41742
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/hls_stream.h" 1 ::: 41743
#pragma line 1 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_enum.h" 1 ::: 41810
#pragma line 67 "/opt/Xilinx_2017.1/Vivado_HLS/2017.1/common/technology/autopilot/hls_stream.h" 2 ::: 41945
#pragma line 9 "./mem.h" 2 ::: 42051
#pragma line 29 "./mem.h" ::: 42060
#pragma line 2 "mem.cpp" 2 ::: 42072
| [
"[email protected]"
] | |
9af14a9b992fe2b10d5a0c654f9a1d3082bde470 | 3b3a792c80203e905e346c6ef47a60ee2661f3f2 | /a2oj_51.cpp | cd5a244749ecd6ec0dff6aac9d3cd1ca6d8c5e8e | [] | no_license | avc9/ladder-2A | 08de717fa7fe977ddadbcd10c27940168629f20c | e22ca098f7b214ba04ca68c381d52725a80e1ba6 | refs/heads/main | 2023-02-05T02:42:59.328814 | 2020-12-25T07:03:23 | 2020-12-25T07:03:23 | 320,185,957 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 400 | cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
string s,t;
cin>>s;
cin>>t;
//cout<<s<<endl;
int position=0;
cout<<t.size()<<endl;
for(auto iter=0;iter<sizeof(t);iter++){
if(t[iter]==s[position]){
cout<<"IN "<<t[iter]<<" "<<s[position]<<endl;
position++;
}
}
cout<<(position+1);
return 0;
}
| [
"[email protected]"
] | |
1121c242431e2a9c201b1b43e789a0a94929ab2a | a1fdf55be58ba28fbed60fb9b65eb8fbf5d67af6 | /src/Core/ITKCommon/IRPruner.h | edb52822dc8bf9fa72ccb654cddb5a58ad7ea1ad | [] | no_license | rblake/seg3d2 | a8a28907207f5a95cfca1e47e4e0aa40a65d7d3b | aa65235b577732f506991021f16576332c64c4ae | refs/heads/master | 2016-09-07T18:49:54.102440 | 2015-03-26T19:17:53 | 2015-03-26T19:17:53 | 16,261,878 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,180 | h | /*
For more information, please see: http://software.sci.utah.edu
The MIT License
Copyright (c) 2013 Scientific Computing and Imaging Institute,
University of Utah.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// File : IRPruner.h
// Author : Bradley C. Grimm
// Created : 2009/05/15 11:52
// Copyright : (C) 2009 University of Utah
// Description : Used to prune uninteresting tiles.
#ifndef __IR_PRUNER_HXX__
#define __IR_PRUNER_HXX__
#include <string>
// boost:
#include <boost/filesystem.hpp>
namespace bfs=boost::filesystem;
class IRPruner
{
public:
typedef std::list<bfs::path> ImageList;
static void PruneImages(ImageList & image_names,
std::vector<base_transform_t::Pointer> &transform,
const unsigned int &shrink_factor,
const double &pixel_spacing,
const bool &use_std_mask,
const unsigned int &tile_size,
const double &intensity_tolerance,
float overlap_percent = 1.0f);
};
#endif
| [
"ayla@305cdda6-5ce1-45b3-a98d-dfc68c8b3305"
] | ayla@305cdda6-5ce1-45b3-a98d-dfc68c8b3305 |
f9c97273437096a679a62e9fb97651eb7a349b22 | 251dc7f60d26e4ae0998628a91cd620fad70944d | /tensorflow/compiler/jit/xla_device_context.h | a8ad511fbd2d7f06601608101b8346ff30f8fc20 | [
"Apache-2.0"
] | permissive | markostam/tensorflow | 8e148fdf5b11502cf7b846995e903c54edc5d58e | 90df8ab4ab127fac239597ce0708577a335613bf | refs/heads/master | 2020-03-07T13:08:31.584600 | 2018-03-30T20:16:16 | 2018-03-30T20:16:16 | 127,493,571 | 3 | 1 | Apache-2.0 | 2018-03-31T02:55:38 | 2018-03-31T02:55:37 | null | UTF-8 | C++ | false | false | 3,660 | h | /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_COMPILER_JIT_XLA_DEVICE_CONTEXT_H_
#define TENSORFLOW_COMPILER_JIT_XLA_DEVICE_CONTEXT_H_
#include <memory>
#include "tensorflow/compiler/jit/xla_tensor.h"
#include "tensorflow/compiler/xla/client/global_data.h"
#include "tensorflow/compiler/xla/client/local_client.h"
#include "tensorflow/core/framework/allocator.h"
#include "tensorflow/core/framework/device_base.h"
#include "tensorflow/core/lib/core/status.h"
namespace tensorflow {
// The allocator used for Tensors assigned to the XLA device. The allocator
// ignores the alignment and size of the request and always returns a new,
// empty, XlaTensor.
class XlaDeviceAllocator : public Allocator {
public:
XlaDeviceAllocator();
~XlaDeviceAllocator() override;
string Name() override;
void* AllocateRaw(size_t alignment, size_t num_bytes) override;
void DeallocateRaw(void* ptr) override;
void GetStats(AllocatorStats* stats) override;
};
// Helper class for managing data transfers between host and XLA devices.
class XlaTransferManager {
public:
explicit XlaTransferManager(perftools::gputools::Stream* stream,
xla::LocalClient* client,
bool transfer_as_literal);
void CopyCPUTensorToDevice(const Tensor* cpu_tensor, Device* device,
Tensor* device_tensor, StatusCallback done) const;
void CopyDeviceTensorToCPU(const Tensor* device_tensor,
StringPiece tensor_name, Device* device,
Tensor* cpu_tensor, StatusCallback done);
perftools::gputools::Stream* stream() const { return stream_; }
private:
// Stream obtained from a Device, used to transfer tensors between
// CPU and device.
perftools::gputools::Stream* stream_;
// For the underlying memory allocator and XLA's TransferManager.
xla::LocalClient* client_;
// True if we must use XLA's TransferManager for correct device transfers.
bool transfer_as_literal_;
};
// DeviceContext for operators assigned to XlaDevice devices. The
// implementation must inherit from DeviceContext but otherwise just
// wraps the methods in XlaTransferManager.
class XlaDeviceContext : public DeviceContext {
public:
explicit XlaDeviceContext(perftools::gputools::Stream* stream,
xla::LocalClient* client, bool transfer_as_literal);
void CopyCPUTensorToDevice(const Tensor* cpu_tensor, Device* device,
Tensor* device_tensor,
StatusCallback done) const override;
void CopyDeviceTensorToCPU(const Tensor* device_tensor,
StringPiece tensor_name, Device* device,
Tensor* cpu_tensor, StatusCallback done) override;
perftools::gputools::Stream* stream() const override {
return manager_.stream();
}
private:
XlaTransferManager manager_;
};
} // namespace tensorflow
#endif // TENSORFLOW_COMPILER_JIT_XLA_DEVICE_CONTEXT_H_
| [
"[email protected]"
] | |
43b25ad060f76582d743f96780591122b0aa4443 | 7810649933c047866ca4f25180b7faab05781cb3 | /src/software/simulation/threaded_simulator.h | 0bae6e479afb2cce771b4905f852be3f622798bb | [
"LGPL-3.0-only"
] | permissive | amrm3lm/Software | 21004f55defe7f29309396372976e7c72cbcc315 | 7f0db5a720e319a9efd35bbaa0a7a5fabaf72e95 | refs/heads/master | 2022-11-13T04:59:26.999944 | 2021-10-08T03:25:02 | 2021-10-08T03:25:02 | 210,059,814 | 0 | 0 | MIT | 2019-09-21T22:16:19 | 2019-09-21T22:16:19 | null | UTF-8 | C++ | false | false | 7,509 | h | #pragma once
#include <atomic>
#include <thread>
#include "proto/defending_side_msg.pb.h"
#include "proto/messages_robocup_ssl_wrapper.pb.h"
#include "shared/parameter/cpp_dynamic_parameters.h"
#include "software/simulation/simulator.h"
extern "C"
{
#include "proto/primitive.nanopb.h"
}
/**
* A wrapper for Simulator that runs in a separate thread with a callback registry
*/
class ThreadedSimulator
{
public:
/**
* Creates a new ThreadedSimulator. The starting state of the simulation
* will have the given field, with no robots or ball.
*
* @param field The field to initialize the simulation with
* @param robot_constants The robot constants
* @param wheel_constants The wheel constants
* @param simulator_config The config to fetch parameters from
*/
explicit ThreadedSimulator(const Field& field,
const RobotConstants_t& robot_constants,
const WheelConstants& wheel_constants,
std::shared_ptr<const SimulatorConfig> simulator_config);
~ThreadedSimulator();
/**
* Registers the given callback function. This callback function will be
* called each time the simulation updates and a new SSLProto::SSL_WrapperPacket
* is generated.
*
* Note: This function is threadsafe
*
* @param callback The callback function to register
*/
void registerOnSSLWrapperPacketReadyCallback(
const std::function<void(SSLProto::SSL_WrapperPacket)>& callback);
/**
* Starts running the simulator in a new thread. This is a non-blocking call.
* If the simulator is already running, this function does nothing.
*
* Note: This function is threadsafe
*/
void startSimulation();
/**
* Stops the simulation if it is running. If the simulation is not already
* running, this function does nothing.
*
* Note: This function is threadsafe
*/
void stopSimulation();
/**
* Sets the slow motion multiplier for the simulation. Larger values
* cause the simulation to run in slow motion. For example, a value
* of 2.0 causes the simulation to run 2x slower.
*
* Note: This function is threadsafe
*
* @pre multiplier is >= 1.0
*
* @param multiplier The slow motion multiplier
*/
void setSlowMotionMultiplier(double multiplier);
/**
* Resets the slow motion multiplier value to let the simulation
* run in real-time speed.
*/
void resetSlowMotionMultiplier();
/**
* Sets the state of the ball in the simulation. No more than 1 ball may exist
* in the simulation at a time. If a ball does not already exist, a ball
* is added with the given state. If a ball already exists, it's state is set to the
* given state.
*
* Note: This function is threadsafe.
*
* @param ball_state The new ball state
*/
void setBallState(const BallState& ball_state);
/**
* Removes the ball from the physics world. If a ball does not already exist,
* this has no effect.
*
* Note: This function is threadsafe.
*/
void removeBall();
/**
* Adds robots to the specified team with the given initial states.
*
* Note: These functions are threadsafe.
*
* @pre The robot IDs must not be duplicated and must not match the ID
* of any robot already on the specified team.
*
* @throws runtime_error if any of the given robot ids are duplicated, or a
* robot already exists on the specified team with one of the new IDs
*
* @param robots the robots to add
*/
void addYellowRobots(const std::vector<RobotStateWithId>& robots);
void addBlueRobots(const std::vector<RobotStateWithId>& robots);
/**
* Adds a robots to the specified team at the given position. The robot will
* automatically be given a valid ID.
*
* @param position the position at which to add the robot
*/
void addYellowRobot(const Point& position);
void addBlueRobot(const Point& position);
/**
* Sets the primitive being simulated by the robot in simulation
*
* @param id The id of the robot to set the primitive for
* @param primitive_msg The primitive to run on the robot
*/
void setYellowRobotPrimitive(RobotId id, const TbotsProto_Primitive& primitive_msg);
void setBlueRobotPrimitive(RobotId id, const TbotsProto_Primitive& primitive_msg);
/**
* Sets the primitive being simulated by the robot on the corresponding team
* in simulation
*
* @param primitive_set_msg The set of primitives to run on the robot
*/
void setYellowRobotPrimitiveSet(const TbotsProto_PrimitiveSet& primitive_set_msg);
void setBlueRobotPrimitiveSet(const TbotsProto_PrimitiveSet& primitive_set_msg);
/**
* Sets which side of the field the corresponding team is defending.
*
* This will flip robot and ball coordinates an applicable in order to present
* the firmware being simulated with data that matches our coordinate convention. See
* https://github.com/UBC-Thunderbots/Software/blob/master/docs/software-architecture-and-design.md#coordinates
* for more information about our coordinate conventions.
*
* @param defending_side_proto The side to defend
*/
void setYellowTeamDefendingSide(const DefendingSideProto& defending_side_proto);
void setBlueTeamDefendingSide(const DefendingSideProto& defending_side_proto);
/**
* Returns the PhysicsRobot at the given position. This function accounts
* for robot radius, so a robot will be returned if the given position is
* within the robot's radius from its position.
*
* @param position The position at which to check for a robot
*
* @return a weak_ptr to the PhysicsRobot at the given position if one exists,
* otherwise returns an empty pointer
*/
std::weak_ptr<PhysicsRobot> getRobotAtPosition(const Point& position);
/**
* Removes the given PhysicsRobot from the PhysicsWorld, if it exists.
*
* @param robot The robot to be removed
*/
void removeRobot(std::weak_ptr<PhysicsRobot> robot);
private:
/**
* The function that runs inside the simulation thread, handling
* updating the simulation and calling the callback functions.
*
* Note that because this function puts the simulation thread to
* sleep in order to simulate real-time simulation (ie. simulation
* time passes at the same speed as wall time), this means we will
* always run at realtime or slightly slower because of timing jitter
* due to the thread scheduler.
*/
void runSimulationLoop();
/**
* A helper function to update the callback functions with the latest
* data from the simulator
*/
void updateCallbacks();
std::vector<std::function<void(SSLProto::SSL_WrapperPacket)>>
ssl_wrapper_packet_callbacks;
std::mutex callback_mutex;
Simulator simulator;
std::mutex simulator_mutex;
std::thread simulation_thread;
bool simulation_thread_started;
std::mutex simulation_thread_started_mutex;
std::atomic_bool stopping_simulation;
std::atomic<double> slow_motion_multiplier = 1.0;
// 60HZ is approximately the framerate of the real-life cameras
static constexpr double TIME_STEP_SECONDS = 1.0 / 60.0;
};
| [
"[email protected]"
] | |
fd13516a317d54a334b9a06ac917665d90cc40af | 4b8219218f6c6ade37d2d989b331d71353c0f03f | /braces.cpp | 0e03311e749e78c1b8c3998ce713c795a11510d7 | [] | no_license | abbasidaniyal/ieee-code-1 | ff45d3e5e5049e4a7a67af96552085bbbeefda26 | 3b0afe524e56b4059731b32853315230d3054573 | refs/heads/master | 2020-04-10T13:53:23.235666 | 2018-12-09T17:01:58 | 2018-12-09T17:01:58 | 161,061,636 | 0 | 0 | null | 2018-12-09T17:01:07 | 2018-12-09T17:01:07 | null | UTF-8 | C++ | false | false | 2,032 | cpp | #include <iostream>
#include <string>
#include <vector>
using namespace std;
bool checkbraces(string s)
{
int cnt1=0,cnt2=0;
for (int i = 0; i < s.size() ; ++i)
{
if (s[i]=='(')
{
cnt1++;
}
else if (s[i]==')')
{
cnt1--;
}
else if (s[i]=='[')
{
cnt2++;
}
else if (s[i]==']')
{
cnt2--;
}
if (cnt1<0|| cnt2<0)
{
return false;
}
}
if (cnt1==cnt2)
return true ;
else return false ;
}
int main()
{
string s;
vector<char> s1,s2;
cin>>s;
int len=s.size();
bool flag;
flag=checkbraces(s);
if(!flag)
{
cout<<"impossible";
return 0;
}
char type1,type2;
int cnt1,cnt2;
for (int i = 0; i < s.size(); i++)
{
if(s[i]=='(' )
{
s1.push_back(s[i]);
cnt1++;
cout<<1<<" ";
}
else if ( s[i]=='[')
{
s1.push_back(s[i]);
cnt1++;
cout<<1<<" ";
}
if(s[i-1]=='[' && s[i]==']')
{
s1.push_back(s[i]);
cnt1++;
cout<<1<<" ";
}
if(s[i-1]=='(' && s[i]==')')
{
s1.push_back(s[i]);
cnt1++;
cout<<1<<" ";
}
if(s[i-1]=='(' && s[i]==']')
{
int k;
for (k = i-2; s[k] != '['; k--)
{
cout<<"\b\b \b";
}
for ( k = i-1; s[k] != '['; k--)
{
s2.push_back(s1[k]);
s1.pop_back();
cnt2++;
cout<<2<<" ";
}
s1.push_back(s[i]);
cnt1=cnt1 - (i-k);
cout<<1<<" " ;
}
if(s[i-2]=='[' && s[i]==')')
{
int k;
for (k = i-2; s[k] != '('; k--)
{
cout<<"\b\b \b" ;
}
for (k = i-1; s[k] != '('; k--)
{
s2.push_back(s1[k]);
s1.pop_back();
cnt2++;
cout<<2<<" ";
}
s1.push_back(s[i]);
cnt1=cnt1 - (i-k);
cout<<1<<" " ;
}
}
// if (cnt1!=cnt2)
// {
// cout<<"impossible";
// }
return 0;
} | [
"[email protected]"
] | |
242fca6d82b1592a5560067e4feeccb07e485f02 | 2aca3c2863fe7e25e0ce47002271136c7c24475e | /main.cc | e6fafde399e95153a2afbadce6e67cbfa3b68bbb | [] | no_license | hun-nemethpeter/cpp-modules-test | 220a0177cc2a762a18e0c3092c256e4ff31d97e6 | 40a956fe601735b3b302570524bc2c4ce7067a01 | refs/heads/master | 2016-09-05T08:59:21.066922 | 2013-12-18T16:59:56 | 2013-12-18T16:59:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 889 | cc | //#define string aaa
#include <dummy.h>
#include <IdPool.hh>
#include <Bug.h>
//#undef string
class Session : public IdResourceBase<Session>
{
public:
Session(unsigned id) : IdResourceBase<Session>(id)
{
std::cout << "Session ctor" << std::endl;
}
~Session()
{
std::cout << "Session dtor" << std::endl;
}
};
class App
{
public:
App()
: sessionPool(100)
{
std::cout << "Session pool: " << sessionPool.getUsedCount() << std::endl;
auto session = Session::create(sessionPool);
// auto session = Session::createUnique(sessionPool);
std::cout << "Hello session: " << session->getId() << std::endl;
std::cout << "Session pool: " << sessionPool.getUsedCount() << std::endl;
}
private:
std::string str;
std::vector<std::string> aa;
IdPool<Session> sessionPool;
};
int main()
{
App app;
foo("");
// Bug<int>::foo();
return 0;
}
| [
"[email protected]"
] | |
30c6cae205770f894b6095dacd100e0485dea8f1 | 0a45b8c5b07ae5e5f0b3c24ba0dce8467a62915f | /src/screening.cpp | a8b35db0b000ebfb3b5185c77a0be267631e06bf | [] | no_license | hugogogo/sprintr | ec2f70c8c1e67b787456315054dd13813bbda358 | 7a4120c862e455f922a4ff85ac561bb238475df1 | refs/heads/master | 2021-12-20T07:23:19.705473 | 2021-12-03T07:41:11 | 2021-12-03T07:41:11 | 199,120,296 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 11,544 | cpp | #include <cmath>
#include <queue>
#include <vector>
// we only include RcppArmadillo.h which automatically pulls Rcpp.h in for us
#include "RcppArmadillo.h"
class Triplet
{
private:
// j, k are the indices of the interaction
int j, k;
// the absolute correlation of the j,k interaction with some target
double abs_cor;
public:
Triplet(int _j, int _k, double _abs_cor)
{
j = _j;
k = _k;
abs_cor = _abs_cor;
}
int get_j() const{
return j;
}
int get_k() const{
return k;
}
double get_cor() const{
return abs_cor;
}
};
// user specified comparator
class Triplet_Comparator{
public:
bool operator() (const Triplet & p1, const Triplet & p2) const {
// note that here we use > instead of <
// so that the resulting heap is a min-heap
// (by default the C++ priority_queue is a max-heap)
return p1.get_cor() > p2.get_cor();
}
};
//' Sure Independence Screening in Step 2
//'
//' @param x a n-by-p matrix of main effects, with i.i.d rows, and each row represents a vector of observations of p main-effects
//' @param y a vector of length n. In sprinter, y is the residual from step 1
//' @param num_keep the number of candidate interactions in Step 2. Default to be n / [log n]
//' @param square An indicator of whether squared effects should be considered in Step 1 (NOT Step 2!). square == TRUE if squared effects have been considered in Step 1, i.e., squared effects will NOT be considered in Step 2.
//' @param main_effect An indicator of whether main effects should also be screened. Default to be false. The functionality of main_effect = true is not used in sprinter, but for SIS_lasso.
//' @return an matrix of 3 columns, representing the index pair of the selected interactions, and the corresponding absolute correlation with the residual.
//' @export
// [[Rcpp::export]]
arma::mat screen_cpp(const arma::mat & x, const arma::vec & y, const int num_keep, const bool square = false, const bool main_effect = false){
// main is TRUE if we want to screen main effects simultaneously
// square is TRUE if squared effects have been considered in the first step
// i.e., squared effects will NOT be considered in the screening step!
// screening all the interaction x_j*x_k based on its correlation with y
// return the indices (j, k) of the top k interactions
const int n = x.n_rows;
const int p = x.n_cols;
// j, k are used for indexing interactions
int j, k;
int count = 0;
double cur_cor = 0.0;
double cur_std = 0.0;
arma::vec temp_vec(n);
// matrix of num_keep by 2, storing the results
arma::mat result = arma::zeros<arma::mat>(num_keep, 3);
// Creates a Min heap of Triplets (ordered by absolute correlation with y)
std::priority_queue <Triplet, std::vector<Triplet>, Triplet_Comparator> min_heap;
// calculate the correlations in a stream way
if(square){
for(j = 0; j < p - 1; ++j){
for (k = j + 1; k < p; ++k){
// this is a little faster than calculating correlation
// and it gives the same results
temp_vec = x.unsafe_col(j) % x.unsafe_col(k);
cur_std = arma::stddev(temp_vec);
if (cur_std > 0){
cur_cor = fabs(arma::dot(temp_vec, y)) / cur_std;
// cor function when applied to two vectors, returns a 1-by-1 matrix
// cur_cor = fabs(arma::as_scalar(arma::cor(x.col(j) % x.col(k), y)));
if (count < num_keep){
// use emplace instead of push
// emplace avoids constructing a temporary Triplet
// emplace requires C++11, to use it, add
// // [[Rcpp::plugins(cpp11)]] in the top of the file
// min_heap.emplace(j, k, cur_cor);
// found that emplace really doesn't help
min_heap.push(Triplet(j, k, cur_cor));
++count;
} else{
if (cur_cor > min_heap.top().get_cor()){
// pop the current top element
min_heap.pop();
// insert the (j,k) interaction
// min_heap.emplace(j, k, cur_cor);
min_heap.push(Triplet(j, k, cur_cor));
}
}
}
}
}
}
else{
// squared effects are not considered in the first step
// include them in the screening
for(j = 0; j < p; ++j){
for (k = j; k < p; ++k){
temp_vec = x.unsafe_col(j) % x.unsafe_col(k);
cur_std = arma::stddev(temp_vec);
if (cur_std > 0){
cur_cor = fabs(arma::dot(temp_vec, y)) / arma::stddev(temp_vec);
// cor function when applied to two vectors, returns a 1-by-1 matrix
// cur_cor = fabs(arma::as_scalar(arma::cor(x.col(j) % x.col(k), y)));
if (count < num_keep){
// use emplace instead of push
// emplace avoids constructing a temporary Triplet
// emplace requires C++11, to use it, add
// // [[Rcpp::plugins(cpp11)]] in the top of the file
// min_heap.emplace(j, k, cur_cor);
min_heap.push(Triplet(j, k, cur_cor));
++count;
} else{
if (cur_cor > min_heap.top().get_cor()){
// pop the current top element
min_heap.pop();
// insert the (j,k) interaction
//min_heap.emplace(j, k, cur_cor);
min_heap.push(Triplet(j, k, cur_cor));
}
}
}
}
}
}
// if we need to screen main effects also
if(main_effect){
for(k = 0; k < p; ++k){
cur_std = arma::stddev(x.unsafe_col(k));
if (cur_std > 0){
cur_cor = fabs(arma::dot(x.unsafe_col(k), y)) / cur_std;
if (cur_cor > min_heap.top().get_cor()){
// pop the current top element
min_heap.pop();
// insert the (j,k) interaction
// for main effects, it corresponds to (0, k)
min_heap.push(Triplet(-1, k, cur_cor));
}
}
}
}
// now store the selected indices of interactions
for (count = 0; count < num_keep; ++count){
result(count, 0) = min_heap.top().get_j() + 1;
result(count, 1) = min_heap.top().get_k() + 1;
result(count, 2) = min_heap.top().get_cor();
min_heap.pop();
}
return result;
}
//' Sure Independence Screening in Step 2 for sparse design matrix
//'
//' @param x a n-by-p sparse matrix of main effects
//' @param y a vector of length n. In sprinter, y is the residual from step 1
//' @param num_keep the number of candidate interactions in Step 2. Default to be n / [log n]
//' @param square An indicator of whether squared effects should be considered in Step 1 (NOT Step 2!). square == TRUE if squared effects have been considered in Step 1, i.e., squared effects will NOT be considered in Step 2.
//' @param main_effect An indicator of whether main effects should also be screened. Default to be false. The functionality of main_effect = true is not used in sprinter, but for SIS_lasso.
//' @return an matrix of 3 columns, representing the index pair of the selected interactions, and the corresponding absolute correlation with the residual.
//' @export
// [[Rcpp::export]]
arma::mat screen_sparse_cpp(const arma::sp_mat & x, const arma::vec & y, const int num_keep, const bool square = false, const bool main_effect = false){
// main is TRUE if we want to screen main effects simultaneously
// square is TRUE if squared effects have been considered in the first step
// i.e., squared effects will NOT be considered in the screening step!
// screening all the interaction x_j*x_k based on its correlation with y
// return the indices (j, k) of the top k interactions
const int n = x.n_rows;
const int p = x.n_cols;
// j, k are used for indexing interactions
int j, k;
int count = 0;
double cur_cor = 0.0;
double cur_std = 0.0;
arma::vec temp_vec(n);
// matrix of num_keep by 2, storing the results
arma::mat result = arma::zeros<arma::mat>(num_keep, 3);
// Creates a Min heap of Triplets (ordered by absolute correlation with y)
std::priority_queue <Triplet, std::vector<Triplet>, Triplet_Comparator> min_heap;
// calculate the correlations in a stream way
if(square){
for(j = 0; j < p - 1; ++j){
for (k = j + 1; k < p; ++k){
// this is a little faster than calculating correlation
// and it gives the same results
// arma::vec temp_vec(x.col(j) % x.col(k));
temp_vec = x.col(j) % x.col(k);
cur_std = arma::stddev(temp_vec);
if(cur_std > 0){
cur_cor = fabs(arma::dot(temp_vec, y)) / cur_std;
// cor function when applied to two vectors, returns a 1-by-1 matrix
// cur_cor = fabs(arma::as_scalar(arma::cor(x.col(j) % x.col(k), y)));
if (count < num_keep){
// use emplace instead of push
// emplace avoids constructing a temporary Triplet
// emplace requires C++11, to use it, add
// // [[Rcpp::plugins(cpp11)]] in the top of the file
// min_heap.emplace(j, k, cur_cor);
// found that emplace really doesn't help
min_heap.push(Triplet(j, k, cur_cor));
++count;
} else{
if (cur_cor > min_heap.top().get_cor()){
// pop the current top element
min_heap.pop();
// insert the (j,k) interaction
// min_heap.emplace(j, k, cur_cor);
min_heap.push(Triplet(j, k, cur_cor));
}
}
}
}
}
}
else{
// squared effects are not considered in the first step
// include them in the screening
for(j = 0; j < p; ++j){
for (k = j; k < p; ++k){
temp_vec = x.col(j) % x.col(k);
cur_std = arma::stddev(temp_vec);
if(cur_std > 0){
cur_cor = fabs(arma::dot(temp_vec, y)) / cur_std;
// cor function when applied to two vectors, returns a 1-by-1 matrix
// cur_cor = fabs(arma::as_scalar(arma::cor(x.col(j) % x.col(k), y)));
if (count < num_keep){
// use emplace instead of push
// emplace avoids constructing a temporary Triplet
// emplace requires C++11, to use it, add
// // [[Rcpp::plugins(cpp11)]] in the top of the file
// min_heap.emplace(j, k, cur_cor);
min_heap.push(Triplet(j, k, cur_cor));
++count;
} else{
if (cur_cor > min_heap.top().get_cor()){
// pop the current top element
min_heap.pop();
// insert the (j,k) interaction
//min_heap.emplace(j, k, cur_cor);
min_heap.push(Triplet(j, k, cur_cor));
}
}
}
}
}
}
// if we need to screen main effects also
if(main_effect){
for(k = 0; k < p; ++k){
temp_vec = x.col(k);
cur_std = arma::stddev(temp_vec);
if(cur_std > 0){
cur_cor = fabs(arma::dot(temp_vec, y)) / cur_std;
if (cur_cor > min_heap.top().get_cor()){
// pop the current top element
min_heap.pop();
// insert the (j,k) interaction
// for main effects, it corresponds to (0, k)
min_heap.push(Triplet(-1, k, cur_cor));
}
}
}
}
// now store the selected indices of interactions
for (count = 0; count < num_keep; ++count){
result(count, 0) = min_heap.top().get_j() + 1;
result(count, 1) = min_heap.top().get_k() + 1;
result(count, 2) = min_heap.top().get_cor();
min_heap.pop();
}
return result;
}
| [
"[email protected]"
] | |
1b416041756fe8701d398e9664e9bf7ffe080c4b | ebd6ef77b04b657806df3343c09d30aeca558751 | /main1.cpp | 17f1a23fa5e1b868a9014c0181712d1dd3c522a4 | [] | no_license | ivanstar/LinkedList | 12f6d4f44e459c71ecf0a2f5640a6680c49d0bc7 | ba86876f314ad81f79d64575595db056b56ad4a6 | refs/heads/master | 2020-07-07T05:44:47.774024 | 2019-08-21T06:04:05 | 2019-08-21T06:04:05 | 203,268,859 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 498 | cpp | #include "LinkedList1.h"
#include <iostream>
using namespace std;
int main()
{
int sum,value,result;
LinkedList1 list;
list.insertFront(3);
list.insertFront(4);
list.insertFront(5);
list.insertBack(1);
list.insertBack(7);
list.print();
list.backward();
list.print();
sum = list.sum();
cout << "\nSum.." << sum;
cout << "\nEnter position: ";
cin >> value;
result = list.findValue(value);
cout << "Position " << value << " has integer: " << result;
return 0;
}
| [
"[email protected]"
] | |
44923b7a0fd2ab41b4d81001b4a47055f9127d27 | 2c49dc548230abe4d1665be56f4a6905b1cc7d29 | /src/physically_based/PhysicallyBasedScene.cpp | 904df5f296b4eafe0e4be8d224fb777f2c9d401e | [] | no_license | bencole12345/PhysicallyBasedRenderer | e0430434b51d04c6e3fe7fdf0f9215298d904d25 | b1db11fedc9de992f5b23bea539efa195fa1bca6 | refs/heads/main | 2023-06-05T06:18:34.160063 | 2021-06-21T22:26:08 | 2021-06-21T22:26:08 | 318,552,896 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,910 | cpp | #include "physically_based/PhysicallyBasedScene.h"
#include <memory>
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/functional/hash.hpp>
#include "core/PointLightSource.h"
#include "core/ShaderProgram.h"
#include "core/TexturePrecomputation.h"
#include "physically_based/EnvironmentMap.h"
#include "physically_based/PBRUtil.h"
#include "physically_based/PhysicallyBasedSceneObject.h"
namespace PBR::physically_based {
namespace {
struct PhysicallyBasedMaterialHasher {
size_t operator()(const PhysicallyBasedMaterial& material) const
{
size_t seed = 0;
boost::hash_combine(seed, boost::hash_value(material.albedo.r));
boost::hash_combine(seed, boost::hash_value(material.albedo.g));
boost::hash_combine(seed, boost::hash_value(material.albedo.b));
boost::hash_combine(seed, boost::hash_value(material.roughness));
boost::hash_combine(seed, boost::hash_value(material.metallic));
boost::hash_combine(seed, boost::hash_value(material.F0.r));
boost::hash_combine(seed, boost::hash_value(material.F0.g));
boost::hash_combine(seed, boost::hash_value(material.F0.b));
return seed;
}
};
} // anonymous namespace
PhysicallyBasedScene::PhysicallyBasedScene(std::vector<std::shared_ptr<PhysicallyBasedSceneObject>> sceneObjects,
std::vector<PointLightSource> lights,
std::shared_ptr<EnvironmentMap> environmentMap)
:Scene<PhysicallyBasedSceneObject>(std::move(sceneObjects), std::move(lights), glm::vec3(0.0f)),
environmentMap(environmentMap),
prefilteredEnvironmentMaps(),
brdfIntegrationMaps()
{
precomputePrefilteredEnvironmentMaps();
precomputeBRDFIntegrationMaps();
}
std::shared_ptr<EnvironmentMap> PhysicallyBasedScene::getEnvironmentMap() const
{
return environmentMap;
}
const std::vector<std::shared_ptr<Texture>>& PhysicallyBasedScene::getPrefilteredEnvironmentMaps() const
{
return prefilteredEnvironmentMaps;
}
const std::vector<std::shared_ptr<Texture>>& PhysicallyBasedScene::getBRDFIntegrationMaps() const
{
return brdfIntegrationMaps;
}
void PhysicallyBasedScene::precomputePrefilteredEnvironmentMaps()
{
std::unordered_map<PhysicallyBasedMaterial, std::shared_ptr<Texture>, PhysicallyBasedMaterialHasher> prefilteredCache;
prefilteredEnvironmentMaps.clear();
for (const auto& object : getSceneObjectsList()) {
auto it = prefilteredCache.find(object->material);
if (it == prefilteredCache.end()) {
// Not found, need to compute it and add it to the cache
std::shared_ptr<Texture> prefilteredEnvironmentMap = computePrefilteredEnvironmentMap(object->material);
prefilteredEnvironmentMaps.push_back(prefilteredEnvironmentMap);
prefilteredCache.insert(std::make_pair(object->material, prefilteredEnvironmentMap));
}
else {
// Found, use the one we computed already
prefilteredEnvironmentMaps.push_back(it->second);
}
}
}
std::shared_ptr<Texture> PhysicallyBasedScene::computePrefilteredEnvironmentMap(const PhysicallyBasedMaterial& material)
{
// Load the shader program
auto vertexShaderPath = PBRUtil::pbrShadersDir() / "PrepVerticesForRenderingTexture.vert";
auto fragmentShaderPath = PBRUtil::pbrShadersDir() / "ComputePreFilteredEnvironmentMap.frag";
ShaderProgram shader(vertexShaderPath, fragmentShaderPath);
// Code to set up uniforms
constexpr unsigned int mipmapLevels = 5;
auto setUniforms = [this, &shader, mipmapLevels, material](auto mipmapLevel) {
float roughness = (float) mipmapLevel / (float) (mipmapLevels - 1);
shader.resetUniforms();
shader.setUniform("radianceMap", this->environmentMap->getRadianceMap());
shader.setUniform("roughness", roughness);
shader.setUniform("dCoefficients.k_TrowbridgeReitzGGX", material.brdfCoefficients.normalDistribution.k_TrowbridgeReitzGGX);
shader.setUniform("dCoefficients.k_Beckmann", material.brdfCoefficients.normalDistribution.k_Beckmann);
shader.setUniform("gCoefficients.k_SchlickGGX", material.brdfCoefficients.geometricAttenutation.k_SchlickGGX);
shader.setUniform("gCoefficients.k_CookTorrance", material.brdfCoefficients.geometricAttenutation.k_CookTorrance);
};
// Allocate a texture ready for rendering
std::shared_ptr<Texture> texture(new Texture());
// Render the texture
constexpr unsigned int maxWidth = 512;
constexpr unsigned int maxHeight = 512;
TexturePrecomputation::renderToMipmappedTexture(texture, shader, maxWidth, maxHeight, mipmapLevels, setUniforms);
return texture;
}
void PhysicallyBasedScene::precomputeBRDFIntegrationMaps()
{
std::unordered_map<PhysicallyBasedMaterial, std::shared_ptr<Texture>, PhysicallyBasedMaterialHasher> brdfCache;
brdfIntegrationMaps.clear();
for (const auto& object : getSceneObjectsList()) {
auto it = brdfCache.find(object->material);
if (it == brdfCache.end()) {
// Not found, need to compute it and add it to the cache
std::shared_ptr<Texture> brdfIntegrationMap = computeBRDFIntegrationMap(object->material);
brdfIntegrationMaps.push_back(brdfIntegrationMap);
brdfCache.insert(std::make_pair(object->material, brdfIntegrationMap));
}
else {
// Found, use the one we computed already
brdfIntegrationMaps.push_back(it->second);
}
}
}
std::shared_ptr<Texture> PhysicallyBasedScene::computeBRDFIntegrationMap(const PhysicallyBasedMaterial& material)
{
auto vertexShader = PBRUtil::pbrShadersDir() / "PrepVerticesForRenderingTexture.vert";
auto fragmentShader = PBRUtil::pbrShadersDir() / "ComputeBRDFIntegrationMap.frag";
ShaderProgram shaderProgram(vertexShader, fragmentShader);
// Function for setting up shader uniforms
auto prepareShaderUniforms = [material, &shaderProgram]() {
shaderProgram.resetUniforms();
shaderProgram.setUniform("dCoefficients.k_TrowbridgeReitzGGX", material.brdfCoefficients.normalDistribution.k_TrowbridgeReitzGGX);
shaderProgram.setUniform("dCoefficients.k_Beckmann", material.brdfCoefficients.normalDistribution.k_Beckmann);
shaderProgram.setUniform("gCoefficients.k_SchlickGGX", material.brdfCoefficients.geometricAttenutation.k_SchlickGGX);
shaderProgram.setUniform("gCoefficients.k_CookTorrance", material.brdfCoefficients.geometricAttenutation.k_CookTorrance);
};
std::shared_ptr<Texture> texture(new Texture());
unsigned int width = 512, height = 512;
TexturePrecomputation::renderToTexture(texture, shaderProgram, width, height, prepareShaderUniforms);
return texture;
}
} // namespace PBR::physically_based
| [
"[email protected]"
] | |
f24e4e2536d7c6631cfa3907720a7a3615a4cbda | dc02e94a6b7f09714a85198af3ce5fb2cbc0def4 | /src/engine/shared/console.h | bbe267d4262d92a2c734813d921092609bbacf49 | [
"Zlib",
"LicenseRef-scancode-other-permissive"
] | permissive | SailorEx/Taschenrechner | 1c87791464f9cbeb094edaac7021703e3464ec93 | f4ac996469c5d02f51c92b2d0b60ba436bcaeeba | refs/heads/master | 2020-12-13T07:37:47.162881 | 2015-01-11T21:18:52 | 2015-01-11T21:18:52 | 234,348,839 | 0 | 1 | NOASSERTION | 2020-01-16T15:20:57 | 2020-01-16T15:20:56 | null | UTF-8 | C++ | false | false | 5,256 | h | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef ENGINE_SHARED_CONSOLE_H
#define ENGINE_SHARED_CONSOLE_H
#include <engine/console.h>
#include "memheap.h"
class CConsole : public IConsole
{
class CCommand : public CCommandInfo
{
public:
CCommand *m_pNext;
int m_Flags;
bool m_Temp;
FCommandCallback m_pfnCallback;
void *m_pUserData;
virtual const CCommandInfo *NextCommandInfo(int AccessLevel, int FlagMask) const;
void SetAccessLevel(int AccessLevel) { m_AccessLevel = clamp(AccessLevel, (int)(ACCESS_LEVEL_ADMIN), (int)(ACCESS_LEVEL_MOD)); }
};
class CChain
{
public:
FChainCommandCallback m_pfnChainCallback;
FCommandCallback m_pfnCallback;
void *m_pCallbackUserData;
void *m_pUserData;
};
int m_FlagMask;
bool m_StoreCommands;
const char *m_paStrokeStr[2];
CCommand *m_pFirstCommand;
class CExecFile
{
public:
const char *m_pFilename;
CExecFile *m_pPrev;
};
CExecFile *m_pFirstExec;
class IStorage *m_pStorage;
int m_AccessLevel;
CCommand *m_pRecycleList;
CHeap m_TempCommands;
static void Con_Chain(IResult *pResult, void *pUserData);
static void Con_Echo(IResult *pResult, void *pUserData);
static void Con_Exec(IResult *pResult, void *pUserData);
static void ConToggle(IResult *pResult, void *pUser);
static void ConToggleStroke(IResult *pResult, void *pUser);
static void ConModCommandAccess(IResult *pResult, void *pUser);
static void ConModCommandStatus(IConsole::IResult *pResult, void *pUser);
void ExecuteFileRecurse(const char *pFilename);
void ExecuteLineStroked(int Stroke, const char *pStr);
struct
{
int m_OutputLevel;
FPrintCallback m_pfnPrintCallback;
void *m_pPrintCallbackUserdata;
} m_aPrintCB[MAX_PRINT_CB];
int m_NumPrintCB;
enum
{
CONSOLE_MAX_STR_LENGTH = 1024,
MAX_PARTS = (CONSOLE_MAX_STR_LENGTH+1)/2
};
class CResult : public IResult
{
public:
char m_aStringStorage[CONSOLE_MAX_STR_LENGTH+1];
char *m_pArgsStart;
const char *m_pCommand;
const char *m_apArgs[MAX_PARTS];
CResult() : IResult()
{
mem_zero(m_aStringStorage, sizeof(m_aStringStorage));
m_pArgsStart = 0;
m_pCommand = 0;
mem_zero(m_apArgs, sizeof(m_apArgs));
}
CResult &operator =(const CResult &Other)
{
if(this != &Other)
{
IResult::operator=(Other);
int Offset = m_aStringStorage - Other.m_aStringStorage;
mem_copy(m_aStringStorage, Other.m_aStringStorage, sizeof(m_aStringStorage));
m_pArgsStart = Other.m_pArgsStart + Offset;
m_pCommand = Other.m_pCommand + Offset;
for(unsigned i = 0; i < Other.m_NumArgs; ++i)
m_apArgs[i] = Other.m_apArgs[i] + Offset;
}
return *this;
}
void AddArgument(const char *pArg)
{
m_apArgs[m_NumArgs++] = pArg;
}
virtual const char *GetString(unsigned Index);
virtual int GetInteger(unsigned Index);
virtual float GetFloat(unsigned Index);
};
int ParseStart(CResult *pResult, const char *pString, int Length);
int ParseArgs(CResult *pResult, const char *pFormat);
class CExecutionQueue
{
CHeap m_Queue;
public:
struct CQueueEntry
{
CQueueEntry *m_pNext;
FCommandCallback m_pfnCommandCallback;
void *m_pCommandUserData;
CResult m_Result;
} *m_pFirst, *m_pLast;
void AddEntry()
{
CQueueEntry *pEntry = static_cast<CQueueEntry *>(m_Queue.Allocate(sizeof(CQueueEntry)));
pEntry->m_pNext = 0;
if(!m_pFirst)
m_pFirst = pEntry;
if(m_pLast)
m_pLast->m_pNext = pEntry;
m_pLast = pEntry;
(void)new(&(pEntry->m_Result)) CResult;
}
void Reset()
{
m_Queue.Reset();
m_pFirst = m_pLast = 0;
}
} m_ExecutionQueue;
void AddCommandSorted(CCommand *pCommand);
CCommand *FindCommand(const char *pName, int FlagMask);
public:
CConsole(int FlagMask);
virtual const CCommandInfo *FirstCommandInfo(int AccessLevel, int FlagMask) const;
virtual const CCommandInfo *GetCommandInfo(const char *pName, int FlagMask, bool Temp);
virtual void PossibleCommands(const char *pStr, int FlagMask, bool Temp, FPossibleCallback pfnCallback, void *pUser);
virtual void ParseArguments(int NumArgs, const char **ppArguments);
virtual void Register(const char *pName, const char *pParams, int Flags, FCommandCallback pfnFunc, void *pUser, const char *pHelp);
virtual void RegisterTemp(const char *pName, const char *pParams, int Flags, const char *pHelp);
virtual void DeregisterTemp(const char *pName);
virtual void DeregisterTempAll();
virtual void Chain(const char *pName, FChainCommandCallback pfnChainFunc, void *pUser);
virtual void StoreCommands(bool Store);
virtual bool LineIsValid(const char *pStr);
virtual void ExecuteLine(const char *pStr);
virtual void ExecuteLineFlag(const char *pStr, int FlagMask);
virtual void ExecuteFile(const char *pFilename);
virtual int RegisterPrintCallback(int OutputLevel, FPrintCallback pfnPrintCallback, void *pUserData);
virtual void SetPrintOutputLevel(int Index, int OutputLevel);
virtual void Print(int Level, const char *pFrom, const char *pStr);
void SetAccessLevel(int AccessLevel) { m_AccessLevel = clamp(AccessLevel, (int)(ACCESS_LEVEL_ADMIN), (int)(ACCESS_LEVEL_MOD)); }
};
#endif
| [
"[email protected]"
] | |
ddd84ed0a59b647cdbd2c593e0c011d2cfff644f | e67bbbe53675728bd2035f059ff2257936c829ee | /libs/query/test/translator.cpp | 2f2d5c60f709a4ec364c59ae77453719ece4c553 | [] | no_license | galaxyeye/atlasdb | e4da3c7196b4be70ed4d012ba4941c85820428de | d53d1a8c9d41beeb42700c58d653b14d7d1e006e | refs/heads/master | 2021-01-01T17:47:54.761295 | 2013-05-16T14:33:35 | 2013-05-16T14:33:35 | 9,598,475 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 138 | cpp | /*
* translator.cpp
*
* Created on: Apr 21, 2013
* Author: vincent
*/
#include <atlasdb/query/ir_builder.h>
int main() {
}
| [
"[email protected]"
] | |
c0985bef042c1e9ee9361c79428c300dc445d0a1 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5648941810974720_1/C++/zyhzyhzyh/A.cpp | b9a3fb7ddf762073a2bf0234018d8a5c564d9d42 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 1,578 | cpp | #include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define PII pair<int,int>
typedef long long LL;
using namespace std;
char s[2010];
int T,c[300],ues[20],vis[30];
string S[10]={"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE"};
double a[30][20];
template<class T>
void read(T&x)
{
char ch=getchar();int mk=1;x=0;for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());
if (ch=='-') mk=-1,ch=getchar();for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-48;x*=mk;
}
int main()
{
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
scanf("%d",&T);
for(int _=1;_<=T;_++)
{
printf("Case #%d: ",_);
scanf("%s",s);
int l=strlen(s);
memset(c,0,sizeof(c));
for(int i=0;i<l;i++) c[s[i]-'A']++;
memset(a,0,sizeof(a));
for(int i=0;i<26;i++)
{
for(int j=0;j<10;j++)
for(int k=0;k<(int)S[j].size();k++)
a[i][j]+=(S[j][k]=='A'+i);
a[i][10]=c[i];
}
memset(ues,-1,sizeof(ues));
memset(vis,0,sizeof(vis));
for(int i=0;i<10;i++)
{
int l=-1;
for(int j=0;j<26;j++)
if (a[j][i]&&!vis[j])
{
l=j;ues[i]=j;vis[j]=1;break;
}
double k=a[l][i];
for(int j=0;j<=10;j++) a[l][j]/=k;
for(int k=0;k<26;k++)
if (k!=l)
{
double X=a[k][i];
for(int j=0;j<=10;j++) a[k][j]-=X*a[l][j];
}
}
for(int i=0;i<10;i++)
if (ues[i]!=-1)
for(int j=1;j<=a[ues[i]][10]+0.1;j++) printf("%d",i);
printf("\n");
}
}
| [
"[email protected]"
] | |
9d80cc15574ec4f8864b047d043015d7149f830c | 4a74ec1b7e299540b924bce4928537a51fc00ff5 | /CppAlgo/Project1/Project1/소스.cpp | 3c60298b889038bc579a05b6b938f0255a8d79b9 | [] | no_license | yeonlang/algorithm | ef74b2592818495f29f6de5f44f81ccf307efa59 | ab788658bb781773c489cac8c6e8d2bea48fda07 | refs/heads/master | 2020-04-22T20:25:46.243355 | 2019-05-08T15:17:45 | 2019-05-08T15:17:45 | 170,641,144 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 1,973 | cpp | #include <stdio.h>
const int maxR = 100;
const int maxC = 100;
int N, M, K, ans;
typedef struct FISH{
int big,y,x,s,d;
};
FISH data[maxR][maxC] = { 0, };
// 상하우좌
int dy[4] = { -1,1,0,0 };
int dx[4] = { 0,0,1,-1 };
void trans(int y, int x) {
int time;
time = 0;
while (time < data[y][x].s) {
if (data[y][x].d < 2) {
data[y][x].y += dy[data[y][x].d];
if (data[y][x].y==N or data[y][x].y==-1) {
data[y][x].y -= dy[data[y][x].d];
data[y][x].d += data[y][x].d % 2 ? -1 : 1;
data[y][x].y += dy[data[y][x].d];
}
}
else {
data[y][x].x += dx[data[y][x].d];
if (data[y][x].x == M or data[y][x].x == -1) {
data[y][x].x -= dx[data[y][x].d];
data[y][x].d += data[y][x].d % 2 ? -1 : 1;
data[y][x].x += dx[data[y][x].d];
}
}
time++;
}
}
void moving() {
FISH tempdata[maxR][maxC] = { 0, };
for (int y = 0; y < N; ++y)
for (int x = 0; x < M; ++x) {
if (!data[y][x].big == 0) {
trans(y, x);
//물고기가 있으면서
if (tempdata[data[y][x].y][data[y][x].x].big) {
//물고기의 크기가 더 큰놈이면 큰놈으로 갱신
if (tempdata[data[y][x].y][data[y][x].x].big < data[y][x].big) {
tempdata[data[y][x].y][data[y][x].x] = data[y][x];
}
}
//물고기가 없으면
else {
tempdata[data[y][x].y][data[y][x].x] = data[y][x];
}
}
}
for (int y = 0; y < N; ++y){
for (int x = 0; x < M; ++x) {
data[y][x] = tempdata[y][x];
}
}
}
int kill(int x) {
for (int y = 0; y < N; ++y) {
if (data[y][x].big) {
ans += data[y][x].big;
data[y][x].big = 0;
return 0;
}
}
return 0;
}
//int main() {
// scanf("%d %d %d", &n, &m, &k);
// int r, c, s, d, z;
// for (int i = 0; i < k; ++i) {
// scanf("%d %d %d %d %d", &r, &c, &s, &d, &z);
// r--; c--; d--;
// data[r][c] = { z,r,c,s,d };
// }
// int now_x;
// ans, now_x = 0, 0;
// while (now_x != m) {
// kill(now_x);
// moving();
// now_x++;
// }
// printf("%d", ans);
//}
| [
"[email protected]"
] | |
920d0addeb9d0f627701267a45a5bdb2d3a455d2 | a61ebd1507eeaa334aff44800b022ef0a258752a | /Code/HackerRank/Practice/leo_prime_factors.cpp | 0e233f64a087d7088fea4049a603639d26de5f5e | [
"MIT"
] | permissive | Jimut123/competitive_programming | 14ce0ab65414e6086763519f95487cddc91205a9 | b4cdebaceee719c1a256921829ebafda11c515f5 | refs/heads/master | 2023-03-05T15:42:57.194176 | 2022-04-08T08:53:26 | 2022-04-08T08:53:26 | 156,541,142 | 1 | 0 | null | 2019-05-29T17:10:28 | 2018-11-07T12:09:55 | C++ | UTF-8 | C++ | false | false | 707 | cpp | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
void Leoprime(long long num)
{
bool pno[num+1];
memset(pno, true, sizeof(pno));
for (int i = 2; i*i <= num; i++) {
if (pno[i] == true) {
for (int j = i*2; j <= num; j += i)
pno[j] = false;
}
}
long long k=1;
int d=0;
for (int i = 2; i <= num; i++){
if (pno[i]&& k<=num)
{
d++;
k=k*i;
}
cout<<k<<endl;
if(k>num)
break;
}
cout<<--d<<endl;
}
int main()
{
int T;
long long n;
cin>>T;
while(T--)
{
cin>>n;
if(n==1)
cout<<'0'<<endl;
else if(n==2)
cout<<'1'<<endl;
else
{
Leoprime(n);
}
}
return 0;
}
| [
"[email protected]"
] | |
27be0d3b175a426d1a6f1cfd14d0f2dc35a68a00 | f62cfd7268c83ff894880bdc71744f15715a3231 | /src/logger/dummy_logger.cpp | 8631dbfcf11c2f1b27e1226dd7c7c70f0b6a369d | [] | no_license | ewized/digital | 71c495247b1981ec93d4070c75a290c40e9b929a | 60cf960be0b3c465e197da2f4398f32eb9341f22 | refs/heads/master | 2020-06-16T13:25:18.795886 | 2016-11-27T16:48:37 | 2016-11-27T16:48:37 | 75,097,895 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 170 | cpp | /*
* Copyright 2016 ewized. All Rights Reserved.
*/
#include "logger.h"
#ifndef LOGGER
#include <string>
/** Do nothing */
void log(std::string message) {}
#endif
| [
"[email protected]"
] | |
6ef4b7dee966dbaa804748f9b2cf18dcd4af46eb | 99b6050160e7d89249720f8a49c7ed2aff6b6bad | /arduino/SmokerControl/SmokerController.h | 79d541af6b34278f36c7fefa2fb5d94667eea8fd | [] | no_license | ninjachris81/SmokerControl | 17cddcd2b32f92daeb620120de876a43c15b8335 | 1778e5229e9fa19abe720e93ce6d342eceeaf8c5 | refs/heads/master | 2021-05-08T01:29:36.025799 | 2020-04-20T21:16:03 | 2020-04-20T21:16:03 | 107,863,695 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,270 | h | #ifndef SMOKERCONTROLLER_H
#define SMOKERCONTROLLER_H
#include <AbstractIntervalTask.h>
#include "Debug.h"
#include "Pins.h"
#include "BehaviorProperty.h"
#include "Simulation.h"
#define PROP_HEATER 0
#define TARGET_TEMP_TOLERANCE 5.0
#define HEATER_DELAY_MS 20000
class SmokerController : public AbstractIntervalTask, public Property<bool>::ValueChangeListener {
public:
struct SmokerProfile {
String name;
float insideTemp;
float meatTargetTemp;
bool autoStop;
};
enum SMOKER_STATUS {
STATUS_PREHEATING,
STATUS_READY,
STATUS_RUNNING,
STATUS_TARGET_REACHED,
STATUS_FINISHED
};
SmokerController();
void init();
void update();
void onPropertyValueChange(uint8_t id, bool newValue, bool oldValue);
void start();
void stop();
void finish();
uint64_t getDuration();
SMOKER_STATUS getStatus();
SmokerProfile getCurrentProfile();
private:
uint64_t startTime;
uint64_t endTime;
void setStatus(SMOKER_STATUS newState);
SMOKER_STATUS mStatus = STATUS_PREHEATING;
BehaviorProperty<bool> heaterState;
SmokerProfile currentProfile;
#ifdef IS_SIMULATION
uint8_t simulationDelay = 0;
#endif
};
#endif
| [
"[email protected]"
] | |
4c32da4517c5e2d5116c411963b3180fa348574e | 8a14c4f4ca487e673d8b0d5feb7bf3e6d723b9f0 | /Code Storage/小知识点/Windows/GraphLib/C5Sides.cpp | 8a9769926ef73407be88885ff1348751153fdcc8 | [] | no_license | tyekrgk/code-refrence | 47c0185161577d35302434fe7d06b9f0a5853ea0 | 019d120ce62504320c50ce0ca23e562a14e3d0bb | refs/heads/master | 2021-05-28T13:59:08.079034 | 2013-11-05T09:24:47 | 2013-11-05T09:24:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,502 | cpp | #include "stdafx.h"
#include "GraphLib.h"
C5Sides::C5Sides(int nWidth, Color crColor, DashStyle dashstyle)
{
m_nMinCount = 5;
m_nWidth = nWidth;
m_crColor = crColor;
m_ptary.SetSize(7,1);
m_nDashStyle = dashstyle;
InitGraphData();
}
C5Sides::C5Sides()
{
}
C5Sides::C5Sides(const C5Sides& gph)
{
CopyTheBaseDataMember(&gph);
m_ptary.SetSize(5,1);
m_ptary.RemoveAll();
m_ptary.Copy(gph.m_ptary);
m_ptarytemp.RemoveAll();
m_ptarytemp.Copy(gph.m_ptarytemp);
m_Region.MakeEmpty();
m_Region.Union(&gph.m_Region);
}
C5Sides & C5Sides::operator = (const C5Sides& gph)
{
CopyTheBaseDataMember(&gph);
m_ptary.SetSize(5,1);
m_ptary.RemoveAll();
m_ptary.Copy(gph.m_ptary);
m_ptarytemp.RemoveAll();
m_ptarytemp.Copy(gph.m_ptarytemp);
m_Region.MakeEmpty();
m_Region.Union(&gph.m_Region);
return *this;
}
C5Sides::~C5Sides()
{
m_ptarytemp.RemoveAll();
}
void C5Sides::InitGraphData()
{
m_ptary[0].X = 35.000004f;
m_ptary[0].Y = 0.000000f;
m_ptary[1].X = 1.713023f;
m_ptary[1].Y = 24.184404f;
m_ptary[2].X = 14.427510f;
m_ptary[2].Y = 63.315590f;
m_ptary[3].X = 55.572475f;
m_ptary[3].Y = 63.315598f;
m_ptary[4].X = 68.286980f;
m_ptary[4].Y = 24.184412f;
}
void C5Sides::Draw(CDC* pDC,CRect& rcInvalid)
{
if(m_nPtCount <= 0)
return;
Pen penDraw(m_crColor,(float)m_nWidth);
penDraw.SetLineJoin(LineJoinRound);
penDraw.SetDashStyle(m_nDashStyle);
Graphics graph(pDC->m_hDC);
graph.SetSmoothingMode(SmoothingModeAntiAlias);
Matrix mat;
mat.RotateAt(m_fAngle,m_ptCenter);
graph.SetTransform(&mat);
if(!m_bFinish)
{
if(m_nPtCount <= 1)
{
return;
}
PointF* pPt = m_ptarytemp.GetData();
graph.DrawPolygon(&penDraw,pPt,5);
}
else
{
if(m_bSelected || m_bEdit)
{
DrawHotShape(graph);
}
graph.ExcludeClip(&m_RgnErase);
PointF* pPt = m_ptary.GetData();
graph.DrawPolygon(&penDraw,pPt,m_nPtCount);
}
}
void C5Sides::FinishGraph()
{
m_ptarytemp.RemoveAll();
m_ptary.RemoveAt(5,2);
if(m_nPtCount == 5)
{
m_bFinish = TRUE;
InitHotData();
}
return;
}
void C5Sides::SetRegion()
{
PointF* pPt = m_ptary.GetData();
int nWidth = m_nWidth;
Pen penDraw(Color(255, 0, 255, 0));
penDraw.SetDashStyle(m_nDashStyle);
penDraw.SetWidth((float)m_nWidth);
GraphicsPath path;
path.AddPolygon(pPt, m_nPtCount);
path.Widen(&penDraw);
path.Outline();
m_Region.MakeEmpty();
m_Region.Union(&path);
}
void C5Sides::FormGraphData(UINT nMouseState,CPoint point,CRect& rcUpdate)
{
PointF pt((float)point.x,(float)point.y);
if(MS_LBTNDOWN == nMouseState)
{
m_ptary[5] = pt;
m_nPtCount = 1;
}
else if(m_nPtCount >= 1)
{
m_ptary[6] = pt;
m_nPtCount = 2;
NormalizeTempData();
if(MS_LBTNUP == nMouseState)
{
m_bFinish = TRUE;
m_ptarytemp.RemoveAll();
NormalizeGraphData();
InitHotData();
rcUpdate = m_rcHot;
}
}
else
{
rcUpdate.SetRect(0, 0, 1, 1);
}
}
void C5Sides::NormalizeGraphData()
{
float fleft = min(m_ptary[5].X, m_ptary[6].X);
float ftop = min(m_ptary[5].Y, m_ptary[6].Y);
if(m_ptary[5].X == m_ptary[6].X
&& m_ptary[5].Y == m_ptary[6].Y)
{
for(int i = 0; i < 5; i++)
{
m_ptary[i].X += fleft;
m_ptary[i].Y += ftop;
}
}
else
{
float fWidthOrg = m_ptary[4].X - m_ptary[1].X;
float fHeightOrg = m_ptary[3].Y - m_ptary[0].Y;
float fWidth = fabs(m_ptary[5].X - m_ptary[6].X);
float fHeight = fabs(m_ptary[5].Y - m_ptary[6].Y);
float fscalex = fWidth / fWidthOrg;
float fscaley = fHeight / fHeightOrg;
for(int i = 0; i < 5; i++)
{
m_ptary[i].X = m_ptary[i].X * fscalex + fleft;
m_ptary[i].Y = m_ptary[i].Y * fscaley + ftop;
}
}
m_ptary.RemoveAt(5,2);
m_nPtCount = 5;
}
void C5Sides::NormalizeTempData()
{
m_ptarytemp.Copy(m_ptary);
float fleft = min(m_ptarytemp[5].X, m_ptarytemp[6].X);
float ftop = min(m_ptarytemp[5].Y, m_ptarytemp[6].Y);
float fWidthOrg = m_ptarytemp[4].X - m_ptarytemp[1].X;
float fHeightOrg = m_ptarytemp[3].Y - m_ptarytemp[0].Y;
float fWidth = fabs(m_ptarytemp[5].X - m_ptarytemp[6].X);
float fHeight = fabs(m_ptarytemp[5].Y - m_ptarytemp[6].Y);
float fscalex = fWidth / fWidthOrg;
float fscaley = fHeight / fHeightOrg;
for(int i = 0; i < 5; i++)
{
m_ptarytemp[i].X = m_ptarytemp[i].X * fscalex + fleft;
m_ptarytemp[i].Y = m_ptarytemp[i].Y * fscaley + ftop;
}
}
| [
"[email protected]"
] | |
bad559846932bc391a7a7ffe5fdd61c61d0e72d6 | fe739acd76bba1028e38c67607424ee1b4bd0c05 | /EJElena/26_hoja-VI-3_bisiesto.cpp | 09c0fb2bf692ee7ade01481aa5051cb897d8b35c | [] | no_license | vtsartas/EJCpp | ad57f3f21c9d198d0685023356feeeb2f939bc25 | d340b3d7a74e6d96b559720269fa88da8f195318 | refs/heads/master | 2020-12-09T18:30:17.892969 | 2020-01-16T20:51:46 | 2020-01-16T20:51:46 | 233,383,248 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 791 | cpp | #include <iostream> // Librería básica de entrada y salida, necesaria para cout, cin...
#include <conio.h> // Se incluye para pausar el programa al final hasta que se pulse una tecla y que no se cierre
using namespace std;
// Ejercicio 26 - Hoja VI (3) - Verificar si el año dado es bisiesto según las indicaciones dadas
int main(){
// Definimos la variable a utilizar
int year;
cout<<"Introduce el año del que deseas comprobar si es o no bisiesto: ";
cin>>year;
// Comprobamos según las indicaciones dadas si es o no bisiesto
if ((year%4==0 && year%100!=0) || (year%100==0 && year%400==0)) {
cout<<"El año "<<year<<" es bisiesto.";
}
else {
cout<<"El año "<<year<<" NO es bisiesto.";
}
cout <<"\nPulse una tecla para salir";
getch();
return 0;
}
| [
"[email protected]"
] | |
6a47057372274063b1e5f1be4e718b10e0efb8d0 | a90546b830d2c37e5db9284fe099b0f0658e723a | /libraries/eosiolib/tester/wasi_polyfill/__wasi_fd_seek.cpp | 477cb71c36d27f3277271ee3989691fe55657410 | [
"BSL-1.0",
"MIT"
] | permissive | NorseGaud/Eden | afba632342c2b56018e8d5d5bb8db38d81189f8f | 56610ebea830c3e7febe3f0c42d8fdc7dec609a5 | refs/heads/main | 2023-05-02T19:20:36.591718 | 2021-05-17T13:36:30 | 2021-05-17T21:39:01 | 365,883,543 | 0 | 0 | MIT | 2021-05-10T01:19:47 | 2021-05-10T01:19:47 | null | UTF-8 | C++ | false | false | 580 | cpp | #include <wasi/api.h>
extern "C" __wasi_errno_t __wasi_fd_seek(__wasi_fd_t fd,
__wasi_filedelta_t offset,
__wasi_whence_t whence,
__wasi_filesize_t* newoffset)
__attribute__((__import_module__("wasi_snapshot_preview1"), __import_name__("fd_seek")))
{
[[clang::import_name("prints")]] void prints(const char*);
[[clang::import_name("tester_abort"), noreturn]] void tester_abort();
prints("__wasi_fd_seek not implemented");
tester_abort();
}
| [
"[email protected]"
] | |
50cee1b6176c4ebb25d6e8a6a7b62565180cb7fc | d51ec7da9ef4be2d37f996913df350704037ef9b | /Semana 1/ACMC-7206.cpp | 9360e18552692501767db415873c478504009f32 | [] | no_license | lucasx95/Desafios | dc2686c444d4e90fce8df660acabad723f3f9a3c | 04d1000c9931cb90411e2845d443b1047364ef27 | refs/heads/master | 2020-04-06T06:43:44.060865 | 2016-05-31T17:39:15 | 2016-05-31T17:39:15 | 53,157,094 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,030 | cpp | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int n,m,budget,card,sumRound,daedelusPoints, daedelusCard, maxPoints;
vector<int> cards;
cards.push_back(10000);
cards.push_back(1000);
cards.push_back(100);
cards.push_back(10);
cards.push_back(1);
while(cin >> n){
cin >> m;
maxPoints = daedelusPoints = 0;
for(int i = 0; i < m; i++){
cin >> budget;
//cout << "B: " << budget << endl;
cin >> daedelusCard;
sumRound = 0;
for(int j = 0; j < n-1; j++){
cin >> card;
sumRound += card;
}
if (sumRound + daedelusCard <= budget){
daedelusPoints += daedelusCard;
}
//cout << "DIF: " << budget - sumRound << endl;
bool flag = true;
for(unsigned int i = 0; i < cards.size() && flag; i++){
if(cards[i] + sumRound <= budget){
maxPoints += cards[i];
flag = false;
}
}
//cout << "DP: " << daedelusPoints << endl;
//cout << "MP: " << maxPoints << endl;
}
cout << maxPoints - daedelusPoints << endl;
}
return 0;
}
| [
"[email protected]"
] | |
5998934c4e24b477cc0ca79a0e6f2303f272d8b6 | 5ac13fa1746046451f1989b5b8734f40d6445322 | /minimangalore/Nebula2/code/mangalore/msg/ui/dragboxcancelled.cc | 7d030bc18df822f95213ec0bc4699cea4c6436e9 | [] | no_license | moltenguy1/minimangalore | 9f2edf7901e7392490cc22486a7cf13c1790008d | 4d849672a6f25d8e441245d374b6bde4b59cbd48 | refs/heads/master | 2020-04-23T08:57:16.492734 | 2009-08-01T09:13:33 | 2009-08-01T09:13:33 | 35,933,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 450 | cc | //------------------------------------------------------------------------------
// msg/ui/dragboxcancelled.cc
// (C) 2006 Radon Labs GmbH
//------------------------------------------------------------------------------
#include "msg/ui/dragboxcancelled.h"
namespace Message
{
ImplementRtti(Message::DragBoxCancelled, Message::Msg);
ImplementFactory(Message::DragBoxCancelled);
ImplementMsgId(DragBoxCancelled);
} // namespace Message
| [
"BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c"
] | BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c |
1591d04f9f960b247ea57088a852a1bebbe66a87 | ea401c3e792a50364fe11f7cea0f35f99e8f4bde | /hackathon/PengXie/NeuronStructNavigator/cmake-3.6.2/Tests/CMakeCommands/target_compile_features/main.cpp | 6f5daee0bbcc2ac3e98d3f827bfd354e46912e5b | [
"MIT",
"BSD-3-Clause"
] | permissive | Vaa3D/vaa3d_tools | edb696aa3b9b59acaf83d6d27c6ae0a14bf75fe9 | e6974d5223ae70474efaa85e1253f5df1814fae8 | refs/heads/master | 2023-08-03T06:12:01.013752 | 2023-08-02T07:26:01 | 2023-08-02T07:26:01 | 50,527,925 | 107 | 86 | MIT | 2023-05-22T23:43:48 | 2016-01-27T18:19:17 | C++ | UTF-8 | C++ | false | false | 53 | cpp |
int main(int, char**)
{
auto i = 0;
return i;
}
| [
"[email protected]"
] | |
6bfa926ed5b22fd8b65dd23fb8990abbb5a32a92 | e85b706cd3644a2b734ba6966ea183c06e32db07 | /Feet.cpp | b8862b5f88284950e6ecb0563d6523d1b00b819c | [] | no_license | PurplePerilla/Feet | c0e26515051a65818e6c8c0747634fa4d2c78eb8 | 6df1c5144e27fede1016cdeb8ca11ff3104df04a | refs/heads/master | 2020-05-29T19:19:37.604784 | 2019-05-30T01:58:55 | 2019-05-30T01:58:55 | 189,327,284 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 920 | cpp | // ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include"iostream"
using namespace std;
class CFeet
{
private:
int feet;
int inches;
public:
CFeet();
CFeet(int f, int i);
int setFeet(int f, int i);
void displayFeet();
int check();
};
CFeet::CFeet()
{
feet = 0;
inches = 0;
}
CFeet::CFeet(int f,int i)
{
feet = f;
inches = i;
if (check() == 1)
{
cout << feet << "feet" << inches << "inches" << endl;
}
}
int CFeet::setFeet(int f, int i)
{
feet = f;
inches = i;
if (check() == 1)
{
cout << feet << "feet" << inches << "inches" << endl;
}
return 0;
}
void CFeet::displayFeet()
{
cout << feet << "feet" << inches << "inches" << endl;
}
int CFeet::check()
{
if (inches >= 12)
{
while (inches / 12 > 0)
{
feet++;
inches -= 12;
}
return 1;
}
return 0;
}
int main()
{
CFeet od;
od.setFeet(2,62);
od.displayFeet();
return 0;
}
| [
"[email protected]"
] | |
543e5f24415e25ef325c2b03dcb8950f7ed40d0c | 24357a12af42349b9b787b47722a738a6694419b | /Learn/30-Days-Of-Code/Day 19/interfaces.cpp | 683e2eb23576018036fb20cd81cefd9fe9f980dd | [
"MIT"
] | permissive | Adriel-M/HackerRank | 1aee2f3501f7db01bf2c7eabc00ff555779a345c | 0f361bb7eaa3d2db3dd96de511c4b7fa02efa8c5 | refs/heads/master | 2021-01-21T10:49:03.610333 | 2017-06-18T03:37:16 | 2017-06-18T03:37:16 | 91,708,001 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 680 | cpp | #include <iostream>
using namespace std;
class AdvancedArithmetic {
public:
virtual int divisorSum(int n) = 0;
};
class Calculator : public AdvancedArithmetic {
public:
int divisorSum(int n) {
int s = n > 1 ? n + 1 : 1;
for (int i = 2; i < ((n / 2) + 1); i++) {
if (n % i == 0) {
s += i;
}
}
return s;
}
};
int main() {
int n;
cin >> n;
AdvancedArithmetic *myCalculator = new Calculator();
int sum = myCalculator->divisorSum(n);
cout << "I implemented: AdvancedArithmetic" << endl;
cout << sum << endl;
return 0;
}
| [
"[email protected]"
] | |
acb06cdd34aa12055c9f8b66c1d27b4f5cea2d34 | e280a47865b1d8d6b184940f49e3e1b9a8035ee1 | /Lab 4/ex3.cpp | c3f4bc75f9cd5cb32c5a5ea39eef9ec4b4fc3c5c | [] | no_license | LeAlmond/Programming-1 | 4f0229a0e6405504f810223011508307ba00929a | 39d1425ab7f1460958e45d27807fbaa7c7450aeb | refs/heads/master | 2023-08-20T05:22:52.898186 | 2021-10-20T17:37:30 | 2021-10-20T17:37:30 | 294,236,209 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 456 | cpp | #include <stdio.h>
int main()
{
int a1, a2, a3, max;
printf("%s","Enter first age ");
scanf("%i",&a1 );
printf("%s","Enter second age ");
scanf("%i",&a2 );
printf("%s","Enter second age ");
scanf("%i",&a3 );
max = a1;
if (a2 > max) {
max = a2;
}
if (a3 > max) {
max = a3;
}
printf("Eldest %i",max );
return 0;
}
| [
"[email protected]"
] | |
4d906e413da9eca8f22150d4698d0e1aac0f596c | 2636985df14f40006499fd7da0986c3404326c52 | /src/test/config_tests.cpp | 16997c886ca6d1fc7e286181cfcffc8f962b5869 | [
"MIT"
] | permissive | bitcoincandyofficial/bitcoincandy | 37feb54ad72522854a272395110b5b2e7d1a55cb | aa72d2440ed5b7f07bef017aa6f8465d06162ff2 | refs/heads/master | 2022-07-06T01:24:07.956560 | 2021-12-15T14:41:57 | 2021-12-15T14:41:57 | 120,779,114 | 33 | 14 | MIT | 2022-06-20T22:39:41 | 2018-02-08T15:27:24 | C++ | UTF-8 | C++ | false | false | 2,051 | cpp | // Copyright (c) 2016 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "config.h"
#include "chainparams.h"
#include "consensus/consensus.h"
#include "test/test_bitcoin.h"
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(config_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(max_block_size) {
GlobalConfig config;
// Too small.
BOOST_CHECK(!config.SetMaxBlockSize(0));
BOOST_CHECK(!config.SetMaxBlockSize(12345));
BOOST_CHECK(!config.SetMaxBlockSize(LEGACY_MAX_BLOCK_SIZE - 1));
BOOST_CHECK(!config.SetMaxBlockSize(LEGACY_MAX_BLOCK_SIZE));
// LEGACY_MAX_BLOCK_SIZE + 1
BOOST_CHECK(config.SetMaxBlockSize(LEGACY_MAX_BLOCK_SIZE + 1));
BOOST_CHECK_EQUAL(config.GetMaxBlockSize(), LEGACY_MAX_BLOCK_SIZE + 1);
// 2MB
BOOST_CHECK(config.SetMaxBlockSize(2 * ONE_MEGABYTE));
BOOST_CHECK_EQUAL(config.GetMaxBlockSize(), 2 * ONE_MEGABYTE);
// 8MB
BOOST_CHECK(config.SetMaxBlockSize(8 * ONE_MEGABYTE));
BOOST_CHECK_EQUAL(config.GetMaxBlockSize(), 8 * ONE_MEGABYTE);
// Invalid size keep config.
BOOST_CHECK(!config.SetMaxBlockSize(54321));
BOOST_CHECK_EQUAL(config.GetMaxBlockSize(), 8 * ONE_MEGABYTE);
// Setting it back down
BOOST_CHECK(config.SetMaxBlockSize(7 * ONE_MEGABYTE));
BOOST_CHECK_EQUAL(config.GetMaxBlockSize(), 7 * ONE_MEGABYTE);
BOOST_CHECK(config.SetMaxBlockSize(ONE_MEGABYTE + 1));
BOOST_CHECK_EQUAL(config.GetMaxBlockSize(), ONE_MEGABYTE + 1);
}
BOOST_AUTO_TEST_CASE(chain_params) {
GlobalConfig config;
// Global config is consistent with params.
SelectParams(CBaseChainParams::MAIN);
BOOST_CHECK_EQUAL(&Params(), &config.GetChainParams());
SelectParams(CBaseChainParams::TESTNET);
BOOST_CHECK_EQUAL(&Params(), &config.GetChainParams());
SelectParams(CBaseChainParams::REGTEST);
BOOST_CHECK_EQUAL(&Params(), &config.GetChainParams());
}
BOOST_AUTO_TEST_SUITE_END()
| [
"[email protected]"
] | |
21eaa2506093ca38ca10e411a2a85126367390f0 | 493a4c99ba7d2122bcca2a495b87bf190ece5750 | /LCM.cpp | 249069cf11a64c14cd733a0cc2c305c983ab9caf | [] | no_license | md-qubais/Data_Structures_Algorithms_and_Competitive_Programming | 9b8d38c05522568bbf4cffa95dc5390a3aaae1cb | d7157c27720fa28ead3d4562e423ad719aabd87b | refs/heads/main | 2023-04-02T12:36:34.482803 | 2021-04-05T08:31:14 | 2021-04-05T08:31:14 | 354,769,143 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 367 | cpp | #include<bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a,ll b){
return b==0?a:gcd(b,a%b);
}
int main()
{
#ifndef qubais_judge
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll a,b;
cin>>a>>b;
cout<<(a*b)/gcd(a,b)<<endl;
return 0;
} | [
"[email protected]"
] | |
071a641a796e340ace92df2eb39790d6e23b6119 | 8b76d8f5949e7d1a2a2b2d84cbeab08d3d2e0b62 | /inc/inl/atomic_value.hxx | 26ea2393e3586ac4cad5ce31bfac7a3cb5bf72f3 | [] | no_license | RoyMattar/smart-home | a5690d1de4c22a94f55960d9fe8d19f199bac17d | 5a27facdd225df252a6f3d9e1d1edbcc10514dd4 | refs/heads/master | 2022-07-03T10:55:42.119093 | 2020-05-18T08:58:11 | 2020-05-18T08:58:11 | 264,874,482 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 849 | hxx | namespace advcpp
{
template <typename T>
AtomicValue<T>::AtomicValue (T a_val) NOEXCEPTIONS
: m_val(a_val)
{ }
template <typename T>
void AtomicValue<T>::operator+= (T a_val) NOEXCEPTIONS
{
__sync_add_and_fetch(&m_val, a_val);
}
template <typename T>
void AtomicValue<T>::operator-= (T a_val) NOEXCEPTIONS
{
__sync_sub_and_fetch(&m_val, a_val);
}
template <typename T>
T AtomicValue<T>::operator++ () NOEXCEPTIONS
{
return __sync_add_and_fetch(&m_val, 1);
}
template <typename T>
T AtomicValue<T>::operator-- () NOEXCEPTIONS
{
return __sync_sub_and_fetch(&m_val, 1);
}
template <typename T>
T AtomicValue<T>::Value () NOEXCEPTIONS
{
return __sync_add_and_fetch(&m_val, 0);
}
template <typename T>
void AtomicValue<T>::Value (T a_val) NOEXCEPTIONS
{
__sync_val_compare_and_swap(&m_val, m_val, a_val);
}
} // advcpp | [
"[email protected]"
] | |
abc0ce9841705ddddeab6452ad40491aabb897a4 | 28a3e26ce3c4a4e63d1af7df899ed61b3b03ea61 | /RationalAgents/Utility.cpp | b3b81f9ce6f787bf6cbc6b4d8da4debc4166e308 | [] | no_license | outofband1/Finplex | 41b78cb8df421b0400f9c66df91730a8c85da400 | e7f8fdce276912ffc35e241b3d0fac3c51d33985 | refs/heads/master | 2020-03-22T06:22:24.143867 | 2019-12-20T11:24:43 | 2019-12-20T11:24:43 | 139,628,996 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 879 | cpp | #include "utility.h"
#include <math.h>
Utility::Utility(const std::string& name, const std::string& description)
{
name_ = name;
description_ = description;
}
void Utility::setCurve(const double& max, const double& saturationAmount, const double& saturationDegree)
{
// solve max(1-e^saturationAmount*x)=saturationDegree*max)
max_ = max;
coefficient_ = log(-saturationDegree + 1);
coefficient_ /= saturationAmount;
}
double Utility::getUtility(const double& amount) const
{
double u = max_ * (1.0 - exp(coefficient_ * amount));
return u;
}
double Utility::getMarginalUtility(const double& amount) const
{
double mu = max_ * -coefficient_ * exp(coefficient_ * amount);
return mu;
}
double Utility::getAmountFromMU(const double& targetMU) const
{
double res = log(-targetMU / (max_ * coefficient_)) / coefficient_;
return res;
} | [
"[email protected]"
] | |
13adafdb0e08deb100b8f79ac11abd1d0a0b341f | 7f365a0dfad5267dd45844e678a09e7c3f8881bd | /Wagl/Texture.h | f409913520d93c132929b5289b5b8a291a76ed3a | [] | no_license | GMWolf/GameDev-project | 8f9036b7c8f3b78db66eaac10ad434e85f1cddaf | c3a8246b4d8e22612f8fe5f9558a0f4ece6ec11c | refs/heads/master | 2021-05-01T13:02:21.556804 | 2018-05-13T23:02:22 | 2018-05-13T23:02:22 | 121,067,073 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 358 | h | #pragma once
#include <glad/glad.h>
#include <GLFW/glfw3.h>
namespace wagl {
class Texture
{
public:
Texture();
Texture(int width, int height, GLenum formatInternal, GLenum format, GLenum type);
Texture(GLint glTex);
~Texture();
void bind();
void bind(GLint textureUnit);
bool isBound();
GLuint glTex;
static Texture* bound;
};
} | [
"[email protected]"
] | |
e54427847aaf11dcd8bec3fdd19a06ea5433c780 | b61bb615dad283a74714538baca0956689f96b5e | /OOP/L2/L2.h | 04c976387e1c663a0b124bc906146c74ee55f169 | [] | no_license | edwarddsongg/ICS4U | 27e8456e93f8a731c2364e8598358c72cdd6d123 | c4018023d91a88afef5557ac90a3c64d5f50a048 | refs/heads/master | 2023-06-03T18:30:53.146639 | 2021-06-19T15:38:53 | 2021-06-19T15:38:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 931 | h | #ifndef L2_H
#define L2_H
#include <string>
using namespace std;
class Fraction {
public:
Fraction();
Fraction(int num, int den);
Fraction(const Fraction& f);
int getNumerator();
int getDenominator();
void setNumerator(int n);
void setDenominator(int d);
string toString();
void add(const Fraction& f);
void subtract(const Fraction& f);
void multiply(const Fraction& f);
void divide(const Fraction& f);
static Fraction add(const Fraction& f, const Fraction& g);
static Fraction subtract(const Fraction& f, const Fraction& g);
static Fraction multiply(const Fraction& f, const Fraction& g);
static Fraction divide(const Fraction& f, const Fraction& g);
private:
int numerator, denominator;
static int count;
static int numOfFractions();
};
#endif
| [
"[email protected]"
] | |
1dd9396e883731dc6590eded776a35e8f143c24b | da59f8111c8b6f39b40211b2b508c112541a36ec | /omaha/third_party/chrome/files/src/crypto/rsa_private_key.cc | fbb76e65547d9fc83b83f5ac1957b86f125628a1 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"Apache-2.0"
] | permissive | Gunanekza/omaha | bae26dc259f277a21dbfaf49b3795c442941265c | e73cb9edffaba24bb3b7515f5b48376f922b697e | refs/heads/master | 2022-11-04T22:23:17.642890 | 2020-06-13T21:40:19 | 2020-06-13T21:40:19 | 272,082,687 | 0 | 0 | Apache-2.0 | 2020-06-13T21:40:20 | 2020-06-13T20:42:07 | null | UTF-8 | C++ | false | false | 6,887 | cc | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "crypto/rsa_private_key.h"
#include <list>
#include <memory>
#include "omaha/base/debug.h"
namespace crypto {
// static
RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) {
std::unique_ptr<RSAPrivateKey> result(new RSAPrivateKey());
if (!result->InitProvider())
return nullptr;
DWORD flags = CRYPT_EXPORTABLE;
// The size is encoded as the upper 16 bits of the flags. :: sigh ::.
flags |= (num_bits << 16);
if (!CryptGenKey(result->provider_, CALG_RSA_SIGN, flags,
result->key_.receive()))
return nullptr;
return result.release();
}
// static
RSAPrivateKey* RSAPrivateKey::CreateSensitive(uint16 num_bits) {
UNREFERENCED_PARAMETER(num_bits);
ASSERT1(false);
return nullptr;
}
// static
RSAPrivateKey* RSAPrivateKey::CreateFromPrivateKeyInfo(
const std::vector<uint8>& input) {
std::unique_ptr<RSAPrivateKey> result(new RSAPrivateKey());
if (!result->InitProvider())
return nullptr;
PrivateKeyInfoCodec pki(false); // Little-Endian
pki.Import(input);
size_t blob_size = sizeof(PUBLICKEYSTRUC) +
sizeof(RSAPUBKEY) +
pki.modulus()->size() +
pki.prime1()->size() +
pki.prime2()->size() +
pki.exponent1()->size() +
pki.exponent2()->size() +
pki.coefficient()->size() +
pki.private_exponent()->size();
std::unique_ptr<BYTE[]> blob(new BYTE[blob_size]);
uint8* dest = blob.get();
PUBLICKEYSTRUC* public_key_struc = reinterpret_cast<PUBLICKEYSTRUC*>(dest);
public_key_struc->bType = PRIVATEKEYBLOB;
public_key_struc->bVersion = 0x02;
public_key_struc->reserved = 0;
public_key_struc->aiKeyAlg = CALG_RSA_SIGN;
dest += sizeof(PUBLICKEYSTRUC);
RSAPUBKEY* rsa_pub_key = reinterpret_cast<RSAPUBKEY*>(dest);
rsa_pub_key->magic = 0x32415352;
rsa_pub_key->bitlen = static_cast<DWORD>(pki.modulus()->size() * 8);
int public_exponent_int = 0;
for (size_t i = pki.public_exponent()->size(); i > 0; --i) {
public_exponent_int <<= 8;
public_exponent_int |= (*pki.public_exponent())[i - 1];
}
rsa_pub_key->pubexp = public_exponent_int;
dest += sizeof(RSAPUBKEY);
memcpy(dest, &pki.modulus()->front(), pki.modulus()->size());
dest += pki.modulus()->size();
memcpy(dest, &pki.prime1()->front(), pki.prime1()->size());
dest += pki.prime1()->size();
memcpy(dest, &pki.prime2()->front(), pki.prime2()->size());
dest += pki.prime2()->size();
memcpy(dest, &pki.exponent1()->front(), pki.exponent1()->size());
dest += pki.exponent1()->size();
memcpy(dest, &pki.exponent2()->front(), pki.exponent2()->size());
dest += pki.exponent2()->size();
memcpy(dest, &pki.coefficient()->front(), pki.coefficient()->size());
dest += pki.coefficient()->size();
memcpy(dest, &pki.private_exponent()->front(),
pki.private_exponent()->size());
dest += pki.private_exponent()->size();
ASSERT1(dest == blob.get() + blob_size);
if (!CryptImportKey(result->provider_,
reinterpret_cast<uint8*>(public_key_struc),
static_cast<DWORD>(blob_size), 0,
CRYPT_EXPORTABLE, result->key_.receive()))
return nullptr;
return result.release();
}
// static
RSAPrivateKey* RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo(
const std::vector<uint8>& input) {
UNREFERENCED_PARAMETER(input);
ASSERT1(false);
return nullptr;
}
// static
RSAPrivateKey* RSAPrivateKey::FindFromPublicKeyInfo(
const std::vector<uint8>& input) {
UNREFERENCED_PARAMETER(input);
ASSERT1(false);
return nullptr;
}
RSAPrivateKey::RSAPrivateKey() : provider_(NULL), key_(NULL) {}
RSAPrivateKey::~RSAPrivateKey() {}
bool RSAPrivateKey::InitProvider() {
return FALSE != CryptAcquireContext(provider_.receive(), NULL, NULL,
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
}
bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) {
// Export the key
DWORD blob_length = 0;
if (!CryptExportKey(key_, 0, PRIVATEKEYBLOB, 0, NULL, &blob_length)) {
ASSERT1(false);
return false;
}
std::unique_ptr<uint8[]> blob(new uint8[blob_length]);
if (!CryptExportKey(key_, 0, PRIVATEKEYBLOB, 0, blob.get(), &blob_length)) {
ASSERT1(false);
return false;
}
uint8* pos = blob.get();
PUBLICKEYSTRUC *publickey_struct = reinterpret_cast<PUBLICKEYSTRUC*>(pos);
pos += sizeof(PUBLICKEYSTRUC);
RSAPUBKEY *rsa_pub_key = reinterpret_cast<RSAPUBKEY*>(pos);
pos += sizeof(RSAPUBKEY);
int mod_size = rsa_pub_key->bitlen / 8;
int primes_size = rsa_pub_key->bitlen / 16;
PrivateKeyInfoCodec pki(false); // Little-Endian
pki.modulus()->assign(pos, pos + mod_size);
pos += mod_size;
pki.prime1()->assign(pos, pos + primes_size);
pos += primes_size;
pki.prime2()->assign(pos, pos + primes_size);
pos += primes_size;
pki.exponent1()->assign(pos, pos + primes_size);
pos += primes_size;
pki.exponent2()->assign(pos, pos + primes_size);
pos += primes_size;
pki.coefficient()->assign(pos, pos + primes_size);
pos += primes_size;
pki.private_exponent()->assign(pos, pos + mod_size);
pos += mod_size;
pki.public_exponent()->assign(reinterpret_cast<uint8*>(&rsa_pub_key->pubexp),
reinterpret_cast<uint8*>(&rsa_pub_key->pubexp) + 4);
ASSERT1(pos - blob_length == reinterpret_cast<BYTE*>(publickey_struct));
return pki.Export(output);
}
bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) {
DWORD key_info_len;
if (!CryptExportPublicKeyInfo(
provider_, AT_SIGNATURE, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
NULL, &key_info_len)) {
ASSERT1(false);
return false;
}
std::unique_ptr<uint8[]> key_info(new uint8[key_info_len]);
if (!CryptExportPublicKeyInfo(
provider_, AT_SIGNATURE, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
reinterpret_cast<CERT_PUBLIC_KEY_INFO*>(key_info.get()), &key_info_len)) {
ASSERT1(false);
return false;
}
DWORD encoded_length;
if (!CryptEncodeObject(
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, X509_PUBLIC_KEY_INFO,
reinterpret_cast<CERT_PUBLIC_KEY_INFO*>(key_info.get()), NULL,
&encoded_length)) {
ASSERT1(false);
return false;
}
std::unique_ptr<BYTE[]> encoded(new BYTE[encoded_length]);
if (!CryptEncodeObject(
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, X509_PUBLIC_KEY_INFO,
reinterpret_cast<CERT_PUBLIC_KEY_INFO*>(key_info.get()), encoded.get(),
&encoded_length)) {
ASSERT1(false);
return false;
}
for (size_t i = 0; i < encoded_length; ++i)
output->push_back(encoded[i]);
return true;
}
} // namespace crypto
| [
"[email protected]"
] | |
e0bacc43c8621b33261fc2c5131c6ec014b80721 | af94fdcc207213c08c6fec9067726a284833530c | /src/gamersonlinecoinrpc.cpp | a45b8c711390461d8dc0b5b772319d976e42f24f | [
"MIT"
] | permissive | gamersonlinecoin/GamersOnlineCoin | 5776fd83ac68108df419b9c63c9d572ddf8b4c96 | 50d65d47f5a607e1ff6ccef7ba0662498c7e5d80 | refs/heads/master | 2021-04-12T09:46:32.434400 | 2018-03-24T11:19:51 | 2018-03-24T11:19:51 | 126,592,066 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 48,335 | cpp | // Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "init.h"
#include "util.h"
#include "sync.h"
#include "ui_interface.h"
#include "base58.h"
#include "gamersonlinecoinrpc.h"
#include "db.h"
#undef printf
#include <boost/asio.hpp>
#include <boost/asio/ip/v6_only.hpp>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/shared_ptr.hpp>
#include <list>
#define printf OutputDebugStringF
using namespace std;
using namespace boost;
using namespace boost::asio;
using namespace json_spirit;
void ThreadRPCServer2(void* parg);
static std::string strRPCUserColonPass;
const Object emptyobj;
void ThreadRPCServer3(void* parg);
static inline unsigned short GetDefaultRPCPort()
{
return GetBoolArg("-testnet", false) ? 32681 : 32680;
}
Object JSONRPCError(int code, const string& message)
{
Object error;
error.push_back(Pair("code", code));
error.push_back(Pair("message", message));
return error;
}
void RPCTypeCheck(const Array& params,
const list<Value_type>& typesExpected,
bool fAllowNull)
{
unsigned int i = 0;
BOOST_FOREACH(Value_type t, typesExpected)
{
if (params.size() <= i)
break;
const Value& v = params[i];
if (!((v.type() == t) || (fAllowNull && (v.type() == null_type))))
{
string err = strprintf("Expected type %s, got %s",
Value_type_name[t], Value_type_name[v.type()]);
throw JSONRPCError(RPC_TYPE_ERROR, err);
}
i++;
}
}
void RPCTypeCheck(const Object& o,
const map<string, Value_type>& typesExpected,
bool fAllowNull)
{
BOOST_FOREACH(const PAIRTYPE(string, Value_type)& t, typesExpected)
{
const Value& v = find_value(o, t.first);
if (!fAllowNull && v.type() == null_type)
throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first.c_str()));
if (!((v.type() == t.second) || (fAllowNull && (v.type() == null_type))))
{
string err = strprintf("Expected type %s for %s, got %s",
Value_type_name[t.second], t.first.c_str(), Value_type_name[v.type()]);
throw JSONRPCError(RPC_TYPE_ERROR, err);
}
}
}
int64_t AmountFromValue(const Value& value)
{
double dAmount = value.get_real();
if (dAmount <= 0.0 || dAmount > MAX_MONEY)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
int64_t nAmount = roundint64(dAmount * COIN);
if (!MoneyRange(nAmount))
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
return nAmount;
}
Value ValueFromAmount(int64_t amount)
{
return (double)amount / (double)COIN;
}
std::string HexBits(unsigned int nBits)
{
union {
int32_t nBits;
char cBits[4];
} uBits;
uBits.nBits = htonl((int32_t)nBits);
return HexStr(BEGIN(uBits.cBits), END(uBits.cBits));
}
//
// Utilities: convert hex-encoded Values
// (throws error if not hex).
//
uint256 ParseHashV(const Value& v, string strName)
{
string strHex;
if (v.type() == str_type)
strHex = v.get_str();
if (!IsHex(strHex)) // Note: IsHex("") is false
throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
uint256 result;
result.SetHex(strHex);
return result;
}
uint256 ParseHashO(const Object& o, string strKey)
{
return ParseHashV(find_value(o, strKey), strKey);
}
vector<unsigned char> ParseHexV(const Value& v, string strName)
{
string strHex;
if (v.type() == str_type)
strHex = v.get_str();
if (!IsHex(strHex))
throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
return ParseHex(strHex);
}
vector<unsigned char> ParseHexO(const Object& o, string strKey)
{
return ParseHexV(find_value(o, strKey), strKey);
}
///
/// Note: This interface may still be subject to change.
///
string CRPCTable::help(string strCommand) const
{
string strRet;
set<rpcfn_type> setDone;
for (map<string, const CRPCCommand*>::const_iterator mi = mapCommands.begin(); mi != mapCommands.end(); ++mi)
{
const CRPCCommand *pcmd = mi->second;
string strMethod = mi->first;
// We already filter duplicates, but these deprecated screw up the sort order
if (strMethod.find("label") != string::npos)
continue;
if (strCommand != "" && strMethod != strCommand)
continue;
try
{
Array params;
rpcfn_type pfn = pcmd->actor;
if (setDone.insert(pfn).second)
(*pfn)(params, true);
}
catch (std::exception& e)
{
// Help text is returned in an exception
string strHelp = string(e.what());
if (strCommand == "")
if (strHelp.find('\n') != string::npos)
strHelp = strHelp.substr(0, strHelp.find('\n'));
strRet += strHelp + "\n";
}
}
if (strRet == "")
strRet = strprintf("help: unknown command: %s\n", strCommand.c_str());
strRet = strRet.substr(0,strRet.size()-1);
return strRet;
}
Value help(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"help [command]\n"
"List commands, or get help for a command.");
string strCommand;
if (params.size() > 0)
strCommand = params[0].get_str();
return tableRPC.help(strCommand);
}
Value stop(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"stop <detach>\n"
"<detach> is true or false to detach the database or not for this stop only\n"
"Stop gamersonlinecoin server (and possibly override the detachdb config value).");
// Shutdown will take long enough that the response should get back
if (params.size() > 0)
bitdb.SetDetach(params[0].get_bool());
StartShutdown();
return "gamersonlinecoin server stopping";
}
//
// Call Table
//
static const CRPCCommand vRPCCommands[] =
{ // name function safemd unlocked
// ------------------------ ----------------------- ------ --------
{ "help", &help, true, true },
{ "stop", &stop, true, true },
{ "getbestblockhash", &getbestblockhash, true, false },
{ "getblockcount", &getblockcount, true, false },
{ "getconnectioncount", &getconnectioncount, true, false },
{ "getpeerinfo", &getpeerinfo, true, false },
{ "getdifficulty", &getdifficulty, true, false },
{ "getinfo", &getinfo, true, false },
{ "getsubsidy", &getsubsidy, true, false },
{ "getmininginfo", &getmininginfo, true, false },
{ "getstakinginfo", &getstakinginfo, true, false },
{ "getnewaddress", &getnewaddress, true, false },
{ "getnewpubkey", &getnewpubkey, true, false },
{ "getaccountaddress", &getaccountaddress, true, false },
{ "setaccount", &setaccount, true, false },
{ "getaccount", &getaccount, false, false },
{ "getaddressesbyaccount", &getaddressesbyaccount, true, false },
{ "sendtoaddress", &sendtoaddress, false, false },
{ "getreceivedbyaddress", &getreceivedbyaddress, false, false },
{ "getreceivedbyaccount", &getreceivedbyaccount, false, false },
{ "listreceivedbyaddress", &listreceivedbyaddress, false, false },
{ "listreceivedbyaccount", &listreceivedbyaccount, false, false },
{ "backupwallet", &backupwallet, true, false },
{ "keypoolrefill", &keypoolrefill, true, false },
{ "walletpassphrase", &walletpassphrase, true, false },
{ "walletpassphrasechange", &walletpassphrasechange, false, false },
{ "walletlock", &walletlock, true, false },
{ "encryptwallet", &encryptwallet, false, false },
{ "validateaddress", &validateaddress, true, false },
{ "validatepubkey", &validatepubkey, true, false },
{ "getbalance", &getbalance, false, false },
{ "move", &movecmd, false, false },
{ "sendfrom", &sendfrom, false, false },
{ "sendmany", &sendmany, false, false },
{ "addmultisigaddress", &addmultisigaddress, false, false },
{ "addredeemscript", &addredeemscript, false, false },
{ "getrawmempool", &getrawmempool, true, false },
{ "getblock", &getblock, false, false },
{ "getblockbynumber", &getblockbynumber, false, false },
{ "getblockhash", &getblockhash, false, false },
{ "gettransaction", &gettransaction, false, false },
{ "listtransactions", &listtransactions, false, false },
{ "listaddressgroupings", &listaddressgroupings, false, false },
{ "signmessage", &signmessage, false, false },
{ "verifymessage", &verifymessage, false, false },
{ "getwork", &getwork, true, false },
{ "getworkex", &getworkex, true, false },
{ "listaccounts", &listaccounts, false, false },
{ "settxfee", &settxfee, false, false },
{ "getblocktemplate", &getblocktemplate, true, false },
{ "submitblock", &submitblock, false, false },
{ "listsinceblock", &listsinceblock, false, false },
{ "dumpprivkey", &dumpprivkey, false, false },
{ "dumpwallet", &dumpwallet, true, false },
{ "importwallet", &importwallet, false, false },
{ "importprivkey", &importprivkey, false, false },
{ "listunspent", &listunspent, false, false },
{ "getrawtransaction", &getrawtransaction, false, false },
{ "createrawtransaction", &createrawtransaction, false, false },
{ "decoderawtransaction", &decoderawtransaction, false, false },
{ "decodescript", &decodescript, false, false },
{ "signrawtransaction", &signrawtransaction, false, false },
{ "sendrawtransaction", &sendrawtransaction, false, false },
{ "getcheckpoint", &getcheckpoint, true, false },
{ "reservebalance", &reservebalance, false, true},
{ "checkwallet", &checkwallet, false, true},
{ "repairwallet", &repairwallet, false, true},
{ "resendtx", &resendtx, false, true},
{ "makekeypair", &makekeypair, false, true},
{ "sendalert", &sendalert, false, false},
};
CRPCTable::CRPCTable()
{
unsigned int vcidx;
for (vcidx = 0; vcidx < (sizeof(vRPCCommands) / sizeof(vRPCCommands[0])); vcidx++)
{
const CRPCCommand *pcmd;
pcmd = &vRPCCommands[vcidx];
mapCommands[pcmd->name] = pcmd;
}
}
const CRPCCommand *CRPCTable::operator[](string name) const
{
map<string, const CRPCCommand*>::const_iterator it = mapCommands.find(name);
if (it == mapCommands.end())
return NULL;
return (*it).second;
}
//
// HTTP protocol
//
// This ain't Apache. We're just using HTTP header for the length field
// and to be compatible with other JSON-RPC implementations.
//
string HTTPPost(const string& strMsg, const map<string,string>& mapRequestHeaders)
{
ostringstream s;
s << "POST / HTTP/1.1\r\n"
<< "User-Agent: gamersonlinecoin-json-rpc/" << FormatFullVersion() << "\r\n"
<< "Host: 127.0.0.1\r\n"
<< "Content-Type: application/json\r\n"
<< "Content-Length: " << strMsg.size() << "\r\n"
<< "Connection: close\r\n"
<< "Accept: application/json\r\n";
BOOST_FOREACH(const PAIRTYPE(string, string)& item, mapRequestHeaders)
s << item.first << ": " << item.second << "\r\n";
s << "\r\n" << strMsg;
return s.str();
}
string rfc1123Time()
{
char buffer[64];
time_t now;
time(&now);
struct tm* now_gmt = gmtime(&now);
string locale(setlocale(LC_TIME, NULL));
setlocale(LC_TIME, "C"); // we want POSIX (aka "C") weekday/month strings
strftime(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S +0000", now_gmt);
setlocale(LC_TIME, locale.c_str());
return string(buffer);
}
static string HTTPReply(int nStatus, const string& strMsg, bool keepalive)
{
if (nStatus == HTTP_UNAUTHORIZED)
return strprintf("HTTP/1.0 401 Authorization Required\r\n"
"Date: %s\r\n"
"Server: gamersonlinecoin-json-rpc/%s\r\n"
"WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n"
"Content-Type: text/html\r\n"
"Content-Length: 296\r\n"
"\r\n"
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\r\n"
"\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\r\n"
"<HTML>\r\n"
"<HEAD>\r\n"
"<TITLE>Error</TITLE>\r\n"
"<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>\r\n"
"</HEAD>\r\n"
"<BODY><H1>401 Unauthorized.</H1></BODY>\r\n"
"</HTML>\r\n", rfc1123Time().c_str(), FormatFullVersion().c_str());
const char *cStatus;
if (nStatus == HTTP_OK) cStatus = "OK";
else if (nStatus == HTTP_BAD_REQUEST) cStatus = "Bad Request";
else if (nStatus == HTTP_FORBIDDEN) cStatus = "Forbidden";
else if (nStatus == HTTP_NOT_FOUND) cStatus = "Not Found";
else if (nStatus == HTTP_INTERNAL_SERVER_ERROR) cStatus = "Internal Server Error";
else cStatus = "";
return strprintf(
"HTTP/1.1 %d %s\r\n"
"Date: %s\r\n"
"Connection: %s\r\n"
"Content-Length: %"PRIszu"\r\n"
"Content-Type: application/json\r\n"
"Server: gamersonlinecoin-json-rpc/%s\r\n"
"\r\n"
"%s",
nStatus,
cStatus,
rfc1123Time().c_str(),
keepalive ? "keep-alive" : "close",
strMsg.size(),
FormatFullVersion().c_str(),
strMsg.c_str());
}
int ReadHTTPStatus(std::basic_istream<char>& stream, int &proto)
{
string str;
getline(stream, str);
vector<string> vWords;
boost::split(vWords, str, boost::is_any_of(" "));
if (vWords.size() < 2)
return HTTP_INTERNAL_SERVER_ERROR;
proto = 0;
const char *ver = strstr(str.c_str(), "HTTP/1.");
if (ver != NULL)
proto = atoi(ver+7);
return atoi(vWords[1].c_str());
}
int ReadHTTPHeader(std::basic_istream<char>& stream, map<string, string>& mapHeadersRet)
{
int nLen = 0;
while (true)
{
string str;
std::getline(stream, str);
if (str.empty() || str == "\r")
break;
string::size_type nColon = str.find(":");
if (nColon != string::npos)
{
string strHeader = str.substr(0, nColon);
boost::trim(strHeader);
boost::to_lower(strHeader);
string strValue = str.substr(nColon+1);
boost::trim(strValue);
mapHeadersRet[strHeader] = strValue;
if (strHeader == "content-length")
nLen = atoi(strValue.c_str());
}
}
return nLen;
}
int ReadHTTP(std::basic_istream<char>& stream, map<string, string>& mapHeadersRet, string& strMessageRet)
{
mapHeadersRet.clear();
strMessageRet = "";
// Read status
int nProto = 0;
int nStatus = ReadHTTPStatus(stream, nProto);
// Read header
int nLen = ReadHTTPHeader(stream, mapHeadersRet);
if (nLen < 0 || nLen > (int)MAX_SIZE)
return HTTP_INTERNAL_SERVER_ERROR;
// Read message
if (nLen > 0)
{
vector<char> vch(nLen);
stream.read(&vch[0], nLen);
strMessageRet = string(vch.begin(), vch.end());
}
string sConHdr = mapHeadersRet["connection"];
if ((sConHdr != "close") && (sConHdr != "keep-alive"))
{
if (nProto >= 1)
mapHeadersRet["connection"] = "keep-alive";
else
mapHeadersRet["connection"] = "close";
}
return nStatus;
}
bool HTTPAuthorized(map<string, string>& mapHeaders)
{
string strAuth = mapHeaders["authorization"];
if (strAuth.substr(0,6) != "Basic ")
return false;
string strUserPass64 = strAuth.substr(6); boost::trim(strUserPass64);
string strUserPass = DecodeBase64(strUserPass64);
return TimingResistantEqual(strUserPass, strRPCUserColonPass);
}
//
// JSON-RPC protocol. gamersonlinecoin speaks version 1.0 for maximum compatibility,
// but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were
// unspecified (HTTP errors and contents of 'error').
//
// 1.0 spec: http://json-rpc.org/wiki/specification
// 1.2 spec: http://groups.google.com/group/json-rpc/web/json-rpc-over-http
// http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx
//
string JSONRPCRequest(const string& strMethod, const Array& params, const Value& id)
{
Object request;
request.push_back(Pair("method", strMethod));
request.push_back(Pair("params", params));
request.push_back(Pair("id", id));
return write_string(Value(request), false) + "\n";
}
Object JSONRPCReplyObj(const Value& result, const Value& error, const Value& id)
{
Object reply;
if (error.type() != null_type)
reply.push_back(Pair("result", Value::null));
else
reply.push_back(Pair("result", result));
reply.push_back(Pair("error", error));
reply.push_back(Pair("id", id));
return reply;
}
string JSONRPCReply(const Value& result, const Value& error, const Value& id)
{
Object reply = JSONRPCReplyObj(result, error, id);
return write_string(Value(reply), false) + "\n";
}
void ErrorReply(std::ostream& stream, const Object& objError, const Value& id)
{
// Send error reply from json-rpc error object
int nStatus = HTTP_INTERNAL_SERVER_ERROR;
int code = find_value(objError, "code").get_int();
if (code == RPC_INVALID_REQUEST) nStatus = HTTP_BAD_REQUEST;
else if (code == RPC_METHOD_NOT_FOUND) nStatus = HTTP_NOT_FOUND;
string strReply = JSONRPCReply(Value::null, objError, id);
stream << HTTPReply(nStatus, strReply, false) << std::flush;
}
bool ClientAllowed(const boost::asio::ip::address& address)
{
// Make sure that IPv4-compatible and IPv4-mapped IPv6 addresses are treated as IPv4 addresses
if (address.is_v6()
&& (address.to_v6().is_v4_compatible()
|| address.to_v6().is_v4_mapped()))
return ClientAllowed(address.to_v6().to_v4());
if (address == asio::ip::address_v4::loopback()
|| address == asio::ip::address_v6::loopback()
|| (address.is_v4()
// Check whether IPv4 addresses match 127.0.0.0/8 (loopback subnet)
&& (address.to_v4().to_ulong() & 0xff000000) == 0x7f000000))
return true;
const string strAddress = address.to_string();
const vector<string>& vAllow = mapMultiArgs["-rpcallowip"];
BOOST_FOREACH(string strAllow, vAllow)
if (WildcardMatch(strAddress, strAllow))
return true;
return false;
}
//
// IOStream device that speaks SSL but can also speak non-SSL
//
template <typename Protocol>
class SSLIOStreamDevice : public iostreams::device<iostreams::bidirectional> {
public:
SSLIOStreamDevice(asio::ssl::stream<typename Protocol::socket> &streamIn, bool fUseSSLIn) : stream(streamIn)
{
fUseSSL = fUseSSLIn;
fNeedHandshake = fUseSSLIn;
}
void handshake(ssl::stream_base::handshake_type role)
{
if (!fNeedHandshake) return;
fNeedHandshake = false;
stream.handshake(role);
}
std::streamsize read(char* s, std::streamsize n)
{
handshake(ssl::stream_base::server); // HTTPS servers read first
if (fUseSSL) return stream.read_some(asio::buffer(s, n));
return stream.next_layer().read_some(asio::buffer(s, n));
}
std::streamsize write(const char* s, std::streamsize n)
{
handshake(ssl::stream_base::client); // HTTPS clients write first
if (fUseSSL) return asio::write(stream, asio::buffer(s, n));
return asio::write(stream.next_layer(), asio::buffer(s, n));
}
bool connect(const std::string& server, const std::string& port)
{
ip::tcp::resolver resolver(stream.get_io_service());
ip::tcp::resolver::query query(server.c_str(), port.c_str());
ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
ip::tcp::resolver::iterator end;
boost::system::error_code error = asio::error::host_not_found;
while (error && endpoint_iterator != end)
{
stream.lowest_layer().close();
stream.lowest_layer().connect(*endpoint_iterator++, error);
}
if (error)
return false;
return true;
}
private:
bool fNeedHandshake;
bool fUseSSL;
asio::ssl::stream<typename Protocol::socket>& stream;
};
class AcceptedConnection
{
public:
virtual ~AcceptedConnection() {}
virtual std::iostream& stream() = 0;
virtual std::string peer_address_to_string() const = 0;
virtual void close() = 0;
};
template <typename Protocol>
class AcceptedConnectionImpl : public AcceptedConnection
{
public:
AcceptedConnectionImpl(
asio::io_service& io_service,
ssl::context &context,
bool fUseSSL) :
sslStream(io_service, context),
_d(sslStream, fUseSSL),
_stream(_d)
{
}
virtual std::iostream& stream()
{
return _stream;
}
virtual std::string peer_address_to_string() const
{
return peer.address().to_string();
}
virtual void close()
{
_stream.close();
}
typename Protocol::endpoint peer;
asio::ssl::stream<typename Protocol::socket> sslStream;
private:
SSLIOStreamDevice<Protocol> _d;
iostreams::stream< SSLIOStreamDevice<Protocol> > _stream;
};
void ThreadRPCServer(void* parg)
{
// Make this thread recognisable as the RPC listener
RenameThread("gamersonlinecoin-rpclist");
try
{
vnThreadsRunning[THREAD_RPCLISTENER]++;
ThreadRPCServer2(parg);
vnThreadsRunning[THREAD_RPCLISTENER]--;
}
catch (std::exception& e) {
vnThreadsRunning[THREAD_RPCLISTENER]--;
PrintException(&e, "ThreadRPCServer()");
} catch (...) {
vnThreadsRunning[THREAD_RPCLISTENER]--;
PrintException(NULL, "ThreadRPCServer()");
}
printf("ThreadRPCServer exited\n");
}
// Forward declaration required for RPCListen
template <typename Protocol, typename SocketAcceptorService>
static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor,
ssl::context& context,
bool fUseSSL,
AcceptedConnection* conn,
const boost::system::error_code& error);
/**
* Sets up I/O resources to accept and handle a new connection.
*/
template <typename Protocol, typename SocketAcceptorService>
static void RPCListen(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor,
ssl::context& context,
const bool fUseSSL)
{
// Accept connection
AcceptedConnectionImpl<Protocol>* conn = new AcceptedConnectionImpl<Protocol>(acceptor->get_io_service(), context, fUseSSL);
acceptor->async_accept(
conn->sslStream.lowest_layer(),
conn->peer,
boost::bind(&RPCAcceptHandler<Protocol, SocketAcceptorService>,
acceptor,
boost::ref(context),
fUseSSL,
conn,
boost::asio::placeholders::error));
}
/**
* Accept and handle incoming connection.
*/
template <typename Protocol, typename SocketAcceptorService>
static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor,
ssl::context& context,
const bool fUseSSL,
AcceptedConnection* conn,
const boost::system::error_code& error)
{
vnThreadsRunning[THREAD_RPCLISTENER]++;
// Immediately start accepting new connections, except when we're cancelled or our socket is closed.
if (error != asio::error::operation_aborted
&& acceptor->is_open())
RPCListen(acceptor, context, fUseSSL);
AcceptedConnectionImpl<ip::tcp>* tcp_conn = dynamic_cast< AcceptedConnectionImpl<ip::tcp>* >(conn);
// TODO: Actually handle errors
if (error)
{
delete conn;
}
// Restrict callers by IP. It is important to
// do this before starting client thread, to filter out
// certain DoS and misbehaving clients.
else if (tcp_conn
&& !ClientAllowed(tcp_conn->peer.address()))
{
// Only send a 403 if we're not using SSL to prevent a DoS during the SSL handshake.
if (!fUseSSL)
conn->stream() << HTTPReply(HTTP_FORBIDDEN, "", false) << std::flush;
delete conn;
}
// start HTTP client thread
else if (!NewThread(ThreadRPCServer3, conn)) {
printf("Failed to create RPC server client thread\n");
delete conn;
}
vnThreadsRunning[THREAD_RPCLISTENER]--;
}
void ThreadRPCServer2(void* parg)
{
printf("ThreadRPCServer started\n");
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"];
if ((mapArgs["-rpcpassword"] == "") ||
(mapArgs["-rpcuser"] == mapArgs["-rpcpassword"]))
{
unsigned char rand_pwd[32];
RAND_bytes(rand_pwd, 32);
string strWhatAmI = "To use gamersonlinecoind";
if (mapArgs.count("-server"))
strWhatAmI = strprintf(_("To use the %s option"), "\"-server\"");
else if (mapArgs.count("-daemon"))
strWhatAmI = strprintf(_("To use the %s option"), "\"-daemon\"");
uiInterface.ThreadSafeMessageBox(strprintf(
_("%s, you must set a rpcpassword in the configuration file:\n %s\n"
"It is recommended you use the following random password:\n"
"rpcuser=gamersonlinecoinrpc\n"
"rpcpassword=%s\n"
"(you do not need to remember this password)\n"
"The username and password MUST NOT be the same.\n"
"If the file does not exist, create it with owner-readable-only file permissions.\n"
"It is also recommended to set alertnotify so you are notified of problems;\n"
"for example: alertnotify=echo %%s | mail -s \"gamersonlinecoin Alert\" [email protected]\n"),
strWhatAmI.c_str(),
GetConfigFile().string().c_str(),
EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32).c_str()),
_("Error"), CClientUIInterface::OK | CClientUIInterface::MODAL);
StartShutdown();
return;
}
const bool fUseSSL = GetBoolArg("-rpcssl");
asio::io_service io_service;
ssl::context context(io_service, ssl::context::sslv23);
if (fUseSSL)
{
context.set_options(ssl::context::no_sslv2);
filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert"));
if (!pathCertFile.is_complete()) pathCertFile = filesystem::path(GetDataDir()) / pathCertFile;
if (filesystem::exists(pathCertFile)) context.use_certificate_chain_file(pathCertFile.string());
else printf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string().c_str());
filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem"));
if (!pathPKFile.is_complete()) pathPKFile = filesystem::path(GetDataDir()) / pathPKFile;
if (filesystem::exists(pathPKFile)) context.use_private_key_file(pathPKFile.string(), ssl::context::pem);
else printf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string().c_str());
string strCiphers = GetArg("-rpcsslciphers", "TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH");
SSL_CTX_set_cipher_list(context.impl(), strCiphers.c_str());
}
// Try a dual IPv6/IPv4 socket, falling back to separate IPv4 and IPv6 sockets
const bool loopback = !mapArgs.count("-rpcallowip");
asio::ip::address bindAddress = loopback ? asio::ip::address_v6::loopback() : asio::ip::address_v6::any();
ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", GetDefaultRPCPort()));
boost::system::error_code v6_only_error;
boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(io_service));
boost::signals2::signal<void ()> StopRequests;
bool fListening = false;
std::string strerr;
try
{
acceptor->open(endpoint.protocol());
acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
// Try making the socket dual IPv6/IPv4 (if listening on the "any" address)
acceptor->set_option(boost::asio::ip::v6_only(loopback), v6_only_error);
acceptor->bind(endpoint);
acceptor->listen(socket_base::max_connections);
RPCListen(acceptor, context, fUseSSL);
// Cancel outstanding listen-requests for this acceptor when shutting down
StopRequests.connect(signals2::slot<void ()>(
static_cast<void (ip::tcp::acceptor::*)()>(&ip::tcp::acceptor::close), acceptor.get())
.track(acceptor));
fListening = true;
}
catch(boost::system::system_error &e)
{
strerr = strprintf(_("An error occurred while setting up the RPC port %u for listening on IPv6, falling back to IPv4: %s"), endpoint.port(), e.what());
}
try {
// If dual IPv6/IPv4 failed (or we're opening loopback interfaces only), open IPv4 separately
if (!fListening || loopback || v6_only_error)
{
bindAddress = loopback ? asio::ip::address_v4::loopback() : asio::ip::address_v4::any();
endpoint.address(bindAddress);
acceptor.reset(new ip::tcp::acceptor(io_service));
acceptor->open(endpoint.protocol());
acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
acceptor->bind(endpoint);
acceptor->listen(socket_base::max_connections);
RPCListen(acceptor, context, fUseSSL);
// Cancel outstanding listen-requests for this acceptor when shutting down
StopRequests.connect(signals2::slot<void ()>(
static_cast<void (ip::tcp::acceptor::*)()>(&ip::tcp::acceptor::close), acceptor.get())
.track(acceptor));
fListening = true;
}
}
catch(boost::system::system_error &e)
{
strerr = strprintf(_("An error occurred while setting up the RPC port %u for listening on IPv4: %s"), endpoint.port(), e.what());
}
if (!fListening) {
uiInterface.ThreadSafeMessageBox(strerr, _("Error"), CClientUIInterface::OK | CClientUIInterface::MODAL);
StartShutdown();
return;
}
vnThreadsRunning[THREAD_RPCLISTENER]--;
while (!fShutdown)
io_service.run_one();
vnThreadsRunning[THREAD_RPCLISTENER]++;
StopRequests();
}
class JSONRequest
{
public:
Value id;
string strMethod;
Array params;
JSONRequest() { id = Value::null; }
void parse(const Value& valRequest);
};
void JSONRequest::parse(const Value& valRequest)
{
// Parse request
if (valRequest.type() != obj_type)
throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
const Object& request = valRequest.get_obj();
// Parse id now so errors from here on will have the id
id = find_value(request, "id");
// Parse method
Value valMethod = find_value(request, "method");
if (valMethod.type() == null_type)
throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
if (valMethod.type() != str_type)
throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
strMethod = valMethod.get_str();
if (strMethod != "getwork" && strMethod != "getblocktemplate")
printf("ThreadRPCServer method=%s\n", strMethod.c_str());
// Parse params
Value valParams = find_value(request, "params");
if (valParams.type() == array_type)
params = valParams.get_array();
else if (valParams.type() == null_type)
params = Array();
else
throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array");
}
static Object JSONRPCExecOne(const Value& req)
{
Object rpc_result;
JSONRequest jreq;
try {
jreq.parse(req);
Value result = tableRPC.execute(jreq.strMethod, jreq.params);
rpc_result = JSONRPCReplyObj(result, Value::null, jreq.id);
}
catch (Object& objError)
{
rpc_result = JSONRPCReplyObj(Value::null, objError, jreq.id);
}
catch (std::exception& e)
{
rpc_result = JSONRPCReplyObj(Value::null,
JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
}
return rpc_result;
}
static string JSONRPCExecBatch(const Array& vReq)
{
Array ret;
for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++)
ret.push_back(JSONRPCExecOne(vReq[reqIdx]));
return write_string(Value(ret), false) + "\n";
}
static CCriticalSection cs_THREAD_RPCHANDLER;
void ThreadRPCServer3(void* parg)
{
// Make this thread recognisable as the RPC handler
RenameThread("gamersonlinecoin-rpchand");
{
LOCK(cs_THREAD_RPCHANDLER);
vnThreadsRunning[THREAD_RPCHANDLER]++;
}
AcceptedConnection *conn = (AcceptedConnection *) parg;
bool fRun = true;
while (true)
{
if (fShutdown || !fRun)
{
conn->close();
delete conn;
{
LOCK(cs_THREAD_RPCHANDLER);
--vnThreadsRunning[THREAD_RPCHANDLER];
}
return;
}
map<string, string> mapHeaders;
string strRequest;
ReadHTTP(conn->stream(), mapHeaders, strRequest);
// Check authorization
if (mapHeaders.count("authorization") == 0)
{
conn->stream() << HTTPReply(HTTP_UNAUTHORIZED, "", false) << std::flush;
break;
}
if (!HTTPAuthorized(mapHeaders))
{
printf("ThreadRPCServer incorrect password attempt from %s\n", conn->peer_address_to_string().c_str());
/* Deter brute-forcing short passwords.
If this results in a DOS the user really
shouldn't have their RPC port exposed.*/
if (mapArgs["-rpcpassword"].size() < 20)
MilliSleep(250);
conn->stream() << HTTPReply(HTTP_UNAUTHORIZED, "", false) << std::flush;
break;
}
if (mapHeaders["connection"] == "close")
fRun = false;
JSONRequest jreq;
try
{
// Parse request
Value valRequest;
if (!read_string(strRequest, valRequest))
throw JSONRPCError(RPC_PARSE_ERROR, "Parse error");
string strReply;
// singleton request
if (valRequest.type() == obj_type) {
jreq.parse(valRequest);
Value result = tableRPC.execute(jreq.strMethod, jreq.params);
// Send reply
strReply = JSONRPCReply(result, Value::null, jreq.id);
// array of requests
} else if (valRequest.type() == array_type)
strReply = JSONRPCExecBatch(valRequest.get_array());
else
throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error");
conn->stream() << HTTPReply(HTTP_OK, strReply, fRun) << std::flush;
}
catch (Object& objError)
{
ErrorReply(conn->stream(), objError, jreq.id);
break;
}
catch (std::exception& e)
{
ErrorReply(conn->stream(), JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
break;
}
}
delete conn;
{
LOCK(cs_THREAD_RPCHANDLER);
vnThreadsRunning[THREAD_RPCHANDLER]--;
}
}
json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_spirit::Array ¶ms) const
{
// Find method
const CRPCCommand *pcmd = tableRPC[strMethod];
if (!pcmd)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
// Observe safe mode
string strWarning = GetWarnings("rpc");
if (strWarning != "" && !GetBoolArg("-disablesafemode") &&
!pcmd->okSafeMode)
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning);
try
{
// Execute
Value result;
{
if (pcmd->unlocked)
result = pcmd->actor(params, false);
else {
LOCK2(cs_main, pwalletMain->cs_wallet);
result = pcmd->actor(params, false);
}
}
return result;
}
catch (std::exception& e)
{
throw JSONRPCError(RPC_MISC_ERROR, e.what());
}
}
Object CallRPC(const string& strMethod, const Array& params)
{
if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "")
throw runtime_error(strprintf(
_("You must set rpcpassword=<password> in the configuration file:\n%s\n"
"If the file does not exist, create it with owner-readable-only file permissions."),
GetConfigFile().string().c_str()));
// Connect to localhost
bool fUseSSL = GetBoolArg("-rpcssl");
asio::io_service io_service;
ssl::context context(io_service, ssl::context::sslv23);
context.set_options(ssl::context::no_sslv2);
asio::ssl::stream<asio::ip::tcp::socket> sslStream(io_service, context);
SSLIOStreamDevice<asio::ip::tcp> d(sslStream, fUseSSL);
iostreams::stream< SSLIOStreamDevice<asio::ip::tcp> > stream(d);
if (!d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(GetDefaultRPCPort()))))
throw runtime_error("couldn't connect to server");
// HTTP basic authentication
string strUserPass64 = EncodeBase64(mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]);
map<string, string> mapRequestHeaders;
mapRequestHeaders["Authorization"] = string("Basic ") + strUserPass64;
// Send request
string strRequest = JSONRPCRequest(strMethod, params, 1);
string strPost = HTTPPost(strRequest, mapRequestHeaders);
stream << strPost << std::flush;
// Receive reply
map<string, string> mapHeaders;
string strReply;
int nStatus = ReadHTTP(stream, mapHeaders, strReply);
if (nStatus == HTTP_UNAUTHORIZED)
throw runtime_error("incorrect rpcuser or rpcpassword (authorization failed)");
else if (nStatus >= 400 && nStatus != HTTP_BAD_REQUEST && nStatus != HTTP_NOT_FOUND && nStatus != HTTP_INTERNAL_SERVER_ERROR)
throw runtime_error(strprintf("server returned HTTP error %d", nStatus));
else if (strReply.empty())
throw runtime_error("no response from server");
// Parse reply
Value valReply;
if (!read_string(strReply, valReply))
throw runtime_error("couldn't parse reply from server");
const Object& reply = valReply.get_obj();
if (reply.empty())
throw runtime_error("expected reply to have result, error and id properties");
return reply;
}
template<typename T>
void ConvertTo(Value& value, bool fAllowNull=false)
{
if (fAllowNull && value.type() == null_type)
return;
if (value.type() == str_type)
{
// reinterpret string as unquoted json value
Value value2;
string strJSON = value.get_str();
if (!read_string(strJSON, value2))
throw runtime_error(string("Error parsing JSON:")+strJSON);
ConvertTo<T>(value2, fAllowNull);
value = value2;
}
else
{
value = value.get_value<T>();
}
}
// Convert strings to command-specific RPC representation
Array RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)
{
Array params;
BOOST_FOREACH(const std::string ¶m, strParams)
params.push_back(param);
int n = params.size();
//
// Special case non-string parameter types
//
if (strMethod == "stop" && n > 0) ConvertTo<bool>(params[0]);
if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);
if (strMethod == "settxfee" && n > 0) ConvertTo<double>(params[0]);
if (strMethod == "getreceivedbyaddress" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "getreceivedbyaccount" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "listreceivedbyaddress" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "listreceivedbyaddress" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "listreceivedbyaccount" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "listreceivedbyaccount" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getbalance" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "getblock" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblockbynumber" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "getblockbynumber" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblockhash" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "move" && n > 2) ConvertTo<double>(params[2]);
if (strMethod == "move" && n > 3) ConvertTo<boost::int64_t>(params[3]);
if (strMethod == "sendfrom" && n > 2) ConvertTo<double>(params[2]);
if (strMethod == "sendfrom" && n > 3) ConvertTo<boost::int64_t>(params[3]);
if (strMethod == "listtransactions" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "listtransactions" && n > 2) ConvertTo<boost::int64_t>(params[2]);
if (strMethod == "listaccounts" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "walletpassphrase" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "walletpassphrase" && n > 2) ConvertTo<bool>(params[2]);
if (strMethod == "getblocktemplate" && n > 0) ConvertTo<Object>(params[0]);
if (strMethod == "listsinceblock" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "sendalert" && n > 2) ConvertTo<boost::int64_t>(params[2]);
if (strMethod == "sendalert" && n > 3) ConvertTo<boost::int64_t>(params[3]);
if (strMethod == "sendalert" && n > 4) ConvertTo<boost::int64_t>(params[4]);
if (strMethod == "sendalert" && n > 5) ConvertTo<boost::int64_t>(params[5]);
if (strMethod == "sendalert" && n > 6) ConvertTo<boost::int64_t>(params[6]);
if (strMethod == "sendmany" && n > 1) ConvertTo<Object>(params[1]);
if (strMethod == "sendmany" && n > 2) ConvertTo<boost::int64_t>(params[2]);
if (strMethod == "reservebalance" && n > 0) ConvertTo<bool>(params[0]);
if (strMethod == "reservebalance" && n > 1) ConvertTo<double>(params[1]);
if (strMethod == "addmultisigaddress" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "addmultisigaddress" && n > 1) ConvertTo<Array>(params[1]);
if (strMethod == "listunspent" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "listunspent" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "listunspent" && n > 2) ConvertTo<Array>(params[2]);
if (strMethod == "getrawtransaction" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "createrawtransaction" && n > 0) ConvertTo<Array>(params[0]);
if (strMethod == "createrawtransaction" && n > 1) ConvertTo<Object>(params[1]);
if (strMethod == "signrawtransaction" && n > 1) ConvertTo<Array>(params[1], true);
if (strMethod == "signrawtransaction" && n > 2) ConvertTo<Array>(params[2], true);
if (strMethod == "keypoolrefill" && n > 0) ConvertTo<boost::int64_t>(params[0]);
return params;
}
int CommandLineRPC(int argc, char *argv[])
{
string strPrint;
int nRet = 0;
try
{
// Skip switches
while (argc > 1 && IsSwitchChar(argv[1][0]))
{
argc--;
argv++;
}
// Method
if (argc < 2)
throw runtime_error("too few parameters");
string strMethod = argv[1];
// Parameters default to strings
std::vector<std::string> strParams(&argv[2], &argv[argc]);
Array params = RPCConvertValues(strMethod, strParams);
// Execute
Object reply = CallRPC(strMethod, params);
// Parse reply
const Value& result = find_value(reply, "result");
const Value& error = find_value(reply, "error");
if (error.type() != null_type)
{
// Error
strPrint = "error: " + write_string(error, false);
int code = find_value(error.get_obj(), "code").get_int();
nRet = abs(code);
}
else
{
// Result
if (result.type() == null_type)
strPrint = "";
else if (result.type() == str_type)
strPrint = result.get_str();
else
strPrint = write_string(result, true);
}
}
catch (std::exception& e)
{
strPrint = string("error: ") + e.what();
nRet = 87;
}
catch (...)
{
PrintException(NULL, "CommandLineRPC()");
}
if (strPrint != "")
{
fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str());
}
return nRet;
}
#ifdef TEST
int main(int argc, char *argv[])
{
#ifdef _MSC_VER
// Turn off Microsoft heap dump noise
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, CreateFile("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
#endif
setbuf(stdin, NULL);
setbuf(stdout, NULL);
setbuf(stderr, NULL);
try
{
if (argc >= 2 && string(argv[1]) == "-server")
{
printf("server ready\n");
ThreadRPCServer(NULL);
}
else
{
return CommandLineRPC(argc, argv);
}
}
catch (std::exception& e) {
PrintException(&e, "main()");
} catch (...) {
PrintException(NULL, "main()");
}
return 0;
}
#endif
const CRPCTable tableRPC;
| [
"[email protected]"
] | |
94daa2e3e6a2249292cf3f0e2555f30f8292a3df | b0c112527241f645ca77a724e97d0a46c8eed417 | /GraphQL/Parser/Parser.h | 1a8cfe2b755453d920b9b59e54b2129026998c39 | [
"MIT"
] | permissive | faizol/GraphQL-cpp-1 | fbac3f0bc8fbbee7ceaf202c5ffb370c7aec2076 | 42c35c97f239cc066455a11b37249697dcaed130 | refs/heads/master | 2022-04-08T22:17:36.028125 | 2020-03-16T20:58:12 | 2020-03-16T20:58:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 318 | h | #pragma once
#include <GraphQL/Parser/Lexer.h>
namespace GraphQL {
namespace Parser {
class Parser {
private:
Lexer lexer_;
Token current_token_;
public:
Parser(const Source& source);
void* /*Types::Document*/ parse();
};
}
}
| [
"[email protected]"
] | |
d1654be91da4d3c53327220a0cb4223515f9a30d | d95a3ab5f5ff1056fa32a250617b03b5227a0d5b | /mp4/tests/tests_part1.cpp | 3b5e6a2919aa7b91a66c78d180b2b51796edbf65 | [] | no_license | DarkenedOrigins/CppDataStructures | 0a2475c9a3f31883bb7a1f96ebb556607afa4420 | e18986ec919767b81c6c9fdf793ee93807ea36bb | refs/heads/master | 2022-09-21T05:03:25.746203 | 2020-05-30T03:19:51 | 2020-05-30T03:19:51 | 267,995,004 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,254 | cpp | #include "catch.hpp"
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include "../cs225/PNG.h"
#include "../cs225/HSLAPixel.h"
#include "../imageTraversal/BFS.h"
#include "../imageTraversal/DFS.h"
using namespace cs225;
/**
* Returns a 4x4 image with a white center and black border:
*
* X X X X
* X - - X X: black
* X - - X -: white
* X X X X
*
* The black/X (h=180, s=1, l=0) is as different from
* white/- (h=0, s=0, l=1) as possible.
**/
PNG getTestPNG() {
PNG png(4, 4);
HSLAPixel blackPixel(180, 1, 0);
for (unsigned i = 0; i < 4; i++) {
*(png.getPixel(i, 0)) = blackPixel;
*(png.getPixel(0, i)) = blackPixel;
*(png.getPixel(i, 3)) = blackPixel;
*(png.getPixel(3, i)) = blackPixel;
}
return png;
}
TEST_CASE("DFS iterator starts at the start point", "[weight=1][part=1]") {
PNG png = getTestPNG();
Point startPoint(1, 1);
DFS dfs(png, startPoint, 0.2);
REQUIRE( *(dfs.begin()) == startPoint );
}
TEST_CASE("DFS visits the right pixel first", "[weight=1][part=1]") {
PNG png = getTestPNG();
Point startPoint(1, 1);
DFS dfs(png, startPoint, 0.2);
ImageTraversal::Iterator it = dfs.begin();
++it;
REQUIRE( *it == Point(1, 2) );
}
TEST_CASE("BFS iterator starts at the start point", "[weight=1][part=1]") {
PNG png = getTestPNG();
Point startPoint(1, 1);
BFS bfs(png, startPoint, 0.2);
REQUIRE( *(bfs.begin()) == startPoint );
}
TEST_CASE("BFS visits the right pixel first", "[weight=1][part=1]") {
PNG png = getTestPNG();
Point startPoint(1, 1);
BFS bfs(png, startPoint, 0.2);
ImageTraversal::Iterator it = bfs.begin();
++it;
REQUIRE( *it == Point(2, 1) );
}
TEST_CASE("DFS visits all points within a tolerance", "[weight=1][part=1]") {
PNG png = getTestPNG();
Point startPoint(1, 1);
DFS t(png, startPoint, 0.2);
unsigned count = 0;
for (auto it = t.begin(); it != t.end(); ++it) {
count++;
}
REQUIRE( count == 4 );
}
TEST_CASE("BFS visits all points within a tolerance", "[weight=1][part=1]") {
PNG png = getTestPNG();
Point startPoint(1, 1);
BFS t(png, startPoint, 0.2);
unsigned count = 0;
for (const Point & p : t) {
count++;
}
REQUIRE( count == 4 );
}
TEST_CASE("DFS visits all points within a tolerance (includes pixels on image edge)", "[weight=1][part=1]") {
PNG png = getTestPNG();
Point startPoint(0, 0);
DFS t(png, startPoint, 0.2);
unsigned count = 0;
for (const Point & p : t) { count++; }
REQUIRE( count == 12 );
}
TEST_CASE("BFS visits all points within a tolerance (includes pixels on image edge)", "[weight=1][part=1]") {
PNG png = getTestPNG();
Point startPoint(0, 0);
BFS t(png, startPoint, 0.2);
unsigned count = 0;
for (const Point & p : t) { count++; }
REQUIRE( count == 12 );
}
TEST_CASE("DFS iterator visits all points in the correct order", "[weight=1][part=1]") {
PNG png = getTestPNG();
Point startPoint(0, 0);
DFS t(png, startPoint, 0.2);
ImageTraversal::Iterator it = t.begin();
REQUIRE( *it == Point(0, 0) ); ++it;
REQUIRE( *it == Point(0, 1) ); ++it;
REQUIRE( *it == Point(0, 2) ); ++it;
REQUIRE( *it == Point(0, 3) ); ++it;
REQUIRE( *it == Point(1, 3) ); ++it;
REQUIRE( *it == Point(2, 3) ); ++it;
REQUIRE( *it == Point(3, 3) ); ++it;
REQUIRE( *it == Point(3, 2) ); ++it;
REQUIRE( *it == Point(3, 1) ); ++it;
REQUIRE( *it == Point(3, 0) ); ++it;
REQUIRE( *it == Point(2, 0) ); ++it;
REQUIRE( *it == Point(1, 0) ); ++it;
}
TEST_CASE("BFS iterator visits all points in the correct order", "[weight=1][part=1]") {
PNG png = getTestPNG();
Point startPoint(0, 0);
BFS t(png, startPoint, 0.2);
ImageTraversal::Iterator it = t.begin();
REQUIRE( *it == Point(0, 0) ); ++it;
REQUIRE( *it == Point(1, 0) ); ++it;
REQUIRE( *it == Point(0, 1) ); ++it;
REQUIRE( *it == Point(2, 0) ); ++it;
REQUIRE( *it == Point(0, 2) ); ++it;
REQUIRE( *it == Point(3, 0) ); ++it;
REQUIRE( *it == Point(0, 3) ); ++it;
REQUIRE( *it == Point(3, 1) ); ++it;
REQUIRE( *it == Point(1, 3) ); ++it;
REQUIRE( *it == Point(3, 2) ); ++it;
REQUIRE( *it == Point(2, 3) ); ++it;
REQUIRE( *it == Point(3, 3) ); ++it;
}
| [
"[email protected]"
] | |
42eb92bbb54fbbd87dd64dec02b3b0986ba516cc | 1a20961af3b03b46c109b09812143a7ef95c6caa | /Book/3dlearn/DirectX/3DGraphicsProgrammingCD/glib/GutTGA.h | 8c256873e0d8f28493202cdda7f69a69cbe239dd | [] | no_license | JetAr/ZNginx | eff4ae2457b7b28115787d6af7a3098c121e8368 | 698b40085585d4190cf983f61b803ad23468cdef | refs/heads/master | 2021-07-16T13:29:57.438175 | 2017-10-23T02:05:43 | 2017-10-23T02:05:43 | 26,522,265 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 814 | h |
#define IMG_OK 0x1
#define IMG_ERR_NO_FILE 0x2
#define IMG_ERR_MEM_FAIL 0x4
#define IMG_ERR_BAD_FORMAT 0x8
#define IMG_ERR_UNSUPPORTED 0x40
#include "GutImage.h"
class TGAImg : public GutImage
{
public:
TGAImg();
~TGAImg();
int Load(const char* szFilename);
int GetBPP();
int GetWidth();
int GetHeight();
unsigned char* GetImg(void); // Return a pointer to image data
unsigned char* GetPalette(void); // Return a pointer to VGA palette
void FlipImg();
bool DownSampling(void);
private:
short int iWidth,iHeight,iBPP;
unsigned long lImageSize;
char bEnc;
unsigned char *pImage, *pPalette, *pData;
// Internal workers
int ReadHeader();
int LoadRawData();
int LoadTgaRLEData();
int LoadTgaPalette();
void BGRtoRGB();
unsigned char *GetPixel(int x, int y);
};
| [
"[email protected]"
] | |
22ff245bd843e925225d113c3f40e9a9180d03b4 | 506e96a1186f5524ad9a6f1466e65f4c6857a1c3 | /codeforces/1284/B.cpp | 3b556c1d598fa9d1b73f8ac0ae0677eb7a95d2a5 | [] | no_license | 142ayushkumar/OJ-Submissions | 65c5a9baf13b9a8155178f66a1698dcbcc05d24f | a71e9a8f96cba8859158db7d25b04f28fc9efa34 | refs/heads/master | 2023-02-04T07:28:40.316895 | 2019-12-16T15:25:00 | 2020-12-22T09:10:06 | 323,572,960 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,576 | cpp | #include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//
int32_t main()
{
fastio;
int n;
cin >> n;
vector<pair<int, int>> minmax(n);
vector<int> maxmin(n);
vector<bool> accent(n, false);
int acc_ = 0;
for(int i=0;i<n;i++)
{
int m;
cin >> m;
int mn = -1, mx = -1;
bool has_accent = false;
for(int j=0;j<m;j++)
{
int z;
cin >> z;
if(!j)
{
mn = z;
mx = z;
}
else
{
if(z > mn)
{
has_accent = true;
}
mn = min(mn, z);
mx = max(mx, z);
}
}
if(has_accent)
{
accent[i] = true;
acc_++;
}
minmax[i] = {mn, mx};
maxmin[i] = mx;
if(has_accent) maxmin[i] = -1;
}
sort(all(maxmin));
int ans = 0;
for(int i=0;i<n;i++)
{
if(accent[i]) ans += n;
else
{
int z = upper_bound(all(maxmin), minmax[i].first) - maxmin.begin();
z = n-z;
z += acc_;
ans += z;
}
}
cout << ans << "\n";
return 0;
}
| [
"[email protected]"
] | |
6fada9061ee0cdcd329f886a4545ab77b4452256 | cd0af8a3ea0a1b2b47286039c190f603acaaf580 | /alignment/asmd/asmd/eita/BasicCalculation_v170122.hpp | a0e25c5033cba541c9a42cc2a945c483e7bdb04f | [
"MIT"
] | permissive | LIMUNIMI/MMSP2021-Audio2ScoreAlignment | 1fcedab96ac09cac4a9f046fe5e22fe4da808fcb | f5c23e94e97bb524342a9b0b34f99037121d6e7f | refs/heads/master | 2023-04-15T10:10:10.844856 | 2022-10-14T09:58:30 | 2022-10-14T09:58:30 | 372,559,818 | 24 | 6 | MIT | 2022-10-14T09:58:31 | 2021-05-31T15:55:44 | Jupyter Notebook | UTF-8 | C++ | false | false | 5,638 | hpp | /*
Copyright 2019 Eita Nakamura
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef BasicCalculation_HPP
#define BasicCalculation_HPP
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<cassert>
#include<algorithm>
using namespace std;
inline int gcd(int m, int n){
if(0==m||0==n){return 0;}
while(m!=n){if(m>n){m=m-n;}else{n=n-m;}}//endwhile
return m;
}//end gcd
inline int lcm(int m,int n){
if (0==m||0==n){return 0;}
return ((m/gcd(m,n))*n);//lcm=m*n/gcd(m,n)
}//end lcm
inline double LogAdd(double d1,double d2){
//log(exp(d1)+exp(d2))=log(exp(d1)(1+exp(d2-d1)))
if(d1>d2){
// if(d1-d2>20){return d1;}
return d1+log(1+exp(d2-d1));
}else{
// if(d2-d1>20){return d2;}
return d2+log(1+exp(d1-d2));
}//endif
}//end LogAdd
inline void Norm(vector<double>& vd){
double sum=0;
for(int i=0;i<vd.size();i+=1){
sum+=vd[i];
// if(vd[i]<0){cout<<"negative weight!"<<endl;}
}//endif
for(int i=0;i<vd.size();i+=1){vd[i]/=sum;}
return;
}//end Norm
inline void Lognorm(vector<double>& vd){
double tmpd=vd[0];
for(int i=0;i<vd.size();i+=1){if(vd[i]>tmpd){tmpd=vd[i];}}//endfor i
for(int i=0;i<vd.size();i+=1){vd[i]-=tmpd;}//endfor i
tmpd=0;
for(int i=0;i<vd.size();i+=1){tmpd+=exp(vd[i]);}//endfor i
tmpd=log(tmpd);
for(int i=0;i<vd.size();i+=1){vd[i]-=tmpd;if(vd[i]<-200){vd[i]=-200;}}//endfor i
}//end Lognorm
inline double Average(vector<double>& vd){
assert(vd.size()>0);
double sum=0;
for(int i=0;i<vd.size();i+=1){
sum+=vd[i];
}//endfor i
return sum/double(vd.size());
}//end Average
inline double StDev(vector<double>& vd){
assert(vd.size()>1);
double ave=Average(vd);
double sum=0;
for(int i=0;i<vd.size();i+=1){
sum+=pow(vd[i]-ave,2.);
}//endfor i
return pow(sum/double(vd.size()-1),0.5);
}//end StDev
inline int SampleDistr(vector<double> &p){
double val=(1.0*rand())/(1.0*RAND_MAX);
for(int i=0;i<p.size()-1;i+=1){
if(val<p[i]){return i;
}else{val-=p[i];
}//endif
}//endfor i
return p.size()-1;
}//end SampleDistr
inline double RandDouble(){
return (1.0*rand())/(1.0*RAND_MAX);
}//end
class Pair{
public:
int ID;
double value;
};//endclass Pair
class MorePair{
public:
bool operator()(const Pair& a, const Pair& b){
if(a.value > b.value){
return true;
}else{//if a.value <= b.value
return false;
}//endif
}//end operator()
};//end class MorePair
//sort(pairs.begin(), pairs.end(), MorePair());
//From Prob_v160925.hpp
template <typename T> class Prob{
public:
vector<double> P;
vector<double> LP;
vector<T> samples;
Prob(){
}//end Prob
Prob(Prob<T> const & prob_){
P=prob_.P;
LP=prob_.LP;
samples=prob_.samples;
}//end Prob
~Prob(){
}//end ~Prob
Prob& operator=(const Prob<T> & prob_){
P=prob_.P;
LP=prob_.LP;
samples=prob_.samples;
return *this;
}//end =
void Print(){
for(int i=0;i<P.size();i+=1){
cout<<i<<"\t"<<samples[i]<<"\t"<<P[i]<<"\t"<<LP[i]<<endl;
}//endfor i
}//end Print
void Normalize(){
Norm(P);
PToLP();
}//end Normalize
void LogNormalize(){
Lognorm(LP);
LPToP();
}//end Normalize
void PToLP(){
LP.clear();
LP.resize(P.size());
for(int i=0;i<P.size();i+=1){
LP[i]=log(P[i]);
}//endfor i
}//end PToLP
void LPToP(){
P.clear();
P.resize(LP.size());
for(int i=0;i<LP.size();i+=1){
P[i]=exp(LP[i]);
}//endfor i
}//end LPToP
T Sample(){
return samples[SampleDistr(P)];
}//end Sample
void Resize(int _size){
P.clear(); LP.clear(); samples.clear();
P.resize(_size);
LP.resize(_size);
samples.resize(_size);
}//end Resize
void Assign(int _size,double value){
P.clear(); LP.clear(); samples.clear();
P.assign(_size,value);
LP.resize(_size);
samples.resize(_size);
}//end Assign
double MaxP(){
double max=P[0];
for(int i=1;i<P.size();i+=1){
if(P[i]>max){max=P[i];}
}//endfor i
return max;
}//end MaxValue
void Randomize(){
for(int i=0;i<P.size();i+=1){
P[i]=(1.0*rand())/(1.0*RAND_MAX);
}//endfor i
Normalize();
}//end Randomize
void Sort(){
vector<Pair> pairs;
Pair pair;
for(int i=0;i<P.size();i+=1){
pair.ID=i;
pair.value=P[i];
pairs.push_back(pair);
}//endfor i
stable_sort(pairs.begin(), pairs.end(), MorePair());
Prob<T> tmpProb;
tmpProb=*this;
for(int i=0;i<P.size();i+=1){
P[i]=tmpProb.P[pairs[i].ID];
samples[i]=tmpProb.samples[pairs[i].ID];
}//endfor i
PToLP();
}//end Sort
double Entropy(){
double ent=0;
for(int i=0;i<P.size();i+=1){
if(P[i]<1E-10){continue;}
ent+=-P[i]*log(P[i]);
}//endfor i
return ent;
}//end Entropy
};//endclass Prob
#endif // BasicCalculation_HPP
| [
"[email protected]"
] | |
529e7685357668c93132e2db4b12a176fa1ee918 | 520aaa426dee1a0d88e646039c26bb203e25604e | /00_create_window/sdl/sdl_window.cpp | 41d36910810945a8319abd7cf2a8916bc40aba33 | [] | no_license | benjaminhuanghuang/opgl-study | 4c6a0f2d53c6ffcd2b0ee3bc5eed5043a5087f0d | a761ee7fde1c7e41c18a6b64aba3ec1503c74067 | refs/heads/master | 2023-03-27T21:59:20.338919 | 2021-03-30T05:01:35 | 2021-03-30T05:01:35 | 199,388,714 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,924 | cpp | #include <SDL2/SDL.h>
#include <stdlib.h>
#include <stdio.h>
#include <GL/glew.h>
bool isRunning = true;
void processInput(){
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
isRunning = false;
break;
}
}
}
int main(void)
{
// Set OpenGL attributes
// Use the core OpenGL profile
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
// Specify version 3.3
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
// Request a color buffer with 8-bits per RGBA channel
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
// Enable double buffering
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
// Force OpenGL to use hardware acceleration
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_Window *mWindow = SDL_CreateWindow("OpenGL widnow using SDL", 100, 100, 800, 600, SDL_WINDOW_OPENGL);
if (!mWindow)
{
SDL_Log("Failed to create window: %s", SDL_GetError());
return false;
}
// Create an OpenGL context
SDL_GLContext mContext = SDL_GL_CreateContext(mWindow);
// Initialize GLEW
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK)
{
SDL_Log("Failed to initialize GLEW.");
return false;
}
// Initialize GLEW
glewExperimental = true; // Needed for core profile
if (glewInit() != GLEW_OK)
{
SDL_Log("Failed to initialize GLEW.");
exit(EXIT_FAILURE);
}
glViewport(0, 0, 640, 480);
while (isRunning)
{
processInput();
// Dark blue background
glClearColor(0.0f, 0.0f, 0.4f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Drawing ...
// Swap the buffers
SDL_GL_SwapWindow(mWindow);
}
SDL_Quit();
} | [
"[email protected]"
] | |
37df5d55ec4c458f659caac3bb05d9b3123ff5b5 | 90517ce1375e290f539748716fb8ef02aa60823b | /solved/i-k/knights-in-chessboard/gen.cpp | 4cd5e4f5e07b63f0ec339464090d16277718bdae | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | Code4fun4ever/pc-code | 23e4b677cffa57c758deeb655fd4f71b36807281 | 77ce51d692acf6edcb9e47aeb7b7f06bf56e4e90 | refs/heads/master | 2021-01-15T08:15:00.681534 | 2014-09-08T05:28:39 | 2014-09-08T05:28:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 525 | cpp | #include <cstdio>
#include <cstdlib>
#include <ctime>
#define MAXT 41000
#define MAXM 200
#define MAXN 200
void test_case()
{
int m = rand() % MAXM + 1;
int n = rand() % MAXN + 1;
printf("%d %d\n", m, n);
}
int main()
{
srand(time(NULL));
int T = MAXT;
printf("%d\n", T);
for (int i = 1; i <= 200; ++i)
for (int j = 1; j <= 200; ++j)
if (T > 0) {
printf("%d %d\n", i, j);
--T;
}
while (T--) test_case();
return 0;
}
| [
"[email protected]"
] | |
33339e592b6dbde32e72f968ed0340d27055877c | 22964c1b05c503fc88d26b5e1cfa558308e7342f | /search/binary_search.cpp | 13467067c2eff4141e17343844b41ad4a09426ca | [] | no_license | oceanwavechina/algorithm | 8f67088ac80b236d076333c63e3161f7bf0fff11 | d3fae2f5ed1a636eca1f35cdc9a5703238957efd | refs/heads/master | 2021-11-29T00:21:25.798080 | 2021-09-22T09:29:42 | 2021-09-22T09:29:42 | 180,058,662 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,023 | cpp | /*
* binary_search.cpp
*
* Created on: Sep 5, 2016
* Author: liuyanan
*/
#include <iostream>
#include <vector>
#include <cmath>
int binary_search_recursive(std::vector<int> A, int low, int high, int key) {
// 这个算法需要注意的就是边界,因为第一个判断就是中值,所以之后的两个分支中,不包括这个中间的index
// 还有就是注意之前说的,我们什么时候用元素,什么时候用元素的值
if (high < low)
return low -1;
// ** 考察的点:不能是,(low+high)/2, 因为可能出现越界
int mid = low + (high-low)/2;
if (key == A[mid]) {
return mid;
} else if (key < A[mid]) {
return binary_search_recursive(A, low, mid-1, key);
} else {
return binary_search_recursive(A, mid+1, high, key);
}
}
int binary_search_iterative(std::vector<int> A, int low, int high, int key) {
/* 递归变成迭代的步骤就是:
1. 首先找到循环的是什么: 就是递归掉用时的 结束条件的 反条件,比如递归中是 high < low, 迭代中循环的条件就是 low <= high
2. 找到每次迭代的 step大小 是多少
*/
while (low <= high) {
int mid = low + (high-low)/2;
if (key == A[mid]) {
return mid;
} else if (key < A[mid]) {
high = mid -1;
} else {
low = mid + 1;
}
}
return low - 1;
}
int main() {
std::vector<int> A = {0, 2, 3, 4, 5, 7, 8, 9};
// std::cout << "target index of 5 is: " << binary_search_recursive(A, 0, A.size()-1, 5) << std::endl;
// std::cout << "target index of 6 is: " << binary_search_recursive(A, 0, A.size()-1, 6) << std::endl;
// std::cout << "target index of -1 is: " << binary_search_recursive(A, 0, A.size()-1, -1) << std::endl;
std::cout << "target index of 5 is: " << binary_search_iterative(A, 0, A.size()-1, 5) << std::endl;
std::cout << "target index of 6 is: " << binary_search_iterative(A, 0, A.size()-1, 6) << std::endl;
std::cout << "target index of -1 is: " << binary_search_iterative(A, 0, A.size()-1, -1) << std::endl;
return 0;
}
| [
"[email protected]"
] | |
d36b3d2c135550f425a28e428b0a1e5347a32ad6 | d25615104f7f8d7e1c6d6a02f18dd6c4f0a62461 | /removeLinkedListElements.cpp | 38c4d406d00e484621fc88c21e0174b94a76bf11 | [] | no_license | luisacoding/LeetCode | bba511c4fcd1a7d031864055b38b92018f685bbc | 8c729ce796a4e68328ef20311fa68cea43cfbe4d | refs/heads/master | 2021-01-12T22:38:09.038350 | 2015-05-12T08:56:57 | 2015-05-12T08:56:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,517 | cpp | /*
203. Removed Linked List Elements
Remove all elements from a linked list of integers that have value val.
Example
Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6
Return: 1 --> 2 --> 3 --> 4 --> 5
*/
#include "ListNode.h"
#include <iostream>
void printListNode(ListNode *head)
{
if (head == nullptr)
return;
for (; head != nullptr; head = head->next)
std::cout << head->val << '\t';
std::cout << std::endl;
}
ListNode* removeElements(ListNode* head, int val)
{
if (head == nullptr) return nullptr;
ListNode *pre = head,
*p = head;
for (; p != nullptr; )
{
if (val != p->val)
{
pre = p;
p = p->next;
continue;
}
// else
if (p == head) // Head
{
ListNode *tmp = head;
head = head->next;
p = pre = head;
delete tmp;
continue;
}
if (p->next == nullptr) // Tail
{
pre->next = nullptr;
delete p;
break;
}
// Middle
ListNode *tmp = p;
pre->next = p->next;
p = p->next;
delete tmp;
}
return head;
}
int main(int argv, char **argc)
{
int A[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
ListNode *p = new ListNode(A[0]),
*head = p;
for (int i = 1; i < 10; i++)
{
p->next = new ListNode(A[i]);
p = p->next;
}
printListNode(head);
p = removeElements(head, 5); // Middle
printListNode(p);
p = removeElements(p, 1); // Head
printListNode(p);
p = removeElements(p, 0); // Tail
printListNode(p);
ListNode *singleNode = new ListNode(100);
p = removeElements(singleNode, 100); // SingleNode
printListNode(p);
return 0;
}
| [
"[email protected]"
] | |
3cea04415ad70a208c61a83ce6991e275eb8accb | 3b5ff782365cbe5539a260b4ccb5bb3f272f510e | /Tank.h | e18f9fed46a6268b0c34eab41b95e692a2de31d4 | [] | no_license | BrockBarber/cs476_SE_Zombie | 5a19dcf492cb694f0add546667075fafbf199ffb | 5d44602f89bfcb032d7b263fca623be78398b9f8 | refs/heads/master | 2021-01-13T01:00:02.375466 | 2016-03-03T17:27:03 | 2016-03-03T17:27:03 | 52,115,318 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 252 | h | //
// Created by horvste on 2/29/16.
//
#ifndef ZOMBIEWAR_TANK_H
#define ZOMBIEWAR_TANK_H
#include "Zombie.h"
class Tank : public Zombie {
public:
Tank();
virtual void attack(ISurvivor *survivor) override;
};
#endif //ZOMBIEWAR_TANK_H
| [
"[email protected]"
] | |
e1eea7217261a850b365e969f6ee6315ee548eb1 | 2ecf9c1d7d447b894a1b3f6b81d0ee3fd30b1d1e | /Common/include/CoreMsgBase.h | 0a78ca143dad262e2e9050ea5459c50403f23559 | [] | no_license | jjzhang166/Overlay | 206ba27f7e95f756d299b64ead736e4a675b5832 | 4f9829b5552e238d4dfeea1500a45818c0f921a3 | refs/heads/master | 2023-03-17T16:15:55.520663 | 2015-03-10T08:31:34 | 2015-03-10T08:31:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,718 | h | #pragma once
//////////////////////////////////////////////////////////////////////////
// file: CoreMsgComm.h
// brief: This file is a global definition and implementation for communication between CoreClient
// and In-Game Overlay based on C/S framework.
// author: Sonic Guan
//////////////////////////////////////////////////////////////////////////
#include "atlbase.h"
#include "atlwin.h"
#include <list>
//////////////////////////////////////////////////////////////////////////
// macros
// class name of server message window
#define MSG_SERVER_CLSNAME _T("ArcMsgServer")
// class name of client message window
#define MSG_CLIENT_CLSNAME _T("ArcMsgClient")
#define SET_CLASS_NAME(clsname) static const TCHAR * GetClsName(){ return clsname; }
// the host window should responds this message to handle core messages
// wParam: hwnd of client or server who sent this message
// lParam: a pointer to a buffer with a core_msg_header
#define WM_COREMESSAGE WM_USER + 0x7316
// magic number to verify if the packet is a valid core message packet
#define CORE_MSG_MAGIC 0x83777
enum
{
CORE_MSG_CONNECT = 1,
};
//////////////////////////////////////////////////////////////////////////
// structures
struct core_msg_header
{
DWORD dwCmdId; // command id of the message packet
DWORD dwSize; // the size of the whole message packet, including this message header
DWORD dwRet; // result returned by this sending operation
BOOL bGet; // if this parameter is set to TRUE, it means the sender wanna the receiver to set the value of this packet for it.
// after the sender called SendCoreMessage and returned, the packet passed to the function is already set with data from receiver
};
//////////////////////////////////////////////////////////////////////////
// this packet is used for a client to connect a message server and register itself to the server
// it is implemented internally during the initialization of a client
// dwRet: 0 for OK, 1 for renew failed
struct core_msg_connect : public core_msg_header
{
DWORD dwClientId; // a client id is generally an user-define identity number which should be unique.
// in CoreClient this value should the game id.
core_msg_connect()
{
memset(this, 0, sizeof(core_msg_connect));
dwSize = sizeof(core_msg_connect);
dwCmdId = CORE_MSG_CONNECT;
}
};
class ICoreMsgCallback
{
public:
virtual void OnCoreMessage(HWND hFrom, core_msg_header * pHeader) = 0;
};
//////////////////////////////////////////////////////////////////////////
// CCoreMsgBase
//////////////////////////////////////////////////////////////////////////
template<class T>
class CCoreMsgBase
{
public:
// waiting data structure
enum
{
waitGet = 0,
waitMsg = 1,
waitOK = 0x10
};
struct tagWaitingItem
{
DWORD dwCmdId;
DWORD dwFlag;
core_msg_header * pItem;
};
typedef std::list<tagWaitingItem> LIST_WAITING;
private:
class CMsgWnd : public CWindowImpl<CMsgWnd>
{
public:
typedef CCoreMsgBase<T> CCoreMsgBaseT;
CMsgWnd(CCoreMsgBaseT * pBase) : m_pBase(pBase){}
~CMsgWnd(){}
DECLARE_WND_CLASS(T::GetClsName())
BEGIN_MSG_MAP(CMsgWnd)
MESSAGE_HANDLER(WM_COPYDATA, OnCopyData)
END_MSG_MAP()
// handle WM_COPYDATA and transmit core message to the host window
LRESULT OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled)
{
COPYDATASTRUCT * pCopyData = (COPYDATASTRUCT *)lParam;
if(pCopyData)
{
if(pCopyData->dwData == CORE_MSG_MAGIC)
{
// valid core messages, go on
core_msg_header * pHeader = (core_msg_header *)(pCopyData->lpData);
if(pHeader->dwCmdId == CORE_MSG_CONNECT)
{
// only server needs to handle this message, a client doesn't care
m_pBase->OnConnect((HWND)wParam, (core_msg_connect *)pHeader);
}
if(m_pBase->m_WaitingList.size())
{
// there is someone waiting for messages
EnterCriticalSection(&m_pBase->m_csWaitingLock);
for(CCoreMsgBaseT::LIST_WAITING::iterator it = m_pBase->m_WaitingList.begin(); it != m_pBase->m_WaitingList.end(); it++)
{
if(it->dwCmdId == pHeader->dwCmdId)
{
if(pHeader->bGet == 2 && it->pItem && it->dwFlag == waitGet)
{
memcpy(it->pItem, pHeader, pHeader->dwSize);
it->dwFlag |= CCoreMsgBaseT::waitOK;
break;
}
if(pHeader->bGet <= 1 && it->dwFlag == waitMsg)
{
it->dwFlag |= CCoreMsgBaseT::waitOK;
break;
}
}
}
LeaveCriticalSection(&m_pBase->m_csWaitingLock);
}
if(pHeader->bGet > 1)
{
// now in the sender, receiving the packet reflected from the receiver
return 0;
}
// relay messages
if(m_pBase->m_hHost)
{
::SendMessage(m_pBase->m_hHost, WM_COREMESSAGE, wParam, (LPARAM)pHeader);
}
else if(m_pBase->m_pCallback)
{
m_pBase->m_pCallback->OnCoreMessage((HWND)wParam, pHeader);
}
if(pHeader->bGet == TRUE)
{
// I am the receiver, the packet is already filled with data by receiver, reflect it to the sender
pHeader->bGet++;
m_pBase->SendCoreMsg((HWND)wParam, pHeader);
}
return (LRESULT)pHeader->dwRet;
}
}
return 0;
}
private:
CCoreMsgBaseT * m_pBase;
};
public:
CCoreMsgBase() : m_MsgWnd(this)
{
m_hHost = NULL;
m_pCallback = NULL;
}
virtual ~CCoreMsgBase(){}
friend class CMsgWnd;
//brief: necessary initialization of the message server, should be global unique in a process.
//hHost[in]: a core message server or client will transmit core message packets to the host window by sending method
//dwUserData[in]: user-define data, this param is only significant in CCoreMsgClient
//szServerName[in]: this parameter has different meanings in a server or in a client.
// when initiate a server, this means the window name, by using which the client could find the server.
BOOL Initialize(HWND hHost, DWORD dwUserData = 0, LPCTSTR szServerName = NULL)
{
if(!IsWindow(hHost))
{
return FALSE;
}
m_hHost = hHost;
return InternalInit(szServerName, dwUserData);
}
//brief: necessary initialization of the message server, should be global unique in a process.
//pCallback[in]: the message handler who will actually process customer messages
//dwUserData[in]: user-define data, this param is only significant in CCoreMsgClient
//szServerName[in]: this parameter has different meanings in a server or in a client.
// when initiate a server, this means the window name, by using which the client could find the server.
BOOL Initialize(ICoreMsgCallback * pCallback, DWORD dwUserData = 0, LPCTSTR szServerName = NULL)
{
if(!pCallback)
{
return FALSE;
}
m_pCallback = pCallback;
return InternalInit(szServerName, dwUserData);
}
// brief: should be called at the end of a process
virtual void Uninitialize()
{
if(m_MsgWnd.IsWindow())
{
m_MsgWnd.DestroyWindow();
}
m_hHost = NULL;
DeleteCriticalSection(&m_csWaitingLock);
m_WaitingList.clear();
}
// brief: test if the server or client is now working
virtual BOOL IsValid()
{
return m_MsgWnd.IsWindow();
}
// send a block of buffer with core_msg_header to a specified window
// hWnd[in]: the window will receive this buffer
// pHeader[in]: a pointer to a block of buffer with core_msg_header
virtual BOOL SendCoreMsg(HWND hWnd, core_msg_header * pHeader)
{
if(!hWnd || !IsWindow(hWnd))
{
return FALSE;
}
COPYDATASTRUCT cds;
cds.cbData = pHeader->dwSize;
cds.dwData = CORE_MSG_MAGIC;
cds.lpData = (LPVOID)pHeader;
if(pHeader->bGet == TRUE)
{
// wanna directly get data from receiver
AddWaitingItem(pHeader->dwCmdId, pHeader);
}
DWORD dwRet = 0;
BOOL bOK = FALSE;
if(SendMessageTimeout(hWnd, WM_COPYDATA, (WPARAM)(HWND)m_MsgWnd, (LPARAM)&cds, SMTO_ABORTIFHUNG, 50000, (PDWORD_PTR)&dwRet))
{
pHeader->dwRet = dwRet;
bOK = TRUE;
}
if(pHeader->bGet)
{
RemoveWaitingItem(pHeader->dwCmdId, pHeader);
}
return bOK;
}
// wait for a specified sent core message
virtual BOOL WaitForCoreMsg(DWORD dwCmdId, UINT uMilliseconds)
{
BOOL bOK = FALSE;
AddWaitingItem(dwCmdId);
const UINT uInterval = 100;
for(UINT uElapse = 0; ;uElapse += uInterval)
{
MSG msg;
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
Sleep(uInterval);
if(uMilliseconds != -1 && uElapse >=uMilliseconds)
{
// overtime
break;
}
EnterCriticalSection(&m_csWaitingLock);
for(LIST_WAITING::iterator it = m_WaitingList.begin(); it != m_WaitingList.end(); it++)
{
if(it->dwCmdId == dwCmdId && (it->dwFlag & waitOK))
{
// the waiting item has been removed from the waiting list, which means we have received the packet we wanted
bOK = TRUE;
m_WaitingList.erase(it);
break;
}
}
LeaveCriticalSection(&m_csWaitingLock);
if(bOK)
{
break;
}
}
return bOK;
}
// get the host window who will actually handle messages
// get the window of this message base used for relaying messages
HWND GetSelfWindow(){ return m_MsgWnd.m_hWnd; }
protected:
virtual void OnConnect(HWND hClientSender, core_msg_connect * pConnect){}
virtual BOOL InternalInit(LPCTSTR szServerName, DWORD dwUserData)
{
InitializeCriticalSection(&m_csWaitingLock);
return m_MsgWnd.Create(HWND_MESSAGE, NULL, szServerName) != NULL;
}
private:
void AddWaitingItem(DWORD dwCmdId, core_msg_header * pWaitingHeader = NULL)
{
tagWaitingItem item = {dwCmdId, pWaitingHeader ? waitGet : waitMsg, pWaitingHeader};
EnterCriticalSection(&m_csWaitingLock);
m_WaitingList.push_back(item);
LeaveCriticalSection(&m_csWaitingLock);
}
BOOL RemoveWaitingItem(DWORD dwCmdId, core_msg_header * pWaitingHeader = NULL)
{
BOOL bRet = FALSE;
EnterCriticalSection(&m_csWaitingLock);
for(LIST_WAITING::iterator it = m_WaitingList.begin(); it != m_WaitingList.end(); it++)
{
if(it->dwCmdId == dwCmdId)
{
if(!pWaitingHeader || it->pItem == pWaitingHeader)
{
m_WaitingList.erase(it);
bRet = TRUE;
break;
}
}
}
LeaveCriticalSection(&m_csWaitingLock);
return bRet;
}
private:
HWND m_hHost;
ICoreMsgCallback * m_pCallback;
CMsgWnd m_MsgWnd;
LIST_WAITING m_WaitingList;
CRITICAL_SECTION m_csWaitingLock;
};
//////////////////////////////////////////////////////////////////////////
// CCoreMsgServer
//////////////////////////////////////////////////////////////////////////
class CCoreMsgServer : public CCoreMsgBase<CCoreMsgServer>
{
public:
typedef struct tagClientData
{
HWND hClientWnd;
DWORD dwClientId;
}CLIENT_DATA;
typedef std::list<CLIENT_DATA> LIST_CLIENT_DATA;
private:
LIST_CLIENT_DATA m_listClientData;
public:
SET_CLASS_NAME(MSG_SERVER_CLSNAME)
virtual void Uninitialize()
{
m_listClientData.clear();
CCoreMsgBase::Uninitialize();
}
// remark: a server could set hWnd to HWND_BROADCAST to broadcast a message to all clients
virtual BOOL SendCoreMsg(HWND hWnd, core_msg_header * pHeader)
{
if(hWnd == HWND_BROADCAST)
{
// broadcast the message to all clients
for(LIST_CLIENT_DATA::iterator it = m_listClientData.begin(); it != m_listClientData.end(); it++)
{
CCoreMsgBase::SendCoreMsg(it->hClientWnd, pHeader);
}
return TRUE;
}
else if(!IsWindow(hWnd))
{
// the destination client is unavailable, remove it from the client list
for(LIST_CLIENT_DATA::iterator it = m_listClientData.begin(); it != m_listClientData.end(); it++)
{
if(hWnd == it->hClientWnd)
{
m_listClientData.erase(it);
break;
}
}
return FALSE;
}
else
{
return CCoreMsgBase::SendCoreMsg(hWnd, pHeader);
}
}
// remark: a server could send messages to a client with a user-define client id
virtual BOOL SendCoreMsg(DWORD dwClientID, core_msg_header * pHeader)
{
BOOL bRet = FALSE;
for(LIST_CLIENT_DATA::iterator it = m_listClientData.begin(); it != m_listClientData.end(); )
{
if(!IsWindow(it->hClientWnd))
{
it = m_listClientData.erase(it);
continue;
}
if(it->dwClientId == dwClientID)
{
bRet &= CCoreMsgBase::SendCoreMsg(it->hClientWnd, pHeader);
}
it++;
}
return bRet;
}
// to test if a client is still valid according to the validity of the binding hwnd
BOOL IsClientValid(DWORD dwClientId)
{
for(LIST_CLIENT_DATA::iterator it = m_listClientData.begin(); it != m_listClientData.end(); it++)
{
if(it->dwClientId == dwClientId)
{
return IsWindow(it->hClientWnd);
}
}
return FALSE;
}
// return the client id corresponding to a specified hWnd
DWORD GetClientIdByHwnd(HWND hWnd)
{
for(LIST_CLIENT_DATA::iterator it = m_listClientData.begin(); it != m_listClientData.end(); it++)
{
if(it->hClientWnd == hWnd)
{
return it->dwClientId;
}
}
return 0;
}
BOOL RemoveClientById(DWORD dwClientId)
{
BOOL bRet = FALSE;
for (LIST_CLIENT_DATA::iterator it = m_listClientData.begin();it != m_listClientData.end(); )
{
if (it->dwClientId == dwClientId)
{
it = m_listClientData.erase(it);
bRet = TRUE;
continue;
}
it++;
}
return bRet;
}
protected:
virtual void OnConnect(HWND hClientSender, core_msg_connect * pConnect)
{
for(LIST_CLIENT_DATA::iterator it = m_listClientData.begin(); it != m_listClientData.end(); it++)
{
if(it->hClientWnd == hClientSender)
{
return;
}
}
// a new client is connecting
CLIENT_DATA data = {hClientSender, pConnect->dwClientId};
m_listClientData.push_back(data);
}
};
//////////////////////////////////////////////////////////////////////////
// CCoreMsgClient
//////////////////////////////////////////////////////////////////////////
class CCoreMsgClient : public CCoreMsgBase<CCoreMsgClient>
{
private:
HWND m_hSvr;
DWORD m_dwClientID;
protected:
virtual BOOL InternalInit(LPCTSTR szServerName, DWORD dwUserData)
{
if(!CCoreMsgBase::InternalInit(szServerName, dwUserData))
{
return FALSE;
}
::SetWindowText(GetSelfWindow(), NULL);
m_hSvr = FindWindow(MSG_SERVER_CLSNAME, szServerName);
if(!m_hSvr)
{
return FALSE;
}
m_dwClientID = dwUserData;
return TRUE;
}
public:
SET_CLASS_NAME(MSG_CLIENT_CLSNAME)
CCoreMsgClient()
{
m_hSvr = NULL;
m_dwClientID = 0;
}
~CCoreMsgClient(){}
virtual BOOL SendCoreMsg(HWND hWnd, core_msg_header * pHeader)
{
return CCoreMsgBase::SendCoreMsg(hWnd, pHeader);
}
virtual BOOL SendCoreMsg(core_msg_header * pHeader)
{
return CCoreMsgBase::SendCoreMsg(m_hSvr, pHeader);
}
virtual void Uninitialize()
{
m_hSvr = NULL;
CCoreMsgBase::Uninitialize();
}
BOOL Connect()
{
core_msg_connect msg;
msg.dwClientId = m_dwClientID;
if(!SendCoreMsg(&msg))
{
return FALSE;
}
if(msg.dwRet)
{
return FALSE;
}
return TRUE;
}
};
| [
"[email protected]"
] | |
843acffe09b976781ca564b402b18bf7856f660b | 312463a0ad42b933cce6a851004ab5e56e5b4fb4 | /include/neb/gfx/glsl/program/util/flag.hpp | 6ada4cdea59412f2c9c6cc73f7889d89b0fe93c5 | [] | no_license | Luddw/Nebula-Graphics | bfeeedafc18f18728fb9b5adc8198f12a56891af | 8d787f4fed27e9d0130f69a4473d5bfe48e02794 | refs/heads/master | 2021-05-29T17:42:09.056540 | 2015-03-11T03:17:14 | 2015-03-11T03:17:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 271 | hpp | #ifndef NEB_GFX_GLSL_PROGRAM_UTIL_FLAG_HPP
#define NEB_GFX_GLSL_PROGRAM_UTIL_FLAG_HPP
#include <gal/etc/flag.hpp>
namespace neb { namespace gfx { namespace glsl { namespace program { namespace util {
DEFINE_FLAG(flag_shader,
((SHADOW)(1 << 0))
)
}}}}}
#endif
| [
"[email protected]"
] | |
eccddcb0531701a2c9f1a3c1419e5d076ce6303e | 9fc4a85471668e9ee9a8acb01f2ed2705895bd66 | /cpp/xmlhw/DigitalInputDefn.cpp | c737c7043e4f230988a306fc518ba3c8e4789744 | [
"MIT"
] | permissive | Team302/2018BetaCode | 56badc4624bdce48721c8efb195058a79eb4e277 | c941a77c537ce14fac0c13b7416f33b1cea97cad | refs/heads/master | 2020-04-14T18:27:28.418862 | 2019-01-03T20:50:30 | 2019-01-03T20:50:30 | 164,019,828 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,421 | cpp | // --------------------------------------------------------------------------------------------
// DigitalInputDefn.cpp
//
// Created on: Jan 15, 2018
// Author: casti
//
// --------------------------------------------------------------------------------------------
//
// Description: Create an DigitalInput from an XML definition
//
//
// --------------------------------------------------------------------------------------------
// C++ includes
#include <iostream>
// FRC includes
#include <xmlhw/DigitalInputDefn.h>
#include <frc/SmartDashboard/SmartDashboard.h>
// Team302 includes
#include <xmlhw/DigitalInputDefn.h>
#include <hw/DragonDigitalInput.h>
// Third Party includes
#include <pugixml/pugixml.hpp>
using namespace frc;
//-----------------------------------------------------------------------
// Method: ParseXML
// Description: Parse a motor XML element and create a DragonTalon from
// its definition.
//
//<!-- ====================================================
// digitalInput
// ====================================================
// enum DIGITAL_INPUT_TYPE
// {
// UNKNOWN_DIGITAL_INPUT_TYPE = -1,
// CUBE_PRESENT,
// ELEVATOR_POSITION_0,
// ELEVATOR_POSITION_1,
// ELEVATOR_POSITION_2,
// ELEVATOR_POSITION_3,
// ELEVATOR_POSITION_4,
// ELEVATOR_POSITION_5,
// ELEVATOR_POSITION_6,
// MAX_DIGITAL_INPPUT_TYPES
// };
//
// ==================================================== -->
//<!ELEMENT digitalInput EMPTY>
//<!ATTLIST digitalInput
// usage ( 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 ) "0"
// digitalId ( 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
// 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
// 20 | 21 | 22 | 23 | 24 | 25 ) "0"
// reversed (true | false ) "false"
//>
//
//
// Returns: DragonDigitalInput*
//-----------------------------------------------------------------------
DragonDigitalInput* DigitalInputDefn::ParseXML
(
pugi::xml_node DigitalNode
)
{
// initialize the output
DragonDigitalInput* input = nullptr;
// initialize the attributes to default values
DragonDigitalInput::DIGITAL_INPUT_TYPE usage = DragonDigitalInput::UNKNOWN_DIGITAL_INPUT_TYPE;
int digitalID = 0;
bool reversed = false;
bool hasError = false;
// Parse/validate the XML
for (pugi::xml_attribute attr = DigitalNode.first_attribute(); attr; attr = attr.next_attribute())
{
if ( strcmp( attr.name(), "usage" ) == 0 )
{
int iVal = attr.as_int();
switch (iVal )
{
case DragonDigitalInput::DIGITAL_INPUT_TYPE::CUBE_PRESENT:
usage = DragonDigitalInput::DIGITAL_INPUT_TYPE::CUBE_PRESENT;
break;
case DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_FLOOR:
usage = DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_FLOOR;
break;
case DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_SWITCH:
usage = DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_SWITCH;
break;
case DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_SCALE:
usage = DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_SCALE;
break;
case DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_MAX:
usage = DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_MAX;
break;
case DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_POSITION_4:
usage = DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_POSITION_4;
break;
case DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_POSITION_5:
usage = DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_POSITION_5;
break;
case DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_POSITION_6:
usage = DragonDigitalInput::DIGITAL_INPUT_TYPE::ELEVATOR_POSITION_6;
break;
default:
hasError = true;
printf( "==>> unknown DragonDigitalInput type %d \n", iVal );
break;
}
}
else if ( strcmp( attr.name(), "digitalId" ) == 0 )
{
int iVal = attr.as_int();
if ( iVal >=0 && iVal <= 25 )
{
digitalID = iVal;
}
else
{
printf( "==>> DigitalInputDefn::ParseXML invalid digitalId %d \n", iVal );
hasError = true;
}
}
else if ( strcmp( attr.name(), "reversed" ) == 0 )
{
reversed = attr.as_bool();
}
}
// Create the DragonDigitalInput
if ( !hasError )
{
input = new DragonDigitalInput( usage, digitalID, reversed );
}
return input;
}
| [
"[email protected]"
] | |
e550aee5690a639d352d4df827faa08f43c5af87 | 04b1803adb6653ecb7cb827c4f4aa616afacf629 | /third_party/blink/public/platform/web_client_hints_type.h | 589c372c9ba7cb002cb6f90c18a2fd04a070a745 | [
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"BSD-3-Clause"
] | permissive | Samsung/Castanets | 240d9338e097b75b3f669604315b06f7cf129d64 | 4896f732fc747dfdcfcbac3d442f2d2d42df264a | refs/heads/castanets_76_dev | 2023-08-31T09:01:04.744346 | 2021-07-30T04:56:25 | 2021-08-11T05:45:21 | 125,484,161 | 58 | 49 | BSD-3-Clause | 2022-10-16T19:31:26 | 2018-03-16T08:07:37 | null | UTF-8 | C++ | false | false | 1,044 | h | // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_CLIENT_HINTS_TYPE_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_CLIENT_HINTS_TYPE_H_
#include "third_party/blink/public/mojom/web_client_hints/web_client_hints_types.mojom-shared.h"
namespace blink {
// WebEnabledClientHints stores all the client hints along with whether the hint
// is enabled or not.
struct WebEnabledClientHints {
WebEnabledClientHints() = default;
bool IsEnabled(mojom::WebClientHintsType type) const {
return enabled_types_[static_cast<int>(type)];
}
void SetIsEnabled(mojom::WebClientHintsType type, bool should_send) {
enabled_types_[static_cast<int>(type)] = should_send;
}
bool enabled_types_[static_cast<int>(mojom::WebClientHintsType::kMaxValue) +
1] = {};
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_CLIENT_HINTS_TYPE_H_
| [
"[email protected]"
] | |
8a038c6b6c3f16abce976a46e13159336499a356 | d6bec40d1e65692127f08c8930e65cc94798ed8e | /SAD-Mesh/src/User.cpp | 0cd00706eff96e22324c221686e5314ed67eb7d0 | [] | no_license | xlcbingo1999/SAD-Mesh | 9f54a22a7aa6d2a14d20b4ba04ce73f555c43045 | d85372d7eafee9568a05c198fda08c1b02844e5e | refs/heads/master | 2023-05-29T19:07:50.151912 | 2023-05-13T08:16:19 | 2023-05-13T08:16:19 | 262,072,475 | 1 | 2 | null | 2023-05-13T08:16:20 | 2020-05-07T14:25:25 | C++ | UTF-8 | C++ | false | false | 746 | cpp | #ifndef USER_CPP
#define USER_CPP
#include "User.hpp"
User::User(/* args */)
{
fileManager.signIn();
}
User::~User()
{
fileManager.signOut();
fileManager.~FileManager();
execManager.~ExecManager();
}
bool User::importApplication() {
if( fileManager.receiveImportApplication() == false ){
return false;
}
return true;
}
bool User::chooseDataStruct() {
if(fileManager.receiveChooseDataStruct() == false) {
return false;
}
return true;
}
bool User::beginImporting() {
if(fileManager.beginImporting() == false) return false;
return true;
}
void User::outputDataStruct() {
fileManager.outputDataStruct();
}
void User::diy() {
fileManager.diyBeginSignal();
}
#endif
| [
"[email protected]"
] | |
183f2f4e3d154e75975a34448b011551321a9a6c | 18fbd5bc14f53de3822f7cf8e2d0339c789cf671 | /GLTools/include/GLMatrixStack.h | 08944fbbbc5c7be4859414b825faadfdf013c0ea | [] | no_license | codingabc/sb5code | f30c3205504d6c7447bd47b5dadb6cfcd7648d9b | d5ad2d29275055e07a5033b37de15db153e32e87 | refs/heads/master | 2016-08-11T15:59:51.724485 | 2015-10-12T09:39:33 | 2015-10-12T09:39:33 | 44,079,976 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,753 | h | // GLMatrixStack.h
// Matrix stack functionality
/*
Copyright (c) 2009, Richard S. Wright Jr.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
Neither the name of Richard S. Wright Jr. nor the names of other contributors may be used
to endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __GLT_MATRIX_STACK
#define __GLT_MATRIX_STACK
#include <GLTools.h>
#include <math3d.h>
#include <GLFrame.h>
enum GLT_STACK_ERROR { GLT_STACK_NOERROR = 0, GLT_STACK_OVERFLOW, GLT_STACK_UNDERFLOW };
class GLMatrixStack
{
public:
GLMatrixStack(int iStackDepth = 64) {
stackDepth = iStackDepth;
pStack = new M3DMatrix44f[iStackDepth];
stackPointer = 0;
m3dLoadIdentity44(pStack[0]);
lastError = GLT_STACK_NOERROR;
}
~GLMatrixStack(void) {
delete [] pStack;
}
inline void LoadIdentity(void) {
m3dLoadIdentity44(pStack[stackPointer]);
}
inline void LoadMatrix(const M3DMatrix44f mMatrix) {
m3dCopyMatrix44(pStack[stackPointer], mMatrix);
}
inline void LoadMatrix(GLFrame& frame) {
M3DMatrix44f m;
frame.GetMatrix(m);
LoadMatrix(m);
}
inline void MultMatrix(const M3DMatrix44f mMatrix) {
M3DMatrix44f mTemp;
m3dCopyMatrix44(mTemp, pStack[stackPointer]);
m3dMatrixMultiply44(pStack[stackPointer], mTemp, mMatrix);
}
inline void MultMatrix(GLFrame& frame) {
M3DMatrix44f m;
frame.GetMatrix(m);
MultMatrix(m);
}
inline void PushMatrix(void) {
if(stackPointer < (stackDepth-1)) {
stackPointer++;
m3dCopyMatrix44(pStack[stackPointer], pStack[stackPointer-1]);
}
else
lastError = GLT_STACK_OVERFLOW;
}
inline void PopMatrix(void) {
if(stackPointer > 0)
stackPointer--;
else
lastError = GLT_STACK_UNDERFLOW;
}
void Scale(GLfloat x, GLfloat y, GLfloat z) {
M3DMatrix44f mTemp, mScale;
m3dScaleMatrix44(mScale, x, y, z);
m3dCopyMatrix44(mTemp, pStack[stackPointer]);
m3dMatrixMultiply44(pStack[stackPointer], mTemp, mScale);
}
void Translate(GLfloat x, GLfloat y, GLfloat z) {
M3DMatrix44f mTemp, mScale;
m3dTranslationMatrix44(mScale, x, y, z);
m3dCopyMatrix44(mTemp, pStack[stackPointer]);
m3dMatrixMultiply44(pStack[stackPointer], mTemp, mScale);
}
void Rotate(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) {
M3DMatrix44f mTemp, mRotate;
m3dRotationMatrix44(mRotate, float(m3dDegToRad(angle)), x, y, z);
m3dCopyMatrix44(mTemp, pStack[stackPointer]);
m3dMatrixMultiply44(pStack[stackPointer], mTemp, mRotate);
}
// I've always wanted vector versions of these
void Scalev(const M3DVector3f vScale) {
M3DMatrix44f mTemp, mScale;
m3dScaleMatrix44(mScale, vScale);
m3dCopyMatrix44(mTemp, pStack[stackPointer]);
m3dMatrixMultiply44(pStack[stackPointer], mTemp, mScale);
}
void Translatev(const M3DVector3f vTranslate) {
M3DMatrix44f mTemp, mTranslate;
m3dLoadIdentity44(mTranslate);
memcpy(&mTranslate[12], vTranslate, sizeof(GLfloat) * 3);
m3dCopyMatrix44(mTemp, pStack[stackPointer]);
m3dMatrixMultiply44(pStack[stackPointer], mTemp, mTranslate);
}
void Rotatev(GLfloat angle, M3DVector3f vAxis) {
M3DMatrix44f mTemp, mRotation;
m3dRotationMatrix44(mRotation, float(m3dDegToRad(angle)), vAxis[0], vAxis[1], vAxis[2]);
m3dCopyMatrix44(mTemp, pStack[stackPointer]);
m3dMatrixMultiply44(pStack[stackPointer], mTemp, mRotation);
}
// I've also always wanted to be able to do this
void PushMatrix(const M3DMatrix44f mMatrix) {
if(stackPointer < stackDepth) {
stackPointer++;
m3dCopyMatrix44(pStack[stackPointer], mMatrix);
}
else
lastError = GLT_STACK_OVERFLOW;
}
void PushMatrix(GLFrame& frame) {
M3DMatrix44f m;
frame.GetMatrix(m);
PushMatrix(m);
}
// Two different ways to get the matrix
const M3DMatrix44f& GetMatrix(void) { return pStack[stackPointer]; }
void GetMatrix(M3DMatrix44f mMatrix) { m3dCopyMatrix44(mMatrix, pStack[stackPointer]); }
inline GLT_STACK_ERROR GetLastError(void) {
GLT_STACK_ERROR retval = lastError;
lastError = GLT_STACK_NOERROR;
return retval;
}
protected:
GLT_STACK_ERROR lastError;
int stackDepth;
int stackPointer;
M3DMatrix44f *pStack;
};
#endif
| [
"[email protected]"
] | |
8558869d0895bf03e7987d42c2738e86787f585d | 341f268cd7061eae5de77c1a6de0736ac6d94206 | /C++/求素数4.cpp | f97df364331554c118d370e1fd49230347ca5388 | [] | no_license | jianjiachenghub/CLanguageProgramming | d25467a1fc48cdbe9a0a053fe3091e86dc9c9205 | 415b13bfa0888b2c61b36d68a407b39cde3ab662 | refs/heads/master | 2020-08-07T22:56:23.793406 | 2019-10-08T11:00:54 | 2019-10-08T11:00:54 | 213,611,543 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 356 | cpp | #include<stdio.h>
#include<math.h>
int main ()
{
int a,b;
while(scanf("%d %d",&a,&b)!=EOF)
{
if(a>b){
int j;
j=b;
b=a;
a=j;
}
int count=0;
int i=a;
for(a;a<=b;a++)
{
float c = sqrt(a);
for(int i=2;i<=c;i++)
{
if(a%i==0)
{
count++;
break;
}
}
}
int z=b-i+1-count;
printf("%d\n",z);
}
}
| [
"[email protected]"
] | |
2f6d4bf9e9810dd401fab59bfe2542046d3b2be0 | bbda3afa0f845bea14d7e6e442b6c119663dea87 | /Coda/src/nlp-stack/Dictionary/SuffixModelTrieBinaryFileReader.h | ab270ae9fccffb626dba8608a555a62ea2034265 | [
"Apache-2.0"
] | permissive | AndreAKM/veles.nlp | 91d261659bc48b9608cb6cbc9ed59b6e031d0291 | 972fde27203cb04d301e34274b57435ed58372c4 | refs/heads/master | 2020-12-24T06:20:58.764281 | 2016-11-11T12:23:32 | 2016-11-11T12:23:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,831 | h | /**
* SuffixModelTrieBinaryFileReader.h
* Class SuffixModelTrieBinaryFileReader
*
* .. invisible:
* _ _ _____ _ _____ _____
*
* | | | | ___| | | ___/ ___|
*
* | | | | |__ | | | |__ \ `--.
*
* | | | | __|| | | __| `--. \
*
* \ \_/ / |___| |___| |___/\__/ /
*
* \___/\____/\_____|____/\____/
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License
*
*/
//#pragma warning( disable: 4018 )
#ifndef _SUFFIXMODELTRIEBINARYFILEREADER_H_
#define _SUFFIXMODELTRIEBINARYFILEREADER_H_
#include "SuffixModelTrie.h"
using namespace std;
/**
* class SuffixModelTrieBinaryFileReader for searching featureListId for suffix of a non-dictionary word
* load from binary file
*/
class SuffixModelTrieBinaryFileReader : public SuffixModelTrie
{
public:
SuffixModelTrieBinaryFileReader(Dictionary* _dic);
~SuffixModelTrieBinaryFileReader(void);
/**
* @brief load from binary file
*/
void loadFromBinaryFile(string _filePath);
protected:
vector<SuffixModelNode*> SuffixModelNodeList;
};
#endif /* _SUFFIXMODELTRIEBINARYFILEREADER_H_ */
| [
"[email protected]"
] | |
f9b1d2a38dfd5fcaaaa14611c8b4afba6225fee6 | 725ae70dafce9976291288c5980241d282e2fa13 | /alljoyn/alljoyn_core/src/AboutIcon.cc | d01efc1cff6c757dd8c47caa0f940c75ac02ba79 | [
"MIT"
] | permissive | EmbeddedSystemClass/compassApp | 99c8068f30cb0fab19b52e600059e61f7bc4e55e | 39c5207f81613b2e595231c580a994c4c04bf7f7 | refs/heads/master | 2021-04-14T09:29:11.421615 | 2015-11-20T17:06:45 | 2015-11-20T17:06:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,962 | cc | /******************************************************************************
* Copyright AllSeen Alliance. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************************/
#include <alljoyn/AboutIcon.h>
namespace ajn {
AboutIcon::AboutIcon() : content(NULL), contentSize(0), mimetype(""), url(""), m_arg() {
//empty constructor
}
QStatus AboutIcon::SetContent(const char* mimetype, uint8_t* data, size_t csize, bool ownsData)
{
QStatus status = ER_OK;
status = m_arg.Set("ay", csize, data);
if (status != ER_OK) {
return status;
}
this->mimetype = mimetype;
this->content = data;
this->contentSize = csize;
if (ownsData) {
m_arg.SetOwnershipFlags(MsgArg::OwnsData);
}
return status;
}
QStatus AboutIcon::SetUrl(const char* mimetype, const char* url)
{
this->mimetype = mimetype;
this->url = url;
return ER_OK;
}
void AboutIcon::Clear() {
m_arg.Clear();
content = NULL;
contentSize = 0;
mimetype = "";
url = "";
}
QStatus AboutIcon::SetContent(const MsgArg& arg) {
m_arg = arg;
m_arg.Stabilize();
return m_arg.Get("ay", &contentSize, &content);
}
}
| [
"[email protected]"
] | |
49bbdd19197fafba8d175457e0f7fd88b961d2e8 | 565627454904b93c2f3576bead8fb5675aaa7559 | /Control.cpp | db4959e18b2a46088f605450ee01c9d5c5ef28c8 | [] | no_license | mattbritt/terminal-snake | eed35e53220397c69113bcdefcdafe13e28c917a | c47898ed90d22aea91896ff7a3b5d8bd5dd6a6d4 | refs/heads/master | 2020-03-20T22:49:33.036142 | 2018-06-18T23:31:56 | 2018-06-18T23:31:56 | 137,817,050 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,807 | cpp | /**********************************************************************
** Control.cpp
** Author: Matt Britt
** Date: 12/2/2017
** Description: Control.cpp is the implementation file for the Control class.
** The Control class polls for and gets input from keyboard.
*********************************************************************/
#include "Control.hpp"
/********************************************************************
** Key pollKey(int ms)
** Description: Polls for input for ms milliseconds, returns Key pressed
*********************************************************************/
Key Control::pollKey(int ms)
{
// based on original terminal control code in Terry Quest by Harlan James
system("stty raw");
bool gotKey = false;
pollfd fd;
clock_t stopTime = ((double)ms / 1000.0) * CLOCKS_PER_SEC ; // calc stopTime in clocks; reduces overhead in timing loop below
stopTime += eventObj.updateTime(); // sets stopTime to currentTime + ms & updates timer (EventObj)
cout << CURSOR_HOME << CLEAR_LINE << endl; // critical endl
do
{
// poll code courtesy of https://stackoverflow.com/questions/4656388/poll-stdin-and-other-fds
fd.fd = 0;
fd.events = POLLIN;
fd.revents = 0;
int ret = poll(&fd, 1, 0);
// if there's a key available, exit loop
if (ret > 0 && (fd.revents & POLLIN != 0))
{
gotKey = true;
cout << CLEAR_LINE;
}
} while (!gotKey && (clock() < stopTime));
// reset cursor line
cout << CURSOR_HOME << CLEAR_LINE;
// if we polled a key
if (gotKey)
{
char key;
Key retKey = NO_KEY;
// we can extract now extract a key from stdin w/o blocking
key = cin.get();
if (key == 27) // handle escape sequence on arrow keys
{
key = cin.get();
key = cin.get(); // discard extraneous chars
}
// parse key code
switch (key)
{
case 13:
retKey = ENTER_KEY;
break;
case 65:
retKey = UP_KEY;
break;
case 66:
retKey = DOWN_KEY;
break;
case 67:
retKey = RIGHT_KEY;
break;
case 68:
retKey = LEFT_KEY;
break;
}
// handle redefinable keys
if (key == quitKey)
{
retKey = QUIT_KEY;
}
return retKey;
}
// else loop timeout == no key pressed
else
{
return NO_KEY;
}
}
/********************************************************************
** Direction keyToDir(Key key)
** Description: Convert Key to Direction
*********************************************************************/
Direction Control::keyToDir(Key key)
{
switch (key)
{
case UP_KEY:
return UP;
break;
case DOWN_KEY:
return DOWN;
break;
case LEFT_KEY:
return LEFT;
break;
case RIGHT_KEY:
return RIGHT;
break;
}
}
| [
"[email protected]"
] | |
4da2d66a9573d38217bb8d438b69b7132ee0efbe | 5045163196c2015a134a49528826b4364b67877a | /engineCode/RenderingCore.h | 60538d215ccc075a8c5afbb2ec35ed5a57023f3f | [
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | nkyllonen/8980-scripted-game | 8594c0f19e5f0dbf95b799332baf7b983c92e2af | ae3b9e6c04d1f3e67d3ff5be6137285831265d73 | refs/heads/master | 2020-08-17T00:45:01.318236 | 2019-10-30T05:26:50 | 2019-10-30T05:26:50 | 215,581,392 | 0 | 0 | NOASSERTION | 2019-10-30T05:26:51 | 2019-10-16T15:23:59 | C++ | UTF-8 | C++ | false | false | 298 | h | #include <vector>
//HDR Buffers and textures
extern unsigned int pingpongFBO[2];
extern unsigned int pingpongColorbuffers[2];
extern unsigned int baseTex, brightText; //Textures which are bound to the HDR FBO
//Full screen quad rendering
extern unsigned int quadVAO;
void createFullscreenQuad();
| [
"[email protected]"
] | |
36563d8709197fb69ab7bfca25582b2b2d0b1d00 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/curl/gumtree/curl_old_log_16421.cpp | 384ba2b91e25ef5b904b3af02a94d2840d5ccea5 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 512 | cpp | fputs(
" exact). To make commands take place after a successful transfer,\n"
" prefix them with a dash '-'. To make commands be sent after\n"
" curl has changed the working directory, just before the transfer\n"
" command(s), prefix the command with a '+' (this is only sup-\n"
" ported for FTP). You may specify any number of commands.\n"
"\n"
" If the server returns failure for one of the commands, the\n"
, stdout); | [
"[email protected]"
] | |
85b60c6f8e11a03b323e5b723e6423a83629ffbd | 09bb77419b43045b7b0156972a4cf31f8dff0b9d | /Trabalho - 2/romano.cpp | 42a1f24adfe9aacb1f4478be9b90aa63a9b16ba4 | [
"MIT"
] | permissive | DraculK/MP | 3f01f9766ba4b624a9a100313609f6e7ee6003ff | 7f35acf6bee744c9da692e95beff4212809ec956 | refs/heads/main | 2023-04-01T15:16:45.296570 | 2021-03-31T18:31:02 | 2021-03-31T18:31:02 | 352,451,629 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 777 | cpp | #include "romano.hpp"
using namespace std;
int romanoInt::value(char r){
if (r == 'I')
return 1;
if (r == 'V')
return 5;
if (r == 'X')
return 10;
if (r == 'L')
return 50;
if (r == 'C')
return 100;
if (r == 'D')
return 500;
if (r == 'M')
return 1000;
return -1;
}
int romanoInt::romanToInt(string str){
int res = 0;
int a = str.length();
for (int i = 0; i < a; i++)
{
int s1 = value(str[i]);
if (i + 1 <a)
{
int s2 = value(str[i + 1]);
if (s1 >= s2)
{
res = res + s1;
}
else
{
res = res + s2 - s1;
i++;
}
}
else {
res = res + s1;
}
}
return res;
}
/*int main()
{
romanoInt obj;
string str = "XXX";
cout << "Integer form of Roman Numeral is "
<< obj.romanToInt(str) << endl;
return 0;
}*/ | [
"[email protected]"
] | |
8eeb0d2c57c4978fa209ac38dc03e1a2bcbb8382 | 8e9ee669011cd7ac56028fd4afd65fda9cfdb8a1 | /lab4dsa bun/SortedBagLb4Bun/ExtendedTest.cpp | f833a4c4ca179cf269bd74e3b4e4574353a28002 | [] | no_license | 915-Munteanu-Tudor/Data-Structures-and-Algorithms | 3ca650f27c9b60c2c0bfd0f7d25c9ab9266565d6 | fdd5c8601aaac548c9840e51a212d9bb4a2b9c33 | refs/heads/main | 2023-09-01T02:06:01.443140 | 2021-10-23T09:39:43 | 2021-10-23T09:39:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,399 | cpp | #include "ShortTest.h"
#include "SortedBag.h"
#include "SortedBagIterator.h"
#include <assert.h>
#include <iostream>
#include <exception>
using namespace std;
bool relation2(TComp r1, TComp r2) {
return r1 <= r2;
}
bool relation3(TComp r1, TComp r2) {
return r1 >= r2;
}
void testExtra(){
cout<< "Test extra operation"<<endl;
SortedBag sb(relation2);
sb.add(1);
sb.add(2);
sb.add(2);
sb.add(3);
sb.add(2);
sb.add(6);
try {
sb.removeOccurrences(-2, 2);
assert(false);
}
catch (...) {
assert(true);
}
try {
assert(sb.removeOccurrences(2, 2) ==2);
}
catch (exception& ex) {
cout<<ex.what()<<endl;
}
assert(sb.size()==4);
try {
assert(sb.removeOccurrences(5, 2) ==1);
}
catch (exception& ex) {
cout<<ex.what()<<endl;
}
assert(sb.size() == 3);
}
void testCreate() {
cout << "Test create" << endl;
SortedBag sb(relation2);
assert(sb.isEmpty() == true);
assert(sb.size() == 0);
for (int i = -10; i < 30; i++) {
assert(sb.remove(i) == false);
}
for (int i = -10; i < 30; i++) {
assert(sb.search(i) == false);
}
for (int i = -10; i < 30; i++) {
assert(sb.nrOccurrences(i) == 0);
}
SortedBagIterator it = sb.iterator();
assert(it.valid() == false);
try {
it.getCurrent();
assert(false);
}
catch (exception&) {
assert(true);
}
try {
it.next();
assert(false);
}
catch (exception&) {
assert(true);
}
}
void testIterator(SortedBag& sb, Relation rel) {
SortedBagIterator it = sb.iterator();
TComp e1;
TComp e2;
if (it.valid()) {
e1 = it.getCurrent();
it.next();
}
while (it.valid()) {
e2 = e1;
e1 = it.getCurrent();
it.next();
assert(sb.search(e1) == true);
assert(sb.search(e2) == true);
assert(sb.nrOccurrences(e1) > 0);
assert(sb.nrOccurrences(e2) > 0);
assert(rel(e2, e1));
}
try {
it.getCurrent();
assert(false);
}
catch (exception&) {
assert(true);
}
try {
it.next();
assert(false);
}
catch (exception&) {
assert(true);
}
it.first();
assert(it.valid() == true);
it.first();
int count = 0;
while (it.valid()) {
count++;
it.next();
}
assert(count == sb.size());
}
void testAdd(Relation r) {
cout << "Test add" << endl;
SortedBag sb(r);
for (int i = 0; i < 100; i++) {
sb.add(i);
}
assert(sb.size() == 100);
assert(sb.isEmpty() == false);
testIterator(sb, r);
for (int i = 200; i >= -200; i--) {
sb.add(i);
}
assert(sb.size() == 501);
testIterator(sb, r);
for (int i = -300; i < 300; i++) {
bool exista = sb.search(i);
int nrA = sb.nrOccurrences(i);
if (i < -200 || i > 200) {
assert(exista == false);
assert(nrA == 0);
}
else if (i >= -200 && i < 0) {
assert(exista == true);
assert(nrA == 1);
}
else if (i >= 0 && i < 100) {
assert(exista == true);
assert(nrA == 2);
}
else if (i >= 100 && i <= 200) {
assert(exista == true);
assert(nrA == 1);
}
}
for (int i = 0; i < 100; i++) {
sb.add(0);
}
assert(sb.nrOccurrences(0) == 102);
testIterator(sb, r);
SortedBag sb2(r);
for (int i = 0; i < 300; i = i + 2) {
sb2.add(i);
sb2.add(2 * i);
sb2.add(-2 * i);
}
assert(sb2.size() == 450);
testIterator(sb2, r);
}
void testRemove(Relation r) {
cout << "Test remove" << endl;
SortedBag sb(r);
for (int i = -100; i < 100; i++) {
assert(sb.remove(i) == false);
assert(sb.search(i) == false);
assert(sb.nrOccurrences(i) == 0);
}
assert(sb.isEmpty() == true);
for (int i = -100; i < 100; i++) {
sb.add(i);
}
assert(sb.size() == 200);
for (int i = -100; i < 100; i = i + 2) {
assert(sb.remove(i) == true);
}
assert(sb.size() == 100);
for (int i = -100; i < 100; i++) {
if (i % 2 == 0) {
assert(sb.nrOccurrences(i) == 0);
assert(sb.search(i) == false);
assert(sb.remove(i) == false);
}
else {
assert(sb.nrOccurrences(i) == 1);
assert(sb.search(i) == true);
}
sb.add(i);
sb.add(i);
sb.add(i);
}
assert(sb.size() == 700);
for (int i = -200; i < 200; i++) {
if (i < -100 || i >= 100) {
assert(sb.search(i) == false);
assert(sb.nrOccurrences(i) == 0);
assert(sb.remove(i) == false);
}
else if (i % 2 == 0) {
assert(sb.search(i) == true);
assert(sb.nrOccurrences(i) == 3);
assert(sb.remove(i) == true);
assert(sb.remove(i) == true);
assert(sb.remove(i) == true);
assert(sb.remove(i) == false);
}
else {
assert(sb.search(i) == true);
assert(sb.nrOccurrences(i) == 4);
assert(sb.remove(i) == true);
assert(sb.remove(i) == true);
assert(sb.remove(i) == true);
assert(sb.remove(i) == true);
assert(sb.remove(i) == false);
}
}
SortedBag sb2(r);
for (int i = 300; i >= -500; i--) {
sb2.add(i);
sb2.add(i * 2);
sb2.add(-2 * i);
}
for (int i = -100; i < 100; i++) {
for (int j = 0; j < 100; j++) {
sb2.remove(i);
}
}
for (int i = -100; i < 100; i++) {
assert(sb2.nrOccurrences(i) == 0);
assert(sb2.search(i) == false);
}
}
void testQuantity(Relation r) {
cout << "Test quantity" << endl;
SortedBag sb(r);
for (int j = 0; j < 10; j++) {
sb.add(0);
for (int i = 1; i < 300; i++) {
sb.add(i);
sb.add(-i);
}
sb.add(-3000);
}
int count = 6000;
assert(sb.size() == 6000);
for (int i = 0; i < 5000; i++) {
TComp nr = rand() % 8000 - 4000;
if (sb.remove(nr) == true) {
count--;
}
assert(sb.size() == count);
}
assert(sb.size() == count);
}
void testIterator(Relation rel) {
cout << "Test iterator" << endl;
SortedBag sb(rel);
for (int i = 0; i < 500; i++) {
sb.add(i);
sb.add(-2 * i);
sb.add(2 * i);
sb.add(i);
sb.add(-2 * i);
sb.add(2 * i);
}
assert(sb.size() == 3000);
SortedBagIterator sbi = sb.iterator();
int count = 0;
while (sbi.valid()) {
count++;
sbi.next();
}
assert(count == sb.size());
sbi.first();
TElem e = sbi.getCurrent();
sbi.next();
count = 1;
while (sbi.valid()) {
TElem ee = sbi.getCurrent();
assert(rel(e, ee));
TElem ee2 = sbi.getCurrent();
assert(ee == ee2);
TElem ee3 = sbi.getCurrent();
assert(ee == ee3);
e = ee;
sbi.next();
count++;
}
assert(count == sb.size());
}
void testAllExtended() {
testCreate();
testExtra();
testAdd(relation2);
testAdd(relation3);
testRemove(relation2);
testRemove(relation3);
testIterator(relation2);
testIterator(relation3);
testQuantity(relation2);
testQuantity(relation3);
}
| [
"[email protected]"
] | |
f7bd36b256eea08930fa5eb092c334afae71b261 | bab1b5ac32b4424866d7f596a51abc018256c0f6 | /Assignment41/A41Q3.cpp | ef825b6c25ca5bd330d24c85f3e8b25fee282a70 | [] | no_license | PoojaPadir/CC-JAVA-Assignments | d1ee8244668387bbd18a06c79d2cd1587e12a5b3 | 3285daa4239b7f1b248e9949256eab585f038b88 | refs/heads/master | 2023-07-31T05:25:57.372520 | 2021-09-15T05:52:44 | 2021-09-15T05:52:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 439 | cpp | //Write generic program to accept N numbers from user and return addition of that numbers
#include<iostream>
using namespace std;
template<class T>
T AddN(T *arr,int iSize)
{
T sum=0;
int i=0;
for(i=0;i<iSize;i++)
{
sum=sum+arr[i];
}
return sum;
}
int main()
{
int arr[]={10,20,30,40,50};
float brr[]={10.0,3.7,9.8,8.7};
int iSum=AddN(arr,5);
printf("%d\n",iSum);
float fSum=AddN(brr,4);
printf("%f\n",fSum);
return 0;
} | [
"[email protected]"
] | |
b549d6714c54e8728f029bd12e1ae231d0799498 | e62baedc80d095acd3fca231cf82c07aa359070c | /first_pass/chords.cpp | ecd7d3237b4a3d9cad9e70f803d5597a59e2a044 | [] | no_license | KudeGit/elments_of_programming_interview | 347ac0b6d87f6d077bff62d6642b56c9c9ae4f18 | 2cbc0a0560f899cab11a296feab96397856af81c | refs/heads/master | 2021-01-17T14:15:49.270554 | 2017-01-07T17:24:25 | 2017-01-07T17:24:25 | 44,858,915 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 653 | cpp | #include <iostream>
#include <unordered_map>
#include "utils.hpp"
int chordCntHelper(int A, std::unordered_map<int, long int>& K)
{
if (A == 1 || A == 0) {
return 1;
} else if (A == 2) {
return 2;
}else if (K.find(A) != K.end()) {
return K[A];
} else {
long acc = 0;
for (int i = 0; i <= A - 2; ++i) {
acc += chordCntHelper(i, K) * chordCntHelper(A-2-i, K);
debug(acc);
}
K[A] = chordCntHelper(A-1, K) + acc;
return K[A];
}
}
int main (void)
{
std::unordered_map<int, long int> K;
auto res = chordCntHelper(4, K);
debug(res);
}
| [
"[email protected]"
] | |
2a5dcce9b0801f36fdb845d415bf3769b6442dab | 4b902f7cc86c128793f555cd03e38349a28ac4c6 | /dataset/cpp/ZLZipArchive.cpp | 480e17b05b8ca14e95ee7d02c91e48e630d15395 | [] | no_license | korhankonaray/FileTypeDetector | bf763ad20992978a54a1484035398fe69f6edd71 | 2ab29f9433781c74f35206c1ab2ecb6c6689e263 | refs/heads/master | 2021-06-29T20:14:47.062064 | 2021-02-28T18:54:07 | 2021-02-28T18:54:07 | 206,796,718 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 9,246 | cpp | // Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com
#include "pch.h"
#include <zlcore/zl_util.h>
#include <zlcore/ZLZipArchive.h>
using namespace std;
#define SCAN_BUFFER_SIZE 256
#define ARCHIVE_HEADER_SIGNATURE 0x06054b50
#define ENTRY_HEADER_SIGNATURE 0x02014b50
#define FILE_HEADER_SIGNATURE 0x04034b50
//================================================================//
// ZLZipArchiveHeader
//================================================================//
//----------------------------------------------------------------//
int ZLZipArchiveHeader::FindAndRead ( FILE* file ) {
size_t filelen;
size_t cursor;
char buffer [ SCAN_BUFFER_SIZE ];
size_t scansize;
int i;
if ( !file ) return -1;
fseek ( file, 0, SEEK_END );
filelen = ftell ( file );
cursor = filelen;
while ( cursor ) {
cursor = ( cursor > SCAN_BUFFER_SIZE ) ? cursor - SCAN_BUFFER_SIZE : 0;
scansize = (( cursor + SCAN_BUFFER_SIZE ) > filelen ) ? filelen - cursor : SCAN_BUFFER_SIZE;
fseek ( file, cursor, SEEK_SET );
fread ( buffer, scansize, 1, file );
for ( i = scansize - 4; i >= 0; --i ) {
// maybe found it
if ( *( unsigned long* )&buffer [ i ] == ARCHIVE_HEADER_SIGNATURE ) {
fseek ( file, cursor + i, SEEK_SET );
fread ( &this->mSignature, 4, 1, file );
fread ( &this->mDiskNumber, 2, 1, file );
fread ( &this->mStartDisk, 2, 1, file );
fread ( &this->mTotalDiskEntries, 2, 1, file );
fread ( &this->mTotalEntries, 2, 1, file );
fread ( &this->mCDSize, 4, 1, file );
fread ( &this->mCDAddr, 4, 1, file );
fread ( &this->mCommentLength, 2, 1, file );
return 0;
}
}
}
return -1;
}
//================================================================//
// ZLZipEntryHeader
//================================================================//
//----------------------------------------------------------------//
int ZLZipEntryHeader::Read ( FILE* file ) {
fread ( &this->mSignature, 4, 1, file );
if ( this->mSignature != ENTRY_HEADER_SIGNATURE ) return -1;
fread ( &this->mByVersion, 2, 1, file );
fread ( &this->mVersionNeeded, 2, 1, file );
fread ( &this->mFlag, 2, 1, file );
fread ( &this->mCompression, 2, 1, file );
fread ( &this->mLastModTime, 2, 1, file );
fread ( &this->mLastModDate, 2, 1, file );
fread ( &this->mCrc32, 4, 1, file );
fread ( &this->mCompressedSize, 4, 1, file );
fread ( &this->mUncompressedSize, 4, 1, file );
fread ( &this->mNameLength, 2, 1, file );
fread ( &this->mExtraFieldLength, 2, 1, file );
fread ( &this->mCommentLength, 2, 1, file );
fread ( &this->mDiskNumber, 2, 1, file );
fread ( &this->mInternalAttributes, 2, 1, file );
fread ( &this->mExternalAttributes, 4, 1, file );
fread ( &this->mFileHeaderAddr, 4, 1, file );
return 0;
}
//================================================================//
// ZLZipFileHeader
//================================================================//
//----------------------------------------------------------------//
int ZLZipFileHeader::Read ( FILE* file ) {
fread ( &this->mSignature, 4, 1, file );
if ( this->mSignature != FILE_HEADER_SIGNATURE ) return -1;
fread ( &this->mVersionNeeded, 2, 1, file );
fread ( &this->mFlag, 2, 1, file );
fread ( &this->mCompression, 2, 1, file );
fread ( &this->mLastModTime, 2, 1, file );
fread ( &this->mLastModDate, 2, 1, file );
fread ( &this->mCrc32, 4, 1, file ); // *not* to be trusted (Android)
fread ( &this->mCompressedSize, 4, 1, file ); // *not* to be trusted (Android)
fread ( &this->mUncompressedSize, 4, 1, file ); // *not* to be trusted (Android)
fread ( &this->mNameLength, 2, 1, file );
fread ( &this->mExtraFieldLength, 2, 1, file );
return 0;
}
//================================================================//
// ZLZipFileDir
//================================================================//
//----------------------------------------------------------------//
ZLZipFileDir* ZLZipFileDir::AffirmSubDir ( const char* path, size_t len ) {
ZLZipFileDir* dir = this->mChildDirs;
for ( ; dir; dir = dir->mNext ) {
if ( count_same_nocase ( dir->mName.c_str (), path ) == len ) return dir;
}
dir = new ZLZipFileDir ();
dir->mNext = this->mChildDirs;
this->mChildDirs = dir;
dir->mName.assign ( path, len );
return dir;
}
//----------------------------------------------------------------//
ZLZipFileDir::ZLZipFileDir () :
mNext ( 0 ),
mChildDirs ( 0 ),
mChildFiles ( 0 ) {
}
//----------------------------------------------------------------//
ZLZipFileDir::~ZLZipFileDir () {
ZLZipFileDir* dirCursor = this->mChildDirs;
while ( dirCursor ) {
ZLZipFileDir* dir = dirCursor;
dirCursor = dirCursor->mNext;
delete dir;
}
ZLZipFileEntry* entryCursor = this->mChildFiles;
while ( entryCursor ) {
ZLZipFileEntry* entry = entryCursor;
entryCursor = entryCursor->mNext;
delete entry;
}
}
//================================================================//
// ZLZipArchive
//================================================================//
//----------------------------------------------------------------//
void ZLZipArchive::AddEntry ( ZLZipEntryHeader* header, const char* name ) {
int i;
const char* path = name;
ZLZipFileDir* dir = this->mRoot;
// gobble the leading '/' (if any)
if ( path [ 0 ] == '/' ) {
path = &path [ 1 ];
}
// build out directories
for ( i = 0; path [ i ]; ) {
if ( path [ i ] == '/' ) {
dir = dir->AffirmSubDir ( path, i + 1 );
path = &path [ i + 1 ];
i = 0;
continue;
}
i++;
}
if ( path [ 0 ]) {
ZLZipFileEntry* entry = new ZLZipFileEntry ();
entry->mFileHeaderAddr = header->mFileHeaderAddr;
entry->mCrc32 = header->mCrc32;
entry->mCompression = header->mCompression;
entry->mCompressedSize = header->mCompressedSize;
entry->mUncompressedSize = header->mUncompressedSize;
entry->mName = path;
entry->mNext = dir->mChildFiles;
dir->mChildFiles = entry;
}
}
//----------------------------------------------------------------//
ZLZipFileDir* ZLZipArchive::FindDir ( char const* path ) {
size_t i;
ZLZipFileDir* dir;
if ( !this->mRoot ) return 0;
if ( !path ) return 0;
// gobble the leading '/' (if any)
if ( path [ 0 ] == '/' ) {
path = &path [ 1 ];
}
dir = this->mRoot;
for ( i = 0; path [ i ]; ) {
if ( path [ i ] == '/' ) {
ZLZipFileDir* cursor = dir->mChildDirs;
for ( ; cursor; cursor = cursor->mNext ) {
if ( count_same_nocase ( cursor->mName.c_str (), path ) == cursor->mName.length ()) {
dir = cursor;
break;
}
}
// no match found; can't resolve directory
if ( !cursor ) return 0;
path = &path [ i + 1 ];
i = 0;
continue;
}
i++;
}
return dir;
}
//----------------------------------------------------------------//
ZLZipFileEntry* ZLZipArchive::FindEntry ( char const* filename ) {
ZLZipFileDir* dir;
ZLZipFileEntry* entry;
int i;
if ( !filename ) return 0;
i = strlen ( filename ) - 1;
if ( filename [ i ] == '/' ) return 0;
dir = this->FindDir ( filename );
if ( !dir ) return 0;
for ( ; i >= 0; --i ) {
if ( filename [ i ] == '/' ) {
filename = &filename [ i + 1 ];
break;
}
}
entry = dir->mChildFiles;
for ( ; entry; entry = entry->mNext ) {
if ( strcmp_ignore_case ( entry->mName.c_str (), filename ) == 0 ) break;
}
return entry;
}
//----------------------------------------------------------------//
int ZLZipArchive::Open ( const char* filename ) {
ZLZipArchiveHeader header;
ZLZipEntryHeader entryHeader;
char* nameBuffer = 0;
int nameBufferSize = 0;
int result = 0;
int i;
FILE* file = fopen ( filename, "rb" );
if ( !file ) goto error;
result = header.FindAndRead ( file );
if ( result ) goto error;
if ( header.mDiskNumber != 0 ) goto error; // unsupported
if ( header.mStartDisk != 0 ) goto error; // unsupported
if ( header.mTotalDiskEntries != header.mTotalEntries ) goto error; // unsupported
// seek to top of central directory
fseek ( file, header.mCDAddr, SEEK_SET );
this->mFilename = filename;
this->mRoot = new ZLZipFileDir ();
// parse in the entries
for ( i = 0; i < header.mTotalEntries; ++i ) {
result = entryHeader.Read ( file );
if ( result ) goto error;
if (( entryHeader.mNameLength + 1 ) > nameBufferSize ) {
nameBufferSize += SCAN_BUFFER_SIZE;
nameBuffer = ( char* )realloc ( nameBuffer, nameBufferSize );
}
fread ( nameBuffer, entryHeader.mNameLength, 1, file );
nameBuffer [ entryHeader.mNameLength ] = 0;
// skip the extra field, etc.
result = fseek ( file, entryHeader.mCommentLength + entryHeader.mExtraFieldLength, SEEK_CUR );
if ( result ) goto error;
this->AddEntry ( &entryHeader, nameBuffer );
}
goto finish;
error:
result = -1;
finish:
if ( nameBuffer ) {
free ( nameBuffer );
}
if ( file ) {
fclose ( file );
}
return result;
}
//----------------------------------------------------------------//
ZLZipArchive::ZLZipArchive () :
mRoot ( 0 ) {
}
//----------------------------------------------------------------//
ZLZipArchive::~ZLZipArchive () {
if ( this->mRoot ) {
delete this->mRoot;
}
}
| [
"[email protected]"
] | |
b762929e1a6984b6961101c566b800eb9a09025b | 6b40e9dccf2edc767c44df3acd9b626fcd586b4d | /NT/printscan/print/spooler/localspl/ssp.hxx | e8468cae9460cef237e45a629f8e627124cb17d8 | [] | 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 | 2,652 | hxx | /*++
Copyright (c) 2001 Microsoft Corporation
All rights reserved
Module Name:
ssp.hxx
Abstract:
This file wraps around wintrust functions.
Author:
Larry Zhu (LZhu) 6-Apr-2001
Environment:
User Mode -Win32
Revision History:
--*/
#ifndef _SSP_HXX_
#define _SSP_HXX_
#ifdef __cplusplus
#include <mscat.h>
#include <softpub.h>
class TSSP
{
SIGNATURE('sspp'); // Security Service Provider for Printers
public:
TSSP(
VOID
);
~TSSP(
VOID
);
HRESULT
IsValid(
VOID
) const;
HRESULT
AddCatalogDirect(
IN PCWSTR pszCatalogFullPath,
IN PCWSTR pszCatNameOnSystem OPTIONAL
);
HRESULT
VerifyCatalog(
IN PCWSTR pszCatalogFullPath
);
private:
typedef BOOL
(* PFuncCryptCATAdminAcquireContext)(
OUT HCATADMIN *phCatAdmin,
IN const GUID *pgSubsystem,
IN DWORD dwFlags
);
typedef HCATINFO
(* PFuncCryptCATAdminAddCatalog)(
IN HCATADMIN hCatAdmin,
IN WCHAR *pwszCatalogFile,
IN WCHAR *pwszSelectBaseName, OPTIONAL
IN DWORD dwFlags
);
typedef BOOL
(* PFuncCryptCATAdminReleaseCatalogContext)(
IN HCATADMIN hCatAdmin,
IN HCATINFO hCatInfo,
IN DWORD dwFlags
);
typedef BOOL
(* PFuncCryptCATAdminReleaseContext)(
IN HCATADMIN hCatAdmin,
IN DWORD dwFlags
);
typedef HRESULT
(* PFuncWinVerifyTrust)(
IN HWND hWnd,
IN GUID *pgActionID,
IN WINTRUST_DATA *pWinTrustData
);
//
// Copying and assignment are not defined.
//
TSSP(const TSSP & rhs);
TSSP& operator =(const TSSP & rhs);
HRESULT
Initialize(
VOID
);
HMODULE m_hLibrary;
PFuncCryptCATAdminAcquireContext m_pfnCryptCATAdminAcquireContext;
PFuncCryptCATAdminAddCatalog m_pfnCryptCATAdminAddCatalog;
PFuncCryptCATAdminReleaseCatalogContext m_pfnCryptCATAdminReleaseCatalogContext;
PFuncCryptCATAdminReleaseContext m_pfnCryptCATAdminReleaseContext;
PFuncWinVerifyTrust m_pfnWinVerifyTrust;
HRESULT m_hr;
};
#endif // #ifdef __cplusplus
#endif // #ifndef _SSP_HXX_
| [
"[email protected]"
] | |
9b8c6c6a21a2ac7179a4ed3fb1b80358b101fd24 | 8c8a8af67076b2b7ac9808d614be8e40728d7854 | /jni/Debug/Debug.cpp | b086d54eb47c72abba312723568d8bfd02770e47 | [] | no_license | MihaiBabiac/Framework | 694d5185c6a394c0a453f9812db327550612eb67 | ad97160286a7fb69d9f3667e2ed736c0a2a0dbfe | refs/heads/master | 2021-05-28T10:14:12.218635 | 2013-07-25T09:51:31 | 2013-07-25T09:51:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,252 | cpp | #include "Debug.hpp"
#include "TextureMappedFont.hpp"
#include "Types.hpp"
#include "Log.hpp"
namespace Debug
{
const int DEBUGMESSAGEBUFFER_SIZE = 1024;
int printLines;
int circlePoints = 30;
float printFontSize = 40.0f;
float layer = 805.0f;
void InitFrame()
{
printLines=0;
}
void Print(TextureMappedFont *font, const char *message, ...)
{
char buffer[DEBUGMESSAGEBUFFER_SIZE];
memset(buffer,NULL,DEBUGMESSAGEBUFFER_SIZE);
va_list args;
va_start(args,message);
vsprintf(buffer,message,args);
va_end(args);
GLfloat currentFontSize=font->GetFontSize();
font->SetFontSize(printFontSize);
font->SendString(string(buffer),5.0f,5.0f+printLines*printFontSize);
font->SetFontSize(currentFontSize);
++printLines;
}
void AssertGL(const char *pMessage)
{
GLint error = glGetError();
if(error)
{
LOGE(pMessage);
if(error == GL_INVALID_ENUM)
{
LOGE("EGL Error: Invalid enum");
}
else if(error == GL_INVALID_VALUE)
{
LOGE("EGL Error: Invalid value");
}
else if(error == GL_INVALID_OPERATION)
{
LOGE("EGL Error: Invalid operation");
}
else
{
LOGE("EGL Error: Out of memory");
}
}
}
}
| [
"[email protected]"
] | |
6ff17004f0e2a223131f90e6da6380934dbbc986 | 5e8d200078e64b97e3bbd1e61f83cb5bae99ab6e | /main/source/src/ObjexxFCL/FArray5A.hh | 71b6888eae2795f1f433c88b58f80f36660a760f | [] | no_license | MedicaicloudLink/Rosetta | 3ee2d79d48b31bd8ca898036ad32fe910c9a7a28 | 01affdf77abb773ed375b83cdbbf58439edd8719 | refs/heads/master | 2020-12-07T17:52:01.350906 | 2020-01-10T08:24:09 | 2020-01-10T08:24:09 | 232,757,729 | 2 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 23,500 | hh | #ifndef INCLUDED_ObjexxFCL_FArray5A_hh
#define INCLUDED_ObjexxFCL_FArray5A_hh
// FArray5A: Fortran-Compatible 5D Argument Array
//
// Project: Objexx Fortran Compatibility Library (ObjexxFCL)
//
// Version: 3.0.0
//
// Language: C++
//
// Copyright (c) 2000-2009 Objexx Engineering, Inc. All Rights Reserved.
// Use of this source code or any derivative of it is restricted by license.
// Licensing is available from Objexx Engineering, Inc.: http://objexx.com [email protected]
// ObjexxFCL Headers
#include <ObjexxFCL/FArray5A.fwd.hh>
#include <ObjexxFCL/FArray5P.hh>
#include <ObjexxFCL/StaticIndexRange.hh>
namespace ObjexxFCL {
/// @brief FArray5A: Fortran-Compatible 5D Argument Array
template< typename T >
class FArray5A :
public FArray5< T >
{
private: // Types
typedef FArray5< T > Super;
typedef typename Super::real_FArray real_FArray;
typedef typename Super::proxy_FArray proxy_FArray;
typedef typename Super::arg_FArray arg_FArray;
typedef internal::ProxySentinel ProxySentinel;
public: // Types
typedef typename Super::Base Base;
typedef typename Base::Section Section;
typedef typename Super::IR SIR;
typedef StaticIndexRange IR;
// STL Style
typedef typename Base::value_type value_type;
typedef typename Base::reference reference;
typedef typename Base::const_reference const_reference;
typedef typename Base::pointer pointer;
typedef typename Base::const_pointer const_pointer;
typedef typename Base::size_type size_type;
typedef typename Base::difference_type difference_type;
// C++ Style
typedef typename Base::Value Value;
typedef typename Base::Reference Reference;
typedef typename Base::ConstReference ConstReference;
typedef typename Base::Pointer Pointer;
typedef typename Base::ConstPointer ConstPointer;
typedef typename Base::Size Size;
typedef typename Base::Difference Difference;
using Super::array_;
using Super::array_size_;
#ifdef OBJEXXFCL_PROXY_CONST_CHECKS
using Super::not_const_proxy;
#endif // OBJEXXFCL_PROXY_CONST_CHECKS
using Super::npos;
using Super::sarray_;
using Super::shift_;
using Super::shift_set;
using Super::size_set;
using Super::s1_;
using Super::s2_;
using Super::s3_;
using Super::s4_;
public: // Creation
/// @brief Default Constructor
inline
FArray5A() :
Super( ProxySentinel() )
{}
/// @brief Copy Constructor
inline
FArray5A( FArray5A const & a ) :
Super( a, ProxySentinel() ),
I1_( a.I1_ ),
I2_( a.I2_ ),
I3_( a.I3_ ),
I4_( a.I4_ ),
I5_( a.I5_ )
{
shift_set( a.shift_ );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
}
/// @brief Non-Const Copy Constructor
inline
FArray5A( FArray5A & a ) :
Super( a, ProxySentinel() ),
I1_( a.I1_ ),
I2_( a.I2_ ),
I3_( a.I3_ ),
I4_( a.I4_ ),
I5_( a.I5_ )
{
shift_set( a.shift_ );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
}
/// @brief Real Constructor
inline
FArray5A( real_FArray const & a ) :
Super( a, ProxySentinel() ),
I1_( a.I1_ ),
I2_( a.I2_ ),
I3_( a.I3_ ),
I4_( a.I4_ ),
I5_( a.I5_ )
{
shift_set( a.shift_ );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
}
/// @brief Non-Const Real Constructor
inline
FArray5A( real_FArray & a ) :
Super( a, ProxySentinel() ),
I1_( a.I1_ ),
I2_( a.I2_ ),
I3_( a.I3_ ),
I4_( a.I4_ ),
I5_( a.I5_ )
{
shift_set( a.shift_ );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
}
/// @brief Proxy Constructor
inline
FArray5A( proxy_FArray const & a ) :
Super( a, ProxySentinel() ),
I1_( a.I1_ ),
I2_( a.I2_ ),
I3_( a.I3_ ),
I4_( a.I4_ ),
I5_( a.I5_ )
{
shift_set( a.shift_ );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
}
/// @brief Non-Const Proxy Constructor
inline
FArray5A( proxy_FArray & a ) :
Super( a, ProxySentinel() ),
I1_( a.I1_ ),
I2_( a.I2_ ),
I3_( a.I3_ ),
I4_( a.I4_ ),
I5_( a.I5_ )
{
shift_set( a.shift_ );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
}
/// @brief Super Constructor
inline
FArray5A( Super const & a ) :
Super( a, ProxySentinel() ),
I1_( a.I1() ),
I2_( a.I2() ),
I3_( a.I3() ),
I4_( a.I4() ),
I5_( a.I5() )
{
shift_set( a.shift_ );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
}
/// @brief Non-Const Super Constructor
inline
FArray5A( Super & a ) :
Super( a, ProxySentinel() ),
I1_( a.I1() ),
I2_( a.I2() ),
I3_( a.I3() ),
I4_( a.I4() ),
I5_( a.I5() )
{
shift_set( a.shift_ );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
}
/// @brief Base Constructor
inline
FArray5A( Base const & a ) :
Super( a, ProxySentinel() ),
I1_( 1 ),
I2_( 1 ),
I3_( 1 ),
I4_( 1 ),
I5_( a.size() )
{
shift_set( 5 );
s1_ = s2_ = s3_ = s4_ = 1;
}
/// @brief Non-Const Base Constructor
inline
FArray5A( Base & a ) :
Super( a, ProxySentinel() ),
I1_( 1 ),
I2_( 1 ),
I3_( 1 ),
I4_( 1 ),
I5_( a.size() )
{
shift_set( 5 );
s1_ = s2_ = s3_ = s4_ = 1;
}
/// @brief Section Constructor
inline
FArray5A( Section const & s ) :
Super( s, ProxySentinel() ),
I1_( 1 ),
I2_( 1 ),
I3_( 1 ),
I4_( 1 ),
I5_( s.size() )
{
shift_set( 5 );
s1_ = s2_ = s3_ = s4_ = 1;
}
/// @brief Non-Const Section Constructor
inline
FArray5A( Section & s ) :
Super( s, ProxySentinel() ),
I1_( 1 ),
I2_( 1 ),
I3_( 1 ),
I4_( 1 ),
I5_( s.size() )
{
shift_set( 5 );
s1_ = s2_ = s3_ = s4_ = 1;
}
/// @brief Value Constructor
inline
FArray5A( T const & t ) :
Super( t, ProxySentinel() ),
I1_( 1 ),
I2_( 1 ),
I3_( 1 ),
I4_( 1 ),
I5_( star ) // Unbounded
{
shift_set( 5 );
s1_ = s2_ = s3_ = s4_ = 1;
}
/// @brief Non-Const Value Constructor
inline
FArray5A( T & t ) :
Super( t, ProxySentinel() ),
I1_( 1 ),
I2_( 1 ),
I3_( 1 ),
I4_( 1 ),
I5_( star ) // Unbounded
{
shift_set( 5 );
s1_ = s2_ = s3_ = s4_ = 1;
}
/// @brief Copy + IndexRange Constructor
inline
FArray5A( FArray5A const & a, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( a, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Non-Const Copy + IndexRange Constructor
inline
FArray5A( FArray5A & a, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( a, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Real + IndexRange Constructor
inline
FArray5A( real_FArray const & a, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( a, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Non-Const Real + IndexRange Constructor
inline
FArray5A( real_FArray & a, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( a, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Proxy + IndexRange Constructor
inline
FArray5A( proxy_FArray const & a, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( a, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Non-Const Proxy + IndexRange Constructor
inline
FArray5A( proxy_FArray & a, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( a, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Super + IndexRange Constructor
inline
FArray5A( Super const & a, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( a, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Non-Const Super + IndexRange Constructor
inline
FArray5A( Super & a, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( a, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Base + IndexRange Constructor
inline
FArray5A( Base const & a, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( a, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Non-Const Base + IndexRange Constructor
inline
FArray5A( Base & a, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( a, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Section + IndexRange Constructor
inline
FArray5A( Section const & s, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( s, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Non-Const Section + IndexRange Constructor
inline
FArray5A( Section & s, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( s, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Value + IndexRange Constructor
inline
FArray5A( T const & t, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( t, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Non-Const Value + IndexRange Constructor
inline
FArray5A( T & t, IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) :
Super( t, ProxySentinel() ),
I1_( I1_a ),
I2_( I2_a ),
I3_( I3_a ),
I4_( I4_a ),
I5_( I5_a )
{
dimension_argument();
}
/// @brief Destructor
inline
virtual
~FArray5A()
{}
public: // Assignment
/// @brief Copy Assignment
inline
FArray5A &
operator =( FArray5A const & a )
{
if ( this != &a ) {
if ( ! equal_dimension( a ) ) dimension( a );
Base::operator =( a );
}
return *this;
}
/// @brief Super Assignment
inline
FArray5A &
operator =( Super const & a )
{
if ( this != &a ) {
if ( ! equal_dimension( a ) ) dimension( a );
Base::operator =( a );
}
return *this;
}
/// @brief Super Assignment Template
template< typename U >
inline
FArray5A &
operator =( FArray5< U > const & a )
{
if ( ! equal_dimension( a ) ) dimension( a );
Base::operator =( a );
return *this;
}
/// @brief += Array Template
template< typename U >
inline
FArray5A &
operator +=( FArray5< U > const & a )
{
Super::operator +=( a );
return *this;
}
/// @brief -= Array Template
template< typename U >
inline
FArray5A &
operator -=( FArray5< U > const & a )
{
Super::operator -=( a );
return *this;
}
/// @brief = Value
inline
FArray5A &
operator =( T const & t )
{
Super::operator =( t );
return *this;
}
/// @brief += Value
inline
FArray5A &
operator +=( T const & t )
{
Super::operator +=( t );
return *this;
}
/// @brief -= Value
inline
FArray5A &
operator -=( T const & t )
{
Super::operator -=( t );
return *this;
}
/// @brief *= Value
inline
FArray5A &
operator *=( T const & t )
{
Super::operator *=( t );
return *this;
}
/// @brief /= Value
inline
FArray5A &
operator /=( T const & t )
{
Super::operator /=( t );
return *this;
}
public: // Subscript
/// @brief array( i1, i2, i3, i4, i5 ) const
inline
T const &
operator ()( int const i1, int const i2, int const i3, int const i4, int const i5 ) const
{
assert( ( I1_.contains( i1 ) ) && ( I2_.contains( i2 ) ) && ( I3_.contains( i3 ) ) && ( I4_.contains( i4 ) ) && ( I5_.contains( i5 ) ) );
return sarray_[ ( ( ( ( ( ( ( i5 * s4_ ) + i4 ) * s3_ ) + i3 ) * s2_ ) + i2 ) * s1_ ) + i1 ];
}
/// @brief array( i1, i2, i3, i4, i5 )
inline
T &
operator ()( int const i1, int const i2, int const i3, int const i4, int const i5 )
{
proxy_const_assert( not_const_proxy() );
assert( ( I1_.contains( i1 ) ) && ( I2_.contains( i2 ) ) && ( I3_.contains( i3 ) ) && ( I4_.contains( i4 ) ) && ( I5_.contains( i5 ) ) );
return sarray_[ ( ( ( ( ( ( ( i5 * s4_ ) + i4 ) * s3_ ) + i3 ) * s2_ ) + i2 ) * s1_ ) + i1 ];
}
/// @brief Section Starting at array( i1, i2, i3, i4, i5 )
inline
Section const
a( int const i1, int const i2, int const i3, int const i4, int const i5 ) const
{
assert( ( I1_.contains( i1 ) ) && ( I2_.contains( i2 ) ) && ( I3_.contains( i3 ) ) && ( I4_.contains( i4 ) ) && ( I5_.contains( i5 ) ) );
size_type const offset( ( ( ( ( ( ( ( ( i5 * s4_ ) + i4 ) * s3_ ) + i3 ) * s2_ ) + i2 ) * s1_ ) + i1 ) - shift_ );
return Section( static_cast< T const * >( array_ + offset ), ( array_size_ != npos ) ? array_size_ - offset : npos );
}
/// @brief Non-Const Section Starting at array( i1, i2, i3, i4, i5 )
inline
Section
a( int const i1, int const i2, int const i3, int const i4, int const i5 )
{
proxy_const_assert( not_const_proxy() );
assert( ( I1_.contains( i1 ) ) && ( I2_.contains( i2 ) ) && ( I3_.contains( i3 ) ) && ( I4_.contains( i4 ) ) && ( I5_.contains( i5 ) ) );
size_type const offset( ( ( ( ( ( ( ( ( i5 * s4_ ) + i4 ) * s3_ ) + i3 ) * s2_ ) + i2 ) * s1_ ) + i1 ) - shift_ );
return Section( array_ + offset, ( array_size_ != npos ) ? array_size_ - offset : npos );
}
/// @brief Linear Index
inline
size_type
index( int const i1, int const i2, int const i3, int const i4, int const i5 ) const
{
return ( ( ( ( ( ( ( ( ( i5 * s4_ ) + i4 ) * s3_ ) + i3 ) * s2_ ) + i2 ) * s1_ ) + i1 ) - shift_ );
}
public: // Predicate
/// @brief Dimensions Initialized?
inline
bool
dimensions_initialized() const
{
return true;
}
/// @brief Contains Indexed Element?
inline
bool
contains( int const i1, int const i2, int const i3, int const i4, int const i5 ) const
{
return ( ( I1_.contains( i1 ) ) && ( I2_.contains( i2 ) ) && ( I3_.contains( i3 ) ) && ( I4_.contains( i4 ) ) && ( I5_.contains( i5 ) ) );
}
/// @brief Initializer Active?
inline
bool
initializer_active() const
{
return false;
}
public: // Inspector
/// @brief IndexRange of Dimension 1
inline
IR const &
I1() const
{
return I1_;
}
/// @brief Lower Index of Dimension 1
inline
int
l1() const
{
return I1_.l();
}
/// @brief Upper Index of Dimension 1
inline
int
u1() const
{
return I1_.u();
}
/// @brief IndexRange of Dimension 2
inline
IR const &
I2() const
{
return I2_;
}
/// @brief Lower Index of Dimension 2
inline
int
l2() const
{
return I2_.l();
}
/// @brief Upper Index of Dimension 2
inline
int
u2() const
{
return I2_.u();
}
/// @brief IndexRange of Dimension 3
inline
IR const &
I3() const
{
return I3_;
}
/// @brief Lower Index of Dimension 3
inline
int
l3() const
{
return I3_.l();
}
/// @brief Upper Index of Dimension 3
inline
int
u3() const
{
return I3_.u();
}
/// @brief IndexRange of Dimension 4
inline
IR const &
I4() const
{
return I4_;
}
/// @brief Lower Index of Dimension 4
inline
int
l4() const
{
return I4_.l();
}
/// @brief Upper Index of Dimension 4
inline
int
u4() const
{
return I4_.u();
}
/// @brief IndexRange of Dimension 5
inline
IR const &
I5() const
{
return I5_;
}
/// @brief Lower Index of Dimension 5
inline
int
l5() const
{
return I5_.l();
}
/// @brief Upper Index of Dimension 5
inline
int
u5() const
{
return I5_.u();
}
/// @brief Size of Dimension 5
inline
size_type
size5() const
{
return I5_.size();
}
public: // Modifier
/// @brief Clear
inline
FArray5A &
clear()
{
Super::clear();
I1_.clear();
I2_.clear();
I3_.clear();
I4_.clear();
I5_.clear();
return *this;
}
/// @brief Dimension by IndexRanges Even if Const
inline
FArray5A const &
dim( IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a ) const
{
const_cast< FArray5A & >( *this ).dimension( I1_a, I2_a, I3_a, I4_a, I5_a );
return *this;
}
/// @brief Dimension by Array Even if Const
template< typename U >
inline
FArray5A const &
dim( FArray5< U > const & a ) const
{
const_cast< FArray5A & >( *this ).dimension( a );
return *this;
}
/// @brief Dimension by IndexRange
inline
FArray5A &
dimension( IR const & I1_a, IR const & I2_a, IR const & I3_a, IR const & I4_a, IR const & I5_a )
{
I1_.assign_value_of( I1_a );
I2_.assign_value_of( I2_a );
I3_.assign_value_of( I3_a );
I4_.assign_value_of( I4_a );
I5_.assign_value_of( I5_a );
dimension_argument();
return *this;
}
/// @brief Dimension by Array
template< typename U >
inline
FArray5A &
dimension( FArray5< U > const & a )
{
I1_.assign_value_of( a.I1() );
I2_.assign_value_of( a.I2() );
I3_.assign_value_of( a.I3() );
I4_.assign_value_of( a.I4() );
I5_.assign_value_of( a.I5() );
dimension_argument();
return *this;
}
/// @brief Attach to Argument Array
inline
FArray5A &
attach( FArray5A const & a )
{
Base::attach( a );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
I1_.assign_value_of( a.I1_ );
I2_.assign_value_of( a.I2_ );
I3_.assign_value_of( a.I3_ );
I4_.assign_value_of( a.I4_ );
I5_.assign_value_of( a.I5_ );
return *this;
}
/// @brief Attach to Non-Const Argument Array
inline
FArray5A &
attach( FArray5A & a )
{
Base::attach( a );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
I1_.assign_value_of( a.I1_ );
I2_.assign_value_of( a.I2_ );
I3_.assign_value_of( a.I3_ );
I4_.assign_value_of( a.I4_ );
I5_.assign_value_of( a.I5_ );
return *this;
}
/// @brief Attach to Real Array
inline
FArray5A &
attach( real_FArray const & a )
{
Base::attach( a );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
I1_.assign_value_of( a.I1_ );
I2_.assign_value_of( a.I2_ );
I3_.assign_value_of( a.I3_ );
I4_.assign_value_of( a.I4_ );
I5_.assign_value_of( a.I5_ );
return *this;
}
/// @brief Attach to Non-Const Real Array
inline
FArray5A &
attach( real_FArray & a )
{
Base::attach( a );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
I1_.assign_value_of( a.I1_ );
I2_.assign_value_of( a.I2_ );
I3_.assign_value_of( a.I3_ );
I4_.assign_value_of( a.I4_ );
I5_.assign_value_of( a.I5_ );
return *this;
}
/// @brief Attach to Proxy Array
inline
FArray5A &
attach( proxy_FArray const & a )
{
Base::attach( a );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
I1_.assign_value_of( a.I1_ );
I2_.assign_value_of( a.I2_ );
I3_.assign_value_of( a.I3_ );
I4_.assign_value_of( a.I4_ );
I5_.assign_value_of( a.I5_ );
return *this;
}
/// @brief Attach to Non-Const Proxy Array
inline
FArray5A &
attach( proxy_FArray & a )
{
Base::attach( a );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
I1_.assign_value_of( a.I1_ );
I2_.assign_value_of( a.I2_ );
I3_.assign_value_of( a.I3_ );
I4_.assign_value_of( a.I4_ );
I5_.assign_value_of( a.I5_ );
return *this;
}
/// @brief Attach to Super Array
inline
FArray5A &
attach( Super const & a )
{
Base::attach( a );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
I1_.assign_value_of( a.I1() );
I2_.assign_value_of( a.I2() );
I3_.assign_value_of( a.I3() );
I4_.assign_value_of( a.I4() );
I5_.assign_value_of( a.I5() );
return *this;
}
/// @brief Attach to Non-Const Super Array
inline
FArray5A &
attach( Super & a )
{
Base::attach( a );
s1_ = a.s1_;
s2_ = a.s2_;
s3_ = a.s3_;
s4_ = a.s4_;
I1_.assign_value_of( a.I1() );
I2_.assign_value_of( a.I2() );
I3_.assign_value_of( a.I3() );
I4_.assign_value_of( a.I4() );
I5_.assign_value_of( a.I5() );
return *this;
}
/// @brief Attach to Base Array
inline
FArray5A &
attach( Base const & a )
{
Base::attach( a, 5 );
s1_ = s2_ = s3_ = s4_ = 1;
I1_ = 1;
I2_ = 1;
I3_ = 1;
I4_ = 1;
I5_ = a.size();
return *this;
}
/// @brief Attach to Non-Const Base Array
inline
FArray5A &
attach( Base & a )
{
Base::attach( a, 5 );
s1_ = s2_ = s3_ = s4_ = 1;
I1_ = 1;
I2_ = 1;
I3_ = 1;
I4_ = 1;
I5_ = a.size();
return *this;
}
/// @brief Attach to Section
inline
FArray5A &
attach( Section const & s )
{
Base::attach( s, 5 );
s1_ = s2_ = s3_ = s4_ = 1;
I1_ = 1;
I2_ = 1;
I3_ = 1;
I4_ = 1;
I5_ = s.size();
return *this;
}
/// @brief Attach to Non-Const Section
inline
FArray5A &
attach( Section & s )
{
Base::attach( s, 5 );
s1_ = s2_ = s3_ = s4_ = 1;
I1_ = 1;
I2_ = 1;
I3_ = 1;
I4_ = 1;
I5_ = s.size();
return *this;
}
/// @brief Attach to Value
inline
FArray5A &
attach( T const & t )
{
Base::attach( t, 5 );
s1_ = s2_ = s3_ = s4_ = 1;
I1_ = 1;
I2_ = 1;
I3_ = 1;
I4_ = 1;
I5_ = star; // Unbounded
return *this;
}
/// @brief Attach to Non-Const Value
inline
FArray5A &
attach( T & t )
{
Base::attach( t, 5 );
s1_ = s2_ = s3_ = s4_ = 1;
I1_ = 1;
I2_ = 1;
I3_ = 1;
I4_ = 1;
I5_ = star; // Unbounded
return *this;
}
/// @brief Detach from Source Array
inline
FArray5A &
detach()
{
Base::detach();
s1_ = s2_ = s3_ = s4_ = 0;
I1_.clear();
I2_.clear();
I3_.clear();
I4_.clear();
I5_.clear();
return *this;
}
protected: // Functions
/// @brief Dimension by IndexRanges
inline
void
dimension_assign( SIR const & I1_a, SIR const & I2_a, SIR const & I3_a, SIR const & I4_a, SIR const & I5_a )
{
I1_.assign_value_of( I1_a );
I2_.assign_value_of( I2_a );
I3_.assign_value_of( I3_a );
I4_.assign_value_of( I4_a );
I5_.assign_value_of( I5_a );
dimension_argument();
}
private: // Functions
/// @brief Dimension by Current IndexRanges
inline
void
dimension_argument()
{
assert( I1_.bounded_value() );
assert( I2_.bounded_value() );
assert( I3_.bounded_value() );
assert( I4_.bounded_value() );
s1_ = I1_.size();
s2_ = I2_.size();
s3_ = I3_.size();
s4_ = I4_.size();
if ( I5_.bounded_value() ) { // Bounded
size_set( this->size_of( s1_, s2_, s3_, s4_, I5_.size() ) );
} else if ( array_size_ != npos ) { // Unbounded with bounded data array
size_type const slice_size( this->size_of( s1_, s2_, s3_, s4_ ) );
if ( slice_size > 0 ) { // Infer upper index and size
I5_.u( I5_.lz() + ( array_size_ / slice_size ) - 1 );
size_set( this->size_of( slice_size, I5_.size() ) );
} else {
size_set( array_size_ );
}
} else { // Unbounded with unbounded data array
size_set( npos );
}
shift_set( ( ( ( ( ( ( ( I5_.lz() * s4_ ) + I4_.lz() ) * s3_ ) + I3_.lz() ) * s2_ ) + I2_.lz() ) * s1_ ) + I1_.lz() );
}
private: // Data
/// @brief Dimension 1 index range
IR I1_;
/// @brief Dimension 2 index range
IR I2_;
/// @brief Dimension 3 index range
IR I3_;
/// @brief Dimension 4 index range
IR I4_;
/// @brief Dimension 5 index range
IR I5_;
}; // FArray5A
} // namespace ObjexxFCL
#endif // INCLUDED_ObjexxFCL_FArray5A_HH
| [
"[email protected]"
] | |
092444a6339ba4ba6054c2d6428eb3c9e57bc930 | 90deb8f9d2fce25c6908a6cc91199dd8d9bbe999 | /libraries/EthernetWebServer_STM32/examples/WebClient/WebClient.ino | 494563b5dbc1ffe5ef2075367debd6e89d8310a6 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | gazza2577/arduino | b940b444038dec356b379e9f820109dfa603b062 | ab08c1c7933d3c9f795c2b2d378eab688c952b0f | refs/heads/master | 2023-02-06T00:59:02.959466 | 2020-12-26T15:30:48 | 2020-12-26T15:30:48 | 314,380,263 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,451 | ino | /****************************************************************************************************************************
WebClient.ino - Simple Arduino web server sample for ESP8266 AT-command shield
For STM32 with built-in Ethernet (Nucleo-144, DISCOVERY, etc) or W5x00/ENC28J60 Ethernet
EthernetWebServer_STM32 is a library for the STM32 run built-in Ethernet WebServer
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_STM32
Licensed under MIT license
Version: 1.0.6
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 26/02/2020 Initial coding for STM32 with built-in Ethernet (Nucleo-144, DISCOVERY, etc) and ENC28J60
1.0.1 K Hoang 28/02/2020 Add W5x00 Ethernet shields using Ethernet library
1.0.2 K Hoang 05/03/2020 Remove dependency on functional-vlpp
1.0.3 K Hoang 22/07/2020 Fix bug not closing client and releasing socket. Add features.
1.0.4 K Hoang 23/07/2020 Add support to all STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash.
1.0.5 K Hoang 16/09/2020 Add support to Ethernet2, Ethernet3, Ethernet Large for W5x00
Add support to new EthernetENC library for ENC28J60. Add debug feature.
1.0.6 K Hoang 24/09/2020 Add support to PROGMEM-related commands, such as sendContent_P() and send_P()
*****************************************************************************************************************************/
#include "defines.h"
char server[] = "arduino.cc";
// Initialize the Web client object
EthernetClient client;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial);
Serial.println("\nStart WebClient on " + String(BOARD_NAME) + ", using " + String(SHIELD_TYPE));
ET_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN);
ET_LOGWARN(F("Default SPI pinout:"));
ET_LOGWARN1(F("MOSI:"), MOSI);
ET_LOGWARN1(F("MISO:"), MISO);
ET_LOGWARN1(F("SCK:"), SCK);
ET_LOGWARN1(F("SS:"), SS);
ET_LOGWARN(F("========================="));
#if !(USE_BUILTIN_ETHERNET || USE_UIP_ETHERNET)
// For other boards, to change if necessary
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )
// Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries
Ethernet.init (USE_THIS_SS_PIN);
#elif USE_ETHERNET3
// Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
#ifndef ETHERNET3_MAX_SOCK_NUM
#define ETHERNET3_MAX_SOCK_NUM 4
#endif
Ethernet.setCsPin (USE_THIS_SS_PIN);
Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
#elif USE_CUSTOM_ETHERNET
// You have to add initialization for your Custom Ethernet here
// This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
//Ethernet.init(USE_THIS_SS_PIN);
#endif //( ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )
#endif
// start the ethernet connection and the server:
// Use DHCP dynamic IP and random mac
uint16_t index = millis() % NUMBER_OF_MAC;
// Use Static IP
//Ethernet.begin(mac[index], ip);
Ethernet.begin(mac[index]);
// you're connected now, so print out the data
Serial.print(F("You're connected to the network, IP = "));
Serial.println(Ethernet.localIP());
Serial.println();
Serial.println(F("Starting connection to server..."));
// if you get a connection, report back via serial
if (client.connect(server, 80))
{
Serial.println(F("Connected to server"));
// Make a HTTP request
client.println(F("GET /asciilogo.txt HTTP/1.1"));
client.println(F("Host: arduino.cc"));
client.println(F("Connection: close"));
client.println();
}
}
void printoutData(void)
{
// if there are incoming bytes available
// from the server, read them and print them
while (client.available())
{
char c = client.read();
Serial.write(c);
}
Serial.flush();
}
void loop()
{
printoutData();
// if the server's disconnected, stop the client
if (!client.connected())
{
Serial.println();
Serial.println(F("Disconnecting from server..."));
client.stop();
// do nothing forevermore
while (true);
}
}
| [
"[email protected]"
] | |
8310b09d8e20e08bc3864eeed9854c63046d842f | afcafa3c7a17028d1a57a81475aae377b35c813e | /HelloIntegrations/message.cpp | 1830888f35859d6bc1d7229128ce5cf743f54ddd | [] | no_license | mashafrancis/qt-applications | 0fa833e8818c79ef54771d59e8a5d184519424ed | e67e84eefe291238e6ef8cd88d6cde57b31399ec | refs/heads/master | 2020-06-27T22:12:53.660480 | 2019-08-15T11:45:31 | 2019-08-19T08:43:55 | 200,065,293 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 543 | cpp | #include "message.h"
#include <QDebug>
Message::Message(QObject *parent) :
QObject(parent),
m_counter(0),
m_message("Startup message")
{
}
void Message::doMessageChange()
{
setMessage("Hello Property World %1");
// ++m_counter;
// emit messageChanged(m_message.arg(m_counter));
}
void Message::setMessage(QString value) {
m_message = value.arg(++m_counter);
emit messageChanged();
}
int Message::sendMessageFromCpp(const QString value) {
qDebug() << "This is C++ speaking. I heard QML say:" << value;
return m_counter;
}
| [
"[email protected]"
] | |
2a222e62144a599a48c56f4ce6186c544f463365 | 24cd70e546fee0218c7597f1d864acab1c32c1c1 | /201816040329/Ex12_15/CommissionEmployee.h | efc433560bf47c2d18cdc6de8b76396b1d82451d | [] | no_license | 201816040329/Assignment_07 | c021fd04aa579090f5a7704be6c24f9261c9bc3f | 17f34b35625f8926b2ad0db496400edf5bf0a6f4 | refs/heads/master | 2020-11-24T12:33:48.901660 | 2019-12-15T09:09:51 | 2019-12-15T09:09:51 | 228,144,875 | 0 | 0 | null | 2019-12-15T07:20:06 | 2019-12-15T07:20:06 | null | UTF-8 | C++ | false | false | 483 | h | #ifndef COMMISSIONEMPLOYEE_H_INCLUDED
#define COMMISSIONEMPLOYEE_H_INCLUDED
#include<string>
#include"Employee.h"
using namespace std;
class CommissionEmployee
{
public:
CommissionEmployee(const string &, const string &, const string &,
double = 0.0, double = 0.0);
void setGsales(double);
double getGsales();
void setcomrate(double);
double getcomrate();
virtual void print();
virtual double earings();
private:
double sales;
double rate;
};
| [
"[email protected]"
] | |
ce68824da89978bf4c3878d0fcd14ba13772e1bf | cb954f4769f77ac4bb6ee0138aaa5ac7afaec743 | /savenotepadinidialog.cpp | 0f3cd96560d4024bddac78dfc88fca7a7c29330e | [
"Apache-2.0",
"LicenseRef-scancode-free-unknown"
] | permissive | graylira/PomodroidoLite | 261c192e26ec70cf83b9d31a7f717a35835102cf | 1e831199708888d037ac0652b645faeaca4e82c1 | refs/heads/master | 2020-04-16T17:50:40.555332 | 2019-01-21T07:46:16 | 2019-01-21T07:46:16 | 165,791,189 | 2 | 0 | Apache-2.0 | 2019-01-18T11:08:29 | 2019-01-15T05:32:46 | C++ | UTF-8 | C++ | false | false | 1,366 | cpp | #include <QFileInfo>
#include <QFile>
#include <QDir>
#include <QMessageBox>
#include <qDebug>
#include "savenotepadinidialog.h"
#include "ui_savenotepadinidialog.h"
#include "parameter_config.h"
SaveNotepadIniDialog::SaveNotepadIniDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SaveNotepadIniDialog)
{
ui->setupUi(this);
}
SaveNotepadIniDialog::~SaveNotepadIniDialog()
{
delete ui;
}
bool SaveNotepadIniDialog::addNameToTxtSlot()
{
QDir *dir = new QDir(Base_Path);
QStringList filter;
QList<QFileInfo> *fileInfo = new QList<QFileInfo>(dir->entryInfoList(filter));
if(ui->lineEdit_input->text()=="")
{
QMessageBox::information(this, QStringLiteral("提示!"), QStringLiteral("请输入日志名称!"));
return false;
}
m_strTxtName = ui->lineEdit_input->text()+".txt";
bool bRepeat = false;
for (int i = 0; i<fileInfo->count(); i++)
{
if (m_strTxtName == fileInfo->at(i).fileName())
bRepeat = true;
qDebug() << "已存入配置文件名:"+fileInfo->at(i).fileName();
}
if (!bRepeat)
accept();
else
QMessageBox::information(this, QStringLiteral("提示!"), QStringLiteral("日志名称重复!"));
delete fileInfo;
return true;
}
QString SaveNotepadIniDialog::GetIniName(void)const
{
return m_strTxtName;
}
| [
"[email protected]"
] | |
9f14ee4c822109f6d7505f271bc2d1f2750c3068 | b3565adcbc166444356692ddf781bd97d75087e4 | /raster/util/test/LoggingTest.cpp | 8e09aa9f0885c24beb1febd58011dfe926796213 | [
"Apache-2.0"
] | permissive | duzhanyuan/rddoc-framework | e3b2aa0435cacf66d2e9b81cbb008f99576055c9 | 47933d2599fa5f186113b7a755dde280807f5809 | refs/heads/master | 2021-01-20T08:40:14.880473 | 2017-08-25T02:26:38 | 2017-08-25T02:26:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 976 | cpp | /*
* Copyright (C) 2017, Yeolar
*/
#include "raster/util/Logging.h"
#include <gtest/gtest.h>
using namespace rdd;
using namespace rdd::logging;
TEST(RDDLog, log) {
RDDLOG(DEBUG) << "debug log default output to stderr";
RDDLOG(INFO) << "info log default output to stderr";
RDDLOG(WARN) << "warning log default output to stderr";
RDDLOG(ERROR) << "error log default output to stderr";
}
TEST(RDDLog, plog) {
int saved_errno = errno;
errno = EAGAIN;
RDDPLOG(WARN) << "EAGAIN warning log";
errno = saved_errno;
}
TEST(RDDLog, setLevel) {
Singleton<RDDLogger>::get()->setLevel(logging::LOG_INFO);
RDDLOG(DEBUG) << "debug log SHOULD NOT BE SEEN";
RDDLOG(INFO) << "info log available";
Singleton<RDDLogger>::get()->setLevel(logging::LOG_DEBUG);
RDDLOG(DEBUG) << "debug log available";
RDDLOG(INFO) << "info log available";
}
TEST(RDDLog, async) {
Singleton<RDDLogger>::get()->setLogFile("log.txt");
RDDLOG(INFO) << "async info log to file";
}
| [
"[email protected]"
] | |
6f45eeb03049d1796f7a1c96570299ba86f2c9dd | 83f5fe1ceffc775da59d905ebd9ee146ffc05f37 | /Getting started Practice Contest/CC_B_ISBOTH.cpp | df91ff2f0baf12ebd1ccec7ee575cef041e565fc | [] | no_license | AnandSinhaProjects/Learning_CP | 4da9cbc1d1cbcbf009902673b8c9eab0874cd695 | a648d3913cf7d9a9aad079206bd0756aa29e989c | refs/heads/main | 2023-07-02T02:29:06.862430 | 2021-08-10T10:52:23 | 2021-08-10T10:52:23 | 394,528,777 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 911 | cpp | /*
You're given a number N. If N is divisible by 5 or 11 but not both then print "ONE"(without quotes). If N is divisible by both 5 and 11 then print "BOTH"(without quotes). If N is not divisible by 5 or 11 then print "NONE"(without quotes).
Input:
First-line will contain the number N.
Output:
Print the answer in a newline.
Constraints
1≤N≤103
Sample Input 1:
50
Sample Output 1:
ONE
Sample Input 2:
110
Sample Output 2:
BOTH
Sample Input 2:
16
Sample Output 2:
NONE
EXPLANATION:
In the first example, 50 is divisible by 5, but not 11.
In the second example, 110 is divisible by both 5 and 11.
In the third example, 16 is not divisible by 5 or 11.
*/
#include <iostream>
using namespace std;
int main(){
int N;
cin>>N;
if(N%5 == 0 && N%11==0){
cout<<"BOTH";
}
else if (N%5 == 0 || N%11 == 0)
{
cout<<"ONE";
}
else
{
cout<<"NONE";
}
} | [
"[email protected]"
] | |
ccacaa9859bb77e8eee17ed77a1bd3abd7b91729 | c9e38d5cb8595d4afbb0ba002a44d61a9b6dc6d1 | /unboundedknapsack.cpp | a489b5e4eb00f04014a7a2cded07c74aa0825358 | [] | no_license | btrx/karung | d3c187b5b2eac3f70253482467a8af2a52a1ed26 | 9134a42cfc68c1577719fc935ca48b8677ca9149 | refs/heads/master | 2020-03-29T13:55:49.388872 | 2018-09-23T14:04:08 | 2018-09-23T14:04:08 | 149,989,396 | 0 | 2 | null | 2019-10-11T06:39:31 | 2018-09-23T13:58:33 | C++ | UTF-8 | C++ | false | false | 2,422 | cpp | #include<iostream>
using namespace std;
void instancesUsed(int items[],int weights[],int capacity,int size) {
int k = capacity;
int instances[size];
int i;
for(i=0;i<size;i++)
instances[i] = 0;
while(k >= 0) {
int x = items[k];
if(x == -1) break;
instances[x] += 1;
k -= weights[items[k]];
}
cout<<"\nBarang yang diambil : \n";
for(i=0;i<size;i++)
cout << "Barang dengan berat " << weights[i] << " diambil " << instances[i] << endl;
}
int findMaxValue(int weight[],int values[],int items[],int n,int capacity) {
int knapsack[capacity+1];
knapsack[0] = 0;
items[0] = -1;
int i,j;
for(j=1;j<=capacity;j++) {
items[j] = items[j-1];
int max = knapsack[j-1];
for(i=0;i<n;i++) {
int x = j-weight[i];
if(x >= 0 && (knapsack[x] + values[i]) > max) {
max = knapsack[x] + values[i];
items[j] = i;
}
knapsack[j] = max;
}
}
return knapsack[capacity];
}
// main
int main() {
int weight[10]; //Harus sama dengan values
int values[10]; //Harus sama dengan weight
int bnyk_barang;
int capacity = 100; // kapasitas knapsack
int size = sizeof(weight)/sizeof(weight[0]);
//Opsional untuk menentukan banyak barang
//Banyak barang harus sama dengan array-nya
cout << "Masukkan berapa banyaknya barang : ";
cin >> bnyk_barang;
//Eror Handle
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(bnyk_barang > size){
cout << endl << "Jenis barang terlalu banyak" << endl;
return 0;
}
if(bnyk_barang < size){
cout << endl << "Jenis barang terlalu sedikit" << endl;
return 0;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cout << endl << "Masukkan berat barang dan harganya" << endl;
for(int i=0; i < bnyk_barang; i++){
cout << "Berat barang ke " << i + 1 << " = "; cin >> weight[i];
cout << "Harganya = "; cin >> values[i];
cout << endl;
}
cout << size;
int items[capacity+1];
int val = findMaxValue(weight,values,items,size,capacity);
cout << endl << "Harga maksimum yang diperoleh : " << val << endl;
instancesUsed(items,weight,capacity,size);
cout << endl;
return 0;
}
| [
"[email protected]"
] | |
359378827a8897dbff33e5c8caad3d6edd9f9265 | 42385b77d4fbbb4db6f8cd5b15a5f2cc02ba0e3c | /signals/mainwindow.h | 9c26a5c3552dbd91c674036aa2893e9d28f5ba37 | [] | no_license | jom-everest/poisk_technical-test | e2f98b9b0e2a4ca5dfd3a5ad2627f4480bfc3b6b | b7a9624e7e623c28d5951b9a47a0b86934f3e150 | refs/heads/master | 2021-08-24T07:49:16.792118 | 2017-12-08T18:21:09 | 2017-12-08T18:21:09 | 112,857,094 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,653 | h | #ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "transferdataservice_as.h"
#include "discretservice.h"
#include "sensorsservice.h"
#include "analogsignalsservice.h"
#include <vector>
#include <QMainWindow>
#include <QBarCategoryAxis>
#include <QBarSeries>
#include <QBarSet>
#include <QChart>
#include <QLCDNumber>
#include <QLabel>
#include <QMainWindow>
#include <QProgressBar>
QT_CHARTS_USE_NAMESPACE
namespace Ui {
class MainWindow;
}
//-------------
struct IndicatorGroup_forDiscretSignals {
QLabel* label;
QLCDNumber* lcdNumber;
IndicatorGroup_forDiscretSignals(QLabel* l, QLCDNumber* n) : label(l), lcdNumber(n) {}
};
//---------------
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void updateSignalsView();
void updateDiscretSignalsView();
void updateSensorsAndAnalogSignalsView();
void initIndicators();
void mainControllerOnTimer();
void initChart();
void on_horizontalSlider_sliderMoved(int position);
void on_horizontalSlider_2_sliderMoved(int position);
private:
Ui::MainWindow *ui;
QBarSet *barSet;
QChart *chart;
QBarSeries *series;
QBarCategoryAxis *axis;
TransferDataService_AS transferService_AS;
TransferDataService_DS transferService_DS;
SensorsService sensorsService;
AnalogSignalsService analogSignalsService;
SensorsData sensorsData;
DiscretSignalsSet discretSignalsSet;
AnalogSignalsSet analogSignalsSet;
std::vector<IndicatorGroup_forDiscretSignals> listViewIndicators_forDiscretSignals;
};
#endif // MAINWINDOW_H
| [
"[email protected]"
] | |
37090e5a18afbf8e2c03215924283cac13e8206f | 6b7262b6c491226d728b83547bd8daff12069511 | /Minesweeper/Minesweeper/Source/Menu/Options.h | 31d2b20be1c210114d10f0bf950858c23294b779 | [] | no_license | nipplesticks/Minesweeper_B-Edition | 7df7e58459274211b2cf5f0da00cf6458e5815fe | 9454e857e05a753b9c20e99e1d8e4b42876bb8fd | refs/heads/master | 2020-03-29T06:18:10.047580 | 2020-02-05T13:55:18 | 2020-02-05T13:55:18 | 149,618,718 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 779 | h | #pragma once
#include "../GUI/Button.h"
#include <fstream>
class Options : public sf::Drawable
{
public:
struct Settings
{
int nrOfBombs = 33;
int gridX = 10;
int gridY = 10;
};
private:
Button m_removeBombs;
Button m_numberOfBombs;
Button m_addBombs;
Button m_removeGridX;
Button m_gridX;
Button m_addGridX;
Button m_removeGridY;
Button m_gridY;
Button m_addGridY;
Button m_back;
public:
static Settings s_currentSetting;
public:
Options();
//Returns if still in options menu;
bool MousePress(const sf::Vector2i & mp);
void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
private:
Button _getStandardTextButton() const;
Button _getStandardIncrementButton() const;
void _loadLastSetting();
void _saveLastSetting();
}; | [
"[email protected]"
] | |
144d563e6e69803fc32d9c4446a489d2814c951e | 5d83739af703fb400857cecc69aadaf02e07f8d1 | /Archive2/c0/dc607248c4a0a0/main.cpp | a5ef491e45d0be648aae20786474878cd6bb3a01 | [] | no_license | WhiZTiM/coliru | 3a6c4c0bdac566d1aa1c21818118ba70479b0f40 | 2c72c048846c082f943e6c7f9fa8d94aee76979f | refs/heads/master | 2021-01-01T05:10:33.812560 | 2015-08-24T19:09:22 | 2015-08-24T19:09:22 | 56,789,706 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 932 | cpp | #include <iostream>
#include <thread>
#include <chrono>
using namespace std;
void foo() {
cout << "Hello from foo()!" << endl;
}
struct timed_execution {
typedef void (*func_type)(void);
timed_execution(func_type func, const std::chrono::duration period)
: func_(func)
, period_(period)
, thread_(std::bind(this,timed_execution<func_type>::threadFunc))
{
}
private:
void threadFunc() {
while(true) {
std::this_thread::sleep_for(period_);
func_();
}
}
func_type func_;
const std::chrono::duration period_;
std::thread thread_;
};
int main() {
timed_execution t(foo,std::chrono::milliseconds(2000));
std::this_thread::sleep_for(std::chrono::seconds(60));
return 0;
}
| [
"francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df"
] | francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df |
74fa70767e0732bd65c9f7f9c9c69d5c5301a725 | cd470ad61c4dbbd37ff004785fd6d75980987fe9 | /Luogu/4213 【模板】杜教筛(Sum)/std.cpp | 76d9a68a3689c54bc440870181cf5d6c767b7263 | [] | no_license | AutumnKite/Codes | d67c3770687f3d68f17a06775c79285edc59a96d | 31b7fc457bf8858424172bc3580389badab62269 | refs/heads/master | 2023-02-17T21:33:04.604104 | 2023-02-17T05:38:57 | 2023-02-17T05:38:57 | 202,944,952 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,103 | cpp | #include <bits/stdc++.h>
const int N = 8000005;
namespace sub1 {
int cnt, prime[N];
bool vis[N];
int phi[N];
long long sum[N];
void init() {
vis[1] = true;
phi[1] = 1;
for (int i = 2; i < N; ++i) {
if (!vis[i]) {
prime[++cnt] = i;
phi[i] = i - 1;
}
for (int j = 1; j <= cnt && i * prime[j] < N; ++j) {
vis[i * prime[j]] = true;
if (i % prime[j] == 0) {
phi[i * prime[j]] = phi[i] * prime[j];
break;
} else {
phi[i * prime[j]] = phi[i] * (prime[j] - 1);
}
}
}
for (int i = 1; i < N; ++i) {
sum[i] = sum[i - 1] + phi[i];
}
}
std::unordered_map<unsigned, long long> S;
long long calc(unsigned n) {
if (n < N) {
return sum[n];
}
if (S.count(n)) {
return S[n];
}
long long res = 1ll * n * (n + 1) / 2;
for (unsigned l = 2, r; l <= n; l = r + 1) {
unsigned t = n / l;
r = n / t;
res -= (r - l + 1) * calc(t);
}
S[n] = res;
return res;
}
long long solve(unsigned n) {
return calc(n);
}
}
namespace sub2 {
int cnt, prime[N];
bool vis[N];
int mu[N];
int sum[N];
void init() {
vis[1] = true;
mu[1] = 1;
for (int i = 2; i < N; ++i) {
if (!vis[i]) {
prime[++cnt] = i;
mu[i] = -1;
}
for (int j = 1; j <= cnt && i * prime[j] < N; ++j) {
vis[i * prime[j]] = true;
if (i % prime[j] == 0) {
mu[i * prime[j]] = 0;
break;
} else {
mu[i * prime[j]] = -mu[i];
}
}
}
for (int i = 1; i < N; ++i) {
sum[i] = sum[i - 1] + mu[i];
}
}
std::unordered_map<unsigned, int> S;
int calc(unsigned n) {
if (n < N) {
return sum[n];
}
if (S.count(n)) {
return S[n];
}
int res = 1;
for (unsigned l = 2, r; l <= n; l = r + 1) {
unsigned t = n / l;
r = n / t;
res -= (int)(r - l + 1) * calc(t);
}
S[n] = res;
return res;
}
int solve(unsigned n) {
return calc(n);
}
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
sub1::init(), sub2::init();
int T = 1;
std::cin >> T;
while (T--) {
int n;
std::cin >> n;
std::cout << sub1::solve(n) << " " << sub2::solve(n) << "\n";
}
}
| [
"[email protected]"
] | |
f3e62a1a568c8a5195b8275713ff3f0745940c12 | 429194d2630db826e8497466a9a3196a1e0f25a6 | /insertionSort.cpp | 5ff69ef47f8c2f9fe9026972aa14468beb4399fb | [] | no_license | shivamparashar165/DSA | 8a887cfcb53ecb922b01e04792f87a466d42e94e | 30101dff9cb542ca719280a2bb927883fc16fc1c | refs/heads/main | 2023-07-15T04:44:54.420000 | 2021-08-31T04:47:11 | 2021-08-31T04:47:11 | 389,828,850 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 226 | cpp | void iSort(int arr[],int n){
for(int i=1;i<n;i++){
int key = arr[i];
int j=i-1;
while(j>=0 && arr[j]>key){
arr[j+1]=arr[j];
j--;
}
arr[j+1]=key;
}
}
| [
"[email protected]"
] | |
688fc232c28b2fd2ef0f1051b39458ed8da29f23 | 4cedfda65a73a2a98bfc49a2ce09bfec901cccc3 | /modules/vfs/native/include/vfs/job_response.h | 8b1f14cd122f6f984e434a1629e57da111c8897a | [
"MIT",
"Apache-2.0"
] | permissive | Tencent/Hippy | f71695fb4488ee3df273524593301d7c241e0177 | 8560a25750e40f8fb51a8abfa44aad0392ebb209 | refs/heads/main | 2023-09-03T22:24:38.429469 | 2023-09-01T04:16:16 | 2023-09-01T06:22:14 | 221,822,577 | 8,300 | 1,161 | Apache-2.0 | 2023-09-14T11:22:44 | 2019-11-15T01:55:31 | Java | UTF-8 | C++ | false | false | 2,035 | h | /*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2022 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <unordered_map>
#include "footstone/string_view.h"
namespace hippy {
inline namespace vfs {
class JobResponse {
public:
using string_view = footstone::string_view;
using bytes = std::string;
enum class RetCode { Success, Failed, DelegateError, UriError, SchemeError, SchemeNotRegister,
PathNotMatch, PathError, ResourceNotFound, Timeout };
JobResponse(RetCode code, const string_view& err_msg, std::unordered_map<std::string, std::string> meta, bytes&& content);
JobResponse(RetCode code);
JobResponse();
virtual ~JobResponse() = default;
inline auto GetRetCode() {
return code_;
}
inline void SetRetCode(RetCode code) {
code_ = code;
}
inline auto GetErrorMessage() {
return err_msg_;
}
inline void SetErrorMessage(const string_view& err_msg) {
err_msg_ = err_msg;
}
inline auto GetMeta() {
return meta_;
}
inline void SetMeta(std::unordered_map<std::string, std::string> meta) {
meta_ = meta;
}
inline auto& GetContent() {
return content_;
}
inline void SetContent(bytes&& content) {
content_ = std::move(content);
}
bytes ReleaseContent();
private:
RetCode code_;
string_view err_msg_;
std::unordered_map<std::string, std::string> meta_;
bytes content_;
};
}
}
| [
"[email protected]"
] | |
7d7cc1e6f66f050de95beb392408b6644d7d9aa2 | ef927955ec4904a79f11be34038af7f6f75bd31f | /grxsdk/inc/Gi/GiShellFaceIterator.h | 4dae9d361c207a26e276358c4628ead6aa2eb338 | [] | no_license | 15831944/arxloader | 610842b913b1fea16133564ff532a4207daf076a | b9d2888953b04ab53743ddae6751d871d2a23dae | refs/heads/master | 2023-04-13T14:54:28.462797 | 2021-04-27T12:37:05 | 2021-04-27T12:37:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,319 | h | ///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
// All rights reserved.
//
// This software and its documentation and related materials are owned by
// the Alliance. The software may only be incorporated into application
// programs owned by members of the Alliance, subject to a signed
// Membership Agreement and Supplemental Software License Agreement with the
// Alliance. The structure and organization of this software are the valuable
// trade secrets of the Alliance and its suppliers. The software is also
// protected by copyright law and international treaty provisions. Application
// programs incorporating this software must include the following statement
// with their copyright notices:
//
// This application incorporates Open Design Alliance software pursuant to a license
// agreement with Open Design Alliance.
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
// All rights reserved.
//
// By use of this software, its documentation or related materials, you
// acknowledge and accept the above terms.
///////////////////////////////////////////////////////////////////////////////
#ifndef __ODGISHELLFACEITERATOR__
#define __ODGISHELLFACEITERATOR__
#include "../TD_PackPush.h"
/** \details
<group OdGi_Classes>
*/
class OdGiShellFaceIterator
{
const OdGePoint3d* _points;
const OdInt32* _faceList;
public:
inline OdGiShellFaceIterator()
: _points(0)
, _faceList(0)
{
}
inline OdGiShellFaceIterator(const OdGePoint3d* points, const OdInt32* faceList)
{
set(points, faceList);
}
inline void set(const OdGePoint3d* points, const OdInt32* faceList)
{
_points = points;
_faceList = faceList;
}
inline const OdInt32* faceListPos() { return _faceList; }
inline const OdGePoint3d& operator *() const
{
return _points[*_faceList];
}
inline operator const OdGePoint3d*() const
{
return _points + (*_faceList);
}
inline const OdGePoint3d* operator ->() const
{
return _points + *_faceList;
}
inline OdGiShellFaceIterator& operator ++()
{
++_faceList;
return *this;
}
inline OdGiShellFaceIterator operator ++(int)
{
OdGiShellFaceIterator res(*this);
++_faceList;
return res;
}
inline OdGiShellFaceIterator& operator --()
{
--_faceList;
return *this;
}
inline OdGiShellFaceIterator operator --(int)
{
OdGiShellFaceIterator res(*this);
--_faceList;
return res;
}
inline OdGiShellFaceIterator& operator += (const int n)
{
_faceList+=n;
return *this;
}
inline OdGiShellFaceIterator& operator -= (const int n)
{
_faceList-=n;
return *this;
}
inline OdGiShellFaceIterator operator + (const int n) const
{
OdGiShellFaceIterator res(*this);
res+=n;
return res;
}
inline OdGiShellFaceIterator operator - (const int n) const
{
OdGiShellFaceIterator res(*this);
res-=n;
return res;
}
inline bool operator < (const OdGiShellFaceIterator& op) const
{
return _faceList < op._faceList;
}
inline bool operator < (const OdInt32* op) const
{
return _faceList < op;
}
};
#include "../TD_PackPop.h"
#endif // __ODGISHELLFACEITERATOR__
| [
"[email protected]"
] | |
22e5d18d375b795232ddb782eed4ead343d666a6 | c4d502f840a26dd6d8fd9d904ff0fd786711bc9a | /cplusplus_projects/logcppTest/logcppTest/stdafx.cpp | 8e4b901aaf883d0c26e5f027db921df65bafc4b5 | [] | no_license | qsunny/Project-C-CPlusPlus | 13de784c6294a39c61dfd81d4dd9b7c745780076 | 1e1bd69aa48709c653635f121fd3eeca986da846 | refs/heads/master | 2021-01-19T01:03:33.458743 | 2017-06-27T15:19:52 | 2017-06-27T15:19:52 | 11,971,544 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 262 | cpp | // stdafx.cpp : 只包括标准包含文件的源文件
// logcppTest.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中
// 引用任何所需的附加头文件,而不是在此文件中引用
| [
"[email protected]"
] | |
b5caf3c7e4c2c8e566b0d7b86a0adc2599c90f97 | 77a06177c4f272dba5796b6f784dac2dff4e5a68 | /src/qt/askpassphrasedialog.cpp | c5e4c0d61f941cf19951b88061d5c71cf0a0d8db | [
"MIT"
] | permissive | merge-swap/fornix-wallet | 2d45422646844ea6ded4de46075cccbaf6523274 | e208e49b53bc8de7c69b4b146e291e840a57df35 | refs/heads/master | 2020-04-18T10:19:40.529386 | 2019-01-25T03:08:15 | 2019-01-25T03:08:15 | 167,464,268 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,301 | cpp | // Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2017 The Fornix developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "askpassphrasedialog.h"
#include "ui_askpassphrasedialog.h"
#include "guiconstants.h"
#include "walletmodel.h"
#include "allocators.h"
#include <QKeyEvent>
#include <QMessageBox>
#include <QPushButton>
AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel* model) : QDialog(parent),
ui(new Ui::AskPassphraseDialog),
mode(mode),
model(model),
fCapsLock(false)
{
ui->setupUi(this);
ui->passEdit1->setMinimumSize(ui->passEdit1->sizeHint());
ui->passEdit2->setMinimumSize(ui->passEdit2->sizeHint());
ui->passEdit3->setMinimumSize(ui->passEdit3->sizeHint());
ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE);
// Setup Caps Lock detection.
ui->passEdit1->installEventFilter(this);
ui->passEdit2->installEventFilter(this);
ui->passEdit3->installEventFilter(this);
this->model = model;
switch (mode) {
case Encrypt: // Ask passphrase x2
ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>."));
ui->passLabel1->hide();
ui->passEdit1->hide();
setWindowTitle(tr("Encrypt wallet"));
break;
case UnlockAnonymize:
ui->anonymizationCheckBox->setChecked(true);
ui->anonymizationCheckBox->show();
case Unlock: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Unlock wallet"));
break;
case Decrypt: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Decrypt wallet"));
break;
case ChangePass: // Ask old passphrase + new passphrase x2
setWindowTitle(tr("Change passphrase"));
ui->warningLabel->setText(tr("Enter the old and new passphrase to the wallet."));
break;
}
ui->anonymizationCheckBox->setChecked(model->isAnonymizeOnlyUnlocked());
textChanged();
connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
}
AskPassphraseDialog::~AskPassphraseDialog()
{
// Attempt to overwrite text so that they do not linger around in memory
ui->passEdit1->setText(QString(" ").repeated(ui->passEdit1->text().size()));
ui->passEdit2->setText(QString(" ").repeated(ui->passEdit2->text().size()));
ui->passEdit3->setText(QString(" ").repeated(ui->passEdit3->text().size()));
delete ui;
}
void AskPassphraseDialog::accept()
{
SecureString oldpass, newpass1, newpass2;
if (!model)
return;
oldpass.reserve(MAX_PASSPHRASE_SIZE);
newpass1.reserve(MAX_PASSPHRASE_SIZE);
newpass2.reserve(MAX_PASSPHRASE_SIZE);
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
// Alternately, find a way to make this input mlock()'d to begin with.
oldpass.assign(ui->passEdit1->text().toStdString().c_str());
newpass1.assign(ui->passEdit2->text().toStdString().c_str());
newpass2.assign(ui->passEdit3->text().toStdString().c_str());
switch (mode) {
case Encrypt: {
if (newpass1.empty() || newpass2.empty()) {
// Cannot encrypt with empty passphrase
break;
}
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet encryption"),
tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR Fornix</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"),
QMessageBox::Yes | QMessageBox::Cancel,
QMessageBox::Cancel);
if (retval == QMessageBox::Yes) {
if (newpass1 == newpass2) {
if (model->setWalletEncrypted(true, newpass1)) {
QMessageBox::warning(this, tr("Wallet encrypted"),
"<qt>" +
tr("FORNIX will close now to finish the encryption process. "
"Remember that encrypting your wallet cannot fully protect "
"your Fornixs from being stolen by malware infecting your computer.") +
"<br><br><b>" +
tr("IMPORTANT: Any previous backups you have made of your wallet file "
"should be replaced with the newly generated, encrypted wallet file. "
"For security reasons, previous backups of the unencrypted wallet file "
"will become useless as soon as you start using the new, encrypted wallet.") +
"</b></qt>");
QApplication::quit();
} else {
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
}
QDialog::accept(); // Success
} else {
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match."));
}
} else {
QDialog::reject(); // Cancelled
}
} break;
case UnlockAnonymize:
case Unlock:
if (!model->setWalletLocked(false, oldpass, ui->anonymizationCheckBox->isChecked())) {
QMessageBox::critical(this, tr("Wallet unlock failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
} else {
QDialog::accept(); // Success
}
break;
case Decrypt:
if (!model->setWalletEncrypted(false, oldpass)) {
QMessageBox::critical(this, tr("Wallet decryption failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
} else {
QDialog::accept(); // Success
}
break;
case ChangePass:
if (newpass1 == newpass2) {
if (model->changePassphrase(oldpass, newpass1)) {
QMessageBox::information(this, tr("Wallet encrypted"),
tr("Wallet passphrase was successfully changed."));
QDialog::accept(); // Success
} else {
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
}
} else {
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match."));
}
break;
}
}
void AskPassphraseDialog::textChanged()
{
// Validate input, set Ok button to enabled when acceptable
bool acceptable = false;
switch (mode) {
case Encrypt: // New passphrase x2
acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
case UnlockAnonymize: // Old passphrase x1
case Unlock: // Old passphrase x1
case Decrypt:
acceptable = !ui->passEdit1->text().isEmpty();
break;
case ChangePass: // Old passphrase x1, new passphrase x2
acceptable = !ui->passEdit1->text().isEmpty() && !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
}
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);
}
bool AskPassphraseDialog::event(QEvent* event)
{
// Detect Caps Lock key press.
if (event->type() == QEvent::KeyPress) {
QKeyEvent* ke = static_cast<QKeyEvent*>(event);
if (ke->key() == Qt::Key_CapsLock) {
fCapsLock = !fCapsLock;
}
if (fCapsLock) {
ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!"));
} else {
ui->capsLabel->clear();
}
}
return QWidget::event(event);
}
bool AskPassphraseDialog::eventFilter(QObject* object, QEvent* event)
{
/* Detect Caps Lock.
* There is no good OS-independent way to check a key state in Qt, but we
* can detect Caps Lock by checking for the following condition:
* Shift key is down and the result is a lower case character, or
* Shift key is not down and the result is an upper case character.
*/
if (event->type() == QEvent::KeyPress) {
QKeyEvent* ke = static_cast<QKeyEvent*>(event);
QString str = ke->text();
if (str.length() != 0) {
const QChar* psz = str.unicode();
bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
if ((fShift && *psz >= 'a' && *psz <= 'z') || (!fShift && *psz >= 'A' && *psz <= 'Z')) {
fCapsLock = true;
ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!"));
} else if (psz->isLetter()) {
fCapsLock = false;
ui->capsLabel->clear();
}
}
}
return QDialog::eventFilter(object, event);
}
| [
"[email protected]"
] | |
00674a376457b9767ba1a22cb90478459cefa299 | 6724a8351ccb974c4ee1fef0e458c401a8c96daa | /VirtualCreatures/Volumetric_SDL/Source/Renderer/Sprite.h | 5bf86772b29ef203873f9c48fe4d3d59a03905c1 | [
"Zlib"
] | permissive | fernicar/EvolvedVirtualCreaturesRepo | 73985b000a23b5e18f1909341abd08632e919488 | 4efaba960c7c56a08faaaeb1f3cae91a9ef1e54e | refs/heads/master | 2021-01-11T22:44:36.944115 | 2017-01-15T13:26:53 | 2017-01-15T13:26:53 | 79,027,931 | 0 | 0 | null | 2017-01-15T11:15:59 | 2017-01-15T11:15:59 | null | UTF-8 | C++ | false | false | 757 | h | #pragma once
#include <Scene/SceneObject.h>
#include <AssetManager/Asset_Texture.h>
class Sprite
{
private:
Asset_Texture* m_pSpriteSheet;
float m_halfWidth, m_halfHeight;
float m_texCoordTileWidth, m_texCoordTileHeight;
int m_numSpritesInX;
int m_numSprites;
float m_time;
float m_spriteFrameTimeInterval;
float m_animationLength;
public:
float m_scale;
Sprite();
void Create(Asset_Texture* pSpriteSheet, float spriteWidth, int numSpritesInX, int numSpritesInY, int numSprites);
void SetSpriteFrameTimeInterval(float interval);
float GetSpriteFrameTimeInterval() const;
void SetTime(float time);
void IncTime(float time);
float GetTime() const;
void Render();
float GetHalfWidth() const;
float GetHalfHeight() const;
};
| [
"[email protected]"
] | |
1bf250bf01930ceffce0d43fd9da35cb7060c8c8 | 22c23e8f5722d781a5e4ba3b863361f90a6596ee | /aoj/itp1/11_b.cpp | 370dc1c1cab16f61406477b59f695dac2e434b9c | [] | no_license | mtannaan/atcoder | 254daf55ed3b59c9274f9ca744253f4ecc431f34 | f9f44a706029c64959bf0f3342f0c36bbdc46105 | refs/heads/master | 2021-01-14T19:16:14.430808 | 2020-03-15T15:32:42 | 2020-03-15T15:32:42 | 242,726,580 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,350 | cpp | // http://judge.u-aizu.ac.jp/onlinejudge/finder.jsp?course=ITP1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
template <typename T>
void read_vector(vector<T> &vec, int n)
{
for (int i = 0; i < n; i++)
{
cin >> vec[i];
}
}
int main()
{
vector<int> x(6);
read_vector(x, 6);
int right_dict[6][4] = {
{2, 3, 5, 4},
{6, 3, 1, 4},
{1, 2, 6, 5},
{1, 5, 6, 2},
{1, 3, 6, 4},
{2, 4, 5, 3},
};
int n_questions;
cin >> n_questions;
for (int i_q = 0; i_q < n_questions; i_q++)
{
int top, front;
cin >> top >> front;
std::vector<int>::iterator it_top = std::find(x.begin(), x.end(), top);
int i0_top = std::distance(x.begin(), it_top);
std::vector<int>::iterator it_front = std::find(x.begin(), x.end(), front);
int i0_front = std::distance(x.begin(), it_front);
int *loop = right_dict[i0_top];
int i1_right = 999;
for (int iright = 0; iright < 4; iright++)
{
if (loop[iright] == i0_front + 1)
{
i1_right = loop[(iright + 1) % 4];
break;
}
}
cout << x.at(i1_right - 1) << endl;
}
return 0;
}
| [
"[email protected]"
] | |
4640df98dd4eec1e22ef7b439a64602f3a7a1d60 | b28df7175c33099d7c4be7492d1db82f7f115e46 | /Tetris.cpp | 8fa2098bae73e6b2955cfc31f1bb05e8d3be222d | [] | no_license | Lazaraaus/Tetris | 579ec39aa8cd26ea02b95a82ba448e7727565820 | 3e07d6ee182ac2cfa2f9d3d12275851072fc056d | refs/heads/main | 2023-03-18T05:03:46.887852 | 2021-02-25T16:05:54 | 2021-02-25T16:05:54 | 342,300,518 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 23,225 | cpp | // Tetris.cpp : This file contains the 'main' function. Program execution begins and ends there.
//TO-DOs: Implement next piece
#include <iostream> //Standard Input / Output Stream Library
#include <thread> //Gives us access to the this_thread class
#include <Windows.h> //Gives us access to the screen object
#include <random> //Gives us access to the rand() function
#include <vector> //Gives us access to the vector container
using namespace std;
//////////////////////////////////////
// G L O B A L V A R I A B L E S //
//////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////
string tetromino[7]; //Array of wide strings for holding Tetromino pieces //
int nFieldWidth = 12; //Width of the game field (columns) //
int nFieldHeight = 18; //Height of the game field (rows) //
unsigned char *pField = nullptr; //Pointer to an unsigned char representing the playing field //
//
int nScreenWidth = 120; //Console Screen Size X (columns) //
int nScreenHeight = 30; //Console Screen Size Y (rows) //
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////
// S T A R T I N G P O I N T //
//////////////////////////////////////////
//
//
//A single dimensional array can be accessed like a multi-array if we arrange it as
//as an [n x m] array. Our tetromino arrays will be of length 16 [0, 1, 2,...., 15]
//so we can arrange it as [4 x 4] multi-array like such:
//
// Standard Rotation
// px = 0 1 2 3
//
// py = 0 0 1 2 3
//
// 1 4 5 6 7
//
// 2 8 9 10 11
//
// 3 12 13 14 15
//
//If we went to access a specific index we can use the formula index = py * 4 + px.
//
//For example in the standard rotation (r = 4), where px = 1 and py = 1
//the function will return py * 4 + px. So the index at (1, 1) -> 1 * 4 + 1 = 5.
//
//What if we need to rotate the array containing our Tetris block aka rotate the Tetromino?
//We rotate the Tetromino array representation and find an indexing formula for that representation.
//
// 90 Degree Rotation
// px = 0 1 2 3
//
// py = 0 12 8 4 0
//
// 1 13 9 5 1
//
// 2 14 10 6 2
//
// 3 15 11 7 3
//
//The formula for indexing is now i = 12 + py - (px * 4)
//
//Formula for 180 degrees: 15 - (py * 4) - px;
//
//Formula for 270 degrees: 3 - py + (px * 4);
//
//This becomes our base point for how we draw and manipulate our Tetromino blocks. We also use the
//general formula position.y * columnWidth + position.x as a way to index into our pField array
//(containing the playing field) and our screen array (the entirety of the console screen).
//////////////////////////////////////
// H E L P E R F U N C T I O N S //
//////////////////////////////////////
//
//
//Function 'rotate' to specify rotation of Tetromino pieces. It takes three params:
//x coordinate, y coordinate, and a value specifying its rotation.
//
//Returns (as an int) the index into the Tetromino array dependent on it's rotation
//and the x and y coordinates. It uses the remainder function '%' to determine
//the rotation value from parameter 'r'.
//
int rotate(int px, int py, int r)
{
switch (r % 4)
{
case 0: return py * 4 + px; // 0 degrees
case 1: return 12 + py - (px * 4); // 90 degrees
case 2: return 15 - (py * 4) - px; // 180 degrees
case 3: return 3 - py + (px * 4); // 270 degrees
}
return 0;
}
//
//
//Function 'doesFit' checks whether a specific Tetromino can fit in a
//specific position. It takes four params:
//nTetromino - an int representing the Tetromino block
//nRotation - an int representing the rotation
//nPosx and nPosy - two ints representing its position within the pField
//
//Returns TRUE if Tetromino piece array can fit at the desired coordinates
//with the desired rotation. Returns FALSE otherwise.
bool doesFit(int nTetromino, int nRotation, int nPosX, int nPosY) {
//iterate through our tetromino array
for (int px = 0; px < 4; px++)
for (int py = 0; py < 4; py++) {
//Get index into tetromino piece array
int pi = rotate(px, py, nRotation);
//get index into pField array
int fi = (nPosY + py) * nFieldWidth + (nPosX + px);
//Check to make sure we're not out of bounds on the X-axis
if (nPosX + px >= 0 && nPosX + px < nFieldWidth)
{
//Check to make sure we're not out of bounds on the Y-axis
if (nPosY + py >= 0 && nPosY + py < nFieldHeight)
{
//If any part of the Tetromino array where we render a piece intersects
//with a portion of the pField that isn't empty, return FALSE.
if (tetromino[nTetromino][pi] == 'X' && pField[fi] != 0)
return false;
}
}
}
//Always return TRUE otherwise
return true;
}
int main()
{
////////////////////////////////////
// C R E A T E A S S E T S //
////////////////////////////////////
//
//
//Here we construct our '4 x 4' Tetromino arrays. We arrange the append
//statements as a series to represent graphically what the Tetromino should
//display as in the final product.
//We use the char '.' to denote a blank space in the Tetromino array and the
//char 'X' to denote where we should render part of the Tetromino block.
//
//We will use the rotation function to transform the placement of the
//'.' character and'X' character into a rotated block instead of creating
//four assets for each block.
//
// S T R A I G H T T E T R O M I N O
tetromino[0].append("..X.");
tetromino[0].append("..X.");
tetromino[0].append("..X.");
tetromino[0].append("..X.");
// R I G H T Z I G T E T R O M I N O
tetromino[1].append("..X.");
tetromino[1].append(".XX.");
tetromino[1].append(".X..");
tetromino[1].append("....");
// L E F T Z I G T E T R O M I N O
tetromino[2].append(".X..");
tetromino[2].append(".XX.");
tetromino[2].append("..X.");
tetromino[2].append("....");
// B L O C K T E T R O M I N O
tetromino[3].append("....");
tetromino[3].append(".XX.");
tetromino[3].append(".XX.");
tetromino[3].append("....");
// B I S E C T T E T R O M I N O
tetromino[4].append("..X.");
tetromino[4].append("..XX");
tetromino[4].append("..X.");
tetromino[4].append("....");
// L E F T H O O K T E T R O M I N O
tetromino[5].append("....");
tetromino[5].append(".XX.");
tetromino[5].append("..X.");
tetromino[5].append("..X.");
// R I G H T H O O K T E T R O M I N O
tetromino[6].append("....");
tetromino[6].append("..XX");
tetromino[6].append("..X.");
tetromino[6].append("..X.");
//
//
//
// After the append statements we have an array 'tetromino' of 7 elements and each element has it's own array of 16 elements.
//
// tetromino tetromino tetromino ,......, tetromino
// [0] [1] [2] ,......, [6]
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ,......, 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// [., ., X, ., ., ., X, ., ., ., X, ., ., ., X, .] [., ., X, ., ., X, X, ., X, ., , ., ., ., ., .] [., X, ., ., ., ., X, X, ., ., ., X, ., ., ., .] ,......, [., ., ., ., ., ., X, X, ., ., X, ., ., ., X, .]
//
//
//
//
//
//Create an array for the playing field and assign pField to point to it
pField = new unsigned char[nFieldWidth * nFieldHeight];
//Use a nested for loop to iterate through the X and Y axis
for (int x = 0; x < nFieldWidth; x++) {
for (int y = 0; y < nFieldHeight; y++) {
//Zero out game field and set value of boundaries of the field to 9 for rendering later
//We see the general formula for indexing through a multi-array: i = py * columnWidth + px.
pField[y * nFieldWidth + x] = (x == 0 || x == nFieldWidth - 1 || y == nFieldHeight - 1) ? 9 : 0;
}
}
//Create a pointer to an array for the screen
char* screen = new char[nScreenWidth * nScreenHeight];
//Fill 'screen' full of Blank Space
for (int i = 0; i < nScreenWidth * nScreenHeight; i++) {
screen[i] = ' ';
}
//Create a handle to the Console Buffer and set it as the Active Buffer.
HANDLE hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
SetConsoleActiveScreenBuffer(hConsole);
DWORD dwBytesWritten = 0;
//////////////////////////////////////////////////////////////////////
// G A M E S T A T E //
////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool bGameOver = false; //Variable tracking Game Status //
int nCurrentPiece = rand() % 7; //Variable tracking current piece in play //
int nNextPiece = rand() % 7; //Variable to track next piece to be played //
int nCurrentRotation{ 0 }; //Variable tracking current rotation of piece in play //
int nCurrentX{ nFieldWidth / 3 }; //Variable of starting X position (middle of game field) //
int nCurrentY{ 0 }; //Variable of starting Y position (top of game field) //
//
bool bKey[4]; //Array of Bool Variables for reading inputs //
bool bRotateHold = false; //Variable to check if rotate button is held down //
//
int nSpeed{ 20 }; //
int nSpeedCounter{ 0 }; //
bool bForceDown = false; //Variable to check forcing blocks down //
int nPieceCount{ 0 }; //Variable to track # of pieces for difficulty //
int nScore{ 0 }; //Variable to track Score //
//
vector<int> vLines; //Variable to store lines //
int nLines{ 0 }; //Variable to store number of lines made //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// G A M E L O O P //
////////////////////////////////////////////////////////////////////////////////
//
//
//Begin While Loop
while (!bGameOver) {
//
//
//
//
/////////////////////////////////////////////////////////////////////////////////
// G A M E T I M I N G //
/////////////////////////////////////////////////////////////////////////////////
//
this_thread::sleep_for(50ms); //Game Tick is 50ms
nSpeedCounter++; //Every Game Tick add 1 to our speed counter
bForceDown = (nSpeedCounter == nSpeed); //When speed counter = speed, set Force Block down to TRUE
//occurs once every second | 50ms * 20 = 1000ms.
//
/////////////////////////////////////////////////////////////////////////////////
// G A M E I N P U T //
/////////////////////////////////////////////////////////////////////////////////
//
//When GetAsyncKeyState of (right, left, down, or z) has it's highest order bit set
//(the key is down) set the corresponding index in the bKey array to true.
//If the highest order bit isn't set it sets the index to false
for (int k = 0; k < 4; k++) // R L D Z
bKey[k] = (0x8000 & GetAsyncKeyState((unsigned char)("\x27\x25\x28Z"[k]))) != 0;
/////////////////////////////////////////////////////////////////////////////////
// G A M E L O G I C //
/////////////////////////////////////////////////////////////////////////////////
//
//
// P L A Y E R M O V E M E N T
//Uses the conditional operator '?:' and helper function 'doesFit' to change the position or rotation of the tetromino block
//
//
//
nCurrentX += (bKey[0] && doesFit(nCurrentPiece, nCurrentRotation, nCurrentX + 1, nCurrentY)) ? 1 : 0; //Moves Tetromino Block to the right (add 1 to it's current x position) if it fits
nCurrentX -= (bKey[1] && doesFit(nCurrentPiece, nCurrentRotation, nCurrentX - 1, nCurrentY)) ? 1 : 0; //Moves Tetromino Block to the left (subtract 1 from it's current x position) if it fits
nCurrentY += (bKey[2] && doesFit(nCurrentPiece, nCurrentRotation, nCurrentX, nCurrentY + 1)) ? 1 : 0; //Moves Tetromino Block down (add 1 to it's current x position) if it fits
if (bKey[3])
{
nCurrentRotation += (!bRotateHold && doesFit(nCurrentPiece, nCurrentRotation + 1, nCurrentX, nCurrentY)) ? 1 : 0; //Rotates Tetromino if it fits and button isn't held down
bRotateHold = true; //Sets hold condition to true
}
else {
bRotateHold = false; //Sets hold condition to false
}
//
//
//
// F A L L I N G B L O C K L O G I C
// Checks condidtion 'bForceDown' to see if 1 second has passed. If 1 second has passed, we start our falling block logic
//
if (bForceDown)
{
//Check to see if tetromino block can move down
if (doesFit(nCurrentPiece, nCurrentRotation, nCurrentX, nCurrentY + 1))
//If true, move block down (falling block)
nCurrentY++;
//If not possible then
else
{
//Lock the current piece to the field
//index through the tetromino array
for (int px = 0; px < 4; px++)
for (int py = 0; py < 4; py++)
//Check for 'X' characters in our tetromino array so we know where to draw our piece
if (tetromino[nCurrentPiece][rotate(px, py, nCurrentRotation)] == 'X')
//draw the current piece to the field, add 1 so we index into the 'render array' correctly
pField[(nCurrentY + py) * nFieldWidth + (nCurrentX + px)] = nCurrentPiece + 1;
//increment piece counter
//every 10 pieces, lower threshold for
//check to set bForceDown is TRUE (speedCounter = nSpeed);
nPieceCount++;
if (nPieceCount % 10 == 0)
if (nSpeed >= 10) nSpeed--;
//Check have we made any lines
for (int py = 0; py < 4; py++)
if (nCurrentY + py < nFieldHeight - 1)
{
//set bLine to true and iterate through x-axis
bool bLine = true;
for (int px = 1; px < nFieldWidth - 1; px++)
//if index isn't empty (!= 0) at any point, bLine remains true, so we have a line
//if any index is empty, we do not have a line and bLine is false
bLine &= (pField[(nCurrentY + py) * nFieldWidth + px]) != 0;
//When we have a line, iterate through x-axis
if (bLine)
{
//set x indices to '=' char
for (int px = 1; px < nFieldWidth - 1; px++)
pField[(nCurrentY + py) * nFieldWidth + px] = 8;
//add y index to our vLines container
vLines.push_back(nCurrentY + py);
nLines++;
}
}
//increment score by 25 for every placed piece.
//if vLines container isn't empty and nLines > 4 Adds 50 * nLines * 2 ^ vLines size
//otherwise Adds 100 * 2 ^ vLines size
//reward players for lasting longer and/or risky behavior
nScore += 25;
if (!vLines.empty()) nScore += (nLines > 4) ? (nLines << vLines.size()) * 50 : (1 << vLines.size()) * 100;
//Choose next piece
nCurrentX = nFieldWidth / 3;
nCurrentY = 0;
nCurrentRotation = 0;
nCurrentPiece = nNextPiece;
nNextPiece = rand() % 7;
//if piece does not fit at the top of screen, GAME OVER
bGameOver = !doesFit(nCurrentPiece, nCurrentRotation, nCurrentX, nCurrentY);
}
nSpeedCounter = 0; //Reset speed counter
}
// R E N D E R O U T P U T
//
//
//
//Draw Field
for (int x = 0; x < nFieldWidth; x++)
for (int y = 0; y < nFieldHeight; y++)
//render field to screen, pfield value is fed through a 'render array' to vary the representation of elements
//'A' for tetromino 1, 'B' for tetromino 2, etc, '#' for boundaries, and '=' for line erasure
screen[(y + 2) * nScreenWidth + (x + 2)] = " ABCDEFG=#"[pField[y * nFieldWidth + x]];
//Draw Current Piece
for (int px = 0; px < 4; px++)
for (int py = 0; py < 4; py++)
//Check if our Tetromino schema has an 'X' at these coordinates, if so
//we write the to the screen (we add 65 to maintain the rendering scheme used for the initial render above)
//0 + 65 = A, 1 + 65 = B, etc;
if (tetromino[nCurrentPiece][rotate(px, py, nCurrentRotation)] == 'X')
screen[(nCurrentY + py + 2) * nScreenWidth + (nCurrentX + px + 2)] = nCurrentPiece + 65;
//Draw SCORE, Lines
//
snprintf(&screen[2 * nScreenWidth + nFieldWidth + 6], 16, "SCORE: %8d", nScore);
snprintf(&screen[4 * nScreenWidth + nFieldWidth + 6], 16, "LINES: %8d", nLines);
//Implement visual for next piece
//Check if we have lines
if (!vLines.empty())
{
//Display Frame for Line erasure
WriteConsoleOutputCharacterA(hConsole, screen, nScreenWidth * nScreenHeight, { 0,0 }, &dwBytesWritten);
this_thread::sleep_for(300ms); //Delay a bit
//Loops backwards through vLines (y-indecies of lines)
//copys the values in the line above the line to be cleared, into the line that was cleared
//Zeroes out row;
//Clears vLines container to start anew
for (auto& v : vLines)
for (int px = 1; px < nFieldWidth - 1; px++)
{
for (int py = v; py > 0; py--)
pField[py * nFieldWidth + px] = pField[(py - 1) * nFieldWidth + px];
pField[px] = 0;
}
vLines.clear();
}
//Displays Frame
WriteConsoleOutputCharacterA(hConsole, screen, nScreenWidth * nScreenHeight, { 0,0 }, &dwBytesWritten);
}
//Game over
CloseHandle(hConsole);
cout << "Game Over!! Score: " << nScore << endl;
system("pause");
return 0;
}
| [
"[email protected]"
] | |
c1024d198d457201a8ffe0480b56a7ef7784a37b | d2f5e0b43885cd080a4c5026ce133e288482f8d0 | /UVA/UVA_1388/UVA_1388/Source.cpp | 5bc6f79cb34dbac957f522230d26d3f74923aca2 | [] | no_license | tito-kimbo/Online-Judge-Solutions | fb0ea2f2b9d8724a4b1f914a8be02294f1664135 | 1207e95365fb6f2691de077beaf2cbe7f0724c11 | refs/heads/master | 2020-06-03T04:18:32.970773 | 2019-06-11T19:12:52 | 2019-06-11T19:12:52 | 191,435,206 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 978 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
const double INF = 999999999999999999.0;
const double EPS = 0.00000001;
const double PI = 2 * acos(0.0);
const int LENGTH = 10000;
bool solve() {
int n, m;
cin >> n >> m;
if (!cin) return false;
vector<double> positions;
vector<double> newPositions;
double origDisp = 10000.0 / (double)n, disp = 10000.0 / (double)(m + n);
positions.push_back(0.0);
newPositions.push_back(0.0);
for (int i = 0; i < n-1; ++i) {
positions.push_back(positions[i] + origDisp);
}
for (int i = 0; i < m + n - 1; ++i) {
newPositions.push_back(newPositions[i] + disp);
}
double minimum = 0.0;
for (int i = 0; i < n; ++i) {
double aux = INF;
for (int j = 0; j < m + n; ++j) {
aux = min(aux, abs(positions[i] - newPositions[j]));
}
minimum += aux;
}
cout << fixed << setprecision(4) << minimum << '\n';
return true;
}
int main() {
while (solve());
} | [
"[email protected]"
] | |
bef5145a9e152b4032de8e14244ffd98a11be150 | c5b59c72501327dc6cc0a18ede99bbdac5330256 | /week4-02.cpp | 35037ec1f44bb482e38e4992f2cd3d0bf4b5d0db | [] | no_license | shubh1312/Principles-of-programming-language | 14e0c6d41fb35e41e2b297fb2ddb7ac59890f7f7 | d9842685b33f1f47fad961079204ac287143c82d | refs/heads/master | 2020-05-07T10:24:24.484611 | 2019-04-11T18:47:29 | 2019-04-11T18:47:29 | 180,416,891 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 864 | cpp | #include<iostream>
using namespace std;
int main()
{
int a[2][2],b[2][2],c[2][2],d[2][2];
cout<<"Enter elements of 2x2 A matrix:"<<endl;
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
cin>>a[i][j];
}
cout<<"Enter elements of 2x2 B matrix:"<<endl;
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
cin>>b[i][j];
}
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
c[i][j]=a[i][j]+b[i][j];
}
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
for(int k=0;k<2;k++)
d[i][j]=d[i][j]+a[i][k]*b[j][k];
}
}
cout<<"After addition matrix C is:"<<endl;
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
cout<<c[i][j]<<" ";
cout<<endl;
}
cout<<"After multiplication matrix D is:"<<endl;
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
cout<<d[i][j]<<" ";
cout<<endl;
}
return 0;
}
| [
"[email protected]"
] | |
54ebf9cf347877000afe9fd273fa864c3e585ee4 | a83378a11aa6b7f766374b50bd5082a2acb7ae54 | /IO/FileStream.cpp | 18c4f98362719982ed460cae06a7a523d39eed94 | [] | no_license | Spritutu/Common | 5e21579fa767621b6d3e487bdd9f12209d8f0948 | 311e512d896f563a9353c743bb0878dafcca1b5b | refs/heads/master | 2022-12-25T16:36:40.449491 | 2020-09-27T09:48:18 | 2020-09-27T09:50:10 | null | 0 | 0 | null | null | null | null | ISO-8859-3 | C++ | false | false | 41,700 | cpp | #include <IO\FileStream.h>
#include <IO\FileUtil.h>
#include <String/Convert.h>
#include <String/StringUtil.h>
#include <String/Path.h>
#if OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
#include <tal.h>
#pragma nowarn (262)
#endif
#if OPERATING_SYSTEM == OS_ANDROID
#include <Xtreme/Environment/AndroidMain.h>
#endif
#include <debug/debugclient.h>
#if OPERATING_SYSTEM == OS_WINDOWS
namespace
{
void MakeBackSlashes( GR::String& Path )
{
for ( size_t i = 0; i < Path.length(); ++i )
{
if ( Path[i] == '/' )
{
Path[i] = '\\';
}
}
}
void MakeBackSlashes( GR::WString& Path )
{
for ( size_t i = 0; i < Path.length(); ++i )
{
if ( Path[i] == L'/' )
{
Path[i] = L'\\';
}
}
}
GR::WString MakeSafeWinFilename( const GR::String& UTF8Filename )
{
GR::String pathToSet = UTF8Filename;
if ( Path::IsRelative( pathToSet ) )
{
// prepend full path
GR::String currentFolder = GR::IO::FileUtil::CurrentWorkingDirectory();
pathToSet = Path::Append( currentFolder, UTF8Filename );
}
GR::WString result = GR::WString( L"\\\\?\\" ) + GR::Convert::ToUTF16( GR::Strings::Replace( pathToSet, "\\.\\", "\\" ) );
MakeBackSlashes( result );
return result;
}
}
#endif
namespace GR
{
namespace IO
{
#if OPERATING_SUB_SYSTEM == OS_SUB_SDL
FILE* NULL_HANDLE = NULL;
#elif OPERATING_SYSTEM == OS_WINDOWS
HANDLE NULL_HANDLE = INVALID_HANDLE_VALUE;
#elif OPERATING_SYSTEM == OS_ANDROID
AAsset* NULL_HANDLE = NULL;
#elif OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
short NULL_HANDLE = -1;
#else
FILE* NULL_HANDLE = NULL;
#endif
FileStream::FileStream() :
IIOStream(),
m_Impl( new FileStreamImpl( NULL_HANDLE ) ),
m_LastError( 0 ),
#if OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
m_CacheSize( 256 )
#else
m_CacheSize( 256 )
#endif
{
}
FileStream::FileStream( const GR::Char* pFileName, IIOStream::OpenType oType ) :
IIOStream(),
m_Impl( new FileStreamImpl( NULL_HANDLE ) ),
m_LastError( 0 ),
#if OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
m_CacheSize( 0 )
#else
m_CacheSize( 256 )
#endif
{
Open( pFileName, oType );
}
FileStream::FileStream( const GR::String& FileName, IIOStream::OpenType oType ) :
IIOStream(),
m_Impl( new FileStreamImpl( NULL_HANDLE ) ),
m_LastError( 0 ),
#if OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
m_CacheSize( 0 )
#else
m_CacheSize( 256 )
#endif
{
Open( FileName, oType );
}
FileStream::~FileStream()
{
}
void FileStream::Close()
{
if ( m_Impl )
{
m_Impl->Close();
}
IIOStream::Close();
m_OpenType = OT_CLOSED;
}
#if OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
bool FileStream::OpenTandem( IIOStream::OpenType OType,
const char* Filename,
short FileCode,
short PrimaryExtentSize,
short SecondaryExtentSize,
short MaximumExtents,
short FileType,
short Options,
short RecordLen,
short BlockLen,
short KeyLen,
short KeyOffset,
bool Buffered )
{
m_LastError = 0;
if ( ( m_Impl )
&& ( m_Impl->m_Handle != NULL_HANDLE ) )
{
return false;
}
m_OpenType = OType;
if ( m_OpenType == OT_WRITE_ONLY )
{
// delete file if it exists, this doesn't seem to happen automatically with Tandem
m_LastError = FILE_PURGE_( Filename, (short)strlen( Filename ) );
}
char NewFilename[1024];
strcpy( NewFilename, Filename );
short FilenameLen = (short)strlen( Filename );
memcpy( NewFilename, Filename, FilenameLen + 1 );
ByteBuffer ItemList;
ByteBuffer ValueList;
// File type
ItemList.AppendU16NetworkOrder( 41 );
ValueList.AppendU16NetworkOrder( FileType );
// File Code
ItemList.AppendU16NetworkOrder( 42 );
ValueList.AppendU16NetworkOrder( FileCode );
// Record length
ItemList.AppendU16NetworkOrder( 43 );
ValueList.AppendU16NetworkOrder( RecordLen );
// Block length
ItemList.AppendU16NetworkOrder( 44 );
ValueList.AppendU16NetworkOrder( BlockLen );
// key offset
ItemList.AppendU16NetworkOrder( 45 );
ValueList.AppendU16NetworkOrder( KeyOffset );
// key length
ItemList.AppendU16NetworkOrder( 46 );
ValueList.AppendU16NetworkOrder( KeyLen );
// primary extent size
ItemList.AppendU16NetworkOrder( 50 );
ValueList.AppendU16NetworkOrder( PrimaryExtentSize );
// secondary extent size
ItemList.AppendU16NetworkOrder( 51 );
ValueList.AppendU16NetworkOrder( SecondaryExtentSize );
// maximum extents
ItemList.AppendU16NetworkOrder( 52 );
ValueList.AppendU16NetworkOrder( MaximumExtents );
if ( FileType == 0 )
{
// odd filebyte, only allowed for unstructured files
ItemList.AppendU16NetworkOrder( 65 );
ValueList.AppendU16NetworkOrder( 1 );
}
// create options
if ( Options != 0 )
{
ItemList.AppendU16NetworkOrder( 71 );
ValueList.AppendU16NetworkOrder( Options );
}
if ( Buffered )
{
// write through
ItemList.AppendU16NetworkOrder( 72 );
ValueList.AppendU16NetworkOrder( 0 );
}
_cc_status Status = FILE_CREATELIST_( NewFilename, FilenameLen, &FilenameLen,
(short*)ItemList.Data(), (short)( ItemList.Size() / 2 ),
(short*)ValueList.Data(), (short)ValueList.Size() );
if ( _status_lt( Status ) )
{
m_LastError = (short)Status;
//printf( "FILE_CREATELIST_ failed %d\n", m_LastError );
return false;
}
short hHandle = NULL_HANDLE;
m_LastError = 0;
switch ( m_OpenType )
{
case OT_READ_ONLY:
m_LastError = FILE_OPEN_( Filename,
(short)strlen( Filename ),
&hHandle,
1,
1 );
/*
{ const char *filename |
const char *pathname }
,short length
,short *filenum
,[ short access ]
,[ short exclusion ]
,[ short nowait-depth ]
,[ short sync-or-receive-depth ]
,[ short options ]
,[ short seq-block-buffer-id ]
,[ short seq-block-buffer-len ]
,[ short *primary-processhandle ]
,[ __int32_t elections ] );
"rb" );
*/
break;
case OT_READ_ONLY_SHARED:
m_LastError = FILE_OPEN_( Filename,
(short)strlen( Filename ),
&hHandle,
1,
0 );
break;
case OT_WRITE_ONLY:
m_LastError = FILE_OPEN_( Filename,
(short)strlen( Filename ),
&hHandle,
2 );
break;
case OT_WRITE_APPEND:
m_LastError = FILE_OPEN_( Filename,
(short)strlen( Filename ),
&hHandle,
2 );
break;
case OT_READ_WRITE:
m_LastError = FILE_OPEN_( Filename,
(short)strlen( Filename ),
&hHandle,
0 );
break;
}
if ( _status_lt( m_LastError ) )
{
Close();
return false;
}
if ( hHandle != NULL_HANDLE )
{
m_Impl = new FileStreamImpl( hHandle );
m_Opened = true;
if ( ( GetFileCode() == 101 )
&& ( GetFileType() == 0 ) )
{
// reopen as edit file (by passing the previous unclosed handle into OPENEDIT!)
switch ( m_OpenType )
{
case OT_READ_ONLY:
m_LastError = OPENEDIT_( Filename,
(short)strlen( Filename ),
&hHandle,
1,
1 );
break;
case OT_READ_ONLY_SHARED:
m_LastError = OPENEDIT_( Filename,
(short)strlen( Filename ),
&hHandle,
1,
0 );
break;
case OT_WRITE_ONLY:
case OT_WRITE_APPEND:
m_LastError = OPENEDIT_( Filename,
(short)strlen( Filename ),
&hHandle,
2 );
break;
}
if ( _status_lt( m_LastError ) )
{
Close();
return false;
}
m_Impl->m_EditFileOpened = true;
m_OpenType = OType;
m_Opened = true;
}
if ( m_OpenType == OT_WRITE_APPEND )
{
m_LastError = FILE_SETPOSITION_( hHandle, -1 );
}
}
return ( hHandle != NULL_HANDLE );
}
#endif
#if OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
short FileStream::GetFileError() const
{
if ( ( m_Impl )
&& ( m_Impl->m_Handle == NULL_HANDLE ) )
{
return -1;
}
short LastError = 0;
_cc_status Status = FILE_GETINFO_( m_Impl->m_Handle, &LastError );
if ( _status_lt( Status ) )
{
//m_LastError = (short)Status;
return -2;
}
return LastError;
}
#endif
bool FileStream::Open( const GR::Char* FileName, OpenType Type )
{
return Open( GR::String( FileName ), Type );
}
bool FileStream::Open( const GR::String& FileName, OpenType Type )
{
if ( ( m_Impl )
&& ( m_Impl->m_Handle != NULL_HANDLE ) )
{
return false;
}
m_OpenType = Type;
#if ( ( OPERATING_SYSTEM == OS_WINDOWS ) && ( ( OPERATING_SUB_SYSTEM == OS_SUB_DESKTOP ) || ( OPERATING_SUB_SYSTEM == OS_SUB_SDL ) ) )
HANDLE hHandle = NULL_HANDLE;
GR::WString utf16FileName = MakeSafeWinFilename( FileName );
switch ( m_OpenType )
{
case OT_READ_ONLY:
hHandle = CreateFileW( utf16FileName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL );
break;
case OT_READ_ONLY_SHARED:
hHandle = CreateFileW( utf16FileName.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL );
break;
case OT_WRITE_ONLY:
hHandle = CreateFileW( utf16FileName.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL );
break;
case OT_WRITE_APPEND:
hHandle = CreateFileW( utf16FileName.c_str(), FILE_APPEND_DATA, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL );
break;
case OT_READ_WRITE:
hHandle = CreateFileW( utf16FileName.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL );
break;
}
#elif ( OPERATING_SYSTEM == OS_ANDROID )
AAssetManager* pManager = AndroidMediator::s_pActivity->assetManager;
AAsset* hHandle = NULL;
switch ( m_OpenType )
{
case OT_READ_ONLY:
hHandle = AAssetManager_open( pManager, FileName.c_str(), AASSET_MODE_BUFFER );
//hHandle = fopen( FileName.c_str(), "rb" );
break;
case OT_READ_ONLY_SHARED:
hHandle = AAssetManager_open( pManager, FileName.c_str(), AASSET_MODE_BUFFER );
//hHandle = fopen( FileName.c_str(), "rb" );
break;
case OT_WRITE_ONLY:
//hHandle = fopen( FileName.c_str(), "wb" );
break;
case OT_WRITE_APPEND:
//hHandle = fopen( FileName.c_str(), "ab" );
break;
case OT_READ_WRITE:
//hHandle = fopen( FileName.c_str(), "r+b" );
break;
}
#elif ( OPERATING_SUB_SYSTEM == OS_SUB_UNIVERSAL_APP ) || ( OPERATING_SUB_SYSTEM == OS_SUB_WINDOWS_PHONE )
HANDLE hHandle = NULL_HANDLE;
GR::WString utf16FileName = MakeSafeWinFilename( FileName );
switch ( m_OpenType )
{
case OT_READ_ONLY:
hHandle = CreateFile2( utf16FileName.c_str(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, NULL );
break;
case OT_READ_ONLY_SHARED:
hHandle = CreateFile2( utf16FileName.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING, NULL );
break;
case OT_WRITE_ONLY:
hHandle = CreateFile2( utf16FileName.c_str(), GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS, NULL );
break;
case OT_WRITE_APPEND:
hHandle = CreateFile2( utf16FileName.c_str(), FILE_APPEND_DATA, FILE_SHARE_READ, OPEN_ALWAYS, NULL );
break;
case OT_READ_WRITE:
hHandle = CreateFile2( utf16FileName.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, OPEN_EXISTING, NULL );
break;
}
#elif OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
short hHandle = NULL_HANDLE;
m_LastError = 0;
switch ( m_OpenType )
{
case OT_READ_ONLY:
m_LastError = FILE_OPEN_( FileName.c_str(), (short)FileName.length(), &hHandle, 1, 1 );
/*
{ const char *filename |
const char *pathname }
,short length
,short *filenum
,[ short access ]
,[ short exclusion ]
,[ short nowait-depth ]
,[ short sync-or-receive-depth ]
,[ short options ]
,[ short seq-block-buffer-id ]
,[ short seq-block-buffer-len ]
,[ short *primary-processhandle ]
,[ __int32_t elections ] );
"rb" );
*/
break;
case OT_READ_ONLY_SHARED:
m_LastError = FILE_OPEN_( FileName.c_str(), (short)FileName.length(), &hHandle, 1, 0 );
break;
case OT_WRITE_ONLY:
return OpenTandem( OT_WRITE_ONLY,
FileName.c_str(),
0,
2000,
2000,
500,
0,
0, // options
0,
0,
0,
0,
false );
case OT_WRITE_APPEND:
m_LastError = FILE_OPEN_( FileName.c_str(), (short)FileName.length(), &hHandle, 2 );
if ( m_LastError == 11 )
{
// file not found, create new
return OpenTandem( OT_WRITE_ONLY,
FileName.c_str(),
0,
2000,
2000,
500,
0,
0, // options
0,
0,
0,
0,
false );
}
m_LastError = FILE_SETPOSITION_( hHandle, -1 );
break;
case OT_READ_WRITE:
m_LastError = FILE_OPEN_( FileName.c_str(), (short)FileName.length(), &hHandle, 0 );
break;
}
if ( _status_lt( m_LastError ) )
{
Close();
return false;
}
#else
m_LastError = 0;
FILE* hHandle = NULL_HANDLE;
switch ( m_OpenType )
{
case OT_READ_ONLY:
hHandle = fopen( FileName.c_str(), "rb" );
break;
case OT_READ_ONLY_SHARED:
hHandle = fopen( FileName.c_str(), "rb" );
break;
case OT_WRITE_ONLY:
hHandle = fopen( FileName.c_str(), "wb" );
break;
case OT_WRITE_APPEND:
hHandle = fopen( FileName.c_str(), "ab" );
break;
case OT_READ_WRITE:
hHandle = fopen( FileName.c_str(), "r+b" );
break;
case OT_CLOSED:
break;
}
#endif
if ( hHandle != NULL_HANDLE )
{
m_Impl = new FileStreamImpl( hHandle );
m_Opened = true;
#if OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
if ( ( GetFileCode() == 101 )
&& ( GetFileType() == 0 ) )
{
// reopen as edit file (by passing the previous unclosed handle into OPENEDIT!)
switch ( Type )
{
case OT_READ_ONLY:
m_LastError = OPENEDIT_( FileName.c_str(),
(short)FileName.length(),
&hHandle,
1,
1 );
break;
case OT_READ_ONLY_SHARED:
m_LastError = OPENEDIT_( FileName.c_str(),
(short)FileName.length(),
&hHandle,
1,
0 );
break;
case OT_WRITE_ONLY:
case OT_WRITE_APPEND:
m_LastError = OPENEDIT_( FileName.c_str(),
(short)FileName.length(),
&hHandle,
2 );
break;
}
if ( _status_lt( m_LastError ) )
{
Close();
return false;
}
m_Impl->m_EditFileOpened = true;
m_OpenType = Type;
m_Opened = true;
}
if ( m_OpenType == OT_WRITE_APPEND )
{
m_LastError = FILE_SETPOSITION_( hHandle, -1 );
}
#endif
}
#if OPERATING_SYSTEM == OS_WINDOWS
else
{
m_LastError = GetLastError();
}
#else
else
{
m_LastError = errno;
//dh::Log( "File Open failed (%d,%s) for (%s)", m_LastError, strerror( m_LastError ), FileName.c_str() );
}
#endif
return ( hHandle != NULL_HANDLE );
}
#if OPERATING_SYSTEM == OS_WINDOWS
HANDLE FileStream::GetHandle()
#elif OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
short FileStream::GetHandle()
#elif OPERATING_SYSTEM == OS_ANDROID
AAsset* FileStream::GetHandle()
#else
FILE* FileStream::GetHandle()
#endif
{
return m_Impl->m_Handle;
}
#if OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
short FileStream::GetFileCode()
{
ByteBuffer ItemList;
ByteBuffer ValueList;
// File Code
ItemList.AppendU16NetworkOrder( 42 );
ValueList.Resize( 2 );
unsigned short returnedBytes = 0;
short errorItem = -1;
_cc_status Status = FILE_GETINFOLIST_( m_Impl->m_Handle,
(short*)ItemList.Data(), (short)( ItemList.Size() / 2 ),
(short*)ValueList.Data(), (short)ValueList.Size(),
&returnedBytes,
&errorItem );
if ( _status_lt( Status ) )
{
m_LastError = (short)Status;
//printf( "FILE_GETINFOLIST_ failed %d\n", m_LastError );
return false;
}
return (GR::i16)ValueList.U16NetworkOrderAt( 0 );
}
short FileStream::GetFileType()
{
ByteBuffer ItemList;
ByteBuffer ValueList;
// File Type
ItemList.AppendU16NetworkOrder( 41 );
ValueList.Resize( 2 );
unsigned short returnedBytes = 0;
short errorItem = -1;
_cc_status Status = FILE_GETINFOLIST_( m_Impl->m_Handle,
(short*)ItemList.Data(), (short)( ItemList.Size() / 2 ),
(short*)ValueList.Data(), (short)ValueList.Size(),
&returnedBytes,
&errorItem );
if ( _status_lt( Status ) )
{
m_LastError = (short)Status;
//printf( "FILE_GETINFOLIST_ failed %d\n", m_LastError );
return false;
}
return (GR::i16)ValueList.U16At( 0 );
}
#endif
GR::u64 FileStream::GetSize()
{
#if OPERATING_SYSTEM == OS_WINDOWS
#if ( OPERATING_SUB_SYSTEM == OS_SUB_UNIVERSAL_APP ) || ( OPERATING_SUB_SYSTEM == OS_SUB_WINDOWS_PHONE )
FILE_STANDARD_INFO fileInfo;
if ( !GetFileInformationByHandleEx( m_Impl->m_Handle, FileStandardInfo, &fileInfo, sizeof( fileInfo ) ) )
{
m_LastError = GetLastError();
return 0;
}
return fileInfo.EndOfFile.QuadPart;
#else
return GetFileSize( m_Impl->m_Handle, NULL );
#endif
#elif OPERATING_SYSTEM == OS_ANDROID
return AAsset_getLength64( m_Impl->m_Handle );
#elif OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
ByteBuffer ItemList;
ByteBuffer ValueList;
// File type
ItemList.AppendU16NetworkOrder( 191 );
ValueList.Resize( 8 );
unsigned short returnedBytes = 0;
short errorItem = -1;
_cc_status Status = FILE_GETINFOLIST_( m_Impl->m_Handle,
(short*)ItemList.Data(), (short)( ItemList.Size() / 2 ),
(short*)ValueList.Data(), (short)ValueList.Size(),
&returnedBytes,
&errorItem );
if ( _status_lt( Status ) )
{
m_LastError = (short)Status;
//printf( "FILE_GETINFOLIST_ failed %d\n", m_LastError );
return false;
}
return ValueList.U64NetworkOrderAt( 0 );
#else
int CurPos = ftell( m_Impl->m_Handle );
if ( fseek( m_Impl->m_Handle, 0, SEEK_END ) == -1 )
{
return (GR::u64)-1;
}
GR::u64 Size = ftell( m_Impl->m_Handle );
if ( fseek( m_Impl->m_Handle, CurPos, SEEK_SET ) == -1 )
{
return (GR::u64)-2;
}
return Size;
#endif
}
bool FileStream::ReadToBuffer( void* pTarget, unsigned long BytesToRead, unsigned long& BytesRead )
{
unsigned long ulNewBytesRead = 0;
#if OPERATING_SYSTEM == OS_WINDOWS
if ( !ReadFile( m_Impl->m_Handle, pTarget, (GR::u32)BytesToRead, &BytesRead, NULL ) )
{
//dh::Log( "ReadFile failed (Wanted % bytes, got %d bytes", BytesToRead, BytesRead );
m_LastError = GetLastError();
return false;
}
return BytesToRead == BytesRead;
#elif OPERATING_SYSTEM == OS_ANDROID
int bytesRead = AAsset_read( m_Impl->m_Handle, pTarget, BytesToRead );
if ( bytesRead < 0 )
{
return false;
}
BytesRead = bytesRead;
return ( BytesRead > 0 );
#elif OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
if ( m_Impl->m_EditFileOpened )
{
short NewBytesRead = 0;
unsigned short BytesAlreadyRead = 0;
unsigned short BytesToReadNow = 0;
while ( BytesAlreadyRead < BytesToRead )
{
if ( m_Impl->m_LFNeedsToBeAdded )
{
m_Impl->m_LFNeedsToBeAdded = false;
*( ( (char*)pTarget ) + BytesAlreadyRead ) = 10;
BytesAlreadyRead++;
BytesRead = BytesAlreadyRead;
}
NewBytesRead = 0;
_cc_status Status = READEDIT( m_Impl->m_Handle, , ( (char*)pTarget ) + BytesAlreadyRead, (short)( BytesToRead - BytesAlreadyRead ), &NewBytesRead );
if ( _status_lt( Status ) )
{
// Fehler
return false;
}
if ( NewBytesRead < 0 )
{
return true;
}
if ( Status == 1 )
{
// EOF reached
return true;
}
/*
if ( NewBytesRead == 0 )
{
printf( "-failed, no bytes read\n" );
return false;
}*/
BytesAlreadyRead += NewBytesRead;
if ( BytesAlreadyRead < BytesToRead )
{
*( ( (char*)pTarget ) + BytesAlreadyRead ) = 10;
BytesAlreadyRead++;
}
else
{
m_Impl->m_LFNeedsToBeAdded = true;
}
BytesRead = BytesAlreadyRead;
}
return true;
}
unsigned long BytesToReadTemp = BytesToRead;
unsigned short BytesToReadNow = 0;
bool Fehler = false;
unsigned short NewBytesRead = 0;
while ( BytesToReadTemp > 0 )
{
if ( BytesToReadTemp > 57344 )
{
BytesToReadNow = 57344;
}
else
{
BytesToReadNow = (short)BytesToReadTemp;
}
//printf( "Read %d Bytes now\n", BytesToReadNow );
_cc_status Status = READX( m_Impl->m_Handle, ( (char*)pTarget ) + ulNewBytesRead, BytesToReadNow, &NewBytesRead );
if ( _status_lt( Status ) )
{
// Fehler
Fehler = true;
//printf( "-failed (%d bytes gotten)\n", NewBytesRead );
break;
}
//printf( "-read %d bytes\n", NewBytesRead );
ulNewBytesRead += NewBytesRead;
BytesRead += NewBytesRead;
BytesToReadTemp -= NewBytesRead;
if ( NewBytesRead < BytesToReadNow )
{
// Fehler
Fehler = true;
break;
}
}
if ( Fehler )
{
return false;
}
//Log( Misc::Format( "Bytes wanted %1% Bytes got %2%" ) << BytesToRead
return ( ulNewBytesRead == BytesToRead );
#else
//ulNewBytesRead = (unsigned long)fread( ( (char*)pTarget ) + ulNewBytesRead, 1, BytesToRead, m_Impl->m_Handle );
BytesRead = (unsigned long)fread( pTarget, 1, BytesToRead, m_Impl->m_Handle );
//printf( "Read %d Bytes now from handle %x, wanted %d, %d\n", ulNewBytesRead, m_Impl->m_Handle, BytesToRead, errno );
return ( BytesRead == BytesToRead );
#endif
}
#if OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
bool FileStream::ReadLine( char* pTarget, unsigned long MaxReadLength )
{
return IIOStream::ReadLine( pTarget, MaxReadLength );
}
bool FileStream::ReadLine( GR::WString& Result )
{
return IIOStream::ReadLine( Result );
}
bool FileStream::ReadLine( GR::String& Result )
{
if ( m_Impl->m_EditFileOpened )
{
static ByteBuffer temp( 256 );
GR::i16 bytesRead = 0;
_cc_status Status = READEDIT( m_Impl->m_Handle, , (char*)temp.Data(), (short)temp.Size(), &bytesRead );
if ( _status_lt( Status ) )
{
// Fehler
Result.erase();
return false;
}
if ( Status == 1 )
{
// EOF reached
Result.erase();
return false;
}
Result.assign( (char*)temp.Data(), bytesRead );
return true;
}
return IIOStream::ReadLine( Result );
}
#endif
unsigned long FileStream::ReadBlock( void* pDestination, size_t CountBytes )
{
#if OPERATING_SYSTEM == OS_WINDOWS
if ( ( m_Impl == INVALID_HANDLE_VALUE )
#elif OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
//if ( ( m_Impl == -1 )
if ( ( GetHandle() == -1 )
#else
if ( ( m_Impl == NULL )
#endif
|| ( !m_Opened )
|| ( m_OpenType == OT_WRITE_ONLY )
|| ( m_OpenType == OT_WRITE_APPEND ) )
{
m_ReadFailed = true;
return 0;
}
/*
// without cache
unsigned long ulBytesRead = 0;
if ( !ReadFile( m_Impl->m_Handle, pDestination, (GR::u32)ulSize, &ulBytesRead, NULL ) )
{
m_ReadFailed = true;
}
if ( ulBytesRead < ulSize )
{
m_ReadFailed = true;
}
return ulBytesRead;
*/
unsigned long ulBytesRead = 0;
size_t ulBytesToRead = CountBytes;
m_ReadFailed = false;
//dh::Log( "%08x>Read %d Bytes (Cached %d Bytes)", m_Impl, ulSize, m_Impl->m_Cache.Size() );
//printf( "%08x>Read %d Bytes (Cached %d Bytes)\n", m_Impl, ulSize, m_Impl->m_Cache.Size() );
// read from cache if enough data left
if ( m_Impl->m_Cache.Size() - m_Impl->m_CacheBytesUsed >= ulBytesToRead )
{
memcpy( pDestination, m_Impl->m_Cache.DataAt( (size_t)m_Impl->m_CacheBytesUsed ), ulBytesToRead );
m_Impl->m_CacheBytesUsed += ulBytesToRead;
//m_Impl->m_Cache.TruncateFront( ulBytesToRead );
m_Impl->m_PseudoFilePos += ulBytesToRead;
//dh::Log( "%08x-from cache (%d bytes in cache left)", m_Impl, m_Impl->m_Cache.Size() );
//printf( "%08x-from cache (%d bytes in cache left)\n", m_Impl, m_Impl->m_Cache.Size() );
//dh::Hex( lpucDestination, ulBytesToRead );
return (unsigned long)ulBytesToRead;
}
// read rest of cache
if ( m_Impl->m_Cache.Size() - m_Impl->m_CacheBytesUsed > 0 )
{
// im Cache ist noch was drin
memcpy( pDestination, m_Impl->m_Cache.DataAt( (size_t)m_Impl->m_CacheBytesUsed ), (size_t)( m_Impl->m_Cache.Size() - m_Impl->m_CacheBytesUsed ) );
ulBytesRead = (unsigned long)( m_Impl->m_Cache.Size() - m_Impl->m_CacheBytesUsed );
m_Impl->m_Cache.Clear();
m_Impl->m_CacheBytesUsed = 0;
ulBytesToRead -= ulBytesRead;
m_Impl->m_PseudoFilePos += ulBytesRead;
//dh::Log( "%08x-from cache2 (%d bytes in cache left)", m_Impl, m_Impl->m_Cache.Size() );
//printf( "%08x-from cache2 (%d bytes in cache left)\n", m_Impl, m_Impl->m_Cache.Size() );
}
// direct read if bigger than cache size
if ( ulBytesToRead > m_CacheSize )
{
// direkt rauslesen
unsigned long ulNewBytesRead = 0;
if ( !ReadToBuffer( ( (char*)pDestination ) + ulBytesRead, (GR::u32)ulBytesToRead, ulNewBytesRead ) )
{
//dh::Log( "Read failed" );
m_ReadFailed = true;
}
m_Impl->m_PseudoFilePos += ulNewBytesRead;
m_Impl->m_FilePosAfterCache += ulNewBytesRead;
ulBytesRead += ulNewBytesRead;
if ( ulBytesRead < CountBytes )
{
m_ReadFailed = true;
}
//dh::Log( "%08x-direct read (want %d got %d)", m_Impl, ulBytesToRead, ulNewBytesRead );
//printf( "%08x-direct read (want %d got %d)\n", m_Impl, ulBytesToRead, ulNewBytesRead );
//dh::Hex( lpucDestination, ulBytesRead );
return ulBytesRead;
}
// refill cache
m_Impl->m_Cache.Resize( m_CacheSize );
m_Impl->m_CacheBytesUsed = 0;
unsigned long ulCacheBytesRead = 0;
if ( !ReadToBuffer( m_Impl->m_Cache.Data(), (GR::u32)m_CacheSize, ulCacheBytesRead ) )
{
if ( ulCacheBytesRead == 0 )
{
//dh::Log( "Read failed 2" );
m_ReadFailed = true;
}
}
m_Impl->m_FilePosAfterCache += ulCacheBytesRead;
//dh::Log( "%08x-into cache (wanted %d, got %d)", m_Impl, m_CacheSize, ulCacheBytesRead );
//printf( "%08x-into cache (wanted %d, got %d)\n", m_Impl, m_CacheSize, ulCacheBytesRead );
m_Impl->m_Cache.Resize( ulCacheBytesRead );
if ( ulBytesRead + ulCacheBytesRead < CountBytes )
{
m_ReadFailed = true;
}
if ( ulBytesToRead > ulCacheBytesRead )
{
// wir waren am Ende; der volle Cache wird kopiert
memcpy( ( (char*)pDestination ) + ulBytesRead, m_Impl->m_Cache.Data(), ulCacheBytesRead );
m_Impl->m_Cache.Clear();
m_Impl->m_CacheBytesUsed = 0;
m_Impl->m_PseudoFilePos += ulCacheBytesRead;
//dh::Log( "%08x-from cache3 (%d bytes in cache left)", m_Impl, m_Impl->m_Cache.Size() );
//printf( "%08x-from cache3 (%d bytes in cache left)\n", m_Impl, m_Impl->m_Cache.Size() );
//dh::Hex( lpucDestination, ulCacheBytesRead + ulBytesRead );
return ulCacheBytesRead + ulBytesRead;
}
memcpy( ( (char*)pDestination ) + ulBytesRead, m_Impl->m_Cache.DataAt( (size_t)m_Impl->m_CacheBytesUsed ), ulBytesToRead );
m_Impl->m_CacheBytesUsed += ulBytesToRead;
//m_Impl->m_Cache.TruncateFront( ulBytesToRead );
m_Impl->m_PseudoFilePos += ulBytesToRead;
//dh::Log( "%08x-from cache4 (%d bytes in cache left)", m_Impl, m_Impl->m_Cache.Size() );
//printf( "%08x-from cache4 (%d bytes in cache left)\n", m_Impl, m_Impl->m_Cache.Size() );
//dh::Hex( lpucDestination, ulBytesToRead + ulBytesRead );
return (unsigned long)ulBytesToRead + ulBytesRead;
}
unsigned long FileStream::WriteBlock( const void* pSource, size_t CountBytes )
{
if ( ( !m_Impl.IsObjectValid() )
|| ( m_Impl->m_Handle == NULL_HANDLE )
|| ( m_OpenType == OT_READ_ONLY ) )
{
//printf( "WriteBlock Invalid\n" );
return 0;
}
unsigned long ulBytesWritten = 0;
if ( !m_Impl->m_Cache.Empty() )
{
m_Impl->m_Cache.Clear();
m_Impl->m_CacheBytesUsed = 0;
m_Impl->m_FilePosAfterCache = m_Impl->m_PseudoFilePos;
SetPosition( m_Impl->m_PseudoFilePos, PT_SET );
}
#if OPERATING_SYSTEM == OS_WINDOWS
WriteFile( m_Impl->m_Handle, pSource, (GR::u32)CountBytes, &ulBytesWritten, NULL );
m_LastError = GetLastError();
#elif OPERATING_SYSTEM == OS_ANDROID
dh::Log( "FileStream::WriteBlock not supported yet" );
#elif OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
unsigned short BytesToWriteNow = 0;
unsigned short ulNewBytesWritten = 0;
//printf( "Want to write %lu bytes\n", ulSize );
while ( CountBytes > 0 )
{
if ( CountBytes > (short)16384 )
{
BytesToWriteNow = (short)16384;
}
else
{
BytesToWriteNow = (short)CountBytes;
}
//printf( "Write %d bytes\n", BytesToWriteNow );
_cc_status Status = WRITEX( m_Impl->m_Handle, (const char*)pSource + ulBytesWritten, BytesToWriteNow, &ulNewBytesWritten );
if ( ( _status_lt( Status ) )
|| ( ulNewBytesWritten < BytesToWriteNow ) )
{
// Fehler
//printf( "Error calling writeX (%d)\n", GetFileError() );
m_LastError = GetFileError();
break;
}
// darf das so laufen?????
if ( ulNewBytesWritten > BytesToWriteNow )
{
// TANDEM kann ein Byte mehr schreiben!?!
//printf( "Tandem wrote %u bytes, but we only provided %u!\n", ulNewBytesWritten, BytesToWriteNow );
ulNewBytesWritten = BytesToWriteNow;
}
//printf( "-Bytes written %d\n", ulNewBytesWritten );
ulBytesWritten += ulNewBytesWritten;
CountBytes -= ulNewBytesWritten;
}
#else
ulBytesWritten = (unsigned long)fwrite( pSource, 1, CountBytes, m_Impl->m_Handle );
#endif
m_Impl->m_FilePosAfterCache += ulBytesWritten;
m_Impl->m_PseudoFilePos += ulBytesWritten;
return ulBytesWritten;
}
unsigned long FileStream::SetPosition( GR::i64 Offset, PositionType Position )
{
if ( m_Impl->m_Handle == NULL_HANDLE )
{
return (unsigned long)-1;
}
switch ( Position )
{
case PT_CURRENT:
// uhoh, Cache berücksichtigen
if ( Offset == 0 )
{
return (unsigned long)( m_Impl->m_PseudoFilePos );
}
/*
if ( iOffset < 0 )
{
m_Impl->m_iFilePos += iOffset;
iOffset = m_Impl->m_iFilePos;
m_Impl->m_Cache.Clear();
pType = PT_SET;
}
if ( ( iOffset <= (GR::i64)m_Impl->m_Cache.Size() )
&& ( iOffset >= 0 ) )
{
// Offset passt in Cache
m_Impl->m_iFilePos += iOffset - (GR::i64)m_Impl->m_Cache.Size();
m_Impl->m_Cache.TruncateFront( iOffset );
return GetPosition();
}
else
{
}
*/
/*
//iOffset -= (GR::i64)m_Impl->m_iFilePos - (GR::i64)m_CacheSize + (GR::i64)m_Impl->m_Cache.Size();
m_Impl->m_iFilePos += iOffset - (GR::i64)m_Impl->m_Cache.Size();
//iOffset -= (GR::i64)m_Impl->m_iFilePos - (GR::i64)m_Impl->m_Cache.Size();
//m_Impl->m_iFilePos += iOffset;
*/
/*
m_Impl->m_iFilePos += iOffset - m_Impl->m_Cache.Size();
iOffset = m_Impl->m_iFilePos;
*/
m_Impl->m_PseudoFilePos += Offset;
m_Impl->m_FilePosAfterCache = m_Impl->m_PseudoFilePos;
Offset = m_Impl->m_PseudoFilePos;
Position = PT_SET;
break;
case PT_SET:
m_Impl->m_PseudoFilePos = Offset;
m_Impl->m_FilePosAfterCache = Offset;
break;
case PT_END:
m_Impl->m_PseudoFilePos = (GR::i64)GetSize();
m_Impl->m_FilePosAfterCache = m_Impl->m_PseudoFilePos;
break;
}
m_Impl->m_Cache.Clear();
m_Impl->m_CacheBytesUsed = 0;
#if OPERATING_SYSTEM == OS_WINDOWS
LARGE_INTEGER offset;
offset.QuadPart = Offset;
return SetFilePointerEx( m_Impl->m_Handle, offset, NULL, Position );
#elif OPERATING_SYSTEM == OS_ANDROID
dh::Log( "FileStream::SetPosition not supported yet" );
return 0;
#elif OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
//return 0;
FILE_SETPOSITION_( m_Impl->m_Handle, Offset );
return Offset;
#else
// TODO - Assume seek-types match pType
fseek( m_Impl->m_Handle, (long)Offset, (int)Position );
return ftell( m_Impl->m_Handle );
#endif
}
GR::u64 FileStream::GetPosition()
{
if ( m_Impl->m_Handle == NULL_HANDLE )
{
return (GR::u64)-1;
}
return m_Impl->m_PseudoFilePos;
}
bool FileStream::Flush()
{
if ( m_Impl->m_Handle == NULL_HANDLE )
{
return false;
}
#if OPERATING_SYSTEM == OS_WINDOWS
return ( FlushFileBuffers( m_Impl->m_Handle ) == TRUE );
#elif OPERATING_SUB_SYSTEM == OS_SUB_GUARDIAN
return true;
#elif OPERATING_SYSTEM == OS_ANDROID
dh::Log( "FileStream::Flush not supported yet" );
return false;
#else
return ( fflush( m_Impl->m_Handle ) == 0 );
#endif
}
bool FileStream::IsGood()
{
if ( m_Impl.ptr() == NULL )
{
return false;
}
return ( m_Impl->m_Handle != NULL_HANDLE );
}
void FileStream::SetCacheSize( size_t Size )
{
m_CacheSize = Size;
if ( m_Impl.ptr() == NULL )
{
return;
}
// force reload of cache
m_Impl->m_Cache.Clear();
m_Impl->m_CacheBytesUsed = 0;
m_Impl->m_FilePosAfterCache = m_Impl->m_PseudoFilePos;
}
GR::i32 FileStream::LastError() const
{
return m_LastError;
}
}
}
| [
"[email protected]"
] | |
94a62db851f01e44db84597f4329bb7e764e3f9a | ed557a8a4fa38ea5f062d90a36b141b8d0853eba | /Square.cpp | 31505b960966e03454da6eb283e06b70e1263864 | [] | no_license | msdedwards/FieldSweeper | e92fd2203b6e7d95f40493f264578f1653f38830 | 5671fc232c2b3a6e278c5f44c7a0a3c3982ddbe2 | refs/heads/master | 2021-01-10T19:00:37.243718 | 2014-05-02T18:29:21 | 2014-05-02T18:29:21 | 19,349,155 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 232 | cpp | #include "StdAfx.h"
#include "Square.h"
CSquare::CSquare(void)
{
Reset();
}
CSquare::~CSquare(void)
{
}
void CSquare::Reset(void)
{
IsMine=false;
IsHidden=true;
IsFlagged=false;
AdjacentMineCount=0;
WasGameOver=false;
}
| [
"[email protected]"
] | |
28afac8b893e1a2e91412cd02f6d66890fe0c49d | a14b7412dc543efab79527a5c0188f7c9fb9a598 | /link-queue.cpp | 759f4f772ba5e829299160320fb0598e132aa55a | [] | no_license | hmc123/gitlearn | 981cb16fbf762e267f9aace0fb5ce8678124e094 | 289714a5e2db16badbd27b17823ea7b94ad3c3e1 | refs/heads/master | 2021-01-10T10:01:04.324026 | 2018-12-07T04:39:04 | 2018-12-07T04:39:04 | 45,775,459 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,164 | cpp | #include<iostream>
using namespace std;
class node
{
public:
int data;
node *next;
};
class linkqueue
{
public:
linkqueue()
{
front = new node;
front->next = NULL;
rear = front;
}
node *front, *rear;
};
bool IsEmpty(linkqueue *Q)
{
if (Q->front == Q->rear)
return true;
else
return false;
}
void EnQueue(linkqueue *Q, int e)
{
node *p = new node;
p->data = e;
p->next = NULL;
Q->rear->next = p;
Q->rear = p;
}
int DeQueue(linkqueue *Q)
{
node *p;
int k;
if (!IsEmpty(Q))
{
p = Q->front;
k = p->next->data;
Q->front = p->next;
delete p;
return k; //return the data of the deleted node
}
else
{
cout<<"队列已空!";
return 0;
}
}
int LenQueue(linkqueue *Q)
{
int count = 0;
node *p = Q->front;
while (p->next != NULL)
{
count++;
p= p->next;
}
return count;
}
int main()
{
linkqueue m;
cout<<"下面进行进队列操作\n";
for (int i = 0; i<10; i++)
{
EnQueue(&m, i*2);
}
cout<<"队列长度为:"<<LenQueue(&m)<<endl;
cout<<"下面做出出队列操作\n";
while (!IsEmpty(&m))
{
cout<<DeQueue(&m)<<endl;
}
cout<<"队列长度为:"<<LenQueue(&m)<<endl;
return 0;
} | [
"[email protected]"
] | |
ec6ad564644bbb1e245f2ad841aa3d5a0a2e042f | b25795509f9545ea6b9f947492b39e518add0396 | /大一下/Gobang/v3.0/Gobang/Gobang.cpp | 2e3f639159bc8fc33dfe80ba482d8ee6709415cc | [] | no_license | Autokaka/C-Single-Ranking | 370e09a5d96212dc0fdef71b4cfe2bd6389c5e22 | 111808c552ee81a6109406e770970560501cea79 | refs/heads/master | 2022-01-11T09:43:02.585962 | 2019-07-15T04:48:12 | 2019-07-15T04:48:12 | 176,041,920 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 25,802 | cpp | #include "stdafx.h"
#include "Gobang.h"
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
Gobang::Gobang(int n)
{
while (n < 0)
{
cout << "输入的棋盘大小有误。请重新输入:";
cin >> n;
}
size = n;
Goboard = new int *[size + 1];
for (int i = 0; i <= size; i++)
Goboard[i] = new int[size + 1];
for (int i = 0; i <= size; i++)
for (int j = 0; j <= size; j++)
{
Goboard[i][0] = i;
Goboard[0][j] = j;
Goboard[i][j] = 0;
}
}
void Gobang::play()
{
cout << "\n__________我们来下五子棋吧~~~__________" << endl;
int turn = -1;
int gamestatus = -1;
while (turn <= 0 || turn > 2)
{
cout << "\n 【选手1:●】【选手2:〇】" << endl;
cout << "\n【比赛由选手1先手】 你的选择是: ";
cin >> turn;
}
switch (turn)
{
case 1:
while (gamestatus)
{
YouGo(1);
gamestatus = judge();
switch (gamestatus)
{
case -1:
break;
case 0:
cout << "\n\n\n\n\n\n\n\n\n\n【平局!皆大欢喜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
case 1:
cout << "\n\n\n\n\n\n\n\n\n\n【玩家1(您自己)获胜!恭喜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
case 2:
cout << "\n\n\n\n\n\n\n\n\n\n【机器人获胜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
}
if (gamestatus >= 0)
break;
AIGo(2);
gamestatus = judge();
switch (gamestatus)
{
case -1:
break;
case 0:
cout << "\n\n\n\n\n\n\n\n\n\n【平局!皆大欢喜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
case 1:
cout << "\n\n\n\n\n\n\n\n\n\n【玩家1(您自己)获胜!恭喜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
case 2:
cout << "\n\n\n\n\n\n\n\n\n\n【机器人获胜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
}
if (gamestatus >= 0)
break;
}
break;
case 2:
while (gamestatus)
{
AIGo(1);
gamestatus = judge();
switch (gamestatus)
{
case -1:
break;
case 0:
cout << "\n\n\n\n\n\n\n\n\n\n【平局!皆大欢喜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
case 1:
cout << "\n\n\n\n\n\n\n\n\n\n【玩家1(您自己)获胜!恭喜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
case 2:
cout << "\n\n\n\n\n\n\n\n\n\n【机器人获胜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
}
if (gamestatus >= 0)
break;
YouGo(2);
gamestatus = judge();
switch (gamestatus)
{
case -1:
break;
case 0:
cout << "\n\n\n\n\n\n\n\n\n\n【平局!皆大欢喜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
case 1:
cout << "\n\n\n\n\n\n\n\n\n\n【玩家1(您自己)获胜!恭喜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
case 2:
cout << "\n\n\n\n\n\n\n\n\n\n【机器人获胜!】\n\n\n\n\n\n\n\n\n" << endl;
break;
}
if (gamestatus >= 0)
break;
}
break;
}
}
void Gobang::YouGo(int num)
{
int x = 0;
int y = 0;
cout << "\n请选手 " << num << "(您自己)下棋: ";
cin >> x >> y;
while (x < 1 || x > size || y < 1 || y > size || Goboard[x][y] != 0)
{
cout << "当前输入坐标不符合要求或者已经落子,请重新输入: ";
cin >> x >> y;
}
Draw(x, y, num);
}
void Gobang::AIGo(int num)//num是自己的号码
{
//判断自己是不是差一步就赢了
for (int hang = 1; hang <= size; hang++)
for (int lie = 1; lie <= size; lie++)
for (int space = 1; space <= size; space++)
for (int direction = 1; direction <= 4; direction++)
if (Goboard[hang][lie] == num && ComboCheck(hang, lie, direction, space) == 4)
{
switch (direction)
{
case 1:
{
if (hang + space <= size && lie - space >= 1 && hang - 4 * space >= 1 && lie + 4 * space <= size)
{
if (Goboard[hang + space][lie - space] == 0)
{
Draw(hang + space, lie - space, num);
return;
}
if (Goboard[hang - 4 * space][lie + 4 * space] == 0)
{
Draw(hang - 4 * space, lie + 4 * space, num);
return;
}
}
}
break;
case 2:
{
if (lie - space >= 1 && lie + 4 * space <= size)
{
if (Goboard[hang][lie - space] == 0)
{
Draw(hang, lie - space, num);
return;
}
if (Goboard[hang][lie + 4 * space] == 0)
{
Draw(hang, lie + 4 * space, num);
return;
}
}
}
break;
case 3:
{
if (hang - space >= 1 && lie - space >= 1 && hang + 4 * space <= size && lie + 4 * space <= size)
{
if (Goboard[hang - space][lie - space] == 0)
{
Draw(hang - space, lie - space, num);
return;
}
if (Goboard[hang + 4 * space][lie + 4 * space] == 0)
{
Draw(hang + 4 * space, lie + 4 * space, num);
return;
}
}
}
break;
case 4:
{
if (hang - space >= 1 && hang + 4 * space <= size)
{
if (Goboard[hang - space][lie] == 0)
{
Draw(hang - space, lie, num);
return;
}
if (Goboard[hang + 4 * space][lie] == 0)
{
Draw(hang + 4 * space, lie, num);
return;
}
}
break;
}
}
}
cout << "\n 判断自己是不是差一步就赢了 结束\n" << endl;
//防守
//判断对面是否即将要赢了
for (int hang = 1; hang <= size; hang++)
for (int lie = 1; lie <= size; lie++)
for (int space = 1; space <= size; space++)
for (int direction = 1; direction <= 4; direction++)
if (Goboard[hang][lie] != num && Goboard[hang][lie] != 0 && ComboCheck(hang, lie, direction, space) >= 3)
{
switch (direction)
{
case 1:
{
if (hang + space <= size && lie - space >= 1 && hang - 3 * space >= 1 && lie + 3 * space <= size)
switch (ComboCheck(hang, lie, direction, space))
{
case 3:
{
if (Goboard[hang + space][lie - space] == 0 && Goboard[hang - 3 * space][lie + 3 * space] == 0)
{
if (SurroundEnemy(hang + space, lie - space, num) > SurroundEnemy(hang - 3 * space, lie + 3 * space, num))
{
Draw(hang + space, lie - space, num);
return;
}
else
{
Draw(hang - 3 * space, lie + 3 * space, num);
return;
}
}
}
break;
case 4:
{
if (hang - 4 * space < 1 || lie + 4 * space > size)
{
if (SurroundEnemy(hang + space, lie - space, num) > 1)
{
Draw(hang + space, lie - space, num);
return;
}
}
else
if (SurroundEnemy(hang - 4 * space, lie + 4 * space, num) > 1)
{
Draw(hang - 4 * space, lie + 4 * space, num);
return;
}
else
if (SurroundEnemy(hang + space, lie - space, num) > 1 || SurroundEnemy(hang + space, lie - space, num) >= 0)
{
Draw(hang + space, lie - space, num);
return;
}
else
if (SurroundEnemy(hang - 4 * space, lie + 4 * space, num) >= 0)
{
Draw(hang - 4 * space, lie + 4 * space, num);
return;
}
}
break;
}
}
break;
case 2:
{
if (lie - space >= 1 && lie + 3 * space <= size)
switch (ComboCheck(hang, lie, direction, space))
{
case 3:
{
if (Goboard[hang][lie - space] == 0 && Goboard[hang][lie + 3 * space] == 0)
{
if (SurroundEnemy(hang, lie - space, num) > SurroundEnemy(hang, lie + 3 * space, num))
{
Draw(hang, lie - space, num);
return;
}
else
{
Draw(hang, lie + 3 * space, num);
return;
}
}
}
break;
case 4:
{
if (lie + 4 * space > size)
{
if (SurroundEnemy(hang, lie - space, num) >= 0)
{
Draw(hang, lie - space, num);
return;
}
}
else
if (SurroundEnemy(hang, lie + 4 * space, num) > 1)
{
Draw(hang, lie + 4 * space, num);
return;
}
else
if (SurroundEnemy(hang, lie - space, num) > 1 || SurroundEnemy(hang, lie - space, num) >= 0)
{
Draw(hang, lie - space, num);
return;
}
else
if (SurroundEnemy(hang, lie + 4 * space, num) >= 0)
{
Draw(hang, lie + 4 * space, num);
return;
}
}
break;
}
}
break;
case 3:
{
if (hang - space >= 1 && lie - space >= 1 && hang + 3 * space <= size && lie + 3 * space <= size)
switch (ComboCheck(hang, lie, direction, space))
{
case 3:
{
if (Goboard[hang - space][lie - space] == 0 && Goboard[hang + 3 * space][lie + 3 * space] == 0)
{
if (SurroundEnemy(hang - space, lie - space, num) > SurroundEnemy(hang + 3 * space, lie + 3 * space, num))
{
Draw(hang - space, lie - space, num);
return;
}
else
{
Draw(hang + 3 * space, lie + 3 * space, num);
return;
}
}
}
break;
case 4:
{
if (hang + 4 * space > size || lie + 4 * space > size)
{
if (SurroundEnemy(hang - space, lie - space, num) >= 0)
{
Draw(hang - space, lie - space, num);
return;
}
}
else
if (SurroundEnemy(hang + 4 * space, lie + 4 * space, num) > 1)
{
Draw(hang + 4 * space, lie + 4 * space, num);
return;
}
else
if (SurroundEnemy(hang - space, lie - space, num) > 1 || SurroundEnemy(hang - space, lie - space, num) >= 0)
{
Draw(hang - space, lie - space, num);
return;
}
else
if (SurroundEnemy(hang + 4 * space, lie + 4 * space, num) >= 0)
{
Draw(hang + 4 * space, lie + 4 * space, num);
return;
}
}
break;
}
}
break;
case 4:
{
if (hang - space >= 1 && hang + 3 * space <= size)
switch (ComboCheck(hang, lie, direction, space))
{
case 3:
{
if (Goboard[hang - space][lie] == 0 && Goboard[hang + 3 * space][lie] == 0)
{
if (SurroundEnemy(hang - space, lie, num) > SurroundEnemy(hang + 3 * space, lie, num))
{
Draw(hang - space, lie, num);
return;
}
else
{
Draw(hang + 3 * space, lie, num);
return;
}
}
}
break;
case 4:
{
if (hang + 4 * space > size)
{
if (SurroundEnemy(hang - space, lie, num) >= 0)
{
Draw(hang - space, lie, num);
return;
}
}
else
if (SurroundEnemy(hang + 4 * space, lie, num) > 1)
{
Draw(hang + 4 * space, lie, num);
return;
}
else
if (SurroundEnemy(hang - space, lie, num) > 1 || SurroundEnemy(hang - space, lie, num) >= 0)
{
Draw(hang - space, lie, num);
return;
}
else
if (SurroundEnemy(hang + 4 * space, lie, num) >= 0)
{
Draw(hang + 4 * space, lie, num);
return;
}
}
break;
}
}
break;
}
}
cout << "\n 判断对面是否即将要赢了 结束\n" << endl;
//判断自己是否即将要赢了(三颗连子两侧空空)
for (int hang = 1; hang <= size; hang++)
for (int lie = 1; lie <= size; lie++)
for (int space = 1; space <= size; space++)
for (int direction = 1; direction <= 4; direction++)
if (Goboard[hang][lie] == num && ComboCheck(hang, lie, direction, space) == 3)
{
switch (direction)
{
case 1:
{
if (hang + space <= size && lie - space >= 1 && hang - 4 * space >= 1 && lie + 4 * space <= size)
if (Goboard[hang + space][lie - space] == 0 && Goboard[hang - 3 * space][lie + 3 * space] == 0)
{
Draw(hang - 3 * space, lie + 3 * space, num);
return;
}
}
break;
case 2:
{
if (lie - space >= 1 && lie + 4 * space <= size)
if (Goboard[hang][lie - space] == 0 && Goboard[hang][lie + 3 * space] == 0)
{
Draw(hang, lie + 3 * space, num);
return;
}
}
break;
case 3:
{
if (hang - space >= 1 && lie - space >= 1 && hang + 4 * space <= size && lie + 4 * space <= size)
if (Goboard[hang - space][lie - space] == 0 && Goboard[hang + 3 * space][lie + 3 * space] == 0)
{
Draw(hang + 3 * space, lie + 3 * space, num);
return;
}
}
break;
case 4:
{
if (hang - space >= 1 && hang + 4 * space <= size)
if (Goboard[hang - space][lie] == 0 && Goboard[hang + 3 * space][lie] == 0)
{
Draw(hang + 3 * space, lie, num);
return;
}
}
break;
}
}
//判断结束
cout << "\n 判断自己是否即将要赢了 结束\n" << endl;
//预判对面双活三
for (int hang = 1; hang <= size; hang++)
for (int lie = 1; lie <= size; lie++)
for (int space = 2; space <= 4; space++)
for (int direction = 1; direction <= 4; direction++)
if (Goboard[hang][lie] != num && Goboard[hang][lie] != 0 && ComboCheck(hang, lie, direction, space) == 2)
{
switch (direction)
{
case 1:
{
int breakcase = 0;
for (int i = 1; i <= space - 1; i++)
{
if (Goboard[hang - i][lie + i] == num)
{
breakcase = 1;
break;
}
}
if (breakcase != 1)
{
for (int i = 1; i <= space - 1; i++)
{
if (Goboard[hang - i][lie + i] == 0)
{
Draw(hang - i, lie + i, num);
return;
}
}
}
}
break;
case 2:
{
int breakcase = 0;
for (int i = 1; i <= space - 1; i++)
{
if (Goboard[hang][lie + i] == num)
{
breakcase = 1;
break;
}
}
if (breakcase != 1)
{
for (int i = 1; i <= space - 1; i++)
{
if (Goboard[hang][lie + i] == 0)
{
Draw(hang, lie + i, num);
return;
}
}
}
}
break;
case 3:
{
int breakcase = 0;
for (int i = 1; i <= space - 1; i++)
{
if (Goboard[hang + i][lie + i] == num)
{
breakcase = 1;
break;
}
}
if (breakcase != 1)
{
for (int i = 1; i <= space - 1; i++)
{
if (Goboard[hang + i][lie + i] == 0)
{
Draw(hang + i, lie + i, num);
return;
}
}
}
}
break;
case 4:
{
int breakcase = 0;
for (int i = 1; i <= space - 1; i++)
{
if (Goboard[hang + i][lie] == num)
{
breakcase = 1;
break;
}
}
if (breakcase != 1)
{
for (int i = 1; i <= space - 1; i++)
{
if (Goboard[hang + i][lie] == 0)
{
Draw(hang + i, lie, num);
return;
}
}
}
}
break;
}
}
cout << "\n 预判对面双活三 结束\n" << endl;
//基础围堵
for (int hang = 1; hang <= size; hang++)
for (int lie = 1; lie <= size; lie++)
for (int space = 2; space <= size; space++)
for (int direction = 1; direction <= 4; direction++)
if (Goboard[hang][lie] != num && Goboard[hang][lie] != 0 && ComboCheck(hang, lie, direction, space) == 3)
{
switch (direction)
{
case 1:
{
if (Goboard[hang - 3 * space][lie - 3 * space] == num && hang + space <= size && lie - space >= 1)
{
Draw(hang + space, lie - space, num);
return;
}
}
break;
case 2:
{
if (Goboard[hang][lie - 3 * space] == num && lie - space >= 1)
{
Draw(hang, lie - space, num);
return;
}
}
break;
case 3:
{
if (Goboard[hang + 3 * space][lie + 3 * space] == num && hang - space >= 1 && lie - space >= 1)
{
Draw(hang - space, lie - space, num);
return;
}
}
break;
case 4:
{
if (Goboard[hang + 3 * space][lie] == num && hang - space >= 1)
{
Draw(hang - space, lie, num);
return;
}
}
break;
}
}
//防守结束
cout << "\n 基础围堵 结束\n" << endl;
//进攻
for (int hang = 1; hang <= size; hang++)
for (int lie = 1; lie <= size; lie++)
for (int space = 1; space <= size; space++)
for (int direction = 1; direction <= 4; direction++)
if (Goboard[hang][lie] == num && (ComboCheck(hang, lie, direction, space) == 3 || ComboCheck(hang, lie, direction, space) == 2))
{
switch (direction)
{
case 1:
{
int combo = ComboCheck(hang, lie, direction, space);
if (hang - combo * space >= 1 && lie + combo * space <= size)
if (Goboard[hang - combo * space][lie + combo * space] == 0)
{
Draw(hang - combo * space, lie + combo * space, num);
return;
}
if (hang + space <= size && lie - space >= 1)
if (Goboard[hang + space][lie - space] == 0)
{
Draw(hang + space, lie - space, num);
return;
}
}
break;
break;
case 2:
{
int combo = ComboCheck(hang, lie, direction, space);
if (lie + combo * space <= size)
if (Goboard[hang][lie + combo * space] == 0)
{
Draw(hang, lie + combo * space, num);
return;
}
if (lie - space >= 1)
if (Goboard[hang][lie - space] == 0)
{
Draw(hang, lie - space, num);
return;
}
}
break;
case 3:
{
int combo = ComboCheck(hang, lie, direction, space);
if (hang + combo * space <= size && lie + combo * space <= size)
if (Goboard[hang + combo * space][lie + combo * space] == 0)
{
Draw(hang + combo * space, lie + combo * space, num);
return;
}
if (hang - space >= 1 && lie - space >= 1)
if (Goboard[hang - space][lie - space] == 0)
{
Draw(hang - space, lie - space, num);
return;
}
}
break;
case 4:
{
int combo = ComboCheck(hang, lie, direction, space);
if (hang + combo * space <= size)
if (Goboard[hang + combo * space][lie] == 0)
{
Draw(hang + combo * space, lie, num);
return;
}
if (hang - space >= 1)
if (Goboard[hang - space][lie] == 0)
{
Draw(hang - space, lie, num);
return;
}
}
break;
}
}
//进攻结束
cout << "\n 进攻 结束\n" << endl;
//AI围绕先手下第二颗棋子
srand(time(0));
int randirection = 1 + rand() % 3;
for (int hang = 1; hang <= size; hang++)
for (int lie = 1; lie <= size; lie++)
if (Goboard[hang][lie] != 0 && Goboard[hang][lie] != num)
switch (randirection)
{
case 1:
{
if (Goboard[hang - 1][lie + 1] == 0)
{
Draw(hang - 1, lie + 1, num);
return;
}
}
case 2:
{
if (Goboard[hang][lie + 1] == 0)
{
Draw(hang, lie + 1, num);
return;
}
}
case 3:
{
if (Goboard[hang + 1][lie + 1] == 0)
{
Draw(hang + 1, lie + 1, num);
return;
}
}
case 4:
{
if (Goboard[hang + 1][lie] == 0)
{
Draw(hang + 1, lie, num);
return;
}
}
default:
break;
}
//AI第二手结束
cout << "\n AI围绕先手下第二颗棋子 结束\n" << endl;
//AI先手
int x = 4 + rand() % (size - 6);
int y = 4 + rand() % (size - 6);
Draw(x, y, num);
cout << "\n AI先手 结束(改bug去吧你!!!)\n" << endl;
}
void Gobang::Draw(int hang, int lie, int num)
{
Goboard[hang][lie] = num;
cout << "\n选手 " << num << " 的落子位置: " << "( " << hang << " , " << lie << " )" << endl;
print();
}
/*测试用接口*/void Gobang::Pointest(int goboard, int num, int hang, int lie, int direction, int space)
{
cout << "\n测试!!!" << " Goboard[hang][lie]: " << goboard << " num: " << num << " hang: " << hang << " lie: " << lie << " direction: " << direction << " space: " << space << endl << endl;
}
int Gobang::judge()//(-1:还未分出胜负)(0:平局)(1:玩家1获胜)(2:玩家2获胜)
{
for (int hang = 1; hang <= size; hang++)
{
for (int lie = 1; lie <= size; lie++)
{
for (int direction = 1; direction <= 4; direction++)
{
for (int space = 1; space <= size; space++)
{
if (Goboard[hang][lie] != 0 && ComboCheck(hang, lie, direction, space) == 5)
return Goboard[hang][lie];
}
}
}
}
for (int i = 1; i <= size; i++)
for (int j = 1; j <= size; j++)
if (Goboard[i][j] == 0)
return -1;
return 0;
}
//返回某点处某个方向的棋子数目
int Gobang::ComboCheck(int hang, int lie, int direction, int space)
{
if (space < 1 || hang < 1 || hang > size || lie < 1 || lie > size || Goboard[hang][lie] == 0)
return 0;
switch (direction)
{
case 1://左下->右上
{
int num = Goboard[hang][lie];
int cnt = 1;
for (int i = 1; i <= 4; i++)//端点
{
if (hang - i * space < 1 || lie + i * space > size)
return cnt;
if (Goboard[hang - i * space][lie + i * space] != num)
return cnt;
else
{
for (int j = 1; j <= space - 1; j++)//端点之间
if (Goboard[hang - (i - 1) * space + j][lie + (i - 1) * space + j] != 0)
return cnt;
cnt++;
}
}
return cnt;
}
break;
case 2://左->右
{
int num = Goboard[hang][lie];
int cnt = 1;
for (int i = 1; i <= 4; i++)//端点
{
if (lie + i * space > size)
return cnt;
if (Goboard[hang][lie + i * space] != num)
return cnt;
else
{
for (int j = 1; j <= space - 1; j++)//端点之间
if (Goboard[hang][lie + (i - 1) * space + j] != 0)
return cnt;
cnt++;
}
}
return cnt;
}
break;
case 3://左上->右下
{
int num = Goboard[hang][lie];
int cnt = 1;
for (int i = 1; i <= 4; i++)//端点
{
if (hang + i * space > size || lie + i * space > size)
return cnt;
if (Goboard[hang + i * space][lie + i * space] != num)
return cnt;
else
{
for (int j = 1; j <= space - 1; j++)//端点之间
if (Goboard[hang + (i - 1) * space + j][lie + (i - 1) * space + j] != 0)
return cnt;
cnt++;
}
}
return cnt;
}
break;
case 4://上->下
{
int num = Goboard[hang][lie];
int cnt = 1;
for (int i = 1; i <= 4; i++)//端点
{
if (hang + i * space > size)
return cnt;
if (Goboard[hang + i * space][lie] != num)
return cnt;
else
{
for (int j = 1; j <= space - 1; j++)//端点之间
if (Goboard[hang + (i - 1) * space + j][lie] != 0)
return cnt;
cnt++;
}
}
return cnt;
}
break;
}
}
int Gobang::SurroundEnemy(int hang, int lie, int num)//num是自己的数字
{
if (hang < 1 || hang > size || lie < 1 || lie > size || Goboard[hang][lie] != 0)
return -1;
int cnt = 0;
for (int direction = 1; direction <= 4; direction++)
{
switch (direction)
{
case 1:
{
if (hang - 1 >= 1 && lie + 1 <= size)
if (Goboard[hang - 1][lie + 1] != 0 && Goboard[hang - 1][lie + 1] != num)
cnt++;
if (hang + 1 <= size && lie - 1 >= 1)
if (Goboard[hang + 1][lie - 1] != 0 && Goboard[hang + 1][lie - 1] != num)
cnt++;
}
break;
case 2:
{
if (lie + 1 <= size)
if (Goboard[hang][lie + 1] != 0 && Goboard[hang][lie + 1] != num)
cnt++;
if (lie - 1 >= 1)
if (Goboard[hang][lie - 1] != 0 && Goboard[hang][lie - 1] != num)
cnt++;
}
break;
case 3:
{
if (hang + 1 <= size && lie + 1 <= size)
if (Goboard[hang + 1][lie + 1] != 0 && Goboard[hang + 1][lie + 1] != num)
cnt++;
if (hang - 1 >= 1 && lie - 1 >= 1)
if (Goboard[hang - 1][lie - 1] != 0 && Goboard[hang - 1][lie - 1] != num)
cnt++;
}
break;
case 4:
{
if (hang + 1 <= size)
if (Goboard[hang + 1][lie] != 0 && Goboard[hang + 1][lie] != num)
cnt++;
if (hang - 1 <= size)
if (Goboard[hang - 1][lie] != 0 && Goboard[hang - 1][lie] != num)
cnt++;
}
break;
}
}
return cnt;
}
void Gobang::print()
{
cout << endl;
for (int i = 1; i <= size; i++)
cout << "__";
cout << "【当前棋盘】";
for (int i = 1; i <= size; i++)
cout << "__";
cout << endl << endl;
for (int i = 0; i <= size; i++)
{
for (int j = 0; j <= size; j++)
{
if (i == 0 || j == 0)
cout << setw(4) << Goboard[i][j] << setw(4);
else
{
switch (Goboard[i][j])
{
case 0:
cout << setw(4) << "十" << setw(4);
break;
case 1:
cout << setw(4) << "●" << setw(4);
break;
case 2:
cout << setw(4) << "〇" << setw(4);
break;
}
}
}
cout << endl << endl;
}
}
Gobang::~Gobang()
{
for (int i = 0; i <= size; i++)
delete[]Goboard[i];
delete[]Goboard;
} | [
"[email protected]"
] | |
1b2a6a3aad8d120a0ee0d27189bf66f84b8571e0 | 2354b55f71c5df8a06cd89d3f8b95bc806fe841c | /avdev-jni/src/main/cpp/dependencies/windows/mf/include/MFTypeConverter.h | a4b4473dddcb629acaab65d2dee8d863b0ed7cac | [
"Apache-2.0"
] | permissive | lectureStudio/avdev | 220c1379a5f2e06f726dab3026c997278611d7e8 | 02b980705565ed2dcf3eacc4992bdf2f244f24a0 | refs/heads/main | 2023-03-30T12:26:19.975509 | 2021-03-23T14:30:30 | 2021-03-23T14:30:30 | 349,114,682 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,523 | h | /*
* Copyright 2016 Alex Andres
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AVDEV_MF_TYPE_CONVERTER_H_
#define AVDEV_MF_TYPE_CONVERTER_H_
#include "AudioFormat.h"
#include "PictureFormat.h"
#include "PictureControl.h"
#include "CameraControl.h"
#include <unordered_map>
#include <Strmif.h>
#include <Ks.h>
#include <Ksmedia.h>
namespace avdev
{
namespace MFTypeConverter
{
struct GUIDHasher
{
std::size_t operator()(const GUID & guid) const
{
std::string d4;
d4 += guid.Data4[0];
d4 += guid.Data4[1];
d4 += guid.Data4[2];
d4 += guid.Data4[3];
d4 += guid.Data4[4];
d4 += guid.Data4[5];
d4 += guid.Data4[6];
d4 += guid.Data4[7];
std::size_t h1 = std::hash<unsigned long>()(guid.Data1);
std::size_t h2 = std::hash<unsigned short>()(guid.Data2);
std::size_t h3 = std::hash<unsigned short>()(guid.Data3);
std::size_t h4 = std::hash<std::string>()(d4);
return h1 ^ (h2 << 1) ^ (h3 << 1) ^ (h4 << 1);
}
};
using PictureControlMap = std::unordered_map<KSPROPERTY_VIDCAP_VIDEOPROCAMP, PictureControlType>;
using CameraControlMap = std::unordered_map<KSPROPERTY_VIDCAP_CAMERACONTROL, CameraControlType>;
using PixelFormatMap = std::unordered_map<const GUID, const PixelFormat, GUIDHasher>;
const PictureControlMap getPictureControlMap();
const CameraControlMap getCameraControlMap();
const SampleFormat toSampleFormat(const GUID & apiFormat, UINT32 bitsPerSample);
const GUID toApiType(const SampleFormat & format);
const PixelFormat toPixelFormat(const GUID & apiFormat);
const GUID toApiType(const PixelFormat & format);
const PictureControlType toPictureControlType(const KSPROPERTY_VIDCAP_VIDEOPROCAMP & apiType);
const KSPROPERTY_VIDCAP_VIDEOPROCAMP toApiType(const PictureControlType & type);
const CameraControlType toCameraControlType(const KSPROPERTY_VIDCAP_CAMERACONTROL & apiFormat);
const KSPROPERTY_VIDCAP_CAMERACONTROL toApiType(const CameraControlType & type);
}
}
#endif | [
"[email protected]"
] | |
86fec8fbb7078a6016d5635d0e4e1e3fc8677d29 | 2d55b0e0a580096e6b6e5304a153e9fad6266134 | /Shadow_LR/src/ChromacityShadRem.cpp | 14b9a8274e44742325028e9456b56f0d4556b563 | [] | no_license | changruowang/ShadowDetct_LR | 940a3913f26e3a0eff5283faa096e3690e316bc6 | ff75b71a4e486be71a8d5b806a17da9b03354809 | refs/heads/master | 2020-05-23T22:12:03.235976 | 2019-05-16T06:27:48 | 2019-05-16T06:27:48 | 186,968,859 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,453 | cpp | // Copyright (C) 2011 NICTA (www.nicta.com.au)
// Copyright (C) 2011 Andres Sanin
//
// This file is provided without any warranty of fitness for any purpose.
// You can redistribute this file and/or modify it under the terms of
// the GNU General Public License (GPL) as published by the
// Free Software Foundation, either version 3 of the License
// or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info)
#include <cv.h>
#include <opencv2/imgproc/imgproc.hpp>
#include "ChromacityShadRem.h"
#include "utils/ConnCompGroup.h"
ChromacityShadRem::ChromacityShadRem(const ChromacityShadRemParams& params) {
this->params = params;
}
ChromacityShadRem::~ChromacityShadRem() {
}
void ChromacityShadRem::removeShadows(const cv::Mat& frame, const cv::Mat& fgMask, const cv::Mat& bg, cv::Mat& srMask) {
ConnCompGroup fg(fgMask);
fgMask.copyTo(srMask);
ConnCompGroup darkPixels;
ConnCompGroup shadows;
cv::Mat hsvFrame, hsvBg;
cv::cvtColor(frame, hsvFrame, CV_BGR2HSV);
cv::cvtColor(bg, hsvBg, CV_BGR2HSV);
extractDarkPixels(hsvFrame, fg, hsvBg, darkPixels);
extractShadows(hsvFrame, darkPixels, hsvBg, shadows);
srMask.setTo(0, shadows.mask);
if (params.cleanSrMask) {
ConnCompGroup ccg;
ccg.update(srMask, true, true);
ccg.mask.copyTo(srMask);
}
}
void ChromacityShadRem::extractDarkPixels(const cv::Mat& hsvFrame, const ConnCompGroup& fg, const cv::Mat& hsvBg,
ConnCompGroup& darkPixels) {
cv::Mat mask(hsvFrame.size(), CV_8U, cv::Scalar(0));
for (int cc = 0; cc < (int) fg.comps.size(); ++cc) {
const ConnComp& object = fg.comps[cc];
for (int p = 0; p < (int) object.pixels.size(); ++p) {
int x = object.pixels[p].x;
int y = object.pixels[p].y;
const uchar* hsvFramePtr = hsvFrame.ptr(y) + x * 3;
const uchar* hsvBgPtr = hsvBg.ptr(y) + x * 3;
float vRatio = (float) hsvFramePtr[2] / hsvBgPtr[2];
if (vRatio > params.vThreshLower && vRatio < params.vThreshUpper) {
uchar* maskPtr = mask.ptr(y);
maskPtr[x] = 255;
}
}
}
darkPixels.update(mask);
}
void ChromacityShadRem::extractShadows(const cv::Mat& hsvFrame, const ConnCompGroup& darkPixels,
const cv::Mat& hsvBg, ConnCompGroup& shadows) {
cv::Mat mask(hsvFrame.size(), CV_8U, cv::Scalar(0));
for (int cc = 0; cc < (int) darkPixels.comps.size(); ++cc) {
const ConnComp& object = darkPixels.comps[cc];
for (int p = 0; p < (int) object.pixels.size(); ++p) {
int x = object.pixels[p].x;
int y = object.pixels[p].y;
int hDiffSum = 0;
int sDiffSum = 0;
int winArea = 0;
int minY = std::max(y - params.winSize, 0);
int maxY = std::min(y + params.winSize, hsvFrame.rows - 1);
int minX = std::max(x - params.winSize, 0);
int maxX = std::min(x + params.winSize, hsvFrame.cols - 1);
for (int i = minY; i <= maxY; ++i) {
const uchar* hsvFramePtr = hsvFrame.ptr(i);
const uchar* hsvBgPtr = hsvBg.ptr(i);
for (int j = minX; j <= maxX; ++j) {
int hDiff = CV_IABS(hsvFramePtr[j * 3] - hsvBgPtr[j * 3]);
if (hDiff > 90) {
hDiff = 180 - hDiff;
}
hDiffSum += hDiff;
int sDiff = hsvFramePtr[j * 3 + 1] - hsvBgPtr[j * 3 + 1];
sDiffSum += sDiff;
++winArea;
}
}
bool hIsShadow = (hDiffSum / winArea < params.hThresh);
bool sIsShadow = (sDiffSum / winArea < params.sThresh);
if (hIsShadow && sIsShadow) {
uchar* maskPtr = mask.ptr(y);
maskPtr[x] = 255;
}
}
}
shadows.update(mask);
}
| [
"[email protected]"
] | |
dcb26d4a5609164aaab4d1b87bd8ccbdfe14621b | ba53b593ea45357cf3b52230bc7c0adb50837dda | /src/operators/RangeOnSubscribe.hpp | f5564c8125f6c260f67ecc9e68b44faeb54de19e | [] | no_license | Gebrechlich/tinyRxCpp | efe182d8286ef03c44972eabe355087107f8dfbe | 0e2f2310011e8d2d4ed6e5389f64521c36e976a1 | refs/heads/master | 2020-12-24T06:39:55.353828 | 2017-03-24T11:59:54 | 2017-03-24T11:59:54 | 57,379,516 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 574 | hpp | #ifndef RANGEONSUBSCRIBE_HPP
#define RANGEONSUBSCRIBE_HPP
#include "OnSubscribeBase.hpp"
template<typename T>
class RangeOnSubscribe : public OnSubscribeBase<T>
{
public:
RangeOnSubscribe(T start, T count) : start(start), count(count)
{}
void operator()(const SubscriberPtrType<T>& t) override
{
T countInner(count);
for(T i = start; countInner > 0 && !t->isUnsubscribe(); ++i, --countInner)
{
t->onNext(i);
}
t->onComplete();
}
private:
T start;
T count;
};
#endif // RANGEONSUBSCRIBE_HPP
| [
"[email protected]"
] | |
6bab52d7bee96866c35c0de1f7f35e0a13827f06 | 382eb97bb79478130f83d50877148188ec7ff51a | /libraries/plugins/src/plugins/Plugin.h | eac355b47ddab756dc360f034aa2e13bea135921 | [
"Apache-2.0"
] | permissive | rabedik/hifi | d6cb72e9426d69714b06a3f842b2a4919f52ed18 | 08986dcb17ece932f567ab27cf1f0b1fdecf41e1 | refs/heads/master | 2021-01-16T20:55:40.135499 | 2015-08-28T23:36:00 | 2015-08-28T23:36:00 | 41,653,396 | 1 | 0 | null | 2015-08-31T03:17:57 | 2015-08-31T03:17:56 | null | UTF-8 | C++ | false | false | 1,238 | h | //
// Created by Bradley Austin Davis on 2015/08/08
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#pragma once
#include <QString>
#include <QObject>
#include "Forward.h"
class Plugin : public QObject {
public:
virtual const QString& getName() const = 0;
virtual bool isSupported() const;
static void setContainer(PluginContainer* container);
/// Called when plugin is initially loaded, typically at application start
virtual void init();
/// Called when application is shutting down
virtual void deinit();
/// Called when a plugin is being activated for use. May be called multiple times.
virtual void activate() = 0;
/// Called when a plugin is no longer being used. May be called multiple times.
virtual void deactivate() = 0;
/**
* Called by the application during it's idle phase. If the plugin needs to do
* CPU intensive work, it should launch a thread for that, rather than trying to
* do long operations in the idle call
*/
virtual void idle();
protected:
static PluginContainer* CONTAINER;
};
| [
"[email protected]"
] | |
e32ed3b460565fc23ceb093940690f19613b1273 | 370b105e552baa787557cb58de5c13970c8a6be7 | /core/src/condition_node.cpp | 1861a56a202dd5b0cdac42fbc58fa93bd5c5d8a2 | [
"MIT"
] | permissive | gonnavis/youbot | 94108dbab80634c25a14ea7df1f5bf3d9e1f9bab | 23e7cd875d4598f4a439dce6835b17ca97e87135 | refs/heads/master | 2023-03-15T13:07:24.316861 | 2020-05-16T09:34:06 | 2020-05-16T09:34:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,432 | cpp | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <condition_node.h>
#include <string>
BT::ConditionNode::ConditionNode(std::string name) : LeafNode::LeafNode(name)
{
type_ = BT::CONDITION_NODE;
}
BT::ConditionNode::~ConditionNode() {}
void BT::ConditionNode::Halt() {}
int BT::ConditionNode::DrawType()
{
return BT::CONDITION;
}
| [
"[email protected]"
] | |
1f97de01eab58e93f154ba6e0b4bbf05965d0a5c | 434581ae09440e2150d1d96a4e18c872bda54909 | /common/CompositeShape.cpp | 478ad5208f758c4828152d0778e0dccc8293d1e5 | [] | no_license | Spectra456/LabsCPP2017 | 2e11ed0cb69979e0d5c3b09e85fe1c23a8b78ebe | 4b3263458c1244d48d12514cec1df67428a54eab | refs/heads/master | 2020-04-23T16:06:01.953835 | 2019-02-18T13:12:04 | 2019-02-18T13:12:04 | 171,286,671 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,127 | cpp | #include <iostream>
#include <stdexcept>
#include <cmath>
#include "CompositeShape.hpp"
CompositeShape::CompositeShape(const std::shared_ptr<Shape> &shape):
shapes_(new std::shared_ptr<Shape>[1]),
size_(1)
{
if (shape == nullptr)
{
throw std::invalid_argument("invalid pointer");
}
shapes_[0] = shape;
}
CompositeShape::CompositeShape(const CompositeShape &composite_shape):
size_(composite_shape.size_)
{
std::unique_ptr <std::shared_ptr<Shape>[]> shapes_copy(new std::shared_ptr<Shape>[size_]);
for (size_t i = 0; i < size_; i ++)
{
shapes_copy[i] = composite_shape.shapes_[i];
}
shapes_.swap(shapes_copy);
}
CompositeShape & CompositeShape::operator=(const CompositeShape &composite_shape)
{
if (this != &composite_shape)
{
size_ = composite_shape.size_;
std::unique_ptr <std::shared_ptr<Shape>[]> shapes_copy(new std::shared_ptr<Shape>[size_]);
for (size_t i = 0; i < size_; i ++)
{
shapes_copy[i] = composite_shape.shapes_[i];
}
shapes_.swap(shapes_copy);
}
return *this;
}
bool CompositeShape::operator==(const CompositeShape &composite_shape_1)
{
if (composite_shape_1.size_ != size_)
{
return false;
}
size_t i = 0;
while (i < composite_shape_1.size_)
{
if (composite_shape_1.shapes_[i] == shapes_[i])
{
i ++;
}
else
{
return false;
}
}
return true;
}
void CompositeShape::addShape(const std::shared_ptr<Shape> &shape)
{
if (shape == nullptr)
{
throw std::invalid_argument("invalid pointer");
}
std::unique_ptr <std::shared_ptr<Shape>[]> shapes_temp(new std::shared_ptr<Shape>[size_ + 1]);
for (size_t i = 0; i < size_; i ++)
{
shapes_temp[i] = shapes_[i];
}
shapes_temp[size_] = shape;
size_ ++;
shapes_.swap(shapes_temp);
}
std::string CompositeShape::getName() const
{
return "composite shape";
}
double CompositeShape::getArea() const
{
double area = shapes_[0] -> getArea();
for (size_t i = 1; i < size_; i ++)
{
area += shapes_[i] -> getArea();
}
return area;
}
rectangle_t CompositeShape::getFrameRect() const
{
rectangle_t shape_frame_rect = shapes_[0] -> getFrameRect();
double shape_frame_rect_top_left_x = shape_frame_rect.pos.x - shape_frame_rect.width / 2;
double shape_frame_rect_top_left_y = shape_frame_rect.pos.y + shape_frame_rect.height / 2;
double shape_frame_rect_bottom_right_x = shape_frame_rect.pos.x + shape_frame_rect.width / 2;
double shape_frame_rect_bottom_right_y = shape_frame_rect.pos.y - shape_frame_rect.height / 2;
point_t top_left = {shape_frame_rect_top_left_x, shape_frame_rect_top_left_y};
point_t bottom_right = {shape_frame_rect_bottom_right_x, shape_frame_rect_bottom_right_y};
for (size_t i = 1; i < size_; i ++)
{
shape_frame_rect = shapes_[i] -> getFrameRect();
shape_frame_rect_top_left_x = shape_frame_rect.pos.x - shape_frame_rect.width / 2;
shape_frame_rect_top_left_y = shape_frame_rect.pos.y + shape_frame_rect.height / 2;
shape_frame_rect_bottom_right_x = shape_frame_rect.pos.x + shape_frame_rect.width / 2;
shape_frame_rect_bottom_right_y = shape_frame_rect.pos.y - shape_frame_rect.height / 2;
if (shape_frame_rect_top_left_x < top_left.x)
{
top_left.x = shape_frame_rect_top_left_x;
}
if (shape_frame_rect_top_left_y > top_left.y)
{
top_left.y = shape_frame_rect_top_left_y;
}
if (shape_frame_rect_bottom_right_x > bottom_right.x)
{
bottom_right.x = shape_frame_rect_bottom_right_x;
}
if (shape_frame_rect_bottom_right_y < bottom_right.y)
{
bottom_right.y = shape_frame_rect_bottom_right_y;
}
}
point_t center = {(top_left.x + bottom_right.x) / 2, (top_left.y + bottom_right.y) / 2};
return {center, bottom_right.x - top_left.x, top_left.y - bottom_right.y};
}
void CompositeShape::move(double dx, double dy)
{
for (size_t i = 0; i < size_; i ++)
{
shapes_[i] -> move(dx, dy);
}
}
void CompositeShape::move(const point_t &pos)
{
point_t center = getFrameRect().pos;
move(pos.x - center.x, pos.y - center.y);
}
void CompositeShape::scale(double x)
{
if (x <= 0)
{
throw std::invalid_argument("invalid scaling factor");
}
point_t center = getFrameRect().pos;
for (size_t i = 0; i < size_; i ++)
{
point_t shape_center = shapes_[i] -> getFrameRect().pos;
shapes_[i] -> move({center.x + x * (shape_center.x - center.x),
center.y + x * (shape_center.y - center.y)});
shapes_[i] -> scale(x);
}
}
void CompositeShape::rotate(double angle)
{
double angle_cos = cos(angle * M_PI / 180);
double angle_sin = sin(angle * M_PI / 180);
point_t center = getFrameRect().pos;
for (size_t i = 0; i < size_; i ++)
{
point_t shape_center = shapes_[i] -> getFrameRect().pos;
shapes_[i] -> move({center.x + angle_cos * (shape_center.x - center.x) - angle_sin *
(shape_center.y - center.y),
center.y + angle_cos * (shape_center.y - center.y) + angle_sin * (shape_center.x - center.x)});
shapes_[i] -> rotate(angle);
}
}
| [
"[email protected]"
] | |
9bd20d4ee30aa4fef75e239130547010b73ba82b | d5928911a9b24dd809b58ccea93463e04bb25435 | /mathematics/ChristmasParty.cpp | f2df7783824d471d234b0a5d151dfa3629eb4615 | [] | no_license | pankajgangwar/cses-problems | 43778d134d7ce8815d62acda63c060d5ee832395 | efb0139fe24f861990cc2da3082686681377142f | refs/heads/main | 2023-03-30T21:22:27.298730 | 2021-03-22T01:07:10 | 2021-03-22T01:07:10 | 330,844,461 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,226 | cpp | #include <stdio.h>
#include <string.h>
#include <iostream>
#include <array>
#include <vector>
#include <queue>
#include <bits/stdc++.h>
#include <chrono>
#define int long long int
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
//Problem : https://cses.fi/problemset/task/1717
//Sol : https://cses.fi/problemset/result/1837696
const int N = 1e6;
const int mod = 1e9 + 7;
int inverseOfNumber[N + 1];
void calculateInverse() {
inverseOfNumber[0] = inverseOfNumber[1] = 1;
for (int i = 2; i <= N; i++) {
inverseOfNumber[i] = inverseOfNumber[mod % i] * (mod - mod / i) % mod;
}
}
int inverseOfFact[N + 1];
void calculateFactorialInv() {
inverseOfFact[0] = inverseOfFact[1] = 1;
for (int i = 2; i <= N; i++) {
inverseOfFact[i] = (inverseOfNumber[i] % mod * inverseOfFact[i - 1] % mod) % mod;
}
}
int fact[N + 1];
void factorial() {
fact[0] = 1;
// n! = n * (n - 1)!
for (int i = 1; i <= N; i++) {
fact[i] = (i * fact[i - 1]) % mod;
}
}
/*
Ways to distribute m mangoes to n people :
1) m identical and n identical:
(m+n-1)!/((n-1)!*(m)!) -> (m + n - 1) C (n-1)
2) m unique and n identical:
(m+n-1)!/((n-1)! -> (m + n - 1) C (n-1) * m!
3) m identical and n unique:
(m+n-1)!/m! -> (m + n - 1) C (n-1) * (n-1)!
4) Both unique
(m+n-1)! -> (m + n - 1) C (n-1) * (n-1)! * m!
*/
/*
Number of dearangments for n different objects
https://brilliant.org/wiki/derangements
!N = N![1 - 1/1! + 1/2! - 1/3! + 1/4! ... 1/N! ]
*/
int32_t main() {
fast_io;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
clock_t tStart = clock();
#endif
calculateInverse();
calculateFactorialInv();
factorial();
int n;
cin >> n;
int ans = 1;
for (int i = 1; i <= n; i++) {
if (i % 2 == 0 ) {
ans = (ans + inverseOfFact[i]) % mod;
} else {
ans = (ans - inverseOfFact[i] + mod) % mod;
}
}
ans = (ans * fact[n]) % mod;
cout << ans << endl;
#ifndef ONLINE_JUDGE
cerr << fixed << setprecision(10) << "\nTime Taken: " << (double)(clock() - tStart) / CLOCKS_PER_SEC << endl;
#endif
return 0;
} | [
"[email protected]"
] | |
9af09c082ae9f08f563d02f78ccee1c899d2b94c | 1555c044e454339f5107a16994e9c1c2c975f24f | /Server/Receiver/Receiver.cpp | 70b4dfbf786fc8f01b7ef9f84b9ba84d6553db41 | [] | no_license | shuiqi2000/swallow | 72a43704538709d8e8dcdd3ca3c58c9a36d15de7 | 764fd31f3d94d4da2c3fbfb48f93d605fdcd7be4 | refs/heads/master | 2021-01-22T14:33:46.394400 | 2013-02-03T13:29:52 | 2013-02-03T13:29:52 | 3,048,043 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 361 | cpp | #include "Receiver.h"
Receiver::Receiver(Network * network)
{
this->network = network;
this->network->setReceiver(this);
}
Receiver::~Receiver(void)
{
if (network != 0){
delete network;
}
}
void Receiver::start(){
network->start();
}
void Receiver::handleData(unsigned char * data){
}
Network * Receiver::getNetwork(){
return network;
}
| [
"[email protected]"
] | |
f9d0c53564215cc17bb76ad8b1da9d138a18e678 | 1f84fd078570475d2510339bab2439b5193af03d | /source/vxRenderAspectDX12/RenderPassGBuffer.h | 514232e3c0b7f46456912718327048692748031a | [
"MIT"
] | permissive | DennisWandschura/vxEngine | df138077cdb9f40461c83e99a8851de593b098f2 | 1396a65f7328aaed50dd34634c65cac561271b9e | refs/heads/master | 2021-01-16T00:17:47.703611 | 2015-10-11T10:44:53 | 2015-10-11T10:44:53 | 32,484,686 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,667 | h | #pragma once
/*
The MIT License (MIT)
Copyright (c) 2015 Dennis Wandschura
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
namespace d3d
{
class ShaderManager;
}
struct ID3D12Device;
class DrawIndexedIndirectCommand;
#include "RenderPass.h"
#include <vxLib/math/Vector.h>
#include "DescriptorHeap.h"
#include <memory>
class RenderPassGBuffer : public RenderPass
{
struct ColdData;
DrawIndexedIndirectCommand* m_drawCmd;
u32 m_buildList;
d3d::DescriptorHeap m_descriptorHeapBuffers;
d3d::DescriptorHeap m_descriptorHeapRt;
d3d::DescriptorHeap m_descriptorHeapDs;
std::unique_ptr<ColdData> m_coldData;
void createTextureDescriptions();
bool loadShaders(d3d::ShaderManager* shaderManager);
bool createRootSignature(ID3D12Device* device);
bool createPipelineState(ID3D12Device* device, d3d::ShaderManager* shaderManager);
bool createTextures(d3d::ResourceManager* resourceManager, const vx::uint2 &resolution, ID3D12Device* device);
bool createDescriptorHeap(ID3D12Device* device);
void createBufferViews(d3d::ResourceManager* resourceManager, ID3D12Device* device);
public:
explicit RenderPassGBuffer(DrawIndexedIndirectCommand* drawCmd);
~RenderPassGBuffer();
void getRequiredMemory(u64* heapSizeBuffer, u32* bufferCount, u64* heapSizeTexture, u32* textureCount, u64* heapSizeRtDs, u32* rtDsCount, ID3D12Device* device) override;
bool createData(ID3D12Device* device) override;
bool initialize(ID3D12Device* device, d3d::CommandAllocator* allocators, u32 frameCount) override;
void shutdown() override;
void buildCommands(d3d::CommandAllocator* currentAllocator, u32 frameIndex) override;
void submitCommands(Graphics::CommandQueue* queue) override;
}; | [
"[email protected]"
] | |
ecef9a3906d8ef9ba615931c1d1baadf76a06afd | e3b8aec0a025cd9ccc6a7826d4a7deca43c9710a | /src/ScreenDebugOverlay.h | 949ecf7a2966034a9da0a248e02fa5098ff90838 | [] | no_license | SamDecrock/stepmania5-http-post-scores | ee2328a7ab48d0a027785a3959f82725793e49e7 | 100c2759d3204a4334a58f50f2de5f94d2beec3e | refs/heads/master | 2020-05-17T18:59:30.912630 | 2012-12-10T18:56:33 | 2012-12-10T18:56:33 | 7,096,072 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,148 | h | /* ScreenDebugOverlay - credits and statistics drawn on top of everything else. */
#ifndef ScreenDebugOverlay_H
#define ScreenDebugOverlay_H
#include "Screen.h"
#include "BitmapText.h"
#include "Quad.h"
void ChangeVolume( float fDelta );
void ChangeVisualDelay( float fDelta );
class ScreenDebugOverlay : public Screen
{
public:
virtual ~ScreenDebugOverlay();
virtual void Init();
bool OverlayInput( const InputEventPlus &input );
void Update( float fDeltaTime );
private:
void UpdateText();
RString GetCurrentPageName() const { return m_asPages[m_iCurrentPage]; }
vector<RString> m_asPages;
int m_iCurrentPage;
bool m_bForcedHidden;
Quad m_Quad;
BitmapText m_textHeader;
vector<BitmapText*> m_vptextPages;
vector<BitmapText*> m_vptextButton;
vector<BitmapText*> m_vptextFunction;
};
#endif
/*
* (c) 2001-2005 Chris Danford, Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
| [
"[email protected]"
] | |
8072cc8529b3a2625f31eb68cdaef1c9c04d1d9b | 3860008e9d34404d400eff8ecca916b9d91232c8 | /realizer/glayout.h | 6fa0ccd9b56bbc7247a10aaece638434ef247d78 | [
"MIT"
] | permissive | codetorex/realizer | 39a847697671fe4ae31f5af9cf0e8570fb192250 | adb06d3138cc039764c0859177a669fa485578bf | refs/heads/master | 2020-12-21T15:56:57.478620 | 2020-01-27T12:03:33 | 2020-01-27T12:03:33 | 236,478,627 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 753 | h | #ifndef GLAYOUT_H
#define GLAYOUT_H
#include "mrectangle.h"
class GObject;
class GAlign
{
public:
void Align( IRectangle& srcRect, const IRectangle& dstRect, Alignment alignment);
};
/**
* Base layout algorithm for laying out strategy of containers.
*/
class GLayout
{
public:
static GLayout Instance;
virtual IRectangle Layout(GObject* container, bool measureOnly);
};
class GLayoutHorizontalOverflow: public GLayout
{
public:
static GLayoutHorizontalOverflow Instance;
virtual IRectangle Layout(GObject* container, bool measureOnly);
};
class GLayoutVertical: public GLayout
{
public:
static GLayoutVertical Instance;
virtual IRectangle Layout(GObject* container, bool measureOnly);
};
#endif | [
"[email protected]"
] |
Subsets and Splits