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 986
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 23
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 145
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 122
values | content
stringlengths 3
10.4M
| authors
listlengths 1
1
| author_id
stringlengths 0
158
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
69671355810a4992b2d4bacda0ebfecba7206ff1
|
c2915484a4fe848b9bfee6bfb65f824993dde59b
|
/Case_save/Case30/case8/0/T
|
0c25eef2292295ac650b664624ad73602a0d4f95
|
[] |
no_license
|
mamitsu2/aircond5_play3
|
835b937da2d60771b8a7b81e13631a8a1271e8f4
|
8eee217855014d562013e0dbe0024208a4633db3
|
refs/heads/master
| 2020-05-24T21:54:50.022678
| 2019-05-19T13:31:37
| 2019-05-19T13:31:37
| 187,480,539
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,530
|
// -*- C++ -*-
// File generated by PyFoam - sorry for the ugliness
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object T;
}
dimensions [ 0 0 0 1 0 0 0 ];
internalField uniform 299.6857070159724;
boundaryField
{
floor
{
type wallHeatTransfer;
Tinf uniform 305.2;
alphaWall uniform 0.24;
value uniform 306;
}
ceiling
{
type wallHeatTransfer;
Tinf uniform 303.2;
alphaWall uniform 0.24;
value uniform 306;
}
sWall
{
type wallHeatTransfer;
Tinf uniform 315.2;
alphaWall uniform 0.36;
value uniform 306;
}
nWall
{
type wallHeatTransfer;
Tinf uniform 307.2;
alphaWall uniform 0.36;
value uniform 306;
}
sideWalls
{
type empty;
}
outlet
{
type zeroGradient;
}
inlet
{
type fixedValue;
value uniform 293.15;
}
glass1
{
type wallHeatTransfer;
Tinf uniform 315.2;
alphaWall uniform 4.3;
value uniform 306;
}
glass2
{
type wallHeatTransfer;
Tinf uniform 307.2;
alphaWall uniform 4.3;
value uniform 306;
}
sun
{
type wallHeatTransfer;
Tinf uniform 305.2;
alphaWall uniform 0.24;
value uniform 306;
}
heatsource1
{
type fixedGradient;
gradient uniform 0;
}
heatsource2
{
type fixedGradient;
gradient uniform 0;
}
Table_master
{
type zeroGradient;
}
Table_slave
{
type zeroGradient;
}
} // ************************************************************************* //
|
[
"mitsuaki.makino@tryeting.jp"
] |
mitsuaki.makino@tryeting.jp
|
|
e2fb36ebc0b044f369f3466e62648b92309d5394
|
36cf28ec4cdc16d4a361b5463c11f3f5e95fe21e
|
/trunk/GemCell.h
|
afa423b28a4395d6f9192c89f6a1e201a9651edb
|
[] |
no_license
|
elricbk/freejeweled
|
920b4e8843cf7b22b7e86ddd79ccc5a9f05351b1
|
073a437292003fcc5ee86bd2310f208eb24b7e15
|
refs/heads/master
| 2021-01-18T15:21:45.514680
| 2013-05-03T22:07:05
| 2013-05-03T22:07:05
| 9,845,249
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,339
|
h
|
#ifndef GEMCELL_H
#define GEMCELL_H
#include <QDeclarativeItem>
class GemCell : public QDeclarativeItem
{
Q_OBJECT
Q_PROPERTY(bool behaviorEnabled READ behaviorEnabled WRITE setBehaviorEnabled NOTIFY behaviorEnabledChanged)
Q_PROPERTY(bool timeToDie READ timeToDie WRITE setTimeToDie NOTIFY timeToDieChanged)
Q_PROPERTY(bool shouldBeRemoved READ shouldBeRemoved WRITE setShouldBeRemoved NOTIFY shouldBeRemovedChanged)
Q_PROPERTY(bool explodedOnce READ explodedOnce WRITE setExplodedOnce NOTIFY explodedOnceChanged)
Q_PROPERTY(bool invincible READ invincible WRITE setInvincible)
Q_PROPERTY(Modifier modifier READ modifier WRITE setModifier NOTIFY modifierChanged)
Q_ENUMS(Modifier)
public:
enum Modifier {
Normal,
Explosive,
HyperCube,
RowColumnRemove
};
explicit GemCell(QDeclarativeItem *parent = 0);
~GemCell() {}
bool behaviorEnabled() const { return m_behaviorEnabled; }
void setBehaviorEnabled(bool newValue) { if (newValue != m_behaviorEnabled) { m_behaviorEnabled = newValue; emit behaviorEnabledChanged(); } }
bool timeToDie() const { return m_timeToDie; }
void setTimeToDie(bool newValue) { if (newValue != m_timeToDie) { m_timeToDie = newValue; emit timeToDieChanged(); } }
bool shouldBeRemoved() const { return m_shouldBeRemoved; }
void setShouldBeRemoved(bool newValue) { if (newValue != m_shouldBeRemoved) { m_shouldBeRemoved = newValue; emit shouldBeRemovedChanged(); } }
bool explodedOnce() const { return m_explodedOnce; }
void setExplodedOnce(bool newValue) { if (newValue != m_explodedOnce) { m_explodedOnce = newValue; emit explodedOnceChanged(); } }
bool invincible() { return m_invincible; }
void setInvincible(bool newValue) { if (m_invincible != newValue) m_invincible = newValue; }
Modifier modifier() { return m_modifier; }
void setModifier(Modifier newValue);
signals:
void behaviorEnabledChanged();
void timeToDieChanged();
void shouldBeRemovedChanged();
void explodedOnceChanged();
void modifierChanged();
private:
bool m_behaviorEnabled;
bool m_timeToDie;
bool m_shouldBeRemoved;
bool m_explodedOnce;
bool m_invincible;
Modifier m_modifier;
};
#endif // GEMCELL_H
|
[
"elricbk@gmail.com"
] |
elricbk@gmail.com
|
bcf2ec0ca987ff56c04c31df4df6759da0c03949
|
3cda2503c12f55e6fe50c671f651ee46bd73492f
|
/simdpp/core/i_reduce_add.h
|
869cea8ebd5e8bb9fa6389c30d2f8c50b05d4b94
|
[
"BSL-1.0",
"LicenseRef-scancode-proprietary-license",
"CC-BY-4.0"
] |
permissive
|
p12tic/libsimdpp
|
f59937921a3eda472ff41a7ee981158ccf326a96
|
16878c9a877aca6022270176738fb5046ed25aa5
|
refs/heads/master
| 2023-08-28T20:44:57.495397
| 2023-02-01T14:59:45
| 2023-02-01T14:59:45
| 9,942,292
| 1,106
| 149
|
BSL-1.0
| 2023-02-01T14:59:47
| 2013-05-08T17:45:25
|
C++
|
UTF-8
|
C++
| false
| false
| 1,941
|
h
|
/* Copyright (C) 2016 Povilas Kanapickas <povilas@radix.lt>
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef LIBSIMDPP_SIMDPP_CORE_I_REDUCE_ADD_H
#define LIBSIMDPP_SIMDPP_CORE_I_REDUCE_ADD_H
#ifndef LIBSIMDPP_SIMD_H
#error "This file must be included through simd.h"
#endif
#include <simdpp/types.h>
#include <simdpp/detail/insn/i_reduce_add.h>
namespace simdpp {
namespace SIMDPP_ARCH_NAMESPACE {
/** Computes the sum of the elements in the vector. Intermediate and the
final result has twice as many bits as the input element size in 8 and 16
bit cases.
@code
r0 = a0 + a1 + a2 + ...
@endcode
*/
template<unsigned N, class E> SIMDPP_INL
int16_t reduce_add(const int8<N,E>& a)
{
return detail::insn::i_reduce_add(a.eval());
}
template<unsigned N, class E> SIMDPP_INL
uint16_t reduce_add(const uint8<N,E>& a)
{
return detail::insn::i_reduce_add(a.eval());
}
template<unsigned N, class E> SIMDPP_INL
int32_t reduce_add(const int16<N,E>& a)
{
return detail::insn::i_reduce_add(a.eval());
}
template<unsigned N, class E> SIMDPP_INL
uint32_t reduce_add(const uint16<N,E>& a)
{
return detail::insn::i_reduce_add(a.eval());
}
template<unsigned N, class E> SIMDPP_INL
int32_t reduce_add(const int32<N,E>& a)
{
return detail::insn::i_reduce_add(uint32<N>(a.eval()));
}
template<unsigned N, class E> SIMDPP_INL
uint32_t reduce_add(const uint32<N,E>& a)
{
return detail::insn::i_reduce_add(a.eval());
}
template<unsigned N, class E> SIMDPP_INL
int64_t reduce_add(const int64<N,E>& a)
{
return detail::insn::i_reduce_add(uint64<N>(a.eval()));
}
template<unsigned N, class E> SIMDPP_INL
uint64_t reduce_add(const uint64<N,E>& a)
{
return detail::insn::i_reduce_add(a.eval());
}
} // namespace SIMDPP_ARCH_NAMESPACE
} // namespace simdpp
#endif
|
[
"povilas@radix.lt"
] |
povilas@radix.lt
|
b19b2933de74549dec5827e1d703ac87323ee215
|
f14910e3dfad38d48a1643a794bc0a2b36363a52
|
/TANJAN.cpp
|
184b762b928fed3204efd302c31dc608a9eb6899
|
[] |
no_license
|
Nayaco/Oiplayer
|
8ed599c40ab0ff9db1e80cb6bc7db2e3fd5d316c
|
ac24a4ca22e3b2e9f574a42100ce5c2635c3cd6a
|
refs/heads/master
| 2021-04-15T06:54:34.643883
| 2018-06-13T12:02:40
| 2018-06-13T12:06:42
| 126,854,835
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 388
|
cpp
|
#include <cstdio>
using namespace std;
const int MAX_N = 1005,MAX_M = 100005;
int LEN[MAX_M], V[MAX_M], HEAD[MAX_N], NEXT[MAX_M], VIS[MAX_N], DIST[MAX_N];
int DNF[MAX_N], LOW[MAX_N], TIME;
int ANS[MAX_N];
int stack[MAX_N], stk_len;
int tot, n, m;
void ADD(int a,int b){...}
void TANJAN_DFS(int x){
if(DNF[x] == LOW[x]){
}
for(int i = HEAD[x]; i; i= NEXT[i]){
}
}
|
[
"1194329594@qq,com"
] |
1194329594@qq,com
|
cf571241e5baf0060a7a90fedaba2968d8ca5095
|
9a0fca3d10d30fbb0b45d6832f99323134876d61
|
/ProgramPearls/11.5.11_Qsort_PartitionOnFatPivot.cc
|
02a8390ab737dfcbfd40959e1b18fc77ed0a5f94
|
[] |
no_license
|
YulongWu/AlgoExercise_CPP
|
1ef4f061c25fffa6313ef0abdedcf4dc48175a4c
|
9c5f6621988ce3b15394e7a5d5b949f87e0d6265
|
refs/heads/master
| 2020-12-24T16:24:59.954398
| 2019-05-28T02:48:29
| 2019-05-28T02:48:29
| 5,934,820
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,936
|
cc
|
/* Following is the answers of problem 11 in section 11.5 of "Programming Pearls"
*/
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
int partition(vector<int> a, int len) {
if(len < 1)
return -1;
if(len == 1)
return 0;
int t = a[0];
int i = 0, j = len, it = -1, jt = len;
while(i < j) {
while(--j > i) {
if(a[j] == t)
swap(a[j], a[--jt]);
else if(a[j] < t)
break;
}
if(i < j) a[i] = a[j];
while(++i < j) {
if(a[i] == t)
swap(a[i], a[++it]);
else if(a[i] > t)
break;
}
if(i < j) a[j] = a[i];
}
a[j] = t;
for(int ii = j-1; ii >= j-it-1; --ii)
swap(a[ii], a[j-ii-1]);
for(int jj = j+1; jj <= j+len-jt; ++jj)
swap(a[jj], a[len - (jj - j)]);
printf("\t\t");
for(int i=0; i<len; ++i)
printf("%d, ", a[i]);
printf("\n");
return j;
}
/*This version 2 is modified based on the program on p223 select1 function*/
int partition_v2(vector<int> a, int len) {
if(len < 1)
return -1;
int t = a[0];
int i = -1, j = len, it = -1, jt = len;
while(true) {
while(a[--j] >= t && j > 0) {
if(a[j] == t)
swap(a[j], a[--jt]);
}
while(a[++i] <= t && i <= j) {
if(a[i] == t)
swap(a[i], a[++it]);
}
if(i <= j) swap(a[i], a[j]);
else break;
}
//printf("i=%2d, j=%2d, it=%2d, jt=%2d\n", i, j, it, jt);
for(int ii=j; ii >= j - it && ii > it; --ii)
swap(a[ii], a[j - ii]);
for(int jj=i; jj < i + len - jt; ++jj)
swap(a[jj], a[len - jj + i - 1]);
printf("\t\t");
for(int i=0; i<len; ++i)
printf("%d, ", a[i]);
printf("\n");
return j;
}
static const int TEST_NUM = 6;
int main() {
vector<int>* cases[TEST_NUM] = {0};
int c1[] = {7,5,8,7,12,-3};
cases[0] = new vector<int>(c1, c1 + sizeof(c1) / sizeof(int));
int c2[] = {5,3,3,3};
cases[1] = new vector<int>(c2, c2 + sizeof(c2) / sizeof(int));
int c3[] = {5,6,6,6};
cases[2] = new vector<int>(c3, c3 + sizeof(c3) / sizeof(int));
int c4[] = {5,5,5,3};
cases[3] = new vector<int>(c4, c4 + sizeof(c4) / sizeof(int));
int c5[] = {3,5,5,5};
cases[4] = new vector<int>(c5, c5 + sizeof(c5) / sizeof(int));
int c6[] = {5,6,5,3};
cases[5] = new vector<int>(c6, c6 + sizeof(c6) / sizeof(int));
for(int c=0; c < TEST_NUM; ++c) {
printf(" Test cases %d:\n", c);
printf(" Original:\n");
printf("\t\t");
for(int i=0; i<cases[c]->size(); ++i)
printf("%d, ", (*cases[c])[i]);
printf("\n");
printf(" v1:\n");
partition(*cases[c], cases[c]->size());
printf(" v2:\n");
partition_v2(*cases[c], cases[c]->size());
}
}
|
[
"wylong.0221@gmail.com"
] |
wylong.0221@gmail.com
|
6a44e5978256efe14af0ecc58ca8c06d08df0b42
|
eb64729627e117af9edcf7352ebc826733045d8f
|
/ProxyServer/ProxyServer.h
|
4e5c3a1de0d6d3e1570183c32395a3655f81fb3a
|
[] |
no_license
|
hpnvphuoc/ProxyServer
|
4b082c3cbba41041e43dff9cf254c696bbb3f2df
|
5fdb0441a9f6a9f5049d9e6415e26afd7950b643
|
refs/heads/master
| 2023-02-09T06:38:39.974769
| 2021-01-01T23:38:32
| 2021-01-01T23:38:32
| 317,762,865
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,427
|
h
|
#pragma once
#define _CRT_SECURE_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include "afxsock.h"
#include <iostream>
#include <fstream>
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define HTTPPORT 80
#define PROXYPORT 8888
#define BUFFERSIZE 40960
char forbidden[46] = "HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n";
//Định danh của chương trình
CWinApp ProxyServer;
//Đường hầm proxy ảo cho kết nối của một cặp client - proxy
struct ProxyTunnel
{
SOCKET clientSide;
SOCKET serverSide;
bool isClientSideOpening;
bool isServerSideOpening;
char host[256]; //Địa chỉ của server, có thể là domain name hoặc địa chỉ IP
HANDLE shakingDone; //Sự kiện (có thể gọi là cờ lệnh, dấu hiệu,...) đã bắt tay với server
};
SOCKET TCPListen; //Socket lắng nghe kết nối
char blacklist[BUFFERSIZE];
//Hàm khởi động proxy server
int StartProxy();
//Hàm kết thúc proxy server
void StopProxy();
//Hàm tải blacklist.conf
void LoadBlacklist(char* blacklist);
//Hàm kiểm tra blacklist
bool isForbidden(char* blacklist, char* host);
//Thread truyền data lên server
UINT Upstream(LPVOID arg);
//Thread truyền data xuống client
UINT Downstream(LPVOID arg);
//Hàm lấy host trong request
int GetHost(char* buffer, char* host);
//Hàm lấy thông tin server
hostent* GetServerInfo(char* host);
|
[
"hpnvphuoc@gmail.com"
] |
hpnvphuoc@gmail.com
|
b0e28991dc63877f7ac60a94a8519ea169845749
|
8d769392c7e600364afaadd689d147b5fad73fa7
|
/src/mem_sync/data_api/kv_reg_mgr.cpp
|
d2a4c2db237b21f0ba0dd5d5202806580240a2cd
|
[] |
no_license
|
P79N6A/dp
|
15452e97eb5fbadc64eae97824dbc664fffc8a21
|
678f69424a876f7f3e2f9567cffe7fb44582f28f
|
refs/heads/master
| 2021-06-09T16:41:47.654789
| 2016-12-30T10:00:26
| 2016-12-30T10:00:26
| 198,253,216
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,572
|
cpp
|
#include "kv_reg_mgr.h"
#include <string.h>
#include "log.h"
#include "reg_zk_data.h"
#include "shm.h"
#include "mem_kv/mem_kv.h"
#define HASH_CAP (1 << 20)
namespace poseidon
{
namespace mem_sync
{
KVRegMgr::KVRegMgr()
{
_cap = HASH_CAP;
_regzk = NULL;
_kvtb = NULL;
}
KVRegMgr::~KVRegMgr()
{
if (_kvtb != NULL) delete _kvtb;
}
int KVRegMgr::init(const std::string &zklist, int dataserver_port)
{
int r = 0;
if (_regzk == NULL) {
_regzk = &RegZKData::get_mutable_instance();
r = _regzk->init(zklist, dataserver_port);
}
return r;
}
int KVRegMgr::init(const std::string &zklist, const std::string &dataserver_ip,
int dataserver_port)
{
int r = 0;
if (_regzk == NULL) {
_regzk = &RegZKData::get_mutable_instance();
r = _regzk->init(zklist, dataserver_ip, dataserver_port);
}
return r;
}
int KVRegMgr::put(const std::string &key, const std::string &val)
{
return put(key.size(), key.data(), val.size(), val.data());
}
int KVRegMgr::put(size_t key_size, const char *key, size_t val_size, const char *val)
{
if (key == NULL || val == NULL) {
LOG_ERROR("invalid arguments");
return -1;
}
if (_kvtb == NULL) {
_kvtb = new MemKV(_cap);
}
return _kvtb->put(key_size, key, val_size, val);
}
void KVRegMgr::reset()
{
if (_kvtb != NULL) {
delete _kvtb;
_kvtb = NULL;
}
}
int KVRegMgr::reg_data(int data_id)
{
int r = 0, shm_key;
char *shm_ptr = NULL;
if (_kvtb == NULL || _regzk == NULL) {
LOG_ERROR("invalid arguments");
return -1;
}
if (data_id <= 0) {
LOG_ERROR("negtive data_id=%d", data_id);
return -1;
}
do {
size_t shm_size = _kvtb->calc_seri_size();
shm_ptr = (char *)_regzk->get_new_shm(data_id, shm_key, shm_size);
if (shm_ptr == NULL) {
r = -3;
break;
}
r = _kvtb->serialize((char *)shm_ptr, shm_size);
if (r != 0) {
r = -4;
break;
}
r = _regzk->reg_data(data_id, shm_key, shm_ptr, shm_size);
} while(0);
delete _kvtb;
_kvtb = NULL;
if (r < 0) {
LOG_ERROR("reg fail, rc=%d", r);
if (shm_ptr != NULL) {
util::shm::ShmDetach(shm_ptr);
util::shm::ShmDelete(shm_key, 1);
}
}
return r;
}
}
}
|
[
"joerong666@126.com"
] |
joerong666@126.com
|
42e15f451d1f6280a9983592dc5359b0020322da
|
c5373a8beb34d9572c97452cf6bf4d750109abc9
|
/Timus/practice/1005.cpp
|
7edbc3dc8c99491636c08e7473aee64ff8cac847
|
[] |
no_license
|
Jellylover11/CP-code-dump
|
8f95c4bf093dcba5ce2f3b727da709633712b5b1
|
003a7a60c160685a160d5db22bc4a6873778ded9
|
refs/heads/main
| 2023-09-05T11:29:16.687503
| 2021-10-30T12:37:24
| 2021-10-30T12:37:24
| 417,556,461
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 442
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int arr[22];
int ans;
int sum=0;
int n;
int main()
{
cin>>n;
for(int j=0;j<n;j++)
{
cin>>arr[j];
sum=sum+arr[j];
}
ans=sum;
for(int mask=0; mask<(1<<n); mask++)
{
int s=0;
for(int k=0; k<n;++k)
{
if((1<<k)&mask) s+=arr[k];
}
ans= min(ans, abs(sum-s*2) );
}
cout<<ans;
}
|
[
"shohid138718@gmail.com"
] |
shohid138718@gmail.com
|
4665e8de33d89c2c147273157f22de8974442214
|
abe694a6883c7c3b82f8035798b435cd36fc3911
|
/libs/ceres/include-osx/ceres/internal/line_parameterization.h
|
eda390148df9b5de170f2d2c2b867941c865399d
|
[
"MIT"
] |
permissive
|
elliotwoods/ofxCeres
|
13a6da24b8ca7a8ba9b600cb974ba7acd3861d40
|
d9cd0d9d70b08b3c1b9b62b71429ea269ab288dd
|
refs/heads/master
| 2023-04-17T13:46:05.729535
| 2023-04-07T08:58:42
| 2023-04-07T08:58:42
| 182,985,199
| 24
| 7
|
MIT
| 2022-08-03T02:26:03
| 2019-04-23T09:50:00
|
C++
|
UTF-8
|
C++
| false
| false
| 7,044
|
h
|
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2020 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of Google Inc. nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Author: jodebo_beck@gmx.de (Johannes Beck)
//
#ifndef CERES_PUBLIC_INTERNAL_LINE_PARAMETERIZATION_H_
#define CERES_PUBLIC_INTERNAL_LINE_PARAMETERIZATION_H_
#include "householder_vector.h"
namespace ceres {
template <int AmbientSpaceDimension>
bool LineParameterization<AmbientSpaceDimension>::Plus(
const double* x_ptr,
const double* delta_ptr,
double* x_plus_delta_ptr) const {
// We seek a box plus operator of the form
//
// [o*, d*] = Plus([o, d], [delta_o, delta_d])
//
// where o is the origin point, d is the direction vector, delta_o is
// the delta of the origin point and delta_d the delta of the direction and
// o* and d* is the updated origin point and direction.
//
// We separate the Plus operator into the origin point and directional part
// d* = Plus_d(d, delta_d)
// o* = Plus_o(o, d, delta_o)
//
// The direction update function Plus_d is the same as for the homogeneous
// vector parameterization:
//
// d* = H_{v(d)} [0.5 sinc(0.5 |delta_d|) delta_d, cos(0.5 |delta_d|)]^T
//
// where H is the householder matrix
// H_{v} = I - (2 / |v|^2) v v^T
// and
// v(d) = d - sign(d_n) |d| e_n.
//
// The origin point update function Plus_o is defined as
//
// o* = o + H_{v(d)} [0.5 delta_o, 0]^T.
static constexpr int kDim = AmbientSpaceDimension;
using AmbientVector = Eigen::Matrix<double, kDim, 1>;
using AmbientVectorRef = Eigen::Map<Eigen::Matrix<double, kDim, 1>>;
using ConstAmbientVectorRef =
Eigen::Map<const Eigen::Matrix<double, kDim, 1>>;
using ConstTangentVectorRef =
Eigen::Map<const Eigen::Matrix<double, kDim - 1, 1>>;
ConstAmbientVectorRef o(x_ptr);
ConstAmbientVectorRef d(x_ptr + kDim);
ConstTangentVectorRef delta_o(delta_ptr);
ConstTangentVectorRef delta_d(delta_ptr + kDim - 1);
AmbientVectorRef o_plus_delta(x_plus_delta_ptr);
AmbientVectorRef d_plus_delta(x_plus_delta_ptr + kDim);
const double norm_delta_d = delta_d.norm();
o_plus_delta = o;
// Shortcut for zero delta direction.
if (norm_delta_d == 0.0) {
d_plus_delta = d;
if (delta_o.isZero(0.0)) {
return true;
}
}
// Calculate the householder transformation which is needed for f_d and f_o.
AmbientVector v;
double beta;
// NOTE: The explicit template arguments are needed here because
// ComputeHouseholderVector is templated and some versions of MSVC
// have trouble deducing the type of v automatically.
internal::ComputeHouseholderVector<ConstAmbientVectorRef, double, kDim>(
d, &v, &beta);
if (norm_delta_d != 0.0) {
// Map the delta from the minimum representation to the over parameterized
// homogeneous vector. See section A6.9.2 on page 624 of Hartley & Zisserman
// (2nd Edition) for a detailed description. Note there is a typo on Page
// 625, line 4 so check the book errata.
const double norm_delta_div_2 = 0.5 * norm_delta_d;
const double sin_delta_by_delta =
std::sin(norm_delta_div_2) / norm_delta_div_2;
// Apply the delta update to remain on the unit sphere. See section A6.9.3
// on page 625 of Hartley & Zisserman (2nd Edition) for a detailed
// description.
AmbientVector y;
y.template head<kDim - 1>() = 0.5 * sin_delta_by_delta * delta_d;
y[kDim - 1] = std::cos(norm_delta_div_2);
d_plus_delta = d.norm() * (y - v * (beta * (v.transpose() * y)));
}
// The null space is in the direction of the line, so the tangent space is
// perpendicular to the line direction. This is achieved by using the
// householder matrix of the direction and allow only movements
// perpendicular to e_n.
//
// The factor of 0.5 is used to be consistent with the line direction
// update.
AmbientVector y;
y << 0.5 * delta_o, 0;
o_plus_delta += y - v * (beta * (v.transpose() * y));
return true;
}
template <int AmbientSpaceDimension>
bool LineParameterization<AmbientSpaceDimension>::ComputeJacobian(
const double* x_ptr, double* jacobian_ptr) const {
static constexpr int kDim = AmbientSpaceDimension;
using AmbientVector = Eigen::Matrix<double, kDim, 1>;
using ConstAmbientVectorRef =
Eigen::Map<const Eigen::Matrix<double, kDim, 1>>;
using MatrixRef = Eigen::Map<
Eigen::Matrix<double, 2 * kDim, 2 * (kDim - 1), Eigen::RowMajor>>;
ConstAmbientVectorRef d(x_ptr + kDim);
MatrixRef jacobian(jacobian_ptr);
// Clear the Jacobian as only half of the matrix is not zero.
jacobian.setZero();
AmbientVector v;
double beta;
// NOTE: The explicit template arguments are needed here because
// ComputeHouseholderVector is templated and some versions of MSVC
// have trouble deducing the type of v automatically.
internal::ComputeHouseholderVector<ConstAmbientVectorRef, double, kDim>(
d, &v, &beta);
// The Jacobian is equal to J = 0.5 * H.leftCols(kDim - 1) where H is
// the Householder matrix (H = I - beta * v * v') for the origin point. For
// the line direction part the Jacobian is scaled by the norm of the
// direction.
for (int i = 0; i < kDim - 1; ++i) {
jacobian.block(0, i, kDim, 1) = -0.5 * beta * v(i) * v;
jacobian.col(i)(i) += 0.5;
}
jacobian.template block<kDim, kDim - 1>(kDim, kDim - 1) =
jacobian.template block<kDim, kDim - 1>(0, 0) * d.norm();
return true;
}
} // namespace ceres
#endif // CERES_PUBLIC_INTERNAL_LINE_PARAMETERIZATION_H_
|
[
"macdonald.roy@gmail.com"
] |
macdonald.roy@gmail.com
|
c61bbf61f3d7c27b6841cfe80d9e24a44c9ff43f
|
ffcc850625b8590866a36d0a607e3a73cf37598d
|
/test/constant/simd/oneosqrteps.cpp
|
38cc6cc356e9689c0c358b065e68089da97bab09
|
[
"BSL-1.0"
] |
permissive
|
remymuller/boost.simd
|
af7e596f17294d35ddcd8f859c4a12cb3276254d
|
c6614f67be94be2608342bf5d753917b6968e821
|
refs/heads/develop
| 2021-01-02T09:00:18.137281
| 2017-07-06T14:23:04
| 2017-07-06T14:23:04
| 99,120,027
| 6
| 7
| null | 2017-08-02T13:34:55
| 2017-08-02T13:34:55
| null |
UTF-8
|
C++
| false
| false
| 1,331
|
cpp
|
//==================================================================================================
/*!
Copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#include <boost/simd/constant/oneosqrteps.hpp>
#include <boost/simd/pack.hpp>
#include <algorithm>
#include <simd_test.hpp>
STF_CASE_TPL( "Check Oneosqrteps behavior"
, (double)(float)
(std::uint8_t)(std::uint16_t)(std::uint32_t)(std::uint64_t)
(std::int8_t )(std::int16_t )(std::int32_t )(std::int64_t )
)
{
namespace bs = boost::simd;
using pack_t = bs::pack<T>;
using hpack_t = bs::pack<T,pack_t::static_size/2>;
using dpack_t = bs::pack<T,pack_t::static_size*2>;
auto are_correct = [](T e) { return e == bs::Oneosqrteps<T>(); };
auto pack = bs::Oneosqrteps<pack_t>();
auto hpack = bs::Oneosqrteps<hpack_t>();
auto dpack = bs::Oneosqrteps<dpack_t>();
STF_EXPECT(( std::all_of(pack.begin() , pack.end(), are_correct ) ));
STF_EXPECT(( std::all_of(hpack.begin(),hpack.end(), are_correct ) ));
STF_EXPECT(( std::all_of(dpack.begin(),dpack.end(), are_correct ) ));
}
|
[
"charly.chevalier@numscale.com"
] |
charly.chevalier@numscale.com
|
d5dae060d9028c6b1a234096d8c3f609c9afd34b
|
5c641708b182c5a790e063614aeb6380da899ae1
|
/library/src/main/jni/interface/cgeVideoEncoder.h
|
f40622f1bb5ab1d10de87908074c6bea961dcf16
|
[
"MIT"
] |
permissive
|
iigacon/gpuimage
|
53b05b00b5574713a69d9c29bae3391d4eee4f47
|
7a9b748556c81c6c7b69b4187ea60a77b1485b37
|
refs/heads/master
| 2021-01-22T02:48:53.886062
| 2017-09-03T09:14:53
| 2017-09-03T09:14:56
| 95,685,178
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,820
|
h
|
/*
* cgeVideoEncoder.h
*
* Created on: 2015-7-30
* Author: Wang Yang
* Mail: admin@wysaid.org
*/
#if !defined(_VIDEO_ENCODER_H_) && defined(_CGE_USE_FFMPEG_)
#define _CGEVIDEO_ENCODER_H_
#include <string>
#include <fstream>
#include <mutex>
struct AVFrame;
namespace CGE
{
struct CGEEncoderContextMP4;
// 使用h264编码视频,FLTP浮点单声道音频的mp4 encoder
class CGEVideoEncoderMP4
{
public:
CGEVideoEncoderMP4();
~CGEVideoEncoderMP4();
enum RecordDataFormat
{
FMT_RGBA8888,
FMT_RGB565,
FMT_BGR24,
FMT_GRAY8,
FMT_NV21,
FMT_YUV420P
};
struct ImageData
{
const unsigned char* data[8];
int width, height;
int linesize[8];
long pts;
};
struct AudioSampleData
{
const unsigned short* data[8];
int nbSamples[8]; //声音帧大小
int channels; //声音包含几个通道
};
bool init(const char* filename, int fps, int width, int height, bool hasAudio = true, int bitRate = 1650000, int audioSampleRate = 44100);
void setRecordDataFormat(RecordDataFormat fmt);
//两个record写入文件时将保证线程安全
bool record(const ImageData& data);
bool record(const AudioSampleData& data);
bool recordAudioFrame(AVFrame*);
bool recordVideoFrame(AVFrame*);
double getVideoStreamTime();
double getAudioStreamTime();
//保存视频
bool save();
//丢弃视频
void drop();
int getAudioSampleRate();
protected:
bool _openVideo();
bool _openAudio();
int _queryDataFormat(RecordDataFormat fmt);
private:
CGEEncoderContextMP4* m_context;
std::string m_filename;
int m_recordDataFmt;
std::mutex m_mutex;
unsigned char* m_videoPacketBuffer;
int m_videoPacketBufferSize;
unsigned char* m_audioPacketBuffer;
int m_audioPacketBufferSize;
bool m_hasAudio;
};
}
#endif
|
[
"12nguyenduc@gmail.com"
] |
12nguyenduc@gmail.com
|
8e2cb48432e1f39aabf6e5e89c35ba2915c5794a
|
83dae07f637c1f7b86b2da26788dfe1ea481053f
|
/ready_ppl/main.cpp
|
e81502b7b1728094c34326e876966aaa82175528
|
[] |
no_license
|
PPL-IIITA/ppl-assignment-iit2015095
|
f66eb6bd29600dcd0aaf8537328e374cf828b1a5
|
2a346e7f90128dd3c3f5af1e868eac0db0ea46e8
|
refs/heads/master
| 2021-01-21T06:19:19.584724
| 2017-04-09T22:41:03
| 2017-04-09T22:41:03
| 83,213,295
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,056
|
cpp
|
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#include<string>
class boy{
public:
char name[10];
int attract;
int intellig;
int budget;
int min_attract_g;
int b;
char committed_boys_types[15];
};
class girl{
public:
char name[10];
int attract;
int intellig;
int maintain;
int gift;
int g;
char committed_girls_type[15];
};
void generate_boys(vector <boy> &BOY , int n)
{
ofstream file;
file.open("boys_records.txt",ios_base::app);
char str[] = "abcdefghijklmnopqrstuvwxyz";
int i, j ,k , l,m;
char committed_boys_types[15];
int attract, intellig, budget, min_attract_g, b_gift;
char type[][50] = {"The Miser","The Generous","The Geeks"};
for(i=0; i<n; i++)
{
char name[10];
for(j=0; j<10; j++)
{
name[j] = str[(rand()%25)];
}
name[j] ='\0';
strcpy(committed_boys_types,type[rand()%3]);
attract = rand()%10;
intellig = rand()%20;
budget = rand()%50000;
min_attract_g = rand()%10;
b_gift = rand()%20;
file << "name -> " <<name;
file << "attractiveness of boy-> " << attract << "\t";
file << "intelligence of boy-> " << intellig <<"\t";
file << "budget of boy-> " << budget <<"\t";
file << "min_attraction_of_girl -> " << min_attract_g <<"\t";
file << "type_of_committed_boy -> " << committed_boys_types <<"\t";
file << endl;
boy New;
strcpy(New.name , name);
New.attract = attract;
New.intellig = intellig;
New.budget = budget;
New.min_attract_g = min_attract_g;
strcpy(New.committed_boys_types , committed_boys_types);
New.b = 0;
BOY.push_back(New);
}
file.close();
}
void generate_girls( vector <girl> &GIRL , int n)
{
ofstream file;
file.open("girls_records.txt",ios_base::app);
char str[] = "abcdefghijklmnopqrstuvwxyz";
int i, j ,k , l,m;
char committed_girls_type[15];
int attract, intellig, maintain, gift;
char type[][50] = {"The Miser","The Generous","The Geeks"};
for(i=0; i<n; i++)
{
char name[10];
for(j=0; j<10; j++)
{
name[j] = str[(rand()%25)];
}
name[j] ='\0';
strcpy(committed_girls_type,type[rand()%3]);
attract = rand()%10;
intellig = rand()%20;
maintain = rand()%50000;
gift = rand()%20;
file << "name -> " <<name <<"\t";
file << "gift by boy -> " <<gift <<"\t";
file << "attractiveness of girl -> " << attract<<"\t" ;
file << "intelligence of girl-> " << intellig <<"\t";
file << "maintenance of girl-> " << maintain <<"\t";
file << "committed_girls_type -> " << committed_girls_type <<"\t";
file << endl;
girl New;
strcpy(New.name , name);
New.attract = attract;
New.intellig = intellig;
New.maintain = maintain;
New.gift = gift;
New.g = 0;
strcpy(New.committed_girls_type , committed_girls_type);
GIRL.push_back(New);
}
file.close();
}
void generate_gifts(int no_gifts){
int price,value,i,lux,diff,utility_value;
ofstream file;
file.open("gifts_record.txt",ios_base::app);
char type[25],type_of_gifts[][25] = {"Essential gift","Luxury gift","Utility gift"};
char Class[] = "ABC",utility_class;
for(i = 1;i <= no_gifts;i++){
strcpy(type,type_of_gifts[rand()%3]);
price = rand()%1000 + 1;
value = rand()%10 + 1;
file <<"gift -> " << i << endl;
file << "type -> " << type << endl;
file << "price -> " << price << endl;
file << "value -> " << value << endl;
if(type[0] == 'L'){
lux = rand()%10 + 1;
diff = rand()%10 + 1;
file << "luxury : " << lux<< endl;
file << "difficulty_for_gift :" << diff << endl;
}
else if(type[0] == 'U'){
utility_value = rand()% 10 + 1;
utility_class = Class[rand()%3];
file << "utility value : " << utility_value << endl;
file << "utility class : " << utility_class << endl;
}
file << endl;
}
file.close();
}
int make_couples(vector <boy> &BOY, vector <girl> &GIRL , int a[][2])
{
ofstream file;
file.open("log.txt",ios_base::app);
int i, j, l=0, k=0;
int commit[1000]={0};
for(i=0; i<1000; i++)
{
l=0;
for(j=0; j<1000; j++)
{
if(commit[j] == 0)
{
if(BOY[j].budget >= GIRL[i].maintain)
{
if(GIRL[i].attract > BOY[j].min_attract_g)
{
if(BOY[j].attract <= GIRL[i].attract)
{
// cout<<GIRL[i].name <<" is commited with "<<BOY[j].name <<"and both are having a happy valentine"<<endl;
file << GIRL[i].name <<" is going to make couple with " << BOY[j].name<<endl;
a[k][0] =i; a[k][1] = j;
k++;
commit[j] =1;
l++;
break;
}
}
}
}
}
if(l == 0)
{
//cout<<GIRL[i].name <<" is not going to make couple because her standard is too damn high "<<endl;
file << GIRL[i].name << "will always remain single because of high standard"<<endl;
}
}
return k;
}
void compatibility (vector <boy> &BOY, vector <girl> &GIRL, int a[][2], int l)
{
int i, j=0 , k, g, b;
int compat[l];
int vkc[l];
for(i=0; i<l; i++)
{
g = a[i][0];
b = a[i][1];
compat[i] = (BOY[b].budget - GIRL[g].maintain) + abs(BOY[b].attract - GIRL[g].attract) + abs(BOY[b].intellig - GIRL[g].intellig);
//cout<<GIRL[g].name <<" with "<<BOY[b].name<<" having compatibility "<<compat[i]<<endl;
vkc[i] = compat[i];
}
sort(compat, compat+l);
ofstream file;
file.open ("comapatible_couple.txt", ios_base::app);
int r=1;
for(i=l-1; i>=0; i--)
{
for(j=0; j<l; j++)
{
if(compat[i] == vkc[j])
{
g = a[j][0];
b = a[j][1];
file<<GIRL[g].name<<" has " << r++ << " compatibility with "<<BOY[b].name <<" value "<<compat[i]<<endl;
break;
}
}
}
}
int main()
{
vector <boy> BOY;
vector <girl> GIRL;
generate_gifts(1000);
generate_boys( BOY, 1000);
generate_girls( GIRL , 1000);
int a[1000][2] = {0};
int m;
m = make_couples(BOY , GIRL, a);
compatibility(BOY, GIRL, a, m);
}
|
[
"noreply@github.com"
] |
PPL-IIITA.noreply@github.com
|
e4bf5076de3574749b7f3715114493c69adaf6d6
|
fcea4ac4fc03c2ec9d0edb437ad9cf1a6a36a677
|
/Source/MCTPlugin/Private/WorldGeneratorBase.cpp
|
bd1e465708becb7ac75e030864aefb19b001f682
|
[] |
no_license
|
bradyrussell/marchingcubesterrainplugin
|
98999696ee3941ab307135969dac4c5f9ac99d3d
|
ed5ce494071d33547347c3f06f05f758aa3f5880
|
refs/heads/master
| 2023-04-13T23:27:49.020404
| 2021-04-08T01:09:52
| 2021-04-08T01:09:52
| 191,637,622
| 6
| 2
| null | 2021-03-11T17:25:53
| 2019-06-12T20:10:55
|
C++
|
UTF-8
|
C++
| false
| false
| 216
|
cpp
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "WorldGeneratorBase.h"
WorldGeneratorBase::WorldGeneratorBase() {
}
WorldGeneratorBase::~WorldGeneratorBase() {
}
|
[
"noreply@github.com"
] |
bradyrussell.noreply@github.com
|
f6c7268186da3185ea760488e2e3a69d311427fc
|
8a87f5b889a9ce7d81421515f06d9c9cbf6ce64a
|
/3rdParty/boost/1.78.0/boost/preprocessor/dec.hpp
|
d57206470b9fad2d8dc97c818e790c47bbe3dd67
|
[
"BSL-1.0",
"Apache-2.0",
"BSD-3-Clause",
"ICU",
"Zlib",
"GPL-1.0-or-later",
"OpenSSL",
"ISC",
"LicenseRef-scancode-gutenberg-2020",
"MIT",
"GPL-2.0-only",
"CC0-1.0",
"LicenseRef-scancode-autoconf-simple-exception",
"LicenseRef-scancode-pcre",
"Bison-exception-2.2",
"LicenseRef-scancode-public-domain",
"JSON",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"Unlicense",
"BSD-4-Clause",
"Python-2.0",
"LGPL-2.1-or-later"
] |
permissive
|
arangodb/arangodb
|
0980625e76c56a2449d90dcb8d8f2c485e28a83b
|
43c40535cee37fc7349a21793dc33b1833735af5
|
refs/heads/devel
| 2023-08-31T09:34:47.451950
| 2023-08-31T07:25:02
| 2023-08-31T07:25:02
| 2,649,214
| 13,385
| 982
|
Apache-2.0
| 2023-09-14T17:02:16
| 2011-10-26T06:42:00
|
C++
|
UTF-8
|
C++
| false
| false
| 736
|
hpp
|
# /* **************************************************************************
# * *
# * (C) Copyright Paul Mensonides 2002.
# * Distributed under the Boost Software License, Version 1.0. (See
# * accompanying file LICENSE_1_0.txt or copy at
# * http://www.boost.org/LICENSE_1_0.txt)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# ifndef BOOST_PREPROCESSOR_DEC_HPP
# define BOOST_PREPROCESSOR_DEC_HPP
#
# include <boost/preprocessor/arithmetic/dec.hpp>
#
# endif
|
[
"jan@arangodb.com"
] |
jan@arangodb.com
|
59a47fb68d4a85bf97c46b8fcce18367738116c1
|
967482ce7998d8814a13d8509db947b0df31f8e0
|
/src/mod/wgt/shl/Expressable.cpp
|
1f5a3d08914e8a53e224c78219cacf4bb75a3b75
|
[] |
no_license
|
loongarch64/afnix
|
38dc9c9808f18ff5517f7c43f641057a9583aeda
|
88cc629cc09086cda707e5ad6d8a1bd412491bbe
|
refs/heads/main
| 2023-05-31T17:16:56.743466
| 2021-06-22T05:18:32
| 2021-06-22T05:18:32
| 379,150,535
| 0
| 0
| null | 2021-06-25T03:05:27
| 2021-06-22T05:20:29
|
C++
|
UTF-8
|
C++
| false
| false
| 5,078
|
cpp
|
// ---------------------------------------------------------------------------
// - Expressable.cpp -
// - afnix:wgt module - expressable abstract class implementation -
// ---------------------------------------------------------------------------
// - This program is free software; you can redistribute it and/or modify -
// - it provided that this copyright notice is kept intact. -
// - -
// - 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. In no event shall -
// - the copyright holder be liable for any direct, indirect, incidental or -
// - special damages arising in any way out of the use of this software. -
// ---------------------------------------------------------------------------
// - copyright (c) 1999-2021 amaury darsch -
// ---------------------------------------------------------------------------
#include "Vector.hpp"
#include "Boolean.hpp"
#include "Evaluable.hpp"
#include "QuarkZone.hpp"
#include "Exception.hpp"
#include "Expressable.hpp"
namespace afnix {
// -------------------------------------------------------------------------
// - class section -
// -------------------------------------------------------------------------
// copy move this expressable
Expressable::Expressable (Expressable&& that) noexcept :
Object (static_cast<Object&&>(that)) {
}
// move this expressable into this one
Expressable& Expressable::operator = (Expressable&& that) noexcept {
Object::operator = (static_cast<Object&&>(that));
return *this;
}
// valuate a conditional
bool Expressable::valuate (const Conditional& cond) const {
rdlock ();
try {
// check for activate
if (cond.getactv () == false) {
unlock ();
return false;
}
// collect conditional data
String oper = cond.getoper ();
Literal* llhs = cond.getllhs ();
Literal* lrhs = cond.getlrhs ();
// check conistency
if (llhs == nullptr) {
throw Exception ("conditional-error", "invalid null lhs in valuate");
}
bool result = (lrhs == nullptr) ?
valuate (oper, *llhs) : valuate (oper, *llhs, *lrhs);
unlock ();
return result;
} catch (...) {
unlock ();
throw;
}
}
// -------------------------------------------------------------------------
// - object section -
// -------------------------------------------------------------------------
// the quark zone
static const long QUARK_ZONE_LENGTH = 1;
static QuarkZone zone (QUARK_ZONE_LENGTH);
// the object supported quarks
static const long QUARK_VALUATE = zone.intern ("valuate");
// return true if the given quark is defined
bool Expressable::isquark (const long quark, const bool hflg) const {
rdlock ();
try {
if (zone.exists (quark) == true) {
unlock ();
return true;
}
bool result = hflg ? Object::isquark (quark, hflg) : false;
unlock ();
return result;
} catch (...) {
unlock ();
throw;
}
}
// apply this object with a set of arguments and a quark
Object* Expressable::apply (Evaluable* zobj, Nameset* nset, const long quark,
Vector* argv) {
// get the number of arguments
long argc = (argv == nullptr) ? 0 : argv->length ();
// check for 1 argument
if (argc == 1) {
if (quark == QUARK_VALUATE) {
Object* obj = argv->get(0);
auto cond = dynamic_cast<Conditional*>(obj);
if (cond == nullptr) {
throw Exception ("type-error", "invalid object as conditional",
Object::repr (obj));
}
return new Boolean (valuate (*cond));
}
}
// check for 2 arguments
if (argc == 2) {
if (quark == QUARK_VALUATE) {
String oper = argv->getstring (0);
Object* obj = argv->get(1);
auto llhs = dynamic_cast<Literal*>(obj);
if (llhs == nullptr) {
throw Exception ("type-error", "invalid object as lhs valuator",
Object::repr (obj));
}
return new Boolean (valuate (oper, *llhs));
}
}
// check for 3 arguments
if (argc == 3) {
if (quark == QUARK_VALUATE) {
String oper = argv->getstring (0);
Object* obj = argv->get(1);
auto llhs = dynamic_cast<Literal*>(obj);
if (llhs == nullptr) {
throw Exception ("type-error", "invalid object as lhs valuator",
Object::repr (obj));
}
obj = argv->get(2);
auto lrhs = dynamic_cast<Literal*>(obj);
if (lrhs == nullptr) {
throw Exception ("type-error", "invalid object as rhs valuator",
Object::repr (obj));
}
return new Boolean (valuate (oper, *llhs, *lrhs));
}
}
// call the object method
return Object::apply (zobj, nset, quark, argv);
}
}
|
[
"wuxiaotian@loongson.cn"
] |
wuxiaotian@loongson.cn
|
f388c64c3cfcafa5830a946ecaf1bfd89886cbbd
|
81c0d8c2bea2907ddb93089e40354a52fc14091b
|
/src/memoryobject.h
|
c77d2dd6894938c6f881f6e55f7e87c3eb22af69
|
[] |
no_license
|
fifield/node-webcl
|
d41cc65d39ebb44f1decf18482eb673eae6636e5
|
6ffd3bcf577f233359be73f06d8496b96d7a963e
|
refs/heads/master
| 2021-01-22T02:57:52.612836
| 2012-04-21T21:25:40
| 2012-04-21T21:25:40
| 1,929,785
| 38
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 888
|
h
|
#ifndef WEBCL_MEMORYOBJECT_H_
#define WEBCL_MEMORYOBJECT_H_
#include "common.h"
#include "wrapper/include/memoryobjectwrapper.h"
namespace webcl {
class MemoryObject : public node::ObjectWrap
{
public:
~MemoryObject();
static void Init(v8::Handle<v8::Object> target);
static MemoryObject *New(MemoryObjectWrapper* mw);
static v8::Handle<v8::Value> New(const v8::Arguments& args);
static v8::Handle<v8::Value> getMemObjectInfo(const v8::Arguments& args);
static v8::Handle<v8::Value> getImageInfo(const v8::Arguments& args);
static v8::Handle<v8::Value> createSubBuffer(const v8::Arguments& args);
MemoryObjectWrapper *getMemoryObjectWrapper() { return mw; };
private:
MemoryObject(v8::Handle<v8::Object> wrapper);
static v8::Persistent<v8::FunctionTemplate> constructor_template;
MemoryObjectWrapper *mw;
};
} // namespace
#endif
|
[
"fifield@colorado.edu"
] |
fifield@colorado.edu
|
b551c3ef0df5b0d6a88d0057721b3c4e6ff4831f
|
67baab02cfda6c54a287d63d0874824cf15f3ba6
|
/oi/joi/2019/a.cpp
|
402d5fb43264c965dfce0d7343af7d204435ec73
|
[
"MIT"
] |
permissive
|
sogapalag/problems
|
a14eedd8cfcdb52661479c8c90e08737aaeeb32b
|
0ea7d65448e1177f8b3f81124a82d187980d659c
|
refs/heads/master
| 2021-01-12T17:49:52.007234
| 2020-08-18T14:51:40
| 2020-08-18T14:51:40
| 71,629,601
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 698
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
const int N = 3111;
char s[N][N];
int c[N][N];
void solve() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> &s[i][1];
}
for (int j = 1; j <= m; j++) {
for (int i = n; i >= 1; i--) {
c[i][j] = c[i+1][j] + (s[i][j] == 'I');
}
}
long long res = 0;
for (int i = 1; i <= n; i++) {
int r = 0;
for (int j = m; j >= 1; j--) {
r += (s[i][j] == 'O');
if (s[i][j] == 'J') res += r * c[i][j];
}
}
cout << res << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}
|
[
"yan-zp@foxmail.com"
] |
yan-zp@foxmail.com
|
c0a313566cb12f5904e22aec878f59ab12ea9f6e
|
0ea03067965572e090cb7cb4f998bfba0ca64c6d
|
/Tudat/Astrodynamics/Relativity/metric.cpp
|
f20f52a99680a78d9c3ba52c9b2195eaf5f1e2a5
|
[] |
no_license
|
MitchellBorst/tudat
|
c59ff1e44a9ba037f3ce5a890b6dfcfdf4d9430d
|
ca04f75819cb0abcf263a6b7dd7c7c3d49acbfa7
|
refs/heads/master
| 2021-05-14T07:44:45.151657
| 2017-12-10T18:02:21
| 2017-12-10T18:02:21
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 766
|
cpp
|
/* Copyright (c) 2010-2017, Delft University of Technology
* All rigths reserved
*
* This file is part of the Tudat. Redistribution and use in source and
* binary forms, with or without modification, are permitted exclusively
* under the terms of the Modified BSD license. You should have received
* a copy of the license with this file. If not, please or visit:
* http://tudat.tudelft.nl/LICENSE.
*/
#include <boost/make_shared.hpp>
#include "Tudat/Astrodynamics/Relativity/metric.h"
namespace tudat
{
namespace relativity
{
//! Initialize global PPN parameters
boost::shared_ptr< PPNParameterSet > ppnParameterSet = boost::make_shared< PPNParameterSet >( 1.0, 1.0 );
double equivalencePrincipleLpiViolationParameter = 0.0;
}
}
|
[
"d.dirkx@tudelft.nl"
] |
d.dirkx@tudelft.nl
|
bf9e5164b597a3d7560490ab2a33d6fdf5b4361e
|
bf6632634a16c91c7ee319ba9a4c95195ddf176d
|
/Tools/MapCreator/includes/MapBackgroundItem.hpp
|
807b5898ac01811b276b366bfd52959a7d70cf43
|
[] |
no_license
|
peauc/RType
|
b3c2d27b5c9204188ee98be0f868c9a49cd3efd8
|
8e04d99b82c36f77f600b9c41eff5c1781c058d6
|
refs/heads/master
| 2021-05-12T10:06:47.728866
| 2018-01-23T22:34:28
| 2018-01-23T22:34:28
| 117,344,079
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,038
|
hpp
|
/*
** EPITECH PROJECT , 2020
** MapCreator
** File description :
** No description
*/
#ifndef MAPCREATOR_MAPBACKGROUNDITEM_HPP
#define MAPCREATOR_MAPBACKGROUNDITEM_HPP
#include "ASpriteInList.hpp"
#include "IDragAndDrop.hpp"
#include "AContainer.hpp"
class MapBackgroundItem : public ASpriteInList, public IDragAndDrop {
public:
MapBackgroundItem(const std::string &iconPath, AItem *parent,
AContainer *employer);
virtual ~MapBackgroundItem() = default;
MapBackgroundItem(const MapBackgroundItem&) = delete;
MapBackgroundItem &operator=(const MapBackgroundItem&) = delete;
virtual void displayOnWindow(sf::RenderWindow &window);
virtual void associateEvents();
virtual void receiveEvent(const sf::Event &event);
virtual void refresh();
virtual void init();
virtual void onMouseButtonPressed(const sf::Event &event);
virtual void onMouseButtonReleased(const sf::Event &event);
virtual void onMouseMoved(const sf::Event &event);
protected:
AContainer *employer;
};
#endif //MAPCREATOR_MAPBACKGROUNDITEM_HPP
|
[
"paul.wery@epitech.eu"
] |
paul.wery@epitech.eu
|
7bb18e3607988682a9fe9ce1cd6b40986e5a8fc3
|
3a7322640a619ffe793e88de4807c58f2a645fb6
|
/system_programming/udp/client/client_udp_test.cpp
|
034ce03605a0e2d8a13bba88c8152f60fb06789f
|
[] |
no_license
|
MiritHadar/Practice
|
d0e60fce8c9346212fd3e1071cb7395e63bec69a
|
471e75393e02d61601a235fe65f0121ae1121b5c
|
refs/heads/master
| 2020-09-08T01:30:03.102784
| 2020-04-30T14:03:51
| 2020-04-30T14:03:51
| 220,971,061
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 588
|
cpp
|
/*
********************************************************************************
Developer : Mirit Hadar
Reviewer :
Last Update :
Status :
********************************************************************************
*/
#include "client_udp.hpp"
using namespace ilrd;
//first argument sent is port number
//second one is num of runs wanted
int main(int argc, char *argv[])
{
uint16_t port = 1234;
size_t numOfSends = 3;
if (argc > 1)
{
port = atoi(argv[1]);
}
if (argc > 2)
{
numOfSends = atoi(argv[2]);
}
RunUDPClient(port, numOfSends);
return EXIT_SUCCESS;
}
|
[
"mirit6873079@gmail.com"
] |
mirit6873079@gmail.com
|
10c42b5bf1bd989fac60f1777cc1b487b1f53801
|
23c524e47a96829d3b8e0aa6792fd40a20f3dd41
|
/.history/vector/Vector_20210405161928.hpp
|
7283109c65d58be5043e699ef344c802f4dad1a6
|
[] |
no_license
|
nqqw/ft_containers
|
4c16d32fb209aea2ce39e7ec25d7f6648aed92e8
|
f043cf52059c7accd0cef7bffcaef0f6cb2c126b
|
refs/heads/master
| 2023-06-25T16:08:19.762870
| 2021-07-23T17:28:09
| 2021-07-23T17:28:09
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,852
|
hpp
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Vector.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dbliss <dbliss@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/29 19:04:34 by dbliss #+# #+# */
/* Updated: 2021/04/05 16:19:27 by dbliss ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VECTOR_HPP
#define VECTOR_HPP
#include <iostream>
#include <memory>
#include <vector>
#include "Iterator.hpp"
namespace ft
{
template <class T, class Alloc = std::allocator<T> >
class vector
{
public:
typedef T value_type;
typedef Alloc allocator_type;
typedef typename Alloc::reference reference;
typedef typename Alloc::const_reference const_reference;
typedef typename Alloc::pointer pointer;
typedef typename Alloc::const_pointer const_pointer;
typedef ft::iterator<pointer> iterator;
typedef ft::iterator<const_pointer> const_iterator;
// TO DO : reverse iterator, const reverse iterator
typedef ptrdiff_t difference_type;
typedef size_t size_type;
// а дальше надо создать итератор!!!
// и потом еще некоторые параметры (которые дальше на сайте С++)
/* 4 CONSTRUCTORS: */
explicit vector(const allocator_type& alloc = allocator_type()) : _v_begin(NULL), _v_size(0) {} // #1: default constructor
explicit vector(size_type n, const value_type& val = value_type(), \
const allocator_type& alloc = allocator_type()) {} // #2: fill constructor: constructs a container with n elements. Each element is a copy of val.
/* #3: Constructs a container with as many elements as the range [first,last),
with each element constructed from its corresponding element in that range, in the same order. */
template <class InputIterator>
vector (InputIterator first, InputIterator last,
const allocator_type& alloc = allocator_type()) {}
/* #4: copy constructor: */
explicit vector(vector const &src);
/* DESTRUCTOR */
~vector(){}
/*ASSIGNMENT OPERATOR*/
vector &operator=(vector const &rhs) {}
/* ITERATORS */
iterator begin() { return (iterator(&(front()))); } // тут мы получаем ссылку из указателя (фронт возвращает указатель, и подставляем в конструктор)
iterator end() { return iterator(&(back()) + 1); } // Unlike member vector::end, which returns an iterator just past this element, this function returns a direct reference, поэтому +1
const_iterator begin() const { return const_iterator(&(front())); }
const_iterator end() const { return const_iterator(&(back()) + 1); }
//reverse_iterator rbegin();
//reverse_iterator rend();
//const_reverse_iterator rbegin();
//const_reverse_iterator rend();
reference front() { return *_v_begin; }
const_reference front() const { return *_v_begin; }
reference back() { return *(this->_v_end - 1); }
const_reference back() const { return *(this->_v_end_ - 1); }
size_type size() const { return this->_v_size; }
/* */
private:
pointer _v_begin;
pointer _v_end;
size_t _v_size;
};
}
#endif /* ***************************************************** MUTANTSTACK_H */
|
[
"dbliss@at-q5.msk.21-school.ru"
] |
dbliss@at-q5.msk.21-school.ru
|
e9074163123bd321a63b875af275fd5f527e2629
|
33bd63c8230f05a72c700de97e6945267d010dc9
|
/prject_u3dgame/netext/session_bind_base.cpp
|
2c3e9ff025e2c7e3b1302b4962992f93e22a4621
|
[] |
no_license
|
magicsea/u3dmmo
|
8788ae9a3f23dfd888d2c76733080b66e6146d78
|
65df9153038abaea52b11a2434f6a67c3c2a809b
|
refs/heads/master
| 2016-09-06T05:27:12.564730
| 2014-07-01T15:29:56
| 2014-07-01T15:29:56
| 17,163,737
| 4
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,392
|
cpp
|
//#include "MwPch.h"
//#include "StdAfx.h"
#include "gc_allnet.h"
#include "session_bind_base.h"
//#include <string>
GC_Session_Bind::GC_Session_Bind():mState(UN_CONNECT)
{
m_iReceiveTime=0;
m_pCallBackObject = NULL;
m_cbfOnConnect = NULL;
m_cbfOnDisConnect = NULL;
m_cbfOnNetClose = NULL;
}
GC_Session_Bind::~GC_Session_Bind()
{
}
bool GC_Session_Bind::IsLogin()
{
if(mState==ALREADY_LOGIN)
return true;
return false;
}
void GC_Session_Bind::OnConnect(bool ret)
{
if(ret)
{
mState=ALREADY_CONNECT;
}
else
{
}
if (m_pCallBackObject&&m_cbfOnConnect)
{
(m_pCallBackObject->*(m_cbfOnConnect))(this,ret);
}
return;
}
bool GC_Session_Bind::Connect(const char* pHostIP, int iPort)
{
if(mState==UN_CONNECT)
{
int port = iPort;
const char* pIP = pHostIP;
if (pIP==0)
{
return false;
}
if(CG_TCPSession::Connect((char*)pIP, port))
{
return true;
}
}
return false;
}
void GC_Session_Bind::OnDisconnect()
{
mState=UN_CONNECT;
if (m_pCallBackObject&&m_cbfOnDisConnect)
{
(m_pCallBackObject->*(m_cbfOnDisConnect))(this);
}
}
void GC_Session_Bind::OnClose(bool bMessage)//
{
Close();
mState=UN_CONNECT;
if (m_pCallBackObject&&m_cbfOnNetClose)
{
(m_pCallBackObject->*(m_cbfOnNetClose))(this,bMessage);
}
}
void GC_Session_Bind::OnReceive(CG_CmdPacket *packet)
{
m_iReceiveTime=Sys_GetTime();
short CommandID;
if(!packet->ReadShort(&CommandID)) return;
this->DoCmd(CommandID, packet);
return;
}
bool GC_Session_Bind::DoCmd(short cmdID, CG_CmdPacket *pPacket)
{
hash_map<short, NETCMD_FUN>::iterator it;
it = m_Bind.find(cmdID);
if (it!=m_Bind.end())
{
return ((*it).second)(cmdID, pPacket);
}
//obj fun
hash_map<short,NETCMD_FUN_OBJ>::iterator itFunobj;
itFunobj=m_BindObjFun.find(cmdID);
if (itFunobj!=m_BindObjFun.end())
{
hash_map<short, CNetCmdBase*>::iterator itObj = m_BindObj.find(cmdID);
CNetCmdBase* pObj = itObj->second;
if (pObj)
{
return (pObj->*(itFunobj->second))(cmdID, pPacket);
}
}
return false;
}
void GC_Session_Bind::OnLogin()
{
mState=ALREADY_LOGIN;
}
void GC_Session_Bind::OnRejectLogin()
{
mState=ALREADY_CONNECT;
}
bool GC_Session_Bind::IsBind(short cmdID)
{
return (m_Bind.find(cmdID)!=m_Bind.end());
}
void GC_Session_Bind::BindCmd(short cmdID, NETCMD_FUN pFun)
{
m_Bind[cmdID] = pFun;
}
void GC_Session_Bind::BindCmdObj(short cmdID, NETCMD_FUN_OBJ pFun,CNetCmdBase* obj)
{
if(!obj)return;
m_BindObjFun[cmdID]=pFun;
m_BindObj[cmdID]=obj;
}
void GC_Session_Bind::UnbindCmd(short cmdID)
{
hash_map<short, NETCMD_FUN>::iterator it;
it = m_Bind.find(cmdID);
if (it!=m_Bind.end())
{
m_Bind.erase(it);
}
}
CG_CmdPacket* GC_Session_Bind::BeginWrite()
{
mSendCommand.BeginWrite();
return &mSendCommand;
}
bool GC_Session_Bind::Send(CG_CmdPacket* pPacket)
{
return SendPacket(pPacket);
}
void GC_Session_Bind::regCallBackFunc(CNetCmdBase* pObj1,CBF_OnConnect cbf1,CBF_OnDisConnect cbf2,CBF_OnNetClose cbf3)
{
if(pObj1)
{
m_pCallBackObject = pObj1;
m_cbfOnConnect = cbf1;
m_cbfOnDisConnect = cbf2;
m_cbfOnNetClose = cbf3;
}
}
/////////////////////////////////////////////////////////////////////////////////
|
[
"magicsea_wy@163.com"
] |
magicsea_wy@163.com
|
1d02ab9b55acd5fcdc5afc5b8cc51c72e194e3e2
|
97708d413db822e6ef4e158ebacd62582a619f47
|
/c++/array/check_if_array_element_consecutive.cpp
|
b33aaeda62e066c256c4571bcddb69980c2e975d
|
[] |
no_license
|
uchihaitachi08/daily_code
|
aa8d233056440fad87bbe27f5c9ee3bb2d60e513
|
aa6eca512684511115e5a64526f596419e098a82
|
refs/heads/master
| 2021-01-19T18:00:02.398436
| 2015-10-10T17:06:31
| 2015-10-10T17:06:31
| 40,917,476
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 770
|
cpp
|
#include<iostream>
#include<map>
#include<climits>
using namespace std;
int getmin(int *arr, int n){
int min = INT_MAX;
for(int i=0;i<n;i++){
if(arr[i] < min){
min = arr[i];
}
}
return min;
}
int getmax(int *arr, int n){
int max = INT_MIN;
for(int i=0;i<n;i++){
if(arr[i] > max){
max = arr[i];
}
}
return max;
}
bool check_consecutive(int* arr, int n){
int min = getmin(arr,n);
int max = getmax(arr,n);
map<int,int>my_map;
if(n == max - min + 1){
for(int i=0;i<n;i++){
if(my_map.count(arr[i]) == 0)
my_map[arr[i]] = 1;
else
return false;
}
}
else
return false;
return true;
}
int main(){
int n;
cin>>n;
int *arr = new int[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
cout<<check_consecutive(arr,n)<<endl;
return 0;
}
|
[
"sameerrrana@gmail.com"
] |
sameerrrana@gmail.com
|
8b19a6e4143a14f8c8b4986a49f98d068cc3ffbf
|
25c550c689d75c6fee4049dc1050fc726bd29336
|
/728. Self Dividing Numbers.cpp
|
3cd1d675adf1e64ed7fa58cb3f209842e73cb6c6
|
[] |
no_license
|
YueJi95/LeetCode
|
aeba34b96846b526960bdb0350a9e2ab21b1f2df
|
61525029e99001fcf7138e045e4a892ae65f3e97
|
refs/heads/master
| 2021-01-20T06:31:00.648130
| 2018-05-09T19:33:21
| 2018-05-09T19:33:21
| 101,503,495
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 525
|
cpp
|
class Solution {
public:
vector<int> selfDividingNumbers(int left, int right) {
vector<int> result;
for(int i = left; i <= right; i++){
int val = i;
bool flag = true;
while(val > 0){
int a = val % 10;
val = val / 10;
if(a == 0 || (i % a) != 0){
flag = false;
break;
}
}
if(flag) result.push_back(i);
}
return result;
}
};
|
[
"yueji95@126.com"
] |
yueji95@126.com
|
02945ea1f87304fed89a196b7e314d06375b7d4a
|
4b8f62ecf3d6c1428f4a94ebac08843b18635bb7
|
/DS Made Easy Problems/OOP Lab/BFS (Linked List).cpp
|
71d932ae1e9fc26650945634665975af431f26a9
|
[] |
no_license
|
abhinavjain0809/Data_Sturctures
|
660e20d1ffb4b29d57e39e01e0f5ffc917468794
|
53793c71f9b0469cebefac8e98ccf741468d1edb
|
refs/heads/master
| 2021-01-01T05:49:58.733652
| 2014-10-19T05:10:11
| 2014-10-19T05:10:11
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,499
|
cpp
|
#include<iostream>
#include<stdlib.h>
using namespace std;
typedef struct queue{
int data;
struct queue *next;
}Q;
Q *front=NULL, *rear=NULL;
void enQueue(int);
int deQueue();
int main(void)
{
int n,m,v,**adj,a,b;
cout<<"Number of Vertices and Edges: ";;
cin>>n>>m;
int onSite[n], visited[n];
adj = new int*[n];
for(int i=0;i<=n;i++) adj[i] = new int[n];
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
adj[i][j] = 0;
cout<<"Connected Edges:\n"; // Adjacency Matrix...
for(int i=0;i<m;i++){
cin>>a>>b;
adj[a][b] = adj[b][a] = 1;
}
cout<<"\nStarting Vertex: ";
cin>>v;
cout<<"\nOrder of Visiting the nodes:\n"<<v<<"\t";
for(int i=1;i<n;i++){
visited[v] = 1;
for(int j=1;j<=n;j++){
if(adj[v][j]!=0 && onSite[j]!=1 && visited[j]!=1){
onSite[j] = 1;
enQueue(j);
}
}
onSite[v] = 0;
v = deQueue();
cout<<v<<"\t";
}
return 0;
}
void enQueue(int n)
{
Q *temp;
temp = new Q;
temp->data = n;
temp->next = NULL;
if(front==NULL){
front = rear = temp;
}
else{
rear->next = temp;
rear = temp;
}
}
int deQueue()
{
int n;
if(front==NULL){
//cout<<"Queue Empty";
exit(1);
}
n = front->data;
front = front->next;
return n;
}
|
[
"abhinavjian0809@gmail.com"
] |
abhinavjian0809@gmail.com
|
effb91490637214b7b9080f17b385e22e4cea7d8
|
c4a77c787211ed88d6533fc873293cbd923d14ed
|
/examples/graphic/illusion2.cpp
|
1c8b674d5d638e5c95e0ec2218b0513ba9a792d7
|
[] |
no_license
|
Scinc-L/Scinc
|
b802edd60aabeaa2322ffa61bf5c6a2f9a024ba3
|
5f0e505f0e1c204066b69f9d24f82a9235edd6df
|
refs/heads/master
| 2023-05-04T10:26:38.308320
| 2021-04-22T11:22:28
| 2021-04-22T11:22:28
| 370,496,445
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,446
|
cpp
|
#include <stdio.h>
#include "graphics.h"
Graph g;
#define M_PI 3.141592654
void Dot(float x, float y, float r, float w, float a, float T, float alpha)
{
int n=r/w;
float ca=cos(a);
float sa=sin(a);
for(int i=-n;i<=n;i++)
{
float t=i+(T-int(T)+(T<0?1:0))*2-1;
float s=sqrt(r*r-t*t*w*w);
g.clear();
g.M(x-s*ca+w*t*sa,y+s*sa+w*t*ca);
g.l(s*2*ca,-s*2*sa);
g.fin();
g.width(w,1);
if(i&1)
g.rgb(1,1,1);
else
g.rgb(0,0,0);
g.alpha(s/r*alpha);
g.stroke();
}
}
int main()
{
while(true)
{
double T=Time();
g.clear();
g.gray(.5);
g.FillRT();
int scene=int(T/10)%3;
//scene=2;
if(scene==0)
{
stext("Watch the form of the ring", 10,10,0x40000000);
int N=48;
for(int i=0;i<N;i++)
{
float a=i/float(N)*M_PI*2;
Dot(320+cos(a)*180,240+sin(a)*180,6,6,a*2+T*2,T*2+a*8,.5);
}
}
else if(scene==1)
{
stext("Is the square rotating?", 10,10,0x40000000);
for(int i=-5;i<6;i++)
{
Dot(320-i*20,240-120,4,4, 0,+sin(T/2.)*i/6.*8,.5);
Dot(320+i*20,240+120,4,4, 0,-sin(T/2.)*i/6.*8,.5);
Dot(320-120,240+i*20,4,4,M_PI/2,+sin(T/2.)*i/6.*8,.5);
Dot(320+120,240-i*20,4,4,M_PI/2,-sin(T/2.)*i/6.*8,.5);
}
}
else if(scene==2)
{
stext("Some movements", 10,10,0x40000000);
for(int i=-14;i<15;i++)
{
for(int j=-14;j<15;j++)
{
Dot(320-j*12,240-i*12,8,2,(sin(i*.3+T*.8)+sin(j*.4-T))+T,T*.5,1.);
}
}
}
Present();
}
return 0;
}
|
[
"klkspa@ukr.net"
] |
klkspa@ukr.net
|
74546083eb3f2a1118e45204c9f452d1de86d4b2
|
8d4b3a70af52a8da1f96016f98cf57c67ea4c027
|
/ex_4_grid_movement/assetmanager.hpp
|
3dea3d5353e4e0890e767d5d18cdedaf7c4f3ab2
|
[] |
no_license
|
Dalphat/cpp-sfml-examples
|
070915bfd97488166fa03bda2a60065c08cdf042
|
ea037c8804c1ffaa41cf1fc54b8b8c861e96b51f
|
refs/heads/master
| 2020-05-16T16:10:24.806799
| 2019-05-01T06:05:53
| 2019-05-01T06:05:53
| 183,153,318
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 613
|
hpp
|
#ifndef ASSETMANAGER_HPP
#define ASSETMANAGER_HPP
/*
Description: Pure static class asset manager. Manages assets.
*/
#include <SFML/Graphics/Texture.hpp>
#include <memory>
#include <unordered_map>
#include <fstream>
namespace my {
class AssetManager {
private:
static std::unordered_map<std::string, std::shared_ptr<sf::Texture>> assets;
static bool file_exists(std::string filename);
public:
//Returns a copy of shared pointer to texture by value: RVO > unsafe
static std::shared_ptr<sf::Texture> load(std::string filename);
};
}
#endif // !ASSETMANAGER_HPP
|
[
"dstackflow@gmail.com"
] |
dstackflow@gmail.com
|
d50863b6aa4b10ce7e7d08837a00ab330011428e
|
929d8ebd7d57ad1dadd80c99a3886a06e14712ab
|
/OpenCVShop/QT_CV.h
|
f8a4c8a452ff6fff2cab70be534cd6fc77017c3b
|
[] |
no_license
|
hrachyahakobyan/OpenCVShop
|
e3fab83c0a2b1a0ffd61b0406a335cd8a8080d0b
|
6a455b991c1837a7cf911c008ce160c70f8061e5
|
refs/heads/master
| 2020-05-21T22:39:13.539364
| 2016-09-22T09:51:57
| 2016-09-22T09:51:57
| 65,006,097
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,435
|
h
|
#pragma once
/****************************************************************************
** Copyright (c) 2012-2015 Debao Zhang <hello@debao.me>
** All right reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**
****************************************************************************/
#include <QtGui/qimage.h>
#include <opencv2/core/core.hpp>
namespace QtOcv {
enum MatColorOrder {
MCO_BGR,
MCO_RGB,
MCO_BGRA = MCO_BGR,
MCO_RGBA = MCO_RGB,
MCO_ARGB
};
/* Convert QImage to/from cv::Mat
*
* - cv::Mat
* - Supported channels
* - 1 channel
* - 3 channels (B G R), (R G B)
* - 4 channels (B G R A), (R G B A), (A R G B)
* - Supported depth
* - CV_8U [0, 255]
* - CV_16U [0, 65535]
* - CV_32F [0, 1.0]
*
* - QImage
* - All of the formats of QImage are supported.
*/
cv::Mat image2Mat(const QImage &img, int requiredMatType = CV_8UC(0), MatColorOrder requiredOrder = MCO_BGR);
QImage mat2Image(const cv::Mat &mat, MatColorOrder order = MCO_BGR, QImage::Format formatHint = QImage::Format_Invalid);
/* Convert QImage to/from cv::Mat without data copy
*
* - Supported QImage formats and cv::Mat types are:
* - QImage::Format_Indexed8 <==> CV_8UC1
* - QImage::Format_Alpha8 <==> CV_8UC1
* - QImage::Format_Grayscale8 <==> CV_8UC1
* - QImage::Format_RGB888 <==> CV_8UC3 (R G B)
* - QImage::Format_RGB32 <==> CV_8UC4 (A R G B or B G R A)
* - QImage::Format_ARGB32 <==> CV_8UC4 (A R G B or B G R A)
* - QImage::Format_ARGB32_Premultiplied <==> CV_8UC4 (A R G B or B G R A)
* - QImage::Format_RGBX8888 <==> CV_8UC4 (R G B A)
* - QImage::Format_RGBA8888 <==> CV_8UC4 (R G B A)
* - QImage::Format_RGBA8888_Premultiplied <==> CV_8UC4 (R G B A)
*
* - For QImage::Format_RGB32 ,QImage::Format_ARGB32
* and QImage::Format_ARGB32_Premultiplied, the
* color channel order of cv::Mat will be (B G R A) in little
* endian system or (A R G B) in big endian system.
*
* - User must make sure that the color channels order is the same as
* the color channels order requried by QImage.
*/
cv::Mat image2Mat_shared(const QImage &img, MatColorOrder *order = 0);
QImage mat2Image_shared(const cv::Mat &mat, QImage::Format formatHint = QImage::Format_Invalid);
} //namespace QtOcv
|
[
"hrachya_hakobyan@edu.aua.am"
] |
hrachya_hakobyan@edu.aua.am
|
58d60832a34ec55e9f8a9fdc7b5dbb3138f9b5a0
|
7a3708c2ac2e98d3126fe3a1863de1b0f08c9d29
|
/Redirector/SocksHelper.cpp
|
c8552bd4010a0ebb3714e2bc362d90420d704518
|
[
"MIT"
] |
permissive
|
Fantickwelrod/netch
|
050f0dc0377d04e83f1eb67b20ae4f997d4a0471
|
8b98df81e5730b331c681de7aef8672f80dae847
|
refs/heads/main
| 2023-07-31T14:33:23.921731
| 2021-09-21T08:39:07
| 2021-09-21T08:39:07
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,065
|
cpp
|
#include "SocksHelper.h"
#include "Utils.h"
extern wstring tgtHost;
extern wstring tgtPort;
extern string tgtUsername;
extern string tgtPassword;
SOCKET SocksHelper::Utils::Connect()
{
auto client = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
if (!client)
{
printf("[Redirector][SocksHelper::Utils::Connect] Create socket failed: %d\n", WSAGetLastError());
return NULL;
}
{
int v6only = 0;
if (setsockopt(client, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&v6only, sizeof(v6only)) == SOCKET_ERROR)
{
printf("[Redirector][SocksHelper::Utils::Connect] Set socket option failed: %d\n", WSAGetLastError());
closesocket(client);
return NULL;
}
}
timeval timeout;
timeout.tv_sec = 4;
if (!WSAConnectByNameW(client, (LPWSTR)tgtHost.c_str(), (LPWSTR)tgtPort.c_str(), NULL, NULL, NULL, NULL, &timeout, NULL))
{
printf("[Redirector][SocksHelper::Utils::Connect] Connect to remote server failed: %d\n", WSAGetLastError());
closesocket(client);
return NULL;
}
return client;
}
bool SocksHelper::Utils::Handshake(SOCKET client)
{
char buffer[1024];
memset(buffer, 0, sizeof(buffer));
/* Client Hello */
buffer[0] = 0x05;
buffer[1] = 0x02;
buffer[2] = 0x00;
buffer[3] = 0x02;
if (send(client, buffer, 4, 0) != 4)
{
printf("[Redirector][SocksHelper::Utils::Handshake] Send client hello failed: %d\n", WSAGetLastError());
return false;
}
/* Server Choice */
if (recv(client, buffer, 2, 0) != 2)
{
printf("[Redirector][SocksHelper::Utils::Handshake] Receive server choice failed: %d\n", WSAGetLastError());
return false;
}
/* Authentication */
if (buffer[1] == 0x02)
{
memset(buffer, 0, sizeof(buffer));
buffer[0] = 0x01;
BYTE ulength = tgtUsername.length() & 0xff;
BYTE plength = tgtPassword.length() & 0xff;
/* Username */
buffer[1] = 0x00;
if (ulength != 0)
{
buffer[1] = ulength;
memcpy(buffer + 1 + 1, tgtUsername.c_str(), ulength);
}
/* Password */
buffer[1 + plength] = 0x00;
if (plength != 0)
{
buffer[1 + ulength] = plength;
memcpy(buffer + 1 + 1 + ulength + 1, tgtPassword.c_str(), plength);
}
auto length = 1 + 1 + ulength + 1 + plength;
if (send(client, buffer, length, 0) != length)
{
printf("[Redirector][SocksHelper::Utils::Handshake] Send authentication request failed: %d\n", WSAGetLastError());
return false;
}
}
else if (buffer[1] != 0x00)
{
return false;
}
/* Server Response */
if (recv(client, buffer, 2, 0) != 2)
{
printf("[Redirector][SocksHelper::Utils::Handshake] Receive server response failed: %d\n", WSAGetLastError());
return false;
}
if (buffer[1] != 0x00)
{
puts("[Redirector][SocksHelper::Utils::Handshake] Authentication failed");
return false;
}
return true;
}
bool SocksHelper::Utils::ReadAddr(SOCKET client, char type, PSOCKADDR addr)
{
if (type == 0x01)
{
auto address = (PSOCKADDR_IN)addr;
address->sin_family = AF_INET;
if (recv(client, (char*)&address->sin_addr, 4, 0) != 4)
{
printf("[Redirector][SocksHelper::Utils::ReadAddr] Read IPv4 address failed: %d\n", WSAGetLastError());
return false;
}
if (recv(client, (char*)&address->sin_port, 2, 0) != 2)
{
printf("[Redirector][SocksHelper::Utils::ReadAddr] Read IPv4 port failed: %d\n", WSAGetLastError());
return false;
}
}
else if (type == 0x04)
{
auto address = (PSOCKADDR_IN6)addr;
address->sin6_family = AF_INET6;
if (recv(client, (char*)&address->sin6_addr, 16, 0) != 16)
{
printf("[Redirector][SocksHelper::Utils::ReadAddr] Read IPv6 address failed: %d\n", WSAGetLastError());
return false;
}
if (recv(client, (char*)&address->sin6_port, 2, 0) != 2)
{
printf("[Redirector][SocksHelper::Utils::ReadAddr] Read IPv6 port failed: %d\n", WSAGetLastError());
return false;
}
}
else
{
puts("[Redirector][SocksHelper::Utils::ReadAddr] Unsupported address family");
return false;
}
return true;
}
SocksHelper::TCP::TCP()
{
}
SocksHelper::TCP::TCP(SOCKET tcpSocket)
{
this->tcpSocket = tcpSocket;
}
SocksHelper::TCP::~TCP()
{
if (this->tcpSocket)
{
closesocket(this->tcpSocket);
this->tcpSocket = NULL;
}
}
bool SocksHelper::TCP::Connect(PSOCKADDR target)
{
/* Connect Request */
if (target->sa_family == AF_INET)
{
char buffer[10];
buffer[0] = 0x05;
buffer[1] = 0x01;
buffer[2] = 0x00;
buffer[3] = 0x01;
auto addr = (PSOCKADDR_IN)target;
memcpy(buffer + 4, &addr->sin_addr, 4);
memcpy(buffer + 8, &addr->sin_port, 2);
if (send(this->tcpSocket, buffer, 10, 0) != 10)
{
printf("[Redirector][SocksHelper::TCP::Connect] Send connect request failed: %d\n", WSAGetLastError());
return false;
}
}
else
{
char buffer[22];
buffer[0] = 0x05;
buffer[1] = 0x01;
buffer[2] = 0x00;
buffer[3] = 0x04;
auto addr = (PSOCKADDR_IN6)target;
memcpy(buffer + 4, &addr->sin6_addr, 16);
memcpy(buffer + 20, &addr->sin6_port, 2);
if (send(this->tcpSocket, buffer, 22, 0) != 22)
{
printf("[Redirector][SocksHelper::TCP::Connect] Send connect request failed: %d\n", WSAGetLastError());
return false;
}
}
/* Server Response */
char buffer[4];
if (recv(this->tcpSocket, buffer, 4, 0) != 4)
{
printf("[Redirector][SocksHelper::TCP::Connect] Receive server response failed: %d\n", WSAGetLastError());
return false;
}
if (buffer[1] != 0x00)
{
return false;
}
SOCKADDR_IN6 addr;
return Utils::ReadAddr(this->tcpSocket, buffer[3], (PSOCKADDR)&addr);
}
int SocksHelper::TCP::Send(char* buffer, int length)
{
if (this->tcpSocket)
{
return send(this->tcpSocket, buffer, length, 0);
}
return -1;
}
int SocksHelper::TCP::Read(char* buffer, int length)
{
if (this->tcpSocket)
{
return recv(this->tcpSocket, buffer, length, 0);
}
return -1;
}
SocksHelper::UDP::UDP()
{
}
SocksHelper::UDP::UDP(SOCKET tcpSocket)
{
this->tcpSocket = tcpSocket;
}
SocksHelper::UDP::~UDP()
{
if (this->tcpSocket)
{
closesocket(this->tcpSocket);
this->tcpSocket = NULL;
}
if (this->udpSocket)
{
closesocket(this->udpSocket);
this->udpSocket = NULL;
}
if (this->tcpThread.joinable())
{
this->tcpThread.join();
}
}
bool SocksHelper::UDP::Associate()
{
if (!this->tcpSocket)
{
return false;
}
char buffer[10];
buffer[0] = 0x05;
buffer[1] = 0x03;
buffer[2] = 0x00;
buffer[3] = 0x01;
buffer[4] = 0x00;
buffer[5] = 0x00;
buffer[6] = 0x00;
buffer[7] = 0x00;
buffer[8] = 0x00;
buffer[9] = 0x00;
if (send(this->tcpSocket, buffer, 10, 0) != 10)
{
printf("[Redirector][SocksHelper::UDP::Associate] Send udp associate request failed: %d\n", WSAGetLastError());
return false;
}
if (recv(this->tcpSocket, buffer, 4, 0) != 4)
{
printf("[Redirector][SocksHelper::UDP::Associate] Receive udp associate response failed: %d\n", WSAGetLastError());
return false;
}
if (buffer[1] != 0x00)
{
puts("[Redirector][SocksHelper::UDP::Associate] UDP associate failed");
return false;
}
return Utils::ReadAddr(this->tcpSocket, buffer[3], (PSOCKADDR)&this->address);
}
bool SocksHelper::UDP::CreateUDP()
{
if (this->address.sin6_family == AF_INET6)
{
this->udpSocket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (!this->udpSocket)
{
printf("[Redirector][SocksHelper::UDP::CreateUDP] Create IPv6 socket failed: %d\n", WSAGetLastError());
return false;
}
SOCKADDR_IN6 bindaddr;
memset(&bindaddr, 0, sizeof(SOCKADDR_IN6));
bindaddr.sin6_family = AF_INET6;
if (bind(this->udpSocket, (PSOCKADDR)&bindaddr, sizeof(SOCKADDR_IN6)) == SOCKET_ERROR)
{
printf("[Redirector][SocksHelper::UDP::CreateUDP] Listen IPv6 socket failed: %d\n", WSAGetLastError());
return false;
}
}
else
{
this->udpSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (!this->udpSocket)
{
printf("[Redirector][SocksHelper::UDP::CreateUDP] Create IPv4 socket failed: %d\n", WSAGetLastError());
return false;
}
SOCKADDR_IN bindaddr;
memset(&bindaddr, 0, sizeof(SOCKADDR_IN));
bindaddr.sin_family = AF_INET;
if (bind(this->udpSocket, (PSOCKADDR)&bindaddr, sizeof(SOCKADDR_IN)) == SOCKET_ERROR)
{
printf("[Redirector][SocksHelper::UDP::CreateUDP] Listen IPv4 socket failed: %d\n", WSAGetLastError());
return false;
}
}
return true;
}
int SocksHelper::UDP::Send(PSOCKADDR target, char* buffer, int length)
{
if (!this->udpSocket)
{
return -1;
}
auto data = new char[3 + 1 + 16 + 2 + (ULONG64)length]();
data[3] = (target->sa_family == AF_INET6) ? 0x04 : 0x01;
if (target->sa_family == AF_INET)
{
auto ipv4 = (PSOCKADDR_IN)target;
memcpy(data + 4, &ipv4->sin_addr, 4);
memcpy(data + 8, &ipv4->sin_port, 2);
}
else if (target->sa_family == AF_INET6)
{
auto ipv6 = (PSOCKADDR_IN6)target;
memcpy(data + 4, &ipv6->sin6_addr, 16);
memcpy(data + 20, &ipv6->sin6_port, 2);
}
else
{
delete[] data;
puts("[Redirector][SocksHelper::UDP::Send] Unsupported address family");
return length;
}
memcpy(data + 3 + 1 + (target->sa_family == AF_INET6 ? 16 : 4) + 2, buffer, length);
auto dataLength = 3 + 1 + (target->sa_family == AF_INET6 ? 16 : 4) + 2 + length;
if (sendto(this->udpSocket, data, dataLength, 0, (PSOCKADDR)&this->address, (this->address.sin6_family == AF_INET6 ? sizeof(SOCKADDR_IN6) : sizeof(SOCKADDR_IN))) != dataLength)
{
delete[] data;
printf("[Redirector][SocksHelper::UDP::Send] Send packet failed: %d\n", WSAGetLastError());
return 0;
}
delete[] data;
return dataLength;
}
int SocksHelper::UDP::Read(PSOCKADDR target, char* buffer, int length)
{
if (!this->udpSocket)
{
return -1;
}
auto targetLength = 0;
auto bufferLength = recvfrom(this->udpSocket, buffer, length, 0, target, &targetLength);
if (!bufferLength)
{
if (bufferLength == SOCKET_ERROR)
{
printf("[Redirector][SocksHelper::UDP::Read] Receive packet failed: %d\n", WSAGetLastError());
return 0;
}
return 0;
}
memset(target, 0, sizeof(SOCKADDR_IN6));
if (buffer[3] == 0x04)
{
auto ipv6 = (PSOCKADDR_IN6)target;
ipv6->sin6_family = AF_INET6;
memcpy(&ipv6->sin6_addr, buffer + 4, 16);
memcpy(&ipv6->sin6_port, buffer + 20, 2);
memcpy(buffer, buffer + 22, (ULONG64)bufferLength - 22);
}
else
{
auto ipv4 = (PSOCKADDR_IN)target;
ipv4->sin_family = AF_INET;
memcpy(&ipv4->sin_addr, buffer + 4, 4);
memcpy(&ipv4->sin_port, buffer + 8, 2);
memcpy(buffer, buffer + 10, (ULONG64)bufferLength - 10);
}
return bufferLength - (target->sa_family == AF_INET6 ? 22 : 10);
}
void SocksHelper::UDP::run()
{
char buffer[1];
while (true)
{
if (recv(this->tcpSocket, buffer, 1, 0) != 1)
{
return;
}
if (send(this->tcpSocket, buffer, 1, 0) != 1)
{
return;
}
}
}
|
[
"cutecr@pm.me"
] |
cutecr@pm.me
|
540e044fc406a1b3fd43ca5bca0d00aaaee9fc05
|
6f2b6e9d77fc4dd5e1dae8ba6e5a66eb7c7ae849
|
/sstd_boost/sstd/boost/spirit/home/support/container.hpp
|
efc3657fa4ea987fd0b33cb7ff2da79bad30789d
|
[
"BSL-1.0"
] |
permissive
|
KqSMea8/sstd_library
|
9e4e622e1b01bed5de7322c2682539400d13dd58
|
0fcb815f50d538517e70a788914da7fbbe786ce1
|
refs/heads/master
| 2020-05-03T21:07:01.650034
| 2019-04-01T00:10:47
| 2019-04-01T00:10:47
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 15,523
|
hpp
|
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2001-2011 Hartmut Kaiser
http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(BOOST_SPIRIT_CONTAINER_FEBRUARY_06_2007_1001AM)
#define BOOST_SPIRIT_CONTAINER_FEBRUARY_06_2007_1001AM
#if defined(_MSC_VER)
#pragma once
#endif
#include <sstd/boost/spirit/home/support/unused.hpp>
#include <sstd/boost/spirit/home/support/attributes_fwd.hpp>
#include <sstd/boost/detail/iterator.hpp> // for boost::detail::iterator_traits
#include <sstd/boost/mpl/has_xxx.hpp>
#include <sstd/boost/mpl/bool.hpp>
#include <sstd/boost/optional.hpp>
#include <sstd/boost/variant.hpp>
#include <sstd/boost/preprocessor/cat.hpp>
#include <sstd/boost/preprocessor/repeat.hpp>
#include <sstd/boost/range/iterator_range.hpp>
namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
// This file contains some container utils for stl containers. The
// utilities provided also accept spirit's unused_type; all no-ops.
// Compiler optimization will easily strip these away.
///////////////////////////////////////////////////////////////////////////
namespace detail
{
BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type)
BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator)
BOOST_MPL_HAS_XXX_TRAIT_DEF(size_type)
BOOST_MPL_HAS_XXX_TRAIT_DEF(reference)
}
template <typename T, typename Enable/* = void*/>
struct is_container
: mpl::bool_<
detail::has_value_type<T>::value &&
detail::has_iterator<T>::value &&
detail::has_size_type<T>::value &&
detail::has_reference<T>::value>
{};
template <typename T>
struct is_container<T&>
: is_container<T>
{};
template <typename T>
struct is_container<boost::optional<T> >
: is_container<T>
{};
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
template<typename T>
struct is_container<boost::variant<T> >
: is_container<T>
{};
template<typename T0, typename T1, typename ...TN>
struct is_container<boost::variant<T0, T1, TN...> >
: mpl::bool_<is_container<T0>::value ||
is_container<boost::variant<T1, TN...> >::value>
{};
#else
#define BOOST_SPIRIT_IS_CONTAINER(z, N, data) \
is_container<BOOST_PP_CAT(T, N)>::value || \
/***/
// make sure unused variant parameters do not affect the outcome
template <>
struct is_container<boost::detail::variant::void_>
: mpl::false_
{};
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct is_container<variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
: mpl::bool_<BOOST_PP_REPEAT(BOOST_VARIANT_LIMIT_TYPES
, BOOST_SPIRIT_IS_CONTAINER, _) false>
{};
#undef BOOST_SPIRIT_IS_CONTAINER
#endif
template <typename T, typename Enable/* = void*/>
struct is_iterator_range
: mpl::false_
{};
template <typename T>
struct is_iterator_range<iterator_range<T> >
: mpl::true_
{};
///////////////////////////////////////////////////////////////////////////
namespace detail
{
template <typename T>
struct remove_value_const
{
typedef T type;
};
template <typename T>
struct remove_value_const<T const>
: remove_value_const<T>
{};
template <typename F, typename S>
struct remove_value_const<std::pair<F, S> >
{
typedef typename remove_value_const<F>::type first_type;
typedef typename remove_value_const<S>::type second_type;
typedef std::pair<first_type, second_type> type;
};
}
///////////////////////////////////////////////////////////////////////
//[customization_container_value_default
template <typename Container, typename Enable/* = void*/>
struct container_value
: detail::remove_value_const<typename Container::value_type>
{};
//]
template <typename T>
struct container_value<T&>
: container_value<T>
{};
// this will be instantiated if the optional holds a container
template <typename T>
struct container_value<boost::optional<T> >
: container_value<T>
{};
// this will be instantiated if the variant holds a container
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct container_value<variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
{
typedef typename
variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types
types;
typedef typename
mpl::find_if<types, is_container<mpl::_1> >::type
iter;
typedef typename container_value<
typename mpl::if_<
is_same<iter, typename mpl::end<types>::type>
, unused_type, typename mpl::deref<iter>::type
>::type
>::type type;
};
//[customization_container_value_unused
template <>
struct container_value<unused_type>
{
typedef unused_type type;
};
//]
template <>
struct container_value<unused_type const>
{
typedef unused_type type;
};
///////////////////////////////////////////////////////////////////////////
template <typename Container, typename Enable/* = void*/>
struct container_iterator
{
typedef typename Container::iterator type;
};
template <typename Container>
struct container_iterator<Container&>
: container_iterator<Container>
{};
template <typename Container>
struct container_iterator<Container const>
{
typedef typename Container::const_iterator type;
};
template <typename T>
struct container_iterator<optional<T> >
: container_iterator<T>
{};
template <typename T>
struct container_iterator<optional<T> const>
: container_iterator<T const>
{};
template <typename Iterator>
struct container_iterator<iterator_range<Iterator> >
{
typedef typename range_const_iterator<
iterator_range<Iterator> >::type type;
};
template <>
struct container_iterator<unused_type>
{
typedef unused_type const* type;
};
template <>
struct container_iterator<unused_type const>
{
typedef unused_type const* type;
};
///////////////////////////////////////////////////////////////////////////
template <typename T, typename Enable/* = void*/>
struct optional_attribute
{
typedef T const& type;
static type call(T const& val)
{
return val;
}
static bool is_valid(T const&)
{
return true;
}
};
template <typename T>
struct optional_attribute<boost::optional<T> >
{
typedef T const& type;
static type call(boost::optional<T> const& val)
{
return boost::get<T>(val);
}
static bool is_valid(boost::optional<T> const& val)
{
return !!val;
}
};
template <typename T>
typename optional_attribute<T>::type
optional_value(T const& val)
{
return optional_attribute<T>::call(val);
}
inline unused_type optional_value(unused_type)
{
return unused;
}
template <typename T>
bool has_optional_value(T const& val)
{
return optional_attribute<T>::is_valid(val);
}
inline bool has_optional_value(unused_type)
{
return true;
}
///////////////////////////////////////////////////////////////////////////
template <typename Container, typename T>
bool push_back(Container& c, T const& val);
//[customization_push_back_default
template <typename Container, typename T, typename Enable/* = void*/>
struct push_back_container
{
static bool call(Container& c, T const& val)
{
c.insert(c.end(), val);
return true;
}
};
//]
template <typename Container, typename T>
struct push_back_container<optional<Container>, T>
{
static bool call(boost::optional<Container>& c, T const& val)
{
if (!c)
c = Container();
return push_back(boost::get<Container>(c), val);
}
};
namespace detail
{
template <typename T>
struct push_back_visitor : public static_visitor<>
{
typedef bool result_type;
push_back_visitor(T const& t) : t_(t) {}
template <typename Container>
bool push_back_impl(Container& c, mpl::true_) const
{
return push_back(c, t_);
}
template <typename T_>
bool push_back_impl(T_&, mpl::false_) const
{
// this variant doesn't hold a container
BOOST_ASSERT(false && "This variant doesn't hold a container");
return false;
}
template <typename T_>
bool operator()(T_& c) const
{
return push_back_impl(c, typename is_container<T_>::type());
}
T const& t_;
};
}
template <BOOST_VARIANT_ENUM_PARAMS(typename T_), typename T>
struct push_back_container<variant<BOOST_VARIANT_ENUM_PARAMS(T_)>, T>
{
static bool call(variant<BOOST_VARIANT_ENUM_PARAMS(T_)>& c, T const& val)
{
return apply_visitor(detail::push_back_visitor<T>(val), c);
}
};
template <typename Container, typename T>
bool push_back(Container& c, T const& val)
{
return push_back_container<Container, T>::call(c, val);
}
//[customization_push_back_unused
template <typename Container>
bool push_back(Container&, unused_type)
{
return true;
}
//]
template <typename T>
bool push_back(unused_type, T const&)
{
return true;
}
inline bool push_back(unused_type, unused_type)
{
return true;
}
///////////////////////////////////////////////////////////////////////////
template <typename Container, typename Enable/* = void*/>
struct is_empty_container
{
static bool call(Container const& c)
{
return c.empty();
}
};
template <typename Container>
bool is_empty(Container const& c)
{
return is_empty_container<Container>::call(c);
}
inline bool is_empty(unused_type)
{
return true;
}
///////////////////////////////////////////////////////////////////////////
// Ensure the attribute is actually a container type
template <typename Container, typename Enable/* = void*/>
struct make_container_attribute
{
static void call(Container&)
{
// for static types this function does nothing
}
};
template <typename T>
void make_container(T& t)
{
make_container_attribute<T>::call(t);
}
inline void make_container(unused_type)
{
}
///////////////////////////////////////////////////////////////////////////
template <typename Container, typename Enable/* = void*/>
struct begin_container
{
static typename container_iterator<Container>::type call(Container& c)
{
return c.begin();
}
};
template <typename Container>
typename spirit::result_of::begin<Container>::type
begin(Container& c)
{
return begin_container<Container>::call(c);
}
inline unused_type const*
begin(unused_type)
{
return &unused;
}
///////////////////////////////////////////////////////////////////////////
template <typename Container, typename Enable/* = void*/>
struct end_container
{
static typename container_iterator<Container>::type call(Container& c)
{
return c.end();
}
};
template <typename Container>
inline typename spirit::result_of::end<Container>::type
end(Container& c)
{
return end_container<Container>::call(c);
}
inline unused_type const*
end(unused_type)
{
return &unused;
}
///////////////////////////////////////////////////////////////////////////
template <typename Iterator, typename Enable/* = void*/>
struct deref_iterator
{
typedef typename boost::detail::iterator_traits<Iterator>::reference type;
static type call(Iterator& it)
{
return *it;
}
};
template <typename Iterator>
typename deref_iterator<Iterator>::type
deref(Iterator& it)
{
return deref_iterator<Iterator>::call(it);
}
inline unused_type
deref(unused_type const*)
{
return unused;
}
///////////////////////////////////////////////////////////////////////////
template <typename Iterator, typename Enable/* = void*/>
struct next_iterator
{
static void call(Iterator& it)
{
++it;
}
};
template <typename Iterator>
void next(Iterator& it)
{
next_iterator<Iterator>::call(it);
}
inline void next(unused_type const*)
{
// do nothing
}
///////////////////////////////////////////////////////////////////////////
template <typename Iterator, typename Enable/* = void*/>
struct compare_iterators
{
static bool call(Iterator const& it1, Iterator const& it2)
{
return it1 == it2;
}
};
template <typename Iterator>
bool compare(Iterator& it1, Iterator& it2)
{
return compare_iterators<Iterator>::call(it1, it2);
}
inline bool compare(unused_type const*, unused_type const*)
{
return false;
}
}}}
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace result_of
{
///////////////////////////////////////////////////////////////////////////
template <typename T>
struct optional_value
{
typedef T type;
};
template <typename T>
struct optional_value<boost::optional<T> >
{
typedef T type;
};
template <typename T>
struct optional_value<boost::optional<T> const>
{
typedef T const type;
};
template <>
struct optional_value<unused_type>
{
typedef unused_type type;
};
template <>
struct optional_value<unused_type const>
{
typedef unused_type type;
};
///////////////////////////////////////////////////////////////////////////
template <typename Container>
struct begin
: traits::container_iterator<Container>
{};
template <typename Container>
struct end
: traits::container_iterator<Container>
{};
template <typename Iterator>
struct deref
: traits::deref_iterator<Iterator>
{};
template <>
struct deref<unused_type const*>
{
typedef unused_type type;
};
}}}
#endif
|
[
"zhaixueqiang@hotmail.com"
] |
zhaixueqiang@hotmail.com
|
1699d721115e532daf0e04e05c4931bfe3f07967
|
fb7efe44f4d9f30d623f880d0eb620f3a81f0fbd
|
/components/variations/variations_associated_data.h
|
6eb51f3eca500b6916bea8f2d9b59015016419da
|
[
"BSD-3-Clause"
] |
permissive
|
wzyy2/chromium-browser
|
2644b0daf58f8b3caee8a6c09a2b448b2dfe059c
|
eb905f00a0f7e141e8d6c89be8fb26192a88c4b7
|
refs/heads/master
| 2022-11-23T20:25:08.120045
| 2018-01-16T06:41:26
| 2018-01-16T06:41:26
| 117,618,467
| 3
| 2
|
BSD-3-Clause
| 2022-11-20T22:03:57
| 2018-01-16T02:09:10
| null |
UTF-8
|
C++
| false
| false
| 7,252
|
h
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_
#define COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "components/variations/active_field_trials.h"
// This file provides various helpers that extend the functionality around
// base::FieldTrial.
//
// This includes several simple APIs to handle getting and setting additional
// data related to Chrome variations, such as parameters and Google variation
// IDs. These APIs are meant to extend the base::FieldTrial APIs to offer extra
// functionality that is not offered by the simpler base::FieldTrial APIs.
//
// The AssociateGoogleVariationID and AssociateVariationParams functions are
// generally meant to be called by the VariationsService based on server-side
// variation configs, but may also be used for client-only field trials by
// invoking them directly after appending all the groups to a FieldTrial.
//
// Experiment code can then use the getter APIs to retrieve variation parameters
// or IDs:
//
// std::map<std::string, std::string> params;
// if (GetVariationParams("trial", ¶ms)) {
// // use |params|
// }
//
// std::string value = GetVariationParamValue("trial", "param_x");
// // use |value|, which will be "" if it does not exist
//
// VariationID id = GetGoogleVariationID(GOOGLE_WEB_PROPERTIES, "trial",
// "group1");
// if (id != variations::kEmptyID) {
// // use |id|
// }
namespace base {
struct Feature;
} // namespace base
namespace variations {
typedef int VariationID;
const VariationID EMPTY_ID = 0;
// A key into the Associate/Get methods for VariationIDs. This is used to create
// separate ID associations for separate parties interested in VariationIDs.
enum IDCollectionKey {
// This collection is used by Google web properties, transmitted through the
// X-Client-Data header.
GOOGLE_WEB_PROPERTIES,
// This collection is used by Google web properties for signed in users only,
// transmitted through the X-Client-Data header.
GOOGLE_WEB_PROPERTIES_SIGNED_IN,
// This collection is used by Google web properties for IDs that trigger
// server side experimental behavior, transmitted through the
// X-Client-Data header.
GOOGLE_WEB_PROPERTIES_TRIGGER,
// This collection is used by Chrome Sync services, transmitted through the
// Chrome Sync experiment labels.
CHROME_SYNC_SERVICE,
// The total count of collections.
ID_COLLECTION_COUNT,
};
// Associate a variations::VariationID value with a FieldTrial group for
// collection |key|. If an id was previously set for |trial_name| and
// |group_name|, this does nothing. The group is denoted by |trial_name| and
// |group_name|. This must be called whenever a FieldTrial is prepared (create
// the trial and append groups) and needs to have a variations::VariationID
// associated with it so Google servers can recognize the FieldTrial.
// Thread safe.
void AssociateGoogleVariationID(IDCollectionKey key,
const std::string& trial_name,
const std::string& group_name,
VariationID id);
// As above, but overwrites any previously set id. Thread safe.
void AssociateGoogleVariationIDForce(IDCollectionKey key,
const std::string& trial_name,
const std::string& group_name,
VariationID id);
// As above, but takes an ActiveGroupId hash pair, rather than the string names.
void AssociateGoogleVariationIDForceHashes(IDCollectionKey key,
const ActiveGroupId& active_group,
VariationID id);
// Retrieve the variations::VariationID associated with a FieldTrial group for
// collection |key|. The group is denoted by |trial_name| and |group_name|.
// This will return variations::kEmptyID if there is currently no associated ID
// for the named group. This API can be nicely combined with
// FieldTrial::GetActiveFieldTrialGroups() to enumerate the variation IDs for
// all active FieldTrial groups. Thread safe.
VariationID GetGoogleVariationID(IDCollectionKey key,
const std::string& trial_name,
const std::string& group_name);
// Same as GetGoogleVariationID(), but takes in a hashed |active_group| rather
// than the string trial and group name.
VariationID GetGoogleVariationIDFromHashes(IDCollectionKey key,
const ActiveGroupId& active_group);
// Deprecated. Use base::AssociateFieldTrialParams() instead.
bool AssociateVariationParams(const std::string& trial_name,
const std::string& group_name,
const std::map<std::string, std::string>& params);
// Deprecated. Use base::GetFieldTrialParams() instead.
bool GetVariationParams(const std::string& trial_name,
std::map<std::string, std::string>* params);
// Deprecated. Use base::GetFieldTrialParamsByFeature() instead.
bool GetVariationParamsByFeature(const base::Feature& feature,
std::map<std::string, std::string>* params);
// Deprecated. Use base::GetFieldTrialParamValue() instead.
std::string GetVariationParamValue(const std::string& trial_name,
const std::string& param_name);
// Deprecated. Use base::GetFieldTrialParamValueByFeature() instead.
std::string GetVariationParamValueByFeature(const base::Feature& feature,
const std::string& param_name);
// Deprecated. Use base::GetFieldTrialParamByFeatureAsInt() instead.
int GetVariationParamByFeatureAsInt(const base::Feature& feature,
const std::string& param_name,
int default_value);
// Deprecated. Use base::GetFieldTrialParamByFeatureAsDouble() instead.
double GetVariationParamByFeatureAsDouble(const base::Feature& feature,
const std::string& param_name,
double default_value);
// Deprecated. Use base::GetFieldTrialParamByFeatureAsBool() instead.
bool GetVariationParamByFeatureAsBool(const base::Feature& feature,
const std::string& param_name,
bool default_value);
// Expose some functions for testing.
namespace testing {
// Clears all of the mapped associations. Deprecated, try to use
// VariationParamsManager instead as it does a lot of work for you
// automatically.
void ClearAllVariationIDs();
// Clears all of the associated params. Deprecated, try to use
// VariationParamsManager instead as it does a lot of work for you
// automatically.
void ClearAllVariationParams();
} // namespace testing
} // namespace variations
#endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_
|
[
"jacob-chen@iotwrt.com"
] |
jacob-chen@iotwrt.com
|
7b3fc318740ddb4ef0dcb2c5d19d1a3df8a7582b
|
dd1a4ca7020ba5cac93d90829798a3a6f80d33a1
|
/others/water/luogu3661.cpp
|
e8a9947da7b6fee8e77b10edf890f15babbcc6ac
|
[] |
no_license
|
Exbilar/Source
|
a0f85b8b47840a4212fd4a9f713f978cab13e9a3
|
b8bc0dc52e51f6c4986bd0f37de61b13d98e6e8c
|
refs/heads/master
| 2022-05-03T22:35:57.300520
| 2022-03-14T09:03:03
| 2022-03-14T09:03:03
| 97,890,246
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,372
|
cpp
|
#include <bits/stdc++.h>
#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
using std :: max;
using std :: min;
using std :: set;
using std :: pair;
using std :: make_pair;
using std :: vector;
using std :: queue;
using std :: multiset;
using std :: priority_queue;
typedef long long LL;
typedef pair<int,int> pii;
static const int maxm = 1e6 + 10;
static const int INF = 1 << 30;
template <class T> void read(T &in){
in = 0; int f = 1 ;char ch = getchar();
for(;ch < '0' || ch > '9';ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9';ch = getchar()) in = in * 10 + ch - '0';
in = in * f;
}
template <class T> inline bool chkmax(T &x,T y){
return x < y ? x = y,true : false;
}
template <class T> inline bool chkmin(T &x,T y){
return x > y ? x = y,true : false;
}
struct Segment{
int l,r;
bool operator < (const Segment &Seg) const {
return r == Seg.r ? l < Seg.l : r < Seg.r;
}
}seg[maxm];
int T[maxm];
int N,C;
multiset<int> S;
typedef multiset<int> :: iterator itr;
int main(){
read(C),read(N);
for(int i = 1;i <= C;i++) read(T[i]),S.insert(T[i]);
for(int i = 1;i <= N;i++) read(seg[i].l),read(seg[i].r);
std :: sort(seg + 1,seg + N + 1);
int ans = 0;
for(int i = 1;i <= N;i++){
itr it = S.lower_bound(seg[i].l);
if(*it <= seg[i].r && it != S.end()){
ans++;
S.erase(it);
}
}
printf("%d\n",ans);
return 0;
}
|
[
"exbilar@gmail.com"
] |
exbilar@gmail.com
|
5b2526ee3ea06cf9ad82863fc5831270e563af1c
|
cd712c98c37403321d6feaddfe3033355d81338d
|
/proj3/src/ssa/symtable/symtable.cpp
|
720952125c05797305be96f0fb38c03df9300749
|
[] |
no_license
|
jwnhy/CS323-Project
|
be61d7e94b2feefcdeed60213ed10f19e92ae7d6
|
4e539480562d581d2518242cc820f4d52d29f814
|
refs/heads/master
| 2023-01-29T03:07:48.458201
| 2020-12-09T01:07:28
| 2020-12-09T01:07:28
| 300,314,171
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,295
|
cpp
|
#include "symtable.h"
using namespace std;
vector<pair<Type*, SymTable*>> scope_stack;
int CNT = 0;
void init() {
scope_stack.clear();
SymTable* global_table = new SymTable();
scope_stack.push_back({NULL, global_table});
}
void enter(Type* ret_type) {
scope_stack.push_back({ret_type, new SymTable()});
}
void exit() {
scope_stack.pop_back();
}
void insert(Entry* entry) {
SymTable* scope = scope_stack.back().second;
string name;
auto iter = scope->find(entry->original_name());
if (iter == scope->end()) {
array<Entry*, 3> entry_arr{0, 0, 0};
entry_arr[(int)entry->entry_type] = entry;
scope->insert({entry->original_name(), entry_arr});
} else {
auto& entry_arr = (*iter).second;
if (entry_arr[(int)entry->entry_type] == NULL)
entry_arr[(int)entry->entry_type] = entry;
else {
switch (entry->entry_type) {
case EntryType::FIELD:
add_err(ErrorType::VAR_REDEF, entry->lineno,
"Variable Redefinition", "");
break;
case EntryType::FUNC:
add_err(ErrorType::FUNC_REDEF, entry->lineno,
"Function Redefinition", "");
break;
case EntryType::TYPE:
add_err(ErrorType::STRUCT_REDEF, entry->lineno,
"Structure Redefinition", "");
break;
}
}
}
}
Entry* lookup(string name, EntryType entry_type) {
for (auto scope_iter = scope_stack.end() - 1;
scope_iter >= scope_stack.begin(); scope_iter--) {
SymTable* scope = (*scope_iter).second;
auto item = scope->find(name);
if (item != scope->end() && item->second[(int)entry_type])
return item->second[(int)entry_type];
}
return NULL;
}
string to_str(Type* type) {
if (type->category == Category::PRIMITIVE) {
if (type->primitive == Primitive::INT)
return "INT";
else if (type->primitive == Primitive::FLOAT)
return "FLOAT";
else if (type->primitive == Primitive::INT)
return "CHAR";
else if (type->primitive == Primitive::NEXP)
return "NON-EXP";
else
return to_string(static_cast<int>(type->primitive));
} else if (type->category == Category::STRUCT) {
return "struct " + type->structure->name;
} else {
return to_str(type->array->base) + "[" + to_string(type->array->size) +
"]";
}
}
std::string temp_var() {
return "t_" + std::to_string(CNT++);
}
std::string temp_label() {
return "l_" + std::to_string(CNT++);
}
std::string temp_pointer() {
return "p_" + std::to_string(CNT++);
}
string to_str(Field* field, int indent = 0) {
Type* type = field->type;
string name = field->name;
return string(indent, ' ') + to_str(type) + ": " + name + " (" +
to_string(field->lineno) + ")";
}
string to_str(Struct* structure, int indent = 0) {
string s = string(indent, ' ') + "struct " + structure->name + " {\n";
for (auto f : structure->fields) {
s = s + string(indent, ' ') + to_str(f, 2) + "\n";
}
s = s + string(indent, ' ') + "}";
return s;
}
string to_str(Func* func, int indent = 0) {
string s = string(indent, ' ') + to_str(func->ret) + " " + func->name + "(";
for (auto f : func->params) {
s = s + string(indent, ' ') + to_str(f) + ", ";
}
s = s + string(indent, ' ') + ")";
return s;
}
void print_entry(Entry* entry, int indent = 0) {
if (!entry)
return;
if (entry->entry_type == EntryType::FIELD) {
cout << to_str(entry->field, indent);
} else if (entry->entry_type == EntryType::TYPE) {
cout << to_str(entry->type->structure, indent);
} else {
cout << to_str(entry->func, indent);
}
cout << "\n";
}
void print_symtable() {
int indent = 0;
for (auto t : scope_stack) {
for (auto p : *t.second) {
auto entry = p.second;
print_entry(entry[0], indent);
print_entry(entry[1], indent);
print_entry(entry[2], indent);
}
indent += 2;
}
}
|
[
"799433746@qq.com"
] |
799433746@qq.com
|
dfd6ed846949320215737c3bd33bb9e4b3d2a466
|
399e439f7d7bd2aa35569868276cb50332c91a97
|
/graph/mincostflow.h
|
050b5cc69a1766b1e1c9a3c3c4d3e04b74b0e480
|
[] |
no_license
|
tenkuunoyoake/Algorithm
|
f733e32c3ab62369af3aa32797a0a47322fe5b3e
|
aa4f2c51b8355f6a0b3985adb5d8317945510eff
|
refs/heads/master
| 2021-07-04T03:06:03.366968
| 2017-09-25T19:05:49
| 2017-09-25T19:05:49
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,116
|
h
|
template<class C, class D, class E>
struct MinCostFlow {
static const D INF = numeric_limits<D>::max();
VV<E> g;
int s, t;
C nc, cap_flow;
D nd, flow;
V<D> dual;
V<int> pv, pe;
MinCostFlow(VV<E> g, int s, int t, bool neg) : g(g), s(s), t(t), cap_flow(0), flow(0) {
assert(s != t);
dual = V<D>(g.size());
pv = V<int>(g.size());
pe = V<int>(g.size());
dual_ref(neg);
}
C single_flow(C c) {
if (nd == INF) return nc;
c = min(c, nc);
for (int v = t; v != s; v = pv[v]) {
E &e = g[pv[v]][pe[v]];
e.cap -= c;
g[v][e.rev].cap += c;
}
cap_flow += c;
flow += c * nd;
nc -= c;
if (!nc) dual_ref(false);
return c;
}
void max_flow(C c) {
while (c) {
C f = single_flow(c);
if (!f) break;
c -= f;
}
}
void dual_ref(bool neg) {
V<D> dist(g.size(), INF);
fill(begin(pv), end(pv), -1);
fill(begin(pe), end(pe), -1);
using P = pair<D, int>;
queue<int> ref_v;
priority_queue<P, vector<P>, greater<P>> que1;
queue<P> que2;
auto empty = [&] {
return (!neg) ? que1.empty() : que2.empty();
};
auto push = [&](P p) {
(!neg) ? que1.push(p) : que2.push(p);
};
auto pop = [&]() {
P p = (!neg) ? que1.top() : que2.front();
(!neg) ? que1.pop() : que2.pop();
return p;
};
push(P(0, s));
dist[s] = 0;
while (!empty()) {
P p = pop();
int v = p.second;
if (dist[v] < p.first) continue;
if (!neg) {
if (v == t) break;
ref_v.push(v);
}
for (int i = 0; i < int(g[v].size()); i++) {
E e = g[v][i];
D ed = e.dist + dual[v] - dual[e.to];
if (e.cap && dist[e.to] > dist[v] + ed) {
dist[e.to] = dist[v] + ed;
pv[e.to] = v; pe[e.to] = i;
push(P(dist[e.to], e.to));
}
}
}
if (dist[t] == INF) {
nd = INF;
nc = 0;
return;
}
if (!neg) {
while (ref_v.size()) {
int v = ref_v.front(); ref_v.pop();
if (dist[v] >= dist[t]) continue;
dual[v] += dist[v]-dist[t];
}
} else {
for (int v = 0; v < int(g.size()); v++) {
dual[v] += dist[v];
}
}
nd = dual[t]-dual[s];
assert(0 <= nd);
nc = numeric_limits<C>::max();
for (int v = t; v != s; v = pv[v]) {
nc = min(nc, g[pv[v]][pe[v]].cap);
}
}
};
template<class C, class D, class E>
auto min_cost_flow(VV<E> g, int s, int t, bool neg = false) {
return MinCostFlow<C, D, E>(g, s, t, neg);
}
/*
template<class C, class D> // cap, dist (C must be integer)
struct MinCostFlow {
int N;
C nc; D nd;
D INF, EPS;
V<D> h, dist;
template<class E>
MinCostFlow(const VV<E> &g, D INF, D EPS) : INF(INF), EPS(EPS) {
N = int(g.size());
h = V<D>(N);
dist = V<D>(N);
pv = V<int>(N); pe = V<int>(N);
visited = V<int>(N);
fill(begin(h), end(h), 0);
nc = nd = 0;
}
int s, t;
template<class E>
void set_ends(const VV<E> &g, int s, int t, bool neg = false) {
this->s = s; this->t = t;
pot_ref(g, neg);
}
template<class E>
C single_flow(VV<E> &g, C c) {
c = min(c, nc);
for (int v = t; v != s; v = pv[v]) {
E &e = g[pv[v]][pe[v]];
e.cap -= c;
g[v][e.rev].cap += c;
}
nc -= c;
if (!nc) pot_ref(g, false);
return c;
}
V<int> visited; int vid = 114514;
template<class E>
C dfs(VV<E> &g, int v, C c) {
visited[v] = vid;
C sm = 0;
for (E &e: g[v]) {
D ed = e.dist + h[v] - h[e.to];
if (!e.cap || visited[e.to] == vid) continue;
if (EPS < ed) continue;
C u;
if (e.to == t) {
u = min(c, e.cap);
} else {
u = dfs(g, e.to, min(e.cap, c-sm));
}
sm += u;
e.cap -= u;
g[e.to][e.rev].cap += u;
if (c-sm <= 0) break;
}
return sm;
}
template<class E>
C multi_flow(VV<E> &g, C c) {
C sm = 0;
while (true) {
vid++;
C res = dfs(g, s, c);
if (!res) break;
sm += res;
c -= res;
}
pot_ref(g, false);
return sm;
}
template<class R, class E> // R = C*T
R max_flow(VV<E> &g, int s, int t, C c, bool neg = false) {
R res = 0;
set_ends(g, s, t, neg);
while (c) {
D d = nd;
C f = multi_flow(g, c);
// C f = single_flow(g, c);
if (!f) break;
res += R(f) * d;
c -= f;
}
return res;
}
V<int> pv, pe;
template<class E>
void pot_ref(const VV<E> &g, bool neg) {
fill(begin(dist), end(dist), INF);
using P = pair<D, int>;
queue<int> ref_v;
priority_queue<P, vector<P>, greater<P>> que1;
queue<P> que2;
auto empty = [&] {
return (!neg) ? que1.empty() : que2.empty();
};
auto push = [&](P p) {
(!neg) ? que1.push(p) : que2.push(p);
};
auto pop = [&]() {
P p = (!neg) ? que1.top() : que2.front();
(!neg) ? que1.pop() : que2.pop();
return p;
};
push(P(0, s));
dist[s] = 0;
while (!empty()) {
P p = pop();
int v = p.second;
if (dist[v] < p.first) continue;
if (!neg) {
if (v == t) break;
ref_v.push(v);
}
for (int i = 0; i < (int)g[v].size(); i++) {
E e = g[v][i];
D ed = e.dist + h[v] - h[e.to];
if (e.cap && dist[e.to] > dist[v] + ed) {
dist[e.to] = dist[v] + ed;
pv[e.to] = v; pe[e.to] = i;
push(P(dist[e.to], e.to));
}
}
}
if (!neg) {
while (ref_v.size()) {
int v = ref_v.front(); ref_v.pop();
if (dist[v] >= dist[t]) continue;
h[v] += dist[v]-dist[t];
}
} else {
for (int v = 0; v < N; v++) {
h[v] += dist[v];
}
}
if (dist[t] == INF) {
nd = INF;
nc = 0;
return;
}
nd = h[t]-h[s];
nc = INF;
for (int v = t; v != s; v = pv[v]) {
nc = min(nc, g[pv[v]][pe[v]].cap);
}
}
};
*/
|
[
"yosupo06@gmail.com"
] |
yosupo06@gmail.com
|
814e3bde84ad849496558f5a22e3bdffbd5568e6
|
6f0c993b062f965f5bbf37a6d5f26a8f47e828ce
|
/BD.cpp
|
2a686f8ca5cf499dbdbfe28344a7e08d8fe6766b
|
[] |
no_license
|
b21quocbao/Competitive-Programming
|
99a6c61d96597e625a313b5fdaa98b00eef62770
|
3e033b6290745f62f1719fe9f6f1421952d2db91
|
refs/heads/master
| 2022-08-25T19:00:14.223802
| 2020-03-13T05:29:27
| 2020-03-13T05:29:27
| 242,359,060
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,354
|
cpp
|
#include <bits/stdc++.h>
#define fn "test"
#define fn1 "BD"
using namespace std;
const int mn = 1 * (int)(1e3) + 10;
const int mod = 1 * (int)(1e9) + 7;
const int mm = 1 * (int)(1e2) + 10;
const int base = 1 * (int)(1e9);
const bool aNs = 0;
struct node
{
int a, b, x, y;
};
int tt, ntest = 1;
int n, m;
pair<int, int> d[mn];
int a[5][mm];
vector<node> sol;
bool ok1[mm][mm];
bool ok[mm][mm];
pair<int, int> tr[mm][mm], tr1[mm][mm];
int hx[4] = {0, 0, 1, - 1};
int hy[4] = {1, - 1, 0, 0};
int cr[mm][mm];
void docfile()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
if (ifstream(fn".inp"))
{
freopen(fn".inp", "r", stdin);
if (!aNs) freopen(fn".out", "w", stdout);
else freopen (fn".ans", "w", stdout);
}else if (ifstream(fn1".inp"))
{
freopen(fn1".inp", "r", stdin);
freopen(fn1".out", "w", stdout);
}
}
template <typename T>
void read(T& x)
{
x = 0; T f = 1;
char ch = getchar();
while (!isdigit(ch)) f = ch == '-' ? - f : f, ch = getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
x *= f;
}
template <typename T>
void write (T a)
{
if (a < 0)
{
putchar ('-');
write (-a);
return;
}
if (a < 10)
{
putchar ('0' + a);
return;
}
write (a / 10);
putchar ((char)('0' + (a % 10)));
}
void bfs (int x, int y, int a, int b, bool ok[mm][mm], pair<int, int> tr[mm][mm])
{
queue<pair<int, int> > qu;
qu.push ({x, y});
while (qu.size())
{
int x = qu.front().first, y = qu.front().second;
qu.pop();
for (int hg = 0; hg < 4; ++ hg)
{
int X = x + hx[hg], Y = y + hy[hg];
if (X < 1 || X > 3 || Y < 1 || Y > n) continue;
if (!cr[X][Y] && !ok[X][Y])
{
qu.push ({X, Y});
ok[X][Y] = 1;
tr[X][Y] = {x, y};
if (X == a && Y == b) return;
}
}
}
}
void sw (int x1, int y1, int x, int y)
{
if (x1 == x && y1 == y) return;
if (a[x1][y1] != 1 && a[x][y] != 1) cerr << "dmm\n";
d[a[x][y]] = {x1, y1};
d[a[x1][y1]] = {x, y};
sol.push_back({x1, y1, x, y});
swap (a[x1][y1], a[x][y]);
}
void ch1 (int x, int y)
{
if (d[1].first == x && d[1].second == y) return;
memset (ok1, 0, sizeof (ok1));
ok1[d[1].first][d[1].second] = 1;
tr1[d[1].first][d[1].second] = {0, 0};
vector<pair<int, int> > v;
bfs (d[1].first, d[1].second, x, y, ok1, tr1);
for (; x || y;)
{
v.push_back({x, y});
auto k = tr1[x][y];
x = k.first; y = k.second;
}
v.pop_back();
reverse (v.begin(), v.end());
for (auto i : v)
sw (d[1].first, d[1].second, i.first, i.second);
cerr << "1\n";
v.clear();
}
void ch (int k, int x, int y)
{
if (d[k].first == x && d[k].second == y) return;
memset (ok, 0, sizeof (ok));
ok[d[k].first][d[k].second] = 1;
tr[d[k].first][d[k].second] = {0, 0};
vector<pair<int, int> > v;
bfs (d[k].first, d[k].second, x, y, ok, tr);
for (; x || y;)
{
v.push_back({x, y});
auto k = tr[x][y];
x = k.first; y = k.second;
}
v.pop_back();
reverse (v.begin(), v.end());
for (auto i : v)
{
cr[d[k].first][d[k].second] = 1;
ch1 (i.first, i.second);
cr[d[k].first][d[k].second] = 0;
cerr << "0\n";
sw (d[k].first, d[k].second, i.first, i.second);
}
v.clear();
}
void enter()
{
cin >> n;
m = n;
int cnt = 0;
for (int i = 1; i <= 3; ++ i)
for (int j = 1; j <= n; ++ j)
{
cin >> a[i][j];
d[a[i][j]] = {i, j};
}
for (; n >= 2; -- n)
{
ch (n, 1, n);
cr[1][n] = 1;
ch (2 * n, 2, n);
cr[2][n] = 1;
ch1 (1, n - 1);
cerr << "2\n";
sw (1, n - 1, 1, n);
sw (1, n, 2, n);
cr[1][n - 1] = 1;
cr[2][n] = 0;
ch (3 * n, 3, n);
cr[3][n] = 1;
ch1 (2, n);
cerr << "3\n";
sw (2, n, 1, n);
sw (1, n, 1, n - 1);
}
for (int i = 1; i <= 1; ++ i)
{
if (a[1][1] == 1 && a[2][1] == m + 1 && a[3][1] == 2 * m + 1) break;
if (a[1][1] == 1 || a[2][1] == 1)
sw (1, 1, 2, 1);
if (a[1][1] == 1 && a[2][1] == m + 1 && a[3][1] == 2 * m + 1) break;
if (a[2][1] == 1 || a[3][1] == 1)
sw (2, 1, 3, 1);
if (a[1][1] == 1 && a[2][1] == m + 1 && a[3][1] == 2 * m + 1) break;
sw (1, 1, 2, 1);
if (a[1][1] == 1 && a[2][1] == m + 1 && a[3][1] == 2 * m + 1) break;
}
cout << sol.size() << "\n";
for (auto x : sol)
cout << x.a << " " << x.b << " " << x.x << " " << x.y << "\n";
}
void solve()
{
for (int i = 1; i <= 3; ++ i)
{
for (int j = 1; j <= m; ++ j)
cerr << a[i][j] << " ";
cerr << "\n";
}
for (int i = 1; i <= 3; ++ i)
for (int j = 1; j <= m; ++ j)
if (a[i][j] != (i - 1) * m + j)
{
cerr << i << " " << j << " " << a[i][j] << "\n";
cerr << "WRONG";
return;
}
cerr << "CORRECT";
}
void print_result()
{
}
int main()
{
docfile();
//cin>>ntest;
for (tt = 1; tt <= ntest; ++ tt)
{
enter();
solve();
print_result();
}
}
|
[
"ngobao2001@gmail.com"
] |
ngobao2001@gmail.com
|
4a2218e2d2b8bed093ecb78275e7f63c2d99373f
|
06eb60c98f4d106fc3bb3d0b7e990828b87d714d
|
/Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.h
|
5d872dfb2edd277aac092935e44a3f4d3ea5c9a2
|
[] |
no_license
|
snyh/dui
|
9486a81d97ec1173b161b6aef8fcea21066aebff
|
c4464629f1efdecae792ed3abc2a7fc9ce9b88db
|
refs/heads/master
| 2021-01-25T08:28:55.224303
| 2013-10-23T00:42:02
| 2013-10-23T00:42:02
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,092
|
h
|
/*
* Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef CustomFilterCompiledProgram_h
#define CustomFilterCompiledProgram_h
#if ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS)
#include "platform/graphics/filters/CustomFilterProgramInfo.h"
#include "platform/graphics/GraphicsContext3D.h"
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class CustomFilterGlobalContext;
class CustomFilterCompiledProgram: public RefCounted<CustomFilterCompiledProgram> {
public:
static PassRefPtr<CustomFilterCompiledProgram> create(PassRefPtr<GraphicsContext3D> context, const String& validatedVertexShader, const String& validatedFragmentShader, CustomFilterProgramType programType)
{
return adoptRef(new CustomFilterCompiledProgram(context, validatedVertexShader, validatedFragmentShader, programType));
}
~CustomFilterCompiledProgram();
int positionAttribLocation() const { return m_positionAttribLocation; }
int texAttribLocation() const { return m_texAttribLocation; }
int meshAttribLocation() const { return m_meshAttribLocation; }
int triangleAttribLocation() const { return m_triangleAttribLocation; }
int meshBoxLocation() const { return m_meshBoxLocation; }
int projectionMatrixLocation() const { return m_projectionMatrixLocation; }
int tileSizeLocation() const { return m_tileSizeLocation; }
int meshSizeLocation() const { return m_meshSizeLocation; }
int samplerLocation() const { return m_samplerLocation; }
int contentSamplerLocation() const { return m_contentSamplerLocation; }
int samplerSizeLocation() const { return m_samplerSizeLocation; }
int uniformLocationByName(const String&);
bool isInitialized() const { return m_isInitialized; }
Platform3DObject program() const { return m_program; }
private:
CustomFilterCompiledProgram(PassRefPtr<GraphicsContext3D>, const String& validatedVertexShader, const String& validatedFragmentShader, CustomFilterProgramType);
Platform3DObject compileShader(GC3Denum shaderType, const String& shaderString);
Platform3DObject linkProgram(Platform3DObject vertexShader, Platform3DObject fragmentShader);
void initializeParameterLocations(CustomFilterProgramType);
RefPtr<GraphicsContext3D> m_context;
Platform3DObject m_program;
int m_positionAttribLocation;
int m_texAttribLocation;
int m_meshAttribLocation;
int m_triangleAttribLocation;
int m_meshBoxLocation;
int m_projectionMatrixLocation;
int m_tileSizeLocation;
int m_meshSizeLocation;
int m_samplerLocation;
int m_samplerSizeLocation;
int m_contentSamplerLocation;
bool m_isInitialized;
};
}
#endif // ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS)
#endif
|
[
"snyh@snyh.org"
] |
snyh@snyh.org
|
3021ec5f9d8577d7f22c7d5ff76bfcf3d3eb23b8
|
78aceec2a1173cf100e726669d933199903282ba
|
/live/cutter/cutterworker/.svn/text-base/StreamReader.h.svn-base
|
64955a4ddcb6241305baf0f349934205bbccd696
|
[] |
no_license
|
shahu/xhome
|
1c6e42257b79c378575cfbb035aff38f8716f709
|
16fed6dece1fbc5a87af019a48931e53197bdfa8
|
refs/heads/master
| 2020-12-25T18:17:55.629694
| 2013-09-26T01:49:37
| 2013-09-26T01:49:37
| 12,605,990
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,706
|
#pragma once
// #include "util/Util.h"
// #include <boost/asio/io_service.hpp>
//#include "util/protocol/http/HttpClient.h"
#include "PieceWriter.h"
namespace util{
namespace protocol{
class HttpClient;
}
}
class CStreamReader
{
public:
CStreamReader(const std::string& url, const std::string& path,
const boost::uint32_t& piece_type, const bool& cut_with_kf, const boost::uint32_t& piece_scale,
const boost::uint32_t& piece_life_span, const boost::uint32_t& head_piece_life_span,
const bool& need_modify_ts = true,
const std::string& livecms_host = "live-cms.synacast.com", const boost::uint32_t& status_report_period = 60);
~CStreamReader(void);
bool Start();
void Stop();
private:
void on_http_open(const boost::system::error_code& ec);
void on_content(const boost::system::error_code& ec, const std::size_t& length);
void async_begin();
bool do_begin();
void OnClockAlarm();
enum {
STAT_NEED_HEAD,
STAT_NEED_FLV_DATA
};
enum {
READING_HEAD,
READING_FLV_TAGHEAD,
READING_FLV_TAGBODY
};
const static int cs_pedding_cut_down_time = 10;
const static int cs_start_cut_down_time = 3;
std::string url_;
boost::shared_ptr<util::protocol::HttpClient> http_client_;
boost::asio::io_service ios_;
int stat_;
int reading_stat_;
liter_buffer_ptr reading_buffer_ptr_;
std::size_t reading_size_;
piece_ptr piece_ptr_;
int cur_flv_tag_type_;
boost::uint32_t flv_tag_beg_timestamp_; // Added by Tady, 06262013: The first non-zero timestamp in flv file.
boost::uint32_t flv_tag_timestamp_; // unit is ms
boost::uint32_t cur_flv_tag_ts_; // unit is piece-count
boost::uint32_t cur_piece_ts_;
bool got_audio_head_;
bool got_video_head_;
// Added by Tady, 06152011: For audio or video only stream.
bool is_header_over_;
CPieceWriter* writer_;
bool got_seek_point_;
boost::uint32_t seek_point_pos_;
bool need_cut_with_kf_;
bool cut_with_kf_;
boost::uint32_t cut_scale_; // Unit is sec.
// bool can_cut_;
int should_cut_count_;
framework::timer::AsioTimerManager clock_manager_;
framework::timer::PeriodicTimer clock_;
boost::asio::io_service::work work_;
bool is_reader_ready_;
int pedding_cut_down_time_;
int start_cut_down_time_;
// Added by Tady, 06182011: When cut_with_kf is true
// , the very first piece is usually starting with a non-kf.
// So we drop it!
bool got_first_data_piece_;
boost::uint32_t flv_tag_ts_delta_; // unit is ms.
bool got_first_data_tag_;
// Added by Tady, 05232012: A switcher to modify time stamp
bool need_modify_ts_;
piece_ptr aac_sequence_header_;
piece_ptr avc_sequence_header_;
};
|
[
"root@ATN-cloud1.0b3ad251ac8442ba91180dabc8e9b6a0.ATN-cloud1.2995091589.chinanorth.internal.chinacloudapp.cn"
] |
root@ATN-cloud1.0b3ad251ac8442ba91180dabc8e9b6a0.ATN-cloud1.2995091589.chinanorth.internal.chinacloudapp.cn
|
|
6689a0e71e3c5a7eabbfd5f749dedc51bedd4383
|
6aac3e5c013ebefbfb2a932dc24677c506c38960
|
/cpp/Ad7b39pgr/primitives/BonusTask.h
|
4beebdc7f4ce962663a6c04d71e5821607707bc1
|
[] |
no_license
|
merxbj/src
|
a0a84b23efb77bf83dae1c63cb85d695c09d706a
|
8eda380b331f53b06303ddf95c8d7675cefecfaa
|
refs/heads/master
| 2023-08-27T18:21:08.159945
| 2023-08-13T18:45:35
| 2023-08-13T18:49:51
| 273,909
| 1
| 1
| null | 2023-09-14T21:41:02
| 2009-08-10T12:23:27
|
Java
|
UTF-8
|
C++
| false
| false
| 509
|
h
|
#pragma once
#include "advancedtask.h"
class BonusTask : public AdvancedTask
{
public:
BonusTask(void);
virtual ~BonusTask(void);
virtual void Initialize();
virtual const char* ToString();
protected:
virtual void DrawTask();
private:
GLuint InitializeVertexBufferHouseWithColors();
GLuint InitializeElementBuffer();
GLuint InitializeVertexArrayHouse(GLuint vertexBuffer);
GLuint m_uiVertexColorArrayHandle;
GLuint m_uiElementsBuffer;
};
|
[
"Jaroslav.Merxbauer@ncr.com"
] |
Jaroslav.Merxbauer@ncr.com
|
1b1afc912df5ef426348bcf61cbcff4ac0f2de7e
|
024246fcea9e059040f695e29db14ab4eb2da227
|
/bfs_dfs.cpp
|
49135291e383437c865583bab4b134738885ec7b
|
[] |
no_license
|
tuxophilia/ds
|
c5863917abc7dfe90ae2c192c23242e9b8d3aa6e
|
1cd49d576c5d135cd01410ebdc949d625a3c3cfd
|
refs/heads/master
| 2021-01-02T09:31:25.448136
| 2014-02-12T18:27:04
| 2014-02-12T18:27:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,703
|
cpp
|
#include<iostream>
using namespace std;
int nodes;
void display(int**);
void enque(int);
int deque();
void dfs(int,int**,int,int*);
void bfs(int,int**,int,int*);
int** construct_adj(int *p,int non,int **adj,int i)
{
for(int j=1;j<=non;j++)
*(*(adj+i)+*(p+j))=1;
display(adj);
return adj;
}
void display(int **adj)
{
for(int i=1;i<=nodes;i++)
{
for(int j=1;j<=nodes;j++)
cout<<" "<<*(*(adj+i)+j);
cout<<"\n";
}
}
main()
{
int non,*p,v,ch;
cout<<"\n\tEnter the number of nodes in graph: ";
cin>>nodes;
int **adj = new int*[nodes];
for(int i=1; i<=nodes; i++)
adj[i] = new int [nodes];
for(int i=1;i<=nodes;i++)
for(int j=1;j<=nodes;j++)
*(*(adj+i)+j)=0;
display(adj);
for(int i=1;i<=nodes;i++)
{
p=new int [nodes];
cout<<"enter the number of nodes to which node "<<i<<" is connected: ";
cin>>non;
cout<<"enter nodes one by one to which node "<<i<<" is connected: ";
for(int j=1;j<=non;j++)
cin>>p[j];
adj=construct_adj(p,non,adj,i);
}
cout<<"\n\n\n";
display(adj);
while(1)
{
int *visited=new int [nodes];
cout<<"\n\tEnter what u want ";
cout<<"\n\t1.Depth First Tranversal";
cout<<"\n\t2.Breadth First Tranversal";
cout<<"\n\t3.Print Adjacency matrix";
cout<<"\n\t4.Clear Visited array ";
cout<<"\n\t5.Exit";
cout<<"\n\tEnter now : ";
cin>>ch;
switch(ch)
{
case 1: cout<<"\n\tEnter the starting node for dfs";
cin>>v;
cout<<"DFT with starting node "<<v<<" is : ";
dfs(v,adj,nodes,visited);
break;
case 2: cout<<"\n\tEnter the starting node for dfs";
cin>>v;
cout<<"BFT with starting node "<<v<<" is : ";
bfs(v,adj,nodes,visited);
break;
case 3: display(adj);
break;
case 4: for(int i=1;i<=nodes;i++)
*(visited+i)=0;
break;
case 5: break;
break;
default:cout<<"\n\tYou entered a wrong choice!!!!";
}
}
return 0;
}
void dfs(int node,int **adj,int no_of_nodes,int *visited)
{
visited[node]=1;
cout<<node<<" ";
for(int i=1;i<=no_of_nodes;i++)
{
if(adj[node][i]==1&&visited[i]!=1)
dfs(i,adj,no_of_nodes,visited);
}
}
int front=-1,rear=-1,*q=new int [nodes];
void enque(int item)
{
if(front==-1&&rear==-1)
{
front++;
rear++;
*(q+front)=item;
}
else if(front<rear)
{
rear++;
*(q+rear)=item;
}
}
int deque()
{
int temp;
if(front<rear)
return *(q+front++);
else if(front==rear)
{
temp=*(q+front);
front=-1;
rear=-1;
return temp;
}
}
void bfs(int node,int **adj,int no_of_nodes,int *visited)
{
int temp;
visited[node]=1;
enque(node);
while(rear!=-1&&front!=-1)
{
temp=deque();
cout<<temp;
for(int i=1;i<=no_of_nodes;i++)
{
if(adj[temp][i]==1&&*(visited+i)!=1)
{
visited[i]=1;
enque(i);
}
}
}
}
|
[
"tuxophilia@gmail.com"
] |
tuxophilia@gmail.com
|
d2db0d7cecf73a36f2cad41ce2e33e44af936b6d
|
41ebf0f127afdc03aac72e26ab87a88b6684fe07
|
/Modules/Components/SinksAndSources/include/selxItkImageSource.h
|
a757a727d8ace7c3419b5c4ab03b57099eed7aa7
|
[
"Apache-2.0"
] |
permissive
|
deliangye/SuperElastix
|
795bb29a2536a3337895943c1b991cae6eea3ee2
|
7bf157a726047efdabb4f9d85a062e3e08f5eb28
|
refs/heads/master
| 2021-01-12T11:28:44.955686
| 2016-09-16T09:15:08
| 2016-09-16T09:15:08
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,512
|
h
|
/*=========================================================================
*
* Copyright Leiden University Medical Center, Erasmus University Medical
* Center and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef selxItkImageSource_h
#define selxItkImageSource_h
#include "ComponentBase.h"
#include "Interfaces.h"
#include <string.h>
#include "selxMacro.h"
namespace selx
{
template<int Dimensionality, class TPixel>
class ItkImageSourceComponent :
public Implements<
Accepting<>,
Providing< SourceInterface, itkImageInterface<Dimensionality, TPixel > >
>
{
public:
selxNewMacro(ItkImageSourceComponent, ComponentBase);
ItkImageSourceComponent();
virtual ~ItkImageSourceComponent();
typedef itk::Image<TPixel, Dimensionality> ItkImageType;
virtual typename ItkImageType::Pointer GetItkImage() override;
virtual void SetMiniPipelineInput(itk::DataObject::Pointer) override;
virtual bool MeetsCriterion(const ComponentBase::CriterionType &criterion) override;
static const char * GetDescription() { return "ItkImageSource Component"; };
private:
typename ItkImageType::Pointer m_Image;
protected:
/* The following struct returns the string name of computation type */
/* default implementation */
static inline const std::string GetTypeNameString()
{
itkGenericExceptionMacro(<< "Unknown ScalarType" << typeid(TPixel).name());
// TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
// We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
}
static inline const std::string GetPixelTypeNameString()
{
itkGenericExceptionMacro(<< "Unknown PixelType" << typeid(TPixel).name());
// TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
// We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
}
};
template <>
inline const std::string
ItkImageSourceComponent<2, float>
::GetPixelTypeNameString()
{
return std::string("float");
}
template <>
inline const std::string
ItkImageSourceComponent<2, double>
::GetPixelTypeNameString()
{
return std::string("double");
}
template <>
inline const std::string
ItkImageSourceComponent<3, float>
::GetPixelTypeNameString()
{
return std::string("float");
}
template <>
inline const std::string
ItkImageSourceComponent<3, double>
::GetPixelTypeNameString()
{
return std::string("double");
}
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxItkImageSource.hxx"
#endif
#endif // #define selxItkImageSource_h
|
[
"floris.berendsen@gmail.com"
] |
floris.berendsen@gmail.com
|
e0b9b2d955549edf0e7e2608544e6c86e076c281
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/external/tfmicro/tensorflow/lite/schema/schema_utils.h
|
32db89ba893d65a6656e4a6602b5aef29efaa849
|
[
"Apache-2.0",
"MIT"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C++
| false
| false
| 1,333
|
h
|
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_SCHEMA_SCHEMA_UTILS_H_
#define TENSORFLOW_LITE_SCHEMA_SCHEMA_UTILS_H_
#include "third_party/flatbuffers/flatbuffers.h"
#include "tensorflow/lite/schema/schema_generated.h"
namespace tflite {
// The following methods are introduced to resolve op builtin code shortage
// problem. The new builtin operator will be assigned to the extended builtin
// code field in the flatbuffer schema. Those methods helps to hide builtin code
// details.
BuiltinOperator GetBuiltinCode(const OperatorCode *op_code);
BuiltinOperator GetBuiltinCode(const OperatorCodeT *op_code);
} // namespace tflite
#endif // TENSORFLOW_LITE_SCHEMA_SCHEMA_UTILS_H_
|
[
"tj80.kwon@samsung.com"
] |
tj80.kwon@samsung.com
|
f4c3cb387ce3f804b6ee9f2e28fcd76ab32517c8
|
fe5c880191fa7a6abb68a678872e87fe957c2569
|
/系统模块/服务器组件/内核引擎/DataBase.h
|
4e52c2d9253ff705d5f55d6ff22594af51a384c8
|
[] |
no_license
|
soft-time/foxuc
|
905565c121f73a0b5abb4f23ceabed8dfc250341
|
32d604c4c1a10b466587ab88b75e84a8935a6f99
|
refs/heads/master
| 2020-12-15T09:23:46.726609
| 2019-04-15T15:16:00
| 2019-04-15T15:16:00
| null | 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 7,337
|
h
|
#ifndef DATA_BASE_ENGINE_HEAD_FILE
#define DATA_BASE_ENGINE_HEAD_FILE
#pragma once
//组件头文件
#include "KernelEngineHead.h"
#include "QueueService.h"
#include "TraceService.h"
#include "QueueServiceEvent.h"
#include <vector>
using namespace std;
//////////////////////////////////////////////////////////////////////////
//ADO 错误类
class CADOError : public IDataBaseException
{
//变量定义
protected:
enSQLException m_enErrorType; //错误代号
CString m_strErrorDescribe; //错误信息
//函数定义
public:
//构造函数
CADOError();
//析构函数
virtual ~CADOError();
//基础接口
public:
//释放对象
virtual VOID Release()
{
return /*true*/;
}
//是否有效
virtual bool IsValid()
{
return AfxIsValidAddress(this, sizeof(CADOError)) ? true : false;
}
//接口查询
virtual void * QueryInterface(const IID & Guid, DWORD dwQueryVer);
//功能接口
public:
//错误类型
virtual enSQLException GetExceptionType()
{
return m_enErrorType;
}
//错误描述
virtual LPCTSTR GetExceptionDescribe()
{
return m_strErrorDescribe;
}
//异常代码
virtual HRESULT GetExceptionResult()
{
return (HRESULT)0; //
}
//功能函数
public:
//设置错误
void SetErrorInfo(enSQLException enErrorType, LPCTSTR pszDescribe);
};
//////////////////////////////////////////////////////////////////////////
//数据库对象
class CDataBase : public IDataBase
{
//信息变量
protected:
CADOError m_ADOError; //错误对象
CString m_strConnect; //连接字符串
CString m_strErrorDescribe; //错误信息
//状态变量
protected:
DWORD m_dwConnectCount; //重试次数
DWORD m_dwConnectErrorTime; //错误时间
const DWORD m_dwResumeConnectCount; //恢复次数
const DWORD m_dwResumeConnectTime; //恢复时间
//内核变量
protected:
_CommandPtr m_DBCommand; //命令对象
_RecordsetPtr m_DBRecordset; //记录集对象
_ConnectionPtr m_DBConnection; //数据库对象
//函数定义
public:
//构造函数
CDataBase();
//析构函数
virtual ~CDataBase();
//基础接口
public:
//释放对象
virtual VOID Release()
{
if (IsValid()) delete this;
return /*true*/;
}
//是否有效
virtual bool IsValid()
{
return AfxIsValidAddress(this, sizeof(CDataBase)) ? true : false;
}
//接口查询
virtual void * QueryInterface(const IID & Guid, DWORD dwQueryVer);
//管理接口
public:
//打开连接
virtual VOID OpenConnection();
//关闭记录
virtual VOID CloseRecordset();
//关闭连接
virtual VOID CloseConnection();
//重新连接
virtual bool TryConnectAgain(bool bFocusConnect, CComError * pComError);
//连接信息
virtual bool SetConnectionInfo(DWORD dwDBAddr, WORD wPort, LPCTSTR szDBName, LPCTSTR szUser, LPCTSTR szPassword);
//设置信息
virtual bool SetConnectionInfo(LPCTSTR szDBAddr, WORD wPort, LPCTSTR szDBName, LPCTSTR szUser, LPCTSTR szPassword);
//切换记录
virtual VOID NextRecordset();
//状态接口
public:
//是否连接错误
virtual bool IsConnectError();
//是否打开
virtual bool IsRecordsetOpened();
//记录集接口
public:
//往下移动
virtual void MoveToNext();
//移到开头
virtual void MoveToFirst();
//是否结束
virtual bool IsRecordsetEnd();
//获取数目
virtual long GetRecordCount();
//获取大小
virtual long GetActualSize(LPCTSTR pszParamName);
//绑定对象
virtual VOID BindToRecordset(CADORecordBinding * pBind);
//获取数据
virtual VOID GetRecordsetValue(LPCTSTR pszItem, CDBVarValue & DBVarValue);
//字段接口
public:
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, BYTE & bValue);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, WORD & wValue);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, INT & nValue);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, LONG & lValue);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, DWORD & ulValue);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, UINT & ulValue);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, DOUBLE & dbValue);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, __int64 & llValue);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, LPSTR szBuffer, UINT uSize);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, LPWSTR szBuffer, UINT uSize);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, COleDateTime & Time);
//获取参数
virtual bool GetFieldValue(LPCTSTR lpFieldName, bool & bValue);
//命令对象接口
public:
//插入参数
virtual void AddParameter(LPCTSTR pszName, DataTypeEnum Type, ParameterDirectionEnum Direction, LONG lSize, CDBVarValue & DBVarValue);
//删除参数
virtual void ClearParameters();
//获得参数
virtual void GetParameter(LPCTSTR pszParamName, CDBVarValue & DBVarValue);
//获取返回数值
virtual long GetReturnValue();
//执行接口
public:
//执行语句
virtual VOID ExecuteProcess(LPCTSTR pszSPName, bool bRecordset);
//执行命令
virtual VOID ExecuteSentence(LPCTSTR pszCommand, bool bRecordset);
//内部函数
private:
//获取错误
LPCTSTR GetComErrorDescribe(CComError & ComError);
//设置错误
void SetErrorInfo(enSQLException enErrorType, LPCTSTR pszDescribe);
};
//////////////////////////////////////////////////////////////////////////
//数据库管理类
class CDataBaseEngine : public IDataBaseEngine, public IQueueServiceSink
{
//内核变量
protected:
bool m_bService; //运行标志
CQueueServiceEvent m_QueueServiceEvent; //队列对象
CQueueService m_QueueService;
//IDataBaseEngineSink * m_pIDataBaseEngineSink; //通知钩子
vector<IDataBaseEngineSink *> m_pIDataBaseEngineSinks; //通知钩子
//函数定义
public:
//构造函数
CDataBaseEngine(void);
//析构函数
virtual ~CDataBaseEngine(void);
//基础接口
public:
//释放对象
virtual VOID Release()
{
if (IsValid()) delete this;
return /*true*/;
}
//是否有效
virtual bool IsValid()
{
return AfxIsValidAddress(this, sizeof(CDataBaseEngine)) ? true : false;
}
//接口查询
virtual void * QueryInterface(const IID & Guid, DWORD dwQueryVer);
//服务接口
public:
//启动服务
virtual bool StartService();
//停止服务
virtual bool ConcludeService();
public:
//引擎负荷
virtual bool GetBurthenInfo(tagBurthenInfo & BurthenInfo);
//配置接口
public:
//配置模块
virtual bool SetDataBaseEngineSink(IUnknownEx * pIUnknownEx);
//配置模块
virtual bool SetDataBaseEngineSink(IUnknownEx * pIUnknownEx[], WORD wSinkCount);
//队列接口
public:
//队列接口
virtual void OnQueueServiceSink(WORD wIdentifier, void * pBuffer, WORD wDataSize);
//控制事件
public:
//控制事件
virtual bool PostDataBaseControl(WORD wControlID, VOID * pData, WORD wDataSize);
//请求事件
virtual bool PostDataBaseRequest(WORD wRequestID, DWORD dwContextID, VOID * pData, WORD wDataSize);
//延期请求
virtual bool DeferDataBaseRequest(WORD wRequestID, DWORD dwContextID, VOID * pData, WORD wDataSize);
};
//////////////////////////////////////////////////////////////////////////
#endif
|
[
"xjlong@outlook.com"
] |
xjlong@outlook.com
|
67eb82ac8f3b19db03cdcd96d9edde64e07da707
|
747238767e0520645687cf1af64a91081904c6d9
|
/ESPWiFiServer/Source/Server/Server.h
|
ce36b74ab47d5ad7a490e72001085b3e6ba72932
|
[] |
no_license
|
MaxGarden/ESPWiFiServer
|
5a66c9fa68dc7c5e53b34c03c3c6a76c4a6c0a48
|
e88154c2d091d65e25e714333f68d771f6b17d73
|
refs/heads/master
| 2020-04-09T05:02:17.174362
| 2019-02-24T16:54:23
| 2019-02-24T16:55:09
| 160,048,396
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 667
|
h
|
#if !defined(__SERVER_H__)
#define __SERVER_H__
#pragma once
#include "DataModel.h"
#include "Client/Client.h"
class IServerListener : public IListener
{
public:
virtual ~IServerListener() override = default;
virtual void OnClientConnected(const IClientSharedPtr& client) = 0;
virtual void OnClientDisconnected(const IClientSharedPtr& client) = 0;
};
class IServer : public IDataModel
{
public:
virtual ~IServer() override = default;
virtual bool StartListening(unsigned short int port) = 0;
virtual void VisitClients(const ConstVisitorType<IClientSharedPtr>& visitor) = 0;
static IServerUniquePtr Create();
};
#endif //__SERVER_H__
|
[
"mserkies@artifexmundi.com"
] |
mserkies@artifexmundi.com
|
d4c1e442731547adb336d34dc57d273daeecaaba
|
5c72412ba71e31559c12cfef46a5c67e84332cf2
|
/imgprocess/test_split.cpp
|
dbf76442d9f0b1615513d63a5d2425c3d3c360d7
|
[
"MIT"
] |
permissive
|
apachefranklin/imageprocess
|
f11a419096942f92377c2aef04ba1e89f5cd0bee
|
563175a90dad85c2ebb16f6ff18da06680b1c1db
|
refs/heads/master
| 2023-08-25T08:59:10.349933
| 2021-10-25T04:55:17
| 2021-10-25T04:55:17
| 283,257,232
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,068
|
cpp
|
#include <iostream>
#include <vector>
using namespace std;
std::vector<std::string> split_string(std::string chaine,std::string sep){
std::vector<std::string> splitElts;
std:string tempchaine=chaine;
size_t pos = 0;
std::string token;
while ((pos = tempchaine.find(sep)) != std::string::npos)
{
token = tempchaine.substr(0, pos);
splitElts.push_back(token);
tempchaine.erase(0, pos + sep.length());
}
splitElts.push_back(tempchaine);
return splitElts;
}
int main(int argc, char **argv)
{
std::string s = "scott>=tiger>=mushroom";
std::string delimiter = ">=";
/* size_t pos = 0;
std::string token;
while ((pos = s.find(delimiter)) != std::string::npos)
{
token = s.substr(0, pos);
std::cout << token << std::endl;
s.erase(0, pos + delimiter.length());
}
std::cout << s << " "<<"apache"<< std::endl; */
std::vector<string> splits=split_string(s,delimiter);
for(std::string x:splits){
cout<<x<<std::endl;
}
return 45;
}
|
[
"dnzklin@gmail.com"
] |
dnzklin@gmail.com
|
8c0075d55f7251c6dcaea7ddf05e774baaac7c82
|
9476946d62b9524d6b1c585e53f6bba23723b552
|
/Template of other teams/NewMeta/merge/HalfPlaneIntersection.cpp
|
fc8a008001ae4a7834ed027aa8801bbb18e67fd0
|
[] |
no_license
|
KurodaKanbei/ACM
|
67df8f6c41e95d3d1a52d6ccde22b14941999a29
|
45d79c8a22ae94e28f12da590f02dd4f0181a307
|
refs/heads/master
| 2021-11-26T21:02:21.462582
| 2021-11-10T19:36:39
| 2021-11-10T19:36:39
| 87,429,146
| 6
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,580
|
cpp
|
struct Point {
int quad() const { return sign(y) == 1 || (sign(y) == 0 && sign(x) >= 0); }
Point turn90() const { return Point(-y, x); }
};
struct Line {
bool include(const Point &p) const { return sign(det(b - a, p - a)) > 0; }
Line push() const{ // 将半平面向外推 eps
const double eps = 1e-6;
Point delta = (b - a).turn90().norm() * eps;
return Line(a - delta, b - delta);
}
};
bool sameDir(const Line &l0, const Line &l1) { return parallel(l0, l1) && sign(dot(l0.b - l0.a, l1.b - l1.a)) == 1; }
bool operator < (const Point &a, const Point &b) {
if (a.quad() != b.quad()) {
return a.quad() < b.quad();
} else {
return sign(det(a, b)) > 0;
}
}
bool operator < (const Line &l0, const Line &l1) {
if (sameDir(l0, l1)) {
return l1.include(l0.a);
} else {
return (l0.b - l0.a) < (l1.b - l1.a);
}
}
bool check(const Line &u, const Line &v, const Line &w) { return w.include(intersect(u, v)); }
vector<Point> intersection(vector<Line> &l) {
sort(l.begin(), l.end());
deque<Line> q;
for (int i = 0; i < (int)l.size(); ++i) {
if (i && sameDir(l[i], l[i - 1])) {
continue;
}
while (q.size() > 1 && !check(q[q.size() - 2], q[q.size() - 1], l[i])) q.pop_back();
while (q.size() > 1 && !check(q[1], q[0], l[i])) q.pop_front();
q.push_back(l[i]);
}
while (q.size() > 2 && !check(q[q.size() - 2], q[q.size() - 1], q[0])) q.pop_back();
while (q.size() > 2 && !check(q[1], q[0], q[q.size() - 1])) q.pop_front();
vector<Point> ret;
for (int i = 0; i < (int)q.size(); ++i) ret.push_back(intersect(q[i], q[(i + 1) % q.size()]));
return ret;
}
|
[
"812395846@qq.com"
] |
812395846@qq.com
|
39781caeb6824b2fa8bf023c2fc59de0a1a0bccb
|
cdd8b267cd24536b72de8d5920a5e502948491b1
|
/SDL_Engine-master/src/Plane.cpp
|
2a60f77363593cb1d04b7f459e57f0e04f491acb
|
[
"MIT"
] |
permissive
|
Offgridhuls/PhysicsA3Scene1_Sangiorgio_Milman
|
dcd6652d05b6db9f8641cbd4ef0b8a59a90891bb
|
6c16e9b41187860be630d3311499b8d4bc1b3df0
|
refs/heads/main
| 2023-01-20T11:34:56.639501
| 2020-12-01T04:00:47
| 2020-12-01T04:00:47
| 317,420,525
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,332
|
cpp
|
#include "Plane.h"
#include "TextureManager.h"
Plane::Plane()
{
TextureManager::Instance()->loadSpriteSheet(
"../Assets/sprites/atlas.txt",
"../Assets/sprites/atlas.png",
"spritesheet");
setSpriteSheet(TextureManager::Instance()->getSpriteSheet("spritesheet"));
// set frame width
setWidth(65);
// set frame height
setHeight(65);
getTransform()->position = glm::vec2(400.0f, 400.0f);
getRigidBody()->velocity = glm::vec2(0.0f, 0.0f);
getRigidBody()->acceleration = glm::vec2(0.0f, 0.0f);
getRigidBody()->isColliding = false;
setType(PLANE);
m_buildAnimations();
}
Plane::~Plane()
= default;
void Plane::draw()
{
// alias for x and y
const auto x = getTransform()->position.x;
const auto y = getTransform()->position.y;
// draw the plane sprite with simple propeller animation
TextureManager::Instance()->playAnimation(
"spritesheet", getAnimation("plane"),
x, y, 0.5f, 0, 255, true);
}
void Plane::update()
{
}
void Plane::clean()
{
}
void Plane::m_buildAnimations()
{
Animation planeAnimation = Animation();
planeAnimation.name = "plane";
planeAnimation.frames.push_back(getSpriteSheet()->getFrame("plane1"));
planeAnimation.frames.push_back(getSpriteSheet()->getFrame("plane2"));
planeAnimation.frames.push_back(getSpriteSheet()->getFrame("plane3"));
setAnimation(planeAnimation);
}
|
[
"55862297+Offgridhuls@users.noreply.github.com"
] |
55862297+Offgridhuls@users.noreply.github.com
|
2e319a29bf7154a502770d712276300bd65fb1ca
|
e1ffaeccfb71d98bf388d1c8f13d8dece8218468
|
/Client/src/maths/metric2.cpp
|
76e07ea340681f38570a4b19226e4cdad1a38a67
|
[] |
no_license
|
Yen/LysOld
|
a3746b6ad60d9e6600d59007788a77499b113ef4
|
83cd0af957681afecc235f5318d91922949aa181
|
refs/heads/master
| 2021-05-30T04:16:33.111082
| 2015-10-24T23:50:14
| 2015-10-24T23:50:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 448
|
cpp
|
#include "metric2.hpp"
#include "vector2.hpp"
namespace lys
{
Metric2::Metric2()
: x(0), y(0)
{}
Metric2::Metric2(const int &x, const int &y)
: x(x), y(y)
{}
bool Metric2::operator ==(const Metric2 &other) const
{
return((x == other.x) && (y == other.y));
}
bool Metric2::operator !=(const Metric2 &other) const
{
return !(*this == other);
}
Metric2::operator Vector2() const
{
return Vector2((float)x, (float)y);
}
}
|
[
"insertlogic@gmail.com"
] |
insertlogic@gmail.com
|
b138343f959ee73fe22932e1a70d8522219cf7bc
|
cd59c2a407c7d9156b9a92419f877c86a3289036
|
/editor/tablemanager.h
|
bf176a7f449b5d1a4cb78223de789501c05557a6
|
[] |
no_license
|
frandibar/pacman3d
|
4abd397cfbc5f521eb68d9e2a9e7a6970bca26b6
|
8b66333add56e0c553b2643d7f6a7bc03412ed81
|
refs/heads/master
| 2022-06-21T02:42:33.504230
| 2020-05-08T00:26:27
| 2020-05-08T00:26:27
| 262,187,761
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,576
|
h
|
#ifndef TABLEMANAGER_H_
#define TABLEMANAGER_H_
#include <gtkmm.h>
#include "editor/mapcell.h"
#include "lib/utilities.h"
#include "lib/graphhandler.h"
#include "lib/grapherrors.h"
#include "lib/gladehelper.h"
#include <vector>
#include <map>
#include <set>
/**
* Para poder manejar la GtkTable, una vez obtenida del XML generado por Glade, ésta es entregada al TableManager, que se encargará de todo su manejo e interacción con el GraphHandler (que será explicado luego).
* El TableManager guarda entre sus atributos a la GtkTable, el tipo de celda que se ha seleccionado para agregar, la cantidad de filas y columnas de la Table, el GtkWindow que lo contiene, para así poder mostrar mensajes de error gracias a un GladeHelper que figura como otro de sus atributos, un GraphHandler con el cual se comunicará para validar que lo que se quiere ingresar sea válido para el mapa, y por ultimo una matriz de MapCell*, que se encargará de guardar por cada uno de ellos que se crea, y luego los eliminará cuando la clase se desinstancie.
* De esta forma, el EditorScreen toma el Table, inicializa el grafo y el GraphHandler, e inicializa también el TableManager, entregándole los atributos que necesita. Luego, cuando se seleccione un botón de elemento a colocar, el tipo de celda del TableManager se modificará y así podrá saber cual es la celda que se quiere agregar. Luego, cuando se haga un click en la celda correspondiente, la misma reaccionará avisando al TableManager. Éste, obtendrá las coordenadas de la celda que fue clickeada. Con esto, podrá evaluar (gracias al GraphHandler) si es posible colocar la nueva celda que se quiere colocar en esa posición o no, y en caso de ser posible, devolverá un valor de verdad al MapCell que fue clickeado, para que éste cambie su imagen a mostrar. En casos especiales (GhostHouse y Portales) el TableManager se encargará de avisar a ciertos MapCell de alrededor del seleccionado para que modifiquen su imagen a mostrar.
* Además de esto, si la celda de introdujo con éxito, el TableManager guarda las coordenadas de la celda seleccionada en un set. Esto lo hace porque si el usuario no soltó el botón del Mouse, podrá arrastrarse sobre otras celdas, y ellas reaccionarán pidiendo también al TableManager que introduzca un elemento y cambie su imagen. Lo que hará que todas las celdas por las que se va pasando y dibujando queden almacenadas en el set, para no redibujarlas cada vez que se pasa por sobre ellas. Y luego, cuando se suelte el botón del Mouse, se logrará que ese set se vacie para la proxima insersion.
* Esta posibilidad de insertar varios elementos a la vez no sirve para elementos especiales o que pueden ser insertados una sola vez en el mapa, como bonus, pacman start, ghost house y portales.
* En caso de que el GraphHandler notificara que no se pudo incluir un vértice con elemento seleccionado, se obtendrá el entero correspondiente al error. Con este entero y gracias a la clase GraphErrors (que no tiene más que un vector de strings con los mensajes de error correspondientes a cada código, y un método para obtener el string correspondiente) se obtiene el mensaje de error para pasar al GladeHelper, para que este último pueda hacer aparecer una ventana de error con ese mensaje.
* */
class TableManager {
private:
bool _started;
unsigned int _rows;
unsigned int _columns;
tCell _actualCell;
Gtk::Window* _window;
Gtk::Table* _table;
std::vector< std::vector< MapCell* > > _cells;
GraphHandler* _graphHandler;
GladeHelper _gh;
bool _saved;
//aca van las coordenadas de las celdas que ya fueron dibujadas en un arrastre de mouse
std::set< std::pair< int, int > > _drawnCells;
void setGhostHouse(std::vector< std::pair<int,int> > & coord, tCell cell);
void setPortal(tEdgeOrientation portalType, int row, int column, tCell type);
//los ocultamos por seguridad
TableManager (const TableManager&);
TableManager& operator=(const TableManager&);
public:
///
TableManager(GraphHandler* graphHandler, Gtk::Window* window, Gtk::Table* table, tCell cell);
///
inline void setActualCell(tCell cell){
_actualCell = cell;
}
///
inline tCell getActualCell() const{
return _actualCell;
}
///
inline void changeGraphHandler(GraphHandler* graphHandler){
_graphHandler = graphHandler;
}
///
inline void setSaved(bool saved){
_saved = saved;
}
///
inline bool isSaved()const{
return _saved;
}
///
inline bool hasStarted()const{
return _started;
}
/// modifica el size de filas y columnas de la tabla, volviendo a cargar walls en cada celda
void reset(unsigned int rows, unsigned int columns);
/// intenta colocar el elemento pedido en la posicion pedida comunicandose con el GraphHandler, devuelve false se no se pudo
bool changeElement(int row, int column, tCell type);
/// reporta el error mediante un mensaje, mediante un metodo del editorScreen
void reportError(int code);
/// avisa si el TableManager esta vacio, que significa que todos sus cell son walls
bool isEmpty();
/// intenta colocar el elemento pedido por tCell, en el vertice pedido. Devuelve false si no pudo hacerlo
bool changeVertexAndImage(int vertexID, tCell type);
/// limpia el set de coordenadas de elementos ya dibujados durante un arrastre del mouse con boton apretado
void resetDrawn();
/// inserta el elemento y lo dibuja en la celda de la coordenada pasada (si esta es valida)
void changeAndDrawElement(int row, int column);
///
virtual ~TableManager();
};
#endif /*TABLEMANAGER_H_*/
|
[
"frandibar@gmail.com"
] |
frandibar@gmail.com
|
968f7b156e0dea46663b77a3b243deafc92fdb63
|
f1157fc241143c8baf8e5384761774f44c4a6ebb
|
/58/main.cpp
|
9df4657dcf34a058b8d067c905190393121d2348
|
[] |
no_license
|
hekun123/LeetcodeSolver
|
28dfebffa18e12a8fe86251e8b9a5590ab04d514
|
6a0ba6733c453b33baef715b97f9af63fa23c861
|
refs/heads/master
| 2020-04-13T07:10:48.276759
| 2019-07-16T02:07:02
| 2019-07-16T02:07:02
| 163,042,956
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 652
|
cpp
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int lengthOfLastWord(char* s) {
int strLen, i, returnAns;
char *sPtr = NULL;
strLen = strlen(s);
sPtr = s+strLen-1;
while(*sPtr == ' '){
*sPtr = '\0';
sPtr--;
}
strLen = strlen(s);
returnAns = 0;
for(i = strLen-1; i >= 0; i --){
if( ('A' <= s[i] && s[i] <= 'Z')
|| ('a' <= s[i] && s[i] <= 'z')){
returnAns++;
}else{
break;
}
}
return returnAns;
}
int main()
{
char a[] = "a ";
printf("%d\n", lengthOfLastWord(a));
return 0;
}
|
[
"hetheory@163.com"
] |
hetheory@163.com
|
a740808cc86b9098a6e2cbd50d019a2bef258009
|
5140fe1e18ee517bfdc33a8a8b50689bb96b5d66
|
/src/models/Input.cpp
|
163c48ba07667fbb8062f25324c733564b0666db
|
[
"MIT"
] |
permissive
|
garrou/bin-packing
|
cc00cff3d5cb18599b5df05daba743a7df1531d8
|
e733fbcbd5fdb3237cc3c3f8c921e34f4c5dcd1e
|
refs/heads/main
| 2023-04-27T07:13:36.764483
| 2023-04-13T09:54:00
| 2023-04-13T09:54:00
| 326,772,528
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,497
|
cpp
|
/**
* @file Input.cpp
* @author Adrien GARROUSTE - 1irda.alwaysdata.net
* @brief Check user input
* @version 0.1
* @date 2021-01-06
* @copyright No copyright no right
*/
#include "../headers/Input.hpp"
#include <iostream>
#include <limits>
#include <vector>
/**
* @brief Min size for boxes and items
*/
const int MIN_SIZE = 0;
/**
* @brief Minimum possible choice algorithm
*/
const int MIN_OPTION = 1;
/**
* @brief Maximum possible choice algorithm
*/
const int MAX_OPTION = 4;
/**
* @brief Check if input user for launching test and program
* @return true if user input equal Y or y
* @return false else user input N or n
*/
bool Input::secure_choice() {
char choice;
bool is_launch = false;
while (!(std::cin >> choice)
|| (choice != 'Y' && choice != 'y'
&& choice !='N' && choice != 'n')) {
if (std::cin.fail()) {
std::cout << "Error !" << std::endl;
} else {
std::cout << "Error ! Select Y or N." << std::endl;
}
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "> ";
}
if (choice == 'Y' || choice == 'y') {
is_launch = true;
}
return is_launch;
}
/**
* @brief Check user input for box size
* @return int a valid box size
*/
int Input::secure_input_size() {
int size;
while (!(std::cin >> size) || size <= MIN_SIZE) {
if (std::cin.fail()) {
std::cout << "Error !" << std::endl;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
} else {
std::cout << "Error ! Size must be greater than " << MIN_SIZE << std::endl;
}
}
return size;
}
/**
* @brief Check user input for item size
* @param max_size box size
* @return int a valid item size
*/
int Input::secure_item_size(int max_size) {
int item_size;
while (!(std::cin >> item_size) || item_size < MIN_SIZE || item_size > max_size) {
if (std::cin.fail()) {
std::cout << "Error !" << std::endl;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
} else if (item_size <= MIN_SIZE) {
std::cout << "Error ! Item must be greater than " << MIN_SIZE << std::endl;
} else {
std::cout << "Error ! Item must be lower than " << max_size << std::endl;
}
}
return item_size;
}
/**
* @brief Input items size while size != 0
* @param max_size box size
* @return std::vector<int> dynamic array with items size
*/
std::vector<int> Input::secure_items(int max_size) {
std::vector<int> items_size;
int size;
do {
size = Input::secure_item_size(max_size);
if (size != 0) {
items_size.push_back(size);
}
} while (size != MIN_SIZE);
return items_size;
}
/**
* @brief Check user input when he chose algorithm
* @return int chosen algorithm
*/
int Input::secure_algo() {
int algo;
while (!(std::cin >> algo) || algo < MIN_OPTION || algo > MAX_OPTION) {
if (std::cin.fail()) {
std::cout << "Error !" << std::endl;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
} else {
std::cout << "Error ! Value must be 1, 2, 3 or 4." << std::endl;
}
std::cout << "> ";
}
return algo;
}
|
[
"garrousteadrien@gmail.com"
] |
garrousteadrien@gmail.com
|
adbc8e9ac7e9424cefe836f765f5d2336ddfbdc2
|
070220e82b5d89e18b93d6ef34d702d2119575ed
|
/external/qtkeychain/keychain_unix.cpp
|
b5910abbfe1cfd8f9f198bc6d0d0a305181cfdbf
|
[
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
Brute-f0rce/l0phtcrack
|
2eb4e51f36fd28c9119269881d5e66e6a6dac533
|
25f681c07828e5e68e0dd788d84cc13c154aed3d
|
refs/heads/main
| 2023-08-19T16:41:06.137715
| 2021-10-17T01:06:21
| 2021-10-17T01:06:21
| 418,568,833
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 19,060
|
cpp
|
/******************************************************************************
* Copyright (C) 2011-2014 Frank Osterfeld <frank.osterfeld@gmail.com> *
* *
* 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. For licensing and distribution *
* details, check the accompanying file 'COPYING'. *
*****************************************************************************/
#include "keychain_p.h"
#include "gnomekeyring_p.h"
#include <QSettings>
#include <QScopedPointer>
using namespace QKeychain;
static QString typeKey( const QString& key )
{
return QString::fromLatin1( "%1/type" ).arg( key );
}
static QString dataKey( const QString& key )
{
return QString::fromLatin1( "%1/data" ).arg( key );
}
enum KeyringBackend {
Backend_GnomeKeyring,
Backend_Kwallet
};
enum DesktopEnvironment {
DesktopEnv_Gnome,
DesktopEnv_Kde4,
DesktopEnv_Unity,
DesktopEnv_Xfce,
DesktopEnv_Other
};
// the following detection algorithm is derived from chromium,
// licensed under BSD, see base/nix/xdg_util.cc
static const char kKDE4SessionEnvVar[] = "KDE_SESSION_VERSION";
static DesktopEnvironment detectDesktopEnvironment() {
QByteArray xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP");
if ( xdgCurrentDesktop == "GNOME" ) {
return DesktopEnv_Gnome;
} else if ( xdgCurrentDesktop == "Unity" ) {
return DesktopEnv_Unity;
} else if ( xdgCurrentDesktop == "KDE" ) {
return DesktopEnv_Kde4;
}
QByteArray desktopSession = qgetenv("DESKTOP_SESSION");
if ( desktopSession == "gnome" ) {
return DesktopEnv_Gnome;
} else if ( desktopSession == "kde" ) {
if ( qgetenv(kKDE4SessionEnvVar).isEmpty() ) {
// most likely KDE3
return DesktopEnv_Other;
} else {
return DesktopEnv_Kde4;
}
} else if ( desktopSession == "kde4" ) {
return DesktopEnv_Kde4;
} else if ( desktopSession.contains("xfce") || desktopSession == "xubuntu" ) {
return DesktopEnv_Xfce;
}
if ( !qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty() ) {
return DesktopEnv_Gnome;
} else if ( !qgetenv("KDE_FULL_SESSION").isEmpty() ) {
if ( qgetenv(kKDE4SessionEnvVar).isEmpty() ) {
// most likely KDE3
return DesktopEnv_Other;
} else {
return DesktopEnv_Kde4;
}
}
return DesktopEnv_Other;
}
static KeyringBackend detectKeyringBackend()
{
switch (detectDesktopEnvironment()) {
case DesktopEnv_Kde4:
return Backend_Kwallet;
break;
// fall through
case DesktopEnv_Gnome:
case DesktopEnv_Unity:
case DesktopEnv_Xfce:
case DesktopEnv_Other:
default:
if ( GnomeKeyring::isAvailable() ) {
return Backend_GnomeKeyring;
} else {
return Backend_Kwallet;
}
}
}
static KeyringBackend getKeyringBackend()
{
static KeyringBackend backend = detectKeyringBackend();
return backend;
}
void ReadPasswordJobPrivate::scheduledStart() {
switch ( getKeyringBackend() ) {
case Backend_GnomeKeyring:
if ( !GnomeKeyring::find_network_password( key.toUtf8().constData(), q->service().toUtf8().constData(),
reinterpret_cast<GnomeKeyring::OperationGetStringCallback>( &ReadPasswordJobPrivate::gnomeKeyring_cb ),
this, 0 ) )
q->emitFinishedWithError( OtherError, tr("Unknown error") );
break;
case Backend_Kwallet:
if ( QDBusConnection::sessionBus().isConnected() )
{
iface = new org::kde::KWallet( QLatin1String("org.kde.kwalletd"), QLatin1String("/modules/kwalletd"), QDBusConnection::sessionBus(), this );
const QDBusPendingReply<QString> reply = iface->networkWallet();
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher( reply, this );
connect( watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(kwalletWalletFound(QDBusPendingCallWatcher*)) );
}
else
{
// D-Bus is not reachable so none can tell us something about KWalletd
QDBusError err( QDBusError::NoServer, tr("D-Bus is not running") );
fallbackOnError( err );
}
break;
}
}
void ReadPasswordJobPrivate::kwalletWalletFound(QDBusPendingCallWatcher *watcher)
{
watcher->deleteLater();
const QDBusPendingReply<QString> reply = *watcher;
const QDBusPendingReply<int> pendingReply = iface->open( reply.value(), 0, q->service() );
QDBusPendingCallWatcher* pendingWatcher = new QDBusPendingCallWatcher( pendingReply, this );
connect( pendingWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(kwalletOpenFinished(QDBusPendingCallWatcher*)) );
}
static QPair<Error, QString> mapGnomeKeyringError( int result )
{
Q_ASSERT( result != GnomeKeyring::RESULT_OK );
switch ( result ) {
case GnomeKeyring::RESULT_DENIED:
return qMakePair( AccessDenied, QObject::tr("Access to keychain denied") );
case GnomeKeyring::RESULT_NO_KEYRING_DAEMON:
return qMakePair( NoBackendAvailable, QObject::tr("No keyring daemon") );
case GnomeKeyring::RESULT_ALREADY_UNLOCKED:
return qMakePair( OtherError, QObject::tr("Already unlocked") );
case GnomeKeyring::RESULT_NO_SUCH_KEYRING:
return qMakePair( OtherError, QObject::tr("No such keyring") );
case GnomeKeyring::RESULT_BAD_ARGUMENTS:
return qMakePair( OtherError, QObject::tr("Bad arguments") );
case GnomeKeyring::RESULT_IO_ERROR:
return qMakePair( OtherError, QObject::tr("I/O error") );
case GnomeKeyring::RESULT_CANCELLED:
return qMakePair( OtherError, QObject::tr("Cancelled") );
case GnomeKeyring::RESULT_KEYRING_ALREADY_EXISTS:
return qMakePair( OtherError, QObject::tr("Keyring already exists") );
case GnomeKeyring::RESULT_NO_MATCH:
return qMakePair( EntryNotFound, QObject::tr("No match") );
default:
break;
}
return qMakePair( OtherError, QObject::tr("Unknown error") );
}
void ReadPasswordJobPrivate::gnomeKeyring_cb( int result, const char* string, ReadPasswordJobPrivate* self )
{
if ( result == GnomeKeyring::RESULT_OK ) {
if ( self->dataType == ReadPasswordJobPrivate::Text )
self->data = string;
else
self->data = QByteArray::fromBase64( string );
self->q->emitFinished();
} else {
const QPair<Error, QString> errorResult = mapGnomeKeyringError( result );
self->q->emitFinishedWithError( errorResult.first, errorResult.second );
}
}
void ReadPasswordJobPrivate::fallbackOnError(const QDBusError& err )
{
QScopedPointer<QSettings> local( !q->settings() ? new QSettings( q->service() ) : 0 );
QSettings* actual = q->settings() ? q->settings() : local.data();
if ( q->insecureFallback() && actual->contains( dataKey( key ) ) ) {
const WritePasswordJobPrivate::Mode mode = WritePasswordJobPrivate::stringToMode( actual->value( typeKey( key ) ).toString() );
if (mode == WritePasswordJobPrivate::Binary)
dataType = Binary;
else
dataType = Text;
data = actual->value( dataKey( key ) ).toByteArray();
q->emitFinished();
} else {
if ( err.type() == QDBusError::ServiceUnknown ) //KWalletd not running
q->emitFinishedWithError( NoBackendAvailable, tr("No keychain service available") );
else
q->emitFinishedWithError( OtherError, tr("Could not open wallet: %1; %2").arg( QDBusError::errorString( err.type() ), err.message() ) );
}
}
void ReadPasswordJobPrivate::kwalletOpenFinished( QDBusPendingCallWatcher* watcher ) {
watcher->deleteLater();
const QDBusPendingReply<int> reply = *watcher;
QScopedPointer<QSettings> local( !q->settings() ? new QSettings( q->service() ) : 0 );
QSettings* actual = q->settings() ? q->settings() : local.data();
if ( reply.isError() ) {
fallbackOnError( reply.error() );
return;
}
if ( actual->contains( dataKey( key ) ) ) {
// We previously stored data in the insecure QSettings, but now have KWallet available.
// Do the migration
data = actual->value( dataKey( key ) ).toByteArray();
const WritePasswordJobPrivate::Mode mode = WritePasswordJobPrivate::stringToMode( actual->value( typeKey( key ) ).toString() );
actual->remove( key );
q->emitFinished();
WritePasswordJob* j = new WritePasswordJob( q->service(), 0 );
j->setSettings( q->settings() );
j->setKey( key );
j->setAutoDelete( true );
if ( mode == WritePasswordJobPrivate::Binary )
j->setBinaryData( data );
else if ( mode == WritePasswordJobPrivate::Text )
j->setTextData( QString::fromUtf8( data ) );
else
Q_ASSERT( false );
j->start();
return;
}
walletHandle = reply.value();
if ( walletHandle < 0 ) {
q->emitFinishedWithError( AccessDenied, tr("Access to keychain denied") );
return;
}
const QDBusPendingReply<int> nextReply = iface->entryType( walletHandle, q->service(), key, q->service() );
QDBusPendingCallWatcher* nextWatcher = new QDBusPendingCallWatcher( nextReply, this );
connect( nextWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(kwalletEntryTypeFinished(QDBusPendingCallWatcher*)) );
}
//Must be in sync with KWallet::EntryType (kwallet.h)
enum KWalletEntryType {
Unknown=0,
Password,
Stream,
Map
};
void ReadPasswordJobPrivate::kwalletEntryTypeFinished( QDBusPendingCallWatcher* watcher ) {
watcher->deleteLater();
if ( watcher->isError() ) {
const QDBusError err = watcher->error();
q->emitFinishedWithError( OtherError, tr("Could not determine data type: %1; %2").arg( QDBusError::errorString( err.type() ), err.message() ) );
return;
}
const QDBusPendingReply<int> reply = *watcher;
const int value = reply.value();
switch ( value ) {
case Unknown:
q->emitFinishedWithError( EntryNotFound, tr("Entry not found") );
return;
case Password:
dataType = Text;
break;
case Stream:
dataType = Binary;
break;
case Map:
q->emitFinishedWithError( EntryNotFound, tr("Unsupported entry type 'Map'") );
return;
default:
q->emitFinishedWithError( OtherError, tr("Unknown kwallet entry type '%1'").arg( value ) );
return;
}
const QDBusPendingCall nextReply = dataType == Text
? QDBusPendingCall( iface->readPassword( walletHandle, q->service(), key, q->service() ) )
: QDBusPendingCall( iface->readEntry( walletHandle, q->service(), key, q->service() ) );
QDBusPendingCallWatcher* nextWatcher = new QDBusPendingCallWatcher( nextReply, this );
connect( nextWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(kwalletReadFinished(QDBusPendingCallWatcher*)) );
}
void ReadPasswordJobPrivate::kwalletReadFinished( QDBusPendingCallWatcher* watcher ) {
watcher->deleteLater();
if ( watcher->isError() ) {
const QDBusError err = watcher->error();
q->emitFinishedWithError( OtherError, tr("Could not read password: %1; %2").arg( QDBusError::errorString( err.type() ), err.message() ) );
return;
}
if ( dataType == Binary ) {
QDBusPendingReply<QByteArray> reply = *watcher;
data = reply.value();
} else {
QDBusPendingReply<QString> reply = *watcher;
data = reply.value().toUtf8();
}
q->emitFinished();
}
void WritePasswordJobPrivate::scheduledStart() {
switch ( getKeyringBackend() ) {
case Backend_GnomeKeyring:
if ( mode == WritePasswordJobPrivate::Delete ) {
if ( !GnomeKeyring::delete_network_password( key.toUtf8().constData(), q->service().toUtf8().constData(),
reinterpret_cast<GnomeKeyring::OperationDoneCallback>( &WritePasswordJobPrivate::gnomeKeyring_cb ),
this, 0 ) )
q->emitFinishedWithError( OtherError, tr("Unknown error") );
} else {
QByteArray password = mode == WritePasswordJobPrivate::Text ? textData.toUtf8() : binaryData.toBase64();
QByteArray service = q->service().toUtf8();
if ( !GnomeKeyring::store_network_password( GnomeKeyring::GNOME_KEYRING_DEFAULT, service.constData(),
key.toUtf8().constData(), service.constData(), password.constData(),
reinterpret_cast<GnomeKeyring::OperationDoneCallback>( &WritePasswordJobPrivate::gnomeKeyring_cb ),
this, 0 ) )
q->emitFinishedWithError( OtherError, tr("Unknown error") );
}
break;
case Backend_Kwallet:
if ( QDBusConnection::sessionBus().isConnected() )
{
iface = new org::kde::KWallet( QLatin1String("org.kde.kwalletd"), QLatin1String("/modules/kwalletd"), QDBusConnection::sessionBus(), this );
const QDBusPendingReply<QString> reply = iface->networkWallet();
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher( reply, this );
connect( watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(kwalletWalletFound(QDBusPendingCallWatcher*)) );
}
else
{
// D-Bus is not reachable so none can tell us something about KWalletd
QDBusError err( QDBusError::NoServer, tr("D-Bus is not running") );
fallbackOnError( err );
}
}
}
QString WritePasswordJobPrivate::modeToString(Mode m)
{
switch (m) {
case Delete:
return QLatin1String("Delete");
case Text:
return QLatin1String("Text");
case Binary:
return QLatin1String("Binary");
}
Q_ASSERT_X(false, Q_FUNC_INFO, "Unhandled Mode value");
return QString();
}
WritePasswordJobPrivate::Mode WritePasswordJobPrivate::stringToMode(const QString& s)
{
if (s == QLatin1String("Delete") || s == QLatin1String("0"))
return Delete;
if (s == QLatin1String("Text") || s == QLatin1String("1"))
return Text;
if (s == QLatin1String("Binary") || s == QLatin1String("2"))
return Binary;
qCritical("Unexpected mode string '%s'", qPrintable(s));
return Text;
}
void WritePasswordJobPrivate::fallbackOnError(const QDBusError &err)
{
QScopedPointer<QSettings> local( !q->settings() ? new QSettings( q->service() ) : 0 );
QSettings* actual = q->settings() ? q->settings() : local.data();
if ( !q->insecureFallback() ) {
q->emitFinishedWithError( OtherError, tr("Could not open wallet: %1; %2").arg( QDBusError::errorString( err.type() ), err.message() ) );
return;
}
if ( mode == Delete ) {
actual->remove( key );
actual->sync();
q->emitFinished();
return;
}
actual->setValue( QString::fromLatin1( "%1/type" ).arg( key ), mode );
if ( mode == Text )
actual->setValue( QString::fromLatin1( "%1/data" ).arg( key ), textData.toUtf8() );
else if ( mode == Binary )
actual->setValue( QString::fromLatin1( "%1/data" ).arg( key ), binaryData );
actual->sync();
q->emitFinished();
}
void WritePasswordJobPrivate::gnomeKeyring_cb( int result, WritePasswordJobPrivate* self )
{
if ( result == GnomeKeyring::RESULT_OK ) {
self->q->emitFinished();
} else {
const QPair<Error, QString> errorResult = mapGnomeKeyringError( result );
self->q->emitFinishedWithError( errorResult.first, errorResult.second );
}
}
void WritePasswordJobPrivate::kwalletWalletFound(QDBusPendingCallWatcher *watcher)
{
watcher->deleteLater();
const QDBusPendingReply<QString> reply = *watcher;
const QDBusPendingReply<int> pendingReply = iface->open( reply.value(), 0, q->service() );
QDBusPendingCallWatcher* pendingWatcher = new QDBusPendingCallWatcher( pendingReply, this );
connect( pendingWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(kwalletOpenFinished(QDBusPendingCallWatcher*)) );
}
void WritePasswordJobPrivate::kwalletOpenFinished( QDBusPendingCallWatcher* watcher ) {
watcher->deleteLater();
QDBusPendingReply<int> reply = *watcher;
QScopedPointer<QSettings> local( !q->settings() ? new QSettings( q->service() ) : 0 );
QSettings* actual = q->settings() ? q->settings() : local.data();
if ( reply.isError() ) {
fallbackOnError( reply.error() );
return;
}
if ( actual->contains( key ) )
{
// If we had previously written to QSettings, but we now have a kwallet available, migrate and delete old insecure data
actual->remove( key );
actual->sync();
}
const int handle = reply.value();
if ( handle < 0 ) {
q->emitFinishedWithError( AccessDenied, tr("Access to keychain denied") );
return;
}
QDBusPendingReply<int> nextReply;
if ( !textData.isEmpty() )
nextReply = iface->writePassword( handle, q->service(), key, textData, q->service() );
else if ( !binaryData.isEmpty() )
nextReply = iface->writeEntry( handle, q->service(), key, binaryData, q->service() );
else
nextReply = iface->removeEntry( handle, q->service(), key, q->service() );
QDBusPendingCallWatcher* nextWatcher = new QDBusPendingCallWatcher( nextReply, this );
connect( nextWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(kwalletWriteFinished(QDBusPendingCallWatcher*)) );
}
void WritePasswordJobPrivate::kwalletWriteFinished( QDBusPendingCallWatcher* watcher ) {
watcher->deleteLater();
QDBusPendingReply<int> reply = *watcher;
if ( reply.isError() ) {
const QDBusError err = reply.error();
q->emitFinishedWithError( OtherError, tr("Could not open wallet: %1; %2").arg( QDBusError::errorString( err.type() ), err.message() ) );
return;
}
q->emitFinished();
}
|
[
"crioux@noctem.org"
] |
crioux@noctem.org
|
22cd11ac6cede2d906527488e19617fd08468359
|
33f1b5f6afa115be45cade93479bb7fbc33e7da0
|
/UVA/10063/20034982_AC_230ms_0kB.cpp
|
7caf6eb1ce551a35f7f8a6aa3bb7c43807af1694
|
[] |
no_license
|
showmic96/Online-Judge-Solution
|
3960c37a646f4885210c09096c21dabd7f2154d2
|
94c34e9db2833fb84d0ac885b637dfebac30a5a2
|
refs/heads/master
| 2022-11-26T09:56:58.469560
| 2020-08-02T04:42:33
| 2020-08-02T04:42:33
| 230,185,618
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 608
|
cpp
|
// In the name of Allah the Lord of the Worlds.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string ar;
void f(int i , string temp)
{
if(i==ar.size()){
cout << temp << endl;
return ;
}
char now = ar[i];
for(int i1=0;i1<=temp.size();i1++){
string s = temp;
s.insert(s.begin()+i1 , now);
f(i+1, s);
}
}
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
bool blank = false;
while(cin >> ar){
if(blank)cout << endl;
else blank = true;
f(0 , "");
}
return 0;
}
|
[
"57711640+showmic96@users.noreply.github.com"
] |
57711640+showmic96@users.noreply.github.com
|
d19ccc3051935db7498466e6671474d7b1183f19
|
f57b2f6501c8af65c3da16c0fed7f8aa0b154929
|
/mad_lib.cpp
|
7bb38e1c593e35aa6a2cb52ebc0d8deea9c0b2f6
|
[] |
no_license
|
ydaniju/game_utils
|
3c4a076444f4ad8566b8c747d3412be2f00886f6
|
482f9b526c008d56f27d428e2a89a82d3dd7a141
|
refs/heads/master
| 2020-09-20T11:20:06.887298
| 2019-12-04T12:12:39
| 2019-12-04T12:12:39
| 224,461,730
| 0
| 0
| null | 2019-12-04T12:12:40
| 2019-11-27T15:32:43
|
C++
|
UTF-8
|
C++
| false
| false
| 1,700
|
cpp
|
// Mad-Lib
// Creates a story based on user input
#include <iostream>
#include <string>
using namespace std;
string askText(string prompt);
int askNumber(string prompt);
void tellStory(
string name, string noun, int number, string bodyPart, string verb
);
int main()
{
cout << "Welcome to Mad Lib.\n\n";
cout << "Answer the following questions to help create a new story.\n";
string name = askText("Please enter a name: ");
string noun = askText("Please enter a plural noun: ");
int number = askNumber("Please enter a number: ");
string bodyPart = askText("Please enter a body part: ");
string verb = askText("Please enter a verb: ");
tellStory(name, noun, number, bodyPart, verb);
return 0;
}
string askText(string prompt)
{
string text;
cout << prompt;
cin >> text;
return text;
}
int askNumber(string prompt)
{
int num;
cout << prompt;
cin >> num;
return num;
}
void tellStory(string name, string noun, int number, string bodyPart, string verb)
{
cout << "\nHere’s your story:\n";
cout << "The famous explorer ";
cout << name;
cout << " had nearly given up a life-long quest to find\n";
cout << "The Lost City of ";
cout << noun;
cout << " when one day, the ";
cout << noun;
cout << " found the explorer.\n";
cout << "Surrounded by ";
cout << number;
cout << " " << noun;
cout << ", a tear came to ";
cout << name << "’s ";
cout << bodyPart << ".\n";
cout << "After all this time, the quest was finally over. ";
cout << "And then, the ";
cout << noun << "\n";
cout << "promptly devoured ";
cout << name << ". ";
cout << "The moral of the story? Be careful what you ";
cout << verb;
cout << " for.\n";
}
|
[
"danijuyusuf@outlook.com"
] |
danijuyusuf@outlook.com
|
5175720cf43203e38ae4ad6b53fb4084e718320b
|
236c9a335be1ce06685171a9c8ef8cfd305d7eec
|
/lang/ok.h
|
59644f1725d78bd3d1567737482b6fa4cd9d0b43
|
[
"MIT"
] |
permissive
|
newmen/micro-scheme
|
39f7ba37052dc5d5331cd5d84a54b3f20b455b00
|
ce11e2d82e1b2ba56a0bff82a59f9de8c987dd93
|
refs/heads/master
| 2021-03-13T00:12:09.134554
| 2014-12-27T20:04:46
| 2014-12-27T20:05:30
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 274
|
h
|
#ifndef OK_H
#define OK_H
#include "tools/singleton.h"
#include "data.h"
class Ok : public Singleton<Ok, Data>
{
friend class Singleton;
Ok() = default;
public:
std::string value() const override;
bool eql(const Data *) const override;
};
#endif // OK_H
|
[
"altermn@gmail.com"
] |
altermn@gmail.com
|
0ab29d9ce2eb29429bd66aeccdfac85e2b169744
|
e85338f6d8666eb476698de5025c742b9b838a50
|
/contests/sub-south-neerc12/A/A.cpp
|
9dde746110b4da6e1bfcb3f5191b9112b97f0dbc
|
[] |
no_license
|
yancouto/competitive-programming
|
8104bb3c45e0b385c2abb4cfcac14c35cce0619e
|
ac849e3aa858eea56b0aa6b7eb93e9a9e70f9475
|
refs/heads/master
| 2022-10-19T11:29:46.932829
| 2022-10-07T00:16:43
| 2022-10-07T00:16:43
| 66,641,933
| 7
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 892
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const int N = 2e5+7;
int x[N];
int w[N];
int p[N];
int n, d;
int get (pii a) {
if (a.first == -1) return 0;
return w[a.first] + w[a.second];
}
int main() {
#ifdef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
scanf("%d %d", &n, &d);
for (int i = 0; i < n; i++) {
scanf("%d %d", &x[i], &w[i]);
p[i] = i;
}
sort(p, p+n, [] (int i, int j) {
return x[i] < x[j];
});
int i = -1;
pii sol(-1,-1);
int bst = -1;
for (int j = 0; j < n; j++) {
while (i < j-1 && x[p[j]] - x[p[i+1]] >= d) {
i++;
if (bst == -1 || w[p[i]] >= w[bst])
bst = p[i];
}
if (get(pii(bst, p[j])) > get(sol))
sol = pii(bst, p[j]);
}
if (sol.first == -1) {
sol.first--;
sol.second--;
}
printf("%lld %lld\n", sol.first+1, sol.second+1);
}
|
[
"yancouto@gmail.com"
] |
yancouto@gmail.com
|
8e2ac04fb93b0720249a52e2060dddb82c2c5097
|
b94cd23b2aae437b0f17bc762e4a6a7f156f9161
|
/Temp/StagingArea/Data/il2cppOutput/Il2CppMetadataRegistration.cpp
|
9bf976b8bd836ac7ee17d63f10de39e81d922d19
|
[] |
no_license
|
DrSlowpokePhd/SuperDuperPlatformingOdyssey
|
4f5638e02c9a374a9a4deeb4a86ef7a0f5d4823e
|
e68b8ea6c420d29db1d78d65c7f1b2ae7fd5fc26
|
refs/heads/master
| 2022-09-01T13:40:32.332401
| 2022-08-10T01:31:31
| 2022-08-10T01:31:31
| 141,931,512
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,112
|
cpp
|
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <limits>
#include <assert.h>
#include "il2cpp-class-internals.h"
#include "codegen/il2cpp-codegen.h"
extern Il2CppGenericClass* const s_Il2CppGenericTypes[];
extern const Il2CppGenericInst* const g_Il2CppGenericInstTable[];
extern const Il2CppGenericMethodFunctionsDefinitions s_Il2CppGenericMethodFunctions[];
extern const RuntimeType* const g_Il2CppTypeTable[];
extern const Il2CppMethodSpec g_Il2CppMethodSpecTable[];
extern const int32_t* g_FieldOffsetTable[];
extern const Il2CppTypeDefinitionSizes* g_Il2CppTypeDefinitionSizesTable[];
extern void** const g_MetadataUsages[];
extern const Il2CppMetadataRegistration g_MetadataRegistration =
{
2469,
s_Il2CppGenericTypes,
585,
g_Il2CppGenericInstTable,
4945,
s_Il2CppGenericMethodFunctions,
8774,
g_Il2CppTypeTable,
5261,
g_Il2CppMethodSpecTable,
2049,
g_FieldOffsetTable,
2049,
g_Il2CppTypeDefinitionSizesTable,
7214,
g_MetadataUsages,
};
|
[
"starmagic1999@gmail.com"
] |
starmagic1999@gmail.com
|
646604a3039b8ed84810a7082c960ee60cd961bf
|
f2cd59a5affec155e7ac7f901740bfb1cd78b96e
|
/dynamiclinkstatic/dynamic2/dynamic.cpp
|
871c8740e08149576cb22de2bd109b78b3d7ed55
|
[] |
no_license
|
richader/exercise
|
bea99e0699e4f7f028647d042e95847d3a4c2b8d
|
2fdac746716e8458933680405b55fdeb47d5d5db
|
refs/heads/master
| 2020-04-06T12:56:41.899040
| 2018-11-14T02:34:34
| 2018-11-14T02:34:34
| 152,691,588
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 204
|
cpp
|
#include "dynamic.h"
#include "../staticf/static.h"
#include <iostream>
using namespace std;
void SetMyValue(){
SetValue(2);
}
void PrintValue(){
cout<<"print value in dynamc2:"<<GetValue()<<endl;
}
|
[
"648963532@qq.com"
] |
648963532@qq.com
|
b953258d5ead278ae95bc0e613f5970864f14f20
|
9cacfc7d15f7d7b3521f6230369faf001d74210e
|
/Practica 2/P2_G18_arduino/lumenes.ino
|
505c05c9dbf6668788be4c79face3ed1ef213391
|
[] |
no_license
|
cgomez29/ACE2_2S21_G18
|
7204c54f627c5d649b3be10fd1f6626306449dd6
|
35021226ab0f96de595527662a57e3c2baf34220
|
refs/heads/main
| 2023-08-25T20:03:25.567488
| 2021-11-06T05:45:46
| 2021-11-06T05:45:46
| 394,782,765
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 180
|
ino
|
//SCL - Pin 21
//SDA - Pin 20
String getLumens() {
unsigned int lux = sensor_lumens.readLightLevel();
String l = "\"luz\":";
l.concat(String(lux));
return (l);
}
|
[
"noreply@github.com"
] |
cgomez29.noreply@github.com
|
3379a8f6a35a198dfaeb1297b03cc804ae0ce787
|
3ca0354d3e76345b1b9aaac56380a7ba8b9a8385
|
/Computer Graphics/CG-Final-Project/CG-Final/CG-Final/Build/cylin.cpp
|
910e4f960be6bc86a3d83bf5945bc7e011859df1
|
[
"MIT"
] |
permissive
|
wpn-zju/Undergraduate-Course-Homework-ZJU
|
c58d1262b1cb30b10e8f4e0f82447c66a20a649e
|
ee75ddd73b13fe7df471b77d9da1532d2fb11c5c
|
refs/heads/master
| 2023-05-12T06:50:37.650218
| 2023-04-30T00:39:11
| 2023-04-30T00:39:11
| 218,277,876
| 9
| 3
|
MIT
| 2020-10-22T01:38:58
| 2019-10-29T12:06:57
|
C++
|
UTF-8
|
C++
| false
| false
| 542
|
cpp
|
#include "cylin.h"
namespace build
{
Cylin::Cylin(GLfloat r, GLfloat h, VECTOR3D center, VECTOR4D color)
: Model::Model(center, color), m_R(r), m_Height(h)
{
}
Cylin::~Cylin()
{
}
void Cylin::draw() const
{
glColor4f(m_Color.x, m_Color.y, m_Color.z, m_Color.w);
GLUquadricObj *objCylinder = gluNewQuadric();
glTranslatef(m_Center.x, m_Center.y, m_Center.z);
glScalef(m_R, m_R, m_Height);
drawCycle(VECTOR3D(0, 0, 1));
drawCycle(VECTOR3D(0, 0, 0));
gluCylinder(objCylinder, 1, 1, 1, 30, 30);
Model::draw();
}
}
|
[
"3150102239@zju.edu.cn"
] |
3150102239@zju.edu.cn
|
cea7e3f05ffc9ad288a097effde07bf2f9353df9
|
38d01a5f6adfce89b40d2cb0c8bf26c37ffbbf27
|
/boost/include/boost/preprocessor/tuple/elem.hpp
|
5a49c511da19f51cbdfd705c2c5ba3aafd2ceac8
|
[
"MIT"
] |
permissive
|
ExpLife0011/gtirb
|
467ed7d20ad4ac0763da50bc21fc1386fdab8f5e
|
e9b90133295b15cfae8960d57dafda548913e8f9
|
refs/heads/master
| 2020-05-02T12:07:56.062974
| 2019-03-26T18:38:13
| 2019-03-26T18:38:13
| 177,950,649
| 1
| 0
|
MIT
| 2019-03-27T08:27:50
| 2019-03-27T08:27:50
| null |
UTF-8
|
C++
| false
| false
| 53,241
|
hpp
|
# /* Copyright (C) 2001
# * Housemarque Oy
# * http://www.housemarque.com
# *
# * Distributed under the Boost Software License, Version 1.0. (See
# * accompanying file LICENSE_1_0.txt or copy at
# * http://www.boost.org/LICENSE_1_0.txt)
# */
#
# /* Revised by Paul Mensonides (2002-2011) */
# /* Revised by Edward Diener (2011,2014) */
#
# /* See http://www.boost.org for most recent version. */
#
# ifndef BOOST_PREPROCESSOR_TUPLE_ELEM_HPP
# define BOOST_PREPROCESSOR_TUPLE_ELEM_HPP
#
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/config/config.hpp>
# include <boost/preprocessor/facilities/expand.hpp>
# include <boost/preprocessor/facilities/overload.hpp>
# include <boost/preprocessor/tuple/rem.hpp>
# include <boost/preprocessor/variadic/elem.hpp>
# include <boost/preprocessor/tuple/detail/is_single_return.hpp>
#
# if BOOST_PP_VARIADICS
# if BOOST_PP_VARIADICS_MSVC
# define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_TUPLE_ELEM_I(BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__), (__VA_ARGS__))
# define BOOST_PP_TUPLE_ELEM_I(m, args) BOOST_PP_TUPLE_ELEM_II(m, args)
# define BOOST_PP_TUPLE_ELEM_II(m, args) BOOST_PP_CAT(m ## args,)
/*
Use BOOST_PP_REM_CAT if it is a single element tuple ( which might be empty )
else use BOOST_PP_REM. This fixes a VC++ problem with an empty tuple and BOOST_PP_TUPLE_ELEM
functionality. See tuple_elem_bug_test.cxx.
*/
# define BOOST_PP_TUPLE_ELEM_O_2(n, tuple) \
BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_EXPAND(BOOST_PP_TUPLE_IS_SINGLE_RETURN(BOOST_PP_REM_CAT,BOOST_PP_REM,tuple) tuple)) \
/**/
# else
# define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__)(__VA_ARGS__)
# define BOOST_PP_TUPLE_ELEM_O_2(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_REM tuple)
# endif
# define BOOST_PP_TUPLE_ELEM_O_3(size, n, tuple) BOOST_PP_TUPLE_ELEM_O_2(n, tuple)
# else
# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()
# define BOOST_PP_TUPLE_ELEM(size, n, tuple) BOOST_PP_TUPLE_ELEM_I(BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM_, n), BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM_E_, size), tuple))
# define BOOST_PP_TUPLE_ELEM_I(m, args) BOOST_PP_TUPLE_ELEM_II(m, args)
# define BOOST_PP_TUPLE_ELEM_II(m, args) BOOST_PP_CAT(m ## args,)
# elif BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()
# define BOOST_PP_TUPLE_ELEM(size, n, tuple) BOOST_PP_TUPLE_ELEM_I_OO((size, n, tuple))
# define BOOST_PP_TUPLE_ELEM_I_OO(par) BOOST_PP_TUPLE_ELEM_I ## par
# define BOOST_PP_TUPLE_ELEM_I(size, n, tuple) BOOST_PP_TUPLE_ELEM_II((n, BOOST_PP_TUPLE_ELEM_E_ ## size ## tuple))
# define BOOST_PP_TUPLE_ELEM_II(par) BOOST_PP_TUPLE_ELEM_III_OO(par)
# define BOOST_PP_TUPLE_ELEM_III_OO(par) BOOST_PP_TUPLE_ELEM_III ## par
# define BOOST_PP_TUPLE_ELEM_III(n, etuple) BOOST_PP_TUPLE_ELEM_ ## n ## etuple
# else
# define BOOST_PP_TUPLE_ELEM(size, n, tuple) BOOST_PP_TUPLE_ELEM_I(BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM_, n) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM_E_, size) tuple)
# define BOOST_PP_TUPLE_ELEM_I(x) x
# endif
# define BOOST_PP_TUPLE_ELEM_E_1(e0) (e0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_2(e0, e1) (e0, e1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_3(e0, e1, e2) (e0, e1, e2, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_4(e0, e1, e2, e3) (e0, e1, e2, e3, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_5(e0, e1, e2, e3, e4) (e0, e1, e2, e3, e4, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_6(e0, e1, e2, e3, e4, e5) (e0, e1, e2, e3, e4, e5, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_7(e0, e1, e2, e3, e4, e5, e6) (e0, e1, e2, e3, e4, e5, e6, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_8(e0, e1, e2, e3, e4, e5, e6, e7) (e0, e1, e2, e3, e4, e5, e6, e7, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_9(e0, e1, e2, e3, e4, e5, e6, e7, e8) (e0, e1, e2, e3, e4, e5, e6, e7, e8, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_10(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_11(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_12(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_13(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_14(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_15(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_16(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_17(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_18(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_19(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_20(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_21(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_22(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_23(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_24(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_25(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_26(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_27(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_28(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_29(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_30(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_31(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_32(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_33(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_34(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_35(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_36(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_37(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_38(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_39(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_40(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_41(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_42(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_43(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_44(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_45(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_46(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_47(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_48(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_49(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_50(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_51(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_52(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_53(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_54(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_55(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_56(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, ?, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_57(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, ?, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_58(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, ?, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_59(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, ?, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_60(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, ?, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_61(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, ?, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_62(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, ?, ?)
# define BOOST_PP_TUPLE_ELEM_E_63(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62) (e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, ?)
# define BOOST_PP_TUPLE_ELEM_E_64
# define BOOST_PP_TUPLE_ELEM_0(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e0
# define BOOST_PP_TUPLE_ELEM_1(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e1
# define BOOST_PP_TUPLE_ELEM_2(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e2
# define BOOST_PP_TUPLE_ELEM_3(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e3
# define BOOST_PP_TUPLE_ELEM_4(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e4
# define BOOST_PP_TUPLE_ELEM_5(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e5
# define BOOST_PP_TUPLE_ELEM_6(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e6
# define BOOST_PP_TUPLE_ELEM_7(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e7
# define BOOST_PP_TUPLE_ELEM_8(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e8
# define BOOST_PP_TUPLE_ELEM_9(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e9
# define BOOST_PP_TUPLE_ELEM_10(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e10
# define BOOST_PP_TUPLE_ELEM_11(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e11
# define BOOST_PP_TUPLE_ELEM_12(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e12
# define BOOST_PP_TUPLE_ELEM_13(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e13
# define BOOST_PP_TUPLE_ELEM_14(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e14
# define BOOST_PP_TUPLE_ELEM_15(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e15
# define BOOST_PP_TUPLE_ELEM_16(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e16
# define BOOST_PP_TUPLE_ELEM_17(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e17
# define BOOST_PP_TUPLE_ELEM_18(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e18
# define BOOST_PP_TUPLE_ELEM_19(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e19
# define BOOST_PP_TUPLE_ELEM_20(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e20
# define BOOST_PP_TUPLE_ELEM_21(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e21
# define BOOST_PP_TUPLE_ELEM_22(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e22
# define BOOST_PP_TUPLE_ELEM_23(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e23
# define BOOST_PP_TUPLE_ELEM_24(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e24
# define BOOST_PP_TUPLE_ELEM_25(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e25
# define BOOST_PP_TUPLE_ELEM_26(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e26
# define BOOST_PP_TUPLE_ELEM_27(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e27
# define BOOST_PP_TUPLE_ELEM_28(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e28
# define BOOST_PP_TUPLE_ELEM_29(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e29
# define BOOST_PP_TUPLE_ELEM_30(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e30
# define BOOST_PP_TUPLE_ELEM_31(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e31
# define BOOST_PP_TUPLE_ELEM_32(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e32
# define BOOST_PP_TUPLE_ELEM_33(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e33
# define BOOST_PP_TUPLE_ELEM_34(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e34
# define BOOST_PP_TUPLE_ELEM_35(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e35
# define BOOST_PP_TUPLE_ELEM_36(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e36
# define BOOST_PP_TUPLE_ELEM_37(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e37
# define BOOST_PP_TUPLE_ELEM_38(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e38
# define BOOST_PP_TUPLE_ELEM_39(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e39
# define BOOST_PP_TUPLE_ELEM_40(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e40
# define BOOST_PP_TUPLE_ELEM_41(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e41
# define BOOST_PP_TUPLE_ELEM_42(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e42
# define BOOST_PP_TUPLE_ELEM_43(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e43
# define BOOST_PP_TUPLE_ELEM_44(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e44
# define BOOST_PP_TUPLE_ELEM_45(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e45
# define BOOST_PP_TUPLE_ELEM_46(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e46
# define BOOST_PP_TUPLE_ELEM_47(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e47
# define BOOST_PP_TUPLE_ELEM_48(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e48
# define BOOST_PP_TUPLE_ELEM_49(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e49
# define BOOST_PP_TUPLE_ELEM_50(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e50
# define BOOST_PP_TUPLE_ELEM_51(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e51
# define BOOST_PP_TUPLE_ELEM_52(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e52
# define BOOST_PP_TUPLE_ELEM_53(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e53
# define BOOST_PP_TUPLE_ELEM_54(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e54
# define BOOST_PP_TUPLE_ELEM_55(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e55
# define BOOST_PP_TUPLE_ELEM_56(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e56
# define BOOST_PP_TUPLE_ELEM_57(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e57
# define BOOST_PP_TUPLE_ELEM_58(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e58
# define BOOST_PP_TUPLE_ELEM_59(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e59
# define BOOST_PP_TUPLE_ELEM_60(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e60
# define BOOST_PP_TUPLE_ELEM_61(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e61
# define BOOST_PP_TUPLE_ELEM_62(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e62
# define BOOST_PP_TUPLE_ELEM_63(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63) e63
# endif
#
# /* directly used elsewhere in Boost... */
#
# define BOOST_PP_TUPLE_ELEM_1_0(a) a
#
# define BOOST_PP_TUPLE_ELEM_2_0(a, b) a
# define BOOST_PP_TUPLE_ELEM_2_1(a, b) b
#
# define BOOST_PP_TUPLE_ELEM_3_0(a, b, c) a
# define BOOST_PP_TUPLE_ELEM_3_1(a, b, c) b
# define BOOST_PP_TUPLE_ELEM_3_2(a, b, c) c
#
# endif
|
[
"nweston@grammatech.com"
] |
nweston@grammatech.com
|
27fa93cb60d8c64939d02d86d0ec94ecb0e50db2
|
cecfda84e25466259d3ef091953c3ac7b44dc1fc
|
/UVa Online Judge/volume107/10734 Triangle Partitioning/program.cpp
|
38646405a8abb72f87191740c0525e00b6884400
|
[] |
no_license
|
metaphysis/Code
|
8e3c3610484a8b5ca0bb116bc499a064dda55966
|
d144f4026872aae45b38562457464497728ae0d6
|
refs/heads/master
| 2023-07-26T12:44:21.932839
| 2023-07-12T13:39:41
| 2023-07-12T13:39:41
| 53,327,611
| 231
| 57
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,181
|
cpp
|
// Triangle Partitioning
// UVa ID: 10734
// Verdict: Accepted
// Submission Date: 2018-12-02
// UVa Run Time: 0.000s
//
// 版权所有(C)2018,邱秋。metaphysis # yeah dot net
#include <bits/stdc++.h>
using namespace std;
const double EPSILON = 1e-7;
struct triangle
{
double a, b, c, A, B, C;
triangle (double a = 0, double b = 0, double c = 0, double A = 0, double B = 0, double C = 0): a(a), b(b), c(c), A(A), B(B), C(C) {}
bool operator==(const triangle &t) const
{
double a1[3] = {A, B, C}, a2[3] = {t.A, t.B, t.C};
sort(a1, a1 + 3);
sort(a2, a2 + 3);
return fabs(A - t.A) < EPSILON && fabs(B - t.B) < EPSILON && fabs(C - t.C) < EPSILON;
}
};
triangle getTriangle(double a, double b, double c)
{
if (a > b) swap(a, b);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
double A = acos((b * b + c * c - a * a) / (2 * b * c));
double B = acos((a * a + c * c - b * b) / (2 * a * c));
double C = acos((a * a + b * b - c * c) / (2 * a * b));
return triangle(a, b, c, A, B, C);
}
pair<triangle, triangle> partition(triangle t)
{
double M = sqrt(t.a * t.a + t.c * t.c / 4 - t.a * t.c * cos(t.B));
return pair<triangle, triangle>(getTriangle(t.a, M, t.c / 2), getTriangle(t.b, M, t.c / 2));
}
int main(int argc, char *argv[])
{
cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
int cases;
double a, b, c;
cin >> cases;
for (int cs = 1; cs <= cases; cs++)
{
vector<triangle> triangles;
cin >> a >> b >> c;
queue<triangle> q;
q.push(getTriangle(a, b, c));
while (!q.empty())
{
triangle t1 = q.front(); q.pop();
bool same = false;
for (auto t2 : triangles)
if (t1 == t2)
{
same = true;
break;
}
if (same) continue;
triangles.push_back(t1);
pair<triangle, triangle> p2 = partition(t1);
q.push(p2.first);
q.push(p2.second);
}
cout << "Triangle " << cs << ": " << triangles.size() << '\n';
}
return 0;
}
|
[
"metaphysis@yeah.net"
] |
metaphysis@yeah.net
|
a2ec460485bc9fa0dea62f3f8dab7eed5d9a1ff6
|
2c6494171023427fded3555ca6d13af7ea921843
|
/General/GuessOutputInheritance.cpp
|
87a7d5abfe7de9a5ab14dd69550c1bb4081b4a7d
|
[] |
no_license
|
monish001/CPP-Programs
|
7d835cb4ec59c03d7b402d7be91062d68a7001a5
|
406d1949a52d03bfec15beef4378729a2c284eee
|
refs/heads/master
| 2021-01-23T19:12:22.356388
| 2016-03-12T13:06:18
| 2016-03-12T13:06:18
| 1,692,308
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 201
|
cpp
|
#include<iostream>
#include<conio.h>
using namespace std;
class Base {
public: int a;
};
class Der: private Base{
public:
void print(){
cout<<a;
}
};
int main(){
Der c;
c.print();
return 0;
}
|
[
"monish.gupta1@gmail.com"
] |
monish.gupta1@gmail.com
|
804e814cf877f69669db0c5a35edc2ddd5d7b6c1
|
0fff690d5ba9d95f10bfb636ae018f3c14de4a14
|
/grad_descent.cpp
|
30aadeef701d9d54462d467a4d86e2de2dd05928
|
[
"MIT"
] |
permissive
|
laurieKell/sraplus
|
8b3675406a5f499ae61ea872736a7560167e6684
|
63823efd3f67ff4485dba1139a44984b6429e574
|
refs/heads/master
| 2021-01-02T11:36:52.779660
| 2020-01-29T18:41:44
| 2020-01-29T18:41:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,961
|
cpp
|
#include <Rcpp.h>
using namespace Rcpp;
// This is a simple example of exporting a C++ function to R. You can
// source this function into an R session using the Rcpp::sourceCpp
// function (or via the Source button on the editor toolbar). Learn
// more about Rcpp at:
//
// http://www.rcpp.org/
// http://adv-r.had.co.nz/Rcpp.html
// http://gallery.rcpp.org/
//
NumericVector popmodel(double r, double k, double m,double b0,double plim,int years, double sigma_proc,NumericVector catches){
double growth_mult;
NumericVector b_t(years,0.0);
// std::vector<double> b_t(years, 0.0);
b_t(0) = b0;
for ( int t = 1; t < years; t++) {
if ((b_t(t - 1) / k) < plim){
growth_mult = b_t(t - 1) / (plim * k);
} else {
growth_mult = 1;
}
b_t(t) = (b_t(t - 1) + growth_mult * ((r / (m - 1)) * b_t(t - 1) * (1 - pow(b_t(t - 1) / k,m - 1)))
- catches(t - 1)) * exp(R::rnorm(-pow(sigma_proc,2)/2, sigma_proc));
b_t(t) = std::max(0.0,b_t(t));
// if ((b_t(t,i) / ks(i)) > 1.2){
//
// b_t(t,i) = 1.2 * ks(i);
//
// }
// std::cout << b_t(t) << std::endl;
if (b_t(t) <= 0){
break;
}
} // close population model
return(b_t);
}
// [[Rcpp::export]]
NumericVector graddesc(double r,
double m,
double init_deps,
double plim,
int years,
double sigma_procs,
NumericVector catches,
double final_state,
double learn_rate){
double growth_mult;
double delta;
double last_proposal;
double prop_error;
double new_proposal;
double grad_dep;
double conv_error;
double log_like;
double k;
int counter;
int crashed;
counter = 0;
delta = 100;
NumericVector proposal_result(years);
last_proposal = log(1000000 * max(catches));
// proposal_result = popmodel(r,m,exp(last_proposal), init_dep, catch_t, proc_errors, time, eps,plim);
proposal_result = popmodel(r, exp(last_proposal), m, exp(last_proposal) * init_deps, plim, years, sigma_procs, catches);
// std::cout << "counter is" << proposal_result(years - 1) << std::endl;
prop_error = log(proposal_result(years - 1) / exp(last_proposal)) - log(final_state);
while(delta > 1e-3){
new_proposal = last_proposal - learn_rate * prop_error;
// std::cout << "new proposal is" << new_proposal << std::endl;
// proposal_result = popmodel(r,m,exp(new_proposal), init_dep, catch_t, proc_errors, time, eps,plim);
proposal_result = popmodel(r, exp(new_proposal), m, exp(new_proposal) * init_deps, plim, years, sigma_procs, catches);
// std::cout << "initial proposal is " << proposal_result << std::endl;
for (int t = 0; t< years; t++){
// std::cout << proposal_result(t) << std::endl;
if (proposal_result(t) <= 0){
crashed = 1;
log_like = -1e9;
break;
}
}
grad_dep = proposal_result(years - 1) / exp(new_proposal);
prop_error = log(grad_dep + 1e-6) - log(final_state);
// std::cout << "prop dep is" << proposal_result[time - 1] / exp(new_proposal) << std::endl;
last_proposal = new_proposal;
delta = sqrt(pow(grad_dep - final_state,2));
// std::cout << "new proposal is is" << new_proposal << std::endl;
conv_error = delta;
// std::cout<< delta << std::endl;
counter += 1;
if (counter > 1e6){
delta = -999;
crashed = 1;
} // close escape hatch
std::cout << "delta is" << delta << std::endl;
} // close while looop for gradient descnet
// std::cout << "counter is" << counter << std::endl;
// std::cout << "delta is" << delta << std::endl;
k = exp(new_proposal);
// log_like(i) += log(conv_error);
return(proposal_result);
}
|
[
"noreply@github.com"
] |
laurieKell.noreply@github.com
|
356818f13fb356e55b6ecf9d6485ea3991b437f5
|
261506f03bbcbf9d5481036a270cdc91bc6ebeff
|
/jazzjackrabbit/Jazz jack rabbit/Multi.cpp
|
05d7ebbae7de32df543752d483cf6e8e10d9341a
|
[] |
no_license
|
guswhd2813/jazzjackrabbit2_smallcopy
|
068136e2d9d3e9820d79acf85b725b9b0aacb030
|
bd05dd8f6f7b277eb862106e033132f5eb833e39
|
refs/heads/master
| 2022-08-16T14:38:22.933766
| 2020-05-23T16:39:51
| 2020-05-23T16:39:51
| 266,376,576
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,679
|
cpp
|
#include "StdAfx.h"
#include "Multi.h"
CMulti::CMulti(void)
:bUp(0),bLR(0)
{
}
CMulti::~CMulti(void)
{
Release();
}
void CMulti::Initialize(void)
{
m_tInfo.fCX = 19.f;
m_tInfo.fCY = 9.f;
m_fBulletSpd = 3.f;
}
void CMulti::Render(HDC hdc)
{
if(bLR==1 && bUp==0)
{
TransparentBlt(hdc,
int(m_tInfo.fX - m_tInfo.fCX / 2.f + m_ptScroll.x),
int(m_tInfo.fY - m_tInfo.fCY / 2.f + m_ptScroll.y),
int(m_tInfo.fCX), int(m_tInfo.fCY),
(*m_pBitMap)["multi-right"]->GetMemDC(),
0, 0,
(int)m_tInfo.fCX,(int)m_tInfo.fCY,
RGB(150, 150, 150));
}
else if(bLR==0 && bUp==0)
{
TransparentBlt(hdc,
int(m_tInfo.fX - m_tInfo.fCX / 2.f + m_ptScroll.x),
int(m_tInfo.fY - m_tInfo.fCY / 2.f + m_ptScroll.y),
int(m_tInfo.fCX), int(m_tInfo.fCY),
(*m_pBitMap)["multi-left"]->GetMemDC(),
0, 0,
(int)m_tInfo.fCX,(int)m_tInfo.fCY,
RGB(150, 150, 150));
}
else if(bUp==1)
{
TransparentBlt(hdc,
int(m_tInfo.fX - m_tInfo.fCX / 2.f + m_ptScroll.x),
int(m_tInfo.fY - m_tInfo.fCY / 2.f + m_ptScroll.y),
int(m_tInfo.fCX), int(m_tInfo.fCY),
(*m_pBitMap)["multi-up"]->GetMemDC(),
0, 0,
(int)m_tInfo.fCX,(int)m_tInfo.fCY,
RGB(150, 150, 150));
}
}
int CMulti::Progress()
{
if(m_iDIr == 1)
{
m_strKey="multi-right";
m_tInfo.fCX = 19.f;
m_tInfo.fCY = 9.f;
bUp=0;
bLR=1;
switch(m_eDir)
{
case DIR_UP:
m_tInfo.fX += m_fBulletSpd;
break;
case DIR_LU:
m_tInfo.fX += m_fBulletSpd;
m_tInfo.fY -= 0.9f;
break;
case DIR_RU:
m_tInfo.fX += m_fBulletSpd;
m_tInfo.fY += 0.9f;
break;
}
}
if(m_iDIr == 2)
{
m_strKey="multi-left";
m_tInfo.fCX = 19.f;
m_tInfo.fCY = 9.f;
bUp=0;
bLR=0;
switch(m_eDir)
{
case DIR_UP:
m_tInfo.fX -= m_fBulletSpd;
break;
case DIR_LU:
m_tInfo.fX -= m_fBulletSpd;
m_tInfo.fY -= 0.9f;
break;
case DIR_RU:
m_tInfo.fX -= m_fBulletSpd;
m_tInfo.fY += 0.9f;
break;
}
}
if(m_iDIr == 3)
{
m_strKey="multi-up";
m_tInfo.fCX = 9.f;
m_tInfo.fCY = 19.f;
bUp=1;
bLR=0;
switch(m_eDir)
{
case DIR_UP:
m_tInfo.fY -= m_fBulletSpd;
break;
case DIR_LU:
m_tInfo.fY -= m_fBulletSpd;
m_tInfo.fX -= 0.9f;
break;
case DIR_RU:
m_tInfo.fY -= m_fBulletSpd;
m_tInfo.fX += 0.9f;
break;
}
}
if(m_iDIr == 4)
{
m_strKey="multi-up";
m_tInfo.fCX = 9.f;
m_tInfo.fCY = 19.f;
bUp=1;
bLR=1;
switch(m_eDir)
{
case DIR_UP:
m_tInfo.fY -= m_fBulletSpd;
break;
case DIR_LU:
m_tInfo.fY -= m_fBulletSpd;
m_tInfo.fX -= 0.9f;
break;
case DIR_RU:
m_tInfo.fY -= m_fBulletSpd;
m_tInfo.fX += 0.9f;
break;
}
}
if(m_iDIr == 5)
{
m_strKey="multi-right";
m_tInfo.fCX = 19.f;
m_tInfo.fCY = 9.f;
bUp=0;
bLR=1;
switch(m_eDir)
{
case DIR_UP:
m_tInfo.fX += m_fBulletSpd;
break;
case DIR_LU:
m_tInfo.fX += m_fBulletSpd;
m_tInfo.fY -= 0.9f;
break;
case DIR_RU:
m_tInfo.fX += m_fBulletSpd;
m_tInfo.fY += 0.9f;
break;
}
}
if(m_iDIr == 6)
{
m_strKey="multi-left";
m_tInfo.fCX = 19.f;
m_tInfo.fCY = 9.f;
bUp=0;
bLR=0;
switch(m_eDir)
{
case DIR_UP:
m_tInfo.fX -= m_fBulletSpd;
break;
case DIR_LU:
m_tInfo.fX -= m_fBulletSpd;
m_tInfo.fY -= 0.9f;
break;
case DIR_RU:
m_tInfo.fX -= m_fBulletSpd;
m_tInfo.fY += 0.9f;
break;
}
}
//m_tInfo.fY += m_fBulletSpd;
return 0;
}
void CMulti::Release()
{
CreateEffect1();
}
void CMulti::SetPlayer(CObj* _pPlayer)
{
m_pPlayer = _pPlayer;
}
void CMulti::SetDir(int _iDIr)
{
m_iDIr = _iDIr;
}
|
[
"guswhd2813@naver.com"
] |
guswhd2813@naver.com
|
2838b304ed1d6b8024324012009f9996565a4eb4
|
81882006b4fe2b191fd68ed5cf511a1ba3218e37
|
/engine/Object.cpp
|
70204eaa0ca13e34c72a544e9252692c941f5229
|
[] |
no_license
|
AdminBenni/SFML-car-party-game
|
d44e2309569949dac01c71266015f7309bc24167
|
0c42acbf978e90f0db9d32d73180cae24b40206a
|
refs/heads/master
| 2021-05-08T03:37:37.391277
| 2017-11-02T10:43:51
| 2017-11-02T10:43:51
| 108,274,147
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,157
|
cpp
|
#include "Object.hpp"
namespace bEngine
{
std::string Object::GetTag()
{
return _tag;
}
void Object::SetTag(std::string tag)
{
_tag = tag;
}
std::string Object::GetName()
{
return _name;
}
void Object::SetName(std::string name)
{
_name = name;
}
bool Object::ToBeDrawn(bool val)
{
_toBeDrawn = val;
return _toBeDrawn;
}
bool Object::Collidable()
{
return _collidable;
}
bool Object::Collidable(bool val)
{
_collidable = val;
return _collidable;
}
void Object::addAttachable(std::string name, sf::Sprite trans)
{
_att.push_back(trans);
_attNames.push_back(name);
}
sf::Sprite &Object::getAttached(std::string name)
{
for(unsigned int i = 0; i < _attNames.size(); i++)
{
if(_attNames[i] == name)
return _att[i];
}
}
std::vector<sf::Sprite> Object::getAttachedRaw()
{
return _att;
}
std::vector<std::string> Object::getAttachedNamesRaw()
{
return _attNames;
}
}
|
[
"benediktaronsigurorsson@gmail.com"
] |
benediktaronsigurorsson@gmail.com
|
7c9d311ec964e2a0a0a3a6cf8ee60615c0918c5f
|
70d1d6b75bd174b4b185669823e37abd693caf46
|
/特征向量获取.cpp
|
0f8cc2aedc65ee9d49570f8f06bb9c73e36e695f
|
[] |
no_license
|
1002liu/Code
|
d79295b2030f24cde7e42fb23b87fa477ba2d08e
|
6462e81f02ff4f6afbbeed8e7b9e5bd32cd612d1
|
refs/heads/master
| 2020-06-22T18:46:15.366274
| 2016-11-23T14:01:38
| 2016-11-23T14:01:38
| 74,581,837
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 4,166
|
cpp
|
#include <stdio.h>
#include <iostream>
#include <string>
#include <fstream>
#include <string.h>
#include <vector>
#include <io.h>
using namespace std;
void getFiles( string path, vector<string>& files )
{
//文件句柄
long hFile = 0;
//文件信息
struct _finddata_t fileinfo;
string p;
if((hFile = _findfirst(p.assign(path).append("\\*").c_str(),&fileinfo)) != -1)
{
do
{
//如果是目录,迭代之
//如果不是,加入列表
if((fileinfo.attrib & _A_SUBDIR))
{
if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0)
getFiles( p.assign(path).append("\\").append(fileinfo.name), files );
}
else
{
files.push_back(p.assign(path).append("\\").append(fileinfo.name) );
}
}
while(_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
}
int main()
{
freopen("out.txt","w",stdout);
ifstream file1;
file1.open("all.txt");
string filePath = "G:\\apktool\\11.4\\virus";
vector<string> files;
//获取该路径下的所有文件
getFiles(filePath, files);
int size1 = files.size();
string filePath2 = "G:\\apktool\\11.4\\benign";
vector<string> files2;
//获取该路径下的所有文件
getFiles(filePath2, files2);
int size2 = files2.size();
//cout<<size1<<" "<<size2<<endl;
string str, s;
vector <string > vec;
vector <string > v;
while(getline(file1,str))
{
vec.push_back(str);
}
int num = 1;
// printf(" ");
// for(int i=0; i<vec.size(); i++)
// cout<<" "<<vec[i];
// cout<<endl;
for (int i = 0; i < size1; i++)
{
v.clear();
//cout<<files[i].c_str()<<endl;
string str = files[i].c_str();
ifstream inFile(files[i].c_str());
//inFile.open(str);
while(getline(inFile,s))
{
string st;
if(s.find("uses-permission android")!=string::npos){
int t = s.find("\"");
st="";
for(int i=t+1; i<s.size(); i++){
if(s[i] == '\"') break;
st += s[i];
}
//cout<<str;
//cout<<s<<" "<< s.find("\"")<< " "<< str<<endl;
}
v.push_back(st);
}
// printf("apk%d",num++);
for(int i=0; i<vec.size(); i++)
{
int t = vec[i].size();
int flag = 0;
for(int j=0; j<v.size(); j++){
if(vec[i] == v[j]){
flag = 1;break;
}
}
//for(int k=0; k<t-1; k++) printf(" ");
printf("%d ",flag);
}
printf("0\n");
}
for (int i = 0; i < size2; i++)
{
v.clear();
//cout<<files[i].c_str()<<endl;
string str = files2[i].c_str();
ifstream inFile2(files2[i].c_str());
//inFile.open(str);
while(getline(inFile2,s))
{
string st;
if(s.find("uses-permission android")!=string::npos){
int t = s.find("\"");
st="";
for(int i=t+1; i<s.size(); i++){
if(s[i] == '\"') break;
st += s[i];
}
//cout<<str;
//cout<<s<<" "<< s.find("\"")<< " "<< str<<endl;
}
v.push_back(st);
}
// printf("apk%d",num++);
for(int i=0; i<vec.size(); i++)
{
int t = vec[i].size();
int flag = 0;
for(int j=0; j<v.size(); j++){
if(vec[i] == v[j]){
flag = 1;break;
}
}
//for(int k=0; k<t-1; k++) printf(" ");
printf("%d ",flag);
}
printf("1\n");
}
return 0;
}
|
[
"noreply@github.com"
] |
1002liu.noreply@github.com
|
f8b77b2e4d61018ef73e818115f3901b72e57d77
|
2133dd71f3bd896acdfe2236a8b95a2774379bda
|
/array/31. 下一个排列.cpp
|
93cf328d0fe15bce0251e8b23bc0f8069c6dc498
|
[] |
no_license
|
SuperCodeFarmers/MyLeetCode
|
4df011817c19b6d3d4f7d0f16ee022d8d2041768
|
a7677da42340b85faee9e2d5d755db38089795b8
|
refs/heads/master
| 2023-08-24T22:20:25.832819
| 2021-09-30T07:12:32
| 2021-09-30T07:12:32
| 275,822,699
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,968
|
cpp
|
/*
31. 下一个排列
实现获取 下一个排列 的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列(即,组合出下一个更大的整数)。
如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。
必须 原地 修改,只允许使用额外常数空间。
示例 1:
输入:nums = [1,2,3]
输出:[1,3,2]
示例 2:
输入:nums = [3,2,1]
输出:[1,2,3]
示例 3:
输入:nums = [1,1,5]
输出:[1,5,1]
示例 4:
输入:nums = [1]
输出:[1]
提示:
1 <= nums.length <= 100
0 <= nums[i] <= 100
*/
/*
解题思路:
1、判断按照字典序有没有下一个,如果完全降序就没有下一个大于当前序列的集合了。
2、判断有没有下一个。只要存在nums[i - 1] < nums[i]的升序结构,就存在下一个大于当前序列的集合。我们从后往前找
3、当发现nums[i - 1] < nums[i]时,在从[i, ∞]中找到最接近a[i-1]并且又大于a[i - 1]的数字,由于是降序,所以从右往左遍历就可以得到K,
4、然后交换nums[i - 1]和K,然后在对[i, ∞]排序即可,排序只需要收尾不停交换即可,因为已经是降序了。
例如:[0,5,4,3,2,1],下一个是[1,0,2,3,4,5]
*/
#include<vector>
using namespace std;
void nextPermutation(vector<int>& nums) {
int len = nums.size();
for (int i = len - 1; i > 0; --i) {
if (nums[i] > nums[i - 1]) {
for (int j = len - 1; j >= i; --j) {
if (nums[j] > nums[i - 1]) {
int temp = nums[i - 1];
nums[i - 1] = nums[j];
nums[j] = temp;
sort(nums.begin() + i, nums.end());
return;
}
}
}
}
for (int i = 0, j = len - 1; i < j; ++i, --j) {
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
|
[
"1041893269@qq.com"
] |
1041893269@qq.com
|
302de7adeaa0563aaf3eaaf4e6b3100a86424212
|
47fb20e1435c9f27aa335f32248f84d370132a46
|
/src/libs/protobuf_clips/communicator.h
|
b26fd67bd5b6409263813e458a2c13bf3e9326fa
|
[] |
no_license
|
sanyaade-teachings/fawkes
|
f7fc08aa18147364a2106ed90b2a18501cfc65a0
|
bb80e90bc5192f2ff6c6c6b4f0f6be52ea5627cd
|
refs/heads/master
| 2020-12-14T17:12:30.790871
| 2013-07-13T09:54:11
| 2013-07-13T09:54:11
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,739
|
h
|
/***************************************************************************
* communicator.h - protobuf network communication for CLIPS
*
* Created: Tue Apr 16 13:41:13 2013
* Copyright 2013 Tim Niemueller [www.niemueller.de]
****************************************************************************/
/* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* - Neither the name of the authors nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PROTOBUF_CLIPS_COMMUNICATOR_H_
#define __PROTOBUF_CLIPS_COMMUNICATOR_H_
#include <list>
#include <map>
#include <clipsmm.h>
#include <protobuf_comm/server.h>
#include <core/threading/mutex.h>
namespace protobuf_comm {
class ProtobufStreamClient;
class ProtobufBroadcastPeer;
}
namespace protobuf_clips {
#if 0 /* just to make Emacs auto-indent happy */
}
#endif
class ClipsProtobufCommunicator
{
public:
ClipsProtobufCommunicator(CLIPS::Environment *env, fawkes::Mutex &env_mutex);
ClipsProtobufCommunicator(CLIPS::Environment *env, fawkes::Mutex &env_mutex,
std::vector<std::string> &proto_path);
~ClipsProtobufCommunicator();
void enable_server(int port);
void enable_peer(std::string address, int send_port, int recv_port = 0);
void disable_server();
void disable_peer();
/** Get Protobuf server.
* @return protobuf server */
protobuf_comm::ProtobufStreamServer * server() const
{ return server_; }
/** Get the communicator's message register.
* @return message register */
protobuf_comm::MessageRegister & message_register()
{ return *message_register_; }
private:
void setup_clips();
bool clips_pb_register_type(std::string full_name);
CLIPS::Values clips_pb_field_names(void *msgptr);
bool clips_pb_has_field(void *msgptr, std::string field_name);
CLIPS::Value clips_pb_field_value(void *msgptr, std::string field_name);
CLIPS::Value clips_pb_field_type(void *msgptr, std::string field_name);
CLIPS::Value clips_pb_field_label(void *msgptr, std::string field_name);
CLIPS::Values clips_pb_field_list(void *msgptr, std::string field_name);
bool clips_pb_field_is_list(void *msgptr, std::string field_name);
CLIPS::Value clips_pb_create(std::string full_name);
CLIPS::Value clips_pb_ref(void *msgptr);
void clips_pb_destroy(void *msgptr);
void clips_pb_set_field(void *msgptr, std::string field_name, CLIPS::Value value);
void clips_pb_add_list(void *msgptr, std::string field_name, CLIPS::Value value);
void clips_pb_send(long int client_id, void *msgptr);
long int clips_pb_client_connect(std::string host, int port);
void clips_pb_disconnect(long int client_id);
void clips_pb_broadcast(void *msgptr);
void clips_pb_enable_server(int port);
void clips_pb_enable_peer(std::string host,
int send_port, int recv_port);
CLIPS::Value clips_pb_connect(std::string host, int port);
typedef enum {
CT_SERVER, CT_CLIENT, CT_PEER
} ClientType;
void clips_assert_message(std::pair<std::string, unsigned short> &endpoint,
uint16_t comp_id, uint16_t msg_type,
std::shared_ptr<google::protobuf::Message> &msg,
ClientType ct, unsigned int client_id = 0);
void handle_server_client_connected(protobuf_comm::ProtobufStreamServer::ClientID client,
boost::asio::ip::tcp::endpoint &endpoint);
void handle_server_client_disconnected(protobuf_comm::ProtobufStreamServer::ClientID client,
const boost::system::error_code &error);
void handle_server_client_msg(protobuf_comm::ProtobufStreamServer::ClientID client,
uint16_t component_id, uint16_t msg_type,
std::shared_ptr<google::protobuf::Message> msg);
void handle_server_client_fail(protobuf_comm::ProtobufStreamServer::ClientID client,
uint16_t component_id, uint16_t msg_type,
std::string msg);
void handle_peer_msg(boost::asio::ip::udp::endpoint &endpoint,
uint16_t component_id, uint16_t msg_type,
std::shared_ptr<google::protobuf::Message> msg);
void handle_peer_recv_error(boost::asio::ip::udp::endpoint &endpoint, std::string msg);
void handle_peer_send_error(std::string msg);
void handle_client_connected(long int client_id);
void handle_client_disconnected(long int client_id,
const boost::system::error_code &error);
void handle_client_msg(long int client_id,
uint16_t comp_id, uint16_t msg_type,
std::shared_ptr<google::protobuf::Message> msg);
private:
CLIPS::Environment *clips_;
fawkes::Mutex &clips_mutex_;
protobuf_comm::MessageRegister *message_register_;
protobuf_comm::ProtobufStreamServer *server_;
protobuf_comm::ProtobufBroadcastPeer *peer_;
fawkes::Mutex map_mutex_;
long int next_client_id_;
std::map<long int, protobuf_comm::ProtobufStreamServer::ClientID> server_clients_;
typedef std::map<protobuf_comm::ProtobufStreamServer::ClientID, long int> RevServerClientMap;
RevServerClientMap rev_server_clients_;
std::map<long int, protobuf_comm::ProtobufStreamClient *> clients_;
std::map<long int, std::pair<std::string, unsigned short>> client_endpoints_;
std::map<long int, CLIPS::Fact::pointer> msg_facts_;
std::list<std::string> functions_;
CLIPS::Fact::pointer avail_fact_;
};
} // end namespace protobuf_clips
#endif
|
[
"niemueller@kbsg.rwth-aachen.de"
] |
niemueller@kbsg.rwth-aachen.de
|
55db20c9772d0d6fdd6368d0c5595dc450fd3fa2
|
29619c1b1ee216fd40f6c13b1cb4612cc6ef79e5
|
/658_B.cpp
|
a6ccee39805a9ccfcff84b5e35871141cb343ee9
|
[] |
no_license
|
sacsachin/programing
|
9527c4340522159423120d203152c37dcf9f8931
|
377b25c317e3972d63ead7a34397458702f8accf
|
refs/heads/master
| 2022-12-14T00:20:35.232816
| 2020-09-26T12:36:32
| 2020-09-26T12:36:32
| 298,810,542
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 674
|
cpp
|
/*
* https://codeforces.com/contest/1382/problem/B
* Sequential Nim.
*/
# include<iostream>
# include<vector>
void solve(std::vector<int>& a)
{
bool first = true;
for(int i = 0; i < a.size()-1; i++)
{
if(a[i] == 1) first = not first;
else break;
}
if(first) std::cout<<"First"<<std::endl;
else std::cout<<"Second"<<std::endl;
return;
}
int main()
{
int t, n;
std::cin>>t;
while(t--)
{
std::cin>>n;
std::vector<int> a(n);
int val, index = 0;
while(n--)
{
std::cin>>val;
a[index++] = val;
}
solve(a);
}
return 0;
}
|
[
"psachin@zeomega.com"
] |
psachin@zeomega.com
|
6e11a1e5f86d6e9c0520731af7564b53bf83c3a1
|
961efcb19a847ae7c1493cae43f61a1788e96c8f
|
/Voyage/Universe.cpp
|
f71f13d66f997fd5ba509e8547a72433e0e539d2
|
[] |
no_license
|
CPPoder/Voyage
|
b7b98799cd6b6ed041c311c176b67c857e7f64fa
|
847fc8cff72256676909ab9e6680e53fb1075a3b
|
refs/heads/master
| 2021-10-17T03:15:30.816083
| 2019-02-13T14:05:34
| 2019-02-13T14:05:34
| 62,450,367
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 30,748
|
cpp
|
#include "stdafx.h"
#include "Universe.hpp"
//Constructor
Universe::Universe(sf::View *globalView, sf::View *playerView, bool *showPlayerView, sf::Font *font, sf::Texture *playerTexture)
: pGlobalView(globalView),
pPlayerView(playerView),
pShowPlayerView(showPlayerView),
pFont(font),
pPlayerTexture(playerTexture)
{
pTextTimeFactor = new sf::Text("", *pFont, 20);
pTextActualTimeFactor = new sf::Text("", *pFont, 20);
pTextWindowSize = new sf::Text("", *pFont, 20);
pTextFramesPerSecond = new sf::Text("", *pFont, 20);
pPlayer = new Player(1.0E06, 1.0, sf::Vector2<double>(1.0E07, 0.0), sf::Vector2<double>(0.0, 0.0), 0.0, 10.0, pPlayerTexture);
//mVectorOfPlanets.push_back(new Planet(1.988E30 * 1.0E05, 1.408E03, sf::Vector2<double>(-1.496E11, 0.0), sf::Vector2<double>(0.0, 0.0), sf::Color::Yellow, createPlanetNumber()));
mVectorOfPlanets.push_back(new Planet(5.974E24/* * 1.0E05*/, 5.515E03, sf::Vector2<double>(0.0, 0.0), sf::Vector2<double>(0.0, 0.0), sf::Color::Blue));
mVectorOfPlanets.push_back(new Planet(7.349E22/* * 1.0E05*/, 3.341E03, sf::Vector2<double>(3.844E08, 0.0), 0.0 * sf::Vector2<double>(0.0, 1.023E03), sf::Color(120, 120, 120)));
//Create Planets 1
/*
unsigned int numberOfPlanets = 10;
for (unsigned int i = 0; i < numberOfPlanets; i++)
{
//mVectorOfPlanets.push_back(new Planet(1000000000.f, sf::Vector2f(720.f, 450.f) + mySFML::randNormalVector() * 120.f, mySFML::randNormalVector() * 0.1f));
mVectorOfPlanets.push_back(new Planet(1.0E24, 4.0E03, static_cast<sf::Vector2<double>>(mySFML::createNormalVectorWithAngle(i * 2 * 3.141592653f / numberOfPlanets) * 10000000.f), static_cast<sf::Vector2<double>>(mySFML::randNormalVector() * 10000.f) * 0.0, sf::Color::White));
}
*/
//Create Planets 2
unsigned int numberOfPlanets = 100;
for (unsigned int i = 0; i < numberOfPlanets; i++)
{
sf::Vector2<double> planetPos = static_cast<sf::Vector2<double>>(mySFML::createNormalVectorWithAngle(i * 2 * 3.141592653f / numberOfPlanets) * (100000000.f + 10000.f * myMath::randIntervalf(0, 1000)));
//sf::Vector2<double> planetVel = static_cast<sf::Vector2<double>>(mySFML::randNormalVector() * 10000.f) * 0.0;
sf::Vector2<double> planetVel = /*(static_cast<double>(myMath::randIntervali(1, 2)) - 1.5) * 2.0 * */mySFML::createOrthogonalVector(mySFML::normalize(planetPos)) * 2400.0;
sf::Color color = sf::Color(myMath::randIntervali(0, 255), myMath::randIntervali(0, 255), myMath::randIntervali(0, 255));
double mass = 1.0E23 * myMath::randIntervali(100, 1000) / 1000.0;
mVectorOfPlanets.push_back(new Planet(mass, 4.0E03, planetPos, planetVel, color));
}
}
//Destructor
Universe::~Universe()
{
delete pTextTimeFactor;
pTextTimeFactor = nullptr;
delete pTextActualTimeFactor;
pTextActualTimeFactor = nullptr;
delete pTextFramesPerSecond;
pTextFramesPerSecond = nullptr;
for (auto planet : mVectorOfPlanets)
{
delete planet;
planet = nullptr;
}
}
//Update
void Universe::update(sf::RenderWindow *renderWindow, sf::Time frametime)
{
//Choose Frametime or Fixed Time, depending on the Mode
sf::Time usedTime;
if (mFixedEvolveTimeMode)
{
usedTime = mFixedEvolveTime;
}
else
{
usedTime = frametime;
}
//User Input: Change Time Factor & Movements
changeTimeFactor(usedTime);
updateControlOfPlayer();
//Determine several Forces
determineGravityBetweenPlanets();
//determineElasticForcesBetweenPlanets();
//determineFriction();
determineGravityForPlayer();
//Update Actual Time Factor
updateActualTimeFactor();
//Evolve the Simulation
evolveSimulation(renderWindow, usedTime * actualTimeFactor);
//Manage Collisions
manageCollisions(renderWindow, usedTime);
//Fusion of planets
manageFusions(usedTime * actualTimeFactor);
normalizeDensities();
//Update Render-Things
updateView(renderWindow, frametime);
updateTexts(renderWindow, frametime);
//Measure the energy
determineEnergy();
}
//Handle Events
void Universe::handleEvents(EventData eventData)
{
for (auto planet : mVectorOfPlanets)
{
planet->handleEvents(eventData);
}
}
//Render
void Universe::render(sf::RenderWindow *renderWindow)
{
for (auto planet : mVectorOfPlanets)
{
planet->render(renderWindow);
}
pPlayer->render(renderWindow);
renderWindow->draw(*pTextTimeFactor);
renderWindow->draw(*pTextActualTimeFactor);
renderWindow->draw(*pTextWindowSize);
renderWindow->draw(*pTextFramesPerSecond);
}
///////////////////
//Private Functions
//Change Time Factor
void Universe::changeTimeFactor(sf::Time frametime)
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Add))
{
timeFactor = timeFactor * pow(10.f, frametime.asSeconds());
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Subtract))
{
timeFactor = timeFactor / pow(10.f, frametime.asSeconds());
}
}
//Determine Gravity Between Planets
void Universe::determineGravityBetweenPlanets()
{
for (auto planet : mVectorOfPlanets)
{
float planetMass = planet->getMass();
sf::Vector2<double> planetPos = planet->getPosition();
planet->resetForces();
for (auto gravitatingPlanet : mVectorOfPlanets)
{
if (gravitatingPlanet == planet)
{
continue;
}
sf::Vector2<double> distVec = gravitatingPlanet->getPosition() - planetPos;
double distance = mySFML::lengthOf(distVec);
if (distance != 0.0)
{
planet->addForce(G * planetMass * gravitatingPlanet->getMass() / distance / distance / distance * distVec);
}
}
}
}
//Determine Elastic Forces between Planets
void Universe::determineElasticForcesBetweenPlanets()
{
float elasticity = 1.0E19;
for (std::vector<Planet*>::iterator planetIt1 = mVectorOfPlanets.begin(); planetIt1 != mVectorOfPlanets.end(); planetIt1++)
{
sf::Vector2<double> planet1Pos = (*planetIt1)->getPosition();
double planet1Rad = (*planetIt1)->getRadius();
for (std::vector<Planet*>::iterator planetIt2 = planetIt1; planetIt2 != mVectorOfPlanets.end(); planetIt2++)
{
if (planetIt1 == planetIt2)
{
continue;
}
sf::Vector2<double> distanceVector = planet1Pos - (*planetIt2)->getPosition();
sf::Vector2<double> unitVector = mySFML::normalize(distanceVector);
double distance = mySFML::lengthOf(distanceVector);
double sumOfRadii = planet1Rad + (*planetIt2)->getRadius();
if (distance < sumOfRadii)
{
double elasticForce = elasticity * (sumOfRadii - distance);
(*planetIt1)->addForce(elasticForce * unitVector);
(*planetIt2)->addForce(-elasticForce * unitVector);
}
}
}
}
//Determine Friction
void Universe::determineFriction()
{
double frictionCoefficient = 1.0E15;
for (auto planet : mVectorOfPlanets)
{
sf::Vector2<double> velocity = planet->getVelocity();
double velValue = mySFML::lengthOf(velocity);
planet->addForce(-mySFML::normalize(velocity) * frictionCoefficient * velValue * velValue);
}
}
//Determine Gravity for the Player
void Universe::determineGravityForPlayer()
{
sf::Vector2<double> playerPos = pPlayer->getPosition();
double playerMass = pPlayer->getMass();
for (auto gravitatingPlanet : mVectorOfPlanets)
{
sf::Vector2<double> distVec = gravitatingPlanet->getPosition() - playerPos;
double distance = mySFML::lengthOf(distVec);
if (distance != 0.0)
{
pPlayer->addForce(G * playerMass * gravitatingPlanet->getMass() / distance / distance / distance * distVec);
}
}
}
//Update the Actual Time Factor
void Universe::updateActualTimeFactor()
{
double biggestAcceleration = 0.0;
for (auto planet : mVectorOfPlanets)
{
double acceleration = mySFML::lengthOf(planet->getForces()) / planet->getMass();
if (acceleration > biggestAcceleration)
{
biggestAcceleration = acceleration;
}
}
float const timeFactorConstant = 4.0E07;
float maximalAllowedTimeFactor = timeFactorConstant / biggestAcceleration;
actualTimeFactor = myMath::min(maximalAllowedTimeFactor, timeFactor);
mEqualTimeFactors = (timeFactor == actualTimeFactor);
}
//Manage Collisions
void Universe::manageCollisions(sf::RenderWindow *renderWindow, sf::Time time)
{
sf::Time timeStepOfLastEvolution = actualTimeFactor * time;
bool collisionOccured = true;
unsigned int const numberOfCollisionFixAttempts = 50;
unsigned int counterOfCollisionFixAttempts = 0;
bool infiniteNumberOfFixAttempts = true;
while (collisionOccured && ((counterOfCollisionFixAttempts < numberOfCollisionFixAttempts) || infiniteNumberOfFixAttempts)) //Repeat till no collisions occurr anymore
{
counterOfCollisionFixAttempts++;
collisionOccured = false;
for (auto planetIt1 = mVectorOfPlanets.begin(); planetIt1 != mVectorOfPlanets.end(); planetIt1++)
{
double planet1Mass = (*planetIt1)->getMass();
double planet1Rad = (*planetIt1)->getRadius();
for (auto planetIt2 = planetIt1; planetIt2 != mVectorOfPlanets.end(); planetIt2++)
{
sf::Vector2<double> planet1Pos = (*planetIt1)->getPosition();
//sf::Vector2<double> planet1LastPos = (*planetIt1)->getLastPosition();
sf::Vector2<double> planet1Velocity = (*planetIt1)->getVelocity();
sf::Vector2<double> planet1LastPos = planet1Pos - (static_cast<double>(timeStepOfLastEvolution.asSeconds()) * planet1Velocity);
double planet2Mass = (*planetIt2)->getMass();
double planet2Rad = (*planetIt2)->getRadius();
sf::Vector2<double> planet2Pos = (*planetIt2)->getPosition();
//sf::Vector2<double> planet2LastPos = (*planetIt2)->getLastPosition();
sf::Vector2<double> planet2Velocity = (*planetIt2)->getVelocity();
sf::Vector2<double> planet2LastPos = planet2Pos - (static_cast<double>(timeStepOfLastEvolution.asSeconds()) * planet2Velocity);
if (planetIt1 == planetIt2)
{
continue;
}
sf::Vector2<double> distVector = planet1Pos - planet2Pos;
double distance = mySFML::lengthOf(distVector); //This is a source of errors, because planets that overlap alternated after one evolution are very near
sf::Vector2<double> relativeVelocity = planet1Velocity - planet2Velocity;
double velocityProjectedOnDistance = mySFML::scalarProduct(distVector, relativeVelocity);
bool comingCloser = (velocityProjectedOnDistance < 0);
double sumOfRadii = planet1Rad + planet2Rad;
if (distance <= (planet1Rad + planet2Rad) && comingCloser)
{
//std::cout << "Collision " << mDebugCounter << "!" << std::endl;
//mySFML::outputOnTerminal((*planetIt1)->getPosition(), "Pos1: ", "\t");
//mySFML::outputOnTerminal((*planetIt2)->getPosition(), "Pos2: ", "\t");
mDebugCounter++;
collisionOccured = true;
//Determine time since collision
sf::Vector2<double> lastDistance = planet1LastPos - planet2LastPos;
double lastDistanceValue = mySFML::lengthOf(lastDistance);
double relativeVelocityValue = mySFML::lengthOf(relativeVelocity);
double scalarProd = mySFML::scalarProduct(lastDistance, relativeVelocity);
sf::Time timeBetweenLastEvolutionAndCollision = -sf::seconds((scalarProd + sqrt(scalarProd * scalarProd + relativeVelocityValue * relativeVelocityValue * (sumOfRadii * sumOfRadii - lastDistanceValue * lastDistanceValue))) / (relativeVelocityValue * relativeVelocityValue)); //Big Error due to circle problem
//sf::Time timeBetweenLastEvolutionAndCollision = sf::seconds(0.f);
/*
std::cout << "------------------------------------------------" << std::endl;
std::cout << "relativeVelocityValue: " << relativeVelocityValue << std::endl;
std::cout << "distance: " << (distance - sumOfRadii) << std::endl;
std::cout << "timeStepOfLastEvolution: " << timeStepOfLastEvolution.asSeconds() << "\t" << "timeBetweenLastEvolutionAndCollision: " << timeBetweenLastEvolutionAndCollision.asSeconds() << std::endl;
*/
sf::Time timeSinceCollision = timeStepOfLastEvolution - timeBetweenLastEvolutionAndCollision;
//Evolve backwards in time till collision
evolveSimulation(renderWindow, -timeSinceCollision);
//Execute collision algorithm
sf::Vector2<double> rHat = mySFML::normalize(distVector);
sf::Vector2<double> nHat = mySFML::createOrthogonalVector(rHat);
double v1Para = mySFML::scalarProduct(planet1Velocity, rHat);
double v1Orth = mySFML::scalarProduct(planet1Velocity, nHat);
double v2Para = mySFML::scalarProduct(planet2Velocity, rHat);
double v2Orth = mySFML::scalarProduct(planet2Velocity, nHat);
//double v1ParaPrime = (planet1Mass - planet2Mass) / (planet1Mass + planet2Mass) * v1Para;
double v1ParaPrime = (2 * ((planet1Mass * v1Para) + (planet2Mass * v2Para)) / (planet1Mass + planet2Mass)) - v1Para;
double v1OrthPrime = v1Orth;
//double v2ParaPrime = (planet2Mass - planet1Mass) / (planet2Mass + planet1Mass) * v2Para;
double v2ParaPrime = (2 * ((planet1Mass * v1Para) + (planet2Mass * v2Para)) / (planet1Mass + planet2Mass)) - v2Para;
double v2OrthPrime = v2Orth;
sf::Vector2<double> v1Prime = (v1ParaPrime * rHat) + (v1OrthPrime * nHat);
sf::Vector2<double> v2Prime = (v2ParaPrime * rHat) + (v2OrthPrime * nHat);
//Friction during collision
//Determine Momentum Transfer
sf::Vector2<double> momentumTransfer = (v1Prime - planet1Velocity) * planet1Mass;
double momentumTransferValue = mySFML::lengthOf(momentumTransfer);
//Loss of momentum proportional to momentum transfer
double const inelasticCollisionConstant = 0.15;
double momentumLossValue = inelasticCollisionConstant * momentumTransferValue;
sf::Vector2<double> momentumLoss1 = -momentumLossValue * mySFML::normalize(v1Prime);
sf::Vector2<double> momentumLoss2 = -momentumLossValue * mySFML::normalize(v2Prime);
(*planetIt1)->setVelocity(v1Prime + (momentumLoss1 / planet1Mass));
(*planetIt2)->setVelocity(v2Prime + (momentumLoss2 / planet2Mass));
double energyLoss1;
double energyLoss2;
//Evolve forwards in time till origin
evolveSimulation(renderWindow, timeSinceCollision);
//Color mixing
(*planetIt1)->setColor(mySFML::mixColors((*planetIt1)->getColor(), (*planetIt2)->getColor(), 0.7, 0.3));
(*planetIt2)->setColor(mySFML::mixColors((*planetIt1)->getColor(), (*planetIt2)->getColor(), 0.3, 0.7));
}
}
}
}
if (counterOfCollisionFixAttempts != 1)
{
//std::cout << "Number of Fix Attempts: " << counterOfCollisionFixAttempts << std::endl;
}
}
//Manage the Fusion of Planets
void Universe::manageFusions(sf::Time time)
{
//Check for near planets
unsigned int sizeOfVectorOfPlanets = mVectorOfPlanets.size();
for (unsigned int planNum1 = 0; planNum1 < sizeOfVectorOfPlanets; planNum1++)
{
sf::Vector2<double> plan1Pos = mVectorOfPlanets.at(planNum1)->getPosition();
double plan1Rad = mVectorOfPlanets.at(planNum1)->getRadius();
unsigned int plan1UniqueNum = mVectorOfPlanets.at(planNum1)->getPlanetNumber();
for (unsigned int planNum2 = (planNum1 + 1); planNum2 < sizeOfVectorOfPlanets; planNum2++)
{
sf::Vector2<double> plan2Pos = mVectorOfPlanets.at(planNum2)->getPosition();
double plan2Rad = mVectorOfPlanets.at(planNum2)->getRadius();
unsigned int plan2UniqueNum = mVectorOfPlanets.at(planNum2)->getPlanetNumber();
double distance = mySFML::lengthOf(plan1Pos - plan2Pos);
double fusionDistance = plan1Rad + plan2Rad + 0.05 * myMath::min(plan1Rad, plan2Rad);
sf::Vector2u vectorOfTwoNearPlanets = sf::Vector2u(myMath::min(plan1UniqueNum, plan2UniqueNum), myMath::max(plan1UniqueNum, plan2UniqueNum));
if (distance < fusionDistance)
{
//Search in mListOfNearPlanetsTimePairs for existing Pair and add time or Pair in case
bool pairAlreadyExists = false;
for (std::list<std::pair<sf::Vector2u, sf::Time>>::iterator nearPairListIt = mListOfNearPlanetsTimePairs.begin(); nearPairListIt != mListOfNearPlanetsTimePairs.end(); nearPairListIt++)
{
if ((*nearPairListIt).first == vectorOfTwoNearPlanets)
{
pairAlreadyExists = true;
(*nearPairListIt).second = (*nearPairListIt).second + time;
break;
}
}
if (!pairAlreadyExists)
{
mListOfNearPlanetsTimePairs.push_back(std::pair<sf::Vector2u, sf::Time>(vectorOfTwoNearPlanets, time));
}
}
else
{
//Search in mListOfNearPlanetsTimePairs for existing Pair and delete in case
for (std::list<std::pair<sf::Vector2u, sf::Time>>::iterator nearPairListIt = mListOfNearPlanetsTimePairs.begin(); nearPairListIt != mListOfNearPlanetsTimePairs.end(); )
{
if ((*nearPairListIt).first == vectorOfTwoNearPlanets)
{
nearPairListIt = mListOfNearPlanetsTimePairs.erase(nearPairListIt);
break;
}
else
{
nearPairListIt++;
}
}
}
}
}
//Merge two planets if a critical time is passed
sf::Time const mergeTimeConstant = sf::seconds(600.f);
while (true) //Repeat till no merges occur anymore!
{
bool planetsAreMerged = false;
for (std::list<std::pair<sf::Vector2u, sf::Time>>::iterator nearPairListIt = mListOfNearPlanetsTimePairs.begin(); nearPairListIt != mListOfNearPlanetsTimePairs.end(); )
{
planetsAreMerged = false;
Planet *newPlanetPointer = nullptr;
unsigned int planet1UniqueNum;
unsigned int planet2UniqueNum;
if ((*nearPairListIt).second > mergeTimeConstant)
{
//Create a new Planet and delete the old ones
planetsAreMerged = true;
planet1UniqueNum = (*nearPairListIt).first.x;
planet2UniqueNum = (*nearPairListIt).first.y;
Planet *planet1UnsafePointer = nullptr;
Planet *planet2UnsafePointer = nullptr;
unsigned int sizeOfPlanetVector = mVectorOfPlanets.size();
for (unsigned int planNum = 0; planNum < sizeOfPlanetVector; planNum++)
{
if (mVectorOfPlanets.at(planNum)->getPlanetNumber() == planet1UniqueNum)
{
planet1UnsafePointer = mVectorOfPlanets.at(planNum);
}
if (mVectorOfPlanets.at(planNum)->getPlanetNumber() == planet2UniqueNum)
{
planet2UnsafePointer = mVectorOfPlanets.at(planNum);
}
}
double plan1Mass = planet1UnsafePointer->getMass();
double plan2Mass = planet2UnsafePointer->getMass();
double plan1Density = planet1UnsafePointer->getDensity();
double plan2Density = planet2UnsafePointer->getDensity();
double plan1Vol = planet1UnsafePointer->getVolume();
double plan2Vol = planet2UnsafePointer->getVolume();
sf::Vector2<double> plan1Pos = planet1UnsafePointer->getPosition();
sf::Vector2<double> plan2Pos = planet2UnsafePointer->getPosition();
sf::Vector2<double> plan1Vel = planet1UnsafePointer->getVelocity();
sf::Vector2<double> plan2Vel = planet2UnsafePointer->getVelocity();
sf::Color plan1Color = planet1UnsafePointer->getColor();
sf::Color plan2Color = planet2UnsafePointer->getColor();
double newMass = plan1Mass + plan2Mass;
double newIntendedDensity = newMass / (plan1Vol + plan2Vol);
sf::Vector2<double> newPosition = (plan1Mass / newMass) * plan1Pos + (plan2Mass / newMass) * plan2Pos;
sf::Vector2<double> newVelocity = (plan1Mass / newMass) * plan1Vel + (plan2Mass / newMass) * plan2Vel;
double newTemperature; //Determine EnergyLoss and mix of old temperatures
sf::Color newColor = mySFML::mixColors(plan1Color, plan2Color, (plan1Mass / newMass), (plan2Mass / newMass));
//Calculate newDensity such that no collisions happen!
unsigned int size = mVectorOfPlanets.size();
double minimalDistance;
bool minimalDistanceValid = false;
for (unsigned int planNum = 0; planNum < size; planNum++)
{
Planet *planetPointer = mVectorOfPlanets.at(planNum);
if ((planetPointer == planet1UnsafePointer) || (planetPointer == planet2UnsafePointer))
{
continue;
}
double dist = myMath::abs(mySFML::lengthOf(planetPointer->getPosition() - newPosition) - planetPointer->getRadius());
if (minimalDistanceValid)
{
if (dist < minimalDistance)
{
minimalDistance = dist;
}
}
else
{
minimalDistance = dist;
minimalDistanceValid = true;
}
}
double newDensity;
if (minimalDistanceValid)
{
newDensity = newMass / (4.0 / 3.0 * 3.141592653 * minimalDistance * minimalDistance * minimalDistance) * 2.0; //Factor 2.0 is only security!!!
}
else
{
newDensity = newIntendedDensity;
}
double usedNewDensity;
bool wrongDensityUsed;
if (newDensity > newIntendedDensity)
{
usedNewDensity = newDensity;
wrongDensityUsed = true;
}
else
{
usedNewDensity = newIntendedDensity;
wrongDensityUsed = false;
}
newPlanetPointer = new Planet(newMass, usedNewDensity, newPosition, newVelocity, newColor, newIntendedDensity);
mVectorOfPlanets.push_back(newPlanetPointer);
mListOfPlanetNumbersWithWrongDensity.push_back(newPlanetPointer->getPlanetNumber());
delete planet1UnsafePointer;
delete planet2UnsafePointer;
planet1UnsafePointer = nullptr;
planet2UnsafePointer = nullptr;
for (std::vector<Planet*>::iterator planIt = mVectorOfPlanets.begin(); planIt != mVectorOfPlanets.end(); )
{
if (((*planIt)->getPlanetNumber() == planet1UniqueNum) || ((*planIt)->getPlanetNumber() == planet2UniqueNum))
{
planIt = mVectorOfPlanets.erase(planIt);
}
else
{
planIt++;
}
}
nearPairListIt = mListOfNearPlanetsTimePairs.erase(nearPairListIt);
}
else
{
nearPairListIt++;
}
if (planetsAreMerged)
{
//Check if mListOfNearPlanetsTimePairs still contains the deleted planetNumbers and handle case
unsigned int newPlanetUniqueNumber = newPlanetPointer->getPlanetNumber();
for (auto pair : mListOfNearPlanetsTimePairs)
{
if ((pair.first.x == planet1UniqueNum) || (pair.first.x == planet2UniqueNum))
{
pair.first.x = newPlanetUniqueNumber;
}
if ((pair.first.y == planet1UniqueNum) || (pair.first.y == planet2UniqueNum))
{
pair.first.y = newPlanetUniqueNumber;
}
}
}
}
//Exit if no planets are merged anymore
if (!planetsAreMerged)
{
break;
}
}
}
//Normalize Densities
void Universe::normalizeDensities()
{
unsigned int planVecSize = mVectorOfPlanets.size();
for (std::list<unsigned int>::iterator wrongDensityPlanetsIt = mListOfPlanetNumbersWithWrongDensity.begin(); wrongDensityPlanetsIt != mListOfPlanetNumbersWithWrongDensity.end(); )
{
//Does Planet still exist?
unsigned int uniquePlanNum = (*wrongDensityPlanetsIt);
bool planetExists = false;
Planet *planetPointer = nullptr;
for (unsigned int planNum = 0; planNum < planVecSize; planNum++)
{
if (mVectorOfPlanets.at(planNum)->getPlanetNumber() == uniquePlanNum)
{
planetExists = true;
planetPointer = mVectorOfPlanets.at(planNum);
break;
}
}
//If Planet exists, normalize Density; Else: Erase Number From List
if (planetExists) //Normalize Density
{
double planRad = planetPointer->getRadius();
sf::Vector2<double> planPos = planetPointer->getPosition();
double planMass = planetPointer->getMass();
double planDensity = planetPointer->getDensity();
double planIntendedDensity = planetPointer->getIntendedDensity();
double distanceMinusRadius;
bool distanceMinusRadiusValid = false;
for (unsigned int planNum = 0; planNum < planVecSize; planNum++)
{
Planet *otherPlanetPointer = mVectorOfPlanets.at(planNum);
if (uniquePlanNum == otherPlanetPointer->getPlanetNumber())
{
continue;
}
double otherPlanRad = otherPlanetPointer->getRadius();
sf::Vector2<double> otherPlanPos = otherPlanetPointer->getPosition();
double distance = myMath::abs(mySFML::lengthOf(planPos - otherPlanPos) - otherPlanRad);
if (distanceMinusRadiusValid)
{
distanceMinusRadius = myMath::min(distance, distanceMinusRadius);
}
else
{
distanceMinusRadius = distance;
distanceMinusRadiusValid = true;
}
}
double newPossibleDensity = planMass / (4.0 / 3.0 * 3.141592653 * distanceMinusRadius * distanceMinusRadius * distanceMinusRadius) * 1.01; //1.01: Security Factor
double newDensity;
bool maximalRadiusAchieved;
if (newPossibleDensity > planIntendedDensity)
{
newDensity = newPossibleDensity;
maximalRadiusAchieved = false;
}
else
{
newDensity = planIntendedDensity;
maximalRadiusAchieved = true;
}
planetPointer->setDensity(newDensity);
if (maximalRadiusAchieved)
{
wrongDensityPlanetsIt = mListOfPlanetNumbersWithWrongDensity.erase(wrongDensityPlanetsIt);
}
else
{
wrongDensityPlanetsIt++;
}
}
else //Erase Number From the List
{
wrongDensityPlanetsIt = mListOfPlanetNumbersWithWrongDensity.erase(wrongDensityPlanetsIt);
}
}
}
//Update the Control of the Player (User Input)
void Universe::updateControlOfPlayer()
{
pPlayer->resetForces();
pPlayer->resetTorsionalMoments();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W))
{
pPlayer->addForce(pPlayer->getOrientation() * 200000000.0);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D))
{
pPlayer->addTorsionalMoment(40.0);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A))
{
pPlayer->addTorsionalMoment(-40.0);
}
}
//Update View
void Universe::updateView(sf::RenderWindow *renderWindow, sf::Time frametime)
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::H))
{
pGlobalView->zoom(pow(10.f, frametime.asSeconds()));
mViewAutoZoom = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Z))
{
pGlobalView->zoom(1.f / pow(10.f, frametime.asSeconds()));
mViewAutoZoom = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up))
{
pGlobalView->move(sf::Vector2f(0.f, -1.f) * pGlobalView->getSize().y * frametime.asSeconds());
mViewAutoPosition = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down))
{
pGlobalView->move(sf::Vector2f(0.f, 1.f) * pGlobalView->getSize().y * frametime.asSeconds());
mViewAutoPosition = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Left))
{
pGlobalView->move(sf::Vector2f(-1.f, 0.f) * pGlobalView->getSize().y * frametime.asSeconds());
mViewAutoPosition = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Right))
{
pGlobalView->move(sf::Vector2f(1.f, 0.f) * pGlobalView->getSize().y * frametime.asSeconds());
mViewAutoPosition = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Return)) //Enter
{
mViewAutoZoom = true;
mViewAutoPosition = true;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Period)) //.
{
mViewAutoZoom = true;
mViewAutoPosition = true;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Comma)) //,
{
mViewAutoZoom = true;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Space))
{
*pShowPlayerView = !(*pShowPlayerView);
}
if (*pShowPlayerView)
{
sf::Vector2i pixelPositionOfPlayer = renderWindow->mapCoordsToPixel(static_cast<sf::Vector2f>(pPlayer->getPosition()));
sf::Vector2f ratioOfPixelPosAndWindowSize = sf::Vector2f(static_cast<float>(pixelPositionOfPlayer.x) / renderWindow->getSize().x, static_cast<float>(pixelPositionOfPlayer.y) / renderWindow->getSize().y);
pPlayerView->setViewport(sf::FloatRect(ratioOfPixelPosAndWindowSize.x, ratioOfPixelPosAndWindowSize.y, 0.1, 0.1));
pPlayerView->setCenter(static_cast<sf::Vector2f>(pPlayer->getPosition()));
float autoViewSize = static_cast<float>(pPlayer->getTextureSize().x * pPlayer->getSpriteScale().x) * 5.f;
pPlayerView->setSize(sf::Vector2f(autoViewSize, autoViewSize * pGlobalView->getSize().y / pGlobalView->getSize().x));
}
if (mViewAutoZoom)
{
*pShowPlayerView = false;
float autoViewSize = static_cast<float>(pPlayer->getTextureSize().x * pPlayer->getSpriteScale().x) * 5.f;
*pGlobalView = sf::View(pGlobalView->getCenter(), sf::Vector2f(autoViewSize, autoViewSize * pGlobalView->getSize().y / pGlobalView->getSize().x));
}
if (mViewAutoPosition)
{
*pGlobalView = sf::View(static_cast<sf::Vector2f>(pPlayer->getPosition()), pGlobalView->getSize());
}
//pGlobalView->setViewport(sf::FloatRect(0.25, 0.25, 0.5, 0.5));
}
//Update Texts
void Universe::updateTexts(sf::RenderWindow *renderWindow, sf::Time frametime)
{
float scale = pGlobalView->getSize().x / static_cast<float>(renderWindow->getSize().x);
pTextTimeFactor->setString("Time Factor: " + std::to_string(timeFactor));
pTextTimeFactor->setScale(scale, scale);
pTextTimeFactor->setPosition(renderWindow->mapPixelToCoords(sf::Vector2i(7, 4)));
pTextActualTimeFactor->setString("Actual Time Factor: " + std::to_string(actualTimeFactor));
pTextActualTimeFactor->setScale(scale, scale);
pTextActualTimeFactor->setPosition(renderWindow->mapPixelToCoords(sf::Vector2i(7, 29)));
if (mEqualTimeFactors)
{
pTextActualTimeFactor->setColor(sf::Color::White);
}
else
{
pTextActualTimeFactor->setColor(sf::Color::Red);
}
pTextWindowSize->setString("Window Size: " + std::to_string(pGlobalView->getSize().x / 1000.f) + " km");
pTextWindowSize->setScale(scale, scale);
pTextWindowSize->setPosition(renderWindow->mapPixelToCoords(sf::Vector2i(7, 54)));
pTextFramesPerSecond->setString("Frames per Second: " + std::to_string(1.f / frametime.asSeconds()));
pTextFramesPerSecond->setScale(scale, scale);
pTextFramesPerSecond->setPosition(renderWindow->mapPixelToCoords(sf::Vector2i(7, 79)));
}
//Evolve Simulation
void Universe::evolveSimulation(sf::RenderWindow *renderWindow, sf::Time time)
{
//std::cout << time.asMilliseconds() << std::endl;
for (auto planet : mVectorOfPlanets)
{
planet->update(renderWindow, time);
}
pPlayer->update(renderWindow, time);
}
//Determine Energy
void Universe::determineEnergy()
{
double energy = 0.0;
unsigned int sizeOfVector = mVectorOfPlanets.size();
for (unsigned int planetNumber1 = 0; planetNumber1 < sizeOfVector; planetNumber1++)
{
//Kinetic Energy
double planet1Mass = mVectorOfPlanets.at(planetNumber1)->getMass();
double planet1VelVal = mySFML::lengthOf(mVectorOfPlanets.at(planetNumber1)->getVelocity());
sf::Vector2<double> planet1Pos = mVectorOfPlanets.at(planetNumber1)->getPosition();
energy = energy + (planet1Mass / 2.0 * planet1VelVal * planet1VelVal);
//Potential Energy
for (unsigned int planetNumber2 = 0; planetNumber2 < sizeOfVector; planetNumber2++)
{
if (planetNumber1 == planetNumber2)
{
continue;
}
double planet2Mass = mVectorOfPlanets.at(planetNumber2)->getMass();
sf::Vector2<double> planet2Pos = mVectorOfPlanets.at(planetNumber2)->getPosition();
energy = energy - (G * planet1Mass * planet2Mass / mySFML::lengthOf(planet2Pos - planet1Pos));
}
}
//std::cout << "Energy: " << energy << std::endl;
if (mEnergiesValid)
{
mLastEnergy = mActualEnergy;
mActualEnergy = energy;
if ((mActualEnergy - mLastEnergy) > 1.0E29)
{
std::cout << "Error!!!" << std::endl;
}
}
else
{
mActualEnergy = energy;
mLastEnergy = energy;
mEnergiesValid = true;
}
}
|
[
"udo.beier@onlinehome.de"
] |
udo.beier@onlinehome.de
|
d04826dfa515e0da2c8dae645bd5b7b6052c3230
|
4c7eafc4f4bccb2fc88d0abad18c6e68e15fd1c1
|
/include/x86/decoder.h
|
43004756c83f24e2a13c6949dc71e6fcfc564e18
|
[
"BSD-2-Clause"
] |
permissive
|
00mjk/riscv-dbt
|
56c95d37b02c1cf882ea62a6668c01c6a33e011f
|
6220323b8d17cc2b873c97343a3f7a73ccec2d4b
|
refs/heads/master
| 2021-10-25T04:24:40.766190
| 2019-03-31T23:55:55
| 2019-03-31T23:55:55
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 556
|
h
|
#ifndef X86_DECODER_H
#define X86_DECODER_H
#include "x86/instruction.h"
namespace x86 {
class Decoder {
uint64_t _pc;
int _rex;
int _opsize;
public:
Decoder(): _pc{0} {}
Decoder(uint64_t pc): _pc{pc} {}
uint64_t pc() const { return _pc; }
void pc(uint64_t pc) { _pc = pc; }
private:
uint8_t read_byte();
uint32_t read_dword();
Register register_of_size(int reg, int size);
void decode_modrm(Operand& operand, Register& reg, int size);
public:
Instruction decode_instruction();
};
} // x86
#endif
|
[
"gary@garyguo.net"
] |
gary@garyguo.net
|
a09b1341570e1ac20b1c3c578d4e6368a152f3a4
|
c51febc209233a9160f41913d895415704d2391f
|
/library/ATF/tagEXTLOGPEN.hpp
|
6fbbddc05100ffc37e7150e7b57f3b0fa02230f0
|
[
"MIT"
] |
permissive
|
roussukke/Yorozuya
|
81f81e5e759ecae02c793e65d6c3acc504091bc3
|
d9a44592b0714da1aebf492b64fdcb3fa072afe5
|
refs/heads/master
| 2023-07-08T03:23:00.584855
| 2023-06-29T08:20:25
| 2023-06-29T08:20:25
| 463,330,454
| 0
| 0
|
MIT
| 2022-02-24T23:15:01
| 2022-02-24T23:15:00
| null |
UTF-8
|
C++
| false
| false
| 469
|
hpp
|
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
START_ATF_NAMESPACE
struct tagEXTLOGPEN
{
unsigned int elpPenStyle;
unsigned int elpWidth;
unsigned int elpBrushStyle;
unsigned int elpColor;
unsigned __int64 elpHatch;
unsigned int elpNumEntries;
unsigned int elpStyleEntry[1];
};
END_ATF_NAMESPACE
|
[
"b1ll.cipher@yandex.ru"
] |
b1ll.cipher@yandex.ru
|
c669bb2e742c6e6ba22f04b9c60127e59d2594f2
|
98646bc3ad5b0bb9a3f7e739fd53bfe4c2ece9fa
|
/GenericRPG/EventHandlers.h
|
c24c9375d316f690957bb019b0b076eba97910d1
|
[] |
no_license
|
nCubedProjects/GenericRPG
|
885d7ab2c8f7785eae0e40413ef89e45f2219482
|
04f6083bf5376a704ce102cd02404a28d8a290e4
|
refs/heads/master
| 2023-01-30T08:53:46.896624
| 2020-12-14T22:25:54
| 2020-12-14T22:25:54
| 289,518,063
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 312
|
h
|
#pragma once
#include <SDL.h>
class KeyEventHandler {
public:
virtual void HandleEvent(SDL_KeyboardEvent) = 0;
};
class MouseButtonEventHandler {
public:
virtual void HandleEvent(SDL_MouseButtonEvent) = 0;
};
class MouseMotionEventHandler {
public:
virtual void HandleEvent(SDL_MouseMotionEvent) = 0;
};
|
[
"trentnov@gmail.com"
] |
trentnov@gmail.com
|
0171cbc2e74f651f46ed0317cabe55ac5b84355c
|
12b13df864815aa51f54194eea3f2b562cf32ae4
|
/meterAnalysis.cpp
|
ff1551fa905b5ba32bda99941761c9a1e91f3561
|
[] |
no_license
|
ArduinoStorm/synesthesia-scribe
|
70df515a52d9ccd8d29896f2281624a9483ddf32
|
8f6b9cce71093c763be2633b879709ee55039a6d
|
refs/heads/master
| 2020-05-05T03:22:25.649072
| 2019-04-05T20:18:48
| 2019-04-05T20:18:48
| 179,669,633
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,245
|
cpp
|
/*
* meterAnalysis.cpp
* Tries to find the meter of a poem by locating rhyming words and checking how often the occur per line to estimate meter
* By Jim Kemp, 2019, Licensed under the MIT License
*/
#include <iostream>
#include <string>
#include <vector>
std::vector<std::string> words;
// takes the word specified in wordNumber and returns what percent of the word list it rhymes with
float findRhyme(unsigned int word_number) {
std::string word_checked_against = words[word_number];
char word_checked_against_lastletter = word_checked_against[word_checked_against.length() - 1];
char word_checked_against_2ndtolastletter = word_checked_against[word_checked_against.length() - 2];
int number_of_rhymes = 0;
for(unsigned int i = 0; i < words.size(); ++i){
if(i == word_number){ // skips checking for rhyme if the word we are checking is the word we are checking against
continue;
}
std::string word_being_checked = words[i];
char word_being_checked_lastletter = word_being_checked[word_being_checked.length() - 1];
char word_being_checked_2ndtolastletter = word_being_checked[word_being_checked.length() - 2];
if(word_being_checked_lastletter == word_checked_against_lastletter && word_being_checked_2ndtolastletter == word_checked_against_2ndtolastletter) {
++number_of_rhymes;
}
}
return number_of_rhymes;
}
// takes the word specified in wordNumber and returns what percent of the word list it is an alliteration with
float findAlliteration(unsigned int word_number) {
std::string word_checked_against = words[word_number];
char word_checked_against_firstletter = word_checked_against[0];
char word_checked_against_2ndletter = word_checked_against[1];
int number_of_alliterations = 0;
for(unsigned int i = 0; i < words.size(); ++i){
if(i == word_number){ // skips checking for rhyme if the word we are checking is the word we are checking against
continue;
}
std::string word_being_checked = words[i];
char word_being_checked_firstletter = word_being_checked[0];
char word_being_checked_2ndletter = word_being_checked[1];
if(word_being_checked_firstletter == word_checked_against_firstletter && word_being_checked_2ndletter == word_checked_against_2ndletter) {
++number_of_alliterations;
}
}
return number_of_alliterations;
}
int main() {
std::cout << "Hello and Welcome to meterAnalysis" << std::endl;
while(true){ // loop to take values from user until the user entes "0" to terminate
std::string input_value = "NULL";
std::cout << "enter a word, enter 0 to exit: ";
std::cin >> input_value;
if(input_value == "0") {
break;
}else{
words.push_back(input_value);
}
}
for(unsigned int i = 0; i < words.size(); ++i) {
std::cout << "--------------------------------------------------------------------" << std::endl;
std::cout << findRhyme(i) << " of the words rhyme with " << words[i] << std::endl;
std::cout << "and " << findAlliteration(i) << " of the words are an alliteration with " << words[i] << std::endl;
}
std::cout << "--------------------------------------------------------------------" << std::endl;
return 0;
}
|
[
"noreply@github.com"
] |
ArduinoStorm.noreply@github.com
|
3fb112d03f8b77e259e011521beca45b06ae475a
|
b2d0bc3d53d125cc3c996e5cca0e53fb2a4cc914
|
/.vscode/cquery_cached_index/c@@users@jjlok@onedrive@documents@github@newpros/src@opcontrol.cpp
|
d0b3e5052b5ffe3f0da7df9cb92c1e066dd0d207
|
[] |
no_license
|
19jloken/NewPros
|
e33140b9a1eac923dc4d250e690e0a5be9b0931a
|
9ad31c53505db9787f454a269b7d8e79dc3a67e2
|
refs/heads/master
| 2020-04-17T09:58:58.944612
| 2019-03-12T21:03:25
| 2019-03-12T21:03:25
| 166,482,687
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,196
|
cpp
|
#include "main.h"
#include "headers/opcontrol.h"
#include "headers/robotFunction.h"
#include "headers/motorSlew.h"
#include "headers/general.h"
#include "headers/timers.h"
#include "headers/pollSensors.h"
#include "pros/rtos.h"
using namespace pros;
/**
* Runs the operator control code. This function will be started in its own task
* with the default priority and stack size whenever the robot is enabled via
* the Field Management System or the VEX Competition Switch in the operator
* control mode.
*
* If no competition control is connected, this function will run immediately
* following initialize().
*
* If the robot is disabled or communications is lost, the
* operator control task will be stopped. Re-enabling the robot will restart the
* task, not resume it from where it left off.
*/
bool curve = false;// should the robot use the parametric drive formula
bool inversed = false;// should the drive be inversed
bool control = false;// should the drive be in control mode
timer opLauncherTimer;
bool launcherWasLoaded = false;
int firstLoadedPostion;
pros::Controller master(pros::E_CONTROLLER_MASTER);
pros::Controller partner(pros::E_CONTROLLER_PARTNER);
// pros::Task userAutonomousTask(userAutonomous, (void*)"PROS", TASK_PRIORITY_DEFAULT, TASK_STACK_DEPTH_DEFAULT, "userAutonomousTask");
void opcontrol()
{
// userAutonomousTask.suspend();
robotFunctionTask.suspend();
enableSlew(0);
enableSlew(1);
enableSlew(2);
enableSlew(3);
enableSlew(4);
enableSlew(5);
enableSlew(6);
enableSlew(7);
initializeTimer(&opLauncherTimer);
zeroTimer(&opLauncherTimer);
stopTimer(&opLauncherTimer);
uint32_t lastRun = pros::c::millis();
// pros::lcd::set_text(1, "Hello PROS User!u");
while(true)// infinite while loop
{
// pros::lcd::set_text(1, "Hello PROS User");
if (partner.is_connected())// if their are two controllers
{
// pros::lcd::set_text(1, "Two Controller Drive");
doubleControllerDrive();// use the two controller drive code
}
else// if there is one controller
{
// pros::lcd::set_text(0, "Single Controller Drive");
// pros::lcd::print(2, "raw cali %d", pros::c::adi_analog_read_calibrated_HR(5));
singleControllerDrive();// use the one controller drive code
}
pros::c::task_delay_until(&lastRun, 5);
lastRun = pros::c::millis();
}
}
void doubleControllerDrive()
{
// userAutonomousTask.suspend();
robotFunctionTask.suspend();
float leftIn;
float rightIn;
float tempLeftIn;
float tempRightIn;
int strafe;
leftIn = master.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
rightIn = master.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
if(control)
{
leftIn = (leftIn*.5);
rightIn = (rightIn*.5);
}
if (curve)
{
leftIn = fabs(leftIn)*leftIn/127;
rightIn = fabs(rightIn)*rightIn/127;
}
if(inversed)
{
tempLeftIn = -rightIn;
tempRightIn = -leftIn;
leftIn = tempLeftIn;
rightIn = tempRightIn;
}
strafe = master.get_digital(E_CONTROLLER_DIGITAL_R1) + master.get_digital(E_CONTROLLER_DIGITAL_R2) - master.get_digital(E_CONTROLLER_DIGITAL_L1) - master.get_digital(E_CONTROLLER_DIGITAL_L2);
moveDrive(leftIn, rightIn, strafe);
moveLift(partner.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y));
if(master.get_digital(pros::E_CONTROLLER_DIGITAL_X))
{
while(master.get_digital(pros::E_CONTROLLER_DIGITAL_X))
{
pros::delay(5);
}
autonomous();
while(!master.get_digital(pros::E_CONTROLLER_DIGITAL_X))
{
pros::delay(5);
}
while(master.get_digital(pros::E_CONTROLLER_DIGITAL_X))
{
pros::delay(5);
}
}
if(partner.get_digital(pros::E_CONTROLLER_DIGITAL_R2))
{
moveIntake(-127);
}
else if(partner.get_digital(pros::E_CONTROLLER_DIGITAL_R1))
{
moveIntake(127);
}
else
{
moveIntake(0);
}
moveFlipper(partner.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y));
if(isLauncherLoaded() || (fabs(firstLoadedPostion - motorArray[6]->get_position()) < 150 && launcherWasLoaded))
{
if(!launcherWasLoaded)
{
firstLoadedPostion = motorArray[6]->get_position();
}
launcherWasLoaded = true;
zeroTimer(&opLauncherTimer);
stopTimer(&opLauncherTimer);
if(partner.get_digital(pros::E_CONTROLLER_DIGITAL_A) || master.get_digital(pros::E_CONTROLLER_DIGITAL_A))
{
moveLauncher(127);
}
else
{
moveLauncher(0);
}
}
else
{
launcherWasLoaded = false;
startTimer(&opLauncherTimer);
if(currentTime(&opLauncherTimer) > 400)
{
moveLauncher(127);
}
else
{
moveLauncher(0);
}
}
}
void singleControllerDrive()
{
// userAutonomousTask.suspend();
robotFunctionTask.suspend();
float leftIn;
float rightIn;
float tempLeftIn;
float tempRightIn;
int strafe;
leftIn = master.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
rightIn = master.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
if(control)
{
leftIn = (leftIn*.5);
rightIn = (rightIn*.5);
}
if (curve)
{
leftIn = fabs(leftIn)*leftIn/127;
rightIn = fabs(rightIn)*rightIn/127;
}
if(inversed)
{
tempLeftIn = -rightIn;
tempRightIn = -leftIn;
leftIn = tempLeftIn;
rightIn = tempRightIn;
}
strafe = master.get_digital(E_CONTROLLER_DIGITAL_R1) + master.get_digital(E_CONTROLLER_DIGITAL_R2) - master.get_digital(E_CONTROLLER_DIGITAL_L1) - master.get_digital(E_CONTROLLER_DIGITAL_L2);
moveDrive(leftIn, rightIn, strafe);
if(master.get_digital(pros::E_CONTROLLER_DIGITAL_X))
{
while(master.get_digital(pros::E_CONTROLLER_DIGITAL_X))
{
pros::delay(5);
}
autonomous();
while(!master.get_digital(pros::E_CONTROLLER_DIGITAL_X))
{
pros::delay(5);
}
while(master.get_digital(pros::E_CONTROLLER_DIGITAL_X))
{
pros::delay(5);
}
}
if(master.get_digital(pros::E_CONTROLLER_DIGITAL_R2))
{
moveIntake(-127);
}
else if(master.get_digital(pros::E_CONTROLLER_DIGITAL_R1))
{
moveIntake(127);
}
else
{
moveIntake(0);
}
if(master.get_digital(pros::E_CONTROLLER_DIGITAL_UP))
{
moveFlipper(-127);
}
else if(master.get_digital(pros::E_CONTROLLER_DIGITAL_DOWN))
{
moveFlipper(127);
}
else
{
moveFlipper(0);
}
if(isLauncherLoaded() || (fabs(firstLoadedPostion - motorArray[6]->get_position()) < 150 && launcherWasLoaded))
{
if(!launcherWasLoaded)
{
firstLoadedPostion = motorArray[6]->get_position();
}
launcherWasLoaded = true;
zeroTimer(&opLauncherTimer);
stopTimer(&opLauncherTimer);
if(master.get_digital(pros::E_CONTROLLER_DIGITAL_A))
{
moveLauncher(127);
}
else
{
moveLauncher(0);
}
}
else
{
launcherWasLoaded = false;
startTimer(&opLauncherTimer);
if(currentTime(&opLauncherTimer) > 400)
{
moveLauncher(127);
}
else
{
moveLauncher(0);
}
}
// userAutonomousTask.resume();
// autonomous();
}
// void userAutonomous(void* param)
// {
// autonomous();
// while(1 == 1)
// {
// pros::delay(5);
// }
// }
|
[
"19jloken@xaviercatholicschools.org"
] |
19jloken@xaviercatholicschools.org
|
ec97e0cdccc6e2cb706e24e22c7730e0d4731b0d
|
b62c5636ca3955e9b2bb8631e7dc351e41d14912
|
/source/SafeStringAPIs.cpp
|
54798cb231e7f55402a507afd4e73550f525cb00
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
kranack/XMP-Toolkit-SDK
|
1a05aa5ebf10d2bec8f504784714a6f20b8cfdb2
|
0872e35a30457d2ecf746a1bebdb7d94636d0e2f
|
refs/heads/master
| 2022-02-24T03:30:23.767797
| 2020-01-29T05:03:16
| 2020-01-29T05:03:16
| 237,179,960
| 2
| 0
|
NOASSERTION
| 2020-04-06T02:54:13
| 2020-01-30T09:30:42
| null |
UTF-8
|
C++
| false
| false
| 14,199
|
cpp
|
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2010 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
**************************************************************************/
#include <stddef.h> /* Include standard ANSI C stuff: size_t, NULL etc */
#include <string.h> /* memmove etc. defined here */
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <stdarg.h>
#include <assert.h>
#include <limits.h>
#include "SafeStringAPIs.h"
/*
Safe String Functions
*/
CONDITIONAL_STATIC size_t strnlen_safe(const char *s, size_t maxSize)
{
if (s)
{
size_t n;
for (n = 0; n < maxSize && *s; n++, s++)
;
return n;
}
else{
return 0;
}
}
CONDITIONAL_STATIC SafeInt32 strcpy_safe(char *dest, size_t size, const char *src)
{
if (dest && src && size > 0)
{
char* p = dest;
size_t available = size;
while((*p++ = *src++) != '\0' && --available > 0)
{
}
if(available == 0)
{
*(--p) = '\0';
//Buffer overflow. return ERROR_SAFE_BUFFER_OVERFLOW
return ERROR_SAFE_BUFFER_OVERFLOW;
}
else
return 0;
}
else{
if(dest)
*dest = '\0';
return ERROR_SAFE_INVALID_PARAM;
}
}
CONDITIONAL_STATIC SafeInt32 strncpy_safe(char *dest, size_t size, const char *src, size_t n)
{
if(n == 0 && dest == NULL && size == 0)
return 0;
if(dest && src && size > 0)
{
if(n == 0)
{
*dest = '\0';
return 0;
}
char* p = dest;
size_t available = size;
while((*p++ = *src++) != '\0' && --available > 0 && --n > 0)
{
}
if(n == 0)
*p = '\0';
if(available == 0)
{
*(--p) = '\0';
//Buffer overflow. Returns ERROR_SAFE_BUFFER_OVERFLOW
return ERROR_SAFE_BUFFER_OVERFLOW;
}
return 0;
}
else{
if(dest)
*dest = '\0';
return ERROR_SAFE_INVALID_PARAM;
}
}
CONDITIONAL_STATIC SafeInt32 strcat_safe(char *s1, size_t s1max, const char *s2)
{
if(s1 == NULL && s1max == 0)
return 0;
if(s1 && s2 && s1max > 0)
{
size_t available = s1max;
char* dest = s1;
while(available > 0 && *dest != '\0')
{
dest++;
available--;
}
if(available == 0)
{
*s1 = '\0';
//Destination not null terminated. Empty destination and return ERROR_SAFE_INVALID_PARAM
return ERROR_SAFE_INVALID_PARAM;
}
while((*dest++ = *s2++) != '\0' && --available > 0)
{
}
if(available == 0)
{
//Truncate at buffer overflow attempt. Return ERROR_SAFE_BUFFER_OVERFLOW.
*(--dest) = '\0';
return ERROR_SAFE_BUFFER_OVERFLOW;
}
return 0;
}
else{
if(s1)
*s1 = '\0';
return ERROR_SAFE_INVALID_PARAM;
}
}
CONDITIONAL_STATIC SafeInt32 strncat_safe(char *s1, size_t s1max, const char *s2, size_t n)
{
if(n == 0 && s1 == NULL && s1max == 0)
return 0;
if(s1 && s2 && s1max > 0)
{
char* dest = s1;
size_t available = s1max;
while(available > 0 && *dest != '\0')
{
dest++;
available--;
}
if(available == 0)
{
*s1 = '\0';
//Destination not null terminated. Empty destination and return ERROR_SAFE_INVALID_PARAM
return ERROR_SAFE_INVALID_PARAM;
}
while(n > 0 && (*dest++ = *s2++)!= '\0' && --available > 0)
{
n--;
}
if(n == 0)
{
*dest = '\0';
}
if(available == 0)
{
//Truncate. Return ERROR_SAFE_BUFFER_OVERFLOW
*(--dest) = '\0';
return ERROR_SAFE_BUFFER_OVERFLOW;
}
return 0;
}
else{
if(s1)
*s1 = '\0';
return ERROR_SAFE_INVALID_PARAM;
}
}
CONDITIONAL_STATIC char *strchr_safe(const char *s, size_t maxSize, char c)
{
if(s == NULL) return NULL;
for (; maxSize > 0 && *s != '\0'; s++, maxSize--)
{
if (*s == (const char)c)
{
return (char *)s;
}
}
if (maxSize > 0 && (const char)c == *s)
{
return (char *)s;
}
return NULL;
}
CONDITIONAL_STATIC char * strtok_safe(char* strToken, size_t maxSize, const char *strDelimit, char **context)
{
if(maxSize == 0)
{
return NULL;
}
if(strToken)
{
strToken[maxSize - 1] = '\0';
}
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return strtok_s(strToken, strDelimit, context);
#else
if( !strDelimit || !context || ( !( *context) && ( !strToken)))
{
return NULL;
}
if( !strToken)
{
// We got NULL input, so we get our last position from context.
strToken = *context;
}
/* pass all characters that are present in the delimiter string */
while(*strToken && strchr_safe(strDelimit, (size_t)-1, *strToken))
++strToken;
if(*strToken){
/* This is where the next piece of string starts */
char *start = strToken;
/* Set the context pointer to the first byte after start */
*context = start + 1;
while(**context && !strchr_safe(strDelimit, (size_t)-1, **context))
++*context;
if(**context){
//The end is not a null byte
**context = '\0'; /* Null terminate it */
++*context; /* Advance the last pointer to beyond the null byte. */
}
return start;
}
// No remaining tokens. Set the context pointer to the original terminating null
// of strToken and return null.
*context = strToken;
return NULL;
#endif
}
CONDITIONAL_STATIC SafeInt32 vprintf_safe(const char* format, va_list argp)
{
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return vprintf_s(format, argp);
#else
if(format)
{
return vprintf(format, argp);
}
else
{
return ERROR_SAFE_INVALID_PARAM;
}
#endif
}
CONDITIONAL_STATIC SafeInt32 vsprintf_safe(char* buffer, size_t size, const char* format, va_list argp)
{
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return vsprintf_s(buffer, size, format, argp);
#else
if(buffer && format && size > 0)
{
SafeInt32 count = static_cast<SafeInt32>(size);
if(count > INT_MAX)
count = INT_MAX;
SafeInt32 numBytes = vsnprintf(buffer, count, format, argp);
if(numBytes >= count)
{
/* If number of bytes written is greater than count, the buffer is too small,
vsnprintf truncates the buffer and null terminates it.*/
return ERROR_SAFE_BUFFER_OVERFLOW;
}
return numBytes;
}
else
{
if(buffer)
*buffer = '\0';
return ERROR_SAFE_INVALID_PARAM;
}
#endif
}
CONDITIONAL_STATIC SafeInt32 vsnprintf_safe(char *buffer, size_t size, size_t count, const char* format, va_list argp)
{
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return vsnprintf_s(buffer, size, count, format, argp);
#else
if(count == 0 && buffer == NULL && size == 0)
return 0; //allowed
if(buffer && format && size > 0)
{
if(count == 0)
{
*buffer = '\0';
return 0;
}
SafeInt32 n = (SafeInt32)((count + 1) < size ? (count + 1) : size); //MIN(count+1, size);
SafeInt32 numBytes = vsnprintf(buffer, n, format, argp);
if(numBytes >= static_cast<SafeInt32>(size) && count >= size)
{
//Truncate here. Return ERROR_SAFE_BUFFER_OVERFLOW.
buffer[n-1] = '\0';
return ERROR_SAFE_BUFFER_OVERFLOW;
}
buffer[n-1] = '\0';
return numBytes;
}
else
{
if(buffer)
*buffer = '\0';
return ERROR_SAFE_INVALID_PARAM;
}
#endif
}
CONDITIONAL_STATIC SafeInt32 vwprintf_safe(const wchar_t *format, va_list argp)
{
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return vwprintf_s(format, argp);
#else
if(format)
{
return vwprintf(format, argp);
}
else
{
return ERROR_SAFE_INVALID_PARAM;
}
#endif
}
CONDITIONAL_STATIC SafeInt32 sprintf_safe(char *buffer, size_t size, const char *format, ...)
{
va_list argp;
va_start(argp, format);
SafeInt32 numBytes = vsprintf_safe(buffer, size, format, argp);
va_end(argp);
return numBytes;
}
CONDITIONAL_STATIC SafeInt32 printf_safe(const char *format, ...)
{
va_list argp;
va_start(argp, format);
SafeInt32 numBytes = vprintf_safe(format, argp);
va_end(argp);
return numBytes;
}
CONDITIONAL_STATIC SafeInt32 snprintf_safe(char* buffer, size_t size, size_t count, const char *format, ...)
{
va_list argp;
va_start(argp, format);
SafeInt32 numBytes = vsnprintf_safe(buffer, size, count, format, argp);
va_end(argp);
return numBytes;
}
CONDITIONAL_STATIC SafeInt32 wprintf_safe(const wchar_t *format, ...)
{
va_list argp;
va_start(argp, format);
SafeInt32 numBytes = vwprintf_safe(format, argp);
va_end(argp);
return numBytes;
}
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
CONDITIONAL_STATIC SafeInt32 splitpath_safe(const char* path, char* drive, size_t driveSize, char* dir,
size_t dirSize, char* fname, size_t fnameSize, char* ext, size_t extSize)
{
return _splitpath_s(path, drive, driveSize, dir, dirSize, fname, fnameSize, ext, extSize);
}
CONDITIONAL_STATIC SafeInt32 makepath_safe(char* path, size_t size, const char* drive, const char* dir,
const char* fname, const char* ext)
{
return _makepath_s(path, size, drive, dir, fname, ext);
}
#endif
#if !(defined(_WIN32) || defined(_WIN64)) || !defined __STDC_WANT_SECURE_LIB__
static char *reverse_string_safe(char *str, size_t size)
{
size_t head = 0;
size_t tail = strnlen_safe(str, size) - 1;
while (head < tail)
{
char temp = str[head];
str[head] = str[tail];
str[tail] = temp;
head++;
tail--;
}
return str;
}
static SafeInt32 _xtox_safe(unsigned long val, char *buf, size_t size, int radix, int isNeg)
{
if(!buf)
{
return ERROR_SAFE_INVALID_PARAM;
}
if(radix < 2 || radix > 36)
{
return ERROR_SAFE_INVALID_PARAM;
}
size_t len;
unsigned long num;
if(isNeg)
num = (unsigned long)(-(long)val);
else
num = val;
for(len = 2; num; num/= radix) len++; /* quick log_base */
if(size <= 0 || size < len)
{
buf[0]='\0';
return ERROR_SAFE_BUFFER_OVERFLOW;
}
/* parameters are valid */
int strIndex = 0;
if(isNeg)
val = (unsigned long)(-(long)val);
do
{
unsigned curDigit = (unsigned) val % radix;
if(curDigit > 9)
buf[strIndex++] = curDigit + 'a' - 10;
else
buf[strIndex++] = curDigit + '0';
val /= radix;
}while(val);
if(isNeg)
buf[strIndex++] = '-';
buf[strIndex++] = 0;
/* Now reverse the string */
reverse_string_safe(buf, size);
return 0;
}
static SafeInt32 _x64tox_safe(SafeUns64 val, char *buf, size_t size, int radix, int isNeg)
{
if(!buf)
{
return ERROR_SAFE_INVALID_PARAM;
}
if(radix < 2 || radix > 36)
{
return ERROR_SAFE_INVALID_PARAM;
}
size_t len;
SafeUns64 num = 0;
if(isNeg)
num = (SafeUns64)(-(SafeInt64)val);
else
num = val;
for(len = 2; num; num/= radix) len++; /* quick log_base */
if(size <= 0 || size < len)
{
buf[0]='\0';
return ERROR_SAFE_BUFFER_OVERFLOW;
}
/* parameters are valid */
int strIndex = 0;
if(isNeg)
val = (SafeUns64)(-(SafeInt64)val);
do
{
unsigned curDigit = (unsigned) val % radix;
if(curDigit > 9)
buf[strIndex++] = curDigit + 'a' - 10;
else
buf[strIndex++] = curDigit + '0';
val /= radix;
}while(val);
if(isNeg)
buf[strIndex++] = '-';
buf[strIndex++] = 0;
/* Now reverse the string */
reverse_string_safe(buf, size);
return 0;
}
#endif
CONDITIONAL_STATIC SafeInt32 _itoa_safe(int val, char* buf, size_t size, int radix)
{
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return _itoa_s(val, buf, size, radix);
#else
if(radix == 10 && val < 0)
return _xtox_safe((unsigned long)val, buf, size, radix, 1);
else
return _xtox_safe((unsigned long)(unsigned int)val, buf, size, radix, 0);
#endif
}
CONDITIONAL_STATIC SafeInt32 _ltoa_safe(long val, char *buf, size_t size, int radix)
{
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return _ltoa_s(val, buf, size, radix);
#else
return _xtox_safe((unsigned long)val, buf, size, radix, (radix == 10 && val < 0));
#endif
}
CONDITIONAL_STATIC SafeInt32 _ultoa_safe(unsigned long val, char *buf, size_t size, int radix)
{
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return _ultoa_s(val, buf, size, radix);
#else
return _xtox_safe(val, buf, size, radix, 0);
#endif
}
CONDITIONAL_STATIC SafeInt32 _i64toa_safe(SafeInt64 val, char* buf, size_t size, int radix)
{
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return _i64toa_s(val, buf, size, radix);
#else
return _x64tox_safe((SafeUns64)val, buf, size, radix, (radix == 10 && val <0 ));
#endif
}
CONDITIONAL_STATIC SafeInt32 _ui64toa_safe(SafeUns64 val, char* buf, size_t size, int radix)
{
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return _ui64toa_s(val, buf, size, radix);
#else
return _x64tox_safe(val, buf, size, radix, 0);
#endif
}
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
CONDITIONAL_STATIC SafeInt32 _itow_safe(int val, wchar_t *buf, size_t size, int radix)
{
return _itow_s(val, buf, size, radix);
}
CONDITIONAL_STATIC SafeInt32 _i64tow_safe(SafeInt64 val, wchar_t *buf, size_t size, int radix)
{
return _i64tow_s(val, buf, size, radix);
}
CONDITIONAL_STATIC SafeInt32 _ui64tow_safe(SafeUns64 val, wchar_t *buf, size_t size, int radix)
{
return _ui64tow_s(val, buf, size, radix);
}
CONDITIONAL_STATIC SafeInt32 _ltow_safe(long val, wchar_t *str, size_t size, int radix)
{
return _ltow_s(val, str, size, radix);
}
CONDITIONAL_STATIC SafeInt32 _ultow_safe(unsigned long val, wchar_t *str, size_t size, int radix)
{
return _ultow_s(val, str, size, radix);
}
#endif
CONDITIONAL_STATIC char * gets_safe(char* buffer, size_t size)
{
#if (defined(_WIN32) || defined(_WIN64)) && defined __STDC_WANT_SECURE_LIB__
return gets_s(buffer, size);
#else
if(buffer && size > 0)
{
char* pointer = buffer;
char ch;
size_t count = size;
ch = (char)getchar();
while(ch != (char)EOF && ch != '\n')
{
if(count > 0)
{
count--;
*pointer++ = ch;
}
ch = (char)getchar();
}
if(count == 0)
{
*buffer = '\0';
}
else
*pointer = '\0';
return buffer;
}
else
{
return NULL;
}
#endif
}
|
[
"gupta66priyanka@gmail.com"
] |
gupta66priyanka@gmail.com
|
48f69fa07c2a9ff553eedae6b633f9ab4886871e
|
c22b3017098ba6e08dbb982d66bbc61c94a4752d
|
/include/linux-halib/driver/morpheus.h
|
dad2dc71db426889b5375c4d93d4f44f94838ee3
|
[
"BSD-2-Clause"
] |
permissive
|
steup/Linux-HaLib
|
c77db74014231f780a08c5f1f6157562beb884df
|
33254a1c8d858c22552ec055f4ac99713945f76f
|
refs/heads/master
| 2019-01-19T13:03:32.419506
| 2012-08-03T14:16:50
| 2012-08-03T14:16:50
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,757
|
h
|
#pragma once
#include <boost/thread.hpp>
#include <boost/chrono.hpp>
namespace linux_halib
{
namespace driver
{
struct Morpheus
{
struct DefaultConfig
{
typedef boost::chrono::milliseconds SleepTimeType;
static const unsigned long long sleepTime = 100;
};
struct SleepModes
{
/**\brief Possible sleep modes
**/
enum SleepModeType
{
idle=0 /**<Default task sleep**/
};
};
typedef SleepModes::SleepModeType SleepModeType;
template<typename Config = DefaultConfig>
struct configure
{
struct type
{
typedef Morpheus::SleepModes SleepModes;
typedef Morpheus::SleepModeType SleepModeType;
/**\brief sleep the mcu
* \param mode the sleep mode to use
*
* this call puts the cpu to sleep. The operation will be resumed when an
* interrupt occurs, however dependant on the selected sleep mode some
* interrupt sources may not trigger.
**/
static void sleep(SleepModeType mode = SleepModes::idle)
{
boost::this_thread::sleep_for(typename Config::SleepTimeType(Config::sleepTime));
}
template<SleepModeType mode>
static void sleep()
{
sleep(mode);
}
};
};
};
}
}
|
[
"christoph.steup@st.ovgu.de"
] |
christoph.steup@st.ovgu.de
|
adb0dd1aa2553ba946d8c541df3636720738a133
|
6ffd23679939f59f0a09c9507a126ba056b239d7
|
/dnn/src/fallback/conv_bias/gi/fp32/direct_kernels/f32_direct_nchw_nchw44_kern_3x3s2_broadcast_channel_bias.cpp
|
472de26a6e7a0aeac64aa0b6fb557b99e3cff154
|
[
"LicenseRef-scancode-generic-cla",
"Apache-2.0"
] |
permissive
|
MegEngine/MegEngine
|
74c1c9b6022c858962caf7f27e6f65220739999f
|
66b79160d35b2710c00befede0c3fd729109e474
|
refs/heads/master
| 2023-08-23T20:01:32.476848
| 2023-08-01T07:12:01
| 2023-08-11T06:04:12
| 248,175,118
| 5,697
| 585
|
Apache-2.0
| 2023-07-19T05:11:07
| 2020-03-18T08:21:58
|
C++
|
UTF-8
|
C++
| false
| false
| 165
|
cpp
|
#include "src/fallback/conv_bias/gi/fp32/direct_kernels/f32_direct_nchw_nchw44_kern_common.h"
INSTANCE_CONV_BROADCAST_CHANNEL_BIAS(3, 2);
// vim: syntax=cpp.doxygen
|
[
"megengine@megvii.com"
] |
megengine@megvii.com
|
a567f1a8c41b20bc628601c493e963f308d5edeb
|
ec46261fa550b92a021318c4e3cca6f23b26a8c0
|
/DirectX11_Starter/ConstantBuffer.cpp
|
ee729582f273429a076cf77b3ddbd324f15324da
|
[] |
no_license
|
alycat/SpaceSaucer
|
330b0999bf97a835cca0bfbd3f8024f99a2f2196
|
b6f681199af547506c33bbcb9d69d25c741e4d70
|
refs/heads/master
| 2021-01-10T14:28:32.207971
| 2015-12-05T06:44:08
| 2015-12-05T06:44:08
| 47,444,650
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,191
|
cpp
|
#include "ConstantBuffer.h"
#include "Global.h"
ConstantBuffer::ConstantBuffer(ConstantBufferLayout c_buffer_data, ID3D11Device* dev)
{
c_byteWidth = sizeof(ConstantBufferLayout);
setUpConstantBuffer(dev);
}
ConstantBuffer::ConstantBuffer(LightBufferType c_buffer_data, ID3D11Device* dev)
{
c_byteWidth = sizeof(LightBufferType);
setUpConstantBuffer(dev);
}
ConstantBuffer::ConstantBuffer(CameraBufferType c_buffer_data, ID3D11Device* dev)
{
c_byteWidth = sizeof(CameraBufferType);
setUpConstantBuffer(dev);
}
ConstantBuffer::ConstantBuffer(ParticleVertexShaderConstantBufferLayout c_buffer_data, ID3D11Device* dev)
{
c_byteWidth = sizeof(ParticleVertexShaderConstantBufferLayout);
setUpConstantBuffer(dev);
}
void ConstantBuffer::setUpConstantBuffer(ID3D11Device* dev){
D3D11_BUFFER_DESC cBufferDesc;
cBufferDesc.ByteWidth = c_byteWidth;
cBufferDesc.Usage = D3D11_USAGE_DEFAULT;
cBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
cBufferDesc.CPUAccessFlags = 0;
cBufferDesc.MiscFlags = 0;
cBufferDesc.StructureByteStride = 0;
dev->CreateBuffer(
&cBufferDesc,
NULL,
&constantBuffer);
}
ConstantBuffer::~ConstantBuffer(void)
{
//ReleaseMacro(constantBuffer);
}
|
[
"alyssalabraham@gmail.com"
] |
alyssalabraham@gmail.com
|
567cafc653f0525c9b30b03616df1d52effafa13
|
eb1517897d7e9e372538b0982223b7ecaaff46b0
|
/chrome/browser/offline_pages/android/prefetch_background_task_android.cc
|
950ae6906c1244137077bdc2e06535676ef963f1
|
[
"BSD-3-Clause"
] |
permissive
|
jiachengii/chromium
|
c93e9cfa8fb79d6a0b5e66848dc204e87236252c
|
ead0d3601849269629ff31de4daed20fce453ba7
|
refs/heads/master
| 2022-11-16T02:35:53.671352
| 2020-06-13T06:43:44
| 2020-06-13T06:43:44
| 271,964,385
| 0
| 0
|
BSD-3-Clause
| 2020-06-13T07:47:21
| 2020-06-13T07:47:21
| null |
UTF-8
|
C++
| false
| false
| 3,098
|
cc
|
// 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.
#include "chrome/browser/offline_pages/android/prefetch_background_task_android.h"
#include <memory>
#include "base/check.h"
#include "base/time/time.h"
#include "chrome/android/chrome_jni_headers/PrefetchBackgroundTask_jni.h"
#include "chrome/browser/android/profile_key_util.h"
#include "chrome/browser/offline_pages/prefetch/prefetch_service_factory.h"
#include "chrome/browser/profiles/profile_key.h"
#include "components/offline_pages/core/prefetch/prefetch_background_task.h"
#include "components/offline_pages/core/prefetch/prefetch_dispatcher.h"
#include "components/offline_pages/core/prefetch/prefetch_service.h"
using base::android::JavaParamRef;
using base::android::ScopedJavaGlobalRef;
using base::android::ScopedJavaLocalRef;
namespace offline_pages {
namespace prefetch {
// JNI call to start request processing in scheduled mode.
static jboolean JNI_PrefetchBackgroundTask_StartPrefetchTask(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller) {
ProfileKey* profile_key = ::android::GetLastUsedProfileKey();
DCHECK(profile_key);
PrefetchService* prefetch_service =
PrefetchServiceFactory::GetForKey(profile_key);
if (!prefetch_service)
return false;
prefetch_service->GetPrefetchDispatcher()->BeginBackgroundTask(
std::make_unique<PrefetchBackgroundTaskAndroid>(env, jcaller,
prefetch_service));
return true;
}
} // namespace prefetch
PrefetchBackgroundTaskAndroid::PrefetchBackgroundTaskAndroid(
JNIEnv* env,
const JavaParamRef<jobject>& java_prefetch_background_task,
PrefetchService* service)
: PrefetchBackgroundTask(service),
java_prefetch_background_task_(java_prefetch_background_task) {
// Give the Java side a pointer to the new background task object.
prefetch::Java_PrefetchBackgroundTask_setNativeTask(
env, java_prefetch_background_task_, reinterpret_cast<jlong>(this));
}
PrefetchBackgroundTaskAndroid::~PrefetchBackgroundTaskAndroid() {
JNIEnv* env = base::android::AttachCurrentThread();
prefetch::Java_PrefetchBackgroundTask_doneProcessing(
env, java_prefetch_background_task_, false);
}
bool PrefetchBackgroundTaskAndroid::OnStopTask(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller) {
SetReschedule(PrefetchBackgroundTaskRescheduleType::RESCHEDULE_DUE_TO_SYSTEM);
service()->GetPrefetchDispatcher()->StopBackgroundTask();
return false;
}
void PrefetchBackgroundTaskAndroid::SetTaskReschedulingForTesting(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller,
int reschedule_type) {
SetReschedule(
static_cast<PrefetchBackgroundTaskRescheduleType>(reschedule_type));
}
void PrefetchBackgroundTaskAndroid::SignalTaskFinishedForTesting(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller) {
service()->GetPrefetchDispatcher()->StopBackgroundTask();
}
} // namespace offline_pages
|
[
"commit-bot@chromium.org"
] |
commit-bot@chromium.org
|
0587e1a822d7df3816f86f50e3a97672dfcc0b3c
|
b50fa69407f6d6c74abfc6cfd7a0c74e109b5d21
|
/win9x/dialog/d_clnd.cpp
|
5180a6b293f7d14e2e46af51a76e78c27e692d28
|
[] |
no_license
|
joshuashaffer/np21w-linux
|
925cdb2add81fc2577d1ea80f493f5ea41fff9e2
|
c27a2d990dbe0420cdc0070d9e3a06f8325a5701
|
refs/heads/master
| 2023-03-23T04:36:01.009882
| 2021-03-09T23:30:19
| 2021-03-09T23:30:19
| 344,650,961
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,369
|
cpp
|
/**
* @file d_clnd.cpp
* @brief カレンダ設定ダイアログ
*/
#include "compiler.h"
#include "resource.h"
#include "dialog.h"
#include "np2.h"
#include "sysmng.h"
#include "timemng.h"
#include "misc/DlgProc.h"
#include "calendar.h"
#include "pccore.h"
#include "common/strres.h"
/**
* @brief カレンダ設定ダイアログ
* @param[in] hwndParent 親ウィンドウ
*/
class CCalendarDlg : public CDlgProc {
public:
CCalendarDlg(HWND hwndParent);
protected:
virtual BOOL OnInitDialog();
virtual void OnOK();
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
private:
void SetTime(const UINT8 *cbuf);
void EnableVirtualCalendar(BOOL bEnabled);
static UINT8 getbcd(LPCTSTR str, int len);
};
/**
* @brief ダイアログ アイテム
*/
struct Item {
UINT16 res; //!< ID
UINT8 min; //!< 最小値
UINT8 max; //!< 最大値
};
/**
* アイテム
*/
static const Item s_vircal[6] = {
{IDC_VIRYEAR, 0x00, 0x99}, {IDC_VIRMONTH, 0x01, 0x12},
{IDC_VIRDAY, 0x01, 0x31}, {IDC_VIRHOUR, 0x00, 0x23},
{IDC_VIRMINUTE, 0x00, 0x59}, {IDC_VIRSECOND, 0x00, 0x59}};
/**
* コンストラクタ
* @param[in] hwndParent 親ウィンドウ
*/
CCalendarDlg::CCalendarDlg(HWND hwndParent)
: CDlgProc(IDD_CALENDAR, hwndParent) {}
/**
* このメソッドは WM_INITDIALOG のメッセージに応答して呼び出されます
* @retval TRUE 最初のコントロールに入力フォーカスを設定
* @retval FALSE 既に設定済
*/
BOOL CCalendarDlg::OnInitDialog() {
// 時間をセット。
UINT8 cbuf[6];
calendar_getvir(cbuf);
SetTime(cbuf);
const UINT nID = (np2cfg.calendar) ? IDC_CLNDREAL : IDC_CLNDVIR;
EnableVirtualCalendar((nID == IDC_CLNDVIR) ? TRUE : FALSE);
CheckDlgButton(nID, BST_CHECKED);
GetDlgItem(nID).SetFocus();
return FALSE;
}
/**
* ユーザーが OK のボタン (IDOK ID がのボタン) をクリックすると呼び出されます
*/
void CCalendarDlg::OnOK() {
const UINT8 bMode =
(IsDlgButtonChecked(IDC_CLNDREAL) != BST_UNCHECKED) ? 1 : 0;
if (np2cfg.calendar != bMode) {
np2cfg.calendar = bMode;
sysmng_update(SYS_UPDATECFG);
}
UINT8 cbuf[6];
for (UINT i = 0; i < 6; i++) {
TCHAR work[32];
GetDlgItemText(s_vircal[i].res, work, NELEMENTS(work));
UINT8 b = getbcd(work, 2);
if ((b >= s_vircal[i].min) && (b <= s_vircal[i].max)) {
if (i == 1) {
b = ((b & 0x10) * 10) + (b << 4);
}
cbuf[i] = b;
}
}
calendar_set(cbuf);
CDlgProc::OnOK();
}
/**
* ユーザーがメニューの項目を選択したときに、フレームワークによって呼び出されます
* @param[in] wParam パラメタ
* @param[in] lParam パラメタ
* @retval TRUE アプリケーションがこのメッセージを処理した
*/
BOOL CCalendarDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
switch (LOWORD(wParam)) {
case IDC_CLNDVIR:
EnableVirtualCalendar(TRUE);
return TRUE;
case IDC_CLNDREAL:
EnableVirtualCalendar(FALSE);
return TRUE;
case IDC_SETNOW: {
UINT8 cbuf[6];
calendar_getreal(cbuf);
SetTime(cbuf);
}
return TRUE;
}
return FALSE;
}
/**
* 時間を設定する
* @param[in] cbuf カレンダ情報
*/
void CCalendarDlg::SetTime(const UINT8 *cbuf) {
for (UINT i = 0; i < 6; i++) {
TCHAR work[8];
if (i != 1) {
wsprintf(work, str_2x, cbuf[i]);
} else {
wsprintf(work, str_2d, cbuf[1] >> 4);
}
SetDlgItemText(s_vircal[i].res, work);
}
}
/**
* 仮想カレンダ アイテムの一括設定
* @param[in] bEnabled 有効フラグ
*/
void CCalendarDlg::EnableVirtualCalendar(BOOL bEnabled) {
for (UINT i = 0; i < 6; i++) {
GetDlgItem(s_vircal[i].res).EnableWindow(bEnabled);
}
GetDlgItem(IDC_SETNOW).EnableWindow(bEnabled);
}
/**
* BCD を得る
* @param[in] str 文字列
* @param[in] len 長さ
* @return 値
*/
UINT8 CCalendarDlg::getbcd(LPCTSTR str, int len) {
UINT ret = 0;
while (len--) {
TCHAR c = *str++;
if (!c) {
break;
}
if ((c < '0') || (c > '9')) {
return 0xff;
}
ret <<= 4;
ret |= (UINT)(c - '0');
}
return static_cast<UINT8>(ret);
}
/**
* カレンダ設定ダイアログ
* @param[in] hwndParent 親ウィンドウ
*/
void dialog_calendar(HWND hwndParent) {
CCalendarDlg dlg(hwndParent);
dlg.DoModal();
}
|
[
"joshua.shaffer@icmrl.net"
] |
joshua.shaffer@icmrl.net
|
2f9ab80c60102de96568ffd72037000edb7e46a3
|
f84be0d4ad35fa61627591344ebd0a18d24189dc
|
/Cpp/shared_ptr_cast/main.cpp
|
53d28750426d4828d2eb5e875ca7a6ed85ef3441
|
[] |
no_license
|
rhexo/app-lib
|
8602fd17aee208e4713572d2238a7b826bf6dc38
|
51f0deaf41b467d18028f18982e312f32f207574
|
refs/heads/master
| 2020-05-20T08:37:41.149116
| 2017-01-21T19:24:19
| 2017-01-21T19:24:19
| 44,518,075
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 327
|
cpp
|
#include <memory>
#include <iostream>
using namespace std;
int main (){
shared_ptr<void> sp(new int{10});
// undefined bihavior for next expression
// shared_ptr<int> sp1 = shared_ptr<int>(static_cast<int*>(sp.get()))
shared_ptr<int> sp1 = static_pointer_cast<int>(sp);
cout << "Cast value: " << *sp1 << endl;
}
|
[
"mmusolov@gmail.com"
] |
mmusolov@gmail.com
|
731904f8aa6f6329364e266bf5944d496900b92e
|
baedc346094836f6a8266d15ffcd8cbb0cf6abb5
|
/Framework-EGC-master_MacOS/lab-framework/src/engine/World.cpp
|
1501542215d8820ab138cf096ab70840cf9c05d5
|
[] |
no_license
|
SergiuBabin/Laboratoare-EGC
|
0fe460b3b3796f107e2c6925419d47563e28233c
|
34a3a2c4ada97bc2bea41f580439e4c65231db9e
|
refs/heads/main
| 2023-02-19T20:02:49.504528
| 2021-01-26T16:59:32
| 2021-01-26T16:59:32
| 306,819,196
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,358
|
cpp
|
#include "World.h"
#include <Engine.h>
#include <component/CameraInput.h>
#include <defines/Component/Transform.h>
World::World()
{
previousTime = 0;
elapsedTime = 0;
deltaTime = 0;
paused = false;
shouldClose = false;
window = Engine::GetWindow();
}
void World::Run()
{
if (!window)
return;
while (!window->ShouldClose())
{
LoopUpdate();
}
}
void World::Pause()
{
paused = !paused;
}
void World::Exit()
{
shouldClose = true;
window->Close();
}
double World::GetLastFrameTime()
{
return deltaTime;
}
void World::ComputeFrameDeltaTime()
{
elapsedTime = Engine::GetElapsedTime();
deltaTime = elapsedTime - previousTime;
previousTime = elapsedTime;
}
void World::LoopUpdate()
{
// Polls and buffers the events
window->PollEvents();
// Computes frame deltaTime in seconds
ComputeFrameDeltaTime();
// Calls the methods of the instance of InputController in the following order
// OnWindowResize, OnMouseMove, OnMouseBtnPress, OnMouseBtnRelease, OnMouseScroll, OnKeyPress, OnMouseScroll, OnInputUpdate
// OnInputUpdate will be called each frame, the other functions are called only if an event is registered
window->UpdateObservers();
// Frame processing
FrameStart();
Update(static_cast<float>(deltaTime));
FrameEnd();
// Swap front and back buffers - image will be displayed to the screen
window->SwapBuffers();
}
|
[
"48562108+SergiuBabin@users.noreply.github.com"
] |
48562108+SergiuBabin@users.noreply.github.com
|
1fec367340e393be704afee60eafc675a786c90d
|
5456502f97627278cbd6e16d002d50f1de3da7bb
|
/ui/views/window/custom_frame_view_unittest.cc
|
837f23d03c8fcb8ccb6d6114483a6941c2214b0b
|
[
"BSD-3-Clause"
] |
permissive
|
TrellixVulnTeam/Chromium_7C66
|
72d108a413909eb3bd36c73a6c2f98de1573b6e5
|
c8649ab2a0f5a747369ed50351209a42f59672ee
|
refs/heads/master
| 2023-03-16T12:51:40.231959
| 2017-12-20T10:38:26
| 2017-12-20T10:38:26
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,512
|
cc
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/window/custom_frame_view.h"
#include <vector>
#include "base/macros.h"
#include "build/build_config.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/window/window_button_order_provider.h"
namespace views {
namespace {
// Allows for the control of whether or not the widget can minimize/maximize or
// not. This can be set after initial setup in order to allow testing of both
// forms of delegates. By default this can minimize and maximize.
class MinimizeAndMaximizeStateControlDelegate : public WidgetDelegateView {
public:
MinimizeAndMaximizeStateControlDelegate()
: can_maximize_(true),
can_minimize_(true) {}
~MinimizeAndMaximizeStateControlDelegate() override {}
void set_can_maximize(bool can_maximize) {
can_maximize_ = can_maximize;
}
void set_can_minimize(bool can_minimize) {
can_minimize_ = can_minimize;
}
// WidgetDelegate:
bool CanMaximize() const override { return can_maximize_; }
bool CanMinimize() const override { return can_minimize_; }
private:
bool can_maximize_;
bool can_minimize_;
DISALLOW_COPY_AND_ASSIGN(MinimizeAndMaximizeStateControlDelegate);
};
} // namespace
class CustomFrameViewTest : public ViewsTestBase {
public:
CustomFrameViewTest() {}
~CustomFrameViewTest() override {}
CustomFrameView* custom_frame_view() {
return custom_frame_view_;
}
MinimizeAndMaximizeStateControlDelegate*
minimize_and_maximize_state_control_delegate() {
return minimize_and_maximize_state_control_delegate_;
}
Widget* widget() {
return widget_;
}
// ViewsTestBase:
void SetUp() override;
void TearDown() override;
protected:
const std::vector<views::FrameButton>& leading_buttons() {
return WindowButtonOrderProvider::GetInstance()->leading_buttons();
}
const std::vector<views::FrameButton>& trailing_buttons() {
return WindowButtonOrderProvider::GetInstance()->trailing_buttons();
}
ImageButton* minimize_button() {
return custom_frame_view_->minimize_button_;
}
ImageButton* maximize_button() {
return custom_frame_view_->maximize_button_;
}
ImageButton* restore_button() {
return custom_frame_view_->restore_button_;
}
ImageButton* close_button() {
return custom_frame_view_->close_button_;
}
gfx::Rect title_bounds() {
return custom_frame_view_->title_bounds_;
}
void SetWindowButtonOrder(
const std::vector<views::FrameButton> leading_buttons,
const std::vector<views::FrameButton> trailing_buttons);
private:
// Parent container for |custom_frame_view_|
Widget* widget_;
// Owned by |widget_|
CustomFrameView* custom_frame_view_;
// Delegate of |widget_| which controls minimizing and maximizing
MinimizeAndMaximizeStateControlDelegate*
minimize_and_maximize_state_control_delegate_;
DISALLOW_COPY_AND_ASSIGN(CustomFrameViewTest);
};
void CustomFrameViewTest::SetUp() {
ViewsTestBase::SetUp();
minimize_and_maximize_state_control_delegate_ =
new MinimizeAndMaximizeStateControlDelegate;
widget_ = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
params.delegate = minimize_and_maximize_state_control_delegate_;
params.remove_standard_frame = true;
widget_->Init(params);
custom_frame_view_ = new CustomFrameView;
widget_->non_client_view()->SetFrameView(custom_frame_view_);
}
void CustomFrameViewTest::TearDown() {
widget_->CloseNow();
ViewsTestBase::TearDown();
}
void CustomFrameViewTest::SetWindowButtonOrder(
const std::vector<views::FrameButton> leading_buttons,
const std::vector<views::FrameButton> trailing_buttons) {
WindowButtonOrderProvider::GetInstance()->
SetWindowButtonOrder(leading_buttons, trailing_buttons);
}
// Tests that there is a default button ordering before initialization causes
// a configuration file check.
TEST_F(CustomFrameViewTest, DefaultButtons) {
const std::vector<views::FrameButton>& trailing = trailing_buttons();
EXPECT_EQ(trailing.size(), 3u);
EXPECT_TRUE(leading_buttons().empty());
EXPECT_EQ(trailing[0], FRAME_BUTTON_MINIMIZE);
EXPECT_EQ(trailing[1], FRAME_BUTTON_MAXIMIZE);
EXPECT_EQ(trailing[2], FRAME_BUTTON_CLOSE);
}
// Tests that layout places the buttons in order, that the restore button is
// hidden and the buttons are placed after the title.
TEST_F(CustomFrameViewTest, DefaultButtonLayout) {
Widget* parent = widget();
CustomFrameView* view = custom_frame_view();
view->Init(parent);
parent->SetBounds(gfx::Rect(0, 0, 300, 100));
parent->Show();
EXPECT_LT(minimize_button()->x(), maximize_button()->x());
EXPECT_LT(maximize_button()->x(), close_button()->x());
EXPECT_FALSE(restore_button()->visible());
EXPECT_GT(minimize_button()->x(),
title_bounds().x() + title_bounds().width());
}
// Tests that setting the buttons to leading places them before the title.
TEST_F(CustomFrameViewTest, LeadingButtonLayout) {
Widget* parent = widget();
CustomFrameView* view = custom_frame_view();
std::vector<views::FrameButton> leading;
leading.push_back(views::FRAME_BUTTON_CLOSE);
leading.push_back(views::FRAME_BUTTON_MINIMIZE);
leading.push_back(views::FRAME_BUTTON_MAXIMIZE);
std::vector<views::FrameButton> trailing;
SetWindowButtonOrder(leading, trailing);
view->Init(parent);
parent->SetBounds(gfx::Rect(0, 0, 300, 100));
parent->Show();
EXPECT_LT(close_button()->x(), minimize_button()->x());
EXPECT_LT(minimize_button()->x(), maximize_button()->x());
EXPECT_FALSE(restore_button()->visible());
EXPECT_LT(maximize_button()->x() + maximize_button()->width(),
title_bounds().x());
}
// Tests that layouts occurring while maximized swap the maximize button for the
// restore button
TEST_F(CustomFrameViewTest, MaximizeRevealsRestoreButton) {
Widget* parent = widget();
CustomFrameView* view = custom_frame_view();
view->Init(parent);
parent->SetBounds(gfx::Rect(0, 0, 300, 100));
parent->Show();
ASSERT_FALSE(restore_button()->visible());
ASSERT_TRUE(maximize_button()->visible());
parent->Maximize();
view->Layout();
#if defined(OS_MACOSX)
// Restore buttons do not exist on Mac. The maximize button is instead a kind
// of toggle, but has no effect on frame decorations.
EXPECT_FALSE(restore_button()->visible());
EXPECT_TRUE(maximize_button()->visible());
#else
EXPECT_TRUE(restore_button()->visible());
EXPECT_FALSE(maximize_button()->visible());
#endif
}
// Tests that when the parent cannot maximize that the maximize button is not
// visible
TEST_F(CustomFrameViewTest, CannotMaximizeHidesButton) {
Widget* parent = widget();
CustomFrameView* view = custom_frame_view();
MinimizeAndMaximizeStateControlDelegate* delegate =
minimize_and_maximize_state_control_delegate();
delegate->set_can_maximize(false);
view->Init(parent);
parent->SetBounds(gfx::Rect(0, 0, 300, 100));
parent->Show();
EXPECT_FALSE(restore_button()->visible());
EXPECT_FALSE(maximize_button()->visible());
}
// Tests that when the parent cannot minimize that the minimize button is not
// visible
TEST_F(CustomFrameViewTest, CannotMinimizeHidesButton) {
Widget* parent = widget();
CustomFrameView* view = custom_frame_view();
MinimizeAndMaximizeStateControlDelegate* delegate =
minimize_and_maximize_state_control_delegate();
delegate->set_can_minimize(false);
view->Init(parent);
parent->SetBounds(gfx::Rect(0, 0, 300, 100));
parent->Show();
EXPECT_FALSE(minimize_button()->visible());
}
// Tests that when maximized that the edge button has an increased width.
TEST_F(CustomFrameViewTest, LargerEdgeButtonsWhenMaximized) {
Widget* parent = widget();
CustomFrameView* view = custom_frame_view();
// Custom ordering to have a button on each edge.
std::vector<views::FrameButton> leading;
leading.push_back(views::FRAME_BUTTON_CLOSE);
leading.push_back(views::FRAME_BUTTON_MAXIMIZE);
std::vector<views::FrameButton> trailing;
trailing.push_back(views::FRAME_BUTTON_MINIMIZE);
SetWindowButtonOrder(leading, trailing);
view->Init(parent);
parent->SetBounds(gfx::Rect(0, 0, 300, 100));
parent->Show();
gfx::Rect close_button_initial_bounds = close_button()->bounds();
gfx::Rect minimize_button_initial_bounds = minimize_button()->bounds();
parent->Maximize();
view->Layout();
#if defined(OS_MACOSX)
// On Mac, "Maximize" should not alter the frame. Only fullscreen does that.
EXPECT_EQ(close_button()->bounds().width(),
close_button_initial_bounds.width());
EXPECT_EQ(minimize_button()->bounds().width(),
minimize_button_initial_bounds.width());
#else
EXPECT_GT(close_button()->bounds().width(),
close_button_initial_bounds.width());
EXPECT_GT(minimize_button()->bounds().width(),
minimize_button_initial_bounds.width());
#endif
}
} // namespace views
|
[
"lixiaodonglove7@aliyun.com"
] |
lixiaodonglove7@aliyun.com
|
e598bdc4a4cb885ae198c4b9201c8d06b32f85f1
|
fa362c05c4b2a7082668cc1d350e9539dfb1d911
|
/src/robot.cpp
|
c15f7e57fabd45d98112b1f8579b20c74471b82f
|
[
"MIT"
] |
permissive
|
RGoulartns/horus_patrol
|
e7e8eb883e5998750a596ff20f9300ef9f499bcf
|
5c7a5857ea19ad6357ad0d59afd990b3009a9614
|
refs/heads/master
| 2023-02-26T18:16:38.589811
| 2021-02-02T12:37:10
| 2021-02-02T12:37:10
| 120,078,957
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 81
|
cpp
|
#include <include/horus_patrol/robot.hpp>
Robot::Robot()
{
}
Robot::~Robot(){}
|
[
"rgoulartns@gmail.com"
] |
rgoulartns@gmail.com
|
942bde201e97270103b05c0881e5e3dd50bf1477
|
4ba69a1a4d90f476afd70f71367d85ceef72a6ff
|
/graf.h
|
c6e74d9ecc08b001eecc981032f58f402405a31e
|
[] |
no_license
|
mihaiburlaciuc/IMDb-Database-Simulation
|
d7cd40695ed406a8dde177a58c2c80d0910fab9b
|
38c4d8063cb4a9d1001d9bf960fc23846802aeb0
|
refs/heads/master
| 2021-07-08T05:48:15.503532
| 2017-10-05T19:58:06
| 2017-10-05T19:58:06
| 105,933,680
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,589
|
h
|
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
class ActorPairs {
int actor1_id_graf;
string actor1_id;
int actor2_id_graf;
string actor2_id;
int movies_number;
public:
explicit ActorPairs(int actor1_id_graf, int actor2_id_graf,
int movies_number, string actor1_id, string actor2_id) {
this->actor1_id_graf = actor1_id_graf;
this->actor2_id_graf = actor2_id_graf;
this->movies_number = movies_number;
this->actor1_id = actor1_id;
this->actor2_id = actor2_id;
}
ActorPairs(const ActorPairs& obj) {
this->actor1_id_graf = obj.actor1_id_graf;
this->actor2_id_graf = obj.actor2_id_graf;
this->movies_number = obj.movies_number;
this->actor1_id = obj.actor1_id;
this->actor2_id = obj.actor2_id;
}
ActorPairs operator=(const ActorPairs& obj) {
this->actor1_id_graf = obj.actor1_id_graf;
this->actor2_id_graf = obj.actor2_id_graf;
this->movies_number = obj.movies_number;
this->actor1_id = obj.actor1_id;
this->actor2_id = obj.actor2_id;
return *this;
}
int get_movies_number() const{
return movies_number;
}
int get_actor1_id_graf() const{
return actor1_id_graf;
}
int get_actor2_id_graf() const{
return actor2_id_graf;
}
string get_actor1_id() const{
return actor1_id;
}
string get_actor2_id() const{
return actor2_id;
}
bool operator==(const ActorPairs& obj) const{
return (movies_number == obj.movies_number);
}
bool operator<(const ActorPairs& obj) const{
if (movies_number != obj. movies_number) {
return (movies_number > obj.movies_number);
} else {
return actor1_id + actor2_id < obj.actor1_id + obj.actor2_id;
}
}
bool operator>(const ActorPairs& obj) {
return (movies_number > obj.movies_number);
}
bool operator!=(const ActorPairs& obj) {
return (movies_number != obj.movies_number);
}
bool operator>=(const ActorPairs& obj) {
return (movies_number >= obj.movies_number);
}
bool operator<=(const ActorPairs& obj) {
return (movies_number <= obj.movies_number);
}
};
struct Node {
std::vector<int> neighbors;
std::vector<int> movies_played;
};
class Graph {
private:
std::vector<Node> nodes;
public:
void add_node(int node){
Node aux;
nodes.push_back(aux) ;
}
void add_edge(int a, int b) {
std::vector<int>::iterator it ;
it = find(nodes[a].neighbors.begin(),nodes[a].neighbors.end(),b);
if (it == nodes[a].neighbors.end()) {
nodes[a].neighbors.push_back(b);
nodes[a].movies_played.push_back(1);
} else {
unsigned int dist = std::distance(nodes[a].neighbors.begin(), it);
nodes[a].movies_played[dist] += 1;
}
it = find(nodes[b].neighbors.begin(),nodes[b].neighbors.end(),a);
if (it == nodes[b].neighbors.end()) {
nodes[b].neighbors.push_back(a);
nodes[b].movies_played.push_back(1);
} else {
unsigned int dist = std::distance(nodes[b].neighbors.begin(), it);
nodes[b].movies_played[dist] += 1;
}
}
std::vector<ActorPairs> return_all_edges(std::map<int, string> mapForIdGraph) {
std::vector<ActorPairs> tempVector;
for (unsigned int i = 0; i < nodes.size(); i++) {
for (unsigned j = 0; j < nodes[i].neighbors.size(); j++) {
int iInt = (int) i;
int idNeig = nodes[iInt].neighbors[j];
if (mapForIdGraph.find(i) != mapForIdGraph.end()
&& mapForIdGraph.find(idNeig) != mapForIdGraph.end()) {
string actor1 = mapForIdGraph.find(i)->second;
string actor2 = mapForIdGraph.find(idNeig)->second;
std::vector<Node>::iterator it;
int movie_num = nodes[iInt].movies_played[j];
if (actor1 < actor2) {
ActorPairs tempActorPairs(iInt, idNeig, movie_num, actor1,
actor2);
tempVector.push_back(tempActorPairs);
}
}
}
}
return tempVector;
}
// Daca da timeout e din cauza copierii grafului
std::vector<Colleague> return_colleagues(int id, std::map<int, string> mapForIdGraph) {
std::vector<Colleague> tempVector;
for (unsigned int i = 0; i < nodes[id].neighbors.size()
&& i < nodes[id].movies_played.size(); i++) {
Colleague tempColleague(mapForIdGraph.find(nodes[id].neighbors[i])->second,
nodes[id].movies_played[i]);
tempVector.push_back(tempColleague);
}
return tempVector;
}
void print() {
unsigned int i;
unsigned int j;
for (i = 0; i < nodes.size(); i++) {
std::cout<<i<<" = ";
for (j = 0; j < nodes[i].neighbors.size(); j++) {
std::cout<<nodes[i].neighbors[j]<<" - "<<nodes[i].movies_played[j]<<"\n";
}
}
}
int return_edge(int a, int b) {
std::vector<int>::iterator it;
it = find(nodes[a].neighbors.begin(),nodes[a].neighbors.end(),b);
unsigned int dist= -1;
if(it != nodes[a].neighbors.end()) {
//std::cout<<dist<<" ";
dist = std::distance(nodes[a].neighbors.begin(), it);
return nodes[a].movies_played[dist];}
//std::cout<<a<<" "<<b<<" "<<dist<<"DA ";
return 0;
}
std::vector<int> get_movies_played(int node) {
return nodes[node].movies_played;
}
std::vector<int> get_neighbors(int node) {
return nodes[node].neighbors;
}
std::vector<int> bfs(int node) {
unsigned int i;
int element;
std::queue<int> Q;
std::vector<int> a2nd;
int *distanta = new int[nodes.size()];
for (i = 0; i < nodes.size(); i++) {
distanta[i] = -1;
}
distanta[node] = 0;
element = node;
Q.push(node);
while (!Q.empty() && distanta[element] < 2) {
element = Q.front();
//std::cout<<element<<" "<<distanta[element]<<std::flush;
Q.pop();
std::vector<int> vecini = get_neighbors(element);
if (distanta[element] < 2) {
for (i = 0; i < vecini.size(); i++) {
if (distanta[vecini[i]] == -1) {
distanta[vecini[i]] = distanta[element] + 1;
if (distanta[vecini[i]] == 2)
a2nd.push_back(vecini[i]);
Q.push(vecini[i]);
}
}
}
}
delete[] distanta;
return a2nd;
}
};
|
[
"eco.nano10@gmail.com"
] |
eco.nano10@gmail.com
|
ae37343641472470e3a8ce8d8ced38bd5cb9d418
|
3624e9f0a026b57ebdafa4e842b93f56e5a8504d
|
/Hackerrank/Codesprints 2016/Codesprint Aug/Problem F/F.cc
|
afde87103a2696532100c0036f764a6bb3764066
|
[
"MIT"
] |
permissive
|
ailyanlu1/Competitive-Programming-2
|
54109c8644d3ac02715dc4570916b212412c25c0
|
6c990656178fb0cd33354cbe5508164207012f24
|
refs/heads/master
| 2020-03-23T07:48:20.560283
| 2018-02-15T06:49:49
| 2018-02-15T06:49:49
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,816
|
cc
|
#include <bits/stdc++.h>
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define meta __FUNCTION__,__LINE__
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
const long double PI = 3.1415926535897932384626433832795;
template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
void tr(){cout << endl;}
template<typename S, typename ... Strings>
void tr(S x, const Strings&... rest){cout<<x<<' ';tr(rest...);}
typedef long long ll;
typedef pair<int,int> pii;
const int N = 301;
int x[N], y[N], z[N];
int solve1(int n, bool flag){
int k = n / 3;
int j = 0;
for(int i = k; i <= 2*k; i++){
x[j] = i;
y[j] = (2 * k) - 2 * (i - k);
z[j] = n - x[j] - y[j];
j++;
}
for(int i = 0; i < k; i++){
x[j] = k - i - 1;
y[j] = 2 * i + 1;
z[j] = n - x[j] - y[j];
j++;
}
if(flag){
printf("%d\n", j);
for(int i = 0; i < j; i++){
printf("%d %d %d\n", x[i], y[i], z[i]);
}
}
return j;
}
void solve2(int n){
int j = solve1(n-2, false);
for(int i = 0; i < j; i++){
y[i]++; z[i]++;
}
x[j] = n, y[j] = 0, z[j] = 0;
j++;
printf("%d\n", j);
for(int i = 0; i < j; i++){
printf("%d %d %d\n", x[i], y[i], z[i]);
}
}
int main(){
int n;
sd(n);
if(n%3 < 2) solve1(n, true); else solve2(n);
return 0;
}
|
[
"adityapaliwal95@gmail.com"
] |
adityapaliwal95@gmail.com
|
7e21dbdc4b8cbd83c690e8f1becad825af7a58f6
|
090b6ff87a20b1a2885fea8193bccd71fbfdbc8c
|
/rpcwallet.cpp
|
0f802646375bcb0491bad59a172c41d7499d4b53
|
[
"MIT"
] |
permissive
|
LifeShareChain/LifeShare-Chain
|
683d51f985185a7aa0cb5a5530466452d0fe0ced
|
e18ea077153e3eae6c73a31f29a1143a4c9fbbcd
|
refs/heads/master
| 2020-03-12T12:39:41.562119
| 2018-05-08T06:19:01
| 2018-05-08T06:19:01
| 130,623,343
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 62,252
|
cpp
|
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "wallet.h"
#include "walletdb.h"
#include "bitcoinrpc.h"
#include "init.h"
#include "base58.h"
using namespace json_spirit;
using namespace std;
int64 nWalletUnlockTime;
static CCriticalSection cs_nWalletUnlockTime;
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, json_spirit::Object& entry);
std::string HelpRequiringPassphrase()
{
return pwalletMain->IsCrypted()
? "\nrequires wallet passphrase to be set with walletpassphrase first"
: "";
}
void EnsureWalletIsUnlocked()
{
if (pwalletMain->IsLocked())
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
if (fWalletUnlockMintOnly)
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Wallet unlocked for block minting only.");
}
void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
{
int confirms = wtx.GetDepthInMainChain();
entry.push_back(Pair("confirmations", confirms));
if (wtx.IsCoinBase() || wtx.IsCoinStake())
entry.push_back(Pair("generated", true));
if (confirms)
{
entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex()));
entry.push_back(Pair("blockindex", wtx.nIndex));
entry.push_back(Pair("blocktime", (boost::int64_t)(mapBlockIndex[wtx.hashBlock]->nTime)));
}
entry.push_back(Pair("txid", wtx.GetHash().GetHex()));
entry.push_back(Pair("time", (boost::int64_t)wtx.GetTxTime()));
entry.push_back(Pair("timereceived", (boost::int64_t)wtx.nTimeReceived));
BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)
entry.push_back(Pair(item.first, item.second));
}
string AccountFromValue(const Value& value)
{
string strAccount = value.get_str();
if (strAccount == "*")
throw JSONRPCError(RPC_WALLET_INVALID_ACCOUNT_NAME, "Invalid account name");
return strAccount;
}
Value getinfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getinfo\n"
"Returns an object containing various state info.");
proxyType proxy;
GetProxy(NET_IPV4, proxy);
Object obj;
obj.push_back(Pair("version", FormatFullVersion()));
obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
obj.push_back(Pair("newmint", ValueFromAmount(pwalletMain->GetNewMint())));
obj.push_back(Pair("stake", ValueFromAmount(pwalletMain->GetStake())));
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("moneysupply", ValueFromAmount(pindexBest->nMoneySupply)));
obj.push_back(Pair("connections", (int)vNodes.size()));
obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string())));
obj.push_back(Pair("ip", addrSeenByPeer.ToStringIP()));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("testnet", fTestNet));
obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", pwalletMain->GetKeyPoolSize()));
obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee)));
if (pwalletMain->IsCrypted())
obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime / 1000));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
return obj;
}
Value getnewpubkey(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"getnewpubkey [account]\n"
"Returns new public key for coinbase generation.");
// Parse the account first so we don't generate a key if there's an error
string strAccount;
if (params.size() > 0)
strAccount = AccountFromValue(params[0]);
if (!pwalletMain->IsLocked())
pwalletMain->TopUpKeyPool();
// Generate a new key that is added to wallet
CPubKey newKey;
if (!pwalletMain->GetKeyFromPool(newKey, false))
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
CKeyID keyID = newKey.GetID();
pwalletMain->SetAddressBookName(keyID, strAccount);
vector<unsigned char> vchPubKey = newKey.Raw();
return HexStr(vchPubKey.begin(), vchPubKey.end());
}
Value getnewaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"getnewaddress [account]\n"
"Returns a new LSC address for receiving payments. "
"If [account] is specified (recommended), it is added to the address book "
"so payments received with the address will be credited to [account].");
// Parse the account first so we don't generate a key if there's an error
string strAccount;
if (params.size() > 0)
strAccount = AccountFromValue(params[0]);
if (!pwalletMain->IsLocked())
pwalletMain->TopUpKeyPool();
// Generate a new key that is added to wallet
CPubKey newKey;
if (!pwalletMain->GetKeyFromPool(newKey, false))
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
CKeyID keyID = newKey.GetID();
pwalletMain->SetAddressBookName(keyID, strAccount);
return CBitcoinAddress(keyID).ToString();
}
CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false)
{
CWalletDB walletdb(pwalletMain->strWalletFile);
CAccount account;
walletdb.ReadAccount(strAccount, account);
bool bKeyUsed = false;
// Check if the current key has been used
if (account.vchPubKey.IsValid())
{
CScript scriptPubKey;
scriptPubKey.SetDestination(account.vchPubKey.GetID());
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin();
it != pwalletMain->mapWallet.end() && account.vchPubKey.IsValid();
++it)
{
const CWalletTx& wtx = (*it).second;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
if (txout.scriptPubKey == scriptPubKey)
bKeyUsed = true;
}
}
// Generate a new key
if (!account.vchPubKey.IsValid() || bForceNew || bKeyUsed)
{
if (!pwalletMain->GetKeyFromPool(account.vchPubKey, false))
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
pwalletMain->SetAddressBookName(account.vchPubKey.GetID(), strAccount);
walletdb.WriteAccount(strAccount, account);
}
return CBitcoinAddress(account.vchPubKey.GetID());
}
Value getaccountaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"getaccountaddress <account>\n"
"Returns the current LSC address for receiving payments to this account.");
// Parse the account first so we don't generate a key if there's an error
string strAccount = AccountFromValue(params[0]);
Value ret;
ret = GetAccountAddress(strAccount).ToString();
return ret;
}
Value setaccount(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"setaccount <LSCaddress> <account>\n"
"Sets the account associated with the given address.");
CBitcoinAddress address(params[0].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid LSC address");
string strAccount;
if (params.size() > 1)
strAccount = AccountFromValue(params[1]);
// Detect when changing the account of an address that is the 'unused current key' of another account:
if (pwalletMain->mapAddressBook.count(address.Get()))
{
string strOldAccount = pwalletMain->mapAddressBook[address.Get()];
if (address == GetAccountAddress(strOldAccount))
GetAccountAddress(strOldAccount, true);
}
pwalletMain->SetAddressBookName(address.Get(), strAccount);
return Value::null;
}
Value getaccount(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"getaccount <LSCaddress>\n"
"Returns the account associated with the given address.");
CBitcoinAddress address(params[0].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid LSC address");
string strAccount;
map<CTxDestination, string>::iterator mi = pwalletMain->mapAddressBook.find(address.Get());
if (mi != pwalletMain->mapAddressBook.end() && !(*mi).second.empty())
strAccount = (*mi).second;
return strAccount;
}
Value getaddressesbyaccount(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"getaddressesbyaccount <account>\n"
"Returns the list of addresses for the given account.");
string strAccount = AccountFromValue(params[0]);
// Find all addresses that have the given account
Array ret;
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook)
{
const CBitcoinAddress& address = item.first;
const string& strName = item.second;
if (strName == strAccount)
ret.push_back(address.ToString());
}
return ret;
}
Value sendtoaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 4)
throw runtime_error(
"sendtoaddress <LSCaddress> <amount> [comment] [comment-to]\n"
"<amount> is a real and is rounded to the nearest 0.000001"
+ HelpRequiringPassphrase());
CBitcoinAddress address(params[0].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid LSC address");
// Amount
int64 nAmount = AmountFromValue(params[1]);
if (nAmount < MIN_TXOUT_AMOUNT)
throw JSONRPCError(-101, "Send amount too small");
// Wallet comments
CWalletTx wtx;
if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty())
wtx.mapValue["comment"] = params[2].get_str();
if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())
wtx.mapValue["to"] = params[3].get_str();
if (pwalletMain->IsLocked())
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx);
if (strError != "")
throw JSONRPCError(RPC_WALLET_ERROR, strError);
return wtx.GetHash().GetHex();
}
Value sendtoaddressB(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 3 || params.size() > 5)
throw runtime_error(
"sendtoaddress <TestCoinaddress> <amount> <returnCoinaddress> [comment] [comment-to]\n"
"<amount> is a real and is rounded to the nearest 0.000001"
+ HelpRequiringPassphrase());
CBitcoinAddress address(params[0].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid LSC address");
// Amount
int64 nAmount = AmountFromValue(params[1]);
if (nAmount < MIN_TXOUT_AMOUNT)
throw JSONRPCError(-101, "Send amount too small");
CBitcoinAddress address1(params[2].get_str());
if (!address1.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid returncoin address");
// Wallet comments
CWalletTx wtx;
if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())
wtx.mapValue["comment"] = params[3].get_str();
if (params.size() > 4 && params[4].type() != null_type && !params[4].get_str().empty())
wtx.mapValue["to"] = params[4].get_str();
if (pwalletMain->IsLocked())
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
string strError = pwalletMain->SendMoneyToDestinationB(address.Get(),address1.Get(), nAmount, wtx);
if (strError != "")
throw JSONRPCError(RPC_WALLET_ERROR, strError);
return wtx.GetHash().GetHex();
}
Value listaddressgroupings(const Array& params, bool fHelp)
{
if (fHelp)
throw runtime_error(
"listaddressgroupings\n"
"Lists groups of addresses which have had their common ownership\n"
"made public by common use as inputs or as the resulting change\n"
"in past transactions");
Array jsonGroupings;
map<CTxDestination, int64> balances = pwalletMain->GetAddressBalances();
BOOST_FOREACH(set<CTxDestination> grouping, pwalletMain->GetAddressGroupings())
{
Array jsonGrouping;
BOOST_FOREACH(CTxDestination address, grouping)
{
Array addressInfo;
addressInfo.push_back(CBitcoinAddress(address).ToString());
addressInfo.push_back(ValueFromAmount(balances[address]));
{
LOCK(pwalletMain->cs_wallet);
if (pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get()) != pwalletMain->mapAddressBook.end())
addressInfo.push_back(pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get())->second);
}
jsonGrouping.push_back(addressInfo);
}
jsonGroupings.push_back(jsonGrouping);
}
return jsonGroupings;
}
Value signmessage(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 2)
throw runtime_error(
"signmessage <LSCaddress> <message>\n"
"Sign a message with the private key of an address");
EnsureWalletIsUnlocked();
string strAddress = params[0].get_str();
string strMessage = params[1].get_str();
CBitcoinAddress addr(strAddress);
if (!addr.IsValid())
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
CKeyID keyID;
if (!addr.GetKeyID(keyID))
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
CKey key;
if (!pwalletMain->GetKey(keyID, key))
throw JSONRPCError(RPC_WALLET_ERROR, "Private key not available");
CDataStream ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << strMessage;
vector<unsigned char> vchSig;
if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed");
return EncodeBase64(&vchSig[0], vchSig.size());
}
Value verifymessage(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 3)
throw runtime_error(
"verifymessage <LSCaddress> <signature> <message>\n"
"Verify a signed message");
string strAddress = params[0].get_str();
string strSign = params[1].get_str();
string strMessage = params[2].get_str();
CBitcoinAddress addr(strAddress);
if (!addr.IsValid())
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
CKeyID keyID;
if (!addr.GetKeyID(keyID))
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
bool fInvalid = false;
vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid);
if (fInvalid)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
CDataStream ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << strMessage;
CKey key;
if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig))
return false;
return (key.GetPubKey().GetID() == keyID);
}
Value getreceivedbyaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"getreceivedbyaddress <LSCaddress> [minconf=1]\n"
"Returns the total amount received by <LSCaddress> in transactions with at least [minconf] confirmations.");
// Bitcoin address
CBitcoinAddress address = CBitcoinAddress(params[0].get_str());
CScript scriptPubKey;
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid LSC address");
scriptPubKey.SetDestination(address.Get());
if (!IsMine(*pwalletMain,scriptPubKey))
return (double)0.0;
// Minimum confirmations
int nMinDepth = 1;
if (params.size() > 1)
nMinDepth = params[1].get_int();
// Tally
int64 nAmount = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
if (wtx.IsCoinBase() || wtx.IsCoinStake() || !wtx.IsFinal())
continue;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
if (txout.scriptPubKey == scriptPubKey)
if (wtx.GetDepthInMainChain() >= nMinDepth)
nAmount += txout.nValue;
}
return ValueFromAmount(nAmount);
}
void GetAccountAddresses(string strAccount, set<CTxDestination>& setAddress)
{
BOOST_FOREACH(const PAIRTYPE(CTxDestination, string)& item, pwalletMain->mapAddressBook)
{
const CTxDestination& address = item.first;
const string& strName = item.second;
if (strName == strAccount)
setAddress.insert(address);
}
}
Value getreceivedbyaccount(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"getreceivedbyaccount <account> [minconf=1]\n"
"Returns the total amount received by addresses with <account> in transactions with at least [minconf] confirmations.");
// Minimum confirmations
int nMinDepth = 1;
if (params.size() > 1)
nMinDepth = params[1].get_int();
// Get the set of pub keys assigned to account
string strAccount = AccountFromValue(params[0]);
set<CTxDestination> setAddress;
GetAccountAddresses(strAccount, setAddress);
// Tally
int64 nAmount = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
if (wtx.IsCoinBase() || wtx.IsCoinStake() || !wtx.IsFinal())
continue;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
CTxDestination address;
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwalletMain, address) && setAddress.count(address))
if (wtx.GetDepthInMainChain() >= nMinDepth)
nAmount += txout.nValue;
}
}
return (double)nAmount / (double)COIN;
}
int64 GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth)
{
int64 nBalance = 0;
// Tally wallet transactions
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
if (!wtx.IsFinal())
continue;
int64 nGenerated, nReceived, nSent, nFee;
wtx.GetAccountAmounts(strAccount, nGenerated, nReceived, nSent, nFee);
if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)
nBalance += nReceived;
nBalance += nGenerated - nSent - nFee;
}
// Tally internal accounting entries
nBalance += walletdb.GetAccountCreditDebit(strAccount);
return nBalance;
}
int64 GetAccountBalance(const string& strAccount, int nMinDepth)
{
CWalletDB walletdb(pwalletMain->strWalletFile);
return GetAccountBalance(walletdb, strAccount, nMinDepth);
}
Value getbalance(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
"getbalance [account] [minconf=1]\n"
"If [account] is not specified, returns the server's total available balance.\n"
"If [account] is specified, returns the balance in the account.");
if (params.size() == 0)
return ValueFromAmount(pwalletMain->GetBalance());
int nMinDepth = 1;
if (params.size() > 1)
nMinDepth = params[1].get_int();
if (params[0].get_str() == "*") {
// Calculate total balance a different way from GetBalance()
// (GetBalance() sums up all unspent TxOuts)
// getbalance and getbalance '*' should always return the same number.
int64 nBalance = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
if (!wtx.IsFinal())
continue;
int64 allGeneratedImmature, allGeneratedMature, allFee;
allGeneratedImmature = allGeneratedMature = allFee = 0;
string strSentAccount;
list<pair<CTxDestination, int64> > listReceived;
list<pair<CTxDestination, int64> > listSent;
wtx.GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount);
if (wtx.GetDepthInMainChain() >= nMinDepth)
{
BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& r, listReceived)
nBalance += r.second;
}
BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& r, listSent)
nBalance -= r.second;
nBalance -= allFee;
nBalance += allGeneratedMature;
}
return ValueFromAmount(nBalance);
}
string strAccount = AccountFromValue(params[0]);
int64 nBalance = GetAccountBalance(strAccount, nMinDepth);
return ValueFromAmount(nBalance);
}
Value movecmd(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 3 || params.size() > 5)
throw runtime_error(
"move <fromaccount> <toaccount> <amount> [minconf=1] [comment]\n"
"Move from one account in your wallet to another.");
string strFrom = AccountFromValue(params[0]);
string strTo = AccountFromValue(params[1]);
int64 nAmount = AmountFromValue(params[2]);
if (nAmount < MIN_TXOUT_AMOUNT)
throw JSONRPCError(-101, "Send amount too small");
if (params.size() > 3)
// unused parameter, used to be nMinDepth, keep type-checking it though
(void)params[3].get_int();
string strComment;
if (params.size() > 4)
strComment = params[4].get_str();
CWalletDB walletdb(pwalletMain->strWalletFile);
if (!walletdb.TxnBegin())
throw JSONRPCError(RPC_DATABASE_ERROR, "database error");
int64 nNow = GetAdjustedTime();
// Debit
CAccountingEntry debit;
debit.nOrderPos = pwalletMain->IncOrderPosNext(&walletdb);
debit.strAccount = strFrom;
debit.nCreditDebit = -nAmount;
debit.nTime = nNow;
debit.strOtherAccount = strTo;
debit.strComment = strComment;
walletdb.WriteAccountingEntry(debit);
// Credit
CAccountingEntry credit;
credit.nOrderPos = pwalletMain->IncOrderPosNext(&walletdb);
credit.strAccount = strTo;
credit.nCreditDebit = nAmount;
credit.nTime = nNow;
credit.strOtherAccount = strFrom;
credit.strComment = strComment;
walletdb.WriteAccountingEntry(credit);
if (!walletdb.TxnCommit())
throw JSONRPCError(RPC_DATABASE_ERROR, "database error");
return true;
}
Value sendfrom(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 3 || params.size() > 6)
throw runtime_error(
"sendfrom <fromaccount> <toLSCaddress> <amount> [minconf=1] [comment] [comment-to]\n"
"<amount> is a real and is rounded to the nearest 0.000001"
+ HelpRequiringPassphrase());
string strAccount = AccountFromValue(params[0]);
CBitcoinAddress address(params[1].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid LSC address");
int64 nAmount = AmountFromValue(params[2]);
if (nAmount < MIN_TXOUT_AMOUNT)
throw JSONRPCError(-101, "Send amount too small");
int nMinDepth = 1;
if (params.size() > 3)
nMinDepth = params[3].get_int();
CWalletTx wtx;
wtx.strFromAccount = strAccount;
if (params.size() > 4 && params[4].type() != null_type && !params[4].get_str().empty())
wtx.mapValue["comment"] = params[4].get_str();
if (params.size() > 5 && params[5].type() != null_type && !params[5].get_str().empty())
wtx.mapValue["to"] = params[5].get_str();
EnsureWalletIsUnlocked();
// Check funds
int64 nBalance = GetAccountBalance(strAccount, nMinDepth);
if (nAmount > nBalance)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
// Send
string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx);
if (strError != "")
throw JSONRPCError(RPC_WALLET_ERROR, strError);
return wtx.GetHash().GetHex();
}
Value sendmany(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 4)
throw runtime_error(
"sendmany <fromaccount> {address:amount,...} [minconf=1] [comment]\n"
"amounts are double-precision floating point numbers"
+ HelpRequiringPassphrase());
string strAccount = AccountFromValue(params[0]);
Object sendTo = params[1].get_obj();
int nMinDepth = 1;
if (params.size() > 2)
nMinDepth = params[2].get_int();
CWalletTx wtx;
wtx.strFromAccount = strAccount;
if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())
wtx.mapValue["comment"] = params[3].get_str();
set<CBitcoinAddress> setAddress;
vector<pair<CScript, int64> > vecSend;
int64 totalAmount = 0;
BOOST_FOREACH(const Pair& s, sendTo)
{
CBitcoinAddress address(s.name_);
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid LSC address: ")+s.name_);
if (setAddress.count(address))
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_);
setAddress.insert(address);
CScript scriptPubKey;
scriptPubKey.SetDestination(address.Get());
int64 nAmount = AmountFromValue(s.value_);
if (nAmount < MIN_TXOUT_AMOUNT)
throw JSONRPCError(-101, "Send amount too small");
totalAmount += nAmount;
vecSend.push_back(make_pair(scriptPubKey, nAmount));
}
EnsureWalletIsUnlocked();
// Check funds
int64 nBalance = GetAccountBalance(strAccount, nMinDepth);
if (totalAmount > nBalance)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
// Send
CReserveKey keyChange(pwalletMain);
int64 nFeeRequired = 0;
bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired);
if (!fCreated)
{
if (totalAmount + nFeeRequired > pwalletMain->GetBalance())
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
throw JSONRPCError(RPC_WALLET_ERROR, "Transaction creation failed");
}
if (!pwalletMain->CommitTransaction(wtx, keyChange))
throw JSONRPCError(RPC_WALLET_ERROR, "Transaction commit failed");
return wtx.GetHash().GetHex();
}
Value addmultisigaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 3)
{
string msg = "addmultisigaddress <nrequired> <'[\"key\",\"key\"]'> [account]\n"
"Add a nrequired-to-sign multisignature address to the wallet\"\n"
"each key is a LSC address or hex-encoded public key\n"
"If [account] is specified, assign address to [account].";
throw runtime_error(msg);
}
int nRequired = params[0].get_int();
const Array& keys = params[1].get_array();
string strAccount;
if (params.size() > 2)
strAccount = AccountFromValue(params[2]);
// Gather public keys
if (nRequired < 1)
throw runtime_error("a multisignature address must require at least one key to redeem");
if ((int)keys.size() < nRequired)
throw runtime_error(
strprintf("not enough keys supplied "
"(got %"PRIszu" keys, but need at least %d to redeem)", keys.size(), nRequired));
std::vector<CKey> pubkeys;
pubkeys.resize(keys.size());
for (unsigned int i = 0; i < keys.size(); i++)
{
const std::string& ks = keys[i].get_str();
// Case 1: Bitcoin address and we have full public key:
CBitcoinAddress address(ks);
if (address.IsValid())
{
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw runtime_error(
strprintf("%s does not refer to a key",ks.c_str()));
CPubKey vchPubKey;
if (!pwalletMain->GetPubKey(keyID, vchPubKey))
throw runtime_error(
strprintf("no full public key for address %s",ks.c_str()));
if (!vchPubKey.IsValid() || !pubkeys[i].SetPubKey(vchPubKey))
throw runtime_error(" Invalid public key: "+ks);
}
// Case 2: hex public key
else if (IsHex(ks))
{
CPubKey vchPubKey(ParseHex(ks));
if (!vchPubKey.IsValid() || !pubkeys[i].SetPubKey(vchPubKey))
throw runtime_error(" Invalid public key: "+ks);
}
else
{
throw runtime_error(" Invalid public key: "+ks);
}
}
// Construct using pay-to-script-hash:
CScript inner;
inner.SetMultisig(nRequired, pubkeys);
CScriptID innerID = inner.GetID();
pwalletMain->AddCScript(inner);
pwalletMain->SetAddressBookName(innerID, strAccount);
return CBitcoinAddress(innerID).ToString();
}
struct tallyitem
{
int64 nAmount;
int nConf;
tallyitem()
{
nAmount = 0;
nConf = std::numeric_limits<int>::max();
}
};
Value ListReceived(const Array& params, bool fByAccounts)
{
// Minimum confirmations
int nMinDepth = 1;
if (params.size() > 0)
nMinDepth = params[0].get_int();
// Whether to include empty accounts
bool fIncludeEmpty = false;
if (params.size() > 1)
fIncludeEmpty = params[1].get_bool();
// Tally
map<CBitcoinAddress, tallyitem> mapTally;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
if (wtx.IsCoinBase() || wtx.IsCoinStake() || !wtx.IsFinal())
continue;
int nDepth = wtx.GetDepthInMainChain();
if (nDepth < nMinDepth)
continue;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
CTxDestination address;
if (!ExtractDestination(txout.scriptPubKey, address) || !IsMine(*pwalletMain, address))
continue;
tallyitem& item = mapTally[address];
item.nAmount += txout.nValue;
item.nConf = min(item.nConf, nDepth);
}
}
// Reply
Array ret;
map<string, tallyitem> mapAccountTally;
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook)
{
const CBitcoinAddress& address = item.first;
const string& strAccount = item.second;
map<CBitcoinAddress, tallyitem>::iterator it = mapTally.find(address);
if (it == mapTally.end() && !fIncludeEmpty)
continue;
int64 nAmount = 0;
int nConf = std::numeric_limits<int>::max();
if (it != mapTally.end())
{
nAmount = (*it).second.nAmount;
nConf = (*it).second.nConf;
}
if (fByAccounts)
{
tallyitem& item = mapAccountTally[strAccount];
item.nAmount += nAmount;
item.nConf = min(item.nConf, nConf);
}
else
{
Object obj;
obj.push_back(Pair("address", address.ToString()));
obj.push_back(Pair("account", strAccount));
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
ret.push_back(obj);
}
}
if (fByAccounts)
{
for (map<string, tallyitem>::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it)
{
int64 nAmount = (*it).second.nAmount;
int nConf = (*it).second.nConf;
Object obj;
obj.push_back(Pair("account", (*it).first));
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
ret.push_back(obj);
}
}
return ret;
}
Value listreceivedbyaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
"listreceivedbyaddress [minconf=1] [includeempty=false]\n"
"[minconf] is the minimum number of confirmations before payments are included.\n"
"[includeempty] whether to include addresses that haven't received any payments.\n"
"Returns an array of objects containing:\n"
" \"address\" : receiving address\n"
" \"account\" : the account of the receiving address\n"
" \"amount\" : total amount received by the address\n"
" \"confirmations\" : number of confirmations of the most recent transaction included");
return ListReceived(params, false);
}
Value listreceivedbyaccount(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
"listreceivedbyaccount [minconf=1] [includeempty=false]\n"
"[minconf] is the minimum number of confirmations before payments are included.\n"
"[includeempty] whether to include accounts that haven't received any payments.\n"
"Returns an array of objects containing:\n"
" \"account\" : the account of the receiving addresses\n"
" \"amount\" : total amount received by addresses with this account\n"
" \"confirmations\" : number of confirmations of the most recent transaction included");
return ListReceived(params, true);
}
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret)
{
int64 nGeneratedImmature, nGeneratedMature, nFee;
string strSentAccount;
list<pair<CTxDestination, int64> > listReceived;
list<pair<CTxDestination, int64> > listSent;
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount);
bool fAllAccounts = (strAccount == string("*"));
// Generated blocks assigned to account ""
if ((nGeneratedMature+nGeneratedImmature) != 0 && (fAllAccounts || strAccount == ""))
{
Object entry;
entry.push_back(Pair("account", string("")));
if (nGeneratedImmature)
{
entry.push_back(Pair("category", wtx.GetDepthInMainChain() ? "immature" : "orphan"));
entry.push_back(Pair("amount", ValueFromAmount(nGeneratedImmature)));
}
else
{
entry.push_back(Pair("category", "generate"));
entry.push_back(Pair("amount", ValueFromAmount(nGeneratedMature)));
}
if (fLong)
WalletTxToJSON(wtx, entry);
ret.push_back(entry);
}
// Sent
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
{
BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& s, listSent)
{
Object entry;
entry.push_back(Pair("account", strSentAccount));
entry.push_back(Pair("address", CBitcoinAddress(s.first).ToString()));
entry.push_back(Pair("category", "send"));
entry.push_back(Pair("amount", ValueFromAmount(-s.second)));
entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
if (fLong)
WalletTxToJSON(wtx, entry);
ret.push_back(entry);
}
}
// Received
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
{
BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& r, listReceived)
{
string account;
if (pwalletMain->mapAddressBook.count(r.first))
account = pwalletMain->mapAddressBook[r.first];
if (fAllAccounts || (account == strAccount))
{
Object entry;
entry.push_back(Pair("account", account));
entry.push_back(Pair("address", CBitcoinAddress(r.first).ToString()));
if (wtx.IsCoinBase())
{
if (wtx.GetDepthInMainChain() < 1)
entry.push_back(Pair("category", "orphan"));
else if (wtx.GetBlocksToMaturity() > 0)
entry.push_back(Pair("category", "immature"));
else
entry.push_back(Pair("category", "generate"));
}
else
entry.push_back(Pair("category", "receive"));
entry.push_back(Pair("amount", ValueFromAmount(r.second)));
if (fLong)
WalletTxToJSON(wtx, entry);
ret.push_back(entry);
}
}
}
}
void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Array& ret)
{
bool fAllAccounts = (strAccount == string("*"));
if (fAllAccounts || acentry.strAccount == strAccount)
{
Object entry;
entry.push_back(Pair("account", acentry.strAccount));
entry.push_back(Pair("category", "move"));
entry.push_back(Pair("time", (boost::int64_t)acentry.nTime));
entry.push_back(Pair("amount", ValueFromAmount(acentry.nCreditDebit)));
entry.push_back(Pair("otheraccount", acentry.strOtherAccount));
entry.push_back(Pair("comment", acentry.strComment));
ret.push_back(entry);
}
}
Value listtransactions(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 3)
throw runtime_error(
"listtransactions [account] [count=10] [from=0]\n"
"Returns up to [count] most recent transactions skipping the first [from] transactions for account [account].");
string strAccount = "*";
if (params.size() > 0)
strAccount = params[0].get_str();
if(strAccount == string("'*'"))
strAccount = "*";
int nCount = 10;
if (params.size() > 1)
nCount = params[1].get_int();
int nFrom = 0;
if (params.size() > 2)
nFrom = params[2].get_int();
if (nCount < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count");
if (nFrom < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative from");
Array ret;
std::list<CAccountingEntry> acentries;
CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(acentries, strAccount);
// iterate backwards until we have nCount items to return:
for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
{
CWalletTx *const pwtx = (*it).second.first;
if (pwtx != 0)
ListTransactions(*pwtx, strAccount, 0, true, ret);
CAccountingEntry *const pacentry = (*it).second.second;
if (pacentry != 0)
AcentryToJSON(*pacentry, strAccount, ret);
if ((int)ret.size() >= (nCount+nFrom)) break;
}
// ret is newest to oldest
if (nFrom > (int)ret.size())
nFrom = ret.size();
if ((nFrom + nCount) > (int)ret.size())
nCount = ret.size() - nFrom;
Array::iterator first = ret.begin();
std::advance(first, nFrom);
Array::iterator last = ret.begin();
std::advance(last, nFrom+nCount);
if (last != ret.end()) ret.erase(last, ret.end());
if (first != ret.begin()) ret.erase(ret.begin(), first);
std::reverse(ret.begin(), ret.end()); // Return oldest to newest
return ret;
}
Value listaccounts(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"listaccounts [minconf=1]\n"
"Returns Object that has account names as keys, account balances as values.");
int nMinDepth = 1;
if (params.size() > 0)
nMinDepth = params[0].get_int();
map<string, int64> mapAccountBalances;
BOOST_FOREACH(const PAIRTYPE(CTxDestination, string)& entry, pwalletMain->mapAddressBook) {
if (IsMine(*pwalletMain, entry.first)) // This address belongs to me
mapAccountBalances[entry.second] = 0;
}
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
int64 nGeneratedImmature, nGeneratedMature, nFee;
string strSentAccount;
list<pair<CTxDestination, int64> > listReceived;
list<pair<CTxDestination, int64> > listSent;
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount);
mapAccountBalances[strSentAccount] -= nFee;
BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& s, listSent)
mapAccountBalances[strSentAccount] -= s.second;
if (wtx.GetDepthInMainChain() >= nMinDepth)
{
mapAccountBalances[""] += nGeneratedMature;
BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& r, listReceived)
if (pwalletMain->mapAddressBook.count(r.first))
mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second;
else
mapAccountBalances[""] += r.second;
}
}
list<CAccountingEntry> acentries;
CWalletDB(pwalletMain->strWalletFile).ListAccountCreditDebit("*", acentries);
BOOST_FOREACH(const CAccountingEntry& entry, acentries)
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
Object ret;
BOOST_FOREACH(const PAIRTYPE(string, int64)& accountBalance, mapAccountBalances) {
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
}
return ret;
}
Value listsinceblock(const Array& params, bool fHelp)
{
if (fHelp)
throw runtime_error(
"listsinceblock [blockhash] [target-confirmations]\n"
"Get all transactions in blocks since block [blockhash], or all transactions if omitted");
CBlockIndex *pindex = NULL;
int target_confirms = 1;
if (params.size() > 0)
{
uint256 blockId = 0;
blockId.SetHex(params[0].get_str());
pindex = CBlockLocator(blockId).GetBlockIndex();
}
if (params.size() > 1)
{
target_confirms = params[1].get_int();
if (target_confirms < 1)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter");
}
int depth = pindex ? (1 + nBestHeight - pindex->nHeight) : -1;
Array transactions;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); it++)
{
CWalletTx tx = (*it).second;
if (depth == -1 || tx.GetDepthInMainChain() < depth)
ListTransactions(tx, "*", 0, true, transactions);
}
uint256 lastblock;
if (target_confirms == 1)
{
lastblock = hashBestChain;
}
else
{
int target_height = pindexBest->nHeight + 1 - target_confirms;
CBlockIndex *block;
for (block = pindexBest;
block && block->nHeight > target_height;
block = block->pprev) { }
lastblock = block ? block->GetBlockHash() : 0;
}
Object ret;
ret.push_back(Pair("transactions", transactions));
ret.push_back(Pair("lastblock", lastblock.GetHex()));
return ret;
}
Value gettransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"gettransaction <txid>\n"
"Get detailed information about <txid>");
uint256 hash;
hash.SetHex(params[0].get_str());
Object entry;
if (pwalletMain->mapWallet.count(hash))
{
const CWalletTx& wtx = pwalletMain->mapWallet[hash];
TxToJSON(wtx, 0, entry);
int64 nCredit = wtx.GetCredit();
int64 nDebit = wtx.GetDebit();
int64 nNet = nCredit - nDebit;
int64 nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0);
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
if (wtx.IsFromMe())
entry.push_back(Pair("fee", ValueFromAmount(nFee)));
WalletTxToJSON(wtx, entry);
Array details;
ListTransactions(pwalletMain->mapWallet[hash], "*", 0, false, details);
entry.push_back(Pair("details", details));
}
else
{
CTransaction tx;
uint256 hashBlock = 0;
if (GetTransaction(hash, tx, hashBlock))
{
entry.push_back(Pair("txid", hash.GetHex()));
TxToJSON(tx, 0, entry);
if (hashBlock == 0)
entry.push_back(Pair("confirmations", 0));
else
{
entry.push_back(Pair("blockhash", hashBlock.GetHex()));
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && (*mi).second)
{
CBlockIndex* pindex = (*mi).second;
if (pindex->IsInMainChain())
{
entry.push_back(Pair("confirmations", 1 + nBestHeight - pindex->nHeight));
entry.push_back(Pair("txntime", (boost::int64_t)tx.nTime));
entry.push_back(Pair("time", (boost::int64_t)pindex->nTime));
}
else
entry.push_back(Pair("confirmations", 0));
}
}
}
else
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
}
return entry;
}
Value backupwallet(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"backupwallet <destination>\n"
"Safely copies wallet.dat to destination, which can be a directory or a path with filename.");
string strDest = params[0].get_str();
if (!BackupWallet(*pwalletMain, strDest))
throw JSONRPCError(RPC_WALLET_ERROR, "Error: Wallet backup failed!");
return Value::null;
}
Value keypoolrefill(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 0)
throw runtime_error(
"keypoolrefill\n"
"Fills the keypool."
+ HelpRequiringPassphrase());
EnsureWalletIsUnlocked();
pwalletMain->TopUpKeyPool();
if (pwalletMain->GetKeyPoolSize() < GetArg("-keypool", 100))
throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool.");
return Value::null;
}
void ThreadTopUpKeyPool(void* parg)
{
// Make this thread recognisable as the key-topping-up thread
RenameThread("bitcoin-key-top");
pwalletMain->TopUpKeyPool();
}
void ThreadCleanWalletPassphrase(void* parg)
{
// Make this thread recognisable as the wallet relocking thread
RenameThread("bitcoin-lock-wa");
int64 nMyWakeTime = GetTimeMillis() + *((int64*)parg) * 1000;
ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime);
if (nWalletUnlockTime == 0)
{
nWalletUnlockTime = nMyWakeTime;
do
{
if (nWalletUnlockTime==0)
break;
int64 nToSleep = nWalletUnlockTime - GetTimeMillis();
if (nToSleep <= 0)
break;
LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime);
Sleep(nToSleep);
ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime);
} while(1);
if (nWalletUnlockTime)
{
nWalletUnlockTime = 0;
pwalletMain->Lock();
}
}
else
{
if (nWalletUnlockTime < nMyWakeTime)
nWalletUnlockTime = nMyWakeTime;
}
LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime);
delete (int64*)parg;
}
Value walletpassphrase(const Array& params, bool fHelp)
{
if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 3))
throw runtime_error(
"walletpassphrase <passphrase> <timeout> [mintonly]\n"
"Stores the wallet decryption key in memory for <timeout> seconds.\n"
"mintonly is optional true/false allowing only block minting.");
if (fHelp)
return true;
if (!pwalletMain->IsCrypted())
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrase was called.");
if (!pwalletMain->IsLocked())
throw JSONRPCError(RPC_WALLET_ALREADY_UNLOCKED, "Error: Wallet is already unlocked, use walletlock first if need to change unlock settings.");
// Note that the walletpassphrase is stored in params[0] which is not mlock()ed
SecureString strWalletPass;
strWalletPass.reserve(100);
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
// Alternately, find a way to make params[0] mlock()'d to begin with.
strWalletPass = params[0].get_str().c_str();
if (strWalletPass.length() > 0)
{
if (!pwalletMain->Unlock(strWalletPass))
throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect.");
}
else
throw runtime_error(
"walletpassphrase <passphrase> <timeout>\n"
"Stores the wallet decryption key in memory for <timeout> seconds.");
NewThread(ThreadTopUpKeyPool, NULL);
int64* pnSleepTime = new int64(params[1].get_int64());
NewThread(ThreadCleanWalletPassphrase, pnSleepTime);
// ppcoin: if user OS account compromised prevent trivial sendmoney commands
if (params.size() > 2)
fWalletUnlockMintOnly = params[2].get_bool();
else
fWalletUnlockMintOnly = false;
return Value::null;
}
Value walletpassphrasechange(const Array& params, bool fHelp)
{
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
throw runtime_error(
"walletpassphrasechange <oldpassphrase> <newpassphrase>\n"
"Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>.");
if (fHelp)
return true;
if (!pwalletMain->IsCrypted())
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrasechange was called.");
// TODO: get rid of these .c_str() calls by implementing SecureString::operator=(std::string)
// Alternately, find a way to make params[0] mlock()'d to begin with.
SecureString strOldWalletPass;
strOldWalletPass.reserve(100);
strOldWalletPass = params[0].get_str().c_str();
SecureString strNewWalletPass;
strNewWalletPass.reserve(100);
strNewWalletPass = params[1].get_str().c_str();
if (strOldWalletPass.length() < 1 || strNewWalletPass.length() < 1)
throw runtime_error(
"walletpassphrasechange <oldpassphrase> <newpassphrase>\n"
"Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>.");
if (!pwalletMain->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass))
throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect.");
return Value::null;
}
Value walletlock(const Array& params, bool fHelp)
{
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0))
throw runtime_error(
"walletlock\n"
"Removes the wallet encryption key from memory, locking the wallet.\n"
"After calling this method, you will need to call walletpassphrase again\n"
"before being able to call any methods which require the wallet to be unlocked.");
if (fHelp)
return true;
if (!pwalletMain->IsCrypted())
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called.");
{
LOCK(cs_nWalletUnlockTime);
pwalletMain->Lock();
nWalletUnlockTime = 0;
}
return Value::null;
}
Value encryptwallet(const Array& params, bool fHelp)
{
if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1))
throw runtime_error(
"encryptwallet <passphrase>\n"
"Encrypts the wallet with <passphrase>.");
if (fHelp)
return true;
if (pwalletMain->IsCrypted())
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called.");
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
// Alternately, find a way to make params[0] mlock()'d to begin with.
SecureString strWalletPass;
strWalletPass.reserve(100);
strWalletPass = params[0].get_str().c_str();
if (strWalletPass.length() < 1)
throw runtime_error(
"encryptwallet <passphrase>\n"
"Encrypts the wallet with <passphrase>.");
if (!pwalletMain->EncryptWallet(strWalletPass))
throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: Failed to encrypt the wallet.");
// BDB seems to have a bad habit of writing old data into
// slack space in .dat files; that is bad if the old data is
// unencrypted private keys. So:
StartShutdown();
return "wallet encrypted; LSC server stopping, restart to run with encrypted wallet. The keypool has been flushed, you need to make a new backup.";
}
class DescribeAddressVisitor : public boost::static_visitor<Object>
{
public:
Object operator()(const CNoDestination &dest) const { return Object(); }
Object operator()(const CKeyID &keyID) const {
Object obj;
CPubKey vchPubKey;
pwalletMain->GetPubKey(keyID, vchPubKey);
obj.push_back(Pair("isscript", false));
obj.push_back(Pair("pubkey", HexStr(vchPubKey.Raw())));
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
return obj;
}
Object operator()(const CScriptID &scriptID) const {
Object obj;
obj.push_back(Pair("isscript", true));
CScript subscript;
pwalletMain->GetCScript(scriptID, subscript);
std::vector<CTxDestination> addresses;
txnouttype whichType;
int nRequired;
ExtractDestinations(subscript, whichType, addresses, nRequired);
obj.push_back(Pair("script", GetTxnOutputType(whichType)));
Array a;
BOOST_FOREACH(const CTxDestination& addr, addresses)
a.push_back(CBitcoinAddress(addr).ToString());
obj.push_back(Pair("addresses", a));
if (whichType == TX_MULTISIG)
obj.push_back(Pair("sigsrequired", nRequired));
return obj;
}
};
Value validateaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"validateaddress <LSCaddress>\n"
"Return information about <LSCaddress>.");
CBitcoinAddress address(params[0].get_str());
bool isValid = address.IsValid();
Object ret;
ret.push_back(Pair("isvalid", isValid));
if (isValid)
{
CTxDestination dest = address.Get();
string currentAddress = address.ToString();
ret.push_back(Pair("address", currentAddress));
bool fMine = IsMine(*pwalletMain, dest);
ret.push_back(Pair("ismine", fMine));
if (fMine) {
Object detail = boost::apply_visitor(DescribeAddressVisitor(), dest);
ret.insert(ret.end(), detail.begin(), detail.end());
}
if (pwalletMain->mapAddressBook.count(dest))
ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest]));
}
return ret;
}
Value validatepubkey(const Array& params, bool fHelp)
{
if (fHelp || !params.size() || params.size() > 2)
throw runtime_error(
"validatepubkey <LSCpubkey>\n"
"Return information about <LSCpubkey>.");
std::vector<unsigned char> vchPubKey = ParseHex(params[0].get_str());
CPubKey pubKey(vchPubKey);
bool isValid = pubKey.IsValid();
bool isCompressed = pubKey.IsCompressed();
CKeyID keyID = pubKey.GetID();
CBitcoinAddress address;
address.Set(keyID);
Object ret;
ret.push_back(Pair("isvalid", isValid));
if (isValid)
{
CTxDestination dest = address.Get();
string currentAddress = address.ToString();
ret.push_back(Pair("address", currentAddress));
bool fMine = IsMine(*pwalletMain, dest);
ret.push_back(Pair("ismine", fMine));
ret.push_back(Pair("iscompressed", isCompressed));
if (fMine) {
Object detail = boost::apply_visitor(DescribeAddressVisitor(), dest);
ret.insert(ret.end(), detail.begin(), detail.end());
}
if (pwalletMain->mapAddressBook.count(dest))
ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest]));
}
return ret;
}
// ppcoin: reserve balance from being staked for network protection
Value reservebalance(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
"reservebalance [<reserve> [amount]]\n"
"<reserve> is true or false to turn balance reserve on or off.\n"
"<amount> is a real and rounded to cent.\n"
"Set reserve amount not participating in network protection.\n"
"If no parameters provided current setting is printed.\n");
if (params.size() > 0)
{
bool fReserve = params[0].get_bool();
if (fReserve)
{
if (params.size() == 1)
throw runtime_error("must provide amount to reserve balance.\n");
int64 nAmount = AmountFromValue(params[1]);
nAmount = (nAmount / CENT) * CENT; // round to cent
if (nAmount < 0)
throw runtime_error("amount cannot be negative.\n");
mapArgs["-reservebalance"] = FormatMoney(nAmount).c_str();
}
else
{
if (params.size() > 1)
throw runtime_error("cannot specify amount to turn off reserve.\n");
mapArgs["-reservebalance"] = "0";
}
}
Object result;
int64 nReserveBalance = 0;
if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
throw runtime_error("invalid reserve balance amount\n");
result.push_back(Pair("reserve", (nReserveBalance > 0)));
result.push_back(Pair("amount", ValueFromAmount(nReserveBalance)));
return result;
}
// ppcoin: check wallet integrity
Value checkwallet(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 0)
throw runtime_error(
"checkwallet\n"
"Check wallet for integrity.\n");
int nMismatchSpent;
int64 nBalanceInQuestion;
pwalletMain->FixSpentCoins(nMismatchSpent, nBalanceInQuestion, true);
Object result;
if (nMismatchSpent == 0)
result.push_back(Pair("wallet check passed", true));
else
{
result.push_back(Pair("mismatched spent coins", nMismatchSpent));
result.push_back(Pair("amount in question", ValueFromAmount(nBalanceInQuestion)));
}
return result;
}
// ppcoin: repair wallet
Value repairwallet(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 0)
throw runtime_error(
"repairwallet\n"
"Repair wallet if checkwallet reports any problem.\n");
int nMismatchSpent;
int64 nBalanceInQuestion;
pwalletMain->FixSpentCoins(nMismatchSpent, nBalanceInQuestion);
Object result;
if (nMismatchSpent == 0)
result.push_back(Pair("wallet check passed", true));
else
{
result.push_back(Pair("mismatched spent coins", nMismatchSpent));
result.push_back(Pair("amount affected by repair", ValueFromAmount(nBalanceInQuestion)));
}
return result;
}
// LSC: resend unconfirmed wallet transactions
Value resendtx(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"resendtx\n"
"Re-send unconfirmed transactions.\n"
);
ResendWalletTransactions();
return Value::null;
}
// ppcoin: make a public-private key pair
Value makekeypair(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"makekeypair [prefix]\n"
"Make a public/private key pair.\n"
"[prefix] is optional preferred prefix for the public key.\n");
string strPrefix = "";
if (params.size() > 0)
strPrefix = params[0].get_str();
CKey key;
key.MakeNewKey(false);
CPrivKey vchPrivKey = key.GetPrivKey();
Object result;
result.push_back(Pair("PrivateKey", HexStr<CPrivKey::iterator>(vchPrivKey.begin(), vchPrivKey.end())));
result.push_back(Pair("PublicKey", HexStr(key.GetPubKey().Raw())));
return result;
}
|
[
"noreply@github.com"
] |
LifeShareChain.noreply@github.com
|
381374afb4a77b5f80c963fc479fa70e28c5897d
|
9f81d77e028503dcbb6d7d4c0c302391b8fdd50c
|
/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc
|
d3bb6b8f6321b2f975b3bcfd95ef2c7555f554a9
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
googleapis/google-cloud-cpp
|
b96a6ee50c972371daa8b8067ddd803de95f54ba
|
178d6581b499242c52f9150817d91e6c95b773a5
|
refs/heads/main
| 2023-08-31T09:30:11.624568
| 2023-08-31T03:29:11
| 2023-08-31T03:29:11
| 111,860,063
| 450
| 351
|
Apache-2.0
| 2023-09-14T21:52:02
| 2017-11-24T00:19:31
|
C++
|
UTF-8
|
C++
| false
| false
| 3,229
|
cc
|
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Generated by the Codegen C++ plugin.
// If you make any local changes, they will be lost.
// source: google/cloud/clouddms/v1/clouddms.proto
#include "google/cloud/datamigration/v1/internal/data_migration_stub_factory.h"
#include "google/cloud/datamigration/v1/internal/data_migration_auth_decorator.h"
#include "google/cloud/datamigration/v1/internal/data_migration_logging_decorator.h"
#include "google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.h"
#include "google/cloud/datamigration/v1/internal/data_migration_stub.h"
#include "google/cloud/datamigration/v1/internal/data_migration_tracing_stub.h"
#include "google/cloud/common_options.h"
#include "google/cloud/grpc_options.h"
#include "google/cloud/internal/algorithm.h"
#include "google/cloud/internal/opentelemetry.h"
#include "google/cloud/log.h"
#include "google/cloud/options.h"
#include <google/cloud/clouddms/v1/clouddms.grpc.pb.h>
#include <memory>
namespace google {
namespace cloud {
namespace datamigration_v1_internal {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
std::shared_ptr<DataMigrationServiceStub> CreateDefaultDataMigrationServiceStub(
google::cloud::CompletionQueue cq, Options const& options) {
auto auth = google::cloud::internal::CreateAuthenticationStrategy(
std::move(cq), options);
auto channel = auth->CreateChannel(options.get<EndpointOption>(),
internal::MakeChannelArguments(options));
auto service_grpc_stub =
google::cloud::clouddms::v1::DataMigrationService::NewStub(channel);
std::shared_ptr<DataMigrationServiceStub> stub =
std::make_shared<DefaultDataMigrationServiceStub>(
std::move(service_grpc_stub),
google::longrunning::Operations::NewStub(channel));
if (auth->RequiresConfigureContext()) {
stub = std::make_shared<DataMigrationServiceAuth>(std::move(auth),
std::move(stub));
}
stub = std::make_shared<DataMigrationServiceMetadata>(
std::move(stub), std::multimap<std::string, std::string>{});
if (internal::Contains(options.get<TracingComponentsOption>(), "rpc")) {
GCP_LOG(INFO) << "Enabled logging for gRPC calls";
stub = std::make_shared<DataMigrationServiceLogging>(
std::move(stub), options.get<GrpcTracingOptionsOption>(),
options.get<TracingComponentsOption>());
}
if (internal::TracingEnabled(options)) {
stub = MakeDataMigrationServiceTracingStub(std::move(stub));
}
return stub;
}
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace datamigration_v1_internal
} // namespace cloud
} // namespace google
|
[
"noreply@github.com"
] |
googleapis.noreply@github.com
|
494b75cd4887a2650851a8e3eb481de8bd48b2bd
|
b596c85d94c6680917a3833b349eabbd89bf17a3
|
/gpu6DSLAM/src/gpu6DSLAM.cpp
|
6343f06e4250b9fc56d8c30bf7a94293809e0db9
|
[] |
no_license
|
nickcharron/mandala-mapping
|
306655b76d706b5182ca79a61ac4805754a3c6b6
|
dd838ab0bdc81b9e0bfa666cb4f56c5763cb1d7c
|
refs/heads/master
| 2020-12-02T21:03:16.526004
| 2017-08-17T16:03:27
| 2017-08-17T16:03:27
| 96,249,643
| 9
| 8
| null | 2017-07-04T20:02:48
| 2017-07-04T20:02:48
| null |
UTF-8
|
C++
| false
| false
| 17,786
|
cpp
|
#include "gpu6DSLAM.h"
void gpu6DSLAM::registerSingleScan(pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> pc, Eigen::Affine3f mtf, std::string iso_time_str)
{
static Eigen::Affine3f last_mtf = mtf;
Eigen::Affine3f odometryIncrement = last_mtf.inverse() * mtf;
//last_mRegistration = last_mRegistration * odometryIncrement;
CCudaWrapper cudaWrapper;
cudaWrapper.warmUpGPU(this->cudaDevice);
std::cout << "gpu6DSLAM::registerSingleScan" << std::endl;
std::string scanName = std::string("scan_") + iso_time_str;
std::string scanPCDFileName = scanName + std::string(".pcd");
boost::filesystem::path tfModelFileName = mainPath;
tfModelFileName/=(std::string("tfModel_" + iso_time_str + ".xml"));
std::cout << "tfModelFileName: " << tfModelFileName << std::endl;
boost::filesystem::path processedDataModelFileName = mainPath;
processedDataModelFileName/=(std::string("tfModelProcessedData_" + iso_time_str + ".xml"));
std::cout << "processedDataModelFileName: " << processedDataModelFileName << std::endl;
boost::filesystem::path registeredDataModelFileName = mainPath;
registeredDataModelFileName/=(std::string("registeredData_" + iso_time_str + ".xml"));
std::cout << "registeredDataModelFileName: " << registeredDataModelFileName << std::endl;
boost::filesystem::path rawDataFileName = rawData;
rawDataFileName/=scanPCDFileName;
boost::filesystem::path processedDataFileName = processedData;
processedDataFileName/=scanPCDFileName;
//save raw data
std::cout << "raw scan: " << scanName << " will be saved in: " << rawDataFileName << std::endl;
if(pcl::io::savePCDFileBinary(rawDataFileName.string(), pc) == -1)
{
std::cout << "ERROR: problem with saving file: " << rawDataFileName << std::endl;
}
//pc processing
//noise removal
cudaWrapper.removeNoiseNaive(pc,
this->noise_removal_resolution,
this->noise_removal_bounding_box_extension,
this->noise_removal_number_of_points_in_bucket_threshold);
//downsampling
cudaWrapper.downsampling(pc, this->downsampling_resolution, this->downsampling_resolution);
//semantic classification
cudaWrapper.classify( pc,
this->semantic_classification_normal_vectors_search_radius,
this->semantic_classification_curvature_threshold,
this->semantic_classification_ground_Z_coordinate_threshold,
this->semantic_classification_number_of_points_needed_for_plane_threshold,
this->semantic_classification_bounding_box_extension,
this->semantic_classification_max_number_considered_in_INNER_bucket,
this->semantic_classification_max_number_considered_in_OUTER_bucket ) ;
//save processed data
std::cout << "processed scan: " << processedDataFileName << " will be saved in: " << processedDataFileName << std::endl;
if(pcl::io::savePCDFileBinary(processedDataFileName.string(), pc) == -1)
{
std::cout << "ERROR: problem with saving file: " << processedDataFileName << std::endl;
}
if(vpc.size() == 0)
{
this->vpc.push_back(pc);
this->cloud_ids.push_back(scanName);
this->vmtf.push_back(mtf);
this->vmregistered.push_back(mtf);
}else
{
this->vpc.push_back(pc);
this->cloud_ids.push_back(scanName);
Eigen::Affine3f m = this->vmtf[this->vmtf.size()-1] * odometryIncrement;
this->vmtf.push_back(m);
Eigen::Affine3f mr = this->vmregistered[this->vmregistered.size()-1] * odometryIncrement;
this->vmregistered.push_back(mr);
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> pc_before;
for(size_t i = 0 ;i < vpc.size(); i++)
{
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> pc_before_local = vpc[i];
transformPointCloud(pc_before_local, this->vmregistered[i]);
pc_before += pc_before_local;
}
pcl::io::savePCDFileBinary(std::string("/tmp/pc_before_")+iso_time_str + std::string(".pcd"), pc_before);
Eigen::Affine3f mBestYaw = Eigen::Affine3f::Identity();
cudaWrapper.findBestYaw(
this->vpc[this->vpc.size()-2],
this->vmregistered[this->vmregistered.size()-2],
this->vpc[this->vpc.size()-1],
this->vmregistered[this->vmregistered.size()-1],
this->findBestYaw_bucket_size,
this->findBestYaw_bounding_box_extension,
this->findBestYaw_search_radius,
this->findBestYaw_max_number_considered_in_INNER_bucket,
this->findBestYaw_max_number_considered_in_OUTER_bucket,
this->findBestYaw_start_angle,
this->findBestYaw_finish_angle,
this->findBestYaw_step_angle,
mBestYaw);
//std::cout << mBestYaw.matrix() << std::endl;
this->vmregistered[this->vmregistered.size()-1] = this->vmregistered[this->vmregistered.size()-1] * mBestYaw;
std::cout << "registerLastArrivedScan START" << std::endl;
for(int i = 0 ; i < this->slam_registerLastArrivedScan_number_of_iterations_step1; i++)
{
registerLastArrivedScan(cudaWrapper, this->slam_search_radius_step1, this->slam_bucket_size_step1);
}
for(int i = 0 ; i < this->slam_registerLastArrivedScan_number_of_iterations_step2; i++)
{
registerLastArrivedScan(cudaWrapper, this->slam_search_radius_step2, this->slam_bucket_size_step2);
}
for(int i = 0 ; i < this->slam_registerLastArrivedScan_number_of_iterations_step3; i++)
{
registerLastArrivedScan(cudaWrapper, this->slam_search_radius_step3, this->slam_bucket_size_step3);
}
for(int i = 0 ; i < this->slam_registerAll_number_of_iterations_step1; i++)
{
registerAll(cudaWrapper, this->slam_search_radius_step1, this->slam_bucket_size_step1);
}
for(int i = 0 ; i < this->slam_registerAll_number_of_iterations_step2; i++)
{
registerAll(cudaWrapper, this->slam_search_radius_step2, this->slam_bucket_size_step2);
}
for(int i = 0 ; i < this->slam_registerAll_number_of_iterations_step3; i++)
{
registerAll(cudaWrapper, this->slam_search_radius_step3, this->slam_bucket_size_step3);
}
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> pc_after;
for(size_t i = 0 ;i < vpc.size(); i++)
{
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> pc_before_local = vpc[i];
transformPointCloud(pc_before_local, this->vmregistered[i]);
pc_after += pc_before_local;
}
pcl::io::savePCDFileBinary(std::string("/tmp/pc_after_")+iso_time_str + std::string(".pcd"), pc_after);
std::cout << "registerLastArrivedScan FINISHED" << std::endl;
}
this->tfModel.setAffine(cloud_ids[cloud_ids.size()-1], mtf.matrix());
this->tfModel.setPointcloudName(cloud_ids[cloud_ids.size()-1], scanPCDFileName);
this->tfModel.saveFile(tfModelFileName.string());
this->processedDataModel.setAffine(cloud_ids[cloud_ids.size()-1], mtf.matrix());
this->processedDataModel.setPointcloudName(cloud_ids[cloud_ids.size()-1], scanPCDFileName);
this->processedDataModel.saveFile(processedDataModelFileName.string());
this->registeredModel.setPointcloudName(cloud_ids[cloud_ids.size()-1], scanPCDFileName);
for(size_t i = 0 ; i < this->vmregistered.size(); i++)
{
this->registeredModel.setAffine(cloud_ids[i], vmregistered[i].matrix());
}
this->registeredModel.saveFile(registeredDataModelFileName.string());
last_mtf = mtf;
return;
}
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> gpu6DSLAM::getMetascan(Eigen::Affine3f m)
{
std::cout << "gpu6DSLAM::getMetascan" << std::endl;
Eigen::Affine3f mLastInv = this->vmregistered[this->vmregistered.size()-1].inverse();
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> metascan;
for(size_t i = 0; i < vpc.size(); i++)
{
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> pc = vpc[i];
transformPointCloud(pc, vmregistered[i]);
metascan += pc;
}
transformPointCloud(metascan, mLastInv);
transformPointCloud(metascan, m);
return metascan;
}
void gpu6DSLAM::registerLastArrivedScan(CCudaWrapper &cudaWrapper, float slam_search_radius, float slam_bucket_size)
{
//this->slam_registerLastArrivedScan_distance_threshold = 10.0f;
//std::vector<Eigen::Affine3f> v_poses;
size_t i = vmregistered.size() - 1;
Eigen::Vector3f omfika1;
Eigen::Vector3f xyz1;
Eigen::Affine3f pose1;
cudaWrapper.Matrix4ToEuler(vmregistered[i], omfika1, xyz1);
cudaWrapper.EulerToMatrix(omfika1, xyz1, pose1);
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> _point_cloud_1 = vpc[i];
transformPointCloud(_point_cloud_1, pose1);
observations_t obs;
obs.om = omfika1.x();
obs.fi = omfika1.y();
obs.ka = omfika1.z();
obs.tx = xyz1.x();
obs.ty = xyz1.y();
obs.tz = xyz1.z();
for(size_t j = i-1; j < i; j++)
{
Eigen::Vector3f omfika2;
Eigen::Vector3f xyz2;
Eigen::Affine3f pose2;
cudaWrapper.Matrix4ToEuler(vmregistered[j], omfika2, xyz2);
cudaWrapper.EulerToMatrix(omfika2, xyz2, pose2);
float dist = sqrt( (xyz1.x() - xyz2.x()) * (xyz1.x() - xyz2.x()) +
(xyz1.y() - xyz2.y()) * (xyz1.y() - xyz2.y()) +
(xyz1.z() - xyz2.z()) * (xyz1.z() - xyz2.z()) );
std::cout << "dist: " << dist << std::endl;
if(dist < this->slam_registerLastArrivedScan_distance_threshold)
{
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> _point_cloud_2 = vpc[j];
transformPointCloud(_point_cloud_2, pose2);
std::vector<int> nearest_neighbour_indexes;
nearest_neighbour_indexes.resize(_point_cloud_2.size());
std::fill(nearest_neighbour_indexes.begin(), nearest_neighbour_indexes.end(), -1);
cudaWrapper.semanticNearestNeighbourhoodSearch(
_point_cloud_1,
_point_cloud_2,
slam_search_radius,
slam_bucket_size,
this->slam_bounding_box_extension,
this->slam_max_number_considered_in_INNER_bucket,
this->slam_max_number_considered_in_OUTER_bucket,
nearest_neighbour_indexes);
int number_of_observations_plane = 0;
int number_of_observations_edge = 0;
int number_of_observations_ceiling = 0;
int number_of_observations_ground = 0;
for(size_t ii = 0 ; ii < nearest_neighbour_indexes.size(); ii++)
{
if(nearest_neighbour_indexes[ii] != -1)
{
switch (_point_cloud_2[ii].label)
{
case LABEL_PLANE:
{
number_of_observations_plane ++;
break;
}
case LABEL_EDGE:
{
number_of_observations_edge ++;
break;
}
case LABEL_CEILING:
{
number_of_observations_ceiling ++;
break;
}
case LABEL_GROUND:
{
number_of_observations_ground ++;
break;
}
}
}
}
for(size_t ii = 0 ; ii < nearest_neighbour_indexes.size(); ii++)
{
if(nearest_neighbour_indexes[ii] != -1)
{
pcl::PointXYZ p1(_point_cloud_1[nearest_neighbour_indexes[ii]].x, _point_cloud_1[nearest_neighbour_indexes[ii]].y, _point_cloud_1[nearest_neighbour_indexes[ii]].z);
pcl::PointXYZ p2(_point_cloud_2[ii].x, _point_cloud_2[ii].y, _point_cloud_2[ii].z);
obs_nn_t obs_nn;
obs_nn.x0 = vpc[i].points[nearest_neighbour_indexes[ii]].x;
obs_nn.y0 = vpc[i].points[nearest_neighbour_indexes[ii]].y;
obs_nn.z0 = vpc[i].points[nearest_neighbour_indexes[ii]].z;
obs_nn.x_diff = p1.x - p2.x;
obs_nn.y_diff = p1.y - p2.y;
obs_nn.z_diff = p1.z - p2.z;
switch(_point_cloud_2[ii].label)
{
case 0://plane
{
obs_nn.P = slam_observation_weight_plane/number_of_observations_plane;
break;
}
case 1: //edge
{
obs_nn.P = slam_observation_weight_edge/number_of_observations_edge;
break;
}
case 2: //ceiling
{
obs_nn.P = slam_observation_weight_ceiling/number_of_observations_ceiling;
break;
}
case 3: //floor/ground
{
obs_nn.P = slam_observation_weight_ground/number_of_observations_ground;
break;
}
}
obs.vobs_nn.push_back(obs_nn);
}
}
std::cout << "obs.vobs_nn.size(): " << obs.vobs_nn.size() << std::endl;
if(obs.vobs_nn.size() > this->slam_number_of_observations_threshold )
{
//std::cout << "obs.vobs_nn.size(): " << obs.vobs_nn.size() << std::endl;
//if(cudaWrapper.registerLS(obs))
if(cudaWrapper.registerLS_4DOF(obs))
{
Eigen::Vector3f omfika1_res(obs.om, obs.fi, obs.ka);
Eigen::Vector3f xyz1_res(obs.tx, obs.ty, obs.tz);
Eigen::Affine3f pose1_res;
cudaWrapper.EulerToMatrix(omfika1_res, xyz1_res, pose1_res);
vmregistered[i] = pose1_res;
}
}
}
}
}
void gpu6DSLAM::registerAll(CCudaWrapper &cudaWrapper, float slam_search_radius, float slam_bucket_size)
{
std::vector<Eigen::Affine3f> v_poses;
if(vpc.size() < 5)return;
for(int i = 0 ; i < vpc.size() - 5 ;i++)v_poses.push_back(vmregistered[i]);
for(size_t i = vpc.size() - 5; i < vpc.size(); i++)
{
std::cout << "registerAll node: " << i << " of: " << vpc.size() - 1 << std::endl;
Eigen::Vector3f omfika1;
Eigen::Vector3f xyz1;
Eigen::Affine3f pose1;
cudaWrapper.Matrix4ToEuler(vmregistered[i], omfika1, xyz1);
cudaWrapper.EulerToMatrix(omfika1, xyz1, pose1);
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> _point_cloud_1 = vpc[i];
transformPointCloud(_point_cloud_1, pose1);
observations_t obs;
obs.om = omfika1.x();
obs.fi = omfika1.y();
obs.ka = omfika1.z();
obs.tx = xyz1.x();
obs.ty = xyz1.y();
obs.tz = xyz1.z();
for(size_t j = 0; j < vpc.size(); j++)
{
if(i != j)
{
Eigen::Vector3f omfika2;
Eigen::Vector3f xyz2;
Eigen::Affine3f pose2;
cudaWrapper.Matrix4ToEuler(vmregistered[j], omfika2, xyz2);
cudaWrapper.EulerToMatrix(omfika2, xyz2, pose2);
float dist = sqrt( (xyz1.x() - xyz2.x()) * (xyz1.x() - xyz2.x()) +
(xyz1.y() - xyz2.y()) * (xyz1.y() - xyz2.y()) +
(xyz1.z() - xyz2.z()) * (xyz1.z() - xyz2.z()) );
if(dist < this->slam_registerAll_distance_threshold)
{
pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> _point_cloud_2 = vpc[j];
transformPointCloud(_point_cloud_2, pose2);
std::vector<int> nearest_neighbour_indexes;
nearest_neighbour_indexes.resize(_point_cloud_2.size());
std::fill(nearest_neighbour_indexes.begin(), nearest_neighbour_indexes.end(), -1);
cudaWrapper.semanticNearestNeighbourhoodSearch(
_point_cloud_1,
_point_cloud_2,
slam_search_radius,
slam_bucket_size,
this->slam_bounding_box_extension,
this->slam_max_number_considered_in_INNER_bucket,
this->slam_max_number_considered_in_OUTER_bucket,
nearest_neighbour_indexes);
int number_of_observations_plane = 0;
int number_of_observations_edge = 0;
int number_of_observations_ceiling = 0;
int number_of_observations_ground = 0;
for(size_t ii = 0 ; ii < nearest_neighbour_indexes.size(); ii++)
{
if(nearest_neighbour_indexes[ii] != -1)
{
switch (_point_cloud_2[ii].label)
{
case LABEL_PLANE:
{
number_of_observations_plane ++;
break;
}
case LABEL_EDGE:
{
number_of_observations_edge ++;
break;
}
case LABEL_CEILING:
{
number_of_observations_ceiling ++;
break;
}
case LABEL_GROUND:
{
number_of_observations_ground ++;
break;
}
}
}
}
for(size_t ii = 0 ; ii < nearest_neighbour_indexes.size(); ii++)
{
if(nearest_neighbour_indexes[ii] != -1)
{
pcl::PointXYZ p1(_point_cloud_1[nearest_neighbour_indexes[ii]].x, _point_cloud_1[nearest_neighbour_indexes[ii]].y, _point_cloud_1[nearest_neighbour_indexes[ii]].z);
pcl::PointXYZ p2(_point_cloud_2[ii].x, _point_cloud_2[ii].y, _point_cloud_2[ii].z);
obs_nn_t obs_nn;
obs_nn.x0 = vpc[i].points[nearest_neighbour_indexes[ii]].x;
obs_nn.y0 = vpc[i].points[nearest_neighbour_indexes[ii]].y;
obs_nn.z0 = vpc[i].points[nearest_neighbour_indexes[ii]].z;
obs_nn.x_diff = p1.x - p2.x;
obs_nn.y_diff = p1.y - p2.y;
obs_nn.z_diff = p1.z - p2.z;
switch(_point_cloud_2[ii].label)
{
case 0://plane
{
obs_nn.P = slam_observation_weight_plane/number_of_observations_plane;
break;
}
case 1: //edge
{
obs_nn.P = slam_observation_weight_edge/number_of_observations_edge;
break;
}
case 2: //ceiling
{
obs_nn.P = slam_observation_weight_ceiling/number_of_observations_ceiling;
break;
}
case 3: //floor/ground
{
obs_nn.P = slam_observation_weight_ground/number_of_observations_ground;
break;
}
}
obs.vobs_nn.push_back(obs_nn);
}
}
}
}//if(i != j)
}//for(size_t j = 0; j < vpointcloud.size(); j++)
std::cout << "obs.vobs_nn.size() " << obs.vobs_nn.size() << std::endl;
//if(!cudaWrapper.registerLS(obs))
if(!cudaWrapper.registerLS_4DOF(obs))
{
std::cout << "PROBLEM: cudaWrapper.registerLS(obs2to1)" << std::endl;
return;
}
Eigen::Vector3f omfika1_res(obs.om, obs.fi, obs.ka);
Eigen::Vector3f xyz1_res(obs.tx, obs.ty, obs.tz);
Eigen::Affine3f pose1_res;
cudaWrapper.EulerToMatrix(omfika1_res, xyz1_res, pose1_res);
std::cout << pose1_res.matrix() << std::endl;
v_poses.push_back(pose1_res);
}
vmregistered = v_poses;
}
void gpu6DSLAM::transformPointCloud(pcl::PointCloud<lidar_pointcloud::PointXYZIRNLRGB> &pointcloud, Eigen::Affine3f transform)
{
for(size_t i = 0; i < pointcloud.size(); i++)
{
Eigen::Vector3f p(pointcloud[i].x, pointcloud[i].y, pointcloud[i].z);
Eigen::Vector3f pt;
pt = transform * p;
pointcloud[i].x = pt.x();
pointcloud[i].y = pt.y();
pointcloud[i].z = pt.z();
Eigen::Affine3f tr = transform;
tr(0,3) = 0.0f;
tr(1,3) = 0.0f;
tr(2,3) = 0.0f;
Eigen::Vector3f n(pointcloud[i].normal_x, pointcloud[i].normal_y, pointcloud[i].normal_z);
Eigen::Vector3f nt;
nt = tr * n;
pointcloud[i].normal_x = nt.x();
pointcloud[i].normal_y = nt.y();
pointcloud[i].normal_z = nt.z();
}
return;
}
|
[
"michalpelka@gmail.com"
] |
michalpelka@gmail.com
|
ae210428a40174848808e1c31411cfcbc02dc59d
|
9b84fab4ae3770f29a2ae4eca7757a9bd5f0f3e4
|
/audio_engine/msgf_osc_pipe.h
|
57cfc6ee72efa71fe2f73c0d6b1864ec599ab05b
|
[
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] |
permissive
|
PeakPei/Musical_Sound_Generator_Framework
|
551ba128812fd01498bd66283f8d13d781a945d3
|
cf4b321ba41272c3bcd0dce67df87754329178fd
|
refs/heads/master
| 2020-03-31T21:12:09.267440
| 2016-10-31T13:07:06
| 2016-10-31T13:07:06
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,480
|
h
|
//
// msgf_osc_pipe.h
// ToneGenerator
//
// Created by 長谷部 雅彦 on 2013/12/01.
// Copyright (c) 2013年 長谷部 雅彦. All rights reserved.
//
#ifndef __ToneGenerator__msgf_osc_pipe__
#define __ToneGenerator__msgf_osc_pipe__
#include <iostream>
#include <math.h>
#include "msgf_type.h"
#include "msgf_signal_process_core.h"
#include "msgf_voice_context.h"
#include "msgf_note.h"
#include "msgf_eg2seg.h"
#include "msgf_lfo.h"
namespace msgf {
// to be defined in every Audio Engine that demands an original parameter set
const int VP_OSC_PIPE_ID = 320;
//---------------------------------------------------------
typedef enum {
// Overtone Type
VP_OVERTONE_TYPE, // 0:Sine, 1:LikeRecorder, 2:LikeOboe
// Pitch
VP_TUNING, // -100 - 100[cent]
VP_TRANSPOSE, // -24 - 24(seminote)
// Portamento
VP_PORTAMENTO_MODE, // 0:rate constant, 1:time constant
VP_PORTAMENTO_CURVE, // 0:cent linear, 1:freqency linear
// LFO
VP_LFO_FREQUENCY, // 0 - ??? (*0.1 =[Hz])
VP_LFO_DELAY_TIME, // 0 - ??? (*10 =[ms])
VP_LFO_FADEIN_TIME, // 0 - ??? (*10 =[ms])
// Note Change EG
VP_WAITING_DCNT, // 0 - inf (*22.67 =[us])
VP_FAST_MOVE_DCNT, // 0 - inf (*22.67 =[us])
VP_PORTAMENTO_DIFF, // 1 - 24(semitone)
VP_OSCILLATOR_MAX
} VoiceParameter_OscMono;
//---------------------------------------------------------
typedef enum {
SINE,
TRIANGLE,
WAVEFORM_MAX
} WAVEFORM;
//---------------------------------------------------------
typedef enum {
NO_MOVE,
WAITING_PRTM, // Time of from event to begin to move
FAST_MOVE, // fast move time
SLOW_MOVE, // slow move time
PRTM_STATE_MAX
} PRTM_STATE;
//---------------------------------------------------------
class TgAudioBuffer;
class PegCallBack;
//---------------------------------------------------------
class OscPipe : public SignalProcessCore {
friend class PegCallBack;
public:
OscPipe( Note& parent );
~OscPipe( void );
void init( void ){ init(true);}
void init( bool phaseReset );
void changeNote( bool chgNote );
void release( void ){}
// process thread
void process( TgAudioBuffer& buf );
static const int PEG_MAX = 60;
static const int PEG_DEPTH_MAX = 2; // /2 Octave
static const int MAX_OVERTONE = 8;
private:
double calcPitch( const Uint8 note );
double getPegPitch( int depth );
void reflectMidiController( void );
double calcDeltaLFO( double lfoDpt );
void stateOfWaitingPortamento( void );
void stateOfFastMove( void );
void stateOfSlowMove( void );
void managePortamentoState( void );
void setPortamentoCounter( double centDiff );
double generateWave( double phase );
int getVoicePrm( int id ){ return _parentNote.getVoiceContext()->getParameter( VP_OSC_PIPE_ID, id ); }
static const double tPitchOfA[11];
static const int MAX_OVERTONE_TYPE = 3;
static const int tOverToneRatio[MAX_OVERTONE_TYPE][MAX_OVERTONE];
// Basic Reference
Note& _parentNote;
// generate waveform
Uint8 _note;
double _pitch;
double _pitchAdj;
double _crntPhase;
double _cent2pitch;
double _chromaticRatio;
// portamento
int _portamentoCounter;
int _prtmDiff; // copy from VP_PORTAMENTO_DIFF
int _maxPortamentoCounter; // prohibit 0
double _sourcePitch;
double _targetPitch;
double _targetCent;
PRTM_STATE _prtmState;
// LFO
Lfo* _pm;
};
}
#endif /* defined(__ToneGenerator__msgf_osc_pipe__) */
|
[
"JCA03205@nifty.com"
] |
JCA03205@nifty.com
|
4852c5560c73c14288b466305de539cceb2471f9
|
14a061561cf7fd34f30ede3c48cf36a7681ce8ff
|
/src/icp/icp_debug.cpp
|
4db84b80d08a72baf811f5a7e23775a4ce29d75c
|
[] |
no_license
|
tangyf96/plicp_wrapper
|
29576c3250798818f692003e4340524cc7224907
|
9bc1ce18a6c38396523152e670343cedce6fcdf3
|
refs/heads/master
| 2020-12-03T21:59:30.895928
| 2020-01-08T09:03:57
| 2020-01-08T09:03:57
| 231,499,669
| 3
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,134
|
cpp
|
#include <string.h>
#include "icp/icp.h"
#include <vector>
void debug_correspondences(struct sm_params * params) {
LDP laser_sens = params->laser_sens;
/** Do the test */
find_correspondences_tricks(params);
//struct correspondence c1[laser_sens->nrays];
std::vector<correspondence> c1;
c1.reserve(laser_sens->nrays);
struct correspondence * c2 = laser_sens->corr;
//memcpy(c1, c2, sizeof(struct correspondence) * laser_sens->nrays);
c1.assign(c2, c2+laser_sens->nrays);
long hash1 = ld_corr_hash(laser_sens);
find_correspondences(params);
long hash2 = ld_corr_hash(laser_sens);
if(hash1 != hash2) {
sm_error("find_correspondences_tricks might be buggy\n");
int i = 0; for(i=0;i<laser_sens->nrays;i++) {
if( (c1[i].valid != c2[i].valid) ||
(c1[i].j1 != c2[i].j1) || (c1[i].j2 != c2[i].j2) ) {
sm_error("\t tricks: c1[%d].valid = %d j1 = %d j2 = %d dist2_j1 = %f\n",
i, c1[i].valid, c1[i].j1, c1[i].j2, c1[i].dist2_j1);
sm_error("\tno tricks: c2[%d].valid = %d j1 = %d j2 = %d dist2_j1 = %f\n",
i, c2[i].valid, c2[i].j1, c2[i].j2, c2[i].dist2_j1);
}
}
if(1) exit(-1);
}
}
|
[
"tangyifan@360.cn"
] |
tangyifan@360.cn
|
9c244cbb65076aaff6b8d7b62a778a0d5a6c574e
|
0aa895f25d462defe8e9956c8850b758e1302cac
|
/Test2/Alarmed.cpp
|
9ac3906e8ab9a42ad06bb20c1251f6e7eacce3c4
|
[] |
no_license
|
nranjan2014/mytc
|
25b0828efba0078c03823107397ad5cec34166b8
|
3574f625810fe001950ef05a06831d0902ee63df
|
refs/heads/master
| 2021-01-10T19:55:23.536268
| 2014-07-19T02:09:51
| 2014-07-19T02:09:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 199
|
cpp
|
// BEGIN CUT HERE
// END CUT HERE
#line 5 "Alarmed.cpp"
#include <string>
#include <vector>
class Alarmed {
public:
double noise(vector <int> x, vector <int> y, vector <int> threshold) {
}
};
|
[
"niloo.ranjan2005@gmail.com"
] |
niloo.ranjan2005@gmail.com
|
41b07c6943e409405a2daac7a4281195456e9a9d
|
9a5f39245c62cfcf3c49fec275534e48185a0dca
|
/cpp/hw3/solution1/edge.cpp
|
61fa5f1ef27f961829bd0399b2547a3c5b2d32be
|
[] |
no_license
|
nickleefly/experiment
|
812a2eb40c6de08d0a54a42ed43dcdf4053daa89
|
9804dced31f622f71a08d5db9952125e9787ed18
|
refs/heads/master
| 2023-07-26T18:33:57.455656
| 2023-07-13T09:53:23
| 2023-07-13T09:53:23
| 11,269,106
| 0
| 0
| null | 2023-06-02T05:28:36
| 2013-07-09T00:40:33
|
C
|
UTF-8
|
C++
| false
| false
| 249
|
cpp
|
#include "Edge.h"
using namespace std;
Edge::Edge(int from, int to, int w) : source(from), dest(to), weight(w)
{}
Edge::~Edge()
{}
ostream& operator<<(ostream &os, const Edge &e) {
os << e.source << "--->" << e.dest << endl;
return os;
}
|
[
"nickleefly@gmail.com"
] |
nickleefly@gmail.com
|
690968517aa17ea58324615e5c98f85fc8b7538c
|
d56ce97233fec38c9708a2c93c394a541a3500bd
|
/BZOJ/2748.cpp
|
80fdd210779b0c492f1734ef36bd5fd9b7252a9e
|
[] |
no_license
|
linkfqy/OJ_code_backup
|
af3fcab26e4c862ed36a71200c915facf93e8d59
|
4cc89b7a4fa4674b806f714acbcdea0028f33ee1
|
refs/heads/master
| 2020-03-22T12:50:06.262831
| 2018-10-25T00:06:52
| 2018-10-25T00:06:52
| 140,065,331
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 395
|
cpp
|
#include<cstdio>
const int maxn=55,maxs=1005;
int n,begin,m;
bool f[maxn][maxs];
int main(){
scanf("%d%d%d",&n,&begin,&m);
f[0][begin]=1;
for (int i=1;i<=n;i++){
int x; scanf("%d",&x);
for (int j=0;j<=m;j++){
if (j-x>=0) f[i][j]|=f[i-1][j-x];
if (j+x<=m) f[i][j]|=f[i-1][j+x];
}
}
int ans=-1;
for (int i=m;i>=0;i--) if (f[n][i]) {ans=i;break;}
printf("%d",ans);
return 0;
}
|
[
"linkfqy@gmail.com"
] |
linkfqy@gmail.com
|
b84dbc4ff3fc9d7f18486407986a0558d9fcc0ba
|
a75d0418b2143d6f59635a8833bff49bc903df5e
|
/DofusMessages/ExchangeWeightMessage.cpp
|
6f6a3236252c098c40502c298f38aeec633e8a5f
|
[] |
no_license
|
Arkwell9112/dofus_bot
|
30b80850ba41b6a2b562705ec8aa1a6c87cfb8f8
|
fc1b805b70c0ed43cbc585322806ece89d057585
|
refs/heads/master
| 2023-01-16T01:08:06.710649
| 2020-11-23T20:53:00
| 2020-11-23T20:53:00
| 314,084,045
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 534
|
cpp
|
#include "ExchangeWeightMessage.h"
#include "../BotCoreAPI/BotCoreAPI.h"
void ExchangeWeightMessage::deserialize(CustomDataInput *input) {
this->_currentWeightFunc(input);
this->_maxWeightFunc(input);
}
void ExchangeWeightMessage::_currentWeightFunc(CustomDataInput *input) {
this->currentWeight = input->readVarUhInt();
if (this->currentWeight < 0) {
}
}
void ExchangeWeightMessage::_maxWeightFunc(CustomDataInput *input) {
this->maxWeight = input->readVarUhInt();
if (this->maxWeight < 0) {
}
}
|
[
"arkwell9112@github.com"
] |
arkwell9112@github.com
|
23115806b9bb42783b63e527a34309c891f6a739
|
c25744db7fffeccac1748c619ffac22b1c4e9337
|
/software/include/random.h
|
d40969fc81a47e981b15147bf017c87340f8354c
|
[] |
no_license
|
scottedwardpratt/moments_bw
|
adac3f8f70583c5a2f79fe610de9777c5689c27b
|
d35d5f17989a3dbf86644de9ab3c0820c3d7327b
|
refs/heads/master
| 2023-04-23T20:16:36.532048
| 2020-09-22T17:13:07
| 2020-09-22T17:13:07
| 365,559,371
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 884
|
h
|
#ifndef __INCLUDE_CRANDOM_H__
#define __INCLUDE_CRANDOM_H__
#include <cmath>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_sf.h>
typedef double FourVector[4];
using namespace std;
class CRandom{
public:
//! returns from zero to 1
double ran(void);
//! returns integer from zero to imax-1
unsigned long int iran(unsigned long int imax);
//! weights with exp(-x^2/2)
double gauss(void);
void gauss2(double *g1,double *g2);
//! weights with exp(-x)
double ran_exp(void);
CRandom(int seed);
void reset(int seed);
void generate_boltzmann(double mass,double T,FourVector &p);
//void generate_boltzmann(double mass,double T,double *p);
void generate_boltzmann_alt(double mass,double T,FourVector &p);
//void generate_boltzmann_alt(double mass,double T,double *p);
int GetNPoissonian(double eta);
private:
gsl_rng *randy;
};
#endif
|
[
"steinhor@msu.edu"
] |
steinhor@msu.edu
|
5027ebae478f5957ba2c09b1e12bd6607ed45a15
|
48f71cc36854c8e3f3ea57aba2a38646a8d63004
|
/shirabeengine/shirabeengine/code/include/ecws/componentbase.h
|
aff5f0af0924c3ad5e71717e0f3ca5944c29052b
|
[
"MIT"
] |
permissive
|
Fraaanzi/ShirabeEngine
|
10b6a5bb736432e3fd22b8d32324fd2b6b0396b2
|
39b3aa2c5173084d59b96b7f60c15207bff0ad04
|
refs/heads/master
| 2020-12-07T23:45:58.001712
| 2019-12-30T21:32:24
| 2019-12-30T21:32:24
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,024
|
h
|
#ifndef __SHIRABE_COMPONENT_BASE_H__
#define __SHIRABE_COMPONENT_BASE_H__
#include "ecws/icomponent.h"
namespace engine::ecws
{
class CEntity;
class CComponentBase
: public IComponent
{
friend class CEntity;
public_constructors:
SHIRABE_INLINE
CComponentBase(std::string const &aName)
: IComponent()
, mName(aName)
{}
public_destructors:
SHIRABE_INLINE
~CComponentBase() override
{
mParentEntity = nullptr;
};
public_methods:
[[nodiscard]]
SHIRABE_INLINE
std::string const &name() const final { return mName; }
protected_methods:
SHIRABE_INLINE
void setParentEntity(class CEntity const *const aEntity) final
{
mParentEntity = aEntity;
}
[[nodiscard]]
SHIRABE_INLINE
CEntity const *const getParentEntity() const
{
return mParentEntity;
}
private_members:
std::string mName;
CEntity const *mParentEntity;
};
}
#endif
|
[
"boehm.marc.anton@gmail.com"
] |
boehm.marc.anton@gmail.com
|
a3500dfe3e8ba40c6bb63ce1ba3cb69e94b51db0
|
e815232be140847ecb5bf088d89a656b593ac1da
|
/UVA/UVA 1121.cpp
|
bba2b77da52c0eb4d1483230f5c81716dbcfbf27
|
[] |
no_license
|
nada3ssam/CompetitiveProgramming
|
fc176c98574d68f0f0ef51be7cc8cc7f355dce05
|
718e78b3745884c617b7488d18d92ff1148f962f
|
refs/heads/master
| 2021-01-24T10:08:03.411975
| 2018-04-09T15:26:30
| 2018-04-09T15:26:30
| 123,040,303
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 827
|
cpp
|
#include <iostream>
#include<cmath>
#include<algorithm>
#define _CRT_SECURE_NO_WARNINGS
#define PI 3.14159265
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
typedef long long ll;
typedef long double ld;
const double EPS = (1e-7);
const ll OO = 1e8;
using namespace std;
void Fast()
{
std::ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
}
int A[200000];
int main()
{
Fast();
int n,S;
while (cin>>n>>S)
{
for (int i = 0; i < n; i++)
cin>>A[i];
int l=0,r=0,Min=1e9,k=1e9,c=0;
ll sum=0;
while (l<n)
{
while (r<n && sum<S)
{
sum+=A[r];
r++;
}
sum-=A[l];
l++;
if(sum>=S)
{
k=r-l;
c++;
}
else if(sum+A[l-1]>=S)
{
k=r;
c++;
}
Min=min(Min,k);
}
if(!c)
cout<<0<<endl;
else
cout<<Min<<endl;
}
return 0;
}
|
[
"nada3ssam1@gmail.com"
] |
nada3ssam1@gmail.com
|
6d07cdd40f6403ad4977c70cfbc5c5cafbed0516
|
8dc84558f0058d90dfc4955e905dab1b22d12c08
|
/extensions/shell/browser/api/runtime/shell_runtime_api_delegate.cc
|
d6e61def2807e5afb96a992b30f52a3a3d8b6bac
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] |
permissive
|
meniossin/src
|
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
|
44f73f7e76119e5ab415d4593ac66485e65d700a
|
refs/heads/master
| 2022-12-16T20:17:03.747113
| 2020-09-03T10:43:12
| 2020-09-03T10:43:12
| 263,710,168
| 1
| 0
|
BSD-3-Clause
| 2020-05-13T18:20:09
| 2020-05-13T18:20:08
| null |
UTF-8
|
C++
| false
| false
| 2,145
|
cc
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "extensions/shell/browser/api/runtime/shell_runtime_api_delegate.h"
#include "build/build_config.h"
#include "extensions/common/api/runtime.h"
#include "extensions/shell/browser/shell_extension_system.h"
#if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#endif
using extensions::api::runtime::PlatformInfo;
namespace extensions {
ShellRuntimeAPIDelegate::ShellRuntimeAPIDelegate(
content::BrowserContext* browser_context)
: browser_context_(browser_context) {
DCHECK(browser_context_);
}
ShellRuntimeAPIDelegate::~ShellRuntimeAPIDelegate() = default;
void ShellRuntimeAPIDelegate::AddUpdateObserver(UpdateObserver* observer) {}
void ShellRuntimeAPIDelegate::RemoveUpdateObserver(UpdateObserver* observer) {}
void ShellRuntimeAPIDelegate::ReloadExtension(const std::string& extension_id) {
static_cast<ShellExtensionSystem*>(ExtensionSystem::Get(browser_context_))
->ReloadExtension(extension_id);
}
bool ShellRuntimeAPIDelegate::CheckForUpdates(
const std::string& extension_id,
const UpdateCheckCallback& callback) {
return false;
}
void ShellRuntimeAPIDelegate::OpenURL(const GURL& uninstall_url) {}
bool ShellRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) {
#if defined(OS_CHROMEOS)
info->os = api::runtime::PLATFORM_OS_CROS;
#elif defined(OS_LINUX)
info->os = api::runtime::PLATFORM_OS_LINUX;
#endif
return true;
}
bool ShellRuntimeAPIDelegate::RestartDevice(std::string* error_message) {
// We allow chrome.runtime.restart() to request a device restart on ChromeOS.
#if defined(OS_CHROMEOS)
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(
power_manager::REQUEST_RESTART_OTHER, "AppShell chrome.runtime API");
return true;
#endif
*error_message = "Restart is only supported on ChromeOS.";
return false;
}
} // namespace extensions
|
[
"arnaud@geometry.ee"
] |
arnaud@geometry.ee
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.