blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
89612b135a965eb0b290e1b5a2148e6a71091527 | 85455876309135778cba6bbf16933ca514f457f8 | /2400/2479.cpp | 9206200fd742e97e9760babb9cd0e50ef49fdaab | [] | no_license | kks227/BOJ | 679598042f5d5b9c3cb5285f593231a4cd508196 | 727a5d5def7dbbc937bd39713f9c6c96b083ab59 | refs/heads/master | 2020-04-12T06:42:59.890166 | 2020-03-09T14:30:54 | 2020-03-09T14:30:54 | 64,221,108 | 83 | 19 | null | null | null | null | UTF-8 | C++ | false | false | 948 | cpp | #include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int main(){
int N, K, S, E;
char W[1000][31];
vector<int> adj[1000];
scanf("%d %d", &N, &K);
for(int i=0; i<N; i++){
scanf("%s", W[i]);
for(int j=0; j<i; j++){
int cnt = 0;
for(int k=0; k<K; k++)
if(W[i][k] != W[j][k] && ++cnt == 2) break;
if(cnt == 1){
adj[i].push_back(j);
adj[j].push_back(i);
}
}
}
scanf("%d %d", &S, &E);
S--; E--;
int prev[1000];
bool visited[1000] = {0};
visited[S] = true;
queue<int> Q;
Q.push(S);
while(!Q.empty()){
int curr = Q.front(); Q.pop();
for(int next: adj[curr]){
if(!visited[next]){
visited[next] = true;
prev[next] = curr;
Q.push(next);
}
}
}
if(!visited[E]) puts("-1");
else{
vector<int> path;
for(int i=E; i!=S; i=prev[i])
path.push_back(i);
path.push_back(S);
for(int i=path.size()-1; i>=0; i--)
printf("%d ", path[i]+1);
}
} | [
"wongrikera@nate.com"
] | wongrikera@nate.com |
606bfd2804570f2d72e8c67055ac42e8b2b9981d | da702eba25c933873644efadd63b796d9c5de73e | /Arduino/libraries/HL1606stripPWM/HL1606stripPWM.h | 6324fb283efb8f5cb3388416aaa8d67377ed2973 | [] | no_license | ExpressiveMachinesMusicalInstruments/EMMI-Code | c11d21c48bef4b135b38642c18881f3e34569a98 | 477a69660491b35fbf81e2cf5f31641c05433ebc | refs/heads/master | 2021-01-19T07:56:41.000432 | 2012-09-13T01:34:54 | 2012-09-13T01:34:54 | 5,678,208 | 1 | 0 | null | 2012-09-13T01:34:40 | 2012-09-04T20:30:34 | C++ | UTF-8 | C++ | false | false | 2,470 | h | // (c) Adafruit Industries / Limor Fried 2010. Released under MIT license.
#include <WProgram.h>
// some spi defines
// Classic Arduinos
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)|| defined(__AVR_ATmega168__)
#define SPI_PORT PORTB
#define SPI_DDR DDRB
#define SPI_PIN PINB
#define SPI_MOSI 3 // Arduino pin 11.
#define SPI_SCK 5 // Arduino pin 13.
#define DATA_PIN 11
#define CLOCK_PIN 13
// Megas
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define SPI_PORT PORTB
#define SPI_DDR DDRB
#define SPI_PIN PINB
#define SPI_MOSI 2 // Arduino pin 51.
#define SPI_SCK 1 // Arduino pin 52.
#define DATA_PIN 51
#define CLOCK_PIN 52
#elif defined(__AVR_ATmega32U4__)
#define SPI_PORT PORTB
#define SPI_DDR DDRB
#define SPI_PIN PINB
#define SPI_MOSI 2 // Teensyduino pin 2
#define SPI_SCK 1 // Teensyduino pin 1
#define DATA_PIN 2
#define CLOCK_PIN 1
#endif
class HL1606stripPWM {
private:
// How many bits of color per LED for PWM?
// if its set to 2 bits/LED that means 6 bit color (since there are 3 LEDs)
// if its set to 3 bits/LED that equals 9 bit color
// if its set to 4 bits/LED that equals 12 bit color
// Setting this to be higher means the CPU works harder, at some point it will run out of CPU
// and look weird or flash
uint8_t PWMbits;
// This is how much we want to divide the SPI clock by
// valid #s are: 2, 4, 8, 16, 32, 64 and 128
// SPI speed = CPU speed / divider
// So divider of 32 and CPU clock of 16MHz (standard arduino) -> 500 KHz SPI
// Smaller divider numbers means faster SPI
// ...but HL1606 cant take faster than 1.5MHz and they're kinda sucky chips which
// means that if you have one bad chip in your string that cant go faster than say 500 MHz
// then the entire strand will fail. Sometimes you're lucky and they're all good - try 16
// but don't be surprised if they fail at 1MHz
uint8_t SPIspeedDiv;
// What 'percentage' of CPU you're willing to use for the PWM action.
uint8_t CPUmaxpercent;
void timerinit(void);
void SPIinit(void);
public:
HL1606stripPWM(uint8_t nLEDs, uint8_t latch);
void begin(void);
void setLEDcolorPWM(uint8_t n, uint8_t r, uint8_t g, uint8_t b);
uint8_t numLEDs(void);
void setSPIdivider(uint8_t div);
uint8_t getSPIdivider();
void setPWMbits(uint8_t b);
uint8_t getPWMbits();
uint8_t getCPUmax();
void setCPUmax(uint8_t cpumax);
};
| [
"stk8m@virginia.edu"
] | stk8m@virginia.edu |
d3969140aeeba1083035f7684e945c679da4e914 | 075156d964a8de3b2936f6d1a8ce1527b6e8ccf8 | /ExcelToPdf/ExcelToPdf/GeneratedFiles/ui_exceltopdf.h | de3cf4e4a76229ba53636812b5bbbb040d024903 | [] | no_license | deboner972/Team | 4099a65e4da4cfee4594639c064553d8477ed2bf | 5e3de25b78fd832f0ae951b139bd21886bb4c2db | refs/heads/master | 2021-09-02T11:12:39.225596 | 2018-01-02T07:08:41 | 2018-01-02T07:08:41 | 115,466,265 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,872 | h | /********************************************************************************
** Form generated from reading UI file 'exceltopdf.ui'
**
** Created by: Qt User Interface Compiler version 5.6.3
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_EXCELTOPDF_H
#define UI_EXCELTOPDF_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QTextBrowser>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_ExcelToPdfClass
{
public:
QWidget *centralWidget;
QTextBrowser *textBrowser;
QPushButton *setExcelPath;
QTextBrowser *textBrowser_2;
QPushButton *setPdfPath;
QPushButton *convertPdf;
void setupUi(QMainWindow *ExcelToPdfClass)
{
if (ExcelToPdfClass->objectName().isEmpty())
ExcelToPdfClass->setObjectName(QStringLiteral("ExcelToPdfClass"));
ExcelToPdfClass->resize(532, 132);
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(ExcelToPdfClass->sizePolicy().hasHeightForWidth());
ExcelToPdfClass->setSizePolicy(sizePolicy);
ExcelToPdfClass->setMinimumSize(QSize(532, 132));
ExcelToPdfClass->setMaximumSize(QSize(532, 132));
centralWidget = new QWidget(ExcelToPdfClass);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
textBrowser = new QTextBrowser(centralWidget);
textBrowser->setObjectName(QStringLiteral("textBrowser"));
textBrowser->setGeometry(QRect(10, 10, 371, 31));
textBrowser->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
textBrowser->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
textBrowser->setLineWrapMode(QTextEdit::NoWrap);
setExcelPath = new QPushButton(centralWidget);
setExcelPath->setObjectName(QStringLiteral("setExcelPath"));
setExcelPath->setGeometry(QRect(390, 10, 131, 31));
textBrowser_2 = new QTextBrowser(centralWidget);
textBrowser_2->setObjectName(QStringLiteral("textBrowser_2"));
textBrowser_2->setGeometry(QRect(9, 50, 371, 31));
textBrowser_2->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
textBrowser_2->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
textBrowser_2->setLineWrapMode(QTextEdit::NoWrap);
setPdfPath = new QPushButton(centralWidget);
setPdfPath->setObjectName(QStringLiteral("setPdfPath"));
setPdfPath->setGeometry(QRect(390, 50, 131, 31));
convertPdf = new QPushButton(centralWidget);
convertPdf->setObjectName(QStringLiteral("convertPdf"));
convertPdf->setGeometry(QRect(10, 90, 511, 31));
ExcelToPdfClass->setCentralWidget(centralWidget);
retranslateUi(ExcelToPdfClass);
QMetaObject::connectSlotsByName(ExcelToPdfClass);
} // setupUi
void retranslateUi(QMainWindow *ExcelToPdfClass)
{
ExcelToPdfClass->setWindowTitle(QApplication::translate("ExcelToPdfClass", "ExcelToPdf", Q_NULLPTR));
setExcelPath->setText(QApplication::translate("ExcelToPdfClass", "\354\227\264\352\270\260", Q_NULLPTR));
setPdfPath->setText(QApplication::translate("ExcelToPdfClass", "\354\240\200\354\236\245", Q_NULLPTR));
convertPdf->setText(QApplication::translate("ExcelToPdfClass", "PDF \353\263\200\355\231\230", Q_NULLPTR));
} // retranslateUi
};
namespace Ui {
class ExcelToPdfClass: public Ui_ExcelToPdfClass {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_EXCELTOPDF_H
| [
"deboner972@weunus.com"
] | deboner972@weunus.com |
c9e1618667e0ba088fd641081fe5b3df351a3dff | 6f0f1096542beb4e299af24136cbe9d8079e3c90 | /test/ha.cpp | 7861029cf06e721dd76d4523df94f0af51bdf468 | [
"MIT"
] | permissive | yanboyang713/Radio-Telescope | f4bf87433830674a405cc615feff849e1bb39861 | 6dace01f6ad8b9361d52fa8405b0ee787cfc37d8 | refs/heads/master | 2023-08-28T05:52:55.733649 | 2021-10-12T03:22:08 | 2021-10-12T03:22:08 | 416,167,343 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 853 | cpp | // stoi example
#include <iostream> // std::cout
#include <string> // std::string, std::stoi
int main ()
{
std::string str_dec = "2001, A Space Odyssey";
std::string str_hex = "40c3";
std::string str_bin = "-10010110001";
std::string str_auto = "0x7f";
std::string one = "003";
std::string::size_type sz; // alias of size_t
int i_dec = std::stoi (str_dec,&sz);
int i_hex = std::stoi (str_hex,nullptr,16);
int i_bin = std::stoi (str_bin,nullptr,2);
int i_auto = std::stoi (str_auto,nullptr,0);
int test = std::stoi (one, nullptr, 10);
std::cout << str_dec << ": " << i_dec << " and [" << str_dec.substr(sz) << "]\n";
std::cout << str_hex << ": " << i_hex << '\n';
std::cout << str_bin << ": " << i_bin << '\n';
std::cout << str_auto << ": " << i_auto << '\n';
std::cout << test << std::endl;
return 0;
}
| [
"yanboyang713@gmail.com"
] | yanboyang713@gmail.com |
3f5034d3bcb6e09bfa312088af4f7c4e5552d600 | 2affe56b2a708ca96b8303195eeeac5326d9e231 | /toolbox/CurveLab-2.0/fdct_wrapping_cpp/src/ifdct_wrapping.cpp | 1568e4a4addcff316d9a7bc9f81e6ab051aa6f02 | [] | no_license | joy-hyl/iqmetrics | 9820b986c8e240d7dd15f40b854f40081ad2833a | 376b5634a679d463f70290d6322742ee5be0d89b | refs/heads/master | 2022-11-06T10:53:21.007557 | 2013-11-25T01:23:47 | 2013-11-25T01:23:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,200 | cpp | /*
Copyright (C) 2004 Caltech
Written by Lexing Ying
*/
#include "fdct_wrapping.hpp"
#include "fdct_wrapping_inline.hpp"
FDCT_WRAPPING_NS_BEGIN_NAMESPACE
int fdct_wrapping_invsepangle(double XL1, double XL2, int nbangle, vector<CpxNumMat>& csc, CpxOffMat& Xhgh);
int fdct_wrapping_invwavelet(vector<CpxNumMat>& csc, CpxOffMat& Xhgh);
//-------------------------------------------------------------------------------
int ifdct_wrapping(int N1, int N2, int nbscales, int nbangles_coarse, int allcurvelets, vector< vector<CpxNumMat> >& c, CpxNumMat& x)
{
assert(nbscales==c.size() && nbangles_coarse==c[1].size());
int F1 = N1/2; int F2 = N2/2;
//-------------------------------------------angles to Xhgh
vector<int> nbangles(nbscales);
vector<CpxOffMat> Xhghs; Xhghs.resize(nbscales);
if(allcurvelets==1) {
//----
nbangles[0] = 1;
for(int sc=1; sc<nbscales; sc++) nbangles[sc] = nbangles_coarse * pow2( int(ceil(double(sc-1)/2)) );
double XL1 = 4.0*N1/3.0; double XL2 = 4.0*N2/3.0;
for(int sc=nbscales-1; sc>0; sc--) {
fdct_wrapping_invsepangle(XL1, XL2, nbangles[sc], c[sc], Xhghs[sc]);
XL1 /= 2; XL2 /= 2;
}
fdct_wrapping_invwavelet(c[0], Xhghs[0]);
} else {
//----
nbangles[0] = 1;
for(int sc=1; sc<nbscales-1; sc++) nbangles[sc] = nbangles_coarse * pow2( int(ceil(double(sc-1)/2)) );
nbangles[nbscales-1] = 1;
fdct_wrapping_invwavelet(c[nbscales-1], Xhghs[nbscales-1]);
double XL1 = 2.0*N1/3.0; double XL2 = 2.0*N2/3.0;
for(int sc=nbscales-2; sc>0; sc--) {
fdct_wrapping_invsepangle(XL1, XL2, nbangles[sc], c[sc], Xhghs[sc]);
XL1 /= 2; XL2 /= 2;
}
fdct_wrapping_invwavelet(c[0], Xhghs[0]);
}
//-------------------------------------------xhghs to O
//combine
CpxOffMat X;
if(allcurvelets==1) {
double XL1 = 4.0*N1/3.0; double XL2 = 4.0*N2/3.0; //range
int XS1, XS2; int XF1, XF2; double XR1, XR2; fdct_wrapping_rangecompute(XL1, XL2, XS1, XS2, XF1, XF2, XR1, XR2);
X.resize(XS1, XS2);
} else {
X.resize(N1, N2);
}
double XL1 = 4.0*N1/3.0; double XL2 = 4.0*N2/3.0;
int XS1, XS2; int XF1, XF2; double XR1, XR2; fdct_wrapping_rangecompute(XL1, XL2, XS1, XS2, XF1, XF2, XR1, XR2);
for(int sc=nbscales-1; sc>0; sc--) {
double XL1n = XL1/2; double XL2n = XL2/2;
int XS1n, XS2n; int XF1n, XF2n; double XR1n, XR2n;
fdct_wrapping_rangecompute(XL1n, XL2n, XS1n, XS2n, XF1n, XF2n, XR1n, XR2n);
DblOffMat lowpass(XS1n, XS2n);
fdct_wrapping_lowpasscompute(XL1n, XL2n, lowpass);
DblOffMat hghpass(XS1n, XS2n);
for(int j=-XF2n; j<-XF2n+XS2n; j++)
for(int i=-XF1n; i<-XF1n+XS1n; i++)
hghpass(i,j) = sqrt(1-lowpass(i,j)*lowpass(i,j));
for(int j=-XF2n; j<-XF2n+XS2n; j++)
for(int i=-XF1n; i<-XF1n+XS1n; i++)
Xhghs[sc](i,j) *= hghpass(i,j);
for(int j=-XF2n; j<-XF2n+XS2n; j++)
for(int i=-XF1n; i<-XF1n+XS1n; i++)
Xhghs[sc-1](i,j) *= lowpass(i,j);
CpxOffMat& G = Xhghs[sc];
for(int j=G.t(); j<G.t()+G.n(); j++)
for(int i=G.s(); i<G.s()+G.m(); i++)
X(i,j) += G(i,j);
XL1 = XL1/2; XL2 = XL2/2;
fdct_wrapping_rangecompute(XL1, XL2, XS1, XS2, XF1, XF2, XR1, XR2);
}
for(int j=-XF2; j<-XF2+XS2; j++)
for(int i=-XF1; i<-XF1+XS1; i++)
X(i,j) += Xhghs[0](i,j);
// fold
CpxOffMat O(N1, N2);
if(allcurvelets==1) {
double XL1 = 4.0*N1/3.0; double XL2 = 4.0*N2/3.0;
int XS1, XS2; int XF1, XF2; double XR1, XR2; fdct_wrapping_rangecompute(XL1, XL2, XS1, XS2, XF1, XF2, XR1, XR2);
//times pou;
DblOffMat lowpass(XS1,XS2);
fdct_wrapping_lowpasscompute(XL1, XL2, lowpass);
for(int j=-XF2; j<-XF2+XS2; j++)
for(int i=-XF1; i<-XF1+XS1; i++)
X(i,j) *= lowpass(i,j);
IntOffVec t1(XS1);
for(int i=-XF1; i<-XF1+XS1; i++) if( i<-N1/2) t1(i) = i+int(N1); else if(i>(N1-1)/2) t1(i) = i-int(N1); else t1(i) = i;
IntOffVec t2(XS2);
for(int i=-XF2; i<-XF2+XS2; i++) if( i<-N2/2) t2(i) = i+int(N2); else if(i>(N2-1)/2) t2(i) = i-int(N2); else t2(i) = i;
for(int j=-XF2; j<-XF2+XS2; j++)
for(int i=-XF1; i<-XF1+XS1; i++)
O(t1(i), t2(j)) += X(i,j);
} else {
O = X;
}
//------------------------------------------------------------
CpxNumMat T(N1,N2);
fdct_wrapping_ifftshift(O, T);
fftwnd_plan p = fftw2d_create_plan(N2, N1, FFTW_BACKWARD, FFTW_ESTIMATE | FFTW_IN_PLACE);
fftwnd_one(p, (fftw_complex*)T.data(), NULL);
fftwnd_destroy_plan(p);
double sqrtprod = sqrt(double(N1*N2)); //scale
for(int i=0; i<N1; i++) for(int j=0; j<N2; j++) T(i,j) /= sqrtprod;
x = T;
//x.resize(N1, N2);
//fdct_wrapping_fftshift(T, x);
return 0;
}
//---------------------
int fdct_wrapping_invsepangle(double XL1, double XL2, int nbangle, vector<CpxNumMat>& csc, CpxOffMat& Xhgh)
{
typedef pair<int,int> intpair;
map<intpair, fftwnd_plan> planmap;
int XS1, XS2; int XF1, XF2; double XR1, XR2; fdct_wrapping_rangecompute(XL1, XL2, XS1, XS2, XF1, XF2, XR1, XR2);
Xhgh.resize(XS1, XS2);
int nbquadrants = 4;
int nd = nbangle / 4;
int wcnt = 0;
//backup
CpxOffMat Xhghb(Xhgh);
double XL1b = XL1; double XL2b = XL2;
int qvec[] = {2,1,0,3};
for(int qi=0; qi<nbquadrants; qi++) {
int q = qvec[qi];
//ROTATE data to its right position
fdct_wrapping_rotate_forward(q, XL1b, XL2b, XL1, XL2); XL1 = abs(XL1); XL2 = abs(XL2);
fdct_wrapping_rotate_forward(q, Xhghb, Xhgh);
//figure out XS, XF, XR
double XW1 = XL1/nd; double XW2 = XL2/nd;
int XS1, XS2; int XF1, XF2; double XR1, XR2; fdct_wrapping_rangecompute(XL1, XL2, XS1, XS2, XF1, XF2, XR1, XR2);
for(int w=nd-1; w>=0; w--) {
double xs = XR1/4 - (XW1/2)/4;
double xe = XR1;
double ys = -XR2 + (w-0.5)*XW2;
double ye = -XR2 + (w+1.5)*XW2; //x range
int xn = int(ceil(xe-xs)); int yn = int(ceil(ye-ys));
//MAKE THEM ODD
if(xn%2==0) xn++; if(yn%2==0) yn++;
int xf = int(ceil(xs)); //int yf = int(ceil(ys));
//theta
double thts, thtm, thte; //y direction
if(w==0) {
thts = atan2(-1.0, 1.0-1.0/nd);
thtm = atan2(-1.0+1.0/nd, 1.0);
thte = atan2(-1.0+3.0/nd, 1.0);
} else if(w==nd-1) {
thts = atan2(-1.0+(2.0*w-1.0)/nd, 1.0);
thtm = atan2(-1.0+(2.0*w+1.0)/nd, 1.0);
thte = atan2(1.0, 1.0-1.0/nd);
} else {
thts = atan2(-1.0+(2.0*w-1.0)/nd, 1.0);
thtm = atan2(-1.0+(2.0*w+1.0)/nd, 1.0);
thte = atan2(-1.0+(2.0*w+3.0)/nd, 1.0);
}
int xh = xn/2; int yh = yn/2; //half length
CpxOffMat wpdata(xn,yn);
{
//load
int xn = csc[wcnt].m(); int yn = csc[wcnt].n();
CpxNumMat tpdata(csc[wcnt]);
//fft
fftwnd_plan p = NULL;
map<intpair, fftwnd_plan>::iterator mit=planmap.find( intpair(xn,yn) );
if(mit!=planmap.end()) {
p = (*mit).second;
} else {
p = fftw2d_create_plan(yn, xn, FFTW_FORWARD, FFTW_ESTIMATE | FFTW_IN_PLACE);
planmap[ intpair(xn, yn) ] = p;
}
fftwnd_one(p, (fftw_complex*)tpdata.data(), NULL);
double sqrtprod = sqrt(double(xn*yn));
for(int i=0; i<xn; i++) for(int j=0; j<yn; j++) tpdata(i,j) /= sqrtprod;
//fftshift
CpxOffMat rpdata;
fdct_wrapping_fftshift(tpdata,rpdata);
//rotate forward
fdct_wrapping_rotate_forward(q, rpdata, wpdata);
}
double R21 = XR2/XR1; //ratio
for(int xcur=xf; xcur<xe; xcur++) { //for each layer
int yfm = (int)ceil( max(-XR2, R21*xcur*tan(thts)) );
int yto = (int)floor( min(XR2, R21*xcur*tan(thte)) );
for(int ycur=yfm; ycur<=yto; ycur++) {
int tmpx = xcur%xn; if(tmpx<-xh) tmpx+=xn; if(tmpx>=-xh+xn) tmpx-=xn;
int tmpy = ycur%yn; if(tmpy<-yh) tmpy+=yn; if(tmpy>=-yh+yn) tmpy-=yn;
//partition of unity
double thtcur = atan2(ycur/XR2, xcur/XR1);
double wtht;
if(thtcur<thtm) {
double l,r; fdct_wrapping_window((thtcur-thts)/(thtm-thts), l, r);
wtht = l;
} else {
double l,r; fdct_wrapping_window((thtcur-thtm)/(thte-thtm), l, r);
wtht = r;
}
double pou = wtht;
wpdata(tmpx,tmpy) *= pou;
Xhgh(xcur,ycur) += wpdata(tmpx,tmpy);
}
}
wcnt++;
}//w loop
fdct_wrapping_rotate_backward(q, Xhgh, Xhghb);
} //q loop
Xhgh = Xhghb;
XL1 = XL1b; XL2 = XL2b;
assert(wcnt==nbangle);
for(map<intpair, fftwnd_plan>::iterator mit=planmap.begin(); mit!=planmap.end(); mit++) {
fftwnd_plan p = (*mit).second;
fftwnd_destroy_plan(p);
}
return 0;
}
//---------------------
int fdct_wrapping_invwavelet(vector<CpxNumMat>& csc, CpxOffMat& Xhgh)
{
assert(csc.size()==1);
CpxNumMat& C = csc[0];
int N1 = C.m(); int N2 = C.n();
CpxNumMat T(C); //CpxNumMat T(N1, N2); fdct_wrapping_ifftshift(N1, N2, F1, F2, C, T);
fftwnd_plan p = fftw2d_create_plan(N2, N1, FFTW_FORWARD, FFTW_ESTIMATE | FFTW_IN_PLACE);
fftwnd_one(p, (fftw_complex*)T.data(), NULL);
fftwnd_destroy_plan(p);
double sqrtprod = sqrt(double(N1*N2));
for(int j=0; j<N2; j++)
for(int i=0; i<N1; i++)
T(i,j) /= sqrtprod;
Xhgh.resize(N1, N2);
fdct_wrapping_fftshift(T, Xhgh);
return 0;
}
FDCT_WRAPPING_NS_END_NAMESPACE
| [
"joyce_farrell@stanford.edu"
] | joyce_farrell@stanford.edu |
faf3d44170f417a49fd1db7b6033883a9c809e6d | 30acc86f402a8093f15768e8488e563a44051b13 | /initial.h | b768adf5d0a5c9d5ed0cae21182f025fb97e52c6 | [] | no_license | james093131/SE | c18814e6dc48cf4117cdfb61f000972a1d80430e | 00a537a47b108f38c7ab99b3bf0af882650d9113 | refs/heads/master | 2022-12-13T14:54:01.836203 | 2020-09-08T05:27:54 | 2020-09-08T05:27:54 | 290,753,622 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,034 | h |
#include <stdio.h>
#include<stdlib.h>
#include<iostream>
#include<fstream>
#include<sstream>
#include <string.h>
#include<time.h>
#include<math.h>
#include<vector>
#define MR 0.65
using namespace std;
class Final {//儲存當前ITER最好的那組解
public:
vector<int> Best_Searcher;
int Best_Searcher_Fitness;
};
class SE_Init { //SE最主要的一些資訊
public:
vector<vector<int> > Searcher ;//分類
vector<vector<int> > Good ;//分類
vector<vector<int> > SampleV ;//vision search產生的解
vector<int> SampleV_Fitness;//各個SampleV的Fitness
vector<vector<int> >Region_Fitness;//各區的Fitness
vector<int>T_Visit;//紀錄Region造訪次數
vector<int>T_Not_Visit;//紀錄Region未造訪次數
};
class Vision_Search{//主要儲存Vision Search 所需的資訊
public:
vector<double >SampleV_Region_Fitness;//把SampleV一區域來做加總
vector<double >Region_Best_Fitness;//每個Region最佳的Fitness
vector<double >Visit_Or_Not;//未造訪/已造訪
vector<double >Expected_FitnessValue;//儲存各區的最佳值
int Fitness_Sum;//所有Sample總和
};
class RUN{
public:
vector<int> AVG_Iter_Searcher_Fitness;//每一個ITER的平均fitness
int AVG_Best_Search_Fitness;//平均的最佳解
};
void random_zero_or_one(vector<vector<int> > &P)//隨機起始01
{
int a=P.size();
int b=P[0].size();
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
{
int ran=rand()%2;
P[i][j]=ran;
}
}
}
int CUT_Region(vector<vector<int> >&P,int Quan,int pop,int Each_Region_Quantity)//region切
{
int temp=0;
int k=1;
int test=Quan;
int len=0;
while(test>=2)
{
test=test/2;
len++;
}
vector<vector<int> >Region_Cut;
Region_Cut.resize(Quan);
for(int i=0;i<Quan;i++){Region_Cut[i].resize(len);}
while(k<Quan)
{
int check=-1;
temp=0;
for(int i=len-1;i>=0;i--)
{
if(check==1)
{
Region_Cut[k][i]=Region_Cut[k-1][i];
}
else{
if(Region_Cut[k-1][i]==0 && temp==1)
{
Region_Cut[k][i]=1;
temp=0;
check=1;
}
else if(Region_Cut[k-1][i]==0 && temp==0)
{
Region_Cut[k][i]=1;
check=1;
}
else if(Region_Cut[k-1][i]==1 && temp==0)
{
Region_Cut[k][i]=0;
temp=1;
}
else if(Region_Cut[k-1][i]==1 && temp==1)
{
Region_Cut[k][i]=0;
temp=1;
}
}
}
k++;
}
for(int i=0;i<P.size();i++)
{
int temp=i/Each_Region_Quantity;
for(int j=0;j<Region_Cut[0].size();j++)
{
P[i][j] = Region_Cut[temp][j];
}
}
return len;
}
void AVG(vector<int> &P,int len){
for(int i=0;i<P.size();i++)
{
P[i]=P[i]/len;
}
}
void InformationOutput(int run,int bit,int region,int searcher,int sample,int Evaluation,int &AVG_Fitness,vector<int> Avg_Iter_Fitness,double START,double END)
{
fstream file;
file.open("SE.txt",ios::out);
file<<"number of runs : "<<run<<endl;
file<<"number of Evaluation : "<<Evaluation<<endl;
file<<"number of Bit : "<<bit<<endl;
file<<"number of Regions : "<<region<<endl;
file<<"number of Searcher : "<<searcher<<endl;
file<<"number of Sample : "<<sample<<endl;
file<<"Execution Time :"<<(END - START) / CLOCKS_PER_SEC<<"(s)"<<endl;
file<<"Average Fitness : "<<AVG_Fitness<<endl;
for(int i=0;i<Avg_Iter_Fitness.size();i++)
{
file<< (i+1)*Evaluation/Avg_Iter_Fitness.size()<<' '<<(double)Avg_Iter_Fitness[i]*100/bit<<endl;
}
} | [
"james093131@gmail.com"
] | james093131@gmail.com |
2f1b9c853ddb2a7ed94699a33bfbc6bc1f2b0178 | 947c16ea428c396988f790097289289e590e5f38 | /lab_9/src/ui/tabs/statisticstab.hpp | b55aa67d1c1bd68e81d722ed702f89661ebe6543 | [] | no_license | RullDeef/cg-lab | ed350e6560df78b8e490a996683895768142b051 | 8a46de19b595f68afef46aec6dbcb7c5aaf897fa | refs/heads/master | 2023-06-16T08:23:31.431634 | 2021-06-23T16:10:13 | 2021-06-23T16:10:13 | 387,730,748 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 282 | hpp | #pragma once
#include "../core/primitiverenderer.hpp"
#include "charttabwidget.hpp"
namespace ui
{
class StatisticsTab : public LineChartTabWidget
{
public:
StatisticsTab(core::RenderersContainer<core::Circle> renderers, QWidget* parent = Q_NULLPTR);
};
}
| [
"deeroll666@gmail.com"
] | deeroll666@gmail.com |
c2f54389663ef0fd5ade06023b5e87282f20409b | c9fb34b4f10d30e71e7acde6f365d356694abf83 | /PBNeo/Source/PBGame/Public/UMG/PBSubWidget.h | f4270a54223b1e19fcb3a8388ae71fb67b38b831 | [] | no_license | daekyuuu/DKGame2 | a52311e4df0d67132afada8d226ce45a0bd331ef | e5405499e7dcf02225757888c8fbaf847cb200cd | refs/heads/master | 2020-12-02T06:40:23.579274 | 2017-07-12T05:00:08 | 2017-07-12T05:00:08 | 96,866,994 | 9 | 2 | null | null | null | null | UHC | C++ | false | false | 668 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "PBUserWidget.h"
#include "PBSubWidget.generated.h"
/**
* 자식으로 추가하는 경우 사용.(Crosshair, Scoreboard, WeaponInfo, minimap,..)
*/
UCLASS()
class PBGAME_API UPBSubWidget : public UPBUserWidget
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = PBSubWidget)
virtual void Show();
UFUNCTION(BlueprintCallable, Category = PBSubWidget)
virtual void Hide();
UFUNCTION(BlueprintCallable, Category = PBSubWidget)
virtual bool IsOpened();
UFUNCTION(BlueprintCallable, Category = Widget)
virtual void ToggleWidget();
};
| [
"daekyu.park@zepetto.com"
] | daekyu.park@zepetto.com |
c6ee36b18f3710f2cf027a591862c8b9371fb7fb | f870423e588273a1ef7cdb6b2e0ed909e555697b | /dev/vehicle/src/sensors/src/laser.cpp | 6ee6e76dcf91cf43d6887df4e6df7c8223187b93 | [
"BSD-3-Clause"
] | permissive | antarikshnarain/ArtemisLeapFrog | 7b6b8e85f9216f48219d24a39433859b8e38d3dd | 4bfdad2f7696d5ce3de419abbd82e9a3d659ce5a | refs/heads/master | 2023-05-27T02:20:52.019746 | 2021-06-11T00:01:41 | 2021-06-11T00:01:41 | 268,946,141 | 3 | 1 | BSD-3-Clause | 2021-06-10T23:52:07 | 2020-06-03T01:23:53 | C++ | UTF-8 | C++ | false | false | 1,799 | cpp | #include <chrono>
#include <memory>
#include <Serial.hpp>
#include "rclcpp/rclcpp.hpp"
#include "sensors/msg/sensor_laser.hpp"
using namespace std::chrono_literals;
class LaserPublisher : public rclcpp::Node, public Serial
{
private:
rclcpp::Publisher<sensors::msg::SensorLaser>::SharedPtr sensor_publisher_;
rclcpp::TimerBase::SharedPtr timer_;
public:
LaserPublisher(string port, int baud) : Node("SEN0259"), Serial(port, baud, 0, 1, 9)
{
// Create Publisher
this->sensor_publisher_ = this->create_publisher<sensors::msg::SensorLaser>("laser", 10);
// Create lambda function to publish data
auto publish_msg = [this]() -> void {
if(this->IsAvailable())
{
auto message = sensors::msg::SensorLaser();
vector<uint8_t> data = this->Recv();
//RCLCPP_INFO(rclcpp::get_logger("rclcpp"), "Laser data: %d %d %d+%d %d+%d", data[0], data[1], data[3], data[2], data[5], data[4]);
int sum = 0;
// process data and update message
message.distance = (data[3] << 8) | data[2];
message.sig_strength = (data[5] << 8) | data[4];
uint8_t checksum = (uint8_t)data[8];
for(int i=0;i<8;i++)
{
sum += (int8_t)data[i];
}
sum &= 0x00FF;
message.checksum = (sum == checksum);
// Publish
this->sensor_publisher_->publish(message);
}
};
// register publisher with timer changed from 10ms to 100ms
this->timer_ = this->create_wall_timer(100ms, publish_msg);
}
};
int main(int argc, char *argv[])
{
rclcpp::init(argc, argv);
if (argc < 3)
{
printf("Pass port and baudrate as parameters");
return -1;
}
rclcpp::spin(std::make_shared<LaserPublisher>(string(argv[1]), atoi(argv[2])));
printf("Waiting for Serial port to close.\n");
std::this_thread::sleep_for(chrono::milliseconds(1000));
rclcpp::shutdown();
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
e41c36bf68ab223934d01ec71ca0609e45a3386e | dfbc368e6a315921dbff9e66dec0fdd2f643da92 | /不确定度计算/operation.h | 243928343e6614a28609fd119cf98c56852368a8 | [] | no_license | sora-mono/uncertainty_calculate | 36cf425833e3df920f17009690c86a7a02794aee | 76885bd27af85c99f596a77220509dbe3071f259 | refs/heads/master | 2022-12-29T17:52:09.950580 | 2020-10-18T13:00:45 | 2020-10-18T13:00:45 | 298,500,723 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,118 | h | #pragma once
#include "reality.h"
#include "uncertain.h"
using std::ostream;
class operation
{
private:
reality realpart;
uncertain uncertainpart;
public:
operation(long double real, long effective_digits, long uncertain_fin, long uncertain_digits);
operation(long double real, long effective_digits, long double uncertain_instrument, long double uncertain_measurement);
operation(const reality& real, const uncertain uncer);
operation(const operation& node);
operation operator+(const operation& node)const;
operation operator-(const operation& node)const;
operation operator*(const operation& node)const;
operation operator*(const long double k)const;
operation operator/(const operation& node)const;
bool operator==(const operation& node)const;
operation operator^(const long double k)const;
friend operation operator*(const long double k, const operation& node);
friend operation ln(const operation& node);
friend operation sin(const operation& node);
friend operation operator^(const long double k, const operation& node);
friend ostream& operator<<(ostream& out, const operation & node);
};
| [
"849526320@qq.com"
] | 849526320@qq.com |
9a10b92652858ff7e832333a1e61fd6205b951ae | 4e6f483d4a80a57d7f89f71ccaa4382c303d5017 | /libbrcdchain/Verify.h | 6bb46b2d0ba363e67388c059a52ebbeb464e8d2a | [] | no_license | youthonline/cpp-lsac | 004816e6ceae024922c0cd84838601462652357f | 105ad38bd60cf34c18eae13fc4ce87ca9d46a198 | refs/heads/master | 2020-07-01T15:47:43.761886 | 2019-08-07T01:53:39 | 2019-08-07T01:53:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 414 | h | #pragma once
#include <State.h>
#include <libdevcore/Address.h>
namespace dev{
namespace brc{
class Verify{
public:
Verify(){}
///verify standby_node to create block
///@return true if can create
bool verify_standby(State const& state, int64_t block_time, Address const& standby_addr, size_t varlitorInterval_time) const;
};
}
} | [
"timobaer@baerchain.net"
] | timobaer@baerchain.net |
7714dfbd647f91d2ec8ff4dbb1743e0068e9dc7c | 1549654da3e5693baf3d3fd3f9fee6b906187660 | /jezzball/src/box.h | 1e9a1d0d35d2d9d778e9e109f7658fef10d472ac | [] | no_license | kazzmir/hacks | c5a51daf663157f1e29a6bd16a93c54e1a656492 | e0402500996e5705e91c437d4a54eb4396289233 | refs/heads/master | 2021-07-04T00:45:02.005565 | 2021-01-10T19:51:39 | 2021-01-10T19:51:39 | 216,437,019 | 0 | 0 | null | 2021-01-10T19:51:40 | 2019-10-20T22:41:15 | C++ | UTF-8 | C++ | false | false | 722 | h | #ifndef _box_h_
#define _box_h_
class Bitmap;
class Box{
public:
Box( int _x1, int _y1, int _x2, int _y2, Bitmap * _pic = 0 );
Box( const Box & copy );
virtual bool collide( Box * other );
virtual void setPic( Bitmap * _pic );
virtual Bitmap * getPic();
virtual void setCoord( int _x1, int _y1, int _x2, int _y2 );
virtual void draw( Bitmap * work );
virtual int getX1() const;
virtual int getY1() const;
virtual int getX2() const;
virtual int getY2() const;
virtual void print();
virtual ~Box();
protected:
int x1, y1, x2, y2;
Bitmap * pic;
int my_box_index;
};
#ifdef DEBUG
#define MAX_BOXES 1000000
extern Box * box_array[ MAX_BOXES ];
void init_boxes();
void print_boxes();
#endif
#endif
| [
"jon@rafkind.com"
] | jon@rafkind.com |
71830e4b08bee886b5efc8fbcaab7856986dcb73 | cbbef8580d0571c84ab4ce5a559e0fb9d660f485 | /problems/D6638/665967.100.cpp | d544f2acd88b537f12ee0b4bcbeee46ba0afe9e5 | [] | no_license | yuantailing/tsinsen | efb4c0297e096b8fa64a3390d6bde3cbaaddb217 | a92759dc965ed58a33536e8c6faaa19b0931afbc | refs/heads/main | 2023-07-08T11:44:32.294152 | 2021-08-09T19:34:07 | 2021-08-09T19:34:07 | 394,414,206 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 603 | cpp | #include <iostream>
#include <cstdio>
using namespace std;
bool isCh(char c) {
return (c>='A' && c<='Z') || (c>='a' && c<='z');
}
int main()
{
int N, M;
scanf("%d%d", &N, &M);
int *v = new int[1<<20];
for (int i = 0; i < N; i++)
scanf("%d", v+i);
int e;
while (scanf("%d", &e) == 1) {
int lo = 0, hi = N;
while (lo < hi) {
int mi = (lo + hi) >> 1;
if (e < v[mi])
hi = mi;
else
lo = mi + 1;
}
--lo;
printf("%d\n", v[lo]==e ? lo : -1);
}
return 0;
}
| [
"yuantailing@gmail.com"
] | yuantailing@gmail.com |
6d1b4ce9cb0d3415d73045b8cdff5b03b0cac906 | 25d62d7206fe9e7b6838dfb9d4dc272aa003b40e | /complex_num.h | a2e0f680ca0b739aeb44038bad9389e1165d14ca | [] | no_license | DwarfMason/Complex_Num | 4757c358aab46296ec6f6eea84ffd60593356223 | 0373c4384d1dc0ae3991f45a26811b0d99688dd0 | refs/heads/master | 2021-10-14T15:34:59.867598 | 2019-02-05T03:08:17 | 2019-02-05T03:08:17 | 168,649,776 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,911 | h | #pragma once
#include <iosfwd>
namespace complex {
class CartCompNum {
private:
double re_, im_;
public:
CartCompNum();
explicit CartCompNum(double);
CartCompNum(double, double);
CartCompNum(const CartCompNum &);
double GetRe();
double GetIm();
void SetRe(double);
void SetIm(double);
CartCompNum& operator=(const CartCompNum &);
CartCompNum operator+();
CartCompNum operator+(const CartCompNum &);
CartCompNum operator+(const double &);
CartCompNum operator+=(const CartCompNum &);
friend CartCompNum operator+(const double &,
const CartCompNum &);
CartCompNum operator-();
CartCompNum operator-(const CartCompNum &);
CartCompNum operator-(const double &);
CartCompNum operator-=(const CartCompNum &);
friend CartCompNum operator-(const double &,
const CartCompNum &);
CartCompNum operator*(const CartCompNum &);
CartCompNum operator*(const double &);
CartCompNum operator*=(const CartCompNum &);
friend CartCompNum operator*(const double &,
const CartCompNum &);
CartCompNum operator/(const CartCompNum &);
CartCompNum operator/(const double &);
CartCompNum operator/=(const CartCompNum &);
double abs() const;
double arg() const;
friend std::ostream &operator<<(std::ostream &, CartCompNum &);
friend std::istream &operator>>(std::istream &, CartCompNum &);
friend bool operator==(const CartCompNum &, const CartCompNum &);
};
class PolarCompNum {
private:
double r_, f_;
public:
PolarCompNum();
explicit PolarCompNum(double r);
PolarCompNum(double, double);
PolarCompNum(const PolarCompNum &);
double GetR();
double GetF();
void SetR(double);
void SetF(double);
PolarCompNum operator=(const PolarCompNum &);
PolarCompNum operator+();
PolarCompNum operator+(const PolarCompNum &);
PolarCompNum operator+=(const PolarCompNum &);
PolarCompNum operator-();
PolarCompNum operator-(const PolarCompNum &);
PolarCompNum operator-=(const PolarCompNum &);
PolarCompNum operator*(const PolarCompNum &);
PolarCompNum operator*(double);
PolarCompNum operator*=(double);
PolarCompNum operator*=(const PolarCompNum &);
double arg() const;
double abs() const;
PolarCompNum operator/(const PolarCompNum &);
PolarCompNum operator/(double);
PolarCompNum operator/=(double);
PolarCompNum operator/=(const PolarCompNum &);
friend std::ostream &operator<<(std::ostream &, PolarCompNum &);
friend std::istream &operator>>(std::istream &, PolarCompNum &);
friend bool operator==(const PolarCompNum &, const PolarCompNum &);
friend PolarCompNum bpow(const PolarCompNum& value, int n);
friend CartCompNum PolarToCart(const PolarCompNum &);
};
CartCompNum PolarToCart(const PolarCompNum &);
PolarCompNum CartToPolar(const CartCompNum &);
CartCompNum bpow(const CartCompNum &value, int n);
}
| [
"dwarfmason@users.noreply.github.com"
] | dwarfmason@users.noreply.github.com |
9fee4e7227133939b445ca76f808075b53dc659f | 3a4e5bfa6e3c0ea7d701087cf0b574866101d935 | /System/Screen/Screen.h | 09e291357d4d28b8749c2f186400e1602bdbd50b | [
"MIT"
] | permissive | Prashant-Jonny/kernel | 7c62a58b56461213d9581131f368f0f8dc4e1122 | 08e9b109dc2995e190c510888e5004bb6f868ef2 | refs/heads/master | 2020-12-30T18:03:50.812611 | 2015-08-17T10:16:33 | 2015-08-17T10:16:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 227 | h | #ifndef _SCREEN_SCREEN_H_
#define _SCREEN_SCREEN_H_
class Screen
{
public:
static void Clear();
static void Write(const char* text);
static void WriteLine(const char* text);
static void WriteLine();
};
#endif | [
"julien.batonnet@gmail.com"
] | julien.batonnet@gmail.com |
c6684f5f47b88e43c574dd93845e10c4889d7fc6 | d14432b9ed1e888cb8b4c9c99cd15e55b5218551 | /_aux.cpp | c99f31bda7129aecf45373879e7affb2a33d5b9a | [] | no_license | JohnTScherer/MemorySimulator | 1001b99e46ea00f8d05b6fd93e73232e7da2befa | c36883cf07095b9bc0176975f2ff4d8aeb18c115 | refs/heads/master | 2020-03-30T06:26:55.318821 | 2014-03-11T18:40:30 | 2014-03-11T18:40:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,870 | cpp | // aux.cpp
// John Scherer
#include "_aux.h"
#include <iostream>
#define MEMSIZE 2400
// determine the correct memory cell to begin allocating for the new process
int get_mem_start_pos( char * memory, int p_size, int start )
{
bool avail = false;
int counter = 0, j = 0, excess = INT_MAX;
int start_pos = -1;
if ( alloc_algorithm == 'f' )//********FIRST********//
{
for( int i=80; i<MEMSIZE; i++ )
{
if( memory[i] == '.' )//if its an empty process
{
for(j=0; j<p_size; j++)//search this process up till the size of the new process
{
if( memory[i+j] == '.' ) counter++;//increment counter if process is still free
if(counter == p_size)//if the amount of consecutive processes is the size of the new process
{
avail = true;//bool to check if the space is available
start_pos = i;//sets the start position to the position of the first '.'
}
}
}
if(avail == true) break;//if the first spot large enough to hold the new process is found
counter = 0;
i = i+j;
}
if(avail == false)//didn't find a space big enough
return -1;
else
return start_pos;
}
else if ( alloc_algorithm == 'b' )//*******BEST********//
{
for( int i=80; i<MEMSIZE; i++ )
{
j = 0;
counter = 0;
avail = false;
while(memory[i+j] == '.')
{
counter++;
if(counter == p_size)//this empty memory space has enough to store the new process
{
avail = true;
}
j++;
}
if(avail == true)//a spot in memory has been found
{//LOW WATER MARK
if(counter < excess){//if it has less than the previously smallest memory space
excess = counter;//mark this the new best size
start_pos = i;//i is the new best starting postion
}
}
i = i+j;//increment i by however long the empty memory space was, 0 if none was found
}
return start_pos;
}
else if ( alloc_algorithm == 'n' )//********NEXT********//
{
for(int i=start; i<MEMSIZE; i++)
{
if( memory[i] == '.' )//if we reach an empty memory loc
{
for(j=0; j<p_size; j++)//for the size of the new process
{
if( memory[i+j] == '.' ) counter++;//incremnt this counter every time there is an open space
if(counter == p_size)//if there is enough space to fill with new process
{
avail = true;//flag for the space being good
start_pos = i;// setting the initial position == i
}
}
}
if(avail == true) break;
counter = 0;
i = i+j;
}
if(avail == true) return start_pos;
for(int i=80; i<start; i++)
{
j=0;
counter = 0;
while(memory[i+j] == '.')//for as long as there is an empty memory space
{
counter++; //increment this counter
if(counter == p_size)// if/when it reaches the size of the new process
{
avail = true;//mark flag for avail space
start_pos = i;// start position for new process was the initial 'i'
}
j++;
}
if(avail == true) break;
counter = 0;
i = i+j;
}
if(avail == true) return start_pos;
else
return -1;
}
else if ( alloc_algorithm == 'w' )//**********WORST**********//
{
excess = 0;
for( int i=80; i<MEMSIZE; i++ )
{
j = 0;
counter = 0;
avail = false;
while(memory[i+j] == '.')//for as long as there is an empty memory space
{
counter++;
if(counter == p_size)//this empty memory space has enough to store the new process
{
avail = true;
}
j++;
}
if(avail == true)
{//HIGH WATER MARK
if(counter > excess){//if the current set of memory has more available then the last
excess = counter;//set this as the new available worst mem space
start_pos = i;
}
}
i = i+j;
}
return start_pos;
}
else if ( alloc_algorithm == 'y' ){//******Non-CONTIGUOUS*************//
for( int i=80; i<MEMSIZE; i++ )
{
if(memory[i] == '.'){
avail = true;
return i;
}
}
if(avail == false) return -1;
}
return -1;
}
// this function performs defragmentation on the current memory map
void defrag_step( char * memory )
{
int free_block_size, application_block_size;
for ( int i = 80; i < MEMSIZE; ++i )
{
if ( memory[i] == '.' )
{
// encountered a free memory cell
// get length of free block
free_block_size = 0;
application_block_size = 0;
get_next_block_sizes( memory, i, free_block_size, application_block_size );
// move the application block back to the the free block region
for ( int j = i; j < (i + application_block_size); ++j )
{
// cout << j << "(" << memory[j] << ") = " << j + free_block_size << "(" << memory[j + free_block_size] << ")" << endl;
memory[j] = memory[j + free_block_size];
}
// set stale application memory to free memory
int j;
if ( free_block_size > application_block_size )
j = i + free_block_size;
else
j = i + application_block_size;
// cout << "freeing stale app memory, starting at " << j << " (" << memory[j] << ")" << endl;
// cout << "--- or should I start here: " << i + free_block_size + application_block_size
// << "(" << memory[i + free_block_size + application_block_size] << ") ???" << endl;
while ( memory[j] != '.' )
{
memory[j] = '.';
++j;
}
return;
}
}
}
void defrag( char * memory )
{
while(is_fragmented( memory ))
{
defrag_step( memory );
}
}
//gets the number of processes that didn't need to be compressed
int get_num_compact_processes( char * memory )
{
int compactProcesses = 0;
char currentProcess, lastProcess;
lastProcess = memory[79];
for(int i=80; i<MEMSIZE; i++)
{
currentProcess = memory[i];
if(currentProcess == '.') return compactProcesses;
else if(lastProcess != currentProcess)
{
lastProcess = currentProcess;
compactProcesses++;
}
}
return -1;
}
//gets the total number of processes that should be compact at the beginning of memory
int get_tot_num_processes( char * memory )
{
int numProcesses = 0;
char currentProcess, lastProcess;
lastProcess = memory[79];
for(int i=80; i<MEMSIZE; i++)
{
currentProcess = memory[i];
if(currentProcess == '.') return numProcesses;
else if(lastProcess != currentProcess){
lastProcess = currentProcess;
numProcesses++;
}
}
return -1;
}
bool sufficient_memory_for_new_process( char * memory, int process_size )
{
int temp, j;
for( int i=80; i<MEMSIZE; i++ )
{
j=0;
temp=0;
while(memory[i+j] == '.'){
temp++;
if(temp == process_size) return true;
j++;
}
i=i+j;
}
return false;
}
int get_num_free_cells( char * memory )
{
int freeCells = 0;
for( int i=80; i<MEMSIZE; i++ )
if(memory[i] == '.') freeCells++;
return freeCells;
}
| [
"john.t.scherer@gmail.com"
] | john.t.scherer@gmail.com |
6ea322924450e881caf84e604fbca0b7377b0d7f | 81b93a8bc16023e31171ce68da0751b3a428696f | /src/drivers/tanway_lidar_driver/src/tanway_m16_lidar_node.cpp | d3ce6918947846dfcb0d843e14b618b6202425f8 | [] | no_license | github188/agv | 3373b9b86203b0b2b98019abfc1058112eb394e2 | 3577ea7f0b561eb791241327a4c05e325d76808c | refs/heads/master | 2022-04-03T20:29:43.938463 | 2019-12-19T10:22:05 | 2019-12-19T10:22:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,549 | cpp | #include <ros/ros.h>
#include <arpa/inet.h>
#include <boost/array.hpp>
#include <boost/asio.hpp>
#include <boost/predef/other/endian.h>
#include <boost/thread.hpp>
#include <iostream>
#include <math.h>
#include <netinet/in.h>
#include <pcl/common/transforms.h>
#include <pcl/conversions.h>
#include <pcl_ros/point_cloud.h> //use these to convert between PCL and ROS datatypes
#include <sensor_msgs/PointCloud2.h> //ROS message type to publish a pointCloud
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
//////////////////////////////////////////////////////////////
#include "ml16_view/TWColor.h"
#include "common_functions.h"
#include "glog_helper.h"
#include "udp_process.h"
#include <list>
#include <map>
#include <thread>
#include <yaml-cpp/yaml.h>
#include <sys/syscall.h>
#include <unistd.h> //getpid()
#define TANWAY_YAML_FILE_PATH "/work/superg_agv/src/drivers/tanway_lidar_driver/cfg/"
#define TANWAY_YAML_FILE_NAME "config.yaml"
using namespace std;
#define NODE_NAME "TW_m16_radar_node"
struct TanWay_Device
{
std::string device_name;
bool device_enable;
std::string device_ip;
int intput_port;
std::string topic_name_1;
double StartAngle;
double EndAngle;
double StaticQuantityFirst[16];
};
namespace YAML
{
// The >> operator disappeared in yaml-cpp 0.5, so this function is
// added to provide support for code written under the yaml-cpp 0.3 API.
template < typename T > void operator>>(const YAML::Node &node, T &i)
{
i = node.as< T >();
}
} /* YAML */
// now the extraction operators for these types //重载 >> 预算符。。。。
void operator>>(const YAML::Node &node, TanWay_Device &tanwayDevice)
{
node["device_name"] >> tanwayDevice.device_name;
node["device_enable"] >> tanwayDevice.device_enable;
node["device_ip"] >> tanwayDevice.device_ip;
node["intput_port"] >> tanwayDevice.intput_port;
node["topic_name_1"] >> tanwayDevice.topic_name_1;
// node["StaticQuantityFirst"] >> tanwayDevice.StaticQuantityFirst;
for (size_t i = 0; i < 16; i++)
{
node["StaticQuantityFirst"][i] >> tanwayDevice.StaticQuantityFirst[i];
}
}
class TWLidarDataProcess : public UdpProcessCallBack
{
public:
float verticalChannels26[16] = {-13.0f, -11.27f, -9.53f, -7.80f, -6.07f, -4.33f, -2.60f, -0.87f,
0.87f, 2.60f, 4.33f, 6.07f, 7.80f, 9.53f, 11.27f, 13.0f};
float verticalChannels11[16] = {-5.50f, -4.77f, -4.03f, -3.30f, -2.57f, -1.83f, -1.10f, -0.37f,
0.37f, 1.10f, 1.83f, 2.57f, 3.30f, 4.03f, 4.77f, 5.50f};
bool recordRawData = true;
float horizonalPerAngle = 0.3f;
int circleCounter = 0;
float RA = ( float )(3.14159265f / 180.0f);
float filter_L = 0.01;
float c = 2.99;
float hAPre = -1.0f;
int myUDPCount = 0;
// std::string host = "192.168.2.200";
// std::string LiDARhost = "192.168.2.101";
std::string frame_id = "odom";
std::string topic = "/ml16_cloud";
std::string Color = "Indoor";
// int port = 5600;
// int LiDARport = 5050;
char SQ[17] = "";
double StaticQuantityFirst[16] = {0};
float verticalChannels[16];
int VerticleAngle = 11;
double StartAngle = 2;
double EndAngle = 350;
bool needPublishCloud = true;
bool transformCloud_Status = false;
double trans_x = 0;
double trans_y = 0;
double trans_z = 0;
double rotate_theta_xy = 3.14;
double rotate_theta_xz = 3.14;
double rotate_theta_yz = 3.14;
bool GPS_Status = false;
// sensor_msgs::PointCloud2 ros_cloud;
// ros::Publisher pubCloud;
// socklen_t sockfd, ret, addrlen;
// struct sockaddr_in saddr, caddr;
// pthread_t pid;
// pthread_attr_t pida;
// @brief Data tansform
public:
TWLidarDataProcess(TanWay_Device &TanWay_Device_info);
virtual ~TWLidarDataProcess();
// void getParam(ros::NodeHandle node, ros::NodeHandle nh_private);
int TwoHextoFourX(unsigned char x1, unsigned char x2);
int HexToInt(unsigned char x1);
pcl::PointCloud< pcl::PointXYZRGB >::Ptr transformCloud(pcl::PointCloud< pcl::PointXYZRGB >::Ptr pPointCloudIn,
double x, double y, double z, double rotate_theta_xy,
double rotate_theta_xz, double rotate_theta_yz);
pcl::PointCloud< pcl::PointXYZRGB >::Ptr process_XYZ(pcl::PointCloud< pcl::PointXYZRGB >::Ptr point_cloud_clr_ptr,
float verticalChannels[], unsigned char *buf, float hA,
double *StaticQuantity, std::string Color);
int publishCloud(pcl::PointCloud< pcl::PointXYZRGB >::Ptr point_cloud_clr_ptr_n1);
void OnUdpProcessCallBack(unsigned char *data, int len, struct sockaddr_in addr_);
void TW_lidar_Sender();
void start();
// void setTanWayParams(TanWay_Device &TanWay_Device_info);
list< sensor_msgs::PointCloud2 > list_ros_cloud_;
// pcl::PointCloud< pcl::PointXYZRGB >::Ptr point_cloud_ptr1(new pcl::PointCloud< pcl::PointXYZRGB >);
pcl::PointCloud< pcl::PointXYZRGB >::Ptr point_cloud_clr_ptr_n1_;
};
TWLidarDataProcess::TWLidarDataProcess(TanWay_Device &TanWay_Device_info)
{
topic = TanWay_Device_info.topic_name_1;
StartAngle = TanWay_Device_info.StartAngle;
EndAngle = TanWay_Device_info.EndAngle;
// for (size_t i = 0; i < 16; i++)
// {
// StaticQuantityFirst[i] = TanWay_Device_info.StaticQuantityFirst[i];
// }
memcpy(StaticQuantityFirst, TanWay_Device_info.StaticQuantityFirst, sizeof(TanWay_Device_info.StaticQuantityFirst));
point_cloud_clr_ptr_n1_.reset(new pcl::PointCloud< pcl::PointXYZRGB >);
if (VerticleAngle == 11)
{
memcpy(verticalChannels, verticalChannels11, sizeof(verticalChannels11));
}
else if (VerticleAngle == 26)
{
memcpy(verticalChannels, verticalChannels26, sizeof(verticalChannels11));
}
}
TWLidarDataProcess::~TWLidarDataProcess(){};
// void TWLidarDataProcess::getParam()
// {
// if (VerticleAngle == 11)
// {
// memcpy(verticalChannels, verticalChannels11, sizeof(verticalChannels11));
// }
// else if (VerticleAngle == 26)
// {
// memcpy(verticalChannels, verticalChannels26, sizeof(verticalChannels11));
// }
// }
int TWLidarDataProcess::TwoHextoFourX(unsigned char x1, unsigned char x2)
{
int a;
char chbuf_high[0x20];
sprintf(chbuf_high, "%02X%02X", x1, x2);
sscanf(chbuf_high, "%04X", &a);
return a;
}
int TWLidarDataProcess::HexToInt(unsigned char x1)
{
int a;
char chbuf_high[0x10];
sprintf(chbuf_high, "%02X", x1);
sscanf(chbuf_high, "%02X", &a);
return a;
}
pcl::PointCloud< pcl::PointXYZRGB >::Ptr
TWLidarDataProcess::transformCloud(pcl::PointCloud< pcl::PointXYZRGB >::Ptr pPointCloudIn, double x, double y, double z,
double theta_xy, double theta_xz, double theta_yz)
{
Eigen::Affine3f transform = Eigen::Affine3f::Identity();
transform.translation() << x, y, z;
transform.rotate(Eigen::AngleAxisf(theta_xy, Eigen::Vector3f::UnitZ()));
transform.rotate(Eigen::AngleAxisf(theta_xz, Eigen::Vector3f::UnitY()));
transform.rotate(Eigen::AngleAxisf(theta_yz, Eigen::Vector3f::UnitX()));
pcl::PointCloud< pcl::PointXYZRGB >::Ptr pPointCloudOut(new pcl::PointCloud< pcl::PointXYZRGB >());
pcl::transformPointCloud(*pPointCloudIn, *pPointCloudOut, transform);
return pPointCloudOut;
}
pcl::PointCloud< pcl::PointXYZRGB >::Ptr
TWLidarDataProcess::process_XYZ(pcl::PointCloud< pcl::PointXYZRGB >::Ptr point_cloud_clr_ptr, float verticalChannels[],
unsigned char *buf, float hA, double *StaticQuantity, std::string Color)
{
float myHA = (hA - 16.5) * 2;
double cos_hA = cos(myHA * RA);
double sin_hA = sin(myHA * RA);
int xx = 1;
while (xx <= 16)
{
int index = 4 + (xx - 1) * 6;
int seq = HexToInt(buf[index]);
int color = HexToInt(buf[index + 5]);
int hexToInt = TwoHextoFourX(buf[index + 2], buf[index + 1]);
float L = hexToInt * c * 32 / 10000.f / 2;
L = ((L - StaticQuantity[seq - 1]) > 0) ? (L - StaticQuantity[seq - 1]) : 0;
if (L > 0 && L < 300)
{
float vA = verticalChannels[seq - 1];
double cos_vA_RA = cos(vA * RA);
double x = L * cos_vA_RA * cos_hA;
double y = L * cos_vA_RA * sin_hA;
double z = L * sin(vA * RA);
pcl::PointXYZRGB basic_point;
basic_point.x = x;
basic_point.y = y;
basic_point.z = z;
TWColor twcolor;
if (Color == "None")
{
uint32_t rgb = twcolor.ConstColor();
basic_point.rgb = *reinterpret_cast< float * >(&rgb);
}
if (Color == "Indoor")
{
uint32_t rgb = twcolor.IndoorColor(L);
basic_point.rgb = *reinterpret_cast< float * >(&rgb);
}
if (Color == "Outdoor")
{
uint32_t rgb = twcolor.OutdoorColor(L);
basic_point.rgb = *reinterpret_cast< float * >(&rgb);
}
point_cloud_clr_ptr->points.push_back(basic_point);
}
xx++;
}
return point_cloud_clr_ptr;
}
void TWLidarDataProcess::OnUdpProcessCallBack(unsigned char *data, int len, struct sockaddr_in addr_)
{
//计算hA
float hA = TwoHextoFourX(data[8], data[7]) / 100.0f;
if ((StartAngle <= hA && hA <= EndAngle))
{
// ROS_INFO("[%s](StartAngle <= hA && hA <= EndAngle) hA = %f", ns.data(), hA);
needPublishCloud = true;
point_cloud_clr_ptr_n1_ =
process_XYZ(point_cloud_clr_ptr_n1_, verticalChannels, data, hA, StaticQuantityFirst, Color);
}
if (hA > EndAngle && needPublishCloud)
{
// ROS_INFO("[%s]hA > EndAngle && needPublishCloud hA = %f", ns.data(), hA);
point_cloud_clr_ptr_n1_->width = ( int )point_cloud_clr_ptr_n1_->points.size();
point_cloud_clr_ptr_n1_->height = 1;
point_cloud_clr_ptr_n1_->header.frame_id = frame_id;
ROS_DEBUG("Publish num: [%d]", ( int )point_cloud_clr_ptr_n1_->points.size());
if (transformCloud_Status == true)
point_cloud_clr_ptr_n1_ = transformCloud(point_cloud_clr_ptr_n1_, trans_x, trans_y, trans_z, rotate_theta_xy,
rotate_theta_xz, rotate_theta_yz);
sensor_msgs::PointCloud2 ros_cloud;
pcl::toROSMsg(*point_cloud_clr_ptr_n1_, ros_cloud);
if (GPS_Status == true)
{
int GPSmin = HexToInt(data[100]);
int GPSsec = HexToInt(data[101]);
int GPSusec = TwoHextoFourX(data[103], data[102]);
time_t time_now;
time_t GPStime;
time(&time_now);
tm *GPSlocaltime = localtime(&time_now);
GPSlocaltime->tm_min = GPSmin;
GPSlocaltime->tm_sec = GPSsec;
GPStime = mktime(GPSlocaltime);
ros_cloud.header.stamp = ros::Time(GPStime);
ros_cloud.header.stamp.nsec = GPSusec * 1000000;
}
else
{
ros_cloud.header.stamp = ros::Time::now();
}
list_ros_cloud_.push_back(ros_cloud);
point_cloud_clr_ptr_n1_->points.clear();
/* pthread_create(&pid, &pida, clearVector, &point_cloud_clr_ptr_n1_->points);*/
needPublishCloud = false;
}
if (hAPre != hA)
{
hAPre = hA;
}
return;
}
//发布话题
void TWLidarDataProcess::TW_lidar_Sender()
{
ROS_INFO("process[%d] thread[%u] TW_lidar_Sender Start!", getpid(), ( unsigned int )pthread_self());
ros::NodeHandle nh;
ros::Publisher pubCloud = nh.advertise< sensor_msgs::PointCloud2 >(topic, 1);
ros::Rate loop_rate(100);
while (ros::ok())
{
loop_rate.sleep();
if (!list_ros_cloud_.empty())
{
sensor_msgs::PointCloud2 ros_cloud = list_ros_cloud_.front();
pubCloud.publish(ros_cloud);
list_ros_cloud_.pop_front();
} // list_ros_cloud_.empty()
} // while (ros::ok())
}
void TWLidarDataProcess::start()
{
boost::thread thrd(boost::bind(&TWLidarDataProcess::TW_lidar_Sender, this));
thrd.detach();
}
int main(int argc, char *argv[])
{
ROS_INFO("ROS node is star, name is [%s], file name is %s", NODE_NAME, argv[0]);
// GLogHelper gh(argv[0]);
ros::init(argc, argv, NODE_NAME); // node name
ros::NodeHandle nh;
// glog
GLogHelper gh(argv[0]);
gh.setLogDirectory(argv[0]);
// get yaml file path
char *home_path = getenv("HOME");
char yaml_file_name[1024] = {0};
sprintf(yaml_file_name, "%s%s%s", home_path, TANWAY_YAML_FILE_PATH, TANWAY_YAML_FILE_NAME);
SUPERG_INFO << "yaml_file_name:" << yaml_file_name;
///////////////////////////////////////////////////////////////////////////////////////////////////
std::string file_name = yaml_file_name;
YAML::Node doc;
doc = YAML::LoadFile(file_name);
SUPERG_INFO << "config_num: " << doc.size();
SUPERG_INFO << "doc[sensor_name]: " << doc["sensor_name"];
SUPERG_INFO << "doc[device_list]: " << doc["device_list"].size();
ostringstream log_dir_stream;
log_dir_stream.fill('0');
log_dir_stream << home_path << doc["log_dir"].as< string >();
SUPERG_INFO << "log_dir_: " << log_dir_stream.str();
// udp class
UdpProcess udp_[doc["device_list"].size()];
// radar data process class
boost::shared_ptr< TWLidarDataProcess > lidar_[doc["device_list"].size()];
for (unsigned i = 0; i < doc["device_list"].size(); i++)
{
TanWay_Device TanWay_Device_;
doc["device_list"][i] >> TanWay_Device_;
// SUPERG_INFO << "device_name: " << TanWay_Device_.device_name;
// SUPERG_INFO << "device_ip: " << TanWay_Device_.device_ip;
// SUPERG_INFO << "device_enable: " << TanWay_Device_.device_enable;
// SUPERG_INFO << "intput_port: " << TanWay_Device_.intput_port;
// SUPERG_INFO << "topic_name_1: " << TanWay_Device_.topic_name_1;
if (TanWay_Device_.device_enable)
{
udp_[i].log_dir_ = log_dir_stream.str();
udp_[i].sensor_name_ = doc["sensor_name"].as< string >();
udp_[i].device_name_ = TanWay_Device_.device_name;
lidar_[i].reset(new TWLidarDataProcess(TanWay_Device_));
if (udp_[i].Initial(lidar_[i], TanWay_Device_.device_ip, TanWay_Device_.intput_port, 205) == 1)
{
lidar_[i]->start();
}
}
}
/////////////////////////////////////////////////////////////////////////
ros::spin();
return 0;
} | [
"sheng.tao@superg.ai"
] | sheng.tao@superg.ai |
6a316c650a831fee99e813eeb3e0c17eb1b18be3 | af6c9242685d646f958e7874ff7ec4314017dd46 | /2019.1寒假集训/2019-2-16&&2019-2-17 张若天 DP/test.cpp | 4bc4f7134145f8da935aaba00e4e7f1ebd452c00 | [] | no_license | Doveqise/Class | 65df2cb634ee462498478e2e0a6431726a028333 | 80f2349ae1d45f1d985082f35bfefa01b8d581eb | refs/heads/master | 2020-05-20T04:05:27.320624 | 2019-12-07T08:13:29 | 2019-12-07T08:13:29 | 185,373,620 | 4 | 1 | null | 2019-05-07T10:23:01 | 2019-05-07T09:52:18 | HTML | GB18030 | C++ | false | false | 521 | cpp | #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,k;
int a[1000005];
int q[1000005];
int h,t;
// h 队头
// t 队尾后一个元素
// 队列里存储元素在a[]的下标
int main(){
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++){
// +a[i]
if(h==t || a[q[t-1]]>a[i]) q[t++]=i;
else{
while(h!=t && a[q[t-1]]<=a[i]) t--;
q[t++]=i;
}
// -a[i-k]
if(q[h] == i-k) h++;
if(i>=k) printf("%d\n", a[q[h]]);
}
return 0;
}
| [
"932376634@qq.com"
] | 932376634@qq.com |
5465f9e1427ad171a248d9e248f311f02f7a1b4d | 0a2ff7c394bd842b51d13b6183a1b776a3b7f574 | /Structural.Patterns/Composite.Exercise/shape.hpp | 13bb3d9edecd1d618650ab188418da6082b4c990 | [] | no_license | infotraining/cpp-dp-2020-10-26 | 87a018163f81695fa23fed3ab2539d65e316b3e6 | 2e38bbbf09f854e8602a902e4d6a16d08d7cc78f | refs/heads/master | 2023-01-03T14:54:10.052056 | 2020-10-28T15:32:47 | 2020-10-28T15:32:47 | 305,798,584 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,201 | hpp | #ifndef SHAPE_HPP
#define SHAPE_HPP
#include "point.hpp"
#include <memory>
namespace Drawing
{
class Shape
{
public:
virtual ~Shape() = default;
virtual void move(int dx, int dy) = 0;
virtual void draw() const = 0;
virtual std::unique_ptr<Shape> clone() const = 0;
};
template <typename Type, typename BaseType = Shape>
class CloneableShape : public BaseType
{
public:
using BaseType::BaseType;
std::unique_ptr<Shape> clone() const override
{
return std::make_unique<Type>(static_cast<const Type&>(*this));
}
};
template <typename Type>
class ShapeBase : public CloneableShape<Type>
{
Point coord_; // composition
public:
Point coord() const
{
return coord_;
}
void set_coord(const Point& pt)
{
coord_ = pt;
}
ShapeBase(int x = 0, int y = 0)
: coord_{x, y}
{
}
void move(int dx, int dy) override
{
coord_.translate(dx, dy);
}
};
}
#endif // SHAPE_HPP
| [
"krystian.piekos@infotraining.pl"
] | krystian.piekos@infotraining.pl |
7f4632466ce9dd1eb087516bc7aab0df287c81e6 | 876b4a0b307b57ab2df634a0aa55b61cdf8d6680 | /core/widgets/OpenUrl.h | ae85114ec0cda462776f425b64d3034934f62b5b | [] | no_license | McManning/fro_client | b2b0dec3709ce0b737691dcf4335c13313961c97 | 985b85ce5c1470923880ca0d203f4814e6020516 | refs/heads/master | 2021-01-19T05:53:07.544837 | 2012-01-23T21:44:19 | 2012-01-23T21:44:19 | 2,669,742 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,457 | h |
/*
* Copyright (c) 2011 Chase McManning
*
* 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 _OPENURL_H_
#define _OPENURL_H_
#include "../Core.h"
#include "Frame.h"
#define OPENURL_MAX_WIDTH 400
#define OPENURL_MIN_WIDTH 150
class OpenUrl : public Frame
{
public:
OpenUrl(string url);
~OpenUrl();
void Render();
string mUrl;
};
#endif //_OPENURL_H_
| [
"cmcmanning@gmail.com"
] | cmcmanning@gmail.com |
18ca7bd34efcaeab04fd75fb777ae13fb69dd9d6 | 404071d56001e3bb8c31760ea301459a5ee622e8 | /terracotta/block/BlockElement.h | c6e0ab0559b0e120fae5fa5fd23c810e624be29f | [
"MIT"
] | permissive | plushmonkey/Terracotta | 66ce832a9eff49553922c24f61182781cc3584dd | f5c6bcfe92c7ac5a09f87e597a5e542e7e33769c | refs/heads/master | 2020-04-16T17:18:19.866170 | 2019-10-22T20:28:08 | 2019-10-22T20:28:08 | 165,771,314 | 26 | 3 | MIT | 2019-10-22T20:28:09 | 2019-01-15T02:32:46 | C++ | UTF-8 | C++ | false | false | 1,821 | h | #pragma once
#ifndef TERRACOTTA_BLOCK_BLOCKELEMENT_H_
#define TERRACOTTA_BLOCK_BLOCKELEMENT_H_
#include "BlockFace.h"
#include <vector>
#include <glm/glm.hpp>
#include "../assets/TextureArray.h"
namespace terra {
namespace block {
struct RenderableFace {
assets::TextureHandle texture;
int tint_index;
BlockFace face;
BlockFace cull_face;
glm::vec2 uv_from;
glm::vec2 uv_to;
};
struct ElementRotation {
glm::vec3 origin;
glm::vec3 axis;
float angle;
bool rescale;
ElementRotation() : origin(0, 0, 0), axis(0, 0, 0), angle(0), rescale(false) { }
};
class BlockElement {
public:
BlockElement(glm::vec3 from, glm::vec3 to) : m_From(from), m_To(to), m_Shade(true) {
m_Faces.resize(6);
for (RenderableFace& renderable : m_Faces) {
renderable.face = BlockFace::None;
}
m_FullExtent = m_From == glm::vec3(0, 0, 0) && m_To == glm::vec3(1, 1, 1);
}
std::vector<RenderableFace>& GetFaces() { return m_Faces; }
const RenderableFace& GetFace(BlockFace face) const { return m_Faces[static_cast<std::size_t>(face)]; }
void AddFace(RenderableFace face) { m_Faces[static_cast<std::size_t>(face.face)] = face; }
const glm::vec3& GetFrom() const { return m_From; }
const glm::vec3& GetTo() const { return m_To; }
bool IsFullExtent() const { return m_FullExtent; }
void SetShouldShade(bool shade) { m_Shade = shade; }
bool ShouldShade() const { return m_Shade; }
ElementRotation& GetRotation() { return m_Rotation; }
const ElementRotation& GetRotation() const { return m_Rotation; }
private:
std::vector<RenderableFace> m_Faces;
glm::vec3 m_From;
glm::vec3 m_To;
bool m_FullExtent;
bool m_Shade;
ElementRotation m_Rotation;
};
} // ns block
} // ns terra
#endif
| [
"plushmonkey.ss@gmail.com"
] | plushmonkey.ss@gmail.com |
421849fea7b13364b6d54cb65b855b6d80870137 | ebe213f948bd01a18291b8b955ef9fdda6570cb2 | /Cocos2dxCPPABC/L05SuperC/People.h | a4bdc13703726c6cc9b16d65c30084b55aa40003 | [] | no_license | RonDingDing/CPP-Primer-Plus | 4b6eb808b72e6ec36d5b399782689298ebebbc65 | ac796e8c1e64db2c6a412b85441c6fd3ae9fc2a8 | refs/heads/master | 2021-05-01T14:31:24.988553 | 2018-12-07T06:42:50 | 2018-12-07T06:42:50 | 112,147,473 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 231 | h | #ifndef __L01OOP__People__
#define __L01OOP__People__
#include <iostream>
class People
{
private:
int age;
int sex;
public:
People();
People(int age, int sex);
void sayHello();
int getAge();
int getSex();
};
#endif | [
"ronweasleyding@163.com"
] | ronweasleyding@163.com |
86f149f792f2635cc3356b07d467ca75cd8d48fb | b2b9e4d616a6d1909f845e15b6eaa878faa9605a | /C++/20148301654.cpp | 0ad6c16ac16b87c93722060c2191bfd7178bc57a | [] | no_license | JinbaoWeb/ACM | db2a852816d2f4e395086b2b7f2fdebbb4b56837 | 021b0c8d9c96c1bc6e10374ea98d0706d7b509e1 | refs/heads/master | 2021-01-18T22:32:50.894840 | 2016-06-14T07:07:51 | 2016-06-14T07:07:51 | 55,882,694 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 304 | cpp | #include <iostream>
using namespace std;
int main()
{
int n,s,x,y;
while (cin>>n>>s)
{
int max=0,flag=0;
for (int i=0;i<n;i++)
{
cin>>x>>y;
if (max<100-y&&y)
max=100-y;
if (x*100+y<=s*100)
flag=1;
}
if (flag==0)
cout<<-1<<endl;
else
cout<<max<<endl;
}
return 0;
}
| [
"jinbaosite@yeah.net"
] | jinbaosite@yeah.net |
4af221b52dc3b31690b5769d8f57bb2ab8c66ea0 | 2045263497b0b0b0e272eea4ad4510b9c83f7b6b | /Minigin/InputManager.h | c9065110cb2a6f3d0699d1bb92005ac65f48751a | [] | no_license | Myvampire99/Minigin | 82f6faaa13114ab92fab71c407a91df9b0dabe92 | d3633b55e29465e05e4772b54c4bcf736ad79306 | refs/heads/master | 2022-02-27T11:45:17.089938 | 2019-10-08T14:09:49 | 2019-10-08T14:09:49 | 188,622,379 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,201 | h | #pragma once
//#include <XInput.h>
//#include <unordered_map>
/*
#include "Command.h"*/
enum class ControllerButton
{
Button_A = XINPUT_GAMEPAD_A,
Button_B = XINPUT_GAMEPAD_B,
Button_X = XINPUT_GAMEPAD_X,
Button_Y = XINPUT_GAMEPAD_Y,
Dpad_Down = XINPUT_GAMEPAD_DPAD_DOWN,
Dpad_Up = XINPUT_GAMEPAD_DPAD_UP,
Dpad_Right = XINPUT_GAMEPAD_DPAD_RIGHT,
Dpad_Left = XINPUT_GAMEPAD_DPAD_LEFT,
Keyboard_A = VK_ESCAPE
};
class Command;
class InputManager
{
public:
bool ProcessInput();
std::pair<bool, int> IsPressed(ControllerButton button,int player,bool Keyboard);
InputManager();
~InputManager();
//template<class T>
void AssignButton(ControllerButton button, Command *pointer, int player,bool release = false);
void HandleInput();
void ForceButton(ControllerButton button,int player);
bool IsKeyDown();
const Uint8* KeyState = nullptr;
private:
std::vector<std::unordered_map<ControllerButton, Command*>> m_Buttons;
XINPUT_STATE m_States[XUSER_MAX_COUNT];
bool m_ControllerConected;
bool m_SkipPlayer[4];
bool m_KeyDown = false;
std::vector<std::unordered_map<ControllerButton, bool>> m_Released;
std::vector<std::unordered_map<ControllerButton, bool>> m_NeedToRelease;
}; | [
"47989066+Myvampire99@users.noreply.github.com"
] | 47989066+Myvampire99@users.noreply.github.com |
8e17c9ed95fef001f25bc13f405fee417d4033f3 | a9f99e73e79c8636627cac3dab04604e7f6adea6 | /ESP8266_Ambient_Condition_Controller/ESP8266_Ambient_Condition_Controller.ino | a12e7156c5741493dde92f84901506936ab7afbb | [] | no_license | minusmagis/Arduino_projects_all | 8e25e329f07512eb4eddad58563735e121111af0 | 801d39f6497ef8a296649135111b35d86e48f8cb | refs/heads/master | 2023-03-11T14:01:46.778317 | 2021-02-23T17:01:28 | 2021-02-23T17:01:28 | 260,660,712 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 933 | ino | /*
This code is used to control a self watering grow station that controls the ambient temperature and humidity as well as the soil temperature and moisture levels.
Author: minusmagis
Last update: 09/01/2021
*/
// First we include all the needed libraries and header files
#include "DHTesp.h"
#include "Definitions.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <SpeedyStepper.h>
unsigned long lastMsg = 0;
unsigned long lastUpdate = 0;
// On the setup we initialize all the comunications needed for the software to work
void setup()
{
StartCode();
}
void loop()
{
unsigned long messageNow = millis();
if (messageNow - lastMsg > MessageReceiveDelay) {
lastMsg = messageNow;
FastUpdate();
}
unsigned long StatusNow = millis();
if (StatusNow - lastUpdate > StatusUpdateDelay) {
lastUpdate = StatusNow;
Get_Conditions();
}
}
| [
"minu_10@hotmail.com"
] | minu_10@hotmail.com |
188a450e1f360cd416cc09ead14ee819b9acce66 | e00aa6936df0a03afc1690f87715035bd9edcd59 | /FarNet/FarNetMan/Window.cpp | df3aee0bb32a30ef91aee68ee473463eb8f5fe3c | [
"BSD-3-Clause"
] | permissive | MinhTranCA/FarNet | d955ab116b1fdd70480814b76c25dc3f31404e05 | 673f89165c614c9f8811d0fc445f52d1bbf8162d | refs/heads/master | 2023-03-10T08:07:53.062898 | 2020-11-14T04:37:27 | 2021-02-11T17:49:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,470 | cpp |
// FarNet plugin for Far Manager
// Copyright (c) Roman Kuzmin
#include "StdAfx.h"
#include "Window.h"
#include "Wrappers.h"
namespace FarNet
{;
WindowKind Window::GetKindAt(int index)
{
WindowInfo wi;
Call_ACTL_GETWINDOWINFO(wi, index);
return (FarNet::WindowKind)wi.Type;
}
String^ Window::GetNameAt(int index)
{
WindowInfo wi;
Call_ACTL_GETWINDOWINFO(wi, index);
CBox box(wi.NameSize);
wi.Name = box;
Call_ACTL_GETWINDOWINFO(wi);
return gcnew String(box);
}
int Window::Count::get()
{
return (int)Info.AdvControl(&MainGuid, ACTL_GETWINDOWCOUNT, 0, 0);
}
bool Window::IsModal::get()
{
WindowInfo wi;
Call_ACTL_GETWINDOWINFO(wi, -1);
return 0 != (wi.Flags & WIF_MODAL);
}
WindowKind Window::Kind::get()
{
return Wrap::WindowGetKind();
}
void Window::SetCurrentAt(int index)
{
//_141017_151021 Far 3.0.4138 Not documented: -1 is for Panels.
if (index == -1)
{
// find index of Panels
int nWindow = Count;
for(int iWindow = 0; iWindow < nWindow; ++iWindow)
{
WindowKind kind = GetKindAt(iWindow);
if (kind == WindowKind::Panels)
{
index = iWindow;
break;
}
}
// not found
if (index == -1)
throw gcnew InvalidOperationException(__FUNCTION__ " failed, missing Panels");
}
if (!Info.AdvControl(&MainGuid, ACTL_SETCURRENTWINDOW, index, 0))
throw gcnew InvalidOperationException(__FUNCTION__ " failed, index = " + index);
}
}
| [
"nightroman@gmail.com"
] | nightroman@gmail.com |
e0e1d044f902ffefef842b6192091944b54681b0 | ef7fe819881517c1e1c0a40db0d4e984a3df43c6 | /structures/deque.hpp | ca3aa3fe99cb5d98339f5e83aa60235a41de3663 | [
"MIT"
] | permissive | Dannnno/DataStructures | 7ecc49c67fc3095e3dc42cbafc7c63297d2eb625 | 898e16acc4d05e7c387972f1aef252b298fc4f81 | refs/heads/master | 2021-01-22T21:13:41.922141 | 2015-03-26T01:57:15 | 2015-03-26T01:57:15 | 31,244,281 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,579 | hpp | /**
* \file deque.hpp
* \author Dan Obermiller
* \brief Implementation of a doubly linked list.
*/
#ifndef DEQUE_HPP
#define DEQUE_HPP 1
#include <cstddef>
#include <iterator>
#include "list.hpp"
#include "../exceptions.hpp"
/**
* \brief A paramaterized doubly-linked list
*/
template <typename T>
class Deque : public List<T>
{
private:
/**
* \brief Iterator for a deque.
*/
class Iterator;
/**
* \brief Constant iterator for a deque.
*/
class ConstIterator;
/**
* \brief Reverse iterator for a deque.
*/
class ReverseIterator;
/**
* \brief Constant reverse iterator for a deque.
*/
class ConstReverseIterator;
/**
* \brief Node of a deque
*/
struct ListNode;
public:
/**
* \brief A default constructor for a deque.
*/
Deque();
/**
* \brief A constructor from an array.
*/
Deque(T* arr, std::size_t length);
/**
* \brief Copy constructor.
*/
Deque(const Deque<T>& orig);
/**
* \brief Move constructor.
*/
Deque(Deque<T>&& other);
/**
* \brief Assignment to a list;
*/
Deque<T>& operator=(Deque<T> rhs);
/**
* \brief The destructor for a deque.
*/
~Deque();
/**
* \brief Non-member function version of swap.
*/
template <class P>
friend void swap(Deque<P>& lhs, Deque<P>& rhs);
/**
* \brief The head (first item) of the list.
*/
T& getHead();
/**
* \brief Constant version of getHead()
*/
const T& getHead() const;
/**
* \brief The tail (last item) of the list.
*/
T& getTail();
/**
* \brief Constant version of getTail()
*/
const T& getTail() const;
/**
* \brief Returns the size of the list
*/
std::size_t size() const;
/**
* \brief Returns whether or not the list is empty.
*/
bool isEmpty() const;
/**
* \brief Adds a node to the end of the list.
* \post All nodes have the appropriate "next_" and the list has
* the appropriate size.
*/
void append(T value);
/**
* \brief Adds a node to the front of the list.
*/
void appendLeft(T value);
/**
* \brief Removes the first item in the list.
*/
void remove();
/**
* \brief Removes the nth item in the list.
*/
void remove(std::size_t n);
/**
* \brief Removes and returns a copy of the value of the first item
* in the list.
*/
T pop();
/**
* \brief Removes and returns a copy of the value of the nth item
* in the list.
*/
T pop(std::size_t n);
/**
* \brief inserts an item at the indicated index.
*/
void insert(std::size_t index, T value);
/**
* \brief Determines the index of an element.
*/
std::size_t index_of(T const& value) const;
/**
* \brief Determines whether or not the value is present.
*/
bool contains(T const& value) const;
/**
* \brief Overloads the addition operator.
* \details Adds two lists together and returns the result.
*/
template <typename P>
friend Deque<P> operator+(Deque<P> lhs, Deque<P> rhs);
/**
* \brief Overloads the multiplication operator.
* \details Allows us to make the list repeat n times.
*/
template <typename P>
friend Deque<P> operator*(Deque<P> lhs, std::size_t n);
/**
* \brief Overloads the mutable subscript operator.
*/
T& operator[](std::size_t index);
/**
* \brief Overloads the immutable subscript operator.
*/
const T& operator[](std::size_t index) const;
/**
* \brief Overloads the equivalence operator.
*/
bool operator==(const Deque<T>& rhs) const;
/**
* \brief Overloads the inequivalence operator.
*/
bool operator!=(const Deque<T>& rhs) const;
/**
* \brief Returns an array of the values within the list.
* \details This is a dynamically allocated array and needs to be
* explicitly deleted.
*/
T* asArray() const;
/**
* \brief Overloads the << operator.
*/
template <class P>
friend std::ostream& operator<<(
std::ostream& str, const Deque<P>& list);
typedef Iterator iterator;
typedef ConstIterator const_iterator;
typedef ReverseIterator reverse_iterator;
typedef ConstReverseIterator const_reverse_iterator;
/**
* \brief Start of the deque.
*/
iterator begin();
/**
* \brief Termination of the deque.
*/
iterator end();
/**
* \brief Start of the deque.
*/
const_iterator begin() const;
/**
* \brief Termination of the deque.
*/
const_iterator end() const;
/**
* \brief End of the deque.
*/
reverse_iterator rbegin();
/**
* \brief Termination of the reversed deque.
*/
reverse_iterator rend();
/**
* \brief End of the deque.
*/
const_reverse_iterator rbegin() const;
/**
* \brief Terminatin of the reversed deque.
*/
const_reverse_iterator rend() const;
/**
* \brief Sorts the current list.
*/
void sort();
/**
* \brief Returns a copy of the list in sorted order.
* \post The original list is unchanged.
*/
Deque<T> sorted() const;
/**
* \brief Reverses the order of the list.
*/
void reverse();
/**
* \brief Returns a copy of the list, reversed.
* \post The original list is unchanged.
*/
Deque<T> reversed() const;
/**
* \brief Returns an array of the items in the list.
*/
T* toArray() const;
private:
class Iterator : public std::iterator<std::forward_iterator_tag, T>
{
public:
/**
* \brief Prefix increment operator overloading.
*/
Iterator& operator++();
/**
* \brief Postfix increment operator overloading.
*/
Iterator operator++(int) const;
/**
* \brief Dereferencing operator overloading.
*/
const T& operator*() const;
/**
* \brief Member access operator overriding.
*/
const T* operator->() const;
/**
* \brief Equality operator overriding.
*/
bool operator==(const Iterator& rhs) const;
/**
* \brief Inequality operator overriding.
*/
bool operator!=(const Iterator& rhs) const;
private:
friend class Deque;
/**
* \brief The default constructor.
*/
Iterator() = delete;
/**
* \brief All iterators should have a current node.
*/
Iterator(ListNode* node) : current_{node}
{
}
ListNode* current_;
};
class ConstIterator : public std::iterator<std::forward_iterator_tag, T>
{
public:
/**
* \brief Prefix increment operator overloading.
*/
ConstIterator& operator++();
/**
* \brief Postfix increment operator overloading.
*/
ConstIterator operator++(int) const;
/**
* \brief Dereferencing operator overloading.
*/
const T& operator*() const;
/**
* \brief Member access operator overriding.
*/
const T* operator->() const;
/**
* \brief Equality operator overriding.
*/
bool operator==(const ConstIterator& rhs) const;
/**
* \brief Inequality operator overriding.
*/
bool operator!=(const ConstIterator& rhs) const;
private:
friend class Deque;
/**
* \brief The default constructor.
*/
ConstIterator() = delete;
/**
* \brief All iterators should have a current node.
*/
ConstIterator(ListNode* node) : current_{node}
{
}
ListNode* current_;
};
class ReverseIterator : public std::iterator<std::forward_iterator_tag, T>
{
public:
/**
* \brief Prefix increment operator overloading.
*/
ReverseIterator& operator++();
/**
* \brief Postfix increment operator overloading.
*/
ReverseIterator operator++(int) const;
/**
* \brief Dereferencing operator overloading.
*/
const T& operator*() const;
/**
* \brief Member access operator overriding.
*/
const T* operator->() const;
/**
* \brief Equality operator overriding.
*/
bool operator==(const ReverseIterator& rhs) const;
/**
* \brief Inequality operator overriding.
*/
bool operator!=(const ReverseIterator& rhs) const;
private:
friend class Deque;
/**
* \brief The default constructor.
*/
ReverseIterator() = delete;
/**
* \brief All iterators should have a current node.
*/
ReverseIterator(ListNode* node) : current_{node}
{
}
ListNode* current_;
};
class ConstReverseIterator :
public std::iterator<std::forward_iterator_tag, T>
{
public:
/**
* \brief Prefix increment operator overloading.
*/
ConstReverseIterator& operator++();
/**
* \brief Postfix increment operator overloading.
*/
ConstReverseIterator operator++(int) const;
/**
* \brief Dereferencing operator overloading.
*/
const T& operator*() const;
/**
* \brief Member access operator overriding.
*/
const T* operator->() const;
/**
* \brief Equality operator overriding.
*/
bool operator==(const ConstReverseIterator& rhs) const;
/**
* \brief Inequality operator overriding.
*/
bool operator!=(const ConstReverseIterator& rhs) const;
private:
friend class Deque;
/**
* \brief The default constructor.
*/
ConstReverseIterator() = delete;
/**
* \brief All iterators should have a current node.
*/
ConstReverseIterator(ListNode* node) : current_{node}
{
}
ListNode* current_;
};
/**
* \brief Node of a linkedlist
*/
struct ListNode
{
T value_;
ListNode* next_;
ListNode* previous_;
};
/**
* \brief Gets a list node at the given index
*/
ListNode* getListNode(std::size_t index) const;
std::size_t numElements_;
ListNode* head_;
ListNode* tail_;
};
#include "_deque.hpp"
#endif
| [
"dannnno16@gmail.com"
] | dannnno16@gmail.com |
ae00ee3a5715b2a5fd43b2f25367a595f3eaa19f | 0fc04eb3da62dd7917b1ae330bab7daf1cbc182f | /src/main.cpp | 2f80543900bf11b6cb5ea1851bfa64c222e4d853 | [
"Apache-2.0"
] | permissive | JohndeVostok/THKVS | 3b48757944877ced8c6a2b77f9b5d4da729e09ce | 23ce5d79ac467e9efcaf0c95df8dd10e41ac5980 | refs/heads/master | 2020-03-23T14:02:46.655849 | 2018-08-04T13:08:05 | 2018-08-04T13:08:05 | 141,652,429 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 58 | cpp | #include "btree.h"
int main() {
Btree bt;
bt.test();
}
| [
"dyxdy@live.com"
] | dyxdy@live.com |
7d1225429356321fc3b169a7808dc11abfbdeffb | 872f8a019ddb0cd2cce6569bcc51e35005e218b8 | /Capture/src/testApp.cpp | aa869f92d1b7c5d86cf7a519f8aa319395d49258 | [] | no_license | amodal1/PofxC | aba6739c450286ba06e8b5c2d0614ba999b090d6 | 33bb604249aa487c1eed6db3f3d0cd1baf7ff072 | refs/heads/master | 2020-04-15T03:09:51.482039 | 2012-12-22T00:00:43 | 2012-12-22T00:00:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,229 | cpp | #include "testApp.h"
//--------------------------------------------------------------
void testApp::setup()
{
mSession = PXCUPipeline_Init((PXCUPipeline)(PXCU_PIPELINE_GESTURE|PXCU_PIPELINE_COLOR_VGA));
if(!mSession)
return;
if(PXCUPipeline_QueryLabelMapSize(mSession, &mlw, &mlh))
{
mLabelMap = new unsigned char[mlw*mlh];
mLabelTex = ofTexture();
mLabelTex.allocate(mlw,mlh,GL_LUMINANCE);
}
if(PXCUPipeline_QueryRGBSize(mSession, &mcw, &mch))
{
mRgbMap = new unsigned char[mcw*mch*4];
mRgbTex = ofTexture();
mRgbTex.allocate(mcw,mch,GL_RGBA);
}
ofSetWindowShape(mcw*2,mch);
mDraw = false;
}
//--------------------------------------------------------------
void testApp::update()
{
if(PXCUPipeline_AcquireFrame(mSession, true))
{
if(PXCUPipeline_QueryRGB(mSession, mRgbMap))
mRgbTex.loadData(mRgbMap,mcw,mch,GL_RGBA);
if(PXCUPipeline_QueryLabelMap(mSession, mLabelMap,0))
mLabelTex.loadData(mLabelMap,mlw,mlh,GL_LUMINANCE);
PXCUPipeline_ReleaseFrame(mSession);
}
}
//--------------------------------------------------------------
void testApp::draw()
{
mRgbTex.draw(0,0,mcw,mch);
mLabelTex.draw(mcw,0,mlw*2,mlh*2);
}
//--------------------------------------------------------------
| [
"seth.gibson@intel.com"
] | seth.gibson@intel.com |
fb97faf8349a0ab5c0d0ea3ba67b25c9a4a02e85 | fbbe424559f64e9a94116a07eaaa555a01b0a7bb | /Keras_tensorflow_nightly/source2.7/tensorflow/include/tensorflow/stream_executor/trace_listener.h | d1e87c348b1f867009fdb6b741d984b2f58cef21 | [
"MIT"
] | permissive | ryfeus/lambda-packs | 6544adb4dec19b8e71d75c24d8ed789b785b0369 | cabf6e4f1970dc14302f87414f170de19944bac2 | refs/heads/master | 2022-12-07T16:18:52.475504 | 2022-11-29T13:35:35 | 2022-11-29T13:35:35 | 71,386,735 | 1,283 | 263 | MIT | 2022-11-26T05:02:14 | 2016-10-19T18:22:39 | Python | UTF-8 | C++ | false | false | 3,408 | h | /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// This file defines the StreamExecutor trace listener, used for inserting
// non-device-specific instrumentation into the StreamExecutor.
#ifndef TENSORFLOW_STREAM_EXECUTOR_TRACE_LISTENER_H_
#define TENSORFLOW_STREAM_EXECUTOR_TRACE_LISTENER_H_
#include "tensorflow/stream_executor/device_memory.h"
#include "tensorflow/stream_executor/kernel.h"
#include "tensorflow/stream_executor/launch_dim.h"
#include "tensorflow/stream_executor/lib/status.h"
namespace perftools {
namespace gputools {
class Stream;
// Traces StreamExecutor PIMPL-level events.
// The few StreamExecutor interfaces that are synchronous have both Begin and
// Complete versions of their trace calls. Asynchronous operations only have
// Submit calls, as execution of the underlying operations is device-specific.
// As all tracing calls mirror StreamExecutor routines, documentation here is
// minimal.
//
// All calls have default implementations that perform no work; subclasses
// should override functionality of interest. Keep in mind that these routines
// are not called on a dedicated thread, so callbacks should execute quickly.
//
// Note: This API is constructed on an as-needed basis. Users should add
// support for further StreamExecutor operations as required. By enforced
// convention (see SCOPED_TRACE in stream_executor_pimpl.cc), synchronous
// tracepoints should be named NameBegin and NameComplete.
class TraceListener {
public:
virtual ~TraceListener() {}
virtual void LaunchSubmit(Stream* stream, const ThreadDim& thread_dims,
const BlockDim& block_dims,
const KernelBase& kernel,
const KernelArgsArrayBase& args) {}
virtual void SynchronousMemcpyH2DBegin(int64 correlation_id,
const void* host_src, int64 size,
DeviceMemoryBase* gpu_dst) {}
virtual void SynchronousMemcpyH2DComplete(int64 correlation_id,
const port::Status* result) {}
virtual void SynchronousMemcpyD2HBegin(int64 correlation_id,
const DeviceMemoryBase& gpu_src,
int64 size, void* host_dst) {}
virtual void SynchronousMemcpyD2HComplete(int64 correlation_id,
const port::Status* result) {}
virtual void BlockHostUntilDoneBegin(int64 correlation_id, Stream* stream) {}
virtual void BlockHostUntilDoneComplete(int64 correlation_id,
const port::Status* result) {}
};
} // namespace gputools
} // namespace perftools
#endif // TENSORFLOW_STREAM_EXECUTOR_TRACE_LISTENER_H_
| [
"ryfeus@gmail.com"
] | ryfeus@gmail.com |
eba428b2878d409e8f2c0bb3ec1c84ea6836f0a9 | 777a75e6ed0934c193aece9de4421f8d8db01aac | /src/Providers/UNIXProviders/DoorAccessToDevice/UNIX_DoorAccessToDevice_HPUX.hxx | 97b66da7d8c2f8f6ba4a6e0b4c8c91dd649f14ff | [
"MIT"
] | permissive | brunolauze/openpegasus-providers-old | 20fc13958016e35dc4d87f93d1999db0eae9010a | b00f1aad575bae144b8538bf57ba5fd5582a4ec7 | refs/heads/master | 2021-01-01T20:05:44.559362 | 2014-04-30T17:50:06 | 2014-04-30T17:50:06 | 19,132,738 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 131 | hxx | #ifdef PEGASUS_OS_HPUX
#ifndef __UNIX_DOORACCESSTODEVICE_PRIVATE_H
#define __UNIX_DOORACCESSTODEVICE_PRIVATE_H
#endif
#endif
| [
"brunolauze@msn.com"
] | brunolauze@msn.com |
8a90d11cbd1ba6e7fa742e5f756eda9ab2f43e4e | a73e792f069221abf4b63ce6186adc31eb2564e7 | /cheat/Core/InputSys.cpp | fc7be4eb7113f01988c1465c63b70175cf7a9149 | [
"MIT"
] | permissive | rafalohaki/FAKEWARE | 0cb9e53a4b3da1ff708b30ffd73a4693b4e45a07 | 0ba045f1d41f981baef338b9c765646174c5718b | refs/heads/master | 2020-03-27T04:51:13.020590 | 2018-04-20T20:38:45 | 2018-04-20T20:38:45 | 145,974,029 | 0 | 1 | MIT | 2018-08-24T09:48:35 | 2018-08-24T09:48:35 | null | UTF-8 | C++ | false | false | 3,752 | cpp | #include "InputSys.h"
#include "SDK.h"
#include "../Menu/Menu.h"
InputSys::InputSys()
: m_hTargetWindow(nullptr), m_ulOldWndProc(0)
{}
InputSys::~InputSys()
{
if (m_ulOldWndProc)
SetWindowLongPtr(m_hTargetWindow, GWLP_WNDPROC, m_ulOldWndProc);
m_ulOldWndProc = 0;
}
void InputSys::Initialize()
{
D3DDEVICE_CREATION_PARAMETERS params;
if (FAILED(g_D3DDevice9->GetCreationParameters(¶ms)))
throw std::runtime_error("[InputSys] GetCreationParameters failed.");
m_hTargetWindow = params.hFocusWindow;
m_ulOldWndProc = SetWindowLongPtr(m_hTargetWindow, GWLP_WNDPROC, (LONG_PTR)WndProc);
if (!m_ulOldWndProc)
throw std::runtime_error("[InputSys] SetWindowLongPtr failed.");
}
LRESULT __stdcall InputSys::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
Get().ProcessMessage(msg, wParam, lParam);
if (Menu::Get().IsVisible())
return true;
return CallWindowProcW((WNDPROC)Get().m_ulOldWndProc, hWnd, msg, wParam, lParam);
}
bool InputSys::ProcessMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_MBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
case WM_LBUTTONDBLCLK:
case WM_XBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONDOWN:
case WM_XBUTTONDOWN:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONUP:
case WM_XBUTTONUP:
return ProcessMouseMessage(uMsg, wParam, lParam);
case WM_KEYDOWN:
case WM_KEYUP:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
return ProcessKeybdMessage(uMsg, wParam, lParam);
case WM_CHAR:
Menu::Get().HandleInput(wParam);
default:
return false;
}
}
bool InputSys::ProcessMouseMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
auto key = VK_LBUTTON;
auto state = KeyState::None;
switch (uMsg)
{
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
state = uMsg == WM_MBUTTONUP ? KeyState::Up : KeyState::Down;
key = VK_MBUTTON;
break;
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
state = uMsg == WM_RBUTTONUP ? KeyState::Up : KeyState::Down;
key = VK_RBUTTON;
break;
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
state = uMsg == WM_LBUTTONUP ? KeyState::Up : KeyState::Down;
key = VK_LBUTTON;
break;
case WM_XBUTTONDOWN:
case WM_XBUTTONUP:
state = uMsg == WM_XBUTTONUP ? KeyState::Up : KeyState::Down;
key = (HIWORD(wParam) == XBUTTON1 ? VK_XBUTTON1 : VK_XBUTTON2);
break;
default:
return false;
}
if (state == KeyState::Up && m_iKeyMap[int(key)] == KeyState::Down)
{
m_iKeyMap[int(key)] = KeyState::Pressed;
auto& hotkey_callback = m_Hotkeys[key];
if (hotkey_callback)
hotkey_callback();
} else
{
m_iKeyMap[int(key)] = state;
}
return true;
}
bool InputSys::ProcessKeybdMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
auto key = wParam;
auto state = KeyState::None;
switch (uMsg)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
state = KeyState::Down;
break;
case WM_KEYUP:
case WM_SYSKEYUP:
state = KeyState::Up;
break;
default:
return false;
}
if (state == KeyState::Up && m_iKeyMap[int(key)] == KeyState::Down)
{
m_iKeyMap[int(key)] = KeyState::Pressed;
auto& hotkey_callback = m_Hotkeys[key];
if (hotkey_callback)
hotkey_callback();
} else
{
m_iKeyMap[int(key)] = state;
}
return true;
}
KeyState InputSys::GetKeyState(std::uint32_t vk)
{
return m_iKeyMap[vk];
}
bool InputSys::IsKeyDown(std::uint32_t vk)
{
return m_iKeyMap[vk] == KeyState::Down;
}
bool InputSys::WasKeyPressed(std::uint32_t vk)
{
if (m_iKeyMap[vk] == KeyState::Pressed)
{
m_iKeyMap[vk] = KeyState::Up;
return true;
}
return false;
}
void InputSys::RegisterHotkey(std::uint32_t vk, std::function<void(void)> f)
{
m_Hotkeys[vk] = f;
}
void InputSys::RemoveHotkey(std::uint32_t vk)
{
m_Hotkeys[vk] = nullptr;
} | [
"hydrogenide@gmail.com"
] | hydrogenide@gmail.com |
84ffd849473440af3252c7ed164081158f61b7c6 | 2502943d23a18cce4b2cb169288ca08e2243ca4f | /HDOJcode/1534 2013-04-28 15 51 12.cpp | 05d95bb96b25e1955da885f38502be435603573e | [] | no_license | townboy/acm-algorithm | 27745db88cf8e3f84836f98a6c2dfa4a76ee4227 | 4999e15efcd7574570065088b085db4a7c185a66 | refs/heads/master | 2021-01-01T16:20:50.099324 | 2014-11-29T06:13:49 | 2014-11-29T06:13:49 | 18,025,712 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,674 | cpp | ******************************
Author : townboy
Submit time : 2013-04-28 15:51:12
Judge Status : Accepted
HDOJ Runid : 8191762
Problem id : 1534
Exe.time : 15MS
Exe.memory : 612K
https://github.com/townboy
******************************
#include<stdio.h>
#include<memory.h>
#include<iostream>
#include<queue>
#define maxn 10005
using namespace std;
struct node
{
int v,len;
node(){}
node(int _v,int _len){
v=_v; len=_len;
}
};
int n,nn,dis[maxn],hash[maxn];
int t[maxn],ru[maxn];
int flag;
vector<node>G[maxn];
void init()
{
int i;
nn=2*n;
flag=0;
for(i=0;i<nn;i++)
G[i].clear();
memset(dis,0x80,sizeof(dis));
memset(ru,0,sizeof(ru));
memset(hash,0,sizeof(hash));
}
void add(int u,int v,int len){
G[u].push_back(node(v,len));
}
void spfa(int s)
{
int len;
int i,size,tem,to;
queue<int>q;
ru[s]++;
q.push(s);
dis[s]=0;
while(!q.empty())
{
tem=q.front();
q.pop();
if(ru[tem] > nn)
{
flag=1;
break;
}
hash[tem]=0;
size=G[tem].size();
for(i=0;i<size;i++)
{
len=G[tem][i].len;
to=G[tem][i].v;
if(dis[tem]+len > dis[to])
{
ru[to]++;
dis[to]=dis[tem]+len;
if(1 == hash[to]) continue;
hash[to]=1;
q.push(to);
}
}
}
}
void ans()
{
int i;
if(1 == flag)
{
puts("impossible\n");
return ;
}
for(i=0;i<n;i++)
printf("%d %d\n",i+1,dis[2*i]);
printf("\n");
}
int main()
{
char ch[10];
int u,v,len;
int i,cas=0;
while(scanf("%d",&n),n)
{
cas++;
init();
for(i=0;i<n;i++)
scanf("%d",t+i);
for(i=0;i<n;i++)
{
add(2*i,2*i+1,t[i]);
add(2*i+1,2*i,-t[i]);
}
while(scanf("%s",ch)!=EOF)
{
if('#' == ch[0]) break;
scanf("%d%d",&u,&v);
u--;v--;
if(0 == strcmp(ch,"FAS"))
add(2*v,2*u+1,0);
else if(0 == strcmp(ch,"FAF"))
add(2*v+1,2*u+1,0);
else if(0 == strcmp(ch,"SAF"))
add(2*v+1,2*u,0);
else
add(2*v,2*u,0);
}
for(i=0;i<nn;i++)
add(nn,i,0);
spfa(nn);
printf("Case %d:\n",cas);
ans();
}
return 0;
} | [
"564690377@qq.com"
] | 564690377@qq.com |
e0b5ab640c045278df3cc2d6c90d89a272924ad3 | f42f23e63690949cb6a7005fa6e48323b6bb6a53 | /addrev.cpp | 5f0d8031b1e49f8015a779a1fc51ce80e144d047 | [
"MIT"
] | permissive | anand434/SPOJ-Solutions | 0f082127e06c9e2ed36719a6805674a589fe377e | 763b759d19ac5259b21028abb73f0cfb58c55817 | refs/heads/master | 2020-05-24T08:03:56.462674 | 2018-01-28T11:44:13 | 2018-01-28T11:44:13 | 84,838,454 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 389 | cpp | #include <iostream>
using namespace std;
int reverse(int a){
int rev = 0, rem;
while(a!=0){
rem= a % 10;
rev = (rev * 10) + rem;
a /= 10;
}
return rev;
}
int main(){
int t , a , b;
cin >> t;
while(t--){
cin >> a >> b;
a = reverse(a);
b = reverse(b);
cout << reverse(a+b) << endl;
}
return 0;
} | [
"kr.anand434@gamil.com"
] | kr.anand434@gamil.com |
06952998011671ae057ccb8a16d8f52080a2a534 | 87a0c275c7974325bc88571aab27ec9094670cbb | /Software/receiver/receiver.ino | ca226a24c335855bc6d3585a8aec3b891e80b5b4 | [] | no_license | chittojnr/rc-truck | 12f5eefe74adea2002ad171d86bbbc3528fd2d9d | 95e3959fe2d1aa5cb2e6a60db6cf484ee108299a | refs/heads/main | 2023-03-20T05:20:49.271450 | 2021-02-16T00:29:14 | 2021-02-16T00:29:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,151 | ino | #include <Servo.h>
#include "src/communication/RF433.h"
#include "src/communication/radio.h"
enum
{
address = 25,
nof_channels = 2,
dataPin = 2,
speedPin = 6,
forewardPin = 7,
reversePin = 8,
servoPin = 9,
voltagePin = 3
};
enum
{
minSteeringAngle = 40,
middleSteeringAngle = 108,
maxSteeringAngle = 160,
minVoltageLevel = 524
};
Servo myservo;
RF433::Receiver radioDevice(dataPin);
RADIO::Receiver radio(radioDevice,address);
void setup()
{
myservo.attach(servoPin);
pinMode(forewardPin, OUTPUT);
pinMode(speedPin, OUTPUT);
pinMode(reversePin, OUTPUT);
digitalWrite(forewardPin,LOW);
digitalWrite(speedPin,LOW);
digitalWrite(reversePin,LOW);
}
void loop()
{
static int8_t driveData[nof_channels] = {0};
// check battery voltage
readVoltage();
// receive remote data
receiveData(driveData);
// drive and steer
drive(driveData[0]);
steer(driveData[1]);
}
void readVoltage()
{
static unsigned long readTime = 0;
if ((millis() - readTime) > 1000)
{
// read battery voltage
int voltage = analogRead(voltagePin);
if (voltage <= minVoltageLevel)
{
// stop forever
setSpeed(0);
while(1);
}
readTime = millis();
}
}
void receiveData(int8_t* data)
{
static unsigned long receiveTime[nof_channels] = {0};
for (int i = 0; i < nof_channels; ++i)
{
if (radio.receive(i,(uint8_t*)data))
{
// new data received
receiveTime[i] = millis();
}
if ((millis() - receiveTime[i]) > 300)
{
// reset on receive timeout
*data = 0;
}
// next channel
++data;
}
}
void drive(int newSpeed)
{
static unsigned long setTime = 0;
static int currentSpeed = 0;
if ((millis() - setTime) > 10)
{
setTime = millis();
int speedDifference = newSpeed - currentSpeed;
if (speedDifference > 2)
{
speedDifference = 2;
}
else if (speedDifference < -2)
{
speedDifference = -2;
}
currentSpeed += speedDifference;
setSpeed(currentSpeed);
}
}
void setSpeed(int speed)
{
unsigned dutycycle;
if (speed >= 0)
{
dutycycle = map(speed, 0, 127, 0, 255);
digitalWrite(reversePin,LOW);
digitalWrite(forewardPin,HIGH);
}
else
{
dutycycle = map(speed, -128, 0, 150, 0);
digitalWrite(forewardPin,LOW);
digitalWrite(reversePin,HIGH);
}
analogWrite(speedPin,dutycycle);
}
void steer(int newAngle)
{
static unsigned long setTime = 0;
static int currentAngle = 0;
if ((millis() - setTime) > 10)
{
setTime = millis();
int angleDifference = newAngle - currentAngle;
if (angleDifference > 4)
{
angleDifference = 4;
}
else if (angleDifference < -4)
{
angleDifference = -4;
}
currentAngle += angleDifference;
setAngle(currentAngle);
}
}
void setAngle(int angle)
{
unsigned servoPos;
if (angle >= 0)
{
servoPos = map(angle, 0, 127, middleSteeringAngle, maxSteeringAngle);
}
else
{
servoPos = map(angle, -128, 0, minSteeringAngle, middleSteeringAngle);
}
myservo.write(servoPos);
}
| [
"rubinknoepfel@bluewin.ch"
] | rubinknoepfel@bluewin.ch |
6cdad463020638ddb8e911134a90256cc1cb5e56 | 142ddd4c42dc7ff65fd9b531cfd0adbfe2a1dd34 | /export/servers/physics_2d/constraint_2d_sw.h | f9e872bc7827127657be9b447c89c54453fc1313 | [
"MIT",
"LicenseRef-scancode-free-unknown",
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"CC0-1.0",
"OFL-1.1",
"LicenseRef-scancode-unknown-license-reference",
"Unlicense",
"FTL",
"BSD-3-Clause",
"Bitstream-Vera",
"MPL-2.0",
"Zlib",
"CC-BY-4.0"
] | permissive | GhostWalker562/godot-admob-iOS-precompiled | 3fa99080f224d1b4c2dacac31e3786cebc034e2d | 18668d2fd7ea4bc5a7e84ddba36481fb20ee4095 | refs/heads/master | 2023-04-03T23:31:36.023618 | 2021-07-29T04:46:45 | 2021-07-29T04:46:45 | 195,341,087 | 24 | 2 | MIT | 2023-03-06T07:20:25 | 2019-07-05T04:55:50 | C++ | UTF-8 | C++ | false | false | 3,885 | h | /*************************************************************************/
/* constraint_2d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* 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 CONSTRAINT_2D_SW_H
#define CONSTRAINT_2D_SW_H
#include "body_2d_sw.h"
class Constraint2DSW : public RID_Data {
Body2DSW **_body_ptr;
int _body_count;
uint64_t island_step;
Constraint2DSW *island_next;
Constraint2DSW *island_list_next;
bool disabled_collisions_between_bodies;
RID self;
protected:
Constraint2DSW(Body2DSW **p_body_ptr = NULL, int p_body_count = 0) {
_body_ptr = p_body_ptr;
_body_count = p_body_count;
island_step = 0;
disabled_collisions_between_bodies = true;
}
public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
_FORCE_INLINE_ uint64_t get_island_step() const { return island_step; }
_FORCE_INLINE_ void set_island_step(uint64_t p_step) { island_step = p_step; }
_FORCE_INLINE_ Constraint2DSW *get_island_next() const { return island_next; }
_FORCE_INLINE_ void set_island_next(Constraint2DSW *p_next) { island_next = p_next; }
_FORCE_INLINE_ Constraint2DSW *get_island_list_next() const { return island_list_next; }
_FORCE_INLINE_ void set_island_list_next(Constraint2DSW *p_next) { island_list_next = p_next; }
_FORCE_INLINE_ Body2DSW **get_body_ptr() const { return _body_ptr; }
_FORCE_INLINE_ int get_body_count() const { return _body_count; }
_FORCE_INLINE_ void disable_collisions_between_bodies(const bool p_disabled) { disabled_collisions_between_bodies = p_disabled; }
_FORCE_INLINE_ bool is_disabled_collisions_between_bodies() const { return disabled_collisions_between_bodies; }
virtual bool setup(real_t p_step) = 0;
virtual void solve(real_t p_step) = 0;
virtual ~Constraint2DSW() {}
};
#endif // CONSTRAINT_2D_SW_H
| [
"pvu2002@outlook.com"
] | pvu2002@outlook.com |
c8ba6dd9eb8c52775dccd13010b0494eaf8d49f9 | 5044f1dba912fbf2c0908246c08290f2221081c2 | /pdlc2/symbolTable.cpp | 9fe186c91a393a567d6dfede6e5b694be3e2e104 | [] | no_license | ampam/pdlc2 | 6b08161273c8f3305322fbf97094bfbff1e3a943 | 5240686073999e3a847134cb174ade02f35a0025 | refs/heads/master | 2022-02-24T04:39:22.962990 | 2022-02-14T21:37:39 | 2022-02-14T21:37:39 | 205,622,008 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,176 | cpp | #include "stdafx.h"
#include "languageCommon.h"
#include "symbols.h"
#include "ast.h"
#include "symbolTable.h"
using namespace pam::pdl;
using namespace pam::pdl::symbols;
NamespaceSymbolPtr SymbolTable::addNamespace( std::string const& fullName )
{
NamespaceSymbolPtr result( new NamespaceSymbol( /*SymbolTablePtr(this), */fullName ) );
add( result );
return result;
}
NamespaceSymbolPtr SymbolTable::addNamespace( ast::NamespaceNode const& astNode )
{
auto result( addNamespace( joinIdentifier( astNode.name ) ) );
return result;
}
ClassSymbolPtr SymbolTable::addClass( ast::ClassNode const& astNode, NamespaceSymbolPtr parent )
{
//std::string fullClassName = parent->name() + "." + astNode.name.name;
auto const& className = astNode.name.name;
assert( !classExists( className ) );
ClassSymbolPtr result( new ClassSymbol( className, parent ) );
add( result );
//_table[ className ] = result;
//TODO incorporate more info from the astNode
return result;
}
ClassSymbolPtr SymbolTable::addUsingClass( ast::UsingNode const& astNode )
{
auto parsedClassName = SymbolTable::parseFullClassName( astNode.className );
auto& fullNamespace = parsedClassName.first;
const auto parentNamespace( getNamespace( fullNamespace ) );
auto& className = parsedClassName.second;
assert( !classExists( className ) );
ClassSymbolPtr result( new ClassSymbol( className, parentNamespace ) );
add( result );
result->SetAsExternalClass();
//TODO incorporate more info from the astNode
return result;
}
MethodSymbolPtr SymbolTable::addMethod( ast::MethodNode const& astNode, ClassSymbolPtr parent )
{
MethodSymbolPtr result( new MethodSymbol( astNode.name.name, parent ) );
add( result );
//TODO incorporate more info from the astNode
return result;
}
ConstSymbolPtr SymbolTable::addConst( ast::ConstNode const& constNode, ClassSymbolPtr parent )
{
ConstSymbolPtr result( new ConstSymbol( constNode.name.name, parent ) );
add( result );
//TODO incorporate more info from the astNode
return result;
}
PropertySymbolPtr SymbolTable::addProperty( ast::PropertyNode const& propertyNode, ClassSymbolPtr parent )
{
PropertySymbolPtr result( new PropertySymbol(propertyNode.name.name, parent ) );
add( result );
return result;
}
PropertySymbolPtr SymbolTable::addProperty(ast::ShortPropertyNode const& shortPropertyNode, ClassSymbolPtr parent)
{
PropertySymbolPtr result(new PropertySymbol(shortPropertyNode.name.name, parent));
add(result);
return result;
}
bool SymbolTable::classExists( std::string const& className )
{
const auto result = nullptr != getSymbol<ClassSymbolPtr>( className ).get();
return result;
}
bool SymbolTable::namespaceExists( std::string const& fullName )
{
const auto result = nullptr != getSymbol<NamespaceSymbolPtr>( fullName ).get();
return result;
}
NamespaceSymbolPtr SymbolTable::getNamespace( std::string const& fullName )
{
auto result = getSymbol<NamespaceSymbolPtr>( fullName );
if ( !result )
{
result = addNamespace( fullName );
}
return result;
}
| [
"am@plusamedia.com"
] | am@plusamedia.com |
f6baf53db2b83c0ed2003e96668acb5602e5fe39 | 5cb669c6c48ffdeb3d139985ead844751573e203 | /src/triangle.h | 4ae770d2c1d9763695d588c7f5c59572b90c1ca9 | [] | no_license | gzmuszynski/rasterizer | 9a99013c2ebc514caf92db9bb400865cb69722b1 | 498a9524a1cf75cc84f98b0b88aba82ba57d36b2 | refs/heads/master | 2021-09-06T16:51:22.504808 | 2018-01-13T12:43:59 | 2018-01-13T12:43:59 | 106,024,274 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 671 | h | #ifndef TRIANGLE_H
#define TRIANGLE_H
#include "light.h"
#include "color.h"
#include <string>
#include <vector>
#include "material.h"
/* B
* /\
* / \
* AB / \ BC
* / \
* /________\
* A AC C
*/
struct vertex
{
vertex(double x, double y, double z): pos(x,y,z) { }
float4 pos;
float4 pos2;
float4 norm;
float4 uv;
color col;
};
struct hit{
bool isHit;
float4 areas;
};
struct triangle
{
vertex *A,*B,*C;
material* mat;
triangle(vertex *A, vertex *B, vertex *C);
hit intersection(double x, double y);
hit intersectionCos(float x, float y);
};
#endif // TRIANGLE_H
| [
"gz.muszynski@gmail.com"
] | gz.muszynski@gmail.com |
ddb7db8aa3c8c7aeb5fc23c5601e705a16db538a | 587b48c424c2877000de11ee3c8c11eb3fb564cf | /1er año - 2do cuatrimestre/Informatica/Linked list/Example/LinkedList.cpp | 4a05e0e07e2f3b70caa96e8bfda23e4ecfd20a4f | [] | no_license | AguuSz/apuntes-iua | ad888f2371524b7fba4d03190639f6a28e5a61ae | 67ba189e3265969122c26ce9cccaea24b6794c70 | refs/heads/main | 2023-04-27T07:37:53.956866 | 2021-05-14T13:48:20 | 2021-05-14T13:48:20 | 309,660,169 | 0 | 0 | null | 2021-03-30T16:55:45 | 2020-11-03T11:08:59 | C++ | UTF-8 | C++ | false | false | 1,442 | cpp | //
// Created by aureb on 2/10/2020.
//
#include <iostream>
#include "LinkedList.h"
LinkedList::LinkedList() {
head = nullptr;
list_size = 0;
}
Node *LinkedList::getNode(int pos) {
int p = 0;
Node *aux = head;
while (p != pos - 1 && aux != nullptr) {
aux = aux->getNext();
p++;
}
if (aux == nullptr) {
throw 404;
}
return aux;
}
void LinkedList::insert(int pos, int dato) {
Node *aux;
if (pos == 0) {
aux = new Node;
aux->setNext(head);
aux->setData(dato);
head = aux;
return;
}
aux = getNode(pos - 1);
getNode(pos);
Node *newNode = new Node;
newNode->setNext(aux->getNext());
aux->setNext(newNode);
newNode->setData(dato);
}
int LinkedList::get(int pos) {
Node *aux = getNode(pos);
return aux->getData();
}
void LinkedList::replace(int pos, int dato) {
Node *aux = getNode(pos - 1);
aux->setData(dato);
}
bool LinkedList::empty() {
return (head == nullptr);
}
void LinkedList::erase(int pos) {
if(head == nullptr){
throw 404;
}
if (pos == 0) {
Node *toDelete = head;
head = head->getNext();
delete toDelete;
return;
}
Node *aux = getNode(pos - 1);
Node *toDelete = aux->getNext();
if (toDelete == nullptr) {
throw 404;
}
aux->setNext(toDelete->getNext());
delete toDelete;
}
| [
"aure.bidart@gmail.com"
] | aure.bidart@gmail.com |
3a23cc5fe0d6cbd464f310c102d6adc96028fa7f | f915aa382b6ac5673cec612718368c04931c0b0c | /src/ExtentChildNode.cpp | 3d338c1275000d9da23ce24edec4ce33c24a7e3a | [
"BSD-2-Clause"
] | permissive | diazf/indri | f477749f9e571c03b695c2f0b04c0326bbfd9f04 | 6ad646f3edb9864a98214039886c6b6e9a9f6b74 | refs/heads/master | 2022-09-07T19:35:02.661982 | 2022-08-19T13:59:26 | 2022-08-19T13:59:26 | 128,638,901 | 23 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 12,017 | cpp | /*==========================================================================
* Copyright (c) 2006 Carnegie Mellon University. All Rights Reserved.
*
* Use of the Lemur Toolkit for Language Modeling and Information Retrieval
* is subject to the terms of the software license set forth in the LICENSE
* file included with this software (and below), and also available at
* http://www.lemurproject.org/license.html
*
*==========================================================================
*/
//
// ExtentChildNode
//
// 31 Jan 2006 -- pto
//
#include "indri/ExtentChildNode.hpp"
#include "lemur/lemur-compat.hpp"
#include "indri/Annotator.hpp"
indri::infnet::ExtentChildNode::ExtentChildNode( const std::string& name,
ListIteratorNode* inner,
ListIteratorNode* outer,
DocumentStructureHolderNode & documentStructureHolderNode ) :
_inner(inner),
_outer(outer),
_docStructHolder(documentStructureHolderNode),
_name(name)
{
}
void indri::infnet::ExtentChildNode::prepare( lemur::api::DOCID_T documentID ) {
// initialize the child / sibling pointer
initpointer();
_extents.clear();
_lastExtent.begin = -1;
_lastExtent.end = -1;
if( !_inner || !_outer )
return;
const indri::utility::greedy_vector<indri::index::Extent>& inExtents = _inner->extents();
const indri::utility::greedy_vector<indri::index::Extent>& outExtents = _outer->extents();
indri::utility::greedy_vector<indri::index::Extent>::const_iterator innerIter = inExtents.begin();
// if we have child / parent ordinals in the index, we can sort on these
// and quickly break out instead of having to go thorugh the whole list.
if (innerIter!=inExtents.end() && innerIter->ordinal != 0 && innerIter->parent != -1) {
// ordinal & parent fields for extents recorded in index.
// this is the fast loop!
// should construct hash table from parent id -> child extents if there are
// many [./argx] child extent requests in one single query.
// Count up children and initialize findChildren hash
while (innerIter != inExtents.end()){
if(innerIter->parent > 0){
_extents.push_back(*innerIter);
}
innerIter++;
}
// sort by the parent ID
sortparent(_extents);
// quick exit out
return;
} // end if (innerIter!=inExtents.end() && innerIter->ordinal != 0 && innerIter->parent != -1)
indri::utility::greedy_vector<indri::index::Extent>::const_iterator outerBegin = outExtents.begin();
indri::utility::greedy_vector<indri::index::Extent>::const_iterator outerEnd = outExtents.end();
indri::index::DocumentStructure * docStruct = _docStructHolder.getDocumentStructure();
// check the inner extents, searching for a parent in outerNodes
while ( innerIter != inExtents.end() ) {
if ( innerIter->ordinal == 0 ) {
_leafs.clear();
docStruct->findLeafs( &_leafs, innerIter->begin, innerIter->end, true );
std::set<int>::iterator leafsEnd = _leafs.end();
std::set<int>::iterator leaf = _leafs.begin();
bool found = false;
while ( leaf != leafsEnd && !found) {
indri::utility::greedy_vector<indri::index::Extent>::const_iterator outerIter = outerBegin;
while ( outerIter != outerEnd && !found ) {
if ( outerIter->ordinal == 0 ) {
_ancestors.clear();
docStruct->findLeafs( &_ancestors, outerIter->begin, outerIter->end, true );
std::set<int>::iterator ancestor = _ancestors.begin();
std::set<int>::iterator ancestorsEnd = _ancestors.end();
while ( ancestor != ancestorsEnd && !found ) {
if ( *ancestor == docStruct->parent( *leaf ) ) {
found = true;
indri::index::Extent extent( innerIter->weight * outerIter->weight,
innerIter->begin,
innerIter->end,
*leaf );
_extents.push_back( extent );
}
ancestor++;
}
} else {
if ( outerIter->ordinal == docStruct->parent( *leaf ) ) {
indri::index::Extent extent( innerIter->weight * outerIter->weight,
innerIter->begin,
innerIter->end,
*leaf );
_extents.push_back( extent );
}
}
outerIter++;
}
leaf++;
}
} else {
bool found = false;
indri::utility::greedy_vector<indri::index::Extent>::const_iterator outerIter = outerBegin;
while ( outerIter != outerEnd && !found ) {
if ( outerIter->ordinal == 0 ) {
_ancestors.clear();
docStruct->findLeafs( &_ancestors, outerIter->begin, outerIter->end, true );
std::set<int>::iterator ancestor = _ancestors.begin();
std::set<int>::iterator ancestorsEnd = _ancestors.end();
while ( ancestor != ancestorsEnd && !found ) {
int parent = innerIter->parent;
if ( parent == -1 ) {
parent = docStruct->parent( innerIter->ordinal );
}
if ( *ancestor == parent ) {
found = true;
indri::index::Extent extent( innerIter->weight * outerIter->weight,
innerIter->begin,
innerIter->end,
innerIter->ordinal,
parent,
innerIter->number );
_extents.push_back( extent );
}
ancestor++;
}
} else {
int parent = innerIter->parent;
if ( parent == -1 ) {
parent = docStruct->parent( innerIter->ordinal );
}
if ( outerIter->ordinal == parent ) {
indri::index::Extent extent( innerIter->weight * outerIter->weight,
innerIter->begin,
innerIter->end,
innerIter->ordinal,
parent,
innerIter->number );
_extents.push_back( extent );
}
}
outerIter++;
}
}
innerIter++;
}
}
const indri::utility::greedy_vector<indri::index::Extent>& indri::infnet::ExtentChildNode::extents() {
return _extents;
}
lemur::api::DOCID_T indri::infnet::ExtentChildNode::nextCandidateDocument() {
return lemur_compat::max( _inner->nextCandidateDocument(), _outer->nextCandidateDocument() );
}
const std::string& indri::infnet::ExtentChildNode::getName() const {
return _name;
}
void indri::infnet::ExtentChildNode::annotate( class Annotator& annotator, lemur::api::DOCID_T documentID, indri::index::Extent &extent ) {
if (! _lastExtent.contains(extent)) {
// if the last extent we annotated contains this one, there is no work
// to do.
_lastExtent = extent;
annotator.addMatches( _extents, this, documentID, extent );
indri::index::Extent range( extent.begin, extent.end );
indri::utility::greedy_vector<indri::index::Extent>::const_iterator iter;
iter = std::lower_bound( _extents.begin(), _extents.end(), range, indri::index::Extent::begins_before_less() );
for( size_t i = iter-_extents.begin(); i<_extents.size() && _extents[i].begin <= extent.end; i++ ) {
_inner->annotate( annotator, documentID, (indri::index::Extent &)_extents[i] );
_outer->annotate( annotator, documentID, (indri::index::Extent &)_extents[i] );
}
}
}
void indri::infnet::ExtentChildNode::indexChanged( indri::index::Index& index ) {
_lastExtent.begin = -1;
_lastExtent.end = -1;
}
const indri::utility::greedy_vector<indri::index::Extent>& indri::infnet::ExtentChildNode::matches( indri::index::Extent &extent ) {
_matches.clear();
int begin = extent.begin;
int end = extent.end;
// no length? Quick exit
if (begin == end || _extents.size()==0) {
return _matches;
}
// if the extents are stored, we can quickly gather them
// from the table built in prepare()
if (extent.ordinal != 0) {
// make sure we didn't pass it up...
while(_lastpos>0&&_extents[_lastpos-1].parent>=extent.ordinal){
_lastpos--;
}
// make sure we're in the right position
while(_lastpos<_extents.size()&&_extents[_lastpos].parent<extent.ordinal){
_lastpos++;
}
// gather the child matches
while(_lastpos<_extents.size()&&_extents[_lastpos].parent==extent.ordinal){
indri::index::Extent ext(_extents[_lastpos]);
ext.weight *= extent.weight;
_matches.push_back(ext);
_lastpos++;
}
// quick exit out
return _matches;
} // end if (extent.ordinal != 0)
indri::index::DocumentStructure * docStruct = _docStructHolder.getDocumentStructure();
if ( extent.ordinal == 0 ) {
_ancestors.clear();
docStruct->findLeafs( &_ancestors, begin, end, true);
std::set<int>::iterator ancestorsBegin = _ancestors.begin();
std::set<int>::iterator ancestorsEnd = _ancestors.end();
for( size_t i = 0; i < _extents.size(); i++ ) {
bool match = false;
int innerBegin = _extents[i].begin;
int innerEnd = _extents[i].end;
if ( _extents[i].ordinal == 0 ) {
_leafs.clear();
docStruct->findLeafs( &_leafs, innerBegin, innerEnd, true);
std::set<int>::iterator leafsBegin = _leafs.begin();
std::set<int>::iterator leafsEnd = _leafs.end();
std::set<int>::iterator ancestor = ancestorsBegin;
while ( !match && ancestor != ancestorsEnd ) {
std::set<int>::iterator leaf = leafsBegin;
while ( !match && leaf != leafsEnd ) {
if ( *ancestor == docStruct->parent(*leaf) ) {
match = true;
}
leaf++;
}
ancestor++;
}
} else {
int parent = _extents[i].parent;
if (parent == -1) {
parent = docStruct->parent( _extents[i].ordinal );
}
std::set<int>::iterator ancestor = ancestorsBegin;
while ( !match && ancestor != ancestorsEnd ) {
if ( *ancestor == parent ) {
match = true;
}
ancestor++;
}
}
if ( match ) {
_matches.push_back(_extents[i]);
}
}
} else {
for( size_t i = 0; i < _extents.size(); i++ ) {
int innerBegin = _extents[i].begin;
int innerEnd = _extents[i].end;
bool match = false;
if ( _extents[i].ordinal == 0 ) {
_leafs.clear();
docStruct->findLeafs( &_leafs, innerBegin, innerEnd, true);
std::set<int>::iterator leafsBegin = _leafs.begin();
std::set<int>::iterator leafsEnd = _leafs.end();
std::set<int>::iterator leaf = leafsBegin;
while ( !match && leaf != leafsEnd ) {
if ( extent.ordinal == docStruct->parent(*leaf) ) {
match = true;
}
leaf++;
}
} else {
int parent = _extents[i].parent;
if (parent == -1) {
parent = docStruct->parent( _extents[i].ordinal );
}
if ( extent.ordinal == parent ) {
match = true;
}
}
if ( match ) {
_matches.push_back(_extents[i]);
}
}
}
return _matches;
}
| [
"diazf@acm.org"
] | diazf@acm.org |
15eb0d497454cf715b94383c43451c61732e17ee | 761303811ecb2948562f28de3bdfa0f4184e8dbf | /inventory.cpp | f4016db9e4cbbdd7b6b2fc480a1be87f9e33197a | [] | no_license | AaronThomsen/dungeon-quest | 23857c0406093285a2f265ccc7512842379f5799 | 2fc00e5de05a5453b9c61644b27ecba2709a8b84 | refs/heads/master | 2020-03-29T20:29:39.072474 | 2018-09-25T20:43:34 | 2018-09-25T20:43:34 | 150,314,915 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,537 | cpp | #include "inventory.h"
Inventory::Inventory(Character& c, int i) : ch(c), type(i) {
if (i == 0) { //character inventory
Basic_Armour *bscArm = new Basic_Armour(0, ch, "Standard");
armorPtr = bscArm;
item = bscArm;
this->addInventoryItem(item, 1);
//Determine weapon to add based on Character class
std::string charClass = ch.getName();
if (charClass == "Adventurer") {
item = new Magic_Sword(0, ch, "Simple");
}
else if (charClass == "Alcoholic") {
item = new Alcohol_Bottle(0, ch, "Shoddy");
}
else if (charClass == "Assassin") {
item = new Katar_Dagger(0, ch, "Basic");
}
weaponPtr = item;
this->addInventoryItem(item, 1);
}
else { //Merchant inventory
std::string s;
if (++floorCount < 4) {
s = "Small";
}
else if (floorCount < 7) {
s = "Medium";
}
else if (floorCount < 9) {
s = "Large";
}
else {
s = "Full";
}
for (int i = 0; i < 7; i++) {
item = getRandItem(s);
if (!isInInventory(item->getName())) //no adding duplicates!
this->addInventoryItem(item, rand() % 3 + 1);
}
}
}
void Inventory::delInventoryItem(I::Items* item, int quantity) {
inventoryItem[item] -= quantity;
if (inventoryItem[item] <= 0) {
inventoryItem.erase(item);
}
}
I::Items* Inventory::getRandItem(std::string type) {
int r = rand() % 6;
switch (r) {
case 0:
case 1:
case 2:
return new Health_Potions(type, ch);
case 3:
return new Special_Potions(type, ch);
case 4:
return new Combat_Potions(type, "Attack", ch);
case 5:
return new Combat_Potions(type, "Defense", ch);
}
return nullptr;
}
void Inventory::accessInventoryItem(std::string& com) const {
std::cout << "Enter item name to use or type 'Back': ";
getline(std::cin, com);
for (unsigned i = 0; i < com.length(); ++i) {
com[i] = tolower(com[i]);
}
}
void Inventory::addInventoryItem(I::Items* item, int quantity) {
inventoryItem[item] += quantity;
}
void Inventory::idItem(std::string& com, I::Items*& item) {
for (auto iter = inventoryItem.begin(); iter != inventoryItem.end(); ++iter) {
I::Items* k = iter->first;
std::string tCom = com;
for (unsigned i = 0; i < com.length(); ++i) {
tCom[i] = tolower(com[i]);
}
std::string name = k->getName();
for (unsigned i = 0; i < name.length(); ++i) {
name[i] = tolower(name[i]);
}
if (tCom == name) {
item = k;
return;
}
}
com = "";
}
bool Inventory::addNewItem(std::string itemName, I::Items* i) {
item = nullptr;
for (unsigned i = 0; i < itemName.length(); ++i) {
itemName[i] = tolower(itemName[i]);
}
if (itemName.find("attack") != std::string::npos ||
itemName.find("defense") != std::string::npos) {
item = new Combat_Potions(*dynamic_cast<Combat_Potions*>(i));
}
else if (itemName.find("health") != std::string::npos) {
item = new Health_Potions(*dynamic_cast<Health_Potions*>(i));
}
else if (itemName.find("mana") != std::string::npos &&
itemName.find("feather") == std::string::npos) {
item = new Special_Potions(*dynamic_cast<Special_Potions*>(i));
}
else if (itemName == "weapon upgrade" ||
itemName == "armor upgrade" ||
itemName == "lamp of illumination" ||
itemName == "bulky herb" ||
itemName == "mana feather" ||
itemName == "ability scroll") {
item = i;
}
if (item) {
addInventoryItem(item, 1);
return true;
}
else {
return false;
}
}
bool Inventory::isInInventory(std::string s) {
I::Items* p;
idItem(s, p);
if (s == "")
return false;
return true;
}
bool Inventory::useInventory() {
std::string com;
//Prints out the inventory for the player
this->printInventory();
//Returns the Item the player wants to use
this->accessInventoryItem(com);
if (com == "Back" || com == "back") {
com = "";
return false;
}
else {
if (com.find("magic sword") != std::string::npos ||
com.find("alcohol bottle") != std::string::npos ||
com.find("katar dagger") != std::string::npos ||
com.find("magic armour") != std::string::npos) {
std::cout << "You cannot use weapons/armours in this way!" << std::endl;
com = "";
return false;
}
}
//Finds the item in the map
this->idItem(com, item);
//Deletes one specified item quantity
if (!com.empty()) {
if (item->getName() == "Weapon Upgrade") {
delInventoryItem(item, 1);
std::cout << "\nYou feel the power in your sword grow stronger...\n" << std::endl;
weaponPtr->upgradeWeapon();
return true;
}
else if (item->getName() == "Armor Upgrade") {
delInventoryItem(item, 1);
std::cout << "\nYou feel your armor grow tougher...\n" << std::endl;
armorPtr->upgradeArmor();
return true;
}
else if (item->getName() == "Lamp of Illumination") {
delInventoryItem(item, 1);
std::cout << "\nThe Lamp of Illumination lights up...\n" << std::endl;
throw Lamp(ch);
}
else if (item->getName() == "Ability Scroll") {
delInventoryItem(item, 1);
ch.unlockRandomAbility();
return true;
}
//Uses the item's effect
item->consume();
int itemCount = inventoryItem[item] - 1;
this->delInventoryItem(item, 1);
std::cout << std::endl;
std::cout << "You used one " << com << ". (" << itemCount << ") left in inventory." << std::endl;
std::cout << std::endl;
return true;
}
else {
std::cout << "Item not found." << std::endl << std::endl;
return false;
}
}
void Inventory::printInventory() {
if (type == 0) { //Char inventory
std::cout << std::setw(12) << "Quantity:" << std::setw(30) << "Item:" << std::setw(50) << "Notes:" << std::endl;
for (auto iter = inventoryItem.begin(); iter != inventoryItem.end(); ++iter) {
int v = iter->second;
std::cout << "(" << v << std::setw(10) << ")";
I::Items* k = iter->first;
std::cout << k->info() << std::endl;
}
}
else { //Merchant Inventory
std::cout << std::setw(25) << "Name" << std::setw(15) << "# In-Stock" << std::setw(10) << "Potency" << std::setw(10) << "Price" << std::endl;
std::cout << std::setfill('-') << std::setw(60) << "" << std::setfill(' ') << std::endl;
for (std::map<I::Items*, int>::iterator iter = inventoryItem.begin(); iter != inventoryItem.end(); ++iter) {
int v = iter->second;
I::Items* k = iter->first;
std::cout << std::setw(25) << k->getName() << std::setw(15) << v << std::setw(10) << k->getPotency() << std::setw(10) << k->getPrice() << std::endl;
}
}
}
int Inventory::floorCount = 0; | [
"aarontthomsen@gmail.com"
] | aarontthomsen@gmail.com |
3da6874547d90356e2c148f5e931e63a5648bf11 | cefd6c17774b5c94240d57adccef57d9bba4a2e9 | /WebKit/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.h | bd7555d2712fc6b7268451e2e843b14f02b17b6c | [
"BSL-1.0"
] | permissive | adzhou/oragle | 9c054c25b24ff0a65cb9639bafd02aac2bcdce8b | 5442d418b87d0da161429ffa5cb83777e9b38e4d | refs/heads/master | 2022-11-01T05:04:59.368831 | 2014-03-12T15:50:08 | 2014-03-12T15:50:08 | 17,238,063 | 0 | 1 | BSL-1.0 | 2022-10-18T04:23:53 | 2014-02-27T05:39:44 | C++ | UTF-8 | C++ | false | false | 3,071 | h | /*
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DatabaseProcessProxy_h
#define DatabaseProcessProxy_h
#if ENABLE(DATABASE_PROCESS)
#include "ChildProcessProxy.h"
#include "ProcessLauncher.h"
#include "WebProcessProxyMessages.h"
#include <wtf/Deque.h>
namespace WebKit {
class WebContext;
class DatabaseProcessProxy : public ChildProcessProxy {
public:
static PassRefPtr<DatabaseProcessProxy> create(WebContext*);
~DatabaseProcessProxy();
void getDatabaseProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetDatabaseProcessConnection::DelayedReply>);
private:
DatabaseProcessProxy(WebContext*);
// ChildProcessProxy
virtual void getLaunchOptions(ProcessLauncher::LaunchOptions&) override;
virtual void connectionWillOpen(IPC::Connection*) override;
virtual void connectionWillClose(IPC::Connection*) override;
// IPC::Connection::Client
virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
virtual void didClose(IPC::Connection*) override;
virtual void didReceiveInvalidMessage(IPC::Connection*, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
// Message handlers
void didCreateDatabaseToWebProcessConnection(const IPC::Attachment&);
// ProcessLauncher::Client
virtual void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
void platformGetLaunchOptions(ProcessLauncher::LaunchOptions&);
WebContext* m_webContext;
unsigned m_numPendingConnectionRequests;
Deque<RefPtr<Messages::WebProcessProxy::GetDatabaseProcessConnection::DelayedReply>> m_pendingConnectionReplies;
};
} // namespace WebKit
#endif // ENABLE(DATABASE_PROCESS)
#endif // DatabaseProcessProxy_h
| [
"adzhou@hp.com"
] | adzhou@hp.com |
27c75203208e869e8ed445864adb48ad4f07f0f7 | c2a29ee9de5b82b163f16de431147bf1eb2ebd38 | /Src/ImageProcess/LBP.h | 04343fed8ddf47f4733e235e6c69a4d0324ed690 | [] | no_license | raylee-lilei/QQImageProcess_OpenCV | 01f97f074e8433580e883866587f3dcb7cd72ab2 | 54120ec74f11d7e8c6f477d5b5082703d0102d30 | refs/heads/master | 2020-09-01T09:43:21.777051 | 2019-10-21T05:46:04 | 2019-10-21T05:46:04 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,198 | h | //////////////////////////////////////////////////////////////////////////
// LBP.h (2.0)
// 2015-6-30,by QQ
//
// Please contact me if you find any bugs, or have any suggestions.
// Contact:
// Telephone:17761745857
// Email:654393155@qq.com
// Blog: http://blog.csdn.net/qianqing13579
//////////////////////////////////////////////////////////////////////////
// Updated 2016-12-12 01:12:55 by QQ, LBP 1.1,GetMinBinary()函数修改为查找表,提高了计算速度
// Updated 2016-12-13 14:41:58 by QQ, LBP 2.0,先计算整幅图像的LBP特征图,然后计算每个cell的LBP直方图
// Updated 2017-7-29&30 by QQ,add 对ComputeLBPFeatureVector_256和ComputeLBPFeatureVector_Uniform进行了优化:添加了滑动窗口像素查找表
#ifndef __LBP_H__
#define __LBP_H__
#include "opencv2/opencv.hpp"
#include<vector>
using namespace std;
using namespace cv;
namespace QQ
{
/*
三种LBP特征的计算步骤基本一致:先计算LBP特征图,然后对每个cell计算特征向量
*/
class LBP
{
public:
//////////////////////////////////// 计算基本的256维LBP特征向量 ////////////////////////////////////
void ComputeLBPFeatureVector_256(const Mat &srcImage, Size cellSize,Mat &featureVector);
void ComputeLBPImage_256(const Mat &srcImage, Mat &LBPImage);// 计算256维LBP特征图
// 对ComputeLBPFeatureVector_256优化,构建滑动窗口像素查找表
void ComputeLBPFeatureVector_256_O(const Mat &srcImage, Size cellSize, Mat &featureVector);
// 对ComputeLBPFeatureVector_256_O的优化,主要优化掉循环中的乘法
void ComputeLBPFeatureVector_256_O_2(const Mat &srcImage, Size cellSize, Mat &featureVector);
//////////////////////////////////// 计算灰度不变+等价模式LBP特征向量(58种模式) ////////////////////////////////////
void ComputeLBPFeatureVector_Uniform(const Mat &srcImage, Size cellSize, Mat &featureVector);
// 计算等价模式LBP特征图
void ComputeLBPImage_Uniform(const Mat &srcImage, Mat &LBPImage);
// 对ComputeLBPFeatureVector_Uniform优化,构建滑动窗口像素查找表
void ComputeLBPFeatureVector_Uniform_O(const Mat &srcImage, Size cellSize, Mat &featureVector);
//////////////////////////////////// 计算灰度不变+旋转不变+等价模式LBP特征向量(9种模式) ////////////////////////////////////
void ComputeLBPFeatureVector_Rotation_Uniform(const Mat &srcImage, Size cellSize, Mat &featureVector);
void ComputeLBPImage_Rotation_Uniform(const Mat &srcImage, Mat &LBPImage); // 计算灰度不变+旋转不变+等价模式LBP特征图,使用查找表
// Test
void Test();// 测试灰度不变+旋转不变+等价模式LBP
void TestGetMinBinaryLUT();
private:
void BuildUniformPatternTable(int *table); // 计算等价模式查找表
int GetHopCount(int i);// 获取i中0,1的跳变次数
void ComputeLBPImage_Rotation_Uniform_2(const Mat &srcImage, Mat &LBPImage);// 计算灰度不变+旋转不变+等价模式LBP特征图,不使用查找表
int ComputeValue9(int value58);// 计算9种等价模式
int GetMinBinary(int binary);// 通过LUT计算最小二进制
uchar GetMinBinary(uchar *binary); // 计算得到最小二进制
};
}
#endif
| [
"654393155@qq.com"
] | 654393155@qq.com |
39f686b1364e0b9116c569dfcf7ce1ca2d2a2bc1 | 635c344550534c100e0a86ab318905734c95390d | /wpimath/src/main/native/cpp/estimator/SwerveDrivePoseEstimator.cpp | f2ed301c2adfadb8a7ab8980002d6fa162bd6eda | [
"BSD-3-Clause"
] | permissive | wpilibsuite/allwpilib | 2435cd2f5c16fb5431afe158a5b8fd84da62da24 | 8f3d6a1d4b1713693abc888ded06023cab3cab3a | refs/heads/main | 2023-08-23T21:04:26.896972 | 2023-08-23T17:47:32 | 2023-08-23T17:47:32 | 24,655,143 | 986 | 769 | NOASSERTION | 2023-09-14T03:51:22 | 2014-09-30T20:51:33 | C++ | UTF-8 | C++ | false | false | 380 | cpp | // Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc/estimator/SwerveDrivePoseEstimator.h"
namespace frc {
template class EXPORT_TEMPLATE_DEFINE(WPILIB_DLLEXPORT)
SwerveDrivePoseEstimator<4>;
} // namespace frc
| [
"johnson.peter@gmail.com"
] | johnson.peter@gmail.com |
7547b9575626101b685537bc10734c304dcd5225 | 37d08c745caee39da991debb54635065df1a8e2a | /sparse-iter/src/sresidualvec.cpp | b7d79285bf98b8e427d152a666ef04d96b3875e2 | [] | no_license | kjbartel/magma | c936cd4838523779f31df418303c6bebb063aecd | 3f0dd347d2e230c8474d1e22e05b550fa233c7a3 | refs/heads/master | 2020-06-06T18:12:56.286615 | 2015-06-04T17:20:40 | 2015-06-04T17:20:40 | 36,885,326 | 23 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 2,786 | cpp | /*
-- MAGMA (version 1.6.2) --
Univ. of Tennessee, Knoxville
Univ. of California, Berkeley
Univ. of Colorado, Denver
@date May 2015
@generated from zresidualvec.cpp normal z -> s, Sun May 3 11:22:59 2015
@author Hartwig Anzt
*/
#include "common_magmasparse.h"
#define r(i_) (r->dval)+i_*dofs
#define b(i_) (b.dval)+i_*dofs
/**
Purpose
-------
Computes the residual r = b-Ax for a solution approximation x.
It returns both, the actual residual and the residual vector
Arguments
---------
@param[in]
A magma_s_matrix
input matrix A
@param[in]
b magma_s_matrix
RHS b
@param[in]
x magma_s_matrix
solution approximation
@param[in,out]
r magma_s_matrix*
residual vector
@param[out]
res float*
return residual
@param[in]
queue magma_queue_t
Queue to execute in.
@ingroup magmasparse_saux
********************************************************************/
extern "C" magma_int_t
magma_sresidualvec(
magma_s_matrix A, magma_s_matrix b, magma_s_matrix x,
magma_s_matrix *r, float *res,
magma_queue_t queue )
{
magma_int_t info =0;
// set queue for old dense routines
magma_queue_t orig_queue=NULL;
magmablasGetKernelStream( &orig_queue );
// some useful variables
float zero = MAGMA_S_ZERO, one = MAGMA_S_ONE,
mone = MAGMA_S_NEG_ONE;
magma_int_t dofs = A.num_rows;
if ( A.num_rows == b.num_rows ) {
CHECK( magma_s_spmv( mone, A, x, zero, *r, queue )); // r = A x
magma_saxpy(dofs, one, b.dval, 1, r->dval, 1); // r = r - b
*res = magma_snrm2(dofs, r->dval, 1); // res = ||r||
// /magma_snrm2(dofs, b.dval, 1); /||b||
//printf( "relative residual: %e\n", *res );
} else if ((b.num_rows*b.num_cols)%A.num_rows== 0 ) {
magma_int_t num_vecs = b.num_rows*b.num_cols/A.num_rows;
CHECK( magma_s_spmv( mone, A, x, zero, *r, queue )); // r = A x
for( magma_int_t i=0; i<num_vecs; i++) {
magma_saxpy(dofs, one, b(i), 1, r(i), 1); // r = r - b
res[i] = magma_snrm2(dofs, r(i), 1); // res = ||r||
}
// /magma_snrm2(dofs, b.dval, 1); /||b||
//printf( "relative residual: %e\n", *res );
} else {
printf("error: dimensions do not match.\n");
info = MAGMA_ERR_NOT_SUPPORTED;
}
cleanup:
magmablasSetKernelStream( orig_queue );
return info;
}
| [
"kjbartel@users.noreply.github.com"
] | kjbartel@users.noreply.github.com |
ec599a6dd13065968e42dd6ae8bf9291fd724fd5 | 74aab27b73d22af481ec7bce2fae32e634cfbb37 | /problems/utf8_validation.cpp | 99463a993bbeacb566a2c3469f82e0a45116fd19 | [
"MIT"
] | permissive | JingxueLiao/Data_Structures_and_Algorithms | b36449020cc627af4659f6952912e064d2b312c3 | 7851b0da25ed3c115c51d20f18d3e6a1e2bec4f4 | refs/heads/master | 2020-05-21T14:54:35.190144 | 2016-11-10T08:20:31 | 2016-11-10T08:20:31 | 60,458,858 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,252 | cpp | // A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:
// 1. For 1-byte character, the first bit is a 0, followed by its unicode code.
// 2. For n-bytes character, the first n-bits are all one's, the n+1 bit is 0, followed by n-1 bytes with most significant 2 bits being 10.
// This is how the UTF-8 encoding would work:
// Char. number range | UTF-8 octet sequence
// (hexadecimal) | (binary)
// --------------------+---------------------------------------------
// 0000 0000-0000 007F | 0xxxxxxx
// 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
// 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
// 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
// Given an array of integers representing the data, return whether it is a valid utf-8 encoding.
// Note:
// The input is an array of integers. Only the least significant 8 bits of each integer is used to store the data. This means each integer represents only 1 byte of data.
// Example 1:
// data = [197, 130, 1], which represents the octet sequence: 11000101 10000010 00000001.
// Return true.
// It is a valid utf-8 encoding for a 2-bytes character followed by a 1-byte character.
// Example 2:
// data = [235, 140, 4], which represented the octet sequence: 11101011 10001100 00000100.
// Return false.
// The first 3 bits are all one's and the 4th bit is 0 means it is a 3-bytes character.
// The next byte is a continuation byte which starts with 10 and that's correct.
// But the second continuation byte does not start with 10, so it is invalid.
#include <vector>
using namespace std;
bool ValidUtf8(const vector<int> &data) {
int i = 0;
while (i < data.size()) {
int l = 0;
if ((data[i] >> 7 & 1) == 0) {
l = 1;
} else if ((data[i] >> 5 & 7) == 6) {
l = 2;
} else if ((data[i] >> 4 & 0xf) == 0xe) {
l = 3;
} else if ((data[i] >> 3 & 0x1f) == 0x1e) {
l = 4;
} else {
return false;
}
for (int j = 1; j < l; ++j) {
if (i + j == data.size() || (data[i + j] >> 6 & 3) != 2)
return false;
}
i += l;
}
return true;
}
| [
"jingxue.liao@gmail.com"
] | jingxue.liao@gmail.com |
54cc818602224d73942f2b269dc355a663f18577 | a04dfee52bf07c76d37ac692bc17450feec728df | /include/SchematLib/MapSimplification/SpecialEdgeIdFunctions.h | d3a1e37c74b09aab92baf7723ab56a3106ced2ae | [
"Apache-2.0"
] | permissive | tue-alga/CoordinatedSchematization | 5d3d555b3a2ed939becacb168a2f42180183f06c | 9ffc292c946498d56f7938a86628adba534a9085 | refs/heads/main | 2023-07-13T13:56:39.058355 | 2021-07-01T09:20:10 | 2021-07-01T09:20:10 | 380,178,681 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,485 | h | #ifndef SCHEMATLIB_MAPSIMPLIFICATION_SPECIALEDGDEIDFUNCTIONS_H
#define SCHEMATLIB_MAPSIMPLIFICATION_SPECIALEDGDEIDFUNCTIONS_H
#include <vector>
namespace SchematLib::MapSimplification {
struct SpecialEdgeIdFunctions
{
static constexpr std::size_t NONCANONICAL_BIT = (std::size_t{ 1 } << (sizeof(std::size_t) * 8 - 1));
static inline std::size_t getEdgeId(std::size_t id)
{
return id & (~(NONCANONICAL_BIT));
}
static inline bool isNonCanonical(std::size_t id)
{
return (id & NONCANONICAL_BIT ) > 0;
}
static inline bool isCanonical(std::size_t id)
{
return !isNonCanonical(id);
}
static inline std::size_t makeNonCanonical(std::size_t id)
{
return getEdgeId(id) | NONCANONICAL_BIT;
}
static inline std::size_t makeCanonical(std::size_t id)
{
return getEdgeId(id); //Same, since non-canonical bit is filtered out
}
static inline std::size_t flipCanonical(std::size_t id)
{
return isCanonical(id) ? makeNonCanonical(id) : makeCanonical(id);
}
static inline void reverseCanonicalComplement(std::vector<std::size_t>& ids)
{
std::reverse(ids.begin(), ids.end());
for (auto& id : ids)
{
id = isCanonical(id) ? makeNonCanonical(id) : makeCanonical(id);
}
}
};
}
#endif | [
"b.a.custers@tue.nl"
] | b.a.custers@tue.nl |
a8cbfe953de2c4588a55c1d8f0cfa78c69c900b6 | 1fd64e1e0b12de3256fa9ab509c8a0e7628da9f0 | /examples/Arduino TFT/TFT_Jpeg/TFT_Jpeg.ino | c76b7782ad5c1013e6800d4dc7844e3ef27aa695 | [
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | Bodmer/JPEGDecoder | e3ab37ee9655898ed46097520f1020ca51a2fa55 | c0fad79035abdbf144b59b687532debb41f23fe3 | refs/heads/master | 2022-10-31T06:14:26.484997 | 2022-10-11T01:28:51 | 2022-10-11T01:28:51 | 50,698,680 | 203 | 67 | NOASSERTION | 2020-12-24T07:03:28 | 2016-01-29T23:37:39 | C | UTF-8 | C++ | false | false | 7,809 | ino | /*
Arduino TFT Jpeg example
This example reads a Jpeg image file from a micro-SD card
and draws it on the screen.
In this sketch, the Arduino logo is read from a micro-SD card.
There is a arduino.jpg file included with this sketch.
- open the sketch folder (Ctrl-K or Cmd-K)
- copy the "arduino.jpg" file to a micro-SD
- put the SD into the SD slot of the Arduino TFT module.
This example code is in the public domain.
Original sketch "TFTBitmapLogo" created 19 April 2013 by Enrico Gueli
Adapted by Bodmer 20 January 2017 to display a jpeg image
rather than a bitmap
Display details here:
https://www.arduino.cc/en/Main/GTFT
The decoding of jpeg images involves a lot of complex maths and
requires a processor with at least 8 kbytes of RAM. This sketch has
been tested with the Arduino Mega and Due boards.
*/
// include the necessary libraries
#include <SPI.h>
#include <SD.h>
#include <TFT.h> // Arduino LCD library
//#include <TFT_HX8357.h> // Hardware-specific library
//TFT_HX8357 TFTscreen = TFT_HX8357(); // Invoke custom library
#include <JPEGDecoder.h> // JPEG decoder library
// pin definition for the Mega
#define sd_cs 53
#define lcd_cs 49
#define dc 48
#define rst 47
#define TFT_WHITE 0xFFFF
#define TFT_BLACK 0x0000
#define TFT_RED 0xF800
// TFT driver and graphics library
TFT TFTscreen = TFT(lcd_cs, dc, rst);
// this function determines the minimum of two numbers
#define minimum(a,b) (((a) < (b)) ? (a) : (b))
//====================================================================================
// setup
//====================================================================================
void setup() {
// initialize the GLCD and show a message
// asking the user to open the serial line
TFTscreen.begin();
TFTscreen.fillScreen(TFT_WHITE); // Alternative: TFTscreen.background(255, 255, 255);
TFTscreen.setTextColor(TFT_RED); // Alternative: TFTscreen.stroke(0, 0, 255);
TFTscreen.println();
TFTscreen.println(F("Arduino TFT Jpeg Example"));
TFTscreen.setTextColor(TFT_BLACK); // Alternative: TFTscreen.stroke(0, 0, 0);
TFTscreen.println(F("Open serial monitor"));
TFTscreen.println(F("to run the sketch"));
delay(10000);
// initialize the serial port: it will be used to
// print some diagnostic info
Serial.begin(9600);
while (!Serial) {
// wait for serial port to connect. Needed for native USB port only
}
// clear the GLCD screen before starting
// TFTscreen.background(255, 255, 255);
TFTscreen.fillScreen(TFT_WHITE);
// try to access the SD card. If that fails (e.g.
// no card present), the setup process will stop.
Serial.print(F("Initializing SD card..."));
if (!SD.begin(sd_cs)) {
Serial.println(F("failed!"));
while (1); // SD initialisation failed so wait here
}
Serial.println(F("OK!"));
// initialize and clear the GLCD screen
TFTscreen.begin();
TFTscreen.fillScreen(TFT_WHITE); // Alternative: TFTscreen.background(255, 255, 255);
// now that the SD card can be accessed, check the
// image file exists.
if (SD.exists("arduino.jpg")) {
Serial.println("arduino.jpg found on SD card.");
} else {
Serial.println("arduino.jpg not found on SD card.");
while (1); // Image file missing so stay here
}
}
//====================================================================================
// Main loop
//====================================================================================
void loop() {
// open the image file
File jpgFile = SD.open( "arduino.jpg", FILE_READ);
// initialise the decoder to give access to image information
JpegDec.decodeSdFile(jpgFile);
// print information about the image to the serial port
jpegInfo();
// render the image onto the screen at coordinate 0,0
renderJPEG(0, 0);
// wait a little bit before clearing the screen to random color and drawing again
delay(4000);
// clear screen
TFTscreen.fillScreen(random(0xFFFF)); // Alternative: TFTscreen.background(255, 255, 255);
}
//====================================================================================
// Print information about the image
//====================================================================================
void jpegInfo() {
Serial.println(F("==============="));
Serial.println(F("JPEG image info"));
Serial.println(F("==============="));
Serial.print(F( "Width :")); Serial.println(JpegDec.width);
Serial.print(F( "Height :")); Serial.println(JpegDec.height);
Serial.print(F( "Components :")); Serial.println(JpegDec.comps);
Serial.print(F( "MCU / row :")); Serial.println(JpegDec.MCUSPerRow);
Serial.print(F( "MCU / col :")); Serial.println(JpegDec.MCUSPerCol);
Serial.print(F( "Scan type :")); Serial.println(JpegDec.scanType);
Serial.print(F( "MCU width :")); Serial.println(JpegDec.MCUWidth);
Serial.print(F( "MCU height :")); Serial.println(JpegDec.MCUHeight);
Serial.println(F("==============="));
}
//====================================================================================
// Decode and paint onto the TFT screen
//====================================================================================
void renderJPEG(int xpos, int ypos) {
// retrieve infomration about the image
uint16_t *pImg;
uint16_t mcu_w = JpegDec.MCUWidth;
uint16_t mcu_h = JpegDec.MCUHeight;
uint32_t max_x = JpegDec.width;
uint32_t max_y = JpegDec.height;
// Jpeg images are draw as a set of image block (tiles) called Minimum Coding Units (MCUs)
// Typically these MCUs are 16x16 pixel blocks
// Determine the width and height of the right and bottom edge image blocks
uint32_t min_w = minimum(mcu_w, max_x % mcu_w);
uint32_t min_h = minimum(mcu_h, max_y % mcu_h);
// save the current image block size
uint32_t win_w = mcu_w;
uint32_t win_h = mcu_h;
// record the current time so we can measure how long it takes to draw an image
uint32_t drawTime = millis();
// save the coordinate of the right and bottom edges to assist image cropping
// to the screen size
max_x += xpos;
max_y += ypos;
// read each MCU block until there are no more
while ( JpegDec.read()) {
// save a pointer to the image block
pImg = JpegDec.pImage;
// calculate where the image block should be drawn on the screen
int mcu_x = JpegDec.MCUx * mcu_w + xpos;
int mcu_y = JpegDec.MCUy * mcu_h + ypos;
// check if the image block size needs to be changed for the right and bottom edges
if (mcu_x + mcu_w <= max_x) win_w = mcu_w;
else win_w = min_w;
if (mcu_y + mcu_h <= max_y) win_h = mcu_h;
else win_h = min_h;
// calculate how many pixels must be drawn
uint32_t mcu_pixels = win_w * win_h;
// draw image block if it will fit on the screen
if ( ( mcu_x + win_w) <= TFTscreen.width() && ( mcu_y + win_h) <= TFTscreen.height()) {
// open a window onto the screen to paint the pixels into
//TFTscreen.setAddrWindow(mcu_x, mcu_y, mcu_x + win_w - 1, mcu_y + win_h - 1);
TFTscreen.setAddrWindow(mcu_x, mcu_y, mcu_x + win_w - 1, mcu_y + win_h - 1);
// push all the image block pixels to the screen
while (mcu_pixels--) TFTscreen.pushColor(*pImg++); // Send to TFT 16 bits at a time
}
// stop drawing blocks if the bottom of the screen has been reached
// the abort function will close the file
else if ( ( mcu_y + win_h) >= TFTscreen.height()) JpegDec.abort();
}
// calculate how long it took to draw the image
drawTime = millis() - drawTime; // Calculate the time it took
// print the results to the serial port
Serial.print ("Total render time was : "); Serial.print(drawTime); Serial.println(" ms");
Serial.println("=====================================");
}
| [
"bodmer@anola.net"
] | bodmer@anola.net |
31e049227e66d4acbca1505b28820256bf13c957 | 67cc7fd9528958d4b1c5d9c2662d1c83bec777ba | /drcsim_gazebo_ros_plugins/include/drcsim_gazebo_ros_plugins/AtlasPlugin.h | 2aec2159e74fb46fceead74d662d9b422c050404 | [] | no_license | usaotearoa/drcsim | 552e20b20e9f6d5e78321d8daa0a925d53bb0d83 | 3b18283995809686ecc25a8e5fb998a032772781 | refs/heads/master | 2022-01-08T11:44:25.356866 | 2019-04-15T19:56:33 | 2019-04-15T19:56:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 23,082 | h | /*
* Copyright 2012 Open Source Robotics Foundation
*
* 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 GAZEBO_ATLAS_PLUGIN_HH
#define GAZEBO_ATLAS_PLUGIN_HH
// filter coefficients
#define FIL_N_STEPS 2
#define FIL_MAX_FILT_COEFF 10
#include <string>
#include <vector>
#include <map>
#include <boost/thread/mutex.hpp>
#include <ros/ros.h>
#include <ros/callback_queue.h>
#include <ros/advertise_options.h>
#include <ros/subscribe_options.h>
#include <geometry_msgs/Twist.h>
#include <geometry_msgs/Pose.h>
#include <geometry_msgs/Vector3.h>
#include <geometry_msgs/WrenchStamped.h>
#include <std_msgs/String.h>
#include <atlas_msgs/SynchronizationStatistics.h>
#include <boost/thread.hpp>
#include <boost/thread/condition.hpp>
#include <gazebo/math/Vector3.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/physics/PhysicsTypes.hh>
#include <gazebo/transport/TransportTypes.hh>
#include <gazebo/common/Time.hh>
#include <gazebo/common/Plugin.hh>
#include <gazebo/common/Events.hh>
#include <gazebo/common/PID.hh>
#include <gazebo/sensors/SensorManager.hh>
#include <gazebo/sensors/SensorTypes.hh>
#include <gazebo/sensors/ContactSensor.hh>
#include <gazebo/sensors/ImuSensor.hh>
#include <gazebo/sensors/Sensor.hh>
// publish separate /atlas/imu topic, to be deprecated
#include <sensor_msgs/Imu.h>
// publish separate /atlas/force_torque_sensors topic, to be deprecated
#include <atlas_msgs/ForceTorqueSensors.h>
#include <atlas_msgs/AtlasFilters.h>
#include <atlas_msgs/ResetControls.h>
#include <atlas_msgs/SetJointDamping.h>
#include <atlas_msgs/GetJointDamping.h>
#include <atlas_msgs/ControllerStatistics.h>
// don't use these to control
#include <sensor_msgs/JointState.h>
#include <osrf_msgs/JointCommands.h>
// high speed control
#include <atlas_msgs/AtlasState.h>
#include <atlas_msgs/AtlasCommand.h>
// low speed control
#include <atlas_msgs/AtlasSimInterfaceCommand.h>
#include <atlas_msgs/AtlasSimInterfaceState.h>
#include <atlas_msgs/Test.h>
#include <gazebo_plugins/PubQueue.h>
// AtlasSimInterface: header
#if ATLAS_VERSION == 1
#include "AtlasSimInterface_1.1.1/AtlasSimInterface.h"
#elif ATLAS_VERSION == 3
#include "AtlasSimInterface_2.10.2/AtlasSimInterface.h"
#elif ATLAS_VERSION == 4 || ATLAS_VERSION == 5
#include "AtlasSimInterface_3.0.2/AtlasSimInterface.h"
#endif
namespace gazebo
{
class AtlasPlugin : public ModelPlugin
{
/// \brief Constructor
public: AtlasPlugin();
/// \brief Destructor
public: virtual ~AtlasPlugin();
/// \brief Load the controller
public: void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf);
/// \brief Callback when a pubControllerStatistics subscriber connects
private: void ControllerStatsConnect();
/// \brief Callback when a pubControllerStatistics subscriber disconnects
private: void ControllerStatsDisconnect();
/// \brief connected by lContactUpdateConnection, called when contact
/// sensor update
private: void OnLContactUpdate();
/// \brief connected by rContactUpdateConnection, called when contact
/// sensor update
private: void OnRContactUpdate();
/// \brief Update the controller
private: void UpdateStates();
/// \brief ROS callback queue thread
private: void RosQueueThread();
/// \brief get data from IMU for robot state
/// \param[in] _curTime current simulation time
private: void GetIMUState(const common::Time &_curTime);
/// \brief get data from force torque sensor
private: void GetForceTorqueSensorState(const common::Time &_curTime);
/// \brief ros service callback to reset joint control internal states
/// \param[in] _req Incoming ros service request
/// \param[in] _res Outgoing ros service response
private: bool ResetControls(atlas_msgs::ResetControls::Request &_req,
atlas_msgs::ResetControls::Response &_res);
/// \brief ros service callback to set joint damping
/// \param[in] _req Incoming ros service request
/// \param[in] _res Outgoing ros service response
private: bool SetJointDamping(atlas_msgs::SetJointDamping::Request &_req,
atlas_msgs::SetJointDamping::Response &_res);
/// \brief ros service callback to get joint damping for the model.
/// This value could differ from instantaneous cfm damping coefficient
/// due to pass through from kp_velocity.
/// \param[in] _req Incoming ros service request
/// \param[in] _res Outgoing ros service response
private: bool GetJointDamping(atlas_msgs::GetJointDamping::Request &_req,
atlas_msgs::GetJointDamping::Response &_res);
/// \brief: Load ROS related stuff
private: void LoadROS();
/// \brief Read in the atlas version.
private: bool GetAtlasVersion();
/// \brief Checks atlas model for joint names
/// used to find joint name since atlas_v3 remapped some joint names
/// \param[in] possible joint name
/// \param[in] possible joint name
/// \return _st1 or _st2 whichever is a valid joint, else empty str.
private: std::string FindJoint(std::string _st1, std::string _st2);
private: std::string FindJoint(std::string _st1, std::string _st2,
std::string _st3);
/// \brief pointer to gazebo world
private: physics::WorldPtr world;
/// \brief pointer to gazebo Atlas model
private: physics::ModelPtr model;
/// Pointer to the update event connections
private: event::ConnectionPtr updateConnection;
private: event::ConnectionPtr rContactUpdateConnection;
private: event::ConnectionPtr lContactUpdateConnection;
/// Throttle update rate
private: common::Time lastControllerStatisticsTime;
private: double statsUpdateRate;
// Contact sensors
private: sensors::ContactSensorPtr lFootContactSensor;
private: sensors::ContactSensorPtr rFootContactSensor;
private: ros::Publisher pubLFootContact;
private: PubQueue<geometry_msgs::WrenchStamped>::Ptr pubLFootContactQueue;
private: ros::Publisher pubRFootContact;
private: PubQueue<geometry_msgs::WrenchStamped>::Ptr pubRFootContactQueue;
// Force torque sensors at ankles
private: physics::JointPtr rAnkleJoint;
private: physics::JointPtr lAnkleJoint;
// Force torque sensors at the wrists
private: physics::JointPtr rWristJoint;
private: physics::JointPtr lWristJoint;
/// \brief A combined AtlasState, IMU and ForceTorqueSensors Message
/// for accessing all these states synchronously.
private: atlas_msgs::AtlasState atlasState;
private: void GetAndPublishRobotStates(const common::Time &_curTime);
// IMU sensor
private: sensors::ImuSensorPtr imuSensor;
private: std::string imuLinkName;
// publish separate /atlas/imu topic, to be deprecated
private: ros::Publisher pubImu;
private: PubQueue<sensor_msgs::Imu>::Ptr pubImuQueue;
/// \brief ros publisher for force torque sensors
private: ros::Publisher pubForceTorqueSensors;
private: PubQueue<atlas_msgs::ForceTorqueSensors>::Ptr
pubForceTorqueSensorsQueue;
/// \brief internal copy of sdf for the plugin
private: sdf::ElementPtr sdf;
// ROS internal stuff
private: ros::NodeHandle* rosNode;
private: ros::CallbackQueue rosQueue;
private: boost::thread callbackQueueThread;
/// \brief ros publisher for ros controller timing statistics
private: ros::Publisher pubControllerStatistics;
private: PubQueue<atlas_msgs::ControllerStatistics>::Ptr
pubControllerStatisticsQueue;
/// \brief ROS publisher for atlas joint states
private: ros::Publisher pubJointStates;
private: PubQueue<sensor_msgs::JointState>::Ptr pubJointStatesQueue;
/// \brief ROS publisher for atlas state, currently it contains
/// joint index enums
/// atlas_msgs::AtlasState
private: ros::Publisher pubAtlasState;
private: PubQueue<atlas_msgs::AtlasState>::Ptr pubAtlasStateQueue;
private: ros::Subscriber subAtlasCommand;
private: ros::Subscriber subJointCommands;
/// \brief ros topic callback to update Atlas Commands
/// \param[in] _msg Incoming ros message
private: void SetAtlasCommand(
const atlas_msgs::AtlasCommand::ConstPtr &_msg);
/// \brief ros topic callback to update Joint Commands slowly.
/// Control conmmands received through /atlas/joint_commands are
/// not expected to be able to close near 1kHz.
/// \param[in] _msg Incoming ros message
private: void SetJointCommands(
const osrf_msgs::JointCommands::ConstPtr &_msg);
////////////////////////////////////////////////////////////////////////////
// //
// Controller Synchronization Control //
// //
////////////////////////////////////////////////////////////////////////////
/// \brief Step simulation once.
private: void Tic(const std_msgs::String::ConstPtr &_msg);
/// \brief Special topic for advancing simulation by a ROS topic.
private: ros::Subscriber subTic;
/// \brief Condition variable for tic-ing simulation step.
private: boost::condition delayCondition;
/// \brief a non-moving window is used, every delayWindowSize-seconds
/// the user is allotted delayMaxPerWindow seconds of delay budget.
private: common::Time delayWindowSize;
/// \brief Marks the start of a non-moving delay window.
private: common::Time delayWindowStart;
/// \brief Within each window, simulation will wait at
/// most a total of delayMaxPerWindow seconds.
private: common::Time delayMaxPerWindow;
/// \brief Within each simulation step, simulation will wait at
/// most delayMaxPerStep seconds to receive information from controller.
private: common::Time delayMaxPerStep;
/// \brief Within each window, simulation will wait at
/// most a total of delayMaxPerWindow seconds.
private: common::Time delayInWindow;
/// \brief Publish controller synchronization delay information.
private: ros::Publisher pubDelayStatistics;
private: PubQueue<atlas_msgs::SynchronizationStatistics>::Ptr
pubDelayStatisticsQueue;
private: atlas_msgs::SynchronizationStatistics delayStatistics;
/// \brief enforce delay policy
private: void EnforceSynchronizationDelay(const common::Time &_curTime);
////////////////////////////////////////////////////////////////////////////
// //
// BDI Controller AtlasSimInterface Internals //
// //
////////////////////////////////////////////////////////////////////////////
// AtlasSimInterface:
private: AtlasControlOutput controlOutput;
private: AtlasRobotState atlasRobotState;
private: AtlasControlInput atlasControlInput;
#if ATLAS_VERSION == 4 || ATLAS_VERSION == 5
// private: AtlasSimInterfaceWrapper* atlasSimInterface;
private: AtlasSimInterface* atlasSimInterface;
#else
private: AtlasSimInterface* atlasSimInterface;
#endif
/// \brief AtlasSimInterface: ROS subscriber
private: ros::Subscriber subASICommand;
/// \brief AtlasSimInterface: ROS callback
private: void SetASICommand(
const atlas_msgs::AtlasSimInterfaceCommand::ConstPtr &_msg);
private: ros::Publisher pubASIState;
private: PubQueue<atlas_msgs::AtlasSimInterfaceState>::Ptr pubASIStateQueue;
private: boost::mutex asiMutex;
/// \brief internal copy of atlasSimInterfaceState
private: atlas_msgs::AtlasSimInterfaceState asiState;
/// \brief helper functions converting behavior string to int
private: std::map<std::string, int> behaviorMap;
/// \brief helper functions converting behavior int to string
private: std::string GetBehavior(int _behavior);
/// \brief helper function to copy states
private: void AtlasControlOutputToAtlasSimInterfaceState();
// AtlasSimInterface: Controls ros interface
private: ros::Subscriber subAtlasControlMode;
/// \brief AtlasSimInterface:
/// subscribe to a control_mode string message, current valid commands are:
/// walk, stand, safety, stand-prep, none
/// the command is passed to the AtlasSimInterface library.
/// \param[in] _mode Can be "walk", "stand", "safety", "stand-prep", "none".
private: void OnRobotMode(const std_msgs::String::ConstPtr &_mode);
/// \brief Process BDI contoller updates
/// \param[in] _curTime current simulation time
private: void UpdateAtlasSimInterface(const common::Time &_curTime);
/// \brief Update PID Joint Servo Controllers
/// \param[in] _dt time step size since last update
private: void UpdatePIDControl(double _dt);
////////////////////////////////////////////////////////////////////////////
// //
// Some Helper Functions //
// //
////////////////////////////////////////////////////////////////////////////
private: void LoadPIDGainsFromParameter();
private: void ZeroAtlasCommand();
private: void ZeroJointCommands();
/// \brief keep a list of hard coded Atlas joint names.
private: std::vector<std::string> jointNames;
/// \brief internal bufferred controller states
private: atlas_msgs::AtlasCommand atlasCommand;
private: osrf_msgs::JointCommands jointCommands;
private: sensor_msgs::JointState jointStates;
// JointController: pointer to a copy of the joint controller in gazebo
// \TODO: not yet functional
private: physics::JointControllerPtr jointController;
private: transport::NodePtr node;
private: transport::PublisherPtr jointCmdPub;
/// \brief Internal list of pointers to Joints
private: physics::Joint_V joints;
private: std::vector<double> effortLimit;
/// \brief internal class for keeping track of PID states
private: class ErrorTerms
{
/// error term contributions to final control output
double q_p;
double d_q_p_dt;
double k_i_q_i; // integral term weighted by k_i
double qd_p;
friend class AtlasPlugin;
};
private: std::vector<ErrorTerms> errorTerms;
private: boost::mutex mutex;
/// \brief ros service to reset controls internal states
private: ros::ServiceServer resetControlsService;
/// \brief: for keeping track of internal controller update rates.
private: common::Time lastControllerUpdateTime;
/// \brief ros service to change joint damping
private: ros::ServiceServer setJointDampingService;
/// \brief ros service to retrieve joint damping
private: ros::ServiceServer getJointDampingService;
////////////////////////////////////////////////////////////////////
// //
// filters //
// //
// To test, run //
// rosservice call /atlas/atlas_filters //
// '{ filter_velocity: true, filter_position: false }' //
// //
////////////////////////////////////////////////////////////////////
/// \brief mutex for filter setting
boost::mutex filterMutex;
/// \brief ROS service control for velocity and position filters
private: ros::ServiceServer atlasFiltersService;
/// \brief ros service callback to reset joint control internal states
/// \param[in] _req Incoming ros service request
/// \param[in] _res Outgoing ros service response
private: bool AtlasFilters(atlas_msgs::AtlasFilters::Request &_req,
atlas_msgs::AtlasFilters::Response &_res);
/// \brief turn on velocity filtering
private: bool filterVelocity;
/// \brief turn on position filtering
private: bool filterPosition;
/// \brief filter coefficients
private: double filCoefA[FIL_MAX_FILT_COEFF];
/// \brief filter coefficients
private: double filCoefB[FIL_MAX_FILT_COEFF];
/// \brief filter temporary variable
private: std::vector<std::vector<double> > unfilteredIn;
/// \brief filter temporary variable
private: std::vector<std::vector<double> > unfilteredOut;
/// \brief initialize filter
private: void InitFilter();
/// \brief do `filtering
private: void Filter(std::vector<float> &_aState,
std::vector<double> &_jState);
////////////////////////////////////////////////////////////////////
// //
// helper conversion functions //
// //
////////////////////////////////////////////////////////////////////
/// \brief Conversion functions
private: inline math::Pose ToPose(const geometry_msgs::Pose &_pose) const
{
return math::Pose(math::Vector3(_pose.position.x,
_pose.position.y,
_pose.position.z),
math::Quaternion(_pose.orientation.w,
_pose.orientation.x,
_pose.orientation.y,
_pose.orientation.z));
}
/// \brief Conversion helper functions
private: inline geometry_msgs::Pose ToPose(const math::Pose &_pose) const
{
geometry_msgs::Pose result;
result.position.x = _pose.pos.x;
result.position.y = _pose.pos.y;
result.position.z = _pose.pos.y;
result.orientation.w = _pose.rot.w;
result.orientation.x = _pose.rot.x;
result.orientation.y = _pose.rot.y;
result.orientation.z = _pose.rot.z;
return result;
}
/// \brief Conversion helper functions
private: inline geometry_msgs::Point ToPoint(const AtlasVec3f &_v) const
{
geometry_msgs::Point result;
result.x = _v.n[0];
result.y = _v.n[1];
result.z = _v.n[2];
return result;
}
/// \brief Conversion helper functions
private: inline geometry_msgs::Quaternion ToQ(const math::Quaternion &_q)
const
{
geometry_msgs::Quaternion result;
result.w = _q.w;
result.x = _q.x;
result.y = _q.y;
result.z = _q.z;
return result;
}
/// \brief Conversion helper functions
private: inline AtlasVec3f ToVec3(const geometry_msgs::Point &_point) const
{
return AtlasVec3f(_point.x,
_point.y,
_point.z);
}
/// \brief Conversion helper functions
private: inline AtlasVec3f ToVec3(const math::Vector3 &_vector3) const
{
return AtlasVec3f(_vector3.x,
_vector3.y,
_vector3.z);
}
/// \brief Conversion helper functions
private: inline math::Vector3 ToVec3(const AtlasVec3f &_vec3) const
{
return math::Vector3(_vec3.n[0],
_vec3.n[1],
_vec3.n[2]);
}
/// \brief Conversion helper functions
private: inline geometry_msgs::Vector3 ToGeomVec3(
const AtlasVec3f &_vec3) const
{
geometry_msgs::Vector3 result;
result.x = _vec3.n[0];
result.y = _vec3.n[1];
result.z = _vec3.n[2];
return result;
}
/// \brief Construct a quaternion from surface normal and yaw step date.
/// \param[in] _normal AtlasVec3f for surface noraml in Atlas odom frame.
/// \param[in] _yaw foot yaw angle in Atlas odom frame.
/// \return a quaternion describing pose of foot.
private: inline geometry_msgs::Quaternion OrientationFromNormalAndYaw(
const AtlasVec3f &_normal, double _yaw);
// controls message age measure
private: atlas_msgs::ControllerStatistics controllerStatistics;
private: std::vector<double> atlasCommandAgeBuffer;
private: std::vector<double> atlasCommandAgeDelta2Buffer;
private: unsigned int atlasCommandAgeBufferIndex;
private: double atlasCommandAgeBufferDuration;
private: double atlasCommandAgeMean;
private: double atlasCommandAgeVariance;
private: double atlasCommandAge;
private: void CalculateControllerStatistics(const common::Time &_curTime);
private: void PublishConstrollerStatistics(const common::Time &_curTime);
private: void SetExperimentalDampingPID(
const atlas_msgs::Test::ConstPtr &_msg);
private: ros::Subscriber subTest;
// ros publish multi queue, prevents publish() blocking
private: PubMultiQueue* pmq;
/// \brief Are cheats enabled?
private: bool cheatsEnabled;
/// \brief current joint cfm damping coefficient.
/// store this value so we don't have to call Joint::SetDamping()
/// on every update if coefficient if not changing.
private: std::vector<double> lastJointCFMDamping;
/// \brief current joint damping coefficient for the Model
private: std::vector<double> jointDampingModel;
/// \brief joint damping coefficient upper bound
private: std::vector<double> jointDampingMax;
/// \brief joint damping coefficient lower bounds
private: std::vector<double> jointDampingMin;
/// \brief AtlasSimInterface: startup steps for BDI controller
private: int startupStep;
private: enum StartupSteps {
FREEZE = 0,
USER = 1,
NOMINAL = 2,
};
/// \brief Keep track of number of controller stats connections
private: int controllerStatsConnectCount;
/// \brief Mutex to protect controllerStatsConnectCount.
private: boost::mutex statsConnectionMutex;
/// \brief Atlas version number
private: int atlasVersion;
/// \brief Atlas sub version number. This was added to handle two
/// different versions of Atlas v4.
/// atlasVersion == 4 && atlasSubVersion == 0: wry2 joints exist.
/// atlasVersion == 4 && atlasSubVersion == 1: wry2 joints don't exist.
private: int atlasSubVersion;
};
}
#endif
| [
"vinayak.jagtap04@gmail.com"
] | vinayak.jagtap04@gmail.com |
58b599400cbe219099fd235981ac7affa12d7020 | 492c598c872cff6f8d994dc43fd6e8b202521383 | /main/data_structures/heap.cpp | 6ce8e5559d574f1ba5f266f4f809fec02948fbea | [
"MIT"
] | permissive | angelbeshirov/algorithms | 477b714c920be307f152cbc96880894046e00087 | 278640573080f8e1dd173a3eb3a0df1a9741a300 | refs/heads/master | 2022-12-28T04:52:10.138105 | 2020-10-12T00:13:39 | 2020-10-12T00:13:39 | 260,995,243 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,932 | cpp | #include<bits/stdc++.h>
using namespace std;
int swap(int& x, int& y) {
int temp = x;
x = y;
y = temp;
}
class heap {
public:
heap(int initial_capacity = 6): size(0), capacity(initial_capacity) {
data = new int[capacity];
}
heap(const heap& hp) {
copy_heap(hp);
}
heap& operator=(const heap& hp) {
if(this != &hp) {
delete_heap();
copy_heap(hp);
}
}
~heap() {
delete_heap();
}
void insert(const int& x) {
if(size >= 0.75 * capacity) {
resize();
}
data[size++] = x;
int i = size - 1;
while(i != 0 && data[get_parent(i)] > data[i]) {
swap(data[get_parent(i)], data[i]);
i = get_parent(i);
}
}
int extract_min() {
if(size < 1) {
return INT_MIN;
}
if(size == 1) {
size--;
return data[0];
}
int temp = data[0];
data[0] = data[size - 1];
size--;
min_heapify(0);
return temp;
}
bool is_empty() const {
return size == 0;
}
void delete_at_index(int index) {
decrease_at_index(index, INT_MIN);
extract_min();
}
private:
int* data;
int size;
int capacity;
void copy_heap(const heap& hp) {
size = hp.size;
capacity = hp.capacity;
for(int i = 0; i < size; i++) {
data[i] = hp.data[i];
}
}
void delete_heap() {
delete[] data;
}
void resize() {
capacity *= 2;
int* new_data = new int[capacity];
for(int i = 0; i < size; i++) {
new_data[i] = data[i];
}
delete[] data;
data = new_data;
}
void min_heapify(int index) {
int left = get_left(index);
int right = get_right(index);
int min_index = index;
if(left < size && data[left] < data[index]) {
min_index = left;
}
if(right < size && data[right] < data[min_index]) {
min_index = right;
}
if(min_index != index) {
swap(data[min_index], data[index]);
min_heapify(min_index);
}
}
int get_parent(int index) {
return (index - 1) / 2;
}
int get_left(int index) {
return 2 * index + 1;
}
int get_right(int index) {
return 2 * index + 2;
}
void decrease_at_index(int index, int value) {
data[index] = value;
int i = index;
while(i != 0 && data[get_parent(i)] > data[index]) {
swap(data[i], data[get_parent(i)]);
i = get_parent(i);
}
}
};
int main() {
heap p;
p.insert(3);
p.insert(1);
p.insert(6);
p.insert(12);
p.insert(111);
while(!p.is_empty()) {
cout << p.extract_min() << " ";
}
}
| [
"angel.beshirov@abv.bg"
] | angel.beshirov@abv.bg |
b090f1d0f9c92a66e39b11e8b7ead24269370abf | 4c232d98e67bf3ca627ba7c5f545fc19ba517518 | /turbineSources/bamfield_flume_turbInflow/SOWFA/airfoilProperties/NACA_4415_Re0p140 | 1e612a287ac186f2fe3a7bcb31a11c2e481fb2e4 | [] | no_license | nnmrec/fastFlume | 581032ba9ab564367a06fb707a6215595db23662 | c32e86f08efb3d412736c04a3291d4dc75e49367 | refs/heads/master | 2021-06-01T10:20:03.586436 | 2020-01-30T22:26:01 | 2020-01-30T22:26:01 | 29,706,763 | 10 | 5 | null | 2015-12-21T23:18:41 | 2015-01-22T23:54:30 | C++ | UTF-8 | C++ | false | false | 4,493 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.0.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object airfoilProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// AeroDyn airfoil file Created with QBlade v0.963 64bit on 01.11.2016
// NACA 4415 airfoil, data comes from XFOIL with globally refined mesh, Ncrit = 4 for "dirty flume", Reynolds = [0.042 0.083 0.1 0.12 0.14 0.16 0.18 0.330]
// 0.140 Table ID parameter
// 0.0 Control setting
// 12.50 Stall angle (deg)
// -4.06 Angle of attack for zero Cn for linear Cn curve (deg)
// 6.30053 Cn slope for zero lift for linear Cn curve (1/rad)
// 1.1834 Cn at stall value for positive angle of attack for linear Cn curve
// -0.5893 Cn at stall value for negative angle of attack for linear Cn curve
// 1.00 Angle of attack for minimum CD (deg)
// 0.0133 Minimum CD value
airfoilData
(
// alpha C_l C_d
(-180.00 -0.1194 0.0060)
(-150.00 0.4913 0.4213)
(-120.00 0.3195 1.2358)
( -90.00 -0.0532 1.6376)
( -60.00 -0.3728 1.2343)
( -30.00 -0.4660 0.4154)
( -10.00 -0.6405 0.0312)
( -9.50 -0.5927 0.0286)
( -9.00 -0.5415 0.0268)
( -8.50 -0.4887 0.0251)
( -8.00 -0.4337 0.0235)
( -7.50 -0.3778 0.0221)
( -7.00 -0.3237 0.0210)
( -6.50 -0.2701 0.0199)
( -6.00 -0.2158 0.0190)
( -5.50 -0.1610 0.0182)
( -5.00 -0.1055 0.0174)
( -4.50 -0.0494 0.0168)
( -4.00 0.0065 0.0162)
( -3.50 0.0609 0.0158)
( -3.00 0.1162 0.0153)
( -2.50 0.1708 0.0150)
( -2.00 0.2249 0.0147)
( -1.50 0.2788 0.0145)
( -1.00 0.3320 0.0143)
( -0.50 0.3844 0.0140)
( 0.00 0.4342 0.0136)
( 0.50 0.4824 0.0134)
( 1.00 0.5363 0.0133)
( 1.50 0.6165 0.0135)
( 2.00 0.6761 0.0138)
( 2.50 0.7238 0.0141)
( 3.00 0.7723 0.0145)
( 3.50 0.8212 0.0149)
( 4.00 0.8701 0.0153)
( 4.50 0.9189 0.0158)
( 5.00 0.9672 0.0163)
( 5.50 1.0148 0.0168)
( 6.00 1.0615 0.0174)
( 6.50 1.1067 0.0180)
( 7.00 1.1501 0.0186)
( 7.50 1.1910 0.0192)
( 8.00 1.2285 0.0199)
( 8.50 1.2605 0.0208)
( 9.00 1.2882 0.0218)
( 9.50 1.3130 0.0230)
( 10.00 1.3346 0.0246)
( 10.50 1.3525 0.0265)
( 11.00 1.3662 0.0289)
( 11.50 1.3756 0.0318)
( 12.00 1.3813 0.0353)
( 12.50 1.3839 0.0394)
( 13.00 1.3838 0.0440)
( 13.50 1.3807 0.0494)
( 14.00 1.3779 0.0551)
( 14.50 1.3731 0.0613)
( 15.00 1.3669 0.0681)
( 15.50 1.3601 0.0751)
( 16.00 1.3530 0.0824)
( 16.50 1.3454 0.0900)
( 17.00 1.3373 0.0978)
( 17.50 1.3306 0.1056)
( 18.00 1.3257 0.1132)
( 18.50 1.3200 0.1211)
( 19.00 1.3169 0.1287)
( 19.50 1.3146 0.1362)
( 20.00 1.3125 0.1439)
( 20.50 1.3117 0.1513)
( 21.00 1.3109 0.1589)
( 21.50 1.3093 0.1669)
( 22.00 1.3087 0.1746)
( 22.50 1.3046 0.1834)
( 23.00 1.2987 0.1927)
( 23.50 1.2921 0.2024)
( 24.00 1.2496 0.2230)
( 25.00 1.1951 0.2704)
( 26.00 1.1931 0.2960)
( 27.00 1.1934 0.3222)
( 28.00 1.1957 0.3489)
( 29.00 1.1996 0.3762)
( 30.00 1.2050 0.4039)
( 60.00 1.2308 1.3045)
( 90.00 0.2378 1.7529)
( 120.00 -0.9912 1.3113)
( 150.00 -1.0732 0.4359)
( 180.00 -0.1194 0.0060)
); | [
"dsale@uw.edu"
] | dsale@uw.edu | |
93858ecdd66be4ab100fcc4e4a704fe9931807b9 | c3947f933c1e116e39955073115b25790c8d84c8 | /Polymorphisme/Individu.cpp | 1471b35ac5723594fbd487cbc8fdeb761dddef46 | [] | no_license | Jodge65/M3105 | aa52c532b3c7fc6710a6f7db257ac14b75ebca6b | 9e0b7e8e2ab1e5e09fcefe2711ba92720b3ba98c | refs/heads/master | 2021-01-10T16:39:17.825592 | 2016-03-10T23:21:05 | 2016-03-10T23:21:05 | 47,332,477 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,153 | cpp | #include "Individu.h"
#include "Outils.h"
#include <sstream>
Individu::Individu(): nom(""), prenom(""), anneeNaissance(0){}
Individu::Individu(std::string nom, std::string prenom, int anneeNaissance): nom(nom), prenom(prenom), anneeNaissance(anneeNaissance){}
std::string Individu::getNom() const
{
return nom;
}
std::string Individu::getPrenom() const
{
return prenom;
}
int Individu::getAnneeNaissance() const
{
return anneeNaissance;
}
void Individu::setNom(std::string nom)
{
this->nom = nom;
}
void Individu::setPrenom(std::string prenom)
{
this->prenom = prenom;
}
void Individu::setAnneeNaissance(int anneeNaissance)
{
this->anneeNaissance = anneeNaissance;
}
int Individu::getAge() const
{
Outils o;
return o.anneeActuelle() - anneeNaissance;
//return Outils::anneeActuelle() - anneeNaissance;
}
std::string Individu::toString() const
{
std::ostringstream dateNaissance;
dateNaissance << anneeNaissance;
std::ostringstream age;
age << getAge();
return "Individu:[nom=" + nom + ",prenom=" + prenom + ",anneeNaissance=" + dateNaissance.str() + ",age=" + age.str() + "]\n";
}
| [
"joey.sarie@gmail.com"
] | joey.sarie@gmail.com |
3fc1f4bbe7d65bd2daf67292237739d7c26fc718 | 325c631c0e9f44cbc22201dc0f51b590e024cb79 | /filip01/canvas.cpp | e6cd86d57c2d84a1a13404ab5208d9b6bbc5b753 | [] | no_license | Kahatko/test | f75a757ccf58968479767d83198f43b007690016 | 6f6e8ce02b75dfcefd12a7f958106df1a4dd4714 | refs/heads/master | 2021-01-01T05:23:58.205487 | 2016-05-05T10:11:21 | 2016-05-05T10:11:21 | 58,120,940 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 79 | cpp | #include "canvas.h"
Canvas::Canvas(QWidget *parent) :
QWidget(parent)
{
}
| [
"student@infpc-204.umcs.lublin.pl"
] | student@infpc-204.umcs.lublin.pl |
4c06310866042040dc989a5cc8c5047cd19ccf84 | 785df77400157c058a934069298568e47950e40b | /TnbCad2d/TnbLib/Cad2d/Entities/Edge/Ring/Pln_RingIO.cxx | 72e9be2c5db00d3fcd8a7a4d6135f891e9da36b9 | [] | no_license | amir5200fx/Tonb | cb108de09bf59c5c7e139435e0be008a888d99d5 | ed679923dc4b2e69b12ffe621fc5a6c8e3652465 | refs/heads/master | 2023-08-31T08:59:00.366903 | 2023-08-31T07:42:24 | 2023-08-31T07:42:24 | 230,028,961 | 9 | 3 | null | 2023-07-20T16:53:31 | 2019-12-25T02:29:32 | C++ | UTF-8 | C++ | false | false | 339 | cxx | #include <Pln_Ring.hxx>
#include <Pln_Vertex.hxx>
TNB_SAVE_IMPLEMENTATION(tnbLib::Pln_Ring)
{
ar & boost::serialization::base_object<Pln_Edge>(*this);
ar & theVtx_;
}
TNB_LOAD_IMPLEMENTATION(tnbLib::Pln_Ring)
{
ar & boost::serialization::base_object<Pln_Edge>(*this);
ar & theVtx_;
}
BOOST_CLASS_EXPORT_IMPLEMENT(tnbLib::Pln_Ring); | [
"aasoleimani86@gmail.com"
] | aasoleimani86@gmail.com |
8e6bc7fec3557b25f0bd55d3198cf8e466e15093 | 82751ca8cd84cf2b2fbac850e33c162e9ec77960 | /fish/mbed/LPCExpress/robotic_fish_6/ros_lib/tf/transform_broadcaster.h | 817eaba7db69406f37969a41541c34b9267b7c0e | [
"MIT"
] | permissive | arizonat/softroboticfish7 | c4b1b3a866d42c04f7785088010ba0d6a173dc79 | 777fd37ff817e131106392a85f65c700198b0197 | refs/heads/master | 2022-12-13T02:59:16.290695 | 2022-11-28T21:01:03 | 2022-11-28T21:01:03 | 255,442,610 | 2 | 0 | MIT | 2020-04-13T21:11:31 | 2020-04-13T21:11:30 | null | UTF-8 | C++ | false | false | 2,275 | h | /*
* Software License Agreement (BSD License)
*
* Copyright (c) 2011, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote prducts derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ROS_TRANSFORM_BROADCASTER_H_
#define ROS_TRANSFORM_BROADCASTER_H_
#include "tfMessage.h"
namespace tf
{
class TransformBroadcaster
{
public:
TransformBroadcaster() : publisher_("/tf", &internal_msg) {}
void init(ros::NodeHandle &nh)
{
nh.advertise(publisher_);
}
void sendTransform(geometry_msgs::TransformStamped &transform)
{
internal_msg.transforms_length = 1;
internal_msg.transforms = &transform;
publisher_.publish(&internal_msg);
}
private:
tf::tfMessage internal_msg;
ros::Publisher publisher_;
};
}
#endif
| [
"cyndiac@mit.edu"
] | cyndiac@mit.edu |
603e16c005b26b0f948b2ebc093915e49216dcd6 | c3fbdc39d21b75f8f1c72ba355fc45f91891c9eb | /annotation/rectn.cpp | 17573b210403bbf24eacca9458c6f8eb8bcbc8c1 | [] | no_license | minhinc/MISC | 86eb5ee23fbbd31d330465c48b3e6244216fde1f | d255794b44f563653402dc15ea3cddb531111d06 | refs/heads/master | 2023-08-16T13:05:49.248648 | 2023-08-09T10:08:40 | 2023-08-09T10:08:40 | 79,083,913 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 890 | cpp | #include <QPainter>
#include <QGraphicsSceneMouseEvent>
#include <QPen>
#include "rectn.h"
#include "debug.h"
rectn::rectn(QGraphicsRectItem *p):QGraphicsRectItem(p){
trace("rectn::rectn")
//setFlags(ItemIsMovable|ItemIsSelectable);
colori=Qt::black;
widthi=15;
trace("~rectn::rectn")
}
rectn::~rectn(){
trace("rectn::~rectn")
trace("~rectn::~rectn")
}
//void rectn::mousePressEvent(QGraphicsSceneMouseEvent *e){
//trace("><rectn::mousePressEven,pos"<<e->pos())
//QGraphicsRectItem::mousePressEvent(e);
//}
//void rectn::mouseMoveEvent(QGraphicsSceneMouseEvent *e){
//trace("><rectn::mouseMoveEvent,pos"<<e->pos())
//QGraphicsRectItem::mouseMoveEvent(e);
//}
void rectn::paint(QPainter *painter,QStyleOptionGraphicsItem *option,QWidget *widget){
trace("><rectn::paint")
painter->setPen(QPen(Qt::red,25));
painter->drawRect(10,10,100,100);
QGraphicsRectItem::paint(painter,option,widget);
}
| [
"sales@minhinc.com"
] | sales@minhinc.com |
d97275d82234720764784eb876ff94055dd81707 | b812db5d69f1ddc38596149460a0cbdf5248e0a7 | /Codechef/15 DEC17/CPLAY.cpp | 5a1f5da68ef9abf1d6652083f0b2e3dab32d6b95 | [] | no_license | mnaveenkumar2009/Competitive-Programming | f15536906f8a6015654baf73fec3b94f334c998a | 9bd02ae15d132468e97bc86a95e924910fe5692a | refs/heads/master | 2021-06-06T12:22:59.879873 | 2020-07-12T11:41:44 | 2020-07-12T11:41:44 | 99,432,530 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,263 | cpp | #include <bits/stdc++.h>
using namespace std;
#define f(i,n) for(i=0;i<n;i++)
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define slld(n) scanf("%lld",&n)
#define mod 1000000007
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define gc getchar_unlocked
#define pc putchar_unlocked
inline unsigned long long uscan()
{
unsigned long long n=0,c=gc();
while(c<'0'||c>'9')
c=gc();
while(c<='9'&&c>='0'){
n=n*10+c-'0';
c=gc();}
return n;
}
inline long int lscan()
{
long int n=0,c=gc();
while(c<'0'||c>'9')
c=gc();
while(c<='9'&&c>='0'){
n=n*10+c-'0';
c=gc();}
return n;
}
inline int sscan()
{register int n=0,c=gc();
while(c<'0'||c>'9')
c=gc();
while(c<='9'&&c>='0')
{
n=n*10+c-'0';
c=gc();
}
return n;
}
int main() {
char s[20];
int i;
string A="TEAM-A ",B="TEAM-B ",T="TIE\n";
while(scanf("%s",s)==1){
int ca=0,cb=0,m=0,f=0,r1;
f(i,20){
if(i%2==0){
if(s[i]-'0'){++ca;}
if(!f){
r1=i/2+1;
if(cb+5-r1+1<ca){f=3;m=i;break;}
else if(ca+5-r1<cb){f=4;m=i;break;}
}
}
else if(i%2==1){
if(s[i]=='1'){++cb;}
if(f==0){
r1=i/2+1;
if(cb+5-r1<ca){f=3;m=i;break;}
else if(ca+5-r1<cb){f=4;m=i;break;}
}
else if(f==1){
if(ca>cb){m=i;f=3;break;}
if(cb>ca){m=i;f=4;break;}
}
}
if(i==9){f=1;}
}
if(f==3){
cout<<A<<m+1<<endl;
}
else if(f==4){
cout<<B<<m+1<<endl;
}
else{
cout<<T;
}
}
return 0;
} | [
"mnaveenkumar2009@gmail.com"
] | mnaveenkumar2009@gmail.com |
bf1a343acd76182feb5814af82a567e127963320 | 982374383085fb5155bdcf559b030a8e31bc7192 | /Plugins/kbengine_ue4_plugins/Source/KBEnginePlugins/Engine/ScriptModule.cpp | 3293f14af742c7a362ce006881496deabf533a16 | [] | no_license | sinlandem/kbengine_ue4_demo | 3d6b4dc0f4917e77228bc8cb21c6078f3b6df7c4 | 1b0f4de2e624660caac0ee10607f1eb82538caa8 | refs/heads/master | 2020-06-11T04:27:34.961947 | 2019-06-24T05:38:46 | 2019-06-24T05:38:46 | 193,849,201 | 1 | 0 | null | 2019-06-26T07:08:24 | 2019-06-26T07:08:24 | null | UTF-8 | C++ | false | false | 600 | cpp |
#include "ScriptModule.h"
#include "Method.h"
#include "Property.h"
#include "Entity.h"
#include "EntityDef.h"
#include "KBDebug.h"
namespace KBEngine
{
ScriptModule::ScriptModule(const FString& moduleName, int type):
name(moduleName),
usePropertyDescrAlias(false),
useMethodDescrAlias(false),
propertys(),
idpropertys(),
methods(),
base_methods(),
cell_methods(),
idmethods(),
idbase_methods(),
idcell_methods(),
utype(type)
{
}
ScriptModule::~ScriptModule()
{
}
Entity* ScriptModule::createEntity()
{
return EntityDef::createEntity(utype);
}
} | [
"380000937@qq.com"
] | 380000937@qq.com |
42c5a6f71ce2de1b0df956c556f86330073bcdb8 | 44a03bede7d20ed11e85b9d11dbdd2e6177ee565 | /sdk/3d_sdk/maya/ver-6.0/include/maya/MFnParticleSystem.h | cff9b3b01169c1ff79849ff53eccb707f03b4b66 | [] | no_license | RainbowZerg/X-Ray_Engine_1.5.1.0 | 4bdcd8b38208cb6b9b13d93aac356f685fdaa766 | 95d0f1cb8a3f1e072e5676911d28fbd624195afe | refs/heads/master | 2021-01-23T01:08:19.799158 | 2018-06-01T01:52:29 | 2018-06-01T01:52:29 | 85,878,409 | 8 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,736 | h | #ifndef _MFnParticleSystem
#define _MFnParticleSystem
//
//-
// ==========================================================================
// Copyright (C) Alias Systems Corp., and/or its licensors ("Alias").
// All rights reserved. These coded instructions, statements, computer
// programs, and/or related material (collectively, the "Material")
// contain unpublished information proprietary to Alias, which is
// protected by Canadian and US federal copyright law and by international
// treaties. This Material may not be disclosed to third parties, or be copied
// or duplicated, in whole or in part, without the prior written consent of
// Alias. ALIAS HEREBY DISCLAIMS ALL WARRANTIES RELATING TO THE MATERIAL,
// INCLUDING, WITHOUT LIMITATION, ANY AND ALL EXPRESS OR IMPLIED WARRANTIES OF
// NON-INFRINGEMENT, MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// IN NO EVENT SHALL ALIAS BE LIABLE FOR ANY DAMAGES WHATSOEVER, WHETHER DIRECT,
// INDIRECT, SPECIAL, OR PUNITIVE, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, OR IN EQUITY, ARISING OUT OF OR RELATED TO THE
// ACCESS TO, USE OF, OR RELIANCE UPON THE MATERIAL.
// ==========================================================================
//+
//
// CLASS: MFnParticleSystem
//
// *****************************************************************************
//
// CLASS DESCRIPTION (MFnParticleSystem)
//
// Particle object access class. Intended to be used by the software
// renderer for accessing relevant data from the particle object. The
// data stored in the particle object is a function of the particle
// render type.
//
// Safe to call these methods with any render type:
//
// Method Name Description
// ================================================================
// isValid() data is valid (predicate)
// renderType() object render type
// count() particle count at current frame
// ----------------------------------------------------------------
//
//
// Use this table to determine which methods to call based on the
// render type of the particle object.
//
// Render Type Valid Methods Description
// ================================================================
// kCloud position() particle position
// radius() particle radius
// surfaceShading() object surface shading value
// betterIllum() invoke thick cloud sampling
// threshold() object threshold
// disableCloudAxis() for internal use; do not call
// ----------------------------------------------------------------
// kTube position0() particle start position
// position1() particle end position
// radius0() particle start radius
// radius1() particle end radius
// tailSize() length scale factor
// ----------------------------------------------------------------
// kBlobby position() particle position
// radius() particle radius
// threshold() object threshold
// ----------------------------------------------------------------
// kHardware position() particle position
// radius() particle radius
// ----------------------------------------------------------------
//
//
// *****************************************************************************
#if defined __cplusplus
// *****************************************************************************
// INCLUDED HEADER FILES
#include <maya/MStatus.h>
#include <maya/MTypes.h>
#include <maya/MFnDagNode.h>
// *****************************************************************************
// DECLARATIONS
class MTime;
class MFnDagNode;
class MDoubleArray;
class MVectorArray;
class MIntArray;
// *****************************************************************************
// CLASS DECLARATION (MFnParticleSystem)
///
/**
Class for obtaining information about a particle system. (OpenMayaFX)
*/
#ifdef _WIN32
#pragma warning(disable: 4522)
#endif // _WIN32
class OPENMAYAFX_EXPORT MFnParticleSystem : public MFnDagNode
{
declareDagMFn(MFnParticleSystem, MFnDagNode);
public:
///
enum RenderType
{
///
kCloud,
///
kTube,
///
kBlobby,
///
kHardware
};
///
void evaluateDynamics( MTime &to, bool runupFromStart );
///
bool isValid () const;
///
MString particleName () const;
///
unsigned int count () const;
///
RenderType renderType () const;
///
void particleIds ( MIntArray& ) const;
///
void position ( MVectorArray& ) const;
///
void position0 ( MVectorArray& ) const;
///
void position1 ( MVectorArray& ) const;
///
void radius ( MDoubleArray& ) const;
///
void radius0 ( MDoubleArray& ) const;
///
void radius1 ( MDoubleArray& ) const;
///
double surfaceShading () const;
///
double threshold () const;
///
bool betterIllum () const;
///
bool disableCloudAxis() const;
///
double tailSize () const;
///
void age ( MDoubleArray& ) const;
///
void lifespan ( MDoubleArray& ) const;
///
void rgb ( MVectorArray& ) const;
///
void opacity ( MDoubleArray& ) const;
///
void emission ( MVectorArray& ) const;
///
bool hasLifespan () const;
///
bool hasRgb () const;
///
bool hasOpacity () const;
///
bool hasEmission () const;
///
bool primaryVisibility () const;
///
bool visibleInReflections() const;
///
bool visibleInRefractions() const;
///
bool castsShadows () const;
///
bool receiveShadows () const;
protected:
virtual bool objectChanged( MFn::Type, MStatus * );
};
#ifdef _WIN32
#pragma warning(default: 4522)
#endif // _WIN32
// *****************************************************************************
#endif /* __cplusplus */
#endif /* _MFnParticleSystem */
| [
"zloyzergo@gmail.com"
] | zloyzergo@gmail.com |
cf0c30aed1e59290a1cd25d5d2f657ccf23869bb | 67793c6511dfc80e8e43a87697600491f06783ed | /string_substitutions.cpp | 7d624d8c08754fb125e769b21b548603c5e0b104 | [] | no_license | jethington/Patterns_Overlap | 935546b7ace211b2cd122c86d8ce7a77a7648a6c | dcf4a5f5355a588fe7cc0237b9f8463241f6651d | refs/heads/master | 2021-01-11T14:02:24.746441 | 2020-05-08T22:42:57 | 2020-05-08T22:42:57 | 94,939,775 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,184 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <tuple>
#include <cassert>
struct Split {
// TODO: can optimize this if needed
// instead of not_done, original + index/pointer?
std::string done;
std::string not_done;
Split(std::string start): not_done(start) {
}
bool is_empty(void) {
return (not_done.length() == 0);
}
bool is_done(void) {
bool result = true;
for (const char& c : not_done) {
if (c != '*') {
result = false;
break;
}
}
return result;
}
};
struct Solution {
Split split1;
Split split2;
// TODO: shared std::string done (should match for both anyways)
// Split should instead store original string + index to track completed (and rename it)
Solution(): split1(std::string("")), split2(std::string("")) { // TODO: default constructor not needed if using boost::Optional?
//split1 = Split(std::string("")); // should never be used...
}
Solution(Split one, Split two): split1(one), split2(two) {
}
Solution(const Solution& other) : split1(other.split1), split2(other.split2) {
}
};
//void printPartial(const Solution& s);
std::tuple<bool, Solution> solve(std::string input1, std::string input2);
void run_tests(void);
Solution remove_stars(Solution s);
std::tuple<bool, Solution> solve(std::string input1, std::string input2) {
std::vector<Solution> solution_stack;
solution_stack.push_back(Solution(Split(input1), Split(input2)));
while (true) {
if (solution_stack.size() == 0) {
break;
}
// TODO: there must be a better way to get the popped item? use std::move maybe?
Solution possible_solution = solution_stack[solution_stack.size() - 1];
solution_stack.pop_back();
//printPartial(possible_solution);
char c1 = possible_solution.split1.not_done[0];
char c2 = possible_solution.split2.not_done[0];
if ((c1 == '*') && (c2 == '*')) {
// TODO: what happens if I remove a * from one, push solution, remove a * from the other, push solution?
// appears to work, but what if double *'s? think it's still ok?
if ((possible_solution.split1.not_done.length() == 1) && (possible_solution.split2.not_done.length() == 1)) {
// *'s were at the end, found a solution
possible_solution = remove_stars(possible_solution);
return std::make_tuple(true, possible_solution);
}
Solution s1(possible_solution);
Solution s2(possible_solution);
s1.split1.not_done.erase(0, 1); // remove a * from one of these and keep going - this pushes it into two of the three cases below
s2.split2.not_done.erase(0, 1);
// TODO: edge case, what if this was the last character in one or both of them?
solution_stack.push_back(s1);
solution_stack.push_back(s2);
}
else if (c1 == '*') {
// * from s1 can match up to 4 chars from s2
int i = 0; // index does not necessarily == count because *'s could add 0 length
// for example, * match ab**ab is possible
while (possible_solution.split2.not_done.length() >= i) {
// TODO: repeating this work in a loop is inefficient
Solution s(possible_solution);
std::string match = s.split2.not_done.substr(0, i);
s.split1.not_done.erase(0, 1);
s.split1.done.append(match);
s.split2.done.append(match); // first iteration will be 0 - that is intended because * could match nothing at all
s.split2.not_done.erase(0, i);
// TODO: this is copy/pasted
// TODO: edge case: one length is 0, other not_done is all ***
// need a .done() function, checks for not_done length == 0 or all ***
if (s.split1.is_done() && s.split2.is_done()) {
// found a solution
s = remove_stars(s);
return std::make_tuple(true, s);
}
else if (s.split1.is_empty() != s.split2.is_empty()) {
// one is out of chars, other has chars left (that are not *'s)
// this solution is no good, so discard it
}
else {
// could still be a solution, keep going with it
solution_stack.push_back(s);
}
int star_count = 0;
for (const char& c : match) {
if (c == '*') {
star_count++;
}
}
int matched_chars = match.length() - star_count;
if (matched_chars >= 4) {
break;
}
i++; // always increase i - to move onto the next char
}
}
else if (c2 == '*') {
// * from s2 can match up to 4 chars from s1
int i = 0; // index does not necessarily == count because *'s could add 0 length
// for example, * match ab**ab is possible
while (possible_solution.split1.not_done.length() >= i) {
// TODO: repeating this work in a loop is inefficient
Solution s(possible_solution);
s.split2.not_done.erase(0, 1);
std::string match = s.split1.not_done.substr(0, i); // first iteration will be 0 - that is intended because * could match nothing at all
s.split2.done.append(match);
s.split1.done.append(match);
s.split1.not_done.erase(0, i);
if (s.split1.is_done() && s.split2.is_done()) {
// found a solution
s = remove_stars(s);
return std::make_tuple(true, s);
}
else if (s.split1.is_empty() != s.split2.is_empty()) {
// one is out of chars, other has chars left (that are not *'s)
// this solution is no good, so discard it
}
else {
// could still be a solution, keep going with it
solution_stack.push_back(s);
}
int star_count = 0;
for (const char& c : match) {
if (c == '*') {
star_count++;
}
}
int matched_chars = match.length() - star_count;
if (matched_chars >= 4) {
break;
}
i++; // always increase i - to move onto the next char
}
}
else {
// regular characters, compare them
if (c1 == c2) {
// they match, so advance one char
possible_solution.split1.done.push_back(c1);
possible_solution.split2.done.push_back(c2);
possible_solution.split1.not_done.erase(0, 1);
possible_solution.split2.not_done.erase(0, 1);
if (possible_solution.split1.is_done() && possible_solution.split2.is_done()) {
// found a solution
possible_solution = remove_stars(possible_solution);
return std::make_tuple(true, possible_solution);
}
else if (possible_solution.split1.is_empty() != possible_solution.split2.is_empty()) {
// one is out of chars, other has chars left (that are not *'s)
// this solution is no good, so discard it
}
else {
// could still be a solution, keep going with it
solution_stack.push_back(possible_solution);
}
}
else {
// this branch didn't work, so move on
// no action required - just don't put it back on the stack
}
}
}
// if this is reached, all possible solutions were exhausted
return std::make_tuple(false, Solution());
}
Solution remove_stars(Solution s) {
// used to clean up a solution before printing
// for example, with the current code: when a*b matches *, the 'done' string == a*b, not ab
std::string filtered;
for (const char& c: s.split1.done) {
if (c != '*') {
filtered.push_back(c);
}
}
s.split1.done = filtered;
s.split2.done = filtered;
return s;
}
int main(void) {
run_tests();
// finds solution - check
std::string input1("dnKeeuCCyHOnobnDYMGoXDdNWhTsaoedbPifJ*ki*wWfXjIUwqItTmGqtAItoNWpDeUnNCWgZsKWbuQxKaqemXuFXDylQubuZWhMyDsXvDSwYjui*LviGAEkyQbtR*cELfxiAbbYyJRGtcsoJZppINgJGYeZKGeWLbenBEKaoCgheYwOxLeFZJPGhTFRAjNn*");
std::string input2("d*eeuCCyHOnobnDYMGoXDdNWhTsaoedbP*ijrwWfXjIUwqItTmGqtAItoNWpDeUnNCWgZs*WbuQxKaqemXuFXDylQubuZWhMyDsXvDSwYjuijkLviGAEkyQbtRUsncELfxiAbbYyJRG*soJZppINgJGYeZKGeWLbenBEKaoCghe*YwOxLeFZJPGhTFRAjNn");
// finds solution - check
//std::string input1("THAkZYrkUWgcTpZ*SsNQKsEnvdUveZxssEtCEQuoMqToJjMdCatMs*v*GyMlROpiIDUZyJjhwmjxFWpEwDgRLlLsJYebMSkwxEUvoDcLPLIwHY*GvoRhgcfkdsenObSjWGNYRDJAzRzavAGRoZZ*fDXIRlJkufqHDjLMJKEjLAkRRyQqTrUaWRIndSX");
//std::string input2("*THAkZYrkUWgcTpZSsNQKsEnvdUveZxssEtCEQuoMqToJjMdCatMsYa*nBvIFuGyMlROpiIDUZyJjh*FWpEwDgRLlLsJYebMSkw*oDcLPLIwHYbeBGvoRhgcfkdsenObSjWGNYRDJAzRzavAGRoZZvbEfDXIRlJkufqHDjLMJKEjLAkRRyQqTrU*aWRIndSX");
// finds solution - check
//std::string input1("jEAmXdDUtthXNLbIZFeWdiQPGEvyCEeLI**EyficABUH*YiSZRREvniDexKJSjLXMYfsw*YlbTSZBlYSecorJsWidfALQYzOdrKNrJZRdrQEDoyhPMYAfTiHZIuqGtEkKqYBzxtCOJhRYfZNSYNxRWFrfahlSLvdBTebrXDgGlZEqxRIvGhN*mfhLLSExNHaHLAZI");
//std::string input2("jEAmXdDUtthXNLbIZFeWdiQPGEvyCEeL**BUHYiSZRREvniDexKJSjLXMYfswlaYlbTSZBlYSecorJsWidfALQYzOdrKNrJZ*EDoyhPMYAfTiHZIuqGtEkKqYBzxtC*YfZNSYNxRWFrfahlSLvdBT*ebrXDgGlZEqxRIvGhNcmfhLLSExNHaHLAZI");
auto result = solve(input1, input2);
bool solution_found;
Solution s;
std::tie(solution_found, s) = result;
if (solution_found) {
std::cout << "Solution found: " << std::endl;
std::cout << s.split1.done << std::endl;
std::cout << s.split2.done << std::endl;
}
else {
std::cout << "No solution found" << std::endl;
}
return 0;
}
void run_tests(void) {
std::tuple<bool, Solution> result;
bool solution_found;
Solution s;
//sample input 1: solution "Shakespeare"
std::string s1("Shakes*e");
std::string s2("S*speare");
result = solve(s1, s2);
std::tie(solution_found, s) = result;
assert(solution_found == true);
assert(s.split1.done == "Shakespeare");
// sample input 2: no solution
std::string s3("a*baa**ba**aa");
std::string s4("*ca*b**a*baac");
result = solve(s3, s4);
std::tie(solution_found, s) = result;
assert(solution_found == false);
// START OF CHALLENGE INPUTS
// no solution - check
std::string s5("bb*aaaaa*ba**");
std::string s6("*baabb*b*aaaa");
result = solve(s5, s6);
std::tie(solution_found, s) = result;
assert(solution_found == false);
// my own tests
std::string s7("a*b");
std::string s8("*");
result = solve(s7, s8);
std::tie(solution_found, s) = result;
assert(solution_found == true);
assert(s.split1.done == "ab");
std::string s9("a*b");
std::string s10("c*b");
result = solve(s9, s10);
std::tie(solution_found, s) = result;
assert(solution_found == false);
std::string s11("a*b");
std::string s12("a*c");
result = solve(s11, s12);
std::tie(solution_found, s) = result;
assert(solution_found == false);
std::string s13("*");
std::string s14("abcd");
result = solve(s13, s14);
std::tie(solution_found, s) = result;
assert(solution_found == true);
assert(s.split1.done == "abcd");
std::string s15("*ab");
std::string s16("cd*");
result = solve(s15, s16);
std::tie(solution_found, s) = result;
assert(solution_found == true);
assert(s.split1.done == "cdab");
std::string s17("abcdefgh");
std::string s18("**");
result = solve(s17, s18);
std::tie(solution_found, s) = result;
assert(solution_found == true);
assert(s.split1.done == "abcdefgh");
std::string s19("abc**");
std::string s20("abc*");
result = solve(s19, s20);
std::tie(solution_found, s) = result;
assert(solution_found == true);
assert(s.split1.done == "abc");
std::string s21("ab*cd**");
std::string s22("*def");
result = solve(s21, s22);
std::tie(solution_found, s) = result;
assert(solution_found == true);
assert(s.split1.done == "abcddef"); // note: finds this before "abcdef" - is that expected or due to a bug?
std::string s23("a*");
std::string s24("a");
result = solve(s23, s24);
std::tie(solution_found, s) = result;
assert(solution_found == true);
}
| [
"jethington4@gmail.com"
] | jethington4@gmail.com |
229dcbd7ebc8ea516537275181ad837cf93d5f68 | fb25d1b4294b3a95abadc9b50897f1aee102c097 | /strings/strings/source.cpp | 4a1d5a9a6d2240691b14bedf1c88f8e1a70edb97 | [] | no_license | 25cent9/SouthTech | 93c6fe06216328828b69075607d8414097417ebc | ef39e960959d3bc41f300c11b0f55ea4afc84367 | refs/heads/master | 2021-01-11T22:32:10.945137 | 2017-01-15T03:08:57 | 2017-01-15T03:08:57 | 78,985,967 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 607 | cpp | /*
Innoceny Niyibzi
9/29/15
Find and explain examples of substring and string find
*/
#include <iostream>
#include <string>
using namespace std;
int main(){
string hello;
string sub = " ";
int pos = 0;
hello = "Hello World";
sub = hello.substr(0, 5); //Finds characters from the 0 to 5 positions and sets sub equal to that
cout<<hello<<endl<<sub<<endl;
pos = hello.find("World"); //Find the starting position of world and set pos equal to that
cout<<pos<<endl; //Starting position of the world "World"
cout<<hello.length()<<endl;
cout<<hello.size()<<endl;
system("pause");
return 0;
} | [
"25cent9@gmail.com"
] | 25cent9@gmail.com |
f7528f7e8347c0aa1219c950da41c60b91db8018 | 5ee0eb940cfad30f7a3b41762eb4abd9cd052f38 | /Case_save/case7/500/phi | 41648b086ee495defe856f17a9970773e6cb0526 | [] | no_license | mamitsu2/aircond5_play4 | 052d2ff593661912b53379e74af1f7cee20bf24d | c5800df67e4eba5415c0e877bdeff06154d51ba6 | refs/heads/master | 2020-05-25T02:11:13.406899 | 2019-05-20T04:56:10 | 2019-05-20T04:56:10 | 187,570,146 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,630 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class surfaceScalarField;
location "500";
object phi;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 0 -1 0 0 0 0];
internalField nonuniform List<scalar>
852
(
-0.00277593
0.00284458
-0.00328376
0.000507882
-0.00386527
0.000581549
-0.00442
0.00055477
-0.0049042
0.000484241
-0.00529818
0.000394021
-0.00558426
0.000286122
-0.00574167
0.00015746
-0.00574577
4.13375e-06
-0.00556559
-0.000180138
-0.00517361
-0.00039193
-0.00455198
-0.000621589
-0.0036584
-0.000893546
-0.00229744
-0.00136092
-0.00229431
0.000981008
-0.000977307
0.00148138
-0.000500324
0.0017039
-0.00022247
0.00183834
-0.000134389
0.00193989
-0.000101492
0.00200124
-6.13062e-05
0.0020014
-9.90881e-08
0.00196766
3.37859e-05
0.00192493
4.27886e-05
0.00188101
4.39679e-05
0.00183685
4.42098e-05
0.00179171
4.51962e-05
0.00174234
4.94279e-05
0.00167947
6.29213e-05
0.0015804
9.91195e-05
0.00140825
0.000172213
0.00115687
0.000251435
0.000883052
0.000273872
0.00088958
-0.00201475
0.0050413
-0.00276918
0.00126236
-0.00347634
0.00128875
-0.00406308
0.00114155
-0.00455997
0.000981168
-0.00496609
0.000800183
-0.00526954
0.000589616
-0.00545257
0.000340538
-0.0054941
4.57025e-05
-0.00537754
-0.000296652
-0.00508965
-0.000679776
-0.00461966
-0.00109155
-0.00396772
-0.00154544
-0.00327299
-0.00205561
-0.00319909
-0.00236817
-0.00124557
-0.00195353
-0.00124558
0.000699194
-0.00166671
0.000954582
-0.000755659
0.00112251
-0.000390346
0.00127159
-0.000283421
0.00140332
-0.000233161
0.00150822
-0.00016616
0.0015324
-2.42181e-05
0.00153944
2.67911e-05
0.0015451
3.71884e-05
0.00155013
3.899e-05
0.00155429
4.0103e-05
0.00155759
4.19535e-05
0.0015594
4.76665e-05
0.0015564
6.59809e-05
0.00151951
0.000136065
0.00134779
0.000343985
0.00105255
0.000546734
0.000707312
0.000619169
0.00161328
-0.00147635
0.00679082
-0.00228846
0.0020745
-0.00296635
0.00196669
-0.00349941
0.00167466
-0.00395686
0.00143867
-0.00434054
0.0011839
-0.00463873
0.000887846
-0.00483386
0.000535722
-0.00490594
0.00011782
-0.00483657
-0.000365976
-0.00461736
-0.000898947
-0.00425868
-0.00145018
-0.00381012
-0.00199396
-0.0033862
-0.00247948
-0.0029849
-0.00276944
-0.0020352
-0.00290318
-0.00328074
-6.32235e-05
-0.00158871
0.00022912
-0.00104795
0.000528178
-0.00068935
0.000754911
-0.000510101
0.000939173
-0.000417369
0.00113326
-0.00036019
0.00110925
0.00113625
0.00117364
0.00121284
0.00125315
0.00129532
0.00134319
0.00140939
0.00154566
0.00127899
0.000610717
0.000951031
0.000874748
0.000575656
0.000994604
0.00221334
-0.00109465
0.00823225
-0.00188585
0.00286575
-0.00238084
0.00246172
-0.00279075
0.00208462
-0.00316322
0.00181118
-0.00349102
0.00151175
-0.00376102
0.00115788
-0.00395511
0.000729859
-0.0040489
0.000211651
-0.00401601
-0.000398821
-0.00385438
-0.00106053
-0.00360109
-0.00170343
-0.00332464
-0.00227036
-0.00308915
-0.00271493
-0.00285646
-0.0030021
-0.00261454
-0.00314507
-0.00304355
-0.00285169
-0.000957344
-0.00206985
-0.000541988
-0.00200402
-0.000169195
-0.00142069
0.000149201
-0.00100769
0.000391653
-0.000752499
0.000571896
-0.000597558
0.000677203
-0.000465443
0.000991095
-0.000313992
0.00126408
-0.000273087
0.00151648
-0.000252502
0.00174082
-0.00022444
0.00191476
-0.000174041
0.00200314
-8.84787e-05
0.00196632
3.67176e-05
0.0017705
0.000195724
0.00136463
0.000405772
0.00117316
0.00080224
0.000796748
0.00125121
0.000216458
0.00157495
0.00246149
-0.000804187
0.00944354
-0.00153685
0.00359845
-0.00173584
0.00266075
-0.00198355
0.00233237
-0.00223895
0.00206662
-0.00247372
0.00174656
-0.00267519
0.0013594
-0.00282977
0.000884485
-0.00291415
0.000296081
-0.00288664
-0.000426288
-0.00275008
-0.00119705
-0.00256223
-0.00189124
-0.00238408
-0.00244847
-0.00224661
-0.00285236
-0.00213819
-0.00311049
-0.00206711
-0.00321611
-0.00184144
-0.00307732
-0.00107714
-0.00283411
-0.000603171
-0.00247794
-0.000301644
-0.00172217
-6.11993e-05
-0.00124809
0.000142554
-0.000956199
0.000315776
-0.000770726
0.000487744
-0.000637357
0.000717272
-0.000543467
0.000940811
-0.000496572
0.00115528
-0.000466919
0.00135675
-0.000425853
0.00153114
-0.000348375
0.00165187
-0.000209158
0.00168019
8.45184e-06
0.00159325
0.000282708
0.001407
0.000592079
0.00121352
0.000995776
0.000977423
0.00148736
0.000437494
0.00211494
0.000190128
0.00270892
-0.0012645
0.00145448
-0.00172409
0.000459438
-0.00166279
-0.000712215
0.0106132
-0.00133674
0.00422302
-0.00107429
0.00239834
-0.00108622
0.00234434
-0.00122595
0.0022064
-0.00135538
0.00187605
-0.00145368
0.00145774
-0.00152161
0.000952462
-0.00154809
0.000322601
-0.00148383
-0.000490504
-0.00135878
-0.00132205
-0.00123825
-0.00201173
-0.00116394
-0.00252274
-0.00114946
-0.0028668
-0.00118572
-0.00307419
-0.00123692
-0.00316487
-0.00114651
-0.0031677
-0.000803196
-0.00317739
-0.000477405
-0.00280368
-0.000312798
-0.00188672
-0.00018975
-0.00137108
-7.01968e-05
-0.0010757
5.01348e-05
-0.000891004
0.000182833
-0.000770002
0.000335356
-0.000695936
0.000496537
-0.000657699
0.000663239
-0.000633567
0.000835103
-0.000597664
0.0010079
-0.000521118
0.00116772
-0.000368929
0.00128338
-0.000107158
0.00132495
0.000241195
0.00131294
0.000604141
0.00130691
0.00100186
0.00137609
0.00141823
0.00152323
0.00196786
0.00204498
0.00218722
0.00233388
0.00116565
0.00195905
0.000834321
0.000369278
-0.000965999
0.0120802
-0.00105647
0.00431353
-0.000160995
0.00150291
9.35067e-05
0.00208988
3.54394e-06
0.00229641
-8.75701e-05
0.0019672
-9.28146e-05
0.00146303
-3.91589e-05
0.00089885
7.37359e-05
0.000209751
0.000208117
-0.000624842
0.000302315
-0.0014162
0.000316943
-0.00202632
0.000243935
-0.00244969
9.30589e-05
-0.00271588
-0.00011475
-0.00286635
-0.000335321
-0.00294427
-0.00047947
-0.00302352
-0.000419066
-0.00323776
-0.00028177
-0.00294093
-0.000280371
-0.00188807
-0.000293044
-0.00135835
-0.000283145
-0.00108554
-0.00025488
-0.000919216
-0.000209026
-0.000815802
-0.000146795
-0.000758112
-7.12945e-05
-0.000733147
1.82865e-05
-0.000723096
0.000125913
-0.000705238
0.000258229
-0.000653383
0.000424585
-0.000535234
0.000628359
-0.000310881
0.000822872
4.67327e-05
0.000991156
0.000435908
0.00119122
0.000801846
0.00150726
0.00110225
0.00202921
0.00144596
0.00284187
0.00137461
0.0034843
0.000523272
0.00359117
0.000727516
0.004038
0.00234173
0.0102954
0.00281379
0.00384151
0.00275469
0.00156205
0.00253383
0.00231078
0.00219433
0.00263595
0.00197189
0.00218969
0.00191384
0.00152112
0.00197633
0.000836413
0.00214945
3.66744e-05
0.0022822
-0.000757546
0.00224903
-0.001383
0.00206154
-0.00183878
0.00175949
-0.00214761
0.00138107
-0.00233742
0.000958364
-0.00244361
0.000528079
-0.00251395
0.000152375
-0.00264779
-2.56166e-05
-0.00305974
-6.96648e-05
-0.00289683
-0.00024461
-0.00171307
-0.00041213
-0.00119078
-0.000521023
-0.000976596
-0.0005953
-0.000844886
-0.000650557
-0.000760491
-0.000693765
-0.000714851
-0.000729364
-0.000697495
-0.000757655
-0.000694752
-0.000773535
-0.000689306
-0.000765505
-0.000661362
-0.000710784
-0.000589904
-0.000570221
-0.000451393
-0.000304533
-0.000218905
1.35914e-05
0.000117834
0.000351703
0.000463785
0.000737897
0.000716109
0.00124952
0.000934383
0.00175431
0.000869881
0.00177855
0.000499081
0.000751471
0.00175465
0.00512993
0.0109115
0.014751
0.0126061
0.00370698
0.0103511
0.00456581
0.00855344
0.00443367
0.007316
0.00342717
0.00649957
0.00233758
0.00599414
0.00134189
0.00554749
0.000483369
0.00502334
-0.000233354
0.00444208
-0.000801702
0.00382391
-0.00122057
0.00317972
-0.00150339
0.00252001
-0.00167767
0.00185545
-0.00177903
0.00120253
-0.00186101
0.000621617
-0.00206685
0.000316967
-0.00275506
0.000157963
-0.00273778
-0.000256029
-0.00129902
-0.000585623
-0.00086113
-0.000790174
-0.000771991
-0.000950712
-0.000684294
-0.00110011
-0.000611041
-0.00124946
-0.000565441
-0.00140827
-0.000538638
-0.00158371
-0.000519254
-0.00178047
-0.000492497
-0.00200301
-0.000438769
-0.00225649
-0.000336377
-0.00254593
-0.000161901
-0.00287207
0.000107287
-0.00323362
0.000479437
-0.00373111
0.000961322
-0.00453783
0.00152289
-0.00570429
0.00210089
-0.00733619
0.00250183
-0.0093208
0.00248375
-0.00870995
0.00114385
-0.00320347
0.00457592
0.00500306
0.00457707
0.00456469
0.00566564
0.00334513
0.00608286
0.00300998
0.00613294
0.00228753
0.00606256
0.0014123
0.00589115
0.000654813
0.0055707
8.71334e-05
0.00508573
-0.000316703
0.00448326
-0.000618061
0.00380838
-0.000828485
0.00309497
-0.000964234
0.00235996
-0.00104398
0.0016022
-0.00110323
0.00087045
-0.00133507
0.000504719
-0.0023893
0.000280396
-0.00251339
-0.000454089
-0.000564476
-0.00088098
-0.000434182
-0.00109593
-0.00055699
-0.00128935
-0.000490813
-0.00148315
-0.000417187
-0.00167856
-0.000369979
-0.00188834
-0.000328811
-0.00212224
-0.000285293
-0.00237949
-0.000235202
-0.00264708
-0.000171126
-0.00289867
-8.47378e-05
-0.0030969
3.63847e-05
-0.00323865
0.000249092
-0.00334118
0.000582013
-0.00342566
0.00104586
-0.0035072
0.00160448
-0.00351526
0.002109
-0.0032785
0.00226513
-0.00183352
0.00103881
0.000340809
-0.00103043
-0.00277178
-0.000810489
0.00587098
0.00128415
0.00247007
0.00252265
0.00210665
0.00347794
0.00205471
0.00423459
0.00153092
0.00469845
0.000948469
0.00486235
0.000490949
0.00477718
0.000172327
0.00452189
-6.13837e-05
0.0041396
-0.000235742
0.00366513
-0.000353983
0.00312882
-0.000427888
0.00254873
-0.000463872
0.00192634
-0.000480803
0.0012448
-0.000653509
0.000483102
-0.00162757
-0.000332688
-0.00169753
-0.000968008
7.09033e-05
-0.00129604
-0.000106088
-0.00151966
-0.000333322
-0.00172019
-0.000290225
-0.00189796
-0.000239369
-0.00205371
-0.000214172
-0.00219387
-0.000188591
-0.00232409
-0.000155023
-0.00244658
-0.000112661
-0.00255902
-5.86374e-05
-0.00265462
1.09178e-05
-0.00270998
9.17963e-05
-0.00267152
0.000210687
-0.00249981
0.000410355
-0.00216441
0.000710514
-0.00168109
0.00112121
-0.00102141
0.00144938
0.000178956
0.00106481
0.00190974
-0.000691918
0.0033549
-0.00247554
0.000683005
-0.00899852
-0.0116841
-0.00576343
-0.00326324
-0.0011318
0.000944833
0.00249679
0.0034665
0.00397938
0.00417464
0.00413732
0.00392671
0.00359895
0.00319844
0.00276315
0.00231218
0.00168978
9.4565e-05
-0.00157393
-0.00147608
-0.00155524
-0.00186153
-0.00212481
-0.00233733
-0.00252472
-0.00268661
-0.00281508
-0.00290142
-0.00293412
-0.00289781
-0.00278136
-0.00254689
-0.00211371
-0.00138141
-0.000239501
0.00122926
0.00231303
0.00164117
-0.000813945
)
;
boundaryField
{
floor
{
type calculated;
value nonuniform List<scalar>
29
(
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-6.47139e-06
-1.63291e-05
-2.43473e-05
-3.16358e-05
-3.08524e-06
-3.65075e-06
-9.74049e-06
-1.47273e-05
-1.63161e-05
)
;
}
ceiling
{
type calculated;
value nonuniform List<scalar>
43
(
-5.33898e-05
-5.14524e-05
-4.96684e-05
-3.00996e-05
-2.47651e-05
-2.18984e-05
-2.10066e-05
-2.12089e-05
-2.19087e-05
-2.29037e-05
-2.40295e-05
-2.51036e-05
-2.6198e-05
-2.73447e-05
-2.85502e-05
-2.97979e-05
-3.10777e-05
-3.23244e-05
-2.89426e-05
-2.68846e-05
-2.68823e-05
-2.69697e-05
-2.68922e-05
-2.68011e-05
-2.67306e-05
-2.66448e-05
-2.65019e-05
-2.62618e-05
-2.58868e-05
-2.53401e-05
-2.45986e-05
-2.37396e-05
-2.27714e-05
-2.17314e-05
-2.06483e-05
-1.93342e-05
-1.89067e-05
-1.99999e-05
-2.03732e-05
-1.75553e-05
4.5477e-06
2.07616e-06
-5.74243e-05
)
;
}
sWall
{
type calculated;
value uniform -0.000256596;
}
nWall
{
type calculated;
value nonuniform List<scalar> 6(-6.14436e-05 -7.29611e-05 -7.74996e-05 -9.08234e-05 -9.9831e-05 -0.000113332);
}
sideWalls
{
type empty;
value nonuniform 0();
}
glass1
{
type calculated;
value nonuniform List<scalar> 9(-6.86107e-05 -0.000181935 -0.000273135 -0.00034674 -0.000407065 -0.000457444 -0.000500936 -0.000556847 -0.000620693);
}
glass2
{
type calculated;
value nonuniform List<scalar> 2(-0.000340405 -0.000376499);
}
sun
{
type calculated;
value uniform 0;
}
heatsource1
{
type calculated;
value nonuniform List<scalar> 3(2.06228e-07 2.06047e-07 2.06058e-07);
}
heatsource2
{
type calculated;
value nonuniform List<scalar> 4(5.13317e-08 5.15679e-08 0 0);
}
Table_master
{
type calculated;
value nonuniform List<scalar> 9(-1.54737e-07 -1.548e-07 -1.54811e-07 -1.54818e-07 -1.54822e-07 -1.54824e-07 -1.54823e-07 -1.54815e-07 -1.54779e-07);
}
Table_slave
{
type calculated;
value nonuniform List<scalar> 9(1.54733e-07 1.54694e-07 1.54616e-07 1.54547e-07 1.54496e-07 1.54476e-07 1.54488e-07 1.54517e-07 1.54601e-07);
}
inlet
{
type calculated;
value uniform -0.005872;
}
outlet
{
type calculated;
value nonuniform List<scalar> 2(0.00930852 0.00273704);
}
}
// ************************************************************************* //
| [
"mitsuaki.makino@tryeting.jp"
] | mitsuaki.makino@tryeting.jp | |
c7b7fc589a27522c02a6d40df7afdfe5296676e5 | 3cb02d8bfd827beaff8f5d284bfeee2099c173e6 | /牛客寒假算法基础集训营/2.2/h.cpp | 3edac2b3784d247a09c9584f49aee0cca264bbec | [] | no_license | yyhaos/Competitions | 8a88ddfa0606e884c88f17ef391ffdd1ba32bf0f | d291be1327e895883b423eeebad943893f27e66e | refs/heads/master | 2021-06-12T13:14:22.354538 | 2020-08-18T05:24:24 | 2020-08-18T05:24:24 | 128,635,106 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 629 | cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,x;
ll a[2005];
ll mi[2005][2005];
int main ()
{
cin>>n>>x;
for(ll i=0;i<n;i++)
{
scanf("%d",&a[i]);
mi[i][0]=a[i];
}
ll jin,cnt;
for(ll j=1;j<n;j++)
{
for(ll i=0;i<n;i++)
{
jin=(i-j+n)%n;
mi[i][j]=min(mi[i][j-1],mi[jin][0]);
}
}
ll tmp=0;
ll ans=99999999999999LL;
for(ll k=0;k<n;k++)
{
tmp=0;
for(int i=0;i<n;i++)
{
tmp+=mi[i][k];
}
ans=min(ans,k*x+tmp);
}
cout<<ans;
return 0;
}
| [
"35396510+yyhaos@users.noreply.github.com"
] | 35396510+yyhaos@users.noreply.github.com |
691ebd00b8e73a63e929731f5fbf2c4d32e38678 | 08b8cf38e1936e8cec27f84af0d3727321cec9c4 | /data/crawl/git/old_hunk_932.cpp | 9a369f491f22931788a677728a888f58ebbcb34d | [] | no_license | ccdxc/logSurvey | eaf28e9c2d6307140b17986d5c05106d1fd8e943 | 6b80226e1667c1e0760ab39160893ee19b0e9fb1 | refs/heads/master | 2022-01-07T21:31:55.446839 | 2018-04-21T14:12:43 | 2018-04-21T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 192 | cpp | int flags, long timeout_ms)
{
int fd = lock_file_timeout(lk, path, flags, timeout_ms);
if (fd < 0 && (flags & LOCK_DIE_ON_ERROR))
unable_to_lock_die(path, errno);
return fd;
}
| [
"993273596@qq.com"
] | 993273596@qq.com |
3948867de99e3b613dd4fd4d4cf2cf5e871f1eb9 | ea4e3ac0966fe7b69f42eaa5a32980caa2248957 | /download/unzip/WebKit2/WebKit2-7602.2.14.0.7/UIProcess/PageClient.h | 13dd888251ad7868f859eb8665487efc695f3ff7 | [] | no_license | hyl946/opensource_apple | 36b49deda8b2f241437ed45113d624ad45aa6d5f | e0f41fa0d9d535d57bfe56a264b4b27b8f93d86a | refs/heads/master | 2023-02-26T16:27:25.343636 | 2020-03-29T08:50:45 | 2020-03-29T08:50:45 | 249,169,732 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,731 | h | /*
* Copyright (C) 2010-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PageClient_h
#define PageClient_h
#include "ShareableBitmap.h"
#include "WebColorPicker.h"
#include "WebPageProxy.h"
#include "WebPopupMenuProxy.h"
#include <WebCore/AlternativeTextClient.h>
#include <WebCore/EditorClient.h>
#include <WebCore/UserInterfaceLayoutDirection.h>
#include <wtf/Forward.h>
#if PLATFORM(COCOA)
#include "PluginComplexTextInputState.h"
OBJC_CLASS CALayer;
#if USE(APPKIT)
OBJC_CLASS WKView;
OBJC_CLASS NSTextAlternatives;
#endif
#endif
namespace WebCore {
class Cursor;
class TextIndicator;
class WebMediaSessionManager;
enum class TextIndicatorWindowLifetime : uint8_t;
enum class TextIndicatorWindowDismissalAnimation : uint8_t;
struct Highlight;
struct ViewportAttributes;
}
namespace WebKit {
class DrawingAreaProxy;
class NativeWebKeyboardEvent;
class NativeWebMouseEvent;
class RemoteLayerTreeTransaction;
class ViewSnapshot;
class WebContextMenuProxy;
class WebEditCommandProxy;
class WebPopupMenuProxy;
#if ENABLE(TOUCH_EVENTS)
class NativeWebTouchEvent;
#endif
#if ENABLE(INPUT_TYPE_COLOR)
class WebColorPicker;
#endif
#if ENABLE(FULLSCREEN_API)
class WebFullScreenManagerProxyClient;
#endif
#if USE(GSTREAMER)
class InstallMissingMediaPluginsPermissionRequest;
#endif
#if PLATFORM(COCOA)
struct ColorSpaceData;
#endif
class PageClient {
public:
virtual ~PageClient() { }
// Create a new drawing area proxy for the given page.
virtual std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() = 0;
// Tell the view to invalidate the given region. The region is in view coordinates.
virtual void setViewNeedsDisplay(const WebCore::Region&) = 0;
// Tell the view to scroll to the given position, and whether this was a programmatic scroll.
virtual void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) = 0;
// Return the size of the view the page is associated with.
virtual WebCore::IntSize viewSize() = 0;
// Return whether the view's containing window is active.
virtual bool isViewWindowActive() = 0;
// Return whether the view is focused.
virtual bool isViewFocused() = 0;
// Return whether the view is visible.
virtual bool isViewVisible() = 0;
// Return whether the view is visible, or occluded by another window.
virtual bool isViewVisibleOrOccluded() { return isViewVisible(); }
// Return whether the view is in a window.
virtual bool isViewInWindow() = 0;
// Return whether the view is visually idle.
virtual bool isVisuallyIdle() { return !isViewVisible(); }
// Return the layer hosting mode for the view.
virtual LayerHostingMode viewLayerHostingMode() { return LayerHostingMode::InProcess; }
virtual void processDidExit() = 0;
virtual void didRelaunchProcess() = 0;
virtual void pageClosed() = 0;
virtual void preferencesDidChange() = 0;
virtual void toolTipChanged(const String&, const String&) = 0;
virtual bool decidePolicyForGeolocationPermissionRequest(WebFrameProxy&, API::SecurityOrigin&, GeolocationPermissionRequestProxy&)
{
return false;
}
virtual void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) = 0;
#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
virtual void pageDidRequestScroll(const WebCore::IntPoint&) = 0;
virtual void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) = 0;
virtual void pageTransitionViewportReady() = 0;
virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&) = 0;
#endif
#if PLATFORM(EFL)
virtual void updateTextInputState() = 0;
#endif // PLATFORM(EFL)
virtual void handleDownloadRequest(DownloadProxy*) = 0;
virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) { return false; }
virtual void didChangeContentSize(const WebCore::IntSize&) = 0;
#if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage) = 0;
#endif
virtual void setCursor(const WebCore::Cursor&) = 0;
virtual void setCursorHiddenUntilMouseMoves(bool) = 0;
virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&) = 0;
virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) = 0;
virtual void clearAllEditCommands() = 0;
virtual bool canUndoRedo(WebPageProxy::UndoOrRedo) = 0;
virtual void executeUndoRedo(WebPageProxy::UndoOrRedo) = 0;
virtual void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) = 0;
#if PLATFORM(COCOA)
virtual void accessibilityWebProcessTokenReceived(const IPC::DataReference&) = 0;
virtual bool executeSavedCommandBySelector(const String& selector) = 0;
virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
virtual void updateSecureInputState() = 0;
virtual void resetSecureInputState() = 0;
virtual void notifyInputContextAboutDiscardedComposition() = 0;
virtual void makeFirstResponder() = 0;
virtual void setAcceleratedCompositingRootLayer(LayerOrView *) = 0;
virtual LayerOrView *acceleratedCompositingRootLayer() const = 0;
virtual PassRefPtr<ViewSnapshot> takeViewSnapshot() = 0;
#if ENABLE(MAC_GESTURE_EVENTS)
virtual void gestureEventWasNotHandledByWebCore(const NativeWebGestureEvent&) = 0;
#endif
#endif
#if PLATFORM(COCOA) || PLATFORM(GTK)
virtual void selectionDidChange() = 0;
#endif
#if USE(APPKIT)
virtual void setPromisedDataForImage(const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title,
const String& url, const String& visibleUrl, PassRefPtr<WebCore::SharedBuffer> archiveBuffer) = 0;
#if ENABLE(ATTACHMENT_ELEMENT)
virtual void setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title,
const String& url, const String& visibleUrl) = 0;
#endif
#endif
virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) = 0;
virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) = 0;
virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) = 0;
virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) = 0;
#if PLATFORM(MAC)
virtual WebCore::IntRect rootViewToWindow(const WebCore::IntRect&) = 0;
#endif
#if PLATFORM(IOS)
virtual WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) = 0;
virtual WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) = 0;
virtual void didNotHandleTapAsClick(const WebCore::IntPoint&) = 0;
#endif
virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) = 0;
#if ENABLE(TOUCH_EVENTS)
virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled) = 0;
#endif
virtual RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) = 0;
#if ENABLE(CONTEXT_MENUS)
virtual std::unique_ptr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, const ContextMenuContextData&, const UserData&) = 0;
#endif
#if ENABLE(INPUT_TYPE_COLOR)
virtual RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) = 0;
#endif
#if PLATFORM(COCOA)
virtual void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) = 0;
virtual void clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation) = 0;
virtual void setTextIndicatorAnimationProgress(float) = 0;
#endif
virtual void enterAcceleratedCompositingMode(const LayerTreeContext&) = 0;
virtual void exitAcceleratedCompositingMode() = 0;
virtual void updateAcceleratedCompositingMode(const LayerTreeContext&) = 0;
virtual void willEnterAcceleratedCompositingMode() = 0;
#if PLATFORM(MAC)
virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0;
virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) = 0;
virtual void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) = 0;
virtual void dismissContentRelativeChildWindows(bool withAnimation = true) = 0;
virtual void showCorrectionPanel(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) = 0;
virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeText) = 0;
virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText) = 0;
virtual void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) = 0;
virtual void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) = 0;
virtual void removeNavigationGestureSnapshot() = 0;
virtual void handleControlledElementIDResponse(const String&) = 0;
virtual void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession) = 0;
virtual CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const = 0;
virtual ColorSpaceData colorSpace() = 0;
virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) = 0;
virtual void startWindowDrag() = 0;
virtual NSWindow *platformWindow() = 0;
#if WK_API_ENABLED
virtual NSView *inspectorAttachmentView() = 0;
virtual _WKRemoteObjectRegistry *remoteObjectRegistry() = 0;
#endif
#if USE(APPKIT)
virtual void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize) = 0;
#if USE(DICTATION_ALTERNATIVES)
virtual uint64_t addDictationAlternatives(const RetainPtr<NSTextAlternatives>&) = 0;
virtual void removeDictationAlternatives(uint64_t dictationContext) = 0;
virtual void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) = 0;
virtual Vector<String> dictationAlternatives(uint64_t dictationContext) = 0;
#endif // USE(DICTATION_ALTERNATIVES)
#if USE(INSERTION_UNDO_GROUPING)
virtual void registerInsertionUndoGrouping() = 0;
#endif // USE(INSERTION_UNDO_GROUPING)
#endif // USE(APPKIT)
virtual void setEditableElementIsFocused(bool) = 0;
#endif // PLATFORM(MAC)
#if PLATFORM(IOS)
virtual void commitPotentialTapFailed() = 0;
virtual void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color&, const Vector<WebCore::FloatQuad>& highlightedQuads, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius) = 0;
virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&) = 0;
virtual void layerTreeCommitComplete() = 0;
virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) = 0;
virtual void couldNotRestorePageState() = 0;
virtual void restorePageState(const WebCore::FloatPoint& scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatSize& obscuredInsetOnSave, double scale) = 0;
virtual void restorePageCenterAndScale(const WebCore::FloatPoint& center, double scale) = 0;
virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) = 0;
virtual void stopAssistingNode() = 0;
virtual bool isAssistingNode() = 0;
virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) = 0;
virtual void positionInformationDidChange(const InteractionInformationAtPosition&) = 0;
virtual void saveImageToLibrary(PassRefPtr<WebCore::SharedBuffer>) = 0;
virtual void didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold) = 0;
virtual void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect) = 0;
virtual void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale) = 0;
virtual void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) = 0;
virtual double minimumZoomScale() const = 0;
virtual WebCore::FloatRect documentRect() const = 0;
virtual void overflowScrollViewWillStartPanGesture() = 0;
virtual void overflowScrollViewDidScroll() = 0;
virtual void overflowScrollWillStartScroll() = 0;
virtual void overflowScrollDidEndScroll() = 0;
virtual Vector<String> mimeTypesWithCustomContentProviders() = 0;
virtual void showInspectorHighlight(const WebCore::Highlight&) = 0;
virtual void hideInspectorHighlight() = 0;
virtual void showInspectorIndication() = 0;
virtual void hideInspectorIndication() = 0;
virtual void enableInspectorNodeSearch() = 0;
virtual void disableInspectorNodeSearch() = 0;
#endif
// Auxiliary Client Creation
#if ENABLE(FULLSCREEN_API)
virtual WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() = 0;
#endif
// Custom representations.
virtual void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) = 0;
virtual void navigationGestureDidBegin() = 0;
virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) = 0;
virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) = 0;
virtual void navigationGestureDidEnd() = 0;
virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) = 0;
virtual void didRemoveNavigationGestureSnapshot() = 0;
virtual void didFirstVisuallyNonEmptyLayoutForMainFrame() = 0;
virtual void didFinishLoadForMainFrame() = 0;
virtual void didFailLoadForMainFrame() = 0;
virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) = 0;
virtual void didChangeBackgroundColor() = 0;
#if PLATFORM(MAC)
virtual void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) = 0;
virtual void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) = 0;
virtual void didHandleAcceptedCandidate() = 0;
virtual void videoControlsManagerDidChange() = 0;
#endif
#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
virtual WebCore::WebMediaSessionManager& mediaSessionManager() = 0;
#endif
virtual void refView() = 0;
virtual void derefView() = 0;
#if ENABLE(VIDEO) && USE(GSTREAMER)
virtual bool decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) = 0;
#endif
virtual void didRestoreScrollPosition() = 0;
virtual bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) { return false; }
virtual WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() = 0;
};
} // namespace WebKit
#endif // PageClient_h
| [
"hyl946@163.com"
] | hyl946@163.com |
4946e1364223195b87bdf2bc1d227e81d4e9d79d | dabf6e2d1a0622087fcf31b56bc06a9bcdb592f8 | /PNG.h | 59032e7180713ff1b434014b86bc2597787f497e | [] | no_license | elvisoliveira/splitgif | 19aa3133c991a120e9a4515ec778429d5bf5239d | 2e632003f02c702bc9503d3c544698bacb87ffa5 | refs/heads/master | 2020-05-27T02:07:16.608842 | 2014-06-25T17:10:02 | 2014-06-25T17:10:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 72 | h | #ifndef PNG_H
#define PNG_H
class PNG {
public:
PNG();
};
#endif
| [
"elvis.olv@gmail.com"
] | elvis.olv@gmail.com |
b4954105c49dcd04aee999165770defd5a0d9b7b | 67e8364603f885231b6057abd6859e60562a4008 | /Cpp/357_CountNumbersWithUniqueDigits/002.cpp | 99811121d74fb8a3c2fbb0b713f1f5b0ace0edae | [] | no_license | NeighborUncleWang/Leetcode | 988417721c4a395ac8800cd04e4d5d973b54e9d4 | d5bdbdcd698006c9997ef0e368ffaae6f546ac44 | refs/heads/master | 2021-01-18T22:03:27.400480 | 2019-02-22T04:45:52 | 2019-02-22T04:45:52 | 36,253,135 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 772 | cpp | class Solution {
private:
int dfs(vector<bool>& used, long long cur, long long max) {
int count = 0;
if (cur < max) {
++count;
} else {
return count;
}
for (int i = 0; i < 10; ++i) {
if (!used[i]) {
used[i] = true;
count += dfs(used, cur * 10 + i, max);
used[i] = false;
}
}
return count;
}
public:
int countNumbersWithUniqueDigits(int n) {
int res = 1;
long long max = pow(10, n);
vector<bool> used(10, false);
for (int i = 1; i < 10; ++i) {
used[i] = true;
res += dfs(used, i, max);
used[i] = false;
}
return res;
}
}; | [
"lixianshu1992@gmail.com"
] | lixianshu1992@gmail.com |
bea47afddd9c8832cc29bc47296d16a27804f71a | 514cffbeee7f24a471922cdbb54d07c242fbd93d | /primeno.cpp | d7769004a23e2e10e7c8823f0a772e98573ce3d0 | [] | no_license | Tushar630/CPP-Codes | d6c96bfed5319331bc49cedef320e2b902468d20 | 88071e7d3c97cb4c71094287356cc43e043a9e2e | refs/heads/master | 2023-08-17T04:04:22.500957 | 2019-12-11T08:09:00 | 2019-12-11T08:09:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 728 | cpp | //C++ Program to Display Prime Numbers Between Two Intervals
#include <iostream>
using namespace std;
int main()
{
int low, high, i, flag;
cout << "Enter two numbers(intervals): ";
cin >> low >> high;
cout << "Prime numbers between " << low << " and " << high << " are: ";
while (low < high)
{
flag = 0;
for(i = 2; i <= low/2; ++i)
{
if(low % i == 0)
{
flag = 1;
break;
}
}
if (flag == 0)
cout << low << " ";
++low;
}
return 0;
}
//output:
Enter two numbers(intervals): 20 50 Prime numbers between 20 and 50 are: 23 29 31 37 41 43 47
| [
"noreply@github.com"
] | noreply@github.com |
ffb90888c58a3acc3d713315a002664fb849146a | 2489f20116dfa10e4514b636cbf92a6036edc21a | /tojcode/2779.cpp | c5e371337d60a49eb2b272e56de688d8cdecc7c0 | [] | 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 | 277 | cpp | #include<iostream>
using namespace std;
int main()
{
int n,x1,y1,x2,y2,x,y,r;
cin>>n;
while(n--)
{
cin>>x1>>y1>>x2>>y2>>x>>y>>r;
if(x-r>=x1&&x+r<=x2&&y+r<=y2&&y-r>=y1)
cout<<"Just do it"<<endl;
else
cout<<"Don't get close to it"<<endl;
}
} | [
"qq1812755792@sina.com"
] | qq1812755792@sina.com |
a8ff265e9562a791704701daba2a8e42f7bbbd15 | 0d88019bb8b8b23caf3525d7da1413c87fd52f8c | /advance_cpp/Dsign/p11/Traveler.cpp | d860c739dfb0a0b2138e0d44462236df927f4fa9 | [] | no_license | isaacAdmaso/work | 2b1219d5309cc928b312940c74c2c7536f9d3756 | b1846f2b76abea8178fcbf8f4bd05fc70c12189e | refs/heads/master | 2020-04-22T01:04:47.800484 | 2019-02-10T16:25:02 | 2019-02-10T16:25:02 | 170,002,871 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 273 | cpp | /**
* @file Traveler.cpp
* @author your name (you@domain.com)
* @brief
* @version 0.1
* @date 2018-12-31
*
* @copyright Copyright (c) 2018
*
*/
#include "Traveler.h"
Traveler::Traveler(ITrole* _r)
:m_role(_r)
{
}
void Traveler::Goal()
{
m_role->Gole();
} | [
"ad123maso@gmail.com"
] | ad123maso@gmail.com |
17ecc751a098ed63424bb4d6ce3911da10c1e698 | b566c824f7afef50605bc51c254f49f521bde44d | /iyan3d/trunk/assimp-master/include/assimp/vector3.inl | 22b5bca03954c828a2043c7a5192dc2c73b6960a | [
"LGPL-2.0-or-later",
"BSD-3-Clause",
"MIT"
] | permissive | lanping100/Iyan3d | c8292a0a7e4a34b5cb921c00f8bbe4ee30ba78aa | c21bb191cec06039a3f6e9b2f19381cbd7537757 | refs/heads/master | 2020-06-17T13:53:58.907502 | 2019-07-02T07:43:39 | 2019-07-02T07:43:39 | 195,943,149 | 1 | 0 | MIT | 2019-07-09T06:06:31 | 2019-07-09T06:06:31 | null | UTF-8 | C++ | false | false | 11,177 | inl | /*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file vector3.inl
* @brief Inline implementation of aiVector3t<TReal> operators
*/
#pragma once
#ifndef AI_VECTOR3D_INL_INC
#define AI_VECTOR3D_INL_INC
#ifdef __cplusplus
#include "vector3.h"
#include <cmath>
// ------------------------------------------------------------------------------------------------
/** Transformation of a vector by a 3x3 matrix */
template <typename TReal>
inline aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector)
{
aiVector3t<TReal> res;
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z;
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z;
res.z = pMatrix.c1 * pVector.x + pMatrix.c2 * pVector.y + pMatrix.c3 * pVector.z;
return res;
}
// ------------------------------------------------------------------------------------------------
/** Transformation of a vector by a 4x4 matrix */
template <typename TReal>
inline aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector)
{
aiVector3t<TReal> res;
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z + pMatrix.a4;
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z + pMatrix.b4;
res.z = pMatrix.c1 * pVector.x + pMatrix.c2 * pVector.y + pMatrix.c3 * pVector.z + pMatrix.c4;
return res;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
template <typename TOther>
aiVector3t<TReal>::operator aiVector3t<TOther> () const {
return aiVector3t<TOther>(static_cast<TOther>(x),static_cast<TOther>(y),static_cast<TOther>(z));
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
x = pX; y = pY; z = pZ;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal aiVector3t<TReal>::SquareLength() const {
return x*x + y*y + z*z;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal aiVector3t<TReal>::Length() const {
return std::sqrt( SquareLength());
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
*this /= Length(); return *this;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
TReal len = Length();
if (len > static_cast<TReal>(0))
*this /= len;
return *this;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
x += o.x; y += o.y; z += o.z; return *this;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
x -= o.x; y -= o.y; z -= o.z; return *this;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
x *= f; y *= f; z *= f; return *this;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
x /= f; y /= f; z /= f; return *this;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
return(*this = mat * (*this));
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
return(*this = mat * (*this));
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal aiVector3t<TReal>::operator[](unsigned int i) const {
return *(&x + i);
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal& aiVector3t<TReal>::operator[](unsigned int i) {
return *(&x + i);
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
return x == other.x && y == other.y && z == other.z;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
return x != other.x || y != other.y || z != other.z;
}
// ---------------------------------------------------------------------------
template<typename TReal>
AI_FORCE_INLINE bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
return
std::abs(x - other.x) <= epsilon &&
std::abs(y - other.y) <= epsilon &&
std::abs(z - other.z) <= epsilon;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
return x != other.x ? x < other.x : y != other.y ? y < other.y : z < other.z;
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z);
}
// ------------------------------------------------------------------------------------------------
// symmetric addition
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
}
// ------------------------------------------------------------------------------------------------
// symmetric subtraction
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
}
// ------------------------------------------------------------------------------------------------
// scalar product
template <typename TReal>
AI_FORCE_INLINE TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
// ------------------------------------------------------------------------------------------------
// scalar multiplication
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
}
// ------------------------------------------------------------------------------------------------
// and the other way around
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
}
// ------------------------------------------------------------------------------------------------
// scalar division
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
return v * (1/f);
}
// ------------------------------------------------------------------------------------------------
// vector division
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>(v.x / v2.x,v.y / v2.y,v.z / v2.z);
}
// ------------------------------------------------------------------------------------------------
// cross product
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
return aiVector3t<TReal>( v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x);
}
// ------------------------------------------------------------------------------------------------
// vector negation
template <typename TReal>
AI_FORCE_INLINE aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
return aiVector3t<TReal>( -v.x, -v.y, -v.z);
}
// ------------------------------------------------------------------------------------------------
#endif // __cplusplus
#endif // AI_VECTOR3D_INL_INC
| [
"harishankar@19668fbc-42bf-4728-acef-d3afb4f12ffe"
] | harishankar@19668fbc-42bf-4728-acef-d3afb4f12ffe |
e2bb9853532ae36ab8b4689e99783a596c6446d7 | 877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a | /app/src/main/cpp/dir521/dir522/dir572/dir841/dir1355/file1456.cpp | 2082e71d41dfea28143b139e83a75c0eb1a749b0 | [] | no_license | tgeng/HugeProject | 829c3bdfb7cbaf57727c41263212d4a67e3eb93d | 4488d3b765e8827636ce5e878baacdf388710ef2 | refs/heads/master | 2022-08-21T16:58:54.161627 | 2020-05-28T01:54:03 | 2020-05-28T01:54:03 | 267,468,475 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 111 | cpp | #ifndef file1456
#error "macro file1456 must be defined"
#endif
static const char* file1456String = "file1456"; | [
"tgeng@google.com"
] | tgeng@google.com |
4d3434828fa5b7ddb6d4ae4e4014891d71d40b74 | 285934d4f53fdfd9a5ae472930b7b8ff40ffed35 | /nfatodfa.cpp | bb8b359fff8211e211ecc3895db48a5579a7ea92 | [] | no_license | fagan2888/Competitive-Programming | 235079360ce09418ad79c6d1af5b177c22156e63 | 8daaa6dbb8ec5e5fb37d7c2f0611df81c4e16da0 | refs/heads/master | 2020-12-12T02:19:58.366015 | 2016-10-21T14:03:02 | 2016-10-21T14:03:02 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,487 | cpp | #include<stdio.h>
#include<stdlib.h>
void eclose(int);
void trans(int,int);
struct nfastates
{
int initial;
int final;
char inputsym;
}nfa[50];
int abtrans[50],ai=0,bi=0,ei=0,eclosure[50],queue[50],n,start;
void main()
{
int i;
printf(“\n Enter the no: of states\n”);
scanf(“%d”,&n);
printf(“\n Enter initial state,inputsymbol,finalstate\n”);
for(i=0;i<n;i++)
{
scanf(“%d”,&nfa[i].initial);
nfa[i].inputsym= getche();
scanf(“%d”,&nfa[i].final);
}
printf(“\n Enter the start state\n”);
scanf(“%d”,&start);
printf(“\n THE ECLOSURE is\n”);
eclose(start);
for(i=0;i<ei;i++)
{
printf(“%d\t”,eclosure[i]);
}
printf(“\n THE a-transitions are\n”);
trans(1,1);
for(i=0;i<ai;i++)
{
printf(“%d\t”,abtrans[i]);
}
printf(“\n THE b-transitions are\n”);
trans(2,2);
for(i=0;i<bi;i++)
{
printf(“%d\t”,abtrans[i]);
}
getch();
}
void eclose(int start)
{
int f=0,r=0,i;
eclosure[ei]=start;
ei++;
queue[r]=start;
r++;
do
{
start=queue[f];
f++;
for(i=0;i<n;i++)
{
if(nfa[i].initial==start && nfa[i].inputsym==’e’)
{
queue[r]=nfa[i].final;
r++;
eclosure[ei]=nfa[i].final;
ei++;
}
}
}while(f<r);
}
void trans(int a,int flag)
{
int i,f=0,r=0,j;
for(j=0;j<ei;j++)
{
f=0,r=0;
queue[r]=eclosure[j];
r++;
do
{
start=queue[f];
f++;
for(i=0;i<n;i++)
{
if(nfa[i].initial==start && nfa[i].inputsym==’a’)
{
queue[r]=nfa[i].final;
r++;
if(flag==1)
{
abtrans[ai]=nfa[i].final;
ai++;
}
else if(flag==2)
{
abtrans[bi]=nfa[i].final;
bi++;
}
}
}
}while(f<r);
}
}
| [
"Rishabh Misra"
] | Rishabh Misra |
2747a392341b23442268b3575cf78205f7832f26 | 1f048f6d041c8d40d7f581aac94fd59bea25dd91 | /include/Function.h | 6a8343d650e54293ce41defd5c636b2ebfa4b9a6 | [] | no_license | Zaiyugi/spyceless | 798a90ef1d0f0b9d8184338ba5e726f17b55bfdf | a873227f080f3fccf856172b8df89d9c2cc720f3 | refs/heads/master | 2016-09-06T12:01:59.103826 | 2015-03-19T17:14:45 | 2015-03-19T17:14:45 | 30,669,237 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,905 | h | /* Name: Zachary Shore
* Date: 2014-11-11
* Edit: 2014-11-24
*/
#ifndef __FUNCTION_H__
#define __FUNCTION_H__
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include "Exceptions.h"
#include "Block.h"
#include "Symtab.h"
#include "ParameterList.h"
#include "ExpressionList.h"
namespace spyceless
{
class Block;
class Statement;
class ExpressionList;
class Function
{
public:
Function() : _name(""), _body(nullptr) {}
Function(std::string name, Block* parent = nullptr)
: _name(name), _returnValue() { init(parent); }
~Function();
void eval(std::vector<Literal>& vals);
void addStatement(Statement* loc);
void setParameters(ParameterList* param);
Symtab* getCurrentInstance() const;
Block* getBlockPointer() const;
ParameterList* getParameters() const;
Literal getReturnValue() const;
void setReturnValue(Literal& ret);
const std::string name() const;
private:
void init(Block* parent);
void handle_exception(std::exception& e, int ndx) const;
std::string _name;
ParameterList* _param;
Block* _body;
Literal _returnValue;
};
class FunctionTable
{
private:
std::map<std::string, Function*> _table;
public:
FunctionTable() {}
FunctionTable(const FunctionTable& st) : _table(st._table) {}
FunctionTable(FunctionTable&& st)
: _table( std::move(st._table) )
{}
~FunctionTable()
{
for(auto id : _table)
delete id.second;
_table.clear();
}
void insert(Function* func);
Function* find(std::string name) const;
void clear();
auto begin() -> decltype( _table.begin() ) const
{ return _table.begin(); }
auto end() -> decltype( _table.end() ) const
{ return _table.end(); }
};
};
#endif
| [
"zshore@cauldron.cs.clemson.edu"
] | zshore@cauldron.cs.clemson.edu |
c6f898c72e5083372d7b7b37b4f0c1688c935821 | 25dbc7fc32cdad296cb4ebd2aadaa8ed6ca4b403 | /test/unittest/element_test.cpp | 2b478759ec7b04f1c588bbcc1c3bf79a07cf9ce1 | [] | no_license | windmous/csoup | e96f92cbf27d57928a22eda9ac6e1afe1c885958 | cb8f4f08a08d2661161a5d6c7ec802d32d0aad79 | refs/heads/master | 2021-03-30T16:14:49.621563 | 2014-12-20T11:28:53 | 2014-12-20T11:28:53 | 27,272,222 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 163 | cpp | #include <iostream>
#include <vector>
#include <cstring>
#include <cctype>
#include "gtest/gtest/gtest.h"
#include "nodes/element.h"
#include "util/allocators.h"
| [
"windpls@gmail.com"
] | windpls@gmail.com |
585eeca483f8cb0a04d7e51c73f72198219f7b95 | d4e96aa48ddff651558a3fe2212ebb3a3afe5ac3 | /Modules/Registration/Metricsv4/include/itkANTSNeighborhoodCorrelationImageToImageMetricv4.h | 71934f860483f7337d98d6fbd328d7561f95524b | [
"SMLNJ",
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-mit-old-style",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-warranty-disclaimer",
"NTP",
"IJG",
"GPL-1.0-or-later",
"libtiff",
"BSD-4.3TAHOE",
"... | permissive | nalinimsingh/ITK_4D | 18e8929672df64df58a6446f047e6ec04d3c2616 | 95a2eacaeaffe572889832ef0894239f89e3f303 | refs/heads/master | 2020-03-17T18:58:50.953317 | 2018-10-01T20:46:43 | 2018-10-01T21:21:01 | 133,841,430 | 0 | 0 | Apache-2.0 | 2018-05-17T16:34:54 | 2018-05-17T16:34:53 | null | UTF-8 | C++ | false | false | 9,802 | h | /*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkANTSNeighborhoodCorrelationImageToImageMetricv4_h
#define itkANTSNeighborhoodCorrelationImageToImageMetricv4_h
#include "itkImageToImageMetricv4.h"
#include "itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h"
namespace itk {
/** \class ANTSNeighborhoodCorrelationImageToImageMetricv4
*
* \brief Computes normalized cross correlation using a small neighborhood
* for each voxel between two images, with speed optimizations for dense
* registration.
*
* Please cite this reference for more details:
*
* Brian B. Avants, Nicholas J. Tustison, Gang Song, Philip A. Cook,
* Arno Klein, James C. Gee, A reproducible evaluation of ANTs similarity metric
* performance in brain image registration, NeuroImage, Volume 54, Issue 3,
* 1 February 2011, Pages 2033-2044, ISSN 1053-8119,
* DOI: 10.1016/j.neuroimage.2010.09.025.
*
* Around each voxel, the neighborhood is defined as a N-Dimensional
* rectangle centered at the voxel. The size of the rectangle is 2*radius+1.
* The normalized correlation between neighborhoods of fixed image and moving
* image are averaged over the whole image as the final metric.
* \note A radius less than 2 can be unstable. 2 is the default.
*
* This class uses a specific fast implementation that is described in the
* above paper. There are two particular speed-ups:
*
* 1) It is assumed that the derivative is only affected by changes in the
* transform at the center of the window. This is obviously not true but speeds
* the evaluation up considerably and works well in practice. This assumption
* is the main differentiation of this approach from a more generic one.
*
* 2) The evaluation uses on-the-fly queues with multi-threading and a sliding
* neighborhood window. This is described in the above paper and specifically
* optimized for dense registration.
*
* Example of usage:
*
* typedef itk::ANTSNeighborhoodCorrelationImageToImageMetricv4
* <ImageType, ImageType> MetricType;
* typedef MetricType::Pointer MetricTypePointer;
* MetricTypePointer metric = MetricType::New();
*
* // set all parameters
* Size<Dimension> neighborhoodRadius;
* neighborhoodRadius.Fill(2);
* metric->SetRadius(neighborhood_radius);
* metric->SetFixedImage(fixedImage);
* metric->SetMovingImage(movingImage);
* metric->SetFixedTransform(transformFix);
* metric->SetMovingTransform(transformMov);
*
* // initialization after parameters are set.
* metric->Initialize();
*
* // getting derivative and metric value
* metric->GetValueAndDerivative(valueReturn, derivativeReturn);
*
*
* This class is templated over the type of the two input objects.
* This is the base class for a hierarchy of similarity metrics that may, in
* derived classes, operate on meshes, images, etc. This class computes a
* value that measures the similarity between the two objects.
*
* \note Sparse sampling is not supported by this metric. An exception will be
* thrown if m_UseFixedSampledPointSet is set. Support for sparse sampling
* will require a parallel implementation of the neighborhood scanning, which
* currently caches information as the neighborhood window moves.
*
* \ingroup ITKMetricsv4
*/
template<typename TFixedImage, typename TMovingImage, typename TVirtualImage = TFixedImage,
typename TInternalComputationValueType = double,
typename TMetricTraits = DefaultImageToImageMetricTraitsv4<TFixedImage,TMovingImage,TVirtualImage,TInternalComputationValueType>
>
class ITK_TEMPLATE_EXPORT ANTSNeighborhoodCorrelationImageToImageMetricv4 :
public ImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage, TInternalComputationValueType, TMetricTraits>
{
public:
/** Standard class typedefs. */
typedef ANTSNeighborhoodCorrelationImageToImageMetricv4 Self;
typedef ImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage,
TInternalComputationValueType,TMetricTraits> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(Self, Superclass);
/** superclass types */
typedef typename Superclass::MeasureType MeasureType;
typedef typename Superclass::DerivativeType DerivativeType;
typedef typename Superclass::DerivativeValueType DerivativeValueType;
typedef typename Superclass::VirtualPointType VirtualPointType;
typedef typename Superclass::FixedImagePointType FixedImagePointType;
typedef typename Superclass::FixedImagePixelType FixedImagePixelType;
typedef typename Superclass::FixedTransformType FixedTransformType;
typedef typename Superclass::FixedImageGradientType FixedImageGradientType;
typedef typename FixedTransformType::JacobianType FixedImageJacobianType;
typedef typename Superclass::MovingImagePointType MovingImagePointType;
typedef typename Superclass::MovingImagePixelType MovingImagePixelType;
typedef typename Superclass::MovingImageGradientType MovingImageGradientType;
typedef typename Superclass::MovingTransformType MovingTransformType;
typedef typename MovingTransformType::JacobianType MovingImageJacobianType;
typedef typename Superclass::JacobianType JacobianType;
typedef typename Superclass::VirtualImageGradientType VirtualImageGradientType;
typedef typename Superclass::FixedImageType FixedImageType;
typedef typename Superclass::MovingImageType MovingImageType;
typedef typename Superclass::VirtualImageType VirtualImageType;
typedef typename Superclass::FixedOutputPointType FixedOutputPointType;
typedef typename Superclass::MovingOutputPointType MovingOutputPointType;
typedef typename Superclass::FixedTransformType::JacobianType
FixedTransformJacobianType;
typedef typename Superclass::MovingTransformType::JacobianType
MovingTransformJacobianType;
typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
typedef typename Superclass::ImageDimensionType ImageDimensionType;
typedef typename VirtualImageType::RegionType ImageRegionType;
typedef typename VirtualImageType::SizeType RadiusType;
typedef typename VirtualImageType::IndexType IndexType;
/* Image dimension accessors */
itkStaticConstMacro(FixedImageDimension, ImageDimensionType,
FixedImageType::ImageDimension);
itkStaticConstMacro(MovingImageDimension, ImageDimensionType,
MovingImageType::ImageDimension);
itkStaticConstMacro(VirtualImageDimension, ImageDimensionType,
VirtualImageType::ImageDimension);
// Set the radius of the neighborhood window centered at each pixel.
// See the note above about using a radius less than 2.
itkSetMacro(Radius, RadiusType);
// Get the Radius of the neighborhood window centered at each pixel
itkGetMacro(Radius, RadiusType);
itkGetConstMacro(Radius, RadiusType);
void Initialize(void) throw ( itk::ExceptionObject ) ITK_OVERRIDE;
protected:
ANTSNeighborhoodCorrelationImageToImageMetricv4();
virtual ~ANTSNeighborhoodCorrelationImageToImageMetricv4();
friend class ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedImageRegionPartitioner< VirtualImageDimension >, Superclass, Self >;
typedef ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedImageRegionPartitioner< VirtualImageDimension >, Superclass, Self >
ANTSNeighborhoodCorrelationImageToImageMetricv4DenseGetValueAndDerivativeThreaderType;
friend class ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, Superclass, Self >;
typedef ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, Superclass, Self >
ANTSNeighborhoodCorrelationImageToImageMetricv4SparseGetValueAndDerivativeThreaderType;
virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
private:
ITK_DISALLOW_COPY_AND_ASSIGN(ANTSNeighborhoodCorrelationImageToImageMetricv4);
// Radius of the neighborhood window centered at each pixel
RadiusType m_Radius;
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkANTSNeighborhoodCorrelationImageToImageMetricv4.hxx"
#endif
#endif
| [
"ruizhi@csail.mit.edu"
] | ruizhi@csail.mit.edu |
92403fa84615c4e07f2cd8f94b9c13bf6f844319 | f22bdc99b6b308ec2be3f9cb63aa117f04d82dbe | /code/Network/include/cybUDPServerThread.h | cedee3dba3c8b6c1886fc1d85cbb970399162f7c | [] | no_license | naneaa/cybermed-master | d268b7b6c573feadc7cde041bd80de4a7ccc5687 | 46fba3ea54e9c4671a521cf21624a65a50812bd0 | refs/heads/master | 2021-01-21T08:37:19.621596 | 2018-05-14T23:30:42 | 2018-05-14T23:30:42 | 91,632,795 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,387 | h | // *****************************************************************
// This file is part of the CYBERMED Libraries
//
// Copyright (C) 2007 LabTEVE (http://www.de.ufpb.br/~labteve),
// Federal University of Paraiba and University of São Paulo.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
// *****************************************************************
#ifndef _CYBUDPSERVERTHREAD_H
#define _CYBUDPSERVERTHREAD_H
#include "cybSenderThread.h"
#include "cybUDPServer.h"
class CybUDPServerThread: public CybSenderThread
{
public:
/** Constructor */
CybUDPServerThread(CybUDPServer* server);
/** */
void* getInformation(void);
};
#endif /* _CYBUDPSERVERTHREAD_H */
| [
"elaineanita1@gmail.com"
] | elaineanita1@gmail.com |
d24fdd916e4c8818b831d91f973f726ada5b15eb | 44a010e9b1b142d8450ea6b4f5fd231c56612aa6 | /graphics.h | 237cbffaf8fef879a39fbc41a2b0052e53064ef9 | [] | no_license | SThom44/CaveStory | f66e8f3e37b1f441e3ac22b4ded7b3b71ca1a857 | 97a9f4e0241c1a506cbeaad114dda997135b1f8e | refs/heads/master | 2022-12-01T01:15:44.369085 | 2020-08-17T18:30:41 | 2020-08-17T18:30:41 | 278,733,864 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 935 | h | #pragma once
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include "globals.h"
#include <string>
#include <map>
#include <SDL.h>
#include <SDL_image.h>
using namespace std;
//create a graphics class
class Graphics {
//public methods are available to all parts of the application.
public:
//graphics object constructor and destructor
Graphics();
~Graphics();
//loads image file to store in the _spriteSheets map.
SDL_Surface* loadImage(const string &filePath);
//overlaps texture pulled from sprite sheet onto teh screen.
void blitSurface(SDL_Texture* source, SDL_Rect* sourceRectangle, SDL_Rect* destinationRectangle);
//push render to screen
void flip();
//clears screen
void clear();
SDL_Renderer* getRenderer() const;
//private methods are available only to the class or any subclass derived fro that class
private:
SDL_Window* _window;
SDL_Renderer* _renderer;
map<string, SDL_Surface*> _spriteSheets;
};
#endif | [
"shawn_thomas01@yahoo.com"
] | shawn_thomas01@yahoo.com |
0170dd4c5a1ef3931d4575fdfdf3936cac0da2ef | 45b89580c8547b83311a52c2708a2da503717273 | /Potential.h | 678e06d130d6b7dab33ad6d53898bd8cce0170fc | [] | no_license | jorgehog/QMC | 5eea5bb83edf0c067967dfe19be857dde2a461e1 | 8f759c85d3cf5414a6c205788ba140a80a8f54a1 | refs/heads/master | 2021-01-13T16:11:22.925396 | 2012-07-05T10:40:07 | 2012-07-05T10:40:07 | 4,016,895 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 576 | h | /*
* File: Potential.h
* Author: jorgehog
*
* Created on 13. april 2012, 17:21
*/
#ifndef POTENTIAL_H
#define POTENTIAL_H
class Potential {
public:
Potential(int n_p, int dim, bool coulomb_on);
virtual double get_pot_E(const Walker* walker) const = 0;
protected:
int n_p;
int dim;
Coulomb* coulomb;
};
class Harmonic_osc : public Potential {
protected:
double w;
public:
Harmonic_osc(int n_p, int dim, double W, bool coulomb_on = true);
virtual double get_pot_E(const Walker* walker) const;
};
#endif /* POTENTIAL_H */
| [
"jorgen_da_mad@hotmail.com"
] | jorgen_da_mad@hotmail.com |
e8607f9c25b653489b1fa869d64e57f09cd1859a | 97aa1181a8305fab0cfc635954c92880460ba189 | /torch/csrc/utils/byte_order.cpp | bbbb14c3b1bd58f4599ccdc22b82508340116d99 | [
"BSD-2-Clause"
] | permissive | zhujiang73/pytorch_mingw | 64973a4ef29cc10b96e5d3f8d294ad2a721ccacb | b0134a0acc937f875b7c4b5f3cef6529711ad336 | refs/heads/master | 2022-11-05T12:10:59.045925 | 2020-08-22T12:10:32 | 2020-08-22T12:10:32 | 123,688,924 | 8 | 4 | NOASSERTION | 2022-10-17T12:30:52 | 2018-03-03T12:15:16 | C++ | UTF-8 | C++ | false | false | 9,247 | cpp | #include <torch/csrc/utils/byte_order.h>
#include <c10/util/BFloat16.h>
#include <cstring>
#include <vector>
#if defined(_MSC_VER)
#include <stdlib.h>
#endif
namespace {
static inline void swapBytes16(void *ptr)
{
uint16_t output;
memcpy(&output, ptr, sizeof(uint16_t));
#if defined(_MSC_VER) && !defined(_DEBUG)
output = _byteswap_ushort(output);
#elif defined(__llvm__) || defined(__GNUC__) && !defined(__ICC)
output = __builtin_bswap16(output);
#else
uint16_t Hi = output >> 8;
uint16_t Lo = output << 8;
output = Hi | Lo;
#endif
memcpy(ptr, &output, sizeof(uint16_t));
}
static inline void swapBytes32(void *ptr)
{
uint32_t output;
memcpy(&output, ptr, sizeof(uint32_t));
#if defined(_MSC_VER) && !defined(_DEBUG)
output = _byteswap_ulong(output);
#elif defined(__llvm__) || defined(__GNUC__) && !defined(__ICC)
output = __builtin_bswap32(output);
#else
uint32_t Byte0 = output & 0x000000FF;
uint32_t Byte1 = output & 0x0000FF00;
uint32_t Byte2 = output & 0x00FF0000;
uint32_t Byte3 = output & 0xFF000000;
output = (Byte0 << 24) | (Byte1 << 8) | (Byte2 >> 8) | (Byte3 >> 24);
#endif
memcpy(ptr, &output, sizeof(uint32_t));
}
static inline void swapBytes64(void *ptr)
{
uint64_t output;
memcpy(&output, ptr, sizeof(uint64_t));
#if defined(_MSC_VER)
output = _byteswap_uint64(output);
#elif defined(__llvm__) || defined(__GNUC__) && !defined(__ICC)
output = __builtin_bswap64(output);
#else
uint64_t Byte0 = output & 0x00000000000000FF;
uint64_t Byte1 = output & 0x000000000000FF00;
uint64_t Byte2 = output & 0x0000000000FF0000;
uint64_t Byte3 = output & 0x00000000FF000000;
uint64_t Byte4 = output & 0x000000FF00000000;
uint64_t Byte5 = output & 0x0000FF0000000000;
uint64_t Byte6 = output & 0x00FF000000000000;
uint64_t Byte7 = output & 0xFF00000000000000;
output = (Byte0 << (7*8)) | (Byte1 << (5*8)) | (Byte2 << (3*8)) | (Byte3 << (1*8)) |
(Byte7 >> (7*8)) | (Byte6 >> (5*8)) | (Byte5 >> (3*8)) | (Byte4 >> (1*8));
#endif
memcpy(ptr, &output, sizeof(uint64_t));
}
static inline uint16_t decodeUInt16LE(const uint8_t *data) {
uint16_t output;
memcpy(&output, data, sizeof(uint16_t));
return output;
}
static inline uint16_t decodeUInt16BE(const uint8_t *data) {
uint16_t output = decodeUInt16LE(data);
swapBytes16(&output);
return output;
}
static inline uint32_t decodeUInt32LE(const uint8_t *data) {
uint32_t output;
memcpy(&output, data, sizeof(uint32_t));
return output;
}
static inline uint32_t decodeUInt32BE(const uint8_t *data) {
uint32_t output = decodeUInt32LE(data);
swapBytes32(&output);
return output;
}
static inline uint64_t decodeUInt64LE(const uint8_t *data) {
uint64_t output;
memcpy(&output, data, sizeof(uint64_t));
return output;
}
static inline uint64_t decodeUInt64BE(const uint8_t *data) {
uint64_t output = decodeUInt64LE(data);
swapBytes64(&output);
return output;
}
} // anonymous namespace
namespace torch {
namespace utils {
THPByteOrder THP_nativeByteOrder()
{
uint32_t x = 1;
return *(uint8_t*)&x ? THP_LITTLE_ENDIAN : THP_BIG_ENDIAN;
}
void THP_decodeInt16Buffer(int16_t* dst, const uint8_t* src, THPByteOrder order, size_t len)
{
for (size_t i = 0; i < len; i++) {
dst[i] = (int16_t)(
order == THP_BIG_ENDIAN ? decodeUInt16BE(src) : decodeUInt16LE(src));
src += sizeof(int16_t);
}
}
void THP_decodeInt32Buffer(int32_t* dst, const uint8_t* src, THPByteOrder order, size_t len)
{
for (size_t i = 0; i < len; i++) {
dst[i] = (int32_t)(
order == THP_BIG_ENDIAN ? decodeUInt32BE(src) : decodeUInt32LE(src));
src += sizeof(int32_t);
}
}
void THP_decodeInt64Buffer(int64_t* dst, const uint8_t* src, THPByteOrder order, size_t len)
{
for (size_t i = 0; i < len; i++) {
dst[i] = (int64_t)(
order == THP_BIG_ENDIAN ? decodeUInt64BE(src) : decodeUInt64LE(src));
src += sizeof(int64_t);
}
}
void THP_decodeHalfBuffer(THHalf* dst, const uint8_t* src, THPByteOrder order, size_t len)
{
for (size_t i = 0; i < len; i++) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
union { uint16_t x; THHalf f; };
x = (order == THP_BIG_ENDIAN ? decodeUInt16BE(src) : decodeUInt16LE(src));
dst[i] = f;
src += sizeof(uint16_t);
}
}
void THP_decodeBFloat16Buffer(at::BFloat16* dst, const uint8_t* src, THPByteOrder order, size_t len)
{
for (size_t i = 0; i < len; i++) {
uint16_t x =
(order == THP_BIG_ENDIAN ? decodeUInt16BE(src) : decodeUInt16LE(src));
std::memcpy(&dst[i], &x, sizeof(dst[i]));
src += sizeof(uint16_t);
}
}
void THP_decodeBoolBuffer(bool* dst, const uint8_t* src, THPByteOrder order, size_t len)
{
for (size_t i = 0; i < len; i++) {
dst[i] = (int)src[i] != 0 ? true : false;
}
}
void THP_decodeFloatBuffer(float* dst, const uint8_t* src, THPByteOrder order, size_t len)
{
for (size_t i = 0; i < len; i++) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
union { uint32_t x; float f; };
x = (order == THP_BIG_ENDIAN ? decodeUInt32BE(src) : decodeUInt32LE(src));
dst[i] = f;
src += sizeof(float);
}
}
void THP_decodeDoubleBuffer(double* dst, const uint8_t* src, THPByteOrder order, size_t len)
{
for (size_t i = 0; i < len; i++) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
union { uint64_t x; double d; };
x = (order == THP_BIG_ENDIAN ? decodeUInt64BE(src) : decodeUInt64LE(src));
dst[i] = d;
src += sizeof(double);
}
}
void THP_decodeComplexFloatBuffer(c10::complex<float>* dst, const uint8_t* src, THPByteOrder order, size_t len)
{
for (size_t i = 0; i < len; i++) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
union { uint32_t x; float re; };
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
union { uint32_t y; float im; };
x = (order == THP_BIG_ENDIAN ? decodeUInt32BE(src) : decodeUInt32LE(src));
src += sizeof(float);
y = (order == THP_BIG_ENDIAN ? decodeUInt32BE(src) : decodeUInt32LE(src));
src += sizeof(float);
dst[i] = c10::complex<float>(re, im);
}
}
void THP_decodeComplexDoubleBuffer(c10::complex<double>* dst, const uint8_t* src, THPByteOrder order, size_t len)
{
for (size_t i = 0; i < len; i++) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
union { uint32_t x; double re; };
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
union { uint32_t y; double im; };
x = (order == THP_BIG_ENDIAN ? decodeUInt64BE(src) : decodeUInt64LE(src));
src += sizeof(double);
y = (order == THP_BIG_ENDIAN ? decodeUInt64BE(src) : decodeUInt64LE(src));
src += sizeof(double);
dst[i] = c10::complex<double>(re, im);
}
}
void THP_encodeInt16Buffer(uint8_t* dst, const int16_t* src, THPByteOrder order, size_t len)
{
memcpy(dst, src, sizeof(int16_t) * len);
if (order != THP_nativeByteOrder()) {
for (size_t i = 0; i < len; i++) {
swapBytes16(dst);
dst += sizeof(int16_t);
}
}
}
void THP_encodeInt32Buffer(uint8_t* dst, const int32_t* src, THPByteOrder order, size_t len)
{
memcpy(dst, src, sizeof(int32_t) * len);
if (order != THP_nativeByteOrder()) {
for (size_t i = 0; i < len; i++) {
swapBytes32(dst);
dst += sizeof(int32_t);
}
}
}
void THP_encodeInt64Buffer(uint8_t* dst, const int64_t* src, THPByteOrder order, size_t len)
{
memcpy(dst, src, sizeof(int64_t) * len);
if (order != THP_nativeByteOrder()) {
for (size_t i = 0; i < len; i++) {
swapBytes64(dst);
dst += sizeof(int64_t);
}
}
}
void THP_encodeFloatBuffer(uint8_t* dst, const float* src, THPByteOrder order, size_t len)
{
memcpy(dst, src, sizeof(float) * len);
if (order != THP_nativeByteOrder()) {
for (size_t i = 0; i < len; i++) {
swapBytes32(dst);
dst += sizeof(float);
}
}
}
void THP_encodeDoubleBuffer(uint8_t* dst, const double* src, THPByteOrder order, size_t len)
{
memcpy(dst, src, sizeof(double) * len);
if (order != THP_nativeByteOrder()) {
for (size_t i = 0; i < len; i++) {
swapBytes64(dst);
dst += sizeof(double);
}
}
}
template <typename T>
std::vector<T> complex_to_float(const c10::complex<T>* src, size_t len) {
std::vector<T> new_src;
new_src.reserve(2 * len);
for (size_t i = 0; i < len; i++) {
auto elem = src[i];
new_src.emplace_back(elem.real());
new_src.emplace_back(elem.imag());
}
return new_src;
}
void THP_encodeComplexFloatBuffer(uint8_t* dst, const c10::complex<float>* src, THPByteOrder order, size_t len)
{
auto new_src = complex_to_float(src, len);
memcpy(dst, static_cast<void*>(&new_src), 2 * sizeof(float) * len);
if (order != THP_nativeByteOrder()) {
for (size_t i = 0; i < (2 * len); i++) {
swapBytes32(dst);
dst += sizeof(float);
}
}
}
void THP_encodeCompelxDoubleBuffer(uint8_t* dst, const c10::complex<double>* src, THPByteOrder order, size_t len)
{
auto new_src = complex_to_float(src, len);
memcpy(dst, static_cast<void*>(&new_src), 2 * sizeof(double) * len);
if (order != THP_nativeByteOrder()) {
for (size_t i = 0; i < (2 * len); i++) {
swapBytes64(dst);
dst += sizeof(double);
}
}
}
} // namespace utils
} // namespace torch
| [
"zhujiangmail@hotmail.com"
] | zhujiangmail@hotmail.com |
73291889e8b9e8ca1546d70ab97e73e0cb1f1d75 | 537e7bdcaeb31260603839382bf344de73d58218 | /src/qt/walletmodeltransaction.cpp | e06ec5519b26082a16a3313d1a9d17e4ecf13ed2 | [
"MIT"
] | permissive | GenieG/Escrow | a424f234f4c66abde70c3f56158cf5da9c25205d | c5529cd5737e31e4f8572111c39a374460710552 | refs/heads/master | 2020-04-14T04:46:59.882302 | 2019-01-01T06:41:36 | 2019-01-01T06:41:36 | 163,645,194 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,924 | cpp | // Copyright (c) 2011-2013 The Bitcoin developers
// Copyright (c) 2017-2018 The PIVX developers
// Copyright (c) 2018 The Escrow developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "walletmodeltransaction.h"
#include "wallet.h"
WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient>& recipients) : recipients(recipients),
walletTransaction(0),
keyChange(0),
fee(0)
{
walletTransaction = new CWalletTx();
}
WalletModelTransaction::~WalletModelTransaction()
{
delete keyChange;
delete walletTransaction;
}
QList<SendCoinsRecipient> WalletModelTransaction::getRecipients()
{
return recipients;
}
CWalletTx* WalletModelTransaction::getTransaction()
{
return walletTransaction;
}
unsigned int WalletModelTransaction::getTransactionSize()
{
return (!walletTransaction ? 0 : (::GetSerializeSize(*(CTransaction*)walletTransaction, SER_NETWORK, PROTOCOL_VERSION)));
}
CAmount WalletModelTransaction::getTransactionFee()
{
return fee;
}
void WalletModelTransaction::setTransactionFee(const CAmount& newFee)
{
fee = newFee;
}
CAmount WalletModelTransaction::getTotalTransactionAmount()
{
CAmount totalTransactionAmount = 0;
foreach (const SendCoinsRecipient& rcp, recipients) {
totalTransactionAmount += rcp.amount;
}
return totalTransactionAmount;
}
void WalletModelTransaction::newPossibleKeyChange(CWallet* wallet)
{
keyChange = new CReserveKey(wallet);
}
CReserveKey* WalletModelTransaction::getPossibleKeyChange()
{
return keyChange;
}
| [
"piyushjain90"
] | piyushjain90 |
47fb042214a23eec4af0aeefe532c861355b7b47 | 8dc84558f0058d90dfc4955e905dab1b22d12c08 | /device/bluetooth/test/mock_bluetooth_gatt_service.cc | 8cdd2fe8a6c38f99ac58ccd2536043c123390e3b | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | meniossin/src | 42a95cc6c4a9c71d43d62bc4311224ca1fd61e03 | 44f73f7e76119e5ab415d4593ac66485e65d700a | refs/heads/master | 2022-12-16T20:17:03.747113 | 2020-09-03T10:43:12 | 2020-09-03T10:43:12 | 263,710,168 | 1 | 0 | BSD-3-Clause | 2020-05-13T18:20:09 | 2020-05-13T18:20:08 | null | UTF-8 | C++ | false | false | 2,169 | cc | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "device/bluetooth/test/mock_bluetooth_gatt_service.h"
#include <memory>
#include <utility>
#include "device/bluetooth/test/mock_bluetooth_device.h"
using testing::Return;
using testing::_;
namespace device {
MockBluetoothGattService::MockBluetoothGattService(
MockBluetoothDevice* device,
const std::string& identifier,
const BluetoothUUID& uuid,
bool is_primary,
bool is_local) {
ON_CALL(*this, GetIdentifier()).WillByDefault(Return(identifier));
ON_CALL(*this, GetUUID()).WillByDefault(Return(uuid));
ON_CALL(*this, IsLocal()).WillByDefault(Return(is_local));
ON_CALL(*this, IsPrimary()).WillByDefault(Return(is_primary));
ON_CALL(*this, GetDevice()).WillByDefault(Return(device));
ON_CALL(*this, GetCharacteristics())
.WillByDefault(Return(std::vector<BluetoothRemoteGattCharacteristic*>()));
ON_CALL(*this, GetIncludedServices())
.WillByDefault(Return(std::vector<BluetoothRemoteGattService*>()));
ON_CALL(*this, GetCharacteristic(_))
.WillByDefault(
Return(static_cast<BluetoothRemoteGattCharacteristic*>(NULL)));
}
MockBluetoothGattService::~MockBluetoothGattService() = default;
void MockBluetoothGattService::AddMockCharacteristic(
std::unique_ptr<MockBluetoothGattCharacteristic> mock_characteristic) {
mock_characteristics_.push_back(std::move(mock_characteristic));
}
std::vector<BluetoothRemoteGattCharacteristic*>
MockBluetoothGattService::GetMockCharacteristics() const {
std::vector<BluetoothRemoteGattCharacteristic*> characteristics;
for (const auto& characteristic : mock_characteristics_)
characteristics.push_back(characteristic.get());
return characteristics;
}
BluetoothRemoteGattCharacteristic*
MockBluetoothGattService::GetMockCharacteristic(
const std::string& identifier) const {
for (const auto& characteristic : mock_characteristics_)
if (characteristic->GetIdentifier() == identifier)
return characteristic.get();
return nullptr;
}
} // namespace device
| [
"arnaud@geometry.ee"
] | arnaud@geometry.ee |
aebcd809b31aceb8df88013acf7942396bd56ef9 | 34b02bdc74ffd35caf0ced89612e413e43ef9e70 | /project/SQCore/src/WinAPI/1/WinTool.cpp | 6c7bfbe8439097b529ee594d5438ed211a26b4e5 | [] | no_license | Makmanfu/CppNote | 693f264e3984c6e2e953e395b836306197cc9632 | e1c76e036df4a9831618704e9ccc0ad22cd4b748 | refs/heads/master | 2020-03-26T01:11:51.613952 | 2018-08-10T06:52:21 | 2018-08-10T06:52:39 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 21,148 | cpp |
#include "stdafx.h"
#include "WinTool.h"
#include <io.h>
#include <windows.h>
#include <winreg.h>
#include <ctime>
#include <fstream>
#include <TlHelp32.h>
#include <sys/timeb.h>
#include <climits>
WinTool* WinTool::_instance = 0;
WinTool::WinTool()
{
}
WinTool::~WinTool()
{
}
WinTool* WinTool::Instance()
{
if (NULL == _instance)
_instance = new WinTool();
return _instance;
}
bool WinTool::RunCheckOnly(char* f_tname)
{
//程序运行一个实例
static HANDLE SQ_variable_hMutex;
//程序实例检查
SQ_variable_hMutex = CreateMutexA(NULL, true, f_tname);
if ((GetLastError() == ERROR_ALREADY_EXISTS) || (GetLastError() == ERROR_INVALID_HANDLE))
return false; //ShowBox("该程序已在运行");
return true;
}
void WinTool::SetAutoRun(LPSTR RegName, bool fsetrun /*= true*/)
{
if (!strcmp(RegName, ""))
RegName = "AutoRun";
char bufname[260];
GetModuleFileNameA(NULL, bufname, 260); //获得路径 此时格式是c:\1\2.exe
HKEY sub;
if (fsetrun)
{
//用这个也行//HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run
::RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", &sub);
::RegSetValueExA(sub, RegName, NULL, REG_SZ, (BYTE*)bufname, 260); //设置开机运行
}
else
{
::RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", &sub);
::RegDeleteValueA(sub, RegName); //取消开机运行
}
}
void WinTool::SignFlagEXE(const char* exename, int ver, int verr)
{
std::fstream iofile(exename, ios::in | ios::out | ios::binary); //二进制覆写
if (iofile) //判断打开成功
{
SYSTEMTIME CurTime;
GetLocalTime(&CurTime);
char* buf = (char*)malloc(58 * sizeof(char));
sprintf(buf, "@BUILDING FOR AGAN!$MSVC%02d-%02d-%03d %04d-%02d-%02d %02d:%02d:%02d:%03d\n",
_MSC_VER / 100, ver, verr, CurTime.wYear, CurTime.wMonth, CurTime.wDay, CurTime.wHour,
CurTime.wMinute, CurTime.wSecond, CurTime.wMilliseconds);
iofile.seekp(2, ios::beg); //寻找位置
iofile.write(buf, 58/*sizeof(buf)*/); //头部
free(buf);
char* buf2 = (char*)malloc(52 * sizeof(char));
sprintf(buf2, "WHATEVER IS WORTH DOING IS WORTH DOING WELL! PROGRAM\n");
iofile.seekp(64, ios::beg); //寻找位置
iofile.write(buf2, 52/*sizeof(buf)*/); //头部
free(buf2);
iofile.close();
}
else {
MessageBoxA(NULL, "error", "dll", MB_OK);
}
//main中调用
//if (argc > 1)
// SignFlagEXE(argv[1], 0, 1);
}
void LoadDllPro(char* Dllname, char* ProName)
{
HINSTANCE hInst;
hInst = LoadLibraryA(Dllname);
//定义函数指针
typedef void(*FunProc)(void);
//强制类型转换
FunProc NewFun = (FunProc)GetProcAddress(hInst, ProName);
char SZBUF[255] = { 0 };
sprintf(SZBUF, "没有发现%d", Dllname);
//通过上面函数指针 得到函数就是NewFun
if (!NewFun)
MessageBoxA(NULL, SZBUF, "ERROR", MB_OK);
else
NewFun();
}
void GetSysVersion(void)
{
OSVERSIONINFOEX osver;
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
//获取版本信息
if (!GetVersionExA((LPOSVERSIONINFOA)&osver))
printf("Error:%d", GetLastError());
//打印版本信息
printf("System info:%s,%s", osver.dwMajorVersion, osver.dwMinorVersion);
printf("Build:%s", osver.dwBuildNumber);
printf("Service Pack:%s,%s", osver.wServicePackMajor, osver.wServicePackMinor);
}
/*
//获取CPU厂商
string GetCpuVendor(void)
{
char* pvendor = new char[64];
INT32 dwBuf[4];
if (NULL == pvendor) return 0;
// Function 0: Vendor-ID and Largest Standard Function
__cpuid(dwBuf, 0);
// save. 保存到pvendor
(INT32*)&pvendor[0] = dwBuf[1]; // ebx: 前四个字符
(INT32*)&pvendor[4] = dwBuf[3]; // edx: 中间四个字符
(INT32*)&pvendor[8] = dwBuf[2]; // ecx: 最后四个字符
pvendor[12] = '\0';
return pvendor;
}
//获取CPU商标
string GetCpuBrand(void)
{
char* pbrand = new char[64];
INT32 dwBuf[4];
if (NULL == pbrand) return 0;
// Function 0x80000000: Largest Extended Function Number
__cpuid(dwBuf, 0x80000000);
if (dwBuf[0] < 0x80000004) return 0;
// Function 80000002h,80000003h,80000004h: Processor Brand String
__cpuid((INT32*)&pbrand[0], 0x80000002); // 前16个字符
__cpuid((INT32*)&pbrand[16], 0x80000003); // 中间16个字符
__cpuid((INT32*)&pbrand[32], 0x80000004); // 最后16个字符
pbrand[48] = '\0';
return pbrand;
}
*/
string GetCPUid(void)
{
/*
char cputmpid[255];
//char szBuf[64];
INT32 dwBuf[4];
__cpuidex(dwBuf, 0, 0);
__cpuid(dwBuf, 0);
sprintf(cputmpid, "%.8X%.8X%.8X%.8X", dwBuf[0], dwBuf[1], dwBuf[2], dwBuf[3]);
return cputmpid;
*/
return "";
//x86下
//int s1,s2;
//std::string f_out;
//char cputmpid[255];
//__asm{
// mov eax,01h
// xor edx,edx
// cpuid
// mov s1,edx
// mov s2,eax
//}
//sprintf(cputmpid,"%08X%08X",s1,s2);
//cout<<cputmpid<<endl;
//f_out = string(cputmpid);
//__asm{
// mov eax,03h
// xor ecx,ecx
// xor edx,edx
// cpuid
// mov s1,edx
// mov s2,ecx
//}
//sprintf(cputmpid,"%08X%08X",s1,s2);
//cout<<cputmpid<<endl;
//f_out += string(cputmpid);
//return f_out;
//++++++++cpuid++++++++++++++++++++++++++++++++++++
//#if defined(_WIN64)
// // 64位下不支持内联汇编. 应使用__cpuid、__cpuidex等Intrinsics函数。
//#else
//#if _MSC_VER < 1600 // VS2010. 据说VC2008 SP1之后才支持__cpuidex
// void __cpuidex(INT32 CPUInfo[4], INT32 InfoType, INT32 ECXValue)
// {
// if (NULL == CPUInfo) return;
// _asm
// {
// // load. 读取参数到寄存器
// mov edi, CPUInfo; // 准备用edi寻址CPUInfo
// mov eax, InfoType;
// mov ecx, ECXValue;
// // CPUID
// cpuid;
// // save. 将寄存器保存到CPUInfo
// mov[edi], eax;
// mov[edi + 4], ebx;
// mov[edi + 8], ecx;
// mov[edi + 12], edx;
// }
// }
//#endif // #if _MSC_VER < 1600 // VS2010. 据说VC2008 SP1之后才支持__cpuidex
//
//#if _MSC_VER < 1400 // VC2005才支持__cpuid
// void __cpuid(INT32 CPUInfo[4], INT32 InfoType)
// {
// __cpuidex(CPUInfo, InfoType, 0);
// }
//#endif // #if _MSC_VER < 1400 // VC2005才支持__cpuid
//
//#endif // #if defined(_WIN64)
//========cpuid====================================
}
void GetCPUInfo(void)
{
}
void GetSysInfo(void)
{
////获取网络用户名称
//char username[20];
//unsigned long size1 = 20;
//GetUserName(username, &size1);
////获得计算机名称
//WORD wVersionRequested;
//WSADATA wsaData;
//char name[255];
//wVersionRequested = MAKEWORD(2, 0);
//if (WSAStartup(wVersionRequested, &wsaData) == 0)
//{
// gethostname(name, sizeof(name));
// WSACleanup();
//}
}
void GetUsers(void)
{
}
void AddUsers(void)
{
}
void DelUser(void)
{
}
void GetTime(void)
{
}
int SetBrightness(int f_bright)
{
//调整亮度 参数0-390 成功返回0 失败返回负数
if (f_bright > 390)
f_bright = 390;
void* lpGamma = NULL;
int iArrayValue;
WORD gMap[3][256] = { 0 };
lpGamma = &gMap;
HDC hdc = ::GetDC(NULL);
if (NULL == hdc)
return -1;
for (int i = 0; i < 256; i++)
{
iArrayValue = i * (f_bright + 128);
if (iArrayValue > 65535)
iArrayValue = 65535;
gMap[0][i] = gMap[1][i] = gMap[2][i] = (WORD)iArrayValue;
}
if (FALSE == SetDeviceGammaRamp(hdc, lpGamma))
return -2;
return 0;
}
int SetDisplayState(int fState /*= 2*/)
{
//关闭显示器[1低能耗状态2直接关闭-1打开显示器]
return PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, fState);
}
bool ChngDsplyMd(int f_WidthP, int f_HeightP, int f_intBitsPer)
{
DEVMODE lpDevMode;
lpDevMode.dmBitsPerPel = f_intBitsPer;
lpDevMode.dmPelsWidth = f_WidthP;
lpDevMode.dmPelsHeight = f_HeightP;
lpDevMode.dmSize = sizeof(lpDevMode);
lpDevMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
LONG result = ChangeDisplaySettings(&lpDevMode, 0);
if (result == DISP_CHANGE_SUCCESSFUL)
{
//AfxMessageBox("修改成功");
ChangeDisplaySettings(&lpDevMode, CDS_UPDATEREGISTRY);
//使用CDS_UPDATEREGISTRY表示次修改是持久的,
//并在注册表中写入了相关的数据
return true;
}
else
{
//AfxMessageBox("修改失败,恢复原有设置");
ChangeDisplaySettings(NULL, 0);
return false;
}
}
void SetSysShut_GetNT(void)
{
DWORD dwVersion = GetVersion();
if (dwVersion < 0x80000000) //是NT系列的系统
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
}
}
void SetSysShut(int f_State /*= 1*/)
{
switch (f_State)
{
case 0:
default: //闪电关机
{
const unsigned int SE_SHUTDOWN_PRIVILEGE = 0x13;
HMODULE hDll = ::LoadLibraryA("ntdll.dll");
typedef int(*type_RtlAdjustPrivilege)(int, bool, bool, int*);
typedef int(*type_ZwShutdownSystem)(int);
type_RtlAdjustPrivilege RtlAdjustPrivilege = (type_RtlAdjustPrivilege)GetProcAddress(hDll, "RtlAdjustPrivilege");
type_ZwShutdownSystem ZwShutdownSystem = (type_ZwShutdownSystem)GetProcAddress(hDll, "ZwShutdownSystem");
int nEn = 0;
int nResult = RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, true, true, &nEn);
if (nResult == 0x0c000007c)
nResult = RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, true, false, &nEn);
nResult = ZwShutdownSystem(2); //2 shutdown
FreeLibrary(hDll);
}
break;
case 4:
{
const unsigned int SE_SHUTDOWN_PRIVILEGE = 0x13;
HMODULE hDll = ::LoadLibraryA("ntdll.dll");
typedef int(*type_RtlAdjustPrivilege)(int, bool, bool, int*);
typedef int(*type_ZwShutdownSystem)(int);
type_RtlAdjustPrivilege RtlAdjustPrivilege = (type_RtlAdjustPrivilege)GetProcAddress(hDll, "RtlAdjustPrivilege");
type_ZwShutdownSystem ZwShutdownSystem = (type_ZwShutdownSystem)GetProcAddress(hDll, "ZwShutdownSystem");
int nEn = 0;
int nResult = RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, true, true, &nEn);
if (nResult == 0x0c000007c)
nResult = RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, true, false, &nEn);
nResult = ZwShutdownSystem(1); //reboot
FreeLibrary(hDll);
}
break;
case 1: //系统关机
{
SetSysShut_GetNT();
ExitWindowsEx(EWX_SHUTDOWN, 0);
}
break;
case 2: //Reboot 系统重启
{
SetSysShut_GetNT();
ExitWindowsEx(EWX_REBOOT, 0);
}
break;
case 3: //Logoff 系统注销
{
SetSysShut_GetNT();
ExitWindowsEx(EWX_LOGOFF, 0);
}
break;
}
}
string GetThisNowTime()
{
time_t t = time(0);
char buffer[9] = { 0 };
strftime(buffer, 9, "%H:%M:%S", localtime(&t));
//strftime(buffer, 9, "%H:%M", localtime(&t));
return string(buffer);
}
string GetMilliNum(void)
{
SYSTEMTIME CurTime;
GetLocalTime(&CurTime);
//得出时间
char* szBuffer = (char*)malloc(17 * sizeof(char));
sprintf(szBuffer, "%04d%02d%02d%02d%02d%02d%03d",
CurTime.wYear, CurTime.wMonth, CurTime.wDay, CurTime.wHour, CurTime.wMinute, CurTime.wSecond, CurTime.wMilliseconds);
//stringstream tmp;
//tmp<<CurTime.wYear<<CurTime.wMonth<<CurTime.wDay<<CurTime.wHour<<CurTime.wMinute<<CurTime.wSecond<<CurTime.wMilliseconds;
//return tmp.str();
return (string)szBuffer;
}
char* GetGUID(bool f_num)
{
static char buf[64] = { 0 };
GUID guid;
if (S_OK == ::CoCreateGuid(&guid))
{
if (f_num)
{
//_snprintf_s
printf(buf, sizeof(buf), "%08X%04X%04x%02X%02X%02X%02X%02X%02X%02X%02X"
, guid.Data1, guid.Data2, guid.Data3
, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3]
, guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
}
else
{
printf(buf, sizeof(buf), "{%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}"
, guid.Data1, guid.Data2, guid.Data3
, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3]
, guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
}
}
return (char*)buf; //如果要转换成string return std::string(buf);
}
bool UPackExeRes(char* f_strFileName, WORD f_wResID, char* f_strFileType)
{
//仅exe有效 dll获取不到句柄
/************************************************************************/
/* 函数说明:释放资源中某类型的文件
/* 参 数:新文件名、资源ID、资源类型
/* 返 回 值:成功返回TRUE,否则返回FALSE
/************************************************************************/
//if (!_access(f_strFileName, 0))
// return false;
// 资源大小
DWORD dwWrite = 0;
// 创建文件
HANDLE hFile = CreateFileA(f_strFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) return FALSE;
// 查找资源文件中、加载资源到内存、得到资源大小
HRSRC hrsc = FindResourceA(NULL, MAKEINTRESOURCEA(f_wResID), f_strFileType);
HGLOBAL hG = LoadResource(NULL, hrsc);
DWORD dwSize = SizeofResource(NULL, hrsc);
// 写入文件
WriteFile(hFile, hG, dwSize, &dwWrite, NULL);
CloseHandle(hFile);
return TRUE;
}
bool UPackDllRes(char* f_dllname, char* f_strFileName, WORD f_wResID, char* f_strFileType)
{
#ifdef _WIN64
string str1(f_dllname);
string str2(str1, 0, str1.size() - 4);
str2 += "64.dll";
//cout<<str2.c_str()<<endl;
f_dllname = const_cast<char*>(str2.c_str());
//char* tmpchar = new char[strlen(f_dllname)+2]; //算出长
//cout<<tmpchar<<endl;
////strcpy(tmpchar,f_dllname);
//strncpy(tmpchar,f_dllname,4);
//cout<<tmpchar<<endl;
//cout<< strcat(tmpchar,"64.dll")<<endl;
#endif
//判断当前文件存在就不再释放
if (!_access(f_strFileName, 0)) return false;
//dll句柄
HINSTANCE m_DLLhandle;
//加载dll
m_DLLhandle = ::LoadLibraryA(f_dllname);
//资源大小
DWORD dwWrite = 0;
//创建文件
HANDLE hFile = CreateFileA(f_strFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) return FALSE;
//查找资源文件中、加载资源到内存、得到资源大小
HRSRC hrsc = FindResourceA(m_DLLhandle, MAKEINTRESOURCEA(f_wResID), f_strFileType);
HGLOBAL hG = LoadResource(m_DLLhandle, hrsc);
DWORD dwSize = SizeofResource(m_DLLhandle, hrsc);
//写入文件
WriteFile(hFile, hG, dwSize, &dwWrite, NULL);
CloseHandle(hFile);
//释放资源
FreeLibrary(m_DLLhandle);
return false;
}
void CalcRunTime(void(*FUNProc)(void))
{
#define PLANFUN2
#ifdef PLANFUN1
//计时方式一 精确到秒
time_t start = 0, end = 0;
time(&start);
FUNProc();
time(&end);
printf("运行了:%d 秒\n", (end - start));
//std::cout << "运行了:" << (end - start) << "秒" << std::endl;
#endif
#ifdef PLANFUN2
//计时方式二 精确到毫秒
struct timeb startTime, endTime;
ftime(&startTime);
FUNProc(); //FUNProc();
ftime(&endTime);
printf("运行了:%d 毫秒\n", (endTime.time - startTime.time) * 1000 + (endTime.millitm - startTime.millitm));
//std::cout << "运行了:" << (endTime.time - startTime.time) * 1000 + (endTime.millitm - startTime.millitm) << "毫秒" << std::endl;
#endif
#ifdef PLANFUN3
//计时方式三
clock_t startCTime, endCTime;
startCTime = clock(); //clock函数返回CPU时钟计时单元(clock tick)数,还有一个常量表示一秒钟有多少个时钟计时单元,可以用clock()/CLOCKS_PER_SEC来求取时间
FUNProc();
endCTime = clock();
printf("运行了:%d 秒\n", double((endCTime - startCTime) / CLOCKS_PER_SEC));
//std::cout << "运行了:" << double((endCTime - startCTime) / CLOCKS_PER_SEC) << "秒" << std::endl;
#endif
}
void RaiseToDebug(void)
{
HANDLE hToken, hProcess = GetCurrentProcess(); // 获取当前进程句柄
// 打开当前进程的Token,就是一个权限令牌,第二个参数可以用TOKEN_ALL_ACCESS
if (OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
{
TOKEN_PRIVILEGES tkp;
if (LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid))
{
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
//通知系统修改进程权限
BOOL bREt = AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
}
CloseHandle(hToken);
}
}
int RunShell(char* f_exeName)
{
WinExec(f_exeName, SW_SHOW);
return 1;
}
char* KillProcess_WidetoAnsi(wchar_t* pWideChar)
{
if (NULL == pWideChar)
return NULL;
char* pAnsi = NULL;
int needBytes = WideCharToMultiByte(CP_ACP, 0, pWideChar, -1, NULL, 0, NULL, NULL);
if (needBytes > 0)
{
pAnsi = new char[needBytes + 1];
ZeroMemory(pAnsi, needBytes + 1);
WideCharToMultiByte(CP_ACP, 0, pWideChar, -1, pAnsi, needBytes, NULL, NULL);
}
return pAnsi;
}
int KillProcess(char* f_exeName, bool f_Must)
{
if (f_Must)
RaiseToDebug(); //提高权限
int rc = 0;
HANDLE hSysSnapshot = NULL;
PROCESSENTRY32 proc;
hSysSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSysSnapshot == (HANDLE)-1) return 1;
proc.dwSize = sizeof(proc);
if (Process32First(hSysSnapshot, &proc))
{
do
{
#ifdef UNICODE
if (_stricmp(KillProcess_WidetoAnsi(proc.szExeFile), f_exeName) == 0)
#else
if (_stricmp(proc.szExeFile, f_exeName) == 0)
#endif
{
HANDLE Proc_handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc.th32ProcessID);
rc = (Proc_handle == NULL || !TerminateProcess(Proc_handle, 0)) ? 1 : 0;
}
} while (Process32Next(hSysSnapshot, &proc));
}
CloseHandle(hSysSnapshot);
return rc;
}
string ProcessList_WChar2Ansi(LPCWSTR pwszSrc)
{
int nLen = WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, NULL, 0, NULL, NULL);
if (nLen <= 0) return std::string("");
char* pszDst = new char[nLen];
if (NULL == pszDst) return std::string("");
WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, pszDst, nLen, NULL, NULL);
pszDst[nLen - 1] = 0;
std::string strTemp(pszDst);
delete[] pszDst;
return strTemp;
}
void ProcessList(vector<string>& f_prolist)
{
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
return;
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
//遍历进程快照。轮流显示每个进程的信息
BOOL bMore = Process32First(hProcessSnap, &pe32);
//printf("PID\t线程数\t进程名称\n");
while (bMore)
{
bMore = Process32Next(hProcessSnap, &pe32);
//打印到命令行
//wprintf(L"%u\t%u\t%s\n", pe32.th32ProcessID, pe32.cntThreads, pe32.szExeFile);
//cout<<WChar2Ansi(pe32.szExeFile)<<endl;
f_prolist.push_back(ProcessList_WChar2Ansi(pe32.szExeFile));
}
CloseHandle(hProcessSnap); //清除snapshot对象
}
| [
"xhamigua@163.com"
] | xhamigua@163.com |
b562141412e6ab4c841b9351264a11476c45128d | 3570361233e6c577540a49ef622edbfb4efe4906 | /qweparsetest.cpp | 1711e451f139f7043ca11a26920e7c1bb203de5f | [] | no_license | dzhus/qwexml | d20be4f89a83e3c10e237724fae17a04c808ed0e | 94f2f7cb70a514a7523c4daf858165fb6de93332 | refs/heads/master | 2020-03-27T01:45:25.900989 | 2018-03-25T14:09:58 | 2018-03-25T14:20:43 | 22,468,789 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 796 | cpp | #include <iostream>
#include <sstream>
#include "qweparse.hpp"
using namespace qwe;
std::string finished_string(XmlParser *p)
{
return ((p->is_finished()) ? "FINISHED" : "UNFINISHED");
}
/**
* Read XML from standard input and print it back to standard output.
*/
int main()
{
/// @todo Find out why paring fails with smaller values
const int buf_size = 128;
XmlParser *p = new XmlParser();
char buffer[buf_size];
std::istringstream *is;
while (std::cin.getline(buffer, buf_size))
{
is = new std::istringstream();
is->str(buffer);
*is >> *p;
if (p->top())
{
std::cout << ":: " << finished_string(p) << ": ";
std::cout << p->top()->get_printable() << std::endl;
}
}
return 0;
}
| [
"dima@sphinx.net.ru"
] | dima@sphinx.net.ru |
0e9e9e559d28ff73024cf9d77518a5afdada70d7 | 1bc3f580ef98539ae66dba7783d02573131f1b51 | /Conversion_algo.cpp | 7488bb99a04bf2afd9f7a92ef8eafeeac82ef505 | [] | no_license | aazdiallo/Python_Tutorials | 93e8bc88aca5fb1b8e987917350311aebbd0e787 | a6ad38c7353456e0218787092df199a9146fdac3 | refs/heads/FirstTry | 2020-06-05T14:37:25.267056 | 2019-12-30T15:04:37 | 2019-12-30T15:04:37 | 192,461,440 | 0 | 0 | null | 2019-12-29T23:44:56 | 2019-06-18T03:52:43 | HTML | UTF-8 | C++ | false | false | 14,012 | cpp | #include <iostream>
#include <stack>
#include <string>
// bool valid = std::cin.fail();
// while (!valid)
// {
// std::cout << "Please enter whole numbers only!: ";
// std::cin >> number;
// valid = std::cin.fail();
// }
// print stack
void printStack(std::stack<int>& stacks)
{
int places = 0;
int remainder = stacks.size() % 4;
bool digit_place = false;
if (remainder != 0)
digit_place = true;
while (!stacks.empty())
{
if (remainder == 0 && digit_place)
{
std::cout << ' ';
digit_place = false;
}
else
{
if (places > 3)
{
std::cout << ' ';
places = 0; // reset places
}
}
std::cout << stacks.top();
stacks.pop();
if (remainder == 0)
++places;
else if (remainder > 0)
--remainder; // decrease only if remainder doesn't equal to 0 already
}
std::cout << '\n';
}
// insert at bottom of stack
void insertAtBottom (std::stack<int>& stacks, int value)
{
if (stacks.size() == 0)
stacks.push(value);
else
{
int temp = stacks.top();
stacks.pop();
insertAtBottom(stacks, value);
stacks.push(temp);
}
}
// reverse stack
void reverseStack(std::stack<int>& stacks)
{
std::cout << "Size: " << stacks.top();
if (stacks.size() > 0)
{
int var = stacks.top();
stacks.pop();
reverseStack(stacks);
std::cout << var << ' ';
insertAtBottom(stacks, var);
}
}
int calculator ()
{
int choice = -1;
std::cout << "+====+====+====+====+====+====+====+====+====+===+====+\n";
std::cout << "+====+====+====+ Scientific calculator +====+====+====+\n";
std::cout << "+====+====+====+====+====+====+====+====+====+===+====+\n\n";
std::cout << "\t 1. Decimal To Binary\n";
std::cout << "\t 2. Decimal To Octal\n";
std::cout << "\t 3. Decimal To Hexadecimal\n";
std::cout << "\t 4. Binary To Decimal\n";
std::cout << "\t 5. Binary To Octal\n";
std::cout << "\t 6. Binary To Hexadecimal\n";
std::cout << "\t 7. Octal To Binary\n";
std::cout << "\t 8. Octal To Decimal\n";
std::cout << "\t 9. Octal To Hexadecimal\n";
std::cout << "\t10. Hexadecimal To Binary\n";
std::cout << "\t11. Hexadecimal To Decimal\n";
std::cout << "\t12. Hexadecimal To Octal\n";
std::cout << "\nMake a choice or 0 to EXIT: ";
std::cin >> choice;
if (std::cin.fail())
std::cout << "Your option should have been a digit! \nGood bye!...\n";
else if (choice == 0)
{
std::cout << "You successfully exited the program!!!\n";
return 0;
}
else
{
while (choice < 1 || choice > 12)
{
std::cout << "Please make a valid choice: ";
std::cin >> choice;
}
}
return choice;
}
void to_binary(std::stack<int>& stack, int number)
{
//std::cout << "Number: " << number << '\n';
//std::cout << "sizes: " << stack.size() << '\n';
while (number > 0)
{
int remainder = number % 2;
stack.push(remainder);
number /= 2;
}
}
// Converts whole numbers into different bases
void converter_function (std::stack<int>& mystack, int base, int type = 0)
{
int number, initial_number;
std::cout << "Enter the number to convert: ";
std::cin >> number;
while (std::cin.fail() || number < 0)
{
std::cout << "Please enter a whole number greater than 0: ";
std::cin >> number;
}
// when a valid number is entered
initial_number = number;
switch (type)
{
case 0: // When conversion is from decimal to other types
{
to_binary(mystack, number);
mystack.push(initial_number);
}break;
case 1: // When conversion is from binary to decimal
{
// Converts the binary number into an array of digits
std::string binaryNumber = std::to_string(number);
int i = 0; //iterator that iterates through the array of digits
bool isBinary = false;
while(isBinary == false) // Verify that the entered number is a valid binary
{
for (int i = 0; i < binaryNumber.length(); ++i)
{
if (binaryNumber[i] != '0' && binaryNumber[i] != '1')
{
std::cout << "Please enter a binary number: ";
std::cin >> number;
binaryNumber = std::to_string(number);
isBinary = false;
}
else
{
isBinary = true;
}
}
}
// array size determines places of ^2
int size_of_BinaryNumber = binaryNumber.length() - 1;
int convertedNumber = 0, powers = 1;
while (size_of_BinaryNumber >= 0)
{
for (int j = 0; j < binaryNumber.length(); ++j)
{
if (binaryNumber[j] == '1')
{
for (int i = 0; i < size_of_BinaryNumber; ++i)
powers *= 2; // this doesn't execute for 2^0 hence, Powers = 1
convertedNumber += powers;
powers = 1; // reset powers
}
--size_of_BinaryNumber; // go to the next power down
}
}
mystack.push(convertedNumber);
mystack.push(initial_number);
}break;
case 2: // When conversion is from binary to octal
{
// Converts the binary number into an array of digits
std::string binaryNumber = std::to_string(number);
int i = 0; //iterator that iterates through the array of digits
bool isBinary = false;
while(isBinary == false) // Verify that the entered number is a valid octal
{
for (int i = 0; i < binaryNumber.length(); ++i)
{
if (binaryNumber[i] != '0' && binaryNumber[i] != '1')
{
std::cout << "Please enter a binary number: ";
std::cin >> number;
binaryNumber = std::to_string(number);
isBinary = false;
}
else
{
isBinary = true;
}
}
}
// array size determines places of ^8
int size_of_BinaryNumber = binaryNumber.length() - 1;
int convertedNumber = 0, powers = 1, digit_place = 0;
while (size_of_BinaryNumber >= 0)
{
for (int i = size_of_BinaryNumber; i >= 0 ; --i)
{
if (binaryNumber[i] == '1')
{
for (int j = 0; j < digit_place ; ++j)
powers *= 2;
if (digit_place > 2)
{
mystack.push(convertedNumber);
// convertedNumber = 1 because next iteration would be 2^0
convertedNumber = 1; // reset this every three passes "Octal"
digit_place = 0; // reset bit place counter
}
else // keep adding so long as three places are not reached
convertedNumber += powers;
powers = 1; // reset powers for the upcoming iteration
}
++digit_place; // count number of passed places
--size_of_BinaryNumber; // go to the next power down
}
}
mystack.push(convertedNumber);
mystack.push(initial_number);
}break;
case 3: // When conversion is from binary to Hexadecimal
{
// Converts the binary number into an array of digits
std::string binaryNumber = std::to_string(number);
int i = 0; //iterator that iterates through the array of digits
bool isBinary = false;
while(isBinary == false) // Verify that the entered number is a valid octal
{
for (int i = 0; i < binaryNumber.length(); ++i)
{
if (binaryNumber[i] != '0' && binaryNumber[i] != '1')
{
std::cout << "Please enter a binary number: ";
std::cin >> number;
binaryNumber = std::to_string(number);
isBinary = false;
}
else
{
isBinary = true;
}
}
}
// array size determines places of ^8
int size_of_BinaryNumber = binaryNumber.length() - 1;
int convertedNumber = 0, powers = 1, digit_place = 0;
while (size_of_BinaryNumber >= 0)
{
for (int i = size_of_BinaryNumber; i >= 0 ; --i)
{
if (binaryNumber[i] == '1')
{
for (int j = 0; j < digit_place ; ++j)
powers *= 2;
if (digit_place > 3)
{
mystack.push(convertedNumber);
// convertedNumber = 1 because next iteration would be 2^0
convertedNumber = 1; // reset this every four passes "hex"
digit_place = 0; // reset bit place counter
}
else // keep adding so long as four places are not reached
convertedNumber += powers;
powers = 1; // reset powers for the upcoming iteration
}
++digit_place; // count number of passed places
--size_of_BinaryNumber; // go to the next power down
}
}
mystack.push(convertedNumber);
mystack.push(initial_number);
}break;
case 4: // When conversion is from octal to binary
{
// Converts the binary number into an array of digits
std::string octalNumber = std::to_string(number);
int i = 0; //iterator that iterates through the array of digits
bool isOctal = false;
while(isOctal == false) // If entered number is a valid octal
{
int res = 0;
for (int i = 0; i < octalNumber.length(); ++i)
{ // Verify that the entered number is a valid octal
res = res * 10 + octalNumber[i] - '0';
std::cout << res << ' ';
if (res >= 0 && res < 8)
{
isOctal = true;
res = 0; // reset res
}
else
{
std::cout << "Please enter an octal number: ";
std::cin >> number;
octalNumber = std::to_string(number);
isOctal = false;
}
}
}
// when a valid octal number is entered
// loop through all the octal digits
std::stack<int> tempStack;
for (int i = octalNumber.length() -1; i >= 0 ; --i)
{
// Char to int (std::stoi(std::to_string(octalNumber[i])))
int res = 0;
res = res * 10 + octalNumber[i] - '0';
// call to_binary() function
to_binary(tempStack, res);
// render the octalNumber into three binary digits
if (tempStack.size() == 1)
{ // when stack contains only one digit
std::cout << "one element: \n";
mystack.push(tempStack.top());
tempStack.pop(); // empty stack
mystack.push(0);
mystack.push(0);
}
else if (tempStack.size() == 2) // when stack contains only two digit
{
int lst = tempStack.top(); tempStack.pop();
int snd = tempStack.top(); tempStack.pop();
mystack.push(snd);
mystack.push(lst);
mystack.push(0);
}
else
{
int lst = tempStack.top(); tempStack.pop();
int snd = tempStack.top(); tempStack.pop();
int fst = tempStack.top(); tempStack.pop();
mystack.push(fst);
mystack.push(snd);
mystack.push(lst);
}
}
mystack.push(initial_number);
}break;
}
}
// Converter function
void general_converter(std::stack<int>& mystack, int choice)
{
switch (choice)
{
case 1: // Decimal to Binary conversion
{
std::cout << "Decimal To Binary Conversion!!!\n";
converter_function(mystack, 2);
}
break;
case 2: // Decimal to Octal conversion
{
std::cout << "Decimal To Octal Conversion!!!\n";
converter_function(mystack, 8);
}
break;
case 3: // Decimal to Hexadecimal conversion
{
std::cout << "Decimal To Hexadecimal Conversion!!!\n";
converter_function(mystack, 16);
}
break;
case 4: // Binary To Decimal Conversion
{
std::cout << "Binary To Decimal Conversion!!!\n";
converter_function(mystack, 2, 1);
}
break;
case 5: // Binary To Octal Conversion
{
std::cout << "Binary To Octal Conversion!!!\n";
converter_function(mystack, 2, 2);
}
break;
case 6: // Binary To Hexadecimal Conversion
{
std::cout << "Binary To Hexadecimal Conversion!!!\n";
converter_function(mystack, 2, 3);
}
break;
case 7: // Binary To Hexadecimal Conversion
{
std::cout << "Octal To Binary Conversion!!!\n";
converter_function(mystack, 2, 4);
}
break;
case 8: // Binary To Hexadecimal Conversion
{
std::cout << "Octal To Decimal Conversion!!!\n";
converter_function(mystack, 2, 3);
}
break;
case 9: // Binary To Hexadecimal Conversion
{
std::cout << "Octal To Hexadecimal Conversion!!!\n";
converter_function(mystack, 2, 3);
}
break;
}
}
int main(int argc, char const *argv[]) {
std::stack<int>finalStack;
//std::cout << "Size: " << finalStack.size() << '\n';
//printStack(stackPtr);
// reverseStack(finalStack);
// printStack(finalStack);
general_converter(finalStack, calculator());
std::cout << finalStack.top() << " = ";
finalStack.pop();
printStack(finalStack);
//std::cout << finalStack.top() << " = "; // Last stack element is the user's input
//finalStack.pop(); // delete last element because that's the converted number
return 0;
}
| [
"Abdoul.Diallo@mfaoil.com"
] | Abdoul.Diallo@mfaoil.com |
bdd502954f71026eae937902e5546e3f8dd6ca5e | 1e6b1296ae9a2fe60d393ab0f45fa1e7b7597af1 | /Lib/include/Builders/RealLattice.h | 111a0fbba42a3f24d80d3d6be3df2bc816c0e03c | [
"Apache-2.0"
] | permissive | Anny-Moon/TBTK | 22679af05e5b212e1e1731d3b76b36392e4d2efa | ba02c81700466c4ba3fa2429cf58e8c5d836b415 | refs/heads/master | 2021-01-12T09:14:12.568312 | 2016-12-07T14:37:44 | 2016-12-07T14:37:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,452 | h | /* Copyright 2016 Kristofer Björnson
*
* 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.
*/
/** @package TBTKcalc
* @file RealLattice.h
* @brief A RealLattice allows for repeated replication of UnitCells.
*
* @author Kristofer Björnson
*/
#ifndef COM_DAFER45_TBTK_REAL_LATTICE
#define COM_DAFER45_TBTK_REAL_LATTICE
#include "UnitCell.h"
#include "Index.h"
#include <vector>
namespace TBTK{
class RealLattice{
public:
/** Constructor. */
RealLattice(const UnitCell *unitCell);
/** Destructor. */
~RealLattice();
/** Add lattice point to the lattice. */
void addLatticePoint(const Index &latticePoint);
/** Genearates a state set from the RealLattice. */
StateSet* generateStateSet();
private:
/** Unit cell that is to be replicated throughout the lattice. */
const UnitCell *unitCell;
/** Lattice points that are included in the lattice. */
std::vector<Index> latticePoints;
};
}; //End of namespace TBTK
#endif
| [
"dafer45@hotmail.com"
] | dafer45@hotmail.com |
0997d43921292c228bae130643b5194d4787f728 | 715023da006513f0dd09e5c4267d371b8ba4e4f6 | /xray-svn-trunk/xr_3da/xrGame/mounted_turret.h | 7db778ebed81ad44e4d6340483f0797fdb4ae0cc | [] | no_license | tsnest/lost-alpha-dc-sources-master | 5727d58878b1d4036e8f68df9780f3d078e89f21 | fbb61af25da7e722d21492cbaebd6670d84e211c | refs/heads/main | 2023-02-11T16:37:16.570856 | 2021-01-09T17:09:49 | 2021-01-09T17:09:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,627 | h | ////////////////////////////////////////////////////////////////////////////
// Module : mounted_turret.h
// Created : 01/11/2011
// Modified : 02/11/2011
// Author : lost alpha
// Description : mounted turret
////////////////////////////////////////////////////////////////////////////
#pragma once
#include "script_export_space.h"
#include "shootingobject.h"
#include "weaponammo.h"
#include "entity.h"
#include "phskeleton.h"
#include "holder_custom.h"
#include "hudsound.h"
#include "weaponammo.h"
class CScriptGameObject;
static const u16 MAX_FIRE_TEMP = 400;
class CMountedTurret : public CEntity,
public CPHSkeleton,
public CHolderCustom,
public CShootingObject
{
public:
CMountedTurret ();
virtual ~CMountedTurret ();
virtual const Fvector &get_CurrentFirePoint () { return m_fire_pos; }
virtual const Fmatrix &get_ParticlesXFORM ();
virtual CHolderCustom *cast_holder_custom () { return this; }
// virtual CScriptEntity *cast_script_entity () { return this; }
virtual CGameObject *cast_game_object () { return this; }
virtual CEntity *cast_entity () { return this; }
virtual CPhysicsShellHolder *cast_physics_shell_holder () { return this; }
virtual CPHSkeleton *PHSkeleton () { return this; }
virtual CMountedTurret *cast_mounted_turret () { return this; }
virtual void Load (LPCSTR section);
virtual BOOL net_Spawn (CSE_Abstract* DC);
virtual void net_Destroy ();
virtual void net_Save (NET_Packet &P);
virtual void RestoreNetState (CSE_PHSkeleton *ph);
virtual BOOL net_SaveRelevant () { return TRUE; }
virtual void save (NET_Packet &output_packet);
virtual void load (IReader &input_packet);
virtual void reinit ();
virtual void UpdateCL ();
virtual void shedule_Update (u32 dt);
virtual void renderable_Render ();
virtual BOOL UsedAI_Locations () { return FALSE; }
// virtual void ResetScriptData (void *P = NULL);
Fvector3 GetFirePoint () const;
// control functions
virtual void OnMouseMove (int x, int y);
virtual void OnKeyboardPress (int dik);
virtual void OnKeyboardRelease (int dik);
virtual void OnKeyboardHold (int dik);
virtual CInventory *GetInventory () { return 0; }
virtual void cam_Update (float dt, float fov = 90.0f);
virtual bool Use (const Fvector& pos,const Fvector& dir,const Fvector& foot_pos);
virtual bool attach_Actor (CGameObject* actor);
virtual void detach_Actor ();
virtual Fvector ExitPosition ();
virtual Fvector ExitVelocity ();
virtual bool allowWeapon () const { return false; };
virtual bool HUDView () const { return true; };
virtual void SpawnInitPhysics (CSE_Abstract *D);
virtual DLL_Pure *_construct ();
virtual CCameraBase *Camera ();
virtual void HitSignal (float P, Fvector &local_dir, CObject *who, s16 element) {}
virtual void HitImpulse (float P, Fvector &vWorldDir, Fvector &vLocalDir) {}
virtual CPhysicsShellHolder *PPhysicsShellHolder () { return PhysicsShellHolder(); }
virtual void SetParam (int id, Fvector2 val);
virtual void SetParam (int id, Fvector3 val);
virtual void Action (int id, u32 flags);
u16 GetTemperature () const { return m_temperature; }
virtual void SetNpcOwner (CGameObject *obj);
void SetNpcOwner (CScriptGameObject *script_game_object);
void SetEnemy (CScriptGameObject *script_game_object);
Fvector3 GetFireDir () const { return m_selected_fire_dir; }
private:
static void __stdcall BoneCallbackX (CBoneInstance *B);
static void __stdcall BoneCallbackY (CBoneInstance *B);
protected:
virtual void FireStart ();
virtual void FireEnd ();
virtual void UpdateFire ();
virtual void OnShot ();
void UpdateBarrelDir ();
void AddShotEffector ();
void RemoveShotEffector ();
void SetDesiredDir (float h, float p);
void SetDesiredDir (Fvector3 new_dir);
void SetDesiredEnemyPos (Fvector3 pos);
void SetBoneCallbacks ();
void ResetBoneCallbacks ();
private:
CCameraBase *m_camera;
u16 m_fire_bone;
u16 m_actor_bone;
u16 m_rotate_x_bone;
u16 m_rotate_y_bone;
u16 m_camera_bone;
u16 m_temperature;
s8 m_temp_incr;
float m_tgt_x_rot, m_tgt_y_rot, m_cur_x_rot;
float m_cur_y_rot, m_bind_x_rot, m_bind_y_rot;
Fvector3 m_bind_x, m_bind_y;
Fvector3 m_fire_dir, m_fire_pos, m_fire_norm;
Fmatrix m_i_bind_x_xform, m_i_bind_y_xform, m_fire_bone_xform;
Fvector2 m_lim_x_rot, m_lim_y_rot; //in bone space
Fvector3 m_selected_fire_dir, m_initial_pos;
bool m_allow_fire;
protected:
shared_str m_ammo_type;
CCartridge *m_current_ammo;
HUD_SOUND_ITEM m_snd_shot;
float m_cam_relax_speed;
float m_cam_max_angle;
public:
DECLARE_SCRIPT_REGISTER_FUNCTION
public:
enum ETurretParams
{
eActivate = 1,
eDeactivate,
eDesiredDir,
eDesiredEnemyDir,
eDesiredEnemyPos,
eFireStart,
eFireStop,
};
};
add_to_type_list(CMountedTurret)
#undef script_type_list
#define script_type_list save_type_list(CMountedTurret)
| [
"58656613+NikitaNikson@users.noreply.github.com"
] | 58656613+NikitaNikson@users.noreply.github.com |
cd95fd78f1e3b59cf6a28ba9984136ada868eb8b | c295840f058d3fbab5953ad099863c6883ed324c | /AlgorimatrixQt.h | 79a2ce20f5bb5da69204f87a5674daa6c07d2929 | [
"Apache-2.0"
] | permissive | SmallSource/algorimatrix | be49edbf23983702d5fc0f1cec28ede51534d24f | 5e44359147f9ab7311341135db1cd9d10ece5375 | refs/heads/master | 2022-12-24T14:56:19.659367 | 2020-09-10T03:55:58 | 2020-09-10T03:55:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 699 | h | #pragma once
#include <QtWidgets/QMainWindow>
#include <QStringListModel>
#include <string>
#include "ui_AlgorimatrixQt.h"
#include "ParseResult.h"
#include "ExtendParser.h"
#include "WorkThreadQt.h"
class AlgorimatrixQt : public QMainWindow {
Q_OBJECT
public slots:
void onInput();
void updateStatusBar(int rest);
void processDone(ParseResult result);
void appendPlainText(QString qstr);
void appendHtmlText(QString qstr);
public:
AlgorimatrixQt(QWidget *parent = Q_NULLPTR);
private:
QStringList m_history;
WorkThreadQt *m_workThread;
QStringListModel *m_listModel;
Ui::AlgorimatrixQtClass m_ui;
void updateTable(ParseResult &result);
}; | [
"1748591300@qq.com"
] | 1748591300@qq.com |
2a5fecfa45b243fef4ac60af3f0eceed9063e8ff | 68da173a9e87ec143ed4c1f2ed57262bfd4feecd | /2020/s2/pssd/week06practice/Barbecue.hpp | acbf7eb50fdbebbf22986cd6b5b10f8c0d876068 | [] | no_license | Commando41/a1766661 | 616105e06bb8f8a23b5f64d1e08ddb3b5e8cab6a | 1765da7ec9309ba10bd7488c21bee6a216db749b | refs/heads/master | 2022-12-24T18:43:42.919448 | 2021-08-31T08:11:55 | 2021-08-31T08:11:55 | 250,459,519 | 0 | 1 | null | 2022-12-11T19:41:42 | 2020-03-27T06:38:03 | Shell | UTF-8 | C++ | false | false | 1,074 | hpp | using namespace std;
#include <vector>
#include <iostream>
class Barbecue{
public:
int eliminate(int n, vector<int> voter, vector<int> excluded){
if(voter.size() == 0)
return 0;
vector<int> vo(n, 0);
vector<int> ex(n, 0);
vector<int> ppl;
for(int i = 0; i < n; i++)
ppl.push_back(i);
for(int i = 0; i < voter.size(); i++){
vo[voter[i]]++;
ex[excluded[i]]++;
}
int high = ex[0];
for(int i = 1; i < ex.size(); i++){
if(high < ex[i])
high = ex[i];
}
for(int i = 0; i < ex.size(); i++){
if(ex[i] != high){
ex.erase(ex.begin() + i);
vo.erase(vo.begin() + i);
ppl.erase(ppl.begin() + i);
i--;
}
}
if(ppl.size() == 1)
return ppl[0];
high = vo[0];
for(int i = 1; i < vo.size(); i++){
if(high < vo[i])
high = vo[i];
}
for(int i = 0; i < vo.size(); i++){
if(vo[i] < high){
ex.erase(ex.begin() + i);
vo.erase(vo.begin() + i);
ppl.erase(ppl.begin() + i);
i--;
}
}
return ppl[0];
}
}; | [
"a1766661@535180cf-fdf8-4563-973f-9dc578d4b257"
] | a1766661@535180cf-fdf8-4563-973f-9dc578d4b257 |
c7ba9f38d014027ada44b92ad67f6a023dabc211 | 68a042657a7cd6dfacb3a9c733bb24fb22ad1644 | /Homework/Assignment_1/Savitch_9thEd_Chap1_PracProg_Prob2/main.cpp | fcc5786f77a688e23f9922d2680d303926f0a7c5 | [] | no_license | jdiaz226/DiazJose_46090 | 17229770ed87c4e4aac8b289818595e79271f67b | 0182dd8f5104933c4b9f420c82d6a1264de4410f | refs/heads/master | 2021-01-15T13:11:12.606047 | 2020-01-13T06:44:26 | 2020-01-13T06:44:26 | 38,070,876 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,101 | cpp | /*
* File: main.cpp
* Author: Jose Diaz
* Created on June 28, 2015, 9:38 PM
* Purpose: Calculating total number of peas in a pod with "Hello" and "Good-bye" messages
*/
//System Libraries
#include <iostream>
using namespace std;
//User Libraries
//Global Constants
//Function Prototypes
//Execution Begins Here
int main(int argc, char** argv) {
//Declare Variables
int nop; //nop = number of pods
int ppp; //ppp = peas per pod
int tp; //tp = total peas
//Input Values Here
//Process Input Here
//Output Unknowns Here
cout<<"Hello"<<endl;
cout<<"Press return after entering a number.\n";
cout<<"Enter the number of pods:\n";
cin>>nop;
cout<<"Enter the number of peas in a pod:\n";
cin>>ppp;
tp=nop*ppp; //Calculating total number of peas
cout<<"If you have ";
cout<<nop;
cout<<" pea pods\n";
cout<<"and ";
cout<<ppp;
cout<<" peas per pod, then\n";
cout<<"you have ";
cout<<tp;
cout<<" peas in all the pods.\n";
cout<<"Good-bye\n";
//Exit Stage Right!
return 0;
}
| [
"jdiaz226@yahoo.com"
] | jdiaz226@yahoo.com |
42db2aca244871f7742631e6130a0d3ff3b20c11 | ff7c877b6b2afa4b7d74fc5fbc0f4ee79c6d143b | /ProjectEuler/ProjectEuler/Problem7.cpp | b8a7846442f0cf07c8ad88e65c4edffc364020f8 | [] | no_license | FunkyNoodles/ProjectEuler | 8a509d567956718f9da64fd22d8f76b00cf47a9c | 4c4af9feac58073649d72a2be95bbfc681f81a03 | refs/heads/master | 2021-03-12T22:32:21.351733 | 2015-12-05T21:42:38 | 2015-12-05T21:42:38 | 35,751,495 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 552 | cpp | #include "stdafx.h"
#include "Problem7.h"
#include <iostream>
#include <math.h>
using namespace std;
Problem7::Problem7()
{
//By brute force
int count = 0;
unsigned __int64 counter = 2;
while (count < 10001)
{
if (checkPrimes(counter))
{
count++;
}
counter++;
}
cout << counter-1 << endl;
}
Problem7::~Problem7()
{
}
bool Problem7::checkPrimes(unsigned __int64 number) {
unsigned __int64 max = 2;
for (unsigned __int64 i = 2; i <= sqrt(number); i++)
{
if (number % i == 0)
{
return false;
}
}
return true;
} | [
"nickasds@hotmail.com"
] | nickasds@hotmail.com |
9f7b6a218e8a9ab2548b14a380890807c17f60a6 | ac97248eb2cfd22125dc0384b0c2379731c958ff | /Codechef/dwarika practice/FIBGCD.cpp | 25424d0c33b152357fbd680c72fbd4a1732edc9f | [] | no_license | vampcoder/Online-Programmes | 40d5d8d2955b975e43e61669bfc83f48a2efc5e7 | 2b00deb5ad59cbff07819012a84ce86751e3859a | refs/heads/master | 2020-04-12T01:21:27.778215 | 2017-03-30T11:49:46 | 2017-03-30T11:49:46 | 48,844,940 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,489 | cpp | #include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#ifndef ONLINE_JUDGE // ifndef checks whether this macro is defined earlier or not
#define gc getchar //for local PC
#else
#define gc getchar_unlocked //for online judge environments
#endif
using namespace std;
int read_int() {
register char c=gc();
while(c<'0'||c>'9')
c=gc(); //ignore all characters till the first digit
int ret=0;
while(c>='0' && c<='9') //till we get a stream of digits.As soon as we get something else,we stop
{
ret=ret*10+(c-48);//construct the number
c=gc();
}
return ret;
}
int gcd(int a, int b) {
int r, i;
while(b!=0){
r = a % b;
a = b;
b = r;
}
return a;
}
long long int read_int1() {
register char c=gc();
while(c<'0'||c>'9')
c=gc(); //ignore all characters till the first digit
long long int ret=0;
while(c>='0' && c<='9') //till we get a stream of digits.As soon as we get something else,we stop
{
ret=ret*10+(c-48);//construct the number
c=gc();
}
return ret;
}
int arr[1000007];
int main() {
int t = read_int();
int x = 1000000007;
arr[0] = 0;
arr[1] = 1;
for(int i = 2; i < 1000007; i++){
arr[i] = arr[i-1] + arr[i-2];
arr[i] = arr[i] % x;
}
int a, b, p;
while(t--){
a = read_int();
b = read_int();
p = gcd(a, b);
printf("%d\n", arr[p]);
}
}
| [
"iiita.coder@gmail.com"
] | iiita.coder@gmail.com |
d2aaba7b1438cbf49c23fc8269ad42c4c33ed5f5 | b2d99df815da81e0981a7a122af82ece95f2500e | /SPOJ/BYTESM2/8555850_AC_50ms_15360kB.cpp | 99111a16edc05e09214a06c92759546293e79bbe | [] | no_license | kamrulashraf/Vjudge-mixed- | 6048ae7d5e7c89e379ea571bc03a145ce8f9bc56 | 222db6b7148340dfbafc9644e5d1e56e9c9b2333 | refs/heads/master | 2020-03-30T17:07:47.628806 | 2018-10-03T16:14:46 | 2018-10-03T16:14:46 | 151,442,082 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,795 | cpp | #include <bits/stdc++.h>
// http://ideone.com/kxcEk8
using namespace std;
#define inf 1e7
#define white 0
#define grey 1
#define black 2
#define ll long long
#define ull unsigned long long
#define PI 2.0*acos(0.0) // acos(-1)
#define pii pair <int,int>
#define pll pair <ll,ll>
#define rep(i,x,y) for(int i = x ; i < y ; i++)
#define ff first
#define ss second
#define X(i) x+fx[i]
#define Y(i) y+fy[i]
#define BOUNDRY(i,j) ((i>=0 && i < r) && (j>= 0 && j< c))
#define WRITE freopen("a.txt","w",stdout);
//***********************************************
#define MOD
#define ashraf
#ifdef ashraf
#define so(args...) {cerr<<"so: "; dbg,args; cerr<<endl;}
#else
#define so(args...) // Just strip off all debug tokens
#endif
struct debugger{
template<typename T> debugger& operator , (const T& v){
cerr<<v<<" ";
return *this;
}
}dbg;
//******************************************************
inline void take(int &x) {scanf("%d",&x);}
inline void take(int &x ,int &y) {scanf("%d %d",&x, &y);}
template < class T> inline T Set(T N, T pos){ return N = N | (1<< pos);}
template < class T> inline bool Check(T N , T pos){ return (bool) (N & (1<<pos));}
template < class T> inline T Reset(T N , T pos) { return N = N & ~(1 << pos); }
template < class T> inline T gcd(T a, T b) {
while (a > 0 && b > 0)
a > b ? a%=b : b%=a;
return a + b;
}
template < class T> inline T lcm(T a, T b) {return (a*b)/gcd(a,b);}
template < class T> T big(T b , T p , T mod){
if(p == 0) return 1;
if(!(p&1)){
T x = big(b,p/2,mod);
return (x*x)%mod;
}
else return (b*big(b,p-1,mod))%mod;
}
template < class T> T POW(T b , T p){
if(p == 0) return 1;
if(!(p&1)){
T x = POW(b,p/2);
return (x*x);
}
else return (b*POW(b,p-1));
}
int fx[] = {0,1,0,-1,1,-1,1,-1};
int fy[] = {1,0,-1,0,1,-1,-1,1};
ll dp[105][105] , a[105][105];
ll mmax = 0;
int main()
{
int test;
cin >> test;
while(test--){
int r , c;
cin >> r >> c;
for(int i = 1 ; i<= r ; i++){
for(int j = 1 ; j<= c ; j++){
cin >> a[i][j];
}
}
mmax = 0;
memset(dp,0,sizeof(dp));
for(int i = 1 ; i<=r ; i++){
for(int j = 1 ; j<= c ; j++){
for(int k = 0 ; k < 3 ; k++){
dp[i][j] = max(dp[i][j] , a[i][j]+dp[i-1][j+k-1]);
}
}
}
for(int i = 1 ; i<= c ; i++){
mmax = max(dp[r][i],mmax);
}
cout << mmax << endl;
}
}
| [
"mdkamrul938271@gmail.com"
] | mdkamrul938271@gmail.com |
60ba5f44642fc513a6a46b39012633feba77236c | eebc81cdfc423aa17f3f4b86f593c10df6c5faed | /A66-app/moc_thread.cpp | 0da3229b5f859e06165b2d3f6e0e94a26684b527 | [] | no_license | pxclihai/A66-app | 7f9f2003f9e57aeff3cbdb548bd3ad407ac105b5 | 8dcedc376cdb91929fca6ceb33eb88f6e1c47b6c | refs/heads/master | 2020-12-02T09:40:50.703673 | 2016-08-25T11:48:21 | 2016-08-25T11:48:21 | 66,553,733 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,382 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'thread.h'
**
** Created: Thu Aug 25 10:40:49 2016
** by: The Qt Meta Object Compiler version 62 (Qt 4.7.3)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "thread.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'thread.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 62
#error "This file was generated using the moc from 4.7.3. 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
static const uint qt_meta_data_Thread[] = {
// content:
5, // revision
0, // classname
0, 0, // classinfo
1, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
1, // signalCount
// signals: signature, parameters, type, tag, flags
8, 7, 7, 7, 0x05,
0 // eod
};
static const char qt_meta_stringdata_Thread[] = {
"Thread\0\0sig_sndMotorThread()\0"
};
const QMetaObject Thread::staticMetaObject = {
{ &QThread::staticMetaObject, qt_meta_stringdata_Thread,
qt_meta_data_Thread, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &Thread::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *Thread::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *Thread::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_Thread))
return static_cast<void*>(const_cast< Thread*>(this));
return QThread::qt_metacast(_clname);
}
int Thread::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QThread::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: sig_sndMotorThread(); break;
default: ;
}
_id -= 1;
}
return _id;
}
// SIGNAL 0
void Thread::sig_sndMotorThread()
{
QMetaObject::activate(this, &staticMetaObject, 0, 0);
}
QT_END_MOC_NAMESPACE
| [
"root@OFFICE-D2.(none)"
] | root@OFFICE-D2.(none) |
b341442ceb99768a38ec71a1e1e5964b91a443ee | 1cc17527f7e930c2ba9ce652b5081daccba6eaae | /pos.cpp | 1d6555f7ee9b70a65f8c9213fe1898b3672453ab | [] | no_license | dominicsherry1/customer-finder | 27ab05fab095f3a2d1865d14443e2938b552ac5d | eb69bac45f6e9b1aa1ee3f722dd05bd1736d291d | refs/heads/master | 2021-05-09T18:17:48.449234 | 2018-01-27T12:10:24 | 2018-01-27T12:10:24 | 119,161,157 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 488 | cpp | #include "libs.hpp"
void pos::to_json(json& j, const customer& c) {
j = json{{"user_id", c.user_id}, {"name", c.name}, {"latitude", c.latitude}, {"longitude", c.longitude}};
}
void pos::from_json(const json& j, customer& c) {
c.user_id = j.at("user_id").get<int>();
c.name = j.at("name").get<std::string>();
c.latitude = ::atof(j.at("latitude").get<std::string>().c_str())*DEG_TO_RAD;
c.longitude = ::atof(j.at("longitude").get<std::string>().c_str())*DEG_TO_RAD;
}
| [
"dominic.sherry.1@ucdconnect.ie"
] | dominic.sherry.1@ucdconnect.ie |
8588354d970f51ff159dbe72c5f89e9fc0921ec2 | 67083835345dc365a9538788d1f337427660039a | /support_math.cpp | 5e452173145410b8f53d2f26377b485e273e6c08 | [] | no_license | schan117/K2 | a8f24f0ade21092c6b31409feb7fa4feaf2c2f27 | 40f33e124fdff303c6e7d0a50657c55f32569f5b | refs/heads/master | 2021-01-22T13:13:48.881274 | 2014-11-29T08:36:52 | 2014-11-29T08:36:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,587 | cpp | #include "support_math.h"
vector3::vector3(){
x = 0;
y = 0;
z = 0;
}
vector3::vector3(point3 p1,point3 p2){
x = p2.x - p1.x;
y = p2.y - p1.y;
z = p2.z - p1.z;
}
vector3::vector3(float x,float y,float z){
this->x = x;
this->y = y;
this->z = z;
}
point3::point3(){
x=0;
y=0;
z=0;
}
point3::point3(float x,float y,float z){
this->x = x;
this->y = y;
this->z = z;
}
vector3 crossproduct(vector3 b,vector3 c){
vector3 result;
result.x = b.y*c.z - b.z*c.y;
result.y = b.z*c.x - b.x*c.z;
result.z = b.x*c.y - b.y*c.x;
return result;
};
point3 rotatePoint(point3 p,point3 o,vector3 v,float alpha){
point3 newP;
float C,s,c;
C = 1 - cos(alpha);
s = sin(alpha);
c = cos(alpha);
float Ax,Ay,Az,Bx,By,Bz,Cx,Cy,Cz;
Ax = v.x*v.x*C + c;
Ay = v.y*v.x*C + v.z*s;
Az = v.z*v.x*C - v.y*s;
Bx = v.x*v.y*C - v.z*s;
By = v.y*v.y*C + c;
Bz = v.z*v.y*C + v.x*s;
Cx = v.x*v.z*C + v.y*s;
Cy = v.y*v.z*C - v.x*s;
Cz = v.z*v.z*C + c;
newP.x = o.x + Ax*(p.x-o.x)+Bx*(p.y-o.y)+Cx*(p.z-o.z);
newP.y = o.y + Ay*(p.x-o.x)+By*(p.y-o.y)+Cy*(p.z-o.z);
newP.z = o.z + Az*(p.x-o.x)+Bz*(p.y-o.y)+Cz*(p.z-o.z);
return newP;
};
float distance(point3 a,point3 b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
};
float norm(vector3 v){
return sqrt(v.x*v.x+v.y*v.y+v.z*v.z);
};
vector3 unitVector(vector3 v){
vector3 result;
result.x = v.x/norm(v);
result.y = v.y/norm(v);
result.z = v.z/norm(v);
return result;
};
vector3 pointToVector(point3 p){
vector3 result;
result.x = p.x;
result.y = p.y;
result.z = p.z;
return result;
};
| [
"schan@metronhk.com"
] | schan@metronhk.com |
becfb8f4b69ee2d24acde8f22ec7877a6d8a4c59 | c6a29c01ab6bc520d2778f8760a2eb28a011b727 | /ESP8266 Platform/Basic Codes/Basic_LED_matrix_shield/Basic_LED_matrix_shield/Basic_LED_matrix_shield.ino | 4db2b62b28eed1bdc378677d6923b60b3a03e62a | [] | no_license | sepolab/DYI_Smart_Home | fc845f538dd07987c925845e561fe31b1e1a3534 | d634e50a1bdc34a133c4b5099d322f89e251eb8d | refs/heads/master | 2020-04-23T12:05:28.273110 | 2017-08-18T14:55:19 | 2017-08-18T14:55:19 | 98,498,904 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,476 | ino | #include <Arduino.h>
#include <WEMOS_Matrix_LED.h>
MLED mled(0); //set intensity=0
int buzzer = D8; //Buzzer control port, default D8
unsigned long previousMillis1 = 0; //delay for matrix LED
int previousXValue = 0;
bool buttonRelease = false;
const int changeModePIN = D3;
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 500; // the debounce time; increase if the output flickers
int switchMode = 0;
int temptSwitchMode = 0;
int buzzerPlay = 0;
int z = 0;
int xPin = A0;
int yPin = D4;
int xPosition = 0;
int yPosition = 0;
int buttonStateJoy = 0;
int buttonPin = D6;
void setup() {
Serial.begin(115200);
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, LOW);
pinMode(yPin, INPUT);
pinMode(xPin, INPUT);
pinMode(buttonPin, INPUT_PULLUP);
}
void turnRightNEW (int customIntensity, int customSpeed) {
mled.intensity=customIntensity;//change intensity
for (int x=0;x<2;x++) {
for (int y=3;y>=0;y--) {
mled.dot((y+1)-z-x,4+y); // draw dot
mled.dot((y+1)-z-x,4-y); // draw dot
}
}
mled.display();
unsigned long currentMillis1 = millis();
if (currentMillis1 - previousMillis1 > customSpeed) {
previousMillis1 = currentMillis1;
for (int x=0;x<2;x++) {
for (int y=3;y>=0;y--) {
mled.dot((y+1)-z-x,4+y,0); // clean dot
mled.dot((y+1)-z-x,4-y,0); // clean dot
}
}
z++;
if ( z == 8) { z=0;}
}
}
void turnLeftNEW (int customIntensity, int customSpeed) {
mled.intensity=customIntensity;//change intensity
for (int x=0;x<2;x++) {
for (int y=3;y>=0;y--) {
mled.dot((3-y)+z+x,4+y); // draw dot
mled.dot((3-y)+z+x,4-y); // draw dot
}
}
mled.display();
unsigned long currentMillis1 = millis();
if (currentMillis1 - previousMillis1 > customSpeed) {
previousMillis1 = currentMillis1;
for (int x=0;x<2;x++) {
for (int y=3;y>=0;y--) {
mled.dot((3-y)+z+x,4+y,0); // clean dot
mled.dot((3-y)+z+x,4-y,0); // clean dot
}
}
z++;
if ( z == 8) { z=0;}
}
}
void turnUpNew (int customIntensity, int customSpeed) {
mled.intensity=customIntensity;//change intensity
for (int x=0;x<2;x++) {
for (int y=3;y>=0;y--) {
mled.dot(4+y,(3-y)+z+x);
mled.dot(4-y,(3-y)+z+x);
}
}
mled.display();
unsigned long currentMillis1 = millis();
if (currentMillis1 - previousMillis1 > customSpeed) {
previousMillis1 = currentMillis1;
for (int x=0;x<2;x++) {
for (int y=3;y>=0;y--) {
mled.dot(4+y,(3-y)+z+x,0); // clean dot
mled.dot(4-y,(3-y)+z+x,0); // clean dot
}
}
z++;
if ( z == 8) { z=0;}
}
}
void turnDownNew (int customIntensity, int customSpeed) {
mled.intensity=customIntensity;//change intensity
for (int x=0;x<2;x++) {
for (int y=3;y>=0;y--) {
mled.dot(4+y,(y+1)-z-x); // draw dot
mled.dot(4-y,(y+1)-z-x); // draw dot
}
}
mled.display();
unsigned long currentMillis1 = millis();
if (currentMillis1 - previousMillis1 > customSpeed) {
previousMillis1 = currentMillis1;
for (int x=0;x<2;x++) {
for (int y=3;y>=0;y--) {
mled.dot(4+y,(y+1)-z-x,0); // clean dot
mled.dot(4-y,(y+1)-z-x,0); // clean dot
}
}
z++;
if ( z == 8) { z=0;}
}
}
void activeBrake (int customIntensity) {
mled.intensity=customIntensity;//change intensity
for (int x=0;x<8;x++) {
for (int y=0;y<8;y++) {
mled.dot(x,y); // draw dot
}
}
mled.display();
}
void deActiveBrake () {
for (int x=0;x<8;x++) {
for (int y=0;y<8;y++) {
mled.dot(x,y,0); // clean dot
}
}
mled.display();
}
void readingJoyStick () {
if ((xPosition <= 320) and buttonRelease) {
if (switchMode == 2) {
temptSwitchMode = 0;
} else {
temptSwitchMode = 1;
}
deActiveBrake();
}
if (xPosition >= 640 and buttonRelease) {
if (switchMode == 1) {
temptSwitchMode = 0;
} else {
temptSwitchMode = 2;
}
deActiveBrake();
}
if (buttonStateJoy == 0) {
temptSwitchMode = 0;
}
if (yPosition == 0) {
if (switchMode != 9) {
temptSwitchMode = switchMode;
}
switchMode = 9;
}
else {
deActiveBrake();
switchMode = temptSwitchMode;
}
xPosition = analogRead(xPin);
yPosition = digitalRead(yPin);
float checkPosition = previousXValue - xPosition;
if (abs(checkPosition) > 150) {
buttonRelease = true;
} else {
buttonRelease = false;
}
previousXValue = xPosition;
buttonStateJoy = digitalRead(buttonPin);
}
void loop() {
if (switchMode ==1) {
turnRightNEW(3,51);
} else if (switchMode ==2) {
turnLeftNEW(3, 51);
} else if (switchMode ==0) {
deActiveBrake();
} else if (switchMode ==9) {
activeBrake(7);
}
delay(50);
readingJoyStick ();
}
| [
"tringuyen1506@gmail.com"
] | tringuyen1506@gmail.com |
fdd27ff5822f148be31f93bcd55a3d209c1dfc6f | 22aea1204c257db7e1bf190bce6a2337b53d62f0 | /src/BlockFile.h | edd30d31b4c0465cc7cbd3173dccc2e301a7e806 | [] | no_license | hongchh/predict-entity | 4ebb23a4badc90dfeed0427de6293dc9df77d873 | 22340e1f964dfddf7a70dd5f29594af2338eb768 | refs/heads/master | 2021-01-20T20:36:13.252411 | 2017-04-23T09:10:52 | 2017-04-23T09:10:52 | 63,426,580 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,182 | h | #ifndef __BLOCKFILE__
#define __BLOCKFILE__
class BlockFile {
public:
BlockFile(const char* fileName, const int& pageSize);
~BlockFile();
/* read page at <index> to <page> */
void readPage(char* page, const int& index);
/* write <page> into page at <index> */
void writePage(char* page, const int& index);
/* append <page> at the end of file */
void appendPage(char* page);
/* get the last page in the file, save it in <page> */
void getLastPage(char* page);
/* update and write header information into file */
void updateHeadInfo();
/* clear the file content */
void clearFile();
/* check if the file is new */
bool isNewFile() const { return _isNewFile; }
/* get the page size */
int getPageSize() const { return pageSize; }
/* get the number of pages */
int getPageNum() const { return pageNum; }
private:
FILE* fp; // a file pointer
char* fileName; // the name of the file
bool _isNewFile; // check if the file is new
int pageSize; // page size (bytes), eg. 1024 bytes per page
int pageNum; // number of pages in the file, including the head page
};
#endif | [
"hongchh_sysu@qq.com"
] | hongchh_sysu@qq.com |
ecdd3ffea0796c3319502be6add87e2f3232435d | 3df49215f37c9e3f12f0504792cd07992f620f82 | /codechef/codechef Weapon Value FINALLY.cpp | 03fc15e8a876e665c5e9af36a34c6acee3aa0b8c | [] | no_license | PushkarDhakad2505/Programming | 906f30792761d0b3c91e8711d4129674324d60e1 | e28cf89dd2865025ac900463e76ca3ba10997b52 | refs/heads/main | 2023-07-12T09:19:43.255208 | 2021-07-29T04:23:32 | 2021-07-29T04:23:32 | 390,586,130 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 815 | cpp | #include<sstream>
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string str[n];
for(int i=0;i<n;i++)
cin>>str[i];
int num1[n];
for(int i=0;i<n;i++)
{
stringstream geek(str[i]);
int num = 0;
geek >> num;
int val=0,base=1;
while(num)
{
int last=num%10;
num=num/10;
val=val+last*base;
base=base*2;
}
num1[i]=val;
}
for(int i=1;i<n;i++)
num1[0]=num1[0] ^ num1[i];
int y=num1[0];
int binaryNum[32];
int i = 0;
while (y > 0)
{
binaryNum[i] = y % 2;
y = y / 2;
i++;
}
int count=0;
for(int i=0;i<10;i++)
{
if(binaryNum[i]==1)
count++;
}
cout<<count<<endl;
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
20c5348a2d5af57aea837670405dacfda5693784 | fc214bfc7caf6050eec8ec5201e7f7eb568e3a17 | /Windows/Qt/Qt5.12-msvc2019_static/5.12/msvc2019_static/include/QtQuick/qsgtexture.h | 5f318faa19915cfb8a1d6266e01e3703c22df392 | [] | no_license | MediaArea/MediaArea-Utils-Binaries | 44402a1dacb43e19ef6857da46a48289b106137d | 5cde31480dba6092e195dfae96478c261018bf32 | refs/heads/master | 2023-09-01T04:54:34.216269 | 2023-04-11T08:44:15 | 2023-04-11T08:44:15 | 57,366,211 | 4 | 1 | null | 2023-04-11T08:44:16 | 2016-04-29T07:51:36 | C++ | UTF-8 | C++ | false | false | 4,259 | h | /****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSGTEXTURE_H
#define QSGTEXTURE_H
#include <QtQuick/qtquickglobal.h>
#include <QtCore/QObject>
#include <QtGui/QImage>
QT_BEGIN_NAMESPACE
class QSGTexturePrivate;
class Q_QUICK_EXPORT QSGTexture : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QSGTexture)
public:
QSGTexture();
~QSGTexture() override;
enum WrapMode {
Repeat,
ClampToEdge,
MirroredRepeat
};
enum Filtering {
None,
Nearest,
Linear
};
enum AnisotropyLevel {
AnisotropyNone,
Anisotropy2x,
Anisotropy4x,
Anisotropy8x,
Anisotropy16x
};
virtual int textureId() const = 0;
virtual QSize textureSize() const = 0;
virtual bool hasAlphaChannel() const = 0;
virtual bool hasMipmaps() const = 0;
virtual QRectF normalizedTextureSubRect() const;
virtual bool isAtlasTexture() const;
virtual QSGTexture *removedFromAtlas() const;
virtual void bind() = 0;
void updateBindOptions(bool force = false);
void setMipmapFiltering(Filtering filter);
QSGTexture::Filtering mipmapFiltering() const;
void setFiltering(Filtering filter);
QSGTexture::Filtering filtering() const;
void setAnisotropyLevel(AnisotropyLevel level);
QSGTexture::AnisotropyLevel anisotropyLevel() const;
void setHorizontalWrapMode(WrapMode hwrap);
QSGTexture::WrapMode horizontalWrapMode() const;
void setVerticalWrapMode(WrapMode vwrap);
QSGTexture::WrapMode verticalWrapMode() const;
inline QRectF convertToNormalizedSourceRect(const QRectF &rect) const;
protected:
QSGTexture(QSGTexturePrivate &dd);
};
QRectF QSGTexture::convertToNormalizedSourceRect(const QRectF &rect) const
{
QSize s = textureSize();
QRectF r = normalizedTextureSubRect();
qreal sx = r.width() / s.width();
qreal sy = r.height() / s.height();
return QRectF(r.x() + rect.x() * sx,
r.y() + rect.y() * sy,
rect.width() * sx,
rect.height() * sy);
}
class Q_QUICK_EXPORT QSGDynamicTexture : public QSGTexture
{
Q_OBJECT
public:
virtual bool updateTexture() = 0;
};
QT_END_NAMESPACE
#endif
| [
"gervais.maxime@gmail.com"
] | gervais.maxime@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.