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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
580f123f0865d06e53270dc9378c2f3e88b9bd92
|
7ebae5ec0378642a1d2c181184460e76c73debbd
|
/UVA Online Judge/11060/11060/stdafx.cpp
|
f5f91785710e17c22bca5d9ff38781071b0f416d
|
[] |
no_license
|
tonyli00000/Competition-Code
|
a4352b6b6835819a0f19f7f5cc67e46d2a200906
|
7f5767e3cb997fd15ae6f72145bcb8394f50975f
|
refs/heads/master
| 2020-06-17T23:04:10.367762
| 2019-12-28T22:08:25
| 2019-12-28T22:08:25
| 196,091,038
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 284
|
cpp
|
// stdafx.cpp : source file that includes just the standard includes
// 11060.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
|
[
"tonyli2002@live.com"
] |
tonyli2002@live.com
|
08369023bc802bfc1b7a7b438a79fbc48b9ddcca
|
5e698c35e466910b46206ff59fa0ea0b54864d06
|
/lab3/QQueueItem.cpp
|
dadd97109685917ff9214601e098c46d90e8effc
|
[] |
no_license
|
AntonWilson123/OOP
|
b7e2929d8f0e84e8fabbc0f85b7422a74fb41d82
|
5386325d0984e662903c26a908ed6afedab6223e
|
refs/heads/master
| 2020-03-18T12:32:24.805267
| 2018-06-01T11:58:42
| 2018-06-01T11:58:42
| 134,730,964
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,787
|
cpp
|
#include "QQueueItem.h"
#include <iostream>
QQueueItem::QQueueItem(const std::shared_ptr<Quadrate> &quadrate) {
this->quadrate = quadrate;
this->trapeze = nullptr;
this->rectangle = nullptr;
this->next = nullptr;
std::cout << "Queue item created: quadrate\n";
}
QQueueItem::QQueueItem(const std::shared_ptr<Trapeze> &trapeze) {
this->trapeze = trapeze;
this->quadrate = nullptr;
this->rectangle = nullptr;
this->next = nullptr;
std::cout << "Queue item created: trapeze\n";
}
QQueueItem::QQueueItem(const std::shared_ptr<Rectangle> &rectangle) {
this->rectangle = rectangle;
this->quadrate = nullptr;
this->trapeze = nullptr;
this->next = nullptr;
std::cout << "Queue item created: rectangle\n";
}
/*
QQueueItem::QQueueItem(const QQueueItem& orig) {
this->quadrate = orig.quadrate;
this->next = orig.next;
std::cout << "Queue item copied\n";
}*/
std::shared_ptr<QQueueItem> QQueueItem::SetNext(std::shared_ptr<QQueueItem> &next) {
std::shared_ptr<QQueueItem> old = this->next;
this->next = next;
return old;
}
std::shared_ptr<Quadrate> QQueueItem::GetQuadrate() const {
return this->quadrate;
}
std::shared_ptr<Trapeze> QQueueItem::GetTrapeze() const {
return this->trapeze;
}
std::shared_ptr<Rectangle> QQueueItem::GetRectangle() const {
return this->rectangle;
}
std::shared_ptr<QQueueItem> QQueueItem::GetNext() {
return this->next;
}
QQueueItem::~QQueueItem() {
std::cout << "Queue item deleted\n";
}
std::ostream& operator<<(std::ostream& os, const QQueueItem& obj) {
if (obj.quadrate != nullptr){
os << "-------" << *obj.quadrate << "\n";
return os;
}
if (obj.trapeze != nullptr){
os << "-------" << *obj.trapeze << "\n";
return os;
}
if (obj.rectangle != nullptr){
os << "-------" << *obj.rectangle << "\n";
return os;
}
}
|
[
"noreply@github.com"
] |
AntonWilson123.noreply@github.com
|
4c53351d3899ae236f1f5eaef37e2f35a00f6f0b
|
6d4299ea826239093a91ff56c2399f66f76cc72a
|
/Visual Studio 2017/Projects/jungdae/jungdae/g.cpp
|
47031add3ad737867ec27bfd6238d81be529cedb
|
[] |
no_license
|
kongyi123/Algorithms
|
3eba88cff7dfb36fb4c7f3dc03800640b685801b
|
302750036b06cd6ead374d034d29a1144f190979
|
refs/heads/master
| 2022-06-18T07:23:35.652041
| 2022-05-29T16:07:56
| 2022-05-29T16:07:56
| 142,523,662
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,300
|
cpp
|
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int checkx[600];
int checky[600];
int x[110], y[110];
int xcnt, ycnt;
int data[600][4];
void swap(int &a, int &b) {
int t;
t = a;
a = b;
b = t;
}
int main(void) {
int n;
fscanf(stdin, "%d", &n);
for (int i = 1;i <= n;i++) {
int a, b, c, d;
fscanf(stdin, "%d %d %d %d", &a, &b, &c, &d);
data[i][0] = a;
data[i][1] = b;
data[i][2] = c;
data[i][3] = d;
if (checkx[a] == 0) {
checkx[a] = 1;
xcnt++;
x[xcnt] = a;
}
if (checky[b] == 0) {
checky[b] = 1;
ycnt++;
y[ycnt] = b;
}
if (checkx[c] == 0) {
checkx[c] = 1;
xcnt++;
x[xcnt] = c;
}
if (checky[d] == 0) {
checky[d] = 1;
ycnt++;
y[ycnt] = d;
}
}
for (int i = 1;i <= xcnt;i++) {
for (int j = i + 1;j <= xcnt;j++) {
if (x[i] > x[j]) swap(x[i], x[j]);
}
}
for (int i = 1;i <= ycnt;i++) {
for (int j = i + 1;j <= ycnt;j++) {
if (y[i] > y[j]) swap(y[i], y[j]);
}
}
int sum = 0;
for (int i = 1;i < ycnt;i++) {
for (int j = 1;j < xcnt;j++) {
for (int k = 1;k <= n;k++) {
if ( data[k][1] <= y[i] && y[i + 1] <= data[k][3]) {
if (data[k][0] <= x[j] && x[j + 1] <= data[k][2]) {
sum += (y[i + 1] - y[i])*(x[j + 1] - x[j]);
}
}
}
}
}
fprintf(stdout, "%d", sum);
return 0;
}
|
[
"kongyi123@nate.com"
] |
kongyi123@nate.com
|
bd12da2a32f7d3d3b04e959a66efbcc37386c4bc
|
9aee810d0d9d72d3dca7920447872216a3af49fe
|
/AtCoder/Others/typical90/typical90_aj.cpp
|
c4be38e7442b0d3a666191a93494fbd82c77e260
|
[] |
no_license
|
pulcherriman/Programming_Contest
|
37d014a414d473607a11c2edcb25764040edd686
|
715308628fc19843b8231526ad95dbe0064597a8
|
refs/heads/master
| 2023-08-04T00:36:36.540090
| 2023-07-30T18:31:32
| 2023-07-30T18:31:32
| 163,375,122
| 3
| 0
| null | 2023-01-24T11:02:11
| 2018-12-28T06:33:16
|
C++
|
UTF-8
|
C++
| false
| false
| 6,191
|
cpp
|
#pragma region Perfect Template
#pragma region Unsecured Optimization
// #pragma GCC target("avx")
// #pragma GCC optimize("O3,inline,omit-frame-pointer,no-asynchronous-unwind-tables,fast-math")
// #pragma GCC optimize("unroll-loops")
#ifdef _DEBUG
#define _GLIBCXX_DEBUG 1
#endif
#pragma endregion
#pragma region Include Headers
#if defined(EVAL) || defined(ONLINE_JUDGE) || defined(_DEBUG)
#include <atcoder/all>
using namespace atcoder;
#endif
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
void Main();
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}
#pragma endregion
#pragma region Additional Type Definition
using ll=long long;
using ld=long double;
using ull=unsigned long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
template<class K> using IndexedSet=__gnu_pbds::tree<K,__gnu_pbds::null_type,less<K>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<class K> using HashSet=__gnu_pbds::gp_hash_table<K,__gnu_pbds::null_type>;
template<class K,class V> using IndexedMap=__gnu_pbds::tree<K,V,less<K>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<class K,class V> using HashMap=__gnu_pbds::gp_hash_table<K,V>;
#pragma endregion
#pragma region Macros
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define __LOOPSWITCH(_1, _2, _3, __LOOPSWITCH, ...) __LOOPSWITCH
#define rep(...) __LOOPSWITCH(__VA_ARGS__, __RANGE, __REP, __LOOP) (__VA_ARGS__)
#define rrep(...) __LOOPSWITCH(__VA_ARGS__, __RRANGE, __RREP, __LOOP) (__VA_ARGS__)
#define __LOOP(q) __LOOP2(q, __LINE__)
#define __LOOP2(q,l) __LOOP3(q,l)
#define __LOOP3(q,l) __REP(_lp ## l,q)
#define __REP(i,n) __RANGE(i,0,n)
#define __RANGE(i,a,n) for(ll i=((ll)a);i<((ll)n);++i)
#define __RREP(i,n) __RRANGE(i,0,n)
#define __RRANGE(i,a,n) for(ll i=((ll)n-1);i>=((ll)a);--i)
#define repsq(i,n) for(ll i=0;i*i<=n;++i)
#define each(v,a) for(auto v:a)
#define eachref(v,a) for(auto&v:a)
#define fcout(a) cout<<setprecision(a)<<fixed
#pragma endregion
#pragma region Constants
constexpr ll LINF=1ll<<60;
constexpr int INF=1<<30;
constexpr double EPS=(1e-9);
constexpr ll MOD=1000000007ll;
constexpr long double PI=3.14159265358979323846;
#pragma endregion
#pragma region Output Assist
template<class T>struct hasItr{
template<class U>static constexpr true_type check(class U::iterator*);
template<class U>static constexpr false_type check(...);
static constexpr bool v=decltype(check<T>(nullptr))::value;
};
template<>struct hasItr<string>{static constexpr bool v=false;};
template<class T>void puta(T&t,false_type,ostream&os,[[maybe_unused]]char el){os<<t;}
template<class T>void puta(T&t,true_type,ostream&os,char el){
constexpr bool h=hasItr<typename T::value_type>::v;
bool F=true,I;
for(auto&i:t){
if(!F)os<<' ';
puta(i,bool_constant<h>(),os,el);
F=I=h;
}
if(!I)os<<el;
}
template<class T>void puta(const T&t, ostream&os=cout, char el='\n'){
puta(t,bool_constant<hasItr<T>::v>(),os,el);
if(!hasItr<T>::v)os<<el;
}
template<class H,class...T>void puta(const H&h,const T&...t){cout<<h<<' ';puta(t...);}
template<size_t i,class...T>void puta(tuple<T...>const&t, ostream&os){
if constexpr(i==sizeof...(T)-1)puta(get<i>(t),os);
else{os<<get<i>(t)<<' ';puta<i+1>(t,os);}
}
template<class...T>void puta(tuple<T...>const&t, ostream&os=cout){puta<0>(t,os);}
template<class S,class T>constexpr ostream&operator<<(ostream&os,pair<S,T>p){
os<<'['<<p.first<<", ";
if constexpr(hasItr<T>::v)puta(p.second,bool_constant<true>(),os,']');
else os<<p.second<<']';
return os;
};
template<class...T>constexpr ostream&operator<<(ostream&os,tuple<T...>t){puta(t,os); return os;}
void YN(bool b){puta(b?"YES":"NO");}
void Yn(bool b){puta(b?"Yes":"No");}
#ifdef _DEBUG
template<class T>void dump_f(const T&t){puta(t,cerr);}
template<class H,class...T>void dump_f(const H&h,const T&...t){cerr<<h<<' ';dump_f(t...);}
template<class...T>void dump_f(tuple<T...>const&t){puta(t,cerr);}
#define dump(...)cerr<<" "<<string(#__VA_ARGS__)<<": ["<<to_string(__LINE__)<<":"<<__FUNCTION__<<"]\n ",dump_f(__VA_ARGS__)
#else
#define dump(...)
#endif
#pragma endregion
#pragma region Input Assist
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}
template<typename...S>void geta_(S&...s){((cin>>s),...);}
#define geta(t,...) t __VA_ARGS__;geta_(__VA_ARGS__)
template<class T,class...Args>auto vec(T x,int arg,Args...args){if constexpr(sizeof...(args)==0)return vector(arg,x);else return vector(arg,vec(x,args...));}
#define getv(a,...) auto a=vec(__VA_ARGS__);cin>>a
#pragma endregion
#pragma region Utilities
template<class T>constexpr bool chmax(T&a,T b){return a<b?a=b,1:0;}
template<class T>constexpr bool chmin(T&a,T b){return a>b?a=b,1:0;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
template<class T>T gcd(vector<T> v){return accumulate(all(v),T(),gcd<T,T>);}
template<class T> pair<int,T> getMaxAndIndex(vector<T> a){
int p=-1; T v=numeric_limits<T>::min();
rep(i,a.size())if(chmax(v,a[i]))p=i;
return {p,v};
}
#pragma endregion
#pragma endregion
// ここにライブラリを貼る
// regionのfoldは[Ctrl+K] => [Ctrl+8] expandは9
#pragma region Additional Libraries
#pragma endregion
void Main(){
geta(ll, n,q);
vector<pll> p,mx,query;
rep(i,n){
geta(ll,a,b);
p.emplace_back(a-b,a+b);
}
rep(i,q){
geta(ll,j);
query.push_back(p[j-1]);
}
sort(all(p));
mx.push_back(p.front());
mx.push_back(p.back());
sort(all(p),[](pll a, pll b){return a.second<b.second;});
mx.push_back(p.front());
mx.push_back(p.back());
rep(i,q){
auto[yy,xx]=query[i];
ll ans=0;
for(auto&[y,x]:mx){
chmax(ans, abs(yy-y));
chmax(ans, abs(xx-x));
}
puta(ans);
}
}
|
[
"tsukasawa_agu@yahoo.co.jp"
] |
tsukasawa_agu@yahoo.co.jp
|
2180da046a8e66ddb21c5be5b4863afa82fe54b7
|
5dcf6767b53bf7299af6a4e135e69b18d6cf038d
|
/Textura.h
|
f35dff7b797cc3b832691aad7acc491d0e055ac9
|
[] |
no_license
|
ErickHCerecedo/EscenarioOpenGl
|
f25696f11b1994408981e05730aaaede359dfd4b
|
321d2ea520f8cad95c4fb0c4220cd262f306129c
|
refs/heads/master
| 2020-09-27T19:21:06.646670
| 2019-12-09T21:02:32
| 2019-12-09T21:02:32
| 226,590,871
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,408
|
h
|
#ifndef TEXTURA_H
#define TEXTURA_H
#ifdef __APPLE__
#define GL_SILENCE_DEPRECATION
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#include <GL/freeglut.h>
#endif
#include <GL/glext.h>
#include <stdlib.h>
#include <stdio.h>
#include "math.h"
#include "FreeImage.h"
#define NTextures 9
class Textura
{
public:
Textura();
virtual ~Textura();
bool readImage();
FreeImage_Initialise();
GLuint texture[NTextures];
//variables para manejo de texturas
char *texturefiles[NTextures] = {
"C:/Users/erick/Documents/CodeBlocks_Projects/ProyectoFinal/imagen1.bmp", //0
"C:/Users/erick/Documents/CodeBlocks_Projects/ProyectoFinal/imagen2.bmp", //1
"C:/Users/erick/Documents/CodeBlocks_Projects/ProyectoFinal/imagen3.bmp", //2
"C:/Users/erick/Documents/CodeBlocks_Projects/ProyectoFinal/img/Midday_Front.png",//3
"C:/Users/erick/Documents/CodeBlocks_Projects/ProyectoFinal/img/Midday_Right.png",//4
"C:/Users/erick/Documents/CodeBlocks_Projects/ProyectoFinal/img/Midday_Left.png", //5
"C:/Users/erick/Documents/CodeBlocks_Projects/ProyectoFinal/img/Midday_Back.png", //6
"C:/Users/erick/Documents/CodeBlocks_Projects/ProyectoFinal/img/Midday_Up.png", //7
"C:/Users/erick/Documents/CodeBlocks_Projects/ProyectoFinal/img/Midday_Down.png", //8
};
protected:
private:
};
#endif // TEXTURA_H
|
[
"erickcerecedo@gmail.com"
] |
erickcerecedo@gmail.com
|
d4565ef80ba01b6dfda9bf41f3e55d66bb22e401
|
974a495549988d2ead113ad6c1d800e952b6fb21
|
/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/pdf417/decoder/BitMatrixParser2.cpp
|
b8c396cefaf02e04f3bcc64d48dd999348169676
|
[
"MIT"
] |
permissive
|
188080501/JQTools
|
e46b2adf1c7f476229de20ac83753ee3d722327a
|
4c901a0671c0610f63bf38070d6674ef9bf00ef1
|
refs/heads/master
| 2023-08-30T15:43:03.271875
| 2023-06-06T14:14:22
| 2023-06-06T14:14:22
| 58,843,490
| 1,648
| 533
|
MIT
| 2023-06-06T14:13:24
| 2016-05-15T04:09:51
|
C++
|
UTF-8
|
C++
| false
| false
| 52,113
|
cpp
|
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
* Copyright 2008-2012 ZXing 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.
*
* Modified by Hartmut Neubauer (HFN)
*
* 2012-06-27 HFN plausibility checks of outer columns and modulus-3 conditions
* of rows added.
* 2012-09-?? HFN because the Detector now counts the rows, there is no more
* need to check the equality of consecutive rows. All rows are
* parsed now.
*/
#include <zxing/pdf417/decoder/BitMatrixParser.h>
using zxing::pdf417::decoder::BitMatrixParser;
using zxing::ArrayRef;
// VC++
using zxing::Ref;
using zxing::BitMatrix;
const int BitMatrixParser::MAX_ROWS = 90;
// Maximum Codewords (Data + Error)
const int BitMatrixParser::MAX_CW_CAPACITY = 929;
const int BitMatrixParser::MODULES_IN_SYMBOL = 17;
BitMatrixParser::BitMatrixParser(Ref<BitMatrix> bitMatrix)
: bitMatrix_(bitMatrix)
{
rows_ = 0;
leftColumnECData_ = 0;
rightColumnECData_ = 0;
for (int i = 0; i < 3; i++) {
aLeftColumnTriple_[i]=0;
aRightColumnTriple_[i]=0;
}
eraseCount_ = 0;
ecLevel_ = -1;
}
/**
* To ensure separability of rows, codewords of consecutive rows belong to
* different subsets of all possible codewords. This routine scans the
* symbols in the barcode. When it finds a number of consecutive rows which
* are the same, it assumes that this is a row of codewords and processes
* them into a codeword array.
*
* 2012-09-12 HFN: Because now, at an earlier stage, the Detector has counted
* the rows, now it is no more necessary to check the equality of consecutive
* rows. We now have to check every row.
*
* @return an array of codewords.
* @throw FormatException for example if number of rows is too big or something
* with row processing is bad
*/
ArrayRef<int> BitMatrixParser::readCodewords()
{
//int width = bitMatrix_->getWidth();
int height = bitMatrix_->getHeight();
erasures_ = new Array<int>(MAX_CW_CAPACITY);
ArrayRef<int> codewords (new Array<int>(MAX_CW_CAPACITY));
int next = 0;
int rowNumber = 0;
for (int i = 0; i < height; i++) {
if (rowNumber >= MAX_ROWS) {
// Something is wrong, since we have exceeded
// the maximum rows in the specification.
throw FormatException("BitMatrixParser::readCodewords(PDF): Too many rows!");
}
// Process Row
next = processRow(rowNumber, codewords, next);
rowNumber++;
}
erasures_ = trimArray(erasures_, eraseCount_);
return trimArray(codewords, next);
}
/**
* Convert the symbols in the row to codewords.
* Each PDF417 symbol character consists of four bar elements and four space
* elements, each of which can be one to six modules wide. The four bar and
* four space elements shall measure 17 modules in total.
*
* @param rowNumber the current row number of codewords.
* @param codewords the codeword array to save codewords into.
* @param next the next available index into the codewords array.
* @return the next available index into the codeword array after processing
* this row.
*/
int BitMatrixParser::processRow(int rowNumber, ArrayRef<int> codewords, int next) {
int width = bitMatrix_->getWidth();
int columnNumber = 0;
int cwClusterNumber = -1;
int64_t symbol = 0;
for (int i = 0; i < width; i += MODULES_IN_SYMBOL) {
for (int mask = MODULES_IN_SYMBOL - 1; mask >= 0; mask--) {
if (bitMatrix_->get(i + (MODULES_IN_SYMBOL - 1 - mask), rowNumber)) {
symbol |= int64_t(1) << mask;
}
}
if (columnNumber > 0) {
cwClusterNumber = -1;
int cw = getCodeword(symbol,&cwClusterNumber);
// 2012-06-27 HFN: cwClusterNumber should be the modulus of the row number by 3; otherwise,
// handle the codeword as erasure:
if ((cwClusterNumber >= 0) && (cwClusterNumber != rowNumber % 3)) {
cw = -1;
}
if (cw < 0 && i < width - MODULES_IN_SYMBOL) {
// Skip errors on the Right row indicator column
if (eraseCount_ >= (int)erasures_->size()) {
throw FormatException("BitMatrixParser::processRow(PDF417): eraseCount too big!");
}
erasures_[eraseCount_] = next;
next++;
eraseCount_++;
} else {
if (next >= codewords->size()) {
throw FormatException("BitMatrixParser::processRow(PDF417): codewords index out of bound.");
}
codewords[next++] = cw;
}
} else {
// Left row indicator column
cwClusterNumber = -1;
int cw = getCodeword(symbol,&cwClusterNumber);
aLeftColumnTriple_[rowNumber % 3] = cw; /* added 2012-06-22 hfn */
if (ecLevel_ < 0 && rowNumber % 3 == 1) {
leftColumnECData_ = cw;
}
}
symbol = 0;
columnNumber++;
}
if (columnNumber > 1) {
// Right row indicator column is in codeword[next]
// Overwrite the last codeword i.e. Right Row Indicator
--next;
aRightColumnTriple_[rowNumber % 3] = codewords[next]; /* added 2012-06-22 hfn */
if (rowNumber % 3 == 2) {
if (ecLevel_ < 0) {
rightColumnECData_ = codewords[next];
if (rightColumnECData_ == leftColumnECData_ && (int)leftColumnECData_ > 0) { /* leftColumnECData_ != 0 */
ecLevel_ = ((rightColumnECData_ % 30) - rows_ % 3) / 3;
}
}
// 2012-06-22 hfn: verify whether outer columns are still okay:
if (!VerifyOuterColumns(rowNumber)) {
throw FormatException("BitMatrixParser::processRow(PDF417): outer columns corrupted!");
}
}
codewords[next] = 0;
}
return next;
}
/* Static methods. */
/**
* Trim the array to the required size.
*
* @param array the array
* @param size the size to trim it to
* @return the new trimmed array
*/
ArrayRef<int> BitMatrixParser::trimArray(ArrayRef<int> array, int size)
{
if (size < 0) {
throw IllegalArgumentException("BitMatrixParser::trimArray: negative size!");
}
// 2012-10-12 hfn don't throw "NoErrorException" when size == 0
ArrayRef<int> a = new Array<int>(size);
for (int i = 0; i < size; i++) {
a[i] = array[i];
}
return a;
}
/**
* Translate the symbol into a codeword.
*
* @param symbol
* @return the codeword corresponding to the symbol.
*/
/**
* 2012-06-27 hfn With the second argument, it is possible to verify in which of the three
* "blocks" of the codeword table the codeword has been found: 0, 1 or 2.
*/
int BitMatrixParser::getCodeword(int64_t symbol, int *pi)
{
int64_t sym = symbol & 0x3FFFF;
int i = findCodewordIndex(sym);
if (i == -1) {
return -1;
} else {
int cw = CODEWORD_TABLE[i] - 1;
if (pi!= NULL) {
*pi = cw / 929;
}
cw %= 929;
return cw;
}
}
/**
* Use a binary search to find the index of the codeword corresponding to
* this symbol.
*
* @param symbol the symbol from the barcode.
* @return the index into the codeword table.
*/
int BitMatrixParser::findCodewordIndex(int64_t symbol)
{
int first = 0;
int upto = SYMBOL_TABLE_LENGTH;
while (first < upto) {
int mid = ((unsigned int)(first + upto)) >> 1; // Compute mid point.
if (symbol < SYMBOL_TABLE[mid]) {
upto = mid; // repeat search in bottom half.
} else if (symbol > SYMBOL_TABLE[mid]) {
first = mid + 1; // Repeat search in top half.
} else {
return mid; // Found it. return position
}
}
return -1;
}
/*
* 2012-06-22 hfn additional verification of outer columns
*/
bool BitMatrixParser::VerifyOuterColumns(int rownumber)
{
return IsEqual(aLeftColumnTriple_[0], aRightColumnTriple_[1], rownumber)
&& IsEqual(aLeftColumnTriple_[1], aRightColumnTriple_[2], rownumber)
&& IsEqual(aLeftColumnTriple_[2], aRightColumnTriple_[0], rownumber);
}
/*
* Verifies whether two codewords are equal or at least one of the codewords has not
* been recognized.
*/
bool BitMatrixParser::IsEqual(int &a, int &b, int rownumber)
{
int ret = (a == b) || (a == -1) || (b == -1);
if (!ret) {
int row3 = rownumber / 3;
int row30 = row3 * 30;
int row59 = row30 + 29;
if (a < row30 || a > row59) {
a = -1;
}
if (b < row30 || b > row59) {
b = -1;
}
}
return true;
}
const int BitMatrixParser::SYMBOL_TABLE[] =
{
0x1025e, 0x1027a, 0x1029e,
0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e, 0x1035c, 0x10396,
0x103a6, 0x103ac, 0x10422, 0x10428, 0x10436, 0x10442, 0x10444,
0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482,
0x1049e, 0x104a0, 0x104bc, 0x104c6, 0x104d8, 0x104ee, 0x104f2,
0x104f4, 0x10504, 0x10508, 0x10510, 0x1051e, 0x10520, 0x1053c,
0x10540, 0x10578, 0x10586, 0x1058c, 0x10598, 0x105b0, 0x105be,
0x105ce, 0x105dc, 0x105e2, 0x105e4, 0x105e8, 0x105f6, 0x1062e,
0x1064e, 0x1065c, 0x1068e, 0x1069c, 0x106b8, 0x106de, 0x106fa,
0x10716, 0x10726, 0x1072c, 0x10746, 0x1074c, 0x10758, 0x1076e,
0x10792, 0x10794, 0x107a2, 0x107a4, 0x107a8, 0x107b6, 0x10822,
0x10828, 0x10842, 0x10848, 0x10850, 0x1085e, 0x10866, 0x1086c,
0x1087a, 0x10882, 0x10884, 0x10890, 0x1089e, 0x108a0, 0x108bc,
0x108c6, 0x108cc, 0x108d8, 0x108ee, 0x108f2, 0x108f4, 0x10902,
0x10908, 0x1091e, 0x10920, 0x1093c, 0x10940, 0x10978, 0x10986,
0x10998, 0x109b0, 0x109be, 0x109ce, 0x109dc, 0x109e2, 0x109e4,
0x109e8, 0x109f6, 0x10a08, 0x10a10, 0x10a1e, 0x10a20, 0x10a3c,
0x10a40, 0x10a78, 0x10af0, 0x10b06, 0x10b0c, 0x10b18, 0x10b30,
0x10b3e, 0x10b60, 0x10b7c, 0x10b8e, 0x10b9c, 0x10bb8, 0x10bc2,
0x10bc4, 0x10bc8, 0x10bd0, 0x10bde, 0x10be6, 0x10bec, 0x10c2e,
0x10c4e, 0x10c5c, 0x10c62, 0x10c64, 0x10c68, 0x10c76, 0x10c8e,
0x10c9c, 0x10cb8, 0x10cc2, 0x10cc4, 0x10cc8, 0x10cd0, 0x10cde,
0x10ce6, 0x10cec, 0x10cfa, 0x10d0e, 0x10d1c, 0x10d38, 0x10d70,
0x10d7e, 0x10d82, 0x10d84, 0x10d88, 0x10d90, 0x10d9e, 0x10da0,
0x10dbc, 0x10dc6, 0x10dcc, 0x10dd8, 0x10dee, 0x10df2, 0x10df4,
0x10e16, 0x10e26, 0x10e2c, 0x10e46, 0x10e58, 0x10e6e, 0x10e86,
0x10e8c, 0x10e98, 0x10eb0, 0x10ebe, 0x10ece, 0x10edc, 0x10f0a,
0x10f12, 0x10f14, 0x10f22, 0x10f28, 0x10f36, 0x10f42, 0x10f44,
0x10f48, 0x10f50, 0x10f5e, 0x10f66, 0x10f6c, 0x10fb2, 0x10fb4,
0x11022, 0x11028, 0x11042, 0x11048, 0x11050, 0x1105e, 0x1107a,
0x11082, 0x11084, 0x11090, 0x1109e, 0x110a0, 0x110bc, 0x110c6,
0x110cc, 0x110d8, 0x110ee, 0x110f2, 0x110f4, 0x11102, 0x1111e,
0x11120, 0x1113c, 0x11140, 0x11178, 0x11186, 0x11198, 0x111b0,
0x111be, 0x111ce, 0x111dc, 0x111e2, 0x111e4, 0x111e8, 0x111f6,
0x11208, 0x1121e, 0x11220, 0x11278, 0x112f0, 0x1130c, 0x11330,
0x1133e, 0x11360, 0x1137c, 0x1138e, 0x1139c, 0x113b8, 0x113c2,
0x113c8, 0x113d0, 0x113de, 0x113e6, 0x113ec, 0x11408, 0x11410,
0x1141e, 0x11420, 0x1143c, 0x11440, 0x11478, 0x114f0, 0x115e0,
0x1160c, 0x11618, 0x11630, 0x1163e, 0x11660, 0x1167c, 0x116c0,
0x116f8, 0x1171c, 0x11738, 0x11770, 0x1177e, 0x11782, 0x11784,
0x11788, 0x11790, 0x1179e, 0x117a0, 0x117bc, 0x117c6, 0x117cc,
0x117d8, 0x117ee, 0x1182e, 0x11834, 0x1184e, 0x1185c, 0x11862,
0x11864, 0x11868, 0x11876, 0x1188e, 0x1189c, 0x118b8, 0x118c2,
0x118c8, 0x118d0, 0x118de, 0x118e6, 0x118ec, 0x118fa, 0x1190e,
0x1191c, 0x11938, 0x11970, 0x1197e, 0x11982, 0x11984, 0x11990,
0x1199e, 0x119a0, 0x119bc, 0x119c6, 0x119cc, 0x119d8, 0x119ee,
0x119f2, 0x119f4, 0x11a0e, 0x11a1c, 0x11a38, 0x11a70, 0x11a7e,
0x11ae0, 0x11afc, 0x11b08, 0x11b10, 0x11b1e, 0x11b20, 0x11b3c,
0x11b40, 0x11b78, 0x11b8c, 0x11b98, 0x11bb0, 0x11bbe, 0x11bce,
0x11bdc, 0x11be2, 0x11be4, 0x11be8, 0x11bf6, 0x11c16, 0x11c26,
0x11c2c, 0x11c46, 0x11c4c, 0x11c58, 0x11c6e, 0x11c86, 0x11c98,
0x11cb0, 0x11cbe, 0x11cce, 0x11cdc, 0x11ce2, 0x11ce4, 0x11ce8,
0x11cf6, 0x11d06, 0x11d0c, 0x11d18, 0x11d30, 0x11d3e, 0x11d60,
0x11d7c, 0x11d8e, 0x11d9c, 0x11db8, 0x11dc4, 0x11dc8, 0x11dd0,
0x11dde, 0x11de6, 0x11dec, 0x11dfa, 0x11e0a, 0x11e12, 0x11e14,
0x11e22, 0x11e24, 0x11e28, 0x11e36, 0x11e42, 0x11e44, 0x11e50,
0x11e5e, 0x11e66, 0x11e6c, 0x11e82, 0x11e84, 0x11e88, 0x11e90,
0x11e9e, 0x11ea0, 0x11ebc, 0x11ec6, 0x11ecc, 0x11ed8, 0x11eee,
0x11f1a, 0x11f2e, 0x11f32, 0x11f34, 0x11f4e, 0x11f5c, 0x11f62,
0x11f64, 0x11f68, 0x11f76, 0x12048, 0x1205e, 0x12082, 0x12084,
0x12090, 0x1209e, 0x120a0, 0x120bc, 0x120d8, 0x120f2, 0x120f4,
0x12108, 0x1211e, 0x12120, 0x1213c, 0x12140, 0x12178, 0x12186,
0x12198, 0x121b0, 0x121be, 0x121e2, 0x121e4, 0x121e8, 0x121f6,
0x12204, 0x12210, 0x1221e, 0x12220, 0x12278, 0x122f0, 0x12306,
0x1230c, 0x12330, 0x1233e, 0x12360, 0x1237c, 0x1238e, 0x1239c,
0x123b8, 0x123c2, 0x123c8, 0x123d0, 0x123e6, 0x123ec, 0x1241e,
0x12420, 0x1243c, 0x124f0, 0x125e0, 0x12618, 0x1263e, 0x12660,
0x1267c, 0x126c0, 0x126f8, 0x12738, 0x12770, 0x1277e, 0x12782,
0x12784, 0x12790, 0x1279e, 0x127a0, 0x127bc, 0x127c6, 0x127cc,
0x127d8, 0x127ee, 0x12820, 0x1283c, 0x12840, 0x12878, 0x128f0,
0x129e0, 0x12bc0, 0x12c18, 0x12c30, 0x12c3e, 0x12c60, 0x12c7c,
0x12cc0, 0x12cf8, 0x12df0, 0x12e1c, 0x12e38, 0x12e70, 0x12e7e,
0x12ee0, 0x12efc, 0x12f04, 0x12f08, 0x12f10, 0x12f20, 0x12f3c,
0x12f40, 0x12f78, 0x12f86, 0x12f8c, 0x12f98, 0x12fb0, 0x12fbe,
0x12fce, 0x12fdc, 0x1302e, 0x1304e, 0x1305c, 0x13062, 0x13068,
0x1308e, 0x1309c, 0x130b8, 0x130c2, 0x130c8, 0x130d0, 0x130de,
0x130ec, 0x130fa, 0x1310e, 0x13138, 0x13170, 0x1317e, 0x13182,
0x13184, 0x13190, 0x1319e, 0x131a0, 0x131bc, 0x131c6, 0x131cc,
0x131d8, 0x131f2, 0x131f4, 0x1320e, 0x1321c, 0x13270, 0x1327e,
0x132e0, 0x132fc, 0x13308, 0x1331e, 0x13320, 0x1333c, 0x13340,
0x13378, 0x13386, 0x13398, 0x133b0, 0x133be, 0x133ce, 0x133dc,
0x133e2, 0x133e4, 0x133e8, 0x133f6, 0x1340e, 0x1341c, 0x13438,
0x13470, 0x1347e, 0x134e0, 0x134fc, 0x135c0, 0x135f8, 0x13608,
0x13610, 0x1361e, 0x13620, 0x1363c, 0x13640, 0x13678, 0x136f0,
0x1370c, 0x13718, 0x13730, 0x1373e, 0x13760, 0x1377c, 0x1379c,
0x137b8, 0x137c2, 0x137c4, 0x137c8, 0x137d0, 0x137de, 0x137e6,
0x137ec, 0x13816, 0x13826, 0x1382c, 0x13846, 0x1384c, 0x13858,
0x1386e, 0x13874, 0x13886, 0x13898, 0x138b0, 0x138be, 0x138ce,
0x138dc, 0x138e2, 0x138e4, 0x138e8, 0x13906, 0x1390c, 0x13930,
0x1393e, 0x13960, 0x1397c, 0x1398e, 0x1399c, 0x139b8, 0x139c8,
0x139d0, 0x139de, 0x139e6, 0x139ec, 0x139fa, 0x13a06, 0x13a0c,
0x13a18, 0x13a30, 0x13a3e, 0x13a60, 0x13a7c, 0x13ac0, 0x13af8,
0x13b0e, 0x13b1c, 0x13b38, 0x13b70, 0x13b7e, 0x13b88, 0x13b90,
0x13b9e, 0x13ba0, 0x13bbc, 0x13bcc, 0x13bd8, 0x13bee, 0x13bf2,
0x13bf4, 0x13c12, 0x13c14, 0x13c22, 0x13c24, 0x13c28, 0x13c36,
0x13c42, 0x13c48, 0x13c50, 0x13c5e, 0x13c66, 0x13c6c, 0x13c82,
0x13c84, 0x13c90, 0x13c9e, 0x13ca0, 0x13cbc, 0x13cc6, 0x13ccc,
0x13cd8, 0x13cee, 0x13d02, 0x13d04, 0x13d08, 0x13d10, 0x13d1e,
0x13d20, 0x13d3c, 0x13d40, 0x13d78, 0x13d86, 0x13d8c, 0x13d98,
0x13db0, 0x13dbe, 0x13dce, 0x13ddc, 0x13de4, 0x13de8, 0x13df6,
0x13e1a, 0x13e2e, 0x13e32, 0x13e34, 0x13e4e, 0x13e5c, 0x13e62,
0x13e64, 0x13e68, 0x13e76, 0x13e8e, 0x13e9c, 0x13eb8, 0x13ec2,
0x13ec4, 0x13ec8, 0x13ed0, 0x13ede, 0x13ee6, 0x13eec, 0x13f26,
0x13f2c, 0x13f3a, 0x13f46, 0x13f4c, 0x13f58, 0x13f6e, 0x13f72,
0x13f74, 0x14082, 0x1409e, 0x140a0, 0x140bc, 0x14104, 0x14108,
0x14110, 0x1411e, 0x14120, 0x1413c, 0x14140, 0x14178, 0x1418c,
0x14198, 0x141b0, 0x141be, 0x141e2, 0x141e4, 0x141e8, 0x14208,
0x14210, 0x1421e, 0x14220, 0x1423c, 0x14240, 0x14278, 0x142f0,
0x14306, 0x1430c, 0x14318, 0x14330, 0x1433e, 0x14360, 0x1437c,
0x1438e, 0x143c2, 0x143c4, 0x143c8, 0x143d0, 0x143e6, 0x143ec,
0x14408, 0x14410, 0x1441e, 0x14420, 0x1443c, 0x14440, 0x14478,
0x144f0, 0x145e0, 0x1460c, 0x14618, 0x14630, 0x1463e, 0x14660,
0x1467c, 0x146c0, 0x146f8, 0x1471c, 0x14738, 0x14770, 0x1477e,
0x14782, 0x14784, 0x14788, 0x14790, 0x147a0, 0x147bc, 0x147c6,
0x147cc, 0x147d8, 0x147ee, 0x14810, 0x14820, 0x1483c, 0x14840,
0x14878, 0x148f0, 0x149e0, 0x14bc0, 0x14c30, 0x14c3e, 0x14c60,
0x14c7c, 0x14cc0, 0x14cf8, 0x14df0, 0x14e38, 0x14e70, 0x14e7e,
0x14ee0, 0x14efc, 0x14f04, 0x14f08, 0x14f10, 0x14f1e, 0x14f20,
0x14f3c, 0x14f40, 0x14f78, 0x14f86, 0x14f8c, 0x14f98, 0x14fb0,
0x14fce, 0x14fdc, 0x15020, 0x15040, 0x15078, 0x150f0, 0x151e0,
0x153c0, 0x15860, 0x1587c, 0x158c0, 0x158f8, 0x159f0, 0x15be0,
0x15c70, 0x15c7e, 0x15ce0, 0x15cfc, 0x15dc0, 0x15df8, 0x15e08,
0x15e10, 0x15e20, 0x15e40, 0x15e78, 0x15ef0, 0x15f0c, 0x15f18,
0x15f30, 0x15f60, 0x15f7c, 0x15f8e, 0x15f9c, 0x15fb8, 0x1604e,
0x1605c, 0x1608e, 0x1609c, 0x160b8, 0x160c2, 0x160c4, 0x160c8,
0x160de, 0x1610e, 0x1611c, 0x16138, 0x16170, 0x1617e, 0x16184,
0x16188, 0x16190, 0x1619e, 0x161a0, 0x161bc, 0x161c6, 0x161cc,
0x161d8, 0x161f2, 0x161f4, 0x1620e, 0x1621c, 0x16238, 0x16270,
0x1627e, 0x162e0, 0x162fc, 0x16304, 0x16308, 0x16310, 0x1631e,
0x16320, 0x1633c, 0x16340, 0x16378, 0x16386, 0x1638c, 0x16398,
0x163b0, 0x163be, 0x163ce, 0x163dc, 0x163e2, 0x163e4, 0x163e8,
0x163f6, 0x1640e, 0x1641c, 0x16438, 0x16470, 0x1647e, 0x164e0,
0x164fc, 0x165c0, 0x165f8, 0x16610, 0x1661e, 0x16620, 0x1663c,
0x16640, 0x16678, 0x166f0, 0x16718, 0x16730, 0x1673e, 0x16760,
0x1677c, 0x1678e, 0x1679c, 0x167b8, 0x167c2, 0x167c4, 0x167c8,
0x167d0, 0x167de, 0x167e6, 0x167ec, 0x1681c, 0x16838, 0x16870,
0x168e0, 0x168fc, 0x169c0, 0x169f8, 0x16bf0, 0x16c10, 0x16c1e,
0x16c20, 0x16c3c, 0x16c40, 0x16c78, 0x16cf0, 0x16de0, 0x16e18,
0x16e30, 0x16e3e, 0x16e60, 0x16e7c, 0x16ec0, 0x16ef8, 0x16f1c,
0x16f38, 0x16f70, 0x16f7e, 0x16f84, 0x16f88, 0x16f90, 0x16f9e,
0x16fa0, 0x16fbc, 0x16fc6, 0x16fcc, 0x16fd8, 0x17026, 0x1702c,
0x17046, 0x1704c, 0x17058, 0x1706e, 0x17086, 0x1708c, 0x17098,
0x170b0, 0x170be, 0x170ce, 0x170dc, 0x170e8, 0x17106, 0x1710c,
0x17118, 0x17130, 0x1713e, 0x17160, 0x1717c, 0x1718e, 0x1719c,
0x171b8, 0x171c2, 0x171c4, 0x171c8, 0x171d0, 0x171de, 0x171e6,
0x171ec, 0x171fa, 0x17206, 0x1720c, 0x17218, 0x17230, 0x1723e,
0x17260, 0x1727c, 0x172c0, 0x172f8, 0x1730e, 0x1731c, 0x17338,
0x17370, 0x1737e, 0x17388, 0x17390, 0x1739e, 0x173a0, 0x173bc,
0x173cc, 0x173d8, 0x173ee, 0x173f2, 0x173f4, 0x1740c, 0x17418,
0x17430, 0x1743e, 0x17460, 0x1747c, 0x174c0, 0x174f8, 0x175f0,
0x1760e, 0x1761c, 0x17638, 0x17670, 0x1767e, 0x176e0, 0x176fc,
0x17708, 0x17710, 0x1771e, 0x17720, 0x1773c, 0x17740, 0x17778,
0x17798, 0x177b0, 0x177be, 0x177dc, 0x177e2, 0x177e4, 0x177e8,
0x17822, 0x17824, 0x17828, 0x17836, 0x17842, 0x17844, 0x17848,
0x17850, 0x1785e, 0x17866, 0x1786c, 0x17882, 0x17884, 0x17888,
0x17890, 0x1789e, 0x178a0, 0x178bc, 0x178c6, 0x178cc, 0x178d8,
0x178ee, 0x178f2, 0x178f4, 0x17902, 0x17904, 0x17908, 0x17910,
0x1791e, 0x17920, 0x1793c, 0x17940, 0x17978, 0x17986, 0x1798c,
0x17998, 0x179b0, 0x179be, 0x179ce, 0x179dc, 0x179e2, 0x179e4,
0x179e8, 0x179f6, 0x17a04, 0x17a08, 0x17a10, 0x17a1e, 0x17a20,
0x17a3c, 0x17a40, 0x17a78, 0x17af0, 0x17b06, 0x17b0c, 0x17b18,
0x17b30, 0x17b3e, 0x17b60, 0x17b7c, 0x17b8e, 0x17b9c, 0x17bb8,
0x17bc4, 0x17bc8, 0x17bd0, 0x17bde, 0x17be6, 0x17bec, 0x17c2e,
0x17c32, 0x17c34, 0x17c4e, 0x17c5c, 0x17c62, 0x17c64, 0x17c68,
0x17c76, 0x17c8e, 0x17c9c, 0x17cb8, 0x17cc2, 0x17cc4, 0x17cc8,
0x17cd0, 0x17cde, 0x17ce6, 0x17cec, 0x17d0e, 0x17d1c, 0x17d38,
0x17d70, 0x17d82, 0x17d84, 0x17d88, 0x17d90, 0x17d9e, 0x17da0,
0x17dbc, 0x17dc6, 0x17dcc, 0x17dd8, 0x17dee, 0x17e26, 0x17e2c,
0x17e3a, 0x17e46, 0x17e4c, 0x17e58, 0x17e6e, 0x17e72, 0x17e74,
0x17e86, 0x17e8c, 0x17e98, 0x17eb0, 0x17ece, 0x17edc, 0x17ee2,
0x17ee4, 0x17ee8, 0x17ef6, 0x1813a, 0x18172, 0x18174, 0x18216,
0x18226, 0x1823a, 0x1824c, 0x18258, 0x1826e, 0x18272, 0x18274,
0x18298, 0x182be, 0x182e2, 0x182e4, 0x182e8, 0x182f6, 0x1835e,
0x1837a, 0x183ae, 0x183d6, 0x18416, 0x18426, 0x1842c, 0x1843a,
0x18446, 0x18458, 0x1846e, 0x18472, 0x18474, 0x18486, 0x184b0,
0x184be, 0x184ce, 0x184dc, 0x184e2, 0x184e4, 0x184e8, 0x184f6,
0x18506, 0x1850c, 0x18518, 0x18530, 0x1853e, 0x18560, 0x1857c,
0x1858e, 0x1859c, 0x185b8, 0x185c2, 0x185c4, 0x185c8, 0x185d0,
0x185de, 0x185e6, 0x185ec, 0x185fa, 0x18612, 0x18614, 0x18622,
0x18628, 0x18636, 0x18642, 0x18650, 0x1865e, 0x1867a, 0x18682,
0x18684, 0x18688, 0x18690, 0x1869e, 0x186a0, 0x186bc, 0x186c6,
0x186cc, 0x186d8, 0x186ee, 0x186f2, 0x186f4, 0x1872e, 0x1874e,
0x1875c, 0x18796, 0x187a6, 0x187ac, 0x187d2, 0x187d4, 0x18826,
0x1882c, 0x1883a, 0x18846, 0x1884c, 0x18858, 0x1886e, 0x18872,
0x18874, 0x18886, 0x18898, 0x188b0, 0x188be, 0x188ce, 0x188dc,
0x188e2, 0x188e4, 0x188e8, 0x188f6, 0x1890c, 0x18930, 0x1893e,
0x18960, 0x1897c, 0x1898e, 0x189b8, 0x189c2, 0x189c8, 0x189d0,
0x189de, 0x189e6, 0x189ec, 0x189fa, 0x18a18, 0x18a30, 0x18a3e,
0x18a60, 0x18a7c, 0x18ac0, 0x18af8, 0x18b1c, 0x18b38, 0x18b70,
0x18b7e, 0x18b82, 0x18b84, 0x18b88, 0x18b90, 0x18b9e, 0x18ba0,
0x18bbc, 0x18bc6, 0x18bcc, 0x18bd8, 0x18bee, 0x18bf2, 0x18bf4,
0x18c22, 0x18c24, 0x18c28, 0x18c36, 0x18c42, 0x18c48, 0x18c50,
0x18c5e, 0x18c66, 0x18c7a, 0x18c82, 0x18c84, 0x18c90, 0x18c9e,
0x18ca0, 0x18cbc, 0x18ccc, 0x18cf2, 0x18cf4, 0x18d04, 0x18d08,
0x18d10, 0x18d1e, 0x18d20, 0x18d3c, 0x18d40, 0x18d78, 0x18d86,
0x18d98, 0x18dce, 0x18de2, 0x18de4, 0x18de8, 0x18e2e, 0x18e32,
0x18e34, 0x18e4e, 0x18e5c, 0x18e62, 0x18e64, 0x18e68, 0x18e8e,
0x18e9c, 0x18eb8, 0x18ec2, 0x18ec4, 0x18ec8, 0x18ed0, 0x18efa,
0x18f16, 0x18f26, 0x18f2c, 0x18f46, 0x18f4c, 0x18f58, 0x18f6e,
0x18f8a, 0x18f92, 0x18f94, 0x18fa2, 0x18fa4, 0x18fa8, 0x18fb6,
0x1902c, 0x1903a, 0x19046, 0x1904c, 0x19058, 0x19072, 0x19074,
0x19086, 0x19098, 0x190b0, 0x190be, 0x190ce, 0x190dc, 0x190e2,
0x190e8, 0x190f6, 0x19106, 0x1910c, 0x19130, 0x1913e, 0x19160,
0x1917c, 0x1918e, 0x1919c, 0x191b8, 0x191c2, 0x191c8, 0x191d0,
0x191de, 0x191e6, 0x191ec, 0x191fa, 0x19218, 0x1923e, 0x19260,
0x1927c, 0x192c0, 0x192f8, 0x19338, 0x19370, 0x1937e, 0x19382,
0x19384, 0x19390, 0x1939e, 0x193a0, 0x193bc, 0x193c6, 0x193cc,
0x193d8, 0x193ee, 0x193f2, 0x193f4, 0x19430, 0x1943e, 0x19460,
0x1947c, 0x194c0, 0x194f8, 0x195f0, 0x19638, 0x19670, 0x1967e,
0x196e0, 0x196fc, 0x19702, 0x19704, 0x19708, 0x19710, 0x19720,
0x1973c, 0x19740, 0x19778, 0x19786, 0x1978c, 0x19798, 0x197b0,
0x197be, 0x197ce, 0x197dc, 0x197e2, 0x197e4, 0x197e8, 0x19822,
0x19824, 0x19842, 0x19848, 0x19850, 0x1985e, 0x19866, 0x1987a,
0x19882, 0x19884, 0x19890, 0x1989e, 0x198a0, 0x198bc, 0x198cc,
0x198f2, 0x198f4, 0x19902, 0x19908, 0x1991e, 0x19920, 0x1993c,
0x19940, 0x19978, 0x19986, 0x19998, 0x199ce, 0x199e2, 0x199e4,
0x199e8, 0x19a08, 0x19a10, 0x19a1e, 0x19a20, 0x19a3c, 0x19a40,
0x19a78, 0x19af0, 0x19b18, 0x19b3e, 0x19b60, 0x19b9c, 0x19bc2,
0x19bc4, 0x19bc8, 0x19bd0, 0x19be6, 0x19c2e, 0x19c34, 0x19c4e,
0x19c5c, 0x19c62, 0x19c64, 0x19c68, 0x19c8e, 0x19c9c, 0x19cb8,
0x19cc2, 0x19cc8, 0x19cd0, 0x19ce6, 0x19cfa, 0x19d0e, 0x19d1c,
0x19d38, 0x19d70, 0x19d7e, 0x19d82, 0x19d84, 0x19d88, 0x19d90,
0x19da0, 0x19dcc, 0x19df2, 0x19df4, 0x19e16, 0x19e26, 0x19e2c,
0x19e46, 0x19e4c, 0x19e58, 0x19e74, 0x19e86, 0x19e8c, 0x19e98,
0x19eb0, 0x19ebe, 0x19ece, 0x19ee2, 0x19ee4, 0x19ee8, 0x19f0a,
0x19f12, 0x19f14, 0x19f22, 0x19f24, 0x19f28, 0x19f42, 0x19f44,
0x19f48, 0x19f50, 0x19f5e, 0x19f6c, 0x19f9a, 0x19fae, 0x19fb2,
0x19fb4, 0x1a046, 0x1a04c, 0x1a072, 0x1a074, 0x1a086, 0x1a08c,
0x1a098, 0x1a0b0, 0x1a0be, 0x1a0e2, 0x1a0e4, 0x1a0e8, 0x1a0f6,
0x1a106, 0x1a10c, 0x1a118, 0x1a130, 0x1a13e, 0x1a160, 0x1a17c,
0x1a18e, 0x1a19c, 0x1a1b8, 0x1a1c2, 0x1a1c4, 0x1a1c8, 0x1a1d0,
0x1a1de, 0x1a1e6, 0x1a1ec, 0x1a218, 0x1a230, 0x1a23e, 0x1a260,
0x1a27c, 0x1a2c0, 0x1a2f8, 0x1a31c, 0x1a338, 0x1a370, 0x1a37e,
0x1a382, 0x1a384, 0x1a388, 0x1a390, 0x1a39e, 0x1a3a0, 0x1a3bc,
0x1a3c6, 0x1a3cc, 0x1a3d8, 0x1a3ee, 0x1a3f2, 0x1a3f4, 0x1a418,
0x1a430, 0x1a43e, 0x1a460, 0x1a47c, 0x1a4c0, 0x1a4f8, 0x1a5f0,
0x1a61c, 0x1a638, 0x1a670, 0x1a67e, 0x1a6e0, 0x1a6fc, 0x1a702,
0x1a704, 0x1a708, 0x1a710, 0x1a71e, 0x1a720, 0x1a73c, 0x1a740,
0x1a778, 0x1a786, 0x1a78c, 0x1a798, 0x1a7b0, 0x1a7be, 0x1a7ce,
0x1a7dc, 0x1a7e2, 0x1a7e4, 0x1a7e8, 0x1a830, 0x1a860, 0x1a87c,
0x1a8c0, 0x1a8f8, 0x1a9f0, 0x1abe0, 0x1ac70, 0x1ac7e, 0x1ace0,
0x1acfc, 0x1adc0, 0x1adf8, 0x1ae04, 0x1ae08, 0x1ae10, 0x1ae20,
0x1ae3c, 0x1ae40, 0x1ae78, 0x1aef0, 0x1af06, 0x1af0c, 0x1af18,
0x1af30, 0x1af3e, 0x1af60, 0x1af7c, 0x1af8e, 0x1af9c, 0x1afb8,
0x1afc4, 0x1afc8, 0x1afd0, 0x1afde, 0x1b042, 0x1b05e, 0x1b07a,
0x1b082, 0x1b084, 0x1b088, 0x1b090, 0x1b09e, 0x1b0a0, 0x1b0bc,
0x1b0cc, 0x1b0f2, 0x1b0f4, 0x1b102, 0x1b104, 0x1b108, 0x1b110,
0x1b11e, 0x1b120, 0x1b13c, 0x1b140, 0x1b178, 0x1b186, 0x1b198,
0x1b1ce, 0x1b1e2, 0x1b1e4, 0x1b1e8, 0x1b204, 0x1b208, 0x1b210,
0x1b21e, 0x1b220, 0x1b23c, 0x1b240, 0x1b278, 0x1b2f0, 0x1b30c,
0x1b33e, 0x1b360, 0x1b39c, 0x1b3c2, 0x1b3c4, 0x1b3c8, 0x1b3d0,
0x1b3e6, 0x1b410, 0x1b41e, 0x1b420, 0x1b43c, 0x1b440, 0x1b478,
0x1b4f0, 0x1b5e0, 0x1b618, 0x1b660, 0x1b67c, 0x1b6c0, 0x1b738,
0x1b782, 0x1b784, 0x1b788, 0x1b790, 0x1b79e, 0x1b7a0, 0x1b7cc,
0x1b82e, 0x1b84e, 0x1b85c, 0x1b88e, 0x1b89c, 0x1b8b8, 0x1b8c2,
0x1b8c4, 0x1b8c8, 0x1b8d0, 0x1b8e6, 0x1b8fa, 0x1b90e, 0x1b91c,
0x1b938, 0x1b970, 0x1b97e, 0x1b982, 0x1b984, 0x1b988, 0x1b990,
0x1b99e, 0x1b9a0, 0x1b9cc, 0x1b9f2, 0x1b9f4, 0x1ba0e, 0x1ba1c,
0x1ba38, 0x1ba70, 0x1ba7e, 0x1bae0, 0x1bafc, 0x1bb08, 0x1bb10,
0x1bb20, 0x1bb3c, 0x1bb40, 0x1bb98, 0x1bbce, 0x1bbe2, 0x1bbe4,
0x1bbe8, 0x1bc16, 0x1bc26, 0x1bc2c, 0x1bc46, 0x1bc4c, 0x1bc58,
0x1bc72, 0x1bc74, 0x1bc86, 0x1bc8c, 0x1bc98, 0x1bcb0, 0x1bcbe,
0x1bcce, 0x1bce2, 0x1bce4, 0x1bce8, 0x1bd06, 0x1bd0c, 0x1bd18,
0x1bd30, 0x1bd3e, 0x1bd60, 0x1bd7c, 0x1bd9c, 0x1bdc2, 0x1bdc4,
0x1bdc8, 0x1bdd0, 0x1bde6, 0x1bdfa, 0x1be12, 0x1be14, 0x1be22,
0x1be24, 0x1be28, 0x1be42, 0x1be44, 0x1be48, 0x1be50, 0x1be5e,
0x1be66, 0x1be82, 0x1be84, 0x1be88, 0x1be90, 0x1be9e, 0x1bea0,
0x1bebc, 0x1becc, 0x1bef4, 0x1bf1a, 0x1bf2e, 0x1bf32, 0x1bf34,
0x1bf4e, 0x1bf5c, 0x1bf62, 0x1bf64, 0x1bf68, 0x1c09a, 0x1c0b2,
0x1c0b4, 0x1c11a, 0x1c132, 0x1c134, 0x1c162, 0x1c164, 0x1c168,
0x1c176, 0x1c1ba, 0x1c21a, 0x1c232, 0x1c234, 0x1c24e, 0x1c25c,
0x1c262, 0x1c264, 0x1c268, 0x1c276, 0x1c28e, 0x1c2c2, 0x1c2c4,
0x1c2c8, 0x1c2d0, 0x1c2de, 0x1c2e6, 0x1c2ec, 0x1c2fa, 0x1c316,
0x1c326, 0x1c33a, 0x1c346, 0x1c34c, 0x1c372, 0x1c374, 0x1c41a,
0x1c42e, 0x1c432, 0x1c434, 0x1c44e, 0x1c45c, 0x1c462, 0x1c464,
0x1c468, 0x1c476, 0x1c48e, 0x1c49c, 0x1c4b8, 0x1c4c2, 0x1c4c8,
0x1c4d0, 0x1c4de, 0x1c4e6, 0x1c4ec, 0x1c4fa, 0x1c51c, 0x1c538,
0x1c570, 0x1c57e, 0x1c582, 0x1c584, 0x1c588, 0x1c590, 0x1c59e,
0x1c5a0, 0x1c5bc, 0x1c5c6, 0x1c5cc, 0x1c5d8, 0x1c5ee, 0x1c5f2,
0x1c5f4, 0x1c616, 0x1c626, 0x1c62c, 0x1c63a, 0x1c646, 0x1c64c,
0x1c658, 0x1c66e, 0x1c672, 0x1c674, 0x1c686, 0x1c68c, 0x1c698,
0x1c6b0, 0x1c6be, 0x1c6ce, 0x1c6dc, 0x1c6e2, 0x1c6e4, 0x1c6e8,
0x1c712, 0x1c714, 0x1c722, 0x1c728, 0x1c736, 0x1c742, 0x1c744,
0x1c748, 0x1c750, 0x1c75e, 0x1c766, 0x1c76c, 0x1c77a, 0x1c7ae,
0x1c7d6, 0x1c7ea, 0x1c81a, 0x1c82e, 0x1c832, 0x1c834, 0x1c84e,
0x1c85c, 0x1c862, 0x1c864, 0x1c868, 0x1c876, 0x1c88e, 0x1c89c,
0x1c8b8, 0x1c8c2, 0x1c8c8, 0x1c8d0, 0x1c8de, 0x1c8e6, 0x1c8ec,
0x1c8fa, 0x1c90e, 0x1c938, 0x1c970, 0x1c97e, 0x1c982, 0x1c984,
0x1c990, 0x1c99e, 0x1c9a0, 0x1c9bc, 0x1c9c6, 0x1c9cc, 0x1c9d8,
0x1c9ee, 0x1c9f2, 0x1c9f4, 0x1ca38, 0x1ca70, 0x1ca7e, 0x1cae0,
0x1cafc, 0x1cb02, 0x1cb04, 0x1cb08, 0x1cb10, 0x1cb20, 0x1cb3c,
0x1cb40, 0x1cb78, 0x1cb86, 0x1cb8c, 0x1cb98, 0x1cbb0, 0x1cbbe,
0x1cbce, 0x1cbdc, 0x1cbe2, 0x1cbe4, 0x1cbe8, 0x1cbf6, 0x1cc16,
0x1cc26, 0x1cc2c, 0x1cc3a, 0x1cc46, 0x1cc58, 0x1cc72, 0x1cc74,
0x1cc86, 0x1ccb0, 0x1ccbe, 0x1ccce, 0x1cce2, 0x1cce4, 0x1cce8,
0x1cd06, 0x1cd0c, 0x1cd18, 0x1cd30, 0x1cd3e, 0x1cd60, 0x1cd7c,
0x1cd9c, 0x1cdc2, 0x1cdc4, 0x1cdc8, 0x1cdd0, 0x1cdde, 0x1cde6,
0x1cdfa, 0x1ce22, 0x1ce28, 0x1ce42, 0x1ce50, 0x1ce5e, 0x1ce66,
0x1ce7a, 0x1ce82, 0x1ce84, 0x1ce88, 0x1ce90, 0x1ce9e, 0x1cea0,
0x1cebc, 0x1cecc, 0x1cef2, 0x1cef4, 0x1cf2e, 0x1cf32, 0x1cf34,
0x1cf4e, 0x1cf5c, 0x1cf62, 0x1cf64, 0x1cf68, 0x1cf96, 0x1cfa6,
0x1cfac, 0x1cfca, 0x1cfd2, 0x1cfd4, 0x1d02e, 0x1d032, 0x1d034,
0x1d04e, 0x1d05c, 0x1d062, 0x1d064, 0x1d068, 0x1d076, 0x1d08e,
0x1d09c, 0x1d0b8, 0x1d0c2, 0x1d0c4, 0x1d0c8, 0x1d0d0, 0x1d0de,
0x1d0e6, 0x1d0ec, 0x1d0fa, 0x1d11c, 0x1d138, 0x1d170, 0x1d17e,
0x1d182, 0x1d184, 0x1d188, 0x1d190, 0x1d19e, 0x1d1a0, 0x1d1bc,
0x1d1c6, 0x1d1cc, 0x1d1d8, 0x1d1ee, 0x1d1f2, 0x1d1f4, 0x1d21c,
0x1d238, 0x1d270, 0x1d27e, 0x1d2e0, 0x1d2fc, 0x1d302, 0x1d304,
0x1d308, 0x1d310, 0x1d31e, 0x1d320, 0x1d33c, 0x1d340, 0x1d378,
0x1d386, 0x1d38c, 0x1d398, 0x1d3b0, 0x1d3be, 0x1d3ce, 0x1d3dc,
0x1d3e2, 0x1d3e4, 0x1d3e8, 0x1d3f6, 0x1d470, 0x1d47e, 0x1d4e0,
0x1d4fc, 0x1d5c0, 0x1d5f8, 0x1d604, 0x1d608, 0x1d610, 0x1d620,
0x1d640, 0x1d678, 0x1d6f0, 0x1d706, 0x1d70c, 0x1d718, 0x1d730,
0x1d73e, 0x1d760, 0x1d77c, 0x1d78e, 0x1d79c, 0x1d7b8, 0x1d7c2,
0x1d7c4, 0x1d7c8, 0x1d7d0, 0x1d7de, 0x1d7e6, 0x1d7ec, 0x1d826,
0x1d82c, 0x1d83a, 0x1d846, 0x1d84c, 0x1d858, 0x1d872, 0x1d874,
0x1d886, 0x1d88c, 0x1d898, 0x1d8b0, 0x1d8be, 0x1d8ce, 0x1d8e2,
0x1d8e4, 0x1d8e8, 0x1d8f6, 0x1d90c, 0x1d918, 0x1d930, 0x1d93e,
0x1d960, 0x1d97c, 0x1d99c, 0x1d9c2, 0x1d9c4, 0x1d9c8, 0x1d9d0,
0x1d9e6, 0x1d9fa, 0x1da0c, 0x1da18, 0x1da30, 0x1da3e, 0x1da60,
0x1da7c, 0x1dac0, 0x1daf8, 0x1db38, 0x1db82, 0x1db84, 0x1db88,
0x1db90, 0x1db9e, 0x1dba0, 0x1dbcc, 0x1dbf2, 0x1dbf4, 0x1dc22,
0x1dc42, 0x1dc44, 0x1dc48, 0x1dc50, 0x1dc5e, 0x1dc66, 0x1dc7a,
0x1dc82, 0x1dc84, 0x1dc88, 0x1dc90, 0x1dc9e, 0x1dca0, 0x1dcbc,
0x1dccc, 0x1dcf2, 0x1dcf4, 0x1dd04, 0x1dd08, 0x1dd10, 0x1dd1e,
0x1dd20, 0x1dd3c, 0x1dd40, 0x1dd78, 0x1dd86, 0x1dd98, 0x1ddce,
0x1dde2, 0x1dde4, 0x1dde8, 0x1de2e, 0x1de32, 0x1de34, 0x1de4e,
0x1de5c, 0x1de62, 0x1de64, 0x1de68, 0x1de8e, 0x1de9c, 0x1deb8,
0x1dec2, 0x1dec4, 0x1dec8, 0x1ded0, 0x1dee6, 0x1defa, 0x1df16,
0x1df26, 0x1df2c, 0x1df46, 0x1df4c, 0x1df58, 0x1df72, 0x1df74,
0x1df8a, 0x1df92, 0x1df94, 0x1dfa2, 0x1dfa4, 0x1dfa8, 0x1e08a,
0x1e092, 0x1e094, 0x1e0a2, 0x1e0a4, 0x1e0a8, 0x1e0b6, 0x1e0da,
0x1e10a, 0x1e112, 0x1e114, 0x1e122, 0x1e124, 0x1e128, 0x1e136,
0x1e142, 0x1e144, 0x1e148, 0x1e150, 0x1e166, 0x1e16c, 0x1e17a,
0x1e19a, 0x1e1b2, 0x1e1b4, 0x1e20a, 0x1e212, 0x1e214, 0x1e222,
0x1e224, 0x1e228, 0x1e236, 0x1e242, 0x1e248, 0x1e250, 0x1e25e,
0x1e266, 0x1e26c, 0x1e27a, 0x1e282, 0x1e284, 0x1e288, 0x1e290,
0x1e2a0, 0x1e2bc, 0x1e2c6, 0x1e2cc, 0x1e2d8, 0x1e2ee, 0x1e2f2,
0x1e2f4, 0x1e31a, 0x1e332, 0x1e334, 0x1e35c, 0x1e362, 0x1e364,
0x1e368, 0x1e3ba, 0x1e40a, 0x1e412, 0x1e414, 0x1e422, 0x1e428,
0x1e436, 0x1e442, 0x1e448, 0x1e450, 0x1e45e, 0x1e466, 0x1e46c,
0x1e47a, 0x1e482, 0x1e484, 0x1e490, 0x1e49e, 0x1e4a0, 0x1e4bc,
0x1e4c6, 0x1e4cc, 0x1e4d8, 0x1e4ee, 0x1e4f2, 0x1e4f4, 0x1e502,
0x1e504, 0x1e508, 0x1e510, 0x1e51e, 0x1e520, 0x1e53c, 0x1e540,
0x1e578, 0x1e586, 0x1e58c, 0x1e598, 0x1e5b0, 0x1e5be, 0x1e5ce,
0x1e5dc, 0x1e5e2, 0x1e5e4, 0x1e5e8, 0x1e5f6, 0x1e61a, 0x1e62e,
0x1e632, 0x1e634, 0x1e64e, 0x1e65c, 0x1e662, 0x1e668, 0x1e68e,
0x1e69c, 0x1e6b8, 0x1e6c2, 0x1e6c4, 0x1e6c8, 0x1e6d0, 0x1e6e6,
0x1e6fa, 0x1e716, 0x1e726, 0x1e72c, 0x1e73a, 0x1e746, 0x1e74c,
0x1e758, 0x1e772, 0x1e774, 0x1e792, 0x1e794, 0x1e7a2, 0x1e7a4,
0x1e7a8, 0x1e7b6, 0x1e812, 0x1e814, 0x1e822, 0x1e824, 0x1e828,
0x1e836, 0x1e842, 0x1e844, 0x1e848, 0x1e850, 0x1e85e, 0x1e866,
0x1e86c, 0x1e87a, 0x1e882, 0x1e884, 0x1e888, 0x1e890, 0x1e89e,
0x1e8a0, 0x1e8bc, 0x1e8c6, 0x1e8cc, 0x1e8d8, 0x1e8ee, 0x1e8f2,
0x1e8f4, 0x1e902, 0x1e904, 0x1e908, 0x1e910, 0x1e920, 0x1e93c,
0x1e940, 0x1e978, 0x1e986, 0x1e98c, 0x1e998, 0x1e9b0, 0x1e9be,
0x1e9ce, 0x1e9dc, 0x1e9e2, 0x1e9e4, 0x1e9e8, 0x1e9f6, 0x1ea04,
0x1ea08, 0x1ea10, 0x1ea20, 0x1ea40, 0x1ea78, 0x1eaf0, 0x1eb06,
0x1eb0c, 0x1eb18, 0x1eb30, 0x1eb3e, 0x1eb60, 0x1eb7c, 0x1eb8e,
0x1eb9c, 0x1ebb8, 0x1ebc2, 0x1ebc4, 0x1ebc8, 0x1ebd0, 0x1ebde,
0x1ebe6, 0x1ebec, 0x1ec1a, 0x1ec2e, 0x1ec32, 0x1ec34, 0x1ec4e,
0x1ec5c, 0x1ec62, 0x1ec64, 0x1ec68, 0x1ec8e, 0x1ec9c, 0x1ecb8,
0x1ecc2, 0x1ecc4, 0x1ecc8, 0x1ecd0, 0x1ece6, 0x1ecfa, 0x1ed0e,
0x1ed1c, 0x1ed38, 0x1ed70, 0x1ed7e, 0x1ed82, 0x1ed84, 0x1ed88,
0x1ed90, 0x1ed9e, 0x1eda0, 0x1edcc, 0x1edf2, 0x1edf4, 0x1ee16,
0x1ee26, 0x1ee2c, 0x1ee3a, 0x1ee46, 0x1ee4c, 0x1ee58, 0x1ee6e,
0x1ee72, 0x1ee74, 0x1ee86, 0x1ee8c, 0x1ee98, 0x1eeb0, 0x1eebe,
0x1eece, 0x1eedc, 0x1eee2, 0x1eee4, 0x1eee8, 0x1ef12, 0x1ef22,
0x1ef24, 0x1ef28, 0x1ef36, 0x1ef42, 0x1ef44, 0x1ef48, 0x1ef50,
0x1ef5e, 0x1ef66, 0x1ef6c, 0x1ef7a, 0x1efae, 0x1efb2, 0x1efb4,
0x1efd6, 0x1f096, 0x1f0a6, 0x1f0ac, 0x1f0ba, 0x1f0ca, 0x1f0d2,
0x1f0d4, 0x1f116, 0x1f126, 0x1f12c, 0x1f13a, 0x1f146, 0x1f14c,
0x1f158, 0x1f16e, 0x1f172, 0x1f174, 0x1f18a, 0x1f192, 0x1f194,
0x1f1a2, 0x1f1a4, 0x1f1a8, 0x1f1da, 0x1f216, 0x1f226, 0x1f22c,
0x1f23a, 0x1f246, 0x1f258, 0x1f26e, 0x1f272, 0x1f274, 0x1f286,
0x1f28c, 0x1f298, 0x1f2b0, 0x1f2be, 0x1f2ce, 0x1f2dc, 0x1f2e2,
0x1f2e4, 0x1f2e8, 0x1f2f6, 0x1f30a, 0x1f312, 0x1f314, 0x1f322,
0x1f328, 0x1f342, 0x1f344, 0x1f348, 0x1f350, 0x1f35e, 0x1f366,
0x1f37a, 0x1f39a, 0x1f3ae, 0x1f3b2, 0x1f3b4, 0x1f416, 0x1f426,
0x1f42c, 0x1f43a, 0x1f446, 0x1f44c, 0x1f458, 0x1f46e, 0x1f472,
0x1f474, 0x1f486, 0x1f48c, 0x1f498, 0x1f4b0, 0x1f4be, 0x1f4ce,
0x1f4dc, 0x1f4e2, 0x1f4e4, 0x1f4e8, 0x1f4f6, 0x1f506, 0x1f50c,
0x1f518, 0x1f530, 0x1f53e, 0x1f560, 0x1f57c, 0x1f58e, 0x1f59c,
0x1f5b8, 0x1f5c2, 0x1f5c4, 0x1f5c8, 0x1f5d0, 0x1f5de, 0x1f5e6,
0x1f5ec, 0x1f5fa, 0x1f60a, 0x1f612, 0x1f614, 0x1f622, 0x1f624,
0x1f628, 0x1f636, 0x1f642, 0x1f644, 0x1f648, 0x1f650, 0x1f65e,
0x1f666, 0x1f67a, 0x1f682, 0x1f684, 0x1f688, 0x1f690, 0x1f69e,
0x1f6a0, 0x1f6bc, 0x1f6cc, 0x1f6f2, 0x1f6f4, 0x1f71a, 0x1f72e,
0x1f732, 0x1f734, 0x1f74e, 0x1f75c, 0x1f762, 0x1f764, 0x1f768,
0x1f776, 0x1f796, 0x1f7a6, 0x1f7ac, 0x1f7ba, 0x1f7d2, 0x1f7d4,
0x1f89a, 0x1f8ae, 0x1f8b2, 0x1f8b4, 0x1f8d6, 0x1f8ea, 0x1f91a,
0x1f92e, 0x1f932, 0x1f934, 0x1f94e, 0x1f95c, 0x1f962, 0x1f964,
0x1f968, 0x1f976, 0x1f996, 0x1f9a6, 0x1f9ac, 0x1f9ba, 0x1f9ca,
0x1f9d2, 0x1f9d4, 0x1fa1a, 0x1fa2e, 0x1fa32, 0x1fa34, 0x1fa4e,
0x1fa5c, 0x1fa62, 0x1fa64, 0x1fa68, 0x1fa76, 0x1fa8e, 0x1fa9c,
0x1fab8, 0x1fac2, 0x1fac4, 0x1fac8, 0x1fad0, 0x1fade, 0x1fae6,
0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c, 0x1fb3a, 0x1fb46, 0x1fb4c,
0x1fb58, 0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94,
0x1fba2, 0x1fba4, 0x1fba8, 0x1fbb6, 0x1fbda
};
const int BitMatrixParser::CODEWORD_TABLE[] =
{
2627, 1819, 2622, 2621, 1813, 1812, 2729, 2724, 2723,
2779, 2774, 2773, 902, 896, 908, 868, 865, 861,
859, 2511, 873, 871, 1780, 835, 2493, 825, 2491,
842, 837, 844, 1764, 1762, 811, 810, 809, 2483,
807, 2482, 806, 2480, 815, 814, 813, 812, 2484,
817, 816, 1745, 1744, 1742, 1746, 2655, 2637, 2635,
2626, 2625, 2623, 2628, 1820, 2752, 2739, 2737, 2728,
2727, 2725, 2730, 2785, 2783, 2778, 2777, 2775, 2780,
787, 781, 747, 739, 736, 2413, 754, 752, 1719,
692, 689, 681, 2371, 678, 2369, 700, 697, 694,
703, 1688, 1686, 642, 638, 2343, 631, 2341, 627,
2338, 651, 646, 643, 2345, 654, 652, 1652, 1650,
1647, 1654, 601, 599, 2322, 596, 2321, 594, 2319,
2317, 611, 610, 608, 606, 2324, 603, 2323, 615,
614, 612, 1617, 1616, 1614, 1612, 616, 1619, 1618,
2575, 2538, 2536, 905, 901, 898, 909, 2509, 2507,
2504, 870, 867, 864, 860, 2512, 875, 872, 1781,
2490, 2489, 2487, 2485, 1748, 836, 834, 832, 830,
2494, 827, 2492, 843, 841, 839, 845, 1765, 1763,
2701, 2676, 2674, 2653, 2648, 2656, 2634, 2633, 2631,
2629, 1821, 2638, 2636, 2770, 2763, 2761, 2750, 2745,
2753, 2736, 2735, 2733, 2731, 1848, 2740, 2738, 2786,
2784, 591, 588, 576, 569, 566, 2296, 1590, 537,
534, 526, 2276, 522, 2274, 545, 542, 539, 548,
1572, 1570, 481, 2245, 466, 2242, 462, 2239, 492,
485, 482, 2249, 496, 494, 1534, 1531, 1528, 1538,
413, 2196, 406, 2191, 2188, 425, 419, 2202, 415,
2199, 432, 430, 427, 1472, 1467, 1464, 433, 1476,
1474, 368, 367, 2160, 365, 2159, 362, 2157, 2155,
2152, 378, 377, 375, 2166, 372, 2165, 369, 2162,
383, 381, 379, 2168, 1419, 1418, 1416, 1414, 385,
1411, 384, 1423, 1422, 1420, 1424, 2461, 802, 2441,
2439, 790, 786, 783, 794, 2409, 2406, 2403, 750,
742, 738, 2414, 756, 753, 1720, 2367, 2365, 2362,
2359, 1663, 693, 691, 684, 2373, 680, 2370, 702,
699, 696, 704, 1690, 1687, 2337, 2336, 2334, 2332,
1624, 2329, 1622, 640, 637, 2344, 634, 2342, 630,
2340, 650, 648, 645, 2346, 655, 653, 1653, 1651,
1649, 1655, 2612, 2597, 2595, 2571, 2568, 2565, 2576,
2534, 2529, 2526, 1787, 2540, 2537, 907, 904, 900,
910, 2503, 2502, 2500, 2498, 1768, 2495, 1767, 2510,
2508, 2506, 869, 866, 863, 2513, 876, 874, 1782,
2720, 2713, 2711, 2697, 2694, 2691, 2702, 2672, 2670,
2664, 1828, 2678, 2675, 2647, 2646, 2644, 2642, 1823,
2639, 1822, 2654, 2652, 2650, 2657, 2771, 1855, 2765,
2762, 1850, 1849, 2751, 2749, 2747, 2754, 353, 2148,
344, 342, 336, 2142, 332, 2140, 345, 1375, 1373,
306, 2130, 299, 2128, 295, 2125, 319, 314, 311,
2132, 1354, 1352, 1349, 1356, 262, 257, 2101, 253,
2096, 2093, 274, 273, 267, 2107, 263, 2104, 280,
278, 275, 1316, 1311, 1308, 1320, 1318, 2052, 202,
2050, 2044, 2040, 219, 2063, 212, 2060, 208, 2055,
224, 221, 2066, 1260, 1258, 1252, 231, 1248, 229,
1266, 1264, 1261, 1268, 155, 1998, 153, 1996, 1994,
1991, 1988, 165, 164, 2007, 162, 2006, 159, 2003,
2000, 172, 171, 169, 2012, 166, 2010, 1186, 1184,
1182, 1179, 175, 1176, 173, 1192, 1191, 1189, 1187,
176, 1194, 1193, 2313, 2307, 2305, 592, 589, 2294,
2292, 2289, 578, 572, 568, 2297, 580, 1591, 2272,
2267, 2264, 1547, 538, 536, 529, 2278, 525, 2275,
547, 544, 541, 1574, 1571, 2237, 2235, 2229, 1493,
2225, 1489, 478, 2247, 470, 2244, 465, 2241, 493,
488, 484, 2250, 498, 495, 1536, 1533, 1530, 1539,
2187, 2186, 2184, 2182, 1432, 2179, 1430, 2176, 1427,
414, 412, 2197, 409, 2195, 405, 2193, 2190, 426,
424, 421, 2203, 418, 2201, 431, 429, 1473, 1471,
1469, 1466, 434, 1477, 1475, 2478, 2472, 2470, 2459,
2457, 2454, 2462, 803, 2437, 2432, 2429, 1726, 2443,
2440, 792, 789, 785, 2401, 2399, 2393, 1702, 2389,
1699, 2411, 2408, 2405, 745, 741, 2415, 758, 755,
1721, 2358, 2357, 2355, 2353, 1661, 2350, 1660, 2347,
1657, 2368, 2366, 2364, 2361, 1666, 690, 687, 2374,
683, 2372, 701, 698, 705, 1691, 1689, 2619, 2617,
2610, 2608, 2605, 2613, 2593, 2588, 2585, 1803, 2599,
2596, 2563, 2561, 2555, 1797, 2551, 1795, 2573, 2570,
2567, 2577, 2525, 2524, 2522, 2520, 1786, 2517, 1785,
2514, 1783, 2535, 2533, 2531, 2528, 1788, 2541, 2539,
906, 903, 911, 2721, 1844, 2715, 2712, 1838, 1836,
2699, 2696, 2693, 2703, 1827, 1826, 1824, 2673, 2671,
2669, 2666, 1829, 2679, 2677, 1858, 1857, 2772, 1854,
1853, 1851, 1856, 2766, 2764, 143, 1987, 139, 1986,
135, 133, 131, 1984, 128, 1983, 125, 1981, 138,
137, 136, 1985, 1133, 1132, 1130, 112, 110, 1974,
107, 1973, 104, 1971, 1969, 122, 121, 119, 117,
1977, 114, 1976, 124, 1115, 1114, 1112, 1110, 1117,
1116, 84, 83, 1953, 81, 1952, 78, 1950, 1948,
1945, 94, 93, 91, 1959, 88, 1958, 85, 1955,
99, 97, 95, 1961, 1086, 1085, 1083, 1081, 1078,
100, 1090, 1089, 1087, 1091, 49, 47, 1917, 44,
1915, 1913, 1910, 1907, 59, 1926, 56, 1925, 53,
1922, 1919, 66, 64, 1931, 61, 1929, 1042, 1040,
1038, 71, 1035, 70, 1032, 68, 1048, 1047, 1045,
1043, 1050, 1049, 12, 10, 1869, 1867, 1864, 1861,
21, 1880, 19, 1877, 1874, 1871, 28, 1888, 25,
1886, 22, 1883, 982, 980, 977, 974, 32, 30,
991, 989, 987, 984, 34, 995, 994, 992, 2151,
2150, 2147, 2146, 2144, 356, 355, 354, 2149, 2139,
2138, 2136, 2134, 1359, 343, 341, 338, 2143, 335,
2141, 348, 347, 346, 1376, 1374, 2124, 2123, 2121,
2119, 1326, 2116, 1324, 310, 308, 305, 2131, 302,
2129, 298, 2127, 320, 318, 316, 313, 2133, 322,
321, 1355, 1353, 1351, 1357, 2092, 2091, 2089, 2087,
1276, 2084, 1274, 2081, 1271, 259, 2102, 256, 2100,
252, 2098, 2095, 272, 269, 2108, 266, 2106, 281,
279, 277, 1317, 1315, 1313, 1310, 282, 1321, 1319,
2039, 2037, 2035, 2032, 1203, 2029, 1200, 1197, 207,
2053, 205, 2051, 201, 2049, 2046, 2043, 220, 218,
2064, 215, 2062, 211, 2059, 228, 226, 223, 2069,
1259, 1257, 1254, 232, 1251, 230, 1267, 1265, 1263,
2316, 2315, 2312, 2311, 2309, 2314, 2304, 2303, 2301,
2299, 1593, 2308, 2306, 590, 2288, 2287, 2285, 2283,
1578, 2280, 1577, 2295, 2293, 2291, 579, 577, 574,
571, 2298, 582, 581, 1592, 2263, 2262, 2260, 2258,
1545, 2255, 1544, 2252, 1541, 2273, 2271, 2269, 2266,
1550, 535, 532, 2279, 528, 2277, 546, 543, 549,
1575, 1573, 2224, 2222, 2220, 1486, 2217, 1485, 2214,
1482, 1479, 2238, 2236, 2234, 2231, 1496, 2228, 1492,
480, 477, 2248, 473, 2246, 469, 2243, 490, 487,
2251, 497, 1537, 1535, 1532, 2477, 2476, 2474, 2479,
2469, 2468, 2466, 2464, 1730, 2473, 2471, 2453, 2452,
2450, 2448, 1729, 2445, 1728, 2460, 2458, 2456, 2463,
805, 804, 2428, 2427, 2425, 2423, 1725, 2420, 1724,
2417, 1722, 2438, 2436, 2434, 2431, 1727, 2444, 2442,
793, 791, 788, 795, 2388, 2386, 2384, 1697, 2381,
1696, 2378, 1694, 1692, 2402, 2400, 2398, 2395, 1703,
2392, 1701, 2412, 2410, 2407, 751, 748, 744, 2416,
759, 757, 1807, 2620, 2618, 1806, 1805, 2611, 2609,
2607, 2614, 1802, 1801, 1799, 2594, 2592, 2590, 2587,
1804, 2600, 2598, 1794, 1793, 1791, 1789, 2564, 2562,
2560, 2557, 1798, 2554, 1796, 2574, 2572, 2569, 2578,
1847, 1846, 2722, 1843, 1842, 1840, 1845, 2716, 2714,
1835, 1834, 1832, 1830, 1839, 1837, 2700, 2698, 2695,
2704, 1817, 1811, 1810, 897, 862, 1777, 829, 826,
838, 1760, 1758, 808, 2481, 1741, 1740, 1738, 1743,
2624, 1818, 2726, 2776, 782, 740, 737, 1715, 686,
679, 695, 1682, 1680, 639, 628, 2339, 647, 644,
1645, 1643, 1640, 1648, 602, 600, 597, 595, 2320,
593, 2318, 609, 607, 604, 1611, 1610, 1608, 1606,
613, 1615, 1613, 2328, 926, 924, 892, 886, 899,
857, 850, 2505, 1778, 824, 823, 821, 819, 2488,
818, 2486, 833, 831, 828, 840, 1761, 1759, 2649,
2632, 2630, 2746, 2734, 2732, 2782, 2781, 570, 567,
1587, 531, 527, 523, 540, 1566, 1564, 476, 467,
463, 2240, 486, 483, 1524, 1521, 1518, 1529, 411,
403, 2192, 399, 2189, 423, 416, 1462, 1457, 1454,
428, 1468, 1465, 2210, 366, 363, 2158, 360, 2156,
357, 2153, 376, 373, 370, 2163, 1410, 1409, 1407,
1405, 382, 1402, 380, 1417, 1415, 1412, 1421, 2175,
2174, 777, 774, 771, 784, 732, 725, 722, 2404,
743, 1716, 676, 674, 668, 2363, 665, 2360, 685,
1684, 1681, 626, 624, 622, 2335, 620, 2333, 617,
2330, 641, 635, 649, 1646, 1644, 1642, 2566, 928,
925, 2530, 2527, 894, 891, 888, 2501, 2499, 2496,
858, 856, 854, 851, 1779, 2692, 2668, 2665, 2645,
2643, 2640, 2651, 2768, 2759, 2757, 2744, 2743, 2741,
2748, 352, 1382, 340, 337, 333, 1371, 1369, 307,
300, 296, 2126, 315, 312, 1347, 1342, 1350, 261,
258, 250, 2097, 246, 2094, 271, 268, 264, 1306,
1301, 1298, 276, 1312, 1309, 2115, 203, 2048, 195,
2045, 191, 2041, 213, 209, 2056, 1246, 1244, 1238,
225, 1234, 222, 1256, 1253, 1249, 1262, 2080, 2079,
154, 1997, 150, 1995, 147, 1992, 1989, 163, 160,
2004, 156, 2001, 1175, 1174, 1172, 1170, 1167, 170,
1164, 167, 1185, 1183, 1180, 1177, 174, 1190, 1188,
2025, 2024, 2022, 587, 586, 564, 559, 556, 2290,
573, 1588, 520, 518, 512, 2268, 508, 2265, 530,
1568, 1565, 461, 457, 2233, 450, 2230, 446, 2226,
479, 471, 489, 1526, 1523, 1520, 397, 395, 2185,
392, 2183, 389, 2180, 2177, 410, 2194, 402, 422,
1463, 1461, 1459, 1456, 1470, 2455, 799, 2433, 2430,
779, 776, 773, 2397, 2394, 2390, 734, 728, 724,
746, 1717, 2356, 2354, 2351, 2348, 1658, 677, 675,
673, 670, 667, 688, 1685, 1683, 2606, 2589, 2586,
2559, 2556, 2552, 927, 2523, 2521, 2518, 2515, 1784,
2532, 895, 893, 890, 2718, 2709, 2707, 2689, 2687,
2684, 2663, 2662, 2660, 2658, 1825, 2667, 2769, 1852,
2760, 2758, 142, 141, 1139, 1138, 134, 132, 129,
126, 1982, 1129, 1128, 1126, 1131, 113, 111, 108,
105, 1972, 101, 1970, 120, 118, 115, 1109, 1108,
1106, 1104, 123, 1113, 1111, 82, 79, 1951, 75,
1949, 72, 1946, 92, 89, 86, 1956, 1077, 1076,
1074, 1072, 98, 1069, 96, 1084, 1082, 1079, 1088,
1968, 1967, 48, 45, 1916, 42, 1914, 39, 1911,
1908, 60, 57, 54, 1923, 50, 1920, 1031, 1030,
1028, 1026, 67, 1023, 65, 1020, 62, 1041, 1039,
1036, 1033, 69, 1046, 1044, 1944, 1943, 1941, 11,
9, 1868, 7, 1865, 1862, 1859, 20, 1878, 16,
1875, 13, 1872, 970, 968, 966, 963, 29, 960,
26, 23, 983, 981, 978, 975, 33, 971, 31,
990, 988, 985, 1906, 1904, 1902, 993, 351, 2145,
1383, 331, 330, 328, 326, 2137, 323, 2135, 339,
1372, 1370, 294, 293, 291, 289, 2122, 286, 2120,
283, 2117, 309, 303, 317, 1348, 1346, 1344, 245,
244, 242, 2090, 239, 2088, 236, 2085, 2082, 260,
2099, 249, 270, 1307, 1305, 1303, 1300, 1314, 189,
2038, 186, 2036, 183, 2033, 2030, 2026, 206, 198,
2047, 194, 216, 1247, 1245, 1243, 1240, 227, 1237,
1255, 2310, 2302, 2300, 2286, 2284, 2281, 565, 563,
561, 558, 575, 1589, 2261, 2259, 2256, 2253, 1542,
521, 519, 517, 514, 2270, 511, 533, 1569, 1567,
2223, 2221, 2218, 2215, 1483, 2211, 1480, 459, 456,
453, 2232, 449, 474, 491, 1527, 1525, 1522, 2475,
2467, 2465, 2451, 2449, 2446, 801, 800, 2426, 2424,
2421, 2418, 1723, 2435, 780, 778, 775, 2387, 2385,
2382, 2379, 1695, 2375, 1693, 2396, 735, 733, 730,
727, 749, 1718, 2616, 2615, 2604, 2603, 2601, 2584,
2583, 2581, 2579, 1800, 2591, 2550, 2549, 2547, 2545,
1792, 2542, 1790, 2558, 929, 2719, 1841, 2710, 2708,
1833, 1831, 2690, 2688, 2686, 1815, 1809, 1808, 1774,
1756, 1754, 1737, 1736, 1734, 1739, 1816, 1711, 1676,
1674, 633, 629, 1638, 1636, 1633, 1641, 598, 1605,
1604, 1602, 1600, 605, 1609, 1607, 2327, 887, 853,
1775, 822, 820, 1757, 1755, 1584, 524, 1560, 1558,
468, 464, 1514, 1511, 1508, 1519, 408, 404, 400,
1452, 1447, 1444, 417, 1458, 1455, 2208, 364, 361,
358, 2154, 1401, 1400, 1398, 1396, 374, 1393, 371,
1408, 1406, 1403, 1413, 2173, 2172, 772, 726, 723,
1712, 672, 669, 666, 682, 1678, 1675, 625, 623,
621, 618, 2331, 636, 632, 1639, 1637, 1635, 920,
918, 884, 880, 889, 849, 848, 847, 846, 2497,
855, 852, 1776, 2641, 2742, 2787, 1380, 334, 1367,
1365, 301, 297, 1340, 1338, 1335, 1343, 255, 251,
247, 1296, 1291, 1288, 265, 1302, 1299, 2113, 204,
196, 192, 2042, 1232, 1230, 1224, 214, 1220, 210,
1242, 1239, 1235, 1250, 2077, 2075, 151, 148, 1993,
144, 1990, 1163, 1162, 1160, 1158, 1155, 161, 1152,
157, 1173, 1171, 1168, 1165, 168, 1181, 1178, 2021,
2020, 2018, 2023, 585, 560, 557, 1585, 516, 509,
1562, 1559, 458, 447, 2227, 472, 1516, 1513, 1510,
398, 396, 393, 390, 2181, 386, 2178, 407, 1453,
1451, 1449, 1446, 420, 1460, 2209, 769, 764, 720,
712, 2391, 729, 1713, 664, 663, 661, 659, 2352,
656, 2349, 671, 1679, 1677, 2553, 922, 919, 2519,
2516, 885, 883, 881, 2685, 2661, 2659, 2767, 2756,
2755, 140, 1137, 1136, 130, 127, 1125, 1124, 1122,
1127, 109, 106, 102, 1103, 1102, 1100, 1098, 116,
1107, 1105, 1980, 80, 76, 73, 1947, 1068, 1067,
1065, 1063, 90, 1060, 87, 1075, 1073, 1070, 1080,
1966, 1965, 46, 43, 40, 1912, 36, 1909, 1019,
1018, 1016, 1014, 58, 1011, 55, 1008, 51, 1029,
1027, 1024, 1021, 63, 1037, 1034, 1940, 1939, 1937,
1942, 8, 1866, 4, 1863, 1, 1860, 956, 954,
952, 949, 946, 17, 14, 969, 967, 964, 961,
27, 957, 24, 979, 976, 972, 1901, 1900, 1898,
1896, 986, 1905, 1903, 350, 349, 1381, 329, 327,
324, 1368, 1366, 292, 290, 287, 284, 2118, 304,
1341, 1339, 1337, 1345, 243, 240, 237, 2086, 233,
2083, 254, 1297, 1295, 1293, 1290, 1304, 2114, 190,
187, 184, 2034, 180, 2031, 177, 2027, 199, 1233,
1231, 1229, 1226, 217, 1223, 1241, 2078, 2076, 584,
555, 554, 552, 550, 2282, 562, 1586, 507, 506,
504, 502, 2257, 499, 2254, 515, 1563, 1561, 445,
443, 441, 2219, 438, 2216, 435, 2212, 460, 454,
475, 1517, 1515, 1512, 2447, 798, 797, 2422, 2419,
770, 768, 766, 2383, 2380, 2376, 721, 719, 717,
714, 731, 1714, 2602, 2582, 2580, 2548, 2546, 2543,
923, 921, 2717, 2706, 2705, 2683, 2682, 2680, 1771,
1752, 1750, 1733, 1732, 1731, 1735, 1814, 1707, 1670,
1668, 1631, 1629, 1626, 1634, 1599, 1598, 1596, 1594,
1603, 1601, 2326, 1772, 1753, 1751, 1581, 1554, 1552,
1504, 1501, 1498, 1509, 1442, 1437, 1434, 401, 1448,
1445, 2206, 1392, 1391, 1389, 1387, 1384, 359, 1399,
1397, 1394, 1404, 2171, 2170, 1708, 1672, 1669, 619,
1632, 1630, 1628, 1773, 1378, 1363, 1361, 1333, 1328,
1336, 1286, 1281, 1278, 248, 1292, 1289, 2111, 1218,
1216, 1210, 197, 1206, 193, 1228, 1225, 1221, 1236,
2073, 2071, 1151, 1150, 1148, 1146, 152, 1143, 149,
1140, 145, 1161, 1159, 1156, 1153, 158, 1169, 1166,
2017, 2016, 2014, 2019, 1582, 510, 1556, 1553, 452,
448, 1506, 1500, 394, 391, 387, 1443, 1441, 1439,
1436, 1450, 2207, 765, 716, 713, 1709, 662, 660,
657, 1673, 1671, 916, 914, 879, 878, 877, 882,
1135, 1134, 1121, 1120, 1118, 1123, 1097, 1096, 1094,
1092, 103, 1101, 1099, 1979, 1059, 1058, 1056, 1054,
77, 1051, 74, 1066, 1064, 1061, 1071, 1964, 1963,
1007, 1006, 1004, 1002, 999, 41, 996, 37, 1017,
1015, 1012, 1009, 52, 1025, 1022, 1936, 1935, 1933,
1938, 942, 940, 938, 935, 932, 5, 2, 955,
953, 950, 947, 18, 943, 15, 965, 962, 958,
1895, 1894, 1892, 1890, 973, 1899, 1897, 1379, 325,
1364, 1362, 288, 285, 1334, 1332, 1330, 241, 238,
234, 1287, 1285, 1283, 1280, 1294, 2112, 188, 185,
181, 178, 2028, 1219, 1217, 1215, 1212, 200, 1209,
1227, 2074, 2072, 583, 553, 551, 1583, 505, 503,
500, 513, 1557, 1555, 444, 442, 439, 436, 2213,
455, 451, 1507, 1505, 1502, 796, 763, 762, 760,
767, 711, 710, 708, 706, 2377, 718, 715, 1710,
2544, 917, 915, 2681, 1627, 1597, 1595, 2325, 1769,
1749, 1747, 1499, 1438, 1435, 2204, 1390, 1388, 1385,
1395, 2169, 2167, 1704, 1665, 1662, 1625, 1623, 1620,
1770, 1329, 1282, 1279, 2109, 1214, 1207, 1222, 2068,
2065, 1149, 1147, 1144, 1141, 146, 1157, 1154, 2013,
2011, 2008, 2015, 1579, 1549, 1546, 1495, 1487, 1433,
1431, 1428, 1425, 388, 1440, 2205, 1705, 658, 1667,
1664, 1119, 1095, 1093, 1978, 1057, 1055, 1052, 1062,
1962, 1960, 1005, 1003, 1000, 997, 38, 1013, 1010,
1932, 1930, 1927, 1934, 941, 939, 936, 933, 6,
930, 3, 951, 948, 944, 1889, 1887, 1884, 1881,
959, 1893, 1891, 35, 1377, 1360, 1358, 1327, 1325,
1322, 1331, 1277, 1275, 1272, 1269, 235, 1284, 2110,
1205, 1204, 1201, 1198, 182, 1195, 179, 1213, 2070,
2067, 1580, 501, 1551, 1548, 440, 437, 1497, 1494,
1490, 1503, 761, 709, 707, 1706, 913, 912, 2198,
1386, 2164, 2161, 1621, 1766, 2103, 1208, 2058, 2054,
1145, 1142, 2005, 2002, 1999, 2009, 1488, 1429, 1426,
2200, 1698, 1659, 1656, 1975, 1053, 1957, 1954, 1001,
998, 1924, 1921, 1918, 1928, 937, 934, 931, 1879,
1876, 1873, 1870, 945, 1885, 1882, 1323, 1273, 1270,
2105, 1202, 1199, 1196, 1211, 2061, 2057, 1576, 1543,
1540, 1484, 1481, 1478, 1491, 1700
};
const int BitMatrixParser::SYMBOL_TABLE_LENGTH =
sizeof(BitMatrixParser::SYMBOL_TABLE) / sizeof(int);
|
[
"188080501@qq.com"
] |
188080501@qq.com
|
7bffb580b6f4aa84aa16741422821502c3b66c7c
|
82637172d3427123fb61c79d182ea7ee0d2c72c1
|
/IncidentLog/IncidentLog.cpp
|
22a988d472571bf59e227f21c1f0f3fe6aa605dc
|
[] |
no_license
|
fdelclaux/old-oop-projects
|
74211530fd85ebc93fe289c97d51b1de9f9ab493
|
b18aa99bfd8bb3e4fab5c60f7a86f94e72dd9e8b
|
refs/heads/master
| 2022-09-18T03:38:59.641635
| 2020-06-04T15:17:17
| 2020-06-04T15:17:17
| 269,355,901
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,789
|
cpp
|
/*
* IncidentLog.cpp
*
* COSC 052 Fall 2019
* Project 1
*
* Due on: SEP 19, 2019
* Author: fsd7
*
*
* In accordance with the class policies and Georgetown's
* Honor Code, I certify that, with the exception of the
* class resources and those items noted below, I have neither
* given nor received any assistance on this project.
*
* References not otherwise commented within the program source code.
* Note that you should not mention any help from the TAs, the professor,
* or any code taken from the class textbooks.
*/
#include "IncidentLog.h"
IncidentLog::IncidentLog()
{
}
IncidentLog::~IncidentLog()
{
}
void IncidentLog::displayReports(string outputFileName) const
{
try
{
string openFailure = "ERROR: File failed to open\n";
std::ofstream outFile;
outFile.open(outputFileName.c_str());
if(!outFile)
{
throw logic_error(openFailure);
cout << openFailure << endl;
}
for(int i = 0; i < allIncidents.size();i++)
{
allIncidents.at(i).summaryReport(outFile);
}
outFile.close();
}
catch(logic_error e)
{
cout << e.what() << endl;
}
}
void IncidentLog::displayReports(ostream &os) const
{
try{
string streamFail = "ERROR: Stream failure \n";
if(!os)
{
throw invalid_argument(streamFail);
cout << streamFail << endl;
}
for(int i = 0; i < allIncidents.size(); i++)
{
allIncidents.at(i).summaryReport(os);
cout << "\n" << endl;
}
cout << "Number of valid Records: " << allIncidents.size() << endl;
}
catch(invalid_argument e)
{
cout << e.what() << endl;
}
catch(std::out_of_range e)
{
cout << e.what() << endl;
}
}
HazMat7k& IncidentLog::find(string incidentNum)
{
try
{
for(int i = 0; i < allIncidents.size(); i++)
{
if(incidentNum == allIncidents.at(i).getReportNumber())
{
return allIncidents.at(i);
}
}
}
catch(logic_error e)
{
cout << e.what() << endl;
}
}
void IncidentLog::read( string inputFileName, char fileFormat )
{
string fileFormatError = "ERROR: The given file format is not valid\n";
string fileOpenError = "ERROR: File could not be opened, please check path and name:\n";
if( fileFormat == 'b')
{
ifstream inFile(inputFileName.c_str(), std::ios::binary | std::ios::in);
if (!inFile)
throw logic_error(fileOpenError + inputFileName);
try
{
read(inFile, fileFormat);
inFile.close();
}
catch(invalid_argument &e)
{
cout << e.what() << endl;
}
catch(logic_error &e)
{
cout << e.what() << endl;
}
}
else if(fileFormat == 'q')
{
ifstream inFile (inputFileName.c_str());
if(!inFile)
throw logic_error(fileOpenError + inputFileName );
try
{
read(inFile, fileFormat);
inFile.close();
}
catch(invalid_argument &e)
{
cout << e.what() << endl;
}
catch(logic_error &e)
{
cout << e.what() << endl;
}
}
else
{
throw invalid_argument(fileFormatError);
cout << fileFormatError << endl;
}
}
void IncidentLog::read( istream& in, char fileFormat )
{
if(!in)
throw invalid_argument("ERROR: Stream failure");
if(fileFormat == 'b')
{
HazMatData h1s;
bool valid = true;
int count = 1;
try
{
valid = true;
in.read(reinterpret_cast<char*>(&h1s), sizeof(h1s));
count++;
}
catch(invalid_argument &e)
{
cout << e.what() << "in row " << count << endl;
valid = false;
}
catch(logic_error &e)
{
cout << e.what() << "in row " << count << endl;
valid = false;
}
catch(...)
{
cout << "Exception caught in row " << count << endl;
valid = false;
}
while(in)
{
try
{
if(valid)
{
HazMat7k h1(h1s);
allIncidents.push_back(h1);
}
valid = true;
in.read(reinterpret_cast<char*>(&h1s), sizeof(h1s));
count++;
}
catch(invalid_argument &e)
{
cout << e.what() << "in row " << count << endl;
valid = false;
}
catch(logic_error &e)
{
cout << e.what() << "in row " << count << endl;
valid = false;
}
catch(...)
{
cout << "Exception caught in row " << count << endl;
valid = false;
}
}
}
if( fileFormat == 'q' )
{
HazMat7k h1;
bool valid = true;
int count = 1;
string ignore = " ";
try
{
valid = true;
in >> h1;
count++;
}
catch(invalid_argument &e)
{
valid = false;
cout << e.what() << "in row " << count << endl;
getline(in, ignore);
count++;
}
catch(logic_error &e)
{
valid = false;
cout << e.what() << "in row " << count << endl;
}
catch(...)
{
valid = false;
cout << "Exception caught in row " << count << endl;
}
while(in)
{
try
{
if(valid)
allIncidents.push_back(h1);
valid = true;
in >> h1;
count++;
}
catch(invalid_argument &e)
{
valid = false;
cout << e.what() << "in row " << count << endl;
//getline(in, ignore);
count++;
}
catch(logic_error &e)
{
valid = false;
cout << e.what() << "in row " << count << endl;
}
catch(...)
{
valid = false;
cout << "Exception caught in row " << count << endl;
}
}
}
}
void IncidentLog::write( string outputFileName ) const
{
try
{
string fileOpenError = "ERROR: File could not be opened, please check path and name:\n";
std::ofstream outFile (outputFileName.c_str());
if(!outFile)
throw logic_error(fileOpenError);
write(outFile);
outFile.close();
}
catch(invalid_argument e)
{
cout << e.what() << endl;
}
catch(logic_error e)
{
cout << e.what() << endl;
}
catch(...)
{
cout << "Exception found" << endl;
}
}
void IncidentLog::write( ostream& out) const
{
if(!out)
throw invalid_argument("ERROR: Stream Failure");
for(int i = 0; i < allIncidents.size(); i++)
{
out << allIncidents.at(i);
}
}
|
[
"fdelclaux@users.noreply.github.com"
] |
fdelclaux@users.noreply.github.com
|
be307640bf2f0a0a7d205def077eb9fcb9351a53
|
4682789bb63faf111b5e5a612bdb992c67c6f39d
|
/Functions/Pass by Reference/Main.cpp
|
18a2f3abbd4336f30b969a5e02207d38ab4c374b
|
[] |
no_license
|
MohamedGhareeb933/CPP-Code-Camp
|
fec9b71f3d69515c36e7ee80d7bc59fe6c92045e
|
b6a2109f3238a72000eb2c775fb92fc3d4a524f8
|
refs/heads/main
| 2023-08-04T20:43:12.343124
| 2021-09-28T23:40:33
| 2021-09-28T23:40:33
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,358
|
cpp
|
/*
pass by reference- create An Adress Data type
EX - int& x = y;
the adress of X = Y adress.
any Effects to X apply to Y.
NEXT: Check pointers.
*/
#include <iostream>
#include<string>
// function Declaration.
void askUser(int&, std::string&); // we Can use Pointers aswell
// askUser - Ask user to Fill in Infromation.
// @Pram - int& , ask user to fill in Score.
// @pram - string& , ask user to fill in Name.
// Function Declaration.
void CalculateOutcome(int, std::string);
// Calculate OutCome
// @prma- int, Calculate Score.
// @pram- string , Printout User Name.
int main()
{
int Score;
std::string Name;
askUser(Score, Name);
CalculateOutcome(Score, Name);
std::cout << std::endl << system("pause");
}
void askUser(int &Score, std::string &Name) // we can also Create a pointers*.
{
std::cout << "PLease Enter you'r Name: ";
std::getline(std::cin, Name); // when we create a pointers we have to Derefrence it by putting * before the Name to acces the Value
std::cout << "Please Enter you'r Score: ";
std::cin >> Score; // as well as score
}
void CalculateOutcome(int Score, std::string Name) // we are Just using the Value not modifying , no need for pointers or Reference
{
if (Score >= 50)
std::cout << "you'v Passed " << Name << std::endl;
else
std::cout << "Sorry , good luck next time. " << Name << std::endl;
}
|
[
"mohamedghareeb933@gmail.com"
] |
mohamedghareeb933@gmail.com
|
0e28777cf64c4b17d3209b3e4ce9c08e77dcd15b
|
ca95baf6b57244bf5a8b2286eef9fab39f1affd3
|
/ApplicationMonitor.cpp
|
51c46cb6525b0dc1773bfb2c56512661f86c8558
|
[] |
no_license
|
alur/ApplicationMonitor
|
b7291b3df447e9c7f80b4cdfd7998e9f0de33a17
|
b44ec9ada6f5bb6ca59cfa4c0d71ef376c8c823e
|
refs/heads/master
| 2021-01-13T09:13:15.328121
| 2013-08-22T22:24:35
| 2013-08-22T22:24:35
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,443
|
cpp
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* ApplicationMonitor.cpp
* ApplicationMonitor
*
* Main code for ApplicationMonitor. A simple module which triggers events
* when programs start or stop.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "ApplicationMonitor.h"
// Module entry point
BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID /* pvReserved */)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hInst);
}
return TRUE;
}
// Called on module load
int initModuleW(HWND hwndParent, HINSTANCE hDllInstance, LPCWSTR szPath)
{
g_hParent = hwndParent;
g_hInstance = hDllInstance;
StringCchCopy(g_szPath, _countof(g_szPath), szPath);
if (!CreateMessageHandler())
{
return 1;
}
AddBangCommand(_T("!ApplicationMonitor"), BangApplicationMonitor);
LoadConfig();
return 0;
}
// Called on module unload
void quitModule(HINSTANCE hDllInstance)
{
RemoveBangCommand(_T("!ApplicationMonitor"));
if (g_hwndMessageHandler)
{
SendMessage(GetLitestepWnd(), LM_UNREGISTERMESSAGE, (WPARAM)g_hwndMessageHandler, (LPARAM)g_lsMessages);
DestroyWindow(g_hwndMessageHandler);
}
UnregisterClass(g_szMsgHandler, hDllInstance);
}
// Loads all the .RC configurations
void LoadConfig()
{
LPVOID f = LCOpen(NULL);
TCHAR szLine[MAX_LINE_LENGTH];
while (LCReadNextConfig(f, _T("*ApplicationMonitor"), szLine, _countof(szLine)))
{
ParseConfigLine(szLine);
}
LCClose(f);
}
//
void BangApplicationMonitor(HWND, LPCTSTR pszArgs)
{
ParseConfigLine(pszArgs);
}
//
void ParseConfigLine(LPCTSTR szLine)
{
TCHAR szTimer[MAX_LINE_LENGTH];
LPCTSTR pszNext = szLine;
MonitorData monData;
monData.iUpdateFrequency = 100;
// Retrive information from the line
GetToken(pszNext, monData.szName, &pszNext, false);
GetToken(pszNext, monData.szName, &pszNext, false);
if (*monData.szName == _T('\0'))
{
return;
}
GetToken(pszNext, monData.szApplication, &pszNext, false);
if (*monData.szApplication == _T('\0'))
{
return;
}
if (GetToken(pszNext, szTimer, &pszNext, false))
{
if (*szTimer != _T('\0'))
{
monData.iUpdateFrequency = _ttoi(szTimer);
}
}
// Keep the timer within resonable bounds
if (monData.iUpdateFrequency > USER_TIMER_MAXIMUM) monData.iUpdateFrequency = USER_TIMER_MAXIMUM;
if (monData.iUpdateFrequency < USER_TIMER_MINIMUM) monData.iUpdateFrequency = USER_TIMER_MINIMUM;
// TODO::Avoid duplicates!
// Find a free timer id
UINT id = 0;
MonitorMap::iterator iter;
do
{
iter = g_MonitorMap.find(++id);
}
while (iter != g_MonitorMap.end());
// Set the timer
SetTimer(g_hwndMessageHandler, id, monData.iUpdateFrequency, NULL);
// Load events from the RCs
GetPrefixedRCLine(monData.szOnStart, monData.szName, _T("OnStart"), _T(""));
GetPrefixedRCLine(monData.szOnEnd, monData.szName, _T("OnEnd"), _T(""));
// Store all information in the MonitorMap
g_MonitorMap.insert(MonitorMap::value_type(id, monData));
// Initialize all values (avoids events fireing on startup/recycle)
Check(id, true);
}
// Check if the application is running
void Check(UINT id, bool bInitialize)
{
MonitorMap::iterator iter = g_MonitorMap.find(id);
if (iter != g_MonitorMap.end())
{
bool bInitialState = iter->second.bIsRunning;
iter->second.bIsRunning = AppIsRunning(iter->second.szApplication);
if (bInitialize)
{
SetEvar(iter->second.szName, _T("IsRunning"), _T("%s"), iter->second.bIsRunning ? _T("true") : _T("false"));
}
if (bInitialState != iter->second.bIsRunning )
{
SetEvar(iter->second.szName, _T("IsRunning"), _T("%s"), iter->second.bIsRunning ? _T("true") : _T("false"));
if (!bInitialize)
{
if (iter->second.bIsRunning)
{
LSExecute(NULL, iter->second.szOnStart, SW_SHOWNORMAL);
}
else
{
LSExecute(NULL, iter->second.szOnEnd, SW_SHOWNORMAL);
}
}
}
}
}
// Check whether or not an application is running
bool AppIsRunning(LPCTSTR szApp)
{
bool bReturn = false;
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32* processInfo = new PROCESSENTRY32;
processInfo->dwSize = sizeof(PROCESSENTRY32);
while (Process32Next(hSnapShot, processInfo) != FALSE)
{
if (!_tcscmp(processInfo->szExeFile, szApp))
{
bReturn = true;
break;
}
}
CloseHandle(hSnapShot);
delete processInfo;
return bReturn;
}
// Sets an evironment variable
void SetEvar(LPCTSTR pszName, LPCTSTR pszEvar, LPCTSTR pszFormat, ...)
{
TCHAR szValue[MAX_LINE_LENGTH] = { 0 };
TCHAR szEvar[MAX_LINE_LENGTH] = { 0 };
va_list argList;
va_start(argList, pszFormat);
StringCchVPrintf(szValue, MAX_LINE_LENGTH, pszFormat, argList);
va_end(argList);
StringCchPrintf(szEvar, sizeof(szEvar), _T("%s%s"), pszName, pszEvar);
LSSetVariable(szEvar, szValue);
}
// Retrive a prefixed line from the RCs
void GetPrefixedRCLine(LPTSTR szDest, LPCTSTR szPrefix, LPCTSTR szOption, LPCTSTR szDefault)
{
TCHAR szOptionName[MAX_LINE_LENGTH];
StringCchPrintf(szOptionName, MAX_LINE_LENGTH, _T("%s%s"), szPrefix, szOption);
GetRCLine(szOptionName, szDest, MAX_LINE_LENGTH, szDefault);
}
// Creates the message handler
bool CreateMessageHandler()
{
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = MessageHandlerProc;
wc.hInstance = g_hInstance;
wc.lpszClassName = g_szMsgHandler;
wc.hIconSm = 0;
wc.style = CS_NOCLOSE;
if (!RegisterClassEx(&wc))
return false;
g_hwndMessageHandler = CreateWindowEx(WS_EX_TOOLWINDOW, g_szMsgHandler, 0, WS_POPUP, 0, 0, 0, 0, g_hParent, 0, g_hInstance, 0);
if (!g_hwndMessageHandler)
{
return false;
}
SendMessage(GetLitestepWnd(), LM_REGISTERMESSAGE, (WPARAM)g_hwndMessageHandler, (LPARAM)g_lsMessages);
return true;
}
// Message Handler
LRESULT WINAPI MessageHandlerProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case LM_REFRESH:
{
LoadConfig();
return 0;
}
case LM_GETREVID:
{
StringCchPrintf((LPTSTR)lParam, 64, _T("%s: %s"), g_szAppName, g_rcsRevision);
size_t uLength;
if (SUCCEEDED(StringCchLength((LPTSTR) lParam, 64, &uLength)))
{
return uLength;
}
lParam = NULL;
return 0;
}
case WM_TIMER:
{
Check((UINT)wParam);
return 0;
}
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
|
[
"alur@lsdev.org"
] |
alur@lsdev.org
|
a51280c032a504408478a3f8b07f638feb17d7c6
|
73ee941896043f9b3e2ab40028d24ddd202f695f
|
/external/chromium_org/components/autofill/core/browser/address.cc
|
6f7f2a93ac75158cab75f33ed9707c0710d6c179
|
[
"BSD-3-Clause"
] |
permissive
|
CyFI-Lab-Public/RetroScope
|
d441ea28b33aceeb9888c330a54b033cd7d48b05
|
276b5b03d63f49235db74f2c501057abb9e79d89
|
refs/heads/master
| 2022-04-08T23:11:44.482107
| 2016-09-22T20:15:43
| 2016-09-22T20:15:43
| 58,890,600
| 5
| 3
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,057
|
cc
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/autofill/core/browser/address.h"
#include <stddef.h>
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_type.h"
namespace {
const char16 kAddressSplitChars[] = {'-', ',', '#', '.', ' ', 0};
} // namespace
namespace autofill {
Address::Address() {}
Address::Address(const Address& address) : FormGroup() {
*this = address;
}
Address::~Address() {}
Address& Address::operator=(const Address& address) {
if (this == &address)
return *this;
line1_ = address.line1_;
line2_ = address.line2_;
city_ = address.city_;
state_ = address.state_;
country_code_ = address.country_code_;
zip_code_ = address.zip_code_;
return *this;
}
base::string16 Address::GetRawInfo(ServerFieldType type) const {
// TODO(isherman): Is GetStorableType even necessary?
switch (AutofillType(type).GetStorableType()) {
case ADDRESS_HOME_LINE1:
return line1_;
case ADDRESS_HOME_LINE2:
return line2_;
case ADDRESS_HOME_CITY:
return city_;
case ADDRESS_HOME_STATE:
return state_;
case ADDRESS_HOME_ZIP:
return zip_code_;
case ADDRESS_HOME_COUNTRY:
return ASCIIToUTF16(country_code_);
default:
return base::string16();
}
}
void Address::SetRawInfo(ServerFieldType type, const base::string16& value) {
// TODO(isherman): Is GetStorableType even necessary?
switch (AutofillType(type).GetStorableType()) {
case ADDRESS_HOME_LINE1:
line1_ = value;
break;
case ADDRESS_HOME_LINE2:
line2_ = value;
break;
case ADDRESS_HOME_CITY:
city_ = value;
break;
case ADDRESS_HOME_STATE:
state_ = value;
break;
case ADDRESS_HOME_COUNTRY:
DCHECK(value.empty() ||
(value.length() == 2u && IsStringASCII(value)));
country_code_ = UTF16ToASCII(value);
break;
case ADDRESS_HOME_ZIP:
zip_code_ = value;
break;
default:
NOTREACHED();
}
}
base::string16 Address::GetInfo(const AutofillType& type,
const std::string& app_locale) const {
if (type.html_type() == HTML_TYPE_COUNTRY_CODE) {
return ASCIIToUTF16(country_code_);
} else if (type.html_type() == HTML_TYPE_STREET_ADDRESS) {
base::string16 address = line1_;
if (!line2_.empty())
address += ASCIIToUTF16(", ") + line2_;
return address;
}
ServerFieldType storable_type = type.GetStorableType();
if (storable_type == ADDRESS_HOME_COUNTRY && !country_code_.empty())
return AutofillCountry(country_code_, app_locale).name();
return GetRawInfo(storable_type);
}
bool Address::SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) {
if (type.html_type() == HTML_TYPE_COUNTRY_CODE) {
if (!value.empty() && (value.size() != 2u || !IsStringASCII(value))) {
country_code_ = std::string();
return false;
}
country_code_ = StringToUpperASCII(UTF16ToASCII(value));
return true;
} else if (type.html_type() == HTML_TYPE_STREET_ADDRESS) {
// Don't attempt to parse the address into lines, since this is potentially
// a user-entered address in the user's own format, so the code would have
// to rely on iffy heuristics at best. Instead, just give up when importing
// addresses like this.
line1_ = line2_ = base::string16();
return false;
}
ServerFieldType storable_type = type.GetStorableType();
if (storable_type == ADDRESS_HOME_COUNTRY && !value.empty()) {
country_code_ = AutofillCountry::GetCountryCode(value, app_locale);
return !country_code_.empty();
}
SetRawInfo(storable_type, value);
return true;
}
void Address::GetMatchingTypes(const base::string16& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const {
FormGroup::GetMatchingTypes(text, app_locale, matching_types);
// Check to see if the |text| canonicalized as a country name is a match.
std::string country_code = AutofillCountry::GetCountryCode(text, app_locale);
if (!country_code.empty() && country_code_ == country_code)
matching_types->insert(ADDRESS_HOME_COUNTRY);
}
void Address::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(ADDRESS_HOME_LINE1);
supported_types->insert(ADDRESS_HOME_LINE2);
supported_types->insert(ADDRESS_HOME_CITY);
supported_types->insert(ADDRESS_HOME_STATE);
supported_types->insert(ADDRESS_HOME_ZIP);
supported_types->insert(ADDRESS_HOME_COUNTRY);
}
} // namespace autofill
|
[
"ProjectRetroScope@gmail.com"
] |
ProjectRetroScope@gmail.com
|
9fd39f7d7578486d5e709bdf888c59221101b442
|
f2e7c0cfefe130420549ac170a49769266381631
|
/include/usagi/http/request.cxx
|
b5eddbc58c8eab77ea69423c45825a6c18b9c194
|
[
"MIT"
] |
permissive
|
moicci/usagi
|
a4a1b3ab6050bf345d07fe1b702f606b1fefab83
|
2d57d21eeb92eadfdf4154a3e470aebfc3e388e5
|
refs/heads/master
| 2020-03-22T14:54:48.725530
| 2017-05-08T14:27:27
| 2017-05-08T14:27:27
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,005
|
cxx
|
#pragma once
#include "macro.hxx"
#include "io_service.hxx"
#include "constant.hxx"
#ifndef DISABLE_USAGI_HTTP_JSON
#include <usagi/json/picojson/type.hxx>
#endif
#include <stdexcept>
#include <boost/xpressive/xpressive.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/optional.hpp>
namespace usagi::http
{
auto request
( const string& url
, const string& method
, const void* data
, const size_t data_size
, const string& extra_header
) -> string
{
using namespace boost::xpressive;
ip::tcp::resolver resolver( io_service );
mark_tag scheme(1), host(2), port(3), tail(4);
sregex r
= bos
>> ( scheme = *_ )
>> as_xpr( ':' ) >> +as_xpr( '/' )
>> ( host = +( boost::xpressive::set[ alnum | '.' | '-' ] ) )
>> ! ( as_xpr( ':' ) >> ( port = +alnum ) )
>> ( tail = *_ )
>> eos
;
smatch m;
if ( not regex_search( url, m, r ) )
throw runtime_error( "cannot split the url: " + url );
const auto& url_scheme = m[ scheme ];
const auto& url_host = m[ host ];
auto url_port = string( m[ port ] );
if ( url_port.empty() )
if ( url_scheme == "http" )
url_port = "80";
else if ( url_scheme == "https" )
url_port = "443";
else
throw runtime_error( "cannot set default port with unknown scheme:" + url_scheme );
auto url_tail = string( m[ tail ] );
if ( url_tail.empty() )
url_tail = "/";
ip::tcp::resolver::query
query
( url_host
, url_port
);
ip::tcp::endpoint endpoint( *resolver.resolve( query ) );
const auto request_writer =
[&]
( auto& target_stream )
{
boost::asio::streambuf buffer;
ostream out( &buffer );
out
<< method << ' ' << url_tail << " HTTP/1.0" << http_end_of_line
<< "Host: " << url_host << http_end_of_line
<< "Connection: Close" << http_end_of_line
<< extra_header
;
if ( data and data_size )
{
out << "Content-Length: " << data_size << http_separator;
out.write( reinterpret_cast< const char*>( data ), data_size );
}
else
out << http_end_of_line;
write( target_stream, buffer );
};
const auto response_reader =
[&]
( auto& target_stream )
{
stringstream result;
boost::asio::streambuf buffer;
boost::system::error_code e;
while( read( target_stream, buffer, transfer_all(), e ) )
result << string( buffer_cast< const char* >( buffer.data() ), buffer.size() );
if ( e and e != error::eof )
{
switch ( e.value() )
{
case 335544539:
// SSL SHORT READ は無視する
break;
default:
throw runtime_error( to_string( e.value() ) + " : " + e.message() );
}
}
return result.str();
};
if ( url_scheme == "https" )
{
ssl::context ssl_context( ssl::context::tlsv1_client );
ssl::stream< ip::tcp::socket > ssl_stream( io_service, ssl_context );
ssl_stream.lowest_layer().connect( endpoint );
ssl_stream.handshake( ssl::stream_base::client );
request_writer( ssl_stream );
return response_reader( ssl_stream );
}
else
{
ip::tcp::socket socket( io_service );
socket.connect( endpoint );
request_writer( socket );
return response_reader( socket );
}
}
auto request
( const string& url
, const string& method
) -> string
{ return request( url, method, nullptr, 0, "" ); }
#ifndef DISABLE_USAGI_HTTP_JSON
auto request
( const string& url
, const string& method
, const ::usagi::json::picojson::value_type& data
, const string& extra_header
) -> string
{ return request( url, method, data.serialize(), "Content-Type: application/json\r\n" + extra_header ); }
#endif
auto request_optional
( const string& url
, const string& method
, const void* data
, const size_t data_size
, const string& extra_header
) -> optional< string >
{ try { return request( url, method, data, data_size, extra_header ); } catch ( ... ) { return { }; } }
auto request_optional
( const string& url
, const string& method
, const string& data
, const string& extra_header
) -> optional< string >
{ try { return request( url, method, data, extra_header ); } catch ( ... ) { return { }; } }
#ifndef DISABLE_USAGI_HTTP_JSON
auto request_optional
( const string& url
, const string& method
, const ::usagi::json::picojson::value_type& data
, const string& extra_header
) -> optional< string >
{ try { return request( url, method, data, extra_header ); } catch ( ... ) { return { }; } }
#endif
}
|
[
"usagi@WonderRabbitProject.net"
] |
usagi@WonderRabbitProject.net
|
4295fc6bd2d6be3e1ae969fd25dd26f0247385b1
|
e777649cfddab11f0a0ec76f7ab4b14c75da1470
|
/FolderDemo/stdafx.cpp
|
ce322a4b37579603e9b7a8dbf990f7fd1354d7cb
|
[] |
no_license
|
expDragon/FolderDemo
|
fe7106d83f0bee4b1a07a13e821f54e694bdc1f7
|
9ad3f9b0e52f7b8f564660be88d62013e1b5c08f
|
refs/heads/master
| 2020-04-25T01:44:33.402407
| 2019-02-25T02:54:05
| 2019-02-25T02:54:05
| 172,417,499
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 165
|
cpp
|
// stdafx.cpp : 只包括标准包含文件的源文件
// FolderDemo.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
|
[
"295442216@qq.com"
] |
295442216@qq.com
|
5786a66155ec3fea1f676040063aaba3265ad9cf
|
14582f8c74c28d346399f877b9957d0332ba1c3c
|
/branches/pstade_1_03_5_head/pstade_subversive/pstade/junk/range_based.hpp
|
fe99c78d28b99fbe62b73dd88b0bfb916c6e44e7
|
[] |
no_license
|
svn2github/p-stade
|
c7b421be9eeb8327ddd04d3cb36822ba1331a43e
|
909b46567aa203d960fe76055adafc3fdc48e8a5
|
refs/heads/master
| 2016-09-05T22:14:09.460711
| 2014-08-22T08:16:11
| 2014-08-22T08:16:11
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,906
|
hpp
|
#ifndef BOOST_PP_IS_ITERATING
#ifndef PSTADE_OVEN_RANGE_BASED_HPP
#define PSTADE_OVEN_RANGE_BASED_HPP
// PStade.Oven
//
// Copyright Shunsuke Sogame 2005-2007.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/lambda/core.hpp> // lambda_functor
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_shifted.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/utility/result_of.hpp>
#include <pstade/as.hpp>
#include <pstade/callable.hpp>
#include <pstade/lambda_result_of.hpp> // inclusion guaranteed
#include <pstade/object_generator.hpp>
#include <pstade/preprocessor.hpp>
#include "./range_iterator.hpp"
namespace pstade { namespace oven {
namespace range_based_detail {
template< class IterBased >
struct op_result :
callable< op_result<IterBased> >
{
template< class Myself, PSTADE_CALLABLE_APPLY_PARAMS(A) >
struct apply
{ }; // complete for SFINAE.
// 1ary
template< class Myself, class A0 >
struct apply<Myself, A0> :
boost::result_of<
IterBased(
typename range_iterator<A0>::type,
typename range_iterator<A0>::type
)
>
{ };
template< class Result, class A0 >
Result call(A0& a0) const
{
return m_fun(
boost::begin(a0),
boost::end(a0)
);
}
// 2ary-
#define PSTADE_ref(Z, N, A) BOOST_PP_CAT(A, N) &
#define PSTADE_as_ref(Z, N, A) as_ref(BOOST_PP_CAT(A, N))
#define BOOST_PP_ITERATION_PARAMS_1 (3, (2, PSTADE_CALLABLE_MAX_ARITY, <pstade/oven/range_based.hpp>))
#include BOOST_PP_ITERATE()
#undef PSTADE_as_ref
#undef PSTADE_ref
explicit op_result()
{ }
explicit op_result(IterBased const& fun) :
m_fun(fun)
{ }
typedef IterBased base_type;
IterBased const& base() const
{
return m_fun;
}
private:
IterBased m_fun;
};
} // namespace range_based_detail
// PSTADE_OBJECT_GENERATOR(range_based, (range_based_detail::op_result< deduce<_1, to_value> >))
template< class SigFun >
range_based_detail::op_result<
typename boost::lambda::as_lambda_functor<SigFun>::type
>
range_based()
{
return
range_based_detail::op_result<
typename boost::lambda::as_lambda_functor<SigFun>::type
>( boost::lambda::to_lambda_functor(SigFun()) );
}
template< class Function >
range_based_detail::op_result<Function>
range_based(Function fun)
{
return range_based_detail::op_result<Function>(fun);
}
} } // namespace pstade::oven
#endif
#else
#define n BOOST_PP_ITERATION()
template< class Myself, BOOST_PP_ENUM_PARAMS(n, class A) >
struct apply<Myself, BOOST_PP_ENUM_PARAMS(n, A)> :
boost::result_of<
IterBased(
typename range_iterator<A0>::type,
typename range_iterator<A0>::type,
BOOST_PP_ENUM_SHIFTED(n, PSTADE_ref, A)
)
>
{ };
template< class Result, BOOST_PP_ENUM_PARAMS(n, class A) >
Result call(BOOST_PP_ENUM_BINARY_PARAMS(n, A, & a)) const
{
return m_fun(
as_ref(boost::begin(a0)),
as_ref(boost::end(a0)),
BOOST_PP_ENUM_SHIFTED(n, PSTADE_as_ref, a)
);
}
#undef n
#endif
|
[
"mb2sync@350e9bb6-6311-0410-90c3-be67731b76ec"
] |
mb2sync@350e9bb6-6311-0410-90c3-be67731b76ec
|
596cf7bffa5da8c7a34c9bfc0ba5a591b06a609e
|
9da6ffc55ba8a19192bd0efad09657758de4e792
|
/1172.B. Nauuo and Circle.cpp
|
91beab6e6ddbb8f89a3775971d7cf87f0795a2db
|
[] |
no_license
|
fsq/codeforces
|
b771cb33c67fb34168c8ee0533a67f16673f9057
|
58f3b66439457a7368bb40af38ceaf89b9275b36
|
refs/heads/master
| 2021-05-11T03:12:27.130277
| 2020-10-16T16:55:03
| 2020-10-16T16:55:03
| 117,908,849
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 761
|
cpp
|
#include "stdc++.h"
const int M = 998244353;
int n;
VVI e;
VI A, tot;
int MUL(int a, int b) {
return (LL)a*b % M;
}
// int dp(int x, int pre) {
// int f = 1;
// tot[x] = 1;
// FOREACH_IF(y, e[x], y!=pre) {
// f = MUL(f, dp(y, x));
// f = MUL(f, SZ(e[y]));
// tot[x] += tot[y];
// }
// f = MUL(f, A[SZ(e[x])-(pre!=0)]);
// return f;
// }
int main() {
ios::sync_with_stdio(false);
cin >> n;
A.resize(n+1);
tot.resize(n+1);
A[0] = 1;
REP(i, 1, n)
A[i] = MUL(A[i-1], i);
e.resize(n+1);
for (int u,v,i=0; i<n-1; ++i) {
cin >> u >> v;
e[u].PB(v);
e[v].PB(u);
}
// cout << MUL(dp(1, 0), n) << endl;
int f = 1;
REP(i, 1, n)
f = MUL(f, A[SZ(e[i])]);
cout << MUL(f, n) << endl;
return 0;
}
|
[
"19474@qq.com"
] |
19474@qq.com
|
a79af84d423c1e691a16bf7646a0591c88c70c91
|
d1a81d8fdffd93f2fea25be08e9c790dd7484962
|
/Assignments/P01/11498/Ravishka_Main_11498.cpp
|
0d9d069e0b5d27b51647db0890e24645ad71280d
|
[] |
no_license
|
Ravishka123/4883-Programming-Techniques
|
cff36d8ea681a6c0a447fb4afffa35b18296f34a
|
0d6389c57b8e28fe0578cd7c7e4041197de61505
|
refs/heads/master
| 2023-01-27T18:38:54.125794
| 2020-12-07T08:49:49
| 2020-12-07T08:49:49
| 290,633,609
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 699
|
cpp
|
//Ravishka Rathnasuriya
//Dr.Terry Griffin
//11498 - Division of Nlogonia
//Dividing the land into 4 independent territories.
#include <iostream>
using namespace std;
int main(){
int K, N, M, X,Y;
cin>> K;
while(K!=0){
cin >> N>>M;
for(int i = 0; i < K; i++){
cin >>X>>Y;
if(X>N && Y>M)
cout << "NE\n";
else if (X<N && Y>M)
cout << "NO\n";
else if(X>N && Y<M)
cout << "SE\n";
else if(X<N && Y<M)
cout << "SO\n";
else
cout << "divisa\n";
}
cin >> K;
}
return 0;
}
|
[
"noreply@github.com"
] |
Ravishka123.noreply@github.com
|
364d22b974fcff3b3c90ea9f9366491e01a6cdf1
|
4e3279241bc27e7416842c84241c78e5a60b0b1c
|
/アクションゲーム/スケルトン/Source/Ladder.h
|
5a68b1c824dbeccaa54cc4efc8af4d68d004fc16
|
[] |
no_license
|
munasuke/MyProject
|
31b15b5084dc2cd7059b24c562eb3bd2e32b3346
|
d56e9a5dfbaffbd3a22acf575bb0da60a410dcbf
|
refs/heads/master
| 2020-03-16T20:53:15.143269
| 2018-08-03T09:56:21
| 2018-08-03T09:56:21
| 132,976,116
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 318
|
h
|
#pragma once
#include "CharactorObject.h"
#include<memory>
class Player;
class Camera;
class Ladder :
public CharactorObject
{
public:
Ladder(std::weak_ptr<Player> _pl, std::weak_ptr<Camera> _cam, positin _pos);
~Ladder();
void Updata();
void Draw();
private:
std::weak_ptr<Player> pl;
positin localPos;
};
|
[
"34709203+munasuke@users.noreply.github.com"
] |
34709203+munasuke@users.noreply.github.com
|
ce99a083825aec58ad1cac584cd2a2f32f872af6
|
6127e577648c472a04ea572feaea2e80f479c1cb
|
/prog/methods.h
|
b922e250ffead0275b11373047bb05e3d0fdcce7
|
[] |
no_license
|
barteqx/numerki_2
|
43a0b1c06fc6f45ccdaa4e2e76d367c844e75af2
|
4c1c475f8a5c5c013295e01cdfe37ba23e9f853b
|
refs/heads/master
| 2021-01-01T19:30:11.876276
| 2014-01-26T21:38:43
| 2014-01-26T21:38:43
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 177
|
h
|
#include "matrix.h"
void jacobi_method(Matrix & m, std::vector<double> & b, double precision);
void gauss_seidel_method(Matrix & m, std::vector<double> & b, double precision);
|
[
"barteqx@gmail.com"
] |
barteqx@gmail.com
|
3b89f172c4698e54fa47ca6689f9acf73b13b489
|
1dd397fa88b66877c669711f8a479c2fe61de440
|
/regression/cpp/Decltype2/main.cpp
|
f315130f21afb28980b702a6d2b165895bd3eab1
|
[
"MIT",
"BSD-2-Clause"
] |
permissive
|
fanhy2114/yogar-cbmc
|
bc707ccb927f6e5a2c23c188619e7bb997d9369e
|
4e61ef2853158bf183f9fe31b12bf048cefa643a
|
refs/heads/master
| 2020-04-17T10:27:50.033647
| 2019-12-30T13:43:35
| 2019-12-30T13:43:35
| 166,502,179
| 1
| 1
|
NOASSERTION
| 2019-01-19T03:32:21
| 2019-01-19T03:32:21
| null |
UTF-8
|
C++
| false
| false
| 285
|
cpp
|
// C++11
// decltype is a C++11 feature to get the "declared type" of an expression.
// It is similar to 'typeof' but handles reference types "properly".
class base {};
class derived : public base {};
derived d;
decltype(static_cast<derived *>(&d)) z;
int main()
{
}
|
[
"yinliangze@163.com"
] |
yinliangze@163.com
|
1b94194fa5034d55c7ffc275a4a614bfde936cb8
|
35cbc0049d0c88cd9282a3c82980500bc2093cf2
|
/2019-1-31/C.cpp
|
0d943b0ad36460eb1211f5b93bcd177fc2f81d7d
|
[] |
no_license
|
ciwomuli/NOIP2017exercise
|
9f96026a7c88548a0d2783374b0a9582012acf33
|
e13a818f14da49b3ec94626e7f664301a9da985e
|
refs/heads/master
| 2023-01-22T14:02:02.850686
| 2020-12-04T14:21:08
| 2020-12-04T14:21:08
| 108,097,370
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 873
|
cpp
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#define LL long long
#define P pair<int,int>
using namespace std;
template <typename T>
inline void read(T &t)
{
int f = 0, c = getchar();
t = 0;
while (!isdigit(c))
f |= c == '-', c = getchar();
while (isdigit(c))
t = t * 10 + c - 48, c = getchar();
if (f)
t = -t;
}
template <typename T, typename... Args>
inline void read(T &t, Args &... args)
{
read(t);
read(args...);
}
const int maxn=3e5+5;
int a[maxn];
int main(){
int n;
read(n);
for(int i=1;i<=n;i++)
read(a[i]);
LL ans=0;
sort(a + 1, a + n + 1);
for (int i = 1;i<=n/2;i++)
ans += (a[i] + a[n-i+1]) * (a[i] + a[n-i+1]);
cout << ans;
}
|
[
"570727732@qq.com"
] |
570727732@qq.com
|
fe7a9155daaab9f0d456b99e2243b6e0532b958b
|
7e9c6a7f93274e9f6b51ff9cac6e0d4ac78e2881
|
/array.cc
|
430a3da7ac5fd14f6333b785c9e6a3072b3bf49d
|
[] |
no_license
|
huangyingw/array
|
ba9658c23751bdf00b4c3574faeff6472018e518
|
25a560484c585a124e1bd1bc686dda15b1602f48
|
refs/heads/master
| 2020-06-01T18:45:22.888477
| 2012-11-05T06:31:41
| 2012-11-05T06:31:41
| 2,749,237
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,473
|
cc
|
#include <stdio.h>
#include <iostream>
using namespace std;
void array_copy(int array[], int len) {
//int result[]=new int[len];
int *result=new int[len];
//int result[len];
for (int i=0;i<len;i++) {
result[i]=array[i];
}
int temp;
temp=result[0];
result[0]=result[1];
result[1]=temp;
}
void array_uncopy(int array[], int len) {
int temp;
temp=array[0];
array[0]=array[1];
array[1]=temp;
}
void print_array(int array[], int len) {
for (int i=0;i<len;i++) {
cout<<array[i]<<",";
}
cout<<endl;
}
void print_array2(int array[][4], int len1,int len2) {
for (int i=0;i<len1;i++) {
for (int j=0;j<len2;j++) {
cout<<array[i][j]<<",";
}
}
cout<<endl;
}
int main(void) {
int a1[2][3]={6,5,4,3,2,1};
printf( "%d : %d\n ",a1,sizeof(a1));//a1 -1075833576 : 24
printf( "%d : %d\n ",*a1,sizeof(*a1));//*a1 -1075833576 : 12
printf( "%d : %d\n ",a1[0],sizeof(a1[0]));//*a1 -1075833576 : 12
printf( "%d : %d\n ",*(a1+1),sizeof(*(a1+1)));//*(a1+1) -1075833564 : 12
printf( "%d : %d\n ",a1[1],sizeof(a1[1]));//*(a1+1) -1075833564 : 12
printf( "%d : %d\n ",**a1,sizeof(**a1));//a1[0][0]=6 6 : 4
printf( "%d : %d\n ",*a1[0],sizeof(*a1[0]));//a1[0][0]=6 6 : 4
printf( "%d : %d\n ",*(*(a1+1)+1),sizeof(*(*(a1+1)+1)));//a1[1][1]=2 2 : 4
printf( "%d : %d\n ",*(*a1+1),sizeof(*(*a1+1)));//a1[0][1]=5 5 : 4
printf( "%d : %d\n ",**(a1+1),sizeof(**(a1+1)));//a1[1][0]=3 3 : 4
printf( "%d : %d\n ",*a1[1],sizeof(*a1[1]));//a1[1][0]=3 3 : 4
printf( "%d : %d\n ",&a1,sizeof(&a1));//&a1[0][0] -1075833576 : 8
printf( "%d : %d\n ",&a1[0],sizeof(&a1[0]));//&a1[0][0] -1075833576 : 8
//a1[0]={1,2,3};
int a[] = {4, 2, 5};
print_array(a,sizeof(a)/sizeof(int));
array_copy(a,sizeof(a)/sizeof(int));
print_array(a,sizeof(a)/sizeof(int));
cout<<endl;
print_array(a,sizeof(a)/sizeof(int));
array_uncopy(a,sizeof(a)/sizeof(int));
print_array(a,sizeof(a)/sizeof(int));
int a2[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}};
print_array2(a2,sizeof(a2)/sizeof(a2[0]),sizeof(a2[0])/sizeof(a2[0][0]));
int a3[3][4]={1,2,3,4,5,6,7,8,9,10,11,12};
int a4[3][4]={{1},{5},{9}};
int a5[3][4]={{1},{0,6},{0,0,11}};
int a6[3][4]={{1},{0,6},{0,0,11}};
int a7[3][4]={{1},{5,6}};
int a8[3][4]={{1},{},{9}};
int a9[][4]={1,2,3,4,5,6,7,8,9,10,11,12};
int a10[][4]={{0,0,3},{},{0,10}};
return 0;
}
|
[
"huangyingw@gmail.com"
] |
huangyingw@gmail.com
|
440d45f30124a09728f561dfef2445e7623bed1a
|
b1e1d5580522dfee69cc9de34b90b36d4b4ff195
|
/src/CodegenRules.hpp
|
575bb6de61b730ac5d36be3a0facd44bdb363350
|
[] |
no_license
|
UWQuickstep/rosa
|
66a4e2f04f08692de72d34ca61e17fa6af9953a5
|
623ce962306c28f0cacee97b612fcf1dad652975
|
refs/heads/master
| 2020-12-02T23:58:36.243061
| 2017-07-05T15:51:39
| 2017-07-05T15:51:39
| 95,968,975
| 6
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,962
|
hpp
|
#ifndef ROSA_CODEGEN_RULES_HPP_
#define ROSA_CODEGEN_RULES_HPP_
#include <vector>
#include <map>
#include <memory>
#include <string>
#include "Macros.hpp"
#include "Type.hpp"
namespace rosa {
namespace rule {
namespace codegen {
class CodegenRule {
public:
CodegenRule() {}
virtual ~CodegenRule() {}
virtual std::string genCode(const std::vector<const Type*> &types,
const std::vector<std::string> &args) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(CodegenRule);
};
class OpRule : public CodegenRule {
public:
OpRule(const std::string &op, const std::string &env)
: op_(op), env_(env) {}
std::string genCode(const std::vector<const Type*> &types,
const std::vector<std::string> &args) override;
private:
const std::string op_;
const std::string env_;
static std::map<std::string, std::string> names_;
static std::map<std::string, std::string> renames_;
DISALLOW_COPY_AND_ASSIGN(OpRule);
};
class FirstArgRule : public CodegenRule {
public:
FirstArgRule() {}
std::string genCode(const std::vector<const Type*> &types,
const std::vector<std::string> &args) override;
private:
DISALLOW_COPY_AND_ASSIGN(FirstArgRule);
};
class FnCallRule : public CodegenRule {
public:
FnCallRule(const std::string &fn_name, const std::string &env)
: fn_name_(fn_name), env_(env) {}
std::string genCode(const std::vector<const Type*> &types,
const std::vector<std::string> &args) override;
private:
const std::string fn_name_;
const std::string env_;
DISALLOW_COPY_AND_ASSIGN(FnCallRule);
};
class BuiltinFnCallRule : public CodegenRule {
public:
BuiltinFnCallRule(const std::string &fn_name,
const std::string &env)
: fn_name_(fn_name), env_(env) {}
std::string genCode(const std::vector<const Type*> &types,
const std::vector<std::string> &args) override;
private:
const std::string fn_name_;
const std::string env_;
DISALLOW_COPY_AND_ASSIGN(BuiltinFnCallRule);
};
class ParenthesisRule : public CodegenRule {
public:
ParenthesisRule() {}
std::string genCode(const std::vector<const Type*> &types,
const std::vector<std::string> &args) override;
private:
DISALLOW_COPY_AND_ASSIGN(ParenthesisRule);
};
class BracketRule : public CodegenRule {
public:
BracketRule() {}
std::string genCode(const std::vector<const Type*> &types,
const std::vector<std::string> &args) override;
private:
DISALLOW_COPY_AND_ASSIGN(BracketRule);
};
class ForCondRule : public CodegenRule {
public:
ForCondRule() {}
std::string genCode(const std::vector<const Type*> &types,
const std::vector<std::string> &args) override;
private:
DISALLOW_COPY_AND_ASSIGN(ForCondRule);
};
} // namespace codegen
} // namespace rule
} // namespace rosa
#endif // ROSA_CODEGEN_RULES_HPP_
|
[
"jianqiao@Jianqiaos-MacBook-Pro.local"
] |
jianqiao@Jianqiaos-MacBook-Pro.local
|
10615a558f13664fee63b22867ca569bbc7d4b86
|
293f1095803ea5031e9719d28c0fcefe9008473a
|
/ichigo/cocos2d-x/CocosDirectorView.h
|
60cb8c5fbed01ec76bd10edd6789d6b4862b1d45
|
[] |
no_license
|
Avnerus/ichigo
|
23e24f547dde5d1bd158db7871a07a3f7679d4bb
|
849c507bfca8989685f9fc64ac06f68bc5ce0576
|
refs/heads/master
| 2021-01-13T14:37:06.784739
| 2015-10-03T17:22:19
| 2015-10-03T17:22:19
| 43,607,246
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,031
|
h
|
#ifndef __ICHIGO_COCOSDIRECTORVIEW_H__
#define __ICHIGO_COCOSDIRECTORVIEW_H__
#include "DirectorView.h"
#include "cocos2d.h"
namespace ichigo
{
class CocosDirectorView : public DirectorView
{
public:
CocosDirectorView(Agent *agent);
virtual ~CocosDirectorView();
virtual void *getInternalData();
virtual void setPivot(const Point &pivot);
virtual void addScene(SceneView *sceneView);
virtual void removeScene(SceneView *sceneView);
virtual void setCurrentScene(SceneView *sceneView);
virtual SceneView *getCurrentScene();
virtual Point convertLocalToScreen(const Point &localPos);
virtual Point convertScreenToLocal(const Point &screenPos);
virtual void getScreenSize(int &width, int &height);
protected:
cocos2d::CCDirector *_ccDirector;
};
}
#endif // __ICHIGO_COCOSDIRECTORVIEW_H__
|
[
"avnerus@gmail.com"
] |
avnerus@gmail.com
|
17c4d0d84dcc573792b25b3cc4070166faefce7c
|
ca7c05ceb5a8a2dc5f648e28fcd4754d38b454de
|
/eoeFlappyBird/proj.wp8/eoeFlappyBird.cpp
|
5f3bcc6b26d0fda2e6caaf5716a6bb28fd4275df
|
[] |
no_license
|
AdityaGovil004/eoeFlappyBird
|
aebefb21973d4e6ed0fb5d2a009aa08da4034ec5
|
a9112978530c47a75790b8c0d4c5b0df4bc13c94
|
refs/heads/master
| 2023-05-14T03:08:34.440797
| 2019-06-26T12:18:44
| 2019-06-26T12:18:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,816
|
cpp
|
#include <wrl/client.h>
#include <d3d11_1.h>
#include <DirectXMath.h>
#include <memory>
#include <agile.h>
#include <ppltasks.h>
#include "eoeFlappyBird.h"
#include "CCApplication.h"
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::ApplicationModel::Activation;
using namespace Windows::UI::Core;
using namespace Windows::System;
using namespace Windows::Foundation;
using namespace Windows::Graphics::Display;
using namespace Windows::Phone::UI::Input;
using namespace Windows::Graphics::Display;
using namespace concurrency;
USING_NS_CC;
eoeFlappyBird::eoeFlappyBird()
{
}
void eoeFlappyBird::Initialize(CoreApplicationView^ applicationView)
{
applicationView->Activated +=
ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &eoeFlappyBird::OnActivated);
CoreApplication::Suspending +=
ref new EventHandler<SuspendingEventArgs^>(this, &eoeFlappyBird::OnSuspending);
CoreApplication::Resuming +=
ref new EventHandler<Platform::Object^>(this, &eoeFlappyBird::OnResuming);
}
void eoeFlappyBird::SetWindow(CoreWindow^ window)
{
// Specify the orientation of your application here
// The choices are DisplayOrientations::Portrait or DisplayOrientations::Landscape or DisplayOrientations::LandscapeFlipped
DisplayProperties::AutoRotationPreferences = DisplayOrientations::Landscape;
window->VisibilityChanged +=
ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &eoeFlappyBird::OnVisibilityChanged);
window->Closed +=
ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &eoeFlappyBird::OnWindowClosed);
window->PointerPressed +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &eoeFlappyBird::OnPointerPressed);
window->PointerMoved +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &eoeFlappyBird::OnPointerMoved);
window->PointerReleased +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &eoeFlappyBird::OnPointerReleased);
CCEGLView* eglView = new CCEGLView();
eglView->Create(window);
eglView->setViewName("eoeFlappyBird");
}
void eoeFlappyBird::Load(Platform::String^ entryPoint)
{
}
void eoeFlappyBird::Run()
{
CCApplication::sharedApplication()->run();
}
void eoeFlappyBird::Uninitialize()
{
}
void eoeFlappyBird::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
{
CCEGLView::sharedOpenGLView()->OnVisibilityChanged(sender, args);
}
void eoeFlappyBird::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
{
CCEGLView::sharedOpenGLView()->OnWindowClosed(sender, args);
}
void eoeFlappyBird::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
{
CCEGLView::sharedOpenGLView()->OnPointerPressed(sender, args);
}
void eoeFlappyBird::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
{
CCEGLView::sharedOpenGLView()->OnPointerMoved(sender, args);
}
void eoeFlappyBird::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
{
CCEGLView::sharedOpenGLView()->OnPointerReleased(sender, args);
}
void eoeFlappyBird::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
{
HardwareButtons::BackPressed += ref new EventHandler<BackPressedEventArgs^>(this, &eoeFlappyBird::OnBackButtonPressed);
CoreWindow::GetForCurrentThread()->Activate();
}
void eoeFlappyBird::OnBackButtonPressed(Object^ sender, BackPressedEventArgs^ args)
{
// Leave args->Handled set to false and the app will quit when user presses the back button on the phone
}
void eoeFlappyBird::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
{
// Save app state asynchronously after requesting a deferral. Holding a deferral
// indicates that the application is busy performing suspending operations. Be
// aware that a deferral may not be held indefinitely. After about five seconds,
// the app will be forced to exit.
SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
//m_renderer->ReleaseResourcesForSuspending();
create_task([this, deferral]()
{
// Insert your code here.
deferral->Complete();
});
}
void eoeFlappyBird::OnResuming(Platform::Object^ sender, Platform::Object^ args)
{
// Restore any data or state that was unloaded on suspend. By default, data
// and state are persisted when resuming from suspend. Note that this event
// does not occur if the app was previously terminated.
// m_renderer->CreateWindowSizeDependentResources();
}
IFrameworkView^ Direct3DApplicationSource::CreateView()
{
return ref new eoeFlappyBird();
}
[Platform::MTAThread]
int main(Platform::Array<Platform::String^>^)
{
auto direct3DApplicationSource = ref new Direct3DApplicationSource();
CoreApplication::Run(direct3DApplicationSource);
return 0;
}
|
[
"github@plter.com"
] |
github@plter.com
|
0c28eeefa40cf884e234637a6de69e374c628433
|
94c1c7459eb5b2826e81ad2750019939f334afc8
|
/source/CellRange.h
|
320cb0a08979e0e74a203ef9c98fc784c902adb3
|
[] |
no_license
|
wgwang/yinhustock
|
1c57275b4bca093e344a430eeef59386e7439d15
|
382ed2c324a0a657ddef269ebfcd84634bd03c3a
|
refs/heads/master
| 2021-01-15T17:07:15.833611
| 2010-11-27T07:06:40
| 2010-11-27T07:06:40
| 37,531,026
| 1
| 3
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,349
|
h
|
#if !defined(AFX_CELLRANGE_H__F86EF761_725A_11D1_ABBA_00A0243D1382__INCLUDED_)
#define AFX_CELLRANGE_H__F86EF761_725A_11D1_ABBA_00A0243D1382__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CCellID
{
public:
int row, col;
public:
CCellID(int nRow = -1, int nCol = -1) : row(nRow), col(nCol) {}
int IsValid() const { return (row >= 0 && col >= 0); }
int operator==(const CCellID& rhs) { return (row == rhs.row && col == rhs.col); }
int operator!=(const CCellID& rhs) { return !operator==(rhs); }
};
class CCellRange
{
public:
CCellRange(int nMinRow = -1, int nMinCol = -1, int nMaxRow = -1, int nMaxCol = -1)
{
Set(nMinRow, nMinCol, nMaxRow, nMaxCol);
}
void Set(int nMinRow = -1, int nMinCol = -1, int nMaxRow = -1, int nMaxCol = -1);
int IsValid() const;
int InRange(int row, int col) const;
int InRange(const CCellID& cellID) const;
int Count() { return (m_nMaxRow - m_nMinRow + 1) * (m_nMaxCol - m_nMinCol + 1); }
CCellID GetTopLeft() const;
CCellRange Intersect(const CCellRange& rhs) const;
int GetMinRow() const {return m_nMinRow;}
void SetMinRow(int minRow) {m_nMinRow = minRow;}
int GetMinCol() const {return m_nMinCol;}
void SetMinCol(int minCol) {m_nMinCol = minCol;}
int GetMaxRow() const {return m_nMaxRow;}
void SetMaxRow(int maxRow) {m_nMaxRow = maxRow;}
int GetMaxCol() const {return m_nMaxCol;}
void SetMaxCol(int maxCol) {m_nMaxCol = maxCol;}
int GetRowSpan() const {return m_nMaxRow - m_nMinRow + 1;}
int GetColSpan() const {return m_nMaxCol - m_nMinCol + 1;}
int operator==(const CCellRange& rhs);
int operator!=(const CCellRange& rhs);
protected:
int m_nMinRow;
int m_nMinCol;
int m_nMaxRow;
int m_nMaxCol;
};
inline void CCellRange::Set(int minRow, int minCol, int maxRow, int maxCol)
{
m_nMinRow = minRow;
m_nMinCol = minCol;
m_nMaxRow = maxRow;
m_nMaxCol = maxCol;
}
inline int CCellRange::operator==(const CCellRange& rhs)
{
return ((m_nMinRow == rhs.m_nMinRow) && (m_nMinCol == rhs.m_nMinCol) &&
(m_nMaxRow == rhs.m_nMaxRow) && (m_nMaxCol == rhs.m_nMaxCol));
}
inline int CCellRange::operator!=(const CCellRange& rhs)
{
return !operator==(rhs);
}
inline int CCellRange::IsValid() const
{
return (m_nMinRow >= 0 && m_nMinCol >= 0 && m_nMaxRow >= 0 && m_nMaxCol >= 0 &&
m_nMinRow <= m_nMaxRow && m_nMinCol <= m_nMaxCol);
}
inline int CCellRange::InRange(int row, int col) const
{
return (row >= m_nMinRow && row <= m_nMaxRow && col >= m_nMinCol && col <= m_nMaxCol);
}
inline int CCellRange::InRange(const CCellID& cellID) const
{
return InRange(cellID.row, cellID.col);
}
inline CCellID CCellRange::GetTopLeft() const
{
return CCellID(m_nMinRow, m_nMinCol);
}
inline CCellRange CCellRange::Intersect(const CCellRange& rhs) const
{
return CCellRange(max(m_nMinRow,rhs.m_nMinRow), max(m_nMinCol,rhs.m_nMinCol),
min(m_nMaxRow,rhs.m_nMaxRow), min(m_nMaxCol,rhs.m_nMaxCol));
}
#endif // !defined(AFX_CELLRANGE_H__F86EF761_725A_11D1_ABBA_00A0243D1382__INCLUDED_)
|
[
"7171136@qq.com"
] |
7171136@qq.com
|
2a4a8eead3b2ecccff540f64b56bea02a3f6bc9c
|
64e4fabf9b43b6b02b14b9df7e1751732b30ad38
|
/src/chromium/gen/gen_combined/services/device/public/mojom/public_ip_address_geolocation_provider.mojom-shared.h
|
43ee05e7129c014ff68e3727f0bbd70ec9c939f6
|
[
"BSD-3-Clause"
] |
permissive
|
ivan-kits/skia-opengl-emscripten
|
8a5ee0eab0214c84df3cd7eef37c8ba54acb045e
|
79573e1ee794061bdcfd88cacdb75243eff5f6f0
|
refs/heads/master
| 2023-02-03T16:39:20.556706
| 2020-12-25T14:00:49
| 2020-12-25T14:00:49
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,671
|
h
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_DEVICE_PUBLIC_MOJOM_PUBLIC_IP_ADDRESS_GEOLOCATION_PROVIDER_MOJOM_SHARED_H_
#define SERVICES_DEVICE_PUBLIC_MOJOM_PUBLIC_IP_ADDRESS_GEOLOCATION_PROVIDER_MOJOM_SHARED_H_
#include <stdint.h>
#include <functional>
#include <ostream>
#include <type_traits>
#include <utility>
#include "base/compiler_specific.h"
#include "base/containers/flat_map.h"
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/enum_traits.h"
#include "mojo/public/cpp/bindings/interface_data_view.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/map_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "services/device/public/mojom/public_ip_address_geolocation_provider.mojom-shared-internal.h"
#if defined(ENABLE_GNET)
#include "services/network/public/mojom/mutable_partial_network_traffic_annotation_tag.mojom-shared.h"
#endif // ENABLE_GNET
#include "services/device/public/mojom/geolocation.mojom-shared.h"
#include "mojo/public/cpp/bindings/lib/interface_serialization.h"
#include "mojo/public/cpp/bindings/native_enum.h"
#include "mojo/public/cpp/bindings/lib/native_struct_serialization.h"
namespace device {
namespace mojom {
} // namespace mojom
} // namespace device
namespace mojo {
namespace internal {
} // namespace internal
} // namespace mojo
namespace device {
namespace mojom {
// Interface base classes. They are used for type safety check.
class PublicIpAddressGeolocationProviderInterfaceBase {};
using PublicIpAddressGeolocationProviderPtrDataView =
mojo::InterfacePtrDataView<PublicIpAddressGeolocationProviderInterfaceBase>;
using PublicIpAddressGeolocationProviderRequestDataView =
mojo::InterfaceRequestDataView<PublicIpAddressGeolocationProviderInterfaceBase>;
using PublicIpAddressGeolocationProviderAssociatedPtrInfoDataView =
mojo::AssociatedInterfacePtrInfoDataView<PublicIpAddressGeolocationProviderInterfaceBase>;
using PublicIpAddressGeolocationProviderAssociatedRequestDataView =
mojo::AssociatedInterfaceRequestDataView<PublicIpAddressGeolocationProviderInterfaceBase>;
} // namespace mojom
} // namespace device
namespace std {
} // namespace std
namespace mojo {
} // namespace mojo
namespace device {
namespace mojom {
} // namespace mojom
} // namespace device
#endif // SERVICES_DEVICE_PUBLIC_MOJOM_PUBLIC_IP_ADDRESS_GEOLOCATION_PROVIDER_MOJOM_SHARED_H_
|
[
"trofimov_d_a@magnit.ru"
] |
trofimov_d_a@magnit.ru
|
842409c240c2279b42355ed5820e95179a15d221
|
d60a71af744d3c0f3a618ad5f39389e295bf65d4
|
/CODEFORCES/115/A[ Party ].cpp
|
3004e999c967bd61d80d28e9aeb0ac25657e8b0a
|
[] |
no_license
|
Raghavsangal/CP
|
8f6e42dc534bbdc3779bfbd74995c57a62350095
|
284697abb70c9136622635aac27d101fbe3e4e94
|
refs/heads/master
| 2020-05-07T09:10:04.827114
| 2019-06-19T05:24:37
| 2019-06-19T05:24:37
| 180,365,144
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 29,833
|
cpp
|
head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="X-Csrf-Token" content="87aa77adcc28b0ef3b64630c71beee42"/>
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=0.01"/>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery-1.8.3.js"></script>
<script type="application/javascript">
window.standaloneContest = false;
function adjustViewport() {
var screenWidthPx = Math.min($(window).width(), window.screen.width);
var siteWidthPx = 1100; // min width of site
var ratio = Math.min(screenWidthPx / siteWidthPx, 1.0);
var viewport = "width=device-width, initial-scale=" + ratio;
$('#viewport').attr('content', viewport);
var style = $('<style>html * { max-height: 1000000px; }</style>');
$('html > head').append(style);
}
if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
adjustViewport();
}
</script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
<meta http-equiv="profileName" content="f2">
<meta name="google-site-verification" content="OTd2dN5x4nS4OPknPI9JFg36fKxjqY0i1PSfFPv_J90"/>
<meta property="fb:admins" content="100001352546622" />
<meta property="og:image" content="//st.codeforces.com/s/88777/images/codeforces-telegram-square.png" />
<link rel="image_src" href="//st.codeforces.com/s/88777/images/codeforces-telegram-square.png" />
<meta property="og:title" content="Submission #50083398 - Codeforces"/>
<meta property="og:description" content=""/>
<meta property="og:site_name" content="Codeforces"/>
<meta name="cc" content="c75b437c30890d0c16035648d88cd5600c449e12"/>
<meta name="utc_offset" content="+03:00"/>
<meta name="verify-reformal" content="f56f99fd7e087fb6ccb48ef2" />
<title>Submission #50083398 - Codeforces</title>
<meta name="description" content="Codeforces. Programming competitions and contests, programming community" />
<meta name="keywords" content="programming algorithm contest competition informatics olympiads c++ java graphs vkcup" />
<meta name="robots" content="index, follow" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/font-awesome.min.css" type="text/css" charset="utf-8" />
<link href='//fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Cuprum&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<link rel="shortcut icon" type="image/png" href="//st.codeforces.com/s/88777/favicon.png">
<!--CombineResourcesFilter-->
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/prettify.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/clear.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/ttypography.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/problem-statement.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/second-level-menu.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/roundbox.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/datatable.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/table-form.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/topic.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/jquery.jgrowl.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/facebox.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/jquery.wysiwyg.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/jquery.autocomplete.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/codeforces.datepick.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/colorbox.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/jquery.drafts.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/status.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/css/community.css" type="text/css" charset="utf-8" />
<!-- MathJax -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$$$','$$$']], displayMath: [['$$$$$$','$$$$$$']]}
});
</script>
<script type="text/javascript" async
src="https://assets.codeforces.com/mathjax/MathJax.js?config=TeX-AMS_HTML-full"
>
</script>
<!-- /MathJax -->
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/prettify/prettify.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/moment-with-locales.min.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/pushstream.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.easing.min.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.lavalamp.min.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.jgrowl.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.swipe.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/facebox.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/controls/wysiwyg.colorpicker.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/controls/wysiwyg.table.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/controls/wysiwyg.image.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/controls/wysiwyg.link.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.autocomplete.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.datepick.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.ie6blocker.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.ba-bbq.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/jquery.drafts.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/clipboard.min.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/autosize.min.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/sjcl.js"></script>
<script type="text/javascript" src="/scripts/586267ad2481934daed4124c1c644133/en/codeforces-options.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/codeforces.js?v=20160131"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/EventCatcher.js?v=20160131"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/js/preparedVerdictFormats-en.js"></script>
<!--/CombineResourcesFilter-->
<link rel="stylesheet" href="//st.codeforces.com/s/88777/markitup/skins/markitup/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="//st.codeforces.com/s/88777/markitup/sets/markdown/style.css" type="text/css" charset="utf-8" />
<script type="text/javascript" src="//yandex.st/share/share.js" charset="utf-8"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/markitup/jquery.markitup.js"></script>
<script type="text/javascript" src="//st.codeforces.com/s/88777/markitup/sets/markdown/set.js"></script>
<!--[if IE]>
<style>
#sidebar {
padding-left: 1em;
margin: 1em 1em 1em 0;
}
</style>
<![endif]-->
</head>
<body><span style='display:none;' class='csrf-token' data-csrf='87aa77adcc28b0ef3b64630c71beee42'> </span>
<div class="button-up" style="display: none; opacity: 0.7; width: 50px; height:100%; position: fixed; left: 0; top: 0; cursor: pointer; text-align: center; line-height: 35px; color: #d3dbe4; font-weight: bold; font-size: 3.0rem;"><i class="icon-circle-arrow-up"></i></div>
<div class="verdictPrototypeDiv" style="display: none;"></div>
<!-- Codeforces JavaScripts. -->
<script type="text/javascript">
var queryMobile = Codeforces.queryString.mobile;
if (queryMobile === "true" || queryMobile === "false") {
Codeforces.putToStorage("useMobile", queryMobile == "true");
} else {
var useMobile = Codeforces.getFromStorage("useMobile");
if (useMobile === true || useMobile === false) {
if (useMobile != false) {
Codeforces.redirect(Codeforces.updateUrlParameter(document.location.href, "mobile", useMobile));
}
}
}
</script>
<script type="text/javascript">
if (window.parent.frames.length > 0) {
window.stop();
}
</script>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : '554666954583323',
xfbml : true,
version : 'v2.8'
});
FB.AppEvents.logPageView();
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<script type="text/javascript">
$(document).ready(function () {
(function () {
jQuery.expr[':'].containsCI = function(elem, index, match) {
return !match || !match.length || match.length < 4 || !match[3] || (
elem.textContent || elem.innerText || jQuery(elem).text() || ''
).toLowerCase().indexOf(match[3].toLowerCase()) >= 0;
}
}(jQuery));
$.ajaxPrefilter(function(options, originalOptions, xhr) {
var csrf = Codeforces.getCsrfToken();
if (csrf) {
var data = originalOptions.data;
if (originalOptions.data !== undefined) {
if (Object.prototype.toString.call(originalOptions.data) === '[object String]') {
data = $.deparam(originalOptions.data);
}
} else {
data = {};
}
options.data = $.param($.extend(data, { csrf_token: csrf }));
}
});
window.getCodeforcesServerTime = function(callback) {
$.post("/data/time", {}, callback, "json");
}
window.updateTypography = function () {
$("div.ttypography code").addClass("tt");
$("div.ttypography pre>code").addClass("prettyprint").removeClass("tt");
$("div.ttypography table").addClass("bordertable");
prettyPrint();
}
$.ajaxSetup({ scriptCharset: "utf-8" ,contentType: "application/x-www-form-urlencoded; charset=UTF-8", headers: {
'X-Csrf-Token': Codeforces.getCsrfToken()
}});
window.updateTypography();
Codeforces.signForms();
setTimeout(function() {
$(".second-level-menu-list").lavaLamp({
fx: "backout",
speed: 1000
});
}, 0);
Codeforces.countdown();
$("a[rel='photobox']").colorbox();
function showAnnouncements(json) {
//info("j=" + JSON.stringify(json));
if (json.t != "a") {
return;
}
// console.log("Got announcement from channel");
setTimeout(function() {
Codeforces.showAnnouncements(json.d, "en");
}, Math.random() * 500);
}
function showEventCatcherUserMessage(json) {
if (json.t == "s") {
var points = json.d[5];
var passedTestCount = json.d[7];
var judgedTestCount = json.d[8];
var verdict = preparedVerdictFormats[json.d[12]];
var verdictPrototypeDiv = $(".verdictPrototypeDiv");
verdictPrototypeDiv.html(verdict);
if (judgedTestCount != null && judgedTestCount != undefined) {
verdictPrototypeDiv.find(".verdict-format-judged").text(judgedTestCount);
}
if (passedTestCount != null && passedTestCount != undefined) {
verdictPrototypeDiv.find(".verdict-format-passed").text(passedTestCount);
}
if (points != null && points != undefined) {
verdictPrototypeDiv.find(".verdict-format-points").text(points);
}
Codeforces.showMessage(verdictPrototypeDiv.text());
}
}
$(".clickable-title").each(function() {
var title = $(this).attr("data-title");
if (title) {
var tmp = document.createElement("DIV");
tmp.innerHTML = title;
$(this).attr("title", tmp.textContent || tmp.innerText || "");
}
});
$(".clickable-title").click(function() {
var title = $(this).attr("data-title");
if (title) {
Codeforces.alert(title);
} else {
Codeforces.alert($(this).attr("title"));
}
}).css("position", "relative").css("bottom", "3px");
Codeforces.reformatTimes();
//Codeforces.initializePubSub();
if (window.codeforcesOptions.subscribeServerUrl) {
window.eventCatcher = new EventCatcher(
window.codeforcesOptions.subscribeServerUrl,
[
Codeforces.getGlobalChannel(),
Codeforces.getUserChannel(),
Codeforces.getUserShowMessageChannel(),
Codeforces.getContestChannel(),
Codeforces.getParticipantChannel(),
Codeforces.getTalkChannel()
]
);
if (Codeforces.getParticipantChannel()) {
window.eventCatcher.subscribe(Codeforces.getParticipantChannel(), function(json) {
showAnnouncements(json);
});
}
if (Codeforces.getContestChannel()) {
window.eventCatcher.subscribe(Codeforces.getContestChannel(), function(json) {
showAnnouncements(json);
});
}
if (Codeforces.getGlobalChannel()) {
window.eventCatcher.subscribe(Codeforces.getGlobalChannel(), function(json) {
showAnnouncements(json);
});
}
if (Codeforces.getUserChannel()) {
window.eventCatcher.subscribe(Codeforces.getUserChannel(), function(json) {
showAnnouncements(json);
});
}
if (Codeforces.getUserShowMessageChannel()) {
window.eventCatcher.subscribe(Codeforces.getUserShowMessageChannel(), function(json) {
showEventCatcherUserMessage(json);
});
}
}
Codeforces.setupContestTimes("/data/contests");
Codeforces.setupSpoilers();
Codeforces.setupTutorials("/data/problemTutorial");
});
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-743380-5']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = (document.location.protocol == 'https:' ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<div id="body">
<div class="side-bell" style="visibility: hidden; display: none; opacity: 0.7; width: 40px; position: fixed; right: 0; top: 0; cursor: pointer; text-align: center; line-height: 35px; color: #d3dbe4; font-weight: bold; font-size: 1.5rem;">
<span class="icon-stack" style="width: 100%;">
<i class="icon-circle icon-stack-base"></i>
<i class="icon-bell-alt icon-light"></i>
</span>
<br/>
<span class="side-bell__count" style="position: relative; top: -10px;"></span>
</div>
<div id="header" style="position: relative;">
<div style="float:left;">
<a href="/"><img src="//st.codeforces.com/s/88777/images/codeforces-logo-with-telegram.png"/></a>
</div>
<div class="lang-chooser">
<div style="text-align: right;">
<a href="?locale=en"><img src="//st.codeforces.com/s/88777/images/flags/24/gb.png" title="In English" alt="In English"/></a>
<a href="?locale=ru"><img src="//st.codeforces.com/s/88777/images/flags/24/ru.png" title="По-русски" alt="По-русски"/></a>
</div>
<div >
<a href="/enter?back=%2Fcontest%2F115%2Fsubmission%2F50083398">Enter</a>
|
<a href="/register">Register</a>
</div>
</div>
<br style="clear: both;"/>
</div>
<div class="roundbox menu-box" style="">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<div class="roundbox-lb"> </div>
<div class="roundbox-rb"> </div>
<div class="menu-list-container">
<ul class="menu-list main-menu-list">
<li class=""><a href="/">Home</a></li>
<li class=""><a href="/top">Top</a></li>
<li class="current"><a href="/contests">Contests</a></li>
<li class=""><a href="/gyms">Gym</a></li>
<li class=""><a href="/problemset">Problemset</a></li>
<li class=""><a href="/groups">Groups</a></li>
<li class=""><a href="/ratings">Rating</a></li>
<li class=""><a href="/api/help">API</a></li>
<li class=""><a href="/help">Help</a></li>
<li class=""><a href="/calendar">Calendar</a></li>
</ul>
<form method="post" action="/search"><input type='hidden' name='csrf_token' value='87aa77adcc28b0ef3b64630c71beee42'/>
<input class="search" name="query" data-isPlaceholder="true" value=""/>
</form>
<br style="clear: both;"/>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("input.search").focus(function () {
if ($(this).attr("data-isPlaceholder") === "true") {
$(this).val("");
$(this).removeAttr("data-isPlaceholder");
}
});
});
</script>
<br style="height: 3em; clear: both;"/>
<div style="position: relative;">
<div id="pageContent">
<div class="second-level-menu">
<ul class="second-level-menu-list">
<li><a
href="/contest/115">Problems</a></li>
<li><a
href="/contest/115/submit">Submit Code</a></li>
<li><a
href="/contest/115/my">My Submissions</a></li>
<li class="current selectedLava"><a
href="/contest/115/status">Status</a></li>
<li><a
href="/contest/115/hacks">Hacks</a></li>
<li><a
href="/contest/115/room/1">Room</a></li>
<li><a
href="/contest/115/standings">Standings</a></li>
<li><a
href="/contest/115/customtest">Custom Invocation</a></li>
</ul>
</div>
<style>
.source-copier {
font-size: 1.2rem;
float: right;
color: #888 !important;
cursor: pointer;
border: 1px solid rgb(185, 185, 185);
padding: 3px;
margin: 1px;
margin-right: 3px;
line-height: 1.1rem;
text-transform: none;
}
.source-copier:hover {
background-color: #def;
}
</style>
<div class="datatable"
style="background-color: #E1E1E1; padding-bottom: 3px;">
<div class="lt"> </div>
<div class="rt"> </div>
<div class="lb"> </div>
<div class="rb"> </div>
<div style="padding: 4px 0 0 6px;font-size:1.4rem;position:relative;">
General
<div style="position:absolute;right:0.25em;top:0.35em;">
<span style="padding:0;position:relative;bottom:2px;" class="rowCount"></span>
<img class="closed" src="//st.codeforces.com/s/88777/images/icons/control.png"/>
<span class="filter" style="display:none;">
<img class="opened" src="//st.codeforces.com/s/88777/images/icons/control-270.png"/>
<input style="padding:0;position:relative;bottom:2px;border:1px solid #aaa;height:17px;font-size:1.3rem;"/>
</span>
</div>
</div>
<div style="background-color: white;margin:0.3em 3px 0 3px;position:relative;">
<div class="ilt"> </div>
<div class="irt"> </div>
<table class="">
<tr>
<th style="width:2em;">#</th>
<th style="width:12em;">Author</th>
<th style="width:2em;">Problem</th>
<th style="width:2em;">Lang</th>
<th style="width:8em;">Verdict</th>
<th style="width:2em;">Time</th>
<th style="width:2em;">Memory</th>
<th style="width:4em;">Sent</th>
<th style="width:4em;">Judged</th>
<th style="width:4em;"> </th>
</tr>
<tr>
<td>50083398</td>
<td>
Practice:<br/>
<a href="/profile/raghavsinghal11" title="Newbie raghavsinghal11" class="rated-user user-gray">raghavsinghal11</a> </td>
<td>
<a title="A - Party" href="/contest/115/problem/A">115A</a>
- <span title="problem revision">18</span>
</td>
<td>
GNU C++14
</td>
<td>
<span class='verdict-accepted'>Accepted</span>
</td>
<td>
62 ms
</td>
<td>
8 KB
</td>
<td>2019-02-18 08:58:30</td>
<td>2019-02-18 08:58:30</td>
<td>
<button style="padding: 0.05em; width: 80px;" class="showDiff" title="Compare">Compare</button>
</td>
</tr>
</table>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
// Create new ':containsIgnoreCase' selector for search
jQuery.expr[':'].containsIgnoreCase = function(a, i, m) {
return jQuery(a).text().toUpperCase()
.indexOf(m[3].toUpperCase()) >= 0;
};
if (window.updateDatatableFilter == undefined) {
window.updateDatatableFilter = function(i) {
var parent = $(i).parent().parent().parent().parent();
$("tr.no-items", parent).remove();
$("tr", parent).hide().removeClass('visible');
var text = $(i).val();
if (text) {
$("tr" + ":containsIgnoreCase('" + text + "')", parent).show().addClass('visible');
} else {
parent.find(".rowCount").text("");
$("tr", parent).show().addClass('visible');
}
var found = false;
var visibleRowCount = 0;
$("tr", parent).each(function () {
if (!found) {
if ($(this).find("th").size() > 0) {
$(this).show().addClass('visible');
found = true;
}
}
if ($(this).hasClass('visible')) {
visibleRowCount++;
}
});
if (text) {
parent.find(".rowCount").text("Matches: " + (visibleRowCount - (found ? 1 : 0)));
}
if (visibleRowCount == (found ? 1 : 0)) {
$("<tr class='no-items visible'><td style=\"text-align:left;\"colspan=\"32\">No items<\/td><\/tr>").appendTo($(parent).find('table'));
}
$(parent).find("tr td").removeClass("dark");
$(parent).find("tr.visible:odd td").addClass("dark");
}
$(".datatable .closed").click(function () {
var parent = $(this).parent();
$(this).hide();
$(".filter", parent).fadeIn(function () {
$("input", parent).val("").focus().css("border", "1px solid #aaa");
});
});
$(".datatable .opened").click(function () {
var parent = $(this).parent().parent();
$(".filter", parent).fadeOut(function () {
$(".closed", parent).show();
$("input", parent).val("").each(function () {
window.updateDatatableFilter(this);
});
});
});
$(".datatable .filter input").keyup(function(e) {
window.updateDatatableFilter(this);
e.preventDefault();
e.stopPropagation();
});
$(".datatable table").each(function () {
var found = false;
$("tr", this).each(function () {
if (!found && $(this).find("th").size() == 0) {
found = true;
}
});
if (!found) {
$("<tr class='no-items visible'><td style=\"text-align:left;\"colspan=\"32\">No items<\/td><\/tr>").appendTo(this);
}
});
// Applies styles to datatables.
$(".datatable").each(function () {
$(this).find("tr:first th").addClass("top");
$(this).find("tr:last td").addClass("bottom");
$(this).find("tr:odd td").addClass("dark");
$(this).find("tr td:first-child, tr th:first-child").addClass("left");
$(this).find("tr td:last-child, tr th:last-child").addClass("right");
});
$(".datatable table.tablesorter").each(function () {
$(this).bind("sortEnd", function () {
$(".datatable").each(function () {
$(this).find("th, td")
.removeClass("top").removeClass("bottom")
.removeClass("left").removeClass("right")
.removeClass("dark");
$(this).find("tr:first th").addClass("top");
$(this).find("tr:last td").addClass("bottom");
$(this).find("tr:odd td").addClass("dark");
$(this).find("tr td:first-child, tr th:first-child").addClass("left");
$(this).find("tr td:last-child, tr th:last-child").addClass("right");
});
});
});
}
});
</script>
<div class="roundbox " style="margin-top:2em;font-size:1.1rem;">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<div class="caption titled">→ Source
<div class="top-links">
</div>
</div>
<pre id="program-source-text" class="prettyprint lang-cpp program-source" style="padding: 0.5em;">#include<iostream>
using namespace std;
int main(){
int t;
cin >> t;
int a[2002];
for(int i=0;i<t;i++){
int b;
cin >> b;
a[i+1]=b;
}
int k,r=0,c=0;
for(int j=1;j<=t;j++){
k=a[j];
c=1;
while(k>0){
// c++;
k=a[k];
c++;
}
r=max(c,r);
}
cout << r;
}
|
[
"raghav.1613077@kiet.edu"
] |
raghav.1613077@kiet.edu
|
b6b406b95e4fecc3f9908b113654a5801872abd9
|
2b055a1c156d5e7bf5f770b7ea065529be5c79b4
|
/152_program_wdg/soft_wdg.cpp
|
4f44a896cf19867cf915754a4fc7700d812b7e86
|
[] |
no_license
|
PiotrLenarczyk/CPlusPlus_examples
|
72d52879eb3a738d4f735d98d9bf77da11ade297
|
33decce4ff7509df1288491d50f1ad5c3ca7e507
|
refs/heads/master
| 2023-08-31T21:20:45.032494
| 2023-08-24T15:33:12
| 2023-08-24T15:33:12
| 83,543,134
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,855
|
cpp
|
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
int pidof( char *processName )
{
char cmd[1024];
char pidline[1024];
char *pid;
int i = 0, pids_count = 0;
int pidno[64];
FILE *fp = NULL;
memset( pidline, 0, sizeof(pidline) );
memset( pidno, 0, sizeof(pidno) );
sprintf( cmd, "pidof %s", processName );
fp = popen(cmd,"r");
pid = fgets(pidline,1024,fp);
pid = strtok (pidline," ");
while(pid != NULL)
{
pidno[i] = atoi(pid);
pid = strtok (NULL , " ");
i++;
};
pids_count = i;
if ( pids_count > 1 )
printf( "Found multiple pid's\n" );
pclose(fp);
return pidno[0];
};//pidof()
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
int main( int argc, char* argv[] )
{
int st, period;
char monitored_processName[1024];
char cmd[2048];
int pid;
if(argc != 3)
{
printf( "Program-watchdog for monitoring other software\n" );
printf( "usage:\n" );
printf( "\t%s processName period_ms\n", argv[0] );
printf( "f.e.\t%s software.out 100\n", argv[0] );
return 0;
};
printf( "argv[2] : \"%s\"\n", argv[2] );
strcpy( monitored_processName, argv[1] );
period = (int)strtoull( argv[2], NULL, 10 );
while( 1 )
{
pid = pidof( monitored_processName );
printf( "\"%s\".pid : %i\n", monitored_processName, pid );
if(pid == 0)
{
printf( "\n\n====\n" );
printf( "\tMonitored program \"%s\"", monitored_processName );
printf( "is not executing. " );
printf( "It will be rerun\n====\n\n\n" );
sprintf( cmd, "./%s", monitored_processName );
st = system( cmd );
};
usleep( period * 1000 );
};
return 0;
};//end of main()
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
[
"piotrl@elprotronic.com"
] |
piotrl@elprotronic.com
|
724cf696bf8eface9b563590dbdcdee305a08c60
|
10680b7aed284ad7e49ddde2b3ed46ada1758994
|
/kdrive/src/baos/BaosHeartbeat.cpp
|
6db66795299749f5616aa5c5d412472e08de9535
|
[
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] |
permissive
|
mbr1989/baos
|
6367178c6b2c332df60495a6b66d3c79a801ee41
|
561ef2a1c3b92d577f16d059bc07a2fd56fe0b72
|
refs/heads/master
| 2021-01-13T15:01:08.306506
| 2016-08-08T09:52:09
| 2016-08-08T09:52:09
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,827
|
cpp
|
//
// Copyright (c) 2002-2016 WEINZIERL ENGINEERING GmbH
// All rights reserved.
//
// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
// WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
//
#include "pch/kdrive_pch.h"
#include "kdrive/baos/BaosHeartbeat.h"
#include "kdrive/baos/BaosServerItems.h"
#include "kdrive/baos/core/BaosConnector.h"
#include "kdrive/connector/Events.h"
#include <Poco/Exception.h>
#include <boost/assert.hpp>
using Poco::Exception;
using namespace kdrive::connector;
using namespace kdrive::baos;
/******************************
** BaosHeartbeat
*******************************/
BaosHeartbeat::BaosHeartbeat(BaosConnector::Ptr connector, unsigned int interval)
: connector_(connector),
activeFunction_(std::bind(&BaosHeartbeat::sendHeartbeat, this), interval, "BaosHeartbeat"),
alive_(true),
autoTerminate_(false),
autoTerminateFailCount_(0),
timeSinceReset_(0)
{
BOOST_ASSERT(connector && "Invalid Pointer");
}
BaosHeartbeat::~BaosHeartbeat()
{
try
{
stop();
}
catch (...)
{
}
}
void BaosHeartbeat::start()
{
activeFunction_.start();
}
void BaosHeartbeat::stop()
{
activeFunction_.stop();
}
bool BaosHeartbeat::isAlive() const
{
return alive_;
}
unsigned long BaosHeartbeat::getTimeSinceReset() const
{
return timeSinceReset_;
}
void BaosHeartbeat::setAutoTerminate(bool autoTerminate, int failCount)
{
autoTerminate_ = autoTerminate;
autoTerminateFailCount_ = failCount;
autoTerminateFailCounter_ = failCount;
}
void BaosHeartbeat::sendHeartbeat()
{
try
{
BaosServerItems serverItems(connector_);
timeSinceReset_ = serverItems.getTimeSinceReset();
alive_ = true;
autoTerminateFailCounter_ = autoTerminateFailCount_;
}
catch (Exception& /* exception */)
{
alive_ = false;
}
if (autoTerminate_ && !alive_)
{
if (autoTerminateFailCounter_ > 0)
{
--autoTerminateFailCounter_;
}
else
{
connector_->routeEvent(ConnectorEvents::Terminated);
connector_->close();
activeFunction_.stopFromWithinCallback();
}
}
}
/******************************
** ScopedBaosHeartbeat
*******************************/
ScopedBaosHeartbeat::ScopedBaosHeartbeat(BaosConnector::Ptr connector, unsigned int interval)
: BaosHeartbeat(connector, interval)
{
start();
}
ScopedBaosHeartbeat::~ScopedBaosHeartbeat()
{
try
{
stop();
}
catch (...)
{
}
}
|
[
"info@weinzierl.de"
] |
info@weinzierl.de
|
014c2258916be366376562df34ed9b7e616d17e1
|
4e02637ff36bdae1357b3196d3b94108f2245511
|
/glm-0.9.2.7/glm/core/func_integer.hpp
|
5e3d68d38ef4db5bfbeabf75c379422aa4e0638d
|
[
"MIT"
] |
permissive
|
lokeshh/checkers
|
6ebf5b6fa413f41daa0346621b74ab3d3e3ab91f
|
fd79acbfc3a9f53e853bf35356272f83c8909684
|
refs/heads/master
| 2021-01-10T08:14:53.824994
| 2020-10-11T15:49:03
| 2020-10-11T15:49:03
| 43,547,155
| 1
| 1
|
MIT
| 2020-10-11T15:49:05
| 2015-10-02T10:26:38
|
C++
|
WINDOWS-1252
|
C++
| false
| false
| 6,794
|
hpp
|
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-03-17
// Updated : 2010-03-31
// Licence : This source is under MIT License
// File : glm/core/func_integer.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_core_func_integer
#define glm_core_func_integer
namespace glm
{
namespace core{
namespace function{
//! Define integer functions from Section 8.8 of GLSL 4.00.8 specification.
namespace integer{
/// \addtogroup core_funcs
///@{
//! Adds 32-bit unsigned integer x and y, returning the sum
//! modulo pow(2, 32). The value carry is set to 0 if the sum was
//! less than pow(2, 32), or to 1 otherwise.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uaddCarry.xml">GLSL uaddCarry man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
template <typename genUType>
genUType uaddCarry(
genUType const & x,
genUType const & y,
genUType & carry);
//! Subtracts the 32-bit unsigned integer y from x, returning
//! the difference if non-negative, or pow(2, 32) plus the difference
//! otherwise. The value borrow is set to 0 if x >= y, or to 1 otherwise.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/usubBorrow.xml">GLSL usubBorrow man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
template <typename genUType>
genUType usubBorrow(
genUType const & x,
genUType const & y,
genUType & borrow);
//! Multiplies 32-bit integers x and y, producing a 64-bit
//! result. The 32 least-significant bits are returned in lsb.
//! The 32 most-significant bits are returned in msb.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/umulExtended.xml">GLSL umulExtended man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
template <typename genUType>
void umulExtended(
genUType const & x,
genUType const & y,
genUType & msb,
genUType & lsb);
//! Multiplies 32-bit integers x and y, producing a 64-bit
//! result. The 32 least-significant bits are returned in lsb.
//! The 32 most-significant bits are returned in msb.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/imulExtended.xml">GLSL imulExtended man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
template <typename genIType>
void imulExtended(
genIType const & x,
genIType const & y,
genIType & msb,
genIType & lsb);
//! Extracts bits [offset, offset + bits - 1] from value,
//! returning them in the least significant bits of the result.
//! For unsigned data types, the most significant bits of the
//! result will be set to zero. For signed data types, the
//! most significant bits will be set to the value of bit offset + base – 1.
//!
//! If bits is zero, the result will be zero. The result will be
//! undefined if offset or bits is negative, or if the sum of
//! offset and bits is greater than the number of bits used
//! to store the operand.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldExtract.xml">GLSL bitfieldExtract man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
template <typename genIUType>
genIUType bitfieldExtract(
genIUType const & Value,
int const & Offset,
int const & Bits);
//! Returns the insertion the bits least-significant bits of insert into base.
//!
//! The result will have bits [offset, offset + bits - 1] taken
//! from bits [0, bits – 1] of insert, and all other bits taken
//! directly from the corresponding bits of base. If bits is
//! zero, the result will simply be base. The result will be
//! undefined if offset or bits is negative, or if the sum of
//! offset and bits is greater than the number of bits used to
//! store the operand.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldInsert.xml">GLSL bitfieldInsert man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
template <typename genIUType>
genIUType bitfieldInsert(
genIUType const & Base,
genIUType const & Insert,
int const & Offset,
int const & Bits);
//! Returns the reversal of the bits of value.
//! The bit numbered n of the result will be taken from bit (bits - 1) - n of value,
//! where bits is the total number of bits used to represent value.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldReverse.xml">GLSL bitfieldReverse man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
template <typename genIUType>
genIUType bitfieldReverse(genIUType const & value);
//! Returns the number of bits set to 1 in the binary representation of value.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitCount.xml">GLSL bitCount man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
template <typename T, template <typename> class C>
typename C<T>::signed_type bitCount(C<T> const & Value);
//! Returns the bit number of the least significant bit set to
//! 1 in the binary representation of value.
//! If value is zero, -1 will be returned.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findLSB.xml">GLSL findLSB man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
template <typename T, template <typename> class C>
typename C<T>::signed_type findLSB(C<T> const & Value);
//! Returns the bit number of the most significant bit in the binary representation of value.
//! For positive integers, the result will be the bit number of the most significant bit set to 1.
//! For negative integers, the result will be the bit number of the most significant
//! bit set to 0. For a value of zero or negative one, -1 will be returned.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findMSB.xml">GLSL findMSB man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
template <typename T, template <typename> class C>
typename C<T>::signed_type findMSB(C<T> const & Value);
///@}
}//namespace integer
}//namespace function
}//namespace core
using namespace core::function::integer;
}//namespace glm
#include "func_integer.inl"
#endif//glm_core_func_integer
|
[
"lokeshhsharma@gmail.com"
] |
lokeshhsharma@gmail.com
|
f2c72ad361d77a5498ce0009c69c66101a35efdd
|
eb692e52f9119daeb66dabd85f8b03d4904317f7
|
/main.cpp
|
e91e9c7a521207fad782204471ec1184b141763f
|
[] |
no_license
|
willsliou/LinkedList
|
c9dba35e34ccab63698a203c70243dad9b0beb87
|
fb682a2307f83477663523170b5fc9e7a701fd5a
|
refs/heads/master
| 2022-12-05T02:26:36.076384
| 2020-08-16T14:48:19
| 2020-08-16T14:48:19
| 287,964,058
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,291
|
cpp
|
// Traversing a linked list
#include <iostream>
using namespace std;
struct Node {
int data; // 2 bytes of memory
struct Node *next; // 2 bytes of memory
}*first=NULL;
void create(int A[], int n) {
int i;
struct Node *t, *last;
// first = new struct Node;
first = (struct Node *)malloc(sizeof(struct Node));
first->data=A[0];
first->next=NULL;
last = first;
for(i=0;i<n;i++)
{
t = (struct Node*)malloc(sizeof(struct Node));
// make linked list
t->data=A[i];
t->next=NULL;
last->next=t;
last=t;
}
// struct Node *p = first; // get address of first node
// // each iteration, we take the address of the next node
// while (p != 0)
// {
// p = p->next; //takes address to next node
// }
}
void display(struct Node *p) {
while (p != NULL)
{
printf("%d ", p->data);
p=p->next;
}
}
// recursive function for dipslaying
void Rdisplay(struct Node *p) {
if (p != NULL)
{
printf("%d ", p->data);
p=p->next;
}
}
// in our node, the next value will be the previous address
int main() {
// O(n) time
// space is O(n) to account for last ememory returned in stack
int A[] = {11,12,13,14,15,16,17,18,19};
// create(A, sizeof(A)/sizeof(A[0]));
create(A, 9);
// display(first);
Rdisplay(first);
}
|
[
"hellowillsliou@gmail.com"
] |
hellowillsliou@gmail.com
|
4fcce919e1a11c9032801804fbbc46349b02fb66
|
ed0ab47593e1555c8b9fd0e5055b53df08596e73
|
/Key.h
|
9b62aca0246506b34ca9d63053091c8fa4aee2fb
|
[] |
no_license
|
kostasev/Clustering
|
94a33c5266395adab80c2b4718dba7801e51d606
|
62e0b94414a123fa691b34d7e374f1854215c839
|
refs/heads/master
| 2020-04-05T09:31:29.123664
| 2018-12-03T19:48:10
| 2018-12-03T19:48:10
| 156,761,072
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 439
|
h
|
//
// Created by kosti on 10/20/2018.
//
#ifndef UNTITLED_KEY_H
#define UNTITLED_KEY_H
#include <iostream>
#include <vector>
struct Key {
int hash_val;
bool operator==(const Key& lhs) const
{
return (lhs.hash_val==hash_val);
}
};
namespace std {
template<>
struct hash<Key> {
size_t operator()(const Key &k) const {
return k.hash_val;
}
};
};
#endif //UNTITLED_KEY_H
|
[
"kostas.ev79@gmail.com"
] |
kostas.ev79@gmail.com
|
67885951b9372d47b79168bd97cb0abd5fb18834
|
f9d09511b4ec1095254a19ad7ca53cfec57744cb
|
/src/protocols/secure_channel/MessageCounterManager.cpp
|
0ef994e2a48a083ae80ad39c1f5f17aaa2e1e81e
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
PravinkumarJ/connectedhomeip
|
7caabb86d9d57cf08ef231ed65a3a9fdb0ae68c2
|
33ca52264c4460384f664576049a3f8e1ffa196d
|
refs/heads/master
| 2023-09-03T06:29:39.233972
| 2021-10-22T14:50:21
| 2021-10-22T14:50:21
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,528
|
cpp
|
/*
*
* Copyright (c) 2021 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* This file implements the CHIP message counter messages in secure channel protocol.
*
*/
#include <lib/core/CHIPCore.h>
#include <lib/core/CHIPEncoding.h>
#include <lib/core/CHIPKeyIds.h>
#include <lib/support/BufferWriter.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <messaging/ExchangeContext.h>
#include <messaging/ExchangeMgr.h>
#include <messaging/Flags.h>
#include <protocols/Protocols.h>
#include <protocols/secure_channel/Constants.h>
#include <protocols/secure_channel/MessageCounterManager.h>
namespace chip {
namespace secure_channel {
CHIP_ERROR MessageCounterManager::Init(Messaging::ExchangeManager * exchangeMgr)
{
VerifyOrReturnError(exchangeMgr != nullptr, CHIP_ERROR_INCORRECT_STATE);
mExchangeMgr = exchangeMgr;
ReturnErrorOnFailure(
mExchangeMgr->RegisterUnsolicitedMessageHandlerForType(Protocols::SecureChannel::MsgType::MsgCounterSyncReq, this));
return CHIP_NO_ERROR;
}
void MessageCounterManager::Shutdown()
{
if (mExchangeMgr != nullptr)
{
mExchangeMgr->UnregisterUnsolicitedMessageHandlerForType(Protocols::SecureChannel::MsgType::MsgCounterSyncReq);
mExchangeMgr->CloseAllContextsForDelegate(this);
mExchangeMgr = nullptr;
}
}
CHIP_ERROR MessageCounterManager::StartSync(SessionHandle session, Transport::SecureSession * state)
{
// Initiate message counter synchronization if no message counter synchronization is in progress.
Transport::PeerMessageCounter & counter = state->GetSessionMessageCounter().GetPeerMessageCounter();
if (!counter.IsSynchronizing() && !counter.IsSynchronized())
{
ReturnErrorOnFailure(SendMsgCounterSyncReq(session, state));
}
return CHIP_NO_ERROR;
}
CHIP_ERROR MessageCounterManager::QueueReceivedMessageAndStartSync(const PacketHeader & packetHeader, SessionHandle session,
Transport::SecureSession * state,
const Transport::PeerAddress & peerAddress,
System::PacketBufferHandle && msgBuf)
{
// Queue the message to be reprocessed when sync completes.
ReturnErrorOnFailure(AddToReceiveTable(packetHeader, peerAddress, std::move(msgBuf)));
ReturnErrorOnFailure(StartSync(session, state));
// After the message that triggers message counter synchronization is stored, and a message counter
// synchronization exchange is initiated, we need to return immediately and re-process the original message
// when the synchronization is completed.
return CHIP_NO_ERROR;
}
CHIP_ERROR MessageCounterManager::OnMessageReceived(Messaging::ExchangeContext * exchangeContext,
const PayloadHeader & payloadHeader, System::PacketBufferHandle && msgBuf)
{
if (payloadHeader.HasMessageType(Protocols::SecureChannel::MsgType::MsgCounterSyncReq))
{
return HandleMsgCounterSyncReq(exchangeContext, std::move(msgBuf));
}
else if (payloadHeader.HasMessageType(Protocols::SecureChannel::MsgType::MsgCounterSyncRsp))
{
return HandleMsgCounterSyncResp(exchangeContext, std::move(msgBuf));
}
return CHIP_NO_ERROR;
}
void MessageCounterManager::OnResponseTimeout(Messaging::ExchangeContext * exchangeContext)
{
Transport::SecureSession * state = mExchangeMgr->GetSessionManager()->GetSecureSession(exchangeContext->GetSecureSession());
if (state != nullptr)
{
state->GetSessionMessageCounter().GetPeerMessageCounter().SyncFailed();
}
else
{
ChipLogError(SecureChannel, "Timed out! Failed to clear message counter synchronization status.");
}
}
CHIP_ERROR MessageCounterManager::AddToReceiveTable(const PacketHeader & packetHeader, const Transport::PeerAddress & peerAddress,
System::PacketBufferHandle && msgBuf)
{
ReturnErrorOnFailure(packetHeader.EncodeBeforeData(msgBuf));
for (ReceiveTableEntry & entry : mReceiveTable)
{
if (entry.msgBuf.IsNull())
{
entry.peerAddress = peerAddress;
entry.msgBuf = std::move(msgBuf);
return CHIP_NO_ERROR;
}
}
ChipLogError(SecureChannel, "MCSP ReceiveTable Already Full");
return CHIP_ERROR_NO_MEMORY;
}
/**
* Reprocess all pending messages that were encrypted with application
* group key and were addressed to the specified node id.
*
* @param[in] peerNodeId Node ID of the destination node.
*
*/
void MessageCounterManager::ProcessPendingMessages(NodeId peerNodeId)
{
auto * sessionManager = mExchangeMgr->GetSessionManager();
// Find all receive entries matching peerNodeId. Note that everything in
// this table was using an application group key; that's why it was added.
for (ReceiveTableEntry & entry : mReceiveTable)
{
if (!entry.msgBuf.IsNull())
{
PacketHeader packetHeader;
uint16_t headerSize = 0;
if (packetHeader.Decode((entry.msgBuf)->Start(), (entry.msgBuf)->DataLength(), &headerSize) != CHIP_NO_ERROR)
{
ChipLogError(SecureChannel, "MessageCounterManager::ProcessPendingMessages: Failed to decode PacketHeader");
entry.msgBuf = nullptr;
continue;
}
if (packetHeader.GetSourceNodeId().HasValue() && packetHeader.GetSourceNodeId().Value() == peerNodeId)
{
// Reprocess message.
sessionManager->OnMessageReceived(entry.peerAddress, std::move(entry.msgBuf));
// Explicitly free any buffer owned by this handle.
entry.msgBuf = nullptr;
}
}
}
}
CHIP_ERROR MessageCounterManager::SendMsgCounterSyncReq(SessionHandle session, Transport::SecureSession * state)
{
CHIP_ERROR err = CHIP_NO_ERROR;
Messaging::ExchangeContext * exchangeContext = nullptr;
System::PacketBufferHandle msgBuf;
Messaging::SendFlags sendFlags;
exchangeContext = mExchangeMgr->NewContext(session, this);
VerifyOrExit(exchangeContext != nullptr, err = CHIP_ERROR_NO_MEMORY);
msgBuf = MessagePacketBuffer::New(kChallengeSize);
VerifyOrExit(!msgBuf.IsNull(), err = CHIP_ERROR_NO_MEMORY);
// Generate a 64-bit random number to uniquely identify the request.
SuccessOrExit(err = Crypto::DRBG_get_bytes(msgBuf->Start(), kChallengeSize));
msgBuf->SetDataLength(kChallengeSize);
// Store generated Challenge value to message counter context to resolve synchronization response.
state->GetSessionMessageCounter().GetPeerMessageCounter().SyncStarting(FixedByteSpan<kChallengeSize>(msgBuf->Start()));
sendFlags.Set(Messaging::SendMessageFlags::kNoAutoRequestAck).Set(Messaging::SendMessageFlags::kExpectResponse);
// Arm a timer to enforce that a MsgCounterSyncRsp is received before kSyncTimeoutMs.
exchangeContext->SetResponseTimeout(kSyncTimeoutMs);
// Send the message counter synchronization request in a Secure Channel Protocol::MsgCounterSyncReq message.
SuccessOrExit(
err = exchangeContext->SendMessage(Protocols::SecureChannel::MsgType::MsgCounterSyncReq, std::move(msgBuf), sendFlags));
exit:
if (err != CHIP_NO_ERROR)
{
if (exchangeContext != nullptr)
{
exchangeContext->Close();
}
state->GetSessionMessageCounter().GetPeerMessageCounter().SyncFailed();
ChipLogError(SecureChannel, "Failed to send message counter synchronization request with error:%s", ErrorStr(err));
}
return err;
}
CHIP_ERROR MessageCounterManager::SendMsgCounterSyncResp(Messaging::ExchangeContext * exchangeContext,
FixedByteSpan<kChallengeSize> challenge)
{
CHIP_ERROR err = CHIP_NO_ERROR;
Transport::SecureSession * state = nullptr;
System::PacketBufferHandle msgBuf;
uint8_t * msg = nullptr;
state = mExchangeMgr->GetSessionManager()->GetSecureSession(exchangeContext->GetSecureSession());
VerifyOrExit(state != nullptr, err = CHIP_ERROR_NOT_CONNECTED);
// Allocate new buffer.
msgBuf = MessagePacketBuffer::New(kSyncRespMsgSize);
VerifyOrExit(!msgBuf.IsNull(), err = CHIP_ERROR_NO_MEMORY);
msg = msgBuf->Start();
{
Encoding::LittleEndian::BufferWriter bbuf(msg, kSyncRespMsgSize);
bbuf.Put32(state->GetSessionMessageCounter().GetLocalMessageCounter().Value());
bbuf.Put(challenge.data(), kChallengeSize);
VerifyOrExit(bbuf.Fit(), err = CHIP_ERROR_NO_MEMORY);
}
msgBuf->SetDataLength(kSyncRespMsgSize);
err = exchangeContext->SendMessage(Protocols::SecureChannel::MsgType::MsgCounterSyncRsp, std::move(msgBuf),
Messaging::SendFlags(Messaging::SendMessageFlags::kNoAutoRequestAck));
exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(SecureChannel, "Failed to send message counter synchronization response with error:%s", ErrorStr(err));
}
return err;
}
CHIP_ERROR MessageCounterManager::HandleMsgCounterSyncReq(Messaging::ExchangeContext * exchangeContext,
System::PacketBufferHandle && msgBuf)
{
CHIP_ERROR err = CHIP_NO_ERROR;
uint8_t * req = msgBuf->Start();
size_t reqlen = msgBuf->DataLength();
ChipLogDetail(SecureChannel, "Received MsgCounterSyncReq request");
VerifyOrExit(req != nullptr, err = CHIP_ERROR_MESSAGE_INCOMPLETE);
VerifyOrExit(reqlen == kChallengeSize, err = CHIP_ERROR_INVALID_MESSAGE_LENGTH);
// Respond with MsgCounterSyncResp
err = SendMsgCounterSyncResp(exchangeContext, FixedByteSpan<kChallengeSize>(req));
exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(SecureChannel, "Failed to handle MsgCounterSyncReq message with error:%s", ErrorStr(err));
}
return err;
}
CHIP_ERROR MessageCounterManager::HandleMsgCounterSyncResp(Messaging::ExchangeContext * exchangeContext,
System::PacketBufferHandle && msgBuf)
{
CHIP_ERROR err = CHIP_NO_ERROR;
Transport::SecureSession * state = nullptr;
uint32_t syncCounter = 0;
const uint8_t * resp = msgBuf->Start();
size_t resplen = msgBuf->DataLength();
ChipLogDetail(SecureChannel, "Received MsgCounterSyncResp response");
// Find an active connection to the specified peer node
state = mExchangeMgr->GetSessionManager()->GetSecureSession(exchangeContext->GetSecureSession());
VerifyOrExit(state != nullptr, err = CHIP_ERROR_NOT_CONNECTED);
VerifyOrExit(msgBuf->DataLength() == kSyncRespMsgSize, err = CHIP_ERROR_INVALID_MESSAGE_LENGTH);
VerifyOrExit(resp != nullptr, err = CHIP_ERROR_MESSAGE_INCOMPLETE);
VerifyOrExit(resplen == kSyncRespMsgSize, err = CHIP_ERROR_INVALID_MESSAGE_LENGTH);
syncCounter = chip::Encoding::LittleEndian::Read32(resp);
VerifyOrExit(syncCounter != 0, err = CHIP_ERROR_READ_FAILED);
// Verify that the response field matches the expected Challenge field for the exchange.
err =
state->GetSessionMessageCounter().GetPeerMessageCounter().VerifyChallenge(syncCounter, FixedByteSpan<kChallengeSize>(resp));
SuccessOrExit(err);
// Process all queued incoming messages after message counter synchronization is completed.
ProcessPendingMessages(exchangeContext->GetSecureSession().GetPeerNodeId());
exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(SecureChannel, "Failed to handle MsgCounterSyncResp message with error:%s", ErrorStr(err));
}
return err;
}
} // namespace secure_channel
} // namespace chip
|
[
"noreply@github.com"
] |
PravinkumarJ.noreply@github.com
|
9442a51b1e3458b38ae10332b0037e82ee4d9cc4
|
2489f20116dfa10e4514b636cbf92a6036edc21a
|
/tojcode/1355.cpp
|
7c96474237eee86aa28aedcf147c43df96fde8a2
|
[] |
no_license
|
menguan/toj_code
|
7db20eaffce976932a3bc8880287f0111a621a40
|
f41bd77ee333c58d5fcb26d1848a101c311d1790
|
refs/heads/master
| 2020-03-25T04:08:41.881068
| 2018-08-03T05:02:38
| 2018-08-03T05:02:38
| 143,379,558
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 632
|
cpp
|
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a;
while(cin>>a)
{
int n[a];
int b[a];
bool k=1;
for(int i=1;i<a;i++)
b[i]=0;
for(int i=0;i<a;i++)
{
cin>>n[i];
}
for(int i=0;i<a-1;i++)
{
int o= abs(n[i+1]-n[i]);
b[o]=1;
}
for(int i=1;i<a;i++)
{
if(b[i]==0)
k=0;
}
if(k==0)
{
cout<<"Not jolly"<<endl;
}
else if(k==1)
{
cout<<"Jolly"<<endl;
}
}
return 0;
}
|
[
"qq1812755792@sina.com"
] |
qq1812755792@sina.com
|
2c2ebbf23c44985aeee0711e09c2661631c8bf59
|
fa04d2f56c8d4ebfb931968392811a127a4cb46c
|
/trunk/Cities3D/src/NetworkRules/NetworkRestartListCtrl.h
|
cc7742f571621ef7d2f23be5e185d88fc4f391c0
|
[] |
no_license
|
andrewlangemann/Cities3D
|
9ea8b04eb8ec43d05145e0b91d1c542fa3163ab3
|
58c6510f609a0c8ef801c77f5be9ea622e338f9a
|
refs/heads/master
| 2022-10-04T10:44:51.565770
| 2020-06-03T23:44:07
| 2020-06-03T23:44:07
| 268,979,591
| 0
| 0
| null | 2020-06-03T03:25:54
| 2020-06-03T03:25:53
| null |
UTF-8
|
C++
| false
| false
| 3,711
|
h
|
/*
* Cities3D - Copyright (C) 2001-2009 Jason Fugate (saladyears@gmail.com)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#pragma once
#include "style.h" //READ THIS BEFORE MAKING ANY CHANGES TO THIS FILE!!!
//---------------------------- SYSTEM INCLUDES -----------------------------//
//---------------------------- USER INCLUDES -----------------------------//
#include "BaseListCtrl.h"
//---------------------------- DEFINES -----------------------------//
//---------------------------- TYPEDEFS -----------------------------//
class DataObject;
//---------------------------- CLASSES -----------------------------//
//---------------------------------------------------------------------------//
// Class: wxNetworkRestartListCtrl
//
// Displays all the players currently in the game (or not) when waiting for a
// network game to restart.
//
// Derived From:
// <wxBaseListCtrl>
//
// Project:
// <Cities3D>
//
// Include:
// NetworkRestartListCtrl.h
//
class wxNetworkRestartListCtrl : public wxBaseListCtrl
{
//-----------------------------------------------------------------------//
// Section: Public
//
public:
//-----------------------------------------------------------------------//
// Group: Constructors
//
//-----------------------------------------------------------------------//
// Constructor: wxNetworkRestartListCtrl
//
// The wxNetworkRestartListCtrl constructor.
//
// Parameters:
// parent - The parent window.
// id - The message handling ID. Should be a unique (to the parent
// window) ID, if the parent window wants to receive messages from
// the control.
// pos - The list control position in window coordinates.
// size - The list control size.
//
wxNetworkRestartListCtrl(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize);
//-----------------------------------------------------------------------//
// Group: Destructor
//
//-----------------------------------------------------------------------//
// Destructor: ~wxNetworkRestartListCtrl
//
// The wxNetworkRestartListCtrl destructor.
//
~wxNetworkRestartListCtrl();
//-----------------------------------------------------------------------//
// Section: Private
//
private:
//-----------------------------------------------------------------------//
// Group: Game Event Functions
//
//-----------------------------------------------------------------------//
// Function: OnUpdatePlayers
//
// Sets player names for all <Players> in the <Game> at the selection with
// their color. Triggered by the eventNetworkRestartPlayer <Event>.
//
// Parameters:
// game - The current <Game>.
//
void OnUpdatePlayers(const GamePtr &game);
//-----------------------------------------------------------------------//
// Function: OnCountdownTime
//
// Updates the countdown time reamining for the given color.
//
// Parameters:
// object - The <DataObject> containing the color and time remaining.
//
void OnCountdownTime(const DataObject &object);
};
//---------------------------- PROTOTYPES -----------------------------//
|
[
"saladyears@gmail.com"
] |
saladyears@gmail.com
|
f6a296a440cf381c9ffeb5f5bdc087fa748be290
|
fa05c8919d3ba53f22eeefb0d91f286436c7ae69
|
/DQMOffline/L1Trigger/src/L1TLSBlock.cc
|
428ab48bfabc2dd9c16721c7a26e3824d2cf96a6
|
[] |
no_license
|
EmanuelPerez/cmssw
|
8e6836411cc07cf69e48317f51477574e6fa09d4
|
c882ec3ebf7df89878833db83ef525fb84a15286
|
refs/heads/CMSSW_7_0_X
| 2021-01-17T12:37:34.752053
| 2013-09-06T15:02:15
| 2013-09-06T15:02:15
| 12,681,191
| 1
| 0
| null | 2015-12-06T16:10:34
| 2013-09-08T13:36:57
|
C++
|
UTF-8
|
C++
| false
| false
| 5,887
|
cc
|
/*
* \class L1TLSBlock
*
*
* Description: offline DQM class for LS blocking
*
* Implementation:
* <TODO: enter implementation details>
*
* \author: Pietro Vischia - LIP Lisbon pietro.vischia@gmail.com
*
* Changelog:
* 2012/10/23 12:01:01: Class
*
* Todo: see header file
*
*
*/
//
// This class header
#include "DQMOffline/L1Trigger/interface/L1TLSBlock.h"
// System include files
// --
//// User include files
//#include "DQMServices/Core/interface/DQMStore.h"
//
//#include "DataFormats/Scalers/interface/LumiScalers.h"
//#include "DataFormats/Scalers/interface/Level1TriggerRates.h"
//#include "DataFormats/Scalers/interface/Level1TriggerScalers.h"
//
//#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
//#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
//
//#include "DataFormats/Common/interface/ConditionsInEdm.h" // Parameters associated to Run, LS and Event
//
//#include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
//#include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
//#include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
//#include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
//#include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
//#include "CondFormats/L1TObjects/interface/L1GtMuonTemplate.h"
/////
//// Luminosity Information
////#include "DataFormats/Luminosity/interface/LumiDetails.h"
////#include "DataFormats/Luminosity/interface/LumiSummary.h"
//
//// L1TMonitor includes
/////#include "DQM/L1TMonitor/interface/L1TMenuHelper.h"
//#include "DQMOffline/L1Trigger/interface/L1TMenuHelper.h"
//
//#include "TList.h"
using namespace std;
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
L1TLSBlock::L1TLSBlock(){
// Initialize LumiRangeList object. This will be redone at every doBlocking call. Perhaps rethink this
initializeIO(false);
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
L1TLSBlock::~L1TLSBlock(){}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
L1TLSBlock::LumiRangeList L1TLSBlock::doBlocking(LumiTestDoubleList inputList, double threshold, BLOCKBY blockingMethod)
{
inputDoubleList_ = inputList;
thresholdD_ = threshold;
initializeIO(true);
orderTestDoubleList();
switch(blockingMethod){
case STATISTICS:
blockByStatistics();
break;
default:
cout << "[L1TLSBlock::doBlocking()]: Blocking method does not exist or is not implemented" << endl;
}
return outputList_;
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
L1TLSBlock::LumiRangeList L1TLSBlock::doBlocking(LumiTestIntList inputList, int threshold, BLOCKBY blockingMethod)
{
inputIntList_ = inputList;
thresholdI_ = threshold;
initializeIO(true);
orderTestIntList();
switch(blockingMethod){
case STATISTICS:
cout << "[L1TLSBlock::doBlocking()]: Blocking by statistics require doubles as inputs for test variable and threshold" << endl;
break;
default:
cout << "[L1TLSBlock::doBlocking()]: Blocking method does not exist or is not implemented" << endl;
}
return outputList_;
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
void L1TLSBlock::initializeIO(bool outputOnly){
if(!outputOnly){
inputIntList_.clear();
inputDoubleList_.clear();
}
outputList_.clear();
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
void L1TLSBlock::orderTestDoubleList(){
std::sort(inputDoubleList_.begin(), inputDoubleList_.end(), sort_pair_first<int, double>());
// std::sort(v.begin(), v.end(), sort_pair_second<int, std::greater<int> >());
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
void L1TLSBlock::orderTestIntList(){
std::sort(inputIntList_.begin(), inputIntList_.end(), sort_pair_first<int, int>());
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
void L1TLSBlock::blockByStatistics(){
LumiRange currentRange;
double currentError(0);
bool resetFlag(true);
for(LumiTestDoubleList::iterator i=inputDoubleList_.begin(); i!=inputDoubleList_.end(); i++){
if(resetFlag){
currentRange = std::make_pair(i->first,i->first);
resetFlag = false;
}
else
currentRange = std::make_pair(currentRange.first,i->first);
currentError = computeErrorFromRange(currentRange);
if(currentError < thresholdD_){
outputList_.push_back(currentRange);
resetFlag = true;
}
}
}
double L1TLSBlock::computeErrorFromRange(LumiRange& lumiRange){
std::vector<double> errorList;
errorList.clear();
for(size_t i=0; i < inputDoubleList_.size(); i++){
if(inputDoubleList_[i].first>lumiRange.first && inputDoubleList_[i].first<lumiRange.second)
errorList.push_back(inputDoubleList_[i].second);
}
double error(-1);
for(size_t i=0; i<errorList.size(); i++)
error += 1 / (errorList[i] * errorList[i] );
return error;
}
|
[
"sha1-2551000a52bc8adfdb35968fe5ec8ecbf55a28a1@cern.ch"
] |
sha1-2551000a52bc8adfdb35968fe5ec8ecbf55a28a1@cern.ch
|
8ed192bd1a155bd22127735d7da0c6dd44e171b6
|
eed10716f4cbf9c0cbb06c71df105bba3982b584
|
/codeforces/buy_a_shovel.cpp
|
387ee0834b7fc4833fece242e94640868317d8ea
|
[] |
no_license
|
snandasena/cpp
|
4f147e6e3a3014facd58b31bd8d87cd559c9be21
|
c72c19eb24da6cdba8b673dc1dc47f93a44a8423
|
refs/heads/master
| 2022-11-23T05:20:17.820706
| 2020-07-30T07:39:41
| 2020-07-30T07:39:41
| 272,960,743
| 0
| 0
| null | 2020-07-30T07:39:42
| 2020-06-17T11:51:25
|
C++
|
UTF-8
|
C++
| false
| false
| 415
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, k;
cin >> n >> k;
int sum;
for (int i = 1; i <= 9; i++) {
sum = n * i;
if ((sum - k) % 10 == 0 || sum % 10 == 0) {
cout << i;
break;
}
}
return 0;
}
|
[
"sajith@digitalxlabs.com"
] |
sajith@digitalxlabs.com
|
607a81b0ede065db5223976625124e254359bf70
|
ab2eef9283ea9ffaac2152cde390a11ec2a6f636
|
/习题/第三章/box.cpp
|
8489a0bfd24566ee8d3d3451c1d66d3e28dd8bee
|
[
"MIT"
] |
permissive
|
iuming/Classic_Algorithm
|
6b0b8350a05454b74906f0ec7d32affdee8733c4
|
bc0bba50e75cdfc80deba2f69fbeb438c935e912
|
refs/heads/master
| 2022-11-12T17:54:16.029169
| 2020-07-05T09:50:54
| 2020-07-05T09:50:54
| 275,477,874
| 0
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,042
|
cpp
|
#include <iostream>
#include <algorithm>
using namespace std;
struct Pallets
{
int x, y;
} a[6];
bool cmp(Pallets a, Pallets b)
{
return a.x != b.x ? a.x < b.x : a.y > b.y;
}
bool isOk(Pallets a[6])
{
if (a[0].x != a[1].x || a[2].x != a[3].x || a[4].x != a[5].x || a[0].y != a[1].y || a[2].y != a[3].y || a[4].y != a[5].y)
{
return false;
}
if (a[0].x != a[2].x || a[0].y != a[4].y || a[2].y != a[4].x)
{
return false;
}
return true;
}
int main()
{
int x, y;
while (cin >> x >> y)
{
a[0].x = x;
a[0].y = y;
if (a[0].x > a[0].y)
{
swap(a[0].x, a[0].y);
}
for (int i = 1; i < 6; i++)
{
cin >> x >> y;
a[i].x = x;
a[i].y = y;
if (a[i].x > a[i].y)
swap(a[i].x, a[i].y);
}
sort(a, a + 6, cmp);
if (isOk(a))
cout << "POSSIBLE" << endl;
else
cout << "IMPOSSIBLE" << endl;
}
return 0;
}
|
[
"6ming@hrbeu.edu.cn"
] |
6ming@hrbeu.edu.cn
|
1b3f04d4a6af63278c3980314acdf93966e09a40
|
a13a68085590e793b6bc56149adee5a87242deec
|
/DEPENDENCIES/simple_ml_helib/src/HelibCkksContext.h
|
5faea99763711a3e7c557decf8bc17fa659900a4
|
[
"MIT"
] |
permissive
|
mylittlegh/fhe-toolkit-linux
|
a017fbd7aec19795723bd9b475b03be9034bd4aa
|
24dde4322d71731fc85498932e62a7e9e835825b
|
refs/heads/master
| 2022-11-26T09:30:49.606425
| 2020-08-07T00:30:54
| 2020-08-07T00:30:54
| 285,859,155
| 2
| 0
|
MIT
| 2020-08-07T15:13:36
| 2020-08-07T15:13:35
| null |
UTF-8
|
C++
| false
| false
| 2,471
|
h
|
/*
* MIT License
*
* Copyright (c) 2020 International Business Machines
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SRC_ML_HE_EXAMPLES_HELIBCKKSCONTEXT_H_
#define SRC_ML_HE_EXAMPLES_HELIBCKKSCONTEXT_H_
#include "HelibContext.h"
/** A wrapper class over some of HElib's main classes.
*
* It can be either initialized via an HelibConfig, or loaded from a file.
*
* All other classes (e.g., CTile or CipherMatrix) hold a reference to it,
* for access to the keys and other services.
*
* It may or may not hold the secret key.
* If initialized via config, it will contain both secret and public key.
* Using file I/O it can be specified whether to include the secret key or not.
* Server side contexts are not supposed to have the secret key.
*/
class HelibCkksContext : public HelibContext {
const helib::EncryptedArrayCx* ea=NULL;
public:
HelibCkksContext();
virtual ~HelibCkksContext();
void init(unsigned long m,unsigned long r,unsigned long L);
void init(const HelibConfig&conf);
virtual std::shared_ptr<AbstractCiphertext> createAbstractCipher();
virtual std::shared_ptr<AbstractPlaintext> createAbstractPlain();
std::shared_ptr<AbstractEncoder> getEncoder() override;
void printSignature(std::ostream&out) const override;
inline const helib::EncryptedArrayCx& getEncryptedArray() { return *ea; }
void load(std::istream&out) override;
};
#endif /* SRC_ML_HE_EXAMPLES_HELIBCKKSCONTEXT_H_ */
|
[
"flavio@uk.ibm.com"
] |
flavio@uk.ibm.com
|
742fc8d15a6944f6553dc746a1c8a391d1e5cd19
|
e32132367fa36c63353476cefe32adefaae8622e
|
/LinearRegression/Matrix.h
|
ec15570bbea0df509f741a1c486e9691f1e83e99
|
[] |
no_license
|
AveLexinton/test1
|
57ec2866d52bed2393a617986251366f18082410
|
ba634329ef9fa2194b9208f7d903d60ef23c6894
|
refs/heads/master
| 2021-06-07T18:57:24.113844
| 2016-11-12T17:17:48
| 2016-11-12T17:17:48
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,791
|
h
|
#ifndef __MATRIX_H__
#define __MATRIX_H__
#include <stdexcept>
#include <vector>
#include <numeric>
#include <initializer_list>
#include <algorithm>
#include "../base/Fraction.h"
#include "../base/dbghelp.h"
using namespace std;
template<typename T> class Matrix;
template<typename T>
Matrix<T> mat_union(const Matrix<T>& A, const Matrix<T>& B);
//只推荐使用Matrix<Fraction>, 其它版本未完整测试
template<typename T>
class Matrix {
int nrow, ncol;
vector<vector<T>> data;
public:
//默认构造函数
Matrix(int row = 0, int col = 0) {
//dbgcout << "constructor" << endl;
if (row >= 0 && col >= 0) {
nrow = row;
ncol = col;
vector<vector<T>> tempvec(row);
for(auto& a:tempvec) {
a = move(vector<T>(col));
}
data = move(tempvec);
} else
throw std::invalid_argument("Error: row and col must be positive!");
};
Matrix(const initializer_list<initializer_list<T>>& ilil) {
new(this) Matrix(vector<vector<T>>(ilil.begin(), ilil.end()));
}
Matrix(const vector<vector<T>> & vec) {
data = move(vec);
nrow = data.size();
ncol = 0;
bool firstin = true;
for (auto& c:data) {
if (firstin) {
ncol = c.size();
firstin = false;
} else {
if (c.size() != ncol) {
throw invalid_argument("rows must be of same size!");
}
}
}
}
//拷贝构造函数
Matrix(const Matrix& m) {
//dbgcout << "copy constructor" << endl;
nrow = m.nrow;
ncol = m.ncol;
data = m.data;
}
//赋值构造函数
Matrix& operator=(const Matrix& m) {
//dbgcout << "assignment constructor" << endl;
if (this != &m) {
nrow = m.nrow;
ncol = m.ncol;
data = m.data;
}
return *this;
}
//转移构造函数
Matrix(const Matrix&& m) {
//dbgcout << "move constructor" << endl;
*this = move(m);
}
//转移赋值函数
Matrix& operator=(Matrix&& m) {
//dbgcout << "move assignment" << endl;
if (this != &m) {
nrow = m.nrow;
ncol = m.ncol;
data = move(m.data);
m.nrow = m.ncol = 0;
}
return *this;
}
//取值
int getNrow()const {return nrow;}
int getNcol()const {return ncol;}
const T& get(int r, int c) const {
return data.at(r).at(c);
}
const vector<T> getRow(int i) {return data.at(i);}
const vector<vector<T>>& getData() const {return data;}
void set(int r, int c, T val) {
data.at(r).at(c) = move(val);
}
void fill(T val) {
for (auto& a : data)
std::fill(a.begin(), a.end(), val);
}
void setRow(int i, vector<T>& v) {data.at(i) = move(v);}
void setData(const initializer_list<initializer_list<T>>& ilil) {
data = move(vector<vector<T>>{ilil.begin(),ilil.end()});
}
bool isEmpty() const {return nrow == 0 || ncol == 0;}
//右边添加一列
Matrix& addCol(const vector<T>& newcol) {
if (newcol.size() != nrow)
throw runtime_error("Error adding a column: rows does not match!");
for (int i = 0; i < newcol.size(); ++i)
data.at(i).push_back(newcol.at(i));
++ncol;
return *this;
}
//下边添加一行
Matrix& addRow(const vector<T>& newrow) {
if (newrow.size() != ncol)
throw runtime_error("Error adding a row: columns does not match!");
data.push_back(newrow);
++nrow;
return *this;
}
//删除矩阵中的一行,行号从0开始,默认删除最后一行
void rm_row(int rowno=getNrow()-1) {
if (rowno>=nrow)
throw out_of_range("Error in Matrix: cannot remove the specified row due to out_of_range!");
data.erase(data.begin()+rowno);
--nrow;
}
//删除矩阵中指定一列,默认删除最后一列
void rm_col(int colno=getNcol()-1) {
if (colno>=ncol)
throw out_of_range("Error removing one column: out of range!");
for(auto& r : data) {
r.erase(r.begin()+getNcol()-1);
}
--ncol;
}
//矩阵转置
Matrix invert() const {
Matrix resm(ncol,nrow);
for (int i = 0; i < nrow; ++i) {
for (int j = 0; j < ncol; ++j) {
resm.set(j, i, get(i,j));
}
}
return resm;
}
//矩阵乘法
Matrix multiplies(const Matrix& m) const {
if (m.getNrow() != ncol)
throw invalid_argument("The number of the cols of the 1st matrix should match with that of the rows of the 2nd!");
Matrix res(nrow, m.getNcol());
Matrix invert_m = m.invert();
auto& invert_data = invert_m.getData();
for (int i = 0; i < nrow; ++i) {
for (int j = 0; j < m.getNcol(); ++j) {
T val = inner_product(data.at(i).begin(), data.at(i).end(), invert_data.at(j).begin(), 0);
res.set(i,j, val);
}
}
return res;
}
//最简行形式
void simplest_row_form() {
int non_zero_cnt = 0;
//dbgcout << *this << endl << endl;
for (int i = 0; i < ncol; ++i) { //第i列找一个非零元素,消去其它行该行,使为0
int j = non_zero_cnt; //第j行
for (; j < nrow && !data.at(j).at(i); ++j); //找到第i列第一个非零元素
if (j == nrow) //第i列元素全是0
continue;
for (int k = 0; k < nrow; ++k) {
if (k == j) continue;
T clear_factor = -data.at(k).at(i)/data.at(j).at(i);
//第j列元素乘上clear_factor加到第k行,消元
for (int m = 0; m < ncol; ++m) {
data.at(k).at(m) += data.at(j).at(m)*clear_factor;
}
}
swap(data.at(j), data.at(non_zero_cnt));
non_zero_cnt ++;
//dbgcout << *this << endl << endl;
}
}
//水平粘合矩阵 A|B
friend Matrix mat_union<>(const Matrix& A, const Matrix& B);
};
#endif
|
[
"audition2007@163.com"
] |
audition2007@163.com
|
ca5b07484d29fdcb8b76aa8d053f1c6bac3eed88
|
f0fd2ec4b546cc694b1354afe5b1bb3a39aa6a38
|
/c++ richtofen/el mayor niu c++.cpp
|
3e2aa150243de54f0ec604f6987e8aff742abd41
|
[] |
no_license
|
xXxbYkoNdeLuKanoRxXx/cartagena-de-indias
|
160e74faa4af4b8c1078e65cb6b36252ea25b1d4
|
071078057a77647ded486917c7b3fd1116c5868b
|
refs/heads/master
| 2020-03-28T15:29:46.896922
| 2019-03-26T08:34:38
| 2019-03-26T08:34:38
| 148,600,158
| 0
| 0
| null | null | null | null |
ISO-8859-10
|
C++
| false
| false
| 1,039
|
cpp
|
#include<iostream>
/*Este programa se llama lista array mayor menor*/
using namespace std;
int main(){
float num[10];
int i;
int suma=0;//inicializar a 0 la vaiable acumuladora
int media;
char salir;
float n_numeros;
float mayor,menor;//
cout<< " cuantos nius quieres tocar ";
cin>>n_numeros;
for (i=0;i<n_numeros;i++){
cout<<" dime un mememero ";
cin>> num[i];
}
//ahora voy a enseņar mis mememeros
cout<<" lista de los nius:\n " ;
for(i=0;i<=10;i++){
cout<< num[i];
}
//ahora viene lo shido
//voy comparando el mayor en cada numero
mayor=num[0];
for (i=0;i<n_numeros;i++){
if (num[i]>mayor){
mayor=num[i];
}
}
cout<< "\n el mayor es:" << mayor;
cout<< " toca cualquier niu para salir ";
cin>>salir;
return 0;
}
|
[
"noreply@github.com"
] |
xXxbYkoNdeLuKanoRxXx.noreply@github.com
|
87265d9e48a861115721a3a3f6a7ee8b2db7ec5b
|
b8ce859b04c66d6872c6ffb86d1329b30f8b4f6d
|
/Tempest/ui/controls/uimetrics.h
|
f606edddcc2eca280a1eed54ab41506231255d2a
|
[
"MIT"
] |
permissive
|
enotio/Tempest
|
fc8cca311ae10b1cf7825202296cdbabec373834
|
1a7105cfca3669d54c696ad8188f04f25159c0a0
|
refs/heads/master
| 2023-02-04T11:38:58.829324
| 2020-12-26T12:49:34
| 2020-12-26T12:49:34
| 8,636,507
| 5
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 552
|
h
|
#ifndef UIMETRICS_H
#define UIMETRICS_H
namespace Tempest {
/** \addtogroup GUI
* @{
*/
class UiMetrics {
public:
UiMetrics();
virtual ~UiMetrics() = default;
static int scaledSize(int x);
int buttonWidth = 128;
int buttonHeight = 27;
float uiScale = 1.0;
int smallTextSize = 8;
int normalTextSize = 16;
int largeTextSize = 24;
int scrollButtonSize = 27;
int margin = 8;
};
/** @}*/
}
#endif // UIMETRICS_H
|
[
"try9998@gmail.com"
] |
try9998@gmail.com
|
9a6c8c2afe9883beb67277ebc53ce99ee4150e00
|
49ef0c0170da1312669f3dacdccbd1a8d0d6fb0b
|
/UpdateDownload/Duilib/Layout/UIChildLayout.cpp
|
319d638082657675a7a9a7670a1653feef82a049
|
[] |
no_license
|
e54385991/CZElauncher
|
233f4dc404fe1c7989e0643b1b92b9d3f7e5fdcd
|
0544c8a357d2eb4d33e77cdb7d09d3f33d4ad0a4
|
refs/heads/master
| 2022-12-01T09:31:55.646858
| 2020-08-16T10:53:03
| 2020-08-16T10:53:03
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,430
|
cpp
|
#include "../StdAfx.h"
#include "UIChildLayout.h"
namespace DuiLib
{
IMPLEMENT_DUICONTROL(CChildLayoutUI)
CChildLayoutUI::CChildLayoutUI()
{
}
void CChildLayoutUI::Init()
{
if (!m_pstrXMLFile.IsEmpty())
{
CDialogBuilder builder;
CContainerUI* pChildWindow = static_cast<CContainerUI*>(builder.Create(m_pstrXMLFile.GetData(), (UINT)0, NULL, m_pManager));
if (pChildWindow)
{
this->Add(pChildWindow);
}
else
{
this->RemoveAll();
}
}
}
void CChildLayoutUI::SetAttribute( LPCTSTR pstrName, LPCTSTR pstrValue )
{
if( _tcsicmp(pstrName, _T("xmlfile")) == 0 )
SetChildLayoutXML(pstrValue);
else
CContainerUI::SetAttribute(pstrName,pstrValue);
}
void CChildLayoutUI::SetChildLayoutXML( DuiLib::CDuiString pXML )
{
m_pstrXMLFile=pXML;
}
DuiLib::CDuiString CChildLayoutUI::GetChildLayoutXML()
{
return m_pstrXMLFile;
}
LPVOID CChildLayoutUI::GetInterface( LPCTSTR pstrName )
{
if( _tcsicmp(pstrName, DUI_CTR_CHILDLAYOUT) == 0 ) return static_cast<CChildLayoutUI*>(this);
return CControlUI::GetInterface(pstrName);
}
LPCTSTR CChildLayoutUI::GetClass() const
{
return _T("ChildLayoutUI");
}
} // namespace DuiLib
|
[
"yaas657@qq.com"
] |
yaas657@qq.com
|
247e6b43c326a3eaa66eb7ebf677ecdecba6fc1f
|
d922758e6c9ac51cdbcfe25ff26a114d1635250c
|
/src/functions.h
|
a70b3b75bce19d8f6b536bef889641cd86958023
|
[] |
no_license
|
jeffreyhanson/raptr
|
c7fa50617b080a72f8fe97c9534a664cc02d91b9
|
059a1abc9c2e2f071ce2a7d3596bfd1189441d92
|
refs/heads/master
| 2023-08-31T22:13:12.446845
| 2023-03-14T03:26:50
| 2023-03-14T03:26:50
| 44,244,406
| 5
| 0
| null | 2023-08-21T23:56:38
| 2015-10-14T11:51:44
|
R
|
UTF-8
|
C++
| false
| false
| 2,327
|
h
|
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
#include <Rcpp.h>
using namespace Rcpp;
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <RcppEigen.h>
std::vector<double> calculateConnectivity(
std::vector<std::size_t>&,
std::vector<std::size_t>&,
std::vector<double>&,
IntegerMatrix&
);
// unreliable - best space value
double unreliable_space_value(
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>&
);
// unreliable - space value for a prioritisation with 1 pu
double unreliable_space_value(
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>&,
std::size_t
);
// unreliable - space value for a prioritisation with n pu's
double unreliable_space_value(
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>&,
std::vector<std::size_t>&
);
// reliable - best space value
double reliable_space_value(
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>&,
Rcpp::NumericVector&,
std::size_t
);
// reliable - space value for a prioritisation containing 1 pu
double reliable_space_value(
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>&,
std::size_t,
double,
double
);
// reliable - space value for a prioritisation containing n pu's
double reliable_space_value(
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> &,
std::vector<std::size_t>,
Rcpp::NumericVector&,
std::size_t
);
// power function, templated to use compile-time loop unrolling
template<int P>
inline double Pow(double x) {
return (Pow<P-1>(x) * x);
}
template<>
inline double Pow<1>(double x) {
return (x);
}
template<>
inline double Pow<0>(double x) {
return (1.0);
}
// calculate euclidean distance
double distance(double, double, double, double);
// convert object to string
template<typename T>
inline std::string num2str(T number, int precision=10) {
std::ostringstream ss;
ss << std::fixed << std::setprecision(precision) << number;
return(ss.str());
}
// remove duplicate values in a vector
template<typename T>
void remove_duplicates(std::vector<T> &v) {
v.shrink_to_fit();
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
v.shrink_to_fit();
}
#endif
|
[
"jeffrey.hanson@uqconnect.edu.au"
] |
jeffrey.hanson@uqconnect.edu.au
|
a4834202c867d7e1392f33f9f2c49eea8b41d2ee
|
ddc2551fa7665a63cf26291442ed409e03b5e218
|
/.Sincrono/Report/reportrenderer.cpp
|
5f5b7b6b7b84b1393eb7c6fbde200e4d7b22ede4
|
[] |
no_license
|
kapyderi/recoverdrake-v3
|
41052a7c86e3f25d7cde174e1269e60ed9528164
|
e75375b692d5d7cc7dc224d55cd3c8329d4956b0
|
refs/heads/master
| 2020-06-08T16:26:57.305002
| 2015-02-14T01:34:41
| 2015-02-14T01:34:41
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 71,748
|
cpp
|
#include "reportrenderer.h"
#include "paper.h"
#include <QTime>
#include "section.h"
#include <QDebug>
ReportRenderer::ReportRenderer(QObject *parent) :
QObject(parent)
{
}
QDomDocument ReportRenderer::render(QPrinter* printer ,QDomDocument in ,QMap<QString,QString> queryClausules, QMap<QString,QString> params, bool& error, bool isPrev)
{
QPainter p;
m_doc = preRender(&p,in,queryClausules,params,error,isPrev);
for(int i=0;i<2;i++)
{
QDomNode root = m_doc.firstChild();
QDomNode page = root.firstChild();
while(!page.isNull())
{
if(!page.hasChildNodes())
{
QDomNode _aux = page;
page = page.nextSiblingElement("Page");
root.removeChild(_aux);
}
else
{
QDomNode section = page.firstChild();
while(!section.isNull())
{
if(!section.hasChildNodes())
{
QDomNode _aux = section;
section = section.nextSibling();
page.removeChild(_aux);
}
else
section = section.nextSibling();
}
page = page.nextSiblingElement("Page");
}
}
}
m_doc.firstChild().toElement().setAttribute("pages", m_doc.firstChild().childNodes().size());
QFile f("/usr/share/RecoverDrake/pre.xml");
if(f.open(QFile::WriteOnly))
{
QTextStream out(&f);
const int Indent = 4;
m_doc.save(out,Indent);
}
f.close();
return m_doc;
}
void ReportRenderer::drawElement(qreal dpix, QPainter* painter, QDomElement element, int printResolution, qreal dpiy)
{
if(element.attribute("id")== "RoundRect")
drawRect(element, painter,dpix,dpiy,printResolution);
else if(element.attribute("id")== "Label")
drawLabel(element, painter,dpix,dpiy);
else if(element.attribute("id")== "Line")
drawLine(element, painter,dpix,dpiy,printResolution);
else if(element.attribute("id")== "CodeBar")
drawCodeBar(element, painter,dpix,dpiy);
else if(element.attribute("id")== "Image")
drawImage(element, painter,dpix,dpiy);
}
void ReportRenderer::Print(QPrinter *printer)
{
QDomElement ele = m_doc.documentElement();
QSize margins(printer->paperRect().left() - printer->pageRect().left(), printer->paperRect().top() - printer->pageRect().top());
QPainter painter(printer);
qreal dpix = printer->logicalDpiX() / 96.0;
qreal dpiy = printer->logicalDpiY() / 96.0;
int printResolution = printer->resolution();
painter.translate(margins.width(),margins.height());
double mx = ele.attribute("mx").toDouble();
double my = ele.attribute("my").toDouble();
double usable = ele.attribute("usable").toDouble();
double width = Paper::cmToPx(ele.attribute("w").toDouble()) - ele.attribute("mr").toDouble() - mx;
painter.translate( mx * dpix , my * dpiy);
QDomNodeList pages = ele.childNodes();
for(int i=0;i<pages.size();i++)
{
painter.save();
QDomNodeList sections = pages.at(i).childNodes();
for(int s = 0;s<sections.size();s++)
{
QDomElement cSec = sections.at(s).toElement();
int id = cSec.attribute("id").toDouble();
if(id < 2)
{
QDomNodeList elements = cSec.childNodes();
for(int e = 0;e<elements.size();e++)
{
QDomElement element = elements.at(e).toElement();
drawElement(dpix, &painter, element, printResolution, dpiy);
}
int siz = cSec.attribute("size").toDouble();
painter.translate(0,siz* dpiy);
}
else if(id == 2)
{
QDomNodeList parts = cSec.childNodes();
for(int p=0;p<parts.size();p++)
{
QDomElement cPart = parts.at(p).toElement();
if(cPart.attribute("colored").toDouble())
{
painter.save();
painter.setPen(Qt::NoPen);
painter.setBrush(ColorFromString(cPart.attribute("color")));
painter.drawRect(0,0,width * dpix ,cPart.attribute("size").toDouble() * dpiy);
painter.restore();
}
QDomNodeList elements = cPart.childNodes();
for(int e = 0;e<elements.size();e++)
{
QDomElement element = elements.at(e).toElement();
drawElement(dpix, &painter, element, printResolution, dpiy);
}
int siz = cPart.attribute("size").toDouble();
painter.translate(0,siz* dpiy);
}
}
else
{
if(s==sections.size()-1)
{
int siz = cSec.attribute("size").toDouble();
painter.save();
painter.resetTransform();
painter.translate(margins.width(),margins.height());
painter.translate( mx * dpix , my * dpiy);
int offset = usable - siz;
painter.translate( 0, offset * dpiy);
QDomNodeList elements = cSec.childNodes();
for(int e = 0;e<elements.size();e++)
{
QDomElement element = elements.at(e).toElement();
drawElement(dpix, &painter, element, printResolution, dpiy);
}
painter.restore();
}
else
{
int siz = cSec.attribute("size").toDouble();
int sizNext = sections.at(s+1).toElement().attribute("size").toDouble();
painter.save();
painter.resetTransform();
painter.translate(margins.width(),margins.height());
painter.translate( mx * dpix , my * dpiy);
int offset = usable - siz - sizNext;
painter.translate( 0, offset * dpiy);
QDomNodeList elements = cSec.childNodes();
for(int e = 0;e<elements.size();e++)
{
QDomElement element = elements.at(e).toElement();
drawElement(dpix, &painter, element, printResolution, dpiy);
}
painter.restore();
painter.translate(0,siz* dpiy);
}
}
}
painter.restore();
if(i!=pages.size()-1)
printer->newPage();
}
}
void ReportRenderer::PreRender()
{
bool error;
_params[":fecha"] = "Fecha: " + QDate::currentDate().toString("dd-MM-yyyy");
_params[":hora"] = "Hora: " +QDateTime::currentDateTime().toString("hh:mm:ss");
render( printer ,DocIn , queryClausules, _params, error, _limit);
emit end();
}
QDomDocument ReportRenderer::preRender(QPainter* painter ,QDomDocument in,QMap<QString,QString> queryClausules, QMap<QString,QString> params, bool &error, bool isPrev)
{
QTime t;
t.start();
QDomElement Inroot = in.documentElement();
if (Inroot.tagName() != "RDReports")
{
error = true;
return QDomDocument();
}
QDomDocument doc;
QDomElement root = doc.createElement("Document");
doc.appendChild(root);
bool haveRHeader = false;
bool havePHeader = false;
bool PHeaderOnAll = false;
bool PFooterOnAll = false;
bool havePFooter = false;
bool haveRFooter = false;
int RHeaderSiz = 0;
int PHeaderSiz = 0;
int PFooterSiz = 0;
int RFooterSiz = 0;
QDomNode RHeaderElement;
QDomNode PHeaderElement;
QDomNode PFootElement;
QDomNode RFootElement;
QList<QDomNode> SectionNodes;
QStringList querys;
double usable = 0;
QDomNode child = Inroot.firstChild();
QDomElement _aux = child.toElement();
QMap<QString,float> _paper_acums;
QStringList acums = _aux.attribute("acum").split(",");
foreach (QString s, acums)
{
_paper_acums[s] = 0.0;
}
while (!child.isNull())
{
QDomNode sections = child.firstChild();
while (!sections.isNull())
{
QDomElement secEle = sections.toElement();
if(secEle.tagName() == "Size")
{
usable = Paper::cmToPx(secEle.attribute("h").toDouble());
root.setAttribute("h",secEle.attribute("h"));
root.setAttribute("w",secEle.attribute("w"));
}
else if(secEle.tagName() == "Margin")
{
usable -= Paper::cmToPx(secEle.attribute("top").toDouble());
usable -= Paper::cmToPx(secEle.attribute("bottom").toDouble());
root.setAttribute("my",QString::number(Paper::cmToPx(secEle.attribute("top").toDouble()), 'f', 2));
root.setAttribute("mx",QString::number(Paper::cmToPx(secEle.attribute("left").toDouble()), 'f', 2));
root.setAttribute("usable",QString::number(usable, 'f', 2));
root.setAttribute("mr",QString::number(Paper::cmToPx(secEle.attribute("left").toDouble()), 'f', 2));
}
else if(secEle.tagName() == "Section")
{
Section::SectionType t = static_cast<Section::SectionType>(secEle.attribute("id").toDouble());
switch (t) {
case Section::ReportHeader:
haveRHeader = true;
RHeaderSiz = secEle.attribute("size").toDouble();
RHeaderElement = sections.cloneNode(true);
break;
case Section::PageHeader:
havePHeader = true;
PHeaderSiz = secEle.attribute("size").toDouble();
PHeaderOnAll = secEle.attribute("OnFistPage").toDouble();
PHeaderElement = sections.cloneNode(true);
break;
case Section::Detail:
SectionNodes.append(sections.cloneNode(true));
break;
case Section::PageFooter:
havePFooter = true;
PFooterSiz = secEle.attribute("size").toDouble();
PFooterOnAll= secEle.attribute("OnFistPage").toDouble();
PFootElement = sections.cloneNode(true);
break;
case Section::ReportFooter:
haveRFooter = true;
RFooterSiz = secEle.attribute("size").toDouble();
RFootElement = sections.cloneNode(true);
break;
}
}
else if(secEle.tagName() == "SQL")
{
querys << secEle.attribute("target");
}
sections = sections.nextSibling();
}
child = child.nextSibling();
}
QList<QPair<QString,QString> > finalQuerys;
QStringListIterator it(querys);
while (it.hasNext()) {
QPair<QString,QString> aux = getSql(it.next(),queryClausules,isPrev);
if(!aux.first.isEmpty())
finalQuerys.append(aux);
}
QListIterator<QPair<QString,QString> > qIt(finalQuerys);
QMap<QString,QSqlRecord> selects;
while(qIt.hasNext())
{
QPair<QString,QString> pair = qIt.next();
QSqlDatabase db;
db = QSqlDatabase::database("PRINCIPAL");
QSqlQuery q(db);
if(q.exec(pair.second))
if(q.next())
selects.insert(pair.first,q.record());
}
QListIterator<QDomNode> sectionIt(SectionNodes);
QList<QDomNode> parsedSections;
while(sectionIt.hasNext())
{
QDomNode n = sectionIt.next();
QDomElement ele = n.toElement();
QDomNodeList l = ele.childNodes();
for(int i=0 ; i< l.size(); i++)
{
QDomElement _e = l.at(i).toElement();
if(_e.attribute("id")== "Param")
{
QString value = params.value(_e.attribute("Arg"));
_e.setAttribute("id","Label");
_e.setAttribute("Text",value);
}
}
bool iSql = ele.attribute("haveSqlInterno").toDouble();
QString cla = ele.attribute("ClausulaInterna");
QStringList lCla = cla.split("=");
QString columna = "";
QString bindKey = "";
QString clausulaInterna = "";
if(lCla.size()==2)
{
columna = lCla.at(1);
clausulaInterna = QString("%1=:%2").arg(lCla.at(0)).arg(lCla.at(1));
bindKey = QString(":%1").arg(lCla.at(1));
}
QPair<QString,QString> gSql = getSql(ele.attribute("SqlGlobal"),queryClausules,isPrev);
QString first = gSql.first;
QSqlDatabase db;
db = QSqlDatabase::database("PRINCIPAL");
QSqlQuery gQuery(db);
if(gQuery.exec(gSql.second))
{
while(gQuery.next())
{
QStringList i_acums_list = ele.attribute("acum").split(",");
QMap<QString,float> _i_acums;
foreach (QString _a, i_acums_list)
{
_i_acums[_a]=0.0;
}
QSqlRecord record = gQuery.record();
QDomNode exit = doc.createElement("section");
bool appenExit = true;
QDomNode copy = n.cloneNode(true);
QDomNode sectionPart = copy.firstChild();
while(!sectionPart.isNull())
{
QDomNode next = sectionPart.nextSibling();
QDomElement secEle = sectionPart.toElement();
if(secEle.tagName() == "Header")
{
QDomNode child = sectionPart.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(ele.attribute("id")=="Field")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
text = applyFormato(record.value(value.at(2)).toString(),formato);
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="RelationalField")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("value").split(".");
if(value.size()>1)
{
QString key = value.at(0) + "." + value.at(1);
text = applyFormato(getRelationField(ele.attribute("Sql"),selects.value(key)),formato);
}
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="CodeBar")
{
QString text = "";
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
text = record.value(value.at(2)).toString();
ele.setAttribute("Code",text);
}
else if(ele.attribute("id")=="Image")
{
QByteArray b;
QStringList value = ele.attribute("Path").split(".");
if(value.size()== 3)
b = record.value(value.at(2)).toByteArray();
ele.setAttribute("img-data",QString(b));
}
child = child.nextSibling();
}
exit.appendChild(sectionPart);
}
else if (secEle.tagName() == "Body")
{
if(iSql)
{
QString c1 = ele.attribute("color1");
QString c2 = ele.attribute("color2");
bool colored = ele.attribute("colored").toDouble();
bool altern = ele.attribute("alternative").toDouble();
bool toogle = true;
QString iSql = ele.attribute("SqlInterno");
QSqlDatabase db;
db = QSqlDatabase::database("PRINCIPAL");
QString query = QString("SELECT * FROM %1 WHERE %2").arg(iSql.split(".").at(1)).arg(clausulaInterna);
QSqlQuery iQuery(db);
iQuery.prepare(query);
iQuery.bindValue(bindKey,record.value(columna));
if(iQuery.exec())
{
if(iQuery.next())
{
do
{
QSqlRecord iRecord = iQuery.record();
QDomNode iCopy = sectionPart.cloneNode(true);
QDomElement iCopyEle = iCopy.toElement();
iCopyEle.setAttribute("colored",colored);
if(toogle)
{
iCopyEle.setAttribute("color",c1);
if(altern)
toogle = false;
}
else
{
iCopyEle.setAttribute("color",c2);
toogle = true;
}
QDomNode child = iCopy.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(ele.attribute("id")=="Field")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
text = applyFormato(iRecord.value(value.at(2)).toString(),formato);
ele.setAttribute("Text",text);
if(ele.attribute("Expandable") == "1")
{
double h = ele.attribute("h").toDouble();
double siz = iCopy.toElement().attribute("size").toDouble();
QRectF r(0,0,ele.attribute("w").toDouble(),h);
QRectF r2(painter->fontMetrics().boundingRect(r.toRect(),Qt::TextWordWrap,text));
double diff = r2.height() - h;
iCopy.toElement().setAttribute("size",siz+diff+10);
ele.setAttribute("h",r2.height()+10);
}
if(_i_acums.contains(ele.attribute("name")))
_i_acums[ele.attribute("name")]+= iRecord.value(value.at(2)).toDouble();
}
else if(ele.attribute("id")=="RelationalField")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
text = applyFormato(getRelationField(ele.attribute("Sql"),record),formato);
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="CodeBar")
{
QString text = "";
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
text = record.value(value.at(2)).toString();
ele.setAttribute("value",text);
}
else if(ele.attribute("id")=="Image")
{
QByteArray b;
QStringList value = ele.attribute("Path").split(".");
if(value.size()== 3)
b = record.value(value.at(2)).toByteArray();
ele.setAttribute("img-data",QString(b));
}
child = child.nextSibling();
}
exit.appendChild(iCopy);
}while(iQuery.next());
}
else
{
appenExit = false;
}
}
}
else
{
QDomNode child = sectionPart.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(ele.attribute("id")=="Field")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
text = applyFormato(record.value(value.at(2)).toString(),formato);
ele.setAttribute("Text",text);
if(ele.attribute("Expandable") == "1")
{
double h = ele.attribute("h").toDouble();
double siz = sectionPart.toElement().attribute("size").toDouble();
QRectF r(0,0,ele.attribute("w").toDouble()-10,h);
QRectF r2(painter->fontMetrics().boundingRect(r.toRect(),Qt::TextWordWrap,text));
double diff = r2.height() - h;
sectionPart.toElement().setAttribute("size",siz+diff+painter->fontMetrics().height());
ele.setAttribute("h",r2.height()+painter->fontMetrics().height());
}
}
else if(ele.attribute("id")=="RelationalField")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
text = applyFormato(getRelationField(ele.attribute("Sql"),record),formato);
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="CodeBar")
{
QString text = "";
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
text = record.value(value.at(2)).toString();
ele.setAttribute("Code",text);
}
else if(ele.attribute("id")=="Image")
{
QByteArray b;
QStringList value = ele.attribute("Path").split(".");
if(value.size()== 3)
b = record.value(value.at(2)).toByteArray();
ele.setAttribute("img-data",QString(b));
}
child = child.nextSibling();
}
exit.appendChild(sectionPart);
}
}
else
{
QDomNode child = sectionPart.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(ele.attribute("id")=="Field")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
text = applyFormato(record.value(value.at(2)).toString(),formato);
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="RelationalField")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
text = applyFormato(getRelationField(ele.attribute("Sql"),record),formato);
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="CodeBar")
{
QString text = "";
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
text = record.value(value.at(2)).toString();
ele.setAttribute("Code",text);
}
else if(ele.attribute("id")=="Image")
{
QByteArray b;
QStringList value = ele.attribute("Path").split(".");
if(value.size()== 3)
b = record.value(value.at(2)).toByteArray();
ele.setAttribute("img-data",QString(b));
}
if(ele.attribute("id")=="Acumulador")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
text = applyFormato(QString::number(_i_acums.value(ele.attribute("target")),'f',2),formato);
ele.setAttribute("Text",text);
}
child = child.nextSibling();
}
exit.appendChild(sectionPart);
}
sectionPart = next;
}
if(appenExit)
parsedSections.append(exit);
}
}
}
if(haveRHeader)
{
QDomNodeList l = RHeaderElement.childNodes();
for(int i=0 ; i< l.size(); i++)
{
QDomElement _e = l.at(i).toElement();
if(_e.attribute("id")== "Param")
{
QString value = params.value(_e.attribute("Arg"));
_e.setAttribute("id","Label");
_e.setAttribute("Text",value);
}
}
}
if(havePHeader)
{
QDomNodeList l = PHeaderElement.childNodes();
for(int i=0 ; i< l.size(); i++)
{
QDomElement _e = l.at(i).toElement();
if(_e.attribute("id")== "Param")
{
QString value = params.value(_e.attribute("Arg"));
_e.setAttribute("id","Label");
_e.setAttribute("Text",value);
}
}
}
if(havePFooter)
{
QDomNodeList l = PFootElement.childNodes();
for(int i=0 ; i< l.size(); i++)
{
QDomElement _e = l.at(i).toElement();
if(_e.attribute("id")== "Param")
{
QString value = params.value(_e.attribute("Arg"));
_e.setAttribute("id","Label");
_e.setAttribute("Text",value);
}
}
}
if(haveRFooter)
{
QDomNodeList l = RFootElement.childNodes();
for(int i=0 ; i< l.size(); i++)
{
QDomElement _e = l.at(i).toElement();
if(_e.attribute("id")== "Param")
{
QString value = params.value(_e.attribute("Arg"));
_e.setAttribute("id","Label");
_e.setAttribute("Text",value);
}
}
}
QDomNode pageNode = startPage(usable,PFooterSiz, RHeaderSiz ,RFooterSiz,doc,havePHeader&&PHeaderOnAll,PHeaderElement,selects,haveRHeader,RHeaderElement);
parseFooters(RFootElement , haveRFooter , PFootElement , havePFooter , selects);
root.appendChild(pageNode);
int ipageCount = 1;
int pageUsable = usable;
if(havePHeader&&PHeaderOnAll)
pageUsable -= PHeaderSiz;
if(haveRHeader)
pageUsable -= RHeaderSiz;
QListIterator<QDomNode> parsedIt(parsedSections);
while(parsedIt.hasNext())
{
QDomNode sec = doc.createElement("Section");
sec.toElement().setAttribute("id",2);
pageNode.appendChild(sec);
QDomNode n = parsedIt.next();
QDomNode child = n.firstChild();
QDomNode lastChild = n.lastChild();
QDomNode sectionHeader;
QDomNode sectionFoot;
bool haveHead = false;
bool haveFoot = false;
int headSiz = 0;
int footSiz = 0;
if(child.toElement().tagName() == "Header")
{
haveHead = true;
sectionHeader = child;
headSiz = child.toElement().attribute("size").toDouble();
sec.appendChild(sectionHeader.cloneNode(true));
pageUsable -= headSiz;
}
if(lastChild.toElement().tagName() == "Foot")
{
haveFoot = true;
footSiz = lastChild.toElement().attribute("size").toDouble();
sectionFoot = lastChild;
}
QList<QDomNode> bodys;
QDomNodeList l = n.childNodes();
for(int i = 0;i< l.size(); i++)
{
if(haveFoot && i == l.size()-1)
continue;
bodys.append(l.at(i));
}
QListIterator<QDomNode> bodyIt(bodys);
while (bodyIt.hasNext())
{
QDomNode body = bodyIt.next();
QDomElement bEle = body.toElement();
if(bEle.tagName() == "Body")
{
if(parsedIt.hasNext())
{
if(pageUsable > bEle.attribute("size").toDouble() + footSiz + PFooterSiz)
{
pageUsable -= bEle.attribute("size").toDouble();
sec.appendChild(body);
QDomNode child = body.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(_paper_acums.contains(ele.attribute("name")))
{
QString sValue = ele.attribute("Text");
_paper_acums[ele.attribute("name")] += getNumber(sValue,ele.attribute("formato").toInt());
}
child = child.nextSibling();
}
if(!bodyIt.hasNext())
{
if(haveFoot)
{
sec.appendChild(sectionFoot);
pageUsable -= footSiz;
}
}
}
else
{
if(havePFooter)
endPage(pageNode,PFootElement.cloneNode(true),_paper_acums);
pageNode = startPage(usable,PFooterSiz, RHeaderSiz,RFooterSiz,doc,havePHeader,PHeaderElement,selects);
ipageCount++;
root.appendChild(pageNode);
pageUsable = usable;
if(havePHeader)
pageUsable -= PHeaderSiz;
sec = doc.createElement("Section");
sec.toElement().setAttribute("id",2);
pageNode.appendChild(sec);
if(haveHead)
{
sec.appendChild(sectionHeader.cloneNode(true));
pageUsable -= headSiz;
}
pageUsable -= bEle.attribute("size").toDouble();
sec.appendChild(body);
QDomNode child = body.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(_paper_acums.contains(ele.attribute("name")))
{
QString sValue = ele.attribute("Text");
_paper_acums[ele.attribute("name")] += getNumber(sValue,ele.attribute("formato").toInt());
}
child = child.nextSibling();
}
if(!bodyIt.hasNext())
{
if(haveFoot)
{
sec.appendChild(sectionFoot);
pageUsable -= footSiz;
}
}
}
}
else
{
if(bodyIt.hasNext())
{
if(pageUsable > bEle.attribute("size").toDouble() + footSiz + PFooterSiz)
{
pageUsable -= bEle.attribute("size").toDouble();
sec.appendChild(body);
QDomNode child = body.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(_paper_acums.contains(ele.attribute("name")))
{
QString sValue = ele.attribute("Text");
_paper_acums[ele.attribute("name")] += getNumber(sValue,ele.attribute("formato").toInt());
}
child = child.nextSibling();
}
}
else
{
if(havePFooter)
endPage(pageNode,PFootElement.cloneNode(true),_paper_acums);
pageNode = startPage(usable,PFooterSiz, RHeaderSiz,RFooterSiz,doc,havePHeader,PHeaderElement,selects);
ipageCount++;
root.appendChild(pageNode);
pageUsable = usable;
if(havePHeader)
pageUsable -= PHeaderSiz;
sec = doc.createElement("Section");
sec.toElement().setAttribute("id",2);
pageNode.appendChild(sec);
if(haveHead)
{
sec.appendChild(sectionHeader.cloneNode(true));
pageUsable -= headSiz;
}
pageUsable -= bEle.attribute("size").toDouble();
sec.appendChild(body);
QDomNode child = body.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(_paper_acums.contains(ele.attribute("name")))
{
QString sValue = ele.attribute("Text");
_paper_acums[ele.attribute("name")] += getNumber(sValue,ele.attribute("formato").toInt());
}
child = child.nextSibling();
}
}
}
else
{
int needed = bEle.attribute("size").toDouble() + footSiz + RFooterSiz;
if(PFooterOnAll)
needed += PFooterSiz;
if(pageUsable > needed)
{
pageUsable -= bEle.attribute("size").toDouble();
sec.appendChild(body);
QDomNode child = body.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(_paper_acums.contains(ele.attribute("name")))
{
QString sValue = ele.attribute("Text");
_paper_acums[ele.attribute("name")] += getNumber(sValue,ele.attribute("formato").toInt());
}
child = child.nextSibling();
}
if(!bodyIt.hasNext())//last body of section & report
{
if(haveFoot)
{
sec.appendChild(sectionFoot);
pageUsable -= footSiz;
}
}
if(!bodyIt.hasNext())
{
if(haveFoot)
{
sec.appendChild(sectionFoot);
pageUsable -= footSiz;
}
}
}
else
{
if(havePFooter)
endPage(pageNode,PFootElement.cloneNode(true),_paper_acums);
pageNode = startPage(usable,PFooterSiz, RHeaderSiz,RFooterSiz,doc,havePHeader,PHeaderElement,selects);
ipageCount++;
root.appendChild(pageNode);
pageUsable = usable;
if(havePHeader)
pageUsable -= PHeaderSiz;
sec = doc.createElement("Section");
sec.toElement().setAttribute("id",2);
pageNode.appendChild(sec);
if(haveHead)
{
sec.appendChild(sectionHeader.cloneNode(true));
pageUsable -= headSiz;
}
pageUsable -= bEle.attribute("size").toDouble();
sec.appendChild(body);
QDomNode child = body.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(_paper_acums.contains(ele.attribute("name")))
{
QString sValue = ele.attribute("Text");
_paper_acums[ele.attribute("name")] += getNumber(sValue,ele.attribute("formato").toInt());
}
child = child.nextSibling();
}
if(!bodyIt.hasNext())
{
if(haveFoot)
{
sec.appendChild(sectionFoot);
pageUsable -= footSiz;
}
}
}
}
}
}
}
}
if(havePFooter && PFooterOnAll)
endPage(pageNode,PFootElement.cloneNode(true),_paper_acums);
if(haveRFooter)
{
pageNode.appendChild(RFootElement);
QDomNode sec = pageNode.firstChild();
for(int i= 0; i<2; i++)
{
if(sec.toElement().attribute("id").toDouble() == 0 || sec.toElement().attribute("id").toDouble() == 1)
{
QDomNode ele = sec.firstChild();
while(!ele.isNull())
{
if(ele.toElement().attribute("id") == "Line")
if(ele.toElement().attribute("endPointName")!= "Self")
if(ele.toElement().attribute("endPointName")!= "Pie de report")
ele.toElement().setAttribute("h",ele.toElement().attribute("h").toDouble()-RFooterSiz);
if(ele.toElement().attribute("id") == "RoundRect")
if(ele.toElement().attribute("endPointName")!= "Self")
if(ele.toElement().attribute("endPointName")!= "Pie de report")
ele.toElement().setAttribute("h",ele.toElement().attribute("h").toDouble()-RFooterSiz);
ele = ele.nextSibling();
}
}
sec = sec.nextSibling();
}
QDomNode child = RFootElement.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(ele.attribute("id")=="Acumulador")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
text = applyFormato(QString::number(_paper_acums.value(ele.attribute("target")),'f',2),formato);
ele.setAttribute("Text",text);
}
child = child.nextSibling();
}
}
root.setAttribute("pages",ipageCount);
return doc;
}
bool ReportRenderer::limit() const
{
return _limit;
}
void ReportRenderer::setLimit(bool limit)
{
_limit = limit;
}
QMap<QString, QString> ReportRenderer::params() const
{
return _params;
}
void ReportRenderer::setParams(const QMap<QString, QString> ¶ms)
{
_params = params;
}
void ReportRenderer::drawRect(QDomElement e, QPainter *painter, double dpiX, double dpiY, int printResolution)
{
painter->save();
QPointF pos;
pos.setX(e.attribute("x").toDouble() * dpiX);
pos.setY(e.attribute("y").toDouble() * dpiY);
QSize siz;
siz.setWidth(e.attribute("w").toDouble()* dpiX);
siz.setHeight(e.attribute("h").toDouble()* dpiY);
QColor penColor = ColorFromString(e.attribute("PenColor"));
int penW = e.attribute("PenWidth").toDouble();
QColor color1 , color2;
color1 = ColorFromString(e.attribute("Color1"));
color2 = ColorFromString(e.attribute("Color2"));
double r1, r2;
r1 = e.attribute("RadiousX").toDouble();
r2 = e.attribute("RadiousY").toDouble();
bool vGrad , gUsed;
gUsed = e.attribute("GradientUsed").toDouble();
vGrad = e.attribute("GradientDirection") == "V";
painter->setRenderHints(QPainter::Antialiasing);
QPen pen(painter->pen());
pen.setWidthF((penW / 100) * printResolution);
pen.setColor(penColor);
painter->setPen(pen);
painter->translate(pos);
QRectF r(QPointF(0,0),siz);
if(gUsed)
{
if(vGrad)
{
QLinearGradient Gradient(r.width()/2,0,r.width()/2,r.height());
Gradient.setColorAt(0,color1);
Gradient.setColorAt(1,color2);
painter->setBrush(QBrush(Gradient));
}
else
{
QLinearGradient Gradient(0,r.height()/2,r.width(),r.height()/2);
Gradient.setColorAt(0,color1);
Gradient.setColorAt(1,color2);
painter->setBrush(QBrush(Gradient));
}
}
else
{
painter->setBrush(QBrush(color1));
}
QRectF rr(penW/2.0,
penW/2.0,
r.width()- penW,
r.height()- penW);
painter->drawRoundedRect(rr,r1,r2);
painter->restore();
}
void ReportRenderer::drawLabel(QDomElement e, QPainter *painter, double dpiX, double dpiY)
{
QString m_Text = e.attribute("Text");
_Orientacion m_Orientacion = e.attribute("Orientacion") == "V" ? Vertical : Horizontal;
_Aling m_Alineacion = e.attribute("Alineacion") == "L" ? Left :
e.attribute("Alineacion") == "R" ? Rigth:
Center;
QString m_fontFamily = e.attribute("fontFamily");
int m_fontSize = e.attribute("fontSize").toDouble();
int m_fontWeigth = e.attribute("fontWeigth").toDouble();
bool m_italicFont = e.attribute("italicFont").toDouble();
QColor m_fontColor = ColorFromString(e.attribute("color"));
bool m_underlined = e.attribute("underlined").toDouble();
QPointF pos;
pos.setX(e.attribute("x").toDouble() * dpiX);
pos.setY(e.attribute("y").toDouble() * dpiY);
QSize siz;
siz.setWidth(e.attribute("w").toDouble()* dpiX +10);
siz.setHeight(e.attribute("h").toDouble()* dpiY+10);
painter->save();
painter->translate(pos);
QRectF r(QPointF(0,0),siz);
QFont f(m_fontFamily,m_fontSize);
f.setUnderline(m_underlined);
f.setWeight(m_fontWeigth);
f.setItalic(m_italicFont);
painter->setPen(m_fontColor);
painter->setFont(f);
if(m_Orientacion == Vertical)
{
painter->translate(r.bottomLeft());
painter->rotate(270);
switch (m_Alineacion) {
case Center:
painter->drawText(r,Qt::TextWordWrap|Qt::AlignCenter,m_Text);
break;
case Rigth:
painter->drawText(r,Qt::TextWordWrap|Qt::AlignRight,m_Text);
break;
default:
painter->drawText(r,Qt::TextWordWrap|Qt::AlignLeft,m_Text);
break;
}
}
else
{
switch (m_Alineacion) {
case Center:
painter->drawText(r,Qt::TextWordWrap|Qt::AlignCenter,m_Text);
break;
case Rigth:
painter->drawText(r,Qt::TextWordWrap|Qt::AlignRight,m_Text);
break;
default:
painter->drawText(r,Qt::TextWordWrap|Qt::AlignLeft,m_Text);
break;
}
}
painter->restore();
}
void ReportRenderer::drawLine(QDomElement e, QPainter *painter, double dpiX, double dpiY, int printResolution)
{
int m_penWidth = e.attribute("penWidth").toDouble();
QColor m_penColor = ColorFromString(e.attribute("penColor"));
_Orientacion m_Orientacion = e.attribute("Orientacion") == "V" ? Vertical : Horizontal;
Qt::PenStyle m_penStyle = static_cast<Qt::PenStyle>(e.attribute("penStyle").toDouble());
QPointF pos;
pos.setX(e.attribute("x").toDouble() * dpiX);
pos.setY(e.attribute("y").toDouble() * dpiY);
QSize siz;
siz.setWidth(e.attribute("w").toDouble()* dpiX);
siz.setHeight(e.attribute("h").toDouble()* dpiY);
painter->save();
painter->translate(pos);
QRectF r(QPointF(0,0),siz);
QPen pen;
pen.setWidthF((m_penWidth / 100) * printResolution);
pen.setStyle(m_penStyle);
pen.setColor(m_penColor);
painter->setPen(pen);
if(m_Orientacion == Horizontal)
painter->drawLine(0,r.height()/2,r.width(),r.height()/2);
else
painter->drawLine(r.width()/2,0,r.width()/2,r.height());
painter->restore();
}
void ReportRenderer::drawImage(QDomElement e, QPainter *painter, double dpiX, double dpiY)
{
QString m_ruta = e.attribute("Path");
bool m_fromDB = e.attribute("fromBD").toDouble();
QImage m_image;
bool m_dinamica = e.attribute("Dinamic").toDouble();
QPointF pos;
pos.setX(e.attribute("x").toDouble() * dpiX);
pos.setY(e.attribute("y").toDouble() * dpiY);
QSize siz;
siz.setWidth(e.attribute("w").toDouble()* dpiX +10);
siz.setHeight(e.attribute("h").toDouble()* dpiY);
if(m_fromDB)
{
//FALTA ESTA PARTE
}
else
{
QFile f(m_ruta);
if(f.open(QFile::ReadOnly))
m_image = QImage(m_ruta);
}
painter->save();
painter->translate(pos);
QRectF r(QPointF(0,0),siz);
painter->drawImage(r,m_image);
painter->restore();
}
void ReportRenderer::drawCodeBar(QDomElement e, QPainter *painter, double dpiX, double dpiY)
{
QString m_code = e.attribute("Code");
bool m_visibleCode = e.attribute("visibleCode").toDouble();
QPointF pos;
pos.setX(e.attribute("x").toDouble() * dpiX);
pos.setY(e.attribute("y").toDouble() * dpiY);
QSizeF siz;
siz.setWidth(e.attribute("w").toDouble()* dpiX +10);
siz.setHeight(e.attribute("h").toDouble()* dpiY+10);
int codeSize = (e.attribute("codeSize").toInt());
int barSize = (e.attribute("barSize").toInt());
bool vertical = (e.attribute("vertical").toInt());
painter->save();
painter->translate(pos);
QFont f1 = QFont(painter->font().family(),codeSize);
QFont f("Free 3 of 9 Extended",barSize);
painter->setFont(f);
if(vertical)
{
QRectF _r(QPointF(0,0),siz);
QRectF r(0,0,siz.height(),siz.width()+codeSize*dpiX);
painter->translate(_r.bottomLeft());
painter->rotate(270);
painter->drawText(r,Qt::TextWordWrap|Qt::AlignCenter,m_code);
if(m_visibleCode)
{
painter->setFont(f1);
painter->drawText(r,Qt::AlignBottom|Qt::AlignCenter|Qt::TextJustificationForced,m_code);
}
}
else
{
QRectF r(QPointF(0,0),siz);
painter->drawText(r,Qt::AlignTop|Qt::AlignHCenter,m_code);
if(m_visibleCode)
{
painter->setFont(f1);
painter->drawText(r,Qt::AlignBottom|Qt::AlignCenter|Qt::TextJustificationForced,m_code);
}
}
painter->restore();
}
QPair<QString,QString> ReportRenderer::getSql(QString s, QMap<QString, QString> queryClausules, bool prev)
{
QStringList l = s.split(".");
if(l.size()==2)
{
QString second = l.at(1);
QString clausula = queryClausules.value(s);
QString final;
QTextStream t(&final);
t << "SELECT * FROM " << second;
if(!clausula.isEmpty())
t << " WHERE " << clausula;
if(prev)
t << " limit 100";
t<<";";
QPair<QString,QString> p;
p.first = s;
p.second= final;
return p;
}
else if(l.size()>2)
{
QStringList split = s.split("=");
if(split.size()==2)
{
QStringList l2 = split.at(0).split(".");
QString out = QString("%1.%2").arg(l2.at(0)).arg(l2.at(1));
return getSql(out , queryClausules, prev);
}
}
return QPair<QString,QString>(QString(),QString());
}
QString ReportRenderer::getRelationField(QString s , QSqlRecord r)
{
QStringList split = s.split("=");
if(split.size()==2)
{
QString value = r.value(split.at(0).split(".").at(2)).toString();
QStringList to = split.at(1).split("->");
QString key = to.at(0);
QString final;
QStringList l = key.split(".");
if(l.size()==3)
{
QString second = l.at(1);
QTextStream t(&final);
t << "SELECT * FROM " << second;
t << " WHERE " << l.at(2) << "=" << "'" << value << "'";
t<<";";
}
QSqlDatabase db;
db = QSqlDatabase::database("PRINCIPAL");
QSqlQuery q(db);
if(q.exec(final))
if(q.next())
return q.record().value(to.at(1)).toString();
}
return "";
}
QDomNode ReportRenderer::startPage(double pageUsable, int PFooterSiz, int RHSiz,int RFootSiz, QDomDocument doc, bool pageHeader, QDomNode pHeaderNode, QMap<QString, QSqlRecord> selects, bool reporHeader, QDomNode rHeaderNode)
{
QDomNode toRet = doc.createElement("Page");
if(reporHeader)
{
QDomNode child = rHeaderNode.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(ele.attribute("id")=="Field")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
{
QString key = value.at(0) + "." + value.at(1);
text = applyFormato(selects.value(key).value(value.at(2)).toString(),formato);
}
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="RelationalField")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()>1)
{
QString key = value.at(0) + "." + value.at(1);
text = applyFormato(getRelationField(ele.attribute("value"),selects.value(key)),formato);
}
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="CodeBar")
{
QString text = "";
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
{
QString key = value.at(0) + "." + value.at(1);
text = selects.value(key).value(value.at(2)).toString();
}
ele.setAttribute("Code",text);
}
else if(ele.attribute("id")=="Line")
{
bool globlaLine = ele.attribute("endPointName") != "Self";
if(globlaLine)
{
double footStart = pageUsable;
if(ele.attribute("endPointName") == "Pie de pagina")
footStart-= PFooterSiz;
else if(ele.attribute("endPointName") == "Pie de report")
footStart-= RFootSiz;
double LineEnd = footStart + ele.attribute("endPointPoint").toDouble();
double LineStart = ele.attribute("y").toDouble();
ele.setAttribute("h",LineEnd - LineStart);
}
}
else if(ele.attribute("id")=="RoundRect")
{
bool globlaLine = ele.attribute("endPointName") != "Self";
if(globlaLine)
{
double footStart = pageUsable;
if(ele.attribute("endPointName") == "Pie de pagina")
footStart-= PFooterSiz;
else if(ele.attribute("endPointName") == "Pie de report")
footStart-= RFootSiz;
double LineEnd = footStart + ele.attribute("endPointPoint").toDouble();
double LineStart = ele.attribute("y").toDouble();
ele.setAttribute("h",LineEnd - LineStart);
}
}
child = child.nextSibling();
}
toRet.appendChild(rHeaderNode);
}
if(pageHeader)
{
QDomNode node = pHeaderNode.cloneNode(true);
QDomNode child = node.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(ele.attribute("id")=="Field")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
{
QString key = value.at(0) + "." + value.at(1);
text = applyFormato(selects.value(key).value(value.at(2)).toString(),formato);
}
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="RelationalField")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()>1)
{
QString key = value.at(0) + "." + value.at(1);
text = applyFormato(getRelationField(ele.attribute("value"),selects.value(key)),formato);
}
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="CodeBar")
{
QString text = "";
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
{
QString key = value.at(0) + "." + value.at(1);
text = selects.value(key).value(value.at(2)).toString();
}
ele.setAttribute("Code",text);
}
else if(ele.attribute("id")=="Line")
{
bool globlaLine = ele.attribute("endPointName") != "Self";
if(globlaLine)
{
double footStart = pageUsable - PFooterSiz;
double LineEnd = footStart + ele.attribute("endPointPoint").toDouble();
double LineStart = ele.attribute("y").toDouble();
if(reporHeader)
LineStart+= RHSiz;
ele.setAttribute("h",LineEnd - LineStart);
}
}
else if(ele.attribute("id")=="RoundRect")
{
bool globlaLine = ele.attribute("endPointName") != "Self";
if(globlaLine)
{
double footStart = pageUsable - PFooterSiz;
double LineEnd = footStart + ele.attribute("endPointPoint").toDouble();
double LineStart = ele.attribute("y").toDouble();
ele.setAttribute("h",LineEnd - LineStart);
}
}
child = child.nextSibling();
}
toRet.appendChild(node);
}
doc.appendChild(toRet);
return toRet;
}
QDomNode ReportRenderer::endPage(QDomNode pageNode, QDomNode footerNode , QMap<QString, float> _Acums)
{
QDomNode n = footerNode.cloneNode(true);
pageNode.appendChild(n);
QDomNode child = n.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(ele.attribute("id")=="Acumulador")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
text = applyFormato(QString::number(_Acums.value(ele.attribute("target")),'f',2),formato);
ele.setAttribute("Text",text);
}
child = child.nextSibling();
}
return n;
}
void ReportRenderer::parseFooters(QDomNode RFooter, bool haveRfooter, QDomNode PFooter, bool havePFooter, QMap<QString, QSqlRecord> selects)
{
if(haveRfooter)
{
QDomNode child = RFooter.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(ele.attribute("id")=="Field")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
{
QString key = value.at(0) + "." + value.at(1);
text = applyFormato(selects.value(key).value(value.at(2)).toString(),formato);
}
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="RelationalField")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()>1)
{
QString key = value.at(0) + "." + value.at(1);
text = applyFormato(getRelationField(ele.attribute("value"),selects.value(key)),formato);
}
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="CodeBar")
{
QString text = "";
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
{
QString key = value.at(0) + "." + value.at(1);
text = selects.value(key).value(value.at(2)).toString();
}
ele.setAttribute("Code",text);
}
else if(ele.attribute("id")=="Image")
{
QByteArray b;
QStringList value = ele.attribute("Path").split(".");
if(value.size()== 3)
{
QString key = value.at(0) + "." + value.at(1);
b = selects.value(key).value(value.at(2)).toByteArray();
ele.setAttribute("img-data",QString(b));
}
}
child = child.nextSibling();
}
}
if(havePFooter)
{
QDomNode child = PFooter.firstChild();
while(!child.isNull())
{
QDomElement ele = child.toElement();
if(ele.attribute("id")=="Field")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
{
QString key = value.at(0) + "." + value.at(1);
text = applyFormato(selects.value(key).value(value.at(2)).toString(),formato);
}
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="RelationalField")
{
ele.setAttribute("id","Label");
QString text = "";
int formato = ele.attribute("formato").toDouble();
QStringList value = ele.attribute("Sql").split(".");
if(value.size()>1)
{
QString key = value.at(0) + "." + value.at(1);
text = applyFormato(getRelationField(ele.attribute("value"),selects.value(key)),formato);
}
ele.setAttribute("Text",text);
}
else if(ele.attribute("id")=="CodeBar")
{
QString text = "";
QStringList value = ele.attribute("Sql").split(".");
if(value.size()== 3)
{
QString key = value.at(0) + "." + value.at(1);
text = selects.value(key).value(value.at(2)).toString();
}
ele.setAttribute("Code",text);
}
else if(ele.attribute("id")=="Image")
{
QByteArray b;
QStringList value = ele.attribute("Path").split(".");
if(value.size()== 3)
{
QString key = value.at(0) + "." + value.at(1);
b = selects.value(key).value(value.at(2)).toByteArray();
ele.setAttribute("img-data",QString(b));
}
}
child = child.nextSibling();
}
}
}
QColor ReportRenderer::ColorFromString(QString s)
{
QStringList l= s.split(",");
QColor c;
c.setRed (l.at(0).toDouble());
c.setGreen(l.at(1).toDouble());
c.setBlue (l.at(2).toDouble());
c.setAlpha(l.at(3).toDouble());
return c;
}
float ReportRenderer::getNumber(QString in, int formato)
{
float f = 0;
switch (formato) {
case 0:
case 3:
case 4:
f= in.toFloat();
break;
case 1:
case 5:
case 6:
in.replace(".","");
in.replace(",",".");
f= in.toFloat();
break;
case 2:
in.replace(",","");
f = in.toFloat();
break;
default:
f= 0;
}
return f;
}
QString ReportRenderer::applyFormato(QString in, int formato)
{
if(formato == 0 || formato > 6)
return in;
bool ok;
double d = in.toDouble(&ok);
if(!ok)
return in;
QString aux = QString::number(d, 'f' , 2);
QString aux2 = QString::number(d, 'f' , 3);
QString aux3 = QString::number(d, 'f' , 4);
if(formato == 4)
return aux;
else if(formato == 3)
return aux.replace(".",",");
else if(formato == 2)
{
QString entero = aux.split(".").at(0);
QString final;
int count = 0;
for(int i = entero.size()-1 ; i>= 0 ; i--)
{
final.prepend(entero.at(i));
count++;
if(count%3 == 0 && i != 0)
final.prepend(",");
}
final.append(".");
final.append(aux.split(".").at(1));
return final;
}
else if(formato == 1)
{
aux.replace(".",",");
QString entero = aux.split(",").at(0);
QString final;
int count = 0;
for(int i = entero.size()-1 ; i>= 0 ; i--)
{
final.prepend(entero.at(i));
count++;
if(count%3 == 0 && i != 0)
final.prepend(".");
}
final.append(",");
final.append(aux.split(",").at(1));
return final;
}
else if(formato == 5)
{
aux2.replace(".",",");
QString entero = aux2.split(",").at(0);
QString final;
int count = 0;
for(int i = entero.size()-1 ; i>= 0 ; i--)
{
final.prepend(entero.at(i));
count++;
if(count%3 == 0 && i != 0)
final.prepend(".");
}
final.append(",");
final.append(aux2.split(",").at(1));
return final;
}
else if(formato == 6)
{
aux3.replace(".",",");
QString entero = aux3.split(",").at(0);
QString final;
int count = 0;
for(int i = entero.size()-1 ; i>= 0 ; i--)
{
final.prepend(entero.at(i));
count++;
if(count%3 == 0 && i != 0)
final.prepend(".");
}
final.append(",");
final.append(aux3.split(",").at(1));
return final;
}
}
QString ReportRenderer::ColorString(QColor c)
{
return QString("%1,%2,%3,%4").arg(c.red()).arg(c.green()).arg(c.blue()).arg(c.alpha());
}
QPrinter *ReportRenderer::getPrinter() const
{
return printer;
}
void ReportRenderer::setPrinter(QPrinter *value)
{
printer = value;
}
QDomDocument ReportRenderer::getDocIn() const
{
return DocIn;
}
void ReportRenderer::setDocIn(const QDomDocument &value)
{
DocIn = value;
}
QMap<QString, QString> ReportRenderer::getQueryClausules() const
{
return queryClausules;
}
void ReportRenderer::setQueryClausules(const QMap<QString, QString> &value)
{
queryClausules = value;
}
|
[
"juanjo.kapyderi@gmail.com"
] |
juanjo.kapyderi@gmail.com
|
08f5233fea7e4fed8b67f623136b4d039e23eda6
|
8a6bb8471486e1dfdfe38f876a1fd390ef6e3065
|
/maincalculationthread.h
|
7afb80ccf020acd4702ac909a39b050a55c9964f
|
[
"MIT"
] |
permissive
|
pavelliavonau/COM2OMP
|
357ac2ee88e8db6675dd41d23e41a588391d8f44
|
4560b159ee276780fb342e0b7919eb346977d7fe
|
refs/heads/master
| 2020-06-02T14:11:58.756739
| 2015-07-31T10:10:34
| 2015-07-31T10:10:34
| 39,999,429
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,029
|
h
|
#ifndef MAINCALCULATIONTHREAD_H
#define MAINCALCULATIONTHREAD_H
#include "coclassdata.h"
#include <QFileInfo>
#include <QMutex>
#include <QThread>
#include <QVector>
#include <QWaitCondition>
#include <QDir>
#include <QMap>
class QObject;
class QTextEdit;
class MainCalculationThread : public QThread
{
Q_OBJECT
public:
MainCalculationThread(QObject* parent);
void setCalculationData(QVector<ComClassData> allClassesInIdl, QVector<QString> selectedClasses, QString clsIdlFilename, QString dataIdlFilename);
signals:
void appendToLog(QString) const;
void askUserYesOrNo(QString);
public slots:
void answerUserYesOrNoSlot(bool ignore);
// QThread interface
protected:
void run() override;
private:
void resume();
void pause();
QString findInterfaceDescription(const QString& file_content, const QString& interface_name) const;
bool findIdlDatatypes(QString interface_description, QVector<QString> &type_names ) const;
bool findIdlDatatypesDescription(const QString& file_content, QVector<QString> &typenames, QSet<QString> &datatype_declarations ) const;
void cutComInterfaceHead(QString& desc) const;
QString convertInterfaceDescToOmp(const QString& interface_description);
bool convertClassHeaderToOmp(const QFileInfo& header_file_info, ComClassData& class_data, QVector<QString>& converted_methods);
bool convertClassImplementationToOmp(const QFileInfo& implementation_file_info, const ComClassData &class_data, const QVector<QString> &methods_to_convert);
QString findPlaceForIncludeString(const QString& file) const;
bool isClassSO(const QString& header) const;
void writeToDebugFile(QString &text)const;
bool searchInterfaceInPredefinedMakeSql(InterfaceData &interface, ComClassData &class_data);
bool doAskYesOrNo(QString ask_message);
void stringToLog(QString log_string) const;
QString readFile(const QString& name_of_file);
void writeFile(const QString &name_of_file, const QString &contents) const;
void replaceMacrosInFile(QString& processing_file_name,
QString& folder_name,
const QString& interface_header_file_name,
const QString& search_pattern,
const QString& replace_to,
QSet<QString>& interface_includes,
bool need_add_include = true);
QDir m_project_dir;
QMap< QString, ComClassData > m_all_classes_in_IDL;
QVector<QString> m_selected_classes;
QString m_CLSID_filename;
QString m_data_IDL_filename;
QString m_OID_of_DLL;
QTextEdit* m_log_ptr;
QMutex m_sync;
QWaitCondition m_pause_cond;
bool m_pause;
bool m_answer_is_yes;
bool m_always_yes;
bool m_always_yes_asked;
};
#endif // MAINCALCULATIONTHREAD_H
|
[
"paval@open.by"
] |
paval@open.by
|
7775d01e720a55e19e0011c8611271e1dd298245
|
f1fca1fd42803c72e6dd310b1f325f8a281bf72d
|
/1250 KiloMan/main.cpp
|
4ea230838c0995991c20cb416f1469df2bba7e6a
|
[] |
no_license
|
marcelozeballos/URI
|
409c39244ea291b5246fc5d9b3566b155be5859a
|
1ecfa5dad99bb108c63ae4cef889e57ed19bfa03
|
refs/heads/master
| 2020-07-08T00:21:27.063079
| 2014-10-06T21:55:17
| 2014-10-06T21:55:17
| 23,006,988
| 1
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 585
|
cpp
|
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main()
{
int cases; scanf("%d", &cases);
while(cases--)
{
int length, cnt =0; scanf("%d", &length);
int shots[length];
for(int i =0; i < length; i++)
scanf("%d", &shots[i]);
string jumps; cin >> jumps;
for(int i =0; i < length; i++){
if(jumps[i] == 'J' && shots[i] > 2)
cnt++;
if(jumps[i] == 'S' && shots[i] <= 2)
cnt++;
}
printf("%d\n", cnt);
}
return 0;
}
|
[
"zeballosmarcelo@icloud.com"
] |
zeballosmarcelo@icloud.com
|
a65d2c4162df0e5cb2fa0a450f18e744a0de32e4
|
b5f6d2410a794a9acba9a0f010f941a1d35e46ce
|
/game/server/func_areaportal.cpp
|
98db5e634d469452c35cdb8e7f0db612f353e254
|
[] |
no_license
|
chrizonix/RCBot2
|
0a58591101e4537b166a672821ea28bc3aa486c6
|
ef0572f45c9542268923d500e64bb4cd037077eb
|
refs/heads/master
| 2021-01-19T12:55:49.003814
| 2018-08-27T08:48:55
| 2018-08-27T08:48:55
| 44,916,746
| 4
| 0
| null | null | null | null |
WINDOWS-1252
|
C++
| false
| false
| 4,906
|
cpp
|
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: area portal entity: toggles visibility areas on/off
//
// NOTE: These are not really brush entities. They are brush entities from a
// designer/worldcraft perspective, but by the time they reach the game, the
// brush model is gone and this is, in effect, a point entity.
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "func_areaportalbase.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
enum areaportal_state
{
AREAPORTAL_CLOSED = 0,
AREAPORTAL_OPEN = 1,
};
class CAreaPortal : public CFuncAreaPortalBase
{
public:
DECLARE_CLASS( CAreaPortal, CFuncAreaPortalBase );
CAreaPortal();
virtual void Spawn( void );
virtual void Precache( void );
virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
virtual bool KeyValue( const char *szKeyName, const char *szValue );
virtual int UpdateTransmitState();
// Input handlers
void InputOpen( inputdata_t &inputdata );
void InputClose( inputdata_t &inputdata );
void InputToggle( inputdata_t &inputdata );
virtual bool UpdateVisibility( const Vector &vOrigin, float fovDistanceAdjustFactor, bool &bIsOpenOnClient );
DECLARE_DATADESC();
private:
bool UpdateState( void );
int m_state;
};
LINK_ENTITY_TO_CLASS( func_areaportal, CAreaPortal );
BEGIN_DATADESC( CAreaPortal )
DEFINE_KEYFIELD( m_portalNumber, FIELD_INTEGER, "portalnumber" ),
DEFINE_FIELD( m_state, FIELD_INTEGER ),
// Inputs
DEFINE_INPUTFUNC( FIELD_VOID, "Open", InputOpen ),
DEFINE_INPUTFUNC( FIELD_VOID, "Close", InputClose ),
DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ),
// TODO: obsolete! remove
DEFINE_INPUTFUNC( FIELD_VOID, "TurnOn", InputClose ),
DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputOpen ),
END_DATADESC()
CAreaPortal::CAreaPortal()
{
m_state = AREAPORTAL_OPEN;
}
void CAreaPortal::Spawn( void )
{
AddEffects( EF_NORECEIVESHADOW | EF_NOSHADOW );
Precache();
}
//-----------------------------------------------------------------------------
// Purpose: notify the engine of the state at startup/restore
//-----------------------------------------------------------------------------
void CAreaPortal::Precache( void )
{
UpdateState();
}
//------------------------------------------------------------------------------
// Purpose :
//------------------------------------------------------------------------------
void CAreaPortal::InputClose( inputdata_t &inputdata )
{
m_state = AREAPORTAL_CLOSED;
UpdateState();
}
//------------------------------------------------------------------------------
// Purpose :
//------------------------------------------------------------------------------
void CAreaPortal::InputOpen( inputdata_t &inputdata )
{
m_state = AREAPORTAL_OPEN;
UpdateState();
}
//------------------------------------------------------------------------------
// Purpose :
//------------------------------------------------------------------------------
void CAreaPortal::InputToggle( inputdata_t &inputdata )
{
m_state = ((m_state == AREAPORTAL_OPEN) ? AREAPORTAL_CLOSED : AREAPORTAL_OPEN);
UpdateState();
}
bool CAreaPortal::UpdateVisibility( const Vector &vOrigin, float fovDistanceAdjustFactor, bool &bIsOpenOnClient )
{
if ( m_state )
{
// We're not closed, so give the base class a chance to close it.
return BaseClass::UpdateVisibility( vOrigin, fovDistanceAdjustFactor, bIsOpenOnClient );
}
else
{
bIsOpenOnClient = false;
return false;
}
}
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
void CAreaPortal::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( useType == USE_ON )
{
m_state = AREAPORTAL_OPEN;
}
else if ( useType == USE_OFF )
{
m_state = AREAPORTAL_CLOSED;
}
else
{
return;
}
UpdateState();
}
bool CAreaPortal::KeyValue( const char *szKeyName, const char *szValue )
{
if( FStrEq( szKeyName, "StartOpen" ) )
{
m_state = (atoi(szValue) != 0) ? AREAPORTAL_OPEN : AREAPORTAL_CLOSED;
return true;
}
else
{
return BaseClass::KeyValue( szKeyName, szValue );
}
}
bool CAreaPortal::UpdateState()
{
engine->SetAreaPortalState( m_portalNumber, m_state );
return !!m_state;
}
int CAreaPortal::UpdateTransmitState()
{
// Our brushes are kept around so don't transmit anything since we don't want to draw them.
return SetTransmitState( FL_EDICT_DONTSEND );
}
|
[
"christian.pichler.msc@gmail.com"
] |
christian.pichler.msc@gmail.com
|
d0b16c0738ed4667fff934d802590ee3a60fde78
|
29a33a849f2b22ebed339b4cf870de3833a7a405
|
/Source/Dissonance/Player&Input/DissonanceController.h
|
0e9aad274a8d84a2cba980b4db12d8d0f27832fc
|
[] |
no_license
|
ChrisG4/Dissonance
|
e16a4ed7c0a96a543a5bf77594f6f92ae110f3af
|
1ea4382155bdc0d53e3d70aa74db2eda8ee4d76e
|
refs/heads/master
| 2023-04-16T06:33:33.624777
| 2021-04-19T15:48:14
| 2021-04-19T15:48:14
| 353,405,635
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 352
|
h
|
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "PlayerCharacter.h"
#include "DissonanceController.generated.h"
/**
*
*/
UCLASS()
class DISSONANCE_API ADissonanceController : public APlayerController
{
GENERATED_BODY()
};
|
[
"chrisgoldsack4@gmail.com"
] |
chrisgoldsack4@gmail.com
|
3bf2e71a3c5d47106552768c6340e2e64fecf656
|
95be364ed17fbe1898214e5a3daf63234440bd41
|
/little girl and game.cpp
|
b12109eef4b489c3a0d656a50cad3df0161c7e71
|
[] |
no_license
|
shiv-am117/a2oj_div2-b
|
b4ebd001d717d87a2a7562052068b6ca8c270aa5
|
1dd500aa657bb9228d0a72972a59d623234cdfbe
|
refs/heads/master
| 2020-03-28T00:05:13.496988
| 2018-11-03T14:52:21
| 2018-11-03T14:52:21
| 147,374,426
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 322
|
cpp
|
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
int count=0,i,l=s.length();
map<char,int>temp;
for(i=0;i<l;i++){
temp[s[i]]++;
}
map<char,int>::iterator it;
for(it=temp.begin();it!=temp.end();it++){
if(it->second%2!=0) count++;
}
if(count==0||count%2!=0) cout<<"First";
else cout<<"Second";
}
|
[
"goel.shivam117@gmail.com"
] |
goel.shivam117@gmail.com
|
c82bb0fbd6902eac7d0996993d6aabdd6c239890
|
de75e69a8951f8aa5088d82c499d58b6fc31006f
|
/src/spork.h
|
bb94e9487bf8404bcde6576cbee19de2973462b2
|
[
"MIT"
] |
permissive
|
arekhere/madcoinv3
|
698e11c1fe9d470f2035c0576fffcf271db90407
|
07d8e01e56bb43927a1ebebff20d6236ca87bfbf
|
refs/heads/master
| 2020-03-19T17:48:03.691004
| 2018-06-06T13:24:42
| 2018-06-06T13:24:42
| 136,778,510
| 0
| 1
|
MIT
| 2018-06-10T04:15:44
| 2018-06-10T04:15:43
| null |
UTF-8
|
C++
| false
| false
| 4,507
|
h
|
// Copyright (c) 2017 The MDC developers
// Copyright (c) 2009-2012 The Darkcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef SPORK_H
#define SPORK_H
#include "bignum.h"
#include "sync.h"
#include "net.h"
#include "key.h"
#include "util.h"
#include "script.h"
#include "base58.h"
#include "main.h"
using namespace std;
using namespace boost;
// Don't ever reuse these IDs for other sporks
#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT 10000
#define SPORK_2_INSTANTX 10001
#define SPORK_3_INSTANTX_BLOCK_FILTERING 10002
#define SPORK_4_NOTUSED 10003
#define SPORK_5_MAX_VALUE 10004
#define SPORK_6_REPLAY_BLOCKS 10005
#define SPORK_7_MASTERNODE_SCANNING 10006
#define SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT 10007
#define SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT 10008
#define SPORK_10_MASTERNODE_PAY_UPDATED_NODES 10009
#define SPORK_11_RESET_BUDGET 10010
#define SPORK_12_RECONSIDER_BLOCKS 10011
#define SPORK_13_ENABLE_SUPERBLOCKS 10012
#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT 2428537599 //2015-4-8 23:59:59 GMT // NOT USED
#define SPORK_2_INSTANTX_DEFAULT 978307200 //2001-1-1 23:59:59 GMT
#define SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT 978307200 //2001-1-1 23:59:59 GMT
#define SPORK_4_RECONVERGE_DEFAULT 1451606400 //2016-01-01 // NOT USED
#define SPORK_5_MAX_VALUE_DEFAULT 500 //500 MDC
#define SPORK_6_REPLAY_BLOCKS_DEFAULT 0 // NOT USED
#define SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT 4070908800 //OFF
#define SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT_DEFAULT 4070908800 //OFF
#define SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT 4070908800 //OFF
#define SPORK_11_RESET_BUDGET_DEFAULT 0
#define SPORK_12_RECONSIDER_BLOCKS_DEFAULT 0
#define SPORK_13_ENABLE_SUPERBLOCKS_DEFAULT 4070908800 //OFF
class CSporkMessage;
class CSporkManager;
#include "bignum.h"
#include "net.h"
#include "key.h"
#include "util.h"
#include "protocol.h"
#include "darksend.h"
#include <boost/lexical_cast.hpp>
using namespace std;
using namespace boost;
extern std::map<uint256, CSporkMessage> mapSporks;
extern std::map<int, CSporkMessage> mapSporksActive;
extern CSporkManager sporkManager;
void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
int64_t GetSporkValue(int nSporkID);
bool IsSporkActive(int nSporkID);
void ExecuteSpork(int nSporkID, int nValue);
//void ReprocessBlocks(int nBlocks);
//
// Spork Class
// Keeps track of all of the network spork settings
//
class CSporkMessage
{
public:
std::vector<unsigned char> vchSig;
int nSporkID;
int64_t nValue;
int64_t nTimeSigned;
uint256 GetHash(){
uint256 n = Hash(BEGIN(nSporkID), END(nTimeSigned));
return n;
}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
unsigned int nSerSize = 0;
READWRITE(nSporkID);
READWRITE(nValue);
READWRITE(nTimeSigned);
READWRITE(vchSig);
}
};
class CSporkManager
{
private:
std::vector<unsigned char> vchSig;
std::string strMasterPrivKey;
std::string strTestPubKey;
std::string strMainPubKey;
public:
CSporkManager() {
strMainPubKey = "04a983220ea7a38a7106385003fef77896538a382a0dcc389cc45f3c98751d9af423a097789757556259351198a8aaa628a1fd644c3232678c5845384c744ff8d7";
strTestPubKey = "04a983220ea7a38a7106385003fef77896538a382a0dcc389cc45f3c98751d9af423a097789757556259351198a8aaa628a1fd644c3232678c5845384c744ff8d7";
}
std::string GetSporkNameByID(int id);
int GetSporkIDByName(std::string strName);
bool UpdateSpork(int nSporkID, int64_t nValue);
bool SetPrivKey(std::string strPrivKey);
bool CheckSignature(CSporkMessage& spork);
bool Sign(CSporkMessage& spork);
void Relay(CSporkMessage& msg);
};
#endif
|
[
"support@madcoin.life"
] |
support@madcoin.life
|
46bbcdf8198cd840c5a7435bcf1ed00aec433f6a
|
e173cf1c687d62e72b67d53286a41dcb711a169e
|
/ext-jni.h
|
53bb43de30e63f62b05b918989f87aa35a2d5651
|
[] |
no_license
|
alex2stf/astox
|
d4663d55e6e3a82d9bf0fb83fa698dabe949bd3e
|
4f01cb04991639a7a47d6ecfab6cee3ba9848890
|
refs/heads/master
| 2022-01-30T21:28:00.718833
| 2022-01-02T09:27:37
| 2022-01-02T09:27:37
| 30,925,707
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,654
|
h
|
#ifndef ASTOX_EXTERNAL_JAVA_NATIVE_INTERFACE_SUPPOPRT
#define ASTOX_EXTERNAL_JAVA_NATIVE_INTERFACE_SUPPOPRT
#include "macros.h"
#include "types.h"
#include <jni.h>
namespace astox {
class JNIContainer {
public:
Function * context();
Value * eval(std::string input);
void expose(std::string name, Value * value);
static JNIContainer * instance();
void putFunction(Function * function);
Function * getFunction(stxtr name);
Function * newFunction(const char * input);
Value * callFunctionById(stxtr name, Value *& args);
JNIEnv * env();
void setEnv(JNIEnv * env);
jint throwErr(stxtr msg, const char * filename, const char * funcname, int line);
Value * getMember(const char * serialized);
private:
static JNIContainer * _ins;
Function * _ctx;
JNIContainer();
map<stxtr, Function*> funcBuf;
JNIEnv * _env;
};
class JSTXFunction : public Object {
private:
JNIEnv *env;
const char * clazzcaller;
jobject objcaller;
stxtr methodname;
public:
JSTXFunction(const lexic &l, JNIEnv *env,
jobject objcaller,
const char * clazzname,
stxtr methodname);
Value * call(Value * arguments, Function *&context);
Value * call(std::string &args, const scriptengine::lexic &l, Function *&ctx);
stxtr str();
const char * strtype();
};
namespace serializers {
jobject jobject_from_value(JNIEnv *env, Value * v);
Value * value_from_jobject(JNIEnv *env, jobject j);
}
}
#define STX_EXPOSED_JVM_CLASS_SIGN "axl/stf/astox/Value"
#define STX_EXPOSED_JVM_ENUM_SIGN "axl/stf/astox/Type"
#define STX_EXPOSED_JVM_ENUM_LSIGN "Laxl/stf/astox/Type;"
#define STX_EXPOSED_JVM_CLASS "axl.stf.astox.Value"
#define STX_EXPOSED_METHOD_SIGN "(Laxl/stf/astox/Value;)Laxl/stf/astox/Value;"
stxtr jvm_get_method_name(JNIEnv *env, jobject method, jclass methodClass);
stxtr jvm_get_method_return_type(JNIEnv *env, jobject method, jclass methodClass);
bool jvm_check_params(JNIEnv *env, jobject method, jclass methodClass);
jobject jvm_get_enum_type(JNIEnv *env, int type);
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jobject JNICALL Java_axl_stf_astox_Value_executeNativeFunction(JNIEnv *env, jobject jobj, jstring id, jobject params);
JNIEXPORT jobject JNICALL Java_axl_stf_astox_Scriptengine_evalNative(JNIEnv *env, jobject jobj, jstring input);
JNIEXPORT jobject JNICALL Java_axl_stf_astox_Scriptengine_infoNative(JNIEnv *env, jobject jobj);
JNIEXPORT void JNICALL Java_axl_stf_astox_Scriptengine_exposeNative(JNIEnv *env, jobject jobj, jstring name, jobject inst, jobjectArray methods, jstring clazzname);
jint JNI_OnLoad(JavaVM *vm, void *reserved);
#ifdef __cplusplus
}
#endif
#endif
|
[
"alexandru.stefan@qualitance.com"
] |
alexandru.stefan@qualitance.com
|
0028439d51ba0a93553e0dae1921a4e3fc8e1bc5
|
6145ee015fc3fc5e617d115b4a0a02ec8939f035
|
/Test/Expect/test09.h
|
942b12190d654c8e46ba747ecf9cb5aa73cb7e8b
|
[
"TCL",
"MIT"
] |
permissive
|
DavidZemon/spin2cpp
|
0cad7d62d618bc61e46d9302b049ec1c12e1fbd6
|
89f6e27ddc08996e66ff0976bdb9821bcd22a4c9
|
refs/heads/master
| 2020-12-25T23:27:31.706609
| 2016-08-21T03:55:05
| 2016-08-21T03:55:05
| 53,184,887
| 0
| 0
| null | 2016-03-05T05:15:06
| 2016-03-05T05:15:06
| null |
UTF-8
|
C++
| false
| false
| 153
|
h
|
#ifndef test09_Class_Defined__
#define test09_Class_Defined__
#include <stdint.h>
class test09 {
public:
static void Init(void);
private:
};
#endif
|
[
"ersmith@totalspectrum.ca"
] |
ersmith@totalspectrum.ca
|
8a0a054e423416d65d9aab3e87a574fe078338dc
|
5f5ddc3c7e68c95cd8caf8c70db95f1d0015095d
|
/entity/header/Filme.hpp
|
ac6c91c3681e8396aebd92351ad1115f6e628b76
|
[] |
no_license
|
poatzz/projeto-cinema
|
b6587819cf575cb09d8243df7fbb95a2219ee5c6
|
62be1dda3fb2844dd980765d8cfc4ebe4efb0f17
|
refs/heads/master
| 2021-01-17T22:43:32.444272
| 2014-06-28T06:49:17
| 2014-06-28T06:49:17
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 838
|
hpp
|
#ifndef __FILME_HPP_
#define __FILME_HPP_
#include <string>
#include "../../libraries/cplusplus/data_structures/ListaDinamica.hpp"
#include "../../libraries/cplusplus/utilities/Hora.hpp"
#include "../enumeration/Genero.hpp"
#include "EquipeFilme.hpp"
using std::string;
template<class EquipeFilme>
class Filme {
private:
string _titulo;
unsigned short _censura;
Hora _duracao;
Genero _genero;
ListaDinamica<EquipeFilme> _equipe;
public:
Filme(string titulo, unsigned short censura, Hora duracao, Genero genero);
string getTitulo() const;
unsigned short getCensura() const;
Hora getDuracao() const;
Genero getGenero() const;
ListaDinamica<EquipeFilme> getEquipe() const;
void addEquipe(EquipeFilme * equipe);
void removeEquipe(string nomeEquipe);
};
#endif /* __FILME_HPP_ */
|
[
"guijocargo@gmail.com"
] |
guijocargo@gmail.com
|
7a848e95e798bc4f7f6fb6efc39d3de293cfc222
|
3841f7991232e02c850b7e2ff6e02712e9128b17
|
/小浪底泥沙三维/EV_Xld/jni/src/EV_MapControl_CSharp/wrapper/linestringtrackingItemwrapper_wrapper.cpp
|
127607ce00fcd13f4ea0a1e56e4e16d00f715634
|
[] |
no_license
|
15831944/BeijingEVProjects
|
62bf734f1cb0a8be6fed42cf6b207f9dbdf99e71
|
3b5fa4c4889557008529958fc7cb51927259f66e
|
refs/heads/master
| 2021-07-22T14:12:15.106616
| 2017-10-15T11:33:06
| 2017-10-15T11:33:06
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,337
|
cpp
|
/* This file is produced by the P/Invoke AutoWrapper Utility
Copyright (c) 2012 by EarthView Image Inc */
#include "mapcontrol/linestringtrackingItemwrapper.h"
extern "C" EV_DLL_EXPORT void _stdcall CLinestringTrackingItemWrapper_setLevelScale_void_ev_int32_ev_real64(void *pObjectXXXX, _in ev_int32 level, _in ev_real64 scale )
{
CLinestringTrackingItemWrapper* ptrNativeObject = (CLinestringTrackingItemWrapper*) pObjectXXXX;
ptrNativeObject->setLevelScale(level, scale);
}
extern "C" EV_DLL_EXPORT void _stdcall CLinestringTrackingItemWrapper_setSymbol_void_ISymbol(void *pObjectXXXX, _in EarthView::World::Spatial::Display::ISymbol* pSymbol )
{
CLinestringTrackingItemWrapper* ptrNativeObject = (CLinestringTrackingItemWrapper*) pObjectXXXX;
ptrNativeObject->setSymbol(pSymbol);
}
extern "C" EV_DLL_EXPORT void _stdcall CLinestringTrackingItemWrapper_addPoint_void_CPoint(void *pObjectXXXX, _in EarthView::World::Spatial::Geometry::CPoint* point )
{
CLinestringTrackingItemWrapper* ptrNativeObject = (CLinestringTrackingItemWrapper*) pObjectXXXX;
ptrNativeObject->addPoint(point);
}
extern "C" EV_DLL_EXPORT void _stdcall CLinestringTrackingItemWrapper_refresh_void(void *pObjectXXXX )
{
CLinestringTrackingItemWrapper* ptrNativeObject = (CLinestringTrackingItemWrapper*) pObjectXXXX;
ptrNativeObject->refresh();
}
|
[
"yanguanqi@aliyun.com"
] |
yanguanqi@aliyun.com
|
cd3d7d04367f103104a0c94f241822bf30c5efac
|
5780579dc1ef0e05bbea84ed7993b93b0da95ca2
|
/src/base_stub.cpp
|
fee7831b38fcc27654b0fc777a2b1222db05484d
|
[] |
no_license
|
pveber/ogrillon
|
c88a8cabd537a17ef62953164fc3e910ea5f9130
|
71236e83c033a630e3a947636c5ac04615d9e41b
|
refs/heads/master
| 2021-01-02T23:07:35.933090
| 2012-10-06T20:57:27
| 2012-10-06T20:57:27
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,496
|
cpp
|
/* Caml headers */
extern "C" {
#include<caml/mlvalues.h>
#include<caml/memory.h>
#include<caml/callback.h>
#include<caml/fail.h>
#include<caml/alloc.h>
#include<caml/misc.h>
}
#include <OgreRoot.h>
#include <OgreCamera.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreLogManager.h>
#include <OgreViewport.h>
#include <OgreEntity.h>
#include <OgreWindowEventUtilities.h>
#include <OgrePlugin.h>
#include <OgreRenderSystem.h>
using namespace Ogre;
void demo() {
Ogre::Root *mRoot;
Ogre::Camera* mCamera;
Ogre::SceneManager* mSceneMgr;
Ogre::RenderWindow* mWindow;
mRoot = new Ogre::Root("plugins.cfg", "resources.cfg", "LowLevelOgre.log");
//-------------------------------------------------------------------------------------
// setup resources
// Only add the minimally required resource locations to load up the Ogre head mesh
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/models", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/materials/scripts", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/materials/programs", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("media/materials/textures", "FileSystem", "General");
//-------------------------------------------------------------------------------------
// configure
// Grab the OpenGL RenderSystem, or exit
Ogre::RenderSystem* rs = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
if(!(rs->getName() == "OpenGL Rendering Subsystem"))
{
exit(42);
}
// configure our RenderSystem
rs->setConfigOption("Full Screen", "No");
rs->setConfigOption("VSync", "No");
rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit");
mRoot->setRenderSystem(rs);
mWindow = mRoot->initialise(true, "LowLevelOgre Render Window");
//-------------------------------------------------------------------------------------
// choose scenemanager
// Get the SceneManager, in this case the OctreeSceneManager
mSceneMgr = mRoot->createSceneManager("OctreeSceneManager", "DefaultSceneManager");
//-------------------------------------------------------------------------------------
// create camera
// Create the camera
mCamera = mSceneMgr->createCamera("PlayerCam");
// Position it at 500 in Z direction
mCamera->setPosition(Ogre::Vector3(0,0,80));
// Look back along -Z
mCamera->lookAt(Ogre::Vector3(0,0,-300));
mCamera->setNearClipDistance(5);
//-------------------------------------------------------------------------------------
// create viewports
// Create one viewport, entire window
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
//-------------------------------------------------------------------------------------
// Set default mipmap level (NB some APIs ignore this)
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
//-------------------------------------------------------------------------------------
// Create any resource listeners (for loading screens)
//createResourceListener();
//-------------------------------------------------------------------------------------
// load resources
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//-------------------------------------------------------------------------------------
// Create the scene
Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
headNode->attachObject(ogreHead);
// Set ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
// Create a light
Ogre::Light* l = mSceneMgr->createLight("MainLight");
l->setPosition(20,80,50);
//-------------------------------------------------------------------------------------
//mRoot->startRendering();
while(!mWindow->isClosed())
{
// Pump window messages for nice behaviour
Ogre::WindowEventUtilities::messagePump();
// Render a frame
mRoot->renderOneFrame();
}
}
extern "C" {
value ogrillon_demo(value unit) {
demo();
return Val_unit;
}
}
|
[
"philippe.veber@gmail.com"
] |
philippe.veber@gmail.com
|
18237b1fbb7260154fec2efd1a261e463680aa89
|
8b39fa00bfaf2ab1f1cae37d5c997f7d1b206848
|
/src/generated/DmaRequest.h
|
f20c59cd6a7cc124275de73d058bde4a3833e17d
|
[] |
no_license
|
cambridgehackers/dmac
|
1de447dfd720ba65736c60375a97c83368f98162
|
a58aee52523258d32b936b543be35db884a346a5
|
refs/heads/master
| 2021-01-10T12:55:54.010520
| 2016-04-21T15:43:43
| 2016-04-21T15:43:43
| 43,370,517
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,063
|
h
|
#include "GeneratedTypes.h"
#ifndef _DMAREQUEST_H_
#define _DMAREQUEST_H_
#include "portal.h"
class DmaRequestProxy : public Portal {
DmaRequestCb *cb;
public:
DmaRequestProxy(int id, int tile = DEFAULT_TILE, DmaRequestCb *cbarg = &DmaRequestProxyReq, int bufsize = DmaRequest_reqinfo, PortalPoller *poller = 0) :
Portal(id, tile, bufsize, NULL, NULL, this, poller), cb(cbarg) {};
DmaRequestProxy(int id, PortalTransportFunctions *item, void *param, DmaRequestCb *cbarg = &DmaRequestProxyReq, int bufsize = DmaRequest_reqinfo, PortalPoller *poller = 0) :
Portal(id, DEFAULT_TILE, bufsize, NULL, NULL, item, param, this, poller), cb(cbarg) {};
DmaRequestProxy(int id, PortalPoller *poller) :
Portal(id, DEFAULT_TILE, DmaRequest_reqinfo, NULL, NULL, NULL, NULL, this, poller), cb(&DmaRequestProxyReq) {};
int writeRequestSize ( const uint16_t burstLenBytes ) { return cb->writeRequestSize (&pint, burstLenBytes); };
int readRequestSize ( const uint16_t readRequestBytes ) { return cb->readRequestSize (&pint, readRequestBytes); };
int transferToFpga ( const uint32_t objId, const uint32_t base, const uint32_t bytes, const uint8_t tag ) { return cb->transferToFpga (&pint, objId, base, bytes, tag); };
int transferFromFpga ( const uint32_t objId, const uint32_t base, const uint32_t bytes, const uint8_t tag ) { return cb->transferFromFpga (&pint, objId, base, bytes, tag); };
};
extern DmaRequestCb DmaRequest_cbTable;
class DmaRequestWrapper : public Portal {
public:
DmaRequestWrapper(int id, int tile = DEFAULT_TILE, PORTAL_INDFUNC cba = DmaRequest_handleMessage, int bufsize = DmaRequest_reqinfo, PortalPoller *poller = 0) :
Portal(id, tile, bufsize, cba, (void *)&DmaRequest_cbTable, this, poller) {
};
DmaRequestWrapper(int id, PortalTransportFunctions *item, void *param, PORTAL_INDFUNC cba = DmaRequest_handleMessage, int bufsize = DmaRequest_reqinfo, PortalPoller *poller=0):
Portal(id, DEFAULT_TILE, bufsize, cba, (void *)&DmaRequest_cbTable, item, param, this, poller) {
};
DmaRequestWrapper(int id, PortalPoller *poller) :
Portal(id, DEFAULT_TILE, DmaRequest_reqinfo, DmaRequest_handleMessage, (void *)&DmaRequest_cbTable, this, poller) {
};
DmaRequestWrapper(int id, PortalTransportFunctions *item, void *param, PortalPoller *poller):
Portal(id, DEFAULT_TILE, DmaRequest_reqinfo, DmaRequest_handleMessage, (void *)&DmaRequest_cbTable, item, param, this, poller) {
};
virtual void disconnect(void) {
printf("DmaRequestWrapper.disconnect called %d\n", pint.client_fd_number);
};
virtual void writeRequestSize ( const uint16_t burstLenBytes ) = 0;
virtual void readRequestSize ( const uint16_t readRequestBytes ) = 0;
virtual void transferToFpga ( const uint32_t objId, const uint32_t base, const uint32_t bytes, const uint8_t tag ) = 0;
virtual void transferFromFpga ( const uint32_t objId, const uint32_t base, const uint32_t bytes, const uint8_t tag ) = 0;
};
#endif // _DMAREQUEST_H_
|
[
"jamey.hicks@gmail.com"
] |
jamey.hicks@gmail.com
|
ac43717466cc6d21e97ac18d4dd22fcbc27a4565
|
9cdd582e184199ae9d4570b01ad7f875ed0bf231
|
/src/process_images.cpp
|
86119b585c79155b4983ae4464d368703796232e
|
[] |
no_license
|
callumacrae/aerial-shapes
|
6dc0273e7170fa6cb44a070b8e059846e92698e6
|
219604ec2d59828aaa0f8c3d2e2ce9887eb0df79
|
refs/heads/main
| 2023-07-25T16:46:18.781052
| 2021-08-26T13:59:43
| 2021-08-26T13:59:43
| 381,499,827
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,537
|
cpp
|
#include <linenoise.hpp>
#include "precompiled.h"
#include "config.h"
#include "lib/detect-edge.hpp"
#include "lib/edit-image-edges.hpp"
#include "lib/image-list.hpp"
std::optional<int> imageFromArg(ImageList &imageList, const std::string &arg) {
if (arg.empty()) {
std::cerr << "Argument required\n";
return {};
}
int id = -1;
try {
id = stoi(arg);
} catch (std::invalid_argument) {
for (size_t i = 0; i < imageList.count(); ++i) {
if (imageList.at(i)->path == arg) {
id = i;
break;
}
}
}
if (id == -1) {
std::cerr << "Image not found\n";
return {};
}
if (id > imageList.count() - 1) {
std::cerr << "That image doesn't exist: highest ID is "
<< (imageList.count() - 1) << '\n';
return {};
}
return id;
}
int main(int argc, const char *argv[]) {
auto readStart = std::chrono::high_resolution_clock::now();
if (!argv[1]) {
std::cerr << "No directory specified, exiting\n";
exit(1);
}
std::cout << std::fixed << std::setprecision(2);
ImageList imageList(argv[1]);
if (imageList.count()) {
auto readFinish = std::chrono::high_resolution_clock::now();
std::chrono::duration<float> readElapsed = readFinish - readStart;
std::cout << "Loaded " << imageList.count() << " images from store in "
<< readElapsed.count() << "s\n";
} else {
std::cout << "No store found for this directory, type \"generate\" to "
<< "generate one\n";
}
while (true) {
std::cout << '\n'; // This bugs out if added to the linenoise call
std::string line;
auto quit = linenoise::Readline("> ", line);
if (quit) {
break;
}
std::string_view query(line);
auto splitPos = query.find(' ');
std::string_view command = query.substr(0, splitPos);
std::string_view arg;
if (splitPos != query.npos) {
arg = query.substr(query.find(' ') + 1);
}
linenoise::AddHistory(line.c_str());
if (command == "exit" || command == "q") {
std::cout << "bye\n";
break;
}
auto start = std::chrono::high_resolution_clock::now();
if (command == "generate" || command == "reset") {
if (command == "generate" && imageList.count() > 0) {
std::cerr
<< "Store has already been generated: use \"reset\" to reset\n";
continue;
} else if (command == "reset") {
std::cout << '\n';
std::string line;
auto quit =
linenoise::Readline("Are you sure you wish to reset? (y/N) ", line);
if (quit) {
break;
}
if (line != "y") {
std::cout << "Aborting reset\n";
continue;
}
}
imageList.generate();
imageList.save();
auto finish = std::chrono::high_resolution_clock::now();
std::chrono::duration<float> elapsed = finish - start;
std::cout << "Generated in " << elapsed.count() << "s\n";
} else if (command == "sync") {
auto imageListBackup = imageList;
int newImages = imageList.sync();
if (!newImages) {
std::cout << "Synced: no new images found\n";
continue;
}
char prompt[35];
sprintf(prompt, "%i new images found, save? (Y/n) ", newImages);
std::string line;
auto quit = linenoise::Readline(prompt, line);
if (quit) {
break;
}
if (line != "n") {
std::cout << "Saving " << newImages << " new images to store\n";
imageList.save();
} else {
imageList = imageListBackup;
}
} else if (command == "ls") {
std::cout << imageList.count() << " images in store:\n\n";
int i = 0;
for (const std::shared_ptr<EdgedImage> &image : imageList) {
std::cout << i << ": " << image->path << " (" << image->width << "x"
<< image->height << ")\n";
i++;
}
std::cout << '\n';
} else if (command == "edit") {
auto maybeImage = imageFromArg(imageList, std::string(arg));
if (!maybeImage.has_value()) {
continue;
}
std::shared_ptr<EdgedImage> &image = imageList.at(maybeImage.value());
std::cout << "Editing: " << image->path << "\n";
std::optional<EdgedImage *> maybeNewImage = editImageEdges(*image);
if (maybeNewImage.has_value()) {
image = std::shared_ptr<EdgedImage>(maybeNewImage.value());
imageList.save();
std::cout << "Changes saved\n";
} else {
std::cout << "Changes discarded\n";
}
} else if (command == "rm") {
auto maybeImage = imageFromArg(imageList, std::string(arg));
if (!maybeImage.has_value()) {
continue;
}
int id = maybeImage.value();
std::string path = imageList.at(id)->path;
std::cout << "Removing: " << path << "\n";
imageList.erase(id);
imageList.save();
char prompt[60];
sprintf(prompt, "Image removed from store: delete file from disk? (Y/n) ");
std::string line;
auto quit = linenoise::Readline(prompt, line);
if (quit) {
break;
}
if (line != "n") {
std::filesystem::remove(path);
std::cout << "File removed\n";
}
} else if (command == "sort") {
imageList.sortBy("path");
std::cout << "Sorted by file path - this will not be saved to store\n";
} else if (command == "save") {
imageList.save(false);
std::cout << "Store saved\n";
} else {
std::cout << "?\n";
}
}
}
|
[
"callum@macr.ae"
] |
callum@macr.ae
|
76c847d6ea1132e698e8c2158d0cf20adefa8447
|
ab0d9add78242021c278d3cf891ef7098daf7659
|
/V1.0/code/Server/common/OnvifSDK/OnvifAPIAll/soapNotificationConsumerBindingProxy.h
|
3a80e1b88d0a8a1e47e40608d7019778e3bf1200
|
[] |
no_license
|
qcamei/Project_njlw
|
fe6f80dd42cf7c6bb0abd448eff76c56dade1440
|
e56b42800042062f6b18d2023d73afbdf1668ab0
|
refs/heads/master
| 2020-04-17T11:02:41.014763
| 2017-11-13T11:09:52
| 2017-11-13T11:09:52
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,428
|
h
|
/* soapNotificationConsumerBindingProxy.h
Generated by gSOAP 2.8.0 from Onvif.h
Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
The generated code is released under one of the following licenses:
GPL, the gSOAP public license, or Genivia's license for commercial use.
*/
#ifndef soapNotificationConsumerBindingProxy_H
#define soapNotificationConsumerBindingProxy_H
#include "soapH.h"
class NotificationConsumerBinding
{ public:
/// Runtime engine context allocated in constructor
struct soap *soap;
/// Endpoint URL of service 'NotificationConsumerBinding' (change as needed)
const char *endpoint;
/// Constructor allocates soap engine context, sets default endpoint URL, and sets namespace mapping table
NotificationConsumerBinding()
{ soap = soap_new(); endpoint = "http://localhost:80"; if (soap && !soap->namespaces) { static const struct Namespace namespaces[] =
{
{"SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope", "http://schemas.xmlsoap.org/soap/envelope/", NULL},
{"SOAP-ENC", "http://www.w3.org/2003/05/soap-encoding", "http://schemas.xmlsoap.org/soap/encoding/", NULL},
{"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
{"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},
{"wsa5", "http://www.w3.org/2005/08/addressing", "http://schemas.xmlsoap.org/ws/2004/08/addressing", NULL},
{"c14n", "http://www.w3.org/2001/10/xml-exc-c14n#", NULL, NULL},
{"wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", NULL, NULL},
{"ds", "http://www.w3.org/2000/09/xmldsig#", NULL, NULL},
{"wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd", NULL},
{"ns5", "http://docs.oasis-open.org/wsrf/r-2", NULL, NULL},
{"ns6", "http://schemas.xmlsoap.org/ws/2005/04/discovery", NULL, NULL},
{"xmime", "http://tempuri.org/xmime.xsd", NULL, NULL},
{"xop", "http://www.w3.org/2004/08/xop/include", NULL, NULL},
{"tt", "http://www.onvif.org/ver10/schema", NULL, NULL},
{"ns2", "http://docs.oasis-open.org/wsrf/bf-2", NULL, NULL},
{"wsa", "http://schemas.xmlsoap.org/ws/2004/08/addressing", NULL, NULL},
{"ns3", "http://docs.oasis-open.org/wsn/t-1", NULL, NULL},
{"ns10", "http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding", NULL, NULL},
{"ns11", "http://www.onvif.org/ver10/events/wsdl/EventBinding", NULL, NULL},
{"tev", "http://www.onvif.org/ver10/events/wsdl", NULL, NULL},
{"ns12", "http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding", NULL, NULL},
{"ns13", "http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding", NULL, NULL},
{"ns14", "http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding", NULL, NULL},
{"ns15", "http://www.onvif.org/ver10/events/wsdl/PullPointBinding", NULL, NULL},
{"ns16", "http://www.onvif.org/ver10/events/wsdl/CreatePullPointBinding", NULL, NULL},
{"ns17", "http://www.onvif.org/ver10/events/wsdl/PausableSubscriptionManagerBinding", NULL, NULL},
{"ns1", "http://docs.oasis-open.org/wsn/b-2", NULL, NULL},
{"ns18", "http://www.onvif.org/ver10/network/wsdl/RemoteDiscoveryBinding", NULL, NULL},
{"ns19", "http://www.onvif.org/ver10/network/wsdl/DiscoveryLookupBinding", NULL, NULL},
{"dn", "http://www.onvif.org/ver10/network/wsdl", NULL, NULL},
{"ns8", "http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding", NULL, NULL},
{"ns9", "http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding", NULL, NULL},
{"tan", "http://www.onvif.org/ver20/analytics/wsdl", NULL, NULL},
{"tds", "http://www.onvif.org/ver10/device/wsdl", NULL, NULL},
{"timg", "http://www.onvif.org/ver20/imaging/wsdl", NULL, NULL},
{"tptz", "http://www.onvif.org/ver20/ptz/wsdl", NULL, NULL},
{"trt", "http://www.onvif.org/ver10/media/wsdl", NULL, NULL},
{NULL, NULL, NULL, NULL}
};
soap->namespaces = namespaces; } };
/// Destructor frees deserialized data and soap engine context
virtual ~NotificationConsumerBinding() { if (soap) { soap_destroy(soap); soap_end(soap); soap_free(soap); } };
/// Invoke 'Notify' of service 'NotificationConsumerBinding' and return error code (or SOAP_OK)
virtual int __ns14__Notify(_ns1__Notify *ns1__Notify) { return soap ? soap_send___ns14__Notify(soap, endpoint, NULL, ns1__Notify) : SOAP_EOM; };
};
#endif
|
[
"yang.haifeng@zbitcloud.com"
] |
yang.haifeng@zbitcloud.com
|
714c85ed7dce6a3900b42db17054a51b8ae70040
|
334b8b7fb3789c29175e83e39744791fbff99667
|
/Ispiti/OO1-Jan-2016/Filter.cpp
|
8780644daaf54151db423bba332afdadd6d5c357
|
[] |
no_license
|
vomindoraan/SI2OO1
|
44798c7968581684e7e8c79b1e85d5540834e2ba
|
1de789c4c31efa470ef59851caa94f41851af888
|
refs/heads/master
| 2021-01-09T05:51:24.913514
| 2018-11-29T23:08:50
| 2018-11-29T23:19:13
| 80,846,050
| 2
| 5
| null | 2017-12-03T22:20:05
| 2017-02-03T16:19:12
|
C++
|
UTF-8
|
C++
| false
| false
| 272
|
cpp
|
#include "Filter.h"
void Filter::primeni(Galerija& g) const
{
for (auto* p = g.prvi_; p != nullptr; p = p->sled) {
auto& sl = p->pod;
for (unsigned i = 0; i < sl.brVrsta(); ++i) {
for (unsigned j = 0; j < sl.brKolona(); ++j) {
obradi(sl(i, j));
}
}
}
}
|
[
"vomindoraan@gmail.com"
] |
vomindoraan@gmail.com
|
9bebd75d1fabe7319295f93f6375fafb9deac00b
|
44becf050871ee1a1231a7f4d37c8974cb97ddc1
|
/SP800-90B_EntropyAssessment/cpp/restart_main.cpp
|
f0e2aedf85cd7dbd8295df144f06712987b96135
|
[] |
no_license
|
ziyuzhouzzy/sp800b
|
469d7cea28faeebb69e4e9ce119ba0e16011e286
|
1cc103629b38a3e6e5df81ca7c26f1a5e42870c2
|
refs/heads/main
| 2023-03-31T07:07:47.359373
| 2021-03-31T21:02:02
| 2021-03-31T21:02:02
| 353,487,659
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 14,526
|
cpp
|
#include "shared/utils.h"
#include "shared/most_common.h"
#include "shared/lrs_test.h"
#include "non_iid/collision_test.h"
#include "non_iid/lz78y_test.h"
#include "non_iid/multi_mmc_test.h"
#include "non_iid/lag_test.h"
#include "non_iid/multi_mcw_test.h"
#include "non_iid/compression_test.h"
#include "non_iid/markov_test.h"
#include <getopt.h>
//Each test has a targeted chance of roughly 0.000005, and we need to witness at least 5 failures, so this should be no less than 1000000
#define SIMULATION_ROUNDS 5000000
[[ noreturn ]] void print_usage(){
printf("Usage is: ea_restart [-i|-n] [-v] <file_name> [bits_per_symbol] <H_I>\n\n");
printf("\t <file_name>: Must be relative path to a binary file with at least 1 million entries (samples),\n");
printf("\t and in the \"row dataset\" format described in SP800-90B Section 3.1.4.1.\n");
printf("\t [bits_per_symbol]: Must be between 1-8, inclusive.\n");
printf("\t <H_I>: Initial entropy estimate.\n");
printf("\t [-i|-n]: '-i' for IID data, '-n' for non-IID data. Non-IID is the default.\n");
printf("\t -v: Optional verbosity flag for more output.\n");
printf("\n");
printf("\t Restart samples are assumed to be packed into 8-bit values, where the rightmost 'bits_per_symbol'\n");
printf("\t bits constitute the sample.\n");
printf("\n");
printf("\t This program performs restart testing as described in Restart Tests (Section 3.1.4). The data\n");
printf("\t consists of 1000 restarts, each with 1000 samples. The data is converted to rows and columns\n");
printf("\t as described Section 3.1.4.1. The sanity check (Section 3.1.4.3) and the validation test\n");
printf("\t (Section 3.1.4.2) are performed on this data.\n");
printf("\n");
printf("\t If the restart data passes the sanity check and validation test, this program returns\n");
printf("\t min(H_r, H_c, H_I), which is either the validated entropy assessment or used to derive\n");
printf("\t 'h_in' if conditioning is used (Section 3.1.5).\n");
printf("\n");
exit(-1);
}
//Here, we simulate a sort of "worst case" for this test, where there are a maximal number of symbols with maximal probability,
//and the rest is distributed to the other symbols
long int simulateCount(int k, double H_I, uint64_t *xoshiro256starstarState) {
long int counts[256];
int current_symbol;
int k_max;
long int max_count=0;
double p, max_cutoff, p_min, cur_rand;
assert(k<=256);
p = pow(2.0, -H_I);
k_max = floor(1.0/p);
assert(k_max <= k);
if(k>k_max) {
max_cutoff = p * k_max;
p_min = (1.0-max_cutoff)/(k-k_max);
} else {
max_cutoff = 1.0;
p_min = 0.0;
}
for(int j=0; j<k; j++) counts[j] = 0;
for(int j=0; j<1000; j++) {
cur_rand = randomUnit(xoshiro256starstarState);
if(cur_rand < max_cutoff) {
current_symbol = floor(cur_rand / p);
assert((current_symbol >= 0) && (current_symbol < k_max));
} else {
current_symbol = floor((cur_rand-max_cutoff) / p_min) + k_max;
assert((current_symbol >= k_max) && (current_symbol < k));
}
counts[current_symbol]++;
}
for(int j=0; j<k; j++) {
if(max_count < counts[j]) max_count = counts[j];
}
return max_count;
}
//This returns the bound (cutoff) for the test. Counts equal to this value should pass.
//Larger values should fail.
long int simulateBound(double alpha, int k, double H_I){
uint64_t xoshiro256starstarMainSeed[4];
vector<long int> results(SIMULATION_ROUNDS, -1);
long int returnIndex;
assert((k>1) && (k<=256));
seed(xoshiro256starstarMainSeed);
#pragma omp parallel
{
uint64_t xoshiro256starstarSeed[4];
memcpy(xoshiro256starstarSeed, xoshiro256starstarMainSeed, sizeof(xoshiro256starstarMainSeed));
//Cause the RNG to jump omp_get_thread_num() * 2^128 calls
xoshiro_jump(omp_get_thread_num(), xoshiro256starstarSeed);
#pragma omp for
for(int i = 0; i < SIMULATION_ROUNDS; i++){
results[i] = simulateCount(k, H_I, xoshiro256starstarSeed);
}
}
sort(results.begin(), results.end());
assert((results[0]>=(1000/k)) && (results[0] <= 1000));
assert((results[SIMULATION_ROUNDS-1]>=(1000/k)) && (results[SIMULATION_ROUNDS-1] <= 1000));
assert(results[0] <= results[SIMULATION_ROUNDS-1]);
returnIndex = ((size_t)floor((1.0 - alpha) * ((double)SIMULATION_ROUNDS))) - 1;
assert((returnIndex >= 0) && (returnIndex < SIMULATION_ROUNDS));
return(results[returnIndex]);
}
int main(int argc, char* argv[]){
bool iid;
int verbose = 0;
char *file_path;
int r = 1000, c = 1000;
int counts[256];
long int X_cutoff;
long i, j, X_i, X_r, X_c, X_max;
double H_I, H_r, H_c, alpha, ret_min_entropy;
byte *rdata, *cdata;
data_t data;
int opt;
iid = false;
data.word_size = 0;
while ((opt = getopt(argc, argv, "inv")) != -1) {
switch(opt) {
case 'i':
iid = true;
break;
case 'n':
iid = false;
break;
case 'v':
verbose++;
break;
default:
print_usage();
}
}
argc -= optind;
argv += optind;
// Parse args
if((argc != 3) && (argc != 2)){
printf("Incorrect usage.\n");
print_usage();
}
// get filename
file_path = argv[0];
argv++;
argc--;
if(argc == 2) {
// get bits per word
data.word_size = atoi(argv[0]);
if(data.word_size < 1 || data.word_size > 8){
printf("Invalid bits per symbol.\n");
print_usage();
}
argv++;
argc--;
}
// get H_I
H_I = atof(argv[0]);
if(H_I < 0){
printf("H_I must be nonnegative.\n");
print_usage();
}
if(verbose > 0) printf("Opening file: '%s'\n", file_path);
if(!read_file(file_path, &data)){
printf("Error reading file.\n");
print_usage();
}
if(verbose > 0) printf("Loaded %ld samples made up of %d distinct %d-bit-wide symbols.\n", data.len, data.alph_size, data.word_size);
if(H_I > data.word_size) {
printf("H_I must be at most 'bits_per_symbol'.\n");
free_data(&data);
exit(-1);
}
if(data.alph_size <= 1){
printf("Symbol alphabet consists of 1 symbol. No entropy awarded...\n");
free_data(&data);
exit(-1);
}
if(data.len != MIN_SIZE){
printf("\n*** Error: data does not contain %d samples ***\n\n", MIN_SIZE);
exit(-1);
}
if(verbose > 0) {
if(data.alph_size < (1 << data.word_size)) printf("\nSymbols have been translated.\n\n");
}
rdata = data.symbols;
cdata = (byte*)malloc(data.len);
if(cdata == NULL){
printf("Error: failure to initialize memory for columns\n");
exit(-1);
}
printf("H_I: %f\n", H_I);
alpha = 1 - exp(log(0.99)/(r + c));
X_cutoff = simulateBound(alpha, data.alph_size, H_I);
printf("ALPHA: %.17g, X_cutoff: %ld\n", alpha, X_cutoff);
// get maximum row count
X_r = 0;
for(i = 0; i < r; i++){ //row
memset(counts, 0, 256*sizeof(int));
X_i = 0;
for(j = 0; j < c; j++){//column
//[i*r+j] is row i, column j
//So, we're fixing a row, and then iterate through various columns
if(++counts[rdata[i*r+j]] > X_i) X_i = counts[rdata[i*r+j]];
}
if(X_i > X_r) X_r = X_i;
}
// construct column data from row data and get maximum column count
X_c = 0;
for(j = 0; j < c; j++){ //columns
memset(counts, 0, 256*sizeof(int));
X_i = 0;
for(i = 0; i < r; i++){
//[i*r+j] is row i, column j
//So, we're fixing a column and iterating through various rows
cdata[j*c+i] = rdata[i*r+j];
if(++counts[cdata[j*c+i]] > X_i) X_i = counts[cdata[j*c+i]];
}
if(X_i > X_c) X_c = X_i;
}
// perform sanity check on rows and columns of restart data (Section 3.1.4.3)
X_max = max(X_r, X_c);
printf("X_max: %ld\n", X_max);
if(X_max > X_cutoff){
printf("\n*** Restart Sanity Check Failed ***\n");
exit(-1);
}
else if(verbose> 0) printf("\nRestart Sanity Check Passed...\n");
// The maximum min-entropy is -log2(1/2^word_size) = word_size
H_c = data.word_size;
H_r = data.word_size;
if(iid) printf("\nRunning IID tests...\n\n");
else printf("\nRunning non-IID tests...\n\n");
printf("Running Most Common Value Estimate...\n");
// Section 6.3.1 - Estimate entropy with Most Common Value
ret_min_entropy = most_common(rdata, data.len, data.alph_size, verbose, "Literal");
if(verbose > 0) printf("\tMost Common Value Estimate (Rows) = %f / %d bit(s)\n", ret_min_entropy, data.word_size);
H_r = min(ret_min_entropy, H_r);
ret_min_entropy = most_common(cdata, data.len, data.alph_size, verbose, "Literal");
if(verbose > 0) printf("\tMost Common Value Estimate (Cols) = %f / %d bit(s)\n", ret_min_entropy, data.word_size);
H_c = min(ret_min_entropy, H_c);
if(!iid){
if(data.alph_size == 2){
printf("\nRunning Entropic Statistic Estimates (bit strings only)...\n");
// Section 6.3.2 - Estimate entropy with Collision Test (for bit strings only)
ret_min_entropy = collision_test(rdata, data.len, verbose, "Literal");
if(verbose > 0) printf("\tCollision Test Estimate (Rows) = %f / 1 bit(s)\n", ret_min_entropy);
H_r = min(ret_min_entropy, H_r);
ret_min_entropy = collision_test(cdata, data.len, verbose, "Literal");
if(verbose > 0) printf("\tCollision Test Estimate (Cols) = %f / 1 bit(s)\n", ret_min_entropy);
H_c = min(ret_min_entropy, H_c);
// Section 6.3.3 - Estimate entropy with Markov Test (for bit strings only)
ret_min_entropy = markov_test(rdata, data.len, verbose, "Literal");
if(verbose > 0) printf("\tMarkov Test Estimate (Rows) = %f / 1 bit(s)\n", ret_min_entropy);
H_r = min(ret_min_entropy, H_r);
ret_min_entropy = markov_test(cdata, data.len, verbose, "Literal");
if(verbose > 0) printf("\tMarkov Test Estimate (Cols) = %f / 1 bit(s)\n", ret_min_entropy);
H_c = min(ret_min_entropy, H_c);
// Section 6.3.4 - Estimate entropy with Compression Test (for bit strings only)
ret_min_entropy = compression_test(rdata, data.len, verbose, "Literal");
if(ret_min_entropy >= 0){
if(verbose > 0) printf("\tCompression Test Estimate (Rows) = %f / 1 bit(s)\n", ret_min_entropy);
H_r = min(ret_min_entropy, H_r);
}
ret_min_entropy = compression_test(cdata, data.len, verbose, "Literal");
if(ret_min_entropy >= 0){
if(verbose > 0) printf("\tCompression Test Estimate (Cols) = %f / 1 bit(s)\n", ret_min_entropy);
H_c = min(ret_min_entropy, H_c);
}
}
printf("\nRunning Tuple Estimates...\n");
// Section 6.3.5 - Estimate entropy with t-Tuple Test
double row_t_tuple_res, row_lrs_res;
double col_t_tuple_res, col_lrs_res;
SAalgs(rdata, data.len, data.alph_size, row_t_tuple_res, row_lrs_res, verbose, "Literal");
SAalgs(cdata, data.len, data.alph_size, col_t_tuple_res, col_lrs_res, verbose, "Literal");
if(verbose > 0) printf("\tT-Tuple Test Estimate (Rows) = %f / %d bit(s)\n", row_t_tuple_res, data.word_size);
H_r = min(row_t_tuple_res, H_r);
if(verbose > 0) printf("\tT-Tuple Test Estimate (Cols) = %f / %d bit(s)\n", col_t_tuple_res, data.word_size);
H_c = min(col_t_tuple_res, H_c);
// Section 6.3.6 - Estimate entropy with LRS Test
if(verbose > 0) printf("\tLRS Test Estimate (Rows) = %f / %d bit(s)\n", row_lrs_res, data.word_size);
H_r = min(row_lrs_res, H_r);
if(verbose > 0) printf("\tLRS Test Estimate (Cols) = %f / %d bit(s)\n", col_lrs_res, data.word_size);
H_c = min(col_lrs_res, H_c);
printf("\nRunning Predictor Estimates...\n");
// Section 6.3.7 - Estimate entropy with Multi Most Common in Window Test
ret_min_entropy = multi_mcw_test(rdata, data.len, data.alph_size, verbose, "Literal");
if(ret_min_entropy >= 0){
if(verbose > 0) printf("\tMulti Most Common in Window (MultiMCW) Prediction Test Estimate (Rows) = %f / %d bit(s)\n", ret_min_entropy, data.word_size);
H_r = min(ret_min_entropy, H_r);
}
ret_min_entropy = multi_mcw_test(cdata, data.len, data.alph_size, verbose, "Literal");
if(ret_min_entropy >= 0){
if(verbose > 0) printf("\tMulti Most Common in Window (MultiMCW) Prediction Test Estimate (Cols) = %f / %d bit(s)\n", ret_min_entropy, data.word_size);
H_c = min(ret_min_entropy, H_c);
}
// Section 6.3.8 - Estimate entropy with Lag Prediction Test
ret_min_entropy = lag_test(rdata, data.len, data.alph_size, verbose, "Literal");
if(ret_min_entropy >= 0){
if(verbose > 0) printf("\tLag Prediction Test Estimate (Rows) = %f / %d bit(s)\n", ret_min_entropy, data.word_size);
H_r = min(ret_min_entropy, H_r);
}
ret_min_entropy = lag_test(cdata, data.len, data.alph_size, verbose, "Literal");
if(ret_min_entropy >= 0){
if(verbose > 0) printf("\tLag Prediction Test Estimate (Cols) = %f / %d bit(s)\n", ret_min_entropy, data.word_size);
H_c = min(ret_min_entropy, H_c);
}
// Section 6.3.9 - Estimate entropy with Multi Markov Model with Counting Test (MultiMMC)
ret_min_entropy = multi_mmc_test(rdata, data.len, data.alph_size, verbose, "Literal");
if(ret_min_entropy >= 0){
if(verbose > 0) printf("\tMulti Markov Model with Counting (MultiMMC) Prediction Test Estimate (Rows) = %f / %d bit(s)\n", ret_min_entropy, data.word_size);
H_r = min(ret_min_entropy, H_r);
}
ret_min_entropy = multi_mmc_test(cdata, data.len, data.alph_size, verbose, "Literal");
if(ret_min_entropy >= 0){
if(verbose > 0) printf("\tMulti Markov Model with Counting (MultiMMC) Prediction Test Estimate (Cols) = %f / %d bit(s)\n", ret_min_entropy, data.word_size);
H_c = min(ret_min_entropy, H_c);
}
// Section 6.3.10 - Estimate entropy with LZ78Y Test
ret_min_entropy = LZ78Y_test(rdata, data.len, data.alph_size, verbose, "Literal");
if(ret_min_entropy >= 0){
if(verbose > 0) printf("\tLZ78Y Prediction Test Estimate (Rows) = %f / %d bit(s)\n", ret_min_entropy, data.word_size);
H_r = min(ret_min_entropy, H_r);
}
ret_min_entropy = LZ78Y_test(cdata, data.len, data.alph_size, verbose, "Literal");
if(ret_min_entropy >= 0){
if(verbose > 0) printf("\tLZ78Y Prediction Test Estimate (Cols) = %f / %d bit(s)\n", ret_min_entropy, data.word_size);
H_c = min(ret_min_entropy, H_c);
}
}
printf("\n");
printf("H_r: %f\n", H_r);
printf("H_c: %f\n", H_c);
printf("H_I: %f\n", H_I);
printf("\n");
if(min(H_r, H_c) < H_I/2.0) printf("*** min(H_r, H_c) < H_I/2, Validation Testing Failed ***\n");
else{
printf("Validation Test Passed...\n\n");
printf("min(H_r, H_c, H_I): %f\n\n", min(min(H_r, H_c), H_I));
}
free(cdata);
free_data(&data);
return 0;
}
|
[
"brittanyziyu@gmail.com"
] |
brittanyziyu@gmail.com
|
1a612c10f6a59b36aa9f8141aa76a4c05fb89914
|
238e46a903cf7fac4f83fa8681094bf3c417d22d
|
/OCC/opencascade-7.2.0/x64/debug/inc/BinMXCAFDoc_DimTolDriver.hxx
|
eb3f93bb67057a74f4d90280db3fe51bfc14b9d3
|
[
"BSD-3-Clause"
] |
permissive
|
baojunli/FastCAE
|
da1277f90e584084d461590a3699b941d8c4030b
|
a3f99f6402da564df87fcef30674ce5f44379962
|
refs/heads/master
| 2023-02-25T20:25:31.815729
| 2021-02-01T03:17:33
| 2021-02-01T03:17:33
| 268,390,180
| 1
| 0
|
BSD-3-Clause
| 2020-06-01T00:39:31
| 2020-06-01T00:39:31
| null |
UTF-8
|
C++
| false
| false
| 1,949
|
hxx
|
// Created on: 2008-12-10
// Created by: Pavel TELKOV
// Copyright (c) 2008-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BinMXCAFDoc_DimTolDriver_HeaderFile
#define _BinMXCAFDoc_DimTolDriver_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <BinMDF_ADriver.hxx>
#include <Standard_Boolean.hxx>
#include <BinObjMgt_RRelocationTable.hxx>
#include <BinObjMgt_SRelocationTable.hxx>
class CDM_MessageDriver;
class TDF_Attribute;
class BinObjMgt_Persistent;
class BinMXCAFDoc_DimTolDriver;
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_DimTolDriver, BinMDF_ADriver)
class BinMXCAFDoc_DimTolDriver : public BinMDF_ADriver
{
public:
Standard_EXPORT BinMXCAFDoc_DimTolDriver(const Handle(CDM_MessageDriver)& theMsgDriver);
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Paste (const BinObjMgt_Persistent& theSource, const Handle(TDF_Attribute)& theTarget, BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource, BinObjMgt_Persistent& theTarget, BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_DimTolDriver,BinMDF_ADriver)
protected:
private:
};
#endif // _BinMXCAFDoc_DimTolDriver_HeaderFile
|
[
"l”ibaojunqd@foxmail.com“"
] |
l”ibaojunqd@foxmail.com“
|
66aa3e1f1521d2166993914efd6283e3580a308d
|
d8244a2aae26304344a8757c14ab06f6d6fbad6c
|
/src/viridian/Mouse.h
|
a5a392bad2d8734bbb1bf6946a83982cefd822e7
|
[] |
no_license
|
phinion/EngineDemo
|
22c3533778d3e5f1e32ffcd452e9c01690fbe045
|
88380c07564a99e6770b01cd9c4b78ce0e1a391e
|
refs/heads/master
| 2022-12-10T21:52:28.618722
| 2020-09-08T20:46:07
| 2020-09-08T20:46:07
| 280,017,202
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 129
|
h
|
namespace viridian
{
class Mouse
{
public:
void tick();
int getMouseX();
int getMouseY();
private:
int x, y;
};
}
|
[
"yashvishwanath@yahoo.com"
] |
yashvishwanath@yahoo.com
|
e33f1a7612bc59204f05e5d3e2147155ddb9a65a
|
db3e5f6aec2c7990499208928f175e3555fefbed
|
/trunk/VBF/c++/Cpp/demo/Windows/antlr4-cpp-demo/inc/VbfCommon.h
|
b29ebbd8817269beea80a9849d2caca429134e5f
|
[] |
no_license
|
296066067/TestVBF
|
79417eee0ed847728b6811dc2a21dae4128b3c64
|
db90cc4eec77dc1f2b9ae959fa321bb345cd55bf
|
refs/heads/master
| 2022-12-31T12:28:13.692242
| 2020-10-21T07:42:35
| 2020-10-21T07:42:35
| 303,955,655
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,048
|
h
|
/**
* Copyright (c) 2020, Sumarte Technology, All right reserved
*
* @file: VbfCommon.h
* The file is used to describe the common definition of vbf file.
*
* @date 07/10/2020
* @author chencheng@smarte.com
*/
#ifndef _VBFCOMMON_H_
#define _VBFCOMMON_H_
#include <stdint.h>
#include <string>
#include <deque>
#include <iostream>
/**
* The available value of sw part type.
*/
typedef enum _SwPartType_E
{
InvalidSwPartType,
CARCFG,
CUSTOM,
DATA,
EXE,
GBL,
SBL,
SIGCFG,
TEST
} SwPartType_E;
/**
* The available value of frame format.
*/
typedef enum _FrameFormat_E
{
InvalidFrameFormat,
CAN_STANDARD,
CAN_EXTENDED
} FrameFormat_E;
/**
* The available value of content validity.
*/
typedef enum _ValidityOfContent_E
{
NonExistent,
Existent,
ParseError,
ExistentAndValid,
ExistentButInvalid
} ValidityOfContent_E;
/**
* The defination of block.
*/
typedef struct _Block_T
{
uint32_t startAddress;
uint32_t length;
} Block_T;
#endif // !_VBFCOMMON_H_
/** End copyright (c) 2020, Sumarte Technology, All right reserved */
|
[
"chencheng@sumarte.com"
] |
chencheng@sumarte.com
|
2f35a72cecefc2a4c1503a8682b507601f36b1b1
|
c13a6da839be62f77af883dfd04ef04c1b3f687f
|
/haar_demo.cpp
|
bbbf76e60c55f284836121a7cf14880ff6b837e3
|
[] |
no_license
|
jwbowler/mituav-opencv-demo
|
06118ad28d759e8215d5f6803e2830d41617f85f
|
f2bddcf364d85c68d3a46e62e38d3591257b57a6
|
refs/heads/master
| 2016-09-03T03:45:22.474350
| 2013-09-29T19:04:42
| 2013-09-29T19:04:42
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,547
|
cpp
|
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/objdetect/objdetect.hpp>
class ImageConverter {
public:
ImageConverter() : it(nh) {
image_sub = it.subscribe("input_image", 1, &ImageConverter::onNewImageReceived, this);
image_pub = it.advertise("processed_image", 1);
cv::namedWindow("Raw image");
cv::namedWindow("Processed image");
if (!cascade.load("/home/john/uav-ros/src/opencv_demo/src/palm.xml")) {
printf("Error loading cascade XML file\n");
}
}
~ImageConverter() {
cv::namedWindow("Raw image");
cv::namedWindow("Processed image");
}
void onNewImageReceived(const sensor_msgs::ImageConstPtr& msg) {
cv_bridge::CvImagePtr rawImagePtr;
try {
rawImagePtr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
} catch (cv_bridge::Exception& e) {
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
cv_bridge::CvImage processedImage;
processedImage.image = rawImagePtr->image;
// Process the image here
std::vector<cv::Rect> hands;
cvtColor(processedImage.image, processedImage.image, CV_BGR2GRAY );
equalizeHist(processedImage.image, processedImage.image);
cascade.detectMultiScale(processedImage.image, hands, 1.07, 3, CV_HAAR_SCALE_IMAGE, cv::Size(30, 30));
for( int i = 0; i < hands.size(); i++ ) {
cv::Point center(hands[i].x + hands[i].width*0.5, hands[i].y + hands[i].height*0.5);
cv::ellipse(processedImage.image, center, cv::Size( hands[i].width*0.5, hands[i].height*0.5),
0, 0, 360, cv::Scalar(255, 0, 255), 4, 8, 0);
cv::Mat handROI = processedImage.image(hands[i]);
}
if (hands.size() > 0) {
printf("(%d, %d)\n", hands[0].x, hands[0].y);
fflush(stdout);
}
cv::imshow("Raw image", rawImagePtr->image);
cv::imshow("Processed image", processedImage.image);
cv::waitKey(3);
image_pub.publish(processedImage.toImageMsg());
}
private:
ros::NodeHandle nh;
image_transport::ImageTransport it;
image_transport::Subscriber image_sub;
image_transport::Publisher image_pub;
cv::CascadeClassifier cascade;
};
int main(int argc, char** argv) {
ros::init(argc, argv, "image_converter");
ImageConverter ic;
ros::spin();
return 0;
}
|
[
"jwbowler@gmail.com"
] |
jwbowler@gmail.com
|
ce124295ec5225a3921f6480a7a82206edc114c8
|
40c8612264d982c4564b4ea7d6f5c26fb24e5df6
|
/ComputerGraphics/project1/geometricShapes0.cpp
|
54c363615fa4fcfd7cd1dcc4afd797548edcdbdf
|
[] |
no_license
|
zpak96/ClassWork
|
b7f7efb6bd339aa2d6f7767477086e31a3313542
|
416f6e6536c7e7c3e564ab95298c22c0c10b492d
|
refs/heads/master
| 2022-04-08T15:59:54.840887
| 2019-12-28T20:13:15
| 2019-12-28T20:13:15
| 104,949,303
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,516
|
cpp
|
#define _USE_MATH_DEFINES
#include <cmath>
#include <GL/glut.h>
#include <iostream>
#include <map>
using namespace std;
int nos = 3;
double angle, increment, a, b;
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.5, 0.5, 0.0);
glBegin(GL_POLYGON);
angle = ((360 / nos) * M_PI) / 180;
increment = angle; // this is how we travel around the unit circle.
for (int i =0; i < nos; i++) {
//calculate x and y, then add to dictionary
a = cos(angle); //x
b = sin(angle); //y
glVertex2f(a,b);
angle += increment; //Move to the next point
}
glEnd();
//Flush drawing to screen
glFlush();
}
void keyboard(unsigned char key, int x, int y) {
switch (key) {
case 27:
exit(EXIT_SUCCESS);
case 'q':
nos = 3;
break;
//change number of vertices and pass to calculate
case 'w':
nos = 4;
break;
//change number of vertices
case 'e':
nos = 5;
break;
//change number of vertices
case 'r':
nos = 6;
break;
//change number of vertices
case 't':
nos = 8;
break;
//change number of vertices
case 'y':
nos = 9;
break;
//change number of vertices
}
}
int main(int argc, char** argv) {
glutInit(&argc,argv);
glutCreateWindow("Geometric Shapes");
glutKeyboardFunc(keyboard);
glutIdleFunc(display); //REFERENCE THE DISPLAY FUNCTION HERE
glutMainLoop();
return (EXIT_SUCCESS);
}
//g++ geometricShapes0.cpp -o geo -lglut -lGLU -lGL
|
[
"noreply@github.com"
] |
zpak96.noreply@github.com
|
16d7bbe107243bdb60916c4a3220f21404e3619d
|
0726c8bd994943bcde43443b3a76b94ede9ad845
|
/DesktopApp/Fingerprint/myfingerprint.cpp
|
cd964ba6d917db8b0a6c8653382da9db4dda68c5
|
[
"MIT"
] |
permissive
|
pablovicente/fingerprint-payment-system
|
b1eed039fd62cdab3cdae8e60fe1bd1e9dc69a1e
|
c8e7eb4ca6059c9240e6f9150237d02d435e40c4
|
refs/heads/master
| 2021-04-29T04:31:13.897824
| 2017-01-04T08:24:55
| 2017-01-04T08:24:55
| 77,994,749
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 131
|
cpp
|
#include "myfingerprint.h"
MyFingerprint::MyFingerprint()
{
}
void MyFingerprint::clearMinutiae(void)
{
minutiaes.clear();
}
|
[
"pablo@MacBook-Pro-de-Pablo.local"
] |
pablo@MacBook-Pro-de-Pablo.local
|
e16ecb9adf68a75858100ac1346e2e62926d54a0
|
9264ad419b73883a69fb02688ddc3ee40c53edbd
|
/SPOJ/AGGRCOW.cpp
|
cb09b52d2678174616604f6cdc337f047a0f9841
|
[] |
no_license
|
manish1997/Competitive-Programming
|
6d5e7fb6081d1a09f8658638bddcd1c72495c396
|
b7048f770f7db8ac0bc871d59f1973482f79668f
|
refs/heads/master
| 2021-01-13T04:31:13.082435
| 2020-03-22T20:32:04
| 2020-03-22T20:32:04
| 79,900,759
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 729
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define slld(n) scanf("%lld", &n)
#define rep(i,n) for(int i=0; i<n; i++)
ll C,n;
ll arr[100001];
bool check(ll gap){
ll start=arr[0];
ll end=arr[n-1];
ll cows=C-2;
for(int i=1; i<n && cows; i++){
if((arr[i]-start)>=gap){
start=arr[i];
cows--;
};
};
if(!cows && (end-start)>=gap) return true;
return false;
};
ll answer(){
ll start=0;
ll end=arr[n-1];
while(start<=end){
int mid=(start+end)/2;
if(check(mid)){
start=mid+1;
}
else{
end=mid-1;
};
};
return (start-1);
};
int main() {
ll t;
slld(t);
while(t--){
slld(n);slld(C);
rep(i, n) slld(arr[i]);
sort(arr, arr+n);
cout << answer() << endl;
};
return 0;
}
|
[
"noreply@github.com"
] |
manish1997.noreply@github.com
|
f1ea78d2faa3c94c85d2788085fb781a6174e5a8
|
41b3a72244fa5532cab03618c882af96d83490d6
|
/CsInteractive/Source/CsInteractiveEditor/Public/DetailCustomizations/EnumStruct/Interaction/ECsInteractionCustomization.h
|
03599377e9beab1efa7d231817c2133f266ffcae
|
[
"MIT"
] |
permissive
|
closedsum/core
|
83fe249ef3fd8f543b589b843e85a767820b8ebc
|
12c3ab8d3a43d58d431bfd4a7563fdb4943f4a62
|
refs/heads/master
| 2023-08-30T00:48:34.572460
| 2023-08-30T00:39:11
| 2023-08-30T00:39:11
| 102,293,517
| 3
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 751
|
h
|
// Copyright 2017-2019 Closed Sum Games, LLC. All Rights Reserved.
#pragma once
#include "DetailCustomizations/EnumStruct/ECsEnumStructCustomization.h"
/**
* Customizes a FECsInteraction property to use a dropdown
*/
class CSINTERACTIVEEDITOR_API FECsInteractionCustomization : public FECsEnumStructCustomization
{
private:
typedef FECsEnumStructCustomization Super;
public:
FECsInteractionCustomization();
public:
static TSharedRef<IPropertyTypeCustomization> MakeInstance();
protected:
virtual void SetPropertyHandles(TSharedRef<IPropertyHandle> StructPropertyHandle) override;
virtual void SetEnumWithDisplayName(const FString& DisplayName) override;
virtual void GetDisplayNamePropertyValue(FString& OutDisplayName) const override;
};
|
[
"beditheory@gmail.com"
] |
beditheory@gmail.com
|
a5f477fcd1689a9fcfe364111e5984ec9395e30d
|
ebb72953dfb52c1984d5e2649de3ac2663e5905c
|
/LBEP 5_1.cpp
|
ea8ec21a133018ee3f84a869f73e18d7aa9ea806
|
[] |
no_license
|
NguyenSon009/LBEP
|
763c890f5071c2fd442f395d197f96a42ff229b8
|
14fff7c4eec5429ab07c6fb73f5e9083d587c3fa
|
refs/heads/main
| 2023-04-26T07:44:20.347422
| 2021-05-27T07:53:19
| 2021-05-27T07:53:19
| 367,643,589
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 194
|
cpp
|
#include <stdio.h>
int main(){
int n;
printf("nhap n:");
scanf("%d",&n);
if(n<0){
printf("nhap lai");
}else{
int i;
for(i=0 ; i<n ; i+=2){
printf(" %d:",i);
}
}
}
|
[
"noreply@github.com"
] |
NguyenSon009.noreply@github.com
|
4cce036cb1a7d93736b9a399ab6619a25c926f3e
|
7dfbd9750d765ff0e254c0056702987a08a00cca
|
/lab9_q6.cpp
|
5abc4a9f883099b669d29a8d35237f07f60fa0ef
|
[] |
no_license
|
TanishkaYadav/cs141
|
c124dc94910ea2d09590391e07f9946173ab562d
|
0888c74276c5d7d1ee30622455e0c7f62c2bd494
|
refs/heads/master
| 2020-03-25T11:07:33.632919
| 2018-11-18T13:15:59
| 2018-11-18T13:15:59
| 143,719,449
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 571
|
cpp
|
#include <iostream>
using namespace std;
//function
int countEven(int* p,int size){
int count=0;
for(int i=0;i<size;i++)
{
if(*(p+i)%2==0)//conditions to get a even number
{
count++;
}
}
return count;
}
int main(){
int size;
cout<<"Enter size of the array"<<endl;
cin>>size;
int ar[size];
cout<<"Enter input to array"<<endl;
for(int i=0;i<size;i++)
{
cin>>ar[i];
}
int* p=&ar[0];// output of number of even numbers
cout<<"No. of even numbers:"<<countEven(p,size);
}
|
[
"noreply@github.com"
] |
TanishkaYadav.noreply@github.com
|
8444b37dd13eba34b8491b96181aafbd55d53200
|
25b122c485be841c09616b250781aeb305b2dcd4
|
/finished/350.cpp
|
61dec56b3251d5f16cf4f9fb47d8763c41b658a5
|
[] |
no_license
|
TXZdream/leetcode
|
765086672ae5130c9fc8a8bf2b138bc0447b0c33
|
e135a90e60a70e8a754551bb286a53d7cd2f49da
|
refs/heads/master
| 2020-03-23T17:48:40.081254
| 2019-07-08T12:54:31
| 2019-07-08T12:54:31
| 141,876,570
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 786
|
cpp
|
#include <vector>
#include<algorithm>
using namespace std;
class Solution {
public:
vector<int> intersect(vector<int>& nums1, vector<int>& nums2) {
vector<int> ret;
sort(nums1.begin(), nums1.end());
sort(nums2.begin(), nums2.end());
int index1 = 0, index2 = 0;
while(1) {
if (index1 >= nums1.size() || index2 >= nums2.size()) {
break;
}
if (nums1[index1] == nums2[index2]) {
ret.push_back(nums1[index1]);
index1++;
index2++;
continue;
}
if (nums1[index1] > nums2[index2]) {
index2++;
continue;
}
index1++;
}
return ret;
}
};
|
[
"xuanzhaotang@gmail.com"
] |
xuanzhaotang@gmail.com
|
29992be22864bcd0182252d59ddda8b26d7d1214
|
96bfd3d7c188499434a0e503b06dcf4cf59d50c1
|
/includes/timer.h
|
23d8eab8f6c4fa94c8515abb06abee03be479af6
|
[] |
no_license
|
pawelg89/behavior_detector
|
b07b4e69fe821c479608aa6b441675f1a8850c2d
|
32a2f561d7c603c60a845b5c26cba5b1ea7ee2ff
|
refs/heads/master
| 2020-03-23T18:11:27.860156
| 2019-03-30T16:51:36
| 2019-03-30T16:51:36
| 141,894,605
| 1
| 0
| null | 2018-11-25T17:46:21
| 2018-07-22T12:41:02
|
C++
|
UTF-8
|
C++
| false
| false
| 982
|
h
|
#pragma once
#include <chrono>
#include <cstdlib>
#include <ctime>
#include <string>
namespace bd {
using namespace std::chrono;
/*Class used to measure time elapsed from start to stop. Timer 'start' is set on
* construction */
class Timer {
public:
Timer(bool is_on = true);
~Timer() = default;
/*Set start time*/
void Start();
/*Set stop time*/
void Stop();
/*Print seconds elapsed between start and stop. Start is set to construction
* time so its possible to do:
* Timer obj;
* ... here do something ...
* auto elapsed_time = obj.Elapsed();**/
double Elapsed();
/*Print to LOG directly result of Elapsed()*/
std::string PrintElapsed(const std::string &msg = "", bool new_line = true);
double last_elapsed;
private:
std::string ToString(double duration);
bool is_on_;
high_resolution_clock::time_point start_;
high_resolution_clock::time_point mid_time_;
high_resolution_clock::time_point stop_;
};
} // namespace bd
|
[
"30794662+pawelg89@users.noreply.github.com"
] |
30794662+pawelg89@users.noreply.github.com
|
b92e109d04eef43ee8732c0f5edea8397e025c26
|
e3f96c8785bb6e676a57f857d23ae5e939a44e23
|
/HackerRank/String/HackerRank in a String!.cpp
|
92fa1efed4514af8ed78eca4114234788952e084
|
[] |
no_license
|
JuanDavidSanchezAroca/Competitive-Programing
|
7530ffc78515ad32ea2eeec1e05cc6635fbd44a5
|
079b155f8f0d8a7f62753b07cce993b682e90eaa
|
refs/heads/master
| 2021-01-25T10:56:16.903127
| 2017-10-25T19:53:07
| 2017-10-25T19:53:07
| 93,894,717
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 602
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int LCS(string a,string b){
int m=a.size(),n=b.size();
int dp[m+1][n+1];
for(int i=0; i <= m; i++){
for(int j=0; j <= n; j++){
if(i==0 || j==0){
dp[i][j]=0;
}else if (a[i-1]== b[j-1]){
dp[i][j]=dp[i-1][j-1]+1;
}else{
dp[i][j]= max(dp[i-1][j],dp[i][j-1]);
}
}
}
return dp[m][n];
}
int main(){
string a="hackerrank",b;
int nCasos;
scanf("%d",&nCasos);
while(nCasos--){
cin >> b;
puts(LCS(a,b)==a.size() ? "YES":"NO");
}
return 0;
}
|
[
"noreply@github.com"
] |
JuanDavidSanchezAroca.noreply@github.com
|
41a7500f1970db2b9f4615a956eddc7026dc0f14
|
b517d05dadbeba3365beb1f1365938b421548a85
|
/cpp/sum/recursive_wrapper.hpp
|
44d75bd9fab0611eec8fd20d8764764616957bd7
|
[] |
no_license
|
shayne-fletcher/zen
|
d893219bf95e562c2a8f7234adc08598086f6498
|
5fefe328e223cf650d39e7d9dc14030544bd621b
|
refs/heads/master
| 2023-07-05T21:36:35.241768
| 2023-06-25T18:15:38
| 2023-06-25T18:15:38
| 4,950,943
| 12
| 6
| null | 2021-07-24T17:59:17
| 2012-07-08T23:30:29
|
OCaml
|
UTF-8
|
C++
| false
| false
| 2,087
|
hpp
|
#if !defined (RECURSIVE_WRAPPER_B2AE13A9_EF98_4630_B5C5_54983411750C_H)
# define RECURSIVE_WRAPPER_B2AE13A9_EF98_4630_B5C5_54983411750C_H
// Copyright Eric Friedman, Itay Maman 2002-2003
#include <type_traits>
namespace foo {
template <class T>
class recursive_wrapper;
template <class T>
struct is_recursive_wrapper : std::false_type {};
template <class T>
struct is_recursive_wrapper<recursive_wrapper<T>> : std::true_type {};
template <class T>
struct unwrap_recursive {
typedef T type;
};
template <class T>
struct unwrap_recursive< recursive_wrapper<T> > {
typedef T type;
};
template <class T>
using unwrap_recursive_t = typename unwrap_recursive<T>::type;
template <class T>
class recursive_wrapper {
private:
T* p_;
recursive_wrapper& assign (T const& rhs) { this->get() = rhs; return *this; }
public:
typedef T type;
template <class... Args> recursive_wrapper (Args&&... args) : p_(new T (std::forward<Args>(args)...)) {}
recursive_wrapper (recursive_wrapper const& rhs) : p_ (new T (rhs.get ())) {}
recursive_wrapper (T const& rhs) : p_ (new T (rhs)) {}
recursive_wrapper(recursive_wrapper&& rhs) : p_ (new T (std::move (rhs.get ()))) {}
recursive_wrapper(T&& rhs) : p_ (new T (std::move (rhs))) {}
~recursive_wrapper() { delete p_; }
recursive_wrapper& operator=(recursive_wrapper const& rhs){ return assign (rhs.get()); }
recursive_wrapper& operator=(T const& rhs) { return assign (rhs); }
void swap(recursive_wrapper& rhs) noexcept { std::swap (p_, rhs.p_); }
recursive_wrapper& operator=(recursive_wrapper&& rhs) noexcept { swap (rhs); return *this; }
recursive_wrapper& operator=(T&& rhs) { get() = std::move (rhs); return *this; }
T& get() { return *get_pointer(); }
T const& get() const { return *get_pointer(); }
T* get_pointer() { return p_; }
T const* get_pointer() const { return p_; }
};
template <typename T>
inline void swap(recursive_wrapper<T>& lhs, recursive_wrapper<T>& rhs) noexcept {
lhs.swap(rhs);
}
}//namespace foo
#endif //!defined (RECURSIVE_WRAPPER_B2AE13A9_EF98_4630_B5C5_54983411750C_H)
|
[
"shayne@shaynefletcher.org"
] |
shayne@shaynefletcher.org
|
0c494eef2056f5a3b4c1f1e88c422bd67fea9766
|
58ac7ce414dcbe875e26bb6fae692e3c74f39c4e
|
/chrome/browser/ui/android/infobars/save_password_infobar.cc
|
e4659fc049d1fa5057f13892b6fe2269e6c27192
|
[
"BSD-3-Clause"
] |
permissive
|
markthomas93/tempwork
|
f4ba7b4620c1cb806aef40a66692115140b42c90
|
93c852f3d14c95b2d73077b00e7284ea6f416d84
|
refs/heads/master
| 2021-12-10T10:35:39.230466
| 2016-08-11T12:00:33
| 2016-08-11T12:00:33
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,161
|
cc
|
// Copyright 2015 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/ui/android/infobars/save_password_infobar.h"
#include <utility>
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/memory/ptr_util.h"
#include "jni/SavePasswordInfoBar_jni.h"
SavePasswordInfoBar::SavePasswordInfoBar(
std::unique_ptr<SavePasswordInfoBarDelegate> delegate)
: ConfirmInfoBar(std::move(delegate)) {}
SavePasswordInfoBar::~SavePasswordInfoBar() {
}
base::android::ScopedJavaLocalRef<jobject>
SavePasswordInfoBar::CreateRenderInfoBar(JNIEnv* env) {
using base::android::ConvertUTF16ToJavaString;
using base::android::ScopedJavaLocalRef;
SavePasswordInfoBarDelegate* save_password_delegate =
static_cast<SavePasswordInfoBarDelegate*>(delegate());
ScopedJavaLocalRef<jstring> ok_button_text = ConvertUTF16ToJavaString(
env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK));
ScopedJavaLocalRef<jstring> cancel_button_text = ConvertUTF16ToJavaString(
env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL));
ScopedJavaLocalRef<jstring> message_text = ConvertUTF16ToJavaString(
env, save_password_delegate->GetMessageText());
ScopedJavaLocalRef<jstring> first_run_experience_message =
ConvertUTF16ToJavaString(
env, save_password_delegate->GetFirstRunExperienceMessage());
return Java_SavePasswordInfoBar_show(
env, GetEnumeratedIconId(), message_text.obj(),
save_password_delegate->message_link_range().start(),
save_password_delegate->message_link_range().end(), ok_button_text.obj(),
cancel_button_text.obj(), first_run_experience_message.obj());
}
void SavePasswordInfoBar::OnLinkClicked(JNIEnv* env,
const JavaParamRef<jobject>& obj) {
GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB);
}
std::unique_ptr<infobars::InfoBar> CreateSavePasswordInfoBar(
std::unique_ptr<SavePasswordInfoBarDelegate> delegate) {
return base::WrapUnique(new SavePasswordInfoBar(std::move(delegate)));
}
|
[
"gaoxiaojun@gmail.com"
] |
gaoxiaojun@gmail.com
|
a9fc07e4b5fdd9fe862aabeb7b9b2ef60d6a3208
|
0d127cc37db7197039c77d52637555cb56558850
|
/EX8_1/EX7_1/Main.cpp
|
399df8c874ed9dbfc2bdae03e5ee874258b554ad
|
[] |
no_license
|
ngraham20/CS172-EX08
|
659fee341c89ceffd6117da7e4e82c287154718f
|
df1701b90ef3893d71693fd89f9526ae71594b8c
|
refs/heads/master
| 2021-01-19T21:22:03.095379
| 2017-04-18T17:48:17
| 2017-04-18T17:48:17
| 88,648,861
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,887
|
cpp
|
/**
* Nathaniel Graham
* Recursive Binary Search
* Reading: section 7.3
*/
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <algorithm>
using namespace std;
/**
* Template function for performing the recursive binary search
*/
template <typename T>
int binary_search(const vector<T> &items, int first, int last, T target) {
// SOLVED: Implement recursive binary search
bool found = false;
if (items.at((last - first) / 2) == target && !found)
{
found = true;
return target;
}
if (first == last - 1 && !found)
{
return -1;
}
if (items.at((last + first) / 2) > target && !found)
{
return binary_search(items, first, ((last + first) / 2), target);
}
if (items.at((last+first)/2) < target && !found)
{
return binary_search(items, ((last + first) / 2), last, target);
}
return -1;
}
/**
* Template function for invoking the recursive binary search function.
* This is the function a user calls.
*/
template <typename T>
int binary_search(const vector<T> &items, T target) {
return binary_search(items, 0, items.size() - 1, target);
}
int main()
{
/** TEST */
vector<int> haystack;
srand(1);
for (int i = 0; i < 100000; ++i) // initialize the vector with random values
haystack.push_back(rand());
sort(haystack.begin(), haystack.end()); // sort the contents of the vector
bool retryflag = true;
do {
int needle;
cout << "Enter a number to search for [-1 to exit]: ";
cin >> needle; // get the value to search for in the vector
if (needle == -1) {
retryflag = false; // time to exit
} else {
int idx = binary_search(haystack, needle); // search for the needle in the haystack
if (idx != -1) // found the index where the needle is located in the haystack
cout << needle << " found at index " << idx << endl;
else
cout << needle << " is not in haystack\n";
}
} while (retryflag);
}
|
[
"ngraham20@my.whitworth.edu"
] |
ngraham20@my.whitworth.edu
|
3e8876811cc59522521ccf1c43f0ffb99ac50ac1
|
057fdc8f0cfe51041878cafebafbef0a3b07360c
|
/src/ppl/nn/engines/x86/impls/src/ppl/kernel/x86/fp32/conv2d/direct/avx512/conv2d_n16cx_direct_kernel_fp32_avx512.cpp
|
06b0d79484446f4c92292054295e87eca4f5b8b6
|
[
"Apache-2.0"
] |
permissive
|
wonderzy/ppl.nn
|
8ca93f7bd4d136b88489674a12fa31544c3217d6
|
7dd75a1077867fc9a762449953417088446ae2f8
|
refs/heads/master
| 2023-06-06T13:45:00.119077
| 2021-07-01T13:39:47
| 2021-07-01T13:39:47
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,743
|
cpp
|
#include "ppl/kernel/x86/fp32/conv2d/direct/avx512/conv2d_n16cx_direct_blk1x1_kernel_fp32_avx512.h"
#include "ppl/kernel/x86/fp32/conv2d/direct/avx512/conv2d_n16cx_direct_blk1x6_kernel_fp32_avx512.h"
#include "ppl/kernel/x86/fp32/conv2d/direct/avx512/conv2d_n16cx_direct_blk1x9_kernel_fp32_avx512.h"
#include "ppl/kernel/x86/fp32/conv2d/direct/avx512/conv2d_n16cx_direct_blk1x14_kernel_fp32_avx512.h"
namespace ppl { namespace kernel { namespace x86 {
conv2d_n16cx_direct_kernel_fp32_avx512_func_t
conv2d_n16cx_direct_kernel_fp32_avx512_pad_table[NT_STORE_OPT()][MAX_OC_RF()] =
{
{
conv2d_n16cx_direct_fp32_avx512_blk1x1_kernel<false, 1 * CH_DT_BLK()>,
conv2d_n16cx_direct_fp32_avx512_blk1x1_kernel<false, 2 * CH_DT_BLK()>,
conv2d_n16cx_direct_fp32_avx512_blk1x1_kernel<false, 3 * CH_DT_BLK()>,
conv2d_n16cx_direct_fp32_avx512_blk1x1_kernel<false, 4 * CH_DT_BLK()>,
},
{
conv2d_n16cx_direct_fp32_avx512_blk1x1_kernel<true, 1 * CH_DT_BLK()>,
conv2d_n16cx_direct_fp32_avx512_blk1x1_kernel<true, 2 * CH_DT_BLK()>,
conv2d_n16cx_direct_fp32_avx512_blk1x1_kernel<true, 3 * CH_DT_BLK()>,
conv2d_n16cx_direct_fp32_avx512_blk1x1_kernel<true, 4 * CH_DT_BLK()>,
},
};
#define DIRECT_O16_KERNEL_TABLE_BLK(NT_STORE, STRIDE_W) \
{\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 1>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 2>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 3>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 4>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 5>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 6>,\
conv2d_n16cx_direct_fp32_avx512_blk1x9_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 7>,\
conv2d_n16cx_direct_fp32_avx512_blk1x9_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 8>,\
conv2d_n16cx_direct_fp32_avx512_blk1x9_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 9>,\
conv2d_n16cx_direct_fp32_avx512_blk1x14_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 10>,\
conv2d_n16cx_direct_fp32_avx512_blk1x14_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 11>,\
conv2d_n16cx_direct_fp32_avx512_blk1x14_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 12>,\
conv2d_n16cx_direct_fp32_avx512_blk1x14_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 13>,\
conv2d_n16cx_direct_fp32_avx512_blk1x14_kernel<NT_STORE, STRIDE_W, 1 * CH_DT_BLK(), 14>,\
}
#define DIRECT_O32_KERNEL_TABLE_BLK(NT_STORE, STRIDE_W) \
{\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 1>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 2>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 3>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 4>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 5>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 6>,\
conv2d_n16cx_direct_fp32_avx512_blk1x9_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 7>,\
conv2d_n16cx_direct_fp32_avx512_blk1x9_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 8>,\
conv2d_n16cx_direct_fp32_avx512_blk1x9_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 9>,\
conv2d_n16cx_direct_fp32_avx512_blk1x14_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 10>,\
conv2d_n16cx_direct_fp32_avx512_blk1x14_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 11>,\
conv2d_n16cx_direct_fp32_avx512_blk1x14_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 12>,\
conv2d_n16cx_direct_fp32_avx512_blk1x14_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 13>,\
conv2d_n16cx_direct_fp32_avx512_blk1x14_kernel<NT_STORE, STRIDE_W, 2 * CH_DT_BLK(), 14>,\
}
#define DIRECT_O48_KERNEL_TABLE_BLK(NT_STORE, STRIDE_W) \
{\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 3 * CH_DT_BLK(), 1>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 3 * CH_DT_BLK(), 2>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 3 * CH_DT_BLK(), 3>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 3 * CH_DT_BLK(), 4>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 3 * CH_DT_BLK(), 5>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 3 * CH_DT_BLK(), 6>,\
conv2d_n16cx_direct_fp32_avx512_blk1x9_kernel<NT_STORE, STRIDE_W, 3 * CH_DT_BLK(), 7>,\
conv2d_n16cx_direct_fp32_avx512_blk1x9_kernel<NT_STORE, STRIDE_W, 3 * CH_DT_BLK(), 8>,\
conv2d_n16cx_direct_fp32_avx512_blk1x9_kernel<NT_STORE, STRIDE_W, 3 * CH_DT_BLK(), 9>,\
nullptr,\
nullptr,\
nullptr,\
nullptr,\
nullptr,\
}
#define DIRECT_O64_KERNEL_TABLE_BLK(NT_STORE, STRIDE_W) \
{\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 4 * CH_DT_BLK(), 1>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 4 * CH_DT_BLK(), 2>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 4 * CH_DT_BLK(), 3>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 4 * CH_DT_BLK(), 4>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 4 * CH_DT_BLK(), 5>,\
conv2d_n16cx_direct_fp32_avx512_blk1x6_kernel<NT_STORE, STRIDE_W, 4 * CH_DT_BLK(), 6>,\
nullptr,\
nullptr,\
nullptr,\
nullptr,\
nullptr,\
nullptr,\
nullptr,\
nullptr,\
}
conv2d_n16cx_direct_kernel_fp32_avx512_func_t
conv2d_n16cx_direct_kernel_fp32_avx512_o16_table[NT_STORE_OPT()][STRIDE_W_OPT()][BLK1X14_OW_RF()] =
{
{
DIRECT_O16_KERNEL_TABLE_BLK(false, 0),
DIRECT_O16_KERNEL_TABLE_BLK(false, 1),
DIRECT_O16_KERNEL_TABLE_BLK(false, 2),
},
{
DIRECT_O16_KERNEL_TABLE_BLK(true, 0),
DIRECT_O16_KERNEL_TABLE_BLK(true, 1),
DIRECT_O16_KERNEL_TABLE_BLK(true, 2),
},
};
conv2d_n16cx_direct_kernel_fp32_avx512_func_t
conv2d_n16cx_direct_kernel_fp32_avx512_o32_table[NT_STORE_OPT()][STRIDE_W_OPT()][BLK1X14_OW_RF()] =
{
{
DIRECT_O32_KERNEL_TABLE_BLK(false, 0),
DIRECT_O32_KERNEL_TABLE_BLK(false, 1),
DIRECT_O32_KERNEL_TABLE_BLK(false, 2),
},
{
DIRECT_O32_KERNEL_TABLE_BLK(true, 0),
DIRECT_O32_KERNEL_TABLE_BLK(true, 1),
DIRECT_O32_KERNEL_TABLE_BLK(true, 2),
},
};
conv2d_n16cx_direct_kernel_fp32_avx512_func_t
conv2d_n16cx_direct_kernel_fp32_avx512_o48_table[NT_STORE_OPT()][STRIDE_W_OPT()][BLK1X14_OW_RF()] =
{
{
DIRECT_O48_KERNEL_TABLE_BLK(false, 0),
DIRECT_O48_KERNEL_TABLE_BLK(false, 1),
DIRECT_O48_KERNEL_TABLE_BLK(false, 2),
},
{
DIRECT_O48_KERNEL_TABLE_BLK(true, 0),
DIRECT_O48_KERNEL_TABLE_BLK(true, 1),
DIRECT_O48_KERNEL_TABLE_BLK(true, 2),
},
};
conv2d_n16cx_direct_kernel_fp32_avx512_func_t
conv2d_n16cx_direct_kernel_fp32_avx512_o64_table[NT_STORE_OPT()][STRIDE_W_OPT()][BLK1X14_OW_RF()] =
{
{
DIRECT_O64_KERNEL_TABLE_BLK(false, 0),
DIRECT_O64_KERNEL_TABLE_BLK(false, 1),
DIRECT_O64_KERNEL_TABLE_BLK(false, 2),
},
{
DIRECT_O64_KERNEL_TABLE_BLK(true, 0),
DIRECT_O64_KERNEL_TABLE_BLK(true, 1),
DIRECT_O64_KERNEL_TABLE_BLK(true, 2),
},
};
}}};
|
[
"openppl.ai@hotmail.com"
] |
openppl.ai@hotmail.com
|
19a397d9cce1c53e95542df53ce16de563e2b767
|
0be828239c17a559930784ae5375a55eba7e190f
|
/ADC_Arduino/Old/processing_wave_angle_read/processing_wave_angle_read.ino
|
e2984a591f8207ac79648ef77cbf60071ad0a643
|
[] |
no_license
|
FBWeimer/sEMG-1
|
a7c89cb99a5f218389170483f05b4f152c918b0c
|
598521e8717375a95a87567ce30232aa6bd49579
|
refs/heads/master
| 2022-01-25T01:33:18.409225
| 2019-01-28T04:06:39
| 2019-01-28T04:06:39
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,334
|
ino
|
#include <stdint.h>
#include <Wire.h>
#define DOUT 3
#define CLK 2
#define ACCE_REG_ADDR 0x3B
#define MV_SIZE 10
#define WAIT_SAMPLE 30
#define DELAY_MS 1
#define MAX_ANGLE 360
#define MIN_ANGLE 0
#define ANGLE_SHIFT 0
#define MAX_VALUE 65536.0 // 2^16 int_16
const int MaxSampleCount = 1000;
const int alignment_packet_len = 1;
const int semg_channel = 2;
const int semg_packet_byte = 2;
const int semg_packet_len = alignment_packet_len + semg_channel * semg_packet_byte;
const int mpu_channel = 2;
const int mpu_packet_byte = 2; // int8_t for +-128 degree
const int mpu_packet_len = alignment_packet_len + mpu_channel * mpu_packet_byte;
uint8_t semg_packet[semg_packet_len] = {'$'};
uint8_t mpu_packet[mpu_packet_len] = {'@'};
typedef uint8_t indexType; // !!!!!!! WORKS WHEN MV_SIZE < 255 !!!!!!!
struct MPUData{
int addr;
indexType pointer = 0;
int16_t x_array[MV_SIZE];
int16_t y_array[MV_SIZE];
int16_t z_array[MV_SIZE];
int16_t offset_array[3];
float average_array[3];
float roll_pitch[2];
} mpu_1;
int mpu_addr_1 = 0x68;
int16_t mpu_offset_1[3] = {192, 516, -1993};
void setup() {
Wire.begin();
SerialUSB.begin(0);
while (!SerialUSB);
AdcBooster();
analogReadResolution(12);
analogReference(AR_EXTERNAL);
// MPU initialization
mpu_1.addr = mpu_addr_1;
MPU_init(&mpu_1);
memcpy(mpu_1.offset_array, mpu_offset_1, sizeof mpu_offset_1);
}
void loop() {
int semg_value;
while (1) {
// TODO: Check for MPU data availability before reading
MPU_read(&mpu_1);
MPU_calculateAverage(&mpu_1);
MPU_calculateOrientation(&mpu_1);
((int16_t *)(mpu_packet + alignment_packet_len))[0] = (int16_t)mpu_1.roll_pitch[0];
((int16_t *)(mpu_packet + alignment_packet_len))[1] = (int16_t)mpu_1.roll_pitch[1];
SerialUSB.write(mpu_packet, mpu_packet_len);
//SerialUSB.println((int16_t)mpu_1.roll_pitch[0]);
///*
semg_value = analogRead(A0);
((uint16_t *)(semg_packet + alignment_packet_len))[0] = semg_value;
semg_value = analogRead(A1);
((uint16_t *)(semg_packet + alignment_packet_len))[1] = semg_value;
SerialUSB.write(semg_packet, semg_packet_len);
//*/
}
}
//https://forum.arduino.cc/index.php?topic=443173.0
void AdcBooster()
{
ADC->CTRLA.bit.ENABLE = 0; // Disable ADC
while ( ADC->STATUS.bit.SYNCBUSY == 1 ); // Wait for synchronization
ADC->CTRLB.reg = ADC_CTRLB_PRESCALER_DIV128 | // Divide Clock by N.
ADC_CTRLB_RESSEL_12BIT; // Result on 12 bits
ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_1 | // 1 sample
ADC_AVGCTRL_ADJRES(0x00ul); // Adjusting result by 0
ADC->SAMPCTRL.reg = 0x00; // Sampling Time Length = 0
ADC->CTRLA.bit.ENABLE = 1; // Enable ADC
while ( ADC->STATUS.bit.SYNCBUSY == 1 ); // Wait for synchronization
}
void MPU_init(struct MPUData *mpu) {
SerialUSB.println("MPU_init");
Wire.beginTransmission(mpu->addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
// Read some samples
for (indexType i = 0; i < WAIT_SAMPLE; i++) {
MPU_read(&mpu_1);
delay(DELAY_MS);
}
// Gather initial value
for (indexType i = 0; i < MV_SIZE; i++) {
MPU_read(&mpu_1);
//SerialUSB.println(MPU_calculateAverage(mpu));
delay(DELAY_MS);
}
//SerialUSB.println("MPU_init");
//while(1);
}
int MPU_read(struct MPUData *mpu) {
Wire.beginTransmission(mpu->addr);
Wire.write(ACCE_REG_ADDR); // starting with register 0x3D (ACCEL_YOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(mpu->addr, 6, true); // request a total of 6 registers
mpu->x_array[mpu->pointer] = Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
mpu->y_array[mpu->pointer] = Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
mpu->z_array[mpu->pointer] = Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
mpu->pointer = (mpu->pointer + 1) % MV_SIZE;
}
int MPU_calculateAverage(struct MPUData *mpu) {
float sums[3] = {0, 0, 0};
for (indexType i = 0; i < MV_SIZE; i++) {
sums[0] += mpu->x_array[i];
sums[1] += mpu->y_array[i];
sums[2] += mpu->z_array[i];
}
mpu->average_array[0] = (sums[0] / MV_SIZE) - mpu->offset_array[0];
mpu->average_array[1] = (sums[1] / MV_SIZE) - mpu->offset_array[1];
mpu->average_array[2] = (sums[2] / MV_SIZE) - mpu->offset_array[2];
}
int MPU_calculateOrientation(struct MPUData *mpu) {
// https://stackoverflow.com/questions/3755059/3d-accelerometer-calculate-the-orientation
float sign = mpu->average_array[2] > 0? 1.0 : -1.0;
mpu->roll_pitch[0] =
atan2(
mpu->average_array[1],
sign * sqrt(
mpu->average_array[2]*mpu->average_array[2]
+ 0.001 * mpu->average_array[0] * mpu->average_array[0])
) * 180.0 / PI;
mpu->roll_pitch[1] =
atan2(
-mpu->average_array[0],
sqrt(
mpu->average_array[1]*mpu->average_array[1]
+ mpu->average_array[2]*mpu->average_array[2])
) * 180.0 / PI;
mpu->roll_pitch[0] = - mpu->roll_pitch[0];
// if (mpu->roll_pitch[0] > 180)
// mpu->roll_pitch[0] -= 360;
}
|
[
"vicodin1123@gmail.com"
] |
vicodin1123@gmail.com
|
c99fdab80399b1711acce431d6dcf9fa8f1e85ee
|
c47c43555c068ea93dea752a55bd38fa95dd057a
|
/avs_dx/DxVisuals/Resources/RenderTarget.h
|
b35e57b976377fc393c584dad83405ff25acd96c
|
[
"MIT",
"BSD-3-Clause",
"Intel",
"BSL-1.0",
"BSD-2-Clause",
"MS-PL"
] |
permissive
|
visbot/vis_avs_dx
|
435bafa8373c0fc416433b41871ac3bdf4e308b9
|
03e55f8932a97ad845ff223d3602ff2300c3d1d4
|
refs/heads/master
| 2020-04-23T09:12:08.198994
| 2019-01-17T12:50:57
| 2019-01-17T12:50:57
| 171,060,931
| 2
| 1
|
MIT
| 2019-02-16T23:00:11
| 2019-02-16T23:00:11
| null |
UTF-8
|
C++
| false
| false
| 1,297
|
h
|
#pragma once
#include <Render/Binder.h>
// RGB texture with two views, read only shader view, and write-only render target view.
class RenderTarget
{
CComPtr<ID3D11Texture2D> m_tex;
CComPtr<ID3D11RenderTargetView> m_rtv;
CComPtr<ID3D11RenderTargetView> m_rtvInteger;
CComPtr<ID3D11ShaderResourceView> m_srv;
CComPtr<ID3D11UnorderedAccessView> m_uav;
ID3D11RenderTargetView* getIntegerRt();
public:
static constexpr DXGI_FORMAT format =
DXGI_FORMAT_R10G10B10A2_UNORM;
// DXGI_FORMAT_R8G8B8A8_UNORM;
HRESULT create();
HRESULT create( const CSize& size, bool rt, bool unorderedAccess );
void destroy();
operator bool() const
{
return nullptr != m_tex;
}
void clear( const Vector4& color );
void clear( const Vector3& color );
void clear();
// Bind the write only render target view of the texture
void bindTarget();
void bindTargetForLogicOp();
void copyTo( const RenderTarget& that ) const;
ID3D11Texture2D* texture() const { return m_tex; }
ID3D11ShaderResourceView* srv() const { return m_srv; }
BoundSrv<eStage::Pixel> psView( UINT slot = Binder::psPrevFrame ) const;
// UAVs are only required by some effects and aren't created automatically. This method creates them.
HRESULT createUav();
ID3D11UnorderedAccessView* uav() const { return m_uav; }
};
|
[
"soonts@live.com"
] |
soonts@live.com
|
54781a11db88924113e091a03115607ac86b134f
|
9c49f5c7dad9db3b02643f486e4bc105d7deae2e
|
/DS/Tree/btree.cpp
|
b2e16a12aaeb08d3ca05597096863d4bb0d7e7e8
|
[] |
no_license
|
krishshanmukh/NITW-Assignments
|
eb42ee15230580207da3b73b79740867c6bffce0
|
18f1d5983eaab9c0e02968de24af0f832a66841c
|
refs/heads/master
| 2020-07-28T17:12:53.185473
| 2019-09-19T06:19:51
| 2019-09-19T06:19:51
| 209,476,344
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,933
|
cpp
|
#include<iostream>
using namespace std;
int d;
struct lnode
{
int data;
lnode *next;
lnode();
};
lnode::lnode()
{
next=NULL;
}
struct cnode;
struct btree
{
int count;
btree *parent;
lnode *key;
cnode *child;
btree();
};
btree::btree()
{
parent=NULL;
key=NULL;
child=NULL;
count=0;
}
struct cnode
{
btree *child;
cnode *next;
cnode();
};
cnode::cnode()
{
next=NULL;
}
void addbefore(lnode *A,int x,int y)
{
lnode *T;
while(A->next->data!=y&&A->next!=NULL)
A=A->next;
T=new(lnode);
T->data=x;
T->next=A->next;
A->next=T;
}
void addend(lnode *A,int x)
{
while(A->next!=NULL)
A=A->next;
A->next=new(lnode);
A->next->data=x;
A->next->next=NULL;
}
void addbegin(lnode* &A,int x)
{
lnode *T=new(lnode);
T->data=x;
T->next=A;
A=T;
}
void sort(btree* &L,int count,int c)
{
btree *M=L;
for(int i=0;i<M->count;i++)
{
if(M->key->data>c)
{
if(i==0)
addbegin(L->key,c);
else if(i<count)
addbefore(L->key,c,L->key->data);
else;
break;
}
if(M->key->next!=NULL)
M->key=M->key->next;
}
if(c>M->key->data)
{
addend(L->key,c);
}
}
btree* split(btree *T)
{
btree *M=new(btree);
for(int i=0;i<T->count/2;i++)
T->key=T->key->next;
T->count=T->count/2;
M=new(btree);
M->count=T->count;
M->key=T->key->next;
T->key->next=NULL;
return M;
}
btree* parent(int key)
{
btree *T;
T=new(btree);
addbegin(T->key,key);
T->count++;
return T;
}
void createbtree(btree* &T,int key)
{
btree *M=T;
int i;
if(T->count!=0)
{
for(i=0;i<T->count;i++)
{
if(key<T->key->data)
{
if(T->child!=NULL)
{
createbtree(T->child->child,key);
}
break;
}
if(T->key->next!=NULL)
T->key=T->key->next;
if(T->child!=NULL)
T->child=T->child->next;
}
if(i==T->count&&T->child!=NULL)
{
createbtree(T->child->child,key);
}
else if(T->count<2*d&&T->child==NULL)
{
sort(M,M->count,key);
T=M;
T->count++;
}
else
{
btree *L=split(T);
btree *K=parent(T->count/2);
K->child=new(cnode);
K->child->child=T;
T->parent=K;
K->child->next=new(cnode);
K->child->next->child=L;
L->parent=K;
T=K;
}
}
else
{
addbegin(T->key,key);
T->count++;
}
}
void display(btree *T)
{
if(T!=NULL)
{
for(int i=0;i<T->count;i++)
{
if(T->child!=NULL)
display(T->child->child);
cout<<T->key->data<<" ";
if(T->child!=NULL)
T->child=T->child->next;
if(T->key!=NULL)
T->key=T->key->next;
}
if(T->child!=NULL)
display(T->child->child);
}
}
int main()
{
int c;
cout<<"Enter value of d: ";
cin>>d;
btree *T=new(btree);
cout<<"Enter nos: ";
cin>>c;
while(c!=-1)
{
createbtree(T,c);
cin>>c;
}
display(T);
return 0;
}
|
[
"srikrishnashanmukh@gmail.com"
] |
srikrishnashanmukh@gmail.com
|
277e75842bc51bcca3ab9f09c6edbbd181d2a426
|
2a09951fdd646816cdbd83546be567168dea265a
|
/DeepLearningSystemdialog/build-DeepLearningSystemdialog-Desktop/moc_subgroundpage.cpp
|
f1fdb4b463de4b62d5bf074320962441589bbd35
|
[] |
no_license
|
leequan/DLSD
|
0a36741e6af69429219c58ff81494c301b62b5e0
|
c0ad9406a60869394fa45942e8b66bd25a89c973
|
refs/heads/master
| 2020-03-09T21:59:48.932411
| 2018-04-11T03:43:23
| 2018-04-11T03:43:23
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 17,836
|
cpp
|
/****************************************************************************
** Meta object code from reading C++ file 'subgroundpage.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.5.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../include/subgroundpage.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'subgroundpage.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.5.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_SubGroundPage1_t {
QByteArrayData data[7];
char stringdata0[141];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_SubGroundPage1_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_SubGroundPage1_t qt_meta_stringdata_SubGroundPage1 = {
{
QT_MOC_LITERAL(0, 0, 14), // "SubGroundPage1"
QT_MOC_LITERAL(1, 15, 29), // "SubGroundstartButton_clicked1"
QT_MOC_LITERAL(2, 45, 0), // ""
QT_MOC_LITERAL(3, 46, 21), // "getPathSubGroundPage1"
QT_MOC_LITERAL(4, 68, 18), // "pathSubGroundPage1"
QT_MOC_LITERAL(5, 87, 24), // "showOutPutSubGroundPage1"
QT_MOC_LITERAL(6, 112, 28) // "SubGroundstopButton_clicked1"
},
"SubGroundPage1\0SubGroundstartButton_clicked1\0"
"\0getPathSubGroundPage1\0pathSubGroundPage1\0"
"showOutPutSubGroundPage1\0"
"SubGroundstopButton_clicked1"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_SubGroundPage1[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
4, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 0, 34, 2, 0x0a /* Public */,
3, 1, 35, 2, 0x0a /* Public */,
5, 0, 38, 2, 0x0a /* Public */,
6, 0, 39, 2, 0x0a /* Public */,
// slots: parameters
QMetaType::Void,
QMetaType::Void, QMetaType::QString, 4,
QMetaType::Void,
QMetaType::Void,
0 // eod
};
void SubGroundPage1::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
SubGroundPage1 *_t = static_cast<SubGroundPage1 *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->SubGroundstartButton_clicked1(); break;
case 1: _t->getPathSubGroundPage1((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 2: _t->showOutPutSubGroundPage1(); break;
case 3: _t->SubGroundstopButton_clicked1(); break;
default: ;
}
}
}
const QMetaObject SubGroundPage1::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_SubGroundPage1.data,
qt_meta_data_SubGroundPage1, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *SubGroundPage1::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *SubGroundPage1::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_SubGroundPage1.stringdata0))
return static_cast<void*>(const_cast< SubGroundPage1*>(this));
return QWidget::qt_metacast(_clname);
}
int SubGroundPage1::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 4)
qt_static_metacall(this, _c, _id, _a);
_id -= 4;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 4)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 4;
}
return _id;
}
struct qt_meta_stringdata_SubGroundPage2_t {
QByteArrayData data[7];
char stringdata0[141];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_SubGroundPage2_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_SubGroundPage2_t qt_meta_stringdata_SubGroundPage2 = {
{
QT_MOC_LITERAL(0, 0, 14), // "SubGroundPage2"
QT_MOC_LITERAL(1, 15, 29), // "SubGroundstartButton_clicked2"
QT_MOC_LITERAL(2, 45, 0), // ""
QT_MOC_LITERAL(3, 46, 21), // "getPathSubGroundPage2"
QT_MOC_LITERAL(4, 68, 18), // "pathSubGroundPage2"
QT_MOC_LITERAL(5, 87, 24), // "showOutPutSubGroundPage2"
QT_MOC_LITERAL(6, 112, 28) // "SubGroundstopButton_clicked2"
},
"SubGroundPage2\0SubGroundstartButton_clicked2\0"
"\0getPathSubGroundPage2\0pathSubGroundPage2\0"
"showOutPutSubGroundPage2\0"
"SubGroundstopButton_clicked2"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_SubGroundPage2[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
4, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 0, 34, 2, 0x0a /* Public */,
3, 1, 35, 2, 0x0a /* Public */,
5, 0, 38, 2, 0x0a /* Public */,
6, 0, 39, 2, 0x0a /* Public */,
// slots: parameters
QMetaType::Void,
QMetaType::Void, QMetaType::QString, 4,
QMetaType::Void,
QMetaType::Void,
0 // eod
};
void SubGroundPage2::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
SubGroundPage2 *_t = static_cast<SubGroundPage2 *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->SubGroundstartButton_clicked2(); break;
case 1: _t->getPathSubGroundPage2((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 2: _t->showOutPutSubGroundPage2(); break;
case 3: _t->SubGroundstopButton_clicked2(); break;
default: ;
}
}
}
const QMetaObject SubGroundPage2::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_SubGroundPage2.data,
qt_meta_data_SubGroundPage2, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *SubGroundPage2::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *SubGroundPage2::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_SubGroundPage2.stringdata0))
return static_cast<void*>(const_cast< SubGroundPage2*>(this));
return QWidget::qt_metacast(_clname);
}
int SubGroundPage2::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 4)
qt_static_metacall(this, _c, _id, _a);
_id -= 4;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 4)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 4;
}
return _id;
}
struct qt_meta_stringdata_SubGroundPage3_t {
QByteArrayData data[7];
char stringdata0[141];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_SubGroundPage3_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_SubGroundPage3_t qt_meta_stringdata_SubGroundPage3 = {
{
QT_MOC_LITERAL(0, 0, 14), // "SubGroundPage3"
QT_MOC_LITERAL(1, 15, 29), // "SubGroundstartButton_clicked3"
QT_MOC_LITERAL(2, 45, 0), // ""
QT_MOC_LITERAL(3, 46, 21), // "getPathSubGroundPage3"
QT_MOC_LITERAL(4, 68, 18), // "pathSubGroundPage3"
QT_MOC_LITERAL(5, 87, 24), // "showOutPutSubGroundPage3"
QT_MOC_LITERAL(6, 112, 28) // "SubGroundstopButton_clicked3"
},
"SubGroundPage3\0SubGroundstartButton_clicked3\0"
"\0getPathSubGroundPage3\0pathSubGroundPage3\0"
"showOutPutSubGroundPage3\0"
"SubGroundstopButton_clicked3"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_SubGroundPage3[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
4, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 0, 34, 2, 0x0a /* Public */,
3, 1, 35, 2, 0x0a /* Public */,
5, 0, 38, 2, 0x0a /* Public */,
6, 0, 39, 2, 0x0a /* Public */,
// slots: parameters
QMetaType::Void,
QMetaType::Void, QMetaType::QString, 4,
QMetaType::Void,
QMetaType::Void,
0 // eod
};
void SubGroundPage3::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
SubGroundPage3 *_t = static_cast<SubGroundPage3 *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->SubGroundstartButton_clicked3(); break;
case 1: _t->getPathSubGroundPage3((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 2: _t->showOutPutSubGroundPage3(); break;
case 3: _t->SubGroundstopButton_clicked3(); break;
default: ;
}
}
}
const QMetaObject SubGroundPage3::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_SubGroundPage3.data,
qt_meta_data_SubGroundPage3, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *SubGroundPage3::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *SubGroundPage3::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_SubGroundPage3.stringdata0))
return static_cast<void*>(const_cast< SubGroundPage3*>(this));
return QWidget::qt_metacast(_clname);
}
int SubGroundPage3::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 4)
qt_static_metacall(this, _c, _id, _a);
_id -= 4;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 4)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 4;
}
return _id;
}
struct qt_meta_stringdata_SubGroundPage4_t {
QByteArrayData data[7];
char stringdata0[141];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_SubGroundPage4_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_SubGroundPage4_t qt_meta_stringdata_SubGroundPage4 = {
{
QT_MOC_LITERAL(0, 0, 14), // "SubGroundPage4"
QT_MOC_LITERAL(1, 15, 29), // "SubGroundstartButton_clicked4"
QT_MOC_LITERAL(2, 45, 0), // ""
QT_MOC_LITERAL(3, 46, 21), // "getPathSubGroundPage4"
QT_MOC_LITERAL(4, 68, 18), // "pathSubGroundPage4"
QT_MOC_LITERAL(5, 87, 24), // "showOutPutSubGroundPage4"
QT_MOC_LITERAL(6, 112, 28) // "SubGroundstopButton_clicked4"
},
"SubGroundPage4\0SubGroundstartButton_clicked4\0"
"\0getPathSubGroundPage4\0pathSubGroundPage4\0"
"showOutPutSubGroundPage4\0"
"SubGroundstopButton_clicked4"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_SubGroundPage4[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
4, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 0, 34, 2, 0x0a /* Public */,
3, 1, 35, 2, 0x0a /* Public */,
5, 0, 38, 2, 0x0a /* Public */,
6, 0, 39, 2, 0x0a /* Public */,
// slots: parameters
QMetaType::Void,
QMetaType::Void, QMetaType::QString, 4,
QMetaType::Void,
QMetaType::Void,
0 // eod
};
void SubGroundPage4::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
SubGroundPage4 *_t = static_cast<SubGroundPage4 *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->SubGroundstartButton_clicked4(); break;
case 1: _t->getPathSubGroundPage4((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 2: _t->showOutPutSubGroundPage4(); break;
case 3: _t->SubGroundstopButton_clicked4(); break;
default: ;
}
}
}
const QMetaObject SubGroundPage4::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_SubGroundPage4.data,
qt_meta_data_SubGroundPage4, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *SubGroundPage4::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *SubGroundPage4::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_SubGroundPage4.stringdata0))
return static_cast<void*>(const_cast< SubGroundPage4*>(this));
return QWidget::qt_metacast(_clname);
}
int SubGroundPage4::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 4)
qt_static_metacall(this, _c, _id, _a);
_id -= 4;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 4)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 4;
}
return _id;
}
struct qt_meta_stringdata_SubGroundPage5_t {
QByteArrayData data[7];
char stringdata0[141];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_SubGroundPage5_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_SubGroundPage5_t qt_meta_stringdata_SubGroundPage5 = {
{
QT_MOC_LITERAL(0, 0, 14), // "SubGroundPage5"
QT_MOC_LITERAL(1, 15, 29), // "SubGroundstartButton_clicked5"
QT_MOC_LITERAL(2, 45, 0), // ""
QT_MOC_LITERAL(3, 46, 21), // "getPathSubGroundPage5"
QT_MOC_LITERAL(4, 68, 18), // "pathSubGroundPage5"
QT_MOC_LITERAL(5, 87, 24), // "showOutPutSubGroundPage5"
QT_MOC_LITERAL(6, 112, 28) // "SubGroundstopButton_clicked5"
},
"SubGroundPage5\0SubGroundstartButton_clicked5\0"
"\0getPathSubGroundPage5\0pathSubGroundPage5\0"
"showOutPutSubGroundPage5\0"
"SubGroundstopButton_clicked5"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_SubGroundPage5[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
4, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 0, 34, 2, 0x0a /* Public */,
3, 1, 35, 2, 0x0a /* Public */,
5, 0, 38, 2, 0x0a /* Public */,
6, 0, 39, 2, 0x0a /* Public */,
// slots: parameters
QMetaType::Void,
QMetaType::Void, QMetaType::QString, 4,
QMetaType::Void,
QMetaType::Void,
0 // eod
};
void SubGroundPage5::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
SubGroundPage5 *_t = static_cast<SubGroundPage5 *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->SubGroundstartButton_clicked5(); break;
case 1: _t->getPathSubGroundPage5((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 2: _t->showOutPutSubGroundPage5(); break;
case 3: _t->SubGroundstopButton_clicked5(); break;
default: ;
}
}
}
const QMetaObject SubGroundPage5::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_SubGroundPage5.data,
qt_meta_data_SubGroundPage5, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *SubGroundPage5::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *SubGroundPage5::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_SubGroundPage5.stringdata0))
return static_cast<void*>(const_cast< SubGroundPage5*>(this));
return QWidget::qt_metacast(_clname);
}
int SubGroundPage5::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 4)
qt_static_metacall(this, _c, _id, _a);
_id -= 4;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 4)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 4;
}
return _id;
}
QT_END_MOC_NAMESPACE
|
[
"935626315@qq.com"
] |
935626315@qq.com
|
4d548318d1767a70baf0a985a8c16deb8b585c19
|
dfcaa76f29797fde11286152d790a22214039aba
|
/sources/Core/Layout/node_group.cpp
|
672a0f1126efaf05907b280e1822bcacb2439c6e
|
[
"BSD-3-Clause"
] |
permissive
|
boris-shurygin/showgraph
|
9bcf6e49eee217c7ab881f8deb491f59c8a3b3e0
|
7c00c94b19bf0c1e688ce96ba869663795c2d8a6
|
refs/heads/master
| 2020-05-20T10:41:03.264584
| 2014-09-02T04:57:03
| 2014-09-02T04:57:03
| 33,205,852
| 4
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,516
|
cpp
|
/**
* @file: node_group.cpp
* Implementation of node group class
* Layout library, 2d graph placement of graphs in ShowGraph tool.
* Copyright (c) 2009, Boris Shurygin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "layout_iface.h"
/**
* Compare orders of nodes
*/
bool compareBc( AuxNode* node1,
AuxNode* node2)
{
if ( qFuzzyCompare( node1->bc(), node2->bc()))
{
return node1->order() < node2->order();
}
return ( node1->bc() < node2->bc());
}
/**
* Constructor of group from a node.
* Coordinates are computed with respect to pass direction
*/
NodeGroup::NodeGroup( AuxNode *n, // Parent node
GraphDir dir, // Pass direction
bool first_pass) // If this is the first run
: node_list()
{
init();
addNode( n);
/** Compute coordinates */
double sum = 0;
unsigned int num_peers = 0;
/**
* On descending pass we compute center coordinate with respect to coordinates of predecessors,
* on ascending - we look at successors
*/
GraphDir rdir = RevDir( dir);
for ( AuxEdge* e = n->firstEdgeInDir( rdir);
isNotNullP( e);
e = e->nextEdgeInDir( rdir))
{
if ( !e->isInverted())
{
if ( !e->node( rdir)->isForPlacement())
continue;
num_peers++;
if ( e->node( rdir)->isEdgeLabel())
{
sum+= ( e->node( rdir)->modelX());
} else
{
sum+= ( e->node( rdir)->modelX() + ( e->node( rdir)->width() / 2));
}
}
}
for ( AuxEdge* e = n->firstEdgeInDir( dir);
isNotNullP( e);
e = e->nextEdgeInDir( dir))
{
if ( e->isInverted())
{
if ( !e->node( dir)->isForPlacement())
continue;
num_peers++;
if ( e->node( dir)->isEdgeLabel())
{
sum+= ( e->node( dir)->modelX());
} else
{
sum+= ( e->node( dir)->modelX() + ( e->node( dir)->width() / 2));
}
}
}
/** Barycenter heuristic */
double center = 0;
edge_num = 1;
if ( num_peers > 0)
{
edge_num = num_peers;
center = sum / num_peers;
} else if ( !first_pass)
{
edge_num = 1;
center = n->modelX() + n->width() / 2;
}
if ( n->isEdgeLabel())
center += ( n->width() / 2);
if ( n->isStable())
{
center = n->modelX() + n->width() / 2;
}
n->setBc( center);
barycenter = center;
border_left = center - n->width() / 2;
border_right = center + n->width() / 2;
}
/**
* Merge two groups correcting borders and nodes list of resulting group
*/
void NodeGroup::merge( NodeGroup *grp)
{
/** Add nodes from group on the left */
node_list += grp->nodes();
AuxNodeType prev_type = AUX_NODE_TYPES_NUM;
/** Recalculate border coordinates */
/* 1. calculate center coordinate */
qreal bc1 = bc();
qreal bc2 = grp->bc();
unsigned int e1 = adjEdgesNum();
unsigned int e2 = grp->adjEdgesNum();
qreal center = ( right() + left()) / 2;
center = ( bc1 * e1 + bc2 * e2) / (e1 + e2);
/* 2. calculate width */
qreal width = 0;
int num = 0;
qreal nodes_barycenter = 0;
qSort( node_list.begin(), node_list.end(), compareBc);
foreach ( AuxNode* node, node_list)
{
width += node->spacing( prev_type);
nodes_barycenter += width + node->width() / 2;
width += node->width();
prev_type = node->type();
num++;
}
nodes_barycenter = nodes_barycenter / num;
/* 3. set borders */
setLeft( center - nodes_barycenter);
setRight( left() + width);
barycenter = center;
edge_num = e1 + e2;
//out("Width %e, center %e, barycenter %e", width, center, barycenter);
}
/**
* Place nodes withing the group
*/
void NodeGroup::placeNodes()
{
AuxNodeType prev_type = AUX_NODE_TYPES_NUM;
qreal curr_left = left();
foreach ( AuxNode* node, node_list)
{
curr_left += node->spacing( prev_type);
node->setX( curr_left);
curr_left += node->width();
prev_type = node->type();
}
}
/**
* Place nodes withing the group
*/
void NodeGroup::placeNodesFinal( GraphDir dir)
{
AuxNodeType prev_type = AUX_NODE_TYPES_NUM;
qreal curr_left = left();
//out("Node placement: from %e to %e", left(), right());
foreach ( AuxNode* node, node_list)
{
//out("Node %d", node->id());
curr_left += node->spacing( prev_type);
node->setX( curr_left);
curr_left += node->width();
prev_type = node->type();
node->setY( node->level()->y() - node->height() / 2 );
}
}
|
[
"boris-shurygin@users.noreply.github.com"
] |
boris-shurygin@users.noreply.github.com
|
23eec6da3445eb56f630f4aa997306e4ad07cc9f
|
edcde93548524cf4e7d4cf67b0a772e4ef1a3d95
|
/lab_2/2_2_3/2_2_3/2_2_3.cpp
|
9642f1567a2cb41633c1c18fbcc26f8ac1864b6f
|
[] |
no_license
|
MiNeBudemRabami/oop
|
dd528d4196cb0eff1ffaf7e240e7863ab24f5d0a
|
f3cc85e7bdd8b81b69fb5e35e88e7f189b31dc51
|
refs/heads/master
| 2021-06-15T17:07:16.039156
| 2021-06-09T00:49:58
| 2021-06-09T00:49:58
| 175,844,378
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 322
|
cpp
|
#include "pch.h"
#include <iostream>
#include "2_2_3.h"
int main(int argc, char** argv)
{
if (argc < 3)
{
char curr;
while (!cin.eof())
{
cin >> curr;
cout << curr;
}
}
else
{
string SearchString = argv[1];
string ReplaceString = argv[2];
replace(SearchString, ReplaceString, cin, cout);
}
}
|
[
"sho_mLyaaa@mail.ru"
] |
sho_mLyaaa@mail.ru
|
413c4cc4c1a79f05c2aa06750b5cc73aa262a758
|
3abfbf8fa0375f13eabb837a45c112f4b75d3e46
|
/example/run.cpp
|
329ba42842af7308720300b426168fb28fc06183
|
[
"BSL-1.0"
] |
permissive
|
boost-ext/ut
|
ab49a75a2c01d25f6b44891c0f88d2081ae282c5
|
bf8388f61103571dee3061a4ef23292a320d9dbf
|
refs/heads/master
| 2023-07-15T20:45:10.381416
| 2023-07-09T15:35:15
| 2023-07-09T15:35:15
| 213,094,069
| 827
| 92
|
BSL-1.0
| 2023-07-09T15:35:17
| 2019-10-06T01:33:26
|
C++
|
UTF-8
|
C++
| false
| false
| 499
|
cpp
|
//
// Copyright (c) 2019-2020 Kris Jusiak (kris at jusiak dot 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)
//
#include <boost/ut.hpp>
namespace ut = boost::ut;
ut::suite _ = [] {
using namespace ut;
"test suite"_test = [] {
"should be equal"_test = [] { expect(42_i == 42); };
};
};
int main() {
return ut::cfg<>.run(); // explicitly run registered test suites
}
|
[
"krzysztof@jusiak.net"
] |
krzysztof@jusiak.net
|
7448de083f537cacbaa3495a5137cbdd5b8fd2b4
|
7b4ff1551a810091d66bafb79da7467ef25d8e02
|
/Plugins/MapGener/Source/MapGener/Private/MapGenerEdMode.cpp
|
398c7a5c9421cfa0f608f4b8e57e01eb47dc8d6e
|
[] |
no_license
|
yuukinona/AutoGenerateMap
|
de1d865af3e7bc58f22c80194a95062ff264911a
|
a555c91bf8e66d0a37811bdc40c84b5a268d5243
|
refs/heads/master
| 2021-04-04T22:34:05.898163
| 2020-03-31T08:24:10
| 2020-03-31T08:24:10
| 248,495,784
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 845
|
cpp
|
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "MapGenerEdMode.h"
#include "MapGenerEdModeToolkit.h"
#include "Toolkits/ToolkitManager.h"
#include "EditorModeManager.h"
const FEditorModeID FMapGenerEdMode::EM_MapGenerEdModeId = TEXT("EM_MapGenerEdMode");
FMapGenerEdMode::FMapGenerEdMode()
{
}
FMapGenerEdMode::~FMapGenerEdMode()
{
}
void FMapGenerEdMode::Enter()
{
FEdMode::Enter();
if (!Toolkit.IsValid() && UsesToolkits())
{
Toolkit = MakeShareable(new FMapGenerEdModeToolkit);
Toolkit->Init(Owner->GetToolkitHost());
}
}
void FMapGenerEdMode::Exit()
{
if (Toolkit.IsValid())
{
FToolkitManager::Get().CloseToolkit(Toolkit.ToSharedRef());
Toolkit.Reset();
}
// Call base Exit method to ensure proper cleanup
FEdMode::Exit();
}
bool FMapGenerEdMode::UsesToolkits() const
{
return true;
}
|
[
"yang@marv.jp"
] |
yang@marv.jp
|
0698c888d188da19330b5b65477e88207459cdc4
|
fc56fa52dcd40a640237be19b3faeb7c4339f4ea
|
/meta-heuristics-1.3/orginal/meta-heuristics-1.3/TSP/main/tspTSSearch.cpp
|
3656a79a2a762a06e58108025684d10937e738e2
|
[] |
no_license
|
nghiabui/Metaheuristic
|
592e9b4c25cfd11f5fa610031141c6b8186f90fb
|
9852941f9fde6981a15e1897b046b07f205d0adb
|
refs/heads/master
| 2021-01-10T18:49:27.746091
| 2015-08-20T02:44:48
| 2015-08-20T02:44:48
| 40,337,238
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,690
|
cpp
|
/**
* File: main.cpp
* Author: Tieu Minh
*
* Created on April 7, 2014, 4:24 PM
*/
#include "tspProblem.h"
#include "tspSolution.h"
#include "tsp2Opt.h"
#include "tspInsertion.h"
#define N graph.size()
using namespace std;
#if COMM_MPI
static edaMpiWorkflow workflow;
#else
static edaSeqWorkflow workflow;
#endif
int main(int argc, char** argv)
{
EDAMetasearchStart(argc, argv);
if (argc != 2)
{
std::cerr << "Usage : ./" << __progname
<< " [instance]" << std::endl;
}
else
{
tspProblem graph(argv[1]);
tspSolution route(graph);
edaBestAspirCrit aspir;
edaStaticTabu tabu(N);
tsp2Opt opt;
edaPopulation pop;
pop.init(route, N);
edaTimeCondition crit( N );
edaTS ts(opt, aspir, tabu, crit);
workflow.set(graph);
workflow.insertVertex(ts);
workflow.search(pop);
tspSolution& result = *(tspSolution*) pop[pop.best()];
cout << "[Route] " << result << endl;
cout << "[Fitness] " << result.evaluate () << endl;
}
EDAMetasearchStop();
return 0;
}
edaSerialize* userClassGenerate (unsigned int clsid)
{
switch (clsid)
{
case _USERCLASSID_ + _CLSID_TSPPROBLEM_:
return new tspProblem();
case _USERCLASSID_ + _CLSID_TSPSOLUTION_:
return new tspSolution();
case _USERCLASSID_ + _CLSID_TSP2OPT_:
return new tsp2Opt();
default:
cerr << "Unknown classId " << clsid << " for object generation !" << endl;
exit (-1);
}
}
|
[
"buitrungngnhia_2310@yahoo.com.vn"
] |
buitrungngnhia_2310@yahoo.com.vn
|
cfc9ea165d0ba8de6559d5210c4266aefa7c6f30
|
42fd9e7b8fea63ade1ae24d03660f2a3f3dce04e
|
/examples/task3/class3_test_lm_optimize.cc
|
3c6ee7a7633da8128c0afc27bd6a6172a0d77f98
|
[] |
no_license
|
soarchorale/ImageBasedModellingEduV1.0
|
acd1416030f5e43b506bd6a388116058a4596b84
|
4f4625bffac9657a1567127cc1548d90cfd47e23
|
refs/heads/master
| 2020-04-04T09:53:17.798122
| 2019-01-07T07:19:43
| 2019-01-07T07:19:43
| 155,834,634
| 1
| 3
| null | 2018-11-02T08:14:02
| 2018-11-02T08:14:02
| null |
UTF-8
|
C++
| false
| false
| 35,470
|
cc
|
//
// Created by caoqi on 2018/9/2.
/*
* 实现Levenberg-Marquardt算法,该算法又称为 damped least squares 阻尼最小二乘,用来求解非线性最小二乘
* 问题。LM找到的是局部最小值,该算法介于高斯牛顿法和梯度下降法之间,并通过控制信赖域尺寸的大小,在高斯牛顿法
* 和梯度下降法之间进行调整。LM 算法比高斯牛顿法速度慢但是更为鲁棒,
*
* LM算法的原理是用模型函数f对待估向量p在邻域内做线性估计(泰勒展开),忽略掉二阶以上的导数项,从而转化为线性最小
* 二乘问题。本质上就是用二次曲面对目标函数进行局部近似。LM算法属于一种信赖域法,即:从初始值开始,先假设一个可以
* 信赖的最大的位移s, 然后以当前点为中心,以s为半径的区域内,通过寻找目标函数的一个近似二次函数的最优点来求得真正
* 的位移。在得到位移之后,再计算目标函数值,如果其使得目标函数值得下降满足了一定条件,那么说明这个位移是可靠的
* 则继续按照此规则迭代计算下去;如果其不能使目标函数的下降满足一定的条件,则应该减少信赖域的范围,重新求解。
*
* LM算法的一般流程是:
* 1) 初始化
* 2) 计算雅阁比矩阵J,构造正规方程(JTJ + lambdaI) = JTf
* 3) 求解正规方程(共轭梯度或者预定共轭梯度法)
* 4) 判断若求解成功
* 增加信赖域(1/lambda),使得求解算法接近于高斯牛顿法,加快收敛速度
* 判断终止条件
* 判断若求解失败
* 减少信赖域(1/lambda), 使得求解算法解决域梯度下降法
* 5) 重复1), 2), 3),4)
*
* (注意,信赖域的大小为正规方程中lambda的倒数)
*/
//
#include <fstream>
#include <sstream>
#include <sfm/camera_pose.h>
#include <iomanip>
#include <assert.h>
#include "sfm/ba_conjugate_gradient.h"
#include "sfm/bundle_adjustment.h"
#include "sfm/ba_sparse_matrix.h"
#include "sfm/ba_dense_vector.h"
#include "sfm/ba_linear_solver.h"
#include "sfm/ba_sparse_matrix.h"
#include "sfm/ba_dense_vector.h"
#include "sfm/ba_cholesky.h"
typedef sfm::ba::SparseMatrix<double> SparseMatrixType;
typedef sfm::ba::DenseVector<double> DenseVectorType;
//global variables
std::vector<sfm::ba::Camera> cameras;
std::vector<sfm::ba::Point3D> points;
std::vector<sfm::ba::Observation> observations;
#define TRUST_REGION_RADIUS_INIT (1000)
#define TRUST_REGION_RADIUS_DECREMENT (1.0 / 10.0)
#define TRUST_REGION_RADIUS_GAIN (10.0)
// lm 算法最多迭代次数
const int lm_max_iterations = 100;
// mean square error
double initial_mse = 0.0;
double final_mse = 0.0;
int num_lm_iterations = 0;
int num_lm_successful_iterations = 0;
int num_lm_unsuccessful_iterations = 0;
// lm 算法终止条件
double lm_mse_threshold = 1e-16;
double lm_delta_threshold = 1e-8;
// 信赖域大小
double trust_region_radius = 1000;
int cg_max_iterations =1000;
//相机参数个数
int camera_block_dim = 9;
const int num_cam_params = 9;
/**
* /decription 加载相关数据,包括相机的初始内外参数,三维点,观察点
* @param file_name
* @param cams
* @param pts3D
* @param observations
*/
void load_data(const std::string& file_name
,std::vector<sfm::ba::Camera>&cams
,std::vector<sfm::ba::Point3D>&pts3D
,std::vector<sfm::ba::Observation> &observations){
/* 加载数据 */
std::ifstream in(file_name);
assert(in.is_open());
std::string line, word;
// 加载相机参数
{
int n_cams = 0;
getline(in, line);
std::stringstream stream(line);
stream >> word >> n_cams;
cams.resize(n_cams);
for (int i = 0; i < cams.size(); i++) {
getline(in, line);
std::stringstream stream(line);
stream >> cams[i].focal_length;
stream >> cams[i].distortion[0] >> cams[i].distortion[1];
for (int j = 0; j < 3; j++)stream >> cams[i].translation[j];
for (int j = 0; j < 9; j++)stream >> cams[i].rotation[j];
}
}
// 加载三维点
{
int n_points = 0;
getline(in, line);
std::stringstream stream(line);
stream>>word>>n_points;
pts3D.resize(n_points);
for(int i=0; i<n_points; i++) {
getline(in, line);
std::stringstream stream(line);
stream>>pts3D[i].pos[0]>>pts3D[i].pos[1]>>pts3D[i].pos[2];
}
}
//加载观察点
{
int n_observations = 0;
getline(in, line);
std::stringstream stream(line);
stream>>word>>n_observations;
observations.resize(n_observations);
for(int i=0; i<observations.size(); i++){
getline(in, line);
std::stringstream stream(line);
stream>>observations[i].camera_id
>>observations[i].point_id
>>observations[i].pos[0]
>>observations[i].pos[1];
}
}
}
/*
* Computes for a given matrix A the square matrix A^T * A for the
* case that block columns of A only need to be multiplied with itself.
* Becase the resulting matrix is symmetric, only about half the work
* needs to be performed.
*/
void matrix_block_column_multiply (sfm::ba::SparseMatrix<double> const& A,
std::size_t block_size, sfm::ba::SparseMatrix<double>* B)
{
sfm::ba::SparseMatrix<double>::Triplets triplets;
triplets.reserve(A.num_cols() * block_size);
for (std::size_t block = 0; block < A.num_cols(); block += block_size) {
std::vector<sfm::ba::DenseVector<double>> columns(block_size);
for (std::size_t col = 0; col < block_size; ++col)
A.column_nonzeros(block + col, &columns[col]);
for (std::size_t col = 0; col < block_size; ++col) {
double dot = columns[col].dot(columns[col]);
triplets.emplace_back(block + col, block + col, dot);
for (std::size_t row = col + 1; row < block_size; ++row) {
dot = columns[col].dot(columns[row]);
triplets.emplace_back(block + row, block + col, dot);
triplets.emplace_back(block + col, block + row, dot);
}
}
}
B->allocate(A.num_cols(), A.num_cols());
B->set_from_triplets(triplets);
}
/*
* Inverts a matrix with 3x3 bocks on its diagonal. All other entries
* must be zero. Reading blocks is thus very efficient.
*/
void
invert_block_matrix_3x3_inplace (sfm::ba::SparseMatrix<double>* A) {
if (A->num_rows() != A->num_cols())
throw std::invalid_argument("Block matrix must be square");
if (A->num_non_zero() != A->num_rows() * 3)
throw std::invalid_argument("Invalid number of non-zeros");
for (double* iter = A->begin(); iter != A->end(); )
{
double* iter_backup = iter;
math::Matrix<double, 3, 3> rot;
for (int i = 0; i < 9; ++i)
rot[i] = *(iter++);
double det = math::matrix_determinant(rot);
if (MATH_DOUBLE_EQ(det, 0.0))
continue;
rot = math::matrix_inverse(rot, det);
iter = iter_backup;
for (int i = 0; i < 9; ++i)
*(iter++) = rot[i];
}
}
/*
* Inverts a symmetric, positive definite matrix with NxN bocks on its
* diagonal using Cholesky decomposition. All other entries must be zero.
*/
void
invert_block_matrix_NxN_inplace (sfm::ba::SparseMatrix<double>* A, int blocksize)
{
if (A->num_rows() != A->num_cols())
throw std::invalid_argument("Block matrix must be square");
if (A->num_non_zero() != A->num_rows() * blocksize)
throw std::invalid_argument("Invalid number of non-zeros");
int const bs2 = blocksize * blocksize;
std::vector<double> matrix_block(bs2);
for (double* iter = A->begin(); iter != A->end(); )
{
double* iter_backup = iter;
for (int i = 0; i < bs2; ++i)
matrix_block[i] = *(iter++);
sfm::ba::cholesky_invert_inplace(matrix_block.data(), blocksize);
iter = iter_backup;
for (int i = 0; i < bs2; ++i)
if (std::isfinite(matrix_block[i]))
*(iter++) = matrix_block[i];
else
*(iter++) = 0.0;
}
}
/**
* /descrition 将角轴法转化成旋转矩阵
* @param r 角轴向量
* @param m 旋转矩阵
*/
void rodrigues_to_matrix (double const* r, double* m)
{
/* Obtain angle from vector length. */
double a = std::sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]);
/* Precompute sine and cosine terms. */
double ct = (a == 0.0) ? 0.5f : (1.0f - std::cos(a)) / (2.0 * a);
double st = (a == 0.0) ? 1.0 : std::sin(a) / a;
/* R = I + st * K + ct * K^2 (with cross product matrix K). */
m[0] = 1.0 - (r[1] * r[1] + r[2] * r[2]) * ct;
m[1] = r[0] * r[1] * ct - r[2] * st;
m[2] = r[2] * r[0] * ct + r[1] * st;
m[3] = r[0] * r[1] * ct + r[2] * st;
m[4] = 1.0f - (r[2] * r[2] + r[0] * r[0]) * ct;
m[5] = r[1] * r[2] * ct - r[0] * st;
m[6] = r[2] * r[0] * ct - r[1] * st;
m[7] = r[1] * r[2] * ct + r[0] * st;
m[8] = 1.0 - (r[0] * r[0] + r[1] * r[1]) * ct;
}
/**
* \description 根据求解得到的增量,对相机参数进行更新
* @param cam
* @param update
* @param out
*/
void update_camera (sfm::ba::Camera const& cam,
double const* update, sfm::ba::Camera* out)
{
out->focal_length = cam.focal_length + update[0];
out->distortion[0] = cam.distortion[0] + update[1];
out->distortion[1] = cam.distortion[1] + update[2];
out->translation[0] = cam.translation[0] + update[3];
out->translation[1] = cam.translation[1] + update[4];
out->translation[2] = cam.translation[2] + update[5];
double rot_orig[9];
std::copy(cam.rotation, cam.rotation + 9, rot_orig);
double rot_update[9];
rodrigues_to_matrix(update + 6, rot_update);
math::matrix_multiply(rot_update, 3, 3, rot_orig, 3, out->rotation);
}
/**
* \description 根据求解的增量,对三维点坐标进行更新
* @param pt
* @param update
* @param out
*/
void update_point (sfm::ba::Point3D const& pt,
double const* update, sfm::ba::Point3D* out)
{
out->pos[0] = pt.pos[0] + update[0];
out->pos[1] = pt.pos[1] + update[1];
out->pos[2] = pt.pos[2] + update[2];
}
/**
* /descripition 根据求得的delta_x, 更新相机参数和三维点
* @param delta_x
* @param cameras
* @param points
*/
void
update_parameters (DenseVectorType const& delta_x
, std::vector<sfm::ba::Camera>*cameras
, std::vector<sfm::ba::Point3D>*points)
{
/* Update cameras. */
std::size_t total_camera_params = 0;
for (std::size_t i = 0; i < cameras->size(); ++i){
update_camera(cameras->at(i),
delta_x.data() + num_cam_params * i,
&cameras->at(i));
total_camera_params = cameras->size() * num_cam_params;
}
/* Update points. */
for (std::size_t i = 0; i < points->size(); ++i) {
update_point(points->at(i),
delta_x.data() + total_camera_params + i * 3,
&points->at(i));
}
}
/**
* \description 对像素进行径向畸变
* @param x
* @param y
* @param dist
*/
void radial_distort (double* x, double* y, double const* dist)
{
double const radius2 = *x * *x + *y * *y;
double const factor = 1.0 + radius2 * (dist[0] + dist[1] * radius2);
*x *= factor;
*y *= factor;
}
/**
* \description 计算重投影误差
* @param vector_f
* @param delta_x
* @param cameras
* @param points
* @param observations
*/
void compute_reprojection_errors (DenseVectorType* vector_f
, DenseVectorType const* delta_x
, std::vector<sfm::ba::Camera>* cameras
, std::vector<sfm::ba::Point3D> *points
,std::vector<sfm::ba::Observation> *observations)
{
if (vector_f->size() != observations->size() * 2)
vector_f->resize(observations->size() * 2);
#pragma omp parallel for
for (std::size_t i = 0; i < observations->size(); ++i)
{
sfm::ba::Observation const& obs = observations->at(i);
sfm::ba::Point3D const& p3d = points->at(obs.point_id);
sfm::ba::Camera const& cam = cameras->at(obs.camera_id);
double const* flen = &cam.focal_length; // 相机焦距
double const* dist = cam.distortion; // 径向畸变系数
double const* rot = cam.rotation; // 相机旋转矩阵
double const* trans = cam.translation; // 相机平移向量
double const* point = p3d.pos; // 三维点坐标
sfm::ba::Point3D new_point;
sfm::ba::Camera new_camera;
// 如果delta_x 不为空,则先利用delta_x对相机和结构进行更新,然后再计算重投影误差
if (delta_x != nullptr)
{
std::size_t cam_id = obs.camera_id * num_cam_params;
std::size_t pt_id = obs.point_id * 3;
update_camera(cam, delta_x->data() + cam_id, &new_camera);
flen = &new_camera.focal_length;
dist = new_camera.distortion;
rot = new_camera.rotation;
trans = new_camera.translation;
pt_id += cameras->size() * num_cam_params;
update_point(p3d, delta_x->data() + pt_id, &new_point);
point = new_point.pos;
}
/* Project point onto image plane. */
double rp[] = { 0.0, 0.0, 0.0 };
for (int d = 0; d < 3; ++d)
{
rp[0] += rot[0 + d] * point[d];
rp[1] += rot[3 + d] * point[d];
rp[2] += rot[6 + d] * point[d];
}
rp[2] = (rp[2] + trans[2]);
rp[0] = (rp[0] + trans[0]) / rp[2];
rp[1] = (rp[1] + trans[1]) / rp[2];
/* Distort reprojections. */
radial_distort(rp + 0, rp + 1, dist);
/* Compute reprojection error. */
vector_f->at(i * 2 + 0) = rp[0] * (*flen) - obs.pos[0];
vector_f->at(i * 2 + 1) = rp[1] * (*flen) - obs.pos[1];
}
}
/**
* \description 计算均方误差
* @param vector_f
* @return
*/
double compute_mse (DenseVectorType const& vector_f) {
double mse = 0.0;
for (std::size_t i = 0; i < vector_f.size(); ++i)
mse += vector_f[i] * vector_f[i];
return mse / static_cast<double>(vector_f.size() / 2);
}
/**
* /description 计算观察点坐标(x,y),相遇对相机参数和三维点坐标的雅阁比矩阵
* @param cam
* @param point
* @param cam_x_ptr
* @param cam_y_ptr
* @param point_x_ptr
* @param point_y_ptr
*/
void my_jacobian(sfm::ba::Camera const& cam,
sfm::ba::Point3D const& point,
double* cam_x_ptr, double* cam_y_ptr,
double* point_x_ptr, double* point_y_ptr)
{
const double f = cam.focal_length;
const double *R = cam.rotation;
const double *t = cam.translation;
const double *X = point.pos;
const double k0 = cam.distortion[0];
const double k1 = cam.distortion[1];
const double xc = R[0] *X[0] + R[1] *X[1] + R[2] *X[2] + t[0];
const double yc = R[3] *X[0] + R[4] *X[1] + R[5] *X[2] + t[1];
const double zc = R[6] *X[0] + R[7] *X[1] + R[8] *X[2] + t[2];
const double x = xc/zc;
const double y = yc/zc;
const double r2 = x*x + y*y;
const double distort = 1.0 + (k0 + k1*r2)*r2;
const double u = f* distort*x;
const double v = f* distort*y;
/*关于焦距的偏导数*/
cam_x_ptr[0] = distort*x;
cam_y_ptr[0] = distort*y;
/*计算关于径向畸变函数k0, k1的偏导数*/
// 计算中间变量
const double u_deriv_distort = f*x;
const double v_deriv_distort = f*y;
const double distort_deriv_k0 = r2;
const double distort_deriv_k1 = r2*r2;
cam_x_ptr[1] = u_deriv_distort*distort_deriv_k0;
cam_x_ptr[2] = u_deriv_distort*distort_deriv_k1;
cam_y_ptr[1] = v_deriv_distort*distort_deriv_k0;
cam_y_ptr[2] = v_deriv_distort*distort_deriv_k1;
// 计算中间变量 (x,y)关于(xc, yc, zc)的偏导数
const double x_deriv_xc = 1/zc; const double x_deriv_yc = 0; const double x_deriv_zc = -x/zc;
const double y_deriv_xc = 0 ; const double y_deriv_yc = 1/zc; const double y_deriv_zc = -y/zc;
// 计算u, v关于x, y的偏导数
const double u_deriv_x = f*distort;
const double v_deriv_y = f*distort;
// 计算中间变量distort关于r2的偏导数
const double distort_deriv_r2 = k0 + 2*k1*r2;
// 计算中间变量r2关于xc, yc, zc的偏导数
const double r2_deriv_xc = 2*x/zc;
const double r2_deriv_yc = 2*y/zc;
const double r2_deriv_zc = -2*r2/zc;
// 计算中间变量distort关于xc, yc, zc的偏导数
const double distort_deriv_xc = distort_deriv_r2*r2_deriv_xc;
const double distort_deriv_yc = distort_deriv_r2*r2_deriv_yc;
const double distort_deriv_zc = distort_deriv_r2*r2_deriv_zc;
// 计算(u,v)关于xc, yc, zc的偏导数
const double u_deriv_xc = u_deriv_distort*distort_deriv_xc + u_deriv_x*x_deriv_xc;
const double u_deriv_yc = u_deriv_distort*distort_deriv_yc + u_deriv_x*x_deriv_yc;
const double u_deriv_zc = u_deriv_distort*distort_deriv_zc + u_deriv_x*x_deriv_zc;
const double v_deriv_xc = v_deriv_distort*distort_deriv_xc + v_deriv_y*y_deriv_xc;
const double v_deriv_yc = v_deriv_distort*distort_deriv_yc + v_deriv_y*y_deriv_yc;
const double v_deriv_zc = v_deriv_distort*distort_deriv_zc + v_deriv_y*y_deriv_zc;
/* 计算关于平移向量的t0, t1, t2的偏导数*/
const double xc_deriv_t0=1;
const double yc_deriv_t1=1;
const double zc_deriv_t2=1;
cam_x_ptr[3] = u_deriv_xc* xc_deriv_t0;
cam_x_ptr[4] = u_deriv_yc* yc_deriv_t1;
cam_x_ptr[5] = u_deriv_zc* zc_deriv_t2;
cam_y_ptr[3] = v_deriv_xc* xc_deriv_t0;
cam_y_ptr[4] = v_deriv_yc* yc_deriv_t1;
cam_y_ptr[5] = v_deriv_zc* zc_deriv_t2;
/* 计算关于旋转矩阵(表示为角轴向量w0, w1, w2)的偏导数 */
const double rx = R[0] *X[0] + R[1] *X[1] + R[2] *X[2];
const double ry = R[3] *X[0] + R[4] *X[1] + R[5] *X[2];
const double rz = R[6] *X[0] + R[7] *X[1] + R[8] *X[2];
const double xc_deriv_w0 = 0; const double xc_deriv_w1 = rz; const double xc_deriv_w2 = -ry;
const double yc_deriv_w0 = -rz; const double yc_deriv_w1 = 0 ; const double yc_deriv_w2 = rx;
const double zc_deriv_w0 = ry; const double zc_deriv_w1 = -rx; const double zc_deriv_w2 = 0;
cam_x_ptr[6] = u_deriv_yc*yc_deriv_w0 + u_deriv_zc*zc_deriv_w0;
cam_x_ptr[7] = u_deriv_xc*xc_deriv_w1 + u_deriv_zc*zc_deriv_w1;
cam_x_ptr[8] = u_deriv_xc*xc_deriv_w2 + u_deriv_yc*yc_deriv_w2;
cam_y_ptr[6] = v_deriv_yc*yc_deriv_w0 + v_deriv_zc*zc_deriv_w0;
cam_y_ptr[7] = v_deriv_xc*xc_deriv_w1 + v_deriv_zc*zc_deriv_w1;
cam_y_ptr[8] = v_deriv_xc*xc_deriv_w2 + v_deriv_yc*yc_deriv_w2;
/* 计算关于三维点坐标X,Y,X的偏导数*/
const double xc_deriv_X = R[0]; const double xc_deriv_Y = R[1];const double xc_deriv_Z = R[2];
const double yc_deriv_X = R[3]; const double yc_deriv_Y = R[4];const double yc_deriv_Z = R[5];
const double zc_deriv_X = R[6]; const double zc_deriv_Y = R[7];const double zc_deriv_Z = R[8];
point_x_ptr[0] = u_deriv_xc*xc_deriv_X + u_deriv_yc*yc_deriv_X + u_deriv_zc * zc_deriv_X;
point_x_ptr[1] = u_deriv_xc*xc_deriv_Y + u_deriv_yc*yc_deriv_Y + u_deriv_zc * zc_deriv_Y;
point_x_ptr[2] = u_deriv_xc*xc_deriv_Z + u_deriv_yc*yc_deriv_Z + u_deriv_zc * zc_deriv_Z;
point_y_ptr[0] = v_deriv_xc*xc_deriv_X + v_deriv_yc*yc_deriv_X + v_deriv_zc * zc_deriv_X;
point_y_ptr[1] = v_deriv_xc*xc_deriv_Y + v_deriv_yc*yc_deriv_Y + v_deriv_zc * zc_deriv_Y;
point_y_ptr[2] = v_deriv_xc*xc_deriv_Z + v_deriv_yc*yc_deriv_Z + v_deriv_zc * zc_deriv_Z;
}
/**
* \description 构造雅阁比矩阵,采用稀疏矩阵形式,
* 关于相机参数的雅阁比矩阵大小为:(2*observations.size()) x (num_cameras*9)
* 关于三维点坐标的雅阁比矩阵大小为:(2*observation.size()) x (num_points*3)
* @param jac_cam-- 观察点相对于相机参数的雅阁比矩阵
* @param jac_points--观察点相对于三维点的雅阁比矩阵
*/
void analytic_jacobian (SparseMatrixType* jac_cam
, SparseMatrixType* jac_points) {
assert(jac_cam);
assert(jac_points);
// 相机和三维点jacobian矩阵的行数都是n_observations*2
// 相机jacobian矩阵jac_cam的列数是n_cameras* n_cam_params
// 三维点jacobian矩阵jac_points的列数是n_points*3
std::size_t const camera_cols = cameras.size() * num_cam_params;
std::size_t const point_cols = points.size() * 3;
std::size_t const jacobi_rows = observations.size() * 2;
// 定义稀疏矩阵的基本元素
SparseMatrixType::Triplets cam_triplets, point_triplets;
cam_triplets.reserve(observations.size() * 2 * num_cam_params);
point_triplets.reserve(observations.size()*2 * 3);
double cam_x_ptr[9], cam_y_ptr[9], point_x_ptr[3], point_y_ptr[3];
// 对于每一个观察到的二维点
for (std::size_t i = 0; i < observations.size(); ++i) {
// 获取二维点,obs.point_id 三维点的索引,obs.camera_id 相机的索引
sfm::ba::Observation const &obs = observations[i];
// 三维点坐标
sfm::ba::Point3D const &p3d = points[obs.point_id];
// 相机参数
sfm::ba::Camera const &cam = cameras[obs.camera_id];
/*对一个三维点和相机求解偏导数*/
my_jacobian(cam, p3d,
cam_x_ptr, cam_y_ptr, point_x_ptr, point_y_ptr);
/*观察点对应雅各比矩阵的行,第i个观察点在雅各比矩阵的位置是2*i, 2*i+1*/
std::size_t row_x = i * 2 + 0;
std::size_t row_y = i * 2 + 1;
/*jac_cam中相机对应的列数为camera_id* n_cam_params*/
std::size_t cam_col = obs.camera_id * num_cam_params;
/*jac_points中三维点对应的列数为point_id* 3*/
std::size_t point_col = obs.point_id * 3;
for (int j = 0; j < num_cam_params; ++j) {
cam_triplets.push_back(SparseMatrixType::Triplet(row_x, cam_col + j, cam_x_ptr[j]));
cam_triplets.push_back(SparseMatrixType::Triplet(row_y, cam_col + j, cam_y_ptr[j]));
}
for (int j = 0; j < 3; ++j) {
point_triplets.push_back(SparseMatrixType::Triplet(row_x, point_col + j, point_x_ptr[j]));
point_triplets.push_back(SparseMatrixType::Triplet(row_y, point_col + j, point_y_ptr[j]));
}
}
if (jac_cam != nullptr) {
jac_cam->allocate(jacobi_rows, camera_cols);
jac_cam->set_from_triplets(cam_triplets);
}
if (jac_points != nullptr) {
jac_points->allocate(jacobi_rows, point_cols);
jac_points->set_from_triplets(point_triplets);
}
}
sfm::ba::LinearSolver::Status my_solve_schur (
SparseMatrixType const& jac_cams,
SparseMatrixType const& jac_points,
DenseVectorType const& values,
DenseVectorType* delta_x) {
/*
* 雅阁比矩阵:
* J = [Jc Jp]
* Jc是与相机相关的模块,Jp是与三维点相关的模块。
* 正规方程
* (J^TJ + lambda*I)delta_x = J^T(x - F)
* 进一步写为
* [ Jcc+ lambda*Icc Jcp ][delta_c]= [v]
* [ Jxp Jpp+lambda*Ipp ][delta_p] [w]
*
* B = Jcc, E = Jcp, C = Jpp
* 其中 Jcc = Jc^T* Jc, Jcx = Jc^T*Jx, Jxc = Jx^TJc, Jxx = Jx^T*Jx
* v = Jc^T(F-x), w = Jx^T(F-x), deta_x = [delta_c; delta_p]
*/
// 误差向量
DenseVectorType const& F = values;
// 关于相机的雅阁比矩阵
SparseMatrixType const& Jc = jac_cams;
// 关于三维点的雅阁比矩阵
SparseMatrixType const& Jp = jac_points;
SparseMatrixType JcT = Jc.transpose();
SparseMatrixType JpT = Jp.transpose();
// 构造正规方程
SparseMatrixType B, C;
// B = Jc^T* Jc
matrix_block_column_multiply(Jc, camera_block_dim, &B);
// C = Jp^T*Jp
matrix_block_column_multiply(Jp, 3, &C);
// E = Jc^T*Jp
SparseMatrixType E = JcT.multiply(Jp);
/* Assemble two values vectors. */
DenseVectorType v = JcT.multiply(F);
DenseVectorType w = JpT.multiply(F);
v.negate_self();
w.negate_self();
/* 以矩阵B和C的对角元素重新构建对角阵*/
// SparseMatrixType B_diag = B.diagonal_matrix();
// SparseMatrixType C_diag = C.diagonal_matrix();
/* 添加信赖域 */
C.mult_diagonal(1.0 + 1.0 / trust_region_radius);
B.mult_diagonal(1.0 + 1.0 / trust_region_radius);
/* 求解C矩阵的逆C = inv(Jx^T+Jx + lambda*Ixx)*/
invert_block_matrix_3x3_inplace(&C);
/* 计算S矩阵的Schur补用于高斯消元. */
SparseMatrixType ET = E.transpose();
// S = (Jcc+lambda*Icc) - Jc^T*Jx*inv(Jxx+ lambda*Ixx)*Jx^T*Jc
SparseMatrixType S = B.subtract(E.multiply(C).multiply(ET));
// rhs = v - Jc^T*Jx*inv(Jxx+ lambda*Ixx)*w
DenseVectorType rhs = v.subtract(E.multiply(C.multiply(w)));
/* Compute pre-conditioner for linear system. */
//SparseMatrixType precond = S.diagonal_matrix();
//precond.cwise_invert();
SparseMatrixType precond = B;
invert_block_matrix_NxN_inplace(&precond, camera_block_dim);
/* 用共轭梯度法求解相机参数. */
DenseVectorType delta_y(Jc.num_cols());
typedef sfm::ba::ConjugateGradient<double> CGSolver;
CGSolver::Options cg_opts;
cg_opts.max_iterations = cg_max_iterations;
cg_opts.tolerance = 1e-20;
CGSolver solver(cg_opts);
CGSolver::Status cg_status;
cg_status = solver.solve(S, rhs, &delta_y, &precond);
sfm::ba::LinearSolver::Status status;
status.num_cg_iterations = cg_status.num_iterations;
switch (cg_status.info) {
case CGSolver::CG_CONVERGENCE:
status.success = true;
break;
case CGSolver::CG_MAX_ITERATIONS:
status.success = true;
break;
case CGSolver::CG_INVALID_INPUT:
std::cout << "BA: CG failed (invalid input)" << std::endl;
status.success = false;
return status;
default:
break;
}
/* 将相机参数带入到第二个方程中,求解三维点的参数. */
/*E= inv(Jp^T Jp) (JpT.multiply(F)-Jc^T * Jp * delta_y)*/
DenseVectorType delta_z = C.multiply(w.subtract(ET.multiply(delta_y)));
/* Fill output vector. */
std::size_t const jac_cam_cols = Jc.num_cols();
std::size_t const jac_point_cols = Jp.num_cols();
std::size_t const jac_cols = jac_cam_cols + jac_point_cols;
if (delta_x->size() != jac_cols)
delta_x->resize(jac_cols, 0.0);
for (std::size_t i = 0; i < jac_cam_cols; ++i)
delta_x->at(i) = delta_y[i];
for (std::size_t i = 0; i < jac_point_cols; ++i)
delta_x->at(jac_cam_cols + i) = delta_z[i];
return status;
}
/**
* /description LM 算法流程
* @param cameras
* @param points
* @param observations
*/
void lm_optimization(std::vector<sfm::ba::Camera>*cameras
,std::vector<sfm::ba::Point3D>*points
,std::vector<sfm::ba::Observation>* observations){
/*1.0 初始化*/
// 计算重投影误差向量
DenseVectorType F, F_new;
compute_reprojection_errors(&F, nullptr, cameras, points, observations);// todo F 是误差向量
// 计算初始的均方误差
double current_mse = compute_mse(F);
initial_mse = current_mse;
final_mse = current_mse;
// 设置共轭梯度法的相关参数
trust_region_radius = TRUST_REGION_RADIUS_INIT;
/* Levenberg-Marquard 算法. */
for (int lm_iter = 0; ; ++lm_iter) {
// 判断终止条件,均方误差小于一定阈值
if (current_mse < lm_mse_threshold) {
std::cout << "BA: Satisfied MSE threshold." << std::endl;
break;
}
//1.0 计算雅阁比矩阵
SparseMatrixType Jc, Jp;
analytic_jacobian(&Jc, &Jp);
//2.0 预置共轭梯梯度法对正规方程进行求解*/
DenseVectorType delta_x;
sfm::ba::LinearSolver::Status cg_status = my_solve_schur(Jc, Jp, F, &delta_x);
//3.0 根据计算得到的偏移量,重新计算冲投影误差和均方误差,用于判断终止条件和更新条件.
double new_mse, delta_mse, delta_mse_ratio = 1.0;
// 正规方程求解成功的情况下
if (cg_status.success) {
/*重新计算相机和三维点,计算重投影误差,注意原始的相机参数没有被更新*/
compute_reprojection_errors(&F_new, &delta_x, cameras, points, observations);
/* 计算新的残差值 */
new_mse = compute_mse(F_new);
/* 均方误差的绝对变化值和相对变化率*/
delta_mse = current_mse - new_mse;
delta_mse_ratio = 1.0 - new_mse / current_mse;
}
// 正规方程求解失败的情况下
else {
new_mse = current_mse;
delta_mse = 0.0;
}
// new_mse < current_mse表示残差值减少
bool successful_iteration = delta_mse > 0.0;
/*
* 如果正规方程求解成功,则更新相机参数和三维点坐标,并且增大信赖域的尺寸,使得求解方式
* 趋近于高斯牛顿法
*/
if (successful_iteration) {
std::cout << "BA: #" << std::setw(2) << std::left << lm_iter
<< " success" << std::right
<< ", MSE " << std::setw(11) << current_mse
<< " -> " << std::setw(11) << new_mse
<< ", CG " << std::setw(3) << cg_status.num_cg_iterations
<< ", TRR " << trust_region_radius
<< ", MSE Ratio: "<<delta_mse_ratio
<< std::endl;
num_lm_iterations += 1;
num_lm_successful_iterations += 1;
/* 对相机参数和三点坐标进行更新 */
update_parameters(delta_x, cameras, points);
std::swap(F, F_new);
current_mse = new_mse;
if (delta_mse_ratio < lm_delta_threshold) {
std::cout << "BA: Satisfied delta mse ratio threshold of "
<< lm_delta_threshold << std::endl;
break;
}
// 增大信赖域大小
trust_region_radius *= TRUST_REGION_RADIUS_GAIN;
}
else {
std::cout << "BA: #" << std::setw(2) << std::left << lm_iter
<< " failure" << std::right
<< ", MSE " << std::setw(11) << current_mse
<< ", " << std::setw(11) << " "
<< " CG " << std::setw(3) << cg_status.num_cg_iterations
<< ", TRR " << trust_region_radius
<< std::endl;
num_lm_iterations += 1;
num_lm_unsuccessful_iterations += 1;
// 求解失败的减小信赖域尺寸
trust_region_radius *= TRUST_REGION_RADIUS_DECREMENT;
}
/* 判断是否超过最大的迭代次数. */
if (lm_iter + 1 >= lm_max_iterations) {
std::cout << "BA: Reached maximum LM iterations of "
<< lm_max_iterations << std::endl;
break;
}
}
final_mse = current_mse;
}
int main(int argc, char* argv[])
{
/* 加载数据 */
load_data("./examples/task2/test_ba.txt",cameras, points, observations);
lm_optimization(&cameras, &points, &observations);
// ba优化
// sfm::ba::BundleAdjustment::Options ba_opts;
// ba_opts.verbose_output = true;
// ba_opts.lm_mse_threshold = 1e-16;
// ba_opts.lm_delta_threshold = 1e-8;
// sfm::ba::BundleAdjustment ba(ba_opts);
// ba.set_cameras(&cameras);
// ba.set_points(&points);
// ba.set_observations(&observations);
// ba.optimize();
// ba.print_status();
// 将优化后的结果重新赋值
std::vector<sfm::CameraPose> new_cam_poses(2);
std::vector<math::Vec2f> radial_distortion(2);
std::vector<math::Vec3f> new_pts_3d(points.size());
for(int i=0; i<cameras.size(); i++) {
std::copy(cameras[i].translation, cameras[i].translation + 3, new_cam_poses[i].t.begin());
std::copy(cameras[i].rotation, cameras[i].rotation + 9, new_cam_poses[i].R.begin());
radial_distortion[i]=math::Vec2f(cameras[i].distortion[0], cameras[i].distortion[1]);
new_cam_poses[i].set_k_matrix(cameras[i].focal_length, 0.0, 0.0);
}
for(int i=0; i<new_pts_3d.size(); i++) {
std::copy(points[i].pos, points[i].pos+3, new_pts_3d[i].begin());
}
// 输出优化信息
std::cout<<"Params after BA: "<<std::endl;
std::cout<<" f: "<<new_cam_poses[0].get_focal_length()<<std::endl;
std::cout<<" distortion: "<<radial_distortion[0][0]<<", "<<radial_distortion[0][1]<<std::endl;
std::cout<<" R: "<<new_cam_poses[0].R<<std::endl;
std::cout<<" t: "<<new_cam_poses[0] .t<<std::endl;
// 输出优化信息
std::cout<<"Params after BA: "<<std::endl;
std::cout<<" f: "<<new_cam_poses[1].get_focal_length()<<std::endl;
std::cout<<" distortion: "<<radial_distortion[1][0]<<", "<<radial_distortion[1][1]<<std::endl;
std::cout<<" R: "<<new_cam_poses[1].R<<std::endl;
std::cout<<" t: "<<new_cam_poses[1] .t<<std::endl;
std::cout<<"points 3d: "<<std::endl;
for(int i=0; i<points.size(); i++) {
std::cout<<points[i].pos[0]<<", "<<points[i].pos[1]<<", "<<points[i].pos[2]<<std::endl;
}
// Params after BA:
// f: 0.919446
// distortion: -0.108421, 0.103782
// R: 0.999999 -0.00068734 -0.00135363
// 0.000675175 0.999952 -0.0104268
// 0.0013597 0.0104261 0.999952
// t: 0.00276221 0.0588868 -0.128463
// Params after BA:
// f: 0.920023
// distortion: -0.106701, 0.104344
// R: 0.999796 -0.0127484 0.0156791
// 0.0128673 0.999897 -0.00735337
// -0.0155827 0.00755345 0.999857
// t: 0.0814124 0.93742 -0.0895658
// points 3d:
// 1.36957, -1.17132, 7.04854
// 0.0225931, 0.978747, 7.48085
return 0;
}
|
[
"s463052596@live.cn"
] |
s463052596@live.cn
|
4a17e368657c0091bffe705ab8e1791136ee9056
|
190b0c992b9564cf090033feab46c560924c5405
|
/greedy/maxActiviteisSelection.cpp
|
cdba4d5844ddec602582f9149038bdea3198bdb5
|
[] |
no_license
|
mjcmd/dsAlgoCpp
|
456a954083214e4e19120a01508cde35550a5832
|
79ca90f3a1049cce416064860289f4411580f913
|
refs/heads/main
| 2022-12-28T11:37:27.244701
| 2020-10-09T14:02:49
| 2020-10-09T14:02:49
| 302,645,732
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 946
|
cpp
|
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
class activity
{
public:
string name;
int ST;
int FT;
} ;
void maxActivitiesSelection(activity* a, int n);
int main()
{
int n;
cin>>n;
activity a[n];
for(int i=0; i<n; i++)
{
cin>>a[i].name>>a[i].ST>>a[i].FT;
}
/*
a[0].name="A1";
a[0].ST=12;
a[0].FT=25;
a[1].name="A2";
a[1].ST=10;
a[1].FT=20;
a[2].name="A3";
a[2].ST=20;
a[2].FT=30;
*/
maxActivitiesSelection(a, n);
return 0;
}
bool comp(activity a, activity b)
{
return a.FT<b.FT;
}
void maxActivitiesSelection(activity* a, int n)
{
sort(a, a+n, comp);
int i=0, prev=0;
cout<<a[0].name<<" ";
while(i<=n-2)
{
if(a[prev].FT<=a[i+1].ST)
{
cout<<a[i+1].name<<" ";
prev=i+1;
}
i++;
}
}
|
[
"noreply@github.com"
] |
mjcmd.noreply@github.com
|
542165b2ceeb21677d06316a12c6936fd3f92dc8
|
c1907926fbe5cafa7a520be86969c02c77fad585
|
/main.cpp
|
28747f6bab53af4835fd6de4b91b97a9a77df77b
|
[] |
no_license
|
DJKIM613/sum_test
|
60f15bc1993215cff4a0f4733c29d09542b2dae9
|
9810890d9faca411baae50583751ccea82820d6d
|
refs/heads/master
| 2020-03-28T03:00:29.897070
| 2018-09-06T04:26:20
| 2018-09-06T04:26:20
| 147,612,899
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 112
|
cpp
|
#include <stdio.h>
#include "sum.h"
int main(){
int i = 10;
int s = sum(i);
printf("%d\n", s);
return 0;
}
|
[
"best_sheild97@naver.com"
] |
best_sheild97@naver.com
|
63377c143635b65d06db48cdf730d5a51784226f
|
99a659b5474ced234525d8292e0d469a4375b90e
|
/code/boltsdk/samples/Wizard/src/Transcode.h
|
2d792c1d3840423d3385cefd2e4d19d654495a54
|
[] |
no_license
|
fanliaokeji/lvdun
|
026f7f8efa3dceaf2922ea5dd3710544da78b4ce
|
a3e8ccabaceb185708458e22c8275e4c00708951
|
refs/heads/master
| 2021-01-24T10:11:16.165575
| 2016-12-17T06:57:56
| 2016-12-17T06:57:56
| 40,389,953
| 12
| 6
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 277
|
h
|
#pragma once
class Transcode
{
public:
static void Unicode_to_UTF8(const wchar_t* in, size_t len, std::string& out);
static void UTF8_to_Unicode(const char* in, size_t len, std::wstring& out);
static void ANSI_to_Unicode(const char* in, size_t len, std::wstring& out);
};
|
[
"GreenShield008@163.com"
] |
GreenShield008@163.com
|
f88a4415da8f87af162abc697ca750a87a667f3d
|
df0ea88f1b1dfb79f1aecff51d96d81702d2201f
|
/src/Commands/FPSCounter.h
|
c97d51addb4d21903eb1a34a9e60c67b899a4b5a
|
[
"BSD-2-Clause"
] |
permissive
|
secsome/Antares
|
ea62178d0fca56156f8d8549382f1733dc380f68
|
412b5500bae41104c9da2bc4169cb06a784472b8
|
refs/heads/master
| 2023-06-08T01:02:22.743252
| 2021-06-27T12:48:09
| 2021-06-27T12:48:09
| 380,737,035
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 645
|
h
|
#pragma once
#include "Ares.h"
#include "../Misc/Debug.h"
#include <CommandClass.h>
class FPSCounterCommandClass : public CommandClass
{
public:
//CommandClass
virtual const char* GetName() const override
{
return "FPS Counter";
}
virtual const wchar_t* GetUIName() const override
{
return L"FPS Counter";
}
virtual const wchar_t* GetUICategory() const override
{
return L"Development";
}
virtual const wchar_t* GetUIDescription() const override
{
return L"Shows the current and an average of frames per second.";
}
virtual void Execute(DWORD dwUnk) const override
{
Ares::bFPSCounter = !Ares::bFPSCounter;
}
};
|
[
"302702960@qq.com"
] |
302702960@qq.com
|
02a6bb704bd1669c01a3cc0bcc53f1b6c9b9d5ba
|
b456d9b810679ee1aee0b2ab31f6e98d0981e508
|
/checkers/config-chi.h
|
7a924f185a2f3d6763700fbe9c2daf8f29f435af
|
[
"MIT"
] |
permissive
|
Xilinx/libsystemctlm-soc
|
e7c1b8f19bd20c7b252ccd116983c41c59d13cf9
|
5e147e7d973c1e96ffbb4aa3d787e07e468290e1
|
refs/heads/master
| 2023-05-27T06:06:45.258454
| 2023-04-28T15:12:02
| 2023-05-22T10:15:38
| 72,154,676
| 172
| 60
|
NOASSERTION
| 2023-05-08T11:02:10
| 2016-10-27T22:54:33
|
Verilog
|
UTF-8
|
C++
| false
| false
| 3,430
|
h
|
/*
* Copyright (c) 2019 Xilinx Inc.
* Written by Francisco Iglesias.
*
* 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.
*
*
* References:
*
* [1] AMBA 5 CHI Architecture Specification, ARM IHI 0050C, ID050218
*
*/
#ifndef CONFIG_CHI_H__
#define CONFIG_CHI_H__
class __CHIPCConfig
{
public:
__CHIPCConfig() :
m_check_requests(false),
m_check_data_flits(false),
m_check_snoop_requests(false),
m_check_responses(false),
m_check_txn_structures(false),
m_check_request_retry(false),
m_check_ch_lcredits(false)
{}
bool en_check_requests() { return m_check_requests; }
bool en_check_data_flits() { return m_check_data_flits; }
bool en_check_snoop_requests() { return m_check_snoop_requests; }
bool en_check_responses() { return m_check_responses; }
bool en_check_txn_structures() { return m_check_txn_structures; }
bool en_check_request_retry() { return m_check_request_retry; }
bool en_check_ch_lcredits() { return m_check_ch_lcredits; }
protected:
bool m_check_requests;
bool m_check_data_flits;
bool m_check_snoop_requests;
bool m_check_responses;
bool m_check_txn_structures;
bool m_check_request_retry;
bool m_check_ch_lcredits;
};
class CHIPCConfig : private __CHIPCConfig
{
public:
//
// Check CHI requests
//
void check_requests(bool val = true) { m_check_requests = val; }
//
// Check CHI data flits
//
void check_data_flits(bool val = true) { m_check_data_flits = val; }
//
// Check CHI snoop requests
//
void check_snoop_requests(bool val = true)
{
m_check_snoop_requests = val;
}
//
// Check CHI responses
//
void check_responses(bool val = true) { m_check_responses = val; }
//
// Check that outstanding link credits on the CHI channels are
// between 0 - 15 (13.2.1 [1])
//
void check_ch_lcredits(bool val = true) { m_check_ch_lcredits = val; }
//
// Check transactions structures.
//
void check_transaction_structures(bool val = true)
{
m_check_txn_structures = val;
}
//
// Check request retries and Protocol Credits.
//
void check_request_retry(bool val = true)
{
m_check_request_retry = val;
}
//
// Enables all checks.
//
void enable_all_checks()
{
m_check_requests = true;
m_check_ch_lcredits = true;
m_check_request_retry = true;
m_check_txn_structures = true;
m_check_responses = true;
m_check_snoop_requests = true;
m_check_data_flits = true;
}
};
#endif /* CONFIG_CHI_H__ */
|
[
"francisco.iglesias@xilinx.com"
] |
francisco.iglesias@xilinx.com
|
a3db8c6090f02e9fd001319872140c0f4dce2790
|
2b0733b3a8f398c514d1956460672eb4c9ef36de
|
/src/core/vfs/VFS.cpp
|
d73cd95f59e2b26ad00db02b5beab1fe34160de2
|
[
"MIT"
] |
permissive
|
CompileException/donut
|
677ae45406cffaf56e334a5a66e0c0dbb4951667
|
bc400a8c2c9db9c3c5ed16190dc108e75722b503
|
refs/heads/main
| 2023-07-13T03:09:12.900788
| 2021-08-26T15:18:13
| 2021-08-26T15:18:13
| 400,906,516
| 1
| 0
|
MIT
| 2021-08-28T23:01:59
| 2021-08-28T23:01:59
| null |
UTF-8
|
C++
| false
| false
| 12,313
|
cpp
|
/*
* Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights 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 <donut/core/vfs/VFS.h>
#include <donut/core/log.h>
#include <donut/core/string_utils.h>
#include <fstream>
#include <cassert>
#include <algorithm>
#include <utility>
#include <sstream>
#ifdef WIN32
#include <Shlwapi.h>
#else
extern "C" {
#include <glob.h>
}
#endif // _WIN32
using namespace donut::vfs;
Blob::Blob(void* data, size_t size)
: m_data(data)
, m_size(size)
{
}
const void* Blob::data() const
{
return m_data;
}
size_t Blob::size() const
{
return m_size;
}
Blob::~Blob()
{
if (m_data)
{
free(m_data);
m_data = nullptr;
}
m_size = 0;
}
bool NativeFileSystem::folderExists(const std::filesystem::path& name)
{
return std::filesystem::exists(name) && std::filesystem::is_directory(name);
}
bool NativeFileSystem::fileExists(const std::filesystem::path& name)
{
return std::filesystem::exists(name) && std::filesystem::is_regular_file(name);
}
std::shared_ptr<IBlob> NativeFileSystem::readFile(const std::filesystem::path& name)
{
// TODO: better error reporting
std::ifstream file(name, std::ios::binary);
if (!file.is_open())
{
// file does not exist or is locked
return nullptr;
}
file.seekg(0, std::ios::end);
uint64_t size = file.tellg();
file.seekg(0, std::ios::beg);
if (size > static_cast<uint64_t>(std::numeric_limits<size_t>::max()))
{
// file larger than size_t
assert(false);
return nullptr;
}
char* data = static_cast<char*>(malloc(size));
if (data == nullptr)
{
// out of memory
assert(false);
return nullptr;
}
file.read(data, size);
if (!file.good())
{
// reading error
assert(false);
return nullptr;
}
return std::make_shared<Blob>(data, size);
}
bool NativeFileSystem::writeFile(const std::filesystem::path& name, const void* data, size_t size)
{
// TODO: better error reporting
std::ofstream file(name, std::ios::binary);
if (!file.is_open())
{
// file does not exist or is locked
return false;
}
if (size > 0)
{
file.write(static_cast<const char*>(data), static_cast<std::streamsize>(size));
}
if (!file.good())
{
// writing error
return false;
}
return true;
}
static int enumerateNativeFiles(const char* pattern, bool directories, enumerate_callback_t callback)
{
#ifdef WIN32
WIN32_FIND_DATAA findData;
HANDLE hFind = FindFirstFileA(pattern, &findData);
if (hFind == INVALID_HANDLE_VALUE)
{
if (GetLastError() == ERROR_FILE_NOT_FOUND)
return 0;
return status::Failed;
}
int numEntries = 0;
do
{
bool isDirectory = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
bool isDot = strcmp(findData.cFileName, ".") == 0;
bool isDotDot = strcmp(findData.cFileName, "..") == 0;
if ((isDirectory == directories) && !isDot && !isDotDot)
{
callback(findData.cFileName);
++numEntries;
}
} while (FindNextFileA(hFind, &findData) != 0);
FindClose(hFind);
return numEntries;
#else // WIN32
glob64_t glob_matches;
int globResult = glob64(pattern, 0 /*flags*/, nullptr /*errfunc*/, &glob_matches);
if (globResult == 0)
{
int numEntries = 0;
for (int i=0; i<glob_matches.gl_pathc; ++i)
{
const char* globentry = (glob_matches.gl_pathv)[i];
std::error_code ec, ec2;
std::filesystem::directory_entry entry(globentry, ec);
if (!ec)
{
if (directories == entry.is_directory(ec2) && !ec2)
{
callback(entry.path().filename().native());
++numEntries;
}
}
}
globfree64(&glob_matches);
return numEntries;
}
if (globResult == GLOB_NOMATCH)
return 0;
return status::Failed;
#endif // WIN32
}
int NativeFileSystem::enumerateFiles(const std::filesystem::path& path, const std::vector<std::string>& extensions, enumerate_callback_t callback, bool allowDuplicates)
{
(void)allowDuplicates;
if (extensions.empty())
{
std::string pattern = (path / "*").generic_string();
return enumerateNativeFiles(pattern.c_str(), false, callback);
}
int numEntries = 0;
for (const auto& ext : extensions)
{
std::string pattern = (path / ("*" + ext)).generic_string();
int result = enumerateNativeFiles(pattern.c_str(), false, callback);
if (result < 0)
return result;
numEntries += result;
}
return numEntries;
}
int NativeFileSystem::enumerateDirectories(const std::filesystem::path& path, enumerate_callback_t callback, bool allowDuplicates)
{
(void)allowDuplicates;
std::string pattern = (path / "*").generic_string();
return enumerateNativeFiles(pattern.c_str(), true, callback);
}
RelativeFileSystem::RelativeFileSystem(std::shared_ptr<IFileSystem> fs, const std::filesystem::path& basePath)
: m_UnderlyingFS(std::move(fs))
, m_BasePath(basePath.lexically_normal())
{
}
bool RelativeFileSystem::folderExists(const std::filesystem::path& name)
{
return m_UnderlyingFS->folderExists(m_BasePath / name.relative_path());
}
bool RelativeFileSystem::fileExists(const std::filesystem::path& name)
{
return m_UnderlyingFS->fileExists(m_BasePath / name.relative_path());
}
std::shared_ptr<IBlob> RelativeFileSystem::readFile(const std::filesystem::path& name)
{
return m_UnderlyingFS->readFile(m_BasePath / name.relative_path());
}
bool RelativeFileSystem::writeFile(const std::filesystem::path& name, const void* data, size_t size)
{
return m_UnderlyingFS->writeFile(m_BasePath / name.relative_path(), data, size);
}
int RelativeFileSystem::enumerateFiles(const std::filesystem::path& path, const std::vector<std::string>& extensions, enumerate_callback_t callback, bool allowDuplicates)
{
return m_UnderlyingFS->enumerateFiles(m_BasePath / path.relative_path(), extensions, callback, allowDuplicates);
}
int RelativeFileSystem::enumerateDirectories(const std::filesystem::path& path, enumerate_callback_t callback, bool allowDuplicates)
{
return m_UnderlyingFS->enumerateDirectories(m_BasePath / path.relative_path(), callback, allowDuplicates);
}
void RootFileSystem::mount(const std::filesystem::path& path, std::shared_ptr<IFileSystem> fs)
{
if (findMountPoint(path, nullptr, nullptr))
{
log::error("Cannot mount a filesystem at %s: there is another FS that includes this path", path.c_str());
return;
}
m_MountPoints.push_back(std::make_pair(path.lexically_normal().generic_string(), fs));
}
void donut::vfs::RootFileSystem::mount(const std::filesystem::path& path, const std::filesystem::path& nativePath)
{
mount(path, std::make_shared<RelativeFileSystem>(std::make_shared<NativeFileSystem>(), nativePath));
}
bool RootFileSystem::unmount(const std::filesystem::path& path)
{
std::string spath = path.lexically_normal().generic_string();
for (size_t index = 0; index < m_MountPoints.size(); index++)
{
if (m_MountPoints[index].first == spath)
{
m_MountPoints.erase(m_MountPoints.begin() + index);
return true;
}
}
return false;
}
bool RootFileSystem::findMountPoint(const std::filesystem::path& path, std::filesystem::path* pRelativePath, IFileSystem** ppFS)
{
std::string spath = path.lexically_normal().generic_string();
for (auto it : m_MountPoints)
{
if (spath.find(it.first, 0) == 0 && ((spath.length() == it.first.length()) || (spath[it.first.length()] == '/')))
{
if (pRelativePath)
{
std::string relative = spath.substr(it.first.size() + 1);
*pRelativePath = relative;
}
if (ppFS)
{
*ppFS = it.second.get();
}
return true;
}
}
return false;
}
bool RootFileSystem::folderExists(const std::filesystem::path& name)
{
std::filesystem::path relativePath;
IFileSystem* fs = nullptr;
if (findMountPoint(name, &relativePath, &fs))
{
return fs->folderExists(relativePath);
}
return false;
}
bool RootFileSystem::fileExists(const std::filesystem::path& name)
{
std::filesystem::path relativePath;
IFileSystem* fs = nullptr;
if (findMountPoint(name, &relativePath, &fs))
{
return fs->fileExists(relativePath);
}
return false;
}
std::shared_ptr<IBlob> RootFileSystem::readFile(const std::filesystem::path& name)
{
std::filesystem::path relativePath;
IFileSystem* fs = nullptr;
if (findMountPoint(name, &relativePath, &fs))
{
return fs->readFile(relativePath);
}
return nullptr;
}
bool RootFileSystem::writeFile(const std::filesystem::path& name, const void* data, size_t size)
{
std::filesystem::path relativePath;
IFileSystem* fs = nullptr;
if (findMountPoint(name, &relativePath, &fs))
{
return fs->writeFile(relativePath, data, size);
}
return false;
}
int RootFileSystem::enumerateFiles(const std::filesystem::path& path, const std::vector<std::string>& extensions, enumerate_callback_t callback, bool allowDuplicates)
{
std::filesystem::path relativePath;
IFileSystem* fs = nullptr;
if (findMountPoint(path, &relativePath, &fs))
{
return fs->enumerateFiles(relativePath, extensions, callback, allowDuplicates);
}
return status::PathNotFound;
}
int RootFileSystem::enumerateDirectories(const std::filesystem::path& path, enumerate_callback_t callback, bool allowDuplicates)
{
std::filesystem::path relativePath;
IFileSystem* fs = nullptr;
if (findMountPoint(path, &relativePath, &fs))
{
return fs->enumerateDirectories(relativePath, callback, allowDuplicates);
}
return status::PathNotFound;
}
static void appendPatternToRegex(const std::string& pattern, std::stringstream& regex)
{
for (char c : pattern)
{
switch (c)
{
case '?': regex << "[^/]?"; break;
case '*': regex << "[^/]+"; break;
case '.': regex << "\\."; break;
default: regex << c;
}
}
}
std::string donut::vfs::getFileSearchRegex(const std::filesystem::path& path, const std::vector<std::string>& extensions)
{
std::filesystem::path normalizedPath = path.lexically_normal();
std::string normalizedPathStr = normalizedPath.generic_string();
std::stringstream regex;
appendPatternToRegex(normalizedPathStr, regex);
if (!string_utils::ends_with(normalizedPathStr, "/") && !normalizedPath.empty())
regex << '/';
regex << "[^/]+";
if (!extensions.empty())
{
regex << '(';
bool first = true;
for (const auto& ext : extensions)
{
if (!first) regex << '|';
appendPatternToRegex(ext, regex);
first = false;
}
regex << ')';
}
return regex.str();
}
|
[
"alpanteleev@nvidia.com"
] |
alpanteleev@nvidia.com
|
8c2dd6c5facb9b91f7221802aa980be025821751
|
9c5857bcf2bbc5dc1dc8d7d6fefadd0c756db1ca
|
/src/Storages/PostgreSQL/PostgreSQLReplicaConnection.cpp
|
0c1efc16e051f689975de3c9fa4e5528577449f1
|
[
"Apache-2.0"
] |
permissive
|
garutilorenzo/ClickHouse
|
f006abb6fc6194b6a30b72d5ece2b4d16fa71611
|
7788f19780df58c73c6d328c0540ec7418279218
|
refs/heads/master
| 2023-03-23T05:00:05.154004
| 2021-03-18T11:34:21
| 2021-03-18T11:34:21
| 346,423,324
| 1
| 0
|
Apache-2.0
| 2021-03-10T16:38:01
| 2021-03-10T16:38:01
| null |
UTF-8
|
C++
| false
| false
| 2,509
|
cpp
|
#include "PostgreSQLReplicaConnection.h"
#include <Poco/Util/AbstractConfiguration.h>
namespace DB
{
namespace ErrorCodes
{
extern const int POSTGRESQL_CONNECTION_FAILURE;
}
PostgreSQLReplicaConnection::PostgreSQLReplicaConnection(
const Poco::Util::AbstractConfiguration & config,
const String & config_prefix,
const size_t num_retries_)
: log(&Poco::Logger::get("PostgreSQLConnection"))
, num_retries(num_retries_)
{
auto db = config.getString(config_prefix + ".db", "");
auto host = config.getString(config_prefix + ".host", "");
auto port = config.getUInt(config_prefix + ".port", 0);
auto user = config.getString(config_prefix + ".user", "");
auto password = config.getString(config_prefix + ".password", "");
if (config.has(config_prefix + ".replica"))
{
Poco::Util::AbstractConfiguration::Keys config_keys;
config.keys(config_prefix, config_keys);
for (const auto & config_key : config_keys)
{
if (config_key.starts_with("replica"))
{
std::string replica_name = config_prefix + "." + config_key;
size_t priority = config.getInt(replica_name + ".priority", 0);
auto replica_host = config.getString(replica_name + ".host", host);
auto replica_port = config.getUInt(replica_name + ".port", port);
auto replica_user = config.getString(replica_name + ".user", user);
auto replica_password = config.getString(replica_name + ".password", password);
replicas[priority] = std::make_shared<PostgreSQLConnection>(db, replica_host, replica_port, replica_user, replica_password);
}
}
}
else
{
replicas[0] = std::make_shared<PostgreSQLConnection>(db, host, port, user, password);
}
}
PostgreSQLReplicaConnection::PostgreSQLReplicaConnection(const PostgreSQLReplicaConnection & other)
: log(&Poco::Logger::get("PostgreSQLConnection"))
, replicas(other.replicas)
, num_retries(other.num_retries)
{
}
PostgreSQLConnection::ConnectionPtr PostgreSQLReplicaConnection::get()
{
for (size_t i = 0; i < num_retries; ++i)
{
for (auto & replica : replicas)
{
if (replica.second->tryConnect())
return replica.second->conn();
}
}
throw Exception(ErrorCodes::POSTGRESQL_CONNECTION_FAILURE, "Unable to connect to any of the replicas");
}
}
|
[
"sumarokovakseniia@mail.ru"
] |
sumarokovakseniia@mail.ru
|
96115051e43325df261894eacb8689a132832f2c
|
3552db0179694b11a354148790c3b30c0117e3e1
|
/EngineSource/includes/static_math/utils/type_traits.h
|
61e378717715e768c46ce0a52d2398ba366b4dcc
|
[] |
no_license
|
theLOLflashlight/Practicum
|
91873c21b2820d46291c903838ca1842f3508759
|
3c0212bd0207615cf378655aeaa3f50ebd13ace6
|
refs/heads/master
| 2021-05-02T04:34:09.391138
| 2017-08-06T09:18:53
| 2017-08-06T09:18:53
| 76,617,303
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,026
|
h
|
/*
* Copyright (C) 2013-2014 Morwenn
*
* static_math is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* static_math is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not,
* see <http://www.gnu.org/licenses/>.
*/
#ifndef SMATH_UTILS_TYPE_TRAITS_H_
#define SMATH_UTILS_TYPE_TRAITS_H_
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <type_traits>
namespace smath
{
////////////////////////////////////////////////////////////
// Size traits
template<typename T, typename U>
using greater_of = std::conditional_t<
sizeof(T) >= sizeof(U),
T,
U
>;
template<typename T, typename U>
using lesser_of = std::conditional_t<
sizeof(T) <= sizeof(U),
T,
U
>;
////////////////////////////////////////////////////////////
// Value type of
template< typename T >
struct value_type_of
{
using type = std::conditional_t<
std::is_fundamental< T >::value,
T, typename T::value_type >;
};
template< typename T >
using value_type_of_t = typename value_type_of< T >::type;
////////////////////////////////////////////////////////////
// Float matching
template< typename T >
struct _similar_float
{
using type = float;
};
template< typename T >
struct similar_float
: _similar_float< std::decay_t< T > >
{
};
template< typename T >
using similar_float_t = typename similar_float< T >::type;
template< template< typename... > class T, typename U, typename... Rest >
struct _similar_float< T< U, Rest... > >
{
using type = T< similar_float_t< U >, Rest... >;
};
template<>
struct _similar_float< void >
{
using type = void;
};
// Matches double
template<>
struct _similar_float< double >
{
using type = double;
};
template<>
struct _similar_float< long >
{
using type = double;
};
template<>
struct _similar_float< unsigned long >
{
using type = double;
};
// Matches long double
template<>
struct _similar_float< long double >
{
using type = long double;
};
template<>
struct _similar_float< long long >
{
using type = long double;
};
template<>
struct _similar_float< unsigned long long >
{
using type = long double;
};
/*template< typename T >
struct template_type1
{
using value_type = T;
T value;
};
template< typename T, typename U >
struct template_type2a
{
using value_type = T;
T value;
};
template< typename T, typename U >
struct template_type2b
{
using value_type = U;
U value;
};
template< typename T, typename U, typename V >
struct template_type3a
{
using value_type = T;
T value;
};
template< typename T, typename U, typename V >
struct template_type3b
{
using value_type = U;
U value;
};
template< typename T, typename U, typename V >
struct template_type3c
{
using value_type = V;
V value;
};
similar_float_t< char > x = { 1.0 };
float y = { 1.0 };
static_assert( std::is_same< decltype( x ), decltype( y ) >::value, "" );
similar_float_t< template_type1< int > > x1 = { 1.0 };
template_type1< float > y1 = { 1.0 };
static_assert( std::is_same< decltype( x1 ), decltype( y1 ) >::value, "" );
similar_float_t< template_type2b< int, long long > > x2b = { 1.0 };
template_type2b< int, long double > y2b = { 1.0 };
static_assert( std::is_same< decltype( x2b ), decltype( y2b ) >::value, "" );
similar_float_t< template_type3b< int, short, long > > x3b = { 1.0 };
template_type3b< int, float, long > y3b = { 1.0 };
static_assert( std::is_same< decltype( x3b ), decltype( y3b ) >::value, "" );
similar_float_t< template_type3c< int, long, long > > x3c = { 1.0 };
template_type3c< int, long, double > y3c = { 1.0 };
static_assert( std::is_same< decltype( x3c ), decltype( y3c ) >::value, "" );*/
}
#endif // SMATH_UTILS_TYPE_TRAITS_H_
|
[
"andrew.t.meckling@gmail.com"
] |
andrew.t.meckling@gmail.com
|
7cc42dd7b4abae0a60acc5bdbbb3b541b76ad3a5
|
9e02c151f257584592d7374b0045196a3fd2cf53
|
/AtCoder/ARC/053/A.cpp
|
fc0ffb9b3490b3e4fa20c62f7d20c75d0ac68d7b
|
[] |
no_license
|
robertcal/cpp_competitive_programming
|
891c97f315714a6b1fc811f65f6be361eb642ef2
|
0bf5302f1fb2aa8f8ec352d83fa6281f73dec9b5
|
refs/heads/master
| 2021-12-13T18:12:31.930186
| 2021-09-29T00:24:09
| 2021-09-29T00:24:09
| 173,748,291
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 308
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
int h, w; cin >> h >> w;
int ans = 0;
//横方向
ans += (w - 1) * h;
//縦方向
ans += (h - 1) * w;
cout << ans << endl;
}
|
[
"robertcal900@gmail.com"
] |
robertcal900@gmail.com
|
8b1880bcf71f974be9ec4dce08e4e89442eea49a
|
d2244dc530ce05ebc8d8e654c4bcf0dae991e78b
|
/android_art-xposed-lollipop-mr1/runtime/gc/accounting/heap_bitmap.h
|
cd321d6c582e04f7fa1a0d651ba75a284a7cbef9
|
[
"NCSA",
"Apache-2.0"
] |
permissive
|
java007hf/Dynamicloader
|
6fe4b1de14de751247ecd1b9bda499e100f4ec75
|
474427de20057b9c890622bb168810a990591573
|
refs/heads/master
| 2021-09-05T21:19:30.482850
| 2018-01-31T03:10:39
| 2018-01-31T03:10:39
| 119,626,890
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,316
|
h
|
/*
* Copyright (C) 2012 The Android Open Source Project
*
* 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 ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_H_
#define ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_H_
#include "base/allocator.h"
#include "base/logging.h"
#include "object_callbacks.h"
#include "space_bitmap.h"
namespace art {
namespace gc {
class Heap;
namespace accounting {
class HeapBitmap {
public:
bool Test(const mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_);
void Clear(const mirror::Object* obj) EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_);
template<typename LargeObjectSetVisitor>
bool Set(const mirror::Object* obj, const LargeObjectSetVisitor& visitor)
EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_) ALWAYS_INLINE;
template<typename LargeObjectSetVisitor>
bool AtomicTestAndSet(const mirror::Object* obj, const LargeObjectSetVisitor& visitor)
EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_) ALWAYS_INLINE;
ContinuousSpaceBitmap* GetContinuousSpaceBitmap(const mirror::Object* obj) const;
void Walk(ObjectCallback* callback, void* arg)
SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_);
template <typename Visitor>
void Visit(const Visitor& visitor)
EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Find and replace a bitmap pointer, this is used by for the bitmap swapping in the GC.
void ReplaceBitmap(ContinuousSpaceBitmap* old_bitmap, ContinuousSpaceBitmap* new_bitmap)
EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_);
// Find and replace a object set pointer, this is used by for the bitmap swapping in the GC.
void ReplaceLargeObjectBitmap(LargeObjectBitmap* old_bitmap, LargeObjectBitmap* new_bitmap)
EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_);
explicit HeapBitmap(Heap* heap) : heap_(heap) {}
private:
const Heap* const heap_;
void AddContinuousSpaceBitmap(ContinuousSpaceBitmap* bitmap);
void RemoveContinuousSpaceBitmap(ContinuousSpaceBitmap* bitmap);
void AddLargeObjectBitmap(LargeObjectBitmap* bitmap);
void RemoveLargeObjectBitmap(LargeObjectBitmap* bitmap);
// Bitmaps covering continuous spaces.
std::vector<ContinuousSpaceBitmap*,
TrackingAllocator<ContinuousSpaceBitmap*, kAllocatorTagHeapBitmap>>
continuous_space_bitmaps_;
// Sets covering discontinuous spaces.
std::vector<LargeObjectBitmap*,
TrackingAllocator<LargeObjectBitmap*, kAllocatorTagHeapBitmapLOS>>
large_object_bitmaps_;
friend class art::gc::Heap;
};
} // namespace accounting
} // namespace gc
} // namespace art
#endif // ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_H_
|
[
"benylwang@pacewear.cn"
] |
benylwang@pacewear.cn
|
af9e8516ecd0621684069bf12db4af0a07e1e359
|
aa3ef4a9335447a7077a0963298cde1c9a0b8b7d
|
/CollapsableBox.h
|
775d1b4149f3cfb7c4cb279b3378112da45522ed
|
[] |
no_license
|
phoudoin/sanity
|
9d3fc5eb03143dff86d628a9699baa81db16686b
|
82a4ba3344a32ccbb3901c98010dc3cfce792262
|
refs/heads/master
| 2021-06-02T00:51:51.635721
| 2015-05-12T10:03:54
| 2015-05-12T10:03:54
| 35,473,565
| 5
| 3
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,261
|
h
|
#ifndef COLLAPSABLEBOX_H
#define COLLAPSABLEBOX_H
#include <InterfaceKit.h>
class CollapsableBox : public BControl
{
public:
// Constructors, destructors, operators...
CollapsableBox(BRect frame, const char *name, const char *label, BMessage *msg,
uint32 resize_mask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP | B_FRAME_EVENTS);
typedef BControl inherited;
// Virtual function overrides
public:
virtual void AttachedToWindow(void);
virtual void SetValue(int32 value);
virtual void Draw(BRect updateRect);
virtual void GetPreferredSize(float *width, float *height);
virtual void FrameResized(float new_width, float new_height);
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void MouseDown(BPoint point);
virtual void MouseUp(BPoint point);
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
virtual void MessageReceived(BMessage *message);
// From here, it's none of your business! ;-)
private:
enum {
COLLAPSED,
PRESSED,
EXPANDED
};
bool m_pressing;
BRect m_collapsed_rect;
BRect m_expanded_rect;
BPoint m_click;
void draw_switch(int state);
};
#endif // ifdef COLLAPSABLEBOX_H
|
[
"philippe.houdoin@gmail.com"
] |
philippe.houdoin@gmail.com
|
939e0a42a8b72937135a9d0ae806891af1a6bdd6
|
bfc452edb855d81d4788fcf731603b255acc791b
|
/test_minimax.cc
|
251c7701471eba42efc194520730fa881108b653
|
[] |
no_license
|
icarroll/lachter
|
88b1230fd4c39d544d35377cc49421878aae1656
|
744f493a066e14e870d982eb3738248bcb5e4c81
|
refs/heads/master
| 2020-04-11T05:09:31.053432
| 2019-02-01T04:54:43
| 2019-02-01T04:54:43
| 161,539,339
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 240
|
cc
|
#include <iomanip>
#include <iostream>
#include "minimax.hh"
int main(int numargs, char * args[]) {
gamestate board;
minimax_brain brain(board);
brain.think_depth(3);
//cout << brain.best_move() << endl;
return 0;
}
|
[
"icarroll@pobox.com"
] |
icarroll@pobox.com
|
a69cb0e91b0c3674c83e30c7995d50553b7e5258
|
7e154ad6f21f0047a9eba219c3ec07bb066acc34
|
/test/test_max_pool.cpp
|
e0686ca17b49cf260068842d425e561bfecdfa2c
|
[] |
no_license
|
merdogan10/cnn-mnist-cpp
|
c4f1d6896c8bffbde9f847a497adc11d75a474f4
|
041d527bfb578fb80d7f542092057b2a400d3252
|
refs/heads/master
| 2020-12-07T19:21:08.041053
| 2020-01-09T10:17:31
| 2020-01-09T10:17:31
| 232,780,235
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 492
|
cpp
|
#include "max_pool.hpp"
#include <eigen3/Eigen/Dense>
#include <iostream>
#include <vector>
using Eigen::MatrixXd;
using namespace std;
void test_max_pool_forward() {
MatrixXd m(4, 4), o(2, 2);
m << 1, 1, 2, 4, 5, 6, 7, 8, 3, 2, 1, 0, 1, 2, 3, 4;
o << 6, 8, 3, 4;
vector<MatrixXd> input;
input.push_back(m);
Max_Pool *mp = new Max_Pool(4, 4, 1, 2, 2);
mp->feed_forward(input);
if (!mp->output[0].isApprox(o)) {
cout << "Test failed: test_max_pool_forward" << endl;
}
}
|
[
"mustafaerdogan1994@gmail.com"
] |
mustafaerdogan1994@gmail.com
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.