blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905
values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 115
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
abde3fd93fb0530a2c3e1105527c267b15b55075 | c361d99d919f28387029bcc85a6a71e765fc9da2 | /RTS_Lessons/Source/RTS_Lessons/CameraPawnBase.cpp | 3499c60eb9f37085d5b896550c508326d4944ebf | [] | no_license | Jmin17/RTS_Lessons | c15c7df502c96a4c902c0eec4a0c6d5c0d7495c1 | 1dd5f96393893868f4d0cb9812fb4cbdb81b7ec5 | refs/heads/master | 2020-07-02T13:53:59.437810 | 2019-08-18T22:01:09 | 2019-08-18T22:01:09 | 201,543,232 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,851 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "CameraPawnBase.h"
#include "Classes/Components/InputComponent.h"
#include "Classes/GameFramework/FloatingPawnMovement.h"
#include "Classes/Camera/CameraComponent.h"
#include "Classes/Components/SceneComponent.h"
#include "Classes/GameFramework/SpringArmComponent.h"
//#include "Classes/Engine/World.h"
//#include "Classes/GameFramework/PlayerController.h"
//#include "Classes/Kismet/GameplayStatics.h"
//#include "Runtime/InputCore/Classes/InputCoreTypes.h"
//#include <fstream>
//#include <iostream>
// Sets default values
ACameraPawnBase::ACameraPawnBase()
{
PrimaryActorTick.bCanEverTick = true;// draws/updates pawn every frame, can be false to not do that
//initializing a root component for other components to attach to,
//multi-component objects all need to have a root component
rootSceneComponent = CreateDefaultSubobject<USceneComponent>("RootComponent");
//creating a spring arm which will hold the camera at a certain distance back
// and above to enable a good view
springArm = CreateDefaultSubobject<USpringArmComponent>("SpringArm");
springArm->SetupAttachment(rootSceneComponent);
//causes the camera to be up at an angle looking down
springArm->SetRelativeRotation(FRotator(-60.f, 0.f, 0.f));
minZoom = 300.f;
maxZoom = 3000.f;
zoomIncrement = 100.f;
zoomSmoothingGradient = 8.f;
cameraDistance = 800.f;
springArm->TargetArmLength = cameraDistance;// how far away the camera is
springArm->bDoCollisionTest = false;
zooming = false;
// smooths camera movement to prevent jerkiness, especially helpful on
// zooming the camera in and out
//springArm->bEnableCameraLag = true;
//springArm->CameraLagSpeed = 5.0f;
//used for binding the pawn's movement to player inputs
floatingPawnMovement = CreateDefaultSubobject<UFloatingPawnMovement>("PawnMovement");
// this creates the camera
camera = CreateDefaultSubobject<UCameraComponent>("CameraComponent");
// the line below is not necessary as it was covered by adding the spring arm
//camera->SetRelativeLocationAndRotation(FVector(-500.f, 0.f, -500.f), FRotator(-60.f, 0.f, 0.f));
// attaching the camera to the spring arm
camera->SetupAttachment(springArm, USpringArmComponent::SocketName);
floatingPawnMovement->Acceleration = 20000.0f;
floatingPawnMovement->Deceleration = 20000.0f;
floatingPawnMovement->MaxSpeed = 4500.0f;
floatingPawnMovement->TurningBoost = 30.0f;
// doesn't work
// gives the pawn a handle to the player controller
//playerController = GetWorld()->GetFirstPlayerController();
//playerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
//{
// using namespace std;
// myFile.open("johnny.txt");
// if (playerController != nullptr)
// {
// myFile << "Success!";
// }
// else
// {
// myFile << "Failure :(" << endl << endl;
// }
// myFile.close();
//}//namespace std
//this causes the player to automatically "possess" this pawn
AutoPossessPlayer = EAutoReceiveInput::Player0;
}
// Called when the game starts or when spawned
void ACameraPawnBase::BeginPlay()
{
Super::BeginPlay();
}
void ACameraPawnBase::MoveForward(float amount)
{
floatingPawnMovement->AddInputVector(GetActorForwardVector() * amount);
}
void ACameraPawnBase::MoveRight(float amount)
{
floatingPawnMovement->AddInputVector(GetActorRightVector() * amount);
}
void ACameraPawnBase::ZoomIn()
{
if (cameraDistance > minZoom)
cameraDistance -= zoomIncrement;
zooming = true;
//springArm->TargetArmLength = cameraDistance;
}
void ACameraPawnBase::ZoomOut()
{
if (cameraDistance < maxZoom)
cameraDistance += zoomIncrement;
zooming = true;
//springArm->TargetArmLength = cameraDistance;
}
// Called every frame
void ACameraPawnBase::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// applying a smoothing function to the change in zoom
if (zooming)
{
if (springArm->TargetArmLength != cameraDistance)
{
desiredMovement = (cameraDistance - springArm->TargetArmLength)/zoomSmoothingGradient;
if (abs(desiredMovement) < 1 )
{
desiredMovement = cameraDistance - springArm->TargetArmLength;
}
springArm->TargetArmLength += desiredMovement;
}
else
{
zooming = false;
}
}//end if
}
// Called to bind functionality to input
void ACameraPawnBase::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAction("CameraZoomIn", IE_Pressed, this, &ACameraPawnBase::ZoomIn);
PlayerInputComponent->BindAction("CameraZoomOut", IE_Pressed, this, &ACameraPawnBase::ZoomOut);
PlayerInputComponent->BindAxis("MoveForward", this, &ACameraPawnBase::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &ACameraPawnBase::MoveRight);
//FVector direction =
}
| [
"justin.l.minyard@gmail.com"
] | justin.l.minyard@gmail.com |
02e9b32affff097a75523e5d2117817ff0387992 | 39b7b641c2318d59534e069d1ad47ef58b021df3 | /src/fast_mpd_parser/AdaptationSet.cpp | 4962578c620442933cabbc3836c06f1046d134b1 | [] | no_license | vietanhto/fast_mpd_parser | 926a7c5b9e68a4467c33ab21938f1ef56b907d6f | af60b66c101a5905b81d31185fce3874d544d679 | refs/heads/master | 2020-03-10T09:49:54.595299 | 2018-12-20T08:43:51 | 2018-12-20T09:07:47 | 129,319,640 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,512 | cpp | #include "fast_mpd_parser/Include.h"
namespace fast_mpd_parser {
Status parse_adaptation_set(char* buffer, uint32_t size, uint32_t* ptr_pos, void* elem) {
uint32_t tag_name_start,
tag_name_end,
tag_name_len;
uint32_t attr_name_start,
attr_name_end,
attr_value_start,
attr_value_end,
attr_name_len;
char quote;
uint32_t i;
bool found_close_tag = false;
uint32_t pos = *ptr_pos;
AdaptationSet* ptr_adaptation_set = (AdaptationSet*) elem;
while (pos < size && buffer[pos] != '>') {
FMP__LOC_NEXT_ATTR();
}
while (!found_close_tag) {
FMP__LOC_NEXT_TAG();
if (0 == strncmp(buffer + tag_name_start, "Representation", tag_name_len)) {
i = ptr_adaptation_set->representations_size++;
ptr_adaptation_set->representations[i] = (Representation*) calloc(1, sizeof(Representation));
parse_representation(buffer, size, &pos, ptr_adaptation_set->representations[i]);
} else {
parseTag(buffer, size, &pos, NULL);
}
}
CleanUp:
*ptr_pos = pos;
}
void free_adaptation_set(AdaptationSet* ptr_adaptation_set) {
for (uint32_t i = 0; i < ptr_adaptation_set->representations_size; i++) {
free_representation(ptr_adaptation_set->representations[i]);
}
}
} | [
"vietto@amazon.com"
] | vietto@amazon.com |
f0f1abada07ac08139e4c998952d1f068fa226a6 | d2d6aae454fd2042c39127e65fce4362aba67d97 | /build/iOS/Preview1/include/_root.OutracksSimulat-7329dae0.h | 4033742253a7f4a2f40f4fe2e085a56576dba55b | [] | no_license | Medbeji/Eventy | de88386ff9826b411b243d7719b22ff5493f18f5 | 521261bca5b00ba879e14a2992e6980b225c50d4 | refs/heads/master | 2021-01-23T00:34:16.273411 | 2017-09-24T21:16:34 | 2017-09-24T21:16:34 | 92,812,809 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,447 | h | // This file was generated based on /usr/local/share/uno/Packages/Outracks.Simulator.Client.Uno/0.1.0/.uno/ux11/$.uno.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.String.h>
#include <Uno.UX.Property-1.h>
namespace g{namespace Fuse{namespace Controls{struct TextControl;}}}
namespace g{namespace Uno{namespace UX{struct PropertyObject;}}}
namespace g{namespace Uno{namespace UX{struct Selector;}}}
namespace g{struct OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property;}
namespace g{
// internal sealed class OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property :391
// {
::g::Uno::UX::Property1_type* OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property_typeof();
void OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property__ctor_3_fn(OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property* __this, ::g::Fuse::Controls::TextControl* obj, ::g::Uno::UX::Selector* name);
void OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property__Get1_fn(OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property* __this, ::g::Uno::UX::PropertyObject* obj, uString** __retval);
void OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property__New1_fn(::g::Fuse::Controls::TextControl* obj, ::g::Uno::UX::Selector* name, OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property** __retval);
void OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property__get_Object_fn(OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property* __this, ::g::Uno::UX::PropertyObject** __retval);
void OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property__Set1_fn(OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property* __this, ::g::Uno::UX::PropertyObject* obj, uString* v, uObject* origin);
void OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property__get_SupportsOriginSetter_fn(OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property* __this, bool* __retval);
struct OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property : ::g::Uno::UX::Property1
{
uWeak< ::g::Fuse::Controls::TextControl*> _obj;
void ctor_3(::g::Fuse::Controls::TextControl* obj, ::g::Uno::UX::Selector name);
static OutracksSimulatorClientUno_FuseControlsTextControl_Value_Property* New1(::g::Fuse::Controls::TextControl* obj, ::g::Uno::UX::Selector name);
};
// }
} // ::g
| [
"medbeji@MacBook-Pro-de-MedBeji.local"
] | medbeji@MacBook-Pro-de-MedBeji.local |
109633aee21033c1bc197d4c2f02ad7414f05ba8 | 1bf5dca199e50e725d8ed8593318ea13c7c9190c | /Ceng334/hw2/smelter.cpp | 52d9216025ba27f1f57bbe0f40b04cfa1212bc04 | [] | no_license | kursatozturk/Homeworks | 959f4fb3c16a1d6cd770b6479ae61e9116e46c92 | 0e644381b250a98c6c22d3b0db4c0ca4cbc96c9b | refs/heads/master | 2023-08-09T15:49:07.362743 | 2019-12-14T23:29:00 | 2019-12-14T23:29:00 | 155,235,323 | 1 | 0 | null | 2023-07-19T20:59:56 | 2018-10-29T15:27:21 | Jupyter Notebook | UTF-8 | C++ | false | false | 2,533 | cpp | #include "smelter.hpp"
#include "observer.hpp"
Smelter::Smelter (int ID, OreType oreType, uint capacity, uint interval):
Producer(ID, capacity, interval, SMELTER_CREATED),
oreType(oreType), waitingOreCount(0)
{
//init semaphores
this->oreLock = PTHREAD_MUTEX_INITIALIZER;
sem_init(&this->waitingOre, 0, this->capacity);
sem_init(&this->oreCount, 0, 0); // initially no ore exists to produce ingot
this->observer->Register(this, this->oreType);
this->observer->inform(this->oreType, this->capacity);
this->output(SMELTER_CREATED);
};
inline bool Smelter::waitCanProduce () {
struct timespec ts;
if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
std::cerr << "ERROR" << std::endl;
return false;
}
ts.tv_sec += 5;
if (sem_timedwait(&this->oreCount, &ts) == -1){
return false;
}
if (sem_timedwait(&this->oreCount, &ts) == -1){
return false;
}
return true;
}
inline void Smelter::ProduceFinished () {
acquire(this->oreLock);
this->waitingOreCount -= 2;
if (this->waitingOreCount == 1)
this->observer->primaryNeed(this, this->oreType);
release(this->oreLock);
sem_post(&this->waitingOre);
sem_post(&this->waitingOre);
this->observer->inform(this->oreType, 2);
}
bool Smelter::loadFromTransporter (OreType oreType, TransporterInfo *transporterInfo) {
sem_wait(&this->waitingOre);
acquire(this->transporterLock);
this->output(TRANSPORTER_TRAVEL, transporterInfo);
this->sleep_awhile(); // to travel
acquire(this->oreLock);
this->waitingOreCount++;
if ( this->waitingOreCount == 1)
this->observer->primaryNeed(this, this->oreType);
release(this->oreLock);
this->sleep_awhile(); // unloading
this->output(TRANSPORTER_DROP_ORE, transporterInfo);
sem_post(&this->oreCount);
release(this->transporterLock);
return true;
};
bool Smelter::isAvailable (OreType o){
acquire(this->oreLock);
bool is = this->isActive() & this->waitingOreCount < this->capacity;
release(this->oreLock);
return is;
}
inline void Smelter::output(Action action, TransporterInfo *transporterInfo){
acquire(this->oreLock);
FillSmelterInfo(&this->smelterInfo, this->ID, this->oreType, this->capacity, this->waitingOreCount, this->producedCount);
release(this->oreLock);
WriteOutput(nullptr, transporterInfo, &this->smelterInfo, nullptr, action);
} | [
"e2171874@ceng.metu.edu.tr"
] | e2171874@ceng.metu.edu.tr |
49a2c8ec4e58fc7b9c9be457c8d6899d6f543a59 | 7b0329d3d4ef539b17acac72b79c636b6b8e9661 | /lib/lang_out.cpp | 22dd859ce987fa759892cc29b02fc220b98d3eec | [
"Apache-2.0"
] | permissive | dima201246/serv_fan | 0e544ecfc3369dec10ea0e526d02e7ad2b6d2cc1 | 217b7ecc4effa21bf2553f5f75971d01c7fb2774 | refs/heads/master | 2021-01-20T19:42:26.148112 | 2016-07-05T09:59:52 | 2016-07-05T09:59:52 | 61,531,312 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,196 | cpp | #include "conf_lang.h"
// VERSION: 0.3.6 ALPHA
// LAST UPDATE: 23.03.2016
using namespace std;
bool always_read_lang = false;
unsigned int w_length(string line) {
setlocale(LC_ALL, "");
wchar_t *w_temp_c = new wchar_t[line.length() + 1];
mbstowcs(w_temp_c, line.c_str(), line.length() + 1);
unsigned int num = wcslen(w_temp_c);
delete [] w_temp_c;
return num;
}
string del_end(string str_in) // Óäàëåíèå ñèìâîëà êîíöà ñòðîêè
{
if (str_in.empty()) return "";
char *c_st = new char[str_in.length()+1];
strcpy(c_st,str_in.c_str());
char *p = strtok(c_st, "\r");
return(string(p));
}
string del_b(string str_in) // Óäàëåíèå ñèìâîëà îòêàòà êàðåòêè
{
if (str_in.empty()) return "";
char *c_st = new char[str_in.length()+1];
strcpy(c_st,str_in.c_str());
char *p = strtok(c_st, "\b");
return(p);
}
int del_bl(string str_in) // Óäàëåíèå ñèìâîëà îòêàòà êàðåòêè è âîçâðàùåíèå êîë-âà ñèìâîëîâ â ñòðîêå
{
if (str_in.empty()) return 0;
char *c_st = new char[str_in.length()+1];
strcpy(c_st,str_in.c_str());
char *p = strtok(c_st, "\b");
string p_str;
p_str.clear();
p_str = string(p);
return(p_str.length());
}
string del_new(string str_in) {
if (!strlen(str_in.c_str())) return "";
char *c_st = new char[str_in.length()+1];
strcpy(c_st,str_in.c_str());
char *p = strtok(c_st, "\n");
return(string(p));
}
string str(double input) {
stringstream ss;
ss << "";
ss << input;
string str;
ss >> str;
return str;
}
bool save_commit_lang(unsigned int first_pos, string line) {
for (unsigned int j = first_pos; j < line.length(); j++) {
if ((line[j] == '#') && (line[j - 1] != '\\')) return true;
if (line[j] != ' ') return false;
}
return false;
}
bool search_value(string line, string parametr, string new_value, string &returned_value) {
bool only_read = true /*Пока ищется параметр*/, continue_stat = false, find_first_char = false, not_found = true;
string temp_line, temp_return;
temp_line.clear(); temp_return.clear();
for (unsigned int i = 0; i < line.length(); i++) {
if ((only_read) && (!always_read_lang)) { // Чтение, пока не найдено равно или не активно постоянное чтение
if (line[i] == ' ') continue;
if (line[i] == '=') {
if (temp_line == parametr) { // Если найденный параметр совпал с искомым
not_found = false;
only_read = false; continue; // Пропуск, чтобы не добавлять равно в ответ
} else return false;
}
temp_line = temp_line + line[i]; // Накопление параметра
} else {
if ((!find_first_char) && (line[i] == ' ')) continue; // Если обнаружены пробелы в самом начале
else find_first_char = true;
if (continue_stat) {continue_stat = false; continue;} // Если надо что-то пропустить
if (line[i] == ' ') if (save_commit_lang(i, line)) break; // Если обнаружен пробел и за ним следует комментарий, то закончить
if (line[i] == '\\') { // Если обнаружен знак экранирования
if (line[i + 1] == '#') {temp_return = temp_return + line[i + 1]; continue_stat = true; continue;}
if (line[i + 1] == '\"') {temp_return = temp_return + line[i + 1]; continue_stat = true; continue;}
if (line[i + 1] == '%') {temp_return = temp_return + line[i + 1]; continue_stat = true; continue;}
if (line[i + 1] == 'n') {temp_return = temp_return + '\n'; continue_stat = true; continue;}
}
if (line[i] == '#') break;
if (line[i] == '%') {temp_return = temp_return + " "; continue;}
// if (line[i] == 'n') {temp_return = temp_return + '\n'; continue;}
if (line[i] == '\"') { // Если обнаружены кавычки
if (always_read_lang) { // Если это вторые кавычки
always_read_lang = false;
returned_value = temp_return;
return true;
} else {
always_read_lang = true;
continue;
}
}
temp_return = temp_return + line[i]; // Накопление результата
}
}
returned_value = temp_return;
if (not_found) return false; // Если искомый параметр не был найден
return true;
}
string lang(string parametr, vector <string> lang_base) {
always_read_lang = false;
string readText, returned_value, always_read_temp;
returned_value.clear(); always_read_temp.clear();
bool found_result = false, always_read_bool = false;
for (unsigned int i = 0; i < lang_base.size(); i++) {
if (always_read_lang) always_read_bool = true;
else always_read_bool = false;
if ((search_value(lang_base[i], parametr, "", returned_value)) && (!always_read_lang)) {
found_result = true;
if (always_read_bool) return always_read_temp + returned_value;
else return returned_value;
} else if (always_read_lang) always_read_temp = always_read_temp + returned_value;
}
if (!found_result) return "NotLoadLang"; // Параметр не найден
else return returned_value;
} | [
"dima201246@gmail.com"
] | dima201246@gmail.com |
68278c8e5afaaa56ca9987f7ee002dcd069bb76e | 413a1d85f164ab38ef876452ac3c363f9df058c4 | /wiki_app/venv/lib/python3.5/site-packages/lucene-8.1.1-py3.5-linux-x86_64.egg/lucene/include/org/apache/lucene/analysis/miscellaneous/ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl.h | 8eb6566010a20394065bd520bbc0908021895ed3 | [] | no_license | prateek68/Wikipedia-Online-Content-Comparison | 18d53e3456e2d7aa6eb67629c2ea1c79b7d8be4d | 77d54b99881558b3195190740ba1be7f8328392b | refs/heads/master | 2020-12-26T11:58:18.903011 | 2020-02-02T09:55:37 | 2020-02-02T09:55:37 | 237,495,848 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 3,544 | h | #ifndef org_apache_lucene_analysis_miscellaneous_ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl_H
#define org_apache_lucene_analysis_miscellaneous_ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl_H
#include "org/apache/lucene/util/AttributeImpl.h"
namespace java {
namespace lang {
class CharSequence;
class Class;
}
}
namespace org {
namespace apache {
namespace lucene {
namespace util {
class BytesRef;
class AttributeReflector;
class BytesRefBuilder;
}
namespace analysis {
namespace tokenattributes {
class TermToBytesRefAttribute;
}
namespace miscellaneous {
class ConcatenateGraphFilter$BytesRefBuilderTermAttribute;
}
}
}
}
}
template<class T> class JArray;
namespace org {
namespace apache {
namespace lucene {
namespace analysis {
namespace miscellaneous {
class ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl : public ::org::apache::lucene::util::AttributeImpl {
public:
enum {
mid_init$_8e1955e8a9db094a,
mid_builder_46ecb10fc67fc51b,
mid_clear_8e1955e8a9db094a,
mid_clone_8739924785ce34a1,
mid_copyTo_be2b860579c88c21,
mid_getBytesRef_74802edf7c1e9c5f,
mid_reflectWith_6fbf813cd5ff02c8,
mid_toUTF16_2b3ab98bab26f600,
max_mid
};
static ::java::lang::Class *class$;
static jmethodID *mids$;
static bool live$;
static jclass initializeClass(bool);
explicit ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl(jobject obj) : ::org::apache::lucene::util::AttributeImpl(obj) {
if (obj != NULL && mids$ == NULL)
env->getClass(initializeClass);
}
ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl(const ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl& obj) : ::org::apache::lucene::util::AttributeImpl(obj) {}
ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl();
::org::apache::lucene::util::BytesRefBuilder builder() const;
void clear() const;
::org::apache::lucene::util::AttributeImpl clone() const;
void copyTo(const ::org::apache::lucene::util::AttributeImpl &) const;
::org::apache::lucene::util::BytesRef getBytesRef() const;
void reflectWith(const ::org::apache::lucene::util::AttributeReflector &) const;
::java::lang::CharSequence toUTF16() const;
};
}
}
}
}
}
#include <Python.h>
namespace org {
namespace apache {
namespace lucene {
namespace analysis {
namespace miscellaneous {
extern PyType_Def PY_TYPE_DEF(ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl);
extern PyTypeObject *PY_TYPE(ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl);
class t_ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl {
public:
PyObject_HEAD
ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl object;
static PyObject *wrap_Object(const ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl&);
static PyObject *wrap_jobject(const jobject&);
static void install(PyObject *module);
static void initialize(PyObject *module);
};
}
}
}
}
}
#endif
| [
"prateek16068@iiitd.ac.in"
] | prateek16068@iiitd.ac.in |
d35675548bdee5ec0fcf5ea117e4f167508eb9d7 | 3061616f02bf4a660c1e8f2d68768144f7ef0dd2 | /libraries/StreamUtils/src/StreamUtils/Policies/ReadBufferingPolicy.hpp | 2135ee04995d4a0ac0361dd74adfd4af68ac4f72 | [
"MIT"
] | permissive | the-magister/winetemp | 2cf32d9ee81d79f00465bfd6b13ffaf779747cdf | a9cfafc8315baa848fc7d1f43d503a13cbeb8e2f | refs/heads/main | 2023-07-25T17:44:50.746567 | 2021-09-04T20:12:54 | 2021-09-04T20:12:54 | 306,952,984 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,519 | hpp | // StreamUtils - github.com/bblanchon/ArduinoStreamUtils
// Copyright Benoit Blanchon 2019-2020
// MIT License
#pragma once
#include <Stream.h>
#include "../Buffers/LinearBuffer.hpp"
namespace StreamUtils {
template <typename TAllocator>
struct ReadBufferingPolicy {
ReadBufferingPolicy(size_t capacity, TAllocator allocator = TAllocator())
: _buffer(capacity, allocator) {}
ReadBufferingPolicy(const ReadBufferingPolicy &other)
: _buffer(other._buffer) {}
int available(Stream &stream) {
return stream.available() + _buffer.available();
}
template <typename TTarget> // Stream or Client
int read(TTarget &target) {
if (!_buffer)
return target.read();
reloadIfEmpty(target);
return isEmpty() ? -1 : _buffer.read();
}
int peek(Stream &stream) {
return isEmpty() ? stream.peek() : _buffer.peek();
}
template <typename TTarget> // Stream or Client
size_t readBytes(TTarget &target, char *buffer, size_t size) {
if (!_buffer)
return readDirectly(target, buffer, size);
size_t result = 0;
// can we read from buffer?
if (_buffer.available() > 0) {
size_t bytesRead = _buffer.readBytes(buffer, size);
result += bytesRead;
buffer += bytesRead;
size -= bytesRead;
}
// still something to read?
if (size > 0) {
// (at this point, the buffer is empty)
// should we use the buffer?
if (size < _buffer.capacity()) {
reload(target);
size_t bytesRead = _buffer.readBytes(buffer, size);
result += bytesRead;
} else {
// we can bypass the buffer
result += readDirectly(target, buffer, size);
}
}
return result;
}
size_t read(Client &client, uint8_t *buffer, size_t size) {
return readBytes(client, reinterpret_cast<char *>(buffer), size);
}
private:
size_t readDirectly(Client &client, char *buffer, size_t size) {
return client.read(reinterpret_cast<uint8_t *>(buffer), size);
}
size_t readDirectly(Stream &stream, char *buffer, size_t size) {
return stream.readBytes(buffer, size);
}
bool isEmpty() const {
return _buffer.available() == 0;
}
template <typename TTarget> // Stream or Client
void reloadIfEmpty(TTarget &target) {
if (!isEmpty())
return;
reload(target);
}
template <typename TTarget> // Stream or Client
void reload(TTarget &target) {
_buffer.reloadFrom(target);
}
LinearBuffer<TAllocator> _buffer;
};
} // namespace StreamUtils | [
"magister@the-magister.com"
] | magister@the-magister.com |
4969404a3aceeadeb3a03a6c5f27f6c4fcbd845d | 40d4abdad885b3c2c53534885dc2fcf8752d8874 | /Homework/Assignment 3/Gaddis_8thEdition_Ch4_Prob22_Freezing_and_Boiling_Points/main.cpp | 96ae2bf09e9cd04835bd4f10cda8af6bc61081e8 | [] | no_license | ws2493126/SpencerWesley_CISCSC5_Spring2018 | 820651be334c58d4c0728b1eca38ab5bf1772764 | 9178a6b6069c82122f34b4d2584cc668b63bf8fa | refs/heads/master | 2021-09-13T02:52:37.976514 | 2018-04-24T04:12:29 | 2018-04-24T04:12:29 | 123,743,917 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,449 | cpp | /*
* File: main.cpp
* Author: Wesley Spencer
* Created on March 20, 2018, 3:00 PM
* Purpose: To figure out which substances will freeze and boil
* at temperatures determined by user input.
*/
//System Libraries
#include <iostream> //I/O Library -> cout,endl
using namespace std;//namespace I/O stream library created
//User Libraries
//Global Constants
//Math, Physics, Science, Conversions, 2-D Array Columns
//Function Prototypes
//Execution Begins Here!
int main(int argc, char** argv) {
//Declare Variables
float frzalc=-173, //Freezing point of Ethyl Alcohol
frzmrc=-38, //Freezing point of Mercury
frzoxy=-362, //Freezing point of Oxygen
frzwtr=32, //Freezing point of Water
boilalc=172, //Boiling point of Alcohol
boilmrc=676, //Boiling point of Mercury
boiloxy=-306, //Boiling point of Oxygen
boilwtr=212, //Boiling point of Water
temp; //Temperature inputted by user
//Ask for Input
cout<<"This program can determine what substance freezes and boils at the"
<<endl<<"temperature inputted by the user."<<endl;
cout<<"Available Substances: Ethyl Alcohol, Mercury, Oxygen, Water"<<endl;
cout<<" "<<endl;
cout<<"Please input the temperature of your choice."<<endl;
cin>>temp;
//Map/Process Inputs to Outputs
{
if (temp<=frzoxy)
cout<<"Oxygen will freeze at that temperature."<<endl;
else if (temp<=frzalc)
cout<<"Ethyl Alcohol will freeze at that temperature."<<endl;
else if (temp<=frzmrc)
cout<<"Mercury will freeze at that temperature."<<endl;
else if (temp<=frzwtr)
cout<<"Water will freeze at that temperature."<<endl;
else
cout<<"None of the substances will freeze at that temperature."<<endl;
}
{
if (temp>=boilmrc)
cout<<"Mercury will boil at that temperature."<<endl;
else if (temp>=boilwtr)
cout<<"Water will boil at that temperature."<<endl;
else if (temp>=boilalc)
cout<<"Ethyl Alcohol will boil at that temperature."<<endl;
else if (temp>=boiloxy)
cout<<"Oxygen will boil at that temperature."<<endl;
else
cout<<"None of the substances will boil at that temperature."<<endl;
}
//Display Outputs
//Exit program!
return 0;
} | [
"gubby69240@yahoo.com"
] | gubby69240@yahoo.com |
aa02521bb70796d3c35e96e9579aa1abdab26d9e | 7d318857145acc95577e02f92ae42792d3f9468e | /common/AppsInfoProvider.cc | 1e5ff49bc7e2bec839de369ce6f938daf22401f1 | [
"Apache-2.0"
] | permissive | icprog/cell-phone-ux-demo | 238011e6d9f7fa667e13a3643911baeeab97ce3d | 63a6036c28bb4840eab6f0f1f3a62900d0064007 | refs/heads/master | 2020-03-29T02:14:23.069165 | 2018-07-29T06:45:21 | 2018-07-29T06:45:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,265 | cc | /*! ============================================================================
* @file AppsInfoProvider.cc
* @Synopsis
* @author DongKai
* @version 1.0
* Company: Beijing Feynman Software Technology Co., Ltd.
*/
#include <sstream>
#include "global.h"
#include "AppsInfoProvider.hh"
const char* AppsInfoProvider::CONTENT_URI = SYSTEM_CONTENT_HEAD "apps";
const char* AppsInfoProvider::DB_NAME = SYSTEM_DB_NAME;
const char* AppsInfoProvider::TABLE_NAME = "apps";
const char* AppsInfoProvider::COL_ID = "_ID";
const char* AppsInfoProvider::COL_APP_ACTIVITY = "activity";
const char* AppsInfoProvider::COL_APP_NAME = "name";
const char* AppsInfoProvider::COL_APP_ICON = "icon";
AppsInfoProvider::AppsInfoProvider() :
SQLiteProvider(DB_NAME)
{
std::stringstream sql_cmd;
sql_cmd << "CREATE TABLE " << TABLE_NAME << "(" <<
COL_ID << " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," <<
COL_APP_ACTIVITY << " TEXT," <<
COL_APP_NAME << " TEXT," <<
COL_APP_ICON << " TEXT" <<
");";
#ifdef DEBUG
printf ("AppsInfoProvider................\n");
#endif
m_db.execSQL(sql_cmd.str());
}
AppsInfoProvider::~AppsInfoProvider()
{
#ifdef DEBUG
printf ("~AppsInfoProvider................\n");
#endif
}
| [
"vincent@minigui.org"
] | vincent@minigui.org |
e14d1de807be00e4c182b9b9b1af1d08e5659f14 | ef268924e126f127eadbc82a709acfdaeb505925 | /0053. Maximum Subarray/53_kadane.cpp | a827c456eb422cc2a09921fb8481b63118538d8c | [] | no_license | HappyStorm/LeetCode-OJ | e7dec57156b67886cbb57dc6401b2164eaed7476 | 8e742bc66a70900bbb7bc0bd740cec6092577a6a | refs/heads/master | 2022-08-30T11:40:57.658447 | 2022-08-09T16:59:49 | 2022-08-09T16:59:49 | 55,757,963 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 564 | cpp | class Solution {
public:
int maxSubArray(vector<int>& nums) {
int ans = 0, sub_sum = 0, max_n = nums[0];
bool all_neg = true;
for(auto const &n: nums){
if(n>=0){
all_neg = false;
sub_sum += n;
}
else{
if(sub_sum >= -n)
sub_sum += n;
else
sub_sum = 0;
}
ans = max(ans, sub_sum);
max_n = max(max_n, n);
}
return !all_neg ? ans : max_n;
}
};
| [
"gogogo753951741963@gmail.com"
] | gogogo753951741963@gmail.com |
18bb342543ca82b17f827aec9138763fea368060 | 7b78593b9cc102b83e9c1f422ceec000eece42a4 | /Project1/debugging1.cpp | 65f6054bec85b4c6e54c38d7878c90720f5cc7f5 | [] | no_license | SongJungHyun1004/NewProject | 9bc4e64ae667b594dbe539f674fbf1967bc7f5b3 | f8b0a54981af67df1df3388738066989d946856e | refs/heads/master | 2023-07-24T12:20:31.307281 | 2021-09-03T08:33:47 | 2021-09-03T08:33:47 | 402,261,325 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 238 | cpp | #include <iostream>
class LetDebug
{
public:
void printNum()
{
short s1 = 32767;
short s2 = 1;
int s3 = (int)s1 + s2;
std::cout << s3 << std::endl;
}
};
int main()
{
LetDebug* ld = new LetDebug;
ld->printNum();
return 0;
} | [
"201802112@o.cnu.ac.kr"
] | 201802112@o.cnu.ac.kr |
8ca8d8c351b86f36017f6de4a595ec45a30f9bc1 | 57bf70cabc8c107edbf3cf2be42203bcf7d1da65 | /AOIs/Tests/EuDistance_XYList.cpp | f162e7702ebb6300a49670e18dfa04422ab83eb9 | [] | no_license | tmp-reg/AOIs | 9bb33bd891f37c98ea3f9fe24f3274cdb98cab6b | b9f70b01ef92d42d92379943b9342f0d93ff0ebc | refs/heads/master | 2021-01-21T10:38:03.479485 | 2016-05-21T06:35:17 | 2016-05-21T06:35:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,166 | cpp | //
// test.cpp
// AOIs
//
// Created by zklgame on 4/8/16.
// Copyright © 2016 Zhejiang University. All rights reserved.
//
#include "../GameBasics/GameWorld.hpp"
#include "../AOIServices/EuDistanceAOIService.hpp"
#include "../AOIServices/XYListAOIService.hpp"
#include <iostream>
#include <vector>
using namespace std;
int main1() {
// create object data
entity_t objectNum = 10000;
entity_t movedNum = 5000;
entity_t leaveNum = 2000;
vector<GameObject *> gameObjects, gameObjectsCopy2;
vector<GameObject *> MovedgameObjects1, MovedgameObjects2;
vector<GameObject *> leavedObjects1, leavedObjects2;
vector<int> movedPosX;
vector<int> movedPosY;
entity_t id;
type_t type;
position_t posX, posY, range;
position_t maxRange = 200;
srand((int)time(0));
for (int i = 0; i < objectNum; i ++) {
type = rand() % 3 + 1;
posX = rand() % 10000;
posY = rand() % 10000;
range = rand() % maxRange;
GameObject *obj = new GameObject(i, type, posX, posY, range);
GameObject *obj2 = new GameObject(i, type, posX, posY, range);
gameObjects.push_back(obj);
gameObjectsCopy2.push_back(obj2);
}
srand((int)time(0));
for (int i = 0; i < movedNum; i ++) {
id = rand() % objectNum;
MovedgameObjects1.push_back(gameObjects[id]);
MovedgameObjects2.push_back(gameObjectsCopy2[id]);
movedPosX.push_back(rand() % 500);
movedPosY.push_back(rand() % 500);
}
srand((int)time(0));
for (int i = 0; i < leaveNum; i ++) {
id = rand() % objectNum;
leavedObjects1.push_back(gameObjects[id]);
leavedObjects2.push_back(gameObjectsCopy2[id]);
}
GameWorld *world1 = new GameWorld();
world1 -> aoi = new EuDistanceAOIService();
GameWorld * world2 = new GameWorld();
world2 -> aoi = new XYListAOIService();
//////////////////////
// test addObject
//////////////////////
vector<GameObject *>::iterator iter;
for (iter = gameObjects . begin(); iter != gameObjects . end(); iter ++) {
world1 -> addObject(*iter);
}
for (iter = gameObjectsCopy2 . begin(); iter != gameObjectsCopy2 . end(); iter ++) {
world2 -> addObject(*iter);
}
bool isAddRight = true;
for (int i = 0; i < objectNum; i ++) {
if (gameObjects[i] -> messageNum == gameObjectsCopy2[i] -> messageNum &&
gameObjects[i] -> addMessageNum == gameObjectsCopy2[i] -> addMessageNum &&
gameObjects[i] -> leaveMessageNum == gameObjectsCopy2[i] -> leaveMessageNum &&
gameObjects[i] -> moveMessageNum == gameObjectsCopy2[i] -> moveMessageNum) {
} else {
cout << "isAddRight : FALSE!!! at " << i << endl << endl;
isAddRight = false;
return 1;
}
}
cout << "??????????????????????????????????" << endl;
cout << "ADD OBJECT PASS" << endl;
cout << "??????????????????????????????????" << endl << endl;
//////////////////////
// test moveObject
//////////////////////
for (int i = 0; i < MovedgameObjects1.size(); i ++) {
MovedgameObjects1[i] -> move(movedPosX[i], movedPosY[i]);
}
for (int i = 0; i < MovedgameObjects2.size(); i ++) {
MovedgameObjects2[i] -> move(movedPosX[i], movedPosY[i]);
}
bool isMoveRight = true;
for (int i = 0; i < objectNum; i ++) {
if (gameObjects[i] -> messageNum == gameObjectsCopy2[i] -> messageNum &&
gameObjects[i] -> addMessageNum == gameObjectsCopy2[i] -> addMessageNum &&
gameObjects[i] -> leaveMessageNum == gameObjectsCopy2[i] -> leaveMessageNum &&
gameObjects[i] -> moveMessageNum == gameObjectsCopy2[i] -> moveMessageNum) {
} else {
cout << "isMoveRight : FALSE!!! at " << i << endl << endl;
isMoveRight = false;
return 1;
}
}
cout << "??????????????????????????????????" << endl;
cout << "MOVE OBJECT PASS" << endl;
cout << "??????????????????????????????????" << endl << endl;
//////////////////////
// test removeObject
//////////////////////
for (int i = 0; i < leavedObjects1.size(); i ++) {
world1 -> removeObject(leavedObjects1[i]);
}
for (int i = 0; i < leavedObjects2.size(); i ++) {
world2 -> removeObject(leavedObjects2[i]);
}
bool isRemoveRight = true;
for (int i = 0; i < objectNum; i ++) {
if (gameObjects[i] -> messageNum == gameObjectsCopy2[i] -> messageNum &&
gameObjects[i] -> addMessageNum == gameObjectsCopy2[i] -> addMessageNum &&
gameObjects[i] -> leaveMessageNum == gameObjectsCopy2[i] -> leaveMessageNum &&
gameObjects[i] -> moveMessageNum == gameObjectsCopy2[i] -> moveMessageNum) {
} else {
cout << "isRemoveRight : FALSE!!! at " << i << endl << endl;
isRemoveRight = false;
return 1;
}
}
cout << "??????????????????????????????????" << endl;
cout << "REMOVE OBJECT PASS" << endl;
cout << "??????????????????????????????????" << endl << endl;
delete world1 -> aoi;
delete world1;
delete world2 -> aoi;
delete world2;
return 0;
}
// 出错测试代码,勿删!!!!!
//{
// map<entity_t, entity_t> ids1, ids2;
// list<entity_t> ids;
// cout << "gameObjects: " << endl;
// cout << gameObjects[i] -> id << " | " << uint16_t(gameObjects[i] -> type) << " | " << gameObjects[i] -> posX << " | " << gameObjects[i] -> posY << " | " << gameObjects[i] -> range << " | " << gameObjects[i] -> messageNum << " | " << gameObjects[i] -> addMessageNum << " | " << gameObjects[i] -> moveMessageNum << " | " << gameObjects[i] -> leaveMessageNum << endl;
//
// // cout << "addMsg: " << endl;
// // for (int j = 0; j < gameObjects[i] -> addMessageDetail . size(); j ++) {
// // entity_t id = gameObjects[i] -> addMessageDetail[j];
// // cout << id << " | ";
// // }
// // cout << endl;
// // cout << "removeMsg: " << endl;
// // for (int j = 0; j < gameObjects[i] -> removeMessageDetail . size(); j ++) {
// // entity_t id = gameObjects[i] -> removeMessageDetail[j];
// // cout << id << " | ";
// // ids1[id] = id;
// // }
// // cout << endl << endl;
//
// cout << "gameObjectsCopy2: " << endl;
// cout << gameObjectsCopy2[i] -> id << " | " << uint16_t(gameObjectsCopy2[i] -> type) << " | " << gameObjectsCopy2[i] -> posX << " | " << gameObjectsCopy2[i] -> posY << " | " << gameObjectsCopy2[i] -> range << " | " << gameObjectsCopy2[i] -> messageNum << " | " << gameObjectsCopy2[i] -> addMessageNum << " | " << gameObjectsCopy2[i] -> moveMessageNum << " | " << gameObjectsCopy2[i] -> leaveMessageNum << endl;
//
// // cout << "addMsg: " << endl;
// // for (int j = 0; j < gameObjectsCopy2[i] -> addMessageDetail . size(); j ++) {
// // entity_t id = gameObjectsCopy2[i] -> addMessageDetail[j];
// // cout << id << " | ";
// // }
// // cout << endl;
// // cout << "removeMsg: " << endl;
// // for (int j = 0; j < gameObjectsCopy2[i] -> removeMessageDetail . size(); j ++) {
// // entity_t id = gameObjectsCopy2[i] -> removeMessageDetail[j];
// // cout << id << " | ";
// // ids2[id] = id;
// // }
// // cout << endl << endl;
//
// map<entity_t, entity_t>::iterator iter;
// for (iter = ids1.begin(); iter != ids1.end(); iter ++) {
// if (ids2.find(iter -> first) != ids2.end()) {
// ids2.erase(iter -> second);
// } else {
// ids.push_back(iter -> second);
// }
// }
// if (ids2.size() > 0) {
// for (iter = ids2.begin(); iter != ids2.end(); iter ++) {
// ids.push_back(iter -> second);
// }
// }
//
// // cout << "XXXXXXXXXXXX" << endl << endl;
// // list<entity_t>::iterator iterList;
// // for (iterList = ids.begin(); iterList != ids.end(); iterList ++) {
// // entity_t pos = (*iterList);
// // cout << pos << ": " << uint16_t(gameObjectsCopy2[pos] -> type) << " | " << gameObjectsCopy2[pos] -> posX << " | " << gameObjectsCopy2[pos] -> posY << " | " << gameObjectsCopy2[pos] -> range << endl;
// //
// // world2 -> addObject(gameObjectsCopy2[i]);
// // list<GameObject *>::iterator haha = gameObjectsCopy2[i] -> listPosX;
// // world2 -> removeObject(gameObjectsCopy2[i]);
// // // world2 -> aoi -> aoi -> findPublishersInRange(gameObjectsCopy2[i], REMOVE_MESSAGE);
// // cout << "gameObjectsCopy2: " << endl;
// // cout << gameObjectsCopy2[i] -> id << " | " << uint16_t(gameObjectsCopy2[i] -> type) << " | " << gameObjectsCopy2[i] -> posX << " | " << gameObjectsCopy2[i] -> posY << " | " << gameObjectsCopy2[i] -> range << " | " << gameObjectsCopy2[i] -> messageNum << " | " << gameObjectsCopy2[i] -> addMessageNum << " | " << gameObjectsCopy2[i] -> moveMessageNum << " | " << gameObjectsCopy2[i] -> leaveMessageNum << endl;
// // for (int j = 0; j < gameObjectsCopy2[i] -> removeMessageDetail . size(); j ++) {
// // entity_t id = gameObjectsCopy2[i] -> removeMessageDetail[j];
// // cout << id << " | ";
// // }
// //
// //
// //
// // cout << endl << endl;
// //
// // }
// }
| [
"chikanebest@163.com"
] | chikanebest@163.com |
752843bca22cf73ceb01aa1ab909018ee59fd550 | 5c6f0fecb37e39a8c837e9322c88fe28abb28666 | /visualizer/build/dependencies/GL_platform_tools/include/GL/platform/Application.h | cba0c64818e7a55789956693e8f6f8cdbfe7a3ef | [
"MIT"
] | permissive | GPUPeople/vertex_batch_optimization | d02a900d2b16aab009f1ca0997422b8f06ae9969 | 46332cd9f576eb6a464a96d5214cbce7d0319a6b | refs/heads/master | 2020-03-21T19:11:51.205073 | 2019-04-19T10:52:43 | 2019-04-19T10:52:43 | 138,934,693 | 26 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 512 | h |
#ifndef INCLUDED_GL_PLATFORM_APPLICATION
#define INCLUDED_GL_PLATFORM_APPLICATION
#pragma once
#include "Renderer.h"
#if defined(_WIN32)
#include "../../../source/win32/Win32GLApplication.h"
namespace GL::platform
{
using Win32::GL::run;
using Win32::GL::quit;
}
#elif defined(__gnu_linux__)
#include "../../../source/x11/X11GLApplication.h"
namespace GL::platform
{
using X11::GL::run;
using X11::GL::quit;
}
#else
#error "platform not supported."
#endif
#endif // INCLUDED_GL_PLATFORM_APPLICATION
| [
"michael.kenzel@gmail.com"
] | michael.kenzel@gmail.com |
4bf0e64ad774e92a97a331947464f46c87f88779 | fd7223bfc36dfec1513abf9b0f8d8aef5f17956d | /Gunz/Stable/CSCommon/Include/MMatchRuleDeathMatch.h | 363efb093174a3b903b4fd17e5b43d8e0c0aa725 | [] | no_license | tehKaiN/node3d | 6ca77ecb54a978d563a1e2fbafb70b75112193f7 | b5a6c33986b4791fb5201cb30e6fbcb26b7eac4d | refs/heads/master | 2020-09-01T17:44:45.291690 | 2018-10-17T08:58:25 | 2018-10-17T08:58:25 | null | 0 | 0 | null | null | null | null | WINDOWS-1256 | C++ | false | false | 2,252 | h | #ifndef _MMATCHRULE_DEATHMATCH_H
#define _MMATCHRULE_DEATHMATCH_H
#include "MMatchRule.h"
class MMatchRuleSoloDeath : public MMatchRule {
protected:
bool CheckKillCount(MMatchObject* pOutObject);
virtual void OnBegin();
virtual void OnEnd();
virtual void OnRoundTimeOut();
virtual bool OnCheckRoundFinish();
virtual bool RoundCount();
public:
MMatchRuleSoloDeath(MMatchStage* pStage);
virtual ~MMatchRuleSoloDeath() { }
virtual MMATCH_GAMETYPE GetGameType() { return MMATCH_GAMETYPE_DEATHMATCH_SOLO; }
};
///////////////////////////////////////////////////////////////////////////////////////////////
class MMatchRuleTeamDeath : public MMatchRule {
protected:
bool GetAliveCount(int* pRedAliveCount, int* pBlueAliveCount);
virtual void OnBegin();
virtual void OnEnd();
virtual bool OnRun();
virtual void OnRoundBegin();
virtual void OnRoundEnd();
virtual bool OnCheckRoundFinish();
virtual void OnRoundTimeOut();
virtual bool RoundCount();
virtual bool OnCheckEnableBattleCondition();
public:
MMatchRuleTeamDeath(MMatchStage* pStage);
virtual ~MMatchRuleTeamDeath() {}
virtual void CalcTeamBonus(MMatchObject* pAttacker, MMatchObject* pVictim,
int nSrcExp, int* poutAttackerExp, int* poutTeamExp);
virtual MMATCH_GAMETYPE GetGameType() { return MMATCH_GAMETYPE_DEATHMATCH_TEAM; }
};
// أك°، by µ؟¼·
///////////////////////////////////////////////////////////////////////////////////////////////
class MMatchRuleTeamDeath2 : public MMatchRule {
protected:
void GetTeamScore(int* pRedTeamScore, int* pBLueTeamScore);
virtual void OnBegin();
virtual void OnEnd();
virtual bool OnRun();
virtual void OnRoundBegin();
virtual void OnRoundEnd();
virtual bool OnCheckRoundFinish();
virtual void OnRoundTimeOut();
virtual bool RoundCount();
virtual void OnGameKill(const MUID& uidAttacker, const MUID& uidVictim);
public:
MMatchRuleTeamDeath2(MMatchStage* pStage);
virtual ~MMatchRuleTeamDeath2() {}
virtual void CalcTeamBonus(MMatchObject* pAttacker, MMatchObject* pVictim,
int nSrcExp, int* poutAttackerExp, int* poutTeamExp);
virtual MMATCH_GAMETYPE GetGameType() { return MMATCH_GAMETYPE_DEATHMATCH_TEAM2; }
};
#endif | [
"huihui27@126.com@2d1ece96-c13f-8cac-2818-407c75b61fa3"
] | huihui27@126.com@2d1ece96-c13f-8cac-2818-407c75b61fa3 |
3dc491ad5a12eb77c0ef4665993818a69fb2c445 | 686b91fb3b0c647f675dad7bf542fec25f497273 | /backend/ASTVisitor/src/FunctionChecker/functionChecker.h | 7d6c4c33139c52e3ab03edb8bebcf2a0086f36ad | [] | no_license | Lautstark9217/SEexperiement | 3180c98912e26c29506ddf4f64be494d9a1ac2ba | 48c9c81bcbf95deefef58a04f7e23300f2209d25 | refs/heads/master | 2022-11-11T16:56:14.813234 | 2020-07-04T03:19:22 | 2020-07-04T03:19:22 | 263,796,604 | 0 | 1 | null | 2020-05-20T09:01:31 | 2020-05-14T02:37:16 | Java | UTF-8 | C++ | false | false | 1,697 | h | #include "func.h"
using FCMap = std::map<std::string, SPAFunc *>;
class FuncChecker
{
/*
* class FuncChecker
* 作者:刘浩文
* 配合spafunc进行过程间函数分析的类
* 内部维护一个指向正在定义的函数的指针,它的名字以及一个名字-函数指针的KVmap
*/
public:
/*
* 构造函数
*/
FuncChecker();
/*
* 拷贝构造函数不符合逻辑也没有实际的用途,通知编译器禁用
*/
FuncChecker(const FuncChecker &fc) = delete;
/*
* AST遍历进入一个函数,更换当前的函数名,并且KVmap新增内容
* @param funcName 新函数的名称
* @param pm 这个函数的指针参数列表
*/
void stepInFunc(std::string funcName, std::vector<std::string> pm);
/*
* 给当前正在处理的函数的某个指针参数设置为null或已释放
* @param pname 待处理的指针参数的名字
*/
void setProcFuncPtrFreeByName(std::string pname);
void setProcFuncPtrNullByName(std::string pname);
/*
* 确认在其他函数调用时,确定某个参数位置是不是会在这个函数内部被置为null或被释放
* @param fname 调用函数的名字
* @param index 第几个参数
*/
bool isFuncParamNullByFuncNameAndIndex(std::string fname, int index);
bool isFuncParamFreeByFuncNameAndIndex(std::string fname, int index);
/*
* 查看正在处理的函数是不是有符合这个名字的参数
* @param name 查询的参数名字
*/
bool isProcFuncHasParam(std::string name);
private:
SPAFunc *processingFunc;
std::string curFuncName;
FCMap fcMap;
}; | [
"naws_9217@outlook.com"
] | naws_9217@outlook.com |
487d8643fa712bfe717b81d7f72c4e2e5394dd93 | e1578523531276a57b6a391919ca968eeef85398 | /thermo/Unused Code/point.h | 877ba3545b0086e7347401fd3e5ad9fc511948ac | [] | no_license | rohdesamuel/Thermo | cd6c01b2aded3cecf12122d5bfcf170a33c61922 | 5291c7ccc8d503ef5c4a9d74495eb239176dd63a | refs/heads/master | 2016-09-06T04:03:02.693712 | 2013-12-13T19:24:28 | 2013-12-13T19:24:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,557 | h | #ifndef POINT__H
#define POINT__H
#include "bitset.h"
#include "edge.h"
using namespace std;
template <int Dim>
class Point
{
public:
Point() { };
Point(Bitset<Dim> && Data):__data(Data) { };
typedef typename Bitset<Dim>::iterator iterator;
int size(){return __data.count(); };
int distance(const Point & point) const;
int distance(const Point * point) const;
int similarity(const Point & point) const;
int similarity(const Point * point) const;
bool get(int i);
void set(int i, bool value);
void flip(int i);
void clear();
iterator begin(){ return __data.begin(); };
iterator end(){ return __data.end(); };
private:
Bitset<Dim> __data;
};
template <int Dim>
void Point<Dim>::set(int i, bool value)
{
__data(i, value);
}
template <int Dim>
bool Point<Dim>::get(int i)
{
return __data(i);
}
template <int Dim>
void Point<Dim>::flip(int i)
{
__data.flip(i);
}
template <int Dim>
void Point<Dim>::clear()
{
__data.clear();
}
template <int Dim>
inline int Point<Dim>::distance(const Point & point) const
{
return __data.distance(point.__data);
}
template <int Dim>
inline int Point<Dim>::distance(const Point * point) const
{
if (point)
return __data.distance(point->__data);
else
return -1;
}
template <int Dim>
inline int Point<Dim>::similarity(const Point & point) const
{
if (point)
return __data.similarity(point.__data);
else
return -1;
}
template <int Dim>
inline int Point<Dim>::similarity(const Point * point) const
{
if (point)
return __data.similarity(point->__data);
else
return -1;
}
#endif | [
"rohde.samuel@gmail.com"
] | rohde.samuel@gmail.com |
7a2223971f20d3856a9fdccd72b68280172910b1 | 5e8d200078e64b97e3bbd1e61f83cb5bae99ab6e | /main/source/src/core/chemical/icoor_support.hh | d1fd126cf4103f04b956358c26ed87dfef5f5c4c | [] | no_license | MedicaicloudLink/Rosetta | 3ee2d79d48b31bd8ca898036ad32fe910c9a7a28 | 01affdf77abb773ed375b83cdbbf58439edd8719 | refs/heads/master | 2020-12-07T17:52:01.350906 | 2020-01-10T08:24:09 | 2020-01-10T08:24:09 | 232,757,729 | 2 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 1,497 | hh | // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
// vi: set ts=2 noet:
//
// (c) Copyright Rosetta Commons Member Institutions.
// (c) This file is part of the Rosetta software suite and is made available under license.
// (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
// (c) For more information, see http://www.rosettacommons.org. Questions about this can be
// (c) addressed to University of Washington CoMotion, email: license@uw.edu.
/// @file core/chemical/icoor_support.hh
/// @author Rocco Moretti (rmorettiase@gmail.com)
#ifndef INCLUDED_core_chemical_icoor_support_hh
#define INCLUDED_core_chemical_icoor_support_hh
// Project headers
#include <core/chemical/ResidueType.fwd.hh>
#include <core/chemical/ResidueGraphTypes.hh>
#include <core/kinematics/tree/Atom.fwd.hh>
#include <map>
namespace core {
namespace chemical {
//The core::kinematics::tree::Atom objects take care of the internal/xyz exchange.
//We just need to chain them together appropriately.
typedef std::map< core::chemical::VD, core::kinematics::tree::AtomOP > VdTreeatomMap;
class RerootRestypeVisitor;
class RerootEdgeSorter;
void
reroot_restype(
core::chemical::ResidueType & restype,
core::chemical::ResidueGraph const & graph,
core::chemical::VD root);
void
fill_ideal_xyz_from_icoor(
core::chemical::ResidueType & restype,
core::chemical::ResidueGraph const & graph);
} // chemical
} // core
#endif
| [
"36790013+MedicaicloudLink@users.noreply.github.com"
] | 36790013+MedicaicloudLink@users.noreply.github.com |
9fed919026bc77dbf91bf24ab7f7d0665e91d6db | 72f29a1f42739b1f4d03515e6c23d541ccc2a482 | /src/np/knights_tour.h | 240772f22abe1bfd258b80864eb892a6b104ef9f | [
"Apache-2.0"
] | permissive | zpooky/sputil | ec09ef1bb3d9fe9fac4e2d174729515672bef50a | 30d7f0b2b07cecdc6657da30cf5c4ba52a9ed240 | refs/heads/master | 2022-08-27T09:13:06.982435 | 2022-08-10T20:41:49 | 2022-08-10T20:42:35 | 116,656,968 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,790 | h | #ifndef SP_UTIL_NP_KNIGHTS_TOUR_H
#define SP_UTIL_NP_KNIGHTS_TOUR_H
#include <cstddef>
#include <util/Matrix.h>
// TODO not sure if this is np
// http://ispython.com/knights-tour/
namespace np {
/* # Knight's Tour
* Given a $n*$n chess board, the starting position x:0,y:0. Using the chess
* piece knight(horse) move to every position of the board without vesting the
* same position twice.
*
* _ _
* |
* |__|__|
* | | |
* _|_
*
* Example solution for 5x5 where `00` is the start position.
* 00 03 10 15 24
* 11 16 01 04 09
* 02 19 06 23 14
* 17 12 21 08 05
* 20 07 18 13 22
*/
typedef void (*knights_tour_cb)(const sp::Matrix<int> &board, void *);
/* recursive, backtracking
* Result is a matrix where is entry contains the jump number of the knight:
*/
// TODO not sure if this is working...
std::size_t
knights_tour(std::size_t n, knights_tour_cb, void *closure) noexcept;
namespace graph {
// https://bradfieldcs.com/algos/graphs/knights-tour/
/*
* Using Warnsdorffs Heuristic where vertex with less connecting edges are
* prioritized over vertex with more edges. This optimization is useful when we
* want to find ANY valid solution not all of them. It works by visiting the
* edges of the board(which has less edges since its on the edge of the
* board) before visiting the more central positions. This results that we
* faster discard invalid solutions by first visiting the more harder position
* before the easier central positions.
*
* A edge represents a valid move(for a knight) from a vertex to another vertex.
* The graph is bidirectional since a valid move from a vertex to another can
* be reversed by performing the inverse move.
*/
std::size_t
knights_tour(std::size_t n, knights_tour_cb, void *closure) noexcept;
}
}
#endif
| [
"spooky.bender@gmail.com"
] | spooky.bender@gmail.com |
307cab1fc155cedcb53a2edf2ebcff16cd0c630c | 58ca89bed3d62c713616a35914e536d627203bb4 | /EEShashlikSimulation/H4OpticalSmall_Ideal2016/src/SteppingAction.cc | b7bc1f5d53f46f77ed8f98358b6cbf7d7b1f068d | [] | no_license | nadya-chernyavskaya/geant4 | ceb931a34c2799074785c8db4b37595f02f3fb20 | a1d9b9759bd331185a6eb4d0a748a2fad691612c | refs/heads/master | 2023-02-03T19:39:26.779866 | 2017-09-29T17:47:42 | 2017-09-29T17:47:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,919 | cc | #include "SteppingAction.hh"
#include "common.h"
#include "G4TransportationManager.hh"
#include "G4PropagatorInField.hh"
#include "TMath.h"
#include "CreateTree.h"
using namespace std;
using namespace CLHEP;
//G4double fibre0;
//G4double fibre1;
//G4double fibre2;
//G4double fibre3;
int to_int (string name)
{
int Result ; // int which will contain the result
stringstream convert (name) ;
string dummy ;
convert >> dummy ;
convert >> Result ;
return Result ;
}
//---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
SteppingAction::SteppingAction (EEShashDetectorConstruction* detectorConstruction,
const G4int& scint, const G4int& cher):
fDetectorConstruction(detectorConstruction),
propagateScintillation(scint),
propagateCerenkov(cher)
{}
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
SteppingAction::~SteppingAction ()
{}
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
void SteppingAction::UserSteppingAction (const G4Step * theStep)
{
G4Track* theTrack = theStep->GetTrack () ;
G4int trackID = theTrack->GetTrackID();
TrackInformation* theTrackInfo = (TrackInformation*)(theTrack->GetUserInformation());
G4ParticleDefinition* particleType = theTrack->GetDefinition () ;
//Pre point = first step in a volume
//PostStep point identifies step out of volume
G4StepPoint * thePrePoint = theStep->GetPreStepPoint () ;
// G4StepPoint * thePostPoint = theStep->GetPostStepPoint () ;
const G4ThreeVector & thePrePosition = thePrePoint->GetPosition () ;
G4VPhysicalVolume * thePrePV = thePrePoint->GetPhysicalVolume () ;
// G4VPhysicalVolume * thePostPV = thePostPoint->GetPhysicalVolume () ;
G4String thePrePVName = "" ;
if ( thePrePV ) thePrePVName = thePrePV -> GetName () ;
// G4String thePostPVName = "" ;
// if ( thePostPV ) thePostPVName = thePostPV -> GetName () ;
G4int nStep = theTrack -> GetCurrentStepNumber();
G4TouchableHandle theTouchable = thePrePoint->GetTouchableHandle();
//-------------
// get position
G4double global_x = thePrePosition.x()/mm;
G4double global_y = thePrePosition.y()/mm;
G4double global_z = thePrePosition.z()/mm;
G4TransportationManager* transportMgr ;
transportMgr = G4TransportationManager::GetTransportationManager() ;
G4PropagatorInField * fieldPropagator = transportMgr->GetPropagatorInField() ;
if(nStep>70000){
// std::cout<<"mortacci nstep"<<nStep<<" particle:"<<particleType->GetParticleName()<<" volume:"<<theTrack->GetLogicalVolumeAtVertex()->GetName()<<" id:"<<trackID<<" position:"<<global_x<<" "<<global_y<<" "<<global_z<<" energy:"<<theTrack->GetTotalEnergy()/eV<<std::endl;
theTrack->SetTrackStatus(fStopAndKill);
}
// if(theTrack->GetCreatorProcess() && particleType->GetParticleName()=="gamma") std::cout<<"particle:"<<particleType->GetParticleName()<<" volume:"<<theTrack->GetLogicalVolumeAtVertex()->GetName()<<" id:"<<trackID<<" energy:"<<theTrack->GetTotalEnergy()/eV<<" process:"<<theTrack->GetCreatorProcess()->GetProcessName()<<std::endl;
G4ThreeVector direction=theTrack->GetMomentumDirection();
// std::cout<<"particle: "<<particleType->GetParticleName()<<" step:"<<nStep<<" "<<direction.theta()<<" "<<direction.phi()<<std::endl;
// if(theTrack->GetCreatorProcess()) std::cout<<"particle:"<<particleType->GetParticleName()<<" "<<theTrack->GetCreatorProcess()->GetProcessName()<<" step:"<<nStep<<" "<<direction.theta()<<" "<<direction.phi()<<std::endl;
// optical photon
if( particleType == G4OpticalPhoton::OpticalPhotonDefinition() )
{
G4int copyNo = theTouchable->GetCopyNumber();
G4int motherCopyNo = theTouchable->GetCopyNumber(1);
//FUCK IT Let's just kill them before they bounce that much...
if( nStep>6 && theTrack->GetLogicalVolumeAtVertex()->GetName().contains("Act")){
// theTrack->SetTrackStatus(fKillTrackAndSecondaries);
// std::cout<<"mortacci Act"<<nStep<<" particle:"<<particleType->GetParticleName()<<" volume:"<<theTrack->GetLogicalVolumeAtVertex()->GetName()<<" id:"<<trackID<<" position:"<<global_x<<" "<<global_y<<" "<<global_z<<" energy:"<<theTrack->GetTotalEnergy()/eV<<std::endl;
theTrack->SetTrackStatus(fStopAndKill);
}
G4String processName = theTrack->GetCreatorProcess()->GetProcessName();
//don't track cherenkov photons if they are outside quantum efficiency
float lambdaLowCut=480*1.e-9;
float lambdaUpCut=620*1.e-9;
if(nStep==1 && processName=="Cerenkov"){
float energy=theTrack->GetTotalEnergy()/eV;
float h = 6.62607004*pow(10,-34);
float c = 3*pow(10,8);
float e = 1.60218*pow(10,-19);
float lambda = (h*c)/(energy*e);
if(lambda<lambdaLowCut || lambda>lambdaUpCut ){
theTrack->SetTrackStatus(fStopAndKill);
}
}
//this only for fibre only configuration if(!( theTrack->GetLogicalVolumeAtVertex()->GetName().contains("Fibr") || theTrack->GetLogicalVolumeAtVertex()->GetName().contains("Grease"))) theTrack->SetTrackStatus(fStopAndKill);//kill everything exiting the fibre
/* speeds up simulation but kills a lot of photons i don't know why, in principle should not....
G4ThreeVector direction=theTrack->GetMomentumDirection();
// float totalReflectionAngle=20.4;
float totalReflectionAngle=55;//this is the max angle that will be reflected considering also cladding-air reflection (in fact the correct one is 50.94
float pi=TMath::Pi();
float radTotalReflectionAngle=totalReflectionAngle*pi/180;
float theta=direction.theta();
if(theta>pi/2. && theta<pi) theta=pi-theta;
if(direction.theta()>pi/2.) theTrack->SetTrackStatus(fStopAndKill);//FIXME killing back photons
// if(direction.theta()>pi/2.) std::cout<<"process:"<<processName<<" step:"<<nStep<<" original theta "<<direction.theta()<<" new theta "<<theta<<" "<<direction.phi()<<" "<<radTotalReflectionAngle<<std::endl;
if(nStep==1) if(theta>radTotalReflectionAngle){
// theTrack->SetTrackStatus(fStopAndKill); FIXME!!!!
// std::cout<<"killing"<<std::endl;
}
*/
//----------------------------
// count photons at production in cef3
if( ( theTrack->GetLogicalVolumeAtVertex()->GetName().contains("Act") ) &&
(nStep == 1) && (processName == "Scintillation") )
{
// CreateTree::Instance()->tot_phot_sci += 1;
// if( !propagateScintillation ) theTrack->SetTrackStatus(fKillTrackAndSecondaries);
// fibre0 += 1;
NPhotAct +=1;
}
//count photons entering in the fiber
if( ( theTrack->GetLogicalVolumeAtVertex()->GetName().contains("Core") ) &&
(nStep == 1) && (processName == "OpWLS") )
{
// CreateTree::Instance()->tot_phot_sci += 1;
// if( !propagateScintillation ) theTrack->SetTrackStatus(fKillTrackAndSecondaries);
// fibre0 += 1;
fibreStart0 +=1;
}
//----------------------------
// count photons at fiber exit
if( thePrePVName.contains("Grease")&& copyNo==0 ) {
/*
// Default way of returning is simply MeV's
cout << "Doing theTrack->GetTotalEnergy():" << G4endl;
cout << " theTrack->GetTotalEnergy() = " << theTrack->GetTotalEnergy() << G4endl;
cout << " theTrack->GetMomentum() = " << theTrack->GetMomentum() << G4endl;
cout << " 1 eV = " << eV << G4endl;
cout << " Added to EOpt = " << theTrack->GetTotalEnergy()/eV << G4endl;
*/
EOpt_0+=theTrack->GetTotalEnergy()/eV;
G4ThreeVector directionStart=theTrack->GetVertexPosition();//position at start point
if(processName=="OpWLS"){
}else if(processName=="Scintillation"){
}else if(processName=="Cerenkov"){
}else{
}
fibre0 += 1;
//std::cout << "EOpt_0 = " << EOpt_0 << std::endl;
// CreateTree::Instance()->tot_gap_phot_sci += 1;
// if you do not want to kill a photon once it exits the fiber, comment here below
// theTrack->SetTrackStatus(fKillTrackAndSecondaries);
}
if( thePrePVName.contains("Grease")&& copyNo==1 ) {
EOpt_1+=theTrack->GetTotalEnergy()/eV;
fibre1 += 1;
// CreateTree::Instance()->tot_gap_phot_sci += 1;
// if you do not want to kill a photon once it exits the fiber, comment here below
// theTrack->SetTrackStatus(fKillTrackAndSecondaries);
}
if( thePrePVName.contains("Grease")&& copyNo==2 ) {
EOpt_2+=theTrack->GetTotalEnergy()/eV;
fibre2 += 1;
// CreateTree::Instance()->tot_gap_phot_sci += 1;
// if you do not want to kill a photon once it exits the fiber, comment here below
// theTrack->SetTrackStatus(fKillTrackAndSecondaries);
}
if( thePrePVName.contains("Grease")&& copyNo==3 ) {
EOpt_3+=theTrack->GetTotalEnergy()/eV;
fibre3 += 1;
// CreateTree::Instance()->tot_gap_phot_sci += 1;
// if you do not want to kill a photon once it exits the fiber, comment here below
// theTrack->SetTrackStatus(fKillTrackAndSecondaries);
}
if( thePrePVName.contains("Grease") )
{
// fibre2 += 1;
}
//------------------------------
// count photons at the detector
if( thePrePVName.contains("Grease")&& motherCopyNo ==3 ) //same as if with the prePV == Fibre
{
// fibre3 += 1;
// if you do not want to kill a photon once it enters the detector, comment here below
// theTrack->SetTrackStatus(fKillTrackAndSecondaries);
}
/*
if( (theTrack->GetLogicalVolumeAtVertex()->GetName().contains("core")) && (nStep == 1) )
{
//----------------------------------------------------------
// storing time, energy and position at gap with fast timing
Photon ph;
ph.position.SetX(global_x);
ph.position.SetY(global_y);
ph.position.SetZ(global_z);
ph.direction.SetX(theTrack->GetVertexMomentumDirection().x());
ph.direction.SetY(theTrack->GetVertexMomentumDirection().y());
ph.direction.SetZ(theTrack->GetVertexMomentumDirection().z());
ph.dist = (global_z/(0.5*fiber_length));
ph.energy = theTrack->GetTotalEnergy()/eV;
Fiber* fib = fDetectorConstruction -> GetFiber();
std::map<int,Travel> trc = GetTimeAndProbability(ph,fib,theTrackInfo->GetParticleProdTime());
for(unsigned int it = 0; it < CreateTree::Instance()->attLengths->size(); ++it)
{
int attLength = int( CreateTree::Instance()->attLengths->at(it) );
if( trc[attLength].prob[0] < 1.E-09 ) theTrack->SetTrackStatus(fKillTrackAndSecondaries);
for(int it2 = 0; it2 < 3; ++it2)
{
CreateTree::Instance()->tot_gap_photFast_cer->at(it) += trc[attLength].prob[it2];
//CreateTree::Instance()->h_photFast_cer_gap_lambda[attLength] -> Fill( MyMaterials::fromEvToNm(theTrack->GetTotalEnergy()/eV), trc[attLength].prob[it2] );
//CreateTree::Instance()->h_photFast_cer_gap_E[attLength] -> Fill( theTrack->GetTotalEnergy()/eV, trc[attLength].prob[it2] );
//CreateTree::Instance()->h_photFast_cer_gap_time[attLength] -> Fill( trc[attLength].time[it2], trc[attLength].prob[it2] );
}
}
}
*/
} // optical photon
// non optical photon
else
{
/*
//G4cout << ">>> begin non optical photon" << G4endl;
G4double energy = theStep->GetTotalEnergyDeposit() - theStep->GetNonIonizingEnergyDeposit();
if ( energy == 0. ) return;
// CreateTree::Instance() -> depositedEnergyTotal += energy/GeV;
if( thePrePVName.contains("core") )
{
// CreateTree::Instance()->depositedEnergyCore += energy/GeV;
}
if( thePrePVName.contains("capillary") )
{
// CreateTree::Instance()->depositedEnergyCapillary += energy/GeV;
}
if( thePrePVName.contains("cladding") )
{
// CreateTree::Instance()->depositedEnergyCladding += energy/GeV;
}
if( thePrePVName.contains("world") )
{
// CreateTree::Instance() -> depositedEnergyWorld += energy/GeV;
}
//G4cout << ">>> end non optical photon" << G4endl;
*/
} // non optical photon
return ;
}
| [
"micheli@cern.ch"
] | micheli@cern.ch |
24010bbaaffc7aad535823cc9062392b46bf286a | 2277375bd4a554d23da334dddd091a36138f5cae | /ThirdParty/Havok/Source/Common/GeometryUtilities/Mesh/Memory/hkMemoryMeshBody.h | 92b0ec343134e911ee193c432b2b8cab9843f4cc | [] | no_license | kevinmore/Project-Nebula | 9a0553ccf8bdc1b4bb5e2588fc94516d9e3532bc | f6d284d4879ae1ea1bd30c5775ef8733cfafa71d | refs/heads/master | 2022-10-22T03:55:42.596618 | 2020-06-19T09:07:07 | 2020-06-19T09:07:07 | 25,372,691 | 6 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 5,112 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2013 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HK_MEMORY_MESH_BODY_H
#define HK_MEMORY_MESH_BODY_H
#include <Common/GeometryUtilities/Mesh/hkMeshBody.h>
#include <Common/GeometryUtilities/Mesh/IndexedTransformSet/hkIndexedTransformSet.h>
#include <Common/GeometryUtilities/Mesh/hkMeshShape.h>
#include <Common/GeometryUtilities/Mesh/hkMeshVertexBuffer.h>
extern const class hkClass hkMemoryMeshBodyClass;
class hkMeshSystem;
/// An memory only version of a hkMeshBody
///
/// The memory implementation is useful for just processing hkMesh data.
///
/// \sa hkMeshBody
class hkMemoryMeshBody: public hkMeshBody
{
public:
HK_DECLARE_REFLECTION();
HK_DECLARE_CLASS_ALLOCATOR(HK_MEMORY_CLASS_SCENE_DATA);
/// Ctor
hkMemoryMeshBody(hkMeshSystem* meshSystem, const hkMeshShape* shape, const hkMatrix4& transform, hkIndexedTransformSetCinfo* transformSet);
/// Dtor
virtual ~hkMemoryMeshBody();
// hkMeshBody implementation
virtual const hkMeshShape* getMeshShape() const { return m_shape; }
// hkMeshBody implementation
virtual void getTransform( hkMatrix4& transform ) const { transform = m_transform; }
// hkMeshBody implementation
virtual void setTransform(const hkMatrix4& matrix) { m_transform = matrix; }
// hkMeshBody implementation
virtual hkResult setPickingData(int id, void* data) { return HK_FAILURE; }
// hkMeshBody implementation
virtual hkMeshVertexBuffer* getVertexBuffer(int sectionIndex) { return m_vertexBuffers[sectionIndex]; }
// hkMeshBody implementation
virtual int getNumIndexedTransforms() { return m_transformSet ? m_transformSet->getNumMatrices() : 0; }
// hkMeshBody implementation
virtual void setIndexedTransforms(int startIndex, const hkMatrix4* matrices, int numMatrices) { HK_ASSERT(0x34234, m_transformSet); m_transformSet->setMatrices(startIndex, matrices, numMatrices); }
// hkMeshBody implementation
virtual void getIndexedTransforms(int startIndex, hkMatrix4* matrices, int numMatrices) { HK_ASSERT(0x423432, m_transformSet); m_transformSet->getMatrices(startIndex, matrices, numMatrices); }
// hkMeshBody implementation
virtual void getIndexedInverseTransforms(int startIndex, hkMatrix4* matrices, int numMatrices) { HK_ASSERT(0x34243207, m_transformSet); m_transformSet->getInverseMatrices(startIndex, matrices, numMatrices); }
// hkMeshBody implementation
virtual const hkInt16* getIndexTransformsOrder() const { HK_ASSERT(0x34243207, m_transformSet); return m_transformSet->m_matricesOrder.begin(); }
// hkMeshBody implementation
virtual const hkStringPtr* getIndexTransformNames() const { HK_ASSERT(0x34243207, m_transformSet); return m_transformSet->m_matricesNames.begin(); }
// hkMeshBody implementation
virtual const hkMeshBoneIndexMapping* getIndexMappings() const { HK_ASSERT(0x34243207, m_transformSet); return m_transformSet->getIndexMappings().begin(); }
// hkMeshBody implementation
virtual hkInt32 getNumIndexMappings() const { return m_transformSet == HK_NULL ? 0 : m_transformSet->getIndexMappings().getSize(); }
// hkMeshBody implementation
virtual void completeUpdate() {}
virtual void completeUpdate(const hkMatrix4& transform) {}
virtual const char* getName() const { return m_name.cString(); }
virtual void setName(const char* n) { m_name = n; }
/// Serialization Ctor
hkMemoryMeshBody( hkFinishLoadedObjectFlag flag );
protected:
hkMatrix4 m_transform; ///< The transform
hkRefPtr<hkIndexedTransformSet> m_transformSet; ///< The transform set (can be HK_NULL)
hkRefPtr<const hkMeshShape> m_shape; ///< The originating shape
hkArray<hkMeshVertexBuffer*> m_vertexBuffers; ///< Vertex buffer for each mesh section (hold the per body/instance data)
hkStringPtr m_name;
};
#endif // HK_MEMORY_MESH_BODY_H
/*
* Havok SDK - Base file, BUILD(#20130912)
*
* Confidential Information of Havok. (C) Copyright 1999-2013
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available from salesteam@havok.com.
*
*/
| [
"dingfengyu@gmail.com"
] | dingfengyu@gmail.com |
55c1f7b58228a3f75c3d8aa4f5a9db2476c78d90 | 52cbeb46dfc30530abd7827394de982cdfbbd253 | /Backjoon/9461_파도반수열.cpp | d1ee733903c8d50116a163fb4b9d9ce1d2dfa034 | [] | no_license | fool8474/Algorithm_Backjoon | 48440c271f349438d7af80626e1ff38da51d74f4 | adee831bf8629ef90e05926607a49c52b0512b08 | refs/heads/main | 2023-03-01T11:43:03.737420 | 2021-02-16T03:59:27 | 2021-02-16T03:59:27 | 317,719,052 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 628 | cpp | #pragma once
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
void 파도반수열_9461()
{
ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
int n; cin >> n;
int* dps = new int[n];
int max = -1;
for (int i = 0; i < n; i++)
{
cin >> dps[i];
if (max < dps[i]) max = dps[i];
}
long long* results = new long long[max];
results[0] = 1; results[1] = 1; results[2] = 1;
for (int i = 3; i < max; i++)
{
results[i] = results[i - 3] + results[i - 2];
}
for (int i = 0; i < n; i++)
{
cout << results[dps[i]-1] << '\n';
}
}
| [
"fool8474@naver.com"
] | fool8474@naver.com |
109977ea5166940ab9ad0a8ac546ce872c8d189b | d5f2a48fedcbf1246dfeca0a5e6b35427994f1e8 | /src/GSvar/LovdUploadDialog.cpp | 990916ae9720936f55f6401467f0f02aeb67453b | [
"MIT"
] | permissive | wxb263stu/ngs-bits | b741693a70c21b4c2babb5f93549ec571c613fd6 | 99992e1c7bda0c6fa5ed5cd2ba774088293d5836 | refs/heads/master | 2020-03-22T03:00:08.143544 | 2018-06-27T08:17:52 | 2018-06-27T08:17:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,002 | cpp | #include "LovdUploadDialog.h"
#include "HttpHandler.h"
#include "Settings.h"
#include "Exceptions.h"
#include "Helper.h"
#include "Log.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QPrinter>
#include <QPrintDialog>
#include <QFileInfo>
#include <QDesktopServices>
LovdUploadDialog::LovdUploadDialog(QWidget *parent)
: QDialog(parent)
, ui_()
{
ui_.setupUi(this);
connect(ui_.upload_btn, SIGNAL(clicked(bool)), this, SLOT(upload()));
connect(ui_.processed_sample, SIGNAL(textEdited(QString)), this, SLOT(checkGuiData()));
connect(ui_.chr, SIGNAL(currentTextChanged(QString)), this, SLOT(checkGuiData()));
connect(ui_.gene, SIGNAL(textEdited(QString)), this, SLOT(checkGuiData()));
connect(ui_.nm_number, SIGNAL(textEdited(QString)), this, SLOT(checkGuiData()));
connect(ui_.hgvs_c, SIGNAL(textEdited(QString)), this, SLOT(checkGuiData()));
connect(ui_.hgvs_g, SIGNAL(textEdited(QString)), this, SLOT(checkGuiData()));
connect(ui_.genotype, SIGNAL(currentTextChanged(QString)), this, SLOT(checkGuiData()));
connect(ui_.classification, SIGNAL(currentTextChanged(QString)), this, SLOT(checkGuiData()));
connect(ui_.hgvs_c2, SIGNAL(textEdited(QString)), this, SLOT(checkGuiData()));
connect(ui_.hgvs_g2, SIGNAL(textEdited(QString)), this, SLOT(checkGuiData()));
connect(ui_.genotype2, SIGNAL(currentTextChanged(QString)), this, SLOT(checkGuiData()));
connect(ui_.classification2, SIGNAL(currentTextChanged(QString)), this, SLOT(checkGuiData()));
connect(ui_.phenos, SIGNAL(phenotypeSelectionChanged()), this, SLOT(checkGuiData()));
//update GUI elements for 2nd variant (only for free mode)
connect(ui_.genotype, SIGNAL(currentTextChanged(QString)), this, SLOT(updateSecondVariantGui()));
connect(ui_.genotype2, SIGNAL(currentTextChanged(QString)), this, SLOT(updateSecondVariantGui()));
connect(ui_.print_btn, SIGNAL(clicked(bool)), this, SLOT(printResults()));
connect(ui_.comment_upload, SIGNAL(textChanged()), this, SLOT(updatePrintButton()));
connect(ui_.refseq_btn, SIGNAL(clicked(bool)), this, SLOT(queryRefSeqWebservice()));
connect(ui_.refseq_btn2, SIGNAL(clicked(bool)), this, SLOT(queryRefSeqWebservice()));
}
void LovdUploadDialog::setData(LovdUploadData data)
{
//sample data
ui_.processed_sample->setText(data.processed_sample);
ui_.gender->setCurrentText(data.gender);
ui_.processed_sample->setEnabled(false);
ui_.gender->setEnabled(false);
//variant data
variant1 = data.variant;
ui_.chr->setCurrentText(data.variant.chr().str());
ui_.gene->setText(data.gene);
ui_.nm_number->setText(data.nm_number);
ui_.hgvs_g->setText(data.hgvs_g);
ui_.hgvs_c->setText(data.hgvs_c);
ui_.hgvs_p->setText(data.hgvs_p);
ui_.classification->setCurrentText(data.classification);
ui_.genotype->setCurrentText(data.genotype);
ui_.chr->setEnabled(false);
ui_.classification->setEnabled(false);
ui_.genotype->setEnabled(false);
//variant data
if(data.variant2.isValid())
{
variant2 = data.variant2;
ui_.hgvs_g2->setText(data.hgvs_g2);
ui_.hgvs_c2->setText(data.hgvs_c2);
ui_.hgvs_p2->setText(data.hgvs_p2);
ui_.classification2->setCurrentText(data.classification2);
ui_.genotype2->setCurrentText(data.genotype2);
ui_.hgvs_g2->setEnabled(true);
ui_.hgvs_c2->setEnabled(true);
ui_.hgvs_p2->setEnabled(true);
ui_.refseq_btn2->setEnabled(true);
}
ui_.genotype2->setEnabled(false);
ui_.classification2->setEnabled(false);
//if not in free mode => GUI of 2nd variant needs no updates
disconnect(this, SLOT(updateSecondVariantGui()));
//phenotype data
ui_.phenos->setPhenotypes(data.phenos);
}
void LovdUploadDialog::upload()
{
//init
ui_.upload_btn->setEnabled(false);
//create JSON-formatted upload data
QByteArray upload_file = createJson();
//upload data
static HttpHandler http_handler(HttpHandler::INI); //static to allow caching of credentials
try
{
QString reply = http_handler.getHttpReply("https://databases.lovd.nl/shared/api/submissions", upload_file);
ui_.comment_upload->setText(reply);
//parse JSON result
QJsonDocument json = QJsonDocument::fromJson(reply.toLatin1());
QStringList messages;
bool success = false;
foreach(QJsonValue o, json.object()["messages"].toArray())
{
messages << "MESSAGE: " + o.toString();
if (o.toString().startsWith("Data successfully scheduled for import."))
{
success = true;
}
}
foreach(QJsonValue o, json.object()["errors"].toArray())
{
messages << "ERROR: " + o.toString();
}
foreach(QJsonValue o, json.object()["warnings"].toArray())
{
messages << "WARNING: " +o.toString();
}
//add entry to NGSD
if (success)
{
QString processed_sample = ui_.processed_sample->text().trimmed();
QStringList details;
details << "gene=" + ui_.gene->text();
details << "transcript=" + ui_.nm_number->text();
details << "hgvs_g=" + ui_.hgvs_g->text();
details << "hgvs_c=" + ui_.hgvs_c->text();
details << "hgvs_p=" + ui_.hgvs_p->text();
details << "genotype=" + ui_.genotype->currentText();
details << "classification=" + ui_.classification->currentText();
if (isCompHet())
{
details << "hgvs_g2=" + ui_.hgvs_g2->text();
details << "hgvs_c2=" + ui_.hgvs_c2->text();
details << "hgvs_p2=" + ui_.hgvs_p2->text();
details << "genotype2=" + ui_.genotype2->currentText();
details << "classification2=" + ui_.classification2->currentText();
}
foreach(const Phenotype& pheno, ui_.phenos->selectedPhenotypes())
{
details << "phenotype=" + pheno.accession() + " - " + pheno.name();
}
//Upload only if variant(s) are set
if (variant1.isValid())
{
db_.addVariantPublication(processed_sample, variant1, "LOVD", ui_.classification->currentText(), details.join(";"));
}
if (variant2.isValid())
{
db_.addVariantPublication(processed_sample, variant2, "LOVD", ui_.classification2->currentText(), details.join(";"));
}
//show result
QStringList lines;
lines << "DATA UPLOAD TO LOVD SUCCESSFUL";
lines << "";
lines << messages.join("\n");
lines << "";
lines << "sample: " + processed_sample;
lines << "user: " + Helper::userName();
lines << "date: " + Helper::dateTime();
lines << "";
lines << details;
ui_.comment_upload->setText(lines.join("\n").replace("=", ": "));
//write report file to transfer folder
QString gsvar_publication_transfer = Settings::string("gsvar_publication_transfer");
if (gsvar_publication_transfer!="")
{
QString file_rep = gsvar_publication_transfer + "/" + processed_sample + "_LOVD_" + QDate::currentDate().toString("yyyyMMdd") + ".txt";
Helper::storeTextFile(file_rep, ui_.comment_upload->toPlainText().split("\n"));
}
}
else
{
ui_.comment_upload->setText("DATA UPLOAD ERROR:\n" + messages.join("\n"));
ui_.upload_btn->setEnabled(true);
}
}
catch(Exception e)
{
ui_.comment_upload->setText("DATA UPLOAD FAILED:\n" + e.message());
ui_.upload_btn->setEnabled(true);
}
}
void LovdUploadDialog::checkGuiData()
{
//check if already published
if (ui_.processed_sample->text()!="" && variant1.isValid())
{
QString upload_details = db_.getVariantPublication(ui_.processed_sample->text(), variant1);
if (upload_details!="")
{
ui_.upload_btn->setEnabled(false);
ui_.comment_upload->setText("<font color='red'>ERROR: variant already uploaded!</font><br>" + upload_details);
return;
}
}
//perform checks
QStringList errors;
if (ui_.processed_sample->text().trimmed().isEmpty())
{
errors << "Processed sample unset!";
}
if (ui_.chr->currentText().trimmed().isEmpty())
{
errors << "Chromosome unset!";
}
if (ui_.gene->text().trimmed().isEmpty())
{
errors << "Gene unset!";
}
if (ui_.nm_number->text().trimmed().isEmpty())
{
errors << "Transcript unset!";
}
if (ui_.hgvs_g->text().trimmed().isEmpty())
{
errors << "HGVS.g unset!";
}
if (ui_.hgvs_c->text().trimmed().isEmpty())
{
errors << "HGVS.c unset!";
}
if (ui_.genotype->currentText().trimmed().isEmpty())
{
errors << "Genotype unset!";
}
if (ui_.classification->currentText().trimmed().isEmpty())
{
errors << "Classification unset!";
}
if (isCompHet())
{
if (ui_.hgvs_g2->text().trimmed().isEmpty())
{
errors << "HGVS.g unset (variant 2)!";
}
if (ui_.hgvs_c2->text().trimmed().isEmpty())
{
errors << "HGVS.c unset (variant 2)!";
}
if (ui_.genotype->currentText()!="het" || ui_.genotype2->currentText()!="het")
{
errors << "Two variants for upload, but they are not compound-heterozygous!";
}
if (ui_.classification2->currentText().trimmed().isEmpty())
{
errors << "Classification unset (variant 2)!";
}
}
if (ui_.phenos->selectedPhenotypes().count()==0)
{
errors << "No phenotypes selected!";
}
//show error or enable upload button
if (errors.count()>0)
{
ui_.upload_btn->setEnabled(false);
ui_.comment_upload->setText("Cannot upload data because:\n - " + errors.join("\n - "));
}
else
{
ui_.upload_btn->setEnabled(true);
ui_.comment_upload->clear();
}
}
void LovdUploadDialog::printResults()
{
QPrinter printer(QPrinter::HighResolution);
printer.setFullPage(true);
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (dlg->exec() == QDialog::Accepted)
{
QTextDocument *doc = new QTextDocument();
doc->setPlainText(ui_.comment_upload->toPlainText());
doc->print(&printer);
delete doc;
}
delete dlg;
}
void LovdUploadDialog::updatePrintButton()
{
ui_.print_btn->setEnabled(!ui_.comment_upload->toPlainText().trimmed().isEmpty());
}
void LovdUploadDialog::queryRefSeqWebservice()
{
QString url = Settings::string("VariantInfoRefSeq");
if (sender()==qobject_cast<QObject*>(ui_.refseq_btn) && variant1.isValid()) url += "?variant_data=" + variant1.toString(true).replace(" ", "\t");
if (sender()==qobject_cast<QObject*>(ui_.refseq_btn2) && variant2.isValid()) url += "?variant_data=" + variant2.toString(true).replace(" ", "\t");
QDesktopServices::openUrl(QUrl(url));
}
void LovdUploadDialog::updateSecondVariantGui()
{
bool enabled = ui_.genotype->currentText()=="het" && ui_.genotype2->currentText()=="het";
ui_.hgvs_g2->setEnabled(enabled);
ui_.hgvs_c2->setEnabled(enabled);
ui_.hgvs_p2->setEnabled(enabled);
ui_.classification2->setEnabled(enabled);
ui_.refseq_btn2->setEnabled(enabled);
}
bool LovdUploadDialog::isCompHet() const
{
return variant2.isValid() || ui_.genotype2->currentText()=="het";
}
QByteArray LovdUploadDialog::createJson()
{
QByteArray output;
QTextStream stream(&output);
//create header part
QString lab = getSettings("lovd_lab");
QString user_name = getSettings("lovd_user_name");
QString user_email = getSettings("lovd_user_email");
QString user_id = getSettings("lovd_user_id");
QString user_auth_token = getSettings("lovd_user_auth_token");
stream << "{\n";
stream << " \"lsdb\": {\n";
stream << " \"@id\": \"53786324d4c6cf1d33a3e594a92591aa\",\n";
stream << " \"@uri\": \"http://databases.lovd.nl/shared/\",\n";
stream << " \"source\": {\n";
stream << " \"name\": \"" << lab << "\",\n";
stream << " \"contact\": {\n";
stream << " \"name\": \"" << user_name << "\",\n";
stream << " \"email\": \"" << user_email << "\",\n";
stream << " \"db_xref\": [\n";
stream << " {\n";
stream << " \"@source\": \"lovd\",\n";
stream << " \"@accession\": \"" << user_id << "\"\n";
stream << " },\n";
stream << " {\n";
stream << " \"@source\": \"lovd_auth_token\",\n";
stream << " \"@accession\": \"" << user_auth_token << "\"\n";
stream << " }\n";
stream << " ]\n";
stream << " }\n";
stream << " },\n";
//create patient part
stream << " \"individual\": [\n";
stream << " {\n";
stream << " \"@id\": \"" << ui_.processed_sample->text().trimmed() << "\",\n";
stream << " \"gender\": {\n";
stream << " \"@code\": \"" << convertGender(ui_.gender->currentText().trimmed()) <<"\"\n";
stream << " },\n";
foreach(const Phenotype& pheno, ui_.phenos->selectedPhenotypes())
{
stream << " \"phenotype\": [\n";
stream << " {\n";
stream << " \"@term\": \"" << pheno.name().trimmed() << "\",\n";
stream << " \"@source\": \"HPO\",\n";
stream << " \"@accession\": \"" << pheno.accession().mid(3).trimmed() << "\"\n";
stream << " }\n";
stream << " ],\n";
}
//variant info
stream << " \"variant\": [\n";
QString chr = ui_.chr->currentText().trimmed();
QString gene = ui_.gene->text().trimmed();
QString transcript = ui_.nm_number->text().trimmed();
createJsonForVariant(stream, chr, gene, transcript, ui_.hgvs_g, ui_.hgvs_c, ui_.hgvs_p, ui_.genotype, ui_.classification);
if (isCompHet())
{
stream << ",\n";
createJsonForVariant(stream, chr, gene, transcript, ui_.hgvs_g2, ui_.hgvs_c2, ui_.hgvs_p2, ui_.genotype, ui_.classification);
}
stream << "\n";
//close all brackets
stream << " ]\n";
stream << " }\n";
stream << " ]\n";
stream << " }\n";
stream << "}\n";
stream << "\n";
return output;
}
void LovdUploadDialog::createJsonForVariant(QTextStream& stream, QString chr, QString gene, QString transcript, QLineEdit* hgvs_g, QLineEdit* hgvs_c, QLineEdit* hgvs_p, QComboBox* genotype, QComboBox* classification)
{
stream << " {\n";
stream << " \"@copy_count\": \"" << convertGenotype(genotype->currentText().trimmed()) << "\",\n";
stream << " \"@type\": \"DNA\",\n";
stream << " \"ref_seq\": {\n";
stream << " \"@source\": \"genbank\",\n";
stream << " \"@accession\": \"" << chromosomeToAccession(chr) << "\"\n"; //official identifier for hg19
stream << " },\n";
stream << " \"name\": {\n";
stream << " \"@scheme\": \"HGVS\",\n";
stream << " \"#text\": \"" << hgvs_g->text().trimmed() << "\"\n";
stream << " },\n";
stream << " \"pathogenicity\": {\n";
stream << " \"@scope\": \"individual\",\n";
stream << " \"@term\": \"" << convertClassification(classification->currentText().trimmed()) << "\"\n";
stream << " },\n";
stream << " \"variant_detection\": [\n";
stream << " {\n";
stream << " \"@template\": \"DNA\",\n";
stream << " \"@technique\": \"SEQ\"\n";
stream << " }\n";
stream << " ],\n";
stream << " \"seq_changes\": {\n";
stream << " \"variant\": [\n";
stream << " {\n";
stream << " \"@type\": \"cDNA\",\n";
stream << " \"gene\": {\n";
stream << " \"@source\": \"HGNC\",\n";
stream << " \"@accession\": \"" << gene << "\"\n";
stream << " },\n";
stream << " \"ref_seq\": {\n";
stream << " \"@source\": \"genbank\",\n";
stream << " \"@accession\": \"" << transcript << "\"\n";
stream << " },\n";
stream << " \"name\": {\n";
stream << " \"@scheme\": \"HGVS\",\n";
stream << " \"#text\": \"" << hgvs_c->text().trimmed() << "\"\n";
stream << " },\n";
stream << " \"seq_changes\": {\n";
stream << " \"variant\": [\n";
stream << " {\n";
stream << " \"@type\": \"RNA\",\n";
stream << " \"name\": {\n";
stream << " \"@scheme\": \"HGVS\",\n";
stream << " \"#text\": \"r.(?)\"\n"; //we do not have HGVS.r info!
stream << " }";
if (hgvs_p->text().trimmed()=="")
{
stream << "\n";
}
else
{
stream << ",\n";
stream << " \"seq_changes\": {\n";
stream << " \"variant\": [\n";
stream << " {\n";
stream << " \"@type\": \"AA\",\n";
stream << " \"name\": {\n";
stream << " \"@scheme\": \"HGVS\",\n";
stream << " \"#text\": \"" << hgvs_p->text().trimmed() << "\"\n";
stream << " }\n";
stream << " }\n";
stream << " ]\n";
stream << " }\n";
}
stream << " }\n";
stream << " ]\n";
stream << " }\n";
stream << " }";
stream << " ]\n";
stream << " }\n";
stream << " }\n";
}
QString LovdUploadDialog::getSettings(QString key)
{
QString output = Settings::string(key).trimmed();
if (output.isEmpty())
{
THROW(FileParseException, "Settings INI file does not contain key '" + key + "'!");
}
return output;
}
QString LovdUploadDialog::convertClassification(QString classification)
{
if (classification=="5")
{
return "Pathogenic";
}
if (classification=="4")
{
return "Probably Pathogenic";
}
if (classification=="3" || classification=="n/a" || classification=="")
{
return "Not Known";
}
if (classification=="2")
{
return "Probably Not Pathogenic";
}
if (classification=="1")
{
return "Non-pathogenic";
}
THROW(ProgrammingException, "Unknown classification '" + classification + "' in LovdUploadDialog::create(...) method!");
}
QString LovdUploadDialog::chromosomeToAccession(const Chromosome& chr)
{
QByteArray chr_str = chr.strNormalized(false);
if (chr_str=="1") return "NC_000001.10";
else if (chr_str=="2") return "NC_000002.11";
else if (chr_str=="3") return "NC_000003.11";
else if (chr_str=="4") return "NC_000004.11";
else if (chr_str=="5") return "NC_000005.9";
else if (chr_str=="6") return "NC_000006.11";
else if (chr_str=="7") return "NC_000007.13";
else if (chr_str=="8") return "NC_000008.10";
else if (chr_str=="9") return "NC_000009.11";
else if (chr_str=="10") return "NC_000010.10";
else if (chr_str=="11") return "NC_000011.9";
else if (chr_str=="12") return "NC_000012.11";
else if (chr_str=="13") return "NC_000013.10";
else if (chr_str=="14") return "NC_000014.8";
else if (chr_str=="15") return "NC_000015.9";
else if (chr_str=="16") return "NC_000016.9";
else if (chr_str=="17") return "NC_000017.10";
else if (chr_str=="18") return "NC_000018.9";
else if (chr_str=="19") return "NC_000019.9";
else if (chr_str=="20") return "NC_000020.10";
else if (chr_str=="21") return "NC_000021.8";
else if (chr_str=="22") return "NC_000022.10";
else if (chr_str=="X") return "NC_000023.10";
else if (chr_str=="Y") return "NC_000024.9";
else if (chr_str=="MT") return "NC_012920.1";
THROW(ProgrammingException, "Unknown chromosome '" + chr_str + "' in LovdUploadDialog::create(...) method!");
}
QString LovdUploadDialog::convertGender(QString gender)
{
if (gender=="n/a")
{
return "0";
}
if (gender=="male")
{
return "1";
}
if (gender=="female")
{
return "2";
}
THROW(ProgrammingException, "Unknown gender '" + gender + "' in LovdUploadDialog::create(...) method!");
}
QString LovdUploadDialog::convertGenotype(QString genotype)
{
if (genotype=="het")
{
return "1";
}
if (genotype=="hom")
{
return "2";
}
THROW(ProgrammingException, "Unknown genotype '" + genotype + "' in LovdUploadDialog::create(...) method!")
}
| [
"sturm.marc@gmail.com"
] | sturm.marc@gmail.com |
5c73bf66c1c5f95b20ecdd8fe61c8fb07061ea84 | fb7efe44f4d9f30d623f880d0eb620f3a81f0fbd | /ppapi/proxy/nacl_message_scanner.cc | 8c31b831664a1555d6714c68757742f1b0c95bde | [
"BSD-3-Clause",
"LicenseRef-scancode-khronos"
] | permissive | wzyy2/chromium-browser | 2644b0daf58f8b3caee8a6c09a2b448b2dfe059c | eb905f00a0f7e141e8d6c89be8fb26192a88c4b7 | refs/heads/master | 2022-11-23T20:25:08.120045 | 2018-01-16T06:41:26 | 2018-01-16T06:41:26 | 117,618,467 | 3 | 2 | BSD-3-Clause | 2022-11-20T22:03:57 | 2018-01-16T02:09:10 | null | UTF-8 | C++ | false | false | 21,225 | cc | // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/proxy/nacl_message_scanner.h"
#include <stddef.h>
#include <tuple>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "build/build_config.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/resource_message_params.h"
#include "ppapi/proxy/serialized_handle.h"
#include "ppapi/proxy/serialized_var.h"
class NaClDescImcShm;
namespace IPC {
class Message;
}
using ppapi::proxy::ResourceMessageReplyParams;
using ppapi::proxy::SerializedHandle;
using ppapi::proxy::SerializedVar;
namespace {
typedef std::vector<SerializedHandle> Handles;
struct ScanningResults {
ScanningResults() : handle_index(0), pp_resource(0) {}
// Vector to hold handles found in the message.
Handles handles;
// Current handle index in the rewritten message. During the scan, it will be
// be less than or equal to handles.size(). After the scan it should be equal.
int handle_index;
// The rewritten message. This may be NULL, so all ScanParam overloads should
// check for NULL before writing to it. In some cases, a ScanParam overload
// may set this to NULL when it can determine that there are no parameters
// that need conversion. (See the ResourceMessageReplyParams overload.)
std::unique_ptr<IPC::Message> new_msg;
// Resource id for resource messages. Save this when scanning resource replies
// so when we audit the nested message, we know which resource it is for.
PP_Resource pp_resource;
// Callback to receive the nested message in a resource message or reply.
base::Callback<void(PP_Resource, const IPC::Message&, SerializedHandle*)>
nested_msg_callback;
};
void WriteHandle(int handle_index,
const SerializedHandle& handle,
base::Pickle* msg) {
SerializedHandle::WriteHeader(handle.header(), msg);
if (handle.type() == SerializedHandle::SHARED_MEMORY) {
// Now write the handle itself in POSIX style.
// This serialization must be kept in sync with
// ParamTraits<SharedMemoryHandle>::Write and
// ParamTraits<UnguessableToken>::Write.
if (handle.shmem().IsValid()) {
msg->WriteBool(true); // valid == true
msg->WriteInt(handle_index);
msg->WriteUInt64(handle.shmem().GetGUID().GetHighForSerialization());
msg->WriteUInt64(handle.shmem().GetGUID().GetLowForSerialization());
msg->WriteUInt64(handle.shmem().GetSize());
} else {
msg->WriteBool(false); // valid == false
}
} else if (handle.type() != SerializedHandle::INVALID) {
// Now write the handle itself in POSIX style.
// This serialization must be kept in sync with
// ParamTraits<FileDescriptor>::Write.
msg->WriteBool(true); // valid == true
msg->WriteInt(handle_index);
}
}
// Define overloads for each kind of message parameter that requires special
// handling. See ScanTuple for how these get used.
// Overload to match SerializedHandle.
void ScanParam(const SerializedHandle& handle, ScanningResults* results) {
results->handles.push_back(handle);
if (results->new_msg)
WriteHandle(results->handle_index++, handle, results->new_msg.get());
}
void HandleWriter(int* handle_index,
base::Pickle* m,
const SerializedHandle& handle) {
WriteHandle((*handle_index)++, handle, m);
}
// Overload to match SerializedVar, which can contain handles.
void ScanParam(const SerializedVar& var, ScanningResults* results) {
std::vector<SerializedHandle*> var_handles = var.GetHandles();
// Copy any handles and then rewrite the message.
for (size_t i = 0; i < var_handles.size(); ++i)
results->handles.push_back(*var_handles[i]);
if (results->new_msg)
var.WriteDataToMessage(results->new_msg.get(),
base::Bind(&HandleWriter, &results->handle_index));
}
// For PpapiMsg_ResourceReply and the reply to PpapiHostMsg_ResourceSyncCall,
// the handles are carried inside the ResourceMessageReplyParams.
// NOTE: We only intercept handles from host->NaCl. The only kind of
// ResourceMessageParams that travels this direction is
// ResourceMessageReplyParams, so that's the only one we need to handle.
void ScanParam(const ResourceMessageReplyParams& params,
ScanningResults* results) {
results->pp_resource = params.pp_resource();
// If the resource reply params don't contain handles, NULL the new message
// pointer to cancel further rewriting.
// NOTE: This works because only handles currently need rewriting, and we
// know at this point that this message has none.
if (params.handles().empty()) {
results->new_msg.reset(NULL);
return;
}
// If we need to rewrite the message, write everything before the handles
// (there's nothing after the handles).
if (results->new_msg) {
params.WriteReplyHeader(results->new_msg.get());
// IPC writes the vector length as an int before the contents of the
// vector.
results->new_msg->WriteInt(static_cast<int>(params.handles().size()));
}
for (Handles::const_iterator iter = params.handles().begin();
iter != params.handles().end();
++iter) {
// ScanParam will write each handle to the new message, if necessary.
ScanParam(*iter, results);
}
// Tell ResourceMessageReplyParams that we have taken the handles, so it
// shouldn't close them. The NaCl runtime will take ownership of them.
params.ConsumeHandles();
}
// Overload to match nested messages. If we need to rewrite the message, write
// the parameter.
void ScanParam(const IPC::Message& param, ScanningResults* results) {
if (results->pp_resource && !results->nested_msg_callback.is_null()) {
SerializedHandle* handle = NULL;
if (results->handles.size() == 1)
handle = &results->handles[0];
results->nested_msg_callback.Run(results->pp_resource, param, handle);
}
if (results->new_msg)
IPC::WriteParam(results->new_msg.get(), param);
}
template <class T>
void ScanParam(const std::vector<T>& vec, ScanningResults* results) {
if (results->new_msg)
IPC::WriteParam(results->new_msg.get(), static_cast<int>(vec.size()));
for (const T& element : vec) {
ScanParam(element, results);
}
}
// Overload to match all other types. If we need to rewrite the message, write
// the parameter.
template <class T>
void ScanParam(const T& param, ScanningResults* results) {
if (results->new_msg)
IPC::WriteParam(results->new_msg.get(), param);
}
// These just break apart the given tuple and run ScanParam over each param.
// The idea is to scan elements in the tuple which require special handling,
// and write them into the |results| struct.
template <class A>
void ScanTuple(const std::tuple<A>& t1, ScanningResults* results) {
ScanParam(std::get<0>(t1), results);
}
template <class A, class B>
void ScanTuple(const std::tuple<A, B>& t1, ScanningResults* results) {
ScanParam(std::get<0>(t1), results);
ScanParam(std::get<1>(t1), results);
}
template <class A, class B, class C>
void ScanTuple(const std::tuple<A, B, C>& t1, ScanningResults* results) {
ScanParam(std::get<0>(t1), results);
ScanParam(std::get<1>(t1), results);
ScanParam(std::get<2>(t1), results);
}
template <class A, class B, class C, class D>
void ScanTuple(const std::tuple<A, B, C, D>& t1, ScanningResults* results) {
ScanParam(std::get<0>(t1), results);
ScanParam(std::get<1>(t1), results);
ScanParam(std::get<2>(t1), results);
ScanParam(std::get<3>(t1), results);
}
template <class MessageType>
class MessageScannerImpl {
public:
explicit MessageScannerImpl(const IPC::Message* msg)
// The cast below is invalid. See https://crbug.com/520760.
: msg_(static_cast<const MessageType*>(msg)) {
}
bool ScanMessage(ScanningResults* results) {
typename MessageType::Param params;
if (!MessageType::Read(msg_, ¶ms))
return false;
ScanTuple(params, results);
return true;
}
bool ScanSyncMessage(ScanningResults* results) {
typename MessageType::SendParam params;
if (!MessageType::ReadSendParam(msg_, ¶ms))
return false;
// If we need to rewrite the message, write the message id first.
if (results->new_msg) {
results->new_msg->set_sync();
int id = IPC::SyncMessage::GetMessageId(*msg_);
results->new_msg->WriteInt(id);
}
ScanTuple(params, results);
return true;
}
bool ScanReply(ScanningResults* results) {
typename MessageType::ReplyParam params;
if (!MessageType::ReadReplyParam(msg_, ¶ms))
return false;
// If we need to rewrite the message, write the message id first.
if (results->new_msg) {
results->new_msg->set_reply();
int id = IPC::SyncMessage::GetMessageId(*msg_);
results->new_msg->WriteInt(id);
}
ScanTuple(params, results);
return true;
}
private:
const MessageType* msg_;
};
} // namespace
#define CASE_FOR_MESSAGE(MESSAGE_TYPE) \
case MESSAGE_TYPE::ID: { \
MessageScannerImpl<MESSAGE_TYPE> scanner(&msg); \
if (rewrite_msg) \
results.new_msg.reset( \
new IPC::Message(msg.routing_id(), msg.type(), \
IPC::Message::PRIORITY_NORMAL)); \
if (!scanner.ScanMessage(&results)) \
return false; \
break; \
}
#define CASE_FOR_SYNC_MESSAGE(MESSAGE_TYPE) \
case MESSAGE_TYPE::ID: { \
MessageScannerImpl<MESSAGE_TYPE> scanner(&msg); \
if (rewrite_msg) \
results.new_msg.reset( \
new IPC::Message(msg.routing_id(), msg.type(), \
IPC::Message::PRIORITY_NORMAL)); \
if (!scanner.ScanSyncMessage(&results)) \
return false; \
break; \
}
#define CASE_FOR_REPLY(MESSAGE_TYPE) \
case MESSAGE_TYPE::ID: { \
MessageScannerImpl<MESSAGE_TYPE> scanner(&msg); \
if (rewrite_msg) \
results.new_msg.reset( \
new IPC::Message(msg.routing_id(), msg.type(), \
IPC::Message::PRIORITY_NORMAL)); \
if (!scanner.ScanReply(&results)) \
return false; \
break; \
}
namespace ppapi {
namespace proxy {
class SerializedHandle;
NaClMessageScanner::FileSystem::FileSystem()
: reserved_quota_(0) {
}
NaClMessageScanner::FileSystem::~FileSystem() {
}
bool NaClMessageScanner::FileSystem::UpdateReservedQuota(int64_t delta) {
base::AutoLock lock(lock_);
if (std::numeric_limits<int64_t>::max() - reserved_quota_ < delta)
return false; // reserved_quota_ + delta would overflow.
if (reserved_quota_ + delta < 0)
return false;
reserved_quota_ += delta;
return true;
}
NaClMessageScanner::FileIO::FileIO(FileSystem* file_system,
int64_t max_written_offset)
: file_system_(file_system),
max_written_offset_(max_written_offset) {
}
NaClMessageScanner::FileIO::~FileIO() {
}
void NaClMessageScanner::FileIO::SetMaxWrittenOffset(
int64_t max_written_offset) {
base::AutoLock lock(lock_);
max_written_offset_ = max_written_offset;
}
bool NaClMessageScanner::FileIO::Grow(int64_t amount) {
base::AutoLock lock(lock_);
DCHECK(amount > 0);
if (!file_system_->UpdateReservedQuota(-amount))
return false;
max_written_offset_ += amount;
return true;
}
NaClMessageScanner::NaClMessageScanner() {
}
NaClMessageScanner::~NaClMessageScanner() {
for (FileSystemMap::iterator it = file_systems_.begin();
it != file_systems_.end(); ++it)
delete it->second;
for (FileIOMap::iterator it = files_.begin(); it != files_.end(); ++it)
delete it->second;
}
// Windows IPC differs from POSIX in that native handles are serialized in the
// message body, rather than passed in a separate FileDescriptorSet. Therefore,
// on Windows, any message containing handles must be rewritten in the POSIX
// format before we can send it to the NaCl plugin.
// On Mac, base::SharedMemoryHandle has a different serialization than
// base::FileDescriptor (which base::SharedMemoryHandle is typedef-ed to in
// OS_NACL).
bool NaClMessageScanner::ScanMessage(
const IPC::Message& msg,
uint32_t type,
std::vector<SerializedHandle>* handles,
std::unique_ptr<IPC::Message>* new_msg_ptr) {
DCHECK(handles);
DCHECK(handles->empty());
DCHECK(new_msg_ptr);
DCHECK(!new_msg_ptr->get());
bool rewrite_msg =
#if defined(OS_WIN) || defined(OS_MACOSX)
true;
#else
false;
#endif
// We can't always tell from the message ID if rewriting is needed. Therefore,
// scan any message types that might contain a handle. If we later determine
// that there are no handles, we can cancel the rewriting by clearing the
// results.new_msg pointer.
ScanningResults results;
results.nested_msg_callback =
base::Bind(&NaClMessageScanner::AuditNestedMessage,
base::Unretained(this));
switch (type) {
CASE_FOR_MESSAGE(PpapiMsg_PPBAudio_NotifyAudioStreamCreated)
CASE_FOR_MESSAGE(PpapiMsg_PPPMessaging_HandleMessage)
CASE_FOR_MESSAGE(PpapiPluginMsg_ResourceReply)
CASE_FOR_SYNC_MESSAGE(PpapiMsg_PPPMessageHandler_HandleBlockingMessage)
CASE_FOR_SYNC_MESSAGE(PpapiMsg_PnaclTranslatorCompileInit)
CASE_FOR_SYNC_MESSAGE(PpapiMsg_PnaclTranslatorLink)
CASE_FOR_REPLY(PpapiHostMsg_OpenResource)
CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_Create)
CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer)
CASE_FOR_REPLY(PpapiHostMsg_PPBImageData_CreateSimple)
CASE_FOR_REPLY(PpapiHostMsg_ResourceSyncCall)
CASE_FOR_REPLY(PpapiHostMsg_SharedMemory_CreateSharedMemory)
default:
// Do nothing for messages we don't know.
break;
}
// Only messages containing handles need to be rewritten. If no handles are
// found, don't return the rewritten message either. This must be changed if
// we ever add new param types that also require rewriting.
if (!results.handles.empty()) {
handles->swap(results.handles);
*new_msg_ptr = std::move(results.new_msg);
}
return true;
}
void NaClMessageScanner::ScanUntrustedMessage(
const IPC::Message& untrusted_msg,
std::unique_ptr<IPC::Message>* new_msg_ptr) {
// Audit FileIO and FileSystem messages to ensure that the plugin doesn't
// exceed its file quota. If we find the message is malformed, just pass it
// through - we only care about well formed messages to the host.
if (untrusted_msg.type() == PpapiHostMsg_ResourceCall::ID) {
ResourceMessageCallParams params;
IPC::Message nested_msg;
if (!UnpackMessage<PpapiHostMsg_ResourceCall>(
untrusted_msg, ¶ms, &nested_msg))
return;
switch (nested_msg.type()) {
case PpapiHostMsg_FileIO_Close::ID: {
FileIOMap::iterator it = files_.find(params.pp_resource());
if (it == files_.end())
return;
// Audit FileIO Close messages to make sure the plugin reports an
// accurate file size.
FileGrowth file_growth;
if (!UnpackMessage<PpapiHostMsg_FileIO_Close>(
nested_msg, &file_growth))
return;
int64_t trusted_max_written_offset = it->second->max_written_offset();
delete it->second;
files_.erase(it);
// If the plugin is under-reporting, rewrite the message with the
// trusted value.
if (trusted_max_written_offset > file_growth.max_written_offset) {
new_msg_ptr->reset(
new PpapiHostMsg_ResourceCall(
params,
PpapiHostMsg_FileIO_Close(
FileGrowth(trusted_max_written_offset, 0))));
}
break;
}
case PpapiHostMsg_FileIO_SetLength::ID: {
FileIOMap::iterator it = files_.find(params.pp_resource());
if (it == files_.end())
return;
// Audit FileIO SetLength messages to make sure the plugin is within
// the current quota reservation. In addition, deduct the file size
// increase from the quota reservation.
int64_t length = 0;
if (!UnpackMessage<PpapiHostMsg_FileIO_SetLength>(
nested_msg, &length))
return;
// Calculate file size increase, taking care to avoid overflows.
if (length < 0)
return;
int64_t trusted_max_written_offset = it->second->max_written_offset();
int64_t increase = length - trusted_max_written_offset;
if (increase <= 0)
return;
if (!it->second->Grow(increase)) {
new_msg_ptr->reset(
new PpapiHostMsg_ResourceCall(
params,
PpapiHostMsg_FileIO_SetLength(-1)));
}
break;
}
case PpapiHostMsg_FileSystem_ReserveQuota::ID: {
// Audit FileSystem ReserveQuota messages to make sure the plugin
// reports accurate file sizes.
int64_t amount = 0;
FileGrowthMap file_growths;
if (!UnpackMessage<PpapiHostMsg_FileSystem_ReserveQuota>(
nested_msg, &amount, &file_growths))
return;
bool audit_failed = false;
for (FileGrowthMap::iterator it = file_growths.begin();
it != file_growths.end(); ++it) {
FileIOMap::iterator file_it = files_.find(it->first);
if (file_it == files_.end())
continue;
int64_t trusted_max_written_offset =
file_it->second->max_written_offset();
if (trusted_max_written_offset > it->second.max_written_offset) {
audit_failed = true;
it->second.max_written_offset = trusted_max_written_offset;
}
if (it->second.append_mode_write_amount < 0) {
audit_failed = true;
it->second.append_mode_write_amount = 0;
}
}
if (audit_failed) {
new_msg_ptr->reset(
new PpapiHostMsg_ResourceCall(
params,
PpapiHostMsg_FileSystem_ReserveQuota(
amount, file_growths)));
}
break;
}
case PpapiHostMsg_ResourceDestroyed::ID: {
// Audit resource destroyed messages to release FileSystems.
PP_Resource resource;
if (!UnpackMessage<PpapiHostMsg_ResourceDestroyed>(
nested_msg, &resource))
return;
FileSystemMap::iterator fs_it = file_systems_.find(resource);
if (fs_it != file_systems_.end()) {
delete fs_it->second;
file_systems_.erase(fs_it);
}
break;
}
}
}
}
NaClMessageScanner::FileIO* NaClMessageScanner::GetFile(
PP_Resource file_io) {
FileIOMap::iterator it = files_.find(file_io);
DCHECK(it != files_.end());
return it->second;
}
void NaClMessageScanner::AuditNestedMessage(PP_Resource resource,
const IPC::Message& msg,
SerializedHandle* handle) {
switch (msg.type()) {
case PpapiPluginMsg_FileIO_OpenReply::ID: {
// A file that requires quota checking was opened.
PP_Resource quota_file_system;
int64_t max_written_offset = 0;
if (ppapi::UnpackMessage<PpapiPluginMsg_FileIO_OpenReply>(
msg, "a_file_system, &max_written_offset)) {
if (quota_file_system) {
// Look up the FileSystem by inserting a new one. If it was already
// present, get the existing one, otherwise construct it.
FileSystem* file_system = NULL;
std::pair<FileSystemMap::iterator, bool> insert_result =
file_systems_.insert(std::make_pair(quota_file_system,
file_system));
if (insert_result.second)
insert_result.first->second = new FileSystem();
file_system = insert_result.first->second;
// Create the FileIO.
DCHECK(files_.find(resource) == files_.end());
files_.insert(std::make_pair(
resource,
new FileIO(file_system, max_written_offset)));
}
}
break;
}
case PpapiPluginMsg_FileSystem_ReserveQuotaReply::ID: {
// The amount of reserved quota for a FileSystem was refreshed.
int64_t amount = 0;
FileSizeMap file_sizes;
if (ppapi::UnpackMessage<PpapiPluginMsg_FileSystem_ReserveQuotaReply>(
msg, &amount, &file_sizes)) {
FileSystemMap::iterator it = file_systems_.find(resource);
DCHECK(it != file_systems_.end());
it->second->UpdateReservedQuota(amount);
FileSizeMap::const_iterator offset_it = file_sizes.begin();
for (; offset_it != file_sizes.end(); ++offset_it) {
FileIOMap::iterator fio_it = files_.find(offset_it->first);
DCHECK(fio_it != files_.end());
if (fio_it != files_.end())
fio_it->second->SetMaxWrittenOffset(offset_it->second);
}
}
break;
}
}
}
} // namespace proxy
} // namespace ppapi
| [
"jacob-chen@iotwrt.com"
] | jacob-chen@iotwrt.com |
b7d2c91a86ff199a6847b1d608d3662aa265c702 | 752cdc29e611a9ca848a56bbe9ec304772325b90 | /plan.cpp | a6c5b91cbf59863fb823c67dd12d4d7249de75e7 | [] | no_license | epled/planner | 660c34f586673ab395bff8cbfcbfe5fd1fa50884 | 2e5e1a75f1141c5ad3f0f8c2cea2b93cda19e809 | refs/heads/main | 2023-02-28T09:49:20.937855 | 2021-01-24T07:13:54 | 2021-01-24T07:13:54 | 332,387,865 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,452 | cpp | #include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <bits/stdc++.h>
using namespace std;
const string planfile = "plan.txt";
enum days {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY};
string dayString[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
struct task{
int quarters;
int repeats;
string name;
};
string dayToString(int day){
switch(day){
case 0:
return "Sunday";
break;
case 1:
return "Monday";
break;
case 2:
return "Tuesday";
break;
case 3:
return "Wednesday";
break;
case 4:
return "Thursday";
break;
case 5:
return "Friday";
case 6:
return "Saturday";
}
}
void addOneTask(int day, ofstream & fout){
struct task newTask;
string input;
cout << "Enter the name of your task: "<< endl;
cin >> input;
newTask.
fout << dayString[day] << ": " << input << endl;
return;
}
int main(){
ifstream fin;
ofstream fout;
fin.open(planfile);
fout.open(planfile);
vector <task> Sunday;
vector <task> Monday;
vector <task> Tuesday;
vector <task> Wednesday;
vector <task> Thursday;
vector <task> Friday;
vector <task> Saturday;
addOneTask(MONDAY, fout);
addOneTask(TUESDAY, fout);
struct tm now = *localtime(0);
fout << now.tm_year;
}
| [
"mmaddux@horizon.csueastbay.edu"
] | mmaddux@horizon.csueastbay.edu |
1770839c40dbcbbd01e4f75e3e09f10c7a214681 | 445b08ddf5afa9e7e4980e30e8c36553a0e18b73 | /ExternalLibs/cinolib/include/cinolib/map_distortion.h | 5b6b13867688d53df69ffc995558c53ddb1d816c | [] | no_license | AndrewWang996/6.839-final | 41d741ea0976949d1e9394ce5cce4edc9b822b51 | 3a8d711f37b7be349f9ff21183e561bef224b692 | refs/heads/master | 2020-04-10T14:37:42.582850 | 2018-12-16T21:43:11 | 2018-12-16T21:43:11 | 161,082,380 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,349 | h | /*********************************************************************************
* Copyright(C) 2016: Marco Livesu *
* All rights reserved. *
* *
* This file is part of CinoLib *
* *
* CinoLib is dual-licensed: *
* *
* - For non-commercial use you can redistribute it and/or modify it under the *
* terms of the GNU General Public License as published by the Free Software *
* Foundation; either version 3 of the License, or (at your option) any later *
* version. *
* *
* - If you wish to use it as part of a commercial software, a proper agreement *
* with the Author(s) must be reached, based on a proper licensing contract. *
* *
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE *
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
* *
* Author(s): *
* *
* Marco Livesu (marco.livesu@gmail.com) *
* http://pers.ge.imati.cnr.it/livesu/ *
* *
* Italian National Research Council (CNR) *
* Institute for Applied Mathematics and Information Technologies (IMATI) *
* Via de Marini, 6 *
* 16149 Genoa, *
* Italy *
**********************************************************************************/
#ifndef CINO_MAP_DISTORTION_H
#define CINO_MAP_DISTORTION_H
#include <cinolib/cino_inline.h>
namespace cinolib
{
/* Compute the aspect ratio distortion of a map. Let
* T be the affine map between A and B, such that:
*
* B = T(A) = M * A + t
*
* with M being a 3x3 matrix encoding the rotation/scaling
* part of the mapping and t be a translation. The aspect
* ratio distortion induced by T is defined as the ratio
* between the highest and the lowest eigen values of M,
* that is:
*
* dist = simga_1(M) / |sigma_3(M)|
*
* Ref:
* Injective and Bounded Distortion Mappings in 3D
* N.Aigerman and Y.Lipman
* ACM Transactions on Graphics - SIGGRAPH - 2013
*/
CINO_INLINE
double aspect_ratio_distortion(const double m[3][3]);
}
#ifndef CINO_STATIC_LIB
#include "map_distortion.cpp"
#endif
#endif // CINO_MAP_DISTORTION_H
| [
"andrewwang996@gmail.com"
] | andrewwang996@gmail.com |
f75cf6e264774b5d7f9d37e2a9af23592f12440d | 4d0e3801314e728ae0d1ae4b9b029794dc771e5c | /vj/420958/H.cpp | ad8690a012384aa64971aca3ee2affae0e210bbb | [] | no_license | Perinze/oi | 8880bb028d8108eba110f0dc2b99a0de74902825 | a5cf058d661cb0c276eb126f8f809343b8937d0d | refs/heads/master | 2023-06-21T05:48:00.496697 | 2021-07-22T16:24:19 | 2021-07-22T16:24:19 | 329,524,963 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 890 | cpp | #include <cstdio>
#include <algorithm>
using namespace std;
const int MAXV = 150;
bool d[MAXV][MAXV];
int V;
void floyd()
{
for (int k = 0; k < V; k++)
for (int i = 0; i < V; i++)
for (int j = 0; j < V; j++)
d[i][j] = d[i][j] || (d[i][k] && d[k][j]);
}
int main()
{
int E;
scanf("%d%d", &V, &E);
while (E--)
{
int a, b;
scanf("%d%d", &a, &b);
a--; b--;
d[a][b] = true;
}
for (int i = 0; i < V; i++)
d[i][i] = true;
floyd();
int ans = 0;
for (int i = 0; i < V; i++)
{
bool fail = false;
for (int j = 0; j < V; j++)
if (!(d[i][j] || d[j][i]))
{
fail = true;
break;
}
if (!fail) ans++;
}
printf("%d\n", ans);
return 0;
} | [
"perinzefaper@foxmail.com"
] | perinzefaper@foxmail.com |
718e41a3005e23d05165d3b427b534b478319ecc | 3f1ae7c357ffae77c6f01492be4c2e6dc2eb940c | /C++/TheCherno/HeaderFiles/Log.cpp | 8690d7cc697f997d3c2669a2a362629246384028 | [] | no_license | shwarma01/Projects | e0c50887eaf76406ff2a6be8e2792379e7108d6e | ee45fa5acacb4f449f37b8d2f6f1bdcd371c588f | refs/heads/master | 2023-03-28T01:26:30.699088 | 2021-03-13T15:13:33 | 2021-03-13T15:13:33 | 310,616,849 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 128 | cpp | #include <iostream>
void Log(const char* msg) {
std::cout << msg << std::endl;
}
void InitLog() {
Log("Initializing Log");
} | [
"ayushjunior@gmail.com"
] | ayushjunior@gmail.com |
640751612e8bbfa013d0b6d5bbaa5bb99eb698aa | 57ad491e67a5f7b4c3b909d773c86636d7404441 | /ui/viewmodel/notifications/notifications_settings.h | 035ffae96bfd4edfebb87b4dd05e05335e32e1fa | [
"Apache-2.0"
] | permissive | lucangogo/BTCMW | d0ca011d6f6bbf33ad62b35c63b9800e9e8b89ab | bc1d63a7cda5b3a693a9b92d54b6d0b595b42a7e | refs/heads/master | 2022-07-16T22:31:47.083409 | 2020-05-19T23:06:41 | 2020-05-19T23:06:41 | 265,277,291 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,637 | h | // Copyright 2020 The Beam Team
//
// 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.
#pragma once
#include <QObject>
#include "ui/model/settings.h"
class NotificationsSettings : public QObject
{
Q_OBJECT
Q_PROPERTY(bool isNewVersionActive READ isNewVersionActive WRITE setNewVersionActive NOTIFY newVersionActiveChanged)
Q_PROPERTY(bool isBeamNewsActive READ isBeamNewsActive WRITE setBeamNewsActive NOTIFY beamNewsActiveChanged)
Q_PROPERTY(bool isTxStatusActive READ isTxStatusActive WRITE setTxStatusActive NOTIFY txStatusActiveChanged)
public:
NotificationsSettings(WalletSettings&);
bool isNewVersionActive();
bool isBeamNewsActive();
bool isTxStatusActive();
void setNewVersionActive(bool);
void setBeamNewsActive(bool);
void setTxStatusActive(bool);
signals:
void newVersionActiveChanged();
void beamNewsActiveChanged();
void txStatusActiveChanged();
public slots:
void loadFromStorage();
private:
WalletSettings& m_storage;
bool m_isNewVersionActive;
bool m_isBeamNewsActive;
bool m_isTxStatusActive;
};
| [
"dh@beam-mw.com"
] | dh@beam-mw.com |
1812991ed175a3ad98920e316ffc3d7ee5f8a0f2 | 0575946fd53953ca35d014032d1d896090b2cb41 | /cpp/GameEngine/DragonFishing/DragonFishing/src/GjkSupport.cpp | 8f53e709a55458ea0a5b191ba9dcb6cdf5a9e72f | [] | no_license | trevor-warren/ProjectPortfolio | 7628a2c9df4098daee7321524a93a3d805a69708 | 355865191611e54ef14ad0a262e91d083aa7fdec | refs/heads/master | 2022-12-08T16:39:36.331074 | 2020-08-24T00:26:17 | 2020-08-24T00:26:17 | 289,614,805 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,175 | cpp | #include "Aabb.h"
#include "GjkSupport.h"
#include "CollisionDetectionUnit.h"
namespace Engine
{
//-----------------------------------------------------------------------------SupportShape
Vector3 SupportShape::GetCenter(const std::vector<Vector3>& localPoints, const Matrix3& transform) const
{
Aabb abb;
abb.Compute(localPoints);
Vector3 center = abb.GetCenter();
center.W = 1;
center = transform * center;
return center;
}
Vector3 SupportShape::Support(const Vector3& worldDirection, const std::vector<Vector3>& localPoints, const Matrix3& localToWorldTransform) const
{
Vector3 localSpaceDirection = localToWorldTransform.Inverted() * worldDirection;
float dotP, maxDistance = -FLT_MAX;
Vector3 result = Vector3();
Aabb abb;
abb.Compute(localPoints);
Vector3 localCenter = abb.GetCenter();
Vector3 toPoint;
for (unsigned i = 0; i < localPoints.size(); ++i)
{
toPoint = localPoints[i] - localCenter;
dotP = toPoint.Dot(localSpaceDirection);
if (dotP > maxDistance)
{
maxDistance = dotP;
result = localPoints[i];
}
}
result.W = 1;
result = localToWorldTransform * result;
return result;
}
//-----------------------------------------------------------------------------SphereSupport
SphereSupport::SphereSupport(Matrix3* transform) : mTransform(transform) {}
Vector3 SphereSupport::GetCenter() const
{
return mTransform->Translation();
}
Vector3 SphereSupport::Support(const Vector3& worldDirection) const
{
Vector3 support = worldDirection;
support.Normalize();
support = GetRadius() * support + GetCenter();
return support;
}
void SphereSupport::DrawDebug(const std::shared_ptr<DebugDraw>& DebugDrawer, unsigned Group) const
{
Vector3 center = GetCenter();
float radius = GetRadius();
Vector3 right = mTransform->RightVector();
Vector3 up = mTransform->UpVector();
Vector3 front = mTransform->FrontVector();
right.Normalize();
right *= radius;
up.Normalize();
up *= radius;
front.Normalize();
front *= radius;
// This is a sphere so I can't really start drawing it easily. I just draw the diameter in the direction of each axis
DebugDrawer->DrawLine(center - right, center + right);
DebugDrawer->DrawLine(center - up, center + up);
DebugDrawer->DrawLine(center - front, center + front);
}
float SphereSupport::GetRadius() const
{
float radius;
Vector3 r = mTransform->ExtractScale();
if (r.X > r.Y && r.X > r.Z)
radius = r.X;
else if (r.Y > r.Z)
radius = r.Y;
else
radius = r.Z;
return radius;
}
//-----------------------------------------------------------------------------BoxSupport
BoxSupport::BoxSupport(Matrix3 * transform) : mTransform(transform) {}
Vector3 BoxSupport::GetCenter() const
{
return mTransform->Translation();
}
Vector3 BoxSupport::Support(const Vector3& worldDirection) const
{
Vector3 localSpaceDirection = mTransform->Inverted()* worldDirection;
Vector3 support(0.5f, 0.5f, 0.5f, 1);
for (int i = 0; i < 3; ++i)
{
if (localSpaceDirection[i] < 0)
support[i] *= -1.f;
}
support = *(mTransform) * support;
return support;
}
void BoxSupport::DrawDebug(const std::shared_ptr<DebugDraw>& DebugDrawer, unsigned Group) const
{
std::vector<Vector3> points;
GetPoints(points);
/*
Order of points
Top Points
Vector3(-0.5, 0.5, 0.5, 1) 1
Vector3( 0.5, 0.5, 0.5, 1) 0
Vector3( 0.5, 0.5, -0.5, 1) 5
Vector3(-0.5, 0.5, -0.5, 1) 7
Bottom Points
Vector3(-0.5, -0.5, 0.5, 1) 2
Vector3( 0.5, -0.5, 0.5, 1) 6
Vector3( 0.5, -0.5, -0.5, 1) 4
Vector3(-0.5, -0.5, -0.5, 1) 3
*/
RGBA color = 0xFFFFFFFF;
if (collided)
{
switch (Group)
{
case 1:// Player
color = 0xFF0000FF;
break;
case 2://Dragon
color = 0x00FF00FF;
break;
case 3://DragonProximity
color = 0xAAAAAAFF;
break;
case 4://Terrain
color = 0x0000FFFF;
break;
default:
break;
}
}
// Draw all the lines
DebugDrawer->DrawLine(points[1], points[0], color, 0.2f);
DebugDrawer->DrawLine(points[0], points[5], color, 0.2f);
DebugDrawer->DrawLine(points[5], points[7], color, 0.2f);
DebugDrawer->DrawLine(points[7], points[1], color, 0.2f);
DebugDrawer->DrawLine(points[2], points[6], color, 0.2f);
DebugDrawer->DrawLine(points[6], points[4], color, 0.2f);
DebugDrawer->DrawLine(points[4], points[3], color, 0.2f);
DebugDrawer->DrawLine(points[3], points[2], color, 0.2f);
DebugDrawer->DrawLine(points[1], points[2], color, 0.2f);
DebugDrawer->DrawLine(points[0], points[6], color, 0.2f);
DebugDrawer->DrawLine(points[5], points[4], color, 0.2f);
DebugDrawer->DrawLine(points[7], points[3], color, 0.2f);
}
//-----------------------------------------------------------------------------WedgeSupport
WedgeSupport::WedgeSupport(Matrix3 * transform) : mTransform(transform) {}
Vector3 WedgeSupport::GetCenter() const
{
return mTransform->Translation();
}
Vector3 WedgeSupport::Support(const Vector3 & worldDirection) const
{
Vector3 localSpaceDirection = mTransform->Inverted()* worldDirection;
//localSpaceDirection.Normalize();
Vector3 support(0.5f, 0.5f, 0.5f, 1);
for (int i = 0; i < 3; ++i)
{
if (localSpaceDirection[i] < 0)
support[i] *= -1.f;
}
// For the case that this is one of the points removed from the cube to make a wedge
// I have to figure out if it's closer to the points with a positive y or a negative z
if (support.Y > 0 && support.Z < 0)
{
// The magnitude of the y value is greater than the z value, so it's going more up than forward
if (localSpaceDirection.Y > -localSpaceDirection.Z)
{
support.Z *= -1.f;
}
// The magnitude of the z value is greater than the y value, so it's going more forward than up
else
{
support.Y *= -1.f;
}
}
return support;
}
void WedgeSupport::DrawDebug(const std::shared_ptr<DebugDraw>& DebugDrawer, unsigned Group) const
{
std::vector<Vector3> points;
GetPoints(points);
/*
Order of points
Top Points
Vector3(-0.5, 0.5, 0.5) 1
Vector3( 0.5, 0.5, 0.5) 0
Bottom Points
Vector3(-0.5, -0.5, 0.5) 2
Vector3( 0.5, -0.5, 0.5) 5
Vector3(-0.5, -0.5, -0.5) 3
Vector3( 0.5, -0.5, -0.5) 4
*/
// Draw all the lines
DebugDrawer->DrawLine(points[1], points[0]);
DebugDrawer->DrawLine(points[2], points[5]);
DebugDrawer->DrawLine(points[5], points[2]);
DebugDrawer->DrawLine(points[3], points[4]);
DebugDrawer->DrawLine(points[4], points[2]);
DebugDrawer->DrawLine(points[1], points[2]);
DebugDrawer->DrawLine(points[1], points[3]);
DebugDrawer->DrawLine(points[0], points[5]);
DebugDrawer->DrawLine(points[0], points[4]);
}
} | [
"trevorb309@gmail.com"
] | trevorb309@gmail.com |
9e752e1e69b2fe82be8eefdd3929029c1387af8d | 86b20fb76f0c27c93ec9f967083ca03938a867ec | /primes.h | e131239b0aca895bb35865950024d40e381eea6f | [
"MIT"
] | permissive | mhdeleglise/PsiTheta | 722c952aa2a117c465db72630367c7f119ee1c05 | 21f4f6553851f218801a733f607426c3dba9ba11 | refs/heads/master | 2021-01-11T23:05:37.493741 | 2017-03-05T17:23:03 | 2017-03-05T17:23:03 | 78,546,669 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 467 | h | #ifndef primes_h
#define primes_h
class Prime_table{
public:
Prime_table() {_pi=NULL; _p=NULL;};
Prime_table(long x) {init_pi(x); init_p(x);}
long pi(long x) {return _pi[x];}
long prime(int i) {return _p[i];}
long maxprime() {return maxp;}
long number_of_primes() {return pimax;}
void init(long x);
void display();
~Prime_table();
private:
void init_pi(long x);
void init_p(long x);
long pimax;
int *_pi;
int *_p;
long maxp;
};
#endif
| [
"deleglis@mac2017.home"
] | deleglis@mac2017.home |
1f7312c113b48f75dcffca1ae57e1a7ca65f0fd1 | 7ea37716cff11c15fed0774ea9b1ae56708adcf3 | /core/io_utils.h | 89444f081648ea77d4cd1e809ed5b23cbe2545af | [
"Apache-2.0"
] | permissive | tlemo/darwin | ee9ad08f18c6cda057fe4d3f14347ba2aa228b5b | 669dd93f931e33e501e49155d4a7ba09297ad5a9 | refs/heads/master | 2022-03-08T14:45:17.956167 | 2021-04-16T23:07:58 | 2021-04-16T23:07:58 | 157,114,747 | 105 | 21 | Apache-2.0 | 2021-02-09T18:15:23 | 2018-11-11T19:46:24 | C++ | UTF-8 | C++ | false | false | 2,116 | h | // Copyright 2018 The Darwin Neuroevolution Framework Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "exception.h"
#include <iostream>
#include <vector>
using namespace std;
namespace core {
// extracts an exact match of the specified token, after skipping any leading whitespaces
// (it throws if the input does not match the token)
inline istream& operator>>(istream& stream, const char* token) {
istream::sentry sentry(stream);
for (const char* p = token; *p; ++p) {
if (stream.fail())
throw core::Exception("bad stream state");
if (stream.get() != *p)
throw core::Exception("input doesn't match the expected token '%s'", token);
}
return stream;
}
// peek at the first non-whitespace character, without extracting it
inline char nextSymbol(istream& stream) {
if (stream.fail())
throw core::Exception("bad stream state");
return char((stream >> std::ws).peek());
}
template <class T>
ostream& operator<<(ostream& stream, const vector<T>& v) {
stream << "{ ";
for (size_t i = 0; i < v.size(); ++i) {
if (i != 0)
stream << ", ";
stream << v[i];
}
stream << " }";
return stream;
}
template <class T>
istream& operator>>(istream& stream, vector<T>& v) {
vector<T> extracted_vector;
stream >> "{";
if (nextSymbol(stream) != '}') {
for (;;) {
T value = {};
stream >> value;
extracted_vector.push_back(value);
if (nextSymbol(stream) == '}')
break;
stream >> ",";
}
}
stream >> "}";
v = extracted_vector;
return stream;
}
} // namespace core
| [
"lemo1234@gmail.com"
] | lemo1234@gmail.com |
5f8a32f4e94b89407a7c5f60450e2c10f7238cde | 67baab02cfda6c54a287d63d0874824cf15f3ba6 | /atcoder/abc079d.cpp | 215e148829e45494f1197d54fa033c00d05ddd29 | [
"MIT"
] | permissive | sogapalag/problems | a14eedd8cfcdb52661479c8c90e08737aaeeb32b | 0ea7d65448e1177f8b3f81124a82d187980d659c | refs/heads/master | 2021-01-12T17:49:52.007234 | 2020-08-18T14:51:40 | 2020-08-18T14:51:40 | 71,629,601 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,339 | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 10;
int cost[N][N];
void solve() {
int H, W;
cin >> H >> W;
int n=10;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> cost[j][i]; // tran
}
}
auto dijkstra = [&](int s){
vector<int> d(n, INF);
vector<bool> trk(n, false);
d[s] = 0;
while (true) {
int mindis = INF;
int u = -1;
for (int i = 0; i < n; i++) {
if (!trk[i] && d[i] < mindis) {
u = i; mindis = d[i];
}
}
if (!~u) break;
trk[u] = true;
for (int v = 0; v < n; v++) {
if (!trk[v] && d[v] > d[u] + cost[u][v]) {
d[v] = d[u] + cost[u][v];
}
}
}
return d;
};
auto d = dijkstra(1);
vector<int> cnt(10);
for (int _ = 0; _ < H; _++) {
for (int _ = 0; _ < W; _++) {
int x; cin >> x;
if (x!=-1)cnt[x]++;
}
}
int res = 0;
for (int i = 0; i < n; i++) {
res += cnt[i] * d[i];
}
cout << res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
cout << endl;
}
| [
"yan-zp@foxmail.com"
] | yan-zp@foxmail.com |
b4f9083902a8672b0154a219050dfd24cbb3785d | f1ee65fbe1ffc43c2aac45e41515f1987eb534a4 | /src/net/third_party/quiche/src/quiche/quic/core/quic_stream_id_manager.cc | 1443211786c4dd4e3d6bacec98525f6f07ecf5fb | [
"BSD-3-Clause"
] | permissive | klzgrad/naiveproxy | 6e0d206b6f065b9311d1e12b363109f2d35cc058 | 8ef1cecadfd4e2b5d57e7ea2fa42d05717e51c2e | refs/heads/master | 2023-08-20T22:42:12.511091 | 2023-06-04T03:54:34 | 2023-08-16T23:30:19 | 119,178,893 | 5,710 | 976 | BSD-3-Clause | 2023-08-05T10:59:59 | 2018-01-27T16:02:33 | C++ | UTF-8 | C++ | false | false | 9,830 | cc | // Copyright (c) 2018 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 "quiche/quic/core/quic_stream_id_manager.h"
#include <cstdint>
#include <string>
#include "absl/strings/str_cat.h"
#include "quiche/quic/core/quic_connection.h"
#include "quiche/quic/core/quic_constants.h"
#include "quiche/quic/core/quic_session.h"
#include "quiche/quic/core/quic_utils.h"
#include "quiche/quic/core/quic_versions.h"
#include "quiche/quic/platform/api/quic_flag_utils.h"
#include "quiche/quic/platform/api/quic_flags.h"
#include "quiche/quic/platform/api/quic_logging.h"
namespace quic {
#define ENDPOINT \
(perspective_ == Perspective::IS_SERVER ? " Server: " : " Client: ")
QuicStreamIdManager::QuicStreamIdManager(
DelegateInterface* delegate, bool unidirectional, Perspective perspective,
ParsedQuicVersion version, QuicStreamCount max_allowed_outgoing_streams,
QuicStreamCount max_allowed_incoming_streams)
: delegate_(delegate),
unidirectional_(unidirectional),
perspective_(perspective),
version_(version),
outgoing_max_streams_(max_allowed_outgoing_streams),
next_outgoing_stream_id_(GetFirstOutgoingStreamId()),
outgoing_stream_count_(0),
incoming_actual_max_streams_(max_allowed_incoming_streams),
incoming_advertised_max_streams_(max_allowed_incoming_streams),
incoming_initial_max_open_streams_(max_allowed_incoming_streams),
incoming_stream_count_(0),
largest_peer_created_stream_id_(
QuicUtils::GetInvalidStreamId(version.transport_version)) {}
QuicStreamIdManager::~QuicStreamIdManager() {}
bool QuicStreamIdManager::OnStreamsBlockedFrame(
const QuicStreamsBlockedFrame& frame, std::string* error_details) {
QUICHE_DCHECK_EQ(frame.unidirectional, unidirectional_);
if (frame.stream_count > incoming_advertised_max_streams_) {
// Peer thinks it can send more streams that we've told it.
*error_details = absl::StrCat(
"StreamsBlockedFrame's stream count ", frame.stream_count,
" exceeds incoming max stream ", incoming_advertised_max_streams_);
return false;
}
QUICHE_DCHECK_LE(incoming_advertised_max_streams_,
incoming_actual_max_streams_);
if (incoming_advertised_max_streams_ == incoming_actual_max_streams_) {
// We have told peer about current max.
return true;
}
if (frame.stream_count < incoming_actual_max_streams_) {
// Peer thinks it's blocked on a stream count that is less than our current
// max. Inform the peer of the correct stream count.
SendMaxStreamsFrame();
}
return true;
}
bool QuicStreamIdManager::MaybeAllowNewOutgoingStreams(
QuicStreamCount max_open_streams) {
if (max_open_streams <= outgoing_max_streams_) {
// Only update the stream count if it would increase the limit.
return false;
}
// This implementation only supports 32 bit Stream IDs, so limit max streams
// if it would exceed the max 32 bits can express.
outgoing_max_streams_ =
std::min(max_open_streams, QuicUtils::GetMaxStreamCount());
return true;
}
void QuicStreamIdManager::SetMaxOpenIncomingStreams(
QuicStreamCount max_open_streams) {
QUIC_BUG_IF(quic_bug_12413_1, incoming_stream_count_ > 0)
<< "non-zero incoming stream count " << incoming_stream_count_
<< " when setting max incoming stream to " << max_open_streams;
QUIC_DLOG_IF(WARNING, incoming_initial_max_open_streams_ != max_open_streams)
<< absl::StrCat(unidirectional_ ? "unidirectional " : "bidirectional: ",
"incoming stream limit changed from ",
incoming_initial_max_open_streams_, " to ",
max_open_streams);
incoming_actual_max_streams_ = max_open_streams;
incoming_advertised_max_streams_ = max_open_streams;
incoming_initial_max_open_streams_ = max_open_streams;
}
void QuicStreamIdManager::MaybeSendMaxStreamsFrame() {
int divisor = GetQuicFlag(quic_max_streams_window_divisor);
if (divisor > 0) {
if ((incoming_advertised_max_streams_ - incoming_stream_count_) >
(incoming_initial_max_open_streams_ / divisor)) {
// window too large, no advertisement
return;
}
}
SendMaxStreamsFrame();
}
void QuicStreamIdManager::SendMaxStreamsFrame() {
QUIC_BUG_IF(quic_bug_12413_2,
incoming_advertised_max_streams_ >= incoming_actual_max_streams_);
incoming_advertised_max_streams_ = incoming_actual_max_streams_;
delegate_->SendMaxStreams(incoming_advertised_max_streams_, unidirectional_);
}
void QuicStreamIdManager::OnStreamClosed(QuicStreamId stream_id) {
QUICHE_DCHECK_NE(QuicUtils::IsBidirectionalStreamId(stream_id, version_),
unidirectional_);
if (QuicUtils::IsOutgoingStreamId(version_, stream_id, perspective_)) {
// Nothing to do for outgoing streams.
return;
}
// If the stream is inbound, we can increase the actual stream limit and maybe
// advertise the new limit to the peer.
if (incoming_actual_max_streams_ == QuicUtils::GetMaxStreamCount()) {
// Reached the maximum stream id value that the implementation
// supports. Nothing can be done here.
return;
}
// One stream closed, and another one can be opened.
incoming_actual_max_streams_++;
MaybeSendMaxStreamsFrame();
}
QuicStreamId QuicStreamIdManager::GetNextOutgoingStreamId() {
QUIC_BUG_IF(quic_bug_12413_3, outgoing_stream_count_ >= outgoing_max_streams_)
<< "Attempt to allocate a new outgoing stream that would exceed the "
"limit ("
<< outgoing_max_streams_ << ")";
QuicStreamId id = next_outgoing_stream_id_;
next_outgoing_stream_id_ +=
QuicUtils::StreamIdDelta(version_.transport_version);
outgoing_stream_count_++;
return id;
}
bool QuicStreamIdManager::CanOpenNextOutgoingStream() const {
QUICHE_DCHECK(VersionHasIetfQuicFrames(version_.transport_version));
return outgoing_stream_count_ < outgoing_max_streams_;
}
bool QuicStreamIdManager::MaybeIncreaseLargestPeerStreamId(
const QuicStreamId stream_id, std::string* error_details) {
// |stream_id| must be an incoming stream of the right directionality.
QUICHE_DCHECK_NE(QuicUtils::IsBidirectionalStreamId(stream_id, version_),
unidirectional_);
QUICHE_DCHECK_NE(QuicUtils::IsServerInitiatedStreamId(
version_.transport_version, stream_id),
perspective_ == Perspective::IS_SERVER);
if (available_streams_.erase(stream_id) == 1) {
// stream_id is available.
return true;
}
if (largest_peer_created_stream_id_ !=
QuicUtils::GetInvalidStreamId(version_.transport_version)) {
QUICHE_DCHECK_GT(stream_id, largest_peer_created_stream_id_);
}
// Calculate increment of incoming_stream_count_ by creating stream_id.
const QuicStreamCount delta =
QuicUtils::StreamIdDelta(version_.transport_version);
const QuicStreamId least_new_stream_id =
largest_peer_created_stream_id_ ==
QuicUtils::GetInvalidStreamId(version_.transport_version)
? GetFirstIncomingStreamId()
: largest_peer_created_stream_id_ + delta;
const QuicStreamCount stream_count_increment =
(stream_id - least_new_stream_id) / delta + 1;
if (incoming_stream_count_ + stream_count_increment >
incoming_advertised_max_streams_) {
QUIC_DLOG(INFO) << ENDPOINT
<< "Failed to create a new incoming stream with id:"
<< stream_id << ", reaching MAX_STREAMS limit: "
<< incoming_advertised_max_streams_ << ".";
*error_details = absl::StrCat("Stream id ", stream_id,
" would exceed stream count limit ",
incoming_advertised_max_streams_);
return false;
}
for (QuicStreamId id = least_new_stream_id; id < stream_id; id += delta) {
available_streams_.insert(id);
}
incoming_stream_count_ += stream_count_increment;
largest_peer_created_stream_id_ = stream_id;
return true;
}
bool QuicStreamIdManager::IsAvailableStream(QuicStreamId id) const {
QUICHE_DCHECK_NE(QuicUtils::IsBidirectionalStreamId(id, version_),
unidirectional_);
if (QuicUtils::IsOutgoingStreamId(version_, id, perspective_)) {
// Stream IDs under next_ougoing_stream_id_ are either open or previously
// open but now closed.
return id >= next_outgoing_stream_id_;
}
// For peer created streams, we also need to consider available streams.
return largest_peer_created_stream_id_ ==
QuicUtils::GetInvalidStreamId(version_.transport_version) ||
id > largest_peer_created_stream_id_ ||
available_streams_.contains(id);
}
QuicStreamId QuicStreamIdManager::GetFirstOutgoingStreamId() const {
return (unidirectional_) ? QuicUtils::GetFirstUnidirectionalStreamId(
version_.transport_version, perspective_)
: QuicUtils::GetFirstBidirectionalStreamId(
version_.transport_version, perspective_);
}
QuicStreamId QuicStreamIdManager::GetFirstIncomingStreamId() const {
return (unidirectional_) ? QuicUtils::GetFirstUnidirectionalStreamId(
version_.transport_version,
QuicUtils::InvertPerspective(perspective_))
: QuicUtils::GetFirstBidirectionalStreamId(
version_.transport_version,
QuicUtils::InvertPerspective(perspective_));
}
QuicStreamCount QuicStreamIdManager::available_incoming_streams() const {
return incoming_advertised_max_streams_ - incoming_stream_count_;
}
} // namespace quic
| [
"kizdiv@gmail.com"
] | kizdiv@gmail.com |
869fa4e1b1f944befa1bcabdd73889df0bc3407b | 4b4b803e04d5b9fec108471bac9b369fe7691249 | /shu1904.cpp | 4c9b447fd352f988ea9b4ad1e872c89fa64b7af2 | [] | no_license | lonelam/LearnC | b96f9efcde52e79185a66e6c035b28817ed8ff75 | 8f845626c84fa7301a22cb994c15c9ae20a26a64 | refs/heads/master | 2021-01-18T23:42:14.724933 | 2016-07-09T09:29:37 | 2016-07-09T09:29:37 | 52,439,706 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 335 | cpp | #include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
if(n==1)
{
cout<<"Accepted\n";
}
else if(n==2)
{
cout<<"Wrong Answer\n";
}
else
{
cout<<"handsome yaoge\n";
}
}
}
| [
"lai@DESKTOP-HHP58PF.localdomain"
] | lai@DESKTOP-HHP58PF.localdomain |
737e9bc60e9f79301bfd9bbc3b8cb6407ec9c713 | f928968e21bf249064d26165bb71f32bb459375b | /C/common/src/rendercheck_d3d11.cpp | 79569c0d8b2c0b360f71e45654ed806030ccbdcd | [] | no_license | FNNDSC/gpu | 82f7ee88d1b1c8bb21255b369a2c2a07a1d4db0d | 6f9175caaf4d4f463397ebd752b820cd7e863713 | refs/heads/master | 2016-09-06T19:10:14.667210 | 2010-04-08T13:13:54 | 2010-04-08T13:13:54 | 2,512,739 | 6 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 3,754 | cpp | /*
* Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and
* proprietary rights in and to this software and related documentation.
* Any use, reproduction, disclosure, or distribution of this software
* and related documentation without an express license agreement from
* NVIDIA Corporation is strictly prohibited.
*
* Please refer to the applicable NVIDIA end user license agreement (EULA)
* associated with this source code for terms and conditions that govern
* your use of this NVIDIA software.
*
*/
//
// Utility funcs to wrap up saving a surface or the back buffer as a PPM file
// In addition, wraps up a threshold comparision of two PPMs.
//
// These functions are designed to be used to implement an automated QA testing for SDK samples.
//
// Author: Bryan Dudash
// Email: sdkfeedback@nvidia.com
//
// Copyright (c) NVIDIA Corporation. All rights reserved.
////////////////////////////////////////////////////////////////////////////////
#include <cutil.h>
#include <rendercheck_d3d11.h>
HRESULT CheckRenderD3D11::ActiveRenderTargetToPPM(ID3D11Device *pDevice, const char *zFileName)
{
ID3D11DeviceContext *pDeviceCtxt;
pDevice->GetImmediateContext(&pDeviceCtxt);
ID3D11RenderTargetView *pRTV = NULL;
pDeviceCtxt->OMGetRenderTargets(1,&pRTV,NULL);
ID3D11Resource *pSourceResource = NULL;
pRTV->GetResource(&pSourceResource);
return ResourceToPPM(pDevice,pSourceResource,zFileName);
}
HRESULT CheckRenderD3D11::ResourceToPPM(ID3D11Device*pDevice, ID3D11Resource *pResource, const char *zFileName)
{
ID3D11DeviceContext *pDeviceCtxt;
pDevice->GetImmediateContext(&pDeviceCtxt);
D3D11_RESOURCE_DIMENSION rType;
pResource->GetType(&rType);
if(rType != D3D11_RESOURCE_DIMENSION_TEXTURE2D)
{
printf("SurfaceToPPM: pResource is not a 2D texture! Aborting...\n");
return E_FAIL;
}
ID3D11Texture2D * pSourceTexture = (ID3D11Texture2D *)pResource;
ID3D11Texture2D * pTargetTexture = NULL;
D3D11_TEXTURE2D_DESC desc;
pSourceTexture->GetDesc(&desc);
desc.BindFlags = 0;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
desc.Usage = D3D11_USAGE_STAGING;
if(FAILED(pDevice->CreateTexture2D(&desc,NULL,&pTargetTexture)))
{
printf("SurfaceToPPM: Unable to create target Texture resoruce! Aborting... \n");
return E_FAIL;
}
pDeviceCtxt->CopyResource(pTargetTexture,pSourceTexture);
D3D11_MAPPED_SUBRESOURCE mappedTex2D;
pDeviceCtxt->Map(pTargetTexture, 0, D3D11_MAP_READ,0,&mappedTex2D);
// Need to convert from dx pitch to pitch=width
unsigned char *pPPMData = new unsigned char[desc.Width*desc.Height*4];
for(unsigned int iHeight = 0;iHeight<desc.Height;iHeight++)
{
memcpy(&(pPPMData[iHeight*desc.Width*4]),(unsigned char*)(mappedTex2D.pData)+iHeight*mappedTex2D.RowPitch,desc.Width*4);
}
pDeviceCtxt->Unmap(pTargetTexture, 0);
// Prepends the PPM header info and bumps byte data afterwards
cutSavePPM4ub(zFileName, pPPMData, desc.Width, desc.Height);
delete [] pPPMData;
pTargetTexture->Release();
return S_OK;
}
bool CheckRenderD3D11::PPMvsPPM( const char *src_file, const char *ref_file, const char *exec_path,
const float epsilon, const float threshold )
{
char *ref_file_path = cutFindFilePath(ref_file, exec_path);
if (ref_file_path == NULL) {
printf("CheckRenderD3D11::PPMvsPPM unable to find <%s> in <%s> Aborting comparison!\n", ref_file, exec_path);
printf(">>> Check info.xml and [project//data] folder <%s> <<<\n", ref_file);
printf("Aborting comparison!\n");
printf(" FAILURE!\n");
return false;
}
return cutComparePPM(src_file,ref_file_path,epsilon,threshold,true) == CUTTrue;
} | [
"ginsburg@2e298075-0c49-4d30-86d1-9432a23a86c5"
] | ginsburg@2e298075-0c49-4d30-86d1-9432a23a86c5 |
aaffab4be52772a28f0f5f6f0352b5f1003b4040 | 11c4c7afaa3f09100f73378be285bb2e75195cfa | /tests/tests-var.cpp | f32f980c8b86494f6b8afa92e343fe2ed4aac2b7 | [] | no_license | yodatak/Cpp.js | 56f3cbeac7357e6f2df3027c104f4afa1becd268 | cc9fab9f69aabd5e0cf4f0e44d223dc10ff6e7a9 | refs/heads/master | 2020-03-28T21:51:52.367290 | 2018-09-02T18:07:12 | 2018-09-02T18:07:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 605 | cpp | #include <catch2/catch.hpp>
#include <iostream>
#include "var.h"
TEST_CASE("Var", "[var]"){
std::ostringstream os;
var a{{{"d", "e"}}};
var const& ref = a;
var copie = a;
a["b"] = 34.;
os << '\n' << a << '\n';
CHECK(os.str() == R"(
{"b":34,"d":"e"}
)");
CHECK(a["b"] == 34);
CHECK(ref["b"] == 34);
CHECK(copie["b"] == a["b"]);
os.str("");
var v = 2 < 1;
os << v;
CHECK(os.str() == "false");
var cmp_a = 4.;
var cmp_b = NAN;
CHECK((cmp_a < cmp_b) == false);
var cmp_c = "Not a number";
CHECK((cmp_a < cmp_c) == false);
}
| [
"germinolegrand@gmail.com"
] | germinolegrand@gmail.com |
138d466adb3783c39fb81c2a6541d6dd57647c4c | fff771a3bcd6aa3a45de7cd248a80091bb22e9d8 | /Source/Graphics/OpenGL/OpenGLMaterial.cpp | 3a075aa1919d6f762eb8a6eb76120359c8d62ed5 | [] | no_license | Blodjer/B2D | ba9e495d8e662f4d882c5b903a3b8aa422e322bf | f091d1ec72b14bdfb110e2071a27a723dd1c5d4c | refs/heads/master | 2023-08-02T09:16:12.695209 | 2021-04-14T15:38:10 | 2021-04-14T15:38:10 | 115,878,910 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 150 | cpp | #include "B2D_pch.h"
#include "OpenGLMaterial.h"
#include "OpenGLShader.h"
OpenGLMaterial::OpenGLMaterial(GLuint handle)
: m_handle(handle)
{
}
| [
"j95.szwaczka@gmail.com"
] | j95.szwaczka@gmail.com |
1942ae7b18feeaadd4480c3285c62c46eebd1049 | 8635db0d8e893ba9ba3fe9fb0182af8ade2c8f43 | /code_esp/code_esp.ino | 6d4f29e48d0dd7190a4dd703e674a2988b45d25f | [] | no_license | rashzongo/iot_http | d4341db7c3980a934da807297dbb4f7aa561d651 | 4f386e284ab62b24462f29258e752977889afbf1 | refs/heads/master | 2020-04-29T17:36:38.759481 | 2019-03-19T18:41:08 | 2019-03-19T18:41:08 | 176,301,303 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,368 | ino | #include <WiFi.h>
#include <HTTPClient.h>
#include "OneWire.h"
#include "DallasTemperature.h"
OneWire oneWire(23);
DallasTemperature tempSensor(&oneWire);
WiFiClient client;
const char* NET_SSID = "asus_hotspot";//"HUAWEI-6EC2";
const char* NET_PWD = "1234567890";
const char* SERVER = "192.168.43.152";
const int PORT = 3000;
int sensorValue;
int LED_LIGHT = 19;
int LED_RADIATOR = 21;
int lightState = 0;
int radiatorState = 0;
float lightValue = 0;
float tempValue = 0;
unsigned long lastUpdateTime = 0;
unsigned long lastPostTime = 0;
const unsigned long postingInterval = 1L * 1000L;
const unsigned long updateInterval = 500L;
void print_ip_status(){
Serial.print("WiFi connected \n");
Serial.print("IP address: ");
Serial.print(WiFi.localIP());
Serial.print("\n");
Serial.print("MAC address: ");
Serial.print(WiFi.macAddress());
Serial.print("\n");
}
void connect_wifi(){
Serial.println("Connecting Wifi...");
WiFi.begin(NET_SSID, NET_PWD);
while(WiFi.status() != WL_CONNECTED){
Serial.print("Attempting to connect ..\n");
delay(1000);
}
Serial.print("Connected to local Wifi\n");
}
int getRequest(char *url) {
HTTPClient http;
String tmp = "http://";
tmp = tmp + SERVER;
tmp = tmp + ":";
tmp = tmp + PORT;
tmp = tmp + "/";
tmp = tmp + url;
Serial.println("Getting form " + tmp + "...");
http.begin(tmp);
http.addHeader("Content-Type", "application/json");
int httpResponseCode = http.GET();
String response = "";
if(httpResponseCode > 0){
response = http.getString();
Serial.print(httpResponseCode);
Serial.println(" : " + response);
}
else{
Serial.println("Error on GET: " + httpResponseCode);
}
http.end();
return atoi(response.c_str());
}
void postRequest(char *url, float value, int elmStatus){
HTTPClient http;
String postData = "{ \"value\" : ";
postData = postData + value;
postData = postData + " , \"mac_add\" : \"";
postData = postData + WiFi.macAddress();
postData = postData + "\", \"powered\" : ";
postData = postData + elmStatus;
postData = postData + "}";
Serial.println("Sending" + postData + " to " + url + "...");
String tmp = "http://";
tmp = tmp + SERVER;
tmp = tmp + ":";
tmp = tmp + PORT;
tmp = tmp + "/";
tmp = tmp + url;
http.begin(tmp);
http.addHeader("Content-Type", "application/json");
int httpResponseCode = http.POST(postData);
if(httpResponseCode > 0){
String response = http.getString();
Serial.print(httpResponseCode);
Serial.println(" : " + response);
}
else{
Serial.println("Error on sending POST: " + httpResponseCode);
}
http.end();
}
int getLightState(){
String url = "light/";
url = url + WiFi.macAddress().c_str();
url = url + "/state";
return getRequest((char*)url.c_str());
}
int getRadiatorState(){
String url = "temperature/";
url = url + WiFi.macAddress().c_str();
url = url + "/state";
return getRequest((char*)url.c_str());
}
void postLightData(float sensorValue){
postRequest("light", sensorValue, lightState);
}
void postTemperatureData(float sensorValue){
postRequest("temperature", sensorValue, radiatorState);
}
void setup() {
Serial.begin(9600);
pinMode(LED_LIGHT, OUTPUT);
pinMode(LED_RADIATOR, OUTPUT);
tempSensor.begin();
if(WiFi.status() != WL_CONNECTED)
connect_wifi();
print_ip_status();
}
void postData(){
lightValue = analogRead (A0);
tempSensor.requestTemperaturesByIndex(0);
tempValue = tempSensor.getTempCByIndex(0);
Serial.print("\nTemperature : ");
Serial.println(tempValue);
Serial.print("\nLight intensity : ");
Serial.println(lightValue);
Serial.print("\n");
if(WiFi.status() != WL_CONNECTED)
connect_wifi();
postTemperatureData(tempValue);
postLightData(lightValue);
lastPostTime = millis();
}
void updateComponents(){
int repL = getLightState();
int repR = getRadiatorState();
if(repL == 0 || repL == 1)
lightState = repL;
if(repR == 0 || repR == 1)
radiatorState = repR;
digitalWrite(LED_LIGHT, lightState);
digitalWrite(LED_RADIATOR, radiatorState);
}
void loop() {
while (client.available()) {
char c = client.read();
Serial.write(c);
}
if (millis() - lastPostTime > postingInterval) {
postData();
}
if (millis() - lastUpdateTime > updateInterval) {
updateComponents();
}
}
| [
"rsouleyh95@gmail.com"
] | rsouleyh95@gmail.com |
afd9fa5434844ab1ff1b3c553e7f6e6b7a6f25f8 | 3ef99240a541f699d71d676db514a4f3001b0c4b | /UVa Online Judge/v105/10505.cc | f2d04cc2f3c03b391f9a3bba57018aa681477940 | [
"MIT"
] | permissive | mjenrungrot/competitive_programming | 36bfdc0e573ea2f8656b66403c15e46044b9818a | e0e8174eb133ba20931c2c7f5c67732e4cb2b703 | refs/heads/master | 2022-03-26T04:44:50.396871 | 2022-02-10T11:44:13 | 2022-02-10T11:44:13 | 46,323,679 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,785 | cc | /*=============================================================================
# Author: Teerapat Jenrungrot - https://github.com/mjenrungrot/
# FileName: 10505.cc
# Description: UVa Online Judge - 10505
=============================================================================*/
#include <bits/stdc++.h>
#pragma GCC optimizer("Ofast")
#pragma GCC target("avx2")
using namespace std;
typedef pair<int, int> ii;
typedef pair<long long, long long> ll;
typedef pair<double, double> dd;
typedef tuple<int, int, int> iii;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<dd> vdd;
vs split(string line, regex re) {
vs output;
sregex_token_iterator it(line.begin(), line.end(), re, -1), it_end;
while (it != it_end) {
output.push_back(it->str());
it++;
}
return output;
}
const int INF_INT = 1e9 + 7;
const long long INF_LL = 1e18;
const int MAXN = 205;
vi V[MAXN];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
for (int i = 0; i < MAXN; i++) V[i].clear();
int N;
cin >> N;
for (int i = 1; i <= N; i++) {
int k;
cin >> k;
for (int j = 1; j <= k; j++) {
int x;
cin >> x;
if (x > N) continue;
V[i].push_back(x);
V[x].push_back(i);
}
}
int ans = 0;
vi color(N + 1, INF_INT);
for (int i = 1; i <= N; i++) {
if (color[i] != INF_INT) continue;
int not_bipartite = false;
int count1 = 0, count2 = 0;
vi curr_comp;
queue<int> Q;
curr_comp.push_back(i);
color[i] = 0, count1++;
Q.push(i);
while (not Q.empty()) {
int u = Q.front();
Q.pop();
for (auto v : V[u]) {
if (color[v] == INF_INT) {
color[v] = 1 - color[u];
curr_comp.push_back(v);
(color[v] ? count2 : count1)++;
Q.push(v);
} else if (color[v] == color[u]) {
not_bipartite = true;
}
}
}
if (not_bipartite) {
for (auto x : curr_comp) color[x] = -INF_INT;
continue;
}
ans += max(count1, count2);
}
cout << ans << endl;
}
return 0;
} | [
"15001582+mjenrungrot@users.noreply.github.com"
] | 15001582+mjenrungrot@users.noreply.github.com |
337527ec9b7490d72353e6b6d2a83d71b1eb0001 | 9c2bbb572073c4da711c667a8cacf08063e767bb | /CppProperty/Property.cpp | ed6c004f90bfd2abfdc6b501205f2d72002dfc46 | [] | no_license | JimFawcett/CppProperties | 2222f62b4c40fd59f56ef52ae23c727e654c5b70 | 84d88522fee77f1fa74acfedb640840c235fbd60 | refs/heads/master | 2022-12-11T05:49:37.002543 | 2022-12-03T00:37:59 | 2022-12-03T00:37:59 | 194,754,643 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,555 | cpp | // Property.cpp
#include "Property.h"
#include <iostream>
#include <vector>
#include <deque>
#include <stack>
#include <unordered_map>
#include <type_traits>
int main()
{
std::cout << "\n Testing Properties";
std::cout << "\n ====================\n";
std::cout << "\n Testing PropertyBase<int> class";
std::cout << "\n -----------------------------";
PropertyBase<int> iProp1 = 6;
std::cout << "\n iProp1 = " << iProp1();
show("iProp1() = ", iProp1());
PropertyBase<int> iProp2;
iProp2 = 3;
std::cout << "\n iProp2 = " << iProp2();
PropertyBase<int> iProp3 = iProp1() + iProp2();
std::cout << "\n iProp3 = " << iProp3();
std::cout << "\n\n Testing Property<int> class";
std::cout << "\n -----------------------------";
Property<int> P_iProp1;
P_iProp1(6);
std::cout << "\n P_iProp1 = " << P_iProp1();
show("P_iProp1() = ", P_iProp1());
Property<int> P_iProp1a(6);
show("P_iProp1a() = ", P_iProp1a());
Property<int> P_iProp2;
int test = 3;
P_iProp2 = 3;
std::cout << "\n P_iProp2 = " << P_iProp2();
int sum = P_iProp1() + P_iProp2();
Property<int> P_iProp3(sum);
P_iProp3 = P_iProp1() + P_iProp2();
std::cout << "\n P_iProp3 = " << P_iProp3();
std::cout << "\n\n Testing TS_Property<int> class";
std::cout << "\n --------------------------------";
TS_Property<int> TS_iProp1;
TS_iProp1(6);
std::cout << "\n TS_iProp1 = " << TS_iProp1();
show("TS_iProp1() = ", TS_iProp1());
TS_Property<int> TS_iProp1a(6);
show("TS_iProp1a() = ", TS_iProp1a());
TS_Property<int> TS_iProp2;
test = 3;
TS_iProp2 = 3;
std::cout << "\n TS_iProp2 = " << TS_iProp2();
sum = TS_iProp1() + TS_iProp2();
TS_Property<int> TS_iProp3(sum);
TS_iProp3 = TS_iProp1() + TS_iProp2();
std::cout << "\n TS_iProp3 = " << TS_iProp3();
std::cout << "\n\n Testing TS_Property<std::vector<int>>";
std::cout << "\n ---------------------------------------";
TS_Property<std::vector<int>> TS_PropVi;
TS_PropVi.push_back(3);
TS_PropVi.push_back(2);
TS_PropVi.push_back(1);
std::vector<int> vi = TS_PropVi();
std::vector<int>::iterator iter = vi.begin();
show("TS_PropVi", TS_PropVi());
std::cout << "\n\n TS_PropVi.erase(TS_PropVi.begin() + 1):";
iter = TS_PropVi.begin();
iter = TS_PropVi.erase(iter + 1);
show("TS_PropVi", TS_PropVi());
std::cout << "\n\n TS_PropVi.insert(TS_PropVi.begin() + 1, 13):";
iter = TS_PropVi.begin();
iter = TS_PropVi.insert(iter + 1, 13);
show("TS_PropVi", TS_PropVi());
std::cout << std::endl;
std::cout << "\n\n TS_PropVi.push_back(4):";
TS_PropVi.push_back(4);
show("TS_PropVi:", TS_PropVi());
std::cout << "\n\n TS_PropVi.push_back(2):";
TS_PropVi.push_back(2);
show("TS_PropVi:", TS_PropVi());
std::cout << "\n\n TS_PropVi.push_back(3):";
TS_PropVi.push_back(3);
show("TS_PropVi:", TS_PropVi());
std::cout << "\n\n creating a std::vector<int>, testVec";
std::vector<int> testVec;
testVec.push_back(-7);
std::cout << "\n TS_PropVi(testVec):";
TS_Property<std::vector<int>> TS_PropVi1(testVec);
show("TS_PropVi1", TS_PropVi1());
std::cout << "\n\n TS_PropVi2 = testVec";
TS_Property<std::vector<int>> TS_PropVi2 = testVec;
std::cout << "\n push_back(18)";
testVec.push_back(18);
TS_PropVi2 = testVec;
show("TS_PropVi2", TS_PropVi2());
std::cout << "\n\n TS_PropVi2.lock()";
std::cout << "\n int val0 = TS_PropVi2[0]";
std::cout << "\n TS_PropVi2.unlock()";
TS_PropVi2.lock();
int val0 = TS_PropVi2[0];
TS_PropVi2.unlock();
std::cout << "\n TS_PropVi2[0] = " << val0;
std::cout << "\n after TS_PropVi2[1] = -19:";
TS_PropVi2.lock();
TS_PropVi2[1] = -19;
TS_PropVi2.unlock();
show("TS_PropVi2", TS_PropVi2());
std::cout << "\n\n Testing TS_Property<std::deque<double>>";
std::cout << "\n -----------------------------------------";
TS_Property<std::deque<double>> TS_PropDd;
TS_PropDd.push_front(3.14159);
TS_PropDd.push_back(0.3333);
TS_PropDd.push_front(-3.333);
show("TS_PropDd:", TS_PropDd());
std::cout << "\n TS_PropDd.size() = " << TS_PropDd.size();
std::cout << "\n\n TS_PropDd.pop_front";
std::cout << "\n --------------------";
TS_PropDd.pop_front();
show("TS_PropDd:", TS_PropDd());
std::cout << "\n\n TS_PropDd.pop_back";
std::cout << "\n -------------------";
TS_PropDd.pop_back();
show("TS_PropDd:", TS_PropDd());
double d = TS_PropDd.front();
show("TS_PropDd.front() = ", d);
std::cout << "\n\n Testing TS_Property<std::unordered_map<std::string, std::string>>";
std::cout << "\n -------------------------------------------------------------------";
TS_Property<std::unordered_map<std::string, std::string>> TS_UnordMap1;
std::pair<std::string, std::string> item1 { "one", "1" };
std::pair<std::string, std::string> item2{ "two", "2" };
std::pair<std::string, std::string> item3{ "three", "3" };
std::pair<std::string, std::string> item4{ "four", "4" };
TS_UnordMap1.insert(item1);
TS_UnordMap1.insert(item2);
TS_UnordMap1.insert(item3);
std::unordered_map<std::string, std::string>::iterator iter2 = TS_UnordMap1.begin();
TS_UnordMap1.insert(iter2, item4); // iterator is a hint
show("TS_UnordMap1", TS_UnordMap1());
std::cout << "\n\n TS_UnordMap1.erase(TS_UnordMap1.begin())";
iter2 = TS_UnordMap1.begin();
TS_UnordMap1.erase(iter2);
show("TS_UnordMap1", TS_UnordMap1());
iter2 = ++TS_UnordMap1.begin();
std::cout << "\n\n TS_UnordMap1.insert({ \"five\", \"5\" })";
std::pair<std::string, std::string> item5{ "five", "5" };
TS_UnordMap1.insert(item5);
show("TS_UnordMap1", TS_UnordMap1());
std::unordered_map<std::string, std::string>::key_type key = "five";
std::cout << "\n\n TS_UnordMap1.find(\"" << key << "\")";
std::unordered_map<std::string, std::string>::const_iterator iter3;
iter3 = TS_UnordMap1.find(key);
if (iter3 != TS_UnordMap1.end())
{
std::cout << "\n found item with key = \"" << key << "\"";
std::cout << "\n value is \"" << iter3->second << "\"";
}
else
std::cout << "\n did not find item with key = \"" << key << "\"";
key = "foobar";
std::cout << "\n\n TS_UnordMap1.find(\"" << key << "\")";
iter3 = TS_UnordMap1.find(key);
if (iter3 != TS_UnordMap1.end())
{
std::cout << "\n found item with key = \"" << key << "\"";
std::cout << "\n value is \"" << iter3->second << "\"";
}
else
std::cout << "\n did not find item with key = \"" << key << "\"";
std::unordered_map<std::string, std::string>::mapped_type value;
try {
key = "five";
std::cout << "\n\n TS_UnordMap1[\"" << key << "\"] returned ";
value = TS_UnordMap1[key];
std::cout << "\"" << value << "\"";
key = "foobar";
std::cout << "\n\n TS_UnordMap1[\"" << key << "\"] returned ";
value = TS_UnordMap1[key];
std::cout << "\"" << value << "\"";
}
catch (std::exception& ex)
{
std::cout << "\n " << ex.what();
}
std::cout << "\n\n method editItem(key, valule) is used instead of TS_UnordMap1[key] = value";
std::cout << "\n that is not implemented";
key = "foobar";
value = "feebar";
std::cout << "\n\n TS_UnordMap1.editItem(\"" << key << ", " << value << "\")";
TS_UnordMap1.editItem(key, "feebar");
show("TS_UnordMap1", TS_UnordMap1());
value = "foobar";
std::cout << "\n\n TS_UnordMap1.editItem(\"" << key << ", " << value << "\")";
TS_UnordMap1.editItem(key, "foobar");
show("TS_UnordMap1", TS_UnordMap1());
std::cout << "\n\n ---- That's all folks! ----";
std::cout << "\n\n";
} | [
"jfawcett@twcny.rr.com"
] | jfawcett@twcny.rr.com |
6a9d513aaf267404753f8a4b72f3e7501ce005d9 | 9b85f76be1070dcf983012524366cfeb517e6219 | /Magic/MagicWand/ClrButton.cpp | b0741fc0177baa1be56f4e449c9e89b8a018e822 | [] | no_license | Homebrew-Engine-Archive/botarena | 691d35595a936c7adf5e0a495a5fbf35812244ef | 044e2713315b165002f2e06911ce7455de2f773f | refs/heads/main | 2023-05-10T15:58:08.520085 | 2021-03-17T13:11:56 | 2021-03-17T13:11:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,998 | cpp | // ClrButton.cpp : implementation file
//
#include "stdafx.h"
#include "ClrButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const COLORREF CLR_BTN_WHITE = RGB(255, 255, 255);
const COLORREF CLR_BTN_BLACK = RGB(0, 0, 0);
const COLORREF CLR_BTN_DGREY = RGB(128, 128, 128);
const COLORREF CLR_BTN_GREY = RGB(192, 192, 192);
const COLORREF CLR_BTN_LLGREY = RGB(223, 223, 223);
const int BUTTON_IN = 0x01;
const int BUTTON_OUT = 0x02;
const int BUTTON_BLACK_BORDER = 0x04;
/////////////////////////////////////////////////////////////////////////////
// CClrButton
CClrButton::CClrButton()
{
text_colour = GetSysColor(COLOR_BTNTEXT);
background_colour = GetSysColor(COLOR_BTNFACE);
disabled_background_colour = background_colour;
light = GetSysColor(COLOR_3DLIGHT);
highlight = GetSysColor(COLOR_BTNHIGHLIGHT);
shadow = GetSysColor(COLOR_BTNSHADOW);
dark_shadow = GetSysColor(COLOR_3DDKSHADOW);
}
CClrButton::~CClrButton()
{
}
void CClrButton::SetColour(COLORREF new_text_colour, COLORREF new_background_colour)
{
text_colour = new_text_colour;
background_colour = new_background_colour;
disabled_background_colour = GetSysColor(COLOR_BTNFACE);
Invalidate(FALSE);
}
void CClrButton::SetColour(COLORREF new_text_colour, COLORREF new_background_colour, COLORREF new_disabled_background_colour)
{
text_colour = new_text_colour;
background_colour = new_background_colour;
disabled_background_colour = new_disabled_background_colour;
Invalidate(FALSE);
}
void CClrButton::ResetColour()
{
text_colour = GetSysColor(COLOR_BTNTEXT);
background_colour = GetSysColor(COLOR_BTNFACE);
disabled_background_colour = background_colour;
light = GetSysColor(COLOR_3DLIGHT);
highlight = GetSysColor(COLOR_BTNHIGHLIGHT);
shadow = GetSysColor(COLOR_BTNSHADOW);
dark_shadow = GetSysColor(COLOR_3DDKSHADOW);
Invalidate(FALSE);
}
BEGIN_MESSAGE_MAP(CClrButton, CButton)
//{{AFX_MSG_MAP(CClrButton)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClrButton message handlers
void CClrButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC *dc;
CRect focus_rect, button_rect, text_rect, offset_text_rect;
UINT state;
dc = CDC::FromHandle(lpDrawItemStruct->hDC);
state = lpDrawItemStruct->itemState;
focus_rect.CopyRect(&lpDrawItemStruct->rcItem);
button_rect.CopyRect(&lpDrawItemStruct->rcItem);
text_rect = button_rect;
text_rect.OffsetRect(-1, -1);
offset_text_rect = text_rect;
offset_text_rect.OffsetRect(1, 1);
// Set the focus rectangle to just past the border decoration
focus_rect.left += 4;
focus_rect.right -= 4;
focus_rect.top += 4;
focus_rect.bottom -= 4;
// Retrieve the button's caption
const int bufSize = 512;
TCHAR buffer[bufSize];
GetWindowText(buffer, bufSize);
if (state & ODS_DISABLED)
{
DrawFilledRect(dc, button_rect, disabled_background_colour);
}
else
{
DrawFilledRect(dc, button_rect, background_colour);
}
if (state & ODS_SELECTED)
{
DrawFrame(dc, button_rect, BUTTON_IN);
}
else
{
if ((state & ODS_DEFAULT) || (state & ODS_FOCUS))
{
DrawFrame(dc, button_rect, BUTTON_OUT | BUTTON_BLACK_BORDER);
}
else
{
DrawFrame(dc, button_rect, BUTTON_OUT);
}
}
if (state & ODS_DISABLED)
{
DrawButtonText(dc, offset_text_rect, buffer, CLR_BTN_WHITE);
DrawButtonText(dc, text_rect, buffer, CLR_BTN_DGREY);
}
else
{
if (state & ODS_SELECTED)
{
DrawButtonText(dc, offset_text_rect, buffer, text_colour);
}
else
{
DrawButtonText(dc, text_rect, buffer, text_colour);
}
}
if (state & ODS_FOCUS)
{
DrawFocusRect(lpDrawItemStruct->hDC, (LPRECT)&focus_rect);
}
}
void CClrButton::DrawFrame(CDC *dc, CRect r, int state)
{
COLORREF colour;
if (state & BUTTON_BLACK_BORDER)
{
colour = CLR_BTN_BLACK;
DrawLine(dc, r.left, r.top, r.right, r.top, colour); // Across top
DrawLine(dc, r.left, r.top, r.left, r.bottom, colour); // Down left
DrawLine(dc, r.left, r.bottom - 1, r.right, r.bottom - 1, colour); // Across bottom
DrawLine(dc, r.right - 1, r.top, r.right - 1, r.bottom, colour); // Down right
r.InflateRect(-1, -1);
}
if (state & BUTTON_OUT)
{
colour = highlight;
DrawLine(dc, r.left, r.top, r.right, r.top, colour); // Across top
DrawLine(dc, r.left, r.top, r.left, r.bottom, colour); // Down left
colour = dark_shadow;
DrawLine(dc, r.left, r.bottom - 1, r.right, r.bottom - 1, colour); // Across bottom
DrawLine(dc, r.right - 1, r.top, r.right - 1, r.bottom, colour); // Down right
r.InflateRect(-1, -1);
colour = light;
DrawLine(dc, r.left, r.top, r.right, r.top, colour); // Across top
DrawLine(dc, r.left, r.top, r.left, r.bottom, colour); // Down left
colour = shadow;
DrawLine(dc, r.left, r.bottom - 1, r.right, r.bottom - 1, colour); // Across bottom
DrawLine(dc, r.right - 1, r.top, r.right - 1, r.bottom, colour); // Down right
}
if (state & BUTTON_IN)
{
colour = dark_shadow;
DrawLine(dc, r.left, r.top, r.right, r.top, colour); // Across top
DrawLine(dc, r.left, r.top, r.left, r.bottom, colour); // Down left
DrawLine(dc, r.left, r.bottom - 1, r.right, r.bottom - 1, colour); // Across bottom
DrawLine(dc, r.right - 1, r.top, r.right - 1, r.bottom, colour); // Down right
r.InflateRect(-1, -1);
colour = shadow;
DrawLine(dc, r.left, r.top, r.right, r.top, colour); // Across top
DrawLine(dc, r.left, r.top, r.left, r.bottom, colour); // Down left
DrawLine(dc, r.left, r.bottom - 1, r.right, r.bottom - 1, colour); // Across bottom
DrawLine(dc, r.right - 1, r.top, r.right - 1, r.bottom, colour); // Down right
}
}
void CClrButton::DrawFilledRect(CDC *dc, CRect r, COLORREF colour)
{
CBrush B;
B.CreateSolidBrush(colour);
dc->FillRect(r, &B);
}
void CClrButton::DrawLine(CDC *dc, long sx, long sy, long ex, long ey, COLORREF colour)
{
CPen new_pen;
CPen *old_pen;
new_pen.CreatePen(PS_SOLID, 1, colour);
old_pen = dc->SelectObject(&new_pen);
dc->MoveTo(sx, sy);
dc->LineTo(ex, ey);
dc->SelectObject(old_pen);
new_pen.DeleteObject();
}
void CClrButton::DrawButtonText(CDC *dc, CRect r, LPCTSTR Buf, COLORREF text_colour)
{
COLORREF previous_colour;
previous_colour = dc->SetTextColor(text_colour);
dc->SetBkMode(TRANSPARENT);
dc->DrawText(Buf, _tcslen(Buf), r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
dc->SetTextColor(previous_colour);
}
| [
"zie.develop@gmail.com"
] | zie.develop@gmail.com |
31c8daa88b391286a04266dade87c6526721d1f4 | 342a60a18648325f839c9fd7fa6d96ca6e61e205 | /libcaf_net/caf/net/web_socket/fwd.hpp | 32a4e89f8c4bc24d6c8384e79e48287effaed281 | [] | permissive | DavadDi/actor-framework | 94c47209c8f4985e449c7ca3f852e95d17f9b4f9 | daa75c486ee7edbfd63b92dfa8f878cb97f31eb3 | refs/heads/master | 2023-07-21T09:07:23.774557 | 2022-12-16T13:41:04 | 2022-12-16T13:41:04 | 42,344,449 | 0 | 1 | BSD-3-Clause | 2023-01-26T14:38:39 | 2015-09-12T04:21:48 | C++ | UTF-8 | C++ | false | false | 610 | hpp | // This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
namespace caf::net::web_socket {
template <class OnRequest, class Trait, class... Ts>
class flow_connector_request_impl;
template <class Trait>
class flow_bridge;
template <class Trait, class... Ts>
class request;
class frame;
class framing;
class lower_layer;
class server;
class upper_layer;
enum class status : uint16_t;
} // namespace caf::net::web_socket
| [
"dominik@charousset.de"
] | dominik@charousset.de |
983a5bc6bc715cc490258cbd0610bd5b1f16a34a | 5212dbf9089801b3f9e21878a5efd2fced7fbc1b | /1.Code/C++ Primer Plus/Chapter 11/stone.cpp | e91578bd128f571dcae1ce39cbe847e5d3570875 | [
"MIT"
] | permissive | LingfengPang/Cpp | 65a2fa71a6ec2d9767e6a07601737d9a88d9989d | fe806483c819eb6ffcff539743740d748796e8bc | refs/heads/main | 2023-01-25T00:36:30.510229 | 2020-11-30T02:01:46 | 2020-11-30T02:01:46 | 316,647,768 | 0 | 0 | MIT | 2020-11-30T02:02:35 | 2020-11-28T03:21:56 | C++ | UTF-8 | C++ | false | false | 1,098 | cpp | // stone.cpp -- user-defined conversions
// compile with stonewt.cpp
#include <iostream>
using std::cout;
#include "stonewt.h"
void display(const Stonewt & st, int n);
int main()
{
Stonewt incognito = 275; // uses constructor to initialize
Stonewt wolfe(285.7); // same as Stonewt wolfe = 285.7;
Stonewt taft(21, 8);
cout << "The celebrity weighed ";
incognito.show_stn();
cout << "The detective weighed ";
wolfe.show_stn();
cout << "The President weighed ";
taft.show_lbs();
incognito = 276.8; // uses constructor for conversion
taft = 325; // same as taft = Stonewt(325);
cout << "After dinner, the celebrity weighed ";
incognito.show_stn();
cout << "After dinner, the President weighed ";
taft.show_lbs();
display(taft, 2);
cout << "The wrestler weighed even more.\n";
display(422, 2);
cout << "No stone left unearned\n";
// std::cin.get();
return 0;
}
void display(const Stonewt & st, int n)
{
for (int i = 0; i < n; i++)
{
cout << "Wow! ";
st.show_stn();
}
}
| [
"nitpang@163.com"
] | nitpang@163.com |
7d2c723811853925c6d2ff43b66edc576e136aaf | 63d1eb60cb38d712270420ca29f8e0480113ffb5 | /Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp | 1aa7f261fb6dc3f00a721784fde5caaebe0f454a | [] | no_license | staticlibs/lookaside_webkitgtk4 | ff136f03e5ff993feae251236066462b287310ba | 5276617f7d55012e002f92c966c06a0606b026f8 | refs/heads/master | 2021-05-08T22:35:34.901835 | 2018-01-31T11:28:59 | 2018-01-31T11:28:59 | 119,679,770 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 10,630 | cpp | /*
* Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <WebCore/URLParser.h>
#include <wtf/MainThread.h>
using namespace WebCore;
namespace TestWebKitAPI {
class URLParserTest : public testing::Test {
public:
void SetUp() final {
WTF::initializeMainThread();
}
};
struct ExpectedParts {
String protocol;
String user;
String password;
String host;
unsigned short port;
String path;
String query;
String fragment;
String string;
};
static bool eq(const String& s1, const String& s2) { return s1.utf8() == s2.utf8(); }
static void checkURL(const String& urlString, const ExpectedParts& parts)
{
URLParser parser;
auto url = parser.parse(urlString);
EXPECT_TRUE(eq(parts.protocol, url.protocol()));
EXPECT_TRUE(eq(parts.user, url.user()));
EXPECT_TRUE(eq(parts.password, url.pass()));
EXPECT_TRUE(eq(parts.host, url.host()));
EXPECT_EQ(parts.port, url.port());
EXPECT_TRUE(eq(parts.path, url.path()));
EXPECT_TRUE(eq(parts.query, url.query()));
EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
EXPECT_TRUE(eq(parts.string, url.string()));
auto oldURL = URL(URL(), urlString);
EXPECT_TRUE(eq(parts.protocol, oldURL.protocol()));
EXPECT_TRUE(eq(parts.user, oldURL.user()));
EXPECT_TRUE(eq(parts.password, oldURL.pass()));
EXPECT_TRUE(eq(parts.host, oldURL.host()));
EXPECT_EQ(parts.port, oldURL.port());
EXPECT_TRUE(eq(parts.path, oldURL.path()));
EXPECT_TRUE(eq(parts.query, oldURL.query()));
EXPECT_TRUE(eq(parts.fragment, oldURL.fragmentIdentifier()));
EXPECT_TRUE(eq(parts.string, oldURL.string()));
EXPECT_TRUE(URLParser::allValuesEqual(url, oldURL));
}
TEST_F(URLParserTest, Parse)
{
checkURL("http://user:pass@webkit.org:123/path?query#fragment", {"http", "user", "pass", "webkit.org", 123, "/path", "query", "fragment", "http://user:pass@webkit.org:123/path?query#fragment"});
checkURL("http://user:pass@webkit.org:123/path?query", {"http", "user", "pass", "webkit.org", 123, "/path", "query", "", "http://user:pass@webkit.org:123/path?query"});
checkURL("http://user:pass@webkit.org:123/path", {"http", "user", "pass", "webkit.org", 123, "/path", "", "", "http://user:pass@webkit.org:123/path"});
checkURL("http://user:pass@webkit.org:123/", {"http", "user", "pass", "webkit.org", 123, "/", "", "", "http://user:pass@webkit.org:123/"});
checkURL("http://user:pass@webkit.org:123", {"http", "user", "pass", "webkit.org", 123, "/", "", "", "http://user:pass@webkit.org:123/"});
checkURL("http://user:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
checkURL("http://webkit.org", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"});
checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
checkURL("http://webkit.org/", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"});
checkURL("http://webkit.org/path1/path2/index.html", {"http", "", "", "webkit.org", 0, "/path1/path2/index.html", "", "", "http://webkit.org/path1/path2/index.html"});
checkURL("about:blank", {"about", "", "", "", 0, "blank", "", "", "about:blank"});
checkURL("about:blank?query", {"about", "", "", "", 0, "blank", "query", "", "about:blank?query"});
checkURL("about:blank#fragment", {"about", "", "", "", 0, "blank", "", "fragment", "about:blank#fragment"});
}
static void checkRelativeURL(const String& urlString, const String& baseURLString, const ExpectedParts& parts)
{
URLParser baseParser;
auto base = baseParser.parse(baseURLString);
URLParser parser;
auto url = parser.parse(urlString, base);
EXPECT_TRUE(eq(parts.protocol, url.protocol()));
EXPECT_TRUE(eq(parts.user, url.user()));
EXPECT_TRUE(eq(parts.password, url.pass()));
EXPECT_TRUE(eq(parts.host, url.host()));
EXPECT_EQ(parts.port, url.port());
EXPECT_TRUE(eq(parts.path, url.path()));
EXPECT_TRUE(eq(parts.query, url.query()));
EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
EXPECT_TRUE(eq(parts.string, url.string()));
auto oldURL = URL(URL(URL(), baseURLString), urlString);
EXPECT_TRUE(eq(parts.protocol, oldURL.protocol()));
EXPECT_TRUE(eq(parts.user, oldURL.user()));
EXPECT_TRUE(eq(parts.password, oldURL.pass()));
EXPECT_TRUE(eq(parts.host, oldURL.host()));
EXPECT_EQ(parts.port, oldURL.port());
EXPECT_TRUE(eq(parts.path, oldURL.path()));
EXPECT_TRUE(eq(parts.query, oldURL.query()));
EXPECT_TRUE(eq(parts.fragment, oldURL.fragmentIdentifier()));
EXPECT_TRUE(eq(parts.string, oldURL.string()));
EXPECT_TRUE(URLParser::allValuesEqual(url, oldURL));
}
TEST_F(URLParserTest, ParseRelative)
{
checkRelativeURL("/index.html", "http://webkit.org/path1/path2/", {"http", "", "", "webkit.org", 0, "/index.html", "", "", "http://webkit.org/index.html"});
checkRelativeURL("http://whatwg.org/index.html", "http://webkit.org/path1/path2/", {"http", "", "", "whatwg.org", 0, "/index.html", "", "", "http://whatwg.org/index.html"});
checkRelativeURL("index.html", "http://webkit.org/path1/path2/page.html?query#fragment", {"http", "", "", "webkit.org", 0, "/path1/path2/index.html", "", "", "http://webkit.org/path1/path2/index.html"});
checkRelativeURL("//whatwg.org/index.html", "https://www.webkit.org/path", {"https", "", "", "whatwg.org", 0, "/index.html", "", "", "https://whatwg.org/index.html"});
}
static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld)
{
URLParser parser;
auto url = parser.parse(urlString);
EXPECT_TRUE(eq(partsNew.protocol, url.protocol()));
EXPECT_TRUE(eq(partsNew.user, url.user()));
EXPECT_TRUE(eq(partsNew.password, url.pass()));
EXPECT_TRUE(eq(partsNew.host, url.host()));
EXPECT_EQ(partsNew.port, url.port());
EXPECT_TRUE(eq(partsNew.path, url.path()));
EXPECT_TRUE(eq(partsNew.query, url.query()));
EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier()));
EXPECT_TRUE(eq(partsNew.string, url.string()));
auto oldURL = URL(URL(), urlString);
EXPECT_TRUE(eq(partsOld.protocol, oldURL.protocol()));
EXPECT_TRUE(eq(partsOld.user, oldURL.user()));
EXPECT_TRUE(eq(partsOld.password, oldURL.pass()));
EXPECT_TRUE(eq(partsOld.host, oldURL.host()));
EXPECT_EQ(partsOld.port, oldURL.port());
EXPECT_TRUE(eq(partsOld.path, oldURL.path()));
EXPECT_TRUE(eq(partsOld.query, oldURL.query()));
EXPECT_TRUE(eq(partsOld.fragment, oldURL.fragmentIdentifier()));
EXPECT_TRUE(eq(partsOld.string, oldURL.string()));
EXPECT_FALSE(URLParser::allValuesEqual(url, oldURL));
}
static void checkRelativeURLDifferences(const String& urlString, const String& baseURLString, const ExpectedParts& partsNew, const ExpectedParts& partsOld)
{
URLParser baseParser;
auto base = baseParser.parse(baseURLString);
URLParser parser;
auto url = parser.parse(urlString, base);
EXPECT_TRUE(eq(partsNew.protocol, url.protocol()));
EXPECT_TRUE(eq(partsNew.user, url.user()));
EXPECT_TRUE(eq(partsNew.password, url.pass()));
EXPECT_TRUE(eq(partsNew.host, url.host()));
EXPECT_EQ(partsNew.port, url.port());
EXPECT_TRUE(eq(partsNew.path, url.path()));
EXPECT_TRUE(eq(partsNew.query, url.query()));
EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier()));
EXPECT_TRUE(eq(partsNew.string, url.string()));
auto oldURL = URL(URL(URL(), baseURLString), urlString);
EXPECT_TRUE(eq(partsOld.protocol, oldURL.protocol()));
EXPECT_TRUE(eq(partsOld.user, oldURL.user()));
EXPECT_TRUE(eq(partsOld.password, oldURL.pass()));
EXPECT_TRUE(eq(partsOld.host, oldURL.host()));
EXPECT_EQ(partsOld.port, oldURL.port());
EXPECT_TRUE(eq(partsOld.path, oldURL.path()));
EXPECT_TRUE(eq(partsOld.query, oldURL.query()));
EXPECT_TRUE(eq(partsOld.fragment, oldURL.fragmentIdentifier()));
EXPECT_TRUE(eq(partsOld.string, oldURL.string()));
EXPECT_FALSE(URLParser::allValuesEqual(url, oldURL));
}
TEST_F(URLParserTest, ParserDifferences)
{
checkURLDifferences("http://127.0.1",
{"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
{"http", "", "", "127.0.1", 0, "/", "", "", "http://127.0.1/"});
checkURLDifferences("http://011.11.0X11.0x011",
{"http", "", "", "9.11.17.17", 0, "/", "", "", "http://9.11.17.17/"},
{"http", "", "", "011.11.0x11.0x011", 0, "/", "", "", "http://011.11.0x11.0x011/"});
// FIXME: This behavior ought to be specified in the standard.
// With the existing URL::parse, WebKit returns "https:/", Firefox returns "https:///", and Chrome throws an error.
checkRelativeURLDifferences("//", "https://www.webkit.org/path",
{"https", "", "", "", 0, "", "", "", "https://"},
{"https", "", "", "", 0, "/", "", "", "https:/"});
}
static void shouldFail(const String& urlString)
{
URLParser parser;
auto invalidURL = parser.parse(urlString);
EXPECT_TRUE(URLParser::allValuesEqual(invalidURL, { }));
}
TEST_F(URLParserTest, ParserFailures)
{
shouldFail(" ");
shouldFail("");
}
} // namespace TestWebKitAPI
| [
"alex@staticlibs.net"
] | alex@staticlibs.net |
81265234589c2672aaba431a19506cf52271cbc9 | dd30c63bb193d634ccad712f12237235624394d7 | /libutopia2/utopia2/networkaccessmanager_p.h | c15fa129078b20a3bb26b200aa686680863e4820 | [] | no_license | ripefig/utopia-documents | 1e326398da4f92a3b3e28905ae5836a4c8a4bbaa | 751dd9a8e88bd24de6416924f85c960cc6714ec3 | refs/heads/master | 2020-12-07T10:36:22.674096 | 2020-01-09T02:57:15 | 2020-01-09T02:57:15 | 232,705,051 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,914 | h | /*****************************************************************************
*
* This file is part of the Utopia Documents application.
* Copyright (c) 2008-2017 Lost Island Labs
* <info@utopiadocs.com>
*
* Utopia Documents is free software: you can redistribute it and/or modify
* it under the terms of the GNU GENERAL PUBLIC LICENSE VERSION 3 as
* published by the Free Software Foundation.
*
* Utopia Documents is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the OpenSSL
* library under certain conditions as described in each individual source
* file, and distribute linked combinations including the two.
*
* You must obey the GNU General Public License in all respects for all of
* the code used other than OpenSSL. If you modify file(s) with this
* exception, you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete
* this exception statement from your version.
*
* You should have received a copy of the GNU General Public License
* along with Utopia Documents. If not, see <http://www.gnu.org/licenses/>
*
*****************************************************************************/
#ifndef UTOPIA_NETWORKACCESSMANAGER_P_H
#define UTOPIA_NETWORKACCESSMANAGER_P_H
#include <utopia2/config.h>
#include <QEventLoop>
#include <QMap>
#include <QMutex>
#include <QObject>
#include <QPointer>
#include <QSet>
#include <QString>
#include <QSslCertificate>
class QNetworkReply;
class QNetworkRequest;
class QSignalMapper;
namespace Utopia
{
class NetworkAccessManager;
class NetworkReplyBlocker : public QEventLoop
{
Q_OBJECT
public:
NetworkReplyBlocker(QObject * parent = 0);
~NetworkReplyBlocker();
int exec(ProcessEventsFlags flags = AllEvents);
QNetworkReply * reply() const;
public slots:
void quit();
protected:
QPointer< QNetworkReply > _reply;
mutable QMutex _mutex;
};
class NetworkAccessManagerPrivate : public QObject
{
Q_OBJECT
public slots:
void getForBlocker(const QNetworkRequest & request, NetworkReplyBlocker * blocker);
public:
NetworkAccessManagerPrivate(NetworkAccessManager * manager);
NetworkAccessManager * manager;
QSignalMapper * timeoutMapper;
bool paused;
QMap< QString, QSet< QSslCertificate > > allowedSslCertificates;
QString userAgentString;
};
}
#endif // UTOPIA_NETWORKACCESSMANAGER_P_H
| [
"leftcrane@tutanota.com"
] | leftcrane@tutanota.com |
bd6fc22e6ecb21ab05a6b8bbe02a3a92fc0fc424 | dfe6d6f58bf6f3d58a084c47f163db6555214419 | /beenums.cpp | 56adf8489af6b69d2a974242754227178e5e728b | [] | no_license | gurumurthyraghuraman/SPOJ-Solutions | bf590ed808b847166883f73cde19ca68f8626b0d | 630a73549d2920a9445d64d29c68a9fd42106438 | refs/heads/master | 2021-06-18T02:14:08.564086 | 2018-08-14T23:46:24 | 2018-08-14T23:46:24 | 96,250,191 | 0 | 0 | null | 2017-07-04T23:10:23 | 2017-07-04T20:12:46 | C++ | UTF-8 | C++ | false | false | 448 | cpp | #include <iostream>
using namespace std;
int main(){
int num;
int i;
cin>>num;
while(num!=-1){
if(num==1)
cout<<"Y"<<endl;
else{
i=1;
num--;
while(num>0){
num=num-(6*i);
i++;
}
if(num==0)
cout<<"Y"<<endl;
else cout<<"N"<<endl;
}
cin>>num;
}
return 0;
}
| [
"gurumurthy.raghuraman@gmail.com"
] | gurumurthy.raghuraman@gmail.com |
45a8493f0c66ccb146e567d5118308b137bc4fea | ba51f518ab2f8902557ac37ccb6bb1d756508f1e | /SDL1_handout/SDL1_Handout/DummyESC.h | 77471e180c4fbc478aa7e35a8e2dadc483334983 | [] | no_license | Sebi-Lopez/SDL_Handouts | 26f528b95cbd1a32d01c32d8358dabb5e0b4f957 | c50504414afe2e4b7b047f01ac77a162eb32c488 | refs/heads/master | 2021-04-09T10:16:24.804513 | 2018-04-21T01:43:59 | 2018-04-21T01:43:59 | 125,417,494 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 500 | h | #ifndef _DUMMYESC_H__
#define _DUMMYESC_H__
#include "Module.h"
#include "Globals.h"
#include <conio.h>
#include <iostream>
using namespace std;
class ModuleDummyESC : public Module {
public:
bool Init()
{
LOG("Dummy Init!");
return true;
}
update_status Update()
{
LOG("Dummy Update!");
update_status state = UPDATE_CONTINUE;
if (_kbhit()) state = UPDATE_STOP;
return state;
}
bool CleanUp()
{
LOG("Dummy CleanUp!");
return true;
}
};
#endif // _DUMMYESC_H___
| [
"sebi8818@gmail.com"
] | sebi8818@gmail.com |
fc666c71178d4ea32dda6e6cea132a9a0ee0ada8 | d5e0f606fa53aa4255de587bdce732732e31d707 | /DbTableModel.cpp | 46b27bcf1fc6646924fc7e7a7a5a444e53e078b4 | [] | no_license | ZkPrj/HmiDb_New | 96e259e5ee95e80b8d6544bdf69738086b4c436e | 4e74ea455c6f673c1b9213a19e8a591523a3e7ce | refs/heads/master | 2021-05-14T00:13:07.611020 | 2018-01-07T04:00:13 | 2018-01-07T04:00:13 | 116,535,682 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 68 | cpp | #include "DbTableModel.h"
//DbTableModel::DbTableModel()
//{
//}
| [
"zk_sima@163.com"
] | zk_sima@163.com |
63363044017f6a5843d105b3989fabfdbc341ef1 | 2a1aa92083303cb8bd5219991c52752a9230d9da | /seqsvr/proto/gen-cpp2/StoreService.tcc | 848ea036abac2aa680f04469af52bd50de621d53 | [
"Apache-2.0"
] | permissive | husttaowen/seqsvr | d96356063841f787089ae7ad7e8bd8353cba3f6f | 059f89917b73d83fc13c8e2f6b5bbe440f2c7620 | refs/heads/master | 2021-07-01T18:09:12.037765 | 2017-09-23T10:34:34 | 2017-09-23T10:34:34 | 110,783,282 | 1 | 0 | null | 2017-11-15T04:24:58 | 2017-11-15T04:24:57 | null | UTF-8 | C++ | false | false | 34,385 | tcc | /**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#pragma once
#include "StoreService.h"
#include <thrift/lib/cpp/TApplicationException.h>
#include <folly/io/IOBuf.h>
#include <folly/io/IOBufQueue.h>
#include <thrift/lib/cpp/transport/THeader.h>
#include <thrift/lib/cpp2/server/Cpp2ConnContext.h>
#include <thrift/lib/cpp2/GeneratedCodeHelper.h>
#include <thrift/lib/cpp2/GeneratedSerializationCodeHelper.h>
namespace seqsvr {
typedef apache::thrift::ThriftPresult<false> StoreService_LoadMaxSeqsData_pargs;
typedef apache::thrift::ThriftPresult<true, apache::thrift::FieldData<0, apache::thrift::protocol::T_STRUCT, ::seqsvr::MaxSeqsData*>> StoreService_LoadMaxSeqsData_presult;
typedef apache::thrift::ThriftPresult<false, apache::thrift::FieldData<1, apache::thrift::protocol::T_I32, int32_t*>, apache::thrift::FieldData<2, apache::thrift::protocol::T_I64, int64_t*>> StoreService_SaveMaxSeq_pargs;
typedef apache::thrift::ThriftPresult<true, apache::thrift::FieldData<0, apache::thrift::protocol::T_I64, int64_t*>> StoreService_SaveMaxSeq_presult;
typedef apache::thrift::ThriftPresult<false> StoreService_LoadRouteTable_pargs;
typedef apache::thrift::ThriftPresult<true, apache::thrift::FieldData<0, apache::thrift::protocol::T_STRUCT, ::seqsvr::Router*>> StoreService_LoadRouteTable_presult;
typedef apache::thrift::ThriftPresult<false, apache::thrift::FieldData<1, apache::thrift::protocol::T_STRUCT, ::seqsvr::Router*>> StoreService_SaveRouteTable_pargs;
typedef apache::thrift::ThriftPresult<true, apache::thrift::FieldData<0, apache::thrift::protocol::T_BOOL, bool*>> StoreService_SaveRouteTable_presult;
template <typename ProtocolIn_, typename ProtocolOut_>
void StoreServiceAsyncProcessor::_processInThread_LoadMaxSeqsData(std::unique_ptr<apache::thrift::ResponseChannel::Request> req, std::unique_ptr<folly::IOBuf> buf, std::unique_ptr<ProtocolIn_> iprot, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
auto pri = iface_->getRequestPriority(ctx, apache::thrift::concurrency::NORMAL);
processInThread<ProtocolIn_, ProtocolOut_>(std::move(req), std::move(buf),std::move(iprot), ctx, eb, tm, pri, false, &StoreServiceAsyncProcessor::process_LoadMaxSeqsData<ProtocolIn_, ProtocolOut_>, this);
}
template <typename ProtocolIn_, typename ProtocolOut_>
void StoreServiceAsyncProcessor::process_LoadMaxSeqsData(std::unique_ptr<apache::thrift::ResponseChannel::Request> req, std::unique_ptr<folly::IOBuf> buf, std::unique_ptr<ProtocolIn_> iprot,apache::thrift::Cpp2RequestContext* ctx,folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
// make sure getConnectionContext is null
// so async calls don't accidentally use it
iface_->setConnectionContext(nullptr);
StoreService_LoadMaxSeqsData_pargs args;
std::unique_ptr<apache::thrift::ContextStack> c(this->getContextStack(this->getServiceName(), "StoreService.LoadMaxSeqsData", ctx));
try {
deserializeRequest(args, buf.get(), iprot.get(), c.get());
}
catch (const std::exception& ex) {
ProtocolOut_ prot;
if (req) {
LOG(ERROR) << ex.what() << " in function LoadMaxSeqsData";
apache::thrift::TApplicationException x(apache::thrift::TApplicationException::TApplicationExceptionType::PROTOCOL_ERROR, ex.what());
folly::IOBufQueue queue = serializeException("LoadMaxSeqsData", &prot, ctx->getProtoSeqId(), nullptr, x);
queue.append(apache::thrift::transport::THeader::transform(queue.move(), ctx->getHeader()->getWriteTransforms(), ctx->getHeader()->getMinCompressBytes()));
eb->runInEventBaseThread([queue = std::move(queue), req = std::move(req)]() mutable {
req->sendReply(queue.move());
}
);
return;
}
else {
LOG(ERROR) << ex.what() << " in oneway function LoadMaxSeqsData";
}
}
auto callback = std::make_unique<apache::thrift::HandlerCallback<std::unique_ptr< ::seqsvr::MaxSeqsData>>>(std::move(req), std::move(c), return_LoadMaxSeqsData<ProtocolIn_,ProtocolOut_>, throw_wrapped_LoadMaxSeqsData<ProtocolIn_, ProtocolOut_>, ctx->getProtoSeqId(), eb, tm, ctx);
if (!callback->isRequestActive()) {
callback.release()->deleteInThread();
return;
}
ctx->setStartedProcessing();
iface_->async_tm_LoadMaxSeqsData(std::move(callback));
}
template <class ProtocolIn_, class ProtocolOut_>
folly::IOBufQueue StoreServiceAsyncProcessor::return_LoadMaxSeqsData(int32_t protoSeqId, apache::thrift::ContextStack* ctx, ::seqsvr::MaxSeqsData const& _return) {
ProtocolOut_ prot;
StoreService_LoadMaxSeqsData_presult result;
result.get<0>().value = const_cast< ::seqsvr::MaxSeqsData*>(&_return);
result.setIsSet(0, true);
return serializeResponse("LoadMaxSeqsData", &prot, protoSeqId, ctx, result);
}
template <class ProtocolIn_, class ProtocolOut_>
void StoreServiceAsyncProcessor::throw_wrapped_LoadMaxSeqsData(std::unique_ptr<apache::thrift::ResponseChannel::Request> req,int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) {
if (!ew) {
return;
}
ProtocolOut_ prot;
{
if (req) {
LOG(ERROR) << ew.what().toStdString() << " in function LoadMaxSeqsData";
apache::thrift::TApplicationException x(ew.what().toStdString());
ctx->userExceptionWrapped(false, ew);
ctx->handlerErrorWrapped(ew);
folly::IOBufQueue queue = serializeException("LoadMaxSeqsData", &prot, protoSeqId, ctx, x);
queue.append(apache::thrift::transport::THeader::transform(queue.move(), reqCtx->getHeader()->getWriteTransforms(), reqCtx->getHeader()->getMinCompressBytes()));
req->sendReply(queue.move());
return;
}
else {
LOG(ERROR) << ew.what().toStdString() << " in oneway function LoadMaxSeqsData";
}
}
}
template <typename ProtocolIn_, typename ProtocolOut_>
void StoreServiceAsyncProcessor::_processInThread_SaveMaxSeq(std::unique_ptr<apache::thrift::ResponseChannel::Request> req, std::unique_ptr<folly::IOBuf> buf, std::unique_ptr<ProtocolIn_> iprot, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
auto pri = iface_->getRequestPriority(ctx, apache::thrift::concurrency::NORMAL);
processInThread<ProtocolIn_, ProtocolOut_>(std::move(req), std::move(buf),std::move(iprot), ctx, eb, tm, pri, false, &StoreServiceAsyncProcessor::process_SaveMaxSeq<ProtocolIn_, ProtocolOut_>, this);
}
template <typename ProtocolIn_, typename ProtocolOut_>
void StoreServiceAsyncProcessor::process_SaveMaxSeq(std::unique_ptr<apache::thrift::ResponseChannel::Request> req, std::unique_ptr<folly::IOBuf> buf, std::unique_ptr<ProtocolIn_> iprot,apache::thrift::Cpp2RequestContext* ctx,folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
// make sure getConnectionContext is null
// so async calls don't accidentally use it
iface_->setConnectionContext(nullptr);
StoreService_SaveMaxSeq_pargs args;
int32_t uarg_id{0};
args.get<0>().value = &uarg_id;
int64_t uarg_max_seq{0};
args.get<1>().value = &uarg_max_seq;
std::unique_ptr<apache::thrift::ContextStack> c(this->getContextStack(this->getServiceName(), "StoreService.SaveMaxSeq", ctx));
try {
deserializeRequest(args, buf.get(), iprot.get(), c.get());
}
catch (const std::exception& ex) {
ProtocolOut_ prot;
if (req) {
LOG(ERROR) << ex.what() << " in function SaveMaxSeq";
apache::thrift::TApplicationException x(apache::thrift::TApplicationException::TApplicationExceptionType::PROTOCOL_ERROR, ex.what());
folly::IOBufQueue queue = serializeException("SaveMaxSeq", &prot, ctx->getProtoSeqId(), nullptr, x);
queue.append(apache::thrift::transport::THeader::transform(queue.move(), ctx->getHeader()->getWriteTransforms(), ctx->getHeader()->getMinCompressBytes()));
eb->runInEventBaseThread([queue = std::move(queue), req = std::move(req)]() mutable {
req->sendReply(queue.move());
}
);
return;
}
else {
LOG(ERROR) << ex.what() << " in oneway function SaveMaxSeq";
}
}
auto callback = std::make_unique<apache::thrift::HandlerCallback<int64_t>>(std::move(req), std::move(c), return_SaveMaxSeq<ProtocolIn_,ProtocolOut_>, throw_wrapped_SaveMaxSeq<ProtocolIn_, ProtocolOut_>, ctx->getProtoSeqId(), eb, tm, ctx);
if (!callback->isRequestActive()) {
callback.release()->deleteInThread();
return;
}
ctx->setStartedProcessing();
iface_->async_tm_SaveMaxSeq(std::move(callback), args.get<0>().ref(), args.get<1>().ref());
}
template <class ProtocolIn_, class ProtocolOut_>
folly::IOBufQueue StoreServiceAsyncProcessor::return_SaveMaxSeq(int32_t protoSeqId, apache::thrift::ContextStack* ctx, int64_t const& _return) {
ProtocolOut_ prot;
StoreService_SaveMaxSeq_presult result;
result.get<0>().value = const_cast<int64_t*>(&_return);
result.setIsSet(0, true);
return serializeResponse("SaveMaxSeq", &prot, protoSeqId, ctx, result);
}
template <class ProtocolIn_, class ProtocolOut_>
void StoreServiceAsyncProcessor::throw_wrapped_SaveMaxSeq(std::unique_ptr<apache::thrift::ResponseChannel::Request> req,int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) {
if (!ew) {
return;
}
ProtocolOut_ prot;
{
if (req) {
LOG(ERROR) << ew.what().toStdString() << " in function SaveMaxSeq";
apache::thrift::TApplicationException x(ew.what().toStdString());
ctx->userExceptionWrapped(false, ew);
ctx->handlerErrorWrapped(ew);
folly::IOBufQueue queue = serializeException("SaveMaxSeq", &prot, protoSeqId, ctx, x);
queue.append(apache::thrift::transport::THeader::transform(queue.move(), reqCtx->getHeader()->getWriteTransforms(), reqCtx->getHeader()->getMinCompressBytes()));
req->sendReply(queue.move());
return;
}
else {
LOG(ERROR) << ew.what().toStdString() << " in oneway function SaveMaxSeq";
}
}
}
template <typename ProtocolIn_, typename ProtocolOut_>
void StoreServiceAsyncProcessor::_processInThread_LoadRouteTable(std::unique_ptr<apache::thrift::ResponseChannel::Request> req, std::unique_ptr<folly::IOBuf> buf, std::unique_ptr<ProtocolIn_> iprot, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
auto pri = iface_->getRequestPriority(ctx, apache::thrift::concurrency::NORMAL);
processInThread<ProtocolIn_, ProtocolOut_>(std::move(req), std::move(buf),std::move(iprot), ctx, eb, tm, pri, false, &StoreServiceAsyncProcessor::process_LoadRouteTable<ProtocolIn_, ProtocolOut_>, this);
}
template <typename ProtocolIn_, typename ProtocolOut_>
void StoreServiceAsyncProcessor::process_LoadRouteTable(std::unique_ptr<apache::thrift::ResponseChannel::Request> req, std::unique_ptr<folly::IOBuf> buf, std::unique_ptr<ProtocolIn_> iprot,apache::thrift::Cpp2RequestContext* ctx,folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
// make sure getConnectionContext is null
// so async calls don't accidentally use it
iface_->setConnectionContext(nullptr);
StoreService_LoadRouteTable_pargs args;
std::unique_ptr<apache::thrift::ContextStack> c(this->getContextStack(this->getServiceName(), "StoreService.LoadRouteTable", ctx));
try {
deserializeRequest(args, buf.get(), iprot.get(), c.get());
}
catch (const std::exception& ex) {
ProtocolOut_ prot;
if (req) {
LOG(ERROR) << ex.what() << " in function LoadRouteTable";
apache::thrift::TApplicationException x(apache::thrift::TApplicationException::TApplicationExceptionType::PROTOCOL_ERROR, ex.what());
folly::IOBufQueue queue = serializeException("LoadRouteTable", &prot, ctx->getProtoSeqId(), nullptr, x);
queue.append(apache::thrift::transport::THeader::transform(queue.move(), ctx->getHeader()->getWriteTransforms(), ctx->getHeader()->getMinCompressBytes()));
eb->runInEventBaseThread([queue = std::move(queue), req = std::move(req)]() mutable {
req->sendReply(queue.move());
}
);
return;
}
else {
LOG(ERROR) << ex.what() << " in oneway function LoadRouteTable";
}
}
auto callback = std::make_unique<apache::thrift::HandlerCallback<std::unique_ptr< ::seqsvr::Router>>>(std::move(req), std::move(c), return_LoadRouteTable<ProtocolIn_,ProtocolOut_>, throw_wrapped_LoadRouteTable<ProtocolIn_, ProtocolOut_>, ctx->getProtoSeqId(), eb, tm, ctx);
if (!callback->isRequestActive()) {
callback.release()->deleteInThread();
return;
}
ctx->setStartedProcessing();
iface_->async_tm_LoadRouteTable(std::move(callback));
}
template <class ProtocolIn_, class ProtocolOut_>
folly::IOBufQueue StoreServiceAsyncProcessor::return_LoadRouteTable(int32_t protoSeqId, apache::thrift::ContextStack* ctx, ::seqsvr::Router const& _return) {
ProtocolOut_ prot;
StoreService_LoadRouteTable_presult result;
result.get<0>().value = const_cast< ::seqsvr::Router*>(&_return);
result.setIsSet(0, true);
return serializeResponse("LoadRouteTable", &prot, protoSeqId, ctx, result);
}
template <class ProtocolIn_, class ProtocolOut_>
void StoreServiceAsyncProcessor::throw_wrapped_LoadRouteTable(std::unique_ptr<apache::thrift::ResponseChannel::Request> req,int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) {
if (!ew) {
return;
}
ProtocolOut_ prot;
{
if (req) {
LOG(ERROR) << ew.what().toStdString() << " in function LoadRouteTable";
apache::thrift::TApplicationException x(ew.what().toStdString());
ctx->userExceptionWrapped(false, ew);
ctx->handlerErrorWrapped(ew);
folly::IOBufQueue queue = serializeException("LoadRouteTable", &prot, protoSeqId, ctx, x);
queue.append(apache::thrift::transport::THeader::transform(queue.move(), reqCtx->getHeader()->getWriteTransforms(), reqCtx->getHeader()->getMinCompressBytes()));
req->sendReply(queue.move());
return;
}
else {
LOG(ERROR) << ew.what().toStdString() << " in oneway function LoadRouteTable";
}
}
}
template <typename ProtocolIn_, typename ProtocolOut_>
void StoreServiceAsyncProcessor::_processInThread_SaveRouteTable(std::unique_ptr<apache::thrift::ResponseChannel::Request> req, std::unique_ptr<folly::IOBuf> buf, std::unique_ptr<ProtocolIn_> iprot, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
auto pri = iface_->getRequestPriority(ctx, apache::thrift::concurrency::NORMAL);
processInThread<ProtocolIn_, ProtocolOut_>(std::move(req), std::move(buf),std::move(iprot), ctx, eb, tm, pri, false, &StoreServiceAsyncProcessor::process_SaveRouteTable<ProtocolIn_, ProtocolOut_>, this);
}
template <typename ProtocolIn_, typename ProtocolOut_>
void StoreServiceAsyncProcessor::process_SaveRouteTable(std::unique_ptr<apache::thrift::ResponseChannel::Request> req, std::unique_ptr<folly::IOBuf> buf, std::unique_ptr<ProtocolIn_> iprot,apache::thrift::Cpp2RequestContext* ctx,folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
// make sure getConnectionContext is null
// so async calls don't accidentally use it
iface_->setConnectionContext(nullptr);
StoreService_SaveRouteTable_pargs args;
std::unique_ptr< ::seqsvr::Router> uarg_router(new ::seqsvr::Router());
args.get<0>().value = uarg_router.get();
std::unique_ptr<apache::thrift::ContextStack> c(this->getContextStack(this->getServiceName(), "StoreService.SaveRouteTable", ctx));
try {
deserializeRequest(args, buf.get(), iprot.get(), c.get());
}
catch (const std::exception& ex) {
ProtocolOut_ prot;
if (req) {
LOG(ERROR) << ex.what() << " in function SaveRouteTable";
apache::thrift::TApplicationException x(apache::thrift::TApplicationException::TApplicationExceptionType::PROTOCOL_ERROR, ex.what());
folly::IOBufQueue queue = serializeException("SaveRouteTable", &prot, ctx->getProtoSeqId(), nullptr, x);
queue.append(apache::thrift::transport::THeader::transform(queue.move(), ctx->getHeader()->getWriteTransforms(), ctx->getHeader()->getMinCompressBytes()));
eb->runInEventBaseThread([queue = std::move(queue), req = std::move(req)]() mutable {
req->sendReply(queue.move());
}
);
return;
}
else {
LOG(ERROR) << ex.what() << " in oneway function SaveRouteTable";
}
}
auto callback = std::make_unique<apache::thrift::HandlerCallback<bool>>(std::move(req), std::move(c), return_SaveRouteTable<ProtocolIn_,ProtocolOut_>, throw_wrapped_SaveRouteTable<ProtocolIn_, ProtocolOut_>, ctx->getProtoSeqId(), eb, tm, ctx);
if (!callback->isRequestActive()) {
callback.release()->deleteInThread();
return;
}
ctx->setStartedProcessing();
iface_->async_tm_SaveRouteTable(std::move(callback), std::move(uarg_router));
}
template <class ProtocolIn_, class ProtocolOut_>
folly::IOBufQueue StoreServiceAsyncProcessor::return_SaveRouteTable(int32_t protoSeqId, apache::thrift::ContextStack* ctx, bool const& _return) {
ProtocolOut_ prot;
StoreService_SaveRouteTable_presult result;
result.get<0>().value = const_cast<bool*>(&_return);
result.setIsSet(0, true);
return serializeResponse("SaveRouteTable", &prot, protoSeqId, ctx, result);
}
template <class ProtocolIn_, class ProtocolOut_>
void StoreServiceAsyncProcessor::throw_wrapped_SaveRouteTable(std::unique_ptr<apache::thrift::ResponseChannel::Request> req,int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) {
if (!ew) {
return;
}
ProtocolOut_ prot;
{
if (req) {
LOG(ERROR) << ew.what().toStdString() << " in function SaveRouteTable";
apache::thrift::TApplicationException x(ew.what().toStdString());
ctx->userExceptionWrapped(false, ew);
ctx->handlerErrorWrapped(ew);
folly::IOBufQueue queue = serializeException("SaveRouteTable", &prot, protoSeqId, ctx, x);
queue.append(apache::thrift::transport::THeader::transform(queue.move(), reqCtx->getHeader()->getWriteTransforms(), reqCtx->getHeader()->getMinCompressBytes()));
req->sendReply(queue.move());
return;
}
else {
LOG(ERROR) << ew.what().toStdString() << " in oneway function SaveRouteTable";
}
}
}
template <typename Protocol_>
void StoreServiceAsyncClient::LoadMaxSeqsDataT(Protocol_* prot, bool useSync, apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback) {
auto header = std::make_shared<apache::thrift::transport::THeader>(apache::thrift::transport::THeader::ALLOW_BIG_FRAMES);
header->setProtocolId(getChannel()->getProtocolId());
header->setHeaders(rpcOptions.releaseWriteHeaders());
connectionContext_->setRequestHeader(header.get());
std::unique_ptr<apache::thrift::ContextStack> ctx = this->getContextStack(this->getServiceName(), "StoreService.LoadMaxSeqsData", connectionContext_.get());
StoreService_LoadMaxSeqsData_pargs args;
auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); };
auto writer = [&](Protocol_* p) { args.write(p); };
apache::thrift::clientSendT<Protocol_>(prot, rpcOptions, std::move(callback), std::move(ctx), header, channel_.get(), "LoadMaxSeqsData", writer, sizer, false, useSync);
connectionContext_->setRequestHeader(nullptr);
}
template <typename Protocol_>
folly::exception_wrapper StoreServiceAsyncClient::recv_wrapped_LoadMaxSeqsDataT(Protocol_* prot, ::seqsvr::MaxSeqsData& _return, ::apache::thrift::ClientReceiveState& state) {
if (state.isException()) {
return std::move(state.exception());
}
prot->setInput(state.buf());
auto guard = folly::makeGuard([&] {prot->setInput(nullptr);});
apache::thrift::ContextStack* ctx = state.ctx();
std::string _fname;
int32_t protoSeqId = 0;
apache::thrift::MessageType mtype;
ctx->preRead();
folly::exception_wrapper interior_ew;
auto caught_ew = folly::try_and_catch<std::exception, apache::thrift::TException, apache::thrift::protocol::TProtocolException>([&]() {
prot->readMessageBegin(_fname, mtype, protoSeqId);
if (mtype == apache::thrift::T_EXCEPTION) {
apache::thrift::TApplicationException x;
x.read(prot);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(x);
return; // from try_and_catch
}
if (mtype != apache::thrift::T_REPLY) {
prot->skip(apache::thrift::protocol::T_STRUCT);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::INVALID_MESSAGE_TYPE);
return; // from try_and_catch
}
if (_fname.compare("LoadMaxSeqsData") != 0) {
prot->skip(apache::thrift::protocol::T_STRUCT);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::WRONG_METHOD_NAME);
return; // from try_and_catch
}
::apache::thrift::SerializedMessage smsg;
smsg.protocolType = prot->protocolType();
smsg.buffer = state.buf();
ctx->onReadData(smsg);
StoreService_LoadMaxSeqsData_presult result;
result.get<0>().value = &_return;
result.read(prot);
prot->readMessageEnd();
ctx->postRead(state.header(), state.buf()->length());
if (result.getIsSet(0)) {
// _return pointer has been filled
return; // from try_and_catch
}
else {
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::MISSING_RESULT, "failed: unknown result");
return; // from try_and_catch
}
}
);
auto ew = interior_ew ? std::move(interior_ew) : std::move(caught_ew);
if (ew) {
ctx->handlerErrorWrapped(ew);
}
return ew;
}
template <typename Protocol_>
void StoreServiceAsyncClient::recv_LoadMaxSeqsDataT(Protocol_* prot, ::seqsvr::MaxSeqsData& _return, ::apache::thrift::ClientReceiveState& state) {
auto ew = recv_wrapped_LoadMaxSeqsDataT(prot, _return, state);
if (ew) {
ew.throw_exception();
}
}
template <typename Protocol_>
void StoreServiceAsyncClient::SaveMaxSeqT(Protocol_* prot, bool useSync, apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback, int32_t id, int64_t max_seq) {
auto header = std::make_shared<apache::thrift::transport::THeader>(apache::thrift::transport::THeader::ALLOW_BIG_FRAMES);
header->setProtocolId(getChannel()->getProtocolId());
header->setHeaders(rpcOptions.releaseWriteHeaders());
connectionContext_->setRequestHeader(header.get());
std::unique_ptr<apache::thrift::ContextStack> ctx = this->getContextStack(this->getServiceName(), "StoreService.SaveMaxSeq", connectionContext_.get());
StoreService_SaveMaxSeq_pargs args;
args.get<0>().value = &id;
args.get<1>().value = &max_seq;
auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); };
auto writer = [&](Protocol_* p) { args.write(p); };
apache::thrift::clientSendT<Protocol_>(prot, rpcOptions, std::move(callback), std::move(ctx), header, channel_.get(), "SaveMaxSeq", writer, sizer, false, useSync);
connectionContext_->setRequestHeader(nullptr);
}
template <typename Protocol_>
folly::exception_wrapper StoreServiceAsyncClient::recv_wrapped_SaveMaxSeqT(Protocol_* prot, int64_t& _return, ::apache::thrift::ClientReceiveState& state) {
if (state.isException()) {
return std::move(state.exception());
}
prot->setInput(state.buf());
auto guard = folly::makeGuard([&] {prot->setInput(nullptr);});
apache::thrift::ContextStack* ctx = state.ctx();
std::string _fname;
int32_t protoSeqId = 0;
apache::thrift::MessageType mtype;
ctx->preRead();
folly::exception_wrapper interior_ew;
auto caught_ew = folly::try_and_catch<std::exception, apache::thrift::TException, apache::thrift::protocol::TProtocolException>([&]() {
prot->readMessageBegin(_fname, mtype, protoSeqId);
if (mtype == apache::thrift::T_EXCEPTION) {
apache::thrift::TApplicationException x;
x.read(prot);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(x);
return; // from try_and_catch
}
if (mtype != apache::thrift::T_REPLY) {
prot->skip(apache::thrift::protocol::T_STRUCT);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::INVALID_MESSAGE_TYPE);
return; // from try_and_catch
}
if (_fname.compare("SaveMaxSeq") != 0) {
prot->skip(apache::thrift::protocol::T_STRUCT);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::WRONG_METHOD_NAME);
return; // from try_and_catch
}
::apache::thrift::SerializedMessage smsg;
smsg.protocolType = prot->protocolType();
smsg.buffer = state.buf();
ctx->onReadData(smsg);
StoreService_SaveMaxSeq_presult result;
result.get<0>().value = &_return;
result.read(prot);
prot->readMessageEnd();
ctx->postRead(state.header(), state.buf()->length());
if (result.getIsSet(0)) {
// _return pointer has been filled
return; // from try_and_catch
}
else {
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::MISSING_RESULT, "failed: unknown result");
return; // from try_and_catch
}
}
);
auto ew = interior_ew ? std::move(interior_ew) : std::move(caught_ew);
if (ew) {
ctx->handlerErrorWrapped(ew);
}
return ew;
}
template <typename Protocol_>
int64_t StoreServiceAsyncClient::recv_SaveMaxSeqT(Protocol_* prot, ::apache::thrift::ClientReceiveState& state) {
int64_t _return;
auto ew = recv_wrapped_SaveMaxSeqT(prot, _return, state);
if (ew) {
ew.throw_exception();
}
return _return;
}
template <typename Protocol_>
void StoreServiceAsyncClient::LoadRouteTableT(Protocol_* prot, bool useSync, apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback) {
auto header = std::make_shared<apache::thrift::transport::THeader>(apache::thrift::transport::THeader::ALLOW_BIG_FRAMES);
header->setProtocolId(getChannel()->getProtocolId());
header->setHeaders(rpcOptions.releaseWriteHeaders());
connectionContext_->setRequestHeader(header.get());
std::unique_ptr<apache::thrift::ContextStack> ctx = this->getContextStack(this->getServiceName(), "StoreService.LoadRouteTable", connectionContext_.get());
StoreService_LoadRouteTable_pargs args;
auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); };
auto writer = [&](Protocol_* p) { args.write(p); };
apache::thrift::clientSendT<Protocol_>(prot, rpcOptions, std::move(callback), std::move(ctx), header, channel_.get(), "LoadRouteTable", writer, sizer, false, useSync);
connectionContext_->setRequestHeader(nullptr);
}
template <typename Protocol_>
folly::exception_wrapper StoreServiceAsyncClient::recv_wrapped_LoadRouteTableT(Protocol_* prot, ::seqsvr::Router& _return, ::apache::thrift::ClientReceiveState& state) {
if (state.isException()) {
return std::move(state.exception());
}
prot->setInput(state.buf());
auto guard = folly::makeGuard([&] {prot->setInput(nullptr);});
apache::thrift::ContextStack* ctx = state.ctx();
std::string _fname;
int32_t protoSeqId = 0;
apache::thrift::MessageType mtype;
ctx->preRead();
folly::exception_wrapper interior_ew;
auto caught_ew = folly::try_and_catch<std::exception, apache::thrift::TException, apache::thrift::protocol::TProtocolException>([&]() {
prot->readMessageBegin(_fname, mtype, protoSeqId);
if (mtype == apache::thrift::T_EXCEPTION) {
apache::thrift::TApplicationException x;
x.read(prot);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(x);
return; // from try_and_catch
}
if (mtype != apache::thrift::T_REPLY) {
prot->skip(apache::thrift::protocol::T_STRUCT);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::INVALID_MESSAGE_TYPE);
return; // from try_and_catch
}
if (_fname.compare("LoadRouteTable") != 0) {
prot->skip(apache::thrift::protocol::T_STRUCT);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::WRONG_METHOD_NAME);
return; // from try_and_catch
}
::apache::thrift::SerializedMessage smsg;
smsg.protocolType = prot->protocolType();
smsg.buffer = state.buf();
ctx->onReadData(smsg);
StoreService_LoadRouteTable_presult result;
result.get<0>().value = &_return;
result.read(prot);
prot->readMessageEnd();
ctx->postRead(state.header(), state.buf()->length());
if (result.getIsSet(0)) {
// _return pointer has been filled
return; // from try_and_catch
}
else {
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::MISSING_RESULT, "failed: unknown result");
return; // from try_and_catch
}
}
);
auto ew = interior_ew ? std::move(interior_ew) : std::move(caught_ew);
if (ew) {
ctx->handlerErrorWrapped(ew);
}
return ew;
}
template <typename Protocol_>
void StoreServiceAsyncClient::recv_LoadRouteTableT(Protocol_* prot, ::seqsvr::Router& _return, ::apache::thrift::ClientReceiveState& state) {
auto ew = recv_wrapped_LoadRouteTableT(prot, _return, state);
if (ew) {
ew.throw_exception();
}
}
template <typename Protocol_>
void StoreServiceAsyncClient::SaveRouteTableT(Protocol_* prot, bool useSync, apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback, const ::seqsvr::Router& router) {
auto header = std::make_shared<apache::thrift::transport::THeader>(apache::thrift::transport::THeader::ALLOW_BIG_FRAMES);
header->setProtocolId(getChannel()->getProtocolId());
header->setHeaders(rpcOptions.releaseWriteHeaders());
connectionContext_->setRequestHeader(header.get());
std::unique_ptr<apache::thrift::ContextStack> ctx = this->getContextStack(this->getServiceName(), "StoreService.SaveRouteTable", connectionContext_.get());
StoreService_SaveRouteTable_pargs args;
args.get<0>().value = const_cast< ::seqsvr::Router*>(&router);
auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); };
auto writer = [&](Protocol_* p) { args.write(p); };
apache::thrift::clientSendT<Protocol_>(prot, rpcOptions, std::move(callback), std::move(ctx), header, channel_.get(), "SaveRouteTable", writer, sizer, false, useSync);
connectionContext_->setRequestHeader(nullptr);
}
template <typename Protocol_>
folly::exception_wrapper StoreServiceAsyncClient::recv_wrapped_SaveRouteTableT(Protocol_* prot, bool& _return, ::apache::thrift::ClientReceiveState& state) {
if (state.isException()) {
return std::move(state.exception());
}
prot->setInput(state.buf());
auto guard = folly::makeGuard([&] {prot->setInput(nullptr);});
apache::thrift::ContextStack* ctx = state.ctx();
std::string _fname;
int32_t protoSeqId = 0;
apache::thrift::MessageType mtype;
ctx->preRead();
folly::exception_wrapper interior_ew;
auto caught_ew = folly::try_and_catch<std::exception, apache::thrift::TException, apache::thrift::protocol::TProtocolException>([&]() {
prot->readMessageBegin(_fname, mtype, protoSeqId);
if (mtype == apache::thrift::T_EXCEPTION) {
apache::thrift::TApplicationException x;
x.read(prot);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(x);
return; // from try_and_catch
}
if (mtype != apache::thrift::T_REPLY) {
prot->skip(apache::thrift::protocol::T_STRUCT);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::INVALID_MESSAGE_TYPE);
return; // from try_and_catch
}
if (_fname.compare("SaveRouteTable") != 0) {
prot->skip(apache::thrift::protocol::T_STRUCT);
prot->readMessageEnd();
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::WRONG_METHOD_NAME);
return; // from try_and_catch
}
::apache::thrift::SerializedMessage smsg;
smsg.protocolType = prot->protocolType();
smsg.buffer = state.buf();
ctx->onReadData(smsg);
StoreService_SaveRouteTable_presult result;
result.get<0>().value = &_return;
result.read(prot);
prot->readMessageEnd();
ctx->postRead(state.header(), state.buf()->length());
if (result.getIsSet(0)) {
// _return pointer has been filled
return; // from try_and_catch
}
else {
interior_ew = folly::make_exception_wrapper<apache::thrift::TApplicationException>(apache::thrift::TApplicationException::TApplicationExceptionType::MISSING_RESULT, "failed: unknown result");
return; // from try_and_catch
}
}
);
auto ew = interior_ew ? std::move(interior_ew) : std::move(caught_ew);
if (ew) {
ctx->handlerErrorWrapped(ew);
}
return ew;
}
template <typename Protocol_>
bool StoreServiceAsyncClient::recv_SaveRouteTableT(Protocol_* prot, ::apache::thrift::ClientReceiveState& state) {
bool _return;
auto ew = recv_wrapped_SaveRouteTableT(prot, _return, state);
if (ew) {
ew.throw_exception();
}
return _return;
}
} // seqsvr
namespace apache { namespace thrift {
}} // apache::thrift
| [
"wubenqi@gmail.com"
] | wubenqi@gmail.com |
3c2eaa39e0d7007c73c2872ffa360455d7430855 | 86ad25ef93226773d1de3e46300dd570d67f9ea5 | /HttpReader.h | a48fc7701d3adab0a19d722ea5302820f5e24a15 | [] | no_license | Dr1ve/BotHH | 18e8aee55f77bd2e8a2cc81051d865a83646e020 | 9bfca715c76a051fdec2384844bb75a2979dd255 | refs/heads/master | 2020-03-26T22:23:50.959388 | 2018-11-29T20:00:47 | 2018-11-29T20:00:47 | 145,455,303 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,262 | h | #ifndef HTTPREADER_H
#define HTTPREADER_H
#include <Windows.h>
#include <WinInet.h>
#include <iostream>
class HttpReader
{
public:
HttpReader(const std::string &ServerName = NULL, bool bUseSSL = false);
~HttpReader();
bool OpenInternet(std::string Agent = TEXT("Mozilla / 5.0 (Windows NT 6.1; WOW64; Trident / 7.0; rv:11.0) like Gecko"));
void CloseInternet();
bool OpenConnection(std::string ServerName = "");
void CloseConnection();
bool Get(std::string Action, std::string Referer = "");
bool Post(std::string Action, /*std::string Data,*/ std::string Referer = "");
void Send(std::string Data = "");
void CloseRequest();
std::string GetData();
static std::string getParam(const std::string &html, const std::string &name, const std::string &leftsymbol, std::string rightsymbol);
static std::string getVal(const std::string &json, const std::string &path, const std::string &def = "");
bool AddRequestHeader(std::string header);
private:
bool CheckError(bool bTest);
bool SendRequest(std::string Verb, std::string Action, /*std::string Data,*/ std::string Referer);
HINTERNET m_hInternet;
HINTERNET m_hConnection;
HINTERNET m_hRequest;
DWORD m_dwLastError;
bool m_bUseSSL;
std::string m_ServerName;
};
#endif // !HTTPREADER_H | [
"nazin_konstantin@mail.ru"
] | nazin_konstantin@mail.ru |
f260431b4aafb40c7a1c653f07b83485e929b274 | 1880ae99db197e976c87ba26eb23a20248e8ee51 | /tbaas/include/tencentcloud/tbaas/v20180416/model/GetBcosTransByHashResponse.h | f4eb423205eeb1001400d83461db16d274494dfb | [
"Apache-2.0"
] | permissive | caogenwang/tencentcloud-sdk-cpp | 84869793b5eb9811bb1eb46ed03d4dfa7ce6d94d | 6e18ee6622697a1c60a20a509415b0ddb8bdeb75 | refs/heads/master | 2023-08-23T12:37:30.305972 | 2021-11-08T01:18:30 | 2021-11-08T01:18:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,318 | h | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. 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 TENCENTCLOUD_TBAAS_V20180416_MODEL_GETBCOSTRANSBYHASHRESPONSE_H_
#define TENCENTCLOUD_TBAAS_V20180416_MODEL_GETBCOSTRANSBYHASHRESPONSE_H_
#include <string>
#include <vector>
#include <map>
#include <tencentcloud/core/AbstractModel.h>
namespace TencentCloud
{
namespace Tbaas
{
namespace V20180416
{
namespace Model
{
/**
* GetBcosTransByHash返回参数结构体
*/
class GetBcosTransByHashResponse : public AbstractModel
{
public:
GetBcosTransByHashResponse();
~GetBcosTransByHashResponse() = default;
CoreInternalOutcome Deserialize(const std::string &payload);
std::string ToJsonString() const;
/**
* 获取交易信息json字符串
* @return TransactionJson 交易信息json字符串
*/
std::string GetTransactionJson() const;
/**
* 判断参数 TransactionJson 是否已赋值
* @return TransactionJson 是否已赋值
*/
bool TransactionJsonHasBeenSet() const;
private:
/**
* 交易信息json字符串
*/
std::string m_transactionJson;
bool m_transactionJsonHasBeenSet;
};
}
}
}
}
#endif // !TENCENTCLOUD_TBAAS_V20180416_MODEL_GETBCOSTRANSBYHASHRESPONSE_H_
| [
"tencentcloudapi@tenent.com"
] | tencentcloudapi@tenent.com |
00cc42d207f500a456df46d65bc0f8e4428ee164 | cc695d3493d16c12b3942dccdb5b16355f84f1f3 | /src/qt/forms/ui_askpassphrasedialog.h | 554187f4dedce804959746545c4849778375c4d1 | [
"MIT"
] | permissive | lewis520/dkcoin_src | 0fbfd88a4fb26dd761465b91e53908a65793f18d | 327f134f7f3055fbdd5c033b8e0be0d707f13677 | refs/heads/master | 2021-01-22T18:58:32.158339 | 2019-07-27T05:35:36 | 2019-07-27T05:35:36 | 85,143,799 | 0 | 0 | null | 2017-03-16T02:33:45 | 2017-03-16T02:33:45 | null | UTF-8 | C++ | false | false | 5,567 | h | /********************************************************************************
** Form generated from reading UI file 'askpassphrasedialog.ui'
**
** Created by: Qt User Interface Compiler version 5.2.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_ASKPASSPHRASEDIALOG_H
#define UI_ASKPASSPHRASEDIALOG_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QVBoxLayout>
QT_BEGIN_NAMESPACE
class Ui_AskPassphraseDialog
{
public:
QVBoxLayout *verticalLayout;
QLabel *warningLabel;
QFormLayout *formLayout;
QLabel *passLabel1;
QLineEdit *passEdit1;
QLabel *passLabel2;
QLineEdit *passEdit2;
QLabel *passLabel3;
QLineEdit *passEdit3;
QLabel *capsLabel;
QDialogButtonBox *buttonBox;
void setupUi(QDialog *AskPassphraseDialog)
{
if (AskPassphraseDialog->objectName().isEmpty())
AskPassphraseDialog->setObjectName(QStringLiteral("AskPassphraseDialog"));
AskPassphraseDialog->resize(598, 222);
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(AskPassphraseDialog->sizePolicy().hasHeightForWidth());
AskPassphraseDialog->setSizePolicy(sizePolicy);
AskPassphraseDialog->setMinimumSize(QSize(550, 0));
verticalLayout = new QVBoxLayout(AskPassphraseDialog);
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
verticalLayout->setSizeConstraint(QLayout::SetMinimumSize);
warningLabel = new QLabel(AskPassphraseDialog);
warningLabel->setObjectName(QStringLiteral("warningLabel"));
warningLabel->setText(QStringLiteral("Placeholder text"));
warningLabel->setTextFormat(Qt::RichText);
warningLabel->setWordWrap(true);
verticalLayout->addWidget(warningLabel);
formLayout = new QFormLayout();
formLayout->setObjectName(QStringLiteral("formLayout"));
formLayout->setSizeConstraint(QLayout::SetMinimumSize);
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
passLabel1 = new QLabel(AskPassphraseDialog);
passLabel1->setObjectName(QStringLiteral("passLabel1"));
formLayout->setWidget(0, QFormLayout::LabelRole, passLabel1);
passEdit1 = new QLineEdit(AskPassphraseDialog);
passEdit1->setObjectName(QStringLiteral("passEdit1"));
passEdit1->setEchoMode(QLineEdit::Password);
formLayout->setWidget(0, QFormLayout::FieldRole, passEdit1);
passLabel2 = new QLabel(AskPassphraseDialog);
passLabel2->setObjectName(QStringLiteral("passLabel2"));
formLayout->setWidget(1, QFormLayout::LabelRole, passLabel2);
passEdit2 = new QLineEdit(AskPassphraseDialog);
passEdit2->setObjectName(QStringLiteral("passEdit2"));
passEdit2->setEchoMode(QLineEdit::Password);
formLayout->setWidget(1, QFormLayout::FieldRole, passEdit2);
passLabel3 = new QLabel(AskPassphraseDialog);
passLabel3->setObjectName(QStringLiteral("passLabel3"));
formLayout->setWidget(2, QFormLayout::LabelRole, passLabel3);
passEdit3 = new QLineEdit(AskPassphraseDialog);
passEdit3->setObjectName(QStringLiteral("passEdit3"));
passEdit3->setEchoMode(QLineEdit::Password);
formLayout->setWidget(2, QFormLayout::FieldRole, passEdit3);
capsLabel = new QLabel(AskPassphraseDialog);
capsLabel->setObjectName(QStringLiteral("capsLabel"));
QFont font;
font.setBold(true);
font.setWeight(75);
capsLabel->setFont(font);
capsLabel->setAlignment(Qt::AlignCenter);
formLayout->setWidget(3, QFormLayout::FieldRole, capsLabel);
verticalLayout->addLayout(formLayout);
buttonBox = new QDialogButtonBox(AskPassphraseDialog);
buttonBox->setObjectName(QStringLiteral("buttonBox"));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
verticalLayout->addWidget(buttonBox);
retranslateUi(AskPassphraseDialog);
QObject::connect(buttonBox, SIGNAL(accepted()), AskPassphraseDialog, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), AskPassphraseDialog, SLOT(reject()));
QMetaObject::connectSlotsByName(AskPassphraseDialog);
} // setupUi
void retranslateUi(QDialog *AskPassphraseDialog)
{
AskPassphraseDialog->setWindowTitle(QApplication::translate("AskPassphraseDialog", "Passphrase Dialog", 0));
passLabel1->setText(QApplication::translate("AskPassphraseDialog", "Enter passphrase", 0));
passLabel2->setText(QApplication::translate("AskPassphraseDialog", "New passphrase", 0));
passLabel3->setText(QApplication::translate("AskPassphraseDialog", "Repeat new passphrase", 0));
capsLabel->setText(QString());
} // retranslateUi
};
namespace Ui {
class AskPassphraseDialog: public Ui_AskPassphraseDialog {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_ASKPASSPHRASEDIALOG_H
| [
"dkcoinus@gmail.com"
] | dkcoinus@gmail.com |
ee635d63b699379508eb839989e5ddc0762f654c | 99545d17b802df4a94240b2439dd092de8a2117a | /Projekt1-build-desktop-Qt_4_8_1_w_PATH__System__Release/moc_czteromasztowiec.cpp | 4be60f2b3c7a8a0b5267a17aa21c9d4c979216d2 | [] | no_license | wemstar/Qt | 6cdf1abf97ee5ed89b82d7c23cc594424d9dfb78 | 19bab4bab9a5bbd6bae49f2ab90d9570a322f46c | refs/heads/master | 2021-01-01T18:38:22.462189 | 2013-06-10T09:03:30 | 2013-06-10T09:03:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,484 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'czteromasztowiec.h'
**
** Created: Mon May 13 14:14:34 2013
** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../Projekt1/Statki/czteromasztowiec.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'czteromasztowiec.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_CzteroMasztowiec[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
static const char qt_meta_stringdata_CzteroMasztowiec[] = {
"CzteroMasztowiec\0"
};
void CzteroMasztowiec::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
const QMetaObjectExtraData CzteroMasztowiec::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject CzteroMasztowiec::staticMetaObject = {
{ &AbstractShip::staticMetaObject, qt_meta_stringdata_CzteroMasztowiec,
qt_meta_data_CzteroMasztowiec, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &CzteroMasztowiec::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *CzteroMasztowiec::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *CzteroMasztowiec::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_CzteroMasztowiec))
return static_cast<void*>(const_cast< CzteroMasztowiec*>(this));
return AbstractShip::qt_metacast(_clname);
}
int CzteroMasztowiec::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = AbstractShip::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE
| [
"sylwestermacura@gmail.com"
] | sylwestermacura@gmail.com |
956c4e7966d5f45bcef348402602e18b6ddc437d | 618def3a260c1d4336b5cafc31c3298fe0b9a62f | /src/image/filter/dilate.cpp | 27080cc05753834b01247b310de24d63d87fcaa6 | [
"WTFPL"
] | permissive | lolengine/lolengine | 0ae3d2fadab644daacebcd0fd840b8bf03e9e0ff | 819e4a9cccad21b36eff2212b3543676549a7052 | refs/heads/main | 2023-01-27T15:45:54.881984 | 2023-01-09T23:58:46 | 2023-01-09T23:58:46 | 30,808,495 | 7 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,444 | cpp | //
// Lol Engine
//
// Copyright © 2004—2020 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//
#include <lol/engine-internal.h>
/*
* Dilate and erode functions
*/
/* FIXME: these functions are almost the same, try to merge them
* somewhat efficiently. */
/* TODO: - dilate by k (Manhattan distance)
* - dilate by r (euclidian distance, with non-integer r) */
namespace lol
{
old_image old_image::Dilate()
{
ivec2 isize = size();
old_image ret(isize);
if (format() == PixelFormat::Y_8 || format() == PixelFormat::Y_F32)
{
float const *srcp = lock<PixelFormat::Y_F32>();
float *dstp = ret.lock<PixelFormat::Y_F32>();
for (int y = 0; y < isize.y; ++y)
for (int x = 0; x < isize.x; ++x)
{
int y2 = lol::max(y - 1, 0);
int x2 = lol::max(x - 1, 0);
int y3 = lol::min(y + 1, isize.y - 1);
int x3 = lol::min(x + 1, isize.x - 1);
float t = srcp[y * isize.x + x];
t = lol::max(t, srcp[y * isize.x + x2]);
t = lol::max(t, srcp[y * isize.x + x3]);
t = lol::max(t, srcp[y2 * isize.x + x]);
t = lol::max(t, srcp[y3 * isize.x + x]);
dstp[y * isize.x + x] = t;
}
unlock(srcp);
ret.unlock(dstp);
}
else
{
vec4 const *srcp = lock<PixelFormat::RGBA_F32>();
vec4 *dstp = ret.lock<PixelFormat::RGBA_F32>();
for (int y = 0; y < isize.y; ++y)
for (int x = 0; x < isize.x; ++x)
{
int y2 = lol::max(y - 1, 0);
int x2 = lol::max(x - 1, 0);
int y3 = lol::min(y + 1, isize.y - 1);
int x3 = lol::min(x + 1, isize.x - 1);
vec3 t = srcp[y * isize.x + x].rgb;
t = lol::max(t, srcp[y * isize.x + x2].rgb);
t = lol::max(t, srcp[y * isize.x + x3].rgb);
t = lol::max(t, srcp[y2 * isize.x + x].rgb);
t = lol::max(t, srcp[y3 * isize.x + x].rgb);
dstp[y * isize.x + x] = vec4(t, srcp[y * isize.x + x].a);
}
unlock(srcp);
ret.unlock(dstp);
}
return ret;
}
old_image old_image::Erode()
{
ivec2 isize = size();
old_image ret(isize);
if (format() == PixelFormat::Y_8 || format() == PixelFormat::Y_F32)
{
float const *srcp = lock<PixelFormat::Y_F32>();
float *dstp = ret.lock<PixelFormat::Y_F32>();
for (int y = 0; y < isize.y; ++y)
for (int x = 0; x < isize.x; ++x)
{
int y2 = lol::max(y - 1, 0);
int x2 = lol::max(x - 1, 0);
int y3 = lol::min(y + 1, isize.y - 1);
int x3 = lol::min(x + 1, isize.x - 1);
float t = srcp[y * isize.x + x];
t = lol::max(t, srcp[y * isize.x + x2]);
t = lol::max(t, srcp[y * isize.x + x3]);
t = lol::max(t, srcp[y2 * isize.x + x]);
t = lol::max(t, srcp[y3 * isize.x + x]);
dstp[y * isize.x + x] = t;
}
unlock(srcp);
ret.unlock(dstp);
}
else
{
vec4 const *srcp = lock<PixelFormat::RGBA_F32>();
vec4 *dstp = ret.lock<PixelFormat::RGBA_F32>();
for (int y = 0; y < isize.y; ++y)
for (int x = 0; x < isize.x; ++x)
{
int y2 = lol::max(y - 1, 0);
int x2 = lol::max(x - 1, 0);
int y3 = lol::min(y + 1, isize.y - 1);
int x3 = lol::min(x + 1, isize.x - 1);
vec3 t = srcp[y * isize.x + x].rgb;
t = lol::min(t, srcp[y * isize.x + x2].rgb);
t = lol::min(t, srcp[y * isize.x + x3].rgb);
t = lol::min(t, srcp[y2 * isize.x + x].rgb);
t = lol::min(t, srcp[y3 * isize.x + x].rgb);
dstp[y * isize.x + x] = vec4(t, srcp[y * isize.x + x].a);
}
unlock(srcp);
ret.unlock(dstp);
}
return ret;
}
} /* namespace lol */
| [
"sam@hocevar.net"
] | sam@hocevar.net |
72187ce72215111fd93ac5fd9ae2eb311baa2eb3 | b3710dfdd0eeb3e28d3a4c666af5df6558a03553 | /cgodeps/godot_engine/tests/test_render.cpp | d936dd72e78abea746e1fc52e4ca418d90c6424a | [
"MIT",
"LicenseRef-scancode-free-unknown",
"CC-BY-3.0",
"OFL-1.1",
"BSD-3-Clause",
"Bitstream-Vera",
"FTL",
"MPL-2.0",
"Zlib",
"LicenseRef-scancode-nvidia-2002",
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"CC-BY-4.0"
] | permissive | gabstv/godot-go | 5befd7539ef35a9e459046644dd4b246a0db1ad9 | e0e7f07e1e44716e18330f063c9b3fd3c2468d31 | refs/heads/master | 2021-05-21T23:48:25.434825 | 2020-08-27T16:52:18 | 2020-08-27T16:52:18 | 252,864,512 | 10 | 3 | MIT | 2020-08-27T16:52:20 | 2020-04-03T23:26:52 | C++ | UTF-8 | C++ | false | false | 8,286 | cpp | /*************************************************************************/
/* test_render.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "test_render.h"
#include "core/math/math_funcs.h"
#include "core/math/quick_hull.h"
#include "core/os/keyboard.h"
#include "core/os/main_loop.h"
#include "core/os/os.h"
#include "core/print_string.h"
#include "servers/display_server.h"
#include "servers/rendering_server.h"
#define OBJECT_COUNT 50
namespace TestRender {
class TestMainLoop : public MainLoop {
RID test_cube;
RID instance;
RID camera;
RID viewport;
RID light;
RID scenario;
struct InstanceInfo {
RID instance;
Transform base;
Vector3 rot_axis;
};
List<InstanceInfo> instances;
float ofs;
bool quit;
protected:
public:
virtual void input_event(const Ref<InputEvent> &p_event) {
if (p_event->is_pressed()) {
quit = true;
}
}
virtual void init() {
print_line("INITIALIZING TEST RENDER");
RenderingServer *vs = RenderingServer::get_singleton();
test_cube = vs->get_test_cube();
scenario = vs->scenario_create();
Vector<Vector3> vts;
/*
Vector<Plane> sp = Geometry3D::build_sphere_planes(2,5,5);
Geometry3D::MeshData md2 = Geometry3D::build_convex_mesh(sp);
vts=md2.vertices;
*/
/*
static const int s = 20;
for(int i=0;i<s;i++) {
Basis rot(Vector3(0,1,0),i*Math_PI/s);
for(int j=0;j<s;j++) {
Vector3 v;
v.x=Math::sin(j*Math_PI*2/s);
v.y=Math::cos(j*Math_PI*2/s);
vts.push_back( rot.xform(v*2 ) );
}
}*/
/*for(int i=0;i<100;i++) {
vts.push_back( Vector3(Math::randf()*2-1.0,Math::randf()*2-1.0,Math::randf()*2-1.0).normalized()*2);
}*/
/*
vts.push_back(Vector3(0,0,1));
vts.push_back(Vector3(0,0,-1));
vts.push_back(Vector3(0,1,0));
vts.push_back(Vector3(0,-1,0));
vts.push_back(Vector3(1,0,0));
vts.push_back(Vector3(-1,0,0));*/
vts.push_back(Vector3(1, 1, 1));
vts.push_back(Vector3(1, -1, 1));
vts.push_back(Vector3(-1, 1, 1));
vts.push_back(Vector3(-1, -1, 1));
vts.push_back(Vector3(1, 1, -1));
vts.push_back(Vector3(1, -1, -1));
vts.push_back(Vector3(-1, 1, -1));
vts.push_back(Vector3(-1, -1, -1));
Geometry3D::MeshData md;
Error err = QuickHull::build(vts, md);
print_line("ERR: " + itos(err));
test_cube = vs->mesh_create();
vs->mesh_add_surface_from_mesh_data(test_cube, md);
//vs->scenario_set_debug(scenario,RS::SCENARIO_DEBUG_WIREFRAME);
/*
RID sm = vs->shader_create();
//vs->shader_set_fragment_code(sm,"OUT_ALPHA=mod(TIME,1);");
//vs->shader_set_vertex_code(sm,"OUT_VERTEX=IN_VERTEX*mod(TIME,1);");
vs->shader_set_fragment_code(sm,"OUT_DIFFUSE=vec3(1,0,1);OUT_GLOW=abs(sin(TIME));");
RID tcmat = vs->mesh_surface_get_material(test_cube,0);
vs->material_set_shader(tcmat,sm);
*/
List<String> cmdline = OS::get_singleton()->get_cmdline_args();
int object_count = OBJECT_COUNT;
if (cmdline.size() > 0 && cmdline[cmdline.size() - 1].to_int()) {
object_count = cmdline[cmdline.size() - 1].to_int();
};
for (int i = 0; i < object_count; i++) {
InstanceInfo ii;
ii.instance = vs->instance_create2(test_cube, scenario);
ii.base.translate(Math::random(-20, 20), Math::random(-20, 20), Math::random(-20, 18));
ii.base.rotate(Vector3(0, 1, 0), Math::randf() * Math_PI);
ii.base.rotate(Vector3(1, 0, 0), Math::randf() * Math_PI);
vs->instance_set_transform(ii.instance, ii.base);
ii.rot_axis = Vector3(Math::random(-1, 1), Math::random(-1, 1), Math::random(-1, 1)).normalized();
instances.push_back(ii);
}
camera = vs->camera_create();
// vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
viewport = vs->viewport_create();
Size2i screen_size = DisplayServer::get_singleton()->window_get_size();
vs->viewport_set_size(viewport, screen_size.x, screen_size.y);
vs->viewport_attach_to_screen(viewport, Rect2(Vector2(), screen_size));
vs->viewport_set_active(viewport, true);
vs->viewport_attach_camera(viewport, camera);
vs->viewport_set_scenario(viewport, scenario);
vs->camera_set_transform(camera, Transform(Basis(), Vector3(0, 3, 30)));
vs->camera_set_perspective(camera, 60, 0.1, 1000);
/*
RID lightaux = vs->light_create( RenderingServer::LIGHT_OMNI );
vs->light_set_var( lightaux, RenderingServer::LIGHT_VAR_RADIUS, 80 );
vs->light_set_var( lightaux, RenderingServer::LIGHT_VAR_ATTENUATION, 1 );
vs->light_set_var( lightaux, RenderingServer::LIGHT_VAR_ENERGY, 1.5 );
light = vs->instance_create( lightaux );
*/
RID lightaux;
lightaux = vs->directional_light_create();
//vs->light_set_color( lightaux, RenderingServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
vs->light_set_color(lightaux, Color(1.0, 1.0, 1.0));
//vs->light_set_shadow( lightaux, true );
light = vs->instance_create2(lightaux, scenario);
Transform lla;
//lla.set_look_at(Vector3(),Vector3(1,-1,1),Vector3(0,1,0));
lla.set_look_at(Vector3(), Vector3(-0.000000, -0.836026, -0.548690), Vector3(0, 1, 0));
vs->instance_set_transform(light, lla);
lightaux = vs->omni_light_create();
//vs->light_set_color( lightaux, RenderingServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
vs->light_set_color(lightaux, Color(1.0, 1.0, 0.0));
vs->light_set_param(lightaux, RenderingServer::LIGHT_PARAM_RANGE, 4);
vs->light_set_param(lightaux, RenderingServer::LIGHT_PARAM_ENERGY, 8);
//vs->light_set_shadow( lightaux, true );
//light = vs->instance_create( lightaux );
ofs = 0;
quit = false;
}
virtual bool iteration(float p_time) {
RenderingServer *vs = RenderingServer::get_singleton();
//Transform t;
//t.rotate(Vector3(0, 1, 0), ofs);
//t.translate(Vector3(0,0,20 ));
//vs->camera_set_transform(camera, t);
ofs += p_time * 0.05;
//return quit;
for (List<InstanceInfo>::Element *E = instances.front(); E; E = E->next()) {
Transform pre(Basis(E->get().rot_axis, ofs), Vector3());
vs->instance_set_transform(E->get().instance, pre * E->get().base);
/*
if( !E->next() ) {
vs->free( E->get().instance );
instances.erase(E );
}*/
}
return quit;
}
virtual bool idle(float p_time) {
return quit;
}
virtual void finish() {
}
};
MainLoop *test() {
return memnew(TestMainLoop);
}
} // namespace TestRender
| [
"gabs@gabs.tv"
] | gabs@gabs.tv |
491082aecf46710a942952d51accf2a6cf563616 | 1791461e6740f81c2dd6704ae6a899a6707ee6b1 | /Contest/ICPC Greater New York Region 2019/H.cpp | 5bc4a9aff5b342ce7b9ac0b48efdb621f9d60417 | [
"MIT"
] | permissive | HeRaNO/OI-ICPC-Codes | b12569caa94828c4bedda99d88303eb6344f5d6e | 4f542bb921914abd4e2ee7e17d8d93c1c91495e4 | refs/heads/master | 2023-08-06T10:46:32.714133 | 2023-07-26T08:10:44 | 2023-07-26T08:10:44 | 163,658,110 | 22 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 2,462 | cpp | #include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define lowbit(x) x&-x
#define pb push_back
#define ls (u<<1)
#define rs (u<<1|1)
#define Rint register int
#define ALL(x) (x).begin(),(x).end()
#define UNI(x) sort(ALL(x)),x.resize(unique(ALL(x))-x.begin())
#define GETPOS(c,x) (lower_bound(ALL(c),x)-c.begin())
#define LEN(x) strlen(x)
#define MS0(x) memset((x),0,sizeof((x)))
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<pii> Vpii;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(ll &x) { scanf("%lld", &x); }
void _R(ull &x) { scanf("%llu", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const ll &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
const int MOD=1e9+7,mod=1e9+7;
ll qpow(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
const int MAXN=3e5+10,MAXM=2e6+10;
const int INF=INT_MAX,SINF=0x3f3f3f3f;
const ll llINF=LLONG_MAX;
const int inv2=5e8+4;
const int Lim=1<<20;
uint a[MAXN];
set<uint> s;
void solve()
{
int n;
R(n);
for(int i=1;i<=n;i++)R(a[i]);
for(int i=1;i<=n;i++)
{
uint tmp=a[i];
for(uint j=2;j*j<=tmp;j++)
if(tmp%j==0)
{
while(tmp%j==0)tmp/=j;
s.insert(j);
}
if(tmp>1)s.insert(tmp);
}
int cnt=0;
vector<uint> v;
for(auto j:s)
{
v.pb(j);
}
for(int i=0;i<SZ(v);i++)
{
cout<<v[i];
if(i==SZ(v)-1)continue;
if(i%5<4)printf(" ");
else W("");
}
}
int main()
{
int T = 1;
//R(T);
while (T--)solve();
return 0;
} | [
"heran55@126.com"
] | heran55@126.com |
d2d9e1efd3b29d532bbf21c5498837b311f9d0de | 47c5c5b194dff3fb8a95721effc599591e90519a | /solved/1365.cpp | 6a642abffbce0ffbdc81fa9c07dea0d897a8f25e | [] | no_license | LEECHHE/acmicpc | 75ba56e3cd7a2d8d9c43f83e151632a58823840f | 8717bc33b53ac44037d9f58ee1d0b58014084648 | refs/heads/master | 2020-04-06T06:57:07.679362 | 2018-12-10T09:12:06 | 2018-12-10T09:12:06 | 65,816,339 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 594 | cpp | #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n; int seq[100000];
vector<int> ans;
scanf("%d",&n);
for( int i = 0 ; i < n ; ++i ){
scanf("%d",&seq[i]);
}
int size = 1;
ans.push_back(seq[0]);
for( int i = 1 ; i < n ; ++i ){
if(ans[size-1] < seq[i]){
ans.push_back(seq[i]);
++size;
continue;
}
auto it = (int)(lower_bound(ans.begin(), ans.begin()+size, seq[i])-ans.begin());
ans[it] = seq[i];
}
printf("%d",n-size);
return 0;
} | [
"leechhe90@gmail.com"
] | leechhe90@gmail.com |
d15fb6f39c79b54bcb94ef236498cad3dcd4a688 | 2aa49be64e86ea33b539fc42d67f5f78d8d51303 | /Authentication between Client and Server/Socket.h | d2e4f756c7019411a5b6d07883d2f427540c5c8c | [] | no_license | huangjieSC/Network-Programming-in-C | 914d57b2a6f960f3d23696ac89a93ad4d763a6b1 | e0b6d1b8454fde0b01367029ce7c11c7daafec84 | refs/heads/master | 2021-01-25T07:28:54.871861 | 2014-08-19T17:13:01 | 2014-08-19T17:13:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 879 | h | // Definition of the Socket class
#ifndef Socket_class
#define Socket_class
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <string>
#include <arpa/inet.h>
const int MAXHOSTNAME = 200;
const int MAXCONNECTIONS = 5;
const int MAXRECV = 500;
class Socket
{
public:
int accept_sd;
Socket();
~Socket();
// Server initialization
bool create();
bool bind ( const int port );
bool listen() const;
bool accept( Socket& );
int getAcceptsd();
// Client initialization
bool connect ( const std::string host, const int port );
// Data Transimission
bool send ( const std::string ) const;
int recv ( std::string& ) const;
void set_non_blocking ( const bool );
bool is_valid() const { return m_sock != -1; }
private:
int m_sock;
sockaddr_in m_addr;
};
#endif
| [
"huangjiebupt@gmail.com"
] | huangjiebupt@gmail.com |
e74def082aeeaa4b3c4cc268f536b603f07b95c7 | 913346299f7d2ff74ccd92a7db691440bfca67f8 | /V9/V9/Demo/DlgThreshold.cpp | 51bbc546368dc30a55aa10ff3eb7ae38307e654c | [] | no_license | yinzhengliang/CSCE606_CCCF | 19e06e724ccf962bb9a8d649df922d5a71c85d61 | 16bdb4f233f01460459271db28e920432349fe55 | refs/heads/master | 2021-01-01T19:19:42.220291 | 2013-12-03T20:19:07 | 2013-12-03T20:19:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 998 | cpp | // DlgThreshold.cpp : implementation file
//
#include "stdafx.h"
#include "demo.h"
#include "DlgThreshold.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgThreshold dialog
CDlgThreshold::CDlgThreshold(CWnd* pParent /*=NULL*/)
: CDialog(CDlgThreshold::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgThreshold)
m_threshold = 0;
m_iterate = -1;
//}}AFX_DATA_INIT
}
void CDlgThreshold::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgThreshold)
DDX_Text(pDX, IDC_THRESHOLD, m_threshold);
DDX_Radio(pDX, IDC_ITERATE, m_iterate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgThreshold, CDialog)
//{{AFX_MSG_MAP(CDlgThreshold)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgThreshold message handlers
| [
"yinzhengliang@tamu.edu"
] | yinzhengliang@tamu.edu |
5ad0472eb16badc1cb7dec157440d9a32d649868 | 9a43dcfe2183dd8bfd4e4e9f1066706eee35a9ac | /src/compaction.h | c04ee43e5aba4a21370f03826a9a03059e968de6 | [
"Apache-2.0"
] | permissive | hisundar/forestdb | 9ba31525a17e992cf3f7b38d26be089f425971d8 | 9e27dab0a4d756122dde8bc7c3efd1d31a9119e4 | refs/heads/master | 2021-01-24T07:20:17.016596 | 2016-09-27T21:33:07 | 2016-09-28T17:34:07 | 15,559,174 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 12,810 | h | /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2016 Couchbase, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <string>
#include "common.h"
#include "docio.h"
#include "file_handle.h"
#include "internal_types.h"
#include "kvs_handle.h"
// Forward declarations
class FileMgr;
class BTreeBlkHandle;
class DocioHandle;
class HBTrie;
class BTree;
/**
* Abstraction that defines all operations related to compaction
*/
class Compaction {
public:
Compaction() : fileMgr(nullptr), btreeHandle(nullptr), docHandle(nullptr),
keyTrie(nullptr), seqTree(nullptr), seqTrie(nullptr),
staleTree(nullptr) { }
/**
* Compact a given file by copying its active blocks to the new file.
*
* @param fhandle Pointer to the file handle whose file is compacted
* @param new_filename Name of a new compacted file
* @param in_place_compaction Flag indicating if the new compacted file
* should be renamed to the old file after compaction
* @param marker_bid Block id of a snapshot marker. The stale data up to this
* snapshot marker will be retained in the new file.
* @param clone_docs Flag indicating if the compaction can be done through the
* block-level COW support from the host OS.
* @param new_encryption_key Key with which to encrypt the new compacted file.
* To remove encryption, set the key's algorithm to FDB_ENCRYPTION_NONE.
* @return FDB_RESULT_SUCCESS on success.
*/
static fdb_status compactFile(FdbFileHandle *fhandle,
const char *new_filename,
bool in_place_compaction,
bid_t marker_bid,
bool clone_docs,
const fdb_encryption_key *new_encryption_key);
private:
/**
* Check if a given file can be compacted or not.
*
* @param handle Pointer to the KV store handle of the file that is checked
* for the compaction readiness
* @param new_filename Name of a new file for compaction
* @return FDB_RESULT_SUCCESS if a given file can be compacted
*/
static fdb_status checkCompactionReadiness(FdbKvsHandle *handle,
const char *new_filename);
/**
* Create a new file for compaction.
*
* @param file_name Name of a new file for compaction
* @param fconfig File manager configs for a new file
* @param in_place_compaction Flag indicating if in-place compaction or not
* @param handle Pointer to the KV store handle of the current file
* @return FDB_RESULT_SUCCESS on a successful file creation
*/
fdb_status createFile(const std::string file_name,
FileMgrConfig &fconfig,
bool in_place_compaction,
FdbKvsHandle *handle);
/**
* Clean up all the resources allocated in case of compaction failure
*/
void cleanUpCompactionErr(FdbKvsHandle *handle);
/**
* Copy all the active blocks upto a given snapshot marker from the current
* file to the new file
*
* @param rhandle Pointer to the KV store handle of the current file
* @param marker_bid Block ID of a snapshot marker
* @param last_hdr_bid Block ID of the last commit header
* @param last_seq Last seq number of the current file
* @param prob Write throttling probability
* @param clone_docs Flag indicating if the compaction can be performed by the
* COW support from the host OS
* @return FDB_RESULT_SUCCESS on a successful copy operation
*/
fdb_status copyDocsUptoMarker(FdbKvsHandle *rhandle,
bid_t marker_bid,
bid_t last_hdr_bid,
fdb_seqnum_t last_seq,
size_t *prob,
bool clone_docs);
/**
* Copy all the active blocks belonging to the last commit marker from
* the current file to the new file
*
* @param handle Pointer to the KV store handle of the current file
* @param prob Write throttling probability
* @param clone_docs Flag indicating if the compaction can be performed by the
* COW support from the host OS
* @return FDB_RESULT_SUCCESS on a successful copy operation
*/
fdb_status copyDocs(FdbKvsHandle *handle,
size_t *prob,
bool clone_docs);
/**
* Copy all the active blocks from a given beginning block to ending block in
* the current file to the new file
*
* @param handle Pointer to the KV store handle of the current file
* @param begin_hdr Beginning block ID
* @param end_hdr Ending block ID
* @param compact_upto Flag indicating if this is invoked as part of
* fdb_compact_upto API call
* @param clone_docs Flag indicating if the compaction can be performed by the
* COW support from the host OS
* @param got_lock Flag indicating if the filemgr's lock on the current file is
* currently grabbed by the caller of this function
* @param last_loop Flag indicating if this call is the last round of copying
* the delta blocks from the current file to the new file
* @param prob Write throttling probability
* @return FDB_RESULT_SUCCESS on a successful copy operation
*/
fdb_status copyDelta(FdbKvsHandle *handle,
bid_t begin_hdr,
bid_t end_hdr,
bool compact_upto,
bool clone_docs,
bool got_lock,
bool last_loop,
size_t *prob);
/**
* Copy all the WAL blocks from a given beginning position to ending
* position from the current file to the new file
*
* @param handle Pointer to the KV store handle of the current file
* @param start_bid Beginning block ID
* @param stop_bid Ending block ID
* @return FDB_RESULT_SUCCESS on a successful copy operation
*/
fdb_status copyWalDocs(FdbKvsHandle *handle,
bid_t start_bid,
bid_t stop_bid);
#ifdef _COW_COMPACTION
/**
* Copy all the active blocks belonging to the last commit marker from
* the current file to the new file by using the block-level COW support
* from the host OS.
*
* @param handle Pointer to the KV store handle of the current file
* @param prob Write throttling probability
*/
fdb_status cloneDocs(FdbKvsHandle *handle, size_t *prob);
/**
* Copy the given batch documents from the current file to the new file by
* using the block-level COW support from the host OS.
*
* @param handle Pointer to the KV store handle of the current file
* @param new_handle Pointer to the KV store handle of the new file
* @param doc Pointer to the array containning documents to be copied
* @param old_offset_array Pointer to the array containning the offsets of
* documents to be copied
* @param n_buf Size of the document array
* @param got_lock Flag indicating if the filemgr's lock on the current file is
* currently grabbed by the caller of this function
* @param prob Write throttling probability
* @param delay_us Write throttling time in microseconds
*/
void cloneBatchedDelta(FdbKvsHandle *handle,
FdbKvsHandle *new_handle,
struct docio_object *doc,
uint64_t *old_offset_array,
uint64_t n_buf,
bool got_lock,
size_t *prob,
uint64_t delay_us);
#endif
/**
* Copy the given batch documents from the current file to the new file
*
* @param handle Pointer to the KV store handle of the current file
* @param new_handle Pointer to the KV store handle of the new file
* @param doc Pointer to the array containning documents to be copied
* @param old_offset_array Pointer to the array containning the offsets of
* documents to be copied
* @param n_buf Size of the document array
* @param clone_docs Flag indicating if the compaction can be performed by the
* COW support from the host OS
* @param got_lock Flag indicating if the filemgr's lock on the current file is
* currently grabbed by the caller of this function
* @param prob Write throttling probability
* @param delay_us Write throttling time in microseconds
*/
void appendBatchedDelta(FdbKvsHandle *handle,
FdbKvsHandle *new_handle,
struct docio_object *doc,
uint64_t *old_offset_array,
uint64_t n_buf,
bool clone_docs,
bool got_lock,
size_t *prob,
uint64_t delay_us);
/**
* Commit the new file and set the old file's status to pending removal
*
* @param handle Pointer to the KV store handle of the new file
* @param old_file Pointer to the old file manager
* @return FDB_RESULT_SUCCESS if the operation is completed successfully
*/
fdb_status commitAndRemovePending(FdbKvsHandle *handle,
FileMgr *old_file);
/**
* Calculate the throttling delay time for a writer
*
* @param n_moved_docs Number of documents copied from the old file to
* the new files since a given start timestamp.
* @param start_timestamp Start timestamp of the copy operation
* @return Throttling delay time for a writer
*/
uint64_t calculateWriteThrottlingDelay(uint64_t n_moved_docs,
struct timeval start_timestamp);
/**
* Update the write throttling probability by calculating the throughput ratio
* of the writer to the compactor
*
* @param writer_curr_bid ID of the block where the writer writes currently
* @param compactor_curr_bid ID of the block where the compactor writes currently
* @param writer_prev_bid ID of the block where the writer wrote first since
* the last update on the write throttling probability
* @param compactor_prev_bid ID of the block where the compactor wrote first since
* the last update on the write throttling probability
* @param prob Write throttling probability to be updated
* @param max_prob Maximum write throttling probability allowed
*/
void updateWriteThrottlingProb(bid_t writer_curr_bid,
bid_t compactor_curr_bid,
bid_t *writer_prev_bid,
bid_t *compactor_prev_bid,
size_t *prob,
size_t max_prob);
/**
* Adjust the write throttling probability based on a given throughput ratio
* of the writer to the compactor
*
* @param cur_ratio Throughput ratio of the writer to the compactor
* @param prob Write throttling probability to be updated
* @param max_prob Maximum write throttling probability allowed
*/
void adjustWriteThrottlingProb(size_t cur_ratio,
size_t *prob,
size_t max_prob);
FileMgr *fileMgr; // file manager instance for a new file
BTreeBlkHandle *btreeHandle; // btree block handle for a new file
DocioHandle *docHandle; // document block handle for a new file
HBTrie *keyTrie; // key index trie for a new file
BTree *seqTree; // seq index tree for a new file
HBTrie *seqTrie; // seq index trie for a new file
BTree *staleTree; // stale block tree for a new file
};
| [
"chiyoung@couchbase.com"
] | chiyoung@couchbase.com |
0a7906af08ab84eb96bb7014a631c28860fb50e6 | e1164c586b8a6fb78b8359b2b1fe20d8bc1892a2 | /hello-world-2021/hello_world_husinassegaff.cpp | 7bcf7800db1422a739c798b8628fba23a17943ed | [] | no_license | suhas30/hacktoberfest-beginner | 0f0d97c608a9aebbe86ab6329ec6c61f683ad4ab | a645962cd5e177dcc1bfee7b80f91c0e76e08ba4 | refs/heads/master | 2023-08-28T12:18:34.649814 | 2021-10-29T14:27:51 | 2021-10-29T14:27:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 190 | cpp | // AUTHOR: husinassegaff
// LANGUAGE: C++
// GITHUB: https://github.com/husinassegaff
#include <bits/stdc++.h>
using namespace std;
int main()
{
cout << "Hello World";
return 0;
}
| [
"husinassegaff15@gmail.com"
] | husinassegaff15@gmail.com |
6b4c9910b5065f2817d0e9729d66a9279f363b8e | 406fd11771828c25b66664e1f47f890de511d00e | /src/common/scoped_message_writer.h | d76438b5666bae9c7e74ecc312e132357b161fc5 | [
"BSD-3-Clause"
] | permissive | romankosoj/protect | f903f874d5d931fcc067636186ba2a02d1788999 | 473cd33e97435777ca8885dc3f418e012fdb6cb1 | refs/heads/master | 2021-07-15T17:13:37.270241 | 2017-10-19T14:35:08 | 2017-10-19T14:35:08 | 107,504,869 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,430 | h | // Copyright (c) 2014-2017, The Protect Security Coin
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
#include "misc_log_ex.h"
#include <iostream>
#ifdef HAVE_READLINE
#include "readline_buffer.h"
#define PAUSE_READLINE() \
rdln::suspend_readline pause_readline;
#else
#define PAUSE_READLINE()
#endif
namespace tools
{
/************************************************************************/
/* */
/************************************************************************/
class scoped_message_writer
{
private:
bool m_flush;
std::stringstream m_oss;
epee::console_colors m_color;
bool m_bright;
el::Level m_log_level;
public:
scoped_message_writer(
epee::console_colors color = epee::console_color_default
, bool bright = false
, std::string&& prefix = std::string()
, el::Level log_level = el::Level::Info
)
: m_flush(true)
, m_color(color)
, m_bright(bright)
, m_log_level(log_level)
{
m_oss << prefix;
}
scoped_message_writer(scoped_message_writer&& rhs)
: m_flush(std::move(rhs.m_flush))
#if defined(_MSC_VER)
, m_oss(std::move(rhs.m_oss))
#else
// GCC bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54316
, m_oss(rhs.m_oss.str(), std::ios_base::out | std::ios_base::ate)
#endif
, m_color(std::move(rhs.m_color))
, m_log_level(std::move(rhs.m_log_level))
{
rhs.m_flush = false;
}
scoped_message_writer(scoped_message_writer& rhs) = delete;
scoped_message_writer& operator=(scoped_message_writer& rhs) = delete;
scoped_message_writer& operator=(scoped_message_writer&& rhs) = delete;
template<typename T>
std::ostream& operator<<(const T& val)
{
m_oss << val;
return m_oss;
}
~scoped_message_writer()
{
if (m_flush)
{
m_flush = false;
MCLOG_FILE(m_log_level, "msgwriter", m_oss.str());
if (epee::console_color_default == m_color)
{
std::cout << m_oss.str();
}
else
{
PAUSE_READLINE();
set_console_color(m_color, m_bright);
std::cout << m_oss.str();
epee::reset_console_color();
}
std::cout << std::endl;
}
}
};
inline scoped_message_writer success_msg_writer(bool color = true)
{
return scoped_message_writer(color ? epee::console_color_green : epee::console_color_default, false, std::string(), el::Level::Info);
}
inline scoped_message_writer msg_writer(epee::console_colors color = epee::console_color_default)
{
return scoped_message_writer(color, false, std::string(), el::Level::Info);
}
inline scoped_message_writer fail_msg_writer()
{
return scoped_message_writer(epee::console_color_red, true, "Error: ", el::Level::Error);
}
} // namespace tools
| [
"roman@kosoj.ru"
] | roman@kosoj.ru |
1527c7881318ec796e637b7f35e5dc53d4fedb6e | d0fb46aecc3b69983e7f6244331a81dff42d9595 | /sgw/src/model/DescribeGatewayDNSResult.cc | 984c9dd7696d7c93ab8eefa771a9358846a075e8 | [
"Apache-2.0"
] | permissive | aliyun/aliyun-openapi-cpp-sdk | 3d8d051d44ad00753a429817dd03957614c0c66a | e862bd03c844bcb7ccaa90571bceaa2802c7f135 | refs/heads/master | 2023-08-29T11:54:00.525102 | 2023-08-29T03:32:48 | 2023-08-29T03:32:48 | 115,379,460 | 104 | 82 | NOASSERTION | 2023-09-14T06:13:33 | 2017-12-26T02:53:27 | C++ | UTF-8 | C++ | false | false | 1,845 | cc | /*
* Copyright 2009-2017 Alibaba Cloud 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.
*/
#include <alibabacloud/sgw/model/DescribeGatewayDNSResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Sgw;
using namespace AlibabaCloud::Sgw::Model;
DescribeGatewayDNSResult::DescribeGatewayDNSResult() :
ServiceResult()
{}
DescribeGatewayDNSResult::DescribeGatewayDNSResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
DescribeGatewayDNSResult::~DescribeGatewayDNSResult()
{}
void DescribeGatewayDNSResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["Success"].isNull())
success_ = value["Success"].asString() == "true";
if(!value["Code"].isNull())
code_ = value["Code"].asString();
if(!value["Message"].isNull())
message_ = value["Message"].asString();
if(!value["DnsServer"].isNull())
dnsServer_ = value["DnsServer"].asString();
}
std::string DescribeGatewayDNSResult::getMessage()const
{
return message_;
}
std::string DescribeGatewayDNSResult::getCode()const
{
return code_;
}
bool DescribeGatewayDNSResult::getSuccess()const
{
return success_;
}
std::string DescribeGatewayDNSResult::getDnsServer()const
{
return dnsServer_;
}
| [
"sdk-team@alibabacloud.com"
] | sdk-team@alibabacloud.com |
2b28006cf33efb522bf9513e11c57006792c4161 | 8dc84558f0058d90dfc4955e905dab1b22d12c08 | /third_party/webrtc/pc/ice_server_parsing_unittest.cc | 0ec59caa23d9881bea1a14ba8a1d95b68db064d6 | [
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"LicenseRef-scancode-google-patent-license-webm",
"LicenseRef-scancode-google-patent-license-webrtc",
"LicenseRef-scancode-takuya-ooura",
"LicenseRef-scancode-public-domai... | permissive | meniossin/src | 42a95cc6c4a9c71d43d62bc4311224ca1fd61e03 | 44f73f7e76119e5ab415d4593ac66485e65d700a | refs/heads/master | 2022-12-16T20:17:03.747113 | 2020-09-03T10:43:12 | 2020-09-03T10:43:12 | 263,710,168 | 1 | 0 | BSD-3-Clause | 2020-05-13T18:20:09 | 2020-05-13T18:20:08 | null | UTF-8 | C++ | false | false | 9,607 | cc | /*
* Copyright 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <string>
#include <vector>
#include "p2p/base/port_interface.h"
#include "pc/ice_server_parsing.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/socket_address.h"
#include "test/gtest.h"
namespace webrtc {
class IceServerParsingTest : public testing::Test {
public:
// Convenience functions for parsing a single URL. Result is stored in
// |stun_servers_| and |turn_servers_|.
bool ParseUrl(const std::string& url) {
return ParseUrl(url, std::string(), std::string());
}
bool ParseTurnUrl(const std::string& url) {
return ParseUrl(url, "username", "password");
}
bool ParseUrl(const std::string& url,
const std::string& username,
const std::string& password) {
return ParseUrl(
url, username, password,
PeerConnectionInterface::TlsCertPolicy::kTlsCertPolicySecure);
}
bool ParseUrl(const std::string& url,
const std::string& username,
const std::string& password,
PeerConnectionInterface::TlsCertPolicy tls_certificate_policy) {
return ParseUrl(url, username, password, tls_certificate_policy, "");
}
bool ParseUrl(const std::string& url,
const std::string& username,
const std::string& password,
PeerConnectionInterface::TlsCertPolicy tls_certificate_policy,
const std::string& hostname) {
stun_servers_.clear();
turn_servers_.clear();
PeerConnectionInterface::IceServers servers;
PeerConnectionInterface::IceServer server;
server.urls.push_back(url);
server.username = username;
server.password = password;
server.tls_cert_policy = tls_certificate_policy;
server.hostname = hostname;
servers.push_back(server);
return webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_) ==
webrtc::RTCErrorType::NONE;
}
protected:
cricket::ServerAddresses stun_servers_;
std::vector<cricket::RelayServerConfig> turn_servers_;
};
// Make sure all STUN/TURN prefixes are parsed correctly.
TEST_F(IceServerParsingTest, ParseStunPrefixes) {
EXPECT_TRUE(ParseUrl("stun:hostname"));
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ(0U, turn_servers_.size());
EXPECT_TRUE(ParseUrl("stuns:hostname"));
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ(0U, turn_servers_.size());
EXPECT_TRUE(ParseTurnUrl("turn:hostname"));
EXPECT_EQ(0U, stun_servers_.size());
EXPECT_EQ(1U, turn_servers_.size());
EXPECT_EQ(cricket::PROTO_UDP, turn_servers_[0].ports[0].proto);
EXPECT_TRUE(ParseTurnUrl("turns:hostname"));
EXPECT_EQ(0U, stun_servers_.size());
EXPECT_EQ(1U, turn_servers_.size());
EXPECT_EQ(cricket::PROTO_TLS, turn_servers_[0].ports[0].proto);
EXPECT_TRUE(turn_servers_[0].tls_cert_policy ==
cricket::TlsCertPolicy::TLS_CERT_POLICY_SECURE);
EXPECT_TRUE(ParseUrl(
"turns:hostname", "username", "password",
PeerConnectionInterface::TlsCertPolicy::kTlsCertPolicyInsecureNoCheck));
EXPECT_EQ(0U, stun_servers_.size());
EXPECT_EQ(1U, turn_servers_.size());
EXPECT_TRUE(turn_servers_[0].tls_cert_policy ==
cricket::TlsCertPolicy::TLS_CERT_POLICY_INSECURE_NO_CHECK);
EXPECT_EQ(cricket::PROTO_TLS, turn_servers_[0].ports[0].proto);
// invalid prefixes
EXPECT_FALSE(ParseUrl("stunn:hostname"));
EXPECT_FALSE(ParseUrl(":hostname"));
EXPECT_FALSE(ParseUrl(":"));
EXPECT_FALSE(ParseUrl(""));
}
TEST_F(IceServerParsingTest, VerifyDefaults) {
// TURNS defaults
EXPECT_TRUE(ParseTurnUrl("turns:hostname"));
EXPECT_EQ(1U, turn_servers_.size());
EXPECT_EQ(5349, turn_servers_[0].ports[0].address.port());
EXPECT_EQ(cricket::PROTO_TLS, turn_servers_[0].ports[0].proto);
// TURN defaults
EXPECT_TRUE(ParseTurnUrl("turn:hostname"));
EXPECT_EQ(1U, turn_servers_.size());
EXPECT_EQ(3478, turn_servers_[0].ports[0].address.port());
EXPECT_EQ(cricket::PROTO_UDP, turn_servers_[0].ports[0].proto);
// STUN defaults
EXPECT_TRUE(ParseUrl("stun:hostname"));
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ(3478, stun_servers_.begin()->port());
}
// Check that the 6 combinations of IPv4/IPv6/hostname and with/without port
// can be parsed correctly.
TEST_F(IceServerParsingTest, ParseHostnameAndPort) {
EXPECT_TRUE(ParseUrl("stun:1.2.3.4:1234"));
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ("1.2.3.4", stun_servers_.begin()->hostname());
EXPECT_EQ(1234, stun_servers_.begin()->port());
EXPECT_TRUE(ParseUrl("stun:[1:2:3:4:5:6:7:8]:4321"));
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ("1:2:3:4:5:6:7:8", stun_servers_.begin()->hostname());
EXPECT_EQ(4321, stun_servers_.begin()->port());
EXPECT_TRUE(ParseUrl("stun:hostname:9999"));
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ("hostname", stun_servers_.begin()->hostname());
EXPECT_EQ(9999, stun_servers_.begin()->port());
EXPECT_TRUE(ParseUrl("stun:1.2.3.4"));
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ("1.2.3.4", stun_servers_.begin()->hostname());
EXPECT_EQ(3478, stun_servers_.begin()->port());
EXPECT_TRUE(ParseUrl("stun:[1:2:3:4:5:6:7:8]"));
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ("1:2:3:4:5:6:7:8", stun_servers_.begin()->hostname());
EXPECT_EQ(3478, stun_servers_.begin()->port());
EXPECT_TRUE(ParseUrl("stun:hostname"));
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ("hostname", stun_servers_.begin()->hostname());
EXPECT_EQ(3478, stun_servers_.begin()->port());
// Both TURN IP and host exist
EXPECT_TRUE(
ParseUrl("turn:1.2.3.4:1234", "username", "password",
PeerConnectionInterface::TlsCertPolicy::kTlsCertPolicySecure,
"hostname"));
EXPECT_EQ(1U, turn_servers_.size());
rtc::SocketAddress address = turn_servers_[0].ports[0].address;
EXPECT_EQ("hostname", address.hostname());
EXPECT_EQ(1234, address.port());
EXPECT_FALSE(address.IsUnresolvedIP());
EXPECT_EQ("1.2.3.4", address.ipaddr().ToString());
// Try some invalid hostname:port strings.
EXPECT_FALSE(ParseUrl("stun:hostname:99a99"));
EXPECT_FALSE(ParseUrl("stun:hostname:-1"));
EXPECT_FALSE(ParseUrl("stun:hostname:port:more"));
EXPECT_FALSE(ParseUrl("stun:hostname:port more"));
EXPECT_FALSE(ParseUrl("stun:hostname:"));
EXPECT_FALSE(ParseUrl("stun:[1:2:3:4:5:6:7:8]junk:1000"));
EXPECT_FALSE(ParseUrl("stun::5555"));
EXPECT_FALSE(ParseUrl("stun:"));
}
// Test parsing the "?transport=xxx" part of the URL.
TEST_F(IceServerParsingTest, ParseTransport) {
EXPECT_TRUE(ParseTurnUrl("turn:hostname:1234?transport=tcp"));
EXPECT_EQ(1U, turn_servers_.size());
EXPECT_EQ(cricket::PROTO_TCP, turn_servers_[0].ports[0].proto);
EXPECT_TRUE(ParseTurnUrl("turn:hostname?transport=udp"));
EXPECT_EQ(1U, turn_servers_.size());
EXPECT_EQ(cricket::PROTO_UDP, turn_servers_[0].ports[0].proto);
EXPECT_FALSE(ParseTurnUrl("turn:hostname?transport=invalid"));
EXPECT_FALSE(ParseTurnUrl("turn:hostname?transport="));
EXPECT_FALSE(ParseTurnUrl("turn:hostname?="));
EXPECT_FALSE(ParseTurnUrl("turn:hostname?"));
EXPECT_FALSE(ParseTurnUrl("?"));
}
// Test parsing ICE username contained in URL.
TEST_F(IceServerParsingTest, ParseUsername) {
EXPECT_TRUE(ParseTurnUrl("turn:user@hostname"));
EXPECT_EQ(1U, turn_servers_.size());
EXPECT_EQ("user", turn_servers_[0].credentials.username);
EXPECT_FALSE(ParseTurnUrl("turn:@hostname"));
EXPECT_FALSE(ParseTurnUrl("turn:username@"));
EXPECT_FALSE(ParseTurnUrl("turn:@"));
EXPECT_FALSE(ParseTurnUrl("turn:user@name@hostname"));
}
// Test that username and password from IceServer is copied into the resulting
// RelayServerConfig.
TEST_F(IceServerParsingTest, CopyUsernameAndPasswordFromIceServer) {
EXPECT_TRUE(ParseUrl("turn:hostname", "username", "password"));
EXPECT_EQ(1U, turn_servers_.size());
EXPECT_EQ("username", turn_servers_[0].credentials.username);
EXPECT_EQ("password", turn_servers_[0].credentials.password);
}
// Ensure that if a server has multiple URLs, each one is parsed.
TEST_F(IceServerParsingTest, ParseMultipleUrls) {
PeerConnectionInterface::IceServers servers;
PeerConnectionInterface::IceServer server;
server.urls.push_back("stun:hostname");
server.urls.push_back("turn:hostname");
server.username = "foo";
server.password = "bar";
servers.push_back(server);
EXPECT_EQ(webrtc::RTCErrorType::NONE,
webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_));
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ(1U, turn_servers_.size());
}
// Ensure that TURN servers are given unique priorities,
// so that their resulting candidates have unique priorities.
TEST_F(IceServerParsingTest, TurnServerPrioritiesUnique) {
PeerConnectionInterface::IceServers servers;
PeerConnectionInterface::IceServer server;
server.urls.push_back("turn:hostname");
server.urls.push_back("turn:hostname2");
server.username = "foo";
server.password = "bar";
servers.push_back(server);
EXPECT_EQ(webrtc::RTCErrorType::NONE,
webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_));
EXPECT_EQ(2U, turn_servers_.size());
EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority);
}
} // namespace webrtc
| [
"arnaud@geometry.ee"
] | arnaud@geometry.ee |
7ce7667ef2257b20e229304faea747d34e3c980a | 45e0fbd9a9dbcdd4fbe6aaa2fdb2aed296f81e33 | /FindSecret/Classes/Native/System_System_Net_Security_SslStream_U3CBeginAuthe1222040293.h | 51e1d2ee9b0c67e705a43e294f0b8d9eb867b48b | [
"MIT"
] | permissive | GodIsWord/NewFindSecret | d4a5d2d810ee1f9d6b3bc91168895cc808bac817 | 4f98f316d29936380f9665d6a6d89962d9ee5478 | refs/heads/master | 2020-03-24T09:54:50.239014 | 2018-10-27T05:22:11 | 2018-10-27T05:22:11 | 142,641,511 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,332 | h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include "mscorlib_System_Object3080106164.h"
// System.Security.Cryptography.X509Certificates.X509CertificateCollection
struct X509CertificateCollection_t3399372417;
// System.Net.Security.SslStream
struct SslStream_t2700741536;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Net.Security.SslStream/<BeginAuthenticateAsClient>c__AnonStorey7
struct U3CBeginAuthenticateAsClientU3Ec__AnonStorey7_t1222040293 : public Il2CppObject
{
public:
// System.Security.Cryptography.X509Certificates.X509CertificateCollection System.Net.Security.SslStream/<BeginAuthenticateAsClient>c__AnonStorey7::clientCertificates
X509CertificateCollection_t3399372417 * ___clientCertificates_0;
// System.Net.Security.SslStream System.Net.Security.SslStream/<BeginAuthenticateAsClient>c__AnonStorey7::<>f__this
SslStream_t2700741536 * ___U3CU3Ef__this_1;
public:
inline static int32_t get_offset_of_clientCertificates_0() { return static_cast<int32_t>(offsetof(U3CBeginAuthenticateAsClientU3Ec__AnonStorey7_t1222040293, ___clientCertificates_0)); }
inline X509CertificateCollection_t3399372417 * get_clientCertificates_0() const { return ___clientCertificates_0; }
inline X509CertificateCollection_t3399372417 ** get_address_of_clientCertificates_0() { return &___clientCertificates_0; }
inline void set_clientCertificates_0(X509CertificateCollection_t3399372417 * value)
{
___clientCertificates_0 = value;
Il2CppCodeGenWriteBarrier(&___clientCertificates_0, value);
}
inline static int32_t get_offset_of_U3CU3Ef__this_1() { return static_cast<int32_t>(offsetof(U3CBeginAuthenticateAsClientU3Ec__AnonStorey7_t1222040293, ___U3CU3Ef__this_1)); }
inline SslStream_t2700741536 * get_U3CU3Ef__this_1() const { return ___U3CU3Ef__this_1; }
inline SslStream_t2700741536 ** get_address_of_U3CU3Ef__this_1() { return &___U3CU3Ef__this_1; }
inline void set_U3CU3Ef__this_1(SslStream_t2700741536 * value)
{
___U3CU3Ef__this_1 = value;
Il2CppCodeGenWriteBarrier(&___U3CU3Ef__this_1, value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| [
"zhangyide@9fbank.cc"
] | zhangyide@9fbank.cc |
aef0e22b04bf1a554365a9588f927c7a5c2c831a | 138b56b150301cf75c163b7b9dc1efa0d624d1fb | /source/corpus/corpus_preprocess.h | c7bdcb36ac5a01bb5f9614afe2b538c321fd68e0 | [
"Apache-2.0"
] | permissive | royshan/icma | b5696a958192653230489cada223f44942afe348 | a1655ae6431912d10aa879b6b04d90ffa8b15b50 | refs/heads/master | 2020-12-26T01:12:16.841069 | 2014-09-23T10:37:13 | 2014-09-23T10:37:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,454 | h | /** \file corpus_preprocess.h
*
* \author Jun Jiang
* \version 0.1
* \date Feb 23, 2009
*/
#ifndef CMA_CORPUS_PREPROCESS_H
#define CMA_CORPUS_PREPROCESS_H
#include <string>
namespace cma
{
/**
* CorpusPreprocess preprocsses the corpus for training statistical model.
*/
class CorpusPreprocess
{
public:
virtual ~CorpusPreprocess();
/**
* Read from \e rawFile, process it, and write into \e resultFile in a specific format.
* \param rawFile the file to be processed
* \param resultFile the output file
*/
virtual void format(const char* rawFile, const char* resultFile) = 0;
/** Output format of dictionary */
enum Dict_Format
{
DICT_FORMAT_WORDPOS, ///< "word pos1 pos2 ..."
DICT_FORMAT_POSWORD, ///< "pos word1 word2 ..."
DICT_FORMAT_NUM ///< total number of format
};
/**
* Read from \e corpusFile, extract pairs of word and part-of-speech, and write the dictionary into \e dictFile.
* \param corpusFile the corpus file, which format is assumed as "word/pos" delimited by spaces
* \param dictFile the dictionary file for output
* \param format the format of dictionary file
*/
static void extractDictionary(const char* corpusFile, const char* dictFile, Dict_Format format);
protected:
static const std::string FILE_OPEN_ERROR; ///< error message when file open failed
};
} // namespace cma
#endif // CMA_CORPUS_PREPROCESS_H
| [
"vernkin@vernkin-desktop.(none)"
] | vernkin@vernkin-desktop.(none) |
d341f28cebbba31775d523bd3419a8599944c560 | 2e72c6c1de0ec472de2024ed593e149e7dedac6b | /Fractals/CalculationQueue.cpp | 0a363de46bece5856431eff581919da2124e9750 | [
"MIT"
] | permissive | emgre/fractals | 11d544fe55eaa8bcb0bb0a360bcb472013ece5fe | ed85811f0751d12ac308a1032466c4139895250e | refs/heads/master | 2021-01-19T12:12:12.986004 | 2016-09-23T17:36:38 | 2016-09-23T17:36:38 | 69,047,096 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,257 | cpp | #include "CalculationQueue.h"
#include "Tile.h"
#include <iostream>
CalculationQueue::CalculationQueue()
{
unsigned int numThreads = std::max(MIN_NUM_THREADS, std::thread::hardware_concurrency());
threads.reserve(numThreads);
workerThreadEnabled = true;
for (unsigned int i = 0; i < numThreads; i++)
{
threads.push_back(std::thread(CalculationQueue::threadRoutine, this));
}
}
CalculationQueue::~CalculationQueue()
{
workerThreadEnabled = false;
tileAvailable.notify_all();
for (auto& thread : threads)
{
thread.join();
}
}
void CalculationQueue::addTile(std::weak_ptr<Tile> tile)
{
std::unique_lock<std::mutex> guard(tileMutex);
tiles.push(tile);
tileAvailable.notify_one();
}
std::weak_ptr<Tile> CalculationQueue::getTile()
{
std::unique_lock<std::mutex> guard(tileMutex);
tileAvailable.wait(guard, [this]() {return !isWorkerThreadsEnabled() || !tiles.empty(); });
if (tiles.empty())
{
throw ThreadsFinishedException();
}
auto tile = tiles.front();
tiles.pop();
return tile;
}
bool CalculationQueue::isWorkerThreadsEnabled() const
{
return workerThreadEnabled;
}
void CalculationQueue::addTileReady(std::pair<std::weak_ptr<Tile>, std::vector<sf::Uint8>> tile)
{
tilesReady.push(tile);
}
void CalculationQueue::update()
{
while (!tilesReady.empty())
{
auto t = tilesReady.front();
if (!t.first.expired())
{
auto tile = t.first.lock();
tile->updateData(t.second);
}
tilesReady.pop();
}
}
void CalculationQueue::threadRoutine(CalculationQueue* queue)
{
while (true)
{
try
{
auto tileWeakPtr = queue->getTile();
if (tileWeakPtr.expired()) { continue; }
auto tile = *tileWeakPtr.lock();
std::vector<sf::Uint8> pixels;
pixels.resize(TILE_SIZE * TILE_SIZE * 4);
for (unsigned long i = 0; i < TILE_SIZE; i++)
{
for (unsigned long j = 0; j < TILE_SIZE; j++)
{
unsigned long n = CalculationQueue::calculateMandelbrot(tile, i, j, MAX_ITERATION);
CalculationQueue::setPixel(&pixels, j, i, n);
}
}
queue->addTileReady(std::make_pair(tileWeakPtr, pixels));
}
catch (ThreadsFinishedException e)
{
break;
}
}
}
inline unsigned int CalculationQueue::calculateMandelbrot(const Tile& tile, unsigned long i, unsigned long j, unsigned int maxIteration)
{
auto rect = tile.getRect();
double x0 = mapCoordinate(i, TILE_SIZE, rect.left, rect.left + rect.width);
double y0 = mapCoordinate(j, TILE_SIZE, rect.top, rect.top - rect.height);
double x = 0;
double y = 0;
double xSqr = 0;
double ySqr = 0;
unsigned long iteration = 0;
while (xSqr + ySqr < 4 && iteration < maxIteration)
{
y = x * y;
y += y;
y += y0;
x = xSqr - ySqr + x0;
xSqr = x * x;
ySqr = y * y;
iteration++;
}
return iteration;
}
inline double CalculationQueue::mapCoordinate(unsigned long x, unsigned long width, double min, double max)
{
double range = max - min;
return x * (range / width) + min;
}
inline void CalculationQueue::setPixel(std::vector<sf::Uint8>* pixels, unsigned long x, unsigned long y, unsigned long value)
{
unsigned long base = x * TILE_SIZE * 4 + y * 4;
(*pixels)[base] = (unsigned int)(value);
(*pixels)[base + 1] = (unsigned int)(value);
(*pixels)[base + 2] = (unsigned int)(value);
(*pixels)[base + 3] = 255;
} | [
"eg@emilegregoire.ca"
] | eg@emilegregoire.ca |
38742bc34eea388774a2362a400b6e972c1b44a8 | c68dd0cbe22c5bc848816d4ea9b932a4cb27536a | /src/vnsw/agent/services/test/igmp_test.cc | c4d557e9f60a95edd6726b571d4d013ce394c549 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | gzimin/contrail-controller | 785a54a5d2908fafcc215f92fda383e45ee3e61e | aad54e12d69c78fb9242bc10998955d515ea13c6 | refs/heads/master | 2020-04-21T07:58:09.691455 | 2019-02-01T09:19:03 | 2019-02-01T09:19:03 | 169,405,429 | 6 | 0 | null | 2019-02-06T12:52:00 | 2019-02-06T12:52:00 | null | UTF-8 | C++ | false | false | 30,161 | cc | /*
* Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
*/
#include "igmp_common_test.h"
TEST_F(IgmpTest, SendV1Reports) {
bool ret = false;
uint32_t local_g_add_count = 0;
uint32_t local_g_del_count = 0;
uint32_t report_count = 0;
TestEnvInit(UT_IGMP_VERSION_1, true);
IgmpGlobalEnable(true);
uint32_t idx = 0;
for (idx = 0; idx < sizeof(input)/sizeof(PortInfo); idx++) {
IgmpVmiEnable(idx, true);
}
IgmpRxCountReset();
while (IgmpRxCountGet() < 7) {
usleep(10);
}
EXPECT_EQ(IgmpRxCountGet(), 7);
idx = 0;
local_g_add_count++;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV1Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V1_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForGCount(true, local_g_add_count);
EXPECT_EQ(ret, true);
usleep(10*USECS_PER_SEC);
local_g_del_count++;
ret = WaitForGCount(false, local_g_del_count);
IgmpRxCountReset();
while (IgmpRxCountGet() < 7) {
usleep(10);
}
EXPECT_EQ(IgmpRxCountGet(), 7);
for (idx = 0; idx < sizeof(input)/sizeof(PortInfo); idx++) {
IgmpVmiEnable(idx, false);
}
IgmpGlobalClear();
TestEnvDeinit();
}
TEST_F(IgmpTest, SendV2Reports) {
bool ret = false;
boost::system::error_code ec;
uint32_t local_g_add_count = 0;
uint32_t local_g_del_count = 0;
uint32_t report_count = 0;
uint32_t leave_count = 0;
TestEnvInit(UT_IGMP_VERSION_2, true);
VmInterface *vmi_0 = VmInterfaceGet(input[0].intf_id);
std::string vrf_name = vmi_0->vrf()->GetName();
IgmpGlobalEnable(true);
uint32_t idx = 0;
for (idx = 0; idx < sizeof(input)/sizeof(PortInfo); idx++) {
IgmpVmiEnable(idx, true);
}
IgmpRxCountReset();
while (IgmpRxCountGet() < 7) {
usleep(10);
}
EXPECT_EQ(IgmpRxCountGet(), 7);
idx = 0;
local_g_add_count++;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV2Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V2_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForGCount(true, local_g_add_count);
EXPECT_EQ(ret, true);
idx = 1;
local_g_add_count++;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV2Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V2_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForGCount(true, local_g_add_count);
EXPECT_EQ(ret, true);
usleep(5*USECS_PER_SEC);
const NextHop *nh;
const CompositeNH *cnh;
const ComponentNH *cnh1;
Ip4Address group = Ip4Address::from_string("239.1.1.10", ec);
Ip4Address source = Ip4Address::from_string("0.0.0.0", ec);
Agent *agent = Agent::GetInstance();
Inet4MulticastRouteEntry *mc_route = MCRouteGet(agent->local_peer(),
vrf_name, group, source);
EXPECT_EQ((mc_route != NULL), true);
AgentPath *path = mc_route->FindPath(agent->local_peer());
EXPECT_EQ((path != NULL), true);
nh = MCRouteToNextHop(agent->local_vm_peer(), vrf_name, group, source);
cnh = dynamic_cast<const CompositeNH *>(nh);
EXPECT_EQ(1, cnh->ActiveComponentNHCount());
cnh1 = cnh->Get(0);
nh = cnh1->nh();
cnh = dynamic_cast<const CompositeNH *>(nh);
EXPECT_EQ(2, cnh->ActiveComponentNHCount());
idx = 0;
local_g_del_count++;
leave_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV2Leave, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_GROUP_LEAVE, leave_count);
EXPECT_EQ(ret, true);
ret = WaitForGCount(false, local_g_del_count);
EXPECT_EQ(ret, true);
idx = 1;
local_g_del_count++;
leave_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV2Leave, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_GROUP_LEAVE, leave_count);
EXPECT_EQ(ret, true);
ret = WaitForGCount(false, local_g_del_count);
EXPECT_EQ(ret, true);
usleep(5*USECS_PER_SEC);
nh = MCRouteToNextHop(agent->local_vm_peer(), vrf_name, group, source);
EXPECT_EQ((nh == NULL), true);
IgmpRxCountReset();
while (IgmpRxCountGet() < 7) {
usleep(10);
}
EXPECT_EQ(IgmpRxCountGet(), 7);
for (idx = 0; idx < sizeof(input)/sizeof(PortInfo); idx++) {
IgmpVmiEnable(idx, false);
}
IgmpGlobalClear();
TestEnvDeinit();
}
TEST_F(IgmpTest, SendV2ReportsWithoutLeave) {
bool ret = false;
uint32_t local_g_add_count = 0;
uint32_t local_g_del_count = 0;
uint32_t report_count = 0;
TestEnvInit(UT_IGMP_VERSION_2, true);
IgmpGlobalEnable(true);
uint32_t idx = 0;
for (idx = 0; idx < sizeof(input)/sizeof(PortInfo); idx++) {
IgmpVmiEnable(idx, true);
}
IgmpRxCountReset();
while (IgmpRxCountGet() < 7) {
usleep(10);
}
EXPECT_EQ(IgmpRxCountGet(), 7);
idx = 0;
local_g_add_count++;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV2Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V2_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForGCount(true, local_g_add_count);
EXPECT_EQ(ret, true);
usleep(10*USECS_PER_SEC);
local_g_del_count++;
ret = WaitForGCount(false, local_g_del_count);
IgmpRxCountReset();
while (IgmpRxCountGet() < 7) {
usleep(10);
}
EXPECT_EQ(IgmpRxCountGet(), 7);
for (idx = 0; idx < sizeof(input)/sizeof(PortInfo); idx++) {
IgmpVmiEnable(idx, false);
}
IgmpGlobalClear();
TestEnvDeinit();
}
TEST_F(IgmpTest, SendV3Reports) {
bool ret = false;
boost::system::error_code ec;
uint32_t idx = 0;
uint32_t local_sg_add_count = 0;
uint32_t local_sg_del_count = 0;
uint32_t report_count = 0;
TestEnvInit(UT_IGMP_VERSION_3, true);
VmInterface *vmi_0 = VmInterfaceGet(input[0].intf_id);
std::string vrf_name = vmi_0->vrf()->GetName();
IgmpGlobalEnable(true);
for (idx = 0; idx < sizeof(input)/sizeof(PortInfo); idx++) {
IgmpVmiEnable(idx, true);
}
idx = 1;
igmp_gs[0].record_type = 3;
igmp_gs[0].source_count = 0;
local_sg_add_count += 0;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
idx = 0;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
local_sg_add_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
idx = 2;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
local_sg_add_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
idx = 3;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
local_sg_add_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
idx = 4;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
local_sg_add_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
idx = 5;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
igmp_gs[1].record_type = 1;
igmp_gs[1].source_count = 4;
local_sg_add_count += igmp_gs[0].source_count;
local_sg_add_count += igmp_gs[1].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 2);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
idx = 6;
igmp_gs[2].record_type = 1;
igmp_gs[2].source_count = 5;
local_sg_add_count += igmp_gs[2].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, &igmp_gs[2], 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
const NextHop *nh;
const CompositeNH *cnh;
const ComponentNH *cnh1;
Ip4Address group = Ip4Address::from_string("239.1.1.10", ec);
Ip4Address source = Ip4Address::from_string("100.1.1.10", ec);
Agent *agent = Agent::GetInstance();
nh = MCRouteToNextHop(agent->local_vm_peer(), vrf_name, group, source);
cnh = dynamic_cast<const CompositeNH *>(nh);
EXPECT_EQ(1, cnh->ActiveComponentNHCount());
cnh1 = cnh->Get(0);
nh = cnh1->nh();
cnh = dynamic_cast<const CompositeNH *>(nh);
EXPECT_EQ(5, cnh->ActiveComponentNHCount());
idx = 0;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
local_sg_del_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(false, local_sg_del_count);
EXPECT_EQ(ret, true);
idx = 1;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 4;
local_sg_del_count += 0;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(false, local_sg_del_count);
EXPECT_EQ(ret, true);
idx = 2;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
local_sg_del_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(false, local_sg_del_count);
EXPECT_EQ(ret, true);
idx = 3;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
local_sg_del_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(false, local_sg_del_count);
EXPECT_EQ(ret, true);
idx = 4;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
local_sg_del_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(false, local_sg_del_count);
EXPECT_EQ(ret, true);
idx = 5;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
igmp_gs[1].record_type = 6;
igmp_gs[1].source_count = 4;
local_sg_del_count += igmp_gs[0].source_count + igmp_gs[1].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 2);
ret = WaitForRxOkCount(idx, IgmpTypeV3Report, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(false, local_sg_del_count);
EXPECT_EQ(ret, true);
idx = 6;
igmp_gs[2].record_type = 6;
igmp_gs[2].source_count = 5;
local_sg_del_count += igmp_gs[2].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, &igmp_gs[2], 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(false, local_sg_del_count);
EXPECT_EQ(ret, true);
nh = MCRouteToNextHop(agent->local_vm_peer(), vrf_name, group, source);
EXPECT_EQ((nh == NULL), true);
usleep(lmqt);
IgmpGlobalClear();
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, IgmpIntfConfig) {
bool ret = false;
boost::system::error_code ec;
VmInterface *vm_itf = NULL;
uint32_t local_sg_add_count = 0;
uint32_t local_sg_del_count = 0;
uint32_t report_count = 0;
uint32_t rej_count = 0;
uint32_t idx = 0;
const NextHop *nh;
const CompositeNH *cnh;
const ComponentNH *cnh1;
Agent *agent = Agent::GetInstance();
TestEnvInit(UT_IGMP_VERSION_3, true);
VmInterface *vmi_0 = VmInterfaceGet(input[0].intf_id);
std::string vrf_name = vmi_0->vrf()->GetName();
for (idx = 0; idx < sizeof(input)/sizeof(PortInfo); idx++) {
IgmpVmiEnable(idx, true);
}
idx = 0;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
local_sg_add_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
idx = 1;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
local_sg_add_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
Ip4Address group = Ip4Address::from_string("239.1.1.10", ec);
Ip4Address source = Ip4Address::from_string("100.1.1.10", ec);
nh = MCRouteToNextHop(agent->local_vm_peer(), vrf_name, group, source);
cnh = dynamic_cast<const CompositeNH *>(nh);
EXPECT_EQ(1, cnh->ActiveComponentNHCount());
cnh1 = cnh->Get(0);
nh = cnh1->nh();
cnh = dynamic_cast<const CompositeNH *>(nh);
EXPECT_EQ(2, cnh->ActiveComponentNHCount());
idx = 0;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
local_sg_del_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(false, local_sg_del_count);
EXPECT_EQ(ret, true);
idx = 1;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
local_sg_del_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(false, local_sg_del_count);
EXPECT_EQ(ret, true);
// Disable IGMP on idx = 0
idx = 0;
IgmpVmiEnable(idx, false);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
rej_count = 0;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
rej_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRejPktCount(rej_count);
EXPECT_EQ(ret, true);
idx = 6;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
report_count++;
local_sg_add_count += igmp_gs[0].source_count;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
nh = MCRouteToNextHop(agent->local_vm_peer(), vrf_name, group, source);
cnh = dynamic_cast<const CompositeNH *>(nh);
EXPECT_EQ(1, cnh->ActiveComponentNHCount());
cnh1 = cnh->Get(0);
nh = cnh1->nh();
cnh = dynamic_cast<const CompositeNH *>(nh);
EXPECT_EQ(1, cnh->ActiveComponentNHCount());
idx = 6;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
local_sg_del_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(false, local_sg_del_count);
EXPECT_EQ(ret, true);
// Enable IGMP on idx = 0
idx = 0;
IgmpVmiEnable(idx, true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
idx = 0;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
local_sg_add_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_add_count);
EXPECT_EQ(ret, true);
nh = MCRouteToNextHop(agent->local_vm_peer(), vrf_name, group, source);
cnh = dynamic_cast<const CompositeNH *>(nh);
EXPECT_EQ(1, cnh->ActiveComponentNHCount());
cnh1 = cnh->Get(0);
nh = cnh1->nh();
cnh = dynamic_cast<const CompositeNH *>(nh);
EXPECT_EQ(1, cnh->ActiveComponentNHCount());
idx = 0;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
local_sg_del_count += igmp_gs[0].source_count;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
ret = WaitForSgCount(true, local_sg_del_count);
EXPECT_EQ(ret, true);
usleep(lmqt);
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, IgmpVnEnable) {
bool ret = false;
uint32_t report_count = 0;
uint32_t idx = 0;
TestEnvInit(UT_IGMP_VERSION_3, true);
IgmpVnEnable("vn1", 1, true);
idx = 0;
VmInterface *vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
idx = 0;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
idx = 0;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
usleep(lmqt);
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, IgmpVnDisable) {
bool ret = false;
uint32_t idx = 0;
uint32_t rej_count = 0;
TestEnvInit(UT_IGMP_VERSION_3, true);
IgmpVnEnable("vn1", 1, false);
idx = 0;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
rej_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRejPktCount(rej_count);
EXPECT_EQ(ret, true);
idx = 0;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
rej_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRejPktCount(rej_count);
EXPECT_EQ(ret, true);
usleep(lmqt);
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, IgmpSystemEnable) {
bool ret = false;
uint32_t report_count = 0;
uint32_t idx = 0;
TestEnvInit(UT_IGMP_VERSION_3, true);
IgmpGlobalEnable(true);
idx = 0;
VmInterface *vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
idx = 0;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
idx = 0;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
usleep(lmqt);
IgmpGlobalClear();
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, IgmpSystemDisable) {
bool ret = false;
uint32_t idx = 0;
uint32_t rej_count = 0;
TestEnvInit(UT_IGMP_VERSION_3, true);
IgmpGlobalEnable(false);
idx = 0;
igmp_gs[0].record_type = 1;
igmp_gs[0].source_count = 3;
rej_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRejPktCount(rej_count);
EXPECT_EQ(ret, true);
idx = 0;
igmp_gs[0].record_type = 6;
igmp_gs[0].source_count = 3;
rej_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, igmp_gs, 1);
ret = WaitForRejPktCount(rej_count);
EXPECT_EQ(ret, true);
usleep(lmqt);
IgmpGlobalClear();
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, IgmpMode_1) {
VmInterface *vm_itf = NULL;
uint32_t idx = 0;
TestEnvInit(UT_IGMP_VERSION_3, true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpGlobalEnable(false);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpGlobalEnable(true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
IgmpVnEnable("vn1", 1, false);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpVnEnable("vn1", 1, true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
IgmpGlobalEnable(false);
IgmpVnEnable("vn1", 1, true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
IgmpGlobalEnable(true);
IgmpVnEnable("vn1", 1, false);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpGlobalEnable(true);
IgmpVnEnable("vn1", 1, true);
IgmpVmiEnable(idx, false);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpGlobalEnable(false);
IgmpVnEnable("vn1", 1, false);
IgmpVmiEnable(idx, true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
IgmpGlobalClear();
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, IgmpMode_2) {
VmInterface *vm_itf = NULL;
uint32_t idx = 0;
TestEnvInit(UT_IGMP_VERSION_3, true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpGlobalEnable(false);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpGlobalEnable(true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
IgmpVmiEnable(idx, false);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpGlobalEnable(false);
IgmpVmiEnable(idx, true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
IgmpGlobalClear();
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, IgmpMode_3) {
VmInterface *vm_itf = NULL;
uint32_t idx = 0;
TestEnvInit(UT_IGMP_VERSION_3, true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpVnEnable("vn1", 1, false);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpVnEnable("vn1", 1, true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
IgmpVmiEnable(idx, false);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), false);
IgmpVnEnable("vn1", 1, false);
IgmpVmiEnable(idx, true);
vm_itf = VmInterfaceGet(input[idx].intf_id);
EXPECT_EQ(vm_itf->igmp_enabled(), true);
IgmpGlobalClear();
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, IgmpQuerySend) {
bool ret = false;
TestEnvInit(UT_IGMP_VERSION_3, true);
IgmpGlobalEnable(true);
uint32_t idx = 0;
for (idx = 0; idx < sizeof(input)/sizeof(PortInfo); idx++) {
IgmpVmiEnable(idx, true);
}
Agent::GetInstance()->GetIgmpProto()->ClearStats();
Agent::GetInstance()->GetIgmpProto()->GetGmpProto()->ClearStats();
client->WaitForIdle();
uint32_t sleep = 1;
uint32_t vms = sizeof(input)/sizeof(struct PortInfo);
usleep((sleep * qivl * MSECS_PER_SEC) + 3000000);
client->WaitForIdle();
idx = 0;
// 7 VMs and 2 queries in 10 secs
ret = WaitForTxCount(idx, true, vms*(sleep+1));
EXPECT_EQ(ret, true);
usleep(lmqt);
IgmpGlobalClear();
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, IgmpQueryDisabled) {
bool ret = false;
TestEnvInit(UT_IGMP_VERSION_3, true);
IgmpGlobalEnable(false);
uint32_t idx = 0;
for (idx = 0; idx < sizeof(input)/sizeof(PortInfo); idx++) {
IgmpVmiEnable(idx, false);
}
Agent::GetInstance()->GetIgmpProto()->ClearStats();
Agent::GetInstance()->GetIgmpProto()->GetGmpProto()->ClearStats();
client->WaitForIdle();
uint32_t sleep = 1;
uint32_t vms = sizeof(input)/sizeof(struct PortInfo);
usleep((sleep * qivl * MSECS_PER_SEC) + 3000000);
client->WaitForIdle();
idx = 0;
// 7 VMs and 2 queries in 10 secs
ret = WaitForTxCount(idx, false, vms*(sleep+1));
EXPECT_EQ(ret, true);
usleep(lmqt);
IgmpGlobalClear();
TestEnvDeinit();
client->WaitForIdle();
return;
}
TEST_F(IgmpTest, DISABLED_IgmpTaskTrigger) {
bool ret = false;
uint32_t idx = 0;
struct IgmpGroupSource igmp_gs;
TestEnvInit(UT_IGMP_VERSION_3, true);
IgmpGlobalEnable(true);
Agent *agent = Agent::GetInstance();
IgmpProto *igmp_proto = agent->GetIgmpProto();
GmpProto *gmp_proto = igmp_proto->GetGmpProto();
GmpProto::GmpStats stats;
uint32_t report_count = 0;
uint32_t loop = 10;
uint32_t pkt_per_loop = 50;
uint32_t source_count = 2;
uint32_t ex_count = loop*pkt_per_loop*source_count;
uint32_t count = 0;
igmp_proto->ClearStats();
gmp_proto->ClearStats();
client->WaitForIdle();
uint32_t group = inet_addr("239.1.1.10");
uint32_t source = inet_addr("100.1.1.10");
memset(&igmp_gs, 0x00, sizeof(igmp_gs));
igmp_gs.record_type = 1;
igmp_gs.source_count = source_count;
igmp_gs.group = ntohl(group);
for (uint32_t i = 0; i < loop; i++) {
for (uint32_t j = 0; j < pkt_per_loop; j++) {
igmp_gs.sources[0] = ntohl(source);
igmp_gs.sources[1] = ntohl(source+1);
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, &igmp_gs, 1);
source += igmp_gs.source_count;
usleep(1000);
}
usleep(10000);
}
client->WaitForIdle();
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
count = 0;
do {
usleep(1000);
client->WaitForIdle();
stats = gmp_proto->GetStats();
if (++count == 10000) {
break;
}
} while (stats.gmp_sg_add_count_ != ex_count);
uint32_t actual_count = stats.gmp_sg_add_count_;
EXPECT_EQ(actual_count, ex_count);
group = inet_addr("239.1.1.10");
source = inet_addr("100.1.1.10");
igmp_gs.record_type = 6;
igmp_gs.source_count = source_count;
igmp_gs.group = ntohl(group);
for (uint32_t i = 0; i < loop; i++) {
for (uint32_t j = 0; j < pkt_per_loop; j++) {
igmp_gs.sources[0] = ntohl(source);
igmp_gs.sources[1] = ntohl(source+1);
report_count++;
SendIgmp(GetItfId(idx), input[idx].addr, IgmpTypeV3Report, &igmp_gs, 1);
source += igmp_gs.source_count;
usleep(1000);
}
usleep(10000);
}
client->WaitForIdle();
ret = WaitForRxOkCount(idx, IGMP_V3_MEMBERSHIP_REPORT, report_count);
EXPECT_EQ(ret, true);
count = 0;
do {
usleep(1000);
client->WaitForIdle();
stats = gmp_proto->GetStats();
if (++count == 10000) {
break;
}
} while (stats.gmp_sg_del_count_ != ex_count);
actual_count = stats.gmp_sg_del_count_;
EXPECT_EQ(actual_count, ex_count);
IgmpGlobalClear();
TestEnvDeinit();
client->WaitForIdle();
return;
}
int main(int argc, char *argv[]) {
GETUSERARGS();
client = TestInit(DEFAULT_VNSW_CONFIG_FILE, ksync_init, true, true);
client->WaitForIdle();
StartControlNodeMock();
Agent *agent = Agent::GetInstance();
RouterIdDepInit(agent);
// Disable MVPN mode for normal IGMP testing.
agent->params()->set_mvpn_ipv4_enable(false);
int ret = RUN_ALL_TESTS();
client->WaitForIdle();
StopControlNodeMock();
TestShutdown();
delete client;
return ret;
}
| [
"esnagendra@juniper.net"
] | esnagendra@juniper.net |
64802e7930816fe396e36bd483817945a327bd8d | db9b2d47d41745d52133d14c96633f3109428820 | /Sparky-core/src/sp/graphics/shaders/ShaderManager.h | 387d65c4faf908a07dc0ec31b6691d5ba46a1a59 | [
"LicenseRef-scancode-unknown-license-reference"
] | permissive | bigkitttty/Sparky | 99ffefd26b15b5476b163edf177d45dfd9f7d169 | 79fcf089b9f1c2f4bfbea6f1938767556bb6dd13 | refs/heads/master | 2021-09-22T10:38:22.182092 | 2021-09-11T03:33:57 | 2021-09-11T03:33:57 | 71,099,127 | 0 | 0 | Apache-2.0 | 2021-09-11T03:33:57 | 2016-10-17T04:09:20 | C++ | UTF-8 | C++ | false | false | 475 | h | #pragma once
#include "sp/sp.h"
#include "sp/Common.h"
#include "sp/Types.h"
#include "Shader.h"
namespace sp { namespace graphics {
class SP_API ShaderManager
{
private:
static std::vector<API::Shader*> s_Shaders;
public:
static void Add(API::Shader* shader);
static API::Shader* Get(const String& name);
static void Clean();
static void Reload(const String& name);
static void Reload(const API::Shader* shader);
private:
ShaderManager() { }
};
} } | [
"cherno21@hotmail.com"
] | cherno21@hotmail.com |
1638c3ca51022f6c172458e68e49d4d6b8733307 | e79e5a096d2afac0ee02deb2734d006dae9e4cbb | /Gears/Src/RenderCore/IRenderEntity.h | 285a20008ba5a3a39fb9481a35ee2ca836226074 | [
"MIT"
] | permissive | pkm158/Gears | ee003c32dc7699139acbea8e2cb160cc609928d3 | 9ea5d835bf9bcbc3905e544bcb6c36816caca553 | refs/heads/master | 2021-05-16T03:02:47.212967 | 2016-11-19T22:38:49 | 2016-11-19T22:38:49 | 40,279,097 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,802 | h | /************************************************************************/
/* Author: Kemi Peng
History: 08/03/2015 by Kemi Peng*/
/************************************************************************/
#ifndef IRENDERENTITY
#define IRENDERENTITY
#include "GearsCommonHead.h"
#include "RenderCommonHead.h"
#include "GutModel.h"
class IRenderEntity {
public:
IRenderEntity(void);
IRenderEntity(bool hasShadow, bool canBeShadowed);
virtual ~IRenderEntity(void);
virtual bool loadFromFile(const char *file);
virtual bool loadExternTexture(int channel, const char *file);
virtual void render(void) = NULL;
virtual void scale(float x, float y, float z) = NULL;
virtual void scale(float uni) = NULL;
virtual void move(float x, float y, float z) = NULL;
virtual void rotateX(const float rads) = NULL;
virtual void rotateY(const float rads) = NULL;
virtual void rotateZ(const float rads) = NULL;
virtual const CMatrix& getWorldMat(void) = NULL;
virtual int getDiffuseMapNum(void) const { return m_diffuseMapNum; };
virtual float getDiffuseMapScale(int idx) const { HR(idx < m_diffuseMapNum); return m_diffuseMapScale[idx]; };
/************************************************************************/
/* hasShadow: if false does not have shadow
canBeShadowed: if false does not draw shadow on it
isLight: if true, will be effect by shininess bloom effect
canBeLighted if false, light won't effect this object, it is self-luminous
diffuseMapNum how many diffuse map it has*/
/************************************************************************/
bool hasShadow;
bool canBeShadowed;
bool isLight;
bool canBeLighted;
bool hasSpecMap;
bool hasNormalMap;
bool hasEmissionMap;
protected:
CGutModel m_model;
int m_diffuseMapNum;
float *m_diffuseMapScale;
};
#endif | [
"pengsoftware@gmail.com"
] | pengsoftware@gmail.com |
60dcd073494fe885b0472933b7c70da770700b89 | 4506fff2306dcab2562b6a718141bb5c50f8e704 | /testing/tests/test_bb.cpp | 8089a201eb98e03d5dc9f03c3b0e702af545f1a8 | [
"MIT"
] | permissive | theo77186/ToppleChess | 327a4b1d73bf810231f95c7ceb22803f3d0c5328 | d47fe338ad21eb84a96faa1f2db066582d1bba0c | refs/heads/master | 2020-04-26T20:10:01.466769 | 2019-03-01T16:30:40 | 2019-03-01T16:30:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 32,250 | cpp | //
// Created by Vincent on 27/09/2017.
//
#include "../catch.hpp"
#include "../util.h"
TEST_CASE("Bitboard engine") {
SECTION("Table initialisation") {
REQUIRE_NOTHROW(init_tables());
}
SECTION("General operations") {
SECTION("Single bit") {
REQUIRE(single_bit(E4) == U64(1) << E4);
REQUIRE(single_bit(A1) == U64(1) << A1);
REQUIRE(single_bit(H8) == U64(1) << H8);
REQUIRE(single_bit(A8) == U64(1) << A8);
REQUIRE(single_bit(H1) == U64(1) << H1);
REQUIRE(single_bit(G2) == U64(1) << G2);
}
SECTION("popLSB") {
U64 bb = c_u64({0, 0, 0, 0, 0, 0, 1, 0,
0, 1, 0, 1, 0, 0, 0, 1,
0, 0, 0, 0, 0, 1, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1, 1, 1, 0, 0, 0});
REQUIRE(pop_bit(bb) == C1);
REQUIRE(pop_bit(bb) == D1);
REQUIRE(pop_bit(bb) == E1);
REQUIRE(pop_bit(bb) == F2);
REQUIRE(pop_bit(bb) == F4);
REQUIRE(pop_bit(bb) == A5);
REQUIRE(pop_bit(bb) == F6);
REQUIRE(pop_bit(bb) == B7);
REQUIRE(pop_bit(bb) == D7);
REQUIRE(pop_bit(bb) == H7);
REQUIRE(pop_bit(bb) == G8);
REQUIRE(bb == 0);
}
/*
SECTION("popMSB") {
U64 bb = c_u64({0, 0, 0, 0, 0, 0, 1, 0,
0, 1, 0, 1, 0, 0, 0, 1,
0, 0, 0, 0, 0, 1, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1, 1, 1, 0, 0, 0});
REQUIRE(pop_bit(BLACK, bb) == G8);
REQUIRE(pop_bit(BLACK, bb) == H7);
REQUIRE(pop_bit(BLACK, bb) == D7);
REQUIRE(pop_bit(BLACK, bb) == B7);
REQUIRE(pop_bit(BLACK, bb) == F6);
REQUIRE(pop_bit(BLACK, bb) == A5);
REQUIRE(pop_bit(BLACK, bb) == F4);
REQUIRE(pop_bit(BLACK, bb) == F2);
REQUIRE(pop_bit(BLACK, bb) == E1);
REQUIRE(pop_bit(BLACK, bb) == D1);
REQUIRE(pop_bit(BLACK, bb) == C1);
REQUIRE(bb == 0);
}
*/
SECTION("Square index lookup") {
REQUIRE(square_index(0, 0) == A1);
REQUIRE(square_index(2, 2) == C3);
REQUIRE(square_index(7, 7) == H8);
REQUIRE(square_index(3, 2) == D3);
REQUIRE(square_index(4, 6) == E7);
}
SECTION("String conversion") {
SECTION("From string") {
REQUIRE(to_sq('e', '4') == E4);
REQUIRE(to_sq('f', '8') == F8);
REQUIRE(to_sq('a', '1') == A1);
REQUIRE(to_sq('g', '2') == G2);
REQUIRE(to_sq('h', '8') == H8);
REQUIRE_THROWS(to_sq('!', 'k'));
REQUIRE_THROWS(to_sq('i', '4'));
REQUIRE_THROWS(to_sq('b', '0'));
REQUIRE_THROWS(to_sq('c', '9'));
}
SECTION("To string") {
REQUIRE(from_sq(A4) == "a4");
REQUIRE(from_sq(B8) == "b8");
REQUIRE(from_sq(C5) == "c5");
REQUIRE(from_sq(H8) == "h8");
REQUIRE(from_sq(D4) == "d4");
}
}
SECTION("Alignment") {
REQUIRE(aligned(A1, B2));
REQUIRE(aligned(A1, B1));
REQUIRE(aligned(A1, A2));
REQUIRE(!aligned(E4, B5));
REQUIRE(aligned(B2, G7));
REQUIRE(!aligned(A1, C2));
REQUIRE(aligned(A1, B2, F6));
REQUIRE(aligned(A1, D1, G1));
REQUIRE(aligned(B2, B6, B4));
REQUIRE(!aligned(E4, B5));
REQUIRE(!aligned(B2, D5, G7));
REQUIRE(!aligned(A1, C2));
}
SECTION("Population count") {
REQUIRE(pop_count(0b0001100100100011000100100111000000000000000000010000000000000000) == 12);
REQUIRE(pop_count(0b0000000000000000000000000000000000000000000000000000000000000000) == 0);
REQUIRE(pop_count(0b1111111111111111111111111111111111111111111111111111111111111111) == 64);
REQUIRE(pop_count(0b1000100111100011111100110111000000000110001000011111000000010010) == 27);
}
}
SECTION("Bitboard move generation") {
Square square;
U64 expected;
SECTION("King") {
square = E5;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0,
0, 0, 0, 1, 0, 1, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KING>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KING>(WHITE, square, 0) == expected);
square = A1;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KING>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KING>(WHITE, square, 0) == expected);
square = H8;
expected = c_u64({0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KING>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KING>(WHITE, square, 0) == expected);
square = D8;
expected = c_u64({0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KING>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KING>(WHITE, square, 0) == expected);
square = E1;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0,
0, 0, 0, 1, 0, 1, 0, 0});
REQUIRE(find_moves<KING>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KING>(WHITE, square, 0) == expected);
square = H3;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KING>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KING>(WHITE, square, 0) == expected);
square = A7;
expected = c_u64({1, 1, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KING>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KING>(WHITE, square, 0) == expected);
}
SECTION("Knight") {
square = E5;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 1, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 0, 1, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KNIGHT>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KNIGHT>(WHITE, square, 0) == expected);
square = A1;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KNIGHT>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KNIGHT>(WHITE, square, 0) == expected);
square = H8;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KNIGHT>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KNIGHT>(WHITE, square, 0) == expected);
square = G4;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KNIGHT>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KNIGHT>(WHITE, square, 0) == expected);
square = E1;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 1, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KNIGHT>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KNIGHT>(WHITE, square, 0) == expected);
square = H3;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0});
REQUIRE(find_moves<KNIGHT>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KNIGHT>(WHITE, square, 0) == expected);
square = A7;
expected = c_u64({0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<KNIGHT>(BLACK, square, 0) == expected);
REQUIRE(find_moves<KNIGHT>(WHITE, square, 0) == expected);
}
SECTION("Pawn") {
U64 occupied;
SECTION("Normal moves") {
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0}); // C4
REQUIRE(find_moves<PAWN>(BLACK, C5, 0) == expected);
REQUIRE(find_moves<PAWN>(WHITE, C3, 0) == expected);
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0}); // D5
REQUIRE(find_moves<PAWN>(BLACK, D6, 0) == expected);
REQUIRE(find_moves<PAWN>(WHITE, D4, 0) == expected);
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0}); // C4
REQUIRE(find_moves<PAWN>(WHITE, A5, 0) == expected);
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0}); // C4
REQUIRE(find_moves<PAWN>(BLACK, G3, 0) == expected);
}
SECTION("Double moves") {
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(BLACK, G2, 0) != expected);
REQUIRE(find_moves<PAWN>(WHITE, G2, 0) == expected);
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(BLACK, C7, 0) == expected);
REQUIRE(find_moves<PAWN>(WHITE, C7, 0) != expected);
}
SECTION("Square in front occupied") {
occupied = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(WHITE, B4, occupied) == expected);
REQUIRE(find_moves<PAWN>(BLACK, B6, occupied) == expected);
REQUIRE(find_moves<PAWN>(WHITE, D6, occupied) == expected);
REQUIRE(find_moves<PAWN>(BLACK, E6, occupied) == expected);
REQUIRE(find_moves<PAWN>(WHITE, E4, occupied) == expected);
REQUIRE(find_moves<PAWN>(BLACK, F7, occupied) == expected);
REQUIRE(find_moves<PAWN>(WHITE, F5, occupied) == expected);
REQUIRE(find_moves<PAWN>(BLACK, F4, occupied) == expected);
REQUIRE(find_moves<PAWN>(WHITE, F2, occupied) == expected);
REQUIRE(find_moves<PAWN>(BLACK, H6, occupied) == expected);
REQUIRE(find_moves<PAWN>(WHITE, H4, occupied) == expected);
// Blocking the second square of the double move
occupied = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(BLACK, E7, occupied) == expected);
// Blocking the second square of the double move
occupied = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1,
0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(WHITE, B2, occupied) == expected);
}
SECTION("Normal moves with captures") {
occupied = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 1, 1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(BLACK, D6, occupied) == expected);
REQUIRE(find_moves<PAWN>(WHITE, D4, occupied) == expected);
occupied = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 1, 0, 0, 1, 0,
0, 0, 0, 0, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(BLACK, H6, occupied) == expected);
REQUIRE(find_moves<PAWN>(WHITE, H4, occupied) == expected);
}
SECTION("Mixed situations") {
occupied = c_u64({0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 1, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 1, 1,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
1, 1, 1, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0});
square = B7;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(BLACK, square, occupied) == expected);
square = D7;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(BLACK, square, occupied) == expected);
square = E3;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(WHITE, square, occupied) == expected);
square = G4;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<PAWN>(WHITE, square, occupied) == expected);
}
}
SECTION("Bishop") {
U64 occupied = c_u64({0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 1, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 1, 1,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
1, 1, 1, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0});
square = E4;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 0, 1, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 1, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<BISHOP>(WHITE, square, occupied) == expected);
REQUIRE(find_moves<BISHOP>(BLACK, square, occupied) == expected);
square = C1;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0,
0, 1, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<BISHOP>(WHITE, square, occupied) == expected);
REQUIRE(find_moves<BISHOP>(BLACK, square, occupied) == expected);
square = D3;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 1, 0,
0, 1, 0, 0, 0, 1, 0, 0,
0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0});
REQUIRE(find_moves<BISHOP>(WHITE, square, occupied) == expected);
REQUIRE(find_moves<BISHOP>(BLACK, square, occupied) == expected);
square = D8;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<BISHOP>(WHITE, square, occupied) == expected);
REQUIRE(find_moves<BISHOP>(BLACK, square, occupied) == expected);
}
SECTION("Rook") {
U64 occupied = c_u64({0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 1, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
1, 1, 1, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0});
square = E4;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0,
1, 1, 1, 1, 0, 1, 1, 1,
0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0});
REQUIRE(find_moves<ROOK>(WHITE, square, occupied) == expected);
REQUIRE(find_moves<ROOK>(BLACK, square, occupied) == expected);
square = C1;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
1, 1, 0, 1, 1, 1, 1, 1});
REQUIRE(find_moves<ROOK>(WHITE, square, occupied) == expected);
REQUIRE(find_moves<ROOK>(BLACK, square, occupied) == expected);
square = D3;
expected = c_u64({0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
1, 1, 1, 0, 1, 1, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0});
REQUIRE(find_moves<ROOK>(WHITE, square, occupied) == expected);
REQUIRE(find_moves<ROOK>(BLACK, square, occupied) == expected);
square = D8;
expected = c_u64({1, 1, 1, 0, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0});
REQUIRE(find_moves<ROOK>(WHITE, square, occupied) == expected);
REQUIRE(find_moves<ROOK>(BLACK, square, occupied) == expected);
}
}
SECTION("Utility") {
REQUIRE(E4 + rel_offset(WHITE, D_N) == E5);
REQUIRE(E5 + rel_offset(BLACK, D_N) == E4);
REQUIRE(E4 + rel_offset(WHITE, D_NE) == F5);
REQUIRE(E4 + rel_offset(WHITE, D_NW) == D5);
REQUIRE(E5 + rel_offset(BLACK, D_NE) == D4);
REQUIRE(E5 + rel_offset(BLACK, D_NW) == F4);
}
} | [
"vincentyntang@gmail.com"
] | vincentyntang@gmail.com |
a922bbfd6ebdeed73a831d26da0df5b0b69c178e | ca0ae441ce7ee14864304835c0451f2e846bc1be | /arduino/vacuum_pump/footswitch.cpp | 520c93c67df9be93823eb1ca9c7ee8ded2b55bdc | [] | no_license | koendv/vacuum-pump-controller | b3e2e39b7b1fd3224ccb2de225968081a6a6e6eb | 9a36e9e55daa9d16c5b6e95e1c7156fa0ff26ebe | refs/heads/main | 2023-06-02T01:05:33.056614 | 2021-06-22T16:36:17 | 2021-06-22T16:36:17 | 370,748,042 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,770 | cpp | #include "footswitch.h"
#include "motor.h"
// footswitch connector contacts
#define PIN_FTSW_TIP PA3
#define PIN_FTSW_R1 PC15
#define PIN_FTSW_R2 PC14
namespace footswitch {
static uint32_t lastTimeMillis = 0;
const uint32_t sampleTimeMillis = 10;
enum state_enum { FTSW_INIT,
FTSW_ON,
FTSW_OFF };
state_enum ftsw_state;
void setup() {
pinMode(PIN_FTSW_TIP, INPUT_PULLUP);
pinMode(PIN_FTSW_R1, INPUT_PULLUP);
pinMode(PIN_FTSW_R2, INPUT_PULLUP);
ftsw_state = FTSW_INIT;
lastTimeMillis = millis();
return;
}
void loop() {
uint32_t nowMillis = millis();
if ((nowMillis < lastTimeMillis) || (nowMillis >= lastTimeMillis + sampleTimeMillis)) {
// footswitch pins. footswitch has two contacts.
// one contact is normally open, one contact is normally closed.
bool ftsw_no = digitalRead(PIN_FTSW_TIP); // footswitch contact normally open
bool ftsw_nc = digitalRead(PIN_FTSW_R1); // footswitch contact normally closed
// contact debouncing
bool ftsw_on = ftsw_no && !ftsw_nc;
bool ftsw_off = !ftsw_no && ftsw_nc;
switch (ftsw_state) {
case FTSW_INIT:
if (ftsw_off) {
Serial.println("footswitch");
motor::setswitch(2, false);
ftsw_state = FTSW_OFF;
}
break;
case FTSW_ON:
if (ftsw_off) {
// Serial.println("footswitch off");
motor::setswitch(2, false);
ftsw_state = FTSW_OFF;
}
break;
case FTSW_OFF:
if (ftsw_on) {
// Serial.println("footswitch on");
motor::setswitch(2, true);
ftsw_state = FTSW_ON;
}
break;
default:
ftsw_state = FTSW_INIT;
break;
}
lastTimeMillis = nowMillis;
}
}
} // namespace footswitch
// not truncated
| [
"kdv@kdvelectronics.eu"
] | kdv@kdvelectronics.eu |
b536fb60b7243661e6e9ce9e0c12c525d77f09c7 | f53891174b71e3b52497b3ab56b30ca7056ef1b7 | /src/elle/reactor/modules/cpp-netlib/uri/src/boost/smart_ptr/detail/lwm_pthreads.hpp | c31f263188d426c490c1daa6ed6ca94c362d7461 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | infinit/elle | 050e0a3825a585add8899cf8dd8e25b0531c67ce | 1a8f3df18500a9854a514cbaf9824784293ca17a | refs/heads/master | 2023-09-04T01:15:06.820585 | 2022-09-17T08:43:45 | 2022-09-17T08:43:45 | 51,672,792 | 533 | 51 | Apache-2.0 | 2023-05-22T21:35:50 | 2016-02-14T00:38:23 | C++ | UTF-8 | C++ | false | false | 1,769 | hpp | #ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/detail/lwm_pthreads.hpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/assert.hpp>
#include <pthread.h>
namespace network_boost
{
namespace detail
{
class lightweight_mutex
{
private:
pthread_mutex_t m_;
lightweight_mutex(lightweight_mutex const &);
lightweight_mutex & operator=(lightweight_mutex const &);
public:
lightweight_mutex()
{
// HPUX 10.20 / DCE has a nonstandard pthread_mutex_init
#if defined(__hpux) && defined(_DECTHREADS_)
BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 );
#else
BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 );
#endif
}
~lightweight_mutex()
{
BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 );
}
class scoped_lock;
friend class scoped_lock;
class scoped_lock
{
private:
pthread_mutex_t & m_;
scoped_lock(scoped_lock const &);
scoped_lock & operator=(scoped_lock const &);
public:
scoped_lock(lightweight_mutex & m): m_(m.m_)
{
BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
}
~scoped_lock()
{
BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
}
};
};
} // namespace detail
} // namespace network_boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED
| [
"glyn.matthews@gmail.com"
] | glyn.matthews@gmail.com |
fe95d89d297196b42e0a7536eeff95aeb4e88f13 | 625dab99ce8dd90ab9c5d5ccba63a60288d3c676 | /Code/ide/Xcode /L10Operator/L10Operator/main.cpp | 9d084e013f2708844a3ef393c1d55af65218ef4b | [] | no_license | charmingYT/charCPPLesson | f3b245902639f6f73f07133da101345de9f3b923 | d8dae68bc01a263b21b7c72a1547ba69094dcae6 | refs/heads/master | 2021-01-10T13:33:42.072353 | 2015-11-26T03:28:59 | 2015-11-26T03:28:59 | 46,846,439 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 917 | cpp | //
// main.cpp
// L10Operator
//
// Created by Mr.Beta on 15/11/26.
// Copyright © 2015年 sipsys. All rights reserved.
//
#include <iostream>
class Point {
private:
int x,y;
public:
Point(int x,int y){
this->x = x;
this->y = y;
}
int getX(){
return this->x;
}
int getY(){
return this->y;
}
void add(Point p){
add(p.getX(),p.getY());
}
void add(int x,int y){
this->x+=x;
this->y+=y;
}
void operator+=(Point p){
add(p);
}
};
int main(int argc, const char * argv[]) {
// Point p(10,10);
// p.add(Point(20, 20));
// p+=Point(13,13);
Point *p = new Point(5,5);
(*p)+=Point(2,2);
std::cout<<p->getY()<<"\n";
std::cout << "Hello, World!\n";
return 0;
}
| [
"charmingyt@126.com"
] | charmingyt@126.com |
454e73669ad97b88846b6923bc7a1f82f17aee30 | 0641d87fac176bab11c613e64050330246569e5c | /tags/cldr-25-d02/source/common/unicode/listformatter.h | 1e5a0d8f22c69bd45268b0ba3a76e17f9bf64564 | [
"ICU",
"NAIST-2003",
"LicenseRef-scancode-unicode",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | svn2github/libicu_full | ecf883cedfe024efa5aeda4c8527f227a9dbf100 | f1246dcb7fec5a23ebd6d36ff3515ff0395aeb29 | refs/heads/master | 2021-01-01T17:00:58.555108 | 2015-01-27T16:59:40 | 2015-01-27T16:59:40 | 9,308,333 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 4,795 | h | /*
*******************************************************************************
*
* Copyright (C) 2012-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: listformatter.h
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
*
* created on: 20120426
* created by: Umesh P. Nair
*/
#ifndef __LISTFORMATTER_H__
#define __LISTFORMATTER_H__
#include "unicode/utypes.h"
#ifndef U_HIDE_DRAFT_API
#include "unicode/unistr.h"
#include "unicode/locid.h"
U_NAMESPACE_BEGIN
/** @internal */
class Hashtable;
/** @internal */
struct ListFormatInternal;
/* The following can't be #ifndef U_HIDE_INTERNAL_API, needed for other .h file declarations */
/** @internal */
struct ListFormatData : public UMemory {
UnicodeString twoPattern;
UnicodeString startPattern;
UnicodeString middlePattern;
UnicodeString endPattern;
ListFormatData(const UnicodeString& two, const UnicodeString& start, const UnicodeString& middle, const UnicodeString& end) :
twoPattern(two), startPattern(start), middlePattern(middle), endPattern(end) {}
};
/**
* \file
* \brief C++ API: API for formatting a list.
*/
/**
* An immutable class for formatting a list, using data from CLDR (or supplied
* separately).
*
* Example: Input data ["Alice", "Bob", "Charlie", "Delta"] will be formatted
* as "Alice, Bob, Charlie and Delta" in English.
*
* The ListFormatter class is not intended for public subclassing.
* @draft ICU 50
*/
class U_COMMON_API ListFormatter : public UObject{
public:
/**
* Copy constructor.
* @draft ICU 52
*/
ListFormatter(const ListFormatter&);
/**
* Assignment operator.
* @draft ICU 52
*/
ListFormatter& operator=(const ListFormatter& other);
/**
* Creates a ListFormatter appropriate for the default locale.
*
* @param errorCode ICU error code, set if no data available for default locale.
* @return Pointer to a ListFormatter object for the default locale,
* created from internal data derived from CLDR data.
* @draft ICU 50
*/
static ListFormatter* createInstance(UErrorCode& errorCode);
/**
* Creates a ListFormatter appropriate for a locale.
*
* @param locale The locale.
* @param errorCode ICU error code, set if no data available for the given locale.
* @return A ListFormatter object created from internal data derived from
* CLDR data.
* @draft ICU 50
*/
static ListFormatter* createInstance(const Locale& locale, UErrorCode& errorCode);
#ifndef U_HIDE_INTERNAL_API
/**
* Creates a ListFormatter appropriate for a locale and style.
*
* @param locale The locale.
* @param style the style, either "standard", "duration", or "duration-short"
* @param errorCode ICU error code, set if no data available for the given locale.
* @return A ListFormatter object created from internal data derived from
* CLDR data.
* @internal
*/
static ListFormatter* createInstance(const Locale& locale, const char* style, UErrorCode& errorCode);
#endif /* U_HIDE_INTERNAL_API */
/**
* Destructor.
*
* @draft ICU 50
*/
virtual ~ListFormatter();
/**
* Formats a list of strings.
*
* @param items An array of strings to be combined and formatted.
* @param n_items Length of the array items.
* @param appendTo The string to which the result should be appended to.
* @param errorCode ICU error code, set if there is an error.
* @return Formatted string combining the elements of items, appended to appendTo.
* @draft ICU 50
*/
UnicodeString& format(const UnicodeString items[], int32_t n_items,
UnicodeString& appendTo, UErrorCode& errorCode) const;
#ifndef U_HIDE_INTERNAL_API
/**
@internal for MeasureFormat
*/
UnicodeString& format(
const UnicodeString items[],
int32_t n_items,
UnicodeString& appendTo,
int32_t index,
int32_t &offset,
UErrorCode& errorCode) const;
/**
* @internal constructor made public for testing.
*/
ListFormatter(const ListFormatData &data);
ListFormatter(const ListFormatInternal* listFormatterInternal);
#endif /* U_HIDE_INTERNAL_API */
private:
static void initializeHash(UErrorCode& errorCode);
static const ListFormatInternal* getListFormatInternal(const Locale& locale, const char *style, UErrorCode& errorCode);
ListFormatter();
ListFormatInternal* owned;
const ListFormatInternal* data;
};
U_NAMESPACE_END
#endif /* U_HIDE_DRAFT_API */
#endif
| [
"emmons@251d0590-4201-4cf1-90de-194747b24ca1"
] | emmons@251d0590-4201-4cf1-90de-194747b24ca1 |
0ee1ddcca1f700a4ad45441e65c821c8581a79d0 | aad6b08ee56c2760b207d562f16be0a5bb8e3e2a | /tags/Doduo1.1.2/BAL/WKAL/Concretizations/Graphics/WK/BCSVGResourceClipperWK.cpp | bc207ff67de951204e6ffdc17ba1618c325b87a0 | [] | no_license | Chengjian-Tang/owb-mirror | 5ffd127685d06f2c8e00832c63cd235bec63f753 | b48392a07a2f760bfc273d8d8b80e8d3f43b6b55 | refs/heads/master | 2021-05-27T02:09:03.654458 | 2010-06-23T11:10:12 | 2010-06-23T11:10:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,029 | cpp | /*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. 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 "config.h"
#if ENABLE(SVG)
#include "SVGResourceClipper.h"
#include "AffineTransform.h"
#include "GraphicsContext.h"
#include "SVGRenderTreeAsText.h"
#if PLATFORM(CG)
#include <ApplicationServices/ApplicationServices.h>
#endif
namespace WKAL {
SVGResourceClipper::SVGResourceClipper()
: SVGResource()
{
}
SVGResourceClipper::~SVGResourceClipper()
{
}
void SVGResourceClipper::resetClipData()
{
m_clipData.clear();
}
void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
{
if (m_clipData.clipData().isEmpty())
return;
bool heterogenousClipRules = false;
WindRule clipRule = m_clipData.clipData()[0].windRule;
context->beginPath();
for (unsigned x = 0; x < m_clipData.clipData().size(); x++) {
ClipData clipData = m_clipData.clipData()[x];
if (clipData.windRule != clipRule)
heterogenousClipRules = true;
Path clipPath = clipData.path;
if (clipData.bboxUnits) {
AffineTransform transform;
transform.translate(boundingBox.x(), boundingBox.y());
transform.scale(boundingBox.width(), boundingBox.height());
clipPath.transform(transform);
}
context->addPath(clipPath);
}
// FIXME!
// We don't currently allow for heterogenous clip rules.
// we would have to detect such, draw to a mask, and then clip
// to that mask
context->clipPath(clipRule);
}
void SVGResourceClipper::addClipData(const Path& path, WindRule rule, bool bboxUnits)
{
m_clipData.addPath(path, rule, bboxUnits);
}
const ClipDataList& SVGResourceClipper::clipData() const
{
return m_clipData;
}
TextStream& SVGResourceClipper::externalRepresentation(TextStream& ts) const
{
ts << "[type=CLIPPER]";
ts << " [clip data=" << clipData().clipData() << "]";
return ts;
}
TextStream& operator<<(TextStream& ts, WindRule rule)
{
switch (rule) {
case RULE_NONZERO:
ts << "NON-ZERO"; break;
case RULE_EVENODD:
ts << "EVEN-ODD"; break;
}
return ts;
}
TextStream& operator<<(TextStream& ts, const ClipData& d)
{
ts << "[winding=" << d.windRule << "]";
if (d.bboxUnits)
ts << " [bounding box mode=" << d.bboxUnits << "]";
ts << " [path=" << d.path.debugString() << "]";
return ts;
}
SVGResourceClipper* getClipperById(Document* document, const AtomicString& id)
{
SVGResource* resource = getResourceById(document, id);
if (resource && resource->isClipper())
return static_cast<SVGResourceClipper*>(resource);
return 0;
}
} // namespace WebCore
#endif
| [
"jcverdie@a3cd4a6d-042f-0410-9b26-d8d12826d3fb"
] | jcverdie@a3cd4a6d-042f-0410-9b26-d8d12826d3fb |
e34d65fc0581d670ee7f1696bc6f262e51960aa1 | fc38a55144a0ad33bd94301e2d06abd65bd2da3c | /src/modelmeshbinder.h | f67833666781c1c1ebcaa108e9955ba4e4611ffb | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | bobpepin/dust3d | 20fc2fa4380865bc6376724f0843100accd4b08d | 6dcc6b1675cb49ef3fac4a58845f9c9025aa4c9f | refs/heads/master | 2022-11-30T06:00:10.020207 | 2020-08-09T09:54:29 | 2020-08-09T09:54:29 | 286,051,200 | 0 | 0 | MIT | 2020-08-08T13:45:15 | 2020-08-08T13:45:14 | null | UTF-8 | C++ | false | false | 2,363 | h | #ifndef DUST3D_MODEL_MESH_BINDER_H
#define DUST3D_MODEL_MESH_BINDER_H
#include <QOpenGLVertexArrayObject>
#include <QMutex>
#include <QOpenGLBuffer>
#include <QString>
#include <QOpenGLTexture>
#include "model.h"
#include "modelshaderprogram.h"
class ModelMeshBinder
{
public:
ModelMeshBinder(bool toolEnabled=false);
~ModelMeshBinder();
Model *fetchCurrentMesh();
void updateMesh(Model *mesh);
void initialize();
void paint(ModelShaderProgram *program);
void cleanup();
void showWireframe();
void hideWireframe();
bool isWireframeVisible();
void enableCheckUv();
void disableCheckUv();
void enableEnvironmentLight();
bool isEnvironmentLightEnabled();
bool isCheckUvEnabled();
void reloadMesh();
void fetchCurrentToonNormalAndDepthMaps(QImage *normalMap, QImage *depthMap);
void updateToonNormalAndDepthMaps(QImage *normalMap, QImage *depthMap);
private:
Model *m_mesh = nullptr;
Model *m_newMesh = nullptr;
int m_renderTriangleVertexCount = 0;
int m_renderEdgeVertexCount = 0;
int m_renderToolVertexCount = 0;
bool m_newMeshComing = false;
bool m_showWireframe = false;
bool m_hasTexture = false;
QOpenGLTexture *m_texture = nullptr;
bool m_hasNormalMap = false;
QOpenGLTexture *m_normalMap = nullptr;
bool m_hasMetalnessMap = false;
bool m_hasRoughnessMap = false;
bool m_hasAmbientOcclusionMap = false;
QOpenGLTexture *m_metalnessRoughnessAmbientOcclusionMap = nullptr;
bool m_toolEnabled = false;
bool m_checkUvEnabled = false;
bool m_environmentLightEnabled = false;
QOpenGLTexture *m_environmentIrradianceMap = nullptr;
QOpenGLTexture *m_environmentSpecularMap = nullptr;
QOpenGLTexture *m_toonNormalMap = nullptr;
QOpenGLTexture *m_toonDepthMap = nullptr;
QImage *m_newToonNormalMap = nullptr;
QImage *m_newToonDepthMap = nullptr;
QImage *m_currentToonNormalMap = nullptr;
QImage *m_currentToonDepthMap = nullptr;
bool m_newToonMapsComing = false;
private:
QOpenGLVertexArrayObject m_vaoTriangle;
QOpenGLBuffer m_vboTriangle;
QOpenGLVertexArrayObject m_vaoEdge;
QOpenGLBuffer m_vboEdge;
QOpenGLVertexArrayObject m_vaoTool;
QOpenGLBuffer m_vboTool;
QMutex m_meshMutex;
QMutex m_newMeshMutex;
QMutex m_toonNormalAndDepthMapMutex;
};
#endif
| [
"huxingyi@msn.com"
] | huxingyi@msn.com |
dc68759a5315aa8e1b81a4a9e63da9f65d270feb | 33c053ddea13a71a0c0ce1780df22648ed975e60 | /枚舉_0~9組成兩數的最小差.cpp | 0d5ec4d351a580bbd61240783f23682c7f165279 | [] | no_license | chiha8888/Code | 3c76ee6fe63187edb00147cf5dd0ed0583848451 | ae4df9feb86a4f0b130500eb7c6c631ba8657782 | refs/heads/master | 2022-09-17T02:07:13.322590 | 2020-06-05T15:40:24 | 2020-06-05T15:40:24 | 269,687,390 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 418 | cpp | #include<iostream>
#include<cstdlib>
#include<cstring>
#include<string.h>
#include<sstream>
#include<deque>
using namespace std;
deque<int>::iterator iter;
int main(){
int T,num;
string s;
cin>>T;
while(T--){
deque<int> dq;
cin>>s;
stringstream ss(s);
while(ss>>s){
dq.push_back(atoi(s));
}
cout<<dq.size()<<endl;
for(iter=dq.begin();iter!=dq.end();iter++)
cout<<*iter<<endl;
}
return 0;
}
| [
"chiha8888@gmail.com"
] | chiha8888@gmail.com |
24da895d353aa9ad25a830837d94421af80dc22a | 0514949c259aea5dbef62ddb26826a1bc28185a8 | /code/SDK/include/Maya_17/maya/MPxFileTranslator.h | cebcbb4911aa1e1280ae5dc579bafdbf861095f6 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
] | permissive | ArtemGen/xray-oxygen | f759a1c72803b9aabc1fdb2d5c62f8c0b14b7858 | f62d3e1f4e211986c057fd37e97fd03c98b5e275 | refs/heads/master | 2020-12-18T15:41:40.774697 | 2020-01-22T02:36:23 | 2020-01-22T02:36:23 | 235,440,782 | 1 | 0 | NOASSERTION | 2020-01-22T02:36:24 | 2020-01-21T21:01:45 | C++ | UTF-8 | C++ | false | false | 4,736 | h | #ifndef _MPxFileTranslator
#define _MPxFileTranslator
//-
// ===========================================================================
// Copyright 2018 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
// ===========================================================================
//+
//
// CLASS: MPxFileTranslator
//
// ****************************************************************************
#if defined __cplusplus
// ****************************************************************************
// INCLUDED HEADER FILES
#include <maya/MStatus.h>
#include <maya/MString.h>
#include <maya/MTypes.h>
#include <maya/MFileObject.h>
OPENMAYA_MAJOR_NAMESPACE_OPEN
// ****************************************************************************
// CLASS DECLARATION (MPxFileTranslator)
//! \ingroup OpenMaya MPx
//! \brief Base Class for creating Maya File Translators.
/*!
This class provides the connection to Maya by which user written file
translators can be added as plug-ins.
This class provides a base class from which one derives in order to
implement Maya "File Translator Plug-Ins." A file translator
plug-in allows Maya to read or write 3rd party file formats.
The identifyFile method is called whenever Maya's file save or
restore dialogs are run, and identifyFile uses the filename and
first few bytes of the file to determine whether it is of a type
supported by the translator. If it is, then Maya will display the
file with the "name" and "icon" specified as arguments to
MFnPlugin::registerFileTranslator.
If an attempt is made to read the file, the "reader" method in the
derived class is called, if an attempt is made to write the file,
the "writer" method is called.
*/
class OPENMAYA_EXPORT MPxFileTranslator
{
public:
//! How the translator identifies this file
enum MFileKind {
kIsMyFileType, //!< Translator understands how to read/write this file
kCouldBeMyFileType, //!< Translator is not best available to read/write this file
kNotMyFileType //!< Translator does not understand how to read/write this file
};
//! Type of file access
enum FileAccessMode {
kUnknownAccessMode, //!< This mode is set when no file operation is currently in progress.
kOpenAccessMode, //!< This mode is set when data is being read into a new scene. (i.e.: file -open True)
kReferenceAccessMode, //!< This mode is set when a referenced file is being read. This mode can be temporary if the parent file was opened or imported in. For example, if a parent file is being opened, the file access mode will be set to kOpenAccessMode but when the reference file is being read, it will be set to kReferenceAccessMode. It will be set back to kOpenAccessMode once the reference file has been read.
kImportAccessMode, //!< This mode is set when data is being read into the current scene.
kSaveAccessMode, //!< This mode is set when the user saves the file. (i.e.: file -save True)
kExportAccessMode, //!< This mode is set when the user chooses to export all or a referenced file is being written out. This mode can be temporary if the parent file was saved or exported out. For example, if a parent file is being saved, the file access mode will be set to kSaveAccessMode but when the reference file is being written, it will be set to kExportAccessMode. It will be set back to kSaveAccessMode once the reference file has been written.
kExportActiveAccessMode //!< This mode is set when only the selected items are to be exported.
};
MPxFileTranslator ();
virtual ~MPxFileTranslator ();
virtual MStatus reader ( const MFileObject& file,
const MString& optionsString,
FileAccessMode mode);
virtual MStatus writer ( const MFileObject& file,
const MString& optionsString,
FileAccessMode mode);
virtual bool haveReadMethod () const;
virtual bool haveWriteMethod () const;
virtual bool haveNamespaceSupport () const;
virtual bool haveReferenceMethod () const;
virtual bool allowMultipleFileOptimization() const;
virtual MString defaultExtension () const;
virtual MString filter () const;
virtual bool canBeOpened () const;
virtual MPxFileTranslator::MFileKind identifyFile ( const MFileObject& file,
const char* buffer, short size) const;
static MPxFileTranslator::FileAccessMode fileAccessMode();
protected:
// No protected members
private:
void* data;
};
OPENMAYA_NAMESPACE_CLOSE
#endif /* __cplusplus */
#endif /* _MPxFileTranslator */
| [
"sv3nk@yandex.ru"
] | sv3nk@yandex.ru |
a5c266f2dfd36f0fcc7293828d01b6e842b9f28c | c8185e29b7dbcac2bb9b005d4b5b62901f493d76 | /combinatorics/josephus/josephus_test.cc | 920d28d477ef8d56f5b28c754741d9b1ce55ce65 | [] | no_license | yuhanlyu/experimental | 4e624603b50da41e0863314ba13a5a1e4ef0700f | 97e27e1bfed3b3cd5314424a7c9ad6bc58377f5e | refs/heads/master | 2021-01-22T21:32:18.387849 | 2019-02-21T04:18:49 | 2019-02-21T04:18:49 | 85,438,984 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 821 | cc | #include "josephus.h"
#include "gtest/gtest.h"
namespace {
static constexpr int32_t n = 2000000;
TEST(JosephusTest, ValidateConcreteMath) {
for (int32_t m = 2; m < n; m += 100000) {
EXPECT_EQ(ConcreteMath(n, m), TAOCPK(n, m, n));
}
}
TEST(JosephusTest, ValidateWoodhousea) {
for (int32_t m = 2; m < n; m += 100000) {
EXPECT_EQ(Woodhousea(n, m), TAOCPK(n, m, n));
}
}
TEST(JosephusTest, ValidateGelgi) {
for (int32_t m = 2; m < n; m += 100000) {
EXPECT_EQ(Gelgi(n, m), TAOCPK(n, m, n));
}
}
TEST(JosephusTest, ValidateGelgiImprove) {
for (int32_t m = 2; m < n; m += 100000) {
EXPECT_EQ(ImprovedGelgi(n, m), TAOCPK(n, m, n));
}
}
TEST(JosephusTest, ValidateGelgiTAOCP) {
for (int32_t m = 2; m < n; m += 100000) {
EXPECT_EQ(TAOCP(n, m), TAOCPK(n, m, n));
}
}
} // namespace
| [
"yuhanlyu@gmail.com"
] | yuhanlyu@gmail.com |
41874399d6cb53d460e5542a87b9c724b40b4dc1 | 67b650c9a3a0c5d9bdcc78f61a66e84a8dcdcdb7 | /LVNS3/rfonttable.h | 62d993f11c68e975cc3068b22553fc1ce06d205b | [] | no_license | Her-Saki/toheart-tools | 86ccfb7bb9673ab5aaa038d08f8ba0526b5f85ae | 7f54201a8e6ecb98e14dc079ae29a28e156b432d | refs/heads/master | 2022-12-15T05:43:33.774450 | 2020-09-13T21:12:30 | 2020-09-13T21:12:30 | 295,234,623 | 1 | 0 | null | 2020-09-13T20:45:41 | 2020-09-13T20:45:41 | null | UTF-8 | C++ | false | false | 51,314 | h | #include <string>
#include <unordered_map>
const std::unordered_map<std::string, uint16_t> rfonttable = {
{" ", 0x0000}, {"■", 0x0001}, {"A", 0x0002}, {"B", 0x0003},
{"C", 0x0004}, {"D", 0x0005}, {"E", 0x0006}, {"F", 0x0007},
{"G", 0x0008}, {"H", 0x0009}, {"I", 0x000a}, {"J", 0x000b},
{"K", 0x000c}, {"L", 0x000d}, {"M", 0x000e}, {"N", 0x000f},
{"O", 0x0010}, {"P", 0x0011}, {"Q", 0x0012}, {"R", 0x0013},
{"S", 0x0014}, {"T", 0x0015}, {"U", 0x0016}, {"V", 0x0017},
{"W", 0x0018}, {"X", 0x0019}, {"Y", 0x001a}, {"Z", 0x001b},
{"a", 0x001c}, {"b", 0x001d}, {"c", 0x001e}, {"d", 0x001f},
{"e", 0x0020}, {"f", 0x0021}, {"g", 0x0022}, {"h", 0x0023},
{"i", 0x0024}, {"j", 0x0025}, {"k", 0x0026}, {"l", 0x0027},
{"m", 0x0028}, {"n", 0x0029}, {"o", 0x002a}, {"p", 0x002b},
{"q", 0x002c}, {"r", 0x002d}, {"s", 0x002e}, {"t", 0x002f},
{"u", 0x0030}, {"v", 0x0031}, {"w", 0x0032}, {"x", 0x0033},
{"y", 0x0034}, {"z", 0x0035}, {"0", 0x0036}, {"1", 0x0037},
{"2", 0x0038}, {"3", 0x0039}, {"4", 0x003a}, {"5", 0x003b},
{"6", 0x003c}, {"7", 0x003d}, {"8", 0x003e}, {"9", 0x003f},
{"あ", 0x0040}, {"い", 0x0041}, {"う", 0x0042}, {"え", 0x0043},
{"お", 0x0044}, {"か", 0x0045}, {"き", 0x0046}, {"く", 0x0047},
{"け", 0x0048}, {"こ", 0x0049}, {"さ", 0x004a}, {"し", 0x004b},
{"す", 0x004c}, {"せ", 0x004d}, {"そ", 0x004e}, {"た", 0x004f},
{"ち", 0x0050}, {"つ", 0x0051}, {"て", 0x0052}, {"と", 0x0053},
{"な", 0x0054}, {"に", 0x0055}, {"ぬ", 0x0056}, {"ね", 0x0057},
{"の", 0x0058}, {"は", 0x0059}, {"ひ", 0x005a}, {"ふ", 0x005b},
{"へ", 0x005c}, {"ほ", 0x005d}, {"ま", 0x005e}, {"み", 0x005f},
{"む", 0x0060}, {"め", 0x0061}, {"も", 0x0062}, {"や", 0x0063},
{"ゆ", 0x0064}, {"よ", 0x0065}, {"ら", 0x0066}, {"り", 0x0067},
{"る", 0x0068}, {"れ", 0x0069}, {"ろ", 0x006a}, {"わ", 0x006b},
{"を", 0x006c}, {"ん", 0x006d}, {"が", 0x006e}, {"ぎ", 0x006f},
{"ぐ", 0x0070}, {"げ", 0x0071}, {"ご", 0x0072}, {"ざ", 0x0073},
{"じ", 0x0074}, {"ず", 0x0075}, {"ぜ", 0x0076}, {"ぞ", 0x0077},
{"だ", 0x0078}, {"ぢ", 0x0079}, {"づ", 0x007a}, {"で", 0x007b},
{"ど", 0x007c}, {"ば", 0x007d}, {"び", 0x007e}, {"ぶ", 0x007f},
{"べ", 0x0080}, {"ぼ", 0x0081}, {"ぱ", 0x0082}, {"ぴ", 0x0083},
{"ぷ", 0x0084}, {"ぺ", 0x0085}, {"ぽ", 0x0086}, {"ぁ", 0x0087},
{"ぃ", 0x0088}, {"ぅ", 0x0089}, {"ぇ", 0x008a}, {"ぉ", 0x008b},
{"ゃ", 0x008c}, {"ゅ", 0x008d}, {"ょ", 0x008e}, {"っ", 0x008f},
{" ", 0x0090}, {"ア", 0x0091}, {"イ", 0x0092}, {"ウ", 0x0093},
{"エ", 0x0094}, {"オ", 0x0095}, {"カ", 0x0096}, {"キ", 0x0097},
{"ク", 0x0098}, {"ケ", 0x0099}, {"コ", 0x009a}, {"サ", 0x009b},
{"シ", 0x009c}, {"ス", 0x009d}, {"セ", 0x009e}, {"ソ", 0x009f},
{"タ", 0x00a0}, {"チ", 0x00a1}, {"ツ", 0x00a2}, {"テ", 0x00a3},
{"ト", 0x00a4}, {"ナ", 0x00a5}, {"ニ", 0x00a6}, {"ヌ", 0x00a7},
{"ネ", 0x00a8}, {"ノ", 0x00a9}, {"ハ", 0x00aa}, {"ヒ", 0x00ab},
{"フ", 0x00ac}, {"ヘ", 0x00ad}, {"ホ", 0x00ae}, {"マ", 0x00af},
{"ミ", 0x00b0}, {"ム", 0x00b1}, {"メ", 0x00b2}, {"モ", 0x00b3},
{"ヤ", 0x00b4}, {"ユ", 0x00b5}, {"ヨ", 0x00b6}, {"ラ", 0x00b7},
{"リ", 0x00b8}, {"ル", 0x00b9}, {"レ", 0x00ba}, {"ロ", 0x00bb},
{"ワ", 0x00bc}, {"ヲ", 0x00bd}, {"ン", 0x00be}, {"ガ", 0x00bf},
{"ギ", 0x00c0}, {"グ", 0x00c1}, {"ゲ", 0x00c2}, {"ゴ", 0x00c3},
{"ザ", 0x00c4}, {"ジ", 0x00c5}, {"ズ", 0x00c6}, {"ゼ", 0x00c7},
{"ゾ", 0x00c8}, {"ダ", 0x00c9}, {"ヂ", 0x00ca}, {"ヅ", 0x00cb},
{"デ", 0x00cc}, {"ド", 0x00cd}, {"バ", 0x00ce}, {"ビ", 0x00cf},
{"ブ", 0x00d0}, {"ベ", 0x00d1}, {"ボ", 0x00d2}, {"パ", 0x00d3},
{"ピ", 0x00d4}, {"プ", 0x00d5}, {"ペ", 0x00d6}, {"ポ", 0x00d7},
{"ァ", 0x00d8}, {"ィ", 0x00d9}, {"ゥ", 0x00da}, {"ェ", 0x00db},
{"ォ", 0x00dc}, {"ャ", 0x00dd}, {"ュ", 0x00de}, {"ョ", 0x00df},
{"ッ", 0x00e0}, {"ヶ", 0x00e1}, {"ヴ", 0x00e2}, {"『", 0x00e3},
{"』", 0x00e4}, {"「", 0x00e5}, {"」", 0x00e6}, {"(", 0x00e7},
{")", 0x00e8}, {"?", 0x00e9}, {"!", 0x00ea}, {":", 0x00eb},
{"-", 0x00ec}, {"ー", 0x00ed}, {"~", 0x00ee}, {"。", 0x00ef},
{"、", 0x00f0}, {".", 0x00f1}, {",", 0x00f2}, {"・", 0x00f3},
{"‥", 0x00f4}, {"…", 0x00f5}, {"○", 0x00f6}, {"々", 0x00f7},
{"了", 0x00f8}, {"←", 0x00f9}, {"→", 0x00fa}, {"▲", 0x00fb},
{"▼", 0x00fc}, {"$", 0x00fd}, {"─", 0x00fe}, {"★", 0x00ff},
{"@", 0x0100}, {";", 0x0101}, {"□", 0x0102}, {"亜", 0x0103},
{"唖", 0x0104}, {"哀", 0x0105}, {"愛", 0x0106}, {"挨", 0x0107},
{"逢", 0x0108}, {"悪", 0x0109}, {"握", 0x010a}, {"圧", 0x010b},
{"扱", 0x010c}, {"宛", 0x010d}, {"飴", 0x010e}, {"或", 0x010f},
{"安", 0x0110}, {"暗", 0x0111}, {"案", 0x0112}, {"闇", 0x0113},
{"以", 0x0114}, {"伊", 0x0115}, {"位", 0x0116}, {"依", 0x0117},
{"偉", 0x0118}, {"囲", 0x0119}, {"委", 0x011a}, {"威", 0x011b},
{"尉", 0x011c}, {"意", 0x011d}, {"慰", 0x011e}, {"易", 0x011f},
{"椅", 0x0120}, {"為", 0x0121}, {"異", 0x0122}, {"移", 0x0123},
{"維", 0x0124}, {"胃", 0x0125}, {"衣", 0x0126}, {"違", 0x0127},
{"遺", 0x0128}, {"医", 0x0129}, {"井", 0x012a}, {"域", 0x012b},
{"育", 0x012c}, {"一", 0x012d}, {"溢", 0x012e}, {"逸", 0x012f},
{"稲", 0x0130}, {"芋", 0x0131}, {"印", 0x0132}, {"咽", 0x0133},
{"員", 0x0134}, {"因", 0x0135}, {"姻", 0x0136}, {"引", 0x0137},
{"飲", 0x0138}, {"淫", 0x0139}, {"院", 0x013a}, {"陰", 0x013b},
{"隠", 0x013c}, {"韻", 0x013d}, {"右", 0x013e}, {"宇", 0x013f},
{"羽", 0x0140}, {"雨", 0x0141}, {"渦", 0x0142}, {"嘘", 0x0143},
{"唄", 0x0144}, {"浦", 0x0145}, {"瓜", 0x0146}, {"噂", 0x0147},
{"云", 0x0148}, {"運", 0x0149}, {"雲", 0x014a}, {"営", 0x014b},
{"影", 0x014c}, {"映", 0x014d}, {"栄", 0x014e}, {"永", 0x014f},
{"泳", 0x0150}, {"洩", 0x0151}, {"英", 0x0152}, {"衛", 0x0153},
{"鋭", 0x0154}, {"液", 0x0155}, {"疫", 0x0156}, {"益", 0x0157},
{"駅", 0x0158}, {"悦", 0x0159}, {"越", 0x015a}, {"閲", 0x015b},
{"円", 0x015c}, {"園", 0x015d}, {"宴", 0x015e}, {"延", 0x015f},
{"援", 0x0160}, {"沿", 0x0161}, {"演", 0x0162}, {"炎", 0x0163},
{"煙", 0x0164}, {"縁", 0x0165}, {"艶", 0x0166}, {"遠", 0x0167},
{"鉛", 0x0168}, {"塩", 0x0169}, {"汚", 0x016a}, {"甥", 0x016b},
{"央", 0x016c}, {"奥", 0x016d}, {"往", 0x016e}, {"応", 0x016f},
{"押", 0x0170}, {"横", 0x0171}, {"欧", 0x0172}, {"殴", 0x0173},
{"王", 0x0174}, {"黄", 0x0175}, {"岡", 0x0176}, {"沖", 0x0177},
{"億", 0x0178}, {"屋", 0x0179}, {"憶", 0x017a}, {"臆", 0x017b},
{"乙", 0x017c}, {"俺", 0x017d}, {"卸", 0x017e}, {"恩", 0x017f},
{"温", 0x0180}, {"穏", 0x0181}, {"音", 0x0182}, {"下", 0x0183},
{"化", 0x0184}, {"仮", 0x0185}, {"何", 0x0186}, {"価", 0x0187},
{"佳", 0x0188}, {"加", 0x0189}, {"可", 0x018a}, {"嘉", 0x018b},
{"夏", 0x018c}, {"嫁", 0x018d}, {"家", 0x018e}, {"科", 0x018f},
{"暇", 0x0190}, {"果", 0x0191}, {"架", 0x0192}, {"歌", 0x0193},
{"河", 0x0194}, {"火", 0x0195}, {"禍", 0x0196}, {"稼", 0x0197},
{"箇", 0x0198}, {"花", 0x0199}, {"荷", 0x019a}, {"華", 0x019b},
{"菓", 0x019c}, {"課", 0x019d}, {"嘩", 0x019e}, {"貨", 0x019f},
{"過", 0x01a0}, {"霞", 0x01a1}, {"我", 0x01a2}, {"画", 0x01a3},
{"芽", 0x01a4}, {"賀", 0x01a5}, {"雅", 0x01a6}, {"餓", 0x01a7},
{"介", 0x01a8}, {"会", 0x01a9}, {"解", 0x01aa}, {"回", 0x01ab},
{"塊", 0x01ac}, {"壊", 0x01ad}, {"快", 0x01ae}, {"怪", 0x01af},
{"悔", 0x01b0}, {"懐", 0x01b1}, {"戒", 0x01b2}, {"改", 0x01b3},
{"械", 0x01b4}, {"海", 0x01b5}, {"灰", 0x01b6}, {"界", 0x01b7},
{"皆", 0x01b8}, {"絵", 0x01b9}, {"開", 0x01ba}, {"階", 0x01bb},
{"貝", 0x01bc}, {"外", 0x01bd}, {"咳", 0x01be}, {"害", 0x01bf},
{"慨", 0x01c0}, {"概", 0x01c1}, {"蓋", 0x01c2}, {"街", 0x01c3},
{"該", 0x01c4}, {"垣", 0x01c5}, {"嚇", 0x01c6}, {"各", 0x01c7},
{"拡", 0x01c8}, {"格", 0x01c9}, {"核", 0x01ca}, {"殻", 0x01cb},
{"獲", 0x01cc}, {"確", 0x01cd}, {"穫", 0x01ce}, {"覚", 0x01cf},
{"角", 0x01d0}, {"較", 0x01d1}, {"郭", 0x01d2}, {"閣", 0x01d3},
{"隔", 0x01d4}, {"革", 0x01d5}, {"学", 0x01d6}, {"岳", 0x01d7},
{"楽", 0x01d8}, {"額", 0x01d9}, {"顎", 0x01da}, {"掛", 0x01db},
{"割", 0x01dc}, {"喝", 0x01dd}, {"括", 0x01de}, {"活", 0x01df},
{"滑", 0x01e0}, {"轄", 0x01e1}, {"叶", 0x01e2}, {"鞄", 0x01e3},
{"株", 0x01e4}, {"蒲", 0x01e5}, {"釜", 0x01e6}, {"噛", 0x01e7},
{"乾", 0x01e8}, {"冠", 0x01e9}, {"寒", 0x01ea}, {"刊", 0x01eb},
{"勘", 0x01ec}, {"勧", 0x01ed}, {"巻", 0x01ee}, {"姦", 0x01ef},
{"完", 0x01f0}, {"官", 0x01f1}, {"寛", 0x01f2}, {"干", 0x01f3},
{"幹", 0x01f4}, {"患", 0x01f5}, {"感", 0x01f6}, {"慣", 0x01f7},
{"憾", 0x01f8}, {"換", 0x01f9}, {"敢", 0x01fa}, {"款", 0x01fb},
{"歓", 0x01fc}, {"汗", 0x01fd}, {"漢", 0x01fe}, {"環", 0x01ff},
{"甘", 0x0200}, {"監", 0x0201}, {"看", 0x0202}, {"管", 0x0203},
{"簡", 0x0204}, {"緩", 0x0205}, {"肝", 0x0206}, {"艦", 0x0207},
{"観", 0x0208}, {"貫", 0x0209}, {"還", 0x020a}, {"間", 0x020b},
{"閑", 0x020c}, {"関", 0x020d}, {"陥", 0x020e}, {"館", 0x020f},
{"丸", 0x0210}, {"含", 0x0211}, {"玩", 0x0212}, {"眼", 0x0213},
{"岩", 0x0214}, {"頑", 0x0215}, {"顔", 0x0216}, {"願", 0x0217},
{"企", 0x0218}, {"危", 0x0219}, {"喜", 0x021a}, {"器", 0x021b},
{"基", 0x021c}, {"奇", 0x021d}, {"嬉", 0x021e}, {"寄", 0x021f},
{"岐", 0x0220}, {"希", 0x0221}, {"幾", 0x0222}, {"忌", 0x0223},
{"揮", 0x0224}, {"机", 0x0225}, {"旗", 0x0226}, {"既", 0x0227},
{"期", 0x0228}, {"棋", 0x0229}, {"棄", 0x022a}, {"機", 0x022b},
{"帰", 0x022c}, {"気", 0x022d}, {"汽", 0x022e}, {"畿", 0x022f},
{"祈", 0x0230}, {"季", 0x0231}, {"紀", 0x0232}, {"規", 0x0233},
{"記", 0x0234}, {"貴", 0x0235}, {"起", 0x0236}, {"軌", 0x0237},
{"輝", 0x0238}, {"飢", 0x0239}, {"鬼", 0x023a}, {"偽", 0x023b},
{"儀", 0x023c}, {"宜", 0x023d}, {"戯", 0x023e}, {"技", 0x023f},
{"擬", 0x0240}, {"犠", 0x0241}, {"疑", 0x0242}, {"義", 0x0243},
{"議", 0x0244}, {"菊", 0x0245}, {"吉", 0x0246}, {"喫", 0x0247},
{"詰", 0x0248}, {"却", 0x0249}, {"客", 0x024a}, {"脚", 0x024b},
{"虐", 0x024c}, {"逆", 0x024d}, {"丘", 0x024e}, {"久", 0x024f},
{"仇", 0x0250}, {"休", 0x0251}, {"及", 0x0252}, {"吸", 0x0253},
{"宮", 0x0254}, {"弓", 0x0255}, {"急", 0x0256}, {"救", 0x0257},
{"朽", 0x0258}, {"求", 0x0259}, {"泣", 0x025a}, {"球", 0x025b},
{"究", 0x025c}, {"窮", 0x025d}, {"級", 0x025e}, {"給", 0x025f},
{"旧", 0x0260}, {"牛", 0x0261}, {"去", 0x0262}, {"居", 0x0263},
{"巨", 0x0264}, {"拒", 0x0265}, {"拠", 0x0266}, {"挙", 0x0267},
{"虚", 0x0268}, {"許", 0x0269}, {"距", 0x026a}, {"漁", 0x026b},
{"魚", 0x026c}, {"享", 0x026d}, {"京", 0x026e}, {"供", 0x026f},
{"競", 0x0270}, {"共", 0x0271}, {"凶", 0x0272}, {"協", 0x0273},
{"叫", 0x0274}, {"境", 0x0275}, {"強", 0x0276}, {"怯", 0x0277},
{"恐", 0x0278}, {"恭", 0x0279}, {"挟", 0x027a}, {"教", 0x027b},
{"橋", 0x027c}, {"況", 0x027d}, {"狂", 0x027e}, {"狭", 0x027f},
{"胸", 0x0280}, {"脅", 0x0281}, {"興", 0x0282}, {"郷", 0x0283},
{"鏡", 0x0284}, {"響", 0x0285}, {"驚", 0x0286}, {"仰", 0x0287},
{"凝", 0x0288}, {"暁", 0x0289}, {"業", 0x028a}, {"局", 0x028b},
{"曲", 0x028c}, {"極", 0x028d}, {"玉", 0x028e}, {"僅", 0x028f},
{"勤", 0x0290}, {"均", 0x0291}, {"斤", 0x0292}, {"琴", 0x0293},
{"禁", 0x0294}, {"筋", 0x0295}, {"緊", 0x0296}, {"菌", 0x0297},
{"襟", 0x0298}, {"謹", 0x0299}, {"近", 0x029a}, {"金", 0x029b},
{"銀", 0x029c}, {"九", 0x029d}, {"倶", 0x029e}, {"句", 0x029f},
{"区", 0x02a0}, {"苦", 0x02a1}, {"躯", 0x02a2}, {"駆", 0x02a3},
{"具", 0x02a4}, {"愚", 0x02a5}, {"空", 0x02a6}, {"偶", 0x02a7},
{"遇", 0x02a8}, {"隅", 0x02a9}, {"屑", 0x02aa}, {"屈", 0x02ab},
{"掘", 0x02ac}, {"靴", 0x02ad}, {"熊", 0x02ae}, {"隈", 0x02af},
{"栗", 0x02b0}, {"繰", 0x02b1}, {"桑", 0x02b2}, {"勲", 0x02b3},
{"君", 0x02b4}, {"訓", 0x02b5}, {"群", 0x02b6}, {"軍", 0x02b7},
{"郡", 0x02b8}, {"袈", 0x02b9}, {"係", 0x02ba}, {"傾", 0x02bb},
{"刑", 0x02bc}, {"兄", 0x02bd}, {"啓", 0x02be}, {"型", 0x02bf},
{"契", 0x02c0}, {"形", 0x02c1}, {"径", 0x02c2}, {"恵", 0x02c3},
{"慶", 0x02c4}, {"憩", 0x02c5}, {"掲", 0x02c6}, {"携", 0x02c7},
{"敬", 0x02c8}, {"景", 0x02c9}, {"桂", 0x02ca}, {"渓", 0x02cb},
{"稽", 0x02cc}, {"系", 0x02cd}, {"経", 0x02ce}, {"継", 0x02cf},
{"繋", 0x02d0}, {"罫", 0x02d1}, {"蛍", 0x02d2}, {"計", 0x02d3},
{"詣", 0x02d4}, {"警", 0x02d5}, {"軽", 0x02d6}, {"鶏", 0x02d7},
{"芸", 0x02d8}, {"迎", 0x02d9}, {"鯨", 0x02da}, {"劇", 0x02db},
{"撃", 0x02dc}, {"激", 0x02dd}, {"隙", 0x02de}, {"傑", 0x02df},
{"欠", 0x02e0}, {"決", 0x02e1}, {"潔", 0x02e2}, {"穴", 0x02e3},
{"結", 0x02e4}, {"血", 0x02e5}, {"月", 0x02e6}, {"件", 0x02e7},
{"倹", 0x02e8}, {"倦", 0x02e9}, {"健", 0x02ea}, {"兼", 0x02eb},
{"券", 0x02ec}, {"剣", 0x02ed}, {"喧", 0x02ee}, {"圏", 0x02ef},
{"堅", 0x02f0}, {"嫌", 0x02f1}, {"建", 0x02f2}, {"憲", 0x02f3},
{"懸", 0x02f4}, {"拳", 0x02f5}, {"検", 0x02f6}, {"権", 0x02f7},
{"犬", 0x02f8}, {"献", 0x02f9}, {"研", 0x02fa}, {"絹", 0x02fb},
{"県", 0x02fc}, {"肩", 0x02fd}, {"見", 0x02fe}, {"謙", 0x02ff},
{"賢", 0x0300}, {"軒", 0x0301}, {"遣", 0x0302}, {"鍵", 0x0303},
{"険", 0x0304}, {"験", 0x0305}, {"元", 0x0306}, {"原", 0x0307},
{"厳", 0x0308}, {"幻", 0x0309}, {"減", 0x030a}, {"源", 0x030b},
{"玄", 0x030c}, {"現", 0x030d}, {"言", 0x030e}, {"限", 0x030f},
{"個", 0x0310}, {"古", 0x0311}, {"呼", 0x0312}, {"固", 0x0313},
{"孤", 0x0314}, {"己", 0x0315}, {"庫", 0x0316}, {"戸", 0x0317},
{"故", 0x0318}, {"枯", 0x0319}, {"湖", 0x031a}, {"袴", 0x031b},
{"股", 0x031c}, {"誇", 0x031d}, {"雇", 0x031e}, {"顧", 0x031f},
{"鼓", 0x0320}, {"五", 0x0321}, {"互", 0x0322}, {"午", 0x0323},
{"呉", 0x0324}, {"吾", 0x0325}, {"娯", 0x0326}, {"後", 0x0327},
{"御", 0x0328}, {"悟", 0x0329}, {"碁", 0x032a}, {"語", 0x032b},
{"誤", 0x032c}, {"護", 0x032d}, {"乞", 0x032e}, {"交", 0x032f},
{"候", 0x0330}, {"光", 0x0331}, {"公", 0x0332}, {"功", 0x0333},
{"効", 0x0334}, {"厚", 0x0335}, {"口", 0x0336}, {"向", 0x0337},
{"后", 0x0338}, {"喉", 0x0339}, {"垢", 0x033a}, {"好", 0x033b},
{"孔", 0x033c}, {"孝", 0x033d}, {"工", 0x033e}, {"巧", 0x033f},
{"幸", 0x0340}, {"広", 0x0341}, {"康", 0x0342}, {"弘", 0x0343},
{"恒", 0x0344}, {"慌", 0x0345}, {"抗", 0x0346}, {"拘", 0x0347},
{"控", 0x0348}, {"攻", 0x0349}, {"更", 0x034a}, {"校", 0x034b},
{"構", 0x034c}, {"江", 0x034d}, {"洪", 0x034e}, {"港", 0x034f},
{"溝", 0x0350}, {"甲", 0x0351}, {"皇", 0x0352}, {"硬", 0x0353},
{"稿", 0x0354}, {"紅", 0x0355}, {"絞", 0x0356}, {"綱", 0x0357},
{"耕", 0x0358}, {"考", 0x0359}, {"肯", 0x035a}, {"膏", 0x035b},
{"航", 0x035c}, {"荒", 0x035d}, {"行", 0x035e}, {"講", 0x035f},
{"貢", 0x0360}, {"購", 0x0361}, {"郊", 0x0362}, {"鉱", 0x0363},
{"鋼", 0x0364}, {"降", 0x0365}, {"項", 0x0366}, {"香", 0x0367},
{"高", 0x0368}, {"剛", 0x0369}, {"号", 0x036a}, {"合", 0x036b},
{"拷", 0x036c}, {"豪", 0x036d}, {"轟", 0x036e}, {"克", 0x036f},
{"刻", 0x0370}, {"告", 0x0371}, {"国", 0x0372}, {"酷", 0x0373},
{"黒", 0x0374}, {"獄", 0x0375}, {"腰", 0x0376}, {"惚", 0x0377},
{"骨", 0x0378}, {"込", 0x0379}, {"此", 0x037a}, {"頃", 0x037b},
{"今", 0x037c}, {"困", 0x037d}, {"墾", 0x037e}, {"婚", 0x037f},
{"恨", 0x0380}, {"懇", 0x0381}, {"昏", 0x0382}, {"根", 0x0383},
{"混", 0x0384}, {"紺", 0x0385}, {"魂", 0x0386}, {"痕", 0x0387},
{"佐", 0x0388}, {"左", 0x0389}, {"差", 0x038a}, {"査", 0x038b},
{"沙", 0x038c}, {"砂", 0x038d}, {"鎖", 0x038e}, {"裟", 0x038f},
{"座", 0x0390}, {"挫", 0x0391}, {"債", 0x0392}, {"催", 0x0393},
{"再", 0x0394}, {"最", 0x0395}, {"塞", 0x0396}, {"妻", 0x0397},
{"宰", 0x0398}, {"彩", 0x0399}, {"才", 0x039a}, {"採", 0x039b},
{"栽", 0x039c}, {"歳", 0x039d}, {"済", 0x039e}, {"災", 0x039f},
{"砕", 0x03a0}, {"祭", 0x03a1}, {"斎", 0x03a2}, {"細", 0x03a3},
{"菜", 0x03a4}, {"裁", 0x03a5}, {"載", 0x03a6}, {"際", 0x03a7},
{"剤", 0x03a8}, {"在", 0x03a9}, {"材", 0x03aa}, {"罪", 0x03ab},
{"財", 0x03ac}, {"坂", 0x03ad}, {"阪", 0x03ae}, {"咲", 0x03af},
{"崎", 0x03b0}, {"作", 0x03b1}, {"削", 0x03b2}, {"昨", 0x03b3},
{"策", 0x03b4}, {"索", 0x03b5}, {"錯", 0x03b6}, {"桜", 0x03b7},
{"冊", 0x03b8}, {"刷", 0x03b9}, {"察", 0x03ba}, {"拶", 0x03bb},
{"撮", 0x03bc}, {"擦", 0x03bd}, {"札", 0x03be}, {"殺", 0x03bf},
{"雑", 0x03c0}, {"錆", 0x03c1}, {"三", 0x03c2}, {"参", 0x03c3},
{"山", 0x03c4}, {"惨", 0x03c5}, {"散", 0x03c6}, {"産", 0x03c7},
{"算", 0x03c8}, {"蚕", 0x03c9}, {"賛", 0x03ca}, {"酸", 0x03cb},
{"斬", 0x03cc}, {"暫", 0x03cd}, {"残", 0x03ce}, {"仕", 0x03cf},
{"仔", 0x03d0}, {"伺", 0x03d1}, {"使", 0x03d2}, {"刺", 0x03d3},
{"司", 0x03d4}, {"史", 0x03d5}, {"嗣", 0x03d6}, {"四", 0x03d7},
{"士", 0x03d8}, {"始", 0x03d9}, {"姉", 0x03da}, {"姿", 0x03db},
{"子", 0x03dc}, {"市", 0x03dd}, {"師", 0x03de}, {"志", 0x03df},
{"思", 0x03e0}, {"指", 0x03e1}, {"支", 0x03e2}, {"施", 0x03e3},
{"旨", 0x03e4}, {"枝", 0x03e5}, {"止", 0x03e6}, {"死", 0x03e7},
{"氏", 0x03e8}, {"祉", 0x03e9}, {"私", 0x03ea}, {"糸", 0x03eb},
{"紙", 0x03ec}, {"紫", 0x03ed}, {"肢", 0x03ee}, {"脂", 0x03ef},
{"至", 0x03f0}, {"視", 0x03f1}, {"詞", 0x03f2}, {"詩", 0x03f3},
{"試", 0x03f4}, {"誌", 0x03f5}, {"資", 0x03f6}, {"賜", 0x03f7},
{"雌", 0x03f8}, {"飼", 0x03f9}, {"歯", 0x03fa}, {"事", 0x03fb},
{"似", 0x03fc}, {"侍", 0x03fd}, {"児", 0x03fe}, {"字", 0x03ff},
{"寺", 0x0400}, {"慈", 0x0401}, {"持", 0x0402}, {"時", 0x0403},
{"次", 0x0404}, {"滋", 0x0405}, {"治", 0x0406}, {"磁", 0x0407},
{"示", 0x0408}, {"耳", 0x0409}, {"自", 0x040a}, {"辞", 0x040b},
{"鹿", 0x040c}, {"式", 0x040d}, {"識", 0x040e}, {"軸", 0x040f},
{"雫", 0x0410}, {"七", 0x0411}, {"叱", 0x0412}, {"執", 0x0413},
{"失", 0x0414}, {"嫉", 0x0415}, {"室", 0x0416}, {"湿", 0x0417},
{"漆", 0x0418}, {"疾", 0x0419}, {"質", 0x041a}, {"実", 0x041b},
{"柴", 0x041c}, {"芝", 0x041d}, {"舎", 0x041e}, {"写", 0x041f},
{"射", 0x0420}, {"捨", 0x0421}, {"赦", 0x0422}, {"斜", 0x0423},
{"煮", 0x0424}, {"社", 0x0425}, {"者", 0x0426}, {"謝", 0x0427},
{"車", 0x0428}, {"遮", 0x0429}, {"蛇", 0x042a}, {"邪", 0x042b},
{"借", 0x042c}, {"勺", 0x042d}, {"尺", 0x042e}, {"杓", 0x042f},
{"灼", 0x0430}, {"酌", 0x0431}, {"釈", 0x0432}, {"若", 0x0433},
{"寂", 0x0434}, {"弱", 0x0435}, {"主", 0x0436}, {"取", 0x0437},
{"守", 0x0438}, {"手", 0x0439}, {"殊", 0x043a}, {"狩", 0x043b},
{"珠", 0x043c}, {"種", 0x043d}, {"趣", 0x043e}, {"酒", 0x043f},
{"首", 0x0440}, {"受", 0x0441}, {"呪", 0x0442}, {"寿", 0x0443},
{"授", 0x0444}, {"樹", 0x0445}, {"需", 0x0446}, {"収", 0x0447},
{"周", 0x0448}, {"宗", 0x0449}, {"就", 0x044a}, {"州", 0x044b},
{"修", 0x044c}, {"拾", 0x044d}, {"秀", 0x044e}, {"秋", 0x044f},
{"終", 0x0450}, {"習", 0x0451}, {"臭", 0x0452}, {"舟", 0x0453},
{"衆", 0x0454}, {"襲", 0x0455}, {"蹴", 0x0456}, {"週", 0x0457},
{"酬", 0x0458}, {"集", 0x0459}, {"醜", 0x045a}, {"住", 0x045b},
{"充", 0x045c}, {"十", 0x045d}, {"従", 0x045e}, {"柔", 0x045f},
{"汁", 0x0460}, {"渋", 0x0461}, {"獣", 0x0462}, {"縦", 0x0463},
{"重", 0x0464}, {"銃", 0x0465}, {"叔", 0x0466}, {"宿", 0x0467},
{"淑", 0x0468}, {"祝", 0x0469}, {"縮", 0x046a}, {"粛", 0x046b},
{"熟", 0x046c}, {"出", 0x046d}, {"術", 0x046e}, {"述", 0x046f},
{"俊", 0x0470}, {"春", 0x0471}, {"瞬", 0x0472}, {"循", 0x0473},
{"旬", 0x0474}, {"楯", 0x0475}, {"準", 0x0476}, {"潤", 0x0477},
{"純", 0x0478}, {"巡", 0x0479}, {"順", 0x047a}, {"処", 0x047b},
{"初", 0x047c}, {"所", 0x047d}, {"暑", 0x047e}, {"庶", 0x047f},
{"緒", 0x0480}, {"署", 0x0481}, {"書", 0x0482}, {"諸", 0x0483},
{"助", 0x0484}, {"叙", 0x0485}, {"女", 0x0486}, {"序", 0x0487},
{"徐", 0x0488}, {"除", 0x0489}, {"傷", 0x048a}, {"償", 0x048b},
{"勝", 0x048c}, {"升", 0x048d}, {"召", 0x048e}, {"商", 0x048f},
{"唱", 0x0490}, {"嘗", 0x0491}, {"奨", 0x0492}, {"宵", 0x0493},
{"将", 0x0494}, {"小", 0x0495}, {"少", 0x0496}, {"尚", 0x0497},
{"庄", 0x0498}, {"床", 0x0499}, {"彰", 0x049a}, {"承", 0x049b},
{"招", 0x049c}, {"掌", 0x049d}, {"昇", 0x049e}, {"昌", 0x049f},
{"昭", 0x04a0}, {"晶", 0x04a1}, {"松", 0x04a2}, {"沼", 0x04a3},
{"消", 0x04a4}, {"渉", 0x04a5}, {"焼", 0x04a6}, {"焦", 0x04a7},
{"照", 0x04a8}, {"症", 0x04a9}, {"省", 0x04aa}, {"硝", 0x04ab},
{"祥", 0x04ac}, {"称", 0x04ad}, {"章", 0x04ae}, {"笑", 0x04af},
{"粧", 0x04b0}, {"紹", 0x04b1}, {"衝", 0x04b2}, {"裳", 0x04b3},
{"訟", 0x04b4}, {"証", 0x04b5}, {"詳", 0x04b6}, {"象", 0x04b7},
{"賞", 0x04b8}, {"鐘", 0x04b9}, {"障", 0x04ba}, {"上", 0x04bb},
{"丈", 0x04bc}, {"乗", 0x04bd}, {"冗", 0x04be}, {"剰", 0x04bf},
{"城", 0x04c0}, {"場", 0x04c1}, {"嬢", 0x04c2}, {"常", 0x04c3},
{"情", 0x04c4}, {"条", 0x04c5}, {"杖", 0x04c6}, {"浄", 0x04c7},
{"状", 0x04c8}, {"畳", 0x04c9}, {"蒸", 0x04ca}, {"譲", 0x04cb},
{"醸", 0x04cc}, {"嘱", 0x04cd}, {"飾", 0x04ce}, {"拭", 0x04cf},
{"植", 0x04d0}, {"殖", 0x04d1}, {"織", 0x04d2}, {"職", 0x04d3},
{"色", 0x04d4}, {"触", 0x04d5}, {"食", 0x04d6}, {"辱", 0x04d7},
{"尻", 0x04d8}, {"伸", 0x04d9}, {"信", 0x04da}, {"侵", 0x04db},
{"唇", 0x04dc}, {"娠", 0x04dd}, {"寝", 0x04de}, {"審", 0x04df},
{"心", 0x04e0}, {"慎", 0x04e1}, {"振", 0x04e2}, {"新", 0x04e3},
{"森", 0x04e4}, {"浸", 0x04e5}, {"深", 0x04e6}, {"申", 0x04e7},
{"真", 0x04e8}, {"神", 0x04e9}, {"紳", 0x04ea}, {"臣", 0x04eb},
{"芯", 0x04ec}, {"親", 0x04ed}, {"診", 0x04ee}, {"身", 0x04ef},
{"辛", 0x04f0}, {"進", 0x04f1}, {"針", 0x04f2}, {"震", 0x04f3},
{"人", 0x04f4}, {"仁", 0x04f5}, {"刃", 0x04f6}, {"塵", 0x04f7},
{"尋", 0x04f8}, {"訊", 0x04f9}, {"尽", 0x04fa}, {"迅", 0x04fb},
{"陣", 0x04fc}, {"須", 0x04fd}, {"酢", 0x04fe}, {"図", 0x04ff},
{"吹", 0x0500}, {"垂", 0x0501}, {"推", 0x0502}, {"水", 0x0503},
{"睡", 0x0504}, {"粋", 0x0505}, {"衰", 0x0506}, {"遂", 0x0507},
{"酔", 0x0508}, {"随", 0x0509}, {"瑞", 0x050a}, {"髄", 0x050b},
{"崇", 0x050c}, {"数", 0x050d}, {"枢", 0x050e}, {"据", 0x050f},
{"杉", 0x0510}, {"菅", 0x0511}, {"裾", 0x0512}, {"澄", 0x0513},
{"寸", 0x0514}, {"世", 0x0515}, {"瀬", 0x0516}, {"是", 0x0517},
{"凄", 0x0518}, {"制", 0x0519}, {"勢", 0x051a}, {"姓", 0x051b},
{"征", 0x051c}, {"性", 0x051d}, {"成", 0x051e}, {"政", 0x051f},
{"整", 0x0520}, {"星", 0x0521}, {"晴", 0x0522}, {"正", 0x0523},
{"清", 0x0524}, {"牲", 0x0525}, {"生", 0x0526}, {"盛", 0x0527},
{"精", 0x0528}, {"聖", 0x0529}, {"声", 0x052a}, {"製", 0x052b},
{"西", 0x052c}, {"誠", 0x052d}, {"誓", 0x052e}, {"請", 0x052f},
{"青", 0x0530}, {"静", 0x0531}, {"斉", 0x0532}, {"税", 0x0533},
{"脆", 0x0534}, {"隻", 0x0535}, {"席", 0x0536}, {"惜", 0x0537},
{"戚", 0x0538}, {"昔", 0x0539}, {"析", 0x053a}, {"石", 0x053b},
{"積", 0x053c}, {"籍", 0x053d}, {"績", 0x053e}, {"責", 0x053f},
{"赤", 0x0540}, {"跡", 0x0541}, {"切", 0x0542}, {"拙", 0x0543},
{"接", 0x0544}, {"摂", 0x0545}, {"折", 0x0546}, {"設", 0x0547},
{"節", 0x0548}, {"説", 0x0549}, {"雪", 0x054a}, {"絶", 0x054b},
{"舌", 0x054c}, {"仙", 0x054d}, {"先", 0x054e}, {"千", 0x054f},
{"占", 0x0550}, {"宣", 0x0551}, {"専", 0x0552}, {"尖", 0x0553},
{"川", 0x0554}, {"戦", 0x0555}, {"扇", 0x0556}, {"栓", 0x0557},
{"泉", 0x0558}, {"浅", 0x0559}, {"洗", 0x055a}, {"染", 0x055b},
{"潜", 0x055c}, {"煽", 0x055d}, {"旋", 0x055e}, {"線", 0x055f},
{"繊", 0x0560}, {"羨", 0x0561}, {"船", 0x0562}, {"薦", 0x0563},
{"詮", 0x0564}, {"践", 0x0565}, {"選", 0x0566}, {"閃", 0x0567},
{"鮮", 0x0568}, {"前", 0x0569}, {"善", 0x056a}, {"然", 0x056b},
{"全", 0x056c}, {"禅", 0x056d}, {"繕", 0x056e}, {"措", 0x056f},
{"楚", 0x0570}, {"狙", 0x0571}, {"疎", 0x0572}, {"礎", 0x0573},
{"祖", 0x0574}, {"租", 0x0575}, {"粗", 0x0576}, {"素", 0x0577},
{"組", 0x0578}, {"蘇", 0x0579}, {"訴", 0x057a}, {"阻", 0x057b},
{"僧", 0x057c}, {"創", 0x057d}, {"双", 0x057e}, {"倉", 0x057f},
{"喪", 0x0580}, {"壮", 0x0581}, {"奏", 0x0582}, {"層", 0x0583},
{"想", 0x0584}, {"捜", 0x0585}, {"掃", 0x0586}, {"挿", 0x0587},
{"掻", 0x0588}, {"操", 0x0589}, {"早", 0x058a}, {"巣", 0x058b},
{"燥", 0x058c}, {"争", 0x058d}, {"痩", 0x058e}, {"相", 0x058f},
{"窓", 0x0590}, {"総", 0x0591}, {"草", 0x0592}, {"荘", 0x0593},
{"葬", 0x0594}, {"蒼", 0x0595}, {"装", 0x0596}, {"走", 0x0597},
{"送", 0x0598}, {"遭", 0x0599}, {"騒", 0x059a}, {"像", 0x059b},
{"増", 0x059c}, {"憎", 0x059d}, {"臓", 0x059e}, {"蔵", 0x059f},
{"贈", 0x05a0}, {"造", 0x05a1}, {"促", 0x05a2}, {"側", 0x05a3},
{"則", 0x05a4}, {"即", 0x05a5}, {"息", 0x05a6}, {"束", 0x05a7},
{"測", 0x05a8}, {"足", 0x05a9}, {"速", 0x05aa}, {"俗", 0x05ab},
{"属", 0x05ac}, {"賊", 0x05ad}, {"族", 0x05ae}, {"続", 0x05af},
{"卒", 0x05b0}, {"袖", 0x05b1}, {"其", 0x05b2}, {"揃", 0x05b3},
{"存", 0x05b4}, {"孫", 0x05b5}, {"尊", 0x05b6}, {"損", 0x05b7},
{"村", 0x05b8}, {"他", 0x05b9}, {"多", 0x05ba}, {"太", 0x05bb},
{"汰", 0x05bc}, {"唾", 0x05bd}, {"妥", 0x05be}, {"打", 0x05bf},
{"駄", 0x05c0}, {"体", 0x05c1}, {"対", 0x05c2}, {"耐", 0x05c3},
{"帯", 0x05c4}, {"待", 0x05c5}, {"怠", 0x05c6}, {"態", 0x05c7},
{"戴", 0x05c8}, {"替", 0x05c9}, {"泰", 0x05ca}, {"胎", 0x05cb},
{"袋", 0x05cc}, {"貸", 0x05cd}, {"退", 0x05ce}, {"隊", 0x05cf},
{"代", 0x05d0}, {"台", 0x05d1}, {"大", 0x05d2}, {"第", 0x05d3},
{"題", 0x05d4}, {"滝", 0x05d5}, {"卓", 0x05d6}, {"宅", 0x05d7},
{"択", 0x05d8}, {"拓", 0x05d9}, {"沢", 0x05da}, {"濯", 0x05db},
{"託", 0x05dc}, {"濁", 0x05dd}, {"諾", 0x05de}, {"叩", 0x05df},
{"但", 0x05e0}, {"達", 0x05e1}, {"奪", 0x05e2}, {"脱", 0x05e3},
{"辿", 0x05e4}, {"谷", 0x05e5}, {"誰", 0x05e6}, {"丹", 0x05e7},
{"単", 0x05e8}, {"嘆", 0x05e9}, {"担", 0x05ea}, {"探", 0x05eb},
{"旦", 0x05ec}, {"淡", 0x05ed}, {"炭", 0x05ee}, {"短", 0x05ef},
{"端", 0x05f0}, {"胆", 0x05f1}, {"誕", 0x05f2}, {"団", 0x05f3},
{"壇", 0x05f4}, {"弾", 0x05f5}, {"断", 0x05f6}, {"暖", 0x05f7},
{"段", 0x05f8}, {"男", 0x05f9}, {"談", 0x05fa}, {"値", 0x05fb},
{"知", 0x05fc}, {"地", 0x05fd}, {"恥", 0x05fe}, {"池", 0x05ff},
{"痴", 0x0600}, {"稚", 0x0601}, {"置", 0x0602}, {"致", 0x0603},
{"遅", 0x0604}, {"築", 0x0605}, {"畜", 0x0606}, {"竹", 0x0607},
{"蓄", 0x0608}, {"逐", 0x0609}, {"秩", 0x060a}, {"窒", 0x060b},
{"茶", 0x060c}, {"着", 0x060d}, {"中", 0x060e}, {"仲", 0x060f},
{"宙", 0x0610}, {"忠", 0x0611}, {"抽", 0x0612}, {"昼", 0x0613},
{"柱", 0x0614}, {"注", 0x0615}, {"虫", 0x0616}, {"酎", 0x0617},
{"鋳", 0x0618}, {"駐", 0x0619}, {"著", 0x061a}, {"貯", 0x061b},
{"丁", 0x061c}, {"兆", 0x061d}, {"喋", 0x061e}, {"帳", 0x061f},
{"庁", 0x0620}, {"張", 0x0621}, {"彫", 0x0622}, {"徴", 0x0623},
{"懲", 0x0624}, {"挑", 0x0625}, {"暢", 0x0626}, {"朝", 0x0627},
{"潮", 0x0628}, {"町", 0x0629}, {"眺", 0x062a}, {"聴", 0x062b},
{"腸", 0x062c}, {"調", 0x062d}, {"超", 0x062e}, {"跳", 0x062f},
{"長", 0x0630}, {"頂", 0x0631}, {"鳥", 0x0632}, {"直", 0x0633},
{"沈", 0x0634}, {"珍", 0x0635}, {"賃", 0x0636}, {"鎮", 0x0637},
{"陳", 0x0638}, {"津", 0x0639}, {"墜", 0x063a}, {"追", 0x063b},
{"痛", 0x063c}, {"通", 0x063d}, {"塚", 0x063e}, {"掴", 0x063f},
{"辻", 0x0640}, {"潰", 0x0641}, {"坪", 0x0642}, {"爪", 0x0643},
{"釣", 0x0644}, {"鶴", 0x0645}, {"亭", 0x0646}, {"低", 0x0647},
{"停", 0x0648}, {"偵", 0x0649}, {"貞", 0x064a}, {"呈", 0x064b},
{"堤", 0x064c}, {"定", 0x064d}, {"帝", 0x064e}, {"底", 0x064f},
{"庭", 0x0650}, {"弟", 0x0651}, {"抵", 0x0652}, {"提", 0x0653},
{"程", 0x0654}, {"締", 0x0655}, {"艇", 0x0656}, {"訂", 0x0657},
{"諦", 0x0658}, {"邸", 0x0659}, {"釘", 0x065a}, {"泥", 0x065b},
{"摘", 0x065c}, {"敵", 0x065d}, {"滴", 0x065e}, {"的", 0x065f},
{"笛", 0x0660}, {"適", 0x0661}, {"溺", 0x0662}, {"哲", 0x0663},
{"徹", 0x0664}, {"撤", 0x0665}, {"鉄", 0x0666}, {"典", 0x0667},
{"天", 0x0668}, {"展", 0x0669}, {"店", 0x066a}, {"添", 0x066b},
{"纏", 0x066c}, {"貼", 0x066d}, {"転", 0x066e}, {"点", 0x066f},
{"伝", 0x0670}, {"殿", 0x0671}, {"田", 0x0672}, {"電", 0x0673},
{"吐", 0x0674}, {"堵", 0x0675}, {"塗", 0x0676}, {"妬", 0x0677},
{"徒", 0x0678}, {"斗", 0x0679}, {"渡", 0x067a}, {"登", 0x067b},
{"賭", 0x067c}, {"途", 0x067d}, {"都", 0x067e}, {"努", 0x067f},
{"度", 0x0680}, {"土", 0x0681}, {"奴", 0x0682}, {"怒", 0x0683},
{"倒", 0x0684}, {"党", 0x0685}, {"冬", 0x0686}, {"凍", 0x0687},
{"刀", 0x0688}, {"唐", 0x0689}, {"塔", 0x068a}, {"島", 0x068b},
{"投", 0x068c}, {"東", 0x068d}, {"桃", 0x068e}, {"棟", 0x068f},
{"盗", 0x0690}, {"湯", 0x0691}, {"涛", 0x0692}, {"灯", 0x0693},
{"当", 0x0694}, {"等", 0x0695}, {"答", 0x0696}, {"筒", 0x0697},
{"糖", 0x0698}, {"統", 0x0699}, {"到", 0x069a}, {"藤", 0x069b},
{"討", 0x069c}, {"豆", 0x069d}, {"踏", 0x069e}, {"逃", 0x069f},
{"透", 0x06a0}, {"陶", 0x06a1}, {"頭", 0x06a2}, {"闘", 0x06a3},
{"働", 0x06a4}, {"動", 0x06a5}, {"同", 0x06a6}, {"堂", 0x06a7},
{"導", 0x06a8}, {"憧", 0x06a9}, {"瞳", 0x06aa}, {"童", 0x06ab},
{"胴", 0x06ac}, {"道", 0x06ad}, {"銅", 0x06ae}, {"峠", 0x06af},
{"得", 0x06b0}, {"徳", 0x06b1}, {"特", 0x06b2}, {"督", 0x06b3},
{"毒", 0x06b4}, {"独", 0x06b5}, {"読", 0x06b6}, {"突", 0x06b7},
{"届", 0x06b8}, {"寅", 0x06b9}, {"沌", 0x06ba}, {"豚", 0x06bb},
{"頓", 0x06bc}, {"呑", 0x06bd}, {"曇", 0x06be}, {"鈍", 0x06bf},
{"奈", 0x06c0}, {"那", 0x06c1}, {"内", 0x06c2}, {"謎", 0x06c3},
{"馴", 0x06c4}, {"南", 0x06c5}, {"軟", 0x06c6}, {"難", 0x06c7},
{"二", 0x06c8}, {"尼", 0x06c9}, {"匂", 0x06ca}, {"賑", 0x06cb},
{"肉", 0x06cc}, {"日", 0x06cd}, {"乳", 0x06ce}, {"入", 0x06cf},
{"如", 0x06d0}, {"尿", 0x06d1}, {"任", 0x06d2}, {"妊", 0x06d3},
{"忍", 0x06d4}, {"認", 0x06d5}, {"濡", 0x06d6}, {"寧", 0x06d7},
{"猫", 0x06d8}, {"熱", 0x06d9}, {"年", 0x06da}, {"念", 0x06db},
{"捻", 0x06dc}, {"燃", 0x06dd}, {"粘", 0x06de}, {"乃", 0x06df},
{"之", 0x06e0}, {"悩", 0x06e1}, {"濃", 0x06e2}, {"納", 0x06e3},
{"能", 0x06e4}, {"脳", 0x06e5}, {"農", 0x06e6}, {"覗", 0x06e7},
{"把", 0x06e8}, {"播", 0x06e9}, {"波", 0x06ea}, {"派", 0x06eb},
{"破", 0x06ec}, {"婆", 0x06ed}, {"馬", 0x06ee}, {"俳", 0x06ef},
{"廃", 0x06f0}, {"拝", 0x06f1}, {"排", 0x06f2}, {"敗", 0x06f3},
{"杯", 0x06f4}, {"背", 0x06f5}, {"肺", 0x06f6}, {"輩", 0x06f7},
{"配", 0x06f8}, {"倍", 0x06f9}, {"培", 0x06fa}, {"梅", 0x06fb},
{"買", 0x06fc}, {"売", 0x06fd}, {"賠", 0x06fe}, {"這", 0x06ff},
{"伯", 0x0700}, {"剥", 0x0701}, {"博", 0x0702}, {"拍", 0x0703},
{"泊", 0x0704}, {"白", 0x0705}, {"舶", 0x0706}, {"薄", 0x0707},
{"迫", 0x0708}, {"漠", 0x0709}, {"爆", 0x070a}, {"縛", 0x070b},
{"麦", 0x070c}, {"箱", 0x070d}, {"幡", 0x070e}, {"肌", 0x070f},
{"畑", 0x0710}, {"八", 0x0711}, {"発", 0x0712}, {"髪", 0x0713},
{"伐", 0x0714}, {"罰", 0x0715}, {"抜", 0x0716}, {"鳩", 0x0717},
{"伴", 0x0718}, {"判", 0x0719}, {"半", 0x071a}, {"反", 0x071b},
{"帆", 0x071c}, {"搬", 0x071d}, {"板", 0x071e}, {"版", 0x071f},
{"犯", 0x0720}, {"班", 0x0721}, {"畔", 0x0722}, {"繁", 0x0723},
{"般", 0x0724}, {"販", 0x0725}, {"範", 0x0726}, {"晩", 0x0727},
{"番", 0x0728}, {"盤", 0x0729}, {"蛮", 0x072a}, {"卑", 0x072b},
{"否", 0x072c}, {"妃", 0x072d}, {"彼", 0x072e}, {"悲", 0x072f},
{"扉", 0x0730}, {"批", 0x0731}, {"披", 0x0732}, {"比", 0x0733},
{"泌", 0x0734}, {"疲", 0x0735}, {"皮", 0x0736}, {"秘", 0x0737},
{"肥", 0x0738}, {"被", 0x0739}, {"費", 0x073a}, {"避", 0x073b},
{"非", 0x073c}, {"飛", 0x073d}, {"備", 0x073e}, {"尾", 0x073f},
{"微", 0x0740}, {"眉", 0x0741}, {"美", 0x0742}, {"鼻", 0x0743},
{"匹", 0x0744}, {"彦", 0x0745}, {"膝", 0x0746}, {"菱", 0x0747},
{"肘", 0x0748}, {"必", 0x0749}, {"筆", 0x074a}, {"姫", 0x074b},
{"百", 0x074c}, {"俵", 0x074d}, {"標", 0x074e}, {"氷", 0x074f},
{"漂", 0x0750}, {"票", 0x0751}, {"表", 0x0752}, {"評", 0x0753},
{"描", 0x0754}, {"病", 0x0755}, {"秒", 0x0756}, {"苗", 0x0757},
{"品", 0x0758}, {"浜", 0x0759}, {"貧", 0x075a}, {"頻", 0x075b},
{"敏", 0x075c}, {"瓶", 0x075d}, {"不", 0x075e}, {"付", 0x075f},
{"夫", 0x0760}, {"婦", 0x0761}, {"富", 0x0762}, {"布", 0x0763},
{"府", 0x0764}, {"怖", 0x0765}, {"扶", 0x0766}, {"敷", 0x0767},
{"普", 0x0768}, {"浮", 0x0769}, {"父", 0x076a}, {"符", 0x076b},
{"腐", 0x076c}, {"膚", 0x076d}, {"負", 0x076e}, {"賦", 0x076f},
{"赴", 0x0770}, {"侮", 0x0771}, {"撫", 0x0772}, {"武", 0x0773},
{"舞", 0x0774}, {"部", 0x0775}, {"封", 0x0776}, {"風", 0x0777},
{"伏", 0x0778}, {"副", 0x0779}, {"復", 0x077a}, {"幅", 0x077b},
{"服", 0x077c}, {"福", 0x077d}, {"腹", 0x077e}, {"複", 0x077f},
{"覆", 0x0780}, {"淵", 0x0781}, {"払", 0x0782}, {"沸", 0x0783},
{"仏", 0x0784}, {"物", 0x0785}, {"分", 0x0786}, {"吻", 0x0787},
{"憤", 0x0788}, {"奮", 0x0789}, {"粉", 0x078a}, {"紛", 0x078b},
{"雰", 0x078c}, {"文", 0x078d}, {"聞", 0x078e}, {"丙", 0x078f},
{"併", 0x0790}, {"兵", 0x0791}, {"幣", 0x0792}, {"平", 0x0793},
{"柄", 0x0794}, {"並", 0x0795}, {"閉", 0x0796}, {"米", 0x0797},
{"壁", 0x0798}, {"癖", 0x0799}, {"別", 0x079a}, {"蔑", 0x079b},
{"偏", 0x079c}, {"変", 0x079d}, {"片", 0x079e}, {"編", 0x079f},
{"辺", 0x07a0}, {"返", 0x07a1}, {"遍", 0x07a2}, {"便", 0x07a3},
{"勉", 0x07a4}, {"弁", 0x07a5}, {"保", 0x07a6}, {"舗", 0x07a7},
{"捕", 0x07a8}, {"歩", 0x07a9}, {"補", 0x07aa}, {"穂", 0x07ab},
{"募", 0x07ac}, {"墓", 0x07ad}, {"慕", 0x07ae}, {"暮", 0x07af},
{"母", 0x07b0}, {"簿", 0x07b1}, {"俸", 0x07b2}, {"包", 0x07b3},
{"呆", 0x07b4}, {"報", 0x07b5}, {"奉", 0x07b6}, {"宝", 0x07b7},
{"峰", 0x07b8}, {"崩", 0x07b9}, {"抱", 0x07ba}, {"放", 0x07bb},
{"方", 0x07bc}, {"法", 0x07bd}, {"泡", 0x07be}, {"砲", 0x07bf},
{"縫", 0x07c0}, {"胞", 0x07c1}, {"芳", 0x07c2}, {"褒", 0x07c3},
{"訪", 0x07c4}, {"豊", 0x07c5}, {"邦", 0x07c6}, {"飽", 0x07c7},
{"乏", 0x07c8}, {"亡", 0x07c9}, {"傍", 0x07ca}, {"剖", 0x07cb},
{"坊", 0x07cc}, {"妨", 0x07cd}, {"帽", 0x07ce}, {"忘", 0x07cf},
{"忙", 0x07d0}, {"房", 0x07d1}, {"暴", 0x07d2}, {"望", 0x07d3},
{"某", 0x07d4}, {"棒", 0x07d5}, {"冒", 0x07d6}, {"紡", 0x07d7},
{"肪", 0x07d8}, {"膨", 0x07d9}, {"謀", 0x07da}, {"貌", 0x07db},
{"貿", 0x07dc}, {"防", 0x07dd}, {"吠", 0x07de}, {"頬", 0x07df},
{"北", 0x07e0}, {"僕", 0x07e1}, {"墨", 0x07e2}, {"撲", 0x07e3},
{"牧", 0x07e4}, {"勃", 0x07e5}, {"没", 0x07e6}, {"奔", 0x07e7},
{"本", 0x07e8}, {"翻", 0x07e9}, {"凡", 0x07ea}, {"摩", 0x07eb},
{"磨", 0x07ec}, {"魔", 0x07ed}, {"麻", 0x07ee}, {"埋", 0x07ef},
{"妹", 0x07f0}, {"昧", 0x07f1}, {"枚", 0x07f2}, {"毎", 0x07f3},
{"幕", 0x07f4}, {"膜", 0x07f5}, {"枕", 0x07f6}, {"又", 0x07f7},
{"末", 0x07f8}, {"迄", 0x07f9}, {"万", 0x07fa}, {"慢", 0x07fb},
{"満", 0x07fc}, {"漫", 0x07fd}, {"味", 0x07fe}, {"未", 0x07ff},
{"魅", 0x0800}, {"密", 0x0801}, {"蜜", 0x0802}, {"脈", 0x0803},
{"妙", 0x0804}, {"民", 0x0805}, {"眠", 0x0806}, {"務", 0x0807},
{"夢", 0x0808}, {"無", 0x0809}, {"霧", 0x080a}, {"娘", 0x080b},
{"名", 0x080c}, {"命", 0x080d}, {"明", 0x080e}, {"盟", 0x080f},
{"迷", 0x0810}, {"銘", 0x0811}, {"鳴", 0x0812}, {"滅", 0x0813},
{"免", 0x0814}, {"綿", 0x0815}, {"面", 0x0816}, {"模", 0x0817},
{"茂", 0x0818}, {"妄", 0x0819}, {"毛", 0x081a}, {"猛", 0x081b},
{"盲", 0x081c}, {"網", 0x081d}, {"耗", 0x081e}, {"木", 0x081f},
{"黙", 0x0820}, {"目", 0x0821}, {"戻", 0x0822}, {"貰", 0x0823},
{"問", 0x0824}, {"悶", 0x0825}, {"紋", 0x0826}, {"門", 0x0827},
{"匁", 0x0828}, {"也", 0x0829}, {"夜", 0x082a}, {"野", 0x082b},
{"弥", 0x082c}, {"矢", 0x082d}, {"厄", 0x082e}, {"役", 0x082f},
{"約", 0x0830}, {"薬", 0x0831}, {"訳", 0x0832}, {"躍", 0x0833},
{"柳", 0x0834}, {"愉", 0x0835}, {"油", 0x0836}, {"癒", 0x0837},
{"諭", 0x0838}, {"輸", 0x0839}, {"唯", 0x083a}, {"優", 0x083b},
{"勇", 0x083c}, {"友", 0x083d}, {"幽", 0x083e}, {"憂", 0x083f},
{"有", 0x0840}, {"猶", 0x0841}, {"由", 0x0842}, {"祐", 0x0843},
{"裕", 0x0844}, {"誘", 0x0845}, {"遊", 0x0846}, {"郵", 0x0847},
{"雄", 0x0848}, {"融", 0x0849}, {"夕", 0x084a}, {"予", 0x084b},
{"余", 0x084c}, {"与", 0x084d}, {"誉", 0x084e}, {"預", 0x084f},
{"幼", 0x0850}, {"妖", 0x0851}, {"容", 0x0852}, {"揚", 0x0853},
{"揺", 0x0854}, {"曜", 0x0855}, {"様", 0x0856}, {"洋", 0x0857},
{"溶", 0x0858}, {"用", 0x0859}, {"羊", 0x085a}, {"葉", 0x085b},
{"要", 0x085c}, {"踊", 0x085d}, {"遥", 0x085e}, {"陽", 0x085f},
{"養", 0x0860}, {"抑", 0x0861}, {"欲", 0x0862}, {"浴", 0x0863},
{"翌", 0x0864}, {"翼", 0x0865}, {"羅", 0x0866}, {"裸", 0x0867},
{"来", 0x0868}, {"頼", 0x0869}, {"雷", 0x086a}, {"絡", 0x086b},
{"落", 0x086c}, {"酪", 0x086d}, {"乱", 0x086e}, {"卵", 0x086f},
{"欄", 0x0870}, {"藍", 0x0871}, {"覧", 0x0872}, {"利", 0x0873},
{"吏", 0x0874}, {"履", 0x0875}, {"理", 0x0876}, {"璃", 0x0877},
{"裏", 0x0878}, {"里", 0x0879}, {"離", 0x087a}, {"陸", 0x087b},
{"律", 0x087c}, {"率", 0x087d}, {"立", 0x087e}, {"略", 0x087f},
{"流", 0x0880}, {"溜", 0x0881}, {"留", 0x0882}, {"粒", 0x0883},
{"隆", 0x0884}, {"竜", 0x0885}, {"龍", 0x0886}, {"慮", 0x0887},
{"旅", 0x0888}, {"虜", 0x0889}, {"僚", 0x088a}, {"両", 0x088b},
{"凌", 0x088c}, {"寮", 0x088d}, {"料", 0x088e}, {"涼", 0x088f},
{"猟", 0x0890}, {"療", 0x0891}, {"瞭", 0x0892}, {"良", 0x0893},
{"量", 0x0894}, {"陵", 0x0895}, {"領", 0x0896}, {"力", 0x0897},
{"緑", 0x0898}, {"林", 0x0899}, {"臨", 0x089a}, {"輪", 0x089b},
{"隣", 0x089c}, {"瑠", 0x089d}, {"塁", 0x089e}, {"涙", 0x089f},
{"累", 0x08a0}, {"類", 0x08a1}, {"令", 0x08a2}, {"例", 0x08a3},
{"冷", 0x08a4}, {"励", 0x08a5}, {"礼", 0x08a6}, {"鈴", 0x08a7},
{"隷", 0x08a8}, {"零", 0x08a9}, {"霊", 0x08aa}, {"麗", 0x08ab},
{"齢", 0x08ac}, {"暦", 0x08ad}, {"歴", 0x08ae}, {"列", 0x08af},
{"劣", 0x08b0}, {"烈", 0x08b1}, {"裂", 0x08b2}, {"廉", 0x08b3},
{"恋", 0x08b4}, {"憐", 0x08b5}, {"練", 0x08b6}, {"連", 0x08b7},
{"錬", 0x08b8}, {"炉", 0x08b9}, {"路", 0x08ba}, {"露", 0x08bb},
{"労", 0x08bc}, {"廊", 0x08bd}, {"朗", 0x08be}, {"楼", 0x08bf},
{"浪", 0x08c0}, {"漏", 0x08c1}, {"篭", 0x08c2}, {"老", 0x08c3},
{"郎", 0x08c4}, {"六", 0x08c5}, {"録", 0x08c6}, {"論", 0x08c7},
{"和", 0x08c8}, {"話", 0x08c9}, {"歪", 0x08ca}, {"脇", 0x08cb},
{"惑", 0x08cc}, {"枠", 0x08cd}, {"鷲", 0x08ce}, {"湾", 0x08cf},
{"腕", 0x08d0}, {"呟", 0x08d1}, {"呻", 0x08d2}, {"咄", 0x08d3},
{"咬", 0x08d4}, {"喘", 0x08d5}, {"嗚", 0x08d6}, {"嗅", 0x08d7},
{"嗟", 0x08d8}, {"嘔", 0x08d9}, {"嘲", 0x08da}, {"囁", 0x08db},
{"奢", 0x08dc}, {"恍", 0x08dd}, {"愕", 0x08de}, {"慄", 0x08df},
{"憑", 0x08e0}, {"戮", 0x08e1}, {"拗", 0x08e2}, {"揉", 0x08e3},
{"攣", 0x08e4}, {"曖", 0x08e5}, {"泄", 0x08e6}, {"洒", 0x08e7},
{"渾", 0x08e8}, {"滲", 0x08e9}, {"焉", 0x08ea}, {"猥", 0x08eb},
{"痙", 0x08ec}, {"痺", 0x08ed}, {"癇", 0x08ee}, {"癲", 0x08ef},
{"眩", 0x08f0}, {"睨", 0x08f1}, {"瞼", 0x08f2}, {"綺", 0x08f3},
{"罠", 0x08f4}, {"羞", 0x08f5}, {"腑", 0x08f6}, {"膣", 0x08f7},
{"臀", 0x08f8}, {"茫", 0x08f9}, {"訝", 0x08fa}, {"踵", 0x08fb},
{"騙", 0x08fc}, {"◎", 0x08fd}, {"梓", 0x08fe}, {"窺", 0x08ff},
{"苛", 0x0900}, {"牙", 0x0901}, {"駕", 0x0902}, {"崖", 0x0903},
{"缶", 0x0904}, {"鑑", 0x0905}, {"亀", 0x0906}, {"汲", 0x0907},
{"喰", 0x0908}, {"牽", 0x0909}, {"虎", 0x090a}, {"巷", 0x090b},
{"腔", 0x090c}, {"忽", 0x090d}, {"些", 0x090e}, {"皿", 0x090f},
{"朱", 0x0910}, {"愁", 0x0911}, {"盾", 0x0912}, {"逝", 0x0913},
{"醒", 0x0914}, {"蝉", 0x0915}, {"噌", 0x0916}, {"遡", 0x0917},
{"惰", 0x0918}, {"滞", 0x0919}, {"狸", 0x091a}, {"弛", 0x091b},
{"兎", 0x091c}, {"鍋", 0x091d}, {"罵", 0x091e}, {"柏", 0x091f},
{"箸", 0x0920}, {"鉢", 0x0921}, {"閥", 0x0922}, {"飯", 0x0923},
{"紐", 0x0924}, {"楓", 0x0925}, {"噴", 0x0926}, {"塀", 0x0927},
{"弊", 0x0928}, {"陛", 0x0929}, {"瞥", 0x092a}, {"朴", 0x092b},
{"殆", 0x092c}, {"矛", 0x092d}, {"姪", 0x092e}, {"儲", 0x092f},
{"餅", 0x0930}, {"爺", 0x0931}, {"涌", 0x0932}, {"嵐", 0x0933},
{"掠", 0x0934}, {"糧", 0x0935}, {"呂", 0x0936}, {"弄", 0x0937},
{"椀", 0x0938}, {"碗", 0x0939}, {"俯", 0x093a}, {"儚", 0x093b},
{"埒", 0x093c}, {"徊", 0x093d}, {"徘", 0x093e}, {"晰", 0x093f},
{"枷", 0x0940}, {"檻", 0x0941}, {"鬱", 0x0942}, {"涸", 0x0943},
{"皺", 0x0944}, {"胱", 0x0945}, {"膀", 0x0946}, {"贅", 0x0947},
{"躇", 0x0948}, {"躊", 0x0949}, {"躰", 0x094a}, {"頷", 0x094b},
{"鯱", 0x094c}, {"苔", 0x094d}, {"哉", 0x094e}, {"惹", 0x094f},
{"巾", 0x0950}, {"曰", 0x0951}, {"畏", 0x0952}, {"萎", 0x0953},
{"伽", 0x0954}, {"蚊", 0x0955}, {"拐", 0x0956}, {"涯", 0x0957},
{"渇", 0x0958}, {"堪", 0x0959}, {"稀", 0x095a}, {"撒", 0x095b},
{"錠", 0x095c}, {"蝕", 0x095d}, {"靭", 0x095e}, {"錐", 0x095f},
{"爽", 0x0960}, {"耽", 0x0961}, {"智", 0x0962}, {"漬", 0x0963},
{"洞", 0x0964}, {"縄", 0x0965}, {"覇", 0x0966}, {"莫", 0x0967},
{"斑", 0x0968}, {"斐", 0x0969}, {"沫", 0x096a}, {"擁", 0x096b},
{"肋", 0x096c}, {"刹", 0x096d}, {"吼", 0x096e}, {"咆", 0x096f},
{"咤", 0x0970}, {"哮", 0x0971}, {"唸", 0x0972}, {"峙", 0x0973},
{"撼", 0x0974}, {"朦", 0x0975}, {"朧", 0x0976}, {"璧", 0x0977},
{"眸", 0x0978}, {"絆", 0x0979}, {"舐", 0x097a}, {"軋", 0x097b},
{"阿", 0x097c}, {"緯", 0x097d}, {"訣", 0x097e}, {"昂", 0x097f},
{"棲", 0x0980}, {"壷", 0x0981}, {"薙", 0x0982}, {"捧", 0x0983},
{"湧", 0x0984}, {"詫", 0x0985}, {"揶", 0x0986}, {"揄", 0x0987},
{"炒", 0x0988}, {"蠢", 0x0989}, {"蹲", 0x098a}, {"迸", 0x098b},
{"槽", 0x098c}, {"狽", 0x098d}, {"瀕", 0x098e}, {"狼", 0x098f},
{"丼", 0x0990}, {"屹", 0x0991}, {"煌", 0x0992}, {"廻", 0x0993},
{"囚", 0x0994}, {"掟", 0x0995}, {"葛", 0x0996}, {"串", 0x0997},
{"弦", 0x0998}, {"腫", 0x0999}, {"妾", 0x099a}, {"寵", 0x099b},
{"凪", 0x099c}, {"涎", 0x099d}, {"炸", 0x099e}, {"翔", 0x099f},
{"怨", 0x09a0}, {"喚", 0x09a1}, {"窟", 0x09a2}, {"坑", 0x09a3},
{"吊", 0x09a4}, {"悠", 0x09a5}, {"珀", 0x09a6}, {"琥", 0x09a7},
{"貪", 0x09a8}, {"躓", 0x09a9}, {"讐", 0x09aa}, {"逮", 0x09ab},
{"嬌", 0x09ac}, {"餐", 0x09ad}, {"醤", 0x09ae}, {"腎", 0x09af},
{"銭", 0x09b0}, {"鯛", 0x09b1}, {"燗", 0x09b2}, {"脾", 0x09b3},
{"葵", 0x09b4}, {"茜", 0x09b5}, {"渥", 0x09b6}, {"旭", 0x09b7},
{"綾", 0x09b8}, {"鮎", 0x09b9}, {"杏", 0x09ba}, {"惟", 0x09bb},
{"亥", 0x09bc}, {"郁", 0x09bd}, {"磯", 0x09be}, {"壱", 0x09bf},
{"允", 0x09c0}, {"胤", 0x09c1}, {"卯", 0x09c2}, {"丑", 0x09c3},
{"瑛", 0x09c4}, {"詠", 0x09c5}, {"謁", 0x09c6}, {"苑", 0x09c7},
{"翁", 0x09c8}, {"寡", 0x09c9}, {"劾", 0x09ca}, {"馨", 0x09cb},
{"且", 0x09cc}, {"鎌", 0x09cd}, {"刈", 0x09ce}, {"棺", 0x09cf},
{"岸", 0x09d0}, {"巌", 0x09d1}, {"毅", 0x09d2}, {"騎", 0x09d3},
{"欺", 0x09d4}, {"橘", 0x09d5}, {"糾", 0x09d6}, {"亨", 0x09d7},
{"匡", 0x09d8}, {"喬", 0x09d9}, {"峡", 0x09da}, {"尭", 0x09db},
{"桐", 0x09dc}, {"錦", 0x09dd}, {"欣", 0x09de}, {"欽", 0x09df},
{"吟", 0x09e0}, {"矩", 0x09e1}, {"駒", 0x09e2}, {"虞", 0x09e3},
{"薫", 0x09e4}, {"圭", 0x09e5}, {"慧", 0x09e6}, {"茎", 0x09e7},
{"顕", 0x09e8}, {"弧", 0x09e9}, {"伍", 0x09ea}, {"鯉", 0x09eb},
{"侯", 0x09ec}, {"宏", 0x09ed}, {"晃", 0x09ee}, {"浩", 0x09ef},
{"紘", 0x09f0}, {"衡", 0x09f1}, {"酵", 0x09f2}, {"穀", 0x09f3},
{"唆", 0x09f4}, {"詐", 0x09f5}, {"冴", 0x09f6}, {"搾", 0x09f7},
{"笹", 0x09f8}, {"諮", 0x09f9}, {"爾", 0x09fa}, {"璽", 0x09fb},
{"汐", 0x09fc}, {"紗", 0x09fd}, {"爵", 0x09fe}, {"儒", 0x09ff},
{"峻", 0x0a00}, {"准", 0x0a01}, {"殉", 0x0a02}, {"淳", 0x0a03},
{"遵", 0x0a04}, {"渚", 0x0a05}, {"匠", 0x0a06}, {"抄", 0x0a07},
{"梢", 0x0a08}, {"礁", 0x0a09}, {"肖", 0x0a0a}, {"詔", 0x0a0b},
{"丞", 0x0a0c}, {"穣", 0x0a0d}, {"晋", 0x0a0e}, {"薪", 0x0a0f},
{"甚", 0x0a10}, {"帥", 0x0a11}, {"炊", 0x0a12}, {"翠", 0x0a13},
{"錘", 0x0a14}, {"嵩", 0x0a15}, {"畝", 0x0a16}, {"斥", 0x0a17},
{"窃", 0x0a18}, {"遷", 0x0a19}, {"銑", 0x0a1a}, {"漸", 0x0a1b},
{"塑", 0x0a1c}, {"惣", 0x0a1d}, {"聡", 0x0a1e}, {"霜", 0x0a1f},
{"堕", 0x0a20}, {"鷹", 0x0a21}, {"琢", 0x0a22}, {"只", 0x0a23},
{"辰", 0x0a24}, {"鍛", 0x0a25}, {"嫡", 0x0a26}, {"衷", 0x0a27},
{"猪", 0x0a28}, {"弔", 0x0a29}, {"脹", 0x0a2a}, {"蝶", 0x0a2b},
{"勅", 0x0a2c}, {"朕", 0x0a2d}, {"蔦", 0x0a2e}, {"廷", 0x0a2f},
{"悌", 0x0a30}, {"禎", 0x0a31}, {"逓", 0x0a32}, {"迭", 0x0a33},
{"悼", 0x0a34}, {"燈", 0x0a35}, {"痘", 0x0a36}, {"謄", 0x0a37},
{"騰", 0x0a38}, {"匿", 0x0a39}, {"篤", 0x0a3a}, {"酉", 0x0a3b},
{"惇", 0x0a3c}, {"敦", 0x0a3d}, {"楠", 0x0a3e}, {"弐", 0x0a3f},
{"虹", 0x0a40}, {"巴", 0x0a41}, {"媒", 0x0a42}, {"陪", 0x0a43},
{"萩", 0x0a44}, {"肇", 0x0a45}, {"隼", 0x0a46}, {"藩", 0x0a47},
{"煩", 0x0a48}, {"頒", 0x0a49}, {"碑", 0x0a4a}, {"緋", 0x0a4b},
{"罷", 0x0a4c}, {"彬", 0x0a4d}, {"賓", 0x0a4e}, {"芙", 0x0a4f},
{"譜", 0x0a50}, {"附", 0x0a51}, {"蕗", 0x0a52}, {"墳", 0x0a53},
{"碧", 0x0a54}, {"甫", 0x0a55}, {"輔", 0x0a56}, {"倣", 0x0a57},
{"朋", 0x0a58}, {"萌", 0x0a59}, {"睦", 0x0a5a}, {"盆", 0x0a5b},
{"槙", 0x0a5c}, {"亦", 0x0a5d}, {"繭", 0x0a5e}, {"麿", 0x0a5f},
{"巳", 0x0a60}, {"稔", 0x0a61}, {"婿", 0x0a62}, {"孟", 0x0a63},
{"耶", 0x0a64}, {"靖", 0x0a65}, {"佑", 0x0a66}, {"庸", 0x0a67},
{"窯", 0x0a68}, {"蓉", 0x0a69}, {"謡", 0x0a6a}, {"濫", 0x0a6b},
{"蘭", 0x0a6c}, {"李", 0x0a6d}, {"梨", 0x0a6e}, {"痢", 0x0a6f},
{"硫", 0x0a70}, {"亮", 0x0a71}, {"諒", 0x0a72}, {"遼", 0x0a73},
{"倫", 0x0a74}, {"厘", 0x0a75}, {"伶", 0x0a76}, {"嶺", 0x0a77},
{"怜", 0x0a78}, {"玲", 0x0a79}, {"禄", 0x0a7a}, {"賄", 0x0a7b},
{"亙", 0x0a7c}, {"亘", 0x0a7d}, {"侑", 0x0a7e}, {"巖", 0x0a7f},
{"彌", 0x0a80}, {"洸", 0x0a81}, {"洵", 0x0a82}, {"瑶", 0x0a83},
{"皓", 0x0a84}, {"脩", 0x0a85}, {"茉", 0x0a86}, {"莉", 0x0a87},
{"赳", 0x0a88}, {"迪", 0x0a89}, {"頌", 0x0a8a}, {"栖", 0x0a8b},
{"芹", 0x0a8c}, {"’", 0x0a8d}, {"+", 0x0a8e}, {"<", 0x0a8f},
{">", 0x0a90}, {"韓", 0x0a91}, {"灸", 0x0a92}, {"腱", 0x0a93},
{"&", 0x0a94}, {"遜", 0x0a95}, {"髭", 0x0a96}, {"淋", 0x0a97},
{"/", 0x0a98}, {"¥", 0x0a99}, {"%", 0x0a9a}, {"*", 0x0a9b},
{"↑", 0x0a9c}, {"α", 0x0a9d}, {"餌", 0x0a9e}, {"鴨", 0x0a9f},
{"姑", 0x0aa0}, {"傘", 0x0aa1}, {"棚", 0x0aa2}, {"屁", 0x0aa3},
{"撥", 0x0aa4}, {"筐", 0x0aa5}, {"訛", 0x0aa6}, {"”", 0x0aa7},
{"鵜", 0x0aa8}, {"雁", 0x0aa9}, {"昆", 0x0aaa}, {"塾", 0x0aab},
{"焚", 0x0aac}, {"媚", 0x0aad}, {"棘", 0x0aae}, {"哨", 0x0aaf},
{"×", 0x0ab0}, {"槻", 0x0ab1}, {"綴", 0x0ab2}, {"釧", 0x0ab3},
{"醐", 0x0ab4}, {"采", 0x0ab5}, {"雀", 0x0ab6}, {"醍", 0x0ab7},
{"馳", 0x0ab8}, {"筈", 0x0ab9}, {"幌", 0x0aba}, {"彗", 0x0abb},
{"狗", 0x0abc}, {"烏", 0x0abd}, {"謂", 0x0abe}, {"燭", 0x0abf},
{"蹟", 0x0ac0}, {"悸", 0x0ac1}, {"薔", 0x0ac2}, {"薇", 0x0ac3},
{"賎", 0x0ac4}, {"桶", 0x0ac5}, {"汎", 0x0ac6}, {"柵", 0x0ac7},
{"函", 0x0ac8}, {"腺", 0x0ac9}, {"搭", 0x0aca}, {"筑", 0x0acb},
{"雛", 0x0acc}, {"襞", 0x0acd}, {"碇", 0x0ace}, {"湛", 0x0acf},
{"槍", 0x0ad0}, {"嗜", 0x0ad1}, {"≫", 0x0ad2}, {" ", 0x0000},
{"A", 0x0002}, {"B", 0x0003}, {"C", 0x0004}, {"D", 0x0005},
{"E", 0x0006}, {"F", 0x0007}, {"G", 0x0008}, {"H", 0x0009},
{"I", 0x000a}, {"J", 0x000b}, {"K", 0x000c}, {"L", 0x000d},
{"M", 0x000e}, {"N", 0x000f}, {"O", 0x0010}, {"P", 0x0011},
{"Q", 0x0012}, {"R", 0x0013}, {"S", 0x0014}, {"T", 0x0015},
{"U", 0x0016}, {"V", 0x0017}, {"W", 0x0018}, {"X", 0x0019},
{"Y", 0x001a}, {"Z", 0x001b}, {"a", 0x001c}, {"b", 0x001d},
{"c", 0x001e}, {"d", 0x001f}, {"e", 0x0020}, {"f", 0x0021},
{"g", 0x0022}, {"h", 0x0023}, {"i", 0x0024}, {"j", 0x0025},
{"k", 0x0026}, {"l", 0x0027}, {"m", 0x0028}, {"n", 0x0029},
{"o", 0x002a}, {"p", 0x002b}, {"q", 0x002c}, {"r", 0x002d},
{"s", 0x002e}, {"t", 0x002f}, {"u", 0x0030}, {"v", 0x0031},
{"w", 0x0032}, {"x", 0x0033}, {"y", 0x0034}, {"z", 0x0035},
{"0", 0x0036}, {"1", 0x0037}, {"2", 0x0038}, {"3", 0x0039},
{"4", 0x003a}, {"5", 0x003b}, {"6", 0x003c}, {"7", 0x003d},
{"8", 0x003e}, {"9", 0x003f}, {"(", 0x00e7}, {")", 0x00e8},
{"?", 0x00e9}, {"!", 0x00ea}, {":", 0x00eb}, {"-", 0x00ec},
{"~", 0x00ee}, {".", 0x00ef}, {",", 0x00f0}, {".", 0x00f1},
{",", 0x00f2}, {"'", 0x0a8d}, {"+", 0x0a8e}, {"<", 0x0a8f},
{">", 0x0a90}, {"&", 0x0a94}, {"/", 0x0a98}, {"\"", 0x0aa7},
{"%", 0x0a9a}};
| [
"wbn@striated.space"
] | wbn@striated.space |
6b8fb843279a6c052ac1a3a7b1f06b5a30595ae2 | 8e05f05b23dd1b7c5ea128a110366b7fb1c874c2 | /GameBase.h | 2fbeac3349fb741a9c09a52486ce1e04ec263bb5 | [] | no_license | ethandjay/boardgames | 847f5b215cd589aefbb5a400c4feb6477a311f38 | fdd15a5f0148aa2009149a76a4da36cedee1298d | refs/heads/master | 2021-08-23T03:38:03.916060 | 2017-12-03T00:13:31 | 2017-12-03T00:13:31 | 108,688,094 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,032 | h | #pragma once
#include "stdafx.h"
#include "common.h"
#include "piece.h"
#include <string>
#include <memory>
#include <iostream>
#include <vector>
using namespace std;
class GameBase {
protected:
int board_height;
int board_width;
vector<vector<piece>> pieces;
int longestDisplay;
int minTurns;
int turnCount;
string winner;
static shared_ptr<GameBase> sp;
virtual bool isTurnBased() = 0;
virtual int prompt(unsigned int &, unsigned int &);
virtual bool isValidCoord(string);
virtual void print() = 0;
virtual bool done() = 0;
virtual bool stalemate() = 0;
virtual int turn() = 0;
virtual int save(bool real = true) = 0;
public:
static shared_ptr<GameBase> instance();
GameBase(int, int);
//turn based
GameBase(int, int, int);
static void gameCheck(int, char**);
int play();
GameBase(const GameBase &) = delete;
GameBase &operator= (const GameBase &) = delete;
GameBase(const GameBase &&) = delete;
GameBase &operator= (const GameBase &&) = delete;
}; | [
"ethandjay@gmail.com"
] | ethandjay@gmail.com |
7d7c5ad912e264bfa541d28c69fb7b843a65660a | c7eef555bde856d68575dfc05e1417e7c3f175ba | /Codeforces/1206A.cpp | b1106fac80eeda9813249cd7633c474246c5ce87 | [] | no_license | JonathanChavezTamales/Programacion_competitiva | e84e7914e16edf4fe800f784b1807236b78a3b0a | 9c3717ed6bef9c0fe0c6d871993c054d975fed2b | refs/heads/master | 2021-06-25T09:27:18.892438 | 2020-11-25T22:56:28 | 2020-11-25T22:56:28 | 153,844,483 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 421 | cpp | #include <iostream>
using namespace std;
int main(){
int n,m;
cin>>n;
int a[n];
for(int i=0; i<n; i++)
cin>>a[i];
cin>>m;
int b[m];
for(int i=0; i<m; i++)
cin>>b[i];
for(int i=0; i<n; i++){
for(int j =0; j<m; j++){
int sum = a[i]+b[j];
for(int k = 0; k<n; k++){
if(a[k] == sum){
break;
}
}
for(int k = 0; k<m; k++){
if(b[k] == sum){
break;
}
}
cout<<
}
}
}
| [
"jonathanchatab@hotmail.com"
] | jonathanchatab@hotmail.com |
b4d79aea860d024d85b5a88ab80e1194eb0472ea | 4c95eb1e0fbd89f8f2083bd731939059cd6e4cc2 | /archive/old/facebook/hackercup2020/qualification/D1.cpp | 1c9c84293c7665d240d113df0f7d785318f9fd54 | [
"MIT"
] | permissive | irvinodjuana/acm | 60b598a737e0cb9af269d371dda6d0493daf3fa3 | 6f211f87f5e0be964c14e0d062ed0172e348e1be | refs/heads/master | 2022-12-11T04:38:57.567493 | 2022-12-01T13:15:18 | 2022-12-01T13:15:18 | 232,695,320 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,518 | cpp | #include <bits/stdc++.h>
using namespace std;
// shortened types
typedef long long int ll;
#define MAX_VAL LLONG_MAX
vector<int> read_vector(ifstream& fin, int N) {
vector<int> C(N);
for (int i = 0; i < N; i++) {
fin >> C[i];
}
return C;
}
ll solution(vector<int>& C, int N, int M) {
vector<int> cities;
vector<ll> costs;
cities.push_back(0);
costs.push_back(0);
int start = 0;
for (int i = 1; i < N-1; i++) {
if (C[i] != 0) {
cities.push_back(i);
costs.push_back(C[i]);
}
}
cities.push_back(N-1);
costs.push_back(0);
int n = cities.size();
vector<ll> minCosts(n, MAX_VAL);
minCosts[0] = 0;
for (int i = 0; i < n; i++) {
if (minCosts[i] == MAX_VAL) return -1; // city unreachable
int j = i + 1;
while (j < n && cities[j] <= cities[i] + M) {
minCosts[j] = min(minCosts[j], minCosts[i] + costs[i]);
j++;
}
}
return minCosts[n-1];
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ifstream fin("D1_input.txt");
ofstream fout("D1_output.txt");
int tests;
fin >> tests;
for (int t = 0; t < tests; t++) {
// code here
int N, M;
fin >> N >> M;
vector<int> C = read_vector(fin, N);
ll soln = solution(C, N, M);
fout << "Case #" << t+1 << ": " << soln << "\n";
}
fin.close();
fout.close();
cout.flush();
return 0;
} | [
"irvino.djuana@gmail.com"
] | irvino.djuana@gmail.com |
610f6c24d5aa3825cf85ec121219ef57a2323bab | 59fc4e1fc22de27ae2f12bddcddbf447277c76b8 | /debugger/src/gui_plugin/MainWindow/DbgMainWindow.h | 9bb5d01f845b08b09c3272b90a4c934c1ffae890 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | logicdomain/riscv_vhdl | a74d328cb96549708b4ff8dc4af18ad709c9720a | 2c11ef45f4876cbdf563486b740c629f4b94a6bc | refs/heads/master | 2023-06-13T04:01:23.600210 | 2021-07-11T18:54:43 | 2021-07-11T18:54:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,933 | h | /*
* Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
*
* 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.
*/
#pragma once
#include "api_core.h" // MUST BE BEFORE QtWidgets.h or any other Qt header.
#include "igui.h"
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenu>
#include <QtWidgets/QAction>
#include "MdiAreaWidget.h"
namespace debugger {
class DbgMainWindow : public QMainWindow,
public IGuiCmdHandler {
Q_OBJECT
public:
DbgMainWindow(IGui *igui);
virtual ~DbgMainWindow();
/** IGuiCmdHandler */
virtual void handleResponse(const char *cmd);
signals:
void signalUpdateByTimer();
void signalTargetStateChanged(bool);
void signalRedrawDisasm();
void signalAboutToClose();
void signalSimulationTime(double t);
protected:
virtual void closeEvent(QCloseEvent *ev_);
#ifndef QT_NO_CONTEXTMENU
void contextMenuEvent(QContextMenuEvent *ev_) override;
#endif // QT_NO_CONTEXTMENU
private slots:
void slotUpdateByTimer();
void slotActionAbout();
void slotActionTargetRun();
void slotActionTargetHalt();
void slotActionTargetStepInto();
void slotActionTriggerUart0(bool val);
void slotActionTriggerRegs(bool val);
void slotActionTriggerCpuAsmView(bool val);
void slotActionTriggerStackTraceView(bool val);
void slotActionTriggerMemView(bool val);
void slotActionTriggerGpio(bool val);
void slotActionTriggerPnp(bool val);
void slotActionTriggerGnssMap(bool val);
void slotActionTriggerGnssPlot(bool val);
void slotActionTriggerCodeCoverage(bool val);
void slotActionTriggerSymbolBrowser();
void slotActionTriggerDemoM4(bool val);
void slotOpenDisasm(uint64_t addr, uint64_t sz);
void slotOpenMemory(uint64_t addr, uint64_t sz);
void slotBreakpointsChanged();
void slotSimulationTime(double t);
private:
void createActions();
void createMenus();
void createStatusBar();
void createMdiWindow();
void addWidgets();
private:
QAction *actionAbout_;
QAction *actionQuit_;
QAction *actionRun_;
QAction *actionHalt_;
QAction *actionStep_;
QAction *actionSymbolBrowser_;
QAction *actionRegs_;
QMdiSubWindow *viewRegs_;
QAction *actionCpuAsm_;
QMdiSubWindow *viewCpuAsm_;
QAction *actionStackTrace_;
QMdiSubWindow *viewStackTrace_;
QAction *actionMem_;
QMdiSubWindow *viewMem_;
QAction *actionGpio_;
QMdiSubWindow *viewGpio_;
QAction *actionPnp_;
QMdiSubWindow *viewPnp_;
QAction *actionSerial_;
QMdiSubWindow *viewUart0_;
QAction *actionGnssMap_;
QMdiSubWindow *viewGnssMap_;
QAction *actionGnssPlot_;
QMdiSubWindow *viewGnssPlot_;
QAction *actionCodeCoverage_;
QMdiSubWindow *viewCodeCoverage_;
QAction *actionDemoM4_;
QMdiSubWindow *viewDemoM4_;
QTimer *tmrGlobal_;
MdiAreaWidget *mdiArea_;
AttributeType config_;
AttributeType listConsoleListeners_;
AttributeType cmdStatus_;
AttributeType respStatus_;
AttributeType cmdRun_;
AttributeType respRun_;
AttributeType cmdHalt_;
AttributeType respHalt_;
AttributeType cmdStep_;
AttributeType respStep_;
AttributeType cmdSteps_;
AttributeType respSteps_;
IGui *igui_;
int requestedCmd_;
double stepToSecHz_;
double simSecPrev_;
uint64_t realMSecPrev_;
};
} // namespace debugger
| [
"sergeykhbr@gmail.com"
] | sergeykhbr@gmail.com |
ee5e6adab738366e26441afa50c7cb2332806f88 | 391b7efea1c9fb476be6db45afe6164fba1db6cd | /Detix_XII/2.cpp | 5caaa406b1c0e430a7b9b6cb90ac4aec3f7529b3 | [] | no_license | imprakarsh/Codeforces-Contests | bb76f2379365507cbf61f8eed0af68ce5bfa64e1 | e051365bfd173679a198e075087c91a54590f2a2 | refs/heads/main | 2023-06-15T13:40:34.878585 | 2021-07-16T17:53:23 | 2021-07-16T17:53:23 | 315,203,797 | 0 | 1 | null | 2020-11-23T05:21:38 | 2020-11-23T04:52:44 | C++ | UTF-8 | C++ | false | false | 654 | cpp | #include <bits/stdc++.h>
#define int long long
using namespace std;
void solve() {
int n; cin >> n;
vector<int> kt(n);
for (auto &i : kt) cin >> i;
vector<int> v = {1, 2, 1, 1, 2, 1};
cout << n/2 * 6;
for (int i = 1; i <= n/2; i++) {
for (auto j : v) {
cout << j << " " << 2 * i - 1 << " " << 2 * i << '\n';
}
}
}
int32_t main(){
iostream::sync_with_stdio(false);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
int tc = 1;
cin >> tc;
while (tc--)
solve();
return 0;
}
| [
"prakarsh1213@gmail.com"
] | prakarsh1213@gmail.com |
e0cf97863dc61651f3dc26780adbd114728d7961 | 6e53aa8836638c5f1c070225f39731020eba7091 | /sdrdis/solution/cpp/robonaut/image/image.h | 1e9c76cf85dcbb16095d1b8bceb10efa8a7a48f9 | [
"Apache-2.0"
] | permissive | baymax84/NTL-ISS-Robonaut-2-Vision-Algorithm-Challenge | 47592b68a4e526ff3ed6bc98c8e1490641553d3f | e7523c837d3cd4895537b3750d5b31ad7e8b8f59 | refs/heads/master | 2020-12-25T21:34:42.596852 | 2014-01-09T18:02:42 | 2014-01-09T18:02:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,024 | h | #ifndef IMAGE_H
#define IMAGE_H
#include <vector>
#include <math.h>
//#include <QDebug>
//#include "point.h"
using namespace std;
#define imgPixel(im, x, y) (im->img[x + y * im->width])
template <class T>
class Image
{
public:
Image(int H, int W);
Image(int H, int W, T * img, double scale = 1, bool external = false);
Image (const Image<T> &);
~Image();
static Image<T> * resize(Image<T> * from, int size);
static Image<T> * resize(Image<T> * from, int newH, int newW);
static Image<T> * extract(Image<T> * image, int fromX, int fromY, int fromH, int fromW);
static Image<T> * reshape(Image<T> * image, int fromX, int fromY, int fromH, int fromW, int toH, int toW);
static Image<T> * reshapeInWhite(Image<T> * image, int fromX, int fromY, int fromH, int fromW, int toH, int toW, bool autoRotate = true);
static vector <Image<T> > * reshapeRotated(Image<T> * image, int fromX, int fromY, int fromH, int fromW, int toH, int toW);
Image<T> * getWindow(int x, int y, int imgSize, int toSize);
int getWidth();
int getHeight();
double getScale();
T * getVector();
void generateProfile();
T pixel(int x, int y);
void setPixel(int x, int y, T value);
float diff(int xFrom, int yFrom, int xTo, int yTo);
//vector <Point> * getPoints(int threshold = 170, double header = 0.1);
double scale;
int width;
int height;
T * img;
bool external;
};
/* We moved out of cpp file since we are on template...
* See: http://stackoverflow.com/a/10375372/888390
*/
template <class T>
Image<T>::Image(int H, int W)
{
this->height = H;
this->width = W;
this->img = new T[this->height * this->width];
this->scale = 1;
this->external = false;
}
template <class T>
Image<T>::Image(int H, int W, T * img, double scale, bool external)
{
this->height = H;
this->width = W;
this->img = img;
this->scale = scale;
this->external = external;
}
template <class T>
Image<T>::Image(const Image<T> &from)
{
this->width = from.width;
this->height = from.height;
this->scale = from.scale;
this->external = from.external;
this->img = new T[this->width * this->height];
size_t length = this->width * this->height;
for (size_t i = 0; i < length; i++) {
this->img[i] = from.img[i];
}
}
template <class T>
Image<T>::~Image() {
if (!this->external) {
delete img;
}
}
template <class T>
Image<T> * Image<T>::resize(Image<T> * from, int size) {
double scale;
if (from->height > from->width) {
scale = size * 1.0 / from->getHeight();
} else {
scale = size * 1.0 / from->getWidth();
}
Image * img = Image<T>::resize(from, scale * from->getHeight(), scale * from->getWidth());
img->scale = scale;
return img;
}
template <class T>
Image<T> * Image<T>::resize(Image<T> * from, int newH, int newW) {
T * newImage = new T[newH * newW];
double rapX = from->width * 1.0 / newW;
double rapY = from->height * 1.0 / newH;
for (int y = 0; y < newH; y++) {
for (int x = 0; x < newW; x++) {
int newLeft = max((int)(x * rapX), 0);
int newRight = min((int)(newLeft + rapX - 1), from->getWidth() - 1);
int newTop = max((int)(y * rapY), 0);
int newBottom = min((int)(newTop + rapY - 1), from->getHeight() - 1);
T pixelValue = (imgPixel(from, newLeft, newTop) + imgPixel(from, newRight, newTop) + imgPixel(from, newLeft, newBottom) + imgPixel(from, newRight, newBottom)) / 4;
//qDebug() << newRight + newBottom * W << image->size();
newImage[x + y * newW] = pixelValue;
}
}
return new Image<T>(newH, newW, newImage);
}
template <class T>
Image<T> * Image<T>::extract(Image<T> * image, int fromX, int fromY, int fromH, int fromW) {
T * newImage = new T[fromH * fromW];
for (int y = 0; y < fromH; y++) {
for (int x = 0; x < fromW; x++) {
newImage[x + y * fromW] = imgPixel(image, x + fromX, y + fromY);
}
}
return new Image<T>(fromH, fromW, newImage);
}
template <class T>
Image<T> * Image<T>::reshape(Image<T> * image, int fromX, int fromY, int fromH, int fromW, int toH, int toW) {
T * newImage = new T[toH * toW];
double rapX = fromW * 1.0 / toW;
double rapY = fromH * 1.0 / toH;
for (int y = 0; y < toH; y++) {
for (int x = 0; x < toW; x++) {
int newLeft = max((int)(x * rapX + fromX), 0);
int newRight = min((int)(newLeft + rapX - 1), fromX + fromW - 1);
int newTop = max((int)(y * rapY + fromY), 0);
int newBottom = min((int)(newTop + rapY - 1), fromY + fromH - 1);
T pixelValue = (imgPixel(image, newLeft, newTop) + imgPixel(image, newRight, newTop) + imgPixel(image, newLeft, newBottom) + imgPixel(image, newRight, newBottom)) / 4;
newImage[x + y * toW] = pixelValue; // can be highly optimized
}
}
return new Image<T>(toH, toW, newImage);
}
template <class T>
Image<T> * Image<T>::reshapeInWhite(Image<T> * image, int fromX, int fromY, int fromH, int fromW, int toH, int toW, bool autoRotate) {
size_t length = toH * toW;
T * newImage = new T[length];
for (size_t i = 0; i < length; i++) {
newImage[i] = 120;
}
bool rotate = false;
if (fromH > fromW && autoRotate) {
rotate = true;
int temp = toH;
toH = toW;
toW = temp;
}
double rapX = fromW * 1.0 / toW;
double rapY = fromH * 1.0 / toH;
double rap = max(rapX, rapY);
int translationX = rapY > rapX ? ((fromW * 1.0) - toW * rap) / 2 : 0;
int translationY = rapY > rapX ? 0 : ((fromH * 1.0) - toH * rap) / 2;
for (int y = 0; y < toH; y++) {
for (int x = 0; x < toW; x++) {
int newLeft = (x * rap + fromX) + translationX;
int newRight = (newLeft + rap - 1);
int newTop = (y * rap + fromY) + translationY;
int newBottom = (newTop + rap - 1);
int leftTopPixel = (newLeft < fromX || newTop < fromY || newLeft > fromX + fromW - 1 || newTop > fromY + fromH - 1) ? 255 : imgPixel(image, newLeft, newTop);
int rightTopPixel = (newRight < fromX || newTop < fromY || newRight > fromX + fromW - 1 || newTop > fromY + fromH - 1) ? 255 : imgPixel(image, newRight, newTop);
int leftBottomPixel = (newLeft < fromX || newBottom < fromY || newLeft > fromX + fromW - 1 || newBottom > fromY + fromH - 1) ? 255 : imgPixel(image, newLeft, newBottom);
int rightBottomPixel = (newRight < fromX || newBottom < fromY || newRight > fromX + fromW - 1 || newBottom > fromY + fromH - 1) ? 255 : imgPixel(image, newRight, newBottom);
T pixelValue = (leftTopPixel + rightTopPixel + leftBottomPixel + rightBottomPixel) / 4;
newImage[rotate ? (toH - y - 1 + x * toH) : (x + y * toW)] = pixelValue;
}
}
return new Image<T>(rotate ? toW : toH, rotate ? toH : toW, newImage);
}
template <class T>
vector <Image <T> > * Image<T>::reshapeRotated(Image<T> * image, int fromX, int fromY, int fromH, int fromW, int toH, int toW) {
vector <Image <T> > * images = new vector <Image <T> > ();
size_t length = toH * toW;
T * img0 = new T[length];
T * img90 = new T[length];
T * img180 = new T[length];
T * img270 = new T[length];
for (size_t i = 0; i < length; i++) {
img0[i] = 120;
img90[i] = 120;
img180[i] = 120;
img270[i] = 120;
}
double rapX = fromW * 1.0 / toW;
double rapY = fromH * 1.0 / toH;
double rap = max(rapX, rapY);
int translationX = rapY > rapX ? ((fromW * 1.0) - toW * rap) / 2 : 0;
int translationY = rapY > rapX ? 0 : ((fromH * 1.0) - toH * rap) / 2;
for (int y = 0; y < toH; y++) {
for (int x = 0; x < toW; x++) {
int newLeft = (x * rap + fromX) + translationX;
int newRight = (newLeft + rap - 1);
int newTop = (y * rap + fromY) + translationY;
int newBottom = (newTop + rap - 1);
int leftTopPixel = (newLeft < fromX || newTop < fromY || newLeft > fromX + fromW - 1 || newTop > fromY + fromH - 1) ? 255 : imgPixel(image, newLeft, newTop);
int rightTopPixel = (newRight < fromX || newTop < fromY || newRight > fromX + fromW - 1 || newTop > fromY + fromH - 1) ? 255 : imgPixel(image, newRight, newTop);
int leftBottomPixel = (newLeft < fromX || newBottom < fromY || newLeft > fromX + fromW - 1 || newBottom > fromY + fromH - 1) ? 255 : imgPixel(image, newLeft, newBottom);
int rightBottomPixel = (newRight < fromX || newBottom < fromY || newRight > fromX + fromW - 1 || newBottom > fromY + fromH - 1) ? 255 : imgPixel(image, newRight, newBottom);
T pixelValue = (leftTopPixel + rightTopPixel + leftBottomPixel + rightBottomPixel) / 4;
int rotX = toH - y - 1;
int rotY = x;
img0[x + y * toW] = pixelValue;
img90[rotX + rotY * toH] = pixelValue;
img180[toW - x - 1 + (toH - y - 1) * toW] = pixelValue;
img270[toH - rotX - 1 + (toW - rotY - 1) * toH] = pixelValue;
}
}
images->push_back(Image<T>(toH, toW, img0));
images->push_back(Image<T>(toW, toH, img90));
images->push_back(Image<T>(toH, toW, img180));
images->push_back(Image<T>(toW, toH, img270));
return images;
}
template <class T>
Image<T> * Image<T>::getWindow(int x, int y, int imgSize, int toSize) {
/*
int fromH;
int fromW;
vector < int > * img;
img = this->img;
imgSize = imgSize / sScale;
fromH = this->H;
fromW = this->W;
*/
/*
if (toSize > imgSize) {
} else {
img = this->sImg;
fromH = this->sH;
fromW = this->sW;
}*/
return reshape(this, x, y, imgSize, imgSize, toSize, toSize);
}
template <class T>
int Image<T>::getWidth() {
return this->width;
}
template <class T>
int Image<T>::getHeight() {
return this->height;
}
template <class T>
void Image<T>::generateProfile() {
/*
this->profileSum = 0;
this->pH = this->height / 100;
this->pW = this->width / 100;
long threshold = PROFILE_THRESHOLD * PROFILE_SIZE * PROFILE_SIZE;
this->profileXY.resize(this->sW + this->sH);
this->pSum.resize(this->pW * this->pH, 0);
this->pImg.resize(this->pW * this->pH, 0);
for (long x = 0; x < this->sW; x++) {
for (long y = 0; y < this->sH; y++) {
long val = this->sImg->at(x + y * this->sW);
this->profileXY[x] += val;
this->profileXY[this->sW + y] += val;
this->profileSum += val;
long pIndex = (x / PROFILE_SIZE) + (y / PROFILE_SIZE) * this->pW;
this->pSum[pIndex] += val;
//qDebug() << pIndex << this->pSum[pIndex];
if (this->pSum[pIndex] > threshold) {
this->pImg[pIndex] = 255;
}
}
}
*/
}
template <class T>
T Image<T>::pixel(int x, int y) {
return this->img[min(x, this->width) + min(y, this->height) * this->width];
}
template <class T>
void Image<T>::setPixel(int x, int y, T value) {
this->img[x + y * this->width] = value;
}
template <class T>
double Image<T>::getScale() {
return this->scale;
}
template <class T>
T * Image<T>::getVector() {
return this->img;
}
template <class T>
float Image<T>::diff(int xFrom, int yFrom, int xTo, int yTo) {
float diff = imgPixel(this, xFrom, yFrom) - imgPixel(this, xTo, yTo);
return sqrt(diff * diff + diff * diff + diff * diff);
}
#endif // IMAGE_H
| [
"allison.thackston@ratchet"
] | allison.thackston@ratchet |
46ae8573d1ce11b626e4377edf58878a92e609f9 | 00abce0660c98f711a4fced31d9f48131b0df91f | /Linux/ANN/Neuron.h | f2228f96ddfbfc84506fa217e5fdddaff5c1c6f8 | [] | no_license | Sebarl/gaia | 623e3e228f754c3c0cbb50d86630a22e77bff0fa | 5d9006305ea7b2447f4b5930700ba5393f022cb0 | refs/heads/master | 2021-01-20T01:36:16.051041 | 2019-04-08T04:36:44 | 2019-04-08T04:36:44 | 89,306,343 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 440 | h | #ifndef NEURON_H
#define NEURON_H
#include "ActivationFunction.h"
#include "Link.h"
#include <vector>
class Neuron {
public:
std::vector<Link*> outboundLinks;
int cantLinks;
bool visited;
float oldOutput;
ActivationFunction* actFun;
Neuron(ActivationFunction* actFun);
virtual ~Neuron();
virtual void propagate()=0;
virtual void setInput(float input)=0;
virtual void advanceTimestep()=0;
virtual int neuronType()=0;
};
#endif
| [
"seba123321@hotmail.com"
] | seba123321@hotmail.com |
1d1001135a88d8b18d47a7dce306074ca746ce24 | f293984e9bc13b0838c191d2927e23f09eefd556 | /nothingness.cpp | 03ae391cd37996ebc3a980a32848fe1636b827b1 | [] | no_license | devagarwal1803/HackerEarth | ed39f2c53e5f6ab577af9e58aa312fe81d23b458 | 0daa4f80b8379b5fbdaf382d7b2109d3db880ad9 | refs/heads/master | 2020-07-30T19:17:55.107794 | 2016-03-12T11:18:35 | 2016-03-12T11:18:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 554 | cpp | #include<iostream>
using namespace std;
int hcf(int a , int b)
{
while(a!=b)
{
if(a>b)
a=a-b;
else
b=b-a;
}
return a;
}
int main()
{
int s,q;
cin>>s>>q;
bool a[100001];
for(int i=0;i<100001;i++)
a[i]=false;
while(q--)
{
int n;
cin>>n;
int x = hcf(s,n);
if(a[x]==false)
{
cout<<x<<endl;
a[x]=true;
}
else
cout<<-1<<endl;
}
}
| [
"nikhilgautam94@gmail.com"
] | nikhilgautam94@gmail.com |
15865cbbdcb1c6fb7170ffc6f36b4ccef868a04c | 2d6f5e4778fe58f211ce5f08f4359b175e7b43c2 | /src/central/test/AlertAggregator.test.cpp | ed48c4143825710e440b078e67a0936fad26d3ed | [] | no_license | golechwierowicz/tin | c0d3321c17530c7a757f1458ea4e21e2badc452a | 04f26b52448d2f7fe81abd97170e1f078275f53c | refs/heads/master | 2021-01-19T14:28:42.306212 | 2017-06-08T13:49:39 | 2017-06-08T13:49:39 | 88,165,941 | 1 | 0 | null | 2017-05-31T06:20:52 | 2017-04-13T13:08:29 | C++ | UTF-8 | C++ | false | false | 2,466 | cpp | #include <boost/test/unit_test.hpp>
#include "AlertAggregator.h"
namespace {
const uint64_t timestamp = 1495986528ULL;
const uint64_t timestamp_after_minute = timestamp + 60;
const uint16_t latitude = 120;
const uint16_t longitude = 130;
const SensorCommonBlock common(timestamp, latitude, longitude, true);
const SensorCommonBlock common_after_minute(timestamp_after_minute, latitude, longitude, true);
const SensorCommonBlock common_not_alive(timestamp, latitude, longitude, false);
const SensorMeasurementBlock smoke(BlockType::smoke_read, 1.0);
const SensorMeasurementBlock smoke_below_threshold(BlockType::smoke_read, 0.0);
const SensorMeasurementBlock ir(BlockType::ir_read, 0.6);
const SensorMeasurementBlock ir_below_threshold(BlockType::ir_read, 0.0);
}
BOOST_AUTO_TEST_CASE(alert_aggregator_empty) {
AlertAggregator aggregator;
auto result = aggregator.extractAlerts();
BOOST_CHECK_EQUAL(0, result.size());
}
BOOST_AUTO_TEST_CASE(alert_aggregator_several_inserts) {
AlertAggregator aggregator;
aggregator.insert(common, smoke);
aggregator.insert(common, ir);
auto initial = aggregator.extractAlerts();
aggregator.insert(common_after_minute, smoke);
auto after_minute = aggregator.extractAlerts();
BOOST_CHECK_EQUAL(1, initial.size());
BOOST_CHECK_EQUAL(timestamp, initial[0].get_timestamp());
BOOST_CHECK_EQUAL(2, initial[0].get_alerts_count());
BOOST_CHECK_EQUAL(latitude, initial[0].get_latitude());
BOOST_CHECK_EQUAL(longitude, initial[0].get_longitude());
BOOST_CHECK_EQUAL(1, after_minute.size());
BOOST_CHECK_EQUAL(timestamp, after_minute[0].get_timestamp());
BOOST_CHECK_EQUAL(1, after_minute[0].get_alerts_count());
BOOST_CHECK_EQUAL(latitude, after_minute[0].get_latitude());
BOOST_CHECK_EQUAL(longitude, after_minute[0].get_longitude());
}
BOOST_AUTO_TEST_CASE(alert_aggregator_ignores_not_alive) {
AlertAggregator aggregator;
aggregator.insert(common_not_alive, smoke);
aggregator.insert(common_not_alive, ir);
auto result = aggregator.extractAlerts();
BOOST_CHECK_EQUAL(0, result.size());
}
BOOST_AUTO_TEST_CASE(alert_aggregator_ignores_below_threshold) {
AlertAggregator aggregator;
aggregator.insert(common, smoke_below_threshold);
aggregator.insert(common, ir_below_threshold);
auto result = aggregator.extractAlerts();
BOOST_CHECK_EQUAL(0, result.size());
} | [
"marcin.sucharski.github@gmail.com"
] | marcin.sucharski.github@gmail.com |
a8e4f27dd0e134dd7619d2449a44df2f7cffdb1c | 624d1b9bb225c494e8f7b8c668fae49acfe69de4 | /devel/include/ublox_msgs/CfgSBAS.h | 652b365948570a374ad83726561747e251bc6395 | [] | no_license | soyeongkim/Autonomous-car-lab-KUSV | 1630a61e109ae233c32239b2625d59fbbcc3662d | b95eaeff9b5fd25f8bd520f90cefd62ac3b589e5 | refs/heads/master | 2020-06-07T13:31:01.575668 | 2019-06-20T14:52:35 | 2019-06-20T14:52:35 | 193,033,192 | 0 | 0 | null | 2019-06-21T04:59:19 | 2019-06-21T04:59:19 | null | UTF-8 | C++ | false | false | 7,551 | h | // Generated by gencpp from file ublox_msgs/CfgSBAS.msg
// DO NOT EDIT!
#ifndef UBLOX_MSGS_MESSAGE_CFGSBAS_H
#define UBLOX_MSGS_MESSAGE_CFGSBAS_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
namespace ublox_msgs
{
template <class ContainerAllocator>
struct CfgSBAS_
{
typedef CfgSBAS_<ContainerAllocator> Type;
CfgSBAS_()
: mode(0)
, usage(0)
, maxSBAS(0)
, scanmode2(0)
, scanmode1(0) {
}
CfgSBAS_(const ContainerAllocator& _alloc)
: mode(0)
, usage(0)
, maxSBAS(0)
, scanmode2(0)
, scanmode1(0) {
(void)_alloc;
}
typedef uint8_t _mode_type;
_mode_type mode;
typedef uint8_t _usage_type;
_usage_type usage;
typedef uint8_t _maxSBAS_type;
_maxSBAS_type maxSBAS;
typedef uint8_t _scanmode2_type;
_scanmode2_type scanmode2;
typedef uint32_t _scanmode1_type;
_scanmode1_type scanmode1;
enum {
CLASS_ID = 6u,
MESSAGE_ID = 22u,
MODE_ENABLED = 1u,
MODE_TEST = 2u,
USAGE_RANGE = 1u,
USAGE_DIFF_CORR = 2u,
USAGE_INTEGRITY = 4u,
};
typedef boost::shared_ptr< ::ublox_msgs::CfgSBAS_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::ublox_msgs::CfgSBAS_<ContainerAllocator> const> ConstPtr;
}; // struct CfgSBAS_
typedef ::ublox_msgs::CfgSBAS_<std::allocator<void> > CfgSBAS;
typedef boost::shared_ptr< ::ublox_msgs::CfgSBAS > CfgSBASPtr;
typedef boost::shared_ptr< ::ublox_msgs::CfgSBAS const> CfgSBASConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::ublox_msgs::CfgSBAS_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::ublox_msgs::CfgSBAS_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace ublox_msgs
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False}
// {'sensor_msgs': ['/opt/ros/kinetic/share/sensor_msgs/cmake/../msg'], 'geometry_msgs': ['/opt/ros/kinetic/share/geometry_msgs/cmake/../msg'], 'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'ublox_msgs': ['/home/lke/ACL_KUSV/src/sensing/ublox/ublox_msgs/msg']}
// !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types']
template <class ContainerAllocator>
struct IsFixedSize< ::ublox_msgs::CfgSBAS_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::ublox_msgs::CfgSBAS_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::ublox_msgs::CfgSBAS_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::ublox_msgs::CfgSBAS_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::ublox_msgs::CfgSBAS_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::ublox_msgs::CfgSBAS_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::ublox_msgs::CfgSBAS_<ContainerAllocator> >
{
static const char* value()
{
return "b03a1b853ac45d2da104aafaa036e7e8";
}
static const char* value(const ::ublox_msgs::CfgSBAS_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0xb03a1b853ac45d2dULL;
static const uint64_t static_value2 = 0xa104aafaa036e7e8ULL;
};
template<class ContainerAllocator>
struct DataType< ::ublox_msgs::CfgSBAS_<ContainerAllocator> >
{
static const char* value()
{
return "ublox_msgs/CfgSBAS";
}
static const char* value(const ::ublox_msgs::CfgSBAS_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::ublox_msgs::CfgSBAS_<ContainerAllocator> >
{
static const char* value()
{
return "# CFG-SBAS (0x06 0x16)\n\
# SBAS Configuration\n\
#\n\
# This message configures the SBAS receiver subsystem (i.e. WAAS, EGNOS, MSAS).\n\
# See the SBAS Configuration Settings Description for a detailed description of\n\
# how these settings affect receiver operation\n\
#\n\
\n\
uint8 CLASS_ID = 6\n\
uint8 MESSAGE_ID = 22\n\
\n\
uint8 mode # SBAS Mode\n\
uint8 MODE_ENABLED = 1 # SBAS Enabled (1) / Disabled (0)\n\
# This field is deprecated; use UBX-CFG-GNSS to \n\
# enable/disable SBAS operation\n\
uint8 MODE_TEST = 2 # SBAS Testbed: Use data anyhow (1) / Ignore data when \n\
# in Test Mode (SBAS Msg 0)\n\
\n\
uint8 usage # SBAS Usage\n\
uint8 USAGE_RANGE = 1 # Use SBAS GEOs as a ranging source (for navigation)\n\
uint8 USAGE_DIFF_CORR = 2 # Use SBAS Differential Corrections\n\
uint8 USAGE_INTEGRITY = 4 # Use SBAS Integrity Information\n\
\n\
uint8 maxSBAS # Maximum Number of SBAS prioritized tracking\n\
# channels (valid range: 0 - 3) to use\n\
# (obsolete and superseeded by UBX-CFG-GNSS in protocol\n\
# versions 14+).\n\
\n\
\n\
uint8 scanmode2 # Continuation of scanmode bitmask below\n\
# PRN 152...158\n\
uint32 scanmode1 # Which SBAS PRN numbers to search for (Bitmask)\n\
# If all Bits are set to zero, auto-scan (i.e. all valid\n\
# PRNs) are searched. Every bit corresponds to a PRN \n\
# number.\n\
# PRN 120..151\n\
";
}
static const char* value(const ::ublox_msgs::CfgSBAS_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::ublox_msgs::CfgSBAS_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.mode);
stream.next(m.usage);
stream.next(m.maxSBAS);
stream.next(m.scanmode2);
stream.next(m.scanmode1);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct CfgSBAS_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::ublox_msgs::CfgSBAS_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::ublox_msgs::CfgSBAS_<ContainerAllocator>& v)
{
s << indent << "mode: ";
Printer<uint8_t>::stream(s, indent + " ", v.mode);
s << indent << "usage: ";
Printer<uint8_t>::stream(s, indent + " ", v.usage);
s << indent << "maxSBAS: ";
Printer<uint8_t>::stream(s, indent + " ", v.maxSBAS);
s << indent << "scanmode2: ";
Printer<uint8_t>::stream(s, indent + " ", v.scanmode2);
s << indent << "scanmode1: ";
Printer<uint32_t>::stream(s, indent + " ", v.scanmode1);
}
};
} // namespace message_operations
} // namespace ros
#endif // UBLOX_MSGS_MESSAGE_CFGSBAS_H
| [
"lkeun1119@gmail.com"
] | lkeun1119@gmail.com |
42f3e1ffc262cce87b35e4bc10db632a9da1f1cc | 2298ff233ee326776438d87fe0bf4cd2e734a14c | /ex02_slot/mainwindow.cpp | 044cbc1be1522d628160e2b41e253390dbeba7dc | [] | no_license | Harxon/ex_qt | 5ff2c4b1c330f07806cd7788c37217edb39cc18b | fd2963d65910889588f5692112b0970ee0957620 | refs/heads/master | 2020-05-24T07:27:39.123504 | 2017-04-08T04:13:22 | 2017-04-08T04:13:22 | 84,834,757 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 346 | cpp | #include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButtonChangeTitle_clicked(bool checked)
{
this->setWindowTitle("slotTitle");
}
| [
"haoxs@hqyj.com"
] | haoxs@hqyj.com |
d6b38d3832d422bfa072f9681c0fbd2d363e4b3c | 583d3a1388894f86c434854de12ad62729c6af72 | /ArrayProblems/MedianSortedArray.hpp | e26d72612809865ca099c5a5cab73357244e78a3 | [] | no_license | yasharora-dev/ArrayProblems | 0ee1a75f6ec929c9ed746780f3ae51072aa50d7d | d936f414aba82933e6c2cd09fbc641d91ebe8c60 | refs/heads/master | 2022-12-26T04:11:33.329394 | 2020-10-10T21:03:00 | 2020-10-10T21:03:00 | 302,988,920 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 660 | hpp | //
// MedianSortedArray.hpp
// ArrayProblems
//
// Created by Yash Arora on 25/08/20.
// Copyright © 2020 Yash Arora. All rights reserved.
//
#ifndef MedianSortedArray_hpp
#define MedianSortedArray_hpp
#include <stdio.h>
#include <vector>
class MedianSortedArray{
public:
static double findMedianInSortedArrayDiffSize(std::vector<int> &arr1,std::vector<int> &arr2);
static double calculateMedian(int leftX, int leftY, int rightX, int rightY, bool isOdd);
static double findMedianInSortedArrayUtil(std::vector<int> &arr1, std::vector<int> &arr2);
static void Test_findMedianInSortedArrayDiffSize();
};
#endif /* MedianSortedArray_hpp */
| [
"yash.arora310@gmail.com"
] | yash.arora310@gmail.com |
6cb4e456a7510e1729c754d359e27830b6658e5f | 9ff089c49ac30009f9e72e43f88bb1b32d0ab32a | /cpp/src/flovv/Engine.cpp | 1d951dde1df52c4a7bfe7c97e1eb92ac6b4155b9 | [] | no_license | mirek/flovv | 1933cfc46290f6ba077ce8de29459904bf280f2b | 70ed4b758154e81cdbf1b21cdf61808ca2a4a20a | refs/heads/master | 2021-01-01T20:48:20.419803 | 2013-09-20T21:39:17 | 2013-09-20T21:39:17 | 9,410,872 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,360 | cpp | //
// Released under the MIT License.
//
// Copyright (c) 2012 - 2013, Mirek Rusin <mirek [at] me [dot] com>
// http://flovv.org
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
#include <flovv/Engine.hpp>
namespace flovv
{
Node *
Engine::createNode (const std::string &name)
{
Node *result = nullptr;
if (mNodeRegistry.nodeTypeRegistered(name)) {
result = mNodeRegistry.createNode(name);
if (result) {
mDocument.addNode(result);
}
} else {
throw "node type name not registered " + name;
}
return result;
}
bool
Engine::connect (const NodeOutput &source, const NodeInput &destination)
{
bool result = false;
std::cerr << source << std::endl;
// Get convertion function between connected points (or direct
// assignment for the same types).
auto typeConvertionFunction = mTypeRegistry.typeConvertionFunction({source.getTypeName(), destination.typeName()});
if (typeConvertionFunction) {
result = source.getOutput().registerDestination(destination.input(), typeConvertionFunction);
} else {
// TODO: Log/throw convertion function not available.
}
return result;
}
type::UInt64
Engine::getFrame () {
return mFrame;
}
void
Engine::update ()
{
update(++mFrame, getCurrentTimestamp());
}
void
Engine::update (type::UInt64 frame, type::Double at)
{
// mFrame = frame;
// mAt = at;
// mVisitor.visit();
}
}
| [
"mirek@me.com"
] | mirek@me.com |
8df3c3cdbfc8570dfbbb52c27fdef5432e96dda5 | f2a37bab7c306608404535300862d1d19ff58939 | /015_3sum/3sum_bt_tle.cpp | a9db025cbd9ffb1e47f6ee9f67c3b3e75b14360a | [] | no_license | xhwang/leetcode | df008f8693c928c9fe19aed69bcedfdbe4562a81 | 3cf6ab7c50684ee10989e131e6a1f3b4b1eb1608 | refs/heads/master | 2020-12-03T02:04:18.798726 | 2017-06-30T15:45:33 | 2017-06-30T15:45:33 | 95,902,430 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,401 | cpp | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
vector<vector<int>> threeSum(vector<int>& nums) {
vector<vector<int>> rel;
vector<int> curr;
sort(nums.begin(), nums.end());
recursive(rel, curr, nums, 0, 0, 3);
return rel;
}
void recursive(vector<vector<int>>& rel, vector<int>& curr, const vector<int>& candidates, size_t idx, int target, size_t num) {
if(target < 0)
return;
if(0 == target && curr.size() == num) {
vector<int> t(curr);
rel.push_back(t);
} else {
for (size_t i=idx; i<candidates.size(); i++) {
if(i > idx && candidates[i] == candidates[i-1])
continue;
if(curr.size() < num) {
curr.push_back(candidates[i]);
recursive(rel, curr, candidates, i+1, target - candidates[i], num);
curr.pop_back();
}
}
}
}
};
void printVectors(vector<vector<int>> vectors) {
for(vector<int> v: vectors) {
for(int n: v) {
cout<<n<<" ";
}
cout<<endl;
}
}
int main() {
Solution demo = Solution();
vector<vector<int>> rel;
vector<int> nums;
nums.push_back(-1);
nums.push_back(0);
nums.push_back(1);
nums.push_back(2);
nums.push_back(-1);
nums.push_back(4);
rel = demo.threeSum(nums);
printVectors(rel);
}
| [
"xhwang.ict@gmail.com"
] | xhwang.ict@gmail.com |
eec11b998b526ecc42d5bb17a87d7928d1bb1c1f | f64d8201c2e55d7631d0a03a7a51d146c7d5c761 | /1_1_Win_Program/API_多线程_07_解析事件实现线程同步的原理.cpp | 792d8a08e2e34623f350a50326270e7e427034d2 | [] | no_license | wh-orange/CodeRecord | cd14b5ccc1760a3d71762fef596ba9ab8dac8b8c | 0e67d1dafcb2feaf90ffb55964af7a9be050e0ee | refs/heads/master | 2022-01-18T10:26:27.993210 | 2019-08-04T17:38:35 | 2019-08-04T17:38:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,669 | cpp | #include <windows.h>
#include <iostream>
using namespace std;
// 解析事件实现线程同步的原理
// 当线程1已满足继续访问i值时,线程2不能访问i。
// 原因是线程1在break后处于无限循环,线程2根本没机会访问变量i
int i = 1;//全局变量
HANDLE hEvent;//事件
bool th1_flag=true;//线程1
bool th2_flag=true;//线程2
DWORD WINAPI ThreadProc1(LPVOID lpParameter)//线程1
{
while(th1_flag)
{
WaitForSingleObject(hEvent,INFINITE);
cout<<"进入线程1。。。"<<endl;
if(i<5)//界值5
{
cout<<"线程hThread1当前访问的i值:"<<i<<endl;
i*=2;//每次乘以2
}
else
th1_flag=false;
SetEvent(hEvent);
}
return 0;
}
DWORD WINAPI ThreadProc2(LPVOID lpParameter)//线程2
{
while(th2_flag)
{
WaitForSingleObject(hEvent,INFINITE);
cout<<"进入线程2。。。"<<endl;
if(i<20)//界值20
{
cout<<"线程hThread2当前访问的i值:"<<i<<endl;
i*=2;//每次乘以2
}
else
th2_flag=false;
SetEvent(hEvent);
}
return 0;
}
void main()
{
cout<<"-------事件实现线程同步原理--------"<<endl;
HANDLE hThread1;//定义句柄
HANDLE hThread2;//定义句柄
hThread1 = CreateThread(NULL,0,ThreadProc1,NULL,0,NULL);
hThread2 = CreateThread(NULL,0,ThreadProc2,NULL,0,NULL);//创建线程
CloseHandle(hThread1);//关闭线程2
CloseHandle(hThread2);//关闭线程2
hEvent = CreateEvent(NULL,false,false,NULL);//创建事件
if(hEvent)
{
if(GetLastError() == ERROR_ALREADY_EXISTS)//创建事件有错
{
cout<<"该事件已经存在!"<<endl;
return;
}
}
SetEvent(hEvent);//设置事件
Sleep(4000);
CloseHandle(hEvent);//关闭事件句柄
} | [
"ljressrg@gmail.com"
] | ljressrg@gmail.com |
0fd4fdd15ce5cd64df339fb6184023da3d6d6db2 | 0ab72b7740337ec0bcfec102aa7c740ce3e60ca3 | /prj/binding/E2.cxx | 318c4620b96f3a22180881c9770e70cc6f256ad6 | [] | no_license | junwang-nju/mysimulator | 1d1af4ad7ddbe114433ebdadd92de8bb3a45c04f | 9c99970173ce87c249d2a2ca6e6df3a29dfc9b86 | refs/heads/master | 2021-01-10T21:43:01.198526 | 2012-12-15T23:22:56 | 2012-12-15T23:22:56 | 3,367,116 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,327 | cxx |
#include "data/basic/console-output.h"
#include "vector/interface.h"
#include <cmath>
using namespace std;
double f1(double d, double d0, double epsilon) { return -epsilon*exp(-d/d0); }
double ExpF1T(double d,double d0,double epsilon,double T) {
return exp(-f1(d,d0,epsilon)/T);
}
double Intg(double R, double d0, double epsilon,double T,
double RA,double RB, double d1,double d2, double RC) {
double tmdA,tmdB,thdA,thdB;
double sum1,sum2,sum,sfac;
tmdA=RA+d1;
tmdB=RB+d2;
thdA=RC+RA;
thdB=RC+RB;
double thU,thL,thUc,thLc,tmd;
thU=(R*R+tmdA*tmdA-thdA*thdA)/(2*R*tmdA);
thL=(R*R+tmdB*tmdB-thdB*thdB)/(2*R*tmdB);
tmd=sqrt(R*R-RC*RC);
thUc=(tmd<d1?tmd/R:1.0001);
thLc=(tmd<d2?tmd/R:1.0001);
thU=(thU>1?1:thU);
thL=(thL>1?1:thL);
thU=(thUc>thU?thU:thUc);
thL=(thLc>thL?thL:thLc);
int nth=1000;
double dthL,dthU;
dthL=thL/nth;
dthU=thU/nth;
sum1=0;
for(int i=-nth;i<=0;++i) {
if((i==-nth)||(i==0)) sfac=0.5;
else sfac=1.;
tmd=sqrt(R*R+tmdA*tmdA-2*R*tmdA*i*dthL);
sum1+=sfac*ExpF1T(tmd,d0,epsilon,T);
//sum1+=sfac*exp(epsilon/T*exp(-sqrt(-2*R*tmdA*i*dthL+R*R+tmdA*tmdA)/d0));
}
sum1*=dthL;
sum2=0;
for(int i=0;i<=nth;++i) {
if((i==nth)||(i==0)) sfac=0.5;
else sfac=1.;
tmd=sqrt(R*R+tmdA*tmdA-2*R*tmdA*i*dthU);
sum2+=sfac*ExpF1T(tmd,d0,epsilon,T);
//sum2+=sfac*exp(epsilon/T*exp(-sqrt(-2*R*tmdA*i*dthU+R*R+tmdA*tmdA)/d0));
}
sum2*=dthU;
sum=sum1+sum2;
return sum;
}
double f(double d) {
return -exp(-d/0.2)*10;
}
double S(double n, double d) { return 2*log(d)-d*d/n; }
double SG(double r) { return 2*log(r); }
int main(int argc, char** argv) {
if(argc<2) { CErr<<"binding-sphere.run <R-Value>"<<Endl<<Endl; return 1; }
const unsigned int N1=50;
const unsigned int N2=50;
const unsigned int Nm=10;
const unsigned int N=N1+N2+Nm;
const double e1=0;
const double e2=0;
//const double T=1.48;
const double T=0.8555;
const double d0=1;
const double rc=1;
//const double epsilon=100;
const double epsilon=100*exp((pow(N1,1./3.)+rc)*(1./d0-1./2.));
double d,d1,d2;
unsigned int r,r1,r2;
double R,RA,RB;
double FL;
unsigned int NA,NB,Nd;
double C;
R=atof(argv[1]);
d=0.25;
r=0;
r1=r2=0;
NA=N1+r1;
NB=N2+r2;
Nd=Nm-r;
RA=pow(NA,1./3.);
RB=pow(NB,1./3.);
const double dstep=0.0002;
const unsigned int MaxND=50000;
unsigned int nd=5;
Vector<double> dv(MaxND);
d=nd*dstep;
for(unsigned int g=nd;g<MaxND;++g) {
d1=(-RA*NA+(RB+d)*NB+d/2.*Nd)/(N+0.);
d2=d-d1;
C=(f(d)-T*S(Nd,d))-e1*r1-e2*r2-T*SG(R);
FL=Intg(R,d0,epsilon,T,RA,RB,d1,d2,rc);
FL=C-T*log(FL);
//COut<<f1(pow(NA,1./3.)+rc,d0,epsilon)<<Endl;
//getchar();
dv[g]=FL;
d+=dstep;
}
COut.precision(8);
for(unsigned int g=nd+1;g<MaxND-1;++g) {
if((dv[g]-dv[g-1])*(dv[g]-dv[g+1])>0) {
COut<<R<<"\t"<<g*dstep<<"\t"<<dv[g]<<"\t";
if(dv[g]>dv[g-1]) COut<<"Max"<<Endl;
else COut<<"Min"<<Endl;
}
}
COut<<R<<"\t"<<nd*dstep<<"\t"<<dv[nd]<<"\t";
if(dv[nd]<dv[nd+1]) COut<<"Min"<<Endl;
else COut<<"Max"<<Endl;
COut<<R<<"\t"<<(MaxND-1)*dstep<<"\t"<<dv[MaxND-1]<<"\t";
if(dv[MaxND-1]<dv[MaxND-2]) COut<<"Min"<<Endl;
else COut<<"Max"<<Endl;
return 0;
}
| [
"junwang.nju@gmail.com"
] | junwang.nju@gmail.com |
b65539f0ed00e8d0aaeaca8fc8813325850288a3 | aa701cd580bb209e958897b885b76988671ccc86 | /450-Questions-List/Array/problem18.cpp | 5c6605dba1144d973e02915735436475e5fcd160 | [] | no_license | rahulMishra05/DSA-Problems | b0b51e720e8e7fd5278fe77376d6e5e390754639 | 8cbc6cf05b279f9c9b125e7dffb01e9adf359d35 | refs/heads/main | 2023-08-14T21:47:56.097005 | 2021-09-30T10:28:32 | 2021-09-30T10:28:32 | 361,634,452 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 887 | cpp | // Question 18 => Find all pairs on integer array whose sum is equal to given number
#include<bits/stdc++.h>
using namespace std;
int getSum1(int arr[], int n, int sum){
int count = 0;
for(int i=0; i<n; i++){
for(int j=i+1; j<n; j++){
if(arr[i] + arr[j] == sum){
count++;
}
}
}
return count;
}
int getPairsCount(int arr[], int n, int sum){
int count =0;
unordered_map<int,int> m;
for(int i=0; i<n; i++){
int x = sum - arr[i];
if(m[x] == 0){
m[arr[i]]++;
}
else{
count +=m[x];
m[arr[i]]++;
}
}
return count;
}
int main(){
int arr[] = {1,5,7,-1};
int n = sizeof(arr) / sizeof(arr[0]);
int number = 6;
cout<<getSum1(arr, n, number)<<endl;
cout<<getPairsCount(arr, n, number);
} | [
"rahulmishra102000@gmail.com"
] | rahulmishra102000@gmail.com |
600ccdc6a596996d2c376c1955d30238245877c0 | cef7325a55895b26faa7bf006a9417e52d109db8 | /llvm-4.0.0.src/projects/compiler-rt/lib/scudo/scudo_crc32.h | 6635cc78bbab84e7df99cbb14901c0a800ff5b63 | [
"NCSA",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | GJDuck/LowFat | ee4c7c450e9fe64f90e00fc9053b0123f3dc0754 | 20f8075dd1fd6588700262353c7ba619d82cea8f | refs/heads/master | 2022-05-20T20:47:23.759875 | 2022-03-26T23:38:41 | 2022-03-26T23:38:41 | 109,212,497 | 177 | 35 | NOASSERTION | 2022-03-06T05:03:42 | 2017-11-02T03:18:19 | C++ | UTF-8 | C++ | false | false | 747 | h | //===-- scudo_crc32.h -------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// Header for scudo_crc32.cpp.
///
//===----------------------------------------------------------------------===//
#ifndef SCUDO_CRC32_H_
#define SCUDO_CRC32_H_
#include "sanitizer_common/sanitizer_internal_defs.h"
namespace __scudo {
enum : u8 {
CRC32Software = 0,
CRC32Hardware = 1,
};
u32 computeCRC32(u32 Crc, uptr Data, u8 HashType);
} // namespace __scudo
#endif // SCUDO_CRC32_H_
| [
"gregory@comp.nus.edu.sg"
] | gregory@comp.nus.edu.sg |
dc7f7f2741bde2b301778132ccc170e07582b7dc | a06a9ae73af6690fabb1f7ec99298018dd549bb7 | /_Library/_Include/boost/fusion/adapted/std_tuple/detail/size_impl.hpp | 11fb60a356ab5cd829a0dd8b75e25eb7620bd4e8 | [
"BSL-1.0"
] | permissive | longstl/mus12 | f76de65cca55e675392eac162dcc961531980f9f | 9e1be111f505ac23695f7675fb9cefbd6fa876e9 | refs/heads/master | 2021-05-18T08:20:40.821655 | 2020-03-29T17:38:13 | 2020-03-29T17:38:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,334 | hpp | ////////////////////////////////////////////////////////////////////////////////
// size_impl.hpp
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_SIZE_IMPL_09242011_1744)
#define BOOST_FUSION_SIZE_IMPL_09242011_1744
#include <boost/fusion/support/config.hpp>
#include <tuple>
#include <boost/mpl/int.hpp>
#include <boost/type_traits/remove_const.hpp>
namespace boost { namespace fusion
{
struct std_tuple_tag;
namespace extension
{
template<typename T>
struct size_impl;
template <>
struct size_impl<std_tuple_tag>
{
template <typename Sequence>
struct apply :
mpl::int_<std::tuple_size<
typename remove_const<Sequence>::type>::value
>
{};
};
}
}}
#endif
/////////////////////////////////////////////////
// vnDev.Games - Trong.LIVE - DAO VAN TRONG //
////////////////////////////////////////////////////////////////////////////////
| [
"adm.fael.hs@gmail.com"
] | adm.fael.hs@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.