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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e3091915e81f6adf471c4df38254f93661b740d9 | ef4028d8ff4e38fea80a6fefc567bb888dd5290f | /Pool/rush00/classes/A_Physical.cpp | 525b3036f2d104e51a75b823b5a5f656422f438a | [] | no_license | gmarais/Cpp | 8e1418428318a3c22aa02c2abede4f3adfe326f8 | f862f7ecd3d8585dcb90b0a9ea95d6fd72b93ce8 | refs/heads/master | 2020-12-24T16:32:53.377432 | 2016-05-18T00:26:08 | 2016-05-18T00:26:08 | 28,862,441 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,085 | cpp | A_Physical.cpp | // ************************************************************************** //
// //
// ::: :::::::: //
// A_Physical.cpp :+: :+: :+: //
// +:+ +:+ +:+ //
// By: gmarais <gmarais@student.42.fr> +#+ +:+ +#+ //
// +#+#+#+#+#+ +#+ //
// Created: 2015/01/11 03:21:11 by gmarais #+# #+# //
// Updated: 2015/01/12 02:32:17 by cdescat ### ########.fr //
// //
// ************************************************************************** //
#include "A_Physical.hpp"
//--------------------------------------------------------------/ STATICS INIT /
//------------------------------------------------------/ CONSTRUCT & DESTRUCT /
A_Physical::A_Physical()
{
}
A_Physical::A_Physical(int height, int width, t_rows *rows, int color, v2 position) :
A_Shape(height, width, rows, color, position)
{
// std::cout << "BONJOUR PHYSICAL" << std::endl;
}
A_Physical::A_Physical(A_Physical const & src) :
A_Shape(src)
{
*this = src;
}
A_Physical::~A_Physical()
{
}
//-----------------------------------------------------------------/ FUNCTIONS /
//-----------------------------------------------------------------/ OPERATORS /
A_Physical & A_Physical::operator=(A_Physical const & rhs)
{
(void)rhs;
// @TODO : COPY ATTRIBUTES HERE.
return *this;
}
//-------------------------------------------------------------/ OUTSIDE SCOPE /
bool A_Physical::collide(v2 *pos) const // 0 for collision, else 1.
{
v2 curr;
int rel_x;
int rel_y;
curr = this->getPosition();
if (pos->x < curr.x || curr.x + this->getWidth() < pos->x
|| pos->y < curr.y || curr.y + this->getHeight() < pos->y)
return 1;
else
{
rel_x = pos->x - curr.x;
rel_y = pos->y - curr.y;
}
if ((rel_x = pos->x - this->getRows()[rel_y]->indent - curr.x) < 0)
return 1;
return 0;
}
bool A_Physical::collide(A_Shape &shape) const
{
v2 curr;
v2 pos;
int rel_x;
int rel_y;
int rel_y2;
int s_width;
int s_height;
pos = shape.getPosition();
curr = this->getPosition();
s_width = shape.getWidth();
s_height = shape.getHeight();
if (pos.x + s_width < curr.x || curr.x + this->getWidth() < pos.x
|| pos.y + s_height < curr.y || curr.y + this->getHeight() < pos.y)
return 1;
else
rel_y = pos.y - curr.y;
rel_y2 = 0;
if (rel_y < 0)
{
rel_y2 = rel_y * -1;
rel_y = 0;
}
while (rel_y < this->getHeight() && rel_y2 < s_height)
{
rel_x = pos.x + shape.getRows()[rel_y2]->indent - this->getRows()[rel_y]->indent - curr.x;
if (rel_x < 0 && (unsigned int)(-rel_x) < shape.getRows()[rel_y2]->data.length())
return 1;
else if ((unsigned int)rel_x < this->getRows()[rel_y]->data.length())
return 1;
rel_y++;
rel_y2++;
}
return 1;
}
|
05da174e909bcc0b514a123312f7f13ef4a1ed4f | 2800913a2385d7039e815909d77a9d2d34dce926 | /examples/simple/main.cpp | d7f9539264acfe7ebc733a37373ba78c505a13d4 | [] | no_license | beadle/wheel_timer | ee18253b74888fd35cfc6cd95ac4a2953e343ce7 | 2b569c8212d386b43632a4c8dfa5a2386b34d9c5 | refs/heads/master | 2020-03-22T19:46:52.910108 | 2018-07-11T09:16:32 | 2018-07-11T09:16:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 112 | cpp | main.cpp | #include <iostream>
#include "wheel_timer.h"
int main()
{
std::cout << "Hello wheel_timer!" << std::endl;
}
|
2c79dc031d92a80530b4500704d9c2e33f29db94 | 85d692766d062b3346ef8b0b80b16e05b267ede4 | /src/main.cpp | 259aeb1191f0e95f2bf886d037117b5cbd618716 | [] | no_license | vakhrymchuk/roborace | ab0a086fd2dab480ebbeeed40f4cfcb9d7951f6b | 310b5d26c2c2a1beb2ae6e81f8306e1a2f106bf0 | refs/heads/master | 2021-01-10T02:13:58.278795 | 2020-02-03T09:01:23 | 2020-02-03T09:01:23 | 52,906,254 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,446 | cpp | main.cpp | /**
* @author Valery Akhrymchuk
*/
#include <Arduino.h>
//#include <Wire.h>
//#include <MemoryFree.h>
//#define DEBUG true
#if defined(BLUETOOTH_ENABLE)
#include "RoboraceBluetooth.h"
#elif defined(DISPLAY_ENABLE)
#include "RoboraceDisplay.h"
#elif defined(CONFIG_VALUES_ENABLE)
#include "RoboraceConfigValues.h"
#elif defined(NRF_ENABLE)
#include "RoboraceNrf.h"
#elif defined(JOYSTICK_ENABLE)
#include "RoboraceJoystick.h"
#else
#include "Roborace.h"
#endif
Roborace *roborace;
Roborace *createRoborace() {
#if defined(BLUETOOTH_ENABLE)
return new RoboraceBluetooth();
#elif defined(DISPLAY_ENABLE)
return new RoboraceDisplay();
#elif defined(CONFIG_VALUES_ENABLE)
return new RoboraceConfigValues();
#elif defined(NRF_ENABLE)
return new RoboraceNrf();
#elif defined(JOYSTICK_ENABLE)
return new RoboraceJoystick();
#else
return new Roborace();
#endif
}
void setup() {
#ifdef FREE_RUN_MODE
ADC_setup();
#endif
#ifdef VL53
Wire.begin();
Wire.setClock(400000);
#endif
#ifdef DEBUG
Serial.begin(115200);
// Serial.print(F("free memory="));
// Serial.println(freeMemory());
#endif
roborace = createRoborace();
// ButtonPullUp rightWallBtn(3);
// if (rightWallBtn.read()) {
// roborace->activeStrategy = &Strategy::rightWall;
// }
#ifdef DEBUG
// Serial.print(F("free memory="));
// Serial.println(freeMemory());
#endif
}
void loop() {
roborace->loop();
}
|
1423c8ccefee0e134a6cf185137a809f75988556 | 6fe2221b32d76c14cc6a8b025133b7a5604398b9 | /collect then all/game.cpp | 7dc5ebde06089556e2b188922180437066a4bb6b | [] | no_license | VanceZhou/Collect-Them-All | c0a17b8c430d96b1e478725ff198e8e7d36b60d3 | ef0ddb99f9c1515895bf0db869f96d7c0255c19b | refs/heads/main | 2023-04-11T14:49:37.936864 | 2021-04-13T18:49:56 | 2021-04-13T18:49:56 | 357,656,617 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,603 | cpp | game.cpp | #include "game.hpp"
#include "interface_type.hpp"
#include "view.hpp"
#include "curses_view.hpp"
#include "curses_controller.hpp"
// #include "print_view.cpp"
// #include "view.cpp"
// #include "print_controller.cpp"
// #include "map_segment.cpp"
#include "map_segment.hpp"
#include "print_view.hpp"
#include "print_controller.hpp"
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
// These should not have been here in the first place...
// #define INVALID_GAME_FILE_MSG "Invalid game input file"
// #define INVALID_LEVEL_FILE_MSG "Invalid level input file"
// #define INVALID_VIEW_TYPE_MSG "Invalid view type"
const int Game::MIN_VIEW_HEIGHT = 15;
const int Game::MIN_VIEW_WIDTH = 15;
const char Game::HERO_ICON_LEFT = '<';
const char Game::HERO_ICON_RIGHT = '>';
const char Game::HERO_ICON_UP = '^';
const char Game::HERO_ICON_DOWN = 'v';
Game::Game(const std::string &filename, InterfaceType interfaceType)
: mView{nullptr}, mController{nullptr}, mInterfaceType{interfaceType}
{
int i = 0;
currentLV = 1;
ifstream gameInfo;
gameInfo.open(filename);
if (gameInfo.is_open())
{
while (!gameInfo.eof())
{
if (i == 0)
{
gameInfo >> viewLenght >> viewWidth;
}
else if (i == 1)
{
gameInfo >> MaxLevel;
}
else
{
string mapLine;
gameInfo >> mapLine;
mapInfo.push_back(mapLine);
}
i++;
}
mapInfo.pop_back();
}
else
{
cout << "invalid file name" << endl;
}
//set up controller and view type
if (mInterfaceType == InterfaceType ::Print)
{
mView = new PrintView{viewLenght, viewWidth};
mController = new PrintController;
}
else
{
mView = new CursesView{viewLenght, viewWidth};
mController = new CursesController;
}
}
Game::~Game()
{
delete mView;
delete mController;
}
void Game::draw()
{
if (InterfaceType::Curses == mInterfaceType)
{
cout << "Level: " << currentLV << '\r' << endl;
cout << "Items remaining: " << numItem << '\r' << endl;
cout << "Moves remaining: " << steps << '\r' << endl;
}
else
{
cout << "Level: " << currentLV << endl;
cout << "Items remaining: " << numItem << endl;
cout << "Moves remaining: " << steps << endl;
}
}
void Game::loadLevel()
{
numItem = 0;
int i = 0;
char Item;
string fileName = "Example Game Files/";
fileName = fileName + mapInfo[currentLV - 1];
ifstream levelInfo;
levelInfo.open(fileName);
if (levelInfo.is_open())
{
while (!levelInfo.eof())
{
if (i == 0)
{
// start with map with ID
levelInfo >> ID;
}
else if (i == 1)
{
// person coordinate
levelInfo >> personY >> personX;
}
else if (i == 2)
{
// person facing direction
levelInfo >> IniDirection;
for (unsigned i = 0; i < Direction.size(); i++)
{
if (!Direction[i].compare(IniDirection))
{
heroFacing = i;
}
}
}
else
{
levelInfo >> Item;
switch (Item)
{
case 'M':
{
vector<int> intHolder;
int buf;
for (int i = 0; i < 2; i++)
{
levelInfo >> buf;
intHolder.push_back(buf);
}
map_SegInfo.push_back(intHolder);
break;
}
case 'B':
{
vector<int> intHolder;
int buf;
for (int i = 0; i < 3; i++)
{
levelInfo >> buf;
intHolder.push_back(buf);
}
BuildingInfo.push_back(intHolder);
break;
}
case 'I':
{
vector<int> intHolder;
int buf;
for (int i = 0; i < 3; i++)
{
levelInfo >> buf;
intHolder.push_back(buf);
}
targetInfo.push_back(intHolder);
numItem++;
break;
}
case 'P':
{
int PID;
string PDire;
levelInfo >> PID;
levelInfo >> PDire;
portalID.push_back(PID);
portalDirection.push_back(PDire);
levelInfo >> PID;
levelInfo >> PDire;
portalID.push_back(PID);
portalDirection.push_back(PDire);
break;
}
case 'N':
levelInfo >> steps;
break;
}
}
i++;
}
}
else
{
cout << "not open" << endl;
}
}
void Game::drawVectorStr(const std::vector<std::string> &lines)
{
for (auto i : lines)
{
std::cout << i << std::endl;
}
}
void Game::doGameLoop()
{
}
void Game::processFinal_screen(const vector<string> map, const vector<string> view)
{
int centerX, centerY, initX, initY, map_coordinateX, map_coordinateY, replaceLen, startOfSub, endY, startOfY;
Final_Screen = view;
centerX = (viewWidth + 1) / 2;
centerY = (viewLenght + 1) / 2;
initX = centerX - personX;
initY = centerY - personY;
initX < 0 ? map_coordinateX = 0 : map_coordinateX = initX;
initY < 0 ? map_coordinateY = 0 : map_coordinateY = initY;
// for index of substring, starts at 0
if (initX > 0)
{
initX = 0;
}
if (initY > 0)
{
initY = 0;
}
startOfSub = abs(initX);
startOfY = abs(initY);
// calculate the length of the X string need to be replace
int X = viewWidth - map_coordinateX - map[0].length() - initX;
int Y = viewLenght + 2 - map_coordinateY - map.size() - initY;
X >= 0 ? replaceLen = initX + map[0].length() : replaceLen = viewWidth - map_coordinateX + 1;
// calculate the length of the Y string need to be replace
// cout<<X<<endl;
Y >= 0 ? endY = initY + map.size() + map_coordinateY : endY = viewLenght + 2;
for (int i = map_coordinateY; i < endY; i++)
{
Final_Screen[i].replace(map_coordinateX, replaceLen, map[startOfY].substr(startOfSub, replaceLen));
startOfY++;
}
vector<int> holder{map_coordinateX, map_coordinateX + replaceLen - 1, map_coordinateY, endY - 1};
mapCoordinate = holder;
holder.clear();
//modify the direction of arrow
Final_Screen[centerY][centerX] = DirecSymbol[heroFacing];
Final_Screen[0] = view[0];
Final_Screen[Final_Screen.size() - 1] = view[0];
for (unsigned i = 0; i < Final_Screen.size(); i++)
{
Final_Screen[i][0] = '*';
Final_Screen[i][Final_Screen[0].size() - 1] = '*';
}
if (InterfaceType::Curses == mInterfaceType)
{
for (unsigned i = 0; i < Final_Screen.size(); i++)
{
Final_Screen[i].push_back('\r');
}
}
}
void Game::update()
{
Command command;
start_over:
command = mController->getInput();
switch (command)
{
case Command::Forward:
{
// move right, personx +1; move up,personY -1
// still need to check collisions
switch (heroFacing)
{
// up
case 0:
{
// for(auto i: mapCoordinate){
// cout<< i <<endl;
// }
// auto a = mMap->personInMap(personX, personY - 1);
// auto b = mMap->NotHitBuilding(personX, personY - 1);
// cout << "personInMap:" << a << endl;
// cout << "NotHitBuilding:" << b << endl;
if (mMap->personInMap(personX, personY - 1) && mMap->NotHitBuilding(personX, personY - 1))
{
// cout << "In" << endl;
personY -= 1;
steps -= 1;
}
checkIfCrossPortal(personX, personY - 1);
break;
}
// right
case 1:
{
// auto a = mMap->personInMap(personX + 1, personY);
// auto b = mMap->NotHitBuilding(personX + 1, personY);
// cout << "personInMap:" << a << endl;
// cout << "NotHitBuilding:" << b << endl;
if (mMap->personInMap(personX + 1, personY) && mMap->NotHitBuilding(personX + 1, personY))
{
personX += 1;
steps -= 1;
}
checkIfCrossPortal(personX + 1, personY);
break;
}
// down
case 2:
{
// auto a = mMap->personInMap(personX, personY + 1);
// auto b = mMap->NotHitBuilding(personX, personY + 1);
// cout << "personInMap:" << a << endl;
// cout << "NotHitBuilding:" << b << endl;
if (mMap->personInMap(personX, personY + 1) && mMap->NotHitBuilding(personX, personY + 1))
{
personY += 1;
steps -= 1;
}
checkIfCrossPortal(personX, personY + 1);
break;
}
// left
case 3:
{
// auto a = mMap->personInMap(personX - 1, personY);
// auto b = mMap->NotHitBuilding(personX - 1, personY);
// cout << "personInMap:" << a << endl;
// cout << "NotHitBuilding:" << b << endl;
if (mMap->personInMap(personX - 1, personY) && mMap->NotHitBuilding(personX - 1, personY))
{
personX -= 1;
steps -= 1;
}
checkIfCrossPortal(personX - 1, personY);
break;
}
}
break;
}
case Command::Left:
{
if (heroFacing - 1 == -1)
{
heroFacing = 3;
}
else
{
heroFacing -= 1;
}
break;
}
case Command::Right:
{
if (heroFacing + 1 == 4)
{
heroFacing = 0;
}
else
{
heroFacing += 1;
}
break;
}
case Command::Quit:
{
quit = true;
if (InterfaceType::Curses == mInterfaceType)
{
cout << "You quit the game." << '\r' << endl;
}
else
{
cout << "You quit the game." << endl;
}
break;
}
case Command::Invalid:
{
// cout << "Invalid Move" << endl;
goto start_over;
break;
}
}
}
void Game::checkIfCrossPortal(int y, int x)
{
// cout<<"Y:"<<y<<" X:"<<x<<endl;
for (unsigned i = 0; i < localMapPortal.size(); i++)
{
// cout<<"Sour y:"<<localMapPortal[i].first[1]<<" sour x:"<<localMapPortal[i].first[2]<<endl;
// cout<<"dest ID"<<localMapPortal[i].second[0] <<" dest__Py:"<<localMapPortal[i].second[1]<<" dest__Px:"<<localMapPortal[i].second[2]<<endl;
if (localMapPortal[i].first[0] == ID && localMapPortal[i].first[2] == y && localMapPortal[i].first[1] == x)
{
// update the map info
ID = localMapPortal[i].second[0];
personY = localMapPortal[i].second[1];
personX = localMapPortal[i].second[2];
}
}
}
void Game::run()
{
//initialize all the game values
win = false;
lose = false;
quit = false;
nextLV = false;
currentLV = 1;
//load level when win the current level
if (InterfaceType::Curses == mInterfaceType)
{
// cout<<"hereeeeeeeeeeeeeeeee-----------------"<<endl;
initscr();
// newterm(NULL, stdin, stdout);
// printw("clear m,e!!!!!!!!!!!!!!!");
// refresh();
}
loadLevel();
//load another map when going into a portal or win anothor level.
// cout<<"loadLV done!"<<endl;
while (!lose && !win && !quit)
{
if (nextLV)
{
map_SegInfo.clear();
BuildingInfo.clear();
portalDirection.clear();
portalID.clear();
loadLevel();
nextLV = false;
}
MapSegment map{map_SegInfo[ID][0], map_SegInfo[ID][1], ID, BuildingInfo, targetInfo, portalID, portalDirection, map_SegInfo};
mMap = ↦
localMapPortal = mMap->getlocalPortal();
if (InterfaceType::Curses == mInterfaceType)
{
refresh();
}
// cout << "ID:" << ID << endl;
// cout << "number of portal : " << mMap->numPortal << endl;
// cout << "map H : " << mMap->getHeight() << " map W : " << mMap->getWidth() << endl;
draw();
// drawVectorStr(map.getAsLines());
processFinal_screen(mMap->getAsLines(), mView->getView());
drawVectorStr(Final_Screen);
// move(20,20);
// refresh();
update();
// refresh();
// check target
if (mMap->getHasTarget())
{
auto tempTar = mMap->gettarget();
for (auto T : tempTar)
{
if (T[0] == ID && T[1] == personY && T[2] == personX)
{
// find and erase the target
for (unsigned i = 0; i < targetInfo.size(); i++)
{
if (targetInfo[i][0] == ID && T[1] == targetInfo[i][1] && T[2] == targetInfo[i][2])
{
targetInfo.erase(targetInfo.begin() + i);
mMap->eraseTarget(i, T[1], T[2]);
}
}
// update map so it does not think it still has target
numItem -= 1;
}
}
}
checkWin_Lose();
// cout<<"current lv"<<currentLV<<endl;
// cout<<"next lv"<<nextLV<<endl;
}
if (InterfaceType::Curses == mInterfaceType)
{
endwin();
}
}
void Game::checkWin_Lose()
{
if (numItem == 0)
{
// need to load next level
currentLV += 1;
nextLV = true;
}
if (numItem == 0 && currentLV == MaxLevel + 1)
{
win = true;
// cout << "You won the game." << endl;
if (InterfaceType::Curses == mInterfaceType)
{
cout << "You won the game." << '\r' << endl;
}
else
{
cout << "You won the game." << endl;
}
}
if (steps == 0 && !win)
{
lose = true;
if (InterfaceType::Curses == mInterfaceType)
{
cout << "You lost the game." << '\r' << endl;
}
else
{
cout << "You lost the game." << endl;
}
}
}
// int main()
// {
// InterfaceType it = InterfaceType::Print;
// Game g{"Example Game Files/game1.txt", it};
// g.run();
// return 0;
// } |
205049336dd1378d8b029695198a0908b13b0f80 | 7e492c48f9cfbae6d716aeb82a8a0748a82c6635 | /WeatherModule/qmlhweathermodule.cpp | 27cc5c7887a67fc705f9b6ef789ea35cf058c57a | [] | no_license | ZEPORATH/ConfigurableHMI | 9c8ce5f68765a37b183822121e06f9edc12f556b | 701785744b8adb4ce6c9a0c3a8cd80164ace09cd | refs/heads/master | 2023-03-31T21:07:00.234585 | 2021-03-17T03:20:17 | 2021-03-17T03:20:17 | 347,443,068 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 109 | cpp | qmlhweathermodule.cpp | #include "qmlhweathermodule.h"
QmlHWeatherModule::QmlHWeatherModule(QObject *parent) : QObject(parent)
{
}
|
73430ed7ea72de0b5246253b6cfb2c0b2ea4ed4c | 955bf1af88331bc5e55d1dac908ead3bbc4c70a7 | /interrupt_test/interrupt_test.ino | 4e817504b397eff1db7c8ef82567895bd0604bde | [] | no_license | filipkarlsson/mm_sorting_machine | 27c07bc66524137224fdb5dfc92904def771a577 | 468ce5fea03699388d654a9e70e966b24cd7d1a8 | refs/heads/master | 2021-07-25T01:35:56.332674 | 2017-11-05T17:44:10 | 2017-11-05T17:44:10 | 109,535,338 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,208 | ino | interrupt_test.ino | /* M&M-sorter
* Use 8 bit-Timer2 for interupt every ms (freq 1kHz)
* for controlling steppers.
*
* Timer0 is used by Delay() micros() etc
* Timer1 is used by Servo.h
*
*/
#include "Servo.h"
// Wheel stepper_pins
#define WHEEL_IN1 8
#define WHEEL_IN2 9
#define WHEEL_IN3 10
#define WHEEL_IN4 11
#define ARM_IN1 4
#define ARM_IN2 5
#define ARM_IN3 6
#define ARM_IN4 7
#define SERVO_PIN 3
#define FORWARD 1
#define BACKWARD -1
#define STOP 0
unsigned int wheelStepperSteps = 0;
volatile int wheel_dir;
unsigned int armStepperSteps = 0;
volatile int arm_dir;
byte wheelStepperStates = B0001;
byte armStepperStates = B0001;
const byte MASK0 = B0110;
const byte MASK1 = B1100;
const byte MASK2 = B1001;
const byte MASK3 = B0011;
Servo servo;
void setup(){
Serial.begin(9600);
pinMode(WHEEL_IN1, OUTPUT);
pinMode(WHEEL_IN2, OUTPUT);
pinMode(WHEEL_IN3, OUTPUT);
pinMode(WHEEL_IN4, OUTPUT);
pinMode(ARM_IN1, OUTPUT);
pinMode(ARM_IN2, OUTPUT);
pinMode(ARM_IN3, OUTPUT);
pinMode(ARM_IN4, OUTPUT);
servo.attach(SERVO_PIN);
servo.write(93);
// Init interrupts
cli(); //stop interrupts
//set timer2 interrupt at 1kHz
TCCR2A = 0; // set entire TCCR2A register to 0
TCCR2B = 0; // same for TCCR2B
TCNT2 = 0; //initialize counter value to 0
// set compare match register for 8khz increments
OCR2A = 255;// = (16*10^6) / (8000*32) - 1 (must be <256) 249
// turn on CTC mode
TCCR2A |= (1 << WGM21);
// Set CS22 bit for 64 prescaler
TCCR2B |= (1 << CS22); // TCCR2B = TCCR2B | (1 << CS22)
// enable timer compare interrupt
TIMSK2 |= (1 << OCIE2A);
sei(); //allow interrupts
}//end setup
//timer2 interrupt 1kHz
ISR(TIMER2_COMPA_vect){
/*
* Wheel controll
*/
if(wheel_dir != 0){
byte bit0 = (MASK0 & wheelStepperStates) == 0;
byte bit1 = (MASK1 & wheelStepperStates) == 0;
byte bit2 = (MASK2 & wheelStepperStates) == 0;
byte bit3 = (MASK3 & wheelStepperStates) == 0;
if (wheel_dir == FORWARD){
wheelStepperStates = (bit1) | (bit2 << 1) | (bit3 << 2) | (bit0 << 3);
} else if (wheel_dir == BACKWARD) {
wheelStepperStates = (bit0) | (bit1 << 1) | (bit2 << 2) | (bit3 << 3);
}
PORTB = (PORTB & B11110000) | wheelStepperStates; // Set bit0-bit3 according to wheelStepperStates (= Pin 8-11 on Arduino)
wheelStepperSteps += wheel_dir;
}
/*
* Arm controll
*/
if(arm_dir != 0){
byte bit0 = (MASK0 & armStepperStates) == 0;
byte bit1 = (MASK1 & armStepperStates) == 0;
byte bit2 = (MASK2 & armStepperStates) == 0;
byte bit3 = (MASK3 & armStepperStates) == 0;
if (arm_dir == FORWARD){
armStepperStates = (bit1) | (bit2 << 1) | (bit3 << 2) | (bit0 << 3);
} else if (arm_dir == BACKWARD) {
armStepperStates = (bit0) | (bit1 << 1) | (bit2 << 2) | (bit3 << 3);
}
PORTD = (PORTD & B00001111) | armStepperStates << 4; // Set bit 7-4 in PORTD according to armStepperStates (Pin 4-7 on Arduino)
wheelStepperSteps += wheel_dir;
}
}
void loop(){
wheel_dir = FORWARD;
arm_dir = FORWARD;
delay(1000);
arm_dir = STOP;
delay(1000);
arm_dir = BACKWARD;
delay(1000);
}
|
8db3ac933f12f06ad89ed167f955bfe884bf3bfd | bc099abbab99aa6041692ae37e2bd0edd8747135 | /Ejercicios en clase/Dephtbuffer.h | bc7152607092e2ed920014695725fa1789d78a37 | [] | no_license | Jozahandy/Graficas-Computacionales-2017 | bd5144f4dcca99eb3f6f7c2b0a408fae49a68e9e | 57e97d14659d21bc6504677d18792f8b3564c2ed | refs/heads/master | 2021-01-19T14:36:58.490744 | 2017-11-25T05:52:20 | 2017-11-25T05:52:20 | 99,630,344 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 329 | h | Dephtbuffer.h | #pragma once
#include <string>
#include <GL/glew.h>
#include <GL/freeglut.h>
class Dephtbuffer
{
public:
Dephtbuffer();
~Dephtbuffer();
void Create(int resolution);
void Bind();
void Unbind();
void BindDephtMap();
void UnbindDephtMap();
private:
GLuint _framebuffer;
GLuint _depthmap;
GLsizei _resolution;
};
|
a94f7fcd90ce75487a4be143a0f54d3902f4a2cc | 676610bf5f86a8cf8ff92803af476c7c8fff829e | /include/widgets/YLabel.h | 7888c1c3ebb27de9e7fabdce7145113952ea500c | [
"Apache-2.0"
] | permissive | j-tetteroo/kobu | e0e9390f27394bf2c4392bcee025a2bc39ab0642 | 99486ee457c047a3392549bc73935d20bdbdaf93 | refs/heads/master | 2020-05-30T07:20:20.796256 | 2016-10-19T08:07:17 | 2016-10-19T08:07:17 | 68,533,583 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 308 | h | YLabel.h | #ifndef YLABEL_H
#define YLABEL_H
#include <string>
#include <cstdint>
#include "window/YWidget.h"
namespace kobu {
class YLabel : YWidget
{
private :
String label_text;
public :
YLabel(String text, float x, float y) : labelText(text), YWidget(x,y) {};
};
} // namespace kobu
#endif |
60743f518572bdccb0167770dd58583ce95faf8d | 88b130d5ff52d96248d8b946cfb0faaadb731769 | /searchcore/src/vespa/searchcore/proton/attribute/attribute_executor.cpp | 4d854bfdca1e1f9bbfa0e5427c33df9f4b03d345 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | vespa-engine/vespa | b8cfe266de7f9a9be6f2557c55bef52c3a9d7cdb | 1f8213997718c25942c38402202ae9e51572d89f | refs/heads/master | 2023-08-16T21:01:12.296208 | 2023-08-16T17:03:08 | 2023-08-16T17:03:08 | 60,377,070 | 4,889 | 619 | Apache-2.0 | 2023-09-14T21:02:11 | 2016-06-03T20:54:20 | Java | UTF-8 | C++ | false | false | 1,063 | cpp | attribute_executor.cpp | // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "attribute_executor.h"
#include "i_attribute_manager.h"
#include <vespa/searchlib/attribute/attributevector.h>
#include <vespa/vespalib/util/isequencedtaskexecutor.h>
#include <future>
using search::AttributeVector;
namespace proton {
AttributeExecutor::AttributeExecutor(std::shared_ptr<IAttributeManager> mgr,
std::shared_ptr<AttributeVector> attr)
: _mgr(std::move(mgr)),
_attr(std::move(attr))
{
}
AttributeExecutor::~AttributeExecutor() = default;
void
AttributeExecutor::run_sync(std::function<void()> task) const
{
vespalib::string name = _attr->getNamePrefix();
auto& writer = _mgr->getAttributeFieldWriter();
std::promise<void> promise;
auto future = promise.get_future();
auto id = writer.getExecutorIdFromName(name);
writer.execute(id, [&task, promise=std::move(promise)]() mutable { task(); promise.set_value(); });
future.wait();
}
} // namespace proton
|
d4529ee68307b54e1976c750f194fb82bd9e8aa3 | b57c336d191ec197df14f2e632ddba6d7b15e6bb | /utilities.cc | d188a867cfbcf68e5f7c27a3668f065e36f884d3 | [] | no_license | zencoders/ael2lua | c8058a3d16209ac4f1ab1b91d06b25033c04f730 | ca80bfbfd9b32567fc9c9298ed8827f8655527a4 | refs/heads/master | 2021-01-01T17:16:21.252169 | 2012-02-17T18:02:57 | 2012-02-17T18:02:57 | 3,444,358 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,711 | cc | utilities.cc | #include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <iterator>
#include <algorithm>
#include "utilities.h"
using namespace std;
std::string& ltrim(std::string &s)
{
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
return s;
}
std::string& rtrim(std::string& s)
{
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
}
std::string& trim(std::string& s)
{
return ltrim(rtrim(s));
}
std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems)
{
std::stringstream ss(s);
std::string item;
while(std::getline(ss, item, delim))
{
elems.push_back(item);
}
return elems;
}
std::vector<std::string> split(const std::string& s, char delim)
{
std::vector<std::string> elems;
return split(s, delim, elems);
}
vector<string> string_split(const string& s)
{
vector<string> to_ret;
istringstream iss(s);
copy(istream_iterator<string>(iss),
istream_iterator<string>(),
back_inserter<vector<string> >(to_ret));
return to_ret;
}
std::string sday2iday(const std::string& s)
{
if(s == "sun")
return "1";
else if(s == "mon")
return "2";
else if(s == "tue")
return "3";
else if(s == "wed")
return "4";
else if(s == "thu")
return "5";
else if(s == "fri")
return "6";
else if(s == "sat")
return "7";
}
std::string smonth2imonth(const std::string& s)
{
if(s == "jan")
return "1";
else if(s == "feb")
return "2";
else if(s == "mar")
return "3";
else if(s == "apr")
return "4";
else if(s == "may")
return "5";
else if(s == "jun")
return "6";
else if(s == "jul")
return "7";
else if(s == "aug")
return "8";
else if(s == "sep")
return "9";
else if(s == "oct")
return "10";
else if(s == "nov")
return "11";
else if(s == "dec")
return "12";
}
bool isNumeric( const char* pszInput, int nNumberBase )
{
std::istringstream iss( pszInput );
if ( nNumberBase == 10 )
{
double dTestSink;
iss >> dTestSink;
}
else if ( nNumberBase == 8 || nNumberBase == 16 )
{
int nTestSink;
iss >> ( ( nNumberBase == 8 ) ? std::oct : std::hex ) >> nTestSink;
}
else
return false;
// was any input successfully consumed/converted?
if ( ! iss )
return false;
// was all the input successfully consumed/converted?
return ( iss.rdbuf()->in_avail() == 0 );
}
|
35403799973cd35c80bd116c42ec1b6e1fc61e8b | 09c46a2414e674d8631731d58c2c17f8268b5a60 | /core/LocalManager/RegisterAtLMRequestHandler.cpp | fac05612c07a78c0b43ff058fb1dccbd2865ef86 | [
"MIT"
] | permissive | siemens/fluffi | 49ea030e4411ed02e60d3a5394c0a32651450598 | 70cd18deff9d688e10ec71a1eb4f38d7f2d581c0 | refs/heads/master | 2022-09-10T00:23:12.051619 | 2022-08-19T13:41:58 | 2022-08-19T13:41:58 | 209,495,395 | 102 | 24 | MIT | 2023-02-19T10:45:36 | 2019-09-19T07:55:43 | C++ | UTF-8 | C++ | false | false | 9,009 | cpp | RegisterAtLMRequestHandler.cpp | /*
Copyright 2017-2020 Siemens AG
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including without
limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Author(s): Thomas Riedmaier, Abian Blome
*/
#include "stdafx.h"
#include "RegisterAtLMRequestHandler.h"
#include "FluffiServiceDescriptor.h"
#include "FluffiSetting.h"
#include "Util.h"
#include "LMDatabaseManager.h"
#include "LMWorkerThreadState.h"
RegisterAtLMRequestHandler::RegisterAtLMRequestHandler(std::string mylocation) :
m_mylocation(mylocation),
m_myfuzzjob("NOTYETDEFINED")
{
}
RegisterAtLMRequestHandler::~RegisterAtLMRequestHandler()
{
}
void RegisterAtLMRequestHandler::setMyFuzzjob(const std::string myfuzzjob) {
m_myfuzzjob = myfuzzjob;
}
void RegisterAtLMRequestHandler::handleFLUFFIMessage(WorkerThreadState* workerThreadState, FLUFFIMessage* req, FLUFFIMessage* resp) {
LMWorkerThreadState* lmWorkerThreadState = dynamic_cast<LMWorkerThreadState*>(workerThreadState);
if (lmWorkerThreadState == nullptr) {
LOG(ERROR) << "RegisterAtLMRequestHandler::handleFLUFFIMessage - workerThreadState cannot be accessed";
return;
}
AgentType type = req->registeratlmrequest().type();
google::protobuf::RepeatedPtrField< std::string > implementedSubTypes = req->registeratlmrequest().implementedagentsubtypes();
std::stringstream oss;
for (int i = 0; i < implementedSubTypes.size(); i++) {
if (i != 0) {
oss << "|";
}
oss << implementedSubTypes.Get(i);
}
std::string subtypes = oss.str();
FluffiServiceDescriptor fsd(req->registeratlmrequest().servicedescriptor());
bool success;
LOG(DEBUG) << "Incoming registration";
LOG(DEBUG) << "Type=" << Util::agentTypeToString(type);
LOG(DEBUG) << "SubTypes=" << subtypes;
LOG(DEBUG) << "ServiceDescriptor=" << fsd.m_serviceHostAndPort;
LOG(DEBUG) << "Location=" << req->registeratlmrequest().location();
RegisterAtLMResponse* registerResponse = new RegisterAtLMResponse();
if (req->registeratlmrequest().location() != m_mylocation) {
//only accept registrations in my location
success = false;
}
else {
if ("" != lmWorkerThreadState->dbManager->getRegisteredInstanceSubType(fsd.m_guid)) {
//This agent is already in the managed instance database and it is already decided which subagent type it should have
success = true;
}
else {
//Decide which subagent type it should have and add the agent to the managed instances database
switch (type)
{
case TestcaseGenerator:
case TestcaseRunner:
case TestcaseEvaluator:
{
std::string selectedSubAgentType = decideSubAgentType(lmWorkerThreadState->dbManager, type, implementedSubTypes);
if (selectedSubAgentType == "") {
LOG(ERROR) << "decideSubAgentType was not able to determine a valid subagenttype";
success = false;
}
else {
success = lmWorkerThreadState->dbManager->writeManagedInstance(fsd, type, selectedSubAgentType, req->registeratlmrequest().location());
}
}
break;
case GlobalManager:
case LocalManager:
case AgentType_INT_MIN_SENTINEL_DO_NOT_USE_:
case AgentType_INT_MAX_SENTINEL_DO_NOT_USE_:
default:
success = false;
break;
}
}
if (success) {
registerResponse->set_fuzzjobname(m_myfuzzjob);
}
}
// response
LOG(DEBUG) << "Sending success message with status " << (success ? "true" : "false");
registerResponse->set_success(success);
resp->set_allocated_registeratlmresponse(registerResponse);
}
std::string RegisterAtLMRequestHandler::decideSubAgentType(LMDatabaseManager* dbManager, AgentType type, const google::protobuf::RepeatedPtrField<std::string>& implementedSubtypes) {
std::vector<std::pair<std::string, int>> desiredSubTypes;
std::deque<FluffiSetting> settings = dbManager->getAllSettings();
switch (type) {
case AgentType::TestcaseGenerator:
for (auto& setting : settings) {
if (setting.m_settingName == "generatorTypes") {
//generatorTypes is of format "A=50|B=50"
std::vector<std::string> acceptedGenTypesAndPercentages = Util::splitString(setting.m_settingValue, "|");
for (size_t i = 0; i < acceptedGenTypesAndPercentages.size(); i++) {
std::vector<std::string> acceptedGenTypesAndPercentagesAsVector = Util::splitString(acceptedGenTypesAndPercentages[i], "=");
if (acceptedGenTypesAndPercentagesAsVector.size() == 2) {
try {
desiredSubTypes.push_back(std::make_pair(acceptedGenTypesAndPercentagesAsVector[0], std::stoi(acceptedGenTypesAndPercentagesAsVector[1])));
}
catch (...) {
LOG(ERROR) << "std::stoi failed";
google::protobuf::ShutdownProtobufLibrary();
_exit(EXIT_FAILURE); //make compiler happy
}
}
}
break;
}
}
break;
case AgentType::TestcaseEvaluator:
for (auto& setting : settings) {
if (setting.m_settingName == "evaluatorTypes") {
//evaluatorTypes is of format "A=50|B=50"
std::vector<std::string> acceptedEvalTypesAndPercentages = Util::splitString(setting.m_settingValue, "|");
for (size_t i = 0; i < acceptedEvalTypesAndPercentages.size(); i++) {
std::vector<std::string> acceptedEvalTypesAndPercentagesAsVector = Util::splitString(acceptedEvalTypesAndPercentages[i], "=");
if (acceptedEvalTypesAndPercentagesAsVector.size() == 2) {
try {
desiredSubTypes.push_back(std::make_pair(acceptedEvalTypesAndPercentagesAsVector[0], std::stoi(acceptedEvalTypesAndPercentagesAsVector[1])));
}
catch (...) {
LOG(ERROR) << "std::stoi failed";
google::protobuf::ShutdownProtobufLibrary();
_exit(EXIT_FAILURE); //make compiler happy
}
}
}
break;
}
}
break;
case AgentType::TestcaseRunner:
for (auto& setting : settings) {
if (setting.m_settingName == "runnerType") {
desiredSubTypes.push_back(std::make_pair(setting.m_settingValue, 100));
break;
}
}
break;
default:
LOG(ERROR) << "An agent of type " << Util::agentTypeToString(type) << " wanted to have an decicion on its agent sub type. This is not implemented!";
return "";
}
if (desiredSubTypes.size() == 0) {
LOG(ERROR) << "The configuration is invalid - there is no desired agent sub type for agents of type " << Util::agentTypeToString(type);
return "";
}
//normalize desiredSubTypes to 100
{
int sumOfAllSubtypes = 0;
for (auto& subType : desiredSubTypes) {
sumOfAllSubtypes += subType.second;
}
for (auto& subType : desiredSubTypes) {
subType.second = subType.second * 100 / sumOfAllSubtypes;
}
}
std::vector<std::pair<std::string, int>> currentActiveSubtypes = dbManager->getRegisteredInstancesNumOfSubTypes();
//normalize currentActiveSubtypes to 100
{
int sumOfAllSubtypes = 0;
for (size_t i = 0; i < currentActiveSubtypes.size(); i++) {
sumOfAllSubtypes += currentActiveSubtypes[i].second;
}
for (size_t i = 0; i < currentActiveSubtypes.size(); i++) {
currentActiveSubtypes[i].second = currentActiveSubtypes[i].second * 100 / sumOfAllSubtypes;
}
}
std::map <std::string, int> desiredSubTypesAsMap;
for (size_t i = 0; i < desiredSubTypes.size(); i++) {
desiredSubTypesAsMap.insert(desiredSubTypes[i]);
}
std::map <std::string, int> currentActiveSubtypesAsMap;
for (size_t i = 0; i < currentActiveSubtypes.size(); i++) {
currentActiveSubtypesAsMap.insert(currentActiveSubtypes[i]);
}
std::map <std::string, int> subtypeDiffs;
for (int i = 0; i < implementedSubtypes.size(); i++) {
int currentVal = 0;
if (currentActiveSubtypesAsMap.find(implementedSubtypes[i]) != currentActiveSubtypesAsMap.end()) {
currentVal = currentActiveSubtypesAsMap[implementedSubtypes[i]];
}
if (desiredSubTypesAsMap.find(implementedSubtypes[i]) != desiredSubTypesAsMap.end()) {
int desiredVal = desiredSubTypesAsMap[implementedSubtypes[i]];
subtypeDiffs.insert(std::make_pair(implementedSubtypes[i], desiredVal - currentVal));
}
}
//find the subagenttype that is needed most
std::string maxIndex = "";
int maxValue = -200;
for (auto it = subtypeDiffs.begin(); it != subtypeDiffs.end(); ++it) {
if (it->second > maxValue) {
maxIndex = it->first;
maxValue = it->second;
}
}
return maxIndex;
}
|
fac50f3df0d1102928c56c1dd62ee298e726d324 | cdb2160523b3742ea058ab5c22ebf6e44cb7f87d | /C++/boj/boj5585.cpp | 41bde5e29634fbc18d3aab52f6a522db99413e63 | [] | no_license | ryul99/algorithm-study | 68193471264a8bb249e047c922c2f66144eed6a7 | d64c388ca7d0c3b01e8e8a480f5fc435772f154b | refs/heads/master | 2023-03-06T14:44:24.498487 | 2023-02-23T21:16:35 | 2023-02-23T21:16:35 | 149,987,036 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 555 | cpp | boj5585.cpp | #include <cstring>
#include <string>
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
//https://www.acmicpc.net/problem/5585
int main(int argc, char const *argv[]) {
//ios_base::sync_with_stdio(false)
int N;
scanf("%d", &N);
N = 1000 - N;
printf("%d\n", N / 500 + (N % 500) / 100 + (N % 100) / 50 + (N % 50) / 10 + (N % 10) / 5 + (N % 5) / 1);
return 0;
}
|
ffde76f3f1df0d8852a6dad4a0aa61a4a5420503 | f658b1b79782726539d06373e259111e9de88c3b | /第一次上机/T3.cpp | 5ebb604b552aa32652213e4b189f6594efa7138b | [] | no_license | Maydaytyh/OOP-Experiment | b67d3b80334cef4afea4a6ea69f0a24a1dd5f227 | 3fa59b6492541a3167806d3c72a84a4ba7693df9 | refs/heads/master | 2020-05-04T04:50:28.644446 | 2019-04-04T05:52:07 | 2019-04-04T05:52:07 | 178,975,105 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,221 | cpp | T3.cpp | #include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 500000 + 5
#define pa pair<ll, int>
#define pi acos(-1)
#define maxm 30000
#define ll long long
#define eps 1e-6
#define mod 1000000007
#define mian main
#define inf 1000000000
#define rep(i, n, m) for (int i = n; i <= m; ++i)
#define per(i, n, m) for (int i = n; i >= m; --i)
#define mem(a, b) memset(a, b, sizeof a)
#ifndef ONLINE_JUDGE
#define dbg(x) cout << #x << "=" << x << endl;
#else
#define dbg(x)
#endif
class Circle
{
private:
double X, Y, R;//分别表示圆心横纵坐标及半径
public:
void SetXYR(double, double, double);//为圆心横纵坐标,半径设置初值
double GetX(){
return X;
}//外部调用X
double GetY(){
return Y;
}//外部调用Y
double GetR(){
return R;
}//外部调用R
double Distance(const Circle &);//获取两圆心距离
};
void Circle::SetXYR(double a, double b, double c)
{
X = a, Y = b, R = c;
}
double Circle::Distance(const Circle &p)
{
return sqrt((X - p.X) * (X - p.X) + (Y - p.Y) * (Y - p.Y));
}
int main()
{
Circle P, Q;
double a1,b1,c1,a2,b2,c2;
cin>>a1>>b1>>c1>>a2>>b2>>c2;
P.SetXYR(a1,b1,c1);
Q.SetXYR(a2,b2,c2);
double Px=P.GetX(),Py=P.GetY(),Pr=P.GetR();
double Qx=Q.GetX(),Qy=Q.GetY(),Qr=Q.GetR();
// dbg(Px);dbg(Qx);dbg(Py);dbg(Qy);
if (Px ==Qx && Qy == Py)
cout << "Concentric circles\n";//如果圆心重合,则为同心圆
else
{
double Minus = fabs(Pr - Qr);//半径之差
double Dis = P.Distance(Q);//求得间距
double add = Pr+ Qr;//半径之和
if (add < Dis)
cout << "seperation\n";//半径之和大于圆心距离,相离
else if (add == Dis)
cout << "externally tangent\n";//半径之和等于圆心距离,外切
else if (Minus == Dis)
cout << "intenally tangent\n";//半径之差等于圆心距离,内切
else if (Minus > Dis)
cout << "Contain\n";//半径之差大于圆心距离,相含
else cout<<"intersection\n";//其余情况为相交
}
} |
21ea85d1c04cccaa2acf9b480b4c648561b49fe6 | 4734bb00e9e051411a8fa76a7624bfbaa9e40239 | /utilities/binning/mim_accpetance.cpp | e603fe32f7f5ae85f4a7942f3deb9e3a6a35cf9e | [] | no_license | kuantumlad/clas12_pip | f6a9504385eae1ee877014081e6c579b337d1ec5 | 194534aab51f2321324aef8c0b9b6af9d2284a7f | refs/heads/master | 2020-03-21T08:11:16.212026 | 2018-07-10T03:17:55 | 2018-07-10T03:17:55 | 138,326,841 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 3,700 | cpp | mim_accpetance.cpp | #include "TMath.h"
#include "TH1D.h"
#include "TGraph.h"
#include "TCanvas.h"
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <iostream>
TH1D* readTxtToHist( const char* filename, const char* gentype, int nbins, double min_q2, double max_q2 ){
TH1D *h_temp = new TH1D(Form("h_accp_corr_%s",gentype), Form("h_accp_corr_%s",gentype), nbins, min_q2, max_q2);
std::ifstream fIn;
fIn.open(filename, std::ios_base::in );
std::string line;
if( fIn.is_open() ){
while( getline( fIn, line ) ){
if( line[0] == '#' ) continue;
Double_t col1, col2, col3;
std::stringstream first(line);
first >> col1 >> col2 >> col3;
double bin = col1;
double accp = col2;
double recon = col3;
double corrected = accp*recon;
std::cout << " CORRECTED VALUE IS " << corrected << std::endl;
h_temp->SetBinContent(bin,corrected);
}
}
fIn.close();
return h_temp;
}
std::vector<double> readTxtToVector(const char* filename, int col){
std::vector<double> v_temp;
std::ifstream fIn;
fIn.open(filename, std::ios_base::in );
std::string line;
if( fIn.is_open() ){
while( getline( fIn, line ) ){
if( line[0] == '#' ) continue;
Double_t col1, col2, col3;
std::stringstream first(line);
first >> col1 >> col2 >> col3;
double bin = col1;
double accp = col2;
double recon = col3;
if( col == 0 ){ v_temp.push_back(bin); }
if( col == 1 ){ v_temp.push_back(accp); }
if( col == 2 ){ v_temp.push_back(recon); }
}
}
fIn.close();
return v_temp;
}
TH1D* makeHisto(std::vector<double> v_temp_acc, std::vector<double> v_temp_recon, const char* gentype, int nbins, double min_q2, double max_q2){
TH1D *h_temp = new TH1D(Form("h_accp_corr_%s",gentype), Form("h_accp_corr_%s",gentype), nbins, min_q2, max_q2);
for( int bin = 0; bin<nbins; bin++ ){
double accp = v_temp_acc[bin];
double recon = v_temp_recon[bin];
double corrected = accp*recon;
h_temp->SetBinContent(bin,corrected);
}
return h_temp;
}
int mim_accpetance( ){
std::cout<< " >> CREATING PLOTS FOR ACCEPTANCE CORRECTIONS " << std::endl;
int nbins = 10;
double min_q2 = 1.0;
double max_q2 = 9.99;
std::vector<double> v_accp_flat = readTxtToVector("/u/home/bclary/CLAS12/phi_analysis/v2/v1/utilities/binning/h_accep_rec_q2_flat.txt",1);
std::vector<double> v_accp_sin = readTxtToVector("/u/home/bclary/CLAS12/phi_analysis/v2/v1/utilities/binning/h_accep_rec_q2_sin.txt",1);
std::vector<double> v_accp_q4 = readTxtToVector("/u/home/bclary/CLAS12/phi_analysis/v2/v1/utilities/binning/h_accep_rec_q2_q4.txt",1);
std::vector<double> v_recon_flat = readTxtToVector("/u/home/bclary/CLAS12/phi_analysis/v2/v1/utilities/binning/h_accep_rec_q2_flat.txt",2);
TH1D *h_corrected_flat = makeHisto(v_accp_flat,v_recon_flat,"flat",nbins, min_q2, max_q2);
TH1D *h_corrected_sin = makeHisto(v_accp_sin,v_recon_flat,"sin",nbins, min_q2, max_q2);
TH1D *h_corrected_q4 = makeHisto(v_accp_q4,v_recon_flat,"q4",nbins, min_q2, max_q2);
TCanvas *c_trad_corr = new TCanvas("c_trad_corr","c_trad_corr",800,800);
c_trad_corr->Divide(1,1);
c_trad_corr->cd(1);
h_corrected_flat->SetLineColor(1);
h_corrected_sin->SetLineColor(2);
h_corrected_q4->SetLineColor(4);
h_corrected_q4->SetTitle("Q^2 with Bin-by-Bin Correction");
h_corrected_flat->GetXaxis()->SetTitle("Q^{2} [GeV^2]");
h_corrected_flat->Draw("same");
h_corrected_sin->Draw("same");
h_corrected_q4->Draw("same");
c_trad_corr->SaveAs("/u/home/bclary/CLAS12/phi_analysis/v2/v1/utilities/binning/h_trad_accp_final.pdf");
return 0;
}
|
020894dd11747320f772d64224971f7f74c3e797 | 73a0f661f1423d63e86489d4b2673f0103698aab | /oneflow/api/python/functional/indexing.h | 4e157ce5e9459168e13cd396e064ffc4e52c4017 | [
"Apache-2.0"
] | permissive | Oneflow-Inc/oneflow | 4fc3e081e45db0242a465c4330d8bcc8b21ee924 | 0aab78ea24d4b1c784c30c57d33ec69fe5605e4a | refs/heads/master | 2023-08-25T16:58:30.576596 | 2023-08-22T14:15:46 | 2023-08-22T14:15:46 | 81,634,683 | 5,495 | 786 | Apache-2.0 | 2023-09-14T09:44:31 | 2017-02-11T06:09:53 | C++ | UTF-8 | C++ | false | false | 1,320 | h | indexing.h | /*
Copyright 2020 The OneFlow Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef ONEFLOW_API_PYTHON_FUNCTIONAL_INDEXING_H_
#define ONEFLOW_API_PYTHON_FUNCTIONAL_INDEXING_H_
#include <Python.h>
#include "oneflow/api/python/functional/common.h"
#include "oneflow/core/common/maybe.h"
#include "oneflow/core/framework/tensor.h"
#include "oneflow/core/functional/tensor_index.h"
namespace oneflow {
namespace one {
namespace functional {
namespace detail {
void PySliceUnpack(PyObject* object, Py_ssize_t* start, Py_ssize_t* stop, Py_ssize_t* step);
Maybe<Tensor> ConvertToIndexingTensor(PyObject* object);
IndexItem UnpackIndexItem(PyObject* object);
} // namespace detail
} // namespace functional
} // namespace one
} // namespace oneflow
#endif // ONEFLOW_API_PYTHON_FUNCTIONAL_INDEXING_H_
|
64077e60121edc905c5bbeff77bf912bcd03b7b6 | d8683af8b36744fb67750d6683de798ab291a98d | /cms_monojet_run2.cpp | 19d507e925a2ef0e8ddd544e680ad09d6b13d5b3 | [] | no_license | AndreasAlbert/ma5_monojet | 0e3456ed9ca4fa01c076ae1a1077789bfa0fcde3 | f55c9792d04230402be00b78aa47d67a48373c89 | refs/heads/master | 2020-11-26T00:54:04.431036 | 2019-12-18T20:03:10 | 2019-12-18T20:05:13 | 228,912,943 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,970 | cpp | cms_monojet_run2.cpp | #include "SampleAnalyzer/User/Analyzer/cms_monojet_run2.h"
using namespace MA5;
using namespace std;
// -----------------------------------------------------------------------------
// Initialize
// function called one time at the beginning of the analysis
// -----------------------------------------------------------------------------
bool cms_monojet_run2::Initialize(const MA5::Configuration& cfg, const std::map<std::string,std::string>& parameters)
{
cout << "BEGIN Initialization" << endl;
// Set up analysis bins
std::vector<int> bin_edges = {250,280,310};
int nbins = 2;
for(int i=0; i<nbins; i++) {
// Bin definition
char name[20];
char cut[20];
sprintf(name, "bin%d", i);
Manager()->AddRegionSelection(name);
// Cut definition for this bin
sprintf(cut, "%d < MET < %d GeV", bin_edges.at(i), bin_edges.at(i+1));
Manager()->AddCut(cut,name);
}
Manager()->AddCut("Veto_Electron");
Manager()->AddCut("Veto_Muon");
Manager()->AddCut("Veto_Tau");
Manager()->AddCut("Veto_B");
Manager()->AddCut("Veto_Photon");
Manager()->AddCut("DeltaPhi(jet, MET) > 0.5");
Manager()->AddCut("MET > 250 GeV");
Manager()->AddCut("LeadJet_pt");
Manager()->AddCut("LeadJet_eta");
Manager()->AddCut("LeadJet_ID");
cout << "END Initialization" << endl;
return true;
}
// -----------------------------------------------------------------------------
// Finalize
// function called one time at the end of the analysis
// -----------------------------------------------------------------------------
void cms_monojet_run2::Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files)
{
cout << "BEGIN Finalization" << endl;
// saving histos
cout << "END Finalization" << endl;
}
// -----------------------------------------------------------------------------
// Execute
// function called each time one event is read
// -----------------------------------------------------------------------------
bool cms_monojet_run2::Execute(SampleFormat& sample, const EventFormat& event)
{
float CUT_ELECTRON_PT_MIN = 10;
float CUT_ELECTRON_ETA_MAX = 10;
double weight=1.;
if (!Configuration().IsNoEventWeight() && event.mc()!=0) {
weight=event.mc()->weight();
}
Manager()->InitializeForNewEvent(weight);
if (event.rec()==0) {return true;}
vector<const RecJetFormat*> jets, bjets;
vector<const RecLeptonFormat*> muons, electrons;
vector<const RecTauFormat*> taus;
vector<const RecPhotonFormat*> photons;
// Electrons
for(auto electron: event.rec()->electrons()){
if (electron.pt() < CUT_ELECTRON_PT_MIN) continue;
if (fabs(electron.eta()) > CUT_ELECTRON_ETA_MAX) continue;
// TODO: ISO
electrons.push_back(&electron);
}
// // B Jets
// for(auto const jet: event.rec()->jets()) {
// if (jet->pt() < CUT_BJET_PT_MIN) continue;
// if (fabs(jet->eta()) > CUT_BJET_ETA_MAX) continue;
// if (jet->btag)
// }
return true;
}
|
b4063cce6e4dcedc9aa8fdfafaf0ceea5169f794 | c7f24b4cb54dd8e211749863f616b1a9b3dfa75d | /Source/Engine/Scene/SceneDescription.h | a822c9fa9c24247bb472180fc7d5bd8a7dfea3d7 | [
"MIT"
] | permissive | rAzoR8/tracy | 96c75fb682904289e4ca97026f881845449fc6ed | 98ce539cbd1117a826c34959dbbc36788b634508 | refs/heads/master | 2020-05-02T12:43:23.837990 | 2019-03-27T10:02:12 | 2019-03-27T10:02:12 | 177,965,529 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 358 | h | SceneDescription.h | #ifndef TRACY_SCENEDESCRIPTION_H
#define TRACY_SCENEDESCRIPTION_H
#include "Display\RenderObjectDescription.h"
namespace Tracy
{
struct SceneDesc
{
std::vector<RenderObjectDesc> Objects;
uint32_t uMaxDynamicObjects = 0u; // number of objects that can be allocated from dynamicaly from scripts etc
};
} // Tracy
#endif // !TRACY_SCENEDESCRIPTION_H
|
f6af267628eacc92cb9a778adf068f5f3cb09c9c | 959d9efe680b50f04f0e303677ff6067d66bc36a | /src/coin_model.h | c69317a2e0a0b23add0a12e59f0eb7e7e184dfd0 | [] | no_license | ShellCode33/Runner | 2716ef47de5ffab24cfdf3c9dfdaff9a9939b555 | 88405d2c153fa12f737c7be0940938c3034b9bca | refs/heads/master | 2021-03-16T06:16:58.537955 | 2017-12-31T19:54:37 | 2017-12-31T19:54:37 | 51,835,577 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 996 | h | coin_model.h | /*!
* \file coin_model.h
* \class CoinModel
* \brief Partie modèle des pièces
* \author J3ry
*/
#ifndef COIN_MODEL_H
#define COIN_MODEL_H
#include "obstacle.h"
class CoinModel : public Obstacle
{
public:
/*!
* \brief CoinModel construceur
* \param relat_x
* \param relat_y
* \param width
* \param height
*/
CoinModel(int relat_x, int relat_y, int width, int height);
~CoinModel();
/*!
* \brief action qui s'applique lorsque le playerModel entre en collision avec la pièce
* \param game
*/
void action(GameModel &game);
/*!
* \brief update
*/
void update();
/*!
* \brief checkCollision
* \param m
* \return true ou false suivant si la collision a lieu ou pas
*/
bool checkCollision(Movable &m) const;
bool isTaken() const;
private:
bool taken; /*!< Attribut utilisé pour déterminer si la pièce a été récupérée par le joueur */
};
#endif // COIN_MODEL_H
|
a9a310d69a25a941a42cfc7c8e80dae6372b4020 | 7b7b2162b2d03d2a386f580bd6b90371696a251b | /src/tuhhsdk/Data/BoxCandidates.hpp | 16ba7f775e62abc9fe9782d7449ec836a28c6c3d | [
"BSD-2-Clause"
] | permissive | HiddeLekanne/HULKsCodeRelease | 5e1edfccd2de811522d9d2825e89957cf47ec759 | bec0aa39c3266656488527e59ef9aacad9b3ed85 | refs/heads/master | 2021-01-01T02:48:07.715892 | 2020-04-22T22:53:56 | 2020-04-22T22:53:56 | 239,148,122 | 0 | 0 | null | 2020-02-08T14:44:47 | 2020-02-08T14:44:46 | null | UTF-8 | C++ | false | false | 890 | hpp | BoxCandidates.hpp | #pragma once
#include <vector>
#include "Framework/DataType.hpp"
#include "Tools/Math/Circle.hpp"
#include "Tools/Storage/ObjectCandidate.hpp"
class BoxCandidates : public DataType<BoxCandidates>
{
public:
/// the name of this DataType
DataTypeName name = "BoxCandidates";
std::vector<ObjectCandidate> candidates;
/// boxes for debug image
std::vector<DebugCandidate<Circle<int>>> debugBoxes;
/// whether the box candidates are valid
bool valid = false;
/**
* @brief invalidates the position
*/
void reset() override
{
valid = false;
candidates.clear();
debugBoxes.clear();
}
void toValue(Uni::Value& value) const override
{
value = Uni::Value(Uni::ValueType::OBJECT);
value["candidates"] << candidates;
value["valid"] << valid;
}
void fromValue(const Uni::Value& value) override
{
value["valid"] >> valid;
}
};
|
89d3331fc3ad36f7b605f741fd3c51a31e2117a6 | 190cb37ed6c63b9bb98e4ed941a67462c3fe80ac | /MALib_sock/src/console_server.cpp | 8cd91dbfd01c50bc3ed0f8a40de0c676a8cbbf30 | [] | no_license | MaxAlzner/HexEngine | ebcfa6444441569dc7cf94ddd152379a6f9d727f | ae14d0d8aed6fa5a128bd1e75ce92d8ad4552c4b | refs/heads/master | 2021-01-21T11:08:26.259869 | 2015-06-28T16:08:06 | 2015-06-28T16:08:06 | 10,649,526 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,365 | cpp | console_server.cpp |
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include "..\include\MALib_sock.h"
struct TEST_STRUCT
{
TEST_STRUCT()
{
memset(this, 0, sizeof(TEST_STRUCT));
}
int a;
double g;
int b;
char c;
float h;
float j;
};
int send(char* buffer, uint bytes)
{
TEST_STRUCT test1;
test1.a = 81;
test1.g = 18.02;
test1.b = 2;
test1.c = 57;
test1.h = 23.008f;
test1.j = 4.158f;
*((TEST_STRUCT*)buffer) = test1;
printf("SENT : %d %f %d %d %f %f\n", test1.a, test1.g, test1.b, test1.c, test1.h, test1.j);
//int error = MALib::SOCK_CheckError();
//if (error != 0) printf("SEND ERROR : %d\n", error);
return 1000;
}
int receive(char* buffer, uint bytes)
{
TEST_STRUCT test2;
test2 = *((TEST_STRUCT*)buffer);
printf("RECIEVED : %d %f %d %d %f %f\n", test2.a, test2.g, test2.b, test2.c, test2.h, test2.j);
//int error = MALib::SOCK_CheckError();
//if (error != 0) printf("RECIEVE ERROR : %d\n", error);
return 1000;
}
int main()
{
MALib::SOCK_Initialize(true);
static char* ip = MALib::SOCK_GetMyIP();
printf("HOST IP : %s\n", ip);
printf("PORT NUM : %d\n", 20533);
if (MALib::SOCK_Connect(20533, ip, send, receive))
{
printf("SERVER SETUP SUCCESSFUL\n");
}
else
{
printf("SERVER SETUP UNSUCCESSFUL\n");
printf("CONNECTION ERROR : %d\n", MALib::SOCK_CheckError());
}
_getch();
MALib::SOCK_Uninitialize();
return 0;
} |
184315985689321f852c930579f6af065495592a | 3e8ac636d108220a9085a50cb4f7507d5543d72d | /chefmax.cpp | 2cd37814c8fbd01d517c45c2055422c84ee38a92 | [] | no_license | taranjeet/practice | 7ebbc9a4ec3d34a8768769c61785c953a4128751 | a5d91b1ec3ae1f8d586e19e113dceb7762319f53 | refs/heads/master | 2021-05-29T09:36:40.519448 | 2015-05-23T18:41:07 | 2015-05-23T18:41:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 674 | cpp | chefmax.cpp |
/*
2015-02-04 14:23
practice
FEB 15
*/
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long int ll;
#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORS(i,a,n) for(int i = a; i < n; i++)
#define RDARR(a,n) FOR(i,n) cin>>a[i];
#define SOLVE() int t;cin>>t;FOR(tc,t) solve();
#define PB push_back
void solve(){
int a[26]={0};
string s;
cin>>s;
FOR(i,s.length())
a[s[i]-97]++;
int ma=a[0],index=0;
FORS(i,1,26){
if(a[i]>ma){
ma=a[i];
index=i;
}
}
FOR(i,s.length()){
if((s[i]-97)==index)
cout<<"?";
else
cout<<s[i];
}
cout<<endl;
}
int main(){ _
SOLVE()
return 0;
}
|
9fbc486a71bd334dcf6c3566bbfca109c1c75d91 | 7d4bb64b31f06e4a22f63c5944297c52d12285d6 | /Codechef/modular_gcd_codechef.cpp | ebd19086afe218b806f849a6e9463407a55fd6ab | [] | no_license | 927tanmay/Coding-DSA | 17e6eff710859d2f17f35e45883605c721f374f9 | e173fbe64fbf39c11a4d32cda6f8f663757b5cb7 | refs/heads/master | 2023-01-12T15:55:06.984519 | 2020-10-31T16:10:36 | 2020-10-31T16:10:36 | 305,500,210 | 1 | 2 | null | 2020-10-31T16:10:37 | 2020-10-19T20:04:28 | C++ | UTF-8 | C++ | false | false | 1,410 | cpp | modular_gcd_codechef.cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define INF 1e9
#define mod 1000000007
ll max(int a, int b)
{
if (a > b)
return a;
else
return b;
}
ll power(ll a, ll n, ll modi)
{
ll ans = 1;
while (n)
{
if (n % 2 == 1)
{
ans = ((ans % modi) * (a % modi)) % modi;
n--;
}
a = ((a % modi) * (a % modi)) % modi;
n = n / 2;
}
return ans % modi;
}
int main()
{
int t;
cin >> t;
while (t--)
{
ll a, b, n;
cin >> a >> b >> n;
ll y = (a - b);
ll tmp = 1;
ll x = (power(a, n, mod) + power(b, n, mod)) % mod;
if (y == 0)
tmp = x;
else
{
for (ll i = 1; i * i <= y; i++)
{
if (y % i == 0)
{
x = (power(a, n, i) + power(b, n, i)) % i;
if (x == 0)
{
tmp = max(tmp, i);
}
x = (power(a, n, y / i) + power(b, n, y / i)) % (y / i);
if (x == 0)
{
tmp = max(tmp, y / i);
}
}
}
}
cout << tmp % mod << endl;
}
return 0;
} |
a79673ca3e90ddb2be3a78cf5d911d97d4988571 | 2e361df6cbb79d419fb8990f9ecbac8098851cf4 | /nsrrenderedpage.h | a5d1fcd6ddb6904b455a5b16490ca157ee2987d7 | [] | no_license | anubhavrohatgi/nsrreadercore | f499be1759a365829d1a9a107eb8c8c4355618af | a40213300db50b8a5eabe4a301e640e89d1d698e | refs/heads/master | 2020-06-13T01:49:20.388261 | 2015-10-13T22:32:19 | 2015-10-13T22:32:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,391 | h | nsrrenderedpage.h | #ifndef __NSRRENDEREDPAGE_H__
#define __NSRRENDEREDPAGE_H__
/**
* @file nsrrenderedpage.h
* @author Alexander Saprykin
* @brief Rendered page
*/
#include "nsrrenderrequest.h"
#include "nsrabstractdocument.h"
#include "nsrreadercore_global.h"
#include <QSize>
#include <QPointF>
/**
* @class NSRRenderedPage nsrrenderedpage.h
* @brief Class for rendered page
*/
class NSRREADERCORE_SHARED NSRRenderedPage: public NSRRenderRequest
{
public:
/**
* @brief Constructor
*/
NSRRenderedPage ();
/**
* @brief Constructor from request
* @param req Render request.
*/
NSRRenderedPage (const NSRRenderRequest& req);
/**
* @brief Destructor
*/
virtual ~NSRRenderedPage ();
/**
* @brief Gets page size
* @return Page size, in px.
*/
inline QSize getSize () const {
return QSize (_image.width (), _image.height ());
}
/**
* @brief Gets rendered image
* @return Rendered image.
*/
inline NSR_CORE_IMAGE_DATATYPE getImage () const {
return _image;
}
/**
* @brief Gets page text
* @return Page text.
*/
inline QString getText () const {
return _text;
}
/**
* @brief Gets last image scroll position
* @return Last image scroll position.
* @note Useful to store scroll data right in the page object.
*/
inline QPointF getLastPosition () const {
return _lastPos;
}
/**
* @brief Gets last text view position
* @return Last text view position.
* @note Useful to store scroll data right in the page object.
*/
inline QPointF getLastTextPosition () const {
return _lastTextPos;
}
/**
* @brief Gets page zoom value
* @return Zoom value, in %.
*/
inline double getRenderedZoom () const {
return _renderedZoom;
}
/**
* @brief Gets min page zoom value
* @return Min zoom value, in %.
* @since 1.4.3
*/
inline double getMinRenderZoom () const {
return _minRenderZoom;
}
/**
* @brief Gets max page zoom value
* @return Max zoom value, in %.
* @since 1.4.3
*/
inline double getMaxRenderZoom () const {
return _maxRenderZoom;
}
/**
* @brief Checks whether page was taken from cache
* @return True if page was taken from cache, false otherwise.
*/
inline bool isCached () const {
return _cached;
}
/**
* @brief Checks whether page image is valid (non-empty)
* @return True if page image is valid, false otherwise.
*/
bool isImageValid () const;
/**
* @brief Checks whether page is empty (no image and text)
* @return True if page is empty, false otherwise.
*/
bool isEmpty () const;
/**
* @brief Sets page image
* @param image Page image.
*/
inline void setImage (NSR_CORE_IMAGE_DATATYPE image) {
_image = image;
}
/**
* @brief Sets page text
* @param text Page text.
*/
inline void setText (const QString &text) {
_text = text;
}
/**
* @brief Sets last image scroll position
* @param pos Last image scroll position.
* @note Useful to store scroll data right in the page object.
*/
inline void setLastPosition (const QPointF& pos) {
_lastPos = pos;
}
/**
* @brief Sets last text view position
* @param pos Last text view position.
* @note Useful to store scroll data right in the page object.
*/
inline void setLastTextPosition (const QPointF& pos) {
_lastTextPos = pos;
}
/**
* @brief Sets page zoom value
* @param zoom Page zoom value, in %.
*/
inline void setRenderedZoom (double zoom) {
_renderedZoom = zoom;
}
/**
* @brief Sets page min zoom value
* @param minZoom Page min zoom value, in %.
* @since 1.4.3
*/
inline void setMinRenderZoom (double minZoom) {
_minRenderZoom = minZoom;
}
/**
* @brief Sets page max zoom value
* @param maxZoom Page max zoom value, in %.
* @since 1.4.3
*/
inline void setMaxRenderZoom (double maxZoom) {
_maxRenderZoom = maxZoom;
}
/**
* @brief Marks page as cached
* @param cached Whether page is cached.
*/
inline void setCached (bool cached) {
_cached = cached;
}
private:
NSR_CORE_IMAGE_DATATYPE _image; /**< Page image */
QString _text; /**< Page text */
QPointF _lastPos; /**< Last image scroll position */
QPointF _lastTextPos; /**< Last text view position */
double _renderedZoom; /**< Page zoom value */
double _minRenderZoom; /**< Page min zoom value */
double _maxRenderZoom; /**< Page max zoom value */
bool _cached; /**< Cache flag */
};
#endif /* __NSRRENDEREDPAGE_H__ */
|
73ae41189d4196f24b99d143e5bb4e6c5d2ab23c | 72bb387a4642ce9cce4453d3fd8a99e595a58967 | /Landing.cpp | 5b1117d918786b628b93f3c8ddf0552d94a95bc1 | [] | no_license | hanliumaozhi/cassie_jump_part2 | 56e9bfe763973add5ed71b03252ad84858fefd6a | 93d10cfbf7779ed7e3b188f57bf0d593679fd95e | refs/heads/master | 2023-02-11T18:31:38.678850 | 2021-01-03T07:08:02 | 2021-01-03T07:08:02 | 324,747,629 | 2 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 5,166 | cpp | Landing.cpp | //
// Created by han on 2020/12/26.
//
#include "Landing.h"
Landing::Landing(int var_num_per_node, int node_num, double dt):
var_num_per_node_(var_num_per_node),
node_num_(node_num),
dt_(dt){
program_ = std::make_shared<drake::solvers::MathematicalProgram>();
var_sol_ = std::make_unique<Eigen::VectorXd>(node_num_);
}
void Landing::build()
{
//1. construct per node
for (int i = 0; i < node_num_; ++i) {
node_list_.emplace_back(std::make_unique<OptNode>(std::to_string(i), var_num_per_node_, program_));
node_list_[i]->build();
}
for (int i = 0; i < (node_num_-1); ++i) {
// x dotx
direct_collocation_constraints_.push_back(
program_->AddConstraint((node_list_[i+1]->decision_var_ptr_[6]-node_list_[i]->decision_var_ptr_[6])-
0.5*dt_*(node_list_[i+1]->decision_var_ptr_[7]+node_list_[i]->decision_var_ptr_[7]) == 0).evaluator().get());
// dotx ddotx
direct_collocation_constraints_.push_back(
program_->AddConstraint((node_list_[i+1]->decision_var_ptr_[7]-node_list_[i]->decision_var_ptr_[7])-
0.5*dt_*(node_list_[i+1]->decision_var_ptr_[8]+node_list_[i]->decision_var_ptr_[8]) == 0).evaluator().get());
// s dots
direct_collocation_constraints_.push_back(
program_->AddConstraint((node_list_[i+1]->decision_var_ptr_[0]-node_list_[i]->decision_var_ptr_[0])-
0.5*dt_*(node_list_[i+1]->decision_var_ptr_[1]+node_list_[i]->decision_var_ptr_[1]) == 0).evaluator().get());
// dots ddots
direct_collocation_constraints_.push_back(
program_->AddConstraint((node_list_[i+1]->decision_var_ptr_[1]-node_list_[i]->decision_var_ptr_[1])-
0.5*dt_*(node_list_[i+1]->decision_var_ptr_[2]+node_list_[i]->decision_var_ptr_[2]) == 0).evaluator().get());
// l dotl
direct_collocation_constraints_.push_back(
program_->AddConstraint((node_list_[i+1]->decision_var_ptr_[3]-node_list_[i]->decision_var_ptr_[3])-
0.5*dt_*(node_list_[i+1]->decision_var_ptr_[4]+node_list_[i]->decision_var_ptr_[4]) == 0).evaluator().get());
// dotl ddotl
direct_collocation_constraints_.push_back(
program_->AddConstraint((node_list_[i+1]->decision_var_ptr_[4]-node_list_[i]->decision_var_ptr_[4])-
0.5*dt_*(node_list_[i+1]->decision_var_ptr_[5]+node_list_[i]->decision_var_ptr_[5]) == 0).evaluator().get());
}
/*kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[0]->decision_var_ptr_(1) == 0).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[0]->decision_var_ptr_(2) == 0).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[0]->decision_var_ptr_(4) == 0).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[0]->decision_var_ptr_(5) == 0).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[0]->decision_var_ptr_(7) == 0).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[0]->decision_var_ptr_(8) == 0).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[node_num_-1]->decision_var_ptr_(3) == 1).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[node_num_-1]->decision_var_ptr_(4) == 2).evaluator().get());*/
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[0]->decision_var_ptr_(3) == 1).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[0]->decision_var_ptr_(4) == -2).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[node_num_-1]->decision_var_ptr_(3) == 0.75).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[node_num_-1]->decision_var_ptr_(1) == 0.0).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[node_num_-1]->decision_var_ptr_(4) == 0.0).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[node_num_-1]->decision_var_ptr_(2) == 0.0).evaluator().get());
kinematics_constraints_.push_back(
program_->AddLinearConstraint(node_list_[node_num_-1]->decision_var_ptr_(5) == 0.0).evaluator().get());
drake::symbolic::Expression Cost;
for (int i = 0; i < node_num_; ++i) {
Cost += drake::symbolic::pow(node_list_[i]->decision_var_ptr_(5), 2) + 100000*drake::symbolic::pow(node_list_[i]->decision_var_ptr_(1), 2);
}
program_->AddCost(Cost);
}
void Landing::print_var(const drake::solvers::MathematicalProgramResult& result)
{
for (int i = 0; i < node_num_; ++i) {
node_list_[i]->print_var(result);
}
} |
1a7f223652ba4602d06dba82b7bddc62fc14c76d | f3ee682a77a1ce2e059f10f7563666771b6b48fa | /Source/Engine/Subsystem/Subsystem.h | 5b950a5e2d94a30f51e5a95c7ba054b5906c841e | [] | no_license | TeamValkyrie/CatalystEngine | d281de43a3d4580f7a7bfe2f5a4dce2cb70ce0c2 | 9810209b0aa47bdf451ff8808ac565b1f9d85b27 | refs/heads/master | 2020-06-13T05:47:46.707426 | 2019-08-11T13:10:53 | 2019-08-11T13:10:53 | 194,559,134 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 298 | h | Subsystem.h | #pragma once
/*
* Subsystem interface used for standardising Subsystem layout
*/
class Subsystem
{
public:
Subsystem();
virtual ~Subsystem();
virtual void Init();
virtual void Tick(float DeltaTime) = 0;
virtual void Deinit();
bool IsInitialized();
private:
bool m_bIsInitialized;
}; |
ef540a88a92e24a21e2cdb00ca63f6b21b511016 | a980001c54d173462e26a2721051930e336cf5fb | /src/lib/PerlinNoise.h | 6b82099aa85c621ab56944d7001357ef2d7b085b | [] | no_license | jedrzejowski/zpr-project-old | efca1429fd059f31c3fd759b4d4841549bf20301 | 05b3d762b4d32f0c2dbdaa77e96a4b8aa835d0e9 | refs/heads/master | 2020-03-12T11:59:00.108672 | 2018-05-21T21:18:30 | 2018-05-21T21:18:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,001 | h | PerlinNoise.h | //
// Created by adam on 06.05.18.
//
#pragma once
class PerlinNoise {
private:
double Total(double i, double j) const;
double GetValue(double x, double y) const;
double Interpolate(double x, double y, double a) const;
double Noise(int x, int y) const;
double persistence, frequency, amplitude;
int octaves, randomseed;
public:
// Constructor
PerlinNoise();
PerlinNoise(double _persistence, double _frequency,
double _amplitude, int _octaves, int _randomseed);
// Get Height
double GetHeight(double x, double y) const;
// Get
double GetPersistence() const;
double GetFrequency() const;
double GetAmplitude() const;
int GetOctaves() const;
int GetRandomSeed() const;
// Set
void Set(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed);
void SetPersistence(double _persistence);
void SetFrequency(double _frequency);
void SetAmplitude(double _amplitude);
void SetOctaves(int _octaves);
void SetRandomSeed(int _randomseed);
};
|
9174f8f09354dbb991433b927f57ebf0b2c2ca42 | f2d9172af9c727874f5ab8c42447a5bd29548461 | /CCNY_Climber_Arduino/Odometry.ino | 9c8a56a361e39ea9610c6a7abbc530dac8eabd3a | [] | no_license | AutoAILab/Climbing-Robot | d7780a27bd8589db9d3af102bbdb74eaa42212fe | 4a769d828f82c58c8bd3e32460fa0bac23be266b | refs/heads/master | 2023-04-16T18:21:03.580304 | 2014-08-26T23:07:25 | 2014-08-26T23:07:25 | 364,111,768 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,618 | ino | Odometry.ino | // Odometry
#ifdef ENABLE_WHEEL_ODOMETRY
// setup for odometry
void setup_wheel_odometry() {
pinMode(LEncA, pid_input);
pinMode(LEncB, pid_input);
attachInterrupt(0, dCheckL_isr, CHANGE);
attachInterrupt(1, dCheckR_isr, CHANGE);
Lcurrent_time = micros();
Rcurrent_time = micros();
}
void dCheckL_isr() {
bool_dCheckL = 1;
Lcurrent_time = micros();
if (dCheckL_cnt == 0) { // First rotation does not have pre_time
Lpre_time = Lcurrent_time;
dCheckL_cnt = 1;
return;
}
Lperiod = (float)(Lcurrent_time - Lpre_time)/1000000;
if (digitalRead(LEncA) == digitalRead(LEncB)) {
Lcount++;
Vl = 0.247369529/2/Lperiod;
} else {
Lcount--;
Vl = -0.247369529/2/Lperiod;
}
Dl = Lcount*0.247369529;
D = (Dl+Dr)/2;
V = (Vl+Vr)/2;
w = (Vl-Vr)/12; // 12 inches is the distance between the left and right wheel
phi += w*Lperiod;
// phi -= (double)((int)(phi/twopi))*twopi;
x += V*sin(phi)*Lperiod;
y += V*cos(phi)*Lperiod;
Lpre_time = Lcurrent_time;
}
void dCheckR_isr() {
if (dCheckR_cnt == 0) { // First rotation does not have pre_time
Rpre_time = Rcurrent_time;
dCheckR_cnt = 1;
return;
}
Rperiod = (float)(Rcurrent_time - Rpre_time)/1000000;
if (digitalRead(LEncA) == digitalRead(LEncB)) {
Rcount++;
Vr = 0.247369529/2/Rperiod;
} else {
Rcount--;
Vr = -0.247369529/2/Rperiod;
}
Dr = Rcount*0.247369529;
Rpre_time = Rcurrent_time;
}
void display_odo() {
if (1 == bool_dCheckL) {
bool_dCheckL = 0;
my_println(x);
my_println(y);
my_println(phi);
my_println("");
}
}
#endif
|
7a49213a059851b3f55e873a9939dcfcb88b2aca | fb06e4ce5299c5b92039c5076abaa7ca94ded116 | /Scene/OpenGLWidget.h | 62c4e49fed27191fda828f98b9f752a568c006ec | [] | no_license | nolanjian/Parametric-Furniture-Designer | a0fd0e17c8fb75197d7f38e26bad3fac56d4484f | 89dc2009b8446c7db46e803e32cb799d1e60cd04 | refs/heads/master | 2021-02-28T22:46:32.645730 | 2020-07-13T10:14:35 | 2020-07-13T10:14:35 | 245,738,186 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,354 | h | OpenGLWidget.h | /*****************************************************************//**
* \file OpenGLWidget.h
* \brief
*
* \author NolanJian
* \e-mail NolanJian@163.com
* \date 2020/07/02
*
*********************************************************************/
#pragma once
#include "scene_global.h"
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <osgViewer/Viewer>
#include <thread>
#include <map>
#include <memory>
#include <Utils/Utils.h>
#include <spdlog/spdlog.h>
namespace PFD
{
namespace Scene
{
class MouseButtonMap;
class KeyMap;
class SCENE_EXPORT OpenGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
explicit OpenGLWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~OpenGLWidget();
void InitCamera();
public slots:
void OpenFile();
signals:
void initialized();
protected:
void BeginTimer();
void StopTimer();
osg::Vec4 GetBackgroundColor3D();
protected:
virtual void initializeGL() override;
virtual void resizeGL(int w, int h) override;
virtual void paintGL() override;
protected:
// Event handlers
//bool event(QEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void mouseReleaseEvent(QMouseEvent* event) override;
virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
#if QT_CONFIG(wheelevent)
virtual void wheelEvent(QWheelEvent* event) override;
#endif
virtual void keyPressEvent(QKeyEvent* event) override;
virtual void keyReleaseEvent(QKeyEvent* event) override;
virtual void focusInEvent(QFocusEvent* event) override;
virtual void focusOutEvent(QFocusEvent* event) override;
virtual void enterEvent(QEvent* event) override;
virtual void leaveEvent(QEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void moveEvent(QMoveEvent* event) override;
//virtual void resizeEvent(QResizeEvent* event) override; // Avoid overriding this function in derived classes
virtual void closeEvent(QCloseEvent* event) override;
#ifndef QT_NO_CONTEXTMENU
virtual void contextMenuEvent(QContextMenuEvent* event) override;
#endif
#if QT_CONFIG(tabletevent)
virtual void tabletEvent(QTabletEvent* event) override;
#endif
#ifndef QT_NO_ACTION
virtual void actionEvent(QActionEvent* event) override;
#endif
#if QT_CONFIG(draganddrop)
virtual void dragEnterEvent(QDragEnterEvent* event) override;
virtual void dragMoveEvent(QDragMoveEvent* event) override;
virtual void dragLeaveEvent(QDragLeaveEvent* event) override;
virtual void dropEvent(QDropEvent* event);
#endif
virtual void showEvent(QShowEvent* event) override;
virtual void hideEvent(QHideEvent* event) override;
//#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// virtual bool nativeEvent(const QByteArray& eventType, void* message, qintptr* result);
//#else
// virtual bool nativeEvent(const QByteArray& eventType, void* message, long* result);
//#endif
private:
bool PhotorealisticShaders(osg::StateSet* stateSet);
void setDefaultDisplaySettings();
private:
std::shared_ptr<spdlog::logger> logger = spdlog::get(PFD_LOGGER);
osg::ref_ptr<osgViewer::Viewer> m_pViewer;
osg::ref_ptr<osgViewer::GraphicsWindow> m_pGraphicsWindow;
bool bInitOSG = false;
int m_nDevicePixelRatio = 1;
std::shared_ptr<QTimer> m_pTimer;
};
class MouseButtonMap
{
public:
static MouseButtonMap& Get();
int GetKey(Qt::MouseButton mouseButton);
protected:
MouseButtonMap();
private:
MouseButtonMap(const MouseButtonMap&) = delete;
MouseButtonMap(const MouseButtonMap&&) = delete;
MouseButtonMap& operator= (const MouseButtonMap&) = delete;
MouseButtonMap& operator= (const MouseButtonMap&&) = delete;
std::map<Qt::MouseButton, osgGA::GUIEventAdapter::MouseButtonMask> m_Mapping;
};
class KeyMap
{
public:
static KeyMap& Get();
int GetKey(Qt::Key key);
protected:
KeyMap();
private:
KeyMap(const KeyMap&) = delete;
KeyMap(const KeyMap&&) = delete;
KeyMap& operator= (const KeyMap&) = delete;
KeyMap& operator= (const KeyMap&&) = delete;
std::map<Qt::Key, osgGA::GUIEventAdapter::KeySymbol> m_Mapping;
};
} // namespace Scene
} // namespace PFD |
9620089711095562c1b1cdb27d75d6087b8560aa | e9c4bd6fae3a098ebb2a9a6c5b6bcc9c4f9a69f1 | /colecoes_genericas/PIlhas genericas/teste generico/Pilhas.cpp | 28418066f68f8634263b278f334b65dc1212f738 | [] | no_license | eduardoolima/EstruturaDeDados2-3-periodo | 1c14ba31feb0aa4fd963b9b4d2376ab8801c6ad3 | 10cf9297a1465225498712d26a7f8235d4845bdb | refs/heads/master | 2022-11-21T20:58:53.475539 | 2020-07-21T00:55:39 | 2020-07-21T00:55:39 | 281,257,181 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20 | cpp | Pilhas.cpp | #include "Pilhas.h"
|
fc09e780d21d9312bfaa0465ed156bc287ad7256 | 54590b39d4710d32bc129e0e9bf59fd5f56ac32d | /SDK/SoT_BP_cmn_wooden_foundations_05_a_parameters.hpp | 390a34f977d12da5c0da72649a36c1fe9cf96c95 | [] | no_license | DDan1l232/SoT-SDK | bb3bb85fa813963655288d6fa2747d316ce57af8 | cda078f3b8bca304759f05cc71ca55d31878e8e5 | refs/heads/master | 2023-03-17T13:16:11.076040 | 2020-09-09T15:19:09 | 2020-09-09T15:19:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 561 | hpp | SoT_BP_cmn_wooden_foundations_05_a_parameters.hpp | #pragma once
// Sea of Thieves (1.4.16) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "SoT_BP_cmn_wooden_foundations_05_a_classes.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
// Function BP_cmn_wooden_foundations_05_a.BP_cmn_wooden_foundations_05_a_C.UserConstructionScript
struct ABP_cmn_wooden_foundations_05_a_C_UserConstructionScript_Params
{
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
795259913e89a667b59f642350dc0fce21b3cf77 | ca948f316beb1379058b1483c13df56b62182bb4 | /include/device/peripherals/RTC.hpp | 512e246bf50344ce0526c3a305e2cc14f5ff8c31 | [] | no_license | CrustyAuklet/xmega-ecpp | 442cf2a2b9c100c0e03be34b94e20704badac918 | 338f1f1fb570a910105cdf57a4d0eb6df653aa2f | refs/heads/master | 2020-08-19T18:25:43.937990 | 2019-10-18T05:10:36 | 2019-11-25T00:46:24 | 215,942,690 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,578 | hpp | RTC.hpp | /**
* None-RTC (id I6093)
* Real-Time Counter
*
*
*/
#pragma once
#include "device/register.hpp"
#include <cstdint>
namespace device {
/**
* RTC
* Real-Time Counter
* Size: 14 bytes
*/
template <addressType BASE_ADDRESS>
struct RTC_t {
/// Control Register - 1 bytes
struct CTRL : public reg8_t<BASE_ADDRESS + 0x0000> {
typedef reg_field_t<BASE_ADDRESS + 0x0000, 0x07, 0> PRESCALER; //< Prescaling Factor using RTC_PRESCALER
};
/// Status Register - 1 bytes
struct STATUS : public reg8_t<BASE_ADDRESS + 0x0001> {
typedef reg_field_t<BASE_ADDRESS + 0x0001, 0x01, 0> SYNCBUSY; //< Synchronization Busy Flag using None
};
/// Interrupt Control Register - 1 bytes
struct INTCTRL : public reg8_t<BASE_ADDRESS + 0x0002> {
typedef reg_field_t<BASE_ADDRESS + 0x0002, 0x0C, 2> COMPINTLVL; //< Compare Match Interrupt Level using RTC_COMPINTLVL
typedef reg_field_t<BASE_ADDRESS + 0x0002, 0x03, 0> OVFINTLVL; //< Overflow Interrupt Level using RTC_OVFINTLVL
};
/// Interrupt Flags - 1 bytes
struct INTFLAGS : public reg8_t<BASE_ADDRESS + 0x0003> {
typedef reg_field_t<BASE_ADDRESS + 0x0003, 0x02, 1> COMPIF; //< Compare Match Interrupt Flag using None
typedef reg_field_t<BASE_ADDRESS + 0x0003, 0x01, 0> OVFIF; //< Overflow Interrupt Flag using None
};
/// Temporary register - 1 bytes
struct TEMP : public reg8_t<BASE_ADDRESS + 0x0004> {
};
/// Count Register - 2 bytes
struct CNT : public reg16_t<BASE_ADDRESS + 0x0008> {
};
/// Period Register - 2 bytes
struct PER : public reg16_t<BASE_ADDRESS + 0x000A> {
};
/// Compare Register - 2 bytes
struct COMP : public reg16_t<BASE_ADDRESS + 0x000C> {
};
// Prescaler Factor
class PRESCALERv {
public:
enum PRESCALER_ {
OFF = 0x00, // RTC Off
DIV1 = 0x01, // RTC Clock
DIV2 = 0x02, // RTC Clock / 2
DIV8 = 0x03, // RTC Clock / 8
DIV16 = 0x04, // RTC Clock / 16
DIV64 = 0x05, // RTC Clock / 64
DIV256 = 0x06, // RTC Clock / 256
DIV1024 = 0x07, // RTC Clock / 1024
};
PRESCALERv(const PRESCALER_& v) : value_(v) {}
operator uint8_t() const { return value_; }
private:
uint8_t value_;
};
// Compare Interrupt level
class COMPINTLVLv {
public:
enum COMPINTLVL_ {
OFF = 0x00, // Interrupt Disabled
LO = 0x01, // Low Level
MED = 0x02, // Medium Level
HI = 0x03, // High Level
};
COMPINTLVLv(const COMPINTLVL_& v) : value_(v) {}
operator uint8_t() const { return value_; }
private:
uint8_t value_;
};
// Overflow Interrupt level
class OVFINTLVLv {
public:
enum OVFINTLVL_ {
OFF = 0x00, // Interrupt Disabled
LO = 0x01, // Low Level
MED = 0x02, // Medium Level
HI = 0x03, // High Level
};
OVFINTLVLv(const OVFINTLVL_& v) : value_(v) {}
operator uint8_t() const { return value_; }
private:
uint8_t value_;
};
// RTC ISR Vector Offsets (two bytes each)
class INTERRUPTS {
public:
enum INTERRUPTS_ {
OVF = 0, // Overflow Interrupt
COMP = 1, // Compare Interrupt
};
INTERRUPTS(const INTERRUPTS_& v) : value_(v) {}
operator uint8_t() const { return value_; }
private:
uint8_t value_;
};
};
} // namespace device
|
05a27fd9e44fe741f96aae209abbf225c7090f77 | 26fd4d615946f73ee3964cd48fa06120611bf449 | /SkipList/C++_TYPE/skiplist.cpp | 5a6252756de4700b29b49256c1cb8451a4763374 | [] | no_license | xujie-nm/Leetcode | 1aab8a73a33f954bfb3382a286626a56d2f14617 | eb8a7282083e2d2a6c94475759ba01bd4220f354 | refs/heads/master | 2020-04-12T07:25:51.621189 | 2016-12-03T09:29:36 | 2016-12-03T09:29:36 | 28,400,113 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,510 | cpp | skiplist.cpp | #include "skiplist.h"
#include <stdlib.h>
#include <stdio.h>
SkiplistNode::SkiplistNode(int level, double score):score_(score){
levels_.reserve(level);
}
Skiplist::Skiplist(){
level_ = 1;
length_ = 0;
header_ = new SkiplistNode(SKIPLIST_MAXLEVEL, 0);
for (int i = 0; i < SKIPLIST_MAXLEVEL; i++) {
header_->levels_[i] = NULL;
}
header_->backward_ = NULL;
tail_ = NULL;
}
Skiplist::~Skiplist(){
SkiplistNode* node = header_->levels_[0];
SkiplistNode* next;
delete header_;
while(node){
next = node->levels_[0];
delete node;
node = next;
}
}
SkiplistNode* Skiplist::insert(double score){
SkiplistNode* update[SKIPLIST_MAXLEVEL];
SkiplistNode* node;
node = header_;
for (int i = level_-1; i >= 0; i--) {
while(node->levels_[i] &&
node->levels_[i]->score_ < score)
node = node->levels_[i];
update[i] = node;
}
int randomLevel = generateRandomLevel();
if(randomLevel > level_){
for (int i = level_; i < randomLevel; i++) {
update[i] = header_;
}
level_ = randomLevel;
}
node = new SkiplistNode(randomLevel, score);
for (int i = 0; i < randomLevel; i++) {
node->levels_[i] = update[i]->levels_[i];
update[i]->levels_[i] = node;
}
node->backward_ = (update[0] == header_ ? NULL : update[0]);
if(node->levels_[0])
node->levels_[0]->backward_ = node;
else
tail_ = node;
length_++;
return node;
}
int Skiplist::deleteItem(double score){
SkiplistNode* update[SKIPLIST_MAXLEVEL];
SkiplistNode* node;
node = header_;
for (int i = level_-1; i >= 0; i--) {
while(node->levels_[i]
&& node->levels_[i]->score_ < score){
node = node->levels_[i];
}
update[i] = node;
}
node = node->levels_[0];
if(node && score == node->score_){
deleteNode(node, update);
delete node;
return 1;
}
return 0;
}
int Skiplist::search(double score){
SkiplistNode* node;
node = header_;
for (int i = level_-1; i >= 0; i--) {
while(node->levels_[i]
&& node->levels_[i]->score_ < score){
node = node->levels_[i];
}
}
node = node->levels_[0];
if(node && score == node->score_){
printf("Found %d\n", (int)(node->score_));
return 1;
}else{
printf("Not Found %d\n", (int)score);
return 0;
}
}
void Skiplist::print(){
SkiplistNode* node;
for (int i = 0; i < SKIPLIST_MAXLEVEL; i++) {
printf("LEVEL[%d]: ", i);
node = header_->levels_[i];
while(node){
printf("%d -> ", (int)(node->score_));
node = node->levels_[i];
}
printf("NULL\n");
}
}
int Skiplist::generateRandomLevel(){
int randomLevel = 1;
while((rand()&0xFFFF) < (0.5 * 0xFFFF))
randomLevel += 1;
return (randomLevel < SKIPLIST_MAXLEVEL) ?
randomLevel : SKIPLIST_MAXLEVEL;
}
void Skiplist::deleteNode(SkiplistNode* x, SkiplistNode** update){
for (int i = 0; i < level_; i++) {
if(update[i]->levels_[i] == x){
update[i]->levels_[i] = x->levels_[i];
}
}
if(x->levels_[0]){
x->levels_[0]->backward_ = x->backward_;
}else{
tail_ = x->backward_;
}
while(level_ > 1 && header_->levels_[level_-1] == NULL)
level_--;
length_--;
}
|
38d6b12ade807c66c99d7c6af555012d1cd9b358 | 49e19faa999df3abfbfc49e692b9e8cee3208649 | /XULWin/include/XULWin/ElementFactory.h | f1a70b4d20512b70cb5928acd5d114e6a5816564 | [] | no_license | StackedCrooked/xulwin | 30a29a09636738f4821821e05ee6223d114de76b | 1d3c10d0d39b848ff5d121f3dbf21fa489d032a7 | refs/heads/master | 2021-05-02T05:49:47.691311 | 2017-08-03T21:24:55 | 2017-08-03T21:24:55 | 32,498,027 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,931 | h | ElementFactory.h | #ifndef ELEMENTFACTOR_H_INCLUDED
#define ELEMENTFACTOR_H_INCLUDED
#include "XULWin/Element.h"
#include <boost/bind.hpp>
#include <boost/function.hpp>
namespace XULWin
{
class ElementFactory
{
public:
static ElementFactory & Instance();
/**
* createElement
*
* Factory method for the creation of a XUL Element object based on it's XUL type identifier.
*/
ElementPtr createElement(const std::string & inType, Element * inParent, const AttributesMapping & inAttr);
/**
* registerElement
*
* This method adds a mapping for the given element's XUL type identifier
* with the element's factory method (in the form of a function object).
*
*
* This results in a lookup table that looks like this:
*
* "label" => XMLLabel::Create(...)
* "button" => XMLButton::Create(...)
* "checkbox" => XMLCheckBox::Create(...)
* ...
*
* Because the XUL type identifier is defined as a class property it suffices
* to pass the classname in the form of a template parameter. For example:
*
* ElementFactory::Instance().registerElement<XMLLabel>();
*/
template<class ElementType>
void registerElement()
{
mFactoryMethods.insert(std::make_pair(ElementType::TagName(),
boost::bind(ElementType::Create, _1, _2)));
}
private:
ElementFactory();
typedef boost::function<ElementPtr(Element *, const AttributesMapping &)> FactoryMethod;
typedef std::map<std::string, FactoryMethod> FactoryMethods;
FactoryMethods mFactoryMethods;
};
} // namespace XULWin
#endif // ELEMENTFACTOR_H_INCLUDED
|
1943537df92ae19be38bc4ce67528b09d955b577 | 2b1fa87ab788c70130c8ed2735dea795fce4c376 | /data_structures/stack/unit_tests/stack_dynamic_array_utest.cpp | d020b59d37e95b6b0ae331316e7eb90a004b975a | [] | no_license | segoranov/data_structures_and_algorithms | e77d0634e5c0df4a25a0662153698daad45bae88 | fc029eb96a0e6f4bfeac8eeff1f410a39b1a8cdb | refs/heads/master | 2022-12-11T14:43:55.064967 | 2020-09-09T10:27:41 | 2020-09-09T10:27:41 | 258,244,134 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 953 | cpp | stack_dynamic_array_utest.cpp | #include "catch.hpp"
#include "stack_dynamic_array.h"
TEST_CASE("Stack is empty on construction with default constructor") {
StackDynamicArrayImpl<int> stack;
REQUIRE(stack.empty());
REQUIRE(stack.size() == 0);
REQUIRE_THROWS_AS(stack.top(), std::runtime_error);
}
TEST_CASE("Push and pop one element on stack") {
StackDynamicArrayImpl<int> stack;
stack.push(5);
REQUIRE(stack.size() == 1);
REQUIRE(!stack.empty());
REQUIRE(stack.top() == 5);
stack.pop();
REQUIRE(stack.size() == 0);
REQUIRE(stack.empty());
REQUIRE_THROWS_AS(stack.top(), std::runtime_error);
}
TEST_CASE("Push and pop many elements on stack") {
StackDynamicArrayImpl<int> stack;
for (int i = 1; i <= 1000; i++) {
stack.push(i);
REQUIRE(stack.top() == i);
REQUIRE(stack.size() == i);
}
for (int i = 1000; i >= 1; i--) {
REQUIRE(stack.size() == i);
REQUIRE(stack.top() == i);
stack.pop();
}
REQUIRE(stack.empty());
}
|
1a96c183b0509616c719f17061d56424c0de79ec | 9f63b75a1ac13e181ca99d558580e3527a45c0c6 | /4.Maths/10.Prime_Most_efficient.cpp | 9b05630cfa5ef3c93582f49c738954b772423156 | [] | no_license | smritipradhan/Datastructure | 3934cfb27406d84b6840955645026e7b7595f8ea | 74ecf07496fc571f9d676efe95dcdb796dc069e3 | refs/heads/master | 2023-07-11T11:58:33.515265 | 2021-08-11T14:26:11 | 2021-08-11T14:26:11 | 322,194,016 | 1 | 0 | null | 2021-08-11T14:26:12 | 2020-12-17T05:46:07 | C++ | UTF-8 | C++ | false | false | 434 | cpp | 10.Prime_Most_efficient.cpp | //Efficient_method for finding the prime
//Using Divisors
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
if(n==1)
return false;
if(n==2||n==3)
return true;
if(n%2==0||n%3==0)
return false;
for(int i = 5;i*i<=n;i=i+6)
{
if(n%i==0 || n%(i+2)==0)
return false;
}
return true;
}
int main()
{
int n = 1031;
cout<<isPrime(n);
return 0;
}
|
9ae9c3eeb4f847e7ef8368c9f42f70d7cac0d94f | 733882805346a6e34156a88bb04e9cdc97ca8ba5 | /tools/codegen/Parser/ReflectionParser.cpp | fa2c8e1c13803e1fdb5e8f0030c3f06c1e27b74b | [
"MIT"
] | permissive | ostis-dev/sc-machine | 21e14d8293378174f9321517c2d7bc3e94f8495c | 84c2b74b06d786bec75c1aa096e3dc95fbfdb3f7 | refs/heads/master | 2021-11-28T01:51:40.819230 | 2021-10-13T10:39:44 | 2021-10-13T10:39:44 | 3,524,603 | 13 | 17 | NOASSERTION | 2023-02-21T09:08:55 | 2012-02-23T11:04:25 | C++ | UTF-8 | C++ | false | false | 10,675 | cpp | ReflectionParser.cpp | #include "ReflectionParser.hpp"
#include <iostream>
#include <fstream>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#define RECURSE_NAMESPACES(kind, cursor, method, ns) \
if (kind == CXCursor_Namespace) \
{ \
auto displayName = cursor.GetDisplayName(); \
if (!displayName.empty()) \
{ \
ns.emplace_back(displayName); \
method(cursor, ns); \
ns.pop_back(); \
} \
}
namespace impl
{
void displayDiagnostics (CXTranslationUnit tu)
{
if (tu == 0)
{
std::cerr << "Parsing error!" << std::endl;
return;
}
int const numDiagnostics = clang_getNumDiagnostics(tu);
for (int i = 0; i < numDiagnostics; ++i)
{
auto const diagnostic = clang_getDiagnostic (tu, i);
auto const string = clang_formatDiagnostic (diagnostic, clang_defaultDiagnosticDisplayOptions());
std::cerr << clang_getCString (string) << std::endl;
clang_disposeString (string);
clang_disposeDiagnostic (diagnostic);
}
}
} // namespace impl
ReflectionParser::ReflectionParser(const ReflectionOptions &options)
: m_options(options)
, m_index(nullptr)
, m_translationUnit(nullptr)
, m_sourceCache(nullptr)
{
}
void ReflectionParser::CollectFiles(std::string const & inPath, tStringList & outFiles)
{
boost::filesystem::recursive_directory_iterator itEnd, it(inPath);
while (it != itEnd)
{
if (!boost::filesystem::is_directory(*it))
{
boost::filesystem::path path = *it;
std::string filename = path.string();
std::string ext = GetFileExtension(filename);
std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
if (((ext == "hpp") || (ext == "h")) && (filename.find(".generated.") == std::string::npos))
{
outFiles.push_back(filename);
}
}
try
{
++it;
}
catch (std::exception & ex)
{
std::cout << ex.what() << std::endl;
it.no_push();
try
{
++it;
}
catch (...)
{
std::cout << ex.what() << std::endl;
return;
}
}
}
}
void ReflectionParser::Parse()
{
tStringList filesList;
std::string moduleFile;
CollectFiles(m_options.inputPath, filesList);
if (m_options.useCache)
{
m_sourceCache.reset(new SourceCache(m_options.buildDirectory, m_options.targetName));
m_sourceCache->Load();
m_sourceCache->CheckGenerator(m_options.generatorPath);
}
if (m_options.displayDiagnostic)
{
std::cout << "Flags: " << std::endl;
for (auto const & f : m_options.arguments)
std::cout << f << std::endl;
}
// ensure that output directory exist
boost::filesystem::create_directory(boost::filesystem::path(m_options.outputPath));
for (tStringList::const_iterator it = filesList.begin(); it != filesList.end(); ++it)
{
try
{
// if contains module, then process it later
if (!ProcessFile(*it))
{
if (!moduleFile.empty())
{
EMIT_ERROR("You couldn't implement two module classes in one module");
}
moduleFile = *it;
}
}
catch (Exception e)
{
EMIT_ERROR(e.GetDescription() << " in " << *it);
}
}
try
{
if (!moduleFile.empty())
ProcessFile(moduleFile, true);
}
catch (Exception e)
{
EMIT_ERROR(e.GetDescription() << " in " << moduleFile);
}
if (m_options.useCache)
m_sourceCache->Save();
}
void ReflectionParser::Clear()
{
m_currentFile = "";
m_classes.clear();
m_globals.clear();
m_globalFunctions.clear();
}
bool ReflectionParser::ProcessFile(std::string const & fileName, bool inProcessModule)
{
if (!inProcessModule && m_options.useCache && !m_sourceCache->RequestGenerate(fileName))
return true;
if (m_options.displayDiagnostic)
std::cout << "Processing file: " << fileName << std::endl;
Clear();
m_currentFile = fileName;
m_index = clang_createIndex(true, false);
std::vector<const char *> arguments;
for (auto &argument : m_options.arguments)
{
// unescape flags
boost::algorithm::replace_all(argument, "\\-", "-");
arguments.emplace_back(argument.c_str());
}
m_translationUnit = clang_createTranslationUnitFromSourceFile(
m_index,
fileName.c_str(),
static_cast<int>(arguments.size()),
arguments.data(),
0,
nullptr
);
if (m_options.displayDiagnostic)
impl::displayDiagnostics(m_translationUnit);
auto cursor = clang_getTranslationUnitCursor(m_translationUnit);
try
{
Namespace tempNamespace;
buildClasses(cursor, tempNamespace);
tempNamespace.clear();
if (ContainsModule() && !inProcessModule)
{
if (m_classes.size() > 1)
{
EMIT_ERROR("You can't implement any other classes in one file with module class");
}
return false;
}
if (RequestGenerate())
{
std::string fileId = GetFileID(fileName);
std::stringstream outCode;
// includes
outCode << "#include <memory>\n\n";
outCode << "#include \"sc-memory/sc_memory.hpp\"\n\n\n";
outCode << "#include \"sc-memory/sc_event.hpp\"\n\n\n";
for (auto const & klass : m_classes)
{
if (klass->ShouldGenerate())
klass->GenerateCode(fileId, outCode, this);
}
/// write ScFileID definition
outCode << "\n\n#undef ScFileID\n";
outCode << "#define ScFileID " << fileId;
// generate output file
boost::filesystem::path outputPath(m_options.outputPath);
outputPath /= boost::filesystem::path(GetOutputFileName(fileName));
std::ofstream outputFile(outputPath.string());
outputFile << outCode.str();
outputFile << std::endl << std::endl;
outputFile.close();
}
clang_disposeIndex(m_index);
clang_disposeTranslationUnit(m_translationUnit);
}
catch (Exception e)
{
clang_disposeIndex(m_index);
clang_disposeTranslationUnit(m_translationUnit);
EMIT_ERROR(e.GetDescription());
}
return true;
}
void ReflectionParser::ResetCache()
{
if (m_sourceCache)
m_sourceCache->Reset();
}
bool ReflectionParser::IsInCurrentFile(Cursor const & cursor) const
{
return cursor.GetFileName() == m_currentFile;
}
bool ReflectionParser::RequestGenerate() const
{
for (auto it = m_classes.begin(); it != m_classes.end(); ++it)
{
if ((*it)->ShouldGenerate())
return true;
}
return false;
}
bool ReflectionParser::ContainsModule() const
{
for (auto it = m_classes.begin(); it != m_classes.end(); ++it)
{
if ((*it)->IsModule())
return true;
}
return false;
}
void ReflectionParser::buildClasses(const Cursor &cursor, Namespace ¤tNamespace)
{
for (auto &child : cursor.GetChildren())
{
// skip classes from other files
if (!IsInCurrentFile(child))
continue;
auto const kind = child.GetKind();
// actual definition and a class or struct
if (child.IsDefinition() && (kind == CXCursor_ClassDecl || kind == CXCursor_StructDecl))
m_classes.emplace_back(new Class(child, currentNamespace));
RECURSE_NAMESPACES(kind, child, buildClasses, currentNamespace);
}
}
void ReflectionParser::DumpTree(Cursor const & cursor, size_t level, std::stringstream & outData)
{
outData << "\n";
for (size_t i = 0; i < level; ++i)
outData << "-";
outData << cursor.GetDisplayName() << ", " << cursor.GetKind();
for (auto &child : cursor.GetChildren())
{
DumpTree(child, level + 1, outData);
}
}
//void ReflectionParser::buildGlobals(const Cursor &cursor, Namespace ¤tNamespace)
//{
// for (auto &child : cursor.GetChildren())
// {
// // skip static globals (hidden)
// if (child.GetStorageClass() == CX_SC_Static)
// continue;
//
// auto kind = child.GetKind();
//
// // variable declaration, which is global
// if (kind == CXCursor_VarDecl)
// {
// m_globals.emplace_back(
// new Global(child, currentNamespace)
// );
// }
//
// RECURSE_NAMESPACES(kind, child, buildGlobals, currentNamespace);
// }
//}
//
//void ReflectionParser::buildGlobalFunctions(const Cursor &cursor, Namespace ¤tNamespace)
//{
// for (auto &child : cursor.GetChildren())
// {
// // skip static globals (hidden)
// if (child.GetStorageClass() == CX_SC_Static)
// continue;
//
// auto kind = child.GetKind();
//
// // function declaration, which is global
// if (kind == CXCursor_FunctionDecl)
// {
// m_globalFunctions.emplace_back(new Function(child, currentNamespace));
// }
//
// RECURSE_NAMESPACES(
// kind,
// child,
// buildGlobalFunctions,
// currentNamespace
// );
// }
//}
//
//void ReflectionParser::buildEnums(const Cursor &cursor, Namespace ¤tNamespace)
//{
// for (auto &child : cursor.GetChildren())
// {
// auto kind = child.GetKind();
//
// // actual definition and an enum
// if (child.IsDefinition() && kind == CXCursor_EnumDecl)
// {
// // anonymous enum if the underlying type display name contains this
// if (child.GetType().GetDisplayName().find("anonymous enum at")
// != std::string::npos)
// {
// // anonymous enums are just loaded as
// // globals with each of their values
// Enum::LoadAnonymous(m_globals, child, currentNamespace);
// }
// else
// {
// m_enums.emplace_back(
// new Enum(child, currentNamespace)
// );
// }
// }
//
// RECURSE_NAMESPACES(kind, child, buildEnums, currentNamespace);
// }
//}
std::string ReflectionParser::GetFileExtension(std::string const & fileName)
{
// get file extension
size_t n = fileName.rfind(".");
if (n == std::string::npos)
return std::string();
return fileName.substr(n + 1, std::string::npos);
}
std::string ReflectionParser::GetOutputFileName(std::string const & fileName)
{
boost::filesystem::path const inputPath(fileName);
std::string baseName = inputPath.filename().replace_extension().string();
return baseName + ".generated" + inputPath.extension().string();
}
std::string ReflectionParser::GetFileID(std::string const & fileName)
{
boost::filesystem::path inputPath(fileName);
std::string res = inputPath.filename().string();
for (std::string::iterator it = res.begin(); it != res.end(); ++it)
{
if (*it == ' ' || *it == '-' || *it == '.')
{
*it = '_';
}
}
return res;
}
|
6eb77f9fd3ad85287d08c1ef99f329cc8d9abd84 | 1c701d7376af153b2136743a707e87821014ff72 | /addmovie.cpp | 14b773b57aa699c5112a136dc174f27eb050deee | [] | no_license | DanziLLL/visual_course | 03d57baba60a7cabf5de799f8e9332341ab55edf | 715291fae2db1962be9a69d6212508c1da769772 | refs/heads/master | 2021-04-15T14:19:53.766041 | 2018-04-05T17:43:07 | 2018-04-05T17:43:07 | 126,198,271 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,636 | cpp | addmovie.cpp | #include "addmovie.h"
#include "ui_addmovie.h"
AddMovie::AddMovie(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddMovie)
{
ui->setupUi(this);
}
AddMovie::~AddMovie()
{
delete ui;
}
void AddMovie::on_btn_findMovie_clicked()
{
QString s;
s = QString("https://www.google.com/search?q=%1 +insite:imdb.com&btnI").arg(ui->movieName->text());
QUrl q(s);
this->v->show();
qDebug() << q;
v->load(q);
}
void AddMovie::on_btn_addMovie_clicked()
{
QString name = "default", dir = "default", coun = "default",
stud = "default", release = "00/00/00", synop = "default";
if (ui->movieName->text() != "") {
name = ui->movieName->text();
}
if (ui->director->text() != "") {
dir = ui->director->text();
}
if (ui->country->text() != "") {
coun = ui->country->text();
}
if (ui->studio->text() != "") {
stud = ui->studio->text();
}
if (ui->releaseDate->text() != "") {
release = ui->releaseDate->text();
}
if (ui->synopsis->toPlainText() != "") {
synop = ui->synopsis->toPlainText();
}
QSqlQuery q(db);
QString query;
query = QString("INSERT INTO `moviedb` (name, director, country, studio, release_date, synopsis) "
"VALUES ('%1', '%2', '%3', '%4', '%5', '%6');").arg(name).arg(dir)
.arg(coun).arg(stud).arg(release).arg(synop);
q.exec(query);
query = QString("INSERT INTO `rent_log` (name, date_start, date_end, date_return, user) "
"VALUES ('%1', CURDATE(), CURDATE(), CURDATE(), 'admin');").arg(name);
q.exec(query);
}
|
2679675c2f1d22d91bcbef9039c8112d5cef73f1 | 81a1367960cf88168ba38bccfdcd01e22b33a4fc | /app/test/fixed/signal/Arithmetics/nmppsMulC_AddC/nmppsMulC_AddC_2x32s/main.cpp | 76f6833bcb7bbaa12bb4ceb9da48f9bf1009c194 | [] | no_license | RC-MODULE/nmpp | 3ade5fdd40f24960e586669febae715885e21330 | a41c26c650c2dee42b2ae07329f7e139c4178134 | refs/heads/master | 2022-11-02T07:56:09.382120 | 2022-09-21T17:34:38 | 2022-09-21T17:34:38 | 44,173,133 | 9 | 12 | null | 2022-04-28T08:42:55 | 2015-10-13T11:59:04 | Assembly | UTF-8 | C++ | false | false | 1,204 | cpp | main.cpp | #include "nmpp.h"
#include "minrep.h"
/////////////////////////////////////////////////////////////////////////////////////////
nm64s *L0;
nm64s *L1;
nm64s *G0;
nm64s *G1;
const int KB=1024/8;
const int SizeL0=30*KB;
const int SizeL1=30*KB;
const int SizeG0=30*KB;
const int SizeG1=30*KB;
int main()
{
L0=nmppsMalloc_64s(SizeL0);
L1=nmppsMalloc_64s(SizeL1);
G0=nmppsMalloc_64s(SizeG0);
G1=nmppsMalloc_64s(SizeG1);
if ((L0==0)||(L1==0)||(G0==0)||(G1==0)) return -1;
unsigned int crc = 0;
int MaxIntSize=1024;
MaxIntSize=MIN(MaxIntSize,SizeL0*8);
MaxIntSize=MIN(MaxIntSize,SizeG0*8);
nmppsRandUniform_32u((nm32u*)L0,SizeL0*2);
nmppsSet_32s((int)0xCCCCCCCC,(nm32s*)G0,(SizeG0*2));
for(int size=1;size<128;size++)
for(int stepSrc=1;stepSrc<5;stepSrc++)
for(int stepDst=1;stepDst<5;stepDst++)
{
int32x2 MulN;
MulN.lo=1;//nmppsRandUniform_();
MulN.hi=2;//nmppsRandUniform_();
int32x2 AddN;
AddN.lo=3;//nmppsRandUniform_();
AddN.hi=4;//nmppsRandUniform_();
nmppsMulC_AddC_2x32s((int32x2*)L0,&MulN,&AddN,(int32x2*)G0,size,1,1);
nmppsCrcAcc_64u((nm64u*)G0,size*5,&crc);
}
nmppsFree(L0);
nmppsFree(L1);
nmppsFree(G0);
nmppsFree(G1);
return crc>>2;
}
|
658fa622dbd927e125d0d602f709ea5470fe6087 | d629094ddb5171c825d725e263b5e21046ef2446 | /examples/catch2/fib.hpp | 559e886c8de95509de065f4539e8c5bc9810394a | [
"MIT"
] | permissive | NathanielRN/github-action-benchmark | ce6385e111aefd9d52caa83139defee3fc0e5e75 | 7fbd0c5a3a6fe64f9b7675856fcef69811191b5a | refs/heads/master | 2023-08-22T03:22:31.111327 | 2021-08-16T08:34:31 | 2021-10-12T20:12:29 | 396,634,646 | 1 | 1 | MIT | 2021-10-16T00:11:34 | 2021-08-16T05:30:41 | TypeScript | UTF-8 | C++ | false | false | 177 | hpp | fib.hpp | #if !defined FIB_HPP_INCLUDED
#define FIB_HPP_INCLUDED
int fib(int const i) {
if (i <= 1) {
return 1;
}
return fib(i - 2) + fib(i - 1);
}
#endif // FIB_HPP_INCLUDED
|
dea58282fa5c582cc8450f8f1222e52f6f93a4e9 | 5e6910a3e9a20b15717a88fd38d200d962faedb6 | /AtCoder/abc261/F.cpp | fdbe2ce9bcc25f7b800fad2f005f25a6b38a54dd | [] | no_license | khaledsliti/CompetitiveProgramming | f1ae55556d744784365bcedf7a9aaef7024c5e75 | 635ef40fb76db5337d62dc140f38105595ccd714 | refs/heads/master | 2023-08-29T15:12:04.935894 | 2023-08-15T13:27:12 | 2023-08-15T13:27:12 | 171,742,989 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,869 | cpp | F.cpp | // RedStone
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
const int N = 3e5 + 5;
template<typename T>
class fenwick {
vector<T> fen;
int n;
void addPr(int x, T v) {
for(int i = x; i < n; i += i & -i) {
fen[i] += v;
}
}
T getPr(int x) {
T v{};
for(int i = x; i > 0; i -= i & -i) {
v += fen[i];
}
return v;
}
public:
fenwick(int _n) : n(_n + 1) {
fen.resize(n, T());
}
void add(int x, T v) {
addPr(x + 1, v);
}
T get(int x) {
return getPr(x + 1);
}
T get(int l, int r) {
return get(r) - get(l - 1);
}
};
int n;
int c[N], v[N];
int nxt[N], last[N];
int vis[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n;
for(int i = 0; i < n; i++) {
cin >> c[i];
c[i]--;
}
for(int i = 0; i < n; i++) {
cin >> v[i];
v[i]--;
}
for(int i = 0; i <= n; i++) {
last[i] = n;
}
for(int i = n - 1; i >= 0; i--) {
nxt[i] = last[c[i]];
last[c[i]] = i;
}
long long ans = 0;
fenwick<int> fn(n);
for(int i = 0; i < n; i++) {
if(v[i] + 1 < n) {
ans += fn.get(v[i] + 1, n - 1);
}
fn.add(v[i], 1);
}
for(int i = 0; i < n; i++) {
fn.add(v[i], -1);
}
// for(int i = 0; i < n; i++) {
// cout << nxt[i] << " ";
// }
// cout << endl;
for(int i = 0; i < n; i++) {
if(vis[i]) continue;
for(int j = i; j < n; j = nxt[j]) {
if(v[j] + 1 < n) {
ans -= fn.get(v[j] + 1, n - 1);
}
fn.add(v[j], 1);
}
for(int j = i; j < n; j = nxt[j]) {
fn.add(v[j], -1);
vis[j] = 1;
}
}
cout << ans << endl;
return 0;
}
|
c4ac3ef79529ef4a8a17a055a689f4b26bfb5a23 | 119848599720941bf1c4740ea201bb6f5bc5a7bf | /D04/ex04/inc/StripMiner.hpp | 70dcf1be620bf431b97843da9490a48c5e2a7584 | [] | no_license | stmartins/piscine_cpp | 22981f0544808af9832345311a049f8358b049ae | 9acc41cae123a51efec94df1571f21c78b702c11 | refs/heads/master | 2021-04-06T04:21:47.530808 | 2018-04-06T14:40:09 | 2018-04-06T14:40:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 353 | hpp | StripMiner.hpp | #ifndef STRIPMINER_HPP
#define STRIPMINER_HPP
#include "IMiningLaser.hpp"
#include <iostream>
class StripMiner: public IMiningLaser
{
public:
StripMiner(void);
StripMiner(StripMiner const & src);
virtual ~StripMiner();
virtual void mine(IAsteroid*);
StripMiner &operator=(StripMiner const & rhs);
};
#endif |
2e98c9ae90ea895f0f74b03cefea98d4e59e0453 | 1f032ac06a2fc792859a57099e04d2b9bc43f387 | /b9/11/c9/50/a98a6141c118b538e6760bd8a8e7f757410c0d26eb1b85fe03bbe0915497383fde4d14d9bdce3bd07a29513985aaec180adc3c93649a80356ef2365f/sw.cpp | 36af4f8d2c36cccbdae097fd56fbd2efe7f7cb6a | [] | no_license | SoftwareNetwork/specifications | 9d6d97c136d2b03af45669bad2bcb00fda9d2e26 | ba960f416e4728a43aa3e41af16a7bdd82006ec3 | refs/heads/master | 2023-08-16T13:17:25.996674 | 2023-08-15T10:45:47 | 2023-08-15T10:45:47 | 145,738,888 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 167 | cpp | sw.cpp | void build(Solution &s)
{
auto &t = s.addTarget<StaticLibraryTarget>("aantron.better_enums", "0.11.3");
t += Git("https://github.com/aantron/better-enums");
}
|
96dd4159d489b1ef6307ddff755f17f6bc771d24 | cc62ddd6bdaba7133c993f4fa8ce7ee60b5fe336 | /EagleyeServer/View/DetailDlg.cpp | e4cd3a8e6be83b155c333bb6f4529240315100b0 | [] | no_license | sdgdsffdsfff/Eagleye-1 | a88bd153b31a34bacbb681e41dd02e50fb40cd74 | 2817fd3dc4fe135ae0bb1a6fbfebf8ee8cb87519 | refs/heads/master | 2020-12-25T10:13:56.203979 | 2013-09-07T14:31:18 | 2013-09-07T14:31:55 | 41,772,586 | 0 | 1 | null | 2015-09-02T01:31:35 | 2015-09-02T01:31:35 | null | GB18030 | C++ | false | false | 2,855 | cpp | DetailDlg.cpp | // DetailDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "EagleyeServer.h"
#include "DetailDlg.h"
// CDetailDlg 对话框
IMPLEMENT_DYNAMIC(CDetailDlg, CDialog)
CDetailDlg::CDetailDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDetailDlg::IDD, pParent)
{
}
CDetailDlg::~CDetailDlg()
{
}
void CDetailDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TAB, m_Tab);
}
BEGIN_MESSAGE_MAP(CDetailDlg, CDialog)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, &CDetailDlg::OnTcnSelchangeTab)
ON_WM_TIMER()
END_MESSAGE_MAP()
// CDetailDlg 消息处理程序
BOOL CDetailDlg::OnInitDialog()
{
CDialog ::OnInitDialog ();
//初始化TAB标签控件
TCITEM item;
item.mask = TCIF_TEXT;
item.pszText = _T("基本信息");
m_Tab.InsertItem(0,&item);
item.mask = TCIF_TEXT;
item.pszText = _T("进程列表");
m_Tab.InsertItem(1,&item);
m_BaseInfoDlg .Create(IDD_BASEINFO_FORMVIEW,&m_Tab);
m_ProcessDlg .Create(IDD_PROCESS_FORMVIEW,&m_Tab);
CRect rect;
m_Tab.GetClientRect(&rect);
m_BaseInfoDlg.SetWindowPos(NULL,rect.left,rect.top+20,rect.right,rect.bottom,SWP_SHOWWINDOW);
m_ProcessDlg.SetWindowPos(NULL,rect.left,rect.top+20,rect.right,rect.bottom,SWP_HIDEWINDOW);
//徐获取客户端刷新频率
SetTimer(1,5000,NULL) ;
return TRUE;
}
void CDetailDlg::OnTcnSelchangeTab(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: 在此添加控件通知处理程序代码
CRect rect;
m_Tab.GetClientRect(&rect);
switch(m_Tab.GetCurSel())
{
case 0:
m_BaseInfoDlg.SetWindowPos(NULL,rect.left,rect.top+20,rect.right,rect.bottom,SWP_SHOWWINDOW);
m_ProcessDlg .SetWindowPos(NULL,rect.left,rect.top+20,rect.right,rect.bottom,SWP_HIDEWINDOW);
break;
case 1:
m_BaseInfoDlg.SetWindowPos(NULL,rect.left,rect.top+20,rect.right,rect.bottom,SWP_HIDEWINDOW);
m_ProcessDlg.SetWindowPos(NULL,rect.left,rect.top+20,rect.right,rect.bottom,SWP_SHOWWINDOW);
break;
}
*pResult = 0;
}
void CDetailDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CString csUprate;
csUprate.Format (TEXT("%d"),m_pMonitoredPC ->m_Uprate[19]);
csUprate+="kbps";
CString csDownrate;
csDownrate.Format (TEXT("%d"),m_pMonitoredPC ->m_Downrate[19]);
csDownrate+="kbps";
this->GetDlgItem (IDC_UPRATE_EDIT)->SetWindowTextW (csUprate);
this->GetDlgItem (IDC_DOWNRATE_EDIT)->SetWindowTextW (csDownrate);
int nIndex,i;
CString sTem;
char csTem[10];
m_ProcessDlg.m_pProcess->DeleteAllItems();
for (i=0; i<m_pMonitoredPC->m_ProcessList.size(); i++)
{
itoa( m_pMonitoredPC->m_ProcessList.at(i).m_nPID, csTem, 10);
sTem = csTem;
nIndex = m_ProcessDlg.m_pProcess->InsertItem(0, sTem);
sTem = m_pMonitoredPC->m_ProcessList.at(i).m_csName.c_str();
m_ProcessDlg.m_pProcess->SetItemText(nIndex, 1, sTem);
}
CDialog::OnTimer(nIDEvent);
}
|
62fe660307fc5c0728dc5ebb85b2f7520ce1d313 | f850eb5b2f547764d05baa2332fa1bfe76a05274 | /chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc | 0a84f4259bff3ac5ce4c87c9e12dc2836ede6e11 | [
"BSD-3-Clause"
] | permissive | junmin-zhu/chromium-rivertrail | 2c4d74d57a9e2eead500c39d213ac8db4bac29a2 | eb1a57aca71fe68d96e48af8998dcfbe45171ee1 | refs/heads/v8-binding | 2021-03-12T19:35:42.746460 | 2013-06-03T15:05:26 | 2013-06-04T01:49:35 | 6,220,384 | 0 | 1 | null | 2013-06-03T02:50:01 | 2012-10-15T01:51:13 | C++ | UTF-8 | C++ | false | false | 4,788 | cc | error_screen_handler.cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#include "base/logging.h"
#include "base/values.h"
#include "chrome/browser/chromeos/login/captive_portal_window_proxy.h"
#include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
#include "content/public/browser/web_ui.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
ErrorScreenHandler::ErrorScreenHandler(
const scoped_refptr<NetworkStateInformer>& network_state_informer)
: network_state_informer_(network_state_informer),
native_window_delegate_(NULL) {
DCHECK(network_state_informer_);
network_state_informer_->AddObserver(this);
}
ErrorScreenHandler::~ErrorScreenHandler() {
network_state_informer_->RemoveObserver(this);
}
void ErrorScreenHandler::SetNativeWindowDelegate(
NativeWindowDelegate* native_window_delegate) {
native_window_delegate_ = native_window_delegate;
}
void ErrorScreenHandler::UpdateState(NetworkStateInformer::State state,
const std::string& network_name,
const std::string& reason,
ConnectionType last_network_type) {
LOG(ERROR) << "ErrorScreenHandler::UpdateState(): state=" << state <<
", network_name=" << network_name <<
", reason=" << reason <<
", last_network_type=" << last_network_type;
// TODO (ygorshenin): instead of just call JS function, move all
// logic from JS here.
base::FundamentalValue state_value(state);
base::StringValue network_value(network_name);
base::StringValue reason_value(reason);
base::FundamentalValue last_network_value(last_network_type);
web_ui()->CallJavascriptFunction("login.ErrorMessageScreen.updateState",
state_value, network_value, reason_value, last_network_value);
}
void ErrorScreenHandler::GetLocalizedStrings(
base::DictionaryValue* localized_strings) {
localized_strings->SetString("offlineMessageTitle",
l10n_util::GetStringUTF16(IDS_LOGIN_OFFLINE_TITLE));
localized_strings->SetString("offlineMessageBody",
l10n_util::GetStringUTF16(IDS_LOGIN_OFFLINE_MESSAGE));
localized_strings->SetString("captivePortalTitle",
l10n_util::GetStringUTF16(IDS_LOGIN_MAYBE_CAPTIVE_PORTAL_TITLE));
localized_strings->SetString("captivePortalMessage",
l10n_util::GetStringUTF16(IDS_LOGIN_MAYBE_CAPTIVE_PORTAL));
localized_strings->SetString("captivePortalProxyMessage",
l10n_util::GetStringUTF16(IDS_LOGIN_MAYBE_CAPTIVE_PORTAL_PROXY));
localized_strings->SetString("captivePortalNetworkSelect",
l10n_util::GetStringUTF16(IDS_LOGIN_MAYBE_CAPTIVE_PORTAL_NETWORK_SELECT));
localized_strings->SetString("proxyMessageText",
l10n_util::GetStringUTF16(IDS_LOGIN_PROXY_ERROR_MESSAGE));
}
void ErrorScreenHandler::Initialize() {
}
gfx::NativeWindow ErrorScreenHandler::GetNativeWindow() {
if (native_window_delegate_)
return native_window_delegate_->GetNativeWindow();
return NULL;
}
void ErrorScreenHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("fixCaptivePortal",
base::Bind(&ErrorScreenHandler::HandleFixCaptivePortal,
base::Unretained(this)));
web_ui()->RegisterMessageCallback("showCaptivePortal",
base::Bind(&ErrorScreenHandler::HandleShowCaptivePortal,
base::Unretained(this)));
web_ui()->RegisterMessageCallback("hideCaptivePortal",
base::Bind(&ErrorScreenHandler::HandleHideCaptivePortal,
base::Unretained(this)));
}
void ErrorScreenHandler::HandleFixCaptivePortal(const base::ListValue* args) {
if (!native_window_delegate_)
return;
// TODO (ygorshenin): move error page and captive portal window
// showing logic to C++ (currenly most of it is done on the JS
// side).
if (!captive_portal_window_proxy_.get()) {
captive_portal_window_proxy_.reset(
new CaptivePortalWindowProxy(network_state_informer_.get(),
GetNativeWindow()));
}
captive_portal_window_proxy_->ShowIfRedirected();
}
void ErrorScreenHandler::HandleShowCaptivePortal(const base::ListValue* args) {
// This call is an explicit user action
// i.e. clicking on link so force dialog show.
HandleFixCaptivePortal(args);
captive_portal_window_proxy_->Show();
}
void ErrorScreenHandler::HandleHideCaptivePortal(const base::ListValue* args) {
if (captive_portal_window_proxy_.get())
captive_portal_window_proxy_->Close();
}
} // namespace chromeos
|
caf63d62ab13cdfe248e029aa4e6863177704537 | 7a95b4ed267297caffd614001bc6e8ba38ca098e | /MedianFinder.h | 33ec6670c684d725f8ef4970452377b5350b01a7 | [] | no_license | XWHQSJ/SwordtoOffer | f1dc592810d2e7e1987bac330c8986d534313c44 | c445ca3cbdeed250b257e8245b14862761ea8b7d | refs/heads/master | 2020-12-29T18:20:43.395485 | 2020-04-02T13:53:41 | 2020-04-02T13:53:41 | 238,694,286 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,503 | h | MedianFinder.h | //
// Created by Wanhui on 2/29/20.
//
#ifndef SWORDTOOFFER_MEDIANFINDER_H
#define SWORDTOOFFER_MEDIANFINDER_H
/*
* 剑指offer 41 数据流中的中位数
*
* 如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,
* 那么中位数就是所有数值排序之后位于中间的数值。
* 如果从数据流中读出偶数个数值,
* 那么中位数就是所有数值排序之后中间两个数的平均值。
*
* 例如,
*
* [2,3,4] 的中位数是 3
* [2,3] 的中位数是 (2 + 3) / 2 = 2.5
*
* 设计一个支持以下两种操作的数据结构:
*
* void addNum(int num) - 从数据流中添加一个整数到数据结构中。
* double findMedian() - 返回目前所有元素的中位数。
*
* 示例 1:
*
* 输入:
* ["MedianFinder","addNum","addNum","findMedian","addNum","findMedian"]
* [[],[1],[2],[],[3],[]]
* 输出:[null,null,null,1.50000,null,2.00000]
*
* 示例 2:
*
* 输入:
* ["MedianFinder","addNum","findMedian","addNum","findMedian"]
* [[],[2],[],[3],[]]
* 输出:[null,null,2.00000,null,2.50000]
*
* 限制:
* 最多会对 addNum、findMedia进行 50000 次调用。
*
* 进阶:
* 如果数据流中所有整数都在 0 到 100 范围内,你将如何优化你的算法?
* 如果数据流中 99% 的整数都在 0 到 100 范围内,你将如何优化你的算法?
* */
#include <vector>
#include <queue>
#include <set>
/*
* Your MedianFinder object will be instantiated and called as such:
* MedianFinder* obj = new MedianFinder();
* obj->addNum(num);
* double param_2 = obj->findMedian();
* */
class Solution41 {
private:
std::vector<double> nums;
// 大顶堆
std::priority_queue<double> qmax;
// 小顶堆
std::priority_queue<double, std::vector<double>, std::greater<>> qmin;
// 平衡二叉搜索树
std::multiset<double> data;
std::multiset<double>::iterator mid;
public:
/*
* 方法一 简单排序法 O(nlogn) 超时
*
* 每添加一个数,就对当前数组进行排序std::sort(),
* 判断数组大小为奇偶数,再取数组中间的值
* */
Solution41();
void addNum(int num);
double findMedian();
/*
* 方法二 插入排序法 O(n)
*
* 每添加一个数,先在之前的数组中找到不小于该数的数的位置std::lower_bound(),
* 再在找到的数的位置处插入添加的数std::insert(),则数组一直保持有序,
* 二份查找时间O(logn),插入时间为O(n)
* */
void addNum2(int num);
double findMedian2();
/*
* 方法三 大小顶堆法(优先队列) O(logn)
*
* 设置一个大顶堆存储较小的一半数,
* 设置一个小顶堆存储较大的一半数,
* 则两个堆堆顶节点必为数组中间元素。
*
* 而要保持大顶堆和小顶堆平衡,
* 则大顶堆节点数量最多比小顶堆多一个或少一个,
* 如果总共插入了k个元素,则有:
* 1. k = 2*n + 1; 大顶堆n+1个,小顶堆n个;
* 2. k = 2*n; 大顶堆和小顶堆都为n个。
*
* 这样若数组大小为奇数时,中位数为大顶堆的堆顶;
* 数组大小为偶数时,中位数为大顶堆和小顶堆堆顶和的一半。
*
* 每添加一个数num时,
* 1. 将num添加到大顶堆,此时大顶堆比小顶堆多一个元素,
* 为保持小顶堆平衡,从大顶堆中取堆顶,添加到小顶堆中;
* 2. 在操作1后,小顶堆可能比大顶堆保留更多元素,
* 为保持大顶堆平衡,从小顶堆取堆顶,添加到大顶堆。
*
* 举例:输入[41, 35, 62, 4, 97, 108]
* Adding number 41
* MaxHeap lo: [41] // MaxHeap stores the largest value at the top (index 0)
* MinHeap hi: [] // MinHeap stores the smallest value at the top (index 0)
* Median is 41
* =======================
* Adding number 35
* MaxHeap lo: [35]
* MinHeap hi: [41]
* Median is 38
* =======================
* Adding number 62
* MaxHeap lo: [41, 35]
* MinHeap hi: [62]
* Median is 41
* =======================
* Adding number 4
* MaxHeap lo: [35, 4]
* MinHeap hi: [41, 62]
* Median is 38
* =======================
* Adding number 97
* MaxHeap lo: [41, 35, 4]
* MinHeap hi: [62, 97]
* Median is 41
* =======================
* Adding number 108
* MaxHeap lo: [41, 35, 4]
* MinHeap hi: [62, 97, 108]
* Median is 51.5
*
* 最坏情况下,从顶部有三个堆插入两个堆删除,每个需要O(logn)
* */
void addNum3(int num);
double findMedian3();
/*
* 方法四 平衡二叉搜索树法(AVL树) O(logn)
*
* 平衡二叉搜索树将树的高度保持在对数范围内,
* 中位数在树根或它的一个子树上。
* 使用multiset类模拟平衡二叉树的行为,
* 同时保持两个指针,一个用于较中位数低的元素,
* 另一个用于较中位数高的元素。
* 当数组总数为奇数时,两指针指向同一中值元素;
* 当数组总数为偶数时,指针指向两元素的平均值为中位数。
*
* 平衡二叉搜索树的构建是O(logn)
* */
void addNum4(int num);
double findMedian4();
};
#endif //SWORDTOOFFER_MEDIANFINDER_H
|
4e41806dbd56e35dd4ae98fb2ffd24aef8308e23 | b88228e452e75984ef2eb3aa034e7471cd7d2de0 | /gui/inc/FontText.hpp | 495e1025716535384ca66eb9a265f4c1fa71faae | [] | no_license | chongtianfeiyu/zappy | 9ccdf7487a9e3cf8a5e0e67f1a8caa0667cf53ac | cbb229c48756dc97003280c24c0251abefe5bf34 | refs/heads/master | 2020-04-05T23:42:45.250134 | 2014-07-13T17:33:06 | 2014-07-13T17:33:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 816 | hpp | FontText.hpp |
#ifndef _FONTTEXT_H_
# define _FONTTEXT_H_
# include <string>
# include <SFML/Graphics.hpp>
# include <sstream>
# include "Geometry.hpp"
# include "AObject.hpp"
# define FONT "res/textures/font.tga"
class FontText: public AObject
{
public:
FontText();
virtual ~FontText();
void draw(Shader *shader);
void clear();
void setText(std::string const& str, float x, float y, float size = 40.0f);
template <typename T>
std::string operator<<(T const& in)
{
std::stringstream ss;
ss << in;
setText(ss.str(), _defX, _defY, _defSize);
return (ss.str());
}
private:
float _defX;
float _defY;
float _defSize;
sf::Texture _font;
Geometry *_geometry;
};
#endif /* _FONTTEXT_H_ */
|
71c56df4849ebc86e560fad227420994c39e56cc | 724572a64e4f7ba9eecce5c159a7aa9aa6844aa5 | /src/bindings/java/JNIUtil.cpp | 2346a22afa9b78d1892fc3b1b6d6a8c4354a3bbf | [
"BSD-3-Clause",
"CC-BY-4.0",
"BSD-2-Clause",
"Zlib"
] | permissive | KevinJW/OpenColorIO | 91269ca5d9a560a073e115774d567f612b0f45ef | 412aa7ba273616867e607de646e4975791198812 | refs/heads/master | 2020-04-05T22:52:21.357345 | 2019-09-05T19:52:53 | 2019-09-05T19:52:53 | 8,290,076 | 1 | 0 | BSD-3-Clause | 2023-08-29T17:33:12 | 2013-02-19T12:48:26 | C++ | UTF-8 | C++ | false | false | 5,228 | cpp | JNIUtil.cpp | /*
Copyright (c) 2003-2010 Sony Pictures Imageworks Inc., et al.
All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Sony Pictures Imageworks nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <OpenColorIO/OpenColorIO.h>
#include "JNIUtil.h"
OCIO_NAMESPACE_ENTER
{
jobject NewJFloatBuffer(JNIEnv * env, float* ptr, int32_t len) {
jobject byte_buf = env->NewDirectByteBuffer(ptr, len * sizeof(float));
jmethodID mid = env->GetMethodID(env->GetObjectClass(byte_buf),
"asFloatBuffer", "()Ljava/nio/FloatBuffer;");
if (mid == 0) throw Exception("Could not find asFloatBuffer() method");
return env->CallObjectMethod(byte_buf, mid);
}
float* GetJFloatBuffer(JNIEnv * env, jobject buffer, int32_t len) {
jmethodID mid = env->GetMethodID(env->GetObjectClass(buffer), "isDirect", "()Z");
if (mid == 0) throw Exception("Could not find isDirect() method");
if(!env->CallBooleanMethod(buffer, mid)) {
std::ostringstream err;
err << "the FloatBuffer object is not 'direct' it needs to be created ";
err << "from a ByteBuffer.allocateDirect(..).asFloatBuffer() call.";
throw Exception(err.str().c_str());
}
if(env->GetDirectBufferCapacity(buffer) != len) {
std::ostringstream err;
err << "the FloatBuffer object is not allocated correctly it needs to ";
err << "of size " << len << " but is ";
err << env->GetDirectBufferCapacity(buffer) << ".";
throw Exception(err.str().c_str());
}
return (float*)env->GetDirectBufferAddress(buffer);
}
const char* GetOCIOTClass(ConstTransformRcPtr tran) {
if(ConstAllocationTransformRcPtr at = DynamicPtrCast<const AllocationTransform>(tran))
return "org/OpenColorIO/AllocationTransform";
else if(ConstCDLTransformRcPtr ct = DynamicPtrCast<const CDLTransform>(tran))
return "org/OpenColorIO/CDLTransform";
else if(ConstColorSpaceTransformRcPtr cst = DynamicPtrCast<const ColorSpaceTransform>(tran))
return "org/OpenColorIO/ColorSpaceTransform";
else if(ConstDisplayTransformRcPtr dt = DynamicPtrCast<const DisplayTransform>(tran))
return "org/OpenColorIO/DisplayTransform";
else if(ConstExponentTransformRcPtr et = DynamicPtrCast<const ExponentTransform>(tran))
return "org/OpenColorIO/ExponentTransform";
else if(ConstFileTransformRcPtr ft = DynamicPtrCast<const FileTransform>(tran))
return "org/OpenColorIO/FileTransform";
else if(ConstGroupTransformRcPtr gt = DynamicPtrCast<const GroupTransform>(tran))
return "org/OpenColorIO/GroupTransform";
else if(ConstLogTransformRcPtr lt = DynamicPtrCast<const LogTransform>(tran))
return "org/OpenColorIO/LogTransform";
else if(ConstLookTransformRcPtr lkt = DynamicPtrCast<const LookTransform>(tran))
return "org/OpenColorIO/LookTransform";
else if(ConstMatrixTransformRcPtr mt = DynamicPtrCast<const MatrixTransform>(tran))
return "org/OpenColorIO/MatrixTransform";
else return "org/OpenColorIO/Transform";
}
void JNI_Handle_Exception(JNIEnv * env)
{
try
{
throw;
}
catch (ExceptionMissingFile & e)
{
jclass je = env->FindClass("org/OpenColorIO/ExceptionMissingFile");
env->ThrowNew(je, e.what());
env->DeleteLocalRef(je);
}
catch (Exception & e)
{
jclass je = env->FindClass("org/OpenColorIO/ExceptionBase");
env->ThrowNew(je, e.what());
env->DeleteLocalRef(je);
}
catch (std::exception& e)
{
jclass je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, e.what());
env->DeleteLocalRef(je);
}
catch (...)
{
jclass je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, "Unknown C++ exception caught.");
env->DeleteLocalRef(je);
}
}
}
OCIO_NAMESPACE_EXIT
|
851e8ceac770166b0c403cfc95085a4304444398 | 676a139a659ad35f773aee8434ab0d54c328bd6c | /Module_07/ex02/main.cpp | cd6cda0161cc5da55f77cdf86ca99ba106ac8826 | [] | no_license | Analking228/cpp_piscine | fd7bbe702ddd43dc5ab2e91b64b662ba8f3d4073 | ce2a391a6cae656781e0a9bc74bc887d4b6537e2 | refs/heads/master | 2023-04-26T05:27:10.796975 | 2021-06-01T19:08:33 | 2021-06-01T19:08:33 | 361,708,844 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 872 | cpp | main.cpp | #include "Array.hpp"
int main() {
std::cout << "ARRAY OF INTEGERS" << "\n" << "\n";
Array<int> array(30);
std::cout << "Array size: " << array.size() << "\n";
for (int i = 0; i < 30; ++i)
array[i] = i;
std::cout << "printing filled 0-29 array: \n";
try {
for (int i = 0; i < 31; i++)
std::cout << array[i] << " ";
}
catch (const std::exception& e) {
std::cerr << "\n" << e.what() << std::endl;
}
std::cout << "\nARRAY OF CHARS" << "\n" << "\n";
Array<char> s_array(20);
std::cout << "Array size: " << s_array.size() << "\n";
for (int i = 0; i < 20; ++i)
s_array[i] = char(i + 33);
std::cout << "printing filled array: \n";
try {
for (int i = 0; i < 31; i++)
std::cout << s_array[i] << " ";
}
catch (const std::exception& e) {
std::cerr << "\n" << e.what() << std::endl;
}
return 0;
} |
27a1ee66796a0211b9280d5f90986ee77b93f9ec | 9d44d4d8b4a9fce052e8f321a5006080f3246876 | /ino/orange_on_track_test/test_header/test_header.ino | 17a35d3f40f35a734d4ee26b5a2da6decaa756da | [] | no_license | n800sau/roborep | b4d92754be65dc120881b54d9788034cfa09dac6 | adaef48d0498609d3db90c090a09ddb0141d4a1a | refs/heads/master | 2023-08-30T13:58:30.082902 | 2023-08-19T08:52:12 | 2023-08-19T08:52:12 | 72,965,794 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,085 | ino | test_header.ino | #include <Servo.h>
const int headEchoPin = 12; // Echo Pin
const int headTrigPin = 11; // Trigger Pin
const int SONAR_INCR = 5;
const int SONAR_PAN_ANGLE_MIN = 35;
const int SONAR_PAN_ANGLE_MAX = 135;
const int SONAR_PAN_CENTER = SONAR_PAN_ANGLE_MIN + (SONAR_PAN_ANGLE_MAX - SONAR_PAN_ANGLE_MIN) / 2;
const int SONAR_TILT_ANGLE_MIN = 80;
const int SONAR_TILT_ANGLE_MAX = 145;
const int SONAR_TILT_CENTER = SONAR_TILT_ANGLE_MIN + (SONAR_TILT_ANGLE_MAX - SONAR_TILT_ANGLE_MIN) / 2;
// up-down
const int headTiltServoPin = 45;
// left-right
const int headPanServoPin = 46;
Servo head_pan_servo;
Servo head_tilt_servo;
void setup()
{
Serial.begin(115200);
Serial2.begin(115200);
head_pan_servo.attach(headPanServoPin);
head_tilt_servo.attach(headTiltServoPin);
delay(5000);
}
#define MAX_COUNT 500
bool done = false;
struct {
int dist;
int angle;
} sens[MAX_COUNT];
int num;
unsigned long ms;
String val;
bool pan_dir = true;
void head_scan()
{
ms = millis();
Serial2.setTimeout(100);
Serial.println("Start");
for(int tilt=SONAR_TILT_ANGLE_MIN; tilt<SONAR_TILT_ANGLE_MAX; tilt+=SONAR_INCR) {
head_tilt_servo.write(tilt);
head_pan_servo.write((pan_dir) ? SONAR_PAN_ANGLE_MIN : SONAR_PAN_ANGLE_MAX);
delay(200);
// start collecting data
// to start
Serial2.print("r");
delay(1000);
head_pan_servo.write((pan_dir) ? SONAR_PAN_ANGLE_MAX : SONAR_PAN_ANGLE_MIN);
pan_dir = !pan_dir;
// to stop
Serial2.print("s");
// to retrieve
Serial2.print("g");
bool ok = false;
for(int i=MAX_COUNT; i<MAX_COUNT; i++) {
val = Serial2.readStringUntil("#");
Serial.println(val);
if(val == "") {
break;
} else if (val == "e") {
ok = true;
break;
} else {
val = Serial.readStringUntil("@");
Serial.println(val);
sens[i].dist = val.toInt();
val = Serial.readStringUntil("@");
Serial.println(val);
sens[i].angle = val.toInt();
}
}
}
// to stop sending data
Serial2.println("s");
Serial.println("End");
Serial.println(millis() - ms);
}
void loop()
{
if(!done) {
head_scan();
done = true;
}
}
|
c8b91b812b80e3efe0853a1fa0a52509b64c3d07 | e5486b48e9b0a167a22efd59f0fa5e8f4512e2cf | /BAEKJOON/15898.cpp | e1c4ef63ff1044cc4c904f3903128df466a8369a | [] | no_license | Jihunn-Kim/Coding-Test-Practice | a7ec7cb8f186168fa39026527bb8369599389674 | c2fd1c2f6871dc0b3d1614b0dc9e8f9fcdbe3a91 | refs/heads/master | 2023-04-23T00:48:23.833705 | 2021-05-07T13:48:47 | 2021-05-07T13:48:47 | 112,074,131 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 3,681 | cpp | 15898.cpp | #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <cstring>
#include <set>
#include <unordered_set>
#include <climits>
#include <unordered_map>
#include <map>
#include <iomanip>
using namespace std;
int n, ans;
int effect[10][4][4][4];
char element[10][4][4][4];
int dr[4] = {0, 0, 1, 1};
int dc[4] = {0, 1, 1, 0};
void bomb(int p, int q, int r) {
// p, q, r 순서대로
// p, q, r 별 4 회전
for (int pp = 0; pp < 4; ++pp) {
for (int qq = 0; qq < 4; ++qq) {
for (int rr = 0; rr < 4; ++rr) {
// p, q, r 별 가마 위치 4 곳
for (int ppp = 0; ppp < 4; ++ppp) {
for (int qqq = 0; qqq < 4; ++qqq) {
for (int rrr = 0; rrr < 4; ++rrr) {
// 더하기 시작
int matN[5][5] = { 0, };
char matC[5][5] = { 0, };
// p 더하기
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
matN[i + dr[ppp]][j + dc[ppp]] += effect[p][i][j][pp];
if (matN[i + dr[ppp]][j + dc[ppp]] > 9)
matN[i + dr[ppp]][j + dc[ppp]] = 9;
else if (matN[i + dr[ppp]][j + dc[ppp]] < 0)
matN[i + dr[ppp]][j + dc[ppp]] = 0;
if (element[p][i][j][pp] != 'W')
matC[i + dr[ppp]][j + dc[ppp]] = element[p][i][j][pp];
}
}
// q 더하기
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
matN[i + dr[qqq]][j + dc[qqq]] += effect[q][i][j][qq];
if (matN[i + dr[qqq]][j + dc[qqq]] > 9)
matN[i + dr[qqq]][j + dc[qqq]] = 9;
else if (matN[i + dr[qqq]][j + dc[qqq]] < 0)
matN[i + dr[qqq]][j + dc[qqq]] = 0;
if (element[q][i][j][qq] != 'W')
matC[i + dr[qqq]][j + dc[qqq]] = element[q][i][j][qq];
}
}
// r 더하기
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
matN[i + dr[rrr]][j + dc[rrr]] += effect[r][i][j][rr];
if (matN[i + dr[rrr]][j + dc[rrr]] > 9)
matN[i + dr[rrr]][j + dc[rrr]] = 9;
else if (matN[i + dr[rrr]][j + dc[rrr]] < 0)
matN[i + dr[rrr]][j + dc[rrr]] = 0;
if (element[r][i][j][rr] != 'W')
matC[i + dr[rrr]][j + dc[rrr]] = element[r][i][j][rr];
}
}
// 품질 계산
int R = 0, B = 0, G = 0, Y = 0;
for (int i = 0; i < 5; ++i) {
for (int j = 0; j < 5; ++j) {
if (matC[i][j] == 'R')
R += matN[i][j];
else if (matC[i][j] == 'B')
B += matN[i][j];
else if (matC[i][j] == 'G')
G += matN[i][j];
else if (matC[i][j] == 'Y')
Y += matN[i][j];
}
}
int local = 7 * R + 5 * B + 3 * G + 2 * Y;
ans = max(ans, local);
}
}
}
}
}
}
}
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; ++i) {
for (int r = 0; r < 4; ++r) {
for (int c = 0; c < 4; ++c) {
cin >> effect[i][r][c][0];
effect[i][3 - c][r][3] = effect[i][3 - r][3 - c][2] = effect[i][c][3 - r][1] = effect[i][r][c][0];
}
}
for (int r = 0; r < 4; ++r) {
for (int c = 0; c < 4; ++c) {
cin >> element[i][r][c][0];
element[i][3 - c][r][3] = element[i][3 - r][3 - c][2] = element[i][c][3 - r][1] = element[i][r][c][0];
}
}
//cin >> arr[0][0][0] >> arr[0][3][1] >> arr[3][3][2] >> arr[3][0][3];
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
for (int k = 0; k < n; ++k) {
if (i == j || i == k || j == k)
continue;
bomb(i, j, k);
}
}
}
cout << ans;
return 0;
} |
9e6bbbd4af4da886b8046992d3f551d57d6f5f66 | c4fcec81f59d186953de9adab73a45df3766b38c | /vm_manager/Constant.h | eff91246f86ae477205b7a3d4f9562965aeb6e60 | [] | no_license | Dadagum/virtual-memory-manager | d800369656c5770ccada285ab146b68dfd354bc3 | b39da2c55e43ef1e9529ade2755458fe7c69457a | refs/heads/master | 2020-04-04T18:10:24.626784 | 2018-08-31T17:01:17 | 2018-08-31T17:01:17 | 156,152,727 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 127 | h | Constant.h | #pragma once
/*
记录编程过程中使用到的常量
*/
class Constant {
public:
// TLB
static const int TLB_MISS;
}; |
bcec32c4524a56027e41a7b46fcd53da4c5ae8e1 | 1c42e1ae10997cf477aff771c156f074b49f97c3 | /flame/tcpsession.cpp | 920d822460b45057b7b6e091f95fe0f48aa7f4c3 | [
"Apache-2.0"
] | permissive | DNS-OARC/flamethrower | ad7d8ebc6626fb0c7cc3324a897920b821ae4f7a | 122d80f5f306131441c43b859699c637b602262c | refs/heads/master | 2023-05-25T03:47:01.714253 | 2022-12-07T16:16:54 | 2022-12-07T16:16:54 | 164,416,885 | 301 | 38 | Apache-2.0 | 2023-05-19T21:18:56 | 2019-01-07T10:34:55 | C++ | UTF-8 | C++ | false | false | 2,471 | cpp | tcpsession.cpp | #include <cstdint>
#include <cstring>
#include <utility>
#include "tcpsession.h"
TCPSession::TCPSession(std::shared_ptr<uvw::TCPHandle> handle,
malformed_data_cb malformed_data_handler,
got_dns_msg_cb got_dns_msg_handler,
connection_ready_cb connection_ready_handler)
: _handle{handle},
_malformed_data{std::move(malformed_data_handler)},
_got_dns_msg{std::move(got_dns_msg_handler)},
_connection_ready{std::move(connection_ready_handler)}
{
}
TCPSession::~TCPSession()
{
}
// do any pre-connection setup, return true if all OK.
bool TCPSession::setup()
{
return true;
}
void TCPSession::on_connect_event()
{
_connection_ready();
}
// remote peer closed connection
void TCPSession::on_end_event()
{
_handle->close();
}
// all local writes now finished
void TCPSession::on_shutdown_event()
{
_handle->close();
}
// gracefully terminate the session
void TCPSession::close()
{
_handle->stop();
_handle->shutdown();
}
// accumulate data and try to extract DNS messages
void TCPSession::receive_data(const char data[], size_t len)
{
// dnsheader is 12, at least one byte for the minimum name,
// two bytes for the qtype and another two for the qclass
const size_t MIN_DNS_RESPONSE_SIZE = 17;
_buffer.append(data, len);
for(;;) {
std::uint16_t size;
if (_buffer.size() < sizeof(size))
break;
// size is in network byte order.
size = static_cast<unsigned char>(_buffer[1]) |
static_cast<unsigned char>(_buffer[0]) << 8;
// no need to check the maximum size here since the maximum size
// that a std::uint16t_t can hold, std::numeric_limits<std::uint16_t>::max()
// (65535 bytes) is allowed over TCP
if (size < MIN_DNS_RESPONSE_SIZE) {
_malformed_data();
break;
}
if (_buffer.size() >= sizeof(size) + size) {
auto data = std::make_unique<char[]>(size);
std::memcpy(data.get(), _buffer.data() + sizeof(size), size);
_buffer.erase(0, sizeof(size) + size);
_got_dns_msg(std::move(data), size);
} else {
// Nope, we need more data.
break;
}
}
}
// send data, giving data ownership to async library
void TCPSession::write(std::unique_ptr<char[]> data, size_t len)
{
_handle->write(std::move(data), len);
}
|
2636a441f760eb45c6d72cda4232826bb09f29c7 | d649714b9f4427a66970cdfb4bc231d48ef5bff0 | /basic_ray_tracer/Vec3.hpp | 2d1f17994a0b0c199427b3bab156dc5009ac09ee | [] | no_license | carstenbru/eece528_final | 9b64ed66cb0be557625a8aedd404d1337a51220f | 8412f42d24f12eb6cfa5cf5f67152d642dcb1695 | refs/heads/master | 2021-01-10T13:30:59.804904 | 2015-12-19T07:49:06 | 2015-12-19T07:49:06 | 46,308,816 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 901 | hpp | Vec3.hpp | #include <iostream>
#ifndef VEC3_HPP_
#define VEC3_HPP_
#define USE_FP_SQRT_ALGO 1
#include "dtypes.h"
typedef struct {
unsigned int r;
unsigned int g;
unsigned int b;
} Color;
typedef struct {
int x;
int y;
int z;
} Vec3i;
#define FP_PRECISION (16)
#define FP_ONE (1<<FP_PRECISION)
Color generateColorI(unsigned int r, unsigned int g, unsigned int b);
Color generateColor(float r, float g, float b);
Vec3i generateVectorI(int x, int y, int z);
Color add(const Color v1, const Color v2);
Color mul(const Color v1, int mul);
Color mul(const Color v1, const Color v2);
Vec3i add(const Vec3i v1, const Vec3i v2);
Vec3i sub(const Vec3i v1, const Vec3i v2);
Vec3i mul(const Vec3i v1, int mul);
Vec3i conv_fp(const Vec3i v1, int cur_precision);
int64 dot(const Vec3i v1, const Vec3i v2);
Vec3i* normalize(Vec3i* v);
int64 length2(const Vec3i v);
unsigned int fix64_sqrt(uint64 num);
#endif
|
ec0112b4d21c745df3646c17b1a9b57bd6002d7e | 327d74358f45729f1bb421585a6a36c7c6ac95d8 | /Source/3DGame/GameSystem/ScoreManager.cpp | efdd05ff7527880ff11169954edcc8eabb522df9 | [] | no_license | tachikawa-syota/3D_BattleGame | f968d2dcce222fdac81de661e83cfc18b1851b0a | a38f9f9008a082446e90020ba3a8e83a10b15d02 | refs/heads/master | 2021-01-19T03:55:10.237667 | 2016-09-28T04:55:29 | 2016-09-28T04:55:29 | 69,365,698 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,153 | cpp | ScoreManager.cpp | #include "ScoreManager.h"
#include <functional>
#include <algorithm>
/**
* @brief コンストラクタ
*/
ScoreManager::ScoreManager(int size)
{
// サイズ分の配列を生成
for (int i = 0; i < size; i++)
{
m_score.emplace_back(0);
m_killCount.emplace_back(0);
m_deadCount.emplace_back(0);
}
}
/**
* @brief デストラクタ
*/
ScoreManager::~ScoreManager()
{
}
/**
* @brief スコアを増やす
* @param プレイヤー番号
*/
void ScoreManager::AddScore(int index)
{
// スコア加算
m_score[index]++;
// 撃破数も加算
m_killCount[index]++;
}
/**
* @brief スコアを減らす
* @param プレイヤー番号
*/
void ScoreManager::SubScore(int index)
{
// スコアが"1"以上なら減算
m_score[index]--;
// 死亡数を加算
m_deadCount[index]++;
}
/**
* @brief スコアを取得する
*/
int ScoreManager::GetScore(int index) const
{
return m_score[index];
}
/**
* @brief 撃破数を取得する
*/
int ScoreManager::GetKillCount(int index) const
{
return m_killCount[index];
}
/**
* @brief 死亡数を取得する
*/
int ScoreManager::GetDeadCount(int index) const
{
return m_deadCount[index];
} |
fed5129e79461c81d3433fb9cd146c1733d63340 | 81c74937fd4586b264b9ff3242be616292d06bdf | /trunk/src/c++/include/pedcalc/fra_test_util.h | f186daa44ca53e5146360424bd23477770f1ed2f | [] | no_license | rahulkr007/sageCore | be877ff6bb2ee5825e5cc9b9d71e03ac32f4e29f | b1b19b95d80637b48fca789a09a8de16cdaad3ab | refs/heads/master | 2021-06-01T12:41:41.374258 | 2016-09-02T19:14:02 | 2016-09-02T19:14:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,795 | h | fra_test_util.h | #ifndef FRA_TEST_UTIL_H
#define FRA_TEST_UTIL_H
#include "pedcalc/fam_resid_adj.h"
#include "output/Output.h"
#include "mped/mp.h"
#include "boost/iterator/counting_iterator.hpp"
#include <iostream>
#include <sstream>
namespace SAGE
{
namespace PED_CALC
{
/// Generate an output of the familial residual adjustment for binary traits
/// for an entire multipedigree.
///
/// The output generated is a section with subsections for each pedigree
/// in the data set.
template <class FRA, class GENO_ITER>
OUTPUT::Section
generate_fra_test_output
(const FRA& fra,
const typename FRA::MpedType& mp,
const GENO_ITER& gbegin,
const GENO_ITER& gend)
{
OUTPUT::Section test_results(
"Familial Binary Residual Adjustment Test on multipedigree");
for(typename FRA::MpedType::pedigree_iterator p_iter = mp.pedigree_begin();
p_iter != mp.pedigree_end();
++p_iter)
{
test_results << generate_fra_test_output(fra, *p_iter, gbegin, gend);
}
return test_results;
}
/// Generate an output of the familial residual adjustment for binary traits
/// for a pedigree.
///
/// The output generated is a section with subsections for each family
/// in the pedigree.
template <class FRA, class GENO_ITER>
OUTPUT::Section
generate_fra_test_output
(const FRA& fra,
const typename FRA::MpedType::pedigree_type& ped,
const GENO_ITER& gbegin,
const GENO_ITER& gend)
{
OUTPUT::Section test_results(
"Familial Binary Residuals for pedigree: " + ped.name());
for(typename FRA::MpedType::family_const_iterator f_iter = ped.family_begin();
f_iter != ped.family_end();
++f_iter)
{
test_results << generate_fra_test_output(fra, *f_iter, gbegin, gend);
}
return test_results;
}
template <typename T>
std::string convert_to_string(const T& t)
{
std::stringstream s;
s << t;
return s.str();
}
template <class GENOTYPE, class MPTYPE, class GENO_ITER>
OUTPUT::Table
generate_fra_test_output
(const ExactFamResidAdj<GENOTYPE, MPTYPE>& fra,
const typename MPTYPE::family_type& fam,
const GENO_ITER& gbegin,
const GENO_ITER& gend)
{
// Determine mother and father
OUTPUT::Table test_results
("Family Adjustments for family: " + fam.name());
const typename MPTYPE::member_type* mother = fam.parent1();
const typename MPTYPE::member_type* father = fam.parent2();
// I hate doing this, but there's no way to get the mother/father of a family!
if(mother->is_male() || father->is_female())
std::swap(mother, father);
// Set up the columns in the output table
test_results << OUTPUT::TableColumn("Mother: " + mother->name())
<< OUTPUT::TableColumn("Father: " + father->name());
for(typename MPTYPE::offspring_const_iterator child = fam.offspring_begin();
child != fam.offspring_end(); ++child)
{
test_results << OUTPUT::TableColumn("Child: " + child->name());
}
test_results << OUTPUT::TableColumn("Value");
// Generate results to populate the table
for(GENO_ITER mgeno = gbegin; mgeno != gend; ++mgeno)
{
for(GENO_ITER fgeno = gbegin; fgeno != gend; ++fgeno)
{
// We can't do *every* child model, so we'll try just a few:
// 1. All children the same, for each genotype
// 2. Each child with a genotype, the first child having the first
// genotype, second the second, etc. If there aren't enough genotypes
// for each child, just repeat genotypes following the pattern.
// 3. Same as #2, but first having the *last* genotype, second last - 1,
// etc.
// 1.
for(GENO_ITER i = gbegin; i != gend; ++i)
{
std::vector<GENOTYPE> ch_genos(fam.offspring_count(), (GENOTYPE) *i);
OUTPUT::TableRow r;
r << convert_to_string(*mgeno) << convert_to_string(*fgeno);
for(size_t ch = 0; ch != fam.offspring_count(); ++ch)
r << convert_to_string(*i);
r << fra.calculate_adjustment(fam,
(GENOTYPE) *mgeno,
(GENOTYPE) *fgeno,
ch_genos);
test_results << r;
}
// 2.
{
std::vector<GENOTYPE> ch_genos(fam.offspring_count(), (GENOTYPE) *gbegin);
GENO_ITER g = gbegin;
for(size_t ch = 0; ch != fam.offspring_count(); ++ch, ++g)
{
if(g == gend) g = gbegin;
ch_genos[ch] = (GENOTYPE) *g;
}
OUTPUT::TableRow r;
r << convert_to_string(*mgeno) << convert_to_string(*fgeno);
for(size_t ch = 0; ch != fam.offspring_count(); ++ch)
r << convert_to_string(ch_genos[ch]);
r << fra.calculate_adjustment(fam, (GENOTYPE) *mgeno, (GENOTYPE) *fgeno, ch_genos);
test_results << r;
}
// 3.
{
std::vector<GENOTYPE> ch_genos(fam.offspring_count(), (GENOTYPE) *gbegin);
GENO_ITER g = gend;
for(size_t ch = 0; ch != fam.offspring_count(); ++ch)
{
if(g == gbegin) g = gend;
--g;
ch_genos[ch] = (GENOTYPE) *g;
}
OUTPUT::TableRow r;
r << convert_to_string(*mgeno) << convert_to_string(*fgeno);
for(size_t ch = 0; ch != fam.offspring_count(); ++ch)
r << convert_to_string(ch_genos[ch]);
r << fra.calculate_adjustment(fam, (GENOTYPE) *mgeno, (GENOTYPE) *fgeno, ch_genos);
test_results << r;
}
}
}
return test_results;
}
template <class GENOTYPE, class MPTYPE, class GENO_ITER>
OUTPUT::Table
generate_fra_test_output
(const ApproximateFamResidAdj<GENOTYPE, MPTYPE, GENO_ITER>& fra,
const typename MPTYPE::family_type& fam,
const GENO_ITER& gbegin,
const GENO_ITER& gend)
{
// Determine mother and father
OUTPUT::Table test_results
("Approximate Family Adjustments for family: " + fam.name());
const typename MPTYPE::member_type* mother = fam.parent1();
const typename MPTYPE::member_type* father = fam.parent2();
// I hate doing this, but there's no way to get the mother/father of a family!
if(mother->is_male() || father->is_female())
std::swap(mother, father);
// Set up the columns in the output table
test_results << OUTPUT::TableColumn("Mother: " + mother->name())
<< OUTPUT::TableColumn("Father: " + father->name());
test_results << OUTPUT::TableColumn("Value");
// Generate results to populate the table
for(GENO_ITER mgeno = gbegin; mgeno != gend; ++mgeno)
{
for(GENO_ITER fgeno = gbegin; fgeno != gend; ++fgeno)
{
OUTPUT::TableRow r;
r << convert_to_string(*mgeno)
<< convert_to_string(*fgeno)
<< fra.calculate_adjustment(fam, (GENOTYPE) *mgeno,
(GENOTYPE) *fgeno);
test_results << r;
}
}
return test_results;
}
}
}
#endif
|
8a1b0504cf11cb4cad7ac0579f4bda16e3baeb28 | 7b5d60392287f8c9abb610e79c41b552b38ac039 | /src/Session.cpp | b232d2312d76036ff5ca6302e96871ba768d7fe9 | [] | no_license | luzinbar/ContactTracingSystem | 773aa2721e0e82e6242773edb93e54e7c46173fe | bd7fe1e032271a49c90eb8d1dcfb68a561534cc1 | refs/heads/main | 2023-08-07T13:56:23.662062 | 2021-09-14T18:41:41 | 2021-09-14T18:41:41 | 406,250,718 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,199 | cpp | Session.cpp | //
// Created by spl211 on 03/11/2020.
//
//#include "include/json.hpp"
#include "Session.h"
#include "Agent.h"
#include "Graph.h"
#include "Tree.h"
#include <fstream>
#include <iostream>
#include <vector>
using json = nlohmann::json;
using namespace std;
// ******************** Constructor ********************
Session::Session(const std::string &Path) : g(vector<vector<int>>()), treeType(),
agents(vector<Agent *>()), cycleNumber(0) {
ifstream ifs(Path);
json j;
ifs >> j;
Graph matrix(j["graph"]);
setGraph(matrix);
string type = j["tree"];
if (type == "M")
treeType = MaxRank;
else if (type == "R")
treeType = Root;
else
treeType = Cycle;
for (unsigned int i = 0; i < j["agents"].size(); i++) {
if (j["agents"][i][0] == "V") {
Virus vs(j["agents"][i][1]);
addAgent(vs);
g.setNodeAsSick(j["agents"][i][1]);
} else
addAgent(ContactTracer());
}
}
// ******************** Rule of 5 ********************
//destructor
Session::~Session() {
Session::clear();
}
//copy constructor
Session::Session(const Session &other) : g(other.g), treeType(other.treeType), agents(vector<Agent *>()),
cycleNumber(other.cycleNumber) {
for (unsigned int i = 0; i < other.agents.size(); i++) {
Agent *otherAgent = other.agents[i];
agents[i] = otherAgent->clone();
}
}
// copy assignment
Session &Session::operator=(const Session &other) {
if (this != &other) {
this->clear();
for (unsigned int i = 0; i < other.agents.size(); i++) {
Agent *otherAgent = other.agents[i];
agents[i] = otherAgent->clone();
}
g = other.g;
treeType = other.treeType;
cycleNumber = other.cycleNumber;
}
return *this;
}
//move constructor
Session::Session(Session &&other) : g(move(other.g)), treeType(other.treeType), agents(move(other.agents)), cycleNumber(other.cycleNumber) {
for (auto &agent : other.agents)
agent = nullptr;
}
// move assignment
Session &Session::operator=(Session &&other) {
if (this != &other) {
this->clear();
g = other.g;
agents = other.agents;
cycleNumber = other.cycleNumber;
treeType = other.treeType;
for (auto &agent : other.agents)
agent = nullptr;
}
return *this;
}
void Session::clear() {
for (auto &agent : agents) {
if (agent) {
delete agent;
agent = nullptr;
}
}
}
// ******************** Operate on members ********************
// ********** Getters **********
Graph& Session::getGraph() {
return g;
}
TreeType Session::getTreeType() const {
return treeType;
}
int Session::getCycleNumber() const {
return cycleNumber;
}
// ********** Setters **********
void Session::setGraph(const Graph &graph) {
g = graph;
}
// ********** Add agent **********
void Session::addAgent(const Agent &agent) {
Agent *toAdd = agent.clone();
agents.push_back(toAdd);
}
// ********** Queue **********
int Session::dequeueInfected() {
return g.removeFromInfectedQ();
}
void Session::enqueueInfected(int infectedNode) {
(g.getInfectedQueue()).push_back(infectedNode);
}
// ******************** BFS ********************
Tree* Session::BFS() {
int numOfVertices = g.getNumOfVertices();
int rootLabel = dequeueInfected();
// the queue is empty - return
if (rootLabel == -1)
return nullptr;
// initialize an empty vector of size n to store the trees pointers
vector<Tree *> treeByIndex(numOfVertices, nullptr);
vector<bool> visited(numOfVertices, false);
// create the root - to be returned later
Tree *root = Tree::createTree(*this, rootLabel);
treeByIndex[rootLabel] = root;
// create an empty queue
vector<int> q;
q.push_back(rootLabel);
visited[rootLabel] = true;
int currNode;
while (!q.empty()) {
currNode = q[0];
Tree *currTree = treeByIndex[currNode];
q.erase(q.begin());
// For every adjacent node of the curr node
for (int i = 0; i < numOfVertices; i++) {
if (g.isThereAnEdge(currNode,i) && (!visited[i])) {
visited[i] = true;
q.push_back(i);
// create the children and set them as currTree children
Tree *currChild = Tree::createTree(*this, i);
currTree->getChildren().push_back(currChild);
//insert the children to the treeByIndex vector
treeByIndex[i] = currChild;
}
}
}
return root;
}
// ******************** Simulate - the real deal ********************
void Session::simulate() {
// separating first cycle from others because in the first cycle Carriers list is Empty
// only first cycle
for (unsigned int i =0 ; i < agents.size(); i++) {
agents[i]->act(*this);
}
cycleNumber++;
// Termination condition is met if and only if there are no new carriers
while (!g.isCarriersEmpty()) {
// emptying the carriers queue and adding them as new agents
while (!g.isCarriersEmpty()) {
int ind = g.removeFirstCarrier();
Agent *virus = new Virus (ind);
agents.push_back(virus);
}
for (Agent *agent: agents) {
agent->act(*this);
}
cycleNumber++;
}
// ----- output -----
// creating json file output
json j;
int n =g.getNumOfVertices();
vector<vector<int>> matrix (n, vector<int>(n,0));
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
if (g.isThereAnEdge(i,j)) {
matrix[i][j] = 1;
matrix[j][i] = 1;
}
}
}
j["graph"] = matrix;
for (unsigned int i = 0; i < agents.size(); i++) {
if (agents[i]->isFullyInfected()) {
j["infected"].push_back(agents[i]->getIndex());
}
}
ofstream output("output.json");
output << j;
}
|
517d6b8d1f9e9766af5c9d7e0116ecda3ed9132f | 4254718c15e826c8ae5a16550fe3839afa4f2126 | /Program3/Creature.cpp | 7a6ef3d14751aa7d150989d19bb5ec0f17cccf46 | [] | no_license | wrwestrich/CSC1310 | 2c6b95e419f33131b3f627a8a96cb049b560ed53 | 9f05f4f0188e770edfc48470d79bff6c977b4301 | refs/heads/master | 2021-07-11T12:11:53.749219 | 2021-07-01T19:19:35 | 2021-07-01T19:19:35 | 188,274,936 | 0 | 0 | null | 2021-07-01T19:19:36 | 2019-05-23T17:02:35 | C++ | UTF-8 | C++ | false | false | 1,396 | cpp | Creature.cpp | /*
* Name: Creature.cpp
* Date: 2/15/18
* Author: Will Westrich
* Purpose:
*/
#include "Creature.h"
Creature::Creature() {}
Creature::Creature(std::string n, std::string d, bool danger, float c)
: name(n), description(d), dangerous(danger), cost(c)
{
}
std::string Creature::GetName() const
{
return name;
}
std::string Creature::GetDescription() const
{
return description;
}
float Creature::GetCost() const
{
return cost;
}
bool Creature::GetDanger() const
{
return dangerous;
}
void Creature::SetName(std::string n)
{
name = n;
}
void Creature::SetDescription(std::string d)
{
description = d;
}
void Creature::SetCost(float c)
{
cost = c;
}
void Creature::SetDanger(bool dang)
{
dangerous = dang;
}
void Creature::Print()
{
std::string danger;
if (dangerous == 0)
danger = "No";
else
danger = "Yes";
std::cout << "Name: " << name << std::endl;
std::cout << "Description:" << std::endl
<< std::endl
<< description << std::endl
<< std::endl;
std::cout << "Dangerous? " << danger << std::endl;
std::cout << "Cost per month: $" << cost << std::endl;
}
void Creature::PrintToFile(std::string fileName)
{
std::ofstream oF;
oF.open(fileName, std::fstream::app);
oF << name << std::endl
<< description << std::endl
<< dangerous << std::endl
<< cost << std::endl;
oF.close();
}
|
2f2391244cceb5a36c46ab0000b879a6859b7562 | 27a90e2b9f1ab69cc153838ad157fcddfc9cd4d3 | /第01阶段:开始入门吧/02简单操作/2008.cpp | a48f4a3f5616b2bffc034069faee54302ce02386 | [] | no_license | yfuxzpskbr/hoj | 61c065c520bb30f3aebbdb43d35b75fcdf493ca4 | 67c4743445331c7d891e21ab0d910bf7dab23664 | refs/heads/master | 2023-01-01T08:56:25.390799 | 2020-10-27T05:27:40 | 2020-10-27T05:27:40 | 305,619,405 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 331 | cpp | 2008.cpp | #include <iostream>
using namespace std;
int main(){
int n;
double a;
scanf("%d",&n);
while(n!=0){
int num_ = 0;
int num_0 = 0;
int num = 0;
for(int i=0;i<n;i++){
scanf("%lf",&a);
if(a>0) num++;
else if(a<0)num_++;
else num_0++;
}
printf("%d %d %d\n",num_,num_0,num);
scanf("%d",&n);
}
return 0;
}
|
fb9bb8c16eaf496803fbe059cacf4660cd151f24 | 40ee9db50b87ea4a235b0510c2ff0b6db5d650ab | /Neon.cpp | ec13881875e4d5ab32b66dc62646753314d7722f | [
"MIT"
] | permissive | anupam8757/coding | 225ecf3e4f895b6fad71fa56eed3c169a1e8b2a9 | 6aac7fdae5f399491f5ff9aa50e76fefb10d1ccf | refs/heads/master | 2021-10-23T06:40:23.174779 | 2021-10-15T03:06:18 | 2021-10-15T03:06:18 | 227,669,688 | 0 | 1 | MIT | 2020-10-01T03:12:31 | 2019-12-12T18:18:40 | C++ | UTF-8 | C++ | false | false | 656 | cpp | Neon.cpp | /* A neon number is a number where the sum of digits of square of the number is equal to the number.
For example if the input number is 9, its square is 9*9 = 81 and sum of the digits is 9. i.e. 9 is a neon number.
*/
#include <iostream>
using namespace std;
int main() {
int num,square;
cout<<"Hello World! \n Enter a Number to check wether to check Neon\n";
cin>>num;
square=num*num;
int sum=0;
while(square>0)
{
sum=sum+square%10;
square=square/10;
}
if(num==sum)
cout<<"Entered Number is Neon Number";
else
cout<<"Entered Number is not Neon Number";
return 0;
}
|
6cbfa32f5c0ec231eb81439870bf137697cfd0ca | 6c61e42a0f7a532e956ef0da184f9bbf6cbe584e | /Graph/Graph/Graph/test_graph.cpp | aa85b3c5b086193b4d76cc48c8f46001ec37de75 | [] | no_license | HSQ8/CPP_practice | ce4a345dd74e40e466655c368b1609e5987bb591 | 67b7ddfb20b979b00ec9cf1f283ab59596441174 | refs/heads/master | 2021-07-20T11:44:34.890483 | 2017-10-27T08:32:17 | 2017-10-27T08:32:17 | 107,361,911 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,899 | cpp | test_graph.cpp | #include "graph.h"
#include "unit_test.h"
#include <fstream>
#include "graph_algorithms.h"
#include <unordered_map>
using namespace std;
using mystl::graph;
////////////////////////////////////////////////////////////////////////////////
/// @brief Testing of graph
/// @ingroup Testing
////////////////////////////////////////////////////////////////////////////////
class graph_test : public test_class {
protected:
void test() {
test_file_input();
test_find_vertex();
test_find_edge();
test_insert_vertex();
test_insert_edge();
test_insert_edge_undirected();
test_erase_vertex();
test_breadth_first_search();
test_erase_edge();
test_clear();
test_mst_prim_jarniks();
}
private:
/// @brief sets up test graph
void setup_dummy_graph(graph<int, int>& g) {
g.insert_vertex(1);
g.insert_vertex(2);
g.insert_vertex(3);
g.insert_vertex(4);
g.insert_edge(0, 1, 1);
g.insert_edge(1, 2, 2);
g.insert_edge(2, 3, 3);
g.insert_edge(0, 3, 4);
}
/// @brief sets up larger test graph
void setup_larger_dummy_graph(graph<int, int>& g) {
for(size_t i = 0; i < 200; i++){
g.insert_vertex(i);
}
size_t i = 1;
for(auto vi1 = g.vertices_cbegin(); vi1 != g.vertices_cend(); ++vi1) {
for(auto vi2 = g.vertices_cbegin(); vi2 != g.vertices_cend(); ++vi2) {
if((*vi1)->descriptor() != (*vi2)->descriptor())
g.insert_edge((*vi1)->descriptor(), (*vi2)->descriptor(), i++);
}
}
}
/// @brief test input operator
void test_file_input(){
graph<int, int> g;
ifstream is("graph_input.txt");
is >> g;
assert_msg(g.num_vertices() == 119 && g.num_edges() == 596, "Input stream test failed" );
}
/// @brief test find vertex operation
void test_find_vertex() {
graph<int, int> g;
setup_larger_dummy_graph(g);
auto i = g.find_vertex(1);
assert_msg((*i)->property() == 1, "Find vertex failed");
}
/// @brief tests insert vertex operaion
void test_insert_vertex() {
graph<int, int> g;
g.insert_vertex(5);
assert_msg(g.num_vertices() == 1, "Insert vertex failed.");
}
/// @brief test insert edge operation
void test_insert_edge() {
graph<int, int> g;
g.insert_vertex(5);
g.insert_vertex(1);
g.insert_edge(0, 1, 10);
assert_msg(g.num_edges() == 1 && (*g.find_vertex(0))->degree() == 1 && (*g.find_vertex(1))->degree() == 1, "Insert edge failed.");
}
/// @brief test find edge operation
void test_find_edge() {
graph<int, int> g;
setup_larger_dummy_graph(g);
graph<int,int>::edge_descriptor id = std::make_pair(140, 130);
auto iter = g.find_edge(id);
assert_msg((*iter)->source() == 140 && (*iter)->target() == 130, "Find edge failed");
}
/// @brief test erase vertex operation
void test_erase_vertex() {
graph<int, int> g;
setup_dummy_graph(g);
g.erase_vertex(1);
assert_msg(g.num_vertices() == 3 && g.num_edges() == 2, "Erase Vertex failed");
}
/// @brief test erase egde operation
void test_erase_edge() {
graph<int, int> g;
setup_dummy_graph(g);
auto _1 = *g.find_vertex(1);
auto _2 = *g.find_vertex(2);
g.erase_edge(std::make_pair(1,2));
assert_msg(g.num_edges() == 3 && _1->degree() == 1 && _2->degree() == 1, "Erase Edge Failed");
}
/// @brief test breadth first search
void test_breadth_first_search() {
graph<int, int> g;
setup_dummy_graph(g);
typedef graph<int,int>::vertex_descriptor vertex_descriptor;
unordered_map<vertex_descriptor, vertex_descriptor> test_map;
mystl::breadth_first_search(g,test_map);
assert_msg(test_map.size() == 2, "breadth first search failed");
}
/// @brief test clear graph
void test_clear() {
graph<int, int> g;
setup_dummy_graph(g);
g.clear();
assert_msg(g.num_vertices() == 0 && g.num_edges() == 0, "Clearing Graph failed");
}
/// @brief test inserting undirected edge
void test_insert_edge_undirected() {
graph<int, int> g;
setup_dummy_graph(g);
g.insert_edge_undirected(0, 2, 10);
assert_msg(g.num_edges() == 6, "Erase Vertex failed");
}
/// @brief test prim jarniks mst
void test_mst_prim_jarniks() {
graph<int, int> g;
setup_dummy_graph(g);
typedef graph<int,int>::vertex_descriptor vertex_descriptor;
unordered_map<vertex_descriptor, vertex_descriptor> test_map;
mystl::mst_prim_jarniks(g,test_map);
assert_msg(test_map.size() == 4, "MST Prim Jarnik's failed");
}
};
/// @brief main
int main() {
graph_test ge;
if(ge.run())
cout << "All tests passed." << endl;
return 0;
}
|
5d7ce3bc09d2a70f98e9ffba00b3bd7f102550d7 | 265be600fbbf8684501b36e199157b6d29963dcb | /Code/include/7_thermistor.cpp | 9c05bf2a01ad386cfae120c412f99ee36521f777 | [
"MIT"
] | permissive | momsi/Talk_Arduino | a5916648e49bf6a000305ab70fb82ca333c9e0a6 | 19e8809ae9b44edffabb34cf84bae20e27351583 | refs/heads/main | 2023-03-07T14:09:32.145625 | 2021-02-15T15:11:38 | 2021-02-15T15:11:38 | 339,107,299 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 440 | cpp | 7_thermistor.cpp | #include <Arduino.h>
int tempPin = A0;
void setup(){
Serial.begin(9600);
}
void loop(){
int tempReading = analogRead(tempPin);
double tempK = log(10000.0 * ((1024.0 / tempReading - 1)));
tempK = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * tempK * tempK )) * tempK ) - 4.0;
float tempC = tempK - 273.15;
//Serial.print("Temperatur: ");
Serial.print(tempC);
Serial.println("°C");
delay(500);
} |
5ecf3f5ff0e841615b56f1a627fa1405c72ca3d7 | 09dc648a54a59edb12217710f79f91fcb811a874 | /dfsIterator.cpp | dadc2a2183c446100d2b5113bcb7e7ce44cc9011 | [
"MIT"
] | permissive | taco12347/Kerwin_POSD | c75c5b8d5f555bff6584e45da8d9f4ecef3bc537 | 4bab3ab370421d72fda6ac524f35d0491b64954f | refs/heads/master | 2021-09-03T03:42:12.996614 | 2018-01-05T08:21:07 | 2018-01-05T08:21:07 | 103,501,486 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,024 | cpp | dfsIterator.cpp | #include "dfsIterator.h"
#include <iostream>
template<class T>
void DFSIterator<T>::first(){
_dfsTerms.empty();
_index = 1;
extractTermByDFS(_originalTerm);
}
template<class T>
void DFSIterator<T>::next(){
_index++;
}
template<class T>
Term* DFSIterator<T>::currentItem() const{
if(isDone() == false || _index == _dfsTerms.size() - 1)
return _dfsTerms[_index];
}
template<class T>
bool DFSIterator<T>::isDone() const{
return _index >= _dfsTerms.size() - 1;
}
template<class T>
void DFSIterator<T>::extractTermByDFS(T term){
_dfsTerms.push_back(term);
Struct *tempS = dynamic_cast<Struct*>(term);
List *tempL = dynamic_cast<List*>(term);
if(tempS != nullptr){
for(int index = 0; index < tempS->arity(); index++) extractTermByDFS(tempS->args(index));
}
if(tempL != nullptr){
for(int index = 0; index < tempL->arity(); index++) extractTermByDFS(tempL->args(index));
}
}
template class DFSIterator<Term*>; |
1048173f9e38a2be83822ef01046a2b0fb3f2fa9 | 81890c3fe2757020b6bb0451370d8a9e5f45698b | /ServiceServer/Classes/TowerTrialService.cpp | f89bbb04dbc68fe5ea297dc92c2c85f325b5c708 | [] | no_license | alenming/trunkServer | c274811ac810c63939875bda7cf03291f084f6b8 | 4224260b5db72880ec53bbd30e2ada1ba9905e5d | refs/heads/master | 2021-07-16T05:53:40.459835 | 2021-07-01T04:24:37 | 2021-07-01T04:24:37 | 116,622,506 | 4 | 15 | null | null | null | null | GB18030 | C++ | false | false | 15,282 | cpp | TowerTrialService.cpp | #include "TowerTrialService.h"
#include "Protocol.h"
#include "TowerTestProtocol.h"
#include "ErrorCodeProtocol.h"
#include "CommStructs.h"
#include "GameDef.h"
#include "ItemDrop.h"
#include "GameUserManager.h"
#include "KxCommManager.h"
#include "ChallengeRoomManager.h"
#include "ConfHall.h"
#include "ConfGameSetting.h"
#include "CommOssHelper.h"
#include "ModelHelper.h"
#include "PropUseHelper.h"
#include "ChallengeHelper.h"
#include "RankModel.h"
#include "CommonHelper.h"
#include "BattleDataHelper.h"
#include "RandGenerator.h"
void CTowerTrialService::processService(int maincmd, int subcmd, int uid, char *buffer, int len, KxServer::IKxComm *commun)
{
switch (subcmd)
{
case CMD_TOWER_FIGHTING_CS:
processFighting(uid, buffer, len, commun);
break;
case CMD_TOWER_FINISH_CS:
{
CCommonHelper::encryptProtocolBuff(maincmd, subcmd, buffer, len);
processFinish(uid, buffer, len, commun);
}
break;
case CMD_TOWER_CHOSEOUTERBONUS_CS:
processChoseOuterBonus(uid, buffer, len, commun);
break;
case CMD_TOWER_OPENTREASURE_CS:
//处理打开宝箱处理, 暂时不开启
//processOpenTreasure(uid, buffer, len, commun);
break;
case CMD_TOWER_ONEKEYFIGHTING_CS:
//processOneKeyFighting(uid, buffer, len, commun);
break;
default:
break;
}
}
void CTowerTrialService::processFighting(int uid, char *buffer, int len, KxServer::IKxComm *commun)
{
CHECK_RETURN_VOID(len >= sizeof(ChallengeTeamInfo));
CTowerTestModel *pTowerTestModel = dynamic_cast<CTowerTestModel*>(CModelHelper::getModel(uid, MODELTYPE_TOWERTEST));
CHECK_RETURN_VOID(NULL != pTowerTestModel);
int floor = pTowerTestModel->GetTowerTestField(TOWER_FD_FLOOR);
int haveCrystal = pTowerTestModel->GetTowerTestField(TOWER_FD_CRYSTAL);
CHECK_RETURN_VOID(CChallengeHelper::canChallengeTowerTest(uid, floor));
const TowerFloorItem *pTowerFloorConf = queryConfTowerFloor(floor);
if (NULL == pTowerFloorConf)
{
KXLOGDEBUG("%s user %d get tower config is NULL, floor %d!", __FUNCTION__, uid, floor);
return;
}
// 获得队伍信息
ChallengeTeamInfo *pTeamInfo = reinterpret_cast<ChallengeTeamInfo*>(buffer);
int nIndex = g_RandGenerator.MakeRandNum(1, pTowerFloorConf->StageID.size());
int nStageID = pTowerFloorConf->StageID[nIndex - 1];
pTowerTestModel->SetTowerTestField(TOWER_FD_STAGEID, nStageID);
// 构造房间数据
BattleRoomData room;
room.battleType = EBATTLE_TOWERTEST;
room.stageId = nStageID;
room.stageLv = CChallengeHelper::getTowerTestStageLevel(uid, floor);
room.summonerId = pTeamInfo->summonerId;
room.ext1 = haveCrystal; // 剩余水晶数量
room.outerBuffs = pTowerTestModel->GetOuterBonusList();
for (int i = 0; i < 7; ++i)
{
if (pTeamInfo->heroIds[i] > 0)
{
room.heroIds.push_back(pTeamInfo->heroIds[i]);
}
}
room.mecenaryId = pTeamInfo->mercenaryId;
// 返回房间数据包
CBufferData bufferData;
bufferData.init(10240);
// 先封爬塔相关的数据
bufferData.writeData(floor);
if (!CBattleDataHelper::roomDataToBuffer(uid, room, bufferData))
{
return;
}
CKxCommManager::getInstance()->sendData(uid, CMD_TOWERTEST, CMD_TOWER_FIGHTING_SC,
bufferData.getBuffer(), bufferData.getDataLength());
}
void CTowerTrialService::processFinish(int uid, char *buffer, int len, KxServer::IKxComm *commun)
{
CHECK_RETURN_VOID(len >= sizeof(TowerFinishCS));
TowerFinishCS *pFinishCS = reinterpret_cast<TowerFinishCS*>(buffer);
CTowerTestModel *pTowerTestModel = dynamic_cast<CTowerTestModel*>(CModelHelper::getModel(uid, MODELTYPE_TOWERTEST));
CUserModel *pUserModel = dynamic_cast<CUserModel*>(CModelHelper::getModel(uid, MODELTYPE_USER));
CHECK_RETURN_VOID(NULL != pTowerTestModel && NULL != pUserModel);
//爬塔模型修改
std::map<int, int> towerData;
towerData[TOWER_FD_CRYSTAL] = 0;
towerData[TOWER_FD_FLOOR] = 0;
towerData[TOWER_FD_STAGEID] = 0;
CHECK_RETURN_VOID(pTowerTestModel->GetTowerTestField(towerData));
CHECK_RETURN_VOID(towerData[TOWER_FD_STAGEID] != 0);
int floor = towerData[TOWER_FD_FLOOR];
// 再次检查是否可以挑战
//CHECK_RETURN_VOID(CChallengeHelper::canChallengeTowerTest(uid, floor));
const TowerFloorItem *pTowerFloorConf = queryConfTowerFloor(floor);
if (NULL == pTowerFloorConf)
{
KXLOGDEBUG("%s user %d get tower config is NULL!", __FUNCTION__, uid);
return;
}
// 对应的关卡id(上面已经检测过vector大小)
if (pFinishCS->result == CRESULT_WIN)
{
//结算数据
ChallengeBattleInfo *pBattleInfo = reinterpret_cast<ChallengeBattleInfo*>(pFinishCS+1);
const TowerTestSettingItem * pTowerSettingConf = queryConfTowerSetting();
CHECK_RETURN_VOID(NULL != pTowerSettingConf)
//事件置为宝箱事件
//注意, 这里本应为宝箱状态, 后来策划改为不领宝箱, 没有宝箱状态, 直接下一层!
towerData[TOWER_FD_FLOOR] = towerData[TOWER_FD_FLOOR] + 1;
// 检查处理佣兵
if (pBattleInfo->mercenaryId != 0 &&
CModelHelper::canMercenaryUse(uid, pBattleInfo->mercenaryId))
{
CModelHelper::addMercenaryUseList(uid, pBattleInfo->mercenaryId);
}
//获得配置物品
std::vector<DropItemInfo> dropItems;
int nSendLen = sizeof(TowerFinishSC);
//物品掉落
CItemDrop::Drop(pTowerFloorConf->Drop, dropItems);
CPropUseHelper::getInstance()->AddItems(uid, dropItems);
nSendLen = nSendLen + sizeof(TreasureReward) +dropItems.size() * sizeof(DropItemInfo);
char *pSendBuffer = reinterpret_cast<char *>(KxServer::kxMemMgrAlocate(nSendLen));
TowerFinishSC *pFinishSC = reinterpret_cast<TowerFinishSC*>(pSendBuffer);
pFinishSC->floor = floor;
pFinishSC->result = CRESULT_WIN;
TreasureReward *pTreasureReward = reinterpret_cast<TreasureReward *>(pFinishSC + 1);
pTreasureReward->count = dropItems.size();
DropItemInfo *pPropsInfo = reinterpret_cast<DropItemInfo *>(pTreasureReward + 1);
for (size_t i = 0; i < dropItems.size(); ++i)
{
memcpy(pPropsInfo, &dropItems[i], sizeof(DropItemInfo));
pPropsInfo += 1;
}
CKxCommManager::getInstance()->sendData(uid, CMD_TOWERTEST, CMD_TOWER_FINISH_SC, pSendBuffer, nSendLen);
KxServer::kxMemMgrRecycle(pSendBuffer, nSendLen);
//修改玩家数据
towerData[TOWER_FD_CRYSTAL] = pTowerSettingConf->FirstCrystal;
towerData[TOWER_FD_STAGEID] = 0; //重置关卡ID
if (!pTowerTestModel->SetTowerTestField(towerData))
{
KXLOGERROR("%s user %d add tower model error!", __FUNCTION__, uid);
}
//这里需要校验是否在爬塔开放的时间范围内
//if ((int)time(NULL) < towerData[TOWER_FD_TIMESTAMP])
{
//添加到排行榜中
CRankModel::getInstance()->AddRankData(TOWER_RANK_TYPE, uid, towerData[TOWER_FD_FLOOR]);
}
CModelHelper::DispatchActionEvent(uid, ELA_TOWER_TEST_FLOOR, &floor, sizeof(int));
}
else if (pFinishCS->result == CRESULT_LOSE)
{
TowerFinishSC finishSC;
finishSC.floor = floor;
finishSC.result = CRESULT_LOSE;
CKxCommManager::getInstance()->sendData(uid, CMD_TOWERTEST, CMD_TOWER_FINISH_SC,
reinterpret_cast<char *>(&finishSC), sizeof(finishSC));
}
else
{
// 取消暂不处理
}
}
void CTowerTrialService::processChoseOuterBonus(int uid, char *buffer, int len, KxServer::IKxComm *commun)
{
// CHECK_RETURN_VOID(len == sizeof(TowerChoseOuterBonusCS));
//TowerChoseOuterBonusCS * pOuterBonusCS = reinterpret_cast<TowerChoseOuterBonusCS *>(buffer);
//CTowerTestModel *pTowerTestModel = dynamic_cast<CTowerTestModel*>(CModelHelper::getModel(uid, MODELTYPE_TOWERTEST));
// CHECK_RETURN_VOID(NULL != pTowerTestModel);
//// 爬塔信息
//std::map<int, int> towerValues;
//towerValues[TOWER_FD_FLOOR] = 0;
//towerValues[TOWER_FD_FLOORSTATE] = 0;
//towerValues[TOWER_FD_EVENTPARAM] = 0;
//towerValues[TOWER_FD_STARS] = 0;
//if (!pTowerTestModel->GetTowerTestField(towerValues))
//{
// KXLOGERROR("%s user %d get tower model error!", __FUNCTION__, uid);
// return;
//}
//if (towerValues[TOWER_FD_FLOORSTATE] != FLOORSTATE_OUTERBONUS)
//{
// KXLOGERROR("%s user %d floorState != FLOORSTATE_OUTERBONUS", __FUNCTION__, uid);
// return;
//}
////返回的协议
//TowerChoseOuterBonusSC outerBonusSC;
//memset(&outerBonusSC, 0, sizeof(outerBonusSC));
////配置中有的buffId才添加
//const TowerBuffItem *pTowerBuffConf = queryConfTowerBuff(towerValues[TOWER_FD_EVENTPARAM]);
//if (NULL == pTowerBuffConf)
//{
// //bug!!!!存的什么东西??
// KXLOGERROR("%s user %d NULL == pTowerBuffConf", __FUNCTION__, uid);
// return;
//}
//for (std::vector<TowerBuffInfo>::const_iterator iter = pTowerBuffConf->Buff.begin();
// iter != pTowerBuffConf->Buff.end(); ++iter)
//{
// if (pOuterBonusCS->outerBonus1 != 0 && iter->BuffID == pOuterBonusCS->outerBonus1)
// {
// outerBonusSC.outerBonus1 = iter->BuffID;
// outerBonusSC.costStars += iter->Cost;
// }
// if (pOuterBonusCS->outerBonus2 != 0 && iter->BuffID == pOuterBonusCS->outerBonus2)
// {
// outerBonusSC.outerBonus2 = iter->BuffID;
// outerBonusSC.costStars += iter->Cost;
// }
// if (pOuterBonusCS->outerBonus3 != 0 && iter->BuffID == pOuterBonusCS->outerBonus3)
// {
// outerBonusSC.outerBonus3 = iter->BuffID;
// outerBonusSC.costStars += iter->Cost;
// }
//}
////消耗星星
//if (outerBonusSC.costStars > 0)
//{
// //下个楼层
// int haveStar = pTowerTestModel->GetTowerTestField(TOWER_FD_STARS);
// if (haveStar < outerBonusSC.costStars)
// {
// //星星不满足
// KXLOGDEBUG("%s haveStar < outerBonusSC.costStars", __FUNCTION__);
// ErrorCodeData CodeData;
// CodeData.nCode = ERROR_BATTLE_STARTERROR;
// CKxCommManager::getInstance()->sendData(uid, CMD_ERRORCODE, ERRORCODE_PROTOCOL, (char*)&CodeData, sizeof(CodeData));
// return;
// }
// haveStar -= outerBonusSC.costStars;
// towerValues[TOWER_FD_STARS] = haveStar;
// std::vector<int> outerBonusVec;
// if (outerBonusSC.outerBonus1 != 0)
// {
// outerBonusVec.push_back(outerBonusSC.outerBonus1);
// }
// if (outerBonusSC.outerBonus2 != 0)
// {
// outerBonusVec.push_back(outerBonusSC.outerBonus2);
// }
// if (outerBonusSC.outerBonus3 != 0)
// {
// outerBonusVec.push_back(outerBonusSC.outerBonus3);
// }
// // 批量添加
// if (!pTowerTestModel->AddOuterBonus(outerBonusVec))
// {
// KXLOGERROR("%s user %d add tower test outer bonus error!", __FUNCTION__, uid);
// }
//}
////下个楼层
//towerValues[TOWER_FD_FLOOR] += 1;
//towerValues[TOWER_FD_FLOORSTATE] = FLOORSTATE_FIGHTING;
//if (!pTowerTestModel->SetTowerTestField(towerValues))
//{
// KXLOGERROR("%s user %d add tower test outer bonus error!", __FUNCTION__, uid);
//}
//
//CKxCommManager::getInstance()->sendData(uid, CMD_TOWERTEST, CMD_TOWER_CHOSEOUTERBONUS_SC,
// reinterpret_cast<char *>(&outerBonusSC), sizeof(outerBonusSC));
}
void CTowerTrialService::processOpenTreasure(int uid, char *buffer, int len, KxServer::IKxComm *commun)
{
// CHECK_RETURN_VOID(len == sizeof(TowerOpenTreasureCS));
//TowerOpenTreasureCS *pOpenTreasureCS = reinterpret_cast<TowerOpenTreasureCS *>(buffer);
//CUserModel *pUserModel = dynamic_cast<CUserModel*>(CModelHelper::getModel(uid, MODELTYPE_USER));
//CTowerTestModel *pTowerTestModel = dynamic_cast<CTowerTestModel*>(CModelHelper::getModel(uid, MODELTYPE_TOWERTEST));
// CHECK_RETURN_VOID(NULL != pUserModel && NULL != pTowerTestModel);
//std::map<int, int> mapValues;
//mapValues[TOWER_FD_FLOOR] = 0;
//mapValues[TOWER_FD_FLOORSTATE] = 0;
//mapValues[TOWER_FD_EVENTPARAM] = 0;
// CHECK_RETURN_VOID(pTowerTestModel->GetTowerTestField(mapValues));
//int floor = mapValues[TOWER_FD_FLOOR];
//int floorState = mapValues[TOWER_FD_FLOORSTATE];
//int eventParam = mapValues[TOWER_FD_EVENTPARAM];
//if (floorState != FLOORSTATE_TREASURE)
//{
// KXLOGDEBUG("%s user %d floorState != FLOORSTATE_TREASURE", __FUNCTION__, uid);
// return;
//}
//TowerOpenTreasureSC openTreasureSC;
//if (pOpenTreasureCS->operate == 0)
//{
// //下个楼层
// mapValues[TOWER_FD_FLOOR] = floor + 1;
// mapValues[TOWER_FD_FLOORSTATE] = FLOORSTATE_FIGHTING;
// mapValues[TOWER_FD_EVENTPARAM] = 1;
// if (!pTowerTestModel->SetTowerTestField(mapValues))
// {
// KXLOGERROR("%s user %d set tower test model data error!", __FUNCTION__, uid);
// }
// openTreasureSC.diamond = 0;
// openTreasureSC.count = 0;
// CKxCommManager::getInstance()->sendData(uid, CMD_TOWERTEST, CMD_TOWER_OPENTREASURE_SC,
// reinterpret_cast<char *>(&openTreasureSC), sizeof(openTreasureSC));
//}
//else
//{
// //目前策划案只能抽一次
// //再抽一次
// const TowerFloorItem *pTowerFloorItem = queryConfTowerFloor(floor);
// if (NULL == pTowerFloorItem)
// {
// KXLOGDEBUG("%s NULL == pTreasureItem", __FUNCTION__);
// return;
// }
// //钻石是否足够,消耗钻石
// const IncreasePayItem * pPayment = queryConfIncreasePay(eventParam);
// if (NULL == pPayment || pPayment->TowerTreasureCost <= 0)
// {
// return;
// }
// int diamond = 0;
// int needDiamond = pPayment->TowerTreasureCost;
// pUserModel->GetUserFieldVal(USR_FD_DIAMOND, diamond);
// if (diamond < needDiamond)
// {
// KXLOGERROR("%s user %d test test OpenTreasure diamond not enough!", __FUNCTION__, uid);
// return;
// }
// else
// {
// //增加购买次数
// eventParam += 1;
// if (!pTowerTestModel->SetTowerTestField(TOWER_FD_EVENTPARAM, eventParam))
// {
// KXLOGERROR("%s user %d add tower test open treasure times error!", __FUNCTION__, uid);
// }
// if (!CModelHelper::addDiamond(uid, -1 * needDiamond))
// {
// KXLOGERROR("%s user %d cost diamond error!", __FUNCTION__, uid);
// }
// }
// std::vector<DropItemInfo> dropItems;
// CItemDrop::Drop(pTowerFloorItem->Drop, dropItems);
// CPropUseHelper::getInstance()->AddItems(uid, dropItems);
// int nSendLen = sizeof(TowerOpenTreasureSC)+dropItems.size()*sizeof(DropItemInfo);
// char *pSendBuffer = reinterpret_cast<char *>(KxServer::kxMemMgrAlocate(nSendLen));
// TowerOpenTreasureSC *pTreasuerSC = reinterpret_cast<TowerOpenTreasureSC *>(pSendBuffer);
// pTreasuerSC->diamond = needDiamond;
// pTreasuerSC->count = dropItems.size();
// DropItemInfo *pPropsInfo = reinterpret_cast<DropItemInfo *>(pTreasuerSC + 1);
// for (size_t i = 0; i < dropItems.size(); ++i)
// {
// memcpy(pPropsInfo, &dropItems[i], sizeof(DropItemInfo));
// pPropsInfo += 1;
// }
// CKxCommManager::getInstance()->sendData(uid, CMD_TOWERTEST, CMD_TOWER_OPENTREASURE_SC,
// pSendBuffer, nSendLen);
// KxServer::kxMemMgrRecycle(pSendBuffer, nSendLen);
// //宝箱抽奖
// CCommOssHelper::userDiamondPayOss(uid, needDiamond, 0,1);
//}
}
void CTowerTrialService::processOneKeyFighting(int uid, char *buffer, int len, KxServer::IKxComm *commun)
{
}
|
50119bda9756b5652bd55824d7db8976d6211713 | ab15f15d1d3cc66bc698cd7cc4e2fedfd47e71d3 | /Image/ImageLabeling.cc | c80c83708605159351f97bf14ef2556720ad279a | [] | no_license | horsewin/ARDiorama_ARMM | 6d39e3612ad898811460c5f3d4f48cf2ca51cd2c | ca76f4548eea18719eb994cd70aa5d6f1ada1498 | refs/heads/master | 2020-05-18T19:50:52.873256 | 2013-01-24T18:40:01 | 2013-01-24T18:40:01 | 4,478,564 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,392 | cc | ImageLabeling.cc | /*
* ImageLabeing.cc
*
* Created on: 2010/11/18
* Author: umakatsu
* 2-dimensional binary imageに対してのラベリングを行うためのクラス
*/
#include "Image/ImageLabeling.h"
#include <stdio.h>
#include <fstream>
#include <vector>
namespace PTAMM{
//const definition
#define DEBUG 0
using namespace std;
namespace{
template< class T > short int Filtering(int i , int j , T **src , T filter[3][3])
// short int Filtering(int i , int j , short int **src, short filter[3][3])
{
return(src[i-1][j-1]*filter[0][0]+src[i-1][j]*filter[1][0]+src[i-1][j+1]*filter[2][0]+src[i][j-1]*filter[0][1]+src[i][j]*filter[1][1]+src[i][j+1]*filter[2][1]+src[i+1][j-1]*filter[0][2]+src[i+1][j]*filter[1][2]+src[i+1][j+1]*filter[2][2]);
}
}
ImageLabeling::ImageLabeling( void ){}
/**
* @param input : binary image
*/
ImageLabeling::ImageLabeling(int size_x , int size_y , unsigned char *input)
: w(size_x) , h(size_y) , src(input)
{
det = new short[ w * h ];
}
ImageLabeling::~ImageLabeling( void )
{
if(det) delete[] det;
}
/*
* ラプラシアンを行うメソッド
* 輪郭抽出のために用いる
*/
//template <class T>
//void ImageLabeling::laplacian( T **result , T **region){
void ImageLabeling::laplacian( short int **result , short int **region){
short int filter[3][3]={{1,1,1},{1,-8,1},{1,1,1}}; //ラプラシアンのフィルタ
for(int y=1; y<(h-1); y++){
for(int x=1; x<(w-1); x++){
if(Filtering( x , y , result , filter) >= 0){
region[x][y] = 0;
}
else{
region[x][y] = 255;
}
}
}
}
void ImageLabeling::run( void ){
// 連結領域抽出の実行 /////////////////////////////////////////////////////
labeling.Exec( src, det , w, h, true, 0 );
// 引数は順に
// 入力画像の先頭アドレス(unsigned char *)
// 出力画像の先頭アドレス(short *)
// 画像の幅(int)
// 画像の高さ(int)
// 領域の大きさ順にソートするか(bool) - true:する false:しない
// 消去する小領域の最大サイズ(int) - これ以下のサイズの領域を消去する
// 処理結果は det(が指す画像バッファ)に格納される。
// また、各連結領域の情報は labeling 内に保持されており、
// メソッドを通じて取り出すことができる。この情報は
// 次の画像のラベリングを実行すると、消去される。
}
}
|
24b60d6245a87f15eeb69c647542cc53a45ea7cd | 9a2aa125270c285f099024374d1256409b4e6409 | /source.cpp | c89387913a4511fcaac21485a4b5be847a9ad363 | [] | no_license | KrzysiekGL/Transportowy-Kalkulator | ace5e1b2472a457d77bdb84083bd5157ef2b7353 | 3d153c60023cbddcecae8bf53e3c6c88266015b0 | refs/heads/master | 2023-08-29T15:59:49.553656 | 2021-10-21T22:39:38 | 2021-10-21T22:39:38 | 272,003,124 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,822 | cpp | source.cpp | #include <iostream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <fstream>
#include <iomanip>
using namespace std;
void drukuj_macierz(float macierz[6][6], int x = 6, int y = 6);
void generuj_macierz(float macierz[6][6], int x = 6, int y = 6); // matrix with pseudo-random data
void wprowadz_macierz(float macierz[6][6]);
void sumuj_macierz(float macierz[6][6]);
void roznica_macierz(float macierz[6][6]);
bool czy_iterowac(float macierz[6][6]);
void iteracja_macierz(float macierz[6][6]);
void zapisz_wynik_macierz(float macierz[6][6], int iteracja);
int main(){
const int rejony = 3;
float macierz_wynikowa[rejony+3][rejony+3] = {0};
wprowadz_macierz(macierz_wynikowa);
sumuj_macierz(macierz_wynikowa);
roznica_macierz(macierz_wynikowa);
drukuj_macierz(macierz_wynikowa);
cout << "podaj MAKSYMALNĄ dopuszczalną ilość iteracji\n(rada: zacznij od wartości nie większej niż 50)\n" << "warunek_stop: ";
int warunek_stop;
cin >> warunek_stop;
bool stop = false;
int iteracja = 0;
while(czy_iterowac(macierz_wynikowa) && iteracja <= warunek_stop) {
cout << "=======Iteracja numer " << iteracja+1 << "=======\n";
iteracja_macierz(macierz_wynikowa);
iteracja++;
if(iteracja == warunek_stop){
cout << "PRZEKROCZONO ZAKRES\nzwiększ warunek_stop\n";
stop = true;
}
}
if(!stop) zapisz_wynik_macierz(macierz_wynikowa, iteracja);
return 0;
}
void drukuj_macierz(float macierz[6][6], int x, int y){
cout << "Rejony\t1\t\t2\t\t3\t\tSuma\t\tGeneracja\tRóżnica\t";
for(int i = 0 ; i < x; i++){
if( i == 0) cout << endl << "1\t";
if( i == 1) cout << endl << "2\t";
if( i == 2) cout << endl << "3\t";
if( i == 3) cout << endl << "Suma\t";
if( i == 4) cout << endl << "Absorbc\t";
if( i == 5) cout << endl << "Różnica\t";
for(int k = 0 ; k < y ; k++){
if( (( k == 3 || k == 4 || k == 5 || k == 6) && ( i == 3 || i == 4 || i == 5))) cout << "\t";
else printf("%lf\t", macierz[i][k]);
}
}
cout << "\n\n";
}
void generuj_macierz(float macierz[6][6], int x, int y){
srand(time(NULL));
for(int i = 0 ; i < x; i++){
for(int k = 0 ; k < y ; k++){
if(i==k) macierz[i][k] = 0;
else macierz[i][k] = rand()% 10 +1;
}
}
}
void wprowadz_macierz(float macierz[6][6]){
for(int rejon = 1 ; rejon < 4 ; rejon++){
cout << "Podaj ilosc Generacji dla rejonu " << rejon << ": ";
cin >> macierz[rejon-1][4];
}
cout << endl;
for(int rejon = 1 ; rejon < 4 ; rejon++){
cout << "Podaj ilosc Absorbcji dla rejonu " << rejon << ": ";
cin >> macierz[4][rejon-1];
}
cout << endl;
for(int rejon1 = 1 ; rejon1 < 4 ; rejon1++){
cout << "Wiersz " << rejon1 << endl;
for(int rejon2 = 1 ; rejon2 < 4 ; rejon2++){
if(rejon1 == rejon2) macierz[rejon2-1][rejon1-1] = 0;
else{
cout << "Podaj ilosc podrozy miedzy rejonem " << rejon1
<< " a rejonem " << rejon2 << ": ";
cin >> macierz[rejon1-1][rejon2-1];
}
}
cout << endl;
}
cout << endl;
}
void sumuj_macierz(float macierz[6][6]){
float suma = 0;
for(int kolumna = 0 ; kolumna < 3 ; kolumna++){
for(int wiersz = 0 ; wiersz < 3 ; wiersz++){
suma += macierz[wiersz][kolumna];
if(wiersz == 2){
macierz[3][kolumna] = suma;
suma = 0;
}
}
}
suma = 0;
for(int wiersz = 0 ; wiersz < 3 ; wiersz++){
for(int kolumna = 0 ; kolumna < 3 ; kolumna++){
suma += macierz[wiersz][kolumna];
if(kolumna == 2){
macierz[wiersz][3] = suma;
suma = 0;
}
}
}
}
void roznica_macierz(float macierz[6][6]){
for(int kolumna = 0 ; kolumna < 3 ; kolumna++)
macierz[5][kolumna] = macierz[3][kolumna] - macierz[4][kolumna];
for(int wiersz = 0 ; wiersz < 3 ; wiersz++)
macierz[wiersz][5] = macierz[wiersz][3] - macierz[wiersz][4];
}
bool czy_iterowac(float macierz[6][6]){
for(int kolumna = 0 ; kolumna < 3 ; kolumna++)
if(macierz[5][kolumna] != 0) return true;
for(int wiersz = 0 ; wiersz < 3 ; wiersz++)
if(macierz[wiersz][5] != 0) return true;
return false;
}
void iteracja_macierz(float macierz[6][6]){
for(int wiersz = 0 ; wiersz < 3 ; wiersz++){
for(int kolumna = 0 ; kolumna < 3 ; kolumna++){
if(wiersz != kolumna) macierz[wiersz][kolumna] = macierz[wiersz][kolumna] / macierz[wiersz][3] * macierz[wiersz][4];
}
}
sumuj_macierz(macierz);
roznica_macierz(macierz);
for(int wiersz = 0 ; wiersz < 3 ; wiersz++){
for(int kolumna = 0 ; kolumna < 3 ; kolumna++){
if(wiersz != kolumna) macierz[wiersz][kolumna] = macierz[wiersz][kolumna] / macierz[3][kolumna] * macierz[4][kolumna];
}
}
sumuj_macierz(macierz);
roznica_macierz(macierz);
drukuj_macierz(macierz);
}
void zapisz_wynik_macierz(float macierz[6][6], int iteracja){
ofstream file;
file.open("wynik.txt", ios::app);
file << std::fixed;
file << std::setprecision(2);
file << "\n~\n\n===Wynik po " << iteracja << " iteracji===\n";
file << "Rejony\t\t1\t\t2\t\t3";
for(int wiersz = 0 ; wiersz < 3 ; wiersz++){
file << "\n" << wiersz+1 << "\t\t";
for(int kolumna = 0 ; kolumna < 3 ; kolumna++){
file << macierz[wiersz][kolumna] << "\t\t";
}
}
file.close();
cout << "Wynik zapisano do pliku \"wynik.txt\".\nJeżeli plik już istniał, wynik został dopisany.\n";
}
|
bff35e26aa20b65dc66de99442eedbcc6b6ff5fc | 0c0cb16aeb0f6ef54f620d7e317c87a7a5ae0fcc | /Algorithms/274_h_index.cc | b1eda90ed20f6be41935f987117ea7996b366d67 | [] | no_license | jeffreyfox/LeetCode | 5b18d95ffc5143933a306f902b7bcce57197e25c | e05ef7ab4345beecd5ea36a63340a3618311a743 | refs/heads/master | 2022-07-28T10:29:02.490115 | 2022-07-20T16:36:38 | 2022-07-20T16:36:38 | 29,803,806 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 3,273 | cc | 274_h_index.cc | /*
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.
According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each."
For example, given citations = [3, 0, 6, 1, 5], which means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively. Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, his h-index is 3.
Note: If there are several possible values for h, the maximum one is taken as the h-index.
Hint:
An easy approach is to sort the array first.
What are the possible values of h-index?
A faster approach is to use extra space.
*/
// 2021. Solution using the idea of counting sort. The only difference is in step 2 when accumulating counts, we need to start from right and move backwards.
// This is due to the definition of the H-index.
// Can optimize and merge step 3 and step 2 into a single loop.
// Also, the size of the counting matrix doesn't need to be kMax. Only citations.size() + 1 is enough (again due to the definition of the H-index).
// See optimized solution in the Solution 2 below.
class Solution {
public:
int hIndex(vector<int>& citations) {
vector<int> counts(kMax);
// Build counts
for (const auto c : citations) {
counts[c] ++;
}
// Accumulate counts
for (int j = kMax - 2; j >= 0; --j) {
counts[j] += counts[j+1];
}
// Search counts
int result = 0;
for (int j = 0; j < kMax; ++j) {
if (counts[j] >= j) result = j;
else break;
}
return result;
}
private:
const int kMax = 1001;
};
// 2015.
// Solution using binary search. First sort array in descending order. Then find the largest index i such that nums[i] >= i+1.
class Solution {
public:
int hIndex(vector<int>& citations) {
if(citations.empty()) return 0;
sort(citations.begin(), citations.end(), std::greater<int>());
int n = citations.size();
int lo = 0, hi = n-1;
//[0 .. lo-1]: num[i] >= i+1; [hi+1, n): num[i] < i+1, return hi
while(lo <= hi) {
int mid = lo + (hi-lo)/2;
if(citations[mid] >= mid+1) lo = mid+1;
else hi = mid-1;
}
return hi+1;
}
};
// Solution 2. Use another table to store the counts, O(n) space, but O(n) time.
// dict[i] stores the number of papers that have citation of i, since hindex can only be 0 to n, where n is the size of input array,
// we only need to keep track of the counts for i = 0 .. n, hence the size of dict is n+1.
class Solution {
public:
int hIndex(vector<int>& citations) {
if(citations.empty()) return 0;
int n = citations.size();
vector<int> dict(n+1, 0); //dict[i]: count for citations equal to i
for(auto c: citations) dict[min(c, n)]++;
for(int i = n, tot = 0; i >= 0; i--) {
tot += dict[i];
if(tot >= i) return i;
}
return 0;
}
};
|
7dc1f1e4fc502247c258c79b00ffac5aaa036c18 | ade9cbf4e9a400d0834c15fe8aca4814bdd5bbe8 | /data_structure/type_traits.hpp | d9fc632e992b3bd4a7083c9c6df187b930401c2f | [
"Apache-2.0"
] | permissive | Jonny0201/data_structure | 70b9d9a446f98678729f1ab097acc08e54f02ed7 | 4950899b5e64616c00689cc3630432fc7157a22f | refs/heads/master | 2022-11-18T16:27:38.182279 | 2022-11-11T12:54:43 | 2022-11-11T12:54:43 | 166,549,211 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 118,002 | hpp | type_traits.hpp | /*
* Copyright © [2019 - 2022] [Jonny Charlotte]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef DATA_STRUCTURE_TYPE_TRAITS_HPP
#define DATA_STRUCTURE_TYPE_TRAITS_HPP
#include "__config.hpp"
__DATA_STRUCTURE_START(constant)
namespace data_structure {
template <typename T, T Value>
struct constant {
using value_type = T;
using type = constant;
constexpr static auto value {Value};
constexpr value_type operator()() const noexcept {
return this->value;
}
constexpr operator value_type() const noexcept {
return this->value;
}
};
template <bool Value>
using bool_constant = constant<bool, Value>;
using true_type = bool_constant<true>;
using false_type = bool_constant<false>;
}
__DATA_STRUCTURE_END
__DATA_STRUCTURE_START(meta)
namespace data_structure {
template <bool, typename If, typename>
struct conditional {
using type = If;
};
template <typename If, typename Then>
struct conditional<false, If, Then> {
using type = Then;
};
template <bool Value, typename If, typename Then>
using conditional_t = typename conditional<Value, If, Then>::type;
template <bool, typename = void>
struct enable_if;
template <typename T>
struct enable_if<true, T> {
using type = T;
};
template <bool Value, typename T = void>
using enable_if_t = typename enable_if<Value, T>::type;
template <typename ...>
struct make_void {
using type = void;
};
template <typename ...Ts>
using make_void_t = typename make_void<Ts...>::type;
template <typename ...>
using void_t = void;
template <typename T>
struct type_identity {
using type = T;
};
template <typename T>
using type_identity_t = typename type_identity<T>::type;
template <typename T>
using type_holder = type_identity<T>;
template <typename T>
using type_holder_t = typename type_holder<T>::type;
template <typename ...>
struct make_true_type {
using type = true_type;
};
template <typename ...Ts>
using make_true_type_t = typename make_true_type<Ts...>::type;
template <typename ...>
struct make_false_type {
using type = false_type;
};
template <typename ...Ts>
using make_false_type_t = typename make_false_type<Ts...>::type;
template <typename ...>
constexpr inline auto make_true {true};
template <typename ...>
constexpr inline auto make_false {false};
template <typename ...Args>
struct type_container;
template <>
struct type_container<> {
using type = type_container<>;
using remaining = type_container<>;
};
template <typename T>
struct type_container<T> {
using type = T;
using remaining = type_container<>;
};
template <typename T, typename ...Args>
struct type_container<T, Args...> {
using type = T;
using remaining = type_container<Args...>;
};
template <void () = [] {}>
struct unique_type {};
using unique_type_t = unique_type<>;
}
__DATA_STRUCTURE_END
__DATA_STRUCTURE_START(detail)
#define __DATA_STRUCTURE_TEST_ADDITION(template_parameters, operation, disable_type, name) \
template <template_parameters> \
static constexpr operation test_##name(int) noexcept; \
template <template_parameters> \
static constexpr disable_type test_##name(...) noexcept
namespace data_structure::__data_structure_auxiliary {
__DATA_STRUCTURE_TEST_ADDITION(typename T, T &, T, lvalue_reference);
__DATA_STRUCTURE_TEST_ADDITION(typename T, T &&, T, rvalue_reference);
__DATA_STRUCTURE_TEST_ADDITION(typename T, T *, T, pointer);
}
#define __DATA_STRUCTURE_REMOVE_CV_HELPER_MAIN(name) \
template <typename> \
struct name##_auxiliary : false_type {}
#define __DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(name, type, ...) \
template <__VA_ARGS__> \
struct name##_auxiliary<type> : true_type {}
namespace data_structure {
template <typename>
struct is_function;
namespace __data_structure_auxiliary {
__DATA_STRUCTURE_REMOVE_CV_HELPER_MAIN(is_integral);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, bool);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, char);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, unsigned char);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, char8_t);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, char16_t);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, char32_t);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, wchar_t);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, short);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, unsigned short);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, int);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, unsigned int);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, long);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, unsigned long);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, long long);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, unsigned long long);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, __int128_t);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_integral, __uint128_t);
__DATA_STRUCTURE_REMOVE_CV_HELPER_MAIN(is_floating_point);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_floating_point, float);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_floating_point, double);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_floating_point, long double);
__DATA_STRUCTURE_REMOVE_CV_HELPER_MAIN(is_character);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_character, char);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_character, unsigned char);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_character, char8_t);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_character, char16_t);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_character, char32_t);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_character, wchar_t);
template <typename T>
struct is_signed_auxiliary : bool_constant<static_cast<T>(-1) < static_cast<T>(0)> {};
template <typename T>
struct is_unsigned_auxiliary : bool_constant<static_cast<T>(0) < static_cast<T>(-1)> {};
__DATA_STRUCTURE_REMOVE_CV_HELPER_MAIN(is_pointer);
__DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION(is_pointer, T *, typename T);
template <typename>
struct is_member_function_pointer_auxiliary : false_type {};
template <typename F, typename Class>
struct is_member_function_pointer_auxiliary<F Class::*> : is_function<F> {};
template <typename T>
static constexpr true_type test_convertible(T) noexcept;
static constexpr false_type test_convertible(...) noexcept;
template <typename T>
static constexpr void test_noexcept(T) noexcept;
template <typename T>
static constexpr bool_constant<noexcept(test_noexcept<T>())> test_nothrow_convertible() noexcept;
template <typename, typename = void>
struct is_invocable_auxiliary : false_type {};
template <typename Result>
struct is_invocable_auxiliary<Result, void_t<typename Result::type>> : true_type {};
template <bool, bool, typename ...>
struct result_of_nothrow_auxiliary : false_type {};
}
}
#define __DATA_STRUCTURE_TEST_OPERATION(name, expression, ...) \
template <__VA_ARGS__> \
static constexpr select_second_t<decltype(expression), true_type> test_##name(int) noexcept; \
template <__VA_ARGS__> \
static constexpr false_type test_##name(...) noexcept
#define __DATA_STRUCTURE_TEST_OPERATION_NOTHROW(name, expression, ...) \
template <__VA_ARGS__> \
static constexpr bool_constant<noexcept(expression)> test_nothrow_##name(int) noexcept; \
template <__VA_ARGS__> \
static constexpr false_type test_nothrow_##name(...) noexcept
namespace data_structure {
namespace __data_structure_auxiliary {
template <typename, typename T>
struct select_second {
using type = T;
};
template <typename T, typename U>
using select_second_t = typename select_second<T, U>::type;
template <typename T>
static constexpr T &&declval_auxiliary(int) noexcept;
template <typename T>
static constexpr T declval_auxiliary(...) noexcept;
}
template <typename T>
constexpr decltype(__dsa::declval_auxiliary<T>(0)) declval() noexcept;
template <typename> struct is_nothrow_move_constructible;
template <typename> struct is_nothrow_move_assignable;
template <typename T>
void swap(T &lhs, T &rhs) noexcept(is_nothrow_move_constructible<T>::value and
is_nothrow_move_assignable<T>::value);
namespace __data_structure_auxiliary {
__DATA_STRUCTURE_TEST_OPERATION(destructible, declval<T >().~T(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(swappable, ds::swap(declval<LHS>(), declval<RHS>()),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(complete, sizeof(T) > 0, typename T);
__DATA_STRUCTURE_TEST_OPERATION(list_constructible, T {declval<Args>()...},
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION(static_castable, static_cast<To>(declval<From>()),
typename From, typename To);
__DATA_STRUCTURE_TEST_OPERATION(dynamic_castable, dynamic_cast<To>(declval<From>()),
typename From, typename To);
__DATA_STRUCTURE_TEST_OPERATION(const_castable, const_cast<To>(declval<From>()),
typename From, typename To);
__DATA_STRUCTURE_TEST_OPERATION(reinterpret_castable, reinterpret_cast<To>(declval<From>()),
typename From, typename To);
__DATA_STRUCTURE_TEST_OPERATION(castable, (To)declval<From>(), typename From, typename To);
__DATA_STRUCTURE_TEST_OPERATION(swap_memfun, declval<T &>().swap(declval<T &>()), typename T);
__DATA_STRUCTURE_TEST_OPERATION(address_of, declval<T>().operator&(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(bit_and, declval<LHS>() bitand declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(bit_and_assignment, declval<LHS>() and_eq declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(bit_or, declval<LHS>() | declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(bit_or_assignment, declval<LHS>() or_eq declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(bit_xor, declval<LHS>() xor declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(bit_xor_assignment, declval<LHS>() xor_eq declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(complement, compl declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(dereference, *declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(divide, declval<LHS>() / declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(divide_assignment, declval<LHS>() /= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(equal_to, declval<LHS>() == declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(greater, declval<LHS>() > declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(greater_equal_to, declval<LHS>() >= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(left_shift, declval<LHS>() << declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(left_shift_assignment, declval<LHS>() <<= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(right_shift, declval<LHS>() >> declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(right_shift_assignment, declval<LHS>() >>= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(less, declval<LHS>() < declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(less_equal_to, declval<LHS>() <= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(logical_and, declval<LHS>() and declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(logical_or, declval<LHS>() or declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(logical_not, not declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(unary_minus, -declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(minus, declval<LHS>() - declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(minus_assignment, declval<LHS>() -= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(modules, declval<LHS>() % declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(modules_assignment, declval<LHS>() %= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(multiply, declval<LHS>() * declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(multiply_assignment, declval<LHS>() *= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(three_way, declval<LHS>() <=> declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(not_equal_to, declval<LHS>() not_eq declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(plus, declval<LHS>() + declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(unary_plus, +declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(plus_assignment, declval<LHS>() += declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(subscript, declval<LHS>()[declval<RHS>()],
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION(pre_increment, ++declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(post_increment, declval<T>()++, typename T);
__DATA_STRUCTURE_TEST_OPERATION(pre_decrement, --declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(post_decrement, declval<T>()--, typename T);
__DATA_STRUCTURE_TEST_OPERATION(member_access_by_pointer, declval<T>().operator->(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(member_access_by_pointer_dereference,
declval<T>().operator->*(), typename T);
__DATA_STRUCTURE_TEST_OPERATION(new_operator, T::operator new(declval<Args>()...),
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION(new_array_operator, T::operator new[](declval<Args>()...),
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION(delete_operator, T::operator delete(declval<Args>()...),
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION(delete_array_operator, T::operator delete[](declval<Args>()...),
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION(function_call, declval<T>()(declval<Args>()...),
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION(comma, (declval<T>().operator,(declval<Arg>())), typename T, typename Arg);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(destructible, declval<T &>().~T(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(swappable, ds::swap(declval<LHS>(), declval<RHS>()),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(list_constructible, T {declval<Args>()...},
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(static_castable, static_cast<To>(declval<From>()),
typename From, typename To);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(dynamic_castable, dynamic_cast<To>(declval<From>()),
typename From, typename To);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(const_castable, const_cast<To>(declval<From>()),
typename From, typename To);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(reinterpret_castable, reinterpret_cast<To>(declval<From>()),
typename From, typename To);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(castable, (To)declval<From>(), typename From, typename To);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(swap_memfun, declval<T &>().swap(declval<T &>()), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(address_of, declval<T>().operator&(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(bit_and, declval<LHS>() bitand declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(bit_and_assignment, declval<LHS>() and_eq declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(bit_or, declval<LHS>() | declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(bit_or_assignment, declval<LHS>() or_eq declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(bit_xor, declval<LHS>() xor declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(bit_xor_assignment, declval<LHS>() xor_eq declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(complement, compl declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(dereference, *declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(divide, declval<LHS>() / declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(divide_assignment, declval<LHS>() /= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(equal_to, declval<LHS>() == declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(greater, declval<LHS>() > declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(greater_equal_to, declval<LHS>() >= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(left_shift, declval<LHS>() << declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(left_shift_assignment, declval<LHS>() <<= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(right_shift, declval<LHS>() >> declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(right_shift_assignment, declval<LHS>() >>= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(less, declval<LHS>() < declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(less_equal_to, declval<LHS>() <= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(logical_and, declval<LHS>() and declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(logical_or, declval<LHS>() or declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(logical_not, not declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(unary_minus, -declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(minus, declval<LHS>() - declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(minus_assignment, declval<LHS>() -= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(modules, declval<LHS>() % declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(modules_assignment, declval<LHS>() %= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(multiply, declval<LHS>() * declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(multiply_assignment, declval<LHS>() *= declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(three_way, declval<LHS>() <=> declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(not_equal_to, declval<LHS>() not_eq declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(plus, declval<LHS>() + declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(unary_plus, +declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(plus_assignment, declval<LHS>() += declval<RHS>(),
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(subscript, declval<LHS>()[declval<RHS>()],
typename LHS, typename RHS);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(pre_increment, ++declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(post_increment, declval<T>()++, typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(pre_decrement, --declval<T>(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(post_decrement, declval<T>()--, typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(member_access_by_pointer, declval<T>().operator->(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(member_access_by_pointer_dereference,
declval<T>().operator->*(), typename T);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(new_operator, T::operator new(declval<Args>()...),
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(new_array_operator, T::operator new[](declval<Args>()...),
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(delete_operator, T::operator delete(declval<Args>()...),
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(delete_array_operator, T::operator delete[](declval<Args>()...),
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(function_call, declval<T>()(declval<Args>()...),
typename T, typename ...Args);
__DATA_STRUCTURE_TEST_OPERATION_NOTHROW(comma, (declval<T>().operator,(declval<Arg>())),
typename T, typename Arg);
}
}
__DATA_STRUCTURE_END
__DATA_STRUCTURE_START(add something)
namespace data_structure {
template <typename T>
struct add_lvalue_reference {
using type = decltype(__dsa::test_lvalue_reference<T>(0));
};
template <typename T>
using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
template <typename T>
struct add_rvalue_reference {
using type = decltype(__dsa::test_rvalue_reference<T>(0));
};
template <typename T>
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
template <typename T>
struct add_pointer {
using type = decltype(__dsa::test_pointer<T>(0));
};
template <typename T>
using add_pointer_t = typename add_pointer<T>::type;
template <typename T>
struct add_const {
using type = const T;
};
template <typename T>
using add_const_t = typename add_const<T>::type;
template <typename T>
struct add_volatile {
using type = volatile T;
};
template <typename T>
using add_volatile_t = typename add_volatile<T>::type;
template <typename T>
struct add_cv : add_const<add_volatile_t<T>> {};
template <typename T>
using add_cv_t = typename add_cv<T>::type;
template <typename T>
struct add_const_reference : add_lvalue_reference<add_const_t<T>> {};
template <typename T>
using add_const_reference_t = typename add_const_reference<T>::type;
template <typename T>
struct add_const_pointer : add_pointer<add_const_t<T>> {};
template <typename T>
using add_const_pointer_t = typename add_const_pointer<T>::type;
}
__DATA_STRUCTURE_END
__DATA_STRUCTURE_START(remove something)
namespace data_structure {
template <typename T>
struct remove_lvalue_reference {
using type = T;
};
template <typename T>
struct remove_lvalue_reference<T &> {
using type = T;
};
template <typename T>
using remove_lvalue_reference_t = typename remove_lvalue_reference<T>::type;
template <typename T>
struct remove_rvalue_reference {
using type = T;
};
template <typename T>
struct remove_rvalue_reference<T &&> {
using type = T;
};
template <typename T>
using remove_rvalue_reference_t = typename remove_rvalue_reference<T>::type;
template <typename T>
struct remove_reference {
using type = T;
};
template <typename T>
struct remove_reference<T &> {
using type = T;
};
template <typename T>
struct remove_reference<T &&> {
using type = T;
};
template <typename T>
using remove_reference_t = typename remove_reference<T>::type;
template <typename T>
struct remove_pointer {
using type = T;
};
template <typename T>
struct remove_pointer<T *> {
using type = T;
};
template <typename T>
struct remove_pointer<T *const> {
using type = T;
};
template <typename T>
struct remove_pointer<T *volatile> {
using type = T;
};
template <typename T>
struct remove_pointer<T *const volatile> {
using type = T;
};
template <typename T>
using remove_pointer_t = typename remove_pointer<T>::type;
template <typename T>
struct remove_const {
using type = T;
};
template <typename T>
struct remove_const<const T> {
using type = T;
};
template <typename T>
using remove_const_t = typename remove_const<T>::type;
template <typename T>
struct remove_volatile {
using type = T;
};
template <typename T>
struct remove_volatile<volatile T> {
using type = T;
};
template <typename T>
using remove_volatile_t = typename remove_volatile<T>::type;
template <typename T>
struct remove_cv : remove_const<remove_volatile_t<T>> {};
template <typename T>
using remove_cv_t = typename remove_cv<T>::type;
template <typename T>
struct remove_const_reference : remove_const<remove_reference_t<T>> {};
template <typename T>
using remove_const_reference_t = typename remove_const_reference<T>::type;
template <typename T>
struct remove_cvref : remove_cv<remove_reference_t<T>> {};
template <typename T>
using remove_cvref_t = typename remove_cvref<T>::type;
template <typename T>
struct remove_extent {
using type = T;
};
template <typename T>
struct remove_extent<T []> {
using type = T;
};
template <typename T, size_t N>
struct remove_extent<T [N]> {
using type = T;
};
template <typename T>
using remove_extent_t = typename remove_extent<T>::type;
template <typename T>
struct remove_extents {
using type = T;
};
template <typename T>
using remove_extents_t = typename remove_extents<T>::type;
template <typename T>
struct remove_extents<T []> {
using type = remove_extents_t<T>;
};
template <typename T, size_t N>
struct remove_extents<T [N]> {
using type = remove_extents_t<T>;
};
}
__DATA_STRUCTURE_END
__DATA_STRUCTURE_START(is something)
namespace data_structure {
template <typename, typename>
struct is_same : false_type {};
template <typename T>
struct is_same<T, T> : true_type {};
template <typename T, typename U>
constexpr inline auto is_same_v = is_same<T, U>::value;
template <typename T>
struct is_void : is_same<void, remove_cv_t<T>> {};
template <typename T>
constexpr inline auto is_void_v {is_void<T>::value};
template <typename T>
struct is_null_pointer : is_same<decltype(nullptr), remove_cv_t<T>> {};
template <typename T>
constexpr inline auto is_null_pointer_v {is_null_pointer<T>::value};
template <typename T>
struct is_const : false_type {};
template <typename T>
struct is_const<const T> : true_type {};
template <typename T>
constexpr inline auto is_const_v {is_const<T>::value};
template <typename T>
struct is_volatile : false_type {};
template <typename T>
struct is_volatile<volatile T> : true_type {};
template <typename T>
constexpr inline auto is_volatile_v {is_volatile<T>::value};
template <typename T>
struct is_cv : false_type {};
template <typename T>
struct is_cv<const volatile T> : true_type {};
template <typename T>
constexpr inline auto is_cv_v {is_cv<T>::value};
template <typename T>
struct is_integral : __dsa::is_integral_auxiliary<remove_cv_t<T>> {};
template <typename T>
constexpr inline auto is_integral_v {is_integral<T>::value};
template <typename T>
struct is_floating_point : __dsa::is_floating_point_auxiliary<remove_cv_t<T>> {};
template <typename T>
constexpr inline auto is_floating_point_v {is_floating_point<T>::value};
template <typename T>
struct is_signed : __dsa::is_signed_auxiliary<remove_cv_t<T>> {};
template <typename T>
constexpr inline auto is_signed_v {is_signed<T>::value};
template <typename T>
struct is_unsigned : __dsa::is_unsigned_auxiliary<remove_cv_t<T>> {};
template <typename T>
constexpr inline auto is_unsigned_v {is_unsigned<T>::value};
template <typename T>
struct is_character : __dsa::is_character_auxiliary<remove_cv_t<T>> {};
template <typename T>
constexpr inline auto is_character_v {is_character<T>::value};
template <typename>
struct is_array : false_type {};
template <typename T>
struct is_array<T []> : true_type {};
template <typename T, size_t N>
struct is_array<T [N]> : true_type {};
template <typename T>
constexpr inline auto is_array_v {is_array<T>::value};
template <typename>
struct is_unbounded_array : false_type {};
template <typename T>
struct is_unbounded_array<T []> : true_type {};
template <typename T>
constexpr inline auto is_unbounded_array_v {is_unbounded_array<T>::value};
template <typename>
struct is_bounded_array : false_type {};
template <typename T, size_t N>
struct is_bounded_array<T [N]> : true_type {};
template <typename T>
constexpr inline auto is_bounded_array_v {is_bounded_array<T>::value};
template <typename T>
struct is_enum : bool_constant<__is_enum(T)> {};
template <typename T>
constexpr inline auto is_enum_v {is_enum<T>::value};
template <typename T>
struct is_union : bool_constant<__is_union(T)> {};
template <typename T>
constexpr inline auto is_union_v {is_union<T>::value};
template <typename T>
struct is_class : bool_constant<__is_class(T)> {};
template <typename T>
constexpr inline auto is_class_v {is_class<T>::value};
template <typename>
struct is_function : false_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...)> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...)> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) volatile> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const volatile> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) volatile> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const volatile> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) &> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const &> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) volatile &> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const volatile &> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) &> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const &> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) volatile &> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const volatile &> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) &&> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const &&> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) volatile &&> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const volatile &&> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) &&> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const &&> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) volatile &&> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const volatile &&> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) volatile noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const volatile noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) volatile noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const volatile noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) & noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const & noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) volatile & noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const volatile & noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) & noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const & noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) volatile & noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const volatile & noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) && noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const && noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) volatile && noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args...) const volatile && noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) && noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const && noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) volatile && noexcept> : true_type {};
template <typename R, typename ...Args>
struct is_function<R (Args..., ...) const volatile && noexcept> : true_type {};
template <typename T>
constexpr inline auto is_function_v {is_function<T>::value};
template <typename T>
struct is_pointer : __dsa::is_pointer_auxiliary<remove_cv_t<T>> {};
template <typename T>
constexpr inline auto is_pointer_v {is_pointer<T>::value};
template <typename T>
struct is_member_pointer : false_type {};
template <typename T, typename Class>
struct is_member_pointer<T Class::*> : true_type {};
template <typename T>
constexpr inline auto is_member_pointer_v {is_member_pointer<T>::value};
template <typename T>
struct is_member_function_pointer : __dsa::is_member_function_pointer_auxiliary<remove_cv_t<T>> {};
template <typename T>
constexpr inline auto is_member_function_pointer_v {is_member_function_pointer<T>::value};
template <typename T>
struct is_member_object_pointer : bool_constant<is_member_pointer_v<T> and not is_member_function_pointer_v<T>> {};
template <typename T>
constexpr inline auto is_member_object_pointer_v {is_member_object_pointer<T>::value};
template <typename T>
struct is_function_pointer : bool_constant<is_pointer_v<T> and
(is_function_v<remove_pointer_t<T>> or is_void_v<remove_pointer_t<T>> or
is_null_pointer_v<remove_pointer_t<T>>)> {};
template <typename T>
constexpr inline auto is_function_pointer_v {is_function_pointer<T>::value};
template <typename T>
struct is_lvalue_reference : false_type {};
template <typename T>
struct is_lvalue_reference<T &> : false_type {};
template <typename T>
constexpr inline auto is_lvalue_reference_v {is_lvalue_reference<T>::value};
template <typename T>
struct is_rvalue_reference : false_type {};
template <typename T>
struct is_rvalue_reference<T &&> : false_type {};
template <typename T>
constexpr inline auto is_rvalue_reference_v {is_rvalue_reference<T>::value};
template <typename T>
struct is_reference : false_type {};
template <typename T>
struct is_reference<T &> : true_type {};
template <typename T>
struct is_reference<T &&> : true_type {};
template <typename T>
constexpr inline auto is_reference_v {is_reference<T>::value};
template <typename T>
struct is_const_reference : bool_constant<is_lvalue_reference_v<T> and
is_const_v<remove_lvalue_reference_t<T>>> {};
template <typename T>
constexpr inline auto is_const_reference_v {is_const_reference<T>::value};
template <typename>
struct is_type : true_type {};
template <typename T>
constexpr inline auto is_type_v {is_type<T>::value};
template <typename T>
struct is_complete : decltype(__dsa::test_complete<T>(0)) {};
template <typename T>
constexpr inline auto is_complete_v {is_complete<T>::value};
template <typename T>
struct is_pod : bool_constant<__is_pod(T)> {};
template <typename T>
constexpr inline auto is_pod_v {is_pod<T>::value};
template <typename T>
struct is_empty : bool_constant<__is_empty(T)> {};
template <typename T>
constexpr inline auto is_empty_v {is_empty<T>::value};
template <typename T>
struct is_literal_type : bool_constant<__is_literal_type(T)> {};
template <typename T>
constexpr inline auto is_literal_type_v {is_literal_type<T>::value};
template <typename T>
struct is_standard_layout : bool_constant<__is_standard_layout(T)> {};
template <typename T>
constexpr inline auto is_standard_layout_v {is_standard_layout<T>::value};
template <typename T>
struct is_polymorphic : bool_constant<__is_polymorphic(T)> {};
template <typename T>
constexpr inline auto is_polymorphic_v {is_polymorphic<T>::value};
template <typename T>
struct is_abstract : bool_constant<__is_abstract(T)> {};
template <typename T>
constexpr inline auto is_abstract_v {is_abstract<T>::value};
template <typename Base, typename Derived>
struct is_base_of : bool_constant<__is_base_of(Base, Derived)> {};
template <typename Base, typename Derived>
constexpr inline auto is_base_of_v {is_base_of<Base, Derived>::value};
template <typename T>
struct is_final : bool_constant<__is_final(T)> {};
template <typename T>
constexpr inline auto is_final_v {is_final<T>::value};
template <typename T>
struct is_aggregate : bool_constant<__is_aggregate(T)> {};
template <typename T>
constexpr inline auto is_aggregate_v {is_aggregate<T>::value};
template <typename T>
struct is_arithmetic : bool_constant<is_integral_v<T> or is_floating_point_v<T>> {};
template <typename T>
constexpr inline auto is_arithmetic_v {is_arithmetic<T>::value};
template <typename T>
struct is_fundamental : bool_constant<is_arithmetic_v<T> or is_void_v<T> or
is_null_pointer_v<remove_cv_t<T>>> {};
template <typename T>
constexpr inline auto is_fundamental_v {is_fundamental<T>::value};
template <typename T>
struct is_scalar : bool_constant<is_arithmetic_v<T> or is_enum_v<T> or is_pointer_v<T> or
is_member_pointer_v<T> or is_null_pointer_v<T>> {};
template <typename T>
constexpr inline auto is_scalar_v {is_scalar<T>::value};
template <typename T>
struct is_compound : bool_constant<not is_fundamental_v<T>> {};
template <typename T>
constexpr inline auto is_compound_v {is_compound<T>::value};
template <typename T>
struct is_object : bool_constant<is_scalar_v<T> or is_array_v<T> or is_union_v<T> or is_class_v<T>> {};
template <typename T>
constexpr inline auto is_object_v {is_object<T>::value};
template <typename T>
struct is_trivial : bool_constant<__is_trivial(T)> {};
template <typename T>
constexpr inline auto is_trivial_v {is_trivial<T>::value};
template <typename T>
struct is_trivially_copyable : bool_constant<__is_trivially_copyable(T)> {};
template <typename T>
constexpr inline auto is_trivially_copyable_v {is_trivially_copyable<T>::value};
template <typename T, typename ...Args>
struct is_trivially_constructible : bool_constant<__is_trivially_constructible(T, Args...)> {};
template <typename T, typename ...Args>
constexpr inline auto is_trivially_constructible_v {is_trivially_constructible<T, Args...>::value};
template <typename T>
struct is_trivially_default_constructible : is_trivially_constructible<T> {};
template <typename T>
constexpr inline auto is_trivially_default_constructible_v {is_trivially_default_constructible<T>::value};
template <typename T>
struct is_trivially_copy_constructible : is_trivially_constructible<T, add_const_reference_t<T>> {};
template <typename T>
constexpr inline auto is_trivially_copy_constructible_v {is_trivially_copy_constructible<T>::value};
template <typename T>
struct is_trivially_move_constructible : is_trivially_constructible<T, add_rvalue_reference_t<T>> {};
template <typename T>
constexpr inline auto is_trivially_move_constructible_v {is_trivially_move_constructible<T>::value};
template <typename LHS, typename RHS = LHS>
struct is_trivially_assignable : bool_constant<__is_trivially_assignable(LHS, RHS)> {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto is_trivially_assignable_v {is_trivially_assignable<LHS, RHS>::value};
template <typename T>
struct is_trivially_copy_assignable : is_trivially_assignable<T, add_const_reference_t<T>> {};
template <typename T>
constexpr inline auto is_trivially_copy_assignable_v {is_trivially_copy_assignable<T>::value};
template <typename T>
struct is_trivially_move_assignable : is_trivially_assignable<T, add_rvalue_reference_t<T>> {};
template <typename T>
constexpr inline auto is_trivially_move_assignable_v {is_trivially_move_assignable<T>::value};
template <typename From, typename To>
struct is_convertible : bool_constant<__is_convertible_to(From, To) and not is_abstract_v<To>> {};
template <typename From, typename To>
constexpr inline auto is_convertible_v {is_convertible<From, To>::value};
template <typename T>
struct is_trivially_destructible : bool_constant<__is_trivially_destructible(T)> {};
template <typename T>
constexpr inline auto is_trivially_destructible_v {is_trivially_destructible<T>::value};
template <typename T, typename ...Args>
struct is_constructible : bool_constant<__is_constructible(T, Args...)> {};
template <typename T>
constexpr inline auto is_constructible_v {is_constructible<T>::value};
template <typename T>
struct is_default_constructible : is_constructible<T> {};
template <typename T>
constexpr inline auto is_default_constructible_v {is_default_constructible<T>::value};
template <typename T>
struct is_copy_constructible : is_constructible<T, add_const_reference_t<T>> {};
template <typename T>
constexpr inline auto is_copy_constructible_v {is_copy_constructible<T>::value};
template <typename T>
struct is_move_constructible : is_constructible<T, add_rvalue_reference_t<T>> {};
template <typename T>
constexpr inline auto is_move_constructible_v {is_move_constructible<T>::value};
template <typename T, typename ...Args>
struct is_list_constructible : decltype(__dsa::test_list_constructible<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto is_list_constructible_v {is_list_constructible<T, Args...>::value};
template <typename LHS, typename RHS = LHS>
struct is_assignable : bool_constant<__is_assignable(LHS, RHS)> {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto is_assignable_v {is_assignable<LHS, RHS>::value};
template <typename T>
struct is_copy_assignable : is_assignable<T, add_const_reference_t<T>> {};
template <typename T>
constexpr inline auto is_copy_assignable_v {is_copy_assignable<T>::value};
template <typename T>
struct is_move_assignable : is_assignable<T, add_rvalue_reference_t<T>> {};
template <typename T>
constexpr inline auto is_move_assignable_v {is_move_assignable<T>::value};
template <typename T>
struct is_destructible : conditional_t<
not is_function_v<T> and not is_unbounded_array_v<T> and not is_same_v<void, T>,
conditional_t<is_reference_v<T>, true_type, conditional_t<
is_complete_v<T>, decltype(__dsa::test_destructible<remove_extents_t<T>>(0)), false_type>
>, false_type> {};
template <typename T>
constexpr inline auto is_destructible_v {is_destructible<T>::value};
template <typename LHS, typename RHS = LHS>
struct is_swappable_with : conditional_t<is_void_v<LHS> or is_void_v<RHS>, false_type,
conditional_t<is_same_v<decltype(__dsa::test_swappable<LHS, RHS>(0)),
decltype(__dsa::test_swappable<RHS, LHS>(0))>,
decltype(__dsa::test_swappable<LHS, RHS>(0)), false_type>
> {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto is_swappable_with_v {is_swappable_with<LHS, RHS>::value};
template <typename T>
struct is_swappable : is_swappable_with<T, T> {};
template <typename T>
constexpr inline auto is_swappable_v {is_swappable<T>::value};
template <typename, typename ...> struct invoke_result;
template <typename F, typename ...Args>
struct is_invocable : __dsa::is_invocable_auxiliary<invoke_result<F, Args...>> {};
template <typename F, typename ...Args>
constexpr inline auto is_invocable_v {is_invocable<F, Args...>::value};
template <typename R, typename F, typename ...Args>
struct is_invocable_r : conditional_t<is_invocable_v<F, Args...>,
conditional_t<is_convertible_v<typename invoke_result<F, Args...>::type, R>, true_type, false_type>,
false_type> {};
template <typename R, typename F, typename ...Args>
constexpr inline auto is_invocable_r_v {is_invocable_r<R, F, Args...>::value};
template <typename From, typename To>
struct is_static_castable : decltype(__dsa::test_static_castable<From, To>(0)) {};
template <typename From, typename To>
constexpr inline auto is_static_castable_v {is_static_castable<From, To>::value};
template <typename From, typename To>
struct is_dynamic_castable : decltype(__dsa::test_dynamic_castable<From, To>(0)) {};
template <typename From, typename To>
constexpr inline auto is_dynamic_castable_v {is_dynamic_castable<From, To>::value};
template <typename From, typename To>
struct is_const_castable : decltype(__dsa::test_const_castable<From, To>(0)) {};
template <typename From, typename To>
constexpr inline auto is_const_castable_v {is_const_castable<From, To>::value};
template <typename From, typename To>
struct is_reinterpret_castable : decltype(__dsa::test_reinterpret_castable<From, To>(0)) {};
template <typename From, typename To>
constexpr inline auto is_reinterpret_castable_v {is_reinterpret_castable<From, To>::value};
template <typename From, typename To>
struct is_castable : decltype(__dsa::test_castable<From, To>(0)) {};
template <typename From, typename To>
constexpr inline auto is_castable_v {is_castable<From, To>::value};
template <typename T, typename ...Args>
struct is_nothrow_constructible : bool_constant<__is_nothrow_constructible(T, Args...)> {};
template <typename T, typename ...Args>
constexpr inline auto is_nothrow_constructible_v {is_nothrow_constructible<T, Args...>::value};
template <typename T>
struct is_nothrow_default_constructible : is_nothrow_constructible<T> {};
template <typename T>
constexpr inline auto is_nothrow_default_constructible_v {is_nothrow_default_constructible<T>::value};
template <typename T>
struct is_nothrow_copy_constructible : is_nothrow_constructible<T, add_const_reference_t<T>> {};
template <typename T>
constexpr inline auto is_nothrow_copy_constructible_v {is_nothrow_copy_constructible<T>::value};
template <typename T>
struct is_nothrow_move_constructible : is_nothrow_constructible<T, add_rvalue_reference_t<T>> {};
template <typename T>
constexpr inline auto is_nothrow_move_constructible_v {is_nothrow_move_constructible<T>::value};
template <typename T, typename ...Args>
struct is_nothrow_list_constructible :
decltype(__dsa::test_nothrow_list_constructible<T, Args...>()) {};
template <typename T, typename ...Args>
constexpr inline auto is_nothrow_list_constructible_v {is_nothrow_list_constructible<T, Args...>::value};
template <typename LHS, typename RHS = LHS>
struct is_nothrow_assignable : bool_constant<__is_nothrow_assignable(LHS, RHS)> {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto is_nothrow_assignable_v {is_nothrow_assignable<LHS, RHS>::value};
template <typename T>
struct is_nothrow_copy_assignable :
is_nothrow_assignable<add_lvalue_reference_t<T>, add_const_reference_t<T>> {};
template <typename T>
constexpr inline auto is_nothrow_copy_assignable_v {is_nothrow_copy_assignable<T>::value};
template <typename T>
struct is_nothrow_move_assignable :
is_nothrow_assignable<add_lvalue_reference_t<T>, add_rvalue_reference_t<T>> {};
template <typename T>
constexpr inline auto is_nothrow_move_assignable_v {is_nothrow_move_assignable<T>::value};
template <typename T>
struct is_nothrow_destructible : decltype(__dsa::test_nothrow_destructible<T>(0)) {};
template <typename T>
constexpr inline auto is_nothrow_destructible_v {is_nothrow_destructible<T>::value};
template <typename LHS, typename RHS = LHS>
struct is_nothrow_swappable_with : conditional_t<is_swappable_with_v<LHS, RHS>,
decltype(__dsa::test_nothrow_swappable<LHS, RHS>(0)), false_type> {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto is_nothrow_swappable_with_v {is_nothrow_swappable_with<LHS, RHS>::value};
template <typename T>
struct is_nothrow_swappable : is_nothrow_swappable_with<T, T> {};
template <typename T>
constexpr inline auto is_nothrow_swappable_v {is_nothrow_swappable<T>::value};
template <typename Ptr, typename ...Args>
struct is_nothrow_invocable :
__dsa::result_of_nothrow_auxiliary<is_member_object_pointer_v<remove_reference_t<Ptr>>,
is_member_function_pointer_v<remove_reference_t<Ptr>>, Ptr, Args...> {};
template <typename Ptr, typename ...Args>
constexpr inline auto is_nothrow_invocable_v {is_nothrow_invocable<Ptr, Args...>::value};
template <typename From, typename To>
struct is_nothrow_convertible : conditional_t<is_void_v<From> and is_void_v<To>, true_type,
conditional_t<is_convertible_v<From, To>,
decltype(__dsa::test_nothrow_convertible<To>(declval<From>())), false_type>> {};
template <typename From, typename To>
constexpr inline auto is_nothrow_convertible_v {is_nothrow_convertible<From, To>::value};
template <typename R, typename Ptr, typename ...Args>
struct is_nothrow_invocable_r : bool_constant<is_nothrow_invocable_v<Ptr, Args...> and
is_nothrow_convertible_v<typename invoke_result<Ptr, Args...>::type, R>> {};
template <typename From, typename To>
struct is_nothrow_static_castable : decltype(__dsa::test_nothrow_static_castable<From, To>(0)) {};
template <typename From, typename To>
constexpr inline auto is_nothrow_static_castable_v {is_nothrow_static_castable<From, To>::value};
template <typename From, typename To>
struct is_nothrow_dynamic_castable : decltype(__dsa::test_nothrow_dynamic_castable<From, To>(0)) {};
template <typename From, typename To>
constexpr inline auto is_nothrow_dynamic_castable_v {is_nothrow_dynamic_castable<From, To>::value};
template <typename From, typename To>
struct is_nothrow_const_castable : decltype(__dsa::test_nothrow_const_castable<From, To>(0)) {};
template <typename From, typename To>
constexpr inline auto is_nothrow_const_castable_v {is_nothrow_const_castable<From, To>::value};
template <typename From, typename To>
struct is_nothrow_reinterpret_castable :
decltype(__dsa::test_nothrow_reinterpret_castable<From, To>(0)) {};
template <typename From, typename To>
constexpr inline auto is_nothrow_reinterpret_castable_v {is_nothrow_reinterpret_castable<From, To>::value};
template <typename From, typename To>
struct is_nothrow_castable : decltype(__dsa::test_nothrow_castable<From, To>(0)) {};
template <typename From, typename To>
constexpr inline auto is_nothrow_castable_v {is_nothrow_castable<From, To>::value};
template <typename T>
struct is_stateless : conditional_t<is_trivially_default_constructible_v<T> and
is_trivially_copy_constructible_v<T> and is_trivially_assignable_v<T> and
is_trivially_destructible_v<T> and is_empty_v<T>, true_type, false_type> {};
template <typename T>
constexpr inline auto is_stateless_v {is_stateless<T>::value};
template <typename Base, typename Derived>
struct is_virtual_base_of : bool_constant<is_base_of_v<Base, Derived> and
is_castable_v<Derived, Base> and not is_castable_v<Base, Derived>> {};
template <typename Base, typename Derived>
constexpr inline auto is_virtual_base_of_v {is_virtual_base_of<Base, Derived>::value};
template <typename E>
struct is_scoped_enum : bool_constant<is_enum_v<E> and is_convertible_v<E, int>> {};
template <typename E>
constexpr inline auto is_scoped_enum_v {is_scoped_enum<E>::value};
}
__DATA_STRUCTURE_END
__DATA_STRUCTURE_START(has something)
namespace data_structure {
template <typename T>
struct has_virtual_destructor : conditional_t<__has_virtual_destructor(T), true_type, false_type> {};
template <typename T>
constexpr inline auto has_virtual_destructor_v {has_virtual_destructor<T>::value};
template <typename T>
struct has_unique_object_representations :
conditional_t<__has_unique_object_representations(T), true_type, false_type> {};
template <typename T>
constexpr inline auto has_unique_object_representations_v {has_unique_object_representations<T>::value};
template <typename T>
struct has_swap_member_function : decltype(__dsa::test_swap_memfun<T>(0)) {};
template <typename T>
constexpr inline auto has_swap_member_function_v {has_swap_member_function<T>::value};
template <typename T>
struct has_nothrow_swap_member_function : decltype(__dsa::test_nothrow_swap_memfun<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_swap_member_function_v {has_nothrow_swap_member_function<T>::value};
template <typename T>
struct has_address_of_operator : decltype(__dsa::test_address_of<T>(0)) {};
template <typename T>
constexpr inline auto has_address_of_operator_v {has_address_of_operator<T>::value};
template <typename T>
struct has_nothrow_address_of_operator : decltype(__dsa::test_nothrow_address_of<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_address_of_operator_v {has_nothrow_address_of_operator<T>::value};
template <typename LHS, typename RHS = LHS>
struct has_bit_and_operator : decltype(__dsa::test_bit_and<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_bit_and_operator_v {has_bit_and_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_bit_and_operator : decltype(__dsa::test_nothrow_bit_and<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_bit_and_operator_v {has_nothrow_bit_and_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_bit_and_assignment_operator : decltype(__dsa::test_bit_and_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_bit_and_assignment_operator_v {has_bit_and_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_bit_and_assignment_operator :
decltype(__dsa::test_nothrow_bit_and_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_bit_and_assignment_operator_v {
has_nothrow_bit_and_assignment_operator<LHS, RHS>::value
};
template <typename LHS, typename RHS = LHS>
struct has_bit_or_operator : decltype(__dsa::test_bit_or<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_bit_or_operator_v {has_bit_or_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_bit_or_operator : decltype(__dsa::test_nothrow_bit_or<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_bit_or_operator_v {has_nothrow_bit_or_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_bit_or_assignment_operator : decltype(__dsa::test_bit_or_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_bit_or_assignment_operator_v {has_bit_or_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_bit_or_assignment_operator :
decltype(__dsa::test_nothrow_bit_or_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_bit_or_assignment_operator_v {
has_nothrow_bit_or_assignment_operator<LHS, RHS>::value
};
template <typename LHS, typename RHS = LHS>
struct has_bit_xor_operator : decltype(__dsa::test_bit_xor<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_bit_xor_operator_v {has_bit_xor_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_bit_xor_operator : decltype(__dsa::test_nothrow_bit_xor<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_bit_xor_operator_v {has_nothrow_bit_xor_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_bit_xor_assignment_operator : decltype(__dsa::test_bit_xor_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_bit_xor_assignment_operator_v {has_bit_xor_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_bit_xor_assignment_operator :
decltype(__dsa::test_nothrow_bit_xor_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_bit_xor_assignment_operator_v {
has_nothrow_bit_xor_assignment_operator<LHS, RHS>::value
};
template <typename T>
struct has_complement_operator : decltype(__dsa::test_complement<T>(0)) {};
template <typename T>
constexpr inline auto has_complement_operator_v {has_complement_operator<T>::value};
template <typename T>
struct has_nothrow_complement_operator : decltype(__dsa::test_nothrow_complement<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_complement_operator_v {has_nothrow_complement_operator<T>::value};
template <typename T>
struct has_dereference_operator : decltype(__dsa::test_dereference<T>(0)) {};
template <typename T>
constexpr inline auto has_dereference_operator_v {has_dereference_operator<T>::value};
template <typename T>
struct has_nothrow_dereference_operator : decltype(__dsa::test_nothrow_dereference<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_dereference_operator_v {has_nothrow_dereference_operator<T>::value};
template <typename LHS, typename RHS = LHS>
struct has_divide_operator : decltype(__dsa::test_divide<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_divide_operator_v {has_divide_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_divide_operator : decltype(__dsa::test_nothrow_divide<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_divide_operator_v {has_nothrow_divide_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_divide_assignment_operator : decltype(__dsa::test_divide_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_divide_assignment_operator_v {has_divide_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_divide_assignment_operator :
decltype(__dsa::test_nothrow_divide_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_divide_assignment_operator_v {
has_nothrow_divide_assignment_operator<LHS, RHS>::value
};
template <typename LHS, typename RHS = LHS>
struct has_equal_to_operator : decltype(__dsa::test_equal_to<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_equal_to_operator_v {has_equal_to_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_equal_to_operator : decltype(__dsa::test_nothrow_equal_to<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_equal_to_operator_v {has_nothrow_equal_to_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_greater_operator : decltype(__dsa::test_greater<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_greater_operator_v {has_greater_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_greater_operator : decltype(__dsa::test_nothrow_greater<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_greater_operator_v {has_nothrow_greater_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_greater_equal_to_operator : decltype(__dsa::test_greater_equal_to<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_greater_equal_to_operator_v {has_greater_equal_to_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_greater_equal_to_operator : decltype(__dsa::test_nothrow_greater_equal_to<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_greater_equal_to_operator_v {
has_nothrow_greater_equal_to_operator<LHS, RHS>::value
};
template <typename LHS, typename RHS = LHS>
struct has_left_shift_operator : decltype(__dsa::test_left_shift<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_left_shift_operator_v {has_left_shift_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_left_shift_operator : decltype(__dsa::test_nothrow_left_shift<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_left_shift_operator_v {has_nothrow_left_shift_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_left_shift_assignment_operator : decltype(__dsa::test_left_shift_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_left_shift_assignment_operator_v {has_left_shift_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_left_shift_assignment_operator :
decltype(__dsa::test_nothrow_left_shift_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_left_shift_assignment_operator_v {
has_nothrow_left_shift_assignment_operator<LHS, RHS>::value
};
template <typename LHS, typename RHS = LHS>
struct has_right_shift_operator : decltype(__dsa::test_right_shift<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_right_shift_operator_v {has_right_shift_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_right_shift_operator : decltype(__dsa::test_nothrow_right_shift<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_right_shift_operator_v {has_nothrow_right_shift_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_right_shift_assignment_operator :
decltype(__dsa::test_right_shift_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_right_shift_assignment_operator_v {has_right_shift_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_right_shift_assignment_operator :
decltype(__dsa::test_nothrow_right_shift_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_right_shift_assignment_operator_v {
has_nothrow_right_shift_assignment_operator<LHS, RHS>::value
};
template <typename LHS, typename RHS = LHS>
struct has_less_operator : decltype(__dsa::test_less<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_less_operator_v {has_less_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_less_operator : decltype(__dsa::test_nothrow_less<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_less_operator_v {has_nothrow_less_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_less_equal_to_operator : decltype(__dsa::test_less_equal_to<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_less_equal_to_operator_v {has_less_equal_to_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_less_equal_to_operator : decltype(__dsa::test_nothrow_less_equal_to<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_less_equal_to_operator_v {has_nothrow_less_equal_to_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_logical_and_operator : decltype(__dsa::test_logical_and<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_logical_and_operator_v {has_logical_and_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_logical_and_operator : decltype(__dsa::test_nothrow_logical_and<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_logical_and_operator_v {has_nothrow_logical_and_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_logical_or_operator : decltype(__dsa::test_logical_or<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_logical_or_operator_v {has_logical_or_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_logical_or_operator : decltype(__dsa::test_nothrow_logical_or<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_logical_or_operator_v {has_nothrow_logical_or_operator<LHS, RHS>::value};
template <typename T>
struct has_logical_not_operator : decltype(__dsa::test_logical_not<T>(0)) {};
template <typename T>
constexpr inline auto has_logical_not_operator_v {has_logical_not_operator<T>::value};
template <typename T>
struct has_nothrow_logical_not_operator : decltype(__dsa::test_nothrow_logical_not<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_logical_not_operator_v {has_nothrow_logical_not_operator<T>::value};
template <typename T>
struct has_unary_minus_operator : decltype(__dsa::test_unary_minus<T>(0)) {};
template <typename T>
constexpr inline auto has_unary_minus_operator_v {has_unary_minus_operator<T>::value};
template <typename T>
struct has_nothrow_unary_minus_operator : decltype(__dsa::test_nothrow_unary_minus<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_unary_minus_operator_v {has_nothrow_unary_minus_operator<T>::value};
template <typename LHS, typename RHS = LHS>
struct has_minus_operator : decltype(__dsa::test_minus<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_minus_operator_v {has_minus_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_minus_operator : decltype(__dsa::test_nothrow_minus<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_minus_operator_v {has_nothrow_minus_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_minus_assignment_operator : decltype(__dsa::test_minus_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_minus_assignment_operator_v {has_minus_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_minus_assignment_operator : decltype(__dsa::test_nothrow_minus_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_minus_assignment_operator_v {
has_nothrow_minus_assignment_operator<LHS, RHS>::value
};
template <typename LHS, typename RHS = LHS>
struct has_modules_operator : decltype(__dsa::test_modules<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_modules_operator_v {has_modules_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_modules_operator : decltype(__dsa::test_nothrow_modules<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_modules_operator_v {has_nothrow_modules_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_modules_assignment_operator : decltype(__dsa::test_modules_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_modules_assignment_operator_v {has_modules_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_modules_assignment_operator : decltype(__dsa::test_nothrow_modules_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_modules_assignment_operator_v {
has_nothrow_modules_assignment_operator<LHS, RHS>::value
};
template <typename LHS, typename RHS = LHS>
struct has_multiply_operator : decltype(__dsa::test_multiply<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_multiply_operator_v {has_multiply_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_multiply_operator : decltype(__dsa::test_nothrow_multiply<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_multiply_operator_v {has_nothrow_multiply_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_multiply_assignment_operator : decltype(__dsa::test_multiply_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_multiply_assignment_operator_v {has_multiply_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_multiply_assignment_operator : decltype(__dsa::test_nothrow_multiply_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_multiply_assignment_operator_v {
has_nothrow_multiply_assignment_operator<LHS, RHS>::value
};
template <typename LHS, typename RHS = LHS>
struct has_three_way_operator : decltype(__dsa::test_three_way<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_three_way_operator_v {has_three_way_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_three_way_operator : decltype(__dsa::test_nothrow_three_way<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_three_way_operator_v {has_nothrow_three_way_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_not_equal_to_operator : decltype(__dsa::test_not_equal_to<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_not_equal_to_operator_v {has_not_equal_to_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_not_equal_to_operator : decltype(__dsa::test_nothrow_not_equal_to<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_not_equal_to_operator_v {has_nothrow_not_equal_to_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_plus_operator : decltype(__dsa::test_plus<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_plus_operator_v {has_plus_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_plus_operator : decltype(__dsa::test_nothrow_plus<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_plus_operator_v {has_nothrow_plus_operator<LHS, RHS>::value};
template <typename T>
struct has_unary_plus_operator : decltype(__dsa::test_unary_plus<T>(0)) {};
template <typename T>
constexpr inline auto has_unary_plus_operator_v {has_unary_plus_operator<T>::value};
template <typename T>
struct has_nothrow_unary_plus_operator : decltype(__dsa::test_nothrow_unary_plus<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_unary_plus_operator_v {has_nothrow_unary_plus_operator<T>::value};
template <typename LHS, typename RHS = LHS>
struct has_plus_assignment_operator : decltype(__dsa::test_plus_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_plus_assignment_operator_v {has_plus_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_plus_assignment_operator : decltype(__dsa::test_nothrow_plus_assignment<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_plus_assignment_operator_v {has_nothrow_plus_assignment_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_subscript_operator : decltype(__dsa::test_subscript<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_subscript_operator_v {has_subscript_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_subscript_operator : decltype(__dsa::test_nothrow_subscript<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_subscript_operator_v {has_nothrow_subscript_operator<LHS, RHS>::value};
template <typename T>
struct has_pre_increment_operator : decltype(__dsa::test_pre_increment<T>(0)) {};
template <typename T>
constexpr inline auto has_pre_increment_operator_v {has_pre_increment_operator<T>::value};
template <typename T>
struct has_nothrow_pre_increment_operator : decltype(__dsa::test_nothrow_pre_increment<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_pre_increment_operator_v {has_nothrow_pre_increment_operator<T>::value};
template <typename T>
struct has_post_increment_operator : decltype(__dsa::test_post_increment<T>(0)) {};
template <typename T>
constexpr inline auto has_post_increment_operator_v {has_post_increment_operator<T>::value};
template <typename T>
struct has_nothrow_post_increment_operator : decltype(__dsa::test_nothrow_post_increment<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_post_increment_operator_v {has_nothrow_post_increment_operator<T>::value};
template <typename T>
struct has_pre_decrement_operator : decltype(__dsa::test_pre_decrement<T>(0)) {};
template <typename T>
constexpr inline auto has_pre_decrement_operator_v {has_pre_decrement_operator<T>::value};
template <typename T>
struct has_nothrow_pre_decrement_operator : decltype(__dsa::test_nothrow_pre_decrement<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_pre_decrement_operator_v {has_nothrow_pre_decrement_operator<T>::value};
template <typename T>
struct has_post_decrement_operator : decltype(__dsa::test_post_decrement<T>(0)) {};
template <typename T>
constexpr inline auto has_post_decrement_operator_v {has_post_decrement_operator<T>::value};
template <typename T>
struct has_nothrow_post_decrement_operator : decltype(__dsa::test_nothrow_post_decrement<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_post_decrement_operator_v {has_nothrow_post_decrement_operator<T>::value};
template <typename T>
struct has_member_access_by_pointer_operator : decltype(__dsa::test_member_access_by_pointer<T>(0)) {};
template <typename T>
constexpr inline auto has_member_access_by_pointer_operator_v {has_member_access_by_pointer_operator<T>::value};
template <typename T>
struct has_nothrow_member_access_by_pointer_operator :
decltype(__dsa::test_nothrow_member_access_by_pointer<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_member_access_by_pointer_operator_v {
has_nothrow_member_access_by_pointer_operator<T>::value
};
template <typename T>
struct has_member_access_by_pointer_dereference_operator :
decltype(__dsa::test_member_access_by_pointer_dereference<T>(0)) {};
template <typename T>
constexpr inline auto has_member_access_by_pointer_dereference_operator_v {
has_member_access_by_pointer_dereference_operator<T>::value
};
template <typename T>
struct has_nothrow_member_access_by_pointer_dereference_operator :
decltype(__dsa::test_nothrow_member_access_by_pointer_dereference<T>(0)) {};
template <typename T>
constexpr inline auto has_nothrow_member_access_by_pointer_dereference_operator_v {
has_nothrow_member_access_by_pointer_dereference_operator<T>::value
};
template <typename T, typename ...Args>
struct has_new_operator : decltype(__dsa::test_new_operator<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto has_new_operator_v {has_new_operator<T, Args...>::value};
template <typename T, typename ...Args>
struct has_nothrow_new_operator : decltype(__dsa::test_nothrow_new_operator<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto has_nothrow_new_operator_v {has_nothrow_new_operator<T, Args...>::value};
template <typename T, typename ...Args>
struct has_new_array_operator : decltype(__dsa::test_new_array_operator<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto has_new_array_operator_v {has_new_array_operator<T, Args...>::value};
template <typename T, typename ...Args>
struct has_nothrow_new_array_operator : decltype(__dsa::test_nothrow_new_array_operator<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto has_nothrow_new_array_operator_v {has_nothrow_new_array_operator<T, Args...>::value};
template <typename T, typename ...Args>
struct has_delete_operator : decltype(__dsa::test_delete_operator<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto has_delete_operator_v {has_delete_operator<T, Args...>::value};
template <typename T, typename ...Args>
struct has_nothrow_delete_operator : decltype(__dsa::test_nothrow_delete_operator<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto has_nothrow_delete_operator_v {has_nothrow_delete_operator<T, Args...>::value};
template <typename T, typename ...Args>
struct has_delete_array_operator : decltype(__dsa::test_delete_array_operator<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto has_delete_array_operator_v {has_delete_array_operator<T, Args...>::value};
template <typename T, typename ...Args>
struct has_nothrow_delete_array_operator : decltype(__dsa::test_nothrow_delete_array_operator<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto has_nothrow_delete_array_operator_v {
has_nothrow_delete_array_operator<T, Args...>::value
};
template <typename T, typename ...Args>
struct has_function_call_operator : decltype(__dsa::test_function_call<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto has_function_call_operator_v {has_function_call_operator<T, Args...>::value};
template <typename T, typename ...Args>
struct has_nothrow_function_call_operator : decltype(__dsa::test_nothrow_function_call<T, Args...>(0)) {};
template <typename T, typename ...Args>
constexpr inline auto has_nothrow_function_call_operator_v {
has_nothrow_function_call_operator<T, Args...>::value
};
template <typename LHS, typename RHS = LHS>
struct has_comma_operator : decltype(__dsa::test_comma<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_comma_operator_v {has_comma_operator<LHS, RHS>::value};
template <typename LHS, typename RHS = LHS>
struct has_nothrow_comma_operator : decltype(__dsa::test_nothrow_comma<LHS, RHS>(0)) {};
template <typename LHS, typename RHS = LHS>
constexpr inline auto has_nothrow_comma_operator_v {has_nothrow_comma_operator<LHS, RHS>::value};
}
__DATA_STRUCTURE_END
__DATA_STRUCTURE_START(copy something)
namespace data_structure {
template <typename Original, typename To>
struct copy_const {
using type = conditional_t<is_const_v<Original>, add_const_t<To>, To>;
};
template <typename Original, typename To>
using copy_const_t = typename copy_const<Original, To>::type;
template <typename Original, typename To>
struct copy_volatile {
using type = conditional_t<is_volatile_v<Original>, add_volatile_t<To>, To>;
};
template <typename Original, typename To>
using copy_volatile_t = typename copy_volatile<Original, To>::type;
template <typename Original, typename To>
struct copy_cv {
using type = copy_const_t<Original, copy_volatile_t<Original, To>>;
};
template <typename Original, typename To>
using copy_cv_t = typename copy_cv<Original, To>::type;
template <typename Original, typename To>
struct copy_lvalue_reference {
using type = conditional_t<is_lvalue_reference_v<Original>, add_lvalue_reference_t<To>, To>;
};
template <typename Original, typename To>
using copy_lvalue_reference_t = typename copy_lvalue_reference<Original, To>::type;
template <typename Original, typename To>
struct copy_rvalue_reference {
using type = conditional_t<is_rvalue_reference_v<Original>, add_rvalue_reference_t<To>, To>;
};
template <typename Original, typename To>
using copy_rvalue_reference_t = typename copy_rvalue_reference<Original, To>::type;
template <typename Original, typename To>
struct copy_reference {
using type = conditional_t<is_lvalue_reference_v<Original>, add_lvalue_reference_t<To>,
conditional_t<is_rvalue_reference_v<Original>, add_rvalue_reference_t<To>, To>>;
};
template <typename Original, typename To>
using copy_reference_t = typename copy_reference<Original, To>::type;
template <typename Original, typename To>
struct copy_const_reference {
using type = conditional_t<is_const_reference_v<Original>, add_const_reference_t<To>, To>;
};
template <typename Original, typename To>
using copy_const_reference_t = typename copy_const_reference<Original, To>::type;
template <typename Original, typename To>
struct copy_cvref {
using type = copy_cv_t<Original, copy_reference_t<Original, To>>;
};
}
__DATA_STRUCTURE_END
__DATA_STRUCTURE_START(other auxliary)
namespace data_structure {
template <typename> struct decay;
template <typename ...> struct common_type;
template <typename> struct alignment_of;
namespace __data_structure_auxiliary {
using signed_integral = type_container<signed char, signed short, signed int,
signed long,signed long long, __int128_t>;
using unsigned_integral = type_container<unsigned char, unsigned short, unsigned int,
unsigned long, unsigned long long, __uint128_t>;
using floating_point = type_container<float, double, long double>;
using character = type_container<char8_t, char16_t, char32_t>;
template <typename T, typename Result, typename Container>
struct make_signed_or_unsigned_auxiliary {
private:
using next_type = typename Container::type;
using remaining_type = typename Container::remaining;
public:
using type = conditional_t<sizeof(T) == sizeof(Result), Result,
conditional_t<(sizeof(T) > sizeof(Result)) and sizeof(T) <= sizeof(next_type), next_type,
typename make_signed_or_unsigned_auxiliary<T, next_type, remaining_type>::type>>;
};
template <typename T, typename Result>
struct make_signed_or_unsigned_auxiliary<T, Result, type_container<>> {
using type = Result;
};
template <typename, typename>
struct promotion_index;
template <typename T, typename Container>
using promotion_index_t = typename promotion_index<T, Container>::type;
template <typename T, typename Container>
struct promotion_index {
private:
using next_type = typename Container::remaining;
using this_type = typename Container::type;
public:
using type = conditional_t<is_same_v<T, this_type>, Container, promotion_index_t<T, next_type>>;
};
template <typename T>
struct promotion_index<T, type_container<>> {
using type = type_container<>;
};
template <typename T, typename = void>
struct integral_promotion_auxiliary {
static_assert(is_integral_v<T>, "This trait requires an integral type!");
};
template <typename T>
struct integral_promotion_auxiliary<T, enable_if_t<is_signed_v<T>>> {
using type = conditional_t<
is_same_v<typename promotion_index<T, signed_integral>::type::type, __int128_t>,
__int128_t, typename promotion_index<T, signed_integral>::type::remaining::type>;
};
template <typename T>
struct integral_promotion_auxiliary<T, enable_if_t<is_unsigned_v<T>>> {
using type = conditional_t<
is_same_v<typename promotion_index<T, unsigned_integral>::type::type, __uint128_t>,
__uint128_t, typename promotion_index<T, unsigned_integral>::type::remaining::type>;
};
template <typename T, typename = void>
struct floating_point_promotion_auxiliary {
static_assert(is_floating_point_v<T>, "The trait requires a floating point type!");
};
template <typename T>
struct floating_point_promotion_auxiliary<T, enable_if_t<is_floating_point_v<T>>> {
using type = conditional_t<
is_same_v<typename promotion_index<T, floating_point>::type::type, long double>,
long double, typename promotion_index<T, floating_point>::type::remaining::type>;
};
template <typename T, typename = void>
struct character_promotion_auxiliary {
static_assert(is_character_v<T>, "The trait requires a character type!");
};
template <typename T>
struct character_promotion_auxiliary<T, enable_if_t<is_character_v<T>>> {
using type = conditional_t<
is_same_v<typename promotion_index<T, character>::type::type, char32_t>,
char32_t, typename promotion_index<T, character>::type::remaining::type>;
};
template <typename T, typename = void>
struct arithmetic_promotion_auxiliary {
static_assert(is_integral_v<T> or is_floating_point_v<T>,
"The trait requires a character type or an integral type!");
};
template <typename T>
struct arithmetic_promotion_auxiliary<T, enable_if_t<is_integral_v<T>>> :
copy_cv<T, typename __dsa::integral_promotion_auxiliary<remove_cv_t<T>>::type> {};
template <typename T>
struct arithmetic_promotion_auxiliary<T, enable_if_t<is_floating_point_v<T>>> :
copy_cv<T, typename __dsa::floating_point_promotion_auxiliary<remove_cv_t<T>>::type> {};
template <typename T>
using decay_t = typename decay<T>::type;
template <typename> struct reference_wrapper;
struct invoke_failure_tag {};
template <typename T, typename = decay_t<T>>
struct unwrap : type_identity<T> {};
template <typename T, typename U>
struct unwrap<T, reference_wrapper<U>> : type_identity<reference_wrapper<U>> {};
template <typename Fp, typename T, typename ...Args>
static constexpr decltype((declval<T>().*declval<Fp>())(declval<Args>()...))
test_member_function(int) noexcept;
template <typename ...>
static constexpr invoke_failure_tag test_member_function(...) noexcept;
template <typename Fp, typename T, typename ...Args>
static consteval inline bool is_nothrow_member_function() noexcept {
return noexcept((declval<T>().*declval<Fp>())(declval<Args>()...));
}
template <typename Fp, typename Ptr, typename ...Args>
static constexpr decltype((declval<Ptr>()->*declval<Fp>())(declval<Args>()...))
test_member_function_deref(int) noexcept;
template <typename ...>
static constexpr invoke_failure_tag test_member_function_deref(...) noexcept;
template <typename Fp, typename Ptr, typename ...Args>
static consteval inline bool is_nothrow_member_function_deref() noexcept {
return noexcept((declval<Ptr>()->*declval<Fp>())(declval<Args>()...));
}
template <typename Op, typename T>
static constexpr decltype(declval<T>().*declval<Op>()) test_member_object(int) noexcept;
template <typename, typename>
static constexpr invoke_failure_tag test_member_object(...) noexcept;
template <typename Op, typename T>
static consteval inline bool is_nothrow_member_object() noexcept {
return noexcept(declval<T>().*declval<Op>());
}
template <typename Op, typename T>
static constexpr decltype(declval<T>()->*declval<Op>()) test_member_object_deref(int) noexcept;
template <typename, typename>
static constexpr invoke_failure_tag test_member_object_deref(...) noexcept;
template <typename Op, typename T>
static consteval inline bool is_nothrow_member_object_deref() noexcept {
return noexcept(declval<T>()->*declval<Op>());
}
template <typename F, typename ...Args>
static constexpr decltype(declval<F>()(declval<Args>()...)) test_function(int) noexcept;
template <typename ...>
static constexpr invoke_failure_tag test_function(...) noexcept;
template <typename F, typename ...Args>
static consteval inline bool is_nothrow_function() noexcept {
return noexcept(declval<F>()(declval<Args>()...));
}
template <typename, typename>
struct result_of_member_object;
template <typename PreT, typename Class, typename T>
struct result_of_member_object<PreT Class::*, T> {
using type = conditional_t<
is_same_v<remove_cvref_t<T>, Class> or is_base_of_v<Class, remove_cvref_t<T>>,
decltype(test_member_object<PreT Class::*, T>(0)),
decltype(test_member_object_deref<PreT Class::*, T>(0))>;
};
template <typename, typename>
struct result_of_nothrow_member_object;
template <typename PreT, typename Class, typename T>
struct result_of_nothrow_member_object<PreT Class::*, T> :
conditional_t<is_same_v<remove_cvref_t<T>, Class> or is_base_of_v<Class, remove_cvref_t<T>>,
bool_constant<is_nothrow_member_object<PreT Class::*, T>()>,
bool_constant<is_nothrow_member_object_deref<PreT Class::*, T>()>> {};
template <typename ...>
struct result_of_member_function;
template <typename PreT, typename Class, typename Fp, typename ...Args>
struct result_of_member_function<PreT Class::*, Fp, Args...> {
using type = conditional_t<
is_same_v<remove_cvref_t<Fp>, Class> or is_base_of_v<Class, remove_cvref_t<Fp>>,
decltype(test_member_function<PreT Class::*, Fp, Args...>(0)),
decltype(test_member_function_deref<PreT Class::*, Fp, Args...>(0))>;
};
template <typename ...>
struct result_of_nothrow_member_function;
template <typename PreT, typename Class, typename Fp, typename ...Args>
struct result_of_nothrow_member_function<PreT Class::*, Fp, Args...> :
conditional_t<is_same_v<remove_cvref_t<Fp>, Class> or is_base_of_v<Class, remove_cvref_t<Fp>>,
bool_constant<is_nothrow_member_function<PreT Class::*, Fp, Args...>()>,
bool_constant<is_nothrow_member_function_deref<PreT Class::*, Fp, Args...>()>> {};
template <bool, bool, typename, typename ...>
struct result_of_auxiliary : invoke_failure_tag {};
template <typename MenPtr, typename T>
struct result_of_auxiliary<true, false, MenPtr, T> : conditional_t<is_same_v<invoke_failure_tag,
typename result_of_member_object<decay_t<MenPtr>, typename unwrap<T>::type>::type>,
invoke_failure_tag, result_of_member_object<decay_t<MenPtr>, typename unwrap<T>::type>> {};
template <typename MenPtr, typename T, typename ...Args>
struct result_of_auxiliary<false, true, MenPtr, T, Args...> :
conditional_t<is_same_v<invoke_failure_tag, typename result_of_member_function<
decay_t<MenPtr>, typename unwrap<T>::type, Args...>::type>,
invoke_failure_tag,
result_of_member_function<decay_t<MenPtr>, typename unwrap<T>::type, Args...>> {};
template <typename F, typename ...Args>
struct result_of_auxiliary<false, false, F, Args...> : conditional_t<is_same_v<invoke_failure_tag,
decltype(test_function<F, Args...>(0))>, invoke_failure_tag,
type_identity<decltype(test_function<F, Args...>(0))>> {};
template <typename MemPtr, typename T>
struct result_of_nothrow_auxiliary<true, false, MemPtr, T> :
result_of_nothrow_member_object<decay_t<MemPtr>, typename unwrap<T>::type> {};
template <typename MemPtr, typename T, typename ...Args>
struct result_of_nothrow_auxiliary<false, true, MemPtr, T, Args...> :
result_of_nothrow_member_function<decay_t<MemPtr>, typename unwrap<T>::type> {};
template <typename F, typename ...Args>
struct result_of_nothrow_auxiliary<false, false, F, Args...> :
bool_constant<is_nothrow_function<F, Args...>()> {};
struct aligned_storage_double_helper {
long double _1;
};
struct aligned_storage_double4_helper {
double _1[4];
};
using aligned_storage_helper_types = type_container<unsigned char, unsigned short, unsigned int,
unsigned long, unsigned long long, double, long double, aligned_storage_double_helper,
aligned_storage_double4_helper, int *>;
template <size_t Align>
struct alignas(Align) overaligned {};
template <typename, size_t>
struct aligned_storage_find_suitable_type;
template <size_t Align, typename T, typename ...Args>
struct aligned_storage_find_suitable_type<type_container<T, Args...>, Align> {
using type = conditional_t<Align == alignof(T), T,
typename aligned_storage_find_suitable_type<type_container<Args...>, Align>::type>;
};
template <size_t Align>
struct aligned_storage_find_suitable_type<type_container<>, Align> {
using type = overaligned<Align>;
};
template <size_t Length, size_t Align1, size_t Align2>
struct aligned_storage_selector {
private:
constexpr static auto min {Align1 < Align2 ? Align1 : Align2};
constexpr static auto max {Align1 < Align2 ? Align2 : Align1};
public:
constexpr static auto value {Length < max ? min : max};
};
template <typename, size_t>
struct aligned_storage_find_max_align;
template <size_t Length, typename T>
struct aligned_storage_find_max_align<type_container<T>, Length> : alignment_of<T> {};
template <size_t Length, typename T, typename ...Args>
struct aligned_storage_find_max_align<type_container<T, Args...>, Length> : constant<size_t,
aligned_storage_selector<Length, alignof(T),
aligned_storage_find_max_align<type_container<Args...>, Length>::value>::value> {};
template <typename, typename ...>
struct aligned_union_find_max_align;
template <typename T>
struct aligned_union_find_max_align<T> : alignment_of<T> {};
template <typename T, typename U>
struct aligned_union_find_max_align<T, U> :
conditional<alignof(T) < alignof(U), alignment_of<U>, alignment_of<T>> {};
template <typename T, typename U, typename ...Args>
struct aligned_union_find_max_align<T, U, Args...> : conditional_t<alignof(T) < alignof(U),
aligned_union_find_max_align<U, Args...>, aligned_union_find_max_align<T, Args...>> {};
template <size_t, size_t ...>
struct aligned_union_find_max_number;
template <size_t N>
struct aligned_union_find_max_number<N> : constant<size_t, N> {};
template <size_t N, size_t M>
struct aligned_union_find_max_number<N, M> :
conditional_t<N < M, constant<size_t, M>, constant<size_t, M>> {};
template <size_t N, size_t M, size_t ...Numbers>
struct aligned_union_find_max_number<N, M, Numbers...> :
aligned_union_find_max_number<aligned_union_find_max_number<N, M>::value, Numbers...> {};
union type_with_alignment_max_alignment {
char _1;
short _2;
int _3;
long _4;
long long _5;
__int128_t _6;
float _7;
double _8;
long double _9;
};
using type_with_alignment_helper_types = type_container<
char, short, int, long, long long, double, long double>;
template <typename, size_t>
struct type_with_alignment_find_suitable_type;
template <size_t Align>
struct type_with_alignment_find_suitable_type<type_container<>, Align> {
using type = type_with_alignment_max_alignment;
};
template <size_t Align, typename T, typename ...Args>
struct type_with_alignment_find_suitable_type<type_container<T, Args...>, Align> {
using type = conditional_t<Align < alignof(T), T,
typename type_with_alignment_find_suitable_type<type_container<Args...>, Align>::type>;
};
template <typename T, typename U>
using common_ref_auxiliary = decltype(make_true<T, U> ? declval<T (&)()>()() : declval<U (&)()>()());
template <typename T, typename U, typename = void>
struct common_ref_impl {};
template <typename T, typename U>
using common_ref = typename common_ref_impl<T, U>::type;
template <typename T, typename U>
struct common_ref_impl<T &, U &, void_t<common_ref_auxiliary<
add_lvalue_reference_t<copy_cv_t<T, U>>, add_lvalue_reference_t<copy_cv_t<U, T>>>>> {
using type = common_ref_auxiliary<
add_lvalue_reference_t<copy_cv_t<T, U>>, add_lvalue_reference_t<copy_cv_t<U, T>>>;
};
template <typename T, typename U>
using common_ref_make_rvalue_ref = add_rvalue_reference_t<remove_reference_t<common_ref<T &, U &>>>;
template <typename T, typename U>
struct common_ref_impl<T &&, U &&, enable_if_t<is_convertible_v<T &&, common_ref_make_rvalue_ref<T, U>>
and is_convertible_v<U &&, common_ref_make_rvalue_ref<T, U>>>> {
using type = common_ref_make_rvalue_ref<T, U>;
};
template <typename T, typename U>
using common_ref_for_const_ref = common_ref<const T &, U &>;
template <typename T, typename U>
struct common_ref_impl<T &&, U &, enable_if_t<is_convertible_v<T &&, common_ref_for_const_ref<T, U>>>> {
using type = common_ref_for_const_ref<T, U>;
};
template <typename T, typename U>
struct common_ref_impl<T &, U &&> : common_ref_impl<U &&, T &> {};
template <typename T, typename U, template <typename> typename TQual, template <typename> typename UQual>
struct basic_common_reference {};
template <typename T>
struct copy_ref_for_class_template {
template <typename U>
using type = copy_cv_t<T, U>;
};
template <typename T>
struct copy_ref_for_class_template<T &> {
template <typename U>
using type = add_lvalue_reference_t<copy_cv_t<T, U>>;
};
template <typename T>
struct copy_ref_for_class_template<T &&> {
template <typename U>
using type = add_rvalue_reference_t<copy_cv_t<T, U>>;
};
template <typename T, typename U>
using basic_common_ref = typename basic_common_reference<remove_cvref_t<T>, remove_cvref_t<U>,
copy_ref_for_class_template<T>::template type, copy_ref_for_class_template<U>::template type>::type;
template <typename T, typename U, int Bullet = 1, typename = void>
struct common_reference_auxiliary : common_reference_auxiliary<T, U, Bullet + 1> {};
template <typename T, typename U>
struct common_reference_auxiliary<T &, U &, 1, void_t<common_ref<T &, U &>>> {
using type = common_ref<T &, U &>;
};
template <typename T, typename U>
struct common_reference_auxiliary<T &&, U &&, 1, void_t<common_ref<T &, U &>>> {
using type = common_ref<T &&, U &&>;
};
template <typename T, typename U>
struct common_reference_auxiliary<T &, U &&, 1, void_t<common_ref<T &, U &&>>> {
using type = common_ref<T &, U &&>;
};
template <typename T, typename U>
struct common_reference_auxiliary<T &&, U &, 1, void_t<common_ref<T &&, U &>>> {
using type = common_ref<T &&, U &>;
};
template <typename T, typename U>
struct common_reference_auxiliary<T, U, 2, void_t<basic_common_ref<T, U>>> {
using type = basic_common_ref<T, U>;
};
template <typename T, typename U>
struct common_reference_auxiliary<T, U, 3, void_t<common_ref_auxiliary<T, U>>> {
using type = common_ref_auxiliary<T, U>;
};
template <typename T, typename U>
struct common_reference_auxiliary<T, U, 4, void_t<typename common_type<T, U>::type>> {
using type = typename common_type<T, U>::type;
};
template <typename T, typename U>
struct common_reference_auxiliary<T, U, 5, void> {};
}
}
__DATA_STRUCTURE_END
__DATA_STRUCTURE_START(other)
namespace data_structure {
template <typename T>
struct size_of : constant<size_t, sizeof(T)> {};
template <typename T>
constexpr inline auto size_of_v {sizeof(T)};
template <typename T>
struct alignment_of : constant<size_t, alignof(T)> {};
template <typename T>
constexpr inline auto alignment_of_v {alignof(T)};
template <typename T>
struct rank : constant<size_t, 0> {};
template <typename T>
constexpr inline auto rank_v {rank<T>::value};
template <typename T>
struct rank<T []> : constant<size_t, rank_v<T> + 1> {};
template <typename T, size_t N>
struct rank<T [N]> : constant<size_t, rank_v<T> + 1> {};
template <typename T, size_t = 0>
struct extent : constant<size_t, 0> {};
template <typename T>
struct extent<T [], 0> : constant<size_t, 0> {};
template <typename T, size_t N>
struct extent<T [], N> : extent<T, N - 1> {};
template <typename T, size_t Size>
struct extent<T [Size], 0> : constant<size_t, Size> {};
template <typename T, size_t Size, size_t N>
struct extent<T [Size], N> : extent<T, N - 1> {};
template <typename T, size_t N>
constexpr inline auto extent_v {extent<T, N>::value};
template <typename T>
struct decay {
using type = conditional_t<is_array_v<remove_reference_t<T>>,
add_pointer_t<remove_extent_t<remove_reference_t<T>>>,
conditional_t<is_function_v<remove_reference_t<T>>, add_pointer_t<remove_reference_t<T>>,
remove_cv_t<remove_reference_t<T>>>>;
};
template <typename T>
using decay_t = typename decay<T>::type;
template <typename T>
struct underlying_type {
using type = __underlying_type(T);
};
template <typename T>
using underlying_type_t = typename underlying_type<T>::type;
template <typename ...>
struct common_type {};
template <typename ...Ts>
using common_type_t = typename common_type<Ts...>::type;
template <typename T>
struct common_type<T> {
using type = common_type_t<T, T>;
};
template <typename T, typename U>
struct common_type<T, U> {
using type = decltype(make_true<T, U> ? declval<decay_t<T>>() : declval<decay_t<U>>());
};
template <typename T, typename U, typename V, typename ...Ts>
struct common_type<T, U, V, Ts...> : common_type<common_type_t<T, U>, V, Ts...> {};
template <typename ...>
struct common_reference {};
template <typename ...Ts>
using common_reference_t = typename common_reference<Ts...>::type;
template <typename T>
struct common_reference<T> {
using type = T;
};
template <typename T, typename U>
struct common_reference<T, U> : __dsa::common_reference_auxiliary<T, U> {};
template <typename T, typename U, typename ...Ts>
struct common_reference<T, U, Ts...> : common_reference<common_reference_t<T, U>, Ts...> {};
template <typename T>
struct make_signed {
using type = copy_cv_t<T, typename __dsa::make_signed_or_unsigned_auxiliary<remove_cv_t<T>,
signed char, typename __dsa::signed_integral::remaining>::type>;
};
template <typename T>
using make_signed_t = typename make_signed<T>::type;
template <typename T>
struct make_unsigned {
using type = copy_cv_t<T, typename __dsa::make_signed_or_unsigned_auxiliary<remove_cv_t<T>,
unsigned char, typename __dsa::unsigned_integral::remaining>::type>;
};
template <typename T>
using make_unsigned_t = typename make_unsigned<T>::type;
template <typename T>
struct integral_promotion {
using type = copy_cv_t<T, typename __dsa::integral_promotion_auxiliary<remove_cv_t<T>>::type>;
};
template <typename T>
using integral_promotion_t = typename integral_promotion<T>::type;
template <typename T>
struct floating_point_promotion {
using type = copy_cv_t<T, typename __dsa::floating_point_promotion_auxiliary<remove_cv_t<T>>::type>;
};
template <typename T>
using floating_point_promotion_t = typename floating_point_promotion<T>::type;
template <typename T>
struct character_promotion {
using type = copy_cv_t<T, typename __dsa::character_promotion_auxiliary<remove_cv_t<T>>::type>;
};
template <typename T>
using character_promotion_t = typename character_promotion<T>::type;
template <typename T>
struct arithmetic_promotion : __dsa::arithmetic_promotion_auxiliary<T> {};
template <typename T>
using arithmetic_promotion_t = typename arithmetic_promotion<T>::type;
template <typename ...>
struct class_template_traits;
template <template <typename ...> typename T, typename ...Args>
struct class_template_traits<T<Args...>> {
using type = T<Args...>;
template <typename ...Ts>
using rebind = T<Ts...>;
using arguments = type_container<Args...>;
};
template <typename Ptr, typename ...Args>
struct invoke_result : __dsa::result_of_auxiliary<is_member_object_pointer_v<remove_reference_t<Ptr>>,
is_member_function_pointer_v<remove_reference_t<Ptr>>, Ptr, Args...> {
static_assert(is_complete_v<Ptr>, "The first template argument must be a complete type!");
};
template <typename Ptr, typename ...Args>
using invoke_result_t = typename invoke_result<Ptr, Args...>::type;
template <typename ...>
struct result_of;
template <typename F, typename ...Args>
struct result_of<F (Args...)> : invoke_result<F, Args...> {};
template <typename F, typename ...Args>
using result_of_t = typename result_of<F, Args...>::type;
template <size_t Length, size_t Align =
__dsa::aligned_storage_find_max_align<__dsa::aligned_storage_helper_types, Length>::value>
struct aligned_storage {
private:
using aligner = typename __dsa::aligned_storage_find_suitable_type<
__dsa::aligned_storage_helper_types, Align>::type;
public:
union type {
aligner align;
unsigned char data[(Length + Align - 1) / Align * Align];
};
};
template <size_t Length, size_t Align =
__dsa::aligned_storage_find_max_align<__dsa::aligned_storage_helper_types, Length>::value>
using aligned_storage_t = typename aligned_storage<Length, Align>::type;
template <size_t Length, typename ...Ts>
struct aligned_union {
struct type {
alignas(__dsa::aligned_union_find_max_align<Ts...>::value)
char data[__dsa::aligned_union_find_max_number<Length, sizeof...(Ts)>::value];
};
};
template <size_t Length, typename ...Ts>
using aligned_union_t = typename aligned_union<Length, Ts...>::type;
template <size_t Align>
struct type_with_alignment :
__dsa::type_with_alignment_find_suitable_type<__dsa::type_with_alignment_helper_types, Align> {};
template <size_t Align>
using type_with_alignment_t = typename type_with_alignment<Align>::type;
}
__DATA_STRUCTURE_END
__DATA_STRUCTURE_START(undefine useless macros)
#undef __DATA_STRUCTURE_TEST_ADDITION
#undef __DATA_STRUCTURE_REMOVE_CV_HELPER_MAIN
#undef __DATA_STRUCTURE_REMOVE_CV_HELPER_SPECIALIZATION
#undef __DATA_STRUCTURE_TEST_OPERATION
#undef __DATA_STRUCTURE_HAS_NESTED_TYPE_IMPL
#undef __DATA_STRUCTURE_TEST_OPERATION_NOTHROW
__DATA_STRUCTURE_END
#endif //DATA_STRUCTURE_TYPE_TRAITS_HPP
|
6c9dde8a666a8cd63e33b34209d1e71f5846a581 | dc88fb5279972c9873681adea258e7c8f5f1ebac | /test/atmega328p/expected_pins.cpp | 7b0b1c42fc1e82cb8121f5a0003811a215515f9d | [
"MIT"
] | permissive | ricardocosme/avrIO | 9cb4e57991d97a66c7bef1f0bd21fe5d6c498522 | b60238b48d1283324f8f73e530d582432c6c5f71 | refs/heads/main | 2023-04-08T18:46:32.099199 | 2021-04-13T17:32:33 | 2021-04-13T17:32:33 | 334,336,350 | 12 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,628 | cpp | expected_pins.cpp | #include "../expected_io.hpp"
void ctor() {
ctor_impl<PB0, PB1, PB2, PB3, PB4, PB5, PB6, PB7>(DDRB);
ctor_impl<PC0, PC1, PC2, PC3, PC4, PC5, PC6>(DDRC);
ctor_impl<PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7>(DDRD);
}
void functions() {
functions_impl<PB0, PB1, PB2, PB3, PB4, PB5>(PINB, DDRB);
functions_impl<PC0, PC1, PC2, PC3, PC4, PC5, PC6>(PINC, DDRC);
functions_impl<PD0, PD1, PD2, PD3, PD4, PD5, PD6>(PIND, DDRD);
//out(pb0, pb1);
DDRB |= (1<<PB0);
DDRB |= (1<<PB1);
//out(pb0, pb1, pb3);
DDRB |= (1<<PB0) | (1<<PB1) | (1<<PB3);
//out(pb0, pb1, pb2, pb3, pb4, pb5);
DDRB |= (1<<PB0) | (1<<PB1) | (1<<PB2) | (1<<PB3) | (1<<PB4) | (1<<PB5);
//out(pc0, pc1);
DDRC |= (1<<PC0);
DDRC |= (1<<PC1);
//out(pc0, pc1, pc3);
DDRC |= (1<<PC0) | (1<<PC1) | (1<<PC3);
//out(pc0, pc1, pc2, pc3, pc4, pc5);
DDRC |= (1<<PC0) | (1<<PC1) | (1<<PC2) | (1<<PC3) | (1<<PC4) | (1<<PC5) | (1<<PC6);
//out(pc0, pc1);
DDRD |= (1<<PD0);
DDRD |= (1<<PD1);
//out(pd0, pd1, pd3);
DDRD |= (1<<PD0) | (1<<PD1) | (1<<PD3);
//out(pd0, pd1, pd2, pd3, pd4, pd5);
DDRD |= (1<<PD0) | (1<<PD1) | (1<<PD2) | (1<<PD3) | (1<<PD4) | (1<<PD5) | (1<<PD6);
//in(pb0, pb1);
DDRB &= ~(1<<PB0);
DDRB &= ~(1<<PB1);
//in(pb0, pb1, pb3);
DDRB &= ~((1<<PB0) | (1<<PB1) | (1<<PB3));
//in(pb0, pb1, pb2, pb3, pb4, pb5);
DDRB &= ~((1<<PB0) | (1<<PB1) | (1<<PB2) | (1<<PB3) | (1<<PB4) | (1<<PB5));
//in(pc0, pc1);
DDRC &= ~(1<<PC0);
DDRC &= ~(1<<PC1);
//in(pc0, pc1, pc3);
DDRC &= ~((1<<PC0) | (1<<PC1) | (1<<PC3));
//in(pc0, pc1, pc2, pc3, pc4, pc5);
DDRC &= ~((1<<PC0) | (1<<PC1) | (1<<PC2) | (1<<PC3) | (1<<PC4) | (1<<PC5) | (1<<PC6));
//in(pc0, pc1);
DDRD &= ~(1<<PD0);
DDRD &= ~(1<<PD1);
//in(pd0, pd1, pd3);
DDRD &= ~((1<<PD0) | (1<<PD1) | (1<<PD3));
//in(pd0, pd1, pd2, pd3, pd4, pd5);
DDRD &= ~((1<<PD0) | (1<<PD1) | (1<<PD2) | (1<<PD3) | (1<<PD4) | (1<<PD5) | (1<<PD6));
//in(pullup, pb0, pb1);
DDRB &= ~(1<<PB0);
DDRB &= ~(1<<PB1);
PORTB |= (1<<PB0);
PORTB |= (1<<PB1);
//in(pullup, pb0, pb1, pb3);
DDRB &= ~((1<<PB0) | (1<<PB1) | (1<<PB3));
PORTB |= (1<<PB0) | (1<<PB1) | (1<<PB3);
//in(pullup, pb0, pb1, pb2, pb3, pb4, pb5);
DDRB &= ~((1<<PB0) | (1<<PB1) | (1<<PB2) | (1<<PB3) | (1<<PB4) | (1<<PB5));
PORTB |= (1<<PB0) | (1<<PB1) | (1<<PB2) | (1<<PB3) | (1<<PB4) | (1<<PB5);
//in(pullup, pc0, pc1);
DDRC &= ~(1<<PC0);
DDRC &= ~(1<<PC1);
PORTC |= (1<<PC0);
PORTC |= (1<<PC1);
//in(pullup, pc0, pc1, pc3);
DDRC &= ~((1<<PC0) | (1<<PC1) | (1<<PC3));
PORTC |= (1<<PC0) | (1<<PC1) | (1<<PC3);
//in(pullup, pc0, pc1, pc2, pc3, pc4, pc5);
DDRC &= ~((1<<PC0) | (1<<PC1) | (1<<PC2) | (1<<PC3) | (1<<PC4) | (1<<PC5) | (1<<PC6));
PORTC |= (1<<PC0) | (1<<PC1) | (1<<PC2) | (1<<PC3) | (1<<PC4) | (1<<PC5) | (1<<PC6);
//in(pullup, pd0, pd1);
DDRD &= ~(1<<PD0);
DDRD &= ~(1<<PD1);
PORTD |= (1<<PD0);
PORTD |= (1<<PD1);
//in(pullup, pd0, pd1, pd3);
DDRD &= ~((1<<PD0) | (1<<PD1) | (1<<PD3));
PORTD |= (1<<PD0) | (1<<PD1) | (1<<PD3);
//in(pullup, pd0, pd1, pd2, pd3, pd4, pd5);
DDRD &= ~((1<<PD0) | (1<<PD1) | (1<<PD2) | (1<<PD3) | (1<<PD4) | (1<<PD5) | (1<<PD6));
PORTD |= (1<<PD0) | (1<<PD1) | (1<<PD2) | (1<<PD3) | (1<<PD4) | (1<<PD5) | (1<<PD6);
//set(pb0, pb1);
PORTB |= (1<<PB0);
PORTB |= (1<<PB1);
//set(pb0, pb1, pb3);
PORTB |= (1<<PB0) | (1<<PB1) | (1<<PB3);
//set(pb0, pb1, pb2, pb3, pb4, pb5);
PORTB |= (1<<PB0) | (1<<PB1) | (1<<PB2) | (1<<PB3) | (1<<PB4) | (1<<PB5);
//set(pc0, pc1);
PORTC |= (1<<PC0);
PORTC |= (1<<PC1);
//set(pc0, pc1, pc3);
PORTC |= (1<<PC0) | (1<<PC1) | (1<<PC3);
//set(pc0, pc1, pc2, pc3, pc4, pc5);
PORTC |= (1<<PC0) | (1<<PC1) | (1<<PC2) | (1<<PC3) | (1<<PC4) | (1<<PC5) | (1<<PC6);
//set(pd0, pd1);
PORTD |= (1<<PD0);
PORTD |= (1<<PD1);
//set(pd0, pd1, pd3);
PORTD |= (1<<PD0) | (1<<PD1) | (1<<PD3);
//set(pd0, pd1, pd2, pd3, pd4, pd5);
PORTD |= (1<<PD0) | (1<<PD1) | (1<<PD2) | (1<<PD3) | (1<<PD4) | (1<<PD5) | (1<<PD6);
//set(pb0(pb2.is_high()));
if(PINB & (1<<PB2)) PORTB |= (1<<PB0);
else PORTB &= ~(1<<PB0);
}
// set(pb0(lazy::is_high(pb2)), pb1(lazy::is_high(pb3)),);
void set_two_pins() {
uint8_t mask;
asm volatile("ldi %0,0x00" :"=r"(mask)::);
if(PINB & (1<<PB2)) mask |= (1<<PB0);
if(PINB & (1<<PB3)) mask |= (1<<PB1);
PORTB = (PORTB & 0xfc) | mask;
}
|
663e0c451f67d9184a1ed0ae51f353527819c974 | 1501f50acc22b9e915d04df435210d68e2a907ee | /include/HoudiniEngineUnity/TOPNodeTags.hpp | 397b4acfea1000f7801f1262291fe12a45b33d01 | [
"LicenseRef-scancode-unknown",
"Unlicense"
] | permissive | sc2ad/BeatSaber-Quest-Codegen | cd944128d6c7b61f2014f13313d2d6cf424df811 | 4bfd0c0f705e7a302afe6ec1ef996b5b2e3f4600 | refs/heads/master | 2023-03-11T11:07:22.074423 | 2023-02-28T22:15:16 | 2023-02-28T22:15:16 | 285,669,750 | 31 | 25 | Unlicense | 2023-02-28T22:15:18 | 2020-08-06T20:56:01 | C++ | UTF-8 | C++ | false | false | 2,691 | hpp | TOPNodeTags.hpp | // Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
#include "beatsaber-hook/shared/utils/byref.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Type namespace: HoudiniEngineUnity
namespace HoudiniEngineUnity {
// Forward declaring type: TOPNodeTags
class TOPNodeTags;
}
#include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp"
NEED_NO_BOX(::HoudiniEngineUnity::TOPNodeTags);
DEFINE_IL2CPP_ARG_TYPE(::HoudiniEngineUnity::TOPNodeTags*, "HoudiniEngineUnity", "TOPNodeTags");
// Type namespace: HoudiniEngineUnity
namespace HoudiniEngineUnity {
// Size: 0x12
#pragma pack(push, 1)
// Autogenerated type: HoudiniEngineUnity.TOPNodeTags
// [TokenAttribute] Offset: FFFFFFFF
class TOPNodeTags : public ::Il2CppObject {
public:
public:
// public System.Boolean _show
// Size: 0x1
// Offset: 0x10
bool show;
// Field size check
static_assert(sizeof(bool) == 0x1);
// public System.Boolean _autoload
// Size: 0x1
// Offset: 0x11
bool autoload;
// Field size check
static_assert(sizeof(bool) == 0x1);
public:
// Get instance field reference: public System.Boolean _show
[[deprecated("Use field access instead!")]] bool& dyn__show();
// Get instance field reference: public System.Boolean _autoload
[[deprecated("Use field access instead!")]] bool& dyn__autoload();
// public System.Void .ctor()
// Offset: 0x1A73DD4
template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary>
static TOPNodeTags* New_ctor() {
static auto ___internal__logger = ::Logger::get().WithContext("::HoudiniEngineUnity::TOPNodeTags::.ctor");
return THROW_UNLESS((::il2cpp_utils::New<TOPNodeTags*, creationType>()));
}
}; // HoudiniEngineUnity.TOPNodeTags
#pragma pack(pop)
static check_size<sizeof(TOPNodeTags), 17 + sizeof(bool)> __HoudiniEngineUnity_TOPNodeTagsSizeCheck;
static_assert(sizeof(TOPNodeTags) == 0x12);
}
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
// Writing MetadataGetter for method: HoudiniEngineUnity::TOPNodeTags::New_ctor
// Il2CppName: .ctor
// Cannot get method pointer of value based method overload from template for constructor!
// Try using FindMethod instead!
|
acb719e5f06ea1e8ace03db7afe1877cd229c45b | 6d7bfc09df3f4336312537fc3393926c366f5773 | /meta-tizen-common-base/recipes-application-framework/update-desktop-files/update-desktop-files-extraconf.inc | f8fb04f603f4b09ee8b7ff6e704a956d1dbb31c2 | [
"MIT"
] | permissive | rzr/meta-tizen | 535553d1bf2edcf8bfc212f2eac5ce71c476f39a | db6ab944d71077a02fb4b504bed4dc6f1cc7794c | refs/heads/master | 2021-01-17T10:26:41.401120 | 2015-01-23T14:08:40 | 2015-01-26T10:47:03 | 48,059,548 | 0 | 0 | MIT | 2019-08-07T22:02:10 | 2015-12-15T17:50:56 | PHP | UTF-8 | C++ | false | false | 83 | inc | update-desktop-files-extraconf.inc | FILES_brp-trim-desktopfiles += "/usr/lib/rpm/brp-tizen.d/brp-70-trim-desktopfiles"
|
c54d65b769a8bc88b9e55995f5c39943c59cc4d6 | a818c3d2176c485c48e3c8976f3bcbd1be628f47 | /CargoLoading/PalleteModel.cpp | e09b1a1c696a2773ad76c8538117b21970cbaee1 | [] | no_license | alikh31/CargoLoading | d382f6754482c2587b744b5f309ea6137435c456 | 01cac79b3aefe24da0631786cbbb9e555f8a914e | refs/heads/master | 2021-01-20T02:11:54.891233 | 2014-09-22T13:28:17 | 2014-09-22T13:28:17 | 23,918,340 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,245 | cpp | PalleteModel.cpp | #include "PalleteModel.h"
#include "GUIMainWindow.h"
CPalleteModel::CPalleteModel(CGUIMainWindow* pMainWindow)
: QAbstractTableModel()
{
m_pMainWindow=pMainWindow;
}
CPalleteModel::~CPalleteModel()
{
}
int CPalleteModel::rowCount(const QModelIndex & ) const
{
if(!m_pMainWindow || !m_pMainWindow->m_pProject)
return 0;
int count=m_pMainWindow->m_pProject->m_PalleteList.count();
return count;
}
int CPalleteModel::columnCount(const QModelIndex & ) const
{
return m_pMainWindow->m_pProject->m_PalleteList.count()+2;
}
void CPalleteModel::RefreshList()
{
endResetModel();
}
QVariant CPalleteModel::data(const QModelIndex &index, int role) const
{
if(!index.isValid()) return QVariant();
if (role == Qt::BackgroundColorRole)
{
//return (QVariant) ( QColor( Qt::yellow ) );
}
if(role==Qt::SizeHintRole)
{
int test=10;
}
if (role == Qt::FontRole)
{
if(index.column() == 0) {
QFont font;
font.setBold(false);
return font;
}
}
if (role == Qt::TextAlignmentRole)
{
if(index.column() == 0)
{
return (QVariant) ( Qt::AlignRight | Qt::AlignVCenter );
} else {
return (QVariant)
(
Qt::AlignHCenter );
}
}
if(!m_pMainWindow || !m_pMainWindow->m_pProject)
return 0;
if (role == Qt::DisplayRole || role == Qt::EditRole)
{
int col=index.column();
int row=index.row();
if(row<0 || row>=m_pMainWindow->m_pProject->m_PalleteList.count())
return QVariant();
__Pallete* rowData=m_pMainWindow->m_pProject->m_PalleteList.at(row);
QString tmp;
switch(col)
{
case 0:
return rowData->id;
case 1:
return rowData->name;
}
return rowData->bIsPutOver[col-2];
}
return QVariant();
}
bool CPalleteModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if(!m_pMainWindow || !m_pMainWindow->m_pProject)
return 0;
if (index.isValid() && role == Qt::EditRole)
{
// we have index.row() index.column() and value
// all we need
int col=index.column();
int row=index.row();
if(row<0 || row>=m_pMainWindow->m_pProject->m_PalleteList.count())
return false;
__Pallete* rowData=m_pMainWindow->m_pProject->m_PalleteList.at(row);
if(col==0)
{
int id=value.toInt();
rowData->id=id;
}
else if(col==1)
{
QString name=value.toString();
rowData->name=name;
}
else
{
bool bOk;
bOk=value.toBool();
rowData->bIsPutOver[col-2]=bOk;
}
emit dataChanged(index, index);
return true;
}
return false;
}
Qt::ItemFlags CPalleteModel::flags(const QModelIndex &index) const
{
if (!index.isValid()) return Qt::ItemIsEnabled;
int col=index.column();
int row=index.row();
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
}
QVariant CPalleteModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole) return QVariant();
if (orientation == Qt::Horizontal)
{
switch(section)
{
case 0:
return QString("Code");//"Code"
case 1:
return QString("Name");//"Name"
}
__Pallete* rowData=m_pMainWindow->m_pProject->m_PalleteList.at(section-2);
QString tmp;
tmp=QString("On(%1)").arg(rowData->name);
return tmp;
}
else
{
QString headerName=QString("%1").arg(section);
return headerName;
}
return "";
}
|
49986bfadb93ab2c2c02d0274a81865d566e2c30 | f81124e4a52878ceeb3e4b85afca44431ce68af2 | /re20_2/processor54/35/p | 1deef008494fc4b6f4788285917e9cdb71db6b2a | [] | no_license | chaseguy15/coe-of2 | 7f47a72987638e60fd7491ee1310ee6a153a5c10 | dc09e8d5f172489eaa32610e08e1ee7fc665068c | refs/heads/master | 2023-03-29T16:59:14.421456 | 2021-04-06T23:26:52 | 2021-04-06T23:26:52 | 355,040,336 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 8,922 | p | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "35";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
392
(
-0.0076672
-0.00727718
-0.0068966
-0.00767074
-0.00728058
-0.00689987
-0.00767782
-0.00728737
-0.0069064
-0.00768843
-0.00729756
-0.00691618
-0.00770256
-0.00731114
-0.00692921
-0.00772021
-0.00732808
-0.00694548
-0.00774134
-0.00734838
-0.00696496
-0.00776595
-0.00737201
-0.00698766
-0.00779402
-0.00739896
-0.00701353
-0.0078255
-0.0074292
-0.00704256
-0.00786039
-0.0074627
-0.00707473
-0.00789863
-0.00749943
-0.00711
-0.0079402
-0.00753935
-0.00714834
-0.00798505
-0.00758243
-0.00718971
-0.00803315
-0.00762863
-0.00723407
-0.00808443
-0.00767789
-0.00728138
-0.00813886
-0.00773017
-0.0073316
-0.00819639
-0.00778544
-0.00738469
-0.00825694
-0.00784362
-0.00744058
-0.00832025
-0.00790446
-0.00749903
-0.0083862
-0.00796785
-0.00755995
-0.0084566
-0.0080355
-0.00762496
-0.00853468
-0.0081104
-0.0076968
-0.00860677
-0.00817954
-0.00776311
-0.00735707
-0.00824734
-0.00782961
-0.00742231
-0.0084224
-0.00799924
-0.00758664
-0.00860425
-0.00817566
-0.00775776
-0.00879751
-0.00836323
-0.00793977
-0.00900566
-0.00856523
-0.00813575
-0.00922731
-0.00878033
-0.00834442
-0.00946098
-0.00900709
-0.0085644
-0.00970529
-0.00924419
-0.00879442
-0.00995868
-0.00949011
-0.00903299
-0.0102194
-0.00974318
-0.0092785
-0.0104857
-0.0100016
-0.00952924
-0.0107556
-0.0102637
-0.00978349
-0.0110273
-0.0105275
-0.0100395
-0.0112991
-0.0107914
-0.0102956
-0.0115691
-0.0110537
-0.0105502
-0.0118359
-0.0113129
-0.0108018
-0.0120979
-0.0115675
-0.0110489
-0.0123539
-0.0118162
-0.0112905
-0.0126026
-0.012058
-0.0115252
-0.012843
-0.0122918
-0.0117523
-0.0130744
-0.0125167
-0.0119708
-0.0132959
-0.0127322
-0.0121802
-0.013507
-0.0129376
-0.0123797
-0.0137072
-0.0131324
-0.012569
-0.0138962
-0.0133162
-0.0127477
-0.0140736
-0.0134889
-0.0129156
-0.0142393
-0.0136502
-0.0130724
-0.0143932
-0.0138
-0.013218
-0.0145351
-0.0139382
-0.0133524
-0.014665
-0.0140647
-0.0134754
-0.0147829
-0.0141795
-0.0135871
-0.0148888
-0.0142827
-0.0136874
-0.0149828
-0.0143743
-0.0137765
-0.015065
-0.0144542
-0.0138543
-0.0151352
-0.0145227
-0.0139208
-0.0151937
-0.0145796
-0.0139762
-0.0152404
-0.0146251
-0.0140205
-0.0152754
-0.0146592
-0.0140537
-0.0152987
-0.014682
-0.0140758
-0.0153103
-0.0146933
-0.0140868
-0.0104391
-0.0107076
-0.0109817
-0.0112596
-0.0115393
-0.0118189
-0.0120968
-0.0123712
-0.0126406
-0.0129037
-0.0131594
-0.0134064
-0.0136441
-0.0138716
-0.0140884
-0.0142939
-0.0144879
-0.01467
-0.01484
-0.0149978
-0.0151433
-0.0152766
-0.0153975
-0.0155061
-0.0156025
-0.0156867
-0.0157587
-0.0158186
-0.0158665
-0.0159023
-0.0159262
-0.0159381
-0.00824733
-0.00842239
-0.00860423
-0.00879749
-0.00900565
-0.00922729
-0.00946096
-0.00970527
-0.00995866
-0.0102194
-0.0104856
-0.0107556
-0.0110273
-0.0112991
-0.0115691
-0.0118359
-0.0120979
-0.0123539
-0.0126026
-0.012843
-0.0130744
-0.0132959
-0.013507
-0.0137072
-0.0138962
-0.0140736
-0.0142393
-0.0143932
-0.014535
-0.014665
-0.0147829
-0.0148888
-0.0149828
-0.0150649
-0.0151352
-0.0151937
-0.0152404
-0.0152754
-0.0152987
-0.0153103
-0.00782959
-0.00799922
-0.00817564
-0.00836321
-0.00856521
-0.0087803
-0.00900707
-0.00924417
-0.00949009
-0.00974316
-0.0100016
-0.0102636
-0.0105275
-0.0107914
-0.0110537
-0.0113129
-0.0115675
-0.0118162
-0.012058
-0.0122917
-0.0125167
-0.0127322
-0.0129375
-0.0131323
-0.0133162
-0.0134889
-0.0136502
-0.0138
-0.0139382
-0.0140647
-0.0141795
-0.0142827
-0.0143743
-0.0144542
-0.0145227
-0.0145796
-0.0146251
-0.0146592
-0.014682
-0.0146933
-0.00742229
-0.00758662
-0.00775774
-0.00793974
-0.00813573
-0.00834439
-0.00856438
-0.00879439
-0.00903296
-0.00927847
-0.00952922
-0.00978347
-0.0100395
-0.0102956
-0.0105502
-0.00860676
-0.00817953
-0.0077631
-0.00853467
-0.00811039
-0.00769679
-0.00845659
-0.00803549
-0.00762495
-0.0083862
-0.00796784
-0.00755994
-0.00832024
-0.00790445
-0.00749902
-0.00825693
-0.00784361
-0.00744056
-0.00819638
-0.00778543
-0.00738468
-0.00813885
-0.00773016
-0.00733159
-0.00808442
-0.00767788
-0.00728137
-0.00803314
-0.00762862
-0.00723406
-0.00798505
-0.00758242
-0.0071897
-0.00794019
-0.00753934
-0.00714833
-0.00789862
-0.00749942
-0.00710999
-0.00786038
-0.00746269
-0.00707472
-0.0078255
-0.00742919
-0.00704256
-0.00779401
-0.00739895
-0.00701352
-0.00776595
-0.00737201
-0.00698765
-0.00774134
-0.00734837
-0.00696496
-0.0077202
-0.00732808
-0.00694547
-0.00770256
-0.00731113
-0.00692921
-0.00768843
-0.00729756
-0.00691618
-0.00767782
-0.00728737
-0.00690639
-0.00767074
-0.00728057
-0.00689987
-0.0076672
-0.00727717
-0.0068966
)
;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value nonuniform 0();
}
cylinder
{
type zeroGradient;
}
top
{
type symmetryPlane;
}
bottom
{
type symmetryPlane;
}
defaultFaces
{
type empty;
}
procBoundary54to53
{
type processor;
value nonuniform List<scalar>
131
(
-0.00806704
-0.00807072
-0.0080781
-0.00808914
-0.00810386
-0.00812223
-0.00814424
-0.00816986
-0.00819907
-0.00823186
-0.00826817
-0.00830798
-0.00835126
-0.00839795
-0.00844801
-0.00850139
-0.00855804
-0.00861791
-0.00868093
-0.00874681
-0.00881542
-0.00888866
-0.00897005
-0.0090452
-0.00867589
-0.00867589
-0.00885652
-0.00904392
-0.009243
-0.00945743
-0.00968576
-0.00992646
-0.0101781
-0.0104391
-0.0107076
-0.0109817
-0.0112596
-0.0115393
-0.0118189
-0.0120968
-0.0123712
-0.0126406
-0.0129037
-0.0131594
-0.0134065
-0.0136441
-0.0138716
-0.0140884
-0.014294
-0.0144879
-0.01467
-0.01484
-0.0149978
-0.0151434
-0.0152766
-0.0153975
-0.0155061
-0.0156025
-0.0156867
-0.0157587
-0.0158186
-0.0158665
-0.0159023
-0.0159262
-0.0159382
-0.0109317
-0.0112081
-0.0114902
-0.0117761
-0.0120638
-0.0123514
-0.0126371
-0.0129191
-0.0131959
-0.0134662
-0.0137287
-0.0139824
-0.0142263
-0.0144597
-0.0146821
-0.0148929
-0.0150917
-0.0152783
-0.0154526
-0.0156143
-0.0157633
-0.0158998
-0.0160236
-0.0161348
-0.0162335
-0.0163197
-0.0163934
-0.0164547
-0.0165037
-0.0165404
-0.0165649
-0.0165771
-0.00867588
-0.00867588
-0.00885651
-0.00904391
-0.00924299
-0.00945742
-0.00968575
-0.00992645
-0.0101781
-0.0101781
-0.0090452
-0.00897004
-0.00888866
-0.00881541
-0.00874681
-0.00868093
-0.00861791
-0.00855803
-0.00850139
-0.00844801
-0.00839795
-0.00835125
-0.00830798
-0.00826817
-0.00823185
-0.00819907
-0.00816986
-0.00814423
-0.00812223
-0.00810386
-0.00808914
-0.00807809
-0.00807072
-0.00806704
)
;
}
procBoundary54to55
{
type processor;
value nonuniform List<scalar>
131
(
-0.00652514
-0.00652827
-0.00653453
-0.00654392
-0.00655643
-0.00657205
-0.00659075
-0.00661253
-0.00663737
-0.00666524
-0.00669612
-0.00672998
-0.00676679
-0.00680651
-0.0068491
-0.00689454
-0.00694276
-0.00699375
-0.00704743
-0.00710358
-0.00716213
-0.00722458
-0.00729348
-0.00729348
-0.00696106
-0.00702505
-0.00718423
-0.00735018
-0.00752675
-0.00771684
-0.00791922
-0.00813256
-0.00835561
-0.00858695
-0.008825
-0.00906814
-0.00931468
-0.00956294
-0.00981131
-0.0100582
-0.0103022
-0.010542
-0.0107762
-0.011004
-0.0112243
-0.0114364
-0.0116395
-0.0118331
-0.0120169
-0.0121904
-0.0123533
-0.0125055
-0.0126469
-0.0127773
-0.0128968
-0.0130052
-0.0131027
-0.0131891
-0.0132647
-0.0133294
-0.0133832
-0.0134261
-0.0134583
-0.0134798
-0.0134905
-0.0108018
-0.0110489
-0.0112904
-0.0115252
-0.0117523
-0.0119708
-0.0121801
-0.0123797
-0.012569
-0.0127477
-0.0129156
-0.0130724
-0.013218
-0.0133523
-0.0134754
-0.013587
-0.0136874
-0.0137765
-0.0138543
-0.0139208
-0.0139762
-0.0140205
-0.0140537
-0.0140758
-0.0140868
-0.00702503
-0.00735706
-0.0071842
-0.00735015
-0.00752672
-0.00771682
-0.00791919
-0.00813253
-0.00835558
-0.00858692
-0.00882498
-0.00906811
-0.00931465
-0.00956292
-0.00981128
-0.0108018
-0.0100582
-0.00735706
-0.00729346
-0.00722456
-0.00716211
-0.00710356
-0.00704741
-0.00699374
-0.00694275
-0.00689452
-0.00684909
-0.0068065
-0.00676677
-0.00672997
-0.00669611
-0.00666523
-0.00663736
-0.00661253
-0.00659075
-0.00657204
-0.00655643
-0.00654392
-0.00653453
-0.00652827
-0.00652514
)
;
}
}
// ************************************************************************* //
| |
abaff1bd1badde715de9fe677672fc77847cc135 | 2e7a16af778505e22e3227b0d5cc5e77b72dc58f | /codeforces/1396/A.cpp | dfa910f92552f030696d1b0f385f1906f8025cb8 | [] | no_license | sohardforaname/ACM_ICPC_practice | e0c2d32787f7872bc47dc9f7e9d7676ed48f3342 | d9defa11f1ab3c6d73c7ff7653cf5a0fed6a60b6 | refs/heads/master | 2022-04-30T11:15:07.317974 | 2022-03-19T08:39:59 | 2022-03-19T08:39:59 | 251,541,235 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 589 | cpp | A.cpp | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
typedef long long ll;
ll a[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%lld", &a[i]);
if (n == 1)
return printf("1 1\n0\n 1 1\n0\n 1 1\n%lld\n", -a[1]), 0;
printf("1 1\n%lld\n", -a[1]);
printf("1 %d\n0 ", n);
for (int i = 2; i <= n; ++i)
printf("%lld%c", -n * a[i], " \n"[i == n]);
printf("2 %d\n", n);
for (int i = 2; i <= n; ++i)
printf("%lld%c", (n - 1) * a[i], " \n"[i == n]);
return 0;
}
|
9c88ade8fb02b0d33da39e5b7d00eebeb4a2e0ab | 7b86921b259a01855414f453e71ae37143457f16 | /dev/user-dossier/user-dossier-srch.cc | d2d16b576aa37921268779b05d0b3cf5140532d0 | [] | no_license | chlewey/ilecto-util | 5093e15b04bf92eec2788aee176ed3f61bb80b05 | a48afc43fb7a355b49d4f9ec4626a7f6dbb32c6c | refs/heads/master | 2020-05-23T10:17:40.929462 | 2017-02-02T14:42:34 | 2017-02-02T14:42:34 | 80,415,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 31 | cc | user-dossier-srch.cc | #include "user-dossier-srch.h"
|
54c0889b6e3d130b96bf583fbabba489e38fea4e | 614b424a7a45e068fe92dbc5282abeee27f995c4 | /tests/gtest_json.cpp | 85cb6b8db3590ffc90bacefbbcb03f495828cc4d | [
"MIT"
] | permissive | BehaviorTree/BehaviorTree.CPP | b21b34e28bdc7bebbcfd7fc3ac2ef8bc79803c18 | eaa76be985fee01003a0de6f76766249018edded | refs/heads/master | 2023-08-30T23:44:17.414272 | 2023-08-24T12:04:53 | 2023-08-24T12:04:53 | 153,316,914 | 2,301 | 613 | MIT | 2023-09-14T05:56:48 | 2018-10-16T16:19:58 | C++ | UTF-8 | C++ | false | false | 1,667 | cpp | gtest_json.cpp | #include <gtest/gtest.h>
#include "behaviortree_cpp/json_export.h"
//----------- Custom types ----------
struct Vector3D {
double x;
double y;
double z;
};
struct Quaternion3D {
double w;
double x;
double y;
double z;
};
struct Pose3D {
Vector3D pos;
Quaternion3D rot;
};
//----------- JSON specialization ----------
void to_json(nlohmann::json& j, const Vector3D& v)
{
// compact syntax
j = {{"x", v.x}, {"y", v.y}, {"z", v.z}};
}
void to_json(nlohmann::json& j, const Quaternion3D& q)
{
// verbose syntax
j["w"] = q.w;
j["x"] = q.x;
j["y"] = q.y;
j["z"] = q.z;
}
void to_json(nlohmann::json& j, const Pose3D& p)
{
j = {{"pos", p.pos}, {"rot", p.rot}};
}
using namespace BT;
TEST(JsonTest, Exporter)
{
JsonExporter exporter;
Pose3D pose = { {1,2,3},
{4,5,6,7} };
nlohmann::json json;
exporter.toJson(BT::Any(69), json["int"]);
exporter.toJson(BT::Any(3.14), json["real"]);
// expected to throw, because we haven't called addConverter()
ASSERT_FALSE( exporter.toJson(BT::Any(pose), json["pose"]) );
// now it should work
exporter.addConverter<Pose3D>();
exporter.toJson(BT::Any(pose), json["pose"]);
nlohmann::json json_expected;
json_expected["int"] = 69;
json_expected["real"] = 3.14;
json_expected["pose"]["pos"]["x"] = 1;
json_expected["pose"]["pos"]["y"] = 2;
json_expected["pose"]["pos"]["z"] = 3;
json_expected["pose"]["rot"]["w"] = 4;
json_expected["pose"]["rot"]["x"] = 5;
json_expected["pose"]["rot"]["y"] = 6;
json_expected["pose"]["rot"]["z"] = 7;
ASSERT_EQ(json_expected, json);
std::cout << json.dump(2) << std::endl;
}
|
f595c6be1e1c23d80010cbe66e3eb884b92cee6b | 81f04b08896556f13284c003b2f921c008c111f6 | /SRC/controller/management_command.cpp | 2075ca43861a98568755f5b1354ff04db6f40ea2 | [] | no_license | hochlerer/dna-analyzer-design | 890c8f1602a92264cc1205b553dbf9e47a66d462 | 0e3358519ca92bd8a584837ea3200ca643d21ece | refs/heads/master | 2023-01-01T15:41:13.337796 | 2020-09-24T20:25:07 | 2020-09-24T20:25:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 65 | cpp | management_command.cpp | //
// Created by y on 7/8/20.
//
#include "management_command.h" |
d5ab99cd45fa8a034bbbd3160b23c4e4cef3466f | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_2453486_0/C++/koloniss/main.cpp | 2f70edfe91a1d214dff999c7d187fab0693538ad | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 2,292 | cpp | main.cpp | #include <iostream>
#include <string>
using namespace std;
char mas[4][4];
bool xwin,owin,ended;
int main() {
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int T;
cin>>T;
for (int t = 0;t < T;t++)
{
cout<<"Case #"<<t+1<<": ";
ended = true;
for (int i = 0;i<4;i++)
for (int j = 0;j<4;j++)
{
cin>>mas[i][j];
if (mas[i][j]=='.') ended = false;
}
xwin = false;
owin = false;
for (int i = 0;i<4;i++)
{
if (((mas[i][0]=='X') || (mas[i][0]=='T')) && ((mas[i][1]=='X') || (mas[i][1]=='T'))&& ((mas[i][2]=='X') || (mas[i][2]=='T')) && ((mas[i][3]=='X') || (mas[i][3]=='T')))
{
xwin = true;
}
if (((mas[i][0]=='O') || (mas[i][0]=='T')) && ((mas[i][1]=='O') || (mas[i][1]=='T'))&& ((mas[i][2]=='O') || (mas[i][2]=='T')) && ((mas[i][3]=='O') || (mas[i][3]=='T')))
{
owin = true;
}
if (((mas[0][i]=='X') || (mas[0][i]=='T')) && ((mas[1][i]=='X') || (mas[1][i]=='T'))&& ((mas[2][i]=='X') || (mas[2][i]=='T')) && ((mas[3][i]=='X') || (mas[3][i]=='T')))
{
xwin = true;
}
if (((mas[0][i]=='O') || (mas[0][i]=='T')) && ((mas[1][i]=='O') || (mas[1][i]=='T'))&& ((mas[2][i]=='O') || (mas[2][i]=='T')) && ((mas[3][i]=='O') || (mas[3][i]=='T')))
{
owin = true;
}
}
if (((mas[0][0]=='X') || (mas[0][0]=='T')) && ((mas[1][1]=='X') || (mas[1][1]=='T'))&& ((mas[2][2]=='X') || (mas[2][2]=='T')) && ((mas[3][3]=='X') || (mas[3][3]=='T')))
{
xwin = true;
}
if (((mas[0][0]=='O') || (mas[0][0]=='T')) && ((mas[1][1]=='O') || (mas[1][1]=='T'))&& ((mas[2][2]=='O') || (mas[2][2]=='T')) && ((mas[3][3]=='O') || (mas[3][3]=='T')))
{
owin = true;
}
if (((mas[0][3]=='X') || (mas[0][3]=='T')) && ((mas[1][2]=='X') || (mas[1][2]=='T'))&& ((mas[2][1]=='X') || (mas[2][1]=='T')) && ((mas[3][0]=='X') || (mas[3][0]=='T')))
{
xwin = true;
}
if (((mas[0][3]=='O') || (mas[0][3]=='T')) && ((mas[1][2]=='O') || (mas[1][2]=='T'))&& ((mas[2][1]=='O') || (mas[2][1]=='T')) && ((mas[3][0]=='O') || (mas[3][0]=='T')))
{
owin = true;
}
if (xwin) cout<<"X won"<<endl;
else if(owin) cout<<"O won"<<endl;
else if (!ended) cout<<"Game has not completed"<<endl;
else cout<<"Draw"<<endl;
}
return 0;
} |
8a94227f4f532668f94d5519cb0b782bcca4d609 | 8b9e8aeb52bb61513bb295b069cb5502cc25687e | /MiscUtil.h | 967af563f2699aa9c331221aa663208edc9df1b5 | [] | no_license | lfrazer/PapyrusUtil | cecc038ff2bae7390c0037236c8394cb054b0291 | fbd0ad04d48899f158518df83e1bbe14b8095591 | refs/heads/master | 2022-12-12T14:42:23.697992 | 2020-09-20T15:17:09 | 2020-09-20T15:17:09 | 297,849,846 | 1 | 0 | null | 2020-09-23T04:15:41 | 2020-09-23T04:15:40 | null | UTF-8 | C++ | false | false | 663 | h | MiscUtil.h | #pragma once
#include "skse64/GameReferences.h"
#include "skse64/PapyrusVM.h"
struct StaticFunctionTag;
namespace MiscUtil {
void RegisterFuncs(VMClassRegistry* registry);
//void ToggleFreeCamera(StaticFunctionTag* base, bool arg1);
//void SetFreeCameraSpeed(StaticFunctionTag* base, float speed);
//void SetFreeCameraState(StaticFunctionTag* base, bool enable, float speed);
void PrintConsole(StaticFunctionTag* base, BSFixedString text);
//void SetMenus(StaticFunctionTag* base, bool enabled);
BSFixedString GetRaceEditorID(StaticFunctionTag* base, TESRace* RaceRef);
BSFixedString GetActorRaceEditorID(StaticFunctionTag* base, Actor* ActorRef);
}
|
e47460dd5e6fa20db7864963375d37552c382e94 | 3a019bc8436252242b430f3433b45364dc1c80f1 | /C++ Project/TwoInputGate.cpp | 58dbbc6574f76b3f00d855247adf32ee6b11a241 | [] | no_license | hudkinsnoah/Works-Repository | 3812d470cd65a7a29ecdafdb1e849a61cfa68e93 | fb1b8ce2acb710c0f5216714000c8761061dbfc4 | refs/heads/main | 2023-07-19T20:03:31.590720 | 2021-08-26T18:03:43 | 2021-08-26T18:03:43 | 399,323,011 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,333 | cpp | TwoInputGate.cpp | #include <iostream>
using namespace std;
#include "TwoInputGate.h"
TwoInputGate::TwoInputGate(LogicOperation op)
{
input1 = nullptr;
input2 = nullptr;
getType = op;
}
bool TwoInputGate::getOutput() const
{
if(getType == AND)
return input1->getOutput() && input2->getOutput();
else if(getType == OR)
return input1->getOutput() || input2->getOutput();
else
return input1->getOutput() ^ input2->getOutput();
}
void TwoInputGate::setInput1(Component* in1)
{
input1 = in1;
}
void TwoInputGate::setInput2(Component* in2)
{
input2 = in2;
}
void TwoInputGate::prettyPrint(std::string padding) const
{
cout << padding << LOGIC_LABELS[getType] << endl;
input1->Prettyprint(padding + "--");
cout << endl;
input2->Prettyprint(padding + "--");
}
void TwoInputGate::linearPrint() const
{
if(getType == OR)
{
cout << "(";
input1->Linearprint();
cout << " || ";
input2->Linearprint();
cout << ")";
}
else if(getType == AND)
{
cout << "(";
input1->Linearprint();
cout << " && ";
input2->Linearprint();
cout << ")";
}
else
{
cout << "(";
input1->Linearprint();
cout << " ^ ";
input2->Linearprint();
cout << ")";
}
}
|
0061d7a04146693f77230031c9a6920f5de02156 | af1e383a9045ce4afbefafdcafbe6fb881d13343 | /Dev/Codigo/StructureValue.cpp | b9a2a330500d6bfe26a2b10bf534d64113d07b9e | [] | no_license | nicohen/tpdatos2008 | 17941e24a87728f456ac89e623fbf7efc4a26c38 | 7437c437325179f35e6cc04de3de2511023f24ff | refs/heads/master | 2021-03-24T14:07:53.365348 | 2008-12-07T22:09:05 | 2008-12-07T22:09:05 | 34,405,585 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,233 | cpp | StructureValue.cpp | #include "StructureValue.h"
#include "StructureType.h"
#include "IntValue.h"
#include "Data/Record.h"
#include "DataType.h"
using namespace std;
StructureValue::StructureValue()
{
this->_dataValues = new vector<DataValue*>();
}
StructureValue::~StructureValue()
{
this->clear();
delete(this->_dataValues);
}
char StructureValue::getCharType(){
return DataType::STRUCTURED_TYPE;
}
void StructureValue::toString(string* buffer){
DataValue* each;
bool firstValue=true;
vector<DataValue*>::iterator iter;
buffer->append("|");
for(iter = this->_dataValues->begin(); iter != this->_dataValues->end(); iter++) {
each = (DataValue*)*iter;
if(firstValue)
firstValue=false;
else
buffer->append(",");
each->toString(buffer);
}
buffer->append("|");
}
void StructureValue::addValue(DataValue* aType){
this->_dataValues->push_back(aType);
}
void StructureValue::clear(){
vector<DataValue*>::iterator iter;
for (iter = this->_dataValues->begin(); iter != this->_dataValues->end(); iter++ )
{
delete ((DataValue*)*iter);
}
this->_dataValues->clear();
}
int StructureValue::getCount(){
return this->_dataValues->size();
}
bool StructureValue::equalsValueVectors(vector<DataValue*>* vec1,vector<DataValue*>* vec2){
DataValue* each=NULL;
DataValue* eachOther=NULL;
vector<DataValue*>::iterator ownIter;
vector<DataValue*>::iterator otherIter;
if(vec1->size()!=vec2->size()){
//printf("\nFINAL 1 \n");
return false;
}
for (ownIter = vec1->begin(),otherIter = vec2->begin();
ownIter != vec1->end();
ownIter++,otherIter++)
{
each=((DataValue*)*ownIter);
eachOther=((DataValue*)*otherIter);
if(!each->equals(eachOther)){
//printf("\nFINAL 2 \n");
return false;
}
}
//printf("\nFINAL 3 \n");
return true;
}
bool StructureValue::equals(DataValue* other){
StructureValue* otherStructure=NULL;
vector<DataValue*>::iterator ownIter;
vector<DataValue*>::iterator otherIter;
if(DataValue::equals(other)){
otherStructure=(StructureValue*) other;
return equalsValueVectors(this->_dataValues,otherStructure->_dataValues);
}else{
// printf("\nFINAL 4 \n");
return false;
}
}
T_STRING_LENGHT StructureValue::getSerializationSize(){
DataValue* each=NULL;
vector<DataValue*>::iterator iter;
T_RECORD_SIZE size;
size=0;
size+=sizeof(T_RECORD_SIZE);
for (iter = this->_dataValues->begin(); iter != this->_dataValues->end(); iter++ )
{
each=((DataValue*)*iter);
size+=each->getSerializationFullSize()
+1;//le sumo un espacio para guardar el tipo
}
return size;
}
void StructureValue::serializeTo(char* buffer){
DataValue* each=NULL;
vector<DataValue*>::iterator iter;
char* eachSerialization=NULL;
char* currentBufferLocation=NULL;
currentBufferLocation=buffer;
T_RECORD_SIZE valueCount;
valueCount=this->getCount();
//Serializo la cantidad de elementos
memcpy(currentBufferLocation,(char*)&valueCount,sizeof(T_RECORD_SIZE));
currentBufferLocation+=sizeof(T_RECORD_SIZE);
for (iter = this->_dataValues->begin(); iter != this->_dataValues->end(); iter++ )
{
each=((DataValue*)*iter);
//Serializo el tipo del dataValue
*currentBufferLocation=each->getCharType();
currentBufferLocation+=1;
//Serializo el contenido del dataValue
eachSerialization=each->serialize();
memcpy(currentBufferLocation,eachSerialization,each->getSerializationFullSize());
currentBufferLocation+=each->getSerializationFullSize();
free(eachSerialization);
}
}
void StructureValue::deserializeValue(char* data,T_STRING_LENGHT dataLenght){
char* currentDataPointer;
T_RECORD_SIZE valueCount;
T_RECORD_SIZE i;
DataValue* desderializedValue;
DataType* currentValueType;
currentDataPointer=data;
memcpy(&valueCount,currentDataPointer,sizeof(T_RECORD_SIZE));
currentDataPointer+=sizeof(T_RECORD_SIZE);
for (i = 0; i < valueCount; ++i) {
//deserializo el tipo
currentValueType=DataType::createType(*currentDataPointer);
currentDataPointer+=1;
//deserializo el valor
desderializedValue=currentValueType->createNullValue();
currentDataPointer=desderializedValue->deserialize(currentDataPointer);
this->addValue(desderializedValue);
delete currentValueType;
}
}
bool StructureValue::isInstanceOf(DataType* dType){
StructureType* type=NULL;
int valueIndex=0;
int typeIndex=0;
if(dType->getCharType()!=DataType::STRUCTURED_TYPE){
return false;
}
type=(StructureType*) dType;
//Un structureValue sin elementos se considera como nulo de cualquier structureType
if(this->getCount()==0){
return true;
}
if(type->getCount()==0){
return false;
}
for (valueIndex = 0; valueIndex < this->_dataValues->size(); ++valueIndex) {
if(! ((DataValue*)this->_dataValues->at(valueIndex))->isInstanceOf(type->getItem(typeIndex))){
return false;
}
if(++typeIndex>=type->getCount()){
typeIndex=0;
}
}
return true;
}
bool StructureValue::isNull(){
return this->getCount()==0;
}
DataValue* StructureValue::clone(){
StructureValue* result=new StructureValue();
DataValue* each=NULL;
vector<DataValue*>::iterator iter;
for (iter = this->_dataValues->begin(); iter != this->_dataValues->end(); iter++ )
{
each=((DataValue*)*iter);
result->addValue(each->clone());
}
return result;
}
|
c5ff5501b69ee98700ed03fe564acc160f78baf8 | 6398c5babd7b8d3ad24fa743820bccd5f70fa1ed | /source/main_win64gl.cpp | 0ca2705b802f37d31871757c064c9bf7c0034271 | [
"MIT"
] | permissive | Basez/Agnostik-Engine | f8d6173e17c4438b34853d1d51db64d808574e8f | 10171bbeb73c590e75e9db5adf0135e0235f2884 | refs/heads/master | 2021-01-21T04:30:51.989357 | 2016-07-10T09:58:13 | 2016-07-10T09:58:13 | 38,234,601 | 7 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,104 | cpp | main_win64gl.cpp | #include "shared.hpp"
#include "application.hpp"
#include "render_api_gl.hpp"
#include "config_manager.hpp"
#include "os_utils.hpp"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
using namespace AGN;
int WINAPI WinMain(HINSTANCE a_hInstance, HINSTANCE a_hPrevInstance, LPSTR a_lpCmdLine, int a_nShowCmd)
{
UNREFERENCED_PARAMETER(a_hInstance);
UNREFERENCED_PARAMETER(a_hPrevInstance);
UNREFERENCED_PARAMETER(a_lpCmdLine);
UNREFERENCED_PARAMETER(a_nShowCmd);
// load configurations
std::string currentFolder = OSUtils::getCurrentFolder();
std::string configFile = OSUtils::findFile("config.ini", currentFolder.c_str(), 3, 3);
std::string rootFolder = OSUtils::getDirectoryOfPath(configFile);
g_configManager.parseConfigFile(configFile);
// show log output
if (g_configManager.getConfigPropertyAsBool("enable_log_window"))
{
g_log.init(ELogTimeType::RunningTime, (uint8_t)ELoggerOutputType::Window | (uint8_t)ELoggerOutputType::OutputDebug);
}
IRenderAPI* renderAPI = new RenderAPIGL();
g_application.run(renderAPI);
g_application.cleanup();
delete renderAPI;
return 0;
}
|
72cbb89b7258c0094c369332f0b778084e5a9edd | 9b1a0e9ac2c5ffc35f368ca5108cd8953eb2716d | /7/1 General Programming/03 Optical Flow For Videogames Played With Webcams/Game/Source/SoundManager.cpp | 336930c2800b16f977e194992585586b432829f9 | [] | no_license | TomasRejhons/gpg-source-backup | c6993579e96bf5a6d8cba85212f94ec20134df11 | bbc8266c6cd7df8a7e2f5ad638cdcd7f6298052e | refs/heads/main | 2023-06-05T05:14:00.374344 | 2021-06-16T15:08:41 | 2021-06-16T15:08:41 | 377,536,509 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,434 | cpp | SoundManager.cpp | #include <stdio.h>
#include <string>
#include "alc.h"
#include "alut.h"
#include "defines.h"
#include "SoundManager.h"
SoundManager * SoundManager::mSoundManager=NULL;
SoundManager::SoundManager()
{
mIsAvailableSound = true;
_initAL();
}
SoundManager::~SoundManager()
{
_finalizeAL();
}
void SoundManager::CleanUp( void )
{
std::map<std::string,Sound*>::iterator it;
for( it = mSounds.begin(); it!= mSounds.end(); ++it)
{
(*it).second->DestroySound();
delete (*it).second;
}
CHECKED_DELETE(mSoundManager);
}
SoundManager& SoundManager::getInstance()
{
if (mSoundManager==NULL)
{
mSoundManager = new SoundManager();
}
return *mSoundManager;
}
void SoundManager::PlaySource(const std::string& idSound)
{
if( mIsAvailableSound != false )
{
std::map<std::string,Sound*>::iterator it;
it = mSounds.find(idSound);
if( it != mSounds.end() )
{
Sound* sound = (*it).second;
sound->PlaySample();
}
}
}
void SoundManager::_initAL()
{
ALenum error;
ALCdevice* pDevice;
ALCcontext* pContext;
// Get handle to default device.
pDevice = alcOpenDevice(NULL);
// Get the device specifier.
//const ALCubyte* deviceSpecifier = alcGetString(pDevice, ALC_DEVICE_SPECIFIER);
// Create audio context.
pContext = alcCreateContext(pDevice, NULL);
// Set active context.
alcMakeContextCurrent(pContext);
// Check for an error.
if ((error=alcGetError(pDevice)) != ALC_NO_ERROR)
{
mIsAvailableSound = false;
}
}
void SoundManager::_finalizeAL()
{
ALCcontext* pCurContext;
ALCdevice* pCurDevice;
// Get the current context.
pCurContext = alcGetCurrentContext();
// Get the device used by that context.
pCurDevice = alcGetContextsDevice(pCurContext);
// Reset the current context to NULL.
alcMakeContextCurrent(NULL);
// Release the context and the device.
alcDestroyContext(pCurContext);
alcCloseDevice(pCurDevice);
}
void SoundManager::load (std::string xmlSoundsFile)
{
// read the xml doors file
if( mIsAvailableSound != false )
xmlParseFile(xmlSoundsFile);
}
//parsers the xml door file
void SoundManager::onStartElement( const std::string &elem, MKeyValue &atts )
{
if (elem=="sound2d")
{
if (atts["name"]!="" && atts["path"]!="")
{
//Process a Sound
Sound *s = new Sound();
std::string name = atts["name"];
std::string path = atts["path"];
s->LoadSound(path,false);
mSounds.insert( std::pair<std::string,Sound*>(name,s) );
}
}
} |
984a768b42ee80238c21e392cf4624fa6207d23f | 2810e677de2d36a34a4cc4630960054b3e9ab861 | /core/test/test_author.cpp | 90788ad21b26b121b1df670962ad635b7a4a432f | [] | no_license | martiert/library | 692b4352505f38ca09eff7542c4126c061f69136 | f99a816ea69b383f7dc34f23e05016c0515d6b85 | refs/heads/master | 2016-09-11T01:54:14.859655 | 2014-10-12T11:39:48 | 2014-10-12T11:39:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,368 | cpp | test_author.cpp | #include "CppUTest/TestHarness.h"
#include "Library/Author.hpp"
#include "Library/Entry.hpp"
class AuthorOnlyEntry : public Library::Entry
{
public:
AuthorOnlyEntry(std::vector<std::string> authors)
: authors_(authors)
{}
private:
const std::string & get_title() const override
{
return title_;
}
const std::vector<std::string> & get_authors() const override
{
return authors_;
}
std::vector<std::string> authors_;
std::string title_;
};
TEST_GROUP(AuthorTests)
{
void setup()
{
author.reset(new Library::Author("J.R.R. Tolkien"));
}
std::unique_ptr<Library::Author> author;
};
TEST(AuthorTests, initialize_author)
{
CHECK_EQUAL("J.R.R. Tolkien", author->get_name());
CHECK_EQUAL(0U, author->number_of_entries());
}
TEST(AuthorTests, adding_entry_for_author)
{
auto entry = std::make_shared<AuthorOnlyEntry>(
std::vector<std::string>{"J.R.R. Tolkien"});
author->add_entry(entry);
CHECK_EQUAL(1U, author->number_of_entries());
CHECK_EQUAL(entry.get(), author->get_entries()[0].get());
}
TEST(AuthorTests, adding_entry_from_different_author_throws)
{
CHECK_THROWS(Library::NotAuthorsEntryException,
author->add_entry(std::make_shared<AuthorOnlyEntry>(
std::vector<std::string>{"Brandon Sanderson"})));
}
|
2cfb8a950b6ed5e194988f02f2e6a7b259ca3f1e | 0918a3eead990ba0abdf022b5dfa062b335f44f1 | /projects/Week2-FaceTimeMachine/src/testApp.h | de89f026019ab59a0e104cb2bdbd7044673f84a5 | [] | no_license | dmak78/AppropriatingNewTechnologies | 01ba7fd43e5ed6119c9a8805c0c66514a68ec7b4 | ba87cb20f04e7e04bf9b531ce63a28266020de7d | refs/heads/master | 2020-12-25T11:57:35.801660 | 2012-03-23T14:40:57 | 2012-03-23T14:40:57 | 3,283,153 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,273 | h | testApp.h | #pragma once
#include "ofMain.h"
#include "ofxCv.h"
#include "Clone.h"
#include "ofxFaceTracker.h"
#include "ofxFaceTrackerThreaded.h"
using namespace ofxCv;
using namespace cv;
class testApp : public ofBaseApp {
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void loadFace(string face);
ofVideoGrabber cam;
ofxFaceTrackerThreaded tracker;
ofxFaceTracker imgTracker;
ofImage imgSrc;
ofImage img1;
ofImage img2;
ofImage img3;
ofDirectory faces;
int currentFace;
ofVec2f position;
float scale;
ofVec3f orientation;
ofMatrix4x4 rotationMatrix;
Mat translation, rotation;
ofMatrix4x4 pose;
Clone clone1;
Clone clone2;
Clone clone3;
ofFbo img1Fbo, img2Fbo, img3Fbo, clone1Fbo, clone2Fbo, clone3Fbo, camMask, camFbo;
ofMesh camMesh, img1Mesh, img2Mesh, img3Mesh;
vector<ofVec2f> imagePoints[3];
ofEasyCam easyCam;
int newPositionX;
int newPositionY;
bool followMouse;
ofLight light;
vector<float> meltSpeed;
bool isMelting;
bool timeToMelt;
};
|
211d42862fd295ef18461063142d805e922917ce | d5c86c77bb44f9316cf6b54c0ad52b251f9fcf3c | /WordComparison.cpp | d8683182a1f42e1df281a6eefaa033e39ccfeac8 | [] | no_license | Countd0wn142/ProgramsArchive | 7d83e0a108e132e9b38766aac2f273361eb215ff | 2e90462f1eaf2e67437216391d99eea5cd8f0d56 | refs/heads/master | 2020-03-27T11:12:51.416002 | 2018-09-06T13:58:17 | 2018-09-06T13:58:17 | 146,472,460 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,965 | cpp | WordComparison.cpp | /*
+-------------------------------------------------------------------------------+
| Author : Brady Barnett |
| Date : 06/18/2018 |
| Description: Program that checks if two words can be connected through |
| a series of words with only one letter different in each |
| word given an imported dictionary. |
| ex. cord - core - care - dare
+-------------------------------------------------------------------------------+
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
bool CHECK_IF_EDGE(string, string);
bool IS_VISITED(vector<int>, int);
int main()
{
bool FOUND = false;
string TEMP;
string INPUT1;
string INPUT2;
bool CONTINUE;
vector<string> ALL_WORDS;
vector<string> REFINED_WORDS;
vector<int> TEMP_GRAPH;
vector<vector<int> > GRAPH;
cout << "Please input dictionary: ";
cin >> TEMP;
ifstream INPUT;
INPUT.open(TEMP.c_str());
//INPUT ALL WORDS INTO WORD VECTOR
while(INPUT >> TEMP)
{
ALL_WORDS.push_back(TEMP);
}
do
{
REFINED_WORDS.clear();
GRAPH.clear();
cout << "Please input first word: ";
cin >> TEMP;
INPUT1 = TEMP;
cout << "Please input second word: ";
cin >> TEMP;
INPUT2 = TEMP;
if(INPUT1.size() != INPUT2.size())
{
cout << "Error: Words are not of same length. Aborting Process." << endl;
break;
}
//REFINE ALL WORDS TO SAME LENGTH
for(int i = 0; i < ALL_WORDS.size(); i++)
{
if(ALL_WORDS[i].size() == INPUT1.size())
{
REFINED_WORDS.push_back(ALL_WORDS[i]);
}
}
//CREATE GRAPH OF SIZE NxN (WHERE N = ALL_WORDS.size())
for(int i = 0; i < REFINED_WORDS.size(); i++)
{
TEMP_GRAPH.clear();
for(int j = 0; j < REFINED_WORDS.size(); j++)
{
//CHECK TO SEE IF AT SAME WORD FIRST, OR IF STRINGS ARE DIFFERENT SIZES
if(REFINED_WORDS[i] == REFINED_WORDS[j])
{
TEMP_GRAPH.push_back(0);
}
//CHECK TO SEE IF ITS A VALID EDGE
else if(CHECK_IF_EDGE(REFINED_WORDS[i], REFINED_WORDS[j]))
{
TEMP_GRAPH.push_back(1);
}
//IF NOT, RETURN ZERO
else
{
TEMP_GRAPH.push_back(0);
}
}
//INSERT ROW INTO GRAPH
GRAPH.push_back(TEMP_GRAPH);
}
vector<int> VISITED;
vector<int> QUEUE;
vector<int> PATH;
vector<int> PARENTS;
int COUNT = 0;
int STARTING_NODE;
int ENDING_NODE;
PARENTS.clear();
VISITED.clear();
QUEUE.clear();
PATH.clear();
FOUND = false;
for(int i = 0; i < REFINED_WORDS.size(); i++)
{
PARENTS.push_back(-1);
}
//FIND START POSITION
for(int i = 0; i < REFINED_WORDS.size(); i++)
{
if(REFINED_WORDS[i] == INPUT1)
{
QUEUE.push_back(i);
VISITED.push_back(i);
STARTING_NODE = i;
break;
}
//ERROR HANDLING HERE
}
while(!FOUND && QUEUE.size() > 0)
{
for(int i = 0; i < GRAPH.size(); i++)
{
//CHECK TO SEE IF IT IS AN EDGE
if(GRAPH[QUEUE[0]][i] == 1)
{
//CHECK IF VISITED ALREADY
if(!IS_VISITED(VISITED, i))
{
PARENTS[i] = QUEUE[0];
QUEUE.push_back(i);
VISITED.push_back(i);
if(REFINED_WORDS[i] == INPUT2)
{
ENDING_NODE = i;
PATH.push_back(i);
FOUND = true;
break;
}
}
}
}
QUEUE.erase(QUEUE.begin());
}
if(FOUND)
{
bool FINISHED = false;
int LEAF = ENDING_NODE;
int PARENT_NODE;
while(!FINISHED)
{
PARENT_NODE = PARENTS[LEAF];
PATH.push_back(PARENT_NODE);
LEAF = PARENT_NODE;
if(PARENT_NODE == STARTING_NODE)
{
FINISHED = true;
}
}
cout << "PATH IS: ";
for(int i = PATH.size()-1; i >= 0; i--)
{
cout << REFINED_WORDS[PATH[i]] << " ";
}
cout << endl;
}
else
{
cout << "Path not available" << endl;
}
cout << "Continue? y/n: ";
cin >> TEMP;
if(TEMP == "n" || TEMP == "N" || TEMP == "no")
CONTINUE = false;
else if(TEMP == "y" || TEMP == "Y" || TEMP == "yes")
CONTINUE = true;
else
{
cout << "Incorrect option, terminating program." << endl;
CONTINUE = false;
}
}while(CONTINUE);
return 0;
}
bool CHECK_IF_EDGE(string A, string B)
{
/*
This function checks to see if the words are edges by parsing through every individual character in
both strings and comparing them. If an individual comparison is true, then the count will increase
by one. By the end of the loop, if the count is equal to [A.size() - 1], then that means only one
character comparison failed, and the nodes indeed share an edge.
*/
//SET OUR COUNTER TO ZERO
int COUNT = 0;
if(A.size() != B.size())
return false;
for(int i = 0; i < A.size(); i++)
{
if(A[i] != B[i])
{
COUNT++;
}
if(COUNT > 1)
return false;
}
return true;
}
bool IS_VISITED(vector<int> VISITED, int TARGET)
{
for(int i = 0; i < VISITED.size(); i++)
{
if(VISITED[i] == TARGET)
return true;
}
return false;
}
|
870a4dce9b4fef92377bf86c9b621f024e3bca68 | 7dcc021a54186053194fa12fb10f7266dcc6d511 | /src/gmmbin/gmm-et-acc-a.cc | a12c08bd48ef819821b30d0f026e23dce7395210 | [
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | troylee/kaldi | fcdb3cda8a95f0aae71b05242f5a777a02131351 | 33b9f3bcebca5f2e280c6416f95962d664a1d26d | refs/heads/master | 2020-05-25T10:07:08.210149 | 2014-07-18T08:32:35 | 2014-07-18T08:32:35 | 21,224,820 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 7,383 | cc | gmm-et-acc-a.cc | // gmmbin/gmm-et-acc-a.cc
// Copyright 2009-2011 Microsoft Corporation
// 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
//
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
// WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
// MERCHANTABLITY OR NON-INFRINGEMENT.
// See the Apache 2 License for the specific language governing permissions and
// limitations under the License.
#include <string>
using std::string;
#include <vector>
using std::vector;
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "gmm/am-diag-gmm.h"
#include "hmm/transition-model.h"
#include "transform/exponential-transform.h"
int main(int argc, char *argv[]) {
try {
typedef kaldi::int32 int32;
using namespace kaldi;
const char *usage =
"Accumulate statistics for estimating the A matrix of exponential transform, \n"
" per-utterance (default) or per-speaker for \n"
" the supplied set of speakers (spk2utt option).\n"
"Usage: gmm-et-acc-a [options] <model> <exponential-transform> <feature-rspecifier> "
"<gpost-rspecifier> <accs-filename>\n";
ParseOptions po(usage);
string spk2utt_rspecifier;
bool binary = true;
po.Register("spk2utt", &spk2utt_rspecifier, "rspecifier for speaker to "
"utterance-list map");
po.Register("binary", &binary, "Write output in binary mode");
po.Read(argc, argv);
if (po.NumArgs() != 5) {
po.PrintUsage();
exit(1);
}
string model_rxfilename = po.GetArg(1),
et_rxfilename = po.GetArg(2),
feature_rspecifier = po.GetArg(3),
gpost_rspecifier = po.GetArg(4),
accs_wxfilename = po.GetArg(5);
RandomAccessGauPostReader gpost_reader(gpost_rspecifier);
AmDiagGmm am_gmm;
TransitionModel trans_model;
{
bool binary;
Input ki(model_rxfilename, &binary);
trans_model.Read(ki.Stream(), binary);
am_gmm.Read(ki.Stream(), binary);
}
ExponentialTransform et;
ReadKaldiObject(et_rxfilename, &et);
int32 dim = et.Dim();
double tot_objf_impr = 0.0, tot_count = 0.0;
ExponentialTransformAccsA accs_a(dim);
int32 num_done = 0, num_no_gpost = 0, num_other_error = 0;
if (spk2utt_rspecifier != "") { // per-speaker adaptation
SequentialTokenVectorReader spk2utt_reader(spk2utt_rspecifier);
RandomAccessBaseFloatMatrixReader feature_reader(feature_rspecifier);
for (; !spk2utt_reader.Done(); spk2utt_reader.Next()) {
string spk = spk2utt_reader.Key();
FmllrDiagGmmAccs accs(dim);
const vector<string> &uttlist = spk2utt_reader.Value();
for (vector<string>::const_iterator utt_itr = uttlist.begin(),
itr_end = uttlist.end(); utt_itr != itr_end; ++utt_itr) {
if (!feature_reader.HasKey(*utt_itr)) {
KALDI_WARN << "Did not find features for utterance " << *utt_itr;
continue;
}
if (!gpost_reader.HasKey(*utt_itr)) {
KALDI_WARN << "Did not find gpost for utterance "
<< *utt_itr;
num_no_gpost++;
continue;
}
const Matrix<BaseFloat> &feats = feature_reader.Value(*utt_itr);
const GauPost &gpost = gpost_reader.Value(*utt_itr);
if (static_cast<int32>(gpost.size()) != feats.NumRows()) {
KALDI_WARN << "gpost has wrong size " << (gpost.size())
<< " vs. " << (feats.NumRows());
num_other_error++;
continue;
}
for (size_t i = 0; i < gpost.size(); i++) {
const SubVector<BaseFloat> feat(feats, i);
for (size_t j = 0; j < gpost[i].size(); j++) {
int32 pdf_id = trans_model.TransitionIdToPdf(gpost[i][j].first);
const Vector<BaseFloat> &posteriors(gpost[i][j].second);
const DiagGmm &gmm = am_gmm.GetPdf(pdf_id);
KALDI_ASSERT(gmm.NumGauss() == posteriors.Dim());
accs.AccumulateFromPosteriors(gmm, feat, posteriors);
}
}
num_done++;
} // end looping over all utterances of the current speaker
Matrix<BaseFloat> xform(dim, dim+1);
Matrix<BaseFloat> Ds(dim, dim+1); // the diagonal transform..
BaseFloat objf_impr, spk_count, t;
et.ComputeTransform(accs, &xform, &t, &Ds, &objf_impr, &spk_count);
tot_objf_impr += objf_impr;
tot_count += spk_count;
KALDI_VLOG(1) << "Objf impr for speaker " << spk << " is " << (objf_impr/spk_count)
<< " per frame over " << spk_count << " frames.";
accs_a.AccumulateForSpeaker(accs, et, Ds, t);
} // end looping over speakers
} else { // per-utterance adaptation
SequentialBaseFloatMatrixReader feature_reader(feature_rspecifier);
for (; !feature_reader.Done(); feature_reader.Next()) {
string utt = feature_reader.Key();
FmllrDiagGmmAccs accs(dim);
if (!gpost_reader.HasKey(utt)) {
KALDI_WARN << "Did not find gpost for utterance "
<< utt;
num_no_gpost++;
continue;
}
const Matrix<BaseFloat> &feats = feature_reader.Value();
const GauPost &gpost = gpost_reader.Value(utt);
if (static_cast<int32>(gpost.size()) != feats.NumRows()) {
KALDI_WARN << "gpost has wrong size " << (gpost.size())
<< " vs. " << (feats.NumRows());
num_other_error++;
continue;
}
num_done++;
for (size_t i = 0; i < gpost.size(); i++) {
const SubVector<BaseFloat> feat(feats, i);
for (size_t j = 0; j < gpost[i].size(); j++) {
int32 pdf_id = trans_model.TransitionIdToPdf(gpost[i][j].first);
const Vector<BaseFloat> &posteriors(gpost[i][j].second);
const DiagGmm &gmm = am_gmm.GetPdf(pdf_id);
KALDI_ASSERT(gmm.NumGauss() == posteriors.Dim());
accs.AccumulateFromPosteriors(gmm, feat, posteriors);
}
}
num_done++;
Matrix<BaseFloat> xform(dim, dim+1);
Matrix<BaseFloat> Ds(dim, dim+1);
BaseFloat objf_impr, utt_count, t;
et.ComputeTransform(accs, &xform, &t, &Ds, &objf_impr, &utt_count);
tot_objf_impr += objf_impr;
tot_count += utt_count;
KALDI_VLOG(1) << "Objf impr for utterance " << utt << " is " << (objf_impr/utt_count)
<< " per frame over " << utt_count << " frames.";
accs_a.AccumulateForSpeaker(accs, et, Ds, t);
}
}
KALDI_LOG << "Done " << num_done << " files, " << num_no_gpost
<< " with no posteriors, " << num_other_error << " with other errors.";
KALDI_LOG << "Num frames " << tot_count << ", avg objf impr per frame = "
<< (tot_objf_impr / tot_count);
Output ko(accs_wxfilename, binary);
accs_a.Write(ko.Stream(), binary);
KALDI_LOG << "Written accs.";
return 0;
} catch(const std::exception &e) {
std::cerr << e.what();
return -1;
}
}
|
c7c2293598acd08d4f5fbe228e50182265b4fac4 | 839f460f7cd4777fe90e987559075b3d54920132 | /c++_primer_exercise/ch10/ex10_11.cpp | 1912fc3c11f490f4265a5f88bcbef8ade03c1065 | [] | no_license | soldier828/cPlusPlusPrimerProject | 0e2219dff50144089a06ae16dfb0e104392ff552 | af24463968587af410c61db54ecd5a2475e37604 | refs/heads/master | 2021-05-01T22:35:15.197165 | 2017-03-10T12:31:35 | 2017-03-10T12:31:35 | 77,431,012 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 902 | cpp | ex10_11.cpp | #include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using std::string;
using std::vector;
bool isShorter(const string &s1, const string &s2){
return s1.size() < s2.size();
}
void elimDups(vector<string> &words){
std::sort(words.begin(), words.end());
auto end_unique = std::unique(words.begin(), words.end());
words.erase(end_unique, words.end());
}
/*
void print(vector<string> &result){
for(const auto &s : result)
std::cout << s << " ";
std::cout << std::endl;
}
*/
template<typename T>
void print(T const& result){
for(const auto& s : result)
std::cout << s << " ";
std::cout << std::endl;
}
int main(){
vector<string> words = {"the","quick","red","fox","jumps","over","the","slow","red","turtle"};
elimDups(words);
std::stable_sort(words.begin(), words.end(), isShorter);
print(words);
return 0;
}
|
0f4f770188ad4914d3b19dba9bb95d311f37b609 | f63b8fe1d770ae6b23b5643101ee3ab1aa92956a | /History.cpp | eda603f243750e4f8ba54e53bc987eb2ecdbf2cf | [] | no_license | sanvega9/sandibell-project-c- | 41ec23962670e964bf5c59eef93c9ef3dee4fd39 | 1abe01b1d9ba1307ffcde423a6cf142c1f622d1d | refs/heads/master | 2022-06-07T05:17:34.949752 | 2020-05-02T03:08:49 | 2020-05-02T03:08:49 | 260,603,375 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 281 | cpp | History.cpp | #include "History.h"
#include "Map.h"
//function to location to the CANDYMYSTERYLAND
void History::playerTurn()
{
map map("mintchoc", 1);
for (int i = 0; i < 1; i++)
{
map.location("right");
}
for (int i = 0; i < 1; i++)
{
map.distance(28, "23");
}
}
|
927e31723853f1721e00e58d7c76054503080e51 | 82959ffb9b8dfc36ad4b0ff5156d09bb87385475 | /8.ExamPrep.03.09.2017/Cake.cpp | 28387724eb701e5a05701daceca6a4566c5f9852 | [] | no_license | AntoniaShalamanova/Programming-Basic-With-C-Plus-Plus | bec64933afcc7d8edf93822508e82ca9051de097 | 1612fb8615fc42f6d27447214b3c3ed2c2410b57 | refs/heads/master | 2020-05-14T17:50:36.387047 | 2019-04-17T14:28:40 | 2019-04-17T14:28:40 | 181,893,035 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 717 | cpp | Cake.cpp | // Cake.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
int length, width;
cin >> length >> width;
int area = length*width;
string pieces;
int number_of_pieces = 0, piece;
for (int i = 1; i > 0; i++)
{
cin >> pieces;
piece = atoi(pieces.c_str());
number_of_pieces += piece;
if (number_of_pieces > area)
{
cout << "No more cake left! You need " << number_of_pieces - area
<< " pieces more." << endl;
break;
}
else if (pieces == "STOP")
{
cout << area - number_of_pieces << " pieces are left." << endl;
break;
}
}
return 0;
}
|
f344b7857c72ce2b3c7780554ecf05f11ba11e68 | e0005f0b10a7b9091ce8c0aafa5d5431bfbd207f | /linkSort/main.cpp | 144a0b85ab0cfeb4d95c112e90f67a0dac946287 | [] | no_license | PythonMyLife/data_structure | b9c88791620984f754fe13801531cb2e0d4e2342 | 51a31dc8a27aee92d2465f021391363bd90d4834 | refs/heads/master | 2020-05-07T09:48:26.695050 | 2019-06-10T15:22:18 | 2019-06-10T15:22:18 | 180,392,335 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,164 | cpp | main.cpp | #include <iostream>
using namespace std;
struct Node {
int value;
Node *next;
};
/*void insertSort(int *array, int length)
{
int i, j;
Node *head = new Node(), *nextp = new Node(), *tmp = new Node();
nextp->next = NULL;
nextp->value = array[0];
head->next = nextp;
for(i = 1; i < length; i++){
Node *newNode = new Node();
tmp = head;
newNode->value = array[i];
while(tmp->next != NULL && tmp->next->value < newNode->value){
tmp = tmp->next;
}
newNode->next = tmp->next;
tmp->next = newNode;
}
nextp = head->next;
for(j = 0; j < length; j++){
array[j] = nextp->value;
nextp = nextp->next;
}
}*/
Node *insertSort(Node *array)
{
Node *origin = array;
Node *head = new Node(), *tmp = new Node(), *nextp = new Node();
nextp->value = array->value;
nextp->next = NULL;
head->next = nextp;
while((array = array->next) != NULL){
Node *newNode = new Node();
tmp = head;
newNode->value = array->value;
while(tmp->next != NULL && tmp->next->value < newNode->value){
tmp = tmp->next;
}
newNode->next = tmp->next;
tmp->next = newNode;
}
array = head->next;
while(origin != NULL){
Node *p = origin;
origin = origin->next;
delete p;
}
return array;
}
Node *selectSort(Node *array)
{
int size = 0;
Node *origin = array, *o = array;
Node *head = new Node(), *nextp = head;
while((array = array->next) != NULL){
size++;
}
for(int i = 0; i < size; i++){
array = origin->next;
int min = array->value;
Node * newNode = new Node();
while((array = array->next) != NULL){
min = min < array->value ? min : array->value;
}
array = origin->next;
if(array->value == min){
origin = origin->next;
}else{
while(array->next != NULL){
if(array->next->value == min){
Node *tmp = array->next;
array->next = array->next->next;
delete tmp;
break;
}
array = array->next;
}
}
newNode->value = min;
newNode->next = NULL;
nextp->next = newNode;
nextp = nextp->next;
}
while(o != NULL){
Node *tmp = o;
o = o->next;
delete o;
}
return head;
}
int main()
{
Node *head = new Node(),
*a0 = new Node(),
*a1 = new Node(),
*a2 = new Node(),
*a3 = new Node(),
*a4 = new Node(),
*a5 = new Node();
a0->value = 3;
a1->value = 1;
a2->value = 2;
a3->value = 5;
a4->value = 4;
a5->value = 0;
head->next = a0;
a0->next = a1;
a1->next = a2;
a2->next = a3;
a3->next = a4;
a4->next = a5;
a5->next = NULL;
//head = insertSort(head);
head = selectSort(head);
while(head->next != NULL)
{
cout << head->next->value << " ";
head = head->next;
}
return 0;
}
|
581e452c391bdf530165e01f3f8bc40474c638f8 | 3966cab3c688138b27853492331a18985b46e94b | /AlgorithmSortQuick.cpp | f503fc1e5912db20e1b37a49e85e3662640eb9e8 | [
"MIT"
] | permissive | ghanimmustafa/Kth-Largest-number | 6c6c2e7ed3c8356711cda64d1aa27f7df0838187 | 655de19818d9b7a103b6117c564e14f53eaecc2d | refs/heads/master | 2020-12-13T09:00:06.286914 | 2020-01-16T17:15:00 | 2020-01-16T17:15:00 | 234,369,223 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,266 | cpp | AlgorithmSortQuick.cpp | #include "AlgorithmSortQuick.h"
AlgorithmSortQuick::AlgorithmSortQuick(int k): SelectionAlgorithm(k){
this->k = k;
}
int AlgorithmSortQuick::select()
{
int N = 0;
cin>>N;
int x=0;
int *pNums = 0;
pNums = new int[N];
int left =0;
int right = N-1;
for (int i=0; i< N; i++)
{
cin>>x;
pNums[i] = x;
}
quickselect( pNums, left, right, k);
int result = pNums[k];
cout<<"Result: "<<result<<endl;
pNums = 0;
delete [] pNums;
return result;
}
int AlgorithmSortQuick::quickselect(int* pNums,int left, int right,int k)
{
int array_size = right - left + 1 ;
if(array_size>10)
{
// Partition, Quick sort, and quick select:
int pivot=median3(pNums,left,right);
int i=left,j=right-1;
for(;;)
{
while(pNums[++i]>pivot){}
while(pNums[--j]<pivot){}
if(i<j)
swap(pNums,i,j);
else
break;
}
swap(pNums,i,right-1);
if (k == i) {
return pivot;
} else if (k <= i - 1) {
return quickselect(pNums, left, i - 1, k);
} else {
return quickselect(pNums, i + 1, right, k);
}
}
else
{
// Do insertion sort for N<=10
for(int i=0; i<=array_size; i++)
{
int temp = pNums[i];
int j= i-1;
while(j>=0 && temp >= pNums[j])
{
pNums[j+1] = pNums[j];
j = j-1;
}
pNums[j+1] = temp;
}
return pNums[k-1];
}
}
int AlgorithmSortQuick::median3(int* pNums,int left, int right)
{
int center = (left + right ) / 2 ;
if(pNums[center]>pNums[left])
{
swap(pNums,left,center);
}
if(pNums[right]>pNums[left])
{
swap(pNums,left,right);
}
if(pNums[right]>pNums[center])
{
swap(pNums,right,center);
}
swap(pNums,center,right-1);
return pNums[right-1];
}
void AlgorithmSortQuick::swap(int* pNums,int i, int j) {
int t = pNums[i];
pNums[i] = pNums[j];
pNums[j] = t;
}
|
f5745893fd88a6527a0b5e82bef5ac01b6b9167c | b46a748df7ad8336a555ca36ec58a16c2da58722 | /DXR_SoftShadows_Project/BeLuEngine/src/ECS/Components/InputComponent.h | 8b9d3d64819a24a5e4f125fdd1546a4b60027577 | [
"MIT"
] | permissive | fjz345/DXR_SoftShadows | c66aa33b7455f9b6c76df93cbe7710358faef6c3 | 00cb6b1cf560899a010c9e8504578d55e113c22c | refs/heads/main | 2023-08-26T11:45:45.232481 | 2021-07-12T14:39:32 | 2021-07-12T14:39:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 600 | h | InputComponent.h | #ifndef INPUTCOMPONENT_H
#define INPUTCOMPONENT_H
#include "EngineMath.h"
#include "Component.h"
#include "Core.h"
class BaseCamera;
struct MouseScroll;
struct MovementInput;
struct MouseMovement;
namespace component
{
class InputComponent : public Component
{
public:
// Default Settings
InputComponent(Entity* parent);
virtual ~InputComponent();
virtual void Update(double dt) override;
void OnInitScene() override;
void OnUnInitScene() override;
private:
// Move camera
void move(MovementInput* event);
// Rotate camera
void rotate(MouseMovement* event);
};
}
#endif |
c3c2d6bdd4a7b65f63e767132fe26da79e1ec5b8 | 2b8d0631df3b4acf7a978611a378a1b85af9397d | /cpp/leetcode/twoSum.cpp | 189b7f5d701e935ec12a0c45a033d75c8ce5c917 | [] | no_license | sanyinchen/algorithm | ab110ae95c9af480d22407e17cc7b1a9fb4a05d5 | c7e143e082d0f6008bdafde9570f6ab81a0b165e | refs/heads/master | 2022-10-28T11:41:12.335971 | 2022-10-19T14:07:15 | 2022-10-19T14:07:15 | 88,053,211 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 834 | cpp | twoSum.cpp | //
// Created by sanyinchen on 17/4/20.
// https://leetcode.com/problems/two-sum/#/description
//
#include <iostream>
#include <vector>
#include <map>
using namespace std;
vector<int> twoSum(vector<int> &nums, int target) {
int length = nums.size(), dv;
vector<int> res;
map<int, int> maps;
for (int i = 0; i < length; i++) {
maps[nums[i]] = i;
}
for (int i = 0; i < length; i++) {
dv = target - nums[i];
if (maps.find(dv) != maps.cend() && maps[dv] != i) {
res.push_back(i);
res.push_back(maps[dv]);
break;
}
}
return res;
}
int main() {
vector<int> a;
a.push_back(3);
a.push_back(3);
vector<int> r = twoSum(a, 6);
for (int i = 0; i < r.size(); i++) {
cout << r[i] << " ";
}
return 0;
}
|
cab2f782c6382d0013da0b395054248375202e0d | 2b332da28ca7d188892f72724400d79f16cda1b9 | /src/asset/texture.cpp | 5b128113c6c439372a2c9c0e534aa1328bcad1cc | [
"Apache-2.0"
] | permissive | chokomancarr/chokoengine2 | e4b72f18f6fd832c2445b5c7bec1bb538ad62de1 | 2825f2b95d24689f4731b096c8be39cc9a0f759a | refs/heads/master | 2023-05-02T18:05:43.665056 | 2021-04-14T17:54:17 | 2021-04-14T17:54:17 | 191,103,464 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,004 | cpp | texture.cpp | #include "chokoengine.hpp"
#include "texture_internal.hpp"
#include "backend/chokoengine_backend.hpp"
CE_BEGIN_NAMESPACE
_Texture::_Texture(std::nullptr_t) : _Texture(0, 0, 0) {}
_Texture::_Texture(uint w, uint h, GLuint ptr)
: _Asset(AssetType::Texture), _pointer(ptr), _width(w), _height(h), _hdr(false) {}
_Texture::_Texture(uint w, uint h, bool hdr, const TextureOptions& opts)
: _Asset(AssetType::Texture), _width(w), _height(h), _channels(4), _hdr(hdr) {
glGenTextures(1, &_pointer);
glBindTexture(GL_TEXTURE_2D, _pointer);
std::vector<byte> data(w * h * 4);
glTexImage2D(GL_TEXTURE_2D, 0, hdr? GL_RGBA32F : GL_RGBA, (int)w, (int)h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data.data());
SetTexParams<>(opts);
glBindTexture(GL_TEXTURE_2D, 0);
}
_Texture::_Texture(uint w, uint h, GLenum type, const TextureOptions& opts, const void* pixels, const GLenum pixelFmt, const GLenum pixelType)
: _Texture(w, h, 0) {
glGenTextures(1, &_pointer);
glBindTexture(GL_TEXTURE_2D, _pointer);
glTexImage2D(GL_TEXTURE_2D, 0, type, (int)w, (int)h, 0, pixelFmt, pixelType, pixels);
SetTexParams<>(opts);
if (opts.mipmaps > 0) {
glGenerateMipmap(GL_TEXTURE_2D);
}
glBindTexture(GL_TEXTURE_2D, 0);
}
_Texture::_Texture(DataStream strm, const TextureOptions& opts, bool async)
: _Asset(AssetType::Texture), _pointer(0), _width(0), _height(0), _hdr(false), _opts(opts), _pixels({}) {
_asyncThread = std::thread([this](DataStream strm) {
CE_OBJECT_SET_ASYNC_LOADING;
const auto ext = StrExt::ExtensionOf(strm.path);
if (!strm) {
return;
}
if (ext == "jpg") {
if (!Texture_I::FromJPG(std::move(strm), _width, _height, _channels, _pixels))
return;
}
else if (ext == "png") {
if (!Texture_I::FromPNG(std::move(strm), _width, _height, _channels, _pixels))
return;
//rgb = GL_BGR;
//rgba = GL_BGRA;
}
else if (ext == "bmp") {
if (!Texture_I::FromBMP(std::move(strm), _width, _height, _channels, _pixels))
return;
}
else if (ext == "hdr") {
if (!Texture_I::FromHDR(std::move(strm), _width, _height, _channels, _pixels))
return;
_hdr = true;
}
else {
Debug::Error("Texture", "Cannot determine format \"" + ext + "\"!");
return;
}
CE_OBJECT_SET_ASYNC_READY;
}, std::move(strm));
CE_OBJECT_INIT_ASYNC;
}
_Texture::~_Texture() {
CE_OBJECT_FINALIZE_ASYNC;
glDeleteTextures(1, &_pointer);
}
bool _Texture::loaded() {
CE_OBJECT_CHECK_ASYNC;
return !!_pointer;
}
void _Texture::LoadAsync() {
if (!_width || !_height)
return;
glGenTextures(1, &_pointer);
glBindTexture(GL_TEXTURE_2D, _pointer);
if (_channels == 1) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, _hdr ? GL_R32F : GL_RED, _width, _height, 0, GL_RED, _hdr ? GL_FLOAT : GL_UNSIGNED_BYTE, _pixels.data());
}
else if (_channels == 3)
glTexImage2D(GL_TEXTURE_2D, 0, _hdr ? GL_RGB32F : GL_RGB, _width, _height, 0, GL_RGB, _hdr ? GL_FLOAT : GL_UNSIGNED_BYTE, _pixels.data());
else if (_channels == 4)
glTexImage2D(GL_TEXTURE_2D, 0, _hdr ? GL_RGBA32F : GL_RGBA, _width, _height, 0, GL_RGBA, _hdr ? GL_FLOAT : GL_UNSIGNED_BYTE, _pixels.data());
else {
Debug::Error("Texture", "Unexpected channel size " + std::to_string(_channels) + "!");
}
if (_opts.mipmaps > 0) glGenerateMipmap(GL_TEXTURE_2D);
const GLenum wraps[] = { GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT };
SetTexParams<>(_opts.mipmaps,
wraps[(int)_opts.xwrap],
wraps[(int)_opts.ywrap],
(_opts.linear) ? (
(_opts.mipmaps > 0) ?
GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR
) : GL_NEAREST,
(_opts.linear) ?
GL_LINEAR : GL_NEAREST
);
glBindTexture(GL_TEXTURE_2D, 0);
std::vector<byte> empty(0);
std::swap(_pixels, empty);
_loading = false;
}
void _Texture::SetPixelsRaw(const std::vector<byte>& pixels) {
CE_OBJECT_CHECK_ASYNC;
glBindTexture(GL_TEXTURE_2D, _pointer);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _width, _height, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
glBindTexture(GL_TEXTURE_2D, 0);
}
void _Texture::SetPixelsRaw(const std::vector<float>& pixels) {
CE_OBJECT_CHECK_ASYNC;
glBindTexture(GL_TEXTURE_2D, _pointer);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _width, _height, GL_RGBA, GL_FLOAT, pixels.data());
glBindTexture(GL_TEXTURE_2D, 0);
}
void _Texture::Bind() {
CE_OBJECT_CHECK_ASYNC;
glBindTexture(GL_TEXTURE_2D, _pointer);
}
void _Texture::Unbind() const {
glBindTexture(GL_TEXTURE_2D, 0);
}
void _Texture::Blit(const RenderTarget& dst, const Material& mat) {
dst->BindTarget();
glViewport(0, 0, dst->width(), dst->height());
auto tex = get_shared<_Texture>();
glBlendFunc(GL_ONE, GL_ZERO);
if (!mat) {
UI::Texture(Display::fullscreenRect(), tex);
}
else {
mat->SetUniform("mainTex", tex);
mat->Bind();
Backend::Renderer::emptyVao()->Bind();
glDrawArrays(GL_TRIANGLES, 0, 6);
Backend::Renderer::emptyVao()->Unbind();
mat->Unbind();
}
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glViewport(0, 0, Display::width(), Display::height());
dst->UnbindTarget();
}
CE_END_NAMESPACE
|
23fb42ce0c91efcbcab2e567437bdde8610aae97 | 868ba990839028b738584acbf20ec587fb318503 | /src/impl/items/item.h | 7d70bad235303d02ba90f531cc407f33ae71ea25 | [] | no_license | jackHay22/swamp-surveyor | ffa122c08221c1a0f1de5551e184f4975fcfdd51 | 867c33cda7bb173921a3d1c401cb87a8da2e973b | refs/heads/main | 2023-04-07T01:04:14.514055 | 2021-04-03T19:35:46 | 2021-04-03T19:35:46 | 324,853,090 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,123 | h | item.h | /*
* (C) 2021 Jack Hay
*
* Untitled Swamp game
*/
#ifndef _IO_JACKHAY_SWAMP_ITEM_H
#define _IO_JACKHAY_SWAMP_ITEM_H
#include <SDL2/SDL_image.h>
#include <SDL2/SDL.h>
#include <string>
#include "../tilemap/abstract_tilemap.h"
namespace impl {
namespace items {
/**
* An item in the map
* that can be picked up by the
* player
*/
struct item_t {
private:
//the location of the item in the map
int x;
int y;
//the dimensions of the texture
int texture_w;
int texture_h;
//the ticks since the last position update
int position_ticks;
//whether the texture bounce is currently up
bool position_up;
//whether this item has been picked up
bool picked_up;
//once picked up, the position the item moves to
int target_x;
int target_y;
//whether this item can now be shown in inventory
bool displayable;
//once displayed the coordinates (not transformed by camera)
int display_x;
int display_y;
//the texture
SDL_Texture* texture = NULL;
public:
/**
* Constructor
* @param x position of the item x
* @param y position of the item y
* @param texture_path the path to the texture
* @param renderer the renderer for loading the texture
*/
item_t(int x, int y,
const std::string& texture_path,
SDL_Renderer& renderer);
item_t(const item_t&) = delete;
item_t& operator=(const item_t&) = delete;
/**
* Free texture
*/
~item_t();
/**
* Whether this item can be removed from the environment
* @return whether this item has finished any final animations
*/
bool removable() const { return displayable; }
/**
* Set the location for displaying this item
* @param display_x the display coordinate x
* @param display_y the display coordinate y
*/
void set_display_position(int display_x, int display_y);
/**
* Player picks up this item, animate movement
* @param x the player position x
* @param y the player position y
*/
void pick_up(int x, int y);
/**
* Drop this inventory item
* @param x the position x
* @param y the position y
*/
void drop(int x, int y);
/**
* Check if a bounding box collides with this item
* @param bounds the bounds to check
* @return whether the bounds collide
*/
bool is_collided(const SDL_Rect& bounds) const;
/**
* Get the bounding box for this item
* @return the bounding box for this item
*/
SDL_Rect get_bounds() const;
/**
* Update the item
* @param map the tilemap
*/
virtual void update(const tilemap::abstract_tilemap_t& map);
/**
* Render the item
* @param renderer the renderer to use
* @param camera the camera
* @param debug whether debug mode enabled
*/
virtual void render(SDL_Renderer& renderer,
const SDL_Rect& camera,
bool debug) const;
};
}}
#endif /*_IO_JACKHAY_SWAMP_ITEM_H*/
|
68b77e27319caeda946b49222eb1973f8bc297b3 | ee5fb93e5daefbf6ec20157b3c50942451a4983e | /src/optimization_problem.cpp | 7983eef33d1bb98d3c18fe7b5c514c9056150fd9 | [
"MIT"
] | permissive | humanphysiologylab/Genetic-Algorithm | 472bdeec77220c00b5b356ed43774aa7686325be | 88afa7506b3a6d62f0c991ddf1dca325e2524c5f | refs/heads/master | 2022-05-12T06:59:31.072079 | 2022-04-25T09:14:53 | 2022-04-25T09:14:53 | 197,004,635 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,050 | cpp | optimization_problem.cpp | #include "optimization_problem.h"
#include <iomanip>
BlockOfTable::BlockOfTable(int * model_indices, Block xblock)
: Base(xblock), model_indices(model_indices)
{}
int BlockOfTable::get_model_pos(int col) const
{
return model_indices[col];
}
Table::Table(int m, int n, const std::vector<std::string> & header)
: Base(Base::Constant(m, n, 0)), header(header)
{
}
template<typename T>
std::vector<T> operator+(const std::vector<T> & v1, const std::vector<T> & v2)
{
std::vector<T> res(v1.size() + v2.size());
res.insert(res.end(), v1.begin(), v1.end());
res.insert(res.end(), v2.begin(), v2.end());
return res;
}
TableSplit::TableSplit(int m, int n, std::vector<int> states_model_indices,
std::vector<int> alg_model_indices,
const std::vector<std::string> & states_names,
const std::vector<std::string> & alg_names)
: Base(m, n, states_names + alg_names)
{
states_cols = states_model_indices.size();
alg_cols = alg_model_indices.size();
assert(n == states_cols + alg_cols);
model_indices = new int [states_model_indices.size() + alg_model_indices.size()];
for (unsigned i = 0; i < states_model_indices.size(); i++) {
model_indices[i] = states_model_indices[i];
}
for (unsigned i = 0; i < alg_model_indices.size(); i++) {
model_indices[i + states_model_indices.size()] = alg_model_indices[i];
}
}
TableSplit::~TableSplit()
{
delete [] model_indices;
}
BlockOfTable TableSplit::get_algebraic()
{
return BlockOfTable(model_indices + states_cols, this->rightCols(alg_cols));
}
BlockOfTable TableSplit::get_states()
{
return BlockOfTable(model_indices, this->leftCols(states_cols));
}
void Table::export_csv(const std::string & filename)
{
std::ofstream file;
file.open(filename + ".csv");
if (!file.is_open())
throw(filename + " cannot be opened");
for (const auto & x: header)
file << x << " ";
file << std::endl;
file << std::scientific << std::setprecision(12);
for (int i = 0; i < Base::rows(); i++) {
for(int j = 0; j < Base::cols(); j++) {
file << Base::operator()(i, j) << " ";
}
file << std::endl;
}
}
int halfheight_index(const std::vector<double> & v)
{
assert(v.size() > 0);
double max = v[0], min = v[0];
//find max and min
for (unsigned i = 0; i < v.size(); i++) {
if (v[i] < min) {
min = v[i];
} else if (v[i] > max) {
max = v[i];
}
}
const double hh = (max + min) / 2;
//find i : v[i] <= hh <= v[i + 1]
for (unsigned i = 0; i < v.size(); i++) {
if (v[i] < hh)
continue;
//so v[i] >= hh
if (i == 0)
break;
//find closest among i-1 and i
const double a1 = std::fabs(v[i-1] - hh);
const double a2 = std::fabs(v[i] - hh);
if (a1 < a2)
return i - 1;
else
return i;
}
return -1;//smth wrong, or just v[-1] <= hh <= v[0] xx
}
|
d69051951e735200c88c3dd337b077d96a1a4401 | b7e2338a82c2db9050875f104d01065d7c2f5ed8 | /Linked Lists/reverseAlternateKnodes.cpp | 7ec04f679374b9456947063aa5055fdac6d3c976 | [] | no_license | bhavyeah20/interviewbit | c7cdebe88971a5f536cc5cca1f121e2de166f50f | 51662f695a8124992426f329f26800777c2b0531 | refs/heads/master | 2023-08-08T02:51:46.120784 | 2021-09-25T04:27:18 | 2021-09-25T04:27:18 | 356,602,181 | 6 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 564 | cpp | reverseAlternateKnodes.cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
ListNode* Solution::solve(ListNode* A, int B) {
ListNode *t = A;
ListNode *prev = NULL, *curr = t, *next;
int b = B;
if (B == 1)
return t;
while (b-- && curr) {
next = curr->next;
curr->next = prev;
prev = curr;
curr = next;
}
A->next = next;
t = next;
b = B - 1;
while (b-- && t) {
t = t->next;
}
if (t && t->next) {
t->next = Solution::solve(t->next, B);
}
return prev;
}
|
225fc6b5e73a9a679450280ff1f38cac21901597 | afd111f4ff11b47834a1e7c0be4eed81be8ce379 | /dirc.cc | 42cec7966030070bd5d472c4c2de26a6bce4c431 | [] | no_license | EIC-Detector/EicDircStandalone | 16ddb7f6223c2ce4f8236954fc17fd68c5e5bcf1 | a525887fc95e27d3b4eec05341726ac13c45f8ba | refs/heads/master | 2020-05-20T06:04:26.784936 | 2015-10-03T18:43:49 | 2015-10-03T18:43:49 | 30,775,679 | 0 | 1 | null | 2015-10-03T18:43:50 | 2015-02-13T20:55:32 | C++ | UTF-8 | C++ | false | false | 3,245 | cc | dirc.cc | #include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "EicDircStandalonePhysicsList.hh"
#include "EicDircStandalonePrimaryGeneratorAction.hh"
#include "EicDircStandaloneDetectorConstruction.hh"
#include "EicDircStandaloneRunAction.hh"
#include "EicDircStandaloneEventAction.hh"
#include "EicDircStandaloneStackingAction.hh"
#include "EicDircStandaloneSteppingVerbose.hh"
#include "EicDircStandaloneSteppingAction.hh"
#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
#endif
#ifdef G4UI_USE
#include "G4UIExecutive.hh"
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
using namespace std;
int main(int argc,char** argv)
{
// Seed the random number generator manually
//
G4long myseed = 345354;
CLHEP::HepRandom::setTheSeed(myseed);
// User Verbose output class
//
G4VSteppingVerbose* verbosity = new EicDircStandaloneSteppingVerbose;
G4VSteppingVerbose::SetInstance(verbosity);
// Run manager
//
G4RunManager* runManager = new G4RunManager;
// UserInitialization classes - mandatory
//
G4VUserPhysicsList* physics = new EicDircStandalonePhysicsList;
runManager-> SetUserInitialization(physics);
//
//G4VUserDetectorConstruction* detector = new EicDircStandaloneDetectorConstruction;
G4VUserDetectorConstruction* detector = new EicDircStandaloneDetectorConstruction;
runManager-> SetUserInitialization(detector);
//
G4VUserPrimaryGeneratorAction* gen_action = new EicDircStandalonePrimaryGeneratorAction;
runManager->SetUserAction(gen_action);
//
runManager->SetUserAction(new EicDircStandaloneSteppingAction());
// configure run manager
// runManager->SetNumberOfEventsToBeStored(1);
#ifdef G4VIS_USE
// visualization manager
//
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
#endif
// UserAction classes
//
G4UserRunAction* run_action = new EicDircStandaloneRunAction;
runManager->SetUserAction(run_action);
//
G4UserEventAction* event_action = new EicDircStandaloneEventAction;
runManager->SetUserAction(event_action);
//
G4UserStackingAction* stacking_action = new EicDircStandaloneStackingAction;
runManager->SetUserAction(stacking_action);
// Initialize G4 kernel
//
runManager->Initialize();
// Get the pointer to the User Interface manager
//
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if (argc==1) // Define UI session for interactive mode
{
#ifdef G4UI_USE
G4UIExecutive * ui = new G4UIExecutive(argc,argv);
#ifdef G4VIS_USE
UImanager->ApplyCommand("/control/execute vis.mac");
#endif
ui->SessionStart();
delete ui;
#endif
}
else // Batch mode
{
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command+fileName);
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not
// be deleted in the main() program !
#ifdef G4VIS_USE
delete visManager;
#endif
delete runManager;
delete verbosity;
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
0a1ac60ee9e964ba719b2dd80c3022eb7efc3942 | 7dd32e878b844731e6eb9348062c3bcc91374304 | /Hospital Sim/Simulator.h | e8c2853251c4c585a2aaf7148803a1db0a53809e | [] | no_license | dhansen17/Hospital-Sim | 447a4bcedc04ef8d324b02db1aadf12ae1b6dd19 | 411d8eb40ac29a4a9c6c7c8e9d57207fbdaecfd0 | refs/heads/master | 2021-01-10T12:01:56.397673 | 2016-02-16T21:14:59 | 2016-02-16T21:14:59 | 51,870,765 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,056 | h | Simulator.h | #ifndef SIMULATOR_H_
#define SIMULATOR_H_
#include"Patient.h"
#include"Hospital.h"
#include"Random.h"
#include"Doctor.h"
#include"Emergency.h"
Random newmy_random;
class Simulator
{
//Private variables
private:
//Int variables
int totalTime;
int clock;
//Pointers
EmergencyRoom* roomobject;
Hospital* hospitalobject;
DocRoom* pointer;
//Fuunction
int checkP(const std::string &prompt, int low, int high)
{
//This can not happen
if (low >= high)
throw std::invalid_argument("Your low is greater than your high");
std::cin.exceptions(std::ios_base::failbit);
//While loop for obtaining input
int track = 0;
while (true)
{
try {
while (true)
{
cout << prompt;
cin >> track;
if (track >= low && track <= high)
{
return track;
}
}
}
//Catching any errors
catch (std::ios_base::failure)
{
cout << "Invalid string, please try again\n";
cin.clear();
cin.ignore(std::numeric_limits<int>::max(), '\n');
}
}
}
//Public variables
public:
//No-arg construct
Simulator()
{
//New hospital
roomobject = new EmergencyRoom();
//Weeks worth of time
totalTime = 10080;
//A hospital has an emergency room
hospitalobject = new Hospital(roomobject);
}
//Users get to ent in the data for the hospital
void enterPdata()
{
std::cout << "Hello and welcome to our Hospital Simulator.\n";
//Allowing for user to input number of doctors, then creating an array of doctors
cout << "How many doctors are working now? Please only enter between 1 and 2" << endl;
int doctrack = checkP("", 1, 2);
int hourPatientRate = checkP("Please enter the amount of patients in the hospital: ", 1, 59);
hospitalobject->setpArrive(hourPatientRate);
pointer = new DocRoom(doctrack, roomobject, hospitalobject);
}
void runPSim()
{
//For loop to run patient simulation
for (clock = 0; clock < totalTime; ++clock)
{
roomobject->updateER(clock);
pointer->docClock(clock);
}
}
//Displaying the results
void showSim()
{
cout << "Total time for patient spent waiting : " << hospitalobject->getTotalwait() << endl;
int choice = 0;
Simulator sim;
cout << "Please enter in a choice" << endl;
cout << "1. Show Simulation" << endl;
cout << "2. Show the list of all patients" << endl;
cout << "3. Find a patient" << endl;
cout << "4. End session" << endl;
cin >> choice;
//Switch statement for the choice of which the user can do
switch (choice)
{
case 1: cout << "Show simulation" << endl;
sim.enterPdata();
sim.runPSim();
case 2: cout << "Show record of patients" << endl;
hospitalobject->display();
case 3: cout << "Find a person who may have entered into the hospital" << endl;
hospitalobject->reCurrence();
case 4: cout << "End session" << endl;
break;
default:
cout << "Please enter in an option between 1 and 4" << endl;
}
}
};
#endif
|
2081951b7cdc81016f3accf5ff2a240bcfc858d1 | 02f6798a3b497f12382ed6159db194af242ac23b | /source/diy/smd/smdVertex.cpp | 3383e4a75f28146b5977c9367991209a1f87bb8c | [] | no_license | SaulHP91/DIYlib | 62fc2e32861bcbda760e42d72be796d49ffcd2b8 | 7f2c381f0d9a1e90f929a74987dcf0c85ed7f1fa | refs/heads/master | 2020-12-25T18:22:38.390742 | 2015-04-26T09:00:30 | 2015-04-26T09:00:30 | 34,035,942 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,226 | cpp | smdVertex.cpp | #include <diy/smd/smd.hpp>
namespace diy
{
namespace smd
{
SmdVertex::SmdVertex(void) :
BoneIndex(-1)
{
;
}
SmdVertex::~SmdVertex(void)
{
SkinWeights.clear();
SkinWeights.swap(std::vector<SmdSkinWeight>(SkinWeights));
}
bool SmdVertex::ParseFromSStream(std::istringstream& in)
{
std::streampos pos = in.tellg();
in >> BoneIndex;
if (!in.good())
{
in.clear();
in.seekg(pos);
return false;
}
if (!Position.ParseFromSStream(in))
{
in.clear();
in.seekg(pos);
return false;
}
if (!Normal.ParseFromSStream(in))
{
in.clear();
in.seekg(pos);
return false;
}
if (!TexCoord.ParseFromSStream(in))
{
in.clear();
in.seekg(pos);
return false;
}
int skinWeightCount;
in >> skinWeightCount;
if (!in.good())
{
in.clear();
in.seekg(pos);
return false;
}
SkinWeights.resize(skinWeightCount);
for (std::vector<SmdSkinWeight>::iterator smd_skin_weight = SkinWeights.begin(); smd_skin_weight != SkinWeights.end(); ++smd_skin_weight)
{
if (!smd_skin_weight->ParseFromSStream(in))
{
in.clear();
in.seekg(pos);
return false;
}
}
return true;
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.