blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
eb2b5260dcc745f5149185fc7045761776d28269 | ba9322f7db02d797f6984298d892f74768193dcf | /push/src/model/QueryPushStatByAppRequest.cc | e30da9166c8df82d5f719e78816836edd322a4b5 | [
"Apache-2.0"
] | permissive | sdk-team/aliyun-openapi-cpp-sdk | e27f91996b3bad9226c86f74475b5a1a91806861 | a27fc0000a2b061cd10df09cbe4fff9db4a7c707 | refs/heads/master | 2022-08-21T18:25:53.080066 | 2022-07-25T10:01:05 | 2022-07-25T10:01:05 | 183,356,893 | 3 | 0 | null | 2019-04-25T04:34:29 | 2019-04-25T04:34:28 | null | UTF-8 | C++ | false | false | 2,119 | cc | /*
* Copyright 2009-2017 Alibaba Cloud 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 <alibabacloud/push/model/QueryPushStatByAppRequest.h>
using AlibabaCloud::Push::Model::QueryPushStatByAppRequest;
QueryPushStatByAppRequest::QueryPushStatByAppRequest() :
RpcServiceRequest("push", "2016-08-01", "QueryPushStatByApp")
{}
QueryPushStatByAppRequest::~QueryPushStatByAppRequest()
{}
std::string QueryPushStatByAppRequest::getGranularity()const
{
return granularity_;
}
void QueryPushStatByAppRequest::setGranularity(const std::string& granularity)
{
granularity_ = granularity;
setParameter("Granularity", granularity);
}
std::string QueryPushStatByAppRequest::getEndTime()const
{
return endTime_;
}
void QueryPushStatByAppRequest::setEndTime(const std::string& endTime)
{
endTime_ = endTime;
setParameter("EndTime", endTime);
}
long QueryPushStatByAppRequest::getAppKey()const
{
return appKey_;
}
void QueryPushStatByAppRequest::setAppKey(long appKey)
{
appKey_ = appKey;
setParameter("AppKey", std::to_string(appKey));
}
std::string QueryPushStatByAppRequest::getStartTime()const
{
return startTime_;
}
void QueryPushStatByAppRequest::setStartTime(const std::string& startTime)
{
startTime_ = startTime;
setParameter("StartTime", startTime);
}
std::string QueryPushStatByAppRequest::getAccessKeyId()const
{
return accessKeyId_;
}
void QueryPushStatByAppRequest::setAccessKeyId(const std::string& accessKeyId)
{
accessKeyId_ = accessKeyId;
setParameter("AccessKeyId", accessKeyId);
}
| [
"haowei.yao@alibaba-inc.com"
] | haowei.yao@alibaba-inc.com |
054f9ae95c1c08b76a5ddd30a0414ec2bb1940c5 | 94231c2f37bdbc1838630bfd91c5c4087b00083b | /Holamundo.cpp | 2663e13f09731118a67558bb925a20bdf6d2ea3f | [] | no_license | Alexisflipi/Club-de-Algoritmia | 7f5c7bf6aa93d0f1e14033e7bf60f11687cdc68b | 71a840d4430ca4fffa115ed6223702188fb70505 | refs/heads/master | 2021-01-17T11:35:28.014672 | 2017-12-22T06:40:23 | 2017-12-22T06:40:23 | 56,295,576 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 102 | cpp | #include <iostream>
usning namespae std;
int main() {
cout << "hola amigos" << endl;
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
da532f426d549e94943dca7fea8a0c27017ca978 | e03bef21d0c0a682151ddd053f32aee35842fc31 | /Renderer/util/fileUtil.hpp | 93fdefe63b5cd89016a1db8c0fd09ee0b0af5aa8 | [] | no_license | GaoChongwen/A-Renderer | 9a72c70d6048a0360c554b07e7bbd70d09d313ca | 10b04bb0ecaf521ac6f03004108eeb297ca78492 | refs/heads/master | 2020-04-13T05:58:10.401975 | 2019-01-16T06:20:06 | 2019-01-16T06:20:06 | 163,008,126 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 213 | hpp | #ifndef fileUtil_h
#define fileUtil_h
#include <string>
extern std::string getFullPath(const std::string &fileName);
extern const char* getFilePath(const char* name, const char* type);
#endif /* fileUtil_h */
| [
"gaosaroma@gmail.com"
] | gaosaroma@gmail.com |
2fe44b024227fe8ea2eb792fd735839be35a09d3 | 7e62f0928681aaaecae7daf360bdd9166299b000 | /external/DirectXShaderCompiler/tools/clang/test/SemaCXX/compare.cpp | cfc52a25d56b270d03992e1e11c6f810bab6b16a | [
"NCSA",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | yuri410/rpg | 949b001bd0aec47e2a046421da0ff2a1db62ce34 | 266282ed8cfc7cd82e8c853f6f01706903c24628 | refs/heads/master | 2020-08-03T09:39:42.253100 | 2020-06-16T15:38:03 | 2020-06-16T15:38:03 | 211,698,323 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,565 | cpp | // Force x86-64 because some of our heuristics are actually based
// on integer sizes.
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare -std=c++11 %s
int test0(long a, unsigned long b) {
enum EnumA {A};
enum EnumB {B};
enum EnumC {C = 0x10000};
return
// (a,b)
(a == (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
(a == (unsigned int) b) +
(a == (unsigned short) b) +
(a == (unsigned char) b) +
((long) a == b) + // expected-warning {{comparison of integers of different signs}}
((int) a == b) + // expected-warning {{comparison of integers of different signs}}
((short) a == b) + // expected-warning {{comparison of integers of different signs}}
((signed char) a == b) + // expected-warning {{comparison of integers of different signs}}
((long) a == (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
((int) a == (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
((short) a == (unsigned short) b) +
((signed char) a == (unsigned char) b) +
(a < (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
(a < (unsigned int) b) +
(a < (unsigned short) b) +
(a < (unsigned char) b) +
((long) a < b) + // expected-warning {{comparison of integers of different signs}}
((int) a < b) + // expected-warning {{comparison of integers of different signs}}
((short) a < b) + // expected-warning {{comparison of integers of different signs}}
((signed char) a < b) + // expected-warning {{comparison of integers of different signs}}
((long) a < (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
((int) a < (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
((short) a < (unsigned short) b) +
((signed char) a < (unsigned char) b) +
// (A,b)
(A == (unsigned long) b) +
(A == (unsigned int) b) +
(A == (unsigned short) b) +
(A == (unsigned char) b) +
((long) A == b) +
((int) A == b) +
((short) A == b) +
((signed char) A == b) +
((long) A == (unsigned long) b) +
((int) A == (unsigned int) b) +
((short) A == (unsigned short) b) +
((signed char) A == (unsigned char) b) +
(A < (unsigned long) b) +
(A < (unsigned int) b) +
(A < (unsigned short) b) +
(A < (unsigned char) b) +
((long) A < b) +
((int) A < b) +
((short) A < b) +
((signed char) A < b) +
((long) A < (unsigned long) b) +
((int) A < (unsigned int) b) +
((short) A < (unsigned short) b) +
((signed char) A < (unsigned char) b) +
// (a,B)
(a == (unsigned long) B) +
(a == (unsigned int) B) +
(a == (unsigned short) B) +
(a == (unsigned char) B) +
((long) a == B) +
((int) a == B) +
((short) a == B) +
((signed char) a == B) +
((long) a == (unsigned long) B) +
((int) a == (unsigned int) B) +
((short) a == (unsigned short) B) +
((signed char) a == (unsigned char) B) +
(a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}}
(a < (unsigned int) B) +
(a < (unsigned short) B) +
(a < (unsigned char) B) +
((long) a < B) +
((int) a < B) +
((short) a < B) +
((signed char) a < B) +
((long) a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}}
((int) a < (unsigned int) B) + // expected-warning {{comparison of integers of different signs}}
((short) a < (unsigned short) B) +
((signed char) a < (unsigned char) B) +
// (C,b)
(C == (unsigned long) b) +
(C == (unsigned int) b) +
(C == (unsigned short) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned short' is always false}}
(C == (unsigned char) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned char' is always false}}
((long) C == b) +
((int) C == b) +
((short) C == b) +
((signed char) C == b) +
((long) C == (unsigned long) b) +
((int) C == (unsigned int) b) +
((short) C == (unsigned short) b) +
((signed char) C == (unsigned char) b) +
(C < (unsigned long) b) +
(C < (unsigned int) b) +
(C < (unsigned short) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned short' is always false}}
(C < (unsigned char) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned char' is always false}}
((long) C < b) +
((int) C < b) +
((short) C < b) +
((signed char) C < b) +
((long) C < (unsigned long) b) +
((int) C < (unsigned int) b) +
((short) C < (unsigned short) b) +
((signed char) C < (unsigned char) b) +
// (a,C)
(a == (unsigned long) C) +
(a == (unsigned int) C) +
(a == (unsigned short) C) +
(a == (unsigned char) C) +
((long) a == C) +
((int) a == C) +
((short) a == C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'short' is always false}}
((signed char) a == C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'signed char' is always false}}
((long) a == (unsigned long) C) +
((int) a == (unsigned int) C) +
((short) a == (unsigned short) C) +
((signed char) a == (unsigned char) C) +
(a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
(a < (unsigned int) C) +
(a < (unsigned short) C) +
(a < (unsigned char) C) +
((long) a < C) +
((int) a < C) +
((short) a < C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'short' is always true}}
((signed char) a < C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'signed char' is always true}}
((long) a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
((int) a < (unsigned int) C) + // expected-warning {{comparison of integers of different signs}}
((short) a < (unsigned short) C) +
((signed char) a < (unsigned char) C) +
// (0x80000,b)
(0x80000 == (unsigned long) b) +
(0x80000 == (unsigned int) b) +
(0x80000 == (unsigned short) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned short' is always false}}
(0x80000 == (unsigned char) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned char' is always false}}
((long) 0x80000 == b) +
((int) 0x80000 == b) +
((short) 0x80000 == b) +
((signed char) 0x80000 == b) +
((long) 0x80000 == (unsigned long) b) +
((int) 0x80000 == (unsigned int) b) +
((short) 0x80000 == (unsigned short) b) +
((signed char) 0x80000 == (unsigned char) b) +
(0x80000 < (unsigned long) b) +
(0x80000 < (unsigned int) b) +
(0x80000 < (unsigned short) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned short' is always false}}
(0x80000 < (unsigned char) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned char' is always false}}
((long) 0x80000 < b) +
((int) 0x80000 < b) +
((short) 0x80000 < b) +
((signed char) 0x80000 < b) +
((long) 0x80000 < (unsigned long) b) +
((int) 0x80000 < (unsigned int) b) +
((short) 0x80000 < (unsigned short) b) +
((signed char) 0x80000 < (unsigned char) b) +
// (a,0x80000)
(a == (unsigned long) 0x80000) +
(a == (unsigned int) 0x80000) +
(a == (unsigned short) 0x80000) +
(a == (unsigned char) 0x80000) +
((long) a == 0x80000) +
((int) a == 0x80000) +
((short) a == 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'short' is always false}}
((signed char) a == 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'signed char' is always false}}
((long) a == (unsigned long) 0x80000) +
((int) a == (unsigned int) 0x80000) +
((short) a == (unsigned short) 0x80000) +
((signed char) a == (unsigned char) 0x80000) +
(a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
(a < (unsigned int) 0x80000) +
(a < (unsigned short) 0x80000) +
(a < (unsigned char) 0x80000) +
((long) a < 0x80000) +
((int) a < 0x80000) +
((short) a < 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'short' is always true}}
((signed char) a < 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'signed char' is always true}}
((long) a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
((int) a < (unsigned int) 0x80000) + // expected-warning {{comparison of integers of different signs}}
((short) a < (unsigned short) 0x80000) +
((signed char) a < (unsigned char) 0x80000) +
10
;
}
int test1(int i) {
enum en { zero };
return i > zero;
}
enum E { e };
void test2(int i, void *vp) {
if (test1 == vp) { } // expected-warning{{equality comparison between function pointer and void pointer}}
if (test1 == e) { } // expected-error{{comparison between pointer and integer}}
if (vp < 0) { }
if (test1 < e) { } // expected-error{{comparison between pointer and integer}}
}
// PR7536
static const unsigned int kMax = 0;
int pr7536() {
return (kMax > 0);
}
// -Wsign-compare should not warn when ?: operands have different signedness.
// This will be caught by -Wsign-conversion
void test3() {
unsigned long a;
signed long b;
(void) (true ? a : b);
(void) (true ? (unsigned int)a : (signed int)b);
(void) (true ? b : a);
(void) (true ? (unsigned char)b : (signed char)a);
}
// Test comparison of short to unsigned. If tautological compare does not
// trigger, then the signed comparison warning will.
void test4(short s) {
// A is max short plus 1. All zero and positive shorts are smaller than it.
// All negative shorts are cast towards the max unsigned range. Relation
// comparisons are possible, but equality comparisons are tautological.
const unsigned A = 32768;
void (s < A); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s > A); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s <= A); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s >= A); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s == A); // expected-warning{{comparison of constant 32768 with expression of type 'short' is always false}}
void (s != A); // expected-warning{{comparison of constant 32768 with expression of type 'short' is always true}}
// When negative one is converted to an unsigned value, it becomes the max
// unsigned. Likewise, a negative one short can also be converted to max
// unsigned.
const unsigned B = -1;
void (s < B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s > B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s <= B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s >= B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s == B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s != B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
}
void test5(bool b) {
(void) (b < -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always false}}
(void) (b > -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always true}}
(void) (b == -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always false}}
(void) (b != -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always true}}
(void) (b <= -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always false}}
(void) (b >= -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always true}}
(void) (b < -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always false}}
(void) (b > -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always true}}
(void) (b == -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always false}}
(void) (b != -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always true}}
(void) (b <= -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always false}}
(void) (b >= -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always true}}
(void) (b < 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always true}}
(void) (b > 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always false}}
(void) (b == 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always false}}
(void) (b != 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always true}}
(void) (b <= 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always true}}
(void) (b >= 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always false}}
(void) (b < 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always true}}
(void) (b > 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always false}}
(void) (b == 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always false}}
(void) (b != 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always true}}
(void) (b <= 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always true}}
(void) (b >= 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always false}}
}
void test6(signed char sc) {
(void)(sc < 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
(void)(sc > 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(sc <= 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
(void)(sc >= 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(sc == 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(sc != 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
(void)(200 < sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(200 > sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
(void)(200 <= sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(200 >= sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
(void)(200 == sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(200 != sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
}
// Test many signedness combinations.
void test7(unsigned long other) {
// Common unsigned, other unsigned, constant unsigned
(void)((unsigned)other != (unsigned long)(0x1ffffffff)); // expected-warning{{true}}
(void)((unsigned)other != (unsigned long)(0xffffffff));
(void)((unsigned long)other != (unsigned)(0x1ffffffff));
(void)((unsigned long)other != (unsigned)(0xffffffff));
// Common unsigned, other signed, constant unsigned
(void)((int)other != (unsigned long)(0xffffffffffffffff)); // expected-warning{{different signs}}
(void)((int)other != (unsigned long)(0x00000000ffffffff)); // expected-warning{{true}}
(void)((int)other != (unsigned long)(0x000000000fffffff));
(void)((int)other < (unsigned long)(0x00000000ffffffff)); // expected-warning{{different signs}}
(void)((int)other == (unsigned)(0x800000000));
// Common unsigned, other unsigned, constant signed
(void)((unsigned long)other != (int)(0xffffffff)); // expected-warning{{different signs}}
// Common unsigned, other signed, constant signed
// Should not be possible as the common type should also be signed.
// Common signed, other signed, constant signed
(void)((int)other != (long)(0xffffffff)); // expected-warning{{true}}
(void)((int)other != (long)(0xffffffff00000000)); // expected-warning{{true}}
(void)((int)other != (long)(0xfffffff));
(void)((int)other != (long)(0xfffffffff0000000));
// Common signed, other signed, constant unsigned
(void)((int)other != (unsigned char)(0xffff));
(void)((int)other != (unsigned char)(0xff));
// Common signed, other unsigned, constant signed
(void)((unsigned char)other != (int)(0xff));
(void)((unsigned char)other != (int)(0xffff)); // expected-warning{{true}}
// Common signed, other unsigned, constant unsigned
(void)((unsigned char)other != (unsigned short)(0xff));
(void)((unsigned char)other != (unsigned short)(0x100)); // expected-warning{{true}}
(void)((unsigned short)other != (unsigned char)(0xff));
}
void test8(int x) {
enum E {
Negative = -1,
Positive = 1
};
(void)((E)x == 1);
(void)((E)x == -1);
}
void test9(int x) {
enum E : int {
Positive = 1
};
(void)((E)x == 1);
}
namespace templates {
template<class T> T max();
template<> constexpr int max<int>() { return 2147483647; };
template<typename T>
bool less_than_max(short num, T value) {
const T vmax = max<T>();
return (vmax >= num); // no warning
}
template<typename T>
bool less_than_max(short num) {
// This should trigger one warning on the template pattern, and not a
// warning per specialization.
return num < max<int>(); // expected-warning{{comparison of constant 2147483647 with expression of type 'short' is always true}}
}
void test10(short num, int x) {
less_than_max(num, x);
less_than_max<int>(num);
less_than_max<long>(num);
less_than_max<short>(num);
}
template<typename T>
inline bool less_than_zero(T num, T value) {
return num < 0; // no warning
}
template<typename T>
inline bool less_than_zero(unsigned num) {
// This should trigger one warning on the template pattern, and not a
// warning per specialization.
return num < 0; // expected-warning{{comparison of unsigned expression < 0 is always false}}
}
void test11(unsigned num) {
less_than_zero(num, num);
less_than_zero<int>(num);
less_than_zero<long>(num);
less_than_zero<short>(num);
}
template<unsigned n> bool compare(unsigned k) { return k >= n; }
void test12() {
compare<0>(42);
}
struct A { static int x; };
struct B { static int x; };
typedef A otherA;
template <typename T>
void testx() {
if (A::x == T::x && // no warning
A::x == otherA::x) // expected-warning{{self-comparison always evaluates to true}}
return;
}
void test13() {
testx<A>();
testx<B>();
}
}
| [
"yuri410@users.noreply.github.com"
] | yuri410@users.noreply.github.com |
4dbf712f95a086744324898c4e8a9dc82c02770a | becd1f9715a05d360bf40d8341dbe4fffae2aa37 | /Proprietar.cpp | de69f9b04dba6fe5d6604cdf99224a610fbbb2f4 | [] | no_license | baron-mariana/Subiete-OOP | 94feb387cbe65d6b1551baa9220c13eb86d6cd85 | ccc1589f02ca8b3d205c20bfcd3c2e7d01dcd46c | refs/heads/master | 2022-11-25T03:08:53.054242 | 2020-08-05T13:01:51 | 2020-08-05T13:01:51 | 285,277,497 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,479 | cpp | #include<iostream>
#include<string>
using namespace std;
class Proprietar {
char* nume;
string cnp;
int nrApartamente;//e o val ce gestioneaza vect dinic de pointerul chirii
float* chirii;//pointer ce gestioneaza adresa unui vect dinamic de val
const int id;
static float tva;
public:
Proprietar() :id(0) {
this->cnp = "na";
this->nrApartamente = 0;
this->chirii = NULL;
this->nume = new char[strlen("na") + 1];
strcpy(this->nume, "na");
}
Proprietar(int idd, const char* nume, string cnp, int nrAp, float* chirii) :id(idd) {
this->nume = new char[strlen(nume) + 1];
strcpy(this->nume, nume);
this->cnp = cnp;
this->nrApartamente = nrAp;
this->chirii = new float[nrAp];
for (int i = 0; i < nrAp; i++)
{
this->chirii[i] = chirii[i];
}
}
//const char* nume, si string cnp
Proprietar(const char* nume, string cnp) :id(0) {
this->nume = new char[strlen(nume) + 1];
strcpy(this->nume, nume);
this->cnp = cnp;
this->nrApartamente = 0;
this->chirii = NULL;
}
Proprietar(const Proprietar&sursa) :id(sursa.id) {
this->nume = new char[strlen(sursa.nume) + 1];
strcpy(this->nume, sursa.nume);
this->cnp = sursa.cnp;
this->nrApartamente = sursa.nrApartamente;
this->chirii = new float[sursa.nrApartamente];
for (int i = 0; i < sursa.nrApartamente; i++)
{
this->chirii[i] = sursa.chirii[i];
}
}
~Proprietar() {
if (this->nume) {
delete[]this->nume;
}
if (this->chirii) {
delete[]this->chirii;
}
}
//p2=p1=p5=p6
Proprietar&operator=(const Proprietar& sursa) {
if (this->nume) {
delete[]this->nume;
}
if (this->chirii) {
delete[]this->chirii;
}
this->nume = new char[strlen(sursa.nume) + 1];
strcpy(this->nume, sursa.nume);
this->cnp = sursa.cnp;
this->nrApartamente = sursa.nrApartamente;
this->chirii = new float[sursa.nrApartamente];
for (int i = 0; i < sursa.nrApartamente; i++)
{
this->chirii[i] = sursa.chirii[i];
}
return*this;
}
//s3.set(dxf)
void setnume(const char* numeNou) {
if (strlen(numeNou) > 2) {
if (this->nume) {
delete[]this->nume;
}
this->nume = new char[strlen(numeNou) + 1];
strcpy(this->nume, numeNou);
}
}
void setcnp(string cnpNou) {
if (cnpNou.length() > 2) {
this->cnp = cnpNou;
}
}
void setchirii(int nrap, float*chiriiNoi) {
if (nrap > 0) {
if (this->chirii) {
delete[]this->chirii;
}
this->nrApartamente = nrap;
this->chirii = new float[nrap];
for (int i = 0; i < nrap; i++) {
this->chirii[i] = chiriiNoi[i];
}
}
}
//afisez chiria pt p2
float* getchirie() {
return this->chirii;
}
int getnrApartamente() {
return this->nrApartamente;
}
//cout<<s3<<s2;
friend ostream& operator<<(ostream& o, const Proprietar& sursa) {
o << "NUME:" << sursa.nume << endl;
o << "CNP:" << sursa.cnp << endl;
o << "NR APARTAMENTE:" << sursa.nrApartamente << endl;
for (int i = 0; i < sursa.nrApartamente; i++) {
o << sursa.chirii[i] << " ";
}
return o;
}
//cin>>s2>>s3;
friend istream& operator>> (istream& in, Proprietar& sursa) {
cout << "Da nume: ";
char buffer[100];
in >> buffer;
sursa.setnume(buffer);
cout << "Da cnp:";
in >> sursa.cnp;
cout << "Da numarul de aprtamente ";
in >> sursa.nrApartamente;
if (sursa.chirii) {
delete[]sursa.chirii;
}
sursa.chirii = new float[sursa.nrApartamente];
for (int i = 0; i < sursa.nrApartamente; i++) {
cout << "Da chiria pentru ap " << i + 1 << ": ";
in >> sursa.chirii[i];
}
return in;
}
// p1 +=1200;
//p1
// Gabriel
// 2
// 340 380 -->> 440 480
// p1+=100;
// p1.marireChirii(100.00);
void marireChirii(float marirre)
{
for (int i = 0; i < this->nrApartamente; i++) {
// this->chirii[i] = this->chirii[i] + marirre;
this->chirii[i] += marirre;
}
}
// operatori aritmetici unari += -= /= *=
//tipul returnat: va fi intotdeauna o referinta a obiectului pentru care s a apelat functia
// nu mele operatorului operator += / operator -= etdc...
//lista de parametrii: PRIMESTE doar 2 Parametri! ... Obiectul pentru care s a apelat functia ... si inca o referinta sau pointer sau valoarea la orice tip de data
// in corpul functiei ... lucram pe this
// p1+=120;
Proprietar& operator+=(float marirre) {
for (int i = 0; i < this->nrApartamente; i++) {
// this->chirii[i] = this->chirii[i] + marirre;
this->chirii[i] += marirre;
}
// cout << *this;// ti l afisaeaza pe p1 ... cout<<p1;
return *this;
}
// operatori aritmetici binari + - / *
//tipul returnat: va fi intotdeauna o COPIE a obiectului pentru care s a apelat functia
// nu mele operatorului operator + / operator - etdc...
//lista de parametrii: PRIMESTE doar 2 Parametri! ... Obiectul pentru care s a apelat functia ... si inca o referinta sau pointer sau valoarea la orice tip de data
// in corpul functiei ... Primul lucru pe care il facem este sa copiem obiectul din this
//Apoi lucram pe acea copie... modificam pe ea .... Originalul il pstram intact
//la final returnam copia;
// p1+23;
//Proprietar operator + (float marire) {
// Proprietar copie = *this; // Proprietar copie(p1); //apel cosntructor copiere
// for (int i = 0; i < copie.nrApartamente; i++) {
// // this->chirii[i] = this->chirii[i] + marirre;
// copie.chirii[i] += marire;
// }
// return copie;
//}
Proprietar operator+( float chirieNoua) {
Proprietar copie = *this;
float*vn = new float[copie.nrApartamente + 1];
for (int i = 0; i < copie.nrApartamente; i++) {
vn[i] = copie.chirii[i];
}
vn[copie.nrApartamente] = chirieNoua;
copie.nrApartamente++;
if (copie.chirii) {
delete[]copie.chirii;
}
copie.chirii = vn;
return copie;
}
// operator++ -- forma PRE - incrementare decremendate
//tipul returnat: va fi intotdeauna o referinta a obiectului pentru care s a apelat functia
// nu mele operatorului operator ++ / operator -- etdc...
//lista de parametrii: PRIMESTE doar 1 Parametru!
// in corpul functiei ... lucram pe this ... si modificam this cu valoare implicita
//la final *this;
// ++p1;
Proprietar& operator++() {
for (int i = 0; i < this->nrApartamente; i++) {
this->chirii[i] = this->chirii[i] + 10;
//this->chirii[i] += 10;
}
return *this;
}
// operator++ -- forma post - incrementare decremendate
//tipul returnat: va fi intotdeauna o Copie a obiectului pentru care s a apelat functia
// nu mele operatorului operator ++ / operator -- etdc...
//lista de parametrii: PRIMESTE doar 1 Parametru! si cuvantul INT in lista .. pentru a se face diferentierea intre pre si post
// in corpul functiei Mai intai facem o copie a lui this apoi ... lucram pe this ... si modificam this cu valoare implicita
//obs: NU AVEM VOIE sa modificam copia... deoarece ea a fost facuta la inceput si retine valorile initiale a lui this
// returnam copia cu valorile initiale a lui this
Proprietar operator++(int) {
Proprietar copie = *this;
for (int i = 0; i < this->nrApartamente; i++) {
this->chirii[i] = this->chirii[i] + 10;
//this->chirii[i] += 10;
}
return copie;
}
// operatori relationali / de comparatie > < >= <= == !=
//tipul returnat: va fi intotdeauna un BOOL
// nu mele operatorului operator > / operator < etdc...
//lista de parametrii: PRIMESTE doar 2 Parametri! ... Obiectul pentru care s a apelat functia ... si inca o referinta sau pointer sau valoarea la orice tip de data
// in corpul functiei Mai intai facem o copie a lui this apoi ... lucram pe this ... si modificam this cu valoare implicita
//obs: NU AVEM VOIE sa modificam copia... deoarece ea a fost facuta la inceput si retine valorile initiale a lui this
// returnam copia cu valorile initiale a lui this
// p2==p3 p2>=12 p2<vect; p1 != "Gabriel" etc..
// getTotalChirii
float getTotalChirii() {
float s = 0;
for (int i = 0; i < nrApartamente; i++) {
s += chirii[i];
}
return s;
}
float operator ()() {
float s = 0;
for (int i = 0; i < nrApartamente; i++) {
s += chirii[i];
}
return s;
}
bool operator == (Proprietar sursa) { // copie a unui proprietar
if (this->getTotalChirii() == sursa.getTotalChirii()) {
return 1;
}
else {
return 0;
}
}
// operatorul not!
bool operator!() {
if (nrApartamente > 0) {
return false;
}
else {
return true;
}
}
//Protrietar& operator!() {
// if (protectieProprietar == 0) {
// pritectieProprietar= true;
// }
// else {
// pritectieProprietar= false;
// }
/// return * this;
//}
//operator int() {
// return nrApartamente;
//}
explicit operator int() {
return nrApartamente;
}
explicit operator float() {
return getTotalChirii();
}
float& operator[] (int i) {
if (i >= 0 && i < nrApartamente) {
return chirii [i];
}
else {
throw new exception();
}
}
float& operator() (int i) {
if (i >= 0 && i < nrApartamente) {
return chirii[i];
}
else {
throw new exception();
}
}
};
float Proprietar::tva = 0.19;
void main() {
Proprietar p;
float vect[] = { 200,300,400 };
Proprietar p2(123, "Popescu", "sfg", 3, vect);
Proprietar p3("p2", "gfsh");
Proprietar p4(p2);
p4 = p2;
p2.setnume("ionescu");
p2.setcnp("cdh");
float chirii[] = { 200,300 };
p2.setchirii(2, chirii);
//cout << p2.getchirie();
for (int i = 0; i < p2.getnrApartamente(); i++) {
// cout << p2.getchirie()[i]<<endl;
}
//cout << p2;
if (p2 == p4) {
// cout << "Sunt egali=" << endl;
}
else {
// cout << "nu sunt egali" << endl;
}
if (!p2) {
cout << "Are apartamente" << endl;
}
else {
cout << "N are apartamente" << endl;
}
// !p2;
p2 + 12;
p2 += 12;
//int apartamenteP2 =p2; //implicit ... atunci cand compilatorul isi da seama singur la ce sa se faca cast
// de evenitat sa folosim castul implicit ca intra in ambiguitate cu alti operatori ;
int apartamenteP2 = (int)p2;//explicit
float sum = (float)p2;
//cout << sum << endl;
// p2[1] = 12312;
cout << p2();
//cout << p2[1];
} | [
"noreply@github.com"
] | noreply@github.com |
b0b180de355521d379b7c3114b98956ae4b3d8ae | c776476e9d06b3779d744641e758ac3a2c15cddc | /examples/litmus/c/run-scripts/tmp_5/ISA2+dmb.st+dmb.st+po.c.cbmc.cpp | ed766ff41066876a6103d95d397ae560ed210aa1 | [] | no_license | ashutosh0gupta/llvm_bmc | aaac7961c723ba6f7ffd77a39559e0e52432eade | 0287c4fb180244e6b3c599a9902507f05c8a7234 | refs/heads/master | 2023-08-02T17:14:06.178723 | 2023-07-31T10:46:53 | 2023-07-31T10:46:53 | 143,100,825 | 3 | 4 | null | 2023-05-25T05:50:55 | 2018-08-01T03:47:00 | C++ | UTF-8 | C++ | false | false | 42,701 | cpp | // Global variabls:
// 0:vars:3
// 3:atom_1_X0_1:1
// 4:atom_2_X0_1:1
// 5:atom_2_X2_0:1
// Local global variabls:
// 0:thr0:1
// 1:thr1:1
// 2:thr2:1
#define ADDRSIZE 6
#define LOCALADDRSIZE 3
#define NTHREAD 4
#define NCONTEXT 5
#define ASSUME(stmt) __CPROVER_assume(stmt)
#define ASSERT(stmt) __CPROVER_assert(stmt, "error")
#define max(a,b) (a>b?a:b)
char __get_rng();
char get_rng( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
char get_rng_th( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
int main(int argc, char **argv) {
// Declare arrays for intial value version in contexts
int local_mem[LOCALADDRSIZE];
// Dumping initializations
local_mem[0+0] = 0;
local_mem[1+0] = 0;
local_mem[2+0] = 0;
int cstart[NTHREAD];
int creturn[NTHREAD];
// declare arrays for contexts activity
int active[NCONTEXT];
int ctx_used[NCONTEXT];
// declare arrays for intial value version in contexts
int meminit_[ADDRSIZE*NCONTEXT];
#define meminit(x,k) meminit_[(x)*NCONTEXT+k]
int coinit_[ADDRSIZE*NCONTEXT];
#define coinit(x,k) coinit_[(x)*NCONTEXT+k]
int deltainit_[ADDRSIZE*NCONTEXT];
#define deltainit(x,k) deltainit_[(x)*NCONTEXT+k]
// declare arrays for running value version in contexts
int mem_[ADDRSIZE*NCONTEXT];
#define mem(x,k) mem_[(x)*NCONTEXT+k]
int co_[ADDRSIZE*NCONTEXT];
#define co(x,k) co_[(x)*NCONTEXT+k]
int delta_[ADDRSIZE*NCONTEXT];
#define delta(x,k) delta_[(x)*NCONTEXT+k]
// declare arrays for local buffer and observed writes
int buff_[NTHREAD*ADDRSIZE];
#define buff(x,k) buff_[(x)*ADDRSIZE+k]
int pw_[NTHREAD*ADDRSIZE];
#define pw(x,k) pw_[(x)*ADDRSIZE+k]
// declare arrays for context stamps
char cr_[NTHREAD*ADDRSIZE];
#define cr(x,k) cr_[(x)*ADDRSIZE+k]
char iw_[NTHREAD*ADDRSIZE];
#define iw(x,k) iw_[(x)*ADDRSIZE+k]
char cw_[NTHREAD*ADDRSIZE];
#define cw(x,k) cw_[(x)*ADDRSIZE+k]
char cx_[NTHREAD*ADDRSIZE];
#define cx(x,k) cx_[(x)*ADDRSIZE+k]
char is_[NTHREAD*ADDRSIZE];
#define is(x,k) is_[(x)*ADDRSIZE+k]
char cs_[NTHREAD*ADDRSIZE];
#define cs(x,k) cs_[(x)*ADDRSIZE+k]
char crmax_[NTHREAD*ADDRSIZE];
#define crmax(x,k) crmax_[(x)*ADDRSIZE+k]
char sforbid_[ADDRSIZE*NCONTEXT];
#define sforbid(x,k) sforbid_[(x)*NCONTEXT+k]
// declare arrays for synchronizations
int cl[NTHREAD];
int cdy[NTHREAD];
int cds[NTHREAD];
int cdl[NTHREAD];
int cisb[NTHREAD];
int caddr[NTHREAD];
int cctrl[NTHREAD];
__LOCALS__
buff(0,0) = 0;
pw(0,0) = 0;
cr(0,0) = 0;
iw(0,0) = 0;
cw(0,0) = 0;
cx(0,0) = 0;
is(0,0) = 0;
cs(0,0) = 0;
crmax(0,0) = 0;
buff(0,1) = 0;
pw(0,1) = 0;
cr(0,1) = 0;
iw(0,1) = 0;
cw(0,1) = 0;
cx(0,1) = 0;
is(0,1) = 0;
cs(0,1) = 0;
crmax(0,1) = 0;
buff(0,2) = 0;
pw(0,2) = 0;
cr(0,2) = 0;
iw(0,2) = 0;
cw(0,2) = 0;
cx(0,2) = 0;
is(0,2) = 0;
cs(0,2) = 0;
crmax(0,2) = 0;
buff(0,3) = 0;
pw(0,3) = 0;
cr(0,3) = 0;
iw(0,3) = 0;
cw(0,3) = 0;
cx(0,3) = 0;
is(0,3) = 0;
cs(0,3) = 0;
crmax(0,3) = 0;
buff(0,4) = 0;
pw(0,4) = 0;
cr(0,4) = 0;
iw(0,4) = 0;
cw(0,4) = 0;
cx(0,4) = 0;
is(0,4) = 0;
cs(0,4) = 0;
crmax(0,4) = 0;
buff(0,5) = 0;
pw(0,5) = 0;
cr(0,5) = 0;
iw(0,5) = 0;
cw(0,5) = 0;
cx(0,5) = 0;
is(0,5) = 0;
cs(0,5) = 0;
crmax(0,5) = 0;
cl[0] = 0;
cdy[0] = 0;
cds[0] = 0;
cdl[0] = 0;
cisb[0] = 0;
caddr[0] = 0;
cctrl[0] = 0;
cstart[0] = get_rng(0,NCONTEXT-1);
creturn[0] = get_rng(0,NCONTEXT-1);
buff(1,0) = 0;
pw(1,0) = 0;
cr(1,0) = 0;
iw(1,0) = 0;
cw(1,0) = 0;
cx(1,0) = 0;
is(1,0) = 0;
cs(1,0) = 0;
crmax(1,0) = 0;
buff(1,1) = 0;
pw(1,1) = 0;
cr(1,1) = 0;
iw(1,1) = 0;
cw(1,1) = 0;
cx(1,1) = 0;
is(1,1) = 0;
cs(1,1) = 0;
crmax(1,1) = 0;
buff(1,2) = 0;
pw(1,2) = 0;
cr(1,2) = 0;
iw(1,2) = 0;
cw(1,2) = 0;
cx(1,2) = 0;
is(1,2) = 0;
cs(1,2) = 0;
crmax(1,2) = 0;
buff(1,3) = 0;
pw(1,3) = 0;
cr(1,3) = 0;
iw(1,3) = 0;
cw(1,3) = 0;
cx(1,3) = 0;
is(1,3) = 0;
cs(1,3) = 0;
crmax(1,3) = 0;
buff(1,4) = 0;
pw(1,4) = 0;
cr(1,4) = 0;
iw(1,4) = 0;
cw(1,4) = 0;
cx(1,4) = 0;
is(1,4) = 0;
cs(1,4) = 0;
crmax(1,4) = 0;
buff(1,5) = 0;
pw(1,5) = 0;
cr(1,5) = 0;
iw(1,5) = 0;
cw(1,5) = 0;
cx(1,5) = 0;
is(1,5) = 0;
cs(1,5) = 0;
crmax(1,5) = 0;
cl[1] = 0;
cdy[1] = 0;
cds[1] = 0;
cdl[1] = 0;
cisb[1] = 0;
caddr[1] = 0;
cctrl[1] = 0;
cstart[1] = get_rng(0,NCONTEXT-1);
creturn[1] = get_rng(0,NCONTEXT-1);
buff(2,0) = 0;
pw(2,0) = 0;
cr(2,0) = 0;
iw(2,0) = 0;
cw(2,0) = 0;
cx(2,0) = 0;
is(2,0) = 0;
cs(2,0) = 0;
crmax(2,0) = 0;
buff(2,1) = 0;
pw(2,1) = 0;
cr(2,1) = 0;
iw(2,1) = 0;
cw(2,1) = 0;
cx(2,1) = 0;
is(2,1) = 0;
cs(2,1) = 0;
crmax(2,1) = 0;
buff(2,2) = 0;
pw(2,2) = 0;
cr(2,2) = 0;
iw(2,2) = 0;
cw(2,2) = 0;
cx(2,2) = 0;
is(2,2) = 0;
cs(2,2) = 0;
crmax(2,2) = 0;
buff(2,3) = 0;
pw(2,3) = 0;
cr(2,3) = 0;
iw(2,3) = 0;
cw(2,3) = 0;
cx(2,3) = 0;
is(2,3) = 0;
cs(2,3) = 0;
crmax(2,3) = 0;
buff(2,4) = 0;
pw(2,4) = 0;
cr(2,4) = 0;
iw(2,4) = 0;
cw(2,4) = 0;
cx(2,4) = 0;
is(2,4) = 0;
cs(2,4) = 0;
crmax(2,4) = 0;
buff(2,5) = 0;
pw(2,5) = 0;
cr(2,5) = 0;
iw(2,5) = 0;
cw(2,5) = 0;
cx(2,5) = 0;
is(2,5) = 0;
cs(2,5) = 0;
crmax(2,5) = 0;
cl[2] = 0;
cdy[2] = 0;
cds[2] = 0;
cdl[2] = 0;
cisb[2] = 0;
caddr[2] = 0;
cctrl[2] = 0;
cstart[2] = get_rng(0,NCONTEXT-1);
creturn[2] = get_rng(0,NCONTEXT-1);
buff(3,0) = 0;
pw(3,0) = 0;
cr(3,0) = 0;
iw(3,0) = 0;
cw(3,0) = 0;
cx(3,0) = 0;
is(3,0) = 0;
cs(3,0) = 0;
crmax(3,0) = 0;
buff(3,1) = 0;
pw(3,1) = 0;
cr(3,1) = 0;
iw(3,1) = 0;
cw(3,1) = 0;
cx(3,1) = 0;
is(3,1) = 0;
cs(3,1) = 0;
crmax(3,1) = 0;
buff(3,2) = 0;
pw(3,2) = 0;
cr(3,2) = 0;
iw(3,2) = 0;
cw(3,2) = 0;
cx(3,2) = 0;
is(3,2) = 0;
cs(3,2) = 0;
crmax(3,2) = 0;
buff(3,3) = 0;
pw(3,3) = 0;
cr(3,3) = 0;
iw(3,3) = 0;
cw(3,3) = 0;
cx(3,3) = 0;
is(3,3) = 0;
cs(3,3) = 0;
crmax(3,3) = 0;
buff(3,4) = 0;
pw(3,4) = 0;
cr(3,4) = 0;
iw(3,4) = 0;
cw(3,4) = 0;
cx(3,4) = 0;
is(3,4) = 0;
cs(3,4) = 0;
crmax(3,4) = 0;
buff(3,5) = 0;
pw(3,5) = 0;
cr(3,5) = 0;
iw(3,5) = 0;
cw(3,5) = 0;
cx(3,5) = 0;
is(3,5) = 0;
cs(3,5) = 0;
crmax(3,5) = 0;
cl[3] = 0;
cdy[3] = 0;
cds[3] = 0;
cdl[3] = 0;
cisb[3] = 0;
caddr[3] = 0;
cctrl[3] = 0;
cstart[3] = get_rng(0,NCONTEXT-1);
creturn[3] = get_rng(0,NCONTEXT-1);
// Dumping initializations
mem(0+0,0) = 0;
mem(0+1,0) = 0;
mem(0+2,0) = 0;
mem(3+0,0) = 0;
mem(4+0,0) = 0;
mem(5+0,0) = 0;
// Dumping context matching equalities
co(0,0) = 0;
delta(0,0) = -1;
mem(0,1) = meminit(0,1);
co(0,1) = coinit(0,1);
delta(0,1) = deltainit(0,1);
mem(0,2) = meminit(0,2);
co(0,2) = coinit(0,2);
delta(0,2) = deltainit(0,2);
mem(0,3) = meminit(0,3);
co(0,3) = coinit(0,3);
delta(0,3) = deltainit(0,3);
mem(0,4) = meminit(0,4);
co(0,4) = coinit(0,4);
delta(0,4) = deltainit(0,4);
co(1,0) = 0;
delta(1,0) = -1;
mem(1,1) = meminit(1,1);
co(1,1) = coinit(1,1);
delta(1,1) = deltainit(1,1);
mem(1,2) = meminit(1,2);
co(1,2) = coinit(1,2);
delta(1,2) = deltainit(1,2);
mem(1,3) = meminit(1,3);
co(1,3) = coinit(1,3);
delta(1,3) = deltainit(1,3);
mem(1,4) = meminit(1,4);
co(1,4) = coinit(1,4);
delta(1,4) = deltainit(1,4);
co(2,0) = 0;
delta(2,0) = -1;
mem(2,1) = meminit(2,1);
co(2,1) = coinit(2,1);
delta(2,1) = deltainit(2,1);
mem(2,2) = meminit(2,2);
co(2,2) = coinit(2,2);
delta(2,2) = deltainit(2,2);
mem(2,3) = meminit(2,3);
co(2,3) = coinit(2,3);
delta(2,3) = deltainit(2,3);
mem(2,4) = meminit(2,4);
co(2,4) = coinit(2,4);
delta(2,4) = deltainit(2,4);
co(3,0) = 0;
delta(3,0) = -1;
mem(3,1) = meminit(3,1);
co(3,1) = coinit(3,1);
delta(3,1) = deltainit(3,1);
mem(3,2) = meminit(3,2);
co(3,2) = coinit(3,2);
delta(3,2) = deltainit(3,2);
mem(3,3) = meminit(3,3);
co(3,3) = coinit(3,3);
delta(3,3) = deltainit(3,3);
mem(3,4) = meminit(3,4);
co(3,4) = coinit(3,4);
delta(3,4) = deltainit(3,4);
co(4,0) = 0;
delta(4,0) = -1;
mem(4,1) = meminit(4,1);
co(4,1) = coinit(4,1);
delta(4,1) = deltainit(4,1);
mem(4,2) = meminit(4,2);
co(4,2) = coinit(4,2);
delta(4,2) = deltainit(4,2);
mem(4,3) = meminit(4,3);
co(4,3) = coinit(4,3);
delta(4,3) = deltainit(4,3);
mem(4,4) = meminit(4,4);
co(4,4) = coinit(4,4);
delta(4,4) = deltainit(4,4);
co(5,0) = 0;
delta(5,0) = -1;
mem(5,1) = meminit(5,1);
co(5,1) = coinit(5,1);
delta(5,1) = deltainit(5,1);
mem(5,2) = meminit(5,2);
co(5,2) = coinit(5,2);
delta(5,2) = deltainit(5,2);
mem(5,3) = meminit(5,3);
co(5,3) = coinit(5,3);
delta(5,3) = deltainit(5,3);
mem(5,4) = meminit(5,4);
co(5,4) = coinit(5,4);
delta(5,4) = deltainit(5,4);
// Dumping thread 1
int ret_thread_1 = 0;
cdy[1] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[1] >= cstart[1]);
T1BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !38, metadata !DIExpression()), !dbg !47
// br label %label_1, !dbg !48
goto T1BLOCK1;
T1BLOCK1:
// call void @llvm.dbg.label(metadata !46), !dbg !49
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !39, metadata !DIExpression()), !dbg !50
// call void @llvm.dbg.value(metadata i64 1, metadata !42, metadata !DIExpression()), !dbg !50
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !51
// ST: Guess
iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l21_c3
old_cw = cw(1,0);
cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l21_c3
// Check
ASSUME(active[iw(1,0)] == 1);
ASSUME(active[cw(1,0)] == 1);
ASSUME(sforbid(0,cw(1,0))== 0);
ASSUME(iw(1,0) >= 0);
ASSUME(iw(1,0) >= 0);
ASSUME(cw(1,0) >= iw(1,0));
ASSUME(cw(1,0) >= old_cw);
ASSUME(cw(1,0) >= cr(1,0));
ASSUME(cw(1,0) >= cl[1]);
ASSUME(cw(1,0) >= cisb[1]);
ASSUME(cw(1,0) >= cdy[1]);
ASSUME(cw(1,0) >= cdl[1]);
ASSUME(cw(1,0) >= cds[1]);
ASSUME(cw(1,0) >= cctrl[1]);
ASSUME(cw(1,0) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0) = 1;
mem(0,cw(1,0)) = 1;
co(0,cw(1,0))+=1;
delta(0,cw(1,0)) = -1;
ASSUME(creturn[1] >= cw(1,0));
// call void (...) @dmbst(), !dbg !52
// dumbst: Guess
cds[1] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cds[1] >= cdy[1]);
ASSUME(cds[1] >= cw(1,0+0));
ASSUME(cds[1] >= cw(1,0+1));
ASSUME(cds[1] >= cw(1,0+2));
ASSUME(cds[1] >= cw(1,3+0));
ASSUME(cds[1] >= cw(1,4+0));
ASSUME(cds[1] >= cw(1,5+0));
ASSUME(creturn[1] >= cds[1]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !43, metadata !DIExpression()), !dbg !53
// call void @llvm.dbg.value(metadata i64 1, metadata !45, metadata !DIExpression()), !dbg !53
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !54
// ST: Guess
iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l23_c3
old_cw = cw(1,0+1*1);
cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l23_c3
// Check
ASSUME(active[iw(1,0+1*1)] == 1);
ASSUME(active[cw(1,0+1*1)] == 1);
ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(cw(1,0+1*1) >= iw(1,0+1*1));
ASSUME(cw(1,0+1*1) >= old_cw);
ASSUME(cw(1,0+1*1) >= cr(1,0+1*1));
ASSUME(cw(1,0+1*1) >= cl[1]);
ASSUME(cw(1,0+1*1) >= cisb[1]);
ASSUME(cw(1,0+1*1) >= cdy[1]);
ASSUME(cw(1,0+1*1) >= cdl[1]);
ASSUME(cw(1,0+1*1) >= cds[1]);
ASSUME(cw(1,0+1*1) >= cctrl[1]);
ASSUME(cw(1,0+1*1) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0+1*1) = 1;
mem(0+1*1,cw(1,0+1*1)) = 1;
co(0+1*1,cw(1,0+1*1))+=1;
delta(0+1*1,cw(1,0+1*1)) = -1;
ASSUME(creturn[1] >= cw(1,0+1*1));
// ret i8* null, !dbg !55
ret_thread_1 = (- 1);
goto T1BLOCK_END;
T1BLOCK_END:
// Dumping thread 2
int ret_thread_2 = 0;
cdy[2] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[2] >= cstart[2]);
T2BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !58, metadata !DIExpression()), !dbg !68
// br label %label_2, !dbg !50
goto T2BLOCK1;
T2BLOCK1:
// call void @llvm.dbg.label(metadata !67), !dbg !70
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !60, metadata !DIExpression()), !dbg !71
// %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !53
// LD: Guess
old_cr = cr(2,0+1*1);
cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l29_c15
// Check
ASSUME(active[cr(2,0+1*1)] == 2);
ASSUME(cr(2,0+1*1) >= iw(2,0+1*1));
ASSUME(cr(2,0+1*1) >= 0);
ASSUME(cr(2,0+1*1) >= cdy[2]);
ASSUME(cr(2,0+1*1) >= cisb[2]);
ASSUME(cr(2,0+1*1) >= cdl[2]);
ASSUME(cr(2,0+1*1) >= cl[2]);
// Update
creg_r0 = cr(2,0+1*1);
crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+1*1) < cw(2,0+1*1)) {
r0 = buff(2,0+1*1);
ASSUME((!(( (cw(2,0+1*1) < 1) && (1 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,1)> 0));
ASSUME((!(( (cw(2,0+1*1) < 2) && (2 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,2)> 0));
ASSUME((!(( (cw(2,0+1*1) < 3) && (3 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,3)> 0));
ASSUME((!(( (cw(2,0+1*1) < 4) && (4 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,4)> 0));
} else {
if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) {
ASSUME(cr(2,0+1*1) >= old_cr);
}
pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1));
r0 = mem(0+1*1,cr(2,0+1*1));
}
ASSUME(creturn[2] >= cr(2,0+1*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !62, metadata !DIExpression()), !dbg !71
// %conv = trunc i64 %0 to i32, !dbg !54
// call void @llvm.dbg.value(metadata i32 %conv, metadata !59, metadata !DIExpression()), !dbg !68
// call void (...) @dmbst(), !dbg !55
// dumbst: Guess
cds[2] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cds[2] >= cdy[2]);
ASSUME(cds[2] >= cw(2,0+0));
ASSUME(cds[2] >= cw(2,0+1));
ASSUME(cds[2] >= cw(2,0+2));
ASSUME(cds[2] >= cw(2,3+0));
ASSUME(cds[2] >= cw(2,4+0));
ASSUME(cds[2] >= cw(2,5+0));
ASSUME(creturn[2] >= cds[2]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !63, metadata !DIExpression()), !dbg !75
// call void @llvm.dbg.value(metadata i64 1, metadata !65, metadata !DIExpression()), !dbg !75
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !57
// ST: Guess
iw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l31_c3
old_cw = cw(2,0+2*1);
cw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l31_c3
// Check
ASSUME(active[iw(2,0+2*1)] == 2);
ASSUME(active[cw(2,0+2*1)] == 2);
ASSUME(sforbid(0+2*1,cw(2,0+2*1))== 0);
ASSUME(iw(2,0+2*1) >= 0);
ASSUME(iw(2,0+2*1) >= 0);
ASSUME(cw(2,0+2*1) >= iw(2,0+2*1));
ASSUME(cw(2,0+2*1) >= old_cw);
ASSUME(cw(2,0+2*1) >= cr(2,0+2*1));
ASSUME(cw(2,0+2*1) >= cl[2]);
ASSUME(cw(2,0+2*1) >= cisb[2]);
ASSUME(cw(2,0+2*1) >= cdy[2]);
ASSUME(cw(2,0+2*1) >= cdl[2]);
ASSUME(cw(2,0+2*1) >= cds[2]);
ASSUME(cw(2,0+2*1) >= cctrl[2]);
ASSUME(cw(2,0+2*1) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,0+2*1) = 1;
mem(0+2*1,cw(2,0+2*1)) = 1;
co(0+2*1,cw(2,0+2*1))+=1;
delta(0+2*1,cw(2,0+2*1)) = -1;
ASSUME(creturn[2] >= cw(2,0+2*1));
// %cmp = icmp eq i32 %conv, 1, !dbg !58
creg__r0__1_ = max(0,creg_r0);
// %conv1 = zext i1 %cmp to i32, !dbg !58
// call void @llvm.dbg.value(metadata i32 %conv1, metadata !66, metadata !DIExpression()), !dbg !68
// store i32 %conv1, i32* @atom_1_X0_1, align 4, !dbg !59, !tbaa !60
// ST: Guess
iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l33_c15
old_cw = cw(2,3);
cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l33_c15
// Check
ASSUME(active[iw(2,3)] == 2);
ASSUME(active[cw(2,3)] == 2);
ASSUME(sforbid(3,cw(2,3))== 0);
ASSUME(iw(2,3) >= creg__r0__1_);
ASSUME(iw(2,3) >= 0);
ASSUME(cw(2,3) >= iw(2,3));
ASSUME(cw(2,3) >= old_cw);
ASSUME(cw(2,3) >= cr(2,3));
ASSUME(cw(2,3) >= cl[2]);
ASSUME(cw(2,3) >= cisb[2]);
ASSUME(cw(2,3) >= cdy[2]);
ASSUME(cw(2,3) >= cdl[2]);
ASSUME(cw(2,3) >= cds[2]);
ASSUME(cw(2,3) >= cctrl[2]);
ASSUME(cw(2,3) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,3) = (r0==1);
mem(3,cw(2,3)) = (r0==1);
co(3,cw(2,3))+=1;
delta(3,cw(2,3)) = -1;
ASSUME(creturn[2] >= cw(2,3));
// ret i8* null, !dbg !64
ret_thread_2 = (- 1);
goto T2BLOCK_END;
T2BLOCK_END:
// Dumping thread 3
int ret_thread_3 = 0;
cdy[3] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[3] >= cstart[3]);
T3BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !86, metadata !DIExpression()), !dbg !98
// br label %label_3, !dbg !52
goto T3BLOCK1;
T3BLOCK1:
// call void @llvm.dbg.label(metadata !97), !dbg !100
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !88, metadata !DIExpression()), !dbg !101
// %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !55
// LD: Guess
old_cr = cr(3,0+2*1);
cr(3,0+2*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM _l39_c15
// Check
ASSUME(active[cr(3,0+2*1)] == 3);
ASSUME(cr(3,0+2*1) >= iw(3,0+2*1));
ASSUME(cr(3,0+2*1) >= 0);
ASSUME(cr(3,0+2*1) >= cdy[3]);
ASSUME(cr(3,0+2*1) >= cisb[3]);
ASSUME(cr(3,0+2*1) >= cdl[3]);
ASSUME(cr(3,0+2*1) >= cl[3]);
// Update
creg_r1 = cr(3,0+2*1);
crmax(3,0+2*1) = max(crmax(3,0+2*1),cr(3,0+2*1));
caddr[3] = max(caddr[3],0);
if(cr(3,0+2*1) < cw(3,0+2*1)) {
r1 = buff(3,0+2*1);
ASSUME((!(( (cw(3,0+2*1) < 1) && (1 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,1)> 0));
ASSUME((!(( (cw(3,0+2*1) < 2) && (2 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,2)> 0));
ASSUME((!(( (cw(3,0+2*1) < 3) && (3 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,3)> 0));
ASSUME((!(( (cw(3,0+2*1) < 4) && (4 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,4)> 0));
} else {
if(pw(3,0+2*1) != co(0+2*1,cr(3,0+2*1))) {
ASSUME(cr(3,0+2*1) >= old_cr);
}
pw(3,0+2*1) = co(0+2*1,cr(3,0+2*1));
r1 = mem(0+2*1,cr(3,0+2*1));
}
ASSUME(creturn[3] >= cr(3,0+2*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !90, metadata !DIExpression()), !dbg !101
// %conv = trunc i64 %0 to i32, !dbg !56
// call void @llvm.dbg.value(metadata i32 %conv, metadata !87, metadata !DIExpression()), !dbg !98
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !92, metadata !DIExpression()), !dbg !104
// %1 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !58
// LD: Guess
old_cr = cr(3,0);
cr(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM _l40_c15
// Check
ASSUME(active[cr(3,0)] == 3);
ASSUME(cr(3,0) >= iw(3,0));
ASSUME(cr(3,0) >= 0);
ASSUME(cr(3,0) >= cdy[3]);
ASSUME(cr(3,0) >= cisb[3]);
ASSUME(cr(3,0) >= cdl[3]);
ASSUME(cr(3,0) >= cl[3]);
// Update
creg_r2 = cr(3,0);
crmax(3,0) = max(crmax(3,0),cr(3,0));
caddr[3] = max(caddr[3],0);
if(cr(3,0) < cw(3,0)) {
r2 = buff(3,0);
ASSUME((!(( (cw(3,0) < 1) && (1 < crmax(3,0)) )))||(sforbid(0,1)> 0));
ASSUME((!(( (cw(3,0) < 2) && (2 < crmax(3,0)) )))||(sforbid(0,2)> 0));
ASSUME((!(( (cw(3,0) < 3) && (3 < crmax(3,0)) )))||(sforbid(0,3)> 0));
ASSUME((!(( (cw(3,0) < 4) && (4 < crmax(3,0)) )))||(sforbid(0,4)> 0));
} else {
if(pw(3,0) != co(0,cr(3,0))) {
ASSUME(cr(3,0) >= old_cr);
}
pw(3,0) = co(0,cr(3,0));
r2 = mem(0,cr(3,0));
}
ASSUME(creturn[3] >= cr(3,0));
// call void @llvm.dbg.value(metadata i64 %1, metadata !94, metadata !DIExpression()), !dbg !104
// %conv4 = trunc i64 %1 to i32, !dbg !59
// call void @llvm.dbg.value(metadata i32 %conv4, metadata !91, metadata !DIExpression()), !dbg !98
// %cmp = icmp eq i32 %conv, 1, !dbg !60
creg__r1__1_ = max(0,creg_r1);
// %conv5 = zext i1 %cmp to i32, !dbg !60
// call void @llvm.dbg.value(metadata i32 %conv5, metadata !95, metadata !DIExpression()), !dbg !98
// store i32 %conv5, i32* @atom_2_X0_1, align 4, !dbg !61, !tbaa !62
// ST: Guess
iw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l42_c15
old_cw = cw(3,4);
cw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l42_c15
// Check
ASSUME(active[iw(3,4)] == 3);
ASSUME(active[cw(3,4)] == 3);
ASSUME(sforbid(4,cw(3,4))== 0);
ASSUME(iw(3,4) >= creg__r1__1_);
ASSUME(iw(3,4) >= 0);
ASSUME(cw(3,4) >= iw(3,4));
ASSUME(cw(3,4) >= old_cw);
ASSUME(cw(3,4) >= cr(3,4));
ASSUME(cw(3,4) >= cl[3]);
ASSUME(cw(3,4) >= cisb[3]);
ASSUME(cw(3,4) >= cdy[3]);
ASSUME(cw(3,4) >= cdl[3]);
ASSUME(cw(3,4) >= cds[3]);
ASSUME(cw(3,4) >= cctrl[3]);
ASSUME(cw(3,4) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,4) = (r1==1);
mem(4,cw(3,4)) = (r1==1);
co(4,cw(3,4))+=1;
delta(4,cw(3,4)) = -1;
ASSUME(creturn[3] >= cw(3,4));
// %cmp6 = icmp eq i32 %conv4, 0, !dbg !66
creg__r2__0_ = max(0,creg_r2);
// %conv7 = zext i1 %cmp6 to i32, !dbg !66
// call void @llvm.dbg.value(metadata i32 %conv7, metadata !96, metadata !DIExpression()), !dbg !98
// store i32 %conv7, i32* @atom_2_X2_0, align 4, !dbg !67, !tbaa !62
// ST: Guess
iw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l44_c15
old_cw = cw(3,5);
cw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l44_c15
// Check
ASSUME(active[iw(3,5)] == 3);
ASSUME(active[cw(3,5)] == 3);
ASSUME(sforbid(5,cw(3,5))== 0);
ASSUME(iw(3,5) >= creg__r2__0_);
ASSUME(iw(3,5) >= 0);
ASSUME(cw(3,5) >= iw(3,5));
ASSUME(cw(3,5) >= old_cw);
ASSUME(cw(3,5) >= cr(3,5));
ASSUME(cw(3,5) >= cl[3]);
ASSUME(cw(3,5) >= cisb[3]);
ASSUME(cw(3,5) >= cdy[3]);
ASSUME(cw(3,5) >= cdl[3]);
ASSUME(cw(3,5) >= cds[3]);
ASSUME(cw(3,5) >= cctrl[3]);
ASSUME(cw(3,5) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,5) = (r2==0);
mem(5,cw(3,5)) = (r2==0);
co(5,cw(3,5))+=1;
delta(5,cw(3,5)) = -1;
ASSUME(creturn[3] >= cw(3,5));
// ret i8* null, !dbg !68
ret_thread_3 = (- 1);
goto T3BLOCK_END;
T3BLOCK_END:
// Dumping thread 0
int ret_thread_0 = 0;
cdy[0] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[0] >= cstart[0]);
T0BLOCK0:
// %thr0 = alloca i64, align 8
// %thr1 = alloca i64, align 8
// %thr2 = alloca i64, align 8
// call void @llvm.dbg.value(metadata i32 %argc, metadata !119, metadata !DIExpression()), !dbg !141
// call void @llvm.dbg.value(metadata i8** %argv, metadata !120, metadata !DIExpression()), !dbg !141
// %0 = bitcast i64* %thr0 to i8*, !dbg !65
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !65
// call void @llvm.dbg.declare(metadata i64* %thr0, metadata !121, metadata !DIExpression()), !dbg !143
// %1 = bitcast i64* %thr1 to i8*, !dbg !67
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !67
// call void @llvm.dbg.declare(metadata i64* %thr1, metadata !125, metadata !DIExpression()), !dbg !145
// %2 = bitcast i64* %thr2 to i8*, !dbg !69
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !69
// call void @llvm.dbg.declare(metadata i64* %thr2, metadata !126, metadata !DIExpression()), !dbg !147
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !127, metadata !DIExpression()), !dbg !148
// call void @llvm.dbg.value(metadata i64 0, metadata !129, metadata !DIExpression()), !dbg !148
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !72
// ST: Guess
iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l53_c3
old_cw = cw(0,0+2*1);
cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l53_c3
// Check
ASSUME(active[iw(0,0+2*1)] == 0);
ASSUME(active[cw(0,0+2*1)] == 0);
ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(cw(0,0+2*1) >= iw(0,0+2*1));
ASSUME(cw(0,0+2*1) >= old_cw);
ASSUME(cw(0,0+2*1) >= cr(0,0+2*1));
ASSUME(cw(0,0+2*1) >= cl[0]);
ASSUME(cw(0,0+2*1) >= cisb[0]);
ASSUME(cw(0,0+2*1) >= cdy[0]);
ASSUME(cw(0,0+2*1) >= cdl[0]);
ASSUME(cw(0,0+2*1) >= cds[0]);
ASSUME(cw(0,0+2*1) >= cctrl[0]);
ASSUME(cw(0,0+2*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+2*1) = 0;
mem(0+2*1,cw(0,0+2*1)) = 0;
co(0+2*1,cw(0,0+2*1))+=1;
delta(0+2*1,cw(0,0+2*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+2*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !130, metadata !DIExpression()), !dbg !150
// call void @llvm.dbg.value(metadata i64 0, metadata !132, metadata !DIExpression()), !dbg !150
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !74
// ST: Guess
iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l54_c3
old_cw = cw(0,0+1*1);
cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l54_c3
// Check
ASSUME(active[iw(0,0+1*1)] == 0);
ASSUME(active[cw(0,0+1*1)] == 0);
ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(cw(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cw(0,0+1*1) >= old_cw);
ASSUME(cw(0,0+1*1) >= cr(0,0+1*1));
ASSUME(cw(0,0+1*1) >= cl[0]);
ASSUME(cw(0,0+1*1) >= cisb[0]);
ASSUME(cw(0,0+1*1) >= cdy[0]);
ASSUME(cw(0,0+1*1) >= cdl[0]);
ASSUME(cw(0,0+1*1) >= cds[0]);
ASSUME(cw(0,0+1*1) >= cctrl[0]);
ASSUME(cw(0,0+1*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+1*1) = 0;
mem(0+1*1,cw(0,0+1*1)) = 0;
co(0+1*1,cw(0,0+1*1))+=1;
delta(0+1*1,cw(0,0+1*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+1*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !133, metadata !DIExpression()), !dbg !152
// call void @llvm.dbg.value(metadata i64 0, metadata !135, metadata !DIExpression()), !dbg !152
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !76
// ST: Guess
iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l55_c3
old_cw = cw(0,0);
cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l55_c3
// Check
ASSUME(active[iw(0,0)] == 0);
ASSUME(active[cw(0,0)] == 0);
ASSUME(sforbid(0,cw(0,0))== 0);
ASSUME(iw(0,0) >= 0);
ASSUME(iw(0,0) >= 0);
ASSUME(cw(0,0) >= iw(0,0));
ASSUME(cw(0,0) >= old_cw);
ASSUME(cw(0,0) >= cr(0,0));
ASSUME(cw(0,0) >= cl[0]);
ASSUME(cw(0,0) >= cisb[0]);
ASSUME(cw(0,0) >= cdy[0]);
ASSUME(cw(0,0) >= cdl[0]);
ASSUME(cw(0,0) >= cds[0]);
ASSUME(cw(0,0) >= cctrl[0]);
ASSUME(cw(0,0) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0) = 0;
mem(0,cw(0,0)) = 0;
co(0,cw(0,0))+=1;
delta(0,cw(0,0)) = -1;
ASSUME(creturn[0] >= cw(0,0));
// store i32 0, i32* @atom_1_X0_1, align 4, !dbg !77, !tbaa !78
// ST: Guess
iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l56_c15
old_cw = cw(0,3);
cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l56_c15
// Check
ASSUME(active[iw(0,3)] == 0);
ASSUME(active[cw(0,3)] == 0);
ASSUME(sforbid(3,cw(0,3))== 0);
ASSUME(iw(0,3) >= 0);
ASSUME(iw(0,3) >= 0);
ASSUME(cw(0,3) >= iw(0,3));
ASSUME(cw(0,3) >= old_cw);
ASSUME(cw(0,3) >= cr(0,3));
ASSUME(cw(0,3) >= cl[0]);
ASSUME(cw(0,3) >= cisb[0]);
ASSUME(cw(0,3) >= cdy[0]);
ASSUME(cw(0,3) >= cdl[0]);
ASSUME(cw(0,3) >= cds[0]);
ASSUME(cw(0,3) >= cctrl[0]);
ASSUME(cw(0,3) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,3) = 0;
mem(3,cw(0,3)) = 0;
co(3,cw(0,3))+=1;
delta(3,cw(0,3)) = -1;
ASSUME(creturn[0] >= cw(0,3));
// store i32 0, i32* @atom_2_X0_1, align 4, !dbg !82, !tbaa !78
// ST: Guess
iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l57_c15
old_cw = cw(0,4);
cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l57_c15
// Check
ASSUME(active[iw(0,4)] == 0);
ASSUME(active[cw(0,4)] == 0);
ASSUME(sforbid(4,cw(0,4))== 0);
ASSUME(iw(0,4) >= 0);
ASSUME(iw(0,4) >= 0);
ASSUME(cw(0,4) >= iw(0,4));
ASSUME(cw(0,4) >= old_cw);
ASSUME(cw(0,4) >= cr(0,4));
ASSUME(cw(0,4) >= cl[0]);
ASSUME(cw(0,4) >= cisb[0]);
ASSUME(cw(0,4) >= cdy[0]);
ASSUME(cw(0,4) >= cdl[0]);
ASSUME(cw(0,4) >= cds[0]);
ASSUME(cw(0,4) >= cctrl[0]);
ASSUME(cw(0,4) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,4) = 0;
mem(4,cw(0,4)) = 0;
co(4,cw(0,4))+=1;
delta(4,cw(0,4)) = -1;
ASSUME(creturn[0] >= cw(0,4));
// store i32 0, i32* @atom_2_X2_0, align 4, !dbg !83, !tbaa !78
// ST: Guess
iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l58_c15
old_cw = cw(0,5);
cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l58_c15
// Check
ASSUME(active[iw(0,5)] == 0);
ASSUME(active[cw(0,5)] == 0);
ASSUME(sforbid(5,cw(0,5))== 0);
ASSUME(iw(0,5) >= 0);
ASSUME(iw(0,5) >= 0);
ASSUME(cw(0,5) >= iw(0,5));
ASSUME(cw(0,5) >= old_cw);
ASSUME(cw(0,5) >= cr(0,5));
ASSUME(cw(0,5) >= cl[0]);
ASSUME(cw(0,5) >= cisb[0]);
ASSUME(cw(0,5) >= cdy[0]);
ASSUME(cw(0,5) >= cdl[0]);
ASSUME(cw(0,5) >= cds[0]);
ASSUME(cw(0,5) >= cctrl[0]);
ASSUME(cw(0,5) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,5) = 0;
mem(5,cw(0,5)) = 0;
co(5,cw(0,5))+=1;
delta(5,cw(0,5)) = -1;
ASSUME(creturn[0] >= cw(0,5));
// %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !84
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[1] >= cdy[0]);
// %call5 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !85
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[2] >= cdy[0]);
// %call6 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !86
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[3] >= cdy[0]);
// %3 = load i64, i64* %thr0, align 8, !dbg !87, !tbaa !88
r4 = local_mem[0];
// %call7 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !90
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[1]);
// %4 = load i64, i64* %thr1, align 8, !dbg !91, !tbaa !88
r5 = local_mem[1];
// %call8 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !92
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[2]);
// %5 = load i64, i64* %thr2, align 8, !dbg !93, !tbaa !88
r6 = local_mem[2];
// %call9 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !94
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[3]);
// %6 = load i32, i32* @atom_1_X0_1, align 4, !dbg !95, !tbaa !78
// LD: Guess
old_cr = cr(0,3);
cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l68_c13
// Check
ASSUME(active[cr(0,3)] == 0);
ASSUME(cr(0,3) >= iw(0,3));
ASSUME(cr(0,3) >= 0);
ASSUME(cr(0,3) >= cdy[0]);
ASSUME(cr(0,3) >= cisb[0]);
ASSUME(cr(0,3) >= cdl[0]);
ASSUME(cr(0,3) >= cl[0]);
// Update
creg_r7 = cr(0,3);
crmax(0,3) = max(crmax(0,3),cr(0,3));
caddr[0] = max(caddr[0],0);
if(cr(0,3) < cw(0,3)) {
r7 = buff(0,3);
ASSUME((!(( (cw(0,3) < 1) && (1 < crmax(0,3)) )))||(sforbid(3,1)> 0));
ASSUME((!(( (cw(0,3) < 2) && (2 < crmax(0,3)) )))||(sforbid(3,2)> 0));
ASSUME((!(( (cw(0,3) < 3) && (3 < crmax(0,3)) )))||(sforbid(3,3)> 0));
ASSUME((!(( (cw(0,3) < 4) && (4 < crmax(0,3)) )))||(sforbid(3,4)> 0));
} else {
if(pw(0,3) != co(3,cr(0,3))) {
ASSUME(cr(0,3) >= old_cr);
}
pw(0,3) = co(3,cr(0,3));
r7 = mem(3,cr(0,3));
}
ASSUME(creturn[0] >= cr(0,3));
// call void @llvm.dbg.value(metadata i32 %6, metadata !136, metadata !DIExpression()), !dbg !141
// %7 = load i32, i32* @atom_2_X0_1, align 4, !dbg !96, !tbaa !78
// LD: Guess
old_cr = cr(0,4);
cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l69_c13
// Check
ASSUME(active[cr(0,4)] == 0);
ASSUME(cr(0,4) >= iw(0,4));
ASSUME(cr(0,4) >= 0);
ASSUME(cr(0,4) >= cdy[0]);
ASSUME(cr(0,4) >= cisb[0]);
ASSUME(cr(0,4) >= cdl[0]);
ASSUME(cr(0,4) >= cl[0]);
// Update
creg_r8 = cr(0,4);
crmax(0,4) = max(crmax(0,4),cr(0,4));
caddr[0] = max(caddr[0],0);
if(cr(0,4) < cw(0,4)) {
r8 = buff(0,4);
ASSUME((!(( (cw(0,4) < 1) && (1 < crmax(0,4)) )))||(sforbid(4,1)> 0));
ASSUME((!(( (cw(0,4) < 2) && (2 < crmax(0,4)) )))||(sforbid(4,2)> 0));
ASSUME((!(( (cw(0,4) < 3) && (3 < crmax(0,4)) )))||(sforbid(4,3)> 0));
ASSUME((!(( (cw(0,4) < 4) && (4 < crmax(0,4)) )))||(sforbid(4,4)> 0));
} else {
if(pw(0,4) != co(4,cr(0,4))) {
ASSUME(cr(0,4) >= old_cr);
}
pw(0,4) = co(4,cr(0,4));
r8 = mem(4,cr(0,4));
}
ASSUME(creturn[0] >= cr(0,4));
// call void @llvm.dbg.value(metadata i32 %7, metadata !137, metadata !DIExpression()), !dbg !141
// %8 = load i32, i32* @atom_2_X2_0, align 4, !dbg !97, !tbaa !78
// LD: Guess
old_cr = cr(0,5);
cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l70_c13
// Check
ASSUME(active[cr(0,5)] == 0);
ASSUME(cr(0,5) >= iw(0,5));
ASSUME(cr(0,5) >= 0);
ASSUME(cr(0,5) >= cdy[0]);
ASSUME(cr(0,5) >= cisb[0]);
ASSUME(cr(0,5) >= cdl[0]);
ASSUME(cr(0,5) >= cl[0]);
// Update
creg_r9 = cr(0,5);
crmax(0,5) = max(crmax(0,5),cr(0,5));
caddr[0] = max(caddr[0],0);
if(cr(0,5) < cw(0,5)) {
r9 = buff(0,5);
ASSUME((!(( (cw(0,5) < 1) && (1 < crmax(0,5)) )))||(sforbid(5,1)> 0));
ASSUME((!(( (cw(0,5) < 2) && (2 < crmax(0,5)) )))||(sforbid(5,2)> 0));
ASSUME((!(( (cw(0,5) < 3) && (3 < crmax(0,5)) )))||(sforbid(5,3)> 0));
ASSUME((!(( (cw(0,5) < 4) && (4 < crmax(0,5)) )))||(sforbid(5,4)> 0));
} else {
if(pw(0,5) != co(5,cr(0,5))) {
ASSUME(cr(0,5) >= old_cr);
}
pw(0,5) = co(5,cr(0,5));
r9 = mem(5,cr(0,5));
}
ASSUME(creturn[0] >= cr(0,5));
// call void @llvm.dbg.value(metadata i32 %8, metadata !138, metadata !DIExpression()), !dbg !141
// %and = and i32 %7, %8, !dbg !98
creg_r10 = max(creg_r8,creg_r9);
r10 = r8 & r9;
// call void @llvm.dbg.value(metadata i32 %and, metadata !139, metadata !DIExpression()), !dbg !141
// %and10 = and i32 %6, %and, !dbg !99
creg_r11 = max(creg_r10,creg_r7);
r11 = r7 & r10;
// call void @llvm.dbg.value(metadata i32 %and10, metadata !140, metadata !DIExpression()), !dbg !141
// %cmp = icmp eq i32 %and10, 1, !dbg !100
creg__r11__1_ = max(0,creg_r11);
// br i1 %cmp, label %if.then, label %if.end, !dbg !102
old_cctrl = cctrl[0];
cctrl[0] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[0] >= old_cctrl);
ASSUME(cctrl[0] >= creg__r11__1_);
if((r11==1)) {
goto T0BLOCK1;
} else {
goto T0BLOCK2;
}
T0BLOCK1:
// call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([106 x i8], [106 x i8]* @.str.1, i64 0, i64 0), i32 noundef 73, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !103
// unreachable, !dbg !103
r12 = 1;
goto T0BLOCK_END;
T0BLOCK2:
// %9 = bitcast i64* %thr2 to i8*, !dbg !106
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !106
// %10 = bitcast i64* %thr1 to i8*, !dbg !106
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !106
// %11 = bitcast i64* %thr0 to i8*, !dbg !106
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #7, !dbg !106
// ret i32 0, !dbg !107
ret_thread_0 = 0;
goto T0BLOCK_END;
T0BLOCK_END:
ASSUME(meminit(0,1) == mem(0,0));
ASSUME(coinit(0,1) == co(0,0));
ASSUME(deltainit(0,1) == delta(0,0));
ASSUME(meminit(0,2) == mem(0,1));
ASSUME(coinit(0,2) == co(0,1));
ASSUME(deltainit(0,2) == delta(0,1));
ASSUME(meminit(0,3) == mem(0,2));
ASSUME(coinit(0,3) == co(0,2));
ASSUME(deltainit(0,3) == delta(0,2));
ASSUME(meminit(0,4) == mem(0,3));
ASSUME(coinit(0,4) == co(0,3));
ASSUME(deltainit(0,4) == delta(0,3));
ASSUME(meminit(1,1) == mem(1,0));
ASSUME(coinit(1,1) == co(1,0));
ASSUME(deltainit(1,1) == delta(1,0));
ASSUME(meminit(1,2) == mem(1,1));
ASSUME(coinit(1,2) == co(1,1));
ASSUME(deltainit(1,2) == delta(1,1));
ASSUME(meminit(1,3) == mem(1,2));
ASSUME(coinit(1,3) == co(1,2));
ASSUME(deltainit(1,3) == delta(1,2));
ASSUME(meminit(1,4) == mem(1,3));
ASSUME(coinit(1,4) == co(1,3));
ASSUME(deltainit(1,4) == delta(1,3));
ASSUME(meminit(2,1) == mem(2,0));
ASSUME(coinit(2,1) == co(2,0));
ASSUME(deltainit(2,1) == delta(2,0));
ASSUME(meminit(2,2) == mem(2,1));
ASSUME(coinit(2,2) == co(2,1));
ASSUME(deltainit(2,2) == delta(2,1));
ASSUME(meminit(2,3) == mem(2,2));
ASSUME(coinit(2,3) == co(2,2));
ASSUME(deltainit(2,3) == delta(2,2));
ASSUME(meminit(2,4) == mem(2,3));
ASSUME(coinit(2,4) == co(2,3));
ASSUME(deltainit(2,4) == delta(2,3));
ASSUME(meminit(3,1) == mem(3,0));
ASSUME(coinit(3,1) == co(3,0));
ASSUME(deltainit(3,1) == delta(3,0));
ASSUME(meminit(3,2) == mem(3,1));
ASSUME(coinit(3,2) == co(3,1));
ASSUME(deltainit(3,2) == delta(3,1));
ASSUME(meminit(3,3) == mem(3,2));
ASSUME(coinit(3,3) == co(3,2));
ASSUME(deltainit(3,3) == delta(3,2));
ASSUME(meminit(3,4) == mem(3,3));
ASSUME(coinit(3,4) == co(3,3));
ASSUME(deltainit(3,4) == delta(3,3));
ASSUME(meminit(4,1) == mem(4,0));
ASSUME(coinit(4,1) == co(4,0));
ASSUME(deltainit(4,1) == delta(4,0));
ASSUME(meminit(4,2) == mem(4,1));
ASSUME(coinit(4,2) == co(4,1));
ASSUME(deltainit(4,2) == delta(4,1));
ASSUME(meminit(4,3) == mem(4,2));
ASSUME(coinit(4,3) == co(4,2));
ASSUME(deltainit(4,3) == delta(4,2));
ASSUME(meminit(4,4) == mem(4,3));
ASSUME(coinit(4,4) == co(4,3));
ASSUME(deltainit(4,4) == delta(4,3));
ASSUME(meminit(5,1) == mem(5,0));
ASSUME(coinit(5,1) == co(5,0));
ASSUME(deltainit(5,1) == delta(5,0));
ASSUME(meminit(5,2) == mem(5,1));
ASSUME(coinit(5,2) == co(5,1));
ASSUME(deltainit(5,2) == delta(5,1));
ASSUME(meminit(5,3) == mem(5,2));
ASSUME(coinit(5,3) == co(5,2));
ASSUME(deltainit(5,3) == delta(5,2));
ASSUME(meminit(5,4) == mem(5,3));
ASSUME(coinit(5,4) == co(5,3));
ASSUME(deltainit(5,4) == delta(5,3));
ASSERT(r12== 0);
}
| [
"tuan-phong.ngo@it.uu.se"
] | tuan-phong.ngo@it.uu.se |
42ff8f1be994837c4afbca49e27ed355ac47a1eb | b219519f94e6c6782f641a5a9d2dcf22537fac3b | /normal/HDU_BC/BC_65/C.cpp | cd50c6ff6e5d4e999f28b7340f1bba3de7dd7895 | [] | no_license | liangsheng/ACM | 71a37a85b13aa7680a095cf0710c50acb5457641 | 0e80385b51e622b2b97431ac650b8121ecd56e51 | refs/heads/master | 2023-06-01T06:37:51.727779 | 2023-05-14T03:16:18 | 2023-05-14T03:16:18 | 9,337,661 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,940 | cpp | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)
#define pause cout << " press ansy key to continue...", cin >> chh
#define file_r(x) freopen(x, "r", stdin)
#define file_w(x) freopen(x, "w", stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)
#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")
#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)
using namespace std;
int chh;
typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;
const int N = 50005;
int T, n;
int a[N], b[N], c[N], d[N];
void init() {
memset(c, 0, sizeof(c));
}
void add(int x, int y) {
while (x <= n) c[x] += y, x += lowbit(x);
}
int cal(int x) {
int ans = 0;
while (x > 0) ans += c[x], x -= lowbit(x);
return ans;
}
int main() {
int l, r, mid, t, id;
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
rep (i, n) scanf("%d", &a[i]);
FOR (i, 1, n - 1) b[i] = a[i] - a[i - 1];
init();
FOR (i, 1, n) add(i, 1);
FORD (i, n - 1, 0) {
l = 1, r = n, id = i + 1 - b[i];
//sc2(i, id);
while (l != r) {
mid = (l + r) >> 1;
t = cal(mid);
if (t >= id) r = mid;
else l = mid + 1;
}
d[i] = l;
add(l, -1);
}
rep (i, n) {
printf("%d%c", d[i], i == n - 1 ? '\n' : ' ');
}
}
return 0;
}
| [
"904491908@qq.com"
] | 904491908@qq.com |
7ddaa5383398cee66bb3216a7468133d29214c83 | 216d4204b74c94516c176c33de7443832295ce86 | /demos/object_detection_demo_yolov3_async/object_detection_demo_yolov3_async.hpp | a5bf213e5ce270c72360f7535be86b60e89af548 | [
"Apache-2.0"
] | permissive | undeadinu/open_model_zoo | 320cd2289391b474feb417a16569265739a56d9d | db4757112bfe3bd66ad4977fcfec08a55ef02d1f | refs/heads/2018 | 2020-04-16T03:22:32.462850 | 2018-12-14T17:53:48 | 2018-12-14T17:53:48 | 165,229,929 | 0 | 0 | Apache-2.0 | 2019-01-11T11:53:40 | 2019-01-11T11:02:25 | CSS | UTF-8 | C++ | false | false | 5,363 | hpp | /*
// Copyright (c) 2018 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.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <string>
#include <vector>
#include <gflags/gflags.h>
#include <iostream>
#ifdef _WIN32
#include <os/windows/w_dirent.h>
#else
#include <dirent.h>
#endif
/// @brief Message for help argument
static const char help_message[] = "Print a usage message.";
/// @brief Message for images argument
static const char video_message[] = "Required. Path to a video file (specify \"cam\" to work with camera).";
/// @brief Message for model argument
static const char model_message[] = "Required. Path to an .xml file with a trained model.";
/// @brief Message for assigning cnn calculation to device
static const char target_device_message[] = "Optional. Specify a target device to infer on (CPU, GPU). " \
"The demo will look for a suitable plugin for the specified device";
/// @brief Message for performance counters
static const char performance_counter_message[] = "Optional. Enable per-layer performance report.";
/// @brief Message for clDNN custom kernels desc
static const char custom_cldnn_message[] = "Optional. Required for GPU custom kernels."\
"Absolute path to the .xml file with the kernels description.";
/// @brief Message for user library argument
static const char custom_cpu_library_message[] = "Optional. Required for CPU custom layers." \
"Absolute path to a shared library with the layers implementation.";
/// @brief Message for probability threshold argument
static const char thresh_output_message[] = "Optional. Probability threshold for detections.";
/// @brief Message for probability threshold argument
static const char iou_thresh_output_message[] = "Optional. Filtering intersection over union threshold for overlapping boxes.";
/// @brief Message raw output flag
static const char raw_output_message[] = "Optional. Output inference results raw values showing.";
/// @brief Message resizable input flag
static const char input_resizable_message[] = "Optional. Enable resizable input with support of ROI crop and auto resize.";
/// \brief Defines flag for showing help message <br>
DEFINE_bool(h, false, help_message);
/// \brief Define parameter for set video file of reading from camera <br>
/// It is a required parameter
DEFINE_string(i, "", video_message);
/// \brief Defines parameter for setting path to a model file <br>
/// It is a required parameter
DEFINE_string(m, "", model_message);
/// \brief Defines the target device to infer on <br>
DEFINE_string(d, "CPU", target_device_message);
/// \brief Enables per-layer performance report
DEFINE_bool(pc, false, performance_counter_message);
/// @brief Defines GPU custom kernels path <br>
/// Default is ./lib
DEFINE_string(c, "", custom_cldnn_message);
/// @brief Defines absolute path to CPU library with user layers <br>
/// It is a optional parameter
DEFINE_string(l, "", custom_cpu_library_message);
/// \brief Defines flag to output raw scoring results<br>
/// It is an optional parameter
DEFINE_bool(r, false, raw_output_message);
/// \brief Defines value of confidence threshold <br>
/// It is an optional parameter
DEFINE_double(t, 0.5, thresh_output_message);
/// \brief Defines value of intersection over union threshold<br>
/// It is an optional parameter
DEFINE_double(iou_t, 0.4, iou_thresh_output_message);
/// \brief Enables resizable input<br>
/// It is an optional parameter
DEFINE_bool(auto_resize, false, input_resizable_message);
/**
* \brief This function shows a help message
*/
static void showUsage() {
std::cout << std::endl;
std::cout << "object_detection_demo_yolov3_async [OPTION]" << std::endl;
std::cout << "Options:" << std::endl;
std::cout << std::endl;
std::cout << " -h " << help_message << std::endl;
std::cout << " -i \"<path>\" " << video_message << std::endl;
std::cout << " -m \"<path>\" " << model_message << std::endl;
std::cout << " -l \"<absolute_path>\" " << custom_cpu_library_message << std::endl;
std::cout << " Or" << std::endl;
std::cout << " -c \"<absolute_path>\" " << custom_cldnn_message << std::endl;
std::cout << " -d \"<device>\" " << target_device_message << std::endl;
std::cout << " -pc " << performance_counter_message << std::endl;
std::cout << " -r " << raw_output_message << std::endl;
std::cout << " -t " << thresh_output_message << std::endl;
std::cout << " -iou_t " << iou_thresh_output_message << std::endl;
std::cout << " -auto_resize " << input_resizable_message << std::endl;
}
| [
"44090433+openvino-pushbot@users.noreply.github.com"
] | 44090433+openvino-pushbot@users.noreply.github.com |
48c56685e81128a5615ad0fa85834a18c34450c7 | 753a561e46de3ee6428c360225b6f40626551e75 | /Nodo.cpp | e1fc4dd1199cdd91caca8917c9930de8ec762117 | [] | no_license | raydelto/arbol_de_sistema_de_archivos | 587ce1daa12fec5112699f3042cf8bd01286b7a4 | bcb4b4a70293bde3f33bfff888cd3b21b8b540b2 | refs/heads/master | 2023-04-03T16:01:21.535275 | 2021-04-07T20:44:48 | 2021-04-07T20:44:48 | 355,676,933 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 441 | cpp | #include "Nodo.h"
Nodo::Nodo(std::string nombre):
_nombre(nombre)
,_primerHijo(nullptr)
,_ultimoHijo(nullptr)
,_siguiente(nullptr)
{
}
void Nodo::AgregarHijo(Nodo* hijo)
{
if(_primerHijo == nullptr)//la lista de hijos está vacía
{
_primerHijo = hijo;
_ultimoHijo = hijo;
}
else //Si la lista no está vacía
{
_ultimoHijo->_siguiente = hijo;
_ultimoHijo = hijo;
}
}
| [
"raydelto.hernandez@qps.nl"
] | raydelto.hernandez@qps.nl |
b61b3a235ec7530ded1d80e50b7a24d4e5596b34 | ef9f82fa7e2c32480689f8bb27e634ed844a4dbf | /src/cs3-skybox/stb_image_impl.cpp | b2dc4641672ff01e21d9071f2b704050c9ac4db7 | [
"MIT"
] | permissive | catonlyprep/opengl-snippets | e6f90f0e0cd0a75016278f8060a253beca7d4d37 | 2d55dcc063e617355503780bea953db4b378684a | refs/heads/master | 2022-12-21T01:09:04.479022 | 2020-09-29T20:11:06 | 2020-09-29T20:11:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 193 | cpp | // Sarvottamananda (shreesh)
// 2020-09-28
// stb_image_impl.cpp v0.0 (OpenGL Code Snippets)
//
// stb image library implementation
#define STB_IMAGE_IMPLEMENTATION
#include "stb/stb_image.h"
| [
"sarvottamananda@gmail.com"
] | sarvottamananda@gmail.com |
7cc6b70061d9c7bfbb0d580580aa0d0582c32417 | 9a1056723da33ba7247cd016a5afd1f471660604 | /chapter2_UVa11988_list.cpp | 6b5fca98361d15ebcfad044f887f06463ee12156 | [] | no_license | jennyc2004/UVa | 48b802a71fab941de161caea9d52f344de5e1118 | c0c7bae6625cc4d8b11c7085d8fa13f7b4900003 | refs/heads/master | 2020-03-31T01:29:14.198681 | 2019-01-25T22:14:22 | 2019-01-25T22:14:22 | 151,783,580 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,087 | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
char line[100001];
while (scanf("%s", line) != EOF) {
list<char> l;
int len = strlen(line);
list<char>::iterator it = l.begin();
for (int i = 0; i < len; i++) {
if (line[i] == '[') {
it = l.begin();
} else if (line[i] == ']') {
it = l.end();
} else {
l.insert(it, line[i]);
}
}
for (it = l.begin(); it != l.end(); it++) {
printf("%c", *it);
}
printf("\n");
}
return 0;
}
/*
Input
There are several test cases. Each test case is a single line containing at least one and at most 100,000
letters, underscores and two special characters ‘[’ and ‘]’. ‘[’ means the “Home” key is pressed
internally, and ‘]’ means the “End” key is pressed internally. The input is terminated by end-of-file
(EOF).
Output
For each case, print the Beiju text on the screen.
Sample Input
This_is_a_[Beiju]_text
[[]][][]Happy_Birthday_to_Tsinghua_University
Sample Output
BeijuThis_is_a__text
Happy_Birthday_to_Tsinghua_University
*/
| [
"noreply@github.com"
] | noreply@github.com |
806f7c8b03c4d0d00be3fff5259c704946ed1be4 | 622a16b119c34452689b3b3b45e3db59ec66209e | /Source/LanGenProject/LanGenProjectGameModeBase.cpp | 83bd1bd7a1696423d587856563816701bacd7415 | [] | no_license | RozyZx/LanGenProject | 4bc6ad3f938a7dd12b19247993ce39c1f2c68541 | bee7b5511d355665294f92151a08d1a2e21dc9f4 | refs/heads/main | 2023-05-06T10:54:08.470234 | 2021-05-24T06:24:18 | 2021-05-24T06:24:18 | 362,961,646 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 93 | cpp | // Copyright Epic Games, Inc. All Rights Reserved.
#include "LanGenProjectGameModeBase.h"
| [
"rozyzzx2701@gmail.com"
] | rozyzzx2701@gmail.com |
2037095f22ea8be1cd343d975937d5796ea2d321 | 015429426e0ef3d9ed9f7898b37fc5a75426228c | /app/src/main/cpp/Actor.h | a12eb2281e27ce1aa9cf73da79a95b81d469a2c5 | [] | no_license | gordeevso/FlappyBird | d8eeaabb6200ea18905b41efd7d559ae695e685b | 98ee5f9805401a83932fcca2398c08c863ba9eea | refs/heads/master | 2021-01-21T11:31:07.010666 | 2017-08-31T14:08:57 | 2017-08-31T14:08:57 | 102,005,771 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,048 | h | #pragma once
#include <memory>
#include <unordered_map>
#include <functional>
#include <cassert>
#include <vector>
#include <string>
#include <glm/glm.hpp>
#include <tinyxml2.h>
#include "Log.h"
#include "Texture.h"
#include "ResourceManager.h"
namespace Actors {
class Actor;
class ActorComponent;
class ActorFactory;
using ActorId = uint64_t;
using ComponentId = std::string;
using StrongActorPtr = std::shared_ptr<Actor>;
using WeakActorPtr = std::weak_ptr<Actor>;
using StrongActorComponentPtr = std::shared_ptr<ActorComponent>;
using ActorComponentCreatorFn = std::function<ActorComponent*(void)>;
using ActorComponents = std::unordered_map<ComponentId, StrongActorComponentPtr>;
using ActorComponentCreatorMap = std::unordered_map<std::string, ActorComponentCreatorFn>;
using XmlElement = tinyxml2::XMLElement;
using XmlDocument = tinyxml2::XMLDocument;
using tinyxml2::XMLError;
template <class Type>
std::shared_ptr<Type> MakeStrongPtr(std::weak_ptr<Type> pWeakPtr) {
if (!pWeakPtr.expired())
return std::shared_ptr<Type>(pWeakPtr);
else
return std::shared_ptr<Type>();
}
}
namespace Actors {
class Actor
{
friend class ActorFactory;
public:
explicit Actor(ActorId id);
~Actor();
bool Init(XmlElement * pData);
void PostInit();
void Destroy();
void Update(double deltaSec);
ActorId GetId(void) const { return mId; }
template<class ComponentType>
std::weak_ptr<ComponentType> GetComponent(ComponentId id) {
auto findIt = mComponents.find(id);
if (findIt != mComponents.end()) {
StrongActorComponentPtr pBase(findIt->second);
// cast to subclass version of the pointer
std::shared_ptr<ComponentType> pSub(
std::static_pointer_cast<ComponentType>(pBase));
std::weak_ptr<ComponentType> pWeakSub(pSub); // convert strong pointer
// to weak pointer
return pWeakSub; // return the weak pointer
}
else {
return std::weak_ptr<ComponentType>();
}
}
private:
// This is called by the ActorFactory; no one else should be
// adding components.
void AddComponent(StrongActorComponentPtr pComponent);
private:
ActorId mId;
std::string mType;
ActorComponents mComponents; // all components this actor has
};
class ActorComponent
{
friend class ActorFactory;
public:
virtual ~ActorComponent() { }
virtual bool VInit(XmlElement* pData) = 0;
virtual void VPostInit() { }
virtual void VUpdate(double deltaSec) { }
virtual ComponentId VGetId(void) const = 0;
private:
void SetOwner(StrongActorPtr pOwner) { mPtrOwner = pOwner; }
protected:
StrongActorPtr mPtrOwner;
};
} | [
"gordeev.so@yandex.ru"
] | gordeev.so@yandex.ru |
1fa6d646644b7fc049ed964393509ded4aa9318d | 2f7b97dff02166ecf6bb85788ae5578e7e6aab2d | /My Template.cpp | b227d5000a33c6a0747b36562d0d6fba596dbb14 | [] | no_license | Saroar-Sojib/My-Algorithm-Implemntation- | bbdbe9ce897058ab692dc1aee8f29829e93a102e | b7edd53bf42bfb4920996b6b57dcd48c8da5ba17 | refs/heads/main | 2023-08-24T23:07:38.710050 | 2021-10-13T11:33:15 | 2021-10-13T11:33:15 | 351,865,779 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,792 | cpp | #include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define odrkey order_of_key
#define fbodr find_by_order
#define ll long long
#define sq(a) ((a)*(a))
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pi 3.1415926536
#define endl "\n"
#define nwl cout << endl
#define MAXN 200009
#define ff first
#define ss second
#define pb push_back
ll Pow(ll a, ll b) {
if (a == 0) return 0LL;
ll ans = 1;
for (int i = 0; i < b; i++) {
ans *= a;
}
return ans;
}
ll lcm(ll a, ll b) {
return (a * b) / __gcd(a, b);
}
ll md = (ll) 1e9 + 7;
ll bigmod(ll a, ll b, ll m) {
if (b == 0) return 1LL;
ll tm = bigmod(a, b / 2, m);
tm = (tm * tm) % m;
if (b % 2) tm = (tm * a) % m;
return tm;
}
ll ncr(ll n, ll r) {
if (r > n - r) r = n - r;
ll up = 1;
ll down = 1;
for (ll i = 0; i < r; i++) {
up = (up * (n - i)) % md; /* md== mod */
down = (down * (r - i)) % md;
}
return (up * bigmod(down, md - 2, md)) % md;
}
string add(string str1, string str2) {
if (str1.length() > str2.length())
swap(str1, str2);
string str = "";
int n1 = str1.length(), n2 = str2.length();
reverse(str1.begin(), str1.end());
reverse(str2.begin(), str2.end());
int carry = 0;
for (int i = 0; i < n1; i++) {
int sum = ((str1[i] - '0') + (str2[i] - '0') + carry);
str.push_back(sum % 10 + '0');
carry = sum / 10;
}
for (int i = n1; i < n2; i++)
{
int sum = ((str2[i] - '0') + carry);
str.push_back(sum % 10 + '0');
carry = sum / 10;
}
if (carry)
str.push_back(carry + '0');
reverse(str.begin(), str.end());
return str;
}
string divide(string number, int divisor = 2)
{
string ans;
int idx = 0;
int temp = number[idx] - '0';
while (temp < divisor)
temp = temp * 10 + (number[++idx] - '0');
while (number.size() > idx) {
ans += (temp / divisor) + '0';
temp = (temp % divisor) * 10 + number[++idx] - '0';
}
if (ans.length() == 0)
return "0";
return ans;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
/*
#ifndef ONLINE_JUDGE
// for getting innput from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
*/
int t;
cin >> t;
for (int cs = 1; cs <= t; cs++) {
string a, b;
cin >> a >> b;
string s = add(a, b);
cout << "Case " << cs << ": ";
cout << divide(s) << endl;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
4cf9de7ee8787642433450e5ededd189a25a21d5 | 88ae8695987ada722184307301e221e1ba3cc2fa | /third_party/tflite/src/tensorflow/lite/kernels/internal/optimized/4bit/neon_fully_connected_aarch64_sdot.cc | 23b0255bdae6cb924e1cbbb95e5656980a9b849d | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"LicenseRef-scancode-generic-cla",
"BSD-2-Clause"
] | permissive | iridium-browser/iridium-browser | 71d9c5ff76e014e6900b825f67389ab0ccd01329 | 5ee297f53dc7f8e70183031cff62f37b0f19d25f | refs/heads/master | 2023-08-03T16:44:16.844552 | 2023-07-20T15:17:00 | 2023-07-23T16:09:30 | 220,016,632 | 341 | 40 | BSD-3-Clause | 2021-08-13T13:54:45 | 2019-11-06T14:32:31 | null | UTF-8 | C++ | false | false | 24,657 | cc | /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#if defined(FC_4BIT_NEON) && defined(__ARM_NEON__)
#include <stdint.h>
#include <algorithm>
#include <vector>
#include "tensorflow/lite/kernels/internal/cppmath.h"
#include "tensorflow/lite/kernels/internal/optimized/4bit/neon_fully_connected_impl.h"
namespace tflite {
namespace optimized_4bit {
#define INNER_LOOP_PREAMBLE "1"
#define OUTER_LOOP_BEGIN "2"
#define OUTER_LOOP_END "3"
#define INNER_LOOP_BEGIN "4"
#define INNER_LOOP "5"
#define INNER_LOOP_END "6"
#define INNER_LOOP_POSTAMBLE "7"
#define END "8"
#define KERNEL_4x1 \
"dup v24.16b, %w[bit_shift]\n" \
"mov x0, %[element_ptr]\n" \
"mov x6, %[lhs_val]\n" \
"mov x1, %[rhs_val]\n" \
\
INNER_LOOP_BEGIN \
":\n" \
"mov x4, x6\n" \
"ld1 {v4.16b}, [x4], #16\n" \
"dup v16.4s, wzr\n" \
"dup v17.4s, wzr\n" \
"ld1 {v5.16b}, [x4], #16\n" \
"dup v18.4s, wzr\n" \
"dup v19.4s, wzr\n" \
"ld1 {v6.16b, v7.16b}, [x4], #32\n" \
"and v8.16b, v4.16b, v24.16b\n" \
"and v9.16b, v5.16b, v24.16b\n" \
"ushr v12.16b, v4.16b, #4\n" \
"ushr v13.16b, v5.16b, #4\n" \
"ld1 {v0.16b, v1.16b}, [x1], #32\n" \
"and v10.16b, v6.16b, v24.16b\n" \
"and v11.16b, v7.16b, v24.16b\n" \
"ushr v14.16b, v6.16b, #4\n" \
"ushr v15.16b, v7.16b, #4\n" \
"mov w3, %w[run_depth]\n" \
"subs w3, w3, #1\n" \
"b.ls " INNER_LOOP_END "f\n" \
\
INNER_LOOP \
":\n" \
"ld1 {v4.16b, v5.16b, v6.16b, v7.16b}, [x4], #64\n" \
"sdot v16.4s, v8.16b, v1.16b\n" \
"sdot v17.4s, v9.16b, v1.16b\n" \
"sdot v18.4s, v10.16b, v1.16b\n" \
"sdot v19.4s, v11.16b, v1.16b\n" \
"sdot v16.4s, v12.16b, v0.16b\n" \
"sdot v17.4s, v13.16b, v0.16b\n" \
"sdot v18.4s, v14.16b, v0.16b\n" \
"sdot v19.4s, v15.16b, v0.16b\n" \
"and v8.16b, v4.16b, v24.16b\n" \
"and v9.16b, v5.16b, v24.16b\n" \
"ushr v12.16b, v4.16b, #4\n" \
"ushr v13.16b, v5.16b, #4\n" \
"ld1 {v0.16b, v1.16b}, [x1], #32\n" \
"and v10.16b, v6.16b, v24.16b\n" \
"and v11.16b, v7.16b, v24.16b\n" \
"ushr v14.16b, v6.16b, #4\n" \
"ushr v15.16b, v7.16b, #4\n" \
"subs w3, w3, #1\n" \
"b.hi " INNER_LOOP "b\n" \
\
INNER_LOOP_END \
":\n" \
"sdot v16.4s, v8.16b, v1.16b\n" \
"sdot v17.4s, v9.16b, v1.16b\n" \
"sdot v18.4s, v10.16b, v1.16b\n" \
"sdot v19.4s, v11.16b, v1.16b\n" \
"sdot v16.4s, v12.16b, v0.16b\n" \
"sdot v17.4s, v13.16b, v0.16b\n" \
"sdot v18.4s, v14.16b, v0.16b\n" \
"sdot v19.4s, v15.16b, v0.16b\n" \
"addp v4.4s, v16.4s, v17.4s\n" \
"addp v5.4s, v18.4s, v19.4s\n" \
"addp v6.4s, v4.4s, v5.4s\n" \
"st1 {v6.4s}, [x0], #16\n"
#define KERNEL_4x2 \
"dup v24.16b, %w[bit_shift]\n" \
"mov x0, %[element_ptr]\n" \
"mov x6, %[lhs_val]\n" \
"mov x1, %[rhs_val]\n" \
\
INNER_LOOP_BEGIN \
":\n" \
"mov x4, x6\n" \
"ld1 {v4.16b}, [x4], #16\n" \
"dup v16.4s, wzr\n" \
"dup v17.4s, wzr\n" \
"ld1 {v5.16b}, [x4], #16\n" \
"dup v18.4s, wzr\n" \
"dup v19.4s, wzr\n" \
"ld1 {v6.16b, v7.16b}, [x4], #32\n" \
"dup v20.4s, wzr\n" \
"dup v21.4s, wzr\n" \
"and v8.16b, v4.16b, v24.16b\n" \
"and v9.16b, v5.16b, v24.16b\n" \
"dup v22.4s, wzr\n" \
"dup v23.4s, wzr\n" \
"ushr v12.16b, v4.16b, #4\n" \
"ushr v13.16b, v5.16b, #4\n" \
"ld1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x1], #64\n" \
"and v10.16b, v6.16b, v24.16b\n" \
"and v11.16b, v7.16b, v24.16b\n" \
"ushr v14.16b, v6.16b, #4\n" \
"ushr v15.16b, v7.16b, #4\n" \
"mov w3, %w[run_depth]\n" \
"subs w3, w3, #1\n" \
"b.ls " INNER_LOOP_END "f\n" \
\
INNER_LOOP \
":\n" \
"ld1 {v4.16b, v5.16b, v6.16b, v7.16b}, [x4], #64\n" \
\
"sdot v16.4s, v12.16b, v0.16b\n" \
"sdot v17.4s, v13.16b, v0.16b\n" \
"sdot v18.4s, v14.16b, v0.16b\n" \
"sdot v19.4s, v15.16b, v0.16b\n" \
"sdot v16.4s, v8.16b, v1.16b\n" \
"sdot v17.4s, v9.16b, v1.16b\n" \
"sdot v18.4s, v10.16b, v1.16b\n" \
"sdot v19.4s, v11.16b, v1.16b\n" \
"sdot v20.4s, v12.16b, v2.16b\n" \
"sdot v21.4s, v13.16b, v2.16b\n" \
"sdot v22.4s, v14.16b, v2.16b\n" \
"sdot v23.4s, v15.16b, v2.16b\n" \
"sdot v20.4s, v8.16b, v3.16b\n" \
"sdot v21.4s, v9.16b, v3.16b\n" \
"sdot v22.4s, v10.16b, v3.16b\n" \
"sdot v23.4s, v11.16b, v3.16b\n" \
\
"and v8.16b, v4.16b, v24.16b\n" \
"and v9.16b, v5.16b, v24.16b\n" \
"ushr v12.16b, v4.16b, #4\n" \
"ld1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x1], #64\n" \
"ushr v13.16b, v5.16b, #4\n" \
"and v10.16b, v6.16b, v24.16b\n" \
"and v11.16b, v7.16b, v24.16b\n" \
"ushr v14.16b, v6.16b, #4\n" \
"ushr v15.16b, v7.16b, #4\n" \
"subs w3, w3, #1\n" \
"b.hi " INNER_LOOP "b\n" \
\
INNER_LOOP_END \
":\n" \
"sdot v16.4s, v12.16b, v0.16b\n" \
"sdot v17.4s, v13.16b, v0.16b\n" \
"sdot v18.4s, v14.16b, v0.16b\n" \
"sdot v19.4s, v15.16b, v0.16b\n" \
"sdot v16.4s, v8.16b, v1.16b\n" \
"sdot v17.4s, v9.16b, v1.16b\n" \
"sdot v18.4s, v10.16b, v1.16b\n" \
"sdot v19.4s, v11.16b, v1.16b\n" \
"sdot v20.4s, v12.16b, v2.16b\n" \
"sdot v21.4s, v13.16b, v2.16b\n" \
"sdot v22.4s, v14.16b, v2.16b\n" \
"sdot v23.4s, v15.16b, v2.16b\n" \
"sdot v20.4s, v8.16b, v3.16b\n" \
"sdot v21.4s, v9.16b, v3.16b\n" \
"sdot v22.4s, v10.16b, v3.16b\n" \
"sdot v23.4s, v11.16b, v3.16b\n" \
"addp v4.4s, v16.4s, v17.4s\n" \
"addp v5.4s, v18.4s, v19.4s\n" \
"addp v8.4s, v20.4s, v21.4s\n" \
"addp v9.4s, v22.4s, v23.4s\n" \
"addp v6.4s, v4.4s, v5.4s\n" \
"addp v7.4s, v8.4s, v9.4s\n" \
"st1 {v6.4s, v7.4s}, [x0], #32\n"
#define KERNEL_4x4 \
"dup v3.16b, %w[bit_shift]\n" \
"mov x0, %[element_ptr]\n" \
"mov x6, %[lhs_val]\n" \
"mov x1, %[rhs_val]\n" \
\
INNER_LOOP_BEGIN \
":\n" \
"mov x4, x6\n" \
"ld1 {v4.16b}, [x4], #16\n" \
"dup v16.4s, wzr\n" \
"dup v17.4s, wzr\n" \
"ld1 {v5.16b}, [x4], #16\n" \
"dup v18.4s, wzr\n" \
"dup v19.4s, wzr\n" \
"ld1 {v6.16b, v7.16b}, [x4], #32\n" \
"and v8.16b, v4.16b, v3.16b\n" \
"and v9.16b, v5.16b, v3.16b\n" \
"dup v20.4s, wzr\n" \
"dup v21.4s, wzr\n" \
"dup v22.4s, wzr\n" \
"dup v23.4s, wzr\n" \
"dup v24.4s, wzr\n" \
"dup v25.4s, wzr\n" \
"dup v26.4s, wzr\n" \
"dup v27.4s, wzr\n" \
"dup v28.4s, wzr\n" \
"dup v29.4s, wzr\n" \
"dup v30.4s, wzr\n" \
"dup v31.4s, wzr\n" \
"ushr v12.16b, v4.16b, #4\n" \
"ushr v13.16b, v5.16b, #4\n" \
"ld1 {v0.16b, v1.16b}, [x1], #32\n" \
"and v10.16b, v6.16b, v3.16b\n" \
"and v11.16b, v7.16b, v3.16b\n" \
"ushr v14.16b, v6.16b, #4\n" \
"ushr v15.16b, v7.16b, #4\n" \
"mov w3, %w[run_depth]\n" \
"subs w3, w3, #1\n" \
"b.ls " INNER_LOOP_END "f\n" \
\
INNER_LOOP \
":\n" \
"ld1 {v4.16b, v5.16b, v6.16b, v7.16b}, [x4], #64\n" \
"sdot v16.4s, v12.16b, v0.16b\n" \
"sdot v17.4s, v13.16b, v0.16b\n" \
"sdot v18.4s, v14.16b, v0.16b\n" \
"sdot v19.4s, v15.16b, v0.16b\n" \
"ld1 {v2.16b}, [x1], #16\n" \
"sdot v16.4s, v8.16b, v1.16b\n" \
"sdot v17.4s, v9.16b, v1.16b\n" \
"sdot v18.4s, v10.16b, v1.16b\n" \
"sdot v19.4s, v11.16b, v1.16b\n" \
"ld1 {v0.16b}, [x1], #16\n" \
"sdot v20.4s, v12.16b, v2.16b\n" \
"sdot v21.4s, v13.16b, v2.16b\n" \
"sdot v22.4s, v14.16b, v2.16b\n" \
"sdot v23.4s, v15.16b, v2.16b\n" \
"ld1 {v1.16b}, [x1], #16\n" \
"sdot v20.4s, v8.16b, v0.16b\n" \
"sdot v21.4s, v9.16b, v0.16b\n" \
"sdot v22.4s, v10.16b, v0.16b\n" \
"sdot v23.4s, v11.16b, v0.16b\n" \
"ld1 {v2.16b}, [x1], #16\n" \
"sdot v24.4s, v12.16b, v1.16b\n" \
"sdot v25.4s, v13.16b, v1.16b\n" \
"sdot v26.4s, v14.16b, v1.16b\n" \
"sdot v27.4s, v15.16b, v1.16b\n" \
"ld1 {v0.16b}, [x1], #16\n" \
"sdot v24.4s, v8.16b, v2.16b\n" \
"sdot v25.4s, v9.16b, v2.16b\n" \
"sdot v26.4s, v10.16b, v2.16b\n" \
"sdot v27.4s, v11.16b, v2.16b\n" \
"ld1 {v1.16b}, [x1], #16\n" \
"sdot v28.4s, v12.16b, v0.16b\n" \
"sdot v29.4s, v13.16b, v0.16b\n" \
"sdot v30.4s, v14.16b, v0.16b\n" \
"sdot v31.4s, v15.16b, v0.16b\n" \
"sdot v28.4s, v8.16b, v1.16b\n" \
"sdot v29.4s, v9.16b, v1.16b\n" \
"sdot v30.4s, v10.16b, v1.16b\n" \
"sdot v31.4s, v11.16b, v1.16b\n" \
"ld1 {v0.16b}, [x1], #16\n" \
"and v8.16b, v4.16b, v3.16b\n" \
"and v9.16b, v5.16b, v3.16b\n" \
"ushr v12.16b, v4.16b, #4\n" \
"ushr v13.16b, v5.16b, #4\n" \
"ld1 {v1.16b}, [x1], #16\n" \
"and v10.16b, v6.16b, v3.16b\n" \
"and v11.16b, v7.16b, v3.16b\n" \
"ushr v14.16b, v6.16b, #4\n" \
"ushr v15.16b, v7.16b, #4\n" \
"subs w3, w3, #1\n" \
"b.hi " INNER_LOOP "b\n" \
\
INNER_LOOP_END \
":\n" \
"sdot v16.4s, v12.16b, v0.16b\n" \
"sdot v17.4s, v13.16b, v0.16b\n" \
"sdot v18.4s, v14.16b, v0.16b\n" \
"sdot v19.4s, v15.16b, v0.16b\n" \
"ld1 {v2.16b}, [x1], #16\n" \
"sdot v16.4s, v8.16b, v1.16b\n" \
"sdot v17.4s, v9.16b, v1.16b\n" \
"sdot v18.4s, v10.16b, v1.16b\n" \
"sdot v19.4s, v11.16b, v1.16b\n" \
"ld1 {v0.16b}, [x1], #16\n" \
"sdot v20.4s, v12.16b, v2.16b\n" \
"sdot v21.4s, v13.16b, v2.16b\n" \
"sdot v22.4s, v14.16b, v2.16b\n" \
"sdot v23.4s, v15.16b, v2.16b\n" \
"ld1 {v1.16b}, [x1], #16\n" \
"sdot v20.4s, v8.16b, v0.16b\n" \
"sdot v21.4s, v9.16b, v0.16b\n" \
"sdot v22.4s, v10.16b, v0.16b\n" \
"sdot v23.4s, v11.16b, v0.16b\n" \
"ld1 {v2.16b}, [x1], #16\n" \
"sdot v24.4s, v12.16b, v1.16b\n" \
"sdot v25.4s, v13.16b, v1.16b\n" \
"sdot v26.4s, v14.16b, v1.16b\n" \
"sdot v27.4s, v15.16b, v1.16b\n" \
"ld1 {v0.16b}, [x1], #16\n" \
"sdot v24.4s, v8.16b, v2.16b\n" \
"sdot v25.4s, v9.16b, v2.16b\n" \
"sdot v26.4s, v10.16b, v2.16b\n" \
"sdot v27.4s, v11.16b, v2.16b\n" \
"ld1 {v1.16b}, [x1], #16\n" \
"sdot v28.4s, v12.16b, v0.16b\n" \
"sdot v29.4s, v13.16b, v0.16b\n" \
"sdot v30.4s, v14.16b, v0.16b\n" \
"sdot v31.4s, v15.16b, v0.16b\n" \
"sdot v28.4s, v8.16b, v1.16b\n" \
"sdot v29.4s, v9.16b, v1.16b\n" \
"sdot v30.4s, v10.16b, v1.16b\n" \
"sdot v31.4s, v11.16b, v1.16b\n" \
"addp v14.4s, v16.4s, v17.4s\n" \
"addp v15.4s, v18.4s, v19.4s\n" \
"addp v12.4s, v20.4s, v21.4s\n" \
"addp v13.4s, v22.4s, v23.4s\n" \
"addp v10.4s, v24.4s, v25.4s\n" \
"addp v11.4s, v26.4s, v27.4s\n" \
"addp v8.4s, v28.4s, v29.4s\n" \
"addp v9.4s, v30.4s, v31.4s\n" \
"addp v4.4s, v14.4s, v15.4s\n" \
"addp v5.4s, v12.4s, v13.4s\n" \
"addp v6.4s, v10.4s, v11.4s\n" \
"addp v7.4s, v8.4s, v9.4s\n" \
"st1 {v4.4s, v5.4s, v6.4s, v7.4s}, [x0], #64\n"
template <int RowsLeft, int RowsRight, int Cols>
void NeonRunKernelSDot(const uint8_t* lhs, const int8_t* rhs, int32_t* dst,
int lhs_layout_rows, int lhs_layout_cols,
int rhs_layout_rows, int rhs_layout_cols,
int dst_layout_rows, int dst_layout_cols) {}
template <>
void NeonRunKernelSDot<4, 1, 32>(const uint8_t* lhs, const int8_t* rhs,
int32_t* dst, int lhs_layout_rows,
int lhs_layout_cols, int rhs_layout_rows,
int rhs_layout_cols, int dst_layout_rows,
int dst_layout_cols) {
const int rows_left = 4;
const int rows_right = 1;
const int cols = 32;
const int start_row = 0;
const int start_col = 0;
const int end_row = lhs_layout_rows;
const int end_col = rhs_layout_rows;
const int clamped_end_row = std::min(end_row, dst_layout_cols);
const int clamped_end_col = std::min(end_col, dst_layout_rows);
int32_t* element_ptr = dst;
const int outer_rows = (clamped_end_row + rows_left - 1) / rows_left;
const int outer_cols = (clamped_end_col + rows_right - 1) / rows_right;
const int depth = std::min(lhs_layout_cols / cols, rhs_layout_cols / cols);
const uint8_t bit_shift = 15;
const int run_depth = depth;
for (int i = start_row; i < outer_rows; ++i) {
int left_index = i * rows_left * lhs_layout_cols / 2;
const uint8_t* lhs_val_data = lhs + left_index;
for (int j = start_col; j < outer_cols; ++j) {
const uint8_t* lhs_val = lhs_val_data;
int right_index = j * rows_right * rhs_layout_cols;
const int8_t* rhs_val = rhs + right_index;
asm volatile(KERNEL_4x1
: [lhs_val] "+r"(lhs_val), [rhs_val] "+r"(rhs_val),
[element_ptr] "+r"(element_ptr)
: [bit_shift] "r"(bit_shift), [run_depth] "r"(run_depth)
: "cc", "memory", "x0", "x1", "w2", "w3", "x4", "w5", "x6",
"v0", "v1", "v4", "v5", "v6", "v7", "v8", "v9", "v10",
"v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18",
"v19", "v20", "v21", "v22", "v23", "v24");
element_ptr += 4;
}
}
}
template <>
void NeonRunKernelSDot<4, 2, 32>(const uint8_t* lhs, const int8_t* rhs,
int32_t* dst, int lhs_layout_rows,
int lhs_layout_cols, int rhs_layout_rows,
int rhs_layout_cols, int dst_layout_rows,
int dst_layout_cols) {
const int rows_left = 4;
const int rows_right = 2;
const int cols = 32;
const int start_row = 0;
const int start_col = 0;
const int end_row = lhs_layout_rows;
const int end_col = rhs_layout_rows;
const int clamped_end_row = std::min(end_row, dst_layout_cols);
const int clamped_end_col = std::min(end_col, dst_layout_rows);
int32_t* element_ptr = dst;
const int outer_rows = (clamped_end_row + rows_left - 1) / rows_left;
const int outer_cols = (clamped_end_col + rows_right - 1) / rows_right;
const int depth = std::min(lhs_layout_cols / cols, rhs_layout_cols / cols);
const uint8_t bit_shift = 15;
const int run_depth = depth;
for (int i = start_row; i < outer_rows; ++i) {
int left_index = i * rows_left * lhs_layout_cols / 2;
const uint8_t* lhs_val_data = lhs + left_index;
for (int j = start_col; j < outer_cols; ++j) {
const uint8_t* lhs_val = lhs_val_data;
int right_index = j * rows_right * rhs_layout_cols;
const int8_t* rhs_val = rhs + right_index;
asm volatile(KERNEL_4x2
: [lhs_val] "+r"(lhs_val), [rhs_val] "+r"(rhs_val),
[element_ptr] "+r"(element_ptr)
: [bit_shift] "r"(bit_shift), [run_depth] "r"(run_depth)
: "cc", "memory", "x0", "x1", "w2", "w3", "x4", "w5", "x6",
"v0", "v1", "v4", "v5", "v6", "v7", "v8", "v9", "v10",
"v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18",
"v19", "v20", "v21", "v22", "v23", "v24");
element_ptr += 8;
}
}
}
template <>
void NeonRunKernelSDot<4, 4, 32>(const uint8_t* lhs, const int8_t* rhs,
int32_t* dst, int lhs_layout_rows,
int lhs_layout_cols, int rhs_layout_rows,
int rhs_layout_cols, int dst_layout_rows,
int dst_layout_cols) {
const int rows_left = 4;
const int rows_right = 4;
const int cols = 32;
const int start_row = 0;
const int start_col = 0;
const int end_row = lhs_layout_rows;
const int end_col = rhs_layout_rows;
const int clamped_end_row = std::min(end_row, dst_layout_cols);
const int clamped_end_col = std::min(end_col, dst_layout_rows);
int32_t* element_ptr = dst;
const int outer_rows = (clamped_end_row + rows_left - 1) / rows_left;
const int outer_cols = (clamped_end_col + rows_right - 1) / rows_right;
const int depth = std::min(lhs_layout_cols / cols, rhs_layout_cols / cols);
const uint8_t bit_shift = 15;
const int run_depth = depth;
for (int i = start_row; i < outer_rows; ++i) {
int left_index = i * rows_left * lhs_layout_cols / 2;
const uint8_t* lhs_val_data = lhs + left_index;
for (int j = start_col; j < outer_cols; ++j) {
const uint8_t* lhs_val = lhs_val_data;
int right_index = j * rows_right * rhs_layout_cols;
const int8_t* rhs_val = rhs + right_index;
asm volatile(KERNEL_4x4
: [lhs_val] "+r"(lhs_val), [rhs_val] "+r"(rhs_val),
[element_ptr] "+r"(element_ptr)
: [bit_shift] "r"(bit_shift), [run_depth] "r"(run_depth)
: "cc", "memory", "x0", "x1", "w2", "w3", "x4", "w5", "x6",
"v0", "v1", "v4", "v5", "v6", "v7", "v8", "v9", "v10",
"v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18",
"v19", "v20", "v21", "v22", "v23", "v24");
element_ptr += 16;
}
}
}
#undef INNER_LOOP_PREAMBLE
#undef OUTER_LOOP_BEGIN
#undef OUTER_LOOP_END
#undef INNER_LOOP_BEGIN
#undef INNER_LOOP
#undef INNER_LOOP_END
#undef INNER_LOOP_POSTAMBLE
#undef END
} // namespace optimized_4bit
} // namespace tflite
#endif // defined(FC_4BIT_NEON) && defined(__ARM_NEON__)
| [
"jengelh@inai.de"
] | jengelh@inai.de |
378ca69580ba706311e4dd4c4507ede03cf8e817 | b6607ecc11e389cc56ee4966293de9e2e0aca491 | /codeforces.com/Contests/Other contests/VK Cup/2018/Round 1/C/C.cpp | f32470dad762f125f4a7beaa7548092eeab0e5a1 | [] | no_license | BekzhanKassenov/olymp | ec31cefee36d2afe40eeead5c2c516f9bf92e66d | e3013095a4f88fb614abb8ac9ba532c5e955a32e | refs/heads/master | 2022-09-21T10:07:10.232514 | 2021-11-01T16:40:24 | 2021-11-01T16:40:24 | 39,900,971 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,112 | cpp | /*****************************************
** Solution by Bekzhan Kassenov **
*****************************************/
#include <bits/stdc++.h>
using namespace std;
#define by(T, x) [](const T& a, const T& b) { return a.x < b.x; }
#define all(x) (x).begin(), (x).end()
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const double EPS = 1e-9;
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 2000 * 1000 * 1000;
const int MAXN = 300010;
const int L = 32;
template <typename T>
inline T sqr(T n) {
return n * n;
}
int n;
long long a[MAXN], p[MAXN];
int l[L * MAXN], r[L * MAXN];
int cnt[L * MAXN];
int ROOT = 1;
int next_node = 2;
int charAt(long long num, int pos) {
pos = L - 1 - pos;
return (num >> pos) & 1;
}
int get_node(int idx) {
if (idx == 0) {
return next_node++;
}
return idx;
}
void add(long long num) {
int cur = ROOT;
for (int i = 0; i < L; i++) {
int ch = charAt(num, i);
if (ch == 0) {
l[cur] = get_node(l[cur]);
cur = l[cur];
} else {
r[cur] = get_node(r[cur]);
cur = r[cur];
}
cnt[cur]++;
}
}
long long get(long long num) {
long long ans = 0;
int cur = ROOT;
for (int i = 0; i < L; i++) {
ans <<= 1;
int ch = charAt(num, i);
if (ch == 0) {
if (cnt[l[cur]] == 0) {
ans |= 1;
cur = r[cur];
} else {
cur = l[cur];
}
} else {
if (cnt[r[cur]] == 0) {
ans |= 1;
cur = l[cur];
} else {
cur = r[cur];
}
}
cnt[cur]--;
}
return ans;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("in", "r", stdin);
#endif
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
cin >> p[i];
add(p[i]);
}
for (int i = 1; i <= n; i++) {
cout << get(a[i]) << ' ';
}
cout << endl;
return 0;
}
| [
"bekzhan.kassenov@gmail.com"
] | bekzhan.kassenov@gmail.com |
6b947f9274e2dc9141b28d3503bf9092bc6692ff | 21c0a8588978cf4ecc31d827d4e5b778401f9eee | /timus/1982.cpp | 6f302f9efe354aef3c7ad9d2566a9cf7223b8d2e | [
"MIT"
] | permissive | cosmicray001/Online_judge_Solutions | c082faa9cc8c9448fa7be8504a150a822d0d5b8a | 5dc6f90d3848eb192e6edea8e8c731f41a1761dd | refs/heads/master | 2022-03-01T12:35:28.985743 | 2022-02-07T10:29:16 | 2022-02-07T10:29:16 | 116,611,495 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,114 | cpp | #include <bits/stdc++.h>
#define le 102
#define ll long long int
using namespace std;
struct edge{
int x, y;
ll w;
};
bool comp(edge a, edge b){
return a.w < b.w;
}
vector<edge> v;
vector<int> v1;
ll arr[le][le];
bool ck[le];
int p[le];
int fnc(int a){
if(p[a] == a) return a;
return p[a] = fnc(p[a]);
}
int main(){
//freopen("input.txt", "r", stdin);
for(int i = 0; i < le; p[i] = i, ck[i] = false, i++);
int n, len, a;
ll cost;
scanf("%d %d", &n, &len);
for(int i = 0; i < len; scanf("%d", &a), v1.push_back(a), ck[a] = true, i++);
edge eg;
for(int i = 1; i < n + 1; i++){
for(int j = 1; j < n + 1; j++){
scanf("%lld", &arr[i][j]);
}
}
for(int i = 1; i < n + 1; i++){
for(int j = i; j < n + 1; j++){
if(ck[i] && ck[j]) eg.w = 0;
else eg.w = arr[i][j];
eg.x = i;
eg.y = j;
v.push_back(eg);
}
}
ll sum = 0;
sort(v.begin(), v.end(), comp);
for(int i = 0; i < v.size(); i++){
int aa = fnc(v[i].x), bb = fnc(v[i].y);
if(aa != bb){
p[aa] = bb;
sum += v[i].w;
}
}
printf("%lld\n", sum);
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
fd47cba72397890698e0180e2069ec9f669f90e1 | 95457f5c7961dd67ac578b3b63a80f97d0a70717 | /third_party/compiler-rt/lib/gwp_asan/tests/late_init.cpp | c7d62c8f3c899a5fe1fc2978c37ac410c37666e5 | [
"Apache-2.0",
"NCSA",
"MIT",
"LLVM-exception"
] | permissive | pzread/fuzvisor | b66ca7cdc132746ef955db3459b21f837c7b58d2 | acf939aaf789ed8422dea66eb887911345a58d9e | refs/heads/master | 2023-07-22T14:20:25.335278 | 2021-01-31T01:25:15 | 2021-01-31T01:25:15 | 276,001,051 | 32 | 0 | Apache-2.0 | 2023-07-05T21:04:36 | 2020-06-30T04:56:45 | Rust | UTF-8 | C++ | false | false | 759 | cpp | //===-- late_init.cpp -------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "gwp_asan/guarded_pool_allocator.h"
#include "gwp_asan/options.h"
#include "gtest/gtest.h"
TEST(LateInit, CheckLateInitIsOK) {
gwp_asan::GuardedPoolAllocator GPA;
for (size_t i = 0; i < 0x100; ++i)
EXPECT_FALSE(GPA.shouldSample());
gwp_asan::options::Options Opts;
Opts.Enabled = true;
Opts.SampleRate = 1;
GPA.init(Opts);
EXPECT_TRUE(GPA.shouldSample());
}
| [
"netfirewall@gmail.com"
] | netfirewall@gmail.com |
7261738823bcecda25393c56d85f1d685529df8a | 184180d341d2928ab7c5a626d94f2a9863726c65 | /issuestests/selectiveInference/inst/testfiles/log_density_laplace_conditional_/libFuzzer_log_density_laplace_conditional_/log_density_laplace_conditional__DeepState_TestHarness.cpp | 91f9356cbdbb1f4074bddd7e4a6b61bc1637ae9a | [] | no_license | akhikolla/RcppDeepStateTest | f102ddf03a22b0fc05e02239d53405c8977cbc2b | 97e73fe4f8cb0f8e5415f52a2474c8bc322bbbe5 | refs/heads/master | 2023-03-03T12:19:31.725234 | 2021-02-12T21:50:12 | 2021-02-12T21:50:12 | 254,214,504 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,030 | cpp | // AUTOMATICALLY GENERATED BY RCPPDEEPSTATE PLEASE DO NOT EDIT BY HAND, INSTEAD EDIT
// log_density_laplace_conditional__DeepState_TestHarness_generation.cpp and log_density_laplace_conditional__DeepState_TestHarness_checks.cpp
#include <fstream>
#include <RInside.h>
#include <iostream>
#include <RcppDeepState.h>
#include <qs.h>
#include <DeepState.hpp>
Rcpp::NumericVector log_density_laplace_conditional_(double noise_scale, Rcpp::NumericMatrix optimization_linear, Rcpp::NumericMatrix optimization_state, Rcpp::NumericVector offset);
TEST(selectiveInference_deepstate_test,log_density_laplace_conditional__test){
static int rinside_flag = 0;
if(rinside_flag == 0)
{
rinside_flag = 1;
RInside R;
} std::time_t current_timestamp = std::time(0);
std::cout << "input starts" << std::endl;
NumericVector noise_scale(1);
noise_scale[0] = RcppDeepState_double();
std::string noise_scale_t = "/home/akhila/fuzzer_packages/fuzzedpackages/selectiveInference/inst/testfiles/log_density_laplace_conditional_/libFuzzer_log_density_laplace_conditional_/libfuzzer_inputs/" + std::to_string(current_timestamp) +
"_noise_scale.qs";
qs::c_qsave(noise_scale,noise_scale_t,
"high", "zstd", 1, 15, true, 1);
std::cout << "noise_scale values: "<< noise_scale << std::endl;
NumericMatrix optimization_linear = RcppDeepState_NumericMatrix();
std::string optimization_linear_t = "/home/akhila/fuzzer_packages/fuzzedpackages/selectiveInference/inst/testfiles/log_density_laplace_conditional_/libFuzzer_log_density_laplace_conditional_/libfuzzer_inputs/" + std::to_string(current_timestamp) +
"_optimization_linear.qs";
qs::c_qsave(optimization_linear,optimization_linear_t,
"high", "zstd", 1, 15, true, 1);
std::cout << "optimization_linear values: "<< optimization_linear << std::endl;
NumericMatrix optimization_state = RcppDeepState_NumericMatrix();
std::string optimization_state_t = "/home/akhila/fuzzer_packages/fuzzedpackages/selectiveInference/inst/testfiles/log_density_laplace_conditional_/libFuzzer_log_density_laplace_conditional_/libfuzzer_inputs/" + std::to_string(current_timestamp) +
"_optimization_state.qs";
qs::c_qsave(optimization_state,optimization_state_t,
"high", "zstd", 1, 15, true, 1);
std::cout << "optimization_state values: "<< optimization_state << std::endl;
NumericVector offset = RcppDeepState_NumericVector();
std::string offset_t = "/home/akhila/fuzzer_packages/fuzzedpackages/selectiveInference/inst/testfiles/log_density_laplace_conditional_/libFuzzer_log_density_laplace_conditional_/libfuzzer_inputs/" + std::to_string(current_timestamp) +
"_offset.qs";
qs::c_qsave(offset,offset_t,
"high", "zstd", 1, 15, true, 1);
std::cout << "offset values: "<< offset << std::endl;
std::cout << "input ends" << std::endl;
try{
log_density_laplace_conditional_(noise_scale[0],optimization_linear,optimization_state,offset);
}
catch(Rcpp::exception& e){
std::cout<<"Exception Handled"<<std::endl;
}
}
| [
"akhilakollasrinu424jf@gmail.com"
] | akhilakollasrinu424jf@gmail.com |
96cea7e8ee1a28b7b3c7286afb0a1ebddf5ef117 | 6b40e9dccf2edc767c44df3acd9b626fcd586b4d | /NT/net/mmc/ipsecmon/addserv.h | 9683d166793bcf53e063120e55544b3d5b642cdc | [] | no_license | jjzhang166/WinNT5_src_20201004 | 712894fcf94fb82c49e5cd09d719da00740e0436 | b2db264153b80fbb91ef5fc9f57b387e223dbfc2 | refs/heads/Win2K3 | 2023-08-12T01:31:59.670176 | 2021-10-14T15:14:37 | 2021-10-14T15:14:37 | 586,134,273 | 1 | 0 | null | 2023-01-07T03:47:45 | 2023-01-07T03:47:44 | null | UTF-8 | C++ | false | false | 1,787 | h | /**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corporation, 1997 - 2002 **/
/**********************************************************************/
/*
EditUser.h
Edit Users dialog header file
FILE HISTORY:
*/
#if !defined(AFX_ADDSERV_H__77C7FD5C_6CE5_11D1_93B6_00C04FC3357A__INCLUDED_)
#define AFX_ADDSERV_H__77C7FD5C_6CE5_11D1_93B6_00C04FC3357A__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
/////////////////////////////////////////////////////////////////////////////
// CAddServ dialog
class CAddServ : public CBaseDialog
{
// Construction
public:
CAddServ(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CAddServ)
enum { IDD = IDD_ADD_COMPUTER };
CEdit m_editComputerName;
//}}AFX_DATA
virtual DWORD * GetHelpMap() { return (DWORD *) &g_aHelpIDs_IDD_ADD_COMPUTER[0]; }
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAddServ)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddServ)
virtual BOOL OnInitDialog();
afx_msg void OnButtonBrowse();
afx_msg void OnRadioBtnClicked();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
public:
CString m_stComputerName;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_ADDSERV_H__77C7FD5C_6CE5_11D1_93B6_00C04FC3357A__INCLUDED_)
| [
"seta7D5@protonmail.com"
] | seta7D5@protonmail.com |
cd5ac1306f9c0ee6a3198866f7a858a967366111 | 0c52fa7265a2ed79a206bcea69267b6776ed45ca | /include/rho/crypt/iHasher.h | 35e9833a4583d36a108f3eb73b5084b1b8464c95 | [
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"LicenseRef-scancode-warranty-disclaimer",
"Zlib",
"MIT",
"BSD-3-Clause",
"RSA-MD",
"LicenseRef-scancode-public-domain"
] | permissive | Rhobota/librho | 532792a9429801c4c9170bd0d19e3dc34c84ae01 | d540cba6227e15ac6ef3dcb6549ed9557f6fee04 | refs/heads/master | 2021-01-01T05:36:43.887317 | 2017-04-29T04:11:33 | 2017-04-29T04:11:33 | 68,876,855 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 707 | h | #ifndef __rho_crypt_iHasher_h__
#define __rho_crypt_iHasher_h__
#include <rho/ppcheck.h>
#include <rho/iWritable.h>
namespace rho
{
namespace crypt
{
class iHasher : public iWritable
{
public:
/**
* Returns the hash in raw byte form.
*/
virtual std::vector<u8> getHash() const = 0;
/**
* Returns the hash in string form.
*
* This string is a lowercase hexadecimal
* representation of the bytes returned by
* getHash().
*/
virtual std::string getHashString() const = 0;
virtual ~iHasher() { }
};
} // namespace crypt
} // namespace rho
#endif // __rho_crypt_iHasher_h__
| [
"ryan@rhobota.com"
] | ryan@rhobota.com |
ebaee3e308b002e5731775aed1619ab6a938da4e | 9c0c418679f14303c7fea3bc38ad902f023ae9be | /src/sysc/packages/boost/detail/sp_counted_base.hpp | d4822ac3236e3bf27b46dbaa2614e7fffd0821de | [
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
] | permissive | sergev/systemc-2.2.0 | 5f5cca204bd272dd0b008cc31d32aa1b219347de | 2b27ab6621f5fa8b5932bf4d85dbc0db7efb3683 | refs/heads/master | 2020-04-15T01:04:54.130653 | 2019-01-06T01:09:56 | 2019-01-06T01:09:56 | 164,262,941 | 0 | 0 | NOASSERTION | 2019-01-06T00:37:26 | 2019-01-06T00:37:26 | null | UTF-8 | C++ | false | false | 1,926 | hpp | #ifndef BOOST_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED
#define BOOST_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// detail/sp_counted_base.hpp
//
// Copyright 2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <sysc/packages/boost/config.hpp>
#if defined( BOOST_SP_DISABLE_THREADS )
# include <sysc/packages/boost/detail/sp_counted_base_nt.hpp>
#elif defined( BOOST_SP_USE_PTHREADS )
# include <sysc/packages/boost/detail/sp_counted_base_pt.hpp>
#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) )
# include <sysc/packages/boost/detail/sp_counted_base_gcc_x86.hpp>
//~ #elif defined( __MWERKS__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) )
//~ # include <sysc/packages/boost/detail/sp_counted_base_cw_x86.hpp>
#elif defined( __GNUC__ ) && defined( __ia64__ ) && !defined( __INTEL_COMPILER )
# include <sysc/packages/boost/detail/sp_counted_base_gcc_ia64.hpp>
#elif defined( __MWERKS__ ) && defined( __POWERPC__ )
# include <sysc/packages/boost/detail/sp_counted_base_cw_ppc.hpp>
#elif defined( __GNUC__ ) && ( defined( __powerpc__ ) || defined( __ppc__ ) )
# include <sysc/packages/boost/detail/sp_counted_base_gcc_ppc.hpp>
#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ )
# include <sysc/packages/boost/detail/sp_counted_base_w32.hpp>
#elif !defined( BOOST_HAS_THREADS )
# include <sysc/packages/boost/detail/sp_counted_base_nt.hpp>
#elif defined( BOOST_HAS_PTHREADS )
# include <sysc/packages/boost/detail/sp_counted_base_pt.hpp>
#else
// Use #define BOOST_DISABLE_THREADS to avoid the error
# error Unrecognized threading platform
#endif
#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED
| [
"puneet@coverify.lan"
] | puneet@coverify.lan |
33be62fb5196a1d72ba6ca98dd87f264aa1d2df4 | 5456502f97627278cbd6e16d002d50f1de3da7bb | /chrome/browser/extensions/api/messaging/native_message_process_host.cc | 23dc49e4691359002e10f468d92cefc035a8abd5 | [
"BSD-3-Clause"
] | permissive | TrellixVulnTeam/Chromium_7C66 | 72d108a413909eb3bd36c73a6c2f98de1573b6e5 | c8649ab2a0f5a747369ed50351209a42f59672ee | refs/heads/master | 2023-03-16T12:51:40.231959 | 2017-12-20T10:38:26 | 2017-12-20T10:38:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,625 | cc | // Copyright (c) 2012 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 "chrome/browser/extensions/api/messaging/native_message_process_host.h"
#include <stddef.h>
#include <stdint.h>
#include <utility>
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/process/kill.h"
#include "base/threading/sequenced_worker_pool.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest.h"
#include "chrome/browser/extensions/api/messaging/native_process_launcher.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/common/constants.h"
#include "extensions/common/features/feature.h"
#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "url/gurl.h"
namespace {
// Maximum message size in bytes for messages received from Native Messaging
// hosts. Message size is limited mainly to prevent Chrome from crashing when
// native application misbehaves (e.g. starts writing garbage to the pipe).
const size_t kMaximumMessageSize = 1024 * 1024;
// Message header contains 4-byte integer size of the message.
const size_t kMessageHeaderSize = 4;
// Size of the buffer to be allocated for each read.
const size_t kReadBufferSize = 4096;
} // namespace
namespace extensions {
NativeMessageProcessHost::NativeMessageProcessHost(
const std::string& source_extension_id,
const std::string& native_host_name,
std::unique_ptr<NativeProcessLauncher> launcher)
: client_(NULL),
source_extension_id_(source_extension_id),
native_host_name_(native_host_name),
launcher_(std::move(launcher)),
closed_(false),
#if defined(OS_POSIX)
read_file_(-1),
#endif
read_pending_(false),
write_pending_(false),
weak_factory_(this) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
task_runner_ = content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO);
}
NativeMessageProcessHost::~NativeMessageProcessHost() {
DCHECK(task_runner_->BelongsToCurrentThread());
if (process_.IsValid()) {
// Kill the host process if necessary to make sure we don't leave zombies.
// On OSX base::EnsureProcessTerminated() may block, so we have to post a
// task on the blocking pool.
#if defined(OS_MACOSX)
content::BrowserThread::PostBlockingPoolTask(
FROM_HERE,
base::Bind(&base::EnsureProcessTerminated, Passed(&process_)));
#else
base::EnsureProcessTerminated(std::move(process_));
#endif
}
}
// static
std::unique_ptr<NativeMessageHost> NativeMessageHost::Create(
gfx::NativeView native_view,
const std::string& source_extension_id,
const std::string& native_host_name,
bool allow_user_level,
std::string* error_message) {
return NativeMessageProcessHost::CreateWithLauncher(
source_extension_id,
native_host_name,
NativeProcessLauncher::CreateDefault(allow_user_level, native_view));
}
// static
std::unique_ptr<NativeMessageHost> NativeMessageProcessHost::CreateWithLauncher(
const std::string& source_extension_id,
const std::string& native_host_name,
std::unique_ptr<NativeProcessLauncher> launcher) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
std::unique_ptr<NativeMessageHost> process(new NativeMessageProcessHost(
source_extension_id, native_host_name, std::move(launcher)));
return process;
}
void NativeMessageProcessHost::LaunchHostProcess() {
DCHECK(task_runner_->BelongsToCurrentThread());
GURL origin(std::string(kExtensionScheme) + "://" + source_extension_id_);
launcher_->Launch(origin, native_host_name_,
base::Bind(&NativeMessageProcessHost::OnHostProcessLaunched,
weak_factory_.GetWeakPtr()));
}
void NativeMessageProcessHost::OnHostProcessLaunched(
NativeProcessLauncher::LaunchResult result,
base::Process process,
base::File read_file,
base::File write_file) {
DCHECK(task_runner_->BelongsToCurrentThread());
switch (result) {
case NativeProcessLauncher::RESULT_INVALID_NAME:
Close(kInvalidNameError);
return;
case NativeProcessLauncher::RESULT_NOT_FOUND:
Close(kNotFoundError);
return;
case NativeProcessLauncher::RESULT_FORBIDDEN:
Close(kForbiddenError);
return;
case NativeProcessLauncher::RESULT_FAILED_TO_START:
Close(kFailedToStartError);
return;
case NativeProcessLauncher::RESULT_SUCCESS:
break;
}
process_ = std::move(process);
#if defined(OS_POSIX)
// This object is not the owner of the file so it should not keep an fd.
read_file_ = read_file.GetPlatformFile();
#endif
scoped_refptr<base::TaskRunner> task_runner(
content::BrowserThread::GetBlockingPool()->
GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
read_stream_.reset(new net::FileStream(std::move(read_file), task_runner));
write_stream_.reset(new net::FileStream(std::move(write_file), task_runner));
WaitRead();
DoWrite();
}
void NativeMessageProcessHost::OnMessage(const std::string& json) {
DCHECK(task_runner_->BelongsToCurrentThread());
if (closed_)
return;
// Allocate new buffer for the message.
scoped_refptr<net::IOBufferWithSize> buffer =
new net::IOBufferWithSize(json.size() + kMessageHeaderSize);
// Copy size and content of the message to the buffer.
static_assert(sizeof(uint32_t) == kMessageHeaderSize,
"kMessageHeaderSize is incorrect");
*reinterpret_cast<uint32_t*>(buffer->data()) = json.size();
memcpy(buffer->data() + kMessageHeaderSize, json.data(), json.size());
// Push new message to the write queue.
write_queue_.push(buffer);
// Send() may be called before the host process is started. In that case the
// message will be written when OnHostProcessLaunched() is called. If it's
// already started then write the message now.
if (write_stream_)
DoWrite();
}
void NativeMessageProcessHost::Start(Client* client) {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!client_);
client_ = client;
// It's safe to use base::Unretained() here because NativeMessagePort always
// deletes us on the IO thread.
task_runner_->PostTask(
FROM_HERE,
base::Bind(&NativeMessageProcessHost::LaunchHostProcess,
weak_factory_.GetWeakPtr()));
}
scoped_refptr<base::SingleThreadTaskRunner>
NativeMessageProcessHost::task_runner() const {
return task_runner_;
}
void NativeMessageProcessHost::ReadNowForTesting() {
DoRead();
}
void NativeMessageProcessHost::WaitRead() {
if (closed_)
return;
DCHECK(!read_pending_);
// On POSIX FileStream::Read() uses blocking thread pool, so it's better to
// wait for the file to become readable before calling DoRead(). Otherwise it
// would always be consuming one thread in the thread pool. On Windows
// FileStream uses overlapped IO, so that optimization isn't necessary there.
#if defined(OS_POSIX)
read_controller_ = base::FileDescriptorWatcher::WatchReadable(
read_file_,
base::Bind(&NativeMessageProcessHost::DoRead, base::Unretained(this)));
#else // defined(OS_POSIX)
DoRead();
#endif // defined(!OS_POSIX)
}
void NativeMessageProcessHost::DoRead() {
DCHECK(task_runner_->BelongsToCurrentThread());
#if defined(OS_POSIX)
read_controller_.reset();
#endif
while (!closed_ && !read_pending_) {
read_buffer_ = new net::IOBuffer(kReadBufferSize);
int result =
read_stream_->Read(read_buffer_.get(), kReadBufferSize,
base::Bind(&NativeMessageProcessHost::OnRead,
weak_factory_.GetWeakPtr()));
HandleReadResult(result);
}
}
void NativeMessageProcessHost::OnRead(int result) {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(read_pending_);
read_pending_ = false;
HandleReadResult(result);
WaitRead();
}
void NativeMessageProcessHost::HandleReadResult(int result) {
DCHECK(task_runner_->BelongsToCurrentThread());
if (closed_)
return;
if (result > 0) {
ProcessIncomingData(read_buffer_->data(), result);
} else if (result == net::ERR_IO_PENDING) {
read_pending_ = true;
} else if (result == 0 || result == net::ERR_CONNECTION_RESET) {
// On Windows we get net::ERR_CONNECTION_RESET for a broken pipe, while on
// Posix read() returns 0 in that case.
Close(kNativeHostExited);
} else {
LOG(ERROR) << "Error when reading from Native Messaging host: " << result;
Close(kHostInputOuputError);
}
}
void NativeMessageProcessHost::ProcessIncomingData(
const char* data, int data_size) {
DCHECK(task_runner_->BelongsToCurrentThread());
incoming_data_.append(data, data_size);
while (true) {
if (incoming_data_.size() < kMessageHeaderSize)
return;
size_t message_size =
*reinterpret_cast<const uint32_t*>(incoming_data_.data());
if (message_size > kMaximumMessageSize) {
LOG(ERROR) << "Native Messaging host tried sending a message that is "
<< message_size << " bytes long.";
Close(kHostInputOuputError);
return;
}
if (incoming_data_.size() < message_size + kMessageHeaderSize)
return;
client_->PostMessageFromNativeHost(
incoming_data_.substr(kMessageHeaderSize, message_size));
incoming_data_.erase(0, kMessageHeaderSize + message_size);
}
}
void NativeMessageProcessHost::DoWrite() {
DCHECK(task_runner_->BelongsToCurrentThread());
while (!write_pending_ && !closed_) {
if (!current_write_buffer_.get() ||
!current_write_buffer_->BytesRemaining()) {
if (write_queue_.empty())
return;
current_write_buffer_ = new net::DrainableIOBuffer(
write_queue_.front().get(), write_queue_.front()->size());
write_queue_.pop();
}
int result =
write_stream_->Write(current_write_buffer_.get(),
current_write_buffer_->BytesRemaining(),
base::Bind(&NativeMessageProcessHost::OnWritten,
weak_factory_.GetWeakPtr()));
HandleWriteResult(result);
}
}
void NativeMessageProcessHost::HandleWriteResult(int result) {
DCHECK(task_runner_->BelongsToCurrentThread());
if (result <= 0) {
if (result == net::ERR_IO_PENDING) {
write_pending_ = true;
} else {
LOG(ERROR) << "Error when writing to Native Messaging host: " << result;
Close(kHostInputOuputError);
}
return;
}
current_write_buffer_->DidConsume(result);
}
void NativeMessageProcessHost::OnWritten(int result) {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(write_pending_);
write_pending_ = false;
HandleWriteResult(result);
DoWrite();
}
void NativeMessageProcessHost::Close(const std::string& error_message) {
DCHECK(task_runner_->BelongsToCurrentThread());
if (!closed_) {
closed_ = true;
read_stream_.reset();
write_stream_.reset();
client_->CloseChannel(error_message);
}
}
} // namespace extensions
| [
"lixiaodonglove7@aliyun.com"
] | lixiaodonglove7@aliyun.com |
7ddd1cc866bcda9959a3f4a854b4ceef5a988165 | fb98e790b90cc475b53780f1e5fedd5eccfe8b56 | /Dynamixel/include/Dynamixel/dxl/dxl.h | 5aaaac5e6850ade7be4b540219de56450d948db5 | [
"MIT"
] | permissive | roadnarrows-robotics/rnr-sdk | e348dacd80907717bee4ad9c0a3c58b20fa380ae | be7b3e0806364cdb4602202aba2b4cdd9ba676f4 | refs/heads/master | 2023-08-16T06:52:31.580475 | 2023-08-03T19:45:33 | 2023-08-03T19:45:33 | 56,259,572 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,497 | h | ////////////////////////////////////////////////////////////////////////////////
//
// Package: Dynamixel
//
// Library: libdxl
//
// File: dxl.h
//
/*! \file
*
* \brief Modified dynamixel SDK interface.
*
* Based on Robotis Inc. dxl_sdk-1.01
*
* \author Robotis
* \author Robin Knight (robin.knight@roadnarrows.com)
*/
/*
* This file is a modified version of the file freely provided by Robotis Inc.
* No restrictions by Robotis Inc. nor RoadNarrows LLC are made.
*/
////////////////////////////////////////////////////////////////////////////////
#ifndef _DXL_H
#define _DXL_H
#include <sys/types.h>
#include <stdint.h>
#include <string>
namespace libdxl
{
//----------------------------------------------------------------------------
// Defines and Types
//----------------------------------------------------------------------------
//
// Common baud number enumeration.
//
#define DXL_BAUDNUM_1000000 (1) ///< 1,000,000 bps at 0.0% tolerance
#define DXL_BAUDNUM_500000 (3) ///< 500,000 bps at 0.0% tolerance
#define DXL_BAUDNUM_400000 (4) ///< 500,000 bps at 0.0% tolerance
#define DXL_BAUDNUM_250000 (7) ///< 250,000 bps at 0.0% tolerance
#define DXL_BAUDNUM_200000 (9) ///< 200,000 bps at 0.0% tolerance
#define DXL_BAUDNUM_115200 (16) ///< 115,200 bps at -2.124% tolerance
#define DXL_BAUDNUM_57600 (34) ///< 57,600 bps at 0.794 % tolerance
#define DXL_BAUDNUM_19200 (103) ///< 19,200 bps at -0.160% tolerance
#define DXL_BAUDNUM_9600 (207) ///< 9,600 bps at -0.160% tolerance
//
// Extended baud number enumeration.
//
#define DXL_BAUDNUM_EXT_2250000 (250) ///< 2,250,000 bps at 0.0% tolerance
#define DXL_BAUDNUM_EXT_2500000 (251) ///< 2,500,000 bps at 0.0% tolerance
#define DXL_BAUDNUM_EXT_3000000 (252) ///< 3,000,000 bps at 0.0% tolerance
// Dynamixel default rate.
#define DXL_DEFAULT_BAUDNUMBER (34) ///< default baud number
//
// Packet field indices.
//
#define DXL_ID (2) ///< servo id field packet index
#define DXL_LENGTH (3) ///< packet length field packet index
#define DXL_INSTRUCTION (4) ///< instruction field packet index
#define DXL_ERRBIT (4) ///< error bits field packet index
#define DXL_PARAMETER (5) ///< start of parameter fields packet index
//
// Maximum transmit/receive lengths.
//
#define DXL_MAXNUM_TXPARAM (150) ///< maximum number of tx parameters
#define DXL_MAXNUM_RXPARAM (60) ///< maximum number of rx parameters
//
// Instructions (commands).
//
#define DXL_INST_PING (1) ///< ping servo
#define DXL_INST_READ (2) ///< read servo control table data
#define DXL_INST_WRITE (3) ///< write servo control table data
#define DXL_INST_REG_WRITE (4) ///< register write
#define DXL_INST_ACTION (5) ///< action
#define DXL_INST_RESET (6) ///< reset servo defaults
#define DXL_INST_SYNC_WRITE (131) ///< synchronous write servo(s) data
//
// Servo Ids
//
#define DXL_MIN_ID (0) ///< minimum servo id
#define DXL_MAX_ID (253) ///< maximum servo id
#define DXL_BROADCAST_ID (254) ///< broadcast "servo" id
//
// Servo error bits.
//
#define DXL_ERRBIT_VOLTAGE (1) ///< voltage out-of-range error
#define DXL_ERRBIT_ANGLE (2) ///< servo angle out-of-range error
#define DXL_ERRBIT_OVERHEAT (4) ///< temperature out-of-range error
#define DXL_ERRBIT_RANGE (8) ///< parameter? out-of-range error
#define DXL_ERRBIT_CHECKSUM (16) ///< bad checksum error
#define DXL_ERRBIT_OVERLOAD (32) ///< load out-of-range error
#define DXL_ERRBIT_INSTRUCTION (64) ///< bad instruction error
//
// Communication result codes.
//
#define DXL_COMM_TXSUCCESS (0) ///< transmit success
#define DXL_COMM_RXSUCCESS (1) ///< receive success
#define DXL_COMM_TXFAIL (2) ///< transmit failure error
#define DXL_COMM_RXFAIL (3) ///< receive failure error
#define DXL_COMM_TXERROR (4) ///< packed transmit packet format error
#define DXL_COMM_RXWAITING (5) ///< waiting for complete receive packet
#define DXL_COMM_RXTIMEOUT (6) ///< receive timeout error
#define DXL_COMM_RXCORRUPT (7) ///< receive corrupted packet
/*!
* \brief half-duplex control transmit callback type.
*
* \param arg Callback user argument.
*/
typedef void (*dxl_hdctl_tx_cb_t)(void *arg);
/*!
* \brief half-duplex control receive callback type.
*
* \param arg Callback user argument.
* \param arg Transmit packet length.
*/
typedef void (*dxl_hdctl_rx_cb_t)(void *arg, size_t txlen);
//
// Foward declarations.
//
class dxlhal;
//----------------------------------------------------------------------------
// Class dxl
//----------------------------------------------------------------------------
class dxl
{
public:
/*!
* \brief Default constructor.
*/
dxl();
/*!
* \brief Destructor.
*/
~dxl();
/*!
* \brief Open Dynamixel Bus serial interface.
*
* The serial device is opened and attributes set.
*
* \param deviceName Serial device name.
* \param baudrate Dynamixel baud rate.
*
* \return Returns 1 on success, 0 on failure.
*/
int open(const char *deviceName, int baudrate);
/*!
* \brief Initialize Dynamixel Bus USB serial interface by index.
*
* The serial device is opened and attributes set.
*
* \note This method is deprecated. The preferred method is open().
*
* \param deviceIndex Device number of /dev/ttyUSBn, n == deviceIndex.
* \param baudnum Dynamixel baud number.
*
* \return Returns 1 on success, 0 on failure.
*/
int dxl_initialize(int deviceIndex, int baudnum);
/*!
* \brief Close the Dynamixel Bus serial interface.
*
* The serial device is closed.
*/
void close();
/*!
* \brief Set Dynamixel Bus serial device baud rate.
*
* \param baudrate Baud rate.
*
* \return Returns 1 on success, 0 on failure.
*/
int setBaudRate(int baudrate);
/*!
* \brief Set serial half-duplex callbacks.
*
* The relavent callback is made just prior to transmitting or receiving a
* packet.
*
* \param enable_tx_cb Enable transmit callback.
* \param enable_rx_cb Enable receive callback.
* \param arg Tx/Rx callback parameter.
*
* \return Returns 1 on success, 0 on failure.
*/
int setHalfDuplexCallbacks(dxl_hdctl_tx_cb_t enable_tx_cb,
dxl_hdctl_rx_cb_t enable_rx_cb,
void *arg);
/*!
* \brief Get the Dynamixel Bus serial device file descriptor.
*
* \return Returns \>= 0 if the device is open, -1 otherwise.
*/
int getFd();
/*!
* \brief Set transmit packet servo id.
*
* \param id Servo id or broadcast id.
*/
void setTxPacketId(int id);
/*!
* \brief Set transmit packet instruction.
*
* \param instruction Request instruction id.
*/
void setTxPacketInstruction(int instruction);
/*!
* \brief Set transmit packet parameter value
*
* \param index Zero offset parameter index.
* \param value Parameter byte value.
*/
void setTxPacketParameter(int index, int value);
/*!
* \brief Set transmit packet length.
*
* \param length Length in bytes.
*/
void setTxPacketLength(int length);
/*!
* \brief Get receive packet error bits field.
*
* \return Error bits.
*/
unsigned int getRxPacketErrBits();
/*!
* \brief Test if error bit is set on received packet.
*
* \param errbit Error bit to test.
*
* \return Returns true or false.
*/
bool getRxPacketError(unsigned int errbit);
/*!
* \brief Get receive packet length field.
*
* \return Receive packet expected length.
*/
int getRxPacketLength();
/*!
* \brief Get receive packet parameter value
*
* \param index Zero offset parameter index.
*
* \return Paramter byte value.
*/
int getRxPacketParameter(int index);
/*!
* \brief Make 16-bit word.
*
* \param lowbyte Least significant byte.
* \param highbyte Most significant byte.
*
* \return Packed word.
*/
int makeWord(int lowbyte, int highbyte);
/*!
* \brief Get low byte from word.
*
* \param word 16-bit word.
*
* \return Unpacked least significant byte.
*/
int getLowByte(int word);
/*!
* \brief Get high byte from word.
*
* \param word 16-bit word.
*
* \return Unpacked most significant byte.
*/
int getHighByte(int word);
/*!
* \brief Transmit a previously packed instruction packet.
*
* \par Transmit Packet
* 0xff 0xff ID LENGTH INSTRUCTION paramters CHECKSUM
*/
void txPacket();
/*!
* \brief Receive status packet.
*
* \par Non-Broadcast Receive Packet
* 0xff 0xff ID LENGTH ERRBIT paramters CHECKSUM
*/
void rxPacket();
/*!
* \brief Transmit instruction packet and receive status response packet.
*
* Use dxl_get_result() to check for success or failure.
*
* Use the tranmit packing functions to build the instruction packet and the
* receive unpacking function to get any read data.
*/
void txrxPacket();
/*!
* \brief Get last transmit/receive result.
*
* \return Result code.
*/
int getResult();
/*!
* \brief Ping servo.
*
* Use dxl_get_result() to check for success or failure.
*
* \param id Servo id.
*/
void ping(int id);
/*!
* \brief Read byte from servo's control table.
*
* Use dxl_get_result() to check for success or failure.
*
* \param id Servo id.
* \param address Control table address.
*
* \return Read 8-bit byte.
*/
int readByte(int id, int address);
/*!
* \brief Write byte to servo's control table.
*
* Use dxl_get_result() to check for success or failure.
*
* \param id Servo id.
* \param address Control table address.
* \param value 8-bit value to write.
*/
void writeByte(int id, int address, int value);
/*!
* \brief Read word from servo's control table.
*
* Use dxl_get_result() to check for success or failure.
*
* \param id Servo id.
* \param address Control table address.
*
* \return Read 16-bit word.
*/
int readWord(int id, int address);
/*!
* \brief Write word to servo's control table.
*
* Use dxl_get_result() to check for success or failure.
*
* \param id Servo id.
* \param address Control table address.
* \param value 16-bit value to write.
*/
void writeWord(int id, int address, int value);
protected:
// packets
uint8_t m_bufInstructionPacket[DXL_MAXNUM_TXPARAM+10];
///< instruction transmit packet buffer
uint8_t m_bufStatusPacket[DXL_MAXNUM_RXPARAM+10];
///< status receive packet buffer
// communication
int m_nRxPacketLength; ///< expected received packet length
int m_nRxGetLength; ///< current received packet length
int m_nCommStatus; ///< communication status
bool m_bBusUsing; ///< bus is [not] busy
// half-duplex control callbacks.
dxl_hdctl_tx_cb_t m_fnEnableTx; ///< enable tx callback
dxl_hdctl_rx_cb_t m_fnEnableRx; ///< enable rx callback
void *m_pTxRxArg; ///< tx/rx argument passback
// implementaion hardware abstraction layer
dxlhal *m_pDxlHal;
/*!
* \brief Convert Dynamixel baud number to baud rate.
*
* \note This method is deprecated. The preferred method is open().
*
* \param baudnum Dynamixel baud number.
*
* \return Baud rate.
*/
float dxl_baudnum_to_baudrate(int baudnum);
};
} // namespace libdxl
#endif // _DXL_H
| [
"robin.knight@roadnarrows.com"
] | robin.knight@roadnarrows.com |
bb3f0811e4fd36bf3054d8feb2c737f76905138d | 0218a730d9fbb1140032bc203e79b8554e60271d | /blinks/blink_3_1_while_veloce/blink_3_1_while_veloce.ino | 4e86c4d2b6f27644aeb07dbe33f295aba9a883bf | [] | no_license | sandroallegri/arduino | 6473904c57ebd55a57c61c8286bb82cc199d14ff | 76812ee46d9118e77e44e328e9424eb8658b7a9d | refs/heads/master | 2021-01-19T05:20:45.408099 | 2016-07-11T19:18:48 | 2016-07-11T19:18:48 | 63,093,422 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,365 | ino | /*
Blink v4: while loop
Accensione e spegnimanto di un LED utilizzando un ciclo
iterativo while per comandare il lampeggio.
Iterazione modificata da una variabile.
*/
const int led = 13; // Il valore non cambia
// durante l'esecuzione del programm
// /////////////////
// Setup: eseguita una volta sola all'accensione della scheda
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// ///////////////
// loop: Le istruzioni vengono eseguite all'infinito
void loop() {
int iterator = 0; // Defniamo una variabile per controllare il ciclo iterativo
while (iterator < 10) { // Condizione del ciclo
iterator = iterator + 1 ; // incrementa l'iteratore
brilla(30 * iterator); // accende e spegne rapidamente il LED
// la pausa e' in funzione della variabile iteratore
}
}
// Funzioni create dall'utente:
void brilla(int velocita) {
// Accende e spegne il LED accetando un argomento
// per impostare la velocita'.
// sequenze di istruzione: accendere e spegnere il LED
digitalWrite(led, HIGH); // Mette il PIN del LED in stato acceso)
delay(velocita); // Pausa
digitalWrite(led, LOW); // Mette il PIN del LED in stato spento
delay(velocita); // Pausa
}
| [
"eaman@time.andreamanni.com"
] | eaman@time.andreamanni.com |
571fdb6131337cc7154aee433bede74a7124a76a | 0fa0a47b7bffe1805ecb8201df51e8c84d85e9d3 | /examples/OGLWindow.cpp | 41c80006e06ff9840d4469115a4896b501fd0060 | [] | no_license | Moaaz-Rafique/FL-Essentials | 28e0cd73e7b6811cf32b1b4b4cb71c5b84f8e343 | 16ab22d65fc3974cb0be34edd9585d4d4a102021 | refs/heads/master | 2023-03-16T19:47:33.708122 | 2021-01-09T01:05:26 | 2021-01-09T01:05:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,525 | cpp | /*********************************************************************************
created: 2017/03/14 02:10AM
filename: OGLWindow.cpp
file base: OGLWindow
file ext: cpp
author: Furqan Ullah (Post-doc, Ph.D.)
website: http://real3d.pk
CopyRight: All Rights Reserved
purpose: OpenGL program to animate the scene, written in FLE.
/**********************************************************************************
FL-ESSENTIALS (FLE) - FLTK Utility Widgets
Copyright (C) 2017 REAL3D
This file and its content is protected by a software license.
You should have received a copy of this license with this file.
If not, please contact Dr. Furqan Ullah immediately:
**********************************************************************************/
#include "OGLWindow.h"
#include <FL/gl.h>
#include <FL/glu.h>
#include <FL/glut.H>
GLWindow::GLWindow(int _x, int _y, int _w, int _h, const char* _title) :
Fle_OpenGLWindow(_x, _y, _w, _h, _title),
m_use_light_0(true),
m_use_light_1(false),
m_use_material(true),
m_angle(0)
{
// start the timer that will start calling timerEvent() function in real-time with around 60 fps.
m_timer.start();
}
GLWindow::GLWindow(int _w, int _h, const char* _title) :
Fle_OpenGLWindow(_w, _h, _title),
m_use_light_0(true),
m_use_light_1(false),
m_use_material(true),
m_angle(0)
{
// start the timer that will start calling timerEvent() function in real-time with around 60 fps.
m_timer.start();
}
void GLWindow::initializeGL()
{
// enable the depth test state.
glEnable(GL_DEPTH_TEST);
// because we want to setup lights/bulbs, so turn on the lighting for this scene.
glEnable(GL_LIGHTING);
glEnable(GL_NORMALIZE); // for lighting and normals
}
void GLWindow::setupCamera()
{
// set width and height of the view port.
// w() and h() are the width and height of this window.
glViewport(0, 0, w(), h());
// setup perspective projection with angle, aspect ratio and near and far planes.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, static_cast<double>(w()) / static_cast<double>(h()), 0.1, 1000.0);
// setup the camera eye.
gluLookAt(
0.0, 0.0, 100.0, // eye is at (0,0,100)
0.0, 0.0, 0.0, // center is at (0,0,0)
0.0, 1.0, 0.); // up is in positive Y direction
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
// This routine draws the text string at the given (x,y,z) position.
// x,y,z: Raster position for text
// txt: String to draw
void drawText(float _x, float _y, float _z, char* _txt, float _red = 1.0f, float _green = 1.0f, float _blue = 1.0f, float _alpha = 1.0f)
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(_red, _green, _blue, _alpha);
glRasterPos3f(_x, _y, _z);
while (*_txt != '\0')
{
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, *_txt);
_txt++;
}
glPopAttrib();
}
void GLWindow::paintGL()
{
// clear the screen with black color.
glClearColor(0.23f, 0.56f, 231.0f, 0.9f);
// clear the color and depth buffers for displaying the next frame.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// place camera at the eye position.
setupCamera();
// set lights/bulbs to the scene.
if (m_use_light_0)
setupPointLight0(); // switch on of light/bulb 0.
else
glDisable(GL_LIGHT0); // switch off of light/bulb 0.
if (m_use_light_1)
setupPointLight1(); // switch on of light/bulb 1.
else
glDisable(GL_LIGHT1); // switch off of light/bulb 1.
if (m_use_material)
setupMaterial(); // set material color to 3D models.
// push matrix for creating the local coordinate system.
glPushMatrix();
// rotate m_angle degrees around x-axes because x is 1.0f.
glRotatef(m_angle, 1.0f, 0.0f, 0.0f);
// rotate m_angle degrees around y-axes because y is 1.0f.
glRotatef(m_angle, 0.0f, 1.0f, 0.0f);
// rotate m_angle degrees around y-axes because z is 1.0f.
glRotatef(m_angle, 0.0f, 0.0f, 1.0f);
// render teapot.
glutSolidTeapot(15.0);
// you can draw various models using GLUT, like
glutWireTorus(5.0, 32.0, 20, 20);
// pop matrix that was pushed above.
glPopMatrix();
// draw a line.
glLineWidth(2.0f); // line thickness
glColor4f(1.f, 0.f, 1.f, 1.f); // line color
glBegin(GL_LINES); // start drawing line
glVertex3f(-50.f, 0.f, 0.f); // first coordinates of the line P1
glVertex3f(50.f, 0.f, 0.f); // 2nd coordinates of the line P2
glEnd(); // end drawing
//// draw a triangle
//glBegin(GL_TRIANGLES);
//glColor3f(1, 0, 0);
//glVertex3f(0, 0, 0);
//glColor3f(0, 1, 0);
//glVertex3f(0, 20, 0);
//glColor3f(0, 0, 1);
//glVertex3f(20, 0, 0);
//glEnd();
}
int GLWindow::keyPressEvent(int _key)
{
if (_key == '0')
{
m_use_light_0 = !m_use_light_0; // toggle On/Off
update(); // update/redraw the scene
return 1;
}
else if (_key == '1')
{
m_use_light_1 = !m_use_light_1; // toggle On/Off
update(); // update/redraw the scene
return 1;
}
else if (_key == 'm')
{
m_use_material = !m_use_material; // toggle On/Off
update(); // update/redraw the scene
return 1;
}
return 0;
}
void GLWindow::setupPointLight0()
{
// set the position of bulb 0.
GLfloat light_position_0[] = { 0, 5, 1000, 1 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position_0);
// give specular color (shininess) to bulb 0.
GLfloat light_specular_0[] = { 1, 0.5, 0, 1 };
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular_0);
glEnable(GL_LIGHT0); // enable light 0, meaning to turn the switch ON of bulb 0.
}
void GLWindow::setupPointLight1()
{
// set the position of bulb 1.
GLfloat light_position_1[] = { 1000, 5, 1000, 1 };
glLightfv(GL_LIGHT1, GL_POSITION, light_position_1);
// give specular color (shininess) to bulb 1.
GLfloat light_specular_1[] = { 0.8f, 0.8f, 0.8f, 1 };
glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular_1);
glEnable(GL_LIGHT1); // enable light 1, meaning to turn the switch ON of bulb 1.
}
void GLWindow::setupMaterial()
{
GLfloat diffuse_material[] = { 0.751640f, 0.606480f, 0.226480f, 1.0f };
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse_material);
GLfloat speular_material[] = { 0.8f, 0.8f, 0.8f, 1.0f };
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, speular_material);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 80.0f);
}
void GLWindow::timerEvent()
{
// increment the angle and when it crosses the 360, make it zero.
m_angle += 0.5f;
if (m_angle >= 360.0f)
m_angle = m_angle - 360.0f;
// update or redraw the scene.
update();
}
| [
"furqan797@gmail.com"
] | furqan797@gmail.com |
c8eaa404252f094021ef4b5c43c7e8718448bf4e | 6a09314904976623474fbe4aec5212be342d7baa | /const.h | 03bfbcd85c439fbaa4eb8cfb81ee3c2e10dd0080 | [
"MIT"
] | permissive | marcielazevedo/ll | 28f598bbe0819262f4639665052b8a74e600c81d | aa23a126586a433194c5a24122d80667fbcca465 | refs/heads/master | 2021-01-01T18:12:54.327442 | 2017-07-25T06:54:45 | 2017-07-25T06:54:45 | 98,273,928 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,735 | h | /**
* The Forgotten Server - a free and open-source MMORPG server emulator
* Copyright (C) 2015 Mark Samman <mark.samman@gmail.com>
*
* 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef FS_CONST_H_0A49B5996F074465BF44B90F4F780E8B
#define FS_CONST_H_0A49B5996F074465BF44B90F4F780E8B
#define NETWORKMESSAGE_MAXSIZE 24590
enum MagicEffectClasses : uint8_t {
CONST_ME_NONE,
CONST_ME_DRAWBLOOD = 1,
CONST_ME_LOSEENERGY = 2,
CONST_ME_POFF = 3,
CONST_ME_BLOCKHIT = 4,
CONST_ME_EXPLOSIONAREA = 5,
CONST_ME_EXPLOSIONHIT = 6,
CONST_ME_FIREAREA = 7,
CONST_ME_YELLOW_RINGS = 8,
CONST_ME_GREEN_RINGS = 9,
CONST_ME_HITAREA = 10,
CONST_ME_TELEPORT = 11,
CONST_ME_ENERGYHIT = 12,
CONST_ME_MAGIC_BLUE = 13,
CONST_ME_MAGIC_RED = 14,
CONST_ME_MAGIC_GREEN = 15,
CONST_ME_HITBYFIRE = 16,
CONST_ME_HITBYPOISON = 17,
CONST_ME_MORTAREA = 18,
CONST_ME_SOUND_GREEN = 19,
CONST_ME_SOUND_RED = 20,
CONST_ME_POISONAREA = 21,
CONST_ME_SOUND_YELLOW = 22,
CONST_ME_SOUND_PURPLE = 23,
CONST_ME_SOUND_BLUE = 24,
CONST_ME_SOUND_WHITE = 25,
CONST_ME_BUBBLES = 26,
CONST_ME_CRAPS = 27,
CONST_ME_GIFT_WRAPS = 28,
CONST_ME_FIREWORK_YELLOW = 29,
CONST_ME_FIREWORK_RED = 30,
CONST_ME_FIREWORK_BLUE = 31,
CONST_ME_STUN = 32,
CONST_ME_SLEEP = 33,
CONST_ME_WATERCREATURE = 34,
CONST_ME_GROUNDSHAKER = 35,
CONST_ME_HEARTS = 36,
CONST_ME_FIREATTACK = 37,
CONST_ME_ENERGYAREA = 38,
CONST_ME_SMALLCLOUDS = 39,
CONST_ME_HOLYDAMAGE = 40,
CONST_ME_BIGCLOUDS = 41,
CONST_ME_ICEAREA = 42,
CONST_ME_ICETORNADO = 43,
CONST_ME_ICEATTACK = 44,
CONST_ME_STONES = 45,
CONST_ME_SMALLPLANTS = 46,
CONST_ME_CARNIPHILA = 47,
CONST_ME_PURPLEENERGY = 48,
CONST_ME_YELLOWENERGY = 49,
CONST_ME_HOLYAREA = 50,
CONST_ME_BIGPLANTS = 51,
CONST_ME_CAKE = 52,
CONST_ME_GIANTICE = 53,
CONST_ME_WATERSPLASH = 54,
CONST_ME_PLANTATTACK = 55,
CONST_ME_TUTORIALARROW = 56,
CONST_ME_TUTORIALSQUARE = 57,
CONST_ME_MIRRORHORIZONTAL = 58,
CONST_ME_MIRRORVERTICAL = 59,
CONST_ME_SKULLHORIZONTAL = 60,
CONST_ME_SKULLVERTICAL = 61,
CONST_ME_ASSASSIN = 62,
CONST_ME_STEPSHORIZONTAL = 63,
CONST_ME_BLOODYSTEPS = 64,
CONST_ME_STEPSVERTICAL = 65,
CONST_ME_YALAHARIGHOST = 66,
CONST_ME_BATS = 67,
CONST_ME_SMOKE = 68,
CONST_ME_INSECTS = 69,
CONST_ME_DRAGONHEAD = 70,
CONST_ME_ORCSHAMAN = 71,
CONST_ME_ORCSHAMAN_FIRE = 72,
CONST_ME_THUNDER = 73,
CONST_ME_FERUMBRAS = 74,
CONST_ME_CONFETTI_HORIZONTAL = 75,
CONST_ME_CONFETTI_VERTICAL = 76,
// 77-157 are empty
CONST_ME_BLACKSMOKE = 158,
// 159-166 are empty
CONST_ME_REDSMOKE = 167,
CONST_ME_YELLOWSMOKE = 168,
CONST_ME_GREENSMOKE = 169,
CONST_ME_PURPLESMOKE = 170,
CONST_ME_RAGIAZCOCOON = 172,
CONST_ME_CRITICALHIT = 173,
};
enum ShootType_t : uint8_t {
CONST_ANI_NONE,
CONST_ANI_SPEAR = 1,
CONST_ANI_BOLT = 2,
CONST_ANI_ARROW = 3,
CONST_ANI_FIRE = 4,
CONST_ANI_ENERGY = 5,
CONST_ANI_POISONARROW = 6,
CONST_ANI_BURSTARROW = 7,
CONST_ANI_THROWINGSTAR = 8,
CONST_ANI_THROWINGKNIFE = 9,
CONST_ANI_SMALLSTONE = 10,
CONST_ANI_DEATH = 11,
CONST_ANI_LARGEROCK = 12,
CONST_ANI_SNOWBALL = 13,
CONST_ANI_POWERBOLT = 14,
CONST_ANI_POISON = 15,
CONST_ANI_INFERNALBOLT = 16,
CONST_ANI_HUNTINGSPEAR = 17,
CONST_ANI_ENCHANTEDSPEAR = 18,
CONST_ANI_REDSTAR = 19,
CONST_ANI_GREENSTAR = 20,
CONST_ANI_ROYALSPEAR = 21,
CONST_ANI_SNIPERARROW = 22,
CONST_ANI_ONYXARROW = 23,
CONST_ANI_PIERCINGBOLT = 24,
CONST_ANI_WHIRLWINDSWORD = 25,
CONST_ANI_WHIRLWINDAXE = 26,
CONST_ANI_WHIRLWINDCLUB = 27,
CONST_ANI_ETHEREALSPEAR = 28,
CONST_ANI_ICE = 29,
CONST_ANI_EARTH = 30,
CONST_ANI_HOLY = 31,
CONST_ANI_SUDDENDEATH = 32,
CONST_ANI_FLASHARROW = 33,
CONST_ANI_FLAMMINGARROW = 34,
CONST_ANI_SHIVERARROW = 35,
CONST_ANI_ENERGYBALL = 36,
CONST_ANI_SMALLICE = 37,
CONST_ANI_SMALLHOLY = 38,
CONST_ANI_SMALLEARTH = 39,
CONST_ANI_EARTHARROW = 40,
CONST_ANI_EXPLOSION = 41,
CONST_ANI_CAKE = 42,
CONST_ANI_TARSALARROW = 44,
CONST_ANI_VORTEXBOLT = 45,
CONST_ANI_PRISMATICBOLT = 48,
CONST_ANI_CRYSTALLINEARROW = 49,
CONST_ANI_DRILLBOLT = 50,
CONST_ANI_ENVENOMEDARROW = 51,
CONST_ANI_GLOOTHSPEAR = 53,
CONST_ANI_SIMPLEARROW = 54,
// for internal use, don't send to client
CONST_ANI_WEAPONTYPE = 0xFE, // 254
};
enum SpeakClasses : uint8_t {
TALKTYPE_SAY = 1,
TALKTYPE_WHISPER = 2,
TALKTYPE_YELL = 3,
TALKTYPE_PRIVATE_FROM = 4,
TALKTYPE_PRIVATE_TO = 5,
TALKTYPE_CHANNEL_Y = 7,
TALKTYPE_CHANNEL_O = 8,
TALKTYPE_SPELL = 9, //Flash Cliente
TALKTYPE_PRIVATE_NP = 10,
TALKTYPE_PRIVATE_PN = 12,
TALKTYPE_BROADCAST = 13,
TALKTYPE_CHANNEL_R1 = 14, //red - #c text
TALKTYPE_PRIVATE_RED_FROM = 15, //@name@text
TALKTYPE_PRIVATE_RED_TO = 16, //@name@text
TALKTYPE_MONSTER_SAY = 36,
TALKTYPE_MONSTER_YELL = 37,
TALKTYPE_CHANNEL_R2 = 0xFF, //#d
};
enum MessageClasses : uint8_t {
MESSAGE_STATUS_CONSOLE_BLUE = 4, /*FIXME Blue message in the console*/
MESSAGE_STATUS_CONSOLE_RED = 13, /*Red message in the console*/
MESSAGE_STATUS_DEFAULT = 17, /*White message at the bottom of the game window and in the console*/
MESSAGE_STATUS_WARNING = 18, /*Red message in game window and in the console*/
MESSAGE_EVENT_ADVANCE = 19, /*White message in game window and in the console*/
MESSAGE_STATUS_SMALL = 21, /*White message at the bottom of the game window"*/
MESSAGE_INFO_DESCR = 22, /*Green message in game window and in the console*/
MESSAGE_DAMAGE_DEALT = 23,
MESSAGE_DAMAGE_RECEIVED = 24,
MESSAGE_HEALED = 25,
MESSAGE_EXPERIENCE = 26,
MESSAGE_DAMAGE_OTHERS = 27,
MESSAGE_HEALED_OTHERS = 28,
MESSAGE_EXPERIENCE_OTHERS = 29,
MESSAGE_EVENT_DEFAULT = 30, /*White message at the bottom of the game window and in the console*/
MESSAGE_LOOT = 31,
MESSAGE_EVENT_ORANGE = 36, /*Orange message in the console*/
MESSAGE_STATUS_CONSOLE_ORANGE = 37, /*Orange message in the console*/
MESSAGE_REPORT = 38,
MESSAGE_HOTKEY_USE = 39,
MESSAGE_TUTORIAL_HINT = 40,
MESSAGE_THANK_YOU = 41,
MESSAGE_MARKET = 42,
};
enum FluidColors_t : uint8_t {
FLUID_EMPTY,
FLUID_BLUE,
FLUID_RED,
FLUID_BROWN,
FLUID_GREEN,
FLUID_YELLOW,
FLUID_WHITE,
FLUID_PURPLE,
};
enum FluidTypes_t : uint8_t {
FLUID_NONE = FLUID_EMPTY,
FLUID_WATER = FLUID_BLUE,
FLUID_BLOOD = FLUID_RED,
FLUID_BEER = FLUID_BROWN,
FLUID_SLIME = FLUID_GREEN,
FLUID_LEMONADE = FLUID_YELLOW,
FLUID_MILK = FLUID_WHITE,
FLUID_MANA = FLUID_PURPLE,
FLUID_LIFE = FLUID_RED + 8,
FLUID_OIL = FLUID_BROWN + 8,
FLUID_URINE = FLUID_YELLOW + 8,
FLUID_COCONUTMILK = FLUID_WHITE + 8,
FLUID_WINE = FLUID_PURPLE + 8,
FLUID_MUD = FLUID_BROWN + 16,
FLUID_FRUITJUICE = FLUID_YELLOW + 16,
FLUID_LAVA = FLUID_RED + 24,
FLUID_RUM = FLUID_BROWN + 24,
FLUID_SWAMP = FLUID_GREEN + 24,
FLUID_TEA = FLUID_BROWN + 32,
FLUID_MEAD = FLUID_BROWN + 40,
};
const uint8_t reverseFluidMap[] = {
FLUID_EMPTY,
FLUID_WATER,
FLUID_MANA,
FLUID_BEER,
FLUID_EMPTY,
FLUID_BLOOD,
FLUID_SLIME,
FLUID_EMPTY,
FLUID_LEMONADE,
FLUID_MILK,
};
const uint8_t clientToServerFluidMap[] = {
FLUID_EMPTY,
FLUID_WATER,
FLUID_MANA,
FLUID_BEER,
FLUID_MUD,
FLUID_BLOOD,
FLUID_SLIME,
FLUID_RUM,
FLUID_LEMONADE,
FLUID_MILK,
FLUID_WINE,
FLUID_LIFE,
FLUID_URINE,
FLUID_OIL,
FLUID_FRUITJUICE,
FLUID_COCONUTMILK,
FLUID_TEA,
FLUID_MEAD,
};
enum ClientFluidTypes_t : uint8_t {
CLIENTFLUID_EMPTY = 0,
CLIENTFLUID_BLUE = 1,
CLIENTFLUID_PURPLE = 2,
CLIENTFLUID_BROWN_1 = 3,
CLIENTFLUID_BROWN_2 = 4,
CLIENTFLUID_RED = 5,
CLIENTFLUID_GREEN = 6,
CLIENTFLUID_BROWN = 7,
CLIENTFLUID_YELLOW = 8,
CLIENTFLUID_WHITE = 9,
};
const uint8_t fluidMap[] = {
CLIENTFLUID_EMPTY,
CLIENTFLUID_BLUE,
CLIENTFLUID_RED,
CLIENTFLUID_BROWN_1,
CLIENTFLUID_GREEN,
CLIENTFLUID_YELLOW,
CLIENTFLUID_WHITE,
CLIENTFLUID_PURPLE,
};
enum SquareColor_t : uint8_t {
SQ_COLOR_BLACK = 0,
};
enum TextColor_t : uint8_t {
TEXTCOLOR_BLUE = 5,
TEXTCOLOR_LIGHTGREEN = 30,
TEXTCOLOR_LIGHTBLUE = 35,
TEXTCOLOR_MAYABLUE = 95,
TEXTCOLOR_DARKRED = 108,
TEXTCOLOR_LIGHTGREY = 129,
TEXTCOLOR_SKYBLUE = 143,
TEXTCOLOR_PURPLE = 155,
TEXTCOLOR_RED = 180,
TEXTCOLOR_MAYARED = 194,
TEXTCOLOR_ORANGE = 198,
TEXTCOLOR_YELLOW = 210,
TEXTCOLOR_WHITE_EXP = 215,
TEXTCOLOR_NONE = 255,
};
enum Icons_t {
ICON_POISON = 1 << 0,
ICON_BURN = 1 << 1,
ICON_ENERGY = 1 << 2,
ICON_DRUNK = 1 << 3,
ICON_MANASHIELD = 1 << 4,
ICON_PARALYZE = 1 << 5,
ICON_HASTE = 1 << 6,
ICON_SWORDS = 1 << 7,
ICON_DROWNING = 1 << 8,
ICON_FREEZING = 1 << 9,
ICON_DAZZLED = 1 << 10,
ICON_CURSED = 1 << 11,
ICON_PARTY_BUFF = 1 << 12,
ICON_REDSWORDS = 1 << 13,
ICON_PIGEON = 1 << 14,
ICON_BLEEDING = 1 << 15,
};
enum WeaponType_t : uint8_t {
WEAPON_NONE,
WEAPON_SWORD,
WEAPON_CLUB,
WEAPON_AXE,
WEAPON_SHIELD,
WEAPON_DISTANCE,
WEAPON_WAND,
WEAPON_AMMO,
};
enum Ammo_t : uint8_t {
AMMO_NONE,
AMMO_BOLT,
AMMO_ARROW,
AMMO_SPEAR,
AMMO_THROWINGSTAR,
AMMO_THROWINGKNIFE,
AMMO_STONE,
AMMO_SNOWBALL,
};
enum WeaponAction_t : uint8_t {
WEAPONACTION_NONE,
WEAPONACTION_REMOVECOUNT,
WEAPONACTION_REMOVECHARGE,
WEAPONACTION_MOVE,
};
enum WieldInfo_t {
WIELDINFO_LEVEL = 1 << 0,
WIELDINFO_MAGLV = 1 << 1,
WIELDINFO_VOCREQ = 1 << 2,
WIELDINFO_PREMIUM = 1 << 3,
};
enum Skulls_t : uint8_t {
SKULL_NONE = 0,
SKULL_YELLOW = 1,
SKULL_GREEN = 2,
SKULL_WHITE = 3,
SKULL_RED = 4,
SKULL_BLACK = 5,
SKULL_ORANGE = 6,
};
enum PartyShields_t : uint8_t {
SHIELD_NONE = 0,
SHIELD_WHITEYELLOW = 1,
SHIELD_WHITEBLUE = 2,
SHIELD_BLUE = 3,
SHIELD_YELLOW = 4,
SHIELD_BLUE_SHAREDEXP = 5,
SHIELD_YELLOW_SHAREDEXP = 6,
SHIELD_BLUE_NOSHAREDEXP_BLINK = 7,
SHIELD_YELLOW_NOSHAREDEXP_BLINK = 8,
SHIELD_BLUE_NOSHAREDEXP = 9,
SHIELD_YELLOW_NOSHAREDEXP = 10,
SHIELD_GRAY = 11,
};
enum GuildEmblems_t : uint8_t {
GUILDEMBLEM_NONE = 0,
GUILDEMBLEM_ALLY = 1,
GUILDEMBLEM_ENEMY = 2,
GUILDEMBLEM_NEUTRAL = 3,
GUILDEMBLEM_MEMBER = 4,
GUILDEMBLEM_OTHER = 5,
};
enum item_t : uint16_t {
ITEM_BROWSEFIELD = 460, // for internal use
ITEM_FIREFIELD_PVP_FULL = 1487,
ITEM_FIREFIELD_PVP_MEDIUM = 1488,
ITEM_FIREFIELD_PVP_SMALL = 1489,
ITEM_FIREFIELD_PERSISTENT_FULL = 1492,
ITEM_FIREFIELD_PERSISTENT_MEDIUM = 1493,
ITEM_FIREFIELD_PERSISTENT_SMALL = 1494,
ITEM_FIREFIELD_NOPVP = 1500,
ITEM_POISONFIELD_PVP = 1496,
ITEM_POISONFIELD_PERSISTENT = 1490,
ITEM_POISONFIELD_NOPVP = 1503,
ITEM_ENERGYFIELD_PVP = 1491,
ITEM_ENERGYFIELD_PERSISTENT = 1495,
ITEM_ENERGYFIELD_NOPVP = 1504,
ITEM_MAGICWALL = 1497,
ITEM_MAGICWALL_PERSISTENT = 1498,
ITEM_MAGICWALL_SAFE = 11098,
ITEM_WILDGROWTH = 1499,
ITEM_WILDGROWTH_PERSISTENT = 2721,
ITEM_WILDGROWTH_SAFE = 11099,
ITEM_BAG = 1987,
ITEM_GOLD_COIN = 2148,
ITEM_PLATINUM_COIN = 2152,
ITEM_CRYSTAL_COIN = 2160,
ITEM_DEPOT = 2594,
ITEM_LOCKER1 = 2589,
ITEM_INBOX = 14404,
ITEM_INBOXHOUSE = 26079,
ITEM_MARKET = 14405,
ITEM_STORE_INBOX = 26052,
//newdepot
ITEM_DEPOT_NULL = 25452,
ITEM_DEPOT_I = 25453,
ITEM_DEPOT_II = 25454,
ITEM_DEPOT_III = 25455,
ITEM_DEPOT_IV = 25456,
ITEM_DEPOT_V = 25457,
ITEM_DEPOT_VI = 25458,
ITEM_DEPOT_VII = 25459,
ITEM_DEPOT_VIII = 25460,
ITEM_DEPOT_IX = 25461,
ITEM_DEPOT_X = 25462,
ITEM_DEPOT_XI = 25463,
ITEM_DEPOT_XII = 25464,
ITEM_DEPOT_XIII = 25465,
ITEM_DEPOT_XIV = 25466,
ITEM_DEPOT_XV = 25467,
ITEM_DEPOT_XVI = 25468,
ITEM_DEPOT_XVII = 25469,
ITEM_REWARDCHEST = 21584, //MYREWARD
ITEM_REWARDCONTAINER = 21518,
ITEM_MALE_CORPSE = 3058,
ITEM_FEMALE_CORPSE = 3065,
ITEM_FULLSPLASH = 2016,
ITEM_SMALLSPLASH = 2019,
ITEM_PARCEL = 2595,
ITEM_LETTER = 2597,
ITEM_LETTER_STAMPED = 2598,
ITEM_LABEL = 2599,
ITEM_AMULETOFLOSS = 2173,
ITEM_STORECOINS = 24774,
RELOAD_TYPE_STORE,
ITEM_DOCUMENT_RO = 1968, //read-only
};
enum PlayerFlags : uint64_t {
PlayerFlag_CannotUseCombat = 1 << 0,
PlayerFlag_CannotAttackPlayer = 1 << 1,
PlayerFlag_CannotAttackMonster = 1 << 2,
PlayerFlag_CannotBeAttacked = 1 << 3,
PlayerFlag_CanConvinceAll = 1 << 4,
PlayerFlag_CanSummonAll = 1 << 5,
PlayerFlag_CanIllusionAll = 1 << 6,
PlayerFlag_CanSenseInvisibility = 1 << 7,
PlayerFlag_IgnoredByMonsters = 1 << 8,
PlayerFlag_NotGainInFight = 1 << 9,
PlayerFlag_HasInfiniteMana = 1 << 10,
PlayerFlag_HasInfiniteSoul = 1 << 11,
PlayerFlag_HasNoExhaustion = 1 << 12,
PlayerFlag_CannotUseSpells = 1 << 13,
PlayerFlag_CannotPickupItem = 1 << 14,
PlayerFlag_CanAlwaysLogin = 1 << 15,
PlayerFlag_CanBroadcast = 1 << 16,
PlayerFlag_CanEditHouses = 1 << 17,
PlayerFlag_CannotBeBanned = 1 << 18,
PlayerFlag_CannotBePushed = 1 << 19,
PlayerFlag_HasInfiniteCapacity = 1 << 20,
PlayerFlag_CanPushAllCreatures = 1 << 21,
PlayerFlag_CanTalkRedPrivate = 1 << 22,
PlayerFlag_CanTalkRedChannel = 1 << 23,
PlayerFlag_TalkOrangeHelpChannel = 1 << 24,
PlayerFlag_NotGainExperience = 1 << 25,
PlayerFlag_NotGainMana = 1 << 26,
PlayerFlag_NotGainHealth = 1 << 27,
PlayerFlag_NotGainSkill = 1 << 28,
PlayerFlag_SetMaxSpeed = 1 << 29,
PlayerFlag_SpecialVIP = 1 << 30,
PlayerFlag_NotGenerateLoot = static_cast<uint64_t>(1) << 31,
PlayerFlag_CanTalkRedChannelAnonymous = static_cast<uint64_t>(1) << 32,
PlayerFlag_IgnoreProtectionZone = static_cast<uint64_t>(1) << 33,
PlayerFlag_IgnoreSpellCheck = static_cast<uint64_t>(1) << 34,
PlayerFlag_IgnoreWeaponCheck = static_cast<uint64_t>(1) << 35,
PlayerFlag_CannotBeMuted = static_cast<uint64_t>(1) << 36,
PlayerFlag_IsAlwaysPremium = static_cast<uint64_t>(1) << 37,
};
#define CHANNEL_GUILD 0x00
#define CHANNEL_PARTY 0x01
#define CHANNEL_PRIVATE 0xFFFF
//CASTAFGP
#define CHANNEL_CAST 0x09
#define MAX_CAST_COUNT 30
const std::string LIVE_CAST_CHAT_NAME = "Spectator Chat";
//CASTAFGP
//Reserved player storage key ranges
//[10000000 - 20000000]
#define PSTRG_RESERVED_RANGE_START 10000000
#define PSTRG_RESERVED_RANGE_SIZE 10000000
//[1000 - 1500]
#define PSTRG_OUTFITS_RANGE_START (PSTRG_RESERVED_RANGE_START + 1000)
#define PSTRG_OUTFITS_RANGE_SIZE 500
//[2001 - 2011]
#define PSTRG_MOUNTS_RANGE_START (PSTRG_RESERVED_RANGE_START + 2001)
#define PSTRG_MOUNTS_RANGE_SIZE 10
#define PSTRG_MOUNTS_CURRENTMOUNT (PSTRG_MOUNTS_RANGE_START + 10)
#define IS_IN_KEYRANGE(key, range) (key >= PSTRG_##range##_START && ((key - PSTRG_##range##_START) <= PSTRG_##range##_SIZE))
#endif
| [
"noreply@github.com"
] | noreply@github.com |
bc426aa42d25eb674efb461d8d15505aa5d02557 | 428e7da0b86e7edad5d8eb7cdf68b75e6f912124 | /CPGene/PCH.h | 8bcea88d33d27955b4414e4b35667674c7c5742e | [] | no_license | walkerjones/CPGene | f605f075137eda0862c65e78cc95cc45369a355c | 803b75a0768e6e7b24d5011d9181e0ef75c45215 | refs/heads/master | 2022-07-22T02:20:29.667431 | 2020-01-30T06:55:29 | 2020-01-30T06:55:29 | 235,897,175 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 342 | h | #pragma once
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <random>
#include <sstream>
#include "Crossover.h"
#include "Chromosome.h"
#include "ChromFloat.h"
#include "ChromChars.h"
#include "GA.h"
#include "GAString.h"
#include "GAFloat.h"
#include "stringbuilder.h" | [
"walker15130@gmail.com"
] | walker15130@gmail.com |
91f27fed11383ab0fc4d545ebbf29edc5f692e95 | 20abcf4a2c8563cb68a9894082fd8832c891664b | /src/include/map_store.h | fd2870f98bc2f4ec4d7703e595115d61391097eb | [] | no_license | rgrunbla/Phi | e9b20c296fd659cb72765fed77805c211643dec4 | 5bf91d95a2b123a2622ede99be5e098edc51465c | refs/heads/master | 2022-11-11T12:16:48.139253 | 2020-06-30T08:44:19 | 2020-06-30T08:44:19 | 275,846,075 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,897 | h | #ifndef MAP_STORE_H
#define MAP_STORE_H
#include <iostream>
#include <map>
#include <ns3-zmq-messages/zmq-propagation-messages.pb.h>
#include <string>
#include <variant>
#include <vector>
class MapStore {
public:
MapStore();
MapStore(std::string);
void set(std::variant<int, float, double, std::string>,
std::variant<std::vector<int>, std::vector<float>,
std::vector<double>, std::vector<std::string>>);
void set(std::variant<int, float, double, std::string>,
std::variant<int, float, double, std::string>);
void set(std::variant<int, float, double, std::string>, int,
std::variant<int, float, double, std::string>);
std::map<
std::variant<int, float, double, std::string>,
std::variant<std::vector<int>, std::vector<float>, std::vector<double>,
std::vector<std::string>>>::iterator
find(std::variant<int, float, double, std::string>);
std::map<
std::variant<int, float, double, std::string>,
std::variant<std::vector<int>, std::vector<float>, std::vector<double>,
std::vector<std::string>>>::iterator
begin();
std::map<
std::variant<int, float, double, std::string>,
std::variant<std::vector<int>, std::vector<float>, std::vector<double>,
std::vector<std::string>>>::iterator
end();
std::map<std::variant<int, float, double, std::string>,
std::variant<std::vector<int>, std::vector<float>,
std::vector<double>, std::vector<std::string>>>
values;
int size();
std::variant<int, float, double, std::string>
get(std::variant<int, float, double, std::string>, int);
void serialize(phi::Map *);
void print();
private:
std::string name;
bool initialized = false;
};
// std::ostream& operator<<(std::ostream& os, const MapStore& store_value);
#endif // MAP_STORE_H | [
"remy@grunblatt.org"
] | remy@grunblatt.org |
c50ce99a123e738e3b84c8f91669d8b0a4ed8f38 | 4c1dbfbb666ddd1b2461c00fbe4b6710ad3cd602 | /exchange/exchange.h | b5bcf538044becfd20b9329752ab73c52ae87641 | [] | no_license | huangjiayi-maker/huangjiayi-vcClass | 290b010604379b94726f7dd8de2457cb180322cb | 1f584afbefc562eaf8a1888b6d771851906dda46 | refs/heads/master | 2021-05-16T23:23:51.272455 | 2020-06-28T16:01:38 | 2020-06-28T16:01:38 | 250,510,189 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 558 | h |
// exchange.h : exchange 应用程序的主头文件
//
#pragma once
#ifndef __AFXWIN_H__
#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
#endif
#include "resource.h" // 主符号
// CexchangeApp:
// 有关此类的实现,请参阅 exchange.cpp
//
class CexchangeApp : public CWinApp
{
public:
CexchangeApp();
// 重写
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// 实现
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
};
extern CexchangeApp theApp;
| [
"noreply@github.com"
] | noreply@github.com |
92bd38a749065aa5771ef8a94331f600435b20fa | eb464c673659836704359c8133d9947246f91c37 | /cpp04/ex01/PowerFist.cpp | cbc9365174cc2efd8c2edf16136faf8d1f75375a | [] | no_license | dmarget/introduction-to-oop-in-CPP | 91d839a5a086e50a350895c44d6da8fa0711947f | 4933703e7b841a7acec1cf176610303fa8a39944 | refs/heads/master | 2023-06-10T08:01:53.735227 | 2021-07-01T13:56:46 | 2021-07-01T13:56:46 | 382,044,578 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 397 | cpp | //
// Created by Duncan Marget on 6/7/21.
//
#include "PowerFist.hpp"
PowerFist::PowerFist()
: AWeapon("PowerFist", 8, 50)
{}
PowerFist::PowerFist(PowerFist ©): AWeapon(copy)
{}
PowerFist & PowerFist::operator=(PowerFist ©)
{
AWeapon::operator=(copy);
return *this;
}
void PowerFist::attack() const
{
std:: cout << "* pschhh... SBAM! * "<< std::endl;
}
PowerFist::~PowerFist()
{
} | [
"duncan.marget@gmail.com"
] | duncan.marget@gmail.com |
9b2da71c59e201fd8180df7fe8a76da098aecb96 | 393f32c64d07e5cc7d326f2b7d4c34403b5d2133 | /assign05/order.cpp | 194b9bda93b8a80cf65d5f068d14ccc54e36bbb2 | [] | no_license | ikpaetukgabriel/CS-165 | 9774c31d419bb1bd0431e3f7508eb350ed6b5fd4 | 5cabbdae440ddf4ef160187ae42998c1a8100052 | refs/heads/main | 2023-03-19T00:26:10.126013 | 2021-03-17T16:56:44 | 2021-03-17T16:56:44 | 327,455,810 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,885 | cpp | /***************************************************************
* File: oredr.cpp
* Author: Gabriel Ikpaetuk
* Purpose: Contains the implementation of the Order class
***************************************************************/
#include "order.h"
// Put your the method bodies for your order class here
/***************************************************************
* ADDRESS CLASS DEFAULT CONSTRUCTOR
***************************************************************/
Order::Order()
{
setQuantity(0);
setProduct(Product());
setCustomer(Customer());
}
/***************************************************************
* ADDRESS CLASS NON-DEFAULT CONSTRUCTOR
***************************************************************/
Order::Order(Product productInput, int quantityInput, Customer customerInput)
{
setQuantity(quantityInput);
setProduct(productInput);
setCustomer(customerInput);
}
/***************************************************************
* GETPRODUCT
* Purpose: Gets the value of Product, the private member class
***************************************************************/
Product Order::getProduct() const
{
return product;
}
/***************************************************************
* SETPRODUCT
* Purpose: Sets, Product, the private member class
***************************************************************/
void Order::setProduct(Product productInput)
{
product = productInput;
}
/***************************************************************
* GETQUANTITY
* Purpose: Gets the value of quantity, the private member
* variable
***************************************************************/
int Order::getQuantity() const
{
return quantity;
}
/***************************************************************
* SETQUANTITY
* Purpose: Sets, quantity, the private member variable
***************************************************************/
void Order::setQuantity(int quantityInput)
{
quantity = quantityInput;
}
/***************************************************************
* GETCUSTOMER
* Purpose: Gets the value of Customer, the private member class
***************************************************************/
Customer Order::getCustomer() const
{
return customer;
}
/***************************************************************
* SETCUSTOMER
* Purpose: Sets, Customer, the private member class
***************************************************************/
void Order::setCustomer(Customer customerInput)
{
customer = customerInput;
}
/***************************************************************
* GETSHIPPINGZIP
* Purpose: Gets the value of Customer zip
***************************************************************/
string Order::getShippingZip() const
{
return getCustomer().getAddress().getZip();
}
/***************************************************************
* GETTOTALPRICE
* Purpose: Gets the product total price
***************************************************************/
double Order::getTotalPrice() const
{
return getProduct().getTotalPrice() * getQuantity();
}
/***************************************************************
* DISPLAYSHIPPINGLABEL
* Purpose: Displays customer's shipping label
***************************************************************/
void Order::displayShippingLabel() const
{
getCustomer().display();
}
/***************************************************************
* DISPLAYINFORMATION
* Purpose: Displays customer details, product details, and
* order total price
***************************************************************/
void Order::displayInformation() const
{
cout << getCustomer().getName() << endl;
cout << getProduct().getName() << endl;
cout << "Total Price: "
<< "$" << getTotalPrice() << endl;
} | [
"gabrielikpaetuk@byui.edu"
] | gabrielikpaetuk@byui.edu |
0f40c87a85ca9f6404004a375d0b2341e7198928 | b34f7f1206edfcd881b7255db6083f24d06f17b8 | /beakjoon/2749.cpp | 5fe99d8e241f3e0f63efcdf0c05182dacab4cc31 | [] | no_license | asdfghjkkl11/algorythm | 1be018751df440166c2349a6c242cdb7d1e06b1f | a59aef536216e60aa6936de6a51952976b4c3f47 | refs/heads/master | 2020-03-09T03:46:43.588344 | 2019-11-15T06:07:13 | 2019-11-15T06:07:13 | 128,572,347 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 248 | cpp | #include <iostream>
using namespace std;
long long n;
int fib[1500000] = {0,1};
int main()
{
cin >> n;
n %= 1500000;
if (n > 1)
for (int i = 2; i <= n;i++)
fib[i] = (fib[i - 1] + fib[i - 2]) % 1000000;
cout << fib[n] << endl;
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
6b997552f725e850f9cb38e840aebaafcf5425cb | 934943c13d4f52d83b96c0d68b37b265a0893d8e | /core/ui/extensions/components/mainView/boardDisplay/dicedisplay.cpp | 6c17375d7f691165a4a8ab67065c822cb51e50e8 | [] | no_license | mustafamohammed14/Monopoli-2D | ed6af6eb7ff2e8eb56ccc2ae39b4b4aff82c8a68 | 531931aea3412975ec47ba6487423f6cb440d811 | refs/heads/master | 2023-06-19T09:28:43.037673 | 2021-07-15T01:19:10 | 2021-07-15T01:19:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 708 | cpp | #include "dicedisplay.h"
#include <QPainter>
#include "core/game/entity/dice.h"
DiceDisplay::DiceDisplay(Dice *setDice, QWidget *parent)
: QWidget(parent)
{
dice = setDice;
connect(dice, SIGNAL(rolled()), this, SLOT(update()));
this->setGeometry(200, 200, 300, 300);
}
void DiceDisplay::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
QString basePath = ":/img/img/dice/die";
QString path1 = basePath + QString::number(dice->getFirst()) + ".png";
QString path2 = basePath + QString::number(dice->getSecond()) + ".png";
QPixmap pixmap1(path1);
QPixmap pixmap2(path2);
painter.drawPixmap(0, 0, 60, 60, pixmap1);
painter.drawPixmap(70, 70, 60, 60, pixmap2);
}
| [
"tilen.gombac@gmail.com"
] | tilen.gombac@gmail.com |
a1c29a6dc7c2ca46a2f23f1b3ce3b8c62540dcbe | 0c5daeaafc8808ea0da663ab5a67394757249c5c | /OJ/oj242.cpp | db3a4d3f4025611b0c5733b6b51dccbcc1b17031 | [] | no_license | Tuotuoi/haizeiOJ | 798c857666b34b719747e6b71c8b67f0e7eb4d96 | a03ebd6c97a7d3f06fb4d214d1e0ab1d74b0713a | refs/heads/master | 2021-05-20T02:50:12.469382 | 2020-09-28T13:21:29 | 2020-09-28T13:21:29 | 252,154,526 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,135 | cpp | /*************************************************************************
> File Name: oj242.cpp
> Author:
> Mail:
> Created Time: 2020年05月17日 星期日 14时34分13秒
************************************************************************/
#include<iostream>
using namespace std;
#define MAX_N 100000
long long a[MAX_N + 5];
long long b[MAX_N + 5];
long long sum[MAX_N + 5];
long long n, m;
bool check(long long A) {
for (long long i = 1; i <= n; i++) {
b[i] = a[i] - A;
sum[i] = b[i] + sum[i - 1];
}
long long Y = 0;
for (long long j = m; j <= n; j++) {
Y = min(Y,sum[j - m]);
if (sum[j] - Y >= 0) return true;
}
return false;
}
long long bs(long long l , long long r) {
if(l == r) return l;
long long mid = (r + l + 1) >> 1;
if (check(mid)) return bs(mid, r);
return bs(l, mid - 1);
}
int main() {
cin >> n >> m;
long long l = 0x3f3f3f3f, r = -0x3f3f3f3f;
for (long long i = 1; i <= n; i++) {
cin >> a[i];
a[i] *= 1000;
l = min(l, a[i]);
r = max(r, a[i]);
}
cout << bs(l,r) << endl;
}
| [
"m18999624868_1@163.com"
] | m18999624868_1@163.com |
4deaeaefeb54e48a448e00a66b4a58799d6a7eb5 | c7600591e4ee819336f76579d0b89327ad41cc68 | /CarCompany/stdafx.cpp | 56854e2bda4303a0ae534ebaef2292dcb1e87674 | [] | no_license | VannesteFelix/CarCompany | 6eb52894cb4a9098274f4e696ee743de8bf51dbb | e5368f4344db40aee09b86b07cee3102f5dcf3f1 | refs/heads/master | 2021-01-17T22:16:58.096285 | 2017-03-08T20:05:54 | 2017-03-08T20:05:54 | 84,192,858 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 332 | cpp | // stdafx.cpp : fichier source incluant simplement les fichiers Include standard
// CarCompany.pch représente l'en-tête précompilé
// stdafx.obj contient les informations de type précompilées
#include "stdafx.h"
// TODO: faites référence aux en-têtes supplémentaires nécessaires dans STDAFX.H
// absents de ce fichier
| [
"felix.vanneste@isen.yncrea.fr"
] | felix.vanneste@isen.yncrea.fr |
b094183be3d44d3b093fe135e56628e21f1defb6 | e5f74db2b079783fbf923826e3ee0d061849a889 | /Code/ConfigOptions/PostCurve.cpp | eaf07058a7361e64d96c8909dff8343907647cda | [
"BSD-3-Clause"
] | permissive | sunhan01/FastCAE | 57b6ba145864978ffcc57dd4721a17d4b6c350f8 | 4e9e9aa1cc076bc3ba5d7823fb61e5b0a9dc2e72 | refs/heads/master | 2023-02-12T14:56:52.414267 | 2021-01-11T05:43:42 | 2021-01-11T05:43:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,024 | cpp | #include "PostCurve.h"
namespace ConfigOption
{
void PostCurve::setDescribe(QString d)
{
_describe = d;
this->appendProperty("Name",d);
}
QString PostCurve::getDescribe()
{
return _describe;
}
void PostCurve::setXVariable(QString x)
{
_xVariable = x;
this->appendProperty("X Axis", x);
}
QString PostCurve::getXVariable()
{
return _xVariable;
}
void PostCurve::setYVariable(QString y)
{
_yVariable = y;
this->appendProperty("Y Axis", y);
}
QString PostCurve::getYVariable()
{
return _yVariable;
}
void PostCurve::setFile(QString f)
{
_file = f;
this->appendProperty("File", f);
}
QString PostCurve::getFile()
{
return _file;
}
void PostCurve::copy(DataBase* data)
{
PostCurve* d = dynamic_cast<PostCurve*>(data);
if (d == nullptr) return;
QString des = d->getDescribe();
QString x = d->getXVariable();
QString y = d->getYVariable();
QString f = d->getFile();
this->setDescribe(des);
this->setXVariable(x);
this->setYVariable(y);
this->setFile(f);
}
} | [
"libaojunqd@foxmail.com"
] | libaojunqd@foxmail.com |
db22c47f8b45990884eb79cd02a0ebfcfd710303 | 488f1abd5cf9777004eaa9d68ba436415e504be0 | /c++ data structure-head file/软件包/kruskal.h | c2411f591e9e3e2b7cc625d84e95d543ab6360de | [] | no_license | tomastong/DataStructure | dcd43e9f70329106a9b039d12173aa1e9d37d70d | ea79a7b9689f18aa426c37e02f20839633d597e6 | refs/heads/master | 2021-01-10T21:26:50.354406 | 2014-01-31T11:40:04 | 2014-01-31T11:40:04 | 16,406,390 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,658 | h | #ifndef __KRUSKAL_H__
#define __KRUSKAL_H__
#include "adj_list_undir_network.h" // 邻接表无向网
// Kruskal森林类
class KruskalForest
{
private:
int *treeNo; // 顶点所在的树编号
int vexNum; // 顶点数
public:
KruskalForest(int num = DEFAULT_SIZE); // 构造函数
~KruskalForest(){ delete []treeNo; }; // 析构函数
bool IsSameTree(int v1, int v2); // 判断v1和v2是否在同一棵树上
void Union(int v1, int v2); // 将v2所在树的所有顶点合并到v1所在树上
};
// Kruskal森林类实现
KruskalForest::KruskalForest(int num)
// 操作结果:构造顶点数为num的Kruskal森林
{
vexNum = num; // 顶点数
treeNo = new int[vexNum]; // 分配存储空间
for (int v = 0; v < vexNum; v++)
{ // 初始时,每棵树只有一个顶点,树的个数与顶点个数相同
treeNo[v] = v;
}
}
bool KruskalForest::IsSameTree(int v1, int v2)
// 操作结果:如果v1和v2在同一棵树上,则返回true,否则返回false
{
return treeNo[v1] == treeNo[v2];
}
void KruskalForest::Union(int v1, int v2)
// 操作结果:将v2所在树的所有顶点合并到v1所在树上
{
int v1TNo = treeNo[v1], v2TNo = treeNo[v2];
for (int v = 0; v < vexNum; v++)
{ // 查找v2所在树的顶点
if (treeNo[v] == v2TNo)
{ // // 将v2所在树上的顶点所在树编号改为v1所在树的编号
treeNo[v] = v1TNo;
}
}
}
// Kruskal边类
template <class WeightType>
class KruskalEdge
{
public:
int vertex1, vertex2; // 边的顶点
WeightType weight; // 边的权值
KruskalEdge(int v1 = -1, int v2 = -1, int w = 0); // 构造函数
};
template <class WeightType>
KruskalEdge<WeightType>::KruskalEdge(int v1, int v2, int w)
// 操作结果: 由顶点v1、v2和权w构造边——构造函数
{ // 构造函数
vertex1 = v1; // 顶点vertex1
vertex2 = v2; // 顶点vertex2
weight = w; // 权weight
}
template <class WeightType>
void Sort(KruskalEdge<WeightType> *a, int n)
// 操作结果:按权值对边进行升序排序
{
for (int i = n - 1; i > 0; i--)
for (int j = 0; j < i; j++)
if (a[j].weight > a[j + 1].weight)
{ // 出现逆序,则交换a[j]与a[j + 1]
KruskalEdge<WeightType> tmpEdge; // 临时边
tmpEdge = a[j];
a[j] = a[j + 1];
a[j + 1] = tmpEdge;
}
}
template <class ElemType, class WeightType>
void MiniSpanTreeKruskal(const AdjListUndirNetwork<ElemType, WeightType> &net)
// 初始条件:存在网net
// 操作结果:用Kruskal算法构造网net的最小代价生成树
{
int count; // 记数器
KruskalForest kForest(net.GetVexNum()); // 定义Kruskal森林
KruskalEdge<WeightType> *kEdge;
kEdge = new KruskalEdge<WeightType>[net.GetEdgeNum()]; // 定义边数组,只存储v > u的边(v,u)
count = 0; // 表示当前已存入kEdge的边数
for (int v = 0; v < net.GetVexNum(); v++)
{
for (int u = net.FirstAdjVex(v); u >= 0; u = net.NextAdjVex(v, u))
{ // 将边(v, u)存入kEdge中
if (v > u)
{ // 只存储v > u的边(v,u)
KruskalEdge<WeightType> tmpKEdge(v, u, net.GetWeight(v, u));
kEdge[count++] = tmpKEdge;
}
}
}
Sort(kEdge, count); // 对边按权值进行排序
for (int i = 0; i < count; i++)
{ // 对kEdgePtr中的边进行搜索
int v1 = kEdge[i].vertex1, v2 = kEdge[i].vertex2;
if (!kForest.IsSameTree(v1, v2))
{ // 边的两端不在同一棵树上,则为最小代价生成树上的边
cout << "edge:(" << v1 << "," << v2 << ") weight:"
<<net.GetWeight(v1, v2)<< endl ; // 输出边及权值
kForest.Union(v1, v2); // 将v2所在树的所有顶点合并到v1所在树上
}
}
delete []kEdge; // 释放存储空间
}
#endif
| [
"tobeyourhero@gmail.com"
] | tobeyourhero@gmail.com |
ed92038f88758b737fd9640ad9202dff91669226 | aba6c403aa4b8fe1ba19d14669062172c413e29a | /Sem 2/Object Computing Lab/Extras/project1/rectangle.cpp | e37112676e63a41dbffba139065831a6cc6e00cd | [] | no_license | rsreenivas2001/LabMain | 3aa38526a40eb0496ab27dbdbfefde966077a6a6 | 249adc5f3189169cf9ed696e0234b11f7d2c028d | refs/heads/master | 2021-07-06T19:21:30.819464 | 2021-04-05T17:07:49 | 2021-04-05T17:07:49 | 232,073,123 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 280 | cpp | #include"rectangle.h"
void rect::set (float x)
{
cout<<"Enter length";
cin>>l;
cout<<"Enter breadth";
cin>>b;
}
float rect::getl()
{
return l;
}
float rect::getb()
{
return b;
}
float area()
{
return l*b;
}
float perimeter()
{
return (2*(l+b));
}
| [
"rsreenivas2001@gmail.com"
] | rsreenivas2001@gmail.com |
1118d8aaeaca5ab8867cb7681d70210c02be39a5 | 5df66b7c0cf0241831ea7d8345aa4102f77eba03 | /Carberp Botnet/source - absource/pro/all source/GrabberIE_FF/common/mem.cpp | 6cd778e9170f63fd86139efc2f6ccf075345f749 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | bengalm/fireroothacker | e8f20ae69f4246fc4fe8c48bbb107318f7a79265 | ceb71ba972caca198524fe91a45d1e53b80401f6 | refs/heads/main | 2023-04-02T03:00:41.437494 | 2021-04-06T00:26:28 | 2021-04-06T00:26:28 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 5,693 | cpp | #include "stdafx.h"
#include <windows.h>
#include "defines.h"
#include "mem.h"
#if defined _WIN64
# define ADVANCED_ALLOC_BYTES 8
#else
# define ADVANCED_ALLOC_BYTES 4
#endif
static HANDLE mainHeap;
#if(MEM_PERSONAL_HEAP == 1)
static bool heapCreated;
#endif
#if(MEM_PERSONAL_HEAP == 1)
void Mem::init(SIZE_T initialSize)
{
mainHeap = HeapCreate(0, initialSize, 0);
if(mainHeap == NULL)
{
mainHeap = GetProcessHeap();
heapCreated = false;
}
else heapCreated = true;
}
#else
void Mem::init(void)
{
mainHeap = CWA(kernel32, GetProcessHeap)();
}
#endif
void Mem::uninit(void)
{
# if(MEM_PERSONAL_HEAP == 1)
if(heapCreated)HeapDestroy(mainHeap);
# endif
}
bool Mem::reallocEx(void *old, SIZE_T size)
{
if(size == 0)
{
free(*(LPBYTE *)old);
*(LPBYTE *)old = NULL;
}
else
{
register void *p = realloc(*(LPBYTE *)old, size);
if(p == NULL)return false;
*(LPBYTE *)old = (LPBYTE)p;
}
return true;
}
void *Mem::realloc(void *old, SIZE_T size)
{
if(size == 0)return NULL;
# if(MEM_ALLOC_SAFE_BYTES == 1)
size += ADVANCED_ALLOC_BYTES;
# endif
if(old == NULL)old = HeapAlloc(mainHeap, HEAP_ZERO_MEMORY, size);
else old = HeapReAlloc(mainHeap, HEAP_ZERO_MEMORY, old, size);
return old;
}
void *Mem::alloc(SIZE_T size)
{
register void *p;
if(size == 0)p = NULL;
else
{
# if(MEM_ALLOC_SAFE_BYTES == 1)
size += ADVANCED_ALLOC_BYTES;
# endif
p = HeapAlloc(mainHeap, HEAP_ZERO_MEMORY, size);
}
return p;
}
void *Mem::quickAlloc(SIZE_T size)
{
register void *p;
if(size == 0)p = NULL;
else
{
# if(MEM_ALLOC_SAFE_BYTES == 1)
size += ADVANCED_ALLOC_BYTES;
# endif
p = HeapAlloc(mainHeap, 0, size);
}
return p;
}
void Mem::free(void *mem)
{
if(mem)HeapFree(mainHeap, 0, mem);
}
void Mem::zeroAndFree(void *mem, SIZE_T size)
{
_zero(mem, size);
free(mem);
}
void Mem::freeArrayOfPointers(void *mem, SIZE_T count)
{
if(mem && count)
{
LPBYTE *p = (LPBYTE *)mem;
while(count--)free(p[count]);
free(p);
}
}
void ASM_INTERNAL Mem::_copy(void *dest, const void *source, SIZE_T size)
{
#if defined _WIN64
for(register SIZE_T i = 0; i < size; i++)
{
((LPBYTE)dest)[i] = ((LPBYTE)source)[i];
if(i == 0)i = 0; //Òóïîé êîìïèëÿòîð ïûòàåòñÿ çàïèõàòü memcpy.
}
#else
__asm
{
push esi
push edi
push ecx
mov esi, dword ptr[esp + 0x8 + 0xC]
mov edi, dword ptr[esp + 0x4 + 0xC]
mov ecx, dword ptr[esp + 0xC + 0xC]
rep movsb
pop ecx
pop edi
pop esi
ret 0xC
};
#endif
}
void Mem::_copyFromEnd(void *dest, const void *source, SIZE_T size)
{
while(size--)((LPBYTE)dest)[size] = ((LPBYTE)source)[size];
}
void *Mem::_copy2(void *dest, const void *source, SIZE_T size)
{
_copy(dest, source, size);
return (void *)((LPBYTE)dest + size);
}
void *Mem::copyEx(const void *source, SIZE_T size)
{
void *p = quickAlloc(size);
if(p != NULL)_copy(p, source, size);
return p;
}
int Mem::_compare(const void *mem1, const void *mem2, SIZE_T size)
{
register BYTE m1, m2;
for(register SIZE_T i = 0; i < size; i++)
{
m1 = ((LPBYTE)mem1)[i];
m2 = ((LPBYTE)mem2)[i];
if(m1 != m2)return (int)(m1 - m2);
}
return 0;
}
void Mem::_zero(void *mem, SIZE_T size)
{
_set(mem, 0, size);
}
void ASM_INTERNAL Mem::_set(void *mem, char c, SIZE_T size)
{
#if defined _WIN64
//ÍÅÍÀÂÈÆÓ ÒÓÏÀÐÛËÛÕ ÈÄÈÎÒÎÂ ÈÇ M$.
register SIZE_T i = size;
while(i--)((char *)mem)[i] = c;
#else
__asm
{
push eax
push edi
push ecx
mov al, byte ptr[esp + 0x8 + 0xC]
mov edi, dword ptr[esp + 0x4 + 0xC]
mov ecx, dword ptr[esp + 0xC + 0xC]
rep stosb
pop ecx
pop edi
pop eax
ret 0xC
};
#endif
}
void *Mem::_getL(void *mem, char c, SIZE_T size)
{
for(register SIZE_T i = 0; i < size; i++)if(((char *)mem)[i] == c)return ((char *)mem) + i;
return NULL;
}
void *Mem::_getR(void *mem, char c, SIZE_T size)
{
register SIZE_T i = size;
while(i--)if(((char *)mem)[i] == c)return ((char *)mem) + i;
return NULL;
}
void Mem::_replace(void *mem, SIZE_T size, char oldChar, char newChar)
{
for(register SIZE_T i = 0; i < size; i++)if(((char *)mem)[i] == oldChar)((char *)mem)[i] = newChar;
}
void *Mem::_findData(const void *mem, SIZE_T memSize, void *data, SIZE_T dataSize)
{
if(memSize >= dataSize)
{
memSize -= dataSize;
for(register SIZE_T i = 0; i <= memSize; i++)
{
register LPBYTE p = (LPBYTE)mem + i;
if(_compare(p, data, dataSize) == 0)return (void *)p;
}
}
return NULL;
}
void Mem::_swap(void *mem1, void *mem2, SIZE_T size)
{
register BYTE tmp;
register LPBYTE b1 = (LPBYTE)mem1;
register LPBYTE b2 = (LPBYTE)mem2;
if(mem1 != mem2)while(size--)
{
tmp = *b1;
*b1++ = *b2;
*b2++ = tmp;
}
}
SIZE_T Mem::_replaceDword(DWORD originalValue, DWORD newValue, void *mem, SIZE_T memSize)
{
SIZE_T count = 0;
if(memSize >= sizeof(DWORD))
{
memSize -= sizeof(DWORD);
for(SIZE_T i = 0; i <= memSize; i++)
{
LPDWORD p = (LPDWORD)((LPBYTE)mem + i);
if(*p == originalValue)
{
count++;
*p = newValue;
i += sizeof(DWORD);
}
}
}
return count;
}
SIZE_T Mem::_replaceQword(DWORD64 originalValue, DWORD64 newValue, void *mem, SIZE_T memSize)
{
SIZE_T count = 0;
if(memSize >= sizeof(DWORD64))
{
memSize -= sizeof(DWORD64);
for(SIZE_T i = 0; i <= memSize; i++)
{
DWORD64 *p = (DWORD64 *)((LPBYTE)mem + i);
if(*p == originalValue)
{
count++;
*p = newValue;
i += sizeof(DWORD64);
}
}
}
return count;
}
| [
"ludi@ps.ac.cn"
] | ludi@ps.ac.cn |
ae89bcee1bd4c933a75677d3692d20fe340d2965 | e3c382bd17830e65873499f9b2a7b1c13d02eab6 | /main.cpp | 5bb8441833636bf99870a8da08531a34c85263da | [] | no_license | ugracing/datalogger-intrerrupts | 3c6f92f45178fdf165204bb84c961e0cc36fbf1a | 8bd86a23b19ea6c9b1dd726499ef74bf97f4cfa7 | refs/heads/master | 2020-04-02T01:04:26.306936 | 2015-02-18T12:48:03 | 2015-02-18T12:48:03 | 30,123,723 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,625 | cpp | #include "mbed.h"
#include <stdio.h>
#include <string>
Serial pc(USBTX, USBRX); // tx, rx
Serial msquirt(p9, p10); // tx, rx
Timer t;
int byte_count;
string data;
bool fetch;
int count;
typedef struct car_data{
float RPM;
float map;
float mat;
float coolant;
float throttle;
float battery;
float air_fuel_1;
float air_fuel_2;
bool engine_status[8];
bool injectors_status[7];
} car_data;
void rx_data()
{ count++;
car_data car_data;
while (msquirt.readable())
{
data += msquirt.getc();
byte_count++;
//pc.printf("\r\n %d" , byte_count);
if (!msquirt.readable())
{
wait(0.001);
}
}
wait(0.001);
union
{
uint8_t b[2];
int i;
};
b[1] = data[22]; b[0] = data[23];
car_data.coolant = (i-320) * 0.05555;
pc.printf("CLT = %f \r\n",car_data.coolant);
pc.printf("got %d bytes\r\n", byte_count);
data = "";
byte_count = 0;
pc.printf("set to zer mofofoker");
fetch = true;
pc.printf("fetch set true");
//wait(0.2);
}
void log_data()
{
//log to usb stick
}
void drive_dash()
{
//drive leds etc
}
int main()
{
msquirt.baud(38400);
pc.baud(57600);
msquirt.attach(&rx_data, Serial::RxIrq);
fetch = true;
t.start();
while(1)
{ wait(0.01);
if(fetch)
{
printf("TIME IS: %f \r\n seconds", t.read());
msquirt.printf("A");
fetch = false;
}
else if (!fetch)
{
count++;
}
}
} | [
"laurabogatu@yahoo.com"
] | laurabogatu@yahoo.com |
f4690c9e9c43dec77b718acf7b9907b10da50e75 | ea03b24806c6657761e7c1ed1d93ea9d8b5cb8e8 | /funciones_valores_referencia.cpp | dfd9cd36518d23dde00635691130f749224e4c58 | [] | no_license | DanielRuizHer/introduccion-a-la-programacion | 984754089f5bfa426f18a8468941886fd108b867 | 70e0047b32bfa0a0f10492d13b3decc6a5fe86d9 | refs/heads/master | 2020-05-05T08:51:11.082969 | 2019-04-13T19:04:52 | 2019-04-13T19:04:52 | 179,880,912 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 500 | cpp | #include<iostream>
using namespace std;
/*int sumaPorValor(int a, int b){
a++;
return a + b;
}*/
void sumaPorReferencia(int *a, int *b){
*a = *a + 2;
*b = *b + 3;
cout<<"a + b: "<<*a + *b<<endl;
}
int main(){
/*int numero1 = 3, numero2 = 5;
cout<<"resultado: "<<sumaPorValor(numero1, numero2)<<endl;
cout<<"numero: "<<numero1<<endl;*/
int numero1 = 3, numero = 5;
sumaPorReferencia (&numero1, &numero2);
cout<<"numero1: "<<numero1<<endl;
cout<<"numero2: "<<numero2<<endl;
return 0;
}
| [
"dan.ruiz.drh@gmail.com"
] | dan.ruiz.drh@gmail.com |
909697c20d330e1003d3b7378c73b9f74609ea3f | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_18065.cpp | f9094e75f47629b6498e41211b4c2feddd2feaec | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 127 | cpp | {
ret = lzma_index_buffer_encode(
i, out, &out_pos, out_size);
stream_flags.backward_size = lzma_index_size(i);
} | [
"993273596@qq.com"
] | 993273596@qq.com |
7ee53e6071337f5cdcb86d98651cf36c657e3fad | 7f5c92709372e4039bff51e0b9ad20acd52a18f5 | /Linked lists/main.cpp | d7d70d448fce2b733d35c43ff356feb5932054a1 | [] | no_license | alvisgage/Cpp-Projects | 6788f50fdcd863e5f5d71c11f0acf2f03dfa796e | 5ea211cd44b8360f2301f73754896afa8af36b38 | refs/heads/master | 2016-08-07T05:55:36.370207 | 2015-05-14T16:40:43 | 2015-05-14T16:40:43 | 35,622,898 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 269 | cpp | /*
* File: main.cpp
* Author: Rage Gage
*
* Created on September 30, 2012, 6:13 PM
*/
#include <cstdlib>
#include "node.h"
#include <iostream>
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
node linked;
return 0;
}
| [
"rga001@uark.edu"
] | rga001@uark.edu |
40385b4ee2abe5bbc84da19eea75084928c3b4fb | cf2d08ceb1dd93a437f9802906b83e1d0635d103 | /src/UI/VideoPlayer.cpp | b4524ec88eca7af7c8ba2b79c0e2d6bfb0884b23 | [
"Apache-2.0"
] | permissive | kousoz80/Salmon | 6e761f946dbd95da3b7ad9514846c56fe6c158a9 | 4bd0ede1b8c299cde39680019a10410638c07f31 | refs/heads/master | 2020-12-14T17:43:15.044068 | 2018-09-17T10:56:35 | 2018-09-17T10:56:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,454 | cpp | /*
* Copyright 2017 PG_MANA
*
* This software is Licensed under the Apache License Version 2.0
* See LICENSE.md
*
* VideoPlayer クラス
* 動画をを再生する。Phonon依存している
*/
#include "VideoPlayer.h"
#include "../Salmon.h"
#include <QtWidgets>
#ifdef NO_PHONON
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <QVideoWidget>
#else
#include <phonon/VideoPlayer>
#endif
VideoPlayer::VideoPlayer ( TwitterJson::TweetData* twdata, QWidget* parent, Qt::WindowFlags f ) :QWidget ( parent,f ) {
if ( twdata == nullptr || twdata->media_info == nullptr ) return;
media_data = *twdata->media_info;//消されてもいいように
QVBoxLayout *main_layout = new QVBoxLayout ( this );
#ifdef NO_PHONON
video_player = new QMediaPlayer;
QVideoWidget *video_widget = new QVideoWidget;
video_player->setMedia ( QUrl ( media_data.video_url ) ); //先に読んでおく
video_player->setVideoOutput ( video_widget );
main_layout->addWidget ( video_widget );
#else
video_player = new Phonon::VideoPlayer ( Phonon::VideoCategory );
video_player->load ( QUrl ( media_data.video_url ) );//先に読んでおく
connect ( video_player,&Phonon::VideoPlayer::finished,video_player,static_cast<void ( Phonon::VideoPlayer::* ) ( void ) > ( &Phonon::VideoPlayer::play ) ); //Loop
main_layout->addWidget ( video_player );
#endif
//ボタン作成
createButtons ( main_layout );
setWindowTitle ( tr ( "動画 " ) + APP_NAME );
setAttribute ( Qt::WA_DeleteOnClose );
}
/*
* 引数:なし
* 戻値:なし
* 概要:表示と同時に再生する。
*/
void VideoPlayer::show() {
QWidget::show();
video_player->play();
return;
}
/*
* 引数:main_layout(格納するレイアウト)
* 戻値:なし
* 概要:ボタンをを作って設定する。ウィンドウ初期化用。
*/
void VideoPlayer::createButtons ( QVBoxLayout* main_layout ) {
QHBoxLayout *button_layout = new QHBoxLayout;
QPushButton *start = new QPushButton ( tr ( "再生(&S)" ) );
QPushButton *pause = new QPushButton ( tr ( "一時停止(&P)" ) );
QPushButton *back = new QPushButton ( tr ( "最初に戻る(&B)" ) ); //最初に戻る
QPushButton *close = new QPushButton ( tr ( "閉じる(&C)" ) );
start->setIcon ( style()->standardIcon ( QStyle::SP_MediaPlay ) );
pause->setIcon ( style()->standardIcon ( QStyle::SP_MediaPause ) );
back->setIcon ( style()->standardIcon ( QStyle::SP_MediaSkipBackward ) );
close->setIcon ( style()->standardIcon ( QStyle::SP_TitleBarCloseButton ) );
#ifdef NO_PHONON
connect ( start,&QPushButton::clicked,video_player,&QMediaPlayer::play );
connect ( pause,&QPushButton::clicked,video_player,&QMediaPlayer::pause );
connect ( back,&QPushButton::clicked,video_player,&QMediaPlayer::position );
#else
connect ( start,&QPushButton::clicked,video_player,static_cast<void ( Phonon::VideoPlayer::* ) ( void ) > ( &Phonon::VideoPlayer::play ) );
connect ( pause,&QPushButton::clicked,video_player,&Phonon::VideoPlayer::pause );
connect ( back,&QPushButton::clicked,video_player,&Phonon::VideoPlayer::seek );
#endif
connect ( close,&QPushButton::clicked,this,&QWidget::close );
button_layout->addWidget ( start );
button_layout->addWidget ( pause );
button_layout->addWidget ( back );
button_layout->addWidget ( close );
main_layout->addLayout ( button_layout );
return;
}
| [
"pg_mana@taprix.org"
] | pg_mana@taprix.org |
84850cd2fac3d37f5e343d11bffa4b3d27765927 | 786de89be635eb21295070a6a3452f3a7fe6712c | /pytopsana/tags/V00-00-02/src/Detector.cpp | ba8ec6b67598e0209fcace707a7800d016ad2ceb | [] | no_license | connectthefuture/psdmrepo | 85267cfe8d54564f99e17035efe931077c8f7a37 | f32870a987a7493e7bf0f0a5c1712a5a030ef199 | refs/heads/master | 2021-01-13T03:26:35.494026 | 2015-09-03T22:22:11 | 2015-09-03T22:22:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,178 | cpp | //-----------------------
// This Class's Header --
//-----------------------
#include "pytopsana/Detector.h"
//-----------------
// C/C++ Headers --
//-----------------
#include <algorithm> // for fill_n
#include <sstream> // for stringstream
//-------------------------------
// Collaborating Class Headers --
//-------------------------------
#include "MsgLogger/MsgLogger.h"
// to work with detector data include corresponding
// header from psddl_psana package
#include "PSEvt/EventId.h"
#include "PSEvt/Source.h"
#include "psddl_psana/pnccd.ddl.h"
#include "PSCalib/CalibParsStore.h"
//-------------------
namespace pytopsana {
typedef Detector::data_t data_t;
typedef data_t TOUT;
const static size_t Segs = 4;
const static size_t Rows = 512;
const static size_t Cols = 512;
const static size_t FrSize = Rows*Cols;
const static size_t Size = Segs*Rows*Cols;
//----------------
// Constructors --
//----------------
Detector::Detector (const PSEvt::Source& source, const unsigned& prbits)
: m_calibpars(0)
, m_source(source)
, m_runnum(-1)
, m_prbits(prbits)
, m_nda_prod(0)
{
std::stringstream ss; ss << source;
m_str_src = ss.str();
m_dettype = ImgAlgos::detectorTypeForSource(m_source);
m_cgroup = ImgAlgos::calibGroupForDetType(m_dettype); // for ex: "PNCCD::CalibV1";
if(m_prbits) {
std::stringstream ss;
ss << "in ctor:" // "SOURCE: " << m_source
<< "\nData source : " << m_str_src
<< "\nCalib group : " << m_cgroup
<< "\nPrint bits : " << m_prbits
<< '\n';
MsgLog(_name_(), info, ss.str());
}
}
//--------------
// Destructor --
//--------------
Detector::~Detector ()
{
// Does nothing for now
}
//-------------------
ndarray<const Detector::pedestals_t, 1> Detector::pedestals(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initCalibStore(*shp_evt, *shp_env);
//ndarray<TOUT, 3> ndarr = make_ndarray<TOUT>(Segs, Rows, Cols);
//std::fill_n(&ndarr[0][0][0], int(Size), TOUT(5));
//return ndarr;
//ndarray<const Detector::pedestals_t, 1> nda = make_ndarray(m_calibpars->pedestals(), m_calibpars->size());
return make_ndarray(m_calibpars->pedestals(), m_calibpars->size());
}
//-------------------
ndarray<const Detector::pixel_rms_t, 1> Detector::pixel_rms(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initCalibStore(*shp_evt, *shp_env);
return make_ndarray(m_calibpars->pixel_rms(), m_calibpars->size());
}
//-------------------
ndarray<const Detector::pixel_gain_t, 1> Detector::pixel_gain(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initCalibStore(*shp_evt, *shp_env);
return make_ndarray(m_calibpars->pixel_gain(), m_calibpars->size());
}
//-------------------
ndarray<const Detector::pixel_mask_t, 1> Detector::pixel_mask(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initCalibStore(*shp_evt, *shp_env);
return make_ndarray(m_calibpars->pixel_mask(), m_calibpars->size());
}
//-------------------
ndarray<const Detector::pixel_bkgd_t, 1> Detector::pixel_bkgd(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initCalibStore(*shp_evt, *shp_env);
return make_ndarray(m_calibpars->pixel_bkgd(), m_calibpars->size());
}
//-------------------
ndarray<const Detector::pixel_status_t, 1> Detector::pixel_status(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initCalibStore(*shp_evt, *shp_env);
return make_ndarray(m_calibpars->pixel_status(), m_calibpars->size());
}
//-------------------
ndarray<const Detector::common_mode_t, 1> Detector::common_mode(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initCalibStore(*shp_evt, *shp_env);
//std::cout << "TEST cm[0]: " << m_calibpars->common_mode()[0] << "\n";
//std::cout << "TEST cm[3]: " << m_calibpars->common_mode()[3] << "\n";
//std::cout << "TEST size: " << m_calibpars->size(PSCalib::COMMON_MODE) << "\n";
return make_ndarray(m_calibpars->common_mode(), m_calibpars->size(PSCalib::COMMON_MODE));
}
//-------------------
void
Detector::initCalibStore(PSEvt::Event& evt, PSEnv::Env& env)
{
int runnum = ImgAlgos::getRunNumber(evt);
if(runnum == m_runnum) return;
m_runnum = runnum;
if(m_calibpars) delete m_calibpars;
//std::string calib_dir = (m_calibDir == "") ? env.calibDir() : m_calibDir;
std::string calibdir = env.calibDir();
if(m_prbits) {
std::stringstream ss;
ss << "in initCalibStore(...):"
<< "\nInstrument : " << env.instrument()
<< "\nCalib dir : " << calibdir
<< "\nCalib group : " << m_cgroup
<< "\nData source : " << m_str_src
<< "\nRun number : " << m_runnum
<< "\nPrint bits : " << m_prbits
<< '\n';
MsgLog(_name_(), info, ss.str());
}
m_calibpars = PSCalib::CalibParsStore::Create(calibdir, m_cgroup, m_str_src, m_runnum, m_prbits);
//m_peds_data = (m_do_peds) ? m_calibpars->pedestals() : 0;
//m_gain_data = (m_do_gain) ? m_calibpars->pixel_gain() : 0;
//m_cmod_data = (m_do_cmod) ? m_calibpars->common_mode() : 0;
//m_rms_data = (m_do_nrms) ? m_calibpars->pixel_rms() : 0;
//m_stat_data = (m_do_stat || m_do_cmod) ? m_calibpars->pixel_status() : 0;
}
//-------------------
//-------------------
//-------------------
//-------------------
void
Detector::initNDArrProducer(const PSEvt::Source& source)
{
//if(!m_nda_prod) m_nda_prod = new NDArrProducerCSPAD(source); // direct access
if(!m_nda_prod) m_nda_prod = NDArrProducerStore::Create(source); // universal access through the factory store
}
//-------------------
//-------------------
ndarray<const int16_t, 1> Detector::data_int16_1(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initNDArrProducer(m_source);
return m_nda_prod->data_nda_int16_1(*shp_evt, *shp_env);
}
//-------------------
ndarray<const int16_t, 2> Detector::data_int16_2(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initNDArrProducer(m_source);
return m_nda_prod->data_nda_int16_2(*shp_evt, *shp_env);
}
//-------------------
ndarray<const int16_t, 3> Detector::data_int16_3(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initNDArrProducer(m_source);
//return m_nda_prod->getNDArr(*shp_evt, *shp_env);
return m_nda_prod->data_nda_int16_3(*shp_evt, *shp_env);
}
//-------------------
ndarray<const int16_t, 4> Detector::data_int16_4(boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
initNDArrProducer(m_source);
return m_nda_prod->data_nda_int16_4(*shp_evt, *shp_env);
}
//-------------------
//-------------------
//-------------------
//-------------------
//-------------------
//-------------------
//-------------------
//-------------------
// Return 3D NDarray of raw detector data
ndarray<data_t,3> Detector::raw(PSEvt::Source source, boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
std::cout << "SOURCE: " << source << std::endl;
std::cout << "ENV: " << shp_env->instrument() << std::endl;
boost::shared_ptr<Psana::PNCCD::FramesV1> frames1 = shp_evt->get(source);
ndarray<TOUT, 3> out_ndarr = make_ndarray<TOUT>(Segs,Rows,Cols);
if (frames1) {
ndarray<TOUT, 3>::iterator it_out = out_ndarr.begin();
for (unsigned i = 0 ; i != frames1->numLinks(); ++ i) {
const Psana::PNCCD::FrameV1& frame = frames1->frame(i);
const ndarray<const data_t, 2> data = frame.data();
// Copy frame from data to output ndarray with changing type
for ( ndarray<const data_t, 2>::iterator it=data.begin(); it!=data.end(); ++it, ++it_out) {
*it_out = (TOUT)*it;
}
}
}
return out_ndarr;
}
//-------------------
// Return 3D NDarray of calibrated detector data
ndarray<double,3> Detector::calib(PSEvt::Source source, boost::shared_ptr<PSEvt::Event> shp_evt, boost::shared_ptr<PSEnv::Env> shp_env)
{
ndarray<data_t,3> raw_data = this->raw(source,shp_evt,shp_env);
ndarray<double,3> calib_data = this->calib(raw_data);
return calib_data;
}
//-------------------
ndarray<double,3> Detector::calib(ndarray<data_t,3> raw_data)
{
// For now, just return a double version of raw_data
// Create the calib_data array
ndarray<double,3> calib_data = make_ndarray<double>(Segs,Rows,Cols);
// Set up iterator to calib_data
ndarray<double,3>::iterator calib_it = calib_data.begin();
// Loop over raw_data and copy value as double into calib_data
for (ndarray<data_t,3>::iterator raw_it = raw_data.begin();
raw_it != raw_data.end(); raw_it++,calib_it++) {
*calib_it = (double) *raw_it;
}
// return calib_data
return calib_data;
}
std::string Detector::str_inst(boost::shared_ptr<PSEnv::Env> shp_env)
{
return shp_env->instrument().c_str();
}
//-------------------
} // namespace pytopsana
//-------------------
| [
"dubrovin@SLAC.STANFORD.EDU@b967ad99-d558-0410-b138-e0f6c56caec7"
] | dubrovin@SLAC.STANFORD.EDU@b967ad99-d558-0410-b138-e0f6c56caec7 |
c732ed337c7b7e70ff95de675c8aecb3de644393 | 6f8f253b448271820d82e3aa0ff2b15737a49afb | /qiwei/self_defined_function/factorization_free_solver/codegen/lib/get_inverse/inv.cpp | 28ff24adf814985375aa0d06c0a2168cbf97d9e1 | [] | no_license | qzhang41/2019-summer-BDI | 7c1eee397a67284fffa1c0d9852735ca9c33aae1 | 9474d84897608f2825cb1b5a3fee5107c4f46e92 | refs/heads/master | 2020-06-13T17:11:23.277131 | 2019-07-01T18:54:44 | 2019-07-01T18:54:44 | 194,726,935 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,784 | cpp | //
// Academic License - for use in teaching, academic research, and meeting
// course requirements at degree granting institutions only. Not for
// government, commercial, or other organizational use.
// File: inv.cpp
//
// MATLAB Coder version : 4.1
// C/C++ source code generated on : 01-Mar-2019 11:25:12
//
// Include Files
#include "get_inverse.h"
#include "inv.h"
#include "xtrsm.h"
#include "xgetrf.h"
// Function Declarations
static void eml_ipiv2perm(const int ipiv[1000], int perm[1000]);
// Function Definitions
//
// Arguments : const int ipiv[1000]
// int perm[1000]
// Return Type : void
//
static void eml_ipiv2perm(const int ipiv[1000], int perm[1000])
{
int k;
int pipk;
for (k = 0; k < 1000; k++) {
perm[k] = 1 + k;
}
for (k = 0; k < 999; k++) {
if (ipiv[k] > 1 + k) {
pipk = perm[ipiv[k] - 1];
perm[ipiv[k] - 1] = perm[k];
perm[k] = pipk;
}
}
}
//
// Arguments : const double x[1000000]
// double y[1000000]
// Return Type : void
//
void invNxN(const double x[1000000], double y[1000000])
{
int i0;
static double b_x[1000000];
int ipiv[1000];
int p[1000];
int k;
int j;
int i1;
int i;
for (i0 = 0; i0 < 1000000; i0++) {
y[i0] = 0.0;
b_x[i0] = x[i0];
}
xgetrf(b_x, ipiv);
eml_ipiv2perm(ipiv, p);
for (k = 0; k < 1000; k++) {
i0 = p[k];
y[k + 1000 * (p[k] - 1)] = 1.0;
for (j = k + 1; j < 1001; j++) {
if (y[(j + 1000 * (i0 - 1)) - 1] != 0.0) {
i1 = j + 1;
for (i = i1; i < 1001; i++) {
y[(i + 1000 * (i0 - 1)) - 1] -= y[(j + 1000 * (i0 - 1)) - 1] * b_x[(i
+ 1000 * (j - 1)) - 1];
}
}
}
}
xtrsm(b_x, y);
}
//
// File trailer for inv.cpp
//
// [EOF]
//
| [
"qzhang41@vols.utk.edu"
] | qzhang41@vols.utk.edu |
b5dbd40032aafea96ebee7a77f026e6782c5dbb6 | b22588340d7925b614a735bbbde1b351ad657ffc | /athena/InnerDetector/InDetConditions/SCT_ConditionsServices/src/SCT_ModuleVetoTestAlg.h | 9dd1a259a5c32c20bd284bacefa423c5e8757260 | [] | no_license | rushioda/PIXELVALID_athena | 90befe12042c1249cbb3655dde1428bb9b9a42ce | 22df23187ef85e9c3120122c8375ea0e7d8ea440 | refs/heads/master | 2020-12-14T22:01:15.365949 | 2020-01-19T03:59:35 | 2020-01-19T03:59:35 | 234,836,993 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 965 | h | /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file SCT_ModuleVetoTestAlg.h
*
* @brief Header file for the SCT_ModuleVetoTestAlg class
* in package SCT_ConditionsServices
*
* @author Shaun Roe
**/
#ifndef SCT_ModuleVetoTestAlg_H
#define SCT_ModuleVetoTestAlg_H
//STL
#include <string>
//Gaudi
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ServiceHandle.h"
//Local
#include "SCT_ConditionsServices/ISCT_ConditionsSvc.h"
//Forward declarations
class ISvcLocator;
class StatusCode;
///Example algorithm to show calling the SCT_ModuleVeto to exclude bad components
class SCT_ModuleVetoTestAlg : public AthAlgorithm {
public:
SCT_ModuleVetoTestAlg(const std::string &name,ISvcLocator *pSvcLocator) ;
~SCT_ModuleVetoTestAlg();
StatusCode initialize();
StatusCode execute();
StatusCode finalize();
private:
ServiceHandle<ISCT_ConditionsSvc> m_pModuleVetoSvc;
}; //end of class
#endif
| [
"rushioda@lxplus754.cern.ch"
] | rushioda@lxplus754.cern.ch |
b59904c530285697a998950c1285ee06580c3848 | 9b7af32b330c59b5bd14ef1f08b93cbd7be621ef | /src/json_streams.hpp | 0181308e07bc1a9f5727948b532ec88333a0660e | [
"MIT"
] | permissive | djarek/jsonstreams | d15c1b45667459c2a14d102347bcb37aca7bf0d2 | 14c083bfe75e4d1925ba6c0ca9d4ab7d41db94d5 | refs/heads/master | 2021-01-12T15:54:33.682592 | 2016-09-27T05:44:44 | 2016-09-29T22:39:30 | 69,323,399 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,464 | hpp | #include <type_traits>
#include <sstream>
#include <vector>
#include <array>
#include <memory>
#include "../ext/jsmn.h"
namespace JSON {
using String = std::string;
template <typename Container>
struct IsContainer : std::false_type { };
//template <typename... Ts> struct IsContainer<std::list<Ts...>> : std::true_type { };
template <typename... Ts> struct IsContainer<std::vector<Ts...>> : std::true_type { };
template<typename InputType, typename ReturnType>
using EnableIfFundamental = typename std::enable_if<std::is_fundamental<typename std::remove_reference<InputType>::type>::value, ReturnType>::type;
template<typename InputType, typename ReturnType>
using EnableIfContainer = typename std::enable_if<IsContainer<typename std::remove_reference<InputType>::type>::value, ReturnType>::type;
template<typename PointerType>
using EnableIfSharedPointer = typename std::enable_if<std::is_same<PointerType, std::shared_ptr<decltype(*PointerType{})>>::value, PointerType>::type;
//template<typename InputType, typename
template <typename Type>
void prepareStream(std::stringstream&, const Type&) {
}
template <>
void prepareStream<bool>(std::stringstream& stream, const bool&) {
stream << std::boolalpha;
}
template <typename Type>
void prepareIStream(std::stringstream&, const Type&) {
}
template <>
void prepareIStream<bool>(std::stringstream& stream, const bool&) {
auto nextCharacter = stream.peek();
if (stream.good() and nextCharacter != '1' and nextCharacter != '0') {
stream >> std::boolalpha;
} else {
stream >> std::noboolalpha;
}
}
template <typename PointerType>
EnableIfSharedPointer<PointerType> make(PointerType& /*in*/)
{
using PointeeRef = decltype(*PointerType{});
using Pointee = typename std::remove_reference<PointeeRef>::type;
return std::make_shared<Pointee>({});
}
template <typename PointerType>
PointerType make(PointerType& /*in*/)
{
using PointeeRef = decltype(*PointerType{});
using Pointee = typename std::remove_reference<PointeeRef>::type;
return PointerType{new Pointee{}};
}
struct NonCopyable
{
NonCopyable() = default;
NonCopyable(const NonCopyable&) = delete;
NonCopyable(NonCopyable&&) = delete;
};
struct NonMovable
{
NonMovable() = default;
NonMovable& operator =(const NonMovable&) = delete;
NonMovable& operator =(NonMovable&&) = delete;
};
class InputStream
{
public:
enum ParseError
{
SUCCESS = 0,
MALFORMED_JSON,
INVALID_TOKEN_TYPE,
INVALID_VALUE
};
private:
using TokenVector = std::vector<jsmntok_t>;
std::stringstream data;
TokenVector tokens{};
TokenVector::iterator currentToken{tokens.end()};
ParseError lastError{};
public:
explicit InputStream(const String& input) : data{input}
{
jsmn_parser parser;
jsmn_init(&parser);
auto tokenCount = jsmn_parse(&parser, input.c_str(), input.size(), nullptr, 0);
if (tokenCount > 0) {
tokens.resize(tokenCount);
jsmn_init(&parser);
jsmn_parse(&parser, input.c_str(), input.size(), tokens.data(), tokens.size());
currentToken = tokens.begin();
} else {
lastError = MALFORMED_JSON;
}
}
const jsmntype_t& peekToken() const {
return currentToken->type;
}
bool skipToken() {
++currentToken;
return currentToken != tokens.end();
}
template <typename InputType>
auto operator >> (InputType& in) -> decltype(*in, in = nullptr, *this)& {
if (not good()) {
return *this;
}
if (currentToken->type == JSMN_PRIMITIVE) {
std::array<char, 4> buffer{};
data.seekg(currentToken->start, data.beg);
data.readsome(buffer.begin(), buffer.size());
if (not data.good()) {
lastError = INVALID_VALUE;
return *this;
}
constexpr static std::array<char, 4> NULL_STRING {'n', 'u', 'l', 'l'};
if (buffer == NULL_STRING) {
in = nullptr;
++currentToken;
} else {
data.seekg(currentToken->start, data.beg);
in = JSON::make(in); // explicitly take the make from JSON namespace to prevent collisions
*this >> *in;
}
} else {
in = JSON::make(in);
*this >> *in;
}
return *this;
}
template <typename InputType>
EnableIfFundamental<InputType, InputStream>& operator >>(InputType& in) {
if (not good()) {
return *this;
}
if (currentToken->type != JSMN_PRIMITIVE) {
lastError = INVALID_TOKEN_TYPE;
return *this;
}
data.seekg(currentToken->start, data.beg);
prepareIStream(data, in);
data >> in;
if (data.fail() or data.bad()) {
lastError = INVALID_VALUE;
return *this;
}
currentToken++;
return *this;
}
InputStream& operator >>(String& in) {
if (not good()) {
return *this;
}
if (currentToken->type != JSMN_STRING) {
lastError = INVALID_TOKEN_TYPE;
return *this;
}
data.seekg(currentToken->start, data.beg);
auto size = currentToken->end - currentToken->start;
in.resize(size);
data.readsome(&in[0], size);
if (data.fail() or data.bad()) {
lastError = INVALID_VALUE;
return *this;
}
currentToken++;
return *this;
}
template<typename Container>
auto reserve(Container& container, size_t n) -> decltype(container.reserve(n))
{
container.reserve(n);
}
template<typename InputType>
EnableIfContainer<InputType, InputStream>& operator >> (InputType& in) {
if (not good()) {
return *this;
}
if (currentToken->type != JSMN_ARRAY) {
lastError = INVALID_TOKEN_TYPE;
return *this;
}
reserve(in, currentToken->size);
auto size = currentToken->size;
skipToken();
for (int i = 0; i < size; ++i) {
if (not good()) {
return *this;
}
in.push_back({});
*this >> in.back();
if (fail() or bad()) {
in.pop_back();
}
}
return *this;
}
bool eof() const {
return currentToken >= tokens.end();
}
bool bad() const {
return lastError == MALFORMED_JSON or lastError == INVALID_TOKEN_TYPE;
}
bool fail() const {
return lastError == MALFORMED_JSON or lastError == INVALID_VALUE;
}
bool good() const {
return currentToken < tokens.end() and lastError == SUCCESS;
}
bool expectToken(jsmntype_t type) {
if (not good()) {
return false;
}
if (currentToken->type != type) {
lastError = INVALID_TOKEN_TYPE;
return false;
}
return true;
}
int childrenCount() const {
return currentToken->size;
}
};
class OutputStream
{
std::stringstream stream{};
template<typename FundamentalType>
EnableIfFundamental<FundamentalType, OutputStream&>& operator <<(const FundamentalType& out) {
prepareStream(stream, out);
stream << out;
return *this;
}
OutputStream& operator <<(const String& out) {
stream << "\"" << out << "\"";
return *this;
}
public:
template<typename ContainerType>
EnableIfContainer<ContainerType, OutputStream>& operator <<(const ContainerType& container) {
stream << "[";
for (const auto& out : container) {
*this << out;
stream << ",";
}
if (not container.empty()) {
stream.seekp(-1, stream.end);
}
stream << "]";
return *this;
}
String str() const {
return stream.str();
}
template<typename OutputType>
struct Pair
{
const String key;
const OutputType& value;
};
class ObjectSentry : private NonCopyable, private NonMovable
{
OutputStream& jsonStream;
bool filled{};
public:
ObjectSentry(OutputStream& stream) : jsonStream{stream} {
stream.stream << "{";
}
template<typename OutputType>
ObjectSentry& operator <<(Pair<OutputType> out) {
jsonStream << out.key;
jsonStream.stream << ":";
jsonStream << out.value;
jsonStream.stream << ",";
filled = true;
return *this;
}
~ObjectSentry() {
if (filled) {
jsonStream.stream.seekp(-1, jsonStream.stream.end); //overwrite trailing comma
}
jsonStream.stream << "}";
}
};
class ArraySentry : private NonCopyable, private NonMovable
{
OutputStream& jsonStream;
bool filled{};
public:
ArraySentry(OutputStream& stream) : jsonStream{stream} {
stream.stream << "[";
}
template<typename OutputType>
ArraySentry& operator <<(const OutputType& out) {
jsonStream << out;
jsonStream.stream << ",";
filled = true;
return *this;
}
~ArraySentry() {
if (filled) {
jsonStream.stream.seekp(-1, jsonStream.stream.end); //overwrite trailing comma
}
jsonStream.stream << "]";
}
};
friend std::ostream& operator <<(std::ostream& ostream, const OutputStream& jsonStream){
ostream << jsonStream.stream.rdbuf();
return ostream;
}
};
template<typename ValueType>
OutputStream::Pair<ValueType> makePair(String key, const ValueType& value) {
return {move(key), value};
}
}
| [
"damian.jarek93@gmail.com"
] | damian.jarek93@gmail.com |
534c41b63726a015d9c33820d9e33dc4c26c5ec9 | d5770a25afd37d0a7bb56f9e19a2e95ccc029ef5 | /NowCoder/牛牛的“质因数”.cpp | 591f0c3c026d7329d54ab7699086237e908a9056 | [] | no_license | Falcone-H/Algorithm | 13861708ba7d8515081578c26a63e08b6b7688f4 | 156f830db237b03a69ae10d857468e5cbe80ca61 | refs/heads/master | 2023-08-16T14:10:17.992239 | 2021-09-23T14:49:23 | 2021-09-23T14:49:23 | 298,321,857 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,100 | cpp | // https://ac.nowcoder.com/acm/contest/9982/I
// 思路:利用埃氏筛,寻找每个数的最大质因数,然后将最大质因数合并到原来的值后面
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 4000005;
const int mod = 1e9 + 7;
bool is_pri[MAXN];
int f[MAXN];
void sieve(int n)
{
for (int i = 0; i <= n; i++)
is_pri[i] = true;
is_pri[0] = 0;
is_pri[1] = 0;
for (int i = 2; i <= n; i++)
{
if (is_pri[i])
{
f[i] = i;
for (int j = 2 * i; j <= n; j += i)
{
is_pri[j] = false;
int temp = 10;
while (f[i] / temp != 0)
{
temp *= 10;
}
f[j] = (f[j / i] * temp % mod + f[i]) % mod;
}
}
}
}
signed main()
{
int n;
cin >> n;
sieve(n);
int ans = 0;
for (int i = 2; i <= n; i++)
{
ans = (ans + f[i]) % mod;
}
cout << ans << endl;
return 0;
} | [
"james_bond1@163.com"
] | james_bond1@163.com |
bb78f61a2f1ccbb74cec7ea700e0a0c46b879e3f | 14a0a0f1ce738cfa66e090d497a25576780a642f | /item/mytextitem.h | 168fb6e7badf032c00faf28e0d07c1b3238b91e2 | [] | no_license | xibeilang524/Graphics | 155002bdc2b063cb89d9e651a2fcb606899ff7f7 | cae0e22697b370151148ba2101e71cf02b7c7cff | refs/heads/devport | 2021-07-16T14:38:34.210460 | 2017-03-31T03:41:28 | 2017-03-31T03:41:28 | 108,335,006 | 6 | 4 | null | 2017-10-25T22:55:05 | 2017-10-25T22:55:05 | null | GB18030 | C++ | false | false | 2,191 | h | /*************************************************
**版 权:RenGu Company
**文件名: mytextitem.h
**作 者: wey Version: 1.0 Date: 2016.09.06
**描 述: 自定义文字控件
**Others: 1:支持文字的双击编辑
** 2:支持样式的设定,如文字字体的格式
**
**修改历史:
**20160921:wey:修复输入文字无法换行问题
** 添加文字初始信息提示并选中状态
**20160927:wey:修复QFontMetrics计算多行文本不正确问题
*************************************************/
#ifndef MYTEXTITEM_H
#define MYTEXTITEM_H
#include <QGraphicsTextItem>
#include <QObject>
#include <QDataStream>
#include "../Header.h"
class MyTextItem : public QGraphicsTextItem
{
Q_OBJECT
public:
MyTextItem(GraphicsType itemType,QGraphicsItem *parent2 = 0, QGraphicsScene *scene = 0);
~MyTextItem();
void setProperty(ItemProperty property);
ItemProperty getProperty(){return this->property;}
void updateFont(QFont font);
void cleartText();
GraphicsType getType(){return this->type;}
void setTextExistType(TextExistType type);
TextExistType getTextExistType(){return this->existType;}
void setZValue(qreal z);
void setPos(const QPointF &pos);
void setPos(qreal x, qreal y);
void setCentralPos(QPointF pos);
QString getText();
void setText(QString text);
void setMoveable(bool lockState);
bool isMoveable(){return this->property.isMoveable;}
QRectF getBoundRect();
friend QDataStream & operator <<(QDataStream &,MyTextItem * item);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
signals:
void textLostFocus(MyTextItem *item);
void posHasChanged(MyRect);
void updateTextGeometry();
protected:
void focusOutEvent(QFocusEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
void keyPressEvent(QKeyEvent *event);
private:
GraphicsType type;
ItemProperty property;
TextExistType existType;
QPixmap pixmap;
};
#endif // MYTEXTITEM_H
| [
"wey580231@live.com"
] | wey580231@live.com |
c848ec51e5d7ecc15c0fc32c043f94246136ce4e | 45a9b0e87bd6088fa53cf6a7faf26d0693f0a509 | /Linked-List/List.cpp | afe7a0ac5d80cdeeac55b65cc1f504b1aa632b02 | [] | no_license | sllujaan/Liked-List_cpp | 47338d486ab855f98b69d84fb1ef207c3c96d36d | f00ffebde5ddc44c35d3e421c70479b5eb11be43 | refs/heads/master | 2022-10-19T19:31:41.847580 | 2020-06-06T09:40:30 | 2020-06-06T09:40:30 | 269,019,011 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,666 | cpp | #include"List.h"
#include<iostream>
using namespace std;
template<typename T, typename U>
void List<T, U>::initValues(U parm)
{
Node<U>* node = new Node<U>(1);
node->value = parm;
this->rearNode = node;
this->currentNode = this->rearNode;
this->prevNode = this->rearNode;
this->nextNode = this->rearNode;
this->rearNode = this->rearNode;
this->frontNode = this->rearNode;
cout << "allocated memory address = " << node << endl;
this->length = 0;
this->length++;
}
template<typename T, typename U>
List<T, U>::List(U parm)
{
this->initValues(parm);
}
template<typename T, typename U>
List<T, U>::~List()
{
cout << "destructor called." << endl;
this->initDeleteAll();
}
template<typename T, typename U>
template<size_t size>
inline List<T, U>::List(U (&arr)[size])
{
cout << "size = " << size << endl;
this->initValues(arr[0]);
for (size_t i = 1; i < size; i++)
{
this->add(arr[i]);
}
}
template<typename T, typename U>
template<size_t size>
void List<T, U>::add(U (&arr)[size])
{
for (size_t i = 0; i < size; i++)
{
this->add(arr[i]);
}
}
template<typename T, typename U>
void List<T, U>::add(U parm)
{
Node<U>* newNode = new Node<U>(1);
newNode->value = parm;
this->prevNode = this->currentNode;
this->currentNode = newNode;
this->prevNode->nextNode = this->currentNode;
this->currentNode->prevNode = this->prevNode;
this->nextNode = this->currentNode;
this->frontNode = this->currentNode;
this->length++;
cout << "allocated memory address = " << newNode << endl;
}
template<typename T, typename U>
U List<T, U>::remove(size_t index)
{
if ((index > 0) && (index <= this->length)) {
return U;
}
return U;
}
template<typename T, typename U>
U List<T, U>::removeCurrent()
{
T* nodeToDelete = this->currentNode;
U value = nodeToDelete->value;
this->prevNode->nextNode = this->nextNode;
if (this->nextNode) {
this->nextNode->prevNode = this->prevNode;
this->currentNode = this->nextNode;
}
else {
this->currentNode = this->prevNode;
cout << "deleting memory...>>>" << nodeToDelete << endl;
delete[] nodeToDelete;
}
--this->length;
return value;
}
template<typename T, typename U>
void List<T, U>::removeAll()
{
cout << "removeAll called." << endl;
this->initDeleteAll();
}
template<typename T, typename U>
void List<T, U>::initDeleteAll()
{
this->currentNode = this->rearNode;
for (size_t i = 0; i < this->length; i++)
{
T* nodeToDelete = this->currentNode;
if (this->currentNode->nextNode) { this->currentNode = this->currentNode->nextNode; }
cout << "deleting memory..." << nodeToDelete << endl;
delete[] nodeToDelete;
}
this->length = 0;
}
| [
"sllujaan44@gmail.com"
] | sllujaan44@gmail.com |
55492adecb60a1c1dd9e3bdfc604ba71f97a0490 | 7e9f6ef27323546e150402e05f96148a0f72482a | /1_個人制作作品/ソースフォルダ/game/source/担当コード/Control.h | 5d061e1846bcc0bb4fd8524edab721739415a985 | [] | no_license | KamitaniTakafumi/MyWrok | 88a67c408ce5c5c412097f8b95141e0c2120b858 | 5ea639e6686b399d3baa8329ad112c551928939f | refs/heads/master | 2023-01-31T08:54:09.654979 | 2020-12-14T02:50:25 | 2020-12-14T02:50:25 | 302,220,596 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,771 | h | /**
* @file Control.h
* @brief コントロール処理
* @author 上谷恭史
* @date 2020 / 08 / 25
*/
#pragma once
#include "appframe.h"
#include "Player.h"
#include "Item.h"
namespace act {
class Control {
private:
std::unique_ptr<Player> player;
std::vector<std::shared_ptr<Item>> itemvec;
public:
/**
* コントロールコンストラクタ
*/
Control();
/**
* コントロールデストラクタ
*/
virtual ~Control() = default;
/**
* コントロール初期化
*/
void Initialize();
/**
* 移動処理
* @param key 押された瞬間の判定
* @param trg 押されっぱなしの判定
*/
void Move(int key, int trg);
/**
* ゲッター(プレイヤー座標)
* @param x プレイヤーx座標
* @param y プレイヤーy座標
*/
void GetPlayerPosition(double* x, double* y);
/**
* ゲッター(アイテム座標)
* @param index 添え字
* @param x アイテムx座標
* @param y アイテムy座標
*/
void GetItemPosition(int index, double* x, double* y);
/**
* 全ての当たり判定
*/
void CollisionAll();
/**
* プレイヤーの体力チェック
*/
bool CheckPlayerHP() { if (player->GetHP() == 0) { return true; } return false; }
/**
* プレイヤーの体力取得
*/
int GetPlayerHP() { return player->GetHP(); }
/**
* 描画処理
*/
void Draw();
private:
/**
* オブジェクト1とオブジェクト2の当たり判定
* @param c1 半径1
* @param c2 半径2
* @param cx1 x座標1
* @param cx2 x座標2
* @param cy1 y座標1
* @param cy2 y座標2
*/
bool CircleCollision(double c1, double c2, double cx1, double cx2, double cy1, double cy2);
};
}
| [
"119pg1004@tokyo.amg.ac.jp"
] | 119pg1004@tokyo.amg.ac.jp |
b3ff6f92a660670b8216e7c11ee3c01fbc853629 | 13452a2b7f5a275c6997e7a96e5b500966956ad2 | /src/icp/controller/mapscene.cpp | 772fb44ce391defe44945166cf3c2e0df93bd2d4 | [] | no_license | PavlovicAndrej/ICP | d9fd103c52c977deeb151ba5f890878cb971e16b | 2015ee18baddfaf81312c29626ce081cd8fc0761 | refs/heads/master | 2023-02-21T04:02:41.796092 | 2020-09-10T18:11:46 | 2020-09-10T18:11:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 25,793 | cpp | /**
* @file
* @author Andrej Pavlovic <xpavlo14@stud.fit.vutbr.cz>
*
* Implementacia triedy MapScene reprezentujuca cast okna aplikacie zobrazujuceho hlavnu mapu
*/
#include "mapscene.h"
#include <math.h>
#include <QDebug>
#include <QGraphicsSceneMouseEvent>
/** Universal size of pen for MapScene */
#define PEN_SIZE 6 // universal size of items in scene
MapScene::MapScene(QObject *parent) : QGraphicsScene(parent)
{
// pass
}
void MapScene::init(QVector<Road*> roads, DataHolder* model) {
this->model = model;
this->roads = roads;
int x1, x2, y1, y2;
/* roads paint */
for (const auto &road : this->roads){
x1 = road->getStart().x;
x2 = road->getEnd().x;
y1 = road->getStart().y;
y2 = road->getEnd().y;
auto line = addLine(x1, y1, x2, y2);
line->setPen(QPen(Qt::black,PEN_SIZE));
this->roadsItems.append(line);
}
/* stops paint */
for (const auto &road : this->roads) {
x1 = road->getStart().x;
x2 = road->getEnd().x;
y1 = road->getStart().y;
y2 = road->getEnd().y;
QRegExp reg("Z.*");
if ( reg.exactMatch(road->getStart().name)){
addEllipse(x1 - PEN_SIZE, y1 - PEN_SIZE, PEN_SIZE * 2, PEN_SIZE * 2, QPen(Qt::darkBlue), Qt::blue);
}
if ( reg.exactMatch(road->getEnd().name)){
addEllipse(x2 - PEN_SIZE, y2 - PEN_SIZE, PEN_SIZE * 2, PEN_SIZE * 2, QPen(Qt::darkBlue), Qt::blue);
}
}
}
void MapScene::updateMap() {
// removes not up to date buses from last update
for ( const auto &item: this->activeBusesItems ) {
removeItem(item);
delete item;
}
activeBusesItems.clear();
int x, y;
/* actaul buses symbols paint */
for ( const auto &spoj: this->activeBuses ) {
x = spoj->x;
y = spoj->y;
if ( spoj->isSelected() ){
activeBusesItems.append(addEllipse(x - PEN_SIZE * 2, y - PEN_SIZE * 2, PEN_SIZE * 4, PEN_SIZE * 4, QPen(Qt::darkBlue), Qt::cyan));
} else {
activeBusesItems.append(addEllipse(x - PEN_SIZE * 2, y - PEN_SIZE * 2, PEN_SIZE * 4, PEN_SIZE * 4, QPen(Qt::black), spoj->getColor()));
}
}
}
void MapScene::mousePressEvent(QGraphicsSceneMouseEvent *event) {
removePreviousEvent();
processActualEvent(event);
updateMap();
// call base class overrides method to take care of some importants of which this override does not
QGraphicsScene::mousePressEvent(event);
}
void MapScene::removePreviousEvent() {
if ( this->lastSelected ) {
if ( this->lastSelected == BUS ) {
for ( auto road : this->lastBus->getConnectionRoadsShort() ) {
this->paintRoad(road);
}
this->lastBus->setSelect(false);
}
if ( this->lastSelected == ROAD ) {
this->lastRoad->setSelect(false);
this->paintRoad(this->lastRoad);
}
this->lastSelected = NOTHING;
}
}
void MapScene::processActualEvent(QGraphicsSceneMouseEvent *event) {
if ( ! items(event->scenePos()).empty() ) {
/* some item was clicked */
QGraphicsItem* item = items(event->scenePos()).first();
if ( this->mode == NORMAL ) {
/* road close mode is off */
if ( item->type() == 6 ) {
/* clicked item is road */
Road* road = roads.at(roadsItems.indexOf(dynamic_cast<QGraphicsLineItem*>(item)));
road->setSelect(true);
this->paintRoad(road);
this->lastSelected = ROAD;
this->lastRoad = road;
if ( std::get<0>(road->getRoadClose()) ) {
emit roadClickedClosed();
}
else {
emit roadClicked(QString::number(road->getTraffic()));
}
if ( std::get<1>(road->getRoadClose()) ) {
emit roadClickedDetour();
}
} else if ( item->type() == 4 && dynamic_cast<QGraphicsEllipseItem*>(item)->rect().height() == PEN_SIZE * 4 ) {
/* clicked item is bus */
Spoj* bus = activeBuses.at(activeBusesItems.indexOf(dynamic_cast<QGraphicsEllipseItem*>(item)));
bus->setSelect(true);
this->lastSelected = BUS;
this->lastBus = bus;
// color bus roads without paintRoad() cause roads are not selected
for ( auto road : bus->getConnectionRoadsShort() ) {
dynamic_cast<QGraphicsLineItem*>(roadsItems.at(roads.indexOf(road)))->setPen(QPen(Qt::cyan,PEN_SIZE));
}
emit busClicked(bus);
}
}
else if ( this->mode == CLOSED ) {
/* road close mode is on */
if ( item->type() == 6 ) {
Road* road = roads.at(roadsItems.indexOf(dynamic_cast<QGraphicsLineItem*>(item)));
if ( std::get<0>(road->getRoadClose()) ) {
/* road already blocked */
this->escapeRoadCloseMode();
emit throwErrorForUser("Nemozno zablokovat jednu cestu viac krat");
return;
}
if ( std::get<1>(road->getRoadClose()) ) {
/* trying to block road that is already detour */
this->escapeRoadCloseMode();
emit throwErrorForUser("Nemozno zablokovat obchadzkovu trasu");
return;
}
QString previousStart;
QString previousEnd;
QString actualStart;
QString actualEnd;
if ( !std::get<0>(closedRoads).isEmpty() ) {
previousStart = std::get<0>(closedRoads).last()->getStartName();
previousEnd = std::get<0>(closedRoads).last()->getEndName();
actualStart = road->getStartName();
actualEnd = road->getEndName();
}
// short-circuit evaluation used to avoid second condition if first road is added
// control if road is connected to last chosed
if ( std::get<0>(closedRoads).isEmpty() || (!previousStart.compare(actualStart) || !previousStart.compare(actualEnd) || !previousEnd.compare(actualStart) || !previousEnd.compare(actualEnd)) ) {
if ( std::get<0>(closedRoads).indexOf(road) < 0 ) {
/* item is selected first time */
road->setRoadClose(std::make_tuple(1, 0));
std::get<0>(closedRoads).append(road);
dynamic_cast<QGraphicsLineItem*>(item)->setPen(QPen(Qt::red,PEN_SIZE));
}
}
else {
/* clicked road is not connected to last clicked */
this->escapeRoadCloseMode();
emit throwErrorForUser("Zvolena cesta sa nespaja s poslednou zvolenou");
return;
}
}
else {
/* clicked somewhere else than road while road close mode is on, exiting road close mode */
this->escapeRoadCloseMode();
return;
}
}
else if ( this->mode == DETOUR ) {
/* road close mode is on */
if ( item->type() == 6 ) {
Road* road = roads.at(roadsItems.indexOf(dynamic_cast<QGraphicsLineItem*>(item)));
QString previousStart;
QString previousEnd;
QString actualStart;
QString actualEnd;
if ( !std::get<1>(closedRoads).isEmpty() ) {
previousStart = std::get<1>(closedRoads).last()->getStartName();
previousEnd = std::get<1>(closedRoads).last()->getEndName();
actualStart = road->getStartName();
actualEnd = road->getEndName();
}
// short-circuit evaluation used to avoid second condition if first road is added
if ( std::get<1>(closedRoads).isEmpty() || (!previousStart.compare(actualStart) || !previousStart.compare(actualEnd) || !previousEnd.compare(actualStart) || !previousEnd.compare(actualEnd)) ) {
if ( std::get<0>(closedRoads).indexOf(road) < 0 && std::get<1>(closedRoads).indexOf(road) < 0 ) {
/* item is selected first time */
road->setRoadClose(std::make_tuple(0, 1));
std::get<1>(closedRoads).append(road);
dynamic_cast<QGraphicsLineItem*>(item)->setPen(QPen(Qt::green,PEN_SIZE));
}
else if ( std::get<1>(closedRoads).indexOf(road) >= 0 ) {
/* clicked road is already selected as detour in actual road closing */
this->escapeRoadCloseMode();
emit throwErrorForUser("Nemozno zvolit cestu ako obchadzku dva krat v jednom uzatvarani ciest");
return;
}
else {
/* if was clicked closed road from actual road closing, nothing happens */
return;
}
}
else {
/* clicked somewhere else than road while road close mode is on, exiting road close mode */
this->escapeRoadCloseMode();
emit throwErrorForUser("Zvolena cesta sa nespaja s poslednou zvolenou");
return;
}
}
else {
/* clicked somewhere else than road while road close mode is on, exiting road close mode */
this->escapeRoadCloseMode();
return;
}
}
}
else {
/* map was clicked */
emit mapClicked();
if ( this->mode == CLOSED || this->mode == DETOUR ) {
/* clicked on map while road close mod is on, exiting road close mode */
this->escapeRoadCloseMode();
return;
}
}
}
void MapScene::roadClose() {
if ( this->mode == NORMAL ) {
/* user confirmed closed roads and chose detour */
// control if any roads was chosen
if ( std::get<1>(this->closedRoads).isEmpty() ) {
this->escapeRoadCloseMode();
emit throwErrorForUser("Je potrebne zvolit minimalne jednu cestu obchadzky");
return;
}
if ( std::get<0>(this->closedRoads).size() == 1 && std::get<1>(this->closedRoads).size() == 1 ) {
this->escapeRoadCloseMode();
emit throwErrorForUser("Nie je mozne vytvorit uzavretie s obchadzkou s menej ako 3 zvolenymi cestami");
return;
}
QString closedFirstStart = std::get<0>(this->closedRoads).first()->getStartName();
QString closedFirstEnd = std::get<0>(this->closedRoads).first()->getEndName();
QString closedLastStart = std::get<0>(this->closedRoads).last()->getStartName();
QString closedLastEnd = std::get<0>(this->closedRoads).last()->getEndName();
QString detourFirstStart = std::get<1>(this->closedRoads).first()->getStartName();
QString detourFirstEnd = std::get<1>(this->closedRoads).first()->getEndName();
QString detourLastStart = std::get<1>(this->closedRoads).last()->getStartName();
QString detourLastEnd = std::get<1>(this->closedRoads).last()->getEndName();
if ( ! (
((!closedFirstStart.compare(detourFirstStart) ||
!closedFirstStart.compare(detourFirstEnd) ||
!closedFirstEnd.compare(detourFirstStart) ||
!closedFirstEnd.compare(detourFirstEnd))
&&
(!closedLastStart.compare(detourLastStart) ||
!closedLastStart.compare(detourLastEnd) ||
!closedLastEnd.compare(detourLastStart) ||
!closedLastEnd.compare(detourLastEnd)))
||
((!closedFirstStart.compare(detourLastStart) ||
!closedFirstStart.compare(detourLastEnd) ||
!closedFirstEnd.compare(detourLastStart) ||
!closedFirstEnd.compare(detourLastEnd))
&&
(!closedLastStart.compare(detourFirstStart) ||
!closedLastStart.compare(detourFirstEnd) ||
!closedLastEnd.compare(detourFirstStart) ||
!closedLastEnd.compare(detourFirstEnd)))
))
{
/* closed roads and detour roads is not connected properly */
this->escapeRoadCloseMode();
emit throwErrorForUser("Nevhodne zvolene cesty");
return;
}
// change color of detour roads
for ( Road* road : std::get<1>(closedRoads) ) {
QGraphicsLineItem* roadItem = roadsItems.at(roads.indexOf(road));
roadItem->setPen(QPen(Qt::darkGreen,PEN_SIZE));
}
for ( Linka* linka : model->getAllConnections() ) {
/* iteration through all lines */
for ( auto road : linka->getRoads() ) {
/* iteration through all roads of current line */
Road* onlyRoad = std::get<0>(road);
for ( Road* road : std::get<0>(this->closedRoads) ) {
/* iteration through all closed roads by user */
if ( ! onlyRoad->getName().compare(road->getName()) ) {
/*
* this condition evaluate as true only once in every iteration of last two fors
* at the end it will break out of both
*/
/* route of current line contains at least one closed road, line's buses will be processed */
for( Spoj* bus : linka->getConnections() ) {
/* iteration through all line's buses */
QVector<std::tuple<Road*, int>> oldConnectionRoads = bus->getConnectionRoads();
QVector<std::tuple<Road*, int>> newConnectionRoads;
std::tuple<Road*, int> previousRoad = make_tuple(nullptr, 0);
// flag to prevent multiple detour inserts if multiple roads was closed by user
bool detourAlreadyInserted = false;
// information about last road from original route used to decide if detour should be inserted upside down
Road* previousRoadOriginal;
for ( std::tuple<Road*, int> road : oldConnectionRoads ) {
/* iteration through all roads of current bus */
// flag that sets false if current road of current bus is closed, therefore this original road won't be inserted
bool originalRoad = true;
for ( Road* closedRoad : std::get<0>(this->closedRoads) ) {
/* iteration through all closed roads by user - again */
if ( ! std::get<0>(road)->getName().compare(closedRoad->getName()) ) {
/* closed road on bus route was found */
if ( !detourAlreadyInserted ) {
/* closed road will be replaced with detour, if detour wasn't already inserted by another found closed road */
int direction;
QString originalRoadStart = previousRoadOriginal->getStartName();
QString originalRoadEnd = previousRoadOriginal->getEndName();
QString newRoadStart = std::get<1>(this->closedRoads).first()->getStartName();
QString newRoadEnd = std::get<1>(this->closedRoads).first()->getEndName();
if ( !originalRoadStart.compare(newRoadStart) || !originalRoadStart.compare(newRoadEnd) || !originalRoadEnd.compare(newRoadStart) || !originalRoadEnd.compare(newRoadEnd) ) {
for ( Road* road : std::get<1>(this->closedRoads) ) {
/* this cycle determinate direction of every road in new buses route and insert it to new bus route */
Road* previousRoadShort = std::get<0>(previousRoad);
if ( previousRoadShort ) {
if ( !road->getStartName().compare(previousRoadShort->getEndName()) || !road->getEndName().compare(previousRoadShort->getStartName())) {
direction = std::get<1>(previousRoad);
}
else {
direction = std::get<1>(previousRoad) * (-1);
}
}
else {
QRegExp reg("Z.*");
if ( reg.exactMatch(road->getStartName()) ) {
direction = 1;
}
else {
direction = -1;
}
}
std::tuple<Road*, int> longRoad;
longRoad = make_tuple(road, direction);
newConnectionRoads.append(longRoad);
previousRoad = longRoad;
}
}
else {
for ( int i = std::get<1>(this->closedRoads).size() - 1; i >= 0; i-- ) {
/* this cycle determinate direction of every road in new buses route and insert it to new bus route */
/* it also reverse order in which were roads selected by user */
Road* road = std::get<1>(this->closedRoads).at(i);
Road* previousRoadShort = std::get<0>(previousRoad);
if ( previousRoadShort ) {
if ( !road->getStartName().compare(previousRoadShort->getEndName()) || !road->getEndName().compare(previousRoadShort->getStartName())) {
direction = std::get<1>(previousRoad);
}
else {
direction = std::get<1>(previousRoad) * (-1);
}
}
else {
QRegExp reg("Z.*");
if ( reg.exactMatch(road->getStartName()) ) {
direction = 1;
}
else {
direction = -1;
}
}
std::tuple<Road*, int> longRoad;
longRoad = make_tuple(road, direction);
newConnectionRoads.append(longRoad);
previousRoad = longRoad;
}
}
detourAlreadyInserted = true;
}
originalRoad = false;
break;
}
}
if ( originalRoad ) {
/* any closed roads wasn't match with original road so original road is inserted */
newConnectionRoads.append(road);
previousRoad = road;
}
previousRoadOriginal = std::get<0>(road);
}
// save new route
bus->assignRoads(newConnectionRoads);
}
goto doubleBreak_1; // break from two fors
}
}
}
doubleBreak_1:;
}
allClosedRoads.append(closedRoads);
}
else if ( this->mode == CLOSED ) {
/* user is choosing closed roads */
// reset data from last road close
std::get<0>(closedRoads).clear();
std::get<1>(closedRoads).clear();
QGraphicsLineItem* lastRoadItem = roadsItems.at(roads.indexOf(this->lastRoad));
lastRoadItem->setPen(QPen(Qt::red,PEN_SIZE));
this->lastRoad->setSelect(false);
this->lastSelected = NOTHING;
this->lastRoad->setRoadClose(std::make_tuple(1, 0));
std::get<0>(closedRoads).append(this->lastRoad);
}
else if ( this->mode == DETOUR ) {
/* user is choosing detour roads */
// change color of closed roads
for ( Road* road : std::get<0>(closedRoads) ) {
QGraphicsLineItem* roadItem = roadsItems.at(roads.indexOf(road));
roadItem->setPen(QPen(Qt::gray,PEN_SIZE));
}
}
}
void MapScene::roadCloseCancel() {
this->lastRoad->setSelect(false);
this->lastSelected = NOTHING;
for ( auto closedRoute : this->allClosedRoads ) {
for ( Road* closedRoad : std::get<0>(closedRoute) ) {
if ( ! closedRoad->getName().compare(this->lastRoad->getName()) ) {
/* found a closed rout that user want to cancel */
this->closedRoads = closedRoute;
this->escapeRoadCloseMode();
for ( Linka* linka : model->getAllConnections() ) {
/* iteration through all lines */
for ( auto road : linka->getRoads() ) {
/* iteration through all roads of current line */
Road* onlyRoad = std::get<0>(road);
if ( ! closedRoad->getName().compare(onlyRoad->getName()) ) {
for( Spoj* bus : linka->getConnections() ) {
bus->assignRoads(linka->getRoads());
}
goto doubleBreak_2;
}
}
}
doubleBreak_2:;
this->allClosedRoads.removeOne(closedRoute);
goto doubleBreak_3;
}
}
}
doubleBreak_3:;
}
void MapScene::escapeRoadCloseMode() {
this->mode = DETOUR;
emit cancelRoadCloseMode();
// repaint closed roads
for ( Road* road : std::get<0>(this->closedRoads) ) {
road->setRoadClose(std::make_tuple(-1, 0));
this->paintRoad(road);
}
// repaint detour roads
for ( Road* road : std::get<1>(this->closedRoads) ) {
road->setRoadClose(std::make_tuple(0, -1));
this->paintRoad(road);
}
}
void MapScene::paintRoad(Road* road) {
QGraphicsLineItem* roadItem = roadsItems.at(roads.indexOf(road));
if ( road->isSelected() ) {
roadItem->setPen(QPen(Qt::cyan,PEN_SIZE));
}
else if ( std::get<0>(road->getRoadClose()) ) {
roadItem->setPen(QPen(Qt::gray,PEN_SIZE));
}
else if ( std::get<1>(road->getRoadClose()) ) {
roadItem->setPen(QPen(Qt::darkGreen,PEN_SIZE));
}
else if ( road->getTraffic() != 0 ) {
if ( road->getTraffic() >= 10 ) {
roadItem->setPen(QPen(Qt::red,PEN_SIZE));
}
else {
roadItem->setPen(QPen(QColor("orange"),PEN_SIZE));
}
}
else {
roadItem->setPen(QPen(Qt::black,PEN_SIZE));
}
}
void MapScene::setActiveBuses(QVector<Spoj *> buses){
this->activeBuses = buses;
}
roadCloseMode MapScene::getMode() {
return this->mode;
}
void MapScene::setMode(roadCloseMode mode) {
this->mode = mode;
}
| [
"xpavlo14@stud.fit.vutbr.cz"
] | xpavlo14@stud.fit.vutbr.cz |
13d5048e456e459aa7254ddeaf5ef2fc5ffa3a66 | 882d3591752a93792bd8c734dd91b1e5439c5ffe | /common-c-library/httpcontroller/HttpGetChatVoucherListTask.h | 902aa51da12cb4d1fcbb21f5f893214227b0902f | [] | no_license | KingsleyYau/LiveClient | f4d4d2ae23cbad565668b1c4d9cd849ea5ca2231 | cdd2694ddb4f1933bef40c5da3cc7d1de8249ae2 | refs/heads/master | 2022-10-15T13:01:57.566157 | 2022-09-22T07:37:05 | 2022-09-22T07:37:05 | 93,734,517 | 27 | 14 | null | null | null | null | UTF-8 | C++ | false | false | 1,267 | h | /*
* HttpGetChatVoucherListTask.h
*
* Created on: 2019-9-11
* Author: Alex
* desc: 5.7.获取LiveChat聊天试用券列表
*/
#ifndef HttpGetChatVoucherListTask_H_
#define HttpGetChatVoucherListTask_H_
#include "HttpRequestTask.h"
#include "item/HttpVoucherItem.h"
class HttpGetChatVoucherListTask;
class IRequestGetChatVoucherListCallback {
public:
virtual ~IRequestGetChatVoucherListCallback(){};
virtual void OnGetChatVoucherList(HttpGetChatVoucherListTask* task, bool success, const string& errnum, const string& errmsg, const VoucherList& list, int totalCount) = 0;
};
class HttpGetChatVoucherListTask : public HttpRequestTask {
public:
HttpGetChatVoucherListTask();
virtual ~HttpGetChatVoucherListTask();
/**
* 设置回调
*/
void SetCallback(IRequestGetChatVoucherListCallback* pCallback);
/**
*
*/
void SetParam(
int start,
int step
);
protected:
// Implement HttpRequestTask
bool ParseData(const string& url, bool bFlag, const char* buf, int size);
protected:
IRequestGetChatVoucherListCallback* mpCallback;
};
#endif /* HttpGetChatVoucherListTask_H_ */
| [
"Kingsleyyau@gmail.com"
] | Kingsleyyau@gmail.com |
c75ccf799cbe2282fe74c6810a00ea25cc9076e1 | 1deacf2c8428a4abfa503716d9cdb6c7b6c4177c | /HomeWork/1.5/1.5/1.5.cpp | 159310bc4701080f0137047c7019305567a52bcf | [] | no_license | Sashahonin/programmed-by-MIREA | 65960837c6128f49fa6b72b81cbcf7d4bd1317ba | 8bb73f613d0f1d860675afb1082efbb9466717bd | refs/heads/master | 2020-07-21T08:36:27.487698 | 2019-12-16T06:03:07 | 2019-12-16T06:03:07 | 206,797,162 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 301 | cpp |
#include <iostream>
using namespace std;
int main()
{
int b;
cout << "enter 0 if it’s light outside,enter 1 if the lamp is on or 2 if the curtains are apart ";
cin >> b;
if (b == 0 || b == 1 || b == 2)
{
cout << "the room is light";
}
else
{
cout << "It's dark in the room";
}
}
| [
"777@6020322.ru"
] | 777@6020322.ru |
f60cfc4960e586c34be21fd44c103c1429cdc9b5 | 6daa1f3309bd2ea048794a501ffe0575ee026c78 | /SK_HourMaze/AlgorithmMove.h | 4ce4a933877cccffc07efb2b806341f5460d59e8 | [
"MIT"
] | permissive | winstonlin/HourMaze | cf8071c971a63b50c6de5cfa64f0af71a053dbfe | 87deb797b9c8d2f6cfc2f925c302742e3b980038 | refs/heads/master | 2020-05-17T12:33:55.160856 | 2013-11-20T03:11:41 | 2013-11-20T03:11:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,490 | h | #pragma once
#ifndef ALGORITHM_MOVE_H
#define ALGORITHM_MOVE_H
// ===================================================================================================================
// Includes
// ===================================================================================================================
#include <vector>
#include "Globals.h"
CORE_NAMESPACE_BEGIN
// ===================================================================================================================
// Class
// This class is used as a linked list for queueing up possible moves when trying to obtain a complete solution.
// A custom class is used to allow more flexibility with implementation.
// ===================================================================================================================
class AlgorithmMove
{
public:
AlgorithmMove(int iValue);
~AlgorithmMove(void);
int mValue; // Value associated with the move
AlgorithmMove* mNextMove; // Next move to be tried
private:
AlgorithmMove(const AlgorithmMove& src); // Disabled copy constructor
AlgorithmMove& operator=(const AlgorithmMove& rhs); // Disabled assignment operator
};
// ===================================================================================================================
// End
// ===================================================================================================================
CORE_NAMESPACE_END
#endif | [
"winston.lin.mail@gmail.com"
] | winston.lin.mail@gmail.com |
a8a5ca6a436091575e8b739a064a331c7b7ee667 | 82a6b429879de0be9c03067d6d1043f30bcaa3cb | /coperC/src/assembling.cpp | d51861bbb8284bdadb41fb191f24842666950401 | [] | no_license | zspark/coperC | 215d662322a21e60121cfe769224bb7270252508 | 1b7cacbdb94224bd3692bb0908edd75baa237485 | refs/heads/master | 2021-01-10T01:50:47.149169 | 2018-03-10T02:07:39 | 2018-03-10T02:07:39 | 54,351,911 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,804 | cpp | #include "assembling.h"
#include "analyzer.h"
using namespace std;
using namespace cl;
Assembling::Assembling(cluint defaultColor
,cluint highlightColor,clbool verbose)
:m_defaultPrintColor(defaultColor)
,m_highLightPrintColor(highlightColor)
,m_bVerbosePrint(verbose){}
Assembling::~Assembling(){}
void Assembling::Assemble(const vector<LexicalInfo*>& in){
m_tmpNode=nullptr;
m_vecInfos.clear();
m_vecInfos=in;
const LexicalInfo* info=nullptr;
const cluint N=in.size();
for(cluint i=0;i<N;i++){
info=in[i];
if(info->type==LexicalInfoType::KEY_WORD){
if(strcmp(info->fixedStr.c_str(),MARK_SLASH)==0){
HandleSlash_(i);
} else if(strcmp(info->fixedStr.c_str(),MARK_V_LINE)==0){
ASSERT(false);
} else if(strcmp(info->fixedStr.c_str(),MARK_LEFT_BRACKET)==0){
i=HandleBracket_(i);
} else if(strcmp(info->fixedStr.c_str(),MARK_RIGHT_BRACKET)==0){
ASSERT(false);
} else if(strcmp(info->fixedStr.c_str(),MARK_DOUBLE_RIGHT_BRACKET)==0){
HandleRegexp_(i);
}
} else if(info->type==LexicalInfoType::NAME){
if(i==N-1){
// last appears must be file name;
HandleLastFileName_(i);
}
}
}
}
cluint Assembling::HandleBracket_(clint index){
clstr m_commonExtension="";
for(auto i:m_vecInfos){
if(i->type==LexicalInfoType::COMMON_EXTENSION){
m_commonExtension=i->fixedStr;
break;
}
}
const LexicalInfo* info=nullptr;
cluint offset=index;
for(;;offset++){
info=m_vecInfos[offset];
const clstr fileName=info->fixedStr;
if(IsRightBracketKeyword(fileName)){
break;
} else{
if(info->type==LexicalInfoType::NAME){
if(!Aim_(fileName)){
hsnode* node=m_hs.CreateNode();
node->customObject.name=fileName+m_commonExtension;
node->customObject.type=NodeType::FILE;
m_hs.InsertNode(m_tmpNode,node,cl::hs::clHSNodeRelation::R_LAST_CHILD);
}
}
}
}
return offset;
}
inline clbool Assembling::HandleSlash_(clint index){
const LexicalInfo* preInfo=m_vecInfos[index-1];
if(!Aim_(preInfo->fixedStr)){
// ��Ŀ¼����û��������Ҫ����Ŀ¼
hsnode* node=m_hs.CreateNode();
node->customObject.name=preInfo->fixedStr;
node->customObject.type=NodeType::FOLDER;
m_hs.InsertNode(m_tmpNode,node,cl::hs::clHSNodeRelation::R_LAST_CHILD);
m_tmpNode=node;
}
return true;
}
clbool Assembling::HandleLastFileName_(clint pos){
const LexicalInfo* info=m_vecInfos[pos];
clstr name=info->fixedStr;
if(!Aim_(name)){
// ���ļ�������û��������Ҫ�������
hsnode* node=m_hs.CreateNode();
m_hs.InsertNode(m_tmpNode,node,cl::hs::clHSNodeRelation::R_LAST_CHILD);
node->customObject.name=name;
if(IsWildCardName(name)){
node->customObject.type=NodeType::FILE_WILDCARD;
} else
node->customObject.type=NodeType::FILE;
}
return true;
}
clbool Assembling::HandleRegexp_(clint index){
const LexicalInfo* info=m_vecInfos[index+1];
F_DBG_ASSERT(info);
if(!Aim_(info->fixedStr)){
// ��Ŀ¼����û��������Ҫ����Ŀ¼
hsnode* node=m_hs.CreateNode();
node->customObject.name=info->fixedStr;
node->customObject.type=NodeType::REGEXP;
m_hs.InsertNode(m_tmpNode,node,cl::hs::clHSNodeRelation::R_LAST_CHILD);
}
return true;
}
clbool Assembling::Aim_(clstr name){
hsnode* tmp=m_hs.GetFirstChildNode(m_tmpNode);
if(!tmp)return false;
while(tmp){
if(::strcmp(tmp->customObject.name.c_str(),name.c_str())==0){
if(tmp->customObject.type==NodeType::FOLDER)
m_tmpNode=tmp;
return true;
}
tmp=tmp->GetNextSiblingNode();
}
return false;
}
| [
"z_Spark@163.com"
] | z_Spark@163.com |
3738fbad3da99fc03a01819558e484057f045d50 | 229e10af52ed337f72b522dec1564e14d924e53b | /Weeemake/examples/We_SoundSensor/We_SoundSensor.ino | c4a10ef1bf1c66ea1aa9453f41522a0822b07e13 | [] | no_license | WEEEMAKE/Weeemake_Libraries_for_Arduino | a00b755ae70c79a65051644d9a04f4956c1c1931 | 02c2be22513f799b6841ffd5a15cfa9e9e11d1d7 | refs/heads/master | 2022-09-13T06:48:48.438828 | 2022-09-07T02:51:40 | 2022-09-07T02:51:40 | 177,978,944 | 2 | 4 | null | 2019-05-08T06:35:39 | 2019-03-27T11:20:33 | C++ | UTF-8 | C++ | false | false | 229 | ino | #include "WeELF328P.h"
WeSoundSensor SoundSensor(PORT_3);
int value = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
value = SoundSensor.read();
Serial.print("value = ");
Serial.println(value);
delay(100);
}
| [
"juneral@weeemake.com"
] | juneral@weeemake.com |
c1713b3423385a1fd85fac4ba568d98b743b108b | 2a440aea43b5b880fd433f58098ac3bbc66fcfec | /dts/include/alibabacloud/dts/model/ConfigureSynchronizationJobReplicatorCompareRequest.h | 3e2e061b7c867a567bacc17f69a6ace18fd8ae79 | [
"Apache-2.0"
] | permissive | longkai1028/aliyun-openapi-cpp-sdk | 30d6553e508c6a38d190557487972553a6ae64d5 | 97286a49ca7ae8754984f6b8abce1a8e6f48117c | refs/heads/master | 2023-04-04T00:13:25.713899 | 2021-04-13T02:28:45 | 2021-04-13T02:28:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,414 | h | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_DTS_MODEL_CONFIGURESYNCHRONIZATIONJOBREPLICATORCOMPAREREQUEST_H_
#define ALIBABACLOUD_DTS_MODEL_CONFIGURESYNCHRONIZATIONJOBREPLICATORCOMPAREREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/dts/DtsExport.h>
namespace AlibabaCloud
{
namespace Dts
{
namespace Model
{
class ALIBABACLOUD_DTS_EXPORT ConfigureSynchronizationJobReplicatorCompareRequest : public RpcServiceRequest
{
public:
ConfigureSynchronizationJobReplicatorCompareRequest();
~ConfigureSynchronizationJobReplicatorCompareRequest();
std::string getClientToken()const;
void setClientToken(const std::string& clientToken);
std::string getOwnerId()const;
void setOwnerId(const std::string& ownerId);
std::string getAccessKeyId()const;
void setAccessKeyId(const std::string& accessKeyId);
std::string getSynchronizationJobId()const;
void setSynchronizationJobId(const std::string& synchronizationJobId);
std::string getAccountId()const;
void setAccountId(const std::string& accountId);
bool getSynchronizationReplicatorCompareEnable()const;
void setSynchronizationReplicatorCompareEnable(bool synchronizationReplicatorCompareEnable);
std::string getSynchronizationDirection()const;
void setSynchronizationDirection(const std::string& synchronizationDirection);
private:
std::string clientToken_;
std::string ownerId_;
std::string accessKeyId_;
std::string synchronizationJobId_;
std::string accountId_;
bool synchronizationReplicatorCompareEnable_;
std::string synchronizationDirection_;
};
}
}
}
#endif // !ALIBABACLOUD_DTS_MODEL_CONFIGURESYNCHRONIZATIONJOBREPLICATORCOMPAREREQUEST_H_ | [
"sdk-team@alibabacloud.com"
] | sdk-team@alibabacloud.com |
713da334c4aa61ad72e2b4a1d0ba6cd4a77090b5 | 82317c31625a9942a534e006242dcdf4e4273fd1 | /necromancer_romance/src/scenes/CScene_Intro.h | 795a5fe94314c1e56cde204dc2c244b25ff3f775 | [] | no_license | Seungwoo-Jo/Necromancer_Romance_DX | d18105d4fb334931a8953f54f1dfe1aa4fd8e06b | 8a1158f5331876da78f4571ad052f69eadd5109e | refs/heads/master | 2020-04-10T03:51:53.562216 | 2016-06-22T21:03:24 | 2016-06-22T21:03:24 | 32,254,856 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 398 | h | #ifndef _CSCENE_INTRO_H_
#define _CSCENE_INTRO_H_
#include "CScene.h"
class CObject_Logo;
class CTime;
class CScene_Intro : public CScene
{
private:
CObject_Logo* m_logo;
CTime* m_sceneTimer;
public:
CScene_Intro();
CScene_Intro(const CScene_Intro&);
~CScene_Intro();
virtual void Initialize();
virtual void Shutdown();
virtual void Update(CInput*);
virtual void Render();
};
#endif | [
"zseqqq123@gmail.com"
] | zseqqq123@gmail.com |
53174087a3717865f3bfcd681ca422b68a23dd3a | aadde63fbf9d342b74e79c0c7cacce21bd741ebf | /Modern_Cpp_Challenge/01/09.cpp | b040db242cba0ea391abee8bed000598032d2562 | [] | no_license | prifri/cpp_practice | eec28f9f623a8902b572ef53c524a7184393773b | d2bb2d44fac50163ea56c7eba010e7481d8ef612 | refs/heads/master | 2022-11-05T16:24:05.263282 | 2020-06-15T16:35:39 | 2020-06-15T16:35:39 | 262,716,861 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,239 | cpp | #include <iostream>
#include <cstring>
#include <iterator>
#include <ostream>
#include <vector>
#define __unused __attribute__((unused))
#if 0
typedef __uint128_t CalType ;
#else
typedef uint64_t CalType ;
#endif
#define DIGIT 10
class InNumber{
public:
int in(uint32_t &n)
{
std::cout << "input plus intger : ";
std::cin >> n;
if (std::cin.fail()){
std::cout << "invalid number" << std::endl;
return -1;
}
return 0;
}
int in(uint64_t &n)
{
std::cout << "input plus intger : ";
std::cin >> n;
if (std::cin.fail()){
std::cout << "invalid number" << std::endl;
return -1;
}
return 0;
}
int in(__uint128_t &n)
{
char uint128_str[41];
std::cout << "input plus intger : ";
std::cin >> uint128_str;
char *p = uint128_str;
int len = 0;
n = 0;
while (*p != '\0'){
n = n*10 + *p - '0';
p++;
len++;
if (len >= 39){
std::cout << "toooo large.." << std::endl;
return -1;
}
}
std::cout << "in : " << uint128_str << std::endl;
if (std::cin.fail()){
std::cout << "invalid number" << std::endl;
return -1;
}
return 0;
}
void pr_128(__uint128_t n)
{
char str[40];
int len = 0;
__uint128_t tmp = n;
while (tmp){
len++;
tmp /= 10;
}
str[len] = '\0';
while (1){
str[--len] = n%10 + '0';
n/=10;
if (len == 0)
break;
}
std::cout << str;
}
bool Is128(__uint128_t n)
{
uint64_t max = -1;
if (n > max)
return true;
return false;
}
void show(__uint128_t n)
{
if (Is128(n) == true)
pr_128(n);
else
std::cout << (uint64_t)n;
}
}Num;
CalType power(CalType x, CalType y)
{
CalType __x = 1;
for (CalType i = y ; i > 0 ; i--){
__x *= x;
}
return __x;
}
template <typename T>
T Sqrt (T a)
{
T min = 0;
T max = ((T) 1) << (sizeof(T)*4);
while(1)
{
if (max <= 1 + min)
return min;
T sqt = min + (max - min)/2;
T sq = sqt*sqt;
if (sq == a)
return sqt;
if (sq > a)
max = sqt;
else
min = sqt;
}
}
/*
* 참고 사이트
* https://stackoverflow.com/questions/15704565/efficient-way-to-return-a-stdvector-in-c
* https://dydtjr1128.github.io/cpp/2019/08/10/Cpp-RVO(Return-Value-Optimization).html
*/
template<typename T>
std::vector<T> prime_factor(T n)
{
T origin = n;
std::vector<T> factors;
while (n % 2 == 0)
{
factors.push_back(2);
n /= 2;
}
for (T i = 3; i <= Sqrt(n) ; i+= 2)
{
while ( n % i == 0)
{
factors.push_back(i);
n /= i;
}
}
if (n > 2 && n != origin)
{
factors.push_back(n);
}
return factors;
}
int main(int __unused argc, char __unused *argv[])
{
CalType n;
if (Num.in(n) < 0)
{
std::cout << "invalid number" << std::endl;
return -1;
}
std::vector<CalType> factors = prime_factor(n);
#if 1
for (const auto &i : factors)
{
std::cout << i << std::endl;
}
#else
for (std::vector<CalType>::iterator i = factors.begin() ;
i != factors.end() ; i++)
{
std::cout << *i << std::endl;
}
#endif
return 0;
}
| [
"kkr@jubix.co.kr"
] | kkr@jubix.co.kr |
d8f16ef1fee318e5081542cdef92b996c61ad520 | 46aec53389acc4caec470911f5a01a62bd9bfd8c | /Pointers in structure/pointers in structures.cpp | 91de37a63a5c75dd748e986f55afb1760c296ee3 | [] | no_license | sohailziagill/object-oriented-programming | 45f7097bbfcacae75f3503b14307f6da5e9e4ad1 | 51a9593071b7bd21beda498b1b3ff5eeae13f865 | refs/heads/master | 2020-09-22T04:55:41.525654 | 2020-06-30T09:51:05 | 2020-06-30T09:51:05 | 225,055,531 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 534 | cpp | #include<iostream >
using namespace std;
struct student {
char name;
int reg;
double salary;
};
int main()
{
student std;
cout<<"Enter the details of student like name,reg and salary ";
cin>>std->name;
cin>>std->reg;
cin>>std->salary;
student person *ptr=NULL;
*ptr=&std;
cout<<"\n The entered details of student is ";
cout<<"\n Name "<<ptr->name;
cout<<"\nRegistration number is "<<ptr->reg;
cout<<"\n The salary is "<<ptr->salary;
system ("pause");
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
14a302a61f38d360d181a196ee79071f0d9db762 | 493606711d4681cec63e7187806763eb6452e8db | /main.cpp | d2111c5273accb43b355514b42a69406a8c37846 | [] | no_license | runtest007/hash_table | 1d541b8a4c753d0d9187f85f783bccae107a38b2 | 3f68be8ad852c8abd76dc611cff87b23a84273f4 | refs/heads/master | 2020-05-15T11:14:39.877806 | 2019-04-19T07:12:18 | 2019-04-19T07:12:18 | 182,218,318 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 6,761 | cpp | #include <iostream>
#include <stdio.h>
#include <string.h>
#include "globaldef.h"
#include "hash.h"
using std::cin;
using std::cout;
using std::endl;
#define ADD_NODE 1
#define LOOKUP_NODE 2
#define REMOVE_NODE 3
#define DISPLAY_NODE 4
#define MEM_STATIC 5
#define LOGOUT 6
#define SRC_IP_BASE 100000000
#define SRC_PORT_BASE 200000000
#define DST_IP_BASE 300000000
#define DST_PORT_BASE 400000000
void display_node(void *key, void *data)
{
if(key == NULL)
{
cout << "节点的key为空,异常"<<endl;
return;
}
Packet_Info_T *node_key = (Packet_Info_T *)key;
printf("节点内容,SrcIP:%8u, SrcPort:%8u, DstIP: %8u, DstPort: %8u, Index:%8u.\n", node_key->nSIp, node_key->nSPort, node_key->nDIp, node_key->nDPort, node_key->nIndex);
return;
}
bool init()
{
int nBucketCnt = -1;
int nBucketDepth = -1;
unsigned int nTimeOut = 0;
cout<<"请输入哈希表桶数:";
cin>>nBucketCnt;
cout<<"请输入哈希表桶深(输入0则表示桶深无限制):";
cin>>nBucketDepth;
cout<<"请输入超时时间(单位s):";
cin>>nTimeOut;
cout<<"输入的桶数为:"<<nBucketCnt<<", 桶深为:"<<nBucketDepth<<", 超时时间为:"<<nTimeOut<<"."<<endl;
if(nBucketCnt <= 0 || nBucketDepth < 0 || nTimeOut == 0)
{
cout << "输入的桶数应该大于0, 输入的桶深应大于等于0, 超时时间应大于0 ."<<endl;
return false;
}
else
{
g_BucketCnt = nBucketCnt;
g_BucketDepth = nBucketDepth;
g_ListTimeOut = nTimeOut;
}
cout<<"开始初始化哈希表"<<endl;
g_ClueHashTable = hash_init(g_BucketCnt, HashKeyFunc, HashCompare, HashDestroyFunc, HashNodeSizeCntFunc, g_BucketDepth);
if(g_ClueHashTable == NULL)
{
cout <<"哈希表初始化失败,程序退出."<<endl;
return false;
}
else
{
cout<<"哈希表初始化成功."<<endl;
}
return true;
}
void display_hashtable_mem_size()
{
unsigned int nTotalNodeCnt = 0;
long long nTotalNodeSizeCnt = 0;
long long nTotalBucketSizeCnt = 0;
for ( int i = 0; i < g_ClueHashTable->bucket_cnt; i++ )
{
nTotalNodeCnt += g_ClueHashTable->bucket[i].node_cnt ;
nTotalNodeSizeCnt += g_ClueHashTable->bucket[i].total_size;
}
nTotalBucketSizeCnt = g_ClueHashTable->bucket_cnt * sizeof(bucket_head_ts);
printf("桶个数:%d,桶内存:%lld Bytes,桶节点个数:%u, 桶节点内存:%lld Bytes, 桶和桶节点总内存:%lld Bytes.\n",
g_ClueHashTable->bucket_cnt, nTotalBucketSizeCnt, nTotalNodeCnt, nTotalNodeSizeCnt, nTotalNodeSizeCnt+nTotalBucketSizeCnt);
return;
}
void add_node_func()
{
unsigned int need_insert_cnt = 0;
unsigned int cur_insert_cnt = 1;
unsigned int err_insert_cnt = 0;
unsigned int dup_insert_cnt = 0;
cout<<"批量插入节点,请输入需要插入的节点数."<<endl;
cin>>need_insert_cnt;
if(need_insert_cnt == 0)
{
cout<<"输入需要插入的节点个数应该大于0"<<endl;
return;
}
cout<<"开始批量插入节点"<<endl;
Packet_Info_T tmp_key;
int befoe_tm = time(NULL);
for(; cur_insert_cnt <= need_insert_cnt; cur_insert_cnt++)
{
bzero(&tmp_key, sizeof(Packet_Info_T));
tmp_key.nSIp = SRC_IP_BASE + cur_insert_cnt%SRC_IP_BASE;
tmp_key.nSPort = SRC_PORT_BASE + cur_insert_cnt%SRC_PORT_BASE;
tmp_key.nDIp = DST_IP_BASE + cur_insert_cnt% DST_IP_BASE;
tmp_key.nDPort= DST_PORT_BASE + cur_insert_cnt%DST_PORT_BASE;
tmp_key.nIndex = g_inedex % 4000000000;
if(NULL != hash_lookup(g_ClueHashTable, &tmp_key))
{
cout<<"需要插入的节点已经存在,不进行插入."<<endl;
g_inedex++;
dup_insert_cnt++;
//return;
continue;
}
Packet_Info_T *key = new Packet_Info_T;
if(key == NULL)
{
cout<<"申请key内存失败,插入节点失败."<<endl;
err_insert_cnt++;
goto err_process;
}
char *data = new char(0x01);
if(data == NULL)
{
cout<<"申请data内存失败,插入节点失败."<<endl;
if( NULL != key)
{
delete key;
key = NULL;
}
err_insert_cnt++;
goto err_process;
}
key->nSIp = tmp_key.nSIp;
key->nSPort = tmp_key.nSPort;
key->nDIp = tmp_key.nDIp;
key->nDPort= tmp_key.nDPort;
key->nIndex = tmp_key.nIndex;
if(0 != hash_add(g_ClueHashTable, (void *)key, data))
{
cout << "hash_add函数调用失败, 插入节点失败" <<endl;
}
g_inedex++;
}
err_process:
if(cur_insert_cnt > need_insert_cnt)
{
cur_insert_cnt = need_insert_cnt;
}
int after_tm = time(NULL);
printf("批量插入节点结束,用时%d s, 需要插入%u节点,实际插入了%u次,其中插入失败%u次, 因重复而未插入%u次.\n", after_tm-befoe_tm, need_insert_cnt, cur_insert_cnt, err_insert_cnt, dup_insert_cnt);
return;
}
void lookup_node_func()
{
Packet_Info_T key;
bzero(&key, sizeof(Packet_Info_T));
cout <<"请输入源ip、源port、目的ip、目的端口、索引号"<<endl;
cin>>key.nSIp>>key.nSPort>>key.nDIp>>key.nDPort>>key.nIndex;
Packet_Info_T *node_key = (Packet_Info_T *)hash_lookup(g_ClueHashTable, (void *)&key);
if(node_key)
{
printf("查找到节点,SrcIP:%8u, SrcPort:%8u, DstIP: %8u, DstPort: %8u, Index:%8u.\n", node_key->nSIp, node_key->nSPort, node_key->nDIp, node_key->nDPort, node_key->nIndex);
}
else
{
cout<<"未查找到节点,节点不存在."<<endl;
}
return;
}
void remove_node_func()
{
Packet_Info_T key;
bzero(&key, sizeof(Packet_Info_T));
cout <<"请输入源ip、源port、目的ip、目的端口、索引号"<<endl;
cin>>key.nSIp>>key.nSPort>>key.nDIp>>key.nDPort>>key.nIndex;
if(0 == hash_remove(g_ClueHashTable, &key))
{
cout<<"节点删除成功."<<endl;
}
else
{
cout<<"节点删除失败."<<endl;
}
}
void display_node_func()
{
hash_browse(g_ClueHashTable, display_node);
return;
}
int main()
{
//初始化hash表
if(!init())
{
return -1;
}
int out_flag = 0;
while(out_flag == 0)
{
int nOpt;
cout<<"请输入操作类型:1 插入, 2 查询, 3 删除, 4 遍历打印 5 内存统计 6 退出"<<endl;
cin >> nOpt;
switch (nOpt)
{
case ADD_NODE:
add_node_func();
break;
case LOOKUP_NODE:
lookup_node_func();
break;
case REMOVE_NODE:
remove_node_func();
break;
case DISPLAY_NODE:
display_node_func();
break;
case MEM_STATIC:
display_hashtable_mem_size();
break;
case LOGOUT:
out_flag = 1;
break;
default:
cout << "操作类型输入错误,请重新输入.";
break;
}
}
if( NULL != g_ClueHashTable)
{
free_hash(g_ClueHashTable);
g_ClueHashTable = NULL;
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
2dce5063b30d20acc3d3a0d17345a8f8d5e07765 | d6b2dd2aa6c951cce83fc894e7f78b4ca0dd9893 | /ProjectSeycodeAndroid/build/Android/Debug/SeyCode/app/src/main/include/Uno.Graphics.DeviceBuffer.h | 2dddb15ba30d6d134d30a541557a5a786853c075 | [] | no_license | seycode/projectSeycode | 2e1ce90cb3e7c6ea322fa36f649b4b3906b32db3 | e1ebf63966ace40afa8736cc0aa37b18117774dc | refs/heads/master | 2021-01-11T02:49:33.975116 | 2016-12-13T16:08:45 | 2016-12-13T16:08:45 | 70,919,614 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,446 | h | // This file was generated based on /usr/local/share/uno/Packages/UnoCore/0.32.2/Source/Uno/Graphics/$.uno.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.IDisposable.h>
#include <Uno.Object.h>
namespace g{namespace Uno{namespace Graphics{struct DeviceBuffer;}}}
namespace g{namespace Uno{struct Buffer;}}
namespace g{
namespace Uno{
namespace Graphics{
// public abstract class DeviceBuffer :9
// {
struct DeviceBuffer_type : uType
{
::g::Uno::IDisposable interface0;
};
DeviceBuffer_type* DeviceBuffer_typeof();
void DeviceBuffer__ctor__fn(DeviceBuffer* __this, int* usage);
void DeviceBuffer__Dispose_fn(DeviceBuffer* __this);
void DeviceBuffer__get_GLBufferHandle_fn(DeviceBuffer* __this, uint32_t* __retval);
void DeviceBuffer__set_GLBufferHandle_fn(DeviceBuffer* __this, uint32_t* value);
void DeviceBuffer__get_GLBufferTarget_fn(DeviceBuffer* __this, int* __retval);
void DeviceBuffer__set_GLBufferTarget_fn(DeviceBuffer* __this, int* value);
void DeviceBuffer__GLInit_fn(DeviceBuffer* __this, int* target);
void DeviceBuffer__GLInit1_fn(DeviceBuffer* __this, int* target, int* sizeInBytes);
void DeviceBuffer__GLInit2_fn(DeviceBuffer* __this, int* target, ::g::Uno::Buffer* data);
void DeviceBuffer__get_IsDisposed_fn(DeviceBuffer* __this, bool* __retval);
void DeviceBuffer__set_IsDisposed_fn(DeviceBuffer* __this, bool* value);
void DeviceBuffer__get_SizeInBytes_fn(DeviceBuffer* __this, int* __retval);
void DeviceBuffer__set_SizeInBytes_fn(DeviceBuffer* __this, int* value);
void DeviceBuffer__Update_fn(DeviceBuffer* __this, ::g::Uno::Buffer* data);
void DeviceBuffer__get_Usage_fn(DeviceBuffer* __this, int* __retval);
void DeviceBuffer__set_Usage_fn(DeviceBuffer* __this, int* value);
struct DeviceBuffer : uObject
{
uint32_t _GLBufferHandle;
int _GLBufferTarget;
bool _IsDisposed;
int _SizeInBytes;
int _Usage;
void ctor_(int usage);
void Dispose();
uint32_t GLBufferHandle();
void GLBufferHandle(uint32_t value);
int GLBufferTarget();
void GLBufferTarget(int value);
void GLInit(int target);
void GLInit1(int target, int sizeInBytes);
void GLInit2(int target, ::g::Uno::Buffer* data);
bool IsDisposed();
void IsDisposed(bool value);
int SizeInBytes();
void SizeInBytes(int value);
void Update(::g::Uno::Buffer* data);
int Usage();
void Usage(int value);
};
// }
}}} // ::g::Uno::Graphics
| [
"seycodeware@gmail.com"
] | seycodeware@gmail.com |
60f2cdef4e99ec1acba73d168a16fd28b78f26bc | 1cc44526fe719ddb807241e873b536c22fa0d1bf | /Src/Representations/Modeling/RobotMap.h | d7f8fc8b492806c7a912b5bd8453a785925692b3 | [
"BSD-2-Clause"
] | permissive | Handsome-Computer-Organization/nao | 55e188276a7ba82631bc6283d18db89f2b688c75 | d7bbac09355e5f8f719acb4b65b39bc7975878ca | refs/heads/main | 2023-04-26T12:24:59.944423 | 2021-05-14T12:53:10 | 2021-05-14T12:53:10 | 367,357,552 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,396 | h | /**
* @file RobotMap.h
* Declaration of a class that represents the map of tracked robots in this robot's environment.
* @author <a href="mailto:stefan.czarnetzki@tu-dortmund.de">Stefan Czarnetzki</a>
*/
#pragma once
#include "Representations/Perception/RobotsPercept.h"
#include "Tools/Streams/AutoStreamable.h"
#include "Tools/Math/Pose2f.h"
#include "Tools/Math/Pose3f.h"
#include <vector>
/**
* @class RobotMap
* A class represents the map of tracked robots in this robot's environment.
*/
STREAMABLE(RobotMapEntry,
{,
(Pose2f) pose, /**< The position in absolute field coordinates. */
((RobotEstimate) RobotType)(RobotEstimate::unknownRobot) robotType,
/** This is nice to have but might not be filled correctly and will not be sent! **/
(Vector2f) velocity,
(float)(0.f) validity,
});
// Global robot map (local + remote)
STREAMABLE(RobotMap,
{
RobotMap() { robots.reserve(10); }
/** Reset the RobotMap */
void reset() { robots.clear(); }
RobotMap& operator=(const RobotMap &other)
{
if (this == &other)
return *this;
reset();
for (unsigned int i = 0; i < other.robots.size(); i++)
{
RobotMapEntry re;
re.pose = other.robots[i].pose;
re.robotType = other.robots[i].robotType;
re.velocity = other.robots[i].velocity;
re.validity = other.robots[i].validity;
robots.push_back(re);
}
return *this;
}
void draw() const,
(std::vector<RobotMapEntry>) robots, /**< The robots in absolute field coordinates. */
});
struct GroundTruthRobotMap : public RobotMap
{
/** Draws something*/
void draw() const;
};
// Local robot map
struct LocalRobotMap : public RobotMap
{
void draw() const;
};
// Robot map of generated by teammate data
struct RemoteRobotMap : public RobotMap
{
/** Draws something*/
void draw() const;
};
STREAMABLE(RobotMapCompressedEntry,
{
RobotMapCompressedEntry() = default;
RobotMapCompressedEntry(const Pose2f& pose, RobotEstimate::RobotType type, float validity)
{
position = pose.translation.cast<short>();
rotation = static_cast<std::uint8_t>((toDegrees(pose.rotation) + 180.f) / 360.f * std::numeric_limits<std::uint8_t>::max());
robotType = type;
this->validity = static_cast<std::uint8_t>(validity * 255.f);
},
(Vector2s) position,
(std::uint8_t)(0) rotation,
((RobotEstimate) RobotType)(RobotEstimate::unknownRobot) robotType,
(std::uint8_t)(0) validity,
});
STREAMABLE(RobotMapCompressed,
{
RobotMapCompressed() = default;
RobotMapCompressed(const RobotMap& other)
{
robots.clear();
for (unsigned int i = 0; i < other.robots.size(); i++)
{
robots.push_back(RobotMapCompressedEntry(
other.robots[i].pose,
other.robots[i].robotType,
other.robots[i].validity));
}
}
operator RobotMap() const
{
RobotMap robotMap;
robotMap.robots.clear();
for (unsigned int i = 0; i < robots.size(); i++)
{
RobotMapEntry re;
re.pose.translation = robots[i].position.cast<float>();
re.pose.rotation = robots[i].rotation / std::numeric_limits<std::uint8_t>::max() * 360.f - 180.f;
re.robotType = robots[i].robotType;
re.velocity = Vector2f::Zero();
re.validity = static_cast<float>(robots[i].validity) / 255.f;
robotMap.robots.push_back(re);
}
return robotMap;
},
(std::vector<RobotMapCompressedEntry>) robots,
});
STREAMABLE(LocalRobotMapCompressed,
{
LocalRobotMapCompressed() = default;
LocalRobotMapCompressed(const LocalRobotMap& other)
{
robots.clear();
for (unsigned int i = 0; i < other.robots.size(); i++)
{
robots.push_back(RobotMapCompressedEntry(
other.robots[i].pose,
other.robots[i].robotType,
other.robots[i].validity));
}
}
operator LocalRobotMap() const
{
LocalRobotMap robotMap;
robotMap.robots.clear();
for (unsigned int i = 0; i < robots.size(); i++)
{
RobotMapEntry re;
re.pose.translation = robots[i].position.cast<float>();
re.pose.rotation = robots[i].rotation / std::numeric_limits<std::uint8_t>::max() * 360.f - 180.f;
re.robotType = robots[i].robotType;
re.velocity = Vector2f::Zero();
re.validity = static_cast<float>(robots[i].validity) / 255.f;
robotMap.robots.push_back(re);
}
return robotMap;
},
(std::vector<RobotMapCompressedEntry>) robots,
});
| [
"handsomeyingyan@github.com"
] | handsomeyingyan@github.com |
d29ef40116f6b8c18327dad5bc8bad9a074170f2 | 80e0750940abe5b23aaa27770e43889e586c9103 | /mapeditor/include/World.hpp | fcc0453610fcd61bd611c0a470a282dab8ccc0fb | [] | no_license | Yoggiburken/Good-bye | d56cbe69a66513800c0ecc8b8915e6bcce748404 | 06481647b44e469c74c69524bfcc9b140f213372 | refs/heads/master | 2021-01-01T16:33:55.969687 | 2013-10-24T11:55:19 | 2013-10-24T11:55:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 864 | hpp | #include<map>
#include<vector>
#include<SFML/Graphics.hpp>
#include"UI.hpp"
#include"Tile.hpp"
#include"FileManager.hpp"
#ifndef WORLD_HPP
#define WORLD_HPP
class World {
private:
friend class UI;
//Windows and events
sf::RenderWindow app;
sf::RenderWindow tilewindow;
UI tile_manager;
sf::Event event;
//tiles
int tilenumber; //Keeps track of selected tile
sf::Texture sprite_sheet;
std::vector<Tile> tile_types; //Tiles to choose from
std::vector<Tile> tilemap;
//Load and save
FileManager filemanager;
void events(); //Parse events
void input(); //Reads input
void addTile(); //places tile at mouse pos
void drawMouseTile(); //Draws current tile at mouse pos
public:
World();
~World();
void main();
};
#endif
| [
"wass95@hotmail.se"
] | wass95@hotmail.se |
404ded602d1dff99183e24a1142285819a36e2de | 625b8ee0d304cc72eb54ff7803e1aef74e33347c | /Table.h | bd0f2ab45653636d3171a3b7e874d55d9b7cdb86 | [] | no_license | yuri-castroo/Database-SQL | 4143f2cbd64f8ebe171539f713ed1ee782cd194b | 5f0245d50257ac3e107924ad25e290c86ea58ca3 | refs/heads/master | 2020-09-17T05:46:25.949678 | 2019-11-25T18:02:12 | 2019-11-25T18:02:12 | 224,010,048 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,566 | h | #pragma once
#ifndef TABLE_H
#define TABLE_H
#include "pch.h"
class Table
{
public:
// Constructors
Table() {};
~Table() {};
Table(std::string aTableName, std::string aKey, std::vector<std::string> aAttributeNameList); // Custom constructor
// (Column Name) Attribute functions
void addAttribute(std::string attribute);
void deleteAttribute(std::string attribute);
// Record functions
void insertRecord(std::string key, Record r);
void deleteRecord(std::string key);
// Join functions
Table crossJoin(Table *t2);
Table naturalJoin(Table *t2);
// Functions called by Database Class - Not by User!
void writeToFile(std::ofstream &fileStream);
Table readFromFile(std::ifstream &fileStream);
std::vector<std::string> readAttributeNameList(std::string &line);
// Getter and Setters
std::string getKey() const { return key; }
std::string getTableName() const { return tableName; }
std::vector<std::string> getAttributeNameList() const { return attributeNameList; }; // Get list of Table attributes
int getSize() const { return table.size(); } // Return table size
Record getRecord(std::string aKey) const;
int getCount(std::string attribute) const; // FIXME: getCount / getSum?
double getMin(std::string attribute) const;
double getMax(std::string attribute) const;
void setKey(std::string aKey) { key = aKey; }
void setTableName(std::string aTableName) { tableName = aTableName; }
// The following function is used just for the query function.
std::map<std::string, Record> getTable() { return table; }
// Extra Credit!
void renameAttribute(std::string attribute1, std::string attribute2);
private:
std::string key; // Table key
std::string tableName;
std::vector<std::string> attributeNameList; // List of all attribute names (column names)
std::map<std::string, Record> table; // Maps Record key to Record object
// Private Function
int getAttributeIndex(std::string attribute) const; // Gets index of attribute in attributeNameList
// Print Table (for debugging)
friend std::ostream& operator<<(std::ostream& os, const Table& t)
{
os << t.getTableName() << std::endl;
int i = 0;
// Prints each row of a table seperately
for (auto elem : t.table)
{
for (auto elem2 : elem.second.getAttributeList())
{
os << t.getAttributeNameList().at(i) << ": ";
os << elem.second.getAttributeList()[i] << std::endl;
i++;
}
os << std::endl;
i = 0;
}
os << std::endl << std::endl;
return os;
}
};
#endif | [
"noreply@github.com"
] | noreply@github.com |
713c86295aaf7f14b5eeb8d5a1ef3c5ee474bb3b | bb4b967732337945dc96a899a1a0463f10db42d1 | /vendor/abseil-cpp/absl/container/internal/compressed_tuple.h | 29fe7c12ca3cd66ef65271c6452d1cacbf570337 | [
"Zlib",
"CC0-1.0",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | killvxk/loki-network | b5d5dc9ff6ac8488b39528edcb71e622f546dea2 | 3715c28616fac132f622a80d5d0e8e794166315a | refs/heads/master | 2020-05-04T19:41:57.347351 | 2019-04-03T19:18:13 | 2019-04-03T19:18:13 | 179,403,950 | 1 | 1 | NOASSERTION | 2019-04-04T02:08:54 | 2019-04-04T02:08:54 | null | UTF-8 | C++ | false | false | 6,139 | h | // Copyright 2018 The Abseil Authors.
//
// 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.
//
// Helper class to perform the Empty Base Optimization.
// Ts can contain classes and non-classes, empty or not. For the ones that
// are empty classes, we perform the optimization. If all types in Ts are empty
// classes, then CompressedTuple<Ts...> is itself an empty class.
//
// To access the members, use member get<N>() function.
//
// Eg:
// absl::container_internal::CompressedTuple<int, T1, T2, T3> value(7, t1, t2,
// t3);
// assert(value.get<0>() == 7);
// T1& t1 = value.get<1>();
// const T2& t2 = value.get<2>();
// ...
//
// http://en.cppreference.com/w/cpp/language/ebo
#ifndef ABSL_CONTAINER_INTERNAL_COMPRESSED_TUPLE_H_
#define ABSL_CONTAINER_INTERNAL_COMPRESSED_TUPLE_H_
#include <tuple>
#include <type_traits>
#include <utility>
#include "absl/utility/utility.h"
#ifdef _MSC_VER
// We need to mark these classes with this declspec to ensure that
// CompressedTuple happens.
#define ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC __declspec(empty_bases)
#else // _MSC_VER
#define ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC
#endif // _MSC_VER
namespace absl {
inline namespace lts_2018_12_18 {
namespace container_internal {
template <typename... Ts>
class CompressedTuple;
namespace internal_compressed_tuple {
template <typename D, size_t I>
struct Elem;
template <typename... B, size_t I>
struct Elem<CompressedTuple<B...>, I>
: std::tuple_element<I, std::tuple<B...>> {};
template <typename D, size_t I>
using ElemT = typename Elem<D, I>::type;
// Use the __is_final intrinsic if available. Where it's not available, classes
// declared with the 'final' specifier cannot be used as CompressedTuple
// elements.
// TODO(sbenza): Replace this with std::is_final in C++14.
template <typename T>
constexpr bool IsFinal() {
#if defined(__clang__) || defined(__GNUC__)
return __is_final(T);
#else
return false;
#endif
}
template <typename T>
constexpr bool ShouldUseBase() {
return std::is_class<T>::value && std::is_empty<T>::value && !IsFinal<T>();
}
// The storage class provides two specializations:
// - For empty classes, it stores T as a base class.
// - For everything else, it stores T as a member.
template <typename D, size_t I, bool = ShouldUseBase<ElemT<D, I>>()>
struct Storage {
using T = ElemT<D, I>;
T value;
constexpr Storage() = default;
explicit constexpr Storage(T&& v) : value(absl::forward<T>(v)) {}
constexpr const T& get() const { return value; }
T& get() { return value; }
};
template <typename D, size_t I>
struct ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC Storage<D, I, true>
: ElemT<D, I> {
using T = internal_compressed_tuple::ElemT<D, I>;
constexpr Storage() = default;
explicit constexpr Storage(T&& v) : T(absl::forward<T>(v)) {}
constexpr const T& get() const { return *this; }
T& get() { return *this; }
};
template <typename D, typename I>
struct ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTupleImpl;
template <typename... Ts, size_t... I>
struct ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC
CompressedTupleImpl<CompressedTuple<Ts...>, absl::index_sequence<I...>>
// We use the dummy identity function through std::integral_constant to
// convince MSVC of accepting and expanding I in that context. Without it
// you would get:
// error C3548: 'I': parameter pack cannot be used in this context
: Storage<CompressedTuple<Ts...>,
std::integral_constant<size_t, I>::value>... {
constexpr CompressedTupleImpl() = default;
explicit constexpr CompressedTupleImpl(Ts&&... args)
: Storage<CompressedTuple<Ts...>, I>(absl::forward<Ts>(args))... {}
};
} // namespace internal_compressed_tuple
// Helper class to perform the Empty Base Class Optimization.
// Ts can contain classes and non-classes, empty or not. For the ones that
// are empty classes, we perform the CompressedTuple. If all types in Ts are
// empty classes, then CompressedTuple<Ts...> is itself an empty class.
//
// To access the members, use member .get<N>() function.
//
// Eg:
// absl::container_internal::CompressedTuple<int, T1, T2, T3> value(7, t1, t2,
// t3);
// assert(value.get<0>() == 7);
// T1& t1 = value.get<1>();
// const T2& t2 = value.get<2>();
// ...
//
// http://en.cppreference.com/w/cpp/language/ebo
template <typename... Ts>
class ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple
: private internal_compressed_tuple::CompressedTupleImpl<
CompressedTuple<Ts...>, absl::index_sequence_for<Ts...>> {
private:
template <int I>
using ElemT = internal_compressed_tuple::ElemT<CompressedTuple, I>;
public:
constexpr CompressedTuple() = default;
explicit constexpr CompressedTuple(Ts... base)
: CompressedTuple::CompressedTupleImpl(absl::forward<Ts>(base)...) {}
template <int I>
ElemT<I>& get() {
return internal_compressed_tuple::Storage<CompressedTuple, I>::get();
}
template <int I>
constexpr const ElemT<I>& get() const {
return internal_compressed_tuple::Storage<CompressedTuple, I>::get();
}
};
// Explicit specialization for a zero-element tuple
// (needed to avoid ambiguous overloads for the default constructor).
template <>
class ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple<> {};
} // namespace container_internal
} // inline namespace lts_2018_12_18
} // namespace absl
#undef ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC
#endif // ABSL_CONTAINER_INTERNAL_COMPRESSED_TUPLE_H_
| [
"michael@loki.network"
] | michael@loki.network |
258144496cf38f636646452170343f0a09ee292b | 3cd34a7401a7a04141a92f8d1b2e56cab2c7ec8a | /samples/super.cpp | 479fa8906e550f93b66d79d54c2895b5313cf726 | [
"MIT"
] | permissive | arbrk1/typeclasses_cpp | 6d9022458c3e004358aabaf150b33f6e37ba8c9f | 7bb180f0daaa7dfeb84387f9913c99b99702be2c | refs/heads/master | 2021-07-09T21:02:35.297292 | 2020-07-05T15:41:07 | 2020-07-05T15:41:07 | 157,772,080 | 12 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 389 | cpp | #include "../tc.hpp"
// an example of constrained definition
template<class T>
struct Foo {};
template<class T>
struct Bar { TC_REQUIRE(Foo<T>); };
struct Quuz {};
template<> TC_INSTANCE(Foo<Quuz>, {}); // ### TRY TO REMOVE ###
template<> TC_INSTANCE(Bar<Quuz>, {});
int main() {
TC_IMPL(Bar<Quuz>) BarQuuz;
// Does not compile if the Foo<Quuz> instance is removed.
}
| [
"arbrk1@gmail.com"
] | arbrk1@gmail.com |
6f8385e71165b3534a59632d8fa10668c0e199b6 | 005c33655b6260cc5e0ff2087471e6e0a2226a01 | /CAssembler/include/instructions.h | 72533b70864c67052a60ef1262b7cc403a1cf07f | [
"MIT"
] | permissive | zeFresk/CASM | 11c76af18b782961a92dc4d5e313594f5fee9cef | 38cb88ca51799894c5c3e46a26f821b971a40850 | refs/heads/master | 2020-03-30T05:00:47.934265 | 2018-11-03T21:23:54 | 2018-11-03T21:29:31 | 150,774,606 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,435 | h | /*
All existing instructions and their parameters
*/
#ifndef instruction_h
#define instructions_h
#include "regexs.h"
#include "assembler.h"
#include <unordered_map>
#include <string>
#include <limits>
#include <regex>
#include <cstdint>
using opcode = std::uint8_t;
// Functions we will use
// retrieve opcode given instruction name
// instruction must be correct !
opcode instruction_opcode(std::string const& instruction_name);
// tells if parameter is compatible with given instruction
bool is_valid_instruction_parameter(std::string const& instruction_name, std::string const& parameter);
// tells if instruction is a valid one
bool is_valid_instruction(std::string const& instruction_name);
// We will not have to go here !
namespace _impl {
constexpr opcode special_op = std::numeric_limits<opcode>::max();
struct parameter_data {
opcode id;
std::regex reg_params;
};
using map_type = std::unordered_map<std::string, parameter_data>;
// Singleton which map every instruction to its id and correct parameters
class Instructions
{
public:
// Return all instructions and initialize them if not already done
static Instructions& get()
{
static Instructions instance;
return instance;
}
// typedefs
using mapped_type = map_type::mapped_type;
using key_type = map_type::key_type;
using iterator = map_type::iterator;
using const_iterator = map_type::const_iterator;
// Redirecting to unordered_map access functions
mapped_type& operator[](key_type const& key);
mapped_type& at(key_type const& key);
mapped_type const& at(key_type const& key) const;
// Redirecting to unordered_map iterator related functions
iterator begin() noexcept;
const_iterator begin() const noexcept;
const_iterator cbegin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
const_iterator cend() const noexcept;
// Redirecting to unordered_map find
iterator find(const key_type& key);
const_iterator find(const key_type& key) const;
private:
// real map of instructions
std::unordered_map<std::string, parameter_data> instructions_;
Instructions();
// Create the inside map
void create_map();
~Instructions() = default;
Instructions(const Instructions&) = delete;
Instructions& operator=(const Instructions&) = delete;
};
}
#endif
| [
"8807862+zeFresk@users.noreply.github.com"
] | 8807862+zeFresk@users.noreply.github.com |
b56d03e343eb82a077e3b7651f55d1bd64cf2500 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/git/gumtree/git_function_2672.cpp | 3a33d5aaf13ded060b6267494a0c7fc8fc499ee1 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 173 | cpp | static void warn_unspecified_push_default_configuration(void)
{
static int warn_once;
if (warn_once++)
return;
warning("%s\n", _(warn_unspecified_push_default_msg));
} | [
"993273596@qq.com"
] | 993273596@qq.com |
d23bfadcb341f80ba6c66885b20227774ddb9e76 | 04b1803adb6653ecb7cb827c4f4aa616afacf629 | /chromeos/services/multidevice_setup/public/cpp/fake_multidevice_setup_client.cc | 08ef0747cc3470aecac6d418a246be58fff6774e | [
"BSD-3-Clause"
] | permissive | Samsung/Castanets | 240d9338e097b75b3f669604315b06f7cf129d64 | 4896f732fc747dfdcfcbac3d442f2d2d42df264a | refs/heads/castanets_76_dev | 2023-08-31T09:01:04.744346 | 2021-07-30T04:56:25 | 2021-08-11T05:45:21 | 125,484,161 | 58 | 49 | BSD-3-Clause | 2022-10-16T19:31:26 | 2018-03-16T08:07:37 | null | UTF-8 | C++ | false | false | 5,364 | cc | // Copyright 2018 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 "chromeos/services/multidevice_setup/public/cpp/fake_multidevice_setup_client.h"
namespace chromeos {
namespace multidevice_setup {
FakeMultiDeviceSetupClient::FakeMultiDeviceSetupClient()
: host_status_with_device_(GenerateDefaultHostStatusWithDevice()),
feature_states_map_(GenerateDefaultFeatureStatesMap()) {}
FakeMultiDeviceSetupClient::~FakeMultiDeviceSetupClient() {
DCHECK(get_eligible_host_devices_callback_queue_.empty());
DCHECK(set_host_args_queue_.empty());
DCHECK(set_feature_enabled_state_args_queue_.empty());
DCHECK(retry_set_host_now_callback_queue_.empty());
DCHECK(trigger_event_for_debugging_type_and_callback_queue_.empty());
}
void FakeMultiDeviceSetupClient::SetHostStatusWithDevice(
const HostStatusWithDevice& host_status_with_device) {
if (host_status_with_device == host_status_with_device_)
return;
host_status_with_device_ = host_status_with_device;
MultiDeviceSetupClient::NotifyHostStatusChanged(host_status_with_device_);
}
void FakeMultiDeviceSetupClient::SetFeatureStates(
const FeatureStatesMap& feature_states_map) {
if (feature_states_map == feature_states_map_)
return;
feature_states_map_ = feature_states_map;
MultiDeviceSetupClient::NotifyFeatureStateChanged(feature_states_map_);
}
void FakeMultiDeviceSetupClient::SetFeatureState(
mojom::Feature feature,
mojom::FeatureState feature_state) {
if (feature_states_map_[feature] == feature_state)
return;
feature_states_map_[feature] = feature_state;
MultiDeviceSetupClient::NotifyFeatureStateChanged(feature_states_map_);
}
void FakeMultiDeviceSetupClient::InvokePendingGetEligibleHostDevicesCallback(
const multidevice::RemoteDeviceRefList& eligible_devices) {
std::move(get_eligible_host_devices_callback_queue_.front())
.Run(eligible_devices);
get_eligible_host_devices_callback_queue_.pop();
}
void FakeMultiDeviceSetupClient::InvokePendingSetHostDeviceCallback(
const std::string& expected_device_id,
const std::string& expected_auth_token,
bool success) {
DCHECK_EQ(expected_device_id, std::get<0>(set_host_args_queue_.front()));
DCHECK_EQ(expected_auth_token, std::get<1>(set_host_args_queue_.front()));
std::move(std::get<2>(set_host_args_queue_.front())).Run(success);
set_host_args_queue_.pop();
}
void FakeMultiDeviceSetupClient::InvokePendingSetFeatureEnabledStateCallback(
mojom::Feature expected_feature,
bool expected_enabled,
const base::Optional<std::string>& expected_auth_token,
bool success) {
auto& tuple = set_feature_enabled_state_args_queue_.front();
DCHECK_EQ(expected_feature, std::get<0>(tuple));
DCHECK_EQ(expected_enabled, std::get<1>(tuple));
DCHECK(expected_auth_token == std::get<2>(tuple));
std::move(std::get<3>(tuple)).Run(success);
set_feature_enabled_state_args_queue_.pop();
}
void FakeMultiDeviceSetupClient::InvokePendingRetrySetHostNowCallback(
bool success) {
std::move(retry_set_host_now_callback_queue_.front()).Run(success);
retry_set_host_now_callback_queue_.pop();
}
void FakeMultiDeviceSetupClient::InvokePendingTriggerEventForDebuggingCallback(
mojom::EventTypeForDebugging expected_type,
bool success) {
DCHECK_EQ(expected_type,
trigger_event_for_debugging_type_and_callback_queue_.front().first);
std::move(trigger_event_for_debugging_type_and_callback_queue_.front().second)
.Run(success);
trigger_event_for_debugging_type_and_callback_queue_.pop();
}
void FakeMultiDeviceSetupClient::GetEligibleHostDevices(
GetEligibleHostDevicesCallback callback) {
get_eligible_host_devices_callback_queue_.push(std::move(callback));
}
void FakeMultiDeviceSetupClient::SetHostDevice(
const std::string& host_device_id,
const std::string& auth_token,
mojom::MultiDeviceSetup::SetHostDeviceCallback callback) {
set_host_args_queue_.emplace(host_device_id, auth_token, std::move(callback));
}
void FakeMultiDeviceSetupClient::RemoveHostDevice() {
num_remove_host_device_called_++;
}
const MultiDeviceSetupClient::HostStatusWithDevice&
FakeMultiDeviceSetupClient::GetHostStatus() const {
return host_status_with_device_;
}
void FakeMultiDeviceSetupClient::SetFeatureEnabledState(
mojom::Feature feature,
bool enabled,
const base::Optional<std::string>& auth_token,
mojom::MultiDeviceSetup::SetFeatureEnabledStateCallback callback) {
set_feature_enabled_state_args_queue_.emplace(feature, enabled, auth_token,
std::move(callback));
}
const MultiDeviceSetupClient::FeatureStatesMap&
FakeMultiDeviceSetupClient::GetFeatureStates() const {
return feature_states_map_;
}
void FakeMultiDeviceSetupClient::RetrySetHostNow(
mojom::MultiDeviceSetup::RetrySetHostNowCallback callback) {
retry_set_host_now_callback_queue_.push(std::move(callback));
}
void FakeMultiDeviceSetupClient::TriggerEventForDebugging(
mojom::EventTypeForDebugging type,
mojom::MultiDeviceSetup::TriggerEventForDebuggingCallback callback) {
trigger_event_for_debugging_type_and_callback_queue_.emplace(
type, std::move(callback));
}
} // namespace multidevice_setup
} // namespace chromeos
| [
"sunny.nam@samsung.com"
] | sunny.nam@samsung.com |
4404f920cb563c6062b55b5dff8d02eb83dbe514 | 64699c2a69e7362bc07fbdd59a34e1dcbd7068f9 | /9_Palindrome/main.cpp | d955e7edc95f0efd15efd2a9338dca61d5351639 | [] | no_license | yuanyind/dyy.leetcode | fb492d0771a9ce29002833e2d7af2f685fcf5d27 | b523262d142ba38437bf32d7ab2334c31d4a27d4 | refs/heads/master | 2021-01-18T22:42:06.312105 | 2016-06-05T22:36:04 | 2016-06-05T22:36:04 | 41,131,783 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 346 | cpp | //
// main.cpp
// Palindrome
//
// Created by 杜袁茵 on 15/8/23.
// Copyright (c) 2015年 杜袁茵. All rights reserved.
//
#include <iostream>
#include "solution.cpp"
int main(int argc, const char * argv[]) {
Solution *s=new Solution();
bool result=s->isPalindrome(3323);
std::cout<<result<<std::endl;
return 0;
}
| [
"ydcoding@gmail.com"
] | ydcoding@gmail.com |
f890b375ca4f9e757b647f0c6224290bbacfdd3f | 4c04bfa2b0dd91250e35bce2886954830299bb80 | /src/test/blockencodings_tests.cpp | 767330d387b63a6011451a8ceb821e2a2f2a65c8 | [
"MIT"
] | permissive | thehomosapien/dclr | 6a81a5fcd761b6fb7cf21f5d1c7e64d8d6e0c941 | dba88f2ad6359addaa66f1875792cc8c4f30d686 | refs/heads/master | 2020-07-04T03:28:50.754864 | 2019-08-13T12:27:40 | 2019-08-13T12:27:40 | 202,137,473 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,002 | cpp | // Copyright (c) 2017-2018 The Bitcoin Core developers
// Copyright (c) 2017 The Raven Core developers
// Copyright (c) 2018 The Rito Core developers
// Copyright (c) 2019 The DCLRcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "blockencodings.h"
#include "consensus/merkle.h"
#include "chainparams.h"
#include "random.h"
#include "test/test_dclr.h"
#include <boost/test/unit_test.hpp>
std::vector<std::pair<uint256, CTransactionRef>> extra_txn;
struct RegtestingSetup : public TestingSetup
{
RegtestingSetup() : TestingSetup(CBaseChainParams::REGTEST)
{}
};
BOOST_FIXTURE_TEST_SUITE(blockencodings_tests, RegtestingSetup)
static CBlock BuildBlockTestCase()
{
CBlock block;
CMutableTransaction tx;
tx.vin.resize(1);
tx.vin[0].scriptSig.resize(10);
tx.vout.resize(1);
tx.vout[0].nValue = 42;
block.vtx.resize(3);
block.vtx[0] = MakeTransactionRef(tx);
block.nVersion = 42;
block.hashPrevBlock = InsecureRand256();
block.nBits = 0x207fffff;
tx.vin[0].prevout.hash = InsecureRand256();
tx.vin[0].prevout.n = 0;
block.vtx[1] = MakeTransactionRef(tx);
tx.vin.resize(10);
for (size_t i = 0; i < tx.vin.size(); i++)
{
tx.vin[i].prevout.hash = InsecureRand256();
tx.vin[i].prevout.n = 0;
}
block.vtx[2] = MakeTransactionRef(tx);
bool mutated;
block.hashMerkleRoot = BlockMerkleRoot(block, &mutated);
assert(!mutated);
while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce;
return block;
}
// Number of shared use_counts we expect for a tx we haven't touched
// == 2 (mempool + our copy from the GetSharedTx call)
#define SHARED_TX_OFFSET 2
BOOST_AUTO_TEST_CASE(simple_round_trip_test)
{
BOOST_TEST_MESSAGE("Running Simple Round Trip Test");
CTxMemPool pool;
TestMemPoolEntryHelper entry;
CBlock block(BuildBlockTestCase());
pool.addUnchecked(block.vtx[2]->GetHash(), entry.FromTx(*block.vtx[2]));
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
// Do a simple ShortTxIDs RT
{
CBlockHeaderAndShortTxIDs shortIDs(block, true);
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << shortIDs;
CBlockHeaderAndShortTxIDs shortIDs2;
stream >> shortIDs2;
PartiallyDownloadedBlock partialBlock(&pool);
BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK);
BOOST_CHECK(partialBlock.IsTxAvailable(0));
BOOST_CHECK(!partialBlock.IsTxAvailable(1));
BOOST_CHECK(partialBlock.IsTxAvailable(2));
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1);
size_t poolSize = pool.size();
pool.removeRecursive(*block.vtx[2]);
BOOST_CHECK_EQUAL(pool.size(), poolSize - 1);
CBlock block2;
{
PartiallyDownloadedBlock tmp = partialBlock;
BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_INVALID); // No transactions
partialBlock = tmp;
}
// Wrong transaction
{
PartiallyDownloadedBlock tmp = partialBlock;
partialBlock.FillBlock(block2, {block.vtx[2]}); // Current implementation doesn't check txn here, but don't require that
partialBlock = tmp;
}
bool mutated;
BOOST_CHECK(block.hashMerkleRoot != BlockMerkleRoot(block2, &mutated));
CBlock block3;
BOOST_CHECK(partialBlock.FillBlock(block3, {block.vtx[1]}) == READ_STATUS_OK);
BOOST_CHECK_EQUAL(block.GetHash().ToString(), block3.GetHash().ToString());
BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block3, &mutated).ToString());
BOOST_CHECK(!mutated);
}
}
class TestHeaderAndShortIDs
{
// Utility to encode custom CBlockHeaderAndShortTxIDs
public:
CBlockHeader header;
uint64_t nonce;
std::vector<uint64_t> shorttxids;
std::vector<PrefilledTransaction> prefilledtxn;
explicit TestHeaderAndShortIDs(const CBlockHeaderAndShortTxIDs &orig)
{
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << orig;
stream >> *this;
}
explicit TestHeaderAndShortIDs(const CBlock &block) :
TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs(block, true))
{}
uint64_t GetShortID(const uint256 &txhash) const
{
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << *this;
CBlockHeaderAndShortTxIDs base;
stream >> base;
return base.GetShortID(txhash);
}
ADD_SERIALIZE_METHODS;
template<typename Stream, typename Operation>
inline void SerializationOp(Stream &s, Operation ser_action)
{
READWRITE(header);
READWRITE(nonce);
size_t shorttxids_size = shorttxids.size();
READWRITE(VARINT(shorttxids_size));
shorttxids.resize(shorttxids_size);
for (size_t i = 0; i < shorttxids.size(); i++)
{
uint32_t lsb = shorttxids[i] & 0xffffffff;
uint16_t msb = (shorttxids[i] >> 32) & 0xffff;
READWRITE(lsb);
READWRITE(msb);
shorttxids[i] = (uint64_t(msb) << 32) | uint64_t(lsb);
}
READWRITE(prefilledtxn);
}
};
BOOST_AUTO_TEST_CASE(non_coinbase_preforward_rt_test)
{
BOOST_TEST_MESSAGE("Running Non Coinbase Forward RT Test");
CTxMemPool pool;
TestMemPoolEntryHelper entry;
CBlock block(BuildBlockTestCase());
pool.addUnchecked(block.vtx[2]->GetHash(), entry.FromTx(*block.vtx[2]));
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
uint256 txhash;
// Test with pre-forwarding tx 1, but not coinbase
{
TestHeaderAndShortIDs shortIDs(block);
shortIDs.prefilledtxn.resize(1);
shortIDs.prefilledtxn[0] = {1, block.vtx[1]};
shortIDs.shorttxids.resize(2);
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetHash());
shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetHash());
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << shortIDs;
CBlockHeaderAndShortTxIDs shortIDs2;
stream >> shortIDs2;
PartiallyDownloadedBlock partialBlock(&pool);
BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK);
BOOST_CHECK(!partialBlock.IsTxAvailable(0));
BOOST_CHECK(partialBlock.IsTxAvailable(1));
BOOST_CHECK(partialBlock.IsTxAvailable(2));
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1);
CBlock block2;
{
PartiallyDownloadedBlock tmp = partialBlock;
BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_INVALID); // No transactions
partialBlock = tmp;
}
// Wrong transaction
{
PartiallyDownloadedBlock tmp = partialBlock;
partialBlock.FillBlock(block2, {block.vtx[1]}); // Current implementation doesn't check txn here, but don't require that
partialBlock = tmp;
}
bool mutated;
BOOST_CHECK(block.hashMerkleRoot != BlockMerkleRoot(block2, &mutated));
CBlock block3;
PartiallyDownloadedBlock partialBlockCopy = partialBlock;
BOOST_CHECK(partialBlock.FillBlock(block3, {block.vtx[0]}) == READ_STATUS_OK);
BOOST_CHECK_EQUAL(block.GetHash().ToString(), block3.GetHash().ToString());
BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block3, &mutated).ToString());
BOOST_CHECK(!mutated);
txhash = block.vtx[2]->GetHash();
block.vtx.clear();
block2.vtx.clear();
block3.vtx.clear();
BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); // + 1 because of partialBlockCopy.
}
BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
}
BOOST_AUTO_TEST_CASE(sufficient_preforward_rt_test)
{
BOOST_TEST_MESSAGE("Running Sufficient Preforward RT Test");
CTxMemPool pool;
TestMemPoolEntryHelper entry;
CBlock block(BuildBlockTestCase());
pool.addUnchecked(block.vtx[1]->GetHash(), entry.FromTx(*block.vtx[1]));
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
uint256 txhash;
// Test with pre-forwarding coinbase + tx 2 with tx 1 in mempool
{
TestHeaderAndShortIDs shortIDs(block);
shortIDs.prefilledtxn.resize(2);
shortIDs.prefilledtxn[0] = {0, block.vtx[0]};
shortIDs.prefilledtxn[1] = {1, block.vtx[2]}; // id == 1 as it is 1 after index 1
shortIDs.shorttxids.resize(1);
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetHash());
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << shortIDs;
CBlockHeaderAndShortTxIDs shortIDs2;
stream >> shortIDs2;
PartiallyDownloadedBlock partialBlock(&pool);
BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK);
BOOST_CHECK(partialBlock.IsTxAvailable(0));
BOOST_CHECK(partialBlock.IsTxAvailable(1));
BOOST_CHECK(partialBlock.IsTxAvailable(2));
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1);
CBlock block2;
PartiallyDownloadedBlock partialBlockCopy = partialBlock;
BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_OK);
BOOST_CHECK_EQUAL(block.GetHash().ToString(), block2.GetHash().ToString());
bool mutated;
BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block2, &mutated).ToString());
BOOST_CHECK(!mutated);
txhash = block.vtx[1]->GetHash();
block.vtx.clear();
block2.vtx.clear();
BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); // + 1 because of partialBlockCopy.
}
BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
}
BOOST_AUTO_TEST_CASE(empty_block_round_trip_test)
{
BOOST_TEST_MESSAGE("Running Empty BLock Round Trip Test");
CTxMemPool pool;
CMutableTransaction coinbase;
coinbase.vin.resize(1);
coinbase.vin[0].scriptSig.resize(10);
coinbase.vout.resize(1);
coinbase.vout[0].nValue = 42;
CBlock block;
block.vtx.resize(1);
block.vtx[0] = MakeTransactionRef(std::move(coinbase));
block.nVersion = 42;
block.hashPrevBlock = InsecureRand256();
block.nBits = 0x207fffff;
bool mutated;
block.hashMerkleRoot = BlockMerkleRoot(block, &mutated);
assert(!mutated);
while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce;
// Test simple header round-trip with only coinbase
{
CBlockHeaderAndShortTxIDs shortIDs(block, false);
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << shortIDs;
CBlockHeaderAndShortTxIDs shortIDs2;
stream >> shortIDs2;
PartiallyDownloadedBlock partialBlock(&pool);
BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK);
BOOST_CHECK(partialBlock.IsTxAvailable(0));
CBlock block2;
std::vector<CTransactionRef> vtx_missing;
BOOST_CHECK(partialBlock.FillBlock(block2, vtx_missing) == READ_STATUS_OK);
BOOST_CHECK_EQUAL(block.GetHash().ToString(), block2.GetHash().ToString());
BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block2, &mutated).ToString());
BOOST_CHECK(!mutated);
}
}
BOOST_AUTO_TEST_CASE(transactions_request_serialization_test)
{
BOOST_TEST_MESSAGE("Running Transaction Request Serialization Test");
BlockTransactionsRequest req1;
req1.blockhash = InsecureRand256();
req1.indexes.resize(4);
req1.indexes[0] = 0;
req1.indexes[1] = 1;
req1.indexes[2] = 3;
req1.indexes[3] = 4;
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << req1;
BlockTransactionsRequest req2;
stream >> req2;
BOOST_CHECK_EQUAL(req1.blockhash.ToString(), req2.blockhash.ToString());
BOOST_CHECK_EQUAL(req1.indexes.size(), req2.indexes.size());
BOOST_CHECK_EQUAL(req1.indexes[0], req2.indexes[0]);
BOOST_CHECK_EQUAL(req1.indexes[1], req2.indexes[1]);
BOOST_CHECK_EQUAL(req1.indexes[2], req2.indexes[2]);
BOOST_CHECK_EQUAL(req1.indexes[3], req2.indexes[3]);
}
BOOST_AUTO_TEST_SUITE_END()
| [
"rishabhshukla@opulasoft.com"
] | rishabhshukla@opulasoft.com |
9789f74c3bfd7eeae6499428f2cf41eef6276a53 | 53f6502591f35c86e8bf1b4b867c6bdcea7a6a32 | /Prime_Seeker/Prime_Seeker/main.cpp | 8a17724c076ec661e25f0b81911d987c06432745 | [] | no_license | fiberleif/ASE-personal-project | 31e0aaefada835136cc895afea9a51badf864bf5 | 4511753ebea9150bc8f04a309b89de1492ea5e0c | refs/heads/master | 2021-01-10T11:28:02.256088 | 2015-10-26T12:27:56 | 2015-10-26T12:27:56 | 44,725,149 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,519 | cpp | #include<stdio.h>
#include<iostream>
#include<vector>
#include<time.h>
#include"bigint.h"
#include"constant.h"
#define _BIGINT_LIBRARY_
int main(int argc,char *argv[])
{
clock_t start_ = clock();
#if defined (_BIGINT_LIBRARY_)
Bigint::Bigint init(2);
Bigint::Bigint zero(0);
std::vector<Bigint::Bigint> prime_(1,init);
int prime_size = atoi (argv[1]);
Bigint::Bigint number(3);
while (prime_.size() < prime_size)
{
bool flag = 1;
Bigint::Bigint number_sqrt = number;
for (std::vector<Bigint::Bigint>::iterator prime_iter_ = prime_.begin(); prime_iter_ != prime_.end(); prime_iter_++)
{
if ((*prime_iter_) > number_sqrt)
{
break;
}
else
{
if ((number%(*prime_iter_)) == zero)
{
flag = 0;
break;
}
}
}
if (flag == 1)
{
prime_.push_back(number);
}
number = number + init;
}
printf("The pre-set prime size is %d\n", prime_size);
printf("The prime sequence is under:\n");
for (std::vector<Bigint::Bigint>::iterator prime_iter_ = prime_.begin(); prime_iter_ != prime_.end(); prime_iter_++)
{
(*prime_iter_).vector_printf();
cout << endl;
}
#else
std::vector<long long> prime_(1,2);
int prime_size = atoi(argv[1]);
long long number = 3;
while (prime_.size() < prime_size)
{
bool flag = 1;
double number_sqrt = sqrt(number);
for (std::vector<long long>::iterator prime_iter_ = prime_.begin(); prime_iter_ != prime_.end(); prime_iter_++)
{
if ((*prime_iter_) > number_sqrt)
{
break;
}
else
{
if ((number%(*prime_iter_)) == 0)
{
flag = 0;
break;
}
}
}
if (flag == 1)
{
prime_.push_back(number);
}
number = number + 2;
}
printf("The pre-set prime size is %d\n", prime_size);
printf("The prime sequence is under:\n");
for (std::vector<long long>::iterator prime_iter_ = prime_.begin(); prime_iter_ != prime_.end(); prime_iter_++)
{
printf("%ld\n", *prime_iter_);
}
#endif
printf("Total process time cost:%f\n", (clock() - start_) / (double)CLOCKS_PER_SEC);
return 0;
} | [
"v-guoql@microsoft.com"
] | v-guoql@microsoft.com |
0aa3b9ae0a839956bd2854fb30ee4461d0b7dd7f | 2251a3606c97b564ffba0f16c0865d8b7f5fce31 | /runtime/vm/cpu_x64.cc | 295a2e60fbbc8fd841128959fddccf1e42f08d11 | [] | no_license | syntheticpp/dartruntime | b531c4dc1c7cb8f6c2be5e12030a44ee067fbd4a | 189c705b0a6a0b525f3642f964e51d13937fa453 | refs/heads/master | 2016-09-08T01:16:48.304350 | 2013-11-26T11:18:00 | 2013-11-26T11:18:00 | 2,958,662 | 7 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 593 | cc | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/globals.h"
#if defined(TARGET_ARCH_X64)
#include "vm/cpu.h"
#include "vm/constants_x64.h"
#include "vm/heap.h"
#include "vm/isolate.h"
#include "vm/object.h"
namespace dart {
void CPU::FlushICache(uword start, uword size) {
// Nothing to be done here.
}
const char* CPU::Id() {
return "x64";
}
} // namespace dart
#endif // defined TARGET_ARCH_X64
| [
"asiva@google.com@260f80e4-7a28-3924-810f-c04153c831b5"
] | asiva@google.com@260f80e4-7a28-3924-810f-c04153c831b5 |
da3652bcc6e4cb5042f00219d4966d0ae535895f | 8d2b7f36f2b06499edef329e106ecab2848cc9dd | /450 Ques/Strings/KMP Algorithm.cpp | 8cba2b95b93fe2a543121439a1f4a72bb8ce0fcc | [
"MIT"
] | permissive | Benson1198/CPP | c2bbd2625615418a0d42aa7cfe1891cd29e09fbb | b12494becadc9431303cfdb51c5134dc68c679c3 | refs/heads/main | 2023-03-08T00:32:23.000754 | 2021-02-26T18:33:22 | 2021-02-26T18:33:22 | 301,605,290 | 0 | 1 | null | 2020-10-06T09:43:00 | 2020-10-06T03:37:55 | C++ | UTF-8 | C++ | false | false | 1,260 | cpp | #include<bits/stdc++.h>
using namespace std;
void LPSarrayUtil(char *pat,int m,int *lps){
int len=0;
lps[0] = 0;
int i=1;
while(i<m){
if (pat[i] == pat[len]) {
len++;
lps[i] = len;
i++;
}
else
{
if (len != 0) {
len = lps[len - 1];
}
else
{
lps[i] = 0;
i++;
}
}
}
}
void KMPSearch(char *pat,char *txt,vector<int> &ans){
int n = strlen(txt);
int m = strlen(pat);
int lps[m];
LPSarrayUtil(pat,m,lps);
int i=0;
int j=0;
while(i<n){
if(pat[i] == txt[j]){
i++;
j++;
}
if(j==m){
ans.emplace_back(i-j);
j = lps[j-1];
}
else if(i<n && pat[i] != txt[j]){
if(j != 0){
j = lps[j-1];
}
else{
i++;
}
}
}
}
int main(){
char txt[] = "ABABDABACDABABCABAB";
char pat[] = "ABABCABAB";
vector<int> ans;
KMPSearch(pat, txt,ans);
for(int i=0;i<ans.size();i++){
cout << i << " ";
}
return 0;
} | [
"bensonpx1198@gmail.com"
] | bensonpx1198@gmail.com |
4cae942f08bfba74278ada6148cc37e525cdee79 | 536656cd89e4fa3a92b5dcab28657d60d1d244bd | /chrome/browser/extensions/extension_action_unittest.cc | c279b96c21bcf1745613b1a6105abf62e4b8f6c0 | [
"BSD-3-Clause"
] | permissive | ECS-251-W2020/chromium | 79caebf50443f297557d9510620bf8d44a68399a | ac814e85cb870a6b569e184c7a60a70ff3cb19f9 | refs/heads/master | 2022-08-19T17:42:46.887573 | 2020-03-18T06:08:44 | 2020-03-18T06:08:44 | 248,141,336 | 7 | 8 | BSD-3-Clause | 2022-07-06T20:32:48 | 2020-03-18T04:52:18 | null | UTF-8 | C++ | false | false | 7,491 | cc | // Copyright (c) 2012 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 "chrome/browser/extensions/extension_action.h"
#include "chrome/common/extensions/api/extension_action/action_info.h"
#include "extensions/common/extension_builder.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace extensions {
namespace {
std::unique_ptr<ExtensionAction> CreateAction(const ActionInfo& action_info) {
scoped_refptr<const Extension> extension = ExtensionBuilder("Test").Build();
return std::make_unique<ExtensionAction>(*extension, action_info);
}
} // namespace
TEST(ExtensionActionTest, Title) {
ActionInfo action_info(ActionInfo::TYPE_PAGE);
action_info.default_title = "Initial Title";
std::unique_ptr<ExtensionAction> action = CreateAction(action_info);
ASSERT_EQ("Initial Title", action->GetTitle(1));
action->SetTitle(ExtensionAction::kDefaultTabId, "foo");
ASSERT_EQ("foo", action->GetTitle(1));
ASSERT_EQ("foo", action->GetTitle(100));
action->SetTitle(100, "bar");
ASSERT_EQ("foo", action->GetTitle(1));
ASSERT_EQ("bar", action->GetTitle(100));
action->SetTitle(ExtensionAction::kDefaultTabId, "baz");
ASSERT_EQ("baz", action->GetTitle(1));
action->ClearAllValuesForTab(100);
ASSERT_EQ("baz", action->GetTitle(100));
}
TEST(ExtensionActionTest, Visibility) {
std::unique_ptr<ExtensionAction> action =
CreateAction(ActionInfo(ActionInfo::TYPE_PAGE));
ASSERT_FALSE(action->GetIsVisible(1));
action->SetIsVisible(ExtensionAction::kDefaultTabId, true);
ASSERT_TRUE(action->GetIsVisible(1));
ASSERT_TRUE(action->GetIsVisible(100));
action->SetIsVisible(ExtensionAction::kDefaultTabId, false);
ASSERT_FALSE(action->GetIsVisible(1));
ASSERT_FALSE(action->GetIsVisible(100));
action->SetIsVisible(100, true);
ASSERT_FALSE(action->GetIsVisible(1));
ASSERT_TRUE(action->GetIsVisible(100));
action->ClearAllValuesForTab(100);
ASSERT_FALSE(action->GetIsVisible(1));
ASSERT_FALSE(action->GetIsVisible(100));
std::unique_ptr<ExtensionAction> browser_action =
CreateAction(ActionInfo(ActionInfo::TYPE_BROWSER));
ASSERT_TRUE(browser_action->GetIsVisible(1));
}
TEST(ExtensionActionTest, Icon) {
ActionInfo action_info(ActionInfo::TYPE_PAGE);
action_info.default_icon.Add(16, "icon16.png");
std::unique_ptr<ExtensionAction> page_action = CreateAction(action_info);
ASSERT_TRUE(page_action->default_icon());
EXPECT_EQ("icon16.png",
page_action->default_icon()->Get(
16, ExtensionIconSet::MATCH_EXACTLY));
EXPECT_EQ("",
page_action->default_icon()->Get(
17, ExtensionIconSet::MATCH_BIGGER));
}
TEST(ExtensionActionTest, Badge) {
std::unique_ptr<ExtensionAction> action =
CreateAction(ActionInfo(ActionInfo::TYPE_PAGE));
ASSERT_EQ("", action->GetExplicitlySetBadgeText(1));
action->SetBadgeText(ExtensionAction::kDefaultTabId, "foo");
ASSERT_EQ("foo", action->GetExplicitlySetBadgeText(1));
ASSERT_EQ("foo", action->GetExplicitlySetBadgeText(100));
action->SetBadgeText(100, "bar");
ASSERT_EQ("foo", action->GetExplicitlySetBadgeText(1));
ASSERT_EQ("bar", action->GetExplicitlySetBadgeText(100));
action->SetBadgeText(ExtensionAction::kDefaultTabId, "baz");
ASSERT_EQ("baz", action->GetExplicitlySetBadgeText(1));
action->ClearAllValuesForTab(100);
ASSERT_EQ("baz", action->GetExplicitlySetBadgeText(100));
}
TEST(ExtensionActionTest, DisplayBadgeText) {
constexpr int kFirstTabId = 1;
constexpr int kSecondTabId = 2;
std::unique_ptr<ExtensionAction> action =
CreateAction(ActionInfo(ActionInfo::TYPE_PAGE));
ASSERT_EQ("", action->GetDisplayBadgeText(kFirstTabId));
action->SetDNRActionCount(kFirstTabId, 10 /* action_count */);
ASSERT_EQ("10", action->GetDisplayBadgeText(kFirstTabId));
action->SetBadgeText(ExtensionAction::kDefaultTabId, "foo");
ASSERT_EQ("10", action->GetDisplayBadgeText(kFirstTabId));
ASSERT_EQ("foo", action->GetDisplayBadgeText(kSecondTabId));
action->SetDNRActionCount(kFirstTabId, 0 /* action_count */);
ASSERT_EQ("foo", action->GetDisplayBadgeText(kFirstTabId));
action->SetBadgeText(kFirstTabId, "bar");
ASSERT_EQ("bar", action->GetDisplayBadgeText(kFirstTabId));
action->SetDNRActionCount(kFirstTabId, 100 /* action_count */);
ASSERT_EQ("bar", action->GetDisplayBadgeText(kFirstTabId));
action->ClearAllValuesForTab(kFirstTabId);
ASSERT_EQ("foo", action->GetDisplayBadgeText(kFirstTabId));
}
TEST(ExtensionActionTest, BadgeTextColor) {
std::unique_ptr<ExtensionAction> action =
CreateAction(ActionInfo(ActionInfo::TYPE_PAGE));
ASSERT_EQ(0x00000000u, action->GetBadgeTextColor(1));
action->SetBadgeTextColor(ExtensionAction::kDefaultTabId, 0xFFFF0000u);
ASSERT_EQ(0xFFFF0000u, action->GetBadgeTextColor(1));
ASSERT_EQ(0xFFFF0000u, action->GetBadgeTextColor(100));
action->SetBadgeTextColor(100, 0xFF00FF00);
ASSERT_EQ(0xFFFF0000u, action->GetBadgeTextColor(1));
ASSERT_EQ(0xFF00FF00u, action->GetBadgeTextColor(100));
action->SetBadgeTextColor(ExtensionAction::kDefaultTabId, 0xFF0000FFu);
ASSERT_EQ(0xFF0000FFu, action->GetBadgeTextColor(1));
action->ClearAllValuesForTab(100);
ASSERT_EQ(0xFF0000FFu, action->GetBadgeTextColor(100));
}
TEST(ExtensionActionTest, BadgeBackgroundColor) {
std::unique_ptr<ExtensionAction> action =
CreateAction(ActionInfo(ActionInfo::TYPE_PAGE));
ASSERT_EQ(0x00000000u, action->GetBadgeBackgroundColor(1));
action->SetBadgeBackgroundColor(ExtensionAction::kDefaultTabId,
0xFFFF0000u);
ASSERT_EQ(0xFFFF0000u, action->GetBadgeBackgroundColor(1));
ASSERT_EQ(0xFFFF0000u, action->GetBadgeBackgroundColor(100));
action->SetBadgeBackgroundColor(100, 0xFF00FF00);
ASSERT_EQ(0xFFFF0000u, action->GetBadgeBackgroundColor(1));
ASSERT_EQ(0xFF00FF00u, action->GetBadgeBackgroundColor(100));
action->SetBadgeBackgroundColor(ExtensionAction::kDefaultTabId,
0xFF0000FFu);
ASSERT_EQ(0xFF0000FFu, action->GetBadgeBackgroundColor(1));
action->ClearAllValuesForTab(100);
ASSERT_EQ(0xFF0000FFu, action->GetBadgeBackgroundColor(100));
}
TEST(ExtensionActionTest, PopupUrl) {
GURL url_unset;
GURL url_foo("http://www.example.com/foo.html");
GURL url_bar("http://www.example.com/bar.html");
GURL url_baz("http://www.example.com/baz.html");
ActionInfo action_info(ActionInfo::TYPE_PAGE);
action_info.default_popup_url = url_foo;
std::unique_ptr<ExtensionAction> action = CreateAction(action_info);
ASSERT_EQ(url_foo, action->GetPopupUrl(1));
ASSERT_EQ(url_foo, action->GetPopupUrl(100));
ASSERT_TRUE(action->HasPopup(1));
ASSERT_TRUE(action->HasPopup(100));
action->SetPopupUrl(ExtensionAction::kDefaultTabId, url_unset);
ASSERT_EQ(url_unset, action->GetPopupUrl(1));
ASSERT_EQ(url_unset, action->GetPopupUrl(100));
ASSERT_FALSE(action->HasPopup(1));
ASSERT_FALSE(action->HasPopup(100));
action->SetPopupUrl(100, url_bar);
ASSERT_EQ(url_unset, action->GetPopupUrl(1));
ASSERT_EQ(url_bar, action->GetPopupUrl(100));
action->SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz);
ASSERT_EQ(url_baz, action->GetPopupUrl(1));
ASSERT_EQ(url_bar, action->GetPopupUrl(100));
action->ClearAllValuesForTab(100);
ASSERT_EQ(url_baz, action->GetPopupUrl(1));
ASSERT_EQ(url_baz, action->GetPopupUrl(100));
}
} // namespace extensions
| [
"pcding@ucdavis.edu"
] | pcding@ucdavis.edu |
c92f349ebc33a9bc2a51cce3227f14aa9c65c37b | d2b2fa78e9dc829cdce175abd104044bf11282b3 | /src/rpcprotocol.cpp | 7ca26e82357c6733cf8bb958ba6e0e5117693962 | [
"MIT"
] | permissive | Nugetzrul3/topa | 79b453181b02b32710a7a34739c9348b99c045d9 | 33205f374c05a77b1b4f2359c54a16ab2608a425 | refs/heads/master | 2021-03-22T17:12:14.651399 | 2020-03-15T00:30:44 | 2020-03-15T00:30:44 | 247,385,900 | 0 | 0 | MIT | 2020-03-15T02:09:56 | 2020-03-15T02:09:55 | null | UTF-8 | C++ | false | false | 4,215 | cpp | // Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2019 TopaChain LLC
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "httpserver.h"
#include "rpcprotocol.h"
#include "random.h"
#include "tinyformat.h"
#include "primitives/transaction.h"
#include "util.h"
#include "utilstrencodings.h"
#include "utiltime.h"
#include "version.h"
#include <stdint.h>
#include <fstream>
using namespace std;
/**
* JSON-RPC protocol. TopaChain speaks version 1.0 for maximum compatibility,
* but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were
* unspecified (HTTP errors and contents of 'error').
*
* 1.0 spec: http://json-rpc.org/wiki/specification
* 1.2 spec: http://jsonrpc.org/historical/json-rpc-over-http.html
* http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx
*/
string JSONRPCRequest(const string& strMethod, const UniValue& params, const UniValue& id)
{
UniValue request(UniValue::VOBJ);
request.push_back(Pair("method", strMethod));
request.push_back(Pair("params", params));
request.push_back(Pair("id", id));
return request.write() + "\n";
}
UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id)
{
UniValue reply(UniValue::VOBJ);
if (!error.isNull())
reply.push_back(Pair("result", NullUniValue));
else
reply.push_back(Pair("result", result));
reply.push_back(Pair("error", error));
reply.push_back(Pair("id", id));
return reply;
}
string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id)
{
UniValue reply = JSONRPCReplyObj(result, error, id);
return reply.write() + "\n";
}
UniValue JSONRPCError(int code, const string& message)
{
UniValue error(UniValue::VOBJ);
error.push_back(Pair("code", code));
error.push_back(Pair("message", message));
return error;
}
/** Username used when cookie authentication is in use (arbitrary, only for
* recognizability in debugging/logging purposes)
*/
static const std::string COOKIEAUTH_USER = "__cookie__";
/** Default name for auth cookie file */
static const std::string COOKIEAUTH_FILE = ".cookie";
boost::filesystem::path GetAuthCookieFile()
{
boost::filesystem::path path(GetArg("-rpccookiefile", COOKIEAUTH_FILE));
if (!path.is_complete()) path = GetDataDir() / path;
return path;
}
bool GenerateAuthCookie(std::string *cookie_out)
{
unsigned char rand_pwd[32];
GetRandBytes(rand_pwd, 32);
std::string cookie = COOKIEAUTH_USER + ":" + EncodeBase64(&rand_pwd[0],32);
/** the umask determines what permissions are used to create this file -
* these are set to 077 in init.cpp unless overridden with -sysperms.
*/
std::ofstream file;
boost::filesystem::path filepath = GetAuthCookieFile();
file.open(filepath.string().c_str());
if (!file.is_open()) {
LogPrintf("Unable to open cookie authentication file %s for writing\n", filepath.string());
return false;
}
file << cookie;
file.close();
LogPrintf("Generated RPC authentication cookie %s\n", filepath.string());
if (cookie_out)
*cookie_out = cookie;
return true;
}
bool GetAuthCookie(std::string *cookie_out)
{
std::ifstream file;
std::string cookie;
boost::filesystem::path filepath = GetAuthCookieFile();
file.open(filepath.string().c_str());
if (!file.is_open())
return false;
std::getline(file, cookie);
file.close();
if (cookie_out)
*cookie_out = cookie;
return true;
}
void DeleteAuthCookie()
{
try {
boost::filesystem::remove(GetAuthCookieFile());
} catch (const boost::filesystem::filesystem_error& e) {
LogPrintf("%s: Unable to remove random auth cookie file: %s\n", __func__, e.what());
}
}
int RPCSerializationFlags()
{
int flag = 0;
if (GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) == 0)
flag |= SERIALIZE_TRANSACTION_NO_WITNESS;
return flag;
} | [
"shadow42@nocomail.com"
] | shadow42@nocomail.com |
b910f929af287e36a4b807d538823e55b8b97e39 | 803f0fbc5973ff31fd5faca5c0f2981b2c52a591 | /C++/CodeForces/R-451-div.2/pE.cpp | 7684ddefac0ccd33da173750569cb8b6651c3d92 | [] | no_license | MiohitoKiri5474/CodesBackUp | 00ab52bd55732b8164a42cffd664407878f4390e | 4247fa032c8e88259dcc3992a21c510b6f2e8850 | refs/heads/master | 2023-08-09T14:46:10.445697 | 2023-08-04T01:12:58 | 2023-08-04T01:12:58 | 126,162,563 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,529 | cpp | // by. MiohitoKiri5474
#include<bits/stdc++.h>
#pragma GCC optimize ( "O3" )
#pragma loop_opt ( on )
using namespace std;
typedef long long LL;
// define tools
#define REPP(i,f,s) for ( int i = f ; i < s ; i++ )
#define REPM(i,f,s) for ( int i = f ; i >= s ; i-- )
#define REPALL(i,n) for ( auto &i: n )
#define debuger cout << "111\n"
#define SP(a,b) swap ( a, b )
#define MEM(n,i) memset ( n, i, sizeof n )
// define pair
typedef pair < LL, LL > pll;
typedef pair < int, int > pii;
#define F first
#define S second
#define mp make_pair
// define vector && some stl's api
template < class T > using vec = vector < T >;
typedef vec < int > vi;
typedef vec < LL > vl;
#define pb push_back
#define ep emplace_back
#define SZ(n) ( int ) n.size()
#define CLR(n) n.clear()
#define BEG(n) n.begin()
#define END(n) n.end()
#define EMP(n) n.empty()
#define RSZ(n,s) n.resize ( s )
#define ALL(n) BEG ( n ), END ( n )
#define PIO(n) REPALL ( i, n ) cout << i << ' '; cout << '\n'
// define set
typedef set < int > si;
typedef set < LL > sl;
#define FID(n,Index) n.find ( Index ) != n.end()
// graph
#define GRE(T,edge) vec < T > edge[maxN]
#define UNI(u,v,edge) edge[u].pb ( v ), edge[v].pb ( u )
#define UNIw(u,v,w,edge) edge[u].pb ( mp ( v, w ) ), edge[v].pb ( mp ( u, w ) )
// IO
#define GL(n) getline ( cin, n )
// define stack, queue, pri-queue
template < class T > using stack = stack < T, vec < T > >;
template < class T > using MaxHeap = priority_queue < T, vec < T >, less < T > >;
template < class T > using MinHeap = priority_queue < T, vec < T >, greater < T > >;
// define stringstream
#define sstr stringstream
// number~ remember change maxN
#define INF 0x3f3f3f3f
#define maxN 100005
// ready~ go!
// let's coding and have fun!
// I can solve this problem!
int main(){
ios::sync_with_stdio ( false );
cin.tie ( 0 );
cout.tie ( 0 );
LL n, stop, zero, res;
double d;
cin >> n;
vi data1, data2;
REPP ( i, 0, n ){
cin >> stop;
d = sqrt ( stop );
d == ( int ) d ? data1.pb ( stop ) : data2.pb ( stop );
}
n /= 2;
if ( SZ ( data1 ) == SZ ( data2 ) )
stop = 0;
else if ( SZ ( data1 ) > n ){
stop = SZ ( data1 ) - n;
zero = 0;
REPALL ( i, data1 ) if ( !i ) zero++;
if ( zero > n ){
zero -= n;
stop += zero;
}
}
else{
CLR ( data1 );
REPALL ( i, data2 ){
res = sqrt ( i );
stop = res + 1;
data1.pb ( min ( i - res * res, stop * stop - i ) );
}
stop = 0;
sort ( ALL ( data1 ) );
REPP ( i, 0, SZ ( data2 ) - n ) stop += data1[i];
}
cout << stop << '\n';
} | [
"lltzpp@gmail.com"
] | lltzpp@gmail.com |
d83c09a9bec5b165c34a454e547a073c31615d21 | f986e39d6edfe83006c01efbc61de0c0a18ed172 | /boost_asio_tcp_example/inc/MessageConnection.h | 6e9394da1f3f6db0e286748eef9ddfc592e6e403 | [] | no_license | PanosGeorgiadis/AccelDevTools | bbeff55d7b6cf45bf4cecb672e57f2488ae15409 | ea2db020b4507218f0acc2e37694c2493e877246 | refs/heads/master | 2022-09-06T05:06:14.002134 | 2022-08-17T13:44:54 | 2022-08-17T13:44:54 | 207,584,757 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,889 | h | #pragma once
#include "CeosProtocol/ConnectionItf.h"
#include "CeosProtocol/MessageConnectionItf.h"
namespace Server {
namespace CeosProtocol {
class MessageConnection : public MessageConnectionItf
{
public:
explicit MessageConnection(std::unique_ptr<ConnectionItf> pConnection);
bool IsConnected() const override;
uint32_t ReceiveRawPacket() override;
void StartReceiveRawPacket(const std::function<void(uint32_t)>& handler, const std::function<void(const boost::system::error_code& error)>& errorHandler) override;
void SendRawPacket(uint32_t content) override;
boost::system::error_code SendRawPacketNoThrow(uint32_t content) override;
std::shared_ptr<CommandMessage> ReceiveCommand() override;
void StartReceiveCommand(const std::function<void(const std::shared_ptr<CommandMessage>&)>& handler, const std::function<void(const boost::system::error_code& error)>& errorHandler) override;
std::shared_ptr<AsynchronousResult<CommandMessage>> StartReceiveCommand() override;
std::shared_ptr<ResultMessage> ReceiveResult() override;
void StartReceiveResult(const std::function<void(const std::shared_ptr<ResultMessage>&)>& handler, const std::function<void(const boost::system::error_code& error)>& errorHandler) override;
std::shared_ptr<AsynchronousResult<ResultMessage>> StartReceiveResult() override;
std::shared_ptr<EventMessage> ReceiveEvent() override;
void StartReceiveEvent(const std::function<void(const std::shared_ptr<EventMessage>&)>& handler, const std::function<void(const boost::system::error_code& error)>& errorHandler) override;
std::shared_ptr<AsynchronousResult<EventMessage>> StartReceiveEvent() override;
void SendMessagePacket(const Message& message) override;
boost::system::error_code SendMessagePacketNoThrow(const Message& message) override;
private:
static void EndReceiveRawPacket(const std::shared_ptr<RawData>& pRawData, const std::function<void(uint32_t)>& handler);
template <typename T> std::shared_ptr<T> ReceiveMessage();
template <typename T> void StartReceiveMessage(const std::function<void(const std::shared_ptr<T>&)>& handler, const std::function<void(const boost::system::error_code& error)>& errorHandler);
template <typename T> void EndReceiveMessageSize(uint32_t messageSize, const std::function<void(const std::shared_ptr<T>&)>& handler, const std::function<void(const boost::system::error_code& error)>& errorHandler);
template <typename T> void EndReceiveMessageContent(const std::shared_ptr<RawData>& pData, const std::function<void(const std::shared_ptr<T>&)>& handler, const std::function<void(const boost::system::error_code& error)>& errorHandler);
template <typename T> std::shared_ptr<AsynchronousResult<T>> StartReceiveMessage();
std::unique_ptr<ConnectionItf> m_pConnection;
};
} // namespace Ceos
} // namespace Server
| [
"PanosGeorgiadis@users.noreply.github.com"
] | PanosGeorgiadis@users.noreply.github.com |
7de7cacde579b695599701f0af1131dafbc8a433 | 8c033791b2ed917f12dbf9eaf9163f4288f88851 | /Vorlesungsbeispiele/MRT2_VL-8_OPCUA_FirstSteps_PiServer/src/task.h | fa8f6a3634f2539e1910b3c777faf3d61dc90c84 | [
"MIT"
] | permissive | plt-tud/PLT_MRT_ARM-RPi2 | 4a34e6dd1d8e29858acce50efc1f39ace5e416e2 | dc164c7ccbb55467149610c2f62c224deef17885 | refs/heads/master | 2021-12-24T03:52:56.536957 | 2021-11-19T08:22:37 | 2021-11-19T08:22:37 | 43,895,032 | 5 | 9 | MIT | 2021-11-19T08:22:38 | 2015-10-08T14:40:46 | C | UTF-8 | C++ | false | false | 1,802 | h | /*
* Copyright (c) 2018 Chris Paul Iatrou chris_paul.iatrou@tu-dresden.de
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef TASK_H
#define TASK_H
#include <thread>
#include <list>
#include <time.h>
using namespace std;
class task
{
protected:
bool runThread;
bool running;
thread *t;
timespec interval;
list<task*> children;
void workerThread();
virtual void init();
virtual void run() = 0;
virtual void terminate();
public:
task(struct timespec interval) : runThread(false), running(false), interval(interval) {};
task() : runThread(false), running(false), interval((struct timespec) {1,0} ) {};
virtual ~task();
void start();
void stop();
};
#endif // TASK_H
| [
"Chris_Paul.Iatrou@tu-dresden.de"
] | Chris_Paul.Iatrou@tu-dresden.de |
2b5f1f2e5e516ba38860d8a249186c53ed711265 | b081fb02d00646451828a4e8863f849fbc1bd4be | /MCTS/Leaf-Parallel/Threes.cpp | 951db22053c7c4a295c5e23434cf57ff6ffcf90a | [] | no_license | kevinlee87/Parallelization-of-Threes | 4d297b691eae866b7e44c5f0f9d5ac6439533f8f | bb2ccfc4c75b2662aa6dfaa6f78b796c4d0b52cb | refs/heads/master | 2020-04-16T04:10:15.537870 | 2019-01-11T15:30:09 | 2019-01-11T15:30:09 | 165,257,731 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,238 | cpp | #include <cstdlib>
#include <random>
#include <vector>
#include <chrono>
#include <fstream>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <pthread.h>
#include "board.h"
#include "move.h"
#define nthread 12
#define forstate for(int i = 0 ; i < 16 ; i++) for(int j = 0 ; j < 4 ; j++) for(int k = 0 ; k < 4 ; k++)
std::default_random_engine engine;
std::uniform_int_distribution <int> dis(0,3);
std::vector<Move> record;
int next[4][4] = {{12, 13, 14, 15}, {0, 4, 8, 12}, {0, 1, 2, 3}, {3, 7, 11, 15}};
unsigned long long ret[nthread];
pthread_t thread[nthread];
class Node
{
public:
Board board;
unsigned long long score, time;
int num_next, dir;
Node **next, *parent;
Node()
{
score = time = 0;
num_next = 0;
parent = NULL;
next = NULL;
dir = 4;
}
}*target;
time_t get_time()
{
auto now = std::chrono::system_clock::now().time_since_epoch();
return std::chrono::duration_cast<std::chrono::milliseconds>(now).count();
}
Node* select(Node *s)
{
Node *ret = NULL;
double value;
if(!s || !s->num_next) return s;
for(int i = 0 ; i < s->num_next ; i++)
{
if(!s->next[i]) continue;
if(!ret || s->next[i]->score / (double)s->next[i]->time > value)
{
ret = s->next[i];
value = s->next[i]->score / (double)s->next[i]->time;
}
}
return select(ret);
}
void expand(Node *s)
{
Board board;
if(s->dir == 4)
{
s->num_next = 4;
s->next = new Node*[4];
for(int i = 0 ; i < 4 ; i++) s->next[i] = NULL;
for(int i = 0 ; i < 4 ; i++)
{
board = s->board;
if(board.slide(i) == -1) continue;
s->next[i] = new Node;
s->next[i]->dir = i;
s->next[i]->board = board;
s->next[i]->parent = s;
}
}
else
{
s->num_next = 12;
s->next = new Node*[12];
for(int i = 0 ; i < 12 ; i++) s->next[i] = NULL;
for(int i = 0 ; i < 4 ; i++)
{
if(!s->board.take_place(next[s->dir][i], 0)) continue;
for(int j = 1 ; j <= 3 ; j++)
{
s->next[i+j-1] = new Node;
s->next[i+j-1]->board = s->board;
s->next[i+j-1]->board.take_place(next[s->dir][i], j);
s->next[i+j-1]->dir = 4;
s->next[i+j-1]->parent = s;
}
}
}
}
unsigned long long run(Board board, int dir, bool bag[3], int k)
{
Board tmp;
int move[4];
if(dir == 4)
{
dir = -1;
move[0] = 0;
move[1] = 1;
move[2] = 2;
move[3] = 3;
std::shuffle(move, move + 4, engine);
for(int i = 0 ; i < 4 ; i++)
{
tmp = board;
if(tmp.slide(move[i]) != -1) {dir = move[i]; break;}
}
if(dir == -1) return 100 * std::log(board.count_score());
board.slide(dir);
return run(board, dir, bag, k);
}
else
{
if(!bag[0] && !bag[1] && !bag[2]) bag[0] = bag[1] = bag[2] = 1;
int place = -1, s, num = 0;
move[0] = next[dir][0];
move[1] = next[dir][1];
move[2] = next[dir][2];
move[3] = next[dir][3];
std::shuffle(move, move + 4, engine);
for(int i = 0 ; i < 4 ; i++)
if(board.take_place(move[i], 0)) {place = move[i]; break;}
while(1)
{
s = dis(engine);
if(!s) continue;
if(!bag[s-1]) continue;
bag[s-1] = 0;
board.take_place(place, s);
break;
}
return run(board, 4, bag, k);
}
}
void *multithread(void *data)
{
bool bag[3];
unsigned long long *value = (unsigned long long*)data;
*value = 0;
for(int i = 0 ; i < 1000 ; i++)
{
bag[0] = bag[1] = bag[2] = 1;
*value += run(target->board, target->dir, bag, value - ret);
}
}
void simulate(Node *s)
{
for(int i = 0 ; i < s->num_next ; i++)
{
if(s->next[i])
{
s->next[i]->time = nthread * 1000;
target = s->next[i];
for(int i = 0 ; i < nthread ; i++) pthread_create(&thread[i], NULL, multithread, (void*)&ret[i]);
// for(int i = 0 ; i < 500 ; i++)
// {
// bool bag[3] = {1, 1, 1};
// target->score += run(target->board, target->dir, bag, 1);
// }
for(int i = 0 ; i < nthread ; i++) pthread_join(thread[i], NULL);
for(int i = 0 ; i < nthread ; i++) target->score += ret[i];
}
}
}
void update(Node *s)
{
if(s->dir == 4)
{
double tmp = -1;
for(int i = 0 ; i < 4 ; i++)
{
if(!s->next[i]) continue;
if(tmp == -1 || s->next[i]->score / (double)s->next[i]->time > tmp)
{
tmp = s->next[i]->score / (double)s->next[i]->time;
s->score = s->next[i]->score;
s->time = s->next[i]->time;
}
}
}
else
{
s->score = s->time = 0;
for(int i = 0 ; i < 12 ; i++)
{
if(!s->next[i]) continue;
s->score += s->next[i]->score;
s->time += s->next[i]->time;
}
}
if(s->parent) update(s->parent);
}
void del(Node *s)
{
for(int i = 0 ; i < s->num_next ; i++) if(s->next[i]) del(s->next[i]);
delete(s);
}
int MCTS(Board &board)
{
int dir = -1;
double value;
Node *cur, *head = new Node;
head->board = board;
head->dir = 4;
time_t start = get_time();
while(get_time() - start < 1000)
{
cur = select(head);
if(!cur) {std::cout << "NULL\n"; break;}
expand(cur);
simulate(cur);
update(cur);
}
for(int i = 0 ; i < 4 ; i++)
{
if(!head->next[i]) continue;
if(dir == -1 || head->next[i]->score / (double)head->next[i]->time > value)
{
dir = i;
value = head->next[i]->score / (double)head->next[i]->time;
}
}
del(head);
return dir;
}
void Computer(Board &board, const int dir, Move &p)
{
static int bag[3] = {1, 2, 3}, bag_index;
static int location[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
if(dir == 4)
{
bag_index = 0;
shuffle(bag, bag + 3, engine);
shuffle(location, location + 16, engine);
for(int i = 0 ; i < 9 ; i++)
{
board.take_place(location[i], bag[i % 3]);
record.push_back(Move(location[i], bag[i % 3]));
}
bag_index = 3;
}
else
{
if(bag_index == 3)
{
bag_index = 0;
shuffle(bag, bag + 3, engine);
}
shuffle(next[dir], next[dir] + 4, engine);
for(int i = 0 ; i < 4 ; i++) if(board.take_place(next[dir][i], bag[bag_index])) {p = Move(next[dir][i], bag[bag_index]); break;}
bag_index++;
}
}
void Player(Board &board, Move &p)
{
int dir = MCTS(board);
if(dir == -1) {p = Move(); return ;}
board.slide(dir);
p = Move(dir);
}
int main(int n, char **argv)
{
//std::ios_base::sync_with_stdio(0);
//std::cin.tie(0);
int num_game = atoi(argv[1]), dir;
engine.seed(time(NULL));
Board board;
Move p;
time_t time_start, time_end;
std::printf("Start Playing.\n");
std::ofstream fout("result.txt");
for(int i = 0 ; i < num_game ; i++)
{
std::cout << i << "\n";
record.clear();
board = Board();
Computer(board, 4, p);
time_start = get_time();
while(true)
{
//std::cout << "Player\n" << board << "\n";
Player(board, p);
//std::cout << "Computer\n" << board << "\n";
if(p.slide() == -1) break;
record.push_back(p);
Computer(board, p.slide(), p);
record.push_back(p);
}
time_end = get_time();
fout << "0516310:N-Tuple@" << time_start << "|";
for(int j = 0 ; j < record.size() ; j++) fout << record[j];
fout << "|N-Tuple@" << time_end << "\n";
}
printf("Complete playing.\n");
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
f6c87bf47542b655b1ddce9dd8717c01f3aa2f30 | f00c001f62456ade8715574cdf709f1e454c485b | /Engine/Shaders/BasicShader.cpp | 377227fdd986ef3e1b0deb2433b3f33f87a458a9 | [] | no_license | m-hegyi/3dEnginePrototype | d0e9032d2dbc47679339078e7fdb8c6719154e75 | 439bb1b7a73edb98ca8e3c0d63e235f0ca0d4511 | refs/heads/master | 2020-06-20T21:07:54.268818 | 2019-07-16T18:37:26 | 2019-07-16T18:37:26 | 197,249,095 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,621 | cpp | #include "BasicShader.h"
#include <fstream>
BasicShader::BasicShader()
{
};
BasicShader::BasicShader(std::shared_ptr<Graphics> graphics)
{
m_Graphics = graphics;
};
BasicShader::~BasicShader()
{
};
bool BasicShader::Initialize(HWND hwnd)
{
if (!InitializeShader(hwnd, "BaseVertexTexture.cso", "BasePixelTexture.cso"))
{
return false;
}
return true;
}
bool BasicShader::Render(int vertexCount, int instanceCount,
DirectX::SimpleMath::Matrix worldMatrix, DirectX::SimpleMath::Matrix viewMatrix, DirectX::SimpleMath::Matrix projectionMatrix,
ID3D11ShaderResourceView * texture)
{
if (!SetShaderParameters(vertexCount, instanceCount, worldMatrix, viewMatrix, projectionMatrix, texture))
{
return false;
}
RenderShader(vertexCount, instanceCount);
return true;
}
bool BasicShader::InitializeShader(HWND hwnd, std::string vertexShaderFile, std::string pixelShaderFile)
{
HRESULT result;
Microsoft::WRL::ComPtr<ID3D10Blob> errorMessage;
D3D11_INPUT_ELEMENT_DESC polygonLayout[2];
unsigned int numElements;
// Initialize the pointers this function will use to null.
errorMessage.Reset();
auto vertexShader = std::make_unique<ShaderFileType>();
auto pixelShader = std::make_unique<ShaderFileType>();
if (!GetShaderFile(vertexShaderFile, vertexShader.get()))
{
return false;
}
auto device = m_Graphics->getRenderer()->getDevice();
result = device->CreateVertexShader(vertexShader->data, vertexShader->length, NULL, m_vertexShader.ReleaseAndGetAddressOf());
if (FAILED(result)) {
return false;
}
if (!GetShaderFile(pixelShaderFile, pixelShader.get())) {
return false;
}
result = device->CreatePixelShader(pixelShader->data, pixelShader->length, NULL, m_pixelShader.ReleaseAndGetAddressOf());
if (FAILED(result)) {
return false;
}
polygonLayout[0].SemanticName = "POSITION";
polygonLayout[0].SemanticIndex = 0;
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
polygonLayout[0].InputSlot = 0;
polygonLayout[0].AlignedByteOffset = 0;
polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
polygonLayout[0].InstanceDataStepRate = 0;
polygonLayout[1].SemanticName = "TEXCOORD";
polygonLayout[1].SemanticIndex = 0;
polygonLayout[1].Format = DXGI_FORMAT_R32G32_FLOAT;
polygonLayout[1].InputSlot = 0;
polygonLayout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
polygonLayout[1].InstanceDataStepRate = 0;
numElements = sizeof(polygonLayout) / sizeof(polygonLayout[0]);
// Create the vertex input layout.
result = device->CreateInputLayout(polygonLayout, numElements, vertexShader->data,
vertexShader->length, m_layout.ReleaseAndGetAddressOf());
if (FAILED(result))
{
return false;
}
if (!CreateBuffers())
{
return false;
}
if (!CreateSamplerState())
{
return false;
}
delete vertexShader->data;
delete pixelShader->data;
return true;
}
void BasicShader::ResetShader()
{
m_vertexShader->Release();
m_vertexShader.Reset();
m_pixelShader->Release();
m_pixelShader.Reset();
m_layout->Release();
m_layout.Reset();
m_samplerState->Release();
m_samplerState.Reset();
}
void BasicShader::RenderShader(int vertexCount, int instanceCount)
{
auto deviceContext = m_Graphics->getRenderer()->getContext();
//Set the vertex input layout.
deviceContext->IASetInputLayout(m_layout.Get());
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext->VSSetShader(m_vertexShader.Get(), NULL, 0);
deviceContext->PSSetShader(m_pixelShader.Get(), NULL, 0);
// Set the sampler state
//
// TODO: switchable
//
deviceContext->PSSetSamplers(0, 1, m_samplerState.GetAddressOf());
// Render
deviceContext->DrawInstanced(vertexCount, instanceCount, 0, 0);
//deviceContext->DrawIndexed(indexCount, 0, 0);
//
// TODO: properly count the rendered instance
//
m_Graphics->UpdateStat(instanceCount);
}
bool BasicShader::CreateBuffers()
{
if (!CreateMatrixBuffer())
{
return false;
}
return true;
}
bool BasicShader::CreateSamplerState()
{
D3D11_SAMPLER_DESC samplerDesc;
HRESULT result;
// Sampler Description
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
result = m_Graphics->getRenderer()->getDevice()->CreateSamplerState(&samplerDesc, m_samplerState.ReleaseAndGetAddressOf());
if (FAILED(result)) {
return false;
}
return true;
}
bool BasicShader::CreateMatrixBuffer()
{
HRESULT result;
D3D11_BUFFER_DESC matrixBufferDesc;
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
result = m_Graphics->getRenderer()->getDevice()->CreateBuffer(&matrixBufferDesc, NULL, m_matrixBuffer.ReleaseAndGetAddressOf());
if (FAILED(result))
{
return false;
}
return true;
}
bool BasicShader::SetShaderParameters(int vertexCount, int instanceCount,
DirectX::SimpleMath::Matrix worldMatrix, DirectX::SimpleMath::Matrix viewMatrix, DirectX::SimpleMath::Matrix projectionMatrix,
ID3D11ShaderResourceView * texture)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
unsigned int bufferNumber;
// Transpose the matrices to prepare them for the shader.
worldMatrix = worldMatrix.Transpose();
viewMatrix = viewMatrix.Transpose();
projectionMatrix = projectionMatrix.Transpose();
auto deviceContext = m_Graphics->getRenderer()->getContext();
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(m_matrixBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
return false;
}
// Get a pointer to the data in the constant buffer.
dataPtr = (MatrixBufferType*)mappedResource.pData;
// Copy the matrices into the constant buffer.
dataPtr->world = worldMatrix;
dataPtr->view = viewMatrix;
dataPtr->projection = projectionMatrix;
// Unlock the constant buffer.
deviceContext->Unmap(m_matrixBuffer.Get(), 0);
// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;
// Finanly set the constant buffer in the vertex shader with the updated values.
deviceContext->VSSetConstantBuffers(bufferNumber, 1, m_matrixBuffer.GetAddressOf());
// Set shader texture resource in the pixel shader
deviceContext->PSSetShaderResources(0, 1, &texture);
return true;
}
bool BasicShader::GetShaderFile(std::string fileName, ShaderFileType * shaderData)
{
int length;
std::ifstream file(fileName.c_str(), std::ios::binary);
if (file.bad()) {
file.close();
return false;
}
file.seekg(0, std::ios::end);
length = size_t(file.tellg());
auto buffer = new char[length];
file.seekg(0, std::ios::beg);
file.read(buffer, length);
shaderData->data = buffer;
shaderData->length = length;
file.close();
return true;
} | [
"mario.hegyi93@gmail.com"
] | mario.hegyi93@gmail.com |
b0dcc3ddf8657b7d6d9a74f564b2df818d73aa19 | 1c59f72a7d3d272803ca3ebf216c6fdf837e3862 | /DuiDesigner/PyModuleImport.cpp | 52992c894036521f3f462bb6e2205e60bd5e4c2c | [
"BSD-2-Clause",
"MIT"
] | permissive | BlankTec/pyui4win | aa55976c6e0e508181b6bdb6fc6f1ad6147584d3 | de5293561b38545f3a5c03a2fef55e1a97d6c0bd | refs/heads/master | 2020-12-08T16:21:29.356816 | 2020-01-09T12:03:08 | 2020-01-09T12:03:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,146 | cpp | #include "stdafx.h"
#ifdef _DEBUG
#undef _DEBUG
#include <Python.h>
#define _DEBUG
#else
#include <Python.h>
#endif
#include<boost/python.hpp>
#include "PyModuleImport.h"
#include "PyException.h"
using namespace std;
using namespace boost::python;
BOOST_PYTHON_MODULE(PyUI)
{
class_<PyLog>("PyLog")
.def("LogText", &PyLog::LogText)
;
class_<PyScript>("PyScript")
.def("RunPy", &PyScript::RunPy)
;
}
void PyExtentInit()
{
PyImport_AppendInittab("PyUI", initPyUI);
}
std::string PyScript::RunPy(std::string pyModule, std::string pyFunc)
{
std::string ret = "";
boost::python::handle<>* _module = NULL; // Module handle.
try
{
_module = new boost::python::handle<>(
PyImport_ImportModule( pyModule.c_str()));
ret = boost::python::call_method<std::string>(_module->get(), pyFunc.c_str());
}
catch(boost::python::error_already_set const &){
ret = parse_python_exception();
PyLog().LogText(ret.c_str());
PyErr_Clear();
}
catch (...)
{
if (PyErr_Occurred())
{
ret = parse_python_exception();
PyLog().LogText(ret.c_str());
PyErr_Clear();
}
}
if (_module)
delete _module;
return ret;
} | [
"huqinghua@baidu.com"
] | huqinghua@baidu.com |
2330774c81d0a6662d75e87301557ea7268cd544 | 785df77400157c058a934069298568e47950e40b | /TnbMarineBase/TnbLib/MarineBase/RepairSections/CmpSection/MarineRepairSect_CmpSection.cxx | 39bde76400218a7261596b730fc9fbd5f5bdfe86 | [] | no_license | amir5200fx/Tonb | cb108de09bf59c5c7e139435e0be008a888d99d5 | ed679923dc4b2e69b12ffe621fc5a6c8e3652465 | refs/heads/master | 2023-08-31T08:59:00.366903 | 2023-08-31T07:42:24 | 2023-08-31T07:42:24 | 230,028,961 | 9 | 3 | null | 2023-07-20T16:53:31 | 2019-12-25T02:29:32 | C++ | UTF-8 | C++ | false | false | 501 | cxx | #include <MarineRepairSect_CmpSection.hxx>
#include <MarineRepairSect_Section.hxx>
#include <TnbError.hxx>
#include <OSstream.hxx>
std::vector<std::shared_ptr<tnbLib::Pln_Curve>>
tnbLib::MarineRepairSect_CmpSection::FillingCurves() const
{
std::vector<std::shared_ptr<Pln_Curve>> allCurves;
for (const auto& x : Sections())
{
Debug_Null_Pointer(x);
auto curves = x->FillingCurves();
for (auto& c : curves)
{
allCurves.push_back(std::move(c));
}
}
return std::move(allCurves);
} | [
"aasoleimani86@gmail.com"
] | aasoleimani86@gmail.com |
e4c72f9e0da2ad7a360a69686e534192f93e12cc | 77135a35cca3782f08d49842ecf8d89f25e80a7c | /SettingEdit.h | e8f5379eb9f1b1525fdaf4b68492ed24abec681c | [] | no_license | Ben1028/Axis3 | b7672d36492bc4e0fe12c20c88816d819074d846 | 5795c6d0877b27d6c44df079355f911f81ba042e | refs/heads/master | 2021-08-20T06:17:06.565027 | 2021-01-02T15:34:59 | 2021-01-02T15:36:49 | 58,974,036 | 7 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 744 | h |
#pragma once
class CSettingEditDlg : public CDialogEx
{
public:
CSettingEditDlg(CWnd* pParent = NULL);
int iSelIndex;
CString csTable;
Database dDatabase;
CRect MinSize;
enum { IDD = IDD_SETTINGEDIT};
CListCtrl m_clcData;
CEdit m_ceID;
CEdit m_ceValue;
CButton m_cbAddEdit;
CButton m_cbDelData;
CComboBox m_ccbSettings;
protected:
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog();
afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
afx_msg void OnBnClickedAddEdit();
afx_msg void OnItemchangedItems(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnSelchangeSettings();
afx_msg void OnBnClickedDelData();
afx_msg void OnEditchangeID();
void FillData();
DECLARE_MESSAGE_MAP()
}; | [
"b.croussette@hotmail.com"
] | b.croussette@hotmail.com |
de4f1831e4ac0f7e4dcbe071ce6fb9783b373512 | a9e1884ce922cbfa2fd2eff6d2cc9895c9b2bb05 | /RenderPass.h | ffe414b06b1dfdfdb7e804562222c8c6809b0f82 | [] | no_license | VulkanWorks/vkBreaker-2D-Game | 8f7cae8bb0ad113b4400beea6854ffc7baca37b6 | 44c6fb0a31bda125cb3e7b2c4833114805375f0e | refs/heads/main | 2023-06-24T10:29:06.547591 | 2021-07-28T12:23:00 | 2021-07-28T12:23:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 341 | h | #pragma once
#include <Vulkan/vulkan.h>
#include <stdexcept>
class RenderPass {
public:
RenderPass(VkDevice device, VkFormat swapChainImageFormat);
void createRenderPass();
VkRenderPass getRenderPass() { return renderPass; }
private:
VkRenderPass renderPass;
VkFormat swapChainImageFormat;
VkDevice device;
}; | [
"noreply@github.com"
] | noreply@github.com |
3d69a89b19007f195ae0e9a250edf82d95ba5beb | 527739ed800e3234136b3284838c81334b751b44 | /include/RED4ext/Types/generated/AI/behavior/WaitTargetToFollowConditionDefinition.hpp | 0aa12920c822c0340e72dfaeaa80e206ac5cb467 | [
"MIT"
] | permissive | 0xSombra/RED4ext.SDK | 79ed912e5b628ef28efbf92d5bb257b195bfc821 | 218b411991ed0b7cb7acd5efdddd784f31c66f20 | refs/heads/master | 2023-07-02T11:03:45.732337 | 2021-04-15T16:38:19 | 2021-04-15T16:38:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 613 | hpp | #pragma once
// This file is generated from the Game's Reflection data
#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/REDhash.hpp>
#include <RED4ext/Types/generated/AI/behavior/ConditionDefinition.hpp>
namespace RED4ext
{
namespace AI::behavior {
struct WaitTargetToFollowConditionDefinition : AI::behavior::ConditionDefinition
{
static constexpr const char* NAME = "AIbehaviorWaitTargetToFollowConditionDefinition";
static constexpr const char* ALIAS = NAME;
};
RED4EXT_ASSERT_SIZE(WaitTargetToFollowConditionDefinition, 0x38);
} // namespace AI::behavior
} // namespace RED4ext
| [
"expired6978@gmail.com"
] | expired6978@gmail.com |
e14cfc5a966cb80b2e943459f4c9dbae5332ce52 | fe04056461c37ca3d4597f89f1e74fb230d616a9 | /IFEngine/IFEngine.cpp | 7252b732525635780b29c52da45788bebd8e2560 | [] | no_license | sweetmandm/IFEngine | b1e744262f3f816cc7bd0da827ac126a0f2ce10d | 416590eafe9f3c091dfc75849e3333f7d0119dc9 | refs/heads/master | 2021-09-01T07:25:50.198629 | 2017-12-25T17:05:48 | 2017-12-25T17:05:48 | 103,849,902 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,599 | cpp | //
// IFEngine.cpp
// Ramshackle
//
// Created by David Sweetman on 12/17/15.
// Copyright © 2015 tinfish. All rights reserved.
//
#include "IFEngine.hpp"
#include "GameState.hpp"
#include "Action.hpp"
#include "ActionQuestion.hpp"
#include "ActionMessage.hpp"
#include "UIController.hpp"
#include "ActionRegistry.hpp"
#include "GameEvent.hpp"
#include "GameEventStart.hpp"
#include "UIController.hpp"
#include "Description.hpp"
#include "TextUtils.hpp"
#include "NameSystem.hpp"
#include "Software.hpp"
#include "DataSearchSystem.hpp"
NS_RAM_OPEN
static IFEngine *instance = nullptr;
IFEngine* IFEngine::shared()
{
if (instance == nullptr) {
instance = new (std::nothrow) IFEngine();
}
return instance;
}
Entity* IFEngine::getPlayer() {
return IFEngine::shared()->getGameState()->getPlayer();
}
void IFEngine::begin(GameState* state)
{
if (state == nullptr) {
_gameState = GameState::makeNew();
auto action = GameEventStart::loadEvent();
_gameState->setNextAction(action);
} else {
_gameState = state;
}
playTurn();
}
void IFEngine::playTurn()
{
_gameState->getNextAction()->perform();
}
void IFEngine::performQuestion(ActionQuestion *question) {
UIController::shared()->showQuestion(question);
}
void IFEngine::performMessage(ActionMessage *message)
{
UIController::shared()->showMessage(message);
}
void IFEngine::acceptMessage(ActionMessage *message)
{
auto next = message->getNextAction().getNext();
_gameState->setNextAction(next);
_gameState->applyEmotion(message->getMessage().impact);
playTurn();
}
void IFEngine::answerQuestion(ActionQuestion *question, Answer answer)
{
question->selectAnswer(answer);
_gameState->applyEmotion(answer.impact);
auto next = question->getNextAction().getNext();
_gameState->setNextAction(next);
playTurn();
}
Action* IFEngine::loadGameEvent(GameEvent *event)
{
RAM_LOG_STR("Activating event: " + event->getName());
return _gameState->loadGameEvent(event);
}
void IFEngine::search() {
UIController::shared()->showSearchMenu();
auto sw = getPlayer()->getComponent<Software>();
auto data = DataSearchSystem::search(sw->getComputer());
if (data->textRepresentation().length() > 0) {
message(you("found coherent data:\n" + data->textRepresentation()));
} else {
message(you("found corrupted data."));
}
}
void IFEngine::learn() {
message(you("are having trouble focusing."));
}
void IFEngine::showIO() {
message(you("don't see anybody to talk to."));
}
NS_RAM_CLOSE
| [
"david@davidsweetman.com"
] | david@davidsweetman.com |
b660338cb1bff6a4aa43dcfb91f6a80bde0e824a | 49ff64160e31ea1460434908d39b8e5803b41440 | /Pathfinding_20160525/Pathfinding_20160525/Project2/Pathfinding/AStarV4.h | 10da448c6ac2ac34a7c738bf395e43ab207731d6 | [] | no_license | MidnightDrifter/CS580Proj2Pathfinding | c1d585fb59576fcf9f90639efc684a4b238bc030 | 248e44f419099dfae2800320afe92745694d6a17 | refs/heads/master | 2021-01-21T14:17:10.401683 | 2016-07-07T02:53:23 | 2016-07-07T02:53:23 | 59,779,917 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,409 | h | #pragma once
#include "AStarNodeV3.h"
#include <math.h>
#include <list>
#define SIZE_OF_MAP 40
#define CAPACITY_OF_OPEN_LIST 256
class AStarV4
{
public:
AStarV4();
~AStarV4();
int getGoalRow() const;
int getGoalCol() const;
int getStartRow() const;
int getStartCol() const;
int getOpenListSize() const;
float calculateHeuristicCost(int h, float weight, int nodeX, int nodeY, int goalX, int goalY) const;
bool isValidNode(int i, int j);
bool findPath(bool newRequest, bool isSingleStep, int heuristic, float hWeight, int startX, int startY, int goalX, int goalY, bool useAnalysis, bool fogOfWar);
AStarNodeV3 getMapNode(int i, int j);
int getSizeOfOpenList() const;
std::list<AStarNodeV3>& getRubberbandList();
void setGoalRow(int x);
void setGoalCol(int x);
void setGoal(int x, int y);
void setStartRow(int x);
void setStartCol(int y);
void setStart(int x, int y);
void clearMap();
void clearOpenList();
void clear();
void pushOpen(AStarNodeV3 n);
AStarNodeV3 popOpenMin();
void removeNodeOpen(int x, int y);
void rubberband();
private:
int goalRow;
int goalCol;
int startRow;
int startCol;
int sizeOfOpenList;
AStarNodeV3 map[SIZE_OF_MAP][SIZE_OF_MAP];
float fogOfWarMap[SIZE_OF_MAP][SIZE_OF_MAP]; //Keeps track of if a tile has / hasn't been seen
AStarNodeV3 openList[CAPACITY_OF_OPEN_LIST];
std::list<AStarNodeV3> rubberbandList;
static float SQRT2;
};
| [
"linkmasterchief@aol.com"
] | linkmasterchief@aol.com |
dc59faf3eb02756ee1995b0390991aeab1a0262c | 54354439574533934e3bbc68cb10e6098d213b5b | /PlistEditor/PlistEditor/plisteditormodelparser.h | b127c103bbdf57773bc83a46d34ca32c20655759 | [] | no_license | heleihong/tools | ddcd7b277fbb1b4e1eb7f722aedcc31f37bd2797 | 6336eefc06f7e20d379be8c8a8d838fbb1b8efb7 | refs/heads/master | 2021-01-20T10:28:32.734951 | 2017-05-08T03:53:38 | 2017-05-08T03:53:38 | 90,354,554 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 606 | h | #ifndef PLIST_EDITOR_DOM_PARSER_H_
#define PLIST_EDITOR_DOM_PARSER_H_
#include <QtXml/QDomDocument>
#include "PlistEditorModel.h"
class PListEditorModelParser
{
public:
PListEditorModelParser();
~PListEditorModelParser();
static PlistEditorModel *fromPlist(QIODevice *plist);
private:
static void parseArrayElement(const QDomElement& element, PListEditorModelItem *item);
static void parseDictElement(const QDomElement& element, PListEditorModelItem *item);
static void parseElement(const QDomElement &node, PListEditorModelItem *item);
};
#endif // PLIST_EDITOR_DOM_PARSER_H_ | [
"562126815@qq.com"
] | 562126815@qq.com |
bf57084707b14c1d6965f6e266d5a32f215ee01b | 9f81d77e028503dcbb6d7d4c0c302391b8fdd50c | /google/cloud/notebooks/quickstart/quickstart.cc | b5b3ad75c6c18041e1e8838d621f6785488fa6b8 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | googleapis/google-cloud-cpp | b96a6ee50c972371daa8b8067ddd803de95f54ba | 178d6581b499242c52f9150817d91e6c95b773a5 | refs/heads/main | 2023-08-31T09:30:11.624568 | 2023-08-31T03:29:11 | 2023-08-31T03:29:11 | 111,860,063 | 450 | 351 | Apache-2.0 | 2023-09-14T21:52:02 | 2017-11-24T00:19:31 | C++ | UTF-8 | C++ | false | false | 1,397 | cc | // Copyright 2022 Google LLC
//
// 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
//
// https://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.
//! [all]
#include "google/cloud/notebooks/v2/notebook_client.h"
#include <iostream>
int main(int argc, char* argv[]) try {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " project-id location-id\n";
return 1;
}
namespace notebooks = ::google::cloud::notebooks_v2;
auto client = notebooks::NotebookServiceClient(
notebooks::MakeNotebookServiceConnection());
auto const parent =
std::string{"projects/"} + argv[1] + "/locations/" + argv[2];
for (auto list_element : client.ListInstances(parent)) {
if (!list_element) throw std::move(list_element).status();
std::cout << list_element->DebugString() << "\n";
}
return 0;
} catch (google::cloud::Status const& status) {
std::cerr << "google::cloud::Status thrown: " << status << "\n";
return 1;
}
//! [all]
| [
"noreply@github.com"
] | noreply@github.com |
bb919050652b67950415931ddbebfc378b5d6a42 | 5456502f97627278cbd6e16d002d50f1de3da7bb | /chrome/common/pref_names_util.h | 15dd959732758209ec5c06bec369f5562521ebb9 | [
"BSD-3-Clause"
] | permissive | TrellixVulnTeam/Chromium_7C66 | 72d108a413909eb3bd36c73a6c2f98de1573b6e5 | c8649ab2a0f5a747369ed50351209a42f59672ee | refs/heads/master | 2023-03-16T12:51:40.231959 | 2017-12-20T10:38:26 | 2017-12-20T10:38:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 789 | h | // Copyright (c) 2012 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 CHROME_COMMON_PREF_NAMES_UTIL_H_
#define CHROME_COMMON_PREF_NAMES_UTIL_H_
#include <string>
namespace pref_names_util {
// Extracts the generic family and script from font name pref path |pref_path|.
// For example, if |pref_path| is "webkit.webprefs.fonts.serif.Hang", returns
// true and sets |generic_family| to "serif" and |script| to "Hang".
bool ParseFontNamePrefPath(const std::string& pref_path,
std::string* generic_family,
std::string* script);
} // namespace pref_names_util
#endif // CHROME_COMMON_PREF_NAMES_UTIL_H_
| [
"lixiaodonglove7@aliyun.com"
] | lixiaodonglove7@aliyun.com |
ba75767c3202055008d3a71142b2a489793ded01 | 725e2082a1e338b2979134c16a1ee62dc04900e7 | /StronglyConnectedComponents/graph.cpp | 8792545389ba663698bd7ac50ce8b63850e35d58 | [] | no_license | crybot/Algorithms | a861f5f43350f795dfa659ffa0899033d73dc405 | 7c6e08fe72186363c30a4d99d1f91b9eb2708b1b | refs/heads/master | 2016-08-05T13:53:51.246428 | 2013-03-12T19:13:25 | 2013-03-12T19:13:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,608 | cpp | #include "graph.h"
typedef Node Node;
typedef Edge Edge;
Graph::Graph()
{
srand (time(NULL));
}
Graph::Graph(const NodeMap & nodes)
{
srand (time(NULL));
this->nodes = nodes;
}
Graph Graph::Reverse()
{
Graph Grev;
for (Graph::iterator git = Begin(); git != End(); ++git)
{
Node node = GetNode(git);
for (Node::iterator nit = node.Begin(); nit != node.End(); ++nit)
{
Grev.AddEdge(*nit, git->first);
}
}
return Grev;
}
void Graph::AddNode(const Node & node, int index)
{
nodes.insert(std::make_pair(index, node));
}
void Graph::AddEdge(int a, int b)
{
if (nodes.find(a) == End())
{
AddNode(Node(), a);
}
if (nodes.find(b) == End())
{
AddNode(Node(), b);
}
GetNode(a).InsertNeighbour(b);
}
void Graph::AddEdge(Edge edge)
{
int a = edge.first;
int b = edge.second;
if (nodes.find(a) == End())
{
AddNode(Node(), a);
}
if (nodes.find(b) == End())
{
AddNode(Node(), b);
}
GetNode(a).InsertNeighbour(b);
}
void Graph::DeleteNode(int index)
{
nodes.erase(index);
}
unsigned Graph::NodeCount() const
{
return nodes.size();
}
void Graph::Merge(Edge edge)
{
int a = edge.first, b = edge.second;
Node& A = GetNode(a);
Node& B = GetNode(b);
for (unsigned i=0; i<B.Size(); i++) // if not references to B or self-loops add to A
{
if (B[i] != a && B[i] != b)
A.InsertNeighbour(B[i]);
}
DeleteNode(b); // always delete B
for (Graph::iterator git = Begin(); git != End(); ++git)
{
Node& node = GetNode(git);
for (unsigned i=0; i<node.Size(); i++)
{
if (node[i] == b)
node[i] = a;
if (node[i] == git->first)
{
A.DeleteNeighbour(A.Begin() + i);
i--;
}
}
}
}
void Graph::Print()
{
for(Graph::iterator it = Begin(); it != End(); ++it)
{
std::cout << it->first << " : ";
for (unsigned l=0; l<GetNode(it).Size(); l++)
{
std::cout << GetNode(it)[l] << " ";
}
std::cout << std::endl;
}
}
Edge Graph::RandomEdge()
{
int a,b;
Graph::iterator it;
Node::iterator n_it;
int r;
it = Begin();
r = rand() % NodeCount();
advance(it, r);
a = it->first;
r = rand() % it->second.Size();
n_it = it->second.Begin();
advance(n_it, r);
b = *n_it;
return Edge(a,b);
}
Node& Graph::GetNode(int index)
{
return nodes[index];
}
Node& Graph::GetNode(const iterator& it)
{
return it->second;
}
Node& Graph::GetNode(const reverse_iterator& it)
{
return it->second;
}
inline Graph::iterator Graph::Begin()
{
return nodes.begin();
}
inline Graph::iterator Graph::End()
{
return nodes.end();
}
inline Graph::reverse_iterator Graph::rBegin()
{
return nodes.rbegin();
}
inline Graph::reverse_iterator Graph::rEnd()
{
return nodes.rend();
}
std::vector<int> Graph::ComputeSCC() // returns the sizes of the 5 largest Strongly connected components
{
Graph Grev = Reverse();
Grev.DFS_Loop1();
DFS_Loop2(Grev.ordered);
std::vector<int> cp = std::vector<int>(NodeCount(), 0);
for (Graph::iterator it = Begin(); it != End(); ++it)
{
cp[GetNode(it).Leader()-1]++;
}
std::sort(cp.rbegin(), cp.rend());
cp.resize(5);
return cp;
}
void Graph::DFS_Loop1()
{
dfsLeader = 0;
for (Graph::iterator it = Begin(); it != End(); ++it)
{
GetNode(it).MarkExplored(false);
}
for (Graph::reverse_iterator it = rBegin(); it != rEnd(); ++it)
{
Node& node = GetNode(it);
if(!node.Explored())
{
int node = it->first;
dfsLeader = node;
DFS(node, true);
}
}
}
void Graph::DFS_Loop2(std::stack<int>& nodes)
{
dfsLeader = 0;
for (Graph::iterator it = Begin(); it != End(); ++it)
{
GetNode(it).MarkExplored(false);
}
while (!nodes.empty())
{
int node = nodes.top();
if(!GetNode(node).Explored())
{
dfsLeader = node;
DFS(node, false);
}
nodes.pop();
}
}
void Graph::DFS(int v, bool first)
{
Node& node = GetNode(v);
node.MarkExplored(true);
node.SetLeader(dfsLeader);
for (Node::iterator it = node.Begin(); it != node.End(); ++it)
{
if(!GetNode(*it).Explored())
{
DFS(*it, first);
}
}
if(first)
ordered.push(v);
}
| [
"crybot@hotmail.it"
] | crybot@hotmail.it |
bc3849fadcecaec38bb238d5fd7885fb4d6dee19 | 9aae83114c185a66cbc22ce63644cccf726f9b97 | /Lab1/main.cpp | 367d52a85e54e7966abbc6329083a1a2c07e990c | [] | no_license | CyberDoge/OS-labs | d03972d51710b2c5f4db415a0f23610bd899b9f6 | a26a5edba3ea83098d31e2d4b135eb8eed30ef1a | refs/heads/master | 2020-04-28T11:20:51.973513 | 2019-05-09T14:28:41 | 2019-05-09T14:28:41 | 175,234,605 | 0 | 0 | null | 2019-03-17T19:05:46 | 2019-03-12T14:53:05 | C++ | UTF-8 | C++ | false | false | 2,413 | cpp | #include <iostream>
#include <vector>
#include <math.h>
#include "function/Function.h"
#include "function/Cos.h"
#include "function/Sin.h"
#include "function/Exp.h"
#include "function/Ln.h"
using namespace std;
Function *parseString(const string &f) {
const unsigned long bracketIndex = f.rfind('(');
if (bracketIndex == string::npos) {
throw runtime_error("bad input");
}
Function *function;
if (f.rfind("cos") != string::npos) {
function = new Cos();
} else if (f.rfind("sin") != string::npos) {
function = new Sin();
} else if (f.rfind("e^") != string::npos) {
function = new Exp();
} else if (f.rfind("ln") != string::npos) {
function = new Ln();
} else throw runtime_error("bad input");
// function->setArg(stod(f.substr(bracketIndex, f.rfind(')'))));
auto mulIndex = f.rfind('*');
if (mulIndex != string::npos) {
function->setK(stod(f.substr(0, mulIndex)));
}
return function;
}
vector<Function *> *functionFactory(const string &function) {
unsigned long i = function.size();
unsigned long start = i;
auto *res = new vector<Function *>();
while (i != 0) {
if (function[i] == '+' || function[i] == '-') {
res->push_back(parseString(function.substr(i, start)));
start = i;
}
--i;
}
res->push_back(parseString(function.substr(i, start)));
return res;
}
double f(double x, vector<Function *> functions) {
double res = 0;
for (auto &function : functions) {
res += function->countValue(x);
}
return res;
//return asin(-exp(x));
}
int main() {
// string function = "0.07*e^(x) + cos(x)=x";
string functionStr[] = {
"0.07*e^(x) + cos(x)=x",
};
int iter = 0;
for (const auto &function : functionStr) {
double p, p0, eps = 0.00001;
int i = 0, N = 10000;
try {
vector<Function *> *functions = functionFactory(function);
p = f(0.3, *functions);
do {
p0 = p;
p = f(p0, *functions);
i++;
} while (abs(p - p0) > eps);
cout << "iteration " << iter << "; res = " << p << "; i = " << i << endl;
iter++;
} catch (exception e) {
cout << "bad input"<< endl;
exit(-3);
}
}
return 0;
} | [
"tagirman998@gmail.com"
] | tagirman998@gmail.com |
f1c6cbc106605f0ed889329a49159ad4be779157 | 12840d008d17df59a37997691774fa87e5f227be | /zhongzihao-personal/codeforces/385/385-2-C.cpp | 304398c5cf20afa7af101bbecdf3bdb7f0bf43b7 | [] | no_license | clatisus/ACM-ICPC-Team-Archive | 4b6c3d2dfb300f928f4f201ae156bde5f871a734 | 7410ddfa81de8750668d8ac2c334987b5af7e613 | refs/heads/master | 2022-07-21T13:03:22.768792 | 2020-01-04T11:30:43 | 2020-01-04T11:30:43 | 136,951,655 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 899 | cpp | #include<bits/stdc++.h>
const int N = 10010;
int n, m, k, fa[N], c[N], sz[N];
int find(int u){
return fa[u] == u ? u : fa[u] = find(fa[u]);
}
void unite(int u, int v){
int _u = find(u), _v = find(v);
if (_u == _v){
return;
}
fa[_u] = _v;
find(u);
}
int main(){
for (int i = 0; i < N; ++ i){
fa[i] = i;
}
scanf("%d%d%d", &n, &m, &k);
for (int i = 0; i < k; ++ i){
scanf("%d", &c[i]);
}
for (int i = 0, u, v; i < m; ++ i){
scanf("%d%d", &u, &v);
unite(u, v);
}
for (int i = 1; i <= n; ++ i){
find(i);
++ sz[fa[i]];
}
int max = 0, sit;
for (int i = 0; i < k; ++ i){
int x = sz[fa[c[i]]];
if (x > max){
max = x;
sit = i;
}
}
int ans = -m, sum = 0;
for (int i = 0; i < k; ++ i){
if (i == sit){
continue;
}
int x = sz[fa[c[i]]];
ans += x * (x - 1) >> 1;
sum += x;
}
ans += (n - sum) * (n - sum - 1) >> 1;
return printf("%d\n", ans), 0;
}
| [
"clatisus@gmail.com"
] | clatisus@gmail.com |
9bd70e877030c82a979436a84b1f71f015bbddee | f7642cd26609f69f7c19383d99dff60dac4e38d4 | /include/public/rolegen.h | 513343e35070f4cfd8c573d492d11938322fb849 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | webosose/librolegen | 87ef5d5032ebaea5f60d1a7d78dc454b50c5a11b | d29997a27b7468a9eddac904636ef9b6317946a7 | refs/heads/master | 2023-06-26T16:24:23.268444 | 2023-05-17T12:54:19 | 2023-05-17T12:54:19 | 125,007,615 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 1,297 | h | // Copyright (c) 2010-2018 LG Electronics, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
// NOTE: The header files needed by rolegen.cpp are now included there.
// The ones defined below might be used includers of rolegen.h (this file).
#if 0
#include <string>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#endif
#include <string>
using namespace std;
void ndkGenerateRole(string id, string executablePath);
// deprecated
void __attribute__((deprecated)) pdkGenerateRole(string id, string executablePath);
void roleGenerate(string templatePath, string destinationPath, string id, string executablePath);
void tritonGenerateRole(string id);
| [
"changhyeok.bae@lge.com"
] | changhyeok.bae@lge.com |
d71dd565a4ab74c3c44c03dcf0118f1d30b2907a | 3e352668b8bf4737b8173eb65ad341d59add6305 | /DiaMStu.cpp | 2d9297325fc846b57e75fe0da27ac215d31a83b7 | [] | no_license | hailinzeng/CourseRegist | 4f4c16c5aa4bf6a17b549ad2b68d357c9ac661aa | 6a77d707511b68bc8eb50da1a6cc56114eeca1ae | refs/heads/master | 2020-03-29T19:01:11.261707 | 2012-09-12T03:41:33 | 2012-09-12T03:41:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,158 | cpp | // DiaMStu.cpp : implementation file
//
#include "stdafx.h"
#include "Course_Regist.h"
#include "DiaMStu.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DiaMStu dialog
DiaMStu::DiaMStu(CWnd* pParent /*=NULL*/)
: CDialog(DiaMStu::IDD, pParent)
{
//{{AFX_DATA_INIT(DiaMStu)
m_mstusc = _T("");
m_mstuid = _T("");
m_mstunm = _T("");
m_mstubd = _T("");
m_mstugd = _T("");
m_mstust = _T("");
//}}AFX_DATA_INIT
}
void DiaMStu::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DiaMStu)
DDX_Text(pDX, IDC_MStuSC, m_mstusc);
DDX_Text(pDX, IDC_MStuID, m_mstuid);
DDX_Text(pDX, IDC_MStuNM, m_mstunm);
DDX_Text(pDX, IDC_MStuBD, m_mstubd);
DDX_Text(pDX, IDC_MStuGD, m_mstugd);
DDX_Text(pDX, IDC_MStuST, m_mstust);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DiaMStu, CDialog)
//{{AFX_MSG_MAP(DiaMStu)
ON_BN_CLICKED(IDC_MGetInfo, OnMGetInfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DiaMStu message handlers
| [
"zeng.hailin@qq.com"
] | zeng.hailin@qq.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.