blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 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
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
c502dd86625144c3753bcfca74e13a6eaa6a8977
5cf90b2be2f265e7f02144192dba4a26cef15756
/skia/tests/TessellatingPathRendererTests.cpp
9af45ee51e8d70b41d0fe0dc35cb4c618a578be3
[ "BSD-3-Clause", "MIT" ]
permissive
jiangkang/renderer-dog
b73f1d1d0d5d61ea9a5da81983eeb536d6d791da
8081732e2b4dbdb97c8d1f5e23f9e52c6362ff85
refs/heads/master
2021-07-07T21:49:57.293616
2020-09-13T16:31:34
2020-09-13T16:31:34
174,357,799
0
0
MIT
2020-09-13T11:08:16
2019-03-07T14:18:53
C++
UTF-8
C++
false
false
31,181
cpp
/* * Copyright 2015 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "Test.h" #include "GrClip.h" #include "GrContext.h" #include "GrContextPriv.h" #include "GrShape.h" #include "GrStyle.h" #include "SkGradientShader.h" #include "SkPath.h" #include "SkShaderBase.h" #include "effects/GrPorterDuffXferProcessor.h" #include "ops/GrTessellatingPathRenderer.h" /* * These tests pass by not crashing, hanging or asserting in Debug. */ // Tests active edges made inactive by splitting. // Also tests active edge list forced into an invalid ordering by // splitting (mopped up in cleanup_active_edges()). static SkPath create_path_0() { SkPath path; path.moveTo(229.127044677734375f, 67.34100341796875f); path.lineTo(187.8097381591796875f, -6.7729740142822265625f); path.lineTo(171.411407470703125f, 50.94266510009765625f); path.lineTo(245.5253753662109375f, 9.6253643035888671875f); path.moveTo(208.4683990478515625f, 30.284009933471679688f); path.lineTo(171.411407470703125f, 50.94266510009765625f); path.lineTo(187.8097381591796875f, -6.7729740142822265625f); return path; } // Intersections which fall exactly on the current vertex, and require // a restart of the intersection checking. static SkPath create_path_1() { SkPath path; path.moveTo(314.483551025390625f, 486.246002197265625f); path.lineTo(385.41949462890625f, 532.8087158203125f); path.lineTo(373.232879638671875f, 474.05938720703125f); path.lineTo(326.670166015625f, 544.995361328125f); path.moveTo(349.951507568359375f, 509.52734375f); path.lineTo(373.232879638671875f, 474.05938720703125f); path.lineTo(385.41949462890625f, 532.8087158203125f); return path; } // Tests active edges which are removed by splitting. static SkPath create_path_2() { SkPath path; path.moveTo(343.107391357421875f, 613.62176513671875f); path.lineTo(426.632415771484375f, 628.5740966796875f); path.lineTo(392.3460693359375f, 579.33544921875f); path.lineTo(377.39373779296875f, 662.86041259765625f); path.moveTo(384.869873046875f, 621.097900390625f); path.lineTo(392.3460693359375f, 579.33544921875f); path.lineTo(426.632415771484375f, 628.5740966796875f); return path; } // Collinear edges merged in set_top(). // Also, an intersection between left and right enclosing edges which // falls above the current vertex. static SkPath create_path_3() { SkPath path; path.moveTo(545.95751953125f, 791.69854736328125f); path.lineTo(612.05816650390625f, 738.494140625f); path.lineTo(552.4056396484375f, 732.0460205078125f); path.lineTo(605.61004638671875f, 798.14666748046875f); path.moveTo(579.00787353515625f, 765.0963134765625f); path.lineTo(552.4056396484375f, 732.0460205078125f); path.lineTo(612.05816650390625f, 738.494140625f); return path; } // Tests active edges which are made inactive by set_top(). static SkPath create_path_4() { SkPath path; path.moveTo(819.2725830078125f, 751.77447509765625f); path.lineTo(820.70904541015625f, 666.933837890625f); path.lineTo(777.57049560546875f, 708.63592529296875f); path.lineTo(862.4111328125f, 710.0723876953125f); path.moveTo(819.99078369140625f, 709.3541259765625f); path.lineTo(777.57049560546875f, 708.63592529296875f); path.lineTo(820.70904541015625f, 666.933837890625f); return path; } static SkPath create_path_5() { SkPath path; path.moveTo(823.33209228515625f, 749.052734375f); path.lineTo(823.494873046875f, 664.20013427734375f); path.lineTo(780.9871826171875f, 706.5450439453125f); path.lineTo(865.8397216796875f, 706.70782470703125f); path.moveTo(823.4134521484375f, 706.6263427734375f); path.lineTo(780.9871826171875f, 706.5450439453125f); path.lineTo(823.494873046875f, 664.20013427734375f); return path; } static SkPath create_path_6() { SkPath path; path.moveTo(954.862548828125f, 562.8349609375f); path.lineTo(899.32818603515625f, 498.679443359375f); path.lineTo(895.017578125f, 558.52435302734375f); path.lineTo(959.17315673828125f, 502.990081787109375f); path.moveTo(927.0953369140625f, 530.7572021484375f); path.lineTo(895.017578125f, 558.52435302734375f); path.lineTo(899.32818603515625f, 498.679443359375f); return path; } static SkPath create_path_7() { SkPath path; path.moveTo(958.5330810546875f, 547.35516357421875f); path.lineTo(899.93109130859375f, 485.989013671875f); path.lineTo(898.54901123046875f, 545.97308349609375f); path.lineTo(959.9151611328125f, 487.37109375f); path.moveTo(929.2320556640625f, 516.67205810546875f); path.lineTo(898.54901123046875f, 545.97308349609375f); path.lineTo(899.93109130859375f, 485.989013671875f); return path; } static SkPath create_path_8() { SkPath path; path.moveTo(389.8609619140625f, 369.326873779296875f); path.lineTo(470.6290283203125f, 395.33697509765625f); path.lineTo(443.250030517578125f, 341.9478759765625f); path.lineTo(417.239959716796875f, 422.7159423828125f); path.moveTo(430.244964599609375f, 382.3319091796875f); path.lineTo(443.250030517578125f, 341.9478759765625f); path.lineTo(470.6290283203125f, 395.33697509765625f); return path; } static SkPath create_path_9() { SkPath path; path.moveTo(20, 20); path.lineTo(50, 80); path.lineTo(20, 80); path.moveTo(80, 50); path.lineTo(50, 50); path.lineTo(20, 50); return path; } static SkPath create_path_10() { SkPath path; path.moveTo(257.19439697265625f, 320.876617431640625f); path.lineTo(190.113037109375f, 320.58978271484375f); path.lineTo(203.64404296875f, 293.8145751953125f); path.moveTo(203.357177734375f, 360.896026611328125f); path.lineTo(216.88824462890625f, 334.120819091796875f); path.lineTo(230.41925048828125f, 307.345611572265625f); return path; } // A degenerate segments case, where both upper and lower segments of // a split edge must remain active. static SkPath create_path_11() { SkPath path; path.moveTo(231.9331207275390625f, 306.2012939453125f); path.lineTo(191.4859161376953125f, 306.04547119140625f); path.lineTo(231.0659332275390625f, 300.2642822265625f); path.moveTo(189.946807861328125f, 302.072265625f); path.lineTo(179.79705810546875f, 294.859771728515625f); path.lineTo(191.0016021728515625f, 296.165679931640625f); path.moveTo(150.8942108154296875f, 304.900146484375f); path.lineTo(179.708892822265625f, 297.849029541015625f); path.lineTo(190.4742279052734375f, 299.11895751953125f); return path; } // Handle the case where edge.dist(edge.fTop) != 0.0. static SkPath create_path_12() { SkPath path; path.moveTo( 0.0f, 400.0f); path.lineTo( 138.0f, 202.0f); path.lineTo( 0.0f, 202.0f); path.moveTo( 12.62693023681640625f, 250.57464599609375f); path.lineTo( 8.13896942138671875f, 254.556884765625f); path.lineTo(-18.15641021728515625f, 220.40203857421875f); path.lineTo(-15.986493110656738281f, 219.6513519287109375f); path.moveTo( 36.931194305419921875f, 282.485504150390625f); path.lineTo( 15.617521286010742188f, 261.2901611328125f); path.lineTo( 10.3829498291015625f, 252.565765380859375f); path.lineTo(-16.165292739868164062f, 222.646026611328125f); return path; } // A degenerate segments case which exercises inactive edges being // made active by splitting. static SkPath create_path_13() { SkPath path; path.moveTo(690.62127685546875f, 509.25555419921875f); path.lineTo(99.336181640625f, 511.71405029296875f); path.lineTo(708.362548828125f, 512.4349365234375f); path.lineTo(729.9940185546875f, 516.3114013671875f); path.lineTo(738.708984375f, 518.76995849609375f); path.lineTo(678.3463134765625f, 510.0819091796875f); path.lineTo(681.21795654296875f, 504.81378173828125f); path.moveTo(758.52764892578125f, 521.55963134765625f); path.lineTo(719.1549072265625f, 514.50372314453125f); path.lineTo(689.59063720703125f, 512.0628662109375f); path.lineTo(679.78216552734375f, 507.447845458984375f); return path; } // Tests vertices which become "orphaned" (ie., no connected edges) // after simplification. static SkPath create_path_14() { SkPath path; path.moveTo(217.326019287109375f, 166.4752960205078125f); path.lineTo(226.279266357421875f, 170.929473876953125f); path.lineTo(234.3973388671875f, 177.0623626708984375f); path.lineTo(262.0921630859375f, 188.746124267578125f); path.moveTo(196.23638916015625f, 174.0722198486328125f); path.lineTo(416.15277099609375f, 180.138214111328125f); path.lineTo(192.651947021484375f, 304.0228271484375f); return path; } static SkPath create_path_15() { SkPath path; path.moveTo( 0.0f, 0.0f); path.lineTo(10000.0f, 0.0f); path.lineTo( 0.0f, -1.0f); path.lineTo(10000.0f, 0.000001f); path.lineTo( 0.0f, -30.0f); return path; } // Reduction of Nebraska-StateSeal.svg. Floating point error causes the // same edge to be added to more than one poly on the same side. static SkPath create_path_16() { SkPath path; path.moveTo(170.8199920654296875, 491.86700439453125); path.lineTo(173.7649993896484375, 489.7340087890625); path.lineTo(174.1450958251953125, 498.545989990234375); path.lineTo( 171.998992919921875, 500.88201904296875); path.moveTo(168.2922515869140625, 498.66265869140625); path.lineTo(169.8589935302734375, 497.94500732421875); path.lineTo( 172, 500.88299560546875); path.moveTo( 169.555267333984375, 490.70111083984375); path.lineTo(173.7649993896484375, 489.7340087890625); path.lineTo( 170.82000732421875, 491.86700439453125); return path; } // A simple concave path. Test this with a non-invertible matrix. static SkPath create_path_17() { SkPath path; path.moveTo(20, 20); path.lineTo(80, 20); path.lineTo(30, 30); path.lineTo(20, 80); return path; } // A shape with a vertex collinear to the right hand edge. // This messes up find_enclosing_edges. static SkPath create_path_18() { SkPath path; path.moveTo(80, 20); path.lineTo(80, 60); path.lineTo(20, 60); path.moveTo(80, 50); path.lineTo(80, 80); path.lineTo(20, 80); return path; } // Exercises the case where an edge becomes collinear with *two* of its // adjacent neighbour edges after splitting. // This is a reduction from // http://mooooo.ooo/chebyshev-sine-approximation/horner_ulp.svg static SkPath create_path_19() { SkPath path; path.moveTo( 351.99298095703125, 348.23046875); path.lineTo( 351.91876220703125, 347.33984375); path.lineTo( 351.91876220703125, 346.1953125); path.lineTo( 351.90313720703125, 347.734375); path.lineTo( 351.90313720703125, 346.1328125); path.lineTo( 351.87579345703125, 347.93359375); path.lineTo( 351.87579345703125, 345.484375); path.lineTo( 351.86407470703125, 347.7890625); path.lineTo( 351.86407470703125, 346.2109375); path.lineTo( 351.84844970703125, 347.63763427734375); path.lineTo( 351.84454345703125, 344.19232177734375); path.lineTo( 351.78204345703125, 346.9483642578125); path.lineTo( 351.758636474609375, 347.18310546875); path.lineTo( 351.75469970703125, 346.75); path.lineTo( 351.75469970703125, 345.46875); path.lineTo( 352.5546875, 345.46875); path.lineTo( 352.55078125, 347.01953125); path.lineTo( 351.75079345703125, 347.02313232421875); path.lineTo( 351.74688720703125, 346.15203857421875); path.lineTo( 351.74688720703125, 347.646148681640625); path.lineTo( 352.5390625, 346.94140625); path.lineTo( 351.73907470703125, 346.94268798828125); path.lineTo( 351.73516845703125, 344.48565673828125); path.lineTo( 352.484375, 346.73828125); path.lineTo( 351.68438720703125, 346.7401123046875); path.lineTo( 352.4765625, 346.546875); path.lineTo( 351.67657470703125, 346.54937744140625); path.lineTo( 352.47265625, 346.75390625); path.lineTo( 351.67266845703125, 346.756622314453125); path.lineTo( 351.66876220703125, 345.612091064453125); return path; } // An intersection above the first vertex in the mesh. // Reduction from http://crbug.com/730687 static SkPath create_path_20() { SkPath path; path.moveTo( 2822128.5, 235.026336669921875); path.lineTo( 2819349.25, 235.3623504638671875); path.lineTo( -340558688, 23.83478546142578125); path.lineTo( -340558752, 25.510419845581054688); path.lineTo( -340558720, 27.18605804443359375); return path; } // An intersection whose result is NaN (due to rounded-to-inf endpoint). static SkPath create_path_21() { SkPath path; path.moveTo(1.7889142061167663539e+38, 39338463358011572224.0); path.lineTo( 1647.4193115234375, -522.603515625); path.lineTo( 1677.74560546875, -529.0028076171875); path.lineTo( 1678.29541015625, -528.7847900390625); path.lineTo( 1637.5167236328125, -519.79266357421875); path.lineTo( 1647.4193115234375, -522.603515625); return path; } // A path which contains out-of-range colinear intersections. static SkPath create_path_23() { SkPath path; path.moveTo( 0, 63.39080047607421875); path.lineTo(-0.70804601907730102539, 63.14350128173828125); path.lineTo(-7.8608899287380243391e-17, 64.14080047607421875); path.moveTo( 0, 64.14080047607421875); path.lineTo(44.285900115966796875, 64.14080047607421875); path.lineTo( 0, 62.64080047607421875); path.moveTo(21.434900283813476562, -0.24732701480388641357); path.lineTo(-0.70804601907730102539, 63.14350128173828125); path.lineTo(0.70804601907730102539, 63.6381988525390625); return path; } // A path which results in infs and nans when conics are converted to quads. static SkPath create_path_24() { SkPath path; path.moveTo(-2.20883e+37f, -1.02892e+37f); path.conicTo(-2.00958e+38f, -9.36107e+37f, -1.7887e+38f, -8.33215e+37f, 0.707107f); path.conicTo(-1.56782e+38f, -7.30323e+37f, 2.20883e+37f, 1.02892e+37f, 0.707107f); path.conicTo(2.00958e+38f, 9.36107e+37f, 1.7887e+38f, 8.33215e+37f, 0.707107f); path.conicTo(1.56782e+38f, 7.30323e+37f, -2.20883e+37f, -1.02892e+37f, 0.707107f); return path; } // An edge collapse event which also collapses a neighbour, requiring // its event to be removed. static SkPath create_path_25() { SkPath path; path.moveTo( 43.44110107421875, 148.15106201171875); path.lineTo( 44.64471435546875, 148.16748046875); path.lineTo( 46.35009765625, 147.403076171875); path.lineTo( 46.45404052734375, 148.34906005859375); path.lineTo( 45.0400390625, 148.54205322265625); path.lineTo( 44.624053955078125, 148.9810791015625); path.lineTo( 44.59405517578125, 149.16107177734375); path.lineTo( 44.877044677734375, 149.62005615234375); path.lineTo(144.373016357421875, 68.8070068359375); return path; } // An edge collapse event causes an edge to become collinear, requiring // its event to be removed. static SkPath create_path_26() { SkPath path; path.moveTo( 43.44110107421875, 148.15106201171875); path.lineTo( 44.64471435546875, 148.16748046875); path.lineTo( 46.35009765625, 147.403076171875); path.lineTo( 46.45404052734375, 148.34906005859375); path.lineTo( 45.0400390625, 148.54205322265625); path.lineTo( 44.624053955078125, 148.9810791015625); path.lineTo( 44.59405517578125, 149.16107177734375); path.lineTo( 44.877044677734375, 149.62005615234375); path.lineTo(144.373016357421875, 68.8070068359375); return path; } // A path which results in non-finite points when stroked and bevelled for AA. static SkPath create_path_27() { SkPath path; path.moveTo(8.5027233009104409507e+37, 1.7503381025241130639e+37); path.lineTo(7.0923661737711584874e+37, 1.4600074517285415699e+37); path.lineTo(7.0848733446033294691e+37, 1.4584649744781838604e+37); path.lineTo(-2.0473916115129349496e+37, -4.2146796450364162012e+36); path.lineTo(2.0473912312177548811e+37, 4.2146815465123165435e+36); return path; } // AA stroking this path produces intersection failures on bevelling. // This should skip the point, but not assert. static SkPath create_path_28() { SkPath path; path.moveTo(-7.5952312625177475154e+21, -2.6819185100266674911e+24); path.lineTo( 1260.3787841796875, 1727.7947998046875); path.lineTo( 1260.5567626953125, 1728.0386962890625); path.lineTo(1.1482511310557754163e+21, 4.054538502765980051e+23); path.lineTo(-7.5952312625177475154e+21, -2.6819185100266674911e+24); return path; } // A quad which generates a huge number of points (>2B) when uniformly // linearized. This should not hang or OOM. static SkPath create_path_29() { SkPath path; path.moveTo(10, 0); path.lineTo(0, 0); path.quadTo(10, 0, 0, 8315084722602508288); return path; } // A path which hangs during simplification. It produces an edge which is // to the left of its own endpoints, which causes an infinte loop in the // right-enclosing-edge splitting. static SkPath create_path_30() { SkPath path; path.moveTo(0.75001740455627441406, 23.051967620849609375); path.lineTo(5.8471612930297851562, 22.731662750244140625); path.lineTo(10.749670028686523438, 22.253145217895507812); path.lineTo(13.115868568420410156, 22.180681228637695312); path.lineTo(15.418928146362304688, 22.340015411376953125); path.lineTo( 17.654022216796875, 22.82159423828125); path.lineTo(19.81632232666015625, 23.715869903564453125); path.lineTo(40, 0); path.lineTo(5.5635203441547955577e-15, 0); path.lineTo(5.5635203441547955577e-15, 47); path.lineTo(-1.4210854715202003717e-14, 21.713298797607421875); path.lineTo(0.75001740455627441406, 21.694292068481445312); path.lineTo(0.75001740455627441406, 23.051967620849609375); return path; } // A path with vertices which become infinite on AA stroking. Should not crash or assert. static SkPath create_path_31() { SkPath path; path.moveTo(2.0257809259190991347e+36, -1244080640); path.conicTo(2.0257809259190991347e+36, -1244080640, 2.0257809259190991347e+36, 0.10976474732160568237, 0.70710676908493041992); path.lineTo(-10036566016, -1954718402215936); path.conicTo(-1.1375507718551896064e+20, -1954721086570496, 10036566016, -1954721086570496, 0.70710676908493041992); return path; } // Reduction from skbug.com/7911 that causes a crash due to splitting a // zombie edge. static SkPath create_path_32() { SkPath path; path.moveTo( 0, 1.0927740941146660348e+24); path.lineTo(2.9333931225865729333e+32, 16476101); path.lineTo(1.0927731573659435417e+24, 1.0927740941146660348e+24); path.lineTo(1.0927740941146660348e+24, 3.7616281094287041715e-37); path.lineTo(1.0927740941146660348e+24, 1.0927740941146660348e+24); path.lineTo(1.3061803026169399536e-33, 1.0927740941146660348e+24); path.lineTo(4.7195362919941370727e-16, -8.4247545146051822591e+32); return path; } // From crbug.com/844873. Crashes trying to merge a zombie edge. static SkPath create_path_33() { SkPath path; path.moveTo( 316.000579833984375, -4338355948977389568); path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0); path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0); path.lineTo( 771.21014404296875, -4338355948977389568.0); path.lineTo( 316.000579833984375, -4338355948977389568.0); path.moveTo( 354.208984375, -4338355948977389568.0); path.lineTo( 773.00177001953125, -4338355948977389568.0); path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0); path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0); path.lineTo( 354.208984375, -4338355948977389568.0); return path; } // From crbug.com/844873. Hangs repeatedly splitting alternate vertices. static SkPath create_path_34() { SkPath path; path.moveTo(10, -1e+20f); path.lineTo(11, 25000); path.lineTo(10, 25000); path.lineTo(11, 25010); return path; } // Reduction from circular_arcs_stroke_and_fill_round GM which // repeatedly splits on the opposite edge from case 34 above. static SkPath create_path_35() { SkPath path; path.moveTo( 16.25, 26.495191574096679688); path.lineTo(32.420825958251953125, 37.377376556396484375); path.lineTo(25.176382064819335938, 39.31851959228515625); path.moveTo( 20, 20); path.lineTo(28.847436904907226562, 37.940830230712890625); path.lineTo(25.17638397216796875, 39.31851959228515625); return path; } // Reduction from crbug.com/843135 where an intersection is found // below the bottom of both intersected edges. static SkPath create_path_36() { SkPath path; path.moveTo(-2791476679359332352, 2608107002026524672); path.lineTo( 0, 11.95427703857421875); path.lineTo(-2781824066779086848, 2599088532777598976); path.lineTo( -7772.6875, 7274); return path; } // Reduction from crbug.com/843135. Exercises a case where an intersection is missed. // This causes bad ordering in the active edge list. static SkPath create_path_37() { SkPath path; path.moveTo(-1.0662557646016024569e+23, 9.9621425197286319718e+22); path.lineTo( -121806400, 113805032); path.lineTo( -120098872, 112209680); path.lineTo( 6.2832999862817380468e-36, 2.9885697364807128906); return path; } // Reduction from crbug.com/851914. static SkPath create_path_38() { SkPath path; path.moveTo(14.400531768798828125, 17.711114883422851562); path.lineTo(14.621990203857421875, 171563104293879808); path.lineTo(14.027951240539550781, 872585759381520384); path.lineTo( 14.0216827392578125, 872665817571917824); path.lineTo(7.699314117431640625, -3417320793833472); path.moveTo(11.606547355651855469, 17.40966796875); path.lineTo( 7642114886926860288, 21.08358001708984375); path.lineTo(11.606547355651855469, 21.08358001708984375); return path; } // Reduction from crbug.com/851409. Exercises collinear last vertex. static SkPath create_path_39() { SkPath path; path.moveTo(2072553216, 0); path.lineTo(2072553216, 1); path.lineTo(2072553472, -13.5); path.lineTo(2072553216, 0); path.lineTo(2072553472, -6.5); return path; } // Another reduction from crbug.com/851409. Exercises two sequential collinear edges. static SkPath create_path_40() { SkPath path; path.moveTo(2072553216, 0); path.lineTo(2072553216, 1); path.lineTo(2072553472, -13); path.lineTo(2072553216, 0); path.lineTo(2072553472, -6); path.lineTo(2072553472, -13); return path; } // Reduction from crbug.com/860453. Tests a case where a "missing" intersection // requires the active edge list to go out-of-order. static SkPath create_path_41() { SkPath path; path.moveTo(72154931603311689728.0, 330.95965576171875); path.lineTo(24053266013925408768.0, 78.11376953125); path.lineTo(1.2031099003292404941e+20, 387.168731689453125); path.lineTo(68859835992355373056.0, 346.55047607421875); path.lineTo(76451708695451009024.0, 337.780029296875); path.moveTo(-20815817797613387776.0, 18065700622522384384.0); path.lineTo(-72144121204987396096.0, 142.855804443359375); path.lineTo(72144121204987396096.0, 325.184783935546875); path.lineTo(1.2347242901040791552e+20, 18065700622522384384.0); return path; } // Reduction from crbug.com/860655. Cause is three collinear edges discovered during // sanitize_contours pass, before the vertices have been found coincident. static SkPath create_path_42() { SkPath path; path.moveTo( 32572426382475264, -3053391034974208); path.lineTo( 521289856, -48865776); path.lineTo( 130322464, -12215873); path.moveTo( 32572426382475264, -3053391034974208); path.lineTo( 521289856, -48865776); path.lineTo( 130322464, -12215873); path.moveTo( 32572426382475264, -3053391034974208); path.lineTo( 32114477642022912, -3010462031544320); path.lineTo( 32111784697528320, -3010209702215680); return path; } // Reduction from crbug.com/866319. Cause is edges that are collinear when tested from // one side, but non-collinear when tested from the other. static SkPath create_path_43() { SkPath path; path.moveTo( 307316821852160, -28808363114496); path.lineTo( 307165222928384, -28794154909696); path.lineTo( 307013691113472, -28779948802048); path.lineTo( 306862159298560, -28765744791552); path.lineTo( 306870313025536, -28766508154880); path.lineTo( 307049695019008, -28783327313920); path.lineTo( 307408660332544, -28816974020608); return path; } static std::unique_ptr<GrFragmentProcessor> create_linear_gradient_processor(GrContext* ctx) { SkPoint pts[2] = { {0, 0}, {1, 1} }; SkColor colors[2] = { SK_ColorGREEN, SK_ColorBLUE }; sk_sp<SkShader> shader = SkGradientShader::MakeLinear( pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode); GrColorSpaceInfo colorSpaceInfo(nullptr, kRGBA_8888_GrPixelConfig); GrFPArgs args(ctx, &SkMatrix::I(), SkFilterQuality::kLow_SkFilterQuality, &colorSpaceInfo); return as_SB(shader)->asFragmentProcessor(args); } using AATypeFlags = GrPathRenderer::AATypeFlags; static void test_path(GrContext* ctx, GrRenderTargetContext* renderTargetContext, const SkPath& path, const SkMatrix& matrix = SkMatrix::I(), AATypeFlags aaTypeFlags = AATypeFlags::kNone, std::unique_ptr<GrFragmentProcessor> fp = nullptr) { GrTessellatingPathRenderer tess; GrPaint paint; paint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc)); if (fp) { paint.addColorFragmentProcessor(std::move(fp)); } GrNoClip noClip; SkIRect clipConservativeBounds = SkIRect::MakeWH(renderTargetContext->width(), renderTargetContext->height()); GrStyle style(SkStrokeRec::kFill_InitStyle); GrShape shape(path, style); GrPathRenderer::DrawPathArgs args{ctx, std::move(paint), &GrUserStencilSettings::kUnused, renderTargetContext, &noClip, &clipConservativeBounds, &matrix, &shape, aaTypeFlags, false}; tess.drawPath(args); } DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) { GrContext* ctx = ctxInfo.grContext(); const GrBackendFormat format = ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType); sk_sp<GrRenderTargetContext> rtc(ctx->priv().makeDeferredRenderTargetContext( format, SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin)); if (!rtc) { return; } ctx->flush(); // Adding discard to appease vulkan validation warning about loading uninitialized data on draw rtc->discard(); test_path(ctx, rtc.get(), create_path_0()); test_path(ctx, rtc.get(), create_path_1()); test_path(ctx, rtc.get(), create_path_2()); test_path(ctx, rtc.get(), create_path_3()); test_path(ctx, rtc.get(), create_path_4()); test_path(ctx, rtc.get(), create_path_5()); test_path(ctx, rtc.get(), create_path_6()); test_path(ctx, rtc.get(), create_path_7()); test_path(ctx, rtc.get(), create_path_8()); test_path(ctx, rtc.get(), create_path_9()); test_path(ctx, rtc.get(), create_path_10()); test_path(ctx, rtc.get(), create_path_11()); test_path(ctx, rtc.get(), create_path_12()); test_path(ctx, rtc.get(), create_path_13()); test_path(ctx, rtc.get(), create_path_14()); test_path(ctx, rtc.get(), create_path_15()); test_path(ctx, rtc.get(), create_path_16()); SkMatrix nonInvertibleMatrix = SkMatrix::MakeScale(0, 0); std::unique_ptr<GrFragmentProcessor> fp(create_linear_gradient_processor(ctx)); test_path(ctx, rtc.get(), create_path_17(), nonInvertibleMatrix, AATypeFlags::kCoverage, std::move(fp)); test_path(ctx, rtc.get(), create_path_18()); test_path(ctx, rtc.get(), create_path_19()); test_path(ctx, rtc.get(), create_path_20(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_21(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_23()); test_path(ctx, rtc.get(), create_path_24()); test_path(ctx, rtc.get(), create_path_25(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_26(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_27(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_28(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_29()); test_path(ctx, rtc.get(), create_path_30()); test_path(ctx, rtc.get(), create_path_31(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_32()); test_path(ctx, rtc.get(), create_path_33()); test_path(ctx, rtc.get(), create_path_34()); test_path(ctx, rtc.get(), create_path_35()); test_path(ctx, rtc.get(), create_path_36()); test_path(ctx, rtc.get(), create_path_37()); test_path(ctx, rtc.get(), create_path_38(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_39()); test_path(ctx, rtc.get(), create_path_40()); test_path(ctx, rtc.get(), create_path_41(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_42()); test_path(ctx, rtc.get(), create_path_43(), SkMatrix(), AATypeFlags::kCoverage); }
[ "jiangkang0504@163.com" ]
jiangkang0504@163.com
9bfcdbdbf8f938745730cec44cd6b9b2b078490d
5932c483784240c78a493cbc349d955c63d3ba9b
/SimpleTfIdfDocument.h
d304ec08a598e5c0f895acc42111f71830ed6a60
[ "MIT" ]
permissive
UCSB-CS32-F15/cs32-f15-lab07-start
cfb00b221f947271bf666335d84b454f477dc02b
bbb7ba5068329cfb0b5a102c4319ee96308f1821
refs/heads/master
2021-01-10T15:20:42.441640
2018-02-07T04:30:24
2018-02-07T04:30:24
46,363,265
0
0
null
null
null
null
UTF-8
C++
false
false
572
h
#ifndef SIMPLE_TFIDF_DOCUMENT_H #define SIMPLE_TFIDF_DOCUMENT_H #include "GenericTfIdfDocument.h" class SimpleTfIdfDocument: public GenericTfIdfDocument { public: SimpleTfIdfDocument(std::string id, std::string text, std::string metadata="") : id(id), text(text), metadata(metadata) {} std::string getId() { return this->id;} std::string getText() { return "stub";} // @@@ DO THE RIGHT THING std::string getMetadata() { return this->metadata;} private: std::string id; std::string text; std::string metadata; }; #endif
[ "pconrad@cs.ucsb.edu" ]
pconrad@cs.ucsb.edu
1476fd99cb70e74cee533d2ef3d0c0c40cce338e
309647935d0f8f507207ecf48d124102c1d7197f
/Utility/memory_parser/Password.h
1f4901f9aa1b7a159acdd5477f26e8dba5bfa642
[ "MIT" ]
permissive
ThomasChevalier/passwordWallet
6b59d8afd48c1bbdc89348798beebfa6ced87e7e
115dbde3e32f2be65071e6f298c4f03ddfe19b09
refs/heads/master
2021-03-27T20:00:34.594894
2020-04-19T17:03:49
2020-04-19T17:03:49
71,448,410
3
0
null
null
null
null
UTF-8
C++
false
false
318
h
#ifndef PASSWORD_HEADER_THOMAS_CHEVALIER #define PASSWORD_HEADER_THOMAS_CHEVALIER #include <cstdint> #include <string> struct Password { typedef uint8_t id_t; Password(); id_t id; uint16_t counter; std::string name; std::string password; std::string userName; }; #endif // PASSWORD_HEADER_THOMAS_CHEVALIER
[ "thomasom.chevalier@gmail.com" ]
thomasom.chevalier@gmail.com
df1315040d5f57018b7be11b3886ec910c0d910e
22ab69eeeecd020fee3e7be74bd5f6f4959cf7e0
/rocsolver/library/src/auxiliary/rocauxiliary_larf.cpp
8753b11bd34bf0424be1149c0caecb572c854553
[ "BSD-2-Clause" ]
permissive
jcarzu/internalDevelop
4ca697dacd2cc5baa5e7a702466e101fb7715cb6
b874d42ce7db68234e4082c5a4e28446469d8460
refs/heads/master
2020-12-10T02:19:55.781116
2020-01-13T00:56:43
2020-01-13T00:56:43
233,480,387
0
0
null
2020-01-13T00:28:14
2020-01-13T00:28:13
null
UTF-8
C++
false
false
3,374
cpp
#include "rocauxiliary_larf.hpp" template <typename T> rocblas_status rocsolver_larf_impl(rocblas_handle handle, const rocblas_side side, const rocblas_int m, const rocblas_int n, T* x, const rocblas_int incx, const T* alpha, T* A, const rocblas_int lda) { if(!handle) return rocblas_status_invalid_handle; //logging is missing ??? if(n < 0 || m < 0 || lda < m || !incx) return rocblas_status_invalid_size; if(!x || !A || !alpha) return rocblas_status_invalid_pointer; rocblas_int stridex = 0; rocblas_int stridea = 0; rocblas_int stridep = 0; rocblas_int batch_count = 1; return rocsolver_larf_template<T>(handle, side, m, n, x, 0, //vector shifted 0 entries incx, stridex, alpha, stridep, A, 0, //matrix shifted 0 entries lda, stridea, batch_count); } /* * =========================================================================== * C wrapper * =========================================================================== */ extern "C" { ROCSOLVER_EXPORT rocblas_status rocsolver_slarf(rocblas_handle handle, const rocblas_side side, const rocblas_int m, const rocblas_int n, float* x, const rocblas_int incx, const float* alpha, float* A, const rocblas_int lda) { return rocsolver_larf_impl<float>(handle, side, m, n, x, incx, alpha, A, lda); } ROCSOLVER_EXPORT rocblas_status rocsolver_dlarf(rocblas_handle handle, const rocblas_side side, const rocblas_int m, const rocblas_int n, double* x, const rocblas_int incx, const double* alpha, double* A, const rocblas_int lda) { return rocsolver_larf_impl<double>(handle, side, m, n, x, incx, alpha, A, lda); } } //extern C
[ "juan.zuniga-anaya@amd.com" ]
juan.zuniga-anaya@amd.com
b5589fb337feef68645274585eb809249bd12867
ef91f0c61520391ad25692c6adebff4aebe8dd09
/ServerNet/Sources/VMIMEMessage.cpp
8d1b73eef7e85b122df90ba1f9b7731956adf56e
[]
no_license
StephaneH/core-XToolbox
77462b758dfae86f86aafb8a9c9e5b34215259c7
c166b76bbd1dfba27c7863f203b158212028222e
refs/heads/master
2021-01-19T06:52:37.703070
2014-11-17T13:35:24
2014-11-17T13:35:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,340
cpp
/* * This file is part of Wakanda software, licensed by 4D under * (i) the GNU General Public License version 3 (GNU GPL v3), or * (ii) the Affero General Public License version 3 (AGPL v3) or * (iii) a commercial license. * This file remains the exclusive property of 4D and/or its licensors * and is protected by national and international legislations. * In any event, Licensee's compliance with the terms and conditions * of the applicable license constitutes a prerequisite to any use of this file. * Except as otherwise expressly stated in the applicable license, * such license does not include any other license or rights on this file, * 4D's and/or its licensors' trademarks and/or other proprietary rights. * Consequently, no title, copyright or other proprietary rights * other than those specified in the applicable license is granted. */ #include "VServerNetPrecompiled.h" #include "VMIMEMessage.h" #include "VNameValueCollection.h" #include "VHTTPHeader.h" #include "HTTPTools.h" #include "VMIMEReader.h" BEGIN_TOOLBOX_NAMESPACE USING_TOOLBOX_NAMESPACE using namespace HTTPTools; //-------------------------------------------------------------------------------------------------- VMIMEMessage::VMIMEMessage() : fEncoding (CONST_MIME_MESSAGE_ENCODING_URL) { } VMIMEMessage::~VMIMEMessage() { Clear(); } void VMIMEMessage::Clear() { fMIMEParts.clear(); } void VMIMEMessage::_AddTextPart (const XBOX::VString& inName, bool inIsInline, const XBOX::VString& inContentType, const XBOX::VString& inContentID, XBOX::VPtrStream& inStream) { VMIMEMessagePart *partSource = new VMIMEMessagePart(); if (NULL != partSource) { partSource->SetName (inName); partSource->SetIsInline(inIsInline); partSource->SetMediaType (inContentType); partSource->SetContentID(inContentID); if (XBOX::VE_OK == inStream.OpenReading()) partSource->PutData (inStream.GetDataPtr(), inStream.GetDataSize()); inStream.CloseReading(); fMIMEParts.push_back (partSource); partSource->Release(); } } void VMIMEMessage::_AddFilePart (const XBOX::VString& inName, const XBOX::VString& inFileName, bool inIsInline, const XBOX::VString& inContentType, const XBOX::VString& inContentID, XBOX::VPtrStream& inStream) { VMIMEMessagePart *partSource = new VMIMEMessagePart(); if (NULL != partSource) { partSource->SetName (inName); partSource->SetFileName (inFileName); partSource->SetIsInline(inIsInline); partSource->SetMediaType (inContentType); partSource->SetContentID(inContentID); if (XBOX::VE_OK == inStream.OpenReading()) partSource->PutData (inStream.GetDataPtr(), inStream.GetDataSize()); inStream.CloseReading(); fMIMEParts.push_back (partSource); partSource->Release(); } } void VMIMEMessage::_AddValuePair (const XBOX::VString& inName, const XBOX::VString& inContentType, void *inData, const XBOX::VSize inDataSize) { VMIMEMessagePart *partSource = new VMIMEMessagePart(); if (NULL != partSource) { partSource->SetName (inName); partSource->SetMediaType (inContentType); partSource->PutData (inData, inDataSize); fMIMEParts.push_back (partSource); partSource->Release(); } } void VMIMEMessage::Load (bool inFromPOST, const XBOX::VString& inContentType, const XBOX::VString& inURLQuery, const XBOX::VStream& inStream) { Clear(); if (inFromPOST) { XBOX::VNameValueCollection params; VHTTPHeader::SplitParameters (inContentType, fEncoding, params); if (HTTPTools::EqualASCIIVString (fEncoding, CONST_MIME_MESSAGE_ENCODING_MULTIPART)) { fBoundary = params.Get (CONST_MIME_MESSAGE_BOUNDARY); _ReadMultipart (inStream); } else { _ReadUrl (inStream); } } else { _ReadUrl (inURLQuery); } } void VMIMEMessage::LoadMail (const VMIMEMailHeader *inHeader, VMemoryBufferStream &inStream) { xbox_assert(inHeader != NULL); if (inHeader->fIsMultiPart) { fBoundary = inHeader->fBoundary; _ReadMultiPartMail(inStream); } else _ReadSinglePartMail(inHeader, inStream); } void VMIMEMessage::_ReadUrl (const XBOX::VStream& inStream) { XBOX::VStream& stream = const_cast<XBOX::VStream&>(inStream); if (XBOX::VE_OK == stream.OpenReading()) { XBOX::VString urlString; XBOX::StErrorContextInstaller filter (XBOX::VE_STREAM_TEXT_CONVERSION_FAILURE, XBOX::VE_STREAM_EOF, XBOX::VE_OK); // YT 28-Mar-2013 - ACI0081219 if (XBOX::VE_OK == stream.GetText (urlString)) _ReadUrl (urlString); stream.CloseReading(); } } void VMIMEMessage::_ReadUrl (const XBOX::VString& inString) { if (!inString.IsEmpty()) { const UniChar *stringPtr = inString.GetCPointer(); UniChar ch = *stringPtr; while (ch != '\0') { XBOX::VString name; XBOX::VString value; while (ch != '\0' && ch != CHAR_EQUALS_SIGN && ch != CHAR_AMPERSAND) { if (ch == CHAR_PLUS_SIGN) ch = CHAR_SPACE; name.AppendUniChar (ch); ch = *(++stringPtr); } if (ch == CHAR_EQUALS_SIGN) { ch = *(++stringPtr); while (ch != '\0' && ch != CHAR_AMPERSAND) { if (ch == CHAR_PLUS_SIGN) ch = CHAR_SPACE; value.AppendUniChar (ch); ch = *(++stringPtr); } } XBOX::VString decodedName (name); XBOX::VString decodedValue (value); XBOX::VURL::Decode (decodedName); XBOX::VURL::Decode (decodedValue); XBOX::StStringConverter<char> buffer (decodedValue, XBOX::VTC_UTF_8); _AddValuePair (decodedName, CONST_TEXT_PLAIN_UTF_8, (void *)buffer.GetCPointer(), buffer.GetLength()); if (ch == CHAR_AMPERSAND) ch = *(++stringPtr); } } } void VMIMEMessage::_ReadMultipart (const XBOX::VStream& inStream) { XBOX::VStream& stream = const_cast<XBOX::VStream&>(inStream); VMIMEReader reader (fBoundary, stream); while (reader.HasNextPart()) { VHTTPMessage message; if (!reader.GetNextPart (message)) break; XBOX::VString dispositionValue; XBOX::VNameValueCollection params; if (message.GetHeaders().IsHeaderSet (STRING_HEADER_CONTENT_DISPOSITION)) { XBOX::VString contentDispositionHeaderValue; message.GetHeaders().GetHeaderValue (STRING_HEADER_CONTENT_DISPOSITION, contentDispositionHeaderValue); VHTTPHeader::SplitParameters (contentDispositionHeaderValue, dispositionValue, params, true); // YT 25-Jan-2012 - ACI0075142 } if (params.Has (CONST_MIME_PART_FILENAME)) { XBOX::VString fileName; XBOX::VString name; XBOX::VString contentType; XBOX::VString contentID; message.GetHeaders().GetHeaderValue (STRING_HEADER_CONTENT_TYPE, contentType); fileName = params.Get (CONST_MIME_PART_FILENAME); name = params.Get (CONST_MIME_PART_NAME); // Default as "attachment", not "inline". _AddFilePart (name, fileName, false, contentType, contentID, message.GetBody()); } else { XBOX::VString nameString = params.Get (CONST_MIME_PART_NAME); XBOX::VURL::Decode (nameString); _AddValuePair (nameString, CONST_TEXT_PLAIN, message.GetBody().GetDataPtr(), message.GetBody().GetDataSize()); } XBOX::VTask::Yield(); // YT 14-Oct-2013 - ACI0084474 } } void VMIMEMessage::_ReadMultiPartMail (const XBOX::VStream &inStream) { XBOX::VStream &stream = const_cast<XBOX::VStream&>(inStream); VMIMEReader reader(fBoundary, stream); while (reader.HasNextPart()) { XBOX::VHTTPMessage message; reader.GetNextPart(message); // Parse header of part. XBOX::VHTTPHeader header = message.GetHeaders(); const XBOX::VNameValueCollection &headerList = header.GetHeaderList(); XBOX::VNameValueCollection::ConstIterator it; XBOX::VString name, fileName, contentType, contentID; bool isInline, isBase64, isQuotedPrintable; isInline = isBase64 = isQuotedPrintable = false; for (it = headerList.begin(); it != headerList.end(); it++) { XBOX::VString value; XBOX::VNameValueCollection params; if (HTTPTools::EqualASCIIVString(it->first, "Content-Type", false)) { header.GetHeaderValue(it->first, contentType); VHTTPHeader::SplitParameters(contentType, value, params); if (params.Has("name")) { name = params.Get("name"); _UnQuote(&name, '"', '"'); } } else if (HTTPTools::EqualASCIIVString(it->first, "Content-Disposition", false)) { XBOX::VString disposition; header.GetHeaderValue(it->first, value); VHTTPHeader::SplitParameters(value, disposition, params); isInline = HTTPTools::EqualASCIIVString(disposition, "inline"); if (params.Has("filename")) { fileName = params.Get("filename"); _UnQuote(&fileName, '"', '"'); } } else if (HTTPTools::EqualASCIIVString(it->first, "Content-Transfer-Encoding", false)) { XBOX::VString encoding; header.GetHeaderValue(it->first, value); VHTTPHeader::SplitParameters(value, encoding, params); if (!(isBase64 = HTTPTools::EqualASCIIVString(encoding, "base64"))) isQuotedPrintable = HTTPTools::EqualASCIIVString(encoding, "quoted-printable"); } else if (HTTPTools::EqualASCIIVString(it->first, "Content-ID", false)) { header.GetHeaderValue(it->first, value); VHTTPHeader::SplitParameters(value, contentID, params); _UnQuote(&contentID, '<', '>'); } else { // Ignore unknown fields. } } // Get body of part, decode it if need. XBOX::VMemoryBuffer<> decodedData; XBOX::VPtrStream decodedBody; XBOX::VPtrStream *body = message.GetBodyPtr(); if (isBase64) { XBOX::Base64Coder::Decode(body->GetDataPtr(), body->GetDataSize(), decodedData); decodedBody.SetDataPtr(decodedData.GetDataPtr(), decodedData.GetDataSize()); decodedData.ForgetData(); body = &decodedBody; } else if (isQuotedPrintable) { VMIMEReader::DecodeQuotedPrintable (body->GetDataPtr(), body->GetDataSize(), &decodedData); decodedBody.SetDataPtr(decodedData.GetDataPtr(), decodedData.GetDataSize()); decodedData.ForgetData(); body = &decodedBody; } if (fileName.IsEmpty()) _AddTextPart(name, isInline, contentType, contentID, *body); else _AddFilePart(name, fileName, isInline, contentType, contentID, *body); decodedBody.Clear(); XBOX::VTask::Yield(); // YT 14-Oct-2013 - ACI0084474 } } void VMIMEMessage::_ReadSinglePartMail (const VMIMEMailHeader *inHeader, VStream &inStream) { xbox_assert(inHeader != NULL); // Read header information. XBOX::VString name, fileName, contentType, contentID; bool isInline, isBase64, isQuotedPrintable; isInline = isBase64 = isQuotedPrintable = false; XBOX::VString string; XBOX::VNameValueCollection params; if (!inHeader->fContentType.IsEmpty()) { contentType = inHeader->fContentType; VHTTPHeader::SplitParameters(inHeader->fContentType, string, params); if (params.Has("name")) { name = params.Get("name"); _UnQuote(&name, '"', '"'); } } if (!inHeader->fContentDisposition.IsEmpty()) { VHTTPHeader::SplitParameters(inHeader->fContentDisposition, string, params); isInline = HTTPTools::EqualASCIIVString(string, "inline"); if (params.Has("filename")) { fileName = params.Get("filename"); _UnQuote(&fileName, '"', '"'); } } if (!inHeader->fContentTransferEncoding.IsEmpty()) { VHTTPHeader::SplitParameters(inHeader->fContentTransferEncoding, string, params); if (!(isBase64 = HTTPTools::EqualASCIIVString(string, "base64"))) isQuotedPrintable = HTTPTools::EqualASCIIVString(string, "quoted-printable"); } // Read body (a single part). Must be bigger than 5 bytes because of the ending "\r\n.\r\n" sequence. XBOX::VError error; VSize size; if ((error = inStream.OpenReading()) != XBOX::VE_OK) XBOX::vThrowError(error); else if ((size = (VSize) inStream.GetSize()) > 5) { uBYTE *buffer; size -= 5; if ((buffer = new uBYTE[size]) == NULL) XBOX::vThrowError(XBOX::VE_MEMORY_FULL); else { XBOX::VMemoryBuffer<> decodedData; XBOX::VPtrStream decodedBody; inStream.GetData(buffer, size); if (isBase64) { XBOX::Base64Coder::Decode(buffer, size, decodedData); decodedBody.SetDataPtr(decodedData.GetDataPtr(), decodedData.GetDataSize()); decodedData.ForgetData(); } else if (isQuotedPrintable) { VMIMEReader::DecodeQuotedPrintable(buffer, size, &decodedData); decodedBody.SetDataPtr(decodedData.GetDataPtr(), decodedData.GetDataSize()); decodedData.ForgetData(); } else decodedBody.SetDataPtr(buffer, size); inStream.CloseReading(); if (fileName.IsEmpty()) _AddTextPart(name, isInline, contentType, contentID, decodedBody); else _AddFilePart(name, fileName, isInline, contentType, contentID, decodedBody); if (isBase64 || isQuotedPrintable) decodedBody.Clear(); else decodedBody.StealData(); // Prevent VPtrStream from freeing buffer. delete[] buffer; } } else inStream.CloseReading(); } XBOX::VError VMIMEMessage::ToStream (XBOX::VStream& outStream, sLONG inEncoding) const { XBOX::VError error = XBOX::VE_OK; if (XBOX::VE_OK == outStream.OpenWriting()) { outStream.SetCarriageReturnMode(eCRM_CRLF); if (!fMIMEParts.empty()) { XBOX::VString string; XBOX::VString charsetName; bool bEncodeBody; // Encode using base64. for (XBOX::VectorOfMIMEPart::const_iterator it = fMIMEParts.begin(); it != fMIMEParts.end(); ++it) { outStream.PutPrintf ("\r\n--%S\r\n", &fBoundary); string.FromCString ("Content-Type: "); string.AppendString ((*it)->GetMediaType()); if (!(*it)->GetFileName().IsEmpty()) { string.AppendCString ("; name=\""); if (!(*it)->GetName().IsEmpty()) string.AppendString ((*it)->GetName()); else string.AppendString ((*it)->GetFileName()); string.AppendCString("\"\r\nContent-Disposition: "); string.AppendCString((*it)->IsInline() ? "inline; " : "attachment; "); string.AppendCString("filename=\""); string.AppendString ((*it)->GetFileName()); string.AppendCString ("\"\r\n"); if (inEncoding == ENCODING_BINARY) { string.AppendCString ("Content-Transfer-Encoding: 8bit\r\n"); bEncodeBody = false; } else { if ((inEncoding == ENCODING_BINARY_ONLY) && ((*it)->GetMediaTypeKind() == MIMETYPE_TEXT)) { bEncodeBody = false; } else { string.AppendCString ("Content-Transfer-Encoding: base64\r\n"); bEncodeBody = true; } } } else { if ((*it)->GetMediaTypeCharSet() != XBOX::VTC_UNKNOWN) { string.AppendCString ("; charset=\""); XBOX::VTextConverters::Get()->GetNameFromCharSet ((*it)->GetMediaTypeCharSet(), charsetName); string.AppendString (charsetName); string.AppendCString ("\""); } if (!(*it)->GetName().IsEmpty()) { string.AppendCString("; name=\""); string.AppendString((*it)->GetName()); string.AppendCString("\""); } string.AppendCString ("\r\n"); if ((*it)->IsInline()) string.AppendCString("Content-Disposition: inline\r\n"); if (inEncoding == ENCODING_7BIT || ((inEncoding == ENCODING_BINARY_ONLY) && ((*it)->GetMediaTypeKind() != MIMETYPE_TEXT))) { string.AppendCString ("Content-Transfer-Encoding: base64\r\n"); bEncodeBody = true; } else { string.AppendCString("Content-Transfer-Encoding: 8bit\r\n"); bEncodeBody = false; } } if ((*it)->GetContentID().GetLength()) { string.AppendCString("Content-ID: <"); string.AppendString((*it)->GetContentID()); string.AppendCString(">\r\n"); } string.AppendCString ("\r\n"); outStream.PutText (string); if (bEncodeBody) { XBOX::VMemoryBuffer<> buffer; if (XBOX::Base64Coder::Encode ((*it)->GetData().GetDataPtr(), (*it)->GetData().GetDataSize(), buffer, kBASE64_QUADS_PER_LINE)) { outStream.PutData (buffer.GetDataPtr(), buffer.GetDataSize()); } } else { outStream.PutData ((*it)->GetData().GetDataPtr(), (*it)->GetData().GetDataSize()); } } outStream.PutPrintf ("\r\n--%S--\r\n", &fBoundary); } outStream.CloseWriting(); } return error; } void VMIMEMessage::_UnQuote (XBOX::VString *ioString, UniChar inStartQuote, UniChar inEndQuote) { xbox_assert(ioString != NULL); if (ioString->GetLength() >= 2 && ioString->GetUniChar(1) == inStartQuote && ioString->GetUniChar(ioString->GetLength()) == inEndQuote) ioString->SubString(2, ioString->GetLength() - 2); } END_TOOLBOX_NAMESPACE
[ "stephane.hamel@4d.com" ]
stephane.hamel@4d.com
b9b828d0818d1e36db7998a54d1ba8f7a219905b
a9d13a7251696bc70471792765a6e3b46af40490
/cpp/21.cpp
bc8d296e2e70f9104e0849ec2216a8347e15015f
[]
no_license
Yesol222/Algorithm
529e895eb0aa154633f85ae215d41cc74cd5b33e
a8d632935a5bc0413aa097b5ebac435fbf24486a
refs/heads/master
2023-03-24T23:58:39.799405
2021-03-23T06:59:56
2021-03-23T06:59:56
334,355,839
0
0
null
null
null
null
UTF-8
C++
false
false
694
cpp
#include <stdio.h> int main(){ freopen("input.txt.","rt",stdin); int i, A[10],B[10],as=0,bs=0,lw=0; for(i=0;i<10;i++){ scanf("%d",&A[i]); } for(i=0;i<10;i++){ scanf("%d",&B[i]); } for(i=0;i<10;i++){ if(A[i]>B[i]){ as+=3; lw=1; } else if(A[i]<B[i]){ bs+=3; lw=2; } else{ as+=1; bs+=1; } } printf("%d %d", as, bs); if(as==bs){ if(lw==0) printf("D\n"); else if(lw==1) printf("A\n"); else printf("B\n"); } else if(as>bs) printf("A\n"); else printf("B\n"); return 0; }
[ "744348@gmail.com" ]
744348@gmail.com
4c157dec32a8c39e3d1c52fb29b8bd51631135c8
47b755444e700332877d8bb432e5739045ba2c8b
/wxWidgets/include/wx/generic/spinctlg.h
0f09abd5d7065c4b2aa2c67dd4b8d4c4bf59b4c3
[ "MIT" ]
permissive
andr3wmac/Torque6Editor
5b30e103f0b3a81ae7a189725e25d807093bf131
0f8536ce90064adb9918f004a45aaf8165b2a343
refs/heads/master
2021-01-15T15:32:54.537291
2016-06-09T20:45:49
2016-06-09T20:45:49
39,276,153
25
14
null
null
null
null
UTF-8
C++
false
false
14,361
h
///////////////////////////////////////////////////////////////////////////// // Name: wx/generic/spinctlg.h // Purpose: generic wxSpinCtrl class // Author: Vadim Zeitlin // Modified by: // Created: 28.10.99 // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_GENERIC_SPINCTRL_H_ #define _WX_GENERIC_SPINCTRL_H_ // ---------------------------------------------------------------------------- // wxSpinCtrl is a combination of wxSpinButton and wxTextCtrl, so if // wxSpinButton is available, this is what we do - but if it isn't, we still // define wxSpinCtrl class which then has the same appearance as wxTextCtrl but // the different interface. This allows to write programs using wxSpinCtrl // without tons of #ifdefs. // ---------------------------------------------------------------------------- #if wxUSE_SPINBTN #include "wx/compositewin.h" class WXDLLIMPEXP_FWD_CORE wxSpinButton; class WXDLLIMPEXP_FWD_CORE wxTextCtrl; class wxSpinCtrlTextGeneric; // wxTextCtrl used for the wxSpinCtrlGenericBase // The !wxUSE_SPINBTN version's GetValue() function conflicts with the // wxTextCtrl's GetValue() and so you have to input a dummy int value. #define wxSPINCTRL_GETVALUE_FIX // ---------------------------------------------------------------------------- // wxSpinCtrlGeneric is a combination of wxTextCtrl and wxSpinButton // // This class manages a double valued generic spinctrl through the DoGet/SetXXX // functions that are made public as Get/SetXXX functions for int or double // for the wxSpinCtrl and wxSpinCtrlDouble classes respectively to avoid // function ambiguity. // ---------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase : public wxNavigationEnabled<wxCompositeWindow<wxSpinCtrlBase> > { public: wxSpinCtrlGenericBase() { Init(); } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrl")); virtual ~wxSpinCtrlGenericBase(); // accessors // T GetValue() const // T GetMin() const // T GetMax() const // T GetIncrement() const virtual bool GetSnapToTicks() const { return m_snap_to_ticks; } // unsigned GetDigits() const - wxSpinCtrlDouble only // operations virtual void SetValue(const wxString& text); // void SetValue(T val) // void SetRange(T minVal, T maxVal) // void SetIncrement(T inc) virtual void SetSnapToTicks(bool snap_to_ticks); // void SetDigits(unsigned digits) - wxSpinCtrlDouble only // Select text in the textctrl void SetSelection(long from, long to); // implementation from now on // forward these functions to all subcontrols virtual bool Enable(bool enable = true); virtual bool Show(bool show = true); virtual bool SetBackgroundColour(const wxColour& colour); // get the subcontrols wxTextCtrl *GetText() const { return m_textCtrl; } wxSpinButton *GetSpinButton() const { return m_spinButton; } // forwarded events from children windows void OnSpinButton(wxSpinEvent& event); void OnTextLostFocus(wxFocusEvent& event); void OnTextChar(wxKeyEvent& event); // this window itself is used only as a container for its sub windows so it // shouldn't accept the focus at all and any attempts to explicitly set // focus to it should give focus to its text constol part virtual bool AcceptsFocus() const { return false; } virtual void SetFocus(); friend class wxSpinCtrlTextGeneric; protected: // override the base class virtuals involved into geometry calculations virtual wxSize DoGetBestSize() const; virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; virtual void DoMoveWindow(int x, int y, int width, int height); #ifdef __WXMSW__ // and, for MSW, enabling this window itself virtual void DoEnable(bool enable); #endif // __WXMSW__ enum SendEvent { SendEvent_None, SendEvent_Text }; // generic double valued functions double DoGetValue() const { return m_value; } bool DoSetValue(double val, SendEvent sendEvent); void DoSetRange(double min_val, double max_val); void DoSetIncrement(double inc); // update our value to reflect the text control contents (if it has been // modified by user, do nothing otherwise) // // can also change the text control if its value is invalid // // return true if our value has changed bool SyncSpinToText(SendEvent sendEvent); // Send the correct event type virtual void DoSendEvent() = 0; // Convert the text to/from the corresponding value. virtual bool DoTextToValue(const wxString& text, double *val) = 0; virtual wxString DoValueToText(double val) = 0; // check if the value is in range bool InRange(double n) const { return (n >= m_min) && (n <= m_max); } // ensure that the value is in range wrapping it round if necessary double AdjustToFitInRange(double value) const; double m_value; double m_min; double m_max; double m_increment; bool m_snap_to_ticks; int m_spin_value; // the subcontrols wxTextCtrl *m_textCtrl; wxSpinButton *m_spinButton; private: // common part of all ctors void Init(); // Implement pure virtual function inherited from wxCompositeWindow. virtual wxWindowList GetCompositeWindowParts() const; wxDECLARE_EVENT_TABLE(); }; #else // !wxUSE_SPINBTN #define wxSPINCTRL_GETVALUE_FIX int = 1 // ---------------------------------------------------------------------------- // wxSpinCtrl is just a text control // ---------------------------------------------------------------------------- #include "wx/textctrl.h" class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase : public wxTextCtrl { public: wxSpinCtrlGenericBase() : m_value(0), m_min(0), m_max(100), m_increment(1), m_snap_to_ticks(false), m_format(wxT("%g")) { } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrl")) { m_min = min; m_max = max; m_value = initial; m_increment = inc; bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style, wxDefaultValidator, name); DoSetValue(initial, SendEvent_None); return ok; } // accessors // T GetValue() const // T GetMin() const // T GetMax() const // T GetIncrement() const virtual bool GetSnapToTicks() const { return m_snap_to_ticks; } // unsigned GetDigits() const - wxSpinCtrlDouble only // operations virtual void SetValue(const wxString& text) { wxTextCtrl::SetValue(text); } // void SetValue(T val) // void SetRange(T minVal, T maxVal) // void SetIncrement(T inc) virtual void SetSnapToTicks(bool snap_to_ticks) { m_snap_to_ticks = snap_to_ticks; } // void SetDigits(unsigned digits) - wxSpinCtrlDouble only // Select text in the textctrl //void SetSelection(long from, long to); protected: // generic double valued double DoGetValue() const { double n; if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%lf"), &n) != 1) ) n = INT_MIN; return n; } bool DoSetValue(double val, SendEvent sendEvent) { wxString str(wxString::Format(m_format, val)); switch ( sendEvent ) { case SendEvent_None: wxTextCtrl::ChangeValue(str); break; case SendEvent_Text: wxTextCtrl::SetValue(str); break; } return true; } void DoSetRange(double min_val, double max_val) { m_min = min_val; m_max = max_val; } void DoSetIncrement(double inc) { m_increment = inc; } // Note: unused double m_value; double m_min; double m_max; double m_increment; bool m_snap_to_ticks; wxString m_format; }; #endif // wxUSE_SPINBTN/!wxUSE_SPINBTN #if !defined(wxHAS_NATIVE_SPINCTRL) //----------------------------------------------------------------------------- // wxSpinCtrl //----------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGenericBase { public: wxSpinCtrl() { Init(); } wxSpinCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, int min = 0, int max = 100, int initial = 0, const wxString& name = wxT("wxSpinCtrl")) { Init(); Create(parent, id, value, pos, size, style, min, max, initial, name); } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, int min = 0, int max = 100, int initial = 0, const wxString& name = wxT("wxSpinCtrl")) { return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size, style, min, max, initial, 1, name); } // accessors int GetValue(wxSPINCTRL_GETVALUE_FIX) const { return int(DoGetValue()); } int GetMin() const { return int(m_min); } int GetMax() const { return int(m_max); } int GetIncrement() const { return int(m_increment); } // operations void SetValue(const wxString& value) { wxSpinCtrlGenericBase::SetValue(value); } void SetValue( int value ) { DoSetValue(value, SendEvent_None); } void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); } void SetIncrement(int inc) { DoSetIncrement(inc); } virtual int GetBase() const { return m_base; } virtual bool SetBase(int base); protected: virtual void DoSendEvent(); virtual bool DoTextToValue(const wxString& text, double *val); virtual wxString DoValueToText(double val); private: // Common part of all ctors. void Init() { m_base = 10; } int m_base; wxDECLARE_DYNAMIC_CLASS(wxSpinCtrl); }; #endif // wxHAS_NATIVE_SPINCTRL //----------------------------------------------------------------------------- // wxSpinCtrlDouble //----------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxSpinCtrlDouble : public wxSpinCtrlGenericBase { public: wxSpinCtrlDouble() { Init(); } wxSpinCtrlDouble(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrlDouble")) { Init(); Create(parent, id, value, pos, size, style, min, max, initial, inc, name); } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrlDouble")) { return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size, style, min, max, initial, inc, name); } // accessors double GetValue(wxSPINCTRL_GETVALUE_FIX) const { return DoGetValue(); } double GetMin() const { return m_min; } double GetMax() const { return m_max; } double GetIncrement() const { return m_increment; } unsigned GetDigits() const { return m_digits; } // operations void SetValue(const wxString& value) { wxSpinCtrlGenericBase::SetValue(value); } void SetValue(double value) { DoSetValue(value, SendEvent_None); } void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); } void SetIncrement(double inc) { DoSetIncrement(inc); } void SetDigits(unsigned digits); // We don't implement bases support for floating point numbers, this is not // very useful in practice. virtual int GetBase() const { return 10; } virtual bool SetBase(int WXUNUSED(base)) { return 0; } protected: virtual void DoSendEvent(); virtual bool DoTextToValue(const wxString& text, double *val); virtual wxString DoValueToText(double val); unsigned m_digits; private: // Common part of all ctors. void Init() { m_digits = 0; m_format = wxS("%g"); } wxString m_format; wxDECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble); }; #endif // _WX_GENERIC_SPINCTRL_H_
[ "andrewmac@gmail.com" ]
andrewmac@gmail.com
4493f84051a862b7a4b6422ec4753feeb3476e6d
898d9b3afbb20aa1354873ef1314760732bfc7d0
/avenue/server_connection.cpp
8f0cdddcf596ae2cd7afd8a5bcb6c9055e40407b
[ "MIT" ]
permissive
Aiyowoo/im
cafc74b119f85f09a857e369fff8c6b371c7b86c
d510275d1cc83b2748cb675e99dacbbf04616fb5
refs/heads/master
2020-05-07T19:13:16.772434
2019-05-08T16:12:05
2019-05-08T16:12:05
180,802,881
0
0
null
null
null
null
GB18030
C++
false
false
1,557
cpp
// server_connection.cpp // Created by m8792 on 2019/4/24. // 2019/4/24 22:17 #include "server_connection.hpp" #include "details/log_helper.hpp" namespace asio = boost::asio; namespace ssl = boost::asio::ssl; namespace avenue { server_connection::server_connection(boost::asio::ip::tcp::socket &socket, boost::asio::ssl::context &ssl_context) : message_connection(socket, ssl_context) { } void server_connection::run() { INFO_LOG("start to run..."); set_running(true); stream().async_handshake(ssl::stream_base::handshake_type::server, [this, self = shared_from_base()](boost::system::error_code ec) { if (ec) { status s(ec.value(), fmt::format("failed to handshake with client due to error[{}]", ec.message())); handle_initialize_error(s); return; } initialize(); }); } std::shared_ptr<server_connection> server_connection::shared_from_base() { return std::dynamic_pointer_cast<server_connection>(shared_from_this()); } void server_connection::handle_initialize_error(const status& error) { // 已经不再运行了 set_running(false); // fixme: 是否需要关闭socket连接 on_initialized(error); } }
[ "m879224490@qq.com" ]
m879224490@qq.com
c40cec2855a8e1024a089444ba834a4497a6b87e
74fc7c5d39baa6c30aa929e629ff60bf40500c61
/test/unit-tests/mbr/abr_manager_mock.h
7d72e0e7df2540c2a133c41a74fcdd4bdfbd12c3
[ "BSD-3-Clause" ]
permissive
jhyunleehi/poseidonos
e472be680d0e85dc62f0e2c0d7356dbee74a3bd6
1d90e4320855d61742ff37af8c0148da579d95d4
refs/heads/develop
2023-07-13T03:37:29.754509
2021-08-23T15:26:08
2021-08-23T15:26:08
393,203,347
0
0
BSD-3-Clause
2021-08-20T00:04:14
2021-08-06T00:30:35
C
UTF-8
C++
false
false
754
h
#include <gmock/gmock.h> #include <list> #include <string> #include <vector> #include "src/mbr/abr_manager.h" namespace pos { class MockAbrManager : public AbrManager { public: using AbrManager::AbrManager; MOCK_METHOD(int, LoadAbr, (string arrayName, ArrayMeta& meta), (override)); MOCK_METHOD(int, SaveAbr, (string arrayName, ArrayMeta& meta), (override)); MOCK_METHOD(bool, GetMfsInit, (string arrayName), (override)); MOCK_METHOD(int, SetMfsInit, (string arrayName, bool value), (override)); MOCK_METHOD(int, CreateAbr, (string arrayName, ArrayMeta& meta), (override)); MOCK_METHOD(int, DeleteAbr, (string arrayName, ArrayMeta& meta), (override)); MOCK_METHOD(int, ResetMbr, (), (override)); }; } // namespace pos
[ "kyuho.son@samsung.com" ]
kyuho.son@samsung.com
86c9a0c29e0a927b054f6f09bc2ff427d5c3d419
11e6ec185672c57bb5f80955f001f42731768c73
/Source/BuildingEscape/OpenDoor.h
ac9d413900a980835feec92212b6372c57d01e7e
[]
no_license
Zagorouiko/BuildingEscape
d122fd9d6beca6c1373764844a829107ad383f10
baef29a3bb6561c9d5e8c4e29c01e19e863397ee
refs/heads/master
2020-04-22T18:15:04.301177
2019-02-17T14:37:41
2019-02-17T14:37:41
170,570,823
0
0
null
null
null
null
UTF-8
C++
false
false
792
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "Components/ActorComponent.h" #include "Engine/TriggerVolume.h" #include "OpenDoor.generated.h" UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class BUILDINGESCAPE_API UOpenDoor : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties UOpenDoor(); protected: // Called when the game starts virtual void BeginPlay() override; public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; private: UPROPERTY(VisibleAnywhere) float OpenAngle = 90.0f; UPROPERTY(EditAnywhere) ATriggerVolume* PressurePlate; };
[ "Zagorouiko@gmail.com" ]
Zagorouiko@gmail.com
9cc7265b0b688e52232a58d0c883fa3a388cbe8a
77b28b71ff49842067732ef8f948d935a8f3e7a5
/my_Codes/test3.cpp
96cdb66ab676ea94b52eeb7a6decaaddb359d07e
[]
no_license
rahulSingh2995/Codes
ea21b49aabb63e8d55db58da2bc10e5c89b4ccfe
f90d7ad5c20523e5d9b76ce6f71305e9cdf7f37f
refs/heads/master
2021-06-12T17:01:52.723269
2020-05-15T04:55:57
2020-05-15T04:55:57
254,365,740
0
0
null
null
null
null
UTF-8
C++
false
false
141
cpp
#include<iostream> class Test { static void fun(int a) {} void fun() {} // compiler error }; int main() { getchar(); return 0; }
[ "rahulcdacacts@gmail.com" ]
rahulcdacacts@gmail.com
41c9e858b3f9a48f4d3b1ad829d66b9ef806a405
dfd960b9c39ab30680774f9e6204ef9c58054798
/CPP/复数类latest.cpp
760566d59208f4f49a90d826931d467f85a12510
[]
no_license
yuyuOWO/source-code
09e0025672169e72cbd493a13664b35a0d2480aa
d4972f4d807ddf8e17fd074c0568f2ec5aba2bfe
refs/heads/master
2021-06-15T22:32:08.325223
2017-05-04T05:44:36
2017-05-04T05:44:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,345
cpp
#include <iostream> using namespace std; class Complex { public: Complex(double a = 0, double b = 0): Real(a), Imag(b){} ~Complex(){} friend ostream & operator<<(ostream &os, const Complex t) { os << "(" << t.Real << "," << t.Imag << "!)"; return os; } friend istream & operator>>(istream &is, Complex &t) { is >> t.Real >> t.Imag; return is; } friend Complex operator+(Complex a, Complex b) { /**************************** Complex tmp; tmp.Real = a.Real + b.Real; tmp.Real = a.Imag + a.Imag; return tmp; *****************************/ return Complex(a.Real + b.Real, a.Imag + b.Imag); } friend Complex operator-(Complex a, Complex b) { /**************************** Complex tmp; tmp.Real = a.Real - b.Real; tmp.Real = a.Imag - a.Imag; return tmp; *****************************/ return Complex(a.Real - b.Real, a.Imag - b.Imag); } Complex operator=(Complex a) { return Complex(Real = a.Real, Imag = a.Imag); } private: double Real, Imag; }; int main(int argc, char const *argv[]) { Complex a, b, c; cin >> a >> b; c = a; cout << "a = " << a << " " << "b = " << b << endl; cout << "c = " << c << endl; cout << "a + b = " << a + b << endl; cout << "a + 23.32 = " << a + 23.32 << endl; cout << "200 + b = " << 200 + b << endl; cout << "a - b = " << a - b << endl; return 0; }
[ "xanarry@163.com" ]
xanarry@163.com
7dd90e0a5fe64e6f0b097f48fea2d058e4492439
771a4e3846212eabbabf6b68bf73d4a326d0973e
/src/vswprinn.cpp
3f647373b1f94326e709d91a5f2ed7b5919456f5
[]
no_license
ganboing/crt.vc12
4e65b96bb5bd6c5b5be6a08d04c9b712b269461f
f1d47126bf13d1c9dccaa6c53b72217fd0474968
refs/heads/master
2021-01-13T08:48:12.365115
2016-09-24T20:16:46
2016-09-24T20:16:46
69,113,159
4
1
null
null
null
null
UTF-8
C++
false
false
4,238
cpp
/*** *vswprint.c - print formatted data into a string from var arg list * * Copyright (c) Microsoft Corporation. All rights reserved. * *Purpose: * defines vswprintf() and _vsnwprintf() - print formatted output to * a string, get the data from an argument ptr instead of explicit * arguments. * *******************************************************************************/ #ifdef CRTDLL /* * Suppress the inline definitions of iswalpha et al. Necessary to avoid * a conflict with the dllexport versions from _wctype.c in the DLL build. */ #define _WCTYPE_INLINE_DEFINED #endif /* CRTDLL */ #include <cruntime.h> /* This is prevent pulling in the inline versions of (v)swprintf */ #define _INC_SWPRINTF_INL_ #include <stdio.h> #include <wchar.h> #include <dbgint.h> #include <stdarg.h> #include <internal.h> #include <limits.h> #include <mtdll.h> #define MAXSTR INT_MAX /*** *int vswprintf(string, cnt, format, ap) - print formatted data to string from arg ptr * *Purpose: * Prints formatted data, but to a string and gets data from an argument * pointer. * Sets up a FILE so file i/o operations can be used, make string look * like a huge buffer to it, but _flsbuf will refuse to flush it if it * fills up. Appends '\0' to make it a true string. * * Allocate the 'fake' _iob[] entryit statically instead of on * the stack so that other routines can assume that _iob[] entries are in * are in DGROUP and, thus, are near. * * The vswprintf() flavor takes a count argument that is * the max number of bytes that should be written to the * user's buffer. * * Multi-thread: (1) Since there is no stream, this routine must never try * to get the stream lock (i.e., there is no stream lock either). (2) * Also, since there is only one staticly allocated 'fake' iob, we must * lock/unlock to prevent collisions. * *Entry: * wchar_t *string - place to put destination string * size_t count - max number of bytes to put in buffer * wchar_t *format - format string, describes format of data * va_list ap - varargs argument pointer * *Exit: * returns number of wide characters in string * *Exceptions: * *******************************************************************************/ int __cdecl _vswprintf_l ( wchar_t *string, size_t count, const wchar_t *format, _locale_t plocinfo, va_list ap ) { FILE str = { 0 }; FILE *outfile = &str; int retval; _ASSERTE(string != NULL); _ASSERTE(format != NULL); outfile->_flag = _IOWRT|_IOSTRG; outfile->_ptr = outfile->_base = (char *) string; if(count>(INT_MAX/sizeof(wchar_t))) { /* old-style functions allow any large value to mean unbounded */ outfile->_cnt = INT_MAX; } else { outfile->_cnt = (int)(count*sizeof(wchar_t)); } retval = _woutput_l(outfile,format,plocinfo,ap ); _putc_nolock('\0',outfile); /* no-lock version */ _putc_nolock('\0',outfile); /* 2nd byte for wide char version */ return(retval); } int __cdecl vswprintf ( wchar_t *string, size_t count, const wchar_t *format, va_list ap ) { return _vswprintf_l(string, count, format, NULL, ap); } #if defined (_NATIVE_WCHAR_T_DEFINED) int __cdecl _vswprintf_l ( unsigned short *string, size_t count, const unsigned short *format, _locale_t plocinfo, va_list ap ) { return _vswprintf_l(reinterpret_cast<wchar_t *>(string), count, reinterpret_cast<const wchar_t *>(format), plocinfo,ap); } int __cdecl vswprintf ( unsigned short *string, size_t count, const unsigned short *format, va_list ap ) { return _vswprintf_l(reinterpret_cast<wchar_t *>(string), count, reinterpret_cast<const wchar_t *>(format), NULL, ap); } #endif /* defined (_NATIVE_WCHAR_T_DEFINED) */
[ "gan.bo@columbia.edu" ]
gan.bo@columbia.edu
d10bebe69c3a50eb40de190598629544bca6dd08
99ca9bb6ac36daf7ae528f971e94ad0daf8b03ca
/pi0/ERAlgoJeremyPi0.cxx
29845a6cdcee1977f8f12b378137efa65d960494
[]
no_license
jhewes15/ngamma
fc121295e2ee1366a901360fd2f57f51228efad6
f31b0a31c6464480e5d52d95b5ee917be57a18fb
refs/heads/master
2020-06-05T08:29:47.184869
2015-07-22T18:04:12
2015-07-22T18:04:12
39,088,036
0
0
null
null
null
null
UTF-8
C++
false
false
3,643
cxx
#ifndef ERTOOL_ERALGOJEREMYPI0_CXX #define ERTOOL_ERALGOJEREMYPI0_CXX #include "ERAlgoJeremyPi0.h" namespace ertool { ERAlgoJeremyPi0::ERAlgoJeremyPi0(const std::string& name) : AlgoBase(name) { _name = name; _nGamma = new NGammaBase(); } void ERAlgoJeremyPi0::Reset() {} void ERAlgoJeremyPi0::AcceptPSet(const ::fcllite::PSet& cfg) { // get external parameters if not training PDFs if (!_trainingMode) { auto ngamma_pset = cfg.get_pset(_name); _nGamma->AcceptPSet(ngamma_pset); } } void ERAlgoJeremyPi0::ProcessBegin() {} bool ERAlgoJeremyPi0::Reconstruct(const EventData &data, ParticleGraph& graph) { // first case: training pdfs! if (_trainingMode) { auto nodes = graph.GetParticleNodes(RecoType_t::kShower, 0, 22); if (nodes.size() == 2) { // get the two gamma shower particles auto particle1 = graph.GetParticle(nodes[0]); auto particle2 = graph.GetParticle(nodes[1]); // calculate angle between showers double angle = particle1.Momentum().Angle(particle2.Momentum()); // calculate invariant mass double invMass = sqrt(2 * particle1.Energy() * particle2.Energy() * (1 - cos(angle))); // make sure energies are above a certain threshold if (invMass < 300) { // add to PDF _nGamma->FillMassPdf(invMass); } } } // second case: using pdfs to make selection! else { // score all possible combinations of gammas CombinationScoreSet_t candidates = _nGamma->GammaComparison(graph, 2); // select the best candidates as pi0s CombinationScoreSet_t event = _nGamma->EventSelection(candidates, _cut); // add the pi0s to the particle graph, then check it worked properly AddPi0s(graph, event); } return true; } void ERAlgoJeremyPi0::ProcessEnd(TFile* fout) { // if in training mode, save the trained parameters for future use if (_trainingMode) { auto& params = OutputPSet(); params.add_pset(_nGamma->GetParams()); } } // ****************** // // **** ADD PI0S **** // // ****************** // void ERAlgoJeremyPi0::AddPi0s(ParticleGraph &graph, CombinationScoreSet_t particles) { // this comes in useful later: int pdg_pi0 = 111; // loop over each identified pi0 for (auto const& particle : particles) { // get ids of two gamma showers double gamma1_id = particle.first[0]; double gamma2_id = particle.first[1]; // get pointers to two gamma showers Particle *gamma1 = &(graph.GetParticle(gamma1_id)); Particle *gamma2 = &(graph.GetParticle(gamma2_id)); // identify them as siblings (which creates "parent" object if it doesn't exist already) graph.SetSiblings(gamma1_id, gamma2_id, particle.second); // get id of parent object double parent_id = gamma1->Parent(); // get a pointer to the parent object Particle *parent = &(graph.GetParticle(parent_id)); // figure out the pi0's information geoalgo::Vector X (( gamma1->Vertex()[0] + gamma2->Vertex()[0]) /2, (gamma1->Vertex()[1] + gamma2->Vertex()[1]) /2, (gamma1->Vertex()[2] + gamma2->Vertex()[2]) /2 ); geoalgo::Vector P ( gamma1->Momentum()[0] + gamma2->Momentum()[0], gamma1->Momentum()[1] + gamma2->Momentum()[1], gamma1->Momentum()[2] + gamma2->Momentum()[2] ); parent->SetParticleInfo(pdg_pi0, ParticleMass(pdg_pi0), X, P, particle.second); } } } #endif
[ "jeremy.hewes@manchester.ac.uk" ]
jeremy.hewes@manchester.ac.uk
96eac3462d7af7dbf335defbc10d3bfc4dfbf450
2dcd06afb36378652c851c713e323681d0679242
/Source/effectpattern.cpp
ac2b95d8b2278d66048612fe3e9278049416c403
[]
no_license
LightInMotion/NativeTest
186df26c808a5667434fe8c895bef1ae75ac9b5a
bc6957238a97d120840aa355012f40169811ab70
refs/heads/master
2021-01-10T19:55:50.110959
2016-09-08T23:03:30
2016-09-08T23:03:30
3,811,690
0
0
null
null
null
null
UTF-8
C++
false
false
5,460
cpp
/* Module Description: This module is an 'effect pattern', basically a shape scanned by the effect class. It knows how to load itself from a filename, or from an istream. Effect is a 'friend' because the actual coordinate pairs are fetched directly for speed. */ // Includes .................................................................. #include "EffectPattern.h" // Local Defines ............................................................. // effect file versions. const uint32 _EFFECT_FILE_VERSION_1_00 = 0x0100; // current version const uint32 _EFFECT_FILE_VERSION_CURRENT = _EFFECT_FILE_VERSION_1_00; // Local Data Types .......................................................... // Local Data ................................................................ // Public Interface .......................................................... /* A pattern is asked to load itself from disk here. */ /*---------------------------------------------------------------------------- EffectPattern::EffectPatLoad Load an individual pattern from a file Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::EffectPatLoad (String file) { bool result = false; ShowFile show (file); if (show.open()) { // If we got here, it is structured storage and // is supposed to be an EffectFile // Try to read the info and points if (VerifyVersion(show) == true) if (ReadInfo (show) == true) if (ReadPoints (show) == true) result = true; show.close(); } return result; } /*---------------------------------------------------------------------------- EffectPattern:EffectPatGetGuid Fetch the GUID for a pattern ----------------------------------------------------------------------------*/ void EffectPattern::EffectPatGetGuid (Uuid &guid ) // OUT: Guid to retrieve { guid = m_Guid; } /*---------------------------------------------------------------------------- EffectPattern:EffectPatGetName Fetch the Name for a pattern ----------------------------------------------------------------------------*/ String EffectPattern::EffectPatGetName () { return m_Name; } // Effect File Helpers ....................................................... /* This bundles up the structured storage stuff and version checking, etc. for effect files */ /*---------------------------------------------------------------------------- EffectPattern::VerifyVersion read the effect version from the structore storage file and verify that it is the correct version. Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::VerifyVersion (ShowFile& show) { bool result = false; // Save Path String oldpath = show.getPath(); // open version stream if (show.setPath (oldpath + "EffectX1")) { // load effect file version uint32 fileVersion = 0; if (show.readDword (fileVersion)) { // verify the version. Currently we have only one effect file // version and we don't support any other version. // Should we change the file format in a later version then we // have to be able to load new and old versions. if (fileVersion == _EFFECT_FILE_VERSION_CURRENT) result = true; } } show.setPath (oldpath); return result; } /*---------------------------------------------------------------------------- EffectPattern::ReadInfo Get the GUID, name, and count from the effect file. Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::ReadInfo (ShowFile& show) // Open file { bool result = false; // Save Path String oldpath = show.getPath(); // open info stream if (show.setPath (oldpath + "Info")) { do { // Load the GUID if (! show.readGuid(m_Guid)) break; // Load the Count if (! show.readShort(m_EffectPatCount) || m_EffectPatCount != EFFECT_PAT_MAX_POINT) break; // Read the name if (! show.readString (m_Name)) break; result = true; } while (0); } show.setPath (oldpath); return result; } /*---------------------------------------------------------------------------- EffectPattern::ReadPoints Get the data points from the effect file. Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::ReadPoints (ShowFile& show) // Open file { bool result = false; // Save Path String oldpath = show.getPath(); // open info stream if (show.setPath (oldpath + "Points")) { uint32 bread; // Load the Points int count = sizeof(EffectPoint) * m_EffectPatCount; if (show.readBytes ((uint8*)(&m_EffectPatData), count, bread) && bread == (uint32)count) result = true; } show.setPath (oldpath); return result; }
[ "jf@emisense.com" ]
jf@emisense.com
3c90a958fd46cd6c8c1ab273a6613ec5c435920b
8a45f1803d67e98aa59421981c95a5865d4dbf60
/cpp_16_classes/ch12_05_Friend_this.cpp
14f1a76f864b114d9f5003d1ee9965b5e323663f
[]
no_license
walter-cc/cpp
1a2e2f01692be15ad1224d6abe76c6b766d08fa4
36b5d184d7b4e69753750d5132e87754957f7d2a
refs/heads/master
2021-12-30T21:40:22.305507
2021-08-06T16:11:28
2021-08-06T16:13:21
162,880,321
0
0
null
null
null
null
UTF-8
C++
false
false
2,411
cpp
/* 新增編譯和執行步驟 : g++ hello.cpp -o hello ./hello =============================== # 此範例可以看到 : 「this」指標的宣告和使用方式。 「*this」代表目前這個物件的內容,「return *this;」代表傳回目前這個物件的內容。 =============================== # 在建立class物件時,會自動建立屬於該物件自己的指標,叫做「this」指標。 # 「this」指標指向物件自己本身,指向記憶體中儲存該物件的「位址」。 # 「this」指標代表了「目前這個物件」的指標,可以存取到該class的資料成員和成員函數。 this->資料成員; //第一種方式 (*this).資料成員; //第二種方式 */ #include <iostream> // 引入標準程式庫中相關的輸入、輸出程式 #include <cstdlib> using namespace std; // std : 標準程式庫的命名空間 class Square { // 宣告類別 private: //私用資料成員 int a; public: //公用資料成員 Square(); //宣告預設建構子(constructor) Square(int n); //宣告有參數的建構子(constructor) Square squ(Square b); void show_data(); }; // 記得加上 ";" #### 重要 Square::Square(int n) //constructor使用參數設定初始值 { a = n*n; } Square Square::squ(Square b) // 實作 { this->a = this->a + b.a; // this->a 為 n1*n1, b.a 為 n2*n2 return *this; // 透過this指標 傳回 class Square } void Square::show_data() { cout << "答案" << (*this).a << endl; } /* - argc : argument count(參數總和)的縮寫,代表包括指令本身的參數個數。 - argv : argument value 的縮寫。 一個陣列,它會分拆所帶的參數放到陣列內 */ int main(int argc, char *argv[]) { int n1, n2; cout << "輸入第一個數字 : " ; cin >> n1; cout << "輸入第二個數字 : " ; cin >> n2; Square first(n1), second(n2), third(0); //宣告 class Square 的物件 third = first.squ(second); // 此時進入squ後, this->a 表示的是first這個物件的a成員。b.a 則為second的a成員。 third.show_data(); /* cc@cpphome$g++ cpp_16_classes/ch12_05_Friend_this.cpp -o test cc@cpphome$./test 輸入第一個數字 : 10 輸入第二個數字 : 20 答案500 */ return 0; }
[ "imwalter8@gmail.com" ]
imwalter8@gmail.com
f3460f675f5e2b569bfb2559b06024507bc95d79
67233ab008d07efb37e6ed33c6959fc6215e5048
/CodeTestZone/A1_Threadpool/CThreadUsingMsgLoop.h
8f8965c427a41a58caaa2efac5d085e184a3aa2b
[]
no_license
yinjingyu/LinuxDevelopment
0e9350ec985c40e2a29c9544297e5118a21192a3
5e5c57f3b233507c16cd5e56d4b9682c01a7bdbc
refs/heads/master
2021-01-22T05:15:27.000512
2013-12-03T09:28:29
2013-12-03T09:28:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
707
h
#ifndef CTHREADFORMSGLOOP_H #define CTHREADFORMSGLOOP_H #include "./include/CMsgObserver.h" #include <string> #include "./include/CStatus.h" class CThreadInitFinishedNotifier; class CThread; typedef struct { void * pContext; CThreadInitFinishedNotifier * pNotifier; }SInitialParameter; class CThreadUsingMsgLoop { public: CThreadUsingMsgLoop(const char * strThreadName, CMsgObserver * pMsgObserver); CThreadUsingMsgLoop(const char * strThreadNaem,CMsgObserver * pMsgObserver,bool bWaitForDeath); virtual ~CThreadUsingMsgLoop(); CStatus Run(void * pContext); const char * GetThreadName(); private: std::string m_sThreadName; CThread * m_pThread; bool m_bWaitForDeath; }; #endif
[ "yin_jingyu@126.com" ]
yin_jingyu@126.com
8f7dde38a5c99c6afcfc4d3d26627c4b65a2d688
237af8f87b8fd71635ff57e9d1657a16e06dcb35
/KnightRiderScanBar.ino
cd4a5c116283a7a8e677c325a4781ccab8c791fa
[]
no_license
erichilarysmithsr/KnightRiderScanBar
814db6c16b6822115204b188b35829312e4cb6f1
72717aab55fd7a6d0b06ddac21aa65a6dadd4263
refs/heads/master
2021-01-21T02:49:40.808396
2014-08-11T15:29:06
2014-08-11T15:29:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,455
ino
#include "LPD8806.h" #include "SPI.h" // Knight Rider KITT and KARR scan bar (light chaser). // Uses a 1 metre Adafruit digital RGB LED strip with an LPD8806 chip. // http://www.adafruit.com/products/306 /*****************************************************************************/ // Number of RGB LEDs in strand: int nLEDs = 32; int dataPin = 2; int clockPin = 3; LPD8806 strip = LPD8806(nLEDs, dataPin, clockPin); void setup() { strip.begin(); // Update the strip, to start they are all 'off' strip.show(); } void scanBar(uint32_t (*getColor)(byte)) { int tail = 7; for(int i=0; i<(int)strip.numPixels()+tail; i++) { for(int j=0; j<=i; j++) { int diff = min(tail, abs(j-i)); int brightness = (128 >> diff) - 1; strip.setPixelColor(min(strip.numPixels()-1, j), getColor(brightness)); } strip.show(); delay(20); } for(int i=strip.numPixels()-1; i>=-tail; i--) { for(int j=strip.numPixels()-1; j>=i; j--) { int diff = min(tail, abs(j-i)); int brightness = (128 >> diff) - 1; strip.setPixelColor(max(0, j), getColor(brightness)); } strip.show(); delay(20); } } void loop() { for(int i = 0; i<3; i++) { scanBar(&kitt); } for(int i = 0; i<3; i++) { scanBar(&karr); } } uint32_t kitt(byte brightness) { return strip.Color(brightness, 0, 0); } uint32_t karr(byte brightness) { return strip.Color(brightness, brightness*0.4, 0); }
[ "rbirkby@gmail.com" ]
rbirkby@gmail.com
835f58b4577711e00aa48932d1d287b67d08cc32
4c66e1d186ad4b32cd1677bb64d871e09b505ffc
/drivenet_ros/include/ace/config-sunos5.10.h
e4590571fa8e9b6be69d2dbd1796e15f4d5ee3dd
[ "Apache-2.0" ]
permissive
Bangglll/driveworks_ros
0ace6f4bee4cc585b4c9fd01054101c8c09c5186
9f08a8be336cf317bcb36ae058bb8d673d814660
refs/heads/main
2023-08-14T16:46:55.264875
2021-10-03T06:47:17
2021-10-03T06:47:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,866
h
/* -*- C++ -*- */ // $Id: config-sunos5.10.h 2793 2015-11-30 23:09:18Z mitza $ // The following configuration file is designed to work for SunOS 5.10 // (Solaris 10) platforms using the SunC++ 5.x (Sun Studio 8-10), or g++ // compilers. #ifndef ACE_CONFIG_H // ACE_CONFIG_H is defined by one of the following #included headers. // #include the SunOS 5.9 config, then add any SunOS 5.10 updates below. #include "ace/config-sunos5.9.h" // Solaris 10 can do sem_timedwait() (see ACE_OS::sema_wait). #define ACE_HAS_POSIX_SEM_TIMEOUT #define ACE_HAS_SCANDIR // Solaris 10 offers a useable alphasort() unlike previous Solaris versions. #if defined (ACE_LACKS_ALPHASORT) # undef ACE_LACKS_ALPHASORT #endif #undef ACE_LACKS_GETADDRINFO #undef ACE_LACKS_GETNAMEINFO // Solaris 10 offers a useable log2() unlike previous Solaris versions. #if defined (ACE_LACKS_LOG2) # undef ACE_LACKS_LOG2 #endif // Solaris 10 offers a useable isblank() unlike previous Solaris versions. #if defined (ACE_LACKS_ISBLANK) # undef ACE_LACKS_ISBLANK #endif // Solaris 10 delivers pthread_attr_setstack #if defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK) # undef ACE_LACKS_PTHREAD_ATTR_SETSTACK #endif // Solaris 10 introduced printf() modifiers for [s]size_t types. #undef ACE_SSIZE_T_FORMAT_SPECIFIER_ASCII #define ACE_SSIZE_T_FORMAT_SPECIFIER_ASCII "%zd" #undef ACE_SIZE_T_FORMAT_SPECIFIER_ASCII #define ACE_SIZE_T_FORMAT_SPECIFIER_ASCII "%zu" // Solaris 10 offers wcstoll() and wcstoull() #if defined (ACE_LACKS_WCSTOLL) # undef ACE_LACKS_WCSTOLL #endif /* ACE_LACKS_WCSTOLL */ #if defined (ACE_LACKS_WCSTOULL) # undef ACE_LACKS_WCSTOULL #endif /* ACE_LACKS_WCSTOULL */ #if defined (ACE_HAS_SCTP) && defined (ACE_HAS_LKSCTP) # define ACE_HAS_VOID_PTR_SCTP_GETLADDRS # define ACE_HAS_VOID_PTR_SCTP_GETPADDRS #endif #define ACE_HAS_SOLARIS_ATOMIC_LIB #endif /* ACE_CONFIG_H */
[ "763k357@naver.com" ]
763k357@naver.com
f978428f4f42016702f129d3cc175014e4e5c76b
3c9d8787d9dd84b5402097c1331add04bc7a7f94
/7.23 DP - Min Insertion or Deletion to convert 'a' to 'b'.cpp
db56c70d498ff465e07876dd4221319e86e8a863
[]
no_license
AbhishekPratik1810/my_cpp_dsa_practice
bfc6df01dc2412b39056b5d49791a0ccf105d19a
37e465cf15d162dfaf535fdcf780d5d5225a8575
refs/heads/master
2022-12-09T03:24:24.220974
2020-09-15T17:50:33
2020-09-15T17:50:33
295,805,408
0
0
null
null
null
null
UTF-8
C++
false
false
1,679
cpp
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define endl "\n" #define fo for(int i=0;i<n;i++) #define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n'); #define loopSolve int t; cin>>t; while(t--){solve();} //INT_MAX 2,147,483,647 <10^10 //U_INT_MAX 4,294,967,295 <10^10 //LONG_LONG_MAX 9,223,372,036,854,775,807 <10^18 //U_LONG_LONG_MAX 18,446,744,073,709,551,615 <10^18 /*ll power(int a, int b){ return (ll)(pow(a,b)+0.5); }*/ int getBits(ll num){ return (int)log2(num) + 1; } vector<int> gV(int n){ vector<int> v; int input; fo { cin>>input; v.pb(input); } return v; } int* gA(int n){ int* arr = new int[n]; fo cin>>arr[i]; return arr; } //https://practice.geeksforgeeks.org/problems/minimum-number-of-deletions-and-insertions/0 //x se LCS(x,y) pe pahuncho via x-LCS(x,y) deletion in x. Then LCS se y pe pahuncho by y-LCS(x,y) insertions. Total operations = x-LCS(x,y)+ y-LCS(x,y) = x+y - 2*LCS(x,y) void solve(){ int n,m; cin>>n>>m; string x,y; cin>>x>>y; static int dp[1001][1001]; for(int i=0;i<=1000;i++){ for(int j=0;j<=1000;j++) dp[i][j]=0; } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(x[i-1]==y[j-1]) dp[i][j]=dp[i-1][j-1]+1; else dp[i][j]=max(dp[i-1][j],dp[i][j-1]); } } cout<<n+m-(2*dp[n][m])<<endl; } int main() { ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL); //solve(); loopSolve; return 0; }
[ "developerpratik18@gmail.com" ]
developerpratik18@gmail.com
79f094cb51e708d142f6f5bcf9e3aae3cd0dac00
511f58bc46be60a0215eb46335a783585701c07a
/frq_b.cpp
c3303c414df1466eab2fcf96aabad31667337eff
[]
no_license
sagar-massand/spoj1
6ee6c7b93ba4873dd2a0b43c107f081a3fb69879
56ceac968afc318854ceec4c22267fa64d2c72a8
refs/heads/master
2016-09-06T09:41:04.540897
2013-11-29T12:38:20
2013-11-29T12:38:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,125
cpp
#include<iostream> #include<stdio.h> #include<stdlib.h> #include<algorithm> #include<string.h> #include<math.h> #include<queue> #include<vector> #include<stack> #include<set> using namespace std; #define FOR(i,n) for(i=0;i<n;i++) #define pi(n) printf("%d\n",n); #define pl(n) printf("%lld\n",n); #define ps(c) printf("%s\n",c); #define si(n) scanf("%d",&n); #define sl(n) scanf("%lld",&n); #define ss(n) scanf("%s",n); #define sf(n) scanf("%lf",&n); #define sc(n) scanf(" %c",&n); #define mod 1000000007 #define FORi(i,a,n) for(i=a;i<n;i++) int main() { long long a,b,c,n,t,i,j,k; long long *prime,*prim; prim=(long long *)malloc(1000001*sizeof(long long)); prime=(long long *)malloc(1000001*sizeof(long long)); for(i=3;i<1000000;i+=2) prim[i]=1; prime[0]=2; k=1; for(i=3;i<1000;i+=2) { if(prim[i]==1) { prime[k]=i; k++; for(j=i*i;j<1000000;j+=(2*i)) { prim[j]=0; } } } long long total; for(;i<1000000;i+=2) { if(prim[i]==1) { prime[k]=i; k++; } } total=k; sl(t) FOR(i,t) { long long ans=0,sum,num=k; sl(n) sl(k) for(a=3;a<=n;a++) { }
[ "sagar.massand@gmail.com" ]
sagar.massand@gmail.com
e803acdb2294fc1410d222ed47d8dcbe2ab78515
77222f794141f3018763c071d48e38dfd7252246
/src/soundbuffer.cpp
f6cf062f60732579b1222d0a20bca728b29b07aa
[ "Zlib", "BSD-3-Clause", "MIT", "FTL", "LicenseRef-scancode-happy-bunny", "LicenseRef-scancode-warranty-disclaimer", "BSL-1.0", "SGI-B-2.0", "LicenseRef-scancode-synthesis-toolkit", "LicenseRef-scancode-khronos" ]
permissive
dakodun/uair
c3101ee83d5f89b688feef8c5fe6b7ff67c78ab2
a2a6ed6c13e796937c06f2731146e85185680e69
refs/heads/master
2021-11-28T10:38:18.194923
2021-11-13T22:17:05
2021-11-13T22:17:05
18,681,066
0
0
null
null
null
null
UTF-8
C++
false
false
2,361
cpp
/* **************************************************************** ** ** Uair Engine ** Copyright (c) 2010 - 2017, Iain M. Crawford ** ** This software is provided 'as-is', without any express or ** implied warranty. In no event will the authors be held liable ** for any damages arising from the use of this software. ** ** Permission is granted to anyone to use this software for any ** purpose, including commercial applications, and to alter it ** and redistribute it freely, subject to the following ** restrictions: ** ** 1. The origin of this software must not be misrepresented; ** you must not claim that you wrote the original ** software. If you use this software in a product, an ** acknowledgment in the product documentation would be ** appreciated but is not required. ** ** 2. Altered source versions must be plainly marked as such, ** and must not be misrepresented as being the original ** software. ** ** 3. This notice may not be removed or altered from any ** source distribution. ** **************************************************************** */ #include "soundbuffer.hpp" namespace uair { SoundBuffer::SoundBuffer(SoundBuffer&& other) : SoundBuffer() { swap(*this, other); } SoundBuffer::~SoundBuffer() { } SoundBuffer& SoundBuffer::operator=(SoundBuffer other) { swap(*this, other); return *this; } void swap(SoundBuffer& first, SoundBuffer& second) { using std::swap; swap(first.mSampleData, second.mSampleData); swap(first.mNumChannels, second.mNumChannels); } void SoundBuffer::LoadFromFile(const std::string& filename) { using namespace std::placeholders; std::ifstream oggFile(filename.c_str(), std::ios::in | std::ios::binary); // open the ogg file on disk SoundLoaderOgg slo; slo.Decode(oggFile, std::bind(&SoundBuffer::DecoderCallback, this, _1, _2, _3, _4)); // decode the entire ogg file } unsigned int SoundBuffer::GetTypeID() { return static_cast<unsigned int>(Resources::SoundBuffer); } int SoundBuffer::DecoderCallback(const int& serial, const int& numChannels, const int& numSamples, std::vector<int>& samples) { mSampleData.insert(mSampleData.end(), samples.begin(), samples.end()); // add the samples into the array mNumChannels = numChannels; // set the number of channels return numSamples; // return the number of samples used (all of them) } }
[ "github@chikin.net" ]
github@chikin.net
c5ad784120061b33d38be0cfed15aff55f57f342
b367fe5f0c2c50846b002b59472c50453e1629bc
/xbox_leak_may_2020/xbox trunk/xbox/private/ui/xapp/cdda.cpp
e567984ba410e6154a688265aaabe095167bfeaa
[]
no_license
sgzwiz/xbox_leak_may_2020
11b441502a659c8da8a1aa199f89f6236dd59325
fd00b4b3b2abb1ea6ef9ac64b755419741a3af00
refs/heads/master
2022-12-23T16:14:54.706755
2020-09-27T18:24:48
2020-09-27T18:24:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,204
cpp
#include "std.h" #include "xapp.h" #include "cdda.h" //////////////////////////////////////////////////////////////////////////// CCDDAStreamer::CCDDAStreamer(CNtIoctlCdromService* pDrive, DWORD dwRetries) { ASSERT(pDrive != NULL); m_ibChunk = 0; m_pDrive = pDrive; m_dwRetries = dwRetries; m_dwCurFrame = 0; m_chunk = (BYTE *)XPhysicalAlloc(CDDA_BUFFER_SIZE, -1, 0, PAGE_READWRITE); } CCDDAStreamer::~CCDDAStreamer() { if (m_chunk) XPhysicalFree(m_chunk); } int CCDDAStreamer::ReadFrames(void* pvBuffer, DWORD nFrameCount) { #ifdef _DEBUG const DWORD dwStartTime = GetTickCount(); #endif DWORD nTotalFrames = m_pDrive->GetTrackFrame(m_pDrive->GetTrackCount()); nFrameCount = min(nFrameCount, nTotalFrames - m_dwCurFrame); ASSERT((int)nFrameCount > 0); HRESULT hr = m_pDrive->Read(m_dwCurFrame, nFrameCount, pvBuffer, m_dwRetries); if (FAILED(hr)) { ZeroMemory(pvBuffer, nFrameCount * CDAUDIO_BYTES_PER_FRAME); if (hr != HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER)) { return -1; } else { // REVIEW: we probably hit end of the disc but need better way to detect this return 0; } } #ifdef _DEBUG const DWORD dwEndTime = GetTickCount(); if(dwEndTime - dwStartTime >= nFrameCount * 1000 / CDAUDIO_FRAMES_PER_SECOND) { TRACE(_T("\001CCDDAStreamer: read of frames %lu through %lu took longer than real-time (%lu ms)\n"), m_dwCurFrame, m_dwCurFrame + nFrameCount - 1, dwEndTime - dwStartTime); } #endif m_dwCurFrame += nFrameCount; return nFrameCount * CDAUDIO_BYTES_PER_FRAME; } int CCDDAStreamer::Read(void* pvBuffer, int cbWanted) { BYTE *pbBuffer = (BYTE *)pvBuffer; int cbRead; if (!m_chunk) return -1; if (m_ibChunk) { cbRead = min(cbWanted, CDDA_BUFFER_SIZE - m_ibChunk); CopyMemory(pbBuffer, m_chunk + m_ibChunk, cbRead); m_ibChunk += cbRead; m_ibChunk %= CDDA_BUFFER_SIZE; cbWanted -= cbRead; pbBuffer += cbRead; } while (cbWanted >= CDDA_MAX_FRAMES_PER_READ * CDAUDIO_BYTES_PER_FRAME) { cbRead = ReadFrames(pbBuffer, CDDA_MAX_FRAMES_PER_READ); if (cbRead <= 0) return cbRead; cbWanted -= cbRead; pbBuffer += cbRead; } while (cbWanted >= CDDA_BUFFER_SIZE) { cbRead = ReadFrames(pbBuffer, CDDA_BUFFER_SIZE / CDAUDIO_BYTES_PER_FRAME); if (cbRead <= 0) return cbRead; cbWanted -= cbRead; pbBuffer += cbRead; } if (cbWanted) { cbRead = ReadFrames(m_chunk, CDDA_BUFFER_SIZE / CDAUDIO_BYTES_PER_FRAME); if (cbRead <= 0) return cbRead; if (cbRead < CDDA_BUFFER_SIZE) ZeroMemory(m_chunk + cbRead, CDDA_BUFFER_SIZE - cbRead); m_ibChunk = cbWanted; cbRead = min(cbRead, cbWanted); CopyMemory(pbBuffer, m_chunk, cbRead); cbWanted -= cbRead; pbBuffer += cbRead; } return pbBuffer - (LPBYTE)pvBuffer; }
[ "benjamin.barratt@icloud.com" ]
benjamin.barratt@icloud.com
bd72938528701a16c9143e960f5b68ffd7076d1a
0e3cf2d88620e4311a9d0fda2bee2d93b6607119
/Scripts/Legion/EyeOfAzshara/boss_lady_hatecoil.cpp
dae1ed2560a33474a056ec59a845bffa5d08eb81
[]
no_license
SquallSpiegel/Project-Darkspear
67b1d895cf31a6796ffc0322c9e0a9b78f298245
b93487efb808e0421e1551d1fb951f406c521f26
refs/heads/master
2023-03-16T00:43:51.943898
2019-01-05T10:21:38
2019-01-05T10:21:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,440
cpp
/* * Copyright (C) 2017-2019 Project Darkspear <https://github.com/Hymn-WoW/Project-Darkspear> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "AreaTrigger.h" #include "AreaTriggerAI.h" #include "ScriptMgr.h" #include "eye_of_azshara.h" enum Spells { SPELL_STATIC_NOVA = 193597, SPELL_FOCUSED_LIGHTING = 193611, SPELL_BECKON_STORM = 193682, SPELL_BECKON_STORM_SUMMON = 193683, SPELL_CURSE_OF_THE_WITCH_DEBUFF = 193698, SPELL_CURSE_OF_THE_WITCH_1_TARGET = 193712, SPELL_CURSE_OF_THE_WITCH_3_TARGETS = 193716, SPELL_CURSE_OF_THE_WITCH_KNOCK_BACK = 193700, SPELL_CURSE_OF_THE_WITCH_KILL = 193720, SPELL_ARCANE_SHIELDING = 197868, SPELL_SAND_DUNE_GOB = 193061, SPELL_CRACKLING_THUNDER_CHECK = 197324, SPELL_CRACKLING_THUNDER_DAMAGE = 197326, // Heroic & Mythic SPELL_MONSOON_DAMAGE = 196610, SPELL_MONSOON_VISUAL = 196609, SPELL_MONSOON_TARGET = 196624, SPELL_MONSOON_MISSILE = 196630 // Triggers the spawn of the Monsoon NPC }; // 91784 struct boss_lady_hatecoil : public BossAI { boss_lady_hatecoil(Creature* creature) : BossAI(creature, DATA_LADY_HATECOIL) { } void Reset() override { BossAI::Reset(); if (!_arcanistsDead) DoCastSelf(SPELL_ARCANE_SHIELDING, true); me->GetInstanceScript()->SetData(DATA_RESPAWN_DUNES, 0); } void JustDied(Unit* killer) override { BossAI::JustDied(killer); me->GetInstanceScript()->SetData(DATA_BOSS_DIED, 0); } void ScheduleTasks() override { events.ScheduleEvent(SPELL_BECKON_STORM, 20s); events.ScheduleEvent(SPELL_CURSE_OF_THE_WITCH_DEBUFF, 40s); events.ScheduleEvent(SPELL_STATIC_NOVA, 14s); events.ScheduleEvent(SPELL_FOCUSED_LIGHTING, 29s); events.ScheduleEvent(SPELL_CRACKLING_THUNDER_CHECK, 1s); if (IsHeroic()) events.ScheduleEvent(SPELL_MONSOON_TARGET, 15s); } void DoAction(int32 param) override { if (param == 1) { _arcanistsDead = true; me->RemoveAurasDueToSpell(SPELL_ARCANE_SHIELDING); me->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); } } void ExecuteEvent(uint32 eventId) override { switch (eventId) { case SPELL_BECKON_STORM: { Talk(3); DoCastSelf(SPELL_BECKON_STORM, false); events.Repeat(45s); break; } case SPELL_CURSE_OF_THE_WITCH_DEBUFF: { uint32 spellId = urand(0, 1) ? SPELL_CURSE_OF_THE_WITCH_1_TARGET : SPELL_CURSE_OF_THE_WITCH_3_TARGETS; DoCastSelf(spellId, false); events.Repeat(40s); break; } case SPELL_STATIC_NOVA: { Talk(2); DoCastSelf(SPELL_STATIC_NOVA, false); events.Repeat(35s); break; } case SPELL_FOCUSED_LIGHTING: { DoCastSelf(SPELL_FOCUSED_LIGHTING, false); events.Repeat(35s); break; } case SPELL_CRACKLING_THUNDER_CHECK: { DoCastSelf(SPELL_CRACKLING_THUNDER_CHECK, true); events.Repeat(1s); break; } case SPELL_MONSOON_TARGET: { Talk(6); DoCastSelf(SPELL_MONSOON_TARGET, true); events.Repeat(25s, 35s); break; } } } private: bool _arcanistsDead = false; }; // 193597 class spell_lady_hatecoil_static_nova : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_static_nova); void FilterTargets(std::list<WorldObject*>& targets) { targets.remove_if([](WorldObject* object) { if (Unit* target = object->ToUnit()) if (target->FindNearestCreature(NPC_SAND_DUNE, 5.0f, true)) return true; return false; }); } void Register() override { OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_lady_hatecoil_static_nova::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_lady_hatecoil_static_nova::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); } }; // 193611 class spell_lady_hatecoil_focused_lightning : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_focused_lightning); void HandleDamage(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); if (target && target->ToPlayer()) { if (Creature* sandDune = target->FindNearestCreature(NPC_SAND_DUNE, 5.0f, true)) { if (GameObject* dune = target->FindNearestGameObject(GOB_SAND_DUNE, 5.0f)) { sandDune->RemoveGameObject(dune, true); sandDune->DisappearAndDie(); } } } } void Register() override { OnEffectHitTarget += SpellEffectFn(spell_lady_hatecoil_focused_lightning::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); } }; // 193682 class spell_lady_hatecoil_beckon_storm : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_beckon_storm); void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); target->CastSpell(target, SPELL_BECKON_STORM_SUMMON, true); } void Register() override { OnEffectHitTarget += SpellEffectFn(spell_lady_hatecoil_beckon_storm::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // 193712 && 193716 class spell_lady_hatecoil_curse_of_the_witch : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_curse_of_the_witch); void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); if (Unit* caster = GetCaster()) caster->CastSpell(target, SPELL_CURSE_OF_THE_WITCH_DEBUFF, true); } void Register() override { OnEffectHitTarget += SpellEffectFn(spell_lady_hatecoil_curse_of_the_witch::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // 193698 class aura_lady_hatecoil_curse_of_the_witch : public AuraScript { PrepareAuraScript(aura_lady_hatecoil_curse_of_the_witch); void OnRemove(AuraEffect const* /*auraEff*/, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); target->CastSpell(target, SPELL_CURSE_OF_THE_WITCH_KNOCK_BACK, true); target->CastSpell(target, SPELL_CURSE_OF_THE_WITCH_KILL, true); } void Register() override { OnEffectRemove += AuraEffectRemoveFn(aura_lady_hatecoil_curse_of_the_witch::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; // 197324 class spell_lady_hatecoil_crackling_thunder : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_crackling_thunder); void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); Unit* caster = GetCaster(); if (caster && target && target->GetDistance(Position(-3434.230469f, 4592.095703f, -0.437837f)) > 42.0f) caster->CastSpell(target, SPELL_CRACKLING_THUNDER_DAMAGE, true); } void Register() override { OnEffectHitTarget += SpellEffectFn(spell_lady_hatecoil_crackling_thunder::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // 196624 class spell_lady_hatecoil_monsoon_target : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_monsoon_target); void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); Unit* caster = GetCaster(); if (caster && target) caster->CastSpell(target, SPELL_MONSOON_MISSILE, true); } void Register() override { OnEffectHitTarget += SpellEffectFn(spell_lady_hatecoil_monsoon_target::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // 99852 struct npc_lady_hatecoil_monsoon : public ScriptedAI { npc_lady_hatecoil_monsoon(Creature* creature) : ScriptedAI(creature) { } void Reset() override { DoCastSelf(SPELL_MONSOON_VISUAL, true); me->setFaction(16); // Same faction as Lady Hatecoil me->SetSpeed(MOVE_RUN, 2.0f); if (Unit* victim = me->SelectNearestPlayer(100.0f)) me->GetMotionMaster()->MoveFollow(victim, 0.0f, 0.0f); } }; // Spell: 196610 // AT: 100101 (custom) struct at_lady_hatecoil_monsoon : AreaTriggerAI { at_lady_hatecoil_monsoon(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { } void OnUnitEnter(Unit* unit) override { Unit* caster = at->GetCaster(); if (caster) { if (Player* player = unit->ToPlayer()) caster->CastSpell(player, SPELL_MONSOON_DAMAGE, true); else if (Creature* creature = unit->ToCreature()) { if (creature->GetEntry() == NPC_SAND_DUNE) { if (GameObject* dune = creature->FindNearestGameObject(GOB_SAND_DUNE, 5.0f)) { creature->RemoveGameObject(dune, true); creature->DisappearAndDie(); at->Remove(); if (Creature* casterCre = caster->ToCreature()) casterCre->DisappearAndDie(); } } } } } }; // Criteria ID: 29404 class achievement_stay_salty : public AchievementCriteriaScript { public: achievement_stay_salty() : AchievementCriteriaScript("achievement_stay_salty") { } bool OnCheck(Player* /*player*/, Unit* /*target*/) override { // TODO return false; } }; void AddSC_boss_lady_hatecoil() { RegisterCreatureAI(boss_lady_hatecoil); RegisterCreatureAI(npc_lady_hatecoil_monsoon); RegisterSpellScript(spell_lady_hatecoil_static_nova); RegisterSpellScript(spell_lady_hatecoil_focused_lightning); RegisterSpellScript(spell_lady_hatecoil_beckon_storm); RegisterSpellScript(spell_lady_hatecoil_curse_of_the_witch); RegisterSpellScript(spell_lady_hatecoil_crackling_thunder); RegisterSpellScript(spell_lady_hatecoil_monsoon_target); RegisterAuraScript(aura_lady_hatecoil_curse_of_the_witch); RegisterAreaTriggerAI(at_lady_hatecoil_monsoon); new achievement_stay_salty(); }
[ "lordn00dle2@gmail.com" ]
lordn00dle2@gmail.com
9244c0f202281ff985344b06fe77ae7f77e05ce6
847e5c2984a5d5d425e6a47565a9fb57d15dbe13
/Libraries/LibJS/Lexer.cpp
75ec759f3f9c56a742e6aa56e3a4932e0a2b88b0
[ "BSD-2-Clause" ]
permissive
rizzrackguy/serenity
7616511a187d22b64c65e19a6f5e6cb57e0dc64d
dd00175ae2d6f23b08cb803eb86fc0108c393971
refs/heads/master
2022-04-15T01:14:30.855454
2020-04-12T17:22:42
2020-04-12T17:23:39
255,151,103
0
0
BSD-2-Clause
2020-04-12T19:04:07
2020-04-12T19:04:07
null
UTF-8
C++
false
false
15,213
cpp
/* * Copyright (c) 2020, Stephan Unverwerth <s.unverwerth@gmx.de> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. */ #include "Lexer.h" #include <AK/HashMap.h> #include <AK/StringBuilder.h> #include <ctype.h> #include <stdio.h> namespace JS { HashMap<String, TokenType> Lexer::s_keywords; HashMap<String, TokenType> Lexer::s_three_char_tokens; HashMap<String, TokenType> Lexer::s_two_char_tokens; HashMap<char, TokenType> Lexer::s_single_char_tokens; Lexer::Lexer(StringView source) : m_source(source) , m_current_token(TokenType::Eof, StringView(nullptr), StringView(nullptr), 0, 0) { if (s_keywords.is_empty()) { s_keywords.set("await", TokenType::Await); s_keywords.set("break", TokenType::Break); s_keywords.set("case", TokenType::Case); s_keywords.set("catch", TokenType::Catch); s_keywords.set("class", TokenType::Class); s_keywords.set("const", TokenType::Const); s_keywords.set("continue", TokenType::Continue); s_keywords.set("default", TokenType::Default); s_keywords.set("delete", TokenType::Delete); s_keywords.set("do", TokenType::Do); s_keywords.set("else", TokenType::Else); s_keywords.set("false", TokenType::BoolLiteral); s_keywords.set("finally", TokenType::Finally); s_keywords.set("for", TokenType::For); s_keywords.set("function", TokenType::Function); s_keywords.set("if", TokenType::If); s_keywords.set("in", TokenType::In); s_keywords.set("instanceof", TokenType::Instanceof); s_keywords.set("interface", TokenType::Interface); s_keywords.set("let", TokenType::Let); s_keywords.set("new", TokenType::New); s_keywords.set("null", TokenType::NullLiteral); s_keywords.set("return", TokenType::Return); s_keywords.set("switch", TokenType::Switch); s_keywords.set("throw", TokenType::Throw); s_keywords.set("true", TokenType::BoolLiteral); s_keywords.set("try", TokenType::Try); s_keywords.set("typeof", TokenType::Typeof); s_keywords.set("var", TokenType::Var); s_keywords.set("void", TokenType::Void); s_keywords.set("while", TokenType::While); s_keywords.set("yield", TokenType::Yield); } if (s_three_char_tokens.is_empty()) { s_three_char_tokens.set("===", TokenType::EqualsEqualsEquals); s_three_char_tokens.set("!==", TokenType::ExclamationMarkEqualsEquals); s_three_char_tokens.set("**=", TokenType::AsteriskAsteriskEquals); s_three_char_tokens.set("<<=", TokenType::ShiftLeftEquals); s_three_char_tokens.set(">>=", TokenType::ShiftRightEquals); s_three_char_tokens.set(">>>", TokenType::UnsignedShiftRight); } if (s_two_char_tokens.is_empty()) { s_two_char_tokens.set("=>", TokenType::Arrow); s_two_char_tokens.set("+=", TokenType::PlusEquals); s_two_char_tokens.set("-=", TokenType::MinusEquals); s_two_char_tokens.set("*=", TokenType::AsteriskEquals); s_two_char_tokens.set("/=", TokenType::SlashEquals); s_two_char_tokens.set("%=", TokenType::PercentEquals); s_two_char_tokens.set("&=", TokenType::AmpersandEquals); s_two_char_tokens.set("|=", TokenType::PipeEquals); s_two_char_tokens.set("&&", TokenType::DoubleAmpersand); s_two_char_tokens.set("||", TokenType::DoublePipe); s_two_char_tokens.set("??", TokenType::DoubleQuestionMark); s_two_char_tokens.set("**", TokenType::DoubleAsterisk); s_two_char_tokens.set("==", TokenType::EqualsEquals); s_two_char_tokens.set("<=", TokenType::LessThanEquals); s_two_char_tokens.set(">=", TokenType::GreaterThanEquals); s_two_char_tokens.set("!=", TokenType::ExclamationMarkEquals); s_two_char_tokens.set("--", TokenType::MinusMinus); s_two_char_tokens.set("++", TokenType::PlusPlus); s_two_char_tokens.set("<<", TokenType::ShiftLeft); s_two_char_tokens.set(">>", TokenType::ShiftRight); s_two_char_tokens.set("?.", TokenType::QuestionMarkPeriod); } if (s_single_char_tokens.is_empty()) { s_single_char_tokens.set('&', TokenType::Ampersand); s_single_char_tokens.set('*', TokenType::Asterisk); s_single_char_tokens.set('[', TokenType::BracketOpen); s_single_char_tokens.set(']', TokenType::BracketClose); s_single_char_tokens.set('^', TokenType::Caret); s_single_char_tokens.set(':', TokenType::Colon); s_single_char_tokens.set(',', TokenType::Comma); s_single_char_tokens.set('{', TokenType::CurlyOpen); s_single_char_tokens.set('}', TokenType::CurlyClose); s_single_char_tokens.set('=', TokenType::Equals); s_single_char_tokens.set('!', TokenType::ExclamationMark); s_single_char_tokens.set('-', TokenType::Minus); s_single_char_tokens.set('(', TokenType::ParenOpen); s_single_char_tokens.set(')', TokenType::ParenClose); s_single_char_tokens.set('%', TokenType::Percent); s_single_char_tokens.set('.', TokenType::Period); s_single_char_tokens.set('|', TokenType::Pipe); s_single_char_tokens.set('+', TokenType::Plus); s_single_char_tokens.set('?', TokenType::QuestionMark); s_single_char_tokens.set(';', TokenType::Semicolon); s_single_char_tokens.set('/', TokenType::Slash); s_single_char_tokens.set('~', TokenType::Tilde); s_single_char_tokens.set('<', TokenType::LessThan); s_single_char_tokens.set('>', TokenType::GreaterThan); } consume(); } void Lexer::consume() { if (m_position >= m_source.length()) { m_position = m_source.length() + 1; m_current_char = EOF; return; } if (m_current_char == '\n') { m_line_number++; m_line_column = 1; } else { m_line_column++; } m_current_char = m_source[m_position++]; } void Lexer::consume_exponent() { consume(); if (m_current_char == '-' || m_current_char == '+') consume(); while (isdigit(m_current_char)) { consume(); } } bool Lexer::is_eof() const { return m_current_char == EOF; } bool Lexer::is_identifier_start() const { return isalpha(m_current_char) || m_current_char == '_' || m_current_char == '$'; } bool Lexer::is_identifier_middle() const { return is_identifier_start() || isdigit(m_current_char); } bool Lexer::is_line_comment_start() const { return m_current_char == '/' && m_position < m_source.length() && m_source[m_position] == '/'; } bool Lexer::is_block_comment_start() const { return m_current_char == '/' && m_position < m_source.length() && m_source[m_position] == '*'; } bool Lexer::is_block_comment_end() const { return m_current_char == '*' && m_position < m_source.length() && m_source[m_position] == '/'; } bool Lexer::is_numeric_literal_start() const { return isdigit(m_current_char) || (m_current_char == '.' && m_position < m_source.length() && isdigit(m_source[m_position])); } void Lexer::syntax_error(const char* msg) { m_has_errors = true; if (m_log_errors) fprintf(stderr, "Syntax Error: %s (line: %zu, column: %zu)\n", msg, m_line_number, m_line_column); } Token Lexer::next() { size_t trivia_start = m_position; // consume whitespace and comments while (true) { if (isspace(m_current_char)) { do { consume(); } while (isspace(m_current_char)); } else if (is_line_comment_start()) { consume(); do { consume(); } while (!is_eof() && m_current_char != '\n'); } else if (is_block_comment_start()) { consume(); do { consume(); } while (!is_eof() && !is_block_comment_end()); consume(); // consume * consume(); // consume / } else { break; } } size_t value_start = m_position; auto token_type = TokenType::Invalid; if (is_identifier_start()) { // identifier or keyword do { consume(); } while (is_identifier_middle()); StringView value = m_source.substring_view(value_start - 1, m_position - value_start); auto it = s_keywords.find(value); if (it == s_keywords.end()) { token_type = TokenType::Identifier; } else { token_type = it->value; } } else if (is_numeric_literal_start()) { if (m_current_char == '0') { consume(); if (m_current_char == '.') { // decimal consume(); while (isdigit(m_current_char)) { consume(); } if (m_current_char == 'e' || m_current_char == 'E') { consume_exponent(); } } else if (m_current_char == 'e' || m_current_char == 'E') { consume_exponent(); } else if (m_current_char == 'o' || m_current_char == 'O') { // octal consume(); while (m_current_char >= '0' && m_current_char <= '7') { consume(); } } else if (m_current_char == 'b' || m_current_char == 'B') { // binary consume(); while (m_current_char == '0' || m_current_char == '1') { consume(); } } else if (m_current_char == 'x' || m_current_char == 'X') { // hexadecimal consume(); while (isxdigit(m_current_char)) { consume(); } } else if (isdigit(m_current_char)) { // octal without 'O' prefix. Forbidden in 'strict mode' // FIXME: We need to make sure this produces a syntax error when in strict mode do { consume(); } while (isdigit(m_current_char)); } } else { // 1...9 or period while (isdigit(m_current_char)) { consume(); } if (m_current_char == '.') { consume(); while (isdigit(m_current_char)) { consume(); } } if (m_current_char == 'e' || m_current_char == 'E') { consume_exponent(); } } token_type = TokenType::NumericLiteral; } else if (m_current_char == '"' || m_current_char == '\'') { char stop_char = m_current_char; consume(); while (m_current_char != stop_char && m_current_char != '\n' && !is_eof()) { if (m_current_char == '\\') { consume(); } consume(); } if (m_current_char != stop_char) { syntax_error("unterminated string literal"); token_type = TokenType::UnterminatedStringLiteral; } else { consume(); token_type = TokenType::StringLiteral; } } else if (m_current_char == EOF) { token_type = TokenType::Eof; } else { // There is only one four-char operator: >>>= bool found_four_char_token = false; if (m_position + 2 < m_source.length()) { if (m_current_char == '>' && m_source[m_position] == '>' && m_source[m_position + 1] == '>' && m_source[m_position + 2] == '=') { found_four_char_token = true; consume(); consume(); consume(); consume(); token_type = TokenType::UnsignedShiftRightEquals; } } bool found_three_char_token = false; if (!found_four_char_token && m_position + 1 < m_source.length()) { char second_char = m_source[m_position]; char third_char = m_source[m_position + 1]; char three_chars[] { (char)m_current_char, second_char, third_char, 0 }; auto it = s_three_char_tokens.find(three_chars); if (it != s_three_char_tokens.end()) { found_three_char_token = true; consume(); consume(); consume(); token_type = it->value; } } bool found_two_char_token = false; if (!found_four_char_token && !found_three_char_token && m_position < m_source.length()) { char second_char = m_source[m_position]; char two_chars[] { (char)m_current_char, second_char, 0 }; auto it = s_two_char_tokens.find(two_chars); if (it != s_two_char_tokens.end()) { found_two_char_token = true; consume(); consume(); token_type = it->value; } } bool found_one_char_token = false; if (!found_four_char_token && !found_three_char_token && !found_two_char_token) { auto it = s_single_char_tokens.find(m_current_char); if (it != s_single_char_tokens.end()) { found_one_char_token = true; consume(); token_type = it->value; } } if (!found_four_char_token && !found_three_char_token && !found_two_char_token && !found_one_char_token) { consume(); token_type = TokenType::Invalid; } } m_current_token = Token( token_type, m_source.substring_view(trivia_start - 1, value_start - trivia_start), m_source.substring_view(value_start - 1, m_position - value_start), m_line_number, m_line_column - m_position + value_start); return m_current_token; } }
[ "kling@serenityos.org" ]
kling@serenityos.org
395859f1272e37abd8c7b0093e037c35f8c1c1b3
4424eb0c6d2666a37bbe5b9d6b3550ca11d51729
/SerialPrograms/Source/NintendoSwitch/Programs/VirtualConsole.h
897ba33a6d65d445b642053b852997e6089d5346
[ "LicenseRef-scancode-proprietary-license", "MIT" ]
permissive
ercdndrs/Arduino-Source
cd87e4036f0e36c3dd0180448293721be95cc654
c0490f0f06aaa38759aa8f11def9e1349e551679
refs/heads/main
2023-05-05T07:43:52.845481
2021-05-24T02:27:25
2021-05-24T02:27:25
369,910,477
0
0
MIT
2021-05-22T21:39:34
2021-05-22T21:39:33
null
UTF-8
C++
false
false
2,248
h
/* Virtual Game Console * * From: https://github.com/PokemonAutomation/Arduino-Source * */ #ifndef PokemonAutomation_VirtualConsole_H #define PokemonAutomation_VirtualConsole_H #include <QJsonObject> #include "Common/Qt/QtJsonTools.h" #include "CommonFramework/Panels/RightPanel.h" #include "CommonFramework/Windows/MainWindow.h" #include "NintendoSwitch/Framework/SwitchSystem.h" namespace PokemonAutomation{ namespace NintendoSwitch{ class VirtualConsoleUI; class VirtualConsole : public RightPanel{ public: VirtualConsole() : RightPanel( QColor(), "Virtual Console", "SerialPrograms/VirtualConsole.md", "Play your Switch from your computer. Device logging is logged to the output window." ) , m_switch( "Switch Settings", "Switch 0", PABotBaseLevel::NOT_PABOTBASE, FeedbackType::NONE ) {} VirtualConsole(const QJsonValue& json) : VirtualConsole() { m_switch.load_json(json.toObject().value(m_name)); } virtual QJsonValue to_json() const override{ return m_switch.to_json(); } virtual QWidget* make_ui(MainWindow& window) override; private: friend class VirtualConsoleUI; SwitchSystemFactory m_switch; }; class VirtualConsoleUI final : public RightPanelUI{ friend class VirtualConsole; private: VirtualConsoleUI(VirtualConsole& factory, MainWindow& window) : RightPanelUI(factory) , m_window(window) {} virtual void make_body(QWidget& parent, QVBoxLayout& layout) override{ VirtualConsole& factory = static_cast<VirtualConsole&>(m_factory); m_switch = (SwitchSystem*)factory.m_switch.make_ui(parent, m_window.output_window()); layout.addWidget(m_switch); // QLabel* controls = new QLabel("Controls", this); // layout.addWidget(controls); } private: MainWindow& m_window; SwitchSystem* m_switch; }; inline QWidget* VirtualConsole::make_ui(MainWindow& window){ VirtualConsoleUI* widget = new VirtualConsoleUI(*this, window); widget->construct(); return widget; } } } #endif
[ "a-yee@u.northwestern.edu" ]
a-yee@u.northwestern.edu
3e5c001d463ce600cf58656641ad7314790e0892
5947865dc56dc2906951f21b780db5dc901848c5
/GeeksforGeeks/Palindrome numbers.cpp
c7fa510064a2cd021b74cfae8543eee738f687e3
[]
no_license
nishu112/Geek-Codes
6d9cad76291d7c56900bd988c0c123db6d900c36
f7eece428655c1f656e402b321260f234de62153
refs/heads/master
2021-10-07T09:31:13.379816
2018-12-04T16:36:54
2018-12-04T16:36:54
121,122,751
0
0
null
null
null
null
UTF-8
C++
false
false
456
cpp
#include<iostream> using namespace std; int main() { int t; cin>>t; while(t--) { long long n; cin>>n; long long num=n,len=0; while(num) { ++len; num=num>>1; } long long i=0,j=len-1; int flag=1; while(j>i) { if((!(n&(1<<i)))!=(!(n&(1<<j)))) { flag=0; break; } --j,++i; } cout<<flag<<'\n'; } return 0; }
[ "nishant.sharma112@gmail.com" ]
nishant.sharma112@gmail.com
9cef3c531e617dcf519ef5a53c362a7cff4f6206
0975c61a1485440b5d483dccec9bcd1c218be2e9
/Attribute_types.h
51c6c691204727a81c4b3a1bded946cba23fa2d1
[]
no_license
Lipovr/Starmap
71c4ce6cf58eebacc2d64ae82491fc7b83917867
7bc57cb6580fb491bc5c253e93a356da59423a9f
refs/heads/master
2022-10-01T11:48:52.702621
2020-05-26T18:38:02
2020-05-26T18:38:02
267,121,602
0
0
null
null
null
null
UTF-8
C++
false
false
1,481
h
#ifndef ATTRIBUTE_TYPES_H_INCLUDED #define ATTRIBUTE_TYPES_H_INCLUDED namespace ATTRIBUTES{ namespace ATTRIBUTES_TYPE{ enum TYPE{ ///ALL NAME=0, DESCRIPTION, END_TEXT, ///STAR STARCLASS, ECONOMY, //POP, END_LIST, ///WSROUTE //CONNECTED_NAME, UNDEFINED }; } namespace ATTRIBUTES_STAR{ namespace ECONOMY { enum ECONOMY_T{ EXTRACTION=0, REFINERY, INDUSTRIAL, TERRAFORMING, TOURISM, HIGHTECH, AGRICULTURE, END }; } namespace STARCLASS{ enum STARCLASS_T{ O=0, B, A, F, G, K, M, END }; } } } namespace LISTS { const std::vector<std::string> starclass={ "O", "B", "A", "F", "G", "K", "M" }; const std::vector<std::string> economy={ "Extraction", "Refinery", "Industrial", "Terraforming", "Tourism", "Hightech", "Agriculture" }; } #endif // ATTRIBUTE_TYPES_H_INCLUDED
[ "lipov.ra@phystech.edu" ]
lipov.ra@phystech.edu
cbf73f5b78d1b0c71b47d3e0f361cfcaaa9bd1b7
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_1674486_1/C++/jdh/pbA.cpp
400a8f6e181975e08b90206f73e5c46b413009e2
[]
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
2,941
cpp
// g++ -std=c++0x #include <iostream> // cout, endl #include <iomanip> // setprecision #include <iterator> // ostream_iterator #include <vector> #include <algorithm> // sort #include <cstring> // memset #include <deque> using namespace std; typedef long long ll; typedef unsigned long long ull; struct Node { ll v,d; }; typedef vector<int> VI; typedef vector<double> VD; typedef vector<ll> VLL; typedef vector<vector<ll> > MLL; typedef vector<ull> VULL; typedef vector<vector<ull> > MULL; typedef vector<Node> VNode; typedef vector<vector<Node> > MNode; #define MAX(a,b) ((a)>(b)?(a):(b)) #define FOR(i,N) for(int i=0;i<(N);++i) #define FORLL(i,N) for(ll i=0;i<(N);++i) #define FORULL(i,N) for(ull i=0;i<(N);++i) #define FOR2(i,A,B) for(int i=(A);i<(B);++i) #define FORLL2(i,A,B) for(ll i=(A);i<(B);++i) #define FORULL2(i,A,B) for(ull i=(A);i<(B);++i) #define SORT(v) sort((v).begin(),(v).end()) #define PB push_back #define PF pop_front #define X first #define Y second #define MATRIX(m,T,size,init) vector<vector<T> > m(size,vector<T>(size,init)); #define FILE __FILE__ << " " #define LINE "line " << __LINE__ << " : " #define FUNC "(function " << __FUNCTION__ << ") " #define log cout<<endl<<FILE<<LINE<<FUNC; #define printL(l) for(auto it=l.begin();it!=l.end();++it) cout<<*it<<","; cout<<endl; #define printM(m) for(auto it=m.begin();it!=m.end();++it){ auto l=*it; for(auto it2=l.begin();it2!=l.end();++it2) cout<<*it2<<","; cout<<endl;} cout<<endl; #define printLNode(lNode) for(auto it=lNode.begin();it!=lNode.end();++it){ Node node=*it; printNode(node); } #define printNode(node) cout<<"("<<node.v<<","<<node.d<<")"<<", "; #define copy(v,T,s) copy((v).begin(),(v).end(),ostream_iterator<T>(cout,s)); cout << endl; #define copyn(v,T,s,n) copy((v).begin(),(v).begin()+n,ostream_iterator<T>(cout,s)); cout << endl; void getRet(ull n,MLL M) { FORLL2(i,1,n) { //cout<<endl<<i<<":"<<endl; VI visited(n,0); deque<ull> d; d.PB(i); while(d.size()>0) { //for(auto it=d.begin();it!=d.end();++it) cout<<*it<<","; cout<<endl; ull a=d.front(); d.PF(); //for(auto it=d.begin();it!=d.end();++it) cout<<*it<<","; cout<<endl; FORLL2(j,1,n) { if(j==i) continue; if(M[a][j]==1) { if(visited[j]==1) { cout<<"Yes"; return; } d.PB(j); //for(auto it=d.begin();it!=d.end();++it) cout<<*it<<","; cout<<endl; visited[j]=1; } } } } cout<<"No"; return; } int main() { int nbCase; cin>>nbCase; //cout<<nbCase<<endl; FOR(i,nbCase) { ull n; cin>>n; //cout<<n<<endl; MLL M(n+1,VLL(n+1,0)); FORLL2(j,1,n+1) { ll nj; cin>>nj; FORLL(k,nj) { ll tmp; cin>>tmp; M[j][tmp]=1; } } //printM(M); cout<<"Case #"<<i+1<<": "; getRet(n+1,M); cout<<endl; } }
[ "eewestman@gmail.com" ]
eewestman@gmail.com
dc0cb618f84e622224d029448a048458734459cd
69b7d52bfcb7d25911829658f401e4cbf56ed8f8
/09/code/01.cpp
231dd0f026e3423b04b208951a3bac780c00d079
[]
no_license
jash-git/OpenCV-path-to-exploration
1c8699683cf47466975774b3a51e0e33bde7c6a4
e568f5689f65b341412244bfb968c2c9f5931e92
refs/heads/master
2020-06-19T22:52:11.057275
2019-07-15T06:15:11
2019-07-15T06:15:11
196,903,754
0
0
null
null
null
null
UTF-8
C++
false
false
1,145
cpp
#include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> #include <stdio.h> using namespace std; using namespace cv; int main() { Mat img, templ, result; img = imread("nba.jpg"); templ = imread("76.png"); int result_cols = img.cols - templ.cols + 1; int result_rows = img.rows - templ.rows + 1; result.create(result_cols, result_rows, CV_32FC1); matchTemplate(img, templ, result, CV_TM_SQDIFF_NORMED);//这里我们使用的匹配算法是标准平方差匹配 method=CV_TM_SQDIFF_NORMED,数值越小匹配度越好 normalize(result, result, 0, 1, NORM_MINMAX, -1, Mat()); double minVal = -1; double maxVal; Point minLoc; Point maxLoc; Point matchLoc; cout << "匹配度:" << minVal << endl; minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat()); cout << "匹配度:" << minVal << endl; matchLoc = minLoc; rectangle(img, matchLoc, Point(matchLoc.x + templ.cols, matchLoc.y + templ.rows), Scalar(0, 255, 0), 2, 8, 0); imshow("img", img); waitKey(0); return 0; }
[ "gitea@fake.local" ]
gitea@fake.local
64b8312ae8205d8c02e9019d152c48a7a360f800
cf85f8ee951490dc13648ec5815e022e31bf6676
/src/CryptoNoteCore/CryptoNoteBasic.h
5480a93e1e35346a799d58e47479ab09cacea106
[]
no_license
rainmanp7/phfx
1c61ee112c22e9c942287536891a7bf94bb9a829
c00be01f89ceca09003f4f10bb42ab80a363c9b5
refs/heads/master
2020-03-28T03:04:06.843858
2018-09-07T02:50:01
2018-09-07T02:50:01
147,617,262
0
0
null
null
null
null
UTF-8
C++
false
false
1,377
h
// Copyright (c) 2011-2016 The Cryptonote developers // Copyright (c) 2017-2018 PHF-project developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #pragma once #include <boost/utility/value_init.hpp> #include <CryptoNote.h> namespace CryptoNote { const Crypto::Hash NULL_HASH = boost::value_initialized<Crypto::Hash>(); const Crypto::PublicKey NULL_PUBLIC_KEY = boost::value_initialized<Crypto::PublicKey>(); const Crypto::SecretKey NULL_SECRET_KEY = boost::value_initialized<Crypto::SecretKey>(); KeyPair generateKeyPair(); struct RootBlockSerializer { RootBlockSerializer(RootBlock& rootBlock, uint64_t& timestamp, uint32_t& nonce, bool hashingSerialization, bool headerOnly) : m_rootBlock(rootBlock), m_timestamp(timestamp), m_nonce(nonce), m_hashingSerialization(hashingSerialization), m_headerOnly(headerOnly) { } RootBlock& m_rootBlock; uint64_t& m_timestamp; uint32_t& m_nonce; bool m_hashingSerialization; bool m_headerOnly; }; inline RootBlockSerializer makeRootBlockSerializer(const Block& b, bool hashingSerialization, bool headerOnly) { Block& blockRef = const_cast<Block&>(b); return RootBlockSerializer(blockRef.rootBlock, blockRef.timestamp, blockRef.nonce, hashingSerialization, headerOnly); } }
[ "muslimsoap@gmail.com" ]
muslimsoap@gmail.com
ceb46a0de8c5b66f5e8fff49deeda7d1e9b98be6
e104892af303d85c5e661d099b500dc1e35b882d
/Sample4_12/app/src/main/cpp/bndev/MyVulkanManager.h
0a29bf3df0403a1e89773e0d81670d32418d2646
[ "Unlicense" ]
permissive
siwangqishiq/Vulkan_Develpment_Samples
624900dabaca75c9ad21ef5a1ee5af6709dcc9a8
409c973e0b37086c854cde07b1e620c3d8d9f15d
refs/heads/master
2023-08-16T04:13:54.777841
2021-10-14T06:53:11
2021-10-14T06:53:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,603
h
#ifndef VULKANEXBASE_MYVULKANMANAGER_H #define VULKANEXBASE_MYVULKANMANAGER_H #include <android_native_app_glue.h> #include <vector> #include <vulkan/vulkan.h> #include "../vksysutil/vulkan_wrapper.h" #include <vector> #include "mylog.h" #include "DrawableObjectCommon.h" #include "ShaderQueueSuit_Common.h" #include "Cube.h" #define FENCE_TIMEOUT 100000000 class MyVulkanManager { public: public: static android_app* Android_application; static bool loopDrawFlag; static std::vector<const char *> instanceExtensionNames; static VkInstance instance; static uint32_t gpuCount; static std::vector<VkPhysicalDevice> gpus; static uint32_t queueFamilyCount; static std::vector<VkQueueFamilyProperties> queueFamilyprops; static uint32_t queueGraphicsFamilyIndex; static VkQueue queueGraphics; static uint32_t queuePresentFamilyIndex; static std::vector<const char *> deviceExtensionNames; static VkDevice device; static VkCommandPool cmdPool; static VkCommandBuffer cmdBuffer; static VkCommandBufferBeginInfo cmd_buf_info; static VkCommandBuffer cmd_bufs[1]; static VkSubmitInfo submit_info[1]; static uint32_t screenWidth; static uint32_t screenHeight; static VkSurfaceKHR surface; static std::vector<VkFormat> formats; static VkSurfaceCapabilitiesKHR surfCapabilities; static uint32_t presentModeCount; static std::vector<VkPresentModeKHR> presentModes; static VkExtent2D swapchainExtent; static VkSwapchainKHR swapChain; static uint32_t swapchainImageCount; static std::vector<VkImage> swapchainImages; static std::vector<VkImageView> swapchainImageViews; static VkFormat depthFormat; static VkFormatProperties depthFormatProps; static VkImage depthImage; static VkPhysicalDeviceMemoryProperties memoryroperties; static VkDeviceMemory memDepth; static VkImageView depthImageView; static VkSemaphore imageAcquiredSemaphore; static uint32_t currentBuffer; static VkRenderPass renderPass; static VkClearValue clear_values[2]; static VkRenderPassBeginInfo rp_begin; static VkFence taskFinishFence; static VkPresentInfoKHR present; static VkFramebuffer* framebuffers; static ShaderQueueSuit_Common* sqsCL; //绘制用对象 static Cube* cube1ForDraw; static Cube* cube2ForDraw; //三角形旋转角度 static float zAngle; static float yAngle; //两种视角标志位 static int ProjectPara; static void init_vulkan_instance(); static void enumerate_vulkan_phy_devices(); static void create_vulkan_devices(); static void create_vulkan_CommandBuffer(); static void create_vulkan_swapChain(); static void create_vulkan_DepthBuffer(); static void create_render_pass(); static void init_queue(); static void create_frame_buffer(); static void createDrawableObject(); static void drawObject(); static void doVulkan(); static void initPipeline(); static void createFence(); static void initPresentInfo(); static void initMatrix(); static void flushUniformBuffer(); static void flushTexToDesSet(); static void destroyFence(); static void destroyPipeline(); static void destroyDrawableObject(); static void destroy_frame_buffer(); static void destroy_render_pass(); static void destroy_vulkan_DepthBuffer(); static void destroy_vulkan_swapChain(); static void destroy_vulkan_CommandBuffer(); static void destroy_vulkan_devices(); static void destroy_vulkan_instance(); }; #endif
[ "709165253@qq.com" ]
709165253@qq.com
2f2d0e429507f30a32767296f98c5cad1bdcb45a
4fc9d5d49b9d0c9a8aec35e02418230c4a439bf7
/Samples/Physics/FreeTopFixedTip/PhysicsModule.cpp
c8b7b281179ee254c2a2c113d9b486aa2955d66a
[]
no_license
zhouxs1023/GTEngine
07d8a299522a8b33b6960dca06a4ca6cb459622c
16c1af003106798dd2d91800085818b40adfad1a
refs/heads/master
2020-03-27T18:03:37.798691
2019-12-30T13:49:17
2019-12-30T13:49:17
146,895,580
9
3
null
null
null
null
UTF-8
C++
false
false
3,296
cpp
// David Eberly, Geometric Tools, Redmond WA 98052 // Copyright (c) 1998-2019 // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt // File Version: 3.1.2 (2018/10/05) #include "PhysicsModule.h" PhysicsModule::PhysicsModule() : gravity(0.0f), mass(0.0f), length(0.0f), inertia1(0.0f), inertia3(0.0f), mTime(0.0f), mState(Vector3<float>::Zero()) { for (int i = 0; i < 5; ++i) { mAux[i] = 0.0f; } } void PhysicsModule::Initialize(float time, float deltaTime, float theta, float phi, float psi, float angVel1, float angVel2, float angVel3) { mTime = time; float cosPhi = std::cos(phi), sinPhi = std::sin(phi); float cosPsi = std::cos(psi), sinPsi = std::sin(psi); // State variables. mState[0] = theta; mState[1] = phi; mState[2] = psi; // Auxiliary variables. mAux[0] = mass * gravity * length / inertia1; // alpha mAux[1] = angVel1 * angVel1 + angVel2 * angVel2 + 2.0f * cosPhi * mAux[0]; // beta mAux[2] = angVel3 * inertia3 / inertia1; // epsilon mAux[3] = sinPhi * (angVel1 * sinPsi + angVel2 * cosPsi) + cosPhi * mAux[2]; // delta mAux[4] = angVel3; // RK4 differential equation solver. std::function<Vector3<float>(float, Vector3<float> const&)> odeFunction = [this](float, Vector3<float> const& input) -> Vector3<float> { float cs = std::cos(input[1]); float invSin = 1.0f / std::sin(input[1]); float numer = mAux[3] - mAux[2] * cs; float fraction = numer * invSin; float arg = mAux[1] - 2.0f * mAux[0] * cs - fraction * fraction; float thetaDotFunction = fraction * invSin; float phiDotFunction = std::sqrt(std::abs(arg)); float psiDotFunction = mAux[4] - cs * thetaDotFunction; return Vector3<float>{thetaDotFunction, phiDotFunction, psiDotFunction}; }; mSolver = std::make_unique<Solver>(deltaTime, odeFunction); } Matrix4x4<float> PhysicsModule::GetBodyAxes() const { float cosTheta = std::cos(mState[0]); float sinTheta = std::sin(mState[0]); float cosPhi = std::cos(mState[1]); float sinPhi = std::sin(mState[1]); float cosPsi = std::cos(mState[2]); float sinPsi = std::sin(mState[2]); Vector3<float> N{ cosTheta, sinTheta, 0.0f }; Vector3<float> axis3{ sinTheta * sinPhi, -cosTheta * sinPhi, cosPhi }; Vector3<float> axis3xN = Cross(axis3, N); Vector3<float> axis1 = cosPsi * N + sinPsi * axis3xN; Vector3<float> axis2 = cosPsi * axis3xN - sinPsi * N; Matrix4x4<float> rotate; #if defined(GTE_USE_MAT_VEC) rotate.SetCol(0, HLift(axis1, 0.0f)); rotate.SetCol(1, HLift(axis2, 0.0f)); rotate.SetCol(2, HLift(axis3, 0.0f)); rotate.SetCol(3, Vector4<float>::Unit(3)); #else rotate.SetRow(0, HLift(axis1, 0.0f)); rotate.SetRow(1, HLift(axis2, 0.0f)); rotate.SetRow(2, HLift(axis3, 0.0f)); rotate.SetRow(3, Vector4<float>::Unit(3)); #endif return rotate; } void PhysicsModule::Update() { // Apply a single step to the ODE solver. if (mSolver) { mSolver->Update(mTime, mState, mTime, mState); } }
[ "zhouxs1023@163.com" ]
zhouxs1023@163.com
06182957a588c3a14dd0bbf0a64bffadc0ecf125
84a7f7ff628a3bb6d318795a4c801df6ad2a9048
/Galactic_cluster/celestialbody.h
a86d9c48b2a0c7dffc2edba27e66dc3787630a6d
[]
no_license
emilblix/FYS-4150
8190d435d830452c30d6f5a3bc3ae547aa4b479e
5f9ee79426f6d034ead0d4d7283ccf6ec544bb23
refs/heads/master
2021-01-20T12:38:10.590619
2014-12-08T07:32:02
2014-12-08T07:32:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
600
h
#ifndef CELESTIAL_BODY_H #define CELESTIAL_BODY_H #include <vec3.h> class CelestialBody { public: double mass; // Relative mass of body compared to the Sun vec3 position; // Coordinates of body vec3 velocity; // Velocity of body vec3 acceleration; // Acceleration of body CelestialBody(double mass_, double x, double y, double z, double vx, double vy, double vz); CelestialBody(vec3 pos, vec3 vel, double mass_); void resetAcceleration(); }; #endif // CELESTIAL_BODY_H
[ "emilblix@gmail.com" ]
emilblix@gmail.com
8d32b96da13101ab1c0443b1d93d483558408227
73e7c20803be5d8ae467af1feba8a4a7fe219f4b
/Modules/Filtering/DistanceMap/include/itkReflectiveImageRegionConstIterator.h
c05128fc2563e28354e2bf3460046e0f7356a8aa
[ "LicenseRef-scancode-other-permissive", "SMLNJ", "BSD-3-Clause", "LicenseRef-scancode-mit-old-style", "LicenseRef-scancode-free-unknown", "BSD-4.3TAHOE", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-unknown-license-reference", "IJG", "Zlib", "Spencer-86", "libtiff", "Apache-2.0", "MIT", "LicenseRef-scancode-public-domain", "NTP", "BSD-2-Clause", "GPL-1.0-or-later", "FSFUL", "Libpng" ]
permissive
CIBC-Internal/itk
deaa8aabe3995f3465ec70a46805bd333967ed5b
6f7b1014a73857115d6da738583492008bea8205
refs/heads/master
2021-01-10T18:48:58.502855
2018-01-26T21:25:51
2018-01-26T21:25:51
31,582,564
0
2
Apache-2.0
2018-05-21T07:59:53
2015-03-03T06:12:12
C++
UTF-8
C++
false
false
7,261
h
/*========================================================================= * * Copyright Insight Software Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #ifndef itkReflectiveImageRegionConstIterator_h #define itkReflectiveImageRegionConstIterator_h #include "itkImageConstIteratorWithIndex.h" namespace itk { /** \class ReflectiveImageRegionConstIterator * \brief Multi-dimensional image iterator which only walks a region. * * ReflectiveImageRegionConstIterator is a templated class to represent a * multi-dimensional iterator. ReflectiveImageRegionConstIterator is templated * over the image type. ReflectiveImageRegionConstIterator is constrained to * walk only within the specified region. * * ReflectiveImageRegionConstIterator will perform two passes over the image * along each dimension. It is useful for algorithms that require to * go back and forth (once) over the data. * * By setting the BeginOffset and EndOffset parameters, you can arrange for * the starting point, when going forwards, to be different from the ending * point, when going backwards. Along dimension d, when going forwards the * iterator traverses the interval [BeginIndex[d]+BeginOffset[d], EndIndex[d]). * When going back, it traverses the interval (EndIndex[d]-EndOffset[d], * BeginIndex[d]]. Setting both offsets to (1, ..., 1) enables the * DanielssonDistanceMapImageFilter to process the entire image, * without encountering boundary conditions, rather * than removing a one-pixel border. * * \sa DanielssonDistanceMapImageFilter * * \ingroup Iterators * \ingroup ITKDistanceMap */ template< typename TImage > class ReflectiveImageRegionConstIterator:public ImageConstIteratorWithIndex< TImage > { public: /** Standard class typedefs. */ typedef ReflectiveImageRegionConstIterator Self; typedef ImageConstIteratorWithIndex< TImage > Superclass; /** Index typedef support. While this was already typdef'ed in the superclass * it needs to be redone here for this subclass to compile properly with gcc. * Note that we have to rescope Index back to itk::Index to that is it not * confused with ImageIterator::Index. */ typedef typename TImage::IndexType IndexType; /** Image typedef support. While this was already typdef'ed in the superclass * it needs to be redone here for this subclass to compile properly with gcc. * Note that we have to rescope Image back to itk::Image to that is it not * confused with ImageIterator::Image. */ typedef TImage ImageType; /** PixelContainer typedef support. Used to refer to the container for * the pixel data. While this was already typdef'ed in the superclass * it needs to be redone here for this subclass to compile properly * with gcc. */ typedef typename TImage::PixelContainer PixelContainer; typedef typename PixelContainer::Pointer PixelContainerPointer; /** Region typedef support. While this was already typdef'ed in the * superclass it needs to be redone here for this subclass to compile * properly with gcc. Note that we have to rescope Region back to * itk::ImageRegion so that is it not confused with * ImageIterator::Index. */ typedef typename TImage::RegionType RegionType; typedef typename TImage::SizeType SizeType; typedef typename TImage::SizeValueType SizeValueType; /** Type of the Offset taken from the image. These typedefs are * duplicated from the superclass for gcc support. */ typedef typename TImage::OffsetType OffsetType; typedef typename OffsetType::OffsetValueType OffsetValueType; /** Default constructor. Needed since we provide a cast constructor. */ ReflectiveImageRegionConstIterator(); /** Default destructor. */ ~ReflectiveImageRegionConstIterator() {} /** Constructor establishes an iterator to walk a particular image and a * particular region of that image. */ ReflectiveImageRegionConstIterator(TImage *ptr, const RegionType & region); /** Copy Constructor. The copy constructor is provided to make sure the * handle to the image is properly reference counted. */ ReflectiveImageRegionConstIterator(const Self & it); /** Constructor that can be used to cast from an ImageIterator to an * ReflectiveImageRegionConstIterator. Many routines return an * ImageIterator but for a particular task, you may want an * ReflectiveImageRegionConstIterator. Rather than provide * overloaded APIs that return different types of Iterators, itk * returns ImageIterators and uses constructors to cast from * an * ImageIterator to a ReflectiveImageRegionConstIterator. */ ReflectiveImageRegionConstIterator(const ImageConstIteratorWithIndex< TImage > & it); /** operator= is provided to make sure the handle to the image is properly * reference counted. */ Self & operator=(const Self & it); bool IsReflected(unsigned int) const; /** Increment (prefix) the fastest moving dimension of the iterator's index. * This operator will constrain the iterator within the region (i.e. the * iterator will automatically wrap from the end of the row of the region * to the beginning of the next row of the region) up until the iterator * tries to moves past the last pixel of the region. Here, the iterator * will be set to be one pixel past the end of the region. * \sa operator++(int) */ Self & operator++(); /** Move an iterator to the beginning of the region. */ void GoToBegin(); /** Is the iterator at the beginning of the region? */ bool IsAtBegin(void) const { return !this->m_Remaining; } /** Set the begin offset. Forward iteration starts at this offset * from the current region. */ void SetBeginOffset(const OffsetType & offset) { m_BeginOffset = offset; } /** Set the end offset. Reverse iteration starts at this offset * from the current region. */ void SetEndOffset(const OffsetType & offset) { m_EndOffset = offset; } /** Get the begin offset. Forward iteration starts at this offset * from the current region. */ OffsetType GetBeginOffset(const OffsetType & ) { return m_BeginOffset; } /** Get the end offset. Reverse iteration starts at this offset * from the current region. */ OffsetType GetEndOffset(const OffsetType & ) { return m_EndOffset; } /** Fill both offsets with a single value. */ void FillOffsets(const OffsetValueType & value); private: bool m_IsFirstPass[TImage::ImageDimension]; OffsetType m_BeginOffset; OffsetType m_EndOffset; }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkReflectiveImageRegionConstIterator.hxx" #endif #endif
[ "ayla@sci.utah.edu" ]
ayla@sci.utah.edu
8a45b92519f1edbaed47284a7cdb59bdeacd858d
95afc50eea3e69c5cfc150b1f0d031f0da95a1d0
/lib/ldcp_sdk/third_party/Asio/asio-1.18.0/src/tests/unit/ip/address_v6_range.cpp
a11eaf6dfa149c8560bcdaa4baefad326537a895
[ "Apache-2.0", "BSL-1.0" ]
permissive
LitraTech/ltme_node
09a04be74b132993210852c8e712984b678ffc9f
f6733085cfd94072764029f4b00171de969e8637
refs/heads/master
2023-07-19T13:00:39.556775
2023-07-13T04:42:25
2023-07-13T04:42:25
232,500,654
6
12
Apache-2.0
2022-08-10T10:52:00
2020-01-08T07:04:26
C++
UTF-8
C++
false
false
697
cpp
// // address_v6_range.cpp // ~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Disable autolinking for unit tests. #if !defined(BOOST_ALL_NO_LIB) #define BOOST_ALL_NO_LIB 1 #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. #include "asio/ip/address_v6_range.hpp" #include "../unit_test.hpp" //------------------------------------------------------------------------------ ASIO_TEST_SUITE ( "ip/address_v6_range", ASIO_TEST_CASE(null_test) )
[ "dnyang@litratech.com" ]
dnyang@litratech.com
0001f23c76099556ce15784cbd97b222475d2d11
0aa91508c25477a70e78156d8e85763e7b37bec6
/UnitFrameDetailCount.cpp
f09d16484fcca74614975870598b8ce1605b8cb1
[]
no_license
Zummer/calculate1c
55969cbb2926ff9adcd5a04bbf05bf84038109c8
b3ca83bd3eeb49294680fc570bca1e525dd84520
refs/heads/master
2016-09-06T15:40:23.818475
2014-12-12T12:01:20
2014-12-12T12:01:20
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
3,690
cpp
// --------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "UnitFrameDetailCount.h" #include "UnitFramePlaceOperation.h" // --------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "AdvSpin" #pragma resource "*.dfm" #include "SquareDetail.h" TFrameDetailCount *FrameDetailCount; // --------------------------------------------------------------------------- __fastcall TFrameDetailCount::TFrameDetailCount(TComponent* Owner, double w, double h, int copyCount) : TFrame(Owner) { ToggleSP(0); spW->FloatValue = w; spH->FloatValue = h; spCount->Value = copyCount; ToggleSP(1); Minimize(); } // --------------------------------------------------------------------------- __fastcall TFrameDetailCount::~TFrameDetailCount() { if (Parent) { Parent->Tag -= 1; } } // --------------------------------------------------------------------------- void __fastcall TFrameDetailCount::spChange(TObject *Sender) { TAdvSpinEdit *e = dynamic_cast<TAdvSpinEdit*>(Sender); if (e->Value < 1) { return; } if (dynamic_cast<TSquareDetail*>(Owner)) { TSquareDetail *detail = dynamic_cast<TSquareDetail*>(Owner); TShapeDetail *last = dynamic_cast<TShapeDetail*> (FormPlace->lastMovedShape); if (last && last->detail != detail) { FormPlace->lastMovedShape->Pen->Color = clBlack; FormPlace->lastMovedShape = (TShape*)detail->listOfShapes->First(); FormPlace->lastMovedShape->Pen->Color = clBlue; } detail->SetW(spW->FloatValue); detail->SetH(spH->FloatValue); detail->SetCount(spCount->Value); // выделим операцию TfrPlaceOperation *detailOperation = (TfrPlaceOperation*)detail->operation; if (!detailOperation->Selected) { detailOperation->Select(); } // поднимем деталь detail->ShowOn(FormPlace->sbForPlace); // поднимем направляющую FormPlace->GuidLine->BringToFront(); // надо бы посчитать fSbornyZakaz->Sum(); } } // --------------------------------------------------------------------------- void TFrameDetailCount::ToggleSP(int onoff) { switch (onoff) { case 0: // отключим на время реакцию на события spCount->OnChange = NULL; spW->OnChange = NULL; spH->OnChange = NULL; break; case 1: // снова включим spCount->OnChange = spChange; spW->OnChange = spChange; spH->OnChange = spChange; break; default: ; // } } } // --------------------------------------------------------------------------- void __fastcall TFrameDetailCount::spKeyPress(TObject *Sender, wchar_t &Key) { TAdvSpinEdit *sp = dynamic_cast<TAdvSpinEdit*>(Sender); if (Key == VK_RETURN) { sp->Brush->Color = clWindow; sp->Repaint(); sp->OnChange = spChange; spChange(Sender); } else { sp->OnChange = NULL; sp->Brush->Color = RGB(255, 125, 125); } } // --------------------------------------------------------------------------- void __fastcall TFrameDetailCount::Button1Click(TObject *Sender) { if (!minimize) Minimize(); else Maximize(); } // --------------------------------------------------------------------------- void __fastcall TFrameDetailCount::Minimize() { Height = 27; minimize = true; if (Parent && Parent->Parent) { Parent->Parent->Height -= 27; } } // --------------------------------------------------------------------------- void __fastcall TFrameDetailCount::Maximize() { Height = 54; minimize = false; if (Parent && Parent->Parent) { Parent->Parent->Height += 27; } } // ---------------------------------------------------------------------------
[ "afanasev@comefoto.ru" ]
afanasev@comefoto.ru
e4fcf02029752af7b2304f0e104f0fc50cfc725c
5c0e1b164b1781ef7c1f16c50006a3c56562a451
/examples/ClientProject/SimpleFramework/appSetTime.ino
91beaaedc0099f61f44ccbc20ee08dd072e6f769
[ "MIT" ]
permissive
jakub-vesely/TTGO_TWatch_Library
f4094c352423e11c267d24218801c7edfe00d239
ecb146c25e3ee59da2ed806f95839f1130e7881a
refs/heads/master
2022-12-20T10:27:00.244787
2020-09-22T13:09:56
2020-09-22T13:09:56
297,645,028
0
0
MIT
2020-09-22T12:41:16
2020-09-22T12:41:15
null
UTF-8
C++
false
false
3,670
ino
// Set the time - no error checking, you might want to add it void appSetTime() { // Get the current info RTC_Date tnow = ttgo->rtc->getDateTime(); hh = tnow.hour; mm = tnow.minute; ss = tnow.second; dday = tnow.day; mmonth = tnow.month; yyear = tnow.year; //Set up the interface buttons ttgo->tft->fillScreen(TFT_BLACK); ttgo->tft->fillRect(0, 35, 80, 50, TFT_BLUE); ttgo->tft->fillRect(161, 35, 78, 50, TFT_BLUE); ttgo->tft->fillRect(81, 85, 80, 50, TFT_BLUE); ttgo->tft->fillRect(0, 135, 80, 50, TFT_BLUE); ttgo->tft->fillRect(161, 135, 78, 50, TFT_BLUE); ttgo->tft->fillRect(0, 185, 80, 50, TFT_BLUE); ttgo->tft->setTextColor(TFT_GREEN); ttgo->tft->drawNumber(1, 30, 40, 2); ttgo->tft->drawNumber(2, 110, 40, 2); ttgo->tft->drawNumber(3, 190, 40, 2); ttgo->tft->drawNumber(4, 30, 90, 2); ttgo->tft->drawNumber(5, 110, 90, 2); ttgo->tft->drawNumber(6, 190, 90, 2); ttgo->tft->drawNumber(7, 30, 140, 2); ttgo->tft->drawNumber(8, 110, 140, 2); ttgo->tft->drawNumber(9, 190, 140, 2); ttgo->tft->drawNumber(0, 30, 190, 2); ttgo->tft->fillRoundRect(120, 200, 119, 39, 6, TFT_WHITE); ttgo->tft->setTextSize(2); ttgo->tft->setCursor(0, 0); ttgo->tft->setCursor(155, 210); ttgo->tft->setTextColor(TFT_BLACK); ttgo->tft->print("DONE"); ttgo->tft->setTextColor(TFT_WHITE); int wl = 0; // Track the current number selected byte curnum = 1; // Track which digit we are on prtTime(curnum); // Display the time for the current digit while (wl != 13) { wl = getTnum(); if (wl != -1 && wl != 13) switch (curnum) { case 1: hh = wl * 10 + hh % 10; break; case 2: hh = int(hh / 10) * 10 + wl; break; case 3: mm = wl * 10 + mm % 10; break; case 4: mm = int(mm / 10) * 10 + wl; break; } while (getTnum() != -1) {} curnum += 1; if (curnum > 4) curnum = 1; prtTime(curnum); } } while (getTnum() != -1) {} ttgo->rtc->setDateTime(yyear, mmonth, dday, hh, mm, 0); ttgo->tft->fillScreen(TFT_BLACK); } // prtTime will display the current selected time and highlight // the current digit to be updated in yellow void prtTime(byte digit) { ttgo->tft->fillRect(0, 0, 100, 34, TFT_BLACK); if (digit == 1) ttgo->tft->setTextColor(TFT_YELLOW); else ttgo->tft->setTextColor(TFT_WHITE); ttgo->tft->drawNumber(int(hh / 10), 5, 5, 2); if (digit == 2) ttgo->tft->setTextColor(TFT_YELLOW); else ttgo->tft->setTextColor(TFT_WHITE); ttgo->tft->drawNumber(hh % 10, 25, 5, 2); ttgo->tft->setTextColor(TFT_WHITE); ttgo->tft->drawString(":", 45, 5, 2); if (digit == 3) ttgo->tft->setTextColor(TFT_YELLOW); else ttgo->tft->setTextColor(TFT_WHITE); ttgo->tft->drawNumber(int(mm / 10), 65 , 5, 2); if (digit == 4) ttgo->tft->setTextColor(TFT_YELLOW); else ttgo->tft->setTextColor(TFT_WHITE); ttgo->tft->drawNumber(mm % 10, 85, 5, 2); } // getTnum takes care of translating where we pressed into // a number that was pressed. Returns -1 for no press // and 13 for DONE int getTnum() { int16_t x, y; if (!ttgo->getTouch(x, y)) return - 1; if (y < 85) { if (x < 80) return 1; else if (x > 160) return 3; else return 2; } else if (y < 135) { if (x < 80) return 4; else if (x > 160) return 6; else return 5; } else if (y < 185) { if (x < 80) return 7; else if (x > 160) return 9; else return 8; } else if (x < 80) return 0; else return 13; }
[ "lewisxhe@outlook.com" ]
lewisxhe@outlook.com
ddd58805cac26ddf828b61912252c038885ecbea
83bfbbe8a3d8c6d6972bfff7edc84458d4cf17fd
/Maze/Stack.cpp
6dafa4d5795b7572cc6d51e6b5090e6a7510276d
[]
no_license
afrojuju1/metaMouse2.0
f4ab7c9e0131fbc6199ecd9b18e7b7b3a7a3b6a0
ccfd6ac43817febecd62cbe1867bab62373ed370
refs/heads/master
2021-06-12T20:43:43.021474
2017-03-20T05:58:54
2017-03-20T05:58:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
146
cpp
#include "Stack.h" Block pop() { Block b = stack[stackPos]; stackPos--; return b; } void push(Block b) { stackPos++; stack[stackPos] = b; }
[ "adeoa.bello.262@my.csun.edu" ]
adeoa.bello.262@my.csun.edu
9df6791be9a643e601ab61a8202ee2eb068278b7
5069f2992e1e3594295819b832032a5395e8e99c
/Actions/SaveAction.h
8b12086bdd6af40aa97de8177f15547b94af8265
[]
no_license
AhmedHisham552/Paint-for-kids
36e8ec9bffeb9be9451a601d49a9c07a3f41d6b7
503da2c694417017221914091fa6f9576c23a916
refs/heads/master
2020-04-12T19:27:52.804002
2018-12-22T09:04:46
2018-12-22T09:04:46
162,709,486
0
0
null
null
null
null
UTF-8
C++
false
false
241
h
#pragma once #include "Action.h" #include"../ApplicationManager.h" class SaveAction : public Action { private: string name; public: SaveAction(ApplicationManager* pApp); void ReadActionParameters(); void Execute(); ~SaveAction(); };
[ "40614397+AhmedHisham552@users.noreply.github.com" ]
40614397+AhmedHisham552@users.noreply.github.com
b65144c6eafe9bd6df4ef28d7bf523ce31ecd92c
bcf138c82fcba9acc7d7ce4d3a92618b06ebe7c7
/rdr2/0x18714953CCED17D3.cpp
46b1fab23d280c0f7fc6a4bb2b1b5f3e782e83ee
[]
no_license
DeepWolf413/additional-native-data
aded47e042f0feb30057e753910e0884c44121a0
e015b2500b52065252ffbe3c53865fe3cdd3e06c
refs/heads/main
2023-07-10T00:19:54.416083
2021-08-12T16:00:12
2021-08-12T16:00:12
395,340,507
1
0
null
null
null
null
UTF-8
C++
false
false
424
cpp
// braithwaites2.ysc @ L52175 bool func_1247(var uParam0) { if (func_33(uParam0) <= iLocal_92) { if (ENTITY::DOES_ENTITY_EXIST(Local_14.f_19[0]) && !CAM::_0x139EFB0A71DD9011()) { if (!VEHICLE::IS_VEHICLE_DRIVEABLE(Local_14.f_19[0], false, false)) { return true; } if (VEHICLE::_0x18714953CCED17D3(Local_14.f_19[0])) { return true; } } } return false; }
[ "jesper15fuji@live.dk" ]
jesper15fuji@live.dk
c679b3d22c8d58af9e9600143a5b66f577bb517d
363c0e6a653d4808640031f82b2c3ee62e13c640
/BlendDemo/Framework3/Math/SphericalHarmonics.cpp
b76d5236968a9016087bf1ef2a5e71a8bb851636
[ "MIT" ]
permissive
dtrebilco/PreMulAlpha
8d7e9a7209c2b2bda6c89e7e9a6daad73ec34ff0
4eaf2b0967a4440bbaf7a83a560ee84626015d3d
refs/heads/master
2021-01-10T12:24:21.105947
2018-03-12T13:00:17
2018-03-12T13:00:17
53,249,801
115
3
null
null
null
null
UTF-8
C++
false
false
23,989
cpp
/* * * * * * * * * * * * * Author's note * * * * * * * * * * * *\ * _ _ _ _ _ _ _ _ _ _ _ _ * * |_| |_| |_| |_| |_|_ _|_| |_| |_| _|_|_|_|_| * * |_|_ _ _|_| |_| |_| |_|_|_|_|_| |_| |_| |_|_ _ _ * * |_|_|_|_|_| |_| |_| |_| |_| |_| |_| |_| |_|_|_|_ * * |_| |_| |_|_ _ _|_| |_| |_| |_|_ _ _|_| _ _ _ _|_| * * |_| |_| |_|_|_| |_| |_| |_|_|_| |_|_|_|_| * * * * http://www.humus.name * * * * This file is a part of the work done by Humus. You are free to * * use the code in any way you like, modified, unmodified or copied * * into your own work. However, I expect you to respect these points: * * - If you use this file and its contents unmodified, or use a major * * part of this file, please credit the author and leave this note. * * - For use in anything commercial, please request my approval. * * - Share your work and ideas too as much as you can. * * * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "SphericalHarmonics.h" #define REDIST_FACTOR 1 //#define REDIST_FACTOR 1e-30f const double sqrt2 = 1.4142135623730950488016887242097; double rcp[MAX_BANDS]; double fTab[MAX_BANDS * (MAX_BANDS + 1)]; double kTab[MAX_BANDS * (MAX_BANDS + 1) / 2]; double getFactor(const int l, const int m){ /* double f = 1; for (int i = l - m + 1; i <= l + m; i++){ f *= i; } double pmm = 1; for (int i = 0; i <= m; i++){ pmm *= (1 - 2 * i); } double x = sqrt(pmm * pmm / f); */ double x = 1.0; int i = l - m + 1; int n = l + m; int k = 0; while (true){ bool b0 = (k <= m); bool b1 = (i <= n); if (!b0 && !b1) break; if ((x <= 1.0 && b0) || !b1){ int f = (1 - 2 * k); x *= (f * f); k++; } else { x /= i; i++; } } x = sqrt(x); if (m & 1) x = -x; return x; } void initSH(){ long double fact[2 * MAX_BANDS]; long double d = 1.0L; rcp[0] = 0; for (int i = 1; i < MAX_BANDS; i++){ rcp[i] = double(1.0L / (long double) i); } fact[0] = d; for (int i = 1; i < 2 * MAX_BANDS; i++){ d *= i; fact[i] = d; } double *dstF = fTab; double *dstK = kTab; for (int l = 0; l < MAX_BANDS; l++){ // double fct = 1; // double pmm = 1; for (int m = 0; m <= l; m++){ // pmm *= fct; // fct -= 2; if (l != m){ *dstF++ = double(2 * l - 1) / double(l - m); *dstF++ = double(l + m - 1) / double(l - m); } else { *dstF++ = 0; *dstF++ = 0; } // *dstK++ = (double) (pmm * sqrt((long double(2 * l + 1) * fact[l - m]) / (4.0L * 3.1415926535897932384626433832795L * fact[l + m])) / REDIST_FACTOR); *dstK++ = (double) (getFactor(l, m) * sqrt((double(2 * l + 1) / (4.0L * 3.1415926535897932384626433832795L))) / REDIST_FACTOR); } } } /* float K_list[] = { 0.28209478785f, 0.4886025051f, 0.34549414466f, 0.63078312173f, 0.2575161311f, 0.12875806555f, 0.7463526548f, 0.21545345308f, 0.068132364148f, 0.027814921189f, 0.84628436355f, 0.18923493652f, 0.044603102283f, 0.011920680509f, 0.0042145970123f, 0.93560256661f, 0.17081687686f, 0.032281355422f, 0.0065894040825f, 0.0015531374369f, 0.00049114518199f, 1.0171072221f, 0.15694305165f, 0.024814875307f, 0.0041358125511f, 0.00075509260929f, 0.00016098628522f, 4.6472737553e-005f, 1.0925484154f, 0.14599792317f, 0.019867800849f, 0.0028097313415f, 0.00042358293734f, 7.0597156223e-005f, 1.384524143e-005f, 3.7002964192e-006f, 1.1631066067f, 0.13707342814f, 0.01638340829f, 0.0020166581537f, 0.00026034944814f, 3.6103972493e-005f, 5.5709639026e-006f, 1.0171141988e-006f, 2.5427854971e-007f, 1.2296226727f, 0.12961361028f, 0.013816857281f, 0.0015075427227f, 0.00017069560029f, 2.0402026496e-005f, 2.6338902949e-006f, 3.801693177e-007f, 6.51985001e-008f, 1.5367433848e-008f, 1.2927207185f, 0.12325608434f, 0.011860322246f, 0.0011630002801f, 0.00011748076923f, 1.2383560401e-005f, 1.384524143e-006f, 1.678982142e-007f, 2.2848052974e-008f, 3.7064436234e-009f, 8.2878598968e-010f, 1.3528790761f, 0.11775300918f, 0.0103276221f, 0.00092005770282f, 8.3989393007e-005f, 7.9362516666e-006f, 7.8580600881e-007f, 8.2831226229e-008f, 9.5013932764e-009f, 1.2266245975e-009f, 1.8927228454e-010f, 4.0352986651e-011f, 1.4104739392f, 0.11292829394f, 0.0091000212546f, 0.00074301362407f, 6.1917802006e-005f, 5.3094077196e-006f, 4.7299963365e-007f, 4.4300474576e-008f, 4.4300474576e-009f, 4.8335780492e-010f, 5.9497232884e-011f, 8.7723884023e-012f, 1.7906562843e-012f, 1.4658075153f, 0.10865288191f, 0.0080985076633f, 0.00061044798366f, 4.6819223098e-005f, 3.6784655714e-006f, 2.9836295628e-007f, 2.5216272196e-008f, 2.2464440745e-009f, 2.1419003838e-010f, 2.2330855175e-011f, 2.6317165207e-012f, 3.7218091959e-013f, 7.2990683522e-014f, 1.5191269238f, 0.10482971704f, 0.0072686330764f, 0.00050890610675f, 3.6166382172e-005f, 2.6237851318e-006f, 1.9556539711e-007f, 1.5088197955e-008f, 1.2158416398e-009f, 1.0349931362e-010f, 9.4481514597e-012f, 9.4481514597e-013f, 1.0697924913e-013f, 1.4558031857e-014f, 2.7512094195e-015f, 1.5706373067f, 0.1013842022f, 0.0065717617374f, 0.00042960950433f, 2.8451584469e-005f, 1.9182054336e-006f, 1.3236875055e-007f, 9.40703748e-009f, 6.9349600383e-010f, 5.3504378288e-011f, 4.3686141937e-012f, 3.8315281119e-013f, 3.6868896447e-014f, 4.0227263989e-015f, 5.2820985382e-016f, 9.6437484011e-017f, 1.6205111811f, 0.098257923044f, 0.0059797867672f, 0.00036664425087f, 2.2738311173e-005f, 1.4323789666e-006f, 9.2076807318e-008f, 6.0713648798e-009f, 4.131040555e-010f, 2.9210867898e-011f, 2.1652535868e-012f, 1.7011838825e-013f, 1.4377627964e-014f, 1.3349292434e-015f, 1.4071389748e-016f, 1.7870682851e-017f, 3.159120257e-018f, 1.6688952713f, 0.095404392594f, 0.0054718171853f, 0.00031591551249f, 1.8424566844e-005f, 1.0894674765e-006f, 6.5578235786e-008f, 4.0360614093e-009f, 2.552629366e-010f, 1.668706019e-011f, 1.1354106326e-012f, 8.1100759469e-014f, 6.1482327086e-015f, 5.0200109853e-016f, 4.508102946e-017f, 4.6010633023e-018f, 5.6635174197e-019f, 9.7128522441e-020f, 1.7159156055f, 0.092786089356f, 0.0050320322108f, 0.00027451986316f, 1.5111821107e-005f, 8.4214886554e-007f, 4.7677290989e-008f, 2.7526496787e-009f, 1.6276758768e-010f, 9.9057199338e-012f, 6.2400170243e-013f, 4.0967718822e-014f, 2.8270411804e-015f, 2.0728871658e-016f, 1.6387611941e-017f, 1.4263585367e-018f, 1.4123054005e-019f, 1.6880278198e-020f, 2.8133796997e-021f, 1.7616813855f, 0.090372348238f, 0.0046482520257f, 0.00024035539025f, 1.2529390841e-005f, 6.6035687919e-007f, 3.5297559928e-008f, 1.9199341526e-009f, 1.0666300848e-010f, 6.0776889666e-012f, 3.5689418491e-013f, 2.1719888413e-014f, 1.3792142934e-015f, 9.2152631233e-017f, 6.5490023309e-018f, 5.0228554997e-019f, 4.2450876965e-020f, 4.0848375405e-021f, 4.7485271873e-022f, 7.7031282861e-023f, 1.8062879733f, 0.088137828247f, 0.0043109620947f, 0.00021187222805f, 1.0489238301e-005f, 5.2446191507e-007f, 2.6557161397e-008f, 1.3659529897e-009f, 7.1595390337e-011f, 3.8379157708e-012f, 2.1127030986e-013f, 1.1999347271e-014f, 7.0706831878e-016f, 4.3517046791e-017f, 2.8207911768e-018f, 1.9465308412e-019f, 1.4508584271e-020f, 1.1925982807e-021f, 1.1169706286e-022f, 1.2647201906e-023f, 1.9996982025e-024f, 1.8498192293f, 0.08606137925f, 0.0040126324977f, 0.00018790873322f, 8.8581026337e-006f, 4.2133697531e-007f, 2.0271584676e-008f, 9.8915204822e-010f, 4.9090791891e-011f, 2.4858088755e-012f, 1.2888318631e-013f, 6.8694969119e-015f, 3.7815335923e-016f, 2.1617588692e-017f, 1.2918980235e-018f, 8.1381925936e-020f, 5.4619972377e-021f, 3.9625492741e-022f, 3.1725784981e-023f, 2.8961546815e-024f, 3.1982678122e-025f, 4.935034375e-026f, 1.8923493652f, 0.084125190447f, 0.0037472338125f, 0.00016758139065f, 7.539843222e-006f, 3.4201423397e-007f, 1.5676196712e-008f, 7.2774916245e-010f, 3.4306424518e-011f, 1.6467610741e-012f, 8.0739104336e-014f, 4.0572926514e-015f, 2.0979760847e-016f, 1.1214153878e-017f, 6.2300854879e-019f, 3.6211636357e-020f, 2.2202778798e-021f, 1.4514410557e-022f, 1.026323813e-023f, 8.0142425394e-025f, 7.1396547136e-026f, 7.6988876748e-027f, 1.1606509873e-027f, 1.9339444301f, 0.082314141311f, 0.0035098867787f, 0.00015020928745f, 6.4639785415e-006f, 2.8024901181e-007f, 1.2266166018e-008f, 5.4315496068e-010f, 2.438837769e-011f, 1.1131720502e-012f, 5.1789450806e-014f, 2.4633729657e-015f, 1.2020029285e-016f, 6.0402919859e-018f, 3.1401982755e-019f, 1.6980247563e-020f, 9.6131721747e-022f, 5.7449692048e-023f, 3.6628585823e-024f, 2.5276125564e-025f, 1.927286506e-026f, 1.6774875866e-027f, 1.7682271734e-028f, 2.6071087338e-029f, 1.9746635149f, 0.080615300422f, 0.0032966047858f, 0.00013526133275f, 5.5780833482e-006f, 2.3161730416e-007f, 9.7013813075e-009f, 4.1069221938e-010f, 1.7608283638e-011f, 7.6630218528e-013f, 3.3932431105e-014f, 1.5329109834e-015f, 7.0858835275e-017f, 3.3628115035e-018f, 1.6448048712e-019f, 8.328793221e-021f, 4.3896594565e-022f, 2.4237839636e-023f, 1.4135795137e-024f, 8.8005616488e-026f, 5.9333374532e-027f, 4.4224486263e-028f, 3.7646382751e-029f, 3.8829279014e-030f, 5.6045236728e-031f, 2.0145597375f, 0.079017533944f, 0.0031041018936f, 0.00012231875022f, 4.842645695e-006f, 1.9293562265e-007f, 7.7484810674e-009f, 3.1424240259e-010f, 1.2893521955e-011f, 5.362998122e-013f, 2.2662803405e-014f, 9.7525177961e-016f, 4.2850103139e-017f, 1.9279172853e-018f, 8.9118008037e-020f, 4.2485343345e-021f, 2.0982015523e-022f, 1.0791984281e-023f, 5.8186479667e-025f, 3.3154823825e-026f, 2.0177383221e-027f, 1.33045725e-028f, 9.7033567732e-030f, 8.0861306443e-031f, 8.1682254459e-032f, 1.1551615206e-032f, 2.0536810547f, 0.077511196458f, 0.0029296478521f, 0.00011104801525f, 4.2275256908e-006f, 1.618803252e-007f, 6.2446691179e-009f, 2.4307341574e-010f, 9.5635956295e-012f, 3.8102277015e-013f, 1.5401932619e-014f, 6.3301553126e-016f, 2.6514102928e-017f, 1.1346988547e-018f, 4.9759836503e-020f, 2.24334668e-021f, 1.0436993321e-022f, 5.0331651141e-024f, 2.5292606351e-025f, 1.3330374005e-026f, 7.4287269985e-028f, 4.4237425515e-029f, 2.8555135383e-030f, 2.0396525274e-031f, 1.6653693149e-032f, 1.6489613353e-033f, 2.2866979406e-034f, 2.0920709389f, 0.076087884417f, 0.0027709573165f, 0.00010118105521f, 3.7094774603e-006f, 1.3673315326e-007f, 5.074643279e-009f, 1.8991375165e-010f, 7.178065106e-012f, 2.7446017901e-013f, 1.0635115913e-014f, 4.1843303907e-016f, 1.6750727509e-017f, 6.8384558696e-019f, 2.8543163317e-020f, 1.2215346231e-021f, 5.3775063301e-023f, 2.4443210591e-024f, 1.1522639975e-025f, 5.6630685934e-027f, 2.9205046332e-028f, 1.5932658987e-029f, 9.2921154198e-031f, 5.8768498016e-032f, 4.114617867e-033f, 3.2943308133e-034f, 3.1997369449e-035f, 4.3542904589e-036f, 2.1297689433f, 0.074740237775f, 0.0026261042693f, 9.2500577646e-005f, 3.2703892858e-006f, 1.1620822308e-007f, 4.1555975734e-009f, 1.4975734135e-010f, 5.4466218462e-012f, 2.0022180112e-013f, 7.4514838584e-015f, 2.8123813477e-016f, 1.0784990145e-017f, 4.2108312072e-019f, 1.6776353093e-020f, 6.8375310661e-022f, 2.8589153611e-023f, 1.2302812869e-024f, 5.4692674337e-026f, 2.5227849463e-027f, 1.2137754732e-028f, 6.1304919139e-030f, 3.2768857649e-031f, 1.8732709079e-032f, 1.1617532993e-033f, 7.9789544184e-035f, 6.26885864e-036f, 5.9771221905e-037f, 7.9872654985e-038f, 2.1668111802f, 0.073461779026f, 0.002493455253f, 8.4829070365e-005f, 2.896016712e-006f, 9.9332553731e-008f, 3.4272987126e-009f, 1.1910686381e-010f, 4.1746934161e-012f, 1.4778254497e-013f, 5.291463929e-015f, 1.9194157044e-016f, 7.0654668469e-018f, 2.6441845117e-019f, 1.0080858943e-020f, 3.9239690218e-022f, 1.563346679e-023f, 6.3929999849e-025f, 2.6919386093e-026f, 1.1715159077e-027f, 5.2923694051e-029f, 2.4948468632e-030f, 1.2351332459e-031f, 6.4738572649e-033f, 3.6303588837e-034f, 2.2093660583e-035f, 1.4895542926e-036f, 1.1492160865e-037f, 1.0763394811e-038f, 1.4133029781e-039f, 2.2032307254f, 0.072246781595f, 0.0023716167942f, 7.8020464477e-005f, 2.5750590401e-006f, 8.5362375968e-008f, 2.8454125323e-009f, 9.548579253e-011f, 3.229855112e-012f, 1.1026543544e-013f, 3.8045189691e-015f, 1.3285956544e-016f, 4.7031776345e-018f, 1.6905222907e-019f, 6.1811616677e-021f, 2.3035829448e-022f, 8.7695903955e-024f, 3.4187422745e-025f, 1.3685922219e-026f, 5.6439791979e-028f, 2.4066008162e-029f, 1.0656607532e-030f, 4.9260185742e-032f, 2.3922860994e-033f, 1.2304591974e-034f, 6.7734549537e-036f, 4.0479135724e-037f, 2.6807962526e-038f, 2.0323063943e-039f, 1.8708896824e-040f, 2.4153081942e-041f, 2.2390579644f, 0.071090161459f, 0.0022593936472f, 7.1953752141e-005f, 2.2984783003e-006f, 7.3723725857e-008f, 2.3769483209e-009f, 7.7118386915e-011f, 2.5206933316e-012f, 8.3104798115e-014f, 2.7670871021e-015f, 9.3172669241e-017f, 3.1771616508e-018f, 1.0988443339e-019f, 3.8609454325e-021f, 1.3806712679e-022f, 5.0347900687e-024f, 1.8763554744e-025f, 7.1639584907e-027f, 2.809935703e-028f, 1.1358491867e-029f, 4.7492240348e-031f, 2.0629310954e-032f, 9.3576454782e-034f, 4.4610824434e-035f, 2.2531868908e-036f, 1.2183839317e-037f, 7.1545967982e-039f, 4.6572458283e-040f, 3.4713060867e-041f, 3.142772863e-042f, 3.9913255273e-043f, };*/ inline float factorial(const int x){ float f = 1.0f; for (int i = 2; i <= x; i++){ f *= i; } return f; // return f[x]; } float P(const int l, const int m, const float x){ float pmm = 1.0f; if (m > 0){ float somx2 = sqrtf((1.0f - x) * (1.0f + x)); float fact = 1.0f; for (int i = 1; i <= m; i++){ pmm *= (-fact) * somx2; fact += 2.0f; } } if (l == m) return pmm; float pmmp1 = x * (2.0f * m + 1.0f) * pmm; if (l == m + 1) return pmmp1; float pll = 0.0f; for (int ll = m + 2; ll <= l; ll++){ pll = ((2.0f * ll - 1.0f) * x * pmmp1 - (ll + m - 1.0f) * pmm) / (ll - m); pmm = pmmp1; pmmp1 = pll; } return pll; } float Pm0(const int l, const float x){ if (l == 0) return 1.0f; if (l == 1) return x; float pmm = 1.0f; float pmmp1 = x; float pll; float f = 1.0f; for (float ll = 2; ll <= l; ll++){ f += 2.0f; pll = (f * x * pmmp1 - (ll - 1.0f) * pmm) / ll; pmm = pmmp1; pmmp1 = pll; } return pll; } float PmX(const int l, const int m, const float x, float pmm0){ if (l == m) return pmm0; float f = float(2 * m + 1); float pmmp1 = f * x * pmm0; if (l == m + 1) return pmmp1; float pll; float d = 2.0f; float f2 = float(2 * m); for (float ll = float(m + 2); ll <= l; ll++){ f += 2.0f; f2++; pll = (f * x * pmmp1 - f2 * pmm0) / d; pmm0 = pmmp1; pmmp1 = pll; d++; } return pll; } float P2(const int l, const int m, const float x){ float pmm = 1.0f; if (m > 0){ float somx2 = sqrtf(1.0f - x * x); float fact = -1.0f; for (int i = 1; i <= m; i++){ pmm *= fact * somx2; fact -= 2.0f; } /* for (int i = 1; i <= m; i++){ pmm *= somx2; } pmm *= f2[m]; */ //pmm *= powf(somx2, m); } if (l == m) return pmm; float pmmp1 = x * (2.0f * m + 1.0f) * pmm; if (l == m + 1) return pmmp1; float pll; for (int ll = m + 2; ll <= l; ll++){ pll = ((2.0f * ll - 1.0f) * x * pmmp1 - (ll + m - 1.0f) * pmm) / (ll - m); pmm = pmmp1; pmmp1 = pll; } return pll; } float K(const int l, const int m){ // renormalisation constant for SH function float temp = ((2.0f * l + 1.0f) * factorial(l - m)) / (4.0f * PI * factorial(l + m)); return sqrtf(temp); } inline float K2(const int l, const int m){ return (float) kTab[((l * (l + 1)) >> 1) + m]; } // return a point sample of a Spherical Harmonic basis function // l is the band, range [0..N] // m in the range [-l..l] // theta in the range [0..Pi] // phi in the range [0..2*Pi] float SH(const int l, const int m, const float theta, const float phi){ const float sqrt2 = sqrtf(2.0f); if (m == 0) return K(l, 0) * P(l, m, cosf(theta)); else if (m > 0) return sqrt2 * K(l, m) * cosf(m * phi) * P(l, m, cosf(theta)); else return sqrt2 * K(l, -m) * sinf(-m * phi) * P(l, -m, cosf(theta)); } float SH2(const int l, const int m, const float cosTheta, const float scPhi){ const int m2 = abs(m); float k = K2(l, m2) * P2(l, m2, cosTheta); if (m == 0) return k; return k * scPhi; } float SH(const int l, const int m, const float3 &pos){ float len = length(pos); float p = atan2f(pos.z, pos.x); // float t = PI / 2 - asinf(pos.y / len); float t = acosf(pos.y / len); return SH(l, m, t, p); } float SH_A(const int l, const int m, const float3 &pos){ float d = dot(pos, pos); float len = sqrtf(d); float p = atan2f(pos.z, pos.x); float t = acosf(pos.y / len); return SH(l, m, t, p) * powf(d, -1.5f); } float SH_A2_pos(const int l, const int m, const float3 &pos){ float dxz = pos.x * pos.x + pos.z * pos.z; // float d = dot(pos, pos); float d = dxz + pos.y * pos.y; float len = sqrtf(d); // float p = atan2f(pos.z, pos.x); float t = pos.y / len; // float cp = cosf(p); // float sp = sinf(p); float xzLenInv = 1.0f / sqrtf(dxz); float cp = pos.x * xzLenInv; float sp = pos.z * xzLenInv; float c = (float) sqrt2; float s = 0.0f; for (int i = 0; i < m; i++){ float ssp = s * sp; float csp = c * sp; c = c * cp - ssp; s = s * cp + csp; } float scPhi = c; // float scPhi = cosf(m * p); return SH2(l, m, t, scPhi) * powf(d, -1.5f); } float SH_A2_neg(const int l, const int m, const float3 &pos){ /* float d = dot(pos, pos); float len = sqrtf(d); float p = atan2f(pos.z, pos.x); float t = pos.y / len; */ float dxz = pos.x * pos.x + pos.z * pos.z; float d = dxz + pos.y * pos.y; float len = sqrtf(d); float t = pos.y / len; float xzLenInv = 1.0f / sqrtf(dxz); float cp = pos.x * xzLenInv; float sp = pos.z * xzLenInv; float c = (float) sqrt2; float s = 0.0f; for (int i = 0; i < m; i++){ float ssp = s * sp; float csp = c * sp; c = c * cp - ssp; s = s * cp + csp; } // float scPhi = sinf(m * p); float scPhi = s; return SH2(l, m, t, scPhi) * powf(d, -1.5f); } float SH_A2(const int l, const int m, const float3 &pos){ if (m >= 0) return SH_A2_pos(l, m, pos); else return SH_A2_neg(l, -m, pos); } template <typename FLOAT> bool cubemapToSH(FLOAT *dst, const Image &img, const int bands){ if (!img.isCube()) return false; FORMAT format = img.getFormat(); if (format < FORMAT_I32F || format > FORMAT_RGBA32F) return false; int size = img.getWidth(); int sliceSize = img.getSliceSize(); int nCoeffs = bands * bands; float *coeffs = new float[nCoeffs]; for (int i = 0; i < nCoeffs; i++){ dst[i] = 0; } float3 v; float *src = (float *) img.getPixels(); for (v.x = 1; v.x >= -1; v.x -= 2){ for (int y = 0; y < size; y++){ for (int z = 0; z < size; z++){ v.y = 1 - 2 * float(y + 0.5f) / size; v.z = (1 - 2 * float(z + 0.5f) / size) * v.x; computeSHCoefficients(coeffs, bands, v, true); float v = *src++; for (int i = 0; i < nCoeffs; i++){ dst[i] += v * coeffs[i]; } } } } for (v.y = 1; v.y >= -1; v.y -= 2){ for (int z = 0; z < size; z++){ for (int x = 0; x < size; x++){ v.x = 2 * float(x + 0.5f) / size - 1; v.z = (2 * float(z + 0.5f) / size - 1) * v.y; computeSHCoefficients(coeffs, bands, v, true); float v = *src++; for (int i = 0; i < nCoeffs; i++){ dst[i] += v * coeffs[i]; } } } } for (v.z = 1; v.z >= -1; v.z -= 2){ for (int y = 0; y < size; y++){ for (int x = 0; x < size; x++){ v.x = (2 * float(x + 0.5f) / size - 1) * v.z; v.y = 1 - 2 * float(y + 0.5f) / size; computeSHCoefficients(coeffs, bands, v, true); float v = *src++; for (int i = 0; i < nCoeffs; i++){ dst[i] += v * coeffs[i]; } } } } delete coeffs; float normFactor = 1.0f / (6 * size * size); for (int i = 0; i < nCoeffs; i++){ dst[i] *= normFactor; } return true; } template <typename FLOAT> bool shToCubemap(Image &img, const int size, const FLOAT *src, const int bands){ img.create(FORMAT_I32F, size, size, 0, 1); int sliceSize = img.getSliceSize(); // memset(img.getPixels(), 0, 6 * sliceSize); int nCoeffs = bands * bands; FLOAT *coeffs = new FLOAT[nCoeffs]; float *dst = (float *) (img.getPixels()); FLOAT scale = 1.0f; float3 v; for (v.x = 1; v.x >= -1; v.x -= 2){ for (int y = 0; y < size; y++){ for (int z = 0; z < size; z++){ v.y = 1 - 2 * float(y + 0.5f) / size; v.z = (1 - 2 * float(z + 0.5f) / size) * v.x; computeSHCoefficients(coeffs, bands, v, false); FLOAT v = 0; for (int i = 0; i < nCoeffs; i++){ v += src[i] * coeffs[i]; } *dst++ = float(v * scale); } } } for (v.y = 1; v.y >= -1; v.y -= 2){ for (int z = 0; z < size; z++){ for (int x = 0; x < size; x++){ v.x = 2 * float(x + 0.5f) / size - 1; v.z = (2 * float(z + 0.5f) / size - 1) * v.y; computeSHCoefficients(coeffs, bands, v, false); FLOAT v = 0; for (int i = 0; i < nCoeffs; i++){ v += src[i] * coeffs[i]; } *dst++ = float(v * scale); } } } for (v.z = 1; v.z >= -1; v.z -= 2){ for (int y = 0; y < size; y++){ for (int x = 0; x < size; x++){ v.x = (2 * float(x + 0.5f) / size - 1) * v.z; v.y = 1 - 2 * float(y + 0.5f) / size; computeSHCoefficients(coeffs, bands, v, false); FLOAT v = 0; for (int i = 0; i < nCoeffs; i++){ v += src[i] * coeffs[i]; } *dst++ = float(v * scale); } } } delete coeffs; return true; } template <typename FLOAT> void computeSHCoefficients(FLOAT *dest, const int bands, const float3 &pos, const bool fade){ FLOAT dxz = pos.x * pos.x + pos.z * pos.z; FLOAT dxyz = dxz + pos.y * pos.y; FLOAT xzLen = sqrt(dxz); FLOAT xyzLen = sqrt(dxyz); FLOAT xzLenInv = 1.0f / xzLen; FLOAT xyzLenInv = 1.0f / xyzLen; FLOAT ct = pos.y * xyzLenInv; FLOAT st = xzLen * xyzLenInv; FLOAT cp = pos.x * xzLenInv; FLOAT sp = pos.z * xzLenInv; // FLOAT a = powf(xyzLen, -3.0f); // FLOAT a = 1.0f / (dxyz * xyzLen); FLOAT a = fade? xyzLenInv * xyzLenInv * xyzLenInv : 1; if (bands > 0) dest[0] = FLOAT(kTab[0] * a * REDIST_FACTOR); if (bands > 1) dest[2] = FLOAT(kTab[1] * a * REDIST_FACTOR * ct); FLOAT pmm0 = FLOAT(1.0 * REDIST_FACTOR); FLOAT pmm1 = FLOAT(ct * REDIST_FACTOR); for (int l = 2; l < bands; l++){ int i = l * (l + 1); // FLOAT pll = ((2 * l - 1) * ct * pmm1 - (l - 1) * pmm0) * rcp[l]; FLOAT pll = FLOAT(ct * pmm1 * fTab[i] - pmm0 * fTab[i + 1]); pmm0 = pmm1; pmm1 = pll; dest[i] = FLOAT(kTab[i >> 1] * pll * a); } FLOAT c = FLOAT(sqrt2 * a); // Start with sqrtf(2) * a instead of 1.0 so that it's baked into sin & cos values below FLOAT s = 0; double pmm = double(1.0 * REDIST_FACTOR); // FLOAT fact = -1; for (int m = 1; m < bands; m++){ // Compute cos(m * phi) and sin(m * phi) iteratively from initial cos(phi) and sin(phi) FLOAT ssp = s * sp; FLOAT csp = c * sp; c = c * cp - ssp; s = s * cp + csp; pmm *= /*fact * */st; // fact -= 2; FLOAT pmm0 = (FLOAT) pmm; FLOAT f0 = FLOAT(2 * m + 1); FLOAT pmm1; FLOAT kp = FLOAT(kTab[((m * (m + 1)) >> 1) + m] * pmm0); dest[m * m ] = kp * s; dest[m * m + 2 * m] = kp * c; if (m + 1 < bands){ pmm1 = f0 * ct * pmm0; FLOAT kp = FLOAT(kTab[(m * m + 5 * m + 2) >> 1] * pmm1); dest[m * m + 2 * m + 2] = kp * s; dest[m * m + 4 * m + 2] = kp * c; } int index = 2; for (int l = m + 2; l < bands; l++){ // f0 += 2.0f; // f1++; // FLOAT pll = (f0 * ct * pmm1 - f1 * pmm0) * rcp[index++]; int it = l * (l + 1) + 2 * m; FLOAT pll = FLOAT(ct * pmm1 * fTab[it] - pmm0 * fTab[it + 1]); pmm0 = pmm1; pmm1 = pll; // pmm1 = (2 * m - 5) * ct * pmm1; // FLOAT pll = pmm1; int i = l * (l + 1); FLOAT kp = FLOAT(kTab[(i >> 1) + m] * pll); dest[i + m] = kp * c; dest[i - m] = kp * s; } } } template bool cubemapToSH(float *dst, const Image &img, const int bands); template bool shToCubemap(Image &img, const int size, const float *src, const int bands); template bool cubemapToSH(double *dst, const Image &img, const int bands); template bool shToCubemap(Image &img, const int size, const double *src, const int bands);
[ "dtrebilco@gmail.com" ]
dtrebilco@gmail.com
07d25173ae7f0659749c2a92131694733553d9d5
54d88765e22d3ce7ce4ff3538ea5205b9913cc4e
/practice_java/exam.c++
2d5b23da4224e06bad71de6dc7bf642ca0f3e742
[]
no_license
KindLoad/pracserver
2bcb343f4c6e5b51218a14620cc12a5a4fa19dfa
312aa0c1b0d8a2c80ac91dfc7189991633cd33d2
refs/heads/Soongil_branch
2022-12-16T20:47:42.955817
2020-07-06T01:28:45
2020-07-06T01:28:45
275,346,771
0
0
null
2022-12-13T04:21:28
2020-06-27T10:15:27
Java
UTF-8
C++
false
false
189
#include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main(int argc, char const *argv[]) { cout << "so sleep" << endl; return 0; }
[ "kdge248@gmail.com" ]
kdge248@gmail.com
7a5ac76848e1eb05658b9463968878209af26d51
0ed1b441759ef92872821a07f6c6cff04094e390
/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
eca774ead93531ec6b4f94b5909439396f89f62e
[ "NCSA" ]
permissive
sslab-gatech/caver
651dd1e404c03a9568ef512164c98e918821c9e8
81363a7d0581d99fe216c4394294b0a2372f08eb
refs/heads/master
2021-01-10T03:43:56.533854
2015-10-13T18:23:15
2015-10-13T18:23:15
44,137,365
30
10
null
null
null
null
UTF-8
C++
false
false
37,374
cpp
//===-- PPCRegisterInfo.cpp - PowerPC Register Information ----------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file contains the PowerPC implementation of the TargetRegisterInfo // class. // //===----------------------------------------------------------------------===// #include "PPCRegisterInfo.h" #include "PPC.h" #include "PPCFrameLowering.h" #include "PPCInstrBuilder.h" #include "PPCMachineFunctionInfo.h" #include "PPCSubtarget.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/RegisterScavenging.h" #include "llvm/IR/CallingConv.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Function.h" #include "llvm/IR/Type.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetFrameLowering.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include <cstdlib> using namespace llvm; #define DEBUG_TYPE "reginfo" #define GET_REGINFO_TARGET_DESC #include "PPCGenRegisterInfo.inc" static cl::opt<bool> EnableBasePointer("ppc-use-base-pointer", cl::Hidden, cl::init(true), cl::desc("Enable use of a base pointer for complex stack frames")); static cl::opt<bool> AlwaysBasePointer("ppc-always-use-base-pointer", cl::Hidden, cl::init(false), cl::desc("Force the use of a base pointer in every function")); PPCRegisterInfo::PPCRegisterInfo(const PPCSubtarget &ST) : PPCGenRegisterInfo(ST.isPPC64() ? PPC::LR8 : PPC::LR, ST.isPPC64() ? 0 : 1, ST.isPPC64() ? 0 : 1), Subtarget(ST) { ImmToIdxMap[PPC::LD] = PPC::LDX; ImmToIdxMap[PPC::STD] = PPC::STDX; ImmToIdxMap[PPC::LBZ] = PPC::LBZX; ImmToIdxMap[PPC::STB] = PPC::STBX; ImmToIdxMap[PPC::LHZ] = PPC::LHZX; ImmToIdxMap[PPC::LHA] = PPC::LHAX; ImmToIdxMap[PPC::LWZ] = PPC::LWZX; ImmToIdxMap[PPC::LWA] = PPC::LWAX; ImmToIdxMap[PPC::LFS] = PPC::LFSX; ImmToIdxMap[PPC::LFD] = PPC::LFDX; ImmToIdxMap[PPC::STH] = PPC::STHX; ImmToIdxMap[PPC::STW] = PPC::STWX; ImmToIdxMap[PPC::STFS] = PPC::STFSX; ImmToIdxMap[PPC::STFD] = PPC::STFDX; ImmToIdxMap[PPC::ADDI] = PPC::ADD4; ImmToIdxMap[PPC::LWA_32] = PPC::LWAX_32; // 64-bit ImmToIdxMap[PPC::LHA8] = PPC::LHAX8; ImmToIdxMap[PPC::LBZ8] = PPC::LBZX8; ImmToIdxMap[PPC::LHZ8] = PPC::LHZX8; ImmToIdxMap[PPC::LWZ8] = PPC::LWZX8; ImmToIdxMap[PPC::STB8] = PPC::STBX8; ImmToIdxMap[PPC::STH8] = PPC::STHX8; ImmToIdxMap[PPC::STW8] = PPC::STWX8; ImmToIdxMap[PPC::STDU] = PPC::STDUX; ImmToIdxMap[PPC::ADDI8] = PPC::ADD8; } /// getPointerRegClass - Return the register class to use to hold pointers. /// This is used for addressing modes. const TargetRegisterClass * PPCRegisterInfo::getPointerRegClass(const MachineFunction &MF, unsigned Kind) const { // Note that PPCInstrInfo::FoldImmediate also directly uses this Kind value // when it checks for ZERO folding. if (Kind == 1) { if (Subtarget.isPPC64()) return &PPC::G8RC_NOX0RegClass; return &PPC::GPRC_NOR0RegClass; } if (Subtarget.isPPC64()) return &PPC::G8RCRegClass; return &PPC::GPRCRegClass; } const MCPhysReg* PPCRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const { if (Subtarget.isDarwinABI()) return Subtarget.isPPC64() ? (Subtarget.hasAltivec() ? CSR_Darwin64_Altivec_SaveList : CSR_Darwin64_SaveList) : (Subtarget.hasAltivec() ? CSR_Darwin32_Altivec_SaveList : CSR_Darwin32_SaveList); return Subtarget.isPPC64() ? (Subtarget.hasAltivec() ? CSR_SVR464_Altivec_SaveList : CSR_SVR464_SaveList) : (Subtarget.hasAltivec() ? CSR_SVR432_Altivec_SaveList : CSR_SVR432_SaveList); } const uint32_t* PPCRegisterInfo::getCallPreservedMask(CallingConv::ID CC) const { if (Subtarget.isDarwinABI()) return Subtarget.isPPC64() ? (Subtarget.hasAltivec() ? CSR_Darwin64_Altivec_RegMask : CSR_Darwin64_RegMask) : (Subtarget.hasAltivec() ? CSR_Darwin32_Altivec_RegMask : CSR_Darwin32_RegMask); return Subtarget.isPPC64() ? (Subtarget.hasAltivec() ? CSR_SVR464_Altivec_RegMask : CSR_SVR464_RegMask) : (Subtarget.hasAltivec() ? CSR_SVR432_Altivec_RegMask : CSR_SVR432_RegMask); } const uint32_t* PPCRegisterInfo::getNoPreservedMask() const { return CSR_NoRegs_RegMask; } BitVector PPCRegisterInfo::getReservedRegs(const MachineFunction &MF) const { BitVector Reserved(getNumRegs()); const PPCFrameLowering *PPCFI = static_cast<const PPCFrameLowering*>(MF.getTarget().getFrameLowering()); // The ZERO register is not really a register, but the representation of r0 // when used in instructions that treat r0 as the constant 0. Reserved.set(PPC::ZERO); Reserved.set(PPC::ZERO8); // The FP register is also not really a register, but is the representation // of the frame pointer register used by ISD::FRAMEADDR. Reserved.set(PPC::FP); Reserved.set(PPC::FP8); // The BP register is also not really a register, but is the representation // of the base pointer register used by setjmp. Reserved.set(PPC::BP); Reserved.set(PPC::BP8); // The counter registers must be reserved so that counter-based loops can // be correctly formed (and the mtctr instructions are not DCE'd). Reserved.set(PPC::CTR); Reserved.set(PPC::CTR8); Reserved.set(PPC::R1); Reserved.set(PPC::LR); Reserved.set(PPC::LR8); Reserved.set(PPC::RM); if (!Subtarget.isDarwinABI() || !Subtarget.hasAltivec()) Reserved.set(PPC::VRSAVE); // The SVR4 ABI reserves r2 and r13 if (Subtarget.isSVR4ABI()) { Reserved.set(PPC::R2); // System-reserved register Reserved.set(PPC::R13); // Small Data Area pointer register } // On PPC64, r13 is the thread pointer. Never allocate this register. if (Subtarget.isPPC64()) { Reserved.set(PPC::R13); Reserved.set(PPC::X1); Reserved.set(PPC::X13); if (PPCFI->needsFP(MF)) Reserved.set(PPC::X31); if (hasBasePointer(MF)) Reserved.set(PPC::X30); // The 64-bit SVR4 ABI reserves r2 for the TOC pointer. if (Subtarget.isSVR4ABI()) { Reserved.set(PPC::X2); } } if (PPCFI->needsFP(MF)) Reserved.set(PPC::R31); if (hasBasePointer(MF)) Reserved.set(PPC::R30); // Reserve Altivec registers when Altivec is unavailable. if (!Subtarget.hasAltivec()) for (TargetRegisterClass::iterator I = PPC::VRRCRegClass.begin(), IE = PPC::VRRCRegClass.end(); I != IE; ++I) Reserved.set(*I); return Reserved; } unsigned PPCRegisterInfo::getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const { const TargetFrameLowering *TFI = MF.getTarget().getFrameLowering(); const unsigned DefaultSafety = 1; switch (RC->getID()) { default: return 0; case PPC::G8RC_NOX0RegClassID: case PPC::GPRC_NOR0RegClassID: case PPC::G8RCRegClassID: case PPC::GPRCRegClassID: { unsigned FP = TFI->hasFP(MF) ? 1 : 0; return 32 - FP - DefaultSafety; } case PPC::F8RCRegClassID: case PPC::F4RCRegClassID: case PPC::VRRCRegClassID: case PPC::VFRCRegClassID: case PPC::VSLRCRegClassID: case PPC::VSHRCRegClassID: return 32 - DefaultSafety; case PPC::VSRCRegClassID: case PPC::VSFRCRegClassID: return 64 - DefaultSafety; case PPC::CRRCRegClassID: return 8 - DefaultSafety; } } const TargetRegisterClass* PPCRegisterInfo::getLargestLegalSuperClass(const TargetRegisterClass *RC)const { if (Subtarget.hasVSX()) { // With VSX, we can inflate various sub-register classes to the full VSX // register set. if (RC == &PPC::F8RCRegClass) return &PPC::VSFRCRegClass; else if (RC == &PPC::VRRCRegClass) return &PPC::VSRCRegClass; } return TargetRegisterInfo::getLargestLegalSuperClass(RC); } //===----------------------------------------------------------------------===// // Stack Frame Processing methods //===----------------------------------------------------------------------===// /// lowerDynamicAlloc - Generate the code for allocating an object in the /// current frame. The sequence of code with be in the general form /// /// addi R0, SP, \#frameSize ; get the address of the previous frame /// stwxu R0, SP, Rnegsize ; add and update the SP with the negated size /// addi Rnew, SP, \#maxCalFrameSize ; get the top of the allocation /// void PPCRegisterInfo::lowerDynamicAlloc(MachineBasicBlock::iterator II) const { // Get the instruction. MachineInstr &MI = *II; // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); // Get the basic block's function. MachineFunction &MF = *MBB.getParent(); // Get the frame info. MachineFrameInfo *MFI = MF.getFrameInfo(); // Get the instruction info. const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); // Determine whether 64-bit pointers are used. bool LP64 = Subtarget.isPPC64(); DebugLoc dl = MI.getDebugLoc(); // Get the maximum call stack size. unsigned maxCallFrameSize = MFI->getMaxCallFrameSize(); // Get the total frame size. unsigned FrameSize = MFI->getStackSize(); // Get stack alignments. unsigned TargetAlign = MF.getTarget().getFrameLowering()->getStackAlignment(); unsigned MaxAlign = MFI->getMaxAlignment(); assert((maxCallFrameSize & (MaxAlign-1)) == 0 && "Maximum call-frame size not sufficiently aligned"); // Determine the previous frame's address. If FrameSize can't be // represented as 16 bits or we need special alignment, then we load the // previous frame's address from 0(SP). Why not do an addis of the hi? // Because R0 is our only safe tmp register and addi/addis treat R0 as zero. // Constructing the constant and adding would take 3 instructions. // Fortunately, a frame greater than 32K is rare. const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); if (MaxAlign < TargetAlign && isInt<16>(FrameSize)) { BuildMI(MBB, II, dl, TII.get(PPC::ADDI), Reg) .addReg(PPC::R31) .addImm(FrameSize); } else if (LP64) { BuildMI(MBB, II, dl, TII.get(PPC::LD), Reg) .addImm(0) .addReg(PPC::X1); } else { BuildMI(MBB, II, dl, TII.get(PPC::LWZ), Reg) .addImm(0) .addReg(PPC::R1); } bool KillNegSizeReg = MI.getOperand(1).isKill(); unsigned NegSizeReg = MI.getOperand(1).getReg(); // Grow the stack and update the stack pointer link, then determine the // address of new allocated space. if (LP64) { if (MaxAlign > TargetAlign) { unsigned UnalNegSizeReg = NegSizeReg; NegSizeReg = MF.getRegInfo().createVirtualRegister(G8RC); // Unfortunately, there is no andi, only andi., and we can't insert that // here because we might clobber cr0 while it is live. BuildMI(MBB, II, dl, TII.get(PPC::LI8), NegSizeReg) .addImm(~(MaxAlign-1)); unsigned NegSizeReg1 = NegSizeReg; NegSizeReg = MF.getRegInfo().createVirtualRegister(G8RC); BuildMI(MBB, II, dl, TII.get(PPC::AND8), NegSizeReg) .addReg(UnalNegSizeReg, getKillRegState(KillNegSizeReg)) .addReg(NegSizeReg1, RegState::Kill); KillNegSizeReg = true; } BuildMI(MBB, II, dl, TII.get(PPC::STDUX), PPC::X1) .addReg(Reg, RegState::Kill) .addReg(PPC::X1) .addReg(NegSizeReg, getKillRegState(KillNegSizeReg)); BuildMI(MBB, II, dl, TII.get(PPC::ADDI8), MI.getOperand(0).getReg()) .addReg(PPC::X1) .addImm(maxCallFrameSize); } else { if (MaxAlign > TargetAlign) { unsigned UnalNegSizeReg = NegSizeReg; NegSizeReg = MF.getRegInfo().createVirtualRegister(GPRC); // Unfortunately, there is no andi, only andi., and we can't insert that // here because we might clobber cr0 while it is live. BuildMI(MBB, II, dl, TII.get(PPC::LI), NegSizeReg) .addImm(~(MaxAlign-1)); unsigned NegSizeReg1 = NegSizeReg; NegSizeReg = MF.getRegInfo().createVirtualRegister(GPRC); BuildMI(MBB, II, dl, TII.get(PPC::AND), NegSizeReg) .addReg(UnalNegSizeReg, getKillRegState(KillNegSizeReg)) .addReg(NegSizeReg1, RegState::Kill); KillNegSizeReg = true; } BuildMI(MBB, II, dl, TII.get(PPC::STWUX), PPC::R1) .addReg(Reg, RegState::Kill) .addReg(PPC::R1) .addReg(NegSizeReg, getKillRegState(KillNegSizeReg)); BuildMI(MBB, II, dl, TII.get(PPC::ADDI), MI.getOperand(0).getReg()) .addReg(PPC::R1) .addImm(maxCallFrameSize); } // Discard the DYNALLOC instruction. MBB.erase(II); } /// lowerCRSpilling - Generate the code for spilling a CR register. Instead of /// reserving a whole register (R0), we scrounge for one here. This generates /// code like this: /// /// mfcr rA ; Move the conditional register into GPR rA. /// rlwinm rA, rA, SB, 0, 31 ; Shift the bits left so they are in CR0's slot. /// stw rA, FI ; Store rA to the frame. /// void PPCRegisterInfo::lowerCRSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; SPILL_CR <SrcReg>, <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); bool LP64 = Subtarget.isPPC64(); const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); unsigned SrcReg = MI.getOperand(0).getReg(); // We need to store the CR in the low 4-bits of the saved value. First, issue // an MFOCRF to save all of the CRBits and, if needed, kill the SrcReg. BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MFOCRF8 : PPC::MFOCRF), Reg) .addReg(SrcReg, getKillRegState(MI.getOperand(0).isKill())); // If the saved register wasn't CR0, shift the bits left so that they are in // CR0's slot. if (SrcReg != PPC::CR0) { unsigned Reg1 = Reg; Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); // rlwinm rA, rA, ShiftBits, 0, 31. BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::RLWINM8 : PPC::RLWINM), Reg) .addReg(Reg1, RegState::Kill) .addImm(getEncodingValue(SrcReg) * 4) .addImm(0) .addImm(31); } addFrameReference(BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::STW8 : PPC::STW)) .addReg(Reg, RegState::Kill), FrameIndex); // Discard the pseudo instruction. MBB.erase(II); } void PPCRegisterInfo::lowerCRRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; <DestReg> = RESTORE_CR <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); bool LP64 = Subtarget.isPPC64(); const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); unsigned DestReg = MI.getOperand(0).getReg(); assert(MI.definesRegister(DestReg) && "RESTORE_CR does not define its destination"); addFrameReference(BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::LWZ8 : PPC::LWZ), Reg), FrameIndex); // If the reloaded register isn't CR0, shift the bits right so that they are // in the right CR's slot. if (DestReg != PPC::CR0) { unsigned Reg1 = Reg; Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); unsigned ShiftBits = getEncodingValue(DestReg)*4; // rlwinm r11, r11, 32-ShiftBits, 0, 31. BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::RLWINM8 : PPC::RLWINM), Reg) .addReg(Reg1, RegState::Kill).addImm(32-ShiftBits).addImm(0) .addImm(31); } BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MTOCRF8 : PPC::MTOCRF), DestReg) .addReg(Reg, RegState::Kill); // Discard the pseudo instruction. MBB.erase(II); } static unsigned getCRFromCRBit(unsigned SrcReg) { unsigned Reg = 0; if (SrcReg == PPC::CR0LT || SrcReg == PPC::CR0GT || SrcReg == PPC::CR0EQ || SrcReg == PPC::CR0UN) Reg = PPC::CR0; else if (SrcReg == PPC::CR1LT || SrcReg == PPC::CR1GT || SrcReg == PPC::CR1EQ || SrcReg == PPC::CR1UN) Reg = PPC::CR1; else if (SrcReg == PPC::CR2LT || SrcReg == PPC::CR2GT || SrcReg == PPC::CR2EQ || SrcReg == PPC::CR2UN) Reg = PPC::CR2; else if (SrcReg == PPC::CR3LT || SrcReg == PPC::CR3GT || SrcReg == PPC::CR3EQ || SrcReg == PPC::CR3UN) Reg = PPC::CR3; else if (SrcReg == PPC::CR4LT || SrcReg == PPC::CR4GT || SrcReg == PPC::CR4EQ || SrcReg == PPC::CR4UN) Reg = PPC::CR4; else if (SrcReg == PPC::CR5LT || SrcReg == PPC::CR5GT || SrcReg == PPC::CR5EQ || SrcReg == PPC::CR5UN) Reg = PPC::CR5; else if (SrcReg == PPC::CR6LT || SrcReg == PPC::CR6GT || SrcReg == PPC::CR6EQ || SrcReg == PPC::CR6UN) Reg = PPC::CR6; else if (SrcReg == PPC::CR7LT || SrcReg == PPC::CR7GT || SrcReg == PPC::CR7EQ || SrcReg == PPC::CR7UN) Reg = PPC::CR7; assert(Reg != 0 && "Invalid CR bit register"); return Reg; } void PPCRegisterInfo::lowerCRBitSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; SPILL_CRBIT <SrcReg>, <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); bool LP64 = Subtarget.isPPC64(); const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); unsigned SrcReg = MI.getOperand(0).getReg(); BuildMI(MBB, II, dl, TII.get(TargetOpcode::KILL), getCRFromCRBit(SrcReg)) .addReg(SrcReg, getKillRegState(MI.getOperand(0).isKill())); BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MFOCRF8 : PPC::MFOCRF), Reg) .addReg(getCRFromCRBit(SrcReg)); // If the saved register wasn't CR0LT, shift the bits left so that the bit to // store is the first one. Mask all but that bit. unsigned Reg1 = Reg; Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); // rlwinm rA, rA, ShiftBits, 0, 0. BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::RLWINM8 : PPC::RLWINM), Reg) .addReg(Reg1, RegState::Kill) .addImm(getEncodingValue(SrcReg)) .addImm(0).addImm(0); addFrameReference(BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::STW8 : PPC::STW)) .addReg(Reg, RegState::Kill), FrameIndex); // Discard the pseudo instruction. MBB.erase(II); } void PPCRegisterInfo::lowerCRBitRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; <DestReg> = RESTORE_CRBIT <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); bool LP64 = Subtarget.isPPC64(); const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); unsigned DestReg = MI.getOperand(0).getReg(); assert(MI.definesRegister(DestReg) && "RESTORE_CRBIT does not define its destination"); addFrameReference(BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::LWZ8 : PPC::LWZ), Reg), FrameIndex); BuildMI(MBB, II, dl, TII.get(TargetOpcode::IMPLICIT_DEF), DestReg); unsigned RegO = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MFOCRF8 : PPC::MFOCRF), RegO) .addReg(getCRFromCRBit(DestReg)); unsigned ShiftBits = getEncodingValue(DestReg); // rlwimi r11, r10, 32-ShiftBits, ..., ... BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::RLWIMI8 : PPC::RLWIMI), RegO) .addReg(RegO, RegState::Kill).addReg(Reg, RegState::Kill) .addImm(ShiftBits ? 32-ShiftBits : 0) .addImm(ShiftBits).addImm(ShiftBits); BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MTOCRF8 : PPC::MTOCRF), getCRFromCRBit(DestReg)) .addReg(RegO, RegState::Kill) // Make sure we have a use dependency all the way through this // sequence of instructions. We can't have the other bits in the CR // modified in between the mfocrf and the mtocrf. .addReg(getCRFromCRBit(DestReg), RegState::Implicit); // Discard the pseudo instruction. MBB.erase(II); } void PPCRegisterInfo::lowerVRSAVESpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; SPILL_VRSAVE <SrcReg>, <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(GPRC); unsigned SrcReg = MI.getOperand(0).getReg(); BuildMI(MBB, II, dl, TII.get(PPC::MFVRSAVEv), Reg) .addReg(SrcReg, getKillRegState(MI.getOperand(0).isKill())); addFrameReference(BuildMI(MBB, II, dl, TII.get(PPC::STW)) .addReg(Reg, RegState::Kill), FrameIndex); // Discard the pseudo instruction. MBB.erase(II); } void PPCRegisterInfo::lowerVRSAVERestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; <DestReg> = RESTORE_VRSAVE <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(GPRC); unsigned DestReg = MI.getOperand(0).getReg(); assert(MI.definesRegister(DestReg) && "RESTORE_VRSAVE does not define its destination"); addFrameReference(BuildMI(MBB, II, dl, TII.get(PPC::LWZ), Reg), FrameIndex); BuildMI(MBB, II, dl, TII.get(PPC::MTVRSAVEv), DestReg) .addReg(Reg, RegState::Kill); // Discard the pseudo instruction. MBB.erase(II); } bool PPCRegisterInfo::hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg, int &FrameIdx) const { // For the nonvolatile condition registers (CR2, CR3, CR4) in an SVR4 // ABI, return true to prevent allocating an additional frame slot. // For 64-bit, the CR save area is at SP+8; the value of FrameIdx = 0 // is arbitrary and will be subsequently ignored. For 32-bit, we have // previously created the stack slot if needed, so return its FrameIdx. if (Subtarget.isSVR4ABI() && PPC::CR2 <= Reg && Reg <= PPC::CR4) { if (Subtarget.isPPC64()) FrameIdx = 0; else { const PPCFunctionInfo *FI = MF.getInfo<PPCFunctionInfo>(); FrameIdx = FI->getCRSpillFrameIndex(); } return true; } return false; } // Figure out if the offset in the instruction must be a multiple of 4. // This is true for instructions like "STD". static bool usesIXAddr(const MachineInstr &MI) { unsigned OpC = MI.getOpcode(); switch (OpC) { default: return false; case PPC::LWA: case PPC::LWA_32: case PPC::LD: case PPC::STD: return true; } } // Return the OffsetOperandNo given the FIOperandNum (and the instruction). static unsigned getOffsetONFromFION(const MachineInstr &MI, unsigned FIOperandNum) { // Take into account whether it's an add or mem instruction unsigned OffsetOperandNo = (FIOperandNum == 2) ? 1 : 2; if (MI.isInlineAsm()) OffsetOperandNo = FIOperandNum-1; return OffsetOperandNo; } void PPCRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS) const { assert(SPAdj == 0 && "Unexpected"); // Get the instruction. MachineInstr &MI = *II; // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); // Get the basic block's function. MachineFunction &MF = *MBB.getParent(); // Get the instruction info. const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); // Get the frame info. MachineFrameInfo *MFI = MF.getFrameInfo(); DebugLoc dl = MI.getDebugLoc(); unsigned OffsetOperandNo = getOffsetONFromFION(MI, FIOperandNum); // Get the frame index. int FrameIndex = MI.getOperand(FIOperandNum).getIndex(); // Get the frame pointer save index. Users of this index are primarily // DYNALLOC instructions. PPCFunctionInfo *FI = MF.getInfo<PPCFunctionInfo>(); int FPSI = FI->getFramePointerSaveIndex(); // Get the instruction opcode. unsigned OpC = MI.getOpcode(); // Special case for dynamic alloca. if (FPSI && FrameIndex == FPSI && (OpC == PPC::DYNALLOC || OpC == PPC::DYNALLOC8)) { lowerDynamicAlloc(II); return; } // Special case for pseudo-ops SPILL_CR and RESTORE_CR, etc. if (OpC == PPC::SPILL_CR) { lowerCRSpilling(II, FrameIndex); return; } else if (OpC == PPC::RESTORE_CR) { lowerCRRestore(II, FrameIndex); return; } else if (OpC == PPC::SPILL_CRBIT) { lowerCRBitSpilling(II, FrameIndex); return; } else if (OpC == PPC::RESTORE_CRBIT) { lowerCRBitRestore(II, FrameIndex); return; } else if (OpC == PPC::SPILL_VRSAVE) { lowerVRSAVESpilling(II, FrameIndex); return; } else if (OpC == PPC::RESTORE_VRSAVE) { lowerVRSAVERestore(II, FrameIndex); return; } // Replace the FrameIndex with base register with GPR1 (SP) or GPR31 (FP). MI.getOperand(FIOperandNum).ChangeToRegister( FrameIndex < 0 ? getBaseRegister(MF) : getFrameRegister(MF), false); // Figure out if the offset in the instruction is shifted right two bits. bool isIXAddr = usesIXAddr(MI); // If the instruction is not present in ImmToIdxMap, then it has no immediate // form (and must be r+r). bool noImmForm = !MI.isInlineAsm() && !ImmToIdxMap.count(OpC); // Now add the frame object offset to the offset from r1. int Offset = MFI->getObjectOffset(FrameIndex); Offset += MI.getOperand(OffsetOperandNo).getImm(); // If we're not using a Frame Pointer that has been set to the value of the // SP before having the stack size subtracted from it, then add the stack size // to Offset to get the correct offset. // Naked functions have stack size 0, although getStackSize may not reflect that // because we didn't call all the pieces that compute it for naked functions. if (!MF.getFunction()->getAttributes(). hasAttribute(AttributeSet::FunctionIndex, Attribute::Naked)) { if (!(hasBasePointer(MF) && FrameIndex < 0)) Offset += MFI->getStackSize(); } // If we can, encode the offset directly into the instruction. If this is a // normal PPC "ri" instruction, any 16-bit value can be safely encoded. If // this is a PPC64 "ix" instruction, only a 16-bit value with the low two bits // clear can be encoded. This is extremely uncommon, because normally you // only "std" to a stack slot that is at least 4-byte aligned, but it can // happen in invalid code. assert(OpC != PPC::DBG_VALUE && "This should be handle in a target independent way"); if (!noImmForm && isInt<16>(Offset) && (!isIXAddr || (Offset & 3) == 0)) { MI.getOperand(OffsetOperandNo).ChangeToImmediate(Offset); return; } // The offset doesn't fit into a single register, scavenge one to build the // offset in. bool is64Bit = Subtarget.isPPC64(); const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; const TargetRegisterClass *RC = is64Bit ? G8RC : GPRC; unsigned SRegHi = MF.getRegInfo().createVirtualRegister(RC), SReg = MF.getRegInfo().createVirtualRegister(RC); // Insert a set of rA with the full offset value before the ld, st, or add BuildMI(MBB, II, dl, TII.get(is64Bit ? PPC::LIS8 : PPC::LIS), SRegHi) .addImm(Offset >> 16); BuildMI(MBB, II, dl, TII.get(is64Bit ? PPC::ORI8 : PPC::ORI), SReg) .addReg(SRegHi, RegState::Kill) .addImm(Offset); // Convert into indexed form of the instruction: // // sth 0:rA, 1:imm 2:(rB) ==> sthx 0:rA, 2:rB, 1:r0 // addi 0:rA 1:rB, 2, imm ==> add 0:rA, 1:rB, 2:r0 unsigned OperandBase; if (noImmForm) OperandBase = 1; else if (OpC != TargetOpcode::INLINEASM) { assert(ImmToIdxMap.count(OpC) && "No indexed form of load or store available!"); unsigned NewOpcode = ImmToIdxMap.find(OpC)->second; MI.setDesc(TII.get(NewOpcode)); OperandBase = 1; } else { OperandBase = OffsetOperandNo; } unsigned StackReg = MI.getOperand(FIOperandNum).getReg(); MI.getOperand(OperandBase).ChangeToRegister(StackReg, false); MI.getOperand(OperandBase + 1).ChangeToRegister(SReg, false, false, true); } unsigned PPCRegisterInfo::getFrameRegister(const MachineFunction &MF) const { const TargetFrameLowering *TFI = MF.getTarget().getFrameLowering(); if (!Subtarget.isPPC64()) return TFI->hasFP(MF) ? PPC::R31 : PPC::R1; else return TFI->hasFP(MF) ? PPC::X31 : PPC::X1; } unsigned PPCRegisterInfo::getBaseRegister(const MachineFunction &MF) const { if (!hasBasePointer(MF)) return getFrameRegister(MF); return Subtarget.isPPC64() ? PPC::X30 : PPC::R30; } bool PPCRegisterInfo::hasBasePointer(const MachineFunction &MF) const { if (!EnableBasePointer) return false; if (AlwaysBasePointer) return true; // If we need to realign the stack, then the stack pointer can no longer // serve as an offset into the caller's stack space. As a result, we need a // base pointer. return needsStackRealignment(MF); } bool PPCRegisterInfo::canRealignStack(const MachineFunction &MF) const { if (MF.getFunction()->hasFnAttribute("no-realign-stack")) return false; return true; } bool PPCRegisterInfo::needsStackRealignment(const MachineFunction &MF) const { const MachineFrameInfo *MFI = MF.getFrameInfo(); const Function *F = MF.getFunction(); unsigned StackAlign = MF.getTarget().getFrameLowering()->getStackAlignment(); bool requiresRealignment = ((MFI->getMaxAlignment() > StackAlign) || F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, Attribute::StackAlignment)); return requiresRealignment && canRealignStack(MF); } /// Returns true if the instruction's frame index /// reference would be better served by a base register other than FP /// or SP. Used by LocalStackFrameAllocation to determine which frame index /// references it should create new base registers for. bool PPCRegisterInfo:: needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const { assert(Offset < 0 && "Local offset must be negative"); unsigned FIOperandNum = 0; while (!MI->getOperand(FIOperandNum).isFI()) { ++FIOperandNum; assert(FIOperandNum < MI->getNumOperands() && "Instr doesn't have FrameIndex operand!"); } unsigned OffsetOperandNo = getOffsetONFromFION(*MI, FIOperandNum); Offset += MI->getOperand(OffsetOperandNo).getImm(); // It's the load/store FI references that cause issues, as it can be difficult // to materialize the offset if it won't fit in the literal field. Estimate // based on the size of the local frame and some conservative assumptions // about the rest of the stack frame (note, this is pre-regalloc, so // we don't know everything for certain yet) whether this offset is likely // to be out of range of the immediate. Return true if so. // We only generate virtual base registers for loads and stores that have // an r+i form. Return false for everything else. unsigned OpC = MI->getOpcode(); if (!ImmToIdxMap.count(OpC)) return false; // Don't generate a new virtual base register just to add zero to it. if ((OpC == PPC::ADDI || OpC == PPC::ADDI8) && MI->getOperand(2).getImm() == 0) return false; MachineBasicBlock &MBB = *MI->getParent(); MachineFunction &MF = *MBB.getParent(); const PPCFrameLowering *PPCFI = static_cast<const PPCFrameLowering*>(MF.getTarget().getFrameLowering()); unsigned StackEst = PPCFI->determineFrameLayout(MF, false, true); // If we likely don't need a stack frame, then we probably don't need a // virtual base register either. if (!StackEst) return false; // Estimate an offset from the stack pointer. // The incoming offset is relating to the SP at the start of the function, // but when we access the local it'll be relative to the SP after local // allocation, so adjust our SP-relative offset by that allocation size. Offset += StackEst; // The frame pointer will point to the end of the stack, so estimate the // offset as the difference between the object offset and the FP location. return !isFrameOffsetLegal(MI, Offset); } /// Insert defining instruction(s) for BaseReg to /// be a pointer to FrameIdx at the beginning of the basic block. void PPCRegisterInfo:: materializeFrameBaseRegister(MachineBasicBlock *MBB, unsigned BaseReg, int FrameIdx, int64_t Offset) const { unsigned ADDriOpc = Subtarget.isPPC64() ? PPC::ADDI8 : PPC::ADDI; MachineBasicBlock::iterator Ins = MBB->begin(); DebugLoc DL; // Defaults to "unknown" if (Ins != MBB->end()) DL = Ins->getDebugLoc(); const MachineFunction &MF = *MBB->getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); const MCInstrDesc &MCID = TII.get(ADDriOpc); MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo(); MRI.constrainRegClass(BaseReg, TII.getRegClass(MCID, 0, this, MF)); BuildMI(*MBB, Ins, DL, MCID, BaseReg) .addFrameIndex(FrameIdx).addImm(Offset); } void PPCRegisterInfo::resolveFrameIndex(MachineInstr &MI, unsigned BaseReg, int64_t Offset) const { unsigned FIOperandNum = 0; while (!MI.getOperand(FIOperandNum).isFI()) { ++FIOperandNum; assert(FIOperandNum < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); } MI.getOperand(FIOperandNum).ChangeToRegister(BaseReg, false); unsigned OffsetOperandNo = getOffsetONFromFION(MI, FIOperandNum); Offset += MI.getOperand(OffsetOperandNo).getImm(); MI.getOperand(OffsetOperandNo).ChangeToImmediate(Offset); MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); const MCInstrDesc &MCID = MI.getDesc(); MachineRegisterInfo &MRI = MF.getRegInfo(); MRI.constrainRegClass(BaseReg, TII.getRegClass(MCID, FIOperandNum, this, MF)); } bool PPCRegisterInfo::isFrameOffsetLegal(const MachineInstr *MI, int64_t Offset) const { return MI->getOpcode() == PPC::DBG_VALUE || // DBG_VALUE is always Reg+Imm (isInt<16>(Offset) && (!usesIXAddr(*MI) || (Offset & 3) == 0)); }
[ "lifeasageek@gmail.com" ]
lifeasageek@gmail.com
40277902a733bbb5558743e2359166f19382f339
dab17edba4d031ef4892bd373892b3ea39eac992
/KleptoEngine/Renderer.h
7e47ce5e6e88256007943feb7f4dd78178405170
[]
no_license
McMasterGameDesignAssociation/current-version
fc13f74693d5ef3e2da76a27d4ee99d972e496c4
df89d6d7a3abafd3333d9115d1cbc370d88f34b7
refs/heads/master
2020-12-24T14:02:00.284263
2015-02-25T16:53:39
2015-02-25T16:53:39
26,332,614
0
0
null
null
null
null
UTF-8
C++
false
false
4,330
h
/* COPYRIGHT BENJAMIN ISHERWOOD 23/10/2014 THIS SOFTWARE IS INTENDED FOR OPEN SOURCE USE, REDISTRIBUTION IS ENCOURAGE 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 SOFTWARsE. */ #ifndef RENDERER_H #define RENDERER_H #include "engineStdafx.h" #include "Image.h" #include "World2D.h" class Renderer { private: Timer frameLimiter = Timer(45); //Dimensions are the size of the screen Pos2D dimensions; //View port position is the current location //That the viewport is located in the scene Pos2D viewPortPosition; //The view port size is the current area that the //player can be situated in i.e. is the view port //is 50% the size of the dimension than the player //can move the screen position by pushing against //the first or third quarter of the screen from //the center Pos2D viewPortSize; /* basicBuffer and working buffers work as follows basicBuffer is the total size of the screen buffer this is what will be passed into the draw functions next the working buffer will be initiated to the basic buffer = color pixel buffer = shape each texture requires it own location, color, and texture coordinate buffer */ vector<FV3*> basicBuffer; vector<IV2*> pixels; //The maxTriangles gives the total number //of triangles in the render pipeline vector<ULong> maxNodes; vector<Image> imageFiles; /* The way that texture coords will works as follows: Each image index will match the textureCoords index in the populate sequence the renderer will subdivide all objects by into lists based on the textureIds each set of textureCoords will require a call to the render pipeline */ vector<FV2*> textureCoords; vector<ULong> currentPointer; //These texture Ids are used solely //for tracking the other objects relations //to images vector<ULong *> textureIds; void addImage(Image image); static void display(void); static Image * currentImage; void linkTextureId(ULong *baseId); //Verify lists is used ot make sure that //all of the lists are the same length, i.e. //all of them have been processed bool verifyLists(void); //This function will be used to move the current //position of the view port so that it is centered //over the current player, and returns true if the //view port needs to be updated, and false if it doesn't bool updateViewPort(Pos2D newCenter); WindowType typeOfWindow = Windowed; protected: friend World2D; //Tiles don't move around in the world //Therefore they don't need to be linked //by address to the object that will be //moving around void addTileToDraw(Pos2D position, Pos2D size, bool canPass, ULong id); void setNewMax(ULong nodes, ULong id); //Actors and players move around in the //world and therefore they need to be //linked to the memory addresses of the //object so that a repopulate does //not need to occur in the draw cycles void linkSprite(Sprite * sprite); void linkTextureCoords(FV2 * linkage, ULong textureId, Uint tileNumber); bool loadImage(string imageName, string desc, Pos2D chunkSize, ULong * linkId, ImageType imageType); /* getImageDivisions, returns the image divisions at a specific position in the image set */ Pos2D getImageDivisions(Uint index) const; /* getImageSize, returns the size of a texture map at a specific place in the image set */ Pos2D getImageSize(Uint index) const; public: Renderer(void); void initWindow(int argc, char *argv[]); void render(void); //rebuild window resizes the window so that the //user can tell the renderer how to handle the //current window. The window can be restored, //minimized or restored void rebuildWindow(void); void setToFullScreen(void); void setToWindowed(void); void setToMinimized(void); WindowType getWindowState(void) const; void populateArrays(World2D * world); }; #endif
[ "isherwb@mcmaster.ca" ]
isherwb@mcmaster.ca
7ecefd58185018499d6e3f74e6507f5bd8c65a52
01ac52f86f7e7c7d8efab9c66796b107a4198731
/base.h
582716769f5fe39ff77adde3eefe1f3bd6a7f6da
[]
no_license
BCnick943204/RNA2DModelGen
1547aba15bec7a85c45c43255828fe974ee31bd2
1e370687792545715e1adab458c5eae6ea44fe4b
refs/heads/master
2021-01-02T12:27:59.094168
2020-05-27T04:44:34
2020-05-27T04:44:34
239,623,812
0
0
null
null
null
null
UTF-8
C++
false
false
260
h
#ifndef BASE_H #define BASE_H #include <QGraphicsPixmapItem> #include <QPixmap> #include <QSize> #include <stdio.h> class Base: public QGraphicsPixmapItem { public: Base(char); int setBasePic(char); private: QSize base_size; }; #endif // BASE_H
[ "nicholas.passantino@bellevuecollege.edu" ]
nicholas.passantino@bellevuecollege.edu
bb17da301f9b90dee19e48afdb0465cffda47723
ef349c7e735019da95b4b39ad6141027e519647f
/helper.h
8494ca28e0a38f83ffcb75b30dc9f11664fa6cba
[]
no_license
eas/Graphics-core
63fec1a0e67b9f3f99013571911d9d1bd2759556
65c378d606ca07982c5a89ab74f06bdb05383fb8
refs/heads/master
2021-01-19T06:05:33.261243
2009-10-21T18:33:09
2009-10-21T18:36:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,712
h
#pragma once #include "exception" #include "windows.h" #include "d3dx9.h" namespace Helper { class WinApiError :public std::exception { public: WinApiError( DWORD errorCode ) : errorCode_(errorCode) { } public: DWORD errorCode_; }; struct WindowPostion { int height; int width; int left; int top; }; const WindowPostion defaultWindowPostion = { 500, 500, 350, 120 }; typedef LRESULT (CALLBACK *WndProcType)(HWND, UINT, WPARAM, LPARAM); class Window { public: Window( HINSTANCE hInstance, int nCmdShow, WndProcType wndProc, TCHAR* szTitle, TCHAR* szWindowClass, unsigned nExtraLong, WindowPostion windowPosition = defaultWindowPostion ); ~Window(); HWND GetHWND() { return hWnd_; } private: Window(const Window&); Window& operator=(const Window&); HWND hWnd_; }; class SpectatorCoords { public: SpectatorCoords(float r, float theta, float phi) :r_(r), theta_(theta), phi_(phi) { } const D3DXVECTOR3 GetCartesianCoords() const { return D3DXVECTOR3( r_*sinf(theta_)*cosf(phi_), r_*cosf(theta_), r_*sinf(theta_)*sinf(phi_) ); } void IncTheta() { if((theta_+=deltaTheta) > thetaMax){ theta_= thetaMax; } } void DecTheta() { if((theta_-=deltaTheta) < thetaMin){ theta_= thetaMin; } } void IncPhi() { phi_ += deltaPhi; } void DecPhi() { phi_ -= deltaPhi; } void IncR() { r_ += deltaR; } void DecR() { if((r_-=deltaR) < rMin){ r_ = rMin; } } private: float r_, theta_, phi_; public: static const float deltaPhi; static const float deltaTheta; static const float deltaR; static const float thetaMin; static const float thetaMax; static const float rMin; }; } // namespace Helper
[ "a.elovikov@gmail.com" ]
a.elovikov@gmail.com
d3efc75cc1ff0484c8503a1b239dfe4baf0b914c
b3366048ca173c251028344fa69cf54c121a993b
/Neuron.cpp
af7ea210fc9a33e87be36df1e1c050b16df152d0
[]
no_license
sanny1/Backpropagation
bc93c41165fd88ef36fa2c19cfed33d6ff3dc663
5ef33ea247f2a7807a0974c9659190ec98402698
refs/heads/master
2020-09-25T19:31:45.680812
2017-12-22T23:32:36
2017-12-22T23:32:36
66,761,695
0
0
null
null
null
null
UTF-8
C++
false
false
2,824
cpp
// // Created by Sanyog Chhetri on 18/12/15. // #include "Neuron.h" #include <random> using namespace Ann; using namespace std; Neuron::Neuron(int size, int Bias) : actual_output(1, 0), weight(size + 1, 0), input(size, 0), hidden_e_gradient(size, 0) { default_random_engine generator(rand()); uniform_real_distribution<float> wei(-0.5,0.5); for (int i = 0; i < (size + 1); i++) { weight.at(i) = wei(generator); } threshold = 0.7; bias = Bias;//bais is what was needed to help me learning_rate = 0.1;//0.3 seems to output the fastest in this set up // learning rate changes the speed but comes at a price of // missing the right value and might skip it } Neuron::~Neuron() { } void Neuron::Set_input(vector<float> inputs) { input = inputs; } int Neuron::Get_Input_Size() { return input.size(); } void Neuron::Activation_Func() { float sum = 0; for (int i = 0; i < (input.size()); i++)//change this and the error gradient function for better { sum += (input.at(i) * weight.at(i+1)); // sum += bias*(weight.at(0)); } sum += bias * weight.at(0); actual_output.at(0) = (2 / (1 + exp(-sum)))-1;//haven't initialised however many outputs // cout << " This is actual " // << actual_output.at(0) << endl; } void Neuron::Error_Evalutation(int i) { error = desired_output.at(i) - actual_output.at(0); error_gradient = (1 - (actual_output.at(0)*actual_output.at(0))) * error; float sum = 0; // for(int j = 0; j < input.size(); j++) // { // sum += weight.at(j)*error_gradient; // } // sum = sum/input.size(); for (int k = 0; k < input.size(); k++) hidden_e_gradient.at(k) = (1 - (input.at(k)*input.at(k))) * weight.at(k + 1) * error_gradient; // cout << " this is error " << error_gradient << endl; } // remember to implement momentum you need to add change in weigh member as well // this is so you can store the weigh change and add it in the future iteration void Neuron::Adjustment_Func() { fak_weig = weight; for (int i = 0; i < weight.size(); i++) { if (i == 0) { weight.at(i) += learning_rate * bias * error_gradient; } else { fak_weig.at(i) = ((learning_rate * input.at(i-1) * error_gradient)); weight.at(i) += fak_weig.at(i); } } } vector<float> Neuron::Get_Weight() { return weight; } void Neuron::Set_Error_Gradient(float error_grad) { error_gradient = error_grad; } vector<float> Neuron::Get_Hidden_Grad() { return hidden_e_gradient; } void Neuron::Set_Desired_Output(vector<float> desired) { desired_output = desired; } float Neuron::Get_Actual_Output() { return actual_output.at(0); } float Neuron::Get_Error() { return error; } float Neuron::Get_Thres() { return threshold; } void Neuron::Set_pre_it(vector<float> pre) { pre_it = pre; } void Neuron::Set_weight(vector<float> weig) { weight = weig; }
[ "Sanyog2.Chhetri@live.uwe.ac.uk" ]
Sanyog2.Chhetri@live.uwe.ac.uk
5a5730d186a551d8411cea24c395a8829543b543
31ac07ecd9225639bee0d08d00f037bd511e9552
/externals/OCCTLib/inc/IGESGraph_ToolColor.hxx
a93a5f73079485404611a3bc2227ab4dcbe56987
[]
no_license
litao1009/SimpleRoom
4520e0034e4f90b81b922657b27f201842e68e8e
287de738c10b86ff8f61b15e3b8afdfedbcb2211
refs/heads/master
2021-01-20T19:56:39.507899
2016-07-29T08:01:57
2016-07-29T08:01:57
64,462,604
1
0
null
null
null
null
UTF-8
C++
false
false
3,117
hxx
// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _IGESGraph_ToolColor_HeaderFile #define _IGESGraph_ToolColor_HeaderFile #ifndef _Standard_HeaderFile #include <Standard.hxx> #endif #ifndef _Standard_DefineAlloc_HeaderFile #include <Standard_DefineAlloc.hxx> #endif #ifndef _Standard_Macro_HeaderFile #include <Standard_Macro.hxx> #endif #ifndef _Handle_IGESGraph_Color_HeaderFile #include <Handle_IGESGraph_Color.hxx> #endif #ifndef _Handle_IGESData_IGESReaderData_HeaderFile #include <Handle_IGESData_IGESReaderData.hxx> #endif #ifndef _Handle_Interface_Check_HeaderFile #include <Handle_Interface_Check.hxx> #endif #ifndef _Handle_Message_Messenger_HeaderFile #include <Handle_Message_Messenger.hxx> #endif #ifndef _Standard_Integer_HeaderFile #include <Standard_Integer.hxx> #endif class Standard_DomainError; class IGESGraph_Color; class IGESData_IGESReaderData; class IGESData_ParamReader; class IGESData_IGESWriter; class Interface_EntityIterator; class IGESData_DirChecker; class Interface_ShareTool; class Interface_Check; class Interface_CopyTool; class IGESData_IGESDumper; class Message_Messenger; //! Tool to work on a Color. Called by various Modules <br> //! (ReadWriteModule, GeneralModule, SpecificModule) <br> class IGESGraph_ToolColor { public: DEFINE_STANDARD_ALLOC //! Returns a ToolColor, ready to work <br> Standard_EXPORT IGESGraph_ToolColor(); //! Reads own parameters from file. <PR> gives access to them, <br> //! <IR> detains parameter types and values <br> Standard_EXPORT void ReadOwnParams(const Handle(IGESGraph_Color)& ent,const Handle(IGESData_IGESReaderData)& IR,IGESData_ParamReader& PR) const; //! Writes own parameters to IGESWriter <br> Standard_EXPORT void WriteOwnParams(const Handle(IGESGraph_Color)& ent,IGESData_IGESWriter& IW) const; //! Lists the Entities shared by a Color <ent>, from <br> //! its specific (own) parameters <br> Standard_EXPORT void OwnShared(const Handle(IGESGraph_Color)& ent,Interface_EntityIterator& iter) const; //! Returns specific DirChecker <br> Standard_EXPORT IGESData_DirChecker DirChecker(const Handle(IGESGraph_Color)& ent) const; //! Performs Specific Semantic Check <br> Standard_EXPORT void OwnCheck(const Handle(IGESGraph_Color)& ent,const Interface_ShareTool& shares,Handle(Interface_Check)& ach) const; //! Copies Specific Parameters <br> Standard_EXPORT void OwnCopy(const Handle(IGESGraph_Color)& entfrom,const Handle(IGESGraph_Color)& entto,Interface_CopyTool& TC) const; //! Dump of Specific Parameters <br> Standard_EXPORT void OwnDump(const Handle(IGESGraph_Color)& ent,const IGESData_IGESDumper& dumper,const Handle(Message_Messenger)& S,const Standard_Integer own) const; protected: private: }; // other Inline functions and methods (like "C++: function call" methods) #endif
[ "litao1009@gmail.com" ]
litao1009@gmail.com
d3deba0f0cd312054f5cbc40f7db7a5f2957f537
85e419bed080da37dd13d2dd4276a486ae6fbe07
/MusicPlayer/MyForm.h
3ac03825701d876c2cd6961a32d5f57a5f474ceb
[]
no_license
mvrtn/mvrtn
afefded1bbfd48be73e3aea98b60106b04dad95b
fc03aa545c65fb20228968f5d091b3f129aa6b7d
refs/heads/master
2020-03-12T11:33:51.726893
2018-04-22T20:30:14
2018-04-22T20:30:14
130,599,549
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
11,817
h
#pragma once #include "Player.h" namespace MusicPlayer { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::IO; using namespace WMPLib; /// <summary> /// Podsumowanie informacji o MyForm /// </summary> public ref class MyForm : public System::Windows::Forms::Form { public: MyForm(void) { InitializeComponent(); // //TODO: W tym miejscu dodaj kod konstruktora // } protected: /// <summary> /// Wyczyść wszystkie używane zasoby. /// </summary> ~MyForm() { if (components) { delete components; } } System::Windows::Forms::ListViewItem^ listViewItem; private: System::Windows::Forms::Button^ button1; protected: private: System::Windows::Forms::Button^ button2; private: System::Windows::Forms::Button^ button3; private: System::Windows::Forms::Button^ button4; private: System::Windows::Forms::Button^ button5; private: System::Windows::Forms::Button^ button6; private: System::Windows::Forms::MenuStrip^ menuStrip1; private: System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ openFileToolStripMenuItem; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator1; private: System::Windows::Forms::ToolStripMenuItem^ quitToolStripMenuItem; private: System::Windows::Forms::ListView^ listView1; private: System::Windows::Forms::TextBox^ textBox1; private: System::Windows::Forms::ColumnHeader^ columnHeader1; private: AxWMPLib::AxWindowsMediaPlayer^ axWindowsMediaPlayer1; private: /// <summary> /// Wymagana zmienna projektanta. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Wymagana metoda obsługi projektanta — nie należy modyfikować /// zawartość tej metody z edytorem kodu. /// </summary> OpenFileDialog^ OpenFileDialog1 = gcnew OpenFileDialog(); void InitializeComponent(void) { System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid)); this->button1 = (gcnew System::Windows::Forms::Button()); this->button2 = (gcnew System::Windows::Forms::Button()); this->button3 = (gcnew System::Windows::Forms::Button()); this->button4 = (gcnew System::Windows::Forms::Button()); this->button5 = (gcnew System::Windows::Forms::Button()); this->button6 = (gcnew System::Windows::Forms::Button()); this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip()); this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->openFileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->quitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->listView1 = (gcnew System::Windows::Forms::ListView()); this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader()); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->axWindowsMediaPlayer1 = (gcnew AxWMPLib::AxWindowsMediaPlayer()); this->menuStrip1->SuspendLayout(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->axWindowsMediaPlayer1))->BeginInit(); this->SuspendLayout(); // // button1 // this->button1->Location = System::Drawing::Point(3, 46); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(75, 23); this->button1->TabIndex = 0; this->button1->Text = L"Play"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click); // // button2 // this->button2->Location = System::Drawing::Point(84, 46); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(75, 23); this->button2->TabIndex = 1; this->button2->Text = L"Pause"; this->button2->UseVisualStyleBackColor = true; this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click); // // button3 // this->button3->Location = System::Drawing::Point(246, 46); this->button3->Name = L"button3"; this->button3->Size = System::Drawing::Size(75, 23); this->button3->TabIndex = 2; this->button3->Text = L"Next"; this->button3->UseVisualStyleBackColor = true; // // button4 // this->button4->Location = System::Drawing::Point(165, 46); this->button4->Name = L"button4"; this->button4->Size = System::Drawing::Size(75, 23); this->button4->TabIndex = 3; this->button4->Text = L"Stop"; this->button4->UseVisualStyleBackColor = true; this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click); // // button5 // this->button5->Location = System::Drawing::Point(327, 46); this->button5->Name = L"button5"; this->button5->Size = System::Drawing::Size(75, 23); this->button5->TabIndex = 4; this->button5->Text = L"Previous"; this->button5->UseVisualStyleBackColor = true; // // button6 // this->button6->Location = System::Drawing::Point(408, 46); this->button6->Name = L"button6"; this->button6->Size = System::Drawing::Size(75, 23); this->button6->TabIndex = 5; this->button6->Text = L"Random"; this->button6->UseVisualStyleBackColor = true; // // menuStrip1 // this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) { this->fileToolStripMenuItem }); this->menuStrip1->Location = System::Drawing::Point(0, 0); this->menuStrip1->Name = L"menuStrip1"; this->menuStrip1->Size = System::Drawing::Size(507, 24); this->menuStrip1->TabIndex = 7; this->menuStrip1->Text = L"menuStrip1"; // // fileToolStripMenuItem // this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) { this->openFileToolStripMenuItem, this->toolStripSeparator1, this->quitToolStripMenuItem }); this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem"; this->fileToolStripMenuItem->Size = System::Drawing::Size(37, 20); this->fileToolStripMenuItem->Text = L"File"; // // openFileToolStripMenuItem // this->openFileToolStripMenuItem->Name = L"openFileToolStripMenuItem"; this->openFileToolStripMenuItem->Size = System::Drawing::Size(180, 22); this->openFileToolStripMenuItem->Text = L"Open File"; this->openFileToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::openFileToolStripMenuItem_Click); // // toolStripSeparator1 // this->toolStripSeparator1->Name = L"toolStripSeparator1"; this->toolStripSeparator1->Size = System::Drawing::Size(177, 6); // // quitToolStripMenuItem // this->quitToolStripMenuItem->Name = L"quitToolStripMenuItem"; this->quitToolStripMenuItem->Size = System::Drawing::Size(180, 22); this->quitToolStripMenuItem->Text = L"Quit"; this->quitToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::quitToolStripMenuItem_Click); // // listView1 // this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(1) { this->columnHeader1 }); this->listView1->Location = System::Drawing::Point(12, 214); this->listView1->MultiSelect = false; this->listView1->Name = L"listView1"; this->listView1->Size = System::Drawing::Size(483, 189); this->listView1->TabIndex = 8; this->listView1->UseCompatibleStateImageBehavior = false; this->listView1->View = System::Windows::Forms::View::Details; this->listView1->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::listView1_SelectedIndexChanged); // // columnHeader1 // this->columnHeader1->Text = L"Ścieżka"; this->columnHeader1->Width = 363; // // textBox1 // this->textBox1->Location = System::Drawing::Point(12, 145); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(205, 20); this->textBox1->TabIndex = 9; this->textBox1->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox1_TextChanged); // // axWindowsMediaPlayer1 // this->axWindowsMediaPlayer1->Enabled = true; this->axWindowsMediaPlayer1->Location = System::Drawing::Point(261, 90); this->axWindowsMediaPlayer1->Name = L"axWindowsMediaPlayer1"; this->axWindowsMediaPlayer1->OcxState = (cli::safe_cast<System::Windows::Forms::AxHost::State^>(resources->GetObject(L"axWindowsMediaPlayer1.OcxState"))); this->axWindowsMediaPlayer1->Size = System::Drawing::Size(222, 99); this->axWindowsMediaPlayer1->TabIndex = 10; this->axWindowsMediaPlayer1->Enter += gcnew System::EventHandler(this, &MyForm::axWindowsMediaPlayer1_Enter); // // MyForm // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(507, 415); this->Controls->Add(this->axWindowsMediaPlayer1); this->Controls->Add(this->textBox1); this->Controls->Add(this->listView1); this->Controls->Add(this->button6); this->Controls->Add(this->button5); this->Controls->Add(this->button4); this->Controls->Add(this->button3); this->Controls->Add(this->button2); this->Controls->Add(this->button1); this->Controls->Add(this->menuStrip1); this->MainMenuStrip = this->menuStrip1; this->Name = L"MyForm"; this->Text = L"MyForm"; this->menuStrip1->ResumeLayout(false); this->menuStrip1->PerformLayout(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->axWindowsMediaPlayer1))->EndInit(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void quitToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { this->Close(); } private: System::Void openFileToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { Stream^ myStream; if (OpenFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK ) { if ((myStream = OpenFileDialog1->OpenFile()) != nullptr) { String^ strfilename = OpenFileDialog1->InitialDirectory + OpenFileDialog1->FileName; MessageBox::Show(strfilename); //textBox1->Text = OpenFileDialog1->FileName; listViewItem = gcnew Windows::Forms::ListViewItem(this->OpenFileDialog1->FileName); this->listView1->Items->Add(this->listViewItem); myStream->Close(); } } } private: System::Void listView1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { } private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Player::open(); //if (axWindowsMediaPlayer1->URL != OpenFileDialog1->FileName) //axWindowsMediaPlayer1->URL = OpenFileDialog1->FileName; //axWindowsMediaPlayer1->Ctlcontrols->play(); } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { axWindowsMediaPlayer1->Ctlcontrols->pause(); } private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { axWindowsMediaPlayer1->Ctlcontrols->stop(); } private: System::Void openFolderToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void axWindowsMediaPlayer1_Enter(System::Object^ sender, System::EventArgs^ e) { } }; }
[ "gloryseeker66@gmail.com" ]
gloryseeker66@gmail.com
2b3951b075345a7f29e0aafab13de1fbe63499d1
58475d1b39384a6a016227c93e2ab69521a26d4c
/AVR_tools/Owi.cpp
9b8b34ebb7c59a547af945af1ffff5cf2b48aeb6
[ "Beerware" ]
permissive
uncle-Zoid/AVR
32cc457e29673d55c179256fdceaa4ad58f83bb7
143e51ccab5e7286f40a2f8ce4e4200a359c0bca
refs/heads/master
2022-12-10T22:52:35.772523
2020-08-27T12:04:58
2020-08-27T12:04:58
283,755,019
1
0
null
null
null
null
UTF-8
C++
false
false
2,023
cpp
/* * Owi.cpp * * Created: 18.06.2020 10:05:41 * Author: pappd */ #include "Owi.h" #include <avr/io.h> #include <util/delay.h> #include <avr/interrupt.h> Owi::Owi(const AvrPort &port, uint8_t pin) : port_ (port) , pin_ (pin) { } byte_t Owi::reset() { cli(); setbit (*port_.ddr, pin_); // nastav pin jako vystupni setbit (*port_.port, pin_); // nahod sbernici _delay_us(5); resbit (*port_.port, pin_); // stahni sbernici _delay_us(H); setbit (*port_.port, pin_); // uvolni sbernici _delay_us(I); resbit (*port_.ddr, pin_); // nastavit pin jako vstupni byte_t presence = !testbit (*port_.pin, pin_); // precti hodnotu _delay_us (J); sei(); return presence; } void Owi::writeBit(byte_t bit) { cli (); setbit (*port_.ddr, pin_); resbit (*port_.port, pin_); if (bit) { _delay_us(A); setbit (*port_.port, pin_); _delay_us(B); } else { _delay_us(C); setbit (*port_.port, pin_); _delay_us(D); } sei (); } void Owi::writeByte(byte_t byte) { for (uint8_t i = 0; i < 8; ++i) { writeBit(byte & 0x01); byte >>= 1; } } byte_t Owi::readBit() { byte_t res = 0; cli (); setbit (*port_.ddr, pin_); resbit (*port_.port, pin_); _delay_us (A); setbit (*port_.port, pin_); _delay_us (E); resbit (*port_.ddr, pin_); // nastav jako vstupni res = testbit (*port_.pin, pin_); _delay_us (F); sei (); return res; } byte_t Owi::readByte() { byte_t result = 0x00; for (uint8_t i = 0; i < 8; ++i) { result >>= 1; result |= 0x80 * readBit(); } return result; } void Owi::readROM(byte_t *rom, byte_t size) { reset(); writeByte(OWI_READ_ROM); for (uint8_t i = 0; i < size; ++i) { rom[i] = readByte(); } } void Owi::skipRom() { reset(); writeByte(OWI_SKIP_ROM); } void Owi::matchROM(byte_t *ROM_64bit) { reset(); writeByte(OWI_MATCH_ROM); for(uint8_t i = 0; i < 8; ++i) { writeByte(ROM_64bit[i]); } }
[ "dominik.papp@tcz.cz" ]
dominik.papp@tcz.cz
eaeeb17fa551a66474d234025e42e5b18aafd07b
f97babbde971815bcc118da750ad462726a87858
/fastText/src/loss.h
d20423b627d54046eb7c144027ca22077e77bee7
[ "MIT" ]
permissive
key2long/HyperbolicEmbedding
925d4204f744ac2f6376edfdd26a30f685f69229
5eb05b7816b774be42e08004ce5b5ead14fe5650
refs/heads/master
2023-06-09T16:25:10.413547
2019-08-20T09:45:59
2019-08-20T09:45:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,728
h
/** * Copyright (c) 2016-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <memory> #include <random> #include <vector> #include "matrix.h" #include "model.h" #include "real.h" #include "utils.h" #include "vector.h" namespace fasttext { class Loss { private: void findKBest( int32_t k, real threshold, Predictions& heap, const Vector& output) const; protected: std::vector<real> t_sigmoid_; std::vector<real> t_log_; std::shared_ptr<Matrix>& wo_; real log(real x) const; real sigmoid(real x) const; public: explicit Loss(std::shared_ptr<Matrix>& wo); virtual ~Loss() = default; virtual real forward( const std::vector<int32_t>& targets, int32_t targetIndex, Model::State& state, real lr, bool backprop) = 0; virtual real forwardHyper( Matrix & wi_, int32_t inWordId, int32_t outWordId, Model::State& state, real lr, bool backprop) = 0; virtual void computeOutput(Model::State& state) const = 0; virtual void predict( int32_t /*k*/, real /*threshold*/, Predictions& /*heap*/, Model::State& /*state*/) const; }; class UnitBiLogisticLoss: public Loss { protected: real unitBiLogistic( int32_t target, Model::State& state, real uNorm, bool labelIsPositive, real lr, bool backprop) const; public: explicit UnitBiLogisticLoss(std::shared_ptr<Matrix>& wo); virtual ~UnitBiLogisticLoss() noexcept override = default; void computeOutput(Model::State& state) const override; }; class BinaryLogisticLoss : public Loss { protected: real binaryLogistic( int32_t target, Model::State& state, bool labelIsPositive, real lr, bool backprop) const; public: explicit BinaryLogisticLoss(std::shared_ptr<Matrix>& wo); virtual ~BinaryLogisticLoss() noexcept override = default; void computeOutput(Model::State& state) const override; }; class OneVsAllLoss : public BinaryLogisticLoss { public: explicit OneVsAllLoss(std::shared_ptr<Matrix>& wo); ~OneVsAllLoss() noexcept override = default; real forward( const std::vector<int32_t>& targets, int32_t targetIndex, Model::State& state, real lr, bool backprop) override; }; class UnitNegativeSamplingLoss: public UnitBiLogisticLoss { protected: static const int32_t UNITNEGATIVE_TABLE_SIZE = 10000000; int neg_; std::vector<int32_t> negatives_; std::uniform_int_distribution<size_t> uniform_; int32_t getNegative(int32_t target, std::minstd_rand& rng); int32_t getNegativeHyper(int32_t inputId, int32_t target, std::minstd_rand& rng); public: explicit UnitNegativeSamplingLoss( std::shared_ptr<Matrix>& wo, int neg, const std::vector<int64_t>& targetCounts); ~UnitNegativeSamplingLoss() noexcept override = default; // real lorentzProduct(Vector& x); real forward( const std::vector<int32_t>& targets, int32_t targetIndex, Model::State& state, real lr, bool backprop) override; real forwardHyper( Matrix & wi_, int32_t inWordId, int32_t outWordId, Model::State& state, real lr, bool backprop) override; }; class NegativeSamplingLoss : public BinaryLogisticLoss { protected: static const int32_t NEGATIVE_TABLE_SIZE = 10000000; int neg_; std::vector<int32_t> negatives_; std::uniform_int_distribution<size_t> uniform_; int32_t getNegative(int32_t target, std::minstd_rand& rng); public: explicit NegativeSamplingLoss( std::shared_ptr<Matrix>& wo, int neg, const std::vector<int64_t>& targetCounts); ~NegativeSamplingLoss() noexcept override = default; real forward( const std::vector<int32_t>& targets, int32_t targetIndex, Model::State& state, real lr, bool backprop) override; real forwardHyper( Matrix & wi_, int32_t inputId, int32_t outWordId, Model::State& state, real lr, bool backprop) override; }; class HierarchicalSoftmaxLoss : public BinaryLogisticLoss { protected: struct Node { int32_t parent; int32_t left; int32_t right; int64_t count; bool binary; }; std::vector<std::vector<int32_t>> paths_; std::vector<std::vector<bool>> codes_; std::vector<Node> tree_; int32_t osz_; void buildTree(const std::vector<int64_t>& counts); void dfs( int32_t k, real threshold, int32_t node, real score, Predictions& heap, const Vector& hidden) const; public: explicit HierarchicalSoftmaxLoss( std::shared_ptr<Matrix>& wo, const std::vector<int64_t>& counts); ~HierarchicalSoftmaxLoss() noexcept override = default; real forward( const std::vector<int32_t>& targets, int32_t targetIndex, Model::State& state, real lr, bool backprop) override; void predict( int32_t k, real threshold, Predictions& heap, Model::State& state) const override; }; class SoftmaxLoss : public Loss { public: explicit SoftmaxLoss(std::shared_ptr<Matrix>& wo); ~SoftmaxLoss() noexcept override = default; real forward( const std::vector<int32_t>& targets, int32_t targetIndex, Model::State& state, real lr, bool backprop) override; void computeOutput(Model::State& state) const override; }; } // namespace fasttext
[ "yaopeizhang1@yeah.net" ]
yaopeizhang1@yeah.net
2d0f3f46e819d631a4fc59ecf1352ef65da660ac
68aa47b6de663a691a45604987d05f52b47e8073
/src/kflio_node.cpp
06a6e8bc0b8dd8d1988a3209610254515ac24062
[]
no_license
liuxinren456852/test
993337fbee1ae6ad8845c9bd37d5fa8015ea7c44
5ad8bae3389c344dc0f4e8156e17abec1b176355
refs/heads/master
2022-04-08T11:13:28.351385
2020-02-27T19:34:51
2020-02-27T19:34:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
550
cpp
#include <ros/ros.h> #include <parameters.h> #include <Estimator.h> int main(int argc, char** argv) { ros::init(argc, argv, "liom_fusion_node"); ros::NodeHandle nh; ros::NodeHandle pnh("~"); ROS_INFO("\033[1;32m---->\033[0m Feature IMU Association Started."); parameter::readParameters(pnh); fusion::Liom liom(nh, pnh); liom.run(); /* ros::Rate rate(200); while (ros::ok()) { ros::spinOnce(); liom.process(); rate.sleep(); }*/ ros::spin(); return 0; }
[ "qinchaom4a1@163.com" ]
qinchaom4a1@163.com
8a5228ee31bac3a8a008aa5cef8dc0a16f9a02a0
d5785b4a1abf832fb6fed4ff4cfe06a0e44e0fe6
/toj373.cpp
eaee3a2ac8eccc134ce93a3c0f9e21258d44bbea
[]
no_license
arasHi87/OnlineJudgeExercise
7caaf58f43c675488a712279cb310c55729957d4
90afc36d25bd2a015c7fde604c78d82591d2113a
refs/heads/master
2022-02-21T19:06:39.260348
2019-09-22T09:17:13
2019-09-22T09:17:13
197,958,223
0
1
null
null
null
null
UTF-8
C++
false
false
415
cpp
#include <cstdio> using namespace std; int x1, x2, y1, y2, x, y, W, H; double tmp; int main() { #ifdef local freopen("in", "r", stdin); #endif scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x, &y); W=x2-x1, H=y2-y1; if (x<x1) tmp+=(x1-x)*H/2.0; if (x>x2) tmp+=(x-x2)*H/2.0; if (y<y1) tmp+=(y1-y)*W/2.0; if (y>y2) tmp+=(y-y2)*W/2.0; printf("%.1f\n", W*H+tmp); }
[ "arasi27676271@gmail.com" ]
arasi27676271@gmail.com
5dfd7789707632222e997ab1d27a8bebb4f2219d
e9ac38a3c8e09ec3b5050fb8d60b695f592f0cca
/src/base/buffer.cpp
aa91df2bbbac9adb5ba71ea9252102e4773bd5cd
[]
no_license
AnaBit/cobweb
54572bdd116d8ceb71eba9e6ac81b88304dc0957
4288898f542176684d1ee347277375768dc6b274
refs/heads/master
2016-09-01T13:21:34.329864
2016-04-12T10:53:13
2016-04-12T10:53:13
54,700,752
0
0
null
null
null
null
UTF-8
C++
false
false
1,238
cpp
#include "buffer.hpp" namespace cobweb { namespace base { atom_buffer::buffer_data atom_buffer::conv_data(std::vector<unsigned char> & data) { buffer_data buf(data); return buf; } atom_buffer::buffer_data atom_buffer::conv_data(std::vector<unsigned char> && data) { buffer_data buf(data); return buf; } atom_buffer::atom_buffer() { } atom_buffer::~atom_buffer() { } void atom_buffer::push_back(atom_buffer::buffer_data & data) { wait(); _buffer.push_back(data); leave(); } void atom_buffer::push_back(atom_buffer::buffer_data && data) { wait(); _buffer.push_back(data); leave(); } atom_buffer::buffer_data atom_buffer::front() { wait(); buffer_data buf = _buffer.front(); leave(); return buf; } atom_buffer::buffer_data atom_buffer::pop_front() { wait(); buffer_data buf = _buffer.front(); _buffer.pop_front(); leave(); return buf; } void atom_buffer::clear() { wait(); _buffer.clear(); leave(); } size_t atom_buffer::size() { wait(); size_t size = _buffer.size(); leave(); return size; } void atom_buffer::wait() { while (_flag_buffer.test_and_set()); } void atom_buffer::leave() { _flag_buffer.clear(); } } }
[ "AnaBitIO@hotmail.com" ]
AnaBitIO@hotmail.com
aaf31aa1fb9aefab2c2bfdada85afd1ca9f5b90d
be56db18beb96bb0584baa423caa8effabc28d03
/src/gpu/kernel_runner.cpp
0bb0345f2c6d7c9b8bf660809b092163bd030921
[ "BSL-1.0", "Apache-2.0" ]
permissive
jingjing54007/clDNN
c09fa54de686a65e98396cc19751a4b629863c33
32b63d833ae078907b85343164708a541fe4d5a5
refs/heads/master
2020-03-14T23:31:47.650731
2018-04-09T02:36:31
2018-04-09T10:17:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,392
cpp
/* // Copyright (c) 2016 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. */ /////////////////////////////////////////////////////////////////////////////////////////////////// #include "kernel_runner.h" #include "kernel.h" #include <chrono> namespace cldnn { namespace gpu { kernel_runner::kernel_runner(engine_impl& engine_ref, bool weights_and_bias_exist) : engine(&engine_ref), weights_and_bias_exist(weights_and_bias_exist) { } void kernel_runner::prepare_kernel_args(const KernelSelector::KernelsData& kernels_data, gpu::kernel::kernel_arguments_data& args) { const auto& base_params = *static_cast<KernelSelector::BaseParams*>(kernels_data[0].params.get()); // Prepare input buffers if (input_buffers.empty()) { for (const auto& input : base_params.inputs) { int num_of_input_elements = (int)input.PhysicalSize(); input_buffers.push_back(engine->allocate_memory({ from_data_type(input.GetDType()), format::bfyx, tensor(1, 1, num_of_input_elements, 1) })); } } for (const auto& input : input_buffers) { args.inputs.push_back(input); } // Prepare output buffer if (output_buffers.empty()) { int num_of_output_elements = (int)base_params.output.PhysicalSize(); output_buffers.push_back(engine->allocate_memory({ from_data_type(base_params.output.GetDType()), format::bfyx, tensor(1, 1, num_of_output_elements, 1) })); } args.output = output_buffers[0]; if (weights_and_bias_exist) { // Prepare weight buffer const auto& weights_bias_params = *static_cast<KernelSelector::WeightBiasParams*>(kernels_data[0].params.get()); int num_of_weight_elements = (int)weights_bias_params.weights.PhysicalSize(); if (weight_buffers.empty()) { weight_buffers.push_back(engine->allocate_memory({ from_weights_type(weights_bias_params.weights.GetDType()), format::bfyx, tensor(1, 1, num_of_weight_elements, 1) })); } while (weight_buffers[0]->get_layout().bytes_count() < weights_bias_params.weights.PhysicalSizeInBytes()) { // Weights layout depends on the kernel. Multiply the buffer size by 2 until it is big enough // (to avoid complex computations of the exact buffer size according to the chosen layout). weight_buffers.clear(); num_of_weight_elements *= 2; weight_buffers.push_back(engine->allocate_memory({ from_weights_type(weights_bias_params.weights.GetDType()), format::bfyx, tensor(1, 1, num_of_weight_elements, 1) })); } args.weights = weight_buffers[0]; // Prepare bias buffer if (!weights_bias_params.bias.empty()) { if (bias_buffers.empty()) { int num_of_bias_elements = (int)weights_bias_params.bias[0].PhysicalSize(); bias_buffers.push_back(engine->allocate_memory({ from_data_type(weights_bias_params.bias[0].GetDType()), format::bfyx, tensor(1, 1, num_of_bias_elements, 1) })); } args.bias = bias_buffers[0]; } } args.split = 0; } std::vector<uint64_t> kernel_runner::run_kernels(const KernelSelector::KernelsData& kernels_data) { auto context = engine->get_context(); std::vector<uint64_t> run_times; int num_of_kernels_to_run = (int)kernels_data.size(); KernelSelector::KernelsData::const_iterator batch_start = kernels_data.begin(); KernelSelector::KernelsData::const_iterator batch_end; while (num_of_kernels_to_run > 0) { int current_compilation_batch = std::min(num_of_kernels_to_run, compilation_batch_size); batch_end = batch_start + current_compilation_batch; std::vector<gpu::kernel> kernels; for (auto it = batch_start; it < batch_end; it++) { kernels.push_back(kernel(context, it->kernels[0].kernelString, false, true)); } gpu::kernel::kernel_arguments_data args; prepare_kernel_args(kernels_data, args); int i = 0; for (auto it = batch_start; it < batch_end; it++) { std::vector<event_impl::ptr> events; uint64_t kernel_run_time = 0; int num_of_runs = 0; for (int iteration = 0; iteration < runs_per_kernel; iteration++) { event_impl::ptr event; try { event = kernels[i].run(it->kernels[0], {}, args); } catch (...) { // Could not run this kernel. Push back NULL event (will be ignored later). } events.push_back(event); } context->queue().finish(); for (auto& event : events) { if (event.get() != NULL) { auto profiling_intervals = event->get_profiling_info(); for (auto const& profiling_interval : profiling_intervals) { if (strcmp(profiling_interval.name, "executing") == 0) { kernel_run_time += profiling_interval.nanoseconds; num_of_runs++; break; } } } } if (num_of_runs > 0) { run_times.push_back(kernel_run_time / num_of_runs); } else { run_times.push_back(std::numeric_limits<uint64_t>::max()); } i++; } num_of_kernels_to_run -= current_compilation_batch; batch_start += current_compilation_batch; } return run_times; } }}
[ "tomasz.poniecki@intel.com" ]
tomasz.poniecki@intel.com
fefe116c87467822bc7a5606dbf092fa45c69b79
16d488cb25d6dd784e13c288cfc7c1ac5fb1d23a
/triangle/triangle.hpp
b1b8614be33c2b00320066a3bc9981a10cdbe5f2
[]
no_license
sufuf3/ST2017-hw4-Symbolic_and_Fuzz
59ca97d5437ef2efdb0df93a068a7f7f044e64b7
d148795b7ffafa556d10f7ee657add0cc6ea1d84
refs/heads/master
2020-12-25T18:52:18.145022
2017-06-12T07:45:58
2017-06-12T07:47:34
94,000,815
1
0
null
null
null
null
UTF-8
C++
false
false
262
hpp
#ifndef __TRIANGLE_H__ #define __TRIANGLE_H__ #define MIN 1 #define MAX 200 #define TYPE_INVALID_INPUT 0 #define TYPE_NOTTRIANGLE 1 #define TYPE_EQUILATERAL 2 #define TYPE_ISOSCELES 3 #define TYPE_SCALENE 4 int triangle_type( int a, int b, int c ); #endif
[ "sufuf3@gmail.com" ]
sufuf3@gmail.com
eb2c1dd1a9516f5e61ccb7737188815bd1678e9e
d61d05748a59a1a73bbf3c39dd2c1a52d649d6e3
/chromium/third_party/crashpad/crashpad/snapshot/win/module_snapshot_win.cc
d9d74c1b7ff20083a6618e1369dd490b1929129f
[ "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "GPL-1.0-or-later", "MIT" ]
permissive
Csineneo/Vivaldi
4eaad20fc0ff306ca60b400cd5fad930a9082087
d92465f71fb8e4345e27bd889532339204b26f1e
refs/heads/master
2022-11-23T17:11:50.714160
2019-05-25T11:45:11
2019-05-25T11:45:11
144,489,531
5
4
BSD-3-Clause
2022-11-04T05:55:33
2018-08-12T18:04:37
null
UTF-8
C++
false
false
11,509
cc
// Copyright 2015 The Crashpad 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. #include "snapshot/win/module_snapshot_win.h" #include <utility> #include "base/strings/utf_string_conversions.h" #include "client/crashpad_info.h" #include "client/simple_address_range_bag.h" #include "snapshot/win/memory_snapshot_win.h" #include "snapshot/win/pe_image_annotations_reader.h" #include "snapshot/win/pe_image_reader.h" #include "util/misc/tri_state.h" #include "util/misc/uuid.h" namespace crashpad { namespace internal { ModuleSnapshotWin::ModuleSnapshotWin() : ModuleSnapshot(), name_(), pdb_name_(), uuid_(), memory_range_(), streams_(), vs_fixed_file_info_(), initialized_vs_fixed_file_info_(), process_reader_(nullptr), pe_image_reader_(), crashpad_info_(), timestamp_(0), age_(0), initialized_() {} ModuleSnapshotWin::~ModuleSnapshotWin() { } bool ModuleSnapshotWin::Initialize( ProcessReaderWin* process_reader, const ProcessInfo::Module& process_reader_module) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); process_reader_ = process_reader; name_ = process_reader_module.name; timestamp_ = process_reader_module.timestamp; pe_image_reader_.reset(new PEImageReader()); if (!pe_image_reader_->Initialize(process_reader_, process_reader_module.dll_base, process_reader_module.size, base::UTF16ToUTF8(name_))) { return false; } DWORD age_dword; if (pe_image_reader_->DebugDirectoryInformation( &uuid_, &age_dword, &pdb_name_)) { static_assert(sizeof(DWORD) == sizeof(uint32_t), "unexpected age size"); age_ = age_dword; } else { // If we fully supported all old debugging formats, we would want to extract // and emit a different type of CodeView record here (as old Microsoft tools // would do). As we don't expect to ever encounter a module that wouldn't be // using .PDB that we actually have symbols for, we simply set a plausible // name here, but this will never correspond to symbols that we have. pdb_name_ = base::UTF16ToUTF8(name_); } if (!memory_range_.Initialize(process_reader_->Memory(), process_reader_->Is64Bit())) { return false; } WinVMAddress crashpad_info_address; WinVMSize crashpad_info_size; if (pe_image_reader_->GetCrashpadInfoSection(&crashpad_info_address, &crashpad_info_size)) { ProcessMemoryRange info_range; info_range.Initialize(memory_range_); info_range.RestrictRange(crashpad_info_address, crashpad_info_address + crashpad_info_size); auto info = std::make_unique<CrashpadInfoReader>(); if (info->Initialize(&info_range, crashpad_info_address)) { crashpad_info_ = std::move(info); } } INITIALIZATION_STATE_SET_VALID(initialized_); return true; } void ModuleSnapshotWin::GetCrashpadOptions(CrashpadInfoClientOptions* options) { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (process_reader_->Is64Bit()) GetCrashpadOptionsInternal<process_types::internal::Traits64>(options); else GetCrashpadOptionsInternal<process_types::internal::Traits32>(options); } std::string ModuleSnapshotWin::Name() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return base::UTF16ToUTF8(name_); } uint64_t ModuleSnapshotWin::Address() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return pe_image_reader_->Address(); } uint64_t ModuleSnapshotWin::Size() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return pe_image_reader_->Size(); } time_t ModuleSnapshotWin::Timestamp() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return timestamp_; } void ModuleSnapshotWin::FileVersion(uint16_t* version_0, uint16_t* version_1, uint16_t* version_2, uint16_t* version_3) const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); const VS_FIXEDFILEINFO* ffi = VSFixedFileInfo(); if (ffi) { *version_0 = ffi->dwFileVersionMS >> 16; *version_1 = ffi->dwFileVersionMS & 0xffff; *version_2 = ffi->dwFileVersionLS >> 16; *version_3 = ffi->dwFileVersionLS & 0xffff; } else { *version_0 = 0; *version_1 = 0; *version_2 = 0; *version_3 = 0; } } void ModuleSnapshotWin::SourceVersion(uint16_t* version_0, uint16_t* version_1, uint16_t* version_2, uint16_t* version_3) const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); const VS_FIXEDFILEINFO* ffi = VSFixedFileInfo(); if (ffi) { *version_0 = ffi->dwProductVersionMS >> 16; *version_1 = ffi->dwProductVersionMS & 0xffff; *version_2 = ffi->dwProductVersionLS >> 16; *version_3 = ffi->dwProductVersionLS & 0xffff; } else { *version_0 = 0; *version_1 = 0; *version_2 = 0; *version_3 = 0; } } ModuleSnapshot::ModuleType ModuleSnapshotWin::GetModuleType() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); const VS_FIXEDFILEINFO* ffi = VSFixedFileInfo(); if (ffi) { switch (ffi->dwFileType) { case VFT_APP: return ModuleSnapshot::kModuleTypeExecutable; case VFT_DLL: return ModuleSnapshot::kModuleTypeSharedLibrary; case VFT_DRV: case VFT_VXD: return ModuleSnapshot::kModuleTypeLoadableModule; } } return ModuleSnapshot::kModuleTypeUnknown; } void ModuleSnapshotWin::UUIDAndAge(crashpad::UUID* uuid, uint32_t* age) const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); *uuid = uuid_; *age = age_; } std::string ModuleSnapshotWin::DebugFileName() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return pdb_name_; } std::vector<std::string> ModuleSnapshotWin::AnnotationsVector() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); // These correspond to system-logged things on Mac. We don't currently track // any of these on Windows, but could in the future. See // https://crashpad.chromium.org/bug/38. return std::vector<std::string>(); } std::map<std::string, std::string> ModuleSnapshotWin::AnnotationsSimpleMap() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); PEImageAnnotationsReader annotations_reader( process_reader_, pe_image_reader_.get(), name_); return annotations_reader.SimpleMap(); } std::vector<AnnotationSnapshot> ModuleSnapshotWin::AnnotationObjects() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); PEImageAnnotationsReader annotations_reader( process_reader_, pe_image_reader_.get(), name_); return annotations_reader.AnnotationsList(); } std::set<CheckedRange<uint64_t>> ModuleSnapshotWin::ExtraMemoryRanges() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); std::set<CheckedRange<uint64_t>> ranges; if (process_reader_->Is64Bit()) GetCrashpadExtraMemoryRanges<process_types::internal::Traits64>(&ranges); else GetCrashpadExtraMemoryRanges<process_types::internal::Traits32>(&ranges); return ranges; } std::vector<const UserMinidumpStream*> ModuleSnapshotWin::CustomMinidumpStreams() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); streams_.clear(); if (process_reader_->Is64Bit()) { GetCrashpadUserMinidumpStreams<process_types::internal::Traits64>( &streams_); } else { GetCrashpadUserMinidumpStreams<process_types::internal::Traits32>( &streams_); } std::vector<const UserMinidumpStream*> result; for (const auto& stream : streams_) { result.push_back(stream.get()); } return result; } template <class Traits> void ModuleSnapshotWin::GetCrashpadOptionsInternal( CrashpadInfoClientOptions* options) { if (!crashpad_info_) { options->crashpad_handler_behavior = TriState::kUnset; options->system_crash_reporter_forwarding = TriState::kUnset; options->gather_indirectly_referenced_memory = TriState::kUnset; options->indirectly_referenced_memory_cap = 0; return; } options->crashpad_handler_behavior = crashpad_info_->CrashpadHandlerBehavior(); options->system_crash_reporter_forwarding = crashpad_info_->SystemCrashReporterForwarding(); options->gather_indirectly_referenced_memory = crashpad_info_->GatherIndirectlyReferencedMemory(); options->indirectly_referenced_memory_cap = crashpad_info_->IndirectlyReferencedMemoryCap(); } const VS_FIXEDFILEINFO* ModuleSnapshotWin::VSFixedFileInfo() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (initialized_vs_fixed_file_info_.is_uninitialized()) { initialized_vs_fixed_file_info_.set_invalid(); if (pe_image_reader_->VSFixedFileInfo(&vs_fixed_file_info_)) { initialized_vs_fixed_file_info_.set_valid(); } } return initialized_vs_fixed_file_info_.is_valid() ? &vs_fixed_file_info_ : nullptr; } template <class Traits> void ModuleSnapshotWin::GetCrashpadExtraMemoryRanges( std::set<CheckedRange<uint64_t>>* ranges) const { if (!crashpad_info_ || !crashpad_info_->ExtraMemoryRanges()) return; std::vector<SimpleAddressRangeBag::Entry> simple_ranges( SimpleAddressRangeBag::num_entries); if (!process_reader_->Memory()->Read( crashpad_info_->ExtraMemoryRanges(), simple_ranges.size() * sizeof(simple_ranges[0]), &simple_ranges[0])) { LOG(WARNING) << "could not read simple address_ranges from " << base::UTF16ToUTF8(name_); return; } for (const auto& entry : simple_ranges) { if (entry.base != 0 || entry.size != 0) { // Deduplication here is fine. ranges->insert(CheckedRange<uint64_t>(entry.base, entry.size)); } } } template <class Traits> void ModuleSnapshotWin::GetCrashpadUserMinidumpStreams( std::vector<std::unique_ptr<const UserMinidumpStream>>* streams) const { if (!crashpad_info_) return; for (uint64_t cur = crashpad_info_->UserDataMinidumpStreamHead(); cur;) { internal::UserDataMinidumpStreamListEntry list_entry; if (!process_reader_->Memory()->Read( cur, sizeof(list_entry), &list_entry)) { LOG(WARNING) << "could not read user data stream entry from " << base::UTF16ToUTF8(name_); return; } if (list_entry.size != 0) { std::unique_ptr<internal::MemorySnapshotWin> memory( new internal::MemorySnapshotWin()); memory->Initialize( process_reader_, list_entry.base_address, list_entry.size); streams->push_back(std::make_unique<UserMinidumpStream>( list_entry.stream_type, memory.release())); } cur = list_entry.next; } } } // namespace internal } // namespace crashpad
[ "csineneo@gmail.com" ]
csineneo@gmail.com
576c9dfb33579334eca1f1f94a57194f5299c29d
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5706278382862336_1/C++/Mejor/A.cpp
0e9a1cfcd02d12e7ec8e7fa0777298d61f2fbd6b
[]
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,071
cpp
#include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <set> #include <map> #include <limits> #include <string> #include <queue> #include <cstdio> using namespace std; long long gcd(long long a, long long b){ while (b!=0){ //fout<<a<<" "<<b<<endl; long long temp=a; a=b; b=temp%b; } // fout<<a<<" "<<b<<endl; return a; } bool verf (long long a){ while (a!=1){ if (a%2==1) return false; a/=2; } return true; } int main (){ ifstream fin("A-large.in"); ofstream fout("A-large.out"); int cpt; fin>>cpt; for (int k=1;k<=cpt;++k){ long long p,q,d,ans=0; char c; bool stop=false; fin>>p>>c>>q; do { d=gcd(q,p); p=p/d,q=q/d; if (!verf(q)) stop=true; else p*=2,ans++; } while (p<q && !stop); if (ans>40) stop=true; if (stop) fout<<"Case #"<<k<<": impossible"<<endl; else fout<<"Case #"<<k<<": "<<ans<<endl; } return 0; }
[ "eewestman@gmail.com" ]
eewestman@gmail.com
4fdddc4be907ae141cb823ca6a68e9de844c41db
e76ea38dbe5774fccaf14e1a0090d9275cdaee08
/src/ash/test/test_launcher_item_delegate.cc
7ac8b727f64a66f34499abcc879493d0089b5c74
[ "BSD-3-Clause" ]
permissive
eurogiciel-oss/Tizen_Crosswalk
efc424807a5434df1d5c9e8ed51364974643707d
a68aed6e29bd157c95564e7af2e3a26191813e51
refs/heads/master
2021-01-18T19:19:04.527505
2014-02-06T13:43:21
2014-02-06T13:43:21
16,070,101
1
3
null
null
null
null
UTF-8
C++
false
false
1,253
cc
// Copyright 2013 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 "ash/test/test_launcher_item_delegate.h" #include "ash/wm/window_util.h" #include "ui/aura/window.h" namespace ash { namespace test { TestLauncherItemDelegate::TestLauncherItemDelegate(aura::Window* window) : window_(window) { } TestLauncherItemDelegate::~TestLauncherItemDelegate() { } void TestLauncherItemDelegate::ItemSelected(const ui::Event& event) { if (window_) { if (window_->type() == aura::client::WINDOW_TYPE_PANEL) ash::wm::MoveWindowToEventRoot(window_, event); window_->Show(); ash::wm::ActivateWindow(window_); } } base::string16 TestLauncherItemDelegate::GetTitle() { return window_ ? window_->title() : base::string16(); } ui::MenuModel* TestLauncherItemDelegate::CreateContextMenu( aura::Window* root_window) { return NULL; } ash::LauncherMenuModel* TestLauncherItemDelegate::CreateApplicationMenu( int event_flags) { return NULL; } bool TestLauncherItemDelegate::IsDraggable() { return true; } bool TestLauncherItemDelegate::ShouldShowTooltip() { return true; } } // namespace test } // namespace ash
[ "ronan@fridu.net" ]
ronan@fridu.net
fbea2b8a5a02bc3c189b4feb934383072e7e9507
889626966d3f108522c753db83a1a23318d4d6fd
/src/governance-object.h
149c20758d17543c584e7f2aae0b1a798b0f93e3
[ "MIT" ]
permissive
safepeofficial/safepeofficial
5a14d0aeaa140c52d3d96f3e7bb892cd28e143c0
aca67695fedfabbdd6dc512358fee54fefc912de
refs/heads/master
2023-06-23T08:00:42.237747
2021-07-22T14:06:58
2021-07-22T14:06:58
386,934,834
0
0
null
null
null
null
UTF-8
C++
false
false
10,097
h
// Copyright (c) 2014-2019 The Dash Core developers // Copyright (c) 2021 The SafePe Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef GOVERNANCE_OBJECT_H #define GOVERNANCE_OBJECT_H #include "cachemultimap.h" #include "governance-exceptions.h" #include "governance-vote.h" #include "governance-votedb.h" #include "key.h" #include "net.h" #include "sync.h" #include "util.h" #include "utilstrencodings.h" #include "bls/bls.h" #include <univalue.h> class CGovernanceManager; class CGovernanceTriggerManager; class CGovernanceObject; class CGovernanceVote; static const int MIN_GOVERNANCE_PEER_PROTO_VERSION = 70213; static const int GOVERNANCE_FILTER_PROTO_VERSION = 70206; static const int GOVERNANCE_POSE_BANNED_VOTES_VERSION = 70215; static const double GOVERNANCE_FILTER_FP_RATE = 0.001; static const int GOVERNANCE_OBJECT_UNKNOWN = 0; static const int GOVERNANCE_OBJECT_PROPOSAL = 1; static const int GOVERNANCE_OBJECT_TRIGGER = 2; static const CAmount GOVERNANCE_PROPOSAL_FEE_TX = (5.0 * COIN); static const int64_t GOVERNANCE_FEE_CONFIRMATIONS = 6; static const int64_t GOVERNANCE_MIN_RELAY_FEE_CONFIRMATIONS = 1; static const int64_t GOVERNANCE_UPDATE_MIN = 60 * 60; static const int64_t GOVERNANCE_DELETION_DELAY = 10 * 60; static const int64_t GOVERNANCE_ORPHAN_EXPIRATION_TIME = 10 * 60; // FOR SEEN MAP ARRAYS - GOVERNANCE OBJECTS AND VOTES static const int SEEN_OBJECT_IS_VALID = 0; static const int SEEN_OBJECT_ERROR_INVALID = 1; static const int SEEN_OBJECT_ERROR_IMMATURE = 2; static const int SEEN_OBJECT_EXECUTED = 3; //used for triggers static const int SEEN_OBJECT_UNKNOWN = 4; // the default typedef std::pair<CGovernanceVote, int64_t> vote_time_pair_t; inline bool operator<(const vote_time_pair_t& p1, const vote_time_pair_t& p2) { return (p1.first < p2.first); } struct vote_instance_t { vote_outcome_enum_t eOutcome; int64_t nTime; int64_t nCreationTime; vote_instance_t(vote_outcome_enum_t eOutcomeIn = VOTE_OUTCOME_NONE, int64_t nTimeIn = 0, int64_t nCreationTimeIn = 0) : eOutcome(eOutcomeIn), nTime(nTimeIn), nCreationTime(nCreationTimeIn) { } ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { int nOutcome = int(eOutcome); READWRITE(nOutcome); READWRITE(nTime); READWRITE(nCreationTime); if (ser_action.ForRead()) { eOutcome = vote_outcome_enum_t(nOutcome); } } }; typedef std::map<int, vote_instance_t> vote_instance_m_t; typedef vote_instance_m_t::iterator vote_instance_m_it; typedef vote_instance_m_t::const_iterator vote_instance_m_cit; struct vote_rec_t { vote_instance_m_t mapInstances; ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(mapInstances); } }; /** * Governance Object * */ class CGovernanceObject { friend class CGovernanceManager; friend class CGovernanceTriggerManager; friend class CSuperblock; public: // Types typedef std::map<COutPoint, vote_rec_t> vote_m_t; typedef vote_m_t::iterator vote_m_it; typedef vote_m_t::const_iterator vote_m_cit; typedef CacheMultiMap<COutPoint, vote_time_pair_t> vote_cmm_t; private: /// critical section to protect the inner data structures mutable CCriticalSection cs; /// Object typecode int nObjectType; /// parent object, 0 is root uint256 nHashParent; /// object revision in the system int nRevision; /// time this object was created int64_t nTime; /// time this object was marked for deletion int64_t nDeletionTime; /// fee-tx uint256 nCollateralHash; /// Data field - can be used for anything std::vector<unsigned char> vchData; /// Masternode info for signed objects COutPoint masternodeOutpoint; std::vector<unsigned char> vchSig; /// is valid by blockchain bool fCachedLocalValidity; std::string strLocalValidityError; // VARIOUS FLAGS FOR OBJECT / SET VIA MASTERNODE VOTING /// true == minimum network support has been reached for this object to be funded (doesn't mean it will for sure though) bool fCachedFunding; /// true == minimum network has been reached flagging this object as a valid and understood governance object (e.g, the serialized data is correct format, etc) bool fCachedValid; /// true == minimum network support has been reached saying this object should be deleted from the system entirely bool fCachedDelete; /** true == minimum network support has been reached flagging this object as endorsed by an elected representative body * (e.g. business review board / technecial review board /etc) */ bool fCachedEndorsed; /// object was updated and cached values should be updated soon bool fDirtyCache; /// Object is no longer of interest bool fExpired; /// Failed to parse object data bool fUnparsable; vote_m_t mapCurrentMNVotes; /// Limited map of votes orphaned by MN vote_cmm_t cmmapOrphanVotes; CGovernanceObjectVoteFile fileVotes; public: CGovernanceObject(); CGovernanceObject(const uint256& nHashParentIn, int nRevisionIn, int64_t nTime, const uint256& nCollateralHashIn, const std::string& strDataHexIn); CGovernanceObject(const CGovernanceObject& other); // Public Getter methods int64_t GetCreationTime() const { return nTime; } int64_t GetDeletionTime() const { return nDeletionTime; } int GetObjectType() const { return nObjectType; } const uint256& GetCollateralHash() const { return nCollateralHash; } const COutPoint& GetMasternodeOutpoint() const { return masternodeOutpoint; } bool IsSetCachedFunding() const { return fCachedFunding; } bool IsSetCachedValid() const { return fCachedValid; } bool IsSetCachedDelete() const { return fCachedDelete; } bool IsSetCachedEndorsed() const { return fCachedEndorsed; } bool IsSetDirtyCache() const { return fDirtyCache; } bool IsSetExpired() const { return fExpired; } const CGovernanceObjectVoteFile& GetVoteFile() const { return fileVotes; } // Signature related functions void SetMasternodeOutpoint(const COutPoint& outpoint); bool Sign(const CBLSSecretKey& key); bool CheckSignature(const CBLSPublicKey& pubKey) const; std::string GetSignatureMessage() const; uint256 GetSignatureHash() const; // CORE OBJECT FUNCTIONS bool IsValidLocally(std::string& strError, bool fCheckCollateral) const; bool IsValidLocally(std::string& strError, bool& fMissingMasternode, bool& fMissingConfirmations, bool fCheckCollateral) const; /// Check the collateral transaction for the budget proposal/finalized budget bool IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const; void UpdateLocalValidity(); void UpdateSentinelVariables(); CAmount GetMinCollateralFee() const; UniValue GetJSONObject(); void Relay(CConnman& connman); uint256 GetHash() const; // GET VOTE COUNT FOR SIGNAL int CountMatchingVotes(vote_signal_enum_t eVoteSignalIn, vote_outcome_enum_t eVoteOutcomeIn) const; int GetAbsoluteYesCount(vote_signal_enum_t eVoteSignalIn) const; int GetAbsoluteNoCount(vote_signal_enum_t eVoteSignalIn) const; int GetYesCount(vote_signal_enum_t eVoteSignalIn) const; int GetNoCount(vote_signal_enum_t eVoteSignalIn) const; int GetAbstainCount(vote_signal_enum_t eVoteSignalIn) const; bool GetCurrentMNVotes(const COutPoint& mnCollateralOutpoint, vote_rec_t& voteRecord) const; // FUNCTIONS FOR DEALING WITH DATA STRING std::string GetDataAsHexString() const; std::string GetDataAsPlainString() const; // SERIALIZER ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { // SERIALIZE DATA FOR SAVING/LOADING OR NETWORK FUNCTIONS READWRITE(nHashParent); READWRITE(nRevision); READWRITE(nTime); READWRITE(nCollateralHash); READWRITE(vchData); READWRITE(nObjectType); READWRITE(masternodeOutpoint); if (!(s.GetType() & SER_GETHASH)) { READWRITE(vchSig); } if (s.GetType() & SER_DISK) { // Only include these for the disk file format LogPrint("gobject", "CGovernanceObject::SerializationOp Reading/writing votes from/to disk\n"); READWRITE(nDeletionTime); READWRITE(fExpired); READWRITE(mapCurrentMNVotes); READWRITE(fileVotes); LogPrint("gobject", "CGovernanceObject::SerializationOp hash = %s, vote count = %d\n", GetHash().ToString(), fileVotes.GetVoteCount()); } // AFTER DESERIALIZATION OCCURS, CACHED VARIABLES MUST BE CALCULATED MANUALLY } private: // FUNCTIONS FOR DEALING WITH DATA STRING void LoadData(); void GetData(UniValue& objResult); bool ProcessVote(CNode* pfrom, const CGovernanceVote& vote, CGovernanceException& exception, CConnman& connman); /// Called when MN's which have voted on this object have been removed void ClearMasternodeVotes(); // Revalidate all votes from this MN and delete them if validation fails. // This is the case for DIP3 MNs that changed voting or operator keys and // also for MNs that were removed from the list completely. // Returns deleted vote hashes. std::set<uint256> RemoveInvalidVotes(const COutPoint& mnOutpoint); void CheckOrphanVotes(CConnman& connman); }; #endif
[ "dev.vanshtah@gmail.com" ]
dev.vanshtah@gmail.com
485de1992d09f2ed397435ff6dea04d61b1645e6
08613205986ad9671c661f0d8e2668df4c24c91c
/Aliza_Naqvi_zz/serialComm/serialComm.ino
542ab0ca613d6cd7b474d9f448681d8d0c86233e
[]
no_license
zhenzhenqi/baruchPresentation
3570008e50de4cb9b973335a4efd46d38f8a140a
92cbe580c08fb916d84f281459ba5e0e09f02246
refs/heads/master
2021-06-25T03:15:15.174942
2017-09-13T02:32:23
2017-09-13T02:32:23
103,343,651
0
0
null
null
null
null
UTF-8
C++
false
false
419
ino
const int SENSOR_PIN = 0; // Analog input pin void setup() { Serial.begin(9600); // No need for any code here // analogWrite() sets up the pins as outputs } void loop() { int sensorValue; // // // Read the voltage from the softpot (0-1023) // sensorValue = analogRead(A0); Serial.write(map(sensorValue,0,1024,255,0)); // Serial.write(map(sensorValue, 0, 1024, 255, 0)); delay(100); }
[ "jane363636@gmail.com" ]
jane363636@gmail.com
d095c26090762548dc580b650dc558094555da02
c41b487ea8a7452f9dffcff8e173d1b300cdc6e7
/pvr/channels/PVRChannelGroupInternal.cpp
e536bce3024df35a0e752aa24f8d9f1d23c6657a
[]
no_license
PengWEI9/seebo
0ade683df5acee18c6458d7326b5a2b761cb9b0e
615caa9f9e625d7961bb4499061d64cec5299019
refs/heads/master
2020-06-18T07:38:48.104372
2016-11-30T09:24:47
2016-11-30T09:24:47
75,152,259
0
0
null
null
null
null
UTF-8
C++
false
false
12,679
cpp
/* * Copyright (C) 2012-2013 Team XBMC * http://xbmc.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XBMC; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. * */ #include "PVRChannelGroupInternal.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogYesNo.h" #include "dialogs/GUIDialogOK.h" #include "settings/AdvancedSettings.h" #include "utils/log.h" #include "PVRChannelGroupsContainer.h" #include "pvr/PVRDatabase.h" #include "pvr/PVRManager.h" #include "epg/EpgContainer.h" #include "pvr/timers/PVRTimers.h" #include "pvr/addons/PVRClients.h" using namespace PVR; using namespace EPG; using namespace std; CPVRChannelGroupInternal::CPVRChannelGroupInternal(bool bRadio) : CPVRChannelGroup(bRadio, bRadio ? XBMC_INTERNAL_GROUP_RADIO : XBMC_INTERNAL_GROUP_TV, g_localizeStrings.Get(bRadio ? 19216 : 19217)) { m_iHiddenChannels = 0; m_iGroupType = PVR_GROUP_TYPE_INTERNAL; } CPVRChannelGroupInternal::CPVRChannelGroupInternal(const CPVRChannelGroup &group) : CPVRChannelGroup(group) { m_iHiddenChannels = group.GetNumHiddenChannels(); } CPVRChannelGroupInternal::~CPVRChannelGroupInternal(void) { Unload(); g_PVRManager.UnregisterObserver(this); } bool CPVRChannelGroupInternal::Load(void) { if (CPVRChannelGroup::Load()) { UpdateChannelPaths(); g_PVRManager.RegisterObserver(this); return true; } CLog::Log(LOGERROR, "PVRChannelGroupInternal - %s - failed to load channels", __FUNCTION__); return false; } void CPVRChannelGroupInternal::CheckGroupName(void) { CSingleLock lock(m_critSection); /* check whether the group name is still correct, or channels will fail to load after the language setting changed */ CStdString strNewGroupName = g_localizeStrings.Get(m_bRadio ? 19216 : 19217); if (!m_strGroupName.Equals(strNewGroupName)) { SetGroupName(strNewGroupName, true); UpdateChannelPaths(); } } void CPVRChannelGroupInternal::UpdateChannelPaths(void) { for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++) { PVRChannelGroupMember member = m_members.at(iChannelPtr); member.channel->UpdatePath(this, iChannelPtr); } } void CPVRChannelGroupInternal::UpdateFromClient(const CPVRChannel &channel, unsigned int iChannelNumber /* = 0 */) { CSingleLock lock(m_critSection); CPVRChannelPtr realChannel = GetByClient(channel.UniqueID(), channel.ClientID()); if (realChannel) { realChannel->UpdateFromClient(channel); } else { PVRChannelGroupMember newMember = { CPVRChannelPtr(new CPVRChannel(channel)), iChannelNumber > 0l ? iChannelNumber : (int)m_members.size() + 1 }; m_members.push_back(newMember); m_bChanged = true; SortAndRenumber(); } } bool CPVRChannelGroupInternal::InsertInGroup(CPVRChannel &channel, int iChannelNumber /* = 0 */) { CSingleLock lock(m_critSection); return CPVRChannelGroup::AddToGroup(channel, iChannelNumber); } bool CPVRChannelGroupInternal::Update(void) { CPVRChannelGroupInternal PVRChannels_tmp(m_bRadio); PVRChannels_tmp.SetPreventSortAndRenumber(); return PVRChannels_tmp.LoadFromClients() && UpdateGroupEntries(PVRChannels_tmp); } bool CPVRChannelGroupInternal::AddToGroup(CPVRChannel &channel, int iChannelNumber /* = 0 */) { CSingleLock lock(m_critSection); bool bReturn(false); /* get the actual channel since this is called from a fileitemlist copy */ CPVRChannelPtr realChannel = GetByChannelID(channel.ChannelID()); if (!realChannel) return bReturn; /* switch the hidden flag */ if (realChannel->IsHidden()) { realChannel->SetHidden(false); m_iHiddenChannels--; SortAndRenumber(); } /* move this channel and persist */ bReturn = (iChannelNumber > 0l) ? MoveChannel(realChannel->ChannelNumber(), iChannelNumber, true) : MoveChannel(realChannel->ChannelNumber(), m_members.size() - m_iHiddenChannels, true); if (m_bLoaded) realChannel->Persist(); return bReturn; } bool CPVRChannelGroupInternal::RemoveFromGroup(const CPVRChannel &channel) { CSingleLock lock(m_critSection); /* check if this channel is currently playing if we are hiding it */ CPVRChannelPtr currentChannel; if (g_PVRManager.GetCurrentChannel(currentChannel) && *currentChannel == channel) { CGUIDialogOK::ShowAndGetInput(19098,19101,0,19102); return false; } /* get the actual channel since this is called from a fileitemlist copy */ CPVRChannelPtr realChannel = GetByChannelID(channel.ChannelID()); if (!realChannel) return false; /* switch the hidden flag */ if (!realChannel->IsHidden()) { realChannel->SetHidden(true); ++m_iHiddenChannels; } else { realChannel->SetHidden(false); --m_iHiddenChannels; } /* renumber this list */ SortAndRenumber(); /* and persist */ return realChannel->Persist() && Persist(); } bool CPVRChannelGroupInternal::MoveChannel(unsigned int iOldChannelNumber, unsigned int iNewChannelNumber, bool bSaveInDb /* = true */) { CSingleLock lock(m_critSection); /* new channel number out of range */ if (iNewChannelNumber > m_members.size() - m_iHiddenChannels) iNewChannelNumber = m_members.size() - m_iHiddenChannels; return CPVRChannelGroup::MoveChannel(iOldChannelNumber, iNewChannelNumber, bSaveInDb); } int CPVRChannelGroupInternal::GetMembers(CFileItemList &results, bool bGroupMembers /* = true */) const { int iOrigSize = results.Size(); CSingleLock lock(m_critSection); for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++) { CPVRChannelPtr channel = m_members.at(iChannelPtr).channel; if (!channel) continue; if (bGroupMembers != channel->IsHidden()) { CFileItemPtr pFileItem(new CFileItem(*channel)); results.Add(pFileItem); } } return results.Size() - iOrigSize; } int CPVRChannelGroupInternal::LoadFromDb(bool bCompress /* = false */) { CPVRDatabase *database = GetPVRDatabase(); if (!database) return -1; int iChannelCount = Size(); if (database->Get(*this) > 0) { if (bCompress) database->Compress(true); } else { CLog::Log(LOGINFO, "PVRChannelGroupInternal - %s - no channels in the database", __FUNCTION__); } SortByChannelNumber(); return Size() - iChannelCount; } bool CPVRChannelGroupInternal::LoadFromClients(void) { /* get the channels from the backends */ return g_PVRClients->GetChannels(this) == PVR_ERROR_NO_ERROR; } bool CPVRChannelGroupInternal::Renumber(void) { CSingleLock lock(m_critSection); bool bReturn(CPVRChannelGroup::Renumber()); m_iHiddenChannels = 0; for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++) { if (m_members.at(iChannelPtr).channel->IsHidden()) m_iHiddenChannels++; else m_members.at(iChannelPtr).channel->UpdatePath(this, iChannelPtr); } return bReturn; } bool CPVRChannelGroupInternal::IsGroupMember(const CPVRChannel &channel) const { return !channel.IsHidden(); } bool CPVRChannelGroupInternal::UpdateChannel(const CPVRChannel &channel) { CSingleLock lock(m_critSection); CPVRChannelPtr updateChannel = GetByUniqueID(channel.UniqueID()); if (!updateChannel) { updateChannel = CPVRChannelPtr(new CPVRChannel(channel.IsRadio())); PVRChannelGroupMember newMember = { updateChannel, 0 }; m_members.push_back(newMember); updateChannel->SetUniqueID(channel.UniqueID()); } updateChannel->UpdateFromClient(channel); return updateChannel->Persist(!m_bLoaded); } bool CPVRChannelGroupInternal::AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers) { bool bReturn(false); SetPreventSortAndRenumber(); CSingleLock lock(m_critSection); // BadJin 13/11/2015 ///////////////////////////////////////// // HPrasad - ECO - START // 2016.01.26 // Bug :- iUniqueId and chName were statically allocated arrays of size 150. There can be segmentation faults for // more that 150 channels loading.So PVR is going to halt // Fix :- They are Dynamically allocated according to channel group size unsigned int iChanGroupSize = channels.m_members.size(); unsigned int *iUniqueId = new unsigned int[iChanGroupSize]; CStdString *chName = new CStdString[iChanGroupSize]; // HPrasad - ECO - FINISH for (unsigned int iChannelPtr = 0; iChannelPtr < iChanGroupSize; iChannelPtr++){ PVRChannelGroupMember member = channels.m_members.at(iChannelPtr); if (!member.channel) continue; chName[iChannelPtr] = member.channel->ChannelName().c_str(); iUniqueId[iChannelPtr] = member.channel->UniqueID(); } ////////////////////////////////////////////////////////////// /* go through the channel list and check for updated or new channels */ for (unsigned int iChannelPtr = 0; iChannelPtr < iChanGroupSize; iChannelPtr++) { PVRChannelGroupMember member = channels.m_members.at(iChannelPtr); if (!member.channel) continue; /* check whether this channel is present in this container */ CPVRChannelPtr existingChannel = GetByClient(member.channel->UniqueID(), member.channel->ClientID()); if (existingChannel) { /* if it's present, update the current tag */ if (existingChannel->UpdateFromClient(*member.channel)) { bReturn = true; CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - updated %s channel '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", member.channel->ChannelName().c_str()); } } else { // BadJin 13/11/2015 ///////////////////////////////////////// bool bSkipFlag = false; for (int i=0 ; i < iChannelPtr ; i++){ if (member.channel->ChannelName().c_str() == chName[i]){ if (member.channel->m_iUniqueId != iUniqueId[i]){ bSkipFlag = true; } } } if (!bSkipFlag){ UpdateFromClient(*member.channel, bUseBackendChannelNumbers ? member.channel->ClientChannelNumber() : 0); bReturn = true; CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - added %s channel '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", member.channel->ChannelName().c_str()); } else{ CLog::Log(LOGINFO,"BJ(1) : skipped channel '%s'", member.channel->ChannelName().c_str()); } ////////////////////////////////////////////////////////////// } } SetPreventSortAndRenumber(false); if (m_bChanged) SortAndRenumber(); // HPrasad - ECO - START // 2016.01.26 delete[] iUniqueId; delete[] chName; // HPrasad - ECO - FINISH return bReturn; } bool CPVRChannelGroupInternal::UpdateGroupEntries(const CPVRChannelGroup &channels) { bool bReturn(false); if (CPVRChannelGroup::UpdateGroupEntries(channels)) { /* try to find channel icons */ if (g_advancedSettings.m_bPVRChannelIconsAutoScan) SearchAndSetChannelIcons(); g_PVRTimers->UpdateChannels(); Persist(); bReturn = true; } return bReturn; } void CPVRChannelGroupInternal::CreateChannelEpg(CPVRChannelPtr channel, bool bForce /* = false */) { if (!channel) return; CSingleLock lock(channel->m_critSection); if (!channel->m_bEPGCreated || bForce) { CEpg *epg = g_EpgContainer.CreateChannelEpg(channel); if (epg) { channel->m_bEPGCreated = true; if (epg->EpgID() != channel->m_iEpgId) { channel->m_iEpgId = epg->EpgID(); channel->m_bChanged = true; } } } } bool CPVRChannelGroupInternal::CreateChannelEpgs(bool bForce /* = false */) { if (!g_EpgContainer.IsStarted()) return false; { CSingleLock lock(m_critSection); for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++) CreateChannelEpg(m_members.at(iChannelPtr).channel); } if (HasChangedChannels()) { g_EpgContainer.PersistTables(); return Persist(); } return true; } void CPVRChannelGroupInternal::Notify(const Observable &obs, const ObservableMessage msg) { if (msg == ObservableMessageManagerStateChanged) { g_PVRManager.TriggerEpgsCreate(); } }
[ "peng.wei8899@gmail.com" ]
peng.wei8899@gmail.com
87a339c2edb699ac2cd0f0f1c4c8fa2b62cbd06d
07834560a94f1617df35b057a26c3976e0e4f519
/VC2013_AES_Security/AES_Security/Function/FileManager.h
d7121e65b036b0d1e9de7ec107b987d382ee4a46
[]
no_license
liqing90/VC_Test_S_3
8d4a07988663251e2cb2b09e49414c82743b694f
75e6cfbfc54129b4e43bab677bba7f27f217ab59
refs/heads/master
2021-03-25T09:50:26.819830
2018-02-28T08:24:34
2018-02-28T08:24:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,313
h
// FileManager.h: interface for the CFileManager class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_FILEMANAGER_H__A9E277BD_2182_44DA_B68A_EE1CBAB6E67F__INCLUDED_) #define AFX_FILEMANAGER_H__A9E277BD_2182_44DA_B68A_EE1CBAB6E67F__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 //-------------------------------------------------------------------------------------------------- #include <vector> #include <string> //-------------------------------------------------------------------------------------------------- namespace std { #if defined (_UNICODE) || defined(UNICODE) typedef wstring tstring; #else typedef string tstring; #endif } using namespace std; //-------------------------------------------------------------------------------------------------- class CFileManager { public: CFileManager(); virtual ~CFileManager(); // ini int ReadIniFile(IN TCHAR *pszIniFileName, IN TCHAR *pszSectionName, IN TCHAR *pszKeyName, OUT TCHAR *pszBuffer, IN DWORD dwBufferLen); int WriteIniFile(IN TCHAR *pszIniFileName, IN TCHAR *pszSectionName, IN TCHAR *pszKeyName, IN TCHAR *pszBuffer); // file int GetCurrentExeFilePath(OUT TCHAR *pszBuffer, IN DWORD dwBufferLen); int GetFileSize(IN TCHAR *pszFullFileName, OUT DWORD64 *pdw64FileSize); // output pdw64FileSize unit: Bytes int RenameFileName(IN TCHAR *pszOldName, IN TCHAR *pszNewFileName); void ParseFullFileName(IN TCHAR *pszFullFileName, OUT TCHAR *pszDrive, OUT TCHAR *pszDir, OUT TCHAR *pszFileName, OUT TCHAR *pszExtension); BOOL IsFileExist(IN TCHAR *pszPath); BOOL IsFolderExist(IN TCHAR *pszPath); int DumpBinaryDataToFile(IN TCHAR *szTargetFile, IN void *pDataBuffer, IN DWORD dwDataSize); int GetFileLastWriteTime(IN TCHAR *pszFileFullPathName, OUT SYSTEMTIME *pSystemTime); // folder int BuildDirectory(IN TCHAR *ADir); int DeleteDirectory(IN TCHAR *pszDirPath); int FindFileFromFolder(IN TCHAR *pszFolder, IN TCHAR *pszExtNameFilter, OUT std::vector<tstring> *pFullFileName); // string int UnicodeStrToAnsiStr(IN WCHAR *pszUnicode, OUT char *pszAnsi); int AnsiStrToUnicodeStr(IN char *pszAnsi, OUT WCHAR *pszUnicode); }; #endif // !defined(AFX_FILEMANAGER_H__A9E277BD_2182_44DA_B68A_EE1CBAB6E67F__INCLUDED_)
[ "rex721101@google.com.tw" ]
rex721101@google.com.tw
d0aca4879164840117fda1f44f02a67d20f97900
fa683fdb9a812992e2069e1ce85270746f3575fc
/src/ui/sprite.cpp
2080d21dea3905af95038bdec5d5f02b58594d03
[ "Apache-2.0" ]
permissive
kevinfyc/KGE
da2021682eec72188db4b1de24f019e915867143
3b3d805317765c1c67f7584f8c1eee6e7c94c3a3
refs/heads/master
2021-07-14T11:31:06.296883
2017-10-18T03:08:13
2017-10-18T03:08:13
104,315,430
1
0
null
null
null
null
UTF-8
C++
false
false
391
cpp
// // sprite.cpp // libkge // // Created by kevin on 17-10-10. // // // #include "sprite.h" namespace kge { Ref<Sprite> Sprite::Create(const Rect& rect, const Vector4& border) { Ref<Sprite> sprite; sprite = Ref<Sprite>(new Sprite()); sprite->_rect = rect; sprite->_border = border; return sprite; } Sprite::Sprite(): _rect(0, 0, 1, 1), _border(0, 0, 0, 0) { } }
[ "kevin" ]
kevin
67332bc032c936ceec98e18ad0fd3fbfb27f9caa
6b3e19170e2bfe62a57656a5836bd64b946366bf
/W6/G1/D2/358.cpp
02d5907a6de6b62f06390d153035b928fc8f1135
[]
no_license
Beisenbek/PP1_2018R
299da157ec370bd4d4ff7fff3f1722505a95dee4
2f5d0a94dc4193ca648655168d4decbfacd6f92e
refs/heads/master
2021-05-12T01:11:11.694365
2018-04-16T13:53:38
2018-04-16T13:53:38
117,552,376
0
0
null
null
null
null
UTF-8
C++
false
false
641
cpp
#include <iostream> #include <stdio.h> #include <cmath> #include <algorithm> #include <ctype.h> using namespace std; int main(){ freopen("input.txt","r",stdin); int n,m; cin >> n >> m; int a[n][m]; int s[n]; for(int i = 0; i < n; ++i){ s[i] = 0; for(int j = 0; j < m; ++j){ cin >> a[i][j]; s[i] = s[i] + a[i][j]; } } int bestI = 0; int bestJ = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < m; ++j){ if(a[bestI][bestJ] < a[i][j]){ bestI = i; bestJ = j; }else if(a[bestI][bestJ] == a[i][j] && s[bestI] < s[i]){ bestI = i; bestJ = j; } } } cout << bestI << endl; return 0; }
[ "beysenbek@gmail.com" ]
beysenbek@gmail.com
cd39232ecebf8397db538ec966e604e4a475de04
c32ee8ade268240a8064e9b8efdbebfbaa46ddfa
/Libraries/m2sdk/C_Traffic_Subdiv_Evaluator.h
03efa6712782e19ed5954071bd7c159b2cef376c
[]
no_license
hopk1nz/maf2mp
6f65bd4f8114fdeb42f9407a4d158ad97f8d1789
814cab57dc713d9ff791dfb2a2abeb6af0e2f5a8
refs/heads/master
2021-03-12T23:56:24.336057
2015-08-22T13:53:10
2015-08-22T13:53:10
41,209,355
19
21
null
2015-08-31T05:28:13
2015-08-22T13:56:04
C++
UTF-8
C++
false
false
230
h
// auto-generated file (rttidump-exporter by h0pk1nz) #pragma once #include <I_TrafficEvaluator.h> /** C_Traffic_Subdiv_Evaluator (VTable=0xFFFFFFFF) */ class C_Traffic_Subdiv_Evaluator : public I_TrafficEvaluator { public: };
[ "hopk1nz@gmail.com" ]
hopk1nz@gmail.com
433e563e3cd11109cb8478ab8bd2ea5ac8e225fe
89b7ffc5c56331a189501cda035648e2b2016d74
/WebLayoutCoreOnly/Source/WebCore/RenderTableRow.h
99ec28cb7e860b456892a3b352eda5f863ac7d12
[ "MIT" ]
permissive
jjbheda/trylearn
60343fdb74dd597f0a49286de4ec1f0f57a06faa
74dd5c6c977f8d867d6aa360b84bc98cb82f480c
refs/heads/master
2020-03-22T17:49:17.391764
2018-03-30T16:25:32
2018-03-30T16:25:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,398
h
/* * Copyright (C) 1997 Martin Jones (mjones@kde.org) * (C) 1997 Torben Weis (weis@kde.org) * (C) 1998 Waldo Bastian (bastian@kde.org) * (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #pragma once #include "RenderTableSection.h" namespace WebCore { static const unsigned unsetRowIndex = 0x7FFFFFFF; static const unsigned maxRowIndex = 0x7FFFFFFE; // 2,147,483,646 class RenderTableRow final : public RenderBox { WTF_MAKE_ISO_ALLOCATED(RenderTableRow); public: RenderTableRow(RenderStyle&&); RenderTableRow* nextRow() const; RenderTableRow* previousRow() const; RenderTableCell* firstCell() const; RenderTableCell* lastCell() const; RenderTable* table() const; void paintOutlineForRowIfNeeded(PaintInfo&, const LayoutPoint&); static RenderPtr<RenderTableRow> createAnonymousWithParentRenderer(const RenderTableSection&); RenderPtr<RenderBox> createAnonymousBoxWithSameTypeAs(const RenderBox&) const override; void setRowIndex(unsigned); bool rowIndexWasSet() const { return m_rowIndex != unsetRowIndex; } unsigned rowIndex() const; const BorderValue& borderAdjoiningTableStart() const; const BorderValue& borderAdjoiningTableEnd() const; const BorderValue& borderAdjoiningStartCell(const RenderTableCell&) const; const BorderValue& borderAdjoiningEndCell(const RenderTableCell&) const; void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override; bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; void collapseAndDestroyAnonymousSiblingRows(); private: static RenderPtr<RenderTableRow> createTableRowWithStyle(const RenderStyle&); const char* renderName() const override { return (isAnonymous() || isPseudoElement()) ? "RenderTableRow (anonymous)" : "RenderTableRow"; } bool isTableRow() const override { return true; } bool canHaveChildren() const override { return true; } void willBeRemovedFromTree() override; void layout() override; LayoutRect clippedOverflowRectForRepaint(const RenderElement* repaintContainer) const override; bool requiresLayer() const override { return false; //hasOverflowClip() || hasTransformRelatedProperty() || hasHiddenBackface() || hasClipPath() || createsGroup() || isStickilyPositioned(); } //void paint(PaintInfo&, const LayoutPoint&) override; void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; RenderTableSection* section() const { return downcast<RenderTableSection>(parent()); } void firstChild() const = delete; void lastChild() const = delete; void nextSibling() const = delete; void previousSibling() const = delete; unsigned m_rowIndex : 31; }; inline void RenderTableRow::setRowIndex(unsigned rowIndex) { if (UNLIKELY(rowIndex > maxRowIndex)) CRASH(); m_rowIndex = rowIndex; } inline unsigned RenderTableRow::rowIndex() const { ASSERT(rowIndexWasSet()); return m_rowIndex; } inline const BorderValue& RenderTableRow::borderAdjoiningTableStart() const { if (isDirectionSame(section(), table())) return style().borderStart(); return style().borderEnd(); } inline const BorderValue& RenderTableRow::borderAdjoiningTableEnd() const { if (isDirectionSame(section(), table())) return style().borderEnd(); return style().borderStart(); } inline RenderTable* RenderTableRow::table() const { RenderTableSection* section = this->section(); if (!section) return nullptr; return downcast<RenderTable>(section->parent()); } inline RenderTableRow* RenderTableRow::nextRow() const { return downcast<RenderTableRow>(RenderBox::nextSibling()); } inline RenderTableRow* RenderTableRow::previousRow() const { return downcast<RenderTableRow>(RenderBox::previousSibling()); } inline RenderTableRow* RenderTableSection::firstRow() const { return downcast<RenderTableRow>(RenderBox::firstChild()); } inline RenderTableRow* RenderTableSection::lastRow() const { return downcast<RenderTableRow>(RenderBox::lastChild()); } inline RenderPtr<RenderBox> RenderTableRow::createAnonymousBoxWithSameTypeAs(const RenderBox& renderer) const { return RenderTableRow::createTableRowWithStyle(renderer.style()); } } // namespace WebCore SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableRow, isTableRow())
[ "jianbai.gbj@alibaba-inc.com" ]
jianbai.gbj@alibaba-inc.com
943bacdce81d365058783fed35770c2759f7edfc
189041dd0815ef75a49080dc49606edaf9cc33c9
/17.电话号码的字母组合.cpp
2f760cf1287740b7163591c3d7b264408bcb8fde
[]
no_license
nercoeus/leetcode_practice
1b3e9e3165fb7af9a69da695de823c423e4b85b0
5181467cc80b417137ff32133460ad58f8fad365
refs/heads/master
2022-12-26T18:45:31.700552
2021-05-19T15:54:07
2021-05-19T15:54:07
152,102,663
1
0
null
null
null
null
UTF-8
C++
false
false
975
cpp
/* * @lc app=leetcode.cn id=17 lang=cpp * * [17] 电话号码的字母组合 */ // @lc code=start #include <vector> #include <string> using namespace std; class Solution { public: vector<string> letterCombinations(string digits) { vector<string> res; if (digits.empty()) return res; vector<string> letter({"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"}); string path = ""; DFS(digits, 0, path, res, letter); return res; } void DFS(string digits, int pos, string &path, vector<string> &res, vector<string> &letter) { if (pos == digits.size()) { res.push_back(path); return; } for (auto c : letter[digits[pos] - '0']) { path.push_back(c); DFS(digits, pos + 1, path, res, letter); path.pop_back(); } } }; // @lc code=end
[ "18252116593@163.com" ]
18252116593@163.com
8b22858c0fb6b21e108253672b59baf2c4fdc6cd
50bdaa2e71aae37240c61c930decbfe9d1e504b8
/harp-daal-app/daal-src/include/algorithms/neural_networks/layers/loss/softmax_cross_layer_types.h
f034df3012b3a8b227a4b370b77cd8f23f38fc61
[ "Apache-2.0" ]
permissive
prawalgangwar/harp
010b1f669ee54941365ba1204be4e1484c15f108
3c3a3bf2d519f76ccf8ae17d8b3681e0a93048b7
refs/heads/master
2020-09-13T19:57:54.274328
2017-06-20T00:03:57
2017-06-20T00:03:57
94,464,682
0
0
null
2017-06-15T17:49:16
2017-06-15T17:49:16
null
UTF-8
C++
false
false
3,460
h
/* file: softmax_cross_layer_types.h */ /******************************************************************************* * Copyright 2014-2016 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ /* //++ // Implementation of the softmax cross-entropy layer types. //-- */ #ifndef __NEURAL_NENTWORK_LOSS_SOFTMAX_CROSS_LAYER_TYPES_H__ #define __NEURAL_NENTWORK_LOSS_SOFTMAX_CROSS_LAYER_TYPES_H__ #include "algorithms/algorithm.h" #include "data_management/data/tensor.h" #include "data_management/data/homogen_tensor.h" #include "services/daal_defines.h" #include "algorithms/neural_networks/layers/layer_types.h" namespace daal { namespace algorithms { namespace neural_networks { namespace layers { namespace loss { /** * @defgroup softmax_cross Softmax Cross-entropy Layer * \copydoc daal::algorithms::neural_networks::layers::loss::softmax_cross * @ingroup loss * @{ */ namespace softmax_cross { /** * <a name="DAAL-ENUM-ALGORITHMS__NEURAL_NETWORKS__LAYERS__LOSS__SOFTMAX_CROSS__METHOD"></a> * \brief Computation methods for the softmax cross-entropy layer */ enum Method { defaultDense = 0, /*!< Default: performance-oriented method */ }; /** * <a name="DAAL-ENUM-ALGORITHMS__NEURAL_NETWORKS__LAYERS__LOSS__SOFTMAX_CROSS__LAYERDATAID"></a> * \brief Identifiers of input objects for the backward softmax cross-entropy layer and results for the forward softmax cross-entropy layer */ enum LayerDataId { auxProbabilities = 2, /*!< Tensor that stores probabilities for the forward softmax cross-entropy layer */ auxGroundTruth = 3, /*!< Tensor that stores ground truth data for the forward softmax cross-entropy layer */ }; /** * \brief Contains version 1.0 of Intel(R) Data Analytics Acceleration Library (Intel(R) DAAL) interface. */ namespace interface1 { /** * <a name="DAAL-CLASS-ALGORITHMS__NEURAL_NETWORKS__LAYERS__LOSS__SOFTMAX_CROSS__PARAMETER"></a> * \brief Parameters for the softmax cross-entropy layer * * \snippet neural_networks/layers/loss/softmax_cross_layer_types.h Parameter source code */ /* [Parameter source code] */ class Parameter: public layers::Parameter { public: /** * Constructs parameters of the softmax cross-entropy layer * \param[in] accuracyThreshold_ Value needed to avoid degenerate cases in logarithm computing */ Parameter(const double accuracyThreshold_ = 1.0e-04) : accuracyThreshold(accuracyThreshold_) {}; double accuracyThreshold; /*!< Value needed to avoid degenerate cases in logarithm computing */ /** * Checks the correctness of the parameter */ virtual void check() const {} }; /* [Parameter source code] */ } // namespace interface1 using interface1::Parameter; } // namespace softmax_cross /** @} */ } // namespace loss } // namespace layers } // namespace neural_networks } // namespace algorithm } // namespace daal #endif
[ "lc37@156-56-102-164.dhcp-bl.indiana.edu" ]
lc37@156-56-102-164.dhcp-bl.indiana.edu
bc60a68efd2e2be024ca355f53cf0800fdba24eb
9fa292d97ceb374068d355bd41097d0407d68bd3
/include/rspf/base/rspfKeywordlist.h
a29bfe9f5c159a038694345590bdbcf9d995566e
[]
no_license
mfkiwl/rspf_v2.0
4d90153b92cc416663c798e05f87e348ad8792ef
f22d2707b775a4776fc8359a255f39c26ecc96a3
refs/heads/master
2021-05-27T04:36:34.132569
2013-07-16T04:04:12
2013-07-16T04:04:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,740
h
//******************************************************************* // // License: See top level LICENSE.txt file. // // Author: Ken Melero // // Description: This class provides capabilities for keywordlists. // //******************************************************************** // $Id: rspfKeywordlist.h 21527 2012-08-26 16:50:49Z dburken $ #ifndef rspfKeywordlist_HEADER #define rspfKeywordlist_HEADER 1 #include <rspf/base/rspfErrorStatusInterface.h> #include <rspf/base/rspfReferenced.h> #include <rspf/base/rspfConstants.h> #include <rspf/base/rspfErrorCodes.h> #include <rspf/base/rspfString.h> #include <iosfwd> #include <map> #include <vector> #include <algorithm> static const char DEFAULT_DELIMITER = ':'; class rspfFilename; class RSPF_DLL rspfKeywordlist : public rspfErrorStatusInterface, public rspfReferenced { public: typedef std::map<std::string, std::string> KeywordMap; rspfKeywordlist(const rspfKeywordlist& src); rspfKeywordlist(char delimiter = DEFAULT_DELIMITER, bool expandEnvVars = false); rspfKeywordlist(const char* file, char delimiter = DEFAULT_DELIMITER, bool ignoreBinaryChars = false, bool expandEnvVars = false ); rspfKeywordlist(const rspfFilename& fileName, char delimiter = DEFAULT_DELIMITER, bool ignoreBinaryChars = false, bool expandEnvVars = false); ~rspfKeywordlist(); static const std::string NULL_KW; /*! * Reads file and adds keywords to the KeywordMap. * Returns true if file was parsed, false on error. */ bool addFile(const char* file); /*! * Reads file and adds keywords to the KeywordMap. * Returns true if file was parsed, false on error. */ bool addFile(const rspfFilename& file); /*! * Method to change default delimiter. Handy when parsing * files similar to a rspfKeywordlist. (DEFAULT = ':') */ void change_delimiter(char del); rspfString delimiter_str() const; /*! * If set to true, then strings found having the format * "$(env_var_name)" are expanded in place. */ void setExpandEnvVarsFlag( bool flag ); /*! * Returns the flag that determines whether or not * environment variables are expanded. */ bool getExpandEnvVarsFlag( void ) const; void add(const char* prefix, const rspfKeywordlist& kwl, bool overwrite=true); /** * This is a generic find method that takes a comparator type and iterates through * the map executing the overloaded operator (). * Typical code example format <pre> typedef std::unary_function<std::pair<rspfString, rspfString>, bool> KwlCompareFunctionType; class KwlKeyCaseInsensitiveEquals : public KwlCompareFunctionType { public: KwlKeyCaseInsensitiveEquals(const rspfString& key):m_key(key){} virtual bool operator()(const KwlComparePairType& rhs)const { return (m_key == rhs.first.downcase()); } rspfString m_key; }; // now for use case example: kwl.findValue(value, KwlKeyCaseInsensitiveEquals("foo")); </pre> This example shows how to supplly your own comparator and do a case insensitive search for the key foo and the value is set to the variable value. * */ template<class CompareType> bool findValue(rspfString& value, const CompareType& compare)const { KeywordMap::const_iterator iter = std::find_if(m_map.begin(), m_map.end(), compare); bool result = (iter != m_map.end()); if(result) value = iter->second; return result; } std::string& operator[](const std::string& key) { return m_map[key]; } std::string operator[](const std::string& key)const { rspfString result = find(key.c_str()); return result.c_str(); } // Methods to add keywords to list. void addPair(const std::string& key, const std::string& value, bool overwrite = true); void addPair(const std::string& prefix, const std::string& key, const std::string& value, bool overwrite = true); /*! * Allows you to extract out a sub keywordlist from another * you can also collapse the hieracrchy by setting * strip prefix to true. */ void add(const rspfKeywordlist& kwl, const char* prefix=0, bool stripPrefix=true); void add(const char* key, const char* value, bool overwrite = true); void add(const char* prefix, const char* key, const char* value, bool overwrite = true); void add(const char* key, char value, bool overwrite = true); void add(const char* prefix, const char* key, char value, bool overwrite = true); void add(const char* key, rspf_int16 value, bool overwrite = true); void add(const char* prefix, const char* key, rspf_int16 value, bool overwrite = true); void add(const char* key, rspf_uint16 value, bool overwrite = true); void add(const char* prefix, const char* key, rspf_uint16 value, bool overwrite = true); void add(const char* key, rspf_int32 value, bool overwrite = true); void add(const char* prefix, const char* key, rspf_int32 value, bool overwrite = true); void add(const char* key, rspf_uint32 value, bool overwrite = true); void add(const char* prefix, const char* key, rspf_uint32 value, bool overwrite = true); void add(const char* key, rspf_int64 value, bool overwrite = true); void add(const char* prefix, const char* key, rspf_int64 value, bool overwrite = true); void add(const char* key, rspf_uint64 value, bool overwrite = true); void add(const char* prefix, const char* key, rspf_uint64 value, bool overwrite = true); /** * @param key Key for key-value pair. * * @param value Value to pair with key. Note this will be stored as a * string. * * @param precision Decimal point precision of the output. (default = 8) * * @param trimZeroFlag If true trailing '0's and any trailing '.' will * be trimmed from the converted string. (default = false) * * @param scientific If true output will be in scientific notation else * fixed is used. (default = false) */ void add(const char* key, rspf_float32 value, bool overwrite = true, int precision = 8); /** * @param key Key for key-value pair. * * @param value Value to pair with key. Note this will be stored as a * string. * * @param precision Decimal point precision of the output. (default = 8) * * @param trimZeroFlag If true trailing '0's and any trailing '.' will * be trimmed from the converted string. (default = false) * * @param scientific If true output will be in scientific notation else * fixed is used. (default = false) */ void add(const char* prefix, const char* key, rspf_float32 value, bool overwrite = true, int precision = 8); /** * @param key Key for key-value pair. * * @param value Value to pair with key. Note this will be stored as a * string. * * @param precision Decimal point precision of the output. (default = 15) * * @param trimZeroFlag If true trailing '0's and any trailing '.' will * be trimmed from the converted string. (default = false) * * @param scientific If true output will be in scientific notation else * fixed is used. (default = false) */ void add(const char* key, rspf_float64 value, bool overwrite = true, int precision = 15); /** * @param key Key for key-value pair. * * @param value Value to pair with key. Note this will be stored as a * string. * * @param precision Decimal point precision of the output. (default = 15) * * @param trimZeroFlag If true trailing '0's and any trailing '.' will * be trimmed from the converted string. (default = false) * * @param scientific If true output will be in scientific notation else * fixed is used. (default = false) */ void add(const char* prefix, const char* key, rspf_float64 value, bool overwrite = true, int precision = 15); /** * @brief Checks for key in map. * * Note that "find" and findKey will alway return an empty string even if * the key in not in the map. * * @return true if key is in map even if value is empty; false, if not. */ bool hasKey( const std::string& key ) const; /** * @brief Find methods that take std::string(s). * Searches the map for key(/prefix) and returns the resulting value * or an empty string if the key was not found. * @param key e.g. "number_line" * @param prefix e..g "image0." * @return Reference to string. This will be emptry if not found or * if value is empty. */ const std::string& findKey(const std::string& key) const; const std::string& findKey(const std::string& prefix, const std::string& key) const; const char* find(const char* key) const; const char* find(const char* prefix, const char* key) const; void remove(const char * key); void remove(const char* prefix, const char * key); /*! * Searches the map for the number of keys containing the string. */ rspf_uint32 numberOf(const char* str) const; /*! * Searches the map for the number of keys containing the prefix+key. * * Given the keyword list contains: * * source.type1: foo * source.type2: you * * This: * * int number_of_sources = numberOf("source", "type"); * * number_of_sources equals 2 */ rspf_uint32 numberOf(const char* prefix, const char* key) const; /** * Methods to dump the rspfKeywordlist to a file on disk. * * @param file Name of output file. * @param comment Optional string that will be written to line 1 * as a C++-style comment. A "//" is prepended to the input string. * * @return true on success, false on error. */ virtual bool write(const char* file, const char* comment = 0) const; virtual rspfString toString()const; virtual void toString(rspfString& result)const; virtual void writeToStream(std::ostream &out)const; virtual std::ostream& print(std::ostream& os) const; RSPFDLLEXPORT friend std::ostream& operator<<(std::ostream& os, const rspfKeywordlist& kwl); bool operator ==(rspfKeywordlist& kwl)const; /*! * Clear all contents out of the rspfKeywordlist. */ void clear(); /*! * Add contents of another keyword list to this one. * * @param src the keyword list to copy items from. * @param overwrite true if keys existing in this and src should have * their value overwritten by the src value, otherwise false to preserve * the original value. Defaults to true. */ void addList( const rspfKeywordlist &src, bool overwrite = true ); /** deprecated method */ virtual bool parseStream(std::istream& is, bool ignoreBinaryChars); virtual bool parseStream(std::istream& is); virtual bool parseString(const std::string& inString); /*! * Will return a list of keys that contain the string passed in. * Later we will need to allow a user to specify regular expresion * searches. */ std::vector<rspfString> findAllKeysThatContains( const rspfString &searchString)const; std::vector<rspfString> findAllKeysThatMatch( const rspfString &regularExpression)const; void extractKeysThatMatch(rspfKeywordlist& kwl, const rspfString &regularExpression)const; void removeKeysThatMatch(const rspfString &regularExpression); /*! * Will return only the portion of the key that * matches the regular expression. * * example: * * source1.source1.a: * source1.source2.a: * source1.source3.a: * source1.source4.a: * source1.source10.a: * * kwl.getSubstringKeyList("source1.source[0-9]*\\."); * * will return: * * source1.source1. * source1.source2. * source1.source3. * source1.source4. * source1.source10. * */ std::vector<rspfString> getSubstringKeyList(const rspfString& regularExpression)const; void getSubstringKeyList(std::vector<rspfString>& result, const rspfString& regularExpression)const; rspf_uint32 getNumberOfSubstringKeys( const rspfString& regularExpression)const; void addPrefixToAll(const rspfString& prefix); void addPrefixToKeysThatMatch(const rspfString& prefix, const rspfString& regularExpression); void stripPrefixFromAll(const rspfString& regularExpression); /*! * Returns the number of elements. */ rspf_uint32 getSize()const; const rspfKeywordlist::KeywordMap& getMap()const; rspfKeywordlist::KeywordMap& getMap(); rspfKeywordlist& downcaseKeywords(); rspfKeywordlist& upcaseKeywords(); rspfKeywordlist& trimAllValues(const rspfString& valueToTrim= rspfString(" \t\n\r")); rspfKeywordlist trimAllValues(const rspfString& valueToTrim= rspfString(" \t\n\r"))const; //! [OLK, Aug/2008] //! Sets the boolean <rtn_val> depending on value associated with keyword for values = //! (yes|no|true|false|1|0). Returns TRUE if keyword found, otherwise false. Also returns false //! if none of the above permitted values are specified (rtn_val left unchanged in this case). bool getBoolKeywordValue(bool& rtn_val, const char* keyword, const char* prefix=0) const; protected: enum KeywordlistParseState { KeywordlistParseState_OK = 0, KeywordlistParseState_FAIL = 1, // just used to say this set of token has failed the rules KeywordlistParseState_BAD_STREAM = 2, // Means an error occured that is a mal formed stream for Keywordlist }; /*! * Method to parse files to initialize the list. Method will error on * binary characters if "ignoreBinaryChars = false". This is used by * ImageHandler factories that can be passed a binary file inadvertently * by a user. The "ignoreBinaryChars" flag should be set to true if * a text file contains mixed ascii/binary values. * Returns true if file was parsed, false on error. */ bool parseFile(const rspfFilename& file, bool ignoreBinaryChars = false); bool isValidKeywordlistCharacter(rspf_uint8 c)const; void skipWhitespace(std::istream& in)const; KeywordlistParseState readComments(rspfString& sequence, std::istream& in)const; KeywordlistParseState readKey(rspfString& sequence, std::istream& in)const; KeywordlistParseState readValue(rspfString& sequence, std::istream& in)const; KeywordlistParseState readKeyAndValuePair(rspfString& key, rspfString& value, std::istream& in)const; // Method to see if keyword exists in list. KeywordMap::iterator getMapEntry(const std::string& key); KeywordMap::iterator getMapEntry(const rspfString& key); KeywordMap::iterator getMapEntry(const char* key); KeywordMap m_map; char m_delimiter; bool m_preserveKeyValues; // enables preserving empty field values, multi lines, ... etc bool m_expandEnvVars; }; #endif /* #ifndef rspfKeywordlist_HEADER */
[ "loongfee@gmail.com" ]
loongfee@gmail.com
a5d42e0eae1a2b6beca313554316239fce002474
96feb31b215645ec438c09588e1c9dc5691f283b
/plugins/dali-script-v8/src/rendering/shader-wrapper.cpp
f3aff6cb89cb1600a2623cb4c46468f26592d031
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
nui-dali/dali-toolkit
28a99e6f117023e95920ee8eda35b6346485e074
b514a4671789bee2f03b0177393b9a21f62ac2c3
refs/heads/master
2020-05-26T23:44:18.106253
2019-05-17T10:06:27
2019-05-17T10:06:27
188,398,539
0
0
null
null
null
null
UTF-8
C++
false
false
3,394
cpp
/* * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * 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. * */ // CLASS HEADER #include "shader-wrapper.h" // INTERNAL INCLUDES #include <v8-utils.h> #include <rendering/shader-api.h> #include <shared/api-function.h> #include <shared/object-template-helper.h> #include <dali-wrapper.h> namespace Dali { namespace V8Plugin { v8::Persistent<v8::ObjectTemplate> ShaderWrapper::mShaderTemplate; ShaderWrapper::ShaderWrapper( const Dali::Shader& shader, GarbageCollectorInterface& gc ) : HandleWrapper( BaseWrappedObject::SHADER , shader, gc ) { mShader = shader; } v8::Handle<v8::Object> ShaderWrapper::WrapShader(v8::Isolate* isolate, const Dali::Shader& shader ) { v8::EscapableHandleScope handleScope( isolate ); v8::Local<v8::ObjectTemplate> objectTemplate; objectTemplate = GetShaderTemplate( isolate); // create an instance of the template v8::Local<v8::Object> localObject = objectTemplate->NewInstance(); // create the Shader wrapper ShaderWrapper* pointer = new ShaderWrapper( shader, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() ); // assign the JavaScript object to the wrapper. pointer->SetJavascriptObject( isolate, localObject ); return handleScope.Escape( localObject ); } v8::Local<v8::ObjectTemplate> ShaderWrapper::GetShaderTemplate( v8::Isolate* isolate) { v8::EscapableHandleScope handleScope( isolate ); v8::Local<v8::ObjectTemplate> objectTemplate; if( mShaderTemplate.IsEmpty() ) { objectTemplate = MakeShaderTemplate( isolate ); mShaderTemplate.Reset( isolate, objectTemplate ); } else { // get the object template objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, mShaderTemplate ); } return handleScope.Escape( objectTemplate ); } v8::Handle<v8::ObjectTemplate> ShaderWrapper::MakeShaderTemplate( v8::Isolate* isolate ) { v8::EscapableHandleScope handleScope( isolate ); v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New(); // property handle intercepts property getters and setters and signals HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate ); objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT ); return handleScope.Escape( objTemplate ); } void ShaderWrapper::NewShader( const v8::FunctionCallbackInfo< v8::Value >& args) { v8::Isolate* isolate = args.GetIsolate(); v8::HandleScope handleScope( isolate); if(!args.IsConstructCall()) { DALI_SCRIPT_EXCEPTION( isolate, "Shader constructor called without 'new'"); return; } Dali::Shader shader = ShaderApi::New( isolate, args ); if(shader) { v8::Local<v8::Object> localObject = WrapShader( isolate, shader ); args.GetReturnValue().Set( localObject ); } } Shader ShaderWrapper::GetShader() { return mShader; } } // namespace V8Plugin } // namespace Dali
[ "r.huang@samsung.com" ]
r.huang@samsung.com
fecc04712635d9a33293026ccbdb4cbe918a984a
ac1c9fbc1f1019efb19d0a8f3a088e8889f1e83c
/out/release/gen/content/common/field_trial_recorder.mojom.h
213394e05ba5bbbce6e6af16cefacdaa54b34876
[ "BSD-3-Clause" ]
permissive
xueqiya/chromium_src
5d20b4d3a2a0251c063a7fb9952195cda6d29e34
d4aa7a8f0e07cfaa448fcad8c12b29242a615103
refs/heads/main
2022-07-30T03:15:14.818330
2021-01-16T16:47:22
2021-01-16T16:47:22
330,115,551
1
0
null
null
null
null
UTF-8
C++
false
false
4,635
h
// content/common/field_trial_recorder.mojom.h is auto generated by mojom_bindings_generator.py, do not edit // Copyright 2013 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 CONTENT_COMMON_FIELD_TRIAL_RECORDER_MOJOM_H_ #define CONTENT_COMMON_FIELD_TRIAL_RECORDER_MOJOM_H_ #include <stdint.h> #include <limits> #include <type_traits> #include <utility> #include "base/callback.h" #include "base/macros.h" #include "base/optional.h" #include "mojo/public/cpp/bindings/mojo_buildflags.h" #if BUILDFLAG(MOJO_TRACE_ENABLED) #include "base/trace_event/trace_event.h" #endif #include "mojo/public/cpp/bindings/clone_traits.h" #include "mojo/public/cpp/bindings/equals_traits.h" #include "mojo/public/cpp/bindings/lib/serialization.h" #include "mojo/public/cpp/bindings/struct_ptr.h" #include "mojo/public/cpp/bindings/struct_traits.h" #include "mojo/public/cpp/bindings/union_traits.h" #include "content/common/field_trial_recorder.mojom-shared.h" #include "content/common/field_trial_recorder.mojom-forward.h" #include <string> #include <vector> #include "mojo/public/cpp/bindings/associated_interface_ptr.h" #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" #include "mojo/public/cpp/bindings/associated_interface_request.h" #include "mojo/public/cpp/bindings/interface_ptr.h" #include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/lib/control_message_handler.h" #include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h" #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" #include "content/common/content_export.h" namespace content { namespace mojom { class FieldTrialRecorderProxy; template <typename ImplRefTraits> class FieldTrialRecorderStub; class FieldTrialRecorderRequestValidator; class CONTENT_EXPORT FieldTrialRecorder : public FieldTrialRecorderInterfaceBase { public: static const char Name_[]; static constexpr uint32_t Version_ = 0; static constexpr bool PassesAssociatedKinds_ = false; static constexpr bool HasSyncMethods_ = false; using Base_ = FieldTrialRecorderInterfaceBase; using Proxy_ = FieldTrialRecorderProxy; template <typename ImplRefTraits> using Stub_ = FieldTrialRecorderStub<ImplRefTraits>; using RequestValidator_ = FieldTrialRecorderRequestValidator; using ResponseValidator_ = mojo::PassThroughFilter; enum MethodMinVersions : uint32_t { kFieldTrialActivatedMinVersion = 0, }; virtual ~FieldTrialRecorder() {} virtual void FieldTrialActivated(const std::string& trial_name) = 0; }; class CONTENT_EXPORT FieldTrialRecorderProxy : public FieldTrialRecorder { public: using InterfaceType = FieldTrialRecorder; explicit FieldTrialRecorderProxy(mojo::MessageReceiverWithResponder* receiver); void FieldTrialActivated(const std::string& trial_name) final; private: mojo::MessageReceiverWithResponder* receiver_; }; class CONTENT_EXPORT FieldTrialRecorderStubDispatch { public: static bool Accept(FieldTrialRecorder* impl, mojo::Message* message); static bool AcceptWithResponder( FieldTrialRecorder* impl, mojo::Message* message, std::unique_ptr<mojo::MessageReceiverWithStatus> responder); }; template <typename ImplRefTraits = mojo::RawPtrImplRefTraits<FieldTrialRecorder>> class FieldTrialRecorderStub : public mojo::MessageReceiverWithResponderStatus { public: using ImplPointerType = typename ImplRefTraits::PointerType; FieldTrialRecorderStub() {} ~FieldTrialRecorderStub() override {} void set_sink(ImplPointerType sink) { sink_ = std::move(sink); } ImplPointerType& sink() { return sink_; } bool Accept(mojo::Message* message) override { if (ImplRefTraits::IsNull(sink_)) return false; return FieldTrialRecorderStubDispatch::Accept( ImplRefTraits::GetRawPointer(&sink_), message); } bool AcceptWithResponder( mojo::Message* message, std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override { if (ImplRefTraits::IsNull(sink_)) return false; return FieldTrialRecorderStubDispatch::AcceptWithResponder( ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder)); } private: ImplPointerType sink_; }; class CONTENT_EXPORT FieldTrialRecorderRequestValidator : public mojo::MessageReceiver { public: bool Accept(mojo::Message* message) override; }; } // namespace mojom } // namespace content namespace mojo { } // namespace mojo #endif // CONTENT_COMMON_FIELD_TRIAL_RECORDER_MOJOM_H_
[ "xueqi@zjmedia.net" ]
xueqi@zjmedia.net
20adf1e4f02b92c80a99a778db630e8bb7972486
d6d0117815cd0328bfd6e8f433db5cc5b7e1b9fd
/hw4/twiteng.cpp
75bd94a4ef224d0713d9fb44feb1b47c21c31faf
[]
no_license
dshebib/USC-CS104-Data-Structures
ec623a67c9ecfcf6e6904038f19cd2d068e37f51
e1d533f182d8c751688658c332a07c45a7b93d0a
refs/heads/master
2023-03-21T14:30:31.524416
2017-07-17T06:54:57
2017-07-17T06:54:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,282
cpp
#include "twiteng.h" TwitEng::TwitEng() { tweetSize_ = 0; tweets_ = new Tweet[10]; tweetMaxSize_ = 10; } TwitEng::~TwitEng() { delete [] tweets_; for(std::map<std::string, User*>::iterator it = usrs.begin(); it != usrs.end(); it++) { delete it->second; } } void TwitEng::adduser(std::string name) { User* usr = new User(name); usrs.insert(std::make_pair(name, usr)); } void TwitEng::follows(std::string usr, std::string usr2) { usrs.find(usr)->second->addFollowing(usrs.find(usr2)->second); if(usrs.find(usr2) != usrs.end()) usrs.find(usr2)->second->addFollower(usrs.find(usr)->second); } void TwitEng::setallfollowers() { for(std::map<std::string, User*>::iterator it = usrs.begin(); it != usrs.end(); it++) { std::set<User*> following = it->second->following(); for(std::set<User*>::iterator itu = following.begin(); itu != following.end(); itu++) { (*itu)->addFollower(it->second); } } } std::string TwitEng::toUpper(std::string in) { std::string out; for(unsigned int i = 0; i < in.length(); i++) { out += std::toupper(in[i]); } return out; } void TwitEng::addTweet(std::string& username, DateTime& dt, std::string& text) { if(usrs.find(username) == usrs.end()) throw username; User* usr = usrs.find(username)->second; if(tweetSize_ == tweetMaxSize_) { Tweet* tmp = tweets_; tweets_ = new Tweet[tweetMaxSize_*2]; for(int i = 0; i < tweetSize_; i++) { tweets_[i] = tmp[i]; } tweetMaxSize_ = tweetMaxSize_*2; } Tweet* tmp = new Tweet(username, usr, dt, text); tweets_[tweetSize_] = *tmp; tweetSize_++; usr->addTweet(tweets_+tweetSize_-1); //Add hashtags std::set<std::string> newtags = tmp->hashTags(); for(std::set<std::string>::iterator it = newtags.begin(); it != newtags.end(); it++) { std::string tag = toUpper(*it); bool inserted = false; for(unsigned int i = 0; i < tags.size(); i++) { if(tags[i].first.compare(tag) == 0) { tags[i].second.insert(tmp); inserted = true; } else if(tags[i].first.compare(tag) < 0) { std::set<Tweet*> newset; newset.insert(tmp); tags.insert(tags.begin()+i, std::make_pair(tag, newset)); inserted = true; } if(inserted) break; } if(!inserted) { std::set<Tweet*> newset; newset.insert(tmp); tags.push_back(std::make_pair(tag, newset)); } } } bool TwitEng::parse(char* filename) { std::ifstream fin(filename); if(!fin.good()) {//check input file std::cout << "Error: Input file not found"; return true; } std::stringstream ss; std::string tmp; std::getline(fin, tmp); ss.str(tmp); int num = 0; ss >> num; for(int i = 0; i < num; i++) { std::getline(fin, tmp); ss.flush(); ss.clear(); ss.str(tmp); std::string usr; ss >> usr; adduser(usr); std::string follow; while(ss >>follow) { //follows(usr, follow); //Do this again later once we ahve all users } } //do that again to add all folloewrs/followings properly //this took me aprox one year to figure out std::ifstream fin2(filename); std::getline(fin2, tmp); for(int i = 0; i < num; i++) { std::getline(fin2, tmp); ss.flush(); ss.clear(); ss.str(tmp); std::string usr; ss >> usr; std::string follow; while(ss >>follow) { follows(usr, follow); } } while(!fin.eof()) { std::getline(fin, tmp); if(tmp.empty()) break; std::string ins[6]; ins[0] = tmp.substr(0, 4); ins[1] = tmp.substr(5, 2); ins[2] = tmp.substr(8, 2); ins[3] = tmp.substr(11, 2); ins[4] = tmp.substr(14, 2); ins[5] = tmp.substr(17, 2); int intin[6]; for(int i = 0; i < 6; i++) { ss.flush(); ss.clear(); ss.str(ins[i]); ss >> intin[i]; } int yyyy = intin[0]; int mm = intin[1]; int dd = intin[2]; int hh = intin[3]; int min = intin[4]; int ss = intin[5]; int sp = tmp.find(" ", 20); std::string username = tmp.substr(20, sp-20); std::string text = tmp.substr(sp+1); DateTime dt(hh, min, ss, yyyy, mm, dd); addTweet(username, dt, text); } setallfollowers(); return false; } std::set<Tweet*> TwitEng::bsearch(std::string key) { key = toUpper(key); int l = 0; int r = tags.size() - 1; while(!(l>r)) { int m = (l+r)/2; if(tags[m].first.compare(key) < 0) r = m-1; else if(tags[m].first.compare(key) > 0) l = m+1; else { return tags[m].second; } } throw NULL; } std::vector<Tweet*> TwitEng::search(std::vector<std::string>& terms, int strategy) { std::vector<Tweet*> out; std::vector<std::set<Tweet*> > sets; for(unsigned int i = 0; i < terms.size(); i++) { try { sets.push_back(bsearch(terms[i])); } catch (...) { if(strategy == 0) return out; } } if(strategy == 0) { for(std::set<Tweet*>::iterator it = sets[0].begin(); it != sets[0].end(); it++) { bool exists = true; for(unsigned int i = 0; i < sets.size(); i++) { if(sets[i].find(*it) == sets[i].end()) exists = false; } if (exists) out.push_back(*it); } } if(strategy == 1) { std::set<Tweet*> sout; for(unsigned int i = 0; i < sets.size(); i++) { for(std::set<Tweet*>::iterator it = sets[i].begin(); it != sets[i].end(); it++) { sout.insert(*it); } } for(std::set<Tweet*>::iterator it = sout.begin(); it != sout.end(); it++) { out.push_back(*it); } } return out; } void TwitEng::dumpFeeds() { for(std::map<std::string, User*>::iterator it = usrs.begin(); it != usrs.end(); it++) { std::string filename = it->first; filename = filename + ".feed"; const char* fname = filename.c_str(); std::ofstream fout(fname); std::vector<Tweet*> feed = it->second->getFeed(); std::sort(feed.begin(), feed.end(), TweetComp()); for(unsigned int i = 0; i < feed.size(); i++) { fout << *feed[i] << std::endl; } fout.close(); } }
[ "shebib@usc.edu" ]
shebib@usc.edu
30977a359a1ec3d2a8d22558ba241055d33576c6
97ce80e44d5558cad2ca42758e2d6fb1805815ce
/Source/Foundation/bsfCore/Private/RTTI/BsTextureImportOptionsRTTI.h
7768ee9af0c4a8186dcac219393fa1bdbe4d2aa9
[ "MIT" ]
permissive
cwmagnus/bsf
ff83ca34e585b32d909b3df196b8cf31ddd625c3
36de1caf1f7532d497b040d302823e98e7b966a8
refs/heads/master
2020-12-08T00:53:11.021847
2020-03-23T22:05:24
2020-03-23T22:05:24
232,839,774
3
0
MIT
2020-01-09T15:26:22
2020-01-09T15:26:21
null
UTF-8
C++
false
false
1,284
h
//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// #pragma once #include "BsCorePrerequisites.h" #include "Reflection/BsRTTIType.h" #include "Reflection/BsRTTIPlain.h" #include "Importer/BsTextureImportOptions.h" namespace bs { /** @cond RTTI */ /** @addtogroup RTTI-Impl-Core * @{ */ class BS_CORE_EXPORT TextureImportOptionsRTTI : public RTTIType<TextureImportOptions, ImportOptions, TextureImportOptionsRTTI> { private: BS_BEGIN_RTTI_MEMBERS BS_RTTI_MEMBER_PLAIN(format, 0) BS_RTTI_MEMBER_PLAIN(generateMips, 1) BS_RTTI_MEMBER_PLAIN(maxMip, 2) BS_RTTI_MEMBER_PLAIN(cpuCached, 3) BS_RTTI_MEMBER_PLAIN(sRGB, 4) BS_RTTI_MEMBER_PLAIN(cubemap, 5) BS_RTTI_MEMBER_PLAIN(cubemapSourceType, 6) BS_END_RTTI_MEMBERS public: const String& getRTTIName() override { static String name = "TextureImportOptions"; return name; } UINT32 getRTTIId() override { return TID_TextureImportOptions; } SPtr<IReflectable> newRTTIObject() override { return bs_shared_ptr_new<TextureImportOptions>(); } }; /** @} */ /** @endcond */ }
[ "bearishsun@gmail.com" ]
bearishsun@gmail.com
d0c7133b06aa53eb9c73eb9d686f83e730b10e2e
bdc6119c5910093d2417830e15f2389a7e5e74b7
/sols/s-topcoder/tree_weighting.cpp
d2afad291ad51faae1f3b97b38f77a241579a952
[]
no_license
danscu/onlinejudge
0d10d4902cb152dd6401d3624ebb7bc6c44bba38
a981794d868dd8366d8f50931f10704066fbab96
refs/heads/master
2021-01-15T15:33:47.893332
2016-08-31T00:50:50
2016-08-31T00:50:58
17,789,216
0
0
null
null
null
null
UTF-8
C++
false
false
4,693
cpp
#include <cstdio> #include <iostream> #include <list> #include <set> using namespace std; #define DBG 1 #if DBG #define D(x) x; #else #define D(x) #endif #define REP(v,n) for(int v=0;v<n;v++) #define every(iter, iterable) \ typeof((iterable).begin()) iter = (iterable).begin(); iter != (iterable).end(); iter++ typedef long long Num; const int maxn = 100005; const int mod = 1000000007; int N; Num grandSum; struct Node { #if DBG int idx; #endif int degrees; list<pair<Node*,Num> > edges; // target, weight Num wts; Node() { wts = 1; } void removeEdge(Node *tgt) { for (every(it, edges)) if (it->first == tgt) { edges.erase(it); break; } } void clear() { edges.clear(); degrees = 0; wts = 1; } Num multiply(Num wt, Node *c) { Num nodeSum = wts * wt % mod * c->wts % mod; #if DBG Num oldWts = wts; #endif wts = (wts + c->wts * wt % mod) % mod; #if DBG printf("path sum = %ld (node %d) * %ld (wt) * %ld (node %d) = %ld, ", oldWts, idx+1, wt, c->wts, c->idx+1, nodeSum); printf("Node %d new weight = %ld + %ld * %ld = %ld, ", idx + 1, oldWts, c->wts, wt, wts); #endif removeEdge(c); return nodeSum; } }; struct NodeComp { bool operator()(const Node *lhs, const Node *rhs) { return lhs->degrees < rhs->degrees || (lhs->degrees == rhs->degrees && lhs < rhs); } } nodeComp; multiset<Node*,NodeComp> que; Node nodes[maxn]; Num solve() { // push all to priority_q multiset<Node*,NodeComp>::iterator it = que.begin(); REP(i, N) { if (nodes[i].degrees) it = que.insert(it, &nodes[i]); } grandSum = 0; while (que.size() > 1) { Node *cur = *que.begin(); que.erase(cur); for (every(it, cur->edges)) { Node *tgt = it->first; Num wt = it->second; // cumulate path weights #if DBG printf("Merge Node %d into Node %d: ", cur->idx + 1, tgt->idx + 1); int oldGS = grandSum; #endif Num nodeSum = tgt->multiply(wt, cur); grandSum = (grandSum + nodeSum) % mod; #if DBG printf("Grand sum = %ld + %ld = %ld\n", oldGS, nodeSum, grandSum); #endif que.erase(tgt); tgt->degrees--; que.insert(tgt); } } // clean-up que.clear(); REP(i,N) nodes[i].clear(); return grandSum; } int getnum() { char cc; int dd; while (cc = getchar(), (cc<'0'||cc>'9')); dd=cc=='-'?0:cc-'0'; while (cc = getchar(), cc>='0'&&cc<='9') dd = dd*10+cc-'0'; return dd; } int main() { int T; #if BENCH freopen("tree_weighting.txt","r",stdin); #endif T = getnum(); for (int tc = 0; tc < T; tc++) { N = getnum(); #if DBG REP(i,N) nodes[i].idx = i; #endif for (int i = 0; i < N - 1; i++) { int a, b, w; a = getnum(), b = getnum(), w = getnum(); a--; b--; nodes[a].degrees++; nodes[b].degrees++; nodes[a].edges.push_back(make_pair(&nodes[b],w)); nodes[b].edges.push_back(make_pair(&nodes[a],w)); } printf("%ld\n", solve()); } return 0; } /* Merge Node 1 into Node 6: path sum = 1 (node 6) * 5 (wt) * 1 (node 1) = 5, Node 6 new weight = 1 + 1 * 5 = 6, Grand sum = 0 + 5 = 5 Merge Node 4 into Node 6: path sum = 6 (node 6) * 2 (wt) * 1 (node 4) = 12, Node 6 new weight = 6 + 1 * 2 = 8, Grand sum = 5 + 12 = 17 Merge Node 7 into Node 3: path sum = 1 (node 3) * 4 (wt) * 1 (node 7) = 4, Node 3 new weight = 1 + 1 * 4 = 5, Grand sum = 17 + 4 = 21 Merge Node 8 into Node 6: path sum = 8 (node 6) * 5 (wt) * 1 (node 8) = 40, Node 6 new weight = 8 + 1 * 5 = 13, Grand sum = 21 + 40 = 61 Merge Node 9 into Node 6: path sum = 13 (node 6) * 2 (wt) * 1 (node 9) = 26, Node 6 new weight = 13 + 1 * 2 = 15, Grand sum = 61 + 26 = 87 Merge Node 11 into Node 6: path sum = 15 (node 6) * 3 (wt) * 1 (node 11) = 45, Node 6 new weight = 15 + 1 * 3 = 18, Grand sum = 87 + 45 = 132 Merge Node 12 into Node 10: path sum = 1 (node 10) * 3 (wt) * 1 (node 12) = 3, Node 10 new weight = 1 + 1 * 3 = 4, Grand sum = 132 + 3 = 135 Merge Node 10 into Node 14: path sum = 1 (node 14) * 4 (wt) * 4 (node 10) = 16, Node 14 new weight = 1 + 4 * 4 = 17, Grand sum = 135 + 16 = 151 Merge Node 13 into Node 6: path sum = 18 (node 6) * 5 (wt) * 1 (node 13) = 90, Node 6 new weight = 18 + 1 * 5 = 23, Grand sum = 151 + 90 = 241 Merge Node 6 into Node 3: path sum = 5 (node 3) * 2 (wt) * 23 (node 6) = 230, Node 3 new weight = 5 + 23 * 2 = 51, Grand sum = 241 + 230 = 471 Merge Node 3 into Node 2: path sum = 1 (node 2) * 4 (wt) * 51 (node 3) = 204, Node 2 new weight = 1 + 51 * 4 = 205, Grand sum = 471 + 204 = 675 Merge Node 2 into Node 5: path sum = 1 (node 5) * 4 (wt) * 205 (node 2) = 820, Node 5 new weight = 1 + 205 * 4 = 821, Grand sum = 675 + 820 = 1495 Merge Node 5 into Node 14: path sum = 17 (node 14) * 5 (wt) * 821 (node 5) = 69785, Node 14 new weight = 17 + 821 * 5 = 4122, Grand sum = 1495 + 69785 = 71280 */
[ "d.xie@sta.samsung.com" ]
d.xie@sta.samsung.com
52532e5e77f9a82050c69df7124a6c19adb4c1ee
72f2992a3659ff746ba5ce65362acbe85a918df9
/apps-src/apps/librose/unit_frame.cpp
8f06c7a17f25bdc4ff28f6cd901aaf5e0c8c9d78
[ "BSD-2-Clause" ]
permissive
chongtianfeiyu/Rose
4742f06ee9ecd55f9717ac6378084ccf8bb02a15
412175b57265ba2cda1e33dd2047a5a989246747
refs/heads/main
2023-05-23T14:03:08.095087
2021-06-19T13:23:58
2021-06-19T14:00:25
391,238,554
0
1
BSD-2-Clause
2021-07-31T02:39:25
2021-07-31T02:39:24
null
UTF-8
C++
false
false
17,077
cpp
/* $Id: unit_frame.cpp 47820 2010-12-05 18:08:51Z mordante $ */ /* Copyright (C) 2006 - 2010 by Jeremy Rosen <jeremy.rosen@enst-bretagne.fr> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. See the COPYING file for more details. */ /** @file */ #include "global.hpp" #include "display.hpp" #include "serialization/string_utils.hpp" #include "unit_frame.hpp" progressive_string::progressive_string(const std::string& data,int duration) : data_(), input_(data) { const std::vector<std::string> first_pass = utils::split(data); const int colons = (int)first_pass.size(); int total_explicit_time = 0, explicit_colon = 0; std::vector<std::string>::const_iterator tmp; for (tmp = first_pass.begin(); tmp != first_pass.end() ; ++ tmp) { std::vector<std::string> second_pass = utils::split(*tmp, ':'); int explicit_time = (second_pass.size() > 1)? atoi(second_pass[1].c_str()): 0; VALIDATE(explicit_time >= 0, null_str); if (explicit_time) { explicit_colon ++; } total_explicit_time += explicit_time; data_.push_back(std::pair<std::string,int>(second_pass[0], explicit_time)); } VALIDATE(total_explicit_time <= duration, null_str); if (explicit_colon != colons) { // 2. calculate average_time, and set it to no explicit itmes. const int average_time = (duration - total_explicit_time) / (colons - explicit_colon); for (std::vector<std::pair<std::string, int> >::iterator it = data_.begin(); it != data_.end(); ++ it) { if (!it->second) { it->second = average_time; } } } } int progressive_string::duration() const { int total =0; std::vector<std::pair<std::string,int> >::const_iterator cur_halo; for(cur_halo = data_.begin() ; cur_halo != data_.end() ; ++cur_halo) { total += cur_halo->second; } return total; } const std::string& progressive_string::get_current_element(int current_time)const { int time = 0; unsigned int sub_halo = 0; if(data_.empty()) return null_str; while(time < current_time&& sub_halo < data_.size()) { time += data_[sub_halo].second; ++sub_halo; } if(sub_halo) sub_halo--; return data_[sub_halo].first; } template <class T> progressive_<T>::progressive_(const std::string &data, int duration) : data_(), input_(data) { int split_flag = utils::REMOVE_EMPTY; // useless to strip spaces const std::vector<std::string> comma_split = utils::split(data,',',split_flag); const int colons = (int)comma_split.size(); // 1. calculate total_explicit, item's time that no explicit set to 0. int total_explicit_time = 0, explicit_colon = 0; std::vector<std::string>::const_iterator com_it = comma_split.begin(); for (; com_it != comma_split.end(); ++com_it) { std::vector<std::string> colon_split = utils::split(*com_it,':',split_flag); int explicit_time = (colon_split.size() > 1)? atoi(colon_split[1].c_str()): 0; VALIDATE(explicit_time >= 0, null_str); if (explicit_time) { explicit_colon ++; } total_explicit_time += explicit_time; std::vector<std::string> range = utils::split(colon_split[0],'~',split_flag); T range0 = lexical_cast<T>(range[0]); T range1 = (range.size() > 1) ? lexical_cast<T>(range[1]) : range0; typedef std::pair<T,T> range_pair; data_.push_back(std::pair<range_pair,int>(range_pair(range0, range1), explicit_time)); } VALIDATE(total_explicit_time <= duration, null_str); if (explicit_colon != colons) { // 2. calculate average_time, and set it to no explicit itmes. const int average_time = (duration - total_explicit_time) / (colons - explicit_colon); for (typename std::vector<std::pair<std::pair<T, T>, int> >::iterator it = data_.begin(); it != data_.end(); ++ it) { if (!it->second) { it->second = average_time; } } } } template <class T> const T progressive_<T>::get_current_element(int current_time, T default_val) const { int time = 0; unsigned int sub_halo = 0; int searched_time = current_time; if(searched_time < 0) searched_time = 0; if(searched_time > duration()) searched_time = duration(); if(data_.empty()) return default_val; while(time < searched_time&& sub_halo < data_.size()) { time += data_[sub_halo].second; ++sub_halo; } if(sub_halo != 0) { sub_halo--; time -= data_[sub_halo].second; } const T first = data_[sub_halo].first.first; const T second = data_[sub_halo].first.second; return T((static_cast<double>(searched_time - time) / static_cast<double>(data_[sub_halo].second)) * (second - first) + first); } template<class T> int progressive_<T>::duration() const { int total = 0; typename std::vector<std::pair<std::pair<T, T>, int> >::const_iterator cur_halo; for(cur_halo = data_.begin() ; cur_halo != data_.end() ; ++cur_halo) { total += cur_halo->second; } return total; } template <class T> bool progressive_<T>::does_not_change() const { return data_.empty() || ( data_.size() == 1 && data_[0].first.first == data_[0].first.second); } // Force compilation of the following template instantiations template class progressive_<int>; template class progressive_<double>; frame_parameters frame_parameters::null_param; const int frame_parameters::default_text_color = 0xFFDDDDDD; // equal font::NORMAL_COLOR frame_parameters::frame_parameters() : duration(0), image(), image_diagonal(), image_horizontal(), image_mod(""), stext(""), halo(""), sound(""), text(""), text_color(0), font_size(0), blend_with(0), blend_ratio(0.0), highlight_ratio(1.0), offset_x(0), offset_y(0), submerge(0.0), x(0), y(0), directional_x(0), directional_y(0), auto_vflip(t_unset), auto_hflip(t_unset), primary_frame(t_unset), drawing_layer(display::LAYER_UNIT_DEFAULT - display::LAYER_UNIT_FIRST), area_mode(false), sound_filter() {} frame_parsed_parameters::frame_parsed_parameters(const config& cfg, const std::string& frame_string, int override_duration) : duration_(override_duration? override_duration: cfg[frame_string + "duration"].to_int(1)) , image_(cfg[frame_string + "image"]) , image_diagonal_(cfg[frame_string + "image_diagonal"]) , image_horizontal_(cfg[frame_string + "image_horizontal"]) , image_mod_(cfg[frame_string + "image_mod"]) , stext_(cfg[frame_string + "stext"]) , halo_(cfg[frame_string + "halo"], duration_) , sound_(cfg[frame_string + "sound"]) , text_(cfg[frame_string + "text"]) , text_color_(frame_parameters::default_text_color) , font_size_(cfg[frame_string + "font_size"].to_int(0)) , blend_with_(0) , blend_ratio_(cfg[frame_string + "blend_ratio"], duration_) , highlight_ratio_(cfg[frame_string + "alpha"], duration_) , offset_x_(cfg[frame_string + "offset_x"], duration_) , offset_y_(cfg[frame_string + "offset_y"], duration_) , submerge_(cfg[frame_string + "submerge"], duration_) , x_(cfg[frame_string + "x"], duration_) , y_(cfg[frame_string + "y"], duration_) , directional_x_(cfg[frame_string + "directional_x"], duration_) , directional_y_(cfg[frame_string + "directional_y"], duration_) , auto_vflip_(t_unset) , auto_hflip_(t_unset) , primary_frame_(t_unset) , drawing_layer_(cfg[frame_string + "layer"], duration_) { if (!frame_string.empty()) { // not support define duration out of [xxx_frame]. must be additive using these [xxx_frame]. VALIDATE(!cfg.has_attribute(frame_string + "duration"), null_str); } if (!cfg.has_attribute(frame_string + "auto_vflip")) { auto_vflip_ = t_unset; } else if(cfg[frame_string + "auto_vflip"].to_bool()) { auto_vflip_ = t_true; } else { auto_vflip_ = t_false; } if(!cfg.has_attribute(frame_string + "auto_hflip")) { auto_hflip_ = t_unset; } else if(cfg[frame_string + "auto_hflip"].to_bool()) { auto_hflip_ = t_true; } else { auto_hflip_ = t_false; } if(!cfg.has_attribute(frame_string + "primary")) { primary_frame_ = t_unset; } else if(cfg[frame_string + "primary"].to_bool()) { primary_frame_ = t_true; } else { primary_frame_ = t_false; } std::vector<std::string> color = utils::split(cfg[frame_string + "text_color"]); if (color.size() == 4) { text_color_ = display::rgb(atoi(color[1].c_str()), atoi(color[2].c_str()), atoi(color[3].c_str())); text_color_ &= 0xffffffff; } color = utils::split(cfg[frame_string + "blend_color"]); if (color.size() == 3) { blend_with_ = display::rgb(atoi(color[0].c_str()), atoi(color[1].c_str()), atoi(color[2].c_str())); } } bool frame_parsed_parameters::does_not_change() const { return halo_.does_not_change() && blend_ratio_.does_not_change() && highlight_ratio_.does_not_change() && offset_x_.does_not_change() && offset_y_.does_not_change() && submerge_.does_not_change() && x_.does_not_change() && y_.does_not_change() && directional_x_.does_not_change() && directional_y_.does_not_change() && drawing_layer_.does_not_change() && stext_.empty(); } bool frame_parsed_parameters::need_update() const { if(!halo_.does_not_change() || !blend_ratio_.does_not_change() || !highlight_ratio_.does_not_change() || !offset_x_.does_not_change() || !offset_y_.does_not_change() || !submerge_.does_not_change() || !x_.does_not_change() || !y_.does_not_change() || !directional_x_.does_not_change() || !directional_y_.does_not_change() || !drawing_layer_.does_not_change() ) { return true; } return false; } const frame_parameters frame_parsed_parameters::parameters(int current_time) const { frame_parameters result; result.duration = duration_; result.image = image_; result.image_diagonal = image_diagonal_; result.image_horizontal = image_horizontal_; result.image_mod = image_mod_; result.stext = stext_; result.halo = halo_.get_current_element(current_time); result.sound = sound_; result.text = text_; result.text_color = text_color_; result.font_size = font_size_; result.blend_with = blend_with_; result.blend_ratio = blend_ratio_.get_current_element(current_time); result.highlight_ratio = highlight_ratio_.get_current_element(current_time,1.0); result.offset_x = offset_x_.get_current_element(current_time,-1000); result.offset_y = offset_y_.get_current_element(current_time,-1000); result.submerge = submerge_.get_current_element(current_time); result.x = x_.get_current_element(current_time); result.y = y_.get_current_element(current_time); result.directional_x = directional_x_.get_current_element(current_time); result.directional_y = directional_y_.get_current_element(current_time); result.auto_vflip = auto_vflip_; result.auto_hflip = auto_hflip_; result.primary_frame = primary_frame_; result.drawing_layer = drawing_layer_.get_current_element(current_time,display::LAYER_UNIT_DEFAULT-display::LAYER_UNIT_FIRST); return result; } void frame_parsed_parameters::override( int duration , const std::string& highlight , const std::string& blend_ratio , Uint32 blend_color , const std::string& offset , const std::string& layer , const std::string& modifiers) { if (!highlight.empty()) { highlight_ratio_ = progressive_double(highlight,duration); } else if (duration != duration_){ highlight_ratio_ = progressive_double(highlight_ratio_.get_original(),duration); } if (!offset.empty()) { offset_x_= progressive_double(offset,duration); } else if (duration != duration_){ offset_x_ = progressive_double(offset_x_.get_original(),duration); } if (!offset.empty()) { offset_y_ = progressive_double(offset,duration); } else if (duration != duration_){ offset_y_ = progressive_double(offset_y_.get_original(),duration); } if (!blend_ratio.empty()) { blend_ratio_ = progressive_double(blend_ratio,duration); blend_with_ = blend_color; } else if (duration != duration_){ blend_ratio_ = progressive_double(blend_ratio_.get_original(),duration); } if (!layer.empty()) { drawing_layer_ = progressive_int(layer,duration); } else if (duration != duration_){ drawing_layer_ = progressive_int(drawing_layer_.get_original(),duration); } if (!modifiers.empty()) { image_mod_ += modifiers; } if (duration != duration_) { halo_ = progressive_string(halo_.get_original(), duration); submerge_=progressive_double(submerge_.get_original(), duration); x_=progressive_int(x_.get_original(), duration); y_=progressive_int(y_.get_original(), duration); directional_x_=progressive_int(directional_x_.get_original(), duration); directional_y_=progressive_int(directional_y_.get_original(), duration); duration_ = duration; } } frame_parsed_parameters& frame_parsed_parameters::image(const std::string& image ,const std::string & image_mod) { image_ = image; image_mod_ = image_mod; return *this; } frame_parsed_parameters& frame_parsed_parameters::image_diagonal(const image::locator& image_diagonal,const std::string& image_mod) { image_diagonal_ = image_diagonal; image_mod_ = image_mod; return *this; } frame_parsed_parameters& frame_parsed_parameters::image_horizontal(const image::locator& image_horizontal,const std::string& image_mod) { image_horizontal_ = image_horizontal; image_mod_ = image_mod; return *this; } frame_parsed_parameters& frame_parsed_parameters::sound(const std::string& sound) { sound_=sound; return *this; } frame_parsed_parameters& frame_parsed_parameters::text(const std::string& text,const Uint32 text_color) { text_=text; text_color_=text_color; return *this; } frame_parsed_parameters& frame_parsed_parameters::halo(const std::string &halo, const std::string &x, const std::string& y,const std::string & mod) { halo_ = progressive_string(halo, duration_); x_ = progressive_int(x, duration_); y_ = progressive_int(y, duration_); image_mod_= mod; return *this; } frame_parsed_parameters& frame_parsed_parameters::duration(const int duration) { if (duration != duration_) { halo_ = progressive_string(halo_.get_original(), duration); blend_ratio_ = progressive_double(blend_ratio_.get_original(), duration); highlight_ratio_ = progressive_double(highlight_ratio_.get_original(), duration); offset_x_ = progressive_double(offset_x_.get_original(), duration); offset_y_ = progressive_double(offset_y_.get_original(), duration); submerge_=progressive_double(submerge_.get_original(), duration); x_=progressive_int(x_.get_original(), duration); y_=progressive_int(y_.get_original(), duration); directional_x_=progressive_int(directional_x_.get_original(), duration); directional_y_=progressive_int(directional_y_.get_original(), duration); drawing_layer_=progressive_int(drawing_layer_.get_original(), duration); duration_ = duration; } return *this; } frame_parsed_parameters& frame_parsed_parameters::blend(const std::string& blend_ratio,const Uint32 blend_color) { blend_with_ = blend_color; blend_ratio_ = progressive_double(blend_ratio, duration_); return *this; } frame_parsed_parameters& frame_parsed_parameters::highlight(const std::string& highlight) { highlight_ratio_ = progressive_double(highlight, duration_); return *this; } frame_parsed_parameters& frame_parsed_parameters::offset(const std::string& offset) { offset_x_ = progressive_double(offset, duration_); offset_y_ = progressive_double(offset, duration_); return *this; } frame_parsed_parameters& frame_parsed_parameters::offset(const std::string& offset_x, const std::string& offset_y) { offset_x_ = progressive_double(offset_x, duration_); offset_y_ = progressive_double(offset_y, duration_); return *this; } frame_parsed_parameters& frame_parsed_parameters::submerge(const std::string& submerge) { submerge_ = progressive_double(submerge, duration_); return *this; } frame_parsed_parameters& frame_parsed_parameters::x(const std::string& x) { x_ = progressive_int(x, duration_); return *this; } frame_parsed_parameters& frame_parsed_parameters::y(const std::string& y) { y_ = progressive_int(y, duration_); return *this; } frame_parsed_parameters& frame_parsed_parameters::directional_x(const std::string& directional_x) { directional_x_ = progressive_int(directional_x, duration_); return *this; } frame_parsed_parameters& frame_parsed_parameters::directional_y(const std::string& directional_y) { directional_y_ = progressive_int(directional_y, duration_); return *this; } frame_parsed_parameters& frame_parsed_parameters::auto_vflip(const bool auto_vflip) { if (auto_vflip) { auto_vflip_ = t_true; } else { auto_vflip_ = t_false; } return *this; } frame_parsed_parameters& frame_parsed_parameters::auto_hflip(const bool auto_hflip) { if (auto_hflip) { auto_hflip_ = t_true; } else { auto_hflip_ = t_false; } return *this; } frame_parsed_parameters& frame_parsed_parameters::primary_frame(const bool primary_frame) { if (primary_frame) { primary_frame_ = t_true; } else { primary_frame_ = t_false; } return *this; } frame_parsed_parameters& frame_parsed_parameters::drawing_layer(const std::string& drawing_layer) { drawing_layer_ = progressive_int(drawing_layer, duration_); return *this; }
[ "service@leagor.com" ]
service@leagor.com
f9ec2b82ce740c09121b98180028ff0331e40c10
39eac74fa6a244d15a01873623d05f480f45e079
/PackageUseSelectionDlg.h
f400301599d944a066eeaf5ccad419b24c110fc3
[]
no_license
15831944/Practice
a8ac8416b32df82395bb1a4b000b35a0326c0897
ae2cde9c8f2fb6ab63bd7d8cd58701bd3513ec94
refs/heads/master
2021-06-15T12:10:18.730367
2016-11-30T15:13:53
2016-11-30T15:13:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,949
h
#if !defined(AFX_PACKAGEUSESELECTIONDLG_H__CF3B3301_44EE_411F_BD52_68DD1866FF7C__INCLUDED_) #define AFX_PACKAGEUSESELECTIONDLG_H__CF3B3301_44EE_411F_BD52_68DD1866FF7C__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // PackageUseSelectionDlg.h : header file // // (j.jones 2008-05-22 11:44) - PLID 28450 - added a proper memory object struct PackageChargeObject { long nPackageChargeID; long nServiceID; double dblQuantity; }; ///////////////////////////////////////////////////////////////////////////// // CPackageUseSelectionDlg dialog class CPackageUseSelectionDlg : public CNxDialog { // Construction public: CPackageUseSelectionDlg(CWnd* pParent); // standard constructor ~CPackageUseSelectionDlg(); NXDATALISTLib::_DNxDataListPtr m_PackageList; long m_nQuoteID; // (j.jones 2008-05-22 11:44) - PLID 28450 - added a new package charge array // that replaced the old service & quantity arrays CArray<PackageChargeObject*, PackageChargeObject*> m_arypPackageCharges; BOOL m_bPackageIsUsedUp; // (j.jones 2007-03-26 14:37) - PLID 25287 - used to determine if we need to // offset our bill amount to match the remaining package amount COleCurrency m_cyMatchRemainingPackageAmount; //used with the above to determine which service ID to assign the matched amount to // (j.jones 2011-02-03 09:12) - PLID 42291 - changed to calculate the package charge ID, not service ID long m_nMatchRemAmountToChargeID; // Dialog Data //{{AFX_DATA(CPackageUseSelectionDlg) enum { IDD = IDD_PACKAGE_USE_SELECTION_DLG }; CNxIconButton m_btnOK; CNxIconButton m_btnCancel; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CPackageUseSelectionDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // (j.jones 2008-05-22 11:45) - PLID 28450 - this function will properly clear m_arypPackageCharges void ClearPackageChargeArray(); // Generated message map functions //{{AFX_MSG(CPackageUseSelectionDlg) virtual BOOL OnInitDialog(); virtual void OnOK(); virtual void OnCancel(); afx_msg void OnEditingStartingPackageList(long nRow, short nCol, VARIANT FAR* pvarValue, BOOL FAR* pbContinue); afx_msg void OnEditingFinishingPackageList(long nRow, short nCol, const VARIANT FAR& varOldValue, LPCTSTR strUserEntered, VARIANT FAR* pvarNewValue, BOOL FAR* pbCommit, BOOL FAR* pbContinue); afx_msg void OnEditingFinishedPackageList(long nRow, short nCol, const VARIANT FAR& varOldValue, const VARIANT FAR& varNewValue, BOOL bCommit); afx_msg void OnRequeryFinishedPackageList(short nFlags); DECLARE_EVENTSINK_MAP() //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_PACKAGEUSESELECTIONDLG_H__CF3B3301_44EE_411F_BD52_68DD1866FF7C__INCLUDED_)
[ "h.shah@WALD" ]
h.shah@WALD
f8d4a206c917c7481d34b354ec62b0b9a6b4c800
bc4f3bae021fb7db65c5fc571cc26fdec38c28b4
/Pods/Headers/Public/SARUnArchiveANY/ulinks.hpp
93506a6330e5d9c0bc8f42d37740632aa5a93e0a
[]
no_license
a349112363/RarDecompression
e00f101cb10f2275cee31f1cbb2a4ad0f3f757b0
c26b8ded3ad99473f3cae81836e329acf8ba16b0
refs/heads/master
2020-03-18T02:56:12.417401
2018-05-21T06:14:27
2018-05-21T06:14:27
134,214,466
0
0
null
null
null
null
UTF-8
C++
false
false
58
hpp
../../../SARUnArchiveANY/External/Unrar/Headers/ulinks.hpp
[ "kiss.loo@qq.com" ]
kiss.loo@qq.com
c17318d3696465f153cec26f0cc3d5d390624f6d
fdc26fead1306592b84068ec9ac3ca5bcc1b9834
/INTERVIEWBIT/Other/OSSTesting.cpp
65a6e38f186824ce95ca2927c858c582edaccc46
[ "MIT" ]
permissive
yashsanghvi001/Hacktober-CP-contributions
f4e34d8061d9b8be8cf5e5004a983098a3022b11
a42628c48b00e296eb41f9dd1e223781ebc841a6
refs/heads/main
2022-12-31T11:58:25.515263
2020-10-24T07:17:08
2020-10-24T07:17:08
302,109,476
1
0
MIT
2020-10-14T16:18:48
2020-10-07T17:22:07
C++
UTF-8
C++
false
false
267
cpp
#include<iostream> #include<sstream> using namespace std; int main(){ int i; ostringstream oss; string str = ""; for(i = 0; i < 5; i++){ oss << i; str = str + oss.str(); oss.str(""); } cout << str; return 0; }
[ "yogeshgaur1995@gmail.com" ]
yogeshgaur1995@gmail.com
be6b224ee8ab0a36fea49e00d7e1df0a05418438
9627bdbd6f366de38685fe674cbcbda673127614
/src/shapes.cpp
7eba2d66b83654f4ab4fa568a88ba10cc6e099ef
[ "MIT" ]
permissive
hermetikos/OpenGL-Cross-Platform-Benchmark
31ce1e9f536e45d480da66ae69d99778e264ad7e
4ed4017401aa6f072059f0d7d61933500427895b
refs/heads/master
2021-10-08T14:23:10.479886
2018-12-13T06:44:29
2018-12-13T06:44:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,691
cpp
/* This file is part of OpenGL-Cross-Platform-Benchmark which is released under the MIT License. Copyright Stan Slupecki 2018 Go to https://misturdust319.github.io/OpenGL-Cross-Platform-Benchmark/ for full license details. */ #include <GLBenchmark/shapes.h> #include <vector> // using these objects // create a new shape // init it // use draw to render it //constructor Shape::Shape(const glm::vec3 origin) { // set the buffers to ID // VAO = VBO = EBO = ID; // set origin setOrigin(origin); } void Shape::init() { // generate and bind buffers glGenVertexArrays(1, &VAO); // VAO glGenBuffers(1, &VBO); // VBO glGenBuffers(1, &EBO); // EBO // 1. bind VAO bindVAO(); // 2. bind then copy verts into vertex buffer initVBO(); // 3. bind then copy inidices into index buffer initEBO(); // 4. set vertex attribute pointers glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3*sizeof(float), (void*)0); glEnableVertexAttribArray(0); } void Shape::bindVAO() { glBindVertexArray(VAO); } void Shape::initVBO() { glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * getNumberVertices(), getVertices(), GL_STATIC_DRAW); } void Shape::initEBO() { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * getNumberIndices(), getIndices(), GL_STATIC_DRAW); } void Shape::draw() { // ensure this Shape's VAO is bound bindVAO(); // init(); // init the shape glDrawElements(GL_TRIANGLES, getNumberIndices(), GL_UNSIGNED_INT, 0); // glDrawArrays(GL_TRIANGLES, 0, getNumberVertices()); glBindVertexArray(0); } // set the vertices to an existing vertex of vertices void Shape::setVertices(const std::vector<float>& verts) { vertices = verts; } // set the vertices to array of floats void Shape::setVertices(const float* verts, const int size) { for (int i = 0; i < size; i++) { this->vertices.emplace_back(verts[i]); } } void Shape::setIndices(const unsigned int* indices, const int size) { for (int i = 0; i < size; i++) { this->indices.emplace_back(indices[i]); } } int Shape::getNumberVertices() { return vertices.size(); } int Shape::getNumberIndices() { return indices.size(); } void Shape::setOrigin(const glm::vec3& shapeOrigin) { origin = shapeOrigin; } void Shape::setOrigin(float x, float y, float z) { origin = glm::vec3(x, y, z); } glm::vec3 Shape::getOrigin() { return origin; } float* Shape::getVertices() { // return vector as array return &vertices[0]; } unsigned int* Shape::getIndices() { // return vector as array return &indices[0]; }
[ "sslup@hermetikos.com" ]
sslup@hermetikos.com
32262cdbe0cf52960edff93162aba3e1488c2879
0fed3d6c4a6dbdb49029913b6ce96a9ede9eac6c
/Codeforces/861/861B.cpp
3ddb69585855ee7e19f52b3c9aaddddcdfb7801b
[]
no_license
87ouo/The-road-to-ACMer
72df2e834027dcfab04b02ba0ddd350e5078dfc0
0a39a9708a0e7fd0e3b2ffff5d1f4a793b031df5
refs/heads/master
2021-02-18T17:44:29.937434
2019-07-31T11:30:27
2019-07-31T11:30:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,516
cpp
#include <bits/stdc++.h> using namespace std; #define clr(a, x) memset(a, x, sizeof(a)) #define mp(x, y) make_pair(x, y) #define pb(x) push_back(x) #define X first #define Y second #define fastin \ ios_base::sync_with_stdio(0); \ cin.tie(0); typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; const double eps = 1e-6; PII a[105]; int main() { int n, m; while (cin >> n >> m) { int ans = -1; for (int i = 0; i < m; i++) { cin >> a[i].X >> a[i].Y; a[i].X--, a[i].Y--; } if (n == 1) { cout << 1 << endl; continue; } n--; for (int i = 1; i <= 100; i++) { // cout << "i = " << i << endl; bool flag = 0; for (int j = 0; j < m; j++) { int k = a[j].X / i; // cout << k << " " << a[j].Y << endl; if (k != a[j].Y) { flag = 1; break; } } if (!flag) { int tmp = n / i + 1; if (ans == -1) ans = tmp; else if (ans != tmp) { ans = -1; break; } } } cout << ans << endl; } return 0; }
[ "zbszx040504@126.com" ]
zbszx040504@126.com
8bef19a548752d87346034296fc3a45d6fdefd0a
df13301ec4a28fbbdd85783fa093c58686dc4a85
/test/vecAdd_5.h
6ac225db3f6b922e6f641828e103db57f7316628
[]
no_license
cjatin/tlib
3d0631b938035bb3b59148f2ffee7e9228691046
a45e8a80fd48a2dc7ca75e6100f9573228cdc626
refs/heads/master
2020-10-01T16:58:15.034497
2019-12-20T05:17:19
2019-12-20T05:17:19
227,581,470
0
0
null
null
null
null
UTF-8
C++
false
false
347
h
#include "tlib.h" #include <benchmark/benchmark.h> static void vecAdd_5(benchmark::State& state) { // Perform setup here for (auto _ : state) { // This code gets timed std::vector<int> a = {1, 2, 3, 4, 5}; auto b = a; std::vector<int> c; vecAdd(a, b, c); } } // Register the function as a benchmark BENCHMARK(vecAdd_5);
[ "Jatin.Chaudhary@amd.com" ]
Jatin.Chaudhary@amd.com
15aa535c4a0005cfb5d9c8f99c44b741aa41118e
05dee134ef4e552fecd0d39dea5d6cdc3a82965c
/LuoGu/洛谷-P3258.cpp
a0d04e7d9f44745c9021350ca1d43889fd223446
[]
no_license
yliu-cs/ACM
35239420f36baf336e17a5c45d2c7a5ae9317413
f67ca3e6de900afabe38201e19c74d0e1c6a40a3
refs/heads/master
2022-03-20T10:10:25.787434
2019-12-05T16:30:29
2019-12-05T16:30:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,707
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; struct Edge { int V, Next; }; Edge edges[maxn << 1]; int Head[maxn]; int Tot; void Init() { Tot = 0; memset(Head, -1, sizeof(Head)); } void AddEdge(int U, int V) { edges[Tot] = Edge {V, Head[U]}; Head[U] = Tot++; } int Rmq[maxn << 1]; struct ST { int Dp[maxn << 1][20]; void Init(int N) { for (int i = 1; i <= N; ++i) { Dp[i][0] = i; } for (int j = 1; (1 << j) <= N; ++j) { for (int i = 1; i + (1 << j) - 1 <= N; ++i) { Dp[i][j] = Rmq[Dp[i][j - 1]] < Rmq[Dp[i + (1 << (j - 1))][j - 1]] ? Dp[i][j - 1] : Dp[i + (1 << (j - 1))][j - 1]; } } } int Query(int Left, int Right) { if (Left > Right) { swap(Left, Right); } int Len = int(log2(Right - Left + 1)); return Rmq[Dp[Left][Len]] <= Rmq[Dp[Right - (1 << Len) + 1][Len]] ? Dp[Left][Len] : Dp[Right - (1 << Len) + 1][Len]; } }; int Vertex[maxn << 1]; int First[maxn]; int Parent[maxn]; int LCATot; ST St; void LCADfs(int Cur, int Pre, int Depth) { Vertex[++LCATot] = Cur; First[Cur] = LCATot; Rmq[LCATot] = Depth; Parent[Cur] = Pre; for (int i = Head[Cur]; ~i; i = edges[i].Next) { if (edges[i].V == Pre) { continue; } LCADfs(edges[i].V, Cur, Depth + 1); Vertex[++LCATot] = Cur; Rmq[LCATot] = Depth; } } void LCAInit(int Root, int NodeNum) { LCATot = 0; LCADfs(Root, 0, 0); St.Init(2 * NodeNum - 1); } int QueryLCA(int U, int V) { return Vertex[St.Query(First[U], First[V])]; } int N; int A[maxn]; int Cnt[maxn]; int Dfs(int Cur, int Pre) { for (int i = Head[Cur]; ~i; i = edges[i].Next) { if (edges[i].V == Pre) { continue; } Cnt[Cur] += Dfs(edges[i].V, Cur); } return Cnt[Cur]; } int main(int argc, char *argv[]) { Init(); scanf("%d", &N); for (int i = 1; i <= N; ++i) { scanf("%d", &A[i]); } for (int i = 1, X, Y; i < N; ++i) { scanf("%d%d", &X, &Y); AddEdge(X, Y); AddEdge(Y, X); } Parent[1] = 0; LCAInit(1, N); memset(Cnt, 0, sizeof(Cnt)); for (int i = 1; i < N; ++i) { int LCA = QueryLCA(A[i], A[i + 1]); Cnt[A[i]]++; Cnt[A[i + 1]]++; Cnt[LCA]--; Cnt[Parent[LCA]]--; } Dfs(1, 0); for (int i = 2; i <= N; ++i) { Cnt[A[i]]--; } for (int i = 1; i <= N; ++i) { printf("%d\n", Cnt[i]); } return 0; }
[ "978539910@qq.com" ]
978539910@qq.com
d6ca27eb144a76ea106a53c99c5484ad763fd386
34a294504a848c7f8ded96d0abaac08ebd4193e3
/sparse_matrix.h
8b4bcf1f4ca3b36e72aa843a8dcb1dedb147e239
[]
no_license
ma-hei/Fluid-Simulation
dbcd1adabf23d92ec08391b592e7f917c1eeada2
c129a9da67197e409858c28810f84444c0bc04b1
refs/heads/master
2021-01-22T07:32:26.278484
2017-05-01T00:48:10
2017-05-01T00:48:10
4,194,245
0
0
null
null
null
null
UTF-8
C++
false
false
8,335
h
#ifndef SPARSE_MATRIX_H #define SPARSE_MATRIX_H #include <iostream> #include <vector> #include "util.h" //============================================================================ // Dynamic compressed sparse row matrix. using namespace std; template<class T> struct SparseMatrix { unsigned int n; // dimension std::vector<std::vector<unsigned int> > index; // for each row, a list of all column indices (sorted) std::vector<std::vector<T> > value; // values corresponding to index explicit SparseMatrix(unsigned int n_=0, unsigned int expected_nonzeros_per_row=7) : n(n_), index(n_), value(n_) { for(unsigned int i=0; i<n; ++i){ index[i].reserve(expected_nonzeros_per_row); value[i].reserve(expected_nonzeros_per_row); } } void clear(void) { n=0; index.clear(); value.clear(); } void zero(void) { for(unsigned int i=0; i<n; ++i){ index[i].resize(0); value[i].resize(0); } } void resize(int n_) { n=n_; index.resize(n); value.resize(n); } T operator()(unsigned int i, unsigned int j) const { for(unsigned int k=0; k<index[i].size(); ++k){ if(index[i][k]==j) return value[i][k]; else if(index[i][k]>j) return 0; } return 0; } void set_element(unsigned int i, unsigned int j, T new_value) { unsigned int k=0; for(; k<index[i].size(); ++k){ if(index[i][k]==j){ value[i][k]=new_value; return; }else if(index[i][k]>j){ insert(index[i], k, j); insert(value[i], k, new_value); return; } } index[i].push_back(j); value[i].push_back(new_value); } void add_to_element(unsigned int i, unsigned int j, T increment_value) { unsigned int k=0; for(; k<index[i].size(); ++k){ if(index[i][k]==j){ value[i][k]+=increment_value; return; }else if(index[i][k]>j){ insert(index[i], k, j); insert(value[i], k, increment_value); return; } } index[i].push_back(j); value[i].push_back(increment_value); } // assumes indices is already sorted void add_sparse_row(unsigned int i, const std::vector<unsigned int> &indices, const std::vector<T> &values) { unsigned int j=0, k=0; while(j<indices.size() && k<index[i].size()){ if(index[i][k]<indices[j]){ ++k; }else if(index[i][k]>indices[j]){ insert(index[i], k, indices[j]); insert(value[i], k, values[j]); ++j; }else{ value[i][k]+=values[j]; ++j; ++k; } } for(;j<indices.size(); ++j){ index[i].push_back(indices[j]); value[i].push_back(values[j]); } } // assumes matrix has symmetric structure - so the indices in row i tell us which columns to delete i from void symmetric_remove_row_and_column(unsigned int i) { for(unsigned int a=0; a<index[i].size(); ++a){ unsigned int j=index[i][a]; // for(unsigned int b=0; b<index[j].size(); ++b){ if(index[j][b]==i){ erase(index[j], b); erase(value[j], b); break; } } } index[i].resize(0); value[i].resize(0); } void write_matlab(std::ostream &output, const char *variable_name) { output<<variable_name<<"=sparse(["; for(unsigned int i=0; i<n; ++i){ for(unsigned int j=0; j<index[i].size(); ++j){ output<<i+1<<" "; } } output<<"],...\n ["; for(unsigned int i=0; i<n; ++i){ for(unsigned int j=0; j<index[i].size(); ++j){ output<<index[i][j]+1<<" "; } } output<<"],...\n ["; for(unsigned int i=0; i<n; ++i){ for(unsigned int j=0; j<value[i].size(); ++j){ output<<value[i][j]<<" "; } } output<<"], "<<n<<", "<<n<<");"<<std::endl; } }; typedef SparseMatrix<float> SparseMatrixf; typedef SparseMatrix<double> SparseMatrixd; // perform result=matrix*x template<class T> void multiply(const SparseMatrix<T> &matrix, const std::vector<T> &x, std::vector<T> &result) { //assert(matrix.n==x.size()); if (matrix.n!=x.size()){ cout<<"assert stuff"; } result.resize(matrix.n); for(unsigned int i=0; i<matrix.n; ++i){ result[i]=0; for(unsigned int j=0; j<matrix.index[i].size(); ++j){ result[i]+=matrix.value[i][j]*x[matrix.index[i][j]]; } } } // perform result=result-matrix*x template<class T> void multiply_and_subtract(const SparseMatrix<T> &matrix, const std::vector<T> &x, std::vector<T> &result) { //assert(matrix.n==x.size()); if (matrix.n!=x.size()){ cout<<"assert stuff"; } result.resize(matrix.n); for(unsigned int i=0; i<matrix.n; ++i){ for(unsigned int j=0; j<matrix.index[i].size(); ++j){ result[i]-=matrix.value[i][j]*x[matrix.index[i][j]]; } } } //============================================================================ // Fixed version of SparseMatrix. This is not a good structure for dynamically // modifying the matrix, but can be significantly faster for matrix-vector // multiplies due to better data locality. template<class T> struct FixedSparseMatrix { unsigned int n; // dimension std::vector<T> value; // nonzero values row by row std::vector<unsigned int> colindex; // corresponding column indices std::vector<unsigned int> rowstart; // where each row starts in value and colindex (and last entry is one past the end, the number of nonzeros) explicit FixedSparseMatrix(unsigned int n_=0) : n(n_), value(0), colindex(0), rowstart(n_+1) {} void clear(void) { n=0; value.clear(); colindex.clear(); rowstart.clear(); } void resize(int n_) { n=n_; rowstart.resize(n+1); } void construct_from_matrix(const SparseMatrix<T> &matrix) { resize(matrix.n); rowstart[0]=0; for(unsigned int i=0; i<n; ++i){ rowstart[i+1]=rowstart[i]+matrix.index[i].size(); } value.resize(rowstart[n]); colindex.resize(rowstart[n]); unsigned int j=0; for(unsigned int i=0; i<n; ++i){ for(unsigned int k=0; k<matrix.index[i].size(); ++k){ value[j]=matrix.value[i][k]; colindex[j]=matrix.index[i][k]; ++j; } } } void write_matlab(std::ostream &output, const char *variable_name) { output<<variable_name<<"=sparse(["; for(unsigned int i=0; i<n; ++i){ for(unsigned int j=rowstart[i]; j<rowstart[i+1]; ++j){ output<<i+1<<" "; } } output<<"],...\n ["; for(unsigned int i=0; i<n; ++i){ for(unsigned int j=rowstart[i]; j<rowstart[i+1]; ++j){ output<<colindex[j]+1<<" "; } } output<<"],...\n ["; for(unsigned int i=0; i<n; ++i){ for(unsigned int j=rowstart[i]; j<rowstart[i+1]; ++j){ output<<value[j]<<" "; } } output<<"], "<<n<<", "<<n<<");"<<std::endl; } }; typedef FixedSparseMatrix<float> FixedSparseMatrixf; typedef FixedSparseMatrix<double> FixedSparseMatrixd; // perform result=matrix*x template<class T> void multiply(const FixedSparseMatrix<T> &matrix, const std::vector<T> &x, std::vector<T> &result) { if (matrix.n!=x.size()){ cout<<"assert stuff"; } result.resize(matrix.n); for(unsigned int i=0; i<matrix.n; ++i){ result[i]=0; for(unsigned int j=matrix.rowstart[i]; j<matrix.rowstart[i+1]; ++j){ result[i]+=matrix.value[j]*x[matrix.colindex[j]]; } } } // perform result=result-matrix*x template<class T> void multiply_and_subtract(const FixedSparseMatrix<T> &matrix, const std::vector<T> &x, std::vector<T> &result) { if (matrix.n!=x.size()){ cout<<"assert stuff"; } result.resize(matrix.n); for(unsigned int i=0; i<matrix.n; ++i){ for(unsigned int j=matrix.rowstart[i]; j<matrix.rowstart[i+1]; ++j){ result[i]-=matrix.value[j]*x[matrix.colindex[j]]; } } } #endif
[ "marten_heidemeyer@web.de" ]
marten_heidemeyer@web.de
1c9194558fea4344eb438dacc2106281781a7499
0399fff8bacf9e54442f7166a0561a7089cce1fe
/src/mmo/ast/composition.h
cc773f5f0f708a0582823e6529488edb9bec69e0
[]
no_license
mascha/qss-engine
a2a2b63703094becba5b31975092ca8985916601
0ff943707b1bc952b2f5e866c8bf27ffb98de5f2
refs/heads/master
2021-06-17T22:35:17.470498
2017-05-19T13:33:42
2017-05-19T13:33:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,906
h
/***************************************************************************** This file is part of QSS Solver. QSS Solver is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. QSS Solver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with QSS Solver. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ #ifndef AST_COMPOSITION_H_ #define AST_COMPOSITION_H_ #include <string> #include "../util/macros.h" #include "../util/util_types.h" #include "ast_node.h" #include "ast_types.h" class AST_CompositionElement_; using namespace std; /** * */ class AST_Composition_ : public AST_Node_ { public: /** * * @param el * @param cl */ AST_Composition_ (AST_ElementList el, AST_CompositionElementList cl); /** * */ DEFINE_CLASS_PRINTER(AST_Composition) ; /** * * @return */ AST_CompositionElementList compositionList () const; /** * * @return */ bool hasCompositionList (); /** * * @return */ AST_ElementList elementList () const; /** * * @return */ bool hasElementList (); /** * * @param */ void setExternalFunctionCall (AST_External_Function_Call); /** * * @return */ AST_External_Function_Call externalCall () const; /** * * @return */ bool hasExternalFunctionCall (); /** * * @param */ void setAnnotation (AST_ArgumentList); /** * * @return */ bool hasAnnotation (); /** * * @param visitor */ void accept (AST_Visitor visitor); private: AST_CompositionElementList _composition_list; AST_ElementList _element_list; AST_ArgumentList _annot; AST_External_Function_Call _ext; }; /** * */ class AST_CompositionElement_ : public AST_Node_ { public: /** * * @param eqs_algs */ AST_CompositionElement_ (AST_CompositionEqsAlgs eqs_algs); /** * * @param el */ AST_CompositionElement_ (AST_ElementList el); /** * */ DEFINE_CLASS_PRINTER(AST_CompositionElement) ; /** * * @return */ AST_CompositionEqsAlgs getEquationsAlgs (); /** * * @return */ AST_ElementList getElementList (); /** * * @return */ bool hasEquations (); /** * * @return */ bool hasStatements (); /** * * @return */ bool hasElements (); /** * * @param visitor */ void accept (AST_Visitor visitor); private: AST_CompositionEqsAlgs _eqs_algs; AST_ElementList _el; }; /** * */ class AST_CompositionEqsAlgs_ : public AST_Node_ { public: /** * @param eq */ AST_CompositionEqsAlgs_ (AST_EquationList eq); /** * * @param st */ AST_CompositionEqsAlgs_ (AST_StatementList st); /** * * @param st * @param initial */ AST_CompositionEqsAlgs_ (AST_StatementList st, bool initial); /** * * @param eq * @param initial */ AST_CompositionEqsAlgs_ (AST_EquationList eq, bool initial); /** * * @return */ AST_EquationList getEquations (); /** * * @return */ AST_StatementList getAlgorithms (); /** * * @return */ bool isInitial (); /** * * @return */ bool hasEquations (); /** * * @return */ bool hasStatements (); /** * * @param visitor */ void accept (AST_Visitor visitor); private: bool _initial; AST_EquationList _eq; AST_StatementList _st; }; /** * */ class AST_External_Function_Call_ : public AST_Node_ { public: /** * * @param * @param * @param * @param */ AST_External_Function_Call_ (AST_String, AST_Expression_ComponentReference, AST_Expression, AST_ArgumentList); /** * * @return */ AST_String language (); /** * * @return */ string languageString (); /** * * @return */ AST_ArgumentList annotation (); /** * * @return */ AST_ExpressionList args (); /** * * @return */ string name (); /** * * @return */ AST_Expression exp (); /** * * @return */ AST_Expression_ComponentReference componentReference (); /** * * @return */ bool hasComponentReference (); /** * * @param visitor */ void accept (AST_Visitor visitor); private: AST_String _lang; AST_ArgumentList _annot; AST_Expression_Call _call; AST_Expression _exp; AST_Expression_ComponentReference _cr; }; #endif /* AST_COMPOSITION_H_ */
[ "joaquin.f.fernandez@gmail.com" ]
joaquin.f.fernandez@gmail.com
8c5c91c639b41e31d86fca6f46b1bb9eb7612c85
a6ed6ea5ebe14517e0ce1a9b7ba293b481cc1abe
/prog_lab_4_2/Tree.h
71eb736a4238a3105dac80ab394d6639deb200b1
[]
no_license
RadiationX/ClionProjects
320c1e5a1be613d5d260b6c75b55da2d097f5011
3695271d84acd7a337e36930ed3fd4b455095030
refs/heads/master
2021-05-15T01:11:23.300882
2017-06-14T23:46:32
2017-06-14T23:46:32
56,440,201
0
0
null
null
null
null
UTF-8
C++
false
false
1,853
h
// // Created by radiationx on 10.05.17. // #ifndef PROG_LAB_4_2_TREE_H #define PROG_LAB_4_2_TREE_H #include "iostream" using namespace std; struct Node { int value; int size = 0; Node *nodes = NULL; }; class Tree { private: Node root; int capacity = 0; void add(Node &root, int value) { if (root.nodes == NULL) { root.nodes = new Node[capacity]; } if (root.size < capacity) { root.nodes[root.size].value = value; root.size++; } else { int minIndex = 0; for (int i = 1; i < capacity; i++) { if (root.nodes[minIndex].size != root.nodes[i].size) { minIndex = i; break; } } add(root.nodes[minIndex], value); } } void printTree(Node &root, int level) { for (int j = 0; j < level; j++) { if (j == level - 1) { cout << "+---"; } else { cout << "| "; } } cout << root.value << endl; for (int i = 0; i < root.size; i++) { level++; printTree(root.nodes[i], level); level--; } } int sum(Node &root) { int res = 0; res += root.value; for (int i = 0; i < root.size; i++) { res += sum(root.nodes[i]); } return res; } public: Tree(int capacity) { this->capacity = capacity; root.value = 0; } void add(int value) { add(root, value); } void printTree() { cout << "TREE:" << endl; printTree(root, 0); } int sum() { int res = sum(root); cout << "SUM VALUES: " << res << endl; return res; } }; #endif //PROG_LAB_4_2_TREE_H
[ "radiationx@yandex.ru" ]
radiationx@yandex.ru
ee840cc26d4f18d6f5d3951ba6a76c380eb8d508
69e2689bcfc9c876595b742d12013657662a6f65
/Codigo/WEMOS/Capбtulo 10/MQTTReleTemperatura/MQTTReleTemperatura.ino
b53fe3c2b214ae9e769c5358af42c01b9e5a9e12
[]
no_license
Marcombo/Processing-interfaces-de-usuario-aplicaciones-de-vision-artificial-IoT-Arduino-ESP8266
91ea44a1a1cb66d49c6a2bae9bf9ecd1fdcdcd9a
e54960281f387de5d09b4005650d6ee872205a7b
refs/heads/main
2023-02-17T05:35:52.555093
2021-01-11T10:08:06
2021-01-11T10:08:06
328,616,518
1
3
null
null
null
null
UTF-8
C++
false
false
2,525
ino
#include <SimpleDHT.h> #include <ESP8266WiFi.h> #include <PubSubClient.h> const char* ssid = "*************"; // SSID de la red WIFI a la que desea conectarse const char* password = "*******************"; // contraseña de dicha red const char* mqtt_server = "test.mosquitto.org"; const char* tema = "marcombo_iot_mqtt_panel"; WiFiClient clienteWIFI; PubSubClient clienteMQTT(clienteWIFI); int pinRele = 13; int pinDHT11 = 12; SimpleDHT11 dht11; byte temperatura = 0; byte humedad = 0; unsigned int tiempoAnterior; int intervaloEnviotemperatura = 2000; void setup() { pinMode(pinRele, OUTPUT); digitalWrite(pinRele, LOW); pinMode(pinDHT11, INPUT); Serial.begin(115200); //Inicializa la conexión WiFI Serial.print("Conectando a " + String(ssid) + " "); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(" Conectado"); //Establecerá el broker que se utilizará clienteMQTT.setServer(mqtt_server, 1883); //Establecerá la función a la que se va a llamar cuando llegue un mensaje del broker clienteMQTT.setCallback(callback); } void callback(char* tema_recibido, byte* contenido, unsigned int longitudContenido) { String mensaje = ""; Serial.print("Ha llegado un mensaje con el tema: "); Serial.print(tema_recibido); Serial.print(" y el contenido: "); for (int i = 0; i < longitudContenido; i++) { mensaje = mensaje + (char)contenido[i]; Serial.print((char)contenido[i]); } Serial.println(); //Activa o desactiva el rele if (mensaje == "ON"){ digitalWrite(pinRele, HIGH); clienteMQTT.publish(tema, "ON_CONFIRMADO", true); } else if (mensaje == "OFF"){ digitalWrite(pinRele, LOW); clienteMQTT.publish(tema, "OFF_CONFIRMADO", true); } } void loop() { //Establecerá la conexión con el broker while (!clienteMQTT.connected()) { Serial.print("Conectando al broker ..."); if (clienteMQTT.connect("wemos")) { Serial.println("Conectado al broker."); clienteMQTT.subscribe(tema); } else delay(5000); } if(millis() - tiempoAnterior > intervaloEnviotemperatura){ dht11.read(pinDHT11, &temperatura, &humedad, NULL); if (!isnan(temperatura)){ Serial.print((int)temperatura); Serial.println(" ºC, "); char tmp[4]; dtostrf((int)temperatura,0, 0, tmp); clienteMQTT.publish(tema, tmp, true); } tiempoAnterior = millis(); } // Cliente escuchando clienteMQTT.loop(); }
[ "ferri.fc@gmail.com" ]
ferri.fc@gmail.com
cbf191b4fc613a5a31ec9b9c6f2934fbb7a87e22
a453c287a016b1bb43163be667daa4a7b03c42f2
/main.cpp
7cf9b615eaec03acbd1555b439816e5f3c80af21
[]
no_license
kolisergej/parentheses
acc56b867efedaede25428f85994a2bcca9b7de9
399ed964edda61779d5e8a46a35f0ad552066e27
refs/heads/main
2023-03-13T23:11:56.921272
2021-03-07T13:13:43
2021-03-07T13:13:43
345,350,828
0
0
null
null
null
null
UTF-8
C++
false
false
5,162
cpp
#include <cassert> #include <iostream> #include <stack> #include <string> #include <unordered_set> #include <unordered_map> using namespace std; const string kInfinite{"Infinite"}; const unordered_map<char, char> kDict = { {'{', '}'}, {'(', ')'}, {'[', ']'} }; const unordered_set<char> kValues{'}', ')', ']'}; bool check_infinite(const string& input) { size_t first_open_idx = 0; while (first_open_idx < input.size() && !kDict.count(input[first_open_idx])) { ++first_open_idx; } stack<char> st; const auto check_ch = [&st, &input](size_t i) { const auto ch = input[i]; if (kDict.count(input[i])) { st.push(ch); return true; } if (!kValues.count(ch)) { return true; } if (!st.empty() && kDict.at(st.top()) == ch) { st.pop(); return true; } return false; }; for (size_t i = first_open_idx; i < input.size(); ++i) { if (!check_ch(i)) { return false; } } for (size_t i = 0; i < first_open_idx; ++i) { if (!check_ch(i)) { return false; } } return st.empty(); } string process_letters_only(const string& input) { string result; int start{-1}; size_t current_length{0}; for (size_t i = 0; i < input.size(); i++) { const auto ch = input[i]; if (kDict.count(ch) || kValues.count(ch)) { if (start != -1 && current_length > result.size()) { result = input.substr(start, current_length); } current_length = 0; start = -1; continue; } if (start == -1) { start = i; } ++current_length; } if (start != -1 && current_length > result.size()) { result = input.substr(start, current_length); } return result; } string process_with_parrs(const string& input) { int start{0}; int end{0}; stack<pair<char, int>> st; for (int i = 0; i < input.size(); ++i) { const auto ch = input[i]; if (kDict.count(ch)) { st.push(make_pair(ch, i)); } else if (kValues.count(ch)) { if (st.empty()) { continue; } const auto top = st.top(); if (kDict.at(top.first) == ch) { st.pop(); if (end == top.second) { end = i+1; } else if (top.second < start) { start = top.second; end = i+1; } else if (end - start < i - top.second) { start = top.second; end = i+1; } } else { stack<pair<char, int>>().swap(st); } } else if (i == end) { ++end; } } return input.substr(start, end-start); } string run(const string& input) { if (check_infinite(input)) { return kInfinite; } const string double_input = input + input; const string letters_only_max = process_letters_only(double_input); const string max_with_parrs = process_with_parrs(double_input); const string result = (letters_only_max.size() > max_with_parrs.size()) ? letters_only_max : max_with_parrs; // cout << "result: " << result << endl; return result; } int main() { assert(run("") == kInfinite); assert(run("aabbcc") == kInfinite); assert(run("[]") == kInfinite); assert(run("(){}") == kInfinite); assert(run("]h({hdb}b)[") == kInfinite); assert(run("[[b[aa]]]") == kInfinite); assert(run("]][[b[aa]") == kInfinite); assert(run("aaaa)((aaa)") == kInfinite); assert(run("]})") == ""); assert(run("[)") == ""); assert(run("())") == "()"); assert(run("((aa)") == "(aa)"); assert(run("[[]") == "[]"); assert(run("[[])") == "[]"); assert(run("}](){") == "(){}"); assert(run("aa)((aaaaa") == "(aaaaaaa)"); assert(run("((aaa)((aa)") == "(aaa)"); assert(run("aaaaaaa)") == "aaaaaaa"); assert(run("(aaaaaaa") == "aaaaaaa"); assert(run("((aa)(aa)") == "(aa)(aa)"); assert(run("(aa(aa)a(aa)a))") == "(aa(aa)a(aa)a)"); assert(run("((aa(aa)a(aa)a)") == "(aa(aa)a(aa)a)"); assert(run("(aa)aa(aa))") == "(aa)aa(aa)"); assert(run("(aa(aa)aa(aa)))") == "(aa(aa)aa(aa))"); assert(run("((aa)((aa)") == "(aa)"); assert(run("((aa)(aa)((aa)") == "(aa)(aa)"); assert(run("(aa))(aa))") == "(aa)"); assert(run("(aba))(aa))") == "(aba)"); assert(run("(aa)(aa))") == "(aa)(aa)"); assert(run("((a{a}bb)))") == "((a{a}bb))"); assert(run("sh(dh)}") == "sh(dh)"); assert(run("[[b[aa]]") == "[b[aa]]"); assert(run("[[b[aa]]]]") == "[[b[aa]]]"); assert(run("[[b[aa]]}") == "[b[aa]]"); assert(run("]h({hhh(b})b)[") == "[]h"); assert(run("]h({h(bb})b)[") == "[]h"); assert(run("]h({h(bbbb})b)[") == "bbbb"); assert(run("]h({hdd(b})b)[") == "[]h"); assert(run("[{({][)][)[{{]])])]])([)]{((}}[") == ""); assert(run(")[{({][)][)[{{]])])]])([)]{((}}[(") == "()"); return 0; }
[ "kolisergej@yandex.ru" ]
kolisergej@yandex.ru
49faf70bbeef6e7075e98a8e9b733a8c68289c57
f6858055f3f619400ba432ec3c2f2e585c244f83
/Source/ProjectOglowia/Private/CommonUtils.cpp
95c29ca440f476f22612f1bf2faa4691b467a295
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
mrG7/peacenet-ue
87e2253bc5566f30061e2cf269b2dd3c59088a6b
a865ea26983dc2930b39a377745210b9d38e9936
refs/heads/master
2020-03-31T16:23:24.605729
2018-10-08T20:42:09
2018-10-08T20:42:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,156
cpp
// Copyright (c) 2018 The Peacenet & Alkaline Thunder. #include "CommonUtils.h" FText UCommonUtils::GetFriendlyFilesystemStatusCode(const EFilesystemStatusCode InStatusCode) { switch (InStatusCode) { case EFilesystemStatusCode::OK: return FText(); case EFilesystemStatusCode::DirectoryNotEmpty: return NSLOCTEXT("Peacegate", "DirectoryNotEmpty", "Directory not empty."); case EFilesystemStatusCode::FileOrDirectoryExists: return NSLOCTEXT("Peacegate", "FileOrDirectoryExists", "File or directory exists."); case EFilesystemStatusCode::FileOrDirectoryNotFound: return NSLOCTEXT("Peacegate", "FileOrDirectoryNotFound", "File or directory not found."); case EFilesystemStatusCode::PermissionDenied: return NSLOCTEXT("Peacegate", "PermissionDenied", "Permission denied."); default: return NSLOCTEXT("Peacegate", "UnknownError", "An unknown error has occurred."); } } UPeacegateFileSystem * UCommonUtils::CreateFilesystem(UPARAM(Ref)TScriptInterface<IFolderRepository> InFolderRepo, int InUserID) { UPeacegateFileSystem* FS = NewObject<UPeacegateFileSystem>(); FS->FolderRepo = InFolderRepo; FS->Initialize(InUserID); return FS; }
[ "31224503+TheFuzzyRiolu@users.noreply.github.com" ]
31224503+TheFuzzyRiolu@users.noreply.github.com
ae235273052a5ff7fbd3c765bf645fcb09c0e075
3435446327127f8dff815c1af5223f3d58c5243a
/Source/Voxel/VoxelHUD.h
ee41c18127eb81db645abfb8abd6e941ae658fa0
[]
no_license
azy2/UEVoxel
83b5d2b45fde3db26d89e3d27873a0b950e6d570
01869ede5d0d1e18cf448539f1e16a54248bef6b
refs/heads/master
2021-05-08T00:44:41.692418
2017-10-23T14:26:54
2017-10-23T14:26:54
107,699,590
1
0
null
null
null
null
UTF-8
C++
false
false
401
h
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "GameFramework/HUD.h" #include "VoxelHUD.generated.h" UCLASS() class AVoxelHUD : public AHUD { GENERATED_BODY() public: AVoxelHUD(); /** Primary draw call for the HUD */ virtual void DrawHUD() override; private: /** Crosshair asset pointer */ class UTexture2D* CrosshairTex; };
[ "Ben Lambeth" ]
Ben Lambeth
3e853920e96631cb90faf26277adcb7cbd5fbf4c
9889e7fd73314382fb2f9e8f63d92cf3254b75fb
/ThirdParty/NairnMPMFEA/Common/System/LinkedObject.hpp
9299a6cb0be0d35913ee273c7f8eaeeed6e1bdb0
[]
no_license
bbanerjee/ParSim
0b05f43cff8e878658dc179b4a604eabd873f594
87f87816b146f40013a5e6648dfe20f6d2d002bb
refs/heads/master
2023-04-27T11:30:36.252023
2023-04-13T22:04:50
2023-04-13T22:04:50
13,608,512
16
3
null
null
null
null
UTF-8
C++
false
false
607
hpp
/******************************************************************************** LinkedObject.hpp NairnFEA Created by John Nairn on 6/22/05. Copyright (c) 2005 John A. Nairn, All rights reserved. Dependencies none ********************************************************************************/ #ifndef _LINKEDOBJECT_ #define _LINKEDOBJECT_ class LinkedObject { public: LinkedObject *nextObject; // Constructors and Destructor LinkedObject(); // methods void SetNextObject(LinkedObject *); LinkedObject *GetNextObject(void) const; }; #endif
[ "b.banerjee.nz@gmail.com" ]
b.banerjee.nz@gmail.com
aba2db8b417c1c0aa04e272085db37056dcb3ed4
042983c6b28fd12d37652bc90390b0e59ee71c4d
/source/tools/new_triangulation/LinearAlgebra/SparseMatrix.ipp
bf7742ae6f3990f6730b4aa79dd996134f50980e
[]
no_license
cigarfish/latticeCollagen
26718aae8cb5a9c6ade428d1e6fd47abe3b71348
74ac165a2e63f8f0aa7501ce8c6568ac8a407d9e
refs/heads/master
2020-03-21T23:07:33.057342
2018-10-11T16:03:01
2018-10-11T16:03:01
139,167,691
0
0
null
null
null
null
UTF-8
C++
false
false
3,538
ipp
/* * SparseMatrix.tcc * * Created on: Oct 27, 2010 * Author: jagiella */ #include <stdlib.h> #include <stdio.h> #include <assert.h> //#include "Mathematix.h" #include "SparseMatrix.hpp" #ifndef NULL #define NULL 0 #endif template <class T> SparseMatrix<T>::SparseMatrix( int m, int n) { A = (SparseVector<T>**) malloc( m * sizeof(SparseVector<T>**)); // values assert( A); for( int i=0; i<m; i++){ A[i] = new SparseVector<T>( n); // values assert( A[i]); } this->m = m; this->n = n; } template <class T> SparseMatrix<T>::~SparseMatrix() { for( int i=0; i<m; i++){ delete A[i]; } free( A); } template <class T> T SparseMatrix<T>::get( int i, int j) { return A[i]->get( j); } template <class T> T& SparseMatrix<T>::getNonZero( int i, int jj) { return A[i]->getNonZero( jj); } template <class T> int SparseMatrix<T>::getNonZeroIndex( int i, int jj) { return A[i]->getNonZeroIndex( jj); } template <class T> void SparseMatrix<T>::resetRow( int i) { A[i]->reset(); } template <class T> void SparseMatrix<T>::setLast( int i, int j, T value) { if( value == 0.) return; A[i]->set( j, value); } template <class T> void SparseMatrix<T>::set( int i, int j, T value) { A[i]->set(j, value); } template <class T> void SparseMatrix<T>::setNonZero( int i, int jj, T value) { A[i]->setNonZero(jj, value); } template <class T> void SparseMatrix<T>::add( int i, int j, T value) { A[i]->add( j, value); } template <class T> void SparseMatrix<T>::MatrixVectorProduct( SparseMatrix<T> *A, T *b, T *x) { //x = A*b // (n x m) * (m x p) = (n x p) // (i x j) * (j x 1) = (i x 1) for( int i=0; i<A->m; i++){ x[i] = 0.; for( int jj=0; jj<A->A[i]->lengthNonZero(); jj++){ int j = A->A[i]->getNonZeroIndex(jj); x[i] += A->A[i]->getNonZero(jj) * b[j]; } } } template <class T> void SparseMatrix<T>::VectorMatrixProduct( T *b, SparseMatrix<T> *A, T *x) { //x = b*A // (n x m) * (m x p) = (n x p) // (1 x i) * (i x j) = (1 x j) //int jj = 0; for( int j=0; j<A->dimI; j++) x[j] = 0.; for( int i=0; i<A->dimI; i++){ for( int jj=0; jj<A->sizeA[i]; jj++){ int j = A->JA[i][jj]; x[j] += b[i] * A->A[i][jj]; /* #if DEBUG > 0 if( isnan(x[j])){ fprintf( stderr, "nan occures in vectorsparseMatrixProduct\n"); fprintf( stderr, "vector b[%i] = %lf\n", i, b[i]); for( int jj=0; jj<sA->sizeA[i]; jj++){ j = sA->JA[i][jj]; fprintf( stderr, "matrix A[%i][%i] = %lf\n", i, j, sA->A[i][jj]); } exit( 0); } #endif */ } } } template <class T> void SparseMatrix<T>::printMatrix( const char* name, const char* format) { fprintf( stderr, "\"%s\" = [\n", name); for( int i=0; i<m; i++) { for( int j=0; j<n; j++) { fprintf( stderr, format, this->get(i,j)); } fprintf( stderr, "\n"); } fprintf( stderr, "]\n"); } template <class T> int SparseMatrix<T>::columns() { return n; } template <class T> int SparseMatrix<T>::columnsNonZero( int i) { return A[i]->lengthNonZero(); } template <class T> int SparseMatrix<T>::rows() { return m; } template <class T> T& SparseMatrix<T>::operator() ( int i, int j) { return (*A[i])(j);//this->get( i, j); } template <class T> void SparseMatrix<T>::operator() ( int i, int j, T value) { this->set( i, j, value); } template <class T> SparseMatrix<T>* SparseMatrix<T>::copy() { SparseMatrix<T>* copy = new SparseMatrix<T>( m, n); for( int i=0; i<m; i++) for( int jj=0; jj<A[i]->lengthNonZero(); jj++){ copy->setLast( i, A[i]->getNonZeroIndex(jj), A[i]->getNonZero(jj)); } return copy; }
[ "zhaojielingzjl@yahoo.com" ]
zhaojielingzjl@yahoo.com
d7f1cee2bc24ce7af551c3cabea8ffc429f56e2d
01acd836f3788aba78e9eeb97fba171f0eaa0128
/1 restart/new3.cpp
d8e2e2b6707759c40d9ff8bea59e941ba57d9ae2
[]
no_license
bagilder/Nixie
ec170ee27584425806a054364323c82c92d62080
92bc18d2e535228f53f4ca8c690b4e9b36e15f34
refs/heads/master
2023-06-01T15:12:09.331828
2023-05-18T04:31:14
2023-05-18T04:31:14
122,246,237
0
0
null
null
null
null
UTF-8
C++
false
false
6,553
cpp
/* new3.cpp brian gilder did a thing 22dec2016 this is a new attempt to nixie clock it up, this time with 60% more ions. uses the time.h library and internal arduino oscillator */ /********** notes *********** **can implement interrupts to set seconds etc. although if we're using time.h, it doesn't really ** matter how often we update our output registers since the internal timekeeping is still accurateish without ** needing our involvement. maybe we don't need interrupts at all. **we could use interrupts to update the lamps using whatever is the current register set. so we have consistent timing ** on lighting them up. but since we are using time.h, we have nothing but free time. timekeeping is basically ** already finished. we just have to update our registers and then animate the hours. this problem becomes pretty trivial. damn. **perhaps the hourAnimate can use the interrupt. that way, we don't need to poll for a flag. now i just need to learn interrupts. ** ** *****************************/ #include <time.h> #include <TimerOne.h> #include <stdio.h> //this isn't a thing in arduino is it?. arduino is meant to be io //**********programmer defined*************** const digitLength = 6; //either 6 or 4 depending on whether there are seconds digits or not const PowerMuxTop = 10; //number of pin at the top of the power mux series of output pins. should descend in number from here to use current sign scheme in setup loop //******************************************* int isSet = 0; int hourAnimate = 0; // need to write the trigger for this. or get rid of it and assign an interrupt for that condition int current_h = 0; int current_m = 0; int current_s = 0; int disp_hHi = 0; int disp_hLo = 0; int disp_mHi = 0; int disp_mLo = 0; int disp_sHi = 0; int disp_sLo = 0; char portHax[5] = 0; long time_t = 0; // long t = 0; // does this need to exist? idk how the time.h library works short portBin[9] = {B00000000,B00010000,B00100000,B00110000,B01000000,B01010000,B01100000,B01110000,B10000000,B10010000}; //reorganize depending on how we pin driver //might not use if we go with switchcase for porthax //can we use shorts to store B's? are those not considered letters? since it's for encoding schemes? void setup() { delay(500); Serial.begin(9600); /*for(int i = 0, i<digit_length; i++) { //did we determine whether loops were allowed in setup? if no, just powermuxtop - 1, - 2 etc pinMode(PowerMuxTop - i, OUTPUT); //make + if going in different direction on port } */ DDRD = DDRD | B11111100; //sets port D as outputs. erase this and uncomment above loop if not port haxing } void loop() { /* while(!isSet) // should we have the while at this level? atm there are two while loops { setBlink(); } */ time_t t = now(); //is time_t a thing in the time.h library? or does it need a type declaration? // is the t a straggler or is it supposed to be there? if so, instantiate it current_h = hour(t); current_m = minute(t); current_s = second(t); disp_hHi = current_h/10; disp_hLo = current_h%10; disp_mHi = current_m/10; disp_mLo = current_m%10; disp_sHi = current_s/10; disp_sLo = current_s%10; disp_send = {disp_hHi,disp_hLo,disp_mHi,disp_mLo,disp_sHi,disp_sLo}; displayUpdate(); } void displayUpdate(){ if(hourAnimate) // can eliminate this flag poll (ha get it) if we use an interrupt for new hour condition hourRoll(); else { for(int j = 0; j <s 6; i++) { // portHax[j] = //don't remember what i was doing here. maybe it's instead of the switchcase? } int q = 0; for(int i = 0; i < digitLength; i++) //this immediately sets the output port binary for tube driver { /* //i'm an idiot. why else would i have portBin if not for this purpose. the indeces even work with the numbers switch(disp_send[i]) { //there is surely a more elegant way to do this /////SPOILERS THERE IS use portBin you dummy case 0: PORTD = B00000000; break; case 1: PORTD = B00010000; break; case 2: PORTD = B00100000; break; case 3: PORTD = B00110000; break; case 4: PORTD = B01000000; break; case 5: PORTD = B01010000; break; case 6: PORTD = B01100000; break; case 7: PORTD = B01110000; break; case 8: PORTD = B10000000; break; case 9: PORTD = B10010000; break; } */ q = disp_send[i]; //goes through each position of disp_send and gets value for q PORTD = portBin[q]; //sets port d to corresponding binary for q value i hope. index already matches values (convenient) //will i need a delay here before toggling on? i think probably not if i'm port hacking. that's way faster than digital write digitalWrite(PowerMuxTop - i, HIGH); delay(muxDelay/2); digitalWrite(PowerMuxTop - i, LOW); delay(muxDelay/2); } } } // do we need to do what follows with pointers or can we return an array at the end? // do we even need to do this or should we have a lookup table? i'll make a table anyway // especially since this returns an array. would i need to concatinate it to make it a number again? int dec2bin(int a) { //this is probably superfluous now that i've made the switchcase int c, k, b[4]; for(c = 4; c>=0; c--) { k = a >> c; if (k & 1) b[c] = 1; else b[c] = 0; } return b; } // is itoa(value,outputstring,base) an actual thing? output string suggests more type conversion but w/e void hourRoll() { //fancy hour animations //use the old stuff from other versions. they mostly worked alright. /* more ideas: -could have them scroll out one side and then scroll in the other. (like a lame powerpoint transition) -could have them roll, but one at a time. like secLow rolls through all 10 numbers, then stops, then secHi goes, etc down the line -could have them flash randomish numbers until it lands on the correct one. either in series or randomly */ } // setBlink should probably be eliminated in favor of flashing a string of 0s on and off until the // time is set. that way, there isn't accidentally a 888888 starting point that is being adjusted void setBlink() { while(!is_set) // might be able just to use an interrupt to quit this loop /////YOU CAN!!! { disp_string = {0,0,0,0,0,0}; //have not defined disp_string before now. maybe use disp_send delay(1000); //some_phantom_button_check_or_something(); //use an interrupt if arduino can handle it /////IT CAN! disp_string = {8,8,8,8,8,8}; delay(1000); //some_phantom_button_check_or_something(); } }
[ "bagilder@users.noreply.github.com" ]
bagilder@users.noreply.github.com
ef9f6f883092d303072536d9d8fdb3c04d82b219
dd80a584130ef1a0333429ba76c1cee0eb40df73
/external/chromium/webkit/glue/media/simple_data_source.h
2c4075af7e7bc562b54f68327f9b5787d438e0e9
[ "BSD-3-Clause", "MIT" ]
permissive
karunmatharu/Android-4.4-Pay-by-Data
466f4e169ede13c5835424c78e8c30ce58f885c1
fcb778e92d4aad525ef7a995660580f948d40bc9
refs/heads/master
2021-03-24T13:33:01.721868
2017-02-18T17:48:49
2017-02-18T17:48:49
81,847,777
0
2
MIT
2020-03-09T00:02:12
2017-02-13T16:47:00
null
UTF-8
C++
false
false
4,926
h
// 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. // An extremely simple implementation of DataSource that downloads the entire // media resource into memory before signaling that initialization has finished. // Primarily used to test <audio> and <video> with buffering/caching removed // from the equation. #ifndef WEBKIT_GLUE_MEDIA_SIMPLE_DATA_SOURCE_H_ #define WEBKIT_GLUE_MEDIA_SIMPLE_DATA_SOURCE_H_ #include <algorithm> #include <string> #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "media/base/filter_factories.h" #include "media/base/filters.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoader.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderClient.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" #include "webkit/glue/media/web_data_source.h" class MessageLoop; class WebMediaPlayerDelegateImpl; namespace webkit_glue { class SimpleDataSource : public WebDataSource, public WebKit::WebURLLoaderClient { public: // Creates a DataSourceFactory for building SimpleDataSource objects. static media::DataSourceFactory* CreateFactory( MessageLoop* render_loop, WebKit::WebFrame* frame, WebDataSourceBuildObserverHack* build_observer); SimpleDataSource(MessageLoop* render_loop, WebKit::WebFrame* frame); virtual ~SimpleDataSource(); // media::Filter implementation. virtual void set_host(media::FilterHost* host); virtual void Stop(media::FilterCallback* callback); // media::DataSource implementation. virtual const media::MediaFormat& media_format(); virtual void Read(int64 position, size_t size, uint8* data, ReadCallback* read_callback); virtual bool GetSize(int64* size_out); virtual bool IsStreaming(); virtual void SetPreload(media::Preload preload); // Used to inject a mock used for unittests. virtual void SetURLLoaderForTest(WebKit::WebURLLoader* mock_loader); // WebKit::WebURLLoaderClient implementations. virtual void willSendRequest( WebKit::WebURLLoader* loader, WebKit::WebURLRequest& newRequest, const WebKit::WebURLResponse& redirectResponse); virtual void didSendData( WebKit::WebURLLoader* loader, unsigned long long bytesSent, unsigned long long totalBytesToBeSent); virtual void didReceiveResponse( WebKit::WebURLLoader* loader, const WebKit::WebURLResponse& response); virtual void didDownloadData( WebKit::WebURLLoader* loader, int dataLength); virtual void didReceiveData( WebKit::WebURLLoader* loader, const char* data, int dataLength, int encodedDataLength); virtual void didReceiveCachedMetadata( WebKit::WebURLLoader* loader, const char* data, int dataLength); virtual void didFinishLoading( WebKit::WebURLLoader* loader, double finishTime); virtual void didFail( WebKit::WebURLLoader* loader, const WebKit::WebURLError&); // webkit_glue::WebDataSource implementation. virtual void Initialize(const std::string& url, media::PipelineStatusCallback* callback); virtual void CancelInitialize(); virtual bool HasSingleOrigin(); virtual void Abort(); private: // Updates |url_| and |media_format_| with the given URL. void SetURL(const GURL& url); // Creates and starts the resource loading on the render thread. void StartTask(); // Cancels and deletes the resource loading on the render thread. void CancelTask(); // Perform initialization completion tasks under a lock. void DoneInitialization_Locked(bool success); // Update host() stats like total bytes & buffered bytes. void UpdateHostState(); // Primarily used for asserting the bridge is loading on the render thread. MessageLoop* render_loop_; // A webframe for loading. WebKit::WebFrame* frame_; // Does the work of loading and sends data back to this client. scoped_ptr<WebKit::WebURLLoader> url_loader_; media::MediaFormat media_format_; GURL url_; std::string data_; int64 size_; bool single_origin_; // Simple state tracking variable. enum State { UNINITIALIZED, INITIALIZING, INITIALIZED, STOPPED, }; State state_; // Used for accessing |state_|. base::Lock lock_; // Filter callbacks. scoped_ptr<media::PipelineStatusCallback> initialize_callback_; // Used to ensure mocks for unittests are used instead of reset in Start(). bool keep_test_loader_; DISALLOW_COPY_AND_ASSIGN(SimpleDataSource); }; } // namespace webkit_glue #endif // WEBKIT_GLUE_MEDIA_SIMPLE_DATA_SOURCE_H_
[ "karun.matharu@gmail.com" ]
karun.matharu@gmail.com
72b19656e8a6959dbd15f273f3531a52203e599b
d7784cb9ce174ec5091d327b21ebcf4c6c507388
/yukicoder/349_352/349.cpp
82680ccd77b63f120194d7217da11346e8eb0f09
[]
no_license
mmxsrup/procon
3a349b10c852ad593ecedcdd1c9fdb93cb8d8f3b
af059cc3f6786db71f0077d1ec5d902171b9860a
refs/heads/master
2021-01-17T15:05:05.580007
2017-12-06T07:52:53
2017-12-06T07:52:53
84,103,106
0
0
null
null
null
null
UTF-8
C++
false
false
1,414
cpp
/* 一番多い者に着目すればいける */ #include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <bitset> #include <map> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> using namespace std; typedef long long ll; typedef pair<int,int> pint; typedef vector<int> vint; typedef vector<pint> vpint; #define mp make_pair #define fi first #define se second #define all(v) (v).begin(),(v).end() #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) int dx[4] = {1, 0, 0, -1}; int dy[4] = {0, 1, -1, 0}; int main(void){ int n; char eto[51][51]; char eto_template[15][15] = {"ne", "ushi", "tora", "u", "tatsu", "mi", "uma", "hitsuji", "saru", "tori", "inu", "i"}; int eto_num[12] = {0}; scanf("%d", &n); rep(i, n){ scanf("%s", eto[i]); rep(j, 12){ /*if (eto[i] == eto_template[j]) eto_num[j]++;*/ if (strcmp(eto[i], eto_template[j]) == 0) //同じなら0を返す { eto_num[j]++; } } } //かぶりが一番多いものを探す int max_num = 0; rep(i, 12) max_num = max(max_num, eto_num[i]); if (n - max_num >= max_num - 1) //かぶりがいちばん多い者を並べて、その間に他のものをいれられるだけ干支が残っていればいい printf("YES\n"); else printf("NO\n"); return 0; }
[ "mmxsrup@yahoo.co.jp" ]
mmxsrup@yahoo.co.jp
8fcd5b8e974b6e07b21891115ff4aa7b0a3ae2d7
4da239317dbe41bdfd2e1982d2564c12b5a757f4
/单一深度图/单一深度图/main.cpp
b9a7738f5936b0ec67ae513ffe755ec797d65d5b
[]
no_license
Vincent-2017/Kinect2.0
6433bc6913ded7e57a53e4c46da9668d479025a6
d1a921db58b4d3219bb3f4681931e1f8b7734115
refs/heads/master
2021-01-01T06:09:04.851453
2017-08-02T12:19:03
2017-08-02T12:19:03
97,370,573
3
1
null
null
null
null
GB18030
C++
false
false
2,328
cpp
#include <Kinect.h> //Kinect的头文件 #include <iostream> #include <opencv2\imgproc.hpp> //opencv头文件 #include <opencv2\calib3d.hpp> #include <opencv2\highgui.hpp> using namespace std; using namespace cv; //获得某点像素值 int get_pixel(Mat & img, Point pt) { int width = img.cols; //图片宽度 int height = img.rows; //图片宽度t;//图片高度 uchar* ptr = (uchar*)img.data + pt.y * width; //获得灰度值数据指针 int intensity = ptr[pt.x]; return intensity; } int main(void) { IKinectSensor* KinectSensor = nullptr; GetDefaultKinectSensor(&KinectSensor); //获取感应器 KinectSensor->Open(); //打开感应器 cout << "打开Kinect传感器" << endl; cout << endl; IDepthFrameSource * DepthSource = nullptr; //取得深度数据 KinectSensor->get_DepthFrameSource(&DepthSource); int height = 0, width = 0; IFrameDescription * myDescription = nullptr; //取得深度数据的分辨率 DepthSource->get_FrameDescription(&myDescription); myDescription->get_Height(&height); myDescription->get_Width(&width); cout <<"深度图像大小是:"<< height << " * " << width << endl; myDescription->Release(); IDepthFrameReader * DepthReader = nullptr; DepthSource->OpenReader(&DepthReader); //打开深度数据的Reader IDepthFrame * myFrame = nullptr; Mat temp(height, width, CV_16UC1); //建立图像矩阵 Mat img(height, width, CV_8UC1); while (1) { if (DepthReader->AcquireLatestFrame(&myFrame) == S_OK) //通过Reader尝试获取最新的一帧深度数据,放入深度帧中,并判断是否成功获取 { //原始UINT16 深度图像不适合用来显示,所以需要砍成8位的就可以了 myFrame->CopyFrameDataToArray(height * width, (UINT16 *)temp.data); //先把数据存入16位的图像矩阵中 temp.convertTo(img, CV_8UC1, 255.0 / 4500); //再把16位转换为8位 cout << get_pixel(img, Point(200, 200)) << endl; imshow("Depth", img); myFrame->Release(); } //POINT pt; //GetCursorPos(&pt); //cout << "当前的鼠标坐标为:" << pt.x << "," << pt.y << endl; if (waitKey(30) == VK_ESCAPE) break; } DepthReader->Release(); //释放不用的变量并且关闭感应器 DepthSource->Release(); KinectSensor->Close(); KinectSensor->Release(); return 0; }
[ "1156767986@qq.com" ]
1156767986@qq.com
58e61bfcc84e28cdbfcccf1fbfff6d23fd62587f
b02dfd153360607a5260c13e48b5a84a866c5353
/include/suic/Framework/Controls/Popup.h
f0f2b7e40f4388d81e52250b259812b685ee1828
[]
no_license
15831944/MPF
7fb54842612a91c4c05cb555c0b065512830f8c9
21e6169b5d1797dfbdfd46ff5a832221ba86b61e
refs/heads/master
2022-03-26T16:32:23.562737
2016-11-12T01:34:41
2016-11-12T01:34:41
null
0
0
null
null
null
null
GB18030
C++
false
false
5,754
h
// 华勤科技版权所有 2010-2011 // // 文件名:Popup.h // 功 能:实现标准的弹出窗口(无焦点)。 // // 作 者:MPF开发组 // 时 间:2010-07-02 // // ============================================================================ #ifndef _UIPOPUP_H_ #define _UIPOPUP_H_ #include <Framework/Controls/Content.h> namespace suic { enum PlacementMode { pmLeft, pmTop, pmRight, pmBottom, pmCenter, pmMouse, pmMousePoint, pmCustom, }; struct SUICORE_API PlacementModeBox { static Integer* LeftBox; static Integer* TopBox; static Integer* RightBox; static Integer* BottomBox; static Integer* CenterBox; static Integer* MouseBox; static Integer* MousePointBox; static Integer* CustomBox; static Integer* From(int index); }; struct PositionInfo { int x; int y; fSize ChildSize; Rect MouseRect; }; class SUICORE_API PopupRoot : public FrameworkElement { public: PopupRoot(); ~PopupRoot(); RTTIOfClass(PopupRoot) Element* GetChild(); void SetChild(Element* elem); int GetVisualChildrenCount(); Element* GetVisualChild(int index); Element* GetLogicalChild(int index); int GetLogicalChildrenCount(); protected: void OnTextInput(KeyboardEventArg* e); void OnKeyDown(KeyboardEventArg* e); void OnKeyUp(KeyboardEventArg* e); void SetupLayoutBindings(Popup* popup); fSize ComputeChildDesiredSize(fSize restrictedSize); fSize ComputePopupSizeRestrictions(Popup* popup, fSize desiredSize, bool& bWidth, bool& bHeight); friend class Popup; public: fSize OnMeasure(const fSize& constraintSize); void OnArrange(const fSize& arrangeSize); private: Element* _child; }; class OpeningEventArg : public EventArg { public: OpeningEventArg(HwndParam* hp) : _hp(hp) { } HwndParam* GetHwndParam() const { return _hp; } private: HwndParam* _hp; }; typedef delegate<void(Object*, OpeningEventArg*), suic::UnrefObj> OpeningEventHandler; class SUICORE_API Popup : public FrameworkElement, public IAddChild { public: EventHandler Closed; EventHandler Opened; EventHandler Closing; OpeningEventHandler Opening; static DpProperty* ChildProperty; static DpProperty* IsOpenProperty; static DpProperty* CoercedPosProperty; static DpProperty* PlacementProperty; static DpProperty* PlacementRectangleProperty; static DpProperty* PlacementTargetProperty; static DpProperty* VerticalOffsetProperty; static DpProperty* HorizontalOffsetProperty; static DpProperty* AllowsTransparencyProperty; static bool StaticInit(); static void CreateRootPopup(Popup* popup, Element* child); static void OnChildPropChanged(DpObject* d, DpPropChangedEventArg* e); static void OnIsOpenPropChanged(DpObject* d, DpPropChangedEventArg* e); static void OnPlacementPropChanged(DpObject* d, DpPropChangedEventArg* e); static void OnOffsetPropChanged(DpObject* d, DpPropChangedEventArg* e); static void OnPlacementTargetPropChanged(DpObject* d, DpPropChangedEventArg* e); static void OnAllowsTransparencyPropChanged(DpObject* d, DpPropChangedEventArg* e); Popup(); ~Popup(); RTTIOfClass(Popup) void Hide(); void Show(Point pt); void Close(); void AsyncClose(); bool IsClosing(); PopupRoot* GetPopupRoot(); PositionInfo* GetPositionInfo(); Element* GetChild(); void SetChild(Element* elem); void InvalidatePopupRoot(); void TrackingPopup(MessageHook& hook=MessageHook()); bool IsOpen(); void SetIsOpen(bool val); bool GetCoercedPos(); void SetCoercedPos(bool val); PlacementMode GetPlacement(); void SetPlacement(PlacementMode val); Rect GetPlacementRectangle(); void GetPlacementRectangle(Rect val); Element* GetPlacementTarget(); void SetPlacementTarget(Element* target); int GetVerticalOffset(); void SetVerticalOffset(int val); int GetHorizontalOffset(); void SetHorizontalOffset(int val); bool AllowsTransparency(); void SetAllowsTransparency(bool val); bool IsChildPopup(); void SetChildPopup(bool value); Popup* GetParentPopup(); void SetParentPopup(Popup* val); public: void AddChild(Object* obj); void AddText(String val); void RemoveChild(Object* child); virtual void OnClosing(CancelEventArg& e); virtual void OnClosed(EventArg* e); virtual void OnOpened(EventArg* e); virtual bool OnShowingWindow(); virtual void OnShowWindow(); virtual void OnHideWindow(); virtual bool OnFilterMessage(Object* sender, MessageParam* mp, bool& interrupt); virtual bool OnSysFilterMessage(Object* sender, MessageParam* mp, bool& interrupt); protected: fSize OnMeasure(const fSize& constratint); void OnArrange(const fSize& arrangeSize); void OnHitTest(HitResultEventArg* e); void OnMouseWheel(MouseWheelEventArg* e); void OnMouseLeftButtonDown(MouseButtonEventArg* e); void OnMouseRightButtonDown(MouseButtonEventArg* e); void OnTextInput(KeyboardEventArg* e); void OnKeyDown(KeyboardEventArg* e); void OnKeyUp(KeyboardEventArg* e); protected: Element* GetTarget(); void InternalClose(bool async); int InternalCreate(int wid, int hei); bool BlockVisualState(); void EnsurePopupRoot(); void ComputePosition(fSize desiredSize); protected: bool _onMouseIn; bool _onTimer; bool _onDownClose; bool _isMouseIn; bool _isClosing; Popup* _parentPopup; PopupRoot* _popupRoot; AssignerFrame* _frame; PositionInfo _positionInfo; }; typedef shared<Popup> PopupPtr; } #endif
[ "china0851@foxmail.com" ]
china0851@foxmail.com
4d68711f36a2aa98a686188398cd19bad7294a26
f5cd4aa57470c77530f83ae0fdad58c9ceb865b4
/tests/core_tests/chain_split_1.h
87e0545e67ea52f3265220ed6476463b5d1dfcc6
[ "BSD-3-Clause" ]
permissive
weirdboy79/fonero
4ff23ddeb4b53cb8f4d5029e85b31ee07685648d
80d5aa64b4a7329222954d504e5d99e3fdd48159
refs/heads/master
2020-03-10T07:38:57.850114
2018-04-11T15:31:50
2018-04-11T15:31:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,120
h
// Copyright (c) 2017-2018, The Fonero Project. // Copyright (c) 2014-2017 The Fonero Project. // Portions Copyright (c) 2012-2013 The Cryptonote developers. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDER 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. // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #pragma once #include "chaingen.h" /************************************************************************/ /* */ /************************************************************************/ class gen_simple_chain_split_1 : public test_chain_unit_base { public: gen_simple_chain_split_1(); bool generate(std::vector<test_event_entry> &events) const; bool check_split_not_switched(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_split_not_switched2(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_split_switched(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_split_not_switched_back(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_split_switched_back_1(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_split_switched_back_2(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_mempool_1(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_mempool_2(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); /*bool check_orphaned_chain_1(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_orphaned_switched_to_alternative(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_orphaned_chain_2(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_orphaned_switched_to_main(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_orphaned_chain_38(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_orphaned_chain_39(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_orphaned_chain_40(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); bool check_orphaned_chain_41(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry> &events); */ private: };
[ "dev@fonero.org" ]
dev@fonero.org
4e8f688d44131f4c063c4d0b1532f6c61199165e
444a9480bce2035565332d4d4654244c0b5cd47b
/research/cv/StackedHourglass/infer/mxbase/src/Hourglass.h
e7771d2e39a2e98c67eff0b5e9c69458ce2d7973
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-proprietary-license" ]
permissive
mindspore-ai/models
7ede9c6454e77e995e674628204e1c6e76bd7b27
eab643f51336dbf7d711f02d27e6516e5affee59
refs/heads/master
2023-07-20T01:49:34.614616
2023-07-17T11:43:18
2023-07-17T11:43:18
417,393,380
301
92
Apache-2.0
2023-05-17T11:22:28
2021-10-15T06:38:37
Python
UTF-8
C++
false
false
2,262
h
/* * Copyright 2022 Huawei Technologies Co., Ltd * * 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 MXBASE_HOURGLASS_H #define MXBASE_HOURGLASS_H #include <dirent.h> #include <sys/stat.h> #include <string> #include <vector> #include <memory> #include <opencv4/opencv2/core.hpp> #include <opencv4/opencv2/opencv.hpp> #include "MxBase/DeviceManager/DeviceManager.h" #include "MxBase/ModelInfer/ModelInferenceProcessor.h" #include "MxBase/PostProcessBases/ObjectPostProcessBase.h" #include "MxBase/Tensor/TensorContext/TensorContext.h" struct InitParam { uint32_t deviceId; std::string modelPath; bool checkTensor; }; float* readCFromFile(std::string path); float* readSFromFile(std::string path); float* readNFromFile(std::string path); cv::Mat readMatFromFile(std::string path); cv::Mat readGtFromFile(std::string path); cv::Mat transform_preds(const cv::Mat &cropped_preds, cv::Mat &mat, const float c[], const float s); void eval(); class Hourglass { public: APP_ERROR Init(const InitParam &initParam); APP_ERROR DeInit(); APP_ERROR ReadInputTensor(const std::string &fileName, MxBase::TensorBase &tensorBase); APP_ERROR Inference(const std::vector<MxBase::TensorBase> &inputs, std::vector<MxBase::TensorBase> &outputs); APP_ERROR Process(const std::string &inferPath, const std::string &fileName); APP_ERROR WriteResult(const std::string &imageFile, std::vector<MxBase::TensorBase> &outputs); APP_ERROR ParseTensor(MxBase::TensorBase &tensors, MxBase::TensorBase &tensors1); private: std::shared_ptr<MxBase::ModelInferenceProcessor> model_; MxBase::ModelDesc modelDesc_; uint32_t deviceId_ = 0; double inferCostTimeMilliSec = 0.0; }; #endif
[ "kangzhaoxiang2018@163.com" ]
kangzhaoxiang2018@163.com