blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
8bed50582edac20d0ad6ada4d15fde70c938c54c
d096cfda35a174ca930b48944598aad67c6f7067
/KeybdName/KeybdName.cpp
23add1bc127cee3ddbe521d5b34001ea2bbc166e
[ "MIT" ]
permissive
katahiromz/ImeStudy
311c85671880bf72be198a77deb61634aef127c6
ce965f20b251ddf4d7ef0eb8229675d1373c598e
refs/heads/main
2023-06-08T21:34:59.032259
2023-06-04T07:29:52
2023-06-04T07:29:52
546,967,901
11
1
null
null
null
null
UTF-8
C++
false
false
267
cpp
// KeybdName.cpp by katahiromz // License: MIT #include <windows.h> #include <imm.h> #include <stdio.h> int main(int argc, char **argv) { char sz[KL_NAMELENGTH + 1]; GetKeyboardLayoutNameA(sz); printf("GetKeyboardLayoutNameA: %s\n", sz); return 0; }
[ "katayama.hirofumi.mz@gmail.com" ]
katayama.hirofumi.mz@gmail.com
92435219f5f547606162ef8ea46418b6d66e0594
ba246ba78fbfa9980081705690cfc26ec5ca8859
/VAS_HeadtrackerConnect/build-VAS_HeadtrackerConnect_Android-Android_for_armeabi_v7a_arm64_v8a_x86_x86_64_Clang_Qt_5_15_2_android-Debug/armeabi-v7a/moc_serviceinfo.cpp
3174a2be6fdb01b572f141c99e61c302d1b1f7a0
[ "MIT" ]
permissive
funkerresch/vas_library
80d57a334f5a9575d9a27fe6910cc5dddb9b0f7f
0658616e49e86627614e9ad2382cb0b11e7d31eb
refs/heads/master
2022-12-21T22:00:33.957639
2022-07-20T09:06:35
2022-07-20T09:06:35
164,434,730
21
2
null
null
null
null
UTF-8
C++
false
false
3,935
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'serviceinfo.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.15.2) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include <memory> #include "../../../../rwacreator/bluetooth/serviceinfo.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'serviceinfo.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.15.2. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_ServiceInfo_t { QByteArrayData data[3]; char stringdata0[28]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_ServiceInfo_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_ServiceInfo_t qt_meta_stringdata_ServiceInfo = { { QT_MOC_LITERAL(0, 0, 11), // "ServiceInfo" QT_MOC_LITERAL(1, 12, 14), // "serviceChanged" QT_MOC_LITERAL(2, 27, 0) // "" }, "ServiceInfo\0serviceChanged\0" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_ServiceInfo[] = { // content: 8, // revision 0, // classname 0, 0, // classinfo 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 1, // signalCount // signals: name, argc, parameters, tag, flags 1, 0, 19, 2, 0x06 /* Public */, // signals: parameters QMetaType::Void, 0 // eod }; void ServiceInfo::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { auto *_t = static_cast<ServiceInfo *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->serviceChanged(); break; default: ; } } else if (_c == QMetaObject::IndexOfMethod) { int *result = reinterpret_cast<int *>(_a[0]); { using _t = void (ServiceInfo::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&ServiceInfo::serviceChanged)) { *result = 0; return; } } } Q_UNUSED(_a); } QT_INIT_METAOBJECT const QMetaObject ServiceInfo::staticMetaObject = { { QMetaObject::SuperData::link<QObject::staticMetaObject>(), qt_meta_stringdata_ServiceInfo.data, qt_meta_data_ServiceInfo, qt_static_metacall, nullptr, nullptr } }; const QMetaObject *ServiceInfo::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *ServiceInfo::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_ServiceInfo.stringdata0)) return static_cast<void*>(this); return QObject::qt_metacast(_clname); } int ServiceInfo::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } return _id; } // SIGNAL 0 void ServiceInfo::serviceChanged() { QMetaObject::activate(this, &staticMetaObject, 0, nullptr); } QT_WARNING_POP QT_END_MOC_NAMESPACE
[ "funker@posteo.net" ]
funker@posteo.net
f46f705739f7b58fa95fc7eefaa83bd3cb308e3f
e16b292bdd2f409e843c55df31805e2d331f1a2d
/src/qt/optionsmodel.h
53f5f3c96ecc189d90cb940f52e1ec47fd5054af
[ "MIT" ]
permissive
Visco33/test
beeffb00d5593fee01703a341c7a46784db24ebf
3735d0d80f5f1d880bd5460cc223b1d05d937b12
refs/heads/master
2020-03-14T17:51:06.887931
2018-05-24T22:19:13
2018-05-24T22:19:13
130,040,474
0
0
null
null
null
null
UTF-8
C++
false
false
3,237
h
// Copyright (c) 2011-2013 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_QT_OPTIONSMODEL_H #define BITCOIN_QT_OPTIONSMODEL_H #include "amount.h" #include <QAbstractListModel> QT_BEGIN_NAMESPACE class QNetworkProxy; QT_END_NAMESPACE /** Interface from Qt to configuration data structure for Bitcoin client. To Qt, the options are presented as a list with the different options laid out vertically. This can be changed to a tree once the settings become sufficiently complex. */ class OptionsModel : public QAbstractListModel { Q_OBJECT public: explicit OptionsModel(QObject* parent = 0); enum OptionID { StartAtStartup, // bool MinimizeToTray, // bool MapPortUPnP, // bool MinimizeOnClose, // bool ProxyUse, // bool ProxyIP, // QString ProxyPort, // int DisplayUnit, // BitcoinUnits::Unit ThirdPartyTxUrls, // QString Digits, // QString Theme, // QString Language, // QString CoinControlFeatures, // bool ThreadsScriptVerif, // int DatabaseCache, // int SpendZeroConfChange, // bool ObfuscationRounds, // int AnonymizetestAmount, //int ShowMasternodesTab, // bool Listen, // bool OptionIDRowCount, }; void Init(); void Reset(); int rowCount(const QModelIndex& parent = QModelIndex()) const; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); /** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */ void setDisplayUnit(const QVariant& value); /* Explicit getters */ bool getMinimizeToTray() { return fMinimizeToTray; } bool getMinimizeOnClose() { return fMinimizeOnClose; } int getDisplayUnit() { return nDisplayUnit; } QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; } bool getProxySettings(QNetworkProxy& proxy) const; bool getCoinControlFeatures() { return fCoinControlFeatures; } const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; } /* Restart flag helper */ void setRestartRequired(bool fRequired); bool isRestartRequired(); bool resetSettings; private: /* Qt-only settings */ bool fMinimizeToTray; bool fMinimizeOnClose; QString language; int nDisplayUnit; QString strThirdPartyTxUrls; bool fCoinControlFeatures; /* settings that were overriden by command-line */ QString strOverriddenByCommandLine; /// Add option to list of GUI options overridden through command line/config file void addOverriddenOption(const std::string& option); signals: void displayUnitChanged(int unit); void obfuscationRoundsChanged(int); void anonymizetestAmountChanged(int); void coinControlFeaturesChanged(bool); }; #endif // BITCOIN_QT_OPTIONSMODEL_H
[ "37253340+Visco33@users.noreply.github.com" ]
37253340+Visco33@users.noreply.github.com
4c319097b4377a0e8cae343b3baa79defff1e59a
1afc2ba02aaa1170db5def78ef506503073ad45b
/StepperMotorDriver.ino
d39203a43cd8a9e0e91b5595f8cd2a4f3e66f982
[]
no_license
sjuim/STEMProject
937f3474862d43144ad02216b65c07539d9f34ab
a02727933affb5bbccc43658b8307e59ec91dc7f
refs/heads/master
2023-02-26T11:41:37.499517
2021-02-06T01:27:29
2021-02-06T01:27:29
336,429,631
0
0
null
null
null
null
UTF-8
C++
false
false
1,284
ino
int PUL=7; //define Pulse pin int DIR=6; //define Direction pin int ENA=5; //define Enable Pin void setup() { pinMode (PUL, OUTPUT); pinMode (DIR, OUTPUT); pinMode (ENA, OUTPUT); } void loop() { for(int i = 0; i < 20; i++){ moveForward(6400); rub(); } for(int i = 0; i < 20; i++){ moveBackward(6400); rub(); } pauseForWater(); } void moveForward(int steps){ setDirection(true); allowControl(true); for (int i=0; i<steps; i++) //Forward 5000 steps { giveCurrent(true); setDelay(); giveCurrent(false); setDelay(); } } void moveBackward(int steps){ setDirection(false); allowControl(true); for (int i=0; i<steps; i++) //Backward 5000 steps { giveCurrent(true); setDelay(); giveCurrent(false); setDelay(); } } void rub(){ for(int i = 0; i < 5; i++){ moveForward(2560); moveBackward(2560); } } void setDirection(boolean isForward){ int signal = isForward ? LOW : HIGH; digitalWrite(DIR, signal); } void giveCurrent(boolean cur){ int signal = cur ? HIGH : LOW; digitalWrite(PUL,signal); } void setDelay(){ delayMicroseconds(50); } void allowControl(boolean enable){ int signal = enable ? HIGH : LOW; digitalWrite(ENA, signal); } void pauseForWater(){ delay(5); }
[ "shreya.jui.majumdar@gmail.com" ]
shreya.jui.majumdar@gmail.com
f02a2a8ae4bb649e01aa2355138bc4c3cad4d5f9
ce1044f6dd1ab23aed435dd087283ece45f3f024
/include/Wallet/ExtendedKey.h
f0d071bca87617afccb07a1a0d64ca893a37e9ff
[ "MIT" ]
permissive
1div0/GrinPlusPlus
daf13ff87681903e0674d1f077f17d3730eebcba
44ba6474b971cd39a96b7ad9742b23d3cb5334c9
refs/heads/master
2021-07-12T20:23:20.039838
2020-12-02T11:18:41
2020-12-02T11:18:41
221,024,351
0
0
MIT
2019-11-11T16:37:06
2019-11-11T16:37:05
null
UTF-8
C++
false
false
2,054
h
#pragma once #include <Crypto/BigInteger.h> #include <Crypto/PublicKey.h> #include <Crypto/SecretKey.h> #include <Core/Serialization/Serializer.h> #include <Core/Serialization/ByteBuffer.h> // // Represents a BIP32 extended key. // class IExtendedKey { public: virtual ~IExtendedKey() = default; // // 4 byte: version bytes (mainnet: TODO: public, TODO: private; floonet: 0x033C08DF public, 0x033C04A4 private) // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 derived keys, .... // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key) // 4 bytes: child number. This is ser32(i) for i in xi = xpar/i, with xi the key being serialized. (0x00000000 if master key) // 32 bytes: the chain code // 33 bytes: the public key or private key data (serP(K) for public keys, 0x00 || ser256(k) for private keys) // void Serialize(Serializer& serializer) const { serializer.Append<uint32_t>(m_network); serializer.Append<uint8_t>(m_depth); serializer.Append<uint32_t>(m_parentFingerprint); serializer.Append<uint32_t>(m_childNumber); serializer.AppendBigInteger<32>(m_chainCode.GetBytes()); m_keyBytes.Serialize(serializer); } uint32_t GetNetwork() const { return m_network; } uint8_t GetDepth() const { return m_depth; } uint32_t GetParentFingerprint() const { return m_parentFingerprint; } uint32_t GetChildNumber() const { return m_childNumber; } const SecretKey& GetChainCode() const { return m_chainCode; } protected: IExtendedKey(const uint32_t network, const uint8_t depth, const uint32_t parentFingerprint, const uint32_t childNumber, SecretKey&& chainCode, PublicKey&& keyBytes) : m_network(network), m_depth(depth), m_parentFingerprint(parentFingerprint), m_childNumber(childNumber), m_chainCode(std::move(chainCode)), m_keyBytes(std::move(keyBytes)) { } const PublicKey& GetKeyBytes() const noexcept { return m_keyBytes; } private: uint32_t m_network; uint8_t m_depth; uint32_t m_parentFingerprint; uint32_t m_childNumber; SecretKey m_chainCode; PublicKey m_keyBytes; };
[ "davidburkett38@gmail.com" ]
davidburkett38@gmail.com
b8fc96ee3c9ae8f30eeb067994d424438c6566b5
dd6162081ec0ee0f8a9b63ec45669f202f8520dc
/src/duke/gl/Program.hpp
6d43714d863182c72280dbc72fb0dc64b27e7e49
[ "MIT" ]
permissive
virneo/duke
60364c8a548c6792030e70167c97360f17ee9b9c
efacf7139cd1d7c2cd2f5127079721bd263dda50
refs/heads/develop
2021-01-17T10:37:25.533907
2014-11-12T14:50:39
2014-11-12T14:50:39
45,284,061
1
0
null
2015-10-31T01:12:54
2015-10-31T01:12:54
null
UTF-8
C++
false
false
1,640
hpp
#pragma once #include "duke/gl/Shader.hpp" #include <map> namespace duke { struct Program : public noncopyable { Program(const SharedVertexShader& vertexShader, const SharedFragmentShader& fragmentShader); ~Program(); void use() const; GLint getUniformLocation(const char* pUniformName) const; void glUniform1f(const char* pUniformName, GLfloat v0); void glUniform2f(const char* pUniformName, GLfloat v0, GLfloat v1); void glUniform3f(const char* pUniformName, GLfloat v0, GLfloat v1, GLfloat v2); void glUniform4f(const char* pUniformName, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); void glUniform1i(const char* pUniformName, GLint v0); void glUniform2i(const char* pUniformName, GLint v0, GLint v1); void glUniform3i(const char* pUniformName, GLint v0, GLint v1, GLint v2); void glUniform4i(const char* pUniformName, GLint v0, GLint v1, GLint v2, GLint v3); void glUniform1ui(const char* pUniformName, GLuint v0); void glUniform2ui(const char* pUniformName, GLuint v0, GLuint v1); void glUniform3ui(const char* pUniformName, GLuint v0, GLuint v1, GLuint v2); void glUniform4ui(const char* pUniformName, GLuint v0, GLuint v1, GLuint v2, GLuint v3); private: const GLuint programId; const SharedVertexShader pVertexShader; const SharedFragmentShader pFragmentShader; enum { DATA_SIZE = 4 * sizeof(GLfloat) }; struct CacheEntry { GLint location; char data[DATA_SIZE]; }; typedef std::map<const char*, CacheEntry> Cache; Cache m_Cache; CacheEntry& getOrCreate(const char* pUniformName); }; typedef std::shared_ptr<Program> SharedProgram; } /* namespace duke */
[ "chatelet.guillaume@gmail.com" ]
chatelet.guillaume@gmail.com
23e8392d4bb1d86075c4f7f117043608c9acacfa
a0863d7dc1bddc6f3a3ee370f6b6e5f4de475550
/Tag/Array/611.ValidTriangleNumber/611.cpp
ad71c6a4996a90bfa82baae90d797cead3511473
[]
no_license
nisak0503/leetcode
c3a936da0d64eac2de9faa60d161d31f76c740b3
fa0f2e36c3ad554f96bef7f4e1e50952cde263e6
refs/heads/master
2021-01-20T10:50:11.220068
2017-11-30T02:53:31
2017-11-30T02:53:31
83,939,025
0
0
null
null
null
null
UTF-8
C++
false
false
2,400
cpp
#include <iostream> #include <fstream> #include <algorithm> #include <vector> using namespace std; ifstream fin("611.in"); class Solution { public: vector<int> nums; public: int triangleNumber(vector<int>& nums) { sort(nums.begin(), nums.begin()+nums.size()); int k = 2, cnt = 0; if(nums.size() < 3) return 0; for(int i = 0; i < nums.size()-2; ++i) { if(nums[i] <= 0) continue; for(int j = i+1; j < nums.size()-1; ++j) { if(nums[j] <= 0) continue; int k = j+1; while(nums[i] + nums[j] > nums[k]) { k++; if(k >= nums.size()) { break; } } k--; cout << nums[i]<<" + "<<nums[j]<<"> "<<nums[k]<<" +"<<k-j<<endl; cnt += max(0, k - j); } } return cnt > 0 ? cnt : 0; } void input() { int num; while(fin >> num) { nums.push_back(num); } } }; int main() { Solution s; s.input(); cout << s.triangleNumber(s.nums) << endl; } /* 自己做没有想出来qwq 好好反省一下 根据宋胖的算法,计算出 larger[i] 表示 比i大的数, 每次计算 max(i-j, j-i) < k < i+j 只要计算 larger(max(i-j), j-i) - larger(i+j) 即可 我的方法是维护一个smaller数组,保证两个数组都是非等号的。 但是这里出现的问题是,2,2,3这种组合会在 2,2时算1次,2,3,2中被算了两次,因为 2>3-1,两个2。等等,这样算下来,晕掉了。。 以上是solution中的思路。 sort之后,每次从j+1开始循环,做了一定的剪枝 232ms, 25.56% 原java代码如下: public class Solution { public int triangleNumber(int[] nums) { int count = 0; Arrays.sort(nums); for (int i = 0; i < nums.length - 2; i++) { int k = i + 2; for (int j = i + 1; j < nums.length - 1 && nums[i] != 0; j++) { while (k < nums.length && nums[i] + nums[j] > nums[k]) k++; count += k - j - 1; } } return count; } } 写第一遍出现的问题是, 3, 82 不拉不拉,算出来nums[k] = 84 紧接着 19, 22 算出来nums[k] 不应该从84开始 */
[ "kasin.xc@sjtu.edu.cn" ]
kasin.xc@sjtu.edu.cn
9a0ac34210bfd04546595f834e9794f560010be8
73c8a3179b944b63b2a798542896e4cdf0937b6e
/Codeforces/Divisibility.cpp
7211c930c2a8d2547c000976532f90ea2c790e00
[ "Apache-2.0" ]
permissive
aajjbb/contest-files
c151f1ab9b562ca91d2f8f4070cb0aac126a188d
71de602a798b598b0365c570dd5db539fecf5b8c
refs/heads/master
2023-07-23T19:34:12.565296
2023-07-16T00:57:55
2023-07-16T00:57:59
52,963,297
2
4
null
2017-08-03T20:12:19
2016-03-02T13:05:25
C++
UTF-8
C++
false
false
2,500
cpp
#include <bits/stdc++.h> template<typename T> T gcd(T a, T b) { if(!b) return a; return gcd(b, a % b); } template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); } template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } int in() { int x; scanf("%d", &x); return x; } using namespace std; typedef long long Int; typedef unsigned long long uInt; typedef unsigned uint; const int MAX_TRY = 100; Int N; Int modPow(Int a, Int n, Int mod) { Int res = 1; while (n) { if (n & 1) { res = (res * a) % mod; } a = (a * a) % mod; n /= 2; } res %= mod; res += mod; res %= mod; return res; } Int llrand(){ Int a = rand(); a<<=32; a+=rand(); return a; } bool is_probably_prime(Int n) { if (n <= 1) return 0; if (n <= 3) return 1; Int s = 0, d = n - 1; while (d % 2 == 0) { d /= 2; s++; } for(int k = 0; k < 512; k++) { Int a = (llrand() % (n - 3)) + 2; Int x = modPow(a, d, n); if (x != 1 && x != n - 1) { for (int r = 1; r < s; r++) { x = modPow(x, 2, n); if(x == 1) { return 0; } if (x == n - 1) { break; } } if (x != n - 1) { return 0; } } } return 1; } Int rho(Int n) { Int d, c = rand() % n, x = rand() % n, xx = x; if (n % 2 == 0) { return 2; } do { x = (modPow(x, x, n) + c) % n; xx = (modPow(xx, xx, n) + c) % n; xx = (modPow(xx, xx, n) + c) % n; d = gcd(abs(x - xx) , n); } while (d == 1); return d; } map <Int, int > F; void factor (Int n) { // cout << n << endl; if (n == 1) { return; } if (is_probably_prime(n)) { F[n]++; return; } Int d = rho(n); while (d == n) { d = rho(n); } factor(d); factor(n / d); } int main(void) { cin >> N; srand(time(NULL)); if (is_probably_prime(N)) { cout << 2 << endl; } else { return 0; factor(N); Int ans = 1; for (auto& it : F) { ans *= (it.second + 1); } cout << ans << endl; } return 0; }
[ "jefersonlsiq@gmail.com" ]
jefersonlsiq@gmail.com
8bd3315890b4f08a3b23d99f132acb62becef226
25d7fa8d57ff934ce1a9f42dd1fc55c7bcd7010d
/gcj2020_r1b/a.cpp
60499b714b183cff409ce9c161e6a6fdba7af8bb
[]
no_license
FMota0/yt-content
22b3e6f0595b348773c6faf1aef9a7c5e27390c4
9210dc3cc3974adf43eef7d9df7d0e7bd8b6e3ad
refs/heads/master
2022-11-25T22:10:31.395335
2020-08-07T13:26:39
2020-08-07T13:26:39
257,675,348
0
0
null
null
null
null
UTF-8
C++
false
false
1,518
cpp
#include <bits/stdc++.h> using namespace std; template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); } template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); } int main(){ ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; for(int _ = 1; _ <= t; _++){ cout << "Case #" << _ << ":"; using ll = long long; ll x, y; cin >> y >> x; int rx = 0, ry = 0; if(x < 0) rx = 1, x = -x; if(y < 0) ry = 1, y = -y; if((x + y) % 2 == 0){ cout << " IMPOSSIBLE\n"; continue; } auto covers = [&](ll x, ll y, int b){ return abs(x) + abs(y) <= ((1ll<<(b + 1)) - 1); }; string res; for(int i = 0; i <= 40 && res.empty(); i++){ if(covers(x, y, i)){ for(int j = i; j >= 0; j--){ long long delta = 1ll<<j; if(covers(x - delta, y, j - 1)){ x -= delta; res.push_back('N'); } else if(covers(x + delta, y, j - 1)){ x += delta; res.push_back('S'); } else if(covers(x, y - delta, j - 1)){ y -= delta; res.push_back('E'); } else if(covers(x, y + delta, j - 1)){ y += delta; res.push_back('W'); } else assert(0); } } } reverse(res.begin(), res.end()); if(rx){ for(auto & c : res){ if(c == 'N') c = 'S'; else if(c == 'S') c = 'N'; } } if(ry){ for(auto & c : res){ if(c == 'E') c = 'W'; else if(c == 'W') c = 'E'; } } cout << " " << res << '\n'; } return 0; }
[ "felipe.santos@ccc.ufcg.edu.br" ]
felipe.santos@ccc.ufcg.edu.br
c7e1c5b871bef007ec63eb8056e13ada5472e65e
c9cf0586ace11aa32fa67606d237a130a06364ee
/circular-cylinder-2-20/w_20/59.5/uniform/functionObjects/functionObjectProperties
1f4a1c487d53f84e20a9f1b5f01c2039c1f7fbed
[]
no_license
jezvonek/CFD-Final-Project
c74cfa21f22545c27d97d85cf30eb6dc8c824dc1
7c9a7fb032d74f20888effa0a0b75b212bf899f4
refs/heads/master
2022-07-05T14:43:52.967657
2020-05-14T03:40:56
2020-05-14T03:40:56
262,370,756
1
1
null
null
null
null
UTF-8
C++
false
false
898
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1912 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "59.5/uniform/functionObjects"; object functionObjectProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // ************************************************************************* //
[ "jezvonek@gmail.com" ]
jezvonek@gmail.com
cdac7c629d3ad4baf8d4568914afc30111a45a03
4a28104787a4ce3bf362fda9182e4f1fe6276c30
/graphs/bfs_shortReach.cpp
6187c87e472830c54e8f005b7efd6223f260b54d
[]
no_license
Ason4901/geeksforgeeks
d0538a22db00c86e97ec8b9f6c548ebd1ecef8ce
777aa4c0752bb0a9b942922e1ad99095a161cc6b
refs/heads/master
2023-02-24T07:51:15.469015
2021-01-30T15:36:20
2021-01-30T15:36:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,627
cpp
#include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <cmath> #include <cstring> #include <chrono> #include <complex> #define endl "\n" #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector < vi > #define pii pair<int,int> #define pll pair<long long, long long> #define mod 1000000007 #define inf 1000000000000000001; #define all(c) c.begin(),c.end() #define mp(x,y) make_pair(x,y) #define mem(a,val) memset(a,val,sizeof(a)) #define eb emplace_back #define f first #define s second using namespace std; void solve(int num_of_nodes, int start_node, const vector<list<int>>& edges) { vi length_to_nodes(num_of_nodes + 1, -1); queue<int> q; length_to_nodes[start_node] = 0; q.push(start_node); while (!q.empty()) { int current_node = q.front(); q.pop(); for (auto node : edges[current_node]) { if (length_to_nodes[node] == -1) { length_to_nodes[node] = length_to_nodes[current_node] + 6; q.push(node); } } } for (int i = 1; i < length_to_nodes.size(); ++i) { if (length_to_nodes[i] != 0) cout << length_to_nodes[i] << " "; } cout << endl; } int main() { std::ios::sync_with_stdio(false); int T; cin >> T; // cin.ignore(); must be there when using getline(cin, s) while (T--) { int nodes, num_edge; cin >> nodes >> num_edge; vector<list<int>> edges(nodes + 1); for (int i = 0; i < num_edge; ++i) { int node_1, node_2; cin >> node_1 >> node_2; edges[node_1].push_back(node_2); edges[node_2].push_back(node_1); } int start_node; cin >> start_node; solve(nodes, start_node, edges); } return 0; }
[ "abhip13th@gmail.com" ]
abhip13th@gmail.com
bc9b12c31a635ee55f76d2b2a1ba9cbf6e3e6035
535d1b93fbe05923e2defac0f7c218bd64559e0d
/CarmenJuego/Proyecto/Carmen/bin/windows/obj/include/lime/ui/_ScanCode/ScanCode_Impl_.h
c96646baf3a2c533c6e3c1cfd7214422d197a857
[]
no_license
XxKarikyXx/ProgVJ1
af9a9f4d7608912e1b2bab9726266b9f4ef5f44d
d26e335379a001cce21d7cd87461d75169391222
refs/heads/develop
2020-03-13T12:44:19.172929
2018-06-05T17:58:01
2018-06-05T17:58:01
131,125,411
0
0
null
2018-05-09T05:12:42
2018-04-26T08:35:17
Haxe
UTF-8
C++
false
true
7,488
h
// Generated by Haxe 3.4.2 (git build master @ 890f8c7) #ifndef INCLUDED_lime_ui__ScanCode_ScanCode_Impl_ #define INCLUDED_lime_ui__ScanCode_ScanCode_Impl_ #ifndef HXCPP_H #include <hxcpp.h> #endif HX_DECLARE_CLASS3(lime,ui,_ScanCode,ScanCode_Impl_) namespace lime{ namespace ui{ namespace _ScanCode{ class HXCPP_CLASS_ATTRIBUTES ScanCode_Impl__obj : public hx::Object { public: typedef hx::Object super; typedef ScanCode_Impl__obj OBJ_; ScanCode_Impl__obj(); public: enum { _hx_ClassId = 0x237bda4a }; void __construct(); inline void *operator new(size_t inSize, bool inContainer=false,const char *inName="lime.ui._ScanCode.ScanCode_Impl_") { return hx::Object::operator new(inSize,inContainer,inName); } inline void *operator new(size_t inSize, int extra) { return hx::Object::operator new(inSize+extra,false,"lime.ui._ScanCode.ScanCode_Impl_"); } hx::ObjectPtr< ScanCode_Impl__obj > __new() { hx::ObjectPtr< ScanCode_Impl__obj > __this = new ScanCode_Impl__obj(); __this->__construct(); return __this; } static hx::ObjectPtr< ScanCode_Impl__obj > __alloc(hx::Ctx *_hx_ctx) { ScanCode_Impl__obj *__this = (ScanCode_Impl__obj*)(hx::Ctx::alloc(_hx_ctx, sizeof(ScanCode_Impl__obj), false, "lime.ui._ScanCode.ScanCode_Impl_")); *(void **)__this = ScanCode_Impl__obj::_hx_vtable; return __this; } static void * _hx_vtable; static Dynamic __CreateEmpty(); static Dynamic __Create(hx::DynamicArray inArgs); //~ScanCode_Impl__obj(); HX_DO_RTTI_ALL; static bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp); static void __register(); bool _hx_isInstanceOf(int inClassId); ::String __ToString() const { return HX_HCSTRING("ScanCode_Impl_","\x8a","\xc1","\x1c","\x37"); } static void __boot(); static int UNKNOWN; static int BACKSPACE; static int TAB; static int RETURN; static int ESCAPE; static int SPACE; static int SINGLE_QUOTE; static int COMMA; static int MINUS; static int PERIOD; static int SLASH; static int NUMBER_0; static int NUMBER_1; static int NUMBER_2; static int NUMBER_3; static int NUMBER_4; static int NUMBER_5; static int NUMBER_6; static int NUMBER_7; static int NUMBER_8; static int NUMBER_9; static int SEMICOLON; static int EQUALS; static int LEFT_BRACKET; static int BACKSLASH; static int RIGHT_BRACKET; static int GRAVE; static int A; static int B; static int C; static int D; static int E; static int F; static int G; static int H; static int I; static int J; static int K; static int L; static int M; static int N; static int O; static int P; static int Q; static int R; static int S; static int T; static int U; static int V; static int W; static int X; static int Y; static int Z; static int DELETE; static int CAPS_LOCK; static int F1; static int F2; static int F3; static int F4; static int F5; static int F6; static int F7; static int F8; static int F9; static int F10; static int F11; static int F12; static int PRINT_SCREEN; static int SCROLL_LOCK; static int PAUSE; static int INSERT; static int HOME; static int PAGE_UP; static int END; static int PAGE_DOWN; static int RIGHT; static int LEFT; static int DOWN; static int UP; static int NUM_LOCK; static int NUMPAD_DIVIDE; static int NUMPAD_MULTIPLY; static int NUMPAD_MINUS; static int NUMPAD_PLUS; static int NUMPAD_ENTER; static int NUMPAD_1; static int NUMPAD_2; static int NUMPAD_3; static int NUMPAD_4; static int NUMPAD_5; static int NUMPAD_6; static int NUMPAD_7; static int NUMPAD_8; static int NUMPAD_9; static int NUMPAD_0; static int NUMPAD_PERIOD; static int APPLICATION; static int POWER; static int NUMPAD_EQUALS; static int F13; static int F14; static int F15; static int F16; static int F17; static int F18; static int F19; static int F20; static int F21; static int F22; static int F23; static int F24; static int EXECUTE; static int HELP; static int MENU; static int SELECT; static int STOP; static int AGAIN; static int UNDO; static int CUT; static int COPY; static int PASTE; static int FIND; static int MUTE; static int VOLUME_UP; static int VOLUME_DOWN; static int NUMPAD_COMMA; static int ALT_ERASE; static int SYSTEM_REQUEST; static int CANCEL; static int CLEAR; static int PRIOR; static int RETURN2; static int SEPARATOR; static int OUT; static int OPER; static int CLEAR_AGAIN; static int CRSEL; static int EXSEL; static int NUMPAD_00; static int NUMPAD_000; static int THOUSAND_SEPARATOR; static int DECIMAL_SEPARATOR; static int CURRENCY_UNIT; static int CURRENCY_SUBUNIT; static int NUMPAD_LEFT_PARENTHESIS; static int NUMPAD_RIGHT_PARENTHESIS; static int NUMPAD_LEFT_BRACE; static int NUMPAD_RIGHT_BRACE; static int NUMPAD_TAB; static int NUMPAD_BACKSPACE; static int NUMPAD_A; static int NUMPAD_B; static int NUMPAD_C; static int NUMPAD_D; static int NUMPAD_E; static int NUMPAD_F; static int NUMPAD_XOR; static int NUMPAD_POWER; static int NUMPAD_PERCENT; static int NUMPAD_LESS_THAN; static int NUMPAD_GREATER_THAN; static int NUMPAD_AMPERSAND; static int NUMPAD_DOUBLE_AMPERSAND; static int NUMPAD_VERTICAL_BAR; static int NUMPAD_DOUBLE_VERTICAL_BAR; static int NUMPAD_COLON; static int NUMPAD_HASH; static int NUMPAD_SPACE; static int NUMPAD_AT; static int NUMPAD_EXCLAMATION; static int NUMPAD_MEM_STORE; static int NUMPAD_MEM_RECALL; static int NUMPAD_MEM_CLEAR; static int NUMPAD_MEM_ADD; static int NUMPAD_MEM_SUBTRACT; static int NUMPAD_MEM_MULTIPLY; static int NUMPAD_MEM_DIVIDE; static int NUMPAD_PLUS_MINUS; static int NUMPAD_CLEAR; static int NUMPAD_CLEAR_ENTRY; static int NUMPAD_BINARY; static int NUMPAD_OCTAL; static int NUMPAD_DECIMAL; static int NUMPAD_HEXADECIMAL; static int LEFT_CTRL; static int LEFT_SHIFT; static int LEFT_ALT; static int LEFT_META; static int RIGHT_CTRL; static int RIGHT_SHIFT; static int RIGHT_ALT; static int RIGHT_META; static int MODE; static int AUDIO_NEXT; static int AUDIO_PREVIOUS; static int AUDIO_STOP; static int AUDIO_PLAY; static int AUDIO_MUTE; static int MEDIA_SELECT; static int WWW; static int MAIL; static int CALCULATOR; static int COMPUTER; static int APP_CONTROL_SEARCH; static int APP_CONTROL_HOME; static int APP_CONTROL_BACK; static int APP_CONTROL_FORWARD; static int APP_CONTROL_STOP; static int APP_CONTROL_REFRESH; static int APP_CONTROL_BOOKMARKS; static int BRIGHTNESS_DOWN; static int BRIGHTNESS_UP; static int DISPLAY_SWITCH; static int BACKLIGHT_TOGGLE; static int BACKLIGHT_DOWN; static int BACKLIGHT_UP; static int EJECT; static int SLEEP; static int fromKeyCode(int keyCode); static ::Dynamic fromKeyCode_dyn(); static int toKeyCode(int scanCode); static ::Dynamic toKeyCode_dyn(); static bool gt(int a,int b); static ::Dynamic gt_dyn(); static bool gte(int a,int b); static ::Dynamic gte_dyn(); static bool lt(int a,int b); static ::Dynamic lt_dyn(); static bool lte(int a,int b); static ::Dynamic lte_dyn(); static int plus(int a,int b); static ::Dynamic plus_dyn(); }; } // end namespace lime } // end namespace ui } // end namespace _ScanCode #endif /* INCLUDED_lime_ui__ScanCode_ScanCode_Impl_ */
[ "kariky@hotmail.es" ]
kariky@hotmail.es
c40b5c1b921f662e52e5f7d05e2d6ea17a54f470
9fad4848e43f4487730185e4f50e05a044f865ab
/src/remoting/protocol/message_reader.cc
fb3400159d98dcc161c04f3d0eb89ed2e40f7606
[ "BSD-3-Clause" ]
permissive
dummas2008/chromium
d1b30da64f0630823cb97f58ec82825998dbb93e
82d2e84ce3ed8a00dc26c948219192c3229dfdaa
refs/heads/master
2020-12-31T07:18:45.026190
2016-04-14T03:17:45
2016-04-14T03:17:45
56,194,439
4
0
null
null
null
null
UTF-8
C++
false
false
3,489
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 "remoting/protocol/message_reader.h" #include <utility> #include "base/bind.h" #include "base/callback.h" #include "base/compiler_specific.h" #include "base/location.h" #include "base/memory/ptr_util.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "remoting/base/compound_buffer.h" #include "remoting/proto/internal.pb.h" #include "remoting/protocol/p2p_stream_socket.h" namespace remoting { namespace protocol { static const int kReadBufferSize = 4096; MessageReader::MessageReader() : weak_factory_(this) {} MessageReader::~MessageReader() {} void MessageReader::StartReading( P2PStreamSocket* socket, const MessageReceivedCallback& message_received_callback, const ReadFailedCallback& read_failed_callback) { DCHECK(CalledOnValidThread()); DCHECK(!socket_); DCHECK(socket); DCHECK(!message_received_callback.is_null()); DCHECK(!read_failed_callback.is_null()); socket_ = socket; message_received_callback_ = message_received_callback; read_failed_callback_ = read_failed_callback; DoRead(); } void MessageReader::DoRead() { DCHECK(CalledOnValidThread()); // Don't try to read again if there is another read pending or we // have messages that we haven't finished processing yet. bool read_succeeded = true; while (read_succeeded && !closed_ && !read_pending_) { read_buffer_ = new net::IOBuffer(kReadBufferSize); int result = socket_->Read( read_buffer_.get(), kReadBufferSize, base::Bind(&MessageReader::OnRead, weak_factory_.GetWeakPtr())); HandleReadResult(result, &read_succeeded); } } void MessageReader::OnRead(int result) { DCHECK(CalledOnValidThread()); DCHECK(read_pending_); read_pending_ = false; if (!closed_) { bool read_succeeded; HandleReadResult(result, &read_succeeded); if (read_succeeded) DoRead(); } } void MessageReader::HandleReadResult(int result, bool* read_succeeded) { DCHECK(CalledOnValidThread()); if (closed_) return; *read_succeeded = true; if (result > 0) { OnDataReceived(read_buffer_.get(), result); *read_succeeded = true; } else if (result == net::ERR_IO_PENDING) { read_pending_ = true; } else { DCHECK_LT(result, 0); // Stop reading after any error. closed_ = true; *read_succeeded = false; LOG(ERROR) << "Read() returned error " << result; read_failed_callback_.Run(result); } } void MessageReader::OnDataReceived(net::IOBuffer* data, int data_size) { DCHECK(CalledOnValidThread()); message_decoder_.AddData(data, data_size); // Get list of all new messages first, and then call the callback // for all of them. while (true) { CompoundBuffer* buffer = message_decoder_.GetNextMessage(); if (!buffer) break; base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&MessageReader::RunCallback, weak_factory_.GetWeakPtr(), base::Passed(base::WrapUnique(buffer)))); } } void MessageReader::RunCallback(std::unique_ptr<CompoundBuffer> message) { if (!message_received_callback_.is_null()) message_received_callback_.Run(std::move(message)); } } // namespace protocol } // namespace remoting
[ "dummas@163.com" ]
dummas@163.com
e0f17c3622e3a4d8e7650e87fe2e532c0056523f
802853a94d217b7937237b7fedebd29c71c7ac51
/Bs2KstKst/main/Bs2KstKst_PIDBDTTraining.cpp
36200e74928007a8ac3aaf2bf4eeb7265dd527a9
[]
no_license
BlaiseDelaney/LHCbAnalysis
7a019f979366eba7f58bc5fe3061405b0a977e82
8ee07d622e7df782b33f7f4ba68df5dd2aff784d
refs/heads/master
2021-04-06T00:42:31.343354
2018-03-13T13:50:45
2018-03-13T13:50:45
124,939,078
0
0
null
2018-03-12T19:16:59
2018-03-12T19:16:59
null
UTF-8
C++
false
false
708
cpp
#include "Utils.h" #include "RunEngine.h" #include "Variables_Analysis.h" #include "BDTForPID.h" using namespace std; using namespace Utils; int main(int argc, char **argv) { // create run engine RunEngine runner("RunEngine", argc, argv); // create the variables Bs2KstKst::Variables_Analysis *v = new Bs2KstKst::Variables_Analysis() ; // make the analysers Bs2KstKst::BDTForPID *bdtTrainer = new Bs2KstKst::BDTForPID ( "BDTForPID" , v ); bdtTrainer->setTrainMode(); // pass variables to runner runner.setVariables( v ); // pass analysers to runner runner.addAnalyser( bdtTrainer ); // run runner.run(); // clean up delete v; delete bdtTrainer; return 0; }
[ "matthew.william.kenzie@cern.ch" ]
matthew.william.kenzie@cern.ch
1239e15d7872b10da899f4cb2070d5d512039621
41a76318e5b9eef2c69bbf922724f8b191d7d124
/kokkos/core/src/Kokkos_ROCm.hpp
93f0ec430e66ea9f24925b8e590b5e712b14f123
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
zishengye/compadre
d0ff10deca224284e7e153371a738e053e66012a
75b738a6a613c89e3c3232cbf7b2589a6b28d0a3
refs/heads/master
2021-06-25T06:16:38.327543
2021-04-02T02:08:48
2021-04-02T02:08:48
223,650,267
0
0
NOASSERTION
2019-11-23T20:41:03
2019-11-23T20:41:02
null
UTF-8
C++
false
false
7,047
hpp
/* //@HEADER // ************************************************************************ // // Kokkos v. 3.0 // Copyright (2020) National Technology & Engineering // Solutions of Sandia, LLC (NTESS). // // Under the terms of Contract DE-NA0003525 with NTESS, // the U.S. Government retains certain rights in this software. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Questions? Contact Christian R. Trott (crtrott@sandia.gov) // // ************************************************************************ //@HEADER */ #ifndef KOKKOS_ROCM_HPP #define KOKKOS_ROCM_HPP #include <Kokkos_Core_fwd.hpp> #if defined(KOKKOS_ENABLE_ROCM) class dim3 { public: int x, y, z; dim3(int _x, int _y, int _z) : x(_x), y(_y), z(_z){}; }; #include <ROCm/hc_math_std.hpp> //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- #include <cstddef> #include <iosfwd> #include <Kokkos_HostSpace.hpp> #include <Kokkos_ROCmSpace.hpp> #include <ROCm/Kokkos_ROCm_Exec.hpp> #include <Kokkos_ScratchSpace.hpp> #include <Kokkos_Parallel.hpp> #include <Kokkos_Layout.hpp> #include <impl/Kokkos_Tags.hpp> /*--------------------------------------------------------------------------*/ #include <hc.hpp> #include <hc_am.hpp> #include <amp_math.h> #if defined(__HCC_ACCELERATOR__) using namespace ::Concurrency::precise_math; #endif /*--------------------------------------------------------------------------*/ namespace Kokkos { namespace Impl { class ROCmExec; } // namespace Impl } // namespace Kokkos /*--------------------------------------------------------------------------*/ namespace Kokkos { namespace Experimental { /// \class ROCm /// \brief Kokkos device for multicore processors in the host memory space. class ROCm { public: //------------------------------------ //! \name Type declarations that all Kokkos devices must provide. //@{ //! Tag this class as a kokkos execution space typedef ROCm execution_space; typedef ROCmSpace memory_space; typedef Kokkos::Device<execution_space, memory_space> device_type; typedef LayoutLeft array_layout; typedef HostSpace::size_type size_type; typedef ScratchMemorySpace<ROCm> scratch_memory_space; ~ROCm() {} ROCm(); // explicit ROCm( const int instance_id ); ROCm(ROCm&&) = default; ROCm(const ROCm&) = default; ROCm& operator=(ROCm&&) = default; ROCm& operator=(const ROCm&) = default; //@} //------------------------------------ //! \name Functions that all Kokkos devices must implement. //@{ KOKKOS_INLINE_FUNCTION static int in_parallel() { #if defined(__HCC_ACCELERATOR__) return true; #else return false; #endif } /** \brief Set the device in a "sleep" state. */ static bool sleep(); /** \brief Wake the device from the 'sleep' state. A noop for OpenMP. */ static bool wake(); /** \brief Wait until all dispatched functors complete. A noop for OpenMP. */ static void impl_static_fence(); #ifdef KOKKOS_ENABLE_DEPRECATED_CODE static void fence(); #else void fence() const; #endif /// \brief Print configuration information to the given output stream. static void print_configuration(std::ostream&, const bool detail = false); /// \brief Free any resources being consumed by the device. static void finalize(); /** \brief Initialize the device. * */ struct SelectDevice { int rocm_device_id; SelectDevice() : rocm_device_id(1) {} explicit SelectDevice(int id) : rocm_device_id(id + 1) {} }; int rocm_device() const { return m_device; } bool isAPU(); bool isAPU(int device); static void initialize(const SelectDevice = SelectDevice()); static int is_initialized(); // static size_type device_arch(); // static size_type detect_device_count(); static int concurrency(); static const char* name(); private: int m_device; }; } // namespace Experimental } // namespace Kokkos namespace Kokkos { namespace Impl { template <> struct MemorySpaceAccess<Kokkos::Experimental::ROCmSpace, Kokkos::Experimental::ROCm::scratch_memory_space> { enum { assignable = false }; enum { accessible = true }; enum { deepcopy = false }; }; template <> struct VerifyExecutionCanAccessMemorySpace< Kokkos::Experimental::ROCm::memory_space, Kokkos::Experimental::ROCm::scratch_memory_space> { enum { value = true }; KOKKOS_INLINE_FUNCTION static void verify(void) {} KOKKOS_INLINE_FUNCTION static void verify(const void*) {} }; template <> struct VerifyExecutionCanAccessMemorySpace< Kokkos::HostSpace, Kokkos::Experimental::ROCm::scratch_memory_space> { enum { value = false }; inline static void verify(void) { Kokkos::Experimental::ROCmSpace::access_error(); } inline static void verify(const void* p) { Kokkos::Experimental::ROCmSpace::access_error(p); } }; } // namespace Impl } // namespace Kokkos #define threadIdx_x (hc_get_workitem_id(0)) #define threadIdx_y (hc_get_workitem_id(1)) #define threadIdx_z (hc_get_workitem_id(2)) #define blockIdx_x (hc_get_group_id(0)) #define blockIdx_y (hc_get_group_id(1)) #define blockIdx_z (hc_get_group_id(2)) #define blockDim_x (hc_get_group_size(0)) #define blockDim_y (hc_get_group_size(1)) #define blockDim_z (hc_get_group_size(2)) #define gridDim_x (hc_get_num_groups(0)) #define gridDim_y (hc_get_num_groups(1)) #define gridDim_z (hc_get_num_groups(2)) #include <ROCm/Kokkos_ROCm_Parallel.hpp> #include <ROCm/Kokkos_ROCm_Task.hpp> #endif #endif
[ "pakuber@sandia.gov" ]
pakuber@sandia.gov
4c75480ce7758462fc99eff7f929067e9f480241
bb5fd447b839853918f1c9b1d27e81b2e1683bca
/simulate.cpp
e60223ae28d785f45427fca49220fa6ea8f940a0
[]
no_license
adhaase/adventure-RPG
013a7b1ab2d429377a78ba0282bf8af1577588d1
eb19281353838fbd18a6054c4f1863ebd0a79f63
refs/heads/master
2021-04-15T04:56:34.652415
2018-03-21T20:09:41
2018-03-21T20:09:41
126,144,522
0
0
null
null
null
null
UTF-8
C++
false
false
1,610
cpp
#include <iostream> #include <string> #include <vector> #include <sstream> #include <fstream> #include <random> #include <ctime> #include <chrono> #include <thread> #include "item.h" #include "player.h" #include "shop.h" using namespace std; void palletTownShop(Shop &palletShop, Player &player) { palletShop.name = "Pallet Town Shop"; palletShop.approachShopkeeper(palletShop); // approach shopkeeper cout << "------------------------------------------\n"; cout << "------------ PALLET TOWN SHOP ------------\n"; cout << "------------------------------------------\n"; // define Pallet Town Shop inventory // Name | Attack Power | Price Item rustySword = { "Rusty Sword", 4, 6 }; Item rustyDagger = { "Rusty Dagger", 2, 3 }; Item apprenticeWand = { "Apprentice Wand", 7, 11 }; Item wornShortBow = { "Worn Short Bow", 6, 9 }; // add items to Pallet Town Shop inventory palletShop.shopSupplies.push_back(rustySword); palletShop.shopSupplies.push_back(rustyDagger); palletShop.shopSupplies.push_back(apprenticeWand); palletShop.shopSupplies.push_back(wornShortBow); // print the items of Pallet Town Shop palletShop.printItems(palletShop.shopSupplies); cout << "\n"; // print player gold player.playerGold = 20; // The player initially starts with 20 gold player.printGold(player); // print player rucksack player.printRucksack(player.rucksack); // print shop choices palletShop.shopChoices(player, palletShop); } void simulate() { Shop palletShop; Player player; palletTownShop(palletShop, player); // TODO : don't always do this. If player chooses then simulate shop }
[ "adhaase@umich.edu" ]
adhaase@umich.edu
b13de398af01c9d4f6fa5b358fd5a3e08267f8c7
b029b01a30c0c42f922f9eddeb5ff3f27c2b8984
/chrome/browser/prerender/prerender_test_utils.h
741d93f6a6e15531e228165dc03bad8cf607decc
[ "BSD-3-Clause" ]
permissive
Schlam/chromium-white-flash-fix
856fa057b44607cdb9835037a36fedc1fa234412
d80242b605bbf316d9908bc5fbe485ffeb51a748
refs/heads/master
2023-02-20T17:35:51.551838
2016-11-19T03:36:37
2016-11-19T03:39:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,616
h
// Copyright (c) 2016 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_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_ #define CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_ #include <deque> #include <functional> #include <memory> #include <set> #include <string> #include <unordered_map> #include <vector> #include "base/memory/weak_ptr.h" #include "base/run_loop.h" #include "base/test/histogram_tester.h" #include "chrome/browser/external_protocol/external_protocol_handler.h" #include "chrome/browser/prerender/prerender_contents.h" #include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/safe_browsing/test_safe_browsing_service.h" #include "chrome/test/base/in_process_browser_test.h" #include "components/safe_browsing_db/test_database_manager.h" #include "content/public/browser/browser_thread.h" #include "net/test/url_request/url_request_mock_http_job.h" #include "net/url_request/url_request_interceptor.h" #include "url/gurl.h" namespace base { class FilePath; } // namespace base namespace net { class URLRequest; class NetworkDelegate; } // namespace net namespace prerender { namespace test_utils { // Dummy counter class to live on the UI thread for counting requests. class RequestCounter : public base::SupportsWeakPtr<RequestCounter> { public: RequestCounter(); ~RequestCounter(); int count() const { return count_; } void RequestStarted(); void WaitForCount(int expected_count); private: int count_; int expected_count_; std::unique_ptr<base::RunLoop> loop_; }; // A SafeBrowsingDatabaseManager implementation that returns a fixed result for // a given URL. class FakeSafeBrowsingDatabaseManager : public safe_browsing::TestSafeBrowsingDatabaseManager { public: FakeSafeBrowsingDatabaseManager(); // Called on the IO thread to check if the given url is safe or not. If we // can synchronously determine that the url is safe, CheckUrl returns true. // Otherwise it returns false, and "client" is called asynchronously with the // result when it is ready. // Returns true, indicating a SAFE result, unless the URL is the fixed URL // specified by the user, and the user-specified result is not SAFE // (in which that result will be communicated back via a call into the // client, and false will be returned). // Overrides SafeBrowsingDatabaseManager::CheckBrowseUrl. bool CheckBrowseUrl(const GURL& gurl, Client* client) override; void SetThreatTypeForUrl(const GURL& url, safe_browsing::SBThreatType threat_type) { bad_urls_[url.spec()] = threat_type; } // These are called when checking URLs, so we implement them. bool IsSupported() const override; bool ChecksAreAlwaysAsync() const override; bool CanCheckResourceType( content::ResourceType /* resource_type */) const override; bool CheckExtensionIDs(const std::set<std::string>& extension_ids, Client* client) override; private: ~FakeSafeBrowsingDatabaseManager() override; void OnCheckBrowseURLDone(const GURL& gurl, Client* client); std::unordered_map<std::string, safe_browsing::SBThreatType> bad_urls_; DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); }; // PrerenderContents that stops the UI message loop on DidStopLoading(). class TestPrerenderContents : public PrerenderContents { public: TestPrerenderContents(PrerenderManager* prerender_manager, Profile* profile, const GURL& url, const content::Referrer& referrer, Origin origin, FinalStatus expected_final_status); ~TestPrerenderContents() override; bool CheckURL(const GURL& url) override; // For tests that open the prerender in a new background tab, the RenderView // will not have been made visible when the PrerenderContents is destroyed // even though it is used. void set_should_be_shown(bool value) { should_be_shown_ = value; } // For tests which do not know whether the prerender will be used. void set_skip_final_checks(bool value) { skip_final_checks_ = value; } FinalStatus expected_final_status() const { return expected_final_status_; } private: void OnRenderViewHostCreated( content::RenderViewHost* new_render_view_host) override; void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) override; FinalStatus expected_final_status_; // The RenderViewHost created for the prerender, if any. content::RenderViewHost* new_render_view_host_; // Set to true when the prerendering RenderWidget is hidden. bool was_hidden_; // Set to true when the prerendering RenderWidget is shown, after having been // hidden. bool was_shown_; // Expected final value of was_shown_. Defaults to true for // FINAL_STATUS_USED, and false otherwise. bool should_be_shown_; // If true, |expected_final_status_| and other shutdown checks are skipped. bool skip_final_checks_; DISALLOW_COPY_AND_ASSIGN(TestPrerenderContents); }; // A handle to a TestPrerenderContents whose lifetime is under the caller's // control. A PrerenderContents may be destroyed at any point. This allows // tracking the FinalStatus. class TestPrerender : public PrerenderContents::Observer, public base::SupportsWeakPtr<TestPrerender> { public: TestPrerender(); ~TestPrerender() override; TestPrerenderContents* contents() const { return contents_; } int number_of_loads() const { return number_of_loads_; } FinalStatus GetFinalStatus() const; void WaitForCreate(); void WaitForStart(); void WaitForStop(); // Waits for |number_of_loads()| to be at least |expected_number_of_loads| OR // for the prerender to stop running (just to avoid a timeout if the prerender // dies). Note: this does not assert equality on the number of loads; the // caller must do it instead. void WaitForLoads(int expected_number_of_loads); void OnPrerenderCreated(TestPrerenderContents* contents); // PrerenderContents::Observer implementation: void OnPrerenderStart(PrerenderContents* contents) override; void OnPrerenderStopLoading(PrerenderContents* contents) override; void OnPrerenderStop(PrerenderContents* contents) override; private: TestPrerenderContents* contents_; FinalStatus final_status_; int number_of_loads_; int expected_number_of_loads_; std::unique_ptr<base::RunLoop> load_waiter_; bool started_; bool stopped_; base::RunLoop create_loop_; base::RunLoop start_loop_; base::RunLoop stop_loop_; DISALLOW_COPY_AND_ASSIGN(TestPrerender); }; // Blocks until a TestPrerenderContents has been destroyed with the given final // status. Should be created with a TestPrerenderContents, and then // WaitForDestroy should be called and its return value checked. class DestructionWaiter { public: // Does not own the prerender_contents, which must outlive any call to // WaitForDestroy(). DestructionWaiter(TestPrerenderContents* prerender_contents, FinalStatus expected_final_status); ~DestructionWaiter(); // Returns true if the TestPrerenderContents was destroyed with the correct // final status, or false otherwise. Note this also may hang if the contents // is never destroyed (which will presumably cause the test to time out). bool WaitForDestroy(); private: class DestructionMarker : public PrerenderContents::Observer { public: // Does not own the waiter which must outlive the TestPrerenderContents. explicit DestructionMarker(DestructionWaiter* waiter); ~DestructionMarker() override; void OnPrerenderStop(PrerenderContents* contents) override; private: DestructionWaiter* waiter_; DISALLOW_COPY_AND_ASSIGN(DestructionMarker); }; // To be called by a DestructionMarker. void MarkDestruction(FinalStatus reason); base::RunLoop wait_loop_; FinalStatus expected_final_status_; bool saw_correct_status_; std::unique_ptr<DestructionMarker> marker_; DISALLOW_COPY_AND_ASSIGN(DestructionWaiter); }; // PrerenderContentsFactory that uses TestPrerenderContents. class TestPrerenderContentsFactory : public PrerenderContents::Factory { public: TestPrerenderContentsFactory(); ~TestPrerenderContentsFactory() override; std::unique_ptr<TestPrerender> ExpectPrerenderContents( FinalStatus final_status); PrerenderContents* CreatePrerenderContents( PrerenderManager* prerender_manager, Profile* profile, const GURL& url, const content::Referrer& referrer, Origin origin) override; private: struct ExpectedContents { ExpectedContents(); ExpectedContents(const ExpectedContents& other); ExpectedContents(FinalStatus final_status, const base::WeakPtr<TestPrerender>& handle); ~ExpectedContents(); FinalStatus final_status; base::WeakPtr<TestPrerender> handle; }; std::deque<ExpectedContents> expected_contents_queue_; DISALLOW_COPY_AND_ASSIGN(TestPrerenderContentsFactory); }; class PrerenderInProcessBrowserTest : virtual public InProcessBrowserTest { public: PrerenderInProcessBrowserTest(); ~PrerenderInProcessBrowserTest() override; void SetUpCommandLine(base::CommandLine* command_line) override; void SetUpInProcessBrowserTestFixture() override; void TearDownInProcessBrowserTestFixture() override; void SetUpOnMainThread() override; content::SessionStorageNamespace* GetSessionStorageNamespace() const; // Many of the file and server manipulation commands are fussy about paths // being relative or absolute. This makes path absolute if it is not // already. The path must not be empty. std::string MakeAbsolute(const std::string& path); bool UrlIsInPrerenderManager(const std::string& html_file) const; bool UrlIsInPrerenderManager(const GURL& url) const; // Convenience function to get the currently active WebContents in // current_browser(). content::WebContents* GetActiveWebContents() const; PrerenderManager* GetPrerenderManager() const; TestPrerenderContents* GetPrerenderContentsFor(const GURL& url) const; // Set up an HTTPS server. void UseHttpsSrcServer(); // Returns the currently active server. See |UseHttpsSrcServer|. net::EmbeddedTestServer* src_server(); safe_browsing::TestSafeBrowsingServiceFactory* safe_browsing_factory() const { return safe_browsing_factory_.get(); } test_utils::FakeSafeBrowsingDatabaseManager* GetFakeSafeBrowsingDatabaseManager(); TestPrerenderContentsFactory* prerender_contents_factory() const { return prerender_contents_factory_; } void set_autostart_test_server(bool value) { autostart_test_server_ = value; } void set_browser(Browser* browser) { explicitly_set_browser_ = browser; } Browser* current_browser() const { return explicitly_set_browser_ ? explicitly_set_browser_ : browser(); } const base::HistogramTester& histogram_tester() { return histogram_tester_; } // Returns a string for pattern-matching TaskManager tab entries. base::string16 MatchTaskManagerTab(const char* page_title); // Returns a string for pattern-matching TaskManager prerender entries. base::string16 MatchTaskManagerPrerender(const char* page_title); protected: // For each FinalStatus in |expected_final_status_queue| creates a prerender // that is going to verify the correctness of its FinalStatus upon // destruction. Waits for creation of the first PrerenderContents. std::vector<std::unique_ptr<TestPrerender>> NavigateWithPrerenders( const GURL& loader_url, const std::vector<FinalStatus>& expected_final_status_queue); // Creates the URL that instructs the test server to substitute the text // |replacement_variable| in the contents of the file pointed to by // |loader_path| with |url_to_prerender|. Also appends the |loader_query| to // the URL. GURL ServeLoaderURL(const std::string& loader_path, const std::string& replacement_variable, const GURL& url_to_prerender, const std::string& loader_query); private: std::unique_ptr<ExternalProtocolHandler::Delegate> external_protocol_handler_delegate_; std::unique_ptr<safe_browsing::TestSafeBrowsingServiceFactory> safe_browsing_factory_; TestPrerenderContentsFactory* prerender_contents_factory_; Browser* explicitly_set_browser_; bool autostart_test_server_; base::HistogramTester histogram_tester_; std::unique_ptr<net::EmbeddedTestServer> https_src_server_; DISALLOW_COPY_AND_ASSIGN(PrerenderInProcessBrowserTest); }; // Makes |url| respond to requests with the contents of |file|, counting the // number that start in |counter|. void CreateCountingInterceptorOnIO( const GURL& url, const base::FilePath& file, const base::WeakPtr<RequestCounter>& counter); // Makes |url| respond to requests with the contents of |file|. void CreateMockInterceptorOnIO(const GURL& url, const base::FilePath& file); // Makes |url| never respond on the first load, and then with the contents of // |file| afterwards. When the first load has been scheduled, runs |callback| on // the UI thread. void CreateHangingFirstRequestInterceptorOnIO( const GURL& url, const base::FilePath& file, base::Closure callback); } // namespace test_utils } // namespace prerender #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
7a15e70c74eaaa9cc36effe9a65cbc57bdca3251
dc6c4086a298b1fec186ba81814e535e18381042
/Template/src/collisions.hpp
6dd397bb08f372312ce142ef4b917e8e85b39538
[]
no_license
Loona22/Colored_Memories
6ec3a18f571328cd1cbc2c2bdcc5f18f656f9513
3cde28803c4aca78a5b88d4df8ab17f5898d5efd
refs/heads/master
2023-02-07T21:50:05.305005
2021-01-03T21:07:12
2021-01-03T21:07:12
326,487,626
0
0
null
null
null
null
UTF-8
C++
false
false
564
hpp
#ifndef COLLISIONS_HPP #define COLLISIONS_HPP #include <glimac/SDLWindowManager.hpp> #include <GL/glew.h> #include <iostream> #include <SDL/SDL.h> #include <glimac/glm.hpp> #include "glimac/FreeflyCamera.hpp" #include <glimac/Program.hpp> #include "tresor.hpp" using namespace glimac; //gestion des collisions // cubePositions pour récupérer la position du cube // float x, y, z pour comparer avec la position du cube // retourne vrai ou faux pour savoir quanc il y a collision bool CheckCollision(glm::vec3 cubePositions, float x, float y, float z); #endif
[ "loona.upem@gmail.com" ]
loona.upem@gmail.com
1a20a252f714c8b7dd79de895add8f06aff5e072
8beb7475ed7cb569596ad51bb0eede836a1fffa1
/aig.hpp
422b9ad8f51c33acb2c676de88aa1dc5cea87c10
[]
no_license
zkaiwen/AIG
525e7347e9e97f5e8e962e0069a01d7e85f2464e
4966401989fb1b8a0f2fbb80bf22cd8dc7e62e87
refs/heads/master
2021-01-10T18:07:30.552466
2013-08-12T23:54:59
2013-08-12T23:54:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,210
hpp
/*@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@ @ @ aig.hpp @ @ @AUTHOR:Kevin Zeng @ Copyright 2012 – 2013 Virginia Polytechnic Institute and State University @ @#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@*/ #ifndef AIG_GUARD #define AIG_GUARD #include <stdlib.h> #include <stdio.h> #include <vector> #include <map> #include <fstream> #include "graph.hpp" //Use to compare keys for "HASH TABLE" struct cmp_intp { bool operator()(int const *a, int const *b) { //printf("A: %d B:%d\nA:%d B:%d\n", a[0], b[0], a[1], b[1]); if(b[0] < a[0] ) return true; if(b[1] < a[1]) return true; return false; } }; class AIG{ private: std::vector<int*> m_AIG; std::vector<int> m_Outputs; void importAIG(const char*, std::vector<std::vector<int>*>&); std::map<int*, int, cmp_intp> m_HashTable; public: AIG(); ~AIG(); void importAIG(std::string); void convertGraph2AIG(Graph*); //Getters void getAIG(std::vector<std::vector<int>*>&); void getOutputs(std::vector<int>&); int create_and2(int, int); int create_input(); int new_and_vertex(int,int); void print(); void printHash(); }; #endif
[ "zkaiwen@gmail.com" ]
zkaiwen@gmail.com
c74884a7dbdad06327122af8856095d0e2beca1a
53ff492d492948bf6815c28789bd5dd0bb3f55f3
/Lab2/Projeto/ProjectFiles/thread.cpp
9d4fedf18274621978c64705f2d4b38346c3d1f0
[ "MIT" ]
permissive
MatheusBigarelli/sistemas-embarcados
3e2321dafdfab4fb5f12ddf5fd803164a15d459b
6a11e604d613fec762a25d1145f208ae268390ba
refs/heads/master
2020-07-04T09:26:17.842367
2019-12-07T17:55:18
2019-12-07T17:55:18
202,238,870
0
0
null
2019-11-08T01:18:00
2019-08-13T23:40:54
C
UTF-8
C++
false
false
995
cpp
#include "thread.h" #include "primes.h" #include "messages.h" #include "gpio.h" #include "uart.h" int current_iteration = 0; uint16_t key; bool key_ready = false; bool decode_ready = false; bool testOK = false; uint8_t message[MESSAGE_LENGTH] = {}; void initThreads(void) { osThreadCreate(osThread(getKeyThread), NULL); osThreadCreate(osThread(decodeMessageThread), NULL); osThreadCreate(osThread(testNextToLastWordThread), NULL); osThreadCreate(osThread(testLastWordThread), NULL); osThreadCreate(osThread(printMessageThread), NULL); } void getKeyThread(void const* arg) { while(1) { PortN_Output(1); } } void decodeMessageThread(void const* arg) { while(1) { PortN_Output(0); } } void testNextToLastWordThread(void const* arg) { while(1) { if(current_iteration < 3) { UART0_TxString("Mensagem decodificada:\r\n"); current_iteration++; } } } void testLastWordThread(void const* arg) { while(1); } void printMessageThread(void const* arg) { while(1); }
[ "victorbelinello17@gmail.com" ]
victorbelinello17@gmail.com
b051f7590ffc3816de97ab40aab15261aaec2757
2d5957d3f96d068c74c266a2651eb61159ffed9f
/Project1/Camera.cpp
8aea93992a91e99f5a45ab74e13c3dfb32802568
[]
no_license
ceski23/GL_MICROCAR
1564716027e62b3e8646ffc76ce88f476f85022f
acfb1ecf98182088c8ecc879b32bc82d5f95fbf2
refs/heads/master
2020-06-02T13:27:22.260357
2019-06-23T14:11:20
2019-06-23T14:11:20
191,169,350
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
1,672
cpp
#include "Camera.h" Camera::Camera(glm::vec3 startPos, glm::vec3 upperStartVector, GLfloat startYaw, GLfloat startPitch, GLfloat speed, GLfloat rotation) { position = startPos; worldUpperVector = upperStartVector; yaw = startYaw; pitch = startPitch; direction = glm::vec3(0.0f, 0.0f, -1.0f); cameraSpeed = speed; rotationSpeed = rotation; update(); } void Camera::update() { direction.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch)); direction.y = sin(glm::radians(pitch)); direction.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch)); direction = glm::normalize(direction); rightAxis = glm::normalize(glm::cross(direction, worldUpperVector)); //iloczyn wektorowy kierunku kamery oraz wektora górnego (świata) topAxis = glm::normalize(glm::cross(rightAxis, direction)); //iloczyn wektorowy prawej osi kamery oraz kierunku kamery (prawdziwy kierunek "do góry") } void Camera::MouseControl(GLfloat deltaX, GLfloat deltaY) { deltaX = deltaX * rotationSpeed; deltaY = deltaY * rotationSpeed; yaw += deltaX; pitch += deltaY; if (pitch > 89.0f) pitch = 89.0f; if (pitch < -89.0f) pitch = -89.0f; update(); } void Camera::KeyboardControl(bool* keys, GLfloat timeUnit) { GLfloat deltaPos = cameraSpeed * timeUnit; if (keys[GLFW_KEY_W]) position += direction * deltaPos; if (keys[GLFW_KEY_S]) position -= direction * deltaPos; if (keys[GLFW_KEY_A]) position -= rightAxis * deltaPos; if (keys[GLFW_KEY_D]) position += rightAxis * deltaPos; } glm::mat4 Camera::ComputeCameraMatrix() { return glm::lookAt(position, position + direction, topAxis); //pozycja + kierunek --- zapewnia że kamera będzie skierowana na punkt docelowy }
[ "ceski23@gmail.com" ]
ceski23@gmail.com
a861915426b9c355fe9254704debb2b87b798686
156ae94769a8b0644feb40d73cc4ac0cdc604a36
/fhe/shield_spark/PALISADE/src/core/unittest/UnitTestEncoding.cpp
531d7116a96f2c57fb5b255d57d9ba1112d8a4f9
[ "BSD-2-Clause" ]
permissive
marcelmon/react-fhe
42ecc2e2efb26e5cd64dd6cc865d63b07ead47f8
f6e388785eb608eecce55641b57c2b102724ddd7
refs/heads/master
2020-03-21T03:13:08.271195
2018-09-17T21:35:52
2018-09-17T21:35:52
138,042,108
0
0
null
2018-08-08T04:39:58
2018-06-20T14:13:13
C++
UTF-8
C++
false
false
6,410
cpp
/* * @file * @author TPOC: palisade@njit.edu * * @copyright Copyright (c) 2017, New Jersey Institute of Technology (NJIT) * All rights reserved. * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /* This code exercises the encoding libraries of the PALISADE lattice encryption library. */ #define PROFILE #include "include/gtest/gtest.h" #include <iostream> #include "../lib/lattice/dcrtpoly.h" #include "math/backend.h" #include "encoding/encodings.h" #include "utils/inttypes.h" #include "utils/utilities.h" #include "lattice/elemparamfactory.h" using namespace std; using namespace lbcrypto; class UTEncoding : public ::testing::Test { protected: virtual void SetUp() { } virtual void TearDown() { // Code here will be called immediately after each test // (right before the destructor). } }; TEST_F(UTEncoding,scalar_encoding) { int64_t value = 47; usint m = 8; PlaintextModulus ptm = 128; shared_ptr<ILParams> lp = ElemParamFactory::GenElemParams<ILParamsImpl<BigInteger>>(m); EncodingParams ep( new EncodingParamsImpl( ptm ) ); ScalarEncoding se(lp, ep, value); se.Encode(); EXPECT_EQ( se.GetElement<Poly>()[0].ConvertToInt(), (uint64_t)value ) << "encoding failed"; EXPECT_EQ( se.GetElement<Poly>()[1].ConvertToInt(), (uint64_t)0 ) << "encoding failed"; se.Decode(); EXPECT_EQ( se.GetScalarValue(), value ) << "positive scalar"; ScalarEncoding se2(lp, ep, -value); se2.Encode(); se2.Decode(); EXPECT_EQ( se2.GetScalarValue(), -value ) << "negative scalar"; ScalarEncoding se3(lp, ep, (ptm/2)+1); EXPECT_THROW( se3.Encode(), config_error ) << "Encode did not throw the proper exception"; ScalarEncoding se3n(lp, ep, ((-1*(int64_t)ptm)/2)); EXPECT_THROW( se3n.Encode(), config_error ) << "Encode did not throw the proper exception"; ScalarEncoding se4(lp, ep, ptm/2); se4.Encode(); se4.Decode(); EXPECT_EQ( se4.GetScalarValue(), (int64_t)ptm/2 ) << "largest number"; ScalarEncoding se5(lp, ep, (-1*(int64_t)ptm)/2 + 1); se5.Encode(); se5.Decode(); EXPECT_EQ( se5.GetScalarValue(), (-1*(int64_t)ptm)/2 + 1 ) << "smallest number"; } TEST_F(UTEncoding,coef_packed_encoding) { vector<int64_t> value = {32, 17, 8, -12, -32, 22, -101, 6 }; usint m = 16; shared_ptr<ILParams> lp = ElemParamFactory::GenElemParams<ILParamsImpl<BigInteger>>(m); EncodingParams ep( new EncodingParamsImpl(256) ); CoefPackedEncoding se(lp, ep, value); se.Encode(); se.Decode(); se.SetLength( value.size() ); EXPECT_EQ( se.GetCoefPackedValue(), value ) << "CoefPacked"; } TEST_F(UTEncoding,packed_int_ptxt_encoding) { usint m = 22; PlaintextModulus p = 89; BigInteger modulusQ("955263939794561"); BigInteger squareRootOfRoot("941018665059848"); BigInteger bigmodulus("80899135611688102162227204937217"); BigInteger bigroot("77936753846653065954043047918387"); auto cycloPoly = GetCyclotomicPolynomial<BigVector, BigInteger>(m, modulusQ); ChineseRemainderTransformArb<BigInteger, BigVector>::SetCylotomicPolynomial(cycloPoly, modulusQ); PackedEncoding::SetParams(m, p); shared_ptr<ILParams> lp(new ILParams(m, modulusQ, squareRootOfRoot, bigmodulus, bigroot)); EncodingParams ep(new EncodingParamsImpl(p,8)); std::vector<uint64_t> vectorOfInts1 = { 1,2,3,4,5,6,7,8,0,0 }; PackedEncoding se(lp, ep, vectorOfInts1); se.Encode(); se.Decode(); EXPECT_EQ( se.GetPackedValue(), vectorOfInts1 ) << "packed int"; } TEST_F(UTEncoding,string_encoding) { string value = "Hello, world!"; usint m = 64; shared_ptr<ILParams> lp = ElemParamFactory::GenElemParams<ILParamsImpl<BigInteger>>(m); EncodingParams ep( new EncodingParamsImpl(256) ); StringEncoding se(lp, ep, value); se.Encode(); se.Decode(); EXPECT_EQ( se.GetStringValue(), value ) << "string encode/decode"; // truncate! shared_ptr<ILParams> lp2 = ElemParamFactory::GenElemParams<ILParamsImpl<BigInteger>>(4); StringEncoding se2(lp2, ep, value); se2.Encode(); se2.Decode(); EXPECT_EQ( se2.GetStringValue(), value.substr(0, lp2->GetRingDimension()) ) << "string truncate encode/decode"; } TEST_F(UTEncoding,integer_encoding){ int m = 64; PlaintextModulus ptm = ((uint64_t)1<<30); shared_ptr<ILParams> lp = ElemParamFactory::GenElemParams<ILParamsImpl<BigInteger>>(m); EncodingParams ep( new EncodingParamsImpl(ptm) ); int64_t mv = ((uint64_t)1<<20) + (uint64_t)1; int64_t sv = 9; IntegerEncoding small(lp, ep, sv); IntegerEncoding smallS(lp, ep, -sv); IntegerEncoding medium(lp, ep, mv); IntegerEncoding mediumS(lp, ep, -mv); small.Encode(); smallS.Encode(); medium.Encode(); mediumS.Encode(); small.Decode(); smallS.Decode(); medium.Decode(); mediumS.Decode(); EXPECT_EQ( small.GetIntegerValue(), sv ) << "small"; EXPECT_EQ( smallS.GetIntegerValue(), -sv ) << "small negative"; EXPECT_EQ( medium.GetIntegerValue(), mv ) << "medium"; EXPECT_EQ( mediumS.GetIntegerValue(), -mv ) << "medium negative"; EncodingParams ep2( new EncodingParamsImpl(2) ); IntegerEncoding one(lp, ep2, 1); one.Encode(); one.Decode(); EXPECT_EQ( one.GetIntegerValue(), 1 ) << "one"; IntegerEncoding mone(lp, ep2, -1); EXPECT_THROW( mone.Encode(), config_error ) << "Encode did not throw the proper exception"; }
[ "marcel@crowdbabble.com" ]
marcel@crowdbabble.com
b3b3c78ae4790a1c1c98dfe1be849f7818aa41a2
784f176c759a464f9792fa9edacc4ac63634e24e
/src/libtsduck/base/tsSysUtils.cpp
27d0901bb0c8db0c01cc746c8b14de8002fcc347
[ "BSD-2-Clause" ]
permissive
ajithdesilva/tsduck
efe6475d9351a19dc12a5f9bb0503d9257507d8f
8dfb98034c7a5d86af52cbce0b6efd50123659b7
refs/heads/master
2023-04-29T01:31:16.919758
2021-05-09T18:09:02
2021-05-09T18:09:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
28,504
cpp
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2021, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- #include "tsSysUtils.h" #include "tsStaticInstance.h" #include "tsMutex.h" #include "tsGuard.h" #include "tsTime.h" #include "tsArgs.h" TSDUCK_SOURCE; #if defined(TS_WINDOWS) #include <intrin.h> #include "tsWinUtils.h" #endif #if defined(TS_LINUX) #include "tsFileUtils.h" #endif #if defined(TS_MAC) #include <sys/resource.h> #include <mach/mach.h> #include <mach/message.h> #include <mach/kern_return.h> #include <mach/task_info.h> extern char **environ; // not defined in public headers #endif // External calls to environment variables are not reentrant. Use a global mutex. TS_STATIC_INSTANCE(ts::Mutex, (), EnvironmentMutex) //---------------------------------------------------------------------------- // Return the name of the current application executable file. //---------------------------------------------------------------------------- ts::UString ts::ExecutableFile() { #if defined(TS_WINDOWS) // Window implementation. std::array<::WCHAR, 2048> name; ::DWORD length = ::GetModuleFileNameW(nullptr, name.data(), ::DWORD(name.size())); return UString(name, length); #elif defined(TS_LINUX) // Linux implementation. // /proc/self/exe is a symbolic link to the executable. return ResolveSymbolicLinks(u"/proc/self/exe"); #elif defined(TS_MAC) // MacOS implementation. // The function proc_pidpath is documented as "private" and "subject to change". // Another option is _NSGetExecutablePath (not tested here yet). int length; char name[PROC_PIDPATHINFO_MAXSIZE]; if ((length = ::proc_pidpath(getpid(), name, sizeof(name))) < 0) { throw ts::Exception(u"proc_pidpath error", errno); } else { assert(length <= int(sizeof(name))); return UString::FromUTF8(name, length); } #else #error "ts::ExecutableFile not implemented on this system" #endif } //---------------------------------------------------------------------------- //! Get the name of the executable or shared library containing the caller. //---------------------------------------------------------------------------- ts::UString ts::CallerLibraryFile() { #if defined(TS_MSC) // Window implementation. // Get return address of current function (in caller code). void* const ret = _ReturnAddress(); // Get the module (DLL) into which this address can be found. ::HMODULE handle = nullptr; if (::GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, ::LPCWSTR(ret), &handle) == 0) { return UString(); } else { std::array<::WCHAR, 2048> name; ::DWORD length = ::GetModuleFileNameW(handle, name.data(), ::DWORD(name.size())); return UString(name, length); } #elif defined(TS_GCC) || defined(TS_LLVM) // GCC and LLVM/clang implementation. // Get return address of current function (in caller code). void* const ret = __builtin_return_address(0); // Get the shared library into which this address can be found. ::Dl_info info; TS_ZERO(info); if (ret != nullptr && ::dladdr(ret, &info) != 0 && info.dli_fname != nullptr) { return UString::FromUTF8(info.dli_fname); } else { return UString(); } #else #error "ts::CallerLibraryFile not implemented on this system" #endif } //---------------------------------------------------------------------------- // Suspend the current thread for the specified period //---------------------------------------------------------------------------- void ts::SleepThread(MilliSecond delay) { #if defined(TS_WINDOWS) // Window implementation. ::Sleep(::DWORD(delay)); #else // POSIX implementation. ::timespec requested, remain; requested.tv_sec = time_t(delay / 1000); // seconds requested.tv_nsec = long((delay % 1000) * 1000000); // nanoseconds while (::nanosleep(&requested, &remain) < 0) { if (errno == EINTR) { // Interrupted by a signal. Wait again. requested = remain; } else { // Actual error throw ts::Exception(u"nanosleep error", errno); } } #endif } //---------------------------------------------------------------------------- // Get current process characteristics. //---------------------------------------------------------------------------- ts::ProcessId ts::CurrentProcessId() { #if defined(TS_WINDOWS) return ::GetCurrentProcessId(); #else return ::getpid(); #endif } bool ts::IsPrivilegedUser() { #if defined(TS_UNIX) return ::geteuid() == 0; #else ::SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; ::PSID AdministratorsGroup; ::BOOL ok = ::AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup); if (ok) { if (!::CheckTokenMembership(nullptr, AdministratorsGroup, &ok)) { ok = false; } ::FreeSid(AdministratorsGroup); } return ok; #endif } //---------------------------------------------------------------------------- // Format an error code into a string //---------------------------------------------------------------------------- #if !defined(TS_WINDOWS) // Depending on GNU vs. POSIX, strerror_r returns an int or a char*. // There are two short functions to handle the strerror_r result. // The C++ compiler will automatically invoke the right one. // The other one is unused (disable unused warning). TS_PUSH_WARNING() TS_LLVM_NOWARNING(unused-function) TS_GCC_NOWARNING(unused-function) namespace { // POSIX version, strerror_r returns an int, leave result unmodified. inline void handle_strerror_r(bool& found, char*& result, int strerror_t_ret) { found = strerror_t_ret == 0; // success } // GNU version, strerror_r returns char*, not necessarily in buffer. inline void handle_strerror_r(bool& found, char*& result, char* strerror_t_ret) { result = strerror_t_ret; // actual message found = result != nullptr; } } TS_POP_WARNING() #endif // not Windows // Portable public interface: ts::UString ts::SysErrorCodeMessage(ts::SysErrorCode code) { #if defined(TS_WINDOWS) return WinErrorMessage(code); #else char message[1024]; TS_ZERO(message); char* result = message; bool found = false; handle_strerror_r(found, result, strerror_r(code, message, sizeof(message))); if (found) { // Make sure message is nul-terminated. message[sizeof(message) - 1] = 0; // Remove trailing newlines (if any) for (size_t i = ::strlen(result); i > 0 && (result[i - 1] == '\n' || result[i - 1] == '\r'); result[--i] = 0) {} return UString::FromUTF8(result); } // At this point, the message is not found. return UString::Format(u"System error %d (0x%X)", {code, code}); #endif } //---------------------------------------------------------------------------- // Get metrics for the current process //---------------------------------------------------------------------------- void ts::GetProcessMetrics(ProcessMetrics& metrics) { metrics.cpu_time = 0; metrics.vmem_size = 0; #if defined(TS_WINDOWS) // Windows implementation // Get a handle to the current process ::HANDLE proc(::GetCurrentProcess()); // Get process CPU time ::FILETIME creation_time, exit_time, kernel_time, user_time; if (::GetProcessTimes(proc, &creation_time, &exit_time, &kernel_time, &user_time) == 0) { throw ts::Exception(u"GetProcessTimes error", ::GetLastError()); } metrics.cpu_time = ts::Time::Win32FileTimeToMilliSecond(kernel_time) + ts::Time::Win32FileTimeToMilliSecond(user_time); // Get virtual memory size ::PROCESS_MEMORY_COUNTERS_EX mem_counters; if (::GetProcessMemoryInfo(proc, (::PROCESS_MEMORY_COUNTERS*)&mem_counters, sizeof(mem_counters)) == 0) { throw ts::Exception(u"GetProcessMemoryInfo error", ::GetLastError()); } metrics.vmem_size = mem_counters.PrivateUsage; #elif defined(TS_LINUX) // Linux implementation. // Definition of data available from /proc/<pid>/stat // See man page for proc(5) for more details. struct ProcessStatus { int pid; // The process id. char state; // One char from "RSDZTW" int ppid; // The PID of the parent. int pgrp; // The process group ID of the process. int session; // The session ID of the process. int tty_nr; // The tty the process uses. int tpgid; // Process group ID which owns the tty unsigned long flags; // The flags of the process. unsigned long minflt; // Minor faults the process made unsigned long cminflt; // Minor faults the process's children made unsigned long majflt; // Major faults the process made unsigned long cmajflt; // Major faults the process's children made unsigned long utime; // Number of jiffies in user mode unsigned long stime; // Number of jiffies in kernel mode long cutime; // Jiffies process's children in user mode long cstime; // Jiffies process's children in kernel mode long priority; // Standard nice value, plus fifteen. long nice; // Nice value, from 19 (nicest) to -19 (not nice) long itrealvalue; // Jiffies before the next SIGALRM unsigned long starttime; // Jiffies the process started after system boot unsigned long vsize; // Virtual memory size in bytes. long rss; // Resident Set Size unsigned long rlim; // Current limit in bytes on the rss unsigned long startcode; // Address above which program text can run. unsigned long endcode; // Address below which program text can run. unsigned long startstack; // Address of the start of the stack unsigned long kstkesp; // Current value of esp (stack pointer) unsigned long kstkeip; // Current EIP (instruction pointer). unsigned long signal; // Bitmap of pending signals (usually 0). unsigned long blocked; // Bitmap of blocked signals unsigned long sigignore; // Bitmap of ignored signals. unsigned long sigcatch; // Bitmap of catched signals. unsigned long wchan; // "Channel" in which the process is waiting unsigned long nswap; // Number of pages swapped - not maintained. unsigned long cnswap; // Cumulative nswap for child processes. int exit_signal; // Signal to be sent to parent when we die. int processor; // CPU number last executed on. }; static const char filename[] = "/proc/self/stat"; FILE* fp = fopen(filename, "r"); if (fp == nullptr) { throw ts::Exception(UString::Format(u"error opening %s", {filename}), errno); } ProcessStatus ps; int expected = 37; int count = fscanf(fp, "%d %*s %c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu " "%ld %ld %ld %ld %*d %ld %lu %lu %ld %lu %lu %lu %lu " "%lu %lu %lu %lu %lu %lu %lu %lu %lu %d %d", &ps.pid, &ps.state, &ps.ppid, &ps.pgrp, &ps.session, &ps.tty_nr, &ps.tpgid, &ps.flags, &ps.minflt, &ps.cminflt, &ps.majflt, &ps.cmajflt, &ps.utime, &ps.stime, &ps.cutime, &ps.cstime, &ps.priority, &ps.nice, &ps.itrealvalue, &ps.starttime, &ps.vsize, &ps.rss, &ps.rlim, &ps.startcode, &ps.endcode, &ps.startstack, &ps.kstkesp, &ps.kstkeip, &ps.signal, &ps.blocked, &ps.sigignore, &ps.sigcatch, &ps.wchan, &ps.nswap, &ps.cnswap, &ps.exit_signal, &ps.processor); fclose(fp); if (count != expected) { throw ts::Exception(UString::Format(u"error reading %s, got %d values, expected %d", {filename, count, expected})); } // Get virtual memory size metrics.vmem_size = ps.vsize; // Evaluate CPU time unsigned long jps = sysconf(_SC_CLK_TCK); // jiffies per second unsigned long jiffies = ps.utime + ps.stime; // CPU time in jiffies metrics.cpu_time = (MilliSecond(jiffies) * 1000) / jps; #elif defined(TS_MAC) // MacOS implementation. // First, get the virtual memory size using task_info (mach kernel). ::mach_task_basic_info_data_t taskinfo; TS_ZERO(taskinfo); ::mach_msg_type_number_t count = MACH_TASK_BASIC_INFO_COUNT; const ::kern_return_t status1 = ::task_info(::mach_task_self(), MACH_TASK_BASIC_INFO, ::task_info_t(&taskinfo), &count); if (status1 != KERN_SUCCESS) { throw ts::Exception(u"task_info error"); } metrics.vmem_size = taskinfo.virtual_size; // Then get CPU time using getrusage. ::rusage usage; const int status2 = ::getrusage(RUSAGE_SELF, &usage); if (status2 < 0) { throw ts::Exception(u"getrusage error"); } // Add system time and user time, in milliseconds. metrics.cpu_time = MilliSecond(usage.ru_stime.tv_sec) * MilliSecPerSec + MilliSecond(usage.ru_stime.tv_usec) / MicroSecPerMilliSec + MilliSecond(usage.ru_utime.tv_sec) * MilliSecPerSec + MilliSecond(usage.ru_utime.tv_usec) / MicroSecPerMilliSec; #else #error "ts::GetProcessMetrics not implemented on this system" #endif } //---------------------------------------------------------------------------- // Ignore SIGPIPE. On UNIX systems: writing to a broken pipe returns an // error instead of killing the process. On Windows systems: does nothing. //---------------------------------------------------------------------------- void ts::IgnorePipeSignal() { #if !defined(TS_WINDOWS) ::signal(SIGPIPE, SIG_IGN); #endif } //---------------------------------------------------------------------------- // Put standard input / output stream in binary mode. // On UNIX systems, this does not make any difference. // On Windows systems, however, in a stream which is not open in // binary mode, there is automatic translation between LF and CR-LF. // The standard input / output are open in text mode (non-binary). // These functions force them into binary mode. // Return true on success, false on error. // If report is a subclass or ts::Args, also terminate application. //---------------------------------------------------------------------------- bool ts::SetBinaryModeStdin(Report& report) { #if defined(TS_WINDOWS) report.debug(u"setting standard input to binary mode"); if (::_setmode(_fileno(stdin), _O_BINARY) < 0) { report.error(u"cannot set standard input to binary mode"); Args* args = dynamic_cast<Args*>(&report); if (args != 0) { args->exitOnError(); } return false; } #endif return true; } bool ts::SetBinaryModeStdout(Report& report) { #if defined(TS_WINDOWS) report.debug(u"setting standard output to binary mode"); if (::_setmode(_fileno(stdout), _O_BINARY) < 0) { report.error(u"cannot set standard output to binary mode"); Args* args = dynamic_cast<Args*>(&report); if (args != 0) { args->exitOnError(); } return false; } #endif return true; } //---------------------------------------------------------------------------- // Check if an environment variable exists //---------------------------------------------------------------------------- bool ts::EnvironmentExists(const UString& name) { Guard lock(EnvironmentMutex::Instance()); #if defined(TS_WINDOWS) std::array <::WCHAR, 2> unused; return ::GetEnvironmentVariableW(name.wc_str(), unused.data(), ::DWORD(unused.size())) != 0; #else // Flawfinder: ignore: Environment variables are untrustable input. return ::getenv(name.toUTF8().c_str()) != nullptr; #endif } //---------------------------------------------------------------------------- // Get the value of an environment variable. // Return default value if does not exist. //---------------------------------------------------------------------------- ts::UString ts::GetEnvironment(const UString& name, const UString& def) { Guard lock(EnvironmentMutex::Instance()); #if defined(TS_WINDOWS) std::vector<::WCHAR> value; value.resize(512); ::DWORD size = ::GetEnvironmentVariableW(name.wc_str(), value.data(), ::DWORD(value.size())); if (size >= ::DWORD(value.size())) { value.resize(size_t(size + 1)); size = ::GetEnvironmentVariableW(name.wc_str(), value.data(), ::DWORD(value.size())); } return size <= 0 ? def : UString(value, size); #else // Flawfinder: ignore: Environment variables are untrustable input. const char* value = ::getenv(name.toUTF8().c_str()); return value != nullptr ? UString::FromUTF8(value) : def; #endif } //---------------------------------------------------------------------------- // Set the value of an environment variable. //---------------------------------------------------------------------------- bool ts::SetEnvironment(const UString& name, const UString& value) { Guard lock(EnvironmentMutex::Instance()); #if defined(TS_WINDOWS) return ::SetEnvironmentVariableW(name.wc_str(), value.wc_str()) != 0; #else // In case of error, setenv(3) is documented to return -1 but not setting errno. return ::setenv(name.toUTF8().c_str(), value.toUTF8().c_str(), 1) == 0; #endif } //---------------------------------------------------------------------------- // Delete an environment variable. //---------------------------------------------------------------------------- bool ts::DeleteEnvironment(const UString& name) { Guard lock(EnvironmentMutex::Instance()); #if defined(TS_WINDOWS) return ::SetEnvironmentVariableW(name.wc_str(), nullptr) != 0; #else // In case of error, unsetenv(3) is documented to return -1 but and set errno. // It is also documented to silently ignore non-existing variables. return ::unsetenv(name.toUTF8().c_str()) == 0; #endif } //---------------------------------------------------------------------------- // Expand environment variables inside a file path (or any string). // Environment variable references are '$name' or '${name}'. // In the first form, 'name' is the longest combination of letters, digits and underscore. // A combination \$ is interpreted as a literal $, not an environment variable reference. //---------------------------------------------------------------------------- ts::UString ts::ExpandEnvironment(const UString& path) { const size_t len = path.length(); UString expanded; expanded.reserve(2 * len); size_t index = 0; while (index < len) { if (path[index] == '\\' && index+1 < len && path[index+1] == '$') { // Escaped dollar expanded += '$'; index += 2; } else if (path[index] != '$') { // Regular character expanded += path[index++]; } else { // Environment variable reference. // First, locate variable name and move index in path. UString varname; if (++index < len) { if (path[index] == '{') { // '${name}' format const size_t last = path.find('}', index); if (last == NPOS) { varname = path.substr(index + 1); index = len; } else { varname = path.substr(index + 1, last - index - 1); index = last + 1; } } else { // '$name' format const size_t last = path.find_first_not_of(u"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_", index); if (last == NPOS) { varname = path.substr(index); index = len; } else { varname = path.substr(index, last - index); index = last; } } } // Second, replace environment variable expanded += GetEnvironment(varname); } } return expanded; } //---------------------------------------------------------------------------- // Add a "name=value" string to a container. // If exact is true, the definition is always valid. // Otherwise, cleanup the string and ignore lines without "=" //---------------------------------------------------------------------------- namespace { void AddNameValue(ts::Environment& env, const ts::UString& line, bool exact) { ts::UString s(line); // With loose line, do some initial cleanup. if (!exact) { s.trim(); if (s.empty() || s.front() == u'#') { // Empty or comment line return; } } // Locate the "=" between name and value. const size_t pos = s.find(u"="); if (pos == ts::NPOS) { // With exact line, no "=" means empty value. // With loose line, not a valid definition. if (exact) { env.insert(std::make_pair(s, ts::UString())); } } else { // Isolate name and value. ts::UString name(s.substr(0, pos)); ts::UString value(s.substr(pos + 1)); // With loose line, do some additional cleanup. if (!exact) { name.trim(); value.trim(); if (value.size() >= 2 && (value.front() == u'\'' || value.front() == u'"') && value.back() == value.front()) { // Remove surrounding quotes in the value. value.pop_back(); value.erase(0, 1); } } if (!name.empty()) { env.insert(std::make_pair(name, value)); } } } } //---------------------------------------------------------------------------- // Get the content of the entire environment (all environment variables). //---------------------------------------------------------------------------- void ts::GetEnvironment(Environment& env) { Guard lock(EnvironmentMutex::Instance()); env.clear(); #if defined(TS_WINDOWS) const ::LPWCH strings = ::GetEnvironmentStringsW(); if (strings != 0) { size_t len; for (const ::WCHAR* p = strings; (len = ::wcslen(p)) != 0; p += len + 1) { assert(sizeof(::WCHAR) == sizeof(UChar)); AddNameValue(env, UString(reinterpret_cast<const UChar*>(p), len), true); } ::FreeEnvironmentStringsW(strings); } #else for (char** p = ::environ; *p != nullptr; ++p) { AddNameValue(env, UString::FromUTF8(*p), true); } #endif } //---------------------------------------------------------------------------- // Load a text file containing environment variables. //---------------------------------------------------------------------------- bool ts::LoadEnvironment(Environment& env, const UString& fileName) { env.clear(); UStringList lines; const bool ok = UString::Load(lines, fileName); if (ok) { for (UStringList::const_iterator it = lines.begin(); it != lines.end(); ++it) { AddNameValue(env, *it, false); } } return ok; } //---------------------------------------------------------------------------- // Check if the standard input/output/error is a terminal. //---------------------------------------------------------------------------- #if defined(TS_WINDOWS) namespace { // On Windows, only the DOS and PowerShell consoles are considered as terminal. // We also want to recognize as terminals the Cygwin and Msys consoles (mintty). bool StdHandleIsATerminal(::DWORD ns) { const ::HANDLE handle = ::GetStdHandle(ns); switch (::GetFileType(handle)) { case FILE_TYPE_CHAR: { // A native console (DOS or PowerShell). return true; } case FILE_TYPE_PIPE: { // Check if associated file name matches Cygwin or Msys pty name. // With mintty, the standard devices are named pipes. With Cygwin, // the name starts with \cygwin. With Msys, the name starts with \msys. // Then, if the device is the mintty console, the name contains -pty. // For actual pipes, -pty is replaced by -pipe. const ts::UString name = ts::WinDeviceName(handle).toLower(); return (name.find(u"\\cygwin") != ts::NPOS || name.find(u"\\msys") != ts::NPOS) && name.find(u"-pty") != ts::NPOS; } default: { // Cannot be a terminal. return false; } } } } #endif bool ts::StdInIsTerminal() { #if defined(TS_WINDOWS) return StdHandleIsATerminal(STD_INPUT_HANDLE); #else return ::isatty(STDIN_FILENO); #endif } bool ts::StdOutIsTerminal() { #if defined(TS_WINDOWS) return StdHandleIsATerminal(STD_OUTPUT_HANDLE); #else return ::isatty(STDOUT_FILENO); #endif } bool ts::StdErrIsTerminal() { #if defined(TS_WINDOWS) return StdHandleIsATerminal(STD_ERROR_HANDLE); #else return ::isatty(STDERR_FILENO); #endif } //---------------------------------------------------------------------------- // Get the name of a class from the @c type_info of an object. //---------------------------------------------------------------------------- #if defined(TS_GCC) #include <cxxabi.h> #endif ts::UString ts::ClassName(const std::type_info& info) { UString name; const char* const rtti = info.name(); if (rtti != nullptr) { // By default, use the plain RTTI name. Not always a pretty name. name.assignFromUTF8(rtti); #if defined(TS_GCC) // With gcc and clang, this is a C++ mangled name. // Demangle it using the portable C++ ABI library. int status = 0; char* const demangled = abi::__cxa_demangle(rtti, nullptr, nullptr, &status); if (demangled != nullptr) { name.assignFromUTF8(demangled); ::free(demangled); } #endif // Cleanup various initial decoration, depending on compiler. if (name.startWith(u"class ")) { name.erase(0, 6); } // MSC: `anonymous namespace':: // GCC: (anonymous namespace):: if (name.find(u"anonymous namespace") == 1 && name.find(u"::") == 21) { name.erase(0, 23); } } return name; }
[ "thierry@lelegard.fr" ]
thierry@lelegard.fr
37dd63086dc821c898fc88d427185202c9ef28d0
ee07ddcba41df8866b838d2749eb2c75bac76dca
/tests/simplest_web_wiznet/simplest_web_wiznet.ino
84100d96ac3adc9e73dd7a3b9d4696d33e71809a
[]
no_license
ioanvapi/arduino-sms-service
6f2e678c178998a75f5270b8cdb124f993e3e432
4459a89b6625ced4eaedd9af0800f7c9a8221cfc
refs/heads/master
2021-01-02T09:02:31.150839
2014-06-06T10:53:43
2014-06-06T10:53:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,454
ino
/* Built on Arduino Nano + Wiznet W5100 Ethernet shield and Ethernet library. Tested in a browser and a POSTMAN chrome plugin End of line = '13 10' = '\r \n' End of request = empty line = '13 10' = '\r \n' Note: It works with both GET and POST requests. */ #include <SPI.h> #include <Ethernet.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(10, 220, 10 , 171); IPAddress mask(255, 255, 0 , 0); IPAddress gateway(10, 220, 0 , 1); IPAddress domain(10, 220, 10 , 1); EthernetServer server(80); EthernetClient client; void setup() { Serial.begin(9600); Ethernet.begin(mac, ip, domain, gateway, mask); server.begin(); Serial.print(F("## server is at ")); Serial.println(Ethernet.localIP()); } void loop() { if (client = server.available()) { Serial.println(F("\n## new client")); while (client.available()) { Serial.write((char) client.read()); } send_http_response(client); delay(5); client.stop(); Serial.println(F("\n## client disconnected")); } } void send_http_response(EthernetClient client) { // send a standard http response client.println(F("HTTP/1.1 200 OK")); client.println(F("Content-Type: text/html")); client.println(); client.println(F("<!DOCTYPE HTML>")); client.println(F("<html>")); client.print(F("Hello world from Arduino !!!")); client.println(F("</html>")); client.println(); }
[ "vapirovschi@synygy.com" ]
vapirovschi@synygy.com
19398f31d7e41d067532393ca851a1842437a5a6
a96c3be032187b3e23a47f1e893797616fb80a14
/Source/Encounters/Private/AI/BTTask_Guard.cpp
55bc66704397f1956b5d669001e0cb679b76088b
[]
no_license
lldvvbll/Encounters
0c7d9c90b5bbfc761038e1eea5ed0db10d760bfb
febbf3ab1f12bbee23877e3cdf6991fcd516d5f8
refs/heads/main
2023-04-13T06:16:50.603147
2021-04-11T14:19:47
2021-04-11T14:19:47
322,254,098
0
0
null
null
null
null
UTF-8
C++
false
false
530
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "AI/BTTask_Guard.h" #include "EncAIController.h" #include "Character/NpcCharacter.h" EBTNodeResult::Type UBTTask_Guard::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) { EBTNodeResult::Type Result = Super::ExecuteTask(OwnerComp, NodeMemory); auto Char = Cast<ANpcCharacter>(OwnerComp.GetAIOwner()->GetPawn()); if (Char == nullptr) return EBTNodeResult::Failed; Char->Guard(); return EBTNodeResult::Succeeded; }
[ "lldvvbll@nate.com" ]
lldvvbll@nate.com
920c236b143c1804d94fa38c61fee7c00b503487
dd1e3221c0b9378457ef54a409788b42b8df66ea
/Include/ViewPerspectiveHighlight.h
ac01fe74996d17a953979865a614c45a593190b9
[ "MIT" ]
permissive
FTD2012/Hieroglyph3
b1b83bea2c7b8e08c2916d2b9006ae77264bfcc4
10adfe1639747ecb6aa0bb5a4d2618383758d361
refs/heads/master
2022-11-02T07:28:00.660292
2020-06-19T12:41:56
2020-06-19T12:41:56
273,384,411
2
2
null
null
null
null
UTF-8
C++
false
false
1,831
h
//-------------------------------------------------------------------------------- // This file is a portion of the Hieroglyph 3 Rendering Engine. It is distributed // under the MIT License, available in the root of this distribution and // at the following URL: // // http://www.opensource.org/licenses/mit-license.php // // Copyright (c) Jason Zink //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // ViewPerspectiveHighlight // //-------------------------------------------------------------------------------- #ifndef ViewPerspectiveHighlight_h #define ViewPerspectiveHighlight_h //-------------------------------------------------------------------------------- #include "SceneRenderTask.h" #include "FullscreenActor.h" //-------------------------------------------------------------------------------- namespace Glyph3 { class Entity3D; class ViewPerspectiveHighlight : public SceneRenderTask { public: ViewPerspectiveHighlight( RendererDX11& Renderer, ResourcePtr RenderTarget, ResourcePtr DepthTarget = 0 ); virtual ~ViewPerspectiveHighlight(); virtual void Update( float fTime ); virtual void QueuePreTasks( RendererDX11* pRenderer ); virtual void ExecuteTask( PipelineManagerDX11* pPipelineManager, IParameterManager* pParamManager ); virtual void Resize( UINT width, UINT height ); void SetRenderTargets( ResourcePtr RenderTarget, ResourcePtr DepthTarget = nullptr ); virtual std::wstring GetName(); ResourcePtr m_SilhouetteTarget; FullscreenActor m_SilhouetteActor; protected: ResourcePtr m_RenderTarget; ResourcePtr m_DepthTarget; }; }; //-------------------------------------------------------------------------------- #endif // ViewPerspectiveHighlight_h
[ "invokerleve@gmail.com" ]
invokerleve@gmail.com
3511eeb54a3cc16ff287121d4a2ce74496b37387
bb85dc81b94a1ec329399f011a04857102641ff7
/1.cpp
8386c26892a700d6e2778a1727cdd8fd1edc83a0
[]
no_license
akahana-1/JOI2012-2013p
86cc036e86b244fc5d2acacd38b266583361490c
e5522f5075815fe4087ab14fb43b6d07d2c53645
refs/heads/master
2021-01-02T22:51:41.703603
2013-01-09T19:27:40
2013-01-09T19:27:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
347
cpp
#include <iostream> #include <cmath> using namespace std; int main(){ int n,ta,tb; double a,b,c,d; cin >> n; cin >> a >> b >> c >> d; a /= c; b /= d; ta = (int)(ceil(a)); tb = (int)(ceil(b)); if(ta > tb){ cout << n - ta << endl; } else { cout << n - tb << endl; } return 0; }
[ "akahana@akahana-PC.(none)" ]
akahana@akahana-PC.(none)
584abc0c91d92ac1e606d85ff60caf750b6c5df7
cb38f5da8916a8c8192fd0d7729652f02417ede7
/BeagleBone_Blue_catkin_ws/src/navigation/src/prototype_mission_4_1.cpp
e0c1105d8daeb4b7e2a92d900a4f2826313cf412
[ "MIT" ]
permissive
raymondturrisi/MiniMAUV-software
fe42057687e4fc42436309bd7cc5f0d729f3d638
442c3238e3ca441a5fb9544da4163ef2afbaafda
refs/heads/main
2023-04-23T22:19:44.685960
2021-05-12T14:42:14
2021-05-12T14:42:14
306,679,229
2
0
null
null
null
null
UTF-8
C++
false
false
6,383
cpp
/* * @file prototype_mission_4_1.cpp * @Node name: prototype_mission_4_1 * @Publishing to: * All * @Subscribing to: * none * * @description * Prototype mission 4_1 with open loop controls * 1) Get into horizontal cruising configuration * 2) Test 2 PWMs for 10 seconds each [1510, 1520] * * @author | initials * Raymond Turrisi, raymond.turrisi@gmail.com | rt * @contributors | initials * - * - * @log * 11/14/2020: Created prototype_mission_4_1 * * */ #include <sstream> #include <thread> #include <chrono> #include <ctime> #include <cmath> #include <signal.h> #include <ratio> #include <unistd.h> #include "ros/ros.h" #include "std_msgs/Int32.h" #include "std_msgs/Bool.h" #include "std_msgs/Float32.h" //shuts down if ctrl^c void MySigintHandler(int sig) { ROS_INFO("Shutting down: prototype_mission_1"); ros::shutdown(); return; } //subscriber variables float vbs_cdist = 20, beat = 0; bool vbs_calibrated = false, leaking = false; //subscriber callbacks void vbs_cdistCallback(const std_msgs::Float32::ConstPtr& msg) { vbs_cdist = msg->data; } void vbs_calibratedCallback(const std_msgs::Bool::ConstPtr& msg) { vbs_calibrated = msg->data; } void beatCallback(const std_msgs::Float32::ConstPtr& msg) { beat = msg->data; } void leakingCallback(const std_msgs::Float32::ConstPtr& msg) { leaking = msg->data; } int main(int argc, char **argv) { // initialize a ros node (name used in ros context) ros::init(argc, argv, "prototype_mission_6"); // create a handle of the node (name used in the file) ros::NodeHandle pm4_1; signal(SIGINT, MySigintHandler); //subscribers: vbs_dist, vbs_calibrated, beat ros::Subscriber vbs_cdist_sub = pm4_1.subscribe("vbs/vbs_current_dist", 1, vbs_cdistCallback); ros::Subscriber vbs_calibrated_sub = pm4_1.subscribe("vbs/vbs_calibrated", 1, vbs_calibratedCallback); ros::Subscriber heartbeat_sub = pm4_1.subscribe("heartbeat/beat", 1, beatCallback); ros::Subscriber leaking_sub = pm4_1.subscribe("heartbeat/leaking", 1, leakingCallback); //publishers ros::Publisher hfleft_ang_pub = pm4_1.advertise<std_msgs::Float32>("dtt/hfleft_ang", 1); ros::Publisher hfright_ang_pub = pm4_1.advertise<std_msgs::Float32>("dtt/hfright_ang", 1); ros::Publisher escleft_pub = pm4_1.advertise<std_msgs::Float32>("dtt/escleft", 1); ros::Publisher escright_pub = pm4_1.advertise<std_msgs::Float32>("dtt/escright", 1); ros::Publisher vbs_desired_dist_pub = pm4_1.advertise<std_msgs::Float32>("vbs/vbs_desired_dist", 1); ros::Publisher mm_ang_pub = pm4_1.advertise<std_msgs::Float32>("mm/mm_ang", 1); ros::Publisher vbs_calibrated_pub = pm4_1.advertise<std_msgs::Bool>("vbs/vbs_calibrated", 1); //publishing variables std_msgs::Float32 hfleft_ang; std_msgs::Float32 hfright_ang; std_msgs::Float32 escleft; std_msgs::Float32 escright; std_msgs::Float32 vbs_desired_dist; std_msgs::Bool vbs_calibrated_pub_msg; std_msgs::Float32 mm_ang; ros::Rate loop_rate(10); while(ros::ok()) { ROS_INFO("T-10..\n"); for(int i = 10; i >= 0; i--) { ROS_INFO("%i\n", i); ros::Duration(1).sleep(); } ROS_INFO("Starting\n"); //1a) Get into horizontal cruising configuration hfleft_ang.data = 180; hfright_ang.data = 180; escleft.data = 1500; escright.data = 1500; vbs_desired_dist.data = 80; mm_ang.data = 90; while((std::abs(vbs_desired_dist.data - vbs_cdist) > 5) && !leaking) { ROS_INFO("1a) dist err %f\n", std::abs(vbs_desired_dist.data - vbs_cdist)); hfleft_ang_pub.publish(hfleft_ang); hfright_ang_pub.publish(hfright_ang); escleft_pub.publish(escleft); escright_pub.publish(escright); vbs_desired_dist_pub.publish(vbs_desired_dist); mm_ang_pub.publish(mm_ang); ros::spinOnce(); ros::Duration(0.5).sleep(); } //1b) Hold into horizontal cruising configuration for 5 seconds >> for ~~ hfleft_ang.data = 180; hfright_ang.data = 180; escleft.data = 1500; escright.data = 1500; vbs_desired_dist.data = 80; mm_ang.data = 90; for(int i = 0; i < 10; i++) { if(leaking) { break; } ROS_INFO("1b) i %i\n", i); hfleft_ang_pub.publish(hfleft_ang); hfright_ang_pub.publish(hfright_ang); escleft_pub.publish(escleft); escright_pub.publish(escright); vbs_desired_dist_pub.publish(vbs_desired_dist); mm_ang_pub.publish(mm_ang); ros::spinOnce(); ros::Duration(1).sleep(); } //2a) Cruise at 1540 PWM for 10 seconds >> for ~~ hfleft_ang.data = 180; hfright_ang.data = 180; escleft.data = 1540; escright.data = 1540; vbs_desired_dist.data = 80; mm_ang.data = 90; for(int i = 0; i < 10; i++) { if(leaking) { break; } ROS_INFO("2a) i %i\n", i); hfleft_ang_pub.publish(hfleft_ang); hfright_ang_pub.publish(hfright_ang); escleft_pub.publish(escleft); escright_pub.publish(escright); vbs_desired_dist_pub.publish(vbs_desired_dist); mm_ang_pub.publish(mm_ang); ros::spinOnce(); ros::Duration(1).sleep(); } //2b) Cruise at 1560 PWM for 10 seconds >> for ~~ hfleft_ang.data = 180; hfright_ang.data = 180; escleft.data = 1560; escright.data = 1560; vbs_desired_dist.data = 80; mm_ang.data = 90; for(int i = 0; i < 10; i++) { if(leaking) { break; } ROS_INFO("2b) i %i\n", i); hfleft_ang_pub.publish(hfleft_ang); hfright_ang_pub.publish(hfright_ang); escleft_pub.publish(escleft); escright_pub.publish(escright); vbs_desired_dist_pub.publish(vbs_desired_dist); mm_ang_pub.publish(mm_ang); ros::spinOnce(); ros::Duration(1).sleep(); } //3) Reset all actuators for 5 seconds >> for ~~ hfleft_ang.data = 180; hfright_ang.data = 180; escleft.data = 1500; escright.data = 1500; vbs_desired_dist.data = 80; mm_ang.data = 90; for(int i = 0; i < 10; i++) { ROS_INFO("exit) i %i\n", i); hfleft_ang_pub.publish(hfleft_ang); hfright_ang_pub.publish(hfright_ang); escleft_pub.publish(escleft); escright_pub.publish(escright); vbs_desired_dist_pub.publish(vbs_desired_dist); mm_ang_pub.publish(mm_ang); ros::spinOnce(); ros::Duration(1).sleep(); } ros::shutdown(); } return 0; }
[ "raymond.turrisi@gmail.com" ]
raymond.turrisi@gmail.com
5259c6c15f1c9d57553be8c9535cb1e6c5e7a2f1
cf4659eacbd05ca334c5cd14b3e01d3128c74914
/src/Native/LdaNative/utils.hpp
7b71ec67da5881ec36aa9c46c593caa26a552c09
[ "MIT" ]
permissive
dotnet/machinelearning
86ae73e4ff43408307244681b8a78d287d7fb83b
d6927515d8014442d35ee22817ec7c40b9e7eec7
refs/heads/main
2023-09-03T19:56:28.278537
2023-09-02T04:06:55
2023-09-02T04:06:55
132,021,166
8,927
2,191
MIT
2023-09-13T17:12:31
2018-05-03T16:20:42
C#
UTF-8
C++
false
false
1,072
hpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #pragma once #define NOMINMAX #include <condition_variable> #include <deque> #include <atomic> #include <mutex> #include <list> namespace lda { double LogGamma(double xx); double get_time(); struct LDAEngineAtomics { LDAEngineAtomics() :doc_ll_(0), word_ll_(0), num_tokens_clock_(0), thread_counter_(0){} ~LDAEngineAtomics() {} std::atomic<double> doc_ll_; std::atomic<double> word_ll_; // # of tokens processed in a Clock() call. std::atomic<int> num_tokens_clock_; std::atomic<int> thread_counter_; std::mutex global_mutex_; }; class CBlockedIntQueue { public: void clear(); int pop(); void push(int value); private: std::mutex _mutex; std::condition_variable _condition; std::deque<int> _queue; }; }
[ "shauheen@users.noreply.github.com" ]
shauheen@users.noreply.github.com
9eb3626a5c8114d970d313661b2eadfaae4f60ed
e020c8080f09a1a174a8a8841eab3ddb2b720b75
/MyStudy/02_WinAPI/DeadParticle.cpp
cde5078db417b8039882de107403755aba5a1128
[]
no_license
eazuooz/WindowsAPI_Portfolio
c19bcf912d5ff2fb55955b7ba390c036326e41d3
f9e6e3645a1a59e62c7522a0f45fa97c76e1c3e9
refs/heads/master
2023-07-02T16:13:15.996565
2021-07-27T03:22:13
2021-07-27T03:22:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
937
cpp
#include "stdafx.h" #include "DeadParticle.h" #include "AniRender.h" #include <JTIME.h> #include <Well512.h> #define m_PI 3.141592 DeadParticle::DeadParticle() : deathTime( 5.0f) { Well512Random::Init(); dPos = {Well512Random::GetFloatValue(-1.00f, 1.00f), Well512Random::GetFloatValue(-1.00f, 1.00f) }; } DeadParticle::~DeadParticle() { } bool DeadParticle::Init() { render = CreateRender<AniRender>(120); render->SubPivotMode(PIVOT::CENTER); render->CreateAnimation(L"CircleBombAll", L"DeadEffect.bmp", 0, 11, true, 0.08f); //render->CreateAnimation(L"CircleBomb", L"PlayerBigBullet.bmp", 7, 10, true, 0.05f); render->PlayAnimation(L"CircleBombAll"); render->RenderSize({60.0f , 60.0f }); return true; } void DeadParticle::Update() { pos += (dPos)* 100.0F * Time::DeltaTime(); deathTime -= Time::DeltaTime(); if (deathTime < 0.0f) { Die(); } }
[ "46310910+MYOMYO3@users.noreply.github.com" ]
46310910+MYOMYO3@users.noreply.github.com
1338ce97ba512d277f23cb5b5f42a916af00117b
eba2fadea4972b682edce710300ea280a210eee2
/leetcode/c++/1110.DeleteNodesAndReturnForest.cc
bcbd61b9cce2a3beff7c09a7e6a8905b38e15315
[]
no_license
seesealonely/leetcode
33b876968f08a0ddd00adc714d03ad6e4c0bfae9
1a371f3ad438bb70bf7a685843097535f5fc1c5d
refs/heads/master
2023-08-30T21:22:07.456531
2023-08-30T20:15:49
2023-08-30T20:15:49
87,525,147
1
0
null
null
null
null
UTF-8
C++
false
false
814
cc
/* Given the root of a binary tree, each node in the tree has a distinct value. After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of trees). Return the roots of the trees in the remaining forest. You may return the result in any order. Example 1: Input: root = [1,2,3,4,5,6,7], to_delete = [3,5] Output: [[1,2,null,4],[6],[7]] Example 2: Input: root = [1,2,4,null,3], to_delete = [3] Output: [[1,2,4]] Constraints: The number of nodes in the given tree is at most 1000. Each node has a distinct value between 1 and 1000. to_delete.length <= 1000 to_delete contains distinct values between 1 and 1000. */ #include"1110.DeleteNodesAndReturnForest.h" int main() { Solution s; vector<int> v={3,5}; show(s.delNodes(buildTree(),v)); return 0; }
[ "seesealonely@gmail.com" ]
seesealonely@gmail.com
160b9de6262f7ff863e6a4f18a37bba185f2612e
229f25ccda6d721f31c6d4de27a7bb85dcc0f929
/solutions/RPC/05-2019/B.cpp
70c3102697876f211658fb887f5a584033a518fe
[]
no_license
camil0palacios/Competitive-programming
e743378a8791a66c90ffaae29b4fd4cfb58fff59
4211fa61e516cb986b3404d87409ad1a49f78132
refs/heads/master
2022-11-01T20:35:21.541132
2022-10-27T03:13:42
2022-10-27T03:13:42
155,419,333
0
0
null
null
null
null
UTF-8
C++
false
false
1,258
cpp
#include <bits/stdc++.h> using namespace std; const int NM = 1e3 + 5; char g[NM][NM]; bool done[NM][NM]; int h, n, m; int dx_p[6] = {-1,-1, 0,0,1,1}; int dy_p[6] = { 0, 1,-1,1,0,1}; int dx[6] = {-1,-1, 0,0, 1,1}; int dy[6] = {-1, 0,-1,1,-1,0}; void dfs(int x, int y, int & cnt){ done[x][y] = 1; cnt++; for(int i = 0; i < 6; i++){ int mx, my; if(x % 2){ mx = x + dx_p[i], my = y + dy_p[i]; }else{ mx = x + dx[i], my = y + dy[i]; } if(mx >= 0 && mx < n && my >= 0 && my < m && !done[mx][my] && g[mx][my] == '.') dfs(mx,my,cnt); } } int main(){ cin >> h >> n >> m; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cin >> g[i][j]; } } vector<int> v; memset(done, 0, sizeof done); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(!done[i][j] && g[i][j] == '.'){ int cnt = 0; dfs(i,j,cnt); v.emplace_back(cnt); } } } sort(v.begin(), v.end(), greater<int>()); int ans = 0; for(auto & i : v){ if(h <= 0)break; h -= i; ans++; } cout << ans << endl; return 0; }
[ "camilopalacios772@gmail.com" ]
camilopalacios772@gmail.com
703dabe3b3940a6d10a423a765845796cba5e362
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_1/ISA2+po+ctrlisb+dmb.sy.c.cbmc.cpp
18b726f6293a03add68fe139a319d6569f4e27b7
[]
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
43,422
cpp
// 0:vars:3 // 7:thr1:1 // 8:thr2:1 // 3:atom_1_X0_1:1 // 4:atom_2_X0_1:1 // 5:atom_2_X2_0:1 // 6:thr0:1 #define ADDRSIZE 9 #define NPROC 4 #define NCONTEXT 1 #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 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_[NPROC*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NPROC*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NPROC*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NPROC*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NPROC*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NPROC*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NPROC*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NPROC*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NPROC*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[NPROC]; int cdy[NPROC]; int cds[NPROC]; int cdl[NPROC]; int cisb[NPROC]; int caddr[NPROC]; int cctrl[NPROC]; int cstart[NPROC]; int creturn[NPROC]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; __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; buff(0,6) = 0; pw(0,6) = 0; cr(0,6) = 0; iw(0,6) = 0; cw(0,6) = 0; cx(0,6) = 0; is(0,6) = 0; cs(0,6) = 0; crmax(0,6) = 0; buff(0,7) = 0; pw(0,7) = 0; cr(0,7) = 0; iw(0,7) = 0; cw(0,7) = 0; cx(0,7) = 0; is(0,7) = 0; cs(0,7) = 0; crmax(0,7) = 0; buff(0,8) = 0; pw(0,8) = 0; cr(0,8) = 0; iw(0,8) = 0; cw(0,8) = 0; cx(0,8) = 0; is(0,8) = 0; cs(0,8) = 0; crmax(0,8) = 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; buff(1,6) = 0; pw(1,6) = 0; cr(1,6) = 0; iw(1,6) = 0; cw(1,6) = 0; cx(1,6) = 0; is(1,6) = 0; cs(1,6) = 0; crmax(1,6) = 0; buff(1,7) = 0; pw(1,7) = 0; cr(1,7) = 0; iw(1,7) = 0; cw(1,7) = 0; cx(1,7) = 0; is(1,7) = 0; cs(1,7) = 0; crmax(1,7) = 0; buff(1,8) = 0; pw(1,8) = 0; cr(1,8) = 0; iw(1,8) = 0; cw(1,8) = 0; cx(1,8) = 0; is(1,8) = 0; cs(1,8) = 0; crmax(1,8) = 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; buff(2,6) = 0; pw(2,6) = 0; cr(2,6) = 0; iw(2,6) = 0; cw(2,6) = 0; cx(2,6) = 0; is(2,6) = 0; cs(2,6) = 0; crmax(2,6) = 0; buff(2,7) = 0; pw(2,7) = 0; cr(2,7) = 0; iw(2,7) = 0; cw(2,7) = 0; cx(2,7) = 0; is(2,7) = 0; cs(2,7) = 0; crmax(2,7) = 0; buff(2,8) = 0; pw(2,8) = 0; cr(2,8) = 0; iw(2,8) = 0; cw(2,8) = 0; cx(2,8) = 0; is(2,8) = 0; cs(2,8) = 0; crmax(2,8) = 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; buff(3,6) = 0; pw(3,6) = 0; cr(3,6) = 0; iw(3,6) = 0; cw(3,6) = 0; cx(3,6) = 0; is(3,6) = 0; cs(3,6) = 0; crmax(3,6) = 0; buff(3,7) = 0; pw(3,7) = 0; cr(3,7) = 0; iw(3,7) = 0; cw(3,7) = 0; cx(3,7) = 0; is(3,7) = 0; cs(3,7) = 0; crmax(3,7) = 0; buff(3,8) = 0; pw(3,8) = 0; cr(3,8) = 0; iw(3,8) = 0; cw(3,8) = 0; cx(3,8) = 0; is(3,8) = 0; cs(3,8) = 0; crmax(3,8) = 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(7+0,0) = 0; mem(8+0,0) = 0; mem(3+0,0) = 0; mem(4+0,0) = 0; mem(5+0,0) = 0; mem(6+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; co(1,0) = 0; delta(1,0) = -1; co(2,0) = 0; delta(2,0) = -1; co(3,0) = 0; delta(3,0) = -1; co(4,0) = 0; delta(4,0) = -1; co(5,0) = 0; delta(5,0) = -1; co(6,0) = 0; delta(6,0) = -1; co(7,0) = 0; delta(7,0) = -1; co(8,0) = 0; delta(8,0) = -1; // 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 !37, metadata !DIExpression()), !dbg !46 // br label %label_1, !dbg !47 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !45), !dbg !48 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !38, metadata !DIExpression()), !dbg !49 // call void @llvm.dbg.value(metadata i64 1, metadata !41, metadata !DIExpression()), !dbg !49 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !50 // ST: Guess iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // 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 @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !42, metadata !DIExpression()), !dbg !51 // call void @llvm.dbg.value(metadata i64 1, metadata !44, metadata !DIExpression()), !dbg !51 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !52 // ST: Guess iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0+1*1); cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // 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 !53 ret_thread_1 = (- 1); // 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 !56, metadata !DIExpression()), !dbg !71 // br label %label_2, !dbg !54 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !69), !dbg !73 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !59, metadata !DIExpression()), !dbg !74 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !57 // LD: Guess old_cr = cr(2,0+1*1); cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // 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); } 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 !61, metadata !DIExpression()), !dbg !74 // %conv = trunc i64 %0 to i32, !dbg !58 // call void @llvm.dbg.value(metadata i32 %conv, metadata !57, metadata !DIExpression()), !dbg !71 // %tobool = icmp ne i32 %conv, 0, !dbg !59 // br i1 %tobool, label %if.then, label %if.else, !dbg !61 old_cctrl = cctrl[2]; cctrl[2] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[2] >= old_cctrl); ASSUME(cctrl[2] >= creg_r0); ASSUME(cctrl[2] >= 0); if((r0!=0)) { goto T2BLOCK2; } else { goto T2BLOCK3; } T2BLOCK2: // br label %lbl_LC00, !dbg !62 goto T2BLOCK4; T2BLOCK3: // br label %lbl_LC00, !dbg !63 goto T2BLOCK4; T2BLOCK4: // call void @llvm.dbg.label(metadata !70), !dbg !82 // call void (...) @isb(), !dbg !65 // isb: Guess cisb[2] = get_rng(0,NCONTEXT-1); // Check ASSUME(cisb[2] >= cdy[2]); ASSUME(cisb[2] >= cctrl[2]); ASSUME(cisb[2] >= caddr[2]); ASSUME(creturn[2] >= cisb[2]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !62, metadata !DIExpression()), !dbg !84 // call void @llvm.dbg.value(metadata i64 1, metadata !64, metadata !DIExpression()), !dbg !84 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !67 // ST: Guess iw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,0+2*1); cw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // 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 !68 // %conv1 = zext i1 %cmp to i32, !dbg !68 // call void @llvm.dbg.value(metadata i32 %conv1, metadata !65, metadata !DIExpression()), !dbg !71 // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !66, metadata !DIExpression()), !dbg !87 // %1 = zext i32 %conv1 to i64 // call void @llvm.dbg.value(metadata i64 %1, metadata !68, metadata !DIExpression()), !dbg !87 // store atomic i64 %1, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !70 // ST: Guess iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,3); cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,3)] == 2); ASSUME(active[cw(2,3)] == 2); ASSUME(sforbid(3,cw(2,3))== 0); ASSUME(iw(2,3) >= max(creg_r0,0)); 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 !71 ret_thread_2 = (- 1); // 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 !92, metadata !DIExpression()), !dbg !110 // br label %label_3, !dbg !58 goto T3BLOCK1; T3BLOCK1: // call void @llvm.dbg.label(metadata !109), !dbg !112 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !94, metadata !DIExpression()), !dbg !113 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !61 // LD: Guess old_cr = cr(3,0+2*1); cr(3,0+2*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM // 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); } 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 !96, metadata !DIExpression()), !dbg !113 // %conv = trunc i64 %0 to i32, !dbg !62 // call void @llvm.dbg.value(metadata i32 %conv, metadata !93, metadata !DIExpression()), !dbg !110 // call void (...) @dmbsy(), !dbg !63 // dumbsy: Guess old_cdy = cdy[3]; cdy[3] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[3] >= old_cdy); ASSUME(cdy[3] >= cisb[3]); ASSUME(cdy[3] >= cdl[3]); ASSUME(cdy[3] >= cds[3]); ASSUME(cdy[3] >= cctrl[3]); ASSUME(cdy[3] >= cw(3,0+0)); ASSUME(cdy[3] >= cw(3,0+1)); ASSUME(cdy[3] >= cw(3,0+2)); ASSUME(cdy[3] >= cw(3,7+0)); ASSUME(cdy[3] >= cw(3,8+0)); ASSUME(cdy[3] >= cw(3,3+0)); ASSUME(cdy[3] >= cw(3,4+0)); ASSUME(cdy[3] >= cw(3,5+0)); ASSUME(cdy[3] >= cw(3,6+0)); ASSUME(cdy[3] >= cr(3,0+0)); ASSUME(cdy[3] >= cr(3,0+1)); ASSUME(cdy[3] >= cr(3,0+2)); ASSUME(cdy[3] >= cr(3,7+0)); ASSUME(cdy[3] >= cr(3,8+0)); ASSUME(cdy[3] >= cr(3,3+0)); ASSUME(cdy[3] >= cr(3,4+0)); ASSUME(cdy[3] >= cr(3,5+0)); ASSUME(cdy[3] >= cr(3,6+0)); ASSUME(creturn[3] >= cdy[3]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !98, metadata !DIExpression()), !dbg !117 // %1 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !65 // LD: Guess old_cr = cr(3,0); cr(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM // 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); } 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 !100, metadata !DIExpression()), !dbg !117 // %conv4 = trunc i64 %1 to i32, !dbg !66 // call void @llvm.dbg.value(metadata i32 %conv4, metadata !97, metadata !DIExpression()), !dbg !110 // %cmp = icmp eq i32 %conv, 1, !dbg !67 // %conv5 = zext i1 %cmp to i32, !dbg !67 // call void @llvm.dbg.value(metadata i32 %conv5, metadata !101, metadata !DIExpression()), !dbg !110 // call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !102, metadata !DIExpression()), !dbg !121 // %2 = zext i32 %conv5 to i64 // call void @llvm.dbg.value(metadata i64 %2, metadata !104, metadata !DIExpression()), !dbg !121 // store atomic i64 %2, i64* @atom_2_X0_1 seq_cst, align 8, !dbg !69 // ST: Guess iw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW old_cw = cw(3,4); cw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM // Check ASSUME(active[iw(3,4)] == 3); ASSUME(active[cw(3,4)] == 3); ASSUME(sforbid(4,cw(3,4))== 0); ASSUME(iw(3,4) >= max(creg_r1,0)); 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)); // %cmp7 = icmp eq i32 %conv4, 0, !dbg !70 // %conv8 = zext i1 %cmp7 to i32, !dbg !70 // call void @llvm.dbg.value(metadata i32 %conv8, metadata !105, metadata !DIExpression()), !dbg !110 // call void @llvm.dbg.value(metadata i64* @atom_2_X2_0, metadata !106, metadata !DIExpression()), !dbg !124 // %3 = zext i32 %conv8 to i64 // call void @llvm.dbg.value(metadata i64 %3, metadata !108, metadata !DIExpression()), !dbg !124 // store atomic i64 %3, i64* @atom_2_X2_0 seq_cst, align 8, !dbg !72 // ST: Guess iw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW old_cw = cw(3,5); cw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM // Check ASSUME(active[iw(3,5)] == 3); ASSUME(active[cw(3,5)] == 3); ASSUME(sforbid(5,cw(3,5))== 0); ASSUME(iw(3,5) >= max(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 !73 ret_thread_3 = (- 1); // 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 !134, metadata !DIExpression()), !dbg !174 // call void @llvm.dbg.value(metadata i8** %argv, metadata !135, metadata !DIExpression()), !dbg !174 // %0 = bitcast i64* %thr0 to i8*, !dbg !83 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !83 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !136, metadata !DIExpression()), !dbg !176 // %1 = bitcast i64* %thr1 to i8*, !dbg !85 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !85 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !140, metadata !DIExpression()), !dbg !178 // %2 = bitcast i64* %thr2 to i8*, !dbg !87 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !87 // call void @llvm.dbg.declare(metadata i64* %thr2, metadata !141, metadata !DIExpression()), !dbg !180 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !142, metadata !DIExpression()), !dbg !181 // call void @llvm.dbg.value(metadata i64 0, metadata !144, metadata !DIExpression()), !dbg !181 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !90 // ST: Guess iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+2*1); cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // 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 !145, metadata !DIExpression()), !dbg !183 // call void @llvm.dbg.value(metadata i64 0, metadata !147, metadata !DIExpression()), !dbg !183 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !92 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // 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 !148, metadata !DIExpression()), !dbg !185 // call void @llvm.dbg.value(metadata i64 0, metadata !150, metadata !DIExpression()), !dbg !185 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !94 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // 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)); // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !151, metadata !DIExpression()), !dbg !187 // call void @llvm.dbg.value(metadata i64 0, metadata !153, metadata !DIExpression()), !dbg !187 // store atomic i64 0, i64* @atom_1_X0_1 monotonic, align 8, !dbg !96 // ST: Guess iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,3); cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // 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)); // call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !154, metadata !DIExpression()), !dbg !189 // call void @llvm.dbg.value(metadata i64 0, metadata !156, metadata !DIExpression()), !dbg !189 // store atomic i64 0, i64* @atom_2_X0_1 monotonic, align 8, !dbg !98 // ST: Guess iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,4); cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // 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)); // call void @llvm.dbg.value(metadata i64* @atom_2_X2_0, metadata !157, metadata !DIExpression()), !dbg !191 // call void @llvm.dbg.value(metadata i64 0, metadata !159, metadata !DIExpression()), !dbg !191 // store atomic i64 0, i64* @atom_2_X2_0 monotonic, align 8, !dbg !100 // ST: Guess iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,5); cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // 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 !101 // 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,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+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,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call11 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !102 // 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,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+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,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %call12 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !103 // 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,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+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,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[3] >= cdy[0]); // %3 = load i64, i64* %thr0, align 8, !dbg !104, !tbaa !105 // LD: Guess old_cr = cr(0,6); cr(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,6)] == 0); ASSUME(cr(0,6) >= iw(0,6)); ASSUME(cr(0,6) >= 0); ASSUME(cr(0,6) >= cdy[0]); ASSUME(cr(0,6) >= cisb[0]); ASSUME(cr(0,6) >= cdl[0]); ASSUME(cr(0,6) >= cl[0]); // Update creg_r4 = cr(0,6); crmax(0,6) = max(crmax(0,6),cr(0,6)); caddr[0] = max(caddr[0],0); if(cr(0,6) < cw(0,6)) { r4 = buff(0,6); } else { if(pw(0,6) != co(6,cr(0,6))) { ASSUME(cr(0,6) >= old_cr); } pw(0,6) = co(6,cr(0,6)); r4 = mem(6,cr(0,6)); } ASSUME(creturn[0] >= cr(0,6)); // %call13 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !109 // 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,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+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,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %4 = load i64, i64* %thr1, align 8, !dbg !110, !tbaa !105 // LD: Guess old_cr = cr(0,7); cr(0,7) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,7)] == 0); ASSUME(cr(0,7) >= iw(0,7)); ASSUME(cr(0,7) >= 0); ASSUME(cr(0,7) >= cdy[0]); ASSUME(cr(0,7) >= cisb[0]); ASSUME(cr(0,7) >= cdl[0]); ASSUME(cr(0,7) >= cl[0]); // Update creg_r5 = cr(0,7); crmax(0,7) = max(crmax(0,7),cr(0,7)); caddr[0] = max(caddr[0],0); if(cr(0,7) < cw(0,7)) { r5 = buff(0,7); } else { if(pw(0,7) != co(7,cr(0,7))) { ASSUME(cr(0,7) >= old_cr); } pw(0,7) = co(7,cr(0,7)); r5 = mem(7,cr(0,7)); } ASSUME(creturn[0] >= cr(0,7)); // %call14 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !111 // 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,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+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,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // %5 = load i64, i64* %thr2, align 8, !dbg !112, !tbaa !105 // LD: Guess old_cr = cr(0,8); cr(0,8) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,8)] == 0); ASSUME(cr(0,8) >= iw(0,8)); ASSUME(cr(0,8) >= 0); ASSUME(cr(0,8) >= cdy[0]); ASSUME(cr(0,8) >= cisb[0]); ASSUME(cr(0,8) >= cdl[0]); ASSUME(cr(0,8) >= cl[0]); // Update creg_r6 = cr(0,8); crmax(0,8) = max(crmax(0,8),cr(0,8)); caddr[0] = max(caddr[0],0); if(cr(0,8) < cw(0,8)) { r6 = buff(0,8); } else { if(pw(0,8) != co(8,cr(0,8))) { ASSUME(cr(0,8) >= old_cr); } pw(0,8) = co(8,cr(0,8)); r6 = mem(8,cr(0,8)); } ASSUME(creturn[0] >= cr(0,8)); // %call15 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !113 // 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,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+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,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[3]); // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !161, metadata !DIExpression()), !dbg !206 // %6 = load atomic i64, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !115 // LD: Guess old_cr = cr(0,3); cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // 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); } 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 i64 %6, metadata !163, metadata !DIExpression()), !dbg !206 // %conv = trunc i64 %6 to i32, !dbg !116 // call void @llvm.dbg.value(metadata i32 %conv, metadata !160, metadata !DIExpression()), !dbg !174 // call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !165, metadata !DIExpression()), !dbg !209 // %7 = load atomic i64, i64* @atom_2_X0_1 seq_cst, align 8, !dbg !118 // LD: Guess old_cr = cr(0,4); cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // 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); } 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 i64 %7, metadata !167, metadata !DIExpression()), !dbg !209 // %conv19 = trunc i64 %7 to i32, !dbg !119 // call void @llvm.dbg.value(metadata i32 %conv19, metadata !164, metadata !DIExpression()), !dbg !174 // call void @llvm.dbg.value(metadata i64* @atom_2_X2_0, metadata !169, metadata !DIExpression()), !dbg !212 // %8 = load atomic i64, i64* @atom_2_X2_0 seq_cst, align 8, !dbg !121 // LD: Guess old_cr = cr(0,5); cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // 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); } 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 i64 %8, metadata !171, metadata !DIExpression()), !dbg !212 // %conv23 = trunc i64 %8 to i32, !dbg !122 // call void @llvm.dbg.value(metadata i32 %conv23, metadata !168, metadata !DIExpression()), !dbg !174 // %and = and i32 %conv19, %conv23, !dbg !123 creg_r10 = max(creg_r8,creg_r9); ASSUME(active[creg_r10] == 0); r10 = r8 & r9; // call void @llvm.dbg.value(metadata i32 %and, metadata !172, metadata !DIExpression()), !dbg !174 // %and24 = and i32 %conv, %and, !dbg !124 creg_r11 = max(creg_r7,creg_r10); ASSUME(active[creg_r11] == 0); r11 = r7 & r10; // call void @llvm.dbg.value(metadata i32 %and24, metadata !173, metadata !DIExpression()), !dbg !174 // %cmp = icmp eq i32 %and24, 1, !dbg !125 // br i1 %cmp, label %if.then, label %if.end, !dbg !127 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg_r11); ASSUME(cctrl[0] >= 0); 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 ([107 x i8], [107 x i8]* @.str.1, i64 0, i64 0), i32 noundef 75, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !128 // unreachable, !dbg !128 r12 = 1; T0BLOCK2: // %9 = bitcast i64* %thr2 to i8*, !dbg !131 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !131 // %10 = bitcast i64* %thr1 to i8*, !dbg !131 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !131 // %11 = bitcast i64* %thr0 to i8*, !dbg !131 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #7, !dbg !131 // ret i32 0, !dbg !132 ret_thread_0 = 0; ASSERT(r12== 0); }
[ "tuan-phong.ngo@it.uu.se" ]
tuan-phong.ngo@it.uu.se
9a89daa1224df9ba3d1b39887094c826f38182a7
4bf4d0d02cdddc354de34062df2d27182e1053d1
/Codeforces/1384A.cpp
f1ccb5c73bb42ef222107180d86c6b537b3b9155
[ "MIT" ]
permissive
DT3264/ProgrammingContestsSolutions
d61fbac7145d82b3262c41a880ac89a1a813f231
e94f344602b22d84751b1e0503bb6fbe389dcf77
refs/heads/master
2022-02-23T02:37:43.144589
2022-02-06T21:47:53
2022-02-06T21:47:53
160,301,185
0
0
null
null
null
null
UTF-8
C++
false
false
1,234
cpp
// Problem : A. Common Prefixes // Contest : Codeforces - Codeforces Round #659 (Div. 2) // URL : https://codeforces.com/contest/1384/problem/0 // Memory Limit : 256 MB // Time Limit : 1000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include<bits/stdc++.h> #define f first #define s second #define ll long long #define vi vector<int> #define pii pair<int, int> #define si set<int> #define y1 yy #define debug if(printDebug) using namespace std; bool printDebug=false; int main(){ //printDebug=true; /*freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);//*/ ios_base::sync_with_stdio(false); cin.tie(NULL);//*/ int cases; cin >> cases; while(cases--){ int n; cin >> n; vector<int> vec(n); for(int &x : vec) cin >> x; string s1; string s2; for(int i=0; i<50; i++) s1+='a'; vector<string> strings={s1}; for(int i=0; i<n; i++){ s2=strings[i]; int pos=vec[i]; while(pos<50){ if(s2[pos]==strings[i][pos]){ s2[pos]++; if(s2[pos]>'z') s2[pos]='a'; pos++; } } strings.push_back(s2); } for(string &s : strings) cout << s << "\n"; } return 0; }
[ "cernadaniel32@gmail.com" ]
cernadaniel32@gmail.com
ab03962226e64a1f96942896d9ef8e71bce76df4
b8e8c8c95d9a196260d4b08e86b4750bb07a1a10
/ZSJ-Project/Project3/CODETEST/test/Priority-Queue-Test/fib_heap(pass correctness).h
c604cbfa2306011fb4572d6d9b663f009f5ee02c
[]
no_license
Randyzhang98/Weikang-s-Data-House
69d1817757eb33bed5747d518ced0a48a8618104
1e8781c5967ff46084b98c4c9fdcc633cccce76f
refs/heads/master
2020-04-06T09:14:33.993428
2018-12-19T07:57:43
2018-12-19T07:57:43
157,334,186
0
0
null
null
null
null
UTF-8
C++
false
false
7,009
h
#ifndef FIB_HEAP_H #define FIB_HEAP_H #include <algorithm> #include <cmath> #include <list> #include <iostream> #include "priority_queue.h" // OVERVIEW: A specialized version of the 'heap' ADT implemented as a // Fibonacci heap. template<typename TYPE, typename COMP = std::less<TYPE> > class fib_heap: public priority_queue<TYPE, COMP> { public: typedef unsigned size_type; // EFFECTS: Construct an empty heap with an optional comparison functor. // See test_heap.cpp for more details on functor. // MODIFIES: this // RUNTIME: O(1) fib_heap(COMP comp = COMP()); // EFFECTS: Deconstruct the heap with no memory leak. // MODIFIES: this // RUNTIME: O(n) ~fib_heap(); // EFFECTS: Add a new element to the heap. // MODIFIES: this // RUNTIME: O(1) virtual void enqueue(const TYPE &val); // EFFECTS: Remove and return the smallest element from the heap. // REQUIRES: The heap is not empty. // MODIFIES: this // RUNTIME: Amortized O(log(n)) virtual TYPE dequeue_min(); // EFFECTS: Return the smallest element of the heap. // REQUIRES: The heap is not empty. // RUNTIME: O(1) virtual const TYPE &get_min() const; // EFFECTS: Get the number of elements in the heap. // RUNTIME: O(1) virtual size_type size() const; // EFFECTS: Return true if the heap is empty. // RUNTIME: O(1) virtual bool empty() const; private: // Note: compare is a functor object COMP compare; private: // Add any additional member functions or data you require here. // You may want to define a strcut/class to represent nodes in the heap and a // pointer to the min node in the heap. struct node_t { TYPE value; unsigned degree = 0; std::list<node_t*> children; }; typename std::list<node_t*>::iterator min; std::list<node_t*> root; const double phi = 1.618; unsigned n = 0; void destructor(node_t *target); void consolidate(); void Fib_Heap_Link(decltype(min) &target, decltype(min) &source); void print_root() const { //std::cout << "root is : "; for (auto p = root.begin(); p != root.end(); p++) { //std::cout << (*p)->value << "." << (*p)->degree << " ; "; } //std::cout << std::endl; } void print_A(std::vector<typename std::list<node_t*>::iterator> A) { //std::cout << "A is : "; for (int i = 0; i < A.size(); i++) { //std::cout << (*A[i]) -> value << "," << (*A[i])->degree<< " ; "; } //std::cout << std::endl; } }; // Add the definitions of the member functions here. Please refer to // binary_heap.h for the syntax. template<typename TYPE, typename COMP> fib_heap<TYPE, COMP> :: fib_heap(COMP comp) { //std::cout<< "fib_heap()" << std::endl; compare = comp; n = 0; min = root.end(); } template<typename TYPE, typename COMP> fib_heap<TYPE, COMP> :: ~fib_heap() { //std::cout<< "!!!!!!!~~~~()" << std::endl; for (auto p = root.begin(); p != root.end(); p++) { destructor(*p); } } template<typename TYPE, typename COMP> void fib_heap<TYPE, COMP> :: destructor(node_t *target) { //std::cout<< "destructor()" << std::endl; if (target->children.empty()) delete target; else { for (auto p = target->children.begin(); p != target->children.end(); p++) { destructor(*p); } } } template<typename TYPE, typename COMP> void fib_heap<TYPE, COMP> :: enqueue(const TYPE &val) { //std::cout<< "enqueue()" << std::endl; node_t* input = new node_t; input->degree = 0; input->value = val; root.push_front(input); if (min == root.end()) { min = root.begin(); } else if (compare(val, (*min)->value)) min = root.begin(); n++; //std::cout<< "here min's value is " << (*min) -> value << std::endl; //print_root(); } template<typename TYPE, typename COMP> TYPE fib_heap<TYPE, COMP> :: dequeue_min() { //std::cout<< "deque()" << std::endl; TYPE result = (*min)->value; decltype(min) z = min; if (z != root.end()) { n--; for (auto p = (*z)->children.begin(); p != (*z)->children.end(); p++) { root.push_front(*p); } min = root.erase(min); if (n == 0) min = root.end(); else consolidate(); } //std::cout<< "result is " << result << std::endl; return result; } template<typename TYPE, typename COMP> void fib_heap<TYPE, COMP> :: consolidate() { //std::cout<< "consolidate()" << std::endl; unsigned N = n; N = (unsigned) log(N) / log(phi); std::vector<typename std::list<node_t*>::iterator> A(N+2, root.end()); typename std::list<node_t*>::iterator new_temp; for (auto p = root.begin(); p != root.end(); p = new_temp ) { ////std::cout << "170" << std::endl; ////std::cout << "here p's value is " << (*p) -> value << std::endl; ////std::cout << "172" << std::endl; print_root(); ////std::cout<< "here min's value is " << (*min) -> value << std::endl; auto x = p; unsigned d = (*x)->degree; new_temp = std::next(p,1); //std::cout<< "here N is " << N << std::endl; while (A[d] != root.end()) { auto y = A[d]; if (compare( (*y)->value, (*x)->value) ) swap(x,y); Fib_Heap_Link(x,y); //std::cout<< "here d is " << d << std::endl; A[d] = root.end(); d++; if (d >= N+1) break; //std::cout<< "here d is " << d << std::endl; print_root(); //print_A(A); } //std::cout<< "here" << std::endl; A[d] = x; print_root(); //std::cout<< "here" << std::endl; min = root.end(); for (unsigned i = 0; i < N+2; i++) { //std::cout<< "here min loop i = " << i << std::endl; if (A[i] != root.end()) { // //std::cout<< "here min loop i = " << i << std::endl; if (min == root.end()) min = A[i]; else if (compare((*A[i])->value, (*min)->value)) min = A[i]; } } //std::cout<< "here min's value is " << (*min) -> value << std::endl; //p = std::next(p, 1); } } template<typename TYPE, typename COMP> void fib_heap<TYPE, COMP> :: Fib_Heap_Link(decltype(min) &target, decltype(min) &source) { //std::cout<< "Fib+Heap+link()" << std::endl; node_t *t = *source; root.erase(source); (*target)->children.push_front(t); ////std::cout<< "here" << std::endl; ((*target)->degree)++; } template<typename TYPE, typename COMP> const TYPE &fib_heap<TYPE, COMP>::get_min() const { //std::cout<< "get_min()" << std::endl; return (*min)->value; } template<typename TYPE, typename COMP> unsigned int fib_heap<TYPE, COMP>::size() const { //std::cout<< "size()" << std::endl; return this->n; } template<typename TYPE, typename COMP> bool fib_heap<TYPE, COMP>::empty() const { //std::cout<< "empty()" << std::endl; return (this->n == 0); } #endif //FIB_HEAP_H
[ "601981285@qq.com" ]
601981285@qq.com
4990dbf5e1cdb0ae0ecd95bfc153cbd2c8af98e5
736dadbdbdcf1ee31ead243f793f229657f281bd
/RTCP/RTP/RtpConnect.cpp
f6b322e2bc395effc61e0c66eec2d07b18528e58
[]
no_license
demon060/IPC
3608dd590b8acde4b7f8f7bfa5c03b42dcd54b07
16be58dcfbec348b6844d959ae00034f4eccb699
refs/heads/master
2020-07-27T13:38:54.214149
2019-02-12T09:08:39
2019-02-12T09:08:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,769
cpp
#include "RtpConnect.h" #include <chrono> RtpConnect::RtpConnect(int port) { sockfd = socket(AF_INET, SOCK_DGRAM, 0); struct sockaddr_in addr = {0}; addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr("0.0.0.0"); addr.sin_port = htons(port); if(bind(sockfd, (struct sockaddr*)&addr, sizeof addr) == -1) { cout << "Sockfd bind error!" << endl; } int size = 50*1024; setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *)&size, sizeof(size)); cout << "[RTP ==> " << port << "]" << endl; rtpHeader.version = RTP_VERSION; packetSeq = 1; //rd()&0xffff; rtpHeader.ssrc = htonl(10); rtpHeader.payload = 96; } RtpConnect::~RtpConnect() { close(sockfd); } uint32_t RtpConnect::getTimeStamp() { auto timePoint = chrono::time_point_cast<chrono::microseconds>(chrono::high_resolution_clock::now()); return (uint32_t)((timePoint.time_since_epoch().count() + 500) / 1000 * 90 ); } void RtpConnect::SetpeerRtpAdd(string ip, int port) { peerRtpAddr.sin_family = AF_INET; peerRtpAddr.sin_addr.s_addr = inet_addr(ip.c_str()); peerRtpAddr.sin_port = htons(port); } bool RtpConnect::pushFrame(AVFrame& frame) { char *frameBuf = frame.buffer.get(); uint32_t frameSize = frame.size; if(frame.timestamp == 0) frame.timestamp = getTimeStamp(); if(frameSize <= MAX_RTP_PAYLOAD_SIZE) { RtpPacketPtr rtpPkt(new char[1500]); memcpy(rtpPkt.get()+4+RTP_HEADER_SIZE, frameBuf, frameSize); // 预留12字节 rtp header sendFrame(frame.type, rtpPkt, frameSize+4+RTP_HEADER_SIZE, 1, frame.timestamp); } else { char FU_A[2] = {0}; // 分包参考live555 FU_A[0] = (frameBuf[0] & 0xE0) | 28; FU_A[1] = 0x80 | (frameBuf[0] & 0x1f); frameBuf += 1; frameSize -= 1; while(frameSize + 2 > MAX_RTP_PAYLOAD_SIZE) { RtpPacketPtr rtpPkt(new char[1500]); rtpPkt.get()[RTP_HEADER_SIZE+4] = FU_A[0]; rtpPkt.get()[RTP_HEADER_SIZE+5] = FU_A[1]; memcpy(rtpPkt.get()+4+RTP_HEADER_SIZE+2, frameBuf, MAX_RTP_PAYLOAD_SIZE-2); sendFrame(frame.type, rtpPkt, 4+RTP_HEADER_SIZE+MAX_RTP_PAYLOAD_SIZE, 0, frame.timestamp); frameBuf += MAX_RTP_PAYLOAD_SIZE - 2; frameSize -= MAX_RTP_PAYLOAD_SIZE - 2; FU_A[1] &= ~0x80; } { //RtpPacketPtr rtpPkt((char*)xop::Alloc(1500), xop::Free); RtpPacketPtr rtpPkt(new char[1500]); FU_A[1] |= 0x40; rtpPkt.get()[RTP_HEADER_SIZE+4] = FU_A[0]; rtpPkt.get()[RTP_HEADER_SIZE+5] = FU_A[1]; memcpy(rtpPkt.get()+4+RTP_HEADER_SIZE+2, frameBuf, frameSize); sendFrame(frame.type, rtpPkt, 4+RTP_HEADER_SIZE+2+frameSize, 1, frame.timestamp); } } return true; } bool RtpConnect::sendFrame(uint8_t frameType, RtpPacketPtr& rtpPkt, uint32_t pktSize, uint8_t last, uint32_t ts) { setFrameType(frameType); setRtpHeader(rtpPkt, last, ts); sendRtpPacket(rtpPkt, pktSize); return true; } void RtpConnect::setFrameType(uint8_t frameType) { //cout << frameType << endl; } void RtpConnect::setRtpHeader(RtpPacketPtr& rtpPkt, uint8_t last, uint32_t ts) { rtpHeader.marker = last; rtpHeader.ts = htonl(ts); rtpHeader.seq = htons(packetSeq++); memcpy(rtpPkt.get()+4, &rtpHeader, RTP_HEADER_SIZE); } int RtpConnect::sendRtpPacket(RtpPacketPtr& rtpPkt, uint32_t pktSize) { int ret = sendto(sockfd, rtpPkt.get()+4, pktSize-4, 0, (struct sockaddr *)&peerRtpAddr, sizeof(struct sockaddr_in)); if(ret < 0) { //teardown(); return -1; } return ret; }
[ "992802269@qq.com" ]
992802269@qq.com
051fb7a89077acfce9b348f22b8b4e293ba6ee6c
445caadc5c727df4b16a0b7bfbb713d408012bd2
/code/machine/interrupt.cc
4c1f593da5a12a47155d153e8a433b45cdadb103
[]
no_license
jamespeace/nachos
37506227f78cf0b0fe0ed1f4c11e711bfa8f6cf3
5a740473a88f0865aab9af8b28ce0ab29612346a
refs/heads/master
2020-06-02T07:54:34.388450
2019-06-19T14:01:23
2019-06-19T14:01:23
191,089,503
1
0
null
null
null
null
UTF-8
C++
false
false
11,609
cc
// interrupt.cc // Routines to simulate hardware interrupts. // // The hardware provides a routine (SetLevel) to enable or disable // interrupts. // // In order to emulate the hardware, we need to keep track of all // interrupts the hardware devices would cause, and when they // are supposed to occur. // // This module also keeps track of simulated time. Time advances // only when the following occur: // interrupts are re-enabled // a user instruction is executed // there is nothing in the ready queue // // DO NOT CHANGE -- part of the machine emulation // // Copyright (c) 1992-1996 The Regents of the University of California. // All rights reserved. See copyright.h for copyright notice and limitation // of liability and disclaimer of warranty provisions. #include "copyright.h" #include "interrupt.h" #include "main.h" #include "../userprog/synchconsole.h" // String definitions for debugging messages static char *intLevelNames[] = { "off", "on"}; static char *intTypeNames[] = { "timer", "disk", "console write", "console read", "elevator", "network send", "network recv"}; //---------------------------------------------------------------------- // PendingInterrupt::PendingInterrupt // Initialize a hardware device interrupt that is to be scheduled // to occur in the near future. // // "callOnInt" is the object to call when the interrupt occurs // "time" is when (in simulated time) the interrupt is to occur // "kind" is the hardware device that generated the interrupt //---------------------------------------------------------------------- PendingInterrupt::PendingInterrupt(CallBackObj *callOnInt, int time, IntType kind) { callOnInterrupt = callOnInt; when = time; type = kind; } //---------------------------------------------------------------------- // PendingCompare // Compare to interrupts based on which should occur first. //---------------------------------------------------------------------- static int PendingCompare (PendingInterrupt *x, PendingInterrupt *y) { if (x->when < y->when) { return -1; } else if (x->when > y->when) { return 1; } else { return 0; } } //---------------------------------------------------------------------- // Interrupt::Interrupt // Initialize the simulation of hardware device interrupts. // // Interrupts start disabled, with no interrupts pending, etc. //---------------------------------------------------------------------- Interrupt::Interrupt() { level = IntOff; pending = new SortedList<PendingInterrupt *>(PendingCompare); inHandler = FALSE; yieldOnReturn = FALSE; status = SystemMode; } //---------------------------------------------------------------------- // Interrupt::~Interrupt // De-allocate the data structures needed by the interrupt simulation. //---------------------------------------------------------------------- Interrupt::~Interrupt() { while (!pending->IsEmpty()) { delete pending->RemoveFront(); } delete pending; } //---------------------------------------------------------------------- // Interrupt::ChangeLevel // Change interrupts to be enabled or disabled, without advancing // the simulated time (normally, enabling interrupts advances the time). // // Used internally. // // "old" -- the old interrupt status // "now" -- the new interrupt status //---------------------------------------------------------------------- void Interrupt::ChangeLevel(IntStatus old, IntStatus now) { level = now; DEBUG(dbgInt, "\tinterrupts: " << intLevelNames[old] << " -> " << intLevelNames[now]); } //---------------------------------------------------------------------- // Interrupt::SetLevel // Change interrupts to be enabled or disabled, and if interrupts // are being enabled, advance simulated time by calling OneTick(). // // Returns: // The old interrupt status. // Parameters: // "now" -- the new interrupt status //---------------------------------------------------------------------- IntStatus Interrupt::SetLevel(IntStatus now) { IntStatus old = level; // interrupt handlers are prohibited from enabling interrupts ASSERT((now == IntOff) || (inHandler == FALSE)); ChangeLevel(old, now); // change to new state if ((now == IntOn) && (old == IntOff)) { OneTick(); // advance simulated time } return old; } //---------------------------------------------------------------------- // Interrupt::OneTick // Advance simulated time and check if there are any pending // interrupts to be called. // // Two things can cause OneTick to be called: // interrupts are re-enabled // a user instruction is executed //---------------------------------------------------------------------- void Interrupt::OneTick() { MachineStatus oldStatus = status; Statistics *stats = kernel->stats; // advance simulated time if (status == SystemMode) { stats->totalTicks += SystemTick; stats->systemTicks += SystemTick; } else { // USER_PROGRAM stats->totalTicks += UserTick; stats->userTicks += UserTick; } DEBUG(dbgInt, "== Tick " << stats->totalTicks << " =="); // check any pending interrupts are now ready to fire ChangeLevel(IntOn, IntOff); // first, turn off interrupts // (interrupt handlers run with // interrupts disabled) CheckIfDue(FALSE); // check for pending interrupts ChangeLevel(IntOff, IntOn); // re-enable interrupts if (yieldOnReturn) { // if the timer device handler asked // for a context switch, ok to do it now yieldOnReturn = FALSE; status = SystemMode; // yield is a kernel routine kernel->currentThread->Yield(); status = oldStatus; } } //---------------------------------------------------------------------- // Interrupt::YieldOnReturn // Called from within an interrupt handler, to cause a context switch // (for example, on a time slice) in the interrupted thread, // when the handler returns. // // We can't do the context switch here, because that would switch // out the interrupt handler, and we want to switch out the // interrupted thread. //---------------------------------------------------------------------- void Interrupt::YieldOnReturn() { ASSERT(inHandler == TRUE); yieldOnReturn = TRUE; } //---------------------------------------------------------------------- // Interrupt::Idle // Routine called when there is nothing in the ready queue. // // Since something has to be running in order to put a thread // on the ready queue, the only thing to do is to advance // simulated time until the next scheduled hardware interrupt. // // If there are no pending interrupts, stop. There's nothing // more for us to do. //---------------------------------------------------------------------- void Interrupt::Idle() { DEBUG(dbgInt, "Machine idling; checking for interrupts."); status = IdleMode; if (CheckIfDue(TRUE)) { // check for any pending interrupts status = SystemMode; return; // return in case there's now // a runnable thread } // if there are no pending interrupts, and nothing is on the ready // queue, it is time to stop. If the console or the network is // operating, there are *always* pending interrupts, so this code // is not reached. Instead, the halt must be invoked by the user program. DEBUG(dbgInt, "Machine idle. No interrupts to do."); cout << "No threads ready or runnable, and no pending interrupts.\n"; cout << "Assuming the program completed.\n"; Halt(); } //---------------------------------------------------------------------- // Interrupt::Halt // Shut down Nachos cleanly, printing out performance statistics. //---------------------------------------------------------------------- void Interrupt::Halt() { cout << "Machine halting!\n\n"; kernel->stats->Print(); delete kernel; // Never returns. } //---------------------------------------------------------------------- // Interrupt::Schedule // Arrange for the CPU to be interrupted when simulated time // reaches "now + when". // // Implementation: just put it on a sorted list. // // NOTE: the Nachos kernel should not call this routine directly. // Instead, it is only called by the hardware device simulators. // // "toCall" is the object to call when the interrupt occurs // "fromNow" is how far in the future (in simulated time) the // interrupt is to occur // "type" is the hardware device that generated the interrupt //---------------------------------------------------------------------- void Interrupt::Schedule(CallBackObj *toCall, int fromNow, IntType type) { int when = kernel->stats->totalTicks + fromNow; PendingInterrupt *toOccur = new PendingInterrupt(toCall, when, type); DEBUG(dbgInt, "Scheduling interrupt handler the " << intTypeNames[type] << " at time = " << when); ASSERT(fromNow > 0); pending->Insert(toOccur); } //---------------------------------------------------------------------- // Interrupt::CheckIfDue // Check if any interrupts are scheduled to occur, and if so, // fire them off. // // Returns: // TRUE, if we fired off any interrupt handlers // Params: // "advanceClock" -- if TRUE, there is nothing in the ready queue, // so we should simply advance the clock to when the next // pending interrupt would occur (if any). //---------------------------------------------------------------------- bool Interrupt::CheckIfDue(bool advanceClock) { PendingInterrupt *next; Statistics *stats = kernel->stats; ASSERT(level == IntOff); // interrupts need to be disabled, // to invoke an interrupt handler if (debug->IsEnabled(dbgInt)) { DumpState(); } if (pending->IsEmpty()) { // no pending interrupts return FALSE; } next = pending->Front(); if (next->when > stats->totalTicks) { if (!advanceClock) { // not time yet return FALSE; } else { // advance the clock to next interrupt stats->idleTicks += (next->when - stats->totalTicks); stats->totalTicks = next->when; } } DEBUG(dbgInt, "Invoking interrupt handler for the "); DEBUG(dbgInt, intTypeNames[next->type] << " at time " << next->when); #ifdef USER_PROGRAM if (kernel->machine != NULL) { kernel->machine->DelayedLoad(0, 0); } #endif inHandler = TRUE; do { next = pending->RemoveFront(); // pull interrupt off list next->callOnInterrupt->CallBack();// call the interrupt handler delete next; } while (!pending->IsEmpty() && (pending->Front()->when <= stats->totalTicks)); inHandler = FALSE; return TRUE; } //---------------------------------------------------------------------- // PrintPending // Print information about an interrupt that is scheduled to occur. // When, where, why, etc. //---------------------------------------------------------------------- static void PrintPending (PendingInterrupt *pending) { cout << "Interrupt handler "<< intTypeNames[pending->type]; cout << ", scheduled at " << pending->when; } //---------------------------------------------------------------------- // DumpState // Print the complete interrupt state - the status, and all interrupts // that are scheduled to occur in the future. //---------------------------------------------------------------------- void Interrupt::DumpState() { cout << "Time: " << kernel->stats->totalTicks; cout << ", interrupts " << intLevelNames[level] << "\n"; cout << "Pending interrupts:\n"; pending->Apply(PrintPending); cout << "\nEnd of pending interrupts\n"; }
[ "james.happylove@gmail.com" ]
james.happylove@gmail.com
a61671589ff0838b6851ae6bacfaaa7929370ac3
53a430e12ef6f7565bca8fa1d0b944b9b734a6f0
/ex08/tree.cpp
85e1a54f222e603a5270b51e23cd0ef4cad048f0
[]
no_license
fmi-lab/fmi-lab-sdp-2019-kn-group2-sem
226a68f839b51c4d2ee945ea0f8f3fad7eef9a8f
978a806ce270a4ae07e9d3a7502d3cb11abddc15
refs/heads/master
2020-08-06T00:05:13.672204
2020-01-24T10:29:26
2020-01-24T10:29:26
212,764,777
1
1
null
null
null
null
UTF-8
C++
false
false
3,084
cpp
#include <iostream> using namespace std; template <class T> struct node { T data; node<T> * left; node<T> * right; }; node<int>* createTree( int data, node<int>* left = NULL, node<int>* right = NULL) { node<int>* root = new node<int>; root->data = data; root->left = left; root->right = right; return root; } template<class T> void deleteTree(node<T> * tree) { } node<int>* createSample() { return createTree(5, createTree(3, createTree(2, createTree(1), NULL), createTree(4)), createTree(10, createTree(7, createTree(6), NULL), createTree(15, NULL, createTree(17, NULL, createTree(20))))); } node<int>* createSampleBalanced() { return createTree(5, createTree(3, createTree(2, createTree(1), NULL), createTree(4)), createTree(10, createTree(7, createTree(6), NULL), createTree(15, NULL, createTree(17, NULL, NULL)))); } template <class T> node<T>* findElement(node<T>* tree, T element) { if (NULL == tree) { return NULL; } if (tree->data == element) { return tree; } else if (tree->data > element) { return findElement(tree->left, element); } else { return findElement(tree->right, element); } } void testFindElement() { node<int>* myTree = createSample(); cout << "Find 20: " << findElement(myTree, 20) << endl; cout << "Find -5: " << findElement(myTree, -5) << endl; deleteTree(myTree); } int sumLeafs(node<int> * tree) { if (NULL == tree) { return 0; } if (NULL == tree->left && NULL == tree->right) { return tree->data; } return sumLeafs(tree->left) + sumLeafs(tree->right); } void testSumLeafs() { node<int> * myTree = createSample(); cout << "31 == " << sumLeafs(myTree) << endl; deleteTree(myTree); } int sumLeafsByHeight(node<int> * tree, int height = 1) { if (NULL == tree) { return 0; } if (NULL == tree->left && NULL == tree->right) { return tree->data * height; } return sumLeafsByHeight(tree->left, height + 1) + sumLeafsByHeight(tree->right, height + 1); } void testSumLeafsByHeight() { node<int> * myTree = createSample(); cout << "140 == " << sumLeafsByHeight(myTree) << endl; deleteTree(myTree); } template <class T> int height(node<T> * tree) { if (NULL == tree) { return 0; } return 1 + max(height(tree->left), height(tree->right)); } template <class T> bool isAVLBalanced(node<T> * tree) { if (NULL == tree) { return true; } int balanceFactor = height(tree->left) - height(tree->right); if (-1 <= balanceFactor && balanceFactor <= 1) { return isAVLBalanced(tree->left) && isAVLBalanced(tree->right); } else { return false; } } void testAVLBalannced() { node<int> * unbalancedTree = createSample(); node<int> * balancedTree = createSampleBalanced(); cout << "false == " << isAVLBalanced(unbalancedTree) << endl; cout << "true == " << isAVLBalanced(balancedTree) << endl; } int main() { // testFindElement(); // testSumLeafs(); // testSumLeafsByHeight(); testAVLBalannced(); return 0; }
[ "stef.vartolomeev@gmail.com" ]
stef.vartolomeev@gmail.com
837693d8f02cf7203b4412d14f7244a1f60014a0
f4482b0859df9c7a6b932422c385442a248a4ba8
/b2/parser/output_buffer.hpp
e856665c9f5be33d367e4ea3648188c57d115497
[]
no_license
mrdooz/tano
e86e3540a8ad4aeb967ff2297f3c44f2537ab619
4fd1112e7590aca0b86a00b4b865f5ebe0453191
refs/heads/master
2021-03-12T19:53:59.096866
2015-10-27T13:41:21
2015-10-27T13:41:21
29,353,711
0
2
null
null
null
null
UTF-8
C++
false
false
249
hpp
#pragma once namespace parser { struct OutputBuffer { OutputBuffer(); void EnsureCapacity(size_t required); char* Cur(); void Advance(size_t distance); size_t _ofs; size_t _capacity; std::vector<char> _buf; }; }
[ "magnus.osterlind@gmail.com" ]
magnus.osterlind@gmail.com
08a1891a0175e736a4064b9003eb1e27ef9ea85f
b81d88e418b72ce70d7350739b76bdc48f8ef468
/tesseract_python/swig/tesseract_environment_python_std_functions.h
5a172cad82df469000e18bf9f2ecc90645e58ecf
[ "BSD-3-Clause", "Apache-2.0", "BSD-2-Clause" ]
permissive
marip8/tesseract_python
e7605ee9b8879c12be14f215d68b88961fa0cfe8
0466e23dc6dbb404deae9b27b38d4cb8768d52fd
refs/heads/master
2023-02-12T04:14:31.733733
2021-01-11T03:05:45
2021-01-11T06:39:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,124
h
/** * @file tesseract_environment_python_std_functions.h * @brief Callback directors for tesseract_python module * * @author John Wason * @date December 18, 2020 * @version TODO * @bug No known bugs * * @copyright Copyright (c) 2020, Wason Technology, LLC * * @par License * Software License Agreement (Apache License) * @par * 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 * @par * 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 <tesseract_environment/core/environment.h> #pragma once class FindTCPCallbackFnBase { public: virtual Eigen::Isometry3d call(const tesseract_common::ManipulatorInfo& a) = 0; virtual ~FindTCPCallbackFnBase() {} };
[ "levi.armstrong@gmail.com" ]
levi.armstrong@gmail.com
975bd7b456ba6c0ca4d5b0b1726cdd25775b60c1
0f7a4119185aff6f48907e8a5b2666d91a47c56b
/sstd_utility/windows_boost/boost/asio/windows/stream_handle.hpp
82ecf20793b7d0a3e0f7d6ca533cfd1d56ff3bb6
[]
no_license
jixhua/QQmlQuickBook
6636c77e9553a86f09cd59a2e89a83eaa9f153b6
782799ec3426291be0b0a2e37dc3e209006f0415
refs/heads/master
2021-09-28T13:02:48.880908
2018-11-17T10:43:47
2018-11-17T10:43:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,863
hpp
// // windows/stream_handle.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_ASIO_WINDOWS_STREAM_HANDLE_HPP #define BOOST_ASIO_WINDOWS_STREAM_HANDLE_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include <boost/asio/detail/config.hpp> #include <boost/asio/windows/overlapped_handle.hpp> #if defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \ || defined(GENERATING_DOCUMENTATION) #if defined(BOOST_ASIO_ENABLE_OLD_SERVICES) # include <boost/asio/windows/basic_stream_handle.hpp> #endif // defined(BOOST_ASIO_ENABLE_OLD_SERVICES) #include <boost/asio/detail/push_options.hpp> namespace boost { namespace asio { namespace windows { #if defined(BOOST_ASIO_ENABLE_OLD_SERVICES) // Typedef for the typical usage of a stream-oriented handle. typedef basic_stream_handle<> stream_handle; #else // defined(BOOST_ASIO_ENABLE_OLD_SERVICES) /// Provides stream-oriented handle functionality. /** * The windows::stream_handle class provides asynchronous and blocking * stream-oriented handle functionality. * * @par Thread Safety * @e Distinct @e objects: Safe.@n * @e Shared @e objects: Unsafe. * * @par Concepts: * AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream. */ class stream_handle : public overlapped_handle { public: /// Construct a stream_handle without opening it. /** * This constructor creates a stream handle without opening it. The handle * needs to be opened and then connected or accepted before data can be sent * or received on it. * * @param io_context The io_context object that the stream handle will use to * dispatch handlers for any asynchronous operations performed on the handle. */ explicit stream_handle(boost::asio::io_context& io_context) : overlapped_handle(io_context) { } /// Construct a stream_handle on an existing native handle. /** * This constructor creates a stream handle object to hold an existing native * handle. * * @param io_context The io_context object that the stream handle will use to * dispatch handlers for any asynchronous operations performed on the handle. * * @param handle The new underlying handle implementation. * * @throws boost::system::system_error Thrown on failure. */ stream_handle(boost::asio::io_context& io_context, const native_handle_type& handle) : overlapped_handle(io_context, handle) { } #if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move-construct a stream_handle from another. /** * This constructor moves a stream handle from one object to another. * * @param other The other stream_handle object from which the move * will occur. * * @note Following the move, the moved-from object is in the same state as if * constructed using the @c stream_handle(io_context&) constructor. */ stream_handle(stream_handle&& other) : overlapped_handle(std::move(other)) { } /// Move-assign a stream_handle from another. /** * This assignment operator moves a stream handle from one object to * another. * * @param other The other stream_handle object from which the move * will occur. * * @note Following the move, the moved-from object is in the same state as if * constructed using the @c stream_handle(io_context&) constructor. */ stream_handle& operator=(stream_handle&& other) { overlapped_handle::operator=(std::move(other)); return *this; } #endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Write some data to the handle. /** * This function is used to write data to the stream handle. The function call * will block until one or more bytes of the data has been written * successfully, or until an error occurs. * * @param buffers One or more data buffers to be written to the handle. * * @returns The number of bytes written. * * @throws boost::system::system_error Thrown on failure. An error code of * boost::asio::error::eof indicates that the connection was closed by the * peer. * * @note The write_some operation may not transmit all of the data to the * peer. Consider using the @ref write function if you need to ensure that * all data is written before the blocking operation completes. * * @par Example * To write a single data buffer use the @ref buffer function as follows: * @code * handle.write_some(boost::asio::buffer(data, size)); * @endcode * See the @ref buffer documentation for information on writing multiple * buffers in one go, and how to use it with arrays, boost::array or * std::vector. */ template <typename ConstBufferSequence> std::size_t write_some(const ConstBufferSequence& buffers) { boost::system::error_code ec; std::size_t s = this->get_service().write_some( this->get_implementation(), buffers, ec); boost::asio::detail::throw_error(ec, "write_some"); return s; } /// Write some data to the handle. /** * This function is used to write data to the stream handle. The function call * will block until one or more bytes of the data has been written * successfully, or until an error occurs. * * @param buffers One or more data buffers to be written to the handle. * * @param ec Set to indicate what error occurred, if any. * * @returns The number of bytes written. Returns 0 if an error occurred. * * @note The write_some operation may not transmit all of the data to the * peer. Consider using the @ref write function if you need to ensure that * all data is written before the blocking operation completes. */ template <typename ConstBufferSequence> std::size_t write_some(const ConstBufferSequence& buffers, boost::system::error_code& ec) { return this->get_service().write_some( this->get_implementation(), buffers, ec); } /// Start an asynchronous write. /** * This function is used to asynchronously write data to the stream handle. * The function call always returns immediately. * * @param buffers One or more data buffers to be written to the handle. * Although the buffers object may be copied as necessary, ownership of the * underlying memory blocks is retained by the caller, which must guarantee * that they remain valid until the handler is called. * * @param handler The handler to be called when the write operation completes. * Copies will be made of the handler as required. The function signature of * the handler must be: * @code void handler( * const boost::system::error_code& error, // Result of operation. * std::size_t bytes_transferred // Number of bytes written. * ); @endcode * Regardless of whether the asynchronous operation completes immediately or * not, the handler will not be invoked from within this function. Invocation * of the handler will be performed in a manner equivalent to using * boost::asio::io_context::post(). * * @note The write operation may not transmit all of the data to the peer. * Consider using the @ref async_write function if you need to ensure that all * data is written before the asynchronous operation completes. * * @par Example * To write a single data buffer use the @ref buffer function as follows: * @code * handle.async_write_some(boost::asio::buffer(data, size), handler); * @endcode * See the @ref buffer documentation for information on writing multiple * buffers in one go, and how to use it with arrays, boost::array or * std::vector. */ template <typename ConstBufferSequence, typename WriteHandler> BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, void (boost::system::error_code, std::size_t)) async_write_some(const ConstBufferSequence& buffers, BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { // If you get an error on the following line it means that your handler does // not meet the documented type requirements for a WriteHandler. BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; boost::asio::async_completion<WriteHandler, void (boost::system::error_code, std::size_t)> init(handler); this->get_service().async_write_some( this->get_implementation(), buffers, init.completion_handler); return init.result.get(); } /// Read some data from the handle. /** * This function is used to read data from the stream handle. The function * call will block until one or more bytes of data has been read successfully, * or until an error occurs. * * @param buffers One or more buffers into which the data will be read. * * @returns The number of bytes read. * * @throws boost::system::system_error Thrown on failure. An error code of * boost::asio::error::eof indicates that the connection was closed by the * peer. * * @note The read_some operation may not read all of the requested number of * bytes. Consider using the @ref read function if you need to ensure that * the requested amount of data is read before the blocking operation * completes. * * @par Example * To read into a single data buffer use the @ref buffer function as follows: * @code * handle.read_some(boost::asio::buffer(data, size)); * @endcode * See the @ref buffer documentation for information on reading into multiple * buffers in one go, and how to use it with arrays, boost::array or * std::vector. */ template <typename MutableBufferSequence> std::size_t read_some(const MutableBufferSequence& buffers) { boost::system::error_code ec; std::size_t s = this->get_service().read_some( this->get_implementation(), buffers, ec); boost::asio::detail::throw_error(ec, "read_some"); return s; } /// Read some data from the handle. /** * This function is used to read data from the stream handle. The function * call will block until one or more bytes of data has been read successfully, * or until an error occurs. * * @param buffers One or more buffers into which the data will be read. * * @param ec Set to indicate what error occurred, if any. * * @returns The number of bytes read. Returns 0 if an error occurred. * * @note The read_some operation may not read all of the requested number of * bytes. Consider using the @ref read function if you need to ensure that * the requested amount of data is read before the blocking operation * completes. */ template <typename MutableBufferSequence> std::size_t read_some(const MutableBufferSequence& buffers, boost::system::error_code& ec) { return this->get_service().read_some( this->get_implementation(), buffers, ec); } /// Start an asynchronous read. /** * This function is used to asynchronously read data from the stream handle. * The function call always returns immediately. * * @param buffers One or more buffers into which the data will be read. * Although the buffers object may be copied as necessary, ownership of the * underlying memory blocks is retained by the caller, which must guarantee * that they remain valid until the handler is called. * * @param handler The handler to be called when the read operation completes. * Copies will be made of the handler as required. The function signature of * the handler must be: * @code void handler( * const boost::system::error_code& error, // Result of operation. * std::size_t bytes_transferred // Number of bytes read. * ); @endcode * Regardless of whether the asynchronous operation completes immediately or * not, the handler will not be invoked from within this function. Invocation * of the handler will be performed in a manner equivalent to using * boost::asio::io_context::post(). * * @note The read operation may not read all of the requested number of bytes. * Consider using the @ref async_read function if you need to ensure that the * requested amount of data is read before the asynchronous operation * completes. * * @par Example * To read into a single data buffer use the @ref buffer function as follows: * @code * handle.async_read_some(boost::asio::buffer(data, size), handler); * @endcode * See the @ref buffer documentation for information on reading into multiple * buffers in one go, and how to use it with arrays, boost::array or * std::vector. */ template <typename MutableBufferSequence, typename ReadHandler> BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, void (boost::system::error_code, std::size_t)) async_read_some(const MutableBufferSequence& buffers, BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { // If you get an error on the following line it means that your handler does // not meet the documented type requirements for a ReadHandler. BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; boost::asio::async_completion<ReadHandler, void (boost::system::error_code, std::size_t)> init(handler); this->get_service().async_read_some( this->get_implementation(), buffers, init.completion_handler); return init.result.get(); } }; #endif // defined(BOOST_ASIO_ENABLE_OLD_SERVICES) } // namespace windows } // namespace asio } // namespace boost #include <boost/asio/detail/pop_options.hpp> #endif // defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) // || defined(GENERATING_DOCUMENTATION) #endif // BOOST_ASIO_WINDOWS_STREAM_HANDLE_HPP
[ "nanguazhude@vip.qq.com" ]
nanguazhude@vip.qq.com
992d4686707951168a4c1d01a36f9f9e0f287285
5e1ae0c5e8f26339759b43e6627771edcf7d16ce
/external/chromium_org/content/renderer/history_serialization.cc
cf85496de3c7441a0d420da02bb21cd117d12925
[ "BSD-3-Clause" ]
permissive
guoyanjun0313/cb40_6735
d303eec21051633ee52230704a1dfd0f3c579cc0
fc5aa800555da17f2c2c3f75f95f772ff67b40c0
refs/heads/master
2022-12-28T16:44:38.678552
2018-04-18T03:00:31
2018-04-18T03:00:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,965
cc
// Copyright 2014 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 "content/renderer/history_serialization.h" #include "content/common/page_state_serialization.h" #include "content/public/common/page_state.h" #include "content/renderer/history_entry.h" #include "third_party/WebKit/public/platform/WebFloatPoint.h" #include "third_party/WebKit/public/platform/WebHTTPBody.h" #include "third_party/WebKit/public/platform/WebPoint.h" #include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebVector.h" #include "third_party/WebKit/public/web/WebHistoryItem.h" #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" using blink::WebHTTPBody; using blink::WebHistoryItem; using blink::WebSerializedScriptValue; using blink::WebString; using blink::WebVector; namespace content { namespace { void ToNullableString16Vector(const WebVector<WebString>& input, std::vector<base::NullableString16>* output) { output->reserve(input.size()); for (size_t i = 0; i < input.size(); ++i) output->push_back(input[i]); } void ToExplodedHttpBodyElement(const WebHTTPBody::Element& input, ExplodedHttpBodyElement* output) { switch (input.type) { case WebHTTPBody::Element::TypeData: output->data.assign(input.data.data(), input.data.size()); break; case WebHTTPBody::Element::TypeFile: output->file_path = input.filePath; output->file_start = input.fileStart; output->file_length = input.fileLength; output->file_modification_time = input.modificationTime; break; case WebHTTPBody::Element::TypeFileSystemURL: output->filesystem_url = input.fileSystemURL; output->file_start = input.fileStart; output->file_length = input.fileLength; output->file_modification_time = input.modificationTime; break; case WebHTTPBody::Element::TypeBlob: output->blob_uuid = input.blobUUID.utf8(); break; } } void AppendHTTPBodyElement(const ExplodedHttpBodyElement& element, WebHTTPBody* http_body) { switch (element.type) { case WebHTTPBody::Element::TypeData: http_body->appendData(element.data); break; case WebHTTPBody::Element::TypeFile: http_body->appendFileRange( element.file_path, element.file_start, element.file_length, element.file_modification_time); break; case WebHTTPBody::Element::TypeFileSystemURL: http_body->appendFileSystemURLRange( element.filesystem_url, element.file_start, element.file_length, element.file_modification_time); break; case WebHTTPBody::Element::TypeBlob: http_body->appendBlob(WebString::fromUTF8(element.blob_uuid)); break; } } void GenerateFrameStateFromItem(const WebHistoryItem& item, ExplodedFrameState* state) { state->url_string = item.urlString(); state->referrer = item.referrer(); state->referrer_policy = item.referrerPolicy(); state->target = item.target(); if (!item.stateObject().isNull()) state->state_object = item.stateObject().toString(); state->pinch_viewport_scroll_offset = item.pinchViewportScrollOffset(); state->scroll_offset = item.scrollOffset(); state->item_sequence_number = item.itemSequenceNumber(); state->document_sequence_number = item.documentSequenceNumber(); state->frame_sequence_number = item.frameSequenceNumber(); state->page_scale_factor = item.pageScaleFactor(); /// M: Support text-reflow in chromium state->text_wrap_width = item.textWrapWidth(); ToNullableString16Vector(item.documentState(), &state->document_state); state->http_body.http_content_type = item.httpContentType(); const WebHTTPBody& http_body = item.httpBody(); state->http_body.is_null = http_body.isNull(); if (!state->http_body.is_null) { state->http_body.identifier = http_body.identifier(); state->http_body.elements.resize(http_body.elementCount()); for (size_t i = 0; i < http_body.elementCount(); ++i) { WebHTTPBody::Element element; http_body.elementAt(i, element); ToExplodedHttpBodyElement(element, &state->http_body.elements[i]); } state->http_body.contains_passwords = http_body.containsPasswordData(); } } void RecursivelyGenerateFrameState(HistoryEntry::HistoryNode* node, ExplodedFrameState* state) { GenerateFrameStateFromItem(node->item(), state); std::vector<HistoryEntry::HistoryNode*>& children = node->children(); state->children.resize(children.size()); for (size_t i = 0; i < children.size(); ++i) RecursivelyGenerateFrameState(children[i], &state->children[i]); } void RecursivelyGenerateHistoryItem(const ExplodedFrameState& state, HistoryEntry::HistoryNode* node) { WebHistoryItem item; item.initialize(); item.setURLString(state.url_string); item.setReferrer(state.referrer, state.referrer_policy); item.setTarget(state.target); if (!state.state_object.is_null()) { item.setStateObject( WebSerializedScriptValue::fromString(state.state_object)); } item.setDocumentState(state.document_state); item.setPinchViewportScrollOffset(state.pinch_viewport_scroll_offset); item.setScrollOffset(state.scroll_offset); item.setPageScaleFactor(state.page_scale_factor); /// M: Support text-reflow in chromium item.setTextWrapWidth(state.text_wrap_width); // These values are generated at WebHistoryItem construction time, and we // only want to override those new values with old values if the old values // are defined. A value of 0 means undefined in this context. if (state.item_sequence_number) item.setItemSequenceNumber(state.item_sequence_number); if (state.document_sequence_number) item.setDocumentSequenceNumber(state.document_sequence_number); if (state.frame_sequence_number) item.setFrameSequenceNumber(state.frame_sequence_number); item.setHTTPContentType(state.http_body.http_content_type); if (!state.http_body.is_null) { WebHTTPBody http_body; http_body.initialize(); http_body.setIdentifier(state.http_body.identifier); for (size_t i = 0; i < state.http_body.elements.size(); ++i) AppendHTTPBodyElement(state.http_body.elements[i], &http_body); item.setHTTPBody(http_body); } node->set_item(item); for (size_t i = 0; i < state.children.size(); ++i) RecursivelyGenerateHistoryItem(state.children[i], node->AddChild()); } } // namespace PageState HistoryEntryToPageState(HistoryEntry* entry) { ExplodedPageState state; ToNullableString16Vector(entry->root().getReferencedFilePaths(), &state.referenced_files); RecursivelyGenerateFrameState(entry->root_history_node(), &state.top); std::string encoded_data; if (!EncodePageState(state, &encoded_data)) return PageState(); return PageState::CreateFromEncodedData(encoded_data); } PageState SingleHistoryItemToPageState(const WebHistoryItem& item) { ExplodedPageState state; ToNullableString16Vector(item.getReferencedFilePaths(), &state.referenced_files); GenerateFrameStateFromItem(item, &state.top); std::string encoded_data; if (!EncodePageState(state, &encoded_data)) return PageState(); return PageState::CreateFromEncodedData(encoded_data); } scoped_ptr<HistoryEntry> PageStateToHistoryEntry(const PageState& page_state) { ExplodedPageState state; if (!DecodePageState(page_state.ToEncodedData(), &state)) return scoped_ptr<HistoryEntry>(); scoped_ptr<HistoryEntry> entry(new HistoryEntry()); RecursivelyGenerateHistoryItem(state.top, entry->root_history_node()); return entry.Pass(); } } // namespace content
[ "liuyiping@t-road.cn" ]
liuyiping@t-road.cn
58914bab23efa98c8bab567972ebce90792eafe5
90312ba1088363f12408b9869d89e31d6ad658e5
/mbr_partition_table/src/cpp_stl_98/mbr_partition_table.cpp
1453b49e293a143821a1a4d469d229237fde90dc
[ "ISC" ]
permissive
Tosyk/formats-kaitai-io.github.io
c3e9d0df4deae557f5ac4d36290c7052be4c16bb
1faec646734b93815d39bc638ead4bc9a37eca3e
refs/heads/master
2023-07-29T07:22:10.818349
2021-09-12T11:41:45
2021-09-12T11:41:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,350
cpp
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild #include "mbr_partition_table.h" #include "kaitai/exceptions.h" mbr_partition_table_t::mbr_partition_table_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, mbr_partition_table_t* p__root) : kaitai::kstruct(p__io) { m__parent = p__parent; m__root = this; m_partitions = 0; try { _read(); } catch(...) { _clean_up(); throw; } } void mbr_partition_table_t::_read() { m_bootstrap_code = m__io->read_bytes(446); int l_partitions = 4; m_partitions = new std::vector<partition_entry_t*>(); m_partitions->reserve(l_partitions); for (int i = 0; i < l_partitions; i++) { m_partitions->push_back(new partition_entry_t(m__io, this, m__root)); } m_boot_signature = m__io->read_bytes(2); if (!(boot_signature() == std::string("\x55\xAA", 2))) { throw kaitai::validation_not_equal_error<std::string>(std::string("\x55\xAA", 2), boot_signature(), _io(), std::string("/seq/2")); } } mbr_partition_table_t::~mbr_partition_table_t() { _clean_up(); } void mbr_partition_table_t::_clean_up() { if (m_partitions) { for (std::vector<partition_entry_t*>::iterator it = m_partitions->begin(); it != m_partitions->end(); ++it) { delete *it; } delete m_partitions; m_partitions = 0; } } mbr_partition_table_t::partition_entry_t::partition_entry_t(kaitai::kstream* p__io, mbr_partition_table_t* p__parent, mbr_partition_table_t* p__root) : kaitai::kstruct(p__io) { m__parent = p__parent; m__root = p__root; m_chs_start = 0; m_chs_end = 0; try { _read(); } catch(...) { _clean_up(); throw; } } void mbr_partition_table_t::partition_entry_t::_read() { m_status = m__io->read_u1(); m_chs_start = new chs_t(m__io, this, m__root); m_partition_type = m__io->read_u1(); m_chs_end = new chs_t(m__io, this, m__root); m_lba_start = m__io->read_u4le(); m_num_sectors = m__io->read_u4le(); } mbr_partition_table_t::partition_entry_t::~partition_entry_t() { _clean_up(); } void mbr_partition_table_t::partition_entry_t::_clean_up() { if (m_chs_start) { delete m_chs_start; m_chs_start = 0; } if (m_chs_end) { delete m_chs_end; m_chs_end = 0; } } mbr_partition_table_t::chs_t::chs_t(kaitai::kstream* p__io, mbr_partition_table_t::partition_entry_t* p__parent, mbr_partition_table_t* p__root) : kaitai::kstruct(p__io) { m__parent = p__parent; m__root = p__root; f_sector = false; f_cylinder = false; try { _read(); } catch(...) { _clean_up(); throw; } } void mbr_partition_table_t::chs_t::_read() { m_head = m__io->read_u1(); m_b2 = m__io->read_u1(); m_b3 = m__io->read_u1(); } mbr_partition_table_t::chs_t::~chs_t() { _clean_up(); } void mbr_partition_table_t::chs_t::_clean_up() { } int32_t mbr_partition_table_t::chs_t::sector() { if (f_sector) return m_sector; m_sector = (b2() & 63); f_sector = true; return m_sector; } int32_t mbr_partition_table_t::chs_t::cylinder() { if (f_cylinder) return m_cylinder; m_cylinder = (b3() + ((b2() & 192) << 2)); f_cylinder = true; return m_cylinder; }
[ "kaitai-bot@kaitai.io" ]
kaitai-bot@kaitai.io
8ed3177ddde259defe8e40437cd82d4fe6040577
17fb61a3a2fdda085941c2ba8d04daaf8397d2a5
/test/libponyc/badpony.cc
fb7a7d0f56c7923f179729859f30a28e0dc133ae
[ "BSD-2-Clause" ]
permissive
shlomif/ponyc
3553a42aa63fc7700f8469715b3c4470fcbda8f3
545e403b3d4e2fcb572575940f2b377c7d391146
refs/heads/master
2020-12-24T16:16:24.254052
2015-08-25T09:57:39
2015-08-25T09:57:39
41,370,048
1
0
null
2015-08-25T15:02:24
2015-08-25T15:02:24
null
UTF-8
C++
false
false
1,668
cc
#include <gtest/gtest.h> #include <platform.h> #include "util.h" /** Pony code that parses, but is erroneous. Typically type check errors and * things used in invalid contexts. * * We build all the way up to and including code gen and check that we do not * assert, segfault, etc but that the build fails and at least one error is * reported. * * There is definite potential for overlap with other tests but this is also a * suitable location for tests which don't obviously belong anywhere else. */ class BadPonyTest : public PassTest { protected: void test(const char* src) { DO(test_error(src, "ir")); ASSERT_NE(0, get_error_count()); } }; // Cases from reported issues TEST_F(BadPonyTest, DontCareInFieldType) { // From issue #207 const char* src = "class Abc\n" " var _test1: (_)"; DO(test(src)); } TEST_F(BadPonyTest, ClassInOtherClassProvidesList) { // From issue #218 const char* src = "class Named\n" "class Dog is Named\n" "actor Main\n" " new create(env: Env) =>\n" " None"; DO(test(src)); } TEST_F(BadPonyTest, TypeParamMissingForTypeInProvidesList) { // From issue #219 const char* src = "trait Bar[A]\n" " fun bar(a: A) =>\n" " None\n" "trait Foo is Bar // here also should be a type argument, like Bar[U8]\n" " fun foo() =>\n" " None\n" "actor Main\n" " new create(env: Env) =>\n" " None"; DO(test(src)); } TEST_F(BadPonyTest, DontCareInIntLiteralType) { // From issue #222 const char* src = "actor Main\n" " new create(env: Env) =>\n" " let crashme: (_, I32) = (4, 4)"; DO(test(src)); }
[ "andrew@causality.io" ]
andrew@causality.io
684a75d016cfce04fb684f65448940837d646b47
7305ca85b0b585d8178f013c2a417deb3ddcd498
/src/backend/spin/camera_device_spin.hpp
04cc58654bbee0d792e6f6b2a66da05dbec5c2c3
[ "Apache-2.0" ]
permissive
rozmar/bias
de00b2b1cfe888487b89480646d5f0516cb7284a
3881370bb46fdc8976c04ec033cdfb240d1a26da
refs/heads/master
2022-11-13T19:08:46.643239
2020-03-13T17:55:44
2020-03-13T17:55:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,392
hpp
#ifdef WITH_SPIN #ifndef BIAS_CAMERA_DEVICE_SPIN_HPP #define BIAS_CAMERA_DEVICE_SPIN_HPP #include <map> #include <string> #include <functional> #include <opencv2/core/core.hpp> #include "utils.hpp" #include "camera_device.hpp" #include "camera_info_spin.hpp" #include "property.hpp" #include "SpinnakerC.h" #include "node_map_spin.hpp" namespace bias { class CameraDevice_spin : public CameraDevice { public: CameraDevice_spin(); explicit CameraDevice_spin(Guid guid); virtual ~CameraDevice_spin(); virtual CameraLib getCameraLib(); virtual void connect(); virtual void disconnect(); virtual void startCapture(); virtual void stopCapture(); virtual cv::Mat grabImage(); virtual void grabImage(cv::Mat &image); virtual bool isColor(); virtual bool isSupported(VideoMode vidMode, FrameRate frmRate); virtual bool isSupported(ImageMode imgMode); virtual unsigned int getNumberOfImageMode(); virtual VideoMode getVideoMode(); virtual FrameRate getFrameRate(); virtual ImageMode getImageMode(); virtual VideoModeList getAllowedVideoModes(); virtual FrameRateList getAllowedFrameRates(VideoMode vidMode); virtual ImageModeList getAllowedImageModes(); virtual PropertyInfo getPropertyInfo(PropertyType propType); virtual Property getProperty(PropertyType propType); virtual void setProperty(Property prop); //virtual void setFormat7ImageMode(ImageMode imgMode); // TO DO // virtual Format7Settings getFormat7Settings(); virtual Format7Info getFormat7Info(ImageMode imgMode); virtual bool validateFormat7Settings(Format7Settings settings); virtual void setFormat7Configuration(Format7Settings settings, float percentSpeed); virtual PixelFormatList getListOfSupportedPixelFormats(ImageMode imgMode); virtual void setTriggerInternal(); virtual void setTriggerExternal(); virtual TriggerType getTriggerType(); virtual std::string getVendorName(); virtual std::string getModelName(); virtual TimeStamp getImageTimeStamp(); virtual std::string toString(); virtual void printGuid(); virtual void printInfo(); void develExpProps(); // Constants // -------------------------------------------------------- // Artificial shutter limits to make GUI more usable. static constexpr double MinAllowedShutterUs = 100.0; static constexpr double MaxAllowedShutterUs = 200000.0; // Number of times auto mode is set to "once". Seems to need to be called // more than once in order to reach a stable value. static constexpr int AutoOnePushSetCount = 10; private: spinSystem hSystem_ = nullptr; spinCamera hCamera_ = nullptr; spinNodeMapHandle hNodeMapCamera_ = nullptr; spinNodeMapHandle hNodeMapTLDevice_ = nullptr; NodeMapCamera_spin nodeMapCamera_; NodeMapTLDevice_spin nodeMapTLDevice_; CameraInfo_spin cameraInfo_; TimeStamp timeStamp_ = {0,0}; int64_t timeStamp_ns_ = 0; bool imageOK_ = false; spinImage hSpinImage_ = nullptr; TriggerType triggerType_ = TRIGGER_TYPE_UNSPECIFIED; bool grabImageCommon(std::string &errMsg); bool releaseSpinImage(spinImage &hImage); bool destroySpinImage(spinImage &hImage); void setupTimeStamping(); void updateTimeStamp(); // Get Property Info methods static std::map<PropertyType, std::function<PropertyInfo(CameraDevice_spin*)>> getPropertyInfoDispatchMap_; PropertyInfo getPropertyInfoBrightness(); PropertyInfo getPropertyInfoGamma(); PropertyInfo getPropertyInfoShutter(); PropertyInfo getPropertyInfoGain(); PropertyInfo getPropertyInfoTriggerDelay(); PropertyInfo getPropertyInfoFrameRate(); PropertyInfo getPropertyInfoTemperature(); PropertyInfo getPropertyInfoTriggerMode(); // Get property methods static std::map<PropertyType, std::function<Property(CameraDevice_spin*)>> getPropertyDispatchMap_; Property getPropertyBrightness(); Property getPropertyGamma(); Property getPropertyShutter(); Property getPropertyGain(); Property getPropertyTriggerDelay(); Property getPropertyFrameRate(); Property getPropertyTemperature(); Property getPropertyTriggerMode(); // Set Property methods bool isPropertySettable(PropertyType propType, std::string &msg); static std::map<PropertyType, std::function<void(CameraDevice_spin*,Property)>> setPropertyDispatchMap_; void setPropertyBrightness(Property prop); void setPropertyGamma(Property prop); void setPropertyShutter(Property prop); void setPropertyGain(Property prop); void setPropertyTriggerDelay(Property prop); void setPropertyFrameRate(Property prop); void setPropertyTemperature(Property prop); void setPropertyTriggerMode(Property prop); PixelFormat getPixelFormat(); bool isSupportedPixelFormat(PixelFormat pixelFormat, ImageMode imgMode); // spin get methods // --------------- std::vector<spinPixelFormatEnums> getSupportedPixelFormats_spin(); spinPixelFormatEnums getPixelFormat_spin(); }; typedef std::shared_ptr<CameraDevice_spin> CameraDevicePtr_spin; } #endif // #ifndef BIAS_CAMERA_DEVICE_SPIN_HPP #endif // #ifdef WITH_SPIN
[ "will@iorodeo.com" ]
will@iorodeo.com
36097b2812f67e4dfe80fc726ead8f8b73f6bcae
1391042fa29e096d42ee5a9488d6385ae2fcbffe
/bin/linux64/cpp/obj/src/zpp_nape/dynamics/ZPP_IContact.cpp
e54ff247817f562097435855611a621cbbaaa246
[]
no_license
TomBebbington/brains
8820de236a879c2199147906bf1d390cf44de6cc
c69b51e261fcbe3c1b7bea84568a92424da6a0aa
refs/heads/master
2021-01-10T18:33:08.105130
2013-08-25T23:20:45
2013-08-25T23:20:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
33,584
cpp
#include <hxcpp.h> #ifndef INCLUDED_zpp_nape_dynamics_ZPP_IContact #include <zpp_nape/dynamics/ZPP_IContact.h> #endif namespace zpp_nape{ namespace dynamics{ Void ZPP_IContact_obj::__construct() { HX_STACK_FRAME("ZPP_IContact","new","ZPP_IContact.new","zpp_nape/dynamics/Contact.hx",625) { HX_STACK_LINE(655) this->length = (int)0; HX_STACK_LINE(654) this->pushmod = false; HX_STACK_LINE(653) this->modified = false; HX_STACK_LINE(652) this->_inuse = false; HX_STACK_LINE(641) this->next = null(); HX_STACK_LINE(639) this->lr2y = 0.0; HX_STACK_LINE(638) this->lr2x = 0.0; HX_STACK_LINE(637) this->lr1y = 0.0; HX_STACK_LINE(636) this->lr1x = 0.0; HX_STACK_LINE(635) this->jtAcc = 0.0; HX_STACK_LINE(634) this->jnAcc = 0.0; HX_STACK_LINE(633) this->friction = 0.0; HX_STACK_LINE(632) this->bounce = 0.0; HX_STACK_LINE(631) this->tMass = 0.0; HX_STACK_LINE(630) this->nMass = 0.0; HX_STACK_LINE(629) this->r2y = 0.0; HX_STACK_LINE(628) this->r2x = 0.0; HX_STACK_LINE(627) this->r1y = 0.0; HX_STACK_LINE(626) this->r1x = 0.0; } ; return null(); } ZPP_IContact_obj::~ZPP_IContact_obj() { } Dynamic ZPP_IContact_obj::__CreateEmpty() { return new ZPP_IContact_obj; } hx::ObjectPtr< ZPP_IContact_obj > ZPP_IContact_obj::__new() { hx::ObjectPtr< ZPP_IContact_obj > result = new ZPP_IContact_obj(); result->__construct(); return result;} Dynamic ZPP_IContact_obj::__Create(hx::DynamicArray inArgs) { hx::ObjectPtr< ZPP_IContact_obj > result = new ZPP_IContact_obj(); result->__construct(); return result;} ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::at( int ind){ HX_STACK_FRAME("ZPP_IContact","at","ZPP_IContact.at","zpp_nape/dynamics/Contact.hx",984) HX_STACK_THIS(this) HX_STACK_ARG(ind,"ind") HX_STACK_LINE(993) ::zpp_nape::dynamics::ZPP_IContact it = this->iterator_at(ind); HX_STACK_VAR(it,"it"); HX_STACK_LINE(994) if (((it != null()))){ HX_STACK_LINE(994) return it; } else{ HX_STACK_LINE(994) return null(); } HX_STACK_LINE(994) return null(); } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,at,return ) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::iterator_at( int ind){ HX_STACK_FRAME("ZPP_IContact","iterator_at","ZPP_IContact.iterator_at","zpp_nape/dynamics/Contact.hx",971) HX_STACK_THIS(this) HX_STACK_ARG(ind,"ind") HX_STACK_LINE(980) ::zpp_nape::dynamics::ZPP_IContact ret = this->next; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(981) while(((bool(((ind)-- > (int)0)) && bool((ret != null()))))){ HX_STACK_LINE(981) ret = ret->next; } HX_STACK_LINE(982) return ret; } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,iterator_at,return ) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::back( ){ HX_STACK_FRAME("ZPP_IContact","back","ZPP_IContact.back","zpp_nape/dynamics/Contact.hx",962) HX_STACK_THIS(this) HX_STACK_LINE(963) ::zpp_nape::dynamics::ZPP_IContact ret = this->next; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(964) ::zpp_nape::dynamics::ZPP_IContact cur = ret; HX_STACK_VAR(cur,"cur"); HX_STACK_LINE(965) while(((cur != null()))){ HX_STACK_LINE(966) ret = cur; HX_STACK_LINE(967) cur = cur->next; } HX_STACK_LINE(969) return ret; } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,back,return ) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::front( ){ HX_STACK_FRAME("ZPP_IContact","front","ZPP_IContact.front","zpp_nape/dynamics/Contact.hx",960) HX_STACK_THIS(this) HX_STACK_LINE(960) return this->next; } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,front,return ) bool ZPP_IContact_obj::inlined_has( ::zpp_nape::dynamics::ZPP_IContact obj){ HX_STACK_FRAME("ZPP_IContact","inlined_has","ZPP_IContact.inlined_has","zpp_nape/dynamics/Contact.hx",929) HX_STACK_THIS(this) HX_STACK_ARG(obj,"obj") HX_STACK_LINE(938) bool ret; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(939) { HX_STACK_LINE(940) ret = false; HX_STACK_LINE(941) { HX_STACK_LINE(942) ::zpp_nape::dynamics::ZPP_IContact cx_ite = this->next; HX_STACK_VAR(cx_ite,"cx_ite"); HX_STACK_LINE(943) while(((cx_ite != null()))){ HX_STACK_LINE(944) ::zpp_nape::dynamics::ZPP_IContact npite = cx_ite; HX_STACK_VAR(npite,"npite"); HX_STACK_LINE(946) if (((npite == obj))){ HX_STACK_LINE(947) ret = true; HX_STACK_LINE(948) break; } HX_STACK_LINE(951) cx_ite = cx_ite->next; } } } HX_STACK_LINE(955) return ret; } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,inlined_has,return ) bool ZPP_IContact_obj::has( ::zpp_nape::dynamics::ZPP_IContact obj){ HX_STACK_FRAME("ZPP_IContact","has","ZPP_IContact.has","zpp_nape/dynamics/Contact.hx",925) HX_STACK_THIS(this) HX_STACK_ARG(obj,"obj") HX_STACK_LINE(925) bool ret; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(925) { HX_STACK_LINE(925) ret = false; HX_STACK_LINE(925) { HX_STACK_LINE(925) ::zpp_nape::dynamics::ZPP_IContact cx_ite = this->next; HX_STACK_VAR(cx_ite,"cx_ite"); HX_STACK_LINE(925) while(((cx_ite != null()))){ HX_STACK_LINE(925) ::zpp_nape::dynamics::ZPP_IContact npite = cx_ite; HX_STACK_VAR(npite,"npite"); HX_STACK_LINE(925) if (((npite == obj))){ HX_STACK_LINE(925) ret = true; HX_STACK_LINE(925) break; } HX_STACK_LINE(925) cx_ite = cx_ite->next; } } } HX_STACK_LINE(925) return ret; } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,has,return ) int ZPP_IContact_obj::size( ){ HX_STACK_FRAME("ZPP_IContact","size","ZPP_IContact.size","zpp_nape/dynamics/Contact.hx",922) HX_STACK_THIS(this) HX_STACK_LINE(922) return this->length; } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,size,return ) bool ZPP_IContact_obj::empty( ){ HX_STACK_FRAME("ZPP_IContact","empty","ZPP_IContact.empty","zpp_nape/dynamics/Contact.hx",917) HX_STACK_THIS(this) HX_STACK_LINE(917) return (this->next == null()); } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,empty,return ) Void ZPP_IContact_obj::reverse( ){ { HX_STACK_FRAME("ZPP_IContact","reverse","ZPP_IContact.reverse","zpp_nape/dynamics/Contact.hx",901) HX_STACK_THIS(this) HX_STACK_LINE(902) ::zpp_nape::dynamics::ZPP_IContact cur = this->next; HX_STACK_VAR(cur,"cur"); HX_STACK_LINE(903) ::zpp_nape::dynamics::ZPP_IContact pre = null(); HX_STACK_VAR(pre,"pre"); HX_STACK_LINE(904) while(((cur != null()))){ HX_STACK_LINE(905) ::zpp_nape::dynamics::ZPP_IContact nx = cur->next; HX_STACK_VAR(nx,"nx"); HX_STACK_LINE(906) cur->next = pre; HX_STACK_LINE(907) this->next = cur; HX_STACK_LINE(908) pre = cur; HX_STACK_LINE(909) cur = nx; } HX_STACK_LINE(911) this->modified = true; HX_STACK_LINE(912) this->pushmod = true; } return null(); } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,reverse,(void)) Void ZPP_IContact_obj::inlined_clear( ){ { HX_STACK_FRAME("ZPP_IContact","inlined_clear","ZPP_IContact.inlined_clear","zpp_nape/dynamics/Contact.hx",896) HX_STACK_THIS(this) } return null(); } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,inlined_clear,(void)) Void ZPP_IContact_obj::clear( ){ { HX_STACK_FRAME("ZPP_IContact","clear","ZPP_IContact.clear","zpp_nape/dynamics/Contact.hx",891) HX_STACK_THIS(this) } return null(); } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,clear,(void)) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::splice( ::zpp_nape::dynamics::ZPP_IContact pre,int n){ HX_STACK_FRAME("ZPP_IContact","splice","ZPP_IContact.splice","zpp_nape/dynamics/Contact.hx",886) HX_STACK_THIS(this) HX_STACK_ARG(pre,"pre") HX_STACK_ARG(n,"n") HX_STACK_LINE(887) while(((bool(((n)-- > (int)0)) && bool((pre->next != null()))))){ HX_STACK_LINE(887) this->erase(pre); } HX_STACK_LINE(888) return pre->next; } HX_DEFINE_DYNAMIC_FUNC2(ZPP_IContact_obj,splice,return ) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::inlined_erase( ::zpp_nape::dynamics::ZPP_IContact pre){ HX_STACK_FRAME("ZPP_IContact","inlined_erase","ZPP_IContact.inlined_erase","zpp_nape/dynamics/Contact.hx",854) HX_STACK_THIS(this) HX_STACK_ARG(pre,"pre") HX_STACK_LINE(863) ::zpp_nape::dynamics::ZPP_IContact old; HX_STACK_VAR(old,"old"); HX_STACK_LINE(864) ::zpp_nape::dynamics::ZPP_IContact ret; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(865) if (((pre == null()))){ HX_STACK_LINE(866) old = this->next; HX_STACK_LINE(867) ret = old->next; HX_STACK_LINE(868) this->next = ret; HX_STACK_LINE(869) if (((this->next == null()))){ HX_STACK_LINE(869) this->pushmod = true; } } else{ HX_STACK_LINE(872) old = pre->next; HX_STACK_LINE(873) ret = old->next; HX_STACK_LINE(874) pre->next = ret; HX_STACK_LINE(875) if (((ret == null()))){ HX_STACK_LINE(875) this->pushmod = true; } } HX_STACK_LINE(878) old->_inuse = false; HX_STACK_LINE(881) this->modified = true; HX_STACK_LINE(882) (this->length)--; HX_STACK_LINE(883) this->pushmod = true; HX_STACK_LINE(884) return ret; } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,inlined_erase,return ) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::erase( ::zpp_nape::dynamics::ZPP_IContact pre){ HX_STACK_FRAME("ZPP_IContact","erase","ZPP_IContact.erase","zpp_nape/dynamics/Contact.hx",850) HX_STACK_THIS(this) HX_STACK_ARG(pre,"pre") HX_STACK_LINE(850) ::zpp_nape::dynamics::ZPP_IContact old; HX_STACK_VAR(old,"old"); HX_STACK_LINE(850) ::zpp_nape::dynamics::ZPP_IContact ret; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(850) if (((pre == null()))){ HX_STACK_LINE(850) old = this->next; HX_STACK_LINE(850) ret = old->next; HX_STACK_LINE(850) this->next = ret; HX_STACK_LINE(850) if (((this->next == null()))){ HX_STACK_LINE(850) this->pushmod = true; } } else{ HX_STACK_LINE(850) old = pre->next; HX_STACK_LINE(850) ret = old->next; HX_STACK_LINE(850) pre->next = ret; HX_STACK_LINE(850) if (((ret == null()))){ HX_STACK_LINE(850) this->pushmod = true; } } HX_STACK_LINE(850) old->_inuse = false; HX_STACK_LINE(850) this->modified = true; HX_STACK_LINE(850) (this->length)--; HX_STACK_LINE(850) this->pushmod = true; HX_STACK_LINE(850) return ret; } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,erase,return ) bool ZPP_IContact_obj::inlined_try_remove( ::zpp_nape::dynamics::ZPP_IContact obj){ HX_STACK_FRAME("ZPP_IContact","inlined_try_remove","ZPP_IContact.inlined_try_remove","zpp_nape/dynamics/Contact.hx",826) HX_STACK_THIS(this) HX_STACK_ARG(obj,"obj") HX_STACK_LINE(835) ::zpp_nape::dynamics::ZPP_IContact pre = null(); HX_STACK_VAR(pre,"pre"); HX_STACK_LINE(836) ::zpp_nape::dynamics::ZPP_IContact cur = this->next; HX_STACK_VAR(cur,"cur"); HX_STACK_LINE(837) bool ret = false; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(838) while(((cur != null()))){ HX_STACK_LINE(839) if (((cur == obj))){ HX_STACK_LINE(840) { HX_STACK_LINE(840) ::zpp_nape::dynamics::ZPP_IContact old; HX_STACK_VAR(old,"old"); HX_STACK_LINE(840) ::zpp_nape::dynamics::ZPP_IContact ret1; HX_STACK_VAR(ret1,"ret1"); HX_STACK_LINE(840) if (((pre == null()))){ HX_STACK_LINE(840) old = this->next; HX_STACK_LINE(840) ret1 = old->next; HX_STACK_LINE(840) this->next = ret1; HX_STACK_LINE(840) if (((this->next == null()))){ HX_STACK_LINE(840) this->pushmod = true; } } else{ HX_STACK_LINE(840) old = pre->next; HX_STACK_LINE(840) ret1 = old->next; HX_STACK_LINE(840) pre->next = ret1; HX_STACK_LINE(840) if (((ret1 == null()))){ HX_STACK_LINE(840) this->pushmod = true; } } HX_STACK_LINE(840) old->_inuse = false; HX_STACK_LINE(840) this->modified = true; HX_STACK_LINE(840) (this->length)--; HX_STACK_LINE(840) this->pushmod = true; HX_STACK_LINE(840) ret1; } HX_STACK_LINE(841) ret = true; HX_STACK_LINE(842) break; } HX_STACK_LINE(844) pre = cur; HX_STACK_LINE(845) cur = cur->next; } HX_STACK_LINE(847) return ret; } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,inlined_try_remove,return ) Void ZPP_IContact_obj::inlined_remove( ::zpp_nape::dynamics::ZPP_IContact obj){ { HX_STACK_FRAME("ZPP_IContact","inlined_remove","ZPP_IContact.inlined_remove","zpp_nape/dynamics/Contact.hx",822) HX_STACK_THIS(this) HX_STACK_ARG(obj,"obj") HX_STACK_LINE(822) ::zpp_nape::dynamics::ZPP_IContact pre = null(); HX_STACK_VAR(pre,"pre"); HX_STACK_LINE(822) ::zpp_nape::dynamics::ZPP_IContact cur = this->next; HX_STACK_VAR(cur,"cur"); HX_STACK_LINE(822) bool ret = false; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(822) while(((cur != null()))){ HX_STACK_LINE(822) if (((cur == obj))){ HX_STACK_LINE(822) { HX_STACK_LINE(822) ::zpp_nape::dynamics::ZPP_IContact old; HX_STACK_VAR(old,"old"); HX_STACK_LINE(822) ::zpp_nape::dynamics::ZPP_IContact ret1; HX_STACK_VAR(ret1,"ret1"); HX_STACK_LINE(822) if (((pre == null()))){ HX_STACK_LINE(822) old = this->next; HX_STACK_LINE(822) ret1 = old->next; HX_STACK_LINE(822) this->next = ret1; HX_STACK_LINE(822) if (((this->next == null()))){ HX_STACK_LINE(822) this->pushmod = true; } } else{ HX_STACK_LINE(822) old = pre->next; HX_STACK_LINE(822) ret1 = old->next; HX_STACK_LINE(822) pre->next = ret1; HX_STACK_LINE(822) if (((ret1 == null()))){ HX_STACK_LINE(822) this->pushmod = true; } } HX_STACK_LINE(822) old->_inuse = false; HX_STACK_LINE(822) this->modified = true; HX_STACK_LINE(822) (this->length)--; HX_STACK_LINE(822) this->pushmod = true; HX_STACK_LINE(822) ret1; } HX_STACK_LINE(822) ret = true; HX_STACK_LINE(822) break; } HX_STACK_LINE(822) pre = cur; HX_STACK_LINE(822) cur = cur->next; } HX_STACK_LINE(822) ret; } return null(); } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,inlined_remove,(void)) bool ZPP_IContact_obj::try_remove( ::zpp_nape::dynamics::ZPP_IContact obj){ HX_STACK_FRAME("ZPP_IContact","try_remove","ZPP_IContact.try_remove","zpp_nape/dynamics/Contact.hx",788) HX_STACK_THIS(this) HX_STACK_ARG(obj,"obj") HX_STACK_LINE(797) ::zpp_nape::dynamics::ZPP_IContact pre = null(); HX_STACK_VAR(pre,"pre"); HX_STACK_LINE(798) ::zpp_nape::dynamics::ZPP_IContact cur = this->next; HX_STACK_VAR(cur,"cur"); HX_STACK_LINE(799) bool ret = false; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(800) while(((cur != null()))){ HX_STACK_LINE(801) if (((cur == obj))){ HX_STACK_LINE(802) this->erase(pre); HX_STACK_LINE(803) ret = true; HX_STACK_LINE(804) break; } HX_STACK_LINE(806) pre = cur; HX_STACK_LINE(807) cur = cur->next; } HX_STACK_LINE(809) return ret; } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,try_remove,return ) Void ZPP_IContact_obj::remove( ::zpp_nape::dynamics::ZPP_IContact obj){ { HX_STACK_FRAME("ZPP_IContact","remove","ZPP_IContact.remove","zpp_nape/dynamics/Contact.hx",786) HX_STACK_THIS(this) HX_STACK_ARG(obj,"obj") HX_STACK_LINE(786) ::zpp_nape::dynamics::ZPP_IContact pre = null(); HX_STACK_VAR(pre,"pre"); HX_STACK_LINE(786) ::zpp_nape::dynamics::ZPP_IContact cur = this->next; HX_STACK_VAR(cur,"cur"); HX_STACK_LINE(786) bool ret = false; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(786) while(((cur != null()))){ HX_STACK_LINE(786) if (((cur == obj))){ HX_STACK_LINE(786) { HX_STACK_LINE(786) ::zpp_nape::dynamics::ZPP_IContact old; HX_STACK_VAR(old,"old"); HX_STACK_LINE(786) ::zpp_nape::dynamics::ZPP_IContact ret1; HX_STACK_VAR(ret1,"ret1"); HX_STACK_LINE(786) if (((pre == null()))){ HX_STACK_LINE(786) old = this->next; HX_STACK_LINE(786) ret1 = old->next; HX_STACK_LINE(786) this->next = ret1; HX_STACK_LINE(786) if (((this->next == null()))){ HX_STACK_LINE(786) this->pushmod = true; } } else{ HX_STACK_LINE(786) old = pre->next; HX_STACK_LINE(786) ret1 = old->next; HX_STACK_LINE(786) pre->next = ret1; HX_STACK_LINE(786) if (((ret1 == null()))){ HX_STACK_LINE(786) this->pushmod = true; } } HX_STACK_LINE(786) old->_inuse = false; HX_STACK_LINE(786) this->modified = true; HX_STACK_LINE(786) (this->length)--; HX_STACK_LINE(786) this->pushmod = true; HX_STACK_LINE(786) ret1; } HX_STACK_LINE(786) ret = true; HX_STACK_LINE(786) break; } HX_STACK_LINE(786) pre = cur; HX_STACK_LINE(786) cur = cur->next; } HX_STACK_LINE(786) ret; } return null(); } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,remove,(void)) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::inlined_pop_unsafe( ){ HX_STACK_FRAME("ZPP_IContact","inlined_pop_unsafe","ZPP_IContact.inlined_pop_unsafe","zpp_nape/dynamics/Contact.hx",764) HX_STACK_THIS(this) HX_STACK_LINE(773) ::zpp_nape::dynamics::ZPP_IContact ret = this->next; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(774) this->pop(); HX_STACK_LINE(775) return ret; } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,inlined_pop_unsafe,return ) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::pop_unsafe( ){ HX_STACK_FRAME("ZPP_IContact","pop_unsafe","ZPP_IContact.pop_unsafe","zpp_nape/dynamics/Contact.hx",760) HX_STACK_THIS(this) HX_STACK_LINE(760) ::zpp_nape::dynamics::ZPP_IContact ret = this->next; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(760) this->pop(); HX_STACK_LINE(760) return ret; } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,pop_unsafe,return ) Void ZPP_IContact_obj::inlined_pop( ){ { HX_STACK_FRAME("ZPP_IContact","inlined_pop","ZPP_IContact.inlined_pop","zpp_nape/dynamics/Contact.hx",740) HX_STACK_THIS(this) HX_STACK_LINE(749) ::zpp_nape::dynamics::ZPP_IContact ret = this->next; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(750) this->next = ret->next; HX_STACK_LINE(752) ret->_inuse = false; HX_STACK_LINE(755) if (((this->next == null()))){ HX_STACK_LINE(755) this->pushmod = true; } HX_STACK_LINE(756) this->modified = true; HX_STACK_LINE(757) (this->length)--; } return null(); } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,inlined_pop,(void)) Void ZPP_IContact_obj::pop( ){ { HX_STACK_FRAME("ZPP_IContact","pop","ZPP_IContact.pop","zpp_nape/dynamics/Contact.hx",736) HX_STACK_THIS(this) HX_STACK_LINE(736) ::zpp_nape::dynamics::ZPP_IContact ret = this->next; HX_STACK_VAR(ret,"ret"); HX_STACK_LINE(736) this->next = ret->next; HX_STACK_LINE(736) ret->_inuse = false; HX_STACK_LINE(736) if (((this->next == null()))){ HX_STACK_LINE(736) this->pushmod = true; } HX_STACK_LINE(736) this->modified = true; HX_STACK_LINE(736) (this->length)--; } return null(); } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,pop,(void)) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::inlined_insert( ::zpp_nape::dynamics::ZPP_IContact cur,::zpp_nape::dynamics::ZPP_IContact o){ HX_STACK_FRAME("ZPP_IContact","inlined_insert","ZPP_IContact.inlined_insert","zpp_nape/dynamics/Contact.hx",710) HX_STACK_THIS(this) HX_STACK_ARG(cur,"cur") HX_STACK_ARG(o,"o") HX_STACK_LINE(719) ::zpp_nape::dynamics::ZPP_IContact temp; HX_STACK_VAR(temp,"temp"); HX_STACK_LINE(719) { HX_STACK_LINE(720) o->_inuse = true; HX_STACK_LINE(721) temp = o; } HX_STACK_LINE(723) if (((cur == null()))){ HX_STACK_LINE(724) temp->next = this->next; HX_STACK_LINE(725) this->next = temp; } else{ HX_STACK_LINE(728) temp->next = cur->next; HX_STACK_LINE(729) cur->next = temp; } HX_STACK_LINE(731) this->pushmod = this->modified = true; HX_STACK_LINE(732) (this->length)++; HX_STACK_LINE(733) return temp; } HX_DEFINE_DYNAMIC_FUNC2(ZPP_IContact_obj,inlined_insert,return ) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::insert( ::zpp_nape::dynamics::ZPP_IContact cur,::zpp_nape::dynamics::ZPP_IContact o){ HX_STACK_FRAME("ZPP_IContact","insert","ZPP_IContact.insert","zpp_nape/dynamics/Contact.hx",706) HX_STACK_THIS(this) HX_STACK_ARG(cur,"cur") HX_STACK_ARG(o,"o") HX_STACK_LINE(706) ::zpp_nape::dynamics::ZPP_IContact temp; HX_STACK_VAR(temp,"temp"); HX_STACK_LINE(706) { HX_STACK_LINE(706) o->_inuse = true; HX_STACK_LINE(706) temp = o; } HX_STACK_LINE(706) if (((cur == null()))){ HX_STACK_LINE(706) temp->next = this->next; HX_STACK_LINE(706) this->next = temp; } else{ HX_STACK_LINE(706) temp->next = cur->next; HX_STACK_LINE(706) cur->next = temp; } HX_STACK_LINE(706) this->pushmod = this->modified = true; HX_STACK_LINE(706) (this->length)++; HX_STACK_LINE(706) return temp; } HX_DEFINE_DYNAMIC_FUNC2(ZPP_IContact_obj,insert,return ) Void ZPP_IContact_obj::addAll( ::zpp_nape::dynamics::ZPP_IContact x){ { HX_STACK_FRAME("ZPP_IContact","addAll","ZPP_IContact.addAll","zpp_nape/dynamics/Contact.hx",696) HX_STACK_THIS(this) HX_STACK_ARG(x,"x") HX_STACK_LINE(697) ::zpp_nape::dynamics::ZPP_IContact cx_ite = x->next; HX_STACK_VAR(cx_ite,"cx_ite"); HX_STACK_LINE(698) while(((cx_ite != null()))){ HX_STACK_LINE(699) ::zpp_nape::dynamics::ZPP_IContact i = cx_ite; HX_STACK_VAR(i,"i"); HX_STACK_LINE(700) this->add(i); HX_STACK_LINE(701) cx_ite = cx_ite->next; } } return null(); } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,addAll,(void)) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::inlined_add( ::zpp_nape::dynamics::ZPP_IContact o){ HX_STACK_FRAME("ZPP_IContact","inlined_add","ZPP_IContact.inlined_add","zpp_nape/dynamics/Contact.hx",668) HX_STACK_THIS(this) HX_STACK_ARG(o,"o") HX_STACK_LINE(677) ::zpp_nape::dynamics::ZPP_IContact temp; HX_STACK_VAR(temp,"temp"); HX_STACK_LINE(677) { HX_STACK_LINE(678) o->_inuse = true; HX_STACK_LINE(679) temp = o; } HX_STACK_LINE(681) temp->next = this->next; HX_STACK_LINE(682) this->next = temp; HX_STACK_LINE(683) this->modified = true; HX_STACK_LINE(684) (this->length)++; HX_STACK_LINE(685) return o; } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,inlined_add,return ) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::add( ::zpp_nape::dynamics::ZPP_IContact o){ HX_STACK_FRAME("ZPP_IContact","add","ZPP_IContact.add","zpp_nape/dynamics/Contact.hx",664) HX_STACK_THIS(this) HX_STACK_ARG(o,"o") HX_STACK_LINE(664) ::zpp_nape::dynamics::ZPP_IContact temp; HX_STACK_VAR(temp,"temp"); HX_STACK_LINE(664) { HX_STACK_LINE(664) o->_inuse = true; HX_STACK_LINE(664) temp = o; } HX_STACK_LINE(664) temp->next = this->next; HX_STACK_LINE(664) this->next = temp; HX_STACK_LINE(664) this->modified = true; HX_STACK_LINE(664) (this->length)++; HX_STACK_LINE(664) return o; } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,add,return ) Void ZPP_IContact_obj::setbegin( ::zpp_nape::dynamics::ZPP_IContact i){ { HX_STACK_FRAME("ZPP_IContact","setbegin","ZPP_IContact.setbegin","zpp_nape/dynamics/Contact.hx",658) HX_STACK_THIS(this) HX_STACK_ARG(i,"i") HX_STACK_LINE(659) this->next = i; HX_STACK_LINE(660) this->modified = true; HX_STACK_LINE(661) this->pushmod = true; } return null(); } HX_DEFINE_DYNAMIC_FUNC1(ZPP_IContact_obj,setbegin,(void)) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::begin( ){ HX_STACK_FRAME("ZPP_IContact","begin","ZPP_IContact.begin","zpp_nape/dynamics/Contact.hx",650) HX_STACK_THIS(this) HX_STACK_LINE(650) return this->next; } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,begin,return ) ::zpp_nape::dynamics::ZPP_IContact ZPP_IContact_obj::elem( ){ HX_STACK_FRAME("ZPP_IContact","elem","ZPP_IContact.elem","zpp_nape/dynamics/Contact.hx",645) HX_STACK_THIS(this) HX_STACK_LINE(645) return hx::ObjectPtr<OBJ_>(this); } HX_DEFINE_DYNAMIC_FUNC0(ZPP_IContact_obj,elem,return ) ZPP_IContact_obj::ZPP_IContact_obj() { } void ZPP_IContact_obj::__Mark(HX_MARK_PARAMS) { HX_MARK_BEGIN_CLASS(ZPP_IContact); HX_MARK_MEMBER_NAME(length,"length"); HX_MARK_MEMBER_NAME(pushmod,"pushmod"); HX_MARK_MEMBER_NAME(modified,"modified"); HX_MARK_MEMBER_NAME(_inuse,"_inuse"); HX_MARK_MEMBER_NAME(next,"next"); HX_MARK_MEMBER_NAME(lr2y,"lr2y"); HX_MARK_MEMBER_NAME(lr2x,"lr2x"); HX_MARK_MEMBER_NAME(lr1y,"lr1y"); HX_MARK_MEMBER_NAME(lr1x,"lr1x"); HX_MARK_MEMBER_NAME(jtAcc,"jtAcc"); HX_MARK_MEMBER_NAME(jnAcc,"jnAcc"); HX_MARK_MEMBER_NAME(friction,"friction"); HX_MARK_MEMBER_NAME(bounce,"bounce"); HX_MARK_MEMBER_NAME(tMass,"tMass"); HX_MARK_MEMBER_NAME(nMass,"nMass"); HX_MARK_MEMBER_NAME(r2y,"r2y"); HX_MARK_MEMBER_NAME(r2x,"r2x"); HX_MARK_MEMBER_NAME(r1y,"r1y"); HX_MARK_MEMBER_NAME(r1x,"r1x"); HX_MARK_END_CLASS(); } void ZPP_IContact_obj::__Visit(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(length,"length"); HX_VISIT_MEMBER_NAME(pushmod,"pushmod"); HX_VISIT_MEMBER_NAME(modified,"modified"); HX_VISIT_MEMBER_NAME(_inuse,"_inuse"); HX_VISIT_MEMBER_NAME(next,"next"); HX_VISIT_MEMBER_NAME(lr2y,"lr2y"); HX_VISIT_MEMBER_NAME(lr2x,"lr2x"); HX_VISIT_MEMBER_NAME(lr1y,"lr1y"); HX_VISIT_MEMBER_NAME(lr1x,"lr1x"); HX_VISIT_MEMBER_NAME(jtAcc,"jtAcc"); HX_VISIT_MEMBER_NAME(jnAcc,"jnAcc"); HX_VISIT_MEMBER_NAME(friction,"friction"); HX_VISIT_MEMBER_NAME(bounce,"bounce"); HX_VISIT_MEMBER_NAME(tMass,"tMass"); HX_VISIT_MEMBER_NAME(nMass,"nMass"); HX_VISIT_MEMBER_NAME(r2y,"r2y"); HX_VISIT_MEMBER_NAME(r2x,"r2x"); HX_VISIT_MEMBER_NAME(r1y,"r1y"); HX_VISIT_MEMBER_NAME(r1x,"r1x"); } Dynamic ZPP_IContact_obj::__Field(const ::String &inName,bool inCallProp) { switch(inName.length) { case 2: if (HX_FIELD_EQ(inName,"at") ) { return at_dyn(); } break; case 3: if (HX_FIELD_EQ(inName,"has") ) { return has_dyn(); } if (HX_FIELD_EQ(inName,"pop") ) { return pop_dyn(); } if (HX_FIELD_EQ(inName,"add") ) { return add_dyn(); } if (HX_FIELD_EQ(inName,"r2y") ) { return r2y; } if (HX_FIELD_EQ(inName,"r2x") ) { return r2x; } if (HX_FIELD_EQ(inName,"r1y") ) { return r1y; } if (HX_FIELD_EQ(inName,"r1x") ) { return r1x; } break; case 4: if (HX_FIELD_EQ(inName,"back") ) { return back_dyn(); } if (HX_FIELD_EQ(inName,"size") ) { return size_dyn(); } if (HX_FIELD_EQ(inName,"elem") ) { return elem_dyn(); } if (HX_FIELD_EQ(inName,"next") ) { return next; } if (HX_FIELD_EQ(inName,"lr2y") ) { return lr2y; } if (HX_FIELD_EQ(inName,"lr2x") ) { return lr2x; } if (HX_FIELD_EQ(inName,"lr1y") ) { return lr1y; } if (HX_FIELD_EQ(inName,"lr1x") ) { return lr1x; } break; case 5: if (HX_FIELD_EQ(inName,"front") ) { return front_dyn(); } if (HX_FIELD_EQ(inName,"empty") ) { return empty_dyn(); } if (HX_FIELD_EQ(inName,"clear") ) { return clear_dyn(); } if (HX_FIELD_EQ(inName,"erase") ) { return erase_dyn(); } if (HX_FIELD_EQ(inName,"begin") ) { return begin_dyn(); } if (HX_FIELD_EQ(inName,"jtAcc") ) { return jtAcc; } if (HX_FIELD_EQ(inName,"jnAcc") ) { return jnAcc; } if (HX_FIELD_EQ(inName,"tMass") ) { return tMass; } if (HX_FIELD_EQ(inName,"nMass") ) { return nMass; } break; case 6: if (HX_FIELD_EQ(inName,"splice") ) { return splice_dyn(); } if (HX_FIELD_EQ(inName,"remove") ) { return remove_dyn(); } if (HX_FIELD_EQ(inName,"insert") ) { return insert_dyn(); } if (HX_FIELD_EQ(inName,"addAll") ) { return addAll_dyn(); } if (HX_FIELD_EQ(inName,"length") ) { return length; } if (HX_FIELD_EQ(inName,"_inuse") ) { return _inuse; } if (HX_FIELD_EQ(inName,"bounce") ) { return bounce; } break; case 7: if (HX_FIELD_EQ(inName,"reverse") ) { return reverse_dyn(); } if (HX_FIELD_EQ(inName,"pushmod") ) { return pushmod; } break; case 8: if (HX_FIELD_EQ(inName,"setbegin") ) { return setbegin_dyn(); } if (HX_FIELD_EQ(inName,"modified") ) { return modified; } if (HX_FIELD_EQ(inName,"friction") ) { return friction; } break; case 10: if (HX_FIELD_EQ(inName,"try_remove") ) { return try_remove_dyn(); } if (HX_FIELD_EQ(inName,"pop_unsafe") ) { return pop_unsafe_dyn(); } break; case 11: if (HX_FIELD_EQ(inName,"iterator_at") ) { return iterator_at_dyn(); } if (HX_FIELD_EQ(inName,"inlined_has") ) { return inlined_has_dyn(); } if (HX_FIELD_EQ(inName,"inlined_pop") ) { return inlined_pop_dyn(); } if (HX_FIELD_EQ(inName,"inlined_add") ) { return inlined_add_dyn(); } break; case 13: if (HX_FIELD_EQ(inName,"inlined_clear") ) { return inlined_clear_dyn(); } if (HX_FIELD_EQ(inName,"inlined_erase") ) { return inlined_erase_dyn(); } break; case 14: if (HX_FIELD_EQ(inName,"inlined_remove") ) { return inlined_remove_dyn(); } if (HX_FIELD_EQ(inName,"inlined_insert") ) { return inlined_insert_dyn(); } break; case 18: if (HX_FIELD_EQ(inName,"inlined_try_remove") ) { return inlined_try_remove_dyn(); } if (HX_FIELD_EQ(inName,"inlined_pop_unsafe") ) { return inlined_pop_unsafe_dyn(); } } return super::__Field(inName,inCallProp); } Dynamic ZPP_IContact_obj::__SetField(const ::String &inName,const Dynamic &inValue,bool inCallProp) { switch(inName.length) { case 3: if (HX_FIELD_EQ(inName,"r2y") ) { r2y=inValue.Cast< Float >(); return inValue; } if (HX_FIELD_EQ(inName,"r2x") ) { r2x=inValue.Cast< Float >(); return inValue; } if (HX_FIELD_EQ(inName,"r1y") ) { r1y=inValue.Cast< Float >(); return inValue; } if (HX_FIELD_EQ(inName,"r1x") ) { r1x=inValue.Cast< Float >(); return inValue; } break; case 4: if (HX_FIELD_EQ(inName,"next") ) { next=inValue.Cast< ::zpp_nape::dynamics::ZPP_IContact >(); return inValue; } if (HX_FIELD_EQ(inName,"lr2y") ) { lr2y=inValue.Cast< Float >(); return inValue; } if (HX_FIELD_EQ(inName,"lr2x") ) { lr2x=inValue.Cast< Float >(); return inValue; } if (HX_FIELD_EQ(inName,"lr1y") ) { lr1y=inValue.Cast< Float >(); return inValue; } if (HX_FIELD_EQ(inName,"lr1x") ) { lr1x=inValue.Cast< Float >(); return inValue; } break; case 5: if (HX_FIELD_EQ(inName,"jtAcc") ) { jtAcc=inValue.Cast< Float >(); return inValue; } if (HX_FIELD_EQ(inName,"jnAcc") ) { jnAcc=inValue.Cast< Float >(); return inValue; } if (HX_FIELD_EQ(inName,"tMass") ) { tMass=inValue.Cast< Float >(); return inValue; } if (HX_FIELD_EQ(inName,"nMass") ) { nMass=inValue.Cast< Float >(); return inValue; } break; case 6: if (HX_FIELD_EQ(inName,"length") ) { length=inValue.Cast< int >(); return inValue; } if (HX_FIELD_EQ(inName,"_inuse") ) { _inuse=inValue.Cast< bool >(); return inValue; } if (HX_FIELD_EQ(inName,"bounce") ) { bounce=inValue.Cast< Float >(); return inValue; } break; case 7: if (HX_FIELD_EQ(inName,"pushmod") ) { pushmod=inValue.Cast< bool >(); return inValue; } break; case 8: if (HX_FIELD_EQ(inName,"modified") ) { modified=inValue.Cast< bool >(); return inValue; } if (HX_FIELD_EQ(inName,"friction") ) { friction=inValue.Cast< Float >(); return inValue; } } return super::__SetField(inName,inValue,inCallProp); } void ZPP_IContact_obj::__GetFields(Array< ::String> &outFields) { outFields->push(HX_CSTRING("length")); outFields->push(HX_CSTRING("pushmod")); outFields->push(HX_CSTRING("modified")); outFields->push(HX_CSTRING("_inuse")); outFields->push(HX_CSTRING("next")); outFields->push(HX_CSTRING("lr2y")); outFields->push(HX_CSTRING("lr2x")); outFields->push(HX_CSTRING("lr1y")); outFields->push(HX_CSTRING("lr1x")); outFields->push(HX_CSTRING("jtAcc")); outFields->push(HX_CSTRING("jnAcc")); outFields->push(HX_CSTRING("friction")); outFields->push(HX_CSTRING("bounce")); outFields->push(HX_CSTRING("tMass")); outFields->push(HX_CSTRING("nMass")); outFields->push(HX_CSTRING("r2y")); outFields->push(HX_CSTRING("r2x")); outFields->push(HX_CSTRING("r1y")); outFields->push(HX_CSTRING("r1x")); super::__GetFields(outFields); }; static ::String sStaticFields[] = { String(null()) }; static ::String sMemberFields[] = { HX_CSTRING("at"), HX_CSTRING("iterator_at"), HX_CSTRING("back"), HX_CSTRING("front"), HX_CSTRING("inlined_has"), HX_CSTRING("has"), HX_CSTRING("size"), HX_CSTRING("empty"), HX_CSTRING("reverse"), HX_CSTRING("inlined_clear"), HX_CSTRING("clear"), HX_CSTRING("splice"), HX_CSTRING("inlined_erase"), HX_CSTRING("erase"), HX_CSTRING("inlined_try_remove"), HX_CSTRING("inlined_remove"), HX_CSTRING("try_remove"), HX_CSTRING("remove"), HX_CSTRING("inlined_pop_unsafe"), HX_CSTRING("pop_unsafe"), HX_CSTRING("inlined_pop"), HX_CSTRING("pop"), HX_CSTRING("inlined_insert"), HX_CSTRING("insert"), HX_CSTRING("addAll"), HX_CSTRING("inlined_add"), HX_CSTRING("add"), HX_CSTRING("setbegin"), HX_CSTRING("length"), HX_CSTRING("pushmod"), HX_CSTRING("modified"), HX_CSTRING("_inuse"), HX_CSTRING("begin"), HX_CSTRING("elem"), HX_CSTRING("next"), HX_CSTRING("lr2y"), HX_CSTRING("lr2x"), HX_CSTRING("lr1y"), HX_CSTRING("lr1x"), HX_CSTRING("jtAcc"), HX_CSTRING("jnAcc"), HX_CSTRING("friction"), HX_CSTRING("bounce"), HX_CSTRING("tMass"), HX_CSTRING("nMass"), HX_CSTRING("r2y"), HX_CSTRING("r2x"), HX_CSTRING("r1y"), HX_CSTRING("r1x"), String(null()) }; static void sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(ZPP_IContact_obj::__mClass,"__mClass"); }; #ifdef HXCPP_VISIT_ALLOCS static void sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(ZPP_IContact_obj::__mClass,"__mClass"); }; #endif Class ZPP_IContact_obj::__mClass; void ZPP_IContact_obj::__register() { hx::Static(__mClass) = hx::RegisterClass(HX_CSTRING("zpp_nape.dynamics.ZPP_IContact"), hx::TCanCast< ZPP_IContact_obj> ,sStaticFields,sMemberFields, &__CreateEmpty, &__Create, &super::__SGetClass(), 0, sMarkStatics #ifdef HXCPP_VISIT_ALLOCS , sVisitStatics #endif ); } void ZPP_IContact_obj::__boot() { } } // end namespace zpp_nape } // end namespace dynamics
[ "tophattedcoder@gmail.com" ]
tophattedcoder@gmail.com
9e774e8c0747fd872618b8bf28567a387b0cc5d8
c45511f1d650751d4f3aa685fde49eb6baa24a08
/tests/core_tests/chain_switch_1.h
c084faeba2cf5ad709d949f50ccf3fb6a7d9f44e
[ "BSD-3-Clause" ]
permissive
cutcoin/cutcoin
41a64eb853d209868b2f37bd7675e833fcdb6c7b
2cec00c3b98b7d67a43cd9310271e1de05309c40
refs/heads/master
2023-09-03T17:23:14.797983
2021-04-06T17:26:12
2021-04-06T17:26:12
162,971,729
9
5
null
null
null
null
UTF-8
C++
false
false
2,673
h
// Copyright (c) 2018-2021, CUT coin // Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #pragma once #include "chaingen.h" /************************************************************************/ /* */ /************************************************************************/ class gen_chain_switch_1 : public test_chain_unit_base { public: gen_chain_switch_1(); bool generate(std::vector<test_event_entry>& events) const; bool check_split_not_switched(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry>& events); bool check_split_switched(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry>& events); private: std::vector<cryptonote::block> m_chain_1; cryptonote::account_base m_recipient_account_1; cryptonote::account_base m_recipient_account_2; cryptonote::account_base m_recipient_account_3; cryptonote::account_base m_recipient_account_4; std::vector<cryptonote::transaction> m_tx_pool; };
[ "info@cutcoin.org" ]
info@cutcoin.org
b69a1980f8e21cb9f1aff842e75e786e54196a5c
184d28d5aa0c74573eaf52d7a90c10e4b2ac9cd1
/source/Memory/Finalizer.cpp
58ac29f3dfdf09526b5cd80fed31e9fab2c75ab3
[ "MIT" ]
permissive
kurocha/memory
8ce792f23dcf5ce9ca6183449000ddcaa07da079
57e4fd53202f17764f7fe6cf04ac77d343bae2a5
refs/heads/master
2020-12-10T03:26:20.912305
2019-09-22T11:02:10
2019-09-22T11:02:10
95,565,544
1
0
null
null
null
null
UTF-8
C++
false
false
1,115
cpp
// // Finalizer.cpp // File file is part of the "Memory" project and released under the MIT License. // // Created by Samuel Williams on 27/6/2017. // Copyright, 2017, by Samuel Williams. All rights reserved. // #include "Finalizer.hpp" namespace Memory { Finalizer::~Finalizer() { } void Finalizer::List::insert(Finalizer * finalizer) { Node * node = new Node; node->finalizer = finalizer; node->next = head; head = node; } bool Finalizer::List::erase(Finalizer * finalizer) { Node ** previous = &head; Node * current = head; // It may be possible to improve upon this approach since it is a linear scan. while (current) { if (current->finalizer == finalizer) { *previous = current->next; delete current; return true; } previous = &(current->next); current = current->next; } return false; } void Finalizer::List::finalize(Object * object) { Node * current = head; while (current) { if (current->finalizer) current->finalizer->finalize(object); Node * next = current->next; delete current; current = next; } } }
[ "samuel.williams@oriontransfer.co.nz" ]
samuel.williams@oriontransfer.co.nz
3b83201b1e766fb0faca0c4659ad2ef8654e9f3b
3517125aebbd8b01f40c41a08d8345e251f4ce19
/server_config.ino
45928be1f3e3d26e82dd53889d5ccd841a1a5754
[]
no_license
jasoncwilley/simple_node_webserver
d8bfb588f2a184d830d68dbb2c8a7777ebc67525
416ccbdab413f733603c658021d8f60b20ae5976
refs/heads/main
2023-04-02T21:08:43.841008
2021-03-26T01:57:22
2021-03-26T01:57:22
351,600,617
0
0
null
null
null
null
UTF-8
C++
false
false
2,026
ino
// ESP8266 and ESP32 boards are utilezed in the project // Not all Libs are compatible with both boards // This if statemtn will allow us to control whether or not to // import the ESP32 or ESP8266 lib version #ifdef ESP8266 #include <ESP8266WiFi.h> #include <ESP8266mDNS.h> #elif defined(ESP32) #include <WiFi.h> #include <ESPmDNS.h> #else #error "Board not found" #endif #include "/home/userone/Arduino/simple_node_webserver/index.h" #include <ESPAsyncWebServer.h> AsyncWebServer server(80); // server port 80 void notFound(AsyncWebServerRequest *request) { request->send(404", "text/plain", "Are you lost? The page you requested ws Not Found") } void setup(void) // Begin setup() { Serial.begin(115200); // Begin communiction on Serial 115200 Serial.println("Creating wifi network"); delay(2000); // SSID and Password for the ESP32 Access Point const char* ssid = "smelly_packets"; const char* password = ""; // Access Point is left insecure WiFi.softAP(ssid, password); //Create INSECURE Access Point Serial.println("Intializing wifi network"); delay(2000); Serial.println("Access Point configured..."); Serial.println(ssid); //Return Access Point SSID in Serial Serial.println("has been created at"); Serial.println(WiFi.softAPIP()); //Return Access Point IP address in Serial if (MDNS.begin("ESP")) { //home.local/ Serial.println("MDNS responder started"); } server.on("/", [](AsyncWebServerRequest * request) // Webserver created at home.local return helo world { String index = INDEX_page; // Reads the HTML code from defined in index.h request->send(200, "text/html", index); // Displays code from index.h }); server.on("/page1", HTTP_GET, [](AsyncWebServerRequest * request) { String message = "Hello world, we meet again..."; request->send(200, "text/plain", message); }); server.onNotFound(notFound); // run notFound function if GET returns 404 server.begin(); // starts webserver } // End setup() void loop(void) { }
[ "jason.c.willey@gmail.com" ]
jason.c.willey@gmail.com
0c676c6b92957e22745b21071c641578a84cb990
90d62b5fc8bb764c7238e7db99da3459fa8be4ef
/Project_Prototype/src/examples/player_demo.cpp
678eb9225714d4601919937133870268d9d1e0d9
[ "MIT" ]
permissive
markoczy/2DGameSDK
1d57c6a2f77e91f73a4d47cb7ca42f21339d2795
53da378d604ace1d931dfe6ec336241045675667
refs/heads/master
2022-03-29T05:17:41.618959
2020-01-16T18:26:01
2020-01-16T18:26:01
177,466,808
4
0
MIT
2019-12-19T18:05:22
2019-03-24T20:40:44
C++
UTF-8
C++
false
false
3,187
cpp
#include <examples.h> using namespace std; using namespace game; // Type of player entity const int _PLAYER_TYPE = 200; /** * @brief Test Entity: Movement Controllable by given observables */ class PlayerEntity : public SpriteKinematicEntity { public: PlayerEntity(Game* game, sf::Texture* texture, float speed, Observable<sf::Keyboard::Key>* up, Observable<sf::Keyboard::Key>* down, Observable<sf::Keyboard::Key>* left, Observable<sf::Keyboard::Key>* right) : SpriteKinematicEntity(_PLAYER_TYPE, game, texture), mSpeed(speed) { // // // mUp = new MethodObserver<sf::Keyboard::Key, PlayerEntity>(this, &PlayerEntity::MoveUp); mDown = new MethodObserver<sf::Keyboard::Key, PlayerEntity>(this, &PlayerEntity::MoveDown); mLeft = new MethodObserver<sf::Keyboard::Key, PlayerEntity>(this, &PlayerEntity::MoveLeft); mRight = new MethodObserver<sf::Keyboard::Key, PlayerEntity>(this, &PlayerEntity::MoveRight); mUp->SubscribeTo(up); mDown->SubscribeTo(down); mLeft->SubscribeTo(left); mRight->SubscribeTo(right); } ~PlayerEntity() { delete mUp; delete mDown; delete mLeft; delete mRight; } void OnTick() { if(mDt.x != 0 || mDt.y != 0) { Transform(sf::Transform().translate(mDt)); mDt = sf::Vector2f(); } } void MoveUp(sf::Keyboard::Key) { mDt.y -= mSpeed; } void MoveDown(sf::Keyboard::Key) { mDt.y += mSpeed; } void MoveLeft(sf::Keyboard::Key) { mDt.x -= mSpeed; } void MoveRight(sf::Keyboard::Key) { mDt.x += mSpeed; } private: float mSpeed; // Delta Transform of current tick sf::Vector2f mDt; // Needed for cleanup Observer<sf::Keyboard::Key>* mUp; Observer<sf::Keyboard::Key>* mDown; Observer<sf::Keyboard::Key>* mLeft; Observer<sf::Keyboard::Key>* mRight; }; int playerDemo(float zoom) { cout << "Start playerDemo" << endl; // Create game auto options = GameOptions{"My Game", sf::Vector2i(512, 512), zoom, 50}; auto game = new Game(options); // Create Keyboard Events auto upPressed = new OnKeyPress(sf::Keyboard::Up); auto downPressed = new OnKeyPress(sf::Keyboard::Down); auto leftPressed = new OnKeyPress(sf::Keyboard::Left); auto rightPressed = new OnKeyPress(sf::Keyboard::Right); // Create Game World auto world = GameWorldFactory::CreateGameWorld(game, "res/maps/testmap/tilemap.json", "", "res/maps/testmap/tile_"); game->SetWorld(world); // Create Player entity and Rotating child entity auto tex = AssetManager::GetTexture("res/textures/sample.png"); auto ent = new PlayerEntity(game, tex, 2.0, upPressed, downPressed, leftPressed, rightPressed); // Layout entities in scene auto scene = new SceneGraph(game); auto parent = scene->AddEntity(ent); scene->AddEntity(ent, parent); // Send Events to controller game->AddEvent(upPressed); game->AddEvent(downPressed); game->AddEvent(leftPressed); game->AddEvent(rightPressed); // Run Game game->Run(); return 0; }
[ "a.markoczy@gmail.com" ]
a.markoczy@gmail.com
fa8ac62a3d5e8a7a32556561bda1a367e9dc784f
2e30c9c3554509b1c83a4bfb1195d91262828bc9
/sumOfArray.cpp
53442947f327fc904fb174d36db7bcd51147cd5d
[]
no_license
ChristinaChyi/lab04_ronak45
f3494ba6abb7c02ee6a09f991d3ed262fe1294a4
8b854e0d7c939947d4f7d1dbd525fde67c96c1b8
refs/heads/master
2020-04-24T01:12:37.206030
2019-02-18T03:28:44
2019-02-18T03:28:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
303
cpp
#include "arrayFuncs.h" #include <cstdlib> #include <iostream> int sumOfArray(int a[], int size) { if (size < 1) { std::cerr << "ERROR: sumOfArray called with size < 1" << std::endl; exit(1); } int result=a[0]; for (int i=1; i<size; i++) { result += a[i]; } return result; }
[ "rsparikh@cs.ucsb.edu" ]
rsparikh@cs.ucsb.edu
53c8cd4328a225ca26d3baddef8ffb4263b5ac1c
13a06ef97a2e820302bb7061abc6d2137758fee1
/AshEngine/src/Core/Camera.cpp
89629cd6873c59802c741ea6c0cebf61fa90e23d
[ "MIT" ]
permissive
haoxiaoshuai01/3dshow
65c5f94116a610f9613ad068b73288a962dc09d6
1f060dca01e2ec1edc93ddf6601743dea7f22707
refs/heads/main
2023-08-30T03:13:56.450437
2021-07-26T10:06:36
2021-07-26T10:06:36
388,115,006
0
0
null
null
null
null
UTF-8
C++
false
false
5,065
cpp
#include <Camera.h> Camera::Camera(QObject* parent): QObject(0) { int tmp_log_level = log_level; log_level = LOG_LEVEL_WARNING; setObjectName("Camera"); reset(); log_level = tmp_log_level; setParent(parent); } Camera::Camera(QVector3D position, QVector3D direction, QObject* parent): QObject(0) { setObjectName("Camera"); setMovingSpeed(0.1f); setFieldOfView(45.0f); setNearPlane(0.1f); setFarPlane(100000.0f); setPosition(position); setDirection(direction); setParent(parent); } Camera::Camera(const Camera & camera): QObject(0) { m_movingSpeed = camera.m_movingSpeed; m_fieldOfView = camera.m_fieldOfView; m_aspectRatio = camera.m_aspectRatio; m_nearPlane = camera.m_nearPlane; m_farPlane = camera.m_farPlane; m_position = camera.m_position; m_direction = camera.m_direction; m_up = camera.m_up; setObjectName(camera.objectName()); } Camera::~Camera() { if (log_level >= LOG_LEVEL_INFO) dout << "Camera" << this->objectName() << "is destroyed"; } void Camera::moveForward(float shift) { setPosition(m_position + m_direction * shift * m_movingSpeed); } void Camera::moveRight(float shift) { setPosition(m_position + QVector3D::crossProduct(m_direction, m_up) * shift * m_movingSpeed); } void Camera::moveUp(float shift) { setPosition(m_position + m_up * shift* m_movingSpeed); } void Camera::turnLeft(float angle) { QMatrix4x4 mat; mat.rotate(angle, QVector3D(0, 1, 0)); setDirection(mat * m_direction); } void Camera::lookUp(float angle) { QMatrix4x4 mat; mat.rotate(angle, QVector3D::crossProduct(m_direction, m_up)); setDirection(mat * m_direction); } void Camera::dumpObjectInfo(int l) { qDebug().nospace() << tab(l) << "Camera: " << objectName(); qDebug().nospace() << tab(l + 1) << "Position: " << m_position; qDebug().nospace() << tab(l + 1) << "Direction: " << m_direction; qDebug().nospace() << tab(l + 1) << "Up: " << m_up; qDebug().nospace() << tab(l + 1) << "Moving Speed: " << m_movingSpeed; qDebug().nospace() << tab(l + 1) << "Field of View: " << m_fieldOfView; qDebug().nospace() << tab(l + 1) << "Aspect Ratio: " << m_aspectRatio; qDebug().nospace() << tab(l + 1) << "Near Plane: " << m_nearPlane; qDebug().nospace() << tab(l + 1) << "Far Plane: " << m_farPlane; } void Camera::dumpObjectTree(int l) { dumpObjectInfo(l); } // Get properties float Camera::movingSpeed() const { return m_movingSpeed; } float Camera::fieldOfView() const { return m_fieldOfView; } float Camera::aspectRatio() const { return m_aspectRatio; } float Camera::nearPlane() const { return m_nearPlane; } float Camera::farPlane() const { return m_farPlane; } QVector3D Camera::position() const { return m_position; } QVector3D Camera::direction() const { return m_direction; } // Get projection and view matrix QMatrix4x4 Camera::projectionMatrix() const { QMatrix4x4 mat; mat.perspective(m_fieldOfView, m_aspectRatio, m_nearPlane, m_farPlane); return mat; } QMatrix4x4 Camera::viewMatrix() const { QMatrix4x4 mat; mat.lookAt(m_position, m_position + m_direction, m_up); return mat; } // Public slots void Camera::reset() { setMovingSpeed(0.1f); setFieldOfView(45.0f); setAspectRatio(1.0f); setNearPlane(0.1f); setFarPlane(100000.0f); setPosition(QVector3D(40, 40, 40)); setDirection(QVector3D(-1, -1, -1)); if (log_level >= LOG_LEVEL_INFO) dout << this->objectName() << "is reset"; } void Camera::setMovingSpeed(float movingSpeed) { if (!isEqual(m_movingSpeed, movingSpeed)) { m_movingSpeed = movingSpeed; movingSpeedChanged(m_movingSpeed); } } void Camera::setFieldOfView(float fieldOfView) { if (!isEqual(m_fieldOfView, fieldOfView)) { m_fieldOfView = fieldOfView; fieldOfViewChanged(m_fieldOfView); } } void Camera::setAspectRatio(float aspectRatio) { if (!isEqual(m_aspectRatio, aspectRatio)) { m_aspectRatio = aspectRatio; aspectRatioChanged(m_aspectRatio); } } void Camera::setNearPlane(float nearPlane) { if (!isEqual(m_nearPlane, nearPlane)) { m_nearPlane = nearPlane; nearPlaneChanged(m_nearPlane); } } void Camera::setFarPlane(float farPlane) { if (!isEqual(m_farPlane, farPlane)) { m_farPlane = farPlane; farPlaneChanged(m_farPlane); } } void Camera::setPosition(QVector3D position) { if (!isEqual(m_position, position)) { m_position = position; positionChanged(m_position); } } void Camera::setDirection(QVector3D direction) { direction.normalize(); if (!isEqual(m_direction, direction)) { m_direction = direction; setUpVector(); directionChanged(m_direction); } } // Private functions void Camera::setUpVector() { QVector3D t = QVector3D::crossProduct(m_direction, QVector3D(0, 1, 0)); m_up = QVector3D::crossProduct(t, m_direction); }
[ "15227916361@163.com" ]
15227916361@163.com
71a8b362d946858d64300331909c1bcfc7a0b45a
641fa8341d8c436ad24945bcbf8e7d7d1dd7dbb2
/chrome/app/mash/mash_runner.h
813daa0eb00aa96a845772a1074b647b251fd3fa
[ "BSD-3-Clause" ]
permissive
massnetwork/mass-browser
7de0dfc541cbac00ffa7308541394bac1e945b76
67526da9358734698c067b7775be491423884339
refs/heads/master
2022-12-07T09:01:31.027715
2017-01-19T14:29:18
2017-01-19T14:29:18
73,799,690
4
4
BSD-3-Clause
2022-11-26T11:53:23
2016-11-15T09:49:29
null
UTF-8
C++
false
false
1,027
h
// Copyright 2016 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_APP_MASH_MASH_RUNNER_H_ #define CHROME_APP_MASH_MASH_RUNNER_H_ #include <memory> #include "base/macros.h" #include "services/service_manager/public/interfaces/service.mojom.h" namespace service_manager { class ServiceContext; } // Responsible for running mash, both child and main processes. class MashRunner { public: MashRunner(); ~MashRunner(); // Returns 0 if the process was initialized correctly, or error code on // failure. int Run(); private: void RunMain(); // Returns 0 if the child process was initialized correctly, or error code on // failure. int RunChild(); void StartChildApp(service_manager::mojom::ServiceRequest service_request); std::unique_ptr<service_manager::ServiceContext> context_; DISALLOW_COPY_AND_ASSIGN(MashRunner); }; int MashMain(); #endif // CHROME_APP_MASH_MASH_RUNNER_H_
[ "xElvis89x@gmail.com" ]
xElvis89x@gmail.com
dfbde205255c31075c0663c2aef1c3bec6e7c6b1
5469901a3c49f28747b7744274cd137cdd1b42ef
/cplex_2018/Data.h
71dd80c4f5b6fe0a5d3f1a441a9a9711406f59b9
[]
no_license
gaoyangu/cplex_code
68a94ddc1c2b8715386f131bd71fdb1c1e1fb784
957330364e5514e32010819357b317a0232f5db1
refs/heads/master
2022-12-21T15:54:05.499618
2020-09-15T08:56:25
2020-09-15T08:56:25
287,940,845
0
0
null
null
null
null
UTF-8
C++
false
false
651
h
#pragma once #include <list> #include <vector> #include "Flight.h" #include "Deport.h" #include "Passenger.h" using namespace std; class Data { public: int flightNum; int parkNum; int passengerNum; vector<Flight> flightList; vector<Deport> deportList; vector<Passenger> passengerList; vector<vector<int>> isTypeMatching; vector<vector<int>> isConflict; vector<vector<int>> tranTime = { {15, 20, 20, 15}, {35, 40, 40, 35}, {35, 40, 40, 45}, {20, 30, 30, 20} }; };
[ "1600314850@qq.com" ]
1600314850@qq.com
549af41db9a65d7fe1acf52e5054a2bf629b70d4
21da454a8f032d6ad63ca9460656c1e04440310e
/test/utest/StringTest.cpp
85fb41c510728e6ec167722582db6d8c20583906
[]
no_license
merezhang/wcpp
d9879ffb103513a6b58560102ec565b9dc5855dd
e22eb48ea2dd9eda5cd437960dd95074774b70b0
refs/heads/master
2021-01-10T06:29:42.908096
2009-08-31T09:20:31
2009-08-31T09:20:31
46,339,619
0
0
null
null
null
null
UTF-8
C++
false
false
3,030
cpp
#include "StringTest.h" #include <wcpp/lang/wscUUID.h> #include <wcpp/lang/wscSystem.h> #include <wcpp/lang/wscLong.h> #include <wcpp/lang/wscThrowable.h> StringTest::StringTest(void) { } StringTest::~StringTest(void) { } ws_result StringTest::doTest(void) { trace( "========================================\n" ); trace( "case:StringTest - begin\n" ); test_wsString(); test_wsLong_ToString(); test_wscUUID_ToString(); trace( "case:StringTest - end\n" ); trace( "========================================\n" ); return ws_result( WS_RLT_SUCCESS ); } void StringTest::test_wscUUID_ToString(void) { trace( " -------------------------------- \n" ); trace( "func:test_wscUUID_ToString - begin\n" ); { ws_ptr<wsiString> str1, str2; wscUUID::ToString( wsiObject::sIID.uuid, &str1 ); ws_uuid uuid; wscUUID::ParseUUID( str1, uuid ); wscUUID::ToString( uuid, &str2 ); trace( "wsiObject::sIID : " ); trace( "{3F45A92B-A7D5-4d93-946C-373E56A8C17B}" ); trace( "\n" ); trace( "wsiObject::sIID ToString : " ); trace( str1->GetBuffer() ); trace( "\n" ); trace( "wsiObject::sIID ParseUUID : " ); trace( str2->GetBuffer() ); trace( "\n" ); } ws_ptr<wsiString> str1,str2; wscUUID::ToString( wsiSystem::sIID.uuid, &str1 ); ws_uuid uuid; wscUUID::ParseUUID( str2, uuid ); wscUUID::ToString( uuid, &str2 ); trace( "wsiSystem::sIID : " ); trace( "{FAC4AD98-7554-4561-AF17-9A5ADB66AD30}" ); trace( "\n" ); trace( "wsiSystem::sIID ToString : " ); trace( str1->GetBuffer() ); trace( "\n" ); trace( "wsiSystem::sIID ParseUUID : " ); trace( str2->GetBuffer() ); trace( "\n" ); trace( "func:test_wscUUID_ToString - end\n" ); trace( " -------------------------------- \n" ); } void StringTest::test_wsLong_ToString(void) { trace( " -------------------------------- \n" ); trace( "func:test_wsLong_ToString - begin\n" ); const int len = 8; ws_long values[len] = { -1, 0, 1, 2147483647, -2147483647, 2147483647, // -2147483648, }; ws_ptr<wsiString> str; trace( "ws_long [wsString]\n" ); for (int i=0; i<len; i++) { wscLong::ToString( values[i], &str ); trace( values[i] ); trace( " [" ); trace( str->GetBuffer() ); trace( "]\n" ); } trace( "func:test_wsLong_ToString - end\n" ); trace( " -------------------------------- \n" ); } void StringTest::test_wsString(void) { trace( " -------------------------------- \n" ); trace( "func:test_wsString - begin\n" ); ws_str str1; ws_str str2( static_cast<wsiString*>(WS_NULL) ); ws_str str3( "" ); ws_str str4( "hello" ); str1 = str4; str2 = str4; str3 = str4; str4 = ""; str3 = str4; str4.SetString( 0, 0 ); str3 = "abcdefg hijk lmn opq rst uvw xyz"; str4 = "hp"; trace( "func:test_wsString - end\n" ); trace( " -------------------------------- \n" ); }
[ "xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8" ]
xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8
98045de483fd823fcd7b33feec700cac2368ee1c
c057e033602e465adfa3d84d80331a3a21cef609
/C/testcases/CWE127_Buffer_Underread/s01/CWE127_Buffer_Underread__CWE839_listen_socket_82.h
25e31d3aeab7fd7a7aff5f03c5ca23a7160008bb
[]
no_license
Anzsley/My_Juliet_Test_Suite_v1.3_for_C_Cpp
12c2796ae7e580d89e4e7b8274dddf920361c41c
f278f1464588ffb763b7d06e2650fda01702148f
refs/heads/main
2023-04-11T08:29:22.597042
2021-04-09T11:53:16
2021-04-09T11:53:16
356,251,613
1
0
null
null
null
null
UTF-8
C++
false
false
1,449
h
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE127_Buffer_Underread__CWE839_listen_socket_82.h Label Definition File: CWE127_Buffer_Underread__CWE839.label.xml Template File: sources-sinks-82.tmpl.h */ /* * @description * CWE: 127 Buffer Underread * BadSource: listen_socket Read data using a listen socket (server side) * GoodSource: Non-negative but less than 10 * Sinks: * GoodSink: Ensure the array index is valid * BadSink : Improperly check the array index by not checking to see if the value is negative * Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer * * */ #include "std_testcase.h" namespace CWE127_Buffer_Underread__CWE839_listen_socket_82 { class CWE127_Buffer_Underread__CWE839_listen_socket_82_base { public: /* pure virtual function */ virtual void action(int data) = 0; }; #ifndef OMITBAD class CWE127_Buffer_Underread__CWE839_listen_socket_82_bad : public CWE127_Buffer_Underread__CWE839_listen_socket_82_base { public: void action(int data); }; #endif /* OMITBAD */ #ifndef OMITGOOD class CWE127_Buffer_Underread__CWE839_listen_socket_82_goodG2B : public CWE127_Buffer_Underread__CWE839_listen_socket_82_base { public: void action(int data); }; class CWE127_Buffer_Underread__CWE839_listen_socket_82_goodB2G : public CWE127_Buffer_Underread__CWE839_listen_socket_82_base { public: void action(int data); }; #endif /* OMITGOOD */ }
[ "65642214+Anzsley@users.noreply.github.com" ]
65642214+Anzsley@users.noreply.github.com
6b0abafe70af21017e2521960b1ef9a285061405
5af80813298c3a2da7f7e3e28adb1b9bcc433878
/gameplay/src/Curve.h
05e9a246ee572af18300197eefa4dcf24b9e12b1
[]
no_license
damonyan1985/SkCanvas
c250ad47bdd0fa072ca859c6b1242dede2045f95
731ae8abb540382da2e156e8d93373c4563017ea
refs/heads/master
2021-09-10T20:03:51.927207
2018-03-23T02:02:10
2018-03-23T02:02:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,129
h
#ifndef CURVE_H_ #define CURVE_H_ #include "Ref.h" namespace gameplay { /** * Defines an n-dimensional curve. */ class Curve : public Ref { friend class AnimationTarget; friend class Animation; friend class AnimationClip; friend class AnimationController; friend class MeshSkin; public: /** * Types of interpolation. * * Defines how the points in the curve are connected. * * Note: InterpolationType::BEZIER requires control points and InterpolationType::HERMITE requires tangents. */ enum InterpolationType { /** * Bezier Interpolation. * * Requires that two control points are set for each segment. */ BEZIER, /** * B-Spline Interpolation. * * Uses the points as control points, and the curve is guaranteed to only pass through the * first and last point. */ BSPLINE, /** * Flat Interpolation. * * A form of Hermite interpolation that generates flat tangents for you. The tangents have a value equal to 0. */ FLAT, /** * Hermite Interpolation. * * Requires that two tangents for each segment. */ HERMITE, /** * Linear Interpolation. */ LINEAR, /** * Smooth Interpolation. * * A form of Hermite interpolation that generates tangents for each segment based on the points prior to and after the segment. */ SMOOTH, /** * Discrete Interpolation. */ STEP, /** * Quadratic-In Interpolation. */ QUADRATIC_IN, /** * Quadratic-Out Interpolation. */ QUADRATIC_OUT, /** * Quadratic-In-Out Interpolation. */ QUADRATIC_IN_OUT, /** * Quadratic-Out-In Interpolation. */ QUADRATIC_OUT_IN, /** * Cubic-In Interpolation. */ CUBIC_IN, /** * Cubic-Out Interpolation. */ CUBIC_OUT, /** * Cubic-In-Out Interpolation. */ CUBIC_IN_OUT, /** * Cubic-Out-In Interpolation. */ CUBIC_OUT_IN, /** * Quartic-In Interpolation. */ QUARTIC_IN, /** * Quartic-Out Interpolation. */ QUARTIC_OUT, /** * Quartic-In-Out Interpolation. */ QUARTIC_IN_OUT, /** * Quartic-Out-In Interpolation. */ QUARTIC_OUT_IN, /** * Quintic-In Interpolation. */ QUINTIC_IN, /** * Quintic-Out Interpolation. */ QUINTIC_OUT, /** * Quintic-In-Out Interpolation. */ QUINTIC_IN_OUT, /** * Quintic-Out-In Interpolation. */ QUINTIC_OUT_IN, /** * Sine-In Interpolation. */ SINE_IN, /** * Sine-Out Interpolation. */ SINE_OUT, /** * Sine-In-Out Interpolation. */ SINE_IN_OUT, /** * Sine-Out-In Interpolation. */ SINE_OUT_IN, /** * Exponential-In Interpolation. */ EXPONENTIAL_IN, /** * Exponential-Out Interpolation. */ EXPONENTIAL_OUT, /** * Exponential-In-Out Interpolation. */ EXPONENTIAL_IN_OUT, /** * Exponential-Out-In Interpolation. */ EXPONENTIAL_OUT_IN, /** * Circular-In Interpolation. */ CIRCULAR_IN, /** * Circular-Out Interpolation. */ CIRCULAR_OUT, /** * Circular-In-Out Interpolation. */ CIRCULAR_IN_OUT, /** * Circular-Out-In Interpolation. */ CIRCULAR_OUT_IN, /** * Elastic-In Interpolation. */ ELASTIC_IN, /** * Elastic-Out Interpolation. */ ELASTIC_OUT, /** * Elastic-In-Out Interpolation. */ ELASTIC_IN_OUT, /** * Elastic-Out-In Interpolation. */ ELASTIC_OUT_IN, /** * Overshoot-In Interpolation. */ OVERSHOOT_IN, /** * Overshoot-Out Interpolation. */ OVERSHOOT_OUT, /** * Overshoot-In-Out Interpolation. */ OVERSHOOT_IN_OUT, /** * Overshoot-Out-In Interpolation. */ OVERSHOOT_OUT_IN, /** * Bounce-In Interpolation. */ BOUNCE_IN, /** * Bounce-Out Interpolation. */ BOUNCE_OUT, /** * Bounce-In-Out Interpolation. */ BOUNCE_IN_OUT, /** * Bounce-Out-In Interpolation. */ BOUNCE_OUT_IN }; /** * Creates a new curve. * * @param pointCount The number of points in the curve. * @param componentCount The number of float component values per key value. * @script{create} */ static Curve* create(unsigned int pointCount, unsigned int componentCount); /** * Gets the number of points in the curve. * * @return The number of points in the curve. */ unsigned int getPointCount() const; /** * Gets the number of float component values per points. * * @return The number of float component values per point. */ unsigned int getComponentCount() const; /** * Returns the start time for the curve. * * @return The curve's start time. */ float getStartTime() const; /** * Returns the end time for the curve. * * @return The curve's end time. */ float getEndTime() const; /** * Sets the given point values on the curve. * * @param index The index of the point. * @param time The time for the key. * @param value The point to add. * @param type The curve interpolation type. */ void setPoint(unsigned int index, float time, float* value, InterpolationType type); /** * Sets the given point on the curve for the specified index and the specified parameters. * * @param index The index of the point. * @param time The time of the point within the curve. * @param value The value of the point to copy the data from. * @param type The curve interpolation type. * @param inValue The tangent approaching the point. * @param outValue The tangent leaving the point. */ void setPoint(unsigned int index, float time, float* value, InterpolationType type, float* inValue, float* outValue); /** * Sets the tangents for a point on the curve specified by the index. * * @param index The index of the point. * @param type The interpolation type. * @param type The curve interpolation type. * @param inValue The tangent approaching the point. * @param outValue The tangent leaving the point. */ void setTangent(unsigned int index, InterpolationType type, float* inValue, float* outValue); /** * Gets the time at a specified point. * * @param index The index of the point. * * @return The time for a key point. */ float getPointTime(unsigned int index) const; /** * Gets the interpolation type at the specified point * * @param index The index of the point. * * @return The interpolation type at the specified index. */ InterpolationType getPointInterpolation(unsigned int index) const; /** * Gets the values and in/out tangent value at a spedified point. * * @param index The index of the point. * @param value The value at the specified index. Ignored if NULL. * @param inValue The tangent inValue at the specified index. Ignored if NULL. * @param outValue The tangent outValue at the specified index. Ignored if NULL. */ void getPointValues(unsigned int index, float* value, float* inValue, float* outValue) const; /** * Evaluates the curve at the given position value. * * Time should generally be specified as a value between 0.0 - 1.0, inclusive. * A value outside this range can also be specified to perform an interpolation * between the two end points of the curve. This can be useful for smoothly * interpolating a repeat of the curve. * * @param time The position to evaluate the curve at. * @param dst The evaluated value of the curve at the given time. */ void evaluate(float time, float* dst) const; /** * Evaluates the curve at the given position value (between 0.0 and 1.0 inclusive) * within the specified subregion of the curve. * * This method is useful for evaluating sub sections of the curve. A common use for * this is when evaluating individual animation clips that are positioned within a * larger animation curve. This method also allows looping to occur between the * end points of curve sub regions, with optional blending/interpolation between * the end points (using the loopBlendTime parameter). * * Time should generally be specified as a value between 0.0 - 1.0, inclusive. * A value outside this range can also be specified to perform an interpolation * between the two end points of the curve. This can be useful for smoothly * interpolating a repeat of the curve. * * @param time The position within the subregion of the curve to evaluate the curve at. * A time of zero represents the start of the subregion, with a time of one * representing the end of the subregion. * @param startTime Start time for the subregion (between 0.0 - 1.0). * @param endTime End time for the subregion (between 0.0 - 1.0). * @param loopBlendTime Time (in milliseconds) to blend between the end points of the curve * for looping purposes when time is outside the range 0-1. A value of zero here * disables curve looping. * @param dst The evaluated value of the curve at the given time. */ void evaluate(float time, float startTime, float endTime, float loopBlendTime, float* dst) const; /** * Linear interpolation function. */ static float lerp(float t, float from, float to); private: /** * Defines a single point within a curve. */ class Point { public: /** The time of the point within the curve. */ float time; /** The value of the point. */ float* value; /** The value of the tangent when approaching this point (from the previous point in the curve). */ float* inValue; /** The value of the tangent when leaving this point (towards the next point in the curve). */ float* outValue; /** The type of interpolation to use between this point and the next point. */ InterpolationType type; /** * Constructor. */ Point(); /** * Destructor. */ ~Point(); /** * Hidden copy assignment operator. */ Point& operator=(const Point&); }; /** * Constructor. */ Curve(); /** * Constructs a new curve and the specified parameters. * * @param pointCount The number of points in the curve. * @param componentCount The number of float component values per key value. */ Curve(unsigned int pointCount, unsigned int componentCount); /** * Constructor. */ Curve(const Curve& copy); /** * Destructor. */ ~Curve(); /** * Hidden copy assignment operator. */ Curve& operator=(const Curve&); /** * Bezier interpolation function. */ void interpolateBezier(float s, Point* from, Point* to, float* dst) const; /** * Bspline interpolation function. */ void interpolateBSpline(float s, Point* c0, Point* c1, Point* c2, Point* c3, float* dst) const; /** * Hermite interpolation function. */ void interpolateHermite(float s, Point* from, Point* to, float* dst) const; /** * Hermite interpolation function. */ void interpolateHermiteFlat(float s, Point* from, Point* to, float* dst) const; /** * Hermite interpolation function. */ void interpolateHermiteSmooth(float s, unsigned int index, Point* from, Point* to, float* dst) const; /** * Linear interpolation function. */ void interpolateLinear(float s, Point* from, Point* to, float* dst) const; /** * Quaternion interpolation function. */ void interpolateQuaternion(float s, float* from, float* to, float* dst) const; /** * Determines the current keyframe to interpolate from based on the specified time. */ int determineIndex(float time, unsigned int min, unsigned int max) const; /** * Sets the offset for the beginning of a Quaternion piece of data within the curve's value span at the specified * index. The next four components of data starting at the given index will be interpolated as a Quaternion. * This function will assert an error if the given index is greater than the component size subtracted by the four components required * to store a quaternion. * * @param index The index of the Quaternion rotation data. */ void setQuaternionOffset(unsigned int index); /** * Gets the InterpolationType value for the given string ID * * @param interpolationId The string representation of the InterpolationType * @return the InterpolationType value; -1 if the string does not represent an InterpolationType. */ static int getInterpolationType(const char* interpolationId); unsigned int _pointCount; // Number of points on the curve. unsigned int _componentCount; // Number of components on the curve. unsigned int _componentSize; // The component size (in bytes). unsigned int* _quaternionOffset; // Offset for the rotation component. Point* _points; // The points on the curve. }; } #endif
[ "hgl868@126.com" ]
hgl868@126.com
ba5fe24e947e5f56fa5d69dde18eb158f92b43bd
5bc47dcf9ab0843b9d06bc25012bcb2f78874216
/53C.cpp
c99cc49bc819989af83b73d5b3f0b6865baf1a26
[]
no_license
MijaTola/Codeforce
428f466248a4e9d42ac457aa971f681320dc5018
9e85803464ed192c6c643bd0f920f345503ac967
refs/heads/master
2021-01-10T16:27:12.479907
2020-10-14T15:00:14
2020-10-14T15:00:14
45,284,776
0
0
null
null
null
null
UTF-8
C++
false
false
260
cpp
#include <bits/stdc++.h> using namespace std; int main() { int b; cin >> b; int a = 1; int f = 1; while(a <= b) { if(f) cout << a++ << " "; else cout << b-- << " "; f = !f; } cout << "\n"; return 0; }
[ "mija.tola.ap@gmail.com" ]
mija.tola.ap@gmail.com
5b731e52b88fe8cbeea776622b9855e8cb61c296
b367fe5f0c2c50846b002b59472c50453e1629bc
/xbox_leak_may_2020/xbox trunk/xbox/private/test/multimedia/dmusic/dmtest1/TemplateError/DMTest1/AudioPath_SetVolume_Invalid.cpp
30bc944796c3718192106774f495915a2d7b3ce9
[]
no_license
sgzwiz/xbox_leak_may_2020
11b441502a659c8da8a1aa199f89f6236dd59325
fd00b4b3b2abb1ea6ef9ac64b755419741a3af00
refs/heads/master
2022-12-23T16:14:54.706755
2020-09-27T18:24:48
2020-09-27T18:24:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,130
cpp
/******************************************************************************** FILE: AUDIOPATH8.cpp PURPOSE: Contains AudioPath test functions. BY: DANHAFF ********************************************************************************/ #include "globals.h" #include "cicmusicx.h" /******************************************************************************** Main test function. ********************************************************************************/ HRESULT AudioPath_SetVolume_Invalid(CtIDirectMusicPerformance8* ptPerf8) { HRESULT hr = S_OK; CICMusic Music; CtIDirectMusicAudioPath *ptPath = NULL; //Start the music playing. hr = Music.Init(ptPerf8, g_szDefaultMedia, DMUS_APATH_DYNAMIC_STEREO); if (S_OK != hr) goto TEST_END; hr = Music.GetInterface(&ptPath); hr = ptPath->SetVolume(-10001, 0); Log(FYILOGLEVEL, "ERROR!!!!! Should have int3'd"); hr = ptPath->SetVolume(1, 0); Log(FYILOGLEVEL, "ERROR!!!!! Should have int3'd"); TEST_END: SAFE_RELEASE(ptPath); return hr; };
[ "benjamin.barratt@icloud.com" ]
benjamin.barratt@icloud.com
c657fcd3e7e0f04e509e37930508fec3c4e7efe8
0e9394230899fd0df0c891a83131883f4451bcb9
/include/boost/simd/constant/definition/oneosqrt5.hpp
be7bc770213d7aa2084fd475e4229585ee747d02
[ "BSL-1.0" ]
permissive
WillowOfTheBorder/boost.simd
f75764485424490302291fbe9856d10eb55cdbf6
561316cc54bdc6353ca78f3b6d7e9120acd11144
refs/heads/master
2022-05-02T07:07:29.560118
2016-04-21T12:53:10
2016-04-21T12:53:10
59,155,554
1
0
null
null
null
null
UTF-8
C++
false
false
1,526
hpp
//================================================================================================== /*! @file @copyright 2012-2015 NumScale SAS Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ //================================================================================================== #ifndef BOOST_SIMD_CONSTANT_DEFINITION_ONEOSQRT5_HPP_INCLUDED #define BOOST_SIMD_CONSTANT_DEFINITION_ONEOSQRT5_HPP_INCLUDED #include <boost/simd/config.hpp> #include <boost/simd/detail/brigand.hpp> #include <boost/simd/detail/dispatch.hpp> #include <boost/simd/detail/constant_traits.hpp> #include <boost/dispatch/function/make_callable.hpp> #include <boost/dispatch/hierarchy/functions.hpp> #include <boost/dispatch/as.hpp> namespace boost { namespace simd { namespace tag { struct oneosqrt5_ : boost::dispatch::constant_value_<oneosqrt5_> { BOOST_DISPATCH_MAKE_CALLABLE(ext,oneosqrt5_,boost::dispatch::constant_value_<oneosqrt5_>); BOOST_SIMD_REGISTER_CONSTANT(0, 0x3ee4f92eUL, 0x3fdc9f25c5bfedd9ULL); }; } namespace ext { BOOST_DISPATCH_FUNCTION_DECLARATION(tag,oneosqrt5_); } namespace detail { BOOST_DISPATCH_CALLABLE_DEFINITION(tag::oneosqrt5_,oneosqrt5); } template<typename T> BOOST_FORCEINLINE auto Oneosqrt5() BOOST_NOEXCEPT_DECLTYPE(detail::oneosqrt5( boost::dispatch::as_<T>{})) { return detail::oneosqrt5( boost::dispatch::as_<T>{} ); } } } #endif
[ "charly.chevalier@numscale.com" ]
charly.chevalier@numscale.com
53c7abaaca6dec19e7d464ce3cdfc49eea7fb92d
95791ff410128726d8d940cd0014535ccb9c16af
/第6章/6.36_递归的求幂计算/main.cpp
c9d9878aafd56c4a805dda702f90c67f2e820977
[]
no_license
LiuXJingx/liu_xinjing
d7c6162d636b7040d41907da47975666bdbf8a9a
e752bb3ce882ef1217b5b9f9e897b194011b5c66
refs/heads/master
2020-04-02T10:42:24.754626
2019-04-21T11:10:44
2019-04-21T11:10:44
154,350,958
0
0
null
null
null
null
UTF-8
C++
false
false
298
cpp
#include <iostream> using namespace std; int power(int base,int exponent) { if(exponent>1) return base*power(base,exponent-1); } int main() { cout<<"Enter base and exponent: "; int base,exponent; cin>>base>>exponent; cout << power(base,exponent) << endl; return 0; }
[ "2464923693@qq.com" ]
2464923693@qq.com
8490bca134100db1659fafb5c6c1f971756543a7
7f2aa0e6328e1ea095b1ef2166c772c7c71541ce
/Step 7 - Transform/Render/Device.h
ecee57a837e8a1c2540d6aef5683a0022cb20ed6
[]
no_license
ENgineE777/RS_Steps
97eb5f9bf3aa94c53b76eec8434150f5b5921d40
85d5e43ea12f75ca1e2b2ab0d826d1b6a8dc222b
refs/heads/master
2021-01-19T13:37:41.460416
2017-08-06T17:06:30
2017-08-06T17:09:26
82,404,755
3
0
null
null
null
null
UTF-8
C++
false
false
954
h
#pragma once #include "Helpers/Helpers.h" #include "Shader.h" #include "GeometryBuffer.h" #include "Program.h" #include "Texture.h" class Device { friend class Render; friend class Program; virtual bool Init(int width, int height, void* data) = 0; virtual void Release() = 0; public: enum Primitive { LineStrip = 0, LinesList, TriangleStrip, TrianglesList }; virtual void Clear(bool renderTarget, Color color, bool zbuffer, float zValue) = 0; virtual void Present() = 0; virtual GeometryBuffer* CreateBuffer(int size, int stride) = 0; virtual void SetVertexBuffer(int slot, GeometryBuffer* buffer) = 0; virtual Texture* CreateTexture(int w, int h, Texture::Format f, int l, Texture::Type tp) = 0; virtual void Draw(Primitive prim, int startVertex, int primCount) { if (Program::current) { Program::current->SetShaders(); } } protected: virtual Shader* CreateShader(Shader::Type type, const char* name) = 0; };
[ "enginee777@gmail.com" ]
enginee777@gmail.com
e80cfecea2ca2464d5534f40d0ac4a484ad646d9
4baedf73762706ceedbef490f465eeaeea33c2b8
/fullratio.hpp
a05767cd90d005a8af5d6edd235d9eaadb64bc62
[]
no_license
vapostolopoulos/RationalNumbers
e47809f4f58175f83ce287ec292aaa04ee5030b8
8e9bf2dff08e20c63bc63728e3fad02ceae68af4
refs/heads/master
2023-01-11T06:16:49.351863
2020-11-05T02:28:54
2020-11-05T02:28:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
556
hpp
#ifndef __FULLRATIO_HPP__ #define __FULLRATIO_HPP__ #include <iostream> class rational { public: rational(int n, int d = 1); friend rational operator + (const rational &x, const rational &y); friend rational operator - (const rational &x, const rational &y); friend rational operator * (const rational &x, const rational &y); friend rational operator / (const rational &x, const rational &y); friend std::ostream & operator << (std::ostream &out, const rational &x); private: int nom, den; static int gcd (int a, int b); }; #endif
[ "vnapostolop@gmail.com" ]
vnapostolop@gmail.com
00203e53a3447ca3bb87245db870620b98f1b2a3
11e0959139da59360d91a49fdb0385482fb96262
/InputSetup.cpp
ac6d5fe9eb5824c829d45e2d3ab8cef8d7ef5c8e
[]
no_license
ePubRepo/life
1acfc7def910e6e2e5034cd053091445ef5eb09a
3cdc3462fc2df32bd04e0700c48c9dc568673ce3
refs/heads/master
2021-01-20T05:49:51.084898
2012-12-05T05:02:32
2012-12-05T05:02:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,610
cpp
// // InputSetup.cpp // life // // Copyright 2012 <EAB> #include <iostream> // for cout #include <string> using namespace std; #include "./InputSetup.h" #include "./StanfordCPPLib/console.h" // required of all files that contain the main function #include "./StanfordCPPLib/simpio.h" // for getLine #include "./GridCreator.h" InputSetup::InputSetup() { this->setInputSetupChoice(); } InputSetupChoice InputSetup::processUserSetupInput(const string &userInput) { InputSetupChoice userChoice; if (userInput == "") { userChoice.usetInputSetupChoiceSelection = SEED_RANDOMLY; } else { userChoice.usetInputSetupChoiceSelection = INPUT_FILE; userChoice.filePath = userInput; } return userChoice; } void InputSetup::setInputSetupChoice() { bool validBoardSetup = false; InputSetupChoice userChoice; while (!validBoardSetup) { string userInput = this->getUserSelection(); userChoice = this->processUserSetupInput(userInput); GridCreator myCreator(userChoice); if (myCreator.isValidGridLoaded()) { validBoardSetup = true; this->loadedGrid = myCreator.getLoadedGrid(); } else { cout << "Please enter a valid file." << endl; } } } string InputSetup::getUserSelection() { cout << "You can start your colony with random cells or " "read from a prepared file." << endl; string prompt = "Enter name of colony file (or RETURN to seed randomly): "; return getLine(prompt); } Grid<int> InputSetup::getLoadedGrid() { return this->loadedGrid; }
[ "your@email.com" ]
your@email.com
89253842e7bc5e199385eb44bf7f06c03af302e8
b1e7481f8b5bf40c2547c95b1863e25b11b8ef78
/RDF/BTagCalibrationStandalone.h
8e36d456ba1699960be2f7425d152579544e389d
[ "Apache-2.0" ]
permissive
NJManganelli/FourTopNAOD
3df39fd62c0546cdbb1886b23e35ebdc1d3598ad
c86181ae02b1933be59d563c94e76d39b83e0c52
refs/heads/master
2022-12-22T22:33:58.697162
2022-12-17T01:19:36
2022-12-17T01:19:36
143,607,743
1
1
Apache-2.0
2022-06-04T23:11:42
2018-08-05T11:40:42
Python
UTF-8
C++
false
false
5,033
h
#ifndef BTagEntry_H #define BTagEntry_H // Copied from https://github.com/cms-sw/cmssw/blob/master/CondTools/BTau/test/BTagCalibrationStandalone.h // and slightly modified for use in RDataFrame (faster initialization) /** * * BTagEntry * * Represents one pt- or discriminator-dependent calibration function. * * measurement_type: e.g. comb, ttbar, di-mu, boosted, ... * sys_type: e.g. central, plus, minus, plus_JEC, plus_JER, ... * * Everything is converted into a function, as it is easiest to store it in a * txt or json file. * ************************************************************/ #include <string> #include <TF1.h> #include <TH1.h> class BTagEntry { public: enum OperatingPoint { OP_LOOSE=0, OP_MEDIUM=1, OP_TIGHT=2, OP_RESHAPING=3, }; enum JetFlavor { FLAV_B=0, FLAV_C=1, FLAV_UDSG=2, }; struct Parameters { OperatingPoint operatingPoint; std::string measurementType; std::string sysType; JetFlavor jetFlavor; float etaMin; float etaMax; float ptMin; float ptMax; float discrMin; float discrMax; // default constructor Parameters( OperatingPoint op=OP_TIGHT, std::string measurement_type="comb", std::string sys_type="central", JetFlavor jf=FLAV_B, float eta_min=-99999., float eta_max=99999., float pt_min=0., float pt_max=99999., float discr_min=0., float discr_max=99999. ); }; BTagEntry() {} BTagEntry(const std::string &csvLine); BTagEntry(const std::string &func, Parameters p); BTagEntry(const TF1* func, Parameters p); BTagEntry(const TH1* histo, Parameters p); ~BTagEntry() {} static std::string makeCSVHeader(); std::string makeCSVLine() const; static std::string trimStr(std::string str); // public, no getters needed std::string formula; Parameters params; static inline JetFlavor jetFlavourFromHadronFlavour(int hadronFlavour) { switch(hadronFlavour) { case 5: return FLAV_B; case 4: return FLAV_C; default: return FLAV_UDSG; } } }; #endif // BTagEntry_H #ifndef BTagCalibration_H #define BTagCalibration_H /** * BTagCalibration * * The 'hierarchy' of stored information is this: * - by tagger (BTagCalibration) * - by operating point or reshape bin * - by jet parton flavor * - by type of measurement * - by systematic * - by eta bin * - as 1D-function dependent of pt or discriminant * ************************************************************/ #include <map> #include <vector> #include <string> #include <istream> #include <ostream> class BTagCalibration { public: BTagCalibration() {} BTagCalibration(const std::string &tagger); BTagCalibration(const std::string &tagger, const std::string &filename); ~BTagCalibration() {} std::string tagger() const {return tagger_;} void addEntry(const BTagEntry &entry); const std::vector<BTagEntry>& getEntries(const BTagEntry::Parameters &par) const; void readCSV(std::istream &s); void readCSV(const std::string &s); void makeCSV(std::ostream &s) const; std::string makeCSV() const; protected: static std::string token(const BTagEntry::Parameters &par); std::string tagger_; std::map<std::string, std::vector<BTagEntry> > data_; }; #endif // BTagCalibration_H #ifndef BTagCalibrationReader_H #define BTagCalibrationReader_H /** * BTagCalibrationReader * * Helper class to pull out a specific set of BTagEntry's out of a * BTagCalibration. TF1 functions are set up at initialization time. * ************************************************************/ #include <memory> #include <string> class BTagCalibrationReader { public: class BTagCalibrationReaderImpl; BTagCalibrationReader() {} BTagCalibrationReader(BTagEntry::OperatingPoint op, const std::string & sysType="central", const std::vector<std::string> & otherSysTypes={}); void load(const BTagCalibration & c, BTagEntry::JetFlavor jf, const std::string & measurementType="comb"); double eval(BTagEntry::JetFlavor jf, float eta, float pt, float discr=0.) const; /* double eval_auto_bounds(const std::string & sys, */ /* BTagEntry::JetFlavor jf, */ /* float eta, */ /* float pt, */ /* float discr=0.) const; */ double eval_auto_bounds(const std::string & sys, int hf, float eta, float pt, float discr=0.) const; std::pair<float, float> min_max_pt(BTagEntry::JetFlavor jf, float eta, float discr=0.) const; protected: std::shared_ptr<BTagCalibrationReaderImpl> pimpl; }; #endif // BTagCalibrationReader_H
[ "nicholas.james.manganelli@cern.ch" ]
nicholas.james.manganelli@cern.ch
1986cd30ea91e26d266b2d2ee8ddeb37a0f01446
2ba220de6f1279bb7e52234149aa9da13f796c09
/src/locations/location_visitor.hpp
9017c078c4263590c5dd090280b6f605e6d0e636
[]
no_license
marblefactory/Server
b19abfef8ecf179200996d13b393abf368723185
9d19db11e2ef8cb7727047a431ddfb1416eb50b1
refs/heads/master
2021-08-20T09:01:56.131969
2017-11-28T17:50:03
2017-11-28T17:50:03
112,361,812
0
0
null
null
null
null
UTF-8
C++
false
false
393
hpp
// // location_visitor.h // EngineCommandSet // // Created by Albie Baker-Smith on 14/11/2017. // Copyright © 2017 Albie Baker-Smith. All rights reserved. // #ifndef location_visitor_h #define location_visitor_h // Forward declarations. class AbsoluteLocation; class LocationVisitor { public: virtual void visit(AbsoluteLocation &location) = 0; }; #endif /* location_visitor_h */
[ "bakersmitha@gmail.com" ]
bakersmitha@gmail.com
317fc15d508e65a869e9a441faa798ab7ff67b8b
e4044fdb9b9785105f3413a0515c45d7a76cbfc1
/gerentebdd.h
3bfdaace05c249f8db31e402f8ad6450e3fe8f38
[]
no_license
esbrito/aig-eq-verifier
b8dd5d8919471dd912025ba0ced8c49c25a00771
8bc9b30c142551a2f24c5eb85a327f42deab882a
refs/heads/master
2021-05-16T14:46:05.737921
2018-01-25T17:51:27
2018-01-25T17:51:27
118,610,425
0
0
null
null
null
null
UTF-8
C++
false
false
2,138
h
//copyright Prof. Andre Reis - UFRGS #ifndef GERENTEBDD_H #define GERENTEBDD_H #include <iostream> #include <string> #include <map> #include <vector> #include <fstream> #include <sstream> #include <algorithm> #include <set> #include "aig.h" using namespace std; enum Token_value{AND='*', OR='+', LP='(', RP=')', NOT='!', LIT, END=';'}; class nodobdd{ nodobdd *f0; nodobdd *f1; int variavel; int idunico; public: nodobdd(int, nodobdd*, nodobdd*, int); void imprime(ostream& saida); friend class gerentebdd; friend class BooleanFunctionWrapper; }; class gerentebdd{ map<string, nodobdd*> tabelaunica; map<string, int> var_indices; vector <string> variaveis; nodobdd *t0; nodobdd *t1; int proximoIdNodo; int proximoIndiceVar; static Token_value curr_tok; static string string_value; nodobdd* prim(istringstream &equation, set<string> &variaveis); nodobdd* term (istringstream &equation, set<string> &variaveis); nodobdd* expr (istringstream &equation, set<string> &variaveis); Token_value get_token(istringstream &equation); public: gerentebdd(); string chaveunica(string v, nodobdd* n0, nodobdd* n1); nodobdd* novo_ou_velho(string s, nodobdd* n0, nodobdd* n1); nodobdd* novo_ou_velho(int i, nodobdd* n0, nodobdd* n1); nodobdd* cadastravariavel(string s); nodobdd* ite(nodobdd* se, nodobdd* entao, nodobdd* senao, int indice); nodobdd* and2(nodobdd* n1, nodobdd* n2); nodobdd* or2(nodobdd* n1, nodobdd* n2); nodobdd* nand2(nodobdd* n1, nodobdd* n2); nodobdd* nor2(nodobdd* n1, nodobdd* n2); nodobdd* exor2(nodobdd* n1, nodobdd* n2); nodobdd* inv(nodobdd* n1); nodobdd* cofactor(nodobdd* function, nodobdd* variable, char polarity); //nodobdd* createCube(Cube c, int n, vector<string> x17); int xstoresSerie(nodobdd*, int); nodobdd* create_from_equation(string equation, set<string> &variaveis); nodobdd* getConstantZero(); nodobdd* getConstantOne(); std::vector<string> create_equations_from_aig(Aig* aig); }; //copyright Prof. Andre Reis - UFRGS #endif
[ "eduardobrito14@gmail.com" ]
eduardobrito14@gmail.com
41731244e0e963dd024db7e53e1725ba85589a88
32cf94c304c2c832595a28b49c7d9e0361d50950
/test/dump/swdbgbk_src/chap25/PdbFairy/PdbMaster.cpp
2f3d3e0f6cb3c4259e33c3bfda90d62113aba8da
[ "MIT" ]
permissive
oudream/ccxx
11d3cd9c044c5f413ebc0735548f102a6f583114
26cecfb02e861ce6b821b33350493bac4793e997
refs/heads/master
2023-01-29T11:20:12.210439
2023-01-12T06:49:23
2023-01-12T06:49:23
47,005,127
46
11
MIT
2020-10-17T02:24:06
2015-11-28T01:05:30
C
UTF-8
C++
false
false
18,207
cpp
// PdbMaster.cpp: implementation of the CPdbMaster class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "PdbFairy.h" #include "PdbMaster.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CPdbMaster::CPdbMaster() { m_hFileHandle=INVALID_HANDLE_VALUE; m_nSignatureLength=0; m_pPdbHeader=NULL; m_nRootStreamOffset=0; } CPdbMaster::~CPdbMaster() { Cleanup(); } // ----------------------------------------------------------------- /*PPDB_HEADER PdbLoad (PWORD pwPath, PBOOL pfInvalid) { HANDLE hf; DWORD dData, dRead; PPDB_HEADER pph = NULL; *pfInvalid = FALSE; if ((hf = CreateFile (pwPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL)) != INVALID_HANDLE_VALUE) { dData = GetFileSize (hf, NULL); if ((dData != INVALID_FILE_SIZE) && dData && ((pph = malloc (dData)) != NULL)) { if ((!ReadFile (hf, pph, dData, &dRead, NULL)) || (dData != dRead) || (*pfInvalid = !PdbValid (pph, dData))) { free (pph); pph = NULL; } } CloseHandle (hf); } return pph; } // ----------------------------------------------------------------- BOOL PdbSave (PWORD pwTarget, PVOID pData, DWORD dData) { HANDLE hf; DWORD dWritten; BOOL fOk = FALSE; printf (L"\r\nSaving \"%s\"... ", pwTarget); if ((hf = CreateFile (pwTarget, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN | FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) { fOk = WriteFile (hf, pData, dData, &dWritten, NULL) && (dData == dWritten); CloseHandle (hf); } printf (fOk ? L"%lu bytes\r\n" : L"ERROR\r\n", dData); return fOk; } // ----------------------------------------------------------------- DWORD PdbLimit (PPDB_HEADER pph) { return ((DWORD) pph->wStartPage - 1) * pph->dPageSize * 8 * pph->dPageSize; } // ----------------------------------------------------------------- DWORD PdbPages (PPDB_HEADER pph, DWORD dBytes) { return (dBytes ? (((dBytes-1) / pph->dPageSize) + 1) : 0); } // ----------------------------------------------------------------- PVOID PdbRead (PPDB_HEADER pph, DWORD dBytes, PWORD pwPages) { DWORD i, j; DWORD dPages = PdbPages (pph, dBytes); PVOID pPages = malloc (dPages * pph->dPageSize); if (pPages != NULL) { for (i = 0; i < dPages; i++) { j = pwPages [i]; CopyMemory ((PBYTE) pPages + (i * pph->dPageSize), (PBYTE) pph + (j * pph->dPageSize), pph->dPageSize); } } return pPages; } // ----------------------------------------------------------------- PPDB_ROOT PdbRoot (PPDB_HEADER pph, PDWORD pdBytes) { DWORD dBytes, i, n; PPDB_ROOT ppr = NULL; if ((ppr = PdbRead (pph, PDB_ROOT_, pph->awRootPages)) != NULL) { dBytes = PDB_ROOT__ ((DWORD) ppr->wCount); free (ppr); if ((ppr = PdbRead (pph, dBytes, pph->awRootPages)) != NULL) { for (n = i = 0; i < (DWORD) ppr->wCount; i++) { n += PdbPages (pph, ppr->aStreams [i].dStreamSize); } dBytes += n * sizeof (WORD); free (ppr); ppr = PdbRead (pph, dBytes, pph->awRootPages); } } *pdBytes = (ppr != NULL ? dBytes : 0); return ppr; } // ----------------------------------------------------------------- PVOID PdbStream (PPDB_HEADER pph, PPDB_ROOT ppr, DWORD dStream, PDWORD pdBytes) { DWORD dBytes, i; PWORD pwPages; PVOID pPages = NULL; if (dStream < (DWORD) ppr->wCount) { pwPages = (PWORD) ((PBYTE) ppr + PDB_ROOT__ ((DWORD) ppr->wCount)); for (i = 0; i < dStream; i++) { pwPages += PdbPages (pph, ppr->aStreams [i].dStreamSize); } dBytes = ppr->aStreams [dStream].dStreamSize; pPages = PdbRead (pph, dBytes, pwPages); } *pdBytes = (pPages != NULL ? dBytes : 0); return pPages; } // ----------------------------------------------------------------- VOID PdbInfo (PWORD pwPath, PPDB_HEADER pph, PPDB_ROOT ppr) { DWORD dFileLimit, dFileBytes, dFilePages, dStreams; DWORD dDataBytes, dDataPages, dRootBytes, dRootPages, i, n; PWORD pwFile; WORD awPath [MAX_PATH]; dFileLimit = PdbLimit (pph); dFilePages = pph->wFilePages; dFileBytes = dFilePages * pph->dPageSize; dStreams = ppr->wCount; dDataBytes = 0; dDataPages = 0; for (i = 0; i < dStreams; i++) { dDataBytes += ppr->aStreams [i].dStreamSize ; dDataPages += PdbPages (pph, ppr->aStreams [i].dStreamSize); } dRootBytes = PDB_ROOT__(dStreams) + (dDataPages * sizeof(WORD)); dRootPages = PdbPages (pph, dRootBytes); n = GetFullPathName (pwPath, MAX_PATH, awPath, &pwFile); if ((!n) || (n >= MAX_PATH)) { lstrcpyn (awPath, pwPath, MAX_PATH); } printf (L"\r\n" L"Properties of \"%s\":\r\n" L"\r\n" L"%13lu byte%s maximum size\r\n" L"%13lu byte%s allocated\r\n" L"%13lu byte%s used by %lu data stream%s\r\n" L"%13lu byte%s used by the root stream\r\n" L"%13lu byte%s per page\r\n" L"%13lu page%s allocated\r\n" L"%13lu page%s used by %lu data stream%s\r\n" L"%13lu page%s used by the root stream\r\n", awPath, COUNT (dFileLimit, L" ", L"s"), COUNT (dFileBytes, L" ", L"s"), COUNT (dDataBytes, L" ", L"s"), COUNT (dStreams, L"", L"s"), COUNT (dRootBytes, L" ", L"s"), COUNT (pph->dPageSize, L" ", L"s"), COUNT (dFilePages, L" ", L"s"), COUNT (dDataPages, L" ", L"s"), COUNT (dStreams, L"", L"s"), COUNT (dRootPages, L" ", L"s")); return; } // ----------------------------------------------------------------- PWORD PdbTarget (PWORD pwPath, PWORD pwTarget, DWORD dOption) { DWORD i, n; BOOL fSeparator; WORD awExtension [] = L".9876543210"; PWORD pwExtension = NULL; PWORD pwBuffer = NULL; switch (dOption & DISPLAY_OPTION_FLAGS) { case DISPLAY_OPTION_HEADER: { pwExtension = L".header"; break; } case DISPLAY_OPTION_ALLOC: { pwExtension = L".alloc"; break; } case DISPLAY_OPTION_ROOT: { pwExtension = L".root"; break; } case DISPLAY_OPTION_DATA: { wsprintf (awExtension, L".%03lu", dOption & DISPLAY_OPTION_STREAM); pwExtension = awExtension; break; } } if (pwExtension != NULL) { i = lstrlen (pwPath); while (i && (pwPath [i-1] != '\\') && (pwPath [i-1] != ':' )) i--; n = lstrlen (pwTarget); if (fSeparator = (n && (pwTarget [n-1] != '\\') && (pwTarget [n-1] != ':' ))) n++; n += (lstrlen (pwPath+i) + lstrlen (pwExtension)); if ((pwBuffer = malloc ((n+1) * sizeof (WORD))) != NULL) { lstrcpy (pwBuffer, pwTarget); if (fSeparator) lstrcat (pwBuffer, L"\\"); lstrcat (pwBuffer, pwPath+i); lstrcat (pwBuffer, pwExtension); } } return pwBuffer; } // ----------------------------------------------------------------- VOID PdbOutput (PWORD pwPath, PWORD pwTarget, DWORD dOptions, PPDB_HEADER pph, PPDB_ROOT ppr, DWORD dRoot) { PWORD pwTarget1; PVOID pData; DWORD dData, dStream; if (dOptions & DISPLAY_OPTION_HEADER) { if ((pwTarget1 = PdbTarget (pwPath, pwTarget, DISPLAY_OPTION_HEADER)) != NULL) { PdbSave (pwTarget1, pph, pph->dPageSize); free (pwTarget1); } else { printf (L"\r\nUnable to save the header\r\n"); } } if (dOptions & DISPLAY_OPTION_ALLOC) { if ((pwTarget1 = PdbTarget (pwPath, pwTarget, DISPLAY_OPTION_ALLOC)) != NULL) { pData = (PBYTE) pph + pph->dPageSize; dData = ((DWORD) pph->wStartPage - 1) * pph->dPageSize; PdbSave (pwTarget1, pData, dData); free (pwTarget1); } else { printf (L"\r\nUnable to save the allocation bits\r\n"); } } if (dOptions & DISPLAY_OPTION_ROOT) { if ((pwTarget1 = PdbTarget (pwPath, pwTarget, DISPLAY_OPTION_ROOT)) != NULL) { PdbSave (pwTarget1, ppr, dRoot); free (pwTarget1); } else { printf (L"\r\nUnable to save the root stream\r\n"); } } if (dOptions & DISPLAY_OPTION_DATA) { for (dStream = 0; dStream < ppr->wCount; dStream++) { pwTarget1 = PdbTarget (pwPath, pwTarget, DISPLAY_OPTION_DATA | dStream); pData = PdbStream (pph, ppr, dStream, &dData); if ((pwTarget1 != NULL) && (pData != NULL)) { PdbSave (pwTarget1, pData, dData); } else { printf (L"\r\nUnable to save data stream #%lu\r\n", dStream); } free (pwTarget1); free (pData); } } return; } // ----------------------------------------------------------------- VOID PdbExplode (PWORD pwPath, PWORD pwTarget, DWORD dOptions) { PPDB_HEADER pph; PPDB_ROOT ppr; DWORD dRoot; BOOL fInvalid; if ((pph = PdbLoad (pwPath, &fInvalid)) != NULL) { if ((ppr = PdbRoot (pph, &dRoot)) != NULL) { PdbInfo (pwPath, pph, ppr); PdbOutput (pwPath, pwTarget, dOptions, pph, ppr, dRoot); free (ppr); } free (pph); } else { printf ((fInvalid ? L"\r\n\"%s\" is not a PDB file\r\n" : L"\r\nUnable to load \"%s\"\r\n"), pwPath); } return; } */ HRESULT CPdbMaster::Cleanup() { if(m_hFileHandle!=INVALID_HANDLE_VALUE) { CloseHandle(m_hFileHandle); m_hFileHandle=INVALID_HANDLE_VALUE; if(m_pPdbHeader) { delete m_pPdbHeader; m_pPdbHeader=NULL; } } return S_OK; } HRESULT CPdbMaster::ReadHeader() { DWORD dwRead=0; if(!IsLoaded() || this->m_nSignatureLength<=0) return E_FAIL; if(m_pPdbHeader==NULL) m_pPdbHeader=new PDB_HEADER70; SetFilePointer(m_hFileHandle,m_nSignatureLength, 0,FILE_BEGIN); if(this->m_nPdbVersion==200) { PDB_HEADER20 ph; if ((!ReadFile (m_hFileHandle, &ph, sizeof(PDB_HEADER20), &dwRead, NULL)) || (sizeof(PDB_HEADER20) != dwRead) ) return E_FAIL; m_pPdbHeader->dwFilePages=ph.wFilePages; m_pPdbHeader->dwPageSize=ph.dwPageSize; m_pPdbHeader->dwStartPage=ph.wStartPage; m_pPdbHeader->RootStream=ph.RootStream; } else { if ((!ReadFile (m_hFileHandle, m_pPdbHeader, sizeof(PDB_HEADER70), &dwRead, NULL)) || (sizeof(PDB_HEADER70) != dwRead) ) return E_FAIL; } return S_OK; } HRESULT CPdbMaster::Load(LPCTSTR lpszFullFileName) { if(IsLoaded()) return E_FAIL; this->m_hFileHandle = CreateFile (lpszFullFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if(m_hFileHandle == INVALID_HANDLE_VALUE) return E_FAIL; return S_OK; } BOOL CPdbMaster::IsPdb(char *szSignature) { return ( !strcmp (szSignature, PDB_SIGNATURE_200) || !strcmp (szSignature, PDB_SIGNATURE_700) ); } HRESULT CPdbMaster::DumpHeader(HWND hWndListBox) { TCHAR szMsg[MAX_PATH]; if(this->m_nSignatureLength<=0) DumpSignature(hWndListBox); if(m_pPdbHeader==NULL && ReadHeader()!=S_OK) return E_FAIL; _stprintf(szMsg, _T("PageSize: 0x%x [%d]"), m_pPdbHeader->dwPageSize,m_pPdbHeader->dwPageSize); SendMessage(hWndListBox, LB_ADDSTRING,0,(LPARAM)szMsg); _stprintf(szMsg, _T("File Pages: 0x%x [%d]"), m_pPdbHeader->dwFilePages,m_pPdbHeader->dwFilePages); SendMessage(hWndListBox, LB_ADDSTRING,0,(LPARAM)szMsg); _stprintf(szMsg, _T("Start Page: 0x%x [%d]"), m_pPdbHeader->dwStartPage,m_pPdbHeader->dwStartPage); SendMessage(hWndListBox, LB_ADDSTRING,0,(LPARAM)szMsg); _stprintf(szMsg, _T("Root Stream Size: 0x%x [%d]"), m_pPdbHeader->RootStream.dwStreamSize,m_pPdbHeader->RootStream.dwStreamSize); SendMessage(hWndListBox, LB_ADDSTRING,0,(LPARAM)szMsg); _stprintf(szMsg, _T("Root Stream Pages Pointer: 0x%x [%d]"), m_pPdbHeader->RootStream.pwStreamPages,m_pPdbHeader->RootStream.pwStreamPages); SendMessage(hWndListBox, LB_ADDSTRING,0,(LPARAM)szMsg); return S_OK; } HRESULT CPdbMaster::DumpSignature(HWND hWndList) { DWORD dwRead=0; char szSignature[MAX_PATH],*lpsz; TCHAR szMsg[MAX_PATH]; SetFilePointer(m_hFileHandle,0,0,FILE_BEGIN); if ((!ReadFile (m_hFileHandle, szSignature, sizeof(szSignature), &dwRead, NULL)) ) return E_FAIL; szSignature[MAX_PATH-1]=0; #ifdef _UNICODE _stprintf(szMsg, _T("Signature: %S"),szSignature); #else _stprintf(szMsg, _T("Signature: %s"),szSignature); #endif // _UNICODE SendMessage(hWndList, LB_ADDSTRING,0,(LPARAM)szMsg); lpsz=strchr(szSignature,'\x1a'); if(lpsz==NULL) return E_FAIL; *(++lpsz)=0; if(stricmp(szSignature, PDB_SIGNATURE_200)==0) m_nPdbVersion=200; else if(stricmp(szSignature, PDB_SIGNATURE_700)==0) m_nPdbVersion=700; else return E_FAIL; m_nSignatureLength=lpsz-szSignature; // skip the magic signature m_nSignatureLength+=4; // align by dword if(m_nSignatureLength%4) m_nSignatureLength+=4-m_nSignatureLength%4; return S_OK; } HRESULT CPdbMaster::DumpStreamDirectory(HWND hWndList) { int nPages=0,i; WORD * pWord=NULL; TCHAR szMsg[MAX_PATH]; DWORD dwRead=0,dwOffset,*pDWord,dwPageNo4RSPA; // page no to store the page no array of root page stream if(this->m_pPdbHeader==NULL && S_OK!=DumpHeader(hWndList) ) return E_FAIL; nPages=m_pPdbHeader->RootStream.dwStreamSize /m_pPdbHeader->dwPageSize; if(m_pPdbHeader->RootStream.dwStreamSize %m_pPdbHeader->dwPageSize) nPages++; dwOffset=m_nSignatureLength; dwOffset+=this->m_nPdbVersion==200?sizeof(PDB_HEADER20): sizeof(PDB_HEADER70); SetFilePointer(m_hFileHandle, dwOffset, 0,FILE_BEGIN); if(this->m_nPdbVersion==200) { pWord=new WORD[nPages]; if(!ReadFile(m_hFileHandle,pWord,nPages*sizeof(WORD),&dwRead,NULL) && dwRead!=nPages*sizeof(WORD)) return E_FAIL; for(i=0;i<nPages;i++) { dwOffset=*(pWord+i); if(i==0) m_nRootStreamOffset=dwOffset*m_pPdbHeader->dwPageSize; _stprintf(szMsg, _T("Root Page [%d]: no = 0x%x, byte offset = 0x%x"), i, dwOffset, dwOffset*m_pPdbHeader->dwPageSize); SendMessage(hWndList, LB_ADDSTRING,0,(LPARAM)szMsg); } delete pWord; } else { // read a dword if(!ReadFile(m_hFileHandle,&dwPageNo4RSPA,sizeof(DWORD),&dwRead,NULL) && dwRead!=sizeof(DWORD)) return E_FAIL; dwOffset=dwPageNo4RSPA*m_pPdbHeader->dwPageSize; SetFilePointer(m_hFileHandle, dwOffset, 0,FILE_BEGIN); pDWord=new DWORD[nPages]; if(!ReadFile(m_hFileHandle,pDWord,nPages*sizeof(DWORD),&dwRead,NULL) && dwRead!=nPages*sizeof(DWORD)) return E_FAIL; for(i=0;i<nPages;i++) { dwOffset=*(pDWord+i); if(i==0) m_nRootStreamOffset=dwOffset*m_pPdbHeader->dwPageSize; _stprintf(szMsg, _T("Root Page [%d]: no = 0x%x, byte offset = 0x%x"), i, dwOffset, dwOffset*m_pPdbHeader->dwPageSize); SendMessage(hWndList, LB_ADDSTRING,0,(LPARAM)szMsg); } delete pDWord; } return S_OK; } HRESULT CPdbMaster::DumpStreams(HWND hWndList) { PDB_ROOT root; DWORD dwRead=0,i; TCHAR szMsg[MAX_PATH]; PDB_STREAM stream; if(m_nRootStreamOffset<=0) DumpStreamDirectory(hWndList); SetFilePointer(m_hFileHandle, m_nRootStreamOffset, 0,FILE_BEGIN); if(!ReadFile(m_hFileHandle,&root,sizeof(PDB_ROOT),&dwRead,NULL) && dwRead!=sizeof(PDB_ROOT)) return E_FAIL; _stprintf(szMsg, _T("Total streams: [%d]"), root.wCount); SendMessage(hWndList, LB_ADDSTRING,0,(LPARAM)szMsg); for(i=0;i<root.wCount;i++) { if(!ReadFile(m_hFileHandle,&stream,sizeof(PDB_STREAM),&dwRead,NULL) && dwRead!=sizeof(PDB_STREAM)) break; _stprintf(szMsg, _T("Stream[%d], size=%d, pages=0x%x"), i,stream.dwStreamSize,stream.pwStreamPages); SendMessage(hWndList, LB_ADDSTRING,0,(LPARAM)szMsg); } return S_OK; }
[ "oudream@126.com" ]
oudream@126.com
32af074297dde14d1214ff102d6fdc6c751a987c
6920669973a1731f3c6bc33b3789095d6fb9c2c0
/101/SymmetricTree.cpp
946d010fb6781874200f92cfd9d3ac2c05052f60
[ "Apache-2.0" ]
permissive
misslzyan/leetcode
47c56a95b30ce2c5c5fdeabb5ec9c635cc9b30be
4ab3e3c8abb35bb9c31c2fd18e81e11ea69ff200
refs/heads/master
2022-12-13T03:52:35.733695
2020-08-24T04:32:14
2020-08-24T04:32:14
285,872,095
0
0
null
null
null
null
UTF-8
C++
false
false
871
cpp
#include<iostream> struct TreeNode { int val; TreeNode* left; TreeNode* right; TreeNode(int x):val(x),left(nullptr), right(nullptr){} }; class Solution { public: bool isSymmitric(TreeNode* root) { return check(root, root); } bool check(TreeNode* r1, TreeNode* r2) { if (!r1 && !r2) return true; if (!r1 || !r2) return false; return (r1 -> val == r2 -> val) && check(r1 -> left, r2 -> right) && check(r1 -> right, r2 -> left); } }; int main() { //[1,2,2,3,4,4,3] TreeNode* root = new TreeNode(1); root -> left = new TreeNode(2); root -> right = new TreeNode(2); root -> left -> left = new TreeNode(3); root -> left -> right = new TreeNode(4); root -> right -> left = new TreeNode(4); root -> right -> right = new TreeNode(3); Solution s; bool r = s.isSymmitric(root); std::cout << std::boolalpha << r << std::endl; }
[ "misslzyan108@gmail.com" ]
misslzyan108@gmail.com
a6217bee854ceaceb798404271dad7dfa6029e55
3d3650565a480d91f47e7ba8a1feb5c1d612b10a
/src/172_fractorial_trailing_zeros.cpp
d538b3a4c935366fdd0baa217b7e797baf806a6f
[]
no_license
Yu-ChenChang/LeetCode
e15c399f0c42a52bdeaa648e88000ff9a01ced7f
690753040d5ae3e6e4433e0b90f78bb9ae38f15d
refs/heads/master
2020-04-06T05:11:40.061743
2016-10-02T18:25:02
2016-10-02T18:25:02
52,691,044
0
0
null
null
null
null
UTF-8
C++
false
false
278
cpp
#include<vector> #include<string> #include<iostream> using namespace::std; class Solution { public: int trailingZeroes(int n) { int res=0; int five = 5; while(n>=five){ res += n/five; if(five>INT_MAX/5) break; five *= 5; } return res; } }; int main(){ }
[ "chang397@purdue.edu" ]
chang397@purdue.edu
d623ade0444bac0f1903babe15f74913f61685f0
8c8b6ca7c2b78d8baa65bf34888343ffbe2ebc06
/hostrpc/run_on_hsa.hpp
98678ededd78b4df1c6898747bb0419183f18b2a
[ "MIT" ]
permissive
powderluv/hostrpc
2184879b2d843563017545bf77031097f616fba5
d2fa4127133cae8c23d8a691a0d23bb0ba1aa126
refs/heads/master
2023-04-02T00:25:01.815059
2021-04-12T01:40:29
2021-04-12T01:40:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,901
hpp
#ifndef RUN_ON_HSA_HPP_INCLUDED #define RUN_ON_HSA_HPP_INCLUDED // Call a function with a given name and type: // void known_function_name(void*); // from: // kernel void kernel_known_function_name(__global void *){} // provided that source containing 'HOSTRPC_ENTRY_POINT(foo)' // is compiled as opencl and as c++, which are then linked // Call extern "C" void NAME(TYPE*); defined in amdgcn source from the host // as extern "C" void NAME(hsa_executable_t, TYPE*) // from an instantiation of HOSTRPC_ENTRY_POINT(NAME, TYPE) compiled as // amdgcn ocl/cxx and on the host #include "detail/platform_detect.hpp" #define HOSTRPC_ENTRY_POINT(NAME, TYPE) \ /* void NAME(TYPE*); */ \ HOSTRPC_OPENCL_PART(NAME, TYPE) \ HOSTRPC_CXX_GCN_PART(NAME, TYPE) \ HOSTRPC_CXX_X64_PART(NAME, TYPE) #define HOSTRPC_CAT(X, Y) X##Y #if HOSTRPC_HOST #include "hsa.h" #include "hsa.hpp" #include <stddef.h> #define bang() (bang)(rc, __LINE__) static void(bang)(hsa_status_t rc, unsigned line) { if (rc != HSA_STATUS_SUCCESS) { printf("Fail at line %u, rc %s\n", line, hsa::status_string(rc)); } } namespace hostrpc { // will call name on every agent in ex for which get_symbol_by_name succeeds void run_on_hsa(hsa_executable_t ex, void *arg, size_t len, const char *name); template <typename T> void run_on_hsa_typed(hsa_executable_t ex, T *arg, const char *name) { run_on_hsa(ex, (void *)arg, sizeof(T), name); } } // namespace hostrpc #define HOSTRPC_OPENCL_PART(NAME, TYPE) #define HOSTRPC_CXX_GCN_PART(NAME, TYPE) #define HOSTRPC_CXX_X64_PART(NAME, TYPE) \ extern "C" void NAME(hsa_executable_t ex, TYPE *arg) \ { \ hostrpc::run_on_hsa_typed<TYPE>(ex, arg, "kernel_" #NAME ".kd"); \ } #else #if defined(__OPENCL_C_VERSION__) #define HOSTRPC_OPENCL_PART(NAME, TYPE) \ void HOSTRPC_CAT(cast_, NAME)(__global TYPE *); \ kernel void HOSTRPC_CAT(kernel_, NAME)(__global TYPE * arg) \ { \ HOSTRPC_CAT(cast_, NAME)(arg); \ } #define HOSTRPC_CXX_GCN_PART(NAME, TYPE) #define HOSTRPC_CXX_X64_PART(NAME, TYPE) #else #define HOSTRPC_OPENCL_PART(NAME, TYPE) #define HOSTRPC_CXX_GCN_PART(NAME, TYPE) \ extern "C" void NAME(TYPE *); \ extern "C" void HOSTRPC_CAT( \ cast_, NAME)(__attribute__((address_space(1))) TYPE * asargs) \ { \ TYPE *args = (TYPE *)asargs; \ NAME(args); \ } #define HOSTRPC_CXX_X64_PART(NAME, TYPE) #endif #endif #endif
[ "jonathanchesterfield@gmail.com" ]
jonathanchesterfield@gmail.com
3dc9325c7747c1c698cc7952ad3e0c77df195e84
36184239a2d964ed5f587ad8e83f66355edb17aa
/.history/hw3/ElectoralMap_20211022000959.h
da6901ec51f98ce332d87131f516f14ee629ed8d
[]
no_license
xich4932/csci3010
89c342dc445f5ec15ac7885cd7b7c26a225dae3e
23f0124a99c4e8e44a28ff31ededc42d9f326ccc
refs/heads/master
2023-08-24T04:03:12.748713
2021-10-22T08:22:58
2021-10-22T08:22:58
415,140,207
0
0
null
null
null
null
UTF-8
C++
false
false
3,899
h
#ifndef __ELECTORALMAP__ #define __ELECTORALMAP__ //#include"District.h" #include<iostream> #include<map> #include<vector> enum party{one, two, three, none}; class District{ public: District(); District(int); void change_party(party,party, int); //void get_constituent(party); double get_square_mile(){return square_mile;}; int get_id() const {return id;}; int get_constituent(party party_name){return map_party[party_name];}; void convert_constituent(party, party, int); party get_max(); int get_sum_constitutent(); party get_max_party(); int get_sum_constitutent_exclude_none(party); friend std::ostream & operator<<(std::ostream& os, District print_district); /* bool operator <(const District& less)const{ if(this->id < less.get_id()) return true; return false; }; bool operator >(const District& less)const{ if(this->id > less.get_id()) return true; return false; }; bool operator ==(const District& less)const{ if(this->id == less.get_id()) return true; return false; }; */ private: double square_mile; std::map<party, int> map_party; int id; }; class Candidate{ public: Candidate(); Candidate(int, party, std::string); int get_ids(); std::string get_name(){return name;}; int get_vote(int dis){return votes[dis];}; party get_party(){return party_affiliation;}; void plus_vote(const int, int); std::map<int,int> get_all_votes() {return votes;} static int party_one_candidate; static int party_two_candidate; static int party_three_candidate; int get_total_vote(){return total_vote;}; // static int party_none; void print_vote(); //debug public: int id_candidate; party party_affiliation; std::string name; std::map<int ,int> votes; int total_vote; }; class Election{ public: Election(); // void register_candidate(party, std::string); bool check_win(); void report_win(); void voting(); void register_candidate(party, std::string); Candidate* who_campaigning(); int where_campaigning(); bool check_end(); //void call_votes(); //void voting(); //void report_win(); //Candidate get_candidat_by_id(int id){ return candidate_[id];}; void print_each_Vote(); virtual void test(){std::cout <<"from base"<<std::endl;}; void converting(District*, Candidate* ); Candidate* get_candidate(int ); // std::vector<Candidate> get_all_candidate(); static int ids; static std::vector<int> party_one_active; static std::vector<int> party_two_active; static std::vector<int> party_three_active; static std::vector<int> party_none; static int active_party[3]; private: std::map<int, Candidate*> candidate_; // std::map<party, int> count_votes; }; class RepresentativeELection : public Election{ public: RepresentativeELection(); void calculate_vote(); void voting(); void test(){std::cout <<"from derivative"<<std::endl;}; void report_win(); private: std::vector<int> vote_per_district; std::map<int, Candidate*> candidate_ ; }; class ElectoralMap{ public: static ElectoralMap& getInstance(){ static ElectoralMap instance; return instance; } //static District* getDistrict(int); friend std::ostream & operator<<(std::ostream& os, ElectoralMap map); static int count_district; std::map<int, District*> get_map(){return map;}; private: ElectoralMap(); std::map<int, District*> map; }; #endif
[ "70279863+xich4932@users.noreply.github.com" ]
70279863+xich4932@users.noreply.github.com
99b9b5b56a650644df32f65e654b563692404a80
a15950e54e6775e6f7f7004bb90a5585405eade7
/extensions/shell/browser/shell_app_delegate.cc
0023132d3786dbce980d730a6b6033583908f92b
[ "BSD-3-Clause" ]
permissive
whycoding126/chromium
19f6b44d0ec3e4f1b5ef61cc083cae587de3df73
9191e417b00328d59a7060fa6bbef061a3fe4ce4
refs/heads/master
2023-02-26T22:57:28.582142
2018-04-09T11:12:57
2018-04-09T11:12:57
128,760,157
1
0
null
2018-04-09T11:17:03
2018-04-09T11:17:03
null
UTF-8
C++
false
false
3,454
cc
// Copyright 2014 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 "extensions/shell/browser/shell_app_delegate.h" #include "content/public/browser/web_contents.h" #include "extensions/common/constants.h" #include "extensions/shell/browser/media_capture_util.h" #include "extensions/shell/browser/shell_extension_web_contents_observer.h" namespace extensions { ShellAppDelegate::ShellAppDelegate() { } ShellAppDelegate::~ShellAppDelegate() { } void ShellAppDelegate::InitWebContents(content::WebContents* web_contents) { ShellExtensionWebContentsObserver::CreateForWebContents(web_contents); } void ShellAppDelegate::RenderViewCreated( content::RenderViewHost* render_view_host) { // The views implementation of AppWindow takes focus via SetInitialFocus() // and views::WebView but app_shell is aura-only and must do it manually. content::WebContents::FromRenderViewHost(render_view_host)->Focus(); } void ShellAppDelegate::ResizeWebContents(content::WebContents* web_contents, const gfx::Size& size) { NOTIMPLEMENTED(); } content::WebContents* ShellAppDelegate::OpenURLFromTab( content::BrowserContext* context, content::WebContents* source, const content::OpenURLParams& params) { NOTIMPLEMENTED(); return NULL; } void ShellAppDelegate::AddNewContents(content::BrowserContext* context, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_rect, bool user_gesture) { NOTIMPLEMENTED(); } content::ColorChooser* ShellAppDelegate::ShowColorChooser( content::WebContents* web_contents, SkColor initial_color) { NOTIMPLEMENTED(); return NULL; } void ShellAppDelegate::RunFileChooser( content::RenderFrameHost* render_frame_host, const content::FileChooserParams& params) { NOTIMPLEMENTED(); } void ShellAppDelegate::RequestMediaAccessPermission( content::WebContents* web_contents, const content::MediaStreamRequest& request, const content::MediaResponseCallback& callback, const extensions::Extension* extension) { media_capture_util::GrantMediaStreamRequest( web_contents, request, callback, extension); } bool ShellAppDelegate::CheckMediaAccessPermission( content::RenderFrameHost* render_frame_host, const GURL& security_origin, content::MediaStreamType type, const Extension* extension) { media_capture_util::VerifyMediaAccessPermission(type, extension); return true; } int ShellAppDelegate::PreferredIconSize() const { return extension_misc::EXTENSION_ICON_SMALL; } void ShellAppDelegate::SetWebContentsBlocked( content::WebContents* web_contents, bool blocked) { NOTIMPLEMENTED(); } bool ShellAppDelegate::IsWebContentsVisible( content::WebContents* web_contents) { return true; } void ShellAppDelegate::SetTerminatingCallback(const base::Closure& callback) { // TODO(jamescook): Should app_shell continue to close the app window // manually or should it use a browser termination callback like Chrome? } bool ShellAppDelegate::TakeFocus(content::WebContents* web_contents, bool reverse) { return false; } } // namespace extensions
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
0f96b7b7186c2807bc91d6186252ecf491655ceb
7468375a3a21d7fdb7890d933b600d703d1cf6df
/source/file/min/serial.cpp
476d47c93ce2e1442883d019914c5c1895f5be2d
[ "Apache-2.0" ]
permissive
ocket8888/mgl
71fb815397a1897356538c33eec231036a787397
151f5d9ea54c8389f2a608435ae28bc456488201
refs/heads/master
2020-03-21T05:40:28.108039
2018-10-04T15:43:50
2018-10-04T15:43:50
138,172,766
0
0
null
2018-06-21T13:17:43
2018-06-21T13:17:42
null
UTF-8
C++
false
false
17,203
cpp
#include "serial.h" template unsigned int min::read_le(const std::vector<uint8_t>&, size_t&); template int min::read_le(const std::vector<uint8_t>&, size_t&); template unsigned short min::read_le(const std::vector<uint8_t>&, size_t&); template char min::read_le(const std::vector<uint8_t>&, size_t&); template <typename T> T min::read_le(const std::vector<uint8_t> &stream, size_t &next) { // Check type is compatible static_assert(sizeof(long long) >= sizeof(T), "Invalid type size, sizeof(T) <= sizeof(long long)"); // Size of T in bytes const size_t size = sizeof(T); long long temp = 0; uint8_t shift = 0; for (size_t i = 0; i < size; i++) { // Unpack little endian stream temp |= ((long long)stream[next + i] << shift); shift += 8; } // Change next position next += size; // Avoiding strict aliasing rules of C/C++ const T *out = reinterpret_cast<T *>(&temp); return *out; } template <typename T> T min::read_be(const std::vector<uint8_t> &stream, size_t &next) { // Check type is compatible static_assert(sizeof(long long) >= sizeof(T), "Invalid type size, sizeof(T) <= sizeof(long long)"); // Size of T in bytes const size_t size = sizeof(T); long long temp = 0; uint8_t shift = (sizeof(T) - 1) * 8; for (size_t i = 0; i < size; i++) { // Unpack big endian stream temp |= ((long long)stream[next + i] << shift); shift -= 8; } // Change next position next += size; // Avoiding strict aliasing rules of C/C++ const T *out = reinterpret_cast<T *>(&temp); return *out; } template void min::write_le(std::vector<uint8_t>&, const char); template void min::write_le(std::vector<uint8_t>&, const unsigned int); template void min::write_le(std::vector<uint8_t>&, const int); template <typename T> void min::write_le(std::vector<uint8_t> &stream, const T data) { // Pointer to data uint8_t *const ptr = (uint8_t *)&data; // Size of T in bytes const size_t size = sizeof(T); for (size_t i = 0; i < size; i++) { // Pack little endian stream stream.push_back(ptr[i]); } } template void min::write_be(std::vector<uint8_t>&, const int); template void min::write_be(std::vector<uint8_t>&, const unsigned int); template void min::write_be(std::vector<uint8_t>&, const char); template void min::write_be(std::vector<uint8_t>&, const unsigned short); template <typename T> void min::write_be(std::vector<uint8_t> &stream, const T data) { // Pointer to data uint8_t *const ptr = (uint8_t *)&data; // Size of T in bytes const size_t size = sizeof(T); const size_t offset = size - 1; for (size_t i = 0; i < size; i++) { // Pack big endian stream stream.push_back(ptr[offset - i]); } } template void min::write_le(std::vector<uint8_t>&, const unsigned int, const size_t); template <typename T> void min::write_le(std::vector<uint8_t> &stream, const T data, const size_t offset) { // Pointer to data uint8_t *const ptr = (uint8_t *)&data; // Size of T in bytes const size_t size = sizeof(T); for (size_t i = 0; i < size; i++) { // Pack little endian stream stream[offset + i] = ptr[i]; } } template <typename T> void min::write_be(std::vector<uint8_t> &stream, const T data, const size_t offset) { // Pointer to data uint8_t *const ptr = (uint8_t *)&data; // Size of T in bytes const size_t size = sizeof(T); const size_t be_offset = size - 1; for (size_t i = 0; i < size; i++) { // Pack big endian stream stream[offset + i] = ptr[be_offset - i]; } } template std::vector<unsigned short> min::read_le_vector(const std::vector<uint8_t>&, size_t&); template std::vector<unsigned int> min::read_le_vector(const std::vector<uint8_t>&, size_t&); template <typename T> std::vector<T> min::read_le_vector(const std::vector<uint8_t> &stream, size_t &next) { const uint32_t size = read_le<uint32_t>(stream, next); // Create output vector and reserve memory std::vector<T> out; out.reserve(size); // Check that the stream has enough data const size_t ssize = stream.size(); if ((next + sizeof(T) * size) > ssize) { throw std::runtime_error("read_le_vector: ran out of data in stream"); } // Read all vector elements for (uint32_t i = 0; i < size; i++) { const T data = read_le<T>(stream, next); out.push_back(data); } return out; } template <typename T> std::vector<T> min::read_be_vector(const std::vector<uint8_t> &stream, size_t &next) { const uint32_t size = read_be<uint32_t>(stream, next); // Create output vector and reserve memory std::vector<T> out; out.reserve(size); // Check that the stream has enough data const size_t ssize = stream.size(); if ((next + sizeof(T) * size) > ssize) { throw std::runtime_error("read_be_vector: ran out of data in stream"); } // Read all vector elements for (uint32_t i = 0; i < size; i++) { const T data = read_be<T>(stream, next); out.push_back(data); } return out; } template void min::write_le_vector(std::vector<uint8_t>&, const std::vector<unsigned short>&); template void min::write_le_vector(std::vector<uint8_t>&, const std::vector<unsigned int>&); template <typename T> void min::write_le_vector(std::vector<uint8_t> &stream, const std::vector<T> &data) { // Get data size, must be less than 2^32-1 const uint32_t size = data.size(); // Write vector size to stream, zero vector is allowed write_le<uint32_t>(stream, size); // Write each data element for (uint32_t i = 0; i < size; i++) { write_le<T>(stream, data[i]); } } template <typename T> void min::write_be_vector(std::vector<uint8_t> &stream, const std::vector<T> &data) { // Get data size, must be less than 2^32-1 const uint32_t size = data.size(); // Write vector size to stream, zero vector is allowed write_be<uint32_t>(stream, size); // Write each data element for (uint32_t i = 0; i < size; i++) { write_be<T>(stream, data[i]); } } template <typename T> min::vec2<T> min::read_le_vec2(const std::vector<uint8_t> &stream, size_t &next) { const T x = read_le<T>(stream, next); const T y = read_le<T>(stream, next); return min::vec2<T>(x, y); } template <typename T> min::vec2<T> min::read_be_vec2(const std::vector<uint8_t> &stream, size_t &next) { const T x = read_be<T>(stream, next); const T y = read_be<T>(stream, next); return min::vec2<T>(x, y); } template <typename T> min::vec3<T> min::read_le_vec3(const std::vector<uint8_t> &stream, size_t &next) { const T x = read_le<T>(stream, next); const T y = read_le<T>(stream, next); const T z = read_le<T>(stream, next); return min::vec3<T>(x, y, z); } template <typename T> min::vec3<T> min::read_be_vec3(const std::vector<uint8_t> &stream, size_t &next) { const T x = read_be<T>(stream, next); const T y = read_be<T>(stream, next); const T z = read_be<T>(stream, next); return min::vec3<T>(x, y, z); } template <typename T> min::vec4<T> min::read_le_vec4(const std::vector<uint8_t> &stream, size_t &next) { const T x = read_le<T>(stream, next); const T y = read_le<T>(stream, next); const T z = read_le<T>(stream, next); const T w = read_le<T>(stream, next); return min::vec4<T>(x, y, z, w); } template <typename T> min::vec4<T> min::read_be_vec4(const std::vector<uint8_t> &stream, size_t &next) { const T x = read_be<T>(stream, next); const T y = read_be<T>(stream, next); const T z = read_be<T>(stream, next); const T w = read_be<T>(stream, next); return min::vec4<T>(x, y, z, w); } template <typename T> void min::write_le_vec2(std::vector<uint8_t> &stream, const min::vec2<T> &v) { write_le<T>(stream, v.x); write_le<T>(stream, v.y); } template <typename T> void min::write_be_vec2(std::vector<uint8_t> &stream, const min::vec2<T> &v) { write_be<T>(stream, v.x); write_be<T>(stream, v.y); } template <typename T> void min::write_le_vec3(std::vector<uint8_t> &stream, const min::vec3<T> &v) { write_le<T>(stream, v.x); write_le<T>(stream, v.y); write_le<T>(stream, v.z); } template <typename T> void min::write_be_vec3(std::vector<uint8_t> &stream, const min::vec3<T> &v) { write_be<T>(stream, v.x); write_be<T>(stream, v.y); write_be<T>(stream, v.z); } template <typename T> void min::write_le_vec4(std::vector<uint8_t> &stream, const min::vec4<T> &v) { write_le<T>(stream, v.x()); write_le<T>(stream, v.y()); write_le<T>(stream, v.z()); write_le<T>(stream, v.w()); } template <typename T> void min::write_be_vec4(std::vector<uint8_t> &stream, const min::vec4<T> &v) { write_be<T>(stream, v.x()); write_be<T>(stream, v.y()); write_be<T>(stream, v.z()); write_be<T>(stream, v.w()); } template std::vector<min::vec2<float>> min::read_le_vector_vec2(const std::vector<uint8_t>&, size_t&); template std::vector<min::vec2<double>> min::read_le_vector_vec2(const std::vector<uint8_t>&, size_t&); template <typename T> std::vector<min::vec2<T>> min::read_le_vector_vec2(const std::vector<uint8_t> &stream, size_t &next) { const uint32_t size = read_le<uint32_t>(stream, next); // Create output vector and reserve memory std::vector<min::vec2<T>> out; out.reserve(size); // Check that the stream has enough data const size_t ssize = stream.size(); if ((next + sizeof(min::vec2<T>) * size) > ssize) { throw std::runtime_error("read_le_vector_vec2: ran out of data in stream"); } // Read all vector elements for (uint32_t i = 0; i < size; i++) { const min::vec2<T> data = read_le_vec2<T>(stream, next); out.push_back(data); } return out; } template <typename T> std::vector<min::vec2<T>> min::read_be_vector_vec2(const std::vector<uint8_t> &stream, size_t &next) { const uint32_t size = read_be<uint32_t>(stream, next); // Create output vector and reserve memory std::vector<min::vec2<T>> out; out.reserve(size); // Check that the stream has enough data const size_t ssize = stream.size(); if ((next + sizeof(min::vec2<T>) * size) > ssize) { throw std::runtime_error("read_be_vector_vec2: ran out of data in stream"); } // Read all vector elements for (uint32_t i = 0; i < size; i++) { const min::vec2<T> data = read_be_vec2<T>(stream, next); out.push_back(data); } return out; } template std::vector<min::vec3<float>> min::read_le_vector_vec3(const std::vector<uint8_t>&, size_t&); template std::vector<min::vec3<double>> min::read_le_vector_vec3(const std::vector<uint8_t>&, size_t&); template <typename T> std::vector<min::vec3<T>> min::read_le_vector_vec3(const std::vector<uint8_t> &stream, size_t &next) { const uint32_t size = read_le<uint32_t>(stream, next); // Create output vector and reserve memory std::vector<min::vec3<T>> out; out.reserve(size); // Check that the stream has enough data const size_t ssize = stream.size(); if ((next + sizeof(min::vec3<T>) * size) > ssize) { throw std::runtime_error("read_le_vector_vec3: ran out of data in stream"); } // Read all vector elements for (uint32_t i = 0; i < size; i++) { const min::vec3<T> data = read_le_vec3<T>(stream, next); out.push_back(data); } return out; } template <typename T> std::vector<min::vec3<T>> min::read_be_vector_vec3(const std::vector<uint8_t> &stream, size_t &next) { const uint32_t size = read_be<uint32_t>(stream, next); // Create output vector and reserve memory std::vector<min::vec3<T>> out; out.reserve(size); // Check that the stream has enough data const size_t ssize = stream.size(); if ((next + sizeof(min::vec3<T>) * size) > ssize) { throw std::runtime_error("read_be_vector_vec3: ran out of data in stream"); } // Read all vector elements for (uint32_t i = 0; i < size; i++) { const min::vec3<T> data = read_be_vec3<T>(stream, next); out.push_back(data); } return out; } template std::vector<min::vec4<float>> min::read_le_vector_vec4(const std::vector<uint8_t>&, size_t&); template std::vector<min::vec4<double>> min::read_le_vector_vec4(const std::vector<uint8_t>&, size_t&); template <typename T> std::vector<min::vec4<T>> min::read_le_vector_vec4(const std::vector<uint8_t> &stream, size_t &next) { const uint32_t size = read_le<uint32_t>(stream, next); // Create output vector and reserve memory std::vector<min::vec4<T>> out; out.reserve(size); // Check that the stream has enough data const size_t ssize = stream.size(); if ((next + sizeof(min::vec4<T>) * size) > ssize) { throw std::runtime_error("read_le_vector_vec4: ran out of data in stream"); } // Read all vector elements for (uint32_t i = 0; i < size; i++) { const min::vec4<T> data = read_le_vec4<T>(stream, next); out.push_back(data); } return out; } template <typename T> std::vector<min::vec4<T>> min::read_be_vector_vec4(const std::vector<uint8_t> &stream, size_t &next) { const uint32_t size = read_be<uint32_t>(stream, next); // Create output vector and reserve memory std::vector<min::vec4<T>> out; out.reserve(size); // Check that the stream has enough data const size_t ssize = stream.size(); if ((next + sizeof(min::vec4<T>) * size) > ssize) { throw std::runtime_error("read_be_vector_vec4: ran out of data in stream"); } // Read all vector elements for (uint32_t i = 0; i < size; i++) { const min::vec4<T> data = read_be_vec4<T>(stream, next); out.push_back(data); } return out; } template void min::write_le_vector_vec2(std::vector<uint8_t>&, const std::vector<min::vec2<double>>&); template void min::write_le_vector_vec2(std::vector<uint8_t>&, const std::vector<min::vec2<float>>&); template <typename T> void min::write_le_vector_vec2(std::vector<uint8_t> &stream, const std::vector<vec2<T>> &data) { // Get data size, must be less than 2^32-1 const uint32_t size = data.size(); // Write vector size to stream, zero vector is allowed write_le<uint32_t>(stream, size); // Write each data element for (uint32_t i = 0; i < size; i++) { write_le_vec2<T>(stream, data[i]); } } template <typename T> void min::write_be_vector_vec2(std::vector<uint8_t> &stream, const std::vector<vec2<T>> &data) { // Get data size, must be less than 2^32-1 const uint32_t size = data.size(); // Write vector size to stream, zero vector is allowed write_be<uint32_t>(stream, size); // Write each data element for (uint32_t i = 0; i < size; i++) { write_be_vec2<T>(stream, data[i]); } } template void min::write_le_vector_vec3(std::vector<uint8_t>&, const std::vector<vec3<float>>&); template void min::write_le_vector_vec3(std::vector<uint8_t>&, const std::vector<vec3<double>>&); template <typename T> void min::write_le_vector_vec3(std::vector<uint8_t> &stream, const std::vector<vec3<T>> &data) { // Get data size, must be less than 2^32-1 const uint32_t size = data.size(); // Write vector size to stream, zero vector is allowed write_le<uint32_t>(stream, size); // Write each data element for (uint32_t i = 0; i < size; i++) { write_le_vec3<T>(stream, data[i]); } } template <typename T> void min::write_be_vector_vec3(std::vector<uint8_t> &stream, const std::vector<vec3<T>> &data) { // Get data size, must be less than 2^32-1 const uint32_t size = data.size(); // Write vector size to stream, zero vector is allowed write_be<uint32_t>(stream, size); // Write each data element for (uint32_t i = 0; i < size; i++) { write_be_vec3<T>(stream, data[i]); } } template void min::write_le_vector_vec4(std::vector<uint8_t>&, const std::vector<min::vec4<float>>&); template void min::write_le_vector_vec4(std::vector<uint8_t>&, const std::vector<min::vec4<double>>&); template <typename T> void min::write_le_vector_vec4(std::vector<uint8_t> &stream, const std::vector<vec4<T>> &data) { // Get data size, must be less than 2^32-1 const uint32_t size = data.size(); // Write vector size to stream, zero vector is allowed write_le<uint32_t>(stream, size); // Write each data element for (uint32_t i = 0; i < size; i++) { write_le_vec4<T>(stream, data[i]); } } template <typename T> void min::write_be_vector_vec4(std::vector<uint8_t> &stream, const std::vector<vec4<T>> &data) { // Get data size, must be less than 2^32-1 const uint32_t size = data.size(); // Write vector size to stream, zero vector is allowed write_be<uint32_t>(stream, size); // Write each data element for (uint32_t i = 0; i < size; i++) { write_be_vec4<T>(stream, data[i]); } }
[ "ocket8888@gmail.com" ]
ocket8888@gmail.com
d563011680e44d7705eb7013680a1b9cc9f876d2
84cb6172f8afd975707c486b11ac8c812960a8a1
/ccfZCO14001.cpp
c4558eb75372ae631362c006c07d688d3418da08
[]
no_license
numan947/Curiously-Bored
d4d761923102831cac83c828e2e6a44daa5d5ac7
7bfffec3989d6cb75697bf7f569da01c3adb1a19
refs/heads/master
2021-07-10T22:01:27.716481
2020-07-02T19:16:16
2020-07-02T19:16:16
152,405,037
2
0
null
null
null
null
UTF-8
C++
false
false
6,027
cpp
#include <bits/stdc++.h> using namespace std; /*Like set but has some more functionality: 1. Find kth smallest minimum 2. Find the index of an element Does these in O(log n) time How to use: ordered_set<type> ss; ss.insert(val); ss.insert(val); ss.insert(val); cout<<ss.ordere_of_key(val)<<endl; // number of elements in ss less than val cout<<*ss.find_by_order(k)<<endl; // prints the kth smallest number in s (0-based) */ /*#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; */ #define ms(s, n) memset(s, n, sizeof(s)) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i) #define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) #define mapHas(t, x) (t.find(x) != t.end()) //for map #define vectHas(v,x) (find(v.begin(),v.end(),x)!=v.end()) //for vector #define setHas(t,x) (t.count(x)!=0) #define pb push_back #define pf push_front #define mp make_pair #define fi first #define se second #define prec(n) fixed<<setprecision(n) //bit manipulation #define bit(n, i) (((n) >> (i)) & 1) //check bit #define setBit(n,i) (n|=(1<<i)) //set i'th bit of n #define checkBit(n,i) (n &(1<<i)) //check i'th bit of n #define resetBit(n,i) (n&=~(1<<i)) //reset i'th bit of n #define toggleBit(n,i) (n^=(1<<i)) //toggle i'th bit of n #define lsOnBit(n) (n&(-n)) //get lsb of n that is on #define turnOnAll(n) ((1<<n) - 1) //turn on size of n bits from right (kind of opposite of clear) #define remainder(s,n) (s & (n-1)) //remainder of s when divided by n, where n is power of 2 #define powerOfTwo(s) ((s & (s-1)) == 0) //determine if s is a power of 2 #define turnOffLastSetBit(s) (s=(s&(s-1))) #define turnOnLastZero(s) (s=(s|(s+1))) #define numLeadZero(s) __builtin_clz(s) #define numTrailZero(s) __builtin_ctz(s) #define numOnes(s) __builtin_popcount(s) #define parity(s) __builtin_parity(s) //shorthands typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<char, int> pci; typedef pair<int, char> pic; typedef pair<int, string> pis; typedef pair<string, int> psi; typedef pair<string, string> pss; typedef vector<int> vi; typedef vector<pii> vii; typedef vector<string> vs; const int MOD = (int) 1e9 + 7; const int FFTMOD = 1007681537; const int INF = (int) 1e9; const ll LINF = (ll) 1e18; const ld PI = acos((ld) -1); const ld EPS = 1e-6; //some common functions inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;} //gcd inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //lcm inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;} //nth power inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;} //add mod inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;} //sub mod inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;} //check sqrt inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;} //check cbrt //some helper functions for input processing inline void tokenize(string str,vector<string> &tokens, string delim){ tokens.clear();size_t s = str.find_first_not_of(delim), e=s; while(s!=std::string::npos){e=str.find(delim,s);tokens.push_back(str.substr(s,e-s));s=str.find_first_not_of(delim,e);}} inline bool isPalindrome(string str){for(int i=0;i<(str.size())/2;i++)if(str[i]!=str[str.size()-1-i])return false;return true;} inline string customStrip(string in,string delim){string ret = "";for(int i=0;i<in.size();i++){if(delim.find(in[i],0)==std::string::npos)ret+=in[i];}return ret;} inline string commaSeparate(long long value){string numWithCommas = to_string(value);int insertPosition = numWithCommas.length() - 3;while (insertPosition > 0) {numWithCommas.insert(insertPosition, ",");insertPosition-=3;}return numWithCommas;} inline string strip(string s){int i=0;while(i<s.size()){if(isspace(s[i]))i++;else break;}s.erase(0,i);i = s.size()-1;while(i>=0){if(isspace(s[i]))i--;else break;}s.erase(i+1,s.size()-i-1);return s;} //errors #define db(x) cerr << #x << " = " << (x) << "\n"; #define endl '\n' /* //double comparisons and ops //d1==d2 inline bool EQ(double d1,double d2){return fabs(d1-d2)<EPS;} //d1>d2 inline bool GT(double d1,double d2){return (d1-d2)>EPS;} //d1<d2 inline bool LT(double d1,double d2){return GT(d2,d1);} //d1>=d2 inline bool GTE(double d1, double d2){return GT(d1,d2)||EQ(d1,d2);} //d1<=d2 inline bool LTE(double d1,double d2){return LT(d1,d2)||EQ(d1,d2);} //numPosAfterDecimal={10,100,1000,10000,....} //Roundoff(3.56985,10000) = 3.5699 inline double Roundoff(double val,int numPosAfterDecimal){return round(val*numPosAfterDecimal)/numPosAfterDecimal;} */ /*//4 directional movement int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1};*/ #define MAX 100001 int stk[MAX]; int main() { /*The standard C++ I/O functions (cin/cout) flush the buffer on every next I/O call which unncecessarily increase I/O time. For enhancing C++ I/O speed,you can either use C’s standard I/O function (scanf/printf) instead of (cin/cout) or you can write the following lines in main function.*/ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int N,H; cin>>N>>H; FOR(i,0,N) cin>>stk[i]; int iPos=0,iStat=0,cmd; while(cin>>cmd){ if(!cmd)break; switch(cmd){ case 1: if(iPos>0) iPos--; break; case 2: if(iPos<N-1) iPos++; break; case 3: if(!iStat && stk[iPos]){ iStat = 1; stk[iPos]--; } break; case 4: if(iStat&&stk[iPos]<H){ iStat = 0; stk[iPos]++; } break; } } cout<<stk[0]; FOR(i,1,N) cout<<" "<<stk[i]; cout<<endl; return 0; }
[ "mahmudulhasan947@gmail.com" ]
mahmudulhasan947@gmail.com
0ff8d27d3c7fb61d3a0e332def90a0d93a52ff47
c74b0c37ac8e2d3d1a3c0ffaa2b608bc4deff1c6
/Toolkit/FreyaReflect/Lib/3party/elsa/smbase/hashtbl.cc
3f100e3bae7da6140d366fd44ed0c63df0474480
[]
no_license
crsib/freya-3d
c33beeb787e572f2faf9528c6f3a1fa3875749c5
ff1f54b09f7bc0e253053a474f3fe5635dbedde6
refs/heads/master
2022-05-21T19:42:30.694778
2011-03-11T13:49:00
2011-03-11T13:49:00
259,894,429
1
0
null
null
null
null
UTF-8
C++
false
false
6,361
cc
// hashtbl.cc see license.txt for copyright and terms of use // code for hashtbl.h #include "hashtbl.h" // this module #include "xassert.h" // xassert #include <string.h> // memset unsigned HashTable::hashFunction(void const *key) const { return coreHashFn(key) % (unsigned)tableSize; } HashTable::HashTable(GetKeyFn gk, HashFn hf, EqualKeyFn ek, int initSize) : getKey(gk), coreHashFn(hf), equalKeys(ek), enableShrink(true) { makeTable(initSize); } HashTable::~HashTable() { delete[] hashTable; } void HashTable::makeTable(int size) { hashTable = new void*[size]; tableSize = size; memset(hashTable, 0, sizeof(void*) * tableSize); numEntries = 0; } inline int HashTable::getEntry(void const *key) const { int index = hashFunction(key); int originalIndex = index; for(;;) { if (hashTable[index] == NULL) { // unmapped return index; } if (equalKeys(key, getKey(hashTable[index]))) { // mapped here return index; } // this entry is mapped, but not with this key, i.e. // we have a collision -- so just go to the next entry, // wrapping as necessary index = nextIndex(index); // detect infinite looping xassert(index != originalIndex); } } void *HashTable::get(void const *key) const { return hashTable[getEntry(key)]; } void HashTable::resizeTable(int newSize) { // Make sure newSize is not the result of an overflowed computation, and // that we're not going to resizeTable again right away in the add() call. xassert(newSize >= numEntries); xassert(newSize/3*2 >= numEntries-1); // save old stuff void **oldTable = hashTable; int oldSize = tableSize; int oldEntries = numEntries; // make the new table (sets 'numEntries' to 0) makeTable(newSize); // set this now, rather than incrementing it with each add numEntries = oldEntries; // move entries to the new table for (int i=0; i<oldSize; i++) { if (oldTable[i] != NULL) { // This function is worth optimizing; it accounts for 12% of qualcc // runtime. This simple inlining reduces resizeTable()'s impact from // 12% to 2%. if (0) { // original code: add(getKey(oldTable[i]), oldTable[i]); } else { // inlined version: int newIndex = getEntry(getKey(oldTable[i])); xassertdb(hashTable[newIndex] == NULL); // must not be a mapping yet hashTable[newIndex] = oldTable[i]; } oldEntries--; } } xassert(oldEntries == 0); // deallocate the old table delete[] oldTable; } void HashTable::add(void const *key, void *value) { if (numEntries+1 > tableSize*2/3) { // We're over the usage threshold; increase table size. // // Note: Resizing by numEntries*4 instead of tableSize*2 gives 42% speedup // in total time used by resizeTable(), at the expense of more memory used. resizeTable(tableSize * 2 + 1); } // make sure above didn't fail due to integer overflow xassert(numEntries+1 < tableSize); int index = getEntry(key); xassert(hashTable[index] == NULL); // must not be a mapping yet hashTable[index] = value; numEntries++; } void *HashTable::remove(void const *key) { if (enableShrink && numEntries-1 < tableSize/5 && tableSize > defaultSize) { // we're below threshold; reduce table size resizeTable(tableSize / 2); } int index = getEntry(key); xassert(hashTable[index] != NULL); // must be a mapping to remove // remove this entry void *retval = hashTable[index]; hashTable[index] = NULL; numEntries--; // now, if we ever inserted something and it collided with this one, // leaving things like this would prevent us from finding that other // mapping because the search stops as soon as a NULL entry is // discovered; so we must examine all entries that could have // collided, and re-insert them int originalIndex = index; for(;;) { index = nextIndex(index); xassert(index != originalIndex); // prevent infinite loops if (hashTable[index] == NULL) { // we've reached the end of the list of possible colliders break; } // remove this one void *data = hashTable[index]; hashTable[index] = NULL; numEntries--; // add it back add(getKey(data), data); } return retval; } void HashTable::empty(int initSize) { delete[] hashTable; makeTable(initSize); } void HashTable::selfCheck() const { int ct=0; for (int i=0; i<tableSize; i++) { if (hashTable[i] != NULL) { checkEntry(i); ct++; } } xassert(ct == numEntries); } void HashTable::checkEntry(int entry) const { int index = getEntry(getKey(hashTable[entry])); int originalIndex = index; for(;;) { if (index == entry) { // the entry lives where it will be found, so that's good return; } if (hashTable[index] == NULL) { // the search for this entry would stop before finding it, // so that's bad! xfailure("checkEntry: entry in wrong slot"); } // collision; keep looking index = nextIndex(index); xassert(index != originalIndex); } } // ------------------ HashTableIter -------------------- HashTableIter::HashTableIter(HashTable &t) : table(t) { index = 0; moveToSth(); } void HashTableIter::adv() { xassert(!isDone()); // move off the current item index++; // keep moving until we find something moveToSth(); } void HashTableIter::moveToSth() { while (index < table.tableSize && table.hashTable[index] == NULL) { index++; } if (index == table.tableSize) { index = -1; // mark as done } } void *HashTableIter::data() const { xassert(!isDone()); return table.hashTable[index]; } STATICDEF void const *HashTable::identityKeyFn(void *data) { return data; } unsigned lcprngTwoSteps(unsigned v) { // this is the core of the LC PRNG in one of the many libcs // running around the net v = (v * 1103515245) + 12345; // do it again for good measure v = (v * 1103515245) + 12345; return v; } STATICDEF unsigned HashTable::lcprngHashFn(void const *key) { return lcprngTwoSteps((unsigned)pointerToInteger(key)); } STATICDEF bool HashTable:: pointerEqualKeyFn(void const *key1, void const *key2) { return key1 == key2; }
[ "crsib@localhost" ]
crsib@localhost
08c13c3751cf892237ccd7d90209409db64e1a6b
a04701966913695a1cbc003bf4b609754b62ed1c
/src/libtsduck/tsAVCVideoDescriptor.h
6a499ef3cb2a8ca436dc104da3f395e3a5b72f4e
[ "BSD-2-Clause" ]
permissive
anto35/tsduck
b80c7bed9138f78d402534fbf94f1635fd9d0c4a
6aa32ce5a59865d8d5509fd22a0c7cd110f79dc0
refs/heads/master
2021-08-30T22:45:45.542104
2017-12-18T22:26:32
2017-12-18T22:26:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,153
h
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2017, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- //! //! @file //! Representation of an AVC_video_descriptor //! //---------------------------------------------------------------------------- #pragma once #include "tsAbstractDescriptor.h" namespace ts { //! //! Representation of an AVC_video_descriptor. //! //! This MPG-defined descriptor is not defined in ISO/IEC 13818-1, //! ITU-T Rec. H.222.0. See its "Amendment 3: Transport of AVC video //! over ITU-T Rec. H.222.0 | ISO/IEC 13818-1 streams" (document W5771), //! section 2.6.54. //! class TSDUCKDLL AVCVideoDescriptor : public AbstractDescriptor { public: // Public members: uint8_t profile_idc; //!< Same as AVC concept. bool constraint_set0; //!< Same as AVC concept. bool constraint_set1; //!< Same as AVC concept. bool constraint_set2; //!< Same as AVC concept. uint8_t AVC_compatible_flags; //!< Same as AVC concept. uint8_t level_idc; //!< Same as AVC concept. bool AVC_still_present; //!< May contain still pictures. bool AVC_24_hour_picture; //!< May contain 25-hour pictures. //! //! Default constructor. //! AVCVideoDescriptor(); //! //! Constructor from a binary descriptor //! @param [in] bin A binary descriptor to deserialize. //! @param [in] charset If not zero, character set to use without explicit table code. //! AVCVideoDescriptor(const Descriptor& bin, const DVBCharset* charset = 0); // Inherited methods virtual void serialize(Descriptor&, const DVBCharset* = 0) const override; virtual void deserialize(const Descriptor&, const DVBCharset* = 0) override; virtual void buildXML(xml::Element*) const override; virtual void fromXML(const xml::Element*) override; //! //! Static method to display a descriptor. //! @param [in,out] display Display engine. //! @param [in] did Descriptor id. //! @param [in] payload Address of the descriptor payload. //! @param [in] size Size in bytes of the descriptor payload. //! @param [in] indent Indentation width. //! @param [in] tid Table id of table containing the descriptors. //! @param [in] pds Private Data Specifier. Used to interpret private descriptors. //! static void DisplayDescriptor(TablesDisplay& display, DID did, const uint8_t* payload, size_t size, int indent, TID tid, PDS pds); }; }
[ "thierry@lelegard.fr" ]
thierry@lelegard.fr
70ffea673f3095f8e9d9a01fbf004e0e19fa15a4
aa66004b533a8d9e8f8ce175d4df6fce1b3137f4
/src/SmartPointers/chrono.cpp
2eef54d2d389a28cbcab33a7adf4063d9a9c1ea2
[]
no_license
ricleal/CppTests
c036ba235765f742504195dba61b85ff752de337
84ac0253604ac02776498ec2a5f05f3e2dda7df9
refs/heads/master
2021-06-25T17:50:13.894692
2017-03-22T18:10:40
2017-03-22T18:10:40
13,873,119
0
0
null
null
null
null
UTF-8
C++
false
false
685
cpp
#include <iostream> #include <vector> #include <numeric> #include <chrono> volatile int sink; int main_chrono() { for (auto size = 1ull; size < 1000000000ull; size *= 100) { // record start time auto start = std::chrono::system_clock::now(); // do some work std::vector<int> v(size, 42); sink = std::accumulate(v.begin(), v.end(), 0u); // make sure it's a side effect // record end time auto end = std::chrono::system_clock::now(); std::chrono::duration<double> diff = end-start; std::cout << "Time to fill and iterate a vector of " << size << " ints : " << diff.count() << " s\n"; } }
[ "ricleal@gmail.com" ]
ricleal@gmail.com
2e9cbe6a1fd9e9fbdcec136da0bd6f7ee82dca1b
4bad7578931dd47c38dc283aec7eb961be6e1f30
/src/wallet/api/pending_transaction.h
db0a52324ce20d62a108c01ae705bc0441328bd3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
cyberstormdotmu/electroneum-classic
d034453071a3c9fa37f494c212e3ffc6d0effc9b
494bd2b5f9d9d759c10568e0326dde1737cefad6
refs/heads/master
2020-04-01T06:25:43.262217
2018-10-17T04:16:13
2018-10-17T04:16:13
152,947,188
0
0
null
2018-10-14T06:47:32
2018-10-14T06:47:32
null
UTF-8
C++
false
false
2,622
h
// Copyrights(c) 2018, The Electroneum Classic Project // Copyrights(c) 2017-2018, The Electroneum Project // Copyrights(c) 2014-2017, The Monero Project // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #include "wallet/wallet2_api.h" #include "wallet/wallet2.h" #include <string> #include <vector> namespace Electroneum { class WalletImpl; class PendingTransactionImpl : public PendingTransaction { public: PendingTransactionImpl(WalletImpl &wallet); ~PendingTransactionImpl(); int status() const; std::string errorString() const; bool commit(const std::string &filename = "", bool overwrite = false); uint64_t amount() const; uint64_t dust() const; uint64_t fee() const; std::vector<std::string> txid() const; uint64_t txCount() const; // TODO: continue with interface; private: friend class WalletImpl; WalletImpl &m_wallet; int m_status; std::string m_errorString; std::vector<tools::wallet2::pending_tx> m_pending_tx; }; } namespace Bitelectroneum = Electroneum;
[ "vans_163@yahoo.com" ]
vans_163@yahoo.com
320df1b17be0f7ebc04f9832ba6956219578d42d
8a274dffceab9d4e63fc0962e20fb7dab761555c
/CSES/Repetitions CSES.cpp
e84e4cac0ec1bbf1d344b228dd8cf16424d3c863
[]
no_license
mkp0/CP
669ce9ab399660d90d829f77b05f1462cd92ede5
80321819e46ebf4dd6512d6577add645da83708a
refs/heads/master
2023-06-01T22:07:36.006530
2021-06-25T21:41:23
2021-06-25T21:41:23
273,572,017
3
0
null
null
null
null
UTF-8
C++
false
false
1,351
cpp
#include <bits/stdc++.h> #define ll long long #define pi (3.141592653589) #define all(x) (x).begin(), (x).end() #define vi vector<int> #define vll vector<long long> #define pii pair<int, int> #define pll pair<long long, long long> #define pb push_back #define mp make_pair #define S second #define loop(i, a, b, c) for (int i = (a); i <= (b); i = i + (c)) #define MOD 1e9 + 7 using namespace std; //stringMul String Multiplication , trie trie, zalgo Z-Algorithm, segTree Segmentation Tree, BS binary Search , subStr Substring , mrg Merge,SOE sieve of Era,permutate PermutationOfString ,graphi GraphIntialzation , graphBFS Graph BFS ,graphDFS graph DFS,exdGCD ExtendedGCD,nCR with Factorial ,axbyn ax+by=n /* I am gonna be the King of the Pirates */ void solve() { string s; cin >> s; int n = s.size(); int ans = 0; for (int i = 0; i < n;) { int j = i; int co = 0; while ((j < n) && (s[i] == s[j])) { co += 1; j++; } ans = max(co, ans); i = j; } cout << ans << "\n"; } int32_t main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #endif ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; while (t--) { solve(); } return 0; }
[ "shadymasum@gmail.com" ]
shadymasum@gmail.com
289137a2ffdae5eb87d99216fdd96ddb5bdfa0bd
9eacc869fa1d8f8b2a2dfb6c3dba613e41992f72
/app/music/music/bottom/bottomwidgets.cpp
13cc2a802cc03ef727dd3cabeb65d9fba9476c13
[ "Apache-2.0" ]
permissive
hyperkin-game/hyperkin-gb
9093c4e29212924cdbb7492e7e13002105f33801
e333185e8a2a4f5c90e84dca515e335e62565a3b
refs/heads/main
2023-04-27T18:17:09.675136
2021-05-14T10:20:59
2021-05-14T10:20:59
331,823,448
6
1
null
null
null
null
UTF-8
C++
false
false
6,046
cpp
#include "bottomwidgets.h" #include "constant.h" #include <QHBoxLayout> #ifdef DEVICE_EVB int playButton_size = 100; int bottom_height = 150; int bottom_spacing = 25; int layout3_size = 70; int layout3_temp = 25; int progress_slider_height = 20; #else int playButton_size = 55; int bottom_height = 80; int bottom_spacing = 20; int layout3_size = 45; int layout3_temp = 10; int progress_slider_height = 10; #endif BottomWidgets::BottomWidgets(QWidget *parent) : BaseWidget(parent) , m_duration(-1) { setBackgroundColor(54, 54, 54); initLayout(); initConnection(); } void BottomWidgets::initLayout() { QVBoxLayout *layout = new QVBoxLayout; QHBoxLayout *mainLayout = new QHBoxLayout; /*----------------- position layout -------------------*/ m_labPosition = new QLabel(this); m_labPosition->setAlignment(Qt::AlignCenter); BaseWidget::setWidgetFontSize(m_labPosition, font_size_large); /* set the whole widget height = this label height + baseSlider height */ m_labPosition->setFixedHeight(bottom_height); /*----------------- play control button ----------------*/ m_btnNext = new FlatButton(this); m_btnPrevious = new FlatButton(this); m_btnPlay = new FlatButton(this); m_btnNext->setFixedSize(playButton_size, playButton_size); m_btnPrevious->setFixedSize(playButton_size, playButton_size); m_btnPlay->setFixedSize(playButton_size, playButton_size); m_btnNext->setBackgroundImage(":/image/music/btn_next (2).png"); m_btnPrevious->setBackgroundImage(":/image/music/btn_previous (2).png"); m_btnPlay->setBackgroundImage(":/image/music/btn_play (2).png"); QHBoxLayout *playControlLayout = new QHBoxLayout; playControlLayout->addWidget(m_btnPrevious); playControlLayout->addWidget(m_btnPlay); playControlLayout->addWidget(m_btnNext); playControlLayout->setMargin(0); playControlLayout->setSpacing(bottom_spacing); /*----------------- volume、playmode ----------------*/ m_volWid = new VolWidget(this); m_btnPlayMode = new FlatButton(this); m_btnPlayMode->setFixedSize(layout3_size, layout3_size); m_btnPlayMode->setBackgroundImage(":/image/music/btn_mode_random.png"); m_btnRefresh = new FlatButton(this); m_btnRefresh->setFixedSize(layout3_size, layout3_size); m_btnRefresh->setBackgroundImage(":/image/music/btn_refresh.png"); m_btnRefresh->setVisible(false); QHBoxLayout *layout3 = new QHBoxLayout; layout3->addStretch(0); layout3->addWidget(m_btnPlayMode); layout3->addWidget(m_volWid); layout3->addStretch(0); layout3->setMargin(0); layout3->setSpacing(bottom_spacing); /*-- whole layout contains control layout and progressSlider --*/ mainLayout->addWidget(m_labPosition, 1); mainLayout->addLayout(playControlLayout, 1); mainLayout->addLayout(layout3, 1); mainLayout->setMargin(0); mainLayout->setSpacing(0); m_progressSlider = new BaseSlider(Qt::Horizontal, this); m_progressSlider->setFixedHeight(progress_slider_height); layout->addWidget(m_progressSlider); layout->addLayout(mainLayout); layout->setMargin(0); layout->setSpacing(0); layout->setContentsMargins(15,15,15,0); setLayout(layout); } void BottomWidgets::initConnection() { connect(m_btnPrevious, SIGNAL(longPressedEvent()), this, SIGNAL(lastLongPressed())); connect(m_btnNext, SIGNAL(longPressedEvent()), this, SIGNAL(nextLongPressed())); connect(m_btnNext, SIGNAL(clicked(bool)), this, SIGNAL(nextClick())); connect(m_btnPrevious, SIGNAL(clicked(bool)), this, SIGNAL(lastClick())); connect(m_btnPlay, SIGNAL(clicked(bool)), this, SIGNAL(playPauseClick())); connect(m_progressSlider, SIGNAL(sig_sliderPositionChanged(int)), this, SIGNAL(progressSliderPositionChanged(int))); connect(m_volWid, SIGNAL(sig_valueChanged(int)), this, SIGNAL(volumeChanged(int))); connect(m_btnPlayMode, SIGNAL(clicked(bool)), this, SIGNAL(playModeClick())); connect(m_btnRefresh, SIGNAL(clicked(bool)), this, SIGNAL(refreshClick())); } void BottomWidgets::setPauseStyle() { m_btnPlay->setBackgroundImage(":/image/music/btn_pause (2).png"); } void BottomWidgets::setPlayStyle() { m_btnPlay->setBackgroundImage(":/image/music/btn_play (2).png"); } void BottomWidgets::setPositionLabel(QTime currentTime, QTime totalTime) { QString ret; ret.append(currentTime.toString("mm:ss")).append("/").append(totalTime.toString("mm:ss")); m_labPosition->setText(ret); } void BottomWidgets::updateVolumeSliderValue(int value) { m_volWid->updateSlider(value); } void BottomWidgets::onPlayerDurationChanged(qint64 duration) { m_duration = duration; m_progressSlider->setRange(0, duration); } void BottomWidgets::onPlayerPositionChanged(qint64 position) { QTime currentTime((position % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60), (position % (1000 * 60 * 60)) / (1000 * 60), (position % (1000 * 60)) / 1000); QTime totalTime((m_duration % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60), (m_duration % (1000 * 60 * 60)) / (1000 * 60), (m_duration % (1000 * 60)) / 1000); setPositionLabel(currentTime, totalTime); m_progressSlider->setValue(position); } void BottomWidgets::updatePlayModeIcon(PlayMode playMode) { switch (playMode) { case PlayRandom: m_btnPlayMode->setBackgroundImage(":/image/music/btn_mode_random.png"); break; case PlayOneCircle: m_btnPlayMode->setBackgroundImage(":/image/music/btn_mode_single.png"); break; case PlayInOrder: m_btnPlayMode->setBackgroundImage(":/image/music/btn_mode_list.png"); break; } } void BottomWidgets::setOriginState() { m_progressSlider->setValue(0); setPositionLabel(QTime(0, 0, 0), QTime(0, 0, 0)); }
[ "stanley@bte.com.tw" ]
stanley@bte.com.tw
8a11b3d42521dbedf29fc78c99c3d89ea2a75254
099f2181439ba42a5fbeb774a182faf3db9bad8c
/problems/347-top-k-frequent-elements.cpp
33e1fca42782bcc10bde6f4cdfdfd49875201170
[]
no_license
luchenqun/leet-code
76a9193e315975b094225d15f0281d0d462c2ee7
38b3f660e5173ad175b8451a730bf4ee3f03a66b
refs/heads/master
2021-07-09T09:49:36.068938
2019-01-15T07:15:22
2019-01-15T07:15:22
102,130,497
1
0
null
null
null
null
UTF-8
C++
false
false
893
cpp
/* * [347] Top K Frequent Elements * * https://leetcode-cn.com/problems/top-k-frequent-elements/description/ * https://leetcode.com/problems/top-k-frequent-elements/discuss/ * * algorithms * Medium (46.38%) * Total Accepted: 561 * Total Submissions: 1.2K * Testcase Example: '[1,1,1,2,2,3]\n2' * * 给定一个非空的整数数组,返回其中出现频率前 k 高的元素。 * 例如, * 给定数组 [1,1,1,2,2,3] , 和 k = 2,返回 [1,2]。 * 注意: * 你可以假设给定的 k 总是合理的,1 ≤ k ≤ 数组中不相同的元素的个数。 * 你的算法的时间复杂度必须优于 O(n log n) , n 是数组的大小。 */ #include <iostream> #include <string> using namespace std; class Solution { public: vector<int> topKFrequent(vector<int>& nums, int k) { } }; int main() { Solution s; return 0; }
[ "luchenqun@juzix.io" ]
luchenqun@juzix.io
0d88ad45f6f55023f6474fd2ceadb20bf1cb2551
b9d8b5bd3dc3c9bd6f3e84670c7fdfb004b661f5
/object.h
960ac120ef1d84d9ce290cf049904db9faea1103
[]
no_license
alex-peng/AnimVis
a6440a69ca73f92e1d07f317bbf0e48b82fc635f
f2e5d788ddc42d1d2e79394e93f9518a517358ed
refs/heads/master
2016-09-06T15:59:39.772963
2013-04-19T00:37:21
2013-04-19T00:37:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
846
h
#ifndef _OBJECT_H_ #define _OBJECT_H_ namespace AMT { typedef enum { WIREFRAME = 0, GOURAUD, TEXTURED } TRenderMode; class CBoundingBox { public: float center[3]; float size; CBoundingBox() : size(0.0f) {}; }; class CRenderObject { public: bool m_visiable; bool m_VisiableTest; bool m_ShaderReady; float alpha; // For transparent display float beginx, beginy; /* position of mouse */ float position[3]; float m_VisibiltyTime; float quat[4]; CBoundingBox boundingBox; CRenderObject( bool _visiable = true, float _alpha = 1.0f ); void ResetPosition(); virtual void draw() = 0; virtual void destroyMyself() = 0; virtual unsigned int getFaceNumber() = 0; virtual void ChangeRenderMode(TRenderMode rm ) = 0; virtual void SetShader() = 0; virtual unsigned int getVisFaceNumber() { return getFaceNumber(); } }; } #endif
[ "mipeng@vt.edu" ]
mipeng@vt.edu
bb82519d6db8208156b47ccda0dc52529e2e2828
2ca3ad74c1b5416b2748353d23710eed63539bb0
/Src/Lokapala/Operator/UserDataDTO.h
27a1e4aa4580bd841a0a396e3b67916832cb8aa5
[]
no_license
sjp38/lokapala
5ced19e534bd7067aeace0b38ee80b87dfc7faed
dfa51d28845815cfccd39941c802faaec9233a6e
refs/heads/master
2021-01-15T16:10:23.884841
2009-06-03T14:56:50
2009-06-03T14:56:50
32,124,140
0
0
null
null
null
null
UTF-8
C++
false
false
1,097
h
/**@file UserDataDTO.h * @brief 유저 개인의 정보를 담는 DTO를 정의한다. * @author siva */ #ifndef USER_DATA_DTO_H #define USER_DATA_DTO_H /**@ingroup GroupDAM * @class CUserDataDTO * @brief 유저 개인의 정보를 담는다.\n * @remarks 비밀번호는 모두 단방향 해싱을 거친 값들을 갖는다.\n * 유저 id는 당방향 해싱 후의 로우레벨 패스워드(학번)다. */ class CUserDataDTO { public : /**@brief 여기선 단순히 해당 유저의 low level password를 사용한다. */ CString m_userId; CString m_name; CString m_lowLevelPassword; /**@brief sha1으로 해싱된 digest message를 갖는다. */ CString m_highLevelPassword; int m_level; CUserDataDTO(CString a_userId, CString a_name, CString a_lowLevelPassword, CString a_highLevelPassword, int a_level); CUserDataDTO(CString a_userId, CString a_name, CString a_lowLevelPassword, int a_level, CString a_hashedHighLevelPassword); CUserDataDTO(){} ~CUserDataDTO(){} private : CString HashMessage(CString a_message); }; #endif
[ "nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c" ]
nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c
4cc016260fdcc37e4e50de75b0ddefc650af6270
81bed8a9185b9a23b32db7e43c1b653954955ecd
/TimerQueue.cpp
e0d919772d095a4605a077ce19603530932d001d
[]
no_license
UltramanWu/SimpleWebServer
cb6e934fc6f516c0522b92db0efdd0ff4f4b7e55
b1eda0a42503d868b8bd5e4e15135f8d55b842a9
refs/heads/master
2021-04-01T07:01:28.320665
2020-04-02T04:02:33
2020-04-02T04:02:33
248,166,353
0
0
null
null
null
null
UTF-8
C++
false
false
904
cpp
// // Created by wu on 3/18/20. // #include "TimerQueue.h" #include "HttpData.h" TimerNode::TimerNode(SPHttpData httpdata,int timeout):m_httpdata(httpdata),deleted(false){ struct timeval now; gettimeofday(&now,NULL); // 时间结构体 时区 expiredTime = (((now.tv_sec%10000)*1000)+(now.tv_usec/1000))+timeout; } TimerNode::~TimerNode() { if(m_httpdata) m_httpdata->CloseHandle(); } void TimerQueue::AddTimer(SPHttpData httpData, int timeout) { SPTimerNode item(std::make_shared<TimerNode>(httpData,timeout)); TimerNodeQueue.push(item); httpData->LinkTimer(item); // 将TimerNode与HttpData进行关联 } void TimerQueue::HandleExpired() { while(!TimerNodeQueue.empty()){ SPTimerNode tn = TimerNodeQueue.top(); if(tn->IsValid()==false || tn->GetDeleted()==true){ TimerNodeQueue.pop(); } else break; } }
[ "shida_wu@163.com" ]
shida_wu@163.com
674ce9fcb1c0227fcd7fb451ba0055a9b0afd5c9
49cfc3f1a96b3f75adf74821342999a20da3e04d
/examples/system_process_pipes.cpp
1726dd571310164c58ac69d96b2ec72e241d0bc2
[ "MIT" ]
permissive
mrexodia/CppCommon
bfb4456b984ceea64dd98853816f388c29bfe006
422bec80be2412e909539b73be40972ecc8acf83
refs/heads/master
2020-05-17T15:10:23.069691
2019-04-25T14:36:20
2019-04-25T14:36:20
183,780,482
1
0
MIT
2019-04-27T14:05:08
2019-04-27T14:05:08
null
UTF-8
C++
false
false
1,342
cpp
/*! \file system_process_pipes.cpp \brief Process pipes example \author Ivan Shynkarenka \date 07.12.2016 \copyright MIT License */ #include "system/environment.h" #include "system/process.h" #include <algorithm> #include <iostream> #include <string> int main(int argc, char** argv) { if (argc > 1) { std::string message = "test message"; std::string endline = CppCommon::Environment::EndLine(); std::cout << "Executing child process..." << std::endl; CppCommon::Pipe input; CppCommon::Pipe output; CppCommon::Pipe error; CppCommon::Process child = CppCommon::Process::Execute(argv[1], nullptr, nullptr, nullptr, &input, &output, &error); input.Write(message); input.Write(endline); std::string out = output.ReadAllText(); std::string err = error.ReadAllText(); int result = child.Wait(); std::cout << "Executed child process! Result = " << result << std::endl; std::cout << "stdout: " << out << std::endl; std::cout << "stderr: " << err << std::endl; return 0; } std::string line; if (getline(std::cin, line)) { std::cout << line << std::endl; std::reverse(line.begin(), line.end()); std::cerr << line << std::endl; } return 123; }
[ "chronoxor@gmail.com" ]
chronoxor@gmail.com
ffcb6d14462bcb2161c1b5b9e96fec2627493b1d
813d9380b3fbf66a0d344937a6be52f408b54078
/runtime/regiontemplates/examples/RTPipelineBundle/HelloWorld.cpp
55a4a0dab31cf60ad5f7c3bc862082531a4e0aee
[]
no_license
SBU-BMI/region-templates
6b63fab2809ac281e458053069d26782d04cd1e5
ab311b70eaeee3353ae09e1b8ba694e29d4d982d
refs/heads/master
2023-03-05T03:26:03.580106
2017-07-13T03:02:35
2017-07-13T03:02:35
35,566,013
5
6
null
2017-04-17T20:04:58
2015-05-13T18:10:24
C++
UTF-8
C++
false
false
2,639
cpp
/* * HelloWorld.cpp * * Created on: Feb 15, 2012 * Author: george */ #include <sstream> #include <stdlib.h> #include <iostream> #include "FileUtils.h" #include "RegionTemplate.h" #include "RegionTemplateCollection.h" #include "SysEnv.h" #include "Segmentation.h" #define NUM_PIPELINE_INSTANCES 1 void parseInputArguments(int argc, char**argv, std::string &inputFolder){ // Used for parameters parsing for(int i = 0; i < argc-1; i++){ if(argv[i][0] == '-' && argv[i][1] == 'i'){ inputFolder = argv[i+1]; } } } RegionTemplateCollection* RTFromFiles(std::string inputFolderPath){ // Search for input files in folder path FileUtils fileUtils("tif"); std::vector<std::string> fileList; fileUtils.traverseDirectoryRecursive(inputFolderPath, fileList); RegionTemplateCollection* rtCollection = new RegionTemplateCollection(); rtCollection->setName("inputimage"); std::cout << "Input Folder: "<< inputFolderPath <<std::endl; // Create one region template instance for each input data file // (creates representations without instantiating them) for(int i = 0; i < fileList.size(); i++){ DenseDataRegion2D *ddr2d = new DenseDataRegion2D(); ddr2d->setName("BGR"); ddr2d->setInputType(DataSourceType::FILE_SYSTEM); // ddr2d->setOutputType(-1); // ddr2d->setOutputType(DataSourceType::DATA_SPACES); ddr2d->setId(fileList[i]); // ddr2d->setInBds(new FileSystemImageDataSource(fileList[i])); RegionTemplate *rt = new RegionTemplate(); rt->setName("tile"); rt->insertDataRegion(ddr2d); rtCollection->addRT(rt); } return rtCollection; } int main (int argc, char **argv){ // Folder when input data images are stored std::string inputFolderPath; std::vector<RegionTemplate *> inputRegionTemplates; RegionTemplateCollection *rtCollection; parseInputArguments(argc, argv, inputFolderPath); // Handler to the distributed execution system environment SysEnv sysEnv; // Tell the system which libraries should be used sysEnv.startupSystem(argc, argv, "libcomponentsrtbundle.so"); // Create region templates description without instantiating data rtCollection = RTFromFiles(inputFolderPath); // Build application dependency graph // Instantiate application dependency graph for(int i = 0; i < rtCollection->getNumRTs(); i++){ Segmentation *seg = new Segmentation(); seg->addRegionTemplateInstance(rtCollection->getRT(i), rtCollection->getRT(i)->getName()); sysEnv.executeComponent(seg); } // End Create Dependency Graph sysEnv.startupExecution(); // Finalize all processes running and end execution sysEnv.finalizeSystem(); delete rtCollection; return 0; }
[ "george@Georges-MacBook-Pro-2.local" ]
george@Georges-MacBook-Pro-2.local
b06522065a944101f9f7507fba882738e800c03c
ca36def64eba15232bd8eb886353517f43610491
/tensorflow/core/profiler/rpc/client/remote_profiler_session_manager.cc
87575ee67a11e24d696b3ea689a1b9b5ff406bba
[ "Apache-2.0" ]
permissive
pulmo/tensorflow
a82d09948bf0678fcb2152ac13527d543edab8ea
ce321f0c9d09936f3084bfb93d0812c7ffa174e6
refs/heads/master
2022-12-25T03:38:47.564304
2020-09-30T20:39:38
2020-09-30T20:45:35
300,059,104
1
0
Apache-2.0
2020-09-30T20:50:07
2020-09-30T20:50:06
null
UTF-8
C++
false
false
6,476
cc
/* Copyright 2020 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. ==============================================================================*/ #include "tensorflow/core/profiler/rpc/client/remote_profiler_session_manager.h" #include <cstddef> #include <memory> #include "absl/memory/memory.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "absl/time/clock.h" #include "absl/time/time.h" #include "tensorflow/core/platform/env_time.h" #include "tensorflow/core/platform/errors.h" #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/types.h" #include "tensorflow/core/profiler/rpc/client/save_profile.h" #include "tensorflow/core/profiler/utils/time_utils.h" #include "tensorflow/core/protobuf/error_codes.pb.h" namespace tensorflow { namespace profiler { namespace { constexpr uint64 kMaxEvents = 1000000; // TODO(yisitu) merge with the implementation in capture_profile. void PopulateProfileRequest(const RemoteProfilerSessionManagerOptions& options, absl::string_view session_id, absl::string_view host_name, ProfileRequest* request) { request->set_max_events(kMaxEvents); request->set_repository_root(options.profiler_options().repository_path()); request->set_session_id(session_id.data(), session_id.size()); request->add_tools("trace_viewer"); request->add_tools("op_profile"); request->add_tools("input_pipeline"); request->add_tools("kernel_stats"); request->add_tools("memory_viewer"); request->add_tools("memory_profile"); request->add_tools("overview_page"); request->add_tools("pod_viewer"); request->add_tools("tensorflow_stats"); request->set_host_name(host_name.data(), host_name.size()); *request->mutable_opts() = options.profiler_options(); request->set_duration_ms(options.profiler_options().duration_ms()); } } // namespace /*static*/ std::unique_ptr<RemoteProfilerSessionManager> RemoteProfilerSessionManager::Create( const RemoteProfilerSessionManagerOptions& options, tensorflow::Status& out_status, AddressResolver resolver) { VLOG(1) << "Creating a RemoteProfilerSessionManager."; auto session_manager = absl::WrapUnique(new RemoteProfilerSessionManager(options, resolver)); out_status = session_manager->Init(); if (!out_status.ok()) { return nullptr; } return session_manager; } RemoteProfilerSessionManager::RemoteProfilerSessionManager( RemoteProfilerSessionManagerOptions options, AddressResolver resolver) : options_(std::move(options)) { if (resolver) { resolver_ = std::move(resolver); } else { resolver_ = [](absl::string_view addr) { return std::string(addr); }; } } RemoteProfilerSessionManager::~RemoteProfilerSessionManager() { VLOG(2) << "Destroying RemoteProfilerSessionManager."; } Status RemoteProfilerSessionManager::Init() { mutex_lock lock(mutex_); VLOG(1) << "SessionManager initializing."; // TODO(b/169482824) Move validation to call site. Status status = ValidateOptionsLocked(); if (!status.ok()) { LOG(ERROR) << status; return status; } std::string session_id = GetCurrentTimeStampAsString(); const absl::Time session_created_ts = absl::FromUnixNanos(options_.session_creation_timestamp_ns()); const absl::Time deadline = session_created_ts + absl::Milliseconds(options_.max_session_duration_ms()); LOG(INFO) << "Deadline set to " << deadline << " because max_session_duration_ms was " << options_.max_session_duration_ms() << " and session_creation_timestamp_ns was " << options_.session_creation_timestamp_ns() << " [" << session_created_ts << "]"; // Prepare a list of clients. clients_.reserve(options_.service_addresses_size()); for (auto& service_addr : options_.service_addresses()) { std::string resolved_service_addr = resolver_(service_addr); ProfileRequest profile_request; PopulateProfileRequest(options_, session_id, resolved_service_addr, &profile_request); // Creation also issues Profile RPC asynchronously. auto client = RemoteProfilerSession::Create( std::move(resolved_service_addr), deadline, std::move(profile_request)); clients_.push_back(std::move(client)); } LOG(INFO) << absl::StrFormat("Issued Profile gRPC to %u clients", clients_.size()); return Status::OK(); } Status RemoteProfilerSessionManager::ValidateOptionsLocked() { if (!options_.service_addresses_size()) { return errors::InvalidArgument("No service addresses specified."); } if (options_.profiler_options().duration_ms() == 0) { if (options_.max_session_duration_ms() != 0) { return errors::InvalidArgument( "If local profiler duration is unbounded, profiling session duration " "must be unbounded."); } } if (options_.max_session_duration_ms() < options_.profiler_options().duration_ms()) { return errors::InvalidArgument( "The maximum profiling session duration must be greater than or equal " "to the local profiler duration."); } return Status::OK(); } std::vector<RemoteProfilerSessionManager::Response> RemoteProfilerSessionManager::WaitForCompletion() { mutex_lock lock(mutex_); std::vector<RemoteProfilerSessionManager::Response> remote_responses; remote_responses.reserve(clients_.size()); for (auto& client : clients_) { remote_responses.emplace_back(); auto* profile_response = &remote_responses.back().profile_response; Status& status = remote_responses.back().status; std::string* service_addr = &remote_responses.back().service_addr; *profile_response = client->WaitForCompletion(status); *service_addr = client->GetServiceAddress(); } return remote_responses; } } // namespace profiler } // namespace tensorflow
[ "gardener@tensorflow.org" ]
gardener@tensorflow.org
a66fcd830da454746793f7f4179157b7febcd454
563579e51032a07492f11e9a3b5fc5e1e128f523
/hphp/third_party/folly/folly/io/IOBufQueue.h
71966f49cb1819f5cc332cf9b4e8a4253bfa4c27
[ "Apache-2.0", "Zend-2.0", "LicenseRef-scancode-unknown-license-reference", "PHP-3.01" ]
permissive
sachintaware/hiphop-php
6a54d4d71bcd2e0b18fddb5a6ecf1cf562b8117e
d95ca0dc9ad160cc1dfd691ecc1245a5a7798327
refs/heads/master
2021-01-16T18:41:50.061432
2013-08-15T21:17:24
2013-08-15T22:19:36
12,209,930
1
0
null
null
null
null
UTF-8
C++
false
false
8,019
h
/* * Copyright 2013 Facebook, 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. */ #ifndef FOLLY_IO_IOBUF_QUEUE_H #define FOLLY_IO_IOBUF_QUEUE_H #include "folly/io/IOBuf.h" #include <stdexcept> #include <string> namespace folly { /** * An IOBufQueue encapsulates a chain of IOBufs and provides * convenience functions to append data to the back of the chain * and remove data from the front. * * You may also prepend data into the headroom of the first buffer in the * chain, if any. */ class IOBufQueue { public: struct Options { Options() : cacheChainLength(false) { } bool cacheChainLength; }; /** * Commonly used Options, currently the only possible value other than * the default. */ static Options cacheChainLength() { Options options; options.cacheChainLength = true; return options; } explicit IOBufQueue(const Options& options = Options()); /** * Return a space to prepend bytes and the amount of headroom available. */ std::pair<void*, uint32_t> headroom(); /** * Indicate that n bytes from the headroom have been used. */ void markPrepended(uint32_t n); /** * Prepend an existing range; throws std::overflow_error if not enough * room. */ void prepend(const void* buf, uint32_t n); /** * Add a buffer or buffer chain to the end of this queue. The * queue takes ownership of buf. * * If pack is true, we try to reduce wastage at the end of this queue * by copying some data from the first buffers in the buf chain (and * releasing the buffers), if possible. If pack is false, we leave * the chain topology unchanged. */ void append(std::unique_ptr<folly::IOBuf>&& buf, bool pack=false); /** * Add a queue to the end of this queue. The queue takes ownership of * all buffers from the other queue. */ void append(IOBufQueue& other, bool pack=false); void append(IOBufQueue&& other, bool pack=false) { append(other, pack); // call lvalue reference overload, above } /** * Copy len bytes, starting at buf, to the end of this queue. * The caller retains ownership of the source data. */ void append(const void* buf, size_t len); /** * Copy a string to the end of this queue. * The caller retains ownership of the source data. */ void append(const std::string& buf) { append(buf.data(), buf.length()); } /** * Append a chain of IOBuf objects that point to consecutive regions * within buf. * * Just like IOBuf::wrapBuffer, this should only be used when the caller * knows ahead of time and can ensure that all IOBuf objects that will point * to this buffer will be destroyed before the buffer itself is destroyed; * all other caveats from wrapBuffer also apply. * * Every buffer except for the last will wrap exactly blockSize bytes. * Importantly, this method may be used to wrap buffers larger than 4GB. */ void wrapBuffer(const void* buf, size_t len, uint32_t blockSize=(1U << 31)); // default block size: 2GB /** * Obtain a writable block of contiguous bytes at the end of this * queue, allocating more space if necessary. The amount of space * reserved will be at least min. If min contiguous space is not * available at the end of the queue, and IOBuf with size newAllocationSize * is appended to the chain and returned. The actual available space * may be larger than newAllocationSize, but will be truncated to max, * if specified. * * If the caller subsequently writes anything into the returned space, * it must call the postallocate() method. * * @return The starting address of the block and the length in bytes. * * @note The point of the preallocate()/postallocate() mechanism is * to support I/O APIs such as Thrift's TAsyncSocket::ReadCallback * that request a buffer from the application and then, in a later * callback, tell the application how much of the buffer they've * filled with data. */ std::pair<void*,uint32_t> preallocate( uint32_t min, uint32_t newAllocationSize, uint32_t max = std::numeric_limits<uint32_t>::max()); /** * Tell the queue that the caller has written data into the first n * bytes provided by the previous preallocate() call. * * @note n should be less than or equal to the size returned by * preallocate(). If n is zero, the caller may skip the call * to postallocate(). If n is nonzero, the caller must not * invoke any other non-const methods on this IOBufQueue between * the call to preallocate and the call to postallocate(). */ void postallocate(uint32_t n); /** * Obtain a writable block of n contiguous bytes, allocating more space * if necessary, and mark it as used. The caller can fill it later. */ void* allocate(uint32_t n) { void* p = preallocate(n, n).first; postallocate(n); return p; } /** * Split off the first n bytes of the queue into a separate IOBuf chain, * and transfer ownership of the new chain to the caller. The IOBufQueue * retains ownership of everything after the split point. * * @warning If the split point lies in the middle of some IOBuf within * the chain, this function may, as an implementation detail, * clone that IOBuf. * * @throws std::underflow_error if n exceeds the number of bytes * in the queue. */ std::unique_ptr<folly::IOBuf> split(size_t n); /** * Similar to IOBuf::trimStart, but works on the whole queue. Will * pop off buffers that have been completely trimmed. */ void trimStart(size_t amount); /** * Similar to IOBuf::trimEnd, but works on the whole queue. Will * pop off buffers that have been completely trimmed. */ void trimEnd(size_t amount); /** * Transfer ownership of the queue's entire IOBuf chain to the caller. */ std::unique_ptr<folly::IOBuf> move() { chainLength_ = 0; return std::move(head_); } /** * Access */ const folly::IOBuf* front() const { return head_.get(); } /** * returns the first IOBuf in the chain and removes it from the chain * * @return first IOBuf in the chain or nullptr if none. */ std::unique_ptr<folly::IOBuf> pop_front(); /** * Total chain length, only valid if cacheLength was specified in the * constructor. */ size_t chainLength() const { if (!options_.cacheChainLength) { throw std::invalid_argument("IOBufQueue: chain length not cached"); } return chainLength_; } /** * Returns true iff the IOBuf chain length is 0. */ bool empty() const { return !head_ || head_->empty(); } const Options& options() const { return options_; } /** * Clear the queue. Note that this does not release the buffers, it * just sets their length to zero; useful if you want to reuse the * same queue without reallocating. */ void clear(); /** Movable */ IOBufQueue(IOBufQueue&&); IOBufQueue& operator=(IOBufQueue&&); private: static const size_t kChainLengthNotCached = (size_t)-1; /** Not copyable */ IOBufQueue(const IOBufQueue&) = delete; IOBufQueue& operator=(const IOBufQueue&) = delete; Options options_; size_t chainLength_; /** Everything that has been appended but not yet discarded or moved out */ std::unique_ptr<folly::IOBuf> head_; }; } // folly #endif // FOLLY_IO_IOBUF_QUEUE_H
[ "sgolemon@fb.com" ]
sgolemon@fb.com
f8d5e6b902ba3ff8901c869fe41699b2078ee755
bbb3e624cc17ac7a6ce280797eb2d2cfad8ea754
/selenium/vagrant-tiennguyen-php-selenium/firefox-sdk/include/nsIDOMCharacterData.h
407469ed8b754b65db940f90541b2f00daa255f9
[]
no_license
Virtual-Machine-Vagrant/TienNguyen-vagrant-env
dff187eaeafc8ca1bb68d81853144d914d6fd293
fe8eaa107dd1a22f07e562937113139c5a4e2687
refs/heads/master
2021-01-13T12:59:28.637343
2017-01-12T08:45:51
2017-01-12T08:45:51
78,718,617
0
0
null
null
null
null
UTF-8
C++
false
false
8,150
h
/* * DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIDOMCharacterData.idl */ #ifndef __gen_nsIDOMCharacterData_h__ #define __gen_nsIDOMCharacterData_h__ #ifndef __gen_nsIDOMNode_h__ #include "nsIDOMNode.h" #endif /* For IDL files that don't want to include root IDL files. */ #ifndef NS_NO_VTABLE #define NS_NO_VTABLE #endif /* starting interface: nsIDOMCharacterData */ #define NS_IDOMCHARACTERDATA_IID_STR "4109a2d2-e7af-445d-bb72-c7c9b875f35e" #define NS_IDOMCHARACTERDATA_IID \ {0x4109a2d2, 0xe7af, 0x445d, \ { 0xbb, 0x72, 0xc7, 0xc9, 0xb8, 0x75, 0xf3, 0x5e }} class NS_NO_VTABLE nsIDOMCharacterData : public nsIDOMNode { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMCHARACTERDATA_IID) /* attribute DOMString data; */ NS_IMETHOD GetData(nsAString & aData) = 0; NS_IMETHOD SetData(const nsAString & aData) = 0; /* readonly attribute unsigned long length; */ NS_IMETHOD GetLength(uint32_t *aLength) = 0; /* DOMString substringData (in unsigned long offset, in unsigned long count) raises (DOMException); */ NS_IMETHOD SubstringData(uint32_t offset, uint32_t count, nsAString & _retval) = 0; /* void appendData (in DOMString arg) raises (DOMException); */ NS_IMETHOD AppendData(const nsAString & arg) = 0; /* void insertData (in unsigned long offset, in DOMString arg) raises (DOMException); */ NS_IMETHOD InsertData(uint32_t offset, const nsAString & arg) = 0; /* void deleteData (in unsigned long offset, in unsigned long count) raises (DOMException); */ NS_IMETHOD DeleteData(uint32_t offset, uint32_t count) = 0; /* void replaceData (in unsigned long offset, in unsigned long count, in DOMString arg) raises (DOMException); */ NS_IMETHOD ReplaceData(uint32_t offset, uint32_t count, const nsAString & arg) = 0; /* [binaryname(MozRemove)] void remove (); */ NS_IMETHOD MozRemove(void) = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMCharacterData, NS_IDOMCHARACTERDATA_IID) /* Use this macro when declaring classes that implement this interface. */ #define NS_DECL_NSIDOMCHARACTERDATA \ NS_IMETHOD GetData(nsAString & aData) override; \ NS_IMETHOD SetData(const nsAString & aData) override; \ NS_IMETHOD GetLength(uint32_t *aLength) override; \ NS_IMETHOD SubstringData(uint32_t offset, uint32_t count, nsAString & _retval) override; \ NS_IMETHOD AppendData(const nsAString & arg) override; \ NS_IMETHOD InsertData(uint32_t offset, const nsAString & arg) override; \ NS_IMETHOD DeleteData(uint32_t offset, uint32_t count) override; \ NS_IMETHOD ReplaceData(uint32_t offset, uint32_t count, const nsAString & arg) override; \ NS_IMETHOD MozRemove(void) override; /* Use this macro when declaring the members of this interface when the class doesn't implement the interface. This is useful for forwarding. */ #define NS_DECL_NON_VIRTUAL_NSIDOMCHARACTERDATA \ NS_METHOD GetData(nsAString & aData); \ NS_METHOD SetData(const nsAString & aData); \ NS_METHOD GetLength(uint32_t *aLength); \ NS_METHOD SubstringData(uint32_t offset, uint32_t count, nsAString & _retval); \ NS_METHOD AppendData(const nsAString & arg); \ NS_METHOD InsertData(uint32_t offset, const nsAString & arg); \ NS_METHOD DeleteData(uint32_t offset, uint32_t count); \ NS_METHOD ReplaceData(uint32_t offset, uint32_t count, const nsAString & arg); \ NS_METHOD MozRemove(void); /* Use this macro to declare functions that forward the behavior of this interface to another object. */ #define NS_FORWARD_NSIDOMCHARACTERDATA(_to) \ NS_IMETHOD GetData(nsAString & aData) override { return _to GetData(aData); } \ NS_IMETHOD SetData(const nsAString & aData) override { return _to SetData(aData); } \ NS_IMETHOD GetLength(uint32_t *aLength) override { return _to GetLength(aLength); } \ NS_IMETHOD SubstringData(uint32_t offset, uint32_t count, nsAString & _retval) override { return _to SubstringData(offset, count, _retval); } \ NS_IMETHOD AppendData(const nsAString & arg) override { return _to AppendData(arg); } \ NS_IMETHOD InsertData(uint32_t offset, const nsAString & arg) override { return _to InsertData(offset, arg); } \ NS_IMETHOD DeleteData(uint32_t offset, uint32_t count) override { return _to DeleteData(offset, count); } \ NS_IMETHOD ReplaceData(uint32_t offset, uint32_t count, const nsAString & arg) override { return _to ReplaceData(offset, count, arg); } \ NS_IMETHOD MozRemove(void) override { return _to MozRemove(); } /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ #define NS_FORWARD_SAFE_NSIDOMCHARACTERDATA(_to) \ NS_IMETHOD GetData(nsAString & aData) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetData(aData); } \ NS_IMETHOD SetData(const nsAString & aData) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetData(aData); } \ NS_IMETHOD GetLength(uint32_t *aLength) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetLength(aLength); } \ NS_IMETHOD SubstringData(uint32_t offset, uint32_t count, nsAString & _retval) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SubstringData(offset, count, _retval); } \ NS_IMETHOD AppendData(const nsAString & arg) override { return !_to ? NS_ERROR_NULL_POINTER : _to->AppendData(arg); } \ NS_IMETHOD InsertData(uint32_t offset, const nsAString & arg) override { return !_to ? NS_ERROR_NULL_POINTER : _to->InsertData(offset, arg); } \ NS_IMETHOD DeleteData(uint32_t offset, uint32_t count) override { return !_to ? NS_ERROR_NULL_POINTER : _to->DeleteData(offset, count); } \ NS_IMETHOD ReplaceData(uint32_t offset, uint32_t count, const nsAString & arg) override { return !_to ? NS_ERROR_NULL_POINTER : _to->ReplaceData(offset, count, arg); } \ NS_IMETHOD MozRemove(void) override { return !_to ? NS_ERROR_NULL_POINTER : _to->MozRemove(); } #if 0 /* Use the code below as a template for the implementation class for this interface. */ /* Header file */ class nsDOMCharacterData : public nsIDOMCharacterData { public: NS_DECL_ISUPPORTS NS_DECL_NSIDOMCHARACTERDATA nsDOMCharacterData(); private: ~nsDOMCharacterData(); protected: /* additional members */ }; /* Implementation file */ NS_IMPL_ISUPPORTS(nsDOMCharacterData, nsIDOMCharacterData) nsDOMCharacterData::nsDOMCharacterData() { /* member initializers and constructor code */ } nsDOMCharacterData::~nsDOMCharacterData() { /* destructor code */ } /* attribute DOMString data; */ NS_IMETHODIMP nsDOMCharacterData::GetData(nsAString & aData) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP nsDOMCharacterData::SetData(const nsAString & aData) { return NS_ERROR_NOT_IMPLEMENTED; } /* readonly attribute unsigned long length; */ NS_IMETHODIMP nsDOMCharacterData::GetLength(uint32_t *aLength) { return NS_ERROR_NOT_IMPLEMENTED; } /* DOMString substringData (in unsigned long offset, in unsigned long count) raises (DOMException); */ NS_IMETHODIMP nsDOMCharacterData::SubstringData(uint32_t offset, uint32_t count, nsAString & _retval) { return NS_ERROR_NOT_IMPLEMENTED; } /* void appendData (in DOMString arg) raises (DOMException); */ NS_IMETHODIMP nsDOMCharacterData::AppendData(const nsAString & arg) { return NS_ERROR_NOT_IMPLEMENTED; } /* void insertData (in unsigned long offset, in DOMString arg) raises (DOMException); */ NS_IMETHODIMP nsDOMCharacterData::InsertData(uint32_t offset, const nsAString & arg) { return NS_ERROR_NOT_IMPLEMENTED; } /* void deleteData (in unsigned long offset, in unsigned long count) raises (DOMException); */ NS_IMETHODIMP nsDOMCharacterData::DeleteData(uint32_t offset, uint32_t count) { return NS_ERROR_NOT_IMPLEMENTED; } /* void replaceData (in unsigned long offset, in unsigned long count, in DOMString arg) raises (DOMException); */ NS_IMETHODIMP nsDOMCharacterData::ReplaceData(uint32_t offset, uint32_t count, const nsAString & arg) { return NS_ERROR_NOT_IMPLEMENTED; } /* [binaryname(MozRemove)] void remove (); */ NS_IMETHODIMP nsDOMCharacterData::MozRemove() { return NS_ERROR_NOT_IMPLEMENTED; } /* End of implementation class template. */ #endif #endif /* __gen_nsIDOMCharacterData_h__ */
[ "mac-l011@mac-l011s-MacBook-Pro-2.local" ]
mac-l011@mac-l011s-MacBook-Pro-2.local
a162d87099d1269563d04bc3d51f85c6a83570a7
8959cdaf3e8f3259f303e50e2fd9e78b9ea318c7
/dorf.h
994810d504a71a977784148832a0435cf6884509
[]
no_license
FFaser/TW2AttackPlanner
4bf9da9c0d23bebfaba9ce1617863a5db0819fa9
95853c3ced072308edd7d5b9b2a711fec1b0c317
refs/heads/master
2021-04-12T10:48:53.056128
2016-07-27T13:39:30
2016-07-27T13:39:30
64,309,904
0
0
null
null
null
null
UTF-8
C++
false
false
1,986
h
#ifndef DORF_H #define DORF_H #include <QObject> //#include <QMetaEnum> #include <QStringList> #include <QList> #include <QMessageBox> enum eDorfState{ undefined, active , ontheway, eDorfState_MAX = ontheway}; enum eDorfMark{ empty = 0, mark1 = 1 << 0, mark2 = 1 << 1, mark3 = 1 << 2, mark4 = 1 << 3, mark5 = 1 << 4, mark6 = 1 << 5, mark7 = 1 << 6, mark8 = 1 << 7, mark9 = 1 << 8, mark10 = 1 << 9, eDorfMark_MAX = mark10}; namespace helpers { QList<eDorfMark> uintMarkToFlags(uint Mark); eDorfMark uintToeDorfMark(uint Mark); uint eDorfMarkToUint(eDorfMark Mark); } class Dorf { public: Dorf(); Dorf(QString DorfName, int X, int Y ); Dorf(QString DorfName, int X, int Y, uint Marks, int State ); Dorf(const Dorf *dorf); void set(QString DorfName, int X, int Y); void set(QString DorfName, int X, int Y, uint Marks, int State); bool isInitializedProperly(); QString getDorfName()const; int getX()const; int getY()const; void setDorfName(QString DorfName); void setX(int X); void setY(int Y); void setSpeed(double C); double getSpeed() const; void setSlowestSpeed(); void setNextSlowestMarksAndSpeedFrom(eDorfMark Mark); static bool equals(Dorf A, Dorf B); eDorfState getState() const ; eDorfMark getMark() const; uint getMarks() const; void setState(eDorfState DorfState); void setMark(eDorfMark Mark); //WARNING think how to init this void setMarks(uint DorfMark); static double eDorfMarkToSpeed(eDorfMark Mark); private: QString dorfName; int x; int y; bool isInitialized; eDorfState dorfState; eDorfMark tempDorfMark; uint dorfMarks; double c = 0; }; #endif // DORF_H
[ "polka@gmx.net" ]
polka@gmx.net
302ddf89f942e3ecefaf58d379ed1c55dd8eec7e
88a7edbe0a2a2a12de392da8fa43ace9fae7ace5
/StudioProject3/Base/Source/SkyBox/SkyBoxEntity.cpp
8339da52df4e0492341e8e3ce89a34c5477ff69d
[]
no_license
hotaru08/Studio-Proj-3
9fed81cf23d3fcabae33a6a1a90e717c89b455e8
f014fc00b3a4260ea82cd05aed7aee39233ed317
refs/heads/master
2021-01-16T21:24:43.742812
2017-08-30T02:14:57
2017-08-30T02:14:57
100,228,937
0
3
null
null
null
null
UTF-8
C++
false
false
3,797
cpp
#include "SkyBoxEntity.h" #include "MeshBuilder.h" #include "../EntityManager.h" #include "GraphicsManager.h" #include "RenderHelper.h" SkyBoxEntity::SkyBoxEntity(void) : size(1000.0f, 1000.0f, 1000.0f) , m_bBoundaryDefined(false) { } SkyBoxEntity::~SkyBoxEntity() { } void SkyBoxEntity::Update(double _dt) { // Does nothing here, can inherit & override or create your own version of this class :D } void SkyBoxEntity::Render() { MS& modelStack = GraphicsManager::GetInstance()->GetModelStack(); modelStack.PushMatrix(); // Front modelStack.PushMatrix(); modelStack.Translate(0, 0, -size.z / 2 - 250.f); modelStack.Scale(size.x, size.y, size.z); RenderHelper::RenderMesh(modelMesh[FRONT]); modelStack.PopMatrix(); // Back modelStack.PushMatrix(); modelStack.Rotate(180, 0, 1, 0); modelStack.Translate(0, 0, -size.z / 2 - 250.f); modelStack.Scale(size.x, size.y, size.z); RenderHelper::RenderMesh(modelMesh[BACK]); modelStack.PopMatrix(); // Left modelStack.PushMatrix(); modelStack.Rotate(-90, 0, 1, 0); modelStack.Translate(0, 0, -size.z / 2); modelStack.Scale(size.x + 500, size.y, size.z); RenderHelper::RenderMesh(modelMesh[LEFT]); modelStack.PopMatrix(); // Right modelStack.PushMatrix(); modelStack.Rotate(90, 0, 1, 0); modelStack.Translate(0, 0, -size.z / 2); modelStack.Scale(size.x + 500, size.y, size.z); RenderHelper::RenderMesh(modelMesh[RIGHT]); modelStack.PopMatrix(); // Top modelStack.PushMatrix(); modelStack.Rotate(90, 1, 0, 0); modelStack.Translate(0, 0, -size.z / 2); modelStack.Rotate(-90, 0, 0, 1); modelStack.Scale(size.x + 500, size.y, size.z); RenderHelper::RenderMesh(modelMesh[TOP]); modelStack.PopMatrix(); // Bottom modelStack.PushMatrix(); modelStack.Rotate(-90, 1, 0, 0); modelStack.Translate(0, 0, -size.z / 2); modelStack.Rotate(90, 0, 0, 1); modelStack.Scale(size.x, size.y, size.z); RenderHelper::RenderMesh(modelMesh[BOTTOM]); modelStack.PopMatrix(); modelStack.PopMatrix(); } // Set a mesh to this class void SkyBoxEntity::SetMesh(const int _side, Mesh* _modelMesh) { modelMesh[_side] = _modelMesh; } Vector3 SkyBoxEntity::GetBoundary(void) { if (!m_bBoundaryDefined) { boundary = Vector3( position.x - (size.x*scale.x) / 2.0f, position.y - (size.y*scale.y) / 2.0f, position.z - (size.z*scale.z) / 2.0f); m_bBoundaryDefined = true; } return boundary; }; SkyBoxEntity* Create::SkyBox( const std::string& _meshName0, const std::string& _meshName1, const std::string& _meshName2, const std::string& _meshName3, const std::string& _meshName4, const std::string& _meshName5) { Mesh* modelMesh0 = MeshBuilder::GetInstance()->GetMesh(_meshName0); if (modelMesh0 == nullptr) return nullptr; Mesh* modelMesh1 = MeshBuilder::GetInstance()->GetMesh(_meshName1); if (modelMesh1 == nullptr) return nullptr; Mesh* modelMesh2 = MeshBuilder::GetInstance()->GetMesh(_meshName2); if (modelMesh2 == nullptr) return nullptr; Mesh* modelMesh3 = MeshBuilder::GetInstance()->GetMesh(_meshName3); if (modelMesh3 == nullptr) return nullptr; Mesh* modelMesh4 = MeshBuilder::GetInstance()->GetMesh(_meshName4); if (modelMesh4 == nullptr) return nullptr; Mesh* modelMesh5 = MeshBuilder::GetInstance()->GetMesh(_meshName5); if (modelMesh5 == nullptr) return nullptr; SkyBoxEntity* result = new SkyBoxEntity(); result->SetMesh(SkyBoxEntity::FRONT, modelMesh0); result->SetMesh(SkyBoxEntity::BACK, modelMesh1); result->SetMesh(SkyBoxEntity::LEFT, modelMesh2); result->SetMesh(SkyBoxEntity::RIGHT, modelMesh3); result->SetMesh(SkyBoxEntity::TOP, modelMesh4); result->SetMesh(SkyBoxEntity::BOTTOM, modelMesh5); EntityManager::GetInstance()->AddEntity(result); return result; }
[ "lzyjeann@gmail.com" ]
lzyjeann@gmail.com
60cf8160aa7d5e951c1f5a6de03c6c66c1b73c41
902e56e5eb4dcf96da2b8c926c63e9a0cc30bf96
/Sources/Tools/EPI/Document/Properties/PtyMaterial.moc.h
1114d4e9d7e6c205e1b9fc7abb2a457b96e09811
[ "BSD-3-Clause" ]
permissive
benkaraban/anima-games-engine
d4e26c80f1025dcef05418a071c0c9cbd18a5670
8aa7a5368933f1b82c90f24814f1447119346c3b
refs/heads/master
2016-08-04T18:31:46.790039
2015-03-22T08:13:55
2015-03-22T08:13:55
32,633,432
2
0
null
null
null
null
UTF-8
C++
false
false
9,766
h
/* * Copyright (c) 2010, Anima Games, Benjamin Karaban, Laurent Schneider, * Jérémie Comarmond, Didier Colin. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef EPI_PROPERTY_MATERIAL_H_ #define EPI_PROPERTY_MATERIAL_H_ #include <QWidget> #include <QGridLayout> #include <QCheckBox> #include <EPI/Document/PropertyNode.moc.h> #include <EPI/Document/PropertyWidget.moc.h> #include <Universe/NodeMesh.h> #include <Universe/NodeSkeleton.h> namespace QtToolbox { class CollapsibleWidget; class QuickColorPicker; class SingleSlidingDouble; class ComboBox; class SingleSlidingHDR; }//namespace QtToolbox namespace EPI { class CustomLine; class PtyWidgetMaterial; //----------------------------------------------------------------------------- LM_ENUM_2 (EPtyMaterialDataType, MATERIAL_DATA_NODE_MESH, MATERIAL_DATA_SKELETON_SKIN) class LM_API_EPI PtyMaterial : public PropertyNode { Q_OBJECT friend class PtyWidgetMaterial; public: //constraucteur pour modifier le material d'un nodeMesh PtyMaterial(const Ptr<Universe::RessourcePool>& pRessourcePool, const Core::List<Ptr<Universe::NodeMesh> >& pNodesM, const Core::String& title = L"Material", bool isSelectable = true); //constructeur pour modifier le material d'un SkeletonSkin PtyMaterial(const Ptr<Universe::RessourcePool>& pRessourcePool, const Core::List<Ptr<Universe::SkeletonSkin> >& pSkin, const Core::String& title = L"Material", bool isSelectable = true); virtual ~PtyMaterial(); virtual Ptr<PropertyWidget> internalCreatePropertyWidget(const Ptr<PropertyWidgetDataProxy>& pDtaProxy, QWidget * parent = 0); virtual void updateData(); void updateProperty(); virtual Ptr<Property> clone() const; virtual void internalCopy(const Ptr<Property>& pSrc); void setNodeMesh(const Ptr<Universe::NodeMesh>& pNodeM, bool keepPtyMaterial = false); void copy(Assets::Material& mat); virtual bool isIntersecting(const Core::Rayf& ray, float& distance); void setBoundingBoxVisible(bool visible); Core::AABoxf getBoundingBox() const; virtual EPropertyClassName getCalssName() const {return PTY_MATERIAL;} virtual String getIconFileName() {return L":/icons/ptyMaterial.png";} private: void setDataMaterial (const Renderer::Material & material); const Renderer::Material& getDataMaterial(); void setDataDiffuseTexture (const String & texName); void setDataSpecularTexture (const String & texName); void setDataNormalTexture (const String & texName); void setDataLightTexture (const String & texName); void setDataCustomTexture0 (const String & texName); void setDataCustomTexture1 (const String & texName); void setDataCustomTexture2 (const String & texName); public: void getDataDiffuseTexture (String & texName); void getDataSpecularTexture (String & texName); void getDataNormalTexture (String & texName); void getDataLightTexture (String & texName); void getDataCustomTexture0 (String & texName); void getDataCustomTexture1 (String & texName); void getDataCustomTexture2 (String & texName); private: Ptr<Universe::RessourcePool> _pRessourcePool; Core::List<Ptr<Universe::NodeMesh> > _pNodesM; Core::List<Ptr<Universe::SkeletonSkin> > _pSkins; Core::List<Ptr<Universe::Node> > _pNodes; EPtyMaterialDataType _dataType; Assets::EMaterialType _matType; bool _translucidTexture; bool _clampTextureBorder; String _diffuseTex; String _specularTex; String _normalTex; Core::Vector4f _emissive; Core::Vector4f _diffuse; Core::Vector4f _specular; double _shininess; Core::Vector4f _glow; Core::Vector4f _reflexions; double _glowExtent; Core::Vector4f _refracColor; double _refracScale; double _refracIndex; bool _dynamicShadowCaster; bool _dynamicShadowReceiver; //Custom String _texture0Name; String _texture1Name; String _texture2Name; Assets::ECustomMode _customMode; Core::Vector4f _customColor; float _colorFactor; float _glowFactor; Assets::EOperationType _opColor01; Assets::EOperationType _opColor12; Core::Vector2f _duv0; Core::Vector2f _duv1; Core::Vector2f _duv2; }; //----------------------------------------------------------------------------- class LM_API_EPI PtyWidgetMaterial : public PropertyWidget { Q_OBJECT friend class PtyMaterial; friend class PtyWidgetModel; public: PtyWidgetMaterial(const Ptr<PropertyWidgetDataProxy>& data, QWidget * parent = 0); virtual ~PtyWidgetMaterial(); void readProperty(); void writeProperty(QWidget* pWidget); void setupUi(); void showMaterialParameter(); private: void showMaterialStandard(bool flag); void showMaterialCustom(bool flag); private: QGridLayout * _layout; QtToolbox::CollapsibleWidget * _groupBox; QtToolbox::ComboBox * _matType; QCheckBox * _translucidTexture; QCheckBox * _clampTextureBorder; QCheckBox * _dynamicShadowCaster; QCheckBox * _dynamicShadowReceiver; CustomLine * _diffuseTex; CustomLine * _specularTex; CustomLine * _normalTex; QtToolbox::QuickColorPicker * _emissive; QtToolbox::QuickColorPicker * _diffuse; QtToolbox::QuickColorPicker * _specular; QtToolbox::SingleSlidingDouble* _shininess; QtToolbox::QuickColorPicker * _glow; QtToolbox::QuickColorPicker * _reflexions; QtToolbox::SingleSlidingDouble* _glowExtent; QtToolbox::QuickColorPicker * _refracColor; QtToolbox::SingleSlidingDouble* _refracScale; QtToolbox::SingleSlidingDouble* _refracIndex; CustomLine * _customTex0; CustomLine * _customTex1; CustomLine * _customTex2; QtToolbox::ComboBox * _customMode; QtToolbox::QuickColorPicker * _customColor; QtToolbox::SingleSlidingDouble* _colorFactor; QtToolbox::SingleSlidingDouble* _glowFactor; QtToolbox::ComboBox * _opColor01; QtToolbox::ComboBox * _opColor12; QtToolbox::SingleSlidingHDR* _duv0_X; QtToolbox::SingleSlidingHDR* _duv1_X; QtToolbox::SingleSlidingHDR* _duv2_X; QtToolbox::SingleSlidingHDR* _duv0_Y; QtToolbox::SingleSlidingHDR* _duv1_Y; QtToolbox::SingleSlidingHDR* _duv2_Y; }; //----------------------------------------------------------------------------- } // namespace EPI #endif /*EPI_PROPERTY_MATERIAL_H_*/
[ "contact@anima-games.com@bd273c4a-bd8d-77bb-0e36-6aa87360798c" ]
contact@anima-games.com@bd273c4a-bd8d-77bb-0e36-6aa87360798c
824ed6266cacf3f5227db633302ca5b83f4bd47c
fbc3ee4467922e3a01aaef61af33ad0a79e6a8df
/Algorithms/sorting/bubble_Sort.cpp
1d092c8838a990ea7ca35e3213e0d27a68a0bd37
[]
no_license
snh3003/CB-Master-Course
9c5026c65ae02dd6114946981f08faff97501fc1
fd6599fce1463c68fc4c2c1fa3552718fdd43b24
refs/heads/master
2023-08-24T12:41:38.067743
2021-09-30T07:17:36
2021-09-30T07:17:36
288,263,538
0
0
null
null
null
null
UTF-8
C++
false
false
633
cpp
#include<bits/stdc++.h> using namespace std; void bubble_sort(vector<int> &v, int n){ // run a loop from 0 to n-1 as the last element always gets sorted for(int i=0; i<(n-1); i++){ // loop runs from 0 to (n-i-1) to check the unsorted part for(int j=0; j<(n-i-1); j++){ if(v[j] > v[j+1]){ // pairwise swap swap(v[j], v[j+1]); } } } } int main(){ int n, ip; cin>>n; vector<int> v; for(int i=0; i<n; i++){ cin>>ip; v.push_back(ip); } bubble_sort(v, n); for(auto x: v){ cout<<x<<" "; } }
[ "shahsama542@gmail.com" ]
shahsama542@gmail.com
01a60db1be3cd7e76e3e51f9a57d2b983da1c57b
3c325c073ae1f04ac71e20a9f3c083b81ef30cef
/Source/AdvGameProgProject/Private/AI/STrackerBot.cpp
8ad51a8418cc1cf4fcefeb8dba08dd2a3533083b
[]
no_license
JustinRobbins7/AdvGraphicsSemesterProject
0b4b946d9bd9bea2e6fff6ea1d1612bd35be1509
a9d36c996181a46cd5b3c89776314166dd6b7c36
refs/heads/master
2020-03-29T18:03:28.327704
2018-10-04T17:06:56
2018-10-04T17:06:56
150,192,528
0
0
null
null
null
null
UTF-8
C++
false
false
2,203
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "AI/STrackerBot.h" #include "Components/StaticMeshComponent.h" #include "Kismet/GameplayStatics.h" #include "AI/Navigation/NavigationSystem.h" #include "AI/Navigation/NavigationPath.h" #include "GameFramework/Character.h" #include "DrawDebugHelpers.h" // Sets default values ASTrackerBot::ASTrackerBot() { // Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp")); RootComponent = MeshComp; MeshComp->SetCanEverAffectNavigation(false); MeshComp->SetSimulatePhysics(true); bUseVelocityChange = true; MovementForce = 1000; RequiredDistanceToTarget = 100; } // Called when the game starts or when spawned void ASTrackerBot::BeginPlay() { Super::BeginPlay(); //Find initial move to NextPathPoint = GetNextPathPoint(); } FVector ASTrackerBot::GetNextPathPoint() { //Hack to get player location ACharacter* PlayerPawn = UGameplayStatics::GetPlayerCharacter(this, 0); UNavigationPath* NavPath = UNavigationSystem::FindPathToActorSynchronously(this, GetActorLocation(), PlayerPawn); if (NavPath->PathPoints.Num() > 1) { //Return next point in path return NavPath->PathPoints[1]; } return GetActorLocation(); } // Called every frame void ASTrackerBot::Tick(float DeltaTime) { Super::Tick(DeltaTime); float DistanceToTarget = (GetActorLocation() - NextPathPoint).Size(); if (DistanceToTarget <= RequiredDistanceToTarget) { NextPathPoint = GetNextPathPoint(); DrawDebugString(GetWorld(), GetActorLocation(), "Target Reached!"); } else { //Keep moving towards next target FVector ForceDirection = NextPathPoint - GetActorLocation(); ForceDirection.Normalize(); ForceDirection *= MovementForce; MeshComp->AddForce(ForceDirection, NAME_None, bUseVelocityChange); DrawDebugDirectionalArrow(GetWorld(), GetActorLocation(), GetActorLocation() + ForceDirection, 32, FColor::Orange, false, 0.0f, 0, 1.0f); } DrawDebugSphere(GetWorld(), NextPathPoint, 20, 12, FColor::Orange, false, 0.0f, 1.0f); }
[ "robbinsju@gmail.com" ]
robbinsju@gmail.com
eb07b041fa0259d2c4c79379b3437e0a385b15fa
090243cf699213f32f870baf2902eb4211f825d6
/CDOJ/Contest/56/A.cpp
5743875ae3269ae4c7662747b643546e1d97e8e0
[]
no_license
zhu-he/ACM-Source
0d4d0ac0668b569846b12297e7ed4abbb1c16571
02e3322e50336063d0d2dad37b2761ecb3d4e380
refs/heads/master
2021-06-07T18:27:19.702607
2016-07-10T09:20:48
2016-07-10T09:20:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,218
cpp
#include <cstdio> #include <cstring> #include <queue> #include <vector> #include <algorithm> #include <map> using namespace std; struct Node { long long w; int p; bool operator < (const Node rhs) const { return w > rhs.w || (w == rhs.w && p < rhs.p); } }; int n, m; vector<pair<int, int> > G[100000]; int s, e, p1, p2, K; bool vis[100000]; long long solve(int from, int to) { priority_queue<Node> q; q.push((Node) {0, from}); while (!q.empty()) { Node p = q.top(); q.pop(); if (p.p == to) { return p.w; } vis[p.p] = true; for (int i = 0; i < G[p.p].size(); ++i) { int v = G[p.p][i].first; if (!vis[v]) { int w = G[p.p][i].second; Node t; t.p = v; t.w = p.w + w; q.push(t); } } } return -1; } int main() { int T; scanf("%d", &T); for (int kase = 1; kase <= T; ++kase) { scanf("%d %d", &n, &m); for (int i = 0; i < n; ++i) { G[i].clear(); } map<pair<int, int>, int> roads; for (int i = 0; i < m; ++i) { int x, y, w; scanf("%d %d %d", &x, &y, &w); if (x > y) { swap(x, y); } pair<int, int> p = make_pair(x, y); if ((roads.count(p) && roads[p] > w) || !roads.count(p)) { roads[p] = w; } } for (map<pair<int, int>, int>::iterator i = roads.begin(); i != roads.end(); ++i) { int x = i->first.first; int y = i->first.second; int w = i->second; G[x].push_back(make_pair(y, w)); G[y].push_back(make_pair(x, w)); } scanf("%d %d %d %d %d", &s, &e, &p1, &p2, &K); memset(vis, 0, sizeof(vis)); vis[p1] = true; long long se = solve(s, e); memset(vis, 0, sizeof(vis)); long long sp1 = solve(s, p1); memset(vis, 0, sizeof(vis)); long long p2e = solve(p2, e); memset(vis, 0, sizeof(vis)); long long p1p2 = solve(p1, p2); memset(vis, 0, sizeof(vis)); vis[p1] = true; long long _p2e = solve(p2, e); long long ans = -1; if (se != -1 && p1 != s) { ans = se; } if (sp1 != -1 && p1p2 != -1 && p2e != -1 && (ans == -1 || ans > sp1 + p1p2 * (K - 1) + p2e)) { ans = sp1 + p1p2 * (K - 1) + p2e; } if (sp1 != -1 && _p2e != -1 && (ans == -1 || ans > sp1 + _p2e)) { ans = sp1 + _p2e; } printf("Case #%d: %lld\n", kase, ans); } return 0; }
[ "841815229@qq.com" ]
841815229@qq.com
787a335ab571e25147cea1ddf7d1b724e635d773
3c6ed046eda83e35ab754883a59dcb7099233b39
/components/password_manager/core/browser/password_generation_state_unittest.cc
1e4a5ac7bb1f0dd236d57460cf0cecfdbf6047b7
[ "BSD-3-Clause" ]
permissive
ssln2014/chromium
66c5021c8893313dee78b963082cbdf948bd2d6a
4bad77148cc4a36373e40cf985444bc649c0eeff
refs/heads/master
2023-03-06T03:21:39.801883
2019-06-08T16:11:10
2019-06-08T16:11:10
190,914,348
1
0
BSD-3-Clause
2019-06-08T17:08:38
2019-06-08T17:08:38
null
UTF-8
C++
false
false
14,480
cc
// Copyright 2019 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 "components/password_manager/core/browser/password_generation_state.h" #include "base/memory/scoped_refptr.h" #include "base/strings/utf_string_conversions.h" #include "base/test/scoped_task_environment.h" #include "base/test/simple_test_clock.h" #include "components/password_manager/core/browser/form_saver_impl.h" #include "components/password_manager/core/browser/mock_password_store.h" #include "components/password_manager/core/browser/stub_password_manager_client.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" namespace password_manager { namespace { using autofill::PasswordForm; using base::ASCIIToUTF16; using testing::_; constexpr char kURL[] = "https://example.in/login"; constexpr char kSubdomainURL[] = "https://m.example.in/login"; constexpr time_t kTime = 123456789; constexpr time_t kAnotherTime = 987654321; // Creates a dummy saved credential. PasswordForm CreateSaved() { PasswordForm form; form.origin = GURL(kURL); form.signon_realm = form.origin.spec(); form.action = GURL("https://login.example.org"); form.username_value = ASCIIToUTF16("old_username"); form.password_value = ASCIIToUTF16("12345"); return form; } // Creates a dummy saved PSL credential. PasswordForm CreateSavedPSL() { PasswordForm form; form.origin = GURL(kSubdomainURL); form.signon_realm = form.origin.spec(); form.action = GURL("https://login.example.org"); form.username_value = ASCIIToUTF16("old_username2"); form.password_value = ASCIIToUTF16("passw0rd"); form.is_public_suffix_match = true; return form; } // Creates a dummy generated password. PasswordForm CreateGenerated() { PasswordForm form; form.origin = GURL(kURL); form.signon_realm = form.origin.spec(); form.action = GURL("https://signup.example.org"); form.username_value = ASCIIToUTF16("MyName"); form.password_value = ASCIIToUTF16("Strong password"); form.preferred = true; form.type = autofill::PasswordForm::Type::kGenerated; return form; } MATCHER_P(FormHasUniqueKey, key, "") { return ArePasswordFormUniqueKeysEqual(arg, key); } class PasswordGenerationStateTest : public testing::Test { public: PasswordGenerationStateTest(); ~PasswordGenerationStateTest() override; MockPasswordStore& store() { return *mock_store_; } PasswordGenerationState& state() { return generation_state_; } FormSaverImpl& form_saver() { return form_saver_; } StubPasswordManagerClient& client() { return client_; } private: // For the MockPasswordStore. base::test::ScopedTaskEnvironment task_environment_; scoped_refptr<MockPasswordStore> mock_store_; // Test with the real form saver for better robustness. FormSaverImpl form_saver_; StubPasswordManagerClient client_; PasswordGenerationState generation_state_; }; PasswordGenerationStateTest::PasswordGenerationStateTest() : mock_store_(new testing::StrictMock<MockPasswordStore>()), form_saver_(mock_store_.get()), generation_state_(&form_saver_, &client_) { auto clock = std::make_unique<base::SimpleTestClock>(); clock->SetNow(base::Time::FromTimeT(kTime)); generation_state_.set_clock(std::move(clock)); } PasswordGenerationStateTest::~PasswordGenerationStateTest() { mock_store_->ShutdownOnUIThread(); } // Check that presaving a password for the first time results in adding it. TEST_F(PasswordGenerationStateTest, PresaveGeneratedPassword_New) { const PasswordForm generated = CreateGenerated(); PasswordForm generated_with_date = generated; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), AddLogin(generated_with_date)); state().PresaveGeneratedPassword(generated, {}); EXPECT_TRUE(state().HasGeneratedPassword()); } // Check that presaving a password for the second time results in updating it. TEST_F(PasswordGenerationStateTest, PresaveGeneratedPassword_Replace) { PasswordForm generated = CreateGenerated(); PasswordForm generated_with_date = generated; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), AddLogin(generated_with_date)); state().PresaveGeneratedPassword(generated, {}); PasswordForm generated_updated = generated; generated_updated.password_value = ASCIIToUTF16("newgenpwd"); generated_with_date = generated_updated; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), UpdateLoginWithPrimaryKey(generated_with_date, FormHasUniqueKey(generated))); state().PresaveGeneratedPassword(generated_updated, {}); EXPECT_TRUE(state().HasGeneratedPassword()); } // Check that presaving a password for the third time results in updating it. TEST_F(PasswordGenerationStateTest, PresaveGeneratedPassword_ReplaceTwice) { PasswordForm generated = CreateGenerated(); PasswordForm generated_with_date = generated; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), AddLogin(generated_with_date)); state().PresaveGeneratedPassword(generated, {}); PasswordForm generated_updated = generated; generated_updated.password_value = ASCIIToUTF16("newgenpwd"); generated_with_date = generated_updated; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), UpdateLoginWithPrimaryKey(generated_with_date, FormHasUniqueKey(generated))); state().PresaveGeneratedPassword(generated_updated, {}); generated = generated_updated; generated_updated.password_value = ASCIIToUTF16("newgenpwd2"); generated_updated.username_value = ASCIIToUTF16("newusername"); generated_with_date = generated_updated; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), UpdateLoginWithPrimaryKey(generated_with_date, FormHasUniqueKey(generated))); state().PresaveGeneratedPassword(generated_updated, {}); EXPECT_TRUE(state().HasGeneratedPassword()); } // Check that presaving a password with a known username results in clearing the // username. TEST_F(PasswordGenerationStateTest, PresaveGeneratedPassword_WithConflict) { const PasswordForm generated = CreateGenerated(); PasswordForm saved = CreateSaved(); saved.username_value = generated.username_value; PasswordForm generated_with_date = generated; generated_with_date.date_created = base::Time::FromTimeT(kTime); generated_with_date.username_value.clear(); EXPECT_CALL(store(), AddLogin(generated_with_date)); state().PresaveGeneratedPassword(generated, {&saved}); EXPECT_TRUE(state().HasGeneratedPassword()); } // Check that presaving a password with an unknown username saves it as is. TEST_F(PasswordGenerationStateTest, PresaveGeneratedPassword_WithoutConflict) { const PasswordForm generated = CreateGenerated(); PasswordForm generated_with_date = generated; generated_with_date.date_created = base::Time::FromTimeT(kTime); const PasswordForm saved = CreateSaved(); EXPECT_CALL(store(), AddLogin(generated_with_date)); state().PresaveGeneratedPassword(generated, {&saved}); EXPECT_TRUE(state().HasGeneratedPassword()); } // Check that presaving a password followed by a call to save a pending // credential (as new) results in replacing the presaved password with the // pending one. TEST_F(PasswordGenerationStateTest, PresaveGeneratedPassword_ThenSaveAsNew) { const PasswordForm generated = CreateGenerated(); EXPECT_CALL(store(), AddLogin(_)); state().PresaveGeneratedPassword(generated, {}); // User edits after submission. PasswordForm pending = generated; pending.password_value = ASCIIToUTF16("edited_password"); pending.username_value = ASCIIToUTF16("edited_username"); PasswordForm generated_with_date = pending; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), UpdateLoginWithPrimaryKey(generated_with_date, FormHasUniqueKey(generated))); state().CommitGeneratedPassword(pending, {} /* matches */, base::string16() /* old_password */); EXPECT_TRUE(state().HasGeneratedPassword()); } // Check that presaving a password followed by a call to save a pending // credential (as update) results in replacing the presaved password with the // pending one. TEST_F(PasswordGenerationStateTest, PresaveGeneratedPassword_ThenUpdate) { PasswordForm generated = CreateGenerated(); PasswordForm related_password = CreateSaved(); related_password.username_value = ASCIIToUTF16("username"); related_password.username_element = ASCIIToUTF16("username_field"); related_password.password_value = ASCIIToUTF16("old password"); PasswordForm related_psl_password = CreateSavedPSL(); related_psl_password.username_value = ASCIIToUTF16("username"); related_psl_password.password_value = ASCIIToUTF16("old password"); PasswordForm unrelated_password = CreateSaved(); unrelated_password.preferred = true; unrelated_password.username_value = ASCIIToUTF16("another username"); unrelated_password.password_value = ASCIIToUTF16("some password"); PasswordForm unrelated_psl_password = CreateSavedPSL(); unrelated_psl_password.preferred = true; unrelated_psl_password.username_value = ASCIIToUTF16("another username"); unrelated_psl_password.password_value = ASCIIToUTF16("some password"); EXPECT_CALL(store(), AddLogin(_)); const std::vector<const autofill::PasswordForm*> matches = { &related_password, &related_psl_password, &unrelated_password, &unrelated_psl_password}; state().PresaveGeneratedPassword(generated, matches); generated.username_value = ASCIIToUTF16("username"); PasswordForm generated_with_date = generated; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), UpdateLoginWithPrimaryKey(generated_with_date, FormHasUniqueKey(CreateGenerated()))); PasswordForm related_password_expected = related_password; related_password_expected.password_value = generated.password_value; EXPECT_CALL(store(), UpdateLogin(related_password_expected)); PasswordForm related_psl_password_expected = related_psl_password; related_psl_password_expected.password_value = generated.password_value; EXPECT_CALL(store(), UpdateLogin(related_psl_password_expected)); PasswordForm unrelated_password_expected = unrelated_password; unrelated_password_expected.preferred = false; EXPECT_CALL(store(), UpdateLogin(unrelated_password_expected)); state().CommitGeneratedPassword(generated, matches, ASCIIToUTF16("old password")); EXPECT_TRUE(state().HasGeneratedPassword()); } // Check that removing a presaved password removes the presaved password. TEST_F(PasswordGenerationStateTest, PasswordNoLongerGenerated) { PasswordForm generated = CreateGenerated(); EXPECT_CALL(store(), AddLogin(_)); state().PresaveGeneratedPassword(generated, {}); generated.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), RemoveLogin(generated)); state().PasswordNoLongerGenerated(); EXPECT_FALSE(state().HasGeneratedPassword()); } // Check that removing the presaved password and then presaving again results in // adding the second presaved password as new. TEST_F(PasswordGenerationStateTest, PasswordNoLongerGenerated_AndPresaveAgain) { PasswordForm generated = CreateGenerated(); PasswordForm generated_with_date = generated; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), AddLogin(generated_with_date)); state().PresaveGeneratedPassword(generated, {}); EXPECT_CALL(store(), RemoveLogin(generated_with_date)); state().PasswordNoLongerGenerated(); generated.username_value = ASCIIToUTF16("newgenusername"); generated.password_value = ASCIIToUTF16("newgenpwd"); generated_with_date = generated; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), AddLogin(generated_with_date)); state().PresaveGeneratedPassword(generated, {}); EXPECT_TRUE(state().HasGeneratedPassword()); } // Check that presaving a password once in original and then once in clone // results in the clone calling update, not a fresh save. TEST_F(PasswordGenerationStateTest, PresaveGeneratedPassword_CloneUpdates) { PasswordForm generated = CreateGenerated(); PasswordForm generated_with_date = generated; generated_with_date.date_created = base::Time::FromTimeT(kTime); EXPECT_CALL(store(), AddLogin(generated_with_date)); state().PresaveGeneratedPassword(generated, {}); std::unique_ptr<FormSaver> cloned_saver = form_saver().Clone(); std::unique_ptr<PasswordGenerationState> cloned_state = state().Clone(cloned_saver.get()); std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock); clock->SetNow(base::Time::FromTimeT(kAnotherTime)); cloned_state->set_clock(std::move(clock)); EXPECT_TRUE(cloned_state->HasGeneratedPassword()); PasswordForm generated_updated = generated; generated_updated.username_value = ASCIIToUTF16("newname"); generated_with_date = generated_updated; generated_with_date.date_created = base::Time::FromTimeT(kAnotherTime); EXPECT_CALL(store(), UpdateLoginWithPrimaryKey(generated_with_date, FormHasUniqueKey(generated))); cloned_state->PresaveGeneratedPassword(generated_updated, {}); EXPECT_TRUE(cloned_state->HasGeneratedPassword()); } // Check that a clone can still work after the original is destroyed. TEST_F(PasswordGenerationStateTest, PresaveGeneratedPassword_CloneSurvives) { auto original = std::make_unique<PasswordGenerationState>(&form_saver(), &client()); const PasswordForm generated = CreateGenerated(); EXPECT_CALL(store(), AddLogin(_)); original->PresaveGeneratedPassword(generated, {}); std::unique_ptr<FormSaver> cloned_saver = form_saver().Clone(); std::unique_ptr<PasswordGenerationState> cloned_state = original->Clone(cloned_saver.get()); original.reset(); EXPECT_CALL(store(), UpdateLoginWithPrimaryKey(_, _)); cloned_state->PresaveGeneratedPassword(generated, {}); } } // namespace } // namespace password_manager
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
7cab39d108786df856ff3a138e0051c450453ff1
9a0a582bdba0dfbeffddd2dfd59948789e0915d8
/prototype1/include/peaklightbardetector.h
ecb806a0aef309680c5ac668c762cae808428cfd
[]
no_license
Gerold31/Streifenprojektion
25eca8c608c5ead546df2e951b4e905e98f90299
31dfa7d0883d9e269280e12381637af81300cc80
refs/heads/master
2021-01-16T23:09:58.093331
2015-05-22T20:54:23
2015-05-22T20:54:23
25,968,337
0
0
null
null
null
null
UTF-8
C++
false
false
638
h
#ifndef PEAKLIGHTBARDETECTOR_H #define PEAKLIGHTBARDETECTOR_H #include <opencv2/core/core.hpp> #include "lightbardetector.h" struct WorkData; class PeakLightBarDetector : public LightBarDetector { public: PeakLightBarDetector() {} virtual ~PeakLightBarDetector() {} virtual void processImage(const cv::Mat& img, Line& line) override; private: void computeAreaAvg(WorkData& data) const; void computeEval(WorkData& data) const; void computeLine(WorkData& data) const; double evaluate(const cv::Vec3d color) const; cv::Vec2i areaSize = {11, 11}; double threshold = 0.6; int median = 1; }; #endif // PEAKLIGHTBARDETECTOR_H
[ "johannes.spangenberg@hotmail.de" ]
johannes.spangenberg@hotmail.de
f50157140e2f6994804c282437f794bc6a287928
527739ed800e3234136b3284838c81334b751b44
/include/RED4ext/Types/generated/audio/VisualTagToNPCMetadata.hpp
2ade393a6ca000337214a85fd8a4302a133b4dd3
[ "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
575
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/CName.hpp> #include <RED4ext/DynArray.hpp> namespace RED4ext { namespace audio { struct VisualTagToNPCMetadata { static constexpr const char* NAME = "audioVisualTagToNPCMetadata"; static constexpr const char* ALIAS = NAME; DynArray<CName> visualTags; // 00 CName foleyNPCMetadata; // 10 }; RED4EXT_ASSERT_SIZE(VisualTagToNPCMetadata, 0x18); } // namespace audio } // namespace RED4ext
[ "expired6978@gmail.com" ]
expired6978@gmail.com
8ed9054b74b0144ca9c0e1bce34c8d9d75f52961
3818b7af7a6407b636870288779014b29b186535
/Source/Editor/FrEdUtil.h
88eb6a36ca125ffdf7b1ec50d75bda64d3f69b8c
[]
no_license
VladGordienko28/ProtoGame
de287b44b6db4de9fc888869e3a663db81dc85ed
3d88f5578f6ceca4275af9ee14a468b190bbfb7c
refs/heads/master
2020-04-16T06:53:18.813931
2019-11-11T19:42:19
2019-11-11T19:42:19
165,364,799
1
0
null
null
null
null
UTF-8
C++
false
false
2,107
h
/*============================================================================= FrEdUtil.h: Various editor stuff. Copyright Jul.2016 Vlad Gordienko. =============================================================================*/ /*----------------------------------------------------------------------------- CGUIRender. -----------------------------------------------------------------------------*/ // // GUI Render. // class CGUIRender: public CGUIRenderBase { public: // CGUIRender interface. CGUIRender(); ~CGUIRender(); void BeginPaint( gfx::DrawContext& drawContext ); void EndPaint( gfx::DrawContext& drawContext ); // CGUIRenderBase interface. void DrawRegion( TPoint P, TSize S, math::Color Color, math::Color BorderColor, EBrushPattern Pattern ); void DrawText( TPoint P, const Char* Text, Int32 Len, math::Color Color, fnt::Font::Ptr Font ); void SetClipArea( TPoint P, TSize S ); void DrawImage( TPoint P, TSize S, TPoint BP, TSize BS, img::Image::Ptr image ); void DrawTexture( TPoint P, TSize S, TPoint BP, TSize BS, rend::Texture2DHandle image, UInt32 width, UInt32 height ); void SetBrightness( Float Brig ); private: Float m_brightness; gfx::TextDrawer m_textDrawer; ffx::Effect::Ptr m_coloredEffect; ffx::Effect::Ptr m_texturedEffect; ffx::TechniqueId m_solidTech; ffx::TechniqueId m_stippleTech; rend::VertexBufferHandle m_coloredVB; rend::VertexBufferHandle m_texturedVB; gfx::DrawContext* m_drawContext; }; /*----------------------------------------------------------------------------- CSG. -----------------------------------------------------------------------------*/ // CSG functions. extern void CSGUnion( FBrushComponent* Brush, FLevel* Level ); extern void CSGIntersection( FBrushComponent* Brush, FLevel* Level ); extern void CSGDifference( FBrushComponent* Brush, FLevel* Level ); // // Experimental stuff // JSon::Ptr exportLevel( FLevel* level ); /*----------------------------------------------------------------------------- The End. -----------------------------------------------------------------------------*/
[ "vladgordienko28@gmail.com" ]
vladgordienko28@gmail.com