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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
db266ddf7401aa89d77492bf6a75637f608594fa | 013c7539d6fb9ffc30740a33691aac902b11b06e | /practive/POJ/finished/3278.cpp | 468d0fcf7c40dcabc1daed9490d807bcad43bd30 | [] | no_license | eternity6666/life-in-acm | 1cc4ebaa65af62219130d53c9be534ad31b361e2 | e279121a28e179d0de33674b9ce10c6763d78d32 | refs/heads/master | 2023-04-13T07:50:58.231217 | 2023-04-09T09:23:24 | 2023-04-09T09:23:24 | 127,930,873 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 996 | cpp | #include <iostream>
#include <cstring>
#include <queue>
using namespace std;
const int maxn = 1e5 + 10;
struct node{int now, time;};
int n, k;
bool v[maxn];
int bfs()
{
memset(v, 1, sizeof(v));
node s;
s.now = n;
s.time = 0;
queue<node> q;
q.push(s);
int ans = maxn;
while(!q.empty())
{
s = q.front();
if(s.now == k)
{
ans = s.time;
break;
}
q.pop();
v[s.now] = 0;
node tmp;
tmp.time = s.time + 1;
tmp.now = s.now + 1;
if(tmp.now < maxn && v[tmp.now])
q.push(tmp);
tmp.now = s.now - 1;
if(tmp.now >= 0 && v[tmp.now])
q.push(tmp);
tmp.now = s.now * 2;
if(tmp.now < maxn && tmp.now >= 0 && v[tmp.now])
q.push(tmp);
}
return ans;
}
int main()
{
freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(0);
cin >> n >> k;
cout << bfs() << endl;
return 0;
}
| [
"1462928058@qq.com"
] | 1462928058@qq.com |
a411158a8ced855fd1a0b0524a30a14f5da21d54 | 5c83b3b84af296ee2aaf4ff879fba949921668f0 | /src/core/vertex_buffer_base.cpp | d57fe45761c166f78655401408ecc5b04593336a | [] | no_license | stevebeard/rend | 8785dd6a71d9f2ebec8a83264fbcbd587c5f67fb | 852b01252da9f9d77fd9ea3bf8743c64aa2e09b1 | refs/heads/master | 2020-07-29T22:00:32.250020 | 2019-09-13T15:39:11 | 2019-09-13T15:39:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 410 | cpp | #include "vertex_buffer_base.h"
using namespace rend;
VertexBufferBase::VertexBufferBase(void)
: _count(0), _bytes(0), _vertex_bytes(0)
{
}
VertexBufferBase::~VertexBufferBase(void)
{
}
uint32_t VertexBufferBase::count(void) const
{
return _count;
}
size_t VertexBufferBase::bytes(void) const
{
return _bytes;
}
size_t VertexBufferBase::vertex_bytes(void) const
{
return _vertex_bytes;
}
| [
"alas.paterson@gmail.com"
] | alas.paterson@gmail.com |
996c64f8814e1e0dc72928669e5bdd6b31396ca6 | da41653417bb575b80f80dcd534083d3ec5968b1 | /Qt5_learn/Day1/Code/01_FirstProject/mypushbutton.cpp | e9fd74b070aa0d6659dd91271f8d6d2a39e11828 | [] | no_license | TaraxaYJ/Qt5_Interface_for_Robot | e5c6420fc17300e0aef72b5afcd7aa3f8002b179 | 4cb7edc6327b55e840c3266329b87f38dde6efb2 | refs/heads/master | 2020-12-03T16:51:21.240568 | 2020-01-02T14:31:50 | 2020-01-02T14:31:50 | 231,396,042 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 239 | cpp | #include "mypushbutton.h"
#include <QDebug>
MyPushButton::MyPushButton(QWidget *parent) : QPushButton(parent)
{
qDebug() << "我的按钮类构造调用";
}
MyPushButton::~MyPushButton()
{
qDebug() << "我的按钮类析构";
}
| [
"yyj_1803294@sjtu.edu.cn"
] | yyj_1803294@sjtu.edu.cn |
12cd74be7c2809147f44d95c0780e8e7a244657f | 62d6e09be253895ef4f574265e4b86a3fe3936d3 | /Getopt/ShortFunction.cpp | 112d134c17eaaa08e514fb1e7abb1c3522bec998 | [] | no_license | JackWyj/Getopts | d8fa752680467dcf053c8af827f2ec48cd375df5 | 02e7b30a0d593cf127afdfd5a152aa0210496868 | refs/heads/master | 2016-09-08T02:03:18.458048 | 2015-06-23T13:34:13 | 2015-06-23T13:34:13 | 37,046,440 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 607 | cpp | #include "stdafx.h"
#include "ShortFunction.h"
ShortFunction::ShortFunction(void)
{
ch = 0;
have_param = false;
}
ShortFunction::ShortFunction(char c , bool b){
ch = c;
have_param = b;
}
ShortFunction::~ShortFunction(void)
{
}
bool ShortFunction::haveParam(){
return have_param;
}
char ShortFunction::getch(){
return ch;
}
ShortFunction::ShortFunction(const ShortFunction &sfn){
ch = sfn.ch;
have_param = sfn.have_param;
}
void ShortFunction::operator=(const ShortFunction &sfn){
ch = sfn.ch;
have_param = sfn.have_param;
}
param_type ShortFunction::carry_param_type(){
return paramty;
} | [
"568887572@qq.com"
] | 568887572@qq.com |
fae816c4afc9cd24cf07e3b92e3d8c6ed3a9d5b1 | 50edf0fe7791df5e792aef4ae844783a9bbbeb64 | /3. dynamic programming/F.cpp | a3b49310cd11be8539f39b7e871b3e1bc8f9c442 | [] | no_license | don2rryV/itmo_ADS | 08a5266f0bb485325f04797979118016bbf6c543 | af728eafc278e6d26c70356817446fe0b2cb9833 | refs/heads/master | 2020-05-27T16:48:10.716049 | 2019-05-27T17:37:57 | 2019-05-27T17:37:57 | 188,708,988 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,850 | cpp | #include <bits/stdc++.h>
using namespace std;
vector <vector <int> > a, ans;
string s;
int func(int left, int right){
if (left > right) return 0; else{
//cout << left << " " << right << endl;
if (a[left][right] == 0){
// cout << left << " " << right << " in 0 " << endl;
int y = right - left;
for (int i = left; i <= right; i++){
cout << s[i];
}
return 0;
}
if (a[left][right] == right - left +1){
return 1;
}//} else
if (ans[left][right] == -1) {
cout << s[left];
func(left + 1, right - 1);
cout << s[right];
return 0;
}
func(left, ans[left][right]);
func(ans[left][right]+1, right);
}
}
int main()
{
cin >> s;
a.resize(s.length()); ans.resize(s.length());
for (int i = 0; i < s.length(); i++){
for (int j = 0; j < s.length(); j++){
a[i].resize(s.length());
ans[i].resize(s.length());
}
}
/* for (int i = 0; i < s.length(); i++){
for (int j = 0; j < s.length(); j++){
a[i][j] = 0;
if (i == j) {a[i][j] = 1;}
if (i == j-1){
if (s[i] == '[' && s[j] == ']' ||
s[i] == '{' && s[j] == '}' ||
s[i] == '(' && s[j] == ')'){
a[i][j] = 0;
ans[i][j] = i;
}
//else {a[i][j] = 2; ans[i][j] = 0;}
}
}
}
/*for (int i = 0; i < s.length(); i++){
for (int j = 0; j < s.length(); j++){
cout << a[i][j] << " ";
}
cout << endl;
}
*/
for (int j = 0; j < s.length(); j++){
for (int i = j; i >=0 ; i--){
if (i != j){
int buf = 1000000000;
int ind = -1;
//ans[i][j] = -1;
if (s[i] == '[' && s[j] == ']' ||
s[i] == '{' && s[j] == '}' ||
s[i] == '(' && s[j] == ')'){
ind = -1;
buf = a[i+1][j-1];
}
int min_buf = a[i][i] + a[i+1][j]; //ind = i;
for (int p = i; p < j; p++){
if (a[i][p] + a[p+1][j] < buf) { buf = a[i][p] + a[p+1][j]; ind = p;}
}
//buf = min(buf, min_buf);
a[i][j] = buf;
ans[i][j] = ind;
}else a[i][j] = 1;
}
}
/* for (int i = 0; i < s.length(); i++){
for (int j = 0; j < s.length(); j++){
cout << a[i][j] << " ";
}
cout << endl;
}
cout << endl;
for (int i = 0; i < s.length(); i++){
for (int j = 0; j < s.length(); j++){
cout << ans[i][j] << " ";
}
cout << endl;
}*/
func(0, s.length()-1);
//cout << s.length() - a[0][ s.length() - 1];
}
| [
"don2rry@gmail.com"
] | don2rry@gmail.com |
ecb7a987d472de06bca16181f8358db10c0320cf | f26360b99a471d466af83f037a02ccc4667db913 | /3rdparty/poco/Crypto/testsuite/src/CryptoTest.cpp | 777c23c610466c2b28c706352f97855d3f7c3a13 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | gitkeidy/opencvr | 80646520b8099485edb6c666750808f876fabf97 | 9bd570ff30c407cf149acdaf483f22f0ebefa72e | refs/heads/master | 2021-01-18T08:56:04.463604 | 2016-02-08T05:10:18 | 2016-02-08T05:10:18 | 50,656,483 | 3 | 1 | null | 2016-02-08T05:10:20 | 2016-01-29T10:44:57 | Makefile | UTF-8 | C++ | false | false | 9,166 | cpp | //
// CryptoTest.cpp
//
// $Id: //poco/1.4/Crypto/testsuite/src/CryptoTest.cpp#2 $
//
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "CryptoTest.h"
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "Poco/Crypto/CipherFactory.h"
#include "Poco/Crypto/Cipher.h"
#include "Poco/Crypto/CipherKey.h"
#include "Poco/Crypto/X509Certificate.h"
#include "Poco/Crypto/CryptoStream.h"
#include "Poco/StreamCopier.h"
#include "Poco/Base64Encoder.h"
#include <sstream>
using namespace Poco::Crypto;
static const std::string APPINF_PEM(
"-----BEGIN CERTIFICATE-----\n"
"MIIESzCCAzOgAwIBAgIBATALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu\n"
"Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n\n"
"aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh\n"
"cmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl\n"
"bnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu\n"
"Y29tMB4XDTA5MDUwNzE0NTY1NloXDTI5MDUwMjE0NTY1NlowgdMxEzARBgNVBAMM\n"
"CmFwcGluZi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdh\n"
"cmUgRW5naW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNV\n"
"BAgMCUNhcmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBp\n"
"bSBSb3NlbnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0Bh\n"
"cHBpbmYuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA89GolWCR\n"
"KtLQclJ2M2QtpFqzNC54hUQdR6n8+DAeruH9WFwLSdWW2fEi+jrtd/WEWCdt4PxX\n"
"F2/eBYeURus7Hg2ZtJGDd3je0+Ygsv7+we4cMN/knaBY7rATqhmnZWk+yBpkf5F2\n"
"IHp9gBxUaJWmt/bq3XrvTtzrDXpCd4zg4zPXZ8IC8ket5o3K2vnkAOsIsgN+Ffqd\n"
"4GjF4dsblG6u6E3VarGRLwGtgB8BAZOA/33mV4FHSMkc4OXpAChaK3tM8YhrLw+m\n"
"XtsfqDiv1825S6OWFCKGj/iX8X2QAkrdB63vXCSpb3de/ByIUfp31PpMlMh6dKo1\n"
"vf7yj0nb2w0utQIDAQABoyowKDAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0lAQH/BAww\n"
"CgYIKwYBBQUHAwMwDQYJKoZIhvcNAQEFBQADggEBAM0cpfb4BgiU/rkYe121P581\n"
"ftg5Ck1PYYda1Fy/FgzbgJh2AwVo/6sn6GF79/QkEcWEgtCMNNO3LMTTddUUApuP\n"
"jnEimyfmUhIThyud/vryzTMNa/eZMwaAqUQWqLf+AwgqjUsBSMenbSHavzJOpsvR\n"
"LI0PQ1VvqB+3UGz0JUnBJiKvHs83Fdm4ewPAf3M5fGcIa+Fl2nU5Plzwzskj84f6\n"
"73ZlEEi3aW9JieNy7RWsMM+1E8Sj2CGRZC4BM9V1Fgnsh4+VHX8Eu7eHucvfeIYx\n"
"3mmLMoK4sCayL/FGhrUDw5AkWb8tKNpRXY+W60Et281yxQSeWLPIbatVzIWI0/M=\n"
"-----END CERTIFICATE-----\n"
);
CryptoTest::CryptoTest(const std::string& name): CppUnit::TestCase(name)
{
}
CryptoTest::~CryptoTest()
{
}
void CryptoTest::testEncryptDecrypt()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256"));
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher->decryptString(out, Cipher::ENC_NONE);
assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64);
assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
std::string result = pCipher->decryptString(out, Cipher::ENC_BINHEX);
assert (in == result);
}
}
void CryptoTest::testEncryptDecryptWithSalt()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher2->decryptString(out, Cipher::ENC_NONE);
assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher2->decryptString(out, Cipher::ENC_BASE64);
assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
std::string result = pCipher2->decryptString(out, Cipher::ENC_BINHEX);
assert (in == result);
}
}
void CryptoTest::testEncryptDecryptDESECB()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("des-ecb", "password"));
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher->decryptString(out, Cipher::ENC_NONE);
assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64);
assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
std::string result = pCipher->decryptString(out, Cipher::ENC_BINHEX);
assert (in == result);
}
}
void CryptoTest::testPassword()
{
CipherKey key("aes256", "password", "salt");
std::ostringstream keyStream;
Poco::Base64Encoder base64KeyEnc(keyStream);
base64KeyEnc.write(reinterpret_cast<const char*>(&key.getKey()[0]), key.keySize());
base64KeyEnc.close();
std::string base64Key = keyStream.str();
assert (base64Key == "hIzxBt58GDd7/6mRp88bewKk42lM4QwaF78ek0FkVoA=");
}
void CryptoTest::testEncryptInterop()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "password", "salt"));
const std::string plainText = "This is a secret message.";
const std::string expectedCipherText = "9HITTPaU3A/LaZzldbdnRZ109DKlshouKren/n8BsHc=";
std::string cipherText = pCipher->encryptString(plainText, Cipher::ENC_BASE64);
assert (cipherText == expectedCipherText);
}
void CryptoTest::testDecryptInterop()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "password", "salt"));
const std::string expectedPlainText = "This is a secret message.";
const std::string cipherText = "9HITTPaU3A/LaZzldbdnRZ109DKlshouKren/n8BsHc=";
std::string plainText = pCipher->decryptString(cipherText, Cipher::ENC_BASE64);
assert (plainText == expectedPlainText);
}
void CryptoTest::testStreams()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256"));
static const std::string SECRET_MESSAGE = "This is a secret message. Don't tell anyone.";
std::stringstream sstr;
EncryptingOutputStream encryptor(sstr, *pCipher);
encryptor << SECRET_MESSAGE;
encryptor.close();
DecryptingInputStream decryptor(sstr, *pCipher);
std::string result;
Poco::StreamCopier::copyToString(decryptor, result);
assert (result == SECRET_MESSAGE);
assert (decryptor.eof());
assert (!decryptor.bad());
std::istringstream emptyStream;
DecryptingInputStream badDecryptor(emptyStream, *pCipher);
Poco::StreamCopier::copyToString(badDecryptor, result);
assert (badDecryptor.fail());
assert (badDecryptor.bad());
assert (!badDecryptor.eof());
}
void CryptoTest::testCertificate()
{
std::istringstream certStream(APPINF_PEM);
X509Certificate cert(certStream);
std::string subjectName(cert.subjectName());
std::string issuerName(cert.issuerName());
std::string commonName(cert.commonName());
std::string country(cert.subjectName(X509Certificate::NID_COUNTRY));
std::string localityName(cert.subjectName(X509Certificate::NID_LOCALITY_NAME));
std::string stateOrProvince(cert.subjectName(X509Certificate::NID_STATE_OR_PROVINCE));
std::string organizationName(cert.subjectName(X509Certificate::NID_ORGANIZATION_NAME));
std::string organizationUnitName(cert.subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME));
assert (subjectName == "/CN=appinf.com/O=Applied Informatics Software Engineering GmbH/OU=Development/ST=Carinthia/C=AT/L=St. Jakob im Rosental/emailAddress=guenter.obiltschnig@appinf.com");
assert (issuerName == subjectName);
assert (commonName == "appinf.com");
assert (country == "AT");
assert (localityName == "St. Jakob im Rosental");
assert (stateOrProvince == "Carinthia");
assert (organizationName == "Applied Informatics Software Engineering GmbH");
assert (organizationUnitName == "Development");
assert (cert.issuedBy(cert));
}
void CryptoTest::setUp()
{
}
void CryptoTest::tearDown()
{
}
CppUnit::Test* CryptoTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("CryptoTest");
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecrypt);
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptWithSalt);
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptDESECB);
CppUnit_addTest(pSuite, CryptoTest, testPassword);
CppUnit_addTest(pSuite, CryptoTest, testEncryptInterop);
CppUnit_addTest(pSuite, CryptoTest, testDecryptInterop);
CppUnit_addTest(pSuite, CryptoTest, testStreams);
CppUnit_addTest(pSuite, CryptoTest, testCertificate);
return pSuite;
}
| [
"xsmart@163.com"
] | xsmart@163.com |
2163d70c3fd36099f2d26e57b9aba7e11bb7163a | ac25e1afb366426988e5900270a27da8da22f8dc | /src/kidsbedsmall.cpp | e4f5cb1b4761ebee99fd5b98b66acc45a53183f0 | [] | no_license | sha256/OpenGLKidsRoom | a2c5424729c74ab1d37300b32e86057a90d85031 | 131b9aa4d1bead40cf32799b5618078e9889ddb9 | refs/heads/master | 2021-01-20T15:19:54.674265 | 2017-05-09T14:44:38 | 2017-05-09T14:44:38 | 90,756,520 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,701 | cpp | //
// kidsbedsmall.c
// Offline1
//
// Created by Shamim Hasnath on 10/5/15.
// Copyright © 2015 Holo. All rights reserved.
//
#include "Header.h"
void kidsBedSmallDisplay(){
color(LB_PILLER);
glPushMatrix();{
glTranslatef(10, 0, 0);
glScaled(1, 3, 1);
drawCurvedCubicLine(200, 100);
}glPopMatrix();
glPushMatrix();{
glTranslatef(10, 0, 0);
glScaled(1, 3, 1);
drawCurvedCubicLine(200, 40);
}glPopMatrix();
glPushMatrix();{
glTranslatef(-10, -5.0, 0);
glScaled(1, 3, 1);
drawCurvedCubicLine(90, 100);
}glPopMatrix();
glPushMatrix();{
glTranslatef(-10, -5.0, 0);
glScaled(1, 3, 1);
drawCurvedCubicLine(90, 40);
}glPopMatrix();
// high cubes
glPushMatrix();{
glTranslatef(-18.0, -48.0, 50.0);
glScaled(1.0, 1.2, 20.0);
glutSolidCube(5.0f);
}glPopMatrix();
glPushMatrix();{
glTranslatef(18.0, -48.0, 50.0);
glScaled(1.0, 1.2, 20.0);
glutSolidCube(5.0f);
}glPopMatrix();
glPushMatrix();{
glTranslatef(20.5, 51.0, 50.0);
glScaled(1.0, 1.2, 20.0);
glutSolidCube(5.0f);
}glPopMatrix();
glPushMatrix();{
glTranslatef(-15.0, 51.0, 50.0);
glScaled(1.0, 1.2, 20.0);
glutSolidCube(5.0f);
}glPopMatrix();
glPushMatrix();{
glTranslatef(2.0, 51.0, 40.0);
glScaled(7, 1, 1);
glutSolidCube(5.0f);
}glPopMatrix();
glPushMatrix();{
glTranslatef(0.0, -51.0, 40.0);
glScaled(7, 1, 1);
glutSolidCube(5.0f);
}glPopMatrix();
glPushMatrix();{
glTranslatef(2.0, 51.0, 98.0);
glScaled(7, 1, 1);
glutSolidCube(5.0f);
}glPopMatrix();
glPushMatrix();{
glTranslatef(0.0, -51.0, 97.0);
glScaled(7, 1, 1);
glutSolidCube(5.0f);
}glPopMatrix();
glPushMatrix();{
glScaled(1, 2.5, 1);
drawSphereLine(0, 67);
}glPopMatrix();
drawHighCubeLine(51.0);
drawHighCubeLine(-51.0);
GLdouble eqn1[4] = { 0.0, 1.0, 1.0, 0.0 };
GLdouble eqn2[4] = { 0.0, -1.0, 1.0, 0.0 };
glPushMatrix();{
glTranslatef(0, 20, 0);
glClipPlane(GL_CLIP_PLANE0,eqn1);
}glPopMatrix();
glPushMatrix();{
glTranslatef(0, -20, 0);
glClipPlane(GL_CLIP_PLANE1,eqn2);
}glPopMatrix();
color(LB_PILLER_VAR2);
glEnable(GL_CLIP_PLANE1);
glEnable(GL_CLIP_PLANE0);{
glPushMatrix();{
glScaled(0.9, 1, 1);
drawCurvedPlate(0, 67);
}glPopMatrix();
}glDisable(GL_CLIP_PLANE0);
glDisable(GL_CLIP_PLANE1);
}
void drawHighCubeLine(float y){
float x = -15;
for(int i=0; i<7; i++){
glPushMatrix();{
glTranslatef(x + 5*i, y, 66);
glScaled(1, 1, 30);
glutSolidCube(2.0);
}glPopMatrix();
}
}
void drawCurvedPlate(double fromAngle, double z){
double angle = fromAngle;
double radius = 30;
for(int i=0; i<200; i++){
double m = radius * cos(angle);
double n = radius * sin(angle);
//drawBitmapInt(i, m, n, 100);
glPushMatrix();{
glTranslatef(m, n, z);
glScaled(1, 30, 1);
glutSolidCube(2);
}glPopMatrix();
angle += 3.10;
}
//once = true;
//glDisable(GL_BLEND);
}
void drawSphereLine(double fromAngle, double z){
double angle = fromAngle;
double radius = 30;
//glEnable(GL_BLEND);
for(int i=0; i<100; i++){
double m = radius * cos(angle);
double n = radius * sin(angle);
//
glPushMatrix();{
glTranslatef(m, n, z);
glScaled(1, 0.3, 32);
// drawBitmapInt(i, m, n, 100);
if ((i > 17 && i < 59) || (i > 92 && i<100))
glutSolidCube(0.0);
else
glutSolidCube(2);
}glPopMatrix();
angle += 3.10;
}
//once = true;
//glDisable(GL_BLEND);
}
void drawCurvedCubicLine(double fromAngle, double z){
glBegin(GL_QUADS);{
double angle = fromAngle;
double radius = 20;
double leno = 2;
double zh = 5.0;
for(int i =0; i<200; i++){
double m = radius * cos(angle);
double n = radius * sin(angle);
//glColor3f(1.0f, 0.0f, 0.0f); // Red
glVertex3f(m+leno, n, z);
glVertex3f(m, n, z);
glVertex3f(m, n+leno, z);
glVertex3f( m+leno, n+leno, z);
// Back face (z = -1.0f)
//glColor3f(1.0, 1.0, 0.0f); // Yellow
glVertex3f(m+leno, n, z-zh);
glVertex3f(m, n, z-zh);
glVertex3f(m, n+leno, z-zh);
glVertex3f( m+leno, n+leno, z-zh);
// Left face (x = -1.0f)
//glColor3f(0.0f, 0.0f, 1.0f); // Blue
glVertex3f(m, n+leno, z);
glVertex3f(m, n+leno, z-zh);
glVertex3f(m, n, z-zh);
glVertex3f(m, n, z);
// Right face (x = 1.0f)
//glColor3f(0.0f, 1.0f, 0.0f); // Magenta
glVertex3f(m+leno, n+leno, z-zh);
glVertex3f(m+leno, n+leno, z);
glVertex3f(m+leno, n, z);
glVertex3f(m+leno, n, z-zh);
angle += 0.01;
}
}glEnd();
}
| [
"shamim@hasnath.net"
] | shamim@hasnath.net |
48d9f45f39bcb60ed5e474c22dde595e8d72f104 | 850a39e68e715ec5b3033c5da5938bbc9b5981bf | /drgraf4_0/Allheads/Mi_obj3d.h | 03f18c3d6340be8f333090d46876a517917e0aef | [] | no_license | 15831944/drProjects | 8cb03af6d7dda961395615a0a717c9036ae1ce0f | 98e55111900d6a6c99376a1c816c0a9582c51581 | refs/heads/master | 2022-04-13T12:26:31.576952 | 2020-01-04T04:18:17 | 2020-01-04T04:18:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,625 | h | // ELMouse.h : header file
//
#ifndef _MI_OBJ3D_H
#define _MI_OBJ3D_H
//#undef AFX_DATA
//#define AFX_DATA AFX_EXT_DATA
#include "drObj3D.h"
#include "DListMgr.h"
#include "Def_Type.h"
/////////////////////////////////////////////////////////////////////////////
// CMouse view
//////////////////////////////////////////////////////
class CMI_Obj3D : public CObject
{
public:
CMI_Obj3D();
//////////////////////////////////////
DECLARE_SERIAL(CMI_Obj3D)
//////////////////////////////////////
// Attributes
// Operations
public:
// Implementation
public:
/////////////////////////////////////////////
virtual int LBDownInit_OEdit(){return 0;};
virtual int LBUpObj3DEdit(){return 0;};
virtual int LBDownInit_OMove(){return 0;};
virtual int LBUpObj3DMove(){return 0;};
/////////////////////////////////////////////
virtual int LBDownInit_OInsert();
virtual int LBUpInit_OInsert();
virtual int LBUp_OInsert(CView* pView,UINT nView);
protected:
//////////////////////////////////////////////////////////// Obj3D
int InsertAllInfo();
CDrObj3D* O_GetInfo();
protected:
// Attributes
protected:
/////////////////////////////////////////// Curve
CDrObj3D* m_pDrObj3D;
/////////////////////////////////////////// Next
//Operations
public:
~CMI_Obj3D();
virtual void Serialize(CArchive& ar);
/*
// Generated message map functions
//{{AFX_MSG(CMI_Obj3D)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
*/
};
//#undef AFX_DATA
//#define AFX_DATA
//////////////////////////////////////
#endif
| [
"sray12345678@gmail.com"
] | sray12345678@gmail.com |
ba65c63bfb27b946dc9a2cb0cd0a7fbe1f3bb856 | 4c8aa269772b2677176b21930e2b513e5fcad252 | /resources/cPerson.cpp | 1a10789bd53c13421e1d3166f8c34ee7504208d9 | [] | no_license | CEduardoSQUTEC/karuSampi | 0e29ef230263fdfe32b1c0e657407f30969ef784 | b0a08ee231789e807590e7d1eac25f41562de91c | refs/heads/master | 2022-03-20T16:58:00.369954 | 2019-11-29T16:46:40 | 2019-11-29T16:46:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 62 | cpp | //
// Created by eduar on 28-Nov-19.
//
#include "cPerson.h"
| [
"eduardo.castro@utec.edu.pe"
] | eduardo.castro@utec.edu.pe |
a8791f0636d7fbecd4a63aa4a4fbb4f64b8c7f6d | e6f6c2fe3a2d77069bca51c39d54ba1821f00a36 | /communication/unixSocket/include_files/unixSocket.hh | 0b964026e907f0c335744bc8a887f872a0c0c473 | [] | no_license | Tibonim/cpp_plazza | b33744dc6ad6a333eabfc9c6beeb992e01e41faa | 0cf973005c59bac8d32bb628604aea760a6cf22f | refs/heads/master | 2023-07-25T08:15:17.735210 | 2018-10-28T10:10:59 | 2018-10-28T10:10:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 485 | hh | #pragma once
#include <string>
#include <sys/socket.h>
#include <sys/un.h>
#include <arpa/inet.h>
#include "ACom.hh"
namespace com {
class unixSocket : public ACom {
public:
unixSocket(std::size_t id, int input);
~unixSocket();
void sendCmd(ICom::SendProtocol const &protocol) override;
void receivedCmd(ICom::SendProtocol& protocol) override;
private:
int _socket;
int _socketIn;
struct sockaddr addrMe;
std::string _socketFileMe;
};
}
| [
"Fusion@LAPTOP-687C0M9D.localdomain"
] | Fusion@LAPTOP-687C0M9D.localdomain |
8a15213a202dba0bce4076bcd4bb20f029b3997b | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/httpd/gumtree/httpd_old_hunk_1357.cpp | 4b86268d0da26e74a2833567515b4af54f3df5de | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 539 | cpp | */
#include "apr_arch_threadproc.h"
APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize)
{
int x;
if (chdir("/") == -1) {
return errno;
}
#if !defined(MPE) && !defined(OS2) && !defined(TPF) && !defined(BEOS)
/* Don't detach for MPE because child processes can't survive the death of
* the parent. */
if (daemonize) {
if ((x = fork()) > 0) {
exit(0);
}
else if (x == -1) {
perror("fork");
fprintf(stderr, "unable to fork new process\n");
| [
"993273596@qq.com"
] | 993273596@qq.com |
4237332df7a0628105c6f91dd7bff4c671c19cf1 | bd59d5419a886576ca93b2d07fb70c910144e4ba | /MsgBox.cpp | bec0bce10e4f2b7698cf074c89d369384959b41c | [] | no_license | liuyanmin120/test | 9555a0622f1a96e4ad1170ab8a38b7f2ac198a6e | 45d5793c70e819e4263f40b32beaeeeb7d751a50 | refs/heads/master | 2021-06-03T17:49:41.679532 | 2020-12-10T07:27:13 | 2020-12-10T07:27:13 | 320,192,472 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,274 | cpp | #include "MsgBox.h"
#include "ui_MsgBox.h"
const int MulHeight = 253;
const int SingleHeight = 193;
MsgBox::MsgBox(QWidget *parent, bool bAutoDel/* = true*/, int autoCloseTime/* = 0*/) :
QDialog(parent),
ui(new Ui::msgbox)
{
ui->setupUi(this);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setFixedSize(width(), height());
setAttribute(Qt::WA_DeleteOnClose, bAutoDel);
// init
_bOk = false;
_funCall = NULL;
_nHasTime = autoCloseTime;
_pParames = NULL;
_pTimer = NULL;
if (_nHasTime > 0) {
_pTimer = new QTimer(this);
connect(_pTimer, SIGNAL(timeout()), this, SLOT(onUpdateTimer()));
//delay->singleShot(60000,this,SLOT(toplay()));
_pTimer->start(_nHasTime * 1000);
}
ui->labMsg->setWordWrap(true);
ui->labMsg->setAlignment(Qt::AlignCenter);
connect(ui->btnOk, SIGNAL(clicked()), this, SLOT(onButtonClick()));
connect(ui->btnCancel, SIGNAL(clicked()), this, SLOT(onButtonClick()));
connect(ui->btnClose, SIGNAL(clicked()), this, SLOT(onButtonClick()));
}
MsgBox::~MsgBox()
{
if (_pTimer) {
if (_pTimer->isActive()) {
_pTimer->stop();
}
}
delete ui;
}
void MsgBox::ShowDlg(FuncMsgCloseCall func /*= NULL*/, void* pFuncParam /*= NULL*/)
{
_funCall = func;
_pParames = pFuncParam;
show();
raise();
}
void MsgBox::SetMainInfo(QString strMsg, QString strTitle /*= ""*/)
{
ui->labMsg->setText(strMsg);
if (!strTitle.isEmpty()) {
setWindowTitle(strTitle);
}
if (strMsg.length() < 100) {
setFixedHeight(SingleHeight);
}
else {
setFixedHeight(MulHeight);
}
}
void MsgBox::SetBtnInfo(bool bShowCancel, QString strOk /*= ""*/, QString strCancel /*= ""*/)
{
if (!strOk.isEmpty()) {
ui->btnOk->setText(strOk);
}
if (!strCancel.isEmpty()) {
ui->btnCancel->setText(strCancel);
}
ui->btnCancel->setVisible(bShowCancel);
}
void MsgBox::closeEvent(QCloseEvent *event)
{
emit sgCloseMsgBox(_bOk, this);
if (_funCall) {
_funCall(_bOk, _pParames);
}
_bOk = false;
QDialog::closeEvent(event);
}
void MsgBox::onButtonClick()
{
QPushButton *pBtn = qobject_cast<QPushButton*>(sender());
if (pBtn == ui->btnOk) {
_bOk = true;
}
else if (pBtn == ui->btnCancel || pBtn == ui->btnClose) {
_bOk = false;
}
hide();
close();
}
void MsgBox::onUpdateTimer()
{
close();
}
| [
"mywin@qq.com"
] | mywin@qq.com |
af36ba3442cb6180a261f6880ebf3f60e68d697a | f5f750efbde0ccd95856820c975ec88ee6ace0f8 | /aws-cpp-sdk-clouddirectory/include/aws/clouddirectory/model/ListObjectChildrenRequest.h | b3245e8b4e7d37504bcfa1e6b4729d65ccf597b7 | [
"JSON",
"MIT",
"Apache-2.0"
] | permissive | csimmons0/aws-sdk-cpp | 578a4ae6e7899944f8850dc37accba5568b919eb | 1d0e1ddb51022a02700a9d1d3658abf628bb41c8 | refs/heads/develop | 2020-06-17T14:58:41.406919 | 2017-04-12T03:45:33 | 2017-04-12T03:45:33 | 74,995,798 | 0 | 0 | null | 2017-03-02T05:35:49 | 2016-11-28T17:12:34 | C++ | UTF-8 | C++ | false | false | 7,931 | h | /*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#pragma once
#include <aws/clouddirectory/CloudDirectory_EXPORTS.h>
#include <aws/clouddirectory/CloudDirectoryRequest.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/clouddirectory/model/ObjectReference.h>
#include <aws/clouddirectory/model/ConsistencyLevel.h>
namespace Aws
{
namespace CloudDirectory
{
namespace Model
{
/**
*/
class AWS_CLOUDDIRECTORY_API ListObjectChildrenRequest : public CloudDirectoryRequest
{
public:
ListObjectChildrenRequest();
Aws::String SerializePayload() const override;
Aws::Http::HeaderValueCollection GetRequestSpecificHeaders() const override;
/**
* <p>ARN associated with the <a>Directory</a> where the object resides. For more
* information, see <a>arns</a>.</p>
*/
inline const Aws::String& GetDirectoryArn() const{ return m_directoryArn; }
/**
* <p>ARN associated with the <a>Directory</a> where the object resides. For more
* information, see <a>arns</a>.</p>
*/
inline void SetDirectoryArn(const Aws::String& value) { m_directoryArnHasBeenSet = true; m_directoryArn = value; }
/**
* <p>ARN associated with the <a>Directory</a> where the object resides. For more
* information, see <a>arns</a>.</p>
*/
inline void SetDirectoryArn(Aws::String&& value) { m_directoryArnHasBeenSet = true; m_directoryArn = value; }
/**
* <p>ARN associated with the <a>Directory</a> where the object resides. For more
* information, see <a>arns</a>.</p>
*/
inline void SetDirectoryArn(const char* value) { m_directoryArnHasBeenSet = true; m_directoryArn.assign(value); }
/**
* <p>ARN associated with the <a>Directory</a> where the object resides. For more
* information, see <a>arns</a>.</p>
*/
inline ListObjectChildrenRequest& WithDirectoryArn(const Aws::String& value) { SetDirectoryArn(value); return *this;}
/**
* <p>ARN associated with the <a>Directory</a> where the object resides. For more
* information, see <a>arns</a>.</p>
*/
inline ListObjectChildrenRequest& WithDirectoryArn(Aws::String&& value) { SetDirectoryArn(value); return *this;}
/**
* <p>ARN associated with the <a>Directory</a> where the object resides. For more
* information, see <a>arns</a>.</p>
*/
inline ListObjectChildrenRequest& WithDirectoryArn(const char* value) { SetDirectoryArn(value); return *this;}
/**
* <p>Reference that identifies the object for which child objects are being
* listed.</p>
*/
inline const ObjectReference& GetObjectReference() const{ return m_objectReference; }
/**
* <p>Reference that identifies the object for which child objects are being
* listed.</p>
*/
inline void SetObjectReference(const ObjectReference& value) { m_objectReferenceHasBeenSet = true; m_objectReference = value; }
/**
* <p>Reference that identifies the object for which child objects are being
* listed.</p>
*/
inline void SetObjectReference(ObjectReference&& value) { m_objectReferenceHasBeenSet = true; m_objectReference = value; }
/**
* <p>Reference that identifies the object for which child objects are being
* listed.</p>
*/
inline ListObjectChildrenRequest& WithObjectReference(const ObjectReference& value) { SetObjectReference(value); return *this;}
/**
* <p>Reference that identifies the object for which child objects are being
* listed.</p>
*/
inline ListObjectChildrenRequest& WithObjectReference(ObjectReference&& value) { SetObjectReference(value); return *this;}
/**
* <p>The pagination token.</p>
*/
inline const Aws::String& GetNextToken() const{ return m_nextToken; }
/**
* <p>The pagination token.</p>
*/
inline void SetNextToken(const Aws::String& value) { m_nextTokenHasBeenSet = true; m_nextToken = value; }
/**
* <p>The pagination token.</p>
*/
inline void SetNextToken(Aws::String&& value) { m_nextTokenHasBeenSet = true; m_nextToken = value; }
/**
* <p>The pagination token.</p>
*/
inline void SetNextToken(const char* value) { m_nextTokenHasBeenSet = true; m_nextToken.assign(value); }
/**
* <p>The pagination token.</p>
*/
inline ListObjectChildrenRequest& WithNextToken(const Aws::String& value) { SetNextToken(value); return *this;}
/**
* <p>The pagination token.</p>
*/
inline ListObjectChildrenRequest& WithNextToken(Aws::String&& value) { SetNextToken(value); return *this;}
/**
* <p>The pagination token.</p>
*/
inline ListObjectChildrenRequest& WithNextToken(const char* value) { SetNextToken(value); return *this;}
/**
* <p>Maximum number of items to be retrieved in a single call. This is an
* approximate number.</p>
*/
inline int GetMaxResults() const{ return m_maxResults; }
/**
* <p>Maximum number of items to be retrieved in a single call. This is an
* approximate number.</p>
*/
inline void SetMaxResults(int value) { m_maxResultsHasBeenSet = true; m_maxResults = value; }
/**
* <p>Maximum number of items to be retrieved in a single call. This is an
* approximate number.</p>
*/
inline ListObjectChildrenRequest& WithMaxResults(int value) { SetMaxResults(value); return *this;}
/**
* <p>Represents the manner and timing in which the successful write or update of
* an object is reflected in a subsequent read operation of that same object.</p>
*/
inline const ConsistencyLevel& GetConsistencyLevel() const{ return m_consistencyLevel; }
/**
* <p>Represents the manner and timing in which the successful write or update of
* an object is reflected in a subsequent read operation of that same object.</p>
*/
inline void SetConsistencyLevel(const ConsistencyLevel& value) { m_consistencyLevelHasBeenSet = true; m_consistencyLevel = value; }
/**
* <p>Represents the manner and timing in which the successful write or update of
* an object is reflected in a subsequent read operation of that same object.</p>
*/
inline void SetConsistencyLevel(ConsistencyLevel&& value) { m_consistencyLevelHasBeenSet = true; m_consistencyLevel = value; }
/**
* <p>Represents the manner and timing in which the successful write or update of
* an object is reflected in a subsequent read operation of that same object.</p>
*/
inline ListObjectChildrenRequest& WithConsistencyLevel(const ConsistencyLevel& value) { SetConsistencyLevel(value); return *this;}
/**
* <p>Represents the manner and timing in which the successful write or update of
* an object is reflected in a subsequent read operation of that same object.</p>
*/
inline ListObjectChildrenRequest& WithConsistencyLevel(ConsistencyLevel&& value) { SetConsistencyLevel(value); return *this;}
private:
Aws::String m_directoryArn;
bool m_directoryArnHasBeenSet;
ObjectReference m_objectReference;
bool m_objectReferenceHasBeenSet;
Aws::String m_nextToken;
bool m_nextTokenHasBeenSet;
int m_maxResults;
bool m_maxResultsHasBeenSet;
ConsistencyLevel m_consistencyLevel;
bool m_consistencyLevelHasBeenSet;
};
} // namespace Model
} // namespace CloudDirectory
} // namespace Aws
| [
"henso@amazon.com"
] | henso@amazon.com |
7d0b9df182f454e20608fd8f6553fe6d3c6dccba | 9f0d42c412db503f0759980a35136618ac6fda79 | /MyProjects/C++/2021/07.19/ZR1955.cpp | d83200d4a6052c9097817442def7e6c6b39fc1f2 | [] | no_license | lieppham/MyCode | 38a8c1353a2627d68b47b5f959bb827819058357 | 469d87f9d859123dec754b2e4ae0dced53f68660 | refs/heads/main | 2023-08-25T04:00:00.495534 | 2021-10-21T12:15:44 | 2021-10-21T12:15:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 956 | cpp | //Created by yanyanlongxia on 2021/7/23
//
#include <bits/stdc++.h>
#define ll long long
#define clm(x) memset(x,0,sizeof(x))
#define infm(x) memset(x,0x3f3f3f3f,sizeof(x))
#define minfm(x) memset(x,0xcf,sizeof(x))
using namespace std;
const int N=2e3;
int n,s,a[N],sum[N];
bool ma[N][N];
int gcd(int x,int y){
return (!y)?x: gcd(y,x%y);
}
int main() {
freopen("data.in","r",stdin);
//freopen("ZR1955.out","w",stdout);
scanf("%d%d",&n,&s);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=n;i++)
for(int j=1;j<=a[i];j++) {
ma[i][j] = true;
sum[j]++;
}
int su=0,u=0;
while(su+n-sum[u+1]<=s){
u++;
su+=n-sum[u];
}
if(s!=su) {
int mum = n-sum[u + 1], son = s - su;
int com = gcd(mum, son);
mum /= com;
son /= com;
printf("%d+%d/%d\n",u,son,mum);
}else {
printf("%d\n", u);
}
return 0;
}
| [
"yanyanlongxia@outlook.com"
] | yanyanlongxia@outlook.com |
ee64d5284d62b300029f2cce0f2c94d0ed48c44f | 83d06b8ef639485edd2085f176f778166aa32486 | /Exercise00-07.cpp | 93d10881bfadf8fb6cc6b343fb4fba1d99865f07 | [] | no_license | peteflorence/KoenigMoo_AcceleratedCpp | ac54385e0311542a94f9607349f3ed65a1f493d7 | 35dba25410e51f1729d8544666e29a78c7c36258 | refs/heads/master | 2020-04-11T09:53:48.726205 | 2015-08-25T12:01:03 | 2015-08-25T12:01:03 | 39,455,273 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 245 | cpp | //Exercise00-07.cpp
#include <iostream>
int main()
{
/* This is a comment that extends over servel lines
because it uses /* and */ as its starting and ending delimiteres */
std::cout << "Hello, world!" << std::endl; }}}}}}
return 0;
} | [
"pete.florence@gmail.com"
] | pete.florence@gmail.com |
2609df0b39f6c063c07d56762615860dccea5fcb | 3ef9dbe0dd6b8161b75950f682ec2fc24f79a90e | /MT_Cup/H/large.cpp | eed27722b56050c5b3b9dd739caad55933998c33 | [
"MIT"
] | permissive | JackBai0914/Competitive-Programming-Codebase | abc0cb911e5f6b32d1bd14416f9eb398b7c65bb9 | a1cabf0fa5072b07a7da25d66bf455eb45b0b7e9 | refs/heads/main | 2023-03-29T14:17:36.190798 | 2021-04-14T23:15:12 | 2021-04-14T23:15:12 | 358,065,977 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 56,611 | cpp | 2 0 0
3 2 1
4 3 2
5 2 3
6 3 1
7 3 5
8 0 3
9 6 0
10 6 4
11 4 7
12 0 9
13 4 5
14 10 9
15 13 7
16 13 8
17 10 16
18 12 13
19 12 18
20 2 19
21 8 6
22 20 3
23 7 21
24 15 6
25 17 16
26 14 25
27 10 17
28 25 26
29 23 22
30 19 24
31 21 26
32 16 31
33 28 22
34 20 30
35 28 25
36 35 29
37 32 31
38 26 23
39 35 26
40 21 33
41 33 38
42 31 39
43 29 40
44 37 13
45 43 44
46 44 45
47 42 28
48 40 41
49 47 38
50 47 39
51 30 36
52 44 47
53 40 48
54 35 53
55 44 42
56 53 36
57 51 19
58 44 46
59 52 55
60 43 24
61 54 55
62 44 45
63 59 40
64 63 62
65 57 60
66 58 44
67 66 63
68 56 62
69 62 62
70 48 51
71 61 68
72 63 56
73 70 68
74 52 62
75 60 72
76 56 73
77 66 76
78 70 76
79 75 75
80 61 79
81 69 71
82 36 79
83 76 59
84 73 54
85 84 84
86 76 83
87 84 82
88 86 78
89 79 84
90 89 56
91 86 66
92 85 91
93 72 81
94 91 90
95 90 84
96 83 92
97 89 95
98 87 89
99 94 98
100 93 95
101 96 94
102 90 100
103 101 99
104 102 97
105 102 103
106 105 100
107 105 88
108 94 99
109 91 80
110 97 108
111 105 110
112 108 91
113 111 109
114 102 112
115 105 114
116 98 96
117 112 114
118 86 105
119 118 116
120 115 111
121 105 119
122 97 118
123 121 118
124 109 106
125 116 117
126 121 108
127 122 124
128 98 127
129 126 117
130 127 123
131 126 123
132 124 124
133 132 95
134 133 126
135 122 117
136 125 129
137 127 133
138 118 114
139 124 138
140 128 135
141 130 92
142 127 140
143 140 113
144 140 133
145 132 141
146 115 143
147 135 145
148 147 142
149 140 144
150 130 145
151 137 149
152 128 144
153 147 139
154 120 146
155 150 151
156 135 139
157 137 148
158 154 141
159 140 156
160 156 147
161 157 154
162 161 131
163 155 135
164 146 160
165 161 164
166 145 165
167 141 156
168 152 164
169 153 151
170 162 128
171 170 128
172 170 168
173 166 163
174 173 170
175 167 169
176 175 167
177 140 175
178 167 173
179 161 174
180 148 179
181 173 175
182 166 176
183 160 180
184 181 182
185 179 174
186 151 183
187 184 143
188 175 186
189 187 180
190 186 161
191 187 181
192 191 174
193 191 191
194 185 188
195 188 185
196 187 187
197 194 185
198 190 195
199 197 195
200 167 197
201 185 200
202 196 201
203 198 192
204 203 201
205 186 203
206 180 190
207 198 206
208 205 155
209 207 200
210 206 205
211 208 196
212 185 210
213 188 212
214 210 210
215 209 200
216 204 204
217 214 207
218 188 193
219 210 217
220 218 215
221 217 212
222 218 208
223 220 221
224 200 219
225 218 222
226 220 225
227 223 224
228 218 219
229 226 220
230 219 193
231 226 223
232 213 230
233 218 232
234 225 233
235 230 224
236 235 230
237 226 214
238 237 217
239 231 238
240 226 236
241 222 233
242 239 235
243 239 242
244 242 204
245 238 233
246 196 245
247 244 226
248 238 244
249 240 246
250 238 236
251 241 227
252 211 241
253 248 246
254 251 253
255 248 237
256 253 252
257 254 249
258 253 239
259 243 254
260 250 257
261 251 260
262 240 249
263 250 251
264 263 255
265 263 249
266 250 254
267 258 247
268 258 252
269 267 260
270 265 267
271 267 254
272 250 271
273 270 261
274 273 265
275 274 266
276 273 268
277 270 262
278 273 263
279 271 270
280 279 277
281 279 279
282 252 277
283 279 269
284 270 260
285 278 282
286 270 241
287 272 285
288 282 282
289 265 281
290 278 288
291 277 285
292 287 289
293 291 279
294 290 293
295 294 283
296 289 289
297 296 294
298 282 292
299 291 287
300 297 293
301 295 286
302 301 284
303 297 301
304 301 288
305 303 274
306 301 304
307 299 305
308 307 295
309 289 297
310 294 309
311 307 310
312 310 299
313 305 309
314 295 313
315 309 310
316 305 313
317 297 297
318 300 317
319 312 312
320 318 316
321 313 320
322 308 282
323 314 322
324 317 296
325 297 299
326 314 319
327 325 322
328 325 326
329 323 325
330 314 327
331 325 328
332 312 311
333 332 326
334 329 330
335 333 319
336 293 305
337 305 304
338 321 324
339 317 319
340 334 318
341 335 338
342 329 337
343 337 327
344 333 335
345 344 344
346 344 336
347 346 324
348 340 334
349 348 345
350 328 349
351 348 334
352 349 342
353 341 352
354 315 344
355 347 346
356 350 346
357 340 356
358 346 336
359 349 357
360 353 347
361 341 351
362 336 359
363 339 335
364 362 346
365 343 361
366 362 357
367 359 351
368 346 364
369 366 366
370 349 357
371 354 351
372 355 368
373 372 362
374 367 368
375 368 364
376 367 370
377 357 372
378 368 374
379 366 362
380 374 358
381 367 369
382 369 359
383 381 375
384 382 375
385 383 377
386 380 383
387 368 375
388 370 381
389 386 382
390 371 387
391 388 376
392 382 357
393 388 380
394 387 380
395 392 372
396 393 386
397 394 380
398 388 391
399 389 389
400 398 388
401 394 386
402 379 400
403 398 399
404 403 401
405 401 401
406 403 385
407 385 398
408 395 389
409 404 405
410 396 401
411 408 410
412 397 406
413 384 406
414 412 397
415 385 380
416 411 414
417 411 398
418 407 413
419 415 414
420 416 414
421 398 420
422 408 421
423 414 407
424 418 409
425 414 424
426 416 414
427 418 404
428 427 405
429 426 416
430 413 427
431 430 427
432 429 431
433 429 432
434 417 429
435 429 432
436 434 432
437 423 420
438 434 427
439 433 418
440 435 415
441 439 436
442 435 422
443 430 440
444 441 429
445 444 440
446 445 433
447 441 445
448 435 427
449 447 443
450 445 443
451 449 449
452 441 422
453 436 430
454 436 448
455 447 438
456 439 455
457 452 455
458 457 440
459 444 443
460 459 457
461 445 457
462 448 459
463 462 456
464 456 442
465 455 464
466 450 465
467 449 460
468 451 456
469 436 466
470 440 466
471 462 446
472 446 470
473 464 469
474 473 471
475 472 470
476 464 452
477 470 456
478 473 476
479 478 476
480 464 476
481 471 475
482 477 478
483 456 479
484 464 480
485 483 478
486 471 483
487 467 482
488 474 425
489 474 487
490 488 488
491 485 477
492 489 475
493 481 491
494 482 491
495 485 489
496 491 485
497 493 494
498 495 490
499 496 490
500 471 459
501 489 473
502 459 498
503 501 501
504 503 470
505 489 485
506 486 472
507 460 505
508 492 503
509 495 496
510 507 493
511 497 492
512 495 510
513 487 510
514 508 513
515 508 513
516 468 515
517 514 516
518 503 515
519 500 507
520 517 507
521 513 520
522 503 508
523 522 522
524 519 498
525 521 523
526 525 508
527 500 526
528 526 523
529 526 516
530 526 520
531 524 488
532 521 531
533 527 524
534 514 492
535 530 532
536 525 531
537 523 512
538 535 535
539 495 517
540 532 524
541 534 522
542 516 509
543 536 539
544 540 510
545 531 536
546 541 493
547 543 521
548 539 523
549 543 539
550 541 531
551 549 549
552 546 531
553 549 551
554 537 547
555 541 544
556 551 552
557 555 550
558 553 540
559 554 558
560 554 549
561 558 549
562 548 560
563 550 550
564 559 560
565 555 552
566 562 560
567 563 558
568 561 566
569 543 560
570 566 569
571 568 570
572 557 569
573 560 570
574 572 573
575 565 561
576 573 566
577 553 567
578 575 573
579 577 569
580 569 573
581 577 577
582 581 558
583 576 570
584 571 579
585 580 578
586 583 585
587 584 566
588 576 578
589 577 562
590 554 581
591 572 590
592 588 562
593 574 588
594 577 587
595 589 593
596 595 585
597 594 577
598 589 597
599 586 596
600 591 588
601 598 600
602 576 595
603 597 592
604 596 599
605 602 599
606 605 604
607 599 606
608 607 594
609 608 571
610 598 597
611 590 609
612 601 606
613 596 607
614 589 604
615 613 613
616 596 597
617 594 616
618 609 603
619 613 618
620 615 611
621 620 617
622 619 620
623 620 591
624 613 620
625 620 602
626 621 623
627 616 625
628 622 627
629 628 609
630 627 618
631 623 628
632 616 628
633 625 628
634 616 621
635 631 628
636 630 632
637 613 629
638 631 634
639 637 631
640 639 636
641 632 633
642 619 641
643 639 624
644 635 643
645 643 643
646 643 641
647 645 646
648 634 643
649 609 639
650 647 645
651 640 644
652 650 650
653 651 613
654 651 646
655 627 645
656 648 641
657 654 654
658 651 652
659 636 649
660 656 659
661 658 638
662 648 657
663 647 651
664 658 648
665 664 662
666 664 665
667 662 648
668 660 657
669 643 663
670 668 660
671 647 668
672 645 666
673 672 671
674 673 670
675 671 652
676 674 666
677 665 665
678 660 672
679 668 676
680 668 679
681 679 678
682 679 678
683 681 677
684 670 649
685 668 684
686 662 682
687 684 678
688 687 684
689 685 686
690 674 671
691 673 683
692 685 691
693 691 664
694 691 692
695 683 659
696 692 692
697 693 689
698 680 696
699 694 694
700 696 693
701 693 684
702 693 701
703 669 695
704 690 682
705 703 697
706 695 693
707 703 703
708 700 701
709 707 704
710 701 691
711 709 709
712 693 708
713 705 696
714 698 704
715 709 707
716 715 713
717 683 711
718 717 710
719 711 715
720 716 719
721 701 713
722 696 721
723 718 717
724 723 721
725 720 718
726 717 717
727 726 715
728 725 712
729 727 701
730 725 724
731 729 727
732 722 725
733 724 727
734 710 730
735 704 730
736 726 720
737 732 716
738 733 737
739 734 725
740 736 738
741 737 719
742 738 733
743 733 718
744 722 742
745 743 735
746 719 742
747 739 743
748 735 734
749 748 729
750 738 725
751 744 749
752 751 749
753 741 752
754 746 722
755 750 753
756 755 749
757 746 747
758 752 753
759 746 757
760 725 757
761 739 757
762 752 752
763 762 737
764 758 732
765 762 735
766 765 762
767 766 746
768 762 758
769 765 760
770 764 752
771 770 765
772 768 751
773 764 765
774 772 758
775 773 754
776 768 768
777 767 772
778 753 756
779 738 768
780 764 778
781 777 755
782 779 779
783 781 780
784 783 783
785 779 773
786 780 773
787 775 781
788 780 785
789 786 768
790 764 772
791 762 788
792 790 774
793 784 774
794 784 792
795 793 789
796 789 795
797 796 785
798 790 797
799 796 797
800 799 799
801 800 800
802 792 783
803 785 802
804 802 791
805 795 793
806 802 804
807 792 806
808 797 783
809 805 800
810 784 804
811 809 808
812 807 795
813 805 807
814 810 812
815 809 810
816 809 799
817 791 801
818 817 790
819 807 796
820 816 819
821 811 815
822 810 813
823 815 810
824 820 823
825 817 815
826 809 818
827 826 824
828 827 822
829 824 820
830 826 812
831 818 823
832 830 810
833 830 832
834 804 831
835 833 811
836 832 823
837 836 832
838 832 816
839 835 836
840 831 832
841 837 827
842 838 839
843 840 841
844 839 820
845 835 839
846 841 843
847 843 840
848 843 832
849 847 845
850 845 847
851 833 848
852 851 829
853 844 850
854 840 847
855 837 851
856 830 852
857 844 827
858 849 856
859 833 853
860 859 825
861 859 855
862 859 854
863 856 852
864 854 861
865 864 859
866 846 865
867 858 849
868 863 858
869 865 866
870 866 862
871 852 867
872 854 868
873 864 868
874 868 855
875 870 873
876 873 853
877 870 870
878 874 851
879 855 869
880 878 877
881 874 879
882 860 871
883 879 874
884 861 877
885 882 873
886 883 866
887 878 886
888 884 884
889 854 867
890 889 883
891 887 882
892 883 876
893 877 884
894 864 891
895 892 890
896 879 888
897 894 896
898 892 861
899 897 884
900 855 892
901 894 897
902 893 887
903 902 886
904 889 894
905 898 904
906 890 900
907 887 899
908 902 876
909 897 902
910 908 905
911 906 907
912 903 894
913 908 907
914 912 907
915 876 914
916 901 907
917 913 915
918 910 912
919 917 912
920 916 917
921 912 913
922 905 917
923 897 897
924 919 901
925 923 919
926 885 924
927 923 921
928 895 912
929 925 928
930 919 924
931 904 926
932 912 926
933 915 926
934 929 924
935 929 923
936 930 932
937 925 932
938 928 921
939 926 923
940 928 938
941 934 937
942 931 935
943 929 942
944 923 942
945 929 918
946 917 927
947 944 943
948 899 939
949 941 941
950 943 943
951 943 944
952 945 931
953 949 947
954 947 952
955 928 947
956 953 935
957 936 952
958 948 943
959 950 914
960 933 954
961 926 956
962 954 957
963 961 962
964 955 960
965 963 949
966 916 949
967 965 965
968 950 949
969 965 963
970 969 952
971 947 965
972 958 968
973 967 959
974 973 960
975 973 963
976 975 967
977 976 975
978 976 936
979 968 977
980 941 943
981 973 971
982 981 976
983 966 978
984 967 982
985 980 978
986 981 970
987 985 981
988 985 983
989 959 985
990 979 978
991 971 975
992 980 974
993 982 991
994 991 945
995 990 994
996 962 992
997 992 993
998 989 988
999 987 997
1000 995 999
1001 997 960
1002 995 996
1003 985 1000
1004 981 982
1005 999 999
1006 990 1000
1007 1001 1006
1008 994 984
1009 1007 1003
1010 1004 1002
1011 1004 1007
1012 1006 1001
1013 990 1012
1014 1004 1012
1015 1010 1007
1016 1006 1012
1017 1012 1008
1018 998 1017
1019 1013 984
1020 1017 1017
1021 1011 1020
1022 1015 1019
1023 1007 1012
1024 1020 981
1025 1024 1021
1026 1015 1011
1027 1006 1012
1028 1017 1013
1029 1028 1028
1030 1024 1014
1031 1023 1025
1032 1030 1026
1033 1030 1026
1034 1028 1022
1035 1021 1023
1036 1029 1003
1037 1020 1018
1038 1008 1036
1039 1037 1035
1040 1036 1033
1041 1033 1024
1042 1030 1040
1043 1040 1014
1044 1030 1036
1045 1023 1027
1046 1038 1039
1047 1034 1039
1048 1045 1047
1049 1041 1047
1050 1032 1043
1051 1050 1040
1052 1046 1049
1053 1052 1044
1054 1052 1050
1055 1042 1042
1056 1055 1052
1057 1048 1050
1058 1049 1053
1059 1057 1049
1060 1051 1058
1061 1044 1045
1062 1049 1059
1063 1022 1048
1064 1059 1063
1065 1051 1058
1066 996 1064
1067 1065 1053
1068 1062 1058
1069 1068 1049
1070 1061 1047
1071 1063 1053
1072 1049 1070
1073 1071 1066
1074 1049 1072
1075 1070 1072
1076 1075 1075
1077 1073 1076
1078 1077 1069
1079 1068 1076
1080 1072 1078
1081 1065 1057
1082 1077 1077
1083 1058 1079
1084 1082 1070
1085 1079 1084
1086 1071 1071
1087 1082 1075
1088 1083 1079
1089 1080 1086
1090 1089 1088
1091 1087 1076
1092 1084 1072
1093 1051 1072
1094 1089 1075
1095 1093 1083
1096 1088 1094
1097 1066 1093
1098 1090 1097
1099 1081 1089
1100 1099 1091
1101 1098 1078
1102 1092 1101
1103 1085 1083
1104 1101 1103
1105 1104 1065
1106 1093 1096
1107 1083 1099
1108 1102 1107
1109 1090 1086
1110 1103 1108
1111 1109 1106
1112 1104 1108
1113 1110 1079
1114 1106 1094
1115 1104 1111
1116 1089 1109
1117 1101 1105
1118 1110 1109
1119 1115 1111
1120 1109 1119
1121 1108 1098
1122 1112 1111
1123 1121 1118
1124 1108 1106
1125 1121 1121
1126 1124 1112
1127 1122 1119
1128 1085 1118
1129 1117 1119
1130 1120 1127
1131 1128 1123
1132 1128 1126
1133 1125 1096
1134 1133 1126
1135 1121 1125
1136 1134 1133
1137 1134 1104
1138 1136 1128
1139 1128 1126
1140 1135 1128
1141 1102 1124
1142 1141 1138
1143 1080 1131
1144 1143 1142
1145 1144 1138
1146 1127 1137
1147 1143 1105
1148 1144 1143
1149 1136 1148
1150 1148 1149
1151 1145 1149
1152 1144 1146
1153 1146 1143
1154 1146 1150
1155 1127 1148
1156 1155 1151
1157 1151 1142
1158 1142 1156
1159 1155 1150
1160 1159 1137
1161 1142 1155
1162 1145 1159
1163 1146 1162
1164 1154 1157
1165 1163 1156
1166 1165 1164
1167 1134 1159
1168 1164 1157
1169 1165 1165
1170 1166 1165
1171 1164 1170
1172 1163 1171
1173 1158 1167
1174 1170 1165
1175 1174 1170
1176 1161 1169
1177 1157 1169
1178 1176 1167
1179 1178 1155
1180 1158 1177
1181 1176 1154
1182 1178 1173
1183 1173 1181
1184 1178 1182
1185 1184 1183
1186 1183 1179
1187 1186 1180
1188 1184 1186
1189 1175 1187
1190 1189 1184
1191 1189 1150
1192 1186 1189
1193 1191 1191
1194 1185 1192
1195 1192 1165
1196 1187 1186
1197 1193 1194
1198 1192 1193
1199 1189 1191
1200 1188 1178
1201 1186 1196
1202 1198 1200
1203 1200 1197
1204 1187 1201
1205 1204 1201
1206 1204 1201
1207 1204 1202
1208 1183 1193
1209 1195 1200
1210 1197 1209
1211 1191 1210
1212 1200 1209
1213 1211 1181
1214 1205 1206
1215 1209 1203
1216 1202 1209
1217 1215 1213
1218 1213 1211
1219 1217 1216
1220 1173 1209
1221 1214 1220
1222 1218 1210
1223 1220 1221
1224 1199 1218
1225 1221 1210
1226 1224 1224
1227 1211 1223
1228 1194 1223
1229 1198 1228
1230 1225 1223
1231 1227 1225
1232 1230 1222
1233 1205 1193
1234 1233 1212
1235 1224 1215
1236 1230 1223
1237 1232 1226
1238 1211 1193
1239 1237 1238
1240 1235 1230
1241 1240 1214
1242 1237 1232
1243 1242 1234
1244 1239 1243
1245 1236 1244
1246 1239 1210
1247 1213 1238
1248 1245 1246
1249 1245 1247
1250 1240 1224
1251 1250 1225
1252 1245 1228
1253 1252 1252
1254 1253 1235
1255 1248 1246
1256 1254 1234
1257 1237 1226
1258 1236 1256
1259 1248 1254
1260 1259 1252
1261 1234 1258
1262 1236 1261
1263 1260 1260
1264 1247 1248
1265 1258 1256
1266 1263 1259
1267 1246 1260
1268 1265 1263
1269 1268 1260
1270 1268 1264
1271 1268 1267
1272 1260 1270
1273 1250 1272
1274 1269 1261
1275 1271 1263
1276 1272 1273
1277 1263 1271
1278 1277 1277
1279 1265 1274
1280 1274 1257
1281 1269 1278
1282 1259 1279
1283 1277 1270
1284 1266 1281
1285 1283 1270
1286 1273 1280
1287 1277 1281
1288 1271 1270
1289 1284 1255
1290 1276 1285
1291 1284 1289
1292 1278 1288
1293 1291 1292
1294 1288 1273
1295 1291 1293
1296 1282 1271
1297 1292 1296
1298 1297 1288
1299 1297 1285
1300 1286 1291
1301 1292 1293
1302 1288 1290
1303 1300 1266
1304 1294 1295
1305 1292 1292
1306 1286 1293
1307 1306 1304
1308 1295 1301
1309 1305 1308
1310 1309 1294
1311 1308 1297
1312 1287 1310
1313 1306 1308
1314 1312 1311
1315 1309 1303
1316 1290 1313
1317 1304 1312
1318 1310 1310
1319 1308 1310
1320 1307 1314
1321 1320 1316
1322 1319 1317
1323 1296 1321
1324 1311 1318
1325 1314 1306
1326 1322 1316
1327 1300 1320
1328 1325 1315
1329 1323 1308
1330 1328 1308
1331 1326 1280
1332 1331 1331
1333 1282 1328
1334 1325 1311
1335 1327 1327
1336 1312 1335
1337 1334 1328
1338 1333 1308
1339 1337 1329
1340 1326 1330
1341 1335 1322
1342 1337 1330
1343 1342 1338
1344 1308 1320
1345 1344 1343
1346 1342 1337
1347 1319 1343
1348 1328 1346
1349 1345 1313
1350 1347 1345
1351 1346 1346
1352 1347 1350
1353 1346 1340
1354 1353 1353
1355 1348 1352
1356 1348 1353
1357 1356 1342
1358 1328 1355
1359 1356 1356
1360 1351 1342
1361 1347 1325
1362 1356 1358
1363 1355 1357
1364 1359 1359
1365 1360 1354
1366 1356 1363
1367 1365 1363
1368 1363 1358
1369 1324 1367
1370 1364 1349
1371 1365 1364
1372 1371 1370
1373 1349 1372
1374 1352 1369
1375 1363 1372
1376 1341 1363
1377 1338 1373
1378 1372 1356
1379 1378 1378
1380 1349 1369
1381 1372 1376
1382 1371 1371
1383 1382 1337
1384 1379 1373
1385 1344 1366
1386 1385 1381
1387 1383 1385
1388 1387 1387
1389 1385 1387
1390 1385 1384
1391 1384 1388
1392 1391 1391
1393 1383 1392
1394 1385 1389
1395 1382 1360
1396 1376 1392
1397 1396 1377
1398 1397 1397
1399 1378 1383
1400 1398 1378
1401 1400 1377
1402 1388 1398
1403 1402 1394
1404 1403 1395
1405 1401 1404
1406 1399 1404
1407 1399 1404
1408 1404 1399
1409 1377 1388
1410 1408 1404
1411 1381 1401
1412 1407 1406
1413 1405 1400
1414 1386 1406
1415 1406 1406
1416 1411 1400
1417 1400 1409
1418 1409 1416
1419 1413 1415
1420 1405 1402
1421 1417 1407
1422 1418 1416
1423 1404 1421
1424 1423 1405
1425 1418 1423
1426 1386 1418
1427 1414 1426
1428 1416 1425
1429 1427 1427
1430 1391 1422
1431 1421 1428
1432 1401 1430
1433 1421 1430
1434 1431 1433
1435 1427 1403
1436 1435 1425
1437 1431 1432
1438 1428 1433
1439 1434 1403
1440 1439 1428
1441 1407 1434
1442 1436 1438
1443 1426 1438
1444 1430 1435
1445 1444 1430
1446 1428 1444
1447 1439 1437
1448 1447 1446
1449 1443 1423
1450 1448 1445
1451 1450 1439
1452 1411 1426
1453 1435 1449
1454 1450 1450
1455 1453 1448
1456 1448 1447
1457 1447 1456
1458 1456 1438
1459 1456 1458
1460 1448 1453
1461 1459 1455
1462 1458 1448
1463 1438 1460
1464 1460 1454
1465 1462 1443
1466 1450 1462
1467 1465 1463
1468 1446 1449
1469 1461 1463
1470 1465 1462
1471 1470 1450
1472 1454 1467
1473 1465 1455
1474 1461 1467
1475 1473 1462
1476 1464 1456
1477 1475 1471
1478 1474 1477
1479 1470 1478
1480 1460 1479
1481 1463 1477
1482 1473 1481
1483 1461 1459
1484 1482 1482
1485 1460 1479
1486 1484 1477
1487 1482 1479
1488 1470 1484
1489 1485 1469
1490 1485 1489
1491 1490 1468
1492 1491 1489
1493 1491 1487
1494 1487 1487
1495 1493 1489
1496 1490 1495
1497 1492 1493
1498 1478 1474
1499 1495 1485
1500 1498 1491
1501 1495 1491
1502 1487 1493
1503 1498 1497
1504 1494 1497
1505 1481 1495
1506 1490 1498
1507 1481 1505
1508 1493 1507
1509 1488 1504
1510 1506 1499
1511 1490 1508
1512 1511 1505
1513 1500 1511
1514 1506 1509
1515 1509 1510
1516 1515 1498
1517 1488 1498
1518 1478 1501
1519 1511 1505
1520 1511 1508
1521 1508 1502
1522 1512 1515
1523 1516 1520
1524 1522 1497
1525 1505 1521
1526 1519 1500
1527 1517 1523
1528 1522 1520
1529 1526 1526
1530 1528 1527
1531 1529 1530
1532 1528 1521
1533 1526 1531
1534 1528 1525
1535 1529 1533
1536 1532 1509
1537 1536 1531
1538 1537 1536
1539 1508 1538
1540 1535 1535
1541 1520 1505
1542 1514 1527
1543 1542 1539
1544 1538 1541
1545 1544 1540
1546 1534 1530
1547 1500 1543
1548 1537 1536
1549 1544 1547
1550 1549 1542
1551 1541 1547
1552 1549 1524
1553 1540 1544
1554 1538 1547
1555 1526 1550
1556 1547 1550
1557 1549 1553
1558 1551 1550
1559 1554 1554
1560 1542 1550
1561 1545 1558
1562 1527 1540
1563 1559 1556
1564 1557 1562
1565 1563 1542
1566 1564 1564
1567 1557 1558
1568 1556 1566
1569 1548 1551
1570 1555 1554
1571 1547 1562
1572 1559 1569
1573 1567 1561
1574 1569 1561
1575 1571 1572
1576 1571 1559
1577 1576 1576
1578 1574 1570
1579 1576 1578
1580 1574 1577
1581 1555 1580
1582 1564 1548
1583 1547 1572
1584 1580 1583
1585 1573 1584
1586 1561 1580
1587 1577 1582
1588 1569 1587
1589 1588 1583
1590 1587 1584
1591 1582 1574
1592 1591 1587
1593 1590 1592
1594 1573 1589
1595 1593 1591
1596 1589 1579
1597 1595 1596
1598 1585 1597
1599 1593 1597
1600 1577 1586
1601 1588 1581
1602 1589 1586
1603 1574 1601
1604 1574 1603
1605 1589 1599
1606 1600 1589
1607 1592 1598
1608 1607 1604
1609 1608 1605
1610 1604 1601
1611 1566 1610
1612 1603 1604
1613 1580 1601
1614 1612 1613
1615 1602 1595
1616 1611 1614
1617 1615 1605
1618 1616 1613
1619 1613 1607
1620 1611 1602
1621 1619 1605
1622 1621 1605
1623 1620 1620
1624 1622 1622
1625 1623 1624
1626 1624 1607
1627 1616 1625
1628 1623 1625
1629 1610 1602
1630 1615 1604
1631 1625 1628
1632 1628 1628
1633 1630 1628
1634 1632 1627
1635 1629 1631
1636 1627 1626
1637 1635 1624
1638 1635 1607
1639 1632 1635
1640 1635 1624
1641 1637 1634
1642 1641 1631
1643 1641 1641
1644 1629 1633
1645 1630 1639
1646 1631 1628
1647 1640 1644
1648 1644 1645
1649 1638 1637
1650 1649 1642
1651 1648 1650
1652 1637 1646
1653 1642 1635
1654 1633 1648
1655 1645 1646
1656 1637 1653
1657 1656 1650
1658 1649 1652
1659 1648 1650
1660 1643 1655
1661 1641 1656
1662 1657 1653
1663 1655 1648
1664 1653 1661
1665 1649 1655
1666 1664 1651
1667 1657 1666
1668 1654 1654
1669 1652 1662
1670 1666 1669
1671 1663 1650
1672 1662 1659
1673 1672 1672
1674 1669 1672
1675 1646 1668
1676 1672 1656
1677 1674 1668
1678 1667 1673
1679 1678 1678
1680 1665 1679
1681 1679 1668
1682 1662 1671
1683 1671 1680
1684 1650 1667
1685 1679 1678
1686 1680 1684
1687 1681 1667
1688 1684 1673
1689 1678 1665
1690 1677 1684
1691 1683 1682
1692 1679 1687
1693 1690 1691
1694 1687 1687
1695 1690 1661
1696 1691 1694
1697 1692 1694
1698 1696 1686
1699 1695 1693
1700 1699 1698
1701 1692 1692
1702 1699 1689
1703 1697 1701
1704 1703 1697
1705 1686 1690
1706 1698 1703
1707 1701 1688
1708 1674 1705
1709 1708 1705
1710 1704 1703
1711 1705 1708
1712 1711 1711
1713 1703 1702
1714 1694 1705
1715 1710 1708
1716 1708 1713
1717 1679 1710
1718 1708 1696
1719 1706 1717
1720 1712 1694
1721 1711 1720
1722 1720 1721
1723 1715 1716
1724 1686 1722
1725 1724 1719
1726 1716 1717
1727 1723 1726
1728 1722 1698
1729 1717 1728
1730 1725 1726
1731 1725 1729
1732 1714 1729
1733 1732 1732
1734 1718 1691
1735 1720 1731
1736 1727 1729
1737 1725 1728
1738 1731 1726
1739 1730 1738
1740 1734 1738
1741 1739 1720
1742 1731 1738
1743 1741 1741
1744 1739 1742
1745 1736 1737
1746 1713 1745
1747 1726 1746
1748 1707 1722
1749 1743 1745
1750 1742 1747
1751 1745 1729
1752 1746 1748
1753 1751 1743
1754 1746 1742
1755 1754 1745
1756 1750 1730
1757 1744 1752
1758 1737 1755
1759 1749 1748
1760 1745 1737
1761 1759 1755
1762 1750 1742
1763 1762 1757
1764 1761 1750
1765 1762 1716
1766 1740 1757
1767 1747 1765
1768 1755 1764
1769 1744 1760
1770 1757 1767
1771 1768 1769
1772 1766 1761
1773 1761 1764
1774 1765 1772
1775 1754 1773
1776 1775 1755
1777 1766 1767
1778 1774 1770
1779 1776 1768
1780 1769 1770
1781 1761 1780
1782 1777 1773
1783 1738 1762
1784 1778 1778
1785 1781 1784
1786 1775 1776
1787 1778 1786
1788 1787 1782
1789 1783 1786
1790 1789 1746
1791 1788 1773
1792 1784 1787
1793 1790 1790
1794 1786 1790
1795 1789 1781
1796 1789 1795
1797 1771 1786
1798 1790 1780
1799 1797 1797
1800 1792 1799
1801 1797 1775
1802 1790 1795
1803 1797 1800
1804 1790 1790
1805 1747 1765
1806 1784 1802
1807 1782 1793
1808 1801 1807
1809 1790 1788
1810 1806 1796
1811 1804 1810
1812 1780 1808
1813 1783 1811
1814 1810 1805
1815 1794 1813
1816 1801 1813
1817 1810 1809
1818 1807 1811
1819 1805 1800
1820 1813 1807
1821 1813 1813
1822 1820 1816
1823 1811 1820
1824 1799 1804
1825 1822 1820
1826 1824 1820
1827 1821 1823
1828 1824 1825
1829 1824 1818
1830 1828 1826
1831 1803 1826
1832 1811 1830
1833 1820 1827
1834 1809 1831
1835 1819 1831
1836 1832 1823
1837 1827 1828
1838 1820 1835
1839 1837 1819
1840 1834 1831
1841 1833 1809
1842 1829 1830
1843 1837 1828
1844 1801 1827
1845 1844 1838
1846 1845 1842
1847 1845 1843
1848 1833 1838
1849 1847 1841
1850 1846 1847
1851 1850 1844
1852 1848 1851
1853 1839 1851
1854 1847 1825
1855 1845 1843
1856 1853 1847
1857 1848 1852
1858 1854 1836
1859 1846 1846
1860 1859 1859
1861 1859 1851
1862 1825 1858
1863 1851 1854
1864 1862 1860
1865 1852 1855
1866 1852 1855
1867 1857 1859
1868 1858 1865
1869 1866 1861
1870 1850 1869
1871 1868 1867
1872 1870 1852
1873 1867 1869
1874 1861 1871
1875 1866 1860
1876 1864 1874
1877 1867 1846
1878 1873 1872
1879 1872 1878
1880 1876 1873
1881 1872 1866
1882 1881 1879
1883 1855 1877
1884 1867 1880
1885 1874 1879
1886 1883 1877
1887 1866 1868
1888 1855 1885
1889 1887 1877
1890 1884 1886
1891 1875 1889
1892 1887 1890
1893 1876 1877
1894 1887 1870
1895 1890 1880
1896 1895 1887
1897 1884 1883
1898 1897 1891
1899 1894 1895
1900 1898 1891
1901 1879 1900
1902 1883 1898
1903 1901 1900
1904 1884 1901
1905 1903 1898
1906 1875 1902
1907 1898 1879
1908 1904 1901
1909 1905 1881
1910 1908 1886
1911 1910 1908
1912 1901 1890
1913 1912 1909
1914 1909 1910
1915 1913 1909
1916 1904 1903
1917 1909 1912
1918 1916 1915
1919 1915 1886
1920 1919 1912
1921 1913 1916
1922 1921 1915
1923 1921 1922
1924 1916 1902
1925 1912 1924
1926 1892 1890
1927 1922 1922
1928 1925 1923
1929 1917 1919
1930 1907 1929
1931 1926 1916
1932 1907 1925
1933 1926 1909
1934 1901 1901
1935 1926 1932
1936 1931 1929
1937 1928 1931
1938 1886 1931
1939 1937 1937
1940 1939 1934
1941 1940 1938
1942 1930 1940
1943 1936 1942
1944 1892 1943
1945 1944 1944
1946 1921 1922
1947 1931 1944
1948 1947 1946
1949 1933 1943
1950 1942 1948
1951 1946 1948
1952 1948 1940
1953 1937 1942
1954 1953 1947
1955 1951 1946
1956 1951 1946
1957 1954 1927
1958 1954 1945
1959 1954 1957
1960 1953 1957
1961 1959 1948
1962 1959 1935
1963 1954 1958
1964 1958 1960
1965 1943 1964
1966 1957 1962
1967 1958 1964
1968 1962 1967
1969 1968 1954
1970 1951 1967
1971 1962 1970
1972 1962 1945
1973 1971 1972
1974 1962 1972
1975 1949 1971
1976 1963 1961
1977 1967 1970
1978 1975 1973
1979 1969 1969
1980 1973 1978
1981 1961 1966
1982 1981 1975
1983 1980 1980
1984 1968 1972
1985 1984 1969
1986 1983 1979
1987 1981 1980
1988 1980 1959
1989 1975 1981
1990 1987 1984
1991 1975 1989
1992 1991 1991
1993 1991 1992
1994 1993 1976
1995 1994 1979
1996 1982 1992
1997 1994 1988
1998 1992 1990
1999 1978 1996
2000 1986 1969
2001 1990 1982
2002 1989 1966
2003 1994 2000
2004 1995 1962
2005 1999 1979
2006 2004 2004
2007 2006 2006
2008 2004 2007
2009 2002 1991
2010 2007 2007
2011 2007 1995
2012 2004 2006
2013 1993 1991
2014 2013 2008
2015 2006 2012
2016 2011 2006
2017 2010 1992
2018 2001 2001
2019 2017 2017
2020 2011 2010
2021 2018 2014
2022 2020 2013
2023 2012 2009
2024 2021 2016
2025 2017 1994
2026 2002 2004
2027 2023 2024
2028 2015 2003
2029 2024 2024
2030 2026 2014
2031 2027 2007
2032 2023 2031
2033 1999 2029
2034 2000 2024
2035 2029 2031
2036 2013 2035
2037 2036 2011
2038 2031 2009
2039 2036 2038
2040 2038 2037
2041 2030 2025
2042 2040 2039
2043 2042 2035
2044 2043 2031
2045 2039 2042
2046 2029 2022
2047 2046 2044
2048 2041 2046
2049 2042 2039
2050 2033 2032
2051 2047 2047
2052 2051 2041
2053 2051 2050
2054 2053 2051
2055 2052 2044
2056 2035 2045
2057 2053 2030
2058 2040 2041
2059 2030 2057
2060 2020 2056
2061 2024 2048
2062 2044 2054
2063 2043 2049
2064 2053 2061
2065 2063 2061
2066 2061 2059
2067 2059 2062
2068 2054 2044
2069 2058 2066
2070 2067 2068
2071 2067 2066
2072 2044 2060
2073 2058 2072
2074 2052 2073
2075 2065 2064
2076 2074 2075
2077 2062 2071
2078 2074 2052
2079 2076 2067
2080 2073 2070
2081 2070 2033
2082 2062 2081
2083 2078 2078
2084 2078 2063
2085 2083 2083
2086 2077 2079
2087 2085 2081
2088 2074 2065
2089 2084 2085
2090 2065 2089
2091 2073 2079
2092 2091 2070
2093 2089 2079
2094 2093 2090
2095 2090 2088
2096 2080 2093
2097 2076 2088
2098 2091 2071
2099 2094 2068
2100 2092 2095
2101 2098 2098
2102 2099 2099
2103 2098 2100
2104 2100 2091
2105 2098 2101
2106 2100 2092
2107 2100 2097
2108 2070 2091
2109 2106 2101
2110 2087 2104
2111 2102 2105
2112 2110 2105
2113 2101 2106
2114 2094 2113
2115 2112 2114
2116 2104 2101
2117 2096 2107
2118 2115 2115
2119 2112 2114
2120 2083 2116
2121 2118 2120
2122 2104 2094
2123 2121 2115
2124 2087 2119
2125 2123 2081
2126 2123 2118
2127 2104 2118
2128 2126 2098
2129 2120 2111
2130 2080 2117
2131 2128 2125
2132 2128 2111
2133 2101 2130
2134 2108 2133
2135 2129 2134
2136 2130 2134
2137 2129 2132
2138 2137 2135
2139 2124 2134
2140 2127 2133
2141 2140 2140
2142 2139 2130
2143 2135 2141
2144 2140 2139
2145 2130 2121
2146 2140 2145
2147 2107 2136
2148 2102 2144
2149 2129 2139
2150 2124 2117
2151 2143 2150
2152 2148 2148
2153 2128 2136
2154 2144 2153
2155 2122 2116
2156 2142 2145
2157 2150 2132
2158 2157 2152
2159 2149 2152
2160 2157 2151
2161 2157 2156
2162 2144 2161
2163 2161 2151
2164 2162 2150
2165 2156 2164
2166 2161 2162
2167 2148 2155
2168 2162 2164
2169 2162 2155
2170 2166 2161
2171 2168 2169
2172 2171 2167
2173 2172 2158
2174 2171 2167
2175 2156 2169
2176 2173 2147
2177 2168 2164
2178 2175 2174
2179 2168 2164
2180 2156 2176
2181 2166 2178
2182 2171 2175
2183 2177 2163
2184 2174 2170
2185 2184 2142
2186 2175 2179
2187 2184 2179
2188 2175 2185
2189 2173 2172
2190 2189 2148
2191 2176 2178
2192 2189 2189
2193 2191 2190
2194 2190 2188
2195 2186 2191
2196 2191 2185
2197 2181 2182
2198 2174 2183
2199 2198 2197
2200 2197 2199
2201 2188 2188
2202 2180 2194
2203 2189 2190
2204 2189 2189
2205 2201 2195
2206 2203 2198
2207 2205 2202
2208 2190 2199
2209 2199 2202
2210 2202 2205
2211 2208 2182
2212 2208 2186
2213 2205 2205
2214 2202 2212
2215 2209 2210
2216 2194 2186
2217 2202 2207
2218 2205 2216
2219 2216 2203
2220 2209 2219
2221 2212 2214
2222 2220 2215
2223 2220 2218
2224 2223 2205
2225 2223 2224
2226 2222 2221
2227 2204 2208
2228 2214 2207
2229 2204 2214
2230 2209 2223
2231 2230 2213
2232 2224 2231
2233 2213 2228
2234 2212 2227
2235 2230 2234
2236 2235 2235
2237 2226 2194
2238 2219 2235
2239 2231 2224
2240 2228 2234
2241 2233 2231
2242 2230 2237
2243 2242 2237
2244 2214 2237
2245 2230 2243
2246 2228 2237
2247 2227 2242
2248 2247 2228
2249 2247 2220
2250 2236 2209
2251 2169 2220
2252 2232 2251
2253 2247 2248
2254 2252 2251
2255 2249 2231
2256 2251 2244
2257 2255 2251
2258 2253 2256
2259 2239 2247
2260 2254 2249
2261 2258 2250
2262 2251 2261
2263 2255 2258
2264 2261 2258
2265 2237 2260
2266 2264 2255
2267 2248 2258
2268 2263 2239
2269 2256 2267
2270 2267 2237
2271 2265 2263
2272 2268 2267
2273 2272 2253
2274 2268 2259
2275 2269 2273
2276 2265 2269
2277 2276 2264
2278 2263 2254
2279 2259 2277
2280 2275 2279
2281 2275 2245
2282 2280 2279
2283 2278 2271
2284 2273 2282
2285 2276 2278
2286 2281 2284
2287 2272 2269
2288 2247 2285
2289 2270 2288
2290 2283 2282
2291 2285 2241
2292 2285 2286
2293 2291 2280
2294 2278 2292
2295 2288 2275
2296 2294 2282
2297 2289 2290
2298 2291 2293
2299 2285 2296
2300 2294 2298
2301 2300 2294
2302 2289 2300
2303 2299 2301
2304 2294 2270
2305 2302 2295
2306 2302 2305
2307 2295 2301
2308 2306 2292
2309 2305 2297
2310 2308 2304
2311 2303 2308
2312 2299 2307
2313 2292 2303
2314 2309 2286
2315 2310 2314
2316 2283 2310
2317 2311 2309
2318 2302 2316
2319 2314 2315
2320 2317 2294
2321 2316 2302
2322 2313 2314
2323 2294 2318
2324 2321 2292
2325 2307 2323
2326 2321 2317
2327 2324 2308
2328 2324 2310
2329 2324 2325
2330 2327 2325
2331 2318 2330
2332 2290 2327
2333 2318 2320
2334 2323 2316
2335 2288 2333
2336 2327 2311
2337 2335 2325
2338 2333 2325
2339 2334 2336
2340 2332 2339
2341 2329 2332
2342 2336 2310
2343 2340 2341
2344 2332 2339
2345 2339 2340
2346 2334 2324
2347 2340 2334
2348 2335 2336
2349 2328 2346
2350 2344 2348
2351 2344 2346
2352 2348 2351
2353 2338 2345
2354 2343 2348
2355 2335 2327
2356 2329 2331
2357 2349 2353
2358 2343 2356
2359 2326 2356
2360 2357 2333
2361 2360 2334
2362 2361 2358
2363 2358 2359
2364 2357 2349
2365 2362 2347
2366 2333 2356
2367 2362 2349
2368 2365 2357
2369 2347 2364
2370 2365 2369
2371 2363 2356
2372 2370 2364
2373 2368 2370
2374 2370 2371
2375 2373 2367
2376 2369 2367
2377 2374 2350
2378 2370 2375
2379 2371 2378
2380 2374 2376
2381 2377 2366
2382 2381 2380
2383 2380 2371
2384 2380 2381
2385 2382 2375
2386 2381 2374
2387 2370 2374
2388 2384 2359
2389 2385 2377
2390 2387 2372
2391 2385 2373
2392 2388 2384
2393 2392 2376
2394 2367 2392
2395 2380 2389
2396 2369 2393
2397 2393 2386
2398 2394 2383
2399 2392 2365
2400 2389 2397
2401 2396 2400
2402 2399 2340
2403 2398 2402
2404 2397 2401
2405 2402 2388
2406 2401 2405
2407 2401 2402
2408 2403 2407
2409 2369 2398
2410 2381 2403
2411 2409 2388
2412 2406 2409
2413 2403 2409
2414 2404 2412
2415 2410 2401
2416 2395 2411
2417 2404 2413
2418 2395 2398
2419 2387 2395
2420 2416 2418
2421 2413 2409
2422 2408 2417
2423 2399 2403
2424 2400 2405
2425 2424 2388
2426 2422 2414
2427 2425 2402
2428 2420 2424
2429 2411 2402
2430 2428 2428
2431 2417 2427
2432 2430 2409
2433 2430 2407
2434 2431 2426
2435 2433 2421
2436 2433 2431
2437 2428 2426
2438 2436 2417
2439 2435 2434
2440 2429 2439
2441 2430 2424
2442 2432 2435
2443 2440 2429
2444 2440 2443
2445 2438 2428
2446 2435 2438
2447 2432 2434
2448 2446 2445
2449 2440 2438
2450 2438 2445
2451 2446 2450
2452 2445 2444
2453 2452 2452
2454 2438 2443
2455 2453 2453
2456 2449 2453
2457 2452 2455
2458 2443 2456
2459 2446 2457
2460 2457 2458
2461 2444 2451
2462 2461 2459
2463 2448 2461
2464 2459 2460
2465 2415 2453
2466 2460 2445
2467 2451 2451
2468 2465 2462
2469 2460 2458
2470 2444 2453
2471 2466 2470
2472 2445 2461
2473 2466 2472
2474 2464 2469
2475 2452 2472
2476 2461 2457
2477 2467 2453
2478 2466 2468
2479 2466 2471
2480 2476 2451
2481 2462 2431
2482 2468 2470
2483 2478 2474
2484 2483 2481
2485 2481 2484
2486 2483 2482
2487 2482 2474
2488 2481 2476
2489 2487 2477
2490 2481 2482
2491 2489 2490
2492 2491 2491
2493 2488 2476
2494 2482 2476
2495 2488 2493
2496 2494 2473
2497 2490 2489
2498 2479 2492
2499 2462 2495
2500 2498 2465
2501 2473 2486
2502 2487 2487
2503 2501 2498
2504 2482 2503
2505 2502 2498
2506 2502 2484
2507 2496 2500
2508 2502 2503
2509 2506 2490
2510 2509 2509
2511 2483 2504
2512 2509 2506
2513 2499 2507
2514 2509 2507
2515 2514 2494
2516 2501 2512
2517 2514 2510
2518 2515 2512
2519 2506 2513
2520 2504 2517
2521 2518 2510
2522 2520 2512
2523 2521 2522
2524 2513 2509
2525 2519 2506
2526 2524 2524
2527 2515 2523
2528 2518 2526
2529 2522 2520
2530 2516 2528
2531 2528 2526
2532 2507 2520
2533 2518 2526
2534 2521 2516
2535 2522 2527
2536 2527 2527
2537 2527 2522
2538 2536 2530
2539 2527 2534
2540 2537 2539
2541 2537 2527
2542 2531 2509
2543 2538 2537
2544 2540 2534
2545 2536 2538
2546 2538 2540
2547 2538 2545
2548 2542 2544
2549 2516 2546
2550 2549 2538
2551 2542 2539
2552 2550 2537
2553 2552 2534
2554 2527 2550
2555 2535 2526
2556 2550 2547
2557 2553 2550
2558 2554 2557
2559 2556 2550
2560 2541 2548
2561 2557 2557
2562 2543 2553
2563 2557 2557
2564 2563 2546
2565 2526 2553
2566 2549 2562
2567 2555 2557
2568 2563 2566
2569 2554 2566
2570 2565 2563
2571 2562 2570
2572 2561 2566
2573 2568 2572
2574 2563 2573
2575 2557 2572
2576 2575 2561
2577 2576 2569
2578 2576 2572
2579 2574 2560
2580 2561 2519
2581 2576 2572
2582 2578 2580
2583 2576 2572
2584 2574 2583
2585 2558 2566
2586 2583 2577
2587 2561 2584
2588 2583 2578
2589 2577 2585
2590 2584 2577
2591 2588 2590
2592 2588 2579
2593 2582 2592
2594 2578 2587
2595 2570 2574
2596 2591 2591
2597 2586 2585
2598 2584 2597
2599 2598 2595
2600 2594 2597
2601 2590 2588
2602 2596 2587
2603 2594 2597
2604 2603 2567
2605 2599 2604
2606 2589 2589
2607 2599 2593
2608 2607 2605
2609 2599 2578
2610 2595 2609
2611 2600 2595
2612 2609 2611
2613 2605 2611
2614 2610 2612
2615 2604 2614
2616 2600 2603
2617 2607 2590
2618 2607 2610
2619 2615 2607
2620 2618 2596
2621 2607 2573
2622 2621 2611
2623 2622 2619
2624 2619 2618
2625 2619 2621
2626 2623 2606
2627 2626 2617
2628 2623 2607
2629 2614 2616
2630 2627 2624
2631 2628 2625
2632 2600 2605
2633 2627 2597
2634 2623 2633
2635 2634 2627
2636 2623 2627
2637 2630 2590
2638 2629 2634
2639 2625 2636
2640 2638 2634
2641 2629 2626
2642 2638 2637
2643 2626 2605
2644 2630 2641
2645 2644 2621
2646 2640 2639
2647 2646 2612
2648 2641 2638
2649 2647 2644
2650 2641 2649
2651 2648 2626
2652 2640 2647
2653 2637 2642
2654 2649 2652
2655 2654 2628
2656 2627 2627
2657 2652 2644
2658 2653 2623
2659 2630 2655
2660 2658 2654
2661 2650 2651
2662 2641 2655
2663 2656 2662
2664 2645 2650
2665 2652 2651
2666 2664 2665
2667 2664 2648
2668 2649 2665
2669 2648 2655
2670 2669 2665
2671 2664 2630
2672 2670 2665
2673 2672 2656
2674 2663 2654
2675 2674 2671
2676 2672 2667
2677 2666 2672
2678 2674 2670
2679 2659 2673
2680 2670 2664
2681 2674 2650
2682 2674 2664
2683 2680 2646
2684 2667 2674
2685 2659 2668
2686 2663 2684
2687 2669 2683
2688 2683 2674
2689 2679 2688
2690 2680 2684
2691 2660 2675
2692 2688 2689
2693 2692 2690
2694 2687 2654
2695 2683 2689
2696 2687 2656
2697 2694 2688
2698 2662 2691
2699 2687 2687
2700 2698 2694
2701 2700 2688
2702 2681 2697
2703 2691 2700
2704 2703 2695
2705 2704 2690
2706 2703 2692
2707 2704 2691
2708 2691 2702
2709 2673 2697
2710 2687 2698
2711 2685 2664
2712 2710 2701
2713 2707 2693
2714 2695 2713
2715 2710 2701
2716 2689 2710
2717 2713 2695
2718 2685 2709
2719 2707 2716
2720 2705 2717
2721 2712 2709
2722 2713 2712
2723 2721 2721
2724 2698 2712
2725 2691 2724
2726 2722 2721
2727 2725 2725
2728 2723 2721
2729 2724 2728
2730 2706 2726
2731 2730 2721
2732 2727 2718
2733 2708 2719
2734 2719 2710
2735 2722 2719
2736 2708 2733
2737 2726 2735
2738 2736 2731
2739 2733 2734
2740 2738 2738
2741 2727 2730
2742 2738 2731
2743 2741 2734
2744 2740 2737
2745 2705 2729
2746 2734 2739
2747 2745 2743
2748 2740 2740
2749 2745 2711
2750 2745 2739
2751 2748 2750
2752 2746 2750
2753 2723 2749
2754 2744 2753
2755 2750 2751
2756 2753 2749
2757 2751 2755
2758 2751 2757
2759 2754 2748
2760 2758 2755
2761 2753 2752
2762 2759 2755
2763 2727 2736
2764 2735 2741
2765 2745 2735
2766 2758 2758
2767 2740 2761
2768 2751 2748
2769 2765 2763
2770 2750 2742
2771 2750 2765
2772 2766 2768
2773 2767 2769
2774 2757 2771
2775 2772 2763
2776 2772 2767
2777 2740 2774
2778 2773 2774
2779 2777 2758
2780 2773 2774
2781 2769 2780
2782 2774 2771
2783 2778 2781
2784 2780 2783
2785 2776 2778
2786 2774 2771
2787 2783 2764
2788 2783 2773
2789 2786 2783
2790 2788 2769
2791 2790 2789
2792 2777 2782
2793 2769 2792
2794 2771 2793
2795 2789 2794
2796 2765 2794
2797 2790 2788
2798 2790 2794
2799 2798 2782
2800 2797 2799
2801 2790 2796
2802 2799 2786
2803 2787 2801
2804 2794 2786
2805 2798 2803
2806 2799 2791
2807 2786 2804
2808 2793 2773
2809 2799 2790
2810 2809 2804
2811 2809 2802
2812 2808 2810
2813 2801 2807
2814 2809 2793
2815 2807 2814
2816 2810 2800
2817 2784 2792
2818 2816 2817
2819 2810 2818
2820 2818 2811
2821 2816 2786
2822 2799 2820
2823 2805 2821
2824 2809 2795
2825 2815 2820
2826 2822 2812
2827 2821 2819
2828 2798 2825
2829 2824 2826
2830 2819 2808
2831 2829 2828
2832 2827 2825
2833 2821 2828
2834 2823 2829
2835 2829 2826
2836 2831 2835
2837 2801 2830
2838 2815 2834
2839 2838 2829
2840 2829 2828
2841 2839 2839
2842 2841 2841
2843 2824 2830
2844 2842 2819
2845 2840 2838
2846 2834 2843
2847 2832 2846
2848 2844 2838
2849 2842 2842
2850 2844 2849
2851 2850 2849
2852 2851 2846
2853 2824 2846
2854 2840 2843
2855 2835 2841
2856 2834 2849
2857 2847 2854
2858 2836 2857
2859 2856 2852
2860 2857 2841
2861 2857 2857
2862 2828 2845
2863 2854 2861
2864 2835 2825
2865 2860 2861
2866 2854 2856
2867 2864 2857
2868 2866 2862
2869 2867 2858
2870 2865 2858
2871 2863 2857
2872 2871 2866
2873 2869 2866
2874 2873 2862
2875 2873 2843
2876 2863 2865
2877 2871 2874
2878 2875 2842
2879 2835 2873
2880 2878 2873
2881 2875 2877
2882 2881 2881
2883 2860 2881
2884 2868 2880
2885 2875 2880
2886 2838 2841
2887 2883 2883
2888 2881 2881
2889 2872 2856
2890 2882 2858
2891 2871 2876
2892 2876 2886
2893 2869 2889
2894 2888 2884
2895 2890 2894
2896 2863 2890
2897 2890 2890
2898 2894 2895
2899 2879 2894
2900 2896 2893
2901 2890 2899
2902 2899 2887
2903 2902 2899
2904 2889 2901
2905 2901 2886
2906 2901 2893
2907 2904 2902
2908 2907 2900
2909 2902 2877
2910 2909 2890
2911 2895 2900
2912 2900 2883
2913 2901 2903
2914 2893 2897
2915 2911 2903
2916 2901 2897
2917 2914 2911
2918 2905 2915
2919 2872 2918
2920 2912 2919
2921 2918 2905
2922 2916 2912
2923 2902 2916
2924 2920 2915
2925 2921 2895
2926 2903 2914
2927 2924 2901
2928 2922 2925
2929 2902 2922
2930 2905 2921
2931 2926 2914
2932 2914 2919
2933 2915 2922
2934 2933 2915
2935 2914 2930
2936 2922 2935
2937 2934 2931
2938 2924 2937
2939 2937 2936
2940 2931 2925
2941 2925 2930
2942 2931 2935
2943 2933 2934
2944 2938 2929
2945 2943 2942
2946 2912 2932
2947 2928 2946
2948 2924 2943
2949 2948 2920
2950 2945 2949
2951 2945 2939
2952 2938 2949
2953 2950 2941
2954 2953 2949
2955 2954 2953
2956 2947 2939
2957 2950 2955
2958 2942 2956
2959 2954 2955
2960 2954 2935
2961 2957 2950
2962 2958 2960
2963 2950 2960
2964 2963 2963
2965 2944 2946
2966 2965 2949
2967 2949 2966
2968 2963 2967
2969 2964 2964
2970 2958 2939
2971 2934 2968
2972 2918 2968
2973 2962 2969
2974 2971 2969
2975 2970 2958
2976 2963 2931
2977 2969 2976
2978 2971 2969
2979 2962 2960
2980 2923 2974
2981 2974 2972
2982 2971 2978
2983 2978 2978
2984 2979 2975
2985 2984 2958
2986 2964 2985
2987 2986 2961
2988 2984 2985
2989 2982 2985
2990 2985 2979
2991 2987 2985
2992 2978 2989
2993 2991 2969
2994 2987 2958
2995 2983 2987
2996 2984 2992
2997 2967 2980
2998 2989 2980
2999 2990 2997
3000 2995 2999
| [
"xingjianbai0914@sina.com"
] | xingjianbai0914@sina.com |
049092663df1e1ad7b506685f510939da48f8fc8 | c1d7cd0b81923e54d18435ad7fdd119c290f0ddf | /10.11.cpp | c0e295f33ffaa33da481833c9ef2fb70545e4c3c | [] | no_license | leebingzheng/li_bingzheng | a6ba4f8d08dff21c5c408e7d03eeecca9a88839b | 6ebe1b67665499b981ec663879b803b46778b632 | refs/heads/master | 2020-04-02T06:24:31.630734 | 2019-04-21T12:08:12 | 2019-04-21T12:08:12 | 154,146,476 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 660 | cpp | #include "Polynomial.h"
#include <iostream>
#include <string>
#include <Polynomial.h>
using namespace std;
Polynomial::Polynomial(int a)
{
z=a;
x=new int[z+1]();
for(int i=0;i<z+1;++i)
x[i]=0;
}
Polynomial::~Polynomial()
{
delete[]x;
}
istream & operator>>(istream& input,Polynomial& a)
{
for(int i=0;i<a.z+1;++i)
cin>>a.x[i];
return input;
}
ostream & operator<<(ostream& output,const Polynomial &a)
{
for(int i=0;i<a.z+1;++i)
{
if(i==0)
cout<<a.x[i]<<"*"<<"x^"<<i;
else
cout<<"+"<<a.x[i]<<" "<<"x^"<<i;
}
cout<<endl;
return output;
}
Polynomial operator+(Polynomial& a,Polynomial& b)
{
}
| [
"1074586195@qq.com"
] | 1074586195@qq.com |
c2adde24185a998d43eaf5e925bf74d05a1f0644 | b974b958552668113dbe82409e4e08bb4e153150 | /main.cpp | 7978b35e1f67e00042fb73c8f40aeb012388f083 | [] | no_license | GeremiaPompei/boost_json_heap | 8826d8d5baf943163ebce113991da4ef1371f0bf | 7add00ff6efba33b553cf4fbdf08cb148f909677 | refs/heads/master | 2023-04-06T04:03:48.254984 | 2021-04-01T08:14:19 | 2021-04-01T08:14:19 | 353,110,401 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 971 | cpp | #include <iostream>
#include <vector>
#include "fibonacci_heap_handler.hpp"
#include "json_handler.hpp"
#include "value.hpp"
using namespace std;
/**
* Funzione main che fa partire l'esecuzione del programma.
*/
int main()
{
JsonHandler json;
FibonacciHeapHandler<Value> fib;
vector<Value> w;
cout << "Inserisci valori json con tale forma: {\"id\": 1, \"name\": \"value1\"}." << endl;
cout << "Digita exit per uscire." << endl;
char in[200] = "";
while (true) {
cout << " > ";
cin.getline(in, sizeof(in));
string s = string(in);
if(s == "exit") break;
try {
Value v = json.parser(s);
w.push_back(v);
fib.heapsort<Value>(&w);
for (int i = 0; i < w.size(); ++i)
cout << json.stringify(w[i]);
cout << endl;
}__catch(exception e) {
cout << "Error: " << e.what() << endl;
}
}
return 0;
}
| [
"geremia.pompei@studenti.unicam.it"
] | geremia.pompei@studenti.unicam.it |
cee78d7c6f635a018ffd6f231402a0d801a31536 | bcf681e46f3214a5d76bc92ab66cb3bda62da8a4 | /CSCE_313_Projects/PA3/SHMreqchannel.h | 6d7e4810f3b66e707ea93eb6dfb0585f11705547 | [] | no_license | AndersonIJ99/oldProjectsForPortfolio | 1930c0916587ce26aae2f20de0e4d7208da0997f | ccd94cd846d7301dde078ebb825ddd9726348d6d | refs/heads/master | 2023-02-28T10:16:54.727695 | 2021-02-02T20:08:56 | 2021-02-02T20:08:56 | 335,409,852 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,195 | h |
#ifndef _SHMreqchannel_H_
#define _SHMreqchannel_H_
#include <semaphore.h>
#include <sys/mman.h>
#include "common.h"
#include "Reqchannel.h"
#include <string>
using namespace std;
class SHMQ {
private:
char* segment;
sem_t* sd;
sem_t* rd;
string name;
int len;
public:
SHMQ (string _name, int _len) : name(_name), len(_len) {
int fd = shm_open(name.c_str(), O_RDWR|O_CREAT, 0600);
if(fd < 0) {
EXITONERROR("could not create/open shared memory segment");
}
ftruncate(fd, len); //set the length to 1024, the default is 0, so this is a necessary step
segment = (char *) mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if(!segment) {
EXITONERROR("Cannot map");
}
rd = sem_open((name + "_rd").c_str(), O_CREAT, 0600, 1); // initial val=1
sd = sem_open((name + "_sd").c_str(), O_CREAT, 0600, 0); // initial val=0
}
int my_shm_send(void* msg, int len) {
sem_wait(rd);
memcpy(segment, msg, len);
sem_post(sd);
return len;
}
int my_shm_recv(void* msg, int len) {
sem_wait(sd);
memcpy(msg, segment, len);
sem_post(rd);
return len;
}
~SHMQ () {
sem_close(sd);
sem_close(rd);
sem_unlink((name + "_rd").c_str());
sem_unlink((name + "_sd").c_str());
munmap(segment, len);
shm_unlink(name.c_str());
}
};
class SHMRequestChannel: public RequestChannel {
private:
SHMQ* shmq1;
SHMQ* shmq2;
int len;
public:
SHMRequestChannel(const string _name, const Side _side, int _len);
/* Creates a "local copy" of the channel specified by the given name.
If the channel does not exist, the associated IPC mechanisms are
created. If the channel exists already, this object is associated with the channel.
The channel has two ends, which are conveniently called "SERVER_SIDE" and "CLIENT_SIDE".
If two processes connect through a channel, one has to connect on the server side
and the other on the client side. Otherwise the results are unpredictable.
NOTE: If the creation of the request channel fails (typically happens when too many
request channels are being created) and error message is displayed, and the program
unceremoniously exits.
NOTE: It is easy to open too many request channels in parallel. Most systems
limit the number of open files per process.
*/
~SHMRequestChannel();
/* Destructor of the local copy of the bus. By default, the Server Side deletes any IPC
mechanisms associated with the channel. */
int cread (void* msgbuf, int bufcapacity);
/* Blocking read of data from the channel. You must provide the address to properly allocated
memory buffer and its capacity as arguments. The 2nd argument is needed because the recepient
side may not have as much capacity as the sender wants to send.
In reply, the function puts the read data in the buffer and
returns an integer that tells how much data is read. If the read fails, it returns -1. */
int cwrite (void *msgbuf , int msglen);
/* Writes msglen bytes from the msgbuf to the channel. The function returns the actual number of
bytes written and that can be less than msglen (even 0) probably due to buffer limitation (e.g., the recepient
cannot accept msglen bytes due to its own buffer capacity. */
};
#endif
| [
"mew1067@gmail.com"
] | mew1067@gmail.com |
febd4bfaf0d06bef7d2dc05e27debf764eccc0aa | 7d497f964e20fbfa6ddfc980858f676eb1a8e274 | /main.cpp | f381df2d79351c480b17820fe94cf100f1af6141 | [] | no_license | jhirniak/keylogger | 41bd0d588088e1d74ca8f444c45cf09554e60159 | 6780826a0219479ac4eb27ffd2b6a5406d7f2754 | refs/heads/master | 2020-05-18T01:03:08.519176 | 2015-01-07T11:22:55 | 2015-01-07T11:22:55 | 28,909,591 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,397 | cpp | #include <windows.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdbool.h>
#include <stdlib.h>
bool invisible = true;
char fileName[MAX_PATH];
void hide(void)
{
HWND stealth;
/* Retrieves a handle to the top-level window whose class name and window name match the specified strings.
1st Parmeter lpClassName: ConsoleWindowClass - Class Name
2nd Parameter lpWindowName: parameter is NULL, all window names match.
If the function succeeds, the return value is a handle to the window that has the specified class name and window name.
If the function fails, the return value is NULL.
*/
stealth = FindWindow("ConsoleWindowClass", NULL );
ShowWindow(stealth, 0);
}
void init(void)
{
// get path to appdata folder
char* dest = "%appdata%\\windows.log";
/* Expands the envirnment variable given into a usable path
1st Parameter lpSrc: A buffer that contains one or more environment-variable strings in the form: %variableName%.
2nd Parameter lpDst: A pointer to a buffer that receives the result of expanding the environment variable strings in the lpSrc buffer.
3rd Parameter nSize: The maximum number of characters that can be stored in the buffer pointed to by the lpDst parameter.
The return value is the fully expanded pathname.
*/
ExpandEnvironmentStrings(dest, fileName, MAX_PATH);
// open file
FILE *file;
file = fopen(fileName, "a+");
time_t startTime = time(0);
// see if file is empty
long savedOffset = ftell(file);
fseek(file, 0, SEEK_END);
if (!ftell(file) == 0) fputc('\n', file);
fseek(file, savedOffset, SEEK_SET);
// print timestamp
fputs("### Started logging at: ", file);
fputs(ctime(&startTime), file);
fclose(file);
}
void powerdown(void)
{
// get path to appdata folder
char* dest = "%appdata%\\windows.log";
ExpandEnvironmentStrings(dest, fileName, MAX_PATH);
// open file
FILE *file;
file = fopen(fileName, "a+");
time_t endTime = time(0);
fputs("\n### Stopped logging at: ", file);
fputs(ctime(&endTime), file);
fclose(file);
}
char getFileName()
{
return fileName;
}
int main(int argc, char* argv[])
{
int startKeyLogging(char* argv[]);
if (invisible) hide();
init();
start(argv);
atexit(powerdown); // only works if process isn't killed
}
| [
"j@hirniak.info"
] | j@hirniak.info |
7b4d3a4a2fddf53e76a7cac7651d501fe0189655 | 2d16f56549a1becb433cab7bf7bc08f0c9bdb930 | /chap4/pr4_1.cpp | 66052560207fbef0fe7666082a397b39ac326e7e | [] | no_license | ferng/cppBeginners | 275811ce762af8ad1cf2e3870da7b702f3aa5a80 | 708a83d150fde776a40f4da86301005ee090eb50 | refs/heads/master | 2020-09-15T11:23:58.621735 | 2019-11-22T15:27:20 | 2019-11-22T15:28:50 | 223,431,399 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 530 | cpp | #include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int nums[10];
int a, b, t;
int size;
size = 10;
for (t = 0; t < size; t++)
nums[t] = rand();
cout << "Array is:\n";
for (t = 0; t < size; t++)
cout << nums[t] << ' ';
for (a = 1; a < size; a++) {
for (b = size-1; b >= a; b--) {
if (nums[b-1] > nums[b]) {
t = nums[b-1];
nums[b-1] = nums[b];
nums[b] = t;
}
}
}
cout << "\nOnce sorted array is\n";
for (t = 0; t < size; t++)
cout << nums[t] << ' ';
return 0;
}
| [
"ferng001@gmail.com"
] | ferng001@gmail.com |
e7f8f757f773affb21f3eddeb74c19cdc9a68f3f | 1bf8b46afad5402fe6fa74293b464e1ca5ee5fd7 | /SDK/BP_MiniGame_SmartBall_SimpleBase_parameters.h | e6726b807594cb733394c401309c3064cd7b94dc | [] | no_license | LemonHaze420/ShenmueIIISDK | a4857eebefc7e66dba9f667efa43301c5efcdb62 | 47a433b5e94f171bbf5256e3ff4471dcec2c7d7e | refs/heads/master | 2021-06-30T17:33:06.034662 | 2021-01-19T20:33:33 | 2021-01-19T20:33:33 | 214,824,713 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 902 | h | #pragma once
#include "../SDK.h"
// Name: Shenmue3SDK, Version: 1.4.1
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
// Parameters
//---------------------------------------------------------------------------
// Function BP_MiniGame_SmartBall_SimpleBase.BP_MiniGame_SmartBall_SimpleBase_C.InitializeBingoType
struct ABP_MiniGame_SmartBall_SimpleBase_C_InitializeBingoType_Params
{
int InputPin; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData)
};
// Function BP_MiniGame_SmartBall_SimpleBase.BP_MiniGame_SmartBall_SimpleBase_C.UserConstructionScript
struct ABP_MiniGame_SmartBall_SimpleBase_C_UserConstructionScript_Params
{
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"35783139+LemonHaze420@users.noreply.github.com"
] | 35783139+LemonHaze420@users.noreply.github.com |
bab23d4f274c2db5bd2a783f29136041dc1c2c5f | 5bef53b0dc9539a4953919f75fde1f0ebd20e9fb | /ICPC/Sharif_2019/I.cpp | 1f74dfa7c7f160dd019cb7912fb5e832dc659e65 | [] | no_license | atrin-hojjat/CompetetiveProgramingCodes | 54c8b94092f7acf40d379e42e1f2c0fe8dab9b32 | 6a02071c3869b8e7cd873ddf7a3a2d678aec6d91 | refs/heads/master | 2020-11-25T10:51:23.200000 | 2020-10-08T11:12:09 | 2020-10-08T11:12:09 | 228,626,397 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,000 | cpp | #include <iostream>
#include <cstring>
#include <vector>
using namespace std;
const int MaxN = 2e5 + 6.66;
struct Segment {
long long seg[(int) (2e5 + 6.66) * 4];
long long laz[(int) (2e5 + 6.66) * 4];
int upd[(int) (2e5 + 6.66) * 4];
Segment() {
memset(seg, 0, sizeof seg);
memset(laz, 0, sizeof laz);
memset(upd, 0, sizeof upd);
}
void push(int id, int l, int r, int x) {
seg[id] = 1ll * (r - l) * x;
laz[id] = x;
upd[id] = true;
}
void push_down(int id, int l, int r) {
if(!upd[id]) return ;
int mid = l + (r - l) / 2;
push(id << 1, l, mid, laz[id]);
push(id << 1 | 1, mid, r, laz[id]);
upd[id] = 0;
laz[id] = 0;
}
void inc(int id, int l, int r, int x, int val) {
if(l >= r) return ;
if(l > x || r <= x) return;
if(l + 1 == r) {
seg[id] += val;
return;
}
push_down(id, l, r);
int mid = l + (r - l) / 2;
inc(id << 1, l, mid, x, val);
inc(id << 1 | 1, mid, r, x, val);
seg[id] = seg[id << 1] + seg[id << 1 | 1];
}
void set(int id, int l, int r, int b, int e, long long x) {
if(l >= r) return ;
if(l >= e || r <= b) return ;
if(l >= b && r <= e) {
push(id, l, r, x);
return ;
}
push_down(id, l, r);
int mid = l + (r - l) / 2;
set(id << 1, l, mid, b, e, x);
set(id << 1 | 1, mid, r, b, e, x);
seg[id] = seg[id << 1] + seg[id << 1 | 1];
}
int get(int id, int l, int r, int x) {
if(l >= r) return -1;
if(l > x || r <= x) return -1;
if(l + 1 == r) return seg[id];
push_down(id, l, r);
int mid = l + (r - l) / 2;
if(x < mid) return get(id << 1, l, mid, x);
return get(id << 1 | 1, mid, r, x);
}
pair<int, int> binary(int id, int l, int r, int b, int e, int x) {
if(l >= r) return {-1, x};
if(l >= e || r <= b) return {-1, x};
push_down(id, l, r);
int mid = l + (r - l) / 2;
if(l >= b && r <= e) {
if(seg[id] <= x) return {r, x - seg[id]};
if(l + 1 == r) return {l, x};
if(seg[id << 1] > x) return binary(id << 1, l, mid, b, e, x);
else return binary(id << 1 | 1, mid, r, b, e, x - seg[id << 1]);
}
auto T = binary(id << 1, l, mid, b, e, x);
int t = T.first;
int s = T.second;
if(t == mid || t < 0) return binary(id << 1 | 1, mid, r, b, e, s);
return T;
}
int get(int i) {
return get(1, 0, MaxN, i);
}
void add(int i, int j) {
auto X = binary(1, 0, MaxN, i, MaxN, j);
set(1, 0, MaxN, i, X.first, 0);
if(X.first < MaxN) inc(1, 0, MaxN, X.first, -X.second);
}
} seg;
int A[MaxN];
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
int n, q; cin >> n >> q;
for(int i = 0; i < n; i++) {
cin >> A[i];
seg.inc(1, 0, MaxN, i, A[i]);
}
while(q--) {
int t; cin >> t;
if(t == 1) {
int a, b; cin >> a >> b;
a--;
seg.add(a, b);
} else {
int x; cin >> x;
x--;
cout << A[x] - seg.get(x) << endl;
}
}
return 0;
}
| [
"magic.h.s.atrin@gmail.com"
] | magic.h.s.atrin@gmail.com |
3c384efd88fda77f22eb44d42a9992f6e1e26a2d | fe6ef75f0e51bf88ba917162f5c31b5ac3cfd5ba | /create_image_task.cpp | 24f4f4ccbef67cfd9dd609b28d61d9471600dead | [
"MIT"
] | permissive | Sauexceed/Fractal_Designer | 5f1d1b8621321500aaf49f0296687838182f767c | 7b8289fbfb4c527786b49b6beeef35356d6a1abf | refs/heads/master | 2023-06-16T17:40:18.404673 | 2021-06-21T15:10:17 | 2021-06-21T15:10:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,280 | cpp | #include "create_image_task.h"
#include "mainwindow.h"
Create_Image_Task::Create_Image_Task(QWidget* parent)
{
MainWindow* p = (MainWindow*) parent;
connect(this, &Create_Image_Task::updateImage_preview, p, &MainWindow::getImage);
connect(this, &Create_Image_Task::progressInform_preview, p, &MainWindow::updateProgressBar);
connect(this, &Create_Image_Task::finished, p, &MainWindow::build_image_finished_deal);
connect(this, &Create_Image_Task::one_ok, p, &MainWindow::build_image_one_ok);
connect(this, &Create_Image_Task::updateImage_route, p->route_tool_window, &Route_Tool::getImage);
connect(this, &Create_Image_Task::progressInform_route, p->route_tool_window, &Route_Tool::updateProgressBar);
connect(p, &MainWindow::createImageStop, this, &Create_Image_Task::stop);
}
void Create_Image_Task::run()
{
qDebug() << "Got it here";
y = -y;
if(!Version_Higher_Than_4) // low version
{
QFile Colour_saved_1(pro_path + "/Colour_Set_1.txt");
if(Colour_saved_1.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in1(&Colour_saved_1);
for(int j = 0; j != 4; j++)
{
for(int i = 0; i != 29; i++)
{
in1 >> Colour_Data[0][j][i][0] >> Colour_Data[0][j][i][1];
}
}
Colour_saved_1.close();
}
QFile Colour_saved_2(pro_path + "/Colour_Set_2.txt");
if(Colour_saved_2.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in2(&Colour_saved_2);
for(int j = 0; j != 4; j++)
{
for(int i = 0; i != 29; i++)
{
in2 >> Colour_Data[1][j][i][0] >> Colour_Data[1][j][i][1];
}
}
Colour_saved_2.close();
}
}
qDebug() << "The working thread: " << QThread::currentThreadId();
double progress = 0;
int progress_now = 0;
if(!Version_Higher_Than_4)
{
QFile Template_(pro_path + "/Template_Choice.txt");
if(Template_.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in3(&Template_);
in3 >> template_;
Template_.close();
}
QFile Define_Value_(pro_path + "/Define_Value.txt");
if(Define_Value_.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in4(&Define_Value_);
in4 >> min_class_v >> max_class_v >> max_loop_t;
Define_Value_.close();
}
}
// qDebug() << QThread::currentThreadId();
QImage image_build(X, Y, QImage::Format_ARGB32);
for(int i = X - 1; i >= 0; i--)
{
if(isCancelled) return;
progress = 100 * static_cast<double>(X - i) / X;
if(static_cast<int>(progress) > progress_now)
{
if(work_name == "Preview") emit progressInform_preview(progress);
if(work_name == "Route") emit progressInform_route(progress);
progress_now = static_cast<int>(progress);
}
for(int j = Y - 1; j >= 0; j--)
{
double dx = x_width * (static_cast<double>(i) / X - 0.5);
double dy = y_height * (static_cast<double>(j) / Y - 0.5);
double mod = sqrt(dx * dx + dy * dy);
double theta = atan2(dy, dx) + rotate_angle / 180 * Pi;
Complex this_point(x + mod * cos(theta),
y + mod * sin(theta));
Complex z0(this_point), last_point(-this_point);
bool test = true;
int k = 0;
for (k = 0; k < max_loop_t; k++)
{
if ((double)this_point.modulus() > max_class_v)
{
test = false;
break;
}
else if (template_ != 4 && (double)this_point.modulus() < min_class_v)
{
// test = true;
break;
}
else if (template_ == 4 && (double)(this_point - last_point).modulus() / (double)(this_point.modulus()) < min_class_v)
{
// test = true;
break;
}
else
{
if (template_ == 4) last_point = this_point;
switch(template_)
{
case 1: this_point = (this_point ^ 2.0) + z0; break;
case 2: this_point = (this_point ^ 2.0) + c0; break;
case 3: this_point = (Complex(fabs(this_point.getReal()), fabs(this_point.getImaginary())) ^ 2.0) + z0; break;
case 4:
{
Complex p = 0, p_ = 0;
for(int i = 0; i != 10; i++)
{
p += Newton_xn[i] * (this_point ^ double(i));
p_ += Newton_xn[i] * (this_point ^ double(i - 1)) * Complex(i);
}
p += Newton_ex * exp(this_point);
p += Newton_sin * sin(this_point);
p += Newton_cos * cos(this_point);
p_ += Newton_ex * exp(this_point);
p_ += Newton_sin * cos(this_point);
p_ -= Newton_cos * sin(this_point);
this_point = this_point - Newton_a * p / p_;
}
default: break;
}
}
}
if(test)
{
double RGBA1[4] = {0, 0, 0, 0};
for(int m = 0; m != 4; m++)
{
RGBA1[m] = (Colour_Data[0][m][0][0] * t + Colour_Data[0][m][0][1]) * k +
(Colour_Data[0][m][1][0] * t + Colour_Data[0][m][1][1]) * this_point.getReal() +
(Colour_Data[0][m][2][0] * t + Colour_Data[0][m][2][1]) * this_point.getImaginary() +
(Colour_Data[0][m][3][0] * t + Colour_Data[0][m][3][1]) * (double)this_point.modulus() +
(Colour_Data[0][m][4][0] * t + Colour_Data[0][m][4][1]) * (double)this_point.modulus() / min_class_v +
(Colour_Data[0][m][5][0] * t + Colour_Data[0][m][5][1]) * this_point.argz() +
(Colour_Data[0][m][6][0] * t + Colour_Data[0][m][6][1]) * sin(this_point.argz()) +
(Colour_Data[0][m][7][0] * t + Colour_Data[0][m][7][1]) * cos(this_point.argz()) +
(Colour_Data[0][m][8][0] * t + Colour_Data[0][m][8][1]) * z0.getReal() +
(Colour_Data[0][m][9][0] * t + Colour_Data[0][m][9][1]) * z0.getImaginary() +
(Colour_Data[0][m][10][0] * t + Colour_Data[0][m][10][1]) * (double)z0.modulus() +
(Colour_Data[0][m][11][0] * t + Colour_Data[0][m][11][1]) * (double)z0.modulus() / min_class_v +
(Colour_Data[0][m][12][0] * t + Colour_Data[0][m][12][1]) * z0.argz() +
(Colour_Data[0][m][13][0] * t + Colour_Data[0][m][13][1]) * sin(z0.argz()) +
(Colour_Data[0][m][14][0] * t + Colour_Data[0][m][14][1]) * (double)(this_point - z0).modulus() +
(Colour_Data[0][m][15][0] * t + Colour_Data[0][m][15][1]) * exp((k > 10) ? 10 : k) +
(Colour_Data[0][m][16][0] * t + Colour_Data[0][m][16][1]) * exp(log(10) * ((k > 10) ? 10 : k)) +
(Colour_Data[0][m][17][0] * t + Colour_Data[0][m][17][1]) * log(1 + (double)this_point.modulus()) +
(Colour_Data[0][m][18][0] * t + Colour_Data[0][m][18][1]) * log(1 + (double)z0.modulus()) +
(Colour_Data[0][m][19][0] * t + Colour_Data[0][m][19][1]) * log(1 + (double)(this_point - z0).modulus()) +
(Colour_Data[0][m][20][0] * t + Colour_Data[0][m][20][1]) * exp((double)this_point.modulus() > 10 ? 10 : (double)this_point.modulus() > 10) +
(Colour_Data[0][m][21][0] * t + Colour_Data[0][m][21][1]) * exp((double)z0.modulus() > 10 ? 10 : (double)z0.modulus()) +
(Colour_Data[0][m][22][0] * t + Colour_Data[0][m][22][1]) * exp((double)(this_point - z0).modulus() > 10 ? 10 : (double)this_point.modulus()) +
(Colour_Data[0][m][23][0] * t + Colour_Data[0][m][23][1]) * exp(log(10) * (double)this_point.modulus() > 10 ? 10 : log(10) * (double)this_point.modulus()) +
(Colour_Data[0][m][24][0] * t + Colour_Data[0][m][24][1]) * exp(log(10) * (double)z0.modulus() > 10 ? 10 : log(10) * (double)z0.modulus()) +
(Colour_Data[0][m][25][0] * t + Colour_Data[0][m][25][1]) * exp(log(10) * (double)(this_point - z0).modulus()) +
(Colour_Data[0][m][26][0] * t + Colour_Data[0][m][26][1]) * exp((double)this_point.modulus() / min_class_v > 10 ? 10 : (double)this_point.modulus() / min_class_v) +
(Colour_Data[0][m][27][0] * t + Colour_Data[0][m][27][1]) * exp((double)z0.modulus() / min_class_v > 10 ? 10 : (double)z0.modulus() / min_class_v) +
(Colour_Data[0][m][28][0] * t + Colour_Data[0][m][28][1]);
if(RGBA1[m] < 0) RGBA1[m] = 0;
else if(RGBA1[m] > 255) RGBA1[m] = 255;
}
image_build.setPixel(i, j, qRgba(RGBA1[0], RGBA1[1], RGBA1[2], RGBA1[3]));
}
else
{
double RGBA2[4];
for(int m = 0; m != 4; m++)
{
RGBA2[m] = (Colour_Data[1][m][0][0] * t + Colour_Data[1][m][0][1]) * k +
(Colour_Data[1][m][1][0] * t + Colour_Data[1][m][1][1]) * this_point.getReal() +
(Colour_Data[1][m][2][0] * t + Colour_Data[1][m][2][1]) * this_point.getImaginary() +
(Colour_Data[1][m][3][0] * t + Colour_Data[1][m][3][1]) * (double)this_point.modulus() +
(Colour_Data[1][m][4][0] * t + Colour_Data[1][m][4][1]) * (double)this_point.modulus() / max_class_v +
(Colour_Data[1][m][5][0] * t + Colour_Data[1][m][5][1]) * this_point.argz() +
(Colour_Data[1][m][6][0] * t + Colour_Data[1][m][6][1]) * sin(this_point.argz()) +
(Colour_Data[1][m][7][0] * t + Colour_Data[1][m][7][1]) * cos(this_point.argz()) +
(Colour_Data[1][m][8][0] * t + Colour_Data[1][m][8][1]) * z0.getReal() +
(Colour_Data[1][m][9][0] * t + Colour_Data[1][m][9][1]) * z0.getImaginary() +
(Colour_Data[1][m][10][0] * t + Colour_Data[1][m][10][1]) * (double)z0.modulus() +
(Colour_Data[1][m][11][0] * t + Colour_Data[1][m][11][1]) * (double)z0.modulus() / max_class_v +
(Colour_Data[1][m][12][0] * t + Colour_Data[1][m][12][1]) * z0.argz() +
(Colour_Data[1][m][13][0] * t + Colour_Data[1][m][13][1]) * sin(z0.argz()) +
(Colour_Data[1][m][14][0] * t + Colour_Data[1][m][14][1]) * (double)(this_point - z0).modulus() +
(Colour_Data[1][m][15][0] * t + Colour_Data[1][m][15][1]) * exp((k > 10) ? 10 : k) +
(Colour_Data[1][m][16][0] * t + Colour_Data[1][m][16][1]) * exp(log(10) * ((k > 10) ? 10 : k)) +
(Colour_Data[1][m][17][0] * t + Colour_Data[1][m][17][1]) * log(1 + (double)this_point.modulus()) +
(Colour_Data[1][m][18][0] * t + Colour_Data[1][m][18][1]) * log(1 + (double)z0.modulus()) +
(Colour_Data[1][m][19][0] * t + Colour_Data[1][m][19][1]) * log(1 + (double)(this_point - z0).modulus()) +
(Colour_Data[1][m][20][0] * t + Colour_Data[1][m][20][1]) * exp((double)this_point.modulus() > 10 ? 10 : (double)this_point.modulus() > 10) +
(Colour_Data[1][m][21][0] * t + Colour_Data[1][m][21][1]) * exp((double)z0.modulus() > 10 ? 10 : (double)z0.modulus()) +
(Colour_Data[1][m][22][0] * t + Colour_Data[1][m][22][1]) * exp((double)(this_point - z0).modulus() > 10 ? 10 : (double)this_point.modulus()) +
(Colour_Data[1][m][23][0] * t + Colour_Data[1][m][23][1]) * exp(log(10) * (double)this_point.modulus() > 10 ? 10 : log(10) * (double)this_point.modulus()) +
(Colour_Data[1][m][24][0] * t + Colour_Data[1][m][24][1]) * exp(log(10) * (double)z0.modulus() > 10 ? 10 : log(10) * (double)z0.modulus()) +
(Colour_Data[1][m][25][0] * t + Colour_Data[1][m][25][1]) * exp(log(10) * (double)(this_point - z0).modulus()) +
(Colour_Data[1][m][26][0] * t + Colour_Data[1][m][26][1]) * exp((double)this_point.modulus() / max_class_v > 10 ? 10 : (double)this_point.modulus() / max_class_v) +
(Colour_Data[1][m][27][0] * t + Colour_Data[1][m][27][1]) * exp((double)z0.modulus() / max_class_v > 10 ? 10 : (double)z0.modulus() / max_class_v) +
(Colour_Data[1][m][28][0] * t + Colour_Data[1][m][28][1]);
if(RGBA2[m] < 0) RGBA2[m] = 0;
else if(RGBA2[m] > 255) RGBA2[m] = 255;
}
image_build.setPixel(i, j, qRgba(RGBA2[0], RGBA2[1], RGBA2[2], RGBA2[3]));
}
}
}
qDebug() << img_path + "/" + img_title + "." + img_format;
image_build.save(img_path + "/" + img_title + "." + img_format);
image_build.load(img_path + "/" + img_title + "." + img_format);
if(work_name == "Preview") emit updateImage_preview(image_build);
if(work_name == "Route") emit updateImage_route(image_build);
if(work_name == "Create_Image") emit one_ok();
if(work_name == "Create_Image_Last") emit finished();
// delete this;
}
void Create_Image_Task::setImage(double x_, double y_, double x_width_, double y_height_, int X_, int Y_, double rotate_angle_, double t_,
QString img_format_, QString img_path_, QString img_title_, QString work_name_)
{
x = x_;
y = y_;
x_width = x_width_;
y_height = y_height_;
X = X_;
Y = Y_;
rotate_angle = rotate_angle_;
t = t_;
img_format = img_format_;
img_path = img_path_;
img_title = img_title_;
work_name = work_name_;
}
void Create_Image_Task::setPath(QString str)
{
pro_path = str;
}
void Create_Image_Task::setData(double C1[4][29][2], double C2[4][29][2], int temp, double min, double max, int lpt)
{
For_All_Colour(i, j)
Colour_Data[0][i][j][0] = C1[i][j][0];
Colour_Data[0][i][j][1] = C1[i][j][1];
Colour_Data[1][i][j][0] = C2[i][j][0];
Colour_Data[1][i][j][1] = C2[i][j][1];
End_All_Colour
template_ = temp;
min_class_v = min < 1E-10 ? 1E-10 : min;
max_class_v = max < 1E-10 ? 1E-10 : max;
max_loop_t = lpt;
}
void Create_Image_Task::setTemplate2(const Complex& c)
{
c0 = c;
}
void Create_Image_Task::setTemplate4(const Complex& c1, Complex* c2, const Complex& c3, const Complex& c4, const Complex& c5)
{
Newton_a = c1;
for(int i = 0; i != 10; i++) Newton_xn[i] = c2[i];
Newton_sin = c3;
Newton_cos = c4;
Newton_ex = c5;
}
void Create_Image_Task::setVersion(bool v)
{
Version_Higher_Than_4 = v;
}
void Create_Image_Task::stop()
{
isCancelled = true;
}
| [
"teddy-jerry@qq.com"
] | teddy-jerry@qq.com |
54a82dcc2e59588acd3eedfbca0072e7adada9a3 | 1a93a3b56dc2d54ffe3ee344716654888b0af777 | /env/Library/include/qt/QtQuick/qquickrendercontrol.h | 8ec9b8aafc1f9f730bbbaf473b09bcd9c4a0722a | [
"BSD-3-Clause",
"GPL-1.0-or-later",
"GPL-3.0-only",
"GPL-2.0-only",
"Python-2.0",
"LicenseRef-scancode-python-cwi",
"LicenseRef-scancode-other-copyleft",
"0BSD",
"LicenseRef-scancode-free-unknown"
] | permissive | h4vlik/TF2_OD_BRE | ecdf6b49b0016407007a1a049f0fdb952d58cbac | 54643b6e8e9d76847329b1dbda69efa1c7ae3e72 | refs/heads/master | 2023-04-09T16:05:27.658169 | 2021-02-22T14:59:07 | 2021-02-22T14:59:07 | 327,001,911 | 0 | 0 | BSD-3-Clause | 2021-02-22T14:59:08 | 2021-01-05T13:08:03 | null | UTF-8 | C++ | false | false | 2,871 | h | /****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QQUICKRENDERCONTROL_H
#define QQUICKRENDERCONTROL_H
#include <QtQuick/qtquickglobal.h>
#include <QtGui/QImage>
QT_BEGIN_NAMESPACE
class QQuickWindow;
class QOpenGLContext;
class QQuickRenderControlPrivate;
class QThread;
class Q_QUICK_EXPORT QQuickRenderControl : public QObject
{
Q_OBJECT
public:
explicit QQuickRenderControl(QObject *parent = nullptr);
~QQuickRenderControl() override;
void prepareThread(QThread *targetThread);
void initialize(QOpenGLContext *gl);
void invalidate();
void polishItems();
void render();
bool sync();
QImage grab();
static QWindow *renderWindowFor(QQuickWindow *win, QPoint *offset = nullptr);
virtual QWindow *renderWindow(QPoint *offset) { Q_UNUSED(offset); return nullptr; }
Q_SIGNALS:
void renderRequested();
void sceneChanged();
private:
Q_DECLARE_PRIVATE(QQuickRenderControl)
};
QT_END_NAMESPACE
#endif // QQUICKRENDERCONTROL_H
| [
"martin.cernil@ysoft.com"
] | martin.cernil@ysoft.com |
e6eaf640255ad4d165cf8ef6930537ea5e4e5ec5 | 446fdbad810bd6623b4995184b82f8c0d5987902 | /leetcode/leetcode/35. 搜索插入位置.cpp | c6bf3c54b172c598553f597938f7fe0538357c9f | [] | no_license | 19865044959/code_test | 74f258769f627f45ba8c829d14a3111335e48562 | 371d1cb89f401290715b42e7f72299aace7ede8c | refs/heads/main | 2023-04-17T19:14:37.449157 | 2021-05-13T01:48:28 | 2021-05-13T01:48:28 | 366,901,912 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,112 | cpp | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <unordered_map>
using namespace std;
/**********************************************************************************************************
方法:暴力法
说明:
时间复杂度与空间复杂度:O(n) O(1)
涉及到的知识点:
***********************************************************************************************************/
class Solution {
public:
int searchInsert(vector<int>& nums, int target) {
int n = nums.size();
int i;
for(i = 0; i < n; i++){
if(nums[i] >= target) return i;
}
return i;
}
};
/**********************************************************************************************************
方法:二分查找法
说明:
时间复杂度与空间复杂度:O(logn) O(1)
涉及到的知识点:
***********************************************************************************************************/
class Solution {
public:
int searchInsert(vector<int>& nums, int target) {
int low = 0;
int high = nums.size() - 1;
while(low < high){
int medium = low + (high - low) / 2;
if(nums[medium] == target) return medium;
if(nums[medium] > target){
high = medium - 1;
}
else{
low = medium + 1;
}
}
int maxVal = max(low, high);
if(nums[maxVal] >= target) return maxVal;
else return maxVal + 1;
}
};
/**********************************************************************************************************
方法:STL库
说明:
时间复杂度与空间复杂度:O(n) O(1)
涉及到的知识点:
***********************************************************************************************************/
class Solution {
public:
int searchInsert(vector<int>& nums, int target) {
return lower_bound(nums.begin(), nums.end(), target) - nums.begin();
}
}; | [
"huanyzhang@foxmail.com"
] | huanyzhang@foxmail.com |
3b2e429c1eb06161a280cd1aa8357f356ff4660f | 9c83aa016dbee6d5ca49cc30cd03bab6d02c30ec | /LanMap Filter/cdp.cpp | 43d74f236077ec91d012acdbdf3f440e99f66465 | [] | no_license | trevelyanuk/SMPF-Client | a8240b856f9550354d59967bb7215d005e9014ea | 716e58552343ed701fc2dc2fbea2c7e7ae6367dd | refs/heads/master | 2020-04-05T14:05:47.766995 | 2019-08-03T20:43:12 | 2019-08-03T20:43:12 | 94,760,868 | 1 | 1 | null | 2019-08-13T19:40:29 | 2017-06-19T09:39:23 | C++ | UTF-8 | C++ | false | false | 9,980 | cpp |
//http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/cdp/configuration/15-mt/cdp-15-mt-book/nm-cdp-discover.html
void getDataCDP()
{
unsigned int count = 0;
/*
Destination MAC address - which is octet 0 - 5
*/
//%02x, rather than %x, will enforce a mininum field size - so a value of 1 becomes 01 and e becomes 0e. The 0 specifies that it should be 0 padded, the 2 represents the number of 0s.
printf("\tDestination MAC address:\t %02x:%02x:%02x:%02x:%02x:%02x", packetData[0], packetData[1], packetData[2], packetData[3], packetData[4], packetData[5]);
/*
Source MAC address - which is octet 6 - 11
*/
printf("\n\tSource MAC address:\t\t %02x:%02x:%02x:%02x:%02x:%02x", packetData[6], packetData[7], packetData[8], packetData[9], packetData[10], packetData[11]);
/*
CDP uses Ethernet 1 headers, so bytes 12 and 13 are length
*/
printf("\n\tLength:\t\t %i", (packetData[12] << 8 | packetData[13]));
/*
CDP uses 802.2 LLC with SNAP headers, sp the next 8 bytes are LLC information, with SNAP extensions for Cisco:
DSAP (1)
SSAP (1)
Control Field (1)
(snap extension)
OUI (3)
Protocol ID (2)
Bytes 14, 15, 16 are LLC
Bytes 17, 18, 19 are the OUI (if its 0, then the PID is assumed to be the Ethertype, anything else indicates organisational specific things). Cisco is 0x00000c
Bytes 20 and 21 are the Protocol ID, which will usually be EtherType. CDP is 2000 (0x2000)
//https://www.informit.com/library/content.aspx?b=CCNP_Studies_Troubleshooting&seqNum=53
//https://en.wikipedia.org/wiki/Subnetwork_Access_Protocol
** CDP **
For CDP, Bytes 22 and 23 are the version of CDP and the TTL
24 and 25 are the checksum
Anything beyond 23 is going to be TLV data. Last 4 octets will be the CRC Checksum, though
*/
printf("\n\t Cisco Discovery Protcol version %i\n\t TTL:%i", packetData[22], packetData[23]);
//http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm is no longer available apparently, so I cant access it to find out the spec
count = 26;
for (count; count < packetHeader->len; )
{
unsigned int type = (packetData[count] << 8 | packetData[count + 1]);
unsigned int length = (packetData[count + 2] << 8 | packetData[count + 3]); //length of the TLV - that includes the type and length itself!
//length = length & mask;
count += 4;
length -= 4;
if (length > 500)
{
int k = 5;
}
unsigned char value[512] = "";
switch (type)
{
case 0x01:
{
printf("\n\n\tDevice ID: ");
memcpy(&systemswName, packetData + count, length);
slsystemswName = strlen(systemswName);
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x02:
{
printf("\n\n\tAddress: ");
//Number of addresses
long numberOfAddresses = (packetData[count] << 24 | packetData[count] << 16 | packetData[count + 2] << 8 | packetData[count + 3]);
count += 4;
length -= 4;
for (UINT16 x = 0; x < numberOfAddresses; x++)
{
//Protocol type
//Protocol length
count += 2;
//This is an IP address
if (packetData[count] == 0xcc)
{
printf("IP Address: ");
count++;
//This is how long it is
int addressLength = (packetData[count] << 8 | packetData[count + 1]);
count += 2;
sprintf_s(systemswIP, "%i.%i.%i.%i", packetData[count], packetData[count + 1], packetData[count + 2], packetData[count + 3]);
printf(systemswIP);
slsystemswIP = strlen(systemswIP);
count += addressLength;
}
}
break;
}
case 0x03:
{
printf("\n\n\tPort-ID: ");
memcpy(&systemswitchport, packetData + count, length);
slsystemswitchport = strlen(systemswitchport);
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
break;
}
case 0x04:
{
printf("\n\n\tCapability: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x05:
{
printf("\n\n\tVersion String: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x06:
{
printf("\n\n\tPlatform: ");
memcpy(&systemswMAC, packetData + count, length);
slsystemswMAC = strlen(systemswMAC);
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x07:
{
printf("\n\n\tPrefixes: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x08:
{
printf("\n\n\tProtocol-Hello option: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x09:
{
printf("\n\n\tVTP Management Domain: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x0a:
{
printf("\n\n\tNative VLAN ID: ");
int port_vlan = (packetData[count] << 8 | packetData[count + 1]);
//printf("VLAN ID: %i", port_vlan);
_itoa_s(port_vlan, systemvlan, 10);
slsystemvlan = strlen(systemvlan);
count += 2;
printf("%i", port_vlan);
break;
}
case 0x0b:
{
printf("\n\n\tDuplex: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x0c:
{
printf("\n\n\tDONT KNOW LOL");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x0d:
{
printf("\n\n\tDONT KNOW LOL");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x0e:
{
printf("\n\n\tATA-186 VoIP VLAN request: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x0f:
{
printf("\n\n\tATA-186 VoIP VLAN assignment: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x10:
{
printf("\n\n\tPower Consumption: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x11:
{
printf("\n\n\tMTU: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x12:
{
printf("\n\n\tAVVID Trust Bitmap: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x13:
{
printf("\n\n\tAVVID Untrusted Ports CoS: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x14:
{
printf("\n\n\tSystem Name: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x15:
{
printf("\n\n\tSystem Object ID (Not Decoded): ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x16:
{
printf("\n\n\tManagement Addresses: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x17:
{
printf("\n\n\tPhysical Location: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x18:
{
printf("\n\n\tUNKNOWN: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x19:
{
printf("\n\n\tUNKNOWN: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x1a:
{
printf("\n\n\tPower Available: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x1b:
{
printf("\n\n\tUNKNOWN: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x1c:
{
printf("\n\n\tUNKNOWN: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x1d:
{
printf("\n\n\tEnergyWise: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x1e:
{
printf("\n\n\tUNKNOWN: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
case 0x1f:
{
printf("\n\n\tSpare PoE: ");
for (UINT16 x = 0; x < length; x++)
{
value[x] = packetData[count];
count++;
}
printf("%s", value);//, count - length);
break;
}
default:
{
printf("\n\n\t *** Unknown *** value = %s", value);
break;
}
}
}
} | [
"cellotape@gmail.com"
] | cellotape@gmail.com |
d586d9eaa0883b0c9ea2714b2f753a49360e649a | 04b1803adb6653ecb7cb827c4f4aa616afacf629 | /chromeos/services/device_sync/public/cpp/fake_device_sync_client.cc | f756216f32e422eb5fa1f43030e902156c9f87ff | [
"BSD-3-Clause"
] | permissive | Samsung/Castanets | 240d9338e097b75b3f669604315b06f7cf129d64 | 4896f732fc747dfdcfcbac3d442f2d2d42df264a | refs/heads/castanets_76_dev | 2023-08-31T09:01:04.744346 | 2021-07-30T04:56:25 | 2021-08-11T05:45:21 | 125,484,161 | 58 | 49 | BSD-3-Clause | 2022-10-16T19:31:26 | 2018-03-16T08:07:37 | null | UTF-8 | C++ | false | false | 4,058 | cc | // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/device_sync/public/cpp/fake_device_sync_client.h"
#include "chromeos/components/multidevice/remote_device.h"
#include "chromeos/components/multidevice/remote_device_cache.h"
namespace chromeos {
namespace device_sync {
FakeDeviceSyncClient::FakeDeviceSyncClient() = default;
FakeDeviceSyncClient::~FakeDeviceSyncClient() = default;
void FakeDeviceSyncClient::ForceEnrollmentNow(
mojom::DeviceSync::ForceEnrollmentNowCallback callback) {
force_enrollment_now_callback_queue_.push(std::move(callback));
}
void FakeDeviceSyncClient::ForceSyncNow(
mojom::DeviceSync::ForceSyncNowCallback callback) {
force_sync_now_callback_queue_.push(std::move(callback));
}
multidevice::RemoteDeviceRefList FakeDeviceSyncClient::GetSyncedDevices() {
return synced_devices_;
}
base::Optional<multidevice::RemoteDeviceRef>
FakeDeviceSyncClient::GetLocalDeviceMetadata() {
return local_device_metadata_;
}
void FakeDeviceSyncClient::SetSoftwareFeatureState(
const std::string public_key,
multidevice::SoftwareFeature software_feature,
bool enabled,
bool is_exclusive,
mojom::DeviceSync::SetSoftwareFeatureStateCallback callback) {
set_software_feature_state_callback_queue_.push(std::move(callback));
}
void FakeDeviceSyncClient::FindEligibleDevices(
multidevice::SoftwareFeature software_feature,
FindEligibleDevicesCallback callback) {
find_eligible_devices_callback_queue_.push(std::move(callback));
}
void FakeDeviceSyncClient::GetDebugInfo(
mojom::DeviceSync::GetDebugInfoCallback callback) {
get_debug_info_callback_queue_.push(std::move(callback));
}
int FakeDeviceSyncClient::GetForceEnrollmentNowCallbackQueueSize() {
return force_enrollment_now_callback_queue_.size();
}
int FakeDeviceSyncClient::GetForceSyncNowCallbackQueueSize() {
return force_sync_now_callback_queue_.size();
}
int FakeDeviceSyncClient::GetSetSoftwareFeatureStateCallbackQueueSize() {
return set_software_feature_state_callback_queue_.size();
}
int FakeDeviceSyncClient::GetFindEligibleDevicesCallbackQueueSize() {
return find_eligible_devices_callback_queue_.size();
}
int FakeDeviceSyncClient::GetGetDebugInfoCallbackQueueSize() {
return get_debug_info_callback_queue_.size();
}
void FakeDeviceSyncClient::InvokePendingForceEnrollmentNowCallback(
bool success) {
DCHECK(force_enrollment_now_callback_queue_.size() > 0);
std::move(force_enrollment_now_callback_queue_.front()).Run(success);
force_enrollment_now_callback_queue_.pop();
}
void FakeDeviceSyncClient::InvokePendingForceSyncNowCallback(bool success) {
DCHECK(force_sync_now_callback_queue_.size() > 0);
std::move(force_sync_now_callback_queue_.front()).Run(success);
force_sync_now_callback_queue_.pop();
}
void FakeDeviceSyncClient::InvokePendingSetSoftwareFeatureStateCallback(
mojom::NetworkRequestResult result_code) {
DCHECK(set_software_feature_state_callback_queue_.size() > 0);
std::move(set_software_feature_state_callback_queue_.front())
.Run(result_code);
set_software_feature_state_callback_queue_.pop();
}
void FakeDeviceSyncClient::InvokePendingFindEligibleDevicesCallback(
mojom::NetworkRequestResult result_code,
multidevice::RemoteDeviceRefList eligible_devices,
multidevice::RemoteDeviceRefList ineligible_devices) {
DCHECK(find_eligible_devices_callback_queue_.size() > 0);
std::move(find_eligible_devices_callback_queue_.front())
.Run(result_code, eligible_devices, ineligible_devices);
find_eligible_devices_callback_queue_.pop();
}
void FakeDeviceSyncClient::InvokePendingGetDebugInfoCallback(
mojom::DebugInfoPtr debug_info_ptr) {
DCHECK(get_debug_info_callback_queue_.size() > 0);
std::move(get_debug_info_callback_queue_.front())
.Run(std::move(debug_info_ptr));
get_debug_info_callback_queue_.pop();
}
} // namespace device_sync
} // namespace chromeos
| [
"sunny.nam@samsung.com"
] | sunny.nam@samsung.com |
08dde59c33d5b689e59069dea2581c10236be166 | 27f817ac1c8be0ad473279d02a514e419b5bd6fc | /November Game/MenuState.cpp | 9a809641579a3bf76401136df6c4b178da883fac | [] | no_license | Swistaak/November-Game | 7281a058d5b8bad4d3880dd0cca898deaff33607 | 5b6dfe4307905e9809f30c6816871c5990f41e2d | refs/heads/master | 2020-07-23T02:55:30.907076 | 2017-07-21T09:43:23 | 2017-07-21T09:43:23 | 73,818,352 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 641 | cpp | #include "MenuState.h"
#include "Game.h"
#include "PlayState.h"
MenuState MenuState::mMenuState;
void MenuState::init(Game * game)
{
font.loadFromFile("font\\dpcomic.ttf");
startText.setFont(font);
startText.setPosition(390, 380);
startText.setString("Press space key to start game");
}
void MenuState::cleanup()
{
}
void MenuState::pause()
{
}
void MenuState::resume()
{
}
void MenuState::handleEvents(Game * game)
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
game->changeState(PlayState::instance());
}
void MenuState::update(Game * game)
{
}
void MenuState::draw(Game * game)
{
game->window.draw(startText);
}
| [
"sswistak123@gmail.com"
] | sswistak123@gmail.com |
8b936fdde655462343005273550c31ada8bc705d | 1bd2698bde9265ab4741358c2b8e1bec1901e7f9 | /Tonb0.1/AutLib/Geom/Merge/Point/Merge_Pnt.hxx | 22b2e2974082aec71e55569618dd3549debbcb1c | [] | no_license | amir5200fx/Tonb0.1 | 150f9843ce3ad02da2ef18f409a100964c08983a | 7b17c6d2b3ddeca8e6b2900967b9599b0b1d61ed | refs/heads/master | 2022-01-17T09:47:25.291502 | 2019-06-14T13:27:39 | 2019-06-14T13:27:39 | 169,406,796 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,232 | hxx | #pragma once
#ifndef _Merge_Pnt_Header
#define _Merge_Pnt_Header
#include <Global_Macros.hxx>
#include <Standard_TypeDef.hxx>
#include <Traits.hxx>
#include <error.hxx>
#include <OSstream.hxx>
#include <memory>
#include <vector>
#include <algorithm>
namespace AutLib
{
class Merge_Info
{
/*Private Data*/
Standard_Real theResolution_;
Standard_Real theRadius_;
protected:
Merge_Info();
Merge_Info
(
const Standard_Real theRes,
const Standard_Real theRadius
)
: theResolution_(theRes)
, theRadius_(theRadius)
{}
public:
// Static data members
static const Standard_Real DEFAULT_RESOLUTION;
static const Standard_Real DEFAULT_RADIUS;
Standard_Real Resolution() const
{
return theRadius_;
}
Standard_Real Radius() const
{
return theRadius_;
}
void SetResolution
(
const Standard_Real theRes
)
{
theResolution_ = theRes;
}
void SetRadius
(
const Standard_Real theRadius
)
{
theRadius_ = theRadius;
}
};
template<class Point>
class Merge_Params
{
/*Private Data*/
Point thePmin_;
Point thePmax_;
Standard_Real theDelta_;
Standard_Integer theMaxIndex_;
protected:
Merge_Params()
: theDelta_(0)
, theMaxIndex_(0)
{}
void SetPmin
(
const Point& theCoord
)
{
thePmin_ = theCoord;
}
void SetPmax
(
const Point& theCoord
)
{
thePmax_ = theCoord;
}
void SetDelta
(
const Standard_Real Value
)
{
theDelta_ = Value;
}
void SetMaxIndex
(
const Standard_Integer Value
)
{
theMaxIndex_ = Value;
}
public:
const Point& Pmin() const
{
return thePmin_;
}
Point& Pmin()
{
return thePmin_;
}
const Point& Pmax() const
{
return thePmax_;
}
Point& Pmax()
{
return thePmax_;
}
Standard_Real Delta() const
{
return theDelta_;
}
Standard_Integer MaxIndex() const
{
return theMaxIndex_;
}
};
template<int Dim> struct Merge_StaticMemory
{
protected: static std::vector<Standard_Integer> keys;
};
template<> std::vector<Standard_Integer> Merge_StaticMemory<2>::keys(9);
template<> std::vector<Standard_Integer> Merge_StaticMemory<3>::keys(27);
enum Merge_PntAlg
{
Merge_PntAlg_Mean,
Merge_PntAlg_Substitude
};
template
<
class Point,
template<class> class NodeVector,
Merge_PntAlg Alg = Merge_PntAlg_Mean
>
class Merge_Pnt
: public Merge_Info
, public Merge_Params<Point>
, public Merge_StaticMemory<Point::dim>
{
public:
//typedef typename remove_pointer<Point>::type Point;
typedef Merge_Params<Point> Params;
typedef Merge_StaticMemory<Point::dim> memory;
typedef Merge_Info Base;
template< bool cond, typename U >
using resolvedType = typename std::enable_if< cond, U >::type;
struct node
{
//- coordinate of the node
Point Coord;
//- index of the node
Standard_Integer Index;
};
typedef std::shared_ptr<std::vector<std::shared_ptr<node>>>
nodeListPtr;
template<class Point>
using Merge_NodeTable = std::vector<nodeListPtr>;
typedef Merge_NodeTable<std::shared_ptr<node>> nodeTable;
typedef std::vector<std::shared_ptr<node>> nodeList;
typedef std::vector<Standard_Integer> indexList;
private:
/*Private Data*/
const NodeVector<Point>* theCoords_;
nodeList theNodes_;
Standard_Boolean IsDone_;
/*Private functions and operators*/
Standard_Integer Round
(
const Standard_Real x
) const
{
return (Standard_Integer)floor(x + 0.5);
}
Standard_Integer Key
(
const Point& theCoord
) const
{
Standard_Integer key = 0;
for (Standard_Integer i = 1; i <= Point::nbCmpts; i++)
key += Round
(
MAX(theCoord.Coord(i) - Params::Pmin().Coord(i),
(Standard_Real)0.) / Params::Delta()
);
return key;
}
template<class U = void>
resolvedType
<
is_two_dimension<(int)Point::dim>::value, U
>
Keys
(
const Standard_Real d,
const Point& theCoord
) const
{
Standard_Real Xo = theCoord.X();
Standard_Real Yo = theCoord.Y();
memory::keys[0] = Key(Point(Xo - d, Yo - d));
memory::keys[1] = Key(Point(Xo, Yo - d));
memory::keys[2] = Key(Point(Xo + d, Yo - d));
memory::keys[3] = Key(Point(Xo - d, Yo));
memory::keys[4] = Key(theCoord);
memory::keys[5] = Key(Point(Xo + d, Yo));
memory::keys[6] = Key(Point(Xo - d, Yo + d));
memory::keys[7] = Key(Point(Xo, Yo + d));
memory::keys[8] = Key(Point(Xo + d, Yo + d));
}
template<class U = void>
resolvedType
<
is_three_dimension<(int)Point::dim>::value, U
>
Keys
(
const Standard_Real d,
const Point& theCoord
) const
{
Standard_Real Xo = theCoord.X();
Standard_Real Yo = theCoord.Y();
Standard_Real Zo = theCoord.Z();
memory::keys[0] = Key(Point(Xo - d, Yo - d, Zo - d));
memory::keys[1] = Key(Point(Xo, Yo - d, Zo - d));
memory::keys[2] = Key(Point(Xo + d, Yo - d, Zo - d));
memory::keys[3] = Key(Point(Xo - d, Yo, Zo - d));
memory::keys[4] = Key(Point(Xo, Yo, Zo - d));
memory::keys[5] = Key(Point(Xo + d, Yo, Zo - d));
memory::keys[6] = Key(Point(Xo - d, Yo + d, Zo - d));
memory::keys[7] = Key(Point(Xo, Yo + d, Zo - d));
memory::keys[8] = Key(Point(Xo + d, Yo + d, Zo - d));
memory::keys[9] = Key(Point(Xo - d, Yo - d, Zo));
memory::keys[10] = Key(Point(Xo, Yo - d, Zo));
memory::keys[11] = Key(Point(Xo + d, Yo - d, Zo));
memory::keys[12] = Key(Point(Xo - d, Yo, Zo));
memory::keys[13] = Key(theCoord);
memory::keys[14] = Key(Point(Xo + d, Yo, Zo));
memory::keys[15] = Key(Point(Xo - d, Yo + d, Zo));
memory::keys[16] = Key(Point(Xo, Yo + d, Zo));
memory::keys[17] = Key(Point(Xo + d, Yo + d, Zo));
memory::keys[18] = Key(Point(Xo - d, Yo - d, Zo + d));
memory::keys[19] = Key(Point(Xo, Yo - d, Zo + d));
memory::keys[20] = Key(Point(Xo + d, Yo - d, Zo + d));
memory::keys[21] = Key(Point(Xo - d, Yo, Zo + d));
memory::keys[22] = Key(Point(Xo, Yo, Zo + d));
memory::keys[23] = Key(Point(Xo + d, Yo, Zo + d));
memory::keys[24] = Key(Point(Xo - d, Yo + d, Zo + d));
memory::keys[25] = Key(Point(Xo, Yo + d, Zo + d));
memory::keys[26] = Key(Point(Xo + d, Yo + d, Zo + d));
}
nodeList Search
(
const Point& theCoord,
const nodeTable& theTable
) const
{
Standard_Real d = 0.499*Params::Delta();
Keys(d, theCoord);
std::sort(memory::keys.begin(), memory::keys.end());
Standard_Integer perKey = -IntegerLast();
nodeList nodes;
for (const auto& key : memory::keys)
{
if (key <= perKey) continue;
const nodeListPtr& listPtr =
theTable[key];
if (listPtr)
{
for (const auto& item : *listPtr)
{
nodes.push_back(item);
}
}
perKey = key;
}
return std::move(nodes);
}
static nodeList GetNodes
(
const NodeVector<Point>& Coords
)
{
nodeList nodeList(Coords.size());
Standard_Integer K = 0;
for (auto& x : nodeList)
{
x = std::make_shared<node>();
x->Index = K + 1;
x->Coord = Coords[K];
K++;
}
return std::move(nodeList);
}
void FindMinMax
(
const std::vector<Point>& theCoord
)
{
Params::Pmin() = Params::Pmax() = *theCoord.begin();
auto& pMin = Params::Pmin();
auto& pMax = Params::Pmax();
for (const auto& x : theCoord)
{
for (int i = 1; i <= Point::nbCmpts; i++)
{
if (x.Coord(i) < pMin.Coord(i))
pMin.SetCoord(i, x.Coord(i));
if (x.Coord(i) > pMax.Coord(i))
pMax.SetCoord(i, x.Coord(i));
}
}
}
void CalcResolution()
{
FindMinMax(*theCoords_);
Standard_Real D = (Standard_Real)0.;
for (Standard_Integer coord = 1; coord <= Point::nbCmpts; coord++)
{
Standard_Real d =
Params::Pmax().Coord(coord) - Params::Pmin().Coord(coord);
if (d > D) D = d;
}
if (D <= (Standard_Real)0.)
{
FatalErrorIn(FunctionSIG)
<< "Singularity domain size"
<< abort(FatalError);
}
Params::SetDelta(2.0*Resolution()*D);
if (Params::Delta() < Radius()) Params::SetDelta(Radius() + EPS6 * D);
Params::SetPmin(Params::Pmin() - 2.0*Params::Delta());
Params::SetMaxIndex(Key(Params::Pmax() + 2.0*Params::Delta()));
if (Params::MaxIndex() <= 0)
{
FatalErrorIn(FunctionSIG)
<< "Singularity domain size"
<< abort(FatalError);
}
}
template<int Alg> void UpdateNode(node& inode, node& item) const;
template<>
void UpdateNode<Merge_PntAlg_Mean>
(
node& inode,
node& item
) const
{
inode.Index = item.Index;
inode.Coord = item.Coord = MEAN(inode.Coord, item.Coord);
}
template<>
void UpdateNode<Merge_PntAlg_Substitude>
(
node& inode,
node& item
) const
{
inode.Index = item.Index;
}
void Merge()
{
nodeTable table(Params::MaxIndex() + 1);
Standard_Integer
key,
Flag;
for (const auto& inode : theNodes_)
{
const auto& Pt = inode->Coord;
nodeList Found = Search(Pt, table);
Flag = 0;
for (const auto& item : Found)
{
if (Pt.Distance(item->Coord) <= Base::Radius())
{
Flag = 1;
UpdateNode<Alg>(*inode, *item);
break;
}
}
if (!Flag)
{
key = Key(Pt);
if (!table[key])
{
table[key] = std::make_shared<nodeList>();
}
table[key]->push_back(inode);
}
}
}
Standard_Boolean& IsDone()
{
return IsDone_;
}
public:
Merge_Pnt()
: theCoords_(nullptr)
, IsDone_(Standard_False)
{}
Merge_Pnt
(
const Standard_Real theRes,
const Standard_Real theRadius
)
: Merge_Info(theRes, theRadius)
, theCoords_(nullptr)
, IsDone_(Standard_False)
{}
Merge_Pnt
(
const NodeVector<Point>& theCoords
)
: theCoords_(&theCoords)
, IsDone_(Standard_False)
{}
Merge_Pnt
(
const NodeVector<Point>& theCoords,
const Standard_Real theRes,
const Standard_Real theRadius
)
: Merge_Info(theRes, theRadius)
, theCoords_(&theCoords)
, IsDone_(Standard_False)
{}
Standard_Boolean IsDone() const
{
return IsDone_;
}
void SetCoords
(
const NodeVector<Point>& theCoords
)
{
theCoords_ = &theCoords;
}
std::vector<Point> CompactPoints() const
{
if (NOT IsDone())
{
FatalErrorIn(FunctionSIG)
<< "Merging Points is not performed!"
<< abort(FatalError);
}
if (IsNULL(theCoords_))
{
FatalErrorIn(FunctionSIG)
<< "no points have been imported"
<< abort(FatalError);
}
std::vector<Point> mergedList;
int K = 0;
for (const auto& pt : theNodes_)
{
if (pt->Index IS_EQUAL K + 1)
mergedList.push_back(pt->Coord);
K++;
}
return std::move(mergedList);
}
indexList CompactIndices() const
{
if (NOT IsDone())
{
FatalErrorIn(FunctionSIG)
<< "Merging Points is not performed!"
<< abort(FatalError);
}
if (IsNULL(theCoords_))
{
FatalErrorIn(FunctionSIG)
<< "no points have been imported"
<< abort(FatalError);
}
indexList compactVector(theNodes_.size());
Standard_Integer K = 0;
for (const auto& x : theNodes_)
{
if (x->Index IS_EQUAL K + 1) compactVector[K] = -1;
else compactVector[K] = x->Index;
K++;
}
K = 0;
for (auto& x : compactVector)
if (x < 0) x = ++K;
forThose(Index, 0, compactVector.size() - 1)
{
if (theNodes_[Index]->Index NOT_EQUAL Index + 1)
{
compactVector[Index] = compactVector[compactVector[Index] - 1];
}
}
return std::move(compactVector);
}
const nodeList& Nodes() const
{
return theNodes_;
}
void Perform()
{
if (IsNULL(theCoords_))
{
FatalErrorIn(FunctionSIG)
<< " No Point Lists detected"
<< abort(FatalError);
}
if (NOT theCoords_->size())
{
FatalErrorIn(FunctionSIG)
<< " Point Lists is empty"
<< abort(FatalError);
}
theNodes_.resize(theCoords_->size());
if (theCoords_->size() IS_EQUAL 1)
{
theNodes_[0] = std::make_shared<node>();
theNodes_[0]->Index = 1;
theNodes_[0]->Coord = (*theCoords_)[0];
return;
}
CalcResolution();
theNodes_ = GetNodes(*theCoords_);
Merge();
IsDone() = Standard_True;
}
};
}
#endif // !_Merge_Pnt_Header
| [
"ma.yaaghoubi@gmail.com"
] | ma.yaaghoubi@gmail.com |
30ff9d2e8c861f92b5780ca785a8d767c9628ced | fa345d30d723c9cbdb750235c832bb3af635d77f | /CountAndSay.cpp | 1d4cd3aa2b150637dc495a9b257e1d51e278b531 | [] | no_license | AparnaChinya/100DaysOfCode | 03c50ff1dc7e003f7c3510ee1c40f2c0588021ec | 436ff8302eaeea705d92de4dc8c5a763b84b3348 | refs/heads/master | 2021-07-18T13:24:06.102900 | 2018-12-07T06:04:29 | 2018-12-07T06:04:29 | 72,006,131 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,083 | cpp | /*
38. Count and Say
The count-and-say sequence is the sequence of integers with the first five terms as following:
1. 1
2. 11
3. 21
4. 1211
5. 111221
1 is read off as "one 1" or 11.
11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.
Given an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say sequence.
Note: Each term of the sequence of integers will be represented as a string.
From <https://leetcode.com/problems/count-and-say/description/>
*/
class Solution {
public:
string countAndSay(int n) {
if(n == 0) {
return "";
}
string res = "1";
while(--n) {
string curr = "";
for(int i = 0; i < res.size();i++) {
int count = 1;
while((i+1) < res.size() && (res[i] == res[i+1])) {
count++;
i++;
}
curr += to_string(count) + res[i];
}
res = curr;
}
return res;
}
};
| [
"apchin@outlook.com"
] | apchin@outlook.com |
74a2c4390d2b02125824bee6e6f6cc7e20efa756 | 6c60fa044d44773c6a40485a3d8209614d2adf5e | /uVision/uVision/GeneratedFiles/ui_imagestitching.h | 8d3b095e9c4f17e0d182e5d308c71325e2f50411 | [] | no_license | githubcjl/uVision_cjl | d36e36f9f022bbfb7b1131fd76bb375f3a6e411b | a1902dd3f308d3524f92bb3552bf3b4096644730 | refs/heads/master | 2021-01-10T10:46:35.820743 | 2015-12-04T13:29:36 | 2015-12-04T13:29:36 | 45,160,854 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,334 | h | /********************************************************************************
** Form generated from reading UI file 'imagestitching.ui'
**
** Created by: Qt User Interface Compiler version 4.8.6
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_IMAGESTITCHING_H
#define UI_IMAGESTITCHING_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_imagestitching
{
public:
void setupUi(QWidget *imagestitching)
{
if (imagestitching->objectName().isEmpty())
imagestitching->setObjectName(QString::fromUtf8("imagestitching"));
imagestitching->resize(638, 481);
retranslateUi(imagestitching);
QMetaObject::connectSlotsByName(imagestitching);
} // setupUi
void retranslateUi(QWidget *imagestitching)
{
imagestitching->setWindowTitle(QApplication::translate("imagestitching", "imagestitching", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class imagestitching: public Ui_imagestitching {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_IMAGESTITCHING_H
| [
"1290478835@qq.com"
] | 1290478835@qq.com |
c305e963e9580d32b45ec2862f7043010e500aa5 | 406ce23771eda2a64efcf41cce28a31e6c7ecd87 | /BOJ/1012.cpp | fd86a4dffedbddf8cfe02cc6dc0719bcc1c6bb47 | [] | no_license | ypd01018/Algorithm | 53d22c9f30e9025af25401718066c73200a6bcb2 | 8382f3adb6f84620d929fcac128cc49fba2f7b6e | refs/heads/master | 2023-06-08T14:25:19.104589 | 2021-06-30T23:19:58 | 2021-06-30T23:19:58 | 324,764,846 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,562 | cpp | #include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
int T,M,N,K,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1},n;
stack<pair<int,int>> stk;
queue<pair<int,int>> q;
pair<bool,bool> mat[60][60];
void input()
{
int x,y;
cin >> M >> N >> K;
for(int i = 0 ; i < N ;i++)
{
for(int j = 0 ; j < M ;j++)
{
mat[i][j].first=0;
mat[i][j].second=0;
}
}
for(int i = 0 ; i <K; i++)
{
cin >> x >> y;
mat[y][x].first=1;
}
}
void sol()
{
for(int i = 0 ; i < N ;i++)
{
for(int j=0 ; j<M ;j++)
{
if(mat[i][j].f == 0 || mat[i][j].s == 1) continue; //배추지역이 아니거나(0) 이미 간곳이면(1) continue
n++;
q.push(make_pair(i,j));
mat[i][j].s=1;
while(!q.empty())
{
auto cur = q.front();
q.pop();
for(int dir=0 ; dir<4;dir++)
{
int nx = cur.s + dx[dir], ny = cur.f + dy[dir];
if(nx < 0 || nx >= M || ny < 0 || ny >=N ) continue;
if(mat[ny][nx].f == 0 || mat[ny][nx].s == 1) continue;
mat[ny][nx].s = 1;
q.push(make_pair(ny,nx));
//cout << "important:" << q.size() << endl;
}
}
}
}
}
int main()
{
cin >> T;
for(int i = 0 ; i < T;i++)
{
n=0;
input();
sol();
cout << n << endl;
}
}
| [
"ypd01018@naver.com"
] | ypd01018@naver.com |
a37761e5b4cbaa9e20c16ec0d45fd33c514806cf | 99b53c56031760912f7dc1d8438252101963c8ec | /radial_clock/radial_clock.h | 6406ff2a41dc0d8cc427e799326ee3b54cdd2285 | [] | no_license | bhill74/QtWidgets | f65ca38b1f692e74a1e806b63c36d289c6ab5613 | d044400cb3cbcb077702aa8d07028f72810f05fd | refs/heads/master | 2020-03-17T07:07:54.420298 | 2018-05-25T14:41:44 | 2018-05-25T14:41:44 | 133,384,953 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 6,711 | h | /****************************************************************************
**
** Copyright (C) 2018 Brian Hill
** All rights reserved.
**
** License Agreement
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** Software Author: Brian Hill <brian.hill@glowfish.ca>
**
** Summary: Header for the radial clock widget
**
****************************************************************************/
#ifndef RADIAL_CLOCK_H
#define RADIAL_CLOCK_H
#include <QWidget>
#include <QToolTip>
#include <map>
#include <QtDesigner/QDesignerExportWidget>
class QDESIGNER_WIDGET_EXPORT RadialClock : public QWidget
{
Q_OBJECT
Q_PROPERTY(bool blip READ blip WRITE setBlip);
Q_PROPERTY(bool seconds READ seconds WRITE setSeconds);
Q_PROPERTY(bool minutes READ minutes WRITE setMinutes);
Q_PROPERTY(bool hours READ hours WRITE setHours);
Q_PROPERTY(bool weekDays READ weekDays WRITE setWeekDays);
Q_PROPERTY(bool monthDays READ monthDays WRITE setMonthDays);
Q_PROPERTY(bool yearDays READ yearDays WRITE setYearDays);
Q_PROPERTY(bool months READ months WRITE setMonths);
Q_PROPERTY(QColor outerColor READ outerColor WRITE setOuterColor);
Q_PROPERTY(QColor innerColor READ innerColor WRITE setInnerColor);
Q_PROPERTY(bool rainbow READ rainbow WRITE setRainbow);
public:
explicit RadialClock(QWidget *parent = 0);
~RadialClock();
/************************************************************************
** Encapsulated Properties
** - blip -- Whether to precursor a tick of the clock with a slight back-tick.
** - seconds -- Whether to show the seconds counting down
** - minutes -- Whether to show the minutes counting down
** - hours -- Whether to show the hours counting down
** - weekDays -- Whether to show the days of the week counting down
** - monthDays -- Whether to show the days of the month counting down
** - yearDays -- Whether to show the days of the year counting down
** - months -- Whether to show the months of the year counting down
** - innerColor -- The color of the inner ring
** - outerColor -- The color of the outer ring
** Note: all in-between rings will be colored on a gradient between INNER and OUTER
** - rainbow -- An override to color the rings based on the colors of the rainbow
************************************************************************/
bool blip() const { return m_blip; }
void setBlip(bool b) { m_blip = b; }
bool seconds() const { return m_seconds; }
void setSeconds(bool s) { m_seconds = s; }
bool minutes() const { return m_minutes; }
void setMinutes(bool m) { m_minutes = m; }
bool hours() const { return m_hours; }
void setHours(bool h) { m_hours = h; }
bool weekDays() const { return m_weekDays; }
void setWeekDays(bool d) { m_weekDays = d; }
bool monthDays() const { return m_monthDays; }
void setMonthDays(bool d) { m_monthDays = d; }
bool yearDays() const { return m_yearDays; }
void setYearDays(bool d) { m_yearDays = d; }
bool months() const { return m_months; }
void setMonths(bool m) { m_months = m; }
QColor outerColor() const { return m_outer_color; }
void setOuterColor(const QColor &c) { m_outer_color = c;
m_colors.clear(); }
QColor innerColor() const { return m_inner_color; }
void setInnerColor(const QColor &c) { m_inner_color = c;
m_colors.clear(); }
bool rainbow() const { return m_rainbow; }
void setRainbow(bool r) { m_rainbow = r; }
QString describe() const;
/************************************************************************
** TimeCode - An enumerated type to differentiate the different rings
** of the clock face.
************************************************************************/
enum TimeCode {
SecondOfMinute = 0,
MinuteOfHour = 1,
HourOfDay = 2,
DayOfWeek = 3,
DayOfMonth = 4,
DayOfYear = 5,
MonthOfYear = 6,
InvalidTimeCode = 7
};
static const QString cTimeCodes[InvalidTimeCode];
static bool isDay(const TimeCode &tc);
static void related(const TimeCode &tc, std::vector<TimeCode> &family);
static TimeCode relatedTo(const TimeCode &tc);
int stages() const;
bool display(const TimeCode &tc) const;
static int value(const QDateTime &dtime, const TimeCode &tc);
static int limit(const QDateTime &dtime, const TimeCode &tc);
static int blipLimit(const QDateTime &dtime, const TimeCode &tc);
void blips(const QDateTime &dtime, std::map<TimeCode, bool> &blips) const;
/************************************************************************
** Color Processing.
************************************************************************/
static const QColor cBlack;
void processColors();
const QColor &getColor(TimeCode tc) const;
void getColors(const std::vector<QColor> &reference, int s, std::vector<QColor> &colors);
protected:
/************************************************************************
** Widget Callbacks
************************************************************************/
void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *);
private:
typedef std::vector<std::pair<TimeCode, int> > angleVector;
/************************************************************************
** Internal Variables.
************************************************************************/
QTimer *m_timer;
bool m_blip;
bool m_seconds;
bool m_minutes;
bool m_hours;
bool m_weekDays;
bool m_monthDays;
bool m_yearDays;
bool m_months;
QColor m_outer_color;
QColor m_inner_color;
bool m_rainbow;
std::map<TimeCode, QColor> m_colors;
std::map<int, TimeCode> m_regions;
void addAngle(angleVector &angles, TimeCode tc, int value, int ref, bool blip = false);
void paintRing(QPainter &painter, const QColor &clr, int x, int y, int r, int t, int a);
void paintRings(QPainter &painter, int x, int y, int t, int s, int b, const angleVector &angles);
signals:
public slots:
};
#endif // RADIAL_CLOCK_H
| [
"pi@chickaletta.pawpatrol.home"
] | pi@chickaletta.pawpatrol.home |
e0268d7a324d85eade450757b3c123d55918fa1d | 001bff3a9254779345f2fc22a02786decafe4678 | /11/debian-10/postgresql-repmgr-11.11.0-15-linux-amd64-debian-10/files/postgresql/include/geos/operation/buffer/OffsetSegmentGenerator.h | 6f461dd7418f629b623ef9fa9764c28e1817a4db | [
"GPL-2.0-only",
"MIT",
"Zlib",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | radondb-pg/radondb-postgresql-kubernetes | 33fe153b2b2148486e9ae3020c6b9664bc603e39 | e7a308cb4fd4c31e76b80d4aaabc9463a912c8fd | refs/heads/main | 2023-07-11T16:10:30.562439 | 2021-08-19T11:42:11 | 2021-08-19T11:42:11 | 370,936,467 | 0 | 0 | Apache-2.0 | 2021-05-26T06:56:52 | 2021-05-26T06:56:51 | null | UTF-8 | C++ | false | false | 11,294 | h | /**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: operation/buffer/OffsetSegmentGenerator.java r378 (JTS-1.12)
*
**********************************************************************/
#ifndef GEOS_OP_BUFFER_OFFSETSEGMENTGENERATOR_H
#define GEOS_OP_BUFFER_OFFSETSEGMENTGENERATOR_H
#include <geos/export.h>
#include <vector>
#include <geos/algorithm/LineIntersector.h> // for composition
#include <geos/geom/Coordinate.h> // for composition
#include <geos/geom/LineSegment.h> // for composition
#include <geos/operation/buffer/BufferParameters.h> // for composition
#include <geos/operation/buffer/OffsetSegmentString.h> // for composition
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class CoordinateSequence;
class PrecisionModel;
}
}
namespace geos {
namespace operation { // geos.operation
namespace buffer { // geos.operation.buffer
/**
* Generates segments which form an offset curve.
* Supports all end cap and join options
* provided for buffering.
* Implements various heuristics to
* produce smoother, simpler curves which are
* still within a reasonable tolerance of the
* true curve.
*
* @author Martin Davis
*
*/
class GEOS_DLL OffsetSegmentGenerator {
public:
/*
* @param nBufParams buffer parameters, this object will
* keep a reference to the passed parameters
* so caller must make sure the object is
* kept alive for the whole lifetime of
* the buffer builder.
*/
OffsetSegmentGenerator(const geom::PrecisionModel* newPrecisionModel,
const BufferParameters& bufParams, double distance);
/**
* Tests whether the input has a narrow concave angle
* (relative to the offset distance).
* In this case the generated offset curve will contain self-intersections
* and heuristic closing segments.
* This is expected behaviour in the case of buffer curves.
* For pure offset curves,
* the output needs to be further treated
* before it can be used.
*
* @return true if the input has a narrow concave angle
*/
bool
hasNarrowConcaveAngle() const
{
return _hasNarrowConcaveAngle;
}
void initSideSegments(const geom::Coordinate& nS1,
const geom::Coordinate& nS2, int nSide);
/// Get coordinates by taking ownership of them
//
/// After this call, the coordinates reference in
/// this object are dropped. Calling twice will
/// segfault...
///
/// FIXME: refactor memory management of this
///
void
getCoordinates(std::vector<geom::CoordinateSequence*>& to)
{
to.push_back(segList.getCoordinates());
}
void
closeRing()
{
segList.closeRing();
}
/// Adds a CW circle around a point
void createCircle(const geom::Coordinate& p, double distance);
/// Adds a CW square around a point
void createSquare(const geom::Coordinate& p, double distance);
/// Add first offset point
void
addFirstSegment()
{
segList.addPt(offset1.p0);
}
/// Add last offset point
void
addLastSegment()
{
segList.addPt(offset1.p1);
}
void addNextSegment(const geom::Coordinate& p, bool addStartPoint);
/// \brief
/// Add an end cap around point p1, terminating a line segment
/// coming from p0
void addLineEndCap(const geom::Coordinate& p0,
const geom::Coordinate& p1);
void
addSegments(const geom::CoordinateSequence& pts, bool isForward)
{
segList.addPts(pts, isForward);
}
private:
/**
* Factor which controls how close offset segments can be to
* skip adding a filler or mitre.
*/
static const double OFFSET_SEGMENT_SEPARATION_FACTOR; // 1.0E-3;
/**
* Factor which controls how close curve vertices on inside turns
* can be to be snapped
*/
static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-3;
/**
* Factor which controls how close curve vertices can be to be snapped
*/
static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-6;
/**
* Factor which determines how short closing segs can be for round buffers
*/
static const int MAX_CLOSING_SEG_LEN_FACTOR = 80;
/** \brief
* the max error of approximation (distance) between a quad segment and
* the true fillet curve
*/
double maxCurveSegmentError; // 0.0
/** \brief
* The angle quantum with which to approximate a fillet curve
* (based on the input # of quadrant segments)
*/
double filletAngleQuantum;
/// The Closing Segment Factor controls how long "closing
/// segments" are. Closing segments are added at the middle of
/// inside corners to ensure a smoother boundary for the buffer
/// offset curve. In some cases (particularly for round joins
/// with default-or-better quantization) the closing segments
/// can be made quite short. This substantially improves
/// performance (due to fewer intersections being created).
///
/// A closingSegFactor of 0 results in lines to the corner vertex.
/// A closingSegFactor of 1 results in lines halfway
/// to the corner vertex.
/// A closingSegFactor of 80 results in lines 1/81 of the way
/// to the corner vertex (this option is reasonable for the very
/// common default situation of round joins and quadrantSegs >= 8).
///
/// The default is 1.
///
int closingSegLengthFactor; // 1;
/// Owned by this object, destroyed by dtor
//
/// This actually gets created multiple times
/// and each of the old versions is pushed
/// to the ptLists std::vector to ensure all
/// created CoordinateSequences are properly
/// destroyed.
///
OffsetSegmentString segList;
double distance;
const geom::PrecisionModel* precisionModel;
const BufferParameters& bufParams;
algorithm::LineIntersector li;
geom::Coordinate s0, s1, s2;
geom::LineSegment seg0;
geom::LineSegment seg1;
geom::LineSegment offset0;
geom::LineSegment offset1;
int side;
bool _hasNarrowConcaveAngle; // =false
void addCollinear(bool addStartPoint);
/// The mitre will be beveled if it exceeds the mitre ratio limit.
//
/// @param offset0 the first offset segment
/// @param offset1 the second offset segment
/// @param distance the offset distance
///
void addMitreJoin(const geom::Coordinate& p,
const geom::LineSegment& offset0,
const geom::LineSegment& offset1,
double distance);
/// Adds a limited mitre join connecting the two reflex offset segments.
//
/// A limited mitre is a mitre which is beveled at the distance
/// determined by the mitre ratio limit.
///
/// @param offset0 the first offset segment
/// @param offset1 the second offset segment
/// @param distance the offset distance
/// @param mitreLimit the mitre limit ratio
///
void addLimitedMitreJoin(
const geom::LineSegment& offset0,
const geom::LineSegment& offset1,
double distance, double mitreLimit);
/// \brief
/// Adds a bevel join connecting the two offset segments
/// around a reflex corner.
//
/// @param offset0 the first offset segment
/// @param offset1 the second offset segment
///
void addBevelJoin(const geom::LineSegment& offset0,
const geom::LineSegment& offset1);
static const double PI; // 3.14159265358979
// Not in JTS, used for single-sided buffers
int endCapIndex;
void init(double newDistance);
/**
* Use a value which results in a potential distance error which is
* significantly less than the error due to
* the quadrant segment discretization.
* For QS = 8 a value of 100 is reasonable.
* This should produce a maximum of 1% distance error.
*/
static const double SIMPLIFY_FACTOR; // 100.0;
/// Adds the offset points for an outside (convex) turn
//
/// @param orientation
/// @param addStartPoint
///
void addOutsideTurn(int orientation, bool addStartPoint);
/// Adds the offset points for an inside (concave) turn
//
/// @param orientation
/// @param addStartPoint
///
void addInsideTurn(int orientation, bool addStartPoint);
/** \brief
* Compute an offset segment for an input segment on a given
* side and at a given distance.
*
* The offset points are computed in full double precision,
* for accuracy.
*
* @param seg the segment to offset
* @param side the side of the segment the offset lies on
* @param distance the offset distance
* @param offset the points computed for the offset segment
*/
void computeOffsetSegment(const geom::LineSegment& seg,
int side, double distance,
geom::LineSegment& offset);
/**
* Adds points for a circular fillet around a reflex corner.
*
* Adds the start and end points
*
* @param p base point of curve
* @param p0 start point of fillet curve
* @param p1 endpoint of fillet curve
* @param direction the orientation of the fillet
* @param radius the radius of the fillet
*/
void addDirectedFillet(const geom::Coordinate& p, const geom::Coordinate& p0,
const geom::Coordinate& p1,
int direction, double radius);
/**
* Adds points for a circular fillet arc between two specified angles.
*
* The start and end point for the fillet are not added -
* the caller must add them if required.
*
* @param direction is -1 for a CW angle, 1 for a CCW angle
* @param radius the radius of the fillet
*/
void addDirectedFillet(const geom::Coordinate& p, double startAngle,
double endAngle, int direction, double radius);
private:
// An OffsetSegmentGenerator cannot be copied because of member "const BufferParameters& bufParams"
// Not declaring these functions triggers MSVC warning C4512: "assignment operator could not be generated"
OffsetSegmentGenerator(const OffsetSegmentGenerator&);
void operator=(const OffsetSegmentGenerator&);
};
} // namespace geos::operation::buffer
} // namespace geos::operation
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // ndef GEOS_OP_BUFFER_OFFSETSEGMENTGENERATOR_H
| [
"hualongzhong@yunify.com"
] | hualongzhong@yunify.com |
69e788e7f83f9a4648031e7b3512d0250dd885cf | 12105636bdbaa06fe0dd4eeb93a9c3d35b28af6f | /bus_router/include/yt/util/nouse/allocator.h | d8f4a58d5b3948bd413b44b8d1b71d6c69562a48 | [] | no_license | crcanfly11/zmq-protobuf | 3f81a6699c123ace9dfd770a04ea4bbe7c32c1c5 | 1ea7039ed442cf83a4250d3af06d801cc3444284 | refs/heads/master | 2020-04-24T04:10:31.778675 | 2014-10-15T07:43:25 | 2014-10-15T07:43:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 737 | h | #pragma once
#include <sys/types.h>
#include <stdlib.h>
namespace yt
{
class Allocator
{
public:
virtual ~Allocator() {}
virtual void * Allocate(size_t iSize, size_t * pRealSize = NULL) = 0;
virtual void Deallocate(void * pData) = 0;
public:
static Allocator * Instance();
};
class MallocAllocator : public Allocator
{
public:
virtual void * Allocate(size_t iSize, size_t * pRealSize = NULL);
virtual void Deallocate(void * pData);
public:
static MallocAllocator * Instance();
};
class NewAllocator : public Allocator
{
public:
virtual void * Allocate(size_t iSize, size_t * pRealSize = NULL);
virtual void Deallocate(void * pData);
public:
static NewAllocator * Instance();
};
}
| [
"185830862@qq.com"
] | 185830862@qq.com |
49fd169d768ce1cd9faf2a9f29d45ab474ea1303 | 6a40151ff39a43f15f8bc1037f665863c7ddf7b3 | /Game/include/Entity.h | edf5c912e14d2de496aa5419a80945f62534c64c | [] | no_license | larinius/2d_RPG_demo | 978ecfec142075edc1103acebc6564e4b8715b63 | 48d18ae4188ee6b0769b5276f8b7c8fecdf53656 | refs/heads/main | 2023-07-09T00:08:21.201234 | 2021-08-21T23:23:38 | 2021-08-21T23:23:38 | 398,671,160 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,883 | h | #pragma once
#include "precompiled.h"
#include "Components/Component.h"
#include "CommandQueue.h"
#include "ActorController.h"
namespace rpg {
class Entity : public sf::Transformable, public rpg::CommandListener {
public:
explicit Entity(int id, std::string name);
Entity(const Entity &) = delete;
Entity &operator=(const Entity &) = delete;
~Entity() {onDestroy();}
// Common API
void draw(sf::RenderWindow *window);
virtual void update(sf::Time dt);
virtual void handleEvent(const sf::Event &event);
// Event API
void setActive(bool);
// API for <Component>
void addComponent(int id) { components_.push_back(id); }
void removeComponent(int id);
std::vector<int> components() { return components_; }
std::vector<int> componentsByTag(int id);
// Component& getComponent(std::string name);
// Attachments API <Entity>
void addChild(int id) { attachments_.push_back(id); }
void removeChild(int id);
std::vector<int> attachments() { return attachments_; };
std::vector<int> get_attachments_by_tag(int id);
// Getters and setters
int id() const { return id_; }
std::string name() { return name_; }
bool isActive() const { return active_; }
void setSize(int size){size_ = size;}
int getSize(){return size_;}
void setTag(int id) { tags_.push_back(id); }
void removeTag(int id);
std::vector<int> getTags();
void onCommand(Command command) override;
protected:
void onActivate();
void onDestroy();
protected:
const int id_;
int ownerId_{0};
int parentId_{0};
const std::string name_;
std::vector<int> attachments_; //ids of attached Entities
std::vector<int> components_; //ids of attached Components
std::vector<int> tags_; //ids of asigned Tags
//Init me after spawn
bool active_;
Entity *owner_{nullptr};
sf::RenderWindow *window_;
int size_{static_cast<int>(GRID)};
};
}
| [
"dmitry.grunt@protonmail.com"
] | dmitry.grunt@protonmail.com |
ec73ef2631a115c06be8b27d9501c88da6f2be30 | cc327a4880fa7e4c9f699b634e17ca5242c06bc0 | /doc/snippets/MagnumDebugTools-gl.cpp | 83d2160fe1e35a6ac78f5788ea633908187ead72 | [
"MIT"
] | permissive | xqms/magnum | 7cd3f2416dfbb6b305956173c5342bca8461a7cc | cef34e32db6f1fd6617870fd0f92492bbdafdf32 | refs/heads/master | 2021-06-19T13:19:18.729043 | 2019-02-07T08:02:51 | 2019-02-07T08:02:51 | 169,609,455 | 0 | 0 | NOASSERTION | 2019-02-07T17:09:32 | 2019-02-07T17:09:32 | null | UTF-8 | C++ | false | false | 4,667 | cpp | /*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <Corrade/TestSuite/Tester.h>
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/DebugTools/ForceRenderer.h"
#include "Magnum/DebugTools/ResourceManager.h"
#include "Magnum/DebugTools/ObjectRenderer.h"
#include "Magnum/DebugTools/TextureImage.h"
#include "Magnum/GL/CubeMapTexture.h"
#include "Magnum/GL/Texture.h"
#include "Magnum/Math/Range.h"
#include "Magnum/SceneGraph/Drawable.h"
#include "Magnum/SceneGraph/Object.h"
#include "Magnum/SceneGraph/MatrixTransformation3D.h"
#ifndef MAGNUM_TARGET_GLES2
#include "Magnum/GL/BufferImage.h"
#endif
using namespace Magnum;
using namespace Magnum::Math::Literals;
int main() {
{
SceneGraph::Object<SceneGraph::MatrixTransformation3D>* object{};
/* [debug-tools-renderers] */
// Global instance of debug resource manager, drawable group for the renderers
DebugTools::ResourceManager manager;
SceneGraph::DrawableGroup3D debugDrawables;
// Create renderer options which will be referenced later by "my" resource key
DebugTools::ResourceManager::instance().set("my",
DebugTools::ObjectRendererOptions{}.setSize(0.3f));
// Create debug renderer for given object, use "my" options for it. The
// renderer is automatically added to the object features and also to
// specified drawable group.
new DebugTools::ObjectRenderer3D{*object, "my", &debugDrawables};
/* [debug-tools-renderers] */
}
{
SceneGraph::Object<SceneGraph::MatrixTransformation3D>* object{};
SceneGraph::DrawableGroup3D debugDrawables;
/* [ForceRenderer] */
DebugTools::ResourceManager::instance().set("my",
DebugTools::ForceRendererOptions{}
.setSize(5.0f)
.setColor(Color3::fromHsv(120.0_degf, 1.0f, 0.7f)));
// Create debug renderer for given object, use "my" options for it
Vector3 force;
new DebugTools::ForceRenderer3D(*object, {0.3f, 1.5f, -0.7f}, force, "my",
&debugDrawables);
/* [ForceRenderer] */
}
{
SceneGraph::Object<SceneGraph::MatrixTransformation3D>* object{};
SceneGraph::DrawableGroup3D debugDrawables;
/* [ObjectRenderer] */
// Create some options
DebugTools::ResourceManager::instance().set("my",
DebugTools::ObjectRendererOptions{}.setSize(0.3f));
// Create debug renderer for given object, use "my" options for it
new DebugTools::ObjectRenderer3D(*object, "my", &debugDrawables);
/* [ObjectRenderer] */
}
{
GL::Texture2D texture;
Range2Di rect;
/* [textureSubImage-2D-rvalue] */
Image2D image = DebugTools::textureSubImage(texture, 0, rect,
{PixelFormat::RGBA8Unorm});
/* [textureSubImage-2D-rvalue] */
}
#ifndef MAGNUM_TARGET_GLES2
{
GL::Texture2D texture;
Range2Di rect;
/* [textureSubImage-2D-rvalue-buffer] */
GL::BufferImage2D image = DebugTools::textureSubImage(texture, 0, rect,
{PixelFormat::RGBA8Unorm}, GL::BufferUsage::StaticRead);
/* [textureSubImage-2D-rvalue-buffer] */
}
#endif
{
GL::CubeMapTexture texture;
Range2Di rect;
/* [textureSubImage-cubemap-rvalue] */
Image2D image = DebugTools::textureSubImage(texture,
GL::CubeMapCoordinate::PositiveX, 0, rect, {PixelFormat::RGBA8Unorm});
/* [textureSubImage-cubemap-rvalue] */
}
#ifndef MAGNUM_TARGET_GLES2
{
GL::CubeMapTexture texture;
Range2Di rect;
/* [textureSubImage-cubemap-rvalue-buffer] */
GL::BufferImage2D image = DebugTools::textureSubImage(texture,
GL::CubeMapCoordinate::PositiveX, 0, rect, {PixelFormat::RGBA8Unorm},
GL::BufferUsage::StaticRead);
/* [textureSubImage-cubemap-rvalue-buffer] */
}
#endif
}
| [
"mosra@centrum.cz"
] | mosra@centrum.cz |
cdf4d51e457fb56f62dd739160e521500a23d1fd | 3507431d0802a6fd7a4eb21f6a1566e9c33cd6d1 | /src/Logging/StreamLogger.h | 64e5017ba8abc2779756da19d3e406c281ae8800 | [
"MIT"
] | permissive | akaneoit/alloy | 7cf75f67226f142712ae4889522db2b52c8cc7f5 | 451d5455663a6b647631b6c87da62a2c3856f0a0 | refs/heads/master | 2021-05-13T21:59:22.454510 | 2018-01-06T01:25:14 | 2018-01-06T01:25:14 | 116,477,678 | 2 | 0 | null | 2018-01-06T11:32:03 | 2018-01-06T11:32:03 | null | UTF-8 | C++ | false | false | 622 | h | // Copyright (c) 2017-2018, The Alloy Developers.
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#include <mutex>
#include "CommonLogger.h"
namespace Logging {
class StreamLogger : public CommonLogger {
public:
StreamLogger(Level level = DEBUGGING);
StreamLogger(std::ostream& stream, Level level = DEBUGGING);
void attachToStream(std::ostream& stream);
protected:
virtual void doLogString(const std::string& message) override;
protected:
std::ostream* stream;
private:
std::mutex mutex;
};
}
| [
"alloycashproject@gmail.com"
] | alloycashproject@gmail.com |
5a16a547cf5b72c0792e58382569df701547c010 | 976a68b4b8441352b5f775a946335328db88783c | /src/parser/lexer/tokens/r_instr_tok.cpp | a021e3189a19bf8aba3b63dc3d31ed265f997605 | [
"MIT"
] | permissive | maddnias/EzMIPS | 08f4b75d0c2529e6817175c09492712f648ec52d | 01b1a96528d2293faebc363a4004f8c03cf82f42 | refs/heads/master | 2021-05-31T07:02:45.852827 | 2016-05-03T12:25:22 | 2016-05-03T12:25:22 | 57,319,750 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 250 | cpp | #include "r_instr_tok.h"
r_instr_tok::r_instr_tok(INSTRUCTION_CODE code, INSTRUCTION_TYPE type, unsigned int tok_row,
unsigned int tok_col):
instr_base_tok(code, INSTRUCTION_R, tok_row, tok_col)
{
}
r_instr_tok::~r_instr_tok(void)
{
}
| [
"imthetuffguy@gmail.com"
] | imthetuffguy@gmail.com |
5c8c69ca203e954a6f7c33672f75bcb319fb30f5 | 66165dc042ba505d7137a5baf27aac1ec5ffa033 | /dia005/lst05-04.cxx | 1a26ef5d97503ccc504af608c507590533f348b7 | [] | no_license | ricardo-rios/programacionii | 92a3e7069a71eecb4eb5601455f8f8b55f1d3dc2 | 6af5857f5fd877a8188743db6e46b81f76010948 | refs/heads/master | 2020-12-30T09:27:24.746166 | 2018-08-27T20:42:31 | 2018-08-27T20:42:31 | 100,416,756 | 0 | 0 | null | 2017-08-15T20:41:55 | 2017-08-15T20:28:31 | null | UTF-8 | C++ | false | false | 484 | cxx | #include <iostream>
using namespace std;
void myFunc();
int main()
{
int x = 5;
cout << "\nIn main x is: " << x;
myFunc();
cout << "\nBack in main, x is: " << x << endl;
return 0;
}
void myFunc()
{
int x = 8;
cout << "\nIn myFunc, local x: " << x << endl;
{
cout << "\nIn block in myFunc, x is: " << x;
int x = 9;
cout << "\nVery local x: " << x;
}
cout << "\nOut of block, in myFunc, x: " << x << endl;
}
| [
"ricardo.rios.sv@gmail.com"
] | ricardo.rios.sv@gmail.com |
3ab9de8b6aaa8ac440a4584f195ca4f5dc1db860 | dcdf0e29d02a6adafa3d2db9dc7cf443e65bf1c5 | /src/Linked_List.cpp | 126489552833baa838c382c6e82c011f782b628c | [] | no_license | hungthanh95/Linked_List_Cpp | 3bb0281ccc5eec87787bf45efc67f8a4dfce15ff | 94d397ee013a30ace3a1ceb080ed7b9374e8bf37 | refs/heads/main | 2023-02-15T09:36:47.238231 | 2021-01-09T13:54:35 | 2021-01-09T13:54:35 | 328,165,074 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,381 | cpp | /*
* Linked_List.cpp
*
* Created on: Jun 12, 2019
* Author: ThanhLH
*/
#include <iostream>
#include <fstream>
#include "Linked_List.hpp"
#include "iomanip"
using namespace std;
void Linked_List::add(Node * newNode) {
/*If head = null newNode is head */
if (head == nullptr) {
head = newNode;
return;
}
Node * temp = head;
while (temp->next != nullptr) {
temp = temp->next;
}
temp->next = newNode;
return;
}
void Linked_List::printList() {
Node * temp = head;
for(int i = 0 ; temp != nullptr; i++) {
cout<<"---------------Node "<<i<<"-----------------"<<endl;
temp->m_employee.printEmployee();
temp = temp->next;
}
}
Node *Linked_List::getTail(){
Node * temp = head;
while(temp != NULL && temp->next != NULL) {
temp = temp->next;
}
return temp;
}
void Linked_List::swap(Node * node1, Node * node2) {
Employee temp = node1->m_employee;
node1->m_employee = node2->m_employee;
node2->m_employee = temp;
}
void Linked_List::bubbleSort() {
int swapped;
Node * node1;
Node * node2 = nullptr;
/* Check for empty list */
if(head == nullptr)
return;
do
{
swapped = 0;
node1 = head;
while(node1->next != node2)
{
if(node1->m_employee.m_level > node1->next->m_employee.m_level)
{
swap(node1, node1->next);
swapped = 1;
}
node1 = node1->next;
}
node2 = node1;
} while (swapped);
}
void Linked_List::addAndSort(Node * newNode) {
add(newNode);
bubbleSort();
}
/* Given a reference (pointer to pointer) to the head of a list
and a key, deletes the first occurrence of key in linked list */
int Linked_List::deleteNode(string name)
{
// Store head node
struct Node* temp = head, *prev;
// If head node itself holds the key to be deleted
if (temp != NULL && temp->m_employee.m_name == name)
{
head = temp->next; // Changed head
free(temp); // free old head
return 1;
}
// Search for the key to be deleted, keep track of the
// previous node as we need to change 'prev->next'
while (temp != NULL && temp->m_employee.m_name != name)
{
prev = temp;
temp = temp->next;
}
// If key was not present in linked list
if (temp == NULL) return 0;
// Unlink the node from linked list
prev->next = temp->next;
free(temp); // Free memory
return 1;
}
void Linked_List::deleteNodes(string name) {
int flag =1;
while(flag) {
flag = deleteNode(name);
}
}
void Linked_List::printList(string name) {
Node * temp = head;
for(int i = 0 ; temp != nullptr; i++) {
if (temp->m_employee.m_name == name)
{
cout<<"---------------Node "<<i<<"-----------------"<<endl;
temp->m_employee.printEmployee();
}
temp = temp->next;
}
}
int Linked_List::countNode(void) {
Node * temp = head;
int count = 0;
while(temp != nullptr) {
count++;
temp = temp->next;
}
return count;
}
void Linked_List::import_Linked_List(string path)
{
// Open file
// ifstream ip("C:\\Users\\ThanhLH\\Desktop\\employees.csv");
ifstream ip(path);
if(!ip.is_open()) cout <<"ERROR: File open"<<'\n';
int idx = 0;
string level_str;
while(ip.good()) {
Node *newNode = new Node();
// Read the Data from the file
getline(ip, newNode->m_employee.m_name, ',');
getline(ip, newNode->m_employee.m_position, ',');
getline(ip, newNode->m_employee.m_dateOfBirth, ',');
getline(ip, level_str, '\n');
/* convert value from string to float */
newNode->m_employee.m_level = std::stof(level_str.c_str());
/* assign Node to Linked List*/
add(newNode);
idx++;
}
numOfNodes = idx;
}
void Linked_List::export_Linked_List(string path) {
//file pointer
fstream fs;
//open file
//fs.open("C:\\Users\\ThanhLH\\Desktop\\employees_export.csv",ios::out);
fs.open(path,ios::out);
cout << "Export data to file csv....." << endl;
// Write the data
Node * temp = head;
fs <<left<<setw(25)<<"Ten"<<setw(25)<<"Chuc vu"<<setw(25)<<"Ngay thang nam sinh"<<setw(25)<<"He so luong"<<endl;
for(int i = 0 ; temp != nullptr; i++) {
// Insert the data to file
fs <<left<<setw(25)<< temp->m_employee.m_name
<<setw(25)<< temp->m_employee.m_position
<<setw(25)<< temp->m_employee.m_dateOfBirth
<<setw(25)<< temp->m_employee.m_level << "\n";
temp = temp->next;
}
fs.close();
}
| [
"hungthanh95@gmail.com"
] | hungthanh95@gmail.com |
b20e00dcda3431c1f64d2346ab532131e4a6716a | c700154ce860a5d4981ea00890eae706047008ba | /codepatch/autopatch.h | ff3c615ab9131aa294cf02dc6aa3a7894d37353c | [] | no_license | KyleSanderson/left4downtown2 | 392529c8c843fa15a42117159a2e9cc84eac0c26 | 920592613c68c9b9fc4ed6313c2d9b7de2bd4121 | refs/heads/master | 2021-01-01T10:36:02.848425 | 2014-03-02T18:39:11 | 2014-03-02T18:39:11 | 33,843,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,438 | h | /**
* vim: set ts=4 :
* =============================================================================
* Left 4 Downtown SourceMod Extension
* Copyright (C) 2009 Igor "Downtown1" Smirnov.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_SOURCEMOD_AUTOPATCH_H_
#define _INCLUDE_SOURCEMOD_AUTOPATCH_H_
/*
use this class to automatically construct a codepatch and then have it call patch
*/
template <typename TPatchable>
class AutoPatch : public ICodePatch
{
public:
AutoPatch() : codePatch()
{
//L4D_DEBUG_LOG("AutoPatch constructor");
Patch(); //note: codePatch.Unpatch() is called automatically by its own destructor.. if it wants to
}
~AutoPatch()
{
L4D_DEBUG_LOG("AutoPatch destructor");
}
/*
patch the code memory
*/
void Patch()
{
codePatch.Patch();
}
/*
unpatch the code memory, restoring it to its original state
*/
void Unpatch()
{
codePatch.Unpatch();
}
/*
get the underlying ICodePatch if we need to access it directly for some reason
*/
TPatchable &GetCodePatch()
{
return codePatch;
}
private:
TPatchable codePatch;
};
#endif
| [
"dcx2gecko@gmail.com"
] | dcx2gecko@gmail.com |
22277d5fa3e2cb2d2b38d11aa72261441e4bd3bc | a9faa8b67818ec8dbb2a38b5041f4bc9ddaba430 | /ExRoadDesigner/Histogram.h | f8b3cb055c51bc1862ec2310d5b72009e09dbd88 | [] | no_license | QLwin/ExRoadDesigner | a219b33ff2da9dae13e739f99b758fb4e2445ad8 | cfabb8f3175babb1006f4ac9a5f26e96dac930aa | refs/heads/master | 2021-12-05T10:48:18.295989 | 2015-06-12T15:17:28 | 2015-06-12T15:17:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 255 | h | #pragma once
#include <QMap>
#include <vector>
class Histogram {
public:
int start;
int end;
int step;
std::vector<int> bins;
public:
Histogram(int start, int end, int step);
~Histogram() {}
void clear();
void add(int value);
int size();
};
| [
"gnishida@purdue.edu"
] | gnishida@purdue.edu |
e3ac4c1ffc412457652351509d61952a1098271f | 65fc30f0eecea65bed6a640ade8fe751f26f9326 | /Lunaway_Code/Runaway/BoardManager.cpp | 7475cee7d38e5693f94df9d0d36475de4eaaea73 | [] | no_license | kmk013/Project_OpenGL_Lunaway | cf143e6063e0be9670c1cda4dba874ae2cb44e63 | a56189080c871d0dfbc5ddd696ccfd9c982d8d39 | refs/heads/master | 2020-04-07T13:48:24.536126 | 2018-11-20T16:50:56 | 2018-11-20T16:50:56 | 158,422,397 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,095 | cpp | #include "stdafx.h"
#include "BoardManager.h"
BoardManager::BoardManager() : phase(1)
{
currentLine = 0;
}
BoardManager::~BoardManager()
{
}
void BoardManager::Update()
{
if ((int)p->pos.z > (int)(pos.z + 16.0f)) {
pos.z += 16.0f;
for (int i = 0; i < 6; i++) {
if(!boards[i][currentLine]->useModel)
boards[i][currentLine]->useModel = true;
if (boards[i][currentLine]->isBreak)
boards[i][currentLine]->isBreak = false;
if (boards[i][currentLine]->myCol)
boards[i][currentLine]->myCol->Destroy();
boards[i][currentLine]->pos.z += 40.0f * 16.0f;
}
currentLine++;
if (currentLine >= 40)
currentLine = 0;
}
}
void BoardManager::PhaseChange(int phase)
{
if (phase == 1) {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 40; j++) {
boards[i][j]->myModel = model1;
}
}
}
if (phase == 2) {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 40; j++) {
boards[i][j]->myModel = model2;
}
}
}
if (phase == 3) {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 40; j++) {
boards[i][j]->myModel = model3;
}
}
}
}
| [
"kmk013@naver.com"
] | kmk013@naver.com |
2ad6a255d1846c8e4d839f3ab0676d69fbb189f2 | 936ff533e5a4a130f629fe596a377ab1122121f3 | /3RDPARTY/OpenTissue/OpenTissue/utility/gl/gl_draw_bone.h | 7d541b9aa1b833f94469425936a3f47bcff4d559 | [
"MIT"
] | permissive | misztal/GRIT | e9eb7671b215c3995a765581655d6a7c3096471f | 6850fec967c9de7c6c501f5067d021ef5288b88e | refs/heads/master | 2021-10-08T11:43:53.580211 | 2018-12-11T21:46:13 | 2018-12-11T21:46:13 | 105,385,278 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,682 | h | #ifndef OPENTISSUE_UTILITY_GL_GL_DRAW_BONE_H
#define OPENTISSUE_UTILITY_GL_GL_DRAW_BONE_H
//
// OpenTissue Template Library
// - A generic toolbox for physics-based modeling and simulation.
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
//
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
//
#include <OpenTissue/configuration.h>
#include <OpenTissue/utility/gl/gl_util.h>
#include <OpenTissue/core/math/math_constants.h>
#include <cassert>
namespace OpenTissue
{
namespace gl
{
/**
* Draw Bone.
* Orientations and translations are simply drawn as arrows and coordinate frames.
*
* @param bone A reference to the bone that should be drawn.
*/
template<typename bone_type>
inline void DrawBone(bone_type const & bone)
{
glPushMatrix();
if(!bone.is_root())
{
Transform(bone.parent()->absolute());
}
DrawVector(bone.relative().T());
DrawFrame(bone.relative());
glPopMatrix();
}
/**
* Draw Bone.
* Mimics Maya's bone visualization. Translations are drawn
* as pyramids and orientaions as circular arcs on a sphere.
*
* Observe that the pyramid for the root bone is not drawn. This
* may cause one to think that a bone consist of a ``sphere-pyramid''
* pairing. This is however misleadning the true pairing that match
* the underlying bone transform is ``pyramid-sphere''.
*
*
* @param bone A reference to the bone that should be drawn.
*/
template<typename bone_type>
inline void DrawFancyBone(bone_type const & bone)
{
using std::sqrt;
using std::acos;
using std::cos;
using std::sin;
typedef typename bone_type::math_types math_types;
typedef typename math_types::real_type real_type;
typedef typename math_types::vector3_type vector3_type;
typedef typename math_types::quaternion_type quaternion_type;
typedef typename math_types::value_traits value_traits;
vector3_type const & T = bone.relative().T();
quaternion_type Q;
Q = bone.relative().Q();
real_type length = sqrt( dot(T,T) );
real_type radius = 0.075 * length;
glPushMatrix();
if(!bone.is_root())
{
Transform(bone.convert(bone.parent()->absolute()));
}
{
glPushMatrix();
Transform(T,Q);
int const N = 24;
real_type delta_theta = 2*value_traits::pi()/N;
real_type theta = 0;
ColorPicker(1,0,0,1);
glBegin(GL_LINE_LOOP);
for(int i=0;i<N;++i)
{
glNormal3f(1,0,0);
glVertex3f( 0, radius*cos(theta),radius*sin(theta));
theta += delta_theta;
}
glEnd();
theta = 0;
ColorPicker(0,1,0,1);
glBegin(GL_LINE_LOOP);
for(int i=0;i<N;++i)
{
glNormal3f(0,1,0);
glVertex3f( radius*cos(theta),0,radius*sin(theta));
theta += delta_theta;
}
glEnd();
theta = 0;
ColorPicker(0,0,1,1);
glBegin(GL_LINE_LOOP);
for(int i=0;i<N;++i)
{
glNormal3f(0,1,0);
glVertex3f( radius*cos(theta), radius*sin(theta), 0);
theta += delta_theta;
}
glEnd();
glPopMatrix();
}
{
if(!bone.is_root())
{
GLfloat angle = 0;
GLfloat x = 1;
GLfloat y = 0;
GLfloat z = 0;
if ( ( T(0) == 0 ) && ( T(1) == 0 ) )
{
if ( T(2) > 0 )
{
angle = 0;
}
else
{
angle = 180;
}
}
else
{
vector3_type v_unit;
vector3_type axis;
v_unit = unit( T );
axis = unit( cross( T, vector3_type(0,0,1 ) ) );
angle = acos( dot(v_unit , vector3_type(0,0,1 ) ) );
angle = -180.0 * angle / value_traits::pi();
x = axis(0);
y = axis(1);
z = axis(2);
}
glPushMatrix();
glRotatef( angle, x, y, z );
glRotatef( 45, 0, 0, 1 );
real_type base = radius / 2.0;
ColorPicker(0,0,.5,1);
glBegin(GL_LINE_LOOP);
glNormal3f(0,0,-1);
glVertex3f( -base, -base, radius);
glNormal3f(0,0,-1);
glVertex3f( -base, base, radius);
glNormal3f(0,0,-1);
glVertex3f( base, base, radius);
glNormal3f(0,0,-1);
glVertex3f( base, -base, radius);
glEnd();
glBegin(GL_LINE_LOOP);
glNormal3f(0,-1,0);
glVertex3f( -base, -base, radius);
glNormal3f(0,-1,0);
glVertex3f( base, -base, radius);
glNormal3f(0,-1,0);
glVertex3f( 0, 0, length-radius);
glEnd();
glBegin(GL_LINE_LOOP);
glNormal3f(1,0,0);
glVertex3f( base, -base, radius);
glNormal3f(1,0,0);
glVertex3f( base, base, radius);
glNormal3f(1,0,0);
glVertex3f( 0, 0, length-radius);
glEnd();
glBegin(GL_LINE_LOOP);
glNormal3f(0,1,0);
glVertex3f( base, base, radius);
glNormal3f(0,1,0);
glVertex3f( -base, base, radius);
glNormal3f(0,1,0);
glVertex3f( 0, 0, length-radius);
glEnd();
glBegin(GL_LINE_LOOP);
glNormal3f(-1,0,0);
glVertex3f( -base, base, radius);
glNormal3f(-1,0,0);
glVertex3f( -base, -base, radius);
glNormal3f(-1,0,0);
glVertex3f( 0,0, length-radius);
glEnd();
glPopMatrix();
}
}
glPopMatrix();
}
/**
* Draw Stick Bone.
* Orientations and translations are simply drawn as arrows and coordinate frames.
*
* @param bone A reference to the bone that should be drawn.
*/
template<typename bone_type>
inline void DrawStickBone(bone_type const & bone ,float red = 0.7,float green = 0.7,float blue = 0.7)
{
ColorPicker(red,green,blue,1.0);
glPushMatrix();
if(!bone.is_root())
{
Transform(bone.parent()->absolute());
}
DrawVector(bone.relative().T());
glPopMatrix();
}
/**
* Draw Fat Bone.
* the bone is drawn as a capsule the color can be chosen or left at the default light grey.
*
* @param bone A reference to the bone that should be drawn.
*/
template<typename bone_type,typename capsule_type >
inline void DrawFatBone(bone_type const & bone ,capsule_type capsule,float red = 0.7,float green = 0.7,float blue = 0.7,float thickness = 0.2)
{
typedef typename bone_type::math_types math_types;
typedef typename math_types::vector3_type V;
typedef typename math_types::real_type T;
typedef typename math_types::value_traits value_traits;
V const zero = V(value_traits::zero(), value_traits::zero(), value_traits::zero());
glPushMatrix();
if(!bone.is_root())
{
Transform(bone.parent()->absolute());
ColorPicker(red,green,blue,1.0);
//T thickness = 0.2;
if(length(bone.relative().T()) < 0.001)
thickness = 0.3;
capsule.set(zero, bone.relative().T(), thickness);
DrawCapsule(capsule);
//DrawVector(bone.relative().T());
}
glPopMatrix();
}
} // namespace gl
} // namespace OpenTissue
//OPENTISSUE_UTILITY_GL_GL_DRAW_BONE_H
#endif
| [
"marek.misztal@gmail.com"
] | marek.misztal@gmail.com |
74487c8a95b958e87573b7ba5d97881a09d4813f | b3a693cb2c15f95133876f74a640ec585b7a0f62 | /Hackerrank/ArushiUppal.cpp | a1006146c409369a63d102195d6bd5dcf7e98b1c | [] | no_license | singhsanket143/CppCompetitiveRepository | 1a7651553ef69fa407d85d789c7c342f9a4bd8e9 | 6e69599ff57e3c9dce4c4d35e60c744f8837c516 | refs/heads/master | 2022-06-23T01:42:38.811581 | 2022-06-16T13:17:15 | 2022-06-16T13:17:15 | 138,698,312 | 349 | 148 | null | 2021-03-06T18:46:58 | 2018-06-26T07:06:16 | C++ | UTF-8 | C++ | false | false | 1,277 | cpp | #include <bits/stdc++.h>
using namespace std;
int solution(int *arr, int n) {
int result = 0;
for(int j=0;j<n;j++) {
int jump = 0;
int min[10005] = {0};
int max[10005] = {0};
for(int i=0;i<n-1;i++) {
int max_el = INT_MAX;
int max_el_idx = i;
for(int j=i+1;j<n;j++) {
if(arr[j]>arr[i] and arr[i]<INT_MAX) {
max_el = arr[j];
max_el_idx = j;
}
}
if(max_el != INT_MAX) {
max[i]=max_el_idx;
}
}
for(int i=0;i<n-1;i++) {
int min_el = INT_MIN;
int min_el_idx = i;
for(int j=i+1;j<n;j++) {
if(arr[j]<arr[i] and arr[i]>min_el) {
min_el = arr[j];
min_el_idx = j;
}
}
if(min_el != INT_MIN) {
min[i]=min_el_idx;
}
}
int traversal = 0;
for(int i=0;i<n;i++){
traversal = i;
int jump=1;
while(traversal < n) {
if(jump%2==0) { // odd jump
int temp = traversal;
traversal = max[traversal];
if(traversal==temp) {
break;
}
} else {
int temp = traversal;
traversal = min[traversal];
if(traversal==temp) {
break;
}
}
if(traversal == n-1) {
result++;
}
}
}
}
return result;
}
int main(int argc, char const *argv[])
{
/* code */
int sol[5] = {10,13,12,14,15};
cout<<solution(sol, 5);
return 0;
}
| [
"singhsanket143@gmail.com"
] | singhsanket143@gmail.com |
a977991d8705ceeedcb376529313734e42e9ecaa | 6aab4199ab2cab0b15d9af390a251f37802366ab | /modules/desktop_capture/mouse_cursor_monitor_win.cc | bf0d8534e31137cfc14ccab2ac28fa5eecbc4bcf | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-google-patent-license-webrtc",
"LicenseRef-scancode-google-patent-license-webm"
] | permissive | adwpc/webrtc | f288a600332e5883b2ca44492e02bea81e45b4fa | a30eb44013b8472ea6a042d7ed2909eb7346f9a8 | refs/heads/master | 2021-05-24T13:18:44.227242 | 2021-02-01T14:54:12 | 2021-02-01T14:54:12 | 174,692,051 | 0 | 0 | MIT | 2019-03-09T12:32:13 | 2019-03-09T12:32:13 | null | UTF-8 | C++ | false | false | 7,006 | cc | /*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <assert.h>
#include <string.h>
#include <memory>
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/mouse_cursor.h"
#include "modules/desktop_capture/mouse_cursor_monitor.h"
#include "modules/desktop_capture/win/cursor.h"
#include "modules/desktop_capture/win/screen_capture_utils.h"
#include "modules/desktop_capture/win/window_capture_utils.h"
#include "rtc_base/logging.h"
namespace webrtc {
namespace {
bool IsSameCursorShape(const CURSORINFO& left, const CURSORINFO& right) {
// If the cursors are not showing, we do not care the hCursor handle.
return left.flags == right.flags &&
(left.flags != CURSOR_SHOWING || left.hCursor == right.hCursor);
}
} // namespace
class MouseCursorMonitorWin : public MouseCursorMonitor {
public:
explicit MouseCursorMonitorWin(HWND window);
explicit MouseCursorMonitorWin(ScreenId screen);
~MouseCursorMonitorWin() override;
void Init(Callback* callback, Mode mode) override;
void Capture() override;
private:
// Get the rect of the currently selected screen, relative to the primary
// display's top-left. If the screen is disabled or disconnected, or any error
// happens, an empty rect is returned.
DesktopRect GetScreenRect();
HWND window_;
ScreenId screen_;
Callback* callback_;
Mode mode_;
HDC desktop_dc_;
// The last CURSORINFO (converted to MouseCursor) we have sent to the client.
CURSORINFO last_cursor_;
};
MouseCursorMonitorWin::MouseCursorMonitorWin(HWND window)
: window_(window),
screen_(kInvalidScreenId),
callback_(NULL),
mode_(SHAPE_AND_POSITION),
desktop_dc_(NULL) {
memset(&last_cursor_, 0, sizeof(CURSORINFO));
}
MouseCursorMonitorWin::MouseCursorMonitorWin(ScreenId screen)
: window_(NULL),
screen_(screen),
callback_(NULL),
mode_(SHAPE_AND_POSITION),
desktop_dc_(NULL) {
assert(screen >= kFullDesktopScreenId);
memset(&last_cursor_, 0, sizeof(CURSORINFO));
}
MouseCursorMonitorWin::~MouseCursorMonitorWin() {
if (desktop_dc_)
ReleaseDC(NULL, desktop_dc_);
}
void MouseCursorMonitorWin::Init(Callback* callback, Mode mode) {
assert(!callback_);
assert(callback);
callback_ = callback;
mode_ = mode;
desktop_dc_ = GetDC(NULL);
}
void MouseCursorMonitorWin::Capture() {
assert(callback_);
CURSORINFO cursor_info;
cursor_info.cbSize = sizeof(CURSORINFO);
if (!GetCursorInfo(&cursor_info)) {
RTC_LOG_F(LS_ERROR) << "Unable to get cursor info. Error = "
<< GetLastError();
return;
}
if (!IsSameCursorShape(cursor_info, last_cursor_)) {
if (cursor_info.flags == CURSOR_SUPPRESSED) {
// The cursor is intentionally hidden now, send an empty bitmap.
last_cursor_ = cursor_info;
callback_->OnMouseCursor(new MouseCursor(
new BasicDesktopFrame(DesktopSize()), DesktopVector()));
} else {
// According to MSDN https://goo.gl/u6gyuC, HCURSOR instances returned by
// functions other than CreateCursor do not need to be actively destroyed.
// And CloseHandle function (https://goo.gl/ja5ycW) does not close a
// cursor, so assume a HCURSOR does not need to be closed.
if (cursor_info.flags == 0) {
// Host machine does not have a hardware mouse attached, we will send a
// default one instead.
// Note, Windows automatically caches cursor resource, so we do not need
// to cache the result of LoadCursor.
cursor_info.hCursor = LoadCursor(nullptr, IDC_ARROW);
}
std::unique_ptr<MouseCursor> cursor(
CreateMouseCursorFromHCursor(desktop_dc_, cursor_info.hCursor));
if (cursor) {
last_cursor_ = cursor_info;
callback_->OnMouseCursor(cursor.release());
}
}
}
if (mode_ != SHAPE_AND_POSITION)
return;
// CURSORINFO::ptScreenPos is in full desktop coordinate.
DesktopVector position(cursor_info.ptScreenPos.x, cursor_info.ptScreenPos.y);
bool inside = cursor_info.flags == CURSOR_SHOWING;
if (window_) {
DesktopRect original_rect;
DesktopRect cropped_rect;
if (!GetCroppedWindowRect(window_, /*avoid_cropping_border*/ false,
&cropped_rect, &original_rect)) {
position.set(0, 0);
inside = false;
} else {
if (inside) {
HWND windowUnderCursor = WindowFromPoint(cursor_info.ptScreenPos);
inside = windowUnderCursor
? (window_ == GetAncestor(windowUnderCursor, GA_ROOT))
: false;
}
position = position.subtract(cropped_rect.top_left());
}
} else {
assert(screen_ != kInvalidScreenId);
DesktopRect rect = GetScreenRect();
if (inside)
inside = rect.Contains(position);
position = position.subtract(rect.top_left());
}
callback_->OnMouseCursorPosition(position);
}
DesktopRect MouseCursorMonitorWin::GetScreenRect() {
assert(screen_ != kInvalidScreenId);
if (screen_ == kFullDesktopScreenId) {
return DesktopRect::MakeXYWH(GetSystemMetrics(SM_XVIRTUALSCREEN),
GetSystemMetrics(SM_YVIRTUALSCREEN),
GetSystemMetrics(SM_CXVIRTUALSCREEN),
GetSystemMetrics(SM_CYVIRTUALSCREEN));
}
DISPLAY_DEVICE device;
device.cb = sizeof(device);
BOOL result = EnumDisplayDevices(NULL, screen_, &device, 0);
if (!result)
return DesktopRect();
DEVMODE device_mode;
device_mode.dmSize = sizeof(device_mode);
device_mode.dmDriverExtra = 0;
result = EnumDisplaySettingsEx(device.DeviceName, ENUM_CURRENT_SETTINGS,
&device_mode, 0);
if (!result)
return DesktopRect();
return DesktopRect::MakeXYWH(
device_mode.dmPosition.x, device_mode.dmPosition.y,
device_mode.dmPelsWidth, device_mode.dmPelsHeight);
}
MouseCursorMonitor* MouseCursorMonitor::CreateForWindow(
const DesktopCaptureOptions& options,
WindowId window) {
return new MouseCursorMonitorWin(reinterpret_cast<HWND>(window));
}
MouseCursorMonitor* MouseCursorMonitor::CreateForScreen(
const DesktopCaptureOptions& options,
ScreenId screen) {
return new MouseCursorMonitorWin(screen);
}
std::unique_ptr<MouseCursorMonitor> MouseCursorMonitor::Create(
const DesktopCaptureOptions& options) {
return std::unique_ptr<MouseCursorMonitor>(
CreateForScreen(options, kFullDesktopScreenId));
}
} // namespace webrtc
| [
"adwpc@hotmail.com"
] | adwpc@hotmail.com |
2ab0a63edd4cbf682ad57e8c18ad396bb585e3c4 | 559207eb5beae4ba9fd638d19bd3009cbe3a6d11 | /src/net/instaweb/util/public/md5_hasher.h | efdb0212071e40238bd0c353c2f827293556971e | [
"Apache-2.0"
] | permissive | voku/mod-spdy | 2a8989668fe0c0f0de48c0b7ecd85b5b5b554ed1 | bcfb388cbc5415ee660c2b5dbcf61f6f43c2a5ca | refs/heads/master | 2023-04-05T09:50:46.847114 | 2015-03-19T17:58:09 | 2015-03-19T17:58:09 | 32,537,692 | 0 | 0 | NOASSERTION | 2023-04-04T01:40:41 | 2015-03-19T17:56:26 | C++ | UTF-8 | C++ | false | false | 1,451 | h | // Copyright 2010 Google 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.
//
// Authors: sligocki@google.com (Shawn Ligocki),
// lsong@google.com (Libo Song)
#ifndef NET_INSTAWEB_UTIL_PUBLIC_MD5_HASHER_H_
#define NET_INSTAWEB_UTIL_PUBLIC_MD5_HASHER_H_
#include "net/instaweb/util/public/basictypes.h"
#include "net/instaweb/util/public/hasher.h"
#include "net/instaweb/util/public/string.h"
#include "net/instaweb/util/public/string_util.h"
namespace net_instaweb {
class MD5Hasher : public Hasher {
public:
static const int kDefaultHashSize = 10;
MD5Hasher() : Hasher(kDefaultHashSize) {}
explicit MD5Hasher(int hash_size) : Hasher(hash_size) { }
virtual ~MD5Hasher();
virtual GoogleString RawHash(const StringPiece& content) const;
virtual int RawHashSizeInBytes() const;
private:
DISALLOW_COPY_AND_ASSIGN(MD5Hasher);
};
} // namespace net_instaweb
#endif // NET_INSTAWEB_UTIL_PUBLIC_MD5_HASHER_H_
| [
"ptrck@blck.io"
] | ptrck@blck.io |
39ee0eae9935106eaad933ef607a313627378803 | 70e98218d0c491bcb4e483eaad3d2ccc98882990 | /Tyle/FieldIterator.cpp | 3c02bb6102613881ae3371ff1f362d8b7fabaefe | [] | no_license | drachluch/karcassonne-z | 3aed973ba344202f07f32b5203a6c1ac5a5eee5b | db70c1b338185c543e2d938a241c3529e9c2d7ea | refs/heads/master | 2020-03-28T07:55:05.926096 | 2019-12-11T09:09:14 | 2019-12-11T09:09:14 | 147,933,159 | 0 | 0 | null | 2018-09-08T13:28:47 | 2018-09-08T12:53:56 | C++ | UTF-8 | C++ | false | false | 26 | cpp | #include "FieldIterator.h" | [
"simon.moulard@laposte.net"
] | simon.moulard@laposte.net |
020f0dd501a89b0023ef96c05e216cdb041f9a07 | dd2ad17eacd1e72fd9a351de6b4c95391aca8044 | /deps/openvdb-6.2.0/openvdb/points/AttributeGroup.cc | 68d2858c08bc51d044304a402ba6cf2e91edb160 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MPL-1.0",
"MPL-2.0"
] | permissive | drakh/LuxCore | 88aea14db0560ba4744ee6bf6e448f6d18c7582e | 54c26383b93e18506c71fca85f08f8ee8ea11d3c | refs/heads/master | 2021-04-01T22:52:18.732333 | 2020-04-09T12:50:05 | 2020-04-09T12:50:05 | 248,220,647 | 0 | 0 | Apache-2.0 | 2020-03-18T12:05:29 | 2020-03-18T12:05:28 | null | UTF-8 | C++ | false | false | 4,698 | cc | ///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012-2017 DreamWorks Animation LLC
//
// All rights reserved. This software is distributed under the
// Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
//
// Redistributions of source code must retain the above copyright
// and license notice and the following restrictions and disclaimer.
//
// * Neither the name of DreamWorks Animation 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 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.
// IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
// LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
//
///////////////////////////////////////////////////////////////////////////
/// @file points/AttributeGroup.cc
#include "AttributeGroup.h"
namespace openvdb {
OPENVDB_USE_VERSION_NAMESPACE
namespace OPENVDB_VERSION_NAME {
namespace points {
////////////////////////////////////////
// GroupHandle implementation
GroupHandle::GroupHandle(const GroupAttributeArray& array, const GroupType& offset)
: mArray(array)
, mBitMask(static_cast<GroupType>(1 << offset))
{
assert(isGroup(mArray));
// load data if delay-loaded
mArray.loadData();
// if array is compressed and preserve compression is true, copy and decompress
// into a local copy that is destroyed with handle to maintain thread-safety
if (mArray.isCompressed()) {
const_cast<GroupAttributeArray&>(mArray).decompress();
}
}
GroupHandle::GroupHandle(const GroupAttributeArray& array, const GroupType& bitMask,
BitMask)
: mArray(array)
, mBitMask(bitMask)
{
assert(isGroup(mArray));
// load data if delay-loaded
mArray.loadData();
// if array is compressed and preserve compression is true, copy and decompress
// into a local copy that is destroyed with handle to maintain thread-safety
if (mArray.isCompressed()) {
const_cast<GroupAttributeArray&>(mArray).decompress();
}
}
bool GroupHandle::get(Index n) const
{
return (mArray.get(n) & mBitMask) == mBitMask;
}
bool GroupHandle::getUnsafe(Index n) const
{
return (mArray.getUnsafe(n) & mBitMask) == mBitMask;
}
////////////////////////////////////////
// GroupWriteHandle implementation
GroupWriteHandle::GroupWriteHandle(GroupAttributeArray& array, const GroupType& offset)
: GroupHandle(array, offset)
{
assert(isGroup(mArray));
}
void GroupWriteHandle::set(Index n, bool on)
{
const GroupType& value = mArray.get(n);
GroupAttributeArray& array(const_cast<GroupAttributeArray&>(mArray));
if (on) array.set(n, value | mBitMask);
else array.set(n, value & ~mBitMask);
}
bool GroupWriteHandle::collapse(bool on)
{
using ValueT = GroupAttributeArray::ValueType;
GroupAttributeArray& array(const_cast<GroupAttributeArray&>(mArray));
array.compact();
if (this->isUniform()) {
if (on) array.collapse(static_cast<ValueT>(array.get(0) | mBitMask));
else array.collapse(static_cast<ValueT>(array.get(0) & ~mBitMask));
return true;
}
for (Index i = 0; i < array.size(); i++) {
if (on) array.set(i, static_cast<ValueT>(array.get(i) | mBitMask));
else array.set(i, static_cast<ValueT>(array.get(i) & ~mBitMask));
}
return false;
}
bool GroupWriteHandle::compact()
{
GroupAttributeArray& array(const_cast<GroupAttributeArray&>(mArray));
return array.compact();
}
////////////////////////////////////////
} // namespace points
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
// Copyright (c) 2012-2017 DreamWorks Animation LLC
// All rights reserved. This software is distributed under the
// Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
| [
"neo2068@web.de"
] | neo2068@web.de |
cc9d363f797238aacf1ba3865e826af1b6324055 | fc30e5491e74cd090f860c0f461fb4079f6d1544 | /src/refractive_test.cpp | bbe423eaf4e36fdd64dd292e697454ec56db7a08 | [
"Unlicense"
] | permissive | PeterZhizhin/RayTracerCpp | f257adf3f3608d555accc036a59450be2be4865c | e3fcd9c19c84e51a7b16aec46406656e7c3878c7 | refs/heads/master | 2022-12-04T02:23:48.097754 | 2020-08-14T15:40:51 | 2020-08-14T15:40:51 | 274,872,550 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,955 | cpp | #define CATCH_CONFIG_MAIN // This tells the catch header to generate a main
#include <catch2/catch.hpp>
#include <cmath>
#include "hittable.h"
#include "random.h"
#include "ray.h"
#include "refractive.h"
#include "vec3.h"
using ray_tracer::geometry::Hittable;
using ray_tracer::material::RefractiveMaterial;
using ray_tracer::random::Random;
using ray_tracer::ray::Ray;
using ray_tracer::vector::Color3;
using ray_tracer::vector::Point3;
using ray_tracer::vector::Vec3;
namespace {
constexpr float deg2rad(float deg) {
return deg * static_cast<float>(M_PI / 180.0);
}
// For 45 degree angle, it reflected at least once with prob = (1 - 1e-14)
constexpr inline size_t number_of_runs = 300;
}
TEST_CASE("When material 2.0 ref index, hit at 45 degree angle, returns normalized vector", "[refractive]") {
Random rand;
RefractiveMaterial material(2.0, rand);
Ray in_ray{Point3{0.0f, 1.0f, 0.0f}, Vec3{1.0f, -1.0f, 0.0f}};
Hittable::HitRecord record{Point3{1.0f, 0.0f, 0.0f}, in_ray, 1.0f, Vec3{0.0f, 1.0f, 0.0f}};
// As it's randomly either refracts or reflects, we make
for (size_t i = 0; i != number_of_runs; ++i) {
auto scatter_info = material.scatter(in_ray, record);
REQUIRE(scatter_info.has_value());
auto scattered_ray_direction = scatter_info->ray.direction();
REQUIRE(scattered_ray_direction.length2() == Approx(1.0f));
}
}
TEST_CASE("When material 2.0 ref index, hit at 45 degree angle, refracts at asin(0.5 * sin(45deg))", "[refractive]") {
Random rand;
RefractiveMaterial material(2.0, rand);
Ray in_ray{Point3{0.0f, 1.0f, 0.0f}, Vec3{1.0f, -1.0f, 0.0f}};
Hittable::HitRecord record{Point3{1.0f, 0.0f, 0.0f}, in_ray, 1.0f, Vec3{0.0f, 1.0f, 0.0f}};
for (size_t i = 0; i != number_of_runs; ++i) {
auto scatter_info = material.scatter(in_ray, record);
REQUIRE(scatter_info.has_value());
auto scattered_ray_direction = scatter_info->ray.direction();
// Reflection will have the positive y coordinate.
if (scattered_ray_direction.y() > 0) {
// Discard reflection.
continue;
}
// To get sin, we should get the x coordinate of scattered_ray_direction
auto expected_sin_angle = 0.5f * std::sin(deg2rad(45.0f));
REQUIRE(scattered_ray_direction.x() == expected_sin_angle);
break;
// Test refracted ray only once.
}
}
TEST_CASE("When material 0.5 ref index, hit at 45 degree angle, it reflects", "[refractive]") {
Random rand;
RefractiveMaterial material(0.5, rand);
Ray in_ray{Point3{0.0f, 1.0f, 0.0f}, Vec3{1.0f, -1.0f, 0.0f}};
Hittable::HitRecord record{Point3{1.0f, 0.0f, 0.0f}, in_ray, 1.0f, Vec3{0.0f, 1.0f, 0.0f}};
for (size_t i = 0; i != number_of_runs; ++i) {
auto scatter_info = material.scatter(in_ray, record);
REQUIRE(scatter_info.has_value());
auto scattered_ray_direction = scatter_info->ray.direction();
REQUIRE(scattered_ray_direction == Vec3{1.0f, 1.0f, 0.0f}.unit());
}
}
TEST_CASE("When material 2.0 ref index, hit almost parallel to the surface, almost always refracts", "[refractive]") {
Random rand;
RefractiveMaterial material(2.0, rand);
Ray in_ray{Point3{0.0f, 1.0f, 0.0f}, Vec3{1.0f, -1e-6f, 0.0f}};
Hittable::HitRecord record{Point3{1.0f, 0.0f, 0.0f}, in_ray, 1.0f, Vec3{0.0f, 1.0f, 0.0f}};
size_t number_of_refractions = 0;
for (size_t i = 0; i != number_of_runs; ++i) {
auto scatter_info = material.scatter(in_ray, record);
REQUIRE(scatter_info.has_value());
auto scattered_ray_direction = scatter_info->ray.direction();
if (scattered_ray_direction.y() < 0) {
// refracted here
++number_of_refractions;
continue;
}
REQUIRE(scattered_ray_direction == Vec3{1.0f, 1e-6f, 0.0f}.unit());
}
REQUIRE(number_of_refractions < 3);
}
| [
"piter.zh@gmail.com"
] | piter.zh@gmail.com |
4ba28716314541e468e9eed22cde6396dc4390ae | f5fb39010aec616f37ac24427f6af61dcdfd3756 | /Pokemon_Mystery_Dungeon/Team.h | 8d023af6487d61f4b808cc2ce313bb82e31d6734 | [] | no_license | JinKyong/Pokemon_Dungeon | 08df9ce02362a239525730aaa06aaa46c4bfbc0e | c595cdcb92f822b54e99e1a366f797712ad69475 | refs/heads/main | 2023-07-31T05:01:27.372424 | 2021-10-03T13:00:52 | 2021-10-03T13:00:52 | 384,614,340 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 148 | h | #pragma once
#include "Player.h"
class Team : public Player
{
public:
virtual HRESULT init(int pokemonNum, int level);
virtual int input();
};
| [
"sjk900700@gmail.com"
] | sjk900700@gmail.com |
7f63c1db518ea138a5d4afd4bc662f60f8f28806 | b3a86f9abffb5a6d581af1b40e08695c105e0681 | /src/fslview/src/fslview/vtkpropertydialog.h | 0f5bc299fa0a5b09f4dfcc80f7f567122124781d | [] | no_license | fithisux/FSL | 60e3e0f90430db343b3170f25a6e8b77811e6bdf | 7aa2932949129f5c61af912ea677d4dbda843895 | refs/heads/fsl-5.0.9 | 2020-12-30T16:16:32.812486 | 2016-01-29T18:52:06 | 2016-01-29T18:52:06 | 90,979,243 | 9 | 1 | null | 2017-05-11T12:56:41 | 2017-05-11T12:56:41 | null | UTF-8 | C++ | false | false | 778 | h | /* FSLView - 2D/3D Interactive Image Viewer
Authors: Rama Aravind Vorray
James Saunders
David Flitney
Mark Jenkinson
Stephen Smith
FMRIB Image Analysis Group
Copyright (C) 2002-2003 University of Oxford */
/* CCOPYRIGHT */
#if !defined(VTKPROPERTYDIALOG_H)
#define VTKPROPERTYDIALOG_H
#include "vtkpropertydialogbase.h"
class VTKProperties;
class VTKPropertyDialog: public VTKPropertyDialogBase
{
public:
VTKPropertyDialog(QWidget* parent, VTKProperties& props);
VTKPropertyDialog(const VTKPropertyDialog& options);
VTKProperties& operator=(const VTKProperties& rhs);
virtual ~VTKPropertyDialog() {}
VTKProperties& getProperties();
private:
VTKProperties& m_props;
private slots:
void selectColor();
void help();
};
#endif
| [
"methodscorehelp@umich.edu"
] | methodscorehelp@umich.edu |
847cbeee04d421f289eb6fa7ac14eb3932aae25e | aa3d6a8a6e8e75d968786ed1900564baaad1bb62 | /AOJ/V1/117.cpp | b30cd6e55a64df793549a52d4af54dc5702ff6ae | [] | no_license | Halksel/Competition | 418b18981d4eb30572e6f24401f53968c5e9c354 | ce9ea74410a63ad2c4de23dee33698d23afb01b1 | refs/heads/master | 2021-01-23T21:46:52.925976 | 2019-08-25T13:07:44 | 2019-08-25T13:07:44 | 59,487,622 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,362 | cpp | #include <bits/stdc++.h>
using namespace std ;
#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};
inline bool value(int x,int y,int w,int h){
return (x >= 0 && x < w && y >= 0 && y < h);
}
template<typename T>
void Unique(vector<T> &v){
sort(all(v));
v.erase(unique(all(v)),v.end());
}
template<typename T>
T ston(string& str, T n){
istringstream sin(str) ;
T num ;
sin >> num ;
return num ;
}
void Ans(bool f){
if(f) cout << "YES"<<endl;
else cout << "NO"<<endl;
}
struct Edge{
int to;
long long cost;
};
struct NODE{
int pos;
long long cost;
};
bool operator < (const NODE &a,const NODE &b){
return a.cost > b.cost;
}
vector<Edge> g[100000],rg[100000];
int N;
const ll INF = 1e15;
vector<ll> dijkstra(vector<Edge> g[100000],int start){
priority_queue<NODE> Q;
Q.push({start,0});
vector<ll> res(N+1,INF);
while(Q.size()){
NODE q= Q.top();Q.pop();
if(res[q.pos] == INF){
res[q.pos] = q.cost;
}
else{
continue;
}
for(auto n : g[q.pos]){
Q.push({n.to,q.cost+n.cost});
}
}
return res;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int m,a,b,d,e,x,x2,y,y2;
char c;
cin >>N>>m;
rep(i,m){
cin >> a>>c>>b>>c>>d>>c>>e;
g[a].push_back(Edge{b,d});
g[b].push_back(Edge{a,e});
}
cin >> x >>c>> x2>>c >> y>>c >> y2;
auto res = dijkstra(g,x);
auto res2 = dijkstra(g,x2);
cout << y - res[x2]-res2[x] -y2 << endl;
return 0;
}
| [
"whentheycry0708@gmail.com"
] | whentheycry0708@gmail.com |
c60c86cb6833616c58c773ede89f7c325f46d330 | 450f07ade94e73cee336bc05de7b6446b95f4e1e | /hsr_grab_operation/include/hsr_grab_operation.h | 5986edaff1f4f75e3f116676082a42e767b56d8d | [] | no_license | shencanjun/hirop_pickandplace | bf0eb6e0aca3da247ccf2bf9a3513f43ecf4684f | 97741d079c8cc175e6b9e5ff41a195d456e80b3a | refs/heads/master | 2020-06-04T12:53:19.345839 | 2019-06-15T07:06:31 | 2019-06-15T07:06:31 | 183,205,951 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,720 | h | #include "igrab_operation.h"
#include <ros/ros.h>
#include <serial/serial.h>
#include "hsr_gripper_driver/serial_open_srv.h"
#include "hsr_gripper_driver/close_srv.h"
#include "hsr_gripper_driver/open_srv.h"
#include "hsr_gripper_driver/stop_srv.h"
#include "hsr_gripper_driver/open_size_srv.h"
#include "hsr_gripper_driver/read_open_size_srv.h"
#include "../3rd/include/hpluginloader.h"
using namespace hirop_pickPlace;
class hsr_grab_operation:public IGrabOperation{
public:
/**
* @brief 构造函数
*/
hsr_grab_operation();
/**
* @brief 夹爪初始化
* @return
*/
int gripper_init();
/**
* @brief 夹爪打开
* @return 0,成功 -1,失败
*/
int gripper_open();
/**
* @brief 夹爪关闭
* @return
*/
int gripper_close();
/**
* @brief 初始化
* @param n 节点句柄
*/
void grab_init(ros::NodeHandle n);
private:
/**
* @brief 串口打开
* @param serialNo
* @param baudrate
* @return
*/
int serial_open(std::string serialNo,int baudrate);
/**
* @brief 夹爪打开
* @param speed
* @return
*/
int _gripper_open(int speed);
/**
* @brief 夹爪关闭
* @param speed
* @param force
* @return
*/
int _gripper_close(int speed, int force);
private:
//节点句柄
ros::NodeHandle n_gripper;
//串口打开服务客户端
ros::ServiceClient client_serialOpen;
//夹爪打开打开服务客户端
ros::ServiceClient client_gripperOpen;
//夹爪关闭打开服务客户端
ros::ServiceClient client_gripperClose;
};
H_DECLARE_PLUGIN(hirop_pickPlace::IGrabOperation)
| [
"1252773119@qq.com"
] | 1252773119@qq.com |
870fe70cb366434e9934fd2fc7fa2bf23a980203 | d827fb10cdea587dcaf4e8d7d4034324c6aaf96e | /DiscreteRemeshing/Examples/AnisotropicRemeshingQ.cxx | b018fa3b8fc4cbe7149444e2067638b4a1f6d36a | [
"LicenseRef-scancode-cecill-b-en",
"BSD-3-Clause",
"CECILL-B"
] | permissive | kayarre/ACVD | cf94635a94538dced381f83ddd59269375bbee8f | 83f7c05a7b3ccf0445708cea918b4b11325fb229 | refs/heads/master | 2022-01-01T06:20:50.424338 | 2021-11-12T12:54:26 | 2021-11-12T12:54:26 | 144,194,466 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,877 | cxx | /*=========================================================================
Program: Aproximated Centroidal Voronoi Diagrams
Module: ACVD.cxx
Language: C++
Date: 2003/11
Auteur: Sebastien Valette,
=========================================================================*/
// .NAME AnisotropicRemeshingQ
// .SECTION Description
#include <sstream>
#include <vtkPLYWriter.h>
#include <vtkSTLWriter.h>
#include <vtkCellData.h>
#include "vtkDiscreteRemeshing.h"
#include "vtkIsotropicMetricForClustering.h"
#include "vtkQuadricAnisotropicMetricForClustering.h"
#include "vtkQEMetricForClustering.h"
#include "vtkTrianglesProcessing.h"
#include "vtkVerticesProcessing.h"
//#include "vtkSubdivisionRemeshing.h"
/////////////////////////////////////////////////////////////////////////////////////////
//
// Adaptive coarsening of triangular meshes
// This program should be run with 3 arguments:
// run: "acvd file nvertices gradation [options]"
// arg1 is the name of the mesh file to read
// arg2 is the desired number of vertices (note: if the number of input
// arg3 is the gradation parameter (0 is uniform, higher values give more and more importance
// to regions with high curvature)
//
// Additionnal options :
// -d x : sets the graphics display (0 : no display. 1: display. 2 :iterative display)
// default value : 0
//
// -s x : sets the subsampling threshold (Higher values give better results but the input
// mesh will be subdivided more times)
// default value : 10
// -np x : sets the number of wanted processes (useful only with multi-processors machines)
//
//////////////////////////////////////////////////////////////////////////////////////////
int main( int argc, char *argv[] )
{
//******************************************************************************************
// Inside input parameters:
int Display=0; // defines whether there will be a graphic
// display (0: No, 1: yes)
int NumberOfSamples=200; // the number of desired vertices
double Gradation=0; // the gamma parameter for simplification
// (if gamma=0: uniform)
// other appropriates values range between 0 and 2
int SubsamplingThreshold=10;
char* OutputDirectory=0; // the output directory
//*******************************************************************************************
char filename[500];
vtkSurface *Mesh=vtkSurface::New();
typedef vtkDiscreteRemeshing<vtkIsotropicMetricForClustering> IsotropicRemeshing;
typedef vtkDiscreteRemeshing<vtkQEMetricForClustering> QEMRemeshing;
// typedef vtkDiscreteRemeshing<vtkL21MetricForClustering> L21Remeshing;
typedef vtkDiscreteRemeshing<vtkQuadricAnisotropicMetricForClustering> QuadricAnisotropicRemeshing;
vtkVerticesProcessing<QuadricAnisotropicRemeshing> *Remesh=
vtkVerticesProcessing<QuadricAnisotropicRemeshing>::New();
if(argc>1)
{
cout <<"load : "<<argv[1]<<endl;
strcpy(filename,argv[1]);
}
else
{
cout<<"Usage : AnisotropicRemeshingQ file nvertices gradation [options]"<<endl;
cout<<"nvertices is the desired number of vertices"<<endl;
cout<<"gradation defines the influence of local curvature (0=uniform meshing)"<<endl;
cout<<endl<<"Optionnal arguments : "<<endl;
cout << "-b 0/1 : sets mesh boundary fixing off/on (default : 0)" << endl;
cout<<"-d 0/1/2 : enables display (default : 0)"<<endl;
cout << "-l ratio : split the edges longer than ( averageLength * ratio )" << endl;
cout << "-b 0/1 : sets mesh boundary fixing off/on (default : 0)" << endl;
cout << "-q 1/2/3 : qets number of eigenvalues used for quadric-based vertex relocation to 0/1/2 (default : 3)"<< endl;
return (0);
}
Mesh->CreateFromFile(filename);
Mesh->GetCellData()->Initialize();
Mesh->GetPointData()->Initialize();
Mesh->DisplayMeshProperties();
if (0)
{
vtkPLYWriter *plyWriter=vtkPLYWriter::New();
plyWriter->SetInputData(Mesh);
plyWriter->SetFileName("input.ply");
plyWriter->Write();
plyWriter->Delete();
}
// get mandatory arguments
if(argc>2)
{
NumberOfSamples=atoi(argv[2]);
}
else
{
NumberOfSamples=3000;
cout<<"Number of vertices ? ";
cin>>NumberOfSamples;
}
if(argc>3)
{
Gradation=atof(argv[3]);
}
else
{
cout<<"Gradation ? ";
cin>>Gradation;
}
// Parse optionnal arguments
int ArgumentsIndex=4;
cout<<argc<<" Arguments"<<endl;
while (ArgumentsIndex<argc)
{
if (strcmp(argv[ArgumentsIndex],"-s")==0)
{
SubsamplingThreshold=atoi(argv[ArgumentsIndex+1]);
cout<<"Subsampling Threshold="<<SubsamplingThreshold<<endl;
}
if (strcmp(argv[ArgumentsIndex],"-d")==0)
{
Display=atoi(argv[ArgumentsIndex+1]);
cout<<"Display="<<Display<<endl;
}
#ifdef DOmultithread
if (strcmp(argv[ArgumentsIndex],"-np")==0)
{
int NumberOfThreads=atoi(argv[ArgumentsIndex+1]);
cout<<"Number of threads="<<NumberOfThreads<<endl;
Remesh->SetNumberOfThreads(NumberOfThreads);
}
#endif
if (strcmp(argv[ArgumentsIndex],"-o")==0)
{
OutputDirectory=argv[ArgumentsIndex+1];
cout<<"OutputDirectory: "<<OutputDirectory<<endl;
}
if (strcmp(argv[ArgumentsIndex],"-l")==0)
{
Mesh->SplitLongEdges(atof(argv[ArgumentsIndex+1]));
cout<<"Splitting edges longer than "
<<atof(argv[ArgumentsIndex+1])<<" times the average edge length"<<endl;
}
if (strcmp(argv[ArgumentsIndex],"-q")==0)
{
cout<<"Setting number of eigenvalues for quadrics to "<<atoi(argv[ArgumentsIndex+1])<<endl;
Remesh->GetMetric()->SetQuadricsOptimizationLevel(atoi(argv[ArgumentsIndex+1]));
}
if (strcmp(argv[ArgumentsIndex], "-b") == 0) {
cout << "Setting boundary fixing to : " << argv[ArgumentsIndex+1] << endl;
Remesh->SetBoundaryFixing(atoi(argv[ArgumentsIndex+1]));
}
ArgumentsIndex+=2;
}
RenderWindow *Window;
if (Display!=0)
{
Window=RenderWindow::New();
vtkPolyData *Visu=vtkPolyData::New();
Visu->ShallowCopy(Mesh);
Window->SetInputData(Visu);
Remesh->SetAnchorRenderWindow(Window);
Window->Render();
Window->SetWindowName(filename);
Window->GetCamera()->Zoom(1.6);
Window->Interact();
}
Remesh->SetInput(Mesh);
Remesh->SetNumberOfClusters(NumberOfSamples);
Remesh->SetConsoleOutput(2);
Remesh->SetSubsamplingThreshold(SubsamplingThreshold);
Remesh->GetMetric()->SetGradation(Gradation);
// Remesh->SetInitialSamplingType(0);
// Remesh->SetDisplayCharacteristicsWindowOn();
// Remesh->SetAlgorithmType(1);
Remesh->SetDisplay(Display);
Remesh->Remesh();
// save the output mesh to .ply format
char REALFILE[500];
if (OutputDirectory)
{
strcpy (REALFILE,OutputDirectory);
strcat (REALFILE,"Remeshing.ply");
cout<<"OutputDirectory: "<<OutputDirectory<<endl;
}
else
strcpy(REALFILE,"Remeshing.ply");
vtkPLYWriter *plyWriter=vtkPLYWriter::New();
plyWriter->SetInputData(Remesh->GetOutput());
plyWriter->SetFileName(REALFILE);
plyWriter->Write();
plyWriter->Delete();
}
| [
"sebastien.valette@creatis.insa-lyon.fr"
] | sebastien.valette@creatis.insa-lyon.fr |
90ae7c7f11c921beacc57401ec204a25fd29d815 | 1c7cb3154854a0d5f628c4285aa209affd8d2fc9 | /chaos-ns-3/ns-3.27/src/wifi/model/wifi-mac-trailer.h | 2f5dd8eb4fcc95117216416963054291a1591ada | [
"GPL-2.0-only",
"LicenseRef-scancode-free-unknown",
"MIT"
] | permissive | ErikNatanael/royal-chaos | fac8e5891044490cd2e61b7367f284d99951d0d1 | a8e763d3720cc3e158e98143cabce8106d8de2aa | refs/heads/master | 2022-07-16T12:21:31.494237 | 2020-05-12T12:50:08 | 2020-05-12T12:50:08 | 263,333,134 | 0 | 0 | MIT | 2020-05-12T12:42:08 | 2020-05-12T12:42:08 | null | UTF-8 | C++ | false | false | 1,579 | h | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2006 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#ifndef WIFI_MAC_TRAILER_H
#define WIFI_MAC_TRAILER_H
#include "ns3/trailer.h"
namespace ns3 {
/**
* The length in octects of the IEEE 802.11 MAC FCS field
*/
static const uint16_t WIFI_MAC_FCS_LENGTH = 4;
/**
* \ingroup wifi
*
* Implements the IEEE 802.11 MAC trailer
*/
class WifiMacTrailer : public Trailer
{
public:
WifiMacTrailer ();
virtual ~WifiMacTrailer ();
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
TypeId GetInstanceTypeId (void) const;
void Print (std::ostream &os) const;
uint32_t GetSerializedSize (void) const;
void Serialize (Buffer::Iterator start) const;
uint32_t Deserialize (Buffer::Iterator start);
};
} //namespace ns3
#endif /* WIFI_MAC_TRAILER_H */
| [
"zhanglong3030@qq.com"
] | zhanglong3030@qq.com |
0026da428a0b4eb7d2d66f9dd100cf646a8bcc99 | c3d5d7433ab1391cac0c2e24ff55f852198eca34 | /Starter/test/LinkedList_test.h | 33ec5e975364fdbc6811a7316b46c87742f041c2 | [
"Apache-2.0"
] | permissive | masterpiece2014/Starter | 6b65125c29fc3da0a00671b40ec2dedde4799b82 | 2f2ac47636b961b797df0101e3307c95c3b1bb5e | refs/heads/master | 2021-01-14T12:31:33.533204 | 2014-04-25T16:43:40 | 2014-04-25T16:43:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,846 | h | ///////////////////////////////////////////////////////////////////////////////
//// Copyright 2012 2013 CaiBowen
//// All rights reserved.
////
//// Author: Cai Bowen
//// contact/bug report/get new version
//// at
//// feedback2bowen@outlook.com
////
////
//// 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 "CycList.h"
#include "CycList.h"
using namespace Starter;
//template<typename T>
////using = CycList<T, std::allocator<T>>;
//typedef typename template CycList<T> CycList<T>;
//
//
//typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
//
//
#include <cassert>
int test_LinkedList() {
double db[LOOP];
for (size_t i = 0; i != LOOP; i++) {
db[i] = rand();
}
CycList<double> ls;
for (size_t i = 0; i != LOOP; i++) {
ls.push_back(db[i]);
cout << db[i] << endl;
}
cout << "front and back " << ls.front() << " " << ls.back() << endl;
auto iiiter = ls.begin();
auto bter = iiiter;
--iiiter; // at end() pointless node
--iiiter; // at back() last node
cout << " begin " << *bter << " " << *iiiter << endl;
cout << " iiiter[3] " << iiiter[3] << endl;
// iter += 3;
// iter -= 3;
// while (iter != ls.end()) {
// cout << *iter << endl;
// iter++;
// }
ls.pop();
ls.pop_front();
ls.insert_at(4, 11111.1111);
ls.insert_at(5, 55555);
cout << "size " << ls.size() << endl;
for(const auto& item : ls) {
cout << item << endl;
}
return 0;
}
struct Friendy {
Friendy () : Friendy(0.0) {}
Friendy(double mkk): mk(mkk){
id = ++ ct;
// cout << id << "Morning!" << mk << " ";
}
void greet() const {
cout << id<<" " << mk << endl;
}
~Friendy() {
// cout << id<< " Dtor\n" ;
}
int fillerr[100];
double mk;
int id;
static int ct;
};
int Friendy::ct = 0;
struct FriendyAgain :public Friendy{
FriendyAgain(){
// cout << "Zhaoshanghao!" << endl;
}
FriendyAgain(double mkk) : Friendy(mkk){}
void greet() {
cout << "ChiFanMei!" << endl;
}
~FriendyAgain() {
// cout << "WanAn!" << endl;
}
int filler[100];
};
#include <limits>
int test1_LinkedList() {
CycList<Friendy> lss, laa;
// list<Friendy> lss, laa;
// vector<Friendy> lss, laa;
Friendy* ptr = (Friendy*)::operator new (LOOP * sizeof(Friendy));
for(size_t i = 0; i != LOOP; ++i) {
new((void*)(ptr + i))Friendy(rand());
lss.push_back(*(ptr + i));
}
// for (auto& i : lss) {
// i.greet();
// }
// laa.push_back(*lss.begin());
laa.push_back(*lss.begin());
laa.push_back(*lss.begin());
cout << "size and greet()" << laa.size() <<endl;
(++laa.begin())->greet();
laa = lss;
cout << "end" << endl;
::operator delete(ptr);
return 0;
}
int test2_LinkedList() {
CycList<Friendy> lss, lbb;
// list<Friendy> lss;
cout << "\n\n size" << lss.size()<< "" << "" <<endl;
lss.clear();
cout << "\n\n after cleaning size" << lss.size()<< "" << "" <<endl;
Friendy* ptr = (Friendy*)::operator new (LOOP * sizeof(Friendy));
for(size_t i = 0; i != LOOP; ++i) {
new((void*)(ptr + i))Friendy(rand());
lss.push_back(*(ptr + i));
}
lss.splice(lss.end(), {Friendy(1111111.2222222), Friendy(3333333.4444), Friendy(5555.66666)});
cout << "Greetings " << lss.size()<< endl;
for(auto& i : lss) {
i.greet();
}
// lss = lbb; // test if operator= will call corresponding Dtor
cout << lss.size() << " size ----- this is the end\n";
// cout << std::distance(lss.begin(), lss.end()) << endl;
// auto iter = lss.begin();
// auto iter6 = iter + 6;
// cout << "\nto be erased\n";
// iter->greet();
// iter6->greet();
// lss.pop();
// lss.popFront();
// lss.erase(iter,iter6);
// lss.insertAt(5, Friendy(111.333));
// lss.insert(iter6, Friendy(111.333));
// cout << "\n" << lss.size() << " done\n";
//for(auto& i : lss) {
// for(auto& i : lss) {
// i.greet();
// }
// auto xx = lss.begin();
// ++xx;
// ++xx;
// cout << "\n iters\n";
// xx->greet();
// lss.reverse();
// cout << "\n" << lss.size() << " reversing done\n\n";
// for(auto& i : lss) {
// i.greet();
// }
// cout << "\n iters \n";
// // while(xx != lss.end()) {
// xx->greet();
// ++xx;
// xx->greet();
// // }
// cout<< "\n\n\t TEST " << ""<<"";
//
::operator delete(ptr);
return 0;
}
template<typename T>
struct Pred
{ bool operator()(T a, T b) { return true; }
};
int test3_LinkedList() {
// CycList<Friendy> lss;
//
// std::vector<double> lss;
// lss.push_back(1.1);
// lss.push_back(2.2);
// lss.push_back(3.1);
// lss.push_back(6.2);
// lss.push_back(1.1);
// lss.push_back(2.2);
// lss.push_back(3.1);
// lss.push_back(6.2);
// CycList<double> laa;
// laa.transplant(laa.begin(), lss.begin(), lss.end());
// for(auto a : laa) {
// cout << a << endl;
// }
// cout << laa.end() - laa.begin() << " " << laa.size() << endl;
// cout << laa.begin() - laa.end() << " " << laa.size() << endl;
// CycList<double> ltt(lss);
// ltt.splice(ltt.begin(), lss);
// CycList<double> ltt{99999.9, 8888.88, 77777.77};
// std::list<double> lss = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6};
// for(auto& i : ltt) {
// cout << i << endl;
// }
CycList<Friendy> laa{Friendy(1.111), Friendy(2.222), Friendy(3.333), Friendy(44.44)};
std::vector<Friendy> vec{Friendy(55.55), Friendy(66.66), Friendy(77.77)};
// test M_transplant
// std::vector<FriendyAgain> vec{FriendyAgain(44545), FriendyAgain(456), FriendyAgain(7845)};
laa.splice(laa.begin(), {Friendy(8888.66), Friendy(99.9999)});
laa.splice(laa.begin() + 2, vec.begin(), vec.end());
// laa.transplant(laa.begin() + 2, vecx.begin(), vecx.end());
//9 8 5 6 7 1 2 3 4
//8 9 5 6 7 1 2 3 4
// 8 9 5 6 7 1 2 3 4
cout << "\n size " << laa.size() << endl;
// CycList<Friendy> lbb(vecx.begin(), vecx.end());
for(auto& i : laa) {
i.greet();
}
auto vecx = laa.to_array();
cout << "\nvecx" << endl;
for(size_t i = 0; i != laa.size(); ++i) {
(vecx + i)->greet();
}
::operator delete(vecx);
cout << "\n laa" << endl;
for(const auto& i : laa) {
i.greet();
}
cout << "const \n";
laa.begin()->greet();
laa = {Friendy(8888.66), Friendy(99.9999)};
for(const auto& i : laa) {
i.greet();
}
// laa.cBegin()->greet();
/*
cout << "\n laa[2].greet();" << endl;
laa[2].greet();
// std::sort(laa.begin(), laa.end(), [](const Friendy& a, const Friendy& b)->bool{return a.mk > b.mk;});
cout << "compare " << std::boolalpha;
cout << (laa.begin() - laa.end() ) << " " << (laa.end() - laa.begin() ) <<endl;
cout<< (laa.begin() < laa.end() ) << endl;
cout << "\n after std::sort" << endl;
for(auto& i : laa) {
i.greet();
}
static_assert(std::is_same<CycList<Friendy>::Iter, decltype(laa.begin())>::value, "" );
int* pint= nullptr;
uint64_t* puint_64_t = nullptr;
cout << sizeof(puint_64_t) << endl;
cout << typeid(puint_64_t).name() << endl;
*/
//assert(1 != 1);
// cout << std::is_same<CycList<Friendy>::Iter, decltype(laa.begin())>::value << endl;
// cout << "\ntest sort" << endl;
// CycList<double> lbb{1.1, 2.2, 4.4, 99.9, 88.88, 55.12, 19.45, 66.15};
// for(auto& i : lbb) {
// cout << i << endl;
// }
// cout << "\ntest size" << lbb.size() << endl;
// auto yeah = [](double i)->bool{cout << i << " in lambda"<< endl; return true;};
//
// lbb.removeIf(yeah);
//
// std::function<bool(double, double)> dd = [](double i, double j)->bool{return true;};
// lbb.merge(lxx, dd);
// Pred<bool> ppp;
// lbb.merge(lxx, ppp);
// cout << lbb.end() - lbb.begin() << " size: " << lbb.size()<< endl;
// // std::sort(lbb.begin(), lbb.end());
// // cout << "\ntest sort" << endl;
// for(auto& i : lbb) {
// cout << i << endl;
// }
// for(int i = 0; i != LOOP; ++i) {
// lss.push_back(Friendy(rand()));
// }
// for(auto& i : lss) {
// i.greet();
// }
// lss.removeAt(6);
// cout << " removeAt 6" << lss.size() << endl;
// for(auto& i : lss) {
// i.greet();
// }
// cout << " At 6" << lss.size() << endl;
// lss[6].greet();
//typedef Friendy alis;
//Friendy ad;
//if(std::is_same<decltype(ad), alis>::value) { cout << "ok ok" << endl;}
return 0;
}
void test_4() {
CycList<Friendy> laa{Friendy(1.111), Friendy(2.222), Friendy(3.333), Friendy(44.44)};
std::vector<Friendy> vec{Friendy(55.55), Friendy(66.66), Friendy(77.77)};
laa.splice(laa.begin(), {Friendy(8888.66), Friendy(99.9999)});
laa.splice(laa.begin() + 2, vec.begin(), vec.end());
for(auto & i : laa) {
i.greet();
}
}
void test_5_LinkedList() {
// CycList<int> l1{5, 9, 0, 1, 3};
//// for(auto & i : l1) {
//// cout << i << " ";
//// }
//// cout << endl;
// CycList<int> l2{8, 7, 2, 16, 4};
//// // l1.merge(l2, [](int a, int b)->bool{return a > b;});
// cout << "\nfirst" << l1.size() << endl;
// l1.merge(l2);
//// for(auto & i : l1) {
//// cout << i << " ";
//// }
// // l1.splice(l1.begin(), {11, 11, 33, 33, 55, 55, 88, 88});
// // cout << "\nfirst" << l1.size() << endl;
// // for(auto & i : l1) {
// // cout << i << " ";
// // }
// // l1.unique();
// cout << "\nunique"<< l1.size() << endl;
// for(auto & i : l1) {
// cout << i << " ";
// }
// CycList<int> ls{0, 1, 35, 9, 44, 51, 28};
CycList<Friendy> ls;
CycList<Friendy> lt;
for(int i = 0; i != 16; ++i) {
ls.push_back(Friendy(rand()));
lt.push_back(Friendy(rand()));
}
cout << "\n\t original " << ls.size() << endl;
for(auto & i : ls) {
// cout << i << endl;
i.greet();
}
cout << "\n\t sorting " << ls.size() << endl;
ls.sort([](const Friendy& a, const Friendy& b)->bool{return a.mk < b.mk;});
lt = ls;
cout << "\n\t sorted " << lt.size() << endl;
for(auto & i : lt) {
// cout << i << endl;
i.greet();
}
}
void test_hash() {
CycList<Friendy> ls{Friendy(55.55), Friendy(66.66), Friendy(77.77), Friendy(8888.66), Friendy(99.9999)};
CycList<Friendy> lt(ls);
// CycList<double> ls;
// for(int i = 0; i != 256; ++i) {
// ls.push_back(Friendy(rand()));
// // ls.push_back(rand());
// }
// ls.sort();
// ls.sort([](const Friendy& a, const Friendy& b)->bool{return a.mk < b.mk;});
// for(auto i : ls) {
// // cout << i << " ";
// i.greet();
// }
cout << "\n\n hash " << ls.hash_code()<< endl;
cout << " hash " << lt.hash_code()<< endl;
}
inline uint32_t jenkins_rev_mix32(uint32_t key) {
key += (key << 12); // key *= (1 + (1 << 12))
key ^= (key >> 22);
key += (key << 4); // key *= (1 + (1 << 4))
key ^= (key >> 9);
key += (key << 10); // key *= (1 + (1 << 10))
key ^= (key >> 2);
// key *= (1 + (1 << 7)) * (1 + (1 << 12))
key += (key << 7);
key += (key << 12);
return key;
}
/*
* Inverse of jenkins_rev_mix32
*
* Note that jenkinks_rev_unmix32 is significantly slower than
* jenkins_rev_mix32.
*/
inline uint32_t
jenkins_rev_unmix32(uint32_t key) {
// These are the modular multiplicative inverses (in Z_2^32) of the
// multiplication factors in jenkins_rev_mix32, in reverse order. They were
// computed using the Extended Euclidean algorithm, see
// http://en.wikipedia.org/wiki/Modular_multiplicative_inverse
key *= 2364026753U;
// The inverse of a ^= (a >> n) is
// b = a
// for (int i = n; i < 32; i += n) {
// b ^= (a >> i);
// }
key ^=
(key >> 2) ^ (key >> 4) ^ (key >> 6) ^ (key >> 8) ^
(key >> 10) ^ (key >> 12) ^ (key >> 14) ^ (key >> 16) ^
(key >> 18) ^ (key >> 20) ^ (key >> 22) ^ (key >> 24) ^
(key >> 26) ^ (key >> 28) ^ (key >> 30);
key *= 3222273025U;
key ^= (key >> 9) ^ (key >> 18) ^ (key >> 27);
key *= 4042322161U;
key ^= (key >> 22);
key *= 16773121U;
return key;
}
const uint32_t FNV_32_HASH_START = 216613626UL;
const uint64_t FNV_64_HASH_START = 14695981039346656037ULL;
inline uint32_t fnv32(const char* s,
uint32_t hash = FNV_32_HASH_START) {
for (; *s; ++s) {
hash += (hash << 1) + (hash << 4) + (hash << 7) +
(hash << 8) + (hash << 24);
hash ^= *s;
}
return hash;
}
inline uint32_t fnv32_buf(const void* buf,
int n,
uint32_t hash = FNV_32_HASH_START) {
const char* char_buf = reinterpret_cast<const char*>(buf);
for (int i = 0; i < n; ++i) {
hash += (hash << 1) + (hash << 4) + (hash << 7) +
(hash << 8) + (hash << 24);
hash ^= char_buf[i];
}
return hash;
}
inline uint32_t fnv32(const std::string& str,
uint64_t hash = FNV_32_HASH_START) {
return fnv32_buf(str.data(), str.size(), hash);
}
int test_hash_funcs() {
uint32_t key = 20130126;
cout << jenkins_rev_mix32(jenkins_rev_unmix32(key)) << endl;
cout << jenkins_rev_unmix32(key) << endl;
cout << jenkins_rev_unmix32 ( jenkins_rev_mix32(key) ) << endl;
std::string str = "20130126xsdnfndaklhvopekwpqowdajsfqw";
std::hash<std::string> stringHasher;
cout << str << endl;
// assert( reinterpret_cast<size_t>(str.data()) == stringHasher(str) );
cout << fnv32(str) << endl;
cout << stringHasher(str) << endl;
return 0;
}
// Friendy* ptr = (Friendy*)::operator new (LOOP * sizeof(Friendy));
// Friendy* ptr1 = ptr + 1;
// new((void*)ptr1) Friendy();
// ptr1->~Friendy();
// ::operator delete(ptr);
// ptr = (Friendy*)::operator new (128 * sizeof(Friendy)); ::operator delete(ptr);
// ptr = (Friendy*)::operator new (128 * sizeof(Friendy)); ::operator delete(ptr);
// ptr = (Friendy*)::operator new (128 * sizeof(Friendy)); ::operator delete(ptr);
// ptr1->greet();
| [
"xcommando@outlook.com"
] | xcommando@outlook.com |
9ee72a3e56b3001c3a123396077db6a389f7ebfa | 304ef9ff301d97451d01ed44e145a974ecf8ff87 | /leetcode/203-remove-linked-list-elements.cpp | 4193b8451a777025416304f692e501dbb3d392a0 | [] | no_license | hartaacme/competitive-programming | eafb8d6ca09b000d2a6207e8e7f915742b440b79 | 0f77cb0c2240e687ce7813b4f5bf79a4d9828715 | refs/heads/master | 2021-01-17T15:55:03.735973 | 2016-07-12T06:52:47 | 2016-07-12T06:52:47 | 57,095,232 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 509 | cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* removeElements(ListNode* head, int val) {
while (head && head->val == val) {
head = head->next;
}
if (head == NULL) return head;
ListNode *curr = head;
while (curr->next) {
if (curr->next->val == val) curr->next = curr->next->next;
else curr = curr->next;
}
return head;
}
};
| [
"wijayaha@garena.com"
] | wijayaha@garena.com |
da6902797bb2471933ab2e7e15d0676f1d4d20a9 | 7dc042a3f9068bc911c16f9173393660df704dab | /VC2008Samples/MFC/general/Scribble/stdafx.cpp | f0d958b1471f8d16fd62898be2bbfae4b061fa5d | [
"MIT"
] | permissive | pluciro/VCSamples | 5639f953bfbe0ef598af601cc78d5a18012e1792 | 8453972390580ef1bbc8c09ec7a14d3c9111518e | refs/heads/master | 2022-05-10T04:45:11.889276 | 2022-05-06T15:11:50 | 2022-05-06T15:11:50 | 280,199,366 | 0 | 0 | NOASSERTION | 2020-07-16T16:10:32 | 2020-07-16T16:10:32 | null | UTF-8 | C++ | false | false | 605 | cpp | // stdafx.cpp : source file that includes just the standard includes
// Scribble.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
| [
"ericmitt@corp.microsoft.com"
] | ericmitt@corp.microsoft.com |
5fcf9116d279416f6d883b71766db5291cde4d95 | 3edc478db837a27dbf8df7eded45df909dfe3cf9 | /URI online/1245.cpp | fdf48db2524ceb6a12dcf911f09e8a3ada69a0f1 | [] | no_license | ronistone/Maratonas | b60ebeb9e7e9298399652df88faa83389bd94542 | 8bd0bedd476645081a09b19152a007ca1497fe20 | refs/heads/master | 2021-01-12T10:06:04.016208 | 2018-10-19T02:40:54 | 2018-10-19T02:40:54 | 76,360,276 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 453 | cpp | #include <bits/stdc++.h>
using namespace std;
main(){
int n,i,j,aux;
while(cin >> n){
std::vector<int> v;
char pe[n];
int count =0;
for(i=0;i<n;i++){
cin >> aux >> pe[i];
v.push_back(aux);
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(j!=i && v[i]==v[j] && v[i]!=0 && v[j]!=0 && ((pe[i]=='D' && pe[j]=='E') || (pe[i]=='E' && pe[j]=='D'))){
v[i] = 0;
v[j] = 0;
count++;
}
}
}
cout << count << endl;
}
} | [
"ronistonejunior@gmail.com"
] | ronistonejunior@gmail.com |
a9d556b8626fec512b1b6430a443627b64af71b9 | 46bf6fc69231692b467f50eba2299db7f1784ace | /Proj/facade/hfbutton_facade.h | 0a23956117c0a795552e3286adfeed7f0c460d65 | [] | no_license | RabbitChenc/crasherror | 5080c6629659a04721e27a04a5100d982c264ff6 | 2b3c589f00e60fc32b0715d795d6ac5070126113 | refs/heads/master | 2022-09-17T13:19:21.198554 | 2020-06-03T09:03:28 | 2020-06-03T09:03:28 | 269,039,710 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 979 | h |
/*
*
*brief:使用qpainter 画家类 自定义一个按钮控件
* 按钮继承了Qwidget 重写绘图事件 和鼠标相关的事件
*
*author: Chenjm
*
*/
#ifndef HFBUTTONFACADE_H
#define HFBUTTONFACADE_H
#include "../hfview_facade.h"
#include <QWidget>
#include <QColor>
class HFButtonFacade : public HFViewFacade
{
Q_OBJECT
public:
explicit HFButtonFacade(QWidget*parent = nullptr);
virtual ~HFButtonFacade();
signals:
void pressed();
void released();
protected:
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void drawImage(QPainter*painter);
QPixmap* ninePatch(QString picName,int iHorzSplit,int iVertSplit, int DstWidth, int DstHeight);
QPixmap generatePixmap(const QPixmap &src, const int w,const int h);
private:
bool press;
int btnWidth;
int btnHight;
int btnStyle;
QString mImageName;
};
#endif // HFBUTTONFACADE_H
| [
"357778342@qq.com"
] | 357778342@qq.com |
e8ff4ec859a9827f95d2ec728e9bdf4389f00882 | 36579e820f5c07cd1fe796abc777f23f32efeb10 | /src/chrome/browser/prerender/prerender_link_manager.cc | b0b2bc6496b8ef837beef4932b00a47c03cafadf | [
"BSD-3-Clause"
] | permissive | sokolovp/BraveMining | 089ea9940ee6e6cb8108b106198e66c62049d27b | 7040cdee80f6f7176bea0e92f8f3435abce3e0ae | refs/heads/master | 2020-03-20T00:52:22.001918 | 2018-06-12T11:33:31 | 2018-06-12T11:33:31 | 137,058,944 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 18,746 | cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/prerender/prerender_link_manager.h"
#include <functional>
#include <limits>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/prerender/prerender_contents.h"
#include "chrome/browser/prerender/prerender_handle.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/prerender/prerender_manager_factory.h"
#include "chrome/common/prerender.mojom.h"
#include "chrome/common/prerender_types.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/session_storage_namespace.h"
#include "content/public/common/referrer.h"
#include "extensions/features/features.h"
#include "third_party/WebKit/public/common/associated_interfaces/associated_interface_provider.h"
#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "components/guest_view/browser/guest_view_base.h"
#endif
using base::TimeDelta;
using base::TimeTicks;
using content::RenderViewHost;
using content::SessionStorageNamespace;
namespace prerender {
namespace {
static_assert(PrerenderRelTypePrerender == 0x1,
"RelTypeHistogrameEnum must match PrerenderRelType");
static_assert(PrerenderRelTypeNext == 0x2,
"RelTypeHistogramEnum must match PrerenderRelType");
constexpr int kRelTypeHistogramEnumMax =
(PrerenderRelTypePrerender | PrerenderRelTypeNext) + 1;
void RecordLinkManagerAdded(const uint32_t rel_types) {
UMA_HISTOGRAM_ENUMERATION("Prerender.RelTypesLinkAdded",
rel_types & (kRelTypeHistogramEnumMax - 1),
kRelTypeHistogramEnumMax);
}
void RecordLinkManagerStarting(const uint32_t rel_types) {
UMA_HISTOGRAM_ENUMERATION("Prerender.RelTypesLinkStarted",
rel_types & (kRelTypeHistogramEnumMax - 1),
kRelTypeHistogramEnumMax);
}
chrome::mojom::PrerenderDispatcherAssociatedPtr GetPrerenderDispatcher(
int child_id) {
chrome::mojom::PrerenderDispatcherAssociatedPtr prerender_dispatcher;
content::RenderProcessHost* render_process_host =
content::RenderProcessHost::FromID(child_id);
if (render_process_host) {
IPC::ChannelProxy* channel = render_process_host->GetChannel();
// |channel| might be NULL in tests.
if (channel) {
channel->GetRemoteAssociatedInterface(&prerender_dispatcher);
}
}
return prerender_dispatcher;
}
} // namespace
// Helper class to implement PrerenderContents::Observer and watch prerenders
// which launch other prerenders.
class PrerenderLinkManager::PendingPrerenderManager
: public PrerenderContents::Observer {
public:
explicit PendingPrerenderManager(PrerenderLinkManager* link_manager)
: link_manager_(link_manager) {}
~PendingPrerenderManager() override { CHECK(observed_launchers_.empty()); }
void ObserveLauncher(PrerenderContents* launcher) {
DCHECK_EQ(FINAL_STATUS_MAX, launcher->final_status());
bool inserted = observed_launchers_.insert(launcher).second;
if (inserted)
launcher->AddObserver(this);
}
void OnPrerenderStart(PrerenderContents* launcher) override {}
void OnPrerenderStop(PrerenderContents* launcher) override {
observed_launchers_.erase(launcher);
if (launcher->final_status() == FINAL_STATUS_USED) {
link_manager_->StartPendingPrerendersForLauncher(launcher);
} else {
link_manager_->CancelPendingPrerendersForLauncher(launcher);
}
}
void OnPrerenderNetworkBytesChanged(PrerenderContents* launcher) override {}
private:
// A pointer to the parent PrerenderLinkManager.
PrerenderLinkManager* link_manager_;
// The set of PrerenderContentses being observed. Lifetimes are managed by
// OnPrerenderStop.
std::set<PrerenderContents*> observed_launchers_;
};
PrerenderLinkManager::PrerenderLinkManager(PrerenderManager* manager)
: has_shutdown_(false),
manager_(manager),
pending_prerender_manager_(
std::make_unique<PendingPrerenderManager>(this)) {}
PrerenderLinkManager::~PrerenderLinkManager() {
for (auto& prerender : prerenders_) {
if (prerender.handle) {
DCHECK(!prerender.handle->IsPrerendering())
<< "All running prerenders should stop at the same time as the "
<< "PrerenderManager.";
delete prerender.handle;
prerender.handle = nullptr;
}
}
}
void PrerenderLinkManager::OnAddPrerender(int launcher_child_id,
int prerender_id,
const GURL& url,
uint32_t rel_types,
const content::Referrer& referrer,
const gfx::Size& size,
int render_view_route_id) {
DCHECK_EQ(nullptr, FindByLauncherChildIdAndPrerenderId(launcher_child_id,
prerender_id));
#if BUILDFLAG(ENABLE_EXTENSIONS)
content::RenderViewHost* rvh =
content::RenderViewHost::FromID(launcher_child_id, render_view_route_id);
content::WebContents* web_contents =
rvh ? content::WebContents::FromRenderViewHost(rvh) : nullptr;
// Guests inside <webview> do not support cross-process navigation and so we
// do not allow guests to prerender content.
if (guest_view::GuestViewBase::IsGuest(web_contents))
return;
#endif
// Check if the launcher is itself an unswapped prerender.
PrerenderContents* prerender_contents =
manager_->GetPrerenderContentsForRoute(launcher_child_id,
render_view_route_id);
if (prerender_contents &&
prerender_contents->final_status() != FINAL_STATUS_MAX) {
// The launcher is a prerender about to be destroyed asynchronously, but
// its AddLinkRelPrerender message raced with shutdown. Ignore it.
DCHECK_NE(FINAL_STATUS_USED, prerender_contents->final_status());
return;
}
LinkPrerender
prerender(launcher_child_id, prerender_id, url, rel_types, referrer, size,
render_view_route_id, manager_->GetCurrentTimeTicks(),
prerender_contents);
prerenders_.push_back(prerender);
RecordLinkManagerAdded(rel_types);
if (prerender_contents)
pending_prerender_manager_->ObserveLauncher(prerender_contents);
else
StartPrerenders();
}
void PrerenderLinkManager::OnCancelPrerender(int child_id, int prerender_id) {
LinkPrerender* prerender = FindByLauncherChildIdAndPrerenderId(child_id,
prerender_id);
if (!prerender)
return;
CancelPrerender(prerender);
StartPrerenders();
}
void PrerenderLinkManager::OnAbandonPrerender(int child_id, int prerender_id) {
LinkPrerender* prerender = FindByLauncherChildIdAndPrerenderId(child_id,
prerender_id);
if (!prerender)
return;
if (!prerender->handle) {
RemovePrerender(prerender);
return;
}
prerender->has_been_abandoned = true;
prerender->handle->OnNavigateAway();
DCHECK(prerender->handle);
// If the prerender is not running, remove it from the list so it does not
// leak. If it is running, it will send a cancel event when it stops which
// will remove it.
if (!prerender->handle->IsPrerendering())
RemovePrerender(prerender);
}
void PrerenderLinkManager::OnChannelClosing(int child_id) {
std::list<LinkPrerender>::iterator next = prerenders_.begin();
while (next != prerenders_.end()) {
std::list<LinkPrerender>::iterator it = next;
++next;
if (child_id != it->launcher_child_id)
continue;
const size_t running_prerender_count = CountRunningPrerenders();
OnAbandonPrerender(child_id, it->prerender_id);
DCHECK_EQ(running_prerender_count, CountRunningPrerenders());
}
}
PrerenderLinkManager::LinkPrerender::LinkPrerender(
int launcher_child_id,
int prerender_id,
const GURL& url,
uint32_t rel_types,
const content::Referrer& referrer,
const gfx::Size& size,
int render_view_route_id,
TimeTicks creation_time,
PrerenderContents* deferred_launcher)
: launcher_child_id(launcher_child_id),
prerender_id(prerender_id),
url(url),
rel_types(rel_types),
referrer(referrer),
size(size),
render_view_route_id(render_view_route_id),
creation_time(creation_time),
deferred_launcher(deferred_launcher),
handle(nullptr),
has_been_abandoned(false) {}
PrerenderLinkManager::LinkPrerender::LinkPrerender(const LinkPrerender& other) =
default;
PrerenderLinkManager::LinkPrerender::~LinkPrerender() {
DCHECK_EQ(nullptr, handle)
<< "The PrerenderHandle should be destroyed before its Prerender.";
}
bool PrerenderLinkManager::IsEmpty() const {
return prerenders_.empty();
}
size_t PrerenderLinkManager::CountRunningPrerenders() const {
return std::count_if(prerenders_.begin(), prerenders_.end(),
[](const LinkPrerender& prerender) {
return prerender.handle &&
prerender.handle->IsPrerendering();
});
}
void PrerenderLinkManager::StartPrerenders() {
if (has_shutdown_)
return;
size_t total_started_prerender_count = 0;
std::list<LinkPrerender*> abandoned_prerenders;
std::list<std::list<LinkPrerender>::iterator> pending_prerenders;
std::multiset<std::pair<int, int> >
running_launcher_and_render_view_routes;
// Scan the list, counting how many prerenders have handles (and so were added
// to the PrerenderManager). The count is done for the system as a whole, and
// also per launcher.
for (std::list<LinkPrerender>::iterator i = prerenders_.begin();
i != prerenders_.end(); ++i) {
LinkPrerender& prerender = *i;
// Skip prerenders launched by a prerender.
if (prerender.deferred_launcher)
continue;
if (!prerender.handle) {
pending_prerenders.push_back(i);
} else {
++total_started_prerender_count;
if (prerender.has_been_abandoned) {
abandoned_prerenders.push_back(&prerender);
} else {
// We do not count abandoned prerenders towards their launcher, since it
// has already navigated on to another page.
std::pair<int, int> launcher_and_render_view_route(
prerender.launcher_child_id, prerender.render_view_route_id);
running_launcher_and_render_view_routes.insert(
launcher_and_render_view_route);
DCHECK_GE(manager_->config().max_link_concurrency_per_launcher,
running_launcher_and_render_view_routes.count(
launcher_and_render_view_route));
}
}
DCHECK_EQ(&prerender,
FindByLauncherChildIdAndPrerenderId(prerender.launcher_child_id,
prerender.prerender_id));
}
DCHECK_LE(abandoned_prerenders.size(), total_started_prerender_count);
DCHECK_GE(manager_->config().max_link_concurrency,
total_started_prerender_count);
DCHECK_LE(CountRunningPrerenders(), total_started_prerender_count);
TimeTicks now = manager_->GetCurrentTimeTicks();
// Scan the pending prerenders, starting prerenders as we can.
for (std::list<std::list<LinkPrerender>::iterator>::const_iterator
i = pending_prerenders.begin(), end = pending_prerenders.end();
i != end; ++i) {
const std::list<LinkPrerender>::iterator& it = *i;
TimeDelta prerender_age = now - it->creation_time;
if (prerender_age >= manager_->config().max_wait_to_launch) {
// This prerender waited too long in the queue before launching.
prerenders_.erase(it);
continue;
}
std::pair<int, int> launcher_and_render_view_route(
it->launcher_child_id, it->render_view_route_id);
if (manager_->config().max_link_concurrency_per_launcher <=
running_launcher_and_render_view_routes.count(
launcher_and_render_view_route)) {
// This prerender's launcher is already at its limit.
continue;
}
if (total_started_prerender_count >=
manager_->config().max_link_concurrency ||
total_started_prerender_count >= prerenders_.size()) {
// The system is already at its prerender concurrency limit. Try removing
// an abandoned prerender, if one exists, to make room.
if (abandoned_prerenders.empty())
return;
CancelPrerender(abandoned_prerenders.front());
--total_started_prerender_count;
abandoned_prerenders.pop_front();
}
if (!(PrerenderRelTypePrerender & it->rel_types)) {
prerenders_.erase(it);
continue;
}
std::unique_ptr<PrerenderHandle> handle =
manager_->AddPrerenderFromLinkRelPrerender(
it->launcher_child_id, it->render_view_route_id, it->url,
it->rel_types, it->referrer, it->size);
if (!handle) {
// This prerender couldn't be launched, it's gone.
prerenders_.erase(it);
continue;
}
if (handle->IsPrerendering()) {
// We have successfully started a new prerender.
it->handle = handle.release();
++total_started_prerender_count;
it->handle->SetObserver(this);
OnPrerenderStart(it->handle);
RecordLinkManagerStarting(it->rel_types);
running_launcher_and_render_view_routes.insert(
launcher_and_render_view_route);
} else {
content::RenderProcessHost* render_process_host =
content::RenderProcessHost::FromID(it->launcher_child_id);
if (!render_process_host)
return;
IPC::ChannelProxy* channel = render_process_host->GetChannel();
// |channel| might be NULL in tests.
if (channel) {
chrome::mojom::PrerenderDispatcherAssociatedPtr prerender_dispatcher;
channel->GetRemoteAssociatedInterface(&prerender_dispatcher);
prerender_dispatcher->PrerenderStop(it->prerender_id);
}
prerenders_.erase(it);
}
}
}
PrerenderLinkManager::LinkPrerender*
PrerenderLinkManager::FindByLauncherChildIdAndPrerenderId(int launcher_child_id,
int prerender_id) {
for (auto& prerender : prerenders_) {
if (prerender.launcher_child_id == launcher_child_id &&
prerender.prerender_id == prerender_id) {
return &prerender;
}
}
return nullptr;
}
PrerenderLinkManager::LinkPrerender*
PrerenderLinkManager::FindByPrerenderHandle(PrerenderHandle* prerender_handle) {
DCHECK(prerender_handle);
for (auto& prerender : prerenders_) {
if (prerender.handle == prerender_handle)
return &prerender;
}
return nullptr;
}
void PrerenderLinkManager::RemovePrerender(LinkPrerender* prerender) {
for (std::list<LinkPrerender>::iterator i = prerenders_.begin();
i != prerenders_.end(); ++i) {
LinkPrerender& current_prerender = *i;
if (¤t_prerender == prerender) {
std::unique_ptr<PrerenderHandle> own_handle(prerender->handle);
prerender->handle = nullptr;
prerenders_.erase(i);
return;
}
}
NOTREACHED();
}
void PrerenderLinkManager::CancelPrerender(LinkPrerender* prerender) {
for (std::list<LinkPrerender>::iterator i = prerenders_.begin();
i != prerenders_.end(); ++i) {
LinkPrerender& current_prerender = *i;
if (¤t_prerender == prerender) {
std::unique_ptr<PrerenderHandle> own_handle(prerender->handle);
prerender->handle = nullptr;
prerenders_.erase(i);
if (own_handle)
own_handle->OnCancel();
return;
}
}
NOTREACHED();
}
void PrerenderLinkManager::StartPendingPrerendersForLauncher(
PrerenderContents* launcher) {
for (auto& prerender : prerenders_) {
if (prerender.deferred_launcher == launcher)
prerender.deferred_launcher = nullptr;
}
StartPrerenders();
}
void PrerenderLinkManager::CancelPendingPrerendersForLauncher(
PrerenderContents* launcher) {
// Remove all pending prerenders for this launcher.
for (std::list<LinkPrerender>::iterator i = prerenders_.begin();
i != prerenders_.end();) {
if (i->deferred_launcher == launcher) {
DCHECK(!i->handle);
i = prerenders_.erase(i);
} else {
++i;
}
}
}
void PrerenderLinkManager::Shutdown() {
has_shutdown_ = true;
}
// In practice, this is always called from PrerenderLinkManager::OnAddPrerender.
void PrerenderLinkManager::OnPrerenderStart(
PrerenderHandle* prerender_handle) {
LinkPrerender* prerender = FindByPrerenderHandle(prerender_handle);
if (!prerender)
return;
chrome::mojom::PrerenderDispatcherAssociatedPtr prerender_dispatcher =
GetPrerenderDispatcher(prerender->launcher_child_id);
if (prerender_dispatcher)
prerender_dispatcher->PrerenderStart(prerender->prerender_id);
}
void PrerenderLinkManager::OnPrerenderStopLoading(
PrerenderHandle* prerender_handle) {
LinkPrerender* prerender = FindByPrerenderHandle(prerender_handle);
if (!prerender)
return;
chrome::mojom::PrerenderDispatcherAssociatedPtr prerender_dispatcher =
GetPrerenderDispatcher(prerender->launcher_child_id);
if (prerender_dispatcher)
prerender_dispatcher->PrerenderStopLoading(prerender->prerender_id);
}
void PrerenderLinkManager::OnPrerenderDomContentLoaded(
PrerenderHandle* prerender_handle) {
LinkPrerender* prerender = FindByPrerenderHandle(prerender_handle);
if (!prerender)
return;
chrome::mojom::PrerenderDispatcherAssociatedPtr prerender_dispatcher =
GetPrerenderDispatcher(prerender->launcher_child_id);
if (prerender_dispatcher)
prerender_dispatcher->PrerenderDomContentLoaded(prerender->prerender_id);
}
void PrerenderLinkManager::OnPrerenderStop(
PrerenderHandle* prerender_handle) {
LinkPrerender* prerender = FindByPrerenderHandle(prerender_handle);
if (!prerender)
return;
chrome::mojom::PrerenderDispatcherAssociatedPtr prerender_dispatcher =
GetPrerenderDispatcher(prerender->launcher_child_id);
if (prerender_dispatcher)
prerender_dispatcher->PrerenderStop(prerender->prerender_id);
RemovePrerender(prerender);
StartPrerenders();
}
void PrerenderLinkManager::OnPrerenderNetworkBytesChanged(
PrerenderHandle* prerender_handle) {}
} // namespace prerender
| [
"sokolov.p@gmail.com"
] | sokolov.p@gmail.com |
165da4abd4f993eb027567a3e8f025fc364ba656 | 89dedd7f3c7acc81d12e2bcb2e716f9af9e5fa04 | /chrome/browser/extensions/api/management/chrome_management_api_delegate.h | 4140ee93e1e8266f3dcad4ddf9efc5b0703442ab | [
"BSD-3-Clause"
] | permissive | bino7/chromium | 8d26f84a1b6e38a73d1b97fea6057c634eff68cb | 4666a6bb6fdcb1114afecf77bdaa239d9787b752 | refs/heads/master | 2022-12-22T14:31:53.913081 | 2016-09-06T10:05:11 | 2016-09-06T10:05:11 | 67,410,510 | 1 | 3 | BSD-3-Clause | 2022-12-17T03:08:52 | 2016-09-05T10:11:59 | null | UTF-8 | C++ | false | false | 3,729 | h | // 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.
#ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_CHROME_MANAGEMENT_API_DELEGATE_H_
#define CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_CHROME_MANAGEMENT_API_DELEGATE_H_
#include "base/task/cancelable_task_tracker.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/extension_uninstall_dialog.h"
#include "extensions/browser/api/management/management_api_delegate.h"
namespace favicon_base {
struct FaviconImageResult;
} // namespace favicon_base
class ChromeManagementAPIDelegate : public extensions::ManagementAPIDelegate {
public:
ChromeManagementAPIDelegate();
~ChromeManagementAPIDelegate() override;
// ManagementAPIDelegate.
void LaunchAppFunctionDelegate(
const extensions::Extension* extension,
content::BrowserContext* context) const override;
GURL GetFullLaunchURL(const extensions::Extension* extension) const override;
extensions::LaunchType GetLaunchType(
const extensions::ExtensionPrefs* prefs,
const extensions::Extension* extension) const override;
void GetPermissionWarningsByManifestFunctionDelegate(
extensions::ManagementGetPermissionWarningsByManifestFunction* function,
const std::string& manifest_str) const override;
std::unique_ptr<extensions::InstallPromptDelegate> SetEnabledFunctionDelegate(
content::WebContents* web_contents,
content::BrowserContext* browser_context,
const extensions::Extension* extension,
const base::Callback<void(bool)>& callback) const override;
std::unique_ptr<extensions::RequirementsChecker> CreateRequirementsChecker()
const override;
std::unique_ptr<extensions::UninstallDialogDelegate>
UninstallFunctionDelegate(
extensions::ManagementUninstallFunctionBase* function,
const extensions::Extension* target_extension,
bool show_programmatic_uninstall_ui) const override;
bool CreateAppShortcutFunctionDelegate(
extensions::ManagementCreateAppShortcutFunction* function,
const extensions::Extension* extension) const override;
std::unique_ptr<extensions::AppForLinkDelegate>
GenerateAppForLinkFunctionDelegate(
extensions::ManagementGenerateAppForLinkFunction* function,
content::BrowserContext* context,
const std::string& title,
const GURL& launch_url) const override;
bool CanHostedAppsOpenInWindows() const override;
bool IsNewBookmarkAppsEnabled() const override;
void EnableExtension(content::BrowserContext* context,
const std::string& extension_id) const override;
void DisableExtension(
content::BrowserContext* context,
const std::string& extension_id,
extensions::Extension::DisableReason disable_reason) const override;
bool UninstallExtension(content::BrowserContext* context,
const std::string& transient_extension_id,
extensions::UninstallReason reason,
const base::Closure& deletion_done_callback,
base::string16* error) const override;
void SetLaunchType(content::BrowserContext* context,
const std::string& extension_id,
extensions::LaunchType launch_type) const override;
GURL GetIconURL(const extensions::Extension* extension,
int icon_size,
ExtensionIconSet::MatchType match,
bool grayscale,
bool* exists) const override;
};
#endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_CHROME_MANAGEMENT_API_DELEGATE_H_
| [
"bino.zh@gmail.com"
] | bino.zh@gmail.com |
9542088c3d3fe5f00bff4b9ac46c660ee6e907dc | e1bafb9c94db3a6cfd86ce4b3a641e79583220b3 | /leetcode-clion/leetcode-problems/cpp/805.split-array-with-same-average.cpp | ede57023a8b404c948a30239146226dc7b2caabc | [] | no_license | lightjameslyy/lt-cpp | 055b0245ba9cc4608db6a0d08dc081d1c2766ba2 | 525c3f0fbeb4b112361a6650bf3ef445fdb61e2c | refs/heads/master | 2021-07-09T08:32:24.405308 | 2020-06-08T08:45:10 | 2020-06-08T08:45:10 | 128,907,003 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,006 | cpp | /*
* @lc app=leetcode id=805 lang=cpp
*
* [805] Split Array With Same Average
*
* https://leetcode.com/problems/split-array-with-same-average/description/
*
* algorithms
* Hard (25.21%)
* Total Accepted: 11.4K
* Total Submissions: 45.2K
* Testcase Example: '[1,2,3,4,5,6,7,8]'
*
* In a given integer array A, we must move every element of A to either list B
* or list C. (B and C initially start empty.)
*
* Return true if and only if after such a move, it is possible that the
* average value of B is equal to the average value of C, and B and C are both
* non-empty.
*
*
* Example :
* Input:
* [1,2,3,4,5,6,7,8]
* Output: true
* Explanation: We can split the array into [1,4,5,8] and [2,3,6,7], and both
* of them have the average of 4.5.
*
*
* Note:
*
*
* The length of A will be in the range [1, 30].
* A[i] will be in the range of [0, 10000].
*
*
*
*
*/
class Solution {
public:
bool splitArraySameAverage(vector<int>& A) {
}
};
| [
"lightjameslyy@gmail.com"
] | lightjameslyy@gmail.com |
ed7c679d7382443a228fce5f7f34b9dd1950409e | 077810b41a92310c6325300a7442e3cef28d1c55 | /lib/xtl/test/test_xfunctional.cpp | db4c8ae3dff6efac3794a36943e530ba444d9023 | [
"MIT",
"BSD-3-Clause"
] | permissive | mjgalindo/VoxSurf | eab0412dd24b2695420911becb5851456c689382 | 6218a73da4acbf0db0895b9204846a19c23ba1c0 | refs/heads/master | 2022-09-06T05:17:47.734479 | 2020-06-01T18:54:08 | 2020-06-01T18:54:08 | 261,152,584 | 1 | 4 | MIT | 2020-05-04T11:13:41 | 2020-05-04T11:13:40 | null | UTF-8 | C++ | false | false | 863 | cpp | /***************************************************************************
* Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
* Copyright (c) QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
#include "xtl/xfunctional.hpp"
#include "gtest/gtest.h"
#include "xtl/xoptional.hpp"
namespace xtl
{
TEST(xfunctional, select_scalar)
{
EXPECT_EQ(select(true, 2., 3.), 2.);
EXPECT_EQ(select(false, 2., 3.), 3.);
}
}
| [
"38547166+toomb-raider@users.noreply.github.com"
] | 38547166+toomb-raider@users.noreply.github.com |
25fee3b5917604de4088248873dec5c74e1ab913 | 5c77807c8a39658e995c00adecb5f9e3bde0884d | /DataStructures/Vector/main.cpp | 849141fdf730dd9922f5e3d6837abd844f6426e3 | [] | no_license | starlitnext/practice | 6a39b116213caaf014875b32d048ff5f2d6ca190 | 3d1be394c7c7cc444a10cfd878caacb2f592b653 | refs/heads/master | 2021-01-18T21:33:09.692397 | 2018-01-24T15:23:25 | 2018-01-24T15:23:25 | 40,886,119 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 473 | cpp | #include <iostream>
#include "Vector.h"
using namespace std;
int main() {
Vector<double> v1(10, 0);
cout << v1.size() << endl;
cout << v1.capacity() << endl;
for (int i = 0; i < 10; i++)
v1.push_back(i);
cout << v1.size() << endl;
cout << v1.capacity() << endl;
v1.resize(20);
cout << v1.size() << endl;
cout << v1.capacity() << endl;
Vector<double> v2(v1);
for (auto it = v2.begin(); it != v2.end(); it++)
cout << *it << " ";
cout << endl;
return 0;
} | [
"vipxxq@foxmail.com"
] | vipxxq@foxmail.com |
9c795ee75d773fecc1d57b6db89fe80ed6b40504 | 41bf5ab42b2e29c20dda2eef9d073cbc6eb4ea5e | /md3dframework/InputListener.h | 1e93a7c6ae6c6eaad7ee3f3ab546a18ab2dd7f25 | [] | no_license | mvdgaag/D3D | 954078a7e0dbd7c647a4d111304157863e37ec90 | 26275e0b032ff585ac4beb75caff8a2f6e567aca | refs/heads/master | 2020-04-06T07:04:03.835089 | 2017-07-15T19:55:31 | 2017-07-15T19:55:31 | 43,242,562 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 743 | h | #pragma once
#include "GaagCommon.h"
#include "Input.h"
REGISTERCLASS(InputListener);
class InputListener
{
public:
explicit InputListener() { theInput.RegisterListener(this); }
virtual ~InputListener() { theInput.UnRegisterListener(this); }
virtual void OnKeyDown(unsigned int inKey) { UNREFERENCED_PARAMETER(inKey); }
virtual void OnKeyUp(unsigned int inKey) { UNREFERENCED_PARAMETER(inKey); }
virtual void OnMouseMove(float2 inCurrentCoord, float2 inPrevCoord) { UNREFERENCED_PARAMETER(inCurrentCoord); UNREFERENCED_PARAMETER(inPrevCoord); }
virtual void OnMouseDown(int inButton) { UNREFERENCED_PARAMETER(inButton); }
virtual void OnMouseUp(int inButton) { UNREFERENCED_PARAMETER(inButton); }
};
| [
"maarten.van.der.gaag@gmail.com"
] | maarten.van.der.gaag@gmail.com |
00b64af96e6f79abe8dd36186141c0fb2b3ea788 | 237acec099992ddb5fc8d55f59d7a89b25724350 | /src/AEntities/GraphicEntityManager.cpp | f935c003e910eaf708a3e42845ac55e6e8558051 | [] | no_license | polyeezy/mouillette_indie | dbefe96b6ebf96143e152c95dced7093e75f5d42 | 268084ec43a6f1006399915c3141a6193ba96359 | refs/heads/master | 2021-01-11T06:09:28.384481 | 2016-06-06T21:32:20 | 2016-06-06T21:32:20 | 57,026,638 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,735 | cpp | //
// GraphicEntityManager.cpp for in /home/polyeezy/rendu/CPP/mouillette_indie/src/AEntities
//
// Made by Valérian Polizzi
// Login <polizz_v@epitech.net>
//
// Started on Mon May 30 05:58:38 2016 Valérian Polizzi
// Last update Mon Jun 6 11:30:54 2016 Valérian Polizzi
//
#include <GraphicEntityManager.hh>
GraphicEntityManager::GraphicEntityManager()
{
}
GraphicEntityManager::~GraphicEntityManager()
{
}
irr::scene::IMeshSceneNode *GraphicEntityManager::createMap(const std::string &map)
{
enum
{
ID_IsNotPickable = 0,
IDFlag_IsPickable = 1 << 0,
IDFlag_IsHighlightable = 1 << 1
};
irr::scene::IAnimatedMesh* mesh_map = _scene->getMesh(map.c_str());
// irr::scene::ISceneNode* skydome = _scene->addSkyDomeSceneNode(_driver->getTexture("../../media/skydome.jpg"),16,8,0.95f,2.0f);
return (_scene->addOctreeSceneNode(mesh_map->getMesh(0), 0, IDFlag_IsPickable));
// if (map)
// {
// map->setPosition(irr::core::vector3df(-50,-10,0));
// map->setRotation(irr::core::vector3df(0,180,0));
// map->setMaterialFlag(irr::video::EMF_LIGHTING, false);
// map->setScale(irr::core::vector3df(1.5, 1.5, 1.5));
// }
return (_scene->addCubeSceneNode());
}
irr::scene::ISceneNode *GraphicEntityManager::createCube()
{
return (_scene->addCubeSceneNode());
}
irr::scene::ISceneManager *GraphicEntityManager::getScene()
{
return (_scene);
}
irr::scene::IMeshSceneNode *GraphicEntityManager::createObject(const std::string &path)
{
irr::scene::IMesh *mesh = _scene->getMesh(path.c_str());
if (mesh)
return (_scene->addMeshSceneNode(mesh));
return (NULL);
}
void GraphicEntityManager::setScene(irr::scene::ISceneManager *scene)
{
_scene = scene;
}
| [
"valerian.polizzi@epitech.eu"
] | valerian.polizzi@epitech.eu |
7071db0db32dea4f337dafad1a521ffb7272c0d1 | 2c347933a7c0baf41689167a82922f457e809bcb | /sphlib/system/common/CellIndices.h | aff24c3309b83d42143bc157e17c15b5e7a8fcbc | [] | no_license | shibing/fluid | 4173380401ddce6a94bba5857a02bf180131b15a | 23c19927f393234139e9243b56cb2ad995a2f2d8 | refs/heads/master | 2020-04-17T08:29:22.797889 | 2014-11-23T13:09:07 | 2014-11-23T13:09:07 | 25,852,296 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 725 | h |
#ifndef RTPS_CELLINDICES_H_INCLUDED
#define RTPS_CELLINDICES_H_INCLUDED
#include <RTPS.h>
#include <Buffer.h>
namespace rtps
{
class CellIndices
{
public:
CellIndices() { cli = NULL; }
CellIndices(const std::string& path, CL* cli);
int execute(int num,
Buffer<unsigned int>& hashes,
Buffer<unsigned int>& ci_start,
Buffer<unsigned int>& ci_stop,
Buffer<GridParams>& gp,
int nb_cells,
Buffer<float4>& clf_debug,
Buffer<int4>& cli_debug);
private:
CL* cli;
Kernel k_cellindices;
};
}
#endif
| [
"shibing.sw@gmail.com"
] | shibing.sw@gmail.com |
096b1959569e2c90b388d1a41d90494f4e33c0e2 | 1f0bb9cef7f824805599c40236a1d68965bf682f | /app/src/main/cpp/Transform.cpp | 43f0fda29e8b1aafa975e3e15a78b163588db8e8 | [
"Apache-2.0"
] | permissive | Da-minHan/android-gles3jni-texturecube | 7282f9b9d1231c40892d7331bd4be594c7c68508 | 4d8c84b9f88ab5949b01fcfe82fbaec84b695089 | refs/heads/master | 2023-03-03T18:53:26.643074 | 2021-02-17T15:43:23 | 2021-02-17T15:43:23 | 338,627,011 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 9,318 | cpp | // The MIT License (MIT)
//
// Copyright (c) 2013 Dan Ginsburg, Budirijanto Purnomo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// Book: OpenGL(R) ES 3.0 Programming Guide, 2nd Edition
// Authors: Dan Ginsburg, Budirijanto Purnomo, Dave Shreiner, Aaftab Munshi
// ISBN-10: 0-321-93388-5
// ISBN-13: 978-0-321-93388-1
// Publisher: Addison-Wesley Professional
// URLs: http://www.opengles-book.com
// http://my.safaribooksonline.com/book/animation-and-3d/9780133440133
//
// ESUtil.c
//
// A utility library for OpenGL ES. This library provides a
// basic common framework for the example applications in the
// OpenGL ES 3.0 Programming Guide.
//
///
// Includes
//
#include <string.h>
#include "Transform.h"
#define PI 3.1415926535897932384626433832795f
void esScale ( GLfloat result[][4], GLfloat sx, GLfloat sy, GLfloat sz )
{
result[0][0] *= sx;
result[0][1] *= sx;
result[0][2] *= sx;
result[0][3] *= sx;
result[1][0] *= sy;
result[1][1] *= sy;
result[1][2] *= sy;
result[1][3] *= sy;
result[2][0] *= sz;
result[2][1] *= sz;
result[2][2] *= sz;
result[2][3] *= sz;
}
void
esTranslate ( GLfloat result[][4], GLfloat tx, GLfloat ty, GLfloat tz )
{
result[3][0] += ( result[0][0] * tx + result[1][0] * ty + result[2][0] * tz );
result[3][1] += ( result[0][1] * tx + result[1][1] * ty + result[2][1] * tz );
result[3][2] += ( result[0][2] * tx + result[1][2] * ty + result[2][2] * tz );
result[3][3] += ( result[0][3] * tx + result[1][3] * ty + result[2][3] * tz );
}
void
esRotate ( GLfloat result[][4], GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
{
GLfloat sinAngle, cosAngle;
GLfloat mag = sqrtf ( x * x + y * y + z * z );
sinAngle = sinf ( angle * PI / 180.0f );
cosAngle = cosf ( angle * PI / 180.0f );
if ( mag > 0.0f )
{
GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs;
GLfloat oneMinusCos;
GLfloat rotMat[4][4];
x /= mag;
y /= mag;
z /= mag;
xx = x * x;
yy = y * y;
zz = z * z;
xy = x * y;
yz = y * z;
zx = z * x;
xs = x * sinAngle;
ys = y * sinAngle;
zs = z * sinAngle;
oneMinusCos = 1.0f - cosAngle;
rotMat[0][0] = ( oneMinusCos * xx ) + cosAngle;
rotMat[0][1] = ( oneMinusCos * xy ) - zs;
rotMat[0][2] = ( oneMinusCos * zx ) + ys;
rotMat[0][3] = 0.0F;
rotMat[1][0] = ( oneMinusCos * xy ) + zs;
rotMat[1][1] = ( oneMinusCos * yy ) + cosAngle;
rotMat[1][2] = ( oneMinusCos * yz ) - xs;
rotMat[1][3] = 0.0F;
rotMat[2][0] = ( oneMinusCos * zx ) - ys;
rotMat[2][1] = ( oneMinusCos * yz ) + xs;
rotMat[2][2] = ( oneMinusCos * zz ) + cosAngle;
rotMat[2][3] = 0.0F;
rotMat[3][0] = 0.0F;
rotMat[3][1] = 0.0F;
rotMat[3][2] = 0.0F;
rotMat[3][3] = 1.0F;
esMatrixMultiply (result, rotMat, result );
}
}
void
esFrustum ( GLfloat result[][4], float left, float right, float bottom, float top, float nearZ, float farZ )
{
float deltaX = right - left;
float deltaY = top - bottom;
float deltaZ = farZ - nearZ;
GLfloat frust[4][4];
if ( ( nearZ <= 0.0f ) || ( farZ <= 0.0f ) ||
( deltaX <= 0.0f ) || ( deltaY <= 0.0f ) || ( deltaZ <= 0.0f ) )
{
return;
}
frust[0][0] = 2.0f * nearZ / deltaX;
frust[0][1] = frust[0][2] = frust[0][3] = 0.0f;
frust[1][1] = 2.0f * nearZ / deltaY;
frust[1][0] = frust[1][2] = frust[1][3] = 0.0f;
frust[2][0] = ( right + left ) / deltaX;
frust[2][1] = ( top + bottom ) / deltaY;
frust[2][2] = - ( nearZ + farZ ) / deltaZ;
frust[2][3] = -1.0f;
frust[3][2] = -2.0f * nearZ * farZ / deltaZ;
frust[3][0] = frust[3][1] = frust[3][3] = 0.0f;
esMatrixMultiply ( result, frust, result );
}
void
esPerspective ( GLfloat result[][4], float fovy, float aspect, float nearZ, float farZ )
{
GLfloat frustumW, frustumH;
frustumH = tanf ( fovy / 360.0f * PI ) * nearZ;
frustumW = frustumH * aspect;
esFrustum ( result, -frustumW, frustumW, -frustumH, frustumH, nearZ, farZ );
}
void
esOrtho ( GLfloat result[][4], float left, float right, float bottom, float top, float nearZ, float farZ )
{
float deltaX = right - left;
float deltaY = top - bottom;
float deltaZ = farZ - nearZ;
GLfloat ortho[4][4];
if ( ( deltaX == 0.0f ) || ( deltaY == 0.0f ) || ( deltaZ == 0.0f ) )
{
return;
}
esMatrixLoadIdentity ( ortho );
ortho[0][0] = 2.0f / deltaX;
ortho[3][0] = - ( right + left ) / deltaX;
ortho[1][1] = 2.0f / deltaY;
ortho[3][1] = - ( top + bottom ) / deltaY;
ortho[2][2] = -2.0f / deltaZ;
ortho[3][2] = - ( nearZ + farZ ) / deltaZ;
esMatrixMultiply ( result, ortho, result );
}
void
esMatrixLookAt ( GLfloat result[][4],
float posX, float posY, float posZ,
float lookAtX, float lookAtY, float lookAtZ,
float upX, float upY, float upZ )
{
float axisX[3], axisY[3], axisZ[3];
float length;
// axisZ = lookAt - pos
axisZ[0] = lookAtX - posX;
axisZ[1] = lookAtY - posY;
axisZ[2] = lookAtZ - posZ;
// normalize axisZ
length = sqrtf ( axisZ[0] * axisZ[0] + axisZ[1] * axisZ[1] + axisZ[2] * axisZ[2] );
if ( length != 0.0f )
{
axisZ[0] /= length;
axisZ[1] /= length;
axisZ[2] /= length;
}
// axisX = up X axisZ
axisX[0] = upY * axisZ[2] - upZ * axisZ[1];
axisX[1] = upZ * axisZ[0] - upX * axisZ[2];
axisX[2] = upX * axisZ[1] - upY * axisZ[0];
// normalize axisX
length = sqrtf ( axisX[0] * axisX[0] + axisX[1] * axisX[1] + axisX[2] * axisX[2] );
if ( length != 0.0f )
{
axisX[0] /= length;
axisX[1] /= length;
axisX[2] /= length;
}
// axisY = axisZ x axisX
axisY[0] = axisZ[1] * axisX[2] - axisZ[2] * axisX[1];
axisY[1] = axisZ[2] * axisX[0] - axisZ[0] * axisX[2];
axisY[2] = axisZ[0] * axisX[1] - axisZ[1] * axisX[0];
// normalize axisY
length = sqrtf ( axisY[0] * axisY[0] + axisY[1] * axisY[1] + axisY[2] * axisY[2] );
if ( length != 0.0f )
{
axisY[0] /= length;
axisY[1] /= length;
axisY[2] /= length;
}
memset ( result, 0x0, sizeof ( GLfloat ) * 16 );
result[0][0] = -axisX[0];
result[0][1] = axisY[0];
result[0][2] = -axisZ[0];
result[1][0] = -axisX[1];
result[1][1] = axisY[1];
result[1][2] = -axisZ[1];
result[2][0] = -axisX[2];
result[2][1] = axisY[2];
result[2][2] = -axisZ[2];
// translate (-posX, -posY, -posZ)
result[3][0] = axisX[0] * posX + axisX[1] * posY + axisX[2] * posZ;
result[3][1] = -axisY[0] * posX - axisY[1] * posY - axisY[2] * posZ;
result[3][2] = axisZ[0] * posX + axisZ[1] * posY + axisZ[2] * posZ;
result[3][3] = 1.0f;
}
void
esMatrixMultiply ( GLfloat result[][4], GLfloat srcA[][4], GLfloat srcB[][4] )
{
GLfloat tmp[4][4];
int i;
for ( i = 0; i < 4; i++ )
{
tmp[i][0] = ( srcA[i][0] * srcB[0][0] ) +
( srcA[i][1] * srcB[1][0] ) +
( srcA[i][2] * srcB[2][0] ) +
( srcA[i][3] * srcB[3][0] ) ;
tmp[i][1] = ( srcA[i][0] * srcB[0][1] ) +
( srcA[i][1] * srcB[1][1] ) +
( srcA[i][2] * srcB[2][1] ) +
( srcA[i][3] * srcB[3][1] ) ;
tmp[i][2] = ( srcA[i][0] * srcB[0][2] ) +
( srcA[i][1] * srcB[1][2] ) +
( srcA[i][2] * srcB[2][2] ) +
( srcA[i][3] * srcB[3][2] ) ;
tmp[i][3] = ( srcA[i][0] * srcB[0][3] ) +
( srcA[i][1] * srcB[1][3] ) +
( srcA[i][2] * srcB[2][3] ) +
( srcA[i][3] * srcB[3][3] ) ;
}
memcpy ( result, tmp, sizeof ( GLfloat ) * 16 );
}
void
esMatrixLoadIdentity ( GLfloat result[][4] )
{
memset ( result, 0x0, sizeof ( GLfloat ) * 16 );
result[0][0] = 1.0f;
result[1][1] = 1.0f;
result[2][2] = 1.0f;
result[3][3] = 1.0f;
} | [
"handa7289@gmail.com"
] | handa7289@gmail.com |
0a2144a4b5185fc74282c45fdd3654346b991844 | 99e44f844d78de330391f2b17bbf2e293bf24b1b | /pytorch/caffe2/operators/dataset_ops.cc | 78fe0032da04247742ec26870cb0728f480375a9 | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | raghavnauhria/whatmt | be10d57bcd6134dd5714d0c4058abd56a1b35a13 | c20483a437c82936cb0fb8080925e37b9c4bba87 | refs/heads/master | 2022-12-04T05:39:24.601698 | 2019-07-22T09:43:30 | 2019-07-22T09:43:30 | 193,026,689 | 0 | 1 | MIT | 2022-11-28T17:50:19 | 2019-06-21T03:48:20 | C++ | UTF-8 | C++ | false | false | 50,195 | cc | #include "caffe2/operators/dataset_ops.h"
#include <memory>
#include <mutex>
#include <string>
#include <vector>
#include "caffe2/core/blob_serialization.h"
#include "caffe2/core/operator.h"
#include "caffe2/core/tensor.h"
#include "caffe2/utils/string_utils.h"
namespace caffe2 {
CAFFE_KNOWN_TYPE(std::unique_ptr<dataset_ops::TreeCursor>);
CAFFE_KNOWN_TYPE(dataset_ops::TensorVectorPtr);
CAFFE_KNOWN_TYPE(dataset_ops::SharedTensorVectorPtr);
namespace dataset_ops {
namespace {
const char kDatasetFieldSeparator = ':';
const char* kDatasetLengthField = "lengths";
// how much percent to grow the dataset when needed
const int kDatasetGrowthPct = 40;
} // namespace
TreeIterator::TreeIterator(const std::vector<std::string>& fields) {
// populate field vector and split field names
fields_.resize(fields.size());
std::vector<std::vector<std::string>> nameParts(fields_.size());
for (size_t i = 0; i < fields.size(); ++i) {
auto& field = fields_.at(i);
field.name = fields[i];
field.id = i;
field.lengthFieldId = -1;
nameParts.at(i) = split(kDatasetFieldSeparator, field.name);
}
// populate lengthFields
for (const auto& field : fields_) {
const auto& parts = nameParts.at(field.id);
if (!parts.empty() && parts.back() == kDatasetLengthField) {
lengthFieldIds_.push_back(field.id);
}
}
// find length-field with maximum prefix matching for each field
for (auto& field : fields_) {
// by default, we are matching against the root domain
size_t maxMatchLevel = 1;
int maxMatchLengthFieldId = -1;
for (int j = 0; j < numLengthFields(); ++j) {
const auto& lenField = lengthField(j);
// a length field can't have itself as its length field
if (field.id == lenField.id) {
continue;
}
auto lf = nameParts.at(lenField.id);
auto lfEnd = lf.end() - 1;
// check whether this lengthField is a prefix for this field name
if (std::mismatch(lf.begin(), lfEnd, nameParts.at(field.id).begin())
.first != lfEnd) {
continue;
}
if (lf.size() > maxMatchLevel) {
maxMatchLevel = lf.size();
maxMatchLengthFieldId = j;
}
}
field.lengthFieldId = maxMatchLengthFieldId;
}
// check that fields are topologically sorted
// (no length field depends on a length defined afterwards)
for (const auto& field : fields_) {
const auto* lengthField = lengthFieldFor(field);
CAFFE_ENFORCE(
(lengthField == nullptr) || (lengthField->id < field.id),
"Error: Field ",
field.id,
" (",
field.name,
") ",
"depends on a field defined afterwards: ",
lengthField->id,
" (",
lengthField->name,
").");
}
}
void TreeIterator::advance(
const std::vector<const TLength*>& lengths,
std::vector<TOffset>& offsets,
std::vector<TOffset>& sizes,
std::vector<TOffset>& limits,
TOffset num) {
std::vector<TOffset> newOffsets;
CAFFE_ENFORCE_EQ(lengths.size(), numLengthFields());
CAFFE_ENFORCE_EQ(offsets.size(), numOffsetFields());
sizes.resize(offsets.size());
newOffsets.resize(offsets.size());
// first index, top level
{
auto limit = limits[0];
auto offset = offsets[0];
CAFFE_ENFORCE(limit >= offset, "Tried to advance past end of cursor.");
TOffset total = std::min(limit - offset, num);
sizes[0] = total;
newOffsets[0] = offset + total;
}
// child indices
for (int j = 1; j < numOffsetFields(); ++j) {
TOffset total = 0;
int parentOffsetId = offsetFieldIdFor(lengthField(j - 1));
const TLength* length = lengths[j - 1] + offsets[parentOffsetId];
for (int k = 0; k < sizes[parentOffsetId]; ++k) {
total += *(length++);
}
auto offset = offsets[j];
CAFFE_ENFORCE(
offset + total <= limits[j],
"Inconsistent field length: ",
"tried to advance past the end of field ",
j);
sizes[j] = total;
newOffsets[j] = offset + total;
}
offsets = newOffsets;
}
TreeWalker::TreeWalker(const vector<const Blob*>& inputs, TreeCursor& cursor)
: inputs_(inputs), cursor_(cursor), sizes_(cursor.it.numOffsetFields()) {
CAFFE_ENFORCE_EQ(inputs.size(), cursor.it.fields().size());
if (cursor.offsets.empty()) {
cursor.offsets.assign(cursor.it.numOffsetFields(), 0);
}
for (int fieldId = 0; fieldId < cursor_.it.fields().size(); ++fieldId) {
fields_.emplace_back(*this, fieldId);
}
gatherLengthData();
gatherSizeLimits();
// The invariant we hold is that we are always one step ahead
advance();
}
void TreeWalker::advance() {
prevOffsets_ = cursor_.offsets;
cursor_.it.advance(lengths_, cursor_.offsets, sizes_, limits_, 1);
}
std::vector<int64_t> TreeWalker::fieldDim(int fieldId) const {
auto tensorDim = input(fieldId).sizes().vec();
tensorDim[0] = sizes_[lengthIdx(fieldId)];
return tensorDim;
}
void* TreeWalker::fieldPtr(int fieldId) const {
auto& in = input(fieldId);
return (char*)in.raw_data() +
offset(fieldId) * in.size_from_dim(1) * in.dtype().itemsize();
}
void TreeWalker::gatherLengthData() {
static const TLength lenZero = 0;
lengths_.resize(cursor_.it.numLengthFields());
for (int i = 0; i < lengths_.size(); ++i) {
auto& in = input(cursor_.it.lengthField(i).id);
if (in.numel() > 0) {
lengths_[i] = in.data<int>();
} else {
lengths_[i] = &lenZero;
}
}
}
void TreeWalker::gatherSizeLimits() {
limits_.assign(sizes_.size(), std::numeric_limits<TOffset>::max());
for (auto fieldId = 0; fieldId < cursor_.it.fields().size(); ++fieldId) {
auto lengthFieldIdx = lengthIdx(fieldId);
limits_[lengthFieldIdx] =
std::min(limits_[lengthFieldIdx], (TOffset)input(fieldId).sizes()[0]);
}
}
namespace {
class CreateTreeCursorOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit CreateTreeCursorOp(Args&&... args)
: Operator(std::forward<Args>(args)...),
fields_(OperatorBase::GetRepeatedArgument<std::string>("fields")) {}
bool RunOnDevice() override {
*OperatorBase::Output<std::unique_ptr<TreeCursor>>(0) =
std::unique_ptr<TreeCursor>(new TreeCursor(TreeIterator(fields_)));
return true;
}
private:
std::vector<std::string> fields_;
};
class GetCursorOffsetOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit GetCursorOffsetOp(Args&&... args)
: Operator(std::forward<Args>(args)...) {}
bool RunOnDevice() override {
auto& cursor = OperatorBase::Input<std::unique_ptr<TreeCursor>>(0);
Output(0)->Resize(cursor->offsets.size());
auto* output = Output(0)->template mutable_data<int>();
for (size_t i = 0; i < cursor->offsets.size(); ++i) {
output[i] = cursor->offsets[i];
}
return true;
}
};
class ResetCursorOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit ResetCursorOp(Args&&... args)
: Operator(std::forward<Args>(args)...) {}
bool RunOnDevice() override {
auto& cursor = OperatorBase::Input<std::unique_ptr<TreeCursor>>(0);
std::lock_guard<std::mutex> lock(cursor->mutex_);
cursor->offsets.clear();
return true;
}
};
class CheckDatasetConsistencyOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit CheckDatasetConsistencyOp(Args&&... args)
: Operator(std::forward<Args>(args)...),
iterator_(OperatorBase::GetRepeatedArgument<std::string>("fields")) {}
bool RunOnDevice() override {
std::vector<const TLength*> lengths;
std::vector<TOffset> limits;
std::vector<TOffset> sizes;
std::vector<TOffset> offsets;
CAFFE_ENFORCE(
InputSize() == iterator_.fields().size(),
"Invalid number of fields. Expected ",
iterator_.fields().size(),
", got ",
InputSize());
sizes.resize(iterator_.numOffsetFields());
// gather length data
lengths.resize(iterator_.numLengthFields());
for (size_t i = 0; i < lengths.size(); ++i) {
lengths[i] = Input(iterator_.lengthField(i).id).data<TLength>();
}
// gather size limits
limits.assign(sizes.size(), std::numeric_limits<TOffset>::max());
for (size_t i = 0; i < iterator_.fields().size(); ++i) {
int lengthIdx = iterator_.fields()[i].lengthFieldId + 1;
CAFFE_ENFORCE_GT(Input(i).dim(), 0);
TOffset size = (TOffset)Input(i).sizes()[0];
if (limits[lengthIdx] == std::numeric_limits<TOffset>::max()) {
limits[lengthIdx] = size;
} else {
CAFFE_ENFORCE(
limits[lengthIdx] == size,
"Inconsistent sizes for fields belonging to same domain.",
" Field: ",
i,
" (",
iterator_.fields()[i].name,
"); Length field index: ",
lengthIdx,
"); Previous size: ",
limits[lengthIdx],
"; New size: ",
size);
}
}
// advance to the end
offsets.assign(sizes.size(), 0);
iterator_.advance(lengths, offsets, sizes, limits, limits[0]);
for (size_t i = 0; i < limits.size(); ++i) {
CAFFE_ENFORCE(limits[i] == offsets[i]);
}
return true;
}
private:
TreeIterator iterator_;
};
class PackRecordsOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit PackRecordsOp(Args&&... args)
: Operator(std::forward<Args>(args)...),
fields_(OperatorBase::GetRepeatedArgument<std::string>("fields")) {}
bool RunOnDevice() override {
// There should be one input per field
CAFFE_ENFORCE_EQ(InputSize(), fields_.size());
CAFFE_ENFORCE_EQ(OutputSize(), 1);
TreeCursor cursor((TreeIterator(fields_)));
TreeWalker walker(Inputs(), cursor);
Output(0)->Resize(walker.size());
// Output(0)->raw_mutable_data(TypeMeta::Make<SharedTensorVectorPtr>()));
auto* dst = Output(0)->template mutable_data<SharedTensorVectorPtr>();
for (int batchId = 0; batchId < walker.size(); ++batchId) {
dst[batchId] = std::make_shared<std::vector<TensorCPU>>();
dst[batchId]->reserve(walker.fields().size());
for (const auto& field : walker.fields()) {
dst[batchId]->emplace_back(field.dim(), CPU);
auto& tensor = dst[batchId]->back();
context_.CopyItemsSameDevice(
field.meta(),
tensor.numel(),
field.ptr() /* src */,
tensor.raw_mutable_data(field.meta()) /* dst */);
}
walker.advance();
}
return true;
}
private:
std::vector<std::string> fields_;
};
class UnPackRecordsOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit UnPackRecordsOp(Args&&... args)
: Operator(std::forward<Args>(args)...),
fields_(OperatorBase::GetRepeatedArgument<std::string>("fields")) {}
bool RunOnDevice() override {
const auto* inputs = Input(0).template data<SharedTensorVectorPtr>();
const auto numRows = Input(0).numel();
CAFFE_ENFORCE_GE(numRows, 0);
auto numTensors = OutputSize();
// Precomputer the output sizes to avoid resizing
std::vector<std::vector<int64_t>> outputDims(numTensors);
std::vector<const TypeMeta*> metas(numTensors);
CAFFE_ENFORCE(
numRows > 0 || InputSize() > 1,
"Unpacking empty record without shape will leave output blobs in "
"undefined state.");
if (InputSize() == 1) {
getShapeAndMetaFromInput(outputDims, metas);
} else {
getShapeAndMetaFromPrototypeBlobs(outputDims, metas);
}
for (int i = 0; i < numRows; ++i) {
CAFFE_ENFORCE(inputs[i]);
for (int j = 0; j < inputs[i]->size(); ++j) {
const auto& input = inputs[i]->at(j);
// Checks to ensure that dimensions/sizes match
CAFFE_ENFORCE_EQ(outputDims[j].size(), input.dim());
CAFFE_ENFORCE(*metas[j] == input.dtype());
// We look from first dimension, because we concat on the first.
for (int k = 1; k < input.dim(); ++k) {
CAFFE_ENFORCE_EQ(input.sizes()[k], outputDims[j][k]);
}
outputDims[j][0] += input.size(0);
}
}
// Resize to the final output size
std::vector<void*> destinations(numTensors);
for (int i = 0; i < numTensors; ++i) {
Output(i)->Resize(outputDims[i]);
destinations[i] = Output(i)->raw_mutable_data(*metas[i]);
}
for (int i = 0; i < numRows; ++i) {
for (int j = 0; j < numTensors; ++j) {
const auto& input = inputs[i]->at(j);
context_.CopyItemsSameDevice(
*metas[j],
input.numel(),
input.raw_data() /* src */,
destinations[j] /* dst */
);
destinations[j] =
(char*)destinations[j] + input.numel() * input.itemsize();
}
}
return true;
}
private:
void getShapeAndMetaFromInput(
std::vector<std::vector<int64_t>>& outputDims,
std::vector<const TypeMeta*>& metas) {
const auto* inputs = Input(0).template data<SharedTensorVectorPtr>();
const auto& inputZero = inputs[0];
CAFFE_ENFORCE(inputZero);
const auto numTensors = inputZero->size();
CAFFE_ENFORCE_EQ(numTensors, fields_.size());
CAFFE_ENFORCE_EQ(numTensors, OutputSize());
for (int i = 0; i < numTensors; ++i) {
outputDims[i] = inputZero->at(i).sizes().vec();
outputDims[i][0] = 0;
metas[i] = &inputZero->at(i).dtype();
}
}
void getShapeAndMetaFromPrototypeBlobs(
std::vector<std::vector<int64_t>>& outputDims,
std::vector<const TypeMeta*>& metas) {
const auto numTensors = fields_.size();
CAFFE_ENFORCE_EQ(numTensors, InputSize() - 1);
CAFFE_ENFORCE_EQ(numTensors, OutputSize());
for (int i = 0; i < numTensors; ++i) {
const auto& input = Input(i + 1);
outputDims[i] = input.sizes().vec();
outputDims[i][0] = 0;
metas[i] = &input.dtype();
}
}
std::vector<std::string> fields_;
};
class ReadNextBatchOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit ReadNextBatchOp(Args&&... args)
: Operator(std::forward<Args>(args)...),
batchSize_(OperatorBase::GetSingleArgument<int>("batch_size", 1)),
enforceBatchSize_(OperatorBase::GetSingleArgument<bool>(
"enforce_batch_size",
false)) {}
bool RunOnDevice() override {
auto& cursor = OperatorBase::Input<std::unique_ptr<TreeCursor>>(0);
CAFFE_ENFORCE(InputSize() == cursor->it.fields().size() + 1);
std::vector<const TLength*> lengths;
std::vector<TOffset> limits;
std::vector<TOffset> sizes;
std::vector<TOffset> offsets;
TLength lenZero = 0;
sizes.resize(cursor->it.numOffsetFields());
// gather length data
lengths.resize(cursor->it.numLengthFields());
for (int i = 0; i < lengths.size(); ++i) {
auto& a = Input(cursor->it.lengthField(i).id + 1);
if (a.numel() > 0) {
lengths[i] = a.data<int>();
} else {
lengths[i] = &lenZero;
}
}
// gather size limits
limits.assign(sizes.size(), std::numeric_limits<TOffset>::max());
for (int i = 0; i < cursor->it.fields().size(); ++i) {
int lengthFieldIdx = cursor->it.fields()[i].lengthFieldId + 1;
limits[lengthFieldIdx] =
std::min(limits[lengthFieldIdx], (TOffset)Input(i + 1).sizes()[0]);
}
// advance cursor
{
std::lock_guard<std::mutex> lock(cursor->mutex_);
if (cursor->offsets.empty()) {
cursor->offsets.assign(sizes.size(), 0);
}
offsets = cursor->offsets;
cursor->it.advance(lengths, cursor->offsets, sizes, limits, batchSize_);
if (enforceBatchSize_ && sizes[0] < batchSize_) {
// if we enforce batch_size but don't have enough rows left to
// complete a full batch, return empty for all columns.
// This signals end of dataset to the caller.
sizes.assign(sizes.size(), 0);
}
}
// gather data
std::vector<int64_t> outDim;
for (int i = 0; i < cursor->it.fields().size(); ++i) {
auto lengthIdx = cursor->it.fields()[i].lengthFieldId + 1;
auto size = sizes[lengthIdx];
auto offset = offsets[lengthIdx];
auto& in = Input(i + 1);
auto innerSize = in.size_from_dim(1);
outDim = in.sizes().vec();
outDim[0] = size;
auto* out = Output(i);
out->Resize(outDim);
void* src =
(char*)in.raw_data() + offset * innerSize * in.dtype().itemsize();
void* dst = out->raw_mutable_data(in.dtype()); // create the tensor
if (out->numel() == 0) {
continue;
}
context_.CopyItemsSameDevice(in.dtype(), out->numel(), src, dst);
}
return true;
}
int batchSize_;
bool enforceBatchSize_;
};
class ComputeOffsetOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit ComputeOffsetOp(Args&&... args)
: Operator(std::forward<Args>(args)...) {}
bool RunOnDevice() override {
auto& cursor = OperatorBase::Input<std::unique_ptr<TreeCursor>>(0);
CAFFE_ENFORCE(InputSize() == cursor->it.fields().size() + 1);
auto* out = Output(0);
std::vector<const TLength*> lengths;
std::vector<TOffset> limits;
std::vector<TOffset> sizes;
std::vector<TOffset> offsets;
TLength lenZero = 0;
sizes.resize(cursor->it.numOffsetFields());
// gather length data
lengths.resize(cursor->it.numLengthFields());
for (int i = 0; i < lengths.size(); ++i) {
auto& a = Input(cursor->it.lengthField(i).id + 1);
if (a.numel() > 0) {
lengths[i] = a.data<int>();
} else {
lengths[i] = &lenZero;
}
}
// gather size limits
limits.assign(sizes.size(), std::numeric_limits<TOffset>::max());
for (int i = 0; i < cursor->it.fields().size(); ++i) {
int lengthFieldIdx = cursor->it.fields()[i].lengthFieldId + 1;
limits[lengthFieldIdx] =
std::min(limits[lengthFieldIdx], (TOffset)Input(i + 1).sizes()[0]);
}
out->Resize(limits.at(0) + 1, sizes.size());
auto* out_data = out->template mutable_data<int64_t>();
for (int k = 0; k <= limits.at(0); k++) {
// advance cursor
if (cursor->offsets.empty()) {
cursor->offsets.assign(sizes.size(), 0);
}
// write output
std::copy(cursor->offsets.begin(), cursor->offsets.end(), out_data);
out_data += sizes.size();
cursor->it.advance(lengths, cursor->offsets, sizes, limits, 1);
}
cursor->offsets.assign(sizes.size(), 0); // reSet after getting meta info
return true;
}
};
class SortAndShuffleOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit SortAndShuffleOp(Args&&... args)
: Operator(std::forward<Args>(args)...),
sort_by_field_idx_(
OperatorBase::GetSingleArgument<int>("sort_by_field_idx", 1)),
batch_size_(OperatorBase::GetSingleArgument<int>("batch_size", 1)),
shuffle_size_(OperatorBase::GetSingleArgument<int>("shuffle_size", 1)) {
}
bool RunOnDevice() override {
auto& cursor = OperatorBase::Input<std::unique_ptr<TreeCursor>>(0);
CAFFE_ENFORCE(InputSize() == cursor->it.fields().size() + 1);
CAFFE_ENFORCE(-1 <= sort_by_field_idx_);
CAFFE_ENFORCE(cursor->it.fields().size() - sort_by_field_idx_ > 0);
int size;
if (sort_by_field_idx_ != -1) {
size = Input(sort_by_field_idx_ + 1).sizes()[0];
} else {
size = Input(1).sizes()[0];
}
CAFFE_ENFORCE(
batch_size_ > 0 && shuffle_size_ > 0 &&
0 < batch_size_ * shuffle_size_);
// adjust shuffle_size_ if it is too large
if (batch_size_ * shuffle_size_ > size) {
shuffle_size_ = size / batch_size_;
}
int num_batch = size / batch_size_;
auto* out = Output(0);
out->Resize(size);
auto* out_data = out->template mutable_data<int64_t>();
vector<int> shuffle_idx(size);
iota(shuffle_idx.begin(), shuffle_idx.end(), 0);
if (sort_by_field_idx_ != -1) {
auto& sortblob = Input(sort_by_field_idx_ + 1);
auto* sortdata = sortblob.data<int>();
// must sort by a field at the root level
CAFFE_ENFORCE(
cursor->it.fields()[sort_by_field_idx_].lengthFieldId == -1);
sort(shuffle_idx.begin(), shuffle_idx.end(), [&sortdata](int i1, int i2) {
return sortdata[i1] < sortdata[i2];
});
}
if (batch_size_ * shuffle_size_ > 1) {
int offset = 0;
while (offset + batch_size_ * shuffle_size_ < size) {
std::shuffle(
shuffle_idx.begin() + offset,
shuffle_idx.begin() + offset + batch_size_ * shuffle_size_,
std::default_random_engine());
offset += batch_size_ * shuffle_size_;
}
}
vector<int> batch_idx(num_batch);
iota(batch_idx.begin(), batch_idx.end(), 0);
std::shuffle(
batch_idx.begin(), batch_idx.end(), std::default_random_engine());
for (int i = 0; i < num_batch; i++) {
std::copy(
shuffle_idx.begin() + batch_idx[i] * batch_size_,
shuffle_idx.begin() + (batch_idx[i] + 1) * batch_size_,
out_data);
out_data += batch_size_;
}
std::copy(
shuffle_idx.begin() + num_batch * batch_size_,
shuffle_idx.end(),
out_data);
return true;
}
int sort_by_field_idx_;
int batch_size_;
int shuffle_size_;
};
class ReadRandomBatchOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit ReadRandomBatchOp(Args&&... args)
: Operator(std::forward<Args>(args)...),
batchSize_(OperatorBase::GetSingleArgument<int>("batch_size", 1)),
enforceBatchSize_(
OperatorBase::GetSingleArgument<bool>("enforce_batch_size", false)),
loopOver_(OperatorBase::GetSingleArgument<bool>("loop_over", false)) {}
bool RunOnDevice() override {
auto& cursor = OperatorBase::Input<std::unique_ptr<TreeCursor>>(0);
auto& idxblob = Input(1);
auto& offsetsmat = Input(2);
CAFFE_ENFORCE(InputSize() == cursor->it.fields().size() + 3);
auto idxvec = idxblob.template data<int64_t>();
auto offsetdim = offsetsmat.sizes();
// gather data
std::vector<int64_t> outDim;
int64_t idx;
{
std::lock_guard<std::mutex> lock(cursor->mutex_);
cursor->offsets.resize(1);
idx = cursor->offsets.at(0);
// if we want to enforce batch size but we dont have a complete
// batch, skip the last rows.
if (enforceBatchSize_ && idx + batchSize_ > idxblob.numel()) {
idx = idxblob.numel();
}
if (loopOver_ && idx >= idxblob.numel()) {
cursor->offsets.at(0) = 0;
idx = 0;
}
cursor->offsets.at(0) += batchSize_;
}
for (int i = 0; i < cursor->it.fields().size(); ++i) {
auto lengthIdx = cursor->it.fields()[i].lengthFieldId + 1;
auto& in = Input(i + 3);
outDim = in.sizes().vec();
outDim.at(0) = 0;
auto idxbegin = idx;
for (int j = 0; j < batchSize_; ++j) {
if (idx >= idxblob.numel()) {
break;
}
CAFFE_ENFORCE(
(idxvec[idx] + 1) * offsetdim[1] + lengthIdx < offsetsmat.numel(),
"Out of bound when trying to get elem from offsetsmat");
auto offsetptr = offsetsmat.template data<TOffset>() +
idxvec[idx] * offsetdim[1] + lengthIdx;
auto offset = *offsetptr;
auto size = *(offsetptr + offsetdim[1]) - offset;
outDim.at(0) += size; // accumulate over the batch
idx++;
}
idx = idxbegin; // reSet
auto* out = Output(i);
out->Resize(outDim);
if (out->numel() == 0) {
continue;
}
auto dst = static_cast<char*>(out->raw_mutable_data(in.dtype()));
int block_size = in.numel() / in.size(0);
auto block_bytesize = in.size_from_dim(1) * in.dtype().itemsize();
CAFFE_ENFORCE(
block_bytesize == in.nbytes() / in.size(0),
"block_bytesize should be consistent with data dim");
auto src_base = static_cast<const char*>(in.raw_data());
int start = 0;
for (int j = 0; j < batchSize_; ++j) {
if (idx >= idxblob.numel()) {
break;
}
auto offsetptr = offsetsmat.template data<TOffset>() +
idxvec[idx] * offsetdim[1] + lengthIdx;
auto offset = *offsetptr;
auto size = *(offsetptr + offsetdim[1]) - offset;
// copy data
auto src = src_base + offset * block_bytesize;
context_.CopyItemsSameDevice(
in.dtype(), size * block_size, src, dst + start * block_bytesize);
start += size;
idx++;
}
idx = idxbegin; // reSet
}
return true;
}
int batchSize_;
bool enforceBatchSize_;
bool loopOver_;
};
template <class Context>
class AppendOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
template <class... Args>
explicit AppendOp(Args&&... args)
: Operator<Context>(std::forward<Args>(args)...) {}
bool RunOnDevice() override {
auto& a = Input(0);
auto& b = Input(1);
auto* c = Output(0);
CAFFE_ENFORCE(b.dim() >= 1);
if (a.numel() == 0 && a.size(0) == 0) {
c->CopyFrom(b);
return true;
}
CAFFE_ENFORCE(&a == c, "First argument must be in-place.");
CAFFE_ENFORCE(c->dim() == b.dim());
CAFFE_ENFORCE(b.dim() == c->dim());
CAFFE_ENFORCE(a.dtype() == b.dtype());
for (int i = 1; i < a.dim(); ++i) {
CAFFE_ENFORCE(a.sizes()[i] == b.sizes()[i]);
}
auto oldSize = c->numel();
c->Extend(b.sizes()[0], kDatasetGrowthPct);
auto* dst = (char*)c->raw_mutable_data() + oldSize * b.dtype().itemsize();
context_.CopyItemsSameDevice(b.dtype(), b.numel(), b.raw_data(), dst);
return true;
}
};
template <class Context>
class AtomicAppendOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
template <class... Args>
explicit AtomicAppendOp(Args&&... args)
: Operator<Context>(std::forward<Args>(args)...) {}
bool RunOnDevice() override {
auto& mutex = OperatorBase::Input<std::unique_ptr<std::mutex>>(0);
const auto numFields = (InputSize() - 1) / 2;
CAFFE_ENFORCE(OutputSize() == numFields);
std::lock_guard<std::mutex> guard(*mutex);
// 1: checks
for (int i = 0; i < numFields; ++i) {
auto& a = Input(1 + i);
auto& b = Input(1 + i + numFields);
auto* c = Output(i);
CAFFE_ENFORCE(b.dim() >= 1);
if (a.numel() == 0) {
continue;
}
CAFFE_ENFORCE(
(void*)&a == (void*)c, "Appended-to arguments must be in-place.");
CAFFE_ENFORCE(c->dim() == b.dim());
CAFFE_ENFORCE(b.dim() == c->dim());
CAFFE_ENFORCE(a.dtype() == b.dtype());
for (int j = 1; j < a.dim(); ++j) {
CAFFE_ENFORCE(a.sizes()[j] == b.sizes()[j]);
}
}
// 2: copies
for (int i = 0; i < numFields; ++i) {
auto& a = Input(1 + i);
auto& b = Input(1 + i + numFields);
auto* c = Output(i);
if (a.numel() == 0 && a.size(0) == 0) {
c->CopyFrom(b);
continue;
}
auto oldSize = c->numel();
c->Extend(b.sizes()[0], kDatasetGrowthPct);
auto* dst = (char*)c->raw_mutable_data() + oldSize * b.dtype().itemsize();
context_.CopyItemsSameDevice(b.dtype(), b.numel(), b.raw_data(), dst);
}
return true;
}
};
template <class Context>
class CreateTensorVectorOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
using Operator<Context>::Operator;
bool RunOnDevice() override {
auto ptr = make_unique<std::vector<Tensor>>();
*OperatorBase::Output<TensorVectorPtr>(TENSOR_VECTOR) = std::move(ptr);
return true;
}
private:
OUTPUT_TAGS(TENSOR_VECTOR);
};
template <class Context>
class TensorVectorSizeOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
USE_SIMPLE_CTOR_DTOR(TensorVectorSizeOp);
bool RunOnDevice() override {
auto& vector_ptr = OperatorBase::Input<TensorVectorPtr>(TENSOR_VECTOR);
auto* size = Output(SIZE);
size->Resize();
// 32-bit should be enough here
*size->template mutable_data<int32_t>() = vector_ptr->size();
return true;
}
private:
INPUT_TAGS(TENSOR_VECTOR);
OUTPUT_TAGS(SIZE);
};
template <class Context>
class ConcatTensorVectorOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
using Operator<Context>::Operator;
bool RunOnDevice() override {
const TensorVectorPtr& tensorVector =
OperatorBase::Input<TensorVectorPtr>(TENSOR_VECTOR);
auto* tensor = Output(TENSOR);
CAFFE_ENFORCE(!tensorVector->empty());
vector<int64_t> outputDims(tensorVector->at(0).sizes().vec());
CAFFE_ENFORCE(outputDims.size() > 0);
for (int i = 1; i < tensorVector->size(); i++) {
// the tensor shapes are the same except for the first dimension
for (int j = 1; j < tensorVector->at(i).dim(); j++) {
CAFFE_ENFORCE(outputDims[j] == tensorVector->at(i).sizes()[j]);
}
CAFFE_ENFORCE(tensorVector->at(0).dtype() == tensorVector->at(i).dtype());
outputDims[0] += tensorVector->at(i).sizes()[0];
}
tensor->Resize(outputDims);
int64_t offset = 0;
auto* dst = (char*)tensor->raw_mutable_data(tensorVector->at(0).dtype());
for (const auto& t : *tensorVector) {
context_.CopyItemsSameDevice(
t.dtype(), t.numel(), t.raw_data(), dst + offset);
offset += t.nbytes();
}
return true;
}
private:
INPUT_TAGS(TENSOR_VECTOR);
OUTPUT_TAGS(TENSOR);
};
template <class Context>
class CollectTensorOp final : public Operator<Context> {
public:
USE_OPERATOR_CONTEXT_FUNCTIONS;
template <class... Args>
explicit CollectTensorOp(Args&&... args)
: Operator<Context>(std::forward<Args>(args)...),
numToCollect_(
OperatorBase::GetSingleArgument<int>("num_to_collect", -1)),
numVisited_(0) {
CAFFE_ENFORCE(numToCollect_ > 0);
}
bool RunOnDevice() override {
int pos = -1;
if (numVisited_ < numToCollect_) {
// append
pos = numVisited_;
} else {
auto& gen = context_.RandGenerator();
// uniform between [0, numVisited_]
std::uniform_int_distribution<int> uniformDist(0, numVisited_);
pos = uniformDist(gen);
if (pos >= numToCollect_) {
// discard
pos = -1;
}
}
for (int i = 0; i < OutputSize(); ++i) {
// TENSOR_VECTOR_IN is enforced inplace with TENSOR_VECTOR_OUT
TensorVectorPtr& tensorVector = *OperatorBase::Output<TensorVectorPtr>(i);
if (numVisited_ >= numToCollect_) {
CAFFE_ENFORCE(
tensorVector->size() == numToCollect_,
"TensorVecotor size = ",
tensorVector->size(),
" is different from numToCollect = ",
numToCollect_);
}
const auto& tensor = Input(OutputSize() + i);
if (pos < 0) {
// discard
CAFFE_ENFORCE(numVisited_ >= numToCollect_);
} else if (pos >= tensorVector->size()) {
// append
tensorVector->emplace_back();
ReinitializeAndCopyFrom(
&tensorVector->back(),
Context::GetDeviceType(),
tensor); // sync copy
} else {
// replace
tensorVector->at(pos).CopyFrom(tensor); // sync copy
}
}
numVisited_++;
return true;
}
private:
// number of tensors to collect
int numToCollect_;
// number of tensors visited
int numVisited_;
};
class TrimDatasetOp : public Operator<CPUContext> {
public:
template <class... Args>
explicit TrimDatasetOp(Args&&... args)
: Operator(std::forward<Args>(args)...),
iterator_(OperatorBase::GetRepeatedArgument<std::string>("fields")),
multiple_of_(OperatorBase::GetSingleArgument<int>("multiple_of", 1)) {
CAFFE_ENFORCE_GE(multiple_of_, 1);
}
bool RunOnDevice() override {
TreeCursor cursor(iterator_);
TreeWalker walker(Inputs(), cursor);
int trimmedSize = (walker.size() / multiple_of_) * multiple_of_;
if (trimmedSize == walker.size()) {
// we already satisfy the condition
return true;
}
// advance desired number of records
for (int i = 0; i < trimmedSize; ++i) {
walker.advance();
}
// trim each column to the offset
for (int col = 0; col < walker.fields().size(); ++col) {
auto newOuterSize = walker.fields().at(col).offset();
Output(col)->ShrinkTo(newOuterSize);
}
return true;
}
private:
TreeIterator iterator_;
int multiple_of_;
};
REGISTER_CPU_OPERATOR(CreateTreeCursor, CreateTreeCursorOp);
REGISTER_CPU_OPERATOR(ResetCursor, ResetCursorOp);
REGISTER_CPU_OPERATOR(ReadNextBatch, ReadNextBatchOp);
REGISTER_CPU_OPERATOR(GetCursorOffset, GetCursorOffsetOp);
REGISTER_CPU_OPERATOR(ComputeOffset, ComputeOffsetOp);
REGISTER_CPU_OPERATOR(SortAndShuffle, SortAndShuffleOp);
REGISTER_CPU_OPERATOR(ReadRandomBatch, ReadRandomBatchOp);
REGISTER_CPU_OPERATOR(CheckDatasetConsistency, CheckDatasetConsistencyOp);
REGISTER_CPU_OPERATOR(Append, AppendOp<CPUContext>);
REGISTER_CPU_OPERATOR(AtomicAppend, AtomicAppendOp<CPUContext>);
REGISTER_CPU_OPERATOR(CreateTensorVector, CreateTensorVectorOp<CPUContext>);
REGISTER_CPU_OPERATOR(TensorVectorSize, TensorVectorSizeOp<CPUContext>);
REGISTER_CPU_OPERATOR(ConcatTensorVector, ConcatTensorVectorOp<CPUContext>);
REGISTER_CPU_OPERATOR(CollectTensor, CollectTensorOp<CPUContext>);
REGISTER_CPU_OPERATOR(PackRecords, PackRecordsOp);
REGISTER_CPU_OPERATOR(UnPackRecords, UnPackRecordsOp);
REGISTER_CPU_OPERATOR(TrimDataset, TrimDatasetOp);
OPERATOR_SCHEMA(CreateTreeCursor)
.NumInputs(0)
.NumOutputs(1)
.SetDoc(R"DOC(
Creates a cursor to iterate through a list of tensors, where some of those
tensors contains the lengths in a nested schema. The schema is determined by
the `fields` arguments.
For example, to represent the following schema:
Struct(
a=Int(),
b=List(List(Int),
c=List(
Struct(
c1=String,
c2=List(Int),
),
),
)
the field list will be:
[
"a",
"b:lengths",
"b:values:lengths",
"b:values:values",
"c:lengths",
"c:c1",
"c:c2:lengths",
"c:c2:values",
]
And for the following instance of the struct:
Struct(
a=3,
b=[[4, 5], [6, 7, 8], [], [9]],
c=[
Struct(c1='alex', c2=[10, 11]),
Struct(c1='bob', c2=[12]),
],
)
The values of the fields will be:
{
"a": [3],
"b:lengths": [4],
"b:values:lengths": [2, 3, 0, 1],
"b:values:values": [4, 5, 6, 7, 8, 9],
"c:lengths": [2],
"c:c1": ["alex", "bob"],
"c:c2:lengths": [2, 1],
"c:c2:values", [10, 11, 12],
}
In general, every field name in the format "{prefix}:lengths" defines a domain
"{prefix}", and every subsequent field in the format "{prefix}:{field}" will
be in that domain, and the length of the domain is provided for each entry of
the parent domain. In the example, "b:lengths" defines a domain of length 4, so
every field under domain "b" will have 4 entries.
The "lengths" field for a given domain must appear before any reference to
that domain.
Returns a pointer to an instance of the Cursor, which keeps the current offset
on each of the domains defined by `fields`. Cursor also ensures thread-safety
such that ReadNextBatch and ResetCursor can be used safely in parallel.
A cursor does not contain data per se, so calls to ReadNextBatch actually need
to pass a list of blobs containing the data to read for each one of the fields.
)DOC")
.Output(0, "cursor", "A blob pointing to an instance of a new TreeCursor.")
.Arg(
"fields",
"A list of strings each one representing a field of the dataset.");
OPERATOR_SCHEMA(ResetCursor)
.NumInputs(1)
.NumOutputs(0)
.SetDoc(R"DOC(
Resets the offsets for the given TreeCursor. This operation is thread safe.
)DOC")
.Input(0, "cursor", "A blob containing a pointer to the cursor.");
OPERATOR_SCHEMA(ReadNextBatch)
.NumInputs(1, INT_MAX)
.NumOutputs(1, INT_MAX)
.SetDoc(R"DOC(
Read the next batch of examples out of the given cursor and data blobs.
Input(0) is a blob pointing to a TreeCursor, and
[Input(1),... Input(num_fields)] a list of tensors containing the data for
each field of the dataset.
ReadNextBatch is thread safe.
)DOC")
.Input(0, "cursor", "A blob containing a pointer to the cursor.")
.Input(1, "dataset_field_0", "First dataset field")
.Output(0, "field_0", "Tensor containing the next batch for field 0.")
.Arg("batch_size", "Number of top-level entries to read.");
OPERATOR_SCHEMA(GetCursorOffset)
.NumInputs(1)
.NumOutputs(1)
.SetDoc("Get the current offset in the cursor.")
.Input(0, "cursor", "A blob containing a pointer to the cursor.")
.Output(0, "offsets", "Tensor containing the offsets for the cursor.");
OPERATOR_SCHEMA(ComputeOffset)
.NumInputs(1, INT_MAX)
.NumOutputs(1)
.SetDoc(R"DOC(
Compute the offsets matrix given cursor and data blobs. Need to be ran at
beginning or after reseting cursor
Input(0) is a blob pointing to a TreeCursor, and
[Input(1),... Input(num_fields)] a list of tensors containing the data for
each field of the dataset.
ComputeOffset is thread safe.
)DOC")
.Input(0, "cursor", "A blob containing a pointer to the cursor.")
.Input(1, "dataset_field_0", "First dataset field")
.Output(0, "field_0", "Tensor containing offset info for this chunk.");
OPERATOR_SCHEMA(SortAndShuffle)
.NumInputs(1, INT_MAX)
.NumOutputs(1)
.SetDoc(R"DOC(
Compute the sorted indices given a field index to sort by and break the sorted
indices into chunks of shuffle_size * batch_size and shuffle each chunk,
finally we shuffle between batches. If sort_by_field_idx is -1 we skip sort.
For example, we have data sorted as
1,2,3,4,5,6,7,8,9,10,11,12
and batchSize = 2 and shuffleSize = 3, when we shuffle we get:
[3,1,4,6,5,2] [12,10,11,8,9,7]
After this we will shuffle among different batches with size 2
[3,1],[4,6],[5,2],[12,10],[11,8],[9,7]
We may end up with something like
[9,7],[5,2],[12,10],[4,6],[3,1],[11,8]
Input(0) is a blob pointing to a TreeCursor, and
[Input(1),... Input(num_fields)] a list of tensors containing the data for
each field of the dataset.
SortAndShuffle is thread safe.
)DOC")
.Input(0, "cursor", "A blob containing a pointer to the cursor.")
.Input(1, "dataset_field_0", "First dataset field")
.Output(0, "indices", "Tensor containing sorted indices.");
OPERATOR_SCHEMA(ReadRandomBatch)
.NumInputs(1, INT_MAX)
.NumOutputs(1, INT_MAX)
.SetDoc(R"DOC(
Read the next batch of examples out of the given cursor,
idx blob, offset matrix and data blobs.
Input(0) is a blob pointing to a TreeCursor,
Input(1) is a blob pointing to the shuffled idx
Input(2) is a blob pointing to the offset matrix and
[Input(3),... Input(num_fields)] a list of tensors containing the data for
each field of the dataset.
ReadRandomBatch is thread safe.
)DOC")
.Input(0, "cursor", "A blob containing a pointer to the cursor.")
.Input(1, "idx", "idx with a shuffled order.")
.Input(2, "offsetsmat", "offset matrix containing length offset info.")
.Input(3, "dataset_field_0", "First dataset field")
.Output(0, "field_0", "Tensor containing the next batch for field 0.")
.Arg("batch_size", "Number of top-level entries to read.")
.Arg("loop_over", "(bool) Repeat the dataset indefinitely");
OPERATOR_SCHEMA(CheckDatasetConsistency)
.NumInputs(1, INT_MAX)
.NumOutputs(0)
.SetDoc(R"DOC(
Checks that the given data fields represents a consistent dataset under
the schema specified by the `fields` argument. Operator fails if the fields
are not consistent. If data is consistent, each field's data can be safely
appended to an existing dataset, keeping it consistent.
)DOC")
.Input(0, "field_0", "Data for field 0.")
.Arg(
"fields",
"List of strings representing the string names in the format"
"specified in the doc for CreateTreeCursor.");
OPERATOR_SCHEMA(Append)
.NumInputs(2)
.NumOutputs(1)
.EnforceInplace({{0, 0}})
.SetDoc(R"DOC(
Append input `B` to the end of input `A`.
- It is required that this operation run in-place, meaning that the input `A` blob must match the output blob.
- All except the outer-most dimension must be the same between `A` and `B`.
- Input `A` may have to be re-allocated in order for accommodate to the new size. Currently, an exponential growth ratio is used in order to ensure amortized constant time complexity.
Github Links:
- https://github.com/pytorch/pytorch/blob/master/caffe2/operators/dataset_ops.cc
<details>
<summary> <b>Example</b> </summary>
**Code**
```
workspace.ResetWorkspace()
op = core.CreateOperator(
"Append",
["A", "B"],
["A"],
)
workspace.FeedBlob("A", np.random.randint(10, size=(1,3,3)))
workspace.FeedBlob("B", np.random.randint(10, size=(2,3,3)))
print("A:", workspace.FetchBlob("A"))
print("B:", workspace.FetchBlob("B"))
workspace.RunOperatorOnce(op)
print("A:", workspace.FetchBlob("A"))
```
**Result**
```
A:
[[[3 8 7]
[1 6 6]
[5 0 6]]]
B:
[[[4 3 1]
[7 9 6]
[9 4 5]]
[[7 7 4]
[9 8 7]
[1 6 6]]]
A:
[[[3 8 7]
[1 6 6]
[5 0 6]]
[[4 3 1]
[7 9 6]
[9 4 5]]
[[7 7 4]
[9 8 7]
[1 6 6]]]
```
</details>
)DOC")
.Input(0, "A", "(*Tensor*): base input tensor of shape $(N, d_1, d_2, ..., d_n)$")
.Input(1, "B", "(*Tensor*): second input tensor of shape $(M, d_1, d_2, ..., d_n)$ to be appended to the base")
.Output(0, "A", "(*Tensor*): output tensor of shape $(N+M, d_1, d_2, ..., d_n)$");
OPERATOR_SCHEMA(AtomicAppend)
.NumInputs(3, INT_MAX)
.NumOutputs(1, INT_MAX)
.AllowInplace([](int in, int out) { return in == out + 1; });
OPERATOR_SCHEMA(CreateTensorVector)
.NumInputs(0)
.NumOutputs(1)
.SetDoc("Create a std::unique_ptr<std::vector<Tensor> >");
OPERATOR_SCHEMA(TensorVectorSize)
.NumInputs(1)
.NumOutputs(1)
.SetDoc("Get the size of the input vector")
.Input(0, "tensor vector", "std::unique_ptr<std::vector<Tensor> >")
.Output(0, "size", "int32_t size");
OPERATOR_SCHEMA(ConcatTensorVector)
.NumInputs(1)
.NumOutputs(1)
.SetDoc(R"DOC(
Concat Tensors in the std::unique_ptr<std::vector<Tensor> >
along the first dimension.
)DOC")
.Input(0, "vector of Tensor", "std::unique_ptr<std::vector<Tensor> >")
.Output(0, "tensor", "tensor after concatenating");
OPERATOR_SCHEMA(CollectTensor)
.NumInputs([](int n) { return n > 0 && n % 2 == 0; })
.NumOutputs(1, INT_MAX)
.NumInputsOutputs([](int in, int out) { return in == out * 2; })
.EnforceInplace([](int in, int out) { return in == out; })
.SetDoc(R"DOC(
Collect tensor into tensor vector by reservoir sampling,
argument num_to_collect indicates the max number of tensors that will be
collected. The first half of the inputs are tensor vectors, which are also the
outputs. The second half of the inputs are the tensors to be collected into each
vector (in the same order). The input tensors are collected in all-or-none
manner. If they are collected, they will be placed at the same index in the
output vectors.
)DOC")
.Arg("num_to_collect", "The max number of tensors to collect");
OPERATOR_SCHEMA(PackRecords)
.NumInputs(1, INT_MAX)
.NumOutputs(1)
.SetDoc(R"DOC(
Given a dataset under a schema specified by the `fields` argument will pack all
the input tensors into one, where each tensor element represents a row of data
(batch of size 1). This format allows easier use with the rest of Caffe2
operators.
)DOC")
.Arg(
"fields",
"List of strings representing the string names in the format"
"specified in the doc for CreateTreeCursor.")
.Output(
0,
"tensor",
"One dimensional tensor having a complex type of SharedTensorVectorPtr."
" In order to reverse it back to the original input it has to be "
"inserted into UnPackRecordsOp.");
OPERATOR_SCHEMA(TrimDataset)
.NumInputs(1, INT_MAX)
.NumOutputs(1, INT_MAX)
.SetDoc(R"DOC(
Trim the given dataset inplace, given the dataset blobs and the field specs.
Trimming happens such that the dataset will contain the largest possible number
of records that is a multiple of the 'multiple_of' argument.
)DOC")
.EnforceInplace([](int input, int output) { return input == output; })
.Arg(
"fields",
"List of strings representing the string names in the format"
"specified in the doc for CreateTreeCursor.");
OPERATOR_SCHEMA(UnPackRecords)
.NumInputs(1, INT_MAX)
.NumOutputs(1, INT_MAX)
.SetDoc(R"DOC(
Given a packed dataset (packed by the PackRecordsOp) and the `fields` argument
describing the datasets schema returns the original dataset format. Number of
returned tensors is equal to the number of fields in the `fields` argument.
The first input is the packed tensor to be unpacked. Optionally, you can provide
prototype tensors to give the expected shapes of the output tensors. This is
helpful when you expected to unpack empty tensor, e.g., output of a sampling
process.
)DOC")
.Arg(
"fields",
"List of strings representing the string names in the format"
"specified in the doc for CreateTreeCursor.")
.Input(0, "packed_tensor", "The tensor to be unpacked");
SHOULD_NOT_DO_GRADIENT(CreateTreeCursor);
SHOULD_NOT_DO_GRADIENT(ResetCursor);
SHOULD_NOT_DO_GRADIENT(ReadNextBatch);
SHOULD_NOT_DO_GRADIENT(ComputeOffset);
SHOULD_NOT_DO_GRADIENT(ReadRandomBatch);
SHOULD_NOT_DO_GRADIENT(CheckDatasetConsistency);
SHOULD_NOT_DO_GRADIENT(Append);
SHOULD_NOT_DO_GRADIENT(AtomicAppend);
SHOULD_NOT_DO_GRADIENT(CreateTensorVector);
SHOULD_NOT_DO_GRADIENT(TensorVectorSize);
SHOULD_NOT_DO_GRADIENT(ConcatTensorVector);
SHOULD_NOT_DO_GRADIENT(CollectTensor);
SHOULD_NOT_DO_GRADIENT(UnPackRecords);
SHOULD_NOT_DO_GRADIENT(PackRecords);
class TreeCursorSerializer : public BlobSerializerBase {
public:
TreeCursorSerializer() {}
~TreeCursorSerializer() override {}
void Serialize(
const void* pointer,
TypeMeta typeMeta,
const string& name,
SerializationAcceptor acceptor) override {
CAFFE_ENFORCE(typeMeta.Match<std::unique_ptr<TreeCursor>>());
const auto& cursor =
*static_cast<const std::unique_ptr<TreeCursor>*>(pointer);
BlobProto blob_proto;
// serialize offsets as a tensor
if (cursor->offsets.size() > 0) {
Blob offsets_blob;
auto* offsets = BlobGetMutableTensor(&offsets_blob, CPU);
offsets->Resize(cursor->offsets.size());
std::copy(
cursor->offsets.begin(),
cursor->offsets.end(),
offsets->template mutable_data<TOffset>());
TensorSerializer ser;
ser.Serialize(
*offsets, name, blob_proto.mutable_tensor(), 0, offsets->numel());
}
blob_proto.set_name(name);
blob_proto.set_type("std::unique_ptr<TreeCursor>");
// serialize field names in the content
std::ostringstream os;
for (const auto& field : cursor->it.fields()) {
os << field.name << " ";
}
blob_proto.set_content(os.str());
acceptor(name, SerializeBlobProtoAsString_EnforceCheck(blob_proto));
}
};
class TreeCursorDeserializer : public BlobDeserializerBase {
public:
void Deserialize(const BlobProto& proto, Blob* blob) override {
// Deserialize the field names
std::vector<std::string> fieldNames;
std::istringstream is(proto.content());
std::string field;
while (true) {
is >> field;
if (is.eof()) {
break;
}
fieldNames.push_back(field);
}
TreeIterator it(fieldNames);
auto* base = blob->template GetMutable<std::unique_ptr<TreeCursor>>();
CAFFE_ENFORCE(base != nullptr, "TreeCursor doesn't exist.");
(*base).reset(new TreeCursor(it));
// Deserialize the offset vector when it is not empty. The proto.tensor()
// function will return a TensorProto associated with offset vector. The
// offset vector contains fields of type int64_t, and we verify it is not
// empty before calling the deserializer.
if (proto.tensor().int64_data().size() > 0) {
TensorDeserializer deser;
Blob offset_blob;
deser.Deserialize(proto, &offset_blob);
auto& offsets = offset_blob.template Get<Tensor>();
auto* offsets_ptr = offsets.data<TOffset>();
(*base)->offsets.assign(offsets_ptr, offsets_ptr + offsets.numel());
}
}
};
REGISTER_BLOB_SERIALIZER(
(TypeMeta::Id<std::unique_ptr<TreeCursor>>()),
TreeCursorSerializer);
REGISTER_BLOB_DESERIALIZER(std::unique_ptr<TreeCursor>, TreeCursorDeserializer);
} // namespace
void SharedTensorVectorPtrSerializer::Serialize(
const void* pointer,
TypeMeta typeMeta,
const string& name,
BlobSerializerBase::SerializationAcceptor acceptor) {
/* This is dummy serialize that doesn't save anything. If saving the content
is desired in future use case, you can change this serializer. Note: special
care need to be taken for the parameter initialization of
LastNWindowCollectorOp and ReservoirSamplingOp if this serializer actually
saves the content.
*/
CAFFE_ENFORCE(typeMeta.Match<std::shared_ptr<std::vector<TensorCPU>>>());
BlobProto blob_proto;
blob_proto.set_name(name);
blob_proto.set_type("std::shared_ptr<std::vector<TensorCPU>>");
blob_proto.set_content("");
acceptor(name, SerializeBlobProtoAsString_EnforceCheck(blob_proto));
};
void SharedTensorVectorPtrDeserializer::Deserialize(
const BlobProto& /* unused */,
Blob* blob) {
/* This is dummy deserialize which creates a nullptr
*/
blob->GetMutable<std::shared_ptr<std::vector<TensorCPU>>>();
}
REGISTER_BLOB_SERIALIZER(
(TypeMeta::Id<std::shared_ptr<std::vector<TensorCPU>>>()),
SharedTensorVectorPtrSerializer);
REGISTER_BLOB_DESERIALIZER(
std::shared_ptr<std::vector<TensorCPU>>,
SharedTensorVectorPtrDeserializer);
} // namespace dataset_ops
} // namespace caffe2
| [
"rnauhria@gmail.com"
] | rnauhria@gmail.com |
4534841781d88142aa184985c163cc2c6e41779d | 3ff1fe3888e34cd3576d91319bf0f08ca955940f | /cdwch/src/v20200915/model/DestroyInstanceResponse.cpp | 30694b76df35e21c4f2917a8ee1a1947248c6676 | [
"Apache-2.0"
] | permissive | TencentCloud/tencentcloud-sdk-cpp | 9f5df8220eaaf72f7eaee07b2ede94f89313651f | 42a76b812b81d1b52ec6a217fafc8faa135e06ca | refs/heads/master | 2023-08-30T03:22:45.269556 | 2023-08-30T00:45:39 | 2023-08-30T00:45:39 | 188,991,963 | 55 | 37 | Apache-2.0 | 2023-08-17T03:13:20 | 2019-05-28T08:56:08 | C++ | UTF-8 | C++ | false | false | 5,584 | cpp | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tencentcloud/cdwch/v20200915/model/DestroyInstanceResponse.h>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Cdwch::V20200915::Model;
using namespace std;
DestroyInstanceResponse::DestroyInstanceResponse() :
m_flowIDHasBeenSet(false),
m_instanceIDHasBeenSet(false),
m_errorMsgHasBeenSet(false)
{
}
CoreInternalOutcome DestroyInstanceResponse::Deserialize(const string &payload)
{
rapidjson::Document d;
d.Parse(payload.c_str());
if (d.HasParseError() || !d.IsObject())
{
return CoreInternalOutcome(Core::Error("response not json format"));
}
if (!d.HasMember("Response") || !d["Response"].IsObject())
{
return CoreInternalOutcome(Core::Error("response `Response` is null or not object"));
}
rapidjson::Value &rsp = d["Response"];
if (!rsp.HasMember("RequestId") || !rsp["RequestId"].IsString())
{
return CoreInternalOutcome(Core::Error("response `Response.RequestId` is null or not string"));
}
string requestId(rsp["RequestId"].GetString());
SetRequestId(requestId);
if (rsp.HasMember("Error"))
{
if (!rsp["Error"].IsObject() ||
!rsp["Error"].HasMember("Code") || !rsp["Error"]["Code"].IsString() ||
!rsp["Error"].HasMember("Message") || !rsp["Error"]["Message"].IsString())
{
return CoreInternalOutcome(Core::Error("response `Response.Error` format error").SetRequestId(requestId));
}
string errorCode(rsp["Error"]["Code"].GetString());
string errorMsg(rsp["Error"]["Message"].GetString());
return CoreInternalOutcome(Core::Error(errorCode, errorMsg).SetRequestId(requestId));
}
if (rsp.HasMember("FlowID") && !rsp["FlowID"].IsNull())
{
if (!rsp["FlowID"].IsString())
{
return CoreInternalOutcome(Core::Error("response `FlowID` IsString=false incorrectly").SetRequestId(requestId));
}
m_flowID = string(rsp["FlowID"].GetString());
m_flowIDHasBeenSet = true;
}
if (rsp.HasMember("InstanceID") && !rsp["InstanceID"].IsNull())
{
if (!rsp["InstanceID"].IsString())
{
return CoreInternalOutcome(Core::Error("response `InstanceID` IsString=false incorrectly").SetRequestId(requestId));
}
m_instanceID = string(rsp["InstanceID"].GetString());
m_instanceIDHasBeenSet = true;
}
if (rsp.HasMember("ErrorMsg") && !rsp["ErrorMsg"].IsNull())
{
if (!rsp["ErrorMsg"].IsString())
{
return CoreInternalOutcome(Core::Error("response `ErrorMsg` IsString=false incorrectly").SetRequestId(requestId));
}
m_errorMsg = string(rsp["ErrorMsg"].GetString());
m_errorMsgHasBeenSet = true;
}
return CoreInternalOutcome(true);
}
string DestroyInstanceResponse::ToJsonString() const
{
rapidjson::Document value;
value.SetObject();
rapidjson::Document::AllocatorType& allocator = value.GetAllocator();
if (m_flowIDHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "FlowID";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_flowID.c_str(), allocator).Move(), allocator);
}
if (m_instanceIDHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "InstanceID";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_instanceID.c_str(), allocator).Move(), allocator);
}
if (m_errorMsgHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "ErrorMsg";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_errorMsg.c_str(), allocator).Move(), allocator);
}
rapidjson::Value iKey(rapidjson::kStringType);
string key = "RequestId";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value().SetString(GetRequestId().c_str(), allocator), allocator);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
value.Accept(writer);
return buffer.GetString();
}
string DestroyInstanceResponse::GetFlowID() const
{
return m_flowID;
}
bool DestroyInstanceResponse::FlowIDHasBeenSet() const
{
return m_flowIDHasBeenSet;
}
string DestroyInstanceResponse::GetInstanceID() const
{
return m_instanceID;
}
bool DestroyInstanceResponse::InstanceIDHasBeenSet() const
{
return m_instanceIDHasBeenSet;
}
string DestroyInstanceResponse::GetErrorMsg() const
{
return m_errorMsg;
}
bool DestroyInstanceResponse::ErrorMsgHasBeenSet() const
{
return m_errorMsgHasBeenSet;
}
| [
"tencentcloudapi@tencent.com"
] | tencentcloudapi@tencent.com |
8fc7f5129112f70d52809d71eb3909299a6cc45f | 6be30dd43e374450d7abacbdca638aacb8eb4c97 | /Src/HMCAD/dxflib/dl_writer.h | ba7718271714d73dcb797c202b35c4baeb986e3c | [] | no_license | 15831944/Main | 471bc3e91a22ccd888ca1351e23bf6982a26d4d6 | 971ba925c261a27ea62f4b6708c7b8ac22298195 | refs/heads/master | 2021-10-26T22:32:09.617567 | 2019-04-14T12:21:29 | 2019-04-14T12:21:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,998 | h | /****************************************************************************
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
** Copyright (C) 2001 Robert J. Campbell Jr.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.ribbonsoft.com for further details.
**
** Contact info@ribbonsoft.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DL_WRITER_H
#define DL_WRITER_H
#ifndef _WIN32
#include <strings.h>
#endif
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <iostream>
#include <algorithm>
#include "dl_attributes.h"
#include "dl_codes.h"
_HM_CAD_BEGIN
/**
* Defines interface for writing low level DXF constructs to
* a file. Implementation is defined in derived classes that write
* to binary or ASCII files.
*
* Implements functions that write higher level constructs in terms of
* the low level ones.
*
* @todo Add error checking for string/entry length.
*/
class HM_CAD_EXT DL_Writer {
public:
/**
* @param version DXF version. Defaults to DL_VERSION_2002.
*/
DL_Writer(DL_Codes::version version) : m_handle(0x30) {
this->version = version;
modelSpaceHandle = 0;
paperSpaceHandle = 0;
paperSpace0Handle = 0;
}
virtual ~DL_Writer() {}
;
/** Generic section for section 'name'.
*
* <pre>
* 0
* SECTION
* 2
* name
* </pre>
*/
void section(const char* name) const {
dxfString(0, "SECTION");
dxfString(2, name);
}
/**
* Section HEADER
*
* <pre>
* 0
* SECTION
* 2
* HEADER
* </pre>
*/
void sectionHeader() const {
section("HEADER");
}
/**
* Section TABLES
*
* <pre>
* 0
* SECTION
* 2
* TABLES
* </pre>
*/
void sectionTables() const {
section("TABLES");
}
/**
* Section BLOCKS
*
* <pre>
* 0
* SECTION
* 2
* BLOCKS
* </pre>
*/
void sectionBlocks() const {
section("BLOCKS");
}
/**
* Section ENTITIES
*
* <pre>
* 0
* SECTION
* 2
* ENTITIES
* </pre>
*/
void sectionEntities() const {
section("ENTITIES");
}
/**
* Section CLASSES
*
* <pre>
* 0
* SECTION
* 2
* CLASSES
* </pre>
*/
void sectionClasses() const {
section("CLASSES");
}
/**
* Section OBJECTS
*
* <pre>
* 0
* SECTION
* 2
* OBJECTS
* </pre>
*/
void sectionObjects() const {
section("OBJECTS");
}
/**
* End of a section.
*
* <pre>
* 0
* ENDSEC
* </pre>
*/
void sectionEnd() const {
dxfString(0, "ENDSEC");
}
/**
* Generic table for table 'name' with 'num' entries:
*
* <pre>
* 0
* TABLE
* 2
* name
* 70
* num
* </pre>
*/
void table(const char* name, int num, int h=0) const {
dxfString(0, "TABLE");
dxfString(2, name);
if (version>=DL_VERSION_2000) {
if (h==0) {
handle();
}
else {
dxfHex(5, h);
}
dxfString(100, "AcDbSymbolTable");
}
dxfInt(70, num);
}
/** Table for layers.
*
* @param num Number of layers in total.
*
* <pre>
* 0
* TABLE
* 2
* LAYER
* 70
* num
* </pre>
*/
void tableLayers(int num) const {
table("LAYER", num, 2);
}
/** Table for line types.
*
* @param num Number of line types in total.
*
* <pre>
* 0
* TABLE
* 2
* LTYPE
* 70
* num
* </pre>
*/
void tableLinetypes(int num) const {
//linetypeHandle = 5;
table("LTYPE", num, 5);
}
/** Table for application id.
*
* @param num Number of registered applications in total.
*
* <pre>
* 0
* TABLE
* 2
* APPID
* 70
* num
* </pre>
*/
void tableAppid(int num) const {
table("APPID", num, 9);
}
/** Table for text style.
*
* @param num Number of text styles.
*
* <pre>
* 0
* TABLE
* 2
* STYLE
* 70
* num
* </pre>
*/
void tableStyle(int num) const {
table("STYLE", num, 3);
}
/**
* End of a table.
*
* <pre>
* 0
* ENDTAB
* </pre>
*/
void tableEnd() const {
dxfString(0, "ENDTAB");
}
/**
* End of the DXF file.
*
* <pre>
* 0
* EOF
* </pre>
*/
void dxfEOF() const {
dxfString(0, "EOF");
}
/**
* Comment.
*
* <pre>
* 999
* text
* </pre>
*/
void comment(const char* text) const {
dxfString(999, text);
}
/**
* Entity.
*
* <pre>
* 0
* entTypeName
* </pre>
*
* @return Unique handle or 0.
*/
void entity(const char* entTypeName) const {
dxfString(0, entTypeName);
if (version>=DL_VERSION_2000) {
handle();
}
}
/**
* Attributes of an entity.
*
* <pre>
* 8
* layer
* 62
* color
* 39
* width
* 6
* linetype
* </pre>
*/
void entityAttributes(const DL_Attributes& attrib) const {
// layer name:
dxfString(8, attrib.getLayer());
// R12 doesn't accept BYLAYER values. The value has to be missing
// in that case.
if (version>=DL_VERSION_2000 || attrib.getColor()!=256) {
dxfInt(62, attrib.getColor());
}
if (version>=DL_VERSION_2000 && attrib.getColor24()!=-1) {
dxfInt(420, attrib.getColor24());
}
if (version>=DL_VERSION_2000) {
dxfInt(370, attrib.getWidth());
}
if (version>=DL_VERSION_2000) {
dxfReal(48, attrib.getLinetypeScale());
}
std::string linetype = attrib.getLinetype();
std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper);
if (version>=DL_VERSION_2000 || linetype=="BYLAYER") {
dxfString(6, attrib.getLinetype());
}
}
/**
* Subclass.
*/
void subClass(const char* sub) const {
dxfString(100, sub);
}
/**
* Layer (must be in the TABLES section LAYER).
*
* <pre>
* 0
* LAYER
* </pre>
*/
void tableLayerEntry(unsigned long int h=0) const {
dxfString(0, "LAYER");
if (version>=DL_VERSION_2000) {
if (h==0) {
handle();
} else {
dxfHex(5, h);
}
dxfString(100, "AcDbSymbolTableRecord");
dxfString(100, "AcDbLayerTableRecord");
}
}
/**
* Line type (must be in the TABLES section LTYPE).
*
* <pre>
* 0
* LTYPE
* </pre>
*/
void tableLinetypeEntry(unsigned long int h=0) const {
dxfString(0, "LTYPE");
if (version>=DL_VERSION_2000) {
if (h==0) {
handle();
} else {
dxfHex(5, h);
}
//dxfHex(330, 0x5);
dxfString(100, "AcDbSymbolTableRecord");
dxfString(100, "AcDbLinetypeTableRecord");
}
}
/**
* Appid (must be in the TABLES section APPID).
*
* <pre>
* 0
* APPID
* </pre>
*/
void tableAppidEntry(unsigned long int h=0) const {
dxfString(0, "APPID");
if (version>=DL_VERSION_2000) {
if (h==0) {
handle();
} else {
dxfHex(5, h);
}
//dxfHex(330, 0x9);
dxfString(100, "AcDbSymbolTableRecord");
dxfString(100, "AcDbRegAppTableRecord");
}
}
/**
* Block (must be in the section BLOCKS).
*
* <pre>
* 0
* BLOCK
* </pre>
*/
void sectionBlockEntry(unsigned long int h=0) const {
dxfString(0, "BLOCK");
if (version>=DL_VERSION_2000) {
if (h==0) {
handle();
} else {
dxfHex(5, h);
}
//dxfHex(330, blockHandle);
dxfString(100, "AcDbEntity");
if (h==0x1C) {
dxfInt(67, 1);
}
dxfString(8, "0"); // TODO: Layer for block
dxfString(100, "AcDbBlockBegin");
}
}
/**
* End of Block (must be in the section BLOCKS).
*
* <pre>
* 0
* ENDBLK
* </pre>
*/
void sectionBlockEntryEnd(unsigned long int h=0) const {
dxfString(0, "ENDBLK");
if (version>=DL_VERSION_2000) {
if (h==0) {
handle();
} else {
dxfHex(5, h);
}
//dxfHex(330, blockHandle);
dxfString(100, "AcDbEntity");
if (h==0x1D) {
dxfInt(67, 1);
}
dxfString(8, "0"); // TODO: Layer for block
dxfString(100, "AcDbBlockEnd");
}
}
void color(int col=256) const {
dxfInt(62, col);
}
void linetype(const char *lt) const {
dxfString(6, lt);
}
void linetypeScale(double scale) const {
dxfReal(48, scale);
}
void lineWeight(int lw) const {
dxfInt(370, lw);
}
void coord(int gc, double x, double y, double z=0) const {
dxfReal(gc, x);
dxfReal(gc+10, y);
dxfReal(gc+20, z);
}
void coordTriplet(int gc, const double* value) const {
if (value) {
dxfReal(gc, *value++);
dxfReal(gc+10, *value++);
dxfReal(gc+20, *value++);
}
}
void resetHandle() const {
m_handle = 1;
}
/**
* Writes a unique handle and returns it.
*/
unsigned long handle(int gc=5) const {
// handle has to be hex
dxfHex(gc, m_handle);
return m_handle++;
}
/**
* @return Next handle that will be written.
*/
unsigned long getNextHandle() const {
return m_handle;
}
/**
* Increases handle, so that the handle returned remains available.
*/
unsigned long incHandle() const {
return m_handle++;
}
/**
* Sets the handle of the model space. Entities refer to
* this handle.
*/
void setModelSpaceHandle(unsigned long h) {
modelSpaceHandle = h;
}
unsigned long getModelSpaceHandle() {
return modelSpaceHandle;
}
/**
* Sets the handle of the paper space. Some special blocks refer to
* this handle.
*/
void setPaperSpaceHandle(unsigned long h) {
paperSpaceHandle = h;
}
unsigned long getPaperSpaceHandle() {
return paperSpaceHandle;
}
/**
* Sets the handle of the paper space 0. Some special blocks refer to
* this handle.
*/
void setPaperSpace0Handle(unsigned long h) {
paperSpace0Handle = h;
}
unsigned long getPaperSpace0Handle() {
return paperSpace0Handle;
}
/**
* Must be overwritten by the implementing class to write a
* real value to the file.
*
* @param gc Group code.
* @param value The real value.
*/
virtual void dxfReal(int gc, double value) const = 0;
/**
* Must be overwritten by the implementing class to write an
* int value to the file.
*
* @param gc Group code.
* @param value The int value.
*/
virtual void dxfInt(int gc, int value) const = 0;
/**
* Can be overwritten by the implementing class to write a
* bool value to the file.
*
* @param gc Group code.
* @param value The bool value.
*/
virtual void dxfBool(int gc, bool value) const {
dxfInt(gc, (int)value);
}
/**
* Must be overwritten by the implementing class to write an
* int value (hex) to the file.
*
* @param gc Group code.
* @param value The int value.
*/
virtual void dxfHex(int gc, int value) const = 0;
/**
* Must be overwritten by the implementing class to write a
* string to the file.
*
* @param gc Group code.
* @param value The string.
*/
virtual void dxfString(int gc, const char* value) const = 0;
/**
* Must be overwritten by the implementing class to write a
* string to the file.
*
* @param gc Group code.
* @param value The string.
*/
virtual void dxfString(int gc, const std::string& value) const = 0;
protected:
mutable unsigned long m_handle;
mutable unsigned long modelSpaceHandle;
mutable unsigned long paperSpaceHandle;
mutable unsigned long paperSpace0Handle;
/**
* DXF version to be created.
*/
DL_Codes::version version;
private:
};
_HM_CAD_END
#endif
| [
"960902471@qq.com"
] | 960902471@qq.com |
8ba186ab00dc67517b1f6dcadf0b4b286f5588ce | 07368f604a72c97faf863529dfef690ff21d8675 | /tensorflow/compiler/jit/xla_device_context.cc | ff30b62bad782f281bcd25275521ed8b0c4c0bfd | [
"Apache-2.0"
] | permissive | Amywanwan/tensorflow | 8f847abe28815977fb1f9edbcc10c9d5ec0d4214 | 4b010b31890369d3236887f29633910af04d1410 | refs/heads/master | 2022-10-26T19:18:29.518549 | 2022-10-17T13:26:51 | 2022-10-17T13:26:51 | 134,808,604 | 0 | 0 | Apache-2.0 | 2018-05-25T05:42:23 | 2018-05-25T05:42:23 | null | UTF-8 | C++ | false | false | 8,736 | cc | /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/jit/xla_device_context.h"
#include "tensorflow/compiler/jit/xla_launch_util.h"
#include "tensorflow/compiler/tf2xla/literal_util.h"
#include "tensorflow/compiler/tf2xla/shape_util.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/common_runtime/device.h"
#include "tensorflow/core/common_runtime/dma_helper.h"
#include "tensorflow/core/platform/mem.h"
namespace tensorflow {
// The allocator used for Tensors assigned to the XLA device.
XlaDeviceAllocator::XlaDeviceAllocator() {}
XlaDeviceAllocator::~XlaDeviceAllocator() = default;
string XlaDeviceAllocator::Name() { return "xla"; }
void* XlaDeviceAllocator::AllocateRaw(size_t alignment, size_t num_bytes) {
// We always return an empty XlaTensor object, encoded as an opaque tagged
// pointer. We can return an empty object and ignore num_bytes here because we
// have control over all of the uses of this device tensor, and can lazily
// allocate memory when used. This allows us to also know the shape of the
// allocated Tensor, which is useful if the device's tensor representation
// differs from the host.
return XlaTensor::ToOpaquePointer(new XlaTensor());
}
void XlaDeviceAllocator::DeallocateRaw(void* ptr) {
delete XlaTensor::FromOpaquePointer(ptr);
}
void XlaDeviceAllocator::GetStats(AllocatorStats* stats) { stats->Clear(); }
XlaTransferManager::XlaTransferManager(
se::Stream* stream, xla::LocalClient* client, bool transfer_as_literal,
XlaCompiler::ShapeRepresentationFn shape_representation_fn)
: stream_(stream),
client_(client),
transfer_manager_(client->backend().transfer_manager()),
transfer_as_literal_(transfer_as_literal),
shape_representation_fn_(std::move(shape_representation_fn)) {}
Status XlaTransferManager::TransferLiteralToDevice(
const Tensor& host_tensor, Tensor* device_tensor) const {
xla::Literal literal;
TF_RETURN_IF_ERROR(HostTensorToLiteral(host_tensor, &literal));
VLOG(1) << "Transfer to device as literal: " << literal.ToString();
const xla::ShapedBuffer& shaped_buffer =
XlaTensor::FromTensor(device_tensor)->shaped_buffer();
return transfer_manager_->TransferLiteralToDevice(stream_->parent(), literal,
shaped_buffer);
}
Status XlaTransferManager::TransferLiteralFromDevice(
Tensor* host_tensor, const Tensor& device_tensor) const {
const xla::ShapedBuffer& shaped_buffer =
XlaTensor::FromTensor(&device_tensor)->shaped_buffer();
TF_ASSIGN_OR_RETURN(std::unique_ptr<xla::Literal> literal,
transfer_manager_->TransferLiteralFromDevice(
stream_->parent(), shaped_buffer));
VLOG(1) << "Transfer from device as literal: " << literal->ToString();
Tensor tensor;
TF_RETURN_IF_ERROR(
LiteralToHostTensor(*literal, host_tensor->dtype(), &tensor));
// Reshape the tensor back to its declared shape.
if (!host_tensor->CopyFrom(tensor, device_tensor.shape())) {
return errors::Internal(
"Tensor::CopyFrom failed when copying from XLA device to CPU");
}
return Status::OK();
}
void XlaTransferManager::CopyCPUTensorToDevice(const Tensor* cpu_tensor,
Device* device,
Tensor* device_tensor,
StatusCallback done) const {
if (cpu_tensor->NumElements() > 0) {
VLOG(2) << "CopyCPUTensorToDevice "
<< reinterpret_cast<const void*>(cpu_tensor->tensor_data().data())
<< " "
<< reinterpret_cast<const void*>(
device_tensor->tensor_data().data())
<< " " << cpu_tensor->NumElements();
void* src_ptr = const_cast<void*>(DMAHelper::base(cpu_tensor));
const int64 total_bytes = cpu_tensor->TotalBytes();
XlaTensor* xla_tensor = XlaTensor::FromTensor(device_tensor);
CHECK(xla_tensor);
TensorShape shape;
if (shape_representation_fn_) {
shape = shape_representation_fn_(device_tensor->shape(),
device_tensor->dtype());
} else {
shape = device_tensor->shape();
}
if (!xla_tensor->has_shaped_buffer()) {
Status s = xla_tensor->AllocateShapedBuffer(
device_tensor->dtype(), shape, client_,
stream_->parent()->device_ordinal());
if (!s.ok()) {
done(s);
return;
}
}
Status status;
if (transfer_as_literal_) {
Tensor reshaped_cpu_tensor;
if (!reshaped_cpu_tensor.CopyFrom(*cpu_tensor, shape)) {
done(errors::Internal(
"Tensor::CopyFrom failed when copying from CPU to XLA device"));
return;
}
status = TransferLiteralToDevice(reshaped_cpu_tensor, device_tensor);
} else {
se::DeviceMemoryBase dev_dst_ptr =
XlaTensor::DeviceMemoryFromTensor(*device_tensor);
stream_->ThenMemcpy(&dev_dst_ptr, src_ptr, total_bytes);
// TODO(hpucha): Make this asynchronous.
Status block_status = stream_->BlockHostUntilDone();
if (!block_status.ok()) {
status = xla::InternalError(
"Failed to complete data transfer on stream %p: %s", stream_,
block_status.error_message().c_str());
}
}
xla_tensor->set_host_tensor(*cpu_tensor);
done(status);
return;
}
VLOG(2) << "CopyCPUTensorToDevice empty tensor";
done(Status::OK());
}
void XlaTransferManager::CopyDeviceTensorToCPU(const Tensor* device_tensor,
StringPiece tensor_name,
Device* device,
Tensor* cpu_tensor,
StatusCallback done) {
if (device_tensor->NumElements() > 0) {
VLOG(2) << "CopyDeviceTensorToCPU "
<< reinterpret_cast<const void*>(
device_tensor->tensor_data().data())
<< " "
<< reinterpret_cast<const void*>(cpu_tensor->tensor_data().data())
<< device_tensor->NumElements();
const int64 total_bytes = cpu_tensor->TotalBytes();
se::DeviceMemoryBase dev_src_ptr =
XlaTensor::DeviceMemoryFromTensor(*device_tensor);
void* dst_ptr = DMAHelper::base(cpu_tensor);
Status status;
if (transfer_as_literal_) {
status = TransferLiteralFromDevice(cpu_tensor, *device_tensor);
} else {
stream_->ThenMemcpy(dst_ptr, dev_src_ptr, total_bytes);
// TODO(hpucha): Make this asynchronous.
Status block_status = stream_->BlockHostUntilDone();
if (!block_status.ok()) {
status = xla::InternalError(
"Failed to complete data transfer on stream %p: %s", stream_,
block_status.error_message().c_str());
}
}
done(status);
return;
}
VLOG(2) << "CopyDeviceTensorToCPU empty tensor";
done(Status::OK());
}
XlaDeviceContext::XlaDeviceContext(
se::Stream* stream, xla::LocalClient* client, bool transfer_as_literal,
XlaCompiler::ShapeRepresentationFn shape_representation_fn)
: manager_(stream, client, transfer_as_literal,
std::move(shape_representation_fn)) {}
void XlaDeviceContext::CopyCPUTensorToDevice(const Tensor* cpu_tensor,
Device* device,
Tensor* device_tensor,
StatusCallback done) const {
manager_.CopyCPUTensorToDevice(cpu_tensor, device, device_tensor, done);
}
void XlaDeviceContext::CopyDeviceTensorToCPU(const Tensor* device_tensor,
StringPiece tensor_name,
Device* device, Tensor* cpu_tensor,
StatusCallback done) {
manager_.CopyDeviceTensorToCPU(device_tensor, tensor_name, device, cpu_tensor,
done);
}
} // namespace tensorflow
| [
"gardener@tensorflow.org"
] | gardener@tensorflow.org |
95bae46918c21c1cf52babb05a818050eee19f09 | c676bcf38a8e3833699752cf03f361b74fcc3e20 | /src/canvascv/widgets/hframe.cpp | 4130562d7f6f28916fa81282ca68d71e7665fbe6 | [
"BSD-3-Clause"
] | permissive | rocee/CanvasCV | 9fa619e9a5f6398f28cad76682f8c9364ac33e15 | 85235e5c6270df0feb6f960254b67a04653f1221 | refs/heads/master | 2021-04-15T10:31:51.462153 | 2017-07-26T11:41:40 | 2017-07-26T11:41:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 536 | cpp | #include "hframe.h"
#include "widgetfactory.h"
using namespace cv;
using namespace std;
namespace canvascv
{
const char * HFrame::type = "HFrame";
HFrame::HFrame(const Point &pos)
: HorizontalLayout(pos)
{
fillBG = true;
}
shared_ptr<HFrame> HFrame::create(Layout &layout, const Point &pos)
{
shared_ptr<HFrame> widget(WidgetFactoryT<HFrame>::newWidget(layout, pos));
return widget;
}
void HFrame::setFrameRelief(Relief value)
{
setRelief(value);
}
const char *HFrame::getType() const
{
return type;
}
}
| [
"sagi.zeevi@gmail.com"
] | sagi.zeevi@gmail.com |
43b2255f5fb45d06c9a5e2a83077149df7df4e9c | 26968d29aefc53d207ab2559084fd8b6943da85b | /SourceFiles/httpThread_y.cpp | 83b728b0212680df85c423a8d0c27e56014d5071 | [] | no_license | dzfowen/Visual-Telemedicine-Aided-Diagnosis-Platform | 53d8809af5cecf4e9c7094ea45e6318436d984fe | efe25002e6d62827f3327281ac505480d5bfd3df | refs/heads/master | 2020-06-01T22:56:44.656482 | 2019-06-09T02:59:18 | 2019-06-09T02:59:18 | 190,713,486 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,380 | cpp | #include "httpThread_y.h"
extern Service* service2;
void httpThread_y::on_get(lacewing::webserver webserver, lacewing::webserver_request request)
{
std::string str;
str = request->GET("Command");
qDebug() << "http thread_y " << str.c_str() << endl;
if (strcmp(str.c_str(), "getcurrentuser") == 0)
{
request->writef(service2->Currentuser().c_str());
}
if (strcmp(str.c_str(), "setcurrentuser") == 0)
{
std::string str1 = request->GET("currentuser");
service2->Currentuser(str1);
}
if (strcmp(str.c_str(), "polling") == 0)
{
}
if (strcmp(str.c_str(), "getlastFile") == 0)
{
char temp1[100];
sprintf_s(temp1, "%d", service2->Lastfile());
request->writef(temp1);
}
if (strcmp(str.c_str(), "getFileList") == 0)
{
string strTosend;
map<string, DataFile*>::iterator begin, end;
end = service2->filedir.end();
for (begin = service2->filedir.begin(); begin != end; begin++)
{
strTosend += (*begin).first + ",";
}
if (strTosend.length() != 0)
{
strTosend = strTosend.substr(0, strTosend.length() - 1);
}
request->writef(strTosend.c_str());
}
if (strcmp(str.c_str(), "getFile") == 0)
{
string md5 = request->GET("md5");
map<string, DataFile*>::iterator i;
i = service2->filedir.find(md5);
if ((*i).second->getType() == ".vtk")
{
//HZIP hz;
string oripath = (*i).second->getPath();
//string path = oripath.substr(0, oripath.find_last_of(".")) + ".zip";
//hz = CreateZip(path.c_str(), 0);
//ZipAdd(hz, oripath.substr(oripath.find_last_of("/") + 1).c_str(), oripath.c_str());
//CloseZip(hz);
//request->write_file(path.c_str());
request->write_file(oripath.c_str());
}
if ((*i).second->getType() == ".mhd")
{
request->write_file((*i).second->Path().c_str());
}
if ((*i).second->getType() == ".raw")
{
request->write_file((*i).second->Path().c_str());
}
else if ((*i).second->getType() == ".dcm")
{
request->write_file((*i).second->Path().c_str());
//HZIP hz;
//string fold = (*i).second->getPath().substr(0, (*i).second->getPath().find_last_of("/"));
//_finddata_t file;
//string path2 = fold + ".zip";
//long longf;
////TCHAR pathT[50] = { '0' };
////mbstowcs(pathT, path2.c_str(), path2.size());
//hz = CreateZip(path2.c_str(), 0);
//
//if ((longf = _findfirst((fold + "/*.*").c_str(), &file)) == -1l)
//{
// qDebug() << "cannot find file";
//}
//else
//{
// string tempName;
// while (_findnext(longf, &file) == 0)
// {
// tempName = "";
// tempName = file.name;
// //TCHAR tempNameT[50] = {'0'};
// //mbstowcs(tempNameT, tempName.c_str(), tempName.size());
// //TCHAR tempNameT2[50] = {'0'};
// //mbstowcs(tempNameT2, (fold + "/" + tempName).c_str(), (fold + "/" + tempName).size());
// ZipAdd(hz, tempName.c_str(), (fold + "/" + tempName).c_str());
// qDebug() << tempName.c_str();
// }
//}
//_findclose(longf);
//CloseZip(hz);
//request->write_file(path2.c_str());
}
}
}
httpThread_y::httpThread_y()
{
eventpump = lacewing::eventpump_new();
webserver = lacewing::webserver_new(eventpump);
}
httpThread_y::~httpThread_y()
{
}
void httpThread_y::run()
{
qDebug() << "http thread_y start";
webserver->on_get(on_get);
webserver->host(20001);
eventpump->start_eventloop();
lacewing::webserver_delete(webserver);
lacewing::pump_delete(eventpump);
}
| [
"575900931@qq.com"
] | 575900931@qq.com |
640ef8237b51d26f621b5a0cc0b79fc5f943a67f | d96333ca6eb18677c2579c1114fb047cc799bf13 | /aoj0232.cpp | c9e6b147c3cbea116a8616994710cc08ec2fef62 | [] | no_license | zaburo-ch/icpc_practice | e8fe735857689f685ea86435346963731f5dcd18 | fc275c0d0a0b8feba786059fa1f571563d8e432e | refs/heads/master | 2021-01-19T05:03:31.891988 | 2015-06-28T17:39:00 | 2015-06-28T17:39:00 | 21,899,426 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,717 | cpp | #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-5;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};
const int MAX_J = 5001;
int X,Y,Z;
int V[4];
int event[51];
int event_A[51];
double dp[51][MAX_J];
int main(){
while(1){
scanf("%d%d%d",&X,&Y,&Z);
if(!X)break;
for(int i=0;i<X;i++){
scanf("%d",&V[i]);
}
fill(event,event+Y+1,0);
for(int i=0;i<Z;i++){
int N,E,A;
scanf("%d%d%d",&N,&E,&A);
event[N] = E;
event_A[N] = A;
}
for(int i=0;i<Y+1;i++){
for(int j=0;j<MAX_J;j++){
dp[i][j] = 0;
}
}
dp[0][0] = 1;
for(int i=0;i<Y;i++){
for(int j=0;j<MAX_J;j++){
for(int k=0;k<X;k++){
int ni = min(Y, i+V[k]), nj = j;
if(event[ni]==1){
ni = min(Y, ni+event_A[ni]);
}else if(event[ni]==2){
nj += event_A[ni];
}else if(event[ni]==3){
nj = max(0, j-event_A[ni]);
}
dp[ni][nj] += dp[i][j] / X;
}
}
}
double ans = 0;
for(int j=1;j<MAX_J;j++){
ans += j*dp[Y][j];
}
printf("%d\n", (int)(ans+EPS));
//break;
}
return 0;
}
| [
"musharna000@gmail.com"
] | musharna000@gmail.com |
912207ae47a0d6f3381398216d9a415ad8b1e119 | 370aa8b7d58d20bf02dbc7c32510b87bee872759 | /testsrc/configtest.cc | be3a8a46f5101f0a888a300ded6166f452c8dec1 | [] | no_license | tlvb/dmx512usb_software | f61d9fbfa403ba71f88ecf1d06db9eb83570ca3f | 5eabf8d6fc8a602c0ed116feec195749d509624b | refs/heads/master | 2020-05-27T19:38:43.656248 | 2012-08-20T20:47:00 | 2012-08-20T20:47:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 431 | cc | #include "config.hh"
#include <iostream>
using namespace std;
using namespace dmx512usb_software;
int main(void) {
Config c;
if (c.get_device().compare("/dev/ttyUSB0") != 0) {
cout << "c.get_device() does does not equal expected value" << endl;
cout << "expected: \"/dev/ttyUSB0\"" << endl;
cout << "actual: \"" << c.get_device() << "\"" << endl;
return 1;
}
cout << "configtest success" << endl;
return 0;
}
| [
"leo.barring@gmail.com"
] | leo.barring@gmail.com |
ce9bb75c4341bba37f5a64401968ce184f08b755 | 30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a | /contest/1542580447.cpp | f941677b85b2f0c7d50bbecdcc0738400d203115 | [] | no_license | thegamer1907/Code_Analysis | 0a2bb97a9fb5faf01d983c223d9715eb419b7519 | 48079e399321b585efc8a2c6a84c25e2e7a22a61 | refs/heads/master | 2020-05-27T01:20:55.921937 | 2019-11-20T11:15:11 | 2019-11-20T11:15:11 | 188,403,594 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,465 | cpp | #include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a) for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
ll ret = 1;
for(; e > 0; e >>= 1)
{
if(e & 1) ret = (ret * p) % M;
p = (p * p) % M;
}
return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
if(b == 0)return a;
return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
ll ret = 1;
for(; e > 0; e >>= 1)
{
if(e & 1) ret = (ret * p);
p = (p * p);
}
return (T)ret;
}
template <class T>bool ISLEFT(T a, T b, T c)
{
if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1; //Uporer dike //A,b,c, x okkher ordera sorted
else return 0;
}
#define md 2100000007ll
#define mx 200004
#define base 193ll
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
int main()
{
int n,m;
I2(n,m);
int ar[20];
SET(ar);
fr(i,1,n)
{
int num=0;
fr(j,0,m-1)
{
int x;
I(x);
if(x)num|=(1<<j);
}
ar[num]++;
}
if(ar[0]){PC("YES\n");
return 0;
}
else
{
int ara[5];
int ko=(1<<m);
for(int j=1; j<(1<<ko); j++)
{
bool fl=0;
memset(ara,0,sizeof ara);
for(int i=0; i<ko; i++)
{
if((j&(1<<i)))
{
if(!ar[i])fl=1;
for(int l=0; l<m; l++)
{
if((i&(1<<l)))ara[l]++;
}
}
}
if(!fl)
{
int lp=CB(j);
int cl=0;
for(int op=0; op<m; op++)
{
if(ara[op]*2>lp)cl=1;
}
if(!cl)
{
PC("YES\n");
return 0;
}
}
}
}
PC("NO\n");
return 0;
}
| [
"harshitagar1907@gmail.com"
] | harshitagar1907@gmail.com |
43bb556f65c566e003c75690398531f764bbe28b | f6761bd4b74ed9c3bc0e8f62e5a1db70c03096f0 | /aten/src/ATen/native/cpu/PointwiseOpsKernel.cpp | 248392ec0aa5e67c9c76138a6e49deb464184f43 | [
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"Apache-2.0"
] | permissive | MarisaKirisame/pytorch | b638790a0997d776ad4c5e4c77badc77e5dc94f9 | 59c5de4d0eda8d4f5494602034093933600d0a3d | refs/heads/master | 2021-06-19T10:44:33.846286 | 2019-10-31T22:56:55 | 2019-10-31T22:58:28 | 218,881,408 | 2 | 0 | NOASSERTION | 2019-11-01T00:02:51 | 2019-11-01T00:02:51 | null | UTF-8 | C++ | false | false | 3,095 | cpp | // Ternary and higher-order pointwise operations
#include <ATen/ATen.h>
#include <ATen/Dispatch.h>
#include <ATen/native/PointwiseOps.h>
#include <ATen/native/TensorIterator.h>
#include <ATen/native/cpu/Loops.h>
namespace at {
namespace native {
namespace {
static void addcmul_cpu_kernel(TensorIterator& iter, Scalar value) {
ScalarType dtype = iter.dtype(0);
AT_DISPATCH_ALL_TYPES_AND_COMPLEX(dtype, "addcmul_cpu_out", [&] {
scalar_t scalar_val = value.to<scalar_t>();
auto scalar_vec = Vec256<scalar_t>(scalar_val);
cpu_kernel_vec(
iter,
[=](scalar_t self_val, scalar_t t1_val, scalar_t t2_val) -> scalar_t {
return self_val + scalar_val * t1_val * t2_val;
},
[=](Vec256<scalar_t> self_vec,
Vec256<scalar_t> t1_vec,
Vec256<scalar_t> t2_vec) {
return self_vec + scalar_vec * t1_vec * t2_vec;
});
});
}
static void addcdiv_cpu_kernel(TensorIterator& iter, Scalar value) {
ScalarType dtype = iter.dtype(0);
AT_DISPATCH_ALL_TYPES_AND_COMPLEX(dtype, "addcdiv_cpu_out", [&] {
scalar_t scalar_val = value.to<scalar_t>();
auto scalar_vec = Vec256<scalar_t>(scalar_val);
cpu_kernel_vec(
iter,
[=](scalar_t self_val, scalar_t t1_val, scalar_t t2_val) -> scalar_t {
return self_val + scalar_val * t1_val / t2_val;
},
[=](Vec256<scalar_t> self_vec,
Vec256<scalar_t> t1_vec,
Vec256<scalar_t> t2_vec) {
return self_vec + scalar_vec * t1_vec / t2_vec;
});
});
}
static void smooth_l1_backward_cpu_kernel(TensorIterator& iter, Scalar norm) {
ScalarType dtype = iter.dtype(0);
AT_DISPATCH_ALL_TYPES(dtype, "smooth_l1_backward_cpu_out", [&] {
auto norm_val = norm.to<scalar_t>();
cpu_kernel(iter,
[=](scalar_t input, scalar_t target, scalar_t grad_output) -> scalar_t {
const auto x = input - target;
if (x < -1.)
return -norm_val * grad_output;
else if (x > 1.)
return norm_val * grad_output;
else
return norm_val * x * grad_output;
}
);
});
}
static void mse_backward_cpu_kernel(TensorIterator& iter, Scalar value) {
ScalarType dtype = iter.dtype(0);
AT_DISPATCH_ALL_TYPES(dtype, "mse_backward_cpu_out", [&] {
scalar_t scalar_val = value.to<scalar_t>();
auto scalar_vec = Vec256<scalar_t>(scalar_val);
cpu_kernel_vec(
iter,
[=](scalar_t self_val, scalar_t t1_val, scalar_t t2_val) -> scalar_t {
return scalar_val * (self_val - t1_val) * t2_val;
},
[=](Vec256<scalar_t> self_vec,
Vec256<scalar_t> t1_vec,
Vec256<scalar_t> t2_vec) {
return scalar_vec * (self_vec - t1_vec) * t2_vec;
});
});
}
} // anonymous namespace
REGISTER_DISPATCH(addcmul_stub, &addcmul_cpu_kernel);
REGISTER_DISPATCH(addcdiv_stub, &addcdiv_cpu_kernel);
REGISTER_DISPATCH(smooth_l1_backward_stub, &smooth_l1_backward_cpu_kernel);
REGISTER_DISPATCH(mse_backward_stub, &mse_backward_cpu_kernel);
} // namespace native
} // namespace at
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
8e826754a06111c93a000e9f9d627904416f3b77 | ff43563cca42c1cf2f48f3273d445cc8ed004edd | /src/game/scene/StartMenu.cc | 64f75298f17f0422219fcc0df50fe07afad4e608 | [] | no_license | MatthewSuttles/galaxy-demo-app | d800280df81f8aff7fd5aaccac161f2006fb0159 | c8aea4db4f525bc28961b6d82924ccf2eb98e72d | refs/heads/master | 2021-01-18T06:13:06.411905 | 2016-04-11T09:36:30 | 2016-04-11T09:36:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,914 | cc | #include "StartMenu.h"
#include <game/IGame.h>
#include <engine/system/Button.h>
#include <engine/core/SDLResourceManager.h>
#include <SDL_opengl.h>
using namespace gogtron;
using namespace gogtron::system;
using namespace gogtron::scene;
using namespace gogtron::networking;
StartMenu::StartMenu(const IGamePtr& _game)
: GameState(_game)
{
}
bool StartMenu::Init()
{
glViewport(0, 0, 1280, 720);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1280, 720, 1.0, -1.0, 1.0);
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1280, 720, 1.0, -1.0, 1.0);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (!core::SDLResourceManager::GetInstance().LoadTexture("res//images//button.png", "button"))
return false;
if (!core::SDLResourceManager::GetInstance().LoadTexture("res//images//selectedbutton.png", "selectedbutton"))
return false;
if (!core::SDLResourceManager::GetInstance().LoadFont("res//fonts//FreeSans.ttf", "FreeSans"))
return false;
GUIElementPtr playButton(std::make_shared<Button>(
"button",
"selectedbutton",
renderer::Sprite(1280 / 2 - 150, 50, 300, 100),
/*Sprite(400, 100, 400, 224),*/
[&](){ game->SetGameState(GameState::State::LOBBY_MENU); }));
guiElements.push_back(playButton);
GUIElementPtr statsButton(std::make_shared<Button>(
"button",
"selectedbutton",
renderer::Sprite(1280 / 2 - 150, 200, 300, 100),
[&]() { game->SetGameState(GameState::State::STATS_VIEW); }));
guiElements.push_back(statsButton);
GUIElementPtr leaderboardsButton(std::make_shared<Button>(
"button",
"selectedbutton",
renderer::Sprite(1280 / 2 - 150, 350, 300, 100),
[&]() { game->SetGameState(GameState::State::LEADERBOARDS_VIEW); }));
guiElements.push_back(leaderboardsButton);
GUIElementPtr quitButton(std::make_shared<Button>(
"button",
"selectedbutton",
renderer::Sprite(1280 / 2 - 150, 500, 300, 100),
/*Sprite(400, 400, 400, 224),*/
[&](){ game->Close(); }));
guiElements.push_back(quitButton);
return true;
}
bool StartMenu::Release()
{
return true;
}
void StartMenu::OnMouseDown(std::uint32_t x, std::uint32_t y)
{
for (const auto& element : guiElements)
{
element->OnMouseDown(x, y);
}
}
void StartMenu::OnMouseMotion(std::uint32_t x, std::uint32_t y)
{
for (const auto& element : guiElements)
{
element->OnMouseMotion(x, y);
}
}
void StartMenu::OnKeyDown(SDL_Keysym key)
{
switch (key.sym)
{
case SDLK_UP:
guiElements[0]->OnMouseMotion(450, 150);
break;
case SDLK_DOWN:
break;
case SDLK_KP_ENTER:
guiElements[0]->OnMouseDown(450, 150);
break;
default:
break;
}
}
void StartMenu::OnLobbyEvent(const LobbyEvent& lobbyEvent)
{
}
bool StartMenu::Update()
{
return true;
}
bool StartMenu::Display(const renderer::OGLRendererPtr& renderEngine)
{
glViewport(0, 0, 1280, 720);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1280, 720, 1.0, -1.0, 1.0);
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1280, 720, 1.0, -1.0, 1.0);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
renderEngine->StartScene();
for (const auto& element : guiElements)
{
element->Display(renderEngine);
}
renderEngine->DisplayText("PLAY", renderer::Sprite(1280 / 2 - 50, 50, 100, 100), "FreeSans_Play", SDL_Color{ 255, 0, 0, 255 });
renderEngine->DisplayText("STATS", renderer::Sprite(1280 / 2 - 50, 200, 100, 100), "FreeSans_Stats", SDL_Color{ 255, 0, 0, 255 });
renderEngine->DisplayText("LEADERBOARDS", renderer::Sprite(1280 / 2 - 100, 350, 200, 100), "FreeSans_Leaderboards", SDL_Color{ 255, 0, 0, 255 });
renderEngine->DisplayText("QUIT", renderer::Sprite(1280 / 2 - 50, 500, 100, 100), "FreeSans_Quit", SDL_Color{ 255, 0, 0, 255 });
renderEngine->EndScene();
return true;
} | [
"tjaskolski@gog.com"
] | tjaskolski@gog.com |
39fdcca7269687757c9612d145d3e719b9c4ab4d | 93183bb5313c7eb85268fdeb1ebfde02f26cca75 | /src/rpc/rawtransaction.cpp | ee1817c1dcfee361e2e20a286606a8380222c9bc | [] | no_license | puzcoin/stakework | 9e600a6ace0c8f5a22842478d657fd940564aee7 | 97725197706b86a6ae3816bc5ffbbe87a57e8d96 | refs/heads/master | 2021-01-08T23:13:21.772438 | 2020-02-21T18:20:43 | 2020-02-21T18:20:43 | 242,171,332 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 47,803 | cpp | // Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <base58.h>
#include <chain.h>
#include <coins.h>
#include <consensus/validation.h>
#include <core_io.h>
#include <init.h>
#include <keystore.h>
#include <main.h>
#include <merkleblock.h>
#include <net.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <rpc/server.h>
#include <script/script.h>
#include <script/script_error.h>
#include <script/sign.h>
#include <script/standard.h>
#include <txmempool.h>
#include <uint256.h>
#include <timedata.h>
#include <utilstrencodings.h>
#ifdef ENABLE_WALLET
#include <wallet/wallet.h>
#endif
#include <stdint.h>
#include <boost/assign/list_of.hpp>
#include <univalue.h>
using namespace std;
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex)
{
txnouttype type;
vector<CTxDestination> addresses;
int nRequired;
out.pushKV("asm", ScriptToAsmStr(scriptPubKey));
if (fIncludeHex)
out.pushKV("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end()));
if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) {
out.pushKV("type", GetTxnOutputType(type));
return;
}
out.pushKV("reqSigs", nRequired);
out.pushKV("type", GetTxnOutputType(type));
if (type == TX_PAYMENTREQUESTNOVOTE || type == TX_PAYMENTREQUESTYESVOTE
|| type == TX_PROPOSALNOVOTE || type == TX_PROPOSALYESVOTE)
{
vector<std::vector<unsigned char>> vSolutions;
txnouttype whichType;
if (Solver(scriptPubKey, whichType, vSolutions))
{
out.pushKV("hash", uint256(vSolutions[0]).ToString());
}
}
else
{
UniValue a(UniValue::VARR);
for(const CTxDestination& addr: addresses)
a.push_back(CStakeWorkAddress(addr).ToString());
out.pushKV("addresses", a);
}
}
void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& entry,
int nHeight = 0, int nConfirmations = 0, int nBlockTime = 0)
{
uint256 txid = tx.GetHash();
entry.pushKV("txid", txid.GetHex());
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
entry.pushKV("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION));
entry.pushKV("vsize", (int)::GetVirtualTransactionSize(tx));
entry.pushKV("version", tx.nVersion);
entry.pushKV("locktime", (int64_t)tx.nLockTime);
entry.pushKV("strdzeel", tx.strDZeel);
UniValue vin(UniValue::VARR);
for (unsigned int i = 0; i < tx.vin.size(); i++) {
const CTxIn& txin = tx.vin[i];
UniValue in(UniValue::VOBJ);
if (tx.IsCoinBase())
in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
else {
in.pushKV("txid", txin.prevout.hash.GetHex());
in.pushKV("vout", (int64_t)txin.prevout.n);
UniValue o(UniValue::VOBJ);
o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true));
o.pushKV("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
in.pushKV("scriptSig", o);
// Add address and value info if spentindex enabled
CSpentIndexValue spentInfo;
CSpentIndexKey spentKey(txin.prevout.hash, txin.prevout.n);
if (GetSpentIndex(spentKey, spentInfo)) {
in.pushKV("value", ValueFromAmount(spentInfo.satoshis));
in.pushKV("valueSat", spentInfo.satoshis);
if (spentInfo.addressType == 1) {
in.pushKV("address", CStakeWorkAddress(CKeyID(spentInfo.addressHash)).ToString());
} else if (spentInfo.addressType == 2) {
in.pushKV("address", CStakeWorkAddress(CScriptID(spentInfo.addressHash)).ToString());
}
}
}
if (!tx.wit.IsNull()) {
if (!tx.wit.vtxinwit[i].IsNull()) {
UniValue txinwitness(UniValue::VARR);
for (unsigned int j = 0; j < tx.wit.vtxinwit[i].scriptWitness.stack.size(); j++) {
std::vector<unsigned char> item = tx.wit.vtxinwit[i].scriptWitness.stack[j];
txinwitness.push_back(HexStr(item.begin(), item.end()));
}
in.pushKV("txinwitness", txinwitness);
}
}
in.pushKV("sequence", (int64_t)txin.nSequence);
vin.push_back(in);
}
entry.pushKV("vin", vin);
UniValue vout(UniValue::VARR);
for (unsigned int i = 0; i < tx.vout.size(); i++) {
const CTxOut& txout = tx.vout[i];
UniValue out(UniValue::VOBJ);
out.pushKV("value", ValueFromAmount(txout.nValue));
out.pushKV("valueSat", txout.nValue);
out.pushKV("n", (int64_t)i);
UniValue o(UniValue::VOBJ);
ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
out.pushKV("scriptPubKey", o);
// Add spent information if spentindex is enabled
CSpentIndexValue spentInfo;
CSpentIndexKey spentKey(txid, i);
if (GetSpentIndex(spentKey, spentInfo)) {
out.pushKV("spentTxId", spentInfo.txid.GetHex());
out.pushKV("spentIndex", (int)spentInfo.inputIndex);
out.pushKV("spentHeight", spentInfo.blockHeight);
}
vout.push_back(out);
}
entry.pushKV("vout", vout);
if (!hashBlock.IsNull()) {
entry.pushKV("blockhash", hashBlock.GetHex());
if (nConfirmations > 0) {
entry.pushKV("height", nHeight);
entry.pushKV("confirmations", nConfirmations);
entry.pushKV("time", nBlockTime);
entry.pushKV("blocktime", nBlockTime);
} else {
entry.pushKV("height", -1);
entry.pushKV("confirmations", 0);
}
}
}
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
{
entry.pushKV("txid", tx.GetHash().GetHex());
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
entry.pushKV("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION));
entry.pushKV("vsize", (int)::GetVirtualTransactionSize(tx));
entry.pushKV("version", tx.nVersion);
entry.pushKV("locktime", (int64_t)tx.nLockTime);
entry.pushKV("time", (int64_t)tx.nTime);
entry.pushKV("strdzeel", tx.strDZeel);
UniValue vin(UniValue::VARR);
for (unsigned int i = 0; i < tx.vin.size(); i++) {
const CTxIn& txin = tx.vin[i];
UniValue in(UniValue::VOBJ);
if (tx.IsCoinBase())
in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
else {
in.pushKV("txid", txin.prevout.hash.GetHex());
in.pushKV("vout", (int64_t)txin.prevout.n);
UniValue o(UniValue::VOBJ);
o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true));
o.pushKV("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
in.pushKV("scriptSig", o);
}
if (!tx.wit.IsNull()) {
if (!tx.wit.vtxinwit[i].IsNull()) {
UniValue txinwitness(UniValue::VARR);
for (unsigned int j = 0; j < tx.wit.vtxinwit[i].scriptWitness.stack.size(); j++) {
std::vector<unsigned char> item = tx.wit.vtxinwit[i].scriptWitness.stack[j];
txinwitness.push_back(HexStr(item.begin(), item.end()));
}
in.pushKV("txinwitness", txinwitness);
}
}
in.pushKV("sequence", (int64_t)txin.nSequence);
vin.push_back(in);
}
entry.pushKV("vin", vin);
UniValue vout(UniValue::VARR);
for (unsigned int i = 0; i < tx.vout.size(); i++) {
const CTxOut& txout = tx.vout[i];
UniValue out(UniValue::VOBJ);
out.pushKV("value", ValueFromAmount(txout.nValue));
out.pushKV("valueSat", txout.nValue);
out.pushKV("n", (int64_t)i);
UniValue o(UniValue::VOBJ);
ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
out.pushKV("scriptPubKey", o);
vout.push_back(out);
}
entry.pushKV("vout", vout);
if (!hashBlock.IsNull()) {
entry.pushKV("blockhash", hashBlock.GetHex());
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) {
entry.pushKV("height", pindex->nHeight);
entry.pushKV("confirmations", 1 + chainActive.Height() - pindex->nHeight);
entry.pushKV("time", pindex->GetBlockTime());
entry.pushKV("blocktime", pindex->GetBlockTime());
} else {
entry.pushKV("height", -1);
entry.pushKV("confirmations", 0);
}
}
}
}
UniValue getrawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"getrawtransaction \"txid\" ( verbose )\n"
"\nNOTE: By default this function only works sometimes. This is when the tx is in the mempool\n"
"or there is an unspent output in the utxo for this transaction. To make it always work,\n"
"you need to maintain a transaction index, using the -txindex command line option.\n"
"\nReturn the raw transaction data.\n"
"\nIf verbose=0, returns a string that is serialized, hex-encoded data for 'txid'.\n"
"If verbose is non-zero, returns an Object with information about 'txid'.\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id\n"
"2. verbose (numeric|boolean, optional, default=0) If 0|false, return a string, other return a json object\n"
"\nResult (if verbose is not set or set to 0):\n"
"\"data\" (string) The serialized, hex-encoded data for 'txid'\n"
"\nResult (if verbose > 0):\n"
"{\n"
" \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n"
" \"txid\" : \"id\", (string) The transaction id (same as provided)\n"
" \"hash\" : \"id\", (string) The transaction hash (differs from txid for witness transactions)\n"
" \"size\" : n, (numeric) The serialized transaction size\n"
" \"vsize\" : n, (numeric) The virtual transaction size (differs from size for witness transactions)\n"
" \"version\" : n, (numeric) The version\n"
" \"locktime\" : ttt, (numeric) The lock time\n"
" \"vin\" : [ (array of json objects)\n"
" {\n"
" \"txid\": \"id\", (string) The transaction id\n"
" \"vout\": n, (numeric) \n"
" \"scriptSig\": { (json object) The script\n"
" \"asm\": \"asm\", (string) asm\n"
" \"hex\": \"hex\" (string) hex\n"
" },\n"
" \"sequence\": n (numeric) The script sequence number\n"
" \"txinwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n"
" }\n"
" ,...\n"
" ],\n"
" \"vout\" : [ (array of json objects)\n"
" {\n"
" \"value\" : x.xxx, (numeric) The value in " + CURRENCY_UNIT + "\n"
" \"n\" : n, (numeric) index\n"
" \"scriptPubKey\" : { (json object)\n"
" \"asm\" : \"asm\", (string) the asm\n"
" \"hex\" : \"hex\", (string) the hex\n"
" \"reqSigs\" : n, (numeric) The required sigs\n"
" \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n"
" \"addresses\" : [ (json array of string)\n"
" \"stakeworkaddress\" (string) stakework address\n"
" ,...\n"
" ]\n"
" }\n"
" }\n"
" ,...\n"
" ],\n"
" \"blockhash\" : \"hash\", (string) the block hash\n"
" \"confirmations\" : n, (numeric) The confirmations\n"
" \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n"
" \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getrawtransaction", "\"mytxid\"")
+ HelpExampleCli("getrawtransaction", "\"mytxid\" 1")
+ HelpExampleRpc("getrawtransaction", "\"mytxid\", 1")
+ HelpExampleRpc("getrawtransaction", "\"mytxid\" true")
+ HelpExampleRpc("getrawtransaction", "\"mytxid\", true")
);
uint256 hash = ParseHashV(params[0], "parameter 1");
bool fVerbose = false;
if (params.size() > 1 && !params[1].isNull()) {
if (params[1].isNum()) {
if (params[1].get_int() != 0) {
fVerbose = true;
}
}
else if(params[1].isBool()) {
if (params[1].isTrue()) {
fVerbose = true;
}
}
else {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid type provided. Verbose parameter must be an int or boolean.");
}
}
CTransaction tx;
uint256 hashBlock;
int nHeight = 0;
int nConfirmations = 0;
int nBlockTime = 0;
{
LOCK(cs_main);
CCoinsViewCache view(pcoinsTip);
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, view, true))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) {
nHeight = pindex->nHeight;
nConfirmations = 1 + chainActive.Height() - pindex->nHeight;
nBlockTime = pindex->GetBlockTime();
} else {
nHeight = -1;
nConfirmations = 0;
nBlockTime = pindex->GetBlockTime();
}
}
}
string strHex = EncodeHexTx(tx);
if (!fVerbose)
return strHex;
UniValue result(UniValue::VOBJ);
result.pushKV("hex", strHex);
TxToJSONExpanded(tx, hashBlock, result, nHeight, nConfirmations, nBlockTime);
return result;
}
UniValue gettxoutproof(const UniValue& params, bool fHelp)
{
if (fHelp || (params.size() != 1 && params.size() != 2))
throw runtime_error(
"gettxoutproof [\"txid\",...] ( blockhash )\n"
"\nReturns a hex-encoded proof that \"txid\" was included in a block.\n"
"\nNOTE: By default this function only works sometimes. This is when there is an\n"
"unspent output in the utxo for this transaction. To make it always work,\n"
"you need to maintain a transaction index, using the -txindex command line option or\n"
"specify the block in which the transaction is included manually (by blockhash).\n"
"\nReturn the raw transaction data.\n"
"\nArguments:\n"
"1. \"txids\" (string) A json array of txids to filter\n"
" [\n"
" \"txid\" (string) A transaction hash\n"
" ,...\n"
" ]\n"
"2. \"block hash\" (string, optional) If specified, looks for txid in the block with this hash\n"
"\nResult:\n"
"\"data\" (string) A string that is a serialized, hex-encoded data for the proof.\n"
);
set<uint256> setTxids;
uint256 oneTxid;
UniValue txids = params[0].get_array();
for (unsigned int idx = 0; idx < txids.size(); idx++) {
const UniValue& txid = txids[idx];
if (txid.get_str().length() != 64 || !IsHex(txid.get_str()))
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid txid ")+txid.get_str());
uint256 hash(uint256S(txid.get_str()));
if (setTxids.count(hash))
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated txid: ")+txid.get_str());
setTxids.insert(hash);
oneTxid = hash;
}
LOCK(cs_main);
CBlockIndex* pblockindex = nullptr;
uint256 hashBlock;
if (params.size() > 1)
{
hashBlock = uint256S(params[1].get_str());
if (!mapBlockIndex.count(hashBlock))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
pblockindex = mapBlockIndex[hashBlock];
} else {
CCoins coins;
if (pcoinsTip->GetCoins(oneTxid, coins) && coins.nHeight > 0 && coins.nHeight <= chainActive.Height())
pblockindex = chainActive[coins.nHeight];
}
if (pblockindex == nullptr)
{
CTransaction tx;
CCoinsViewCache view(pcoinsTip);
if (!GetTransaction(oneTxid, tx, Params().GetConsensus(), hashBlock, view, false) || hashBlock.IsNull())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not yet in block");
if (!mapBlockIndex.count(hashBlock))
throw JSONRPCError(RPC_INTERNAL_ERROR, "Transaction index corrupt");
pblockindex = mapBlockIndex[hashBlock];
}
CBlock block;
if(!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus()))
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
unsigned int ntxFound = 0;
for(const CTransaction&tx: block.vtx)
if (setTxids.count(tx.GetHash()))
ntxFound++;
if (ntxFound != setTxids.size())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "(Not all) transactions not found in specified block");
CDataStream ssMB(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
CMerkleBlock mb(block, setTxids);
ssMB << mb;
std::string strHex = HexStr(ssMB.begin(), ssMB.end());
return strHex;
}
UniValue verifytxoutproof(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"verifytxoutproof \"proof\"\n"
"\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n"
"and throwing an RPC error if the block is not in our best chain\n"
"\nArguments:\n"
"1. \"proof\" (string, required) The hex-encoded proof generated by gettxoutproof\n"
"\nResult:\n"
"[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof is invalid\n"
);
CDataStream ssMB(ParseHexV(params[0], "proof"), SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
CMerkleBlock merkleBlock;
ssMB >> merkleBlock;
UniValue res(UniValue::VARR);
vector<uint256> vMatch;
vector<unsigned int> vIndex;
if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != merkleBlock.header.hashMerkleRoot)
return res;
LOCK(cs_main);
if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()]))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
for(const uint256& hash: vMatch)
res.push_back(hash.GetHex());
return res;
}
UniValue createrawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 5)
throw runtime_error(
"createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,\"data\":\"hex\",...} [strdzeel] [index] [toggle-input-dump]\n"
"\nCreate a transaction spending the given inputs and creating new outputs.\n"
"Outputs can be addresses or data.\n"
"Returns hex-encoded raw transaction.\n"
"Note that the transaction's inputs are not signed, and\n"
"it is not stored in the wallet or transmitted to the network.\n"
"\nArguments:\n"
"1. \"transactions\" (string, required) A json array of json objects\n"
" [\n"
" {\n"
" \"txid\":\"id\", (string, required) The transaction id\n"
" \"vout\":n (numeric, required) The output number\n"
" \"sequence\":n (numeric, optional) The sequence number\n"
" }\n"
" ,...\n"
" ]\n"
"2. \"outputs\" (string, required) a json object with outputs\n"
" {\n"
" \"address\": x.xxx (numeric or string, required) The key is the stakework address, the numeric value (can be string) is the " + CURRENCY_UNIT + " amount\n"
" \"data\": x.xxx, (string, required) The key is hex encoded data, the numeric value (can be string) is the " + CURRENCY_UNIT + " amount\n"
" ...\n"
" }\n"
"3. \"strdzeel\" (string, optional) Attached string metadata \n"
"4. \"index\" (numeric, optional, default=-1) If greater than -1, it will only print the raw data of the output or input on the index \"index\"\n"
"4. \"toggle-input-dump\" (bool, optional, default=false) Sets whether the input (true) or the output (false) at the index \"index\" is dumped \n"
"\nResult:\n"
"\"transaction\" (string) hex string of the transaction\n"
"\nExamples\n"
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"{\\\"address\\\":0.01}\"")
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"{\\\"00010203\\\":\\\"0.01\\\"}\"")
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"address\\\":0.01}\"")
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"00010203\\\":\\\"0.01\\\"}\"")
);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)(UniValue::VSTR)(UniValue::VNUM), true);
if (params[0].isNull() || params[1].isNull())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, arguments 1 and 2 must be non-null");
UniValue inputs = params[0].get_array();
UniValue sendTo = params[1].get_obj();
CMutableTransaction rawTx;
if (params.size() > 2 && !params[2].isNull() && !params[2].get_str().empty()) {
rawTx.strDZeel = params[2].get_str();
}
rawTx.nVersion = IsCommunityFundEnabled(chainActive.Tip(),Params().GetConsensus()) ? CTransaction::TXDZEEL_VERSION_V2 : CTransaction::TXDZEEL_VERSION;
int nout = -1;
if (params.size() > 3 && !params[3].isNull()) {
int nOut = params[3].get_int();
if (nOut < -1 || nOut > std::numeric_limits<int>::max())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, nout out of range");
nout = nOut;
}
int dumpin = false;
if (params.size() > 4 && !params[4].isNull() && params[4].isBool()) {
dumpin = params[4].getBool();
}
rawTx.nTime = GetAdjustedTime();
for (unsigned int idx = 0; idx < inputs.size(); idx++) {
const UniValue& input = inputs[idx];
const UniValue& o = input.get_obj();
uint256 txid = ParseHashO(o, "txid");
const UniValue& vout_v = find_value(o, "vout");
if (!vout_v.isNum())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key");
int nOutput = vout_v.get_int();
if (nOutput < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive");
uint32_t nSequence = (rawTx.nLockTime ? std::numeric_limits<uint32_t>::max() - 1 : std::numeric_limits<uint32_t>::max());
// set the sequence number if passed in the parameters object
const UniValue& sequenceObj = find_value(o, "sequence");
if (sequenceObj.isNum()) {
int64_t seqNr64 = sequenceObj.get_int64();
if (seqNr64 < 0 || seqNr64 > std::numeric_limits<uint32_t>::max())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, sequence number is out of range");
else
nSequence = (uint32_t)seqNr64;
}
CTxIn in(COutPoint(txid, nOutput), CScript(), nSequence);
rawTx.vin.push_back(in);
}
set<CStakeWorkAddress> setAddress;
vector<string> addrList = sendTo.getKeys();
for(const string& name_: addrList) {
CStakeWorkAddress address(name_);
if (address.IsValid()) {
if (setAddress.count(address))
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+name_);
setAddress.insert(address);
CScript scriptPubKey = GetScriptForDestination(address.Get());
CAmount nAmount = AmountFromValue(sendTo[name_]);
CTxOut out(nAmount, scriptPubKey);
rawTx.vout.push_back(out);
} else {
std::vector<unsigned char> data = ParseHex(name_);
CTxOut out(AmountFromValue(sendTo[name_]), CScript(data.begin(), data.end()));
rawTx.vout.push_back(out);
}
}
if (dumpin) {
if(nout > -1 && (unsigned)nout >= rawTx.vin.size())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, index out of range");
} else
if(nout > -1 && (unsigned)nout >= rawTx.vout.size())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, index out of range");
return nout > -1 ? (dumpin ? EncodeHexTxIn(rawTx.vin[nout]) : EncodeHexTxOut(rawTx.vout[nout])) : EncodeHexTx(rawTx);
}
UniValue decoderawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"decoderawtransaction \"hexstring\"\n"
"\nReturn a JSON object representing the serialized, hex-encoded transaction.\n"
"\nArguments:\n"
"1. \"hex\" (string, required) The transaction hex string\n"
"\nResult:\n"
"{\n"
" \"txid\" : \"id\", (string) The transaction id\n"
" \"hash\" : \"id\", (string) The transaction hash (differs from txid for witness transactions)\n"
" \"size\" : n, (numeric) The transaction size\n"
" \"vsize\" : n, (numeric) The virtual transaction size (differs from size for witness transactions)\n"
" \"version\" : n, (numeric) The version\n"
" \"locktime\" : ttt, (numeric) The lock time\n"
" \"vin\" : [ (array of json objects)\n"
" {\n"
" \"txid\": \"id\", (string) The transaction id\n"
" \"vout\": n, (numeric) The output number\n"
" \"scriptSig\": { (json object) The script\n"
" \"asm\": \"asm\", (string) asm\n"
" \"hex\": \"hex\" (string) hex\n"
" },\n"
" \"txinwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n"
" \"sequence\": n (numeric) The script sequence number\n"
" }\n"
" ,...\n"
" ],\n"
" \"vout\" : [ (array of json objects)\n"
" {\n"
" \"value\" : x.xxx, (numeric) The value in " + CURRENCY_UNIT + "\n"
" \"n\" : n, (numeric) index\n"
" \"scriptPubKey\" : { (json object)\n"
" \"asm\" : \"asm\", (string) the asm\n"
" \"hex\" : \"hex\", (string) the hex\n"
" \"reqSigs\" : n, (numeric) The required sigs\n"
" \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n"
" \"addresses\" : [ (json array of string)\n"
" \"12tvKAXCxZjSmdNbao16dKXC8tRWfcF5oc\" (string) stakework address\n"
" ,...\n"
" ]\n"
" }\n"
" }\n"
" ,...\n"
" ],\n"
" \"strdzeel\" : \"id\", (string) Attached string metadata\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("decoderawtransaction", "\"hexstring\"")
+ HelpExampleRpc("decoderawtransaction", "\"hexstring\"")
);
LOCK(cs_main);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR));
CTransaction tx;
if (!DecodeHexTx(tx, params[0].get_str(), true))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
UniValue result(UniValue::VOBJ);
TxToJSON(tx, uint256(), result);
return result;
}
UniValue decodescript(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"decodescript \"hex\"\n"
"\nDecode a hex-encoded script.\n"
"\nArguments:\n"
"1. \"hex\" (string) the hex encoded script\n"
"\nResult:\n"
"{\n"
" \"asm\":\"asm\", (string) Script public key\n"
" \"hex\":\"hex\", (string) hex encoded public key\n"
" \"type\":\"type\", (string) The output type\n"
" \"reqSigs\": n, (numeric) The required signatures\n"
" \"addresses\": [ (json array of string)\n"
" \"address\" (string) stakework address\n"
" ,...\n"
" ],\n"
" \"p2sh\",\"address\" (string) script address\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("decodescript", "\"hexstring\"")
+ HelpExampleRpc("decodescript", "\"hexstring\"")
);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR));
UniValue r(UniValue::VOBJ);
CScript script;
if (params[0].get_str().size() > 0){
vector<unsigned char> scriptData(ParseHexV(params[0], "argument"));
script = CScript(scriptData.begin(), scriptData.end());
} else {
// Empty scripts are valid
}
ScriptPubKeyToJSON(script, r, false);
r.pushKV("p2sh", CStakeWorkAddress(CScriptID(script)).ToString());
return r;
}
/** Pushes a JSON object for script verification or signing errors to vErrorsRet. */
static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::string& strMessage)
{
UniValue entry(UniValue::VOBJ);
entry.pushKV("txid", txin.prevout.hash.ToString());
entry.pushKV("vout", (uint64_t)txin.prevout.n);
entry.pushKV("scriptSig", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
entry.pushKV("sequence", (uint64_t)txin.nSequence);
entry.pushKV("error", strMessage);
vErrorsRet.push_back(entry);
}
UniValue signrawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 4)
throw runtime_error(
"signrawtransaction \"hexstring\" ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] [\"privatekey1\",...] sighashtype )\n"
"\nSign inputs for raw transaction (serialized, hex-encoded).\n"
"The second optional argument (may be null) is an array of previous transaction outputs that\n"
"this transaction depends on but may not yet be in the block chain.\n"
"The third optional argument (may be null) is an array of base58-encoded private\n"
"keys that, if given, will be the only keys used to sign the transaction.\n"
#ifdef ENABLE_WALLET
+ HelpRequiringPassphrase() + "\n"
#endif
"\nArguments:\n"
"1. \"hexstring\" (string, required) The transaction hex string\n"
"2. \"prevtxs\" (string, optional) An json array of previous dependent transaction outputs\n"
" [ (json array of json objects, or 'null' if none provided)\n"
" {\n"
" \"txid\":\"id\", (string, required) The transaction id\n"
" \"vout\":n, (numeric, required) The output number\n"
" \"scriptPubKey\": \"hex\", (string, required) script key\n"
" \"redeemScript\": \"hex\", (string, required for P2SH or P2WSH) redeem script\n"
" \"amount\": value (numeric, required) The amount spent\n"
" }\n"
" ,...\n"
" ]\n"
"3. \"privatekeys\" (string, optional) A json array of base58-encoded private keys for signing\n"
" [ (json array of strings, or 'null' if none provided)\n"
" \"privatekey\" (string) private key in base58-encoding\n"
" ,...\n"
" ]\n"
"4. \"sighashtype\" (string, optional, default=ALL) The signature hash type. Must be one of\n"
" \"ALL\"\n"
" \"NONE\"\n"
" \"SINGLE\"\n"
" \"ALL|ANYONECANPAY\"\n"
" \"NONE|ANYONECANPAY\"\n"
" \"SINGLE|ANYONECANPAY\"\n"
"\nResult:\n"
"{\n"
" \"hex\" : \"value\", (string) The hex-encoded raw transaction with signature(s)\n"
" \"complete\" : true|false, (boolean) If the transaction has a complete set of signatures\n"
" \"errors\" : [ (json array of objects) Script verification errors (if there are any)\n"
" {\n"
" \"txid\" : \"hash\", (string) The hash of the referenced, previous transaction\n"
" \"vout\" : n, (numeric) The index of the output to spent and used as input\n"
" \"scriptSig\" : \"hex\", (string) The hex-encoded signature script\n"
" \"sequence\" : n, (numeric) Script sequence number\n"
" \"error\" : \"text\" (string) Verification or signing error related to the input\n"
" }\n"
" ,...\n"
" ]\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("signrawtransaction", "\"myhex\"")
+ HelpExampleRpc("signrawtransaction", "\"myhex\"")
);
#ifdef ENABLE_WALLET
LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : nullptr);
#else
LOCK(cs_main);
#endif
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR)(UniValue::VARR)(UniValue::VARR)(UniValue::VSTR), true);
vector<unsigned char> txData(ParseHexV(params[0], "argument 1"));
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
vector<CMutableTransaction> txVariants;
while (!ssData.empty()) {
try {
CMutableTransaction tx;
ssData >> tx;
txVariants.push_back(tx);
}
catch (const std::exception&) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
}
}
if (txVariants.empty())
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Missing transaction");
// mergedTx will end up with all the signatures; it
// starts as a clone of the rawtx:
CMutableTransaction mergedTx(txVariants[0]);
// Fetch previous transactions (inputs):
CCoinsView viewDummy;
CCoinsViewCache view(&viewDummy);
{
LOCK(mempool.cs);
CCoinsViewCache &viewChain = *pcoinsTip;
CCoinsViewMemPool viewMempool(&viewChain, mempool);
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
for(const CTxIn& txin: mergedTx.vin) {
const uint256& prevHash = txin.prevout.hash;
CCoins coins;
view.AccessCoins(prevHash); // this is certainly allowed to fail
}
view.SetBackend(viewDummy); // switch back to avoid locking mempool for too long
}
bool fGivenKeys = false;
CBasicKeyStore tempKeystore;
if (params.size() > 2 && !params[2].isNull()) {
fGivenKeys = true;
UniValue keys = params[2].get_array();
for (unsigned int idx = 0; idx < keys.size(); idx++) {
UniValue k = keys[idx];
CStakeWorkSecret vchSecret;
bool fGood = vchSecret.SetString(k.get_str());
if (!fGood)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key");
CKey key = vchSecret.GetKey();
if (!key.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Private key outside allowed range");
tempKeystore.AddKey(key);
}
}
#ifdef ENABLE_WALLET
else if (pwalletMain)
EnsureWalletIsUnlocked();
#endif
// Add previous txouts given in the RPC call:
if (params.size() > 1 && !params[1].isNull()) {
UniValue prevTxs = params[1].get_array();
for (unsigned int idx = 0; idx < prevTxs.size(); idx++) {
const UniValue& p = prevTxs[idx];
if (!p.isObject())
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "expected object with {\"txid'\",\"vout\",\"scriptPubKey\"}");
UniValue prevOut = p.get_obj();
RPCTypeCheckObj(prevOut,
{
{"txid", UniValueType(UniValue::VSTR)},
{"vout", UniValueType(UniValue::VNUM)},
{"scriptPubKey", UniValueType(UniValue::VSTR)},
});
uint256 txid = ParseHashO(prevOut, "txid");
int nOut = find_value(prevOut, "vout").get_int();
if (nOut < 0)
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout must be positive");
vector<unsigned char> pkData(ParseHexO(prevOut, "scriptPubKey"));
CScript scriptPubKey(pkData.begin(), pkData.end());
{
CCoinsModifier coins = view.ModifyCoins(txid);
if (coins->IsAvailable(nOut) && coins->vout[nOut].scriptPubKey != scriptPubKey) {
string err("Previous output scriptPubKey mismatch:\n");
err = err + ScriptToAsmStr(coins->vout[nOut].scriptPubKey) + "\nvs:\n"+
ScriptToAsmStr(scriptPubKey);
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, err);
}
if ((unsigned int)nOut >= coins->vout.size())
coins->vout.resize(nOut+1);
coins->vout[nOut].scriptPubKey = scriptPubKey;
coins->vout[nOut].nValue = 0;
if (prevOut.exists("amount")) {
coins->vout[nOut].nValue = AmountFromValue(find_value(prevOut, "amount"));
}
}
// if redeemScript given and not using the local wallet (private keys
// given), add redeemScript to the tempKeystore so it can be signed:
if (fGivenKeys && (scriptPubKey.IsPayToScriptHash() || scriptPubKey.IsPayToWitnessScriptHash())) {
RPCTypeCheckObj(prevOut,
{
{"txid", UniValueType(UniValue::VSTR)},
{"vout", UniValueType(UniValue::VNUM)},
{"scriptPubKey", UniValueType(UniValue::VSTR)},
{"redeemScript", UniValueType(UniValue::VSTR)},
});
UniValue v = find_value(prevOut, "redeemScript");
if (!v.isNull()) {
vector<unsigned char> rsData(ParseHexV(v, "redeemScript"));
CScript redeemScript(rsData.begin(), rsData.end());
tempKeystore.AddCScript(redeemScript);
}
}
}
}
#ifdef ENABLE_WALLET
const CKeyStore& keystore = ((fGivenKeys || !pwalletMain) ? tempKeystore : *pwalletMain);
#else
const CKeyStore& keystore = tempKeystore;
#endif
int nHashType = SIGHASH_ALL;
if (params.size() > 3 && !params[3].isNull()) {
static map<string, int> mapSigHashValues =
boost::assign::map_list_of
(string("ALL"), int(SIGHASH_ALL))
(string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))
(string("NONE"), int(SIGHASH_NONE))
(string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY))
(string("SINGLE"), int(SIGHASH_SINGLE))
(string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY))
;
string strHashType = params[3].get_str();
if (mapSigHashValues.count(strHashType))
nHashType = mapSigHashValues[strHashType];
else
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid sighash param");
}
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
// Script verification errors
UniValue vErrors(UniValue::VARR);
// Use CTransaction for the constant parts of the
// transaction to avoid rehashing.
const CTransaction txConst(mergedTx);
// Sign what we can:
for (unsigned int i = 0; i < mergedTx.vin.size(); i++) {
CTxIn& txin = mergedTx.vin[i];
const CCoins* coins = view.AccessCoins(txin.prevout.hash);
if (coins == NULL || !coins->IsAvailable(txin.prevout.n)) {
TxInErrorToJSON(txin, vErrors, "Input not found or already spent");
continue;
}
const CScript& prevPubKey = coins->vout[txin.prevout.n].scriptPubKey;
const CAmount& amount = coins->vout[txin.prevout.n].nValue;
SignatureData sigdata;
// Only sign SIGHASH_SINGLE if there's a corresponding output:
if (!fHashSingle || (i < mergedTx.vout.size()))
ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata);
// ... and merge in other signatures:
for(const CMutableTransaction& txv: txVariants) {
sigdata = CombineSignatures(prevPubKey, TransactionSignatureChecker(&txConst, i, amount), sigdata, DataFromTransaction(txv, i));
}
UpdateTransaction(mergedTx, i, sigdata);
ScriptError serror = SCRIPT_ERR_OK;
if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx.wit.vtxinwit.size() > i ? &mergedTx.wit.vtxinwit[i].scriptWitness : nullptr, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker(&txConst, i, amount), &serror)) {
TxInErrorToJSON(txin, vErrors, ScriptErrorString(serror));
}
}
bool fComplete = vErrors.empty();
UniValue result(UniValue::VOBJ);
result.pushKV("hex", EncodeHexTx(mergedTx));
result.pushKV("complete", fComplete);
if (!vErrors.empty()) {
result.pushKV("errors", vErrors);
}
return result;
}
UniValue sendrawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"sendrawtransaction \"hexstring\" ( allowhighfees )\n"
"\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n"
"\nAlso see createrawtransaction and signrawtransaction calls.\n"
"\nArguments:\n"
"1. \"hexstring\" (string, required) The hex string of the raw transaction)\n"
"2. allowhighfees (boolean, optional, default=false) Allow high fees\n"
"\nResult:\n"
"\"hex\" (string) The transaction hash in hex\n"
"\nExamples:\n"
"\nCreate a transaction\n"
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
"Sign the transaction, and get back the hex\n"
+ HelpExampleCli("signrawtransaction", "\"myhex\"") +
"\nSend the transaction (signed hex)\n"
+ HelpExampleCli("sendrawtransaction", "\"signedhex\"") +
"\nAs a json rpc call\n"
+ HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
);
LOCK(cs_main);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR)(UniValue::VBOOL));
// parse hex string from parameter
CTransaction tx;
if (!DecodeHexTx(tx, params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
uint256 hashTx = tx.GetHash();
CAmount nMaxRawTxFee = maxTxFee;
if (params.size() > 1 && params[1].get_bool())
nMaxRawTxFee = 0;
CCoinsViewCache &view = *pcoinsTip;
const CCoins* existingCoins = view.AccessCoins(hashTx);
bool fHaveMempool = mempool.exists(hashTx);
bool fHaveChain = existingCoins && existingCoins->nHeight < 1000000000;
if (!fHaveMempool && !fHaveChain) {
// push to local node and sync with wallets
CValidationState state;
bool fMissingInputs;
if (!AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, false, nMaxRawTxFee)) {
if (state.IsInvalid()) {
throw JSONRPCError(RPC_TRANSACTION_REJECTED, strprintf("%i: %s", state.GetRejectCode(), state.GetRejectReason()));
} else {
if (fMissingInputs) {
throw JSONRPCError(RPC_TRANSACTION_ERROR, "Missing inputs");
}
throw JSONRPCError(RPC_TRANSACTION_ERROR, state.GetRejectReason());
}
}
} else if (fHaveChain) {
throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain");
}
RelayTransaction(tx);
return hashTx.GetHex();
}
static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode
// --------------------- ------------------------ ----------------------- ----------
{ "rawtransactions", "getrawtransaction", &getrawtransaction, true },
{ "rawtransactions", "createrawtransaction", &createrawtransaction, true },
{ "rawtransactions", "decoderawtransaction", &decoderawtransaction, true },
{ "rawtransactions", "decodescript", &decodescript, true },
{ "rawtransactions", "sendrawtransaction", &sendrawtransaction, false },
{ "rawtransactions", "signrawtransaction", &signrawtransaction, false }, /* uses wallet if enabled */
{ "blockchain", "gettxoutproof", &gettxoutproof, true },
{ "blockchain", "verifytxoutproof", &verifytxoutproof, true },
};
void RegisterRawTransactionRPCCommands(CRPCTable &tableRPC)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
}
| [
"akuma@mud.com.cn"
] | akuma@mud.com.cn |
ca902ad76562670fa57749832583bb07539b0634 | 76b7e459b143c8481b044c60a68c768a0848b8f6 | /Codeforces/Round570/A.cpp | 7a33fbf9abb5c35ea39880db5f49f2e0e870fed0 | [] | no_license | hsnavarro/imepp | f3b195e5ed4e453eac9b73d5a77b39f44917435f | eb90580caea91b48e7d541db92531ba3fd2b82c1 | refs/heads/master | 2021-11-28T07:25:05.778476 | 2021-09-10T02:20:32 | 2021-09-10T02:20:32 | 145,646,296 | 0 | 1 | null | 2021-09-10T02:20:33 | 2018-08-22T02:40:54 | C++ | UTF-8 | C++ | false | false | 446 | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
#define st first
#define nd second
typedef pair<int, int> pii;
typedef long long ll;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
int n;
bool check(int n){
string s = to_string(n);
int sum = 0;
for(auto x : s) sum += (x - '0');
return sum % 4 == 0;
}
int main(){
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n;
while(!check(n)) n++;
cout << n << "\n";
}
| [
"ricksnavarro@gmail.com"
] | ricksnavarro@gmail.com |
2f8929eade7f9d319af392268172fdf7a02701e4 | a759c6611c855925e2a73ca437ed004d74c4c611 | /백준문제/자료구조 - Data Structures/백준 10872.cpp | 9cb3482b3f81ab14d7c1bfb5ba4554ae22d121c0 | [] | no_license | yugo9081/My-Codes | dafcfb7428256b9bad06d4221cec6e208241d151 | 84bfe92865d854f9aa6a201a2ba66dae1c2abe27 | refs/heads/master | 2023-01-20T22:50:39.828481 | 2020-11-23T09:47:05 | 2020-11-23T09:47:05 | 283,927,861 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 649 | cpp | /******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
using namespace std;
int factorial(int n){ //recursion
if(n<=1){
return 1;
}
return n*factorial(n-1);
}
int main(void)
{
cin.tie(NULL);
cout.tie(NULL);
ios_base :: sync_with_stdio(false);
int n;
cin>>n;
cout << factorial(n)<<"\n";
}
| [
"yugo9081@colorado.edu"
] | yugo9081@colorado.edu |
e6e5a38020fa86f64eebcb18d11fe432a47a8949 | 31665642ed578801e684eb0e71526707416f6c7b | /osca/xiinux/src/web/web.hpp | 07f8b73e306027d9881615af48c387a59187c780 | [] | no_license | calint/a | 79fb449e4e9baf4b19da6b1cbf925235254ba981 | 50c8d03e0115cd52737a0f95e86b9043e731f419 | refs/heads/master | 2023-02-02T14:30:44.406050 | 2023-01-29T04:57:04 | 2023-01-29T04:57:04 | 32,960,630 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 717 | hpp | #pragma once
//-- generated
#include"hello.hpp"
#include"typealine.hpp"
#include"counter.hpp"
#include"page.hpp"
#include"chunked.hpp"
#include"chunkedbig.hpp"
#include"chunkedbigger.hpp"
#include"notfound.hpp"
namespace xiinux{
static inline widget*widgetget(const char*qs){
if(!strcmp("hello",qs))return new web::hello();
if(!strcmp("typealine",qs))return new web::typealine();
if(!strcmp("counter",qs))return new web::counter();
if(!strcmp("page",qs))return new web::page(nullptr,nullptr);
if(!strcmp("chunked",qs))return new web::chunked();
if(!strcmp("chunkedbig",qs))return new web::chunkedbig();
if(!strcmp("chunkedbigger",qs))return new web::chunkedbigger();
return new web::notfound();
}
}
| [
"calin.tenitchi@gmail.com"
] | calin.tenitchi@gmail.com |
b50f477b68a33dc4dd53b838ca071604d5d469c1 | f22bdc99b6b308ec2be3f9cb63aa117f04d82dbe | /Apps/Tracker Applications/SimpleTrackerApplication/collisionCheck.h | c50f1c0e28fec36e5ddd129986edbe1ad77e7e3b | [] | no_license | naneaa/cybermed-master | d268b7b6c573feadc7cde041bd80de4a7ccc5687 | 46fba3ea54e9c4671a521cf21624a65a50812bd0 | refs/heads/master | 2021-01-21T08:37:19.621596 | 2018-05-14T23:30:42 | 2018-05-14T23:30:42 | 91,632,795 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 693 | h | class collisionCheck : public CybThread
{
private:
CybSphereTriangle *collisionObj;
CybParameters *cybCore;
int count;
public:
collisionCheck(int layerID)
{
collisionObj = new CybSphereTriangle(layerID);
count = 0;
cybCore = CybParameters::getInstance();
this->setTime(50);
}
~collisionCheck(){ delete collisionObj; }
void run()
{
CybThread::lock();
if(collisionObj->getCollisionStatus()){
cybCore->setColor(0,1,1,0,1);
cout << "is Equal the last collision " << collisionObj->isEqualLastCollision() << endl;
}
else
cybCore->setColor(0,1,0,1,1);
CybThread::unlock();
}
CybSphereTriangle *getCollisionInstance() { return collisionObj; }
};
| [
"elaineanita1@gmail.com"
] | elaineanita1@gmail.com |
b4ed4c31a7388377ba32c2c3f16b2bdffe58c7de | ea5abb606afbae6e5774072ffd9b69e6418d0389 | /source/io/fs/detail/FsCommon.h | 01ecfe4b23d8cabd1575c7618951d617b27bdfe8 | [
"MIT"
] | permissive | stormlord/tarm-io | a4487316a4034b654f89fb081e880bb4f3e4a928 | 6aebd85573f65017decf81be073c8b13ce6ac12c | refs/heads/master | 2023-07-01T11:24:38.077682 | 2021-08-08T08:02:37 | 2021-08-08T08:02:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,462 | h | /*----------------------------------------------------------------------------------------------
* Copyright (c) 2020 - present Alexander Voitenko
* Licensed under the MIT License. See License.txt in the project root for license information.
*----------------------------------------------------------------------------------------------*/
#pragma once
#include "Error.h"
#include "EventLoop.h"
namespace tarm {
namespace io {
namespace fs {
namespace detail {
template<typename T, typename OpenCallback>
bool open(EventLoop& loop, T& fs_object, const Path& path, const OpenCallback& callback) {
if (fs_object.state() == T::State::OPENED) {
fs_object.close([&fs_object, &loop, path, callback](typename T::ParentType& dir, const Error& error) {
if (error) {
if(callback) {
callback(dir, error);
}
} else {
loop.schedule_callback([&fs_object, path, callback](EventLoop&) {
fs_object.open(path, callback);
});
}
});
return false;
} else if (!(fs_object.state() == T::State::INITIAL || fs_object.state() == T::State::CLOSED)) {
loop.schedule_callback([&fs_object, path, callback](EventLoop&) {
fs_object.open(path, callback);
});
return false;
}
return true;
}
} // namespace detail
} // namespace fs
} // namespace io
} // namespace tarm
| [
"av@tarm.io"
] | av@tarm.io |
c774bfeab29bec9759f932410ff545fd298709eb | 46367579a54a09dd220dd9a678b1452f06897f11 | /tags/hdf5-1_4_3/c++/src/H5Library.h | f0d2e022702ec08d16b23d45501c7ef8f9f58be3 | [
"LicenseRef-scancode-llnl",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | TPLink32/hdf5 | 33ff24c9b6133f0f51cb6cc2b722fba7bb1777dd | 0d6987c15284bd9f34c7e44452a152833d42a738 | refs/heads/master | 2021-05-31T01:15:39.463663 | 2016-04-14T23:02:09 | 2016-04-14T23:02:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,220 | h | // C++ informative line for the emacs editor: -*- C++ -*-
#ifndef _H5Library_H
#define _H5Library_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
#endif
#define NOTATEXIT (-10) // just in case the HDF5 library use more
// negative constants. Note: the solution used for the atexit/global
// destructors is not reliable, and desperately needs improvement
// It is not even working, inifiteloop message still printed when
// calling H5close
class __DLLCPP__ H5Library {
public:
static bool need_cleanup; // indicates if H5close should be called
// Initializes the HDF5 library.
static void open();
// Flushes all data to disk, closes files, and cleans up memory.
static void close();
// Instructs library not to install atexit cleanup routine
static void dontAtExit();
// Returns the HDF library release number.
static void getLibVersion( unsigned& majnum, unsigned& minnum, unsigned& relnum );
// Verifies that the arguments match the version numbers compiled
// into the library
static void checkVersion( unsigned majnum, unsigned minnum, unsigned relnum );
private:
// Default constructor - no instance ever created
H5Library() {};
};
#ifndef H5_NO_NAMESPACE
}
#endif
#endif
| [
"(no author)@dab4d1a6-ed17-0410-a064-d1ae371a2980"
] | (no author)@dab4d1a6-ed17-0410-a064-d1ae371a2980 |
f7b5afa95d321aefe346b4081a73fbc3d9358b39 | d1f42089ef7f2976bcfba27253860df394fe6221 | /02/lab02/Dispencer/Dispencer.cpp | a954ddbe3cd4f4b6677d66c54df1e2f02a818eb4 | [] | no_license | petaryanakiev-py/oop-2020 | e4f756541fe6ffdcc1cea55d501f261911934d79 | ec9388d2b81325cbf43f5944eb76f7459a2c8b0a | refs/heads/master | 2022-09-10T22:18:23.191298 | 2020-06-03T14:39:26 | 2020-06-03T14:39:26 | 241,456,321 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 496 | cpp | #include "Dispencer.hpp"
#include <iostream>
void Dispencer::fill(const double litres)
{
this->litres = litres;
}
void Dispencer::fillGlass(const double mililitres)
{
const double MILILITRES_IN_LITRE = 1000;
if (this->litres * MILILITRES_IN_LITRE < mililitres)
{
std::cout << "Not enough water. Fill me first." << std::endl;
}
this->litres -= mililitres / MILILITRES_IN_LITRE;
}
void Dispencer::fillBottle(const double mililitres)
{
fillGlass(mililitres);
} | [
"petaryanakiev.py@gmail.com"
] | petaryanakiev.py@gmail.com |
7eb160471a88085df3efc9141b75dd84e9e11efa | c32ee8ade268240a8064e9b8efdbebfbaa46ddfa | /Libraries/m2sdk/ue/ai/framework/C_ObjectCreator_TPL_75E6C06E.h | ea3e3e1ffffbccda496262b1c31c13681acbdc75 | [] | no_license | hopk1nz/maf2mp | 6f65bd4f8114fdeb42f9407a4d158ad97f8d1789 | 814cab57dc713d9ff791dfb2a2abeb6af0e2f5a8 | refs/heads/master | 2021-03-12T23:56:24.336057 | 2015-08-22T13:53:10 | 2015-08-22T13:53:10 | 41,209,355 | 19 | 21 | null | 2015-08-31T05:28:13 | 2015-08-22T13:56:04 | C++ | UTF-8 | C++ | false | false | 539 | h | // auto-generated file (rttidump-exporter by h0pk1nz)
#pragma once
#include <ue/ai/framework/C_Functor_TPL_DC332828.h>
namespace ue
{
namespace ai
{
namespace framework
{
/** ue::ai::framework::C_ObjectCreator<game::ai::C_Behaviour_AvoidingCarJump> (VTable=0x01E43590) */
class C_ObjectCreator_TPL_75E6C06E : public C_Functor_TPL_DC332828
{
public:
virtual void vfn_0001_60D76610() = 0;
virtual void vfn_0002_60D76610() = 0;
virtual void vfn_0003_60D76610() = 0;
};
} // namespace framework
} // namespace ai
} // namespace ue
| [
"hopk1nz@gmail.com"
] | hopk1nz@gmail.com |
83abd328f151249aaa1a0f7e97caf23eb3f3f08a | 1dbbd823d470a10b1e122f99edff5a5e1b94a7a8 | /dependency/Shared/LogModule.h | ebe69aaca8b00921d2516490d97cd8208a6139f0 | [] | no_license | iwifigame/zhajinhua-project | ee99b31199af45985adb409f9bca9bccbeb99c7c | 85c1398f56e16c645fad4760a5c5f9abe3495781 | refs/heads/master | 2021-01-19T13:11:14.723484 | 2013-03-22T13:42:07 | 2013-03-22T13:42:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,920 | h | /********************************************************************
Copyright (C) 2013 by Alden Pang
@date: 2012-1-20 16:03
@file: LogModule.h
@author: Alden Pang
@desc:
*********************************************************************/
#ifndef _LOGMODULE_H_
#define _LOGMODULE_H_
#include <QString>
#include <QList>
#include <QQueue>
#include <QFile>
#include <QThread>
#include <QtNetwork>
#include <QSharedPointer>
/** */
enum LogLevel
{
LL_INFO=0,
LL_WARN,
LL_ERROR,
LL_TOTAL
};
class LogModule : public QObject
{
Q_OBJECT
public:
~LogModule(){};
static LogModule& GetSingleton()
{
static LogModule singleton;
return singleton;
}
public slots:
void SetOutputLevel(LogLevel _level){mLevel = _level;}
void StInfo(const QString& _text);
void StWarn(const QString& _text);
void StError(const QString& _text);
public:
void SetModuleName(const QString _fileName){ mLogFileName = _fileName; }
protected:
private:
LogModule();
LogLevel mLevel;
QString mLogDir;
QString mLogFileName;
QString mTodayStr;
void writeToFile(LogLevel _level, QString _log);
};
#define LOG LogModule::GetSingleton()
//#define DEF_LOG signals: void SiInfo(const QString& _text);void SiWarn(const QString& _text);void SiError(const QString& _text);
#define LOG_INFO(x) emit SiInfo(QString("[%1]-%2").arg(__FUNCTION__).arg(x))
#define LOG_WARN(x) emit SiWarn(QString("[%1]-%2").arg(__FUNCTION__).arg(x))
#define LOG_ERR(x) emit SiError(QString("[%1]-%2").arg(__FUNCTION__).arg(x))
#define LOG_D_INFO(x) LOG.StInfo(QString("[%1]-%2").arg(__FUNCTION__).arg(x))
#define LOG_D_WARN(x) LOG.StWarn(QString("[%1]-%2").arg(__FUNCTION__).arg(x))
#define LOG_D_ERR(x) LOG.StError(QString("[%1]-%2").arg(__FUNCTION__).arg(x))
#endif //_LOGMODULE_H_
/*
*
* [Revision 1.0 2012-1-20 16:03 Administrator] Created
*
*/ | [
"pangshuo1981@gmail.com@d8f4ed1e-bbb0-a400-853e-1b27d4c80825"
] | pangshuo1981@gmail.com@d8f4ed1e-bbb0-a400-853e-1b27d4c80825 |
614a9037776bfda2a144fe0a646c5ae41b3125c8 | 4e0a2e6e8136b54995594b43b2a71d75614a52bf | /ACM-2011-practise/ZOJ/The_8th_Zhejiang_Provincial_Collegiate_Programming_Contest/ProF.cpp | 16a21efccae41a033201608a88c7694fdbab0ab8 | [] | no_license | AlbertWang0116/KrwlngsACMFile | 884c84ba0afff0727448fc5b5b27b5cb76330936 | 23f0d9f6834f2b4fb2604ecbd50d5c41dd994b8f | refs/heads/master | 2023-06-21T09:25:28.528059 | 2023-06-11T19:18:40 | 2023-06-11T19:18:40 | 2,345,592 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 666 | cpp | #include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<algorithm>
using namespace std;
#define N 110
#define M 30
char name[N][M], frt[M];
int n, idx;
void input()
{
int i;
scanf("%d", &n);
scanf("%s", frt);
for (i = 0; i < n; ++i)
{
scanf("%s", name[i]);
if (!strcmp(name[i], frt)) idx = i;
}
}
void conduct()
{
idx = (idx + n / 2) % n;
cout << name[idx] << endl;
}
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int time;
scanf("%d", &time);
while (time--)
{
input();
conduct();
}
//fclose(stdin);
//fclose(stdout);
}
| [
"st.krwlng@gmail.com"
] | st.krwlng@gmail.com |
69d8defcea494a57668b92e7cd6af260edb33e1d | aa463fea7a890456f251d1b55242ef1782a71357 | /mytemplate.cpp | 730df5774fb20733268febad561d53c35ab830b3 | [] | no_license | tariqiitju/Contest-code | 8e18eb8996dd24a877fb9bbcb3593098b2ab91af | 651fe97a134f5c38e278a70723a6f694872d1949 | refs/heads/master | 2021-04-27T01:36:52.229896 | 2018-02-23T22:52:55 | 2018-02-23T22:52:55 | 122,678,847 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,179 | cpp | #include <bits/stdc++.h>
using namespace std;
#define output freopen("output.txt","w",stdout)
#define input freopen("input.txt","r",stdin)
///C IO
#define pf printf
#define sc scanf
#define pch putchar
#define ssc sscanf
#define spf sprintf
///functions
#define pb push_back
#define Mid(l,r) ((l+r)>>1)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mp make_pair
#define xx first
#define yy second
///For loop
#define fr0(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define FOR(a,n) for(auto a : n)
///memory reset
#define Mem(Array,Val,Size) memset(Array,Val,(Size)*(sizeof(Array[0])))
#define set0(x) memset(x,0,sizeof(x))
#define setn1(x) memset(x,-1,sizeof(x))
#define setinf(x) memset(x,127,sizeof(x))
///misc
#define SZ(v) ((int) (v).size())
#define all(v) (v).begin(), (v).end()
///bit operation single variable :: be careful with LL and ULL
#define On(x,i) (x|=(1<<(i)))
#define Off(x,i) (x&= ~(1<<(i)))
#define isOn(x,i) (x&(1<<(i)))
#define Toggle(x,i) (x^=(1<<(i)))
#define tmod(x,i) (x&(~(-1<<i)))
///inputs
template <class T> inline bool In(T &a) {return (bool)(cin>>a);}
template <class T1,class T2> inline bool In(T1 &a,T2 &b){return (bool) (cin>>a>>b);}
template <class T1,class T2,class T3> inline bool In(T1 &a,T2 &b,T3 &c){return (bool)(cin>>a>>b>>c);}
template <class T1,class T2,class T3,class T4> inline bool In(T1 &a,T2 &b,T3 &c,T4 &d){return (bool)(cin>>a>>b>>c>>d);}
inline bool Line(string &a) {return (bool)(getline(cin,a));}
template <class _T>inline void ina(_T a[],int n) {int i; fr0(i,n)In(a[i]);}
///outputs
template <class T> inline bool Pr(T a) {return (bool)(cout<<a);}
template <class T1,class T2> inline bool Pr(T1 a,T2 b) {return (bool)(cout<<a<<" "<<b);}
template <class T1,class T2,class T3> inline bool Pr(T1 a,T2 b,T3 c){return (bool)(cout<<a<<" "<<b<<" "<<c);}
template <class T1,class T2,class T3,class T4> inline bool Pr(T1 a,T2 b,T3 c,T4 d){return (bool)(cout<<a<<" "<<b<<" "<<c<<" "<<d);}
///debug
template <class T> inline void Cr(T a) {cerr<<a<<endl;}
template <class T1,class T2> inline void Cr(T1 a,T2 b){cerr<<a<<" "<<b<<endl;}
#define nln cout<<"\n"
#define sps cout<<" "
int TEST_CASE=0;
#define tcsp cout<<"Case "<<(++TEST_CASE)<<": "
#define tcnl cout<<"Case "<<(++TEST_CASE)<<":\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precice(n) cout<<setprecision(n)
#define FIX(n) cout<<setprecision(n)<<fixed
//data type
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
//BIG MOD / mod inverse
template<class _T>inline _T pow(_T a,_T b,_T m){a%=m;_T ans=1%m;while(b){if(b&1)ans*=a,ans%=m;a*=a;a%=m;b>>=1;}return ans;}
template<class _T>inline _T pow(_T a,_T b) {_T ans=1;while(b){if(b&1)ans*=a;a*=a;b>>=1;}return ans;}
template<class _T>inline _T add(_T a,_T b,_T m){return a>=m-b?a-(m-b):a+b;}//a,b<m
template<class _T>inline _T multiply(_T a,_T b,_T m){_T ans=0;if(b>a)swap(a,b);while(b){if(b&1)ans=add(ans,a,m);b>>=1;a=add(a,a,m);}return ans;}//a,b<m
template<class _T>inline _T bigpow(_T a,_T b,_T m){a%=m;_T ans=1%m;while(b){if(b&1)ans=multiply(ans,a,m);a=multiply(a,a,m);b>>=1;}return ans;}
template<class _T>inline _T modinvers(_T a,_T m){return m>2000000000LL?bigpow(a,m-2,m):pow(a,m-2,m);}//m is prime
//egcd / mod inverse
template<class _T> _T _egcd(_T a, _T b, _T &x,_T &y){if(!b){x=1,y=0;return a;}_T _g=_egcd(b,a%b,x,y);_T xt=x;x=y,y=xt-(a/b)*y;return _g;}
template<class _T>inline _T fmodinvers(_T a,_T m){_T x,y;_egcd(a,m,x,y);x%=m;if(x<0)x+=m;return x;} //a,m co-prime
template<class _T>inline _T _lcm(_T a, _T b){return (a*b)/__gcd(a,b);}
template <class T> inline T SQ(T a) {return a*a;}
ll SQRT(ll n){ll e=sqrt(n*1.0);ll l=max(0LL,e-2),r=min(n,e+2);ll ans=0;while(l<=r){ll m=Mid(l,r);if(m*m<=n)ans=m,l=m+1;else r=m-1;}return ans;}
ll CBRT(ll n){ll e=cbrt(n*1.0);ll l=max(0LL,e-2),r=min(n,e+2);ll ans=0;while(l<=r){ll m=Mid(l,r);if(m*m*m<=n)ans=m,l=m+1;else r=m-1;}return ans;}
//direction array
/*
knight: int dx[]={1,-1,1,-1,2,2,-2,-2}; int dy[]={2,2,-2,-2,1,-1,1,-1};
Grid Side: int dx[]={0,0,1,-1};int dy[]={1,-1,0,0};
*/
///constant
const LD EPS = 1e-9;
const LD PI= acos(-1.0);
const int SIZE= 1e6;
ll mod= 1e9+7;
int main()
{
return 0;
}
/**
Md. Tariqul Islam
IIT,JU
fb/tariqiitju
tarik.amtoly@gmail.com
*/
| [
"tarik.amtoly@gmail.com"
] | tarik.amtoly@gmail.com |
3bd6f1e890a2deeb7cfaa5c39d5f1f5e7a198a96 | 04b1803adb6653ecb7cb827c4f4aa616afacf629 | /chrome/browser/extensions/api/i18n/i18n_api.cc | fd5a25ff5b1975d278a15f13ee87815a3633a4c7 | [
"BSD-3-Clause"
] | permissive | Samsung/Castanets | 240d9338e097b75b3f669604315b06f7cf129d64 | 4896f732fc747dfdcfcbac3d442f2d2d42df264a | refs/heads/castanets_76_dev | 2023-08-31T09:01:04.744346 | 2021-07-30T04:56:25 | 2021-08-11T05:45:21 | 125,484,161 | 58 | 49 | BSD-3-Clause | 2022-10-16T19:31:26 | 2018-03-16T08:07:37 | null | UTF-8 | C++ | false | false | 2,272 | cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/api/i18n/i18n_api.h"
#include <algorithm>
#include <string>
#include <vector>
#include "base/lazy_instance.h"
#include "base/stl_util.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/i18n.h"
#include "components/language/core/browser/pref_names.h"
#include "components/prefs/pref_service.h"
namespace GetAcceptLanguages = extensions::api::i18n::GetAcceptLanguages;
namespace extensions {
namespace {
// Errors.
static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty.";
}
ExtensionFunction::ResponseAction I18nGetAcceptLanguagesFunction::Run() {
std::string accept_languages =
Profile::FromBrowserContext(browser_context())
->GetPrefs()
->GetString(language::prefs::kAcceptLanguages);
// Currently, there are 2 ways to set browser's accept-languages: through UI
// or directly modify the preference file. The accept-languages set through
// UI is guaranteed to be valid, and the accept-languages string returned from
// profile()->GetPrefs()->GetString(language::prefs::kAcceptLanguages) is
// guaranteed to be valid and well-formed, which means each accept-language is
// a valid code, and accept-languages are separated by "," without
// surrrounding spaces. But we do not do any validation (either the format or
// the validity of the language code) on accept-languages set through editing
// preference file directly. So, here, we're adding extra checks to be
// resistant to crashes caused by data corruption.
if (accept_languages.empty())
return RespondNow(Error(kEmptyAcceptLanguagesError));
std::vector<std::string> languages = base::SplitString(
accept_languages, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
base::Erase(languages, "");
if (languages.empty())
return RespondNow(Error(kEmptyAcceptLanguagesError));
return RespondNow(
ArgumentList(GetAcceptLanguages::Results::Create(languages)));
}
} // namespace extensions
| [
"sunny.nam@samsung.com"
] | sunny.nam@samsung.com |
361e83aed4895ff69b67636e7141a3203c966ad7 | 39320b80b4aa862c0d545e85bd2dd88f2585bdce | /src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp | 0b1deea43223d6e9d9bc256e036edf82ad359e47 | [] | no_license | ProjectStarGate/StarGate-Plus-EMU | ec8c8bb4fab9f6d3432d76b2afac1e1e7ec3249f | 8e75d2976ae863557992e69353a23af759346eae | refs/heads/master | 2021-01-15T12:25:53.949001 | 2011-12-21T06:04:07 | 2011-12-21T06:04:07 | 3,004,543 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 5,642 | cpp | /*
* Copyright (C) 2005-2011 MaNGOS <http://www.getmangos.com/>
*
* Copyright (C) 2008-2011 Trinity <http://www.trinitycore.org/>
*
* Copyright (C) 2006-2011 ScriptDev2 <http://www.scriptdev2.com/>
*
* Copyright (C) 2010-2011 ProjectSkyfire <http://www.projectskyfire.org/>
*
* Copyright (C) 2010-2012 Project-StarGate-Emu
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* ScriptData
SDName: Instance_ZulGurub
SD%Complete: 80
SDComment: Missing reset function after killing a boss for Ohgan, Thekal.
SDCategory: Zul'Gurub
EndScriptData */
#include "ScriptPCH.h"
#include "zulgurub.h"
class instance_zulgurub : public InstanceMapScript
{
public:
instance_zulgurub()
: InstanceMapScript("instance_zulgurub", 309)
{
}
struct instance_zulgurub_InstanceMapScript : public InstanceScript
{
instance_zulgurub_InstanceMapScript(Map* pMap) : InstanceScript(pMap) {Initialize();};
//If all High Priest bosses were killed. Lorkhan, Zath and Ohgan are added too.
uint32 m_auiEncounter[MAX_ENCOUNTERS];
//Storing Lorkhan, Zath and Thekal because we need to cast on them later. Jindo is needed for healfunction too.
uint64 m_uiLorKhanGUID;
uint64 m_uiZathGUID;
uint64 m_uiThekalGUID;
uint64 m_uiJindoGUID;
void Initialize()
{
memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
m_uiLorKhanGUID = 0;
m_uiZathGUID = 0;
m_uiThekalGUID = 0;
m_uiJindoGUID = 0;
}
bool IsEncounterInProgress() const
{
//not active in Zul'Gurub
return false;
}
void OnCreatureCreate(Creature* creature)
{
switch(creature->GetEntry())
{
case 11347: m_uiLorKhanGUID = creature->GetGUID(); break;
case 11348: m_uiZathGUID = creature->GetGUID(); break;
case 14509: m_uiThekalGUID = creature->GetGUID(); break;
case 11380: m_uiJindoGUID = creature->GetGUID(); break;
}
}
void SetData(uint32 uiType, uint32 uiData)
{
switch(uiType)
{
case TYPE_ARLOKK:
m_auiEncounter[0] = uiData;
break;
case TYPE_JEKLIK:
m_auiEncounter[1] = uiData;
break;
case TYPE_VENOXIS:
m_auiEncounter[2] = uiData;
break;
case TYPE_MARLI:
m_auiEncounter[3] = uiData;
break;
case TYPE_THEKAL:
m_auiEncounter[4] = uiData;
break;
case TYPE_LORKHAN:
m_auiEncounter[5] = uiData;
break;
case TYPE_ZATH:
m_auiEncounter[6] = uiData;
break;
case TYPE_OHGAN:
m_auiEncounter[7] = uiData;
break;
}
}
uint32 GetData(uint32 uiType)
{
switch(uiType)
{
case TYPE_ARLOKK:
return m_auiEncounter[0];
case TYPE_JEKLIK:
return m_auiEncounter[1];
case TYPE_VENOXIS:
return m_auiEncounter[2];
case TYPE_MARLI:
return m_auiEncounter[3];
case TYPE_THEKAL:
return m_auiEncounter[4];
case TYPE_LORKHAN:
return m_auiEncounter[5];
case TYPE_ZATH:
return m_auiEncounter[6];
case TYPE_OHGAN:
return m_auiEncounter[7];
}
return 0;
}
uint64 GetData64(uint32 uiData)
{
switch(uiData)
{
case DATA_LORKHAN:
return m_uiLorKhanGUID;
case DATA_ZATH:
return m_uiZathGUID;
case DATA_THEKAL:
return m_uiThekalGUID;
case DATA_JINDO:
return m_uiJindoGUID;
}
return 0;
}
};
InstanceScript* GetInstanceScript(InstanceMap* pMap) const
{
return new instance_zulgurub_InstanceMapScript(pMap);
}
};
void AddSC_instance_zulgurub()
{
new instance_zulgurub();
} | [
"sharkipaust@web.de"
] | sharkipaust@web.de |
339d92a59f1c1d6d01f31bed8ff189e6dcf58455 | 3e0725ebd1e7dcb4bb9cb2af7f86a0dceefffa04 | /chrome/browser/vr/ui_scene_constants.h | 70dadfe300ed47e12caa83267df22a77a74b1889 | [
"BSD-3-Clause"
] | permissive | fajarlabs/chromium | 50a25d9240c013d5b266af2bddea973fa01399ea | dec49c8bcb8089e0aebeb7c217276d486a3f4ff4 | refs/heads/master | 2023-01-12T23:47:44.012639 | 2018-04-19T04:15:59 | 2018-04-19T04:15:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,878 | h | // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_VR_UI_SCENE_CONSTANTS_H_
#define CHROME_BROWSER_VR_UI_SCENE_CONSTANTS_H_
#include "ui/gfx/geometry/angle_conversions.h"
namespace vr {
static constexpr float kExitWarningDistance = 0.6f;
static constexpr float kExitWarningTextWidthDMM = 0.44288f;
static constexpr float kExitWarningFontHeightDMM = 0.024576f;
static constexpr float kExitWarningXPaddingDMM = 0.033f;
static constexpr float kExitWarningYPaddingDMM = 0.023f;
static constexpr float kExitWarningCornerRadiusDMM = 0.008f;
static constexpr float kContentDistance = 2.5f;
static constexpr float kContentWidthDMM = 0.96f;
static constexpr float kContentHeightDMM = 0.64f;
static constexpr float kContentWidth = kContentWidthDMM * kContentDistance;
static constexpr float kContentHeight = kContentHeightDMM * kContentDistance;
static constexpr float kContentVerticalOffsetDMM = -0.1f;
static constexpr float kContentVerticalOffset =
kContentVerticalOffsetDMM * kContentDistance;
static constexpr float kContentCornerRadius = 0.005f * kContentWidth;
static constexpr float kContentShadowOffset = 0.09f;
static constexpr float kContentShadowIntesity = 0.4f;
static constexpr float kBackplaneSize = 1000.0f;
static constexpr float kBackgroundDistanceMultiplier = 1.414f;
static constexpr float kFullscreenDistance = 3.0f;
// Make sure that the aspect ratio for fullscreen is 16:9. Otherwise, we may
// experience visual artefacts for fullscreened videos.
static constexpr float kFullscreenHeightDMM = 0.64f;
static constexpr float kFullscreenHeight =
kFullscreenHeightDMM * kFullscreenDistance;
static constexpr float kFullscreenWidth = 1.138f * kFullscreenDistance;
static constexpr float kFullscreenVerticalOffsetDMM = -0.1f;
static constexpr float kFullscreenVerticalOffset =
kFullscreenVerticalOffsetDMM * kFullscreenDistance;
static constexpr float kUrlBarDistance = 2.4f;
static constexpr float kUrlBarHeightDMM = 0.088f;
// This is the non-DMM relative offset of the URL bar. It is used to position
// the DMM root of the URL bar.
static constexpr float kUrlBarRelativeOffset = -0.45f;
// This is the absolute offset of the URL bar's neutral position in DMM.
static constexpr float kUrlBarVerticalOffsetDMM = -0.516f;
static constexpr float kUrlBarRotationRad = gfx::DegToRad(-10.0f);
static constexpr float kUrlBarFontHeightDMM = 0.027f;
static constexpr float kUrlBarButtonSizeDMM = 0.064f;
static constexpr float kUrlBarButtonIconSizeDMM = 0.038f;
static constexpr float kUrlBarEndButtonIconOffsetDMM = 0.0045f;
static constexpr float kUrlBarEndButtonWidthDMM = 0.088f;
static constexpr float kUrlBarSeparatorWidthDMM = 0.002f;
static constexpr float kUrlBarOriginRegionWidthDMM = 0.492f;
static constexpr float kUrlBarOriginRightMarginDMM = 0.020f;
static constexpr float kUrlBarOriginContentOffsetDMM = 0.020f;
static constexpr float kUrlBarItemCornerRadiusDMM = 0.006f;
static constexpr float kUrlBarUrlWidthDMM = kUrlBarOriginRegionWidthDMM -
kUrlBarEndButtonWidthDMM -
kUrlBarOriginRightMarginDMM;
static constexpr float kUrlBarButtonIconScaleFactor =
kUrlBarButtonIconSizeDMM / kUrlBarButtonSizeDMM;
static constexpr float kIndicatorHeightDMM = 0.064f;
static constexpr float kIndicatorIconScaleFactor = 0.55f;
static constexpr float kIndicatorXPaddingDMM = 0.024f;
static constexpr float kIndicatorYPaddingDMM = 0.018f;
static constexpr float kIndicatorCornerRadiusDMM = 0.006f;
static constexpr float kIndicatorOffsetDMM = -0.008f;
static constexpr float kIndicatorMarginDMM = 0.001f;
static constexpr float kIndicatorVerticalOffset = 0.1f;
static constexpr float kIndicatorDistanceOffset = 0.1f;
static constexpr float kIndicatorDepth = 2.4f;
static constexpr float kWebVrToastDistance = 1.0f;
static constexpr float kToastXPaddingDMM = 0.017f;
static constexpr float kToastYPaddingDMM = 0.02f;
static constexpr float kToastCornerRadiusDMM = 0.004f;
static constexpr float kToastTextFontHeightDMM = 0.023f;
static constexpr int kToastTimeoutSeconds = 6;
static constexpr float kPlatformToastVerticalOffset = 0.5f;
static constexpr float kSplashScreenTextDistance = 2.5f;
static constexpr float kSplashScreenTextFontHeightDMM = 0.05f;
static constexpr float kSplashScreenTextWidthDMM = 0.9f;
static constexpr float kSplashScreenTextVerticalOffsetDMM = -0.072f;
static constexpr float kSplashScreenMinDurationSeconds = 2.0f;
static constexpr float kButtonDiameterDMM = 0.088f;
static constexpr float kButtonZOffsetHoverDMM = 0.048f;
static constexpr float kCloseButtonDistance = 2.4f;
static constexpr float kCloseButtonRelativeOffset = -0.8f;
static constexpr float kCloseButtonVerticalOffset =
kFullscreenVerticalOffset - (kFullscreenHeight * 0.5f) - 0.35f;
static constexpr float kCloseButtonDiameter =
kButtonDiameterDMM * kCloseButtonDistance;
static constexpr float kCloseButtonFullscreenDistance = 2.9f;
static constexpr float kCloseButtonFullscreenVerticalOffset =
kFullscreenVerticalOffset - (kFullscreenHeight / 2) - 0.35f;
static constexpr float kCloseButtonFullscreenDiameter =
kButtonDiameterDMM * kCloseButtonFullscreenDistance;
static constexpr float kLoadingIndicatorWidthDMM = 0.24f;
static constexpr float kLoadingIndicatorHeightDMM = 0.008f;
static constexpr float kLoadingIndicatorVerticalOffsetDMM =
(-kUrlBarVerticalOffsetDMM + kContentVerticalOffsetDMM -
kContentHeightDMM / 2 - kUrlBarHeightDMM / 2) /
2;
static constexpr float kSceneSize = 25.0f;
static constexpr float kSceneHeight = 4.0f;
static constexpr int kFloorGridlineCount = 40;
static constexpr float kVoiceSearchCloseButtonDiameterDMM = 0.096f;
static constexpr float kVoiceSearchCloseButtonDiameter =
kVoiceSearchCloseButtonDiameterDMM * kContentDistance;
static constexpr float kVoiceSearchCloseButtonYOffset =
0.316f * kContentDistance + 0.5f * kVoiceSearchCloseButtonDiameter;
static constexpr float kVoiceSearchRecognitionResultTextHeight =
0.026f * kContentDistance;
static constexpr float kVoiceSearchRecognitionResultTextWidth =
0.4f * kContentDistance;
static constexpr float kTimeoutScreenDisatance = 2.5f;
static constexpr float kTimeoutSpinnerSizeDMM = 0.088f;
static constexpr float kTimeoutSpinnerVerticalOffsetDMM =
kSplashScreenTextVerticalOffsetDMM;
static constexpr float kTimeoutMessageHorizontalPaddingDMM = 0.04f;
static constexpr float kTimeoutMessageVerticalPaddingDMM = 0.024f;
static constexpr float kTimeoutMessageCornerRadiusDMM = 0.008f;
static constexpr float kTimeoutMessageLayoutGapDMM = 0.024f;
static constexpr float kTimeoutMessageIconWidthDMM = 0.056f;
static constexpr float kTimeoutMessageIconHeightDMM = 0.056f;
static constexpr float kTimeoutMessageTextFontHeightDMM = 0.022f;
static constexpr float kTimeoutMessageTextHeightDMM = 0.056f;
static constexpr float kTimeoutMessageTextWidthDMM = 0.4f;
static constexpr float kTimeoutButtonDepthOffset = -0.1f;
static constexpr float kTimeoutButtonRotationRad = kUrlBarRotationRad;
static constexpr float kWebVrTimeoutMessageButtonDiameterDMM = 0.096f;
static constexpr float kTimeoutButtonTextWidthDMM = 0.058f;
static constexpr float kTimeoutButtonTextHeightDMM = 0.024f;
static constexpr float kTimeoutButtonTextVerticalOffsetDMM = 0.024f;
static constexpr float kHostedUiHeightRatio = 0.6f;
static constexpr float kHostedUiWidthRatio = 0.6f;
static constexpr float kHostedUiDepthOffset = 0.3f;
static constexpr float kFloatingHostedUiDistance = 0.01f;
static constexpr float kScreenDimmerOpacity = 0.9f;
static constexpr gfx::Point3F kOrigin = {0.0f, 0.0f, 0.0f};
static constexpr float kLaserWidth = 0.01f;
static constexpr float kReticleWidth = 0.025f;
static constexpr float kReticleHeight = 0.025f;
static constexpr float kOmniboxWidthDMM = 0.848f;
static constexpr float kOmniboxHeightDMM = 0.088f;
static constexpr float kOmniboxVerticalOffsetDMM = -0.2f;
static constexpr float kOmniboxTextHeightDMM = 0.032f;
static constexpr float kOmniboxTextMarginDMM = 0.024f;
static constexpr float kOmniboxCloseButtonDiameterDMM = kButtonDiameterDMM;
static constexpr float kOmniboxCloseButtonVerticalOffsetDMM = -0.75f;
static constexpr float kOmniboxCornerRadiusDMM = 0.006f;
static constexpr float kOmniboxCloseButtonDepthOffset = -0.35f;
static constexpr float kOmniboxShadowOffset = 0.07f;
static constexpr float kOmniboxShadowIntensity = 0.4f;
static constexpr int kOmniboxTransitionMs = 300;
static constexpr float kOmniboxTextFieldIconButtonSizeDMM = 0.064f;
static constexpr float kUrlBarButtonHoverOffsetDMM = 0.012f;
static constexpr float kOmniboxTextFieldRightMargin =
((kOmniboxHeightDMM - kOmniboxTextFieldIconButtonSizeDMM) / 2);
static constexpr float kSuggestionHeightDMM = 0.088f;
static constexpr float kSuggestionGapDMM = 0.0018f;
static constexpr float kSuggestionLineGapDMM = 0.01f;
static constexpr float kSuggestionIconSizeDMM = 0.036f;
static constexpr float kSuggestionIconFieldWidthDMM = 0.104f;
static constexpr float kSuggestionRightMarginDMM = 0.024f;
static constexpr float kSuggestionTextFieldWidthDMM =
kOmniboxWidthDMM - kSuggestionIconFieldWidthDMM - kSuggestionRightMarginDMM;
static constexpr float kSuggestionContentTextHeightDMM = 0.024f;
static constexpr float kSuggestionDescriptionTextHeightDMM = 0.020f;
static constexpr float kSuggestionVerticalPaddingDMM = 0.008f;
static constexpr int kControllerFadeInMs = 200;
static constexpr int kControllerFadeOutMs = 550;
static constexpr float kSpeechRecognitionResultTextYOffset = 0.5f;
static constexpr int kSpeechRecognitionResultTimeoutSeconds = 2;
static constexpr int kSpeechRecognitionOpacityAnimationDurationMs = 200;
static constexpr float kModalPromptFadeOpacity = 0.5f;
static constexpr float kKeyboardDistance = 2.2f;
static constexpr float kKeyboardVerticalOffsetDMM = -0.45f;
static constexpr float kKeyboardWebInputOffset = 1.2f;
static constexpr float kSnackbarDistance = 1.5f;
static constexpr float kSnackbarAngle = -gfx::DegToRad(34.0f);
static constexpr float kSnackbarPaddingDMM = 0.032f;
static constexpr float kSnackbarIconWidthDMM = 0.034f;
static constexpr float kSnackbarFontHeightDMM = 0.024f;
static constexpr float kSnackbarHeightDMM = 0.08f;
static constexpr float kSnackbarMoveInAngle = -base::kPiFloat / 10;
static constexpr int kSnackbarTransitionDurationMs = 300;
static constexpr float kControllerLabelSpacerSize = 0.025f;
static constexpr float kControllerLabelLayoutMargin = -0.005f;
static constexpr float kControllerLabelCalloutWidth = 0.02f;
static constexpr float kControllerLabelCalloutHeight = 0.001f;
static constexpr float kControllerLabelFontHeight = 0.05f;
static constexpr float kControllerLabelScale = 0.2f;
// TODO(vollick): these should be encoded in the controller mesh.
static constexpr float kControllerTrackpadOffset = -0.035f;
static constexpr float kControllerExitButtonOffset = -0.008f;
static constexpr float kControllerBackButtonOffset = -0.008f;
static constexpr int kControllerLabelTransitionDurationMs = 700;
static constexpr float kControllerWidth = 0.035f;
static constexpr float kControllerHeight = 0.016f;
static constexpr float kControllerLength = 0.105f;
static constexpr float kControllerSmallButtonSize = kControllerWidth * 0.306f;
static constexpr float kControllerAppButtonZ = kControllerLength * -0.075f;
static constexpr float kControllerHomeButtonZ = kControllerLength * 0.075f;
static constexpr float kSkyDistance = 1000.0f;
static constexpr float kGridOpacity = 0.5f;
static constexpr float kRepositionContentOpacity = 0.2f;
static constexpr float kWebVrPermissionCornerRadius = 0.006f;
static constexpr float kWebVrPermissionLeftPadding = 0.024f;
static constexpr float kWebVrPermissionRightPadding = 0.032f;
static constexpr float kWebVrPermissionTopPadding = 0.026f;
static constexpr float kWebVrPermissionBottomPadding = 0.026f;
static constexpr float kWebVrPermissionMargin = 0.016f;
static constexpr float kWebVrPermissionIconSize = 0.034f;
static constexpr float kWebVrPermissionFontHeight = 0.024f;
static constexpr float kWebVrPermissionTextWidth = 0.380f;
static constexpr float kWebVrPermissionOuterMargin = 0.008f;
static constexpr float kWebVrPermissionDepth = 0.015f;
static constexpr float kWebVrPermissionOffsetStart = 0.3f;
static constexpr float kWebVrPermissionOffsetOvershoot = -0.01f;
static constexpr float kWebVrPermissionOffsetFinal = 0.0f;
static constexpr int kWebVrPermissionOffsetMs = 250;
static constexpr int kWebVrPermissionAnimationDurationMs = 750;
static constexpr float kPromptWidthDMM = 0.63f;
static constexpr float kPromptHeightDMM = 0.218f;
static constexpr float kPromptVerticalOffsetDMM = -0.1f;
static constexpr float kPromptShadowOffsetDMM = 0.1f;
static constexpr float kPromptDistance = 2.4f;
static constexpr float kRepositionCursorBackgroundSize = 1.85f;
static constexpr float kRepositionCursorSize = 1.5f;
static constexpr float kMinResizerScale = 0.5f;
static constexpr float kMaxResizerScale = 1.5f;
static constexpr float kRepositionFrameTopPadding = 0.25f;
static constexpr float kRepositionFrameEdgePadding = 0.04f;
static constexpr float kRepositionFrameHitPlaneTopPadding = 0.5f;
static constexpr float kRepositionFrameTransitionDurationMs = 300;
static constexpr float kOverflowMenuOffset = 0.016f;
static constexpr float kOverflowMenuMinimumWidth = 0.312f;
static constexpr float kOverflowButtonRegionHeight = 0.088f;
static constexpr float kOverflowButtonXOffset = 0.016f;
static constexpr float kOverflowMenuYPadding = 0.012f;
static constexpr float kOverflowMenuItemHeight = 0.080f;
static constexpr float kOverflowMenuItemXPadding = 0.024f;
} // namespace vr
#endif // CHROME_BROWSER_VR_UI_SCENE_CONSTANTS_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
567b5fe53f63d1c6732f4b6576ac26fa2a5f7bfc | 268775f0cb11043637273305dbb7e3c61a09f42a | /chocoblack.h | 5965a024042e1e988e8606389d18e12af618cc7c | [] | no_license | Sevenium/ChocolateFactory | d4312d24a46f875827d91f47019a4b44c3cd52f7 | 0731f31edc33cd3eb7f9253411eec2aa73b0b9ab | refs/heads/master | 2020-09-30T00:58:49.318654 | 2019-12-10T16:11:27 | 2019-12-10T16:11:27 | 227,161,809 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 233 | h | #ifndef CHOCOBLACK_H
#define CHOCOBLACK_H
#include "chocolate.h"
// SubClass of Chocolate with real values
class ChocoBlack : public Chocolate
{
public:
ChocoBlack():Chocolate("Black",100,160,10,90){}
};
#endif // CHOCOBLACK_H
| [
"bryanhardy@hotmail.fr"
] | bryanhardy@hotmail.fr |
bb29049e91202ff876eab9978357858985addbb9 | eab27b0a2cf9e4ea42ba305c771bd4272a58a518 | /src/cloud_filters/radius_outlier_removal.cpp | a9d2cf91212c8ee10d88e561106a5ecbfc7d478e | [
"BSD-3-Clause"
] | permissive | myalfred03/dynamic_robot_localization | fa1ce87d23dba8f40d763bac73aec53d6e74b9c8 | d26e4563ab98171ae724a527a2c63d1b1abb1843 | refs/heads/kinetic-devel | 2020-04-03T14:28:48.608738 | 2018-10-17T17:48:36 | 2018-10-17T17:48:36 | 155,323,125 | 0 | 0 | BSD-3-Clause | 2019-01-12T22:57:23 | 2018-10-30T04:12:11 | C++ | UTF-8 | C++ | false | false | 1,262 | cpp | /**\file radius_outlier_removal.cpp
* \brief Description...
*
* @version 1.0
* @author Carlos Miguel Correia da Costa
*/
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <includes> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <dynamic_robot_localization/common/common.h>
#include <dynamic_robot_localization/cloud_filters/impl/radius_outlier_removal.hpp>
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> </includes> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <template instantiations> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#ifndef DRL_NO_PRECOMPILE
#include <pcl/impl/instantiate.hpp>
#include <pcl/point_types.h>
#define PCL_INSTANTIATE_DRLRadiusOutlierRemoval(T) template class PCL_EXPORTS dynamic_robot_localization::RadiusOutlierRemoval<T>;
PCL_INSTANTIATE(DRLRadiusOutlierRemoval, DRL_POINT_TYPES)
#endif
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> </template instantiations> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
| [
"carloscosta.cmcc@gmail.com"
] | carloscosta.cmcc@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.