blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
247
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 4
111
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
58
| visit_date
timestamp[ns]date 2015-07-25 18:16:41
2023-09-06 10:45:08
| revision_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| github_id
int64 3.89k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 25
values | gha_event_created_at
timestamp[ns]date 2012-06-07 00:51:45
2023-09-14 21:58:52
⌀ | gha_created_at
timestamp[ns]date 2008-03-27 23:40:48
2023-08-24 19:49:39
⌀ | gha_language
stringclasses 159
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
10.5M
| extension
stringclasses 111
values | filename
stringlengths 1
195
| text
stringlengths 7
10.5M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f334d4e79645e5aeb30785ff54a94d0fba0c4d27
|
37851bf986918e7529e7f221e883184ea3f87289
|
/TracerService.cpp
|
f5fa635c4d4cce5cad4757229c4eeee049b66b0f
|
[] |
no_license
|
Hydrotoast/WashingMachineSimulation
|
dc7d6624995476b13cbf6a5df4decc39d308e4e0
|
2a5babee334ac7548855f63b68a8fbf093fbbfe7
|
refs/heads/master
| 2021-01-19T00:12:06.820034
| 2014-03-13T07:35:46
| 2014-03-13T07:35:46
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 629
|
cpp
|
TracerService.cpp
|
#include "TracerService.h"
#include <sstream>
using namespace std;
void TracerService::log(discrete_time::time_point time, string message) {
string timeStr = formatTime(time);
string delim = " - ";
cout << timeStr << delim << message << endl;
cout.flush();
}
string TracerService::formatTime(discrete_time::time_point time) {
ostringstream oss;
unsigned int hrs = time / 3600u;
unsigned int mins = (time / 60u) % 60u;
unsigned int secs = time % 60u;
oss.fill('0');
oss.width(2);
oss << hrs << ":";
oss.fill('0');
oss.width(2);
oss << mins << ":";
oss.fill('0');
oss.width(2);
oss << secs;
return oss.str();
}
|
877d7b94cbc7e165f3d8ec55b9f282fef602c5cd
|
5d29aca40103012977a0a4eb0d3be02bd58e24f4
|
/c++后端开发/WebServer-master/code/buffer/buffer.h
|
90db7a4eb29d7d01b69bbd8dcb2738dce0a30273
|
[
"Apache-2.0"
] |
permissive
|
wangjunstf/computer-system
|
c03e0170cfe0cd1b423ae1afad601c41e360ff19
|
e4da8caf8614f6b6cac05ee317c0346717886f19
|
refs/heads/main
| 2023-08-18T07:44:59.198700
| 2021-10-14T12:27:42
| 2021-10-14T12:27:42
| 361,100,742
| 3
| 0
| null | 2021-09-08T09:13:56
| 2021-04-24T07:39:27
| null |
UTF-8
|
C++
| false
| false
| 1,348
|
h
|
buffer.h
|
#ifndef BUFFER_H
#define BUFFER_H
#include <cstring> //perror
#include <iostream>
#include <unistd.h> // write
#include <sys/uio.h> //readv
#include <vector> //readv
#include <atomic>
#include <assert.h>
class Buffer {
public:
Buffer(int initBuffSize = 1024);
~Buffer() = default;
size_t WritableBytes() const;
size_t ReadableBytes() const ;
size_t PrependableBytes() const;
const char* Peek() const;
void EnsureWriteable(size_t len);
void HasWritten(size_t len);
void Retrieve(size_t len);
void RetrieveUntil(const char* end);
void RetrieveAll() ;
std::string RetrieveAllToStr();
const char* BeginWriteConst() const;
char* BeginWrite();
void Append(const std::string& str);
void Append(const char* str, size_t len);
void Append(const void* data, size_t len);
void Append(const Buffer& buff);
ssize_t ReadFd(int fd, int* Errno);
ssize_t WriteFd(int fd, int* Errno);
private:
char* BeginPtr_(); // 获取内存起始位置
const char* BeginPtr_() const; // 获取内存起始位置
void MakeSpace_(size_t len); // 创建空间
std::vector<char> buffer_; // 具体装数据的vector
std::atomic<std::size_t> readPos_; // 读的位置
std::atomic<std::size_t> writePos_; // 写的位置
};
#endif //BUFFER_H
|
c78677bb69d4954862f142ad331f6bdfd705e779
|
edb124700cfea12419370d99346e1bf6b8c480b6
|
/Vec4.hpp
|
557effedd4997de854235b53c604048f57555b83
|
[] |
no_license
|
AyoubOuarrak/Caffeina
|
d43b4808599a2d23061748d94f4e28aafed38ada
|
b5326c33d5473b8a7f3a75418ccd832afd9914b2
|
refs/heads/master
| 2020-05-20T13:21:56.210507
| 2015-04-06T00:19:41
| 2015-04-06T00:19:41
| 33,387,006
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,224
|
hpp
|
Vec4.hpp
|
/*
* Copyright (C) 2014 Ayoub Ouarrak, ouarrakayoub@gmail.com
*
* This file is part of Caffeina.
*
* Caffeina is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version. Caffeina 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 Caffeina. If not, see http://www.gnu.org/licenses/.
*/
#ifndef VEC4_GUARD_HH
#define VEC4_GUARD_HH
namespace Caffeina {
template <class T>
class Vec4 {
private:
T _x;
T _y;
T _z;
T _w;
public:
// default constructor
Vec4();
// copy constructor
Vec4(const Vec4&);
// constructor of three parameters
Vec4(const T& x, const T& y, const T& z, const T& w);
// destructor
~Vec4();
T x() const;
T y() const;
T z() const;
T w() const;
T norm() const;
// add a value to all component of this
void add(const T&, const T&, const T&, const T&);
// set all component of this to 0
void zero();
// normalize the vector, after this operation all component are in the range [-1, 1]
void normalize();
// static method to convert Vec4 to the T
static T* convert(const Vec4&);
// static method to calculate the dot product between two vector (return a scalar value)
static T dotProduct(const Vec4&, const Vec4&);
// static method to return the distance between two vectors in 3D space
static T distance(const Vec4&, const Vec4&);
// overload operators
Vec4& operator=(const Vec4&);
Vec4 operator+(const Vec4&) const;
Vec4 operator-(const Vec4&) const;
Vec4 operator*(const Vec4&) const;
Vec4 operator*(const T&) const;
Vec4 operator/(const T&) const;
void operator*=(const T&);
void operator-=(const Vec4&);
void operator+=(const Vec4&);
void operator/=(const T&);
};
} // namespace Caffeina
#include "Vec4.cpp"
#endif
|
51a04f3f11134f0ce9a329300cb2488edb957ccf
|
c4d6f65be488d4f3945b8f47b7c805fa956f677d
|
/main.cpp
|
ba93e80ab8070c8df17afacf2a0f9331f345d633
|
[] |
no_license
|
AlejandroIV/prct2EstrcDts
|
0ecd357bf031dcb418c325d8b8195473df2b3ebd
|
7513b11045e8ae3473f0bcfb919b633da6e8771d
|
refs/heads/master
| 2023-08-24T09:14:40.925617
| 2021-09-23T09:04:22
| 2021-09-23T09:04:22
| 409,519,441
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,024
|
cpp
|
main.cpp
|
/**
* @file main.cpp
*
* Codigo para extraer numeros enteros de un documento, aplicar el algoritmo "MergeSort" en una lista doblemente enlazada
* y para escribir en un archivo de texto el contenido de la lista
*
* @author Alejandro Delgado Rivera <AlejandroDR_IV@Outlook.com>
* @version 1.0
* @date 23/09/2021
*/
#include"leerArchivo.h"
int main()
{
string nombre;
cout << "Escribe el nombre del archivo con los datos de entrada (con extension): ";
cin >> nombre;
cin.clear();
cin.ignore(1000, '\n');
// Abre el archivo
Archivo arch(nombre);
// Crea la cadena con los numeros del documento
arch.contarNumerosYCrearCadenaNumeros();
// Declara la lista doblemente ligada que contendra los elementos extraidos del documento de texto
ListaDoble<int> lista;
// Declaracion de indices que reccoreran la cadena y de dos contadores
int l, r, cont, digitos;
l = r = cont = digitos = 0;
// Cadena que contendra cada numero en formato "str" para convertirlo a "int"
string numero = "";
string cadenaDeNumeros = arch.getCadenaNumeros();
// Arreglo que contendra todos los numeros extraidos del documento
int arregloNumeros[arch.getCantNum()];
// Bucle que se repetira hasta que el indice "r" llegue al indice final de la cadena
while(r < cadenaDeNumeros.length()) {
// Si no se ha llegado al final del numero
if(cadenaDeNumeros[r] != 'x') {
r++;
}
// Si ya se llego al final del numero
else {
// Bucle que copia el numero en formato "str"
while(l < r) {
numero += cadenaDeNumeros[l];
l++;
digitos++;
}
// Agrega el elemento al arreglo
arregloNumeros[cont] = strToInt(numero, digitos);
// Pasa al indice donde comienza un nuevo numero
r++;
l++;
// Borra los valores de "numero" y "digitos" para un nuevo numero
numero = "";
digitos = 0;
cont++;
}
}
// Agrega los nodos con los valores almacenados en el arreglo "arregloNumeros" a la lista "lista"
int cont2 = 0;
while(cont > cont2) {
lista.listInsert(arregloNumeros[cont2]);
cont2++;
}
cont = 0;
unsigned short int opcion = 0;
cout << "\nElija una de las siguientes opciones\n" << endl;
do {
if(cont == 0) {
cout << "1 - Aplicar MergeSort a la lista" << endl;
}
cout << "2 - Mostrar el contenido de la lista (si la lista es muy grande es posible que no se vean todos los elementos)" << endl;
cout << "3 - Escribir el contenido de la lista en un documento de texto" << endl;
cout << "0 - Salir" << endl;
cout << "Opcion: ";
cin >> opcion;
cin.clear();
cin.ignore(1000, '\n');
cout << endl;
switch(opcion) {
case 1:
if(cont == 0) {
mergeSort(lista.getCabezaDireccion());
cont++;
opcion++;
}
system("clear");
cout << endl;
cout << "Lista ordenada" << endl;
cout << endl;
break;
case 2:
lista.imprimirLista();
break;
case 3:
cout << "Escribe el nombre del archivo con los datos de salida (sin extension): ";
cin >> nombre;
cin.clear();
cin.ignore(1000, '\n');
lista.escribirArrDocTxt(nombre + ".txt");
system("clear");
cout << endl;
cout << "Archivo creado" << endl;
cout << endl;
break;
default:
continue;
break;
}
} while(opcion > cont && opcion < 4);
system("clear");
system("pause");
return 0;
}
|
89a21f8fc6146360210b43f2f2766cb8f1311c58
|
1f63dde39fcc5f8be29f2acb947c41f1b6f1683e
|
/Boss2D/addon/_old/webrtc-qt5.11.2_for_boss/modules/audio_coding/neteq/delay_manager_unittest.cc
|
e32d24e426a6b452b66453348e5099204ca7ae00
|
[
"LicenseRef-scancode-google-patent-license-webrtc",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"GPL-1.0-or-later",
"LicenseRef-scancode-takuya-ooura",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown",
"MS-LPL",
"MIT",
"LicenseRef-scancode-google-patent-license-webm"
] |
permissive
|
koobonil/Boss2D
|
09ca948823e0df5a5a53b64a10033c4f3665483a
|
e5eb355b57228a701495f2660f137bd05628c202
|
refs/heads/master
| 2022-10-20T09:02:51.341143
| 2019-07-18T02:13:44
| 2019-07-18T02:13:44
| 105,999,368
| 7
| 2
|
MIT
| 2022-10-04T23:31:12
| 2017-10-06T11:57:07
|
C++
|
UTF-8
|
C++
| false
| false
| 16,486
|
cc
|
delay_manager_unittest.cc
|
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
// Unit tests for DelayManager class.
#include "modules/audio_coding/neteq/delay_manager.h"
#include <math.h>
#include "modules/audio_coding/neteq/mock/mock_delay_peak_detector.h"
#include "test/gmock.h"
#include BOSS_WEBRTC_U_test__gtest_h //original-code:"test/gtest.h"
namespace webrtc {
using ::testing::Return;
using ::testing::_;
class DelayManagerTest : public ::testing::Test {
protected:
static const int kMaxNumberOfPackets = 240;
static const int kTimeStepMs = 10;
static const int kFs = 8000;
static const int kFrameSizeMs = 20;
static const int kTsIncrement = kFrameSizeMs * kFs / 1000;
DelayManagerTest();
virtual void SetUp();
virtual void TearDown();
void SetPacketAudioLength(int lengt_ms);
void InsertNextPacket();
void IncreaseTime(int inc_ms);
DelayManager* dm_;
TickTimer tick_timer_;
MockDelayPeakDetector detector_;
uint16_t seq_no_;
uint32_t ts_;
};
DelayManagerTest::DelayManagerTest()
: dm_(NULL), detector_(&tick_timer_), seq_no_(0x1234), ts_(0x12345678) {}
void DelayManagerTest::SetUp() {
EXPECT_CALL(detector_, Reset())
.Times(1);
dm_ = new DelayManager(kMaxNumberOfPackets, &detector_, &tick_timer_);
}
void DelayManagerTest::SetPacketAudioLength(int lengt_ms) {
EXPECT_CALL(detector_, SetPacketAudioLength(lengt_ms));
dm_->SetPacketAudioLength(lengt_ms);
}
void DelayManagerTest::InsertNextPacket() {
EXPECT_EQ(0, dm_->Update(seq_no_, ts_, kFs));
seq_no_ += 1;
ts_ += kTsIncrement;
}
void DelayManagerTest::IncreaseTime(int inc_ms) {
for (int t = 0; t < inc_ms; t += kTimeStepMs) {
tick_timer_.Increment();
}
}
void DelayManagerTest::TearDown() {
EXPECT_CALL(detector_, Die());
delete dm_;
}
TEST_F(DelayManagerTest, CreateAndDestroy) {
// Nothing to do here. The test fixture creates and destroys the DelayManager
// object.
}
TEST_F(DelayManagerTest, VectorInitialization) {
const DelayManager::IATVector& vec = dm_->iat_vector();
double sum = 0.0;
for (size_t i = 0; i < vec.size(); i++) {
EXPECT_NEAR(ldexp(pow(0.5, static_cast<int>(i + 1)), 30), vec[i], 65537);
// Tolerance 65537 in Q30 corresponds to a delta of approximately 0.00006.
sum += vec[i];
}
EXPECT_EQ(1 << 30, static_cast<int>(sum)); // Should be 1 in Q30.
}
TEST_F(DelayManagerTest, SetPacketAudioLength) {
const int kLengthMs = 30;
// Expect DelayManager to pass on the new length to the detector object.
EXPECT_CALL(detector_, SetPacketAudioLength(kLengthMs))
.Times(1);
EXPECT_EQ(0, dm_->SetPacketAudioLength(kLengthMs));
EXPECT_EQ(-1, dm_->SetPacketAudioLength(-1)); // Illegal parameter value.
}
TEST_F(DelayManagerTest, PeakFound) {
// Expect DelayManager to pass on the question to the detector.
// Call twice, and let the detector return true the first time and false the
// second time.
EXPECT_CALL(detector_, peak_found())
.WillOnce(Return(true))
.WillOnce(Return(false));
EXPECT_TRUE(dm_->PeakFound());
EXPECT_FALSE(dm_->PeakFound());
}
TEST_F(DelayManagerTest, UpdateNormal) {
SetPacketAudioLength(kFrameSizeMs);
// First packet arrival.
InsertNextPacket();
// Advance time by one frame size.
IncreaseTime(kFrameSizeMs);
// Second packet arrival.
// Expect detector update method to be called once with inter-arrival time
// equal to 1 packet, and (base) target level equal to 1 as well.
// Return false to indicate no peaks found.
EXPECT_CALL(detector_, Update(1, 1))
.WillOnce(Return(false));
InsertNextPacket();
EXPECT_EQ(1 << 8, dm_->TargetLevel()); // In Q8.
EXPECT_EQ(1, dm_->base_target_level());
int lower, higher;
dm_->BufferLimits(&lower, &higher);
// Expect |lower| to be 75% of target level, and |higher| to be target level,
// but also at least 20 ms higher than |lower|, which is the limiting case
// here.
EXPECT_EQ((1 << 8) * 3 / 4, lower);
EXPECT_EQ(lower + (20 << 8) / kFrameSizeMs, higher);
}
TEST_F(DelayManagerTest, UpdateLongInterArrivalTime) {
SetPacketAudioLength(kFrameSizeMs);
// First packet arrival.
InsertNextPacket();
// Advance time by two frame size.
IncreaseTime(2 * kFrameSizeMs);
// Second packet arrival.
// Expect detector update method to be called once with inter-arrival time
// equal to 1 packet, and (base) target level equal to 1 as well.
// Return false to indicate no peaks found.
EXPECT_CALL(detector_, Update(2, 2))
.WillOnce(Return(false));
InsertNextPacket();
EXPECT_EQ(2 << 8, dm_->TargetLevel()); // In Q8.
EXPECT_EQ(2, dm_->base_target_level());
int lower, higher;
dm_->BufferLimits(&lower, &higher);
// Expect |lower| to be 75% of target level, and |higher| to be target level,
// but also at least 20 ms higher than |lower|, which is the limiting case
// here.
EXPECT_EQ((2 << 8) * 3 / 4, lower);
EXPECT_EQ(lower + (20 << 8) / kFrameSizeMs, higher);
}
TEST_F(DelayManagerTest, UpdatePeakFound) {
SetPacketAudioLength(kFrameSizeMs);
// First packet arrival.
InsertNextPacket();
// Advance time by one frame size.
IncreaseTime(kFrameSizeMs);
// Second packet arrival.
// Expect detector update method to be called once with inter-arrival time
// equal to 1 packet, and (base) target level equal to 1 as well.
// Return true to indicate that peaks are found. Let the peak height be 5.
EXPECT_CALL(detector_, Update(1, 1))
.WillOnce(Return(true));
EXPECT_CALL(detector_, MaxPeakHeight())
.WillOnce(Return(5));
InsertNextPacket();
EXPECT_EQ(5 << 8, dm_->TargetLevel());
EXPECT_EQ(1, dm_->base_target_level()); // Base target level is w/o peaks.
int lower, higher;
dm_->BufferLimits(&lower, &higher);
// Expect |lower| to be 75% of target level, and |higher| to be target level.
EXPECT_EQ((5 << 8) * 3 / 4, lower);
EXPECT_EQ(5 << 8, higher);
}
TEST_F(DelayManagerTest, TargetDelay) {
SetPacketAudioLength(kFrameSizeMs);
// First packet arrival.
InsertNextPacket();
// Advance time by one frame size.
IncreaseTime(kFrameSizeMs);
// Second packet arrival.
// Expect detector update method to be called once with inter-arrival time
// equal to 1 packet, and (base) target level equal to 1 as well.
// Return false to indicate no peaks found.
EXPECT_CALL(detector_, Update(1, 1))
.WillOnce(Return(false));
InsertNextPacket();
const int kExpectedTarget = 1;
EXPECT_EQ(kExpectedTarget << 8, dm_->TargetLevel()); // In Q8.
EXPECT_EQ(1, dm_->base_target_level());
int lower, higher;
dm_->BufferLimits(&lower, &higher);
// Expect |lower| to be 75% of base target level, and |higher| to be
// lower + 20 ms headroom.
EXPECT_EQ((1 << 8) * 3 / 4, lower);
EXPECT_EQ(lower + (20 << 8) / kFrameSizeMs, higher);
}
TEST_F(DelayManagerTest, MaxAndRequiredDelay) {
const int kExpectedTarget = 5;
const int kTimeIncrement = kExpectedTarget * kFrameSizeMs;
SetPacketAudioLength(kFrameSizeMs);
// First packet arrival.
InsertNextPacket();
// Second packet arrival.
// Expect detector update method to be called once with inter-arrival time
// equal to |kExpectedTarget| packet. Return true to indicate peaks found.
EXPECT_CALL(detector_, Update(kExpectedTarget, _))
.WillRepeatedly(Return(true));
EXPECT_CALL(detector_, MaxPeakHeight())
.WillRepeatedly(Return(kExpectedTarget));
IncreaseTime(kTimeIncrement);
InsertNextPacket();
// No limit is set.
EXPECT_EQ(kExpectedTarget << 8, dm_->TargetLevel());
int kMaxDelayPackets = kExpectedTarget - 2;
int kMaxDelayMs = kMaxDelayPackets * kFrameSizeMs;
EXPECT_TRUE(dm_->SetMaximumDelay(kMaxDelayMs));
IncreaseTime(kTimeIncrement);
InsertNextPacket();
EXPECT_EQ(kExpectedTarget * kFrameSizeMs, dm_->least_required_delay_ms());
EXPECT_EQ(kMaxDelayPackets << 8, dm_->TargetLevel());
// Target level at least should be one packet.
EXPECT_FALSE(dm_->SetMaximumDelay(kFrameSizeMs - 1));
}
TEST_F(DelayManagerTest, MinAndRequiredDelay) {
const int kExpectedTarget = 5;
const int kTimeIncrement = kExpectedTarget * kFrameSizeMs;
SetPacketAudioLength(kFrameSizeMs);
// First packet arrival.
InsertNextPacket();
// Second packet arrival.
// Expect detector update method to be called once with inter-arrival time
// equal to |kExpectedTarget| packet. Return true to indicate peaks found.
EXPECT_CALL(detector_, Update(kExpectedTarget, _))
.WillRepeatedly(Return(true));
EXPECT_CALL(detector_, MaxPeakHeight())
.WillRepeatedly(Return(kExpectedTarget));
IncreaseTime(kTimeIncrement);
InsertNextPacket();
// No limit is applied.
EXPECT_EQ(kExpectedTarget << 8, dm_->TargetLevel());
int kMinDelayPackets = kExpectedTarget + 2;
int kMinDelayMs = kMinDelayPackets * kFrameSizeMs;
dm_->SetMinimumDelay(kMinDelayMs);
IncreaseTime(kTimeIncrement);
InsertNextPacket();
EXPECT_EQ(kExpectedTarget * kFrameSizeMs, dm_->least_required_delay_ms());
EXPECT_EQ(kMinDelayPackets << 8, dm_->TargetLevel());
}
// Tests that skipped sequence numbers (simulating empty packets) are handled
// correctly.
TEST_F(DelayManagerTest, EmptyPacketsReported) {
SetPacketAudioLength(kFrameSizeMs);
// First packet arrival.
InsertNextPacket();
// Advance time by one frame size.
IncreaseTime(kFrameSizeMs);
// Advance the sequence number by 5, simulating that 5 empty packets were
// received, but never inserted.
seq_no_ += 10;
for (int j = 0; j < 10; ++j) {
dm_->RegisterEmptyPacket();
}
// Second packet arrival.
// Expect detector update method to be called once with inter-arrival time
// equal to 1 packet, and (base) target level equal to 1 as well.
// Return false to indicate no peaks found.
EXPECT_CALL(detector_, Update(1, 1)).WillOnce(Return(false));
InsertNextPacket();
EXPECT_EQ(1 << 8, dm_->TargetLevel()); // In Q8.
}
// Same as above, but do not call RegisterEmptyPacket. Observe the target level
// increase dramatically.
TEST_F(DelayManagerTest, EmptyPacketsNotReported) {
SetPacketAudioLength(kFrameSizeMs);
// First packet arrival.
InsertNextPacket();
// Advance time by one frame size.
IncreaseTime(kFrameSizeMs);
// Advance the sequence number by 5, simulating that 5 empty packets were
// received, but never inserted.
seq_no_ += 10;
// Second packet arrival.
// Expect detector update method to be called once with inter-arrival time
// equal to 1 packet, and (base) target level equal to 1 as well.
// Return false to indicate no peaks found.
EXPECT_CALL(detector_, Update(10, 10)).WillOnce(Return(false));
InsertNextPacket();
// Note 10 times higher target value.
EXPECT_EQ(10 * 1 << 8, dm_->TargetLevel()); // In Q8.
}
TEST_F(DelayManagerTest, Failures) {
// Wrong sample rate.
EXPECT_EQ(-1, dm_->Update(0, 0, -1));
// Wrong packet size.
EXPECT_EQ(-1, dm_->SetPacketAudioLength(0));
EXPECT_EQ(-1, dm_->SetPacketAudioLength(-1));
// Minimum delay higher than a maximum delay is not accepted.
EXPECT_TRUE(dm_->SetMaximumDelay(10));
EXPECT_FALSE(dm_->SetMinimumDelay(20));
// Maximum delay less than minimum delay is not accepted.
EXPECT_TRUE(dm_->SetMaximumDelay(100));
EXPECT_TRUE(dm_->SetMinimumDelay(80));
EXPECT_FALSE(dm_->SetMaximumDelay(60));
}
// Test if the histogram is stretched correctly if the packet size is decreased.
TEST(DelayManagerIATScalingTest, StretchTest) {
using IATVector = DelayManager::IATVector;
// Test a straightforward 60ms to 20ms change.
IATVector iat = {12, 0, 0, 0, 0, 0};
IATVector expected_result = {4, 4, 4, 0, 0, 0};
IATVector stretched_iat = DelayManager::ScaleHistogram(iat, 60, 20);
EXPECT_EQ(stretched_iat, expected_result);
// Test an example where the last bin in the stretched histogram should
// contain the sum of the elements that don't fit into the new histogram.
iat = {18, 15, 12, 9, 6, 3, 0};
expected_result = {6, 6, 6, 5, 5, 5, 30};
stretched_iat = DelayManager::ScaleHistogram(iat, 60, 20);
EXPECT_EQ(stretched_iat, expected_result);
// Test a 120ms to 60ms change.
iat = {18, 16, 14, 4, 0};
expected_result = {9, 9, 8, 8, 18};
stretched_iat = DelayManager::ScaleHistogram(iat, 120, 60);
EXPECT_EQ(stretched_iat, expected_result);
// Test a 120ms to 20ms change.
iat = {19, 12, 0, 0, 0, 0, 0, 0};
expected_result = {3, 3, 3, 3, 3, 3, 2, 11};
stretched_iat = DelayManager::ScaleHistogram(iat, 120, 20);
EXPECT_EQ(stretched_iat, expected_result);
// Test a 70ms to 40ms change.
iat = {13, 7, 5, 3, 1, 5, 12, 11, 3, 0, 0, 0};
expected_result = {7, 5, 5, 3, 3, 2, 2, 1, 2, 2, 6, 22};
stretched_iat = DelayManager::ScaleHistogram(iat, 70, 40);
EXPECT_EQ(stretched_iat, expected_result);
// Test a 30ms to 20ms change.
iat = {13, 7, 5, 3, 1, 5, 12, 11, 3, 0, 0, 0};
expected_result = {8, 6, 6, 3, 2, 2, 1, 3, 3, 8, 7, 11};
stretched_iat = DelayManager::ScaleHistogram(iat, 30, 20);
EXPECT_EQ(stretched_iat, expected_result);
}
// Test if the histogram is compressed correctly if the packet size is
// increased.
TEST(DelayManagerIATScalingTest, CompressionTest) {
using IATVector = DelayManager::IATVector;
// Test a 20 to 60 ms change.
IATVector iat = {12, 11, 10, 3, 2, 1};
IATVector expected_result = {33, 6, 0, 0, 0, 0};
IATVector compressed_iat = DelayManager::ScaleHistogram(iat, 20, 60);
EXPECT_EQ(compressed_iat, expected_result);
// Test a 60ms to 120ms change.
iat = {18, 16, 14, 4, 1};
expected_result = {34, 18, 1, 0, 0};
compressed_iat = DelayManager::ScaleHistogram(iat, 60, 120);
EXPECT_EQ(compressed_iat, expected_result);
// Test a 20ms to 120ms change.
iat = {18, 12, 5, 4, 4, 3, 5, 1};
expected_result = {46, 6, 0, 0, 0, 0, 0, 0};
compressed_iat = DelayManager::ScaleHistogram(iat, 20, 120);
EXPECT_EQ(compressed_iat, expected_result);
// Test a 70ms to 80ms change.
iat = {13, 7, 5, 3, 1, 5, 12, 11, 3};
expected_result = {11, 8, 6, 2, 5, 12, 13, 3, 0};
compressed_iat = DelayManager::ScaleHistogram(iat, 70, 80);
EXPECT_EQ(compressed_iat, expected_result);
// Test a 50ms to 110ms change.
iat = {13, 7, 5, 3, 1, 5, 12, 11, 3};
expected_result = {18, 8, 16, 16, 2, 0, 0, 0, 0};
compressed_iat = DelayManager::ScaleHistogram(iat, 50, 110);
EXPECT_EQ(compressed_iat, expected_result);
}
// Test if the histogram scaling function handles overflows correctly.
TEST(DelayManagerIATScalingTest, OverflowTest) {
using IATVector = DelayManager::IATVector;
// Test a compression operation that can cause overflow.
IATVector iat = {733544448, 0, 0, 0, 0, 0, 0, 340197376, 0, 0, 0, 0, 0, 0};
IATVector expected_result = {733544448, 340197376, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0};
IATVector scaled_iat = DelayManager::ScaleHistogram(iat, 10, 60);
EXPECT_EQ(scaled_iat, expected_result);
iat = {655591163, 39962288, 360736736, 1930514, 4003853, 1782764,
114119, 2072996, 0, 2149354, 0};
expected_result = {1056290187, 7717131, 2187115, 2149354, 0, 0,
0, 0, 0, 0, 0};
scaled_iat = DelayManager::ScaleHistogram(iat, 20, 60);
EXPECT_EQ(scaled_iat, expected_result);
// In this test case we will not be able to add everything to the final bin in
// the scaled histogram. Check that the last bin doesn't overflow.
iat = {2000000000, 2000000000, 2000000000,
2000000000, 2000000000, 2000000000};
expected_result = {666666666, 666666666, 666666666,
666666667, 666666667, 2147483647};
scaled_iat = DelayManager::ScaleHistogram(iat, 60, 20);
EXPECT_EQ(scaled_iat, expected_result);
// In this test case we will not be able to add enough to each of the bins,
// so the values should be smeared out past the end of the normal range.
iat = {2000000000, 2000000000, 2000000000,
2000000000, 2000000000, 2000000000};
expected_result = {2147483647, 2147483647, 2147483647,
2147483647, 2147483647, 1262581765};
scaled_iat = DelayManager::ScaleHistogram(iat, 20, 60);
EXPECT_EQ(scaled_iat, expected_result);
}
} // namespace webrtc
|
ee57b1c1b293eacf03ef570393518dcb2ed48773
|
19fea0b2ce220a4d5475a4b71af6ecefb7b570e6
|
/src/CSVStatLoggerTask.cpp
|
4f071eca12b389095d2c566fafc9a591c3a6699f
|
[] |
no_license
|
BodonFerenc/NanosecPeriodicTimer
|
9597941e9aefb5df16dc29c95931d0ec4a904f27
|
6c2f056e616569693123d70c6612a0ed0b56d2f9
|
refs/heads/master
| 2021-07-19T21:06:11.431420
| 2021-04-05T17:27:19
| 2021-04-05T17:27:19
| 245,814,204
| 0
| 2
| null | 2021-04-05T12:32:17
| 2020-03-08T12:55:12
|
C++
|
UTF-8
|
C++
| false
| false
| 1,642
|
cpp
|
CSVStatLoggerTask.cpp
|
#include <iostream>
#include <fstream>
#include <numeric>
#include <algorithm>
#include "constant.hpp"
#include "CSVStatLoggerTask.hpp"
using namespace std;
CSVStatLoggerTask::CSVStatLoggerTask(unsigned long triggerNr, std::string filename) : filename{filename} {
latencies.reserve(triggerNr);
}
bool CSVStatLoggerTask::run(const TIME& expected, const TIME& real) {
static bool initialized = false;
latencies.push_back(real - expected);
if (not initialized) {
firstTS = real;
initialized = true;
}
lastTS = real;
return true;
}
CSVStatLoggerTask::~CSVStatLoggerTask() {
if (latencies.empty()) return;
cout << "Writing results to file " << filename << endl;
ofstream file;
file.open(filename);
auto s = accumulate( latencies.begin(), latencies.end(), decltype(latencies)::value_type(0));
auto average = s.count() / latencies.size();
sort(latencies.begin(), latencies.end());
auto median = latencies[latencies.size() / 2];
const auto realdur = (float) (lastTS - firstTS).count() / BILLION;
const auto realfreq = (long) (latencies.size() / realdur);
file << "realFrequency,sentMessageNr,maxTimerLatency,avgTimerLatency,medTimerLatency" << endl;
file << realfreq << ","
<< latencies.size() << ","
<< latencies.back().count() << ","
<< average << ","
<< median.count() << endl;
file.close();
cout << "Average wait time latency\t" << average << " nanosec" << endl;
cout << "Real duration was\t\t" << realdur << " sec" << endl;
cout << "Real frequency was\t\t" << realfreq << endl;
}
|
212c26ebdec256762f41d1c4742483535693f336
|
ee47a7c90cea2944e587cdccdf4fd5edf568b3f5
|
/DistributionOfWork/efficientArray.h
|
811d771e240c14854f37e1f1b60a1911c33dcfaf
|
[] |
no_license
|
khamoyer/scripts
|
68b0fd246729cf9446782fd68fec2a5d9307e393
|
3bc4bdf03fc5bc3c767d080d1eae9464e9833e89
|
refs/heads/master
| 2021-05-05T10:30:03.020154
| 2020-03-07T05:50:57
| 2020-03-07T05:50:57
| 104,251,615
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,907
|
h
|
efficientArray.h
|
#include "judge.h"
using namespace std;
template<typename T>
class Heap : public T {
public:
int size=0;
void push(int value) {
size++;
T::data[size] = value;
}
bool isAny() {
return size > 0;
}
int peek() {
if(isAny()) {
int exIdx = 1;
for(int i=1; i <= size; i++)
if(T::compare(i, exIdx))
exIdx = i;
return T::data[exIdx];
}
else
return 0;
}
int pop() {
int exIdx = 1;
for(int i=1; i <= size; i++)
if(T::compare(i, exIdx))
exIdx = i;
int result = T::data[exIdx];
remove(exIdx);
return result;
}
void remove(int idx) {
if(idx <= size) {
T::data[idx] = T::data[size];
size--;
}
}
};
class HeapMin {
public:
int data[101];
int compare(int i, int j){
return data[i] < data[j];
}
};
struct Job {
int workerId;
int importance;
int runtime;
Status status;
};
Job Jobs[70001];
int jobCompare(int job1Idx, int job2Idx) {
if(Jobs[job1Idx].importance == Jobs[job2Idx].importance)
return job1Idx < job2Idx;
return Jobs[job1Idx].importance > Jobs[job2Idx].importance;
}
class HeapJob {
public:
int data[70001];
int compare(int i, int j){
return jobCompare(data[i], data[j]);
}
};
struct Worker {
Heap<HeapMin> freeChildren; //own children with him itself
Heap<HeapJob> jobs;
int senior; //seniorId
int finishTime; //needed for processing
};
Worker Workers[101];
class HeapBusy {
public:
int data[101];
int compare(int i, int j){
int worker1Idx = data[i];
int worker2Idx = data[j];
if(Workers[worker1Idx].finishTime == Workers[worker2Idx].finishTime)
return worker1Idx < worker2Idx;
return Workers[worker1Idx].finishTime < Workers[worker2Idx].finishTime;
}
};
class EfficientArraySolution : public ISolution {
Heap<HeapBusy> busyWorkers;
public:
EfficientArraySolution() {
Jobs[0].importance = -1;
for(int i = 0; i < 101; i++)
Workers[i] = {};
addWorker(0, 1, 0);
}
void assign(int time, int wIdx, int jIdx) {
Jobs[jIdx].status.workerAssigned = wIdx;
Jobs[jIdx].status.finishTime = Jobs[jIdx].runtime + time;
Workers[wIdx].finishTime = Jobs[jIdx].status.finishTime;
busyWorkers.push(wIdx);
}
void processTo(int time) {
while(busyWorkers.isAny()) {
int worker = busyWorkers.peek();
if(Workers[worker].finishTime > time)
break;
busyWorkers.pop();
int senior = Workers[worker].senior;
if(Workers[worker].jobs.isAny() || Workers[senior].jobs.isAny()) {
if(jobCompare(Workers[worker].jobs.peek(), Workers[senior].jobs.peek()))
assign(Workers[worker].finishTime, worker, Workers[worker].jobs.pop());
else
assign(Workers[worker].finishTime, worker, Workers[senior].jobs.pop());
}
else
{
Workers[worker].freeChildren.push(worker);
Workers[senior].freeChildren.push(worker);
}
}
}
virtual void addWorker(int time, int id, int seniorId)
{
//making it busy by default
Workers[id].senior = seniorId;
Workers[id].finishTime = time;
busyWorkers.push(id);
processTo(time);
}
virtual void removeFromParentFreeChildren(int worker)
{
int senior = Workers[worker].senior;
int idx = 0;
for(int w : Workers[senior].freeChildren.data) {
if(w == worker) {
Workers[senior].freeChildren.remove(idx);
break;
}
idx++;
}
}
virtual void addWork(int time, int job, int worker, int importance, int runtime)
{
processTo(time - 1);
Jobs[job] = {worker, importance, runtime, {}};
Workers[worker].jobs.push(job);
if(Workers[worker].freeChildren.isAny()) {
int waitingWorker = Workers[worker].freeChildren.pop();
Workers[waitingWorker].finishTime = time;
busyWorkers.push(waitingWorker);
if(waitingWorker == worker)
removeFromParentFreeChildren(waitingWorker);
else
Workers[waitingWorker].freeChildren.pop(); //we are sure it is on top
}
processTo(time);
}
virtual Status getStatus(int time, int workId )
{
processTo(time);
return Jobs[workId].status;
}
};
|
693a0c27da62d1b0b9a0be0ba656bbb8374f91a1
|
12512c75a5aa4e5fcd61e95a314e3f2d531e3d03
|
/ufora/core/serialization/OQueueProtocol.cpp
|
887546eb0e5d698ba8cd280e48729c3130a8d66a
|
[
"dtoa",
"MIT",
"BSD-3-Clause",
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] |
permissive
|
arita37/ufora
|
ecc4c2820b1d47e8e23f77676e6def4501ee41f7
|
55c9ebef12806bf0b17fe6ff7c102ae756b13b47
|
refs/heads/master
| 2021-01-11T01:12:29.461835
| 2016-10-11T14:23:22
| 2016-10-11T14:23:22
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,100
|
cpp
|
OQueueProtocol.cpp
|
/***************************************************************************
Copyright 2015 Ufora Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
****************************************************************************/
#include "OQueueProtocol.hpp"
OQueueProtocol::OQueueProtocol(Queue<std::string>& inQueue) :
mQueue(inQueue),
mPosition(0)
{
}
void OQueueProtocol::write(uword_t inByteCount, void *inData)
{
mQueue.write(std::string(static_cast<char*>(inData), inByteCount));
mPosition += inByteCount;
}
uword_t OQueueProtocol::position(void)
{
return mPosition;
}
|
2ab68c6cd3b4a011eafdf290fbb3c7d0e9a995d6
|
3f6649885e8d391a490cdc2b652058a1dab29f57
|
/考试4.cpp
|
05df4c874ac449abcda7d4238f33a8a7760b34ab
|
[] |
no_license
|
cxy205/205
|
c7f6194431fa1fa0f9eded0088aca155ebf8c181
|
aa85e300546560a618e6df6d47daebab4bcf96a8
|
refs/heads/main
| 2023-02-10T23:38:43.737293
| 2021-01-13T03:52:02
| 2021-01-13T03:52:02
| 309,595,779
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 844
|
cpp
|
考试4.cpp
|
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int n,i,j,A,B;
float G;
char g[5]={};
A=0;
B=0;
scanf("%d",&n);
if(n<1||n>100)
return 0;
char NAME[100][10]={},STUDENT_ID[100][19]={};
int GRADE[100]={};
for(i=0;i<n;i++)
{
scanf("%s %s %s",NAME[i],STUDENT_ID[i],g);
if(strcmp(g,"n/a")==0)
{
for(j=0;j<10;j++)
NAME[i][j]='\0';
for(j=0;j<19;j++)
STUDENT_ID[i][j]='\0';
i=i-1;
n=n-1;
}
else
{
G=atoi(&g[0]);
GRADE[i]=G;
}
for(j=0;j<5;j++)
g[j]='\0';
}
for(i=0;i<n;i++)
{
if((GRADE[i]==GRADE[A])&&(NAME[i][0]<NAME[A][0]))
A=i;
if(GRADE[i]>GRADE[A])
A=i;
if((GRADE[i]==GRADE[B])&&(NAME[i][0]>NAME[B][0]))
B=i;
if(GRADE[i]<GRADE[B])
B=i;
}
printf("%s %s\n",NAME[A],STUDENT_ID[A]);
printf("%s %s ",NAME[B],STUDENT_ID[B]);
return 0;
}
|
cbca91c74774e0709b2df58f893727ef232acdce
|
ad3b46656bf0a74739827cc3bbc256da05927b80
|
/ofApp.cpp
|
e56a452dd6a619de029df1b4b81f3a27e5f87000
|
[] |
no_license
|
junkiyoshi/Insta20171013
|
aef80f39268a400d07e5b87e50be4b482c469383
|
3eec0132c5e8c08e67e1254cdc03e86fc1015023
|
refs/heads/master
| 2021-07-12T09:43:32.158296
| 2017-10-13T04:04:36
| 2017-10-13T04:04:36
| 106,773,732
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,306
|
cpp
|
ofApp.cpp
|
#include "ofApp.h"
//--------------------------------------------------------------
ofApp::~ofApp(){
for (int i = this->ripples.size() - 1; i > -1; i--) {
delete this->ripples[i];
this->ripples.erase(this->ripples.begin() + i);
}
}
//--------------------------------------------------------------
void ofApp::setup() {
ofSetFrameRate(30);
ofBackground(255);
ofSetWindowTitle("Insta");
ofSetCircleResolution(360);
ofSetLineWidth(3);
}
//--------------------------------------------------------------
void ofApp::update(){
for(int i = this->ripples.size() - 1; i > -1; i--){
this->ripples[i]->update();
if (this->ripples[i]->isDead()) {
delete this->ripples[i];
this->ripples.erase(this->ripples.begin() + i);
}
}
}
//--------------------------------------------------------------
void ofApp::draw() {
this->cam.begin();
ofColor body_color;
body_color.setHsb(ofGetFrameNum() % 255, 255, 255);
ofFill();
ofSetColor(body_color);
ofDrawCircle(0, 0, 100);
if (ofNoise(ofGetFrameNum() * 0.05) > 0.5) {
this->ripples.push_back(new Ripple(body_color));
}
for (Ripple* r : this->ripples) {
r->draw();
}
this->cam.end();
}
//--------------------------------------------------------------
int main() {
ofSetupOpenGL(720, 720, OF_WINDOW);
ofRunApp(new ofApp());
}
|
b7bfa45695bea475106968c7d682fbd8b81fc937
|
2fd3f4c6d72981a53ca34305f9069f1bbe6c1f52
|
/LP/lp.cpp
|
7c7ed74f7f957d7ecebb45bc2b1806ecde7869ed
|
[] |
no_license
|
gerricduncan/LP
|
51fdf23e57b0c351ac82920cc210afbe26944a77
|
e8f17364d1dfde7f4506f0ffa20c18bc18b945fb
|
refs/heads/master
| 2021-01-01T15:55:48.834278
| 2015-09-18T16:22:42
| 2015-09-18T16:22:42
| 42,676,034
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 936
|
cpp
|
lp.cpp
|
//
// lp.cpp
// LP
//
// Created by Gary Duncan on 9/17/15.
// Copyright (c) 2015 Gary Duncan. All rights reserved.
//
#include "lp.h"
bool lp::validForm() const{
auto numVariables = c.size();
for (auto i : constraints)
if (i.a.size() != numVariables)
return false;
return true;
}
void lp::print(){
std::cout << (min ? "minimize " : "maximize ");
std::cout << vecLine(c) << std::endl;
std::cout << "such that " << std::endl;
for (auto i : constraints)
std::cout << vecLine(i.a) << i.comp << i.b << std::endl;
}
std::string lp::vecLine(std::vector<short int>& v){
std::string s;
for (unsigned int i = 0; i < v.size(); i++) {
s+=(v[i] < 0 ? "-" : "+");
if (i == 0 && s == "+")
s.clear();
s+=(abs(v[i]) == (short int)(1) ? "" : std::to_string(abs(v[i])));
s+="x";
s+=std::to_string(i+1);
}
return s;
}
|
532c4c7f8c4ca0d87a3addf77a53164625b44fb0
|
b1f101c2290dc7cce50e3296e9b58ab1297b8337
|
/include/ki/protocol/control/ServerKeepAlive.h
|
520ff51af1ce7df7a4a3884abd39ed1e3149adc1
|
[] |
no_license
|
SeanOMik/libki
|
e28559142bf3d6aad93fdab6cb0507d99a2c2f14
|
e8d25eeb67338f7891561934ce32a1187d56dba2
|
refs/heads/master
| 2023-02-01T17:13:04.862710
| 2020-12-16T06:36:51
| 2020-12-16T06:36:51
| 318,951,417
| 0
| 0
| null | 2020-12-06T04:35:47
| 2020-12-06T04:35:46
| null |
UTF-8
|
C++
| false
| false
| 579
|
h
|
ServerKeepAlive.h
|
#pragma once
#include "../../util/Serializable.h"
#include <cstdint>
#include <iostream>
namespace ki
{
namespace protocol
{
namespace control
{
class ServerKeepAlive final : public util::Serializable
{
public:
ServerKeepAlive(uint32_t timestamp = 0);
virtual ~ServerKeepAlive() = default;
uint32_t get_timestamp() const;
void set_timestamp(uint32_t timestamp);
void write_to(std::ostream &ostream) const override final;
void read_from(std::istream &istream) override final;
size_t get_size() const override final;
private:
uint32_t m_timestamp;
};
}
}
}
|
6762c37de284e35d6471a7cf8052b3f13a377019
|
31a8e74237625adb92e891ebe41335133d0ec61c
|
/14.Longest_Common_Prefix/LongestCommonPrefix.cpp
|
3c08ad0e47501bbe859a3860844a384d2c158909
|
[] |
no_license
|
forked-from-repos/LeetCode
|
e6f5b14a1e1424b8852c73cea8cffd114ccb27b9
|
4a598cfbfa47f2144991704725fa19acc4ba7a93
|
refs/heads/master
| 2023-03-18T16:05:48.911637
| 2021-03-07T16:10:09
| 2021-03-07T16:10:09
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 651
|
cpp
|
LongestCommonPrefix.cpp
|
class Solution {
public:
string change(string a, string b) {
string temp = "";
int i = 0, j = 0;
while(a[i] == b[j] && i < a.length() && j < b.length()){
temp += a[i++];
j++;
}
return temp;
}
string longestCommonPrefix(vector<string>& strs) {
if(strs.size() == 0)
return "";
string prefix = strs[0];
for(int i = 1; i < strs.size(); ++i){
prefix = change(strs[i], prefix);
if(prefix.length() == 0)
return "";
}
return prefix;
}
};
|
f76d0ee12b6239b7585d6925440e93d763235990
|
d1a4f5b3806676c937d2d25d4dd10d225f6369a6
|
/XMFCaptureCPP/XMFCaptureUsingIMFSinkWriter.h
|
fb6f5a4bfca6457fa7bc7686722b58087db9040d
|
[] |
no_license
|
sdaly2324/XMFCapture
|
38aa7fd566a39971d95df09565b6b84f4e5d8139
|
0343f2ed71d6ffa5cba1d77d2eff0923802010b2
|
refs/heads/master
| 2021-08-19T23:38:24.775250
| 2017-11-27T17:33:26
| 2017-11-27T17:33:26
| 104,789,605
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 949
|
h
|
XMFCaptureUsingIMFSinkWriter.h
|
#pragma once
#include <memory>
#include "IXMFCaptureEngine.h"
class XMFCaptureDevice;
class XMFCaptureUsingIMFSinkWriterRep;
class XMFCaptureUsingIMFSinkWriter : public IXMFCaptureEngine
{
public:
XMFCaptureUsingIMFSinkWriter(std::shared_ptr<XMFCaptureDevice> pAudioDevice, std::shared_ptr<XMFCaptureDevice> pVideoDevice);
~XMFCaptureUsingIMFSinkWriter();
HRESULT SetupWriter(PCWSTR pszDestinationFile);
CComPtr<IMFMediaType> GetAudioMTypeFromSource();
CComPtr<IMFMediaType> GetVideoMTypeFromSource();
HRESULT AddVideoStream(CComPtr<IMFMediaType> pVideoOutputMediaType);
HRESULT AddAudioStream(CComPtr<IMFMediaType> pAudioOutputMediaType);
HRESULT StartRecord(HWND hwnd);
HRESULT StopRecord();
HRESULT StartPreview(HWND hwnd);
HRESULT StopPreview();
virtual bool IsPreviewing() const;
virtual bool IsRecording() const;
HRESULT GetStatistics(MF_SINK_WRITER_STATISTICS *pStats);
private:
XMFCaptureUsingIMFSinkWriterRep* m_pRep;
};
|
7ebd4825ca7f13ab9e6ef62cccf56689bf8d2b89
|
8b3607e7376a2acb57456c30106c5a91372cf6cf
|
/Game.h
|
ff2f18de6360d2ff7e9a80066a70014b0d43c4d2
|
[] |
no_license
|
AhmedElsayed200/Coin-Dozer-DS-Project-
|
914f1150b9f5997408be4f0ad413874e5f41530e
|
9966c62da7aa8369bf03fe59638664470f481a26
|
refs/heads/master
| 2022-09-20T14:45:27.449387
| 2020-06-03T19:28:34
| 2020-06-03T19:28:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 436
|
h
|
Game.h
|
#ifndef GAME_H
#define GAME_H
#include <QGraphicsView>
#include <QGraphicsScene>
class Game: public QGraphicsView{
Q_OBJECT
public:
// constructors
Game(QWidget* parent=NULL);
// public methods
void displayMainMenu();
// public attributes
QGraphicsScene* scene;
QString whosTurn;
public slots:
void start();
void Remove1();
void Remove2();
};
#endif // GAME_H
|
9a079b521e8c34bb7267c978c4ae9bddcbb82b75
|
3bf914538f23ddae0b37a43d489f40be846c711f
|
/gunMayhem/headers/Platform.h
|
ec9a4c74a8bcfc618cf0278c014365c20164b760
|
[] |
no_license
|
26eldrpau/gunMayhem
|
61f0c9b1375eaa71dbdba36672b4cc3e9ed8a4e0
|
3b6eb5d0385365f3131c2511e29ffb5d3edcc652
|
refs/heads/master
| 2023-02-15T04:39:02.415073
| 2021-01-10T14:43:28
| 2021-01-10T14:43:28
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 695
|
h
|
Platform.h
|
//
// Created by Maťo Prošovský on 30. 11. 2020.
//
#ifndef GUNMAYHEM_PLATFORM_H
#define GUNMAYHEM_PLATFORM_H
#include <iostream>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Network.hpp>
#include <SFML/Audio.hpp>
using namespace sf;
class Platform {
private:
RectangleShape rect;
float Y;
float X;
public:
Platform();
virtual ~Platform();
RectangleShape &getRect();
void initPlatform(float x, float y, float xP, float yP);
float getX() const;
float getY() const;
void setX(float x);
void setY(float y);
};
#endif //GUNMAYHEM_PLATFORM_H
|
6ff2961fb35904c54f421924abb3a0f666a9f8d7
|
ee7543fe2aaf7bf45f8ddcb3c30ab9333e50d5f1
|
/graph_orthogonal_list.cpp
|
cd69f5572fcfc662d162be174e840b94f023ad81
|
[] |
no_license
|
645082160/dsa
|
dce5553ef1e9fcc745a512df2d416a45017560c1
|
d3b63c89c3d0ffb5ba894fa087f4a4404b9d7d7b
|
refs/heads/master
| 2021-04-06T01:24:46.025119
| 2018-07-29T14:04:05
| 2018-07-29T14:04:05
| 124,818,018
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 5,407
|
cpp
|
graph_orthogonal_list.cpp
|
/*
图的十字链表表示法
*/
#include <iostream>
#include <stack>
#include <list>
#include <string>
using namespace std;
//弧节点
struct ArcNode
{
int headvex;//弧头
int tailvex;//弧尾
ArcNode* hlink;//连接以该点为头节点的弧
ArcNode* tlink;// 连接以该节点为尾的弧
};
//顶点
struct VexNode
{
string value;//顶点名字
ArcNode* firstin;//指向以该顶点为头的弧
ArcNode* firstout;//指向以该顶点为尾的弧
};
//有向图
const int MAX_VEX_NUM = 5;
typedef struct DirectedGraph
{
VexNode vex[MAX_VEX_NUM];//顶点结合
int vexnum;//顶点数目
int arcnum;//弧的数目
}DG;
int locate(DG& g, string vex)
{
for(int i = 0; i < g.vexnum; ++i)
{
if(g.vex[i].value == vex)
{
return i;
}
}
return -1;
}
int createDG (DG& g)
{
cout << "input vexnum:";
cin >> g.vexnum;
cout << "input arcnum:";
cin >> g.arcnum;
//输入顶点信息
for(int i = 0; i < g.vexnum; ++i)
{
cout << "input vex value:";
cin >> g.vex[i].value;
g.vex[i].firstin = g.vex[i].firstout = NULL;
}
//输入弧的信息
string tail;
string head;
int x = 0, y = 0;
for(int i = 0; i < g.arcnum; ++i)
{
//输入弧的弧尾和弧头
cout << "input tail and head vex:";
cin >> tail;//弧尾
cin >> head;//弧头
x = locate(g, tail);
if(x == -1)
{
cout << "invalid start, " << tail << endl;
return -1;
}
y = locate(g, head);
if(y == -1)
{
cout << "invalid end, " << head << endl;
return -1;
}
//创建弧节点
ArcNode* p = new ArcNode();
p->tailvex = x;//弧尾
p->headvex = y;//弧头
p->hlink = g.vex[y].firstin;
p->tlink = g.vex[x].firstout;
//将弧节点插入到顶点链表中
g.vex[x].firstout = g.vex[y].firstin = p;
}
return 0;
}
void print(DG& g)
{
for(int i = 0; i < g.vexnum; ++i)
{
cout << "vertex:" << g.vex[i].value << endl;
cout << "in:";
ArcNode* it = g.vex[i].firstin;
//弧头相同的弧
while(it != NULL)
{
cout << "(" << it->tailvex << ", " << it->headvex << ")" << " ";
it = it->hlink;
}
cout << endl;
cout << "out:";
it = g.vex[i].firstout;
//弧尾相同的弧
while(it != NULL)
{
cout << "(" << it->tailvex << ", " << it->headvex << ")" << " ";
it = it->tlink;
}
cout << endl;
}
return;
}
//已访问数组
bool visit[MAX_VEX_NUM];
stack<int> s;//dfs 后续遍历栈
list<int> vexset;//强连通顶点集合
void DFS(DG& g, int vex);
void DFS_Traverse(DG& g)
{
//初始化visit数组
for(int i = 0; i < MAX_VEX_NUM; ++i)
{
visit[i] = false;
}
//遍历顶点 集合,执行DFS访问
for(int i = 0; i < g.vexnum; ++i)
{
if(!visit[i]) //顶点未被访问过
{
DFS(g, i);
}
}
return;
}
void DFS(DG& g, int vex)
{
//设置已访问
visit[vex] = true;
//遍历与该顶点相关联的顶点,执行深度优先访问
ArcNode* p = g.vex[vex].firstout;//出边
int connected_vex = 0;
while(p != NULL)
{
//判断顶点是否已经访问过
connected_vex = p->headvex;
if(visit[connected_vex])
{
p = p->tlink;
continue;
}
//未访问过时,顺着该顶点执行DFS深度遍历
DFS(g, connected_vex);
//访问下一条以该顶点未弧尾的边
p = p->tlink;
}
//顶点的关联顶点访问完毕,该顶点入栈
s.push(vex);
return;
}
void print(stack<int>& s)
{
cout << "DFS stack:";
int vex = 0;
while(!s.empty())
{
vex = s.top();
s.pop();
cout << vex << " ";
}
cout << endl;
return;
}
void clear_vexset(list<int>& vexset)
{
while(!vexset.empty())
{
vexset.pop_back();
}
return;
}
void print_set(DG& g, list<int>& vexset);
void Inverted_DFS(DG& g, int vex);
void Inverted_DFS_Traverse(DG& g)
{
//初始化访问数组
for(int i = 0; i < g.vexnum; ++i)
{
visit[i] = false;
}
clear_vexset(vexset);
//访问第一次DFS得到的后续序列
int vex = 0;
while(!s.empty())
{
vex = s.top();
s.pop();
if(!visit[vex])
{
Inverted_DFS(g, vex);
print_set(g, vexset);
clear_vexset(vexset);
}
}
return;
}
void Inverted_DFS(DG& g, int vex)
{
//设置顶点已访问
visit[vex] = true;
//该顶点入队列
vexset.push_back(vex);
//逆向遍历,找到以该顶点为弧头的边,执行DFS
ArcNode* p = g.vex[vex].firstin;
int connected_vex = 0;
while(p != NULL)
{
connected_vex = p->tailvex;//因为是逆向,当前顶点是弧头,这里应该取弧尾顶点
//判断顶点是否已经被访问过
if(visit[connected_vex])
{
p = p->hlink;
continue;
}
//未访问过时执行DFS逆向遍历
Inverted_DFS(g, connected_vex);
p = p->hlink;
}
return;
}
void print_set(DG&g, list<int>& vexset)
{
cout << "vex set:";
list<int>::iterator it = vexset.begin();
list<int>::iterator end = vexset.end();
while(it != end)
{
cout << g.vex[*it].value << " ";
++it;
}
cout << endl;
return;
}
int main(int argc, char** argv)
{
DG g;
int res = createDG(g);
if(res != 0)
{
cout << "create dg fail." << endl;
return -1;
}
print(g);
//dfs
DFS_Traverse(g);
//print(s);
//获得强连通集合
Inverted_DFS_Traverse(g);
return 0;
}
|
056c00d3439801959ad1911b28fdea65ed23b27b
|
3955942801052872fe265e40f228c545780e1323
|
/CSQUAREacc.cpp
|
c5f3d2d8cb10e0f09aa6a0ec0d0a2b954feda1ef
|
[] |
no_license
|
rajnishkr/SpojSolution
|
ccc23008fea3d5cbaebccd1fa06463d56cc6fa84
|
0c077085594733af8cba58ac65253c120ddef873
|
refs/heads/master
| 2016-09-06T10:13:54.016885
| 2013-06-19T16:43:57
| 2013-06-19T16:43:57
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 664
|
cpp
|
CSQUAREacc.cpp
|
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int test;
cin>>test;
while(test--){
long long a,m,z,y;
scanf("%lld",&a);
char s[251];
scanf("%s",s);
scanf("%lld",&m);
z=1;
y=a;
for(int i=strlen(s);i>0;i--)
{ cout<<z<<" "<<y<<endl;
if(s[i-1]=='1')
z=(z*y)%m;
else
{
if(s[i-1]=='2')
z=(z*(y*y)%m)%m;
}
y=((y*y)%m*y)%m;
}
printf("%lld\n",z);
//cin>>z;
}
return 0;
}
|
cb183986454473b652c577e2d30668a33e1a2d09
|
19a6a3e5fa40ff2e5c337e541020ecbfecc8bc4d
|
/SpaceWar/Bullet.cpp
|
81fcaf6d1796c5cfcd91b70dd3a33f3af70171b3
|
[] |
no_license
|
AhmetOzyilmaz/SpaceGun
|
b8aeada17ea6ffc6b792bfd36c60ff3dd258cee2
|
6784ead1874ae393c5652009e98ba672e5500559
|
refs/heads/master
| 2021-03-24T12:42:38.470116
| 2017-09-18T10:22:35
| 2017-09-18T10:22:35
| 103,923,215
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 600
|
cpp
|
Bullet.cpp
|
#include "Bullet.h"
#include "Game.h"
#include "EnemyShip.h"
Bullet::Bullet(vector2f pos, vector2f vel) : GameObject(Texture::Load("bullet2.png", 0.35), pos), velocity(vel)
{
//rotation = 3.14/2;
radius = 5;
}
Bullet::~Bullet()
{
}
void Bullet::Update()
{
position += velocity;
auto contacts = Game::instance->GetContacts(this);
for (auto& contact : contacts) {
EnemyShip* enemy = dynamic_cast<EnemyShip*>(contact);
if (enemy != nullptr) {
enemy->Damage(1);
Destroy();
return;
}
}
if (position.y < 0 || position.y > Game::instance->screenSize.y) {
Destroy();
}
}
|
f2eb7ae3ef6c620361b84e95b6ce7dda531c5b35
|
d30e692b0a2425c3942aeca3373292480c0263cc
|
/Lizard.cpp
|
0be2ade07ee73fa0e478297502a1a847a8405dfc
|
[] |
no_license
|
Kate1900/Zoo
|
edb7296197dfeeb044df799aaca88aaaa06ab5b1
|
4230e8376a06e9744860009bd17ed1b38032bd1b
|
refs/heads/master
| 2021-05-20T01:21:14.062777
| 2020-04-01T10:36:52
| 2020-04-01T10:36:52
| 252,125,965
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 256
|
cpp
|
Lizard.cpp
|
#include "Lizard.h"
TLizard::TLizard() : TReptiles()
{
cvet = 3;
kolvokonechnostei = 4;
kolvosystems = 3;
}
const char* TLizard::Golos()
{
return "Frrt";
}
int TLizard::teeth()
{
return 0;
}
bool TLizard::Shell()
{
return 1;
}
|
923a2ecd59daed369efdd885590fb6e8e3eef681
|
6c44fb8c76ac4d6f2584a248bcf1963b3789d87f
|
/csvfile.cpp
|
3570e13de05741b3d98792d63a944af8069df3fc
|
[] |
no_license
|
bollian/ScoutAnalyzer
|
a70ce9d61cfb72dd14983dce7f59f78aac4efc62
|
742fc06c527df4a40ec5a8da6c6116e63de7ecb8
|
refs/heads/master
| 2021-06-10T13:50:47.593311
| 2017-03-17T19:37:40
| 2017-03-19T10:35:38
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,177
|
cpp
|
csvfile.cpp
|
#include <csvfile.h>
#include <cstdlib>
#include <strings.h>
#include <qiodevice.h>
#include <parseexception.h>
CSVFile::CSVFile(const QString& path) : QFile(path) {}
bool followedBy(char* str, int len, int index, char suf) {
return index < len - 1 ? str[index + 1] == suf : false;
}
/**
* @brief grabCell takes the part of a string indicated by start an end an returns it with extra formatting for csv cells
* @param str the string the cell is contained in
* @param start the beginning of the cell (inclusive)
* @param end the end of the cell (exclusive)
* @return the contents of the cell
*/
QString grabCell(char* str, int start, int end) {
bool quoted = str[start] == '"' && str[end - 1] == '"';
if (quoted) {
++start;
--end;
}
QByteArray copy(str + start, end - start);
if (copy.endsWith('\r')) {
copy.chop(1);
}
if (quoted) {
copy.replace("\"\"", "\"");
}
return QString(copy);
}
bool CSVFile::readRow(QList<QString>& cells) {
const int expansion_size = 1024;
int buf_size = 0;
char* buffer = NULL;
int read_len;
int i = 0;
int cell_start = 0;
bool quoted = false;
bool quote_preceded = false;
do {
do {
buf_size += expansion_size;
buffer = (char*)realloc(buffer, buf_size);
read_len = readLineData(buffer + buf_size - expansion_size, expansion_size);
if (read_len == -1) {
throw ParseException("", -1, "Error reading from file: " + errorString());
}
} while (buffer[buf_size - expansion_size + read_len - 1] != '\n' && !atEnd());
// reset buf_size to the actual length of the string
buf_size = buf_size - expansion_size + read_len;
for (; i < buf_size; ++i) {
switch (buffer[i]) {
case ',':
if (!quoted || quote_preceded) {
cells.append(grabCell(buffer, cell_start, i));
cell_start = i + 1;
quoted = false;
quote_preceded = false;
} // else this is a comma contained in a cell
break;
case '"':
if (i == cell_start) {
// this is the beginning of a quoted cell
quoted = true;
} else if (quote_preceded) {
quote_preceded = false; // found a double quote
} else if (quoted) {
quote_preceded = true;
} else {
throw ParseException(QString(QByteArray(buffer, buf_size)), i, "Unquoted cell contained quotation mark");
}
break;
case '\r':
break;
case '\n':
if (!quoted || quote_preceded) {
cells.append(grabCell(buffer, cell_start, i));
quoted = false;
quote_preceded = false;
}
break;
default:
if (quote_preceded) {
throw ParseException(QString(QByteArray(buffer, buf_size)), i, "Unpaired quote in cell");
}
}
}
if (atEnd() && buffer[i - 1] != '\n') {
// we reached the end of the file but didn't find the newline
// so the cell was never added to the row
if (quoted && !quote_preceded) {
// we never saw the end quote
throw ParseException(QString(buffer), i, "");
}
cells.append(grabCell(buffer, cell_start, i));
quoted = false;
quote_preceded = false;
}
} while (quoted);
free(buffer);
return !atEnd();
}
bool CSVFile::open() {
return super::open(QIODevice::ReadOnly);
}
void CSVFile::close() {
super::close();
}
|
3470f4f1a770b0c7f9cdb20ecf259182e4f4534e
|
a2e865796d179a3dcbad45aa3e97cc5b4d870597
|
/Physics/Source/Load_File.h
|
c0edffd5bfbcad2e89103eb9c2f5296d811f56e2
|
[] |
no_license
|
thunderblader/SP3
|
78d6e6ad489d248f875d3dbcec8a72b5af75d56b
|
808103cf6d262377390055c5e3af6ebe7a014081
|
refs/heads/master
| 2021-01-16T21:13:53.194894
| 2017-08-29T09:56:28
| 2017-08-29T09:56:28
| 100,222,202
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 980
|
h
|
Load_File.h
|
#ifndef LOAD_FILE_H
#define LOAD_FILE_H
#include <iostream>
#include <fstream>
#include <sstream>
#include "Spawner.h"
#include "Tree.h"
using std::vector;
using std::string;
using std::ifstream;
using std::istringstream;
using std::ofstream;
using std::ios;
using std::cout;
using std::endl;
class Load_File
{
public:
Load_File();
~Load_File();
void Init(vector<GameObject *>*Gameobj);
bool Load(bool checker, const string saveFileName);
void Process(bool checker, string content);
bool Load_Data(Tree::avl_node & node, const string saveFileName = "Image//save_data.sav");
bool Save_Data(int data1, int data2, int data3, Tree::avl_node &node, const string saveFileName = "Image//save_data.sav");
int get_score();
int get_gold();
int number_of_items;
protected:
vector<GameObject *>* Gameobject_List;
Tree *items = Tree::getInstance();
Spawner blocks;
int Unit_Height_Space;
int Unit_Width_Space;
int Level;
int Score;
int Gold;
bool has_item;
};
#endif
|
67c810862d05f9f7d12e4d04ead66d59c8bb8154
|
172e7db57c5ad7f1ab029c86807e01deba20ca03
|
/ComputerNetworks/Pracownie/Pracownia 1 - (5 na 10)/icmp_send.cpp
|
a29b045ec99a69071086402159e6d6be79145aa3
|
[] |
no_license
|
TheFebrin/UNIVERSITY
|
419edd42b0965bb65d30e15ae982a36b7a277006
|
cd2bc9198c355fcc213397e87757b5b27f493cbb
|
refs/heads/master
| 2023-03-16T22:04:36.513670
| 2023-02-01T15:45:53
| 2023-02-01T15:45:53
| 135,926,363
| 10
| 10
| null | 2023-03-07T17:13:51
| 2018-06-03T17:38:50
|
Jupyter Notebook
|
UTF-8
|
C++
| false
| false
| 1,588
|
cpp
|
icmp_send.cpp
|
/*
Dawid
Dieu
302052
*/
#include "icmp_send.hpp"
void print_as_bytes (unsigned char* buff, ssize_t length)
{
for (ssize_t i = 0; i < length; i++, buff++)
printf ("%.2x ", *buff);
}
u_int16_t compute_icmp_checksum (const u_int16_t *buff, int length)
{
u_int32_t sum;
const u_int16_t* ptr = buff;
assert (length % 2 == 0);
for (sum = 0; length > 0; length -= 2)
sum += *ptr++;
sum = (sum >> 16) + (sum & 0xffff);
return (u_int16_t)(~(sum + (sum >> 16)));
}
void fill_header(struct icmphdr *h, int ttl, int i)
{
h->type = ICMP_ECHO;
h->code = 0;
h->un.echo.id = (uint16_t)getpid();
h->un.echo.sequence = (uint16_t) 3 * ttl + i;
h->checksum = 0;
h->checksum = compute_icmp_checksum ((u_int16_t*)h, sizeof(*h));
}
void send_packages(int &sockfd, char *ip, int &ttl, vector < pair < int, int > > &sent_ids)
{
sockaddr_in dest;
socklen_t sender_len = sizeof(dest);
bzero(&dest, sizeof(dest));
dest.sin_family = AF_INET;
dest.sin_port = htons(0);
inet_pton(AF_INET, ip, &dest.sin_addr);
setsockopt (sockfd, IPPROTO_IP, IP_TTL, (char *)&ttl, sizeof(ttl));
for(int i = 0; i < 3; i ++)
{
struct icmphdr header;
fill_header(&header, ttl, i);
sent_ids.push_back({header.un.echo.id, header.un.echo.sequence});
ssize_t bytes_sent = sendto (
sockfd,
&header,
sizeof(header),
0,
(struct sockaddr*)&dest,
sender_len
);
if(bytes_sent < 0)
{
perror("Socket failure!");
exit(EXIT_FAILURE);
}
}
}
|
d6e8d13966d8f9487beb8d880058a4babe62185b
|
9b4f93cbada087291f70bfe44ba01458a28f0144
|
/src/base/Mouse.cpp
|
80b3113d3132f50a9f149a83cb7538e53b9226e9
|
[] |
no_license
|
namuol/lite
|
b499155eabcefa95412d58e31d572793de82a13d
|
a3d674b3b1787a6932899de890e8a25484b9e33f
|
refs/heads/master
| 2021-01-18T13:58:41.232411
| 2012-03-27T20:13:13
| 2012-03-27T20:13:13
| 1,080,025
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 815
|
cpp
|
Mouse.cpp
|
//#define _MOUSE_DEBUG
#ifdef _MOUSE_DEBUG
#include <iostream>
using namespace std;
#endif
#include "Vector2.h"
#include "ITimer.h"
#include "Mouse.h"
namespace lite
{
Mouse::Mouse()
{
}
const Vector2& Mouse::position() const
{
return _position;
}
void Mouse::position(const Vector2& value)
{
// TODO: This is dangerous-ish.. make it so that the _prev_position always
// corresponds to what the previous position was in the last frame.
_prev_position = _position;
_position = value;
#ifdef _MOUSE_DEBUG
cout << "mouse pos changed: x=" << _position.x << " y=" << _position.y << endl;
#endif
}
Vector2 Mouse::motion() const
{
return _position - _prev_position;
}
} // namespace lite
|
310926d268f5193fecd3aaec6d8fe53f78c09592
|
6aa810357c774e1532a34bc038ee54afd0413319
|
/Console_mode.h
|
9014efb2c871dd7724ec3e3029450dd59f9a45d2
|
[] |
no_license
|
vishalsinghdeepak/parking_lot
|
48992d469c7219f01b9138b743eff87ad02f5df4
|
74897aa0accfd627578366f037827742120b5fc7
|
refs/heads/master
| 2020-06-07T03:50:55.168248
| 2019-06-25T13:37:21
| 2019-06-25T13:37:21
| 192,915,613
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,785
|
h
|
Console_mode.h
|
//
// Created by Vishal Singh on 20/06/19.
//
#ifndef GOJAK_CONSOLE_MODE_H
#define GOJAK_CONSOLE_MODE_H
#include <iostream>
#include "Global_declaration.h"
#include "Command_function.h"
#include "Formatting.h"
void Console_Mode()
{
while (!cin.eof())
{
global_command_name=input_string();
Identify_Command_Type();
if(global_command_type!=invalid_commmad) {
if(global_command_type==Exit)
break;
if(global_parking_size==0 && global_command_type!=create_parking_lot)
{
cout<<"No Parking created. Please create the parking first"<<endl;
continue;
}
}
//Reading required inputs for the command types
switch(global_command_type)
{
case create_parking_lot:
{
cin>>global_parking_size;
break;
}
case park:
{
global_vehicle_obj.registration_number=input_string();
global_vehicle_obj.color=input_string();
break;
}
case leave:
{
cin>>global_slot_num;
break;
}
case registration_numbers_for_cars_with_colour:
{
global_color=input_string();
break;
}
case slot_numbers_for_cars_with_colour:
{
global_color=input_string();
break;
}
case slot_number_for_registration_number:
{
global_registration_num=input_string();
break;
}
default:
break;
}
Process_Read_Command();
}
}
#endif //GOJAK_CONSOLE_MODE_H
|
c9c3ca180a13c179d319e21ca6b48f8a305cacec
|
d055864962e316d80951cacf65a79a1f28e1c0fd
|
/BookPublication/BookPublication/Publication.h
|
21b5b5ae85b4bc7cec2ebbe29f16c6e697bf4ccb
|
[] |
no_license
|
openupmta/HDT
|
61ca960064ac169d3bc121a85a506a69ac706e86
|
637db35c0e0b7f03013c49af8676eef17d078db7
|
refs/heads/master
| 2020-05-28T09:38:07.667595
| 2019-05-28T16:34:09
| 2019-05-28T16:34:09
| 188,957,592
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 247
|
h
|
Publication.h
|
#pragma once
#include<iostream>
#include<string>
using namespace std;
class Publication
{
protected:
string title;//tieu de
float price;//gia
public:
virtual void getData() = 0;
virtual void putData() = 0;
Publication();
~Publication();
};
|
b12711d7d768b2fc8ccc2de7a5c22cd6f58b277a
|
ac39242880a90c7f8708ab76f721747f1f60269d
|
/sharpeye15_ws/devel/include/seagull_commons_msgs/SeagullHeartbeat.h
|
00e2e8d760300137aa2379a42370e02a915e5d4b
|
[] |
no_license
|
eloipereira/sharpeye15
|
0668152f5c66e6155d035d48651b2e80f4be73bc
|
46895f09c4c35a0686fcd598c61bdf706a2022f6
|
refs/heads/master
| 2021-01-23T14:41:15.976135
| 2017-06-03T15:40:47
| 2017-06-03T15:40:47
| 93,257,653
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,485
|
h
|
SeagullHeartbeat.h
|
// Generated by gencpp from file seagull_commons_msgs/SeagullHeartbeat.msg
// DO NOT EDIT!
#ifndef SEAGULL_COMMONS_MSGS_MESSAGE_SEAGULLHEARTBEAT_H
#define SEAGULL_COMMONS_MSGS_MESSAGE_SEAGULLHEARTBEAT_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
#include <std_msgs/Header.h>
namespace seagull_commons_msgs
{
template <class ContainerAllocator>
struct SeagullHeartbeat_
{
typedef SeagullHeartbeat_<ContainerAllocator> Type;
SeagullHeartbeat_()
: header()
, node(0) {
}
SeagullHeartbeat_(const ContainerAllocator& _alloc)
: header(_alloc)
, node(0) {
}
typedef ::std_msgs::Header_<ContainerAllocator> _header_type;
_header_type header;
typedef uint8_t _node_type;
_node_type node;
enum { HB_AIS_DRIVER = 0u };
enum { HB_GOBI_FG = 1u };
enum { HB_JAI_FG = 2u };
enum { HB_TASE_FG = 3u };
enum { HB_DETECTION_MODULE = 4u };
enum { HB_SEAGULL_MANAGER = 5u };
enum { HB_TASE_DRIVER = 6u };
enum { HB_TASE_COMMS = 7u };
enum { HB_COMMS_RELAY = 8u };
enum { HB_AP_DRIVER = 9u };
enum { HB_AP_COMMS = 10u };
enum { HB_CONTROL_SUPERVISOR = 11u };
enum { HB_TARGET_TRACKING = 12u };
enum { HB_SENSE_AVOID = 13u };
enum { HB_ADSB_DRIVER = 14u };
typedef boost::shared_ptr< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> const> ConstPtr;
}; // struct SeagullHeartbeat_
typedef ::seagull_commons_msgs::SeagullHeartbeat_<std::allocator<void> > SeagullHeartbeat;
typedef boost::shared_ptr< ::seagull_commons_msgs::SeagullHeartbeat > SeagullHeartbeatPtr;
typedef boost::shared_ptr< ::seagull_commons_msgs::SeagullHeartbeat const> SeagullHeartbeatConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace seagull_commons_msgs
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': True}
// {'seagull_commons_msgs': ['/home/ciafa/sharpeye15/sharpeye15_ws/src/seagull_commons_msgs/msg'], 'std_msgs': ['/opt/ros/indigo/share/std_msgs/cmake/../msg']}
// !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types']
template <class ContainerAllocator>
struct IsFixedSize< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> const>
: FalseType
{ };
template <class ContainerAllocator>
struct IsMessage< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> const>
: TrueType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> >
{
static const char* value()
{
return "62b94c14302d5b1cb99c74aba1c738c4";
}
static const char* value(const ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x62b94c14302d5b1cULL;
static const uint64_t static_value2 = 0xb99c74aba1c738c4ULL;
};
template<class ContainerAllocator>
struct DataType< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> >
{
static const char* value()
{
return "seagull_commons_msgs/SeagullHeartbeat";
}
static const char* value(const ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> >
{
static const char* value()
{
return "Header header\n\
uint8 node\n\
uint8 HB_AIS_DRIVER=0\n\
uint8 HB_GOBI_FG=1\n\
uint8 HB_JAI_FG=2\n\
uint8 HB_TASE_FG=3\n\
uint8 HB_DETECTION_MODULE=4\n\
uint8 HB_SEAGULL_MANAGER=5\n\
uint8 HB_TASE_DRIVER=6\n\
uint8 HB_TASE_COMMS=7 \n\
uint8 HB_COMMS_RELAY=8\n\
uint8 HB_AP_DRIVER=9\n\
uint8 HB_AP_COMMS=10\n\
uint8 HB_CONTROL_SUPERVISOR=11\n\
uint8 HB_TARGET_TRACKING=12\n\
uint8 HB_SENSE_AVOID=13\n\
uint8 HB_ADSB_DRIVER=14\n\
\n\
\n\
\n\
================================================================================\n\
MSG: std_msgs/Header\n\
# Standard metadata for higher-level stamped data types.\n\
# This is generally used to communicate timestamped data \n\
# in a particular coordinate frame.\n\
# \n\
# sequence ID: consecutively increasing ID \n\
uint32 seq\n\
#Two-integer timestamp that is expressed as:\n\
# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
# time-handling sugar is provided by the client library\n\
time stamp\n\
#Frame this data is associated with\n\
# 0: no frame\n\
# 1: global frame\n\
string frame_id\n\
";
}
static const char* value(const ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.header);
stream.next(m.node);
}
ROS_DECLARE_ALLINONE_SERIALIZER;
}; // struct SeagullHeartbeat_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::seagull_commons_msgs::SeagullHeartbeat_<ContainerAllocator>& v)
{
s << indent << "header: ";
s << std::endl;
Printer< ::std_msgs::Header_<ContainerAllocator> >::stream(s, indent + " ", v.header);
s << indent << "node: ";
Printer<uint8_t>::stream(s, indent + " ", v.node);
}
};
} // namespace message_operations
} // namespace ros
#endif // SEAGULL_COMMONS_MSGS_MESSAGE_SEAGULLHEARTBEAT_H
|
54d14133dc0e8337e65ef4dfe8463b7f5d963dbf
|
a7cc00f82b9768154a144e2cd81327aa8100f866
|
/schemeparams.cpp
|
a38c7b6c567c38e765e02f514cefb655a0281b5e
|
[] |
no_license
|
Ekop007/CSM
|
88ab74d62915b7ae7a953275595f258f7e0639f7
|
2bab84f5b5fc5b9570a8ba5c15c2e3d0b1eedb63
|
refs/heads/master
| 2020-07-25T23:57:45.845957
| 2020-04-20T11:49:53
| 2020-04-20T11:49:53
| 208,456,655
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,919
|
cpp
|
schemeparams.cpp
|
#include <algorithm>
#include "schemeparams.h"
SchemeParams::SchemeParams(): node_count(0), resistors(0), capasitors(0), inductances(0),
itun(0), inun(0), itut(0), inut(0), b_p_transistors(0),
u_p_transistors(0), oper_amplifiers(0), transformers(0),
p_o_amplifiers(0), perf_transistors(0)
{
}
SchemeParams::SchemeParams(std::size_t nc, std::size_t res, std::size_t cap, std::size_t ind, std::size_t itun,
std::size_t inun, std::size_t itut, std::size_t inut, std::size_t bpt, std::size_t upt,
std::size_t oa, std::size_t tran, std::size_t poa, std::size_t pt, std::size_t ptr) : node_count(nc),
resistors(res), capasitors(cap), inductances(ind), itun(itun),
inun(inun), itut(itut), inut(inut), b_p_transistors(bpt),
u_p_transistors(upt), oper_amplifiers(oa), transformers(tran),
p_o_amplifiers(poa), perf_transistors(pt), perfect_transformer(ptr)
{
}
SchemeParams::SchemeParams(SchemeParams const &sp) : node_count(sp.node_count), resistors(sp.resistors),
capasitors(sp.capasitors), inductances(sp.inductances), itun(sp.itun),
inun(sp.inun), itut(sp.itut), inut(sp.inut), b_p_transistors(sp.b_p_transistors),
u_p_transistors(sp.u_p_transistors), oper_amplifiers(sp.oper_amplifiers),
transformers(sp.transformers), p_o_amplifiers(sp.p_o_amplifiers),
perf_transistors(sp.perf_transistors), perfect_transformer(sp.perfect_transformer)
{
}
SchemeParams::SchemeParams(SchemeParams &&sp) noexcept : node_count(std::move(sp.node_count)), resistors(std::move(sp.resistors)),
capasitors(std::move(sp.capasitors)), inductances(std::move(sp.inductances)), itun(std::move(sp.itun)),
inun(std::move(sp.inun)), itut(std::move(sp.itut)), inut(std::move(sp.inut)),
b_p_transistors(std::move(sp.b_p_transistors)), u_p_transistors(std::move(sp.u_p_transistors)),
oper_amplifiers(std::move(sp.oper_amplifiers)), transformers(std::move(sp.transformers)),
p_o_amplifiers(std::move(sp.p_o_amplifiers)), perf_transistors(std::move(sp.perf_transistors)),
perfect_transformer(std::move(sp.perfect_transformer))
{
sp.node_count = 0;
sp.resistors = 0;
sp.capasitors = 0;
sp.inductances = 0;
sp.itun = 0;
sp.inun = 0;
sp.itut = 0;
sp.inut = 0;
sp.b_p_transistors = 0;
sp.u_p_transistors = 0;
sp.transformers = 0;
sp.p_o_amplifiers = 0;
sp.perf_transistors = 0;
sp.perfect_transformer = 0;
}
void SchemeParams::operator=(SchemeParams &sp)
{
SchemeParams tmp(sp);
swap (tmp);
}
void SchemeParams::operator=(SchemeParams sp)
{
swap(sp);
}
void SchemeParams::swap(SchemeParams sp)
{
node_count = std::move(sp.node_count);
resistors = std::move(sp.resistors);
capasitors = std::move(sp.capasitors);
inductances = std::move(sp.inductances);
itun = std::move(sp.itun);
inun = std::move(sp.inun);
itut = std::move(sp.itut);
inut = std::move(sp.inut);
b_p_transistors = std::move(sp.b_p_transistors);
u_p_transistors = std::move(sp.u_p_transistors);
transformers = std::move(sp.transformers);
p_o_amplifiers = std::move(sp.p_o_amplifiers);
perf_transistors = std::move(sp.perf_transistors);
perfect_transformer = std::move(sp.perfect_transformer);
sp.node_count = 0;
sp.resistors = 0;
sp.capasitors = 0;
sp.inductances = 0;
sp.itun = 0;
sp.inun = 0;
sp.itut = 0;
sp.inut = 0;
sp.b_p_transistors = 0;
sp.u_p_transistors = 0;
sp.transformers = 0;
sp.p_o_amplifiers = 0;
sp.perf_transistors = 0;
sp.perfect_transformer = 0;
}
void SchemeParams::allCount()
{
all_count = resistors + capasitors + inductances + itun + inun
+ itut + inut + b_p_transistors + u_p_transistors
+ transformers + p_o_amplifiers + perf_transistors + perfect_transformer;
}
void SchemeParams::write(std::ofstream &out)
{
out << node_count << " " << resistors << " " << capasitors << " " << inductances << " " << itun << " " << inun << " " << itut << " "
<< inut << " " << b_p_transistors << " " << u_p_transistors << " " << transformers << " " << p_o_amplifiers << " "
<< perf_transistors << " " << perfect_transformer << std::endl;
}
void SchemeParams::read(std::ifstream &in)
{
in >> node_count >> resistors >> capasitors >> inductances >> itun >> inun >> itut >> inut >> b_p_transistors
>> u_p_transistors >> transformers >> p_o_amplifiers >> perf_transistors >> perfect_transformer;
}
|
de5054cae8033d4b1818174feee57e1df9b1ab10
|
cfc105d0d7954ad5ec8a8f2a53d4a86f73d8fe22
|
/src/OTNThread.h
|
3f105b03340f0ecabbffdfc04d16292b0893a39e
|
[] |
no_license
|
mrjojan/OTN
|
5dcd882acdcf5a4966c196b5b3451a03aca62f2e
|
96a094664880fd02618589287697fd1594ebd181
|
refs/heads/master
| 2021-01-01T18:11:04.748487
| 2013-08-17T09:14:35
| 2013-08-17T09:14:35
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 272
|
h
|
OTNThread.h
|
#ifndef OTNTHREAD_H
#define OTNTHREAD_H
#include <pthread.h>
#include <iostream>
class OTNThread
{
public:
void start();
public:
virtual void execute();
public:
void wait_for_exit();
private:
pthread_t handle;
};
#endif
|
b811bbc39b6c603b9021be527ab3291a3a664dd8
|
db3134c14114a91842c72f992bb054d8d780ba6a
|
/PathSumII.h
|
de5f32c3da3bfea0009576aa785415b900c8b3e8
|
[] |
no_license
|
Yunping/leetCode
|
17ba201573b320e181ef7dbf5ebda547ec6807cc
|
e7c0e6abcec706a7cc7799aac557875ae06fe453
|
refs/heads/master
| 2016-09-11T08:35:33.218972
| 2015-12-27T12:30:52
| 2015-12-27T12:30:52
| 13,895,058
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,550
|
h
|
PathSumII.h
|
/*
Problem: Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.
For example:
Given the below binary tree and sum = 22,
5
/ \
4 8
/ / \
11 13 4
/ \ / \
7 2 5 1
return
[
[5,4,11,2],
[5,8,4,5]
]
========================================================================================
Author: Yunping, qufang83@gmail.com
Date: 10/05/2014
Difficulty: *^
Review: **
Solution: (My Own) DFS
*/
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
vector<vector<int> > pathSum(TreeNode *root, int sum) {
vector<vector<int> > ret;
if (!root) return ret;
vector<int> temp;
pathSum_dfs(root, sum, 0, temp, ret);
return ret;
}
private:
void pathSum_dfs(TreeNode *root, int sum, int cur, vector<int> &result, vector<vector<int> >& ret) {
cur += root->val;
result.push_back(root->val);
if (!root->left && !root->right) {
if (cur == sum)
ret.push_back(result);
} else {
if (root->left)
pathSum_dfs(root->left, sum, cur, result, ret);
if (root->right)
pathSum_dfs(root->right, sum, cur, result, ret);
}
result.pop_back();
}
};
|
a40de89ff2f99cae5dd55f1cb66fd20aea6edce6
|
62e55902c7ee22940c2e756a308916882a3ac15b
|
/Source/Core/Core.cpp
|
3eecaeb2bfb810d77f3546cadd4ec9cdb54a0696
|
[
"CC0-1.0"
] |
permissive
|
killvxk/X86Emu
|
9cfa10df850ac8cea8f2b6e3fdeaa8dcf4ad4a74
|
11fb7b2fd6667745f7ac861f373a5d64a9947fb2
|
refs/heads/master
| 2020-04-12T19:39:09.973614
| 2018-11-29T02:20:34
| 2018-11-29T02:20:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,087
|
cpp
|
Core.cpp
|
#include "Bootloader/Bootloader.h"
#include "Core.h"
#include "ELFLoader.h"
#include "LogManager.h"
#include <unicorn/unicorn.h>
#include <unicorn/x86.h>
static uint64_t AlignUp(uint64_t value, uint64_t size) {
return value + (size - value % size) % size;
};
static uint64_t AlignDown(uint64_t value, uint64_t size) {
return value - value % size;
};
constexpr uint64_t PAGE_SIZE = 4096;
constexpr uint64_t FS_OFFSET = 0xb000'0000;
constexpr uint64_t STACK_SIZE = 8 * 1024 * 1024;
constexpr uint64_t STACK_OFFSET = 0xc000'0000;
namespace Emu {
Core::Core()
: CPU{&MemoryMapper} {
}
bool Core::Load(std::string const &File, std::vector<std::string> const &Args) {
bool Result = true;
// Allocate a 64GB SHM region for fun
Result &= MemoryMapper.AllocateSHMRegion(1ULL << 33);
::ELFLoader::ELFContainer file(File);
//// Allocate 4GB of virtual memory for fun
//size_t Size = 0x1'0000'0000;
//void *Ptr = MemoryMapper.MapRegion(0, Size);
uc_engine *uc;
uc_err err;
//err = uc_mem_map_ptr(uc, 0, Size, UC_PROT_ALL, Ptr);
//LogMan::Throw::A(!err, "Failed Map");
//Result &= BL.Load(File, Args);
auto MemLayout = file.GetLayout();
printf("Emulate x86_64 code\n");
// Initialize emulator in X86-64bit mode
err = uc_open(UC_ARCH_X86, UC_MODE_64, &uc);
LogMan::Throw::A(!err, "Failed on uc_open()");
{
uint64_t BasePtr = AlignDown(std::get<0>(MemLayout), PAGE_SIZE);
uint64_t BaseSize = AlignUp(std::get<2>(MemLayout), PAGE_SIZE);
void *Ptr = MemoryMapper.MapRegion(BasePtr, BaseSize);
err = uc_mem_map_ptr(uc, BasePtr, BaseSize, UC_PROT_ALL, Ptr);
LogMan::Throw::A(!err, "Failed Map");
}
{
void *Ptr = MemoryMapper.MapRegion(STACK_OFFSET, STACK_SIZE);
err = uc_mem_map_ptr(uc, STACK_OFFSET, STACK_SIZE, UC_PROT_ALL, Ptr);
LogMan::Throw::A(!err, "Failed Stack Map");
}
{
void *Ptr = MemoryMapper.MapRegion(FS_OFFSET, 0x1000);
err = uc_mem_map_ptr(uc, FS_OFFSET, 0x1000, UC_PROT_WRITE | UC_PROT_READ, Ptr);
LogMan::Throw::A(!err, "Failed FS Map");
}
uint64_t rsp = STACK_OFFSET + STACK_SIZE;
const std::vector<uint8_t> Values = {
2, 0, 0, 0, 0, 0, 0, 0, // Argument count
0, 0, 0, 0, 0, 0, 0, 0, // Argument0 pointer
0, 0, 0, 0, 0, 0, 0, 0, // Argument1 pointer
'B', 'u', 't', 't', 's', // Argument0
'\0',
};
rsp -= Values.size() + 0x1000;
uint64_t arg0offset = rsp + 8;
uint64_t arg0value = rsp + 24;
uc_mem_write(uc, rsp, &Values.at(0), Values.size());
uc_mem_write(uc, arg0offset, &arg0value, 8);
uc_mem_write(uc, arg0offset + 8, &arg0value, 8);
auto Writer = [&](void *Data, uint64_t Addr, uint64_t Size) {
// write machine code to be emulated to memory
if (uc_mem_write(uc, Addr, Data, Size)) {
LogMan::Msg::A("Failed to write emulation code to memory, quit!\n", "");
}
};
file.WriteLoadableSections(Writer);
CPU.uc = uc;
CPU.CPUState.gregs[REG_RSP] = rsp;
CPU.CPUState.rip = file.GetEntryPoint();
CPU.Init();
CPU.RunLoop();
return Result;
}
}
|
c0288fd27e6094abb6008c3baa4c986f7c6d325d
|
335db9546b7b862546446100fc2385caf79f6006
|
/task_3/task_3.cpp
|
bd3195a4cc0aa820bcbdc5ed13853ee57912b6ad
|
[] |
no_license
|
EugeneMagergut/ElementsOfProgramming
|
6dbc062c4e8318c4792c77fd440de45deb3e323e
|
5d807845f4f0e6d288370e5d9eb1af554c0280ab
|
refs/heads/master
| 2016-09-05T14:50:02.195085
| 2013-09-29T16:37:43
| 2013-09-29T16:37:43
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,956
|
cpp
|
task_3.cpp
|
#include <iostream>
#include <vector>
#include <assert.h>
#include <math.h>
#include <algorithm>
using namespace std;
template <class T>
T Gcd(const T& a, const T& b){
T temp;
T a2 = a;
T b2 = b;
while (b2 != 0){
temp = b2;
b2 = a2 % b2;
a2 = temp;
}
return a2;
}
template <class T>
class polynom
{
private:
int size;
vector <T> coef;
public:
polynom(): size(0), coef(1, 1) {}
polynom(int size_): size(size_), coef(size_ + 1) {}
polynom(const polynom<T>& b){
size = b.GetSize();
coef.resize(size+1);
for (int i = 0; i <= size; i++){
coef[i] = b.GetCoef(i);
}
}
T GetCoef(int index) const{
return coef[index];
}
int GetSize() const{
return size;
}
void SetSize(int value){
size = value;
}
void SetCoef(int index, T value){
coef[index] = value;
}
polynom<T> operator =(const polynom<T>& b){
size = b.GetSize();
coef.resize(size + 1);
for (int i = 0; i <= size; i++){
coef[i] = b.GetCoef(i);
}
return *this;
}
bool operator !=(int a){
for (int i = size; i >= 0; i--){
if(coef[i] != 0) return true;
}
return false;
}
bool operator ==(const polynom<T>& b){
if(size != b.size) return false;
else{
for (int i = size; i >=0; i--){
if ((coef[i] - b.coef[i]) > Pogreshnost())
return false;
}
}
return true;
}
T Pogreshnost(){
if(typeid(T).name() == typeid(double).name())
return 0.00001;
}
polynom<T> operator *(T a){
for (int i = size; i >= 0; i--){
coef[i] *= a;
}
}
polynom<T> operator *(const polynom<T>& a){
polynom<T> result(GetSize() + a.GetSize());
for (int i = size; i >= 0; i--){
for (int j = a.size; j >= 0; j--){
result.coef[i + j] += a.coef[j] * coef[i];
}
}
return result;
}
polynom<T> operator %(const polynom<T>& b){
T temp;
for (int i = size; i >= b.GetSize(); i--){
temp = coef[i] / b.GetCoef(b.GetSize());
for (int j = b.GetSize(); j >= 0; j--){
coef[i - (b.GetSize() - j)] = coef[i - (b.GetSize() - j)] - (temp * b.GetCoef(j));
}
}
int k = size;
while (k >= 0 && abs(coef[k]) <= Pogreshnost()){
coef.erase(--coef.end());
k--;
}
size = k;
if (size > 0 || (size == 0 && coef[0] != 0)){
double norm = coef[size];
for (int i = size; i >= 0; i--){
coef[i] /= norm;
}
}
return *this;
}
};
ostream& operator << (ostream& out, const polynom<double>& P){
for (int i = P.GetSize(); i >= 0; i--){
out << P.GetCoef(i);
if (i != 0)
out << "x^" << i << " + ";
}
out << endl << endl;
return out;
}
int ReminderRecursive(int a, int b){
if (a - b >= b){
a = ReminderRecursive(a, b + b);
if (a < b) return a;
}
return a - b;
}
int ReminderNonnegative(int a, int b){
if (a < b) return a;
return ReminderRecursive(a, b);
}
int IntergerGcd(int a, int b){
while (true){
if (b == 0) return a;
a = ReminderNonnegative(a, b);
if (a == 0) return b;
b = ReminderNonnegative(b, a);
}
}
void createCoefs(polynom<double>& P){
int size = P.GetSize();
for (int i = 0; i <= size; i++){
P.SetCoef(i, (rand() % 20));
}
while(1){
if (P.GetCoef(size) == 0)
P.SetCoef(size, (rand() % 20));
else break;
}
}
void IntergerTest(){
int a, b, answer;
srand(5);
for (int i = 0; i < 100; i++){
a = rand() % 1000;
b = rand() % 1000;
answer = Gcd<int>(a, b);
assert(answer == IntergerGcd(a, b));
}
cout << "IntegerTest is done" << endl;
}
void PolynomExample(){
polynom<double> P(rand()%10);
polynom<double> Q(rand()%10);
createCoefs(P);
createCoefs(Q);
cout << "p(x) = " << P;
cout << "q(x) = " << Q;
polynom<double> A;
A = Gcd<polynom<double>> (P, Q);
cout << "gcd(p,q) = " << A;
}
double generatingNumber(vector<double>& arrayOfNumber){
double number;
do{
number = rand()%12;
}while(arrayOfNumber.end() != find(arrayOfNumber.begin(), arrayOfNumber.end(), number));
return number;
}
void CurrentPolynomTest(){
polynom<double> A(1), CommonPolynom;
A.SetCoef(1, 1);
int count;
int CommonPolynomSize = rand()%5;
double number;
vector<double> arrayOfNumber;
for (int i = 1; i <= CommonPolynomSize; i++){
number = generatingNumber(arrayOfNumber);
arrayOfNumber.push_back(number);
A.SetCoef(0, -number);
CommonPolynom = CommonPolynom * A;
}
count = rand()%5;
polynom<double> B(CommonPolynom);
while(count > 0){
number = generatingNumber(arrayOfNumber);
arrayOfNumber.push_back(number);
A.SetCoef(0, -number);
B = B * A;
count--;
}
count = rand()%5;
polynom<double> C(CommonPolynom);
while(count > 0){
number = generatingNumber(arrayOfNumber);
arrayOfNumber.push_back(number);
A.SetCoef(0, -number);
C = C * A;
count--;
}
polynom<double> resultPolynom(Gcd<polynom<double>>(B, C));
assert(resultPolynom == CommonPolynom);
}
void PolynomTest(){
for (int i = 0; i < 1000; i++){
CurrentPolynomTest();
}
cout << "PolinomTest is done" << endl;
}
int main(){
PolynomExample();
PolynomTest();
IntergerTest();
int l;
cin >> l;
return 0;
}
|
9741165ac2311c9e2e2c6e8d34f608e7202b030f
|
0ff730907cce3c00786e7d6478943b4b6d08ca46
|
/codeforces/908B.cpp
|
f94eaec55c2787f06d7ee1478e9d6902f8a0e07e
|
[] |
no_license
|
satyakesav/Competitive-Programming
|
1a864220a4adc183e278a499e184c636e932e04d
|
be825fb286224de946a31a7549c93d63e3ad176a
|
refs/heads/master
| 2021-09-05T15:17:15.574373
| 2018-01-29T07:10:57
| 2018-01-29T07:10:57
| 119,345,560
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,421
|
cpp
|
908B.cpp
|
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> perm;
void generate(vector<int>& curr, int n)
{
if (n==4)
perm.push_back(curr);
else
{
for(int i=n;i<4;i++)
{
swap(curr[n],curr[i]);
generate(curr, n+1);
swap(curr[n],curr[i]);
}
}
}
bool yes(vector<string>& s, int i, int j, string& dir, int ind, vector<int>& num)
{
int m = s.size(), n=s[0].length();
if (i<0 || j<0 || i>=m || j>=n) return false;
if (s[i][j]=='E') return true;
if (s[i][j]=='#') return false;
if (ind==dir.length()) return false;
int val = dir[ind]-'0';
if (num[val]==0) return yes(s, i+1, j, dir, ind+1, num);
if (num[val]==1) return yes(s, i, j-1, dir, ind+1, num);
if (num[val]==2) return yes(s, i-1, j, dir, ind+1, num);
if (num[val]==3) return yes(s, i, j+1, dir, ind+1, num);
return false;
}
int main() {
vector<int> curr = {0,1,2,3};
generate(curr, 0);
int m,n; cin>>m; cin>>n;
vector<string> s(m, "");
for(int i=0;i<m;i++) cin>>s[i];
string dir; cin>>dir;
int count=0, xi, xj;
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
if (s[i][j]=='S')
{
xi = i; xj = j; break;
}
for(int i=0;i<24;i++)
{
if (yes(s,xi,xj,dir,0,perm[i])) count++;
}
cout<<count<<endl;
return 0;
}
|
037d71282bab029baabcb59a7cf049a408682481
|
caf9892271b196a115a1461c1532c6379ddb2271
|
/mzModel/SpatialStructure.cpp
|
b0218ae52fb5071bb6f0206608a7938c90112159
|
[] |
no_license
|
mzleman/mzModel
|
436b5b8c345828f0587747934974d79816d05cae
|
e58374dd66df2b20a3ae45aa5dc756be0df7205c
|
refs/heads/master
| 2023-02-02T00:13:56.933787
| 2020-12-15T12:32:27
| 2020-12-15T12:32:27
| 321,662,076
| 1
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 5,782
|
cpp
|
SpatialStructure.cpp
|
#include "mzModel.h"
#include <iomanip>
SpatialStructure::SpatialStructure() {
this->cellArray = NULL;
}
SpatialStructure::SpatialStructure(int M, int N, double Blx, double Bly, double Dx, double NoValue) {
this->rows = M;
this->cols = N;
this->blx = Blx;
this->bly = Bly;
this->dx = Dx;
this->noValue = NoValue;
this->cellArray = new SpatialCell*[this->rows];
for (int i = 0; i < this->rows; i++)
this->cellArray[i] = new SpatialCell[this->cols];
#pragma omp parallel for
for (int i = 0; i < this->rows; i++) {
for (int j = 0; j < this->cols; j++)
{
this->cellArray[i][j].eastCell = (j == this->cols - 1) ? NULL : &this->cellArray[i][j + 1];
this->cellArray[i][j].westCell = (j == 0) ? NULL : &this->cellArray[i][j - 1];
this->cellArray[i][j].northCell = (i == 0) ? NULL : &this->cellArray[i-1][j];
this->cellArray[i][j].southCell = (i == this->rows-1) ? NULL : &this->cellArray[i+1][j];
}
}
cout << "new spatial structure builded" << endl;
}
int SpatialStructure::appendMatrix2d(Matrix2d & matrix) {
int flag,i,j;
cout << "Spatial Structure data: ";
cout << this->rows << " " << this->cols << " ";
cout << setprecision(12) << this->blx << " " << this->bly << " " << this->dx << " " << this->noValue << endl;
flag = (this->blx == matrix.blx) && (this->bly == matrix.bly) && (this->dx == matrix.dx)&&
(this->rows == matrix.rows) && (this->cols == matrix.cols);
if (!flag) { cout << matrix.fileName << " Exception:matrix shape wrong" << endl; return 0; }
for (i=0;i<this->rows;i++)
for (j = 0; j < this->cols; j++) {
if (matrix.arr[i][j] != NULLVAL) {
this->cellArray[i][j].addValue(matrix.arr[i][j],matrix.id);
}
}
return 1;
}
void SpatialStructure::sort() {
int i, j, k,m,len;
bool didSwap;
double temp;
string strtemp;
double* arr;
string* ids;
#pragma omp parallel for private(j,k,m,len,didSwap,temp,strtemp,arr,ids)
for (i = 0; i < this->rows; i++) {
for (j = 0; j < this->cols; j++) {
len = this->cellArray[i][j].nFloor;
arr = this->cellArray[i][j].values;
ids = this->cellArray[i][j].floorId;
for (k = 0; k < len; k++) {
didSwap = true;
for (m = 0; m < len - k - 1; m++) {
if (arr[m + 1] < arr[m]) {
temp = arr[m];
strtemp = ids[m];
arr[m] = arr[m + 1];
ids[m] = ids[m + 1];
arr[m + 1] = temp;
ids[m + 1] = strtemp;
didSwap = false;
}
}
if (didSwap) break;
}
}
}
}
void SpatialStructure::zerosLike(SpatialStructure &ss) {
this->rows = ss.rows;
this->cols = ss.cols;
this->blx = ss.blx;
this->bly = ss.bly;
this->dx = ss.dx;
this->noValue = ss.noValue;
int i, j, m, length;
SpatialCell *p,*target;
#pragma omp parallel for private(j,m,length,p,target)
for (i = 0; i < this->rows; i++) {
for (j = 0; j<this->cols; j++) {
p = &this->cellArray[i][j];
target = &ss.cellArray[i][j];
length = target->nFloor;
p->nFloor = length;
if (length > 0) {
p->values = new double[length];
p->floorId = new string[length];
for (m = 0; m < length; m++) {
p->values[m] = 0.0;
p->floorId[m] = target->floorId[m];
}
}
}
}
}
void SpatialStructure::nullValLike(SpatialStructure &ss) {
this->rows = ss.rows;
this->cols = ss.cols;
this->blx = ss.blx;
this->bly = ss.bly;
this->dx = ss.dx;
this->noValue = ss.noValue;
int i, j, m, length;
SpatialCell *p, *target;
#pragma omp parallel for private(j,m,length,p,target)
for (i = 0; i < this->rows; i++) {
for (j = 0; j < this->cols; j++) {
p = &this->cellArray[i][j];
target = &ss.cellArray[i][j];
length = target->nFloor;
p->nFloor = length;
if (length > 0) {
p->values = new double[length];
p->floorId = new string[length];
for (m = 0; m < length; m++) {
p->values[m] = NULLVAL;
p->floorId[m] = target->floorId[m];
}
}
}
}
}
void SpatialStructure::clone(SpatialStructure &ss) {
this->rows = ss.rows;
this->cols = ss.cols;
this->blx = ss.blx;
this->bly = ss.bly;
this->dx = ss.dx;
this->noValue = ss.noValue;
int i, j, m, length;
SpatialCell *p, *target;
#pragma omp parallel for private(j,m,length,p,target)
for (i = 0; i < this->rows; i++) {
for (j = 0; j < this->cols; j++) {
p = &this->cellArray[i][j];
target = &ss.cellArray[i][j];
length = target->nFloor;
p->nFloor = length;
if (length > 0) {
p->values = new double[length];
p->floorId = new string[length];
for (m = 0; m < length; m++) {
p->values[m] = target->values[m];
p->floorId[m] = target->floorId[m];
}
}
}
}
}
void SpatialStructure::valuePlus(SpatialStructure &ss) {
if (
this->rows != ss.rows ||
this->cols != ss.cols ||
this->blx != ss.blx ||
this->bly != ss.bly ||
this->dx != ss.dx ||
this->noValue != ss.noValue ||
!this->cellArray ||
!ss.cellArray
)
{
return;
}//保证头部信息相同以及矩阵存在
int i, j, m, length;
SpatialCell *p, *target;
/*double *p, *target;*/
#pragma omp parallel for private(j,m,length,p,target)
for (i = 0; i < this->rows; i++) {
for (j = 0; j < this->cols; j++) {
p = &this->cellArray[i][j];
target = &ss.cellArray[i][j];
/*length = target->nFloor;
p->nFloor = length;*/
if ( p->values &&
target->values &&
p->nFloor==target->nFloor
)
{
length = p->nFloor;
for (m = 0; m < length; m++) {
p->values[m] += target->values[m];
}
}
}
}
}
//释放堆区内存
int SpatialStructure::finalize() {
int i, j;
if (!this->cellArray) return -1;
for (i = 0; i < this->rows; i++)
{
for (j = 0; j < this->cols; j++)
{
this->cellArray[i][j].clear();//释放计算单元内的堆区内存
}
delete[] this->cellArray[i]; this->cellArray[i] = NULL;
}
delete[] this->cellArray; this->cellArray = NULL;
return 0;
}
|
65914ec80b31e7ebea6c97c898c573ea0dd6858b
|
e615dc15378d56a052c945c52bbf534e40b30047
|
/xmlparser.cpp
|
44138092979adc1d326c47d89c101b4e126b2898
|
[] |
no_license
|
k1dyamamoto/xml_corporate_parser
|
608fcdc3f7a41e4142f4bd4a3683070755bf0751
|
d0d954f6dd22f5a3c096c01b3160b64ff663fa62
|
refs/heads/master
| 2022-11-17T17:58:07.997094
| 2020-07-07T08:31:52
| 2020-07-07T08:31:52
| 274,208,413
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,495
|
cpp
|
xmlparser.cpp
|
#include "xmlparser.h"
std::string cut(std::string &s)
{
int p1 = 1 + s.find('>');
int p2 = s.find('<', p1);
return s.substr(p1, p2 - p1);
}
bool contains(const std::string &str, const std::string &sub)
{
return (str.find(sub) != std::string::npos);
}
void read_xml(const std::string &input_file, std::vector<Department*> &tree)
{
std::ifstream xml(input_file);
std::string curline;
int cur_dept = -1;
while (getline(xml, curline)) {
if (contains(curline, "<department ")) {
int begin = curline.find('"');
std::string name = "";
while (curline[++begin] != '"')
name += curline[begin];
tree.push_back(new Department(name));
cur_dept++;
} else if (contains(curline, "<employment>")) {
std::string emp_surname, emp_name,
emp_middlename, emp_function;
int emp_salary;
for (int i = 0; i < 5; ++i) {
getline(xml, curline);
if (contains(curline, "<name>")) {
emp_name = cut(curline);
} else if (contains(curline, "<surname>")) {
emp_surname = cut(curline);
} else if (contains(curline, "<middleName>")) {
emp_middlename = cut(curline);
} else if (contains(curline, "<function>")) {
emp_function = cut(curline);
} else if (contains(curline, "<salary>")) {
emp_salary = std::stoi(cut(curline));
}
}
tree[cur_dept]->add_emp(new Employee(emp_salary, emp_name,
emp_surname, emp_middlename, emp_function));
}
}
}
void writexml(const std::string &output_file, const std::vector<Department*> &tree)
{
std::ofstream xml(output_file);
xml << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<departments>\n";
for (auto &dep : tree) {
xml << " <department name=\"";
xml << dep->get_name() << "\">\n";
auto emps = dep->get_emp();
xml << " <employments>\n";
for (auto &emp : emps) {
xml << " <employment>\n"
<< " <surname>"
<< emp->get_surname() << "</surname>\n"
<< " <name>"
<< emp->get_name() << "</name>\n"
<< " <middleName>"
<< emp->get_middlename() << "</middleName>\n"
<< " <function>"
<< emp->get_function() << "</function>\n"
<< " <salary>"
<< emp->get_salary() << "</salary>\n"
<< " </employment>\n";
}
xml << " </employments>\n" << " </department>\n";
}
xml << "</departments>";
}
|
f02f2f066984a81e1c87ecdd1c3ed5cfa7cea0e9
|
9f8ff58fac6fdb0e1c612aa00b3f954a03d58bfe
|
/C++/Fibonacci.cpp
|
d107ca199a81bf38645193ab858a2435aaebfc6a
|
[] |
no_license
|
sukriti-singh/Hacktober-Fest-2019
|
9db87786433e7877fb33990dbc9c1bec117e31e3
|
cee38660deba2ebeda53547a719f607d5a6e1317
|
refs/heads/master
| 2020-08-27T11:06:18.730065
| 2019-10-24T17:03:34
| 2019-10-24T17:03:34
| 217,344,423
| 1
| 0
| null | 2019-10-24T16:29:13
| 2019-10-24T16:29:12
| null |
UTF-8
|
C++
| false
| false
| 291
|
cpp
|
Fibonacci.cpp
|
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int a=0,b=1;
int f=1;
cout<<"0"<<endl;
for(int i=2;i<=n;i++){
for(int j=1;j<=i;j++){
cout<<f<<" ";
f=a+b; a=b; b=f;
}
cout<<endl;
}
return 0;
}
|
a535f6607272edc90024e055310a32fb7822be0b
|
6fb523a5ad9eb2152b306de7a2741acd26f6bded
|
/ProjetInterSpe/animation.h
|
62996b7b2fb9b281540cc1e701ce5f30f4a7c303
|
[] |
no_license
|
JohnDRO/ProjetInterSpe
|
7954c9dedbf05aab7e46271c8f9f4096911c1423
|
dcf831fa817f8c68c6df88447b4605b16e034c1c
|
refs/heads/master
| 2020-12-30T18:16:20.132461
| 2016-06-17T13:42:25
| 2016-06-17T13:42:25
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 682
|
h
|
animation.h
|
#pragma once
#include "geometry.h"
#include "math.h"
#define PI 3.14159265358979323846
class Animation
{
private:
double angle;
double angle_incr;
Vector rot_vect;
public:
Animation(double agl = 0.0, double aglinc = PI / 12, Vector vect = Vector(1.0, 0.0, 0.0)) { angle = agl; rot_vect = vect; angle_incr = aglinc; }
const double getAngle() {return angle;}
void setAngle(double agl) {angle = agl;}
/*const double getAngleIncr() { return angle_incr; }
void setAngleIncr(double aglinc) { angle_incr = aglinc; }*/
const Vector getRotVect() {return rot_vect;}
void setRotVect(Vector vect) {rot_vect = vect;}
void update();
};
|
21de30d6c015766b6fd92100f36297fe52c09d31
|
508188ce839f454a128c3a1e9bb50c09cb83fcc0
|
/DotNet/IlAsm2Cpp/bin/Release/il2cpp/Root.T_x59.h
|
91d03e6078122afcc2aa45c6741ad7448401329c
|
[] |
no_license
|
dreamanlan/OldWork
|
1162bd208c9c5697ac4a30570b134c8b717e6ee6
|
f49b780e7094ae8d4be6920da0a900a5feb5cce8
|
refs/heads/master
| 2020-07-02T06:35:07.616480
| 2019-09-29T02:32:50
| 2019-09-29T02:32:50
| 67,272,042
| 6
| 5
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 19,990
|
h
|
Root.T_x59.h
|
#pragma once
namespace Root
{
[StructLayout(LayoutKind::Auto , CharSet=CharSet::Ansi)]
public
ref class T_x59 : Reflector::CodeModel::ILanguage
{
ref class T_x1;
internal:
[StructLayout(LayoutKind::Auto , CharSet=CharSet::Ansi)]
ref class T_x1 : Reflector::CodeModel::ILanguageWriter
{
ref class T_x1_2;
internal:
[StructLayout(LayoutKind::Auto , CharSet=CharSet::Ansi)]
ref class T_x1_2 : Reflector::CodeModel::IFormatter
{
private:
System::IO::StringWriter^ F_x1;
private:
System::Boolean F_x2;
private:
System::Int32 F_x12;
public:
virtual System::String^ M_x13() = System::Object::ToString;
//System::Object^::ToString by M_x13
public:
virtual void M_x12(System::String^ A_0) sealed = Reflector::CodeModel::IFormatter::Write;
//Reflector::CodeModel::IFormatter^::Write by M_x12
public:
virtual void M_x13(System::String^ A_0) sealed = Reflector::CodeModel::IFormatter::WriteDeclaration;
//Reflector::CodeModel::IFormatter^::WriteDeclaration by M_x13
public:
virtual void M_x5(System::String^ A_0) sealed = Reflector::CodeModel::IFormatter::WriteComment;
//Reflector::CodeModel::IFormatter^::WriteComment by M_x5
public:
virtual void M_x2(System::String^ A_0) sealed = Reflector::CodeModel::IFormatter::WriteLiteral;
//Reflector::CodeModel::IFormatter^::WriteLiteral by M_x2
public:
virtual void M_x8(System::String^ A_0) sealed = Reflector::CodeModel::IFormatter::WriteKeyword;
//Reflector::CodeModel::IFormatter^::WriteKeyword by M_x8
public:
virtual void M_x12() sealed = Reflector::CodeModel::IFormatter::WriteIndent;
//Reflector::CodeModel::IFormatter^::WriteIndent by M_x12
public:
virtual void M_x2() sealed = Reflector::CodeModel::IFormatter::WriteLine;
//Reflector::CodeModel::IFormatter^::WriteLine by M_x2
public:
virtual void M_x8() sealed = Reflector::CodeModel::IFormatter::WriteOutdent;
//Reflector::CodeModel::IFormatter^::WriteOutdent by M_x8
public:
virtual void M_x1(System::String^ A_0,System::String^ A_1,System::Object^ A_2) sealed = Reflector::CodeModel::IFormatter::WriteReference;
//Reflector::CodeModel::IFormatter^::WriteReference by M_x1
public:
virtual void M_x1(System::String^ A_0,System::String^ A_1) sealed = Reflector::CodeModel::IFormatter::WriteProperty;
//Reflector::CodeModel::IFormatter^::WriteProperty by M_x1
private:
void M_x1(System::String^ A_0);
private:
void M_x1(System::String^ A_0,System::Int32 A_1);
private:
void M_x1();
public:
T_x1_2();
};
private:
Reflector::CodeModel::IFormatter^ F_x1;
private:
Reflector::CodeModel::ILanguageWriterConfiguration^ F_x2;
private:
static System::Collections::Hashtable^ F_x12;
private:
static System::Collections::Hashtable^ F_x13;
private:
System::Boolean F_x8;
private:
System::Boolean F_x5;
private:
System::Int32 F_x9;
private:
System::Int32 F_x4;
private:
System::Collections::ArrayList^ F_x15;
public:
T_x1(Reflector::CodeModel::IFormatter^ A_0,Reflector::CodeModel::ILanguageWriterConfiguration^ A_1);
private:
static T_x1();
public:
virtual void M_x1(Reflector::CodeModel::IAssembly^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteAssembly;
//Reflector::CodeModel::ILanguageWriter^::WriteAssembly by M_x1
public:
virtual void M_x1(Reflector::CodeModel::IAssemblyReference^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteAssemblyReference;
//Reflector::CodeModel::ILanguageWriter^::WriteAssemblyReference by M_x1
public:
virtual void M_x1(Reflector::CodeModel::IModule^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteModule;
//Reflector::CodeModel::ILanguageWriter^::WriteModule by M_x1
public:
virtual void M_x1(Reflector::CodeModel::IModuleReference^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteModuleReference;
//Reflector::CodeModel::ILanguageWriter^::WriteModuleReference by M_x1
public:
virtual void M_x1(Reflector::CodeModel::IResource^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteResource;
//Reflector::CodeModel::ILanguageWriter^::WriteResource by M_x1
public:
virtual void M_x1(Reflector::CodeModel::INamespace^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteNamespace;
//Reflector::CodeModel::ILanguageWriter^::WriteNamespace by M_x1
public:
System::Boolean M_x1(Reflector::CodeModel::ICustomAttributeProvider^ A_0);
public:
virtual void M_x1(Reflector::CodeModel::ITypeDeclaration^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteTypeDeclaration;
//Reflector::CodeModel::ILanguageWriter^::WriteTypeDeclaration by M_x1
public:
void M_x1(Reflector::CodeModel::TypeVisibility A_0,Reflector::CodeModel::IFormatter^ A_1);
public:
void M_x1(Reflector::CodeModel::FieldVisibility A_0,Reflector::CodeModel::IFormatter^ A_1);
public:
void M_x1(Reflector::CodeModel::MethodVisibility A_0,Reflector::CodeModel::IFormatter^ A_1);
public:
virtual void M_x2(Reflector::CodeModel::IFieldDeclaration^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteFieldDeclaration;
//Reflector::CodeModel::ILanguageWriter^::WriteFieldDeclaration by M_x2
public:
virtual void M_x1(Reflector::CodeModel::IMethodDeclaration^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteMethodDeclaration;
//Reflector::CodeModel::ILanguageWriter^::WriteMethodDeclaration by M_x1
public:
virtual void M_x1(Reflector::CodeModel::IPropertyDeclaration^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WritePropertyDeclaration;
//Reflector::CodeModel::ILanguageWriter^::WritePropertyDeclaration by M_x1
public:
virtual void M_x12(Reflector::CodeModel::IEventDeclaration^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteEventDeclaration;
//Reflector::CodeModel::ILanguageWriter^::WriteEventDeclaration by M_x12
private:
void M_x12(Reflector::CodeModel::ITypeReference^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
System::String^ M_x13(Reflector::CodeModel::ITypeReference^ A_0);
private:
void M_x1(Reflector::CodeModel::IType^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x2(Reflector::CodeModel::IMethodDeclaration^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IMethodDeclaration^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IParameterDeclaration^ A_0,Reflector::CodeModel::IFormatter^ A_1,Reflector::CodeModel::ILanguageWriterConfiguration^ A_2);
private:
void M_x1(Reflector::CodeModel::IParameterDeclarationCollection^ A_0,Reflector::CodeModel::IFormatter^ A_1,Reflector::CodeModel::ILanguageWriterConfiguration^ A_2);
private:
void M_x1(Reflector::CodeModel::ICustomAttribute^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ICustomAttributeProvider^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x2(Reflector::CodeModel::ITypeCollection^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ITypeCollection^ A_0,Reflector::CodeModel::IFormatter^ A_1);
public:
virtual void M_x1(Reflector::CodeModel::IExpression^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteExpression;
//Reflector::CodeModel::ILanguageWriter^::WriteExpression by M_x1
private:
void M_x12(Reflector::CodeModel::IExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IExpressionCollection^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IGenericDefaultExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ITypeOfTypedReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::INamedArgumentExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IMemberReference^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x2(Reflector::CodeModel::IExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ITypeOfExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IFieldOfExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IMethodOfExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IArrayCreateExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IArrayInitializerExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IBaseReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ITryCastExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ICanCastExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ICastExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IConditionExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IDelegateCreateExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ITypeReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IFieldReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IArgumentReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IArgumentListExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IVariableReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IVariableReference^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IPropertyIndexerExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IArrayIndexerExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IMethodInvokeExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IMethodReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IEventReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IDelegateInvokeExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IObjectCreateExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IPropertyReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IThisReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IAddressOfExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IAddressReferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IAddressOutExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IAddressDereferenceExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ISizeOfExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IStackAllocateExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ISnippetExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IUnaryExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IBinaryExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x2(Reflector::CodeModel::IExpressionStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::BinaryOperator A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
System::String^ M_x12(System::String^ A_0);
private:
void M_x1(Reflector::CodeModel::ILiteralExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x2(Reflector::CodeModel::ITypeReference^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ITypeReference^ A_0,System::String^ A_1,System::Object^ A_2,Reflector::CodeModel::IFormatter^ A_3);
private:
void M_x1(Reflector::CodeModel::IFieldReference^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IMethodReference^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IPropertyReference^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IEventReference^ A_0,Reflector::CodeModel::IFormatter^ A_1);
public:
virtual void M_x1(Reflector::CodeModel::IStatement^ A_0) sealed = Reflector::CodeModel::ILanguageWriter::WriteStatement;
//Reflector::CodeModel::ILanguageWriter^::WriteStatement by M_x1
private:
void M_x1(Reflector::CodeModel::IStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1,System::Boolean A_2);
private:
void M_x2(Reflector::CodeModel::IFormatter^ A_0);
private:
void M_x1();
private:
void M_x1(Reflector::CodeModel::IFormatter^ A_0);
private:
void M_x1(Reflector::CodeModel::IBlockStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x2(Reflector::CodeModel::IStatementCollection^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IMemoryCopyStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IMemoryInitializeStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IObjectInitializeExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ILockStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IStatementCollection^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IStatementCollection^ A_0,Reflector::CodeModel::IFormatter^ A_1,System::Boolean A_2,System::Boolean A_3);
private:
void M_x1(Reflector::CodeModel::ICommentStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IMethodReturnStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1,System::Boolean A_2);
private:
void M_x1(Reflector::CodeModel::IConditionStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ITryCatchFinallyStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IAssignExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IExpressionStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IForStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IForEachStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IUsingStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IFixedStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IWhileStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IDoStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IBreakStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IContinueStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IThrowExceptionStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IVariableDeclarationExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IVariableDeclaration^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IAttachEventStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IRemoveEventStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ISwitchStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IExpression^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IGotoStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ILabeledStatement^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::ITypeReference^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(Reflector::CodeModel::IAssemblyReference^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
System::String^ M_x12(Reflector::CodeModel::ITypeReference^ A_0);
private:
System::String^ M_x1(Reflector::CodeModel::IFieldReference^ A_0);
private:
System::String^ M_x2(Reflector::CodeModel::IMethodReference^ A_0);
private:
System::String^ M_x1(Reflector::CodeModel::IPropertyReference^ A_0);
private:
System::String^ M_x1(Reflector::CodeModel::IEventReference^ A_0);
private:
Reflector::CodeModel::ICustomAttribute^ M_x1(Reflector::CodeModel::ICustomAttributeProvider^ A_0,System::String^ A_1,System::String^ A_2);
private:
System::String^ M_x2(System::String^ A_0);
private:
System::Boolean M_x1(Reflector::CodeModel::IMethodReference^ A_0);
private:
System::Boolean M_x2(Reflector::CodeModel::IEventDeclaration^ A_0);
private:
Reflector::CodeModel::MethodVisibility M_x1(Reflector::CodeModel::IEventDeclaration^ A_0);
private:
System::Boolean M_x1(Reflector::CodeModel::IFieldDeclaration^ A_0);
private:
System::Boolean M_x1(System::String^ A_0);
private:
void M_x2(System::String^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(System::String^ A_0,Reflector::CodeModel::IFormatter^ A_1);
private:
void M_x1(System::String^ A_0,System::String^ A_1,System::Object^ A_2,Reflector::CodeModel::IFormatter^ A_3);
public:
static System::Boolean M_x2(Reflector::CodeModel::ITypeReference^ A_0);
public:
static System::Boolean M_x1(Reflector::CodeModel::ITypeReference^ A_0);
public:
static System::Boolean M_x1(Reflector::CodeModel::IType^ A_0,System::String^ A_1,System::String^ A_2);
};
public:
virtual System::String^ M_x12() sealed = Reflector::CodeModel::ILanguage::Name::get;
//Reflector::CodeModel::ILanguage^::get_Name by M_x12
public:
virtual System::String^ M_x2() sealed = Reflector::CodeModel::ILanguage::FileExtension::get;
//Reflector::CodeModel::ILanguage^::get_FileExtension by M_x2
public:
virtual System::Boolean M_x1() sealed = Reflector::CodeModel::ILanguage::Translate::get;
//Reflector::CodeModel::ILanguage^::get_Translate by M_x1
public:
virtual Reflector::CodeModel::ILanguageWriter^ M_x1(Reflector::CodeModel::IFormatter^ A_0,Reflector::CodeModel::ILanguageWriterConfiguration^ A_1) sealed = Reflector::CodeModel::ILanguage::GetWriter;
//Reflector::CodeModel::ILanguage^::GetWriter by M_x1
public:
T_x59();
};
}
|
581395ea055b3aacc86b8081358d0199c143c766
|
338c6e51883f9264890dbdfa4cbf141fce1db35d
|
/include/Fly.h
|
2341de9f4edba2ffeedb9290bbad6a5befb617e1
|
[] |
no_license
|
dvora1208/Fun-Run
|
53791286469bf0d412fa2b3a08825fd6d25308c8
|
12658b6c3fa5d28eadd2c44c9538893e37e9d171
|
refs/heads/main
| 2023-03-25T19:12:19.983560
| 2021-03-24T18:13:16
| 2021-03-24T18:13:16
| 351,179,200
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 495
|
h
|
Fly.h
|
#pragma once
#include "Enemy.h"
class Fly :
public Enemy
{
public:
Fly(sf::Vector2f pos, sf::RenderWindow & window);
void draw(sf::RenderWindow &);
sf::Vector2f get_position() const;
const sf::Sprite &get_pic() const;
void update(sf::Vector2f centerPos);
void flip_pic_left();
void flip_pic_right();
void SetDelta(float);
void animate();
~Fly();
private:
sf::Clock m_movement_clock;
float m_delta; // delta for the movement
static bool m_registerit; // for the enemyfactor
};
|
9c2430ec83bfd45802c1e23f5ae1f393c8fd47ec
|
420e0537269dc0e47832205b3982bce6189b850e
|
/Spoj/NECKLACE.cpp
|
a849cae73d7c61046923c37750641cceae5ae530
|
[] |
no_license
|
gcdart/PC-solutions
|
20819d8bd89e4847773174120453d417f1aa2bdb
|
0660b46053389ab895440583fef5d4fee0f011ee
|
refs/heads/master
| 2016-09-06T15:10:57.597470
| 2013-07-16T16:53:52
| 2013-07-16T16:53:52
| 11,454,579
| 4
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,707
|
cpp
|
NECKLACE.cpp
|
/*
ID: gcdart1
PROG: beads
LANG: C++
*/
#include <fstream>
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <list>
#include <queue>
#include <algorithm>
#include <map>
#include <cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
#define repv(i,ar) for(int i=0;i<ar.size();i++)
#define sor(ar) sort(ar.begin(),ar.end())
#define VS vector<string>
#define VI vector<int>
#define p_b push_back
#define ll long long int
#define sz size()
using namespace std;
string g_str;
string get_back(int i){
int j=i-1;if(j<0) j=g_str.length()-1;
char c=g_str[j];
string ret="";
while(c=='w'){
ret+=c;
j--;if(j<0) j=g_str.length()-1;
c=g_str[j];
}
while(g_str[j]==c || g_str[j]=='w'){
ret+=c;
j--;if(j<0) j=g_str.length()-1;
}
return ret;
}
string get_front(int i){
int j=i;string ret="";
char c=g_str[i];
while(c=='w'){
ret+=c;
j++;if(j==g_str.length()) j=0;
c=g_str[j];
}
while(g_str[j]==c || g_str[j]=='w'){
ret+=c;
j++;if(j==g_str.length()) j=0;
}
return ret;
}
int main(){
ifstream fin("beads.in");
ofstream fout("beads.out");
int waste;fin >> waste;
string str;fin >> str;
g_str=str;
bool flag1=false,flag2=false;
repv(i,str) {
if(str[i]=='r') flag1=true;
else if(str[i]=='b') flag2=true;
}
if(!flag1 || !flag2){
fout << str.length() << endl;exit(0);}
int maxcnt=-1;
repv(i,str){
string s1=get_back(i);
string s2=get_front(i);
int cnt=s1.length()+s2.length();
if(cnt > str.size()) cnt=str.size();
if(cnt > maxcnt) maxcnt=cnt;
}
fout << maxcnt << endl;
exit(0);
}
|
86eb9f827a36562f45a2dfbb6a92b45f8cb2229c
|
693b19cd36f52a503b8ac1c9b54b9be6aeea9e76
|
/componentes/TMS Component Pack/TMS Scripter Studio Pro/Source/DesignerTabOrderDialog.hpp
|
b90d86e9646efa71505f46ba80734083dbf25dad
|
[] |
no_license
|
chinnyannieb/Meus-Projetos
|
728e603b451ea4262f9e6f4bf7e3dd05f0d1e79e
|
6e08497c8fc45c142d7be1c4408f02fa524cd71f
|
refs/heads/master
| 2020-12-25T23:58:02.724867
| 2015-07-05T11:45:08
| 2015-07-05T11:45:08
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,799
|
hpp
|
DesignerTabOrderDialog.hpp
|
// CodeGear C++Builder
// Copyright (c) 1995, 2010 by Embarcadero Technologies, Inc.
// All rights reserved
// (DO NOT EDIT: machine generated header) 'DesignerTabOrderDialog.pas' rev: 22.00
#ifndef DesignertaborderdialogHPP
#define DesignertaborderdialogHPP
#pragma delphiheader begin
#pragma option push
#pragma option -w- // All warnings off
#pragma option -Vx // Zero-length empty class member functions
#pragma pack(push,8)
#include <System.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <Windows.hpp> // Pascal unit
#include <Messages.hpp> // Pascal unit
#include <SysUtils.hpp> // Pascal unit
#include <Classes.hpp> // Pascal unit
#include <Graphics.hpp> // Pascal unit
#include <Controls.hpp> // Pascal unit
#include <Forms.hpp> // Pascal unit
#include <Dialogs.hpp> // Pascal unit
#include <StdCtrls.hpp> // Pascal unit
#include <Buttons.hpp> // Pascal unit
//-- user supplied -----------------------------------------------------------
namespace Designertaborderdialog
{
//-- type declarations -------------------------------------------------------
class DELPHICLASS TfrmTabOrder;
class PASCALIMPLEMENTATION TfrmTabOrder : public Forms::TForm
{
typedef Forms::TForm inherited;
__published:
Stdctrls::TLabel* lblControls;
Stdctrls::TListBox* lsbControls;
Buttons::TBitBtn* bbtMoveUp;
Buttons::TBitBtn* bbtMoveDown;
Stdctrls::TButton* btnOK;
Stdctrls::TButton* btnCancel;
void __fastcall bbtMoveUpClick(System::TObject* Sender);
void __fastcall bbtMoveDownClick(System::TObject* Sender);
void __fastcall lsbControlsDragOver(System::TObject* Sender, System::TObject* Source, int X, int Y, Controls::TDragState State, bool &Accept);
void __fastcall lsbControlsStartDrag(System::TObject* Sender, Controls::TDragObject* &DragObject);
void __fastcall lsbControlsDragDrop(System::TObject* Sender, System::TObject* Source, int X, int Y);
private:
int FDragIndex;
public:
/* TCustomForm.Create */ inline __fastcall virtual TfrmTabOrder(Classes::TComponent* AOwner) : Forms::TForm(AOwner) { }
/* TCustomForm.CreateNew */ inline __fastcall virtual TfrmTabOrder(Classes::TComponent* AOwner, int Dummy) : Forms::TForm(AOwner, Dummy) { }
/* TCustomForm.Destroy */ inline __fastcall virtual ~TfrmTabOrder(void) { }
public:
/* TWinControl.CreateParented */ inline __fastcall TfrmTabOrder(HWND ParentWindow) : Forms::TForm(ParentWindow) { }
};
//-- var, const, procedure ---------------------------------------------------
} /* namespace Designertaborderdialog */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE)
using namespace Designertaborderdialog;
#endif
#pragma pack(pop)
#pragma option pop
#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // DesignertaborderdialogHPP
|
6d245a06454910de52fe04cdff8f5e3e47f1ad81
|
34bdaccc678444fe335b34d449323acf3887c3ef
|
/mainwindow.h
|
4b49256b673374fb57227b685848edfadaf60cdc
|
[
"MIT"
] |
permissive
|
bmhenry/MusicVisualizer
|
58e40675acd2137d8092889905ce99cb2e6762b1
|
52669a2370a5e31d113e7342989a1065cf05ebf1
|
refs/heads/master
| 2021-04-15T07:29:21.900880
| 2018-03-24T19:54:33
| 2018-03-24T19:54:33
| 126,635,008
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 646
|
h
|
mainwindow.h
|
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QLabel>
#include <QMenuBar>
#include <QAction>
#include <QShortcut>
#include "canvaswidget.h"
/*
* MainWindow:
* Main display window for the Qt app
*/
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
// ~MainWindow();
private:
CanvasWidget* canvas;
QTimer* timer;
QShortcut* fullscreenShortcut;
virtual void resizeEvent(QResizeEvent *event);
private slots:
inline void toggleFullscreen() { if (!isFullScreen()) showFullScreen(); else showNormal(); }
};
#endif // MAINWINDOW_H
|
5b7096ded31c82e2ef1e9c6615269b3ba3a9ba66
|
7c4e895b9db057e1b02c3576c4facff4ec37a851
|
/libraries/USB_Host_Shield_2.0-master/examples/Xbox/XBOXONE/XBOXONE.ino
|
e54b9c28c6563a0b7c0589731dcc856dc598a567
|
[
"GPL-2.0-only",
"GPL-1.0-or-later"
] |
permissive
|
westpoint-robotics/GLAWS
|
dcd2c1510fe241c9663585aa71cdabde6b5b4fd0
|
dc40dfc914a3193c298088db7a578739876d217d
|
refs/heads/master
| 2023-05-01T05:08:12.486235
| 2023-04-19T16:40:52
| 2023-04-19T16:40:52
| 54,519,438
| 1
| 2
|
Apache-2.0
| 2023-04-13T19:10:19
| 2016-03-23T00:53:18
| null |
UTF-8
|
C++
| false
| false
| 4,138
|
ino
|
XBOXONE.ino
|
/*
Example sketch for the Xbox ONE USB library - by guruthree, based on work by
Kristian Lauszus.
*/
#include <XBOXONE.h>
// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
#include <SPI.h>
USB Usb;
XBOXONE Xbox(&Usb);
void setup() {
Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); //halt
}
Serial.print(F("\r\nXBOX ONE USB Library Started"));
}
void loop() {
Usb.Task();
if (Xbox.XboxOneConnected) {
if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) {
Serial.print(F("LeftHatX: "));
Serial.print(Xbox.getAnalogHat(LeftHatX));
Serial.print("\t");
}
if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) {
Serial.print(F("LeftHatY: "));
Serial.print(Xbox.getAnalogHat(LeftHatY));
Serial.print("\t");
}
if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) {
Serial.print(F("RightHatX: "));
Serial.print(Xbox.getAnalogHat(RightHatX));
Serial.print("\t");
}
if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
Serial.print(F("RightHatY: "));
Serial.print(Xbox.getAnalogHat(RightHatY));
}
Serial.println();
}
if (Xbox.getButtonPress(LT) > 0 || Xbox.getButtonPress(RT) > 0) {
if (Xbox.getButtonPress(LT) > 0) {
Serial.print(F("LT: "));
Serial.print(Xbox.getButtonPress(LT));
Serial.print("\t");
}
if (Xbox.getButtonPress(RT) > 0) {
Serial.print(F("RT: "));
Serial.print(Xbox.getButtonPress(RT));
Serial.print("\t");
}
Serial.println();
}
// Set rumble effect
static uint16_t oldLTValue, oldRTValue;
if (Xbox.getButtonPress(LT) != oldLTValue || Xbox.getButtonPress(RT) != oldRTValue) {
oldLTValue = Xbox.getButtonPress(LT);
oldRTValue = Xbox.getButtonPress(RT);
uint8_t leftRumble = map(oldLTValue, 0, 1023, 0, 255); // Map the trigger values into a byte
uint8_t rightRumble = map(oldRTValue, 0, 1023, 0, 255);
if (leftRumble > 0 || rightRumble > 0)
Xbox.setRumbleOn(leftRumble, rightRumble, leftRumble, rightRumble);
else
Xbox.setRumbleOff();
}
if (Xbox.getButtonClick(UP))
Serial.println(F("Up"));
if (Xbox.getButtonClick(DOWN))
Serial.println(F("Down"));
if (Xbox.getButtonClick(LEFT))
Serial.println(F("Left"));
if (Xbox.getButtonClick(RIGHT))
Serial.println(F("Right"));
if (Xbox.getButtonClick(START))
Serial.println(F("Start"));
if (Xbox.getButtonClick(BACK))
Serial.println(F("Back"));
if (Xbox.getButtonClick(XBOX))
Serial.println(F("Xbox"));
if (Xbox.getButtonClick(SYNC))
Serial.println(F("Sync"));
if (Xbox.getButtonClick(SHARE))
Serial.println(F("Share"));
if (Xbox.getButtonClick(LB))
Serial.println(F("LB"));
if (Xbox.getButtonClick(RB))
Serial.println(F("RB"));
if (Xbox.getButtonClick(LT))
Serial.println(F("LT"));
if (Xbox.getButtonClick(RT))
Serial.println(F("RT"));
if (Xbox.getButtonClick(L3))
Serial.println(F("L3"));
if (Xbox.getButtonClick(R3))
Serial.println(F("R3"));
if (Xbox.getButtonClick(A))
Serial.println(F("A"));
if (Xbox.getButtonClick(B))
Serial.println(F("B"));
if (Xbox.getButtonClick(X))
Serial.println(F("X"));
if (Xbox.getButtonClick(Y))
Serial.println(F("Y"));
}
delay(1);
}
|
156a90778f7e4a42493dabfd618c5c2ebe46f55f
|
b3e525a3c48800303019adac8f9079109c88004e
|
/platform/drivers/linux/rdma/test-res/test_res.cc
|
017a8c1e39d1f690ac696a3c7f9eb7a9f501c55f
|
[] |
no_license
|
PsymonLi/sw
|
d272aee23bf66ebb1143785d6cb5e6fa3927f784
|
3890a88283a4a4b4f7488f0f79698445c814ee81
|
refs/heads/master
| 2022-12-16T21:04:26.379534
| 2020-08-27T07:57:22
| 2020-08-28T01:15:20
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,004
|
cc
|
test_res.cc
|
#include <random>
#include <gtest/gtest.h>
#include "wrap_res.h"
class Buddy : public ::testing::Test {
protected:
Buddy() {
order_max = 20;
buddy_init(&buddy, BIT(order_max));
}
~Buddy() {
check_invariants();
buddy_destroy(&buddy);
}
void check_order_next(int order) const {
int pos = bitmap_find_free_region(buddy.inuse,
buddy.inuse_size,
order);
if (pos >= 0) {
// if it was found just above, release it here
bitmap_release_region(buddy.inuse, pos, order);
// if it could be found, it must not be skipped
EXPECT_LE(buddy.order_next[order], BIT_WORD(pos))
<< "order: " << order;
}
}
void check_order_next_all() const {
for (int i = 0; i <= buddy.order_max; ++i)
check_order_next(i);
}
void check_invariants() const {
check_order_next_all();
}
struct buddy_bits buddy;
int order_max;
};
TEST_F(Buddy, InitMaxOrder) {
EXPECT_EQ(buddy.order_max, order_max);
}
TEST_F(Buddy, OrderZero) {
int pos, i;
for (i = 0; i < BITS_PER_LONG; ++i) {
EXPECT_EQ(buddy.order_next[0], 0);
EXPECT_EQ(buddy.order_next[1], 0);
EXPECT_EQ(buddy.order_next[buddy.order_max], 0);
pos = buddy_get(&buddy, 0);
EXPECT_EQ(pos, i);
}
for (i = 0; i < BITS_PER_LONG; ++i) {
EXPECT_EQ(buddy.order_next[0], 1);
EXPECT_EQ(buddy.order_next[1], 1);
EXPECT_EQ(buddy.order_next[buddy.order_max], BIT_WORD(BIT(buddy.order_max)));
pos = buddy_get(&buddy, 0);
EXPECT_EQ(pos, i + BITS_PER_LONG);
}
EXPECT_EQ(buddy.order_next[0], 2);
EXPECT_EQ(buddy.order_next[1], 2);
EXPECT_EQ(buddy.order_next[buddy.order_max], BIT_WORD(BIT(buddy.order_max)));
buddy_put(&buddy, BITS_PER_LONG-1, 0);
EXPECT_EQ(buddy.order_next[0], 0);
EXPECT_EQ(buddy.order_next[1], 0);
EXPECT_EQ(buddy.order_next[buddy.order_max], 0);
pos = buddy_get(&buddy, 0);
EXPECT_EQ(pos, BITS_PER_LONG-1);
EXPECT_EQ(buddy.order_next[0], 1);
EXPECT_EQ(buddy.order_next[1], 1);
EXPECT_EQ(buddy.order_next[buddy.order_max], BIT_WORD(BIT(buddy.order_max)));
pos = buddy_get(&buddy, 0);
EXPECT_EQ(pos, 2*BITS_PER_LONG);
EXPECT_EQ(buddy.order_next[0], 2);
EXPECT_EQ(buddy.order_next[1], 2);
EXPECT_EQ(buddy.order_next[buddy.order_max], BIT_WORD(BIT(buddy.order_max)));
}
TEST_F(Buddy, OrderMany) {
int pos;
pos = buddy_get(&buddy, 1);
EXPECT_EQ(pos, 0);
pos = buddy_get(&buddy, 9);
EXPECT_EQ(pos, BIT(9));
buddy_put(&buddy, BIT(9), 9);
pos = buddy_get(&buddy, 9);
EXPECT_EQ(pos, BIT(9));
pos = buddy_get(&buddy, 9);
EXPECT_EQ(pos, 2*BIT(9));
buddy_put(&buddy, BIT(9), 9);
pos = buddy_get(&buddy, 9);
EXPECT_EQ(pos, BIT(9));
pos = buddy_get(&buddy, 9);
EXPECT_EQ(pos, 3*BIT(9));
pos = buddy_get(&buddy, 0);
EXPECT_EQ(pos, 2);
pos = buddy_get(&buddy, 8);
EXPECT_EQ(pos, BIT(8));
pos = buddy_get(&buddy, 6);
EXPECT_EQ(pos, BIT(6));
pos = buddy_get(&buddy, 6);
EXPECT_EQ(pos, 2*BIT(6));
pos = buddy_get(&buddy, 10);
EXPECT_EQ(pos, 2*BIT(10));
}
TEST_F(Buddy, OrderTenEleven) {
int pos_10, pos_11;
// A failing sequence found by randomized test
// Made into this unit test and fixed:
pos_10 = buddy_get(&buddy, 10);
pos_11 = buddy_get(&buddy, 11);
buddy_put(&buddy, pos_10, 10);
buddy_put(&buddy, pos_11, 11);
// invariants checked in destructor
}
TEST_F(Buddy, OrderZeroFive) {
// A failing sequence found by randomized test
// Made into this unit test and fixed:
buddy_get(&buddy, 0);
buddy_get(&buddy, 5);
// invariants checked in destructor
}
TEST_F(Buddy, Randomized) {
// buddy_get or put? , pos , order
std::vector<std::tuple<bool,int,int>> hist;
// pos -> order
std::map<int,int> buds;
// random source
std::mt19937 rng;
int iter, count = 5000;
bool inject_failure;
// usage: INJECT_FAILURE= ./test_res [test options...]
inject_failure = !!getenv("INJECT_FAILURE");
// randomize with --gtest_shuffle
rng.seed(::testing::UnitTest::GetInstance()->random_seed());
for (iter = 0; iter < count; ++iter) {
int pos, order;
if (buds.empty() || !(rng() & 1)) {
order = __builtin_popcount(rng() & ((1ull << buddy.order_max) - 1));
pos = buddy_get(&buddy, order);
hist.push_back(std::make_tuple(true, pos, order));
if (pos >= 0)
buds[pos] = order;
} else {
auto it = buds.begin();
std::advance(it, rng() % buds.size());
pos = it->first;
order = it->second;
buddy_put(&buddy, pos, order);
hist.push_back(std::make_tuple(false, pos, order));
it = buds.erase(it);
}
check_invariants();
if (inject_failure && !(rng() & 0x3f))
ADD_FAILURE() << "injecting test failure";
if (HasFailure())
goto show_hist;
}
return;
show_hist:
std::stringstream hist_msg;
hist_msg << "history of operations:";
for(auto it = hist.begin(); it != hist.end(); ++it) {
bool is_get;
int pos, order;
std::tie(is_get, pos, order) = *it;
hist_msg << std::endl;
if (is_get) {
hist_msg << " get(" << order << ") -> " << pos << ";";
} else {
hist_msg << " put(" << pos << ", " << order << ");";
}
}
GTEST_FAIL() << hist_msg.str();
}
|
58cdb3f02b622a9e41381d2adfbfd181e572333c
|
993592f426a5257437cb7adacc71332be211ac13
|
/Algorithm/Baekjoon/lv1/01924_2007년/01924_main.cpp
|
2a30847f42eee51b55ead156d68ac04bb85c3841
|
[] |
no_license
|
Robi02/HomeStudy
|
c88c6b4a94e8a9d9d2c34651539e3a12b4c6e89c
|
ac23d8d55731d8ded12c4af727e01d4570657d90
|
refs/heads/master
| 2023-07-21T01:08:44.414637
| 2022-05-12T09:54:09
| 2022-05-12T09:54:09
| 160,051,975
| 0
| 0
| null | 2023-07-07T21:51:08
| 2018-12-02T13:47:38
|
Java
|
UTF-8
|
C++
| false
| false
| 1,132
|
cpp
|
01924_main.cpp
|
/**
* 오늘은 2007년 1월 1일 월요일이다. 그렇다면 2007년 x월 y일은 무슨 요일일까? 이를 알아내는 프로그램을 작성하시오.
*
* > IN : 첫째 줄에 빈 칸을 사이에 두고 x(1≤x≤12)와 y(1≤y≤31)이 주어진다. 참고로 2007년에는 1, 3, 5, 7, 8, 10, 12월은 31일까지, 4, 6, 9, 11월은 30일까지, 2월은 28일까지 있다.
* > OUT : 첫째 줄에 x월 y일이 무슨 요일인지에 따라 SUN, MON, TUE, WED, THU, FRI, SAT중 하나를 출력한다.
*
**/
#include <iostream>
int main(int argc, char **argv)
{
const std::string dayStr[7] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
const int dateOfMonths[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int month = 0, date = 0;
std::cin >> month >> date;
int monthDelta = month - 1;
int dateDelta = date - 1;
int totalDays = 0;
for (int i = 0; i < monthDelta; ++i)
{
totalDays += dateOfMonths[i];
}
totalDays += dateDelta;
// std::cout << totalDays << std::endl;
std::cout << dayStr[(totalDays + 1) % 7];
return 0;
}
|
75f3223b5691a6e7d8acbe94a48b7fe8339573f3
|
22c66068bd9341b86ac121bbfa494afec2750625
|
/code/cpp/pair_test.cc
|
cce8977afd560d71ed407f215933402cc1a6da03
|
[] |
no_license
|
linghutf/topcoder
|
54f5124563008ae23c0ac6227c8e44579ee371ba
|
07da54aecaac0484675a91775140eb3c40ea5aa6
|
refs/heads/master
| 2020-04-07T06:49:33.114570
| 2017-05-28T08:21:10
| 2017-05-28T08:21:10
| 52,865,558
| 5
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 614
|
cc
|
pair_test.cc
|
/**
* 测试pair和hashmap可不可以使用char *作为key,value
*
* 结论: pair map 可以
* unordered_map 不可以,需要自己实现hash函数
*/
#include <iostream>
#include <utility>
#include <unordered_map>
#include <map>
using namespace std;
template<>
struct std::hash<std::pair<char*,char*>>{
};
int main(int argc, char *argv[])
{
std::pair<char *,char*> p;
//p.first = "haha";
//p.second= "hallo";
//std::map<std::pair<char*,char*>,int> t;
//std::unordered_map<std::pair<int,int>,int> test;
//std::unordered_map<std::pair<char*,char*>,int> test;
return 0;
}
|
1a805ee6a9bd7803c11a97715b0bd700fa46f3c9
|
604b98184de326e87b6bc290763b4bcede48eea6
|
/cpp/mergeIntervals/mergeIntervals.cpp
|
5202f22f583f792ac764e94f320ae72549b2666b
|
[] |
no_license
|
xienan6/leetcode
|
b980fb736e8dac34e5c137afeeb35dddd10eed1e
|
da16b439f0f3b7c146c42191c66cda1bec0b3e94
|
refs/heads/master
| 2020-04-09T12:38:31.567787
| 2020-01-14T05:44:34
| 2020-01-14T05:44:34
| 160,358,300
| 5
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,247
|
cpp
|
mergeIntervals.cpp
|
// Source : https://leetcode.com/problems/merge-intervals
// Author : Nan
// Date : 2018-12-23
// 169 / 169 test cases passed.
// Runtime: 8 ms
/*
* Sort the array and greedy.
*
* Time complexity O(nlogn), Space complexity O(n)
*/
/**
* Definition for an interval.
* struct Interval {
* int start;
* int end;
* Interval() : start(0), end(0) {}
* Interval(int s, int e) : start(s), end(e) {}
* };
*/
class Solution {
public:
static int cmp (Interval i1, Interval i2) {
return i1.start < i2.start;
}
vector<Interval> merge(vector<Interval>& intervals) {
sort(intervals.begin(), intervals.end(), cmp);
vector<Interval> result;
if (intervals.empty()) {
return result;
}
result.push_back(Interval(intervals[0].start, intervals[0].end));
for (int i = 1; i < intervals.size(); i++) {
if (intervals[i].start > result[result.size() - 1].end) {
result.push_back(Interval(intervals[i].start, intervals[i].end));
}
else if (intervals[i].end > result[result.size() - 1].end){
result[result.size() - 1].end = intervals[i].end;
}
}
return result;
}
};
|
e57aa357bd51f1f3f9d0cc8f81c72dacb8db86a9
|
7d52b5f692fb8cae5eb38442bc417fcabbc22a82
|
/modules/sync/src/transaction.cpp
|
2d0dec8c032bdd3857730c1236a0fdd5b7748d7e
|
[] |
no_license
|
Plaristote/crails
|
0acaf96415e7c465e9d6413b50d20db40283f0cc
|
ea56c227932f752190e677d41341d0a3203603fa
|
refs/heads/master
| 2022-11-14T18:13:33.091360
| 2022-10-24T17:23:58
| 2022-10-24T17:23:58
| 8,987,507
| 41
| 8
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 852
|
cpp
|
transaction.cpp
|
#include "../crails/sync/transaction.hpp"
#include "../crails/sync/client.hpp"
extern thread_local Faye::Client faye;
using namespace Sync;
using namespace std;
namespace Sync
{
bool enabled = true;
function<void (DataTree&)> Transaction::on_commit;
}
bool Transaction::is_enabled()
{
return Sync::enabled;
}
void Transaction::commit()
{
if (updates.size() + removals.size() > 0)
{
DataTree message;
vector<string> removal_uids;
for (auto update : updates)
update->render(message["updates"]);
for (auto removal : removals)
removal_uids.push_back(removal->uid());
message["removals"].from_vector<string>(removal_uids);
if (on_commit)
on_commit(message);
faye.publish("/sync", message.as_data());
rollback();
}
}
void Transaction::rollback()
{
updates.clear();
removals.clear();
}
|
57e8a54c9a42198c3c78b4e3ae0f254ae7a21899
|
67b83e5d2b897754027414590548074c9dfba661
|
/20190918_4_4div_test1.cpp
|
f7897aa541baac3a6a2f70ad3c1889502fe6e5c6
|
[] |
no_license
|
outum1500/OpenCV
|
1680974ea6eba88d1f120764dcd4921f81266f84
|
372bf189909e29dc79cee00e0b9e3787b7726b15
|
refs/heads/master
| 2020-09-16T16:25:11.198910
| 2019-11-25T00:31:58
| 2019-11-25T00:31:58
| 223,828,684
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 1,532
|
cpp
|
20190918_4_4div_test1.cpp
|
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main() {
VideoCapture cap(0);
if (!cap.isOpened()) {
cerr << "camera open failed" << endl;
return 0;
}
Mat frame;
cap >> frame; // 초기 프레임 크기 설정!!
int fourcc = VideoWriter::fourcc('D', 'I', 'V', 'X');
double fps = cap.get(CAP_PROP_FPS);
VideoWriter outputVideo1("output1.avi", fourcc, fps, Size(frame.cols / 2, frame.rows / 2));
VideoWriter outputVideo2("output2.avi", fourcc, fps, Size(frame.cols / 2, frame.rows / 2));
VideoWriter outputVideo3("output3.avi", fourcc, fps, Size(frame.cols / 2, frame.rows / 2));
VideoWriter outputVideo4("output4.avi", fourcc, fps, Size(frame.cols / 2, frame.rows / 2));
while (true) {
cap >> frame;
Mat m1 = frame(Range(0, frame.rows / 2), Range(0, frame.cols / 2)); // 좌측 상단
Mat m2 = frame(Range(frame.rows / 2, frame.rows), Range(0, frame.cols / 2)); // 좌측 하단
Mat m3 = frame(Range(0, frame.rows / 2), Range(frame.cols / 2, frame.cols)); // 우측 상단
Mat m4 = frame(Range(frame.rows / 2, frame.rows), Range(frame.cols / 2, frame.cols)); // 우측 하단
if (frame.empty()) {
break;
}
outputVideo1 << m1; // 저장
outputVideo2 << m2;
outputVideo3 << m3;
outputVideo4 << m4;
imshow("frame", frame); // 컴파일해서 바로 보기
imshow("roi", m1);
imshow("roi2", m2);
imshow("roi3", m3);
imshow("roi4", m4);
if (waitKey(10) == 27) { //ESC key
break;
}
}
destroyAllWindows();
return 0;
}
|
4e64e5172b9de7ccba3ef91b47b6e208fbfc0009
|
254428fdb3a8609d2fa590cbd57ced0cf3f604c2
|
/nachos/code/userprog/usersemaphore.h
|
34d62161294a35845b9c8a4c5ca96e270ab0a234
|
[
"MIT-Modern-Variant"
] |
permissive
|
AntoninCastel/nachOS
|
951f1ac7d05b0a0ec1f9947d279fc388b9f0a2a9
|
87c288d060d496d54f08e7b3bf39512ff48fc74c
|
refs/heads/master
| 2020-04-22T13:05:13.374243
| 2019-02-13T21:10:02
| 2019-02-13T21:10:02
| 170,396,555
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 287
|
h
|
usersemaphore.h
|
#ifndef __USERSEMAPHORE_H__
#define __USERSEMAPHORE_H__
#include "synch.h"
#include "system.h"
class Semaphore;
extern int do_Sem_Init(int n);
extern int do_Sem_P(int sem);
extern int do_Sem_V(int sem);
extern int do_Sem_GetValue(int sem);
extern int do_Sem_Destroy(int sem);
#endif
|
4970fa76a1fdaa78550053d84f7c59e0293571a6
|
1dd7e9814bf96b19f812d1d8f123b156aed399dd
|
/Triangles/Triangles.h
|
cc43deb70e949f0ccc3b10bc08be8dc1bec5ee03
|
[] |
no_license
|
AverkinaNastya/LR20
|
d09656972230ee605fa18326e354386e8585985d
|
1e4547c470d4eec4ba1448bfd463ea1defcfd727
|
refs/heads/master
| 2023-08-29T00:58:44.935896
| 2021-10-15T07:18:24
| 2021-10-15T07:18:24
| 417,403,954
| 0
| 0
| null | null | null | null |
WINDOWS-1251
|
C++
| false
| false
| 756
|
h
|
Triangles.h
|
#ifdef TRIANGLES_EXPORTS
#define TRIANGLES_API __declspec(dllexport)
#else
#define TRIANGLES_API __declspec(dllimport)
#endif
namespace TrianglesFuncs
{
// This class is exported from the MathFuncsDll.dll
class MyTrianglesFuncs
{
public:
// Вычисление периметра треугольника A - сторона, b и c - прилежащие углы
// ошибка, если b + c > 180 или b + c <= 0
static TRIANGLES_API double Perimeter(double A, double b, double c);
// Вычисление площади треугольника A - сторона, b и c - прилежащие углы
// ошибка, если b + c > 180 или b + c <= 0
static TRIANGLES_API double Area(double A, double b, double c);
};
}
|
2f4bc7b540f8b978b3796f972b39f3369ba87195
|
ea2d8f87328a70a52c92ebe3d083f76dcdba433c
|
/iitem.cpp
|
4e1748f897927667166d4e9aa9646e578d6687ed
|
[] |
no_license
|
salazc2/Video-Store-Management-System
|
f256188e19055f4acc32e767f1869ed70f30f7a8
|
222536d77a5d9d89d6a35441b13b37bf5dd03592
|
refs/heads/master
| 2021-01-24T02:52:46.235514
| 2018-02-25T16:03:01
| 2018-02-25T16:03:01
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,012
|
cpp
|
iitem.cpp
|
#include "iitem.h"
// --------------------------------------------------------------------------
// destructor
// --------------------------------------------------------------------------
IItem::~IItem()
{
}
// --------------------------------------------------------------------------
// change stock of item for borrow/return and duplicate DVD's (classics)
// --------------------------------------------------------------------------
void IItem::changeStock(int alterNumber)
{
m_stock += alterNumber;
}
// --------------------------------------------------------------------------
// mutator for m_stock
// --------------------------------------------------------------------------
void IItem::setStock(int stock)
{
int empty = 0;
if (stock >= empty)
{
m_stock = stock;
}
}
// --------------------------------------------------------------------------
// accessor for m_stock
// --------------------------------------------------------------------------
int IItem::getStock()
{
return m_stock;
}
|
03ee2034fc799e00eb92a4ea8e7a2af5444ed66d
|
e8378466a24fb0fe0a1e9bf1af7f41b77d2c20b4
|
/hoomd/LoadBalancerGPU.cc
|
1411f7962f262feaf0a791a495745a04fd0b2d81
|
[
"BSD-3-Clause"
] |
permissive
|
glotzerlab/hoomd-blue
|
eeabed0fee10a76b50d99b94ae0e93d3dc1d8037
|
abdd76bc854358426e4cf055badd27f80df6ec85
|
refs/heads/trunk-patch
| 2023-09-02T21:32:24.986845
| 2023-08-22T19:02:21
| 2023-08-22T19:02:21
| 147,663,007
| 287
| 131
|
BSD-3-Clause
| 2023-09-08T11:59:16
| 2018-09-06T11:23:27
|
C++
|
UTF-8
|
C++
| false
| false
| 4,875
|
cc
|
LoadBalancerGPU.cc
|
// Copyright (c) 2009-2023 The Regents of the University of Michigan.
// Part of HOOMD-blue, released under the BSD 3-Clause License.
/*! \file LoadBalancerGPU.cc
\brief Defines the LoadBalancerGPU class
*/
#ifdef ENABLE_HIP
#include "LoadBalancerGPU.h"
#include "LoadBalancerGPU.cuh"
#include <hip/hip_runtime.h>
#include "CachedAllocator.h"
using namespace std;
namespace hoomd
{
/*!
* \param sysdef System definition
* \param decomposition Domain decomposition
*/
LoadBalancerGPU::LoadBalancerGPU(std::shared_ptr<SystemDefinition> sysdef,
std::shared_ptr<Trigger> trigger)
: LoadBalancer(sysdef, trigger)
{
// allocate data connected to the maximum number of particles
m_pdata->getMaxParticleNumberChangeSignal()
.connect<LoadBalancerGPU, &LoadBalancerGPU::slotMaxNumChanged>(this);
GPUArray<unsigned int> off_ranks(m_pdata->getMaxN(), m_exec_conf);
m_off_ranks.swap(off_ranks);
m_tuner.reset(new Autotuner<1>({AutotunerBase::makeBlockSizeRange(m_exec_conf)},
this->m_exec_conf,
"load_balance"));
m_autotuners.push_back(m_tuner);
}
LoadBalancerGPU::~LoadBalancerGPU()
{
// disconnect from the signal
m_pdata->getMaxParticleNumberChangeSignal()
.disconnect<LoadBalancerGPU, &LoadBalancerGPU::slotMaxNumChanged>(this);
}
#ifdef ENABLE_MPI
void LoadBalancerGPU::countParticlesOffRank(std::map<unsigned int, unsigned int>& cnts)
{
// do nothing if rank doesn't own any particles
if (m_pdata->getN() == 0)
{
return;
}
// mark the current ranks of each particle (hijack the comm flags array)
{
ArrayHandle<unsigned int> d_comm_flag(m_pdata->getCommFlags(),
access_location::device,
access_mode::overwrite);
ArrayHandle<Scalar4> d_pos(m_pdata->getPositions(),
access_location::device,
access_mode::read);
ArrayHandle<unsigned int> d_cart_ranks(m_decomposition->getCartRanks(),
access_location::device,
access_mode::read);
m_tuner->begin();
kernel::gpu_load_balance_mark_rank(d_comm_flag.data,
d_pos.data,
d_cart_ranks.data,
m_decomposition->getGridPos(),
m_pdata->getBox(),
m_decomposition->getDomainIndexer(),
m_pdata->getN(),
m_tuner->getParam()[0]);
if (m_exec_conf->isCUDAErrorCheckingEnabled())
CHECK_CUDA_ERROR();
m_tuner->end();
}
// select the particles that should be sent to other ranks
vector<unsigned int> off_rank;
{
ArrayHandle<unsigned int> d_comm_flag(m_pdata->getCommFlags(),
access_location::device,
access_mode::read);
ArrayHandle<unsigned int> d_off_ranks(m_off_ranks,
access_location::device,
access_mode::overwrite);
// size the temporary storage
const unsigned int n_off_rank
= kernel::gpu_load_balance_select_off_rank(d_off_ranks.data,
d_comm_flag.data,
m_pdata->getN(),
m_exec_conf->getRank());
// copy just the subset of particles that are off rank on the device into host memory
// this can save substantially on the memcpy if there are many particles on a rank
off_rank.resize(n_off_rank);
hipMemcpy(&off_rank[0],
d_off_ranks.data,
sizeof(unsigned int) * n_off_rank,
hipMemcpyDeviceToHost);
}
// perform the counting on the host
for (unsigned int cur_p = 0; cur_p < off_rank.size(); ++cur_p)
{
cnts[off_rank[cur_p]]++;
}
}
#endif // ENABLE_MPI
namespace detail
{
void export_LoadBalancerGPU(pybind11::module& m)
{
pybind11::class_<LoadBalancerGPU, LoadBalancer, std::shared_ptr<LoadBalancerGPU>>(
m,
"LoadBalancerGPU")
.def(pybind11::init<std::shared_ptr<SystemDefinition>, std::shared_ptr<Trigger>>());
}
} // end namespace detail
} // end namespace hoomd
#endif // ENABLE_HIP
|
fa7fc9c1c808f0a9ace7b36040fa7390972e9bf5
|
aa156e0747cdf17fb6698bd55e0e98aa297dcdfd
|
/NetServer/echo.cpp
|
f8cc52d1c5063ad5a06c1d8735e293f210ab698e
|
[] |
no_license
|
m5623skhj/BackupFolder2
|
1b6188c3d4d7139b3c51e6ea793c4e8330456b2c
|
be7c89dd02fce26c1b565f57666179ac89b94e8a
|
refs/heads/master
| 2021-02-17T10:38:31.857937
| 2020-03-09T10:14:11
| 2020-03-09T10:14:11
| 245,090,345
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 2,777
|
cpp
|
echo.cpp
|
#include "PreComfile.h"
#include "Echo.h"
#include "Log.h"
#include "Profiler.h"
#include "NetServerSerializeBuffer.h"
CEcho::CEcho(const WCHAR *IP, UINT PORT, BYTE NumOfWorkerThread, bool IsNagle, UINT MaxClient)
{
_LOG(LOG_LEVEL::LOG_DEBUG, L"ERR", L"Start\n");
SetLogLevel(LOG_LEVEL::LOG_DEBUG);
Start(IP, PORT, NumOfWorkerThread, IsNagle, MaxClient);
}
CEcho::~CEcho()
{
_LOG(LOG_LEVEL::LOG_DEBUG, L"ERR", L"End\n%d");
Stop();
WritingProfile();
}
void CEcho::OnClientJoin(UINT64 OutClientID)
{
//__int64 Payload = 0x7fffffffffffffff;
//// 직렬화 버퍼를 동적 할당해서 해당 포인터를
//// SendPacket 에 넣어 놓으면 Send 가 완료 되었을 시
//// 삭제됨
////m_UserSessionMap.insert({OutClientID, 0});
//Begin("Alloc");
//CNetServerSerializationBuf *SendBuf = CNetServerSerializationBuf::Alloc();
//End("Alloc");
////InterlockedIncrement(&g_ULLConuntOfNew);
//WORD StackIndex = (WORD)(OutClientID >> SESSION_INDEX_SHIFT);
//*SendBuf << Payload;
//SendBuf->AddRefCount(SendBuf);
//SendPacket(OutClientID, SendBuf);
//CNetServerSerializationBuf::Free(SendBuf);
}
void CEcho::OnClientLeave(UINT64 LeaveClientID)
{
//if (m_UserSessionMap.erase(LeaveClientID) != 1)
//{
// _LOG(LOG_LEVEL::LOG_DEBUG, L"ERR ", L"%d\n%d", 0, 1001);
//}
}
bool CEcho::OnConnectionRequest()
{
return true;
}
void CEcho::OnRecv(UINT64 ReceivedSessionID, CNetServerSerializationBuf *ServerReceivedBuffer)
{
//__int64 echo = 0;
//*ServerReceivedBuffer >> echo;
//CNetServerSerializationBuf SendBuf;
//SendBuf << echo;
//SendPacket(ReceivedSessionID, &SendBuf);
char echo1 = 0;
char echo2 = 0;
char echo3 = 0;
char echo4 = 0;
*ServerReceivedBuffer >> echo1 >> echo2 >> echo3 >> echo4;
//if (m_UserSessionMap.find(ReceivedSessionID) == m_UserSessionMap.end())
//{
// _LOG(LOG_LEVEL::LOG_DEBUG, L"ERR ", L"%d\n%d", 0, 1002);
//}
// 직렬화 버퍼를 동적 할당해서 해당 포인터를
// SendPacket 에 넣어 놓으면 Send 가 완료 되었을 시
// 삭제됨
Begin("Alloc");
CNetServerSerializationBuf *SendBuf = CNetServerSerializationBuf::Alloc();
End("Alloc");
WORD StackIndex = (WORD)(ReceivedSessionID >> SESSION_INDEX_SHIFT);
//InterlockedIncrement(&g_ULLConuntOfNew);
*SendBuf << echo1 << echo2 << echo3 << echo4;
SendBuf->AddRefCount(SendBuf);
SendPacket(ReceivedSessionID, SendBuf);
CNetServerSerializationBuf::Free(SendBuf);
}
void CEcho::OnSend()
{
}
void CEcho::OnWorkerThreadBegin()
{
}
void CEcho::OnWorkerThreadEnd()
{
}
void CEcho::OnError(st_Error *OutError)
{
if (OutError->GetLastErr != 10054)
{
_LOG(LOG_LEVEL::LOG_DEBUG, L"ERR ", L"%d\n%d", OutError->GetLastErr, OutError->NetServerErr);
printf_s("==============================================================\n");
}
}
|
f7fa313f4adeb61b059908507ce9f86e14046951
|
4e9e4b2aa28113e307c87cd6c777d7498fd85b0a
|
/src/consensus/pbft/libbyz/Request.cpp
|
78363caeaffe7a08b008aa4990837e554f51ef56
|
[
"MIT",
"LicenseRef-scancode-generic-cla",
"Apache-2.0"
] |
permissive
|
kuychaco/CCF
|
b0608e4f241a1c0dfa1c3f72021b4b4d786e0e02
|
e11acde3be6a7d2213fe5b406b959bb5bb64361d
|
refs/heads/master
| 2020-12-23T05:14:45.012959
| 2020-01-29T17:49:12
| 2020-01-29T17:49:12
| 237,045,643
| 1
| 0
|
Apache-2.0
| 2020-01-29T17:45:36
| 2020-01-29T17:45:35
| null |
UTF-8
|
C++
| false
| false
| 4,558
|
cpp
|
Request.cpp
|
// Copyright (c) Microsoft Corporation.
// Copyright (c) 1999 Miguel Castro, Barbara Liskov.
// Copyright (c) 2000, 2001 Miguel Castro, Rodrigo Rodrigues, Barbara Liskov.
// Licensed under the MIT license.
#include "Request.h"
#include "Message_tags.h"
#include "Node.h"
#include "Principal.h"
#include "Statistics.h"
#include "pbft_assert.h"
#include <stdlib.h>
#include <strings.h>
#define SIGN_ALL_RW_REQUESTS
// extra & 1 = read only
// extra & 2 = signed
Request::Request(Request_id r, short rr) :
Message(Request_tag, Max_message_size)
{
rep().cid = pbft::GlobalState::get_node().id();
rep().rid = r;
rep().replier = rr;
rep().command_size = 0;
set_size(sizeof(Request_rep));
}
Request* Request::clone() const
{
Request* ret = (Request*)new Message(max_size);
memcpy(ret->msg, msg, msg->size);
return ret;
}
char* Request::store_command(int& max_len)
{
auto max_auth_size = std::max<size_t>(
pbft_max_signature_size, pbft::GlobalState::get_node().auth_size());
max_len = msize() - sizeof(Request_rep) - max_auth_size;
return contents() + sizeof(Request_rep);
}
inline void Request::comp_digest(Digest& d)
{
INCR_OP(num_digests);
START_CC(digest_cycles);
d = Digest(
(char*)&(rep().cid), sizeof(int) + sizeof(Request_id) + rep().command_size);
STOP_CC(digest_cycles);
}
void Request::authenticate(int act_len, bool read_only)
{
PBFT_ASSERT(
(unsigned)act_len <=
msize() - sizeof(Request_rep) - pbft::GlobalState::get_node().auth_size(),
"Invalid request size");
rep().extra = ((read_only) ? 1 : 0);
rep().command_size = act_len;
if (rep().replier == -1)
{
rep().replier = rand() % pbft::GlobalState::get_node().num_of_replicas();
}
comp_digest(rep().od);
int old_size = sizeof(Request_rep) + act_len;
#ifndef SIGN_ALL_RW_REQUESTS
set_size(old_size + pbft::GlobalState::get_node().auth_size());
auth_type = Auth_type::in;
auth_len = sizeof(Request_rep);
auth_dst_offset = old_size;
auth_src_offset = 0;
#else
if (!read_only)
{
rep().extra |= 2;
auth_type = Auth_type::unknown;
set_size(old_size + pbft_max_signature_size);
}
else
{
set_size(old_size + pbft::GlobalState::get_node().auth_size());
auth_type = Auth_type::in;
auth_len = sizeof(Request_rep);
auth_dst_offset = old_size;
auth_src_offset = 0;
}
#endif
}
void Request::re_authenticate(bool change, Principal* p)
{
if (change)
{
rep().extra &= ~1;
}
int new_rep = rand() % pbft::GlobalState::get_node().num_of_replicas();
rep().replier = (new_rep != rep().replier) ?
new_rep :
(new_rep + 1) % pbft::GlobalState::get_node().num_of_replicas();
int old_size = sizeof(Request_rep) + rep().command_size;
if ((rep().extra & 2) == 0)
{
auth_type = Auth_type::in;
auth_len = sizeof(Request_rep);
auth_dst_offset = old_size;
auth_src_offset = 0;
}
else
{
auth_type = Auth_type::unknown;
}
}
void Request::sign(int act_len)
{
PBFT_ASSERT(
(unsigned)act_len <=
msize() - sizeof(Request_rep) - pbft_max_signature_size,
"Invalid request size");
rep().extra |= 2;
rep().command_size = act_len;
comp_digest(rep().od);
int old_size = sizeof(Request_rep) + act_len;
set_size(old_size + pbft_max_signature_size);
}
Request::Request(Request_rep* contents) : Message(contents) {}
bool Request::pre_verify()
{
const int nid = pbft::GlobalState::get_node().id();
const int cid = client_id();
const int old_size = sizeof(Request_rep) + rep().command_size;
std::shared_ptr<Principal> p =
pbft::GlobalState::get_node().get_principal(cid);
Digest d;
comp_digest(d);
if (p != 0 && d == rep().od)
{
if ((rep().extra & 2) == 0)
{
// Message has an authenticator.
if (
cid != nid &&
size() - old_size >= pbft::GlobalState::get_node().auth_size(cid))
{
return true;
}
}
else
{
// Message is signed.
if (size() - old_size >= pbft_max_signature_size)
{
return true;
}
}
}
return false;
}
bool Request::convert(Message* m1, Request*& m2)
{
if (!m1->has_tag(Request_tag, sizeof(Request_rep)))
{
LOG_INFO << "convert request false" << std::endl;
return false;
}
m2 = (Request*)m1;
m2->trim();
return true;
}
bool Request::convert(char* m1, unsigned max_len, Request& m2)
{
if (!Message::convert(m1, max_len, Request_tag, sizeof(Request_rep), m2))
{
LOG_INFO << "convert request false" << std::endl;
return false;
}
return true;
}
|
f199ee0b48c2f75860beb27a70581f975d002e87
|
d394ea72dc1773893447cca00cc4e881d969c29d
|
/Semester-2/Deque/Deque/Deque.cpp
|
67ea68e6b8947476f4ff1967df866f3b71950d22
|
[] |
no_license
|
ACC-Stas/OAIP
|
e00cf74a001a7efa0c5e6fd2911ee9eeba3c3dd2
|
7ccb806a7bd9e149642169d84eccb3ad5323dc94
|
refs/heads/main
| 2023-04-30T18:09:50.293939
| 2021-05-11T18:31:54
| 2021-05-11T18:31:54
| 352,179,624
| 50
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,929
|
cpp
|
Deque.cpp
|
#include <iostream>
#include <vector>
#include <initializer_list>
#include <iterator>
template <class T>
class Deque {
private:
int leftIndex, rightIndex; //show first empty index
static const int blockSize = 32;
std::vector<T*> posHeaders;
std::vector<T*> negHeaders;
public:
Deque(int length = 0, T def = T()) {
leftIndex = -length - 1;
rightIndex = length;
int numberOfBlocks = length / blockSize + 1;
for (int i = 0; i < numberOfBlocks; i++) {
posHeaders.push_back(new T[blockSize]);
negHeaders.push_back(new T[blockSize]);
}
int counter = 0;
while (counter < length) {
posHeaders[counter / blockSize][counter % blockSize] = def;
negHeaders[counter / blockSize][counter % blockSize] = def;
counter++;
}
}
Deque(Deque& d) {
this->leftIndex = d.leftIndex;
this->rightIndex = d.rightIndex;
int numberOfRightBlocks = 0;
if (d.rightIndex > 0) {
numberOfRightBlocks = rightIndex / blockSize + 1;
}
for (int i = 1; i <= numberOfRightBlocks; i++) {
posHeaders.push_back(new T[blockSize]);
}
int numberOfLeftBlocks = 0;
if (d.leftIndex < -1) {
numberOfLeftBlocks = (-1 * leftIndex - 1) / blockSize + 1;
}
for (int i = 1; i <= numberOfRightBlocks; i++) {
negHeaders.push_back(new T[blockSize]);
}
int index;
T value;
for (int i = d.leftIndex + 1; i < d.rightIndex; i++) {
if (i >= 0) {
value = d[i];
posHeaders[i / blockSize][i% blockSize] = value;
}
else {
value = d[i];
index = -1 * i - 1;
negHeaders[index / blockSize][index % blockSize] = value;
}
}
}
Deque(const std::initializer_list<T>& list) {
leftIndex = -1;
rightIndex = 0;
for (auto it : list) {
push_back(it);
}
}
class Iterator : std::iterator<std::random_access_iterator_tag,T> {
private:
Deque* d;
int index;
public:
Iterator(Deque& d, int index) {
this->d = &d;
this->index = index;
}
Iterator(const Iterator& it) {
this->d = it.d;
this->index = it.index;
}
Iterator& operator=(const Iterator& it) {
this->d = it.d;
this->index = it.index;
return *this;
}
Iterator& operator++() {
index++;
return *this;
}
Iterator& operator--() {
index--;
return *this;
}
Iterator operator++(int) {
Iterator temp = *this;
this->index++;
return temp;
}
Iterator operator--(int) {
Iterator temp = *this;
this->index--;
return temp;
}
Iterator operator+(int value) {
Iterator temp = *this;
temp.index += value;
return temp;
}
Iterator operator+=(int value) {
this->index += value;
return *this;
}
Iterator operator-(int value) {
Iterator temp = *this;
temp.index -= value;
return temp;
}
Iterator operator-=(int value) {
this->index -= value;
return *this;
}
bool operator==(const Iterator& it) {
bool isEqualAddresses = false;
if (d == it.d && index == it.index) {
isEqualAddresses = true;
}
return isEqualAddresses;
}
bool operator!=(const Iterator& it) {
bool isEqualAddresses = false;
if (d == it.d && index == it.index) {
isEqualAddresses = true;
}
return !isEqualAddresses;
}
bool operator<(const Iterator& it) {
T valueThis = d->operator[](index);
T valueIt = it.d->operator[](it.index);
return valueThis < valueIt;
}
bool operator<=(const Iterator& it) {
T valueThis = d->operator[](index);
T valueIt = it.d->operator[](it.index);
return valueThis <= valueIt;
}
bool operator>(const Iterator& it) {
T valueThis = d->operator[](index);
T valueIt = it.d->operator[](it.index);
return valueThis > valueIt;
}
bool operator>=(const Iterator& it) {
T valueThis = d->operator[](index);
T valueIt = it.d->operator[](it.index);
return valueThis >= valueIt;
}
T operator*() {
return d->operator[](index);
}
T operator[](int value) {
return d->operator[](index + value);
}
T* operator->() {
T* ptr = &d->operator[](index);
return ptr;
}
};
Deque& operator=(Deque& d) {
this->leftIndex = d.leftIndex;
this->rightIndex = d.rightIndex;
int numberOfRightBlocks = 0;
if (d.rightIndex > 0) {
numberOfRightBlocks = rightIndex / blockSize + 1;
}
for (int i = 1; i <= numberOfRightBlocks; i++) {
posHeaders.push_back(new T[blockSize]);
}
int numberOfLeftBlocks = 0;
if (d.leftIndex < -1) {
numberOfLeftBlocks = (-1 * leftIndex - 1) / blockSize + 1;
}
for (int i = 1; i <= numberOfRightBlocks; i++) {
negHeaders.push_back(new T[blockSize]);
}
int index;
T value;
for (int i = d.leftIndex + 1; i < d.rightIndex; i++) {
if (i >= 0) {
value = d[i];
posHeaders[i / blockSize][i % blockSize] = value;
}
else {
value = d[i];
index = -1 * i - 1;
negHeaders[index / blockSize][index % blockSize] = value;
}
}
return *this;
}
T& operator[](int index) {
if (index <= leftIndex || index >= rightIndex) {
throw std::exception("No such index\n");
}
T returnValue;
if (index >= 0) {
returnValue = posHeaders[index / blockSize][index % blockSize];
}
else {
index *= -1;
index -= 1;
returnValue = negHeaders[index / blockSize][index % blockSize];
}
return returnValue;
}
Iterator begin() {
Iterator it(*this, leftIndex + 1);
return it;
}
Iterator end() {
Iterator it(*this, rightIndex);
return it;
}
void push_front(T value) { //left
if (leftIndex >= 0) {
if (leftIndex % blockSize == (blockSize -1)) { //need new block of memory
posHeaders[leftIndex / blockSize] = new T[blockSize];
}
posHeaders[leftIndex / blockSize][leftIndex % blockSize] = value;
}
else {
int negIndex = -1 * leftIndex - 1;
if (negIndex% blockSize == 0) {
negHeaders.push_back(new T[blockSize]);
}
negHeaders[negIndex / blockSize][negIndex % blockSize] = value;
}
leftIndex--;
}
void push_back(T value) { //right
if (rightIndex >= 0) {
if (rightIndex % blockSize == 0) {
posHeaders.push_back(new T[blockSize]);
}
posHeaders[rightIndex / blockSize][rightIndex % blockSize] = value;
}
else {
int negIndex = -1 * rightIndex - 1;
if (negIndex % blockSize == (blockSize - 1)) {
negHeaders[negIndex / blockSize] = new T[blockSize];
}
negHeaders[negIndex / blockSize][negIndex % blockSize] = value;
}
rightIndex++;
}
void pop_front() { //left
if (leftIndex == rightIndex - 1) {
throw std::exception("Already empty");
}
if (leftIndex >= 0) {
if (leftIndex % blockSize == (blockSize - 2)) { //don't need block of memory
delete[] posHeaders[leftIndex / blockSize];
}
}
else {
int negIndex = -1 * leftIndex - 1;
if (negIndex % blockSize == 1) {
delete[] negHeaders[negIndex / blockSize + 1];
negHeaders.pop_back();
}
}
leftIndex++;
}
void pop_back() { //right
if (leftIndex == rightIndex - 1) {
throw std::exception("Already empty");
}
if (rightIndex >= 0) {
if (rightIndex % blockSize == 1) {
delete[] posHeaders[rightIndex / blockSize];
}
}
else {
int negIndex = -1 * rightIndex - 1;
if (negIndex % blockSize == (blockSize - 2)) {
delete[] negHeaders[negIndex / blockSize];
negHeaders.pop_back();
}
}
rightIndex--;
}
int leftEmpty() { //can't write in it
return leftIndex;
}
int rightEmpty() {
return rightIndex;
}
bool empty() {
bool isEmpty = false;
if (leftIndex == rightIndex - 1) {
isEmpty = true;
}
return isEmpty;
}
int size() {
return rightIndex - 1 - leftIndex;
}
void clear() {
if (leftIndex < -1) {
int negIndex = -1 * leftIndex - 1;
int maxBlock = negIndex / blockSize;
for (int i = maxBlock; i > 0; i--) {
delete[] negHeaders[i];
negHeaders.pop_back();
}
}
if (rightIndex > 0) {
int maxBlock = rightIndex / blockSize;
for (int i = maxBlock; i >= 0; i--) {
delete[] posHeaders[i];
posHeaders.pop_back();
}
}
rightIndex = 0;
leftIndex = -1;
}
void resize(int length, T def = T()) {
int rightDifference = length;
if (rightIndex > 0) {
rightDifference = length - rightIndex;
}
if (rightDifference > 0) {
for (int i = 0; i < rightDifference; i++) {
push_back(def);
}
}
else {
for (int i = 0; i < -1 * rightDifference; i++) {
pop_back();
}
}
int leftDifference = length;
if (leftIndex < -1) {
leftDifference = length + leftIndex + 1;
}
if (leftDifference > 0) {
for (int i = 0; i < leftDifference; i++) {
push_front(def);
}
}
else {
for (int i = 0; i < -1*leftDifference; i++) {
pop_front();
}
}
leftIndex = -length - 1;
rightIndex = length;
}
~Deque() {
clear();
}
};
class A { //just test class
private:
int variable;
public:
void setVariable(int variable) {
this->variable = variable;
}
int getVariable() {
return variable;
}
};
int main() {
Deque<int> d(5, 1);
for (int i = d.leftEmpty() + 1; i < d.rightEmpty(); i++) {
std::cout << d[i] << " ";
}
std::cout << "\n LeftEmpty is " << d.leftEmpty() << "\n";
d.push_front(4);
std::cout << "LeftEmpty is " << d.leftEmpty() << "\n";
std::cout << d[d.leftEmpty() + 1] << "\n";
Deque<int> d1;
d1.push_front(4);
std::cout << "Is it empty? " << d1.empty() << '\n';
std::cout << "Size is: " << d1.size() << '\n';
std::cout << d1[-1] << "\n";
d1.pop_front();
std::cout << "Is it empty? " << d1.empty() << '\n';
std::cout << "Size is: " << d1.size() << '\n';
try {
d1.pop_front();
}
catch (std::exception& ex) {
std::cout << ex.what() << '\n';
}
for (int i = 1; i < 47; i++) {
d1.push_front(-i);
}
for (int i = d1.leftEmpty() + 1; i < d1.rightEmpty(); i++) {
std::cout << d1[i] << " ";
}
std::cout << '\n';
for (int i = 0; i < 43; i++) {
d1.pop_front();
}
for (int i = d1.leftEmpty() + 1; i < d1.rightEmpty(); i++) {
std::cout << d1[i] << " ";
}
std::cout << "\nWorking with push back\n";
for (int i = 0; i < 46; i++) {
d1.push_back(i);
}
for (int i = d1.leftEmpty() + 1; i < d1.rightEmpty(); i++) {
std::cout << d1[i] << " ";
}
std::cout << '\n';
for (int i = 0; i < 43; i++) {
d1.pop_front();
}
for (int i = d1.leftEmpty() + 1; i < d1.rightEmpty(); i++) {
std::cout << d1[i] << " ";
}
std::cout << '\n';
for (int i = -1; i > -45; i--) {
d1.push_front(i);
}
for (int i = d1.leftEmpty() + 1; i < d1.rightEmpty(); i++) {
std::cout << d1[i] << " ";
}
std::cout << "\nWorking with pop back\n";
for (int i = 0; i < 43; i++) {
d1.pop_back();
}
for (int i = d1.leftEmpty() + 1; i < d1.rightEmpty(); i++) {
std::cout << d1[i] << " ";
}
std::cout << '\n';
d1.clear();
d1.push_front(-1);
d1.push_back(1);
for (int i = d1.leftEmpty() + 1; i < d1.rightEmpty(); i++) {
std::cout << d1[i] << " ";
}
std::cout << "\nWorking with resize\n";
d1.resize(3, 4);
for (int i = d1.leftEmpty() + 1; i < d1.rightEmpty(); i++) {
std::cout << d1[i] << " ";
}
std::cout << '\n';
Deque<int> d2(d1);
std::cout << "It is d2\n";
for (int i = d2.leftEmpty() + 1; i < d2.rightEmpty(); i++) {
std::cout << d2[i] << " ";
}
std::cout << '\n';
Deque<int> d3 { 4,6,8,10,12,14,16 };
std::cout << "It is d3\n";
for (int i = d3.leftEmpty() + 1; i < d3.rightEmpty(); i++) {
std::cout << d3[i] << " ";
}
std::cout << '\n';
d1 = d3;
for (int i = d1.leftEmpty() + 1; i < d1.rightEmpty(); i++) {
std::cout << d1[i] << " ";
}
std::cout << "\nWorking with iterators\n";
Deque<int>::Iterator it3 = d3.begin();
std::cout << *it3 << '\n';
++it3;
std::cout << *it3 << '\n';
--it3;
std::cout << *it3 << '\n';
std::cout << *(it3++) << '\n';
std::cout << *it3 << '\n';
std::cout << *(it3--) << '\n';
std::cout << *it3 << '\n';
it3 = it3 + 2;
std::cout << *it3 << '\n';
it3 += 2;
std::cout << *it3 << '\n';
it3 = it3 - 2;
std::cout << *it3 << '\n';
it3 -= 2;
std::cout << *it3 << '\n';
Deque<int>::Iterator it31 = d3.begin();
std::cout << (it31 == it3) << '\n';
Deque<int>::Iterator it1 = d1.begin();
std::cout << *it1 << '\n';
std::cout << (it1 == it3) << '\n';
it1 += 2;
std::cout << "it1 - " << *it1 << '\n';
std::cout << "it3 - " << *it3 << '\n';
std::cout << "Is it1 < it3: " << (it1 < it3) << '\n';
std::cout << "Is it3 < it1: " << (it3 < it1) << '\n';
std::cout << "Is it1 > it3: " << (it1 > it3) << '\n';
std::cout << "Is it1 <= it3: " << (it1 <= it3) << '\n';
std::cout << "Is it1 >= it3: " << (it1 >= it3) << '\n';
it1 -= 2;
std::cout << "it1 - " << *it1 << '\n';
std::cout << "it3 - " << *it3 << '\n';
std::cout << "Is it1 <= it3: " << (it1 <= it3) << '\n';
std::cout << "Is it1 >= it3: " << (it1 >= it3) << '\n';
std::cout << it3[2] << '\n';
A object;
object.setVariable(5);
Deque<A> da;
da.push_back(object);
da.push_front(object);
Deque<A>::Iterator itA = da.begin();
std::cout << itA->getVariable();
std::cout << "\nTest iterator invalidation\n";
std::cout << "it3 - " << *it3 << '\n';
d3.resize(45, 7);
std::cout << "it3 - " << *it3 << '\n';
for (int i = 0; i < 30; i++) {
std::cout << it3[i] << " ";
}
std::cout << '\n';
}
|
0beb489ac74dee60961ddc1e63c84dd999c97a7f
|
393320d4dc9463ae7047390e4afe6f3e25fd70b9
|
/tek2/C++/cpp_arcade/src/interfaces/IPicture.hpp
|
4d3b7cc0f67f6cb75b85d31353abc366772c542f
|
[] |
no_license
|
Lime5005/epitech-1
|
d1c4f3739716173c8083ea4e6a04260d6dc92775
|
cb25df1fa5d540624b9e7fd58de6e458cd5cc250
|
refs/heads/master
| 2023-02-09T07:38:57.850357
| 2019-10-14T15:03:44
| 2019-10-14T15:03:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,071
|
hpp
|
IPicture.hpp
|
/*
** IPicture.hpp for cpp_arcade in /home/ventinc/epitech/cpp/cpp_arcade/interfaces/IPicture.hpp
**
** Made by Vincent DUSAUTOIR
** Login <vincent.dusautoir@epitech.eu>
**
** Started on Fri Mar 17 15:39:28 2017 Vincent DUSAUTOIR
** Last update Fri Mar 17 15:39:28 2017 Vincent DUSAUTOIR
*/
#ifndef CPP_ARCADE_IPICTURE_HPP
#define CPP_ARCADE_IPICTURE_HPP
#include <string>
#include "Structures.hpp"
namespace arcade
{
class IPicture
{
public:
virtual ~IPicture() {};
virtual bool load(const std::string &path) = 0;
virtual bool rotate(float angle) = 0;
virtual bool setScale(float scale_x, float scale_y) = 0;
virtual bool isLoaded() const = 0;
virtual float getRotate() const = 0;
virtual float getXScale() const = 0;
virtual float getYScale() const = 0;
virtual bool setInnerPos(const pos &positions, uint64_t width, uint64_t height) = 0;
virtual void setColor(const rgb &color) = 0;
virtual const rgb &getColor() const = 0;
virtual const pos &getSize() const = 0;
};
}
#endif //CPP_ARCADE_IPICTURE_HPP
|
c9546a7645bb7f1a8766ac525be471dfd91faac9
|
5a66a73c1328afa6c68b104376d1538a2e89130d
|
/Device/DeviceManager/DeviceManager.h
|
5bc74f8c0bc4baa8379ae9f426ea8787bf861903
|
[] |
no_license
|
QingChunm/USBtest
|
819689e0e3d38cd3e030e384f756bfe47b2ed9c2
|
f2ff9f0a1e1a50b2aced90f35c153ac3b97b1a95
|
refs/heads/master
| 2020-04-26T19:37:13.767325
| 2019-03-05T00:39:32
| 2019-03-05T00:39:32
| 173,780,981
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,763
|
h
|
DeviceManager.h
|
#pragma once
#include "USBDeviceMonitor.h"
#include <map>
#include <string>
#include <SetupAPI.h>
#include "Data/AX32XXDevice.h"
class DeviceManager
{
public:
static DeviceManager& GetInstance();
void Initialize();
void Uninitialize();
void AddSupportedHardwareId(const wchar_t* deviceModel, const wchar_t* hardwareId);
void RemoveSupportedHardwareId(const wchar_t* deviceModel);
void AddDevChangeNotifyFunc(std::function<void(int,const wchar_t*, const wchar_t*, const wchar_t*)> deviceChangeNotifyFunc);
void RemoveDevChangeNotifyFunc();
void ScanDevice();
AX32XXDevice* GetDevice(const wchar_t* devLocation);
private:
DeviceManager();
~DeviceManager();
AX32XXDevice* _AddDevice(const wchar_t* devSymbolicLink, SP_DEVINFO_DATA devInfoData);
void _RemoveDevice(const wchar_t* devSymbolicLink);
bool _IsSupportedDevice(SP_DEVINFO_DATA devInfoData);
bool _IsSupportedDevice(SP_DEVINFO_DATA devInfoData, HDEVINFO deviceInfoSet);
std::wstring _GetDeviceHardwareId(SP_DEVINFO_DATA devInfoData);
std::wstring _GetDeviceHardwareId(SP_DEVINFO_DATA devInfoData, HDEVINFO deviceInfoSet);
SP_DEVINFO_DATA _GetDeviceInfo(const wchar_t* devSymbolicLink);
SP_DEVINFO_DATA _GetDeviceInfo(const wchar_t* devSymbolicLink, HDEVINFO deviceInfoSet);
void _OnUsbEvent(DeviceEvent event, const wchar_t* devSymbolicLink);
HDEVINFO m_DeviceInfoSet;
USBDeviceMonitor m_usbDevMonitor;
std::map<std::wstring, AX32XXDevice*> m_Ax32xxDevMap;
std::function<void(int event,
const wchar_t* devLocation, const wchar_t* devModel, const wchar_t* uvcInterfaceName)> m_deviceChangeNotifyFunc;
static std::map<std::wstring, std::wstring> m_SupportedHardwareSpecificsMap;
};
|
de81a647682a694c42c01255e7639b600c62c966
|
55897f2ac51734b9f299ec0ea00a83f26ae94c3a
|
/src/CriAtomEx3dListener.h
|
55a429927081d87e098b2fb6542dca2adb3c42dc
|
[
"MIT"
] |
permissive
|
Boyquotes/ADX2LE-GodotPlugin
|
60f3825c9ba05c702245e473c6e4b5eda5f3713f
|
cb0d9a585e2c35c1d1708a0904899e1a47096b77
|
refs/heads/master
| 2023-05-25T19:41:35.855112
| 2020-09-27T11:01:53
| 2020-09-27T11:01:53
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 666
|
h
|
CriAtomEx3dListener.h
|
#pragma once
#include <Godot.hpp>
#include <cri_adx2le.h>
#include "CriAtomExAcb.h"
namespace godot {
class CriAtomEx3dListener : public Reference
{
GODOT_CLASS(CriAtomEx3dListener, Reference)
public:
static void _register_methods();
CriAtomEx3dListener();
~CriAtomEx3dListener();
void _init();
void create(Dictionary config);
void destroy();
void update();
void reset_parameters();
void set_position(Vector3 position);
void set_velocity(Vector3 velocity);
void set_orientation(Vector3 front, Vector3 top);
CriAtomEx3dListenerHn get_handle() const { return this->handle; }
private:
CriAtomEx3dListenerHn handle = nullptr;
};
}
|
c2f5f1b0fc1ebc244d009cda2793f6c5045b5398
|
13739586a566a82b47b88f06a9ba7da61d9f167e
|
/GeeksforGeeks/Largest square formed in a matrix.cpp
|
50576251b630f44b077e42770550b0d49ff2f2ef
|
[] |
no_license
|
sajalagrawal/BugFreeCodes
|
d712e5a46fa62319b66b00977a157e4c1758273f
|
c1930a68bdc50619daefea7f7088b506dd921e4c
|
refs/heads/master
| 2023-01-20T19:13:08.736719
| 2023-01-15T14:38:27
| 2023-01-15T14:38:27
| 56,171,988
| 5
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 967
|
cpp
|
Largest square formed in a matrix.cpp
|
//https://practice.geeksforgeeks.org/problems/largest-square-formed-in-a-matrix/0
//https://www.geeksforgeeks.org/maximum-size-sub-matrix-with-all-1s-in-a-binary-matrix/
//Author- Sajal Agrawal
//sajal.agrawal1997@gmail.com
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define pb push_back
int main() {
int t,n,m,i,j;
cin>>t;
while(t--){
cin>>n>>m;
int g[n][m];
int dp[n][m]={0},ans=1; //minimum answer is always 1
for(i=0;i<n;i++){
for(j=0;j<m;j++){
cin>>g[i][j];
dp[i][j]=g[i][j];
}
}
for(i=1;i<n;i++){
for(j=1;j<m;j++){
if(g[i][j]==1 and g[i-1][j-1]==1 and g[i-1][j]==1 and g[i][j-1]==1){
dp[i][j]=min(dp[i-1][j-1],min(dp[i][j-1],dp[i-1][j]))+1;
ans=max(ans,dp[i][j]);
}
}
}
cout<<ans<<endl;
}
return 0;
}
|
2b3f053fcc533118f688330710092d2271315fae
|
7c93cfc7b98995f580eed0f9e920ff2a9da8d4bc
|
/Playground/SimPhotonStudies.cxx
|
250f76560b21872ced3eff56824ef725accebfe8
|
[] |
no_license
|
davidc1/CaraTool
|
0d8f09b18af07b55bdf930e70a96349c6fa063dc
|
3e88c5b7f66d771a9160b296b275e23c9c5c681e
|
refs/heads/master
| 2021-01-19T01:38:50.199022
| 2017-12-14T18:13:40
| 2017-12-14T18:13:40
| 33,445,761
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,506
|
cxx
|
SimPhotonStudies.cxx
|
#ifndef LARLITE_SIMPHOTONSTUDIES_CXX
#define LARLITE_SIMPHOTONSTUDIES_CXX
#include "SimPhotonStudies.h"
#include "DataFormat/simphotons.h"
#include "DataFormat/simch.h"
#include "DataFormat/mctrack.h"
#include "DataFormat/mcshower.h"
namespace larlite {
bool SimPhotonStudies::initialize() {
if (_tree) delete _tree;
_tree = new TTree("_tree","tree");
_tree->Branch("_photons",&_photons,"photons/D");
_tree->Branch("_edep",&_edep,"edep/D");
_tree->Branch("_qdep",&_qdep,"qdep/D");
_tree->Branch("_nshr",&_nshr,"nshr/I");
_tree->Branch("_ntrk",&_ntrk,"ntrk/I");
_tree->Branch("_pdg",&_pdg,"pdg/I");
return true;
}
bool SimPhotonStudies::analyze(storage_manager* storage) {
auto ev_simph = storage->get_data<event_simphotons>("largeant");
auto ev_simch = storage->get_data<event_simch>("largeant");
auto ev_mcshower = storage->get_data<event_mcshower>("mcreco");
auto ev_mctrack = storage->get_data<event_mctrack> ("mcreco");
if ( (ev_mcshower->size() != _n_showers) && (ev_mctrack->size() != _n_tracks) ) return true;
if ( (ev_mcshower->size() == _n_showers) && (ev_mctrack->size() == _n_tracks) ) return true;
_nshr = ev_mcshower->size();
_ntrk = ev_mctrack->size();
if (_nshr == 1)
_pdg = 11;
if (_ntrk == 1)
_pdg = ev_mctrack->at(0).PdgCode();
/*
std::cout << "Det profile : " << trk.at(0).E() - trk.at(trk.size()-1).E() << std::endl;
std::cout << "last point @ [ "
<< trk.at(trk.size()-1).X() << ", "
<< trk.at(trk.size()-1).Y() << ", "
<< trk.at(trk.size()-1).Z() << " ]" << std::endl << std::endl;
*/
// std::cout << ev_simph->size() << std::endl;
_photons = 0.0;
for (size_t i=0; i < ev_simph->size(); i++) {
auto const& simph = ev_simph->at(i);
for (auto const& ph : simph)
_photons += ph.Energy;
}
_edep = _qdep = 0;
// grab all the simchannel info
for (size_t i=0; i < ev_simch->size(); i++) {
auto const& simch = ev_simch->at(i);
auto const& idemap = simch.TDCIDEMap();
for (auto const& idevec : idemap) {
for (auto const& ide : idevec.second) {
_edep += ide.energy;
_qdep += ide.numElectrons;
}// for all ides on this channel
}// for all channels in map
}// for all simchannels in event
_tree->Fill();
return true;
}
bool SimPhotonStudies::finalize() {
_tree->Write();
return true;
}
}
#endif
|
8254ea56508b5b6f537de545a53b0a2175265c56
|
3a495c2c5c2f821fe260a412f994566012df4769
|
/C++/2225.cpp
|
31f6cde7177900a77eb3dc623c558525dca7366a
|
[] |
no_license
|
seohyoj55/Baekjoon
|
796a0846e9c5af91d8147930fd285c3d17d3ff48
|
4b1b467e6497e0f16c431b43443dfc4d76bcb49d
|
refs/heads/master
| 2021-07-12T14:18:40.468767
| 2020-07-15T11:39:19
| 2020-07-15T11:39:19
| 174,791,625
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 428
|
cpp
|
2225.cpp
|
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
using namespace std;
long long d[201][201];
int dp(int N, int K) {
if (K == 1)
return d[N][K] = 1;
if (K == 2)
return d[N][K] = N + 1;
if (d[N][K] != 0)
return d[N][K];
for (int i = 0; i < N; i++)
d[N][K] += dp(N - i, K - 1);
d[N][K] += 1;
return d[N][K] %= 1000000000;
}
int main(void) {
int N, K;
cin >> N >> K;
cout << dp(N, K);
}
|
ff5b3415e43006c442d6e56c5a8ebd0a4bccbc0d
|
ca170d96a960e95a7822eb69c65179898a601329
|
/3rd/fltk/src/CheckButton.cxx
|
94bd53e0f15f7ccd84ce77661d730eb2645a0d45
|
[
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"LGPL-2.0-only"
] |
permissive
|
sgumhold/cgv
|
fbd67e9612d4380714467d161ce264cf8c544b96
|
cd1eb14564280f12bac35d6603ec2bfe6016faed
|
refs/heads/master
| 2023-08-17T02:30:27.528703
| 2023-01-04T12:50:38
| 2023-01-04T12:50:38
| 95,436,980
| 17
| 29
|
BSD-3-Clause
| 2023-04-20T20:54:52
| 2017-06-26T10:49:07
|
C++
|
UTF-8
|
C++
| false
| false
| 3,105
|
cxx
|
CheckButton.cxx
|
//
// "$Id: CheckButton.cxx 6141 2008-07-13 06:41:56Z spitzak $"
//
// Copyright 1998-2006 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs@fltk.org".
#include <fltk/CheckButton.h>
#include <fltk/Group.h>
#include <fltk/Box.h>
#include <fltk/draw.h>
using namespace fltk;
/*! \class fltk::CheckButton
This button turns the value() on and off each release of a click
inside of it, and displays a checkmark to show the user this:
\image html Fl_Check_Button.gif
You can control the color of the checkbox with color() and the
color of the checkmark with textcolor(). You can make it draw
different colors when turned on by setting selection_color()
and selection_textcolor() on the widget (these are ignored if
set in an inherited style()).
*/
static class CheckBox : public Symbol {
public:
void _draw(const Rectangle& R) const {
Box* box = drawstyle()->box();
// for back compatability with some programs that changed the
// square into a diamond or circle, where the checkmark does
// not look too good. Draw the box colored in with the
// selected color instead:
if (!box->fills_rectangle()) {
if (drawflags()&STATE) setbgcolor(drawstyle()->selection_color());
box->draw(R);
return;
}
// Otherwise draw the box with normal colors and then draw checkmark
// inside it:
if (drawflags()&PUSHED) setbgcolor(GRAY50);
box->draw(R);
if (drawflags()&STATE) {
Rectangle r(R); box->inset(r);
if (r.h() < 6) {r = Rectangle(R,6,6); r.move(1,1);}
int x = r.x()+1;
int w = r.h()-2;
int d1 = w/3;
int d2 = w-d1;
int y = r.y()+(r.h()+d2)/2-d1-2;
for (int n = 0; n < 3; n++, y++) {
drawline(x, y, x+d1, y+d1);
drawline(x+d1, y+d1, x+w-1, y+d1-d2+1);
}
}
}
CheckBox() : Symbol("checkbox") {}
} glyph;
void CheckButton::draw() {
Button::draw(int(textsize())+2);
}
static void revert(Style* s) {
s->buttonbox_ = NO_BOX;
//s->box_ = DOWN_BOX;
s->glyph_ = &glyph;
}
static NamedStyle style("Check_Button", revert, &CheckButton::default_style);
NamedStyle* CheckButton::default_style = &::style;
CheckButton::CheckButton(int x, int y, int w, int h, const char *l)
: Button(x, y, w, h, l)
{
style(default_style);
type(TOGGLE);
set_flag(ALIGN_LEFT|ALIGN_INSIDE);
}
|
bee21680c186b3de675b37c2f2d92973a1015d0a
|
98f7dcefc3ae8549939bd42b07b083fe1822f3ea
|
/DatalogProgram.h
|
5d3a1dd820eb33f915fbd6bbc1120b674e4e8f2e
|
[] |
no_license
|
andresmatos2000/project5
|
a1701c8a81d5f7e583d1e802058cfcad3f3fae05
|
313c4bdd14ddd2fdb09b70d600ec7866dbc7a42d
|
refs/heads/main
| 2023-06-29T00:03:18.245889
| 2021-08-02T17:14:30
| 2021-08-02T17:14:30
| 388,567,091
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,242
|
h
|
DatalogProgram.h
|
//
// Created by munch on 7/3/2021.
//
#ifndef PROJECT1_DATALOGPROGRAM_H
#define PROJECT1_DATALOGPROGRAM_H
#include "Predicate.h"
#include "Parameter.h"
#include "Rule.h"
#include <vector>
#include <set>
class DatalogProgram{
private:
public:
std::vector<Predicate*> Schemes;
std::vector<Predicate*> Facts;
std::vector<Rule*> Rules;
std::vector<Predicate*> Queries;
std::set<std::string> Domain;
void addScheme(Predicate* schemes);
void addFact(Predicate* facts);
void addQuery(Predicate* queries);
void addRule(Rule* rule);
std::string To_String();
void parseDomain(std::vector<Parameter*>domain);
void parseHelper();
DatalogProgram(){
std::vector<Predicate*> Schemes;
std::vector<Predicate*> Facts;
std::vector<Rule*> Rules;
std::vector<Predicate*> Queries;
};
~DatalogProgram(){
for (auto p : Schemes){
delete p;
}
Schemes.clear();
for( auto p: Facts){
delete p;
} Facts.clear();
for( auto p: Rules){
delete p;
} Rules.clear();
for( auto p: Queries){
delete p;
} Queries.clear();
}
};
void DatalogProgram::addScheme(Predicate* schemes) {
Schemes.push_back(schemes);
}
void DatalogProgram::addFact(Predicate* facts) {
Facts.push_back(facts);
}
void DatalogProgram::addQuery(Predicate* queries) {
Queries.push_back(queries);
}
void DatalogProgram::addRule(Rule* rule){
Rules.push_back(rule);
}
void DatalogProgram::parseHelper(){
for (unsigned int i = 0; i < Facts.size(); ++i) {
parseDomain(Facts[i]->getParameters());
}
};
void DatalogProgram::parseDomain(std::vector<Parameter*>domain){
for (unsigned int i = 0; i < domain.size(); ++i) {
Domain.insert(domain[i]->getValue());
}
};
std::string DatalogProgram::To_String(){
std::string fullString;
if(!Schemes.empty()){
fullString += "Schemes(" + std::to_string(Schemes.size()) + ")"+":\n";
for (unsigned int i = 0; i < Schemes.size(); ++i) {
fullString += " " + Schemes[i]->To_String() + "\n";
}
}
if(!Facts.empty()){
fullString += "Facts(" + std::to_string(Facts.size()) + ")"+":\n";
for (unsigned int i = 0; i < Facts.size(); ++i) {
fullString += " " + Facts[i]->To_String() + ".\n";
}
} else fullString += "Facts(0):\n";
if(!Rules.empty()){
fullString += "Rules(" + std::to_string(Rules.size()) + ")"+":\n";
for (unsigned int i = 0; i < Rules.size(); ++i) {
fullString += " " + Rules[i]->To_String() + ".\n";
}
} else fullString += "Rules(0):\n";
if(!Queries.empty()){
fullString += "Queries(" + std::to_string(Queries.size()) + ")"+":\n";
for (unsigned int i = 0; i < Queries.size(); ++i) {
fullString += " " + Queries[i]->To_String() + "?\n";
}
}
if(!Domain.empty()){
fullString += "Domain(" + std::to_string(Domain.size()) + ")"+":\n";
for(auto f : Domain){
fullString += " " + f + "\n";
}
}else fullString += "Domain(0):\n";
return fullString;
}
#endif //PROJECT1_DATALOGPROGRAM_H
|
08dd20353b7efb7545936175b3c98dd6ce67d528
|
753b12c79a61a4b903453b8b73249661dd7247fe
|
/opencvhelper.cpp
|
7ed271fd3aa84c74ae1ae4193c987c22bf7dfb3d
|
[] |
no_license
|
sheMnapion/Opencv-Qt-Image-Processor
|
4697ad24121c9bdf0ab56f98d4c71741b0c34431
|
6f444cc32c662e162b43a90e25f2eb0d9e131a08
|
refs/heads/master
| 2020-03-28T08:00:14.183599
| 2018-09-26T15:29:28
| 2018-09-26T15:29:28
| 147,938,246
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,497
|
cpp
|
opencvhelper.cpp
|
#include "opencvhelper.h"
#include "mymainwindow.h"
#include <QDebug>
#include <QString>
uchar *pixelColor(Mat &img,int x,int y)
{
if(x>img.rows||y>img.cols||x<0||y<0){
cout<<"Invalid position!!!"<<endl;
return NULL;
}
int channelNumber=img.channels();
assert(channelNumber>=1);
uchar *ret=(uchar *)malloc(sizeof(uchar)*channelNumber);
uchar *poz=img.ptr<uchar>(x);
for(int i=0;i<channelNumber;i++)
ret[i]=poz[i];
return ret;
}
int setFeatureMatrix(Mat &image,Mat &featureImage,int threshold,QString &method)
{
if(image.empty())
return EMPTY_INPUT;//do nothing for empty image
if(image.channels()!=3&&image.channels()!=4)
return NOT_ENOUGH_CHANNELS;
qDebug()<<method<<" with threshold "<<threshold;
Mat tempImage;
cvtColor(image, tempImage, COLOR_BGR2GRAY);
//create a keypoint vectors
vector<KeyPoint> keypoints;
//use method FAST for now
if(method=="Fast Detector"){
FastFeatureDetector fastDetector(threshold);
//Compute keypoints in in_img with detector1 and detector2
fastDetector.detect(tempImage, keypoints);
drawKeypoints(image, keypoints, featureImage, Scalar::all(-1));
}
else if(method=="Surf Detector"){
SurfFeatureDetector surfDetector(3500,threshold,2,false,false);
surfDetector.detect(image,keypoints);
drawKeypoints(image,keypoints,featureImage,Scalar::all(-1),DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
}
else if(method=="Orb Detector"){
OrbFeatureDetector orbDetector(threshold,1.1f,2,31,0,2,ORB::HARRIS_SCORE,31);
orbDetector.detect(image,keypoints);
drawKeypoints(image,keypoints,featureImage);
}
else{
qDebug()<<"TODO";
}
qDebug()<<"Size: "<<keypoints.size();
return 0;
}
QImage *Mat2QImage(const Mat &imago)
{
QImage *img;
if(imago.channels()==3)
{
//cvt Mat BGR 2 QImage RGB
cout<<"Normal picture"<<endl;
Mat *temp=new Mat();
*temp=imago.clone();
cv::cvtColor(*temp,*temp,CV_BGR2RGB);
img =new QImage((const unsigned char*)(temp->data),
temp->cols,temp->rows,
temp->cols*temp->channels(),
QImage::Format_RGB888);
}
else if(imago.type()==CV_8UC1){
cout<<"Gray picture!"<<endl;
img =new QImage((const unsigned char*)(imago.data),
imago.cols,imago.rows,
imago.cols*imago.channels(),
QImage::Format_Grayscale8);
}
else
{
img =new QImage((const unsigned char*)(imago.data),
imago.cols,imago.rows,
imago.cols*imago.channels(),
QImage::Format_RGB888);
}
return img;
}
void setContraBrightMatrix(Mat &img, Mat &dst, int contra, int bright)
{
cvtColor(img,img,COLOR_BGR2GRAY);
int deltaContra=contra-100;
int deltaBright=bright-100;
double a,b;
if(deltaContra>0){
double delta=127.*deltaContra/100;
a=255./(255.-2*delta);
b=a*(deltaBright-delta);
}
else{
double delta=-128.*deltaContra/100;
a=(256.-delta*2)/255.;
b=a*deltaBright+delta;
}
img.convertTo(dst,CV_8U,a,b);
}
void setEqualizedMatrix(Mat &img, Mat &dst)
{
if(img.empty()==true){
qDebug()<<"Empty image to equalize!";
return;
}
vector<Mat> bgrPlanes;
split(img,bgrPlanes);
int size=bgrPlanes.size();
for(int i=0;i<size;i++)
equalizeHist(bgrPlanes[i],bgrPlanes[i]);
merge(bgrPlanes,dst);
}
void getRetinaMatrix(Mat &img, Mat &dst)
{
Retina myRetina(img.size());
//save default retina parameters file
// myRetina->write("RetinaDefaultParameters.xml");
//The parameters may be reloaded using method setup
myRetina.clearBuffers();
myRetina.run(img);
//retrieve and display retina output
myRetina.getParvo(dst);
}
QString cvhelperError(int errorNumber)
{
QString ret;
switch(errorNumber){
case SUCCESS:
ret=QString("Success");
break;
case NOT_ENOUGH_CHANNELS:
ret=QString("The input image doesn't contain enough channel for desired operation");
break;
case EMPTY_INPUT:
ret=QString("The input image is empty");
break;
default:
ret=QString("Unexpected input!!!");
break;
}
return ret;
}
|
01250ff7f8f648b7cceb9ce7cb517b109ac53da1
|
2400447effade918f9962578d18365889db75e2d
|
/SinglyLinkedList/Source.cpp
|
7ea9707d1f6b30c7f9ee8311dd233e5f3b620c62
|
[] |
no_license
|
bjoonly/SinglyLinkedList
|
fb2f451ebb69360d51a1645d7a0018003c8b2543
|
7280875d52999b74bce2584d74ec62859cad2e75
|
refs/heads/master
| 2022-11-18T09:08:40.186807
| 2020-06-27T16:31:50
| 2020-06-27T16:32:38
| 275,006,115
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,402
|
cpp
|
Source.cpp
|
#include"List.h"
#include"StackList.h"
int main(){
cout << "Singly linked list:\nCreate list:\nAdd to head:\n";
List<int>l1;
l1.AddToHead(12);
l1.Print();
l1.AddToHead(17);
l1.Print();
cout << "\nAdd to tail:\n";
l1.AddToTail(77);
l1.Print();
l1.AddToTail(55);
l1.Print();
cout << "\nAdd to position:\n";
l1.AddToPos(1, 100);
l1.Print();
l1.AddToPos(5, -10);
l1.Print();
cout << "\nDelete from position:\n";
l1.DelteFromPos(l1.GetCount()-1);
l1.Print();
l1.DelteFromPos(2);
l1.Print();
cout << "\nDelete from tail:\n";
l1.DeleteTail();
l1.Print();
cout << "\nDelete from head:\n";
l1.DeleteHead();
l1.Print();
cout << "\nFind by possition:\n";
cout<<l1.Find(2)<<endl;
system("pause");
system("cls");
cout << "Stack:\nCreate and fill first stack:\n";
StackList<int>sl1,sl2;
sl1.Push(12);
sl1.Print();
sl1.Push(22);
sl1.Print();
sl1.Push(17);
sl1.Print();
sl1.Push(11);
sl1.Print();
cout << "Second stack = first stack.\n";
sl2 = sl1;
cout << "Remove elements:\n";
cout << sl1.Pop()<<endl;
cout << sl1.Pop() << endl;
cout << "First stack:\n";
sl1.Print();
cout << "Clear first stack:\n";
sl1.Clear();
cout << "Elements in first stack: "<<sl1.GetCount() << endl;
cout << "Second stack:\n";
sl2.Print();
cout << "Add elemetn in second stack:\n";
sl2.Push(55);
sl2.Print();
cout <<"Last added in second stack: "<< sl2.Peek() << endl;
return 0;
}
|
724a4a47a1fab2b445bd32a20b557d9aa783d580
|
39689c7df24cb5df4155ccb6b2303cd730d6c949
|
/14649.cpp
|
a1cacb9df07d5e559b6b10d9cf03a8ce3f4b43c2
|
[] |
no_license
|
kisang0365/baekjoonAlgorithm
|
7f154cfa3dd2a4f50112061973cd2914acd2c9aa
|
781e8473f158488cf2cab8cbba8800c0102271ac
|
refs/heads/master
| 2021-01-23T03:59:16.446254
| 2017-10-27T08:55:09
| 2017-10-27T08:55:09
| 86,140,982
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 724
|
cpp
|
14649.cpp
|
/*
* 14649.cpp
*
* Created on: 2017. 7. 23.
* Author: chokisang
*/
#include<iostream>
using namespace std;
int main(){
double money;
cin >> money;
int Rock[101] = {0, };
int N;
cin >> N;
for(int i=0; i<N; i++){
int number;
char d;
cin >> number >> d;
if(d == 'R'){
for(int a=number+1; a<=100; a++){
Rock[a]++;
}
}
else{
for(int a=number-1; a>=0; a--){
Rock[a]++;
}
}
}
int n1 = 0, n2 = 0, n3 = 0;
for(int i=1; i<=100; i++){
if(Rock[i]%3 == 0){
n1++;
}
else if(Rock[i]%3 == 1){
n2++;
}
else{
n3++;
}
}
cout<<fixed;
cout.precision(2);
int z = n1+n2+n3;
cout<<(money/z)*n1<<endl<<(money/z)*n2<<endl<<(money/z)*n3<<endl;
return 0;
}
|
069c5480d6d982979356b805677a4bd70c788091
|
9f9266a40a869e34c8627f66d0ef05ec25c40236
|
/AnvilEldorado/Source/Game/UI/UIImpl.cpp
|
73e8beb5059b43a23fd8c078f1ebc7e7c364290e
|
[
"MIT"
] |
permissive
|
AnvilOnline/AnvilClient
|
b2d6273de7c1f7d436f939e19948edf2c69631da
|
9b7751d9583d7221fd9c9f1b864f27e7ff9fcf79
|
refs/heads/development
| 2020-04-13T22:12:16.638751
| 2017-04-22T17:22:10
| 2017-04-22T17:22:10
| 44,775,425
| 57
| 23
| null | 2017-04-22T17:22:10
| 2015-10-22T21:53:19
|
C++
|
UTF-8
|
C++
| false
| false
| 969
|
cpp
|
UIImpl.cpp
|
#include "UIImpl.hpp"
#include "Hooks.hpp"
using namespace AnvilEldorado::Game::UI;
bool UIImpl::Init()
{
m_Hooks = std::make_shared<UI::Hooks>();
if (!m_Hooks->Init())
return false;
return true;
}
const auto UI_Alloc = reinterpret_cast<void *(__cdecl *)(int32_t)>(0xAB4ED0);
const auto UI_OpenDialogById = reinterpret_cast<void *(__thiscall *)(void *, Blam::Text::StringID, int32_t, int32_t, Blam::Text::StringID)>(0xA92780);
const auto UI_PostMessage = reinterpret_cast<int(*)(void *)>(0xA93450);
void* UIImpl::ShowDialog(const Blam::Text::StringID &p_DialogID, const int32_t p_Arg1, const int32_t p_Flags, const Blam::Text::StringID &p_ParentID)
{
// TODO: Fix
//WriteLog("Showing ui dialog '%s'...", Blam::Cache::StringIDCache::Instance()->GetString(p_DialogID));
auto *s_UIData = UI_Alloc(0x40);
if (!s_UIData)
return nullptr;
UI_OpenDialogById(s_UIData, p_DialogID, p_Arg1, p_Flags, p_ParentID);
UI_PostMessage(s_UIData);
return s_UIData;
}
|
98652abd6387351846b84c604dbff7c8df48797e
|
1ddeb3857ee629e950dc930b679ffc05c684d562
|
/CommunicationModule/FC_ESP8266_WiFiComm.h
|
a4d84e0d86dd3bc9ea4518f17f8e0a6daae58a36
|
[] |
no_license
|
JanWielgus/STM_FlightController
|
5f1c51a6fe5eea31a162a7fcb12121aa94ded36e
|
03b84d3523a03ddff387ce6d1ca1c530f5a74167
|
refs/heads/master
| 2021-07-12T00:44:36.291868
| 2020-06-06T22:26:53
| 2020-06-06T22:26:53
| 142,678,917
| 1
| 0
| null | 2020-06-05T11:29:56
| 2018-07-28T13:20:07
|
C++
|
UTF-8
|
C++
| false
| false
| 1,799
|
h
|
FC_ESP8266_WiFiComm.h
|
// FC_ESP8266_WiFiComm.h
//
// Author: Jan Wielgus
// Created: 04.06.2020
//
#ifndef _FC_ESP8266_WIFICOMM_h
#define _FC_ESP8266_WIFICOMM_h
#include "arduino.h"
#include <Arduino.h>
#include <DataBuffer.h>
#include <IPacketTransceiver.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
class FC_ESP8266_WiFiComm : public IPacketTransceiver
{
public:
FC_ESP8266_WiFiComm(const char* ssid, const char* pass, uint16_t port, size_t maxPacketSize);
~FC_ESP8266_WiFiComm();
// setup methods
bool isConnected();
// config methods
void setTargetIPAddress(IPAddress ipAddress);
void setTargetIPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
void setTargetIPAddrAlwaysToLastSender(); // always before sending set targetIPAddress to udp.remoteIP()
// public interface methods
void begin() override;
bool send(const uint8_t* buffer, size_t size) override;
DataBuffer receiveNextData() override; // receive AT MOST ONE data packet. HAVE TO be called until available() return false (data packet was incomplete or no data)
size_t available() override; // return false if there is no data or data packet is incomplete
private: // methods
bool checkIfUdpBeginned(); // return true if udp was beginned and data could be sent, connect with wifi if not connected
private: // data
bool udpBeginnedFlag = false; // set after successful wifi connection
bool sendToRemoteIPFlag = true; // before every sending, set target IP to udp.remoteIP()
WiFiUDP udp;
IPAddress localIPAddress;
IPAddress targetIPAddress; // IP address where data will be sent using send() method
// initial config
const char* SSID;
const char* PASS;
const uint16_t Port;
const size_t MaxPacketSize;
// data buffers
DataBuffer receiveBuffer;
};
#endif
|
3c28c1c4343d03bfac016df9f6a44fcaf087f5f7
|
db666b5c6b5381c55c716f95818a7ecc241d59c7
|
/C++/4-medianOfTwoSortedArrays.cpp
|
674b6769f50ed2720a95eab2cacb5dc0fc0e10b9
|
[] |
no_license
|
SaberDa/LeetCode
|
ed5ea145ff5baaf28ed104bb08046ff9d5275129
|
7dc681a2124fb9e2190d0ab37bf0965736bb52db
|
refs/heads/master
| 2023-06-25T09:16:14.521110
| 2021-07-26T21:58:33
| 2021-07-26T21:58:33
| 234,479,225
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,878
|
cpp
|
4-medianOfTwoSortedArrays.cpp
|
#include <iostream>
#include <vector>
using namespace std;
double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
int m = nums1.size();
int n = nums2.size();
if (m > n) {
return findMedianSortedArrays(nums2, nums1);
}
if (m == 0) {
if (n & 1 == 1) {
return nums2[n/2];
} else {
return (nums2[n/2] + nums2[n/2-1]) / 2.0;
}
}
if (n == 0) {
if (m & 1 == 1) {
return nums1[m/2];
} else {
return (nums1[m/2] + nums1[m/2-1]) / 2.0;
}
}
int left = 0;
int right = m;
int mid = (m + n + 1) / 2;
while (left <= right) {
int i = (left + right) / 2;
int j = mid - i;
if (i < m && nums2[j-1] > nums1[i]) {
left = i + 1;
} else if (i > 0 && nums1[i-1] > nums2[j]) {
right = i - 1;
} else {
int maxLeft = 0;
int minRight = 0;
if (i == 0) {
maxLeft = nums2[j-1];
} else if (j == 0) {
maxLeft = nums1[i-1];
} else {
maxLeft = max(nums1[i-1], nums2[j-1]);
}
// maxLeft = (i == 0) ? nums2[j-1] : (j == 0) ? nums1[i-1] : max(nums1[i-1], nums2[j-1]);
if ((m+n) / 2 == 1) {
return maxLeft;
}
if (i == m) {
minRight = nums2[j];
} else if (j == n) {
minRight = nums1[i];
} else {
minRight = min(nums1[i], nums2[j]);
}
return (maxLeft + minRight) / 2.0;
}
}
return 0;
}
int main() {
vector<int> nums1 = { 100001 };
vector<int> nums2 = { 100000 };
double res = findMedianSortedArrays(nums1, nums2);
cout << res << endl;
return 0;
}
|
ac01516b308d8f265b20d09d34406b5303f04a1c
|
c78f29e9f1fbdaa2e8fcae5dfebb364d325bb818
|
/src/kmeans/kmeans_main.cpp
|
ce3432bd3c0014a88ec93557ade0a671732e66f1
|
[
"MIT"
] |
permissive
|
ivanzamanov/kmeans
|
8cac332d3292753be08d69baca0b0231413a8eb6
|
5b24fb7549b05ee82a8e5081a9194e3c61ed9da5
|
refs/heads/master
| 2021-01-22T00:10:22.601385
| 2014-02-12T01:33:49
| 2014-02-12T01:33:49
| 16,419,252
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,866
|
cpp
|
kmeans_main.cpp
|
#include<stdio.h>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<math.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<dirent.h>
#include<unistd.h>
#include<fcntl.h>
#include"ptree.h"
#include"hash.h"
#include"list.h"
#include"kmeans.h"
void save(list<article_entry*> &entries, hash<double> &h, const char* name) {
article_entry* entry = new article_entry;
entries.add(entry);
int size = h.size;
entry->v.size = size;
int* keys = new int[size];
double* values = new double[size];
for(int i=0; i<size; i++) {
keys[i] = h.keys[i];
values[i] = h.data[i];
}
int nameLength = strlen(name);
char* entry_name = new char[nameLength + 1];
for(int i=0; i<nameLength; i++)
entry_name[i] = name[i];
entry_name[nameLength] = 0;
entry->name = entry_name;
entry->v.keys = keys;
entry->v.values = values;
}
int tokenCount = 0;
void processFile(const char* path, const char* name, ptree<int>& p, list<article_entry*> &entries) {
if(*name == '.')
return;
int fd = open(path, O_RDONLY);
if(fd < 0) {
printf("Cannot open file %s\nCode = %d\n", path, fd);
return;
}
char* fullData = 0;
readFullData(fd, &fullData);
close(fd);
char buffer[4096];
int offset = 0;
hash<double> h;
int* index_ptr = 0;
int index = 0;
while(readToken(fullData, offset, buffer, 4096)) {
if(strlen(buffer) <= 3)
continue;
index_ptr = p.get(buffer);
if(index_ptr == 0) {
p.add(buffer, tokenCount);
index = tokenCount;
tokenCount++;
} else {
index = *index_ptr;
}
int tf = h.get(index, 0);
tf++;
h.insert(index, tf);
}
save(entries, h, name);
delete fullData;
}
void processDirectory(const char* inputDirPath) {
DIR* dirHandle = opendir(inputDirPath);
struct dirent* entry = readdir(dirHandle);
list<article_entry*> entries;
char path[4096];
ptree<int> p;
double docCount = 0;
while(entry != NULL) {
sprintf(path, "%s/%s", inputDirPath, entry->d_name);
processFile(path, entry->d_name, p, entries);
entry = readdir(dirHandle);
docCount++;
}
printf("Unique tokens: %d in %d documents\n", tokenCount, (int)docCount);
// Document frequencies
double* dfs = new double[tokenCount];
for (int i=0; i<tokenCount; i++)
dfs[i] = 0;
for(int i=0; i<entries.size(); i++) {
vector& v = entries.get(i)->v;
for(int j=0; j<v.size; j++)
dfs[ v.keys[j] ]++;
}
for(int i=0; i<entries.size(); i++) {
vector& v = entries.get(i)->v;
for(int j=0; j<v.size; j++) {
int tf = v.values[j];
double idf = log( docCount / dfs[ v.keys[j] ]);
v.values[j] = ((double) tf) * idf;
}
}
delete dfs;
kmeans(entries);
closedir(dirHandle);
}
int main(int argc, char** argv) {
setbuf(stdout, NULL);
if(argc < 2) {
printf("Not enough arguments\n");
printf("Usage: %s <input_dir> <output_file>", argv[0]);
return 1;
}
const char* inputPath = argv[1];
processDirectory(inputPath);
}
|
bb4720e0ce9981ad531246dc0f460f9b1a7702c9
|
1885ce333f6980ab6aad764b3f8caf42094d9f7d
|
/test/e2e/test_master/podofo/base/PdfEncodingFactory.h
|
8b5e1551ff4ca1fc355fa1b0eaa92d472e25703c
|
[
"MIT"
] |
permissive
|
satya-das/cppparser
|
1dbccdeed4287c36c61edc30190c82de447e415b
|
f9a4cfac1a3af7286332056d7c661d86b6c35eb3
|
refs/heads/master
| 2023-07-06T00:55:23.382303
| 2022-10-03T19:40:05
| 2022-10-03T19:40:05
| 16,642,636
| 194
| 26
|
MIT
| 2023-06-26T13:44:32
| 2014-02-08T12:20:01
|
C++
|
UTF-8
|
C++
| false
| false
| 8,444
|
h
|
PdfEncodingFactory.h
|
/***************************************************************************
* Copyright (C) 2008 by Dominik Seichter *
* domseichter@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library 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 Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* In addition, as a special exception, the copyright holders give *
* permission to link the code of portions of this program with the *
* OpenSSL library under certain conditions as described in each *
* individual source file, and distribute linked combinations *
* including the two. *
* You must obey the GNU General Public License in all respects *
* for all of the code used other than OpenSSL. If you modify *
* file(s) with this exception, you may extend this exception to your *
* version of the file(s), but you are not obligated to do so. If you *
* do not wish to do so, delete this exception statement from your *
* version. If you delete this exception statement from all source *
* files in the program, then also delete it here. *
***************************************************************************/
#ifndef _PDF_ENCODING_FACTORY_H_
# define _PDF_ENCODING_FACTORY_H_
# include "PdfDefines.h"
# include "util/PdfMutex.h"
# include "string.h"
namespace PoDoFo
{
class PdfEncoding;
class PdfDocEncoding;
class PdfMacRomanEncoding;
class PdfObject;
class PdfWinAnsiEncoding;
class PdfStandardEncoding;
class PdfMacExpertEncoding;
class PdfSymbolEncoding;
class PdfZapfDingbatsEncoding;
class PdfIdentityEncoding;
class PdfWin1250Encoding;
class PdfIso88592Encoding;
/** This factory creates a PdfEncoding
* from an existing object in the PDF.
*/
class PODOFO_API PdfEncodingFactory
{
public:
/** Singleton method which returns a global instance
* of PdfDocEncoding.
*
* \returns global instance of PdfDocEncoding
*/
static const PdfEncoding* GlobalPdfDocEncodingInstance();
/** Singleton method which returns a global instance
* of WinAnsiEncoding.
*
* \returns global instance of WinAnsiEncoding
*
* \see GlobalWin1250EncodingInstance, GlobalIso88592EncodingInstance
*/
static const PdfEncoding* GlobalWinAnsiEncodingInstance();
/** Singleton method which returns a global instance
* of MacRomanEncoding.
*
* \returns global instance of MacRomanEncoding
*/
static const PdfEncoding* GlobalMacRomanEncodingInstance();
// OC 13.08.2010:
/** Singleton method which returns a global instance
* of StandardEncoding.
*
* \returns global instance of StandardEncoding
*/
static const PdfEncoding* GlobalStandardEncodingInstance();
// OC 13.08.2010:
/** Singleton method which returns a global instance
* of MacExpertEncoding.
*
* \returns global instance of MacExpertEncoding
*/
static const PdfEncoding* GlobalMacExpertEncodingInstance();
// OC 13.08.2010:
/** Singleton method which returns a global instance
* of SymbolEncoding.
*
* \returns global instance of SymbolEncoding
*/
static const PdfEncoding* GlobalSymbolEncodingInstance();
// OC 13.08.2010:
/** Singleton method which returns a global instance
* of ZapfDingbatsEncoding.
*
* \returns global instance of ZapfDingbatsEncoding
*/
static const PdfEncoding* GlobalZapfDingbatsEncodingInstance();
/** Singleton method which returns a global instance
* of IndentityEncoding useful for writing direct UTF8 strings.
*
* \returns global instance of IdentityEncoding
*/
static const PdfEncoding* GlobalIdentityEncodingInstance();
/** Singleton method which returns a global instance
* of Win1250Encoding.
*
* \returns global instance of Win1250Encoding
*
* \see GlobalWinAnsiEncodingInstance, GlobalIso88592EncodingInstance
*/
static const PdfEncoding* GlobalWin1250EncodingInstance();
/** Singleton method which returns a global instance
* of Iso88592Encoding.
*
* \returns global instance of Iso88592Encoding
*
* \see GlobalWinAnsiEncodingInstance, GlobalWin1250EncodingInstance
*/
static const PdfEncoding* GlobalIso88592EncodingInstance();
/** Free's the memory allocated by
* the global encoding instancess in this singleton.
*
* PoDoFo will reallocated these encodings as soon
* as they are needed again.
*
* Only call this method if no other class
* of PoDoFo exists anymore, as PdfString etc
* contain pointers to the global instances.
*
*/
static void FreeGlobalEncodingInstances();
static void PoDoFoClientAttached();
private:
// prohibit instantiating all-methods-static factory from outside
PdfEncodingFactory();
/** Always use this static declaration,
* if you need an instance of PdfDocEncoding
* as heap allocation is expensive for PdfDocEncoding.
*/
static const PdfDocEncoding* s_pDocEncoding;
/** Always use this static declaration,
* if you need an instance of PdfWinAnsiEncoding
* as heap allocation is expensive for PdfWinAnsiEncoding.
*/
static const PdfWinAnsiEncoding* s_pWinAnsiEncoding;
/** Always use this static declaration,
* if you need an instance of PdfWinAnsiEncoding
* as heap allocation is expensive for PdfWinAnsiEncoding.
*/
static const PdfMacRomanEncoding* s_pMacRomanEncoding;
// OC 13.08.2010:
/** Always use this static declaration,
* if you need an instance of StandardEncoding
* as heap allocation is expensive for PdfStandardEncoding.
*/
static const PdfStandardEncoding* s_pStandardEncoding;
// OC 13.08.2010:
/** Always use this static declaration,
* if you need an instance of MacExpertEncoding
* as heap allocation is expensive for PdfMacExpertEncoding.
*/
static const PdfMacExpertEncoding* s_pMacExpertEncoding;
// OC 13.08.2010:
/** Always use this static declaration,
* if you need an instance of SymbolEncoding
* as heap allocation is expensive for PdfSymbolEncoding.
*/
static const PdfSymbolEncoding* s_pSymbolEncoding;
// OC 13.08.2010:
/** Always use this static declaration,
* if you need an instance of ZapfDingbatsEncoding
* as heap allocation is expensive for PdfZapfDingbatsEncoding.
*/
static const PdfZapfDingbatsEncoding* s_pZapfDingbatsEncoding;
static const PdfIdentityEncoding* s_pIdentityEncoding;
/** Always use this static declaration,
* if you need an instance of PdfWin1250Encoding
* as heap allocation is expensive for PdfWin1250Encoding.
*/
static const PdfWin1250Encoding* s_pWin1250Encoding;
/** Always use this static declaration,
* if you need an instance of PdfIso88592Encoding
* as heap allocation is expensive for PdfIso88592Encoding.
*/
static const PdfIso88592Encoding* s_pIso88592Encoding;
static Util::PdfMutex s_mutex;
};
}
#endif
|
fbed2078ba32b9a22647029c691d47e35d2d6068
|
906784701763ff93539eff9c15b43dbbdabc8046
|
/main/page19.h
|
214f4fcb07c70ace146598c34ff67d55e8fddf2b
|
[] |
no_license
|
sandeep123patel/Tao
|
f964f1a36712017abcb1c76223602444cd23efff
|
8dfbca53362582e26afe7d5fa554db93a7c6cd74
|
refs/heads/master
| 2021-01-20T10:05:33.396743
| 2017-12-28T19:06:50
| 2017-12-28T19:06:50
| 101,622,044
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 251
|
h
|
page19.h
|
#ifndef PAGE19_H
#define PAGE19_H
#include <QDialog>
namespace Ui {
class page19;
}
class page19 : public QDialog
{
Q_OBJECT
public:
explicit page19(QWidget *parent = 0);
~page19();
private:
Ui::page19 *ui;
};
#endif // PAGE19_H
|
4c6a781cdb0f4513ced6ad9fcd0f918eb39def8e
|
a406aea9ba5bf9f961263ea80b48dd0475a7b82e
|
/12_1StrBlob/StrBlobPtr.hpp
|
660559018d55be1cb76126eeb37e8d0676ad2337
|
[] |
no_license
|
coder-wpt/Cppprimer_Codes
|
9b9c82ef642075f3767934f7a48fb8c5384f4227
|
19e71707fbb6dfa4fa35e938ddb6132db44719b0
|
refs/heads/master
| 2023-02-15T10:27:02.681395
| 2021-01-16T08:20:08
| 2021-01-16T08:20:08
| 311,896,540
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 717
|
hpp
|
StrBlobPtr.hpp
|
#ifndef STRBLOBPTR_HPP
#define STRBLOBPTR_HPP
#include "StrBlob.hpp"
#include <vector>
#include <string>
#include <iostream>
#include <memory>
class StrBlobPtr
{
public:
StrBlobPtr():curr(0){}
StrBlobPtr(StrBlob & a,std::size_t sz=0):wptr(a.data),curr(sz){}
std::string& deref() const;
StrBlobPtr& invr();
private:
std::shared_ptr<std::vector<std::string>> check(std::size_t i,const std::string& msg)const
{
auto ret=wptr.lock();
if(!ret)
throw std::runtime_error("unbound StrBlobPtr");
if(i>=ret->size())
throw std::out_of_range(msg);
return ret;
}
std::weak_ptr<std::vector<std::string>>wptr;
std::size_t curr;
};
#endif
|
6394908e671a5b458981e461144745c59bbaafc7
|
a477fd0aca844fa3f2d391d53bec9fa424e30a9d
|
/wxChess/ChessPanel.h
|
f2e715ac5fbd60b5099eea33070c9be25b727442
|
[] |
no_license
|
ChristianPao/wxChess
|
878a58b05d3592d1256d78a7380ae5b108e0d05a
|
68f9d8f5c80d8bf721a27190fe827221d62eb16b
|
refs/heads/master
| 2022-12-22T14:46:38.570148
| 2020-09-27T20:06:45
| 2020-09-27T20:06:45
| 282,753,434
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 537
|
h
|
ChessPanel.h
|
#pragma once
#include <wx/wx.h>
#include "Board.h"
#include "Pieces.h"
#include <wx/graphics.h>
class ChessPanel : public wxPanel
{
public:
ChessPanel(wxFrame *parent, Board *board);
private:
void OnPaint(wxPaintEvent& event);
void OnLeftMouseDown(wxMouseEvent& event);
void clearBuffer(wxGraphicsContext *gc);
void drawBoard(wxGraphicsContext* gc);
void drawPieces(wxGraphicsContext* gc);
void drawSelectionScreen(wxGraphicsContext* gc);
void handleScreenSelection(const wxPoint& point);
Board *board;
bool enemySelected;
};
|
11f71b64dbde3f35fad6b24918be5991a9549a27
|
bb9df1b69c2f855a0a094f6bc71c671a70b9da36
|
/leetcode/p083-remove_duplicates_from_sorted_list.cpp
|
4de7a1d4752b1dfb90274f2d9545d71afe20bd5e
|
[] |
no_license
|
cjin/exercises
|
267c0876946c8afebdb5571810de50f3296d590f
|
9207ae241648e611c4bfe0ae7ac383b31ff471f6
|
refs/heads/master
| 2021-06-05T12:10:39.259668
| 2015-08-25T03:59:41
| 2015-08-25T03:59:41
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,240
|
cpp
|
p083-remove_duplicates_from_sorted_list.cpp
|
/*
83
Remove Duplicates from Sorted List
https://leetcode.com/problems/remove-duplicates-from-sorted-list/
Given a sorted linked list, delete all duplicates such that each element
appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
(EASY) Linked List
*/
/*
Use a current pointer to check current->val and last->val.
Pitfalls: need to deal with empty list (NULL head).
Also, be careful when deleting the last element. Below is an example failing
to consider these two cases.
class Solution {
public:
ListNode *deleteDuplicates(ListNode *head) {
ListNode *last = head, *current = NULL;
if (!last->next) return head; else current = head->next; //how about {}
while (current) {
if (current->val == last->val) {
if (current->next) {
last->next = current->next;
}
delete current;
current = last->next; // this is only good if current->next
} else {
current = current->next;
last = last->next;
}
}
return head;
}
};
164 / 164 test cases passed.
Status: Accepted
Runtime: 22 ms
*/
#include <iostream>
#include <vector>
using namespace std;
typedef struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
} ListNode;
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *deleteDuplicates(ListNode *head) {
ListNode *last = head, *current = NULL;
if (!last || !last->next) return head; else current = head->next;
while (current) {
if (current->val == last->val) {
if (current->next) {
last->next = current->next;
delete current;
current = last->next;
} else {
delete current;
last->next = NULL;
break;
}
} else {
current = current->next;
last = last->next;
}
}
return head;
}
};
int main() {
Solution solution;
vector<int> l1data{1, 2, 3, 5, 5, 5, 7, 7, 9, 11};
vector<int> l2data{2, 2};
ListNode *l1 = new ListNode(l1data[0]);
ListNode *current = l1;
for (int i = 1; i < l1data.size(); ++i) {
current->next = new ListNode(l1data[i]);
current = current->next;
}
ListNode * result = solution.deleteDuplicates(l1);
while (result) {
cout << result->val << " ";
result = result->next;
}
cout << endl;
ListNode *l2 = new ListNode(l2data[0]);
current = l2;
for (int i = 1; i < l2data.size(); ++i) {
current->next = new ListNode(l2data[i]);
current = current->next;
}
result = solution.deleteDuplicates(l2);
while (result) {
cout << result->val << " ";
result = result->next;
}
cout << endl;
}
|
22ba15305e6d6cf58d00d1ba2b8efd7a35ab8065
|
a899a86b1d18cd252fe2acc9ae13b4c146e2747b
|
/core/tests/assert/compilation/assert_tu_always_and_disable_always.cpp
|
d318b3cbe1c98124c7bdf94904b2ab309a096000
|
[
"MIT"
] |
permissive
|
BartSiwek/Gris
|
5ca5b8f40b681c08e02d83fa4c57e71b4f46ce2d
|
4521c10dad31b5ffb320a38d7c4c34ffae3b3d22
|
refs/heads/master
| 2023-04-20T11:23:51.076848
| 2021-05-05T23:23:43
| 2021-05-05T23:23:43
| 166,608,215
| 0
| 0
|
MIT
| 2021-05-05T23:23:44
| 2019-01-20T00:33:37
|
C++
|
UTF-8
|
C++
| false
| false
| 120
|
cpp
|
assert_tu_always_and_disable_always.cpp
|
#define GRIS_TU_MODE_ALWAYS
#define GRIS_TU_MODE_DISABLE_ALWAYS
#include <gris/assert.h>
int main()
{
return 0;
}
|
eb2b16dcc5480b1bc0c86e4ce60dbfb800ccc673
|
fcddfe074fbd7f02f28a6823aa6b6610324739c9
|
/src/DOM/NodeList.cxx
|
302e56ae96b30967917a51d580db1c9465a75ce5
|
[] |
no_license
|
sigsegv42/QuantumXML
|
3e36b126327731634ddc0240bcb0b0012a1ca333
|
f98a9beaa4c5228460fde8218e4e009c3751f41a
|
refs/heads/master
| 2016-09-06T21:54:24.699216
| 2011-11-05T05:46:23
| 2011-11-05T05:46:23
| 794,574
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 430
|
cxx
|
NodeList.cxx
|
#include "NodeList.h"
#include "DOMException.h"
using namespace DOM;
boost::shared_ptr<Node> NodeList::item(unsigned long index) const
{
if (index >= _nodes.size())
{
DOMException ex(INDEX_SIZE_ERR);
throw ex;
}
return _nodes[index];
}
unsigned long NodeList::length(void) const
{
return static_cast<unsigned long>(_nodes.size());
}
void NodeList::push_back(boost::shared_ptr<Node> node)
{
_nodes.push_back(node);
}
|
075d22bccce3b3f98fed969b093408693178d548
|
1428039f4841e31b5f5a6acdcf23970f78163b42
|
/Android/graphics/BitmapFactory.h
|
01ce090b12cb015a15b65532fceb6046dd76930c
|
[] |
no_license
|
Shymae/androidpp
|
6b0dc62223b0574e02424b307de2050109a4c08a
|
5fd587157232d1d92bcc9402c0b9acfb5e65034b
|
refs/heads/master
| 2021-05-11T04:04:37.821087
| 2014-02-20T21:56:57
| 2014-02-20T21:56:57
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,022
|
h
|
BitmapFactory.h
|
//
// BitmapFactory.h
// cocos2dx
//
// Created by Saul Howard on 11/13/13.
// Copyright (c) 2013 cocos2d-x. All rights reserved.
//
#ifndef cocos2dx_BitmapFactory_h
#define cocos2dx_BitmapFactory_h
#include "AndroidMacros.h"
#include "cocos2d.h"
#include "Android/graphics/Bitmap.h"
#include <SkImageDecoder.h>
#include <memory>
using namespace std;
ANDROID_BEGIN
class BitmapFactory {
public:
static bool decodeFile(Bitmap *bitmap, const char* filePath) {
cocos2d::CCFileUtils *fileUtils = cocos2d::CCFileUtils::sharedFileUtils();
if (fileUtils->isFileExist(filePath)) {
unsigned long size = 0;
char* pBuffer = (char*) cocos2d::CCFileUtils::sharedFileUtils()->getFileData(filePath, "rt", &size);
if (pBuffer && size > 0) {
SkImageDecoder::DecodeMemory(pBuffer, size, bitmap);
return !bitmap->pixelRef();
}
}
return false;
}
};
ANDROID_END
#endif
|
b8aff27c9f3d1651d38bc3bbbe936ac1652dc892
|
c67cb288cfe0fae0e30138124c836663ae2a7a0c
|
/week4/exercise3/car.cpp
|
1711db92405ccdf69f58325c3524f2299eaeaec7
|
[] |
no_license
|
drcox23/cs162
|
287dc89922bb58413a9629ecdfd0862ac8b20fe6
|
2a62d60e1dc78e45b358f659adaaefc0942b7fd3
|
refs/heads/master
| 2023-01-22T18:07:44.235369
| 2020-12-08T01:19:34
| 2020-12-08T01:19:34
| 298,374,324
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,104
|
cpp
|
car.cpp
|
// Douglas Cox
// Week 3, Exercise 2
#include <iostream>
#include <cstring>
#include "car.h"
using namespace std;
const char *Car::getMake()
{
return make;
}
const char *Car::getModel()
{
return model;
}
int Car::getYear()
{
return year;
}
void Car::setMake(const char *xmake)
{
if (make != NULL)
{
delete[] make;
}
make = new char[strlen(xmake) + 1];
strcpy(make, xmake);
}
void Car::setModel(const char *xmodel)
{
if (model != NULL)
{
delete[] model;
}
model = new char[strlen(xmodel) + 1];
strcpy(model, xmodel);
}
void Car::setYear(int xyear)
{
year = xyear;
}
void Car::print() const
{
cout << "Make: " << make << endl
<< "Model: " << model << endl
<< "Year: " << year << endl;
}
Car::Car()
{
make = new char[MAX_STR + 1];
strcpy(make, "<no value>");
model = new char[MAX_STR + 1];
strcpy(model, "<no value>");
year = 0;
}
Car::Car(const char *xmake, const char *xmodel, int xyear)
{
make = NULL;
setMake(xmake);
model = NULL;
setModel(xmodel);
year = xyear;
}
Car::~Car()
{
delete[] make;
delete[] model;
}
|
778c1b4216452f6301e6469f798fd9dab283c82d
|
72421c5016bd88e1457bc2573fcb14cf80da55ca
|
/src/planner/planner.cc
|
9b4a22cbe4d5dd282319a731c56d2a5d2485bdaa
|
[] |
no_license
|
jakeware/uwp
|
01a2f35bae5051e30a7959905e415bb8164c122c
|
2d1cfee259bbb03d802a7472df22bb4e53d272ab
|
refs/heads/master
| 2021-06-29T18:24:02.040147
| 2017-09-17T20:55:42
| 2017-09-17T20:55:42
| 103,861,136
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 36,269
|
cc
|
planner.cc
|
// Copyright 2015 Jake Ware
// c system includes
// cpp system includes
// external includes
// project includes
#include "planner/planner.h"
Planner::Planner(FlowData * W, App * app) {
if (!app->quiet && app->verbose) {
fprintf(stderr, "Starting planner...\n");
}
initMap(W, app);
if (!app->test_sg) {
// min planner bounds
app->pos_min = W->getXYZ(app->ixyz_min);
app->state_min.segment(0, 3) = app->pos_min;
app->state_min(3) = app->vel_g_min;
// max planner bounds
app->pos_max = W->getXYZ(app->ixyz_max);
app->state_max.segment(0, 3) = app->pos_max;
app->state_max(3) = app->vel_g_max;
// initialize start states
app->start_pos = app->start_state.segment(0, 3);
app->start_ixyz = W->getInd(app->start_pos);
// initialize goal states
app->goal_pos = app->goal_state.segment(0, 3);
app->goal_ixyz = W->getInd(app->goal_pos);
// discretizations
app->x_step = W->res;
app->y_step = W->res;
app->z_step = W->res;
getSteps(app);
getDState(app);
if (app->verbose) {
fprintf(stderr, "Start: x: %0.1f y: %0.1f z: %0.1f vel: %0.1f\n",
app->start_state(0), app->start_state(1), app->start_state(2),
app->start_state(3));
fprintf(stderr, "Goal1: x: %0.1f y: %0.1f z: %0.1f vel: %0.1f\n",
app->goal_state(0), app->goal_state(1), app->goal_state(2),
app->goal_state(3));
}
// node storage array
std::vector<std::vector<std::vector<Node*> > > N;
// initialize nodes
initNodes(&N, W, app);
// get graph
// TODO(jakeware): make this a param
SearchAS G(&N);
// SearchD G(&N);
if (!G.getGraph(W, app)) {
if (!app->quiet) {
fprintf(stderr, "Success: Found goal\n");
}
// find optimal path in graph
std::list<Node*> path;
getPath(&path, &N, W, app);
// find path given naive planner and dynamics constraints
if (app->vel_a_cap_flag && app->naive_flag) {
checkPath(&path, &N, W, app);
}
path_ = path;
// plot initial path
if (app->plot) {
plotPathEdgeVel(&path, "path", app);
plotPathNodePos(&path, "path", app);
}
// dump path to file
if (app->dump) {
// printPath(&path, app);
dumpPath(&path, "path", app);
}
// sample path
// std::list<Node*> path_samp;
// sampPathEnergy(&path, &path_samp, W, app);
// plot sampled path
if (app->plot) {
// plotPathEdgeVel(&path_samp, "path_samp", app);
// plotPathNodePos(&path_samp, "path_samp", app);
}
// dump path to file
if (app->dump) {
// dumpPath(&path_samp, "path_samp", app);
}
// std::list<Node*> path_samp_col;
// collisionCheckPath(&path, &path_samp, &path_samp_col, W, app);
// plot sampled path with collision checking
if (app->plot) {
// plotPathEdgeVel(&path_samp_col, "path_samp_col", app);
// plotPathNodePos(&path_samp_col, "path_samp_col", app);
}
// dump path to file
if (app->dump) {
// dumpPath(&path_samp_col, "path_samp_col", app);
}
// publish path to lcm
if (app->publish) {
// publishPath(&path, app);
}
} else {
fprintf(stderr, "Error: Could not find goal\n");
}
freeMem(&N, W, app);
}
}
Planner::~Planner() {
// Nothing
}
Eigen::VectorXd Planner::getSegmentTimes(std::list<Node*> * path,
std::list<Node*> * path_samp_col,
FlowData* W, App * app) {
if (!app->quiet && app->verbose) {
fprintf(stderr, "getSegmentTimes... ");
}
Eigen::VectorXd segment_times;
segment_times.setZero(path_samp_col->size() - 1);
// iterate over path_samp_col
for (std::list<Node*>::iterator it = ++path_samp_col->begin();
it != path_samp_col->end(); it++) {
int i = std::distance(path_samp_col->begin(), it) - 1;
std::list<Node*>::iterator it_last = it;
it_last--;
// find both it and it_last in path
std::list<Node*>::iterator it_tail;
std::list<Node*>::iterator it_tip;
for (std::list<Node*>::iterator it_path = path->begin();
it_path != path->end(); it_path++) {
// did we find the segment end node?
if ((*it_path)->ixyz == (*it)->ixyz) {
it_tip = it_path;
}
// did we find the segment start node?
if ((*it_path)->ixyz == (*it_last)->ixyz) {
it_tail = it_path;
}
}
// calculate the total distance
std::list<Node*>::iterator it_end = it_tip;
it_end++;
for (std::list<Node*>::iterator it_path = ++it_tail; it_path != it_end;
it_path++) {
std::list<Node*>::iterator it_path_last = it_path;
it_path_last--;
double dist = ((*it_path)->pos - (*it_path_last)->pos).norm();
double speed = (*it_path)->vel_g_mag;
segment_times(i) += dist / speed;
}
}
if (!app->quiet && app->verbose) {
fprintf(stderr, "Done\n");
}
return segment_times;
}
// QuadTrajectory * Planner::getQuadTraj(std::list<Node*> * path, App * app) {
// if (!app->quiet && app->verbose) {
// fprintf(stderr, "getQuadTraj... ");
// }
// // create QuadTrajectory
// QuadTrajectory * quad_traj = new QuadTrajectory(app->param, app->lcm);
// // time segments (taus)
// Eigen::VectorXd segment_times;
// segment_times.setZero(path->size() - 1);
// // derivatives at each path node
// std::list<Node*>::iterator it = path->begin();
// Eigen::VectorXd * start_state = new Eigen::VectorXd;
// start_state->setZero(20);
// (*start_state)(0) = (*it)->pos(0);
// (*start_state)(1) = (*it)->pos(1);
// (*start_state)(2) = (*it)->pos(2);
// (*start_state)(3) = 0.0;
// (*start_state)(4) = (*it)->vel_g(0);
// (*start_state)(5) = (*it)->vel_g(1);
// (*start_state)(6) = (*it)->vel_g(2);
// (*start_state)(7) = 0.0;
// quad_traj->vector_vert_list.push_back(start_state);
// // get segment times and derivatives
// for (std::list<Node*>::iterator it = ++path->begin(); it != path->end();
// it++) {
// int i = std::distance(++path->begin(), it);
// // get last node in path
// std::list<Node*>::iterator it_last = it;
// it_last--;
// // get taus
// double edge_dist = ((*it)->pos - (*it_last)->pos).norm();
// double vel_g_avg = ((*it)->vel_g_mag + (*it_last)->vel_g_mag) / 2.0;
// double edge_time = edge_dist / vel_g_avg;
// segment_times(i) = edge_time;
// // get yaw
// Eigen::Vector3f diff = ((*it)->pos - (*it_last)->pos).normalized();
// double psi = atan2(static_cast<double>(diff(1)),
// static_cast<double>(diff(0)));
// // get state (x, y, z, yaw, xdot, ydot, zdot, yawdot, xddot, ...)
// Eigen::VectorXd * state = new Eigen::VectorXd;
// state->setZero(20);
// (*state)(0) = (*it)->pos(0);
// (*state)(1) = (*it)->pos(1);
// (*state)(2) = (*it)->pos(2);
// (*state)(3) = psi;
// (*state)(4) = (*it)->vel_g(0);
// (*state)(5) = (*it)->vel_g(1);
// (*state)(6) = (*it)->vel_g(2);
// (*state)(7) = 0.0;
// quad_traj->vector_vert_list.push_back(state);
// }
// app->lstore["poly_path"];
// app->lstore["traj_axes"];
// app->lstore["vel_vec"];
// app->lstore["accel_vec"];
// app->lstore.switchAllBuffers();
// quad_traj->poly_path = app->lstore["poly_path"];
// quad_traj->traj_axes = app->lstore["traj_axes"];
// quad_traj->vel_vec = app->lstore["vel_vec"];
// quad_traj->accel_vec = app->lstore["accel_vec"];
// // TODO(jakeware): free state list memory
// if (!app->quiet && app->verbose) {
// fprintf(stderr, "Done\n");
// }
// return quad_traj;
// }
// QuadPath Planner::getQuadPath(std::list<Node*> * path, App * app) {
// if (!app->quiet && app->verbose) {
// fprintf(stderr, "getQuadPath... ");
// }
// // time segments (taus)
// Eigen::VectorXd segment_times;
// segment_times.setZero(path->size() - 1);
// // derivatives at each path node
// std::list<Eigen::VectorXd *> state_list;
// std::list<Node*>::iterator it = path->begin();
// Eigen::VectorXd * start_state = new Eigen::VectorXd;
// start_state->setZero(20);
// (*start_state)(0) = (*it)->pos(0);
// (*start_state)(1) = (*it)->pos(1);
// (*start_state)(2) = (*it)->pos(2);
// (*start_state)(3) = 0.0;
// (*start_state)(4) = (*it)->vel_g(0);
// (*start_state)(5) = (*it)->vel_g(1);
// (*start_state)(6) = (*it)->vel_g(2);
// (*start_state)(7) = 0.0;
// state_list.push_back(start_state);
// // get segment times and derivatives
// for (std::list<Node*>::iterator it = ++path->begin(); it != path->end();
// it++) {
// int i = std::distance(++path->begin(), it);
// // get last node in path
// std::list<Node*>::iterator it_last = it;
// it_last--;
// // get taus
// double edge_dist = ((*it)->pos - (*it_last)->pos).norm();
// double vel_g_avg = ((*it)->vel_g_mag + (*it_last)->vel_g_mag) / 2.0;
// double edge_time = edge_dist / vel_g_avg;
// segment_times(i) = edge_time;
// // get state (x, y, z, yaw, xdot, ydot, zdot, yawdot, xddot, ...)
// Eigen::Vector3f diff = ((*it)->pos - (*it_last)->pos).normalized();
// double psi = atan2(static_cast<double>(diff(1)),
// static_cast<double>(diff(0)));
// Eigen::VectorXd * state = new Eigen::VectorXd;
// state->setZero(20);
// (*state)(0) = (*it)->pos(0);
// (*state)(1) = (*it)->pos(1);
// (*state)(2) = (*it)->pos(2);
// (*state)(3) = psi;
// (*state)(4) = (*it)->vel_g(0);
// (*state)(5) = (*it)->vel_g(1);
// (*state)(6) = (*it)->vel_g(2);
// (*state)(7) = 0.0;
// state_list.push_back(state);
// }
// QuadPath quad_path(state_list, segment_times);
// // quad_path.segment_times = quad_path.getSegmentTimes();
// quad_path.segment_times = segment_times;
// // free memory
// for (std::list<Eigen::VectorXd *>::iterator it = state_list.begin();
// it != state_list.end(); it++) {
// free(*it);
// }
// if (!app->quiet && app->verbose) {
// fprintf(stderr, "Done\n");
// }
// return quad_path;
// }
void Planner::sampPathSimple(std::list<Node*> * path,
std::list<Node*> * samp_path, App * app) {
if (!app->quiet && app->verbose) {
fprintf(stderr, "sampPathSimple... ");
}
// create array to mark nodes for removal
Eigen::VectorXi remove;
remove.setZero(path->size());
// iterate over path and mark for removal
for (std::list<Node*>::iterator it = ++path->begin(); it != path->end();
it++) {
if (((*it)->vel_g - (*it)->parent->vel_g).norm() == 0) {
remove(std::distance(path->begin(), it)) = 1;
}
}
fprintf(stderr, "path size: %lu\n", path->size());
// iterate over path and copy selected nodes
for (std::list<Node*>::iterator it = path->begin(); it != path->end(); it++) {
if (!remove(std::distance(path->begin(), it))) {
samp_path->push_back(*it);
}
}
fprintf(stderr, "samp_path size: %lu\n", samp_path->size());
if (!app->quiet && app->verbose) {
fprintf(stderr, "Done\n");
}
return;
}
void Planner::collisionCheckPath(std::list<Node*> * path,
std::list<Node*> * samp_path,
std::list<Node*> * samp_path_col, FlowData * W,
App * app) {
if (!app->quiet && app->verbose) {
fprintf(stderr, "collisionCheckPath... ");
}
// add start node
std::list<Node*>::iterator it_start = samp_path->begin();
samp_path_col->push_back(*it_start);
// iterate over list looking for collision
for (std::list<Node*>::iterator it = ++samp_path->begin();
it != samp_path->end(); it++) {
// fprintf(stderr, "node: %lu\n", std::distance(samp_path->begin(), it));
std::list<Node*>::iterator it_last = it;
it_last--;
bool collision = collisionCheck((*it_last)->pos, (*it)->pos, false, W, app);
// did we get a collision?
if (collision) {
// plotEdge((*it_last)->pos, (*it)->pos, "collision");
// find first edge node in original path
std::list<Node*>::iterator it_tail;
for (std::list<Node*>::iterator it_path = ++path->begin();
it_path != path->end(); it_path++) {
if ((*it_last)->state == (*it_path)->state) {
it_tail = it_path;
break;
}
}
// look for first collision point between it_tail and it_tip
std::list<Node*>::iterator it_tip = it_tail;
it_tip++;
// Note: compare indices because iterators are from different paths
while ((*it_tip)->ixyz != (*it)->ixyz) {
// collision check
bool collision_test = collisionCheck((*it_tail)->pos, (*it_tip)->pos,
false, W, app);
if (collision_test) {
it_tail = it_tip;
it_tail--;
samp_path_col->push_back(*it_tail);
} else {
it_tip++;
}
// std::cin.get();
}
samp_path_col->push_back(*it);
} else {
// no collision, push node
samp_path_col->push_back(*it);
}
}
fprintf(stderr, "samp_path_col size: %lu\n", samp_path_col->size());
if (!app->quiet && app->verbose) {
fprintf(stderr, "Done\n");
}
return;
}
bool Planner::collisionCheck(Eigen::Vector3f pos1, Eigen::Vector3f pos2,
bool debug, FlowData * W, App * app) {
Eigen::Vector3f dir = (pos2 - pos1).normalized();
float step_size = 0.1; // [m]
float total_dist = (pos2 - pos1).norm();
int steps = ceil(total_dist / step_size);
float current_dist = 0.0;
float last_dist = 0.0;
bool collision = false;
for (int i = 1; i <= steps; i++) {
// get current time
last_dist = current_dist;
current_dist = static_cast<float>(i) * step_size;
// check if time is greater than total time
if (current_dist > total_dist) {
// fprintf(stderr, "total time:%f\n", total_time);
current_dist = total_dist;
}
// get current state
Eigen::Vector3f pos = pos1 + current_dist * dir;
// get index
Eigen::Vector3i ixyz = W->getInd(pos);
// check for collision
if (W->getObs3D(ixyz) > 0) {
collision = true;
}
if (debug) {
plotPos(pos, "step", app);
std::cin.get();
}
}
return collision;
}
double Planner::getEnergyDelta(Eigen::Vector4f state1, Eigen::Vector4f state2,
float dt, bool debug, FlowData * W, App * app) {
Eigen::Vector3f pos1 = state1.segment(0, 3);
Eigen::Vector3f pos2 = state2.segment(0, 3);
float vel_g_mag = state2(3);
Eigen::Vector3f dir = (pos2 - pos1).normalized();
Eigen::Vector3f vel_g = dir * vel_g_mag;
double total_dist = (pos2 - pos1).norm();
double total_time = total_dist / vel_g_mag;
int steps = ceil(total_time / dt);
float total_energy = 0.0;
float current_time = 0.0;
float last_time = 0.0;
float energy_sto = 0.0;
float vel_a_mag = 0.0;
for (int i = 1; i <= steps; i++) {
// get current time
last_time = current_time;
current_time = static_cast<float>(i) * dt;
// check if time is greater than total time
if (current_time > total_time) {
// fprintf(stderr, "total time:%f\n", total_time);
current_time = total_time;
}
// get current state
Eigen::Vector3f pos = pos1 + current_time * vel_g;
// get index
Eigen::Vector3i ixyz = W->getInd(pos);
// get wind at state2
Eigen::Vector3f vel_f = W->getUVW(ixyz);
// get air speed
Eigen::Vector3f vel_a = vel_g - vel_f;
vel_a_mag = vel_a.norm();
// get stored energy
energy_sto = app->pow_prof(0) * powf(vel_a_mag, 4)
+ app->pow_prof(1) * powf(vel_a_mag, 3)
+ app->pow_prof(2) * powf(vel_a_mag, 2) + app->pow_prof(3) * vel_a_mag
+ app->pow_prof(4);
energy_sto *= current_time - last_time;
total_energy += energy_sto;
if (debug) {
fprintf(stderr, "i:%i\n", i);
fprintf(stderr, "current time:%f\n", current_time);
plotPos(pos, "step", app);
eigen_dump(ixyz);
eigen_dump(vel_f);
eigen_dump(vel_a_mag);
std::cin.get();
}
}
// get potential energy
double energy_pot = (pos2(3) - pos1(3)) * app->mass * app->g;
total_energy += energy_pot;
return total_energy;
}
void Planner::sampPathEnergy(std::list<Node*> * path,
std::list<Node*> * samp_path, FlowData * W,
App * app) {
if (!app->quiet && app->verbose) {
fprintf(stderr, "sampPathEnergy... ");
}
fprintf(stderr, "\npath size: %lu\n", path->size());
// print total energy consumption for original path
std::list<Node*>::iterator it = --path->end();
fprintf(stderr, "path_total_energy:%f\n", (*it)->g);
// create array to mark nodes for removal
Eigen::VectorXi remove;
remove.setZero(path->size());
// energy ratio threshold
double energy_ratio_threshold = 0.02;
// iterate over path and mark for removal
std::list<Node*>::iterator it_tail = path->begin();
std::list<Node*>::iterator it_tip = ++path->begin();
std::list<Node*>::iterator it_tip_last;
// iterate over path
int count = 0;
float total_energy = 0.0;
while (it_tip != path->end()) {
// get energy from original path between tail and tip
double energy_diff_orig = (*it_tip)->g - (*it_tail)->g;
// integrate energy between tail and tip with new velocity
double energy_diff = getEnergyDelta((*it_tail)->state, (*it_tip)->state,
0.1, false, W, app);
double energy_ratio = fabs(energy_diff - energy_diff_orig)
/ energy_diff_orig;
// check difference in energy
// TODO(jakeware): fix potential infinite loop here if can't meet constraint
if (energy_ratio > energy_ratio_threshold) {
// check to see if we are stuck in a single step
if (std::distance(it_tail, it_tip) < 2) {
fprintf(stderr, "Stuck on single step. Relaxing. Energy ratio: %f\n",
energy_ratio);
eigen_dump(energy_diff_orig);
eigen_dump(energy_diff);
double temp = getEnergyDelta((*it_tail)->state, (*it_tip_last)->state,
0.1, true, W, app);
fprintf(stderr, "return\n");
plotPos((*it_tail)->pos, "tail", app);
plotEdge((*it_tail)->pos, (*it_tip)->pos, "tail2tip", app);
Eigen::Vector3i ixyz_tail = W->getInd((*it_tail)->pos);
Eigen::Vector3i ixyz_tip = W->getInd((*it_tip)->pos);
plotPos(W->getXYZ(ixyz_tail), "tail_test", app);
plotPos(W->getXYZ(ixyz_tip), "tip_test", app);
std::cin.get();
energy_ratio_threshold = 0.05;
}
// mark tip node for retention
remove(std::distance(path->begin(), it_tip)) = 0;
// get last tip node
it_tip_last = it_tip;
it_tip_last--;
total_energy += getEnergyDelta((*it_tail)->state, (*it_tip_last)->state,
0.1, false, W, app);
// plotEdgePos((*it_tail)->pos, (*it_tip_last)->pos);
// mark previous node for retention
remove(std::distance(path->begin(), it_tip_last)) = 0;
// move tail to last tip
it_tail = it_tip_last;
} else {
// reset threshold
energy_ratio_threshold = 0.02;
// mark node for removal
remove(std::distance(path->begin(), it_tip)) = 1;
// increment tip
it_tip++;
}
// std::cin.get();
count++;
}
// add energy from final segment
it_tip_last = it_tip;
it_tip_last--;
total_energy += getEnergyDelta((*it_tail)->state, (*it_tip_last)->state, 0.1,
false, W, app);
// plotEdgePos((*it_tail)->pos, (*it_tip_last)->pos);
// keep goal
remove(path->size() - 1) = 0;
// eigen_dump(remove);
// iterate over path and copy selected nodes (ignore cost)
// push start node
std::list<Node*>::iterator it_start = path->begin();
Node * n_start = createNode((*it_start)->parent, (*it_start)->ixyz,
(*it_start)->vel_g_mag, W, app);
samp_path->push_back(n_start);
for (std::list<Node*>::iterator it = ++path->begin(); it != path->end();
it++) {
// fprintf(stderr, "i:%lu\n", std::distance(path->begin(), it));
if (!remove(std::distance(path->begin(), it))) {
// eigen_dump((*it)->ixyz);
// eigen_dump((*it)->vel_g_mag);
std::list<Node*>::iterator it_last = --samp_path->end();
// create new node
Node * n = createNode((*it_last), (*it)->ixyz, (*it)->vel_g_mag, W, app);
samp_path->push_back(n);
}
}
fprintf(stderr, "samp_path size: %lu\n", samp_path->size());
fprintf(stderr, "samp_path_total_energy:%f\n", total_energy);
if (!app->quiet && app->verbose) {
fprintf(stderr, "Done\n");
}
return;
}
int Planner::checkDynamics(Node * n, Node * parent, FlowData* W, App * app) {
// check air velocity
if (n->getVelAMagTrue(parent, W) > app->vel_a_max && app->vel_a_cap_flag
&& app->naive_flag) {
return 0;
}
return 1;
}
void Planner::checkPath(std::list<Node*> * path,
std::vector<std::vector<std::vector<Node*> > > * N,
FlowData * W, App * app) {
// fprintf(stderr, "checkPath\n");
Node* n = *(path->begin());
// loop over path from start + 1 to goal
int count = 1;
bool fail = false;
bool once = true;
for (std::list<Node*>::iterator it = ++path->begin(); it != path->end();
it++) {
// fprintf(stderr, "i: %i\n", count++);
(*it)->parent = n;
(*it)->setNode(n, W, app);
// check air speed
int valid = checkDynamics((*it), (*it)->parent, W, app);
// if valid, assign and move on
if (valid) {
n = (*it);
} else { // otherwise decrement ground speed
// reduce air speed until valid or return failure
Eigen::Vector3i ind = getNodeInd((*it)->state, app);
while (!valid) {
// fprintf(stderr, "not valid\n");
// check if ground speed can be lowered
if (ind(2) > 0) {
// decrement ground speed
ind(2) = ind(2) - 1;
n = (*N)[ind(0)][ind(1)][ind(2)];
// check validity
valid = checkDynamics(n, (*it)->parent, W, app);
} else {
if (once) {
once = false;
fprintf(
stderr,
"Warning: checkPath found an infeasible naive trajectory\n");
}
fail = true;
valid = 1;
}
}
// assign new node
n->parent = (*it)->parent;
n->setNode((*it)->parent, W, app);
}
(*it) = n;
// has a past node failed already?
if (fail) {
n->g_true = std::numeric_limits<double>::infinity();
}
}
return;
}
void Planner::initMap(FlowData * W, App * app) {
// get start pos and index
app->start_pos = app->start_state.segment(0, 3);
app->start_ixyz = W->getInd(app->start_pos);
// check if start_pos is valid
// TODO(jakeware): fix segfault that occurs after this is done
Eigen::Vector3f start_pos_test = Eigen::Vector3f::Zero();
start_pos_test = W->getXYZ(app->start_ixyz);
if (app->start_pos != start_pos_test) {
fprintf(stderr, "Warning: Invalid start_pos not on grid.\n");
app->start_pos = start_pos_test;
fprintf(stderr, "Resetting to: %f, %f, %f\n", app->start_pos(0),
app->start_pos(1), app->start_pos(2));
}
// get goal pos and index
app->goal_pos = app->goal_state.segment(0, 3);
app->goal_ixyz = W->getInd(app->goal_pos);
// check if goal_pos is valid
Eigen::Vector3f goal_pos_test = Eigen::Vector3f::Zero();
goal_pos_test = W->getXYZ(app->goal_ixyz);
if (app->goal_pos != goal_pos_test) {
fprintf(stderr, "Warning: Invalid goal_pos not on grid.\n");
app->goal_pos = goal_pos_test;
fprintf(stderr, "Resetting to: %f, %f, %f\n", app->goal_pos(0),
app->goal_pos(1), app->goal_pos(2));
}
// check if start and goal locations are in obstacle space
if (W->getObs3D(app->start_ixyz)) {
fprintf(stderr, "Start Location in Obstacle Space\n");
}
if (W->getObs3D(app->goal_ixyz)) {
fprintf(stderr, "Goal Location in Obstacle Space\n");
}
// plotting
if (app->plot) {
plotSG(app->start_state.segment(0, 3), app->goal_state.segment(0, 3));
plotBounds(W->getXYZ(app->ixyz_min), W->getXYZ(app->ixyz_max), app);
}
// check bounds
if (W->checkMapBounds(app->ixyz_min)) {
fprintf(stderr, "Error: Invalid min bounds. Using map min bound.\n");
app->ixyz_min = W->ixyz_min;
}
if (W->checkMapBounds(app->ixyz_max)) {
fprintf(stderr, "Error: Invalid max bounds. Using map max bound.\n");
app->ixyz_max = W->ixyz_max;
}
return;
}
void Planner::freeMem(std::vector<std::vector<std::vector<Node*> > > * N,
FlowData* W, App * app) {
// nodes
// x
for (int i = 0; i < app->x_steps.rows(); i++) {
// y
for (int j = 0; j < app->y_steps.rows(); j++) {
// vel
for (int k = 0; k < app->vel_g_steps.rows(); k++) {
Eigen::Vector3i ixyz = Eigen::Vector3i::Zero();
ixyz(0) = app->x_steps(i);
ixyz(1) = app->y_steps(j);
ixyz(2) = app->start_ixyz(2);
// don't create node if in obstacle space
if (W->getObs3D(ixyz)) {
continue;
}
delete (*N)[i][j][k];
}
}
}
return;
}
int Planner::checkPlannerBounds(Eigen::Vector3i ixyz, FlowData * W, App * app) {
int ret = 0;
// loop over indicies
for (int i = 0; i < 3; i++) {
if (ixyz(i) < app->ixyz_min(i) || ixyz(i) > app->ixyz_max(i)) {
ret = 1;
}
}
if (W->checkMapBounds(ixyz)) {
ret = 1;
}
return ret;
}
Node* Planner::createNode(Node* parent, const Eigen::Vector3i ixyz,
const double vel_g_mag, FlowData* W, App* app) {
Node* n = new Node(parent, ixyz, vel_g_mag, W, app);
return n;
}
Eigen::Vector3i Planner::getNodeInd(const Eigen::Vector4f state, App * app) {
Eigen::Vector3i ind = Eigen::Vector3i::Zero();
ind(0) = (state(0) - app->state_min(0)) / app->x_step;
ind(1) = (state(1) - app->state_min(1)) / app->y_step;
ind(2) = (state(3) - app->state_min(3)) / app->vel_g_step;
return ind;
}
void Planner::getDState(App * app) {
app->d_pos.setZero(3, 8);
app->d_pos.col(0) << 1, 0, 0; // forward
app->d_pos.col(1) << -1, 0, 0; // backward
app->d_pos.col(2) << 0, 1, 0; // right
app->d_pos.col(3) << 0, -1, 0; // left
app->d_pos.col(4) << 1, 1, 0; // forward-right
app->d_pos.col(5) << 1, -1, 0; // forward-left
app->d_pos.col(6) << -1, 1, 0; // backward-right
app->d_pos.col(7) << -1, -1, 0; // backward-left
app->d_speed.setZero(3);
app->d_speed << -0.5, 0, 0.5; // possible speed deltas
// x,y
// d_state.setZero(4, d_pos.cols());
// for (int i = 0; i < d_pos.cols(); i++) {
// d_state.col(i).segment(0, 3) = d_pos.col(i);
// d_state(3, i) = 0;
// }
// x,y,vel
app->d_state.setZero(4, app->d_pos.cols() * app->d_speed.rows());
for (int i = 0; i < app->d_pos.cols(); i++) {
for (int j = 0; j < app->d_speed.rows(); j++) {
app->d_state.col(i * app->d_speed.rows() + j).segment(0, 3) = app->d_pos
.col(i);
app->d_state(3, i * app->d_speed.rows() + j) = app->d_speed(j);
}
}
// eigen_dump(d_state);
// fprintf(stderr, "d_state: %lu\n", d_state.cols());
return;
}
void Planner::getSteps(App * app) {
// x
int x_size = (app->ixyz_max(0) - app->ixyz_min(0)) / app->x_step;
app->x_steps.setZero(x_size + 1);
for (int i = 0; i < app->x_steps.rows(); i++) {
app->x_steps(i) = app->ixyz_min(0) + i * app->x_step;
}
// y
int y_size = (app->ixyz_max(1) - app->ixyz_min(1)) / app->y_step;
app->y_steps.setZero(y_size + 1);
for (int i = 0; i < app->y_steps.rows(); i++) {
app->y_steps(i) = app->ixyz_min(1) + i * app->y_step;
}
// z
int z_size = (app->ixyz_max(2) - app->ixyz_min(2)) / app->z_step;
app->z_steps.setZero(z_size + 1);
for (int i = 0; i < app->z_steps.rows(); i++) {
app->z_steps(i) = app->ixyz_min(2) + i * app->z_step;
}
// vel
int vel_size = (app->vel_g_max - app->vel_g_min) / app->vel_g_step;
app->vel_g_steps.setZero(vel_size + 1);
for (int i = 0; i < app->vel_g_steps.rows(); i++) {
app->vel_g_steps(i) = app->vel_g_min + i * app->vel_g_step;
}
return;
}
void Planner::initNodes(std::vector<std::vector<std::vector<Node*> > > * N,
FlowData* W, App* app) {
if (!app->quiet && app->verbose) {
fprintf(stderr, "initNodes... ");
}
// init node array
(*N).resize(app->x_steps.rows());
for (int i = 0; i < app->x_steps.rows(); ++i) {
(*N)[i].resize(app->y_steps.rows());
for (int j = 0; j < app->y_steps.rows(); ++j)
(*N)[i][j].resize(app->vel_g_steps.rows());
}
// eigen_dump(z_steps);
// fprintf(stderr, "z: %i\n", z_steps(start_ixyz(2)));
Eigen::Vector3i ixyz = Eigen::Vector3i::Zero();
double speed = 0;
int node_count = 0;
// x
for (int i = 0; i < app->x_steps.rows(); i++) {
// y
for (int j = 0; j < app->y_steps.rows(); j++) {
// vel
for (int k = 0; k < app->vel_g_steps.rows(); k++) {
ixyz(0) = app->x_steps(i);
ixyz(1) = app->y_steps(j);
ixyz(2) = app->start_ixyz(2);
speed = app->vel_g_steps(k);
// don't create node if in obstacle space
if (W->getObs3D(ixyz)) {
continue;
}
node_count++;
Node* n = createNode(NULL, ixyz, speed, W, app);
n->g = std::numeric_limits<double>::infinity();
n->dist = std::numeric_limits<double>::infinity();
n->energy = std::numeric_limits<double>::infinity();
n->energy_sto = std::numeric_limits<double>::infinity();
n->energy_pot = std::numeric_limits<double>::infinity();
(*N)[i][j][k] = n;
// Q.push(n);
}
}
}
// fprintf(stderr, "Total Nodes: %i\n", node_count);
if (!app->quiet && app->verbose) {
fprintf(stderr, "Done\n");
}
return;
}
void Planner::getPath(std::list<Node*> * path,
std::vector<std::vector<std::vector<Node*> > > * N,
FlowData* W, App* app) {
if (!app->quiet && app->verbose) {
fprintf(stderr, "Getting path... ");
}
// reset start node
Eigen::Vector3i start_ind = getNodeInd(app->start_state, app);
Node* n_start = (*N)[start_ind(0)][start_ind(1)][start_ind(2)];
n_start->parent = NULL;
n_start->g = 0;
// get goal node
Eigen::Vector3i goal_ind = getNodeInd(app->goal_state, app);
Node* n = (*N)[goal_ind(0)][goal_ind(1)][goal_ind(2)];
while (n != NULL) {
// n->print();
path->push_front(n);
n = n->parent;
if (n->state == app->start_state) {
path->push_front(n);
break;
}
}
// fprintf(stderr, "path size: %lu\n", P.size());
if (!app->quiet && app->verbose) {
fprintf(stderr, "Done\n");
}
return;
}
void Planner::printPath(std::list<Node*> * path, App * app) {
std::list<Node*>::iterator it = --path->end();
fprintf(stderr, "Total Path Energy: %f\n", (*it)->energy_true);
fprintf(stderr, "Total Path Length: %f\n", (*it)->dist);
return;
}
void Planner::dumpPath(std::list<Node*> * path, std::string path_name,
App * app) {
Eigen::MatrixXd dump;
dump.setZero(path->size(), 22);
int i = 0;
for (std::list<Node*>::iterator it = path->begin(); it != path->end(); it++) {
if (!app->naive_flag) {
// 3 vectors
for (int j = 0; j < 3; j++) {
dump(i, j) = (*it)->ixyz(j);
dump(i, j + 3) = (*it)->pos(j);
dump(i, j + 6) = (*it)->vel_f(j);
dump(i, j + 9) = (*it)->vel_g(j);
dump(i, j + 12) = (*it)->vel_a(j);
}
// cost terms
dump(i, 15) = (*it)->vel_a_mag;
dump(i, 16) = (*it)->vel_g_mag;
dump(i, 17) = (*it)->energy_pot;
dump(i, 18) = (*it)->energy_sto;
dump(i, 19) = (*it)->energy;
dump(i, 20) = (*it)->dist;
dump(i, 21) = (*it)->g;
} else {
// 3 vectors
for (int j = 0; j < 3; j++) {
dump(i, j) = (*it)->ixyz(j);
dump(i, j + 3) = (*it)->pos(j);
dump(i, j + 6) = (*it)->vel_f(j);
dump(i, j + 9) = (*it)->vel_g(j);
dump(i, j + 12) = (*it)->vel_a_true(j);
}
// cost terms
dump(i, 15) = (*it)->vel_a_mag_true;
dump(i, 16) = (*it)->vel_g_mag;
dump(i, 17) = (*it)->energy_pot_true;
dump(i, 18) = (*it)->energy_sto_true;
dump(i, 19) = (*it)->energy_true;
dump(i, 20) = (*it)->dist;
dump(i, 21) = (*it)->g_true;
}
i++;
}
std::ofstream myfile;
char path_num_cstr[6];
snprintf(path_num_cstr, sizeof(path_num_cstr), "%05i", app->path_num);
std::string wind_str = "data";
if (app->filename_flag) {
int start_ind = app->filename.find("/", 32) + 1;
int end_ind = app->filename.find("/", start_ind);
// fprintf(stderr, "start_ind: %i\n", start_ind);
// fprintf(stderr, "end_ind: %i\n", end_ind);
// fprintf(stderr, "%s\n",
// app->filename.substr(start_ind, end_ind-start_ind).c_str());
wind_str = app->filename.substr(start_ind, end_ind - start_ind);
}
char naive_flag_cstr[5];
snprintf(naive_flag_cstr, sizeof(naive_flag_cstr), "%i", !app->naive_flag);
char vela_flag_cstr[5];
snprintf(vela_flag_cstr, sizeof(vela_flag_cstr), "%i", app->vel_a_cap_flag);
std::string filename = wind_str + "_w"
+ std::string(naive_flag_cstr) + "_a" + std::string(vela_flag_cstr) + "_"
+ std::string(path_num_cstr) + ".m";
std::cout << filename + "\n";
myfile.open(filename.c_str());
myfile << "path" << "=[" << (dump) << "];\n";
myfile.close();
// eigen_matlab_dump(dump);
return;
}
// void Planner::publishPath(std::list<Node*> * path, App * app) {
// srand(time(NULL));
// quad_waypoint_list_t list_msg;
// list_msg.utime = bot_timestamp_now();
// list_msg.num_waypoints = path->size() + 1;
// list_msg.waypoints = new quad_waypoint_t[path->size() + 1];
// double psi = 0; // heading
// double psi_last = 0;
// Eigen::Vector3f pos_last = Eigen::Vector3f::Zero();
// for (std::list<Node*>::iterator it = path->begin(); it != path->end(); it++) {
// Eigen::Vector3f diff = ((*it)->pos - pos_last).normalized();
// psi = atan2(static_cast<double>(diff(1)), static_cast<double>(diff(0)));
// quad_waypoint_t waypoint_msg;
// waypoint_msg.utime = bot_timestamp_now();
// waypoint_msg.xyzt[0] = (*it)->pos(0) - app->start_pos(0);
// waypoint_msg.xyzt[1] = (*it)->pos(1) - app->start_pos(1);
// waypoint_msg.xyzt[2] = (*it)->pos(2);
// waypoint_msg.xyzt[3] = psi;
// waypoint_msg.xyzt_dot[0] = (*it)->vel_g(0);
// waypoint_msg.xyzt_dot[1] = (*it)->vel_g(1);
// waypoint_msg.xyzt_dot[2] = (*it)->vel_g(2);
// waypoint_msg.xyzt_dot[3] = 0;
// waypoint_msg.waypt_type = QUAD_WAYPOINT_T_TYPE_WAYPT;
// waypoint_msg.sender = QUAD_WAYPOINT_T_SENDER_MISSION_PLANNER;
// waypoint_msg.nonce = rand_r(&app->seed);
// list_msg.waypoints[distance(path->begin(), it)] = waypoint_msg;
// pos_last = (*it)->pos;
// psi_last = psi;
// }
// // append zero velocity waypoint at goal
// quad_waypoint_t waypoint_msg;
// waypoint_msg.utime = bot_timestamp_now();
// waypoint_msg.xyzt[0] = pos_last(0) - app->start_pos(0);
// waypoint_msg.xyzt[1] = pos_last(1) - app->start_pos(1);
// waypoint_msg.xyzt[2] = pos_last(2);
// waypoint_msg.xyzt[3] = psi_last;
// waypoint_msg.xyzt_dot[0] = 0;
// waypoint_msg.xyzt_dot[1] = 0;
// waypoint_msg.xyzt_dot[2] = 0;
// waypoint_msg.xyzt_dot[3] = 0;
// waypoint_msg.waypt_type = QUAD_WAYPOINT_T_TYPE_WAYPT;
// waypoint_msg.sender = QUAD_WAYPOINT_T_SENDER_MISSION_PLANNER;
// waypoint_msg.nonce = rand_r(&app->seed);
// list_msg.waypoints[path->size()] = waypoint_msg;
// quad_waypoint_list_t_publish(app->lcm, "PLANNED_WAYPOINTS", &list_msg);
// delete list_msg.waypoints;
// return;
// }
|
73de906dd2e9bd726441900812002772b54d0b49
|
d619b3a4bd27f4b2af552490fa4d5af07e4d6514
|
/src/codigo/TP taller/TP taller/Parser/yaml/ParserYaml.h
|
6756b44ae255466a15b6be2db2e6079bd023c549
|
[] |
no_license
|
matiduarte/tp-taller-dkt
|
1a54cc0a701590dd555c0534479a82209521f694
|
cb54ca800c01c7a3347f306a6f324c48504ed0bd
|
refs/heads/master
| 2020-05-16T01:57:01.919564
| 2014-06-20T19:50:02
| 2014-06-20T19:50:02
| 32,113,268
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,011
|
h
|
ParserYaml.h
|
#ifndef __YAMLPARSER_H__
#define __YAMLPARSER_H__
#include "yaml-cpp/yaml.h"
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <valarray>
#include <algorithm>
#include "../../constantes.h"
#include "../../Logger/Logger.h"
#include <time.h>
#include<windows.h>
using namespace std;
struct EscenarioParseado{
double altoPx;
double anchoPx;
double altoU;
double anchoU;
int nivelAgua;
int maximosClientes;
string imagenTierra;
string imagenCielo;
};
struct ObjetoParseado{
int tipo;
int x;
int y;
int ancho;
int alto;
float escala;
string color;
int rotacion;
int masa;
bool estatico;
int linea;
};
class ParserYaml
{
private:
static ParserYaml* parserInstancia;
static string nombreArchivo;
YAML::Node documento;
static EscenarioParseado* escenario;
static vector<ObjetoParseado>* objetos;
bool ParserYaml::esEntero(const std::string& s);
bool ParserYaml::esFloat(const std::string& s);
string getNodoInfo(const YAML::Node & nodo);
int validarMayorA(int valor, int limite, string nodo);
int validarMenorA(int valor, int limite, string nodo);
int getValorEscalar(const YAML::Node & nodo, string clave, const int valorPorDefecto);
float getValorFloat(const YAML::Node & nodo, string clave, const float valorPorDefecto);
string getValorCadena(const YAML::Node & nodo, string clave, string valorPorDefecto);
bool getValorBool(const YAML::Node & nodo, string clave, bool valorPorDefecto);
string getValorColor(const YAML::Node & nodo, string clave, string valorPorDefecto);
int getValorTipoObjeto(const YAML::Node & nodo, string clave, int valorPorDefecto);
vector<ObjetoParseado>* getValorSecuencia(const YAML::Node & nodo, string clave);
bool ParserYaml::validarEscalar(const YAML::Node & nodo, string clave, int &valor);
bool ParserYaml::validarFloat(const YAML::Node & nodo, string clave, float &valor);
bool ParserYaml::validarSecuencia(const YAML::Node &nodo, string clave);
bool ParserYaml::validarCadena(const YAML::Node &nodo, string clave, string &cadena);
bool ParserYaml::validarImagen(string path);
EscenarioParseado* parsearEscenario();
EscenarioParseado* getEscenarioDefault();
vector<ObjetoParseado>* ParserYaml::parsearObjetos();
ObjetoParseado parsearObjeto(const YAML::Node &nodo);
vector<ObjetoParseado>* ParserYaml::getObjetosDefault();
ObjetoParseado ParserYaml::getObjetoDefault();
string crearConfigDefault();
string getTipoStringByTipo(int tipo);
//devuelve una posicion random dentro del escenario.
int getPosRandom(int porcentaje_min, int porcentaje_max, char eje);
public:
ParserYaml(std::string pathArchivo);
ParserYaml();
void parsear();
static ParserYaml* getParser();
//Tiene que devolver el escenario
EscenarioParseado* getEscenario();
vector<ObjetoParseado>* getObjetos();
static void setConfigPath(char* path);
static string getConfigPath();
};
#endif
|
d3578120ee058a3a0024e28b5c927490a0314455
|
a6bfdf4d2dd1ea4ae285215c651c2b64479b6b6a
|
/include/boost/simd/function/interleave_odd.hpp
|
13e19ce0852925f0a2ed07f7a8103fa1a84aa729
|
[
"BSL-1.0"
] |
permissive
|
jeffamstutz/boost.simd
|
fb62210c30680c3cb2ffcc8ed80f8a0050f675fd
|
8afe9673c2a806976a77bc8bbca4cb1116a710cb
|
refs/heads/develop
| 2021-01-13T04:06:02.762442
| 2017-01-05T02:56:52
| 2017-01-06T16:11:47
| 77,879,665
| 6
| 1
| null | 2017-01-03T03:08:57
| 2017-01-03T03:08:57
| null |
UTF-8
|
C++
| false
| false
| 1,124
|
hpp
|
interleave_odd.hpp
|
//==================================================================================================
/**
Copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
**/
//==================================================================================================
#ifndef BOOST_SIMD_FUNCTION_INTERLEAVE_ODD_HPP_INCLUDED
#define BOOST_SIMD_FUNCTION_INTERLEAVE_ODD_HPP_INCLUDED
namespace boost { namespace simd
{
#if defined(DOXYGEN_ONLY)
/**
@ingroup group-swar
Function object implementing interleave_odd capabilities
Computes a vector from a combination of the two inputs.
@par Semantic:
For every parameters of types respectively T
@code
T r = interleave_odd(x, y);
@endcode
is equivalent to :
@code
r = [ x[1] y[1] x[3] y[3] ... x[n/2+1] y[n/2+1] ]
@endcode
with <tt> n = cardinal_of<T>::value </tt>
**/
Value interleave_odd(Value const& v0, Value const& v1);
#endif
} }
#include <boost/simd/function/simd/interleave_odd.hpp>
#endif
|
8e9b7c9b511f715cf7cffee50d2bd56c1669edb2
|
cbcba10c1d313c909297d875a1a1621d07b35d78
|
/11Jan2020/demo2.cpp
|
37110e099be4f1fe3875d4fdf9129cda89658595
|
[] |
no_license
|
vikrant911998/CPP_batch_dec
|
1faf7f48b6a5fd741de3ab092b2be5085dbe8a92
|
3c90c6946869d29a5fb6c3afd5aa901b2b718a2c
|
refs/heads/master
| 2020-12-02T03:11:24.246083
| 2020-02-23T08:59:15
| 2020-02-23T08:59:15
| 230,867,869
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 543
|
cpp
|
demo2.cpp
|
#include<iostream>
using namespace std;
class SimpleInterest{
int principal;
float rate;
int time;
float simple;
public:
void input(){
cout<<"Enter the principal ,rate, time"<<endl;
cin>>principal>>rate>>time;
}
void si(){
simple = (principal*rate*time)/100;
}
float getSimple(){
return simple;
}
};
int main(){
SimpleInterest obj;
obj.input();
obj.si();
obj.getSimple()*5;
return 0;
}
|
7ba18c08e143331da552f2706890a98c4713f78a
|
b2a7f5eb3e404aa867b6cf9bb2c68f1324abc2c3
|
/Simulado 02/Exer 1.2.cpp
|
0200284d263b4210e103ccd863231639b868fdda
|
[] |
no_license
|
Scrowszinho/C
|
34ee7d1cacf64dd267529ce7db44f67cd2fab528
|
60fe7a8938075cd4170548e569785fdd1e354914
|
refs/heads/master
| 2021-07-16T04:37:27.738950
| 2020-10-19T13:56:48
| 2020-10-19T13:56:48
| 218,769,109
| 4
| 1
| null | 2020-10-19T13:56:49
| 2019-10-31T13:11:16
|
C++
|
ISO-8859-1
|
C++
| false
| false
| 589
|
cpp
|
Exer 1.2.cpp
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include<locale.h>
main() {
setlocale(LC_ALL,"");
int i, b = 0,c;
float o1 = 0,o2 = 0,o3 = 0;
float m1 = 0, m2 = 0,m3 = 0;
char p;
for(i = 0; i<=45; i++){
printf("1- Santa Maria, 2- Pinta e 3 - Nina: ");
scanf("%i", &c);
printf("M- Matutino, V- Vespertino e N - Noturno: ");
scanf(" %c", &p);
if (c == 1){o1++;}
if (c == 2){o2++;}
if (c == 3){o3++;}
if (p == 'M'){m1++;}
if (p == 'V'){m2++;}
if (p == 'N'){m3++;}
}
printf("\nÔnibus 1: %.2f",o1/40);
printf("\nÔnibus 2: %.2f",o2/40);
printf("\nÔnibus 3: %.2f",o3/40);
if (p)
}
|
efe002a14e771d35169f413615aa0b32aada7255
|
4c544bb3b7f8a06edc1b61da50c8c7d041a15896
|
/leetcode-cpp/LongestNiceSubstring_1763.cpp
|
2e5c11171fc7fa56f506eded3cdc8a1632f8cd1a
|
[
"Apache-2.0"
] |
permissive
|
emacslisp/cpp
|
fb5385d4008ebb8367da93427474b0b118651d54
|
29beeead4fb385a3702e0022ebdac9608869877d
|
refs/heads/master
| 2023-04-12T05:42:25.022888
| 2023-03-11T14:30:09
| 2023-03-11T14:30:09
| 97,773,677
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,664
|
cpp
|
LongestNiceSubstring_1763.cpp
|
#include <vector>
#include <iostream>
#include <climits>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <math.h>
using namespace std;
#define ll long long
class Solution {
public:
string longestNiceSubstring(string s) {
string result ="";
if(s.size() < 2) return result;
int v[26];
int v1[26];
for(int i=0;i<s.size();i++) {
for(int j=i+1;j<s.size();j++) {
memset(v, 0, sizeof(int)*26);
memset(v1, 0, sizeof(int)*26);
for(int k=i;k<=j;k++) {
if(s[k]-'a' >=0 && s[k]<-'z' <=0) {
v[s[k]-'a']++;
} else if(s[k]-'A' >=0 && s[k] <-'Z' <=0) {
v1[s[k]-'A']++;
}
}
bool isNice = true;
for(int k=0;k<26;k++) {
if((v[k] > 0 && v1[k] >0)||
(v[k] == 0 && v1[k] == 0)) {
continue;
} else {
isNice = false;
break;
}
}
if(isNice && (j-i+1) > result.size()) {
result.clear();
for(int k=i;k<=j;k++) {
result.push_back(s[k]);
}
}
}
}
return result;
}
};
int main() {
Solution s;
vector<int> c
{
4,5,6,7,0,2,1,3
};
string str = "dDzeE";
int n = 1804289383;
string result = s.longestNiceSubstring(str);
cout<<result<<endl;
}
|
45620d8241ddfd6bbd29f090acbda6e92400d862
|
13864263b42c3582e5505e1ad15259aafc55cd52
|
/Bishop.h
|
19ca41f924fd2b473a9e0a6409876d3834571e3b
|
[] |
no_license
|
JermSmith/ChessGame2
|
8421cf937409af9f7ab0d89a98cf56c1e9e9a0ef
|
5f59886786701aa3e63f9a1d9f35e570f65f82b9
|
refs/heads/August-28/17-Restructure
| 2021-06-29T16:12:53.506612
| 2018-04-18T07:35:05
| 2018-04-18T07:35:05
| 94,967,130
| 0
| 0
| null | 2017-09-28T06:44:54
| 2017-06-21T05:42:48
|
C++
|
UTF-8
|
C++
| false
| false
| 162
|
h
|
Bishop.h
|
#pragma once
#include "Piece.h"
class CBishop : public CPiece
{
public:
CBishop(EColour); // constructor
virtual void calcDestinations(CBoard*);
};
|
18c93d99a81489e1bae5690144a93d22d3b6715d
|
fbe68d84e97262d6d26dd65c704a7b50af2b3943
|
/third_party/virtualbox/src/VBox/Runtime/common/ldr/ldrEx.cpp
|
0686986209b0519710e853b3995acb172b54d2f1
|
[
"MIT",
"GPL-2.0-only",
"LicenseRef-scancode-unknown-license-reference",
"CDDL-1.0",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"GPL-2.0-or-later",
"MPL-1.0",
"LicenseRef-scancode-generic-exception",
"Apache-2.0",
"OpenSSL"
] |
permissive
|
thalium/icebox
|
c4e6573f2b4f0973b6c7bb0bf068fe9e795fdcfb
|
6f78952d58da52ea4f0e55b2ab297f28e80c1160
|
refs/heads/master
| 2022-08-14T00:19:36.984579
| 2022-02-22T13:10:31
| 2022-02-22T13:10:31
| 190,019,914
| 585
| 109
|
MIT
| 2022-01-13T20:58:15
| 2019-06-03T14:18:12
|
C++
|
UTF-8
|
C++
| false
| false
| 27,934
|
cpp
|
ldrEx.cpp
|
/* $Id: ldrEx.cpp $ */
/** @file
* IPRT - Binary Image Loader, Extended Features.
*/
/*
* Copyright (C) 2006-2017 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*********************************************************************************************************************************
* Header Files *
*********************************************************************************************************************************/
#define LOG_GROUP RTLOGGROUP_LDR
#include <iprt/ldr.h>
#include "internal/iprt.h"
#include <iprt/assert.h>
#include <iprt/err.h>
#include <iprt/log.h>
#include <iprt/md5.h>
#include <iprt/mem.h>
#include <iprt/sha.h>
#include <iprt/string.h>
#include <iprt/formats/mz.h>
#include <iprt/formats/mach-o.h>
#include "internal/ldr.h"
#if defined(LDR_ONLY_PE) || defined(LDR_ONLY_MACHO)
# undef LDR_WITH_PE
# undef LDR_WITH_ELF
# undef LDR_WITH_LX
# undef LDR_WITH_LE
# undef LDR_WITH_MACHO
# undef LDR_WITH_NE
# undef LDR_WITH_MZ
# undef LDR_WITH_AOUT
# ifdef LDR_ONLY_PE
# define LDR_WITH_PE
# endif
# ifdef LDR_ONLY_MACHO
# define LDR_WITH_MACHO
# endif
#endif
RTDECL(int) RTLdrOpenWithReader(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phMod, PRTERRINFO pErrInfo)
{
/*
* Resolve RTLDRARCH_HOST.
*/
if (enmArch == RTLDRARCH_HOST)
#if defined(RT_ARCH_AMD64)
enmArch = RTLDRARCH_AMD64;
#elif defined(RT_ARCH_X86)
enmArch = RTLDRARCH_X86_32;
#else
enmArch = RTLDRARCH_WHATEVER;
#endif
/*
* Read and verify the file signature.
*/
union
{
char ach[4];
uint16_t au16[2];
uint32_t u32;
} uSign;
int rc = pReader->pfnRead(pReader, &uSign, sizeof(uSign), 0);
if (RT_FAILURE(rc))
return rc;
if ( uSign.au16[0] != IMAGE_DOS_SIGNATURE
&& uSign.u32 != IMAGE_NT_SIGNATURE
&& uSign.u32 != IMAGE_ELF_SIGNATURE
&& uSign.au16[0] != IMAGE_LX_SIGNATURE
&& uSign.u32 != IMAGE_MACHO64_SIGNATURE
&& uSign.u32 != IMAGE_MACHO64_SIGNATURE_OE
&& uSign.u32 != IMAGE_MACHO32_SIGNATURE
&& uSign.u32 != IMAGE_MACHO32_SIGNATURE_OE
&& uSign.u32 != IMAGE_FAT_SIGNATURE
&& uSign.u32 != IMAGE_FAT_SIGNATURE_OE )
{
Log(("rtldrOpenWithReader: %s: unknown magic %#x / '%.4s\n", pReader->pfnLogName(pReader), uSign.u32, &uSign.ach[0]));
return VERR_INVALID_EXE_SIGNATURE;
}
uint32_t offHdr = 0;
if (uSign.au16[0] == IMAGE_DOS_SIGNATURE)
{
rc = pReader->pfnRead(pReader, &offHdr, sizeof(offHdr), RT_UOFFSETOF(IMAGE_DOS_HEADER, e_lfanew));
if (RT_FAILURE(rc))
return rc;
if (offHdr <= sizeof(IMAGE_DOS_HEADER))
{
Log(("rtldrOpenWithReader: %s: no new header / invalid offset %#RX32\n", pReader->pfnLogName(pReader), offHdr));
return VERR_INVALID_EXE_SIGNATURE;
}
rc = pReader->pfnRead(pReader, &uSign, sizeof(uSign), offHdr);
if (RT_FAILURE(rc))
return rc;
if ( uSign.u32 != IMAGE_NT_SIGNATURE
&& uSign.au16[0] != IMAGE_LX_SIGNATURE
&& uSign.au16[0] != IMAGE_LE_SIGNATURE
&& uSign.au16[0] != IMAGE_NE_SIGNATURE)
{
Log(("rtldrOpenWithReader: %s: unknown new magic %#x / '%.4s\n", pReader->pfnLogName(pReader), uSign.u32, &uSign.ach[0]));
return VERR_INVALID_EXE_SIGNATURE;
}
}
/*
* Create image interpreter instance depending on the signature.
*/
if (uSign.u32 == IMAGE_NT_SIGNATURE)
#ifdef LDR_WITH_PE
rc = rtldrPEOpen(pReader, fFlags, enmArch, offHdr, phMod, pErrInfo);
#else
rc = VERR_PE_EXE_NOT_SUPPORTED;
#endif
else if (uSign.u32 == IMAGE_ELF_SIGNATURE)
#if defined(LDR_WITH_ELF)
rc = rtldrELFOpen(pReader, fFlags, enmArch, phMod, pErrInfo);
#else
rc = VERR_ELF_EXE_NOT_SUPPORTED;
#endif
else if ( uSign.u32 == IMAGE_MACHO64_SIGNATURE
|| uSign.u32 == IMAGE_MACHO64_SIGNATURE_OE
|| uSign.u32 == IMAGE_MACHO32_SIGNATURE
|| uSign.u32 == IMAGE_MACHO32_SIGNATURE_OE)
#if defined(LDR_WITH_MACHO)
rc = rtldrMachOOpen(pReader, fFlags, enmArch, offHdr, phMod, pErrInfo);
#else
rc = VERR_INVALID_EXE_SIGNATURE;
#endif
else if ( uSign.u32 == IMAGE_FAT_SIGNATURE
|| uSign.u32 == IMAGE_FAT_SIGNATURE_OE)
#if defined(LDR_WITH_MACHO)
rc = rtldrFatOpen(pReader, fFlags, enmArch, phMod, pErrInfo);
#else
rc = VERR_INVALID_EXE_SIGNATURE;
#endif
else if (uSign.au16[0] == IMAGE_LX_SIGNATURE)
#ifdef LDR_WITH_LX
rc = rtldrLXOpen(pReader, fFlags, enmArch, offHdr, phMod, pErrInfo);
#else
rc = VERR_LX_EXE_NOT_SUPPORTED;
#endif
else if (uSign.au16[0] == IMAGE_LE_SIGNATURE)
#ifdef LDR_WITH_LE
rc = rtldrLEOpen(pReader, fFlags, enmArch, phMod, pErrInfo);
#else
rc = VERR_LE_EXE_NOT_SUPPORTED;
#endif
else if (uSign.au16[0] == IMAGE_NE_SIGNATURE)
#ifdef LDR_WITH_NE
rc = rtldrNEOpen(pReader, fFlags, enmArch, phMod, pErrInfo);
#else
rc = VERR_NE_EXE_NOT_SUPPORTED;
#endif
else if (uSign.au16[0] == IMAGE_DOS_SIGNATURE)
#ifdef LDR_WITH_MZ
rc = rtldrMZOpen(pReader, fFlags, enmArch, phMod, pErrInfo);
#else
rc = VERR_MZ_EXE_NOT_SUPPORTED;
#endif
else if (/* uSign.u32 == IMAGE_AOUT_A_SIGNATURE
|| uSign.u32 == IMAGE_AOUT_Z_SIGNATURE*/ /** @todo find the aout magics in emx or binutils. */
0)
#ifdef LDR_WITH_AOUT
rc = rtldrAOUTOpen(pReader, fFlags, enmArch, phMod, pErrInfo);
#else
rc = VERR_AOUT_EXE_NOT_SUPPORTED;
#endif
else
{
Log(("rtldrOpenWithReader: %s: the format isn't implemented %#x / '%.4s\n", pReader->pfnLogName(pReader), uSign.u32, &uSign.ach[0]));
rc = VERR_INVALID_EXE_SIGNATURE;
}
LogFlow(("rtldrOpenWithReader: %s: returns %Rrc *phMod=%p\n", pReader->pfnLogName(pReader), rc, *phMod));
return rc;
}
RTDECL(size_t) RTLdrSize(RTLDRMOD hLdrMod)
{
LogFlow(("RTLdrSize: hLdrMod=%RTldrm\n", hLdrMod));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), ~(size_t)0);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
AssertMsgReturn(pMod->eState == LDR_STATE_OPENED, ("eState=%d\n", pMod->eState), ~(size_t)0);
/*
* Do it.
*/
size_t cb = pMod->pOps->pfnGetImageSize(pMod);
LogFlow(("RTLdrSize: returns %zu\n", cb));
return cb;
}
RT_EXPORT_SYMBOL(RTLdrSize);
/**
* Loads the image into a buffer provided by the user and applies fixups
* for the given base address.
*
* @returns iprt status code.
* @param hLdrMod The load module handle.
* @param pvBits Where to put the bits.
* Must be as large as RTLdrSize() suggests.
* @param BaseAddress The base address.
* @param pfnGetImport Callback function for resolving imports one by one.
* If this is NULL, imports will not be resolved.
* @param pvUser User argument for the callback.
* @remark Not supported for RTLdrLoad() images.
*/
RTDECL(int) RTLdrGetBits(RTLDRMOD hLdrMod, void *pvBits, RTLDRADDR BaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser)
{
LogFlow(("RTLdrGetBits: hLdrMod=%RTldrm pvBits=%p BaseAddress=%RTptr pfnGetImport=%p pvUser=%p\n",
hLdrMod, pvBits, BaseAddress, pfnGetImport, pvUser));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertPtrReturn(pvBits, VERR_INVALID_POINTER);
AssertPtrNullReturn(pfnGetImport, VERR_INVALID_POINTER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
AssertMsgReturn(pMod->eState == LDR_STATE_OPENED, ("eState=%d\n", pMod->eState), VERR_WRONG_ORDER);
/*
* Do it.
*/
int rc = pMod->pOps->pfnGetBits(pMod, pvBits, BaseAddress, pfnGetImport, pvUser);
LogFlow(("RTLdrGetBits: returns %Rrc\n",rc));
return rc;
}
RT_EXPORT_SYMBOL(RTLdrGetBits);
/**
* Relocates bits after getting them.
* Useful for code which moves around a bit.
*
* @returns iprt status code.
* @param hLdrMod The loader module handle.
* @param pvBits Where the image bits are.
* Must have been passed to RTLdrGetBits().
* @param NewBaseAddress The new base address.
* @param OldBaseAddress The old base address.
* @param pfnGetImport Callback function for resolving imports one by one.
* @param pvUser User argument for the callback.
* @remark Not supported for RTLdrLoad() images.
*/
RTDECL(int) RTLdrRelocate(RTLDRMOD hLdrMod, void *pvBits, RTLDRADDR NewBaseAddress, RTLDRADDR OldBaseAddress,
PFNRTLDRIMPORT pfnGetImport, void *pvUser)
{
LogFlow(("RTLdrRelocate: hLdrMod=%RTldrm pvBits=%p NewBaseAddress=%RTptr OldBaseAddress=%RTptr pfnGetImport=%p pvUser=%p\n",
hLdrMod, pvBits, NewBaseAddress, OldBaseAddress, pfnGetImport, pvUser));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertMsgReturn(VALID_PTR(pvBits), ("pvBits=%p\n", pvBits), VERR_INVALID_PARAMETER);
AssertMsgReturn(VALID_PTR(pfnGetImport), ("pfnGetImport=%p\n", pfnGetImport), VERR_INVALID_PARAMETER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
AssertMsgReturn(pMod->eState == LDR_STATE_OPENED, ("eState=%d\n", pMod->eState), VERR_WRONG_ORDER);
/*
* Do it.
*/
int rc = pMod->pOps->pfnRelocate(pMod, pvBits, NewBaseAddress, OldBaseAddress, pfnGetImport, pvUser);
LogFlow(("RTLdrRelocate: returns %Rrc\n", rc));
return rc;
}
RT_EXPORT_SYMBOL(RTLdrRelocate);
RTDECL(int) RTLdrGetSymbolEx(RTLDRMOD hLdrMod, const void *pvBits, RTLDRADDR BaseAddress,
uint32_t iOrdinal, const char *pszSymbol, PRTLDRADDR pValue)
{
LogFlow(("RTLdrGetSymbolEx: hLdrMod=%RTldrm pvBits=%p BaseAddress=%RTptr iOrdinal=%#x pszSymbol=%p:{%s} pValue=%p\n",
hLdrMod, pvBits, BaseAddress, iOrdinal, pszSymbol, pszSymbol, pValue));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertPtrNullReturn(pvBits, VERR_INVALID_POINTER);
AssertPtrNullReturn(pszSymbol, VERR_INVALID_POINTER);
AssertReturn(pszSymbol || iOrdinal != UINT32_MAX, VERR_INVALID_PARAMETER);
AssertPtrReturn(pValue, VERR_INVALID_POINTER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
/*
* Do it.
*/
int rc;
if (pMod->pOps->pfnGetSymbolEx)
rc = pMod->pOps->pfnGetSymbolEx(pMod, pvBits, BaseAddress, iOrdinal, pszSymbol, pValue);
else if (!BaseAddress && !pvBits && iOrdinal == UINT32_MAX)
{
void *pvValue;
rc = pMod->pOps->pfnGetSymbol(pMod, pszSymbol, &pvValue);
if (RT_SUCCESS(rc))
*pValue = (uintptr_t)pvValue;
}
else
AssertMsgFailedReturn(("BaseAddress=%RTptr pvBits=%p\n", BaseAddress, pvBits), VERR_INVALID_FUNCTION);
LogFlow(("RTLdrGetSymbolEx: returns %Rrc *pValue=%p\n", rc, *pValue));
return rc;
}
RT_EXPORT_SYMBOL(RTLdrGetSymbolEx);
RTDECL(int) RTLdrQueryForwarderInfo(RTLDRMOD hLdrMod, const void *pvBits, uint32_t iOrdinal, const char *pszSymbol,
PRTLDRIMPORTINFO pInfo, size_t cbInfo)
{
LogFlow(("RTLdrQueryForwarderInfo: hLdrMod=%RTldrm pvBits=%p iOrdinal=%#x pszSymbol=%p:{%s} pInfo=%p cbInfo=%zu\n",
hLdrMod, pvBits, iOrdinal, pszSymbol, pszSymbol, pInfo, cbInfo));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertPtrNullReturn(pvBits, VERR_INVALID_POINTER);
AssertMsgReturn(pszSymbol, ("pszSymbol=%p\n", pszSymbol), VERR_INVALID_PARAMETER);
AssertPtrReturn(pInfo, VERR_INVALID_PARAMETER);
AssertReturn(cbInfo >= sizeof(*pInfo), VERR_INVALID_PARAMETER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
/*
* Do it.
*/
int rc;
if (pMod->pOps->pfnQueryForwarderInfo)
{
rc = pMod->pOps->pfnQueryForwarderInfo(pMod, pvBits, iOrdinal, pszSymbol, pInfo, cbInfo);
if (RT_SUCCESS(rc))
LogFlow(("RTLdrQueryForwarderInfo: returns %Rrc pInfo={%#x,%#x,%s,%s}\n", rc,
pInfo->iSelfOrdinal, pInfo->iOrdinal, pInfo->pszSymbol, pInfo->szModule));
else
LogFlow(("RTLdrQueryForwarderInfo: returns %Rrc\n", rc));
}
else
{
LogFlow(("RTLdrQueryForwarderInfo: returns VERR_NOT_SUPPORTED\n"));
rc = VERR_NOT_SUPPORTED;
}
return rc;
}
RT_EXPORT_SYMBOL(RTLdrQueryForwarderInfo);
/**
* Enumerates all symbols in a module.
*
* @returns iprt status code.
* @param hLdrMod The loader module handle.
* @param fFlags Flags indicating what to return and such.
* @param pvBits Optional pointer to the loaded image.
* Set this to NULL if no RTLdrGetBits() processed image bits are available.
* @param BaseAddress Image load address.
* @param pfnCallback Callback function.
* @param pvUser User argument for the callback.
* @remark Not supported for RTLdrLoad() images.
*/
RTDECL(int) RTLdrEnumSymbols(RTLDRMOD hLdrMod, unsigned fFlags, const void *pvBits, RTLDRADDR BaseAddress,
PFNRTLDRENUMSYMS pfnCallback, void *pvUser)
{
LogFlow(("RTLdrEnumSymbols: hLdrMod=%RTldrm fFlags=%#x pvBits=%p BaseAddress=%RTptr pfnCallback=%p pvUser=%p\n",
hLdrMod, fFlags, pvBits, BaseAddress, pfnCallback, pvUser));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertMsgReturn(!pvBits || VALID_PTR(pvBits), ("pvBits=%p\n", pvBits), VERR_INVALID_PARAMETER);
AssertMsgReturn(VALID_PTR(pfnCallback), ("pfnCallback=%p\n", pfnCallback), VERR_INVALID_PARAMETER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
//AssertMsgReturn(pMod->eState == LDR_STATE_OPENED, ("eState=%d\n", pMod->eState), VERR_WRONG_ORDER);
/*
* Do it.
*/
int rc = pMod->pOps->pfnEnumSymbols(pMod, fFlags, pvBits, BaseAddress, pfnCallback, pvUser);
LogFlow(("RTLdrEnumSymbols: returns %Rrc\n", rc));
return rc;
}
RT_EXPORT_SYMBOL(RTLdrEnumSymbols);
RTDECL(int) RTLdrEnumDbgInfo(RTLDRMOD hLdrMod, const void *pvBits, PFNRTLDRENUMDBG pfnCallback, void *pvUser)
{
LogFlow(("RTLdrEnumDbgInfo: hLdrMod=%RTldrm pvBits=%p pfnCallback=%p pvUser=%p\n",
hLdrMod, pvBits, pfnCallback, pvUser));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertMsgReturn(!pvBits || RT_VALID_PTR(pvBits), ("pvBits=%p\n", pvBits), VERR_INVALID_PARAMETER);
AssertMsgReturn(RT_VALID_PTR(pfnCallback), ("pfnCallback=%p\n", pfnCallback), VERR_INVALID_PARAMETER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
//AssertMsgReturn(pMod->eState == LDR_STATE_OPENED, ("eState=%d\n", pMod->eState), VERR_WRONG_ORDER);
/*
* Do it.
*/
int rc;
if (pMod->pOps->pfnEnumDbgInfo)
rc = pMod->pOps->pfnEnumDbgInfo(pMod, pvBits, pfnCallback, pvUser);
else
rc = VERR_NOT_SUPPORTED;
LogFlow(("RTLdrEnumDbgInfo: returns %Rrc\n", rc));
return rc;
}
RT_EXPORT_SYMBOL(RTLdrEnumDbgInfo);
RTDECL(int) RTLdrEnumSegments(RTLDRMOD hLdrMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser)
{
LogFlow(("RTLdrEnumSegments: hLdrMod=%RTldrm pfnCallback=%p pvUser=%p\n",
hLdrMod, pfnCallback, pvUser));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertMsgReturn(RT_VALID_PTR(pfnCallback), ("pfnCallback=%p\n", pfnCallback), VERR_INVALID_PARAMETER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
//AssertMsgReturn(pMod->eState == LDR_STATE_OPENED, ("eState=%d\n", pMod->eState), VERR_WRONG_ORDER);
/*
* Do it.
*/
int rc;
if (pMod->pOps->pfnEnumSegments)
rc = pMod->pOps->pfnEnumSegments(pMod, pfnCallback, pvUser);
else
rc = VERR_NOT_SUPPORTED;
LogFlow(("RTLdrEnumSegments: returns %Rrc\n", rc));
return rc;
}
RT_EXPORT_SYMBOL(RTLdrEnumSegments);
RTDECL(int) RTLdrLinkAddressToSegOffset(RTLDRMOD hLdrMod, RTLDRADDR LinkAddress, uint32_t *piSeg, PRTLDRADDR poffSeg)
{
LogFlow(("RTLdrLinkAddressToSegOffset: hLdrMod=%RTldrm LinkAddress=%RTptr piSeg=%p poffSeg=%p\n",
hLdrMod, LinkAddress, piSeg, poffSeg));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertPtrReturn(piSeg, VERR_INVALID_POINTER);
AssertPtrReturn(poffSeg, VERR_INVALID_POINTER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
//AssertMsgReturn(pMod->eState == LDR_STATE_OPENED, ("eState=%d\n", pMod->eState), VERR_WRONG_ORDER);
*piSeg = UINT32_MAX;
*poffSeg = ~(RTLDRADDR)0;
/*
* Do it.
*/
int rc;
if (pMod->pOps->pfnLinkAddressToSegOffset)
rc = pMod->pOps->pfnLinkAddressToSegOffset(pMod, LinkAddress, piSeg, poffSeg);
else
rc = VERR_NOT_SUPPORTED;
LogFlow(("RTLdrLinkAddressToSegOffset: returns %Rrc %#x:%RTptr\n", rc, *piSeg, *poffSeg));
return rc;
}
RT_EXPORT_SYMBOL(RTLdrLinkAddressToSegOffset);
RTDECL(int) RTLdrLinkAddressToRva(RTLDRMOD hLdrMod, RTLDRADDR LinkAddress, PRTLDRADDR pRva)
{
LogFlow(("RTLdrLinkAddressToRva: hLdrMod=%RTldrm LinkAddress=%RTptr pRva=%p\n",
hLdrMod, LinkAddress, pRva));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertPtrReturn(pRva, VERR_INVALID_POINTER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
//AssertMsgReturn(pMod->eState == LDR_STATE_OPENED, ("eState=%d\n", pMod->eState), VERR_WRONG_ORDER);
*pRva = ~(RTLDRADDR)0;
/*
* Do it.
*/
int rc;
if (pMod->pOps->pfnLinkAddressToRva)
rc = pMod->pOps->pfnLinkAddressToRva(pMod, LinkAddress, pRva);
else
rc = VERR_NOT_SUPPORTED;
LogFlow(("RTLdrLinkAddressToRva: returns %Rrc %RTptr\n", rc, *pRva));
return rc;
}
RT_EXPORT_SYMBOL(RTLdrLinkAddressToRva);
RTDECL(int) RTLdrSegOffsetToRva(RTLDRMOD hLdrMod, uint32_t iSeg, RTLDRADDR offSeg, PRTLDRADDR pRva)
{
LogFlow(("RTLdrSegOffsetToRva: hLdrMod=%RTldrm iSeg=%#x offSeg=%RTptr pRva=%p\n", hLdrMod, iSeg, offSeg, pRva));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertPtrReturn(pRva, VERR_INVALID_POINTER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
//AssertMsgReturn(pMod->eState == LDR_STATE_OPENED, ("eState=%d\n", pMod->eState), VERR_WRONG_ORDER);
*pRva = ~(RTLDRADDR)0;
/*
* Do it.
*/
int rc;
if (pMod->pOps->pfnSegOffsetToRva)
rc = pMod->pOps->pfnSegOffsetToRva(pMod, iSeg, offSeg, pRva);
else
rc = VERR_NOT_SUPPORTED;
LogFlow(("RTLdrSegOffsetToRva: returns %Rrc %RTptr\n", rc, *pRva));
return rc;
}
RT_EXPORT_SYMBOL(RTLdrSegOffsetToRva);
RTDECL(int) RTLdrRvaToSegOffset(RTLDRMOD hLdrMod, RTLDRADDR Rva, uint32_t *piSeg, PRTLDRADDR poffSeg)
{
LogFlow(("RTLdrRvaToSegOffset: hLdrMod=%RTldrm Rva=%RTptr piSeg=%p poffSeg=%p\n",
hLdrMod, Rva, piSeg, poffSeg));
/*
* Validate input.
*/
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
AssertPtrReturn(piSeg, VERR_INVALID_POINTER);
AssertPtrReturn(poffSeg, VERR_INVALID_POINTER);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
//AssertMsgReturn(pMod->eState == LDR_STATE_OPENED, ("eState=%d\n", pMod->eState), VERR_WRONG_ORDER);
*piSeg = UINT32_MAX;
*poffSeg = ~(RTLDRADDR)0;
/*
* Do it.
*/
int rc;
if (pMod->pOps->pfnRvaToSegOffset)
rc = pMod->pOps->pfnRvaToSegOffset(pMod, Rva, piSeg, poffSeg);
else
rc = VERR_NOT_SUPPORTED;
LogFlow(("RTLdrRvaToSegOffset: returns %Rrc %#x:%RTptr\n", rc, *piSeg, *poffSeg));
return rc;
}
RT_EXPORT_SYMBOL(RTLdrRvaToSegOffset);
RTDECL(int) RTLdrQueryProp(RTLDRMOD hLdrMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf)
{
return RTLdrQueryPropEx(hLdrMod, enmProp, NULL /*pvBits*/, pvBuf, cbBuf, NULL);
}
RT_EXPORT_SYMBOL(RTLdrQueryProp);
RTDECL(int) RTLdrQueryPropEx(RTLDRMOD hLdrMod, RTLDRPROP enmProp, void *pvBits, void *pvBuf, size_t cbBuf, size_t *pcbRet)
{
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), RTLDRENDIAN_INVALID);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
AssertPtrNullReturn(pcbRet, VERR_INVALID_POINTER);
size_t cbRet;
if (!pcbRet)
pcbRet = &cbRet;
/*
* Do some pre screening of the input
*/
switch (enmProp)
{
case RTLDRPROP_UUID:
*pcbRet = sizeof(RTUUID);
AssertReturn(cbBuf == sizeof(RTUUID), VERR_INVALID_PARAMETER);
break;
case RTLDRPROP_TIMESTAMP_SECONDS:
*pcbRet = sizeof(int64_t);
AssertReturn(cbBuf == sizeof(int32_t) || cbBuf == sizeof(int64_t), VERR_INVALID_PARAMETER);
break;
case RTLDRPROP_IS_SIGNED:
*pcbRet = sizeof(bool);
AssertReturn(cbBuf == sizeof(bool), VERR_INVALID_PARAMETER);
break;
case RTLDRPROP_PKCS7_SIGNED_DATA:
*pcbRet = 0;
break;
case RTLDRPROP_SIGNATURE_CHECKS_ENFORCED:
*pcbRet = sizeof(bool);
AssertReturn(cbBuf == sizeof(bool), VERR_INVALID_PARAMETER);
break;
case RTLDRPROP_IMPORT_COUNT:
*pcbRet = sizeof(uint32_t);
AssertReturn(cbBuf == sizeof(uint32_t), VERR_INVALID_PARAMETER);
break;
case RTLDRPROP_IMPORT_MODULE:
*pcbRet = sizeof(uint32_t);
AssertReturn(cbBuf >= sizeof(uint32_t), VERR_INVALID_PARAMETER);
break;
case RTLDRPROP_FILE_OFF_HEADER:
*pcbRet = sizeof(uint64_t);
AssertReturn(cbBuf == sizeof(uint32_t) || cbBuf == sizeof(uint64_t), VERR_INVALID_PARAMETER);
break;
case RTLDRPROP_INTERNAL_NAME:
*pcbRet = 0;
break;
default:
AssertFailedReturn(VERR_INVALID_FUNCTION);
}
AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
/*
* Call the image specific worker, if there is one.
*/
if (!pMod->pOps->pfnQueryProp)
return VERR_NOT_SUPPORTED;
return pMod->pOps->pfnQueryProp(pMod, enmProp, pvBits, pvBuf, cbBuf, pcbRet);
}
RT_EXPORT_SYMBOL(RTLdrQueryPropEx);
RTDECL(int) RTLdrVerifySignature(RTLDRMOD hLdrMod, PFNRTLDRVALIDATESIGNEDDATA pfnCallback, void *pvUser, PRTERRINFO pErrInfo)
{
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
AssertPtrReturn(pfnCallback, VERR_INVALID_POINTER);
/*
* Call the image specific worker, if there is one.
*/
if (!pMod->pOps->pfnVerifySignature)
return VERR_NOT_SUPPORTED;
return pMod->pOps->pfnVerifySignature(pMod, pfnCallback, pvUser, pErrInfo);
}
RT_EXPORT_SYMBOL(RTLdrVerifySignature);
RTDECL(int) RTLdrHashImage(RTLDRMOD hLdrMod, RTDIGESTTYPE enmDigest, char *pszDigest, size_t cbDigest)
{
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
/*
* Make sure there is sufficient space for the wanted digest and that
* it's supported.
*/
switch (enmDigest)
{
case RTDIGESTTYPE_MD5: AssertReturn(cbDigest >= RTMD5_DIGEST_LEN + 1, VERR_BUFFER_OVERFLOW); break;
case RTDIGESTTYPE_SHA1: AssertReturn(cbDigest >= RTSHA1_DIGEST_LEN + 1, VERR_BUFFER_OVERFLOW); break;
case RTDIGESTTYPE_SHA256: AssertReturn(cbDigest >= RTSHA256_DIGEST_LEN + 1, VERR_BUFFER_OVERFLOW); break;
case RTDIGESTTYPE_SHA512: AssertReturn(cbDigest >= RTSHA512_DIGEST_LEN + 1, VERR_BUFFER_OVERFLOW); break;
default:
if (enmDigest > RTDIGESTTYPE_INVALID && enmDigest < RTDIGESTTYPE_END)
return VERR_NOT_SUPPORTED;
AssertFailedReturn(VERR_INVALID_PARAMETER);
}
AssertPtrReturn(pszDigest, VERR_INVALID_POINTER);
/*
* Call the image specific worker, if there is one.
*/
if (!pMod->pOps->pfnHashImage)
return VERR_NOT_SUPPORTED;
return pMod->pOps->pfnHashImage(pMod, enmDigest, pszDigest, cbDigest);
}
RT_EXPORT_SYMBOL(RTLdrHashImage);
/**
* Internal method used by the IPRT debug bits.
*
* @returns IPRT status code.
* @param hLdrMod The loader handle which executable we wish to
* read from.
* @param pvBuf The output buffer.
* @param iDbgInfo The debug info ordinal number if the request
* corresponds exactly to a debug info part from
* pfnEnumDbgInfo. Otherwise, pass UINT32_MAX.
* @param off Where in the executable file to start reading.
* @param cb The number of bytes to read.
*
* @remarks Fixups will only be applied if @a iDbgInfo is specified.
*/
DECLHIDDEN(int) rtLdrReadAt(RTLDRMOD hLdrMod, void *pvBuf, uint32_t iDbgInfo, RTFOFF off, size_t cb)
{
AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), VERR_INVALID_HANDLE);
PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
if (iDbgInfo != UINT32_MAX)
{
AssertReturn(pMod->pOps->pfnReadDbgInfo, VERR_NOT_SUPPORTED);
return pMod->pOps->pfnReadDbgInfo(pMod, iDbgInfo, off, cb, pvBuf);
}
AssertReturn(pMod->pReader, VERR_NOT_SUPPORTED);
return pMod->pReader->pfnRead(pMod->pReader, pvBuf, cb, off);
}
/**
* Translates a RTLDRARCH value to a string.
*
* @returns Name corresponding to @a enmArch
* @param enmArch The value to name.
*/
DECLHIDDEN(const char *) rtLdrArchName(RTLDRARCH enmArch)
{
switch (enmArch)
{
case RTLDRARCH_INVALID: return "INVALID";
case RTLDRARCH_WHATEVER: return "WHATEVER";
case RTLDRARCH_HOST: return "HOST";
case RTLDRARCH_AMD64: return "AMD64";
case RTLDRARCH_X86_32: return "X86_32";
case RTLDRARCH_END:
case RTLDRARCH_32BIT_HACK:
break;
}
return "UNKNOWN";
}
|
dc6ee9fb3523047f7b60cba28023ef70221f3e02
|
31745b176ee0d30f47fb6cbdf0e9c621d104d441
|
/Library/Include/Cylinder.hpp
|
3f4cfed18e65cc9dd9967f3eb808d78b28eeb283
|
[] |
no_license
|
BlenderCN-Org/GraphicalMiller
|
8406dcc900a00c7457ebe1f2adcc59c1e2de1bcc
|
59acabb386e462809d7b50b1250df2be53404570
|
refs/heads/master
| 2020-05-27T08:23:53.923312
| 2017-02-21T04:54:11
| 2017-02-21T04:54:11
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,791
|
hpp
|
Cylinder.hpp
|
//***************************************************************************//
// Cylinder Class Interface
//
// Created: May 24, 2006
// By: Jeremy Michael Miller
//
// Copyright (c) 2016-2016 Jeremy Michael Miller.
// Author: = "Jeremy Michael Miller"
// Copyright: = "Copyright 2005-2016, Graphical Miller, All rights reserved."
// Credits = ["Jeremy Michael Miller"]
// License: "Fair use v0.9"
// Version: "0.0.1"
// Maintainer: "Jeremy Michael Miller"
// Email: "maybe_later@mst.dnsalias.net"
// Status: "Alpha"
//***************************************************************************//
#ifndef MST_GRAPHICS_CYLINDER_HPP
#define MST_GRAPHICS_CYLINDER_HPP
//***************************************************************************//
// Local Includes
#include "Mesh.hpp"
//***************************************************************************//
//***************************************************************************//
namespace MST
{
//*************************************************************************//
class Cylinder : public Mesh
{
private:
//***********************************************************************//
//***********************************************************************//
public:
//***********************************************************************//
Cylinder(const std::string& strName, class Scene* const pScene);
~Cylinder();
void Render();
//***********************************************************************//
}; // End of class Cylinder : public Mesh
//*************************************************************************//
} // End of namespace MST
//***************************************************************************//
#endif MST_GRAPHICS_CYLINDER_HPP
|
1a7dd4ab832bc192d0c872c18fa1c5f1efd7d8f2
|
df30714101a14b52499a8a6bafdf5f3ddb9b77cb
|
/sonicball/sonicball/Scene/TitleScene.h
|
7a094310e51d61b308d1e05cf99c9febf0381eac
|
[
"MIT"
] |
permissive
|
nomissbowling/game_samples
|
3eea4ec84cf63e90554d7ec314abc891db0d8370
|
9acfb3101d84f65a8be5b9846bd4764e822baf5f
|
refs/heads/master
| 2022-02-10T19:12:15.385892
| 2019-06-19T00:52:32
| 2019-06-19T00:52:32
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 941
|
h
|
TitleScene.h
|
#pragma once
#include "Scene.h"
#include"../Geometry.h"
class Input;
class TitleScene final:
public Scene
{
private:
struct ImgInfo {
int handle;
Size size;
void Load(const char*);
};
struct BgImgs{
ImgInfo mostbackImg;
ImgInfo farImg;
ImgInfo middleImg;
ImgInfo foregroundImg;
ImgInfo mostforeImg;
};
BgImgs _bgimgs;
int _bgFrame = 0;
int _startSE;
int _wait;
int _titlepng;
int _logoportalH;
int _pressstartH;
Size _portalSize;
Size _pressstartSize;
Position2 _titlepos;
Position2 _pressstartpos;
int _frameCounter;
void (TitleScene::*_updater)(const Input& input);
void FadeinUpdate(const Input& input);
void DrawTitleBackground(int w, int h);
void NormalUpdate(const Input& input);
void BlinkUpdate(const Input& input);
void FadeoutUpdate(const Input& input);
public:
TitleScene(SceneController& controller);
~TitleScene();
void Update(const Input& input) override;
void Draw() override;
};
|
0c0430f167b80d3e99b1167e79e1442f60dc63ad
|
201e09cd2e8d2b2787dbd5d9ec71192c0d46edd1
|
/Menu Searching.cpp
|
ec7de52e6f5d7a4b8caf860a40ebb6d8d699e2ac
|
[] |
no_license
|
Haikallr/Program-Searching
|
23077479b88e18e291db9d02ed90677c870ddcf4
|
30b83509f54031681ea2a74668014cde5cc02d90
|
refs/heads/master
| 2020-03-22T20:07:22.843297
| 2018-07-11T12:50:15
| 2018-07-11T12:50:15
| 140,574,092
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,620
|
cpp
|
Menu Searching.cpp
|
#include <iostream>
#include <math.h>
using namespace std;
int main(){
int nilai[30];
int pil,i,n;
char menu;
cout<<"=========================================="<<endl;
cout<<"||\t PROGRAM SEDERHANA SEARCH \t||"<<endl;
cout<<"=========================================="<<endl;
cout<<"|| NAMA : Mohammad Haikal Ramadan\t||"<<endl;
cout<<"|| NIM : 20170801058\t\t||"<<endl;
cout<<"|| Jurusan : Teknik Informatika\t\t||"<<endl;
cout<<"==========================================\n"<<endl;
cout<<"Masukkan Banyak Bilangan yang Anda Inginkan : ";
cin>>n;
cout<<endl;
for(i=1;i<=n;i++){
cout<<"Masukan Bilangan Ke - ["<<i<<"] : ";
cin>>nilai[i];
}
cout<<endl;
cout<<"Deret Bilangan Yang Diinput : ";
for(i=1;i<=n;i++){
cout<<nilai[i]<<" ";
}
cout<<"\n\n";
start:
cout<<"\n\nPilihlah Menu di Bawah ini : ";
cout << "\n[1] Sequential Search\n";
cout << "[2] Binary Search\n";
cout << "[3] Keluar";
cout << "\n\nTentukan Pilihan Anda : ";
cin >> pil;
if (pil==1){
int no,jd,cari,data[50];
int flag = 0;
cout<<"\nMasukan Jumlah Data : ";
cin>>jd;
cout<<endl;
for (no=0;no<jd;no++){
cout<<"Input Data Ke-"<<(no+1)<<" : ";
cin>>data[no];
}
cout<<"\nMasukkan data yang ingin dicari : ";
cin>>cari;
for(int i=0;i<8;i++){
if(data[i] == cari){
flag = 1;
}
}
if(flag == 1){
cout<<"\nData di Temukan!\n";
}
else{
cout<<"\nData Tidak di Temukan!\n";
}
}
else if(pil==2){
int jd, cari,no, kiri,kanan,tengah,data[50];
cout<<"\nMasukan Jumlah Data : ";
cin>>jd;
cout<<endl;
for (no=0;no<jd;no++)
{
cout<<"Input Data Ke-"<<(no+1)<<" : ";
cin>>data[no];
}
cout<<endl;
cout<<"Masukan Nilai Dicari : ";
cin>>cari;
kiri=0;
kanan=jd-1;
tengah=(kanan-kiri)/2;
while ((data[tengah]!=cari) && (kiri>=0)&& (kanan<jd) && (kanan>=kiri))
{
if (cari>data[tengah]){
kiri=tengah+1;
}
else if (cari<data[tengah]){
kanan=tengah-1;
}
tengah=kiri+(kanan-kiri)/2;
}
cout<<endl;
if (data[tengah]==cari){
cout<<"Data Ditemukan..\n";
}
else{
cout<<"Data Tidak Ditemukan\n";
}
}
else if(pil==3){
}
cout<<"\n\nApakah Anda Ingin Mencoba Menu Lain?[Y/N] : ";
cin>>menu;
if(menu=='Y'||menu=='y')
goto start;
if(menu=='N'||menu=='n')
goto finish;
finish:
cout<<"Thank Your For Trying:)\n\n";
}
|
a1593844261231eb962d033917ebdf3e74b3f4d3
|
30863e0df8ed5fc61c4b1c195582e4d33f20d297
|
/Linked-list/10.cpp
|
88c50bc309528e48871fa6d7264166a7b2793dc1
|
[] |
no_license
|
BUX404-git/DataStruct
|
7e9c9b59c4fe7682643ed099e104696307b7a70d
|
7a076ecf9a1a3e33cc11a8f4abb48b91778db922
|
refs/heads/main
| 2023-04-23T15:20:31.898657
| 2021-05-13T00:26:21
| 2021-05-13T00:26:21
| 364,550,889
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 866
|
cpp
|
10.cpp
|
/**
* 将一个带头结点的单链表A分解为两个带头结点的单链表A和B,
* 使得A表中含有原表中序号为奇数的元素,而B表中含有原表中序号为偶数的元素,
* 且保持相对顺序不变.
*
* 思路:for循环遍历链表,if语句判断序号奇偶.
*
* */
LinkList DisCreate_1(LinkList &A){
LinkList B = (LinkList)malloc(sizeof(LNode));
B->next = nullptr;//定义B链表的表头结点
LNode *ra = A,*rb = B;//ra和rb分别指向将创建的A表和B表的尾结点
LNode *p = A->next;
A->next = nullptr;//置空新的A表
int i = 0;
while(p != nullptr){
i++;
if( i%2 == 0 ){
rb->next = p;//在B表尾插入新结点
rb=p;
}
else{
ra->next = p;//在A表尾插入新结点
ra = p;
}
p=p->next;
}
ra->next = NULL;
rb->next = NULL;
return B;
}
|
e822ff8ce40c5f8a08174bc63aa5c4c8bdea5e58
|
08af5e857c3cd8e77b706a3d25f94edcd0836793
|
/Password.cpp
|
a0b044a56d29e796d1f4b90c7e2e958f1ca2f898
|
[] |
no_license
|
swarooprth/password_validity_checker
|
4fc6f66fead41555768ffb11d97f8775ed610588
|
5fa18d93114c4de48e4d86e77d7d9a3e1b044b0a
|
refs/heads/master
| 2020-04-25T18:33:14.286519
| 2019-02-27T20:50:58
| 2019-02-27T20:50:58
| 172,988,178
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,248
|
cpp
|
Password.cpp
|
#include<iostream>
using namespace std;
void Password_validate(string s)
{
int l=s.length();
if(l < 6)
{
cout<<"Failure Password must be at least 6 characters long.";
return;
}
if(l > 24)
{
cout<<"Failure Password must be at max 12 characters long.";
return;
}
int Lower_case=0, Upper_case=0, Number=0, Special_Char=0;
bool flag=false;
for(int i=0; i<=s.length(); i++)
{
if(s[i]>='a' && s[i]<='z')
Lower_case++;
else if(s[i]>='A' && s[i]<='Z')
Upper_case++;
else if(s[i]>='0' && s[i]<= '9')
Number++;
else if(s[i]=='*' || s[i]=='$' || s[i]=='_' || s[i]=='#' || s[i]=='=' || s[i]=='@')
Special_Char++;
else if(s[i]=='%' || s[i]=='!' || s[i]=='(' || s[i]==')')
{
flag=true;
break;
}
}
if(flag)
{
cout<<"Failure Password cannot contain %!)(.";
return;
}
if(Lower_case >0 && Upper_case>0 && Number>0 && Special_Char>0)
{
cout<<"Success";
return;
}
else
{
if(Lower_case==0)
cout<<"Failure Password must contain at least one letter from a-z.";
else if(Upper_case==0)
cout<<"Failure Password must contain at least one letter from A-Z.";
else if(Number==0)
cout<<"Failure Password must contain at least one letter from 0-9.";
else
cout<<"Failure Password must contain at least one letter from *$_#=@.";
return;
}
}
int main()
{
string Password_list;
getline(cin,Password_list);
string s="";
for(int i=0; i<=Password_list.length(); i++)
{
if(Password_list[i]==','||Password_list[i]=='\0')
{
if(s.length()>0)
{ cout<<s<<" ";
Password_validate(s);
cout<<endl;
s="";
}
}
else s+=Password_list[i];
}
}
|
a6626c1f3a6ac4e768642cfadc21bbe70ca683b1
|
dee02119dba1b3c470fdefc32b3660a26e878cd0
|
/rotation.ino
|
7a6e744145a6281e1b26cc3c2bf32ff5904af4c5
|
[] |
no_license
|
vignanpogu/IOT
|
d3d2628920956cc8e752a00e1321070f5f228e97
|
a5a2f40d89f374b0ccae54fc97d40c696c639ed3
|
refs/heads/main
| 2023-02-10T10:24:42.573102
| 2021-01-10T09:44:20
| 2021-01-10T09:44:20
| 328,348,507
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 135
|
ino
|
rotation.ino
|
void setup() {
pinMode(A0,INPUT);
Serial.begin(9600);
}
void loop() {
int angle = analogRead(A0);
Serial.println(angle);
}
|
66b4f1cf828a715396c8a6e14c7bdb7ba76179c9
|
8a1fa5f5045130c193aae3d810fd64acf14c2ce5
|
/hw07_inheritance/Warrior.cpp
|
ce029a51c5c6db52fd551b7fcd2a4baeab4f4b13
|
[] |
no_license
|
EddieSource/oop_lab
|
8959e4e3361eeb6ad5374ec2191a369cfbdf328c
|
f00253982276c6c5998904c01c51adbd1d455be3
|
refs/heads/master
| 2023-08-31T07:24:02.230656
| 2023-08-18T20:05:53
| 2023-08-18T20:05:53
| 367,999,905
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 311
|
cpp
|
Warrior.cpp
|
//
// Warrior.cpp
// cs2124-hw7
//
// Created by Eddie Zhu on 2020/4/15.
// Copyright © 2020 EddieZ. All rights reserved.
//
#include <stdio.h>
#include "Warrior.h"
using namespace std;
namespace WarriorCraft {
Warrior::Warrior(const string& name, double strength) : Protector(name, strength){}
}
|
80fab47f09c95c2edb567a7041c45ee65db659a0
|
dd826131205a23d707556f463ff6fec4df7dd8fb
|
/GameEngine/GDK/Skybox/Skybox.cpp
|
40148e2fd234dc953e08dbf92a7b72c02f510631
|
[] |
no_license
|
Tahir98/GameEngine
|
57494c3dbc17c84a6a2d7e4cc4f775f8c82e45ff
|
427dd60165bfe7ad336d96e1005d39e5d436908b
|
refs/heads/master
| 2023-04-19T03:40:43.783579
| 2021-04-25T10:37:14
| 2021-04-25T10:37:14
| 335,883,416
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,048
|
cpp
|
Skybox.cpp
|
#pragma once
#include "Skybox.h"
#include "GL/glew.h"
#include <stdlib.h>
float proj[4][4];
Skybox::Skybox(){
textures = (Texture*)malloc(sizeof(Texture) * 6);
textures[0] = Texture("assets/skybox/miramar_ft.jpg");
textures[1] = Texture("assets/skybox/miramar_rt.jpg");
textures[2] = Texture("assets/skybox/miramar_bk.jpg");
textures[3] = Texture("assets/skybox/miramar_lf.jpg");
textures[4] = Texture("assets/skybox/miramar_up.jpg");
textures[5] = Texture("assets/skybox/miramar_dn.jpg");
vertices = {
-1,-1,-1, 0,1,
-1,1,-1, 0,0,
1,1,-1, 1,0,
-1,-1,-1, 0,1,
1,1,-1, 1,0,
1,-1,-1, 1,1,
1,-1,1, 0,1,
1,1,1, 0,0,
1,1,-1, 1,0,
1,-1,1, 0,1,
1,1,-1, 1,0,
1,-1,-1, 1,1,
-1,-1,1, 0,1,
-1,1,1, 0,0,
1,1,1, 1,0,
-1,-1,1, 0,1,
1,1,1, 1,0,
1,-1,1, 1,1,
-1,-1,-1, 0,1,
-1,1,-1, 0,0,
-1,1,1, 1,0,
-1,-1,-1, 0,1,
-1,1,1, 1,0,
-1,-1,1, 1,1,
-1,1,-1, 0,1,
-1,1,1, 0,0,
1,1,1, 0,1,
-1,1,-1, 0,1,
1,1,1, 0,1,
1,1 -1, 1,1,
-1,-1,-1, 0,1,
-1,-1,1, 0,0,
1,-1,1, 1,0,
-1,-1,-1, 0,1,
1,-1,1, 1,0,
1,-1,-1, 1,1,
};
for(unsigned int i=0;i<vertices.size();i+=5){
vertices[i] *= 300.0f;
vertices[i + 1] *= 300.0f;
vertices[i + 2] *= 300.0f;
}
float fRad = 1.0f / tanf(90.0 / 2.0f * 3.14159f / 180.0f);
float far = 1000.0f, near = 0.1f;
proj[0][0] = fRad * 9.0f / 16.0f;
proj[1][1] = fRad;
proj[2][2] = 2.0f / (far - near);
proj[3][2] = (far + near) / (far - near);
proj[2][3] = 1.0f;
vb = new VertexBuffer(vertices.data(),sizeof(float) * vertices.size(), GL_STATIC_DRAW);
va.bind();
vb->bind();
va.addVertexAttribute( 3, GL_FLOAT, false);
va.addVertexAttribute( 2, GL_FLOAT, false);
shader = new Program("Shaders/skybox.shader");
}
Skybox::~Skybox()
{
delete vb;
delete shader;
free(textures);
}
void Skybox::draw(){
va.bind();
vb->bind();
shader->bind();
shader->setUniformMatrix4fv("projection",1,false,proj[0]);
for (unsigned int i = 0; i < 6; i++) {
textures[i].bind(0);
glDrawArrays(GL_TRIANGLES,i*6,6);
}
}
|
fd518260c86567029c1104cafa4cb635efbf85f5
|
67d4b73fa612c33ccd33ab7bd98ebf185ceb4fe2
|
/DataMag/TagPathLink.h
|
eb8bb47efb674e747ac51c82ad1348298249058b
|
[
"Apache-2.0"
] |
permissive
|
lvan100/DataMag
|
5b13086f3fea8c6f6fa3c01bf0ede33b4e1fa0ea
|
a9995c3af1f08b62d6cb64c9dad43e083f790369
|
refs/heads/master
| 2020-12-25T17:25:47.013698
| 2016-08-10T09:07:50
| 2016-08-10T09:07:50
| 37,748,519
| 3
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,369
|
h
|
TagPathLink.h
|
#pragma once
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#include "HilitButton.h"
/**
* 反射自身的按钮点击事件
*/
typedef function<void(CMFCButton*)> ReflactClickEvent;
/**
* 链接路径控件的子按钮
*/
class CPathLinkButton : public CHilitButton
{
DECLARE_DYNAMIC(CPathLinkButton)
public:
CPathLinkButton();
virtual ~CPathLinkButton();
/**
* 按钮点击事件
*/
ReflactClickEvent clickEvent;
DECLARE_MESSAGE_MAP()
protected:
afx_msg void OnBnDoubleclicked();
};
/**
* 路径发生变化的事件
*/
typedef function<void(CString)> PathChangedEvent;
/**
* 标签路径控件
*/
class CTagPathLink : public CStatic
{
DECLARE_DYNAMIC(CTagPathLink)
public:
CTagPathLink();
virtual ~CTagPathLink();
/**
* 设置链接路径
*/
void SetLinkPath(CString strPath);
/**
* 子按钮事件响应
*/
void OnPathBtnClicked(CMFCButton* pBtn);
/**
* 当双击子按钮的时候触发该事件
*/
PathChangedEvent mPathChangedEvent;
protected:
/**
* 销毁所有子按钮
*/
void ClearPathLinkButtons();
protected:
/**
* 路径按钮
*/
vector<CWnd*> m_path_btns;
protected:
virtual BOOL OnInitControl();
virtual void PreSubclassWindow();
DECLARE_MESSAGE_MAP()
protected:
afx_msg void OnDestroy();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
|
04c7cc78b74c766493bc9dffcad74220867cad04
|
c79e45a4f65eda2a32368025739b218ea6f9d71f
|
/AMT830-0131_old/Screen_Main.h
|
c5145fc6e649b266892019166fa194cd6aed7569
|
[] |
no_license
|
ybs0111/AMT830
|
d3c2ad6ae593ff16d7d4e8cc48908803f6752455
|
39791856ee2c6e17d24b9aa6a4434790c7dc2801
|
refs/heads/master
| 2020-04-06T04:42:59.512039
| 2017-08-11T03:40:44
| 2017-08-11T03:40:44
| 82,889,436
| 0
| 1
| null | null | null | null |
UHC
|
C++
| false
| false
| 12,439
|
h
|
Screen_Main.h
|
#if !defined(AFX_SCREEN_MAIN_H__7A483F1B_61FF_4EB9_B41D_251A637D6074__INCLUDED_)
#define AFX_SCREEN_MAIN_H__7A483F1B_61FF_4EB9_B41D_251A637D6074__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Screen_Main.h : header file
//
#include "Variable.h" // 전역 변수 정의 클래스 추가
#include "Public_Function.h"
#include "NewLabel.h" // 칼라 텍스트 박스 생성 클래스 추가
#include "editex.h" // 칼라 에디트 박스 생성 클래스 추가
#include "BtnST.h" // 칼라 버튼 생성 클래스 추가
#include "XPGroupBox.h" // 칼라 그룹 박스 생성 클래스 추가
#include "sxlogfont.h"
#include "LedButton.h" // LED 버튼 클래스
#include "EXDigitST.h" // 디지털 카운터 생성 클래스 추가
#include "MacButtons.h"
#include "Digit.h"
#include "GradientStatic.h" // 그라데이션 칼라 텍스트 박스 생성 클래스 추가
#include "CheckerCtrl.h"
#include "Picture.h"
#include "FloatST.h"
#include "MyBasicData.h"//20120924
#include "PictureEx.h" // GIF 파일을 로딩하기 위한 클래스 추가
#include "BmpImageST.h" // 알람 비트맵 로딩 클래스 추가
#include "Animate.h"
#define TM_LOTEND_READY 5990
#define TM_BCR_HS_DATA_RESET 5991//20120924
/////////////////////////////////////////////////////////////////////////////
// CScreen_Main form view
#ifndef __AFXEXT_H__
#include <afxext.h>
#endif
class CScreen_Main : public CFormView
{
public:
int m_npos;
TSpread *m_grid_lot;
TSpread *m_grid_status;
TSpread *m_grid_time;
GridControlAlg m_p_grid;
CAnimate m_Animate;
public:
CScreen_Main(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CScreen_Main)
// Form Data
public:
//{{AFX_DATA(CScreen_Main)
enum { IDD = IDD_SCREEN_MAIN };
CMacButton m_clip_recovery;
CMacButton m_clip_remove;
CMacButton m_btn_multilot_init;
CMacButton m_btn_viscnt_reset;
CMacButton m_btn_lot_cancel;
CButtonST m_pad_bcr_id4_1;
CButtonST m_pad_bcr_id3_1;
CButtonST m_pad_bcr_id2_1;
CButtonST m_pad_bcr_id_1;
CXPGroupBox m_group_buffer_status;
CMacButton m_btn_door_open;
CDigit m_dgt_alarm;
CDigit m_dgt_mtbi;
CGradientStatic m_msg_wrun;
CGradientStatic m_msg_stop;
CGradientStatic m_msg_run;
CGradientStatic m_msg_brun;
CGradientStatic m_msg_change;
CGradientStatic m_msg_alarm;
CGradientStatic m_msg_mtbi;
CXPGroupBox m_group_daily_yield_info;
CXPGroupBox m_group_time_info;
CXPGroupBox m_group_lot_info;
CXPGroupBox m_group_lot_yield_info;
CDigit m_dgt_stop;
CDigit m_dgt_run;
CMacButton m_btn_lot_open; //20120522
CButtonST m_pad_bcr_id;
CButtonST m_pad_bcr_id2;
CButtonST m_pad_bcr_id3;
CButtonST m_pad_bcr_id4;
CFloatST m_msg_bcr_id;
CFloatST m_msg_bcr_id2;
CFloatST m_msg_bcr_id3;
CFloatST m_msg_bcr_id4;
CXPGroupBox m_group_bcr_set;
CXPGroupBox m_group_jobchange;
CXPGroupBox m_group_jobchange2;
CEditEx m_edit_bcr_id;
CEditEx m_edit_bcr_id2;
CEditEx m_edit_bcr_id3;
CEditEx m_edit_bcr_id4;
CEditEx m_edit_bcr_id_1;
CEditEx m_edit_bcr_id2_1;
CEditEx m_edit_bcr_id3_1;
CEditEx m_edit_bcr_id4_1;
//}}AFX_DATA
// Attributes
public:
CFont* mp_main_font; // 폰트 정보 설정 변수
CFont* mp_main_big_font; // 폰트 정보 설정 변수
int Init_Multistep;
int mn_time_select;
int mn_retest_onoff[4];
int mn_motor_site;
int mn_stacker_Step;
int mn_air_blow_check[2];
CString mstr_rear_buffer[2];
int mn_rear_buffer[2];
int mnDeviceExistence;
/////////////////////////// 20120924
long l_bcr_send_wait[3];
long l_hs_send_wait[3];
int bcr_retry;
int hs_retry;
CMyBasicData mcls_m_main; // 기본 셋팅 정보 로딩 및 저장 클래스
///////////////////////////
GridControlAlg m_pGrid;
CPicture m_p_bmp_view;
CPicture m_p_bmp_view1;
CPicture m_p_bmp_view2;
CPicture m_p_bmp_view3;
CPicture m_p_bmp_view4;
CPicture m_p_bmp_view5;
CPicture m_p_bmp_view6;
CPicture m_p_bmp_view7;
CPicture m_p_bmp_view8;
CPicture m_p_bmp_view9;
CPicture m_p_bmp_view10;
CPicture m_p_bmp_view11;
///////////////////////////////////// 20120707
CCheckerCtrl m_ctrl_loader_tray;
CCheckerCtrl m_ctrl_hs_left_tray;
CCheckerCtrl m_ctrl_hs_right_tray;
CCheckerCtrl m_ctrl_clip1_tray;
CCheckerCtrl m_ctrl_clip2_tray;
CCheckerCtrl m_ctrl_unloader_tray;
CCheckerCtrl m_ctrl_reject_tray;
CCheckerCtrl m_ctrl_loader_picker;
CCheckerCtrl m_ctrl_hs_left_picker;
CCheckerCtrl m_ctrl_hs_right_picker;
CCheckerCtrl m_ctrl_clip1_picker;
CCheckerCtrl m_ctrl_clip2_picker;
CCheckerCtrl m_ctrl_unloader_picker;
CCheckerCtrl m_ctrl_reject_picker;
CCheckerCtrl m_ctrl_sorter_picker;
/////////////////////////////////////
CString mstr_bcr_id[2];
CString mstr_bcr_id2[2];
CString mstr_bcr_id3[2];
CString mstr_bcr_id4[2];
CString mstr_bcr_id_1[2];
CString mstr_bcr_id2_1[2];
CString mstr_bcr_id3_1[2];
CString mstr_bcr_id4_1[2];
int StopFlag;
int CancelFlag;
int StartFlag;
int InitialFlag;
int SimuelFlag;
int m_bExeExcute;
int m_Tray;
int m_remove_step;
int m_recorvery_step;
int m_stacker_step;
int mn_retry;
char mc_alarmcode[10];
long l_Until_WaitTime[3];
int ClipBufferStep;
int mn_Clipretry;
int m_remove_flag;
int m_recorvery_flag;
int n_clipremove_step;
int n_cliprecovery_step;
char cJamcode[10];
/////////////////////////////////////////////////////////////////////////////////
// Operations
public:
void OnMain_Display_CycleTime_Info();
void OnMain_Display_Daily_Yield_info();
void OnMain_Display_Lot_Yield_info();
void OnMain_Display_Lot_Info();
void Device_Lot_Display(int part, int pos);
void Device_Info_Display(int part, int pos);
void OnMain_Init_Lot_Info();
void OnMain_Init_Daily_Yield_info();
void OnMain_Init_Lot_Yield_info();
void OnMain_TimeInfo_Display();
void OnMain_Time_Display(int n_state);
void OnMain_Digital_Count_Set();
void OnMain_Label_Set();
void GridMerge(UINT nID, int srow, int scol, int nrow, int ncol);
void GridFont(UINT nID, int row, int col, int size);
void GridData(UINT nID, int row, int col, CString data);
void GridControl(UINT nID, int type, int row, int col, int pos);
void GridColor(UINT nID, int row, int col, COLORREF bk, COLORREF tk);
void OnMain_GroupBox_Set();
void OnMain_Data_Set();
void OnMain_BCR_DISPLAY(int n_state); //20120524
void UpdateScreens();
void UpdateMotorMove();
void Init_Animation();
////////////////////////////////////////// 20120704
void OnMain_CheckerCtrl_Set();
void OnMainWork_Tray_Display(int iSite);
void OnMainWork_Picker_Display(int iSite);
//////////////////////////////////////////////
void Init_Grid_Lot();//20120711
void OnMain_Init_Grid();
void OnMain_Display_VisionBuffer();
void OnMainWork_RejectTray_Change();
void OnMainLotReStart_Display();
void OnMainMulLotDisplay();
void EnableButton(int iEnable);
void MoveStepClear();
int ClipRemove();
int ClipRecovery();
int LdUldClipBufferPos(int nPos);
int OnRemoveClip();
int OnRecoveryClip();
////////
int OnStackerDown(int nMotorNum);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CScreen_Main)
public:
virtual void OnInitialUpdate();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CScreen_Main();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
//{{AFX_MSG(CScreen_Main)
afx_msg void OnDestroy();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnBtnDoorOpen();
afx_msg void OnBtnLotOpen(); //20120522
afx_msg void OnPadBcrId();
afx_msg void OnPadBcrId2();
afx_msg void OnPadBcrId3();
afx_msg void OnPadBcrId4();
afx_msg void OnSetfocusEditBcrId();
afx_msg void OnSetfocusEditBcrId2();
afx_msg void OnSetfocusEditBcrId3();
afx_msg void OnSetfocusEditBcrId4();
afx_msg void OnSetfocusEditBcrId_1();
afx_msg void OnSetfocusEditBcrId2_1();
afx_msg void OnSetfocusEditBcrId3_1();
afx_msg void OnSetfocusEditBcrId4_1();
afx_msg void OnBtnWorkInformation();
afx_msg void OnPadBcrId1();
afx_msg void OnPadBcrId21();
afx_msg void OnPadBcrId31();
afx_msg void OnPadBcrId41();
afx_msg void OnBtnLotCancel();
afx_msg void OnBtnVisionCntReset();
afx_msg void OnBtnMultilotInit();
afx_msg void OnBtnWorkInformation2();
afx_msg void OnBtnWorkInformation3();
afx_msg void OnBtnWorkbuffer1Mdpos();
afx_msg void OnBtnWorkbuffer1Lhpos();
afx_msg void OnBtnWorkbuffer1Rhspos();
afx_msg void OnWorkbuffer1Clip();
afx_msg void OnBtnWorkbuffer1Uldpos();
afx_msg void OnBtnWorkbuffer2Mdpos();
afx_msg void OnBtnWorkbuffer2Lhpos();
afx_msg void OnBtnWorkbuffer2Rhspos();
afx_msg void OnWorkbuffer2Clip();
afx_msg void OnBtnWorkbuffer2Uldpos();
afx_msg void OnBtnWorkbuffer3Mdpos();
afx_msg void OnBtnWorkbuffer3Lhpos();
afx_msg void OnBtnWorkbuffer3Rhspos();
afx_msg void OnWorkbuffer3Clip();
afx_msg void OnBtnWorkbuffer3Uldpos();
afx_msg void OnBtnWorkbuffer4Mdpos();
afx_msg void OnBtnWorkbuffer4Lhpos();
afx_msg void OnBtnWorkbuffer4Rhspos();
afx_msg void OnWorkbuffer4Clip();
afx_msg void OnBtnWorkbuffer4Uldpos();
afx_msg void OnBtnMdrobotWorkpos1();
afx_msg void OnBtnMdrobotWorkpos2();
afx_msg void OnBtnMdrobotWorkpos3();
afx_msg void OnBtnMdrobotWorkpos4();
afx_msg void OnBtnMdrobotInit();
afx_msg void OnBtnLhsrobotWorkpos1();
afx_msg void OnBtnLhsrobotWorkpos2();
afx_msg void OnBtnLhsrobotWorkpos3();
afx_msg void OnBtnLhsrobotWorkpos4();
afx_msg void OnBtnLhsrobotInit();
afx_msg void OnBtnRhsrobotWorkpos1();
afx_msg void OnBtnRhsrobotWorkpos2();
afx_msg void OnBtnRhsrobotWorkpos3();
afx_msg void OnBtnRhsrobotWorkpos4();
afx_msg void OnBtnRhsrobotInit();
afx_msg void OnBtnClipinsertWorkpos1();
afx_msg void OnBtnClipinsertWorkpos2();
afx_msg void OnBtnClipinsertWorkpos3();
afx_msg void OnBtnClipinsertWorkpos4();
afx_msg void OnBtnClipinsertInit();
afx_msg void OnBtnClipclampWorkpos1();
afx_msg void OnBtnClipclampWorkpos2();
afx_msg void OnBtnClipclampWorkpos3();
afx_msg void OnBtnClipclampWorkpos4();
afx_msg void OnBtnSorterrbtWorkpos1();
afx_msg void OnBtnSorterrbtWorkpos2();
afx_msg void OnBtnSorterrbtWorkpos3();
afx_msg void OnBtnSorterrbtWorkpos4();
afx_msg void OnBtnSorterrbtInit();
afx_msg void OnPaint();
afx_msg void OnBtnUldrobotVisionPick();
afx_msg void OnBtnUldrobotDown();
afx_msg void OnBtnSimuelInit();
afx_msg void OnBtnWorkbuffer1Init();
afx_msg void OnBtnWorkbuffer2Init();
afx_msg void OnBtnWorkbuffer3Init();
afx_msg void OnBtnWorkbuffer4Init();
afx_msg void OnBtnMdrobotDown();
afx_msg void OnBtnLhsrobotDown();
afx_msg void OnBtnRhsrobotDown();
afx_msg void OnBtnClipinsertDown();
afx_msg void OnBtnClipclampDown();
afx_msg void OnBtnSorterDown();
afx_msg void OnBtnUldrbtDown();
afx_msg void OnBtnUldrbtInit();
afx_msg void OnBtnClipclampUp();
afx_msg void OnBtnMdrobotUp();
afx_msg void OnBtnLhsrobotUp();
afx_msg void OnBtnRhsrobotUp();
afx_msg void OnBtnClipinsertUp();
afx_msg void OnBtnSorterUp();
afx_msg void OnBtnUldrbtUp();
afx_msg void OnBtnClipCapRemove();
afx_msg void OnBtnClipCapReset();
afx_msg void OnBtnMDTrayLockOnOff();
afx_msg void OnBtnLHTrayLockOnOff();
afx_msg void OnBtnRHTrayLockOnOff();
afx_msg void OnBtnMDStackerDown();
afx_msg void OnBtnLHStackerDown();
afx_msg void OnBtnRHStackerDown();
afx_msg void OnBtnSerialNo();
afx_msg void OnSetfocusEditSerialNo();
afx_msg void OnSetfocusEditLotNo();
afx_msg void OnBtnUmdStacker2TrayLockOnoff();
afx_msg void OnBtnBarcodePrintReset();
//}}AFX_MSG
// afx_msg void OnCellClick(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnMain_Work_Info_Display(WPARAM wParam,LPARAM lParam); // 테스트 결과 정보 화면에 출력하기 위한 사용자 정의 메시지 추가
// afx_msg LRESULT OnReceivedNewLot( WPARAM wParam, LPARAM lParam );
// afx_msg LRESULT OnDrawLotTime( WPARAM wParam, LPARAM lParam );
// afx_msg LRESULT OnDrawWorkSite( WPARAM wParam, LPARAM lParam );
afx_msg void OnCellClick(WPARAM wParam, LPARAM lParam); //20120711
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SCREEN_MAIN_H__7A483F1B_61FF_4EB9_B41D_251A637D6074__INCLUDED_)
|
da70ad36236e2ea9d14c5c3395342cda2a1d1927
|
cf7ae4ac2644daa52e0f7c5ae30c72b66d15fc7f
|
/LayoutEditor/LayoutEditorCore/Common/EditorCoreBase.cpp
|
8b50ad2f11dbab52fbe11d1404680929fb831ec8
|
[] |
no_license
|
ZHOURUIH/GameEditor
|
13cebb5037a46d1c414c944b4f0229b26d859fb5
|
eb391bd8c2bec8976c29047183722f90d75af361
|
refs/heads/master
| 2023-08-21T10:56:59.318660
| 2023-08-10T16:33:40
| 2023-08-10T16:33:40
| 133,002,663
| 18
| 21
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,001
|
cpp
|
EditorCoreBase.cpp
|
#include "EditorCoreBase.h"
#include "EditorCoreRoot.h"
EditorCoreRoot* EditorCoreBase::mEditorCoreRoot = NULL;
CoreEventSystem* EditorCoreBase::mCoreEventSystem = NULL;
ECUndoManager* EditorCoreBase::mUndoManager = NULL;
ActionTreeEditorCore* EditorCoreBase::mActionTreeEditorCore = NULL;
ComponentEditorCore* EditorCoreBase::mComponentEditorCore = NULL;
LayoutEditorCore* EditorCoreBase::mLayoutEditorCore = NULL;
TremblingEditorCore* EditorCoreBase::mTremblingEditorCore = NULL;
void EditorCoreBase::notifyConstructDone()
{
if (mEditorCoreRoot == NULL)
{
mEditorCoreRoot = EditorCoreRoot::getSingletonPtr();
mCoreEventSystem = mEditorCoreRoot->getCoreEventSystem();
mUndoManager = mEditorCoreRoot->getUndoManager();
mActionTreeEditorCore = mEditorCoreRoot->getActionTreeEditorCore();
mComponentEditorCore = mEditorCoreRoot->getComponentEditorCore();
mLayoutEditorCore = mEditorCoreRoot->getLayoutEditorCore();
mTremblingEditorCore = mEditorCoreRoot->getTremblingEditorCore();
}
}
|
3be71254a770fb0cf93e4a2145547896b3a52100
|
ce9149fc317e62cc5c1cc68ec9c3813830eb3fbf
|
/color.h
|
bfcaa3b89e4c24f213f76fe197b82653024bc346
|
[] |
no_license
|
rasmusbonnedal/raytrace
|
5c35abab6d1299c5e0b723f992e00b16806e26b6
|
30a8eec35717e2aedcbde93cdee1747c7b219527
|
refs/heads/master
| 2020-03-10T02:37:13.867232
| 2018-04-14T21:06:41
| 2018-04-14T21:06:41
| 129,140,954
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 532
|
h
|
color.h
|
#pragma once
#include "vecmath.h"
#include <algorithm>
class Color8
{
public:
Color8(unsigned char r, unsigned char g, unsigned char b) : r(r), g(g), b(b)
{
}
unsigned char r, g, b;
};
class Color
{
public:
Color() {}
Color(const Vec3d& v) : r(v.x), g(v.y), b(v.z) {}
Color8 clamp() const { return Color8(clamp(r), clamp(g), clamp(b)); }
double r, g, b;
private:
static unsigned char clamp(double v)
{
return std::max(0, std::min(255, static_cast<int>(v * 255.0)));
}
};
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.