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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
01554b1db0e62dbcd29ea2da4e2216f801b0353c | 8bd146bb7931dc0bbb08f086c980bc4a299357df | /Source/FightingGameControls/Private/BehaviourTasks/FindNextWaypoint.cpp | 86720818a1e1361cd36de9a4291e1f176059e19a | [] | no_license | gongchao1212a/LargeScaleAIProject | c0563832c4e35235337d81e226d8cc62d0e1977d | e3b84505a0e4dbbd407a8622365d80870fad196d | refs/heads/master | 2023-04-03T17:46:48.392753 | 2018-05-20T10:26:32 | 2018-05-20T10:26:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 525 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "FightingGameControls.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "BehaviourTasks/FindNextWaypoint.h"
EBTNodeResult::Type UFindNextWaypoint::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
UBlackboardComponent* blackboardComponent = OwnerComp.GetBlackboardComponent();
int32 waypointIndex = blackboardComponent->GetValueAsInt(WaypointIndexKey.SelectedKeyName);
return EBTNodeResult::Succeeded;
}
| [
"alastairmelville1@gmail.com"
] | alastairmelville1@gmail.com |
994de6c0b3ea4384337c44fdaa513aa0a5878b1d | 1dacbf90eeb384455ab84a8cf63d16e2c9680a90 | /include/dynd/types/any_kind_type.hpp | 550220c6de60357d0f68c70d9d8c993b560ac7bd | [
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-unknown"
] | permissive | wangyum/Anaconda | ac7229b21815dd92b0bd1c8b7ec4e85c013b8994 | 2c9002f16bb5c265e0d14f4a2314c86eeaa35cb6 | refs/heads/master | 2022-10-21T15:14:23.464126 | 2022-10-05T12:10:31 | 2022-10-05T12:10:31 | 76,526,728 | 11 | 10 | Apache-2.0 | 2022-10-05T12:10:32 | 2016-12-15T05:26:12 | Python | UTF-8 | C++ | false | false | 2,305 | hpp | //
// Copyright (C) 2011-15 DyND Developers
// BSD 2-Clause License, see LICENSE.txt
//
#pragma once
#include <dynd/type.hpp>
namespace dynd {
namespace ndt {
class DYNDT_API any_kind_type : public base_type {
public:
any_kind_type();
size_t get_default_data_size() const;
void print_data(std::ostream &o, const char *arrmeta, const char *data) const;
void print_type(std::ostream &o) const;
bool is_expression() const;
bool is_unique_data_owner(const char *arrmeta) const;
void transform_child_types(type_transform_fn_t transform_fn, intptr_t arrmeta_offset, void *extra,
type &out_transformed_tp, bool &out_was_transformed) const;
type get_canonical_type() const;
type at_single(intptr_t i0, const char **inout_arrmeta, const char **inout_data) const;
type get_type_at_dimension(char **inout_arrmeta, intptr_t i, intptr_t total_ndim = 0) const;
intptr_t get_dim_size(const char *arrmeta, const char *data) const;
void get_shape(intptr_t ndim, intptr_t i, intptr_t *out_shape, const char *arrmeta, const char *data) const;
bool is_lossless_assignment(const type &dst_tp, const type &src_tp) const;
bool operator==(const base_type &rhs) const;
void arrmeta_default_construct(char *arrmeta, bool blockref_alloc) const;
void arrmeta_copy_construct(char *dst_arrmeta, const char *src_arrmeta,
const intrusive_ptr<memory_block_data> &embedded_reference) const;
void arrmeta_reset_buffers(char *arrmeta) const;
void arrmeta_finalize_buffers(char *arrmeta) const;
void arrmeta_destruct(char *arrmeta) const;
void arrmeta_debug_print(const char *arrmeta, std::ostream &o, const std::string &indent) const;
size_t arrmeta_copy_construct_onedim(char *dst_arrmeta, const char *src_arrmeta,
memory_block_data *embedded_reference) const;
void data_destruct(const char *arrmeta, char *data) const;
void data_destruct_strided(const char *arrmeta, char *data, intptr_t stride, size_t count) const;
bool match(const type &candidate_tp, std::map<std::string, type> &tp_vars) const;
static type make() { return type(new any_kind_type(), false); }
};
} // namespace dynd::ndt
} // namespace dynd
| [
"wgyumg@mgail.com"
] | wgyumg@mgail.com |
53ea43e18f10290dcd5d074f5bc36bc44f2e454a | a52a9039585d9e04a52fa3439e84afde87086450 | /程序代码/牛客/hw/hw_bottle.cpp | a0c9e6178d98db5b9b4d42ce2cb4f1bb6e40138b | [] | no_license | AlexZhanghao/Algorithm--notes | 4c676c761274b45c34b061cb8c4630799895cf86 | 9acea2824f29f32c82272cf868b16baec54d9c7f | refs/heads/master | 2020-09-25T23:36:31.291835 | 2020-09-16T11:22:14 | 2020-09-16T11:22:14 | 226,114,339 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 131 | cpp | #include<iostream>
using namespace std;
int main(){
int n;
while(cin>>n){
cout<<n/2<<endl;
}
return 0;
} | [
"363040909@qq.com"
] | 363040909@qq.com |
d4e2a479c0c45ab1395d37fd2726aca941d8d4d0 | d069af8cd661e509666cc669f3de2eeb9564acb4 | /CppSamples/Source/Tags/ViewAllTags.h | ecbd8dae825bb656a10df24fc55e3bdf3588b158 | [] | no_license | matiasfigue/VxSDK-Samples | 7e057540e37866abde97fb7b16f9af568fe049f9 | d1162dd9142204c83d719ffd0048871b8bd75f44 | refs/heads/master | 2022-10-06T23:31:20.325527 | 2020-06-04T20:09:58 | 2020-06-04T20:09:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,401 | h | #pragma once
#include "Plugin.h"
#include "VxSdk.h"
namespace CppSamples {
namespace Tags {
/// <summary>
/// This plugin sample print all tags available in the current system.
/// </summary>
class ViewAllTags : public CppSamples::Common::Plugin {
public:
ViewAllTags(const std::string description) : CppSamples::Common::Plugin(description) { }
~ViewAllTags() { }
/// <summary>
/// Print all tags available in the current system.
/// </summary>
/// <param name="dataModel">Instance of data model.</param>
CppSamples::Common::Plugin* Run(CppSamples::Common::DataModel* dataModel) override;
protected:
/// <summary>
/// Get a collection of tags from the given VideoExpert system.
/// </summary>
/// <param name="vxSystem">Pointer to the VideoExpert system.</param>
/// <returns>A collection of tags.</returns>
static VxSdk::VxCollection<VxSdk::IVxTag**> GetTags(VxSdk::IVxSystem* vxSystem);
/// <summary>
/// Prints the given collection of tags to the screen.
/// </summary>
/// <param name="tagCollection">Collection of tags.</param>
static void PrintTags(VxSdk::VxCollection<VxSdk::IVxTag**> tagCollection);
};
}
}
| [
"Zach.Moore@schneider-electric.com"
] | Zach.Moore@schneider-electric.com |
af7d7d099781cac1456819cf80880de32402a842 | 26289394abd7e98e22fe02e74fedd99cfbcd5132 | /Effective_C++/Item02_constantVariable/main.cpp | 2afde2f6b3505bd02f87e299ce1b3f2af4b76e4f | [] | no_license | cnyzgkn/C- | 7c85cb1f4a5e08ecd5ec453111d2115e2ea2093c | 06ff4c099c4de46f006cc96281c5de8d698f2def | refs/heads/master | 2020-04-12T07:20:41.716391 | 2019-09-03T11:21:20 | 2019-09-03T11:21:20 | 65,672,910 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 158 | cpp | #include <stdlib.h>
#include <iostream>
#include "constVariable.h"
int main()
{
std::cout << &a << std::endl;
std::cout << &b << std::endl;
return 1;
}
| [
"cnyzgkn@gmail.com"
] | cnyzgkn@gmail.com |
4c82f02c8603fd704efb9119442b471d8b6c673a | cd814e4f6c34f37a9796e0ef55652f6bbe692e9e | /SonificationEngine.h | eea00f5f2e33b2cf1954a9df817292acbc511355 | [] | no_license | harimohanraj89/SoniScan | 1e107ce31d9f00d6b2922128f3f0bd911a991bf7 | d00c11b57f18123a73740888a3bcfad334120095 | refs/heads/master | 2021-01-01T18:33:32.024241 | 2014-10-13T23:59:48 | 2014-10-13T23:59:48 | 12,720,935 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,546 | h | //
// SonificationEngine.h
// SoniScan_2_0
//
// Created by Hariharan Mohanraj on 4/15/13.
// Copyright (c) 2013 Hariharan Mohanraj. All rights reserved.
//
#ifndef __SoniScan_2_0__SonificationEngine__
#define __SoniScan_2_0__SonificationEngine__
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include "Constants.h"
class SonificationEngine
{
float ***masterData;
int masterDataSize[3];
int mode; // Mode : 1 = instrument grid mode
int scan; // Scan : 0 = All at once
// 1 = Left-to-Right scan
// 2 = Center-Outwards scan
int slice; // Slice : Current slice number
int instr; // Instr : Temp instrument number for score file writing
int currInstr;
int output; // Output: 0 = Csound instrument and audio output
// 1 = MIDI file output
float centerFreq; // Center Freq: Mode 1 center (reference) frequency
float detuneFactor; // Detune Factor: Mode 1 sensitivity, ie...
// freqRatioDeviation = intensityRatioDeviation * detuneFactor
float instrBoundaries[NUM_INSTR+1]; // Specifies the boundaries at which the instrument transitions are made
// for Mode 3 sonification
char bareOutputFile[MAX_SCORELINE_LENGTH];
char outputfile[MAX_SCORELINE_LENGTH];
char dataFilename[MAX_SCORELINE_LENGTH];
// Score statement variables
char scoreLine[MAX_SCORELINE_LENGTH];
float startTime;
float duration;
int noteIndex;
float panValue;
float amplitude;
int midiVelocity;
int midiPan;
// Slice size variables
int sliceWidthL;
int sliceWidthR;
int sliceHeightU;
int sliceHeightD;
int sliceWidth;
int sliceHeight;
public:
void SetDataFilename(char*);
int GetMode();
void SetMode(int);
int GetScan();
void SetScan(int);
int GetSlice();
void SetSlice(int);
int GetInstr();
void SetInstr(int);
int GetOutput();
void SetOutput(int);
char* GetOutputFile();
void SetOutputFile(char*);
float GetInstrBoundary(int);
void SetInstrBoundary(float,int);
float GetCenterFreq();
void SetCenterFreq(float);
float GetDetuneFactor();
void SetDetuneFactor(float);
// -----------------------------------
void SetMasterData(float***,int[]);
void SonifySelect();
// Sonification utility functions
bool PointUpLine(int, int, int, int, int, int);
bool PointRightLine(int, int, int, int, int, int);
int GetInstrNum(float);
int GetLobe(int, int);
void UpdateSliceSize();
void UpdateScoreLine(float,float,float);
void WriteHeader(std::ofstream&);
void WriteFooter(std::ofstream&);
void WriteToLog(char* , float[], float[], float[], float[]);
void GenerateLines(char*,char*,char*);
void DisplayDiagnostics(char*,char*,char*,int[]);
// Mode 1 Sonification
// Grid-based average, score
void ModeOneSonify();
// Mode 2 Sonification
// Individual voxel, score
void ModeTwoSonify();
// Mode 3 Sonification
// Individual voxel, intensity to instrument
void ModeThreeSonify();
// Constructor
SonificationEngine();
};
#endif /* defined(__SoniScan_2_0__SonificationEngine__) */
| [
"hari.mohanraj89@gmail.com"
] | hari.mohanraj89@gmail.com |
9b1aebdc8296c3d90baa9360b656f93b901374a0 | 5622a89fdec9648747c6826dfaac00c7af16a6f9 | /Arduino101/Arduino101_06_Servo.ino/Arduino101_06_Servo.ino.ino | 97be3f3fc767e577e5bbf3d05ea99d5906e1ec8f | [] | no_license | Makers-Im-Zigerschlitz/Kursunterlagen | 1f330b3eb1cab7e0b973c017c4768a89d19602e2 | 1410a0d85fb7dfa8f44fc952f8fff9c6e1264c0d | refs/heads/master | 2021-09-18T11:57:57.447455 | 2018-07-13T20:15:08 | 2018-07-13T20:15:08 | 93,192,373 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,258 | ino | /*
Bewegt einen Servo
*/
#include <Servo.h> // Fügt den Inhalt einer zweiten Datei die "Servo.h" heisst in dieses Programm ein. Dies nennt man auch Bibliothek
Servo myservo; // Erstellt ein Servo Objekt um einen Servo zu kontrollieren (bis zu 12 auf den meisten Arduino-Boards möglich)
int pos = 0; // Variable, welche die Position des Servos speichert
// Die Setup-Schleife läuft nach dem Start des Arduino genau 1x durch
void setup() {
myservo.attach(9); // Sagt unserem Servo-Objekt, dass die Ausgabe über Pin 9 erfolgen soll.
}
// Die Loop-Funktion wiederholt sich immer wieder solange das Gerät Strom hat.
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // Geht von 0 bis 180 Grad in Schritten von 1°
myservo.write(pos); // Gibt die Gewünschte Position "pos" an den Servo in Form einer PWM-Welle durch
delay(15); // Wartet 15ms bis der Servo diese Position erreicht hat
}
for (pos = 180; pos >= 0; pos -= 1) { // Geht von 180 bis 0 Grad in Schritten von 1°
myservo.write(pos); // Gibt die Gewünschte Position "pos" an den Servo in Form einer PWM-Welle durch
delay(15); // Wartet 15ms bis der Servo diese Position erreicht hat
}
}
| [
"mike.zweifel@zigerschlitzmakers.ch"
] | mike.zweifel@zigerschlitzmakers.ch |
81e03f4e6ecc1ea79519678a6bbfe97b67b44637 | d2659ff70cfcb1d526ee8ca589dab0faa5162784 | /trieNode.cpp | c28064fa27814f0e578d99101d722c83b6012eaf | [] | no_license | lea82/Longest-Compound-Word | 3f8da717726d2e8ee232e2dc61b777284d60830e | aca60d3984374a26ce5fa9ec3a6d7068dfcb07ae | refs/heads/master | 2021-01-21T19:05:51.513916 | 2014-01-27T00:58:28 | 2014-01-27T00:58:28 | 39,536,560 | 0 | 0 | null | 2015-07-23T00:14:07 | 2015-07-23T00:14:07 | null | UTF-8 | C++ | false | false | 298 | cpp | #include "trieNode.h"
namespace words
{
TrieNode :: TrieNode(int arity) {
word_end = false;
no_of_children = arity;
for (int i = 0; i < no_of_children; i++) {
children.push_back(NULL);
}
}
}
| [
"shashankdevan@gmail.com"
] | shashankdevan@gmail.com |
9c15738fee9693ef7b8ed80783b3eda32b763242 | 5b7c4cda91658f77eb0ac166ac997bae010010c4 | /Sem II/SD/Laborator/Laborator 3/Tema Laborator 3/3.2.cpp | ad5aa6746b5e2181ac5cd6600db0c99870c58cd1 | [] | no_license | VLCDaniel/fmi | c9a34ea84e5f00a918413857ee362c652e4d1f10 | a21896a5cbf7a0ecf0d489d0074694169fd24260 | refs/heads/master | 2020-12-12T08:26:34.547450 | 2020-05-05T15:00:56 | 2020-05-05T15:00:56 | 245,807,556 | 9 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,809 | cpp | #include <iostream>
int n, v[100], tos = 0;
void insert(int x)
{
n++;
int aux, i = n - 1;
v[i] = x; // il inserez pe x pe ultima pozitie
while ((i - 1) / 2 >= 0 && v[(i - 1) / 2] > v[i]) // actualizez heap-ul verificand daca x este mai mare ca tatal lui(si ca acesta exista)
{
aux = v[i];
v[i] = v[(i - 1) / 2];
i = (i - 1) / 2;
v[i] = aux;
}
}
void afisare()
{
for (int i = 0; i < n; i++)
{
std::cout << v[i] << ' ';
}
std::cout << '\n';
}
void citire()
{
std::cout << "n= ";
std::cin >> n;
for (int i = 0; i < n; i++)
{
std::cout << "v[" << i << "]= ";
int x;
std::cin >> x;
v[tos] = x;
int j = tos;
while ((j - 1) / 2 >= 0 && v[(j - 1) / 2] > v[j]) // actualizez heap-ul verificand daca x este mai mare ca tatal lui(si ca acesta exista)
{
int aux;
aux = v[j];
v[j] = v[(j - 1) / 2];
j = (j - 1) / 2;
v[j] = aux;
}
tos++;
}
std::cout << '\n';
}
void swap(int& a, int& b)
{
int aux = a;
a = b;
b = aux;
}
int pop_min()
{
if (n != 0)
{
swap(v[0], v[n - 1]);
n--;
int i = 0;
while (2 * i + 1 < n) // cat timp exista fiul stang
{
if (2 * i + 2 < n) // daca exista fiul drept
{
if (v[i] <= v[2 * i + 1] && v[i] <= v[2 * i + 2]) // daca v[i] e mai mic ca fii sai, e pe pozitia corecta.
{
return v[n];
}
if (v[2 * i + 1] < v[2 * i + 2]) // daca fiul stang < fiul drept
{
if (v[i] > v[2 * i + 1])
{
swap(v[i], v[2 * i + 1]);
i = 2 * i + 1;
}
}
else // daca fiul drept < fiul stang
{
if (v[i] > v[2 * i + 2])
{
swap(v[2 * i + 2], v[i]);
i = 2 * i + 2;
}
}
}
else // daca nu exista fiul drept
{
if (v[i] > v[2 * i + 1])
{
swap(v[i], v[2 * i + 1]);
i = 2 * i + 1;
}
else
{
return v[n];
}
}
}
return v[n];
}
}
int main()
{
citire(); // 12 ; 2 4 5 9 7 10 9 15 20 13 18 14
int a[100];
int i = 0;
while (tos != 0)
{
a[i] = pop_min();
i++;
tos--;
}
for (int j = 0; j < i; j++)
{
std::cout << a[j] << ' ';
}
return 0;
} | [
"vlascenco.daniel@yahoo.com"
] | vlascenco.daniel@yahoo.com |
f1ce9a7466382d2ee64f1d2e042a01ad35434ed1 | a92b18defb50c5d1118a11bc364f17b148312028 | /src/prod/src/ServiceModel/ServiceFabricRuntimeAccessDescription.cpp | 7a72d2372c6a3dbd57cf959333fd97d4c0737e5a | [
"MIT"
] | permissive | KDSBest/service-fabric | 34694e150fde662286e25f048fb763c97606382e | fe61c45b15a30fb089ad891c68c893b3a976e404 | refs/heads/master | 2023-01-28T23:19:25.040275 | 2020-11-30T11:11:58 | 2020-11-30T11:11:58 | 301,365,601 | 1 | 0 | MIT | 2020-11-30T11:11:59 | 2020-10-05T10:05:53 | null | UTF-8 | C++ | false | false | 3,987 | cpp | //------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
#include "stdafx.h"
using namespace std;
using namespace Common;
using namespace ServiceModel;
ServiceFabricRuntimeAccessDescription::ServiceFabricRuntimeAccessDescription()
: RemoveServiceFabricRuntimeAccess(false),
UseServiceFabricReplicatedStore(false)
{
}
ServiceFabricRuntimeAccessDescription::ServiceFabricRuntimeAccessDescription(ServiceFabricRuntimeAccessDescription && other)
: RemoveServiceFabricRuntimeAccess(other.RemoveServiceFabricRuntimeAccess),
UseServiceFabricReplicatedStore(other.UseServiceFabricReplicatedStore)
{
}
ServiceFabricRuntimeAccessDescription::ServiceFabricRuntimeAccessDescription(ServiceFabricRuntimeAccessDescription const& other)
: RemoveServiceFabricRuntimeAccess(other.RemoveServiceFabricRuntimeAccess),
UseServiceFabricReplicatedStore(other.UseServiceFabricReplicatedStore)
{
}
ServiceFabricRuntimeAccessDescription const & ServiceFabricRuntimeAccessDescription::operator=(
ServiceFabricRuntimeAccessDescription && other)
{
if (this != &other)
{
RemoveServiceFabricRuntimeAccess = other.RemoveServiceFabricRuntimeAccess;
UseServiceFabricReplicatedStore = other.UseServiceFabricReplicatedStore;
}
return *this;
}
ServiceFabricRuntimeAccessDescription const & ServiceFabricRuntimeAccessDescription::operator=(
ServiceFabricRuntimeAccessDescription const & other)
{
if (this != &other)
{
RemoveServiceFabricRuntimeAccess = other.RemoveServiceFabricRuntimeAccess;
UseServiceFabricReplicatedStore = other.UseServiceFabricReplicatedStore;
}
return *this;
}
bool ServiceFabricRuntimeAccessDescription::operator==(ServiceFabricRuntimeAccessDescription const & other) const
{
return RemoveServiceFabricRuntimeAccess == other.RemoveServiceFabricRuntimeAccess &&
UseServiceFabricReplicatedStore == other.UseServiceFabricReplicatedStore;
}
bool ServiceFabricRuntimeAccessDescription::operator!=(ServiceFabricRuntimeAccessDescription const & other) const
{
return !(*this == other);
}
void ServiceFabricRuntimeAccessDescription::WriteTo(TextWriter & w, FormatOptions const &) const
{
w.Write(wformatString(
"ServiceFabricRuntimeAccessDescription (RemoveServiceFabricRuntimeAccess = {0}, UseServiceFabricReplicatedStore = {1})",
RemoveServiceFabricRuntimeAccess,
UseServiceFabricReplicatedStore));
}
void ServiceFabricRuntimeAccessDescription::ReadFromXml(Common::XmlReaderUPtr const & xmlReader)
{
// <ServiceFabricRuntimeAccessPolicy RemoveServiceFabricRuntimeAccess=true>
xmlReader->StartElement(
*SchemaNames::Element_ServiceFabricRuntimeAccessPolicy,
*SchemaNames::Namespace);
if (xmlReader->HasAttribute(*SchemaNames::Attribute_RemoveServiceFabricRuntimeAccess))
{
auto removeServiceFabricRuntimeAccessString = xmlReader->ReadAttributeValue(*SchemaNames::Attribute_RemoveServiceFabricRuntimeAccess);
if (!StringUtility::TryFromWString<bool>(
removeServiceFabricRuntimeAccessString,
this->RemoveServiceFabricRuntimeAccess))
{
Parser::ThrowInvalidContent(xmlReader, L"RemoveServiceFabricRuntimeAccess", removeServiceFabricRuntimeAccessString);
}
}
if (xmlReader->HasAttribute(*SchemaNames::Attribute_UseServiceFabricReplicatedStore))
{
auto useSFReplicatedStore = xmlReader->ReadAttributeValue(*SchemaNames::Attribute_UseServiceFabricReplicatedStore);
if (!StringUtility::TryFromWString<bool>(
useSFReplicatedStore,
this->UseServiceFabricReplicatedStore))
{
Parser::ThrowInvalidContent(xmlReader, L"UseServiceFabricReplicatedStore", useSFReplicatedStore);
}
}
// Read the rest of the empty element
xmlReader->ReadElement();
}
| [
"noreply-sfteam@microsoft.com"
] | noreply-sfteam@microsoft.com |
1b026e17691a93d2a5e2db34442ee9191b822a41 | a995091ae322b16728a5be9f1c551e413f57cfa9 | /logdevice/server/RebuildingLogEnumerator.cpp | cffdcb50d8f01214aeecc559f38ad4e64a23475b | [
"BSD-3-Clause"
] | permissive | ethio123/LogDevice | 3fb387058eedee05c52fffd9b05384a093b3dd4a | f5083568dd295fb750ed39d2a336a22486bd106c | refs/heads/master | 2020-04-08T00:59:19.185546 | 2018-11-23T14:48:08 | 2018-11-23T14:49:53 | 158,876,580 | 1 | 0 | NOASSERTION | 2018-11-23T20:46:37 | 2018-11-23T20:46:37 | null | UTF-8 | C++ | false | false | 5,500 | cpp | /**
* Copyright (c) 2017-present, Facebook, Inc. and its affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "logdevice/server/RebuildingLogEnumerator.h"
#include "logdevice/common/LegacyLogToShard.h"
#include "logdevice/common/configuration/Configuration.h"
#include "logdevice/common/configuration/UpdateableConfig.h"
#include "logdevice/server/RebuildingEnumerateMetadataLogsTask.h"
#include "logdevice/server/ServerWorker.h"
#include "logdevice/server/storage_tasks/PerWorkerStorageTaskQueue.h"
namespace facebook { namespace logdevice {
void RebuildingLogEnumerator::start() {
auto cur_timestamp = RecordTimestamp::now();
auto logs_config = config_->getLogsConfig();
ld_check(logs_config->isLocal());
ld_check(logs_config->isFullyLoaded());
auto local_logs_config =
checked_downcast<configuration::LocalLogsConfig*>(logs_config.get());
uint32_t internalSkipped = 0;
uint32_t dataSkipped = 0;
for (auto it = local_logs_config->logsBegin();
it != local_logs_config->logsEnd();
++it) {
const logid_t logid(it->first);
// Tests don't rebuild internal logs.
if (!rebuild_internal_logs_ &&
configuration::InternalLogs::isInternal(logid)) {
internalSkipped++;
continue;
}
// Let's try and approximate the next timestamp for this log. If the log has
// no backlog configured, it is set to -inf. Otherwise, the next timestamp
// is the current timestamp minus the backlog value.
// Note that this value does not have to be precise. The goal here is to
// maximize the chances that the first time we read a batch for a log we
// will read some records instead of having the batch stop as soon as it
// encounters the first record.
const auto& backlog =
it->second.log_group->attrs().backlogDuration().value();
// FIXME: Ideally we want to delay SHARD_IS_REBUILT past the
// maxBacklogDuration only if we have logs relevant to the failed shard. But
// not sure if it's possible to determine that without performing copy-set
// iteration. Simpler to just track the biggest backlog.
if (rebuilding_settings_->disable_data_log_rebuilding &&
!MetaDataLog::isMetaDataLog(logid) && backlog.hasValue()) {
// We want to skip over data logs with a finite backlog but we don't
// want to notify that the shard is rebuilt until after the contents
// of the longest-lived log, since rebuild was requested, has expired.
//
// This ensures that readers will correctly account for the shard as
// still rebuilding for the purpose of FMAJORITY calculation. To
// accomplish this, we track the log with the max backlog and only
// trigger SHARD_IS_REBUILT after that logs current data has expired.
if (backlog.value() > maxBacklogDuration_) {
maxBacklogDuration_ = backlog.value();
}
dataSkipped++;
continue;
}
RecordTimestamp next_ts = RecordTimestamp::min();
if (backlog.hasValue()) {
next_ts = cur_timestamp - backlog.value();
}
// Don't start lower than the lower bound of a time-ranged rebuild.
next_ts.storeMax(min_timestamp_);
// TODO: T31009131 stop using the getLegacyShardIndexForLog() function
// altogether.
if (getLegacyShardIndexForLog(logid, num_shards_) == shard_idx_ ||
!rebuilding_settings_->use_legacy_log_to_shard_mapping_in_rebuilding) {
ld_assert(result_.find(logid) == result_.end());
result_.emplace(logid, next_ts);
}
}
ld_info("Enumerator skipped %d internal and %d data logs. Queued %ld logs "
"for rebuild.",
internalSkipped,
dataSkipped,
result_.size());
if (rebuild_metadata_logs_) {
putStorageTask();
} else {
finalize();
}
}
void RebuildingLogEnumerator::putStorageTask() {
auto task = std::make_unique<RebuildingEnumerateMetadataLogsTask>(
ref_holder_.ref(), num_shards_);
auto task_queue =
ServerWorker::onThisThread()->getStorageTaskQueueForShard(shard_idx_);
task_queue->putTask(std::move(task));
}
void RebuildingLogEnumerator::onMetaDataLogsStorageTaskDone(
Status st,
std::vector<logid_t> log_ids) {
if (st != E::OK) {
RATELIMIT_ERROR(std::chrono::seconds(10),
1,
"Unable to enumerate metadata logs for rebuilding on shard "
"%u, version %s: %s. Retrying...",
shard_idx_,
lsn_to_string(version_).c_str(),
error_description(st));
putStorageTask();
return;
}
for (logid_t l : log_ids) {
result_.emplace(l, min_timestamp_);
}
finalize();
}
void RebuildingLogEnumerator::onMetaDataLogsStorageTaskDropped() {
// Retrying
RATELIMIT_WARNING(std::chrono::seconds(10),
1,
"Storage task for enumerating metadata logs dropped for "
"rebuilding on shard %u, version %s. Retrying...",
shard_idx_,
lsn_to_string(version_).c_str());
putStorageTask();
}
void RebuildingLogEnumerator::finalize() {
ld_check(!finalize_called_);
finalize_called_ = true;
callback_->onLogsEnumerated(
shard_idx_, version_, std::move(result_), maxBacklogDuration_);
// `this` may be destroyed here.
}
}} // namespace facebook::logdevice
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
8bc536e3d25bc5498852e2e9c9e6eabe6107990a | a20ce07bc9a20c2109b3a8f439799b794e6912f0 | /src/Leader.hpp | 59c912b4e9a23d5bf95bcb7286f1354c82492b77 | [] | no_license | VBS1998/Algoritmos-Sistemas-Distribuidos | 5fbc3d23aaad8d586ea51112218df9f507a21c22 | 2a9cae116645d4294874a9129c19e312f34834de | refs/heads/main | 2023-02-13T08:10:55.738023 | 2021-01-15T14:53:09 | 2021-01-15T14:53:09 | 328,399,568 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 172 | hpp | #include <unistd.h>
#include "MPI_Service.hpp"
class Leader{
public:
int leader_rank;
Leader();
int start_election();
int check_leader();
}; | [
"gustavovbs98@gmail.com"
] | gustavovbs98@gmail.com |
0b04ef2f0919adaa6ee8cba1124c6e229424cc53 | 4a3685c655ef22b52d91097e5063e15280ea1706 | /aprspacket.cpp | 2f8cd74ad1b0b48023cee59c7b12b62495316f55 | [
"BSD-3-Clause"
] | permissive | Hibby/Teset | dfc312004b9eb8a4cadc3d377228d864b6415b42 | 4286b7ad24489ea2a10cc1f2e6c6ea61acdcb336 | refs/heads/master | 2021-01-22T21:59:35.815436 | 2017-05-03T22:25:01 | 2017-05-03T22:25:01 | 85,499,888 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,017 | cpp | #include "aprspacket.h"
#include <QVariant>
#include <QDebug>
#include <QString>
#include <QtSql>
#include <QDateTime>
#include <fap.h>
aprspacket::aprspacket()
{
}
// Incoming data from aprsis.cpp - readyRead function
void aprspacket::parseAPRS(char *input) {
qDebug() << "Initialising LibFap";
fap_packet_t* packet;
unsigned int input_len = strlen(input);
char errmsg[256];
fap_init();
qDebug() << "initialised";
packet = fap_parseaprs(input, input_len, 0);
qDebug() << "packet input";
if ( packet->error_code )
{
qDebug() << "packet error";
fap_explain_error(*packet->error_code, errmsg);
qDebug() << errmsg;
}
else if ( packet->src_callsign )
{
qDebug() << "packet parsed";
qDebug() << packet->src_callsign;
qDebug() << *packet->type;
qDebug() << *packet->latitude;
qDebug() << *packet->longitude;
//newPacketChanged(packet->src_callsign);
QSqlQuery query;
if (!query.exec(QLatin1String("create table stations(callsign varchar, type int, latitude float, longitude float, comment varchar, timestamp qint64)"))){
}
query.prepare("INSERT INTO stations (callsign, type, latitude, longitude, comment, timestamp) " "VALUES (?, ?, ?, ?, ?, ?)");
query.addBindValue(packet->src_callsign);
query.addBindValue(*packet->type);
query.addBindValue(*packet->latitude);
query.addBindValue(*packet->longitude);
query.addBindValue(packet->comment);
query.addBindValue(QDateTime::currentMSecsSinceEpoch()/1000);
query.exec();
}
qDebug() << "packet cleaning";
fap_free(packet);
fap_cleanup();
}
| [
"d@vehibberd.com"
] | d@vehibberd.com |
7d366736914aea1fceb59a65576b33b25dcb1457 | 420f95cfa2a40d84a3f851b43ba2df691fab4814 | /src/sourceentry.cpp | 124bd0de2d24b4e41a7f457f1b2fe1653948154e | [
"MIT"
] | permissive | iwamatsu/PAmix | 0f6d85daa618d898a33195300234c02f5aba3017 | eb6e8f13db23c6c96cc7de2a3d70f65db0186adf | refs/heads/master | 2021-08-22T20:40:21.652551 | 2017-09-09T20:15:37 | 2017-09-09T20:15:37 | 112,411,139 | 0 | 0 | null | 2017-11-29T01:38:17 | 2017-11-29T01:38:17 | null | UTF-8 | C++ | false | false | 2,267 | cpp | #include <entry.hpp>
void SourceEntry::update(const pa_source_info *info)
{
m_Name = info->description;
m_Index = info->index;
m_Mute = info->mute;
m_MonitorIndex = m_Index;
m_PAVolume = info->volume;
m_PAChannelMap = info->channel_map;
m_Kill = false;
m_Ports.clear();
m_Port = -1;
for (unsigned i = 0; i < info->n_ports; i++)
{
m_Ports.push_back(info->ports[i]->name);
if (info->active_port == info->ports[i])
m_Port = i;
}
m_State = info->state;
}
void SourceEntry::setVolume(const int channel, const pa_volume_t volume)
{
mainloop_lockguard lg(interface->getPAMainloop());
pa_cvolume *cvol = &m_PAVolume;
if (m_Lock)
pa_cvolume_set(cvol, cvol->channels, volume);
else
cvol->values[channel] = volume;
pa_operation *op = pa_context_set_source_volume_by_index(interface->getPAContext(), m_Index, cvol, &PAInterface::cb_success, interface);
while (pa_operation_get_state(op) == PA_OPERATION_RUNNING)
pa_threaded_mainloop_wait(interface->getPAMainloop());
pa_operation_unref(op);
}
void SourceEntry::setMute(bool mute)
{
mainloop_lockguard lg(interface->getPAMainloop());
pa_operation *op = pa_context_set_source_mute_by_index(interface->getPAContext(), m_Index, mute, &PAInterface::cb_success, interface);
while (pa_operation_get_state(op) == PA_OPERATION_RUNNING)
pa_threaded_mainloop_wait(interface->getPAMainloop());
pa_operation_unref(op);
}
void SourceEntry::cycleSwitch(bool increment)
{
int delta = increment ? 1 : -1;
if (!m_Ports.size())
return;
m_Port = (m_Port + delta) % m_Ports.size();
pa_operation *op = pa_context_set_source_port_by_index(interface->getPAContext(), m_Index, m_Ports[m_Port].c_str(), &PAInterface::cb_success, interface);
while (pa_operation_get_state(op) == PA_OPERATION_RUNNING)
pa_threaded_mainloop_wait(interface->getPAMainloop());
pa_operation_unref(op);
}
void SourceEntry::setPort(const char *port)
{
mainloop_lockguard lg(interface->getPAMainloop());
pa_operation *op = pa_context_set_source_port_by_index(interface->getPAContext(), m_Index, port, &PAInterface::cb_success, interface);
while (pa_operation_get_state(op) == PA_OPERATION_RUNNING)
pa_threaded_mainloop_wait(interface->getPAMainloop());
pa_operation_unref(op);
}
| [
"jenschjoshua@gmail.com"
] | jenschjoshua@gmail.com |
17b65e754a17817b6c0a6e6eeaeca30ba9c9ee0a | 249ef4f24b8f043945c63d658a74c49c29a4e76e | /AuditTrailGenerator.h | 1d863bc91f67135e4cf00d3c330263a5e1819021 | [] | no_license | norman833/CMEAuditTrail-1 | f05beb5de6dbffbad99b39edf9eebd58045d4cab | 1e512cc143bebb42aa3917ac83107a45f10cd326 | refs/heads/master | 2020-04-11T22:36:41.131662 | 2018-03-10T09:09:23 | 2018-03-10T09:09:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 374 | h | #ifndef CMEAUDITTRAIL_AUDITTRAILGENERATOR_H
#define CMEAUDITTRAIL_AUDITTRAILGENERATOR_H
#include "quickfix/Message.h"
using namespace FIX;
class AuditTrailGenerator {
public:
static std::string generateAuditTrail(const Message& message, const std::string& txnTime);
static std::string generateHeader();
private:
};
#endif //CMEAUDITTRAIL_AUDITTRAILGENERATOR_H
| [
"zhiminhua@gmail.com"
] | zhiminhua@gmail.com |
f4c44eedcf2cfbc0dea4514aa2b8f42eb4b61ed5 | c48e0bf51dc894524ff724f6dafebdf32f84a032 | /virtualNumberKeyboard/VirtualKeyboard.cpp | c044b023fcee2ebb2732398588ecf7cc77f09776 | [] | no_license | urielyan/sunDemon | cc53890e39d82c06be7daee2dea3b5f710fb2941 | b2e2fa617eacdf8a9d22f8a9c5763115ff3a056e | refs/heads/master | 2021-09-06T22:22:12.141185 | 2018-02-12T12:22:10 | 2018-02-12T12:22:10 | 116,198,880 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,695 | cpp | #include "VirtualKeyboard.h"
#include "ui_VirtualKeyboard.h"
#include <QDebug>
VirtualKeyboard::VirtualKeyboard(QWidget *parent) :
Widget(parent),
ui(new Ui::VirtualKeyboard)
{
ui->setupUi(this);
QList<QPushButton *> allPButtons = this->findChildren<QPushButton *>();
foreach (QPushButton *b, allPButtons) {
connect(b, &QPushButton::clicked, this, &VirtualKeyboard::buttonsClicked);
}
}
VirtualKeyboard::~VirtualKeyboard()
{
delete ui;
}
QString VirtualKeyboard::getStr()
{
return ui->lineEdit->text();
}
void VirtualKeyboard::setInputMask(QString inputMask)
{
ui->lineEdit->setInputMask(inputMask);
}
void VirtualKeyboard::setInitText(QString str)
{
ui->lineEdit->setText(str);
}
void VirtualKeyboard::buttonsClicked()
{
QPushButton *b = static_cast<QPushButton*>(sender());
if (!b)
{
return;
}
//若不是数字则返回
bool ok = false;
float number = b->text().toFloat(&ok);
Q_UNUSED(number);
if (!ok)
{
return;
}
ui->lineEdit->setText(ui->lineEdit->text().append(b->text()));
//qDebug() << number << b->text() << ui->lineEdit->text().toFloat() << ok;
}
void VirtualKeyboard::on_backspace_clicked()
{
QString currentText = ui->lineEdit->text();
ui->lineEdit->setText(currentText.left(currentText.size() - 1));
}
void VirtualKeyboard::on_clear_clicked()
{
ui->lineEdit->clear();
}
void VirtualKeyboard::on_ok_clicked()
{
emit inputComplete(QString::number(ui->lineEdit->text().toFloat()));
qDebug() << ui->lineEdit->text().toFloat();
}
void VirtualKeyboard::on_point_clicked()
{
ui->lineEdit->setText(ui->lineEdit->text().append("."));
}
| [
"urielyan@sina.com"
] | urielyan@sina.com |
b42de89cc956e7415101a1f2995ce54b03847007 | e548acd89b81064247f293c36dced39183617db0 | /foo_spider_monkey_panel/js_objects/internal/fb_properties.cpp | dce9e1f2914eb673245dfdcc03cad617db3f9633 | [
"MIT"
] | permissive | hhy5277/foo_spider_monkey_panel | fcdbc9190881ee8599300289fc46739b7c01d184 | 4a4c1256cced7aebabf4de9df02f1ac1fc554029 | refs/heads/master | 2020-05-20T21:16:22.499590 | 2019-04-24T21:47:04 | 2019-04-24T21:47:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,995 | cpp | #include <stdafx.h>
#include "fb_properties.h"
#include <js_engine/js_to_native_invoker.h>
#include <convert/native_to_js.h>
#include <js_utils/js_error_helper.h>
#include <js_utils/js_object_helper.h>
#include <js_utils/serialized_value.h>
#include <utils/string_helpers.h>
#include <js_panel_window.h>
using namespace smp;
namespace mozjs
{
FbProperties::FbProperties( JSContext* cx, panel::js_panel_window& parentPanel )
: pJsCtx_( cx )
, parentPanel_( parentPanel )
{
}
FbProperties::~FbProperties()
{
RemoveHeapTracer();
}
std::unique_ptr<FbProperties>
FbProperties::Create( JSContext* cx, panel::js_panel_window& parentPanel )
{
std::unique_ptr<FbProperties> fbProps( new FbProperties( cx, parentPanel ) );
if ( !JS_AddExtraGCRootsTracer( cx, FbProperties::TraceHeapValue, fbProps.get() ) )
{
return nullptr;
}
return fbProps;
}
void FbProperties::RemoveHeapTracer()
{
JS_RemoveExtraGCRootsTracer( pJsCtx_, FbProperties::TraceHeapValue, this );
properties_.clear();
}
JS::Value FbProperties::GetProperty( const std::wstring& propName, JS::HandleValue propDefaultValue )
{
std::wstring trimmedPropName( smp::string::Trim( propName ) );
bool hasProperty = false;
if ( properties_.count( trimmedPropName ) )
{
hasProperty = true;
}
else
{
auto prop = parentPanel_.get_config_prop().get_config_item( trimmedPropName );
if ( prop )
{
hasProperty = true;
JS::RootedValue jsProp( pJsCtx_ );
DeserializeJsValue( pJsCtx_, prop.value(), &jsProp );
properties_.emplace( trimmedPropName, std::make_unique<HeapElement>( jsProp ) );
}
}
if ( !hasProperty )
{
if ( propDefaultValue.isNullOrUndefined() )
{ // Not a error: user does not want to set default value
return JS::NullValue();
}
SetProperty( trimmedPropName, propDefaultValue );
}
return properties_[trimmedPropName]->value.get();
}
void FbProperties::SetProperty( const std::wstring& propName, JS::HandleValue propValue )
{
std::wstring trimmedPropName( smp::string::Trim( propName ) );
if ( propValue.isNullOrUndefined() )
{
parentPanel_.get_config_prop().remove_config_item( trimmedPropName );
properties_.erase( trimmedPropName );
return;
}
auto serializedValue = SerializeJsValue( pJsCtx_, propValue );
properties_.insert_or_assign( trimmedPropName, std::make_unique<HeapElement>( propValue ) );
parentPanel_.get_config_prop().set_config_item( trimmedPropName, serializedValue );
}
void FbProperties::TraceHeapValue( JSTracer* trc, void* data )
{
assert( data );
auto jsObject = static_cast<FbProperties*>( data );
auto& properties = jsObject->properties_;
for ( auto& [name, heapElem] : properties )
{
JS::TraceEdge( trc, &heapElem->value, "CustomHeap_Properties" );
}
}
} // namespace mozjs
| [
"qwertiest@mail.ru"
] | qwertiest@mail.ru |
6b6046a45d75fc0c2d73a410db09994f044ed362 | f3e673e43674feb6746948e76160335bfab7585e | /q_lib/include/q/pitch/pitch_detector.hpp | 01e449d15bf4c33ddec8038577658e49676e9709 | [
"MIT"
] | permissive | christofmuc/Q | df008d0b1617a3b7ea01b1279881d3f16796e1da | 38c14796241ed8fb453bc39f7801e9ddb4dae7c8 | refs/heads/master | 2020-09-07T13:19:55.440427 | 2020-04-01T13:05:15 | 2020-04-01T13:05:15 | 220,793,497 | 2 | 1 | null | 2020-04-01T13:05:16 | 2019-11-10T13:23:53 | C++ | UTF-8 | C++ | false | false | 8,243 | hpp | /*=============================================================================
Copyright (c) 2014-2019 Joel de Guzman. All rights reserved.
Distributed under the MIT License [ https://opensource.org/licenses/MIT ]
=============================================================================*/
#if !defined(CYCFI_Q_PITCH_DETECTOR_HPP_MARCH_12_2018)
#define CYCFI_Q_PITCH_DETECTOR_HPP_MARCH_12_2018
#include <q/fx/moving_average.hpp>
#include <q/fx/median.hpp>
#include <q/pitch/period_detector.hpp>
#include <array>
#include <utility>
namespace cycfi { namespace q
{
////////////////////////////////////////////////////////////////////////////
class pitch_detector
{
public:
static constexpr float max_deviation = 0.90f;
static constexpr float min_periodicity = 0.8f;
pitch_detector(
frequency lowest_freq
, frequency highest_freq
, std::uint32_t sps
, decibel hysteresis
);
pitch_detector(pitch_detector const& rhs) = default;
pitch_detector(pitch_detector&& rhs) = default;
pitch_detector& operator=(pitch_detector const& rhs) = default;
pitch_detector& operator=(pitch_detector&& rhs) = default;
bool operator()(float s);
float get_frequency() const { return _frequency(); }
float predict_frequency() const;
bool is_note_onset() const;
bool frames_after_onset() const { return _frames_after_onset; }
float periodicity() const;
void reset() { _frequency = 0.0f; }
bitset<> const& bits() const { return _pd.bits(); }
zero_crossing const& edges() const { return _pd.edges(); }
private:
float calculate_frequency() const;
float bias(float current, float incoming, bool& shift);
void bias(float incoming);
using exp_moving_average_type = exp_moving_average<4>;
period_detector _pd;
exp_moving_average_type _frequency;
median3 _median;
std::uint32_t _sps;
std::size_t _frames_after_onset = 0;
};
////////////////////////////////////////////////////////////////////////////
// Implementation
////////////////////////////////////////////////////////////////////////////
inline pitch_detector::pitch_detector(
q::frequency lowest_freq
, q::frequency highest_freq
, std::uint32_t sps
, decibel hysteresis
)
: _pd(lowest_freq, highest_freq, sps, hysteresis)
, _frequency(0.0f)
, _sps(sps)
{}
inline float pitch_detector::bias(float current, float incoming, bool& shift)
{
auto error = current / 32; // approx 1/2 semitone
auto diff = std::abs(current-incoming);
// Try fundamental
if (diff < error)
return incoming;
if (_frames_after_onset > 1)
{
if (current > incoming)
{
// is current the 5th harmonic of incoming?
auto f = incoming * 5;
if (std::abs(current-f) < error)
return f;
// is current the 4th harmonic of incoming?
f = incoming * 4;
if (std::abs(current-f) < error)
return f;
// is current the 3rd harmonic of incoming?
f = incoming * 3;
if (std::abs(current-f) < error)
return f;
// is current the 2nd harmonic of incoming?
f = incoming * 2;
if (std::abs(current-f) < error)
return f;
}
else
{
// is incoming the 2nd harmonic of current?
auto f = incoming * (1.0f / 2); // Note: favor multiplication over division
if (std::abs(current-f) < error)
return f;
// is incoming the 3rd harmonic of current?
f = incoming * (1.0f / 3); // Note: favor multiplication over division
if (std::abs(current-f) < error)
return f;
}
}
// Don't do anything if the latest autocorrelation is not periodic
// enough Note that we only do this check on frequency shifts (i.e. at
// this point, we are looking at a potential frequency shift, after
// passing through the code above, checking for fundamental and
// harmonic matches).
if (_pd.fundamental()._periodicity > min_periodicity)
{
// Now we have a frequency shift
shift = true;
return incoming;
}
return current;
}
inline void pitch_detector::bias(float incoming)
{
auto current = _frequency();
++_frames_after_onset;
bool shift = false;
auto f = bias(current, incoming, shift);
// Don't do anything if incoming is not periodic enough
// Note that we only do this check on frequency shifts
if (shift)
{
if (_pd.fundamental()._periodicity < max_deviation)
{
// If we don't have enough confidence in the autocorrelation
// result, we'll try the zero-crossing edges to extract the
// frequency and the one closest to the current frequency wins.
bool shift2 = false;
auto predicted = predict_frequency();
if (predicted > 0.0f)
{
float f2 = bias(current, predicted, shift2);
// If there's no shift, the edges wins
if (!shift2)
{
_frequency = _median(f2);
}
else // else, whichever is closest to the current frequency wins.
{
_frequency(_median(
(std::abs(current-f) < std::abs(current-f2))?
f : f2
));
}
}
else
{
_frequency(_median(f));
}
}
else
{
// Now we have a frequency shift. Get the median of 3 (incoming
// frequency and last two frequency shifts) to eliminate abrupt
// changes. This will minimize potentially unwanted shifts.
// See https://en.wikipedia.org/wiki/Median_filter
_frequency = _median(incoming);
if (_frequency() == incoming)
_frames_after_onset = 0;
}
}
else
{
_frequency(_median(f));
}
}
inline bool pitch_detector::operator()(float s)
{
_pd(s);
if (_pd.is_ready())
{
if (_frequency() == 0.0f)
{
// Disregard if we are not periodic enough
if (_pd.fundamental()._periodicity >= max_deviation)
{
auto f = calculate_frequency();
if (f > 0.0f)
{
_median(f); // Apply the median for the future
_frequency = f; // But assign outright now
_frames_after_onset = 0;
}
}
}
else
{
auto f = calculate_frequency();
if (f > 0.0f)
bias(f);
}
}
return _pd.is_ready();
}
inline float pitch_detector::calculate_frequency() const
{
if (_pd.fundamental()._period != -1)
return _sps / _pd.fundamental()._period;
return 0.0f;
}
inline float pitch_detector::periodicity() const
{
return _pd.fundamental()._periodicity;
}
inline bool pitch_detector::is_note_onset() const
{
return _frames_after_onset == 0;
}
inline float pitch_detector::predict_frequency() const
{
auto period = _pd.predict_period();
if (period < _pd.minimum_period())
return 0.0f;
return _sps / period;
}}
}
#endif
| [
"djowel@gmail.com"
] | djowel@gmail.com |
7341c2c03629e93d15003dd95a91c39fe1793aa0 | d01dc4b327e33816ac2ce2af40945a721f7b5854 | /aws-cpp-sdk-elasticfilesystem/include/aws/elasticfilesystem/model/TagResourceRequest.h | 6f1da4511f35d6f52460c965a845d79d7de90221 | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | hpcc-systems/aws-sdk-cpp | 36f89272e3b140fea596c73234c09fb240f86520 | 9c93f28159e1e01ea3ef789a1b0c2c9643955c96 | refs/heads/master | 2022-07-17T05:18:08.190972 | 2020-10-19T20:59:11 | 2020-10-19T20:59:11 | 90,974,127 | 0 | 1 | Apache-2.0 | 2022-06-30T14:47:34 | 2017-05-11T11:58:14 | C++ | UTF-8 | C++ | false | false | 3,942 | h | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/elasticfilesystem/EFS_EXPORTS.h>
#include <aws/elasticfilesystem/EFSRequest.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/elasticfilesystem/model/Tag.h>
#include <utility>
namespace Aws
{
namespace EFS
{
namespace Model
{
/**
*/
class AWS_EFS_API TagResourceRequest : public EFSRequest
{
public:
TagResourceRequest();
// Service request name is the Operation name which will send this request out,
// each operation should has unique request name, so that we can get operation's name from this request.
// Note: this is not true for response, multiple operations may have the same response name,
// so we can not get operation's name from response.
inline virtual const char* GetServiceRequestName() const override { return "TagResource"; }
Aws::String SerializePayload() const override;
/**
* <p>The ID specifying the EFS resource that you want to create a tag for. </p>
*/
inline const Aws::String& GetResourceId() const{ return m_resourceId; }
/**
* <p>The ID specifying the EFS resource that you want to create a tag for. </p>
*/
inline bool ResourceIdHasBeenSet() const { return m_resourceIdHasBeenSet; }
/**
* <p>The ID specifying the EFS resource that you want to create a tag for. </p>
*/
inline void SetResourceId(const Aws::String& value) { m_resourceIdHasBeenSet = true; m_resourceId = value; }
/**
* <p>The ID specifying the EFS resource that you want to create a tag for. </p>
*/
inline void SetResourceId(Aws::String&& value) { m_resourceIdHasBeenSet = true; m_resourceId = std::move(value); }
/**
* <p>The ID specifying the EFS resource that you want to create a tag for. </p>
*/
inline void SetResourceId(const char* value) { m_resourceIdHasBeenSet = true; m_resourceId.assign(value); }
/**
* <p>The ID specifying the EFS resource that you want to create a tag for. </p>
*/
inline TagResourceRequest& WithResourceId(const Aws::String& value) { SetResourceId(value); return *this;}
/**
* <p>The ID specifying the EFS resource that you want to create a tag for. </p>
*/
inline TagResourceRequest& WithResourceId(Aws::String&& value) { SetResourceId(std::move(value)); return *this;}
/**
* <p>The ID specifying the EFS resource that you want to create a tag for. </p>
*/
inline TagResourceRequest& WithResourceId(const char* value) { SetResourceId(value); return *this;}
/**
* <p/>
*/
inline const Aws::Vector<Tag>& GetTags() const{ return m_tags; }
/**
* <p/>
*/
inline bool TagsHasBeenSet() const { return m_tagsHasBeenSet; }
/**
* <p/>
*/
inline void SetTags(const Aws::Vector<Tag>& value) { m_tagsHasBeenSet = true; m_tags = value; }
/**
* <p/>
*/
inline void SetTags(Aws::Vector<Tag>&& value) { m_tagsHasBeenSet = true; m_tags = std::move(value); }
/**
* <p/>
*/
inline TagResourceRequest& WithTags(const Aws::Vector<Tag>& value) { SetTags(value); return *this;}
/**
* <p/>
*/
inline TagResourceRequest& WithTags(Aws::Vector<Tag>&& value) { SetTags(std::move(value)); return *this;}
/**
* <p/>
*/
inline TagResourceRequest& AddTags(const Tag& value) { m_tagsHasBeenSet = true; m_tags.push_back(value); return *this; }
/**
* <p/>
*/
inline TagResourceRequest& AddTags(Tag&& value) { m_tagsHasBeenSet = true; m_tags.push_back(std::move(value)); return *this; }
private:
Aws::String m_resourceId;
bool m_resourceIdHasBeenSet;
Aws::Vector<Tag> m_tags;
bool m_tagsHasBeenSet;
};
} // namespace Model
} // namespace EFS
} // namespace Aws
| [
"aws-sdk-cpp-automation@github.com"
] | aws-sdk-cpp-automation@github.com |
116e6e44e97febfb322a2b7a10cf3ea5c19f5390 | 4a193c0992276fc133bc6e1d737f9fc30a71bef4 | /Game/Kayak/Plugins/Trigger/Source/TriggerRunTime/Public/TriggerOctree.h | 4b39ed05acc076adf5eb692139a200c2870d2f59 | [] | no_license | liulianyou/KayakGame | ff13ac212f311fe388d071151048aad99634054c | 54264f06e23759c68013df92cbef0e77870c37d8 | refs/heads/master | 2022-03-16T16:05:20.782725 | 2022-02-14T11:01:37 | 2022-02-14T11:01:37 | 136,556,867 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,520 | h | #pragma once
/*
* Author: Liulianyou
* Time: 2021/1/25
* Purpose: The internal data struct to hold all triggers in the scene
*/
#include "CoreMinimal.h"
#include "Math/GenericOctree.h"
#include "Templates/SharedPointer.h"
#include "TriggerInterface.h"
class UTriggerTaskComponentBase;
struct TRIGGERRUNTIME_API FTriggerOctreeElement
{
public:
FTriggerOctreeElement(TScriptInterface<ITriggerInterface> Trigger);
~FTriggerOctreeElement();
public:
bool IsVaild();
const FBoxSphereBounds& GetBounds() const { return Bounds; }
TScriptInterface<ITriggerInterface> GetTriggerData() const { return TriggerData; }
private:
//Bounds for the target trigger
FBoxSphereBounds Bounds;
//The ID which stands for the target trigger, This value is runtime ID
TScriptInterface<ITriggerInterface> TriggerData;
};
struct FTriggerOctreeSemantics
{
typedef TOctree2<FTriggerOctreeElement, FTriggerOctreeSemantics> FOctree;
enum { MaxElementsPerLeaf = 16 };
enum { MinInclusiveElementsPerNode = 7 };
enum { MaxNodeDepth = 12 };
typedef TInlineAllocator<MaxElementsPerLeaf> ElementAllocator;
FORCEINLINE static const FBoxSphereBounds& GetBoundingBox(const FTriggerOctreeElement& TriggerData)
{
return TriggerData.GetBounds();
}
//For now this not used in UE4
FORCEINLINE static bool AreElementsEqual(const FTriggerOctreeElement& A, const FTriggerOctreeElement& B)
{
if (A.GetTriggerData() == B.GetTriggerData())
return true;
else
return false;
}
FORCEINLINE static void ApplyOffset(FTriggerOctreeElement& Element, const FVector& InOffset)
{
ensureMsgf(false, TEXT("Not implemented yet"));
}
static void SetElementId(FOctree& OctreeOwner, const FTriggerOctreeElement& Element, FOctreeElementId2 Id);
};
class TRIGGERRUNTIME_API FTriggerOctree : public TOctree2<FTriggerOctreeElement, FTriggerOctreeSemantics>, public TSharedFromThis<FTriggerOctree, ESPMode::ThreadSafe>
{
public:
FTriggerOctree(const FVector& Origin, float Radius);
virtual ~FTriggerOctree();
public:
//Add new node to this Octree
void AddNode(TScriptInterface<ITriggerInterface> Trigger);
//Update the exist node
void UpdateNode(TScriptInterface<ITriggerInterface> Trigger);
//Remove the node from octree
void RemoveNode(TScriptInterface<ITriggerInterface> Trigger);
const TMap< uint32, FOctreeElementId2 >& GetTriggerDataMapInfo() const {return TriggerMapInfo;}
const TMap< uint32, FOctreeElementId2 >& GetTriggerDataMapInfo() { return TriggerMapInfo; }
const TMap<FGuid, TArray<UTriggerTaskComponentBase*>>& GetTriggerComponentMaps() const { return ComponentMaps; }
const TMap<FGuid, TArray<UTriggerTaskComponentBase*>>& GetTriggerComponentMaps() { return ComponentMaps; }
protected:
friend struct FTriggerOctreeSemantics;
//When new octree element added to the node I need to add this element to local map info
void AddNewInstanceToMapInfo(const uint32 OwnerUniqueId, FOctreeElementId2 Id);
private:
void RemoveNode(const FOctreeElementId2& ElementID);
private:
//Key is the Unique Trigger Id(Runtime ID), Value is the OctreeElementId in the Octree
TMap< uint32, FOctreeElementId2 > TriggerMapInfo;
/*
* The map for component of ID.
* When we want to find one component form the ID we should first search in this cashed map. this will reduce the CPU.
* If we run on the listener or editor mode the same ID maybe have several Component: Component At Server, Component At Client1, Component At Client2......
*/
TMap<FGuid, TArray<UTriggerTaskComponentBase*>> ComponentMaps;
};
| [
"cumt.lly@gmail.com"
] | cumt.lly@gmail.com |
d639c187632fe85db7b5380e051b1d3b460be93f | 002902560639e77c5c9606af0fad90ff2334db1e | /822A.cpp | 25e1d6424d32326f5258260a9263f6300f313eaf | [] | no_license | Hasanzakaria/CODEFORCES | 8662b464133d6058b74ea6bbbe0c6fd78366df9d | da08f70a3eae047e2da610b8a7aa3cc704b10202 | refs/heads/master | 2022-11-08T16:59:31.128716 | 2020-06-26T14:18:15 | 2020-06-26T14:18:15 | 275,172,665 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 192 | cpp | #include<bits/stdc++.h>
using namespace std;
int main ()
{
long long int a,b,k,t=1,i;
cin>>a>>b;
k=min(a,b);
for(i=1;i<=k;i++)
{
t=t*i;
}
cout<<t<<endl;
} | [
"hasanxack@gmail.com"
] | hasanxack@gmail.com |
6ccd91b0ed3957daef680a47032f746bb3d9a18a | b7f3edb5b7c62174bed808079c3b21fb9ea51d52 | /third_party/blink/renderer/platform/wtf/hash_set.h | abef9643fb0511b64b6b0bca17c9d769015541b6 | [
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"BSD-3-Clause"
] | permissive | otcshare/chromium-src | 26a7372773b53b236784c51677c566dc0ad839e4 | 64bee65c921db7e78e25d08f1e98da2668b57be5 | refs/heads/webml | 2023-03-21T03:20:15.377034 | 2020-11-16T01:40:14 | 2020-11-16T01:40:14 | 209,262,645 | 18 | 21 | BSD-3-Clause | 2023-03-23T06:20:07 | 2019-09-18T08:52:07 | null | UTF-8 | C++ | false | false | 11,280 | h | /*
* Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_HASH_SET_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_HASH_SET_H_
#include <initializer_list>
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/allocator/partition_allocator.h"
#include "third_party/blink/renderer/platform/wtf/hash_table.h"
#include "third_party/blink/renderer/platform/wtf/wtf_size_t.h"
namespace WTF {
struct IdentityExtractor;
// Note: empty or deleted values are not allowed, using them may lead to
// undefined behavior. For pointer keys this means that null pointers are not
// allowed; for integer keys 0 or -1 can't be used as a key. This restriction
// can be lifted if you supply custom key traits.
template <typename ValueArg,
typename HashArg = typename DefaultHash<ValueArg>::Hash,
typename TraitsArg = HashTraits<ValueArg>,
typename Allocator = PartitionAllocator>
class HashSet {
USE_ALLOCATOR(HashSet, Allocator);
private:
typedef HashArg HashFunctions;
typedef TraitsArg ValueTraits;
typedef typename ValueTraits::PeekInType ValuePeekInType;
public:
typedef typename ValueTraits::TraitType ValueType;
using value_type = ValueType;
private:
typedef HashTable<ValueType,
ValueType,
IdentityExtractor,
HashFunctions,
ValueTraits,
ValueTraits,
Allocator>
HashTableType;
public:
typedef HashTableConstIteratorAdapter<HashTableType, ValueTraits> iterator;
typedef HashTableConstIteratorAdapter<HashTableType, ValueTraits>
const_iterator;
typedef typename HashTableType::AddResult AddResult;
HashSet() {
static_assert(Allocator::kIsGarbageCollected ||
!IsPointerToGarbageCollectedType<ValueArg>::value,
"Cannot put raw pointers to garbage-collected classes into "
"an off-heap HashSet. Use HeapHashSet<Member<T>> instead.");
}
HashSet(const HashSet&) = default;
HashSet& operator=(const HashSet&) = default;
HashSet(HashSet&&) = default;
HashSet& operator=(HashSet&&) = default;
HashSet(std::initializer_list<ValueType> elements);
HashSet& operator=(std::initializer_list<ValueType> elements);
void swap(HashSet& ref) { impl_.swap(ref.impl_); }
unsigned size() const;
unsigned Capacity() const;
bool IsEmpty() const;
void ReserveCapacityForSize(unsigned size) {
impl_.ReserveCapacityForSize(size);
}
iterator begin() const;
iterator end() const;
iterator find(ValuePeekInType) const;
bool Contains(ValuePeekInType) const;
// An alternate version of find() that finds the object by hashing and
// comparing with some other type, to avoid the cost of type
// conversion. HashTranslator must have the following function members:
// static unsigned hash(const T&);
// static bool equal(const ValueType&, const T&);
template <typename HashTranslator, typename T>
iterator Find(const T&) const;
template <typename HashTranslator, typename T>
bool Contains(const T&) const;
// The return value is a pair of an iterator to the new value's location,
// and a bool that is true if an new entry was added.
template <typename IncomingValueType>
AddResult insert(IncomingValueType&&);
// An alternate version of add() that finds the object by hashing and
// comparing with some other type, to avoid the cost of type conversion if
// the object is already in the table. HashTranslator must have the
// following function members:
// static unsigned hash(const T&);
// static bool equal(const ValueType&, const T&);
// static translate(ValueType&, T&&, unsigned hashCode);
template <typename HashTranslator, typename T>
AddResult AddWithTranslator(T&&);
void erase(ValuePeekInType);
void erase(iterator);
void clear();
template <typename Collection>
void RemoveAll(const Collection& to_be_removed) {
WTF::RemoveAll(*this, to_be_removed);
}
ValueType Take(iterator);
ValueType Take(ValuePeekInType);
ValueType TakeAny();
template <typename VisitorDispatcher, typename A = Allocator>
std::enable_if_t<A::kIsGarbageCollected> Trace(
VisitorDispatcher visitor) const {
impl_.Trace(visitor);
}
protected:
ValueType** GetBufferSlot() { return impl_.GetBufferSlot(); }
private:
HashTableType impl_;
};
struct IdentityExtractor {
STATIC_ONLY(IdentityExtractor);
template <typename T>
static const T& Extract(const T& t) {
return t;
}
// Assumes out points to a buffer of size at least sizeof(T).
template <typename T>
static const T& ExtractSafe(const T& t, void* out) {
AtomicReadMemcpy<sizeof(T)>(out, &t);
return *reinterpret_cast<T*>(out);
}
};
template <typename Translator>
struct HashSetTranslatorAdapter {
STATIC_ONLY(HashSetTranslatorAdapter);
template <typename T>
static unsigned GetHash(const T& key) {
return Translator::GetHash(key);
}
template <typename T, typename U>
static bool Equal(const T& a, const U& b) {
return Translator::Equal(a, b);
}
template <typename T, typename U, typename V>
static void Translate(T& location, U&& key, const V&, unsigned hash_code) {
Translator::Translate(location, std::forward<U>(key), hash_code);
}
};
template <typename Value,
typename HashFunctions,
typename Traits,
typename Allocator>
HashSet<Value, HashFunctions, Traits, Allocator>::HashSet(
std::initializer_list<ValueType> elements) {
if (elements.size())
impl_.ReserveCapacityForSize(SafeCast<wtf_size_t>(elements.size()));
for (const ValueType& element : elements)
insert(element);
}
template <typename Value,
typename HashFunctions,
typename Traits,
typename Allocator>
auto HashSet<Value, HashFunctions, Traits, Allocator>::operator=(
std::initializer_list<ValueType> elements) -> HashSet& {
*this = HashSet(std::move(elements));
return *this;
}
template <typename T, typename U, typename V, typename W>
inline unsigned HashSet<T, U, V, W>::size() const {
return impl_.size();
}
template <typename T, typename U, typename V, typename W>
inline unsigned HashSet<T, U, V, W>::Capacity() const {
return impl_.Capacity();
}
template <typename T, typename U, typename V, typename W>
inline bool HashSet<T, U, V, W>::IsEmpty() const {
return impl_.IsEmpty();
}
template <typename T, typename U, typename V, typename W>
inline typename HashSet<T, U, V, W>::iterator HashSet<T, U, V, W>::begin()
const {
return impl_.begin();
}
template <typename T, typename U, typename V, typename W>
inline typename HashSet<T, U, V, W>::iterator HashSet<T, U, V, W>::end() const {
return impl_.end();
}
template <typename T, typename U, typename V, typename W>
inline typename HashSet<T, U, V, W>::iterator HashSet<T, U, V, W>::find(
ValuePeekInType value) const {
return impl_.find(value);
}
template <typename Value,
typename HashFunctions,
typename Traits,
typename Allocator>
inline bool HashSet<Value, HashFunctions, Traits, Allocator>::Contains(
ValuePeekInType value) const {
return impl_.Contains(value);
}
template <typename Value,
typename HashFunctions,
typename Traits,
typename Allocator>
template <typename HashTranslator, typename T>
typename HashSet<Value, HashFunctions, Traits, Allocator>::
iterator inline HashSet<Value, HashFunctions, Traits, Allocator>::Find(
const T& value) const {
return impl_.template Find<HashSetTranslatorAdapter<HashTranslator>>(value);
}
template <typename Value,
typename HashFunctions,
typename Traits,
typename Allocator>
template <typename HashTranslator, typename T>
inline bool HashSet<Value, HashFunctions, Traits, Allocator>::Contains(
const T& value) const {
return impl_.template Contains<HashSetTranslatorAdapter<HashTranslator>>(
value);
}
template <typename T, typename U, typename V, typename W>
template <typename IncomingValueType>
inline typename HashSet<T, U, V, W>::AddResult HashSet<T, U, V, W>::insert(
IncomingValueType&& value) {
return impl_.insert(std::forward<IncomingValueType>(value));
}
template <typename Value,
typename HashFunctions,
typename Traits,
typename Allocator>
template <typename HashTranslator, typename T>
inline typename HashSet<Value, HashFunctions, Traits, Allocator>::AddResult
HashSet<Value, HashFunctions, Traits, Allocator>::AddWithTranslator(T&& value) {
// Forward only the first argument, because the second argument isn't actually
// used in HashSetTranslatorAdapter.
return impl_
.template InsertPassingHashCode<HashSetTranslatorAdapter<HashTranslator>>(
std::forward<T>(value), value);
}
template <typename T, typename U, typename V, typename W>
inline void HashSet<T, U, V, W>::erase(iterator it) {
impl_.erase(it.impl_);
}
template <typename T, typename U, typename V, typename W>
inline void HashSet<T, U, V, W>::erase(ValuePeekInType value) {
erase(find(value));
}
template <typename T, typename U, typename V, typename W>
inline void HashSet<T, U, V, W>::clear() {
impl_.clear();
}
template <typename T, typename U, typename V, typename W>
inline auto HashSet<T, U, V, W>::Take(iterator it) -> ValueType {
if (it == end())
return ValueTraits::EmptyValue();
ValueType result = std::move(const_cast<ValueType&>(*it));
erase(it);
return result;
}
template <typename T, typename U, typename V, typename W>
inline auto HashSet<T, U, V, W>::Take(ValuePeekInType value) -> ValueType {
return Take(find(value));
}
template <typename T, typename U, typename V, typename W>
inline auto HashSet<T, U, V, W>::TakeAny() -> ValueType {
return Take(begin());
}
template <typename C, typename W>
inline void CopyToVector(const C& collection, W& vector) {
typedef typename C::const_iterator iterator;
{
// Disallow GC across resize allocation, see crbug.com/568173
typename W::GCForbiddenScope scope;
vector.resize(collection.size());
}
iterator it = collection.begin();
iterator end = collection.end();
for (unsigned i = 0; it != end; ++it, ++i)
vector[i] = *it;
}
} // namespace WTF
using WTF::HashSet;
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_HASH_SET_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
0244acb952bf825b05479d2161d1d4c230007a10 | 06a4438b52481db8dd6af95440e46d8cbfcd7b46 | /Tek2/B4 - Object-Oriented Programming/NanoTekSpice/include/Handler.hpp | 4c8716fdc1150ef1e525ca75672e46b3b75c76be | [] | no_license | josepvidalcanet/Epitech | f5bf3529c69fca9f10cb17f58cd82bcc076a8515 | 2222a7e5b433bcd847e1978b0efd813043fe01ec | refs/heads/master | 2023-08-16T12:49:28.859792 | 2021-10-01T14:42:44 | 2021-10-01T14:42:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 442 | hpp | /*
** EPITECH PROJECT, 2021
** B-OOP-400-STG-4-1-tekspice-pierre.jeannin
** File description:
** Nanotekspice
*/
#ifndef NANOTEKSPICE_HPP_
#define NANOTEKSPICE_HPP_
#include <fstream>
#include "Error.hpp"
#include "Parser.hpp"
#include "Minishell.hpp"
namespace nts {
class Handler {
public:
static void run(std::ifstream &fileStream);
protected:
private:
};
}
#endif /* !NANOTEKSPICE_HPP_ */
| [
"pierre.jeannin@epitech.eu"
] | pierre.jeannin@epitech.eu |
d849679123ad3f1aad31ad170924abf178a9bfad | 8ff55c9f0dc0e53d1151d50d13c77b15ee8adbfc | /3/iostream.cpp | ca7cdeefc8a429fed27b41908f00ce19f4320297 | [] | no_license | tjgykhulj/Windows-CodeDemo | 53aa251b0b5bf7a3e410cdffc1728bbea409ffc5 | 955a5e3406190028a86cce29d4284d291e8253f5 | refs/heads/master | 2020-04-25T11:47:50.791610 | 2015-08-09T07:45:49 | 2015-08-09T07:45:49 | 40,159,010 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,264 | cpp | #include "iostream.h"
#include "minicrt.h"
#include <Windows.h>
namespace std {
stdout_stream cout;
stdout_stream::stdout_stream() : ofstream() {
fp = stdout;
}
ofstream::ofstream() : fp(0) {}
ofstream::~ofstream() {
close();
}
ofstream::ofstream(const char *filename, ofstream::openmode md) : fp(0) {
open(filename, md);
}
ofstream& ofstream::operator<<(char c) {
fputc(c, fp);
return *this;
}
ofstream& ofstream::operator<<(int n) {
fprintf(fp, "%d", n);
return *this;
}
ofstream& ofstream::operator<<(const char *n) {
fprintf(fp, "%s", n);
return *this;
}
ofstream& ofstream::operator<<(ofstream& (*manip)(ofstream&)) {
return manip(*this);
}
void ofstream::open(const char *filename, ofstream::openmode md)
{
char mode[4];
close();
switch (md)
{
case out | trunc:
strcpy(mode, "w");
break;
case out | in | trunc:
strcpy(mode, "w+");
break;
case out | binary | trunc:
strcpy(mode, "wb");
break;
case out | in | binary | trunc:
strcpy(mode, "wb+");
break;
}
fp = fopen(filename, mode);
}
void ofstream::close()
{
if (fp) {
fclose(fp);
fp = 0;
}
}
ofstream& ofstream::write(const char *buf, unsigned size)
{
fwrite(buf, 1, size, fp);
return *this;
}
} | [
"tjg-6666@163.com"
] | tjg-6666@163.com |
bb80b10840121e3897ee37e283bada9e412b8cff | d00c92e011f72ad54f887a6b09a8a9dde1f54854 | /Bop-the-Block-SDL/src/LevelBuilder.cpp | 705af124997ec5e9cbe67977fb4a22b885e5bb52 | [] | no_license | Persevering-Traveller/Bop-the-Block-SDL | d7ebc36f4295801b4016d98bf839d5cbcb3287d9 | 020974f6a3d13e53399e57fa09b86ce99176e406 | refs/heads/master | 2020-05-03T17:16:34.338027 | 2019-05-18T19:02:10 | 2019-05-18T19:02:10 | 178,741,296 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,872 | cpp | #include "LevelBuilder.h"
#include "Block.h"
#include <SDL.h>
#include <SDL_image.h>
#include <iostream>
#include <fstream>
LevelBuilder::LevelBuilder()
{
shared_texture = nullptr;
}
LevelBuilder::~LevelBuilder()
{
SDL_DestroyTexture(shared_texture);
}
bool LevelBuilder::Init(SDL_Renderer *renderer, std::string texture_file_location)
{
bool status = true;
SDL_Surface *surface_for_texture = IMG_Load(texture_file_location.c_str());
if (!surface_for_texture)
{
std::cout << texture_file_location + " could not be found!\n";
status = false;
}
else
{
shared_texture = SDL_CreateTextureFromSurface(renderer, surface_for_texture);
if (!shared_texture)
{
std::cout << texture_file_location + " could not be turned into a texture!\nIMG Error: " + IMG_GetError() + "\n";
status = false;
}
else
{
for (auto &arr : level)
{
for (auto &block : arr)
{
block.GetSprite()->SetTexture(shared_texture);
}
}
}
}
return status;
}
void LevelBuilder::SetupLevel(std::string level_file_location)
{
std::ifstream file;
int i = 0, j = 0;
char place;
file.open(level_file_location);
// Read through the file for 1s and 0s
while(!file.eof())
{
file >> place;
// Skip any 0s
if (place == '0')
{
i++;
}
if (place == '1') //but place a block if there's a 1
{
level[j][i].SetPosition(i * 16, j * 8);
level[j][i].SetAlive(true);
i++;
}
if (i == MAX_HORIZONTAL_BLOCKS)
{
j++;
i = 0;
}
}
file.close();
}
void LevelBuilder::Draw(SDL_Renderer *renderer)
{
for (auto &arr : level)
{
for (auto &block : arr)
{
block.Draw(renderer);
}
}
}
Block *LevelBuilder::GetBlockAt(int x, int y)
{
return &level[x][y];
}
bool LevelBuilder::AnyBlocksLeft()
{
for (auto &arr : level)
{
for (auto &block : arr)
{
if (block.GetAlive())
return true;
}
}
return false;
} | [
"j.sweet90@hotmail.com"
] | j.sweet90@hotmail.com |
335378396f014cf0a55861839dcb76245e821e18 | 8089ddffbfb0119a5403eb55aff3da6766ae280f | /lib/static/CvMatProvider/ICvMatProvider.cpp | c4c6ef32be305cfbf1fe9600a54b5113112e511e | [] | no_license | kasreedhar/OpenCvExperiments | 33e2b36be0e756e99c1fb96dfc5909f38208d61b | 0b9cb62a1b6dd3b98a76e984e761791a05fdb9e8 | refs/heads/master | 2022-02-07T23:11:33.620999 | 2019-03-03T12:00:55 | 2019-03-03T12:00:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,261 | cpp | #include "ICvMatProvider.h"
#include <QDebug>
ICvMatProvider::~ICvMatProvider( ) {
}
bool ICvMatProvider::init( const QString &configPath ) {
return _fs.open( configPath.toStdString( ), cv::FileStorage::READ );
}
void ICvMatProvider::stop( ) {
if ( _left.isOpened( ) ) {
_left.release( );
}
if ( _right.isOpened( ) ) {
_right.release( );
}
}
bool ICvMatProvider::read( cv::Mat &frame ) {
if ( _left.isOpened( ) ) {
return _left.read( frame );
}
return false;
}
bool ICvMatProvider::read( cv::Mat &left, cv::Mat &right ) {
if ( _left.isOpened( ) && _right.isOpened( ) ) {
if ( _left.grab( ) && _right.grab( ) ) {
bool result = _right.retrieve( right ) & _left.retrieve( left );
if ( _useCalibration )
_calibrator.calibrate( left, right );
return result;
}
else {
qDebug( ) << "not grab";
return false;
}
}
else {
qDebug( ) << "not opened";
return false;
}
}
cv::Mat ICvMatProvider::projectionMatrix1( ) const {
return _calibrator.projectionMatrix1( );
}
cv::Mat ICvMatProvider::projectionMatrix2( ) const {
return _calibrator.projectionMatrix2( );
}
| [
"mimus.triurus@yandex.ru"
] | mimus.triurus@yandex.ru |
70fa72a5361ea88bc7e1ecd3ba7cde00f7cfe4a3 | d0c44dd3da2ef8c0ff835982a437946cbf4d2940 | /cmake-build-debug/programs_tiling/function14723/function14723_schedule_47/function14723_schedule_47_wrapper.cpp | 27489248f398073c257d4806300ec64fa71be24b | [] | no_license | IsraMekki/tiramisu_code_generator | 8b3f1d63cff62ba9f5242c019058d5a3119184a3 | 5a259d8e244af452e5301126683fa4320c2047a3 | refs/heads/master | 2020-04-29T17:27:57.987172 | 2019-04-23T16:50:32 | 2019-04-23T16:50:32 | 176,297,755 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,211 | cpp | #include "Halide.h"
#include "function14723_schedule_47_wrapper.h"
#include "tiramisu/utils.h"
#include <cstdlib>
#include <iostream>
#include <time.h>
#include <fstream>
#include <chrono>
#define MAX_RAND 200
int main(int, char **){
Halide::Buffer<int32_t> buf00(128);
Halide::Buffer<int32_t> buf01(128, 128, 64);
Halide::Buffer<int32_t> buf02(128, 128, 64);
Halide::Buffer<int32_t> buf03(64);
Halide::Buffer<int32_t> buf04(128, 64);
Halide::Buffer<int32_t> buf0(128, 64, 128, 64);
init_buffer(buf0, (int32_t)0);
auto t1 = std::chrono::high_resolution_clock::now();
function14723_schedule_47(buf00.raw_buffer(), buf01.raw_buffer(), buf02.raw_buffer(), buf03.raw_buffer(), buf04.raw_buffer(), buf0.raw_buffer());
auto t2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = t2 - t1;
std::ofstream exec_times_file;
exec_times_file.open("../data/programs/function14723/function14723_schedule_47/exec_times.txt", std::ios_base::app);
if (exec_times_file.is_open()){
exec_times_file << diff.count() * 1000000 << "us" <<std::endl;
exec_times_file.close();
}
return 0;
} | [
"ei_mekki@esi.dz"
] | ei_mekki@esi.dz |
af92da2fdf8d25d8746950b772edd33df97bb946 | f4682d11427ca29609a0749780aba27e442f7ad9 | /CodechefLongChallenge/DEC17/VK18.cpp | 06b862e4f1d1bc0ec7d6e5c23404e025522e56f0 | [] | no_license | ayushi-b/CompetitiveProgramming | 5efd0c4511af74efa6de1fe16cc72ac99d333fa2 | 42ba5ad53ed1996c618a2adef9962a64399649fe | refs/heads/master | 2021-09-12T19:59:11.435606 | 2018-04-20T11:46:37 | 2018-04-20T11:46:37 | 113,031,339 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,432 | cpp | //
// Created by Ayushi on 02/12/17.
//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,j,n) for(ll (i)=(j);(i)<=(n);++(i))
#define rrep(i,j,n) for(ll i = n ; (i)>=(j) ;--(i))
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MAX 1000000
ll ans[MAX+1];
ll memo[2*MAX+1];
ll sum[2*MAX+1];
void solve() {
int lim = 2*MAX;
sum[0] = sum[1] = 0;
for(int i = 2; i<lim; ++i) {
vector<int> digArray;
int a = i;
while(a) {
digArray.pb(a%10);
a /= 10;
}
int l;
l = (int) (digArray.size());
int even = 0, odd = 0;
for(int j = 0; j<l; ++j) {
if(digArray[j]%2) {
odd += digArray[j];
}
else {
even += digArray[j];
}
}
memo[i] = abs(even - odd);
sum[i] = sum[i-1] + memo[i];
}
ans[0] = 0;
for(int i = 1; i<MAX+1; ++i) {
ans[i] = ans[i-1];
ans[i] += 2*(sum[2*i] - sum[i]);
ans[i] -= memo[2*i];
}
};
int main() {
ios::sync_with_stdio(false);
freopen("fi.txt", "r", stdin);freopen("fo.txt", "w", stdout);
solve();
ll t;
cin >> t;
while(t--) {
int n;
cin >> n;
cout << ans[n] << endl;
}
return 0;
}
| [
"kanchibansal08@gmail.com"
] | kanchibansal08@gmail.com |
b39ab4be37ade18f1ad31bc9efa8337bfac90c20 | e33d0f57ced671c22670f3e2b1e16935d14d8fa7 | /19年整理/6专题六 最小生成树/6 prim POJ 1258 Agri-Net.cpp | 2225e6506c391ca579501d5a8a3ea743f199b82e | [] | no_license | MrVBian/acm | e1ffc9c7bf0b440fb055148d5cb12ff8f7a764de | 341d393fd02e363305fc009de65de35d79ef5234 | refs/heads/master | 2020-07-25T17:44:45.022415 | 2020-02-02T14:31:24 | 2020-02-02T14:31:24 | 208,375,609 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,110 | cpp | #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
using namespace std;
const int maxn = 110;
const int inf = 0x3f3f3f3f;
int n, m;
int G[maxn][maxn];
int vst[maxn];
int d[maxn];
int sum;
void Prim(int s) {
for(int i = 0; i <= n; ++i) {
vst[i] = 0;
d[i] = G[s][i];
}
vst[s] = 1;
for(int i = 0; i < n-1; ++i) {
int Min = inf;
int k = s;
for(int j = 1; j <= n; ++j) {
if(!vst[j] && Min > d[j]) {
Min = d[j];
k = j;
}
}
vst[k] = 1;
sum += Min;
for(int j = 1; j <= n; ++j) {
if(!vst[j] && d[j] > G[k][j]) {
d[j] = G[k][j];
}
}
}
}
int main() {
int v;
while(~scanf("%d", &n)){
sum = 0;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n; ++j) {
scanf("%d", &v);
G[i][j] = v;
}
}
Prim(1);
printf("%d\n", sum);
}
return 0;
}
| [
"544207374@qq.com"
] | 544207374@qq.com |
ca67f13f518f57adfa7076ff2460e2c8616888b0 | f0989ccea844ca0f01ceca8c8b34e4e00914dd45 | /MolecularSimulation/ImgMolecule.h | 48350350a18f8217859c583c929bdb9349e6ce4b | [] | no_license | cyshang/MolecularSimulation | d9a008e866e35b68aa04b1cae8d4030c66ec60a1 | fd317638067c1d5183706dfc5c3f9cc6598573ab | refs/heads/master | 2020-04-28T04:50:44.570527 | 2019-03-12T15:43:39 | 2019-03-12T15:43:39 | 174,996,291 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 253 | h | #ifndef IMGMOLECULE_H_
#define IMGMOLECULE_H_
#include <vector>
struct Molecule;
struct ImgMolecule
{
int type;
std::vector<double> atomXYZ;
double centroid[3];
ImgMolecule(const Molecule * molc, double offset[3]);
};
#endif // !IMGMOLECULE_H_
| [
"entropy1231@126.com"
] | entropy1231@126.com |
483221c90d5f1371401c433697c640b0696d967f | cc575ff0803de2fffd6e01c67079ae9910c66427 | /C++/GladiatorVsMage - Travis Delly/Tomes.h | cc9739cf203efccdc1ff27db2f4a14623a264d93 | [] | no_license | Dellybro/PimaCC | 82cad2179824b476ac4eb6d580607783256f70cd | 35ccb85b1fae25b615c7cd8b3bba5fd2e0972935 | refs/heads/master | 2021-01-22T11:41:28.615379 | 2015-08-13T20:18:57 | 2015-08-13T20:18:57 | 40,679,473 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 479 | h | #ifndef _TOMES
#define _TOMES
#include <iostream>
#include <string>
using namespace std;
class Tomes {
private:
int strength;
int Mana;
int intelligence;
int Armor;
public:
Tomes();
Tomes(int, int, int, int);
int getStr()const;
int getMana()const;
int getIntel()const;
int getArm()const;
void setStr(int str);
void setMana(int mana);
void setIntel(int intel);
void setArm(int Arm);
virtual string desc() = 0;
};
#endif | [
"dellybro@gmail.com"
] | dellybro@gmail.com |
0ecd013c8c48c551a2c3891410ef67a27d48b066 | f33d82eb8d136c0de71ca067e2bf9a80cf965ee8 | /AlgCTL/Source.cpp | e758eb1084802710376b12bc054f15ce41415c6c | [] | no_license | hdorin/AlgCTL | 227bce092efeeb7795e438ae95f24a982a62cbb9 | 0596a533536da90fedd94f086ab9d9ff8991b980 | refs/heads/master | 2023-05-22T06:37:09.591940 | 2021-06-14T19:21:39 | 2021-06-14T19:21:39 | 245,832,941 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,702 | cpp | #include<iostream>
#include<fstream>
#include<cstring>
#define MAX_FORMULA_LEN 100
#define MAX_LABELS_COUNT 20
#define MAX_WORLDS_COUNT 100
/*
- sa adaug prioritate ca parametru
- cand termin EX sa apelez din nou process
- daca formula incepe cu {, apelez procecess de la }+1 cu prioritate 2
- daca gasesc ^, apelez ^+1 cu prioritate 2
- voi gasit q, il convertesc
- ma intorc la ^ si aplic operatia
*/
using namespace std;
struct kripkeStructure {
int worldsCount;
char worldsNames[100][10];
bool worldsRelations[100][100];
char wordlsLabels[100][20];
char allLabels[20] = "Tt";
};
char *formulaStartingPoint;
void readKripreStructure(kripkeStructure &ks) {
char aux[100];
int i, j;
ifstream f("kripke_structure.txt");
f.getline(aux, 100);//skipping files comments
f >> ks.worldsCount;
f.get();
f.getline(aux, 100);//skipping files comments
for (i = 0; i < ks.worldsCount; i++) {
f >> ks.worldsNames[i];
}
f.get();
f.getline(aux, 100);//skipping files comments
for (i = 0; i < ks.worldsCount; i++) {
j = -1;
do {
j++;
f >> ks.wordlsLabels[i][j];
if (ks.wordlsLabels[i][j] != '-' && !strchr(ks.allLabels, ks.wordlsLabels[i][j])) {
ks.allLabels[strlen(ks.allLabels) + 1] = '\0';
ks.allLabels[strlen(ks.allLabels)] = ks.wordlsLabels[i][j];
}
} while (ks.wordlsLabels[i][j] != '-');
ks.wordlsLabels[i][j] = '\0';
}
f.get();
f.getline(aux, 100);//skipping files comments
char worldName[10];
for (i = 0; i < ks.worldsCount; i++) {
for (j = 0; j < ks.worldsCount; j++) {
ks.worldsRelations[i][j] = 0;
}
}
for (i = 0; i < ks.worldsCount; i++) {
j = -1;
while (true) {
f >> worldName;
if (strcmp(worldName, "-") == 0) {
break;
}
for (j = 0; j < ks.worldsCount; j++) {
if (strcmp(worldName, ks.worldsNames[j]) == 0) {
ks.worldsRelations[i][j] = true;
}
}
}
}
f.close();
}
void printKripkeStructure(kripkeStructure ks) {
int i, j;
cout << "Worlds count=" << ks.worldsCount << endl;
for (i = 0; i < ks.worldsCount; i++) {
cout << ks.worldsNames[i] << " ";
}
cout << endl;
cout << "Labels:" << endl;
for (i = 0; i < ks.worldsCount; i++) {
if (strlen(ks.wordlsLabels[i]) == 0) {
cout << "-" << endl;
}
else {
cout << ks.wordlsLabels[i] << endl;
}
}
cout << "All labels:" << ks.allLabels << endl;
cout << "Relations:" << endl;
for (i = 0; i < ks.worldsCount; i++) {
for (j = 0; j < ks.worldsCount; j++) {
cout << ks.worldsRelations[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
bool isWorldLabel(kripkeStructure ks, char character) {
return strchr(ks.allLabels, character);
}
void operatorPre(kripkeStructure ks, bool suitableWorlds[100], bool resultingWorldsList[100]) {
int i, j;
for (i = 0; i < ks.worldsCount; i++) {
resultingWorldsList[i] = false;
}
for (i = 0; i < ks.worldsCount; i++) {
for (j = 0; j < ks.worldsCount; j++) {
if (suitableWorlds[i] == true && ks.worldsRelations[j][i] == true) {
resultingWorldsList[j] = true;
}
}
}
}
void operatorPreE(kripkeStructure ks, bool suitableWorlds[100], bool resultingWorldsList[100]) {
int i, j;
for (i = 0; i < ks.worldsCount; i++) {
resultingWorldsList[i] = false;
for (j = 0; j < ks.worldsCount; j++) {
if (suitableWorlds[j] == true && ks.worldsRelations[i][j] == true) {
resultingWorldsList[i] = true;
}
}
}
}
//TOTI succesorii unui predecesor trebuie sa fie din suitableWorlds, adica sa satisfaca q
void operatorPreA(kripkeStructure ks, bool suitableWorlds[100], bool resultingWorldsList[100]) {
int i, j;
operatorPre(ks, suitableWorlds, resultingWorldsList);
for (i = 0; i < ks.worldsCount; i++) {
if (resultingWorldsList[i] == true) {
for (j = 0; j < ks.worldsCount; j++) {
if (ks.worldsRelations[i][j] == true && suitableWorlds[j] == false) {
resultingWorldsList[i] = false;
}
}
}
}
}
bool worldsListsDiffer(kripkeStructure ks, bool worldsList1[100], bool worldsList2[100]) {
int i;
for (i = 0; i < ks.worldsCount; i++)
if (worldsList1[i] != worldsList2[i]) {
return true;
}
return false;
}
void operatorIntersection(kripkeStructure ks, bool firstWorldsList[100], bool secondWorldList[100], bool resultingWorldsList[100]) {
int i;
for (i = 0; i < ks.worldsCount; i++)
resultingWorldsList[i] = firstWorldsList[i] * secondWorldList[i];
}
void operatorReunion(kripkeStructure ks, bool firstWorldsList[100], bool secondWorldList[100], bool resultingWorldsList[100]) {
int i;
for (i = 0; i < ks.worldsCount; i++)
resultingWorldsList[i] = firstWorldsList[i] + secondWorldList[i];
}
void operatorMC_AF(kripkeStructure ks, bool suitableWorlds[100], bool resultingWorldsList[100]) {
int i;
bool Y[100], Z[100], worldsListAux[100];
for (i = 0; i < ks.worldsCount; i++) {
Z[i] = suitableWorlds[i];
Y[i] = true;
}
while (worldsListsDiffer(ks, Y, Z)) {
for (i = 0; i < ks.worldsCount; i++) {
Y[i] = Z[i];
}
operatorPreA(ks, Z, worldsListAux);
operatorReunion(ks, Z, worldsListAux, Z);
}
for (i = 0; i < ks.worldsCount; i++) {
resultingWorldsList[i] = Y[i];
}
}
bool worldsListNotIncludedIn(kripkeStructure ks, bool worldsList1[100], bool worldsList2[100]) {
int i;
for (i = 0; i < ks.worldsCount; i++)
if (worldsList1[i] == true && worldsList2[i] == false) {
return true;
}
return false;
}
void operatorMC_EU(kripkeStructure ks, bool worldsList1[100], bool worldsList2[100], bool resultingWorldsList[100]) {
int i;
bool Y[100], Z[100], worldsListAux[100];
for (i = 0; i < ks.worldsCount; i++) {
Z[i] = worldsList2[i];
Y[i] = false;
}
while (worldsListNotIncludedIn(ks, Z, Y)) {
operatorReunion(ks, Y, Z, Y);
operatorPre(ks, Y, worldsListAux);
operatorIntersection(ks, worldsListAux, worldsList1, Z);
}
for (i = 0; i < ks.worldsCount; i++) {
resultingWorldsList[i] = Y[i];
}
}
void readFormula(char formula[100]) {
ifstream f("formula.txt");
f.get(formula, 100);
f.close();
}
void checkFormula(char formula[100]) {
int flen = strlen(formula);
char auxFormula[100];
if (formula[0] != '[' || formula[flen - 1] != ']') {
cout << "Missing \'[]\'";
return;
}
strncpy_s(auxFormula, MAX_FORMULA_LEN, formula, flen - 1);
strncpy_s(formula, MAX_FORMULA_LEN, auxFormula + 1, flen - 2);
flen -= 2;
if (formula[0] != '|' || formula[flen - 1] != '|') {
cout << "Missing \'||\'";
return;
}
strncpy_s(auxFormula, MAX_FORMULA_LEN, formula, flen - 1);
strncpy_s(formula, MAX_FORMULA_LEN, auxFormula + 1, flen - 2);
flen -= 2;
}
void convertWorldsListToString(kripkeStructure ks, bool boolList[100], char resultingString[100]) {
int i;
bool is_empty = true;
strcpy_s(resultingString, MAX_WORLDS_COUNT, "{");
for (i = 0; i < ks.worldsCount; i++) {
if (boolList[i] == true) {
strcat_s(resultingString, MAX_WORLDS_COUNT, ks.worldsNames[i]);
strcat_s(resultingString, MAX_WORLDS_COUNT, ",");
is_empty = false;
}
}
if (is_empty == false) {
resultingString[strlen(resultingString) - 1] = '\0';
}
strcat_s(resultingString, MAX_WORLDS_COUNT, "}");
}
void convertStringToWorldsList(kripkeStructure ks, char stringToConvert[100], bool resultingBoolList[100]) {
int i;
for (i = 0; i < ks.worldsCount; i++) {
if (strstr(stringToConvert, ks.worldsNames[i])) {
resultingBoolList[i] = true;
}
else {
resultingBoolList[i] = false;
}
}
}
void replaceInFormula(char *formula, int nrOfCharsToReplace, char Source[100]) {
char auxFormula[100];
strcpy_s(auxFormula, MAX_FORMULA_LEN, formula + nrOfCharsToReplace);
strcpy_s(formula, MAX_FORMULA_LEN, Source);
strcpy_s(formula + strlen(Source), MAX_FORMULA_LEN, auxFormula);
}
void findWorldsThatSatifyLabel(kripkeStructure ks, char label, bool resultingWorlds[100]) {
int i;
for (i = 0; i < ks.worldsCount; i++) {
if (label != 't' && (label == 'T' || strchr(ks.wordlsLabels[i], label))) {
resultingWorlds[i] = true;
}
else {
resultingWorlds[i] = false;
}
}
}
void extractListFromString(char *formula, char *resultingString) {
char *pos;
if (*formula != '{') {
cout << "Formula " << formula << " doesn't start from \'{\'!" << endl;
return;
}
pos = strchr(formula, '}');
strncpy_s(resultingString, MAX_FORMULA_LEN, formula, pos - formula);
}
void invertBoolList(bool listToInvert[100], int length) {
int i;
for (i = 0; i < length; i++) {
if (listToInvert[i] == true) {
listToInvert[i] = false;
}
else {
listToInvert[i] = true;
}
}
}
void printIndent(int positions) {
int i;
for (i = 0; i < positions; i++) {
cout << " ";
}
}
void processFormula(kripkeStructure ks, char *formula, int priority, int indentation) {
bool resultingWorldsList[100], resultBool[100], resultBoolAux[100];
char resultingWorldsString[100], resultString[100], resultStringAux[100];
if (strncmp(formula, "(", 1) == 0) {
char formulaAux[100];
printIndent(indentation);
cout << "(: " << formula << endl;
printIndent(indentation);
processFormula(ks, formula + 1, 2, indentation + 1);
replaceInFormula(formula, strlen(formula) - 1, formula + 1);
replaceInFormula(strchr(formula, ')'), strlen(strchr(formula, ')')) - 1, strchr(formula, ')') + 1);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
processFormula(ks, formula, priority, indentation + 1);
}
else if (priority >= 0 && strncmp(formula, "_", 1) == 0) {
printIndent(indentation);
cout << "_: " << formula << " (" << priority << ")" << endl;
processFormula(ks, formula + 1, 0, indentation + 1);
extractListFromString(formula + 1, resultString);
convertStringToWorldsList(ks, resultString, resultingWorldsList);
invertBoolList(resultingWorldsList, ks.worldsCount);
convertWorldsListToString(ks, resultingWorldsList, resultingWorldsString);
replaceInFormula(formula, 2 + strlen(resultString), resultingWorldsString);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
processFormula(ks, formula, priority, indentation + 1);
}
else if (priority >= 0 && strncmp(formula, "EX", 2) == 0) {
printIndent(indentation);
cout << "EX: " << formula << " (" << priority << ")" << endl;
processFormula(ks, formula + 2, 0, indentation + 1);
extractListFromString(formula + 2, resultString);
convertStringToWorldsList(ks, resultString, resultBool);
operatorPreE(ks, resultBool, resultingWorldsList);
convertWorldsListToString(ks, resultingWorldsList, resultingWorldsString);
replaceInFormula(formula, 3 + strlen(resultString), resultingWorldsString);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
processFormula(ks, formula, priority, indentation + 1);
}
else if (priority >= 0 && strncmp(formula, "EG", 2) == 0) {
printIndent(indentation);
cout << " EG: " << formula << " (" << priority << ")" << endl;
strcpy_s(resultString, MAX_FORMULA_LEN, "_AF_");
replaceInFormula(formula, 2, resultString);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
processFormula(ks, formula, priority, indentation + 1);
}
else if (priority >= 0 && strncmp(formula, "AG", 2) == 0) {
printIndent(indentation);
cout << " AG: " << formula << " (" << priority << ")" << endl;
strcpy_s(resultString, MAX_FORMULA_LEN, "_EF_");
replaceInFormula(formula, 2, resultString);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
processFormula(ks, formula, priority, indentation + 1);
}
else if (priority >= 0 && strncmp(formula, "AF", 2) == 0) {
printIndent(indentation);
cout << "AF: " << formula << " (" << priority << ")" << endl;
processFormula(ks, formula + 2, 0, indentation + 1);
extractListFromString(formula + 2, resultString);
convertStringToWorldsList(ks, resultString, resultBool);
operatorMC_AF(ks, resultBool, resultingWorldsList);
convertWorldsListToString(ks, resultingWorldsList, resultingWorldsString);
replaceInFormula(formula, 3 + strlen(resultString), resultingWorldsString);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
processFormula(ks, formula, priority, indentation + 1);
}
else if (priority >= 0 && strncmp(formula, "EF", 2) == 0) {
printIndent(indentation);
cout << " EF: " << formula << " (" << priority << ")" << endl;
strcpy_s(resultString, MAX_FORMULA_LEN, "ETU");
replaceInFormula(formula, 2, resultString);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
processFormula(ks, formula,priority, indentation + 1);//U are prioritate 1
}
else if (priority >= 0 && strncmp(formula, "E", 1) == 0) {
printIndent(indentation);
cout << "EU: " << formula << " (" << priority << ")" << endl;
processFormula(ks, formula + 1, 2, indentation + 1);
processFormula(ks, strchr(formula, 'U') + 1, 1, indentation + 1);//U are prioritate 1
extractListFromString(formula + 1, resultString);
extractListFromString(strchr(formula, 'U') + 1, resultStringAux);
convertStringToWorldsList(ks, resultString, resultBool);
convertStringToWorldsList(ks, resultStringAux, resultBoolAux);
operatorMC_EU(ks, resultBool, resultBoolAux, resultingWorldsList);
convertWorldsListToString(ks, resultingWorldsList, resultingWorldsString);
replaceInFormula(formula, 4 + strlen(resultString) + strlen(resultStringAux), resultingWorldsString);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
processFormula(ks, formula, priority, indentation + 1);
}
else if (priority >= 2 && *formula == '{' && *(strchr(formula, '}') + 1) == '^') {
printIndent(indentation);
cout << "^: " << formula << " (" << priority << ")" << endl;
processFormula(ks, strchr(formula, '}') + 2, priority, indentation + 1);
extractListFromString(formula, resultString);
convertStringToWorldsList(ks, resultString, resultBool);
extractListFromString(strchr(formula, '}') + 2, resultStringAux);
convertStringToWorldsList(ks, resultStringAux, resultBoolAux);
operatorIntersection(ks, resultBool, resultBoolAux, resultingWorldsList);
convertWorldsListToString(ks, resultingWorldsList, resultingWorldsString);
replaceInFormula(formula, 3 + strlen(resultString) + strlen(resultStringAux), resultingWorldsString);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
}
else if (priority >= 2 && *formula == '{' && *(strchr(formula, '}') + 1) == 'v') {
printIndent(indentation);
cout << "v: " << formula << " (" << priority << ")" << endl;
processFormula(ks, strchr(formula, '}') + 2, priority, indentation + 1);
extractListFromString(formula, resultString);
convertStringToWorldsList(ks, resultString, resultBool);
extractListFromString(strchr(formula, '}') + 2, resultStringAux);
convertStringToWorldsList(ks, resultStringAux, resultBoolAux);
operatorReunion(ks, resultBool, resultBoolAux, resultingWorldsList);
convertWorldsListToString(ks, resultingWorldsList, resultingWorldsString);
replaceInFormula(formula, 3 + strlen(resultString) + strlen(resultStringAux), resultingWorldsString);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
}
else if (strncmp(formula, "AX", 2) == 0) {
printIndent(indentation);
cout << " AX: " << formula << " (" << priority << ")" << endl;
strcpy_s(resultString, MAX_FORMULA_LEN, "_EX_");
replaceInFormula(formula, 2, resultString);
printIndent(indentation);
cout << formulaStartingPoint << " (" << priority << ")" << endl;
processFormula(ks, formula, priority, indentation + 1);
}
else if (*formula != '\0' && isWorldLabel(ks, *formula)) {
printIndent(indentation);
cout << "label: " << formula << " (" << priority << ")" << endl;
//processFormula(ks, formula+1, priority);
findWorldsThatSatifyLabel(ks, *formula, resultingWorldsList);
convertWorldsListToString(ks, resultingWorldsList, resultingWorldsString);
replaceInFormula(formula, 1, resultingWorldsString);
printIndent(indentation);
cout << formulaStartingPoint << " ("<<priority<<")" << endl;
processFormula(ks, formula, priority, indentation + 1);
}
else if (*formula != '\0'&&*formula != '{') {
cout << "Encountered error on " << formula << "!" << endl;
return;
}
}
int main() {
kripkeStructure ks;
char formula[100];
formulaStartingPoint = formula;
readKripreStructure(ks);
printKripkeStructure(ks);
readFormula(formula);
cout << formula << endl << endl;
checkFormula(formula);
processFormula(ks, formula, 2, 0);
if (*(strchr(formula, '}') + 1) != '\0') {
cout << "Encountered error on " << (strchr(formula, '}') + 1) << "!" << endl;
}
cout << "\nResult: " << formula << endl;
int x;
cin >> x;
} | [
"hdorin@users.noreply.github.com"
] | hdorin@users.noreply.github.com |
cc4d7e8bc2a911d4f31fde5d4fb0160742c9a79c | 91a882547e393d4c4946a6c2c99186b5f72122dd | /Source/XPSP1/NT/shell/ext/webcheck/test/notfcvt/notfcvt.cpp | 5b1783b44f05fbb5a79e553e1949856c4682d24d | [] | no_license | IAmAnubhavSaini/cryptoAlgorithm-nt5src | 94f9b46f101b983954ac6e453d0cf8d02aa76fc7 | d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2 | refs/heads/master | 2023-09-02T10:14:14.795579 | 2021-11-20T13:47:06 | 2021-11-20T13:47:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,046 | cpp | #include <windows.h>
#include <subsmgr.h>
#include <stdio.h>
#include <stdarg.h>
void ErrorExit(char *fmt, ...)
{
va_list va;
va_start(va, fmt);
vprintf(fmt, va);
exit(1);
}
int _cdecl main()
{
HINSTANCE hinst = LoadLibrary("webcheck.dll");
if (hinst)
{
typedef (*PFCONVERTNOTFMGR)();
PFCONVERTNOTFMGR ConvertNotfMgrSubscriptions;
PFCONVERTNOTFMGR ConvertNotfMgrSchedules;
ConvertNotfMgrSchedules = (PFCONVERTNOTFMGR)GetProcAddress(hinst, MAKEINTRESOURCE(11));
if (ConvertNotfMgrSchedules)
{
HRESULT hr = ConvertNotfMgrSchedules();
if (SUCCEEDED(hr))
{
printf("Schedule conversion succeeded - return code: 0x%08x\n", hr);
ConvertNotfMgrSubscriptions = (PFCONVERTNOTFMGR)GetProcAddress(hinst, MAKEINTRESOURCE(10));
if (ConvertNotfMgrSubscriptions)
{
HRESULT hr = ConvertNotfMgrSubscriptions();
if (SUCCEEDED(hr))
{
printf("Subscription conversion succeeded - return code: 0x%08x\n", hr);
}
else
{
ErrorExit("Error converting subscriptions - error code: 0x%08x\n", hr);
}
}
else
{
ErrorExit("Couldn't find procedure 'ConvertNotfMgrSubscriptions' ordinal #10 - error code: %d\n",
GetLastError());
}
}
else
{
ErrorExit("Error converting schedules - error code: 0x%08x\n", hr);
}
}
else
{
ErrorExit("Couldn't find procedure 'ConvertNotfMgrSchedules' ordinal #11 - error code: %d\n",
GetLastError());
}
}
else
{
ErrorExit("Couldn't load webcheck - error code: %d\n", GetLastError());
}
return 0;
}
| [
"support@cryptoalgo.cf"
] | support@cryptoalgo.cf |
10a3e0735206acc365373f606063ee117689c8f6 | 31e5bd52827263ea7d80ce9e4c98cc384e9efe2f | /trapecio.cc | 88681a3a94e6a2da395df74739f02b4257344df0 | [] | no_license | DobleRodriguez/Practicas-IG | adac634683564f99029686889c3358ec0c06ae4b | bf2ca39cc7a636ad8de4fe75e28e087901125822 | refs/heads/master | 2023-04-16T00:21:45.582295 | 2021-04-29T14:19:54 | 2021-04-29T14:19:54 | 225,965,508 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,054 | cc | #include "aux.h"
#include "malla.h"
#include "trapecio.h"
Trapecio::Trapecio() {
v = {
Tupla3f(-0.5, 0, 1), // Inferior izquierda frontal
Tupla3f(0.5, 0, 1), // Inferior derecha frontal
Tupla3f(-0.3, 1, 1), // Superior izquierda frontal
Tupla3f(0.3, 1, 1), // Superior derecha frontal
Tupla3f(-0.5, 0, -1), // Inferior izquierda trasera
Tupla3f(0.5, 0, -1), // Inferior derecha trasera
Tupla3f(-0.3, 1, -1), // Superior izquierda trasera
Tupla3f(0.3, 1, -1) // Superior derecha trasera
} ;
f = {
// Frontal
Tupla3i(1, 2, 0),
Tupla3i(3, 2, 1),
// Superior
Tupla3i(3, 6, 2),
Tupla3i(7, 6, 3),
// Trasera
Tupla3i(4, 6, 5),
Tupla3i(6, 7, 5),
// Inferior
Tupla3i(0, 5, 1),
Tupla3i(5, 0, 4),
// Izquierda
Tupla3i(0, 2, 6),
Tupla3i(4, 0, 6),
// Derecha
Tupla3i(5, 3, 1),
Tupla3i(3, 5, 7)
} ;
}
| [
"e.doblerodriguez@go.ugr.es"
] | e.doblerodriguez@go.ugr.es |
68b95177fa424cc9deac83165c531f84cdebe097 | 1105319b5e630fab79dc01ec5644cab6dc54162a | /modules/type/complex/boolean/unit/scalar/if_zero_else_one.cpp | f2fa6fb79559ada37b9d0f1758aed2c0868ab716 | [
"BSL-1.0"
] | permissive | joker-eph/nt2 | 29038772b81506cee7274f793531169c7995ca76 | 16c47e568fbd3e0309bb7d71ddb1a1a86840dbc6 | refs/heads/master | 2021-01-16T20:36:46.095656 | 2013-05-30T17:21:48 | 2013-05-30T17:23:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,857 | cpp | //==============================================================================
// Copyright 2003 - 2011 LASMEA UMR 6602 CNRS/Univ. Clermont II
// Copyright 2009 - 2011 LRI UMR 8623 CNRS/Univ Paris Sud XI
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#define NT2_UNIT_MODULE "nt2 boost.simd.boolean toolbox - if_zero_else_one/scalar Mode"
#include <nt2/include/functions/if_zero_else_one.hpp>
#include <nt2/include/constants/nan.hpp>
#include <nt2/include/constants/inf.hpp>
#include <nt2/include/constants/minf.hpp>
#include <nt2/include/constants/true.hpp>
#include <nt2/include/constants/false.hpp>
#include <nt2/sdk/functor/meta/call.hpp>
#include <nt2/sdk/unit/tests/relation.hpp>
#include <nt2/sdk/unit/tests/type_expr.hpp>
#include <nt2/sdk/unit/module.hpp>
#include <complex>
#include <nt2/sdk/simd/logical.hpp>
NT2_TEST_CASE_TPL ( if_zero_else_one_real__2_0, NT2_REAL_TYPES)
{
using nt2::if_zero_else_one;
using nt2::tag::if_zero_else_one_;
using nt2::logical;
typedef std::complex<T> cT;
typedef typename nt2::meta::call<if_zero_else_one_(cT)>::type r_t;
typedef typename nt2:: meta::as_complex<T>::type wished_r_t;
NT2_TEST_TYPE_IS( r_t, wished_r_t);
NT2_TEST_EQUAL(if_zero_else_one(nt2::False< nt2::logical<T> >()), cT(1));
NT2_TEST_EQUAL(if_zero_else_one(nt2::True< nt2::logical<T> >()), cT(0));
NT2_TEST_EQUAL(if_zero_else_one(nt2::Inf<cT>()), cT(0));
NT2_TEST_EQUAL(if_zero_else_one(nt2::Minf<cT>()), cT(0));
NT2_TEST_EQUAL(if_zero_else_one(nt2::Nan<cT>()) , cT(0));
NT2_TEST_EQUAL(if_zero_else_one(nt2::Zero<cT>()), cT(1));
} // end of test for floating_
| [
"jtlapreste@gmail.com"
] | jtlapreste@gmail.com |
f6cf78fa883289e814dba8f7b1c24498e3e6a9a6 | 7e309f67cafe5528eaab8757fa34dd9c59355195 | /Algorithms/EditDistance/editDistance.cc | 4ec70c62dc08358dc155538bbc48d5d7537feb4f | [] | no_license | xusiwei/leetcode | 56cc827020ab5a9373d7b4221e8ae82734b01e7e | 80f0c2b2a89843df2ea3adb12828991ad8534373 | refs/heads/master | 2021-04-22T13:26:46.577996 | 2020-05-24T17:06:12 | 2020-05-24T17:06:12 | 36,977,056 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,761 | cc | /*
copyright xu(xusiwei1236@163.com), all right reserved.
Edit Distance
==============
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)
You have the following 3 operations permitted on a word:
a) Insert a character
b) Delete a character
c) Replace a character
*/
class Solution {
public:
/**
* dp[i][j] is minDistance(word1[0...i), word2[0...j))
*
* if word1[i-1] == word2[j-1],
* dp[i][j] = dp[i-1][j-1]
* else
* dp[i][j] = min(dp[i][j-1] + 1, dp[i-1][j] + 1, dp[i-1][j-1] + 1)
* insert delete replace
*
* word1 : "abb", word2 : "abccd"
*
* 1 ) initailize matrix:
* "" a b c c d
* "" 0 1 2 3 4 5
* a 1
* b 2
* b 3
*
* 2 ) dynmaic programming:
* "" a b c c d
* "" 0 1 2 3 4 5
* a 1 0 1 2 3 4
* b 2 1 0 1 2 3
* b 3 2 1 1 2 3
*
**/
int minDistance(string word1, string word2) {
int n1 = word1.size();
int n2 = word2.size();
if(n1 == 0) return n2;
if(n2 == 0) return n1;
vector<vector<int> > dp(n1+1, vector<int>(n2+1));
for(int i = 0; i <= n1; i++) dp[i][0] = i;
for(int j = 0; j <= n2; j++) dp[0][j] = j;
for(int i = 1; i <= n1; i++) {
for(int j = 1; j <= n2; j++) {
if(word1[i-1] == word2[j-1]) {
dp[i][j] = dp[i-1][j-1];
}
else {
dp[i][j] = min(dp[i][j-1], min(dp[i-1][j], dp[i-1][j-1])) + 1;
}
}
}
return dp[n1][n2];
}
};
| [
"xusiwei1236@163.com"
] | xusiwei1236@163.com |
ca7da363a25aa90373067ff3397fa0f581fefccf | 22018b7c6eea49adb6ac14a609e9792356828956 | /GameTemplate/Game/graphics/SkinModel.h | f604324955cd6704868927eba70099924f6efe48 | [] | no_license | hirota-ryuki/git_hirota | fb50ac126641c69e6afc7048a0aea0f611031738 | 3c341053fd02ec07018cbb25a7f499541ef06ec8 | refs/heads/master | 2021-07-08T06:37:02.992278 | 2020-11-12T01:02:06 | 2020-11-12T01:02:06 | 208,982,270 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 8,649 | h | #pragma once
#include "Skeleton.h"
#include "Assets/shader/LightNumData.h"
//#include "Light.h"
/// <summary>
/// ポイントライト用の構造体。
/// </summary>
struct SPointLight {
CVector4 pos;
CVector4 color;
float range;
float pad[3];
};
/// <summary>
/// スポットライト用の構造体。
/// </summary>
struct SSpotLight {
CVector4 pos;
CVector4 color;
CVector4 direction;
float range;
float pad[3];
};
/*!
*@brief FBXの上方向。
*/
enum EnFbxUpAxis {
enFbxUpAxisY, //Y-up
enFbxUpAxisZ, //Z-up
};
/*!
*@brief スキンモデルクラス。
*/
class SkinModel
{
public:
//メッシュが見つかったときのコールバック関数。
using OnFindMesh = std::function<void(const std::unique_ptr<DirectX::ModelMeshPart>&)>;
/*!
*@brief デストラクタ。
*/
~SkinModel();
/*!
*@brief 初期化。
*@param[in] filePath ロードするcmoファイルのファイルパス。
*@param[in] enFbxUpAxis fbxの上軸。デフォルトはenFbxUpAxisZ。
*/
void Init(const wchar_t* filePath, EnFbxUpAxis enFbxUpAxis = enFbxUpAxisZ);
/*!
*@brief モデルをワールド座標系に変換するためのワールド行列を更新する。
*@param[in] position モデルの座標。
*@param[in] rotation モデルの回転。
*@param[in] scale モデルの拡大率。
*/
void UpdateWorldMatrix(CVector3 position, CQuaternion rotation, CVector3 scale);
/// <summary>
/// 法線マップの初期化処理。
/// </summary>
/// <param name="filePath">法線マップのファイルパス。</param>
void InitNormalMap(const wchar_t* filePath);
/// <summary>
/// スペキュラマップの初期化処理。
/// </summary>
/// <param name="filePath">スペキュラマップのファイルパス。</param>
void InitSpecMap(const wchar_t* filePath);
/*!
*@brief ボーンを検索。
*@param[in] boneName ボーンの名前。
*@return 見つかったボーン。見つからなかった場合はnullptrを返します。
*/
Bone* FindBone(const wchar_t* boneName)
{
int boneId = m_skeleton.FindBoneID(boneName);
return m_skeleton.GetBone(boneId);
}
/*!
*@brief モデルを描画。
*@param[in] viewMatrix カメラ行列。
* ワールド座標系の3Dモデルをカメラ座標系に変換する行列です。
*@param[in] projMatrix プロジェクション行列。
* カメラ座標系の3Dモデルをスクリーン座標系に変換する行列です。
*/
void Draw(
EnRenderMode renderMode,
const CMatrix& viewMatrix,
const CMatrix& projMatrix );
/*!
*@brief スケルトンの取得。
*/
Skeleton& GetSkeleton()
{
return m_skeleton;
}
/*!
*@brief メッシュを検索する。
*@param[in] onFindMesh メッシュが見つかったときのコールバック関数
*/
void FindMesh(OnFindMesh onFindMesh) const
{
for (auto& modelMeshs : m_modelDx->meshes) {
for (std::unique_ptr<DirectX::ModelMeshPart>& mesh : modelMeshs->meshParts) {
onFindMesh(mesh);
}
}
}
void SetLight(int light, const CVector4& direction, float color) {
m_light.directionLight.direction[light] = direction;
m_light.directionLight.direction[light].Normalize();
m_light.directionLight.color[0] = { color, color, color, 0.2f };
}
/*!
*@brief SRVのレジスタ番号。
*/
enum EnSkinModelSRVReg {
enSkinModelSRVReg_DiffuseTexture = 0, //!<ディフューズテクスチャ。
enSkinModelSRVReg_BoneMatrix, //!<ボーン行列。
};
const CMatrix& GetWorldMatrix() const
{
return m_worldMatrix;
}
/// <summary>
/// シャドウレシーバーのフラグを設定する。
/// </summary>
/// <param name="flag">trueを渡すとシャドウレシーバーになる</param>
/// <remarks>
/// シャドウレシーバーとは影を落とされるオブジェクトのことです。
/// シャドウキャスターによって生成された、シャドウマップを利用して
/// 自身に影を落とします。
/// オブジェクトがシャドウレシーバーかつシャドウキャスターになっている場合は
/// セルフシャドウ(自分の影が自分に落ちる)を行うことができます。
/// </remarks>
void SetShadowReciever(bool flag)
{
m_isShadowReciever = flag;
}
/// <summary>
/// ディレクションライトの方向をセット。
/// </summary>
/// <param name="LDir">方向</param>
void SetDirectionLightDirection(const CVector4& LDir ) {
m_light.directionLight.direction[0] = LDir;
m_light.directionLight.direction[0].Normalize();
}
/// <summary>
///ディレクションライトの色をセット。
/// </summary>
/// <param name="LColor">色</param>
void SetDirectionLightColor(const CVector4& LColor ) {
m_light.directionLight.color[0] = LColor;
}
/// <summary>
/// スペキュラの累乗数をセット。
/// </summary>
/// <param name="spec">累乗数</param>
void SetSpec(float spec ) {
m_light.specPow = spec;
}
/// <summary>
/// アンビエントライトをセット。
/// </summary>
/// <param name="spec">アンビエントライト</param>
void SetAmbientLight(const CVector3& ambientLight) {
m_light.ambientLight = ambientLight;
}
/// <summary>
/// ポイントライトを設定する関数。
/// </summary>
/// <param name="spotlist">ポイントライト。</param>
static void SetPointLight(SPointLight pointlist[NUM_POINT_LIG]) {
for (int i = 0; i < NUM_POINT_LIG; i++) {
m_pointLight[i] = pointlist[i];
}
}
/// <summary>
/// スポットライトを設定する関数。
/// </summary>
/// <param name="spotlist">スポットライト。</param>
static void SetSpotLight(SSpotLight spotlist[NUM_SPOT_LIG]) {
for (int i = 0; i < NUM_SPOT_LIG; i++) {
m_spotLight[i] = spotlist[i];
}
}
private:
/*!
*@brief サンプラステートの初期化。
*/
void InitSamplerState();
/*!
*@brief 定数バッファの作成。
*/
void InitConstantBuffer();
/// <summary>
/// ディレクションライトの初期化。
/// </summary>
void InitDirectionLight();
/// <summary>
/// ポイントライトの初期化。
/// </summary>
void InitPointLight();
/// <summary>
/// スポットライトの初期化。
/// </summary>
void InitSpotLight();
/*!
*@brief スケルトンの初期化。
*@param[in] filePath ロードするcmoファイルのファイルパス。
*/
void InitSkeleton(const wchar_t* filePath);
private:
//定数バッファ。
struct SVSConstantBuffer {
CMatrix mWorld;
CMatrix mView;
CMatrix mProj;
CMatrix mLightView; //ライトビュー行列。
CMatrix mLightProj; //ライトプロジェクション行列。
int isShadowReciever; //シャドウレシーバーのフラグ。
int isHasNormalMap; //法線マップを保持していかどうか。
int isHasSpecMap; //法線マップを保持していかどうか。
};
/*!
*@brief ディレクションライト。
*/
struct SDirectionLight {
CVector4 direction[NUM_DIRECTION_LIG]; //ライトの方向。
CVector4 color[NUM_DIRECTION_LIG]; //ライトのカラー。
};
/// <summary>
/// ライト構造体。
/// </summary>
struct SLight {
SDirectionLight directionLight; //ディレクションライト
CVector3 eyePos; //視点の座標。
float specPow; //鏡面反射の絞り。
CVector3 ambientLight; //環境光。
};
EnFbxUpAxis m_enFbxUpAxis = enFbxUpAxisZ; //FBXの上方向。
ID3D11Buffer* m_cb = nullptr; //定数バッファ。
Skeleton m_skeleton; //スケルトン。
CMatrix m_worldMatrix; //ワールド行列。
DirectX::Model* m_modelDx; //DirectXTKが提供するモデルクラス。
ID3D11SamplerState* m_samplerState = nullptr; //サンプラステート。
//ライト
ID3D11Buffer* m_lightCb = nullptr; //ライト用の定数バッファ。
SLight m_light; //ライトクラス。
//ポイントライト
ID3D11Buffer* m_pointlightCb = nullptr; //ポイントライト用の定数バッファ。
static SPointLight m_pointLight[NUM_POINT_LIG]; //ポイントライトクラス。
//スポットライト
ID3D11Buffer* m_spotlightCb = nullptr; //スポットライト用の定数バッファ。
static SSpotLight m_spotLight[NUM_SPOT_LIG]; //スポットライトクラス。
//影。
bool m_isShadowReciever = false; //シャドウレシーバーのフラグ。
//法線マップ。
ID3D11ShaderResourceView* m_normalMapSRV = nullptr; //法線マップのSRV。
//スペキュラマップ。
ID3D11ShaderResourceView* m_specMapSRV = nullptr; //スペキュラマップのSRV。
}; | [
"kbc18b24@stu.kawahara.ac.jp"
] | kbc18b24@stu.kawahara.ac.jp |
a3a7637737293d8a48c089be48d9f519893bfe69 | b5513464486a0c4520468ddeacc074cc95383568 | /ompi/contrib/vt/vt/tools/vtunify/vt_unify_markers.h | bb6b8fd3715f84b686ce2159138d52f7c30c1f50 | [
"BSD-3-Clause-Open-MPI",
"BSD-3-Clause"
] | permissive | ICLDisco/ulfm-legacy | aee021037354b8ee58f6789fea132030ca0cda43 | 720dfbd7d522b67b8ff0b3e1321676a1870c7fc8 | refs/heads/master | 2022-11-09T06:09:43.671960 | 2017-07-14T00:28:44 | 2017-07-14T00:28:44 | 276,218,089 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,878 | h | /**
* VampirTrace
* http://www.tu-dresden.de/zih/vampirtrace
*
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
*
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
* Centre, Federal Republic of Germany
*
* See the file COPYING in the package base directory for details
**/
#ifndef _VT_UNIFY_MARKERS_H_
#define _VT_UNIFY_MARKERS_H_
#include "config.h"
#include "vt_inttypes.h"
#include "vt_unify.h"
#include "vt_unify_defs_recs.h"
#include "vt_unify_lvector.hh"
#include "vt_unify_tkfac.h"
#include <set>
//
// MarkersC class
//
class MarkersC
{
public:
//
// marker spot structure
//
struct MarkerSpotS
{
MarkerSpotS()
: proc( 0 ), time( 0 ), marker( 0 ) {}
MarkerSpotS( const uint32_t & _proc, const uint64_t & _time,
const uint32_t & _marker, const std::string & _text )
: proc( _proc ), time( _time ), marker( _marker ), text( _text ) {}
#ifdef VT_MPI
// get size needed to pack marker spot
VT_MPI_INT getPackSize();
// pack marker spot into a buffer
void pack( char *& buffer, const VT_MPI_INT & bufferSize,
VT_MPI_INT & bufferPos );
// unpack marker spot from a buffer
void unpack( char *& buffer, const VT_MPI_INT & bufferSize,
VT_MPI_INT & bufferPos );
#endif // VT_MPI
// operator for sorting global marker spots
// (not really necessary - but it can't hurt)
bool operator<( const MarkerSpotS & a ) const
{
if( proc == a.proc )
return time < a.time;
else
return proc < a.proc;
}
uint32_t proc; // process id
uint64_t time; // timestamp
uint32_t marker; // marker id
std::string text; // marker text
};
// constructor
MarkersC();
// destructor
~MarkersC();
// unify markers
bool run();
// rename temporary output files
bool cleanUp();
private:
// read local markers
bool readLocal();
// read local markers of certain stream
bool readLocal( const uint32_t & streamId,
LargeVectorC<DefRec_DefMarkerS*> & locDefs,
LargeVectorC<MarkerSpotS*> & locSpots );
// write global markers
bool writeGlobal();
#ifdef VT_MPI
// gather either local marker defs. or spots
typedef enum { GATHER_TYPE_DEFS, GATHER_TYPE_SPOTS } GatherTypeT;
bool gatherLocal( const GatherTypeT & type, void * locRecs );
#endif // VT_MPI
// token factory scope for marker definitions
TokenFactoryScopeC<DefRec_DefMarkerS> * m_tkfacScope;
// global marker definitions
std::set<DefRec_DefMarkerS> m_globDefs;
// global marker spots
LargeVectorC<MarkerSpotS> m_globSpots;
};
// instance of class MarkersC
extern MarkersC * theMarkers;
#endif // _VT_UNIFY_MARKERS_H_
| [
"4259120+jjhursey@users.noreply.github.com"
] | 4259120+jjhursey@users.noreply.github.com |
137565c8bae93a8f6bd7db02115a4343215a6d10 | dd9cf89196476f231b5e9d7b99a50dc3d9395670 | /EuchreTest/Card.cpp | 855d7f316e594ba073d1a9cb5e00b4284fc1ad57 | [] | no_license | tylerjosephrose/Euchre | e99cdab8dcb81da579c502d1f24ad7c7afdc807b | 47b61aef8155f9ba4740dce03cf11a00f994e23f | refs/heads/master | 2021-01-12T14:10:22.341479 | 2016-12-07T12:48:44 | 2016-12-07T12:48:44 | 69,924,127 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,976 | cpp | /*
This is the Card Class
Tyler Rose
Sep-22-2016
*/
#include <iostream>
#include <string>
#include "Card.h"
using namespace std;
Card::Card(int value, int suit)
{
m_value = static_cast<Value>(value);
m_suit = static_cast<Suit>(suit);
m_owner = Owner::MainDeck;
}
Value Card::GetValue() const
{
return m_value;
}
Suit Card::GetSuit() const
{
return m_suit;
}
Owner Card::GetOwner() const
{
return m_owner;
}
void Card::SetOwner(Owner owner)
{
m_owner = owner;
}
string Card::ValueToString() const
{
switch(static_cast<int>(m_value))
{
case 9: return "9";
case 10: return "10";
case 11: return "J";
case 12: return "Q";
case 13: return "K";
case 14: return "A";
}
return "Not a Card!! Uh Oh!";
}
string Card::SuitToString() const
{
switch(m_suit)
{
case Hearts: return "Hearts";
case Spades: return "Spades";
case Diamonds: return "Diamonds";
case Clubs: return "Clubs";
case High: return "High";
case Low: return "Low";
}
return "Not a Card!! Uh Oh!";
}
string SuitToString(Suit suit)
{
switch(suit)
{
case Hearts: return "Hearts";
case Spades: return "Spades";
case Diamonds: return "Diamonds";
case Clubs: return "Clubs";
case High: return "High";
case Low: return "Low";
}
return "Not a Card!! Uh Oh!";
}
string Card::OwnerToString() const
{
switch(m_owner)
{
case Player_1: return "Player 1";
case Player_2: return "Player 2";
case Player_3: return "Player 3";
case Player_4: return "Player 4";
case MainDeck: return "Main Deck";
case InPlay: return "In Play";
}
}
string OwnerToString(Owner owner)
{
switch(owner)
{
case Player_1: return "Player 1";
case Player_2: return "Player 2";
case Player_3: return "Player 3";
case Player_4: return "Player 4";
case MainDeck: return "Main Deck";
case InPlay: return "In Play";
}
} | [
"tylerjosephrose@gmail.com"
] | tylerjosephrose@gmail.com |
177c02968ada099ab2a18d089d4ac2706459418e | 5f9fec9c75b81e89eedee104772337d2bd600daa | /minjmp2d.cpp | 1db247e5fb7858f5617912b2cc690a159b848d3e | [] | no_license | shinron4/Geeks | 146b91679f690e379eb9e7ec1745aa13a6d0f648 | 82dc35439d3a42c426fc2dbf934f3a3d852b0346 | refs/heads/master | 2021-01-21T04:27:26.099641 | 2017-10-28T04:20:53 | 2017-10-28T04:20:53 | 101,915,443 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,103 | cpp | #include <iostream>
#include <climits>
#include <queue>
using namespace std;
int minHops(int matrix[64][64], int m, int n){
int color[n][m], minjmp[n][m];
for(int i = 0; i < n; i++) for(int j = 0; j < m; j++){
color[i][j] = 0;
minjmp[i][j] = INT_MAX;
}
minjmp[0][0] = 0;
queue< pair<int, int> > q;
q.push(make_pair(0, 0));
color[0][0] = 1;
while(!q.empty()){
int u = q.front().first, v = q.front().second, b;
q.pop();
color[u][v] = 2;
b = u + matrix[u][v];
for(int i = u; i <= (b < n - 1 ? b : n - 1); i++){
if(color[i][v] == 0){
minjmp[i][v] = minjmp[u][v] + 1;
q.push(make_pair(i, v));
color[i][v] = 1;
}
}
b = v + matrix[u][v];
for(int i = v; i <= (b < m - 1 ? b : m - 1); i++){
if(color[u][i] == 0){
minjmp[u][i] = minjmp[u][v] + 1;
q.push(make_pair(u, i));
color[u][i] = 1;
}
}
}
return (minjmp[n - 1][m - 1] < INT_MAX ? minjmp[n - 1][m - 1] + 1: 0);
}
int main(){
int n, m, A[64][64];
cin >> n >> m;
for(int i = 0; i < n; i++) for(int j = 0; j < m; j++){
cin >> A[i][j];
}
cout << minHops(A, n, m) << "\n";
return 0;
} | [
"shinron.4@gmail.com"
] | shinron.4@gmail.com |
6944eaf7c63b127924aef1bfab5d2cb0cacab135 | 3ba7549a0e753d125f8a216e33870ae558c9dfb6 | /luogu/cpp/p5735.cpp | d627e80bd18f47a058605735eaa5fc5760cdb104 | [] | no_license | child-eating-tech/luogu-lib | 3860dd8232e2a7a26d40acde3dc1d1d0b97f7a72 | 24f356ac16eeace6711ed54d7d7a825de2f44582 | refs/heads/main | 2023-02-06T09:40:15.566609 | 2020-12-25T12:23:10 | 2020-12-25T12:23:10 | 301,417,456 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 423 | cpp | #include<bits/stdc++.h>
using namespace std;
double dis(double,double,double,double);
int main(){
double x1,x2,x3,y1,y2,y3;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
double dis1,dis2,dis3;
dis1=dis(x1,y1,x2,y2);
dis2=dis(x2,y2,x3,y3);
dis3=dis(x1,y1,x3,y3);
double dist=dis1+dis2+dis3;
printf("%.2lf",dist);
}
double dis(double a,double b,double c,double d){
return sqrt(pow((d-b),2)+pow((c-a),2));
} | [
"lilingfeng0408@outlook.com"
] | lilingfeng0408@outlook.com |
43e8ede2ad062f93ce402d77acd6a7ce963c176a | c37fc0308322c49773cfae61d6283949aeff6ef1 | /Codeforces/PRACTICE/450A.cpp | eed8e38e97a31e0143effca3f36fd221e34b20df | [] | no_license | sagarmittal1/CP-Practice | 59a899b0e62c62f959989ca0182a0278c5483c51 | 0aaf97dac4da684429373cdc004d32e12d87e1db | refs/heads/main | 2023-08-15T00:45:29.581219 | 2021-10-04T19:38:10 | 2021-10-04T19:38:10 | 305,486,471 | 7 | 4 | null | 2021-10-04T19:38:10 | 2020-10-19T19:03:28 | C++ | UTF-8 | C++ | false | false | 610 | cpp | #include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define ll long long
#define pb push_back
#define ff first
#define ss second
int main()
{
fast;
int n, m;
cin >> n >> m;
queue <pair<int, int>> qu;
for (int i = 1; i <= n; i++) {
int x; cin >> x;
qu.push(make_pair(x, i));
}
while (qu.size() != 1) {
if (qu.front().ff <= m) {
qu.pop();
} else {
qu.front().ff -= m;
int x1 = qu.front().ff;
int x2 = qu.front().ss;
qu.pop();
qu.push(make_pair(x1, x2));
}
}
cout << qu.front().ss;
return 0;
} | [
"mittalsagar006@gmail.com"
] | mittalsagar006@gmail.com |
241db25416e28c98ae7a85a95aa1a386b4290627 | f79b579446486539be3b667165298e3530c21062 | /Maximal_Rectangle/main.cpp | 6e25764dceec1c3bc11e87302d950e5d3b61511a | [] | no_license | haidixiansheng/LeetCode | 01ec52020e9abc2fce4a49b165ffe44a603055c6 | 561e7997e1ed77249993cd72a071d148bea2f53c | refs/heads/master | 2021-01-10T21:19:03.615224 | 2014-11-23T05:49:41 | 2014-11-23T05:49:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 987 | cpp | #include <vector>
#include <iostream>
using namespace std;
int max(vector<bool>& check)
{
int max = 0;
int current = 0;
for (unsigned int i = 0, len = check.size(); i < len; ++i )
{
if(!check[i]){
max = current > max ? current : max;
current = 0;
}
else
current ++;
}
max = current > max ? current : max;
return max;
}
int maximalRectangle(vector<vector<char> > &matrix) {
if(matrix.size() == 0 )
return 0;
int row = matrix.size(), col = matrix[0].size();
vector<bool> rowCheck(row, true);
vector<bool> colCheck(col, true);
for (unsigned int i = 0; i < row; ++i)
{
for (unsigned int j = 0; j < col; ++j)
{
if(matrix[i][j] == '0'){
rowCheck[i] = false;
colCheck[j] = false;
}
}
}
return max(rowCheck) * max(colCheck);
}
int main() {
char arr[2] = {'0','1'};
vector<vector<char> > input(1, vector<char>(arr, arr+2));
cout << maximalRectangle(input) <<endl;
return 0;
}
| [
"haidixiansheng@gmail.com"
] | haidixiansheng@gmail.com |
a162c3615b52da3843827f8c98ad9b1e2056cc3d | 39f5ed1178375c65876323589a03ef5daf6e4739 | /content/services/auction_worklet/bidder_worklet.h | 9478e49aecf7d3b270411363f9a1e8869a379f65 | [
"BSD-3-Clause"
] | permissive | berber1016/chromium | 2718166c02fcb3aad24cc3bd326a4f8d2d7c0cae | 9dc373d511536c916dec337b4ccc53106967d28d | refs/heads/main | 2023-03-21T21:53:55.686443 | 2021-05-14T10:13:20 | 2021-05-14T10:13:20 | 367,332,075 | 1 | 0 | BSD-3-Clause | 2021-05-14T10:46:30 | 2021-05-14T10:46:29 | null | UTF-8 | C++ | false | false | 7,020 | h | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SERVICES_AUCTION_WORKLET_BIDDER_WORKLET_H_
#define CONTENT_SERVICES_AUCTION_WORKLET_BIDDER_WORKLET_H_
#include <cmath>
#include <memory>
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/optional.h"
#include "base/time/time.h"
#include "content/services/auction_worklet/public/mojom/auction_worklet_service.mojom-forward.h"
#include "content/services/auction_worklet/public/mojom/auction_worklet_service.mojom.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "services/network/public/mojom/url_loader_factory.mojom-forward.h"
#include "third_party/blink/public/mojom/interest_group/interest_group_types.mojom-forward.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "v8/include/v8.h"
namespace auction_worklet {
class AuctionV8Helper;
class TrustedBiddingSignals;
class WorkletLoader;
// Represents a bidder worklet for FLEDGE
// (https://github.com/WICG/turtledove/blob/main/FLEDGE.md). Loads and runs the
// bidder worklet's Javascript.
//
// Each worklet object can only be used to load and run a single script's
// generateBid() and (if the bid is won) reportWin() once.
//
// TODO(mmenke): Make worklets reuseable. Allow a single BidderWorklet instance
// to both be used for two generateBid() calls for different interest groups
// with the same owner in the same auction, and to be used to bid for the same
// interest group in different auctions.
class BidderWorklet {
public:
// Structure containing information about a bid returned by invoking a
// worklet's generageBid() method. If no bid is made, no Bid is constructed.
struct Bid {
Bid(std::string ad,
double bid,
GURL render_url,
base::TimeDelta bid_duration);
Bid(const Bid& other);
Bid(Bid&& other);
~Bid();
Bid& operator=(const Bid&);
Bid& operator=(Bid&&);
// JSON string to be passed to the scoring function.
std::string ad;
// Offered bid value.
double bid;
// Render URL, if any bid was made.
GURL render_url;
// How long it took to run the script that generated the bid.
base::TimeDelta bid_duration;
};
// If no bid is generated, `bid` is null.
//
// `errors` contains error messages for debugging. This isn't guaranteed
// to be produced for all failures, so should not be checked to identify
// bidding failures errors. It's also possible for there to be an error
// message on success, in the case the trusted bidding signals failed to load
// - auctions will still be run without it, but `errors` will be populated
// with information about the load failure.
using LoadScriptAndGenerateBidCallback =
base::OnceCallback<void(base::Optional<Bid> bid,
const std::vector<std::string>& errors)>;
// `report_url` is the URL to request to report displaying the ad. It is
// nullopt on error or if report is requested. `errors` is a list of
// errors that occurred, if any. `errors` may be non-empty on success, or
// empty on failure.
using ReportWinCallback =
base::OnceCallback<void(const base::Optional<GURL>& report_url,
const std::vector<std::string>& errors)>;
// Starts loading the worklet script on construction, as well as the trusted
// bidding data, if necessary. Will then call the script's generateBid()
// function and invoke the callback with the results. Callback will always be
// invoked asynchronously, once a bid has been generated or a fatal error has
// occurred. Must be destroyed before `v8_helper`.
//
// Data is cached and will be reused ReportWin().
BidderWorklet(
AuctionV8Helper* v8_helper,
network::mojom::URLLoaderFactory* url_loader_factory,
mojom::BiddingInterestGroupPtr bidding_interest_group,
const base::Optional<std::string>& auction_signals_json,
const base::Optional<std::string>& per_buyer_signals_json,
const url::Origin& browser_signal_top_window_origin,
const url::Origin& browser_signal_seller_origin,
base::Time auction_start_time,
LoadScriptAndGenerateBidCallback load_script_and_generate_bid_callback);
explicit BidderWorklet(const BidderWorklet&) = delete;
BidderWorklet& operator=(const BidderWorklet&) = delete;
~BidderWorklet();
// Calls reportWin(), and asynchronously invokes `callback` with reporting
// information. May only be called once the worklet has successfully loaded.
void ReportWin(const std::string& seller_signals_json,
const GURL& browser_signal_render_url,
const std::string& browser_signal_ad_render_fingerprint,
double browser_signal_bid,
ReportWinCallback callback);
private:
void OnScriptDownloaded(
std::unique_ptr<v8::Global<v8::UnboundScript>> worklet_script,
base::Optional<std::string> error_msg);
void OnTrustedBiddingSignalsDownloaded(bool load_result,
base::Optional<std::string> error_msg);
// Checks if the script has been loaded successfully, and the
// TrustedBiddingSignals load has finished (successfully or not). If so, calls
// generateBid(), and invokes `load_script_and_generate_bid_callback_` with
// the resulting bid, if any. May only be called once BidderWorklet has
// successfully loaded.
void GenerateBidIfReady();
// Utility function to invoke `load_script_and_generate_bid_callback_` with
// `error_msg` and `trusted_bidding_signals_error_msg_`.
void InvokeBidCallbackOnError(
base::Optional<std::string> error_msg = base::nullopt);
AuctionV8Helper* const v8_helper_;
const GURL script_source_url_;
const mojom::BiddingInterestGroupPtr bidding_interest_group_;
LoadScriptAndGenerateBidCallback load_script_and_generate_bid_callback_;
const base::Optional<std::string> auction_signals_json_;
const base::Optional<std::string> per_buyer_signals_json_;
const std::string browser_signal_top_window_hostname_;
// Serialized copy of seller's origin.
const std::string browser_signal_seller_;
const base::Time auction_start_time_;
std::unique_ptr<WorkletLoader> worklet_loader_;
bool trusted_bidding_signals_loading_ = false;
std::unique_ptr<TrustedBiddingSignals> trusted_bidding_signals_;
// Error message returned by attempt to load `trusted_bidding_signals_`.
// Errors loading it are not fatal, so such errors are cached here and only
// reported on bid completion.
base::Optional<std::string> trusted_bidding_signals_error_msg_;
// Compiled script, not bound to any context. Can be repeatedly bound to
// different context and executed, without persisting any state.
std::unique_ptr<v8::Global<v8::UnboundScript>> worklet_script_;
};
} // namespace auction_worklet
#endif // CONTENT_SERVICES_AUCTION_WORKLET_BIDDER_WORKLET_H_
| [
"chromium-scoped@luci-project-accounts.iam.gserviceaccount.com"
] | chromium-scoped@luci-project-accounts.iam.gserviceaccount.com |
dc3bcf3d777eb231dde2f213ff62d82329a8c83f | 6023a96bb299017025bb9c4aa20bd373cd344f10 | /team_project/Arduino/아두이노 파이썬 시리얼 통신/Dustsensor/Dustsensor.ino | f4256379296f8d3edee379e33b99c32b81aaf5f1 | [] | no_license | bgu609/portfolio | 69250d928f1aee71a5d4eedcd297f76f44753a9b | 5b0ce5350862c0944c2234dbc8852093c1de2068 | refs/heads/master | 2022-12-10T09:35:14.168207 | 2020-09-15T14:12:51 | 2020-09-15T14:12:51 | 292,497,653 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,659 | ino |
/*
미세 먼지 센서 값 출력
http://www.devicemart.co.kr/
*/
// 미세 먼지 없을 때 초기 V 값 0.35
// 공기청정기 위 등에서 먼지를 가라앉힌 후 voltage값 개별적으로 측정 필요
#define no_dust 0.35
// 아두이노 - 미세 먼지 센서 연결
int dustout=A0;
int v_led=7;
// 센서로 읽은 값 변수 선언
float vo_value=0;
// 센서로 읽은 값을 전압으로 측정 변수
float sensor_voltage=0;
// 실제 미세 먼지 밀도 변수
float dust_density=0;
void setup()
{
Serial.begin(9600); // 통신 속도 9600bps로 시리얼 통신 시작
pinMode(v_led,OUTPUT); // 적외선 led 출력으로 설정
}
void loop()
{
// 미세 먼지 센서 동작
digitalWrite(v_led,LOW); // 적외선 LED ON
delayMicroseconds(280); // 280us동안 딜레이
vo_value=analogRead(dustout); // 데이터를 읽음
delayMicroseconds(40); // 320us - 280us
digitalWrite(v_led,HIGH); // 적외선 LED OFF
delayMicroseconds(9680); // 10ms(주기) -320us(펄스 폭) 한 값
sensor_voltage=get_voltage(vo_value);
dust_density=get_dust_density(sensor_voltage);
Serial.print("value = ");
Serial.println(vo_value);
Serial.print("Voltage = ");
Serial.print(sensor_voltage);
Serial.println(" [V]");
Serial.print("Dust Density = ");
Serial.print(dust_density);
Serial.println(" [ug/m^3]");
delay(1000);
}
float get_voltage(float value)
{
// 아날로그 값을 전압 값으로 바꿈
float V= value * 5.0 / 1024;
return V;
}
float get_dust_density(float voltage)
{
// 데이터 시트에 있는 미세 먼지 농도(ug) 공식 기준
float dust=(voltage-no_dust) / 0.005;
return dust;
}
| [
"giung609@naver.com"
] | giung609@naver.com |
73672dbc4ce5f83bf2bb60144b810c8cc547a2e3 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5631989306621952_1/C++/mati9977/5.cpp | ef19df2f906f3f7c132e4334b1a26d58fb13cf5d | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 665 | cpp | #include<bits/stdc++.h>
using namespace std;
ifstream goo;
ofstream gle;
string s;
deque<char> q;
void solve()
{
char c,a;
goo>>s;
for(int i=0; i<s.size(); i++)
{
c=s[i];
a=q.front();
if(c>=a) q.push_front(c);
else q.push_back(c);
}
while(!q.empty())
{
c=q.front();
gle<<c;
q.pop_front();
}
gle<<"\n";
return;
}
int main()
{
ios_base::sync_with_stdio(0);
goo.open("C:\\Users\\Mateusz\\Downloads\\A-large (1).in");
gle.open("C:\\Users\\Mateusz\\Desktop\\gle.out");
int t;
goo>>t;
for(int i=1; i<=t; i++)
{
gle<<"Case #"<<i<<": ";
solve();
}
goo.close();
gle.close();
return 0;
}
| [
"alexandra1.back@gmail.com"
] | alexandra1.back@gmail.com |
ff94191c7834bc6b8b77dde9efe6100a6469f992 | 4948988b8fef00b551021cbc74a7999aebb07c96 | /SfmlWithRoomManager/testSFGUI/BaseRoom.cpp | 5f45a1135d0998e2961e59a1308d62011cbcc05a | [] | no_license | killerloader/Random-Uni-Project | 7c2b3ca86295727480e073cd609b67420c815f32 | 9ac66d139904d8fa109f66df320dcd36aeefdc66 | refs/heads/master | 2021-01-21T13:52:35.168903 | 2016-05-13T01:05:02 | 2016-05-13T01:05:02 | 51,895,061 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 153 | cpp | #include "BaseRoom.h"
#include "RoomManager.h"
BaseRoom::BaseRoom(RoomManager& rmMngrRef) : m_roomManagerRef(rmMngrRef)
{
}
BaseRoom::~BaseRoom()
{
} | [
"heath.sargent@ad.aie.edu"
] | heath.sargent@ad.aie.edu |
23dc39760d2a8f75f2deca8365d3dc137dd9253a | d9961f5cf2c762698f3bcfdc465e17993d6a02dc | /src/physics/aabb.h | c119a5152dc55ed2f7e566eb6777d1f86bd52fc8 | [] | no_license | MisterMjirDeprecated/Platformer | b852133d5074715636bc3e96eae32c00c079252e | 0953fca912a829ba02b7e51501f08b1989d1dfe8 | refs/heads/master | 2022-06-14T22:43:36.939841 | 2022-05-30T17:27:17 | 2022-05-30T17:27:17 | 230,000,419 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 657 | h | #ifndef AABB_CLASS
#define AABB_CLASS
enum AABB_Type {COLLISIONBOX, HITBOX, HURTBOX};
class AABB
{
public:
AABB(int x, int y, int w, int h, AABB_Type, bool linked);
int xOverlap(AABB*);
int xDiff(AABB*);
int yOverlap(AABB*);
int yDiff(AABB*);
int getX() {return x;}
void changeX(int change) {x += change;}
int getY() {return y;}
void changeY(int change) {y += change;}
int getW() {return w;}
int getH() {return h;}
AABB_Type getType() {return type;}
bool isLinked() {return linked;}
private:
int x, y, w, h; // Coordinates and size
AABB_Type type; // Type of AABB
bool linked; // Is this linked to other AABBs
};
#endif
| [
"mihirsuks@gmail.com"
] | mihirsuks@gmail.com |
d5fe8ab0957c891bfca681b3782f87e22c5223ef | 8a9e7fd1b0a633c97e595f927513400f805aac12 | /torch/csrc/jit/frontend/inline_loop_condition.cpp | e7bf0071ce3c6ee77a1d69cf643d00d2ceccf0d7 | [
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | bertmaher/pytorch | 30337edaa93624164044de73ed67ade7819b3076 | 8cdb581dc2e1e566dd9a8fd084357e8e0c5bf5d7 | refs/heads/pytorch_fusion | 2023-08-29T17:57:42.968233 | 2021-09-08T15:13:25 | 2021-09-08T15:13:25 | 227,474,268 | 3 | 1 | NOASSERTION | 2022-05-26T03:09:04 | 2019-12-11T22:43:30 | C++ | UTF-8 | C++ | false | false | 1,759 | cpp | #include <functional>
#include <memory>
#include <string>
#include <torch/csrc/WindowsTorchApiMacro.h>
#include <torch/csrc/jit/ir/ir.h>
#include <torch/csrc/jit/frontend/inline_loop_condition.h>
namespace torch {
namespace jit {
void InlineBlockBeforeNode(Node* before_node, Block* block) {
for (auto it = block->nodes().begin(); it != block->nodes().end();) {
auto block_node = *it++;
block_node->moveBefore(before_node);
}
}
// The loop node is initially emitted as:
// Loop(max_trip_count)
// block0(loop_counter) {
// <body>
// }
// block1 {
// <loop condition>
// -> (condition)
// }
// Here, we inline the loop condition and convert the loop to the form:
// Loop(max_trip_count, start_condition)
// block0(loop_counter, loop_carried_block*) {
// <body>
// BlockExit(continue_condition, loop_carried_block*)
// }
void inlineLoopCondition(Node* n) {
Block* body_block = n->blocks().at(0);
auto pre_header = n->blocks().at(1);
auto temp_block = n->addBlock();
temp_block->cloneFrom(pre_header, [](Value* v) { return v; });
InlineBlockBeforeNode(n, temp_block);
n->insertInput(/*start_condition_index*/ 1, temp_block->outputs().at(0));
n->eraseBlock(2);
InlineBlockBeforeNode(body_block->return_node(), pre_header);
body_block->return_node()->insertInput(0, pre_header->outputs().at(0));
n->eraseBlock(1);
}
void inlineLoopCondition(Block* block) {
for (Node* n : block->nodes()) {
for (Block* b : n->blocks()) {
inlineLoopCondition(b);
}
if (n->kind() == prim::Loop) {
inlineLoopCondition(n);
}
}
}
void InlineLoopCondition(std::shared_ptr<Graph>& graph) {
inlineLoopCondition(graph->block());
}
} // namespace jit
} // namespace torch
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
24c877dfd6044c1088a7ae8cd40bff47a295cd74 | e105858441c694f7a3a62cee7d47613acff11df1 | /ScoreState.h | d11432a7a2e30f8def09e0fcd9c47a6ee4ce94db | [] | no_license | Sir-Tiffy/MIDI_Runner | 0b4e719b9f94608b6f9c39bf8a2b3c1153c75a27 | 3226da4f20e74c07bfc27d6ea229e8a210ceec84 | refs/heads/master | 2020-06-05T10:04:55.410514 | 2013-09-24T13:29:13 | 2013-09-24T13:29:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 727 | h | #pragma once
#include "StdAfx.h"
#include "State.h"
#include "MountainGen.h"
#include "ScoreClass.h"
class ScoreState:public State{
protected:
GLuint texture;
void Render(bool ignore);
private:
//vector<ScoreStruct> currentSongScores;
string currentSongName;
glm::mat4 projectionMatrix;
short selectedSongIndex;
unsigned char selectedButton;
MountainGen mountainLayer1, mountainLayer2;
public:
void Render() override;
void MouseButton(int button, int state) override;\
void MouseMove(float mousePosX, float mousePosY) override;
void Update(double,double) override;
void Begin(double currentTime) override;
ScoreState(string songName = "", ScoreStruct s = ScoreStruct(), bool newScore = false);
~ScoreState();
}; | [
"zeekyhb@gmail.com"
] | zeekyhb@gmail.com |
28f10babd774dc1a6c768520df667f6fff55572c | f0aec0646fac74546ea0a41ac30b65f96812811a | /src/spliced_aln/WordHitsGroup/main/group_wordHits_wordChunks/duplicateWords/main.cpp | e44ad49da2c2bd9d212ab75af411d59590890e09 | [] | no_license | ganyfml/olegosa2 | 5a283b1169dd5c161c74dd03e4429eef4e5561d1 | 0adb17a214e2e6904a1a08b52b26a1aaaebff6ec | refs/heads/master | 2020-04-06T07:09:08.655874 | 2016-08-21T15:57:36 | 2016-08-21T15:57:36 | 64,513,770 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 887 | cpp | // vim: set noexpandtab tabstop=3:
#include <list>
#include "../../../WordHitsGroup.hpp"
#include <spliced_aln/AlnSpliceOpt.hpp>
#include <seqan_api/SeqString.hpp>
using namespace std;
int main(int argc, char* argv[])
{
int group_id = 0;
WordHitsGroupPtr test_group = make_shared<WordHitsGroup>(group_id);
for(int i = 0; i < argc - 1; ++i)
{
int hit_wordID = atoi(argv[i+1]);
WordHitPtr hit = make_shared<WordHit>(hit_wordID);
hit->ref_pos = i + 1;
hit->query_pos= i;
test_group->wordhits.push_back(hit);
}
AlnSpliceOpt opt;
opt.wordChunk_max_diff = 100;
int num_words = 3;
test_group->group_wordHits_wordChunks(opt, num_words);
printf("wordchunk_id\thit_wordIDs\n");
for(WordHitsChunkPtr chunk: test_group->wordhitschunks)
{
printf("%d\t", chunk->id);
for(WordHitPtr hit: chunk->wordHitList)
{
printf("%d, ", hit->word_id);
}
printf("\n");
}
}
| [
"gany.fml@gmail.com"
] | gany.fml@gmail.com |
83f7506ab040641b41fd5ef13b4eb5faf2d1f386 | bcd8f5a7352a1e0b2e1a83fea9ae2e4182eda805 | /standard-cli/cpp-MspCliStepByStep/Demo10-BigBank/BankAccount.cpp | abbd2710a157ba11e40a242b90bdb8c8238b52d0 | [] | no_license | JediChou/jedichou-study-algo | 455c7709250d424cad1b326efd99f0be7a000edc | 4f0ce79556d7543870dfc13399c7ae85ba773508 | refs/heads/master | 2020-06-24T23:21:34.310122 | 2020-04-01T05:53:33 | 2020-04-01T05:53:33 | 199,122,658 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 320 | cpp | using namespace System;
#include "BankAccount.h"
BankAccount::BankAccount(String^ holder)
: acountHolder(holder), balance(0)
{
}
void BankAccount::Credit(double amount) { balance += amount; }
void BankAccount::Debit(double amount) { balance -= amount; }
double BankAccount::GetBalance() { return balance; } | [
"jedigit@163.com"
] | jedigit@163.com |
f1b7f34b83259501b0a4ee978d6167fe48c1a06f | b24759bb01b002d42d51c93cb8f02eb681ca1542 | /src/LibKopul/KPLC++/srcs/Bitfield.cpp | 2dccb3234cf3bdc4f87a3cb4d2a79d3699832abf | [] | no_license | LionelAuroux/kopul | 272745e6343bf8ca4db73eff76df08c2fab2600b | dc169ca347878e3d11b84371a734acf10230ff4f | refs/heads/master | 2020-12-24T15:58:07.863503 | 2011-12-28T10:37:44 | 2011-12-28T10:37:44 | 32,329,849 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,781 | cpp | #include <sstream>
#include "Bitfield.h"
using namespace kpl;
Bitfield::Bitfield(int size)
{
std::ostringstream oss;
_size = size;
_objectType = "Bitfield";
oss << _size;
_objectToStr = _objectType + oss.str();
}
Bitfield::Bitfield(const Bitfield& bit)
{
_size = bit._size;
_objectType = bit._objectType;
_objectToStr = bit._objectToStr;
}
Bitfield::~Bitfield()
{
}
Bitfield& Bitfield::operator = (const Bitfield& bit)
{
this->_size = bit._size;
this->_objectType = bit._objectType;
this->_objectToStr = bit._objectToStr;
return (*this);
}
int Bitfield::GetSize() const
{
return (this->_size);
}
int Bitfield::GetSizeInOctet() const
{
if (this->_size % 8 > 0)
return (this->_size / 8 + 1);
return (this->_size / 8);
}
void Bitfield::SetSize(int size)
{
std::ostringstream oss;
this->_size = size;
oss << this->_size;
this->_objectToStr = this->_objectType + oss.str();
}
// Get a string representation of the object
const std::string& Bitfield::ToString() const
{
return (this->_objectToStr);
}
// Get the type of the object
const std::string& Bitfield::GetType() const
{
return (this->_objectType);
}
// returns true if the given type and content are equal.
bool Bitfield::Equals(const IObject &value) const
{
if (this->GetType() == value.GetType())
{
if (this->_size == reinterpret_cast<const Bitfield&>(value)._size)
return (true);
}
return (false);
}
// create a new instance by making a deep copy of the current object data
IObject* Bitfield::Clone() const
{
return (new Bitfield(*this));
}
| [
"sebastien.deveza@39133846-08c2-f29e-502e-0a4191c0ae44"
] | sebastien.deveza@39133846-08c2-f29e-502e-0a4191c0ae44 |
a604a174130852de78182e89604d623d1c100f3c | 38628b46e14b158348044c28722e7a1fb612d081 | /BinarySearch.hpp | 69a8e36491f230a484e5749a06e30ed2886d7d5d | [] | no_license | kurmasz-assignments/cis263-binarySearch | 1f1b241903ce3ba43ed1c5fb6f62998d5db36540 | df3abb1f6a352fc45a5484cd4e0034c19e19eee6 | refs/heads/master | 2020-07-07T03:28:13.410910 | 2019-08-28T15:15:20 | 2019-08-28T15:15:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 650 | hpp | //
// Created by Zachary Kurmas on 2019-08-19.
//
#include <vector>
#define NOT_FOUND -1
/**
* Performs the standard binary search using two comparisons per level.
* Returns index where item is found or -1 if not found.
*/
template <typename Comparable>
int binarySearch( const std::vector <Comparable> & a, const Comparable & x )
{
int low=0;
int high= a.size( ) - 1;
while( low <= high ) {
int mid=(low + high ) / 2;
if( a[mid]<x) {
low = mid+ 1;
} else if( a[ mid ]>x) {
high = mid - 1;
} else {
return mid;
}
}
return NOT_FOUND; // NOT_FOUND defined as -1
}
| [
"kurmasz@users.noreply.github.com"
] | kurmasz@users.noreply.github.com |
c00397abe05436dc9bf6521c190539b274191884 | 91a882547e393d4c4946a6c2c99186b5f72122dd | /Source/XPSP1/NT/net/irda/irprops/debug.cpp | 0a5596e587c20c6560a42e4368a1aa5fdd461988 | [] | no_license | IAmAnubhavSaini/cryptoAlgorithm-nt5src | 94f9b46f101b983954ac6e453d0cf8d02aa76fc7 | d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2 | refs/heads/master | 2023-09-02T10:14:14.795579 | 2021-11-20T13:47:06 | 2021-11-20T13:47:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 875 | cpp | /*******************************************************************************
*
* (C) COPYRIGHT MICROSOFT CORP., 1993-1995
* TITLE: DEBUG.CPP
* VERSION: 1.0
* AUTHOR: jsenior
* DATE: 10/28/1998
*
********************************************************************************
*
* CHANGE LOG:
*
* DATE REV DESCRIPTION
* ---------- ------- ----------------------------------------------------------
* 10/28/1998 jsenior Original implementation.
*
*******************************************************************************/
#include "precomp.hxx"
#include "debug.h"
#if DBG
ULONG IRDA_Debug_Trace_Level = LWARN;
#endif // DBG
void TRACE(LPCTSTR Format, ...)
{
va_list arglist;
va_start(arglist, Format);
TCHAR buf[200];
wvsprintf(buf, Format, arglist);
OutputDebugString(buf);
va_end(arglist);
}
| [
"support@cryptoalgo.cf"
] | support@cryptoalgo.cf |
7736df8b9e307a5bffa1076d2745a0453ee435b1 | dd6fee79066e2dfa74371bd82c87a563dc0c47fd | /OJ/CDOJ/给兄贵的对跑.cpp | b40f93a7ec740958a08855c7c694c6f81e6aed2e | [] | no_license | mzry1992/workspace | 404c31df66a3b15a60dc0f07fff397bf50bcc1dc | 9a181419f0d7224e37baa729feaf3bb656544420 | refs/heads/master | 2021-01-19T12:39:17.854501 | 2012-12-24T11:13:22 | 2012-12-24T11:13:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,244 | cpp | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
char x[1000];
double l,r,mid,y,ty,base;
const double eps = 1e-9;
int main()
{
freopen("1.in","r",stdin);
freopen("2.out","w",stdout);
int t;
scanf("%d",&t);
for (int ft = 1;ft <= t;ft++)
{
scanf("%s",x);
scanf("%lf",&y);
if (y == 1.0)
if (x[strlen(x)-1] == '1')
{
int i;
for (i = 0;i < strlen(x);i++)
if (x[i] == '1') break;
if (i < strlen(x)-1) puts("-1");
else
puts("-2");
continue;
}
l = 0.0; r = 1000.0;
while (fabs(l-r) > eps)
{
mid = (l+r)/2.0;
ty = 0.0;
base = 1.0;
for (int i = strlen(x)-1;i >= 0;i--)
{
ty += (x[i]-'0')*base;
base *= mid;
}
if (ty > y) r = mid;
else
l = mid;
}
if (fabs(l) < eps) puts("-1");
else if (fabs(l-1000.0) < eps) puts("-1");
else
printf("%.7lf\n",l);
}
}
| [
"muziriyun@gmail.com"
] | muziriyun@gmail.com |
9530376aaa34db6d777f25864f24588cf8958f58 | 6d77e738c66bdf8809e47ad9be85f9c7361a1bd9 | /src/server/database/Database/PreparedStatement.cpp | 0f5a9fbbf9ceffe2bec0e53f1db56613e07a2edc | [] | no_license | Ramys/Hooaahcore | e768e8b8a2b2c1dba7501495161cf6c0419b9de2 | dad11ee863d34a9f02186936b1dbbca168912ecd | refs/heads/main | 2023-02-27T16:18:27.916812 | 2021-02-07T23:38:52 | 2021-02-07T23:38:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,993 | cpp | /*
* Copyright (C) 2021 Hooaahcore
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PreparedStatement.h"
#include "Errors.h"
#include "MySQLConnection.h"
#include "MySQLPreparedStatement.h"
#include "QueryResult.h"
#include "Log.h"
#include "MySQLWorkaround.h"
PreparedStatementBase::PreparedStatementBase(uint32 index, uint8 capacity) :
m_stmt(nullptr), m_index(index), statement_data(capacity) { }
PreparedStatementBase::~PreparedStatementBase() { }
void PreparedStatementBase::BindParameters(MySQLPreparedStatement* stmt)
{
ASSERT(stmt);
m_stmt = stmt;
uint8 i = 0;
for (; i < statement_data.size(); i++)
{
switch (statement_data[i].type)
{
case TYPE_BOOL:
stmt->setBool(i, statement_data[i].data.boolean);
break;
case TYPE_UI8:
stmt->setUInt8(i, statement_data[i].data.ui8);
break;
case TYPE_UI16:
stmt->setUInt16(i, statement_data[i].data.ui16);
break;
case TYPE_UI32:
stmt->setUInt32(i, statement_data[i].data.ui32);
break;
case TYPE_I8:
stmt->setInt8(i, statement_data[i].data.i8);
break;
case TYPE_I16:
stmt->setInt16(i, statement_data[i].data.i16);
break;
case TYPE_I32:
stmt->setInt32(i, statement_data[i].data.i32);
break;
case TYPE_UI64:
stmt->setUInt64(i, statement_data[i].data.ui64);
break;
case TYPE_I64:
stmt->setInt64(i, statement_data[i].data.i64);
break;
case TYPE_FLOAT:
stmt->setFloat(i, statement_data[i].data.f);
break;
case TYPE_DOUBLE:
stmt->setDouble(i, statement_data[i].data.d);
break;
case TYPE_STRING:
stmt->setBinary(i, statement_data[i].binary, true);
break;
case TYPE_BINARY:
stmt->setBinary(i, statement_data[i].binary, false);
break;
case TYPE_NULL:
stmt->setNull(i);
break;
}
}
#ifdef _DEBUG
if (i < stmt->m_paramCount)
TC_LOG_WARN("sql.sql", "[WARNING]: BindParameters() for statement %u did not bind all allocated parameters", m_index);
#endif
}
//- Bind to buffer
void PreparedStatementBase::setBool(const uint8 index, const bool value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.boolean = value;
statement_data[index].type = TYPE_BOOL;
}
void PreparedStatementBase::setUInt8(const uint8 index, const uint8 value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.ui8 = value;
statement_data[index].type = TYPE_UI8;
}
void PreparedStatementBase::setUInt16(const uint8 index, const uint16 value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.ui16 = value;
statement_data[index].type = TYPE_UI16;
}
void PreparedStatementBase::setUInt32(const uint8 index, const uint32 value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.ui32 = value;
statement_data[index].type = TYPE_UI32;
}
void PreparedStatementBase::setUInt64(const uint8 index, const uint64 value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.ui64 = value;
statement_data[index].type = TYPE_UI64;
}
void PreparedStatementBase::setInt8(const uint8 index, const int8 value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.i8 = value;
statement_data[index].type = TYPE_I8;
}
void PreparedStatementBase::setInt16(const uint8 index, const int16 value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.i16 = value;
statement_data[index].type = TYPE_I16;
}
void PreparedStatementBase::setInt32(const uint8 index, const int32 value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.i32 = value;
statement_data[index].type = TYPE_I32;
}
void PreparedStatementBase::setInt64(const uint8 index, const int64 value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.i64 = value;
statement_data[index].type = TYPE_I64;
}
void PreparedStatementBase::setFloat(const uint8 index, const float value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.f = value;
statement_data[index].type = TYPE_FLOAT;
}
void PreparedStatementBase::setDouble(const uint8 index, const double value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.d = value;
statement_data[index].type = TYPE_DOUBLE;
}
void PreparedStatementBase::setString(const uint8 index, const std::string& value)
{
ASSERT(index < statement_data.size());
statement_data[index].binary.resize(value.length() + 1);
memcpy(statement_data[index].binary.data(), value.c_str(), value.length() + 1);
statement_data[index].type = TYPE_STRING;
}
void PreparedStatementBase::setBinary(const uint8 index, const std::vector<uint8>& value)
{
ASSERT(index < statement_data.size());
statement_data[index].binary = value;
statement_data[index].type = TYPE_BINARY;
}
void PreparedStatementBase::setNull(const uint8 index)
{
ASSERT(index < statement_data.size());
statement_data[index].type = TYPE_NULL;
}
//- Execution
PreparedStatementTask::PreparedStatementTask(PreparedStatementBase* stmt, bool async) :
m_stmt(stmt), m_result(nullptr)
{
m_has_result = async; // If it's async, then there's a result
if (async)
m_result = new PreparedQueryResultPromise();
}
PreparedStatementTask::~PreparedStatementTask()
{
delete m_stmt;
if (m_has_result && m_result != nullptr)
delete m_result;
}
bool PreparedStatementTask::Execute()
{
if (m_has_result)
{
PreparedResultSet* result = m_conn->Query(m_stmt);
if (!result || !result->GetRowCount())
{
delete result;
m_result->set_value(PreparedQueryResult(nullptr));
return false;
}
m_result->set_value(PreparedQueryResult(result));
return true;
}
return m_conn->Execute(m_stmt);
}
| [
"43292003+Hooaah@users.noreply.github.com"
] | 43292003+Hooaah@users.noreply.github.com |
f07533ae776cf40f35e63998ef11c66513665e03 | 3466fed1c64ab775d7ce9a9562b986a1ceb7ba98 | /embedded-firmware/src/GraphicsManager.cpp | d2d29736e9473c3c90c6159beece52ffca94b52e | [] | no_license | ECE493W18T04/android-app | 0961d56f0759662c48c3686d04d3a0a6ab820236 | b054194c9b58b2ce33f4be2bd828c0b53d8e314f | refs/heads/master | 2021-05-01T12:08:51.735740 | 2018-07-19T21:12:08 | 2018-07-19T21:12:08 | 121,058,596 | 0 | 0 | null | 2018-03-16T21:29:14 | 2018-02-10T22:08:12 | Java | UTF-8 | C++ | false | false | 12,536 | cpp | #include "GraphicsManager.h"
#define SPI_SPEED 2000000 // 2MHz
#define RGB_MASK 0x00FFFFFF
#define PIXEL_OFF 0xFF000000
// font from https://github.com/adafruit/Adafruit-GFX-Library/blob/master/glcdfont.c
static const unsigned char font[] = {
0x00, 0x00, 0x00, 0x00, 0x00,
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
0x18, 0x3C, 0x7E, 0x3C, 0x18,
0x1C, 0x57, 0x7D, 0x57, 0x1C,
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
0x00, 0x18, 0x3C, 0x18, 0x00,
0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
0x00, 0x18, 0x24, 0x18, 0x00,
0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
0x30, 0x48, 0x3A, 0x06, 0x0E,
0x26, 0x29, 0x79, 0x29, 0x26,
0x40, 0x7F, 0x05, 0x05, 0x07,
0x40, 0x7F, 0x05, 0x25, 0x3F,
0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
0x7F, 0x3E, 0x1C, 0x1C, 0x08,
0x08, 0x1C, 0x1C, 0x3E, 0x7F,
0x14, 0x22, 0x7F, 0x22, 0x14,
0x5F, 0x5F, 0x00, 0x5F, 0x5F,
0x06, 0x09, 0x7F, 0x01, 0x7F,
0x00, 0x66, 0x89, 0x95, 0x6A,
0x60, 0x60, 0x60, 0x60, 0x60,
0x94, 0xA2, 0xFF, 0xA2, 0x94,
0x08, 0x04, 0x7E, 0x04, 0x08,
0x10, 0x20, 0x7E, 0x20, 0x10,
0x08, 0x08, 0x2A, 0x1C, 0x08,
0x08, 0x1C, 0x2A, 0x08, 0x08,
0x1E, 0x10, 0x10, 0x10, 0x10,
0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
0x30, 0x38, 0x3E, 0x38, 0x30,
0x06, 0x0E, 0x3E, 0x0E, 0x06,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x5F, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07, 0x00,
0x14, 0x7F, 0x14, 0x7F, 0x14,
0x24, 0x2A, 0x7F, 0x2A, 0x12,
0x23, 0x13, 0x08, 0x64, 0x62,
0x36, 0x49, 0x56, 0x20, 0x50,
0x00, 0x08, 0x07, 0x03, 0x00,
0x00, 0x1C, 0x22, 0x41, 0x00,
0x00, 0x41, 0x22, 0x1C, 0x00,
0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
0x08, 0x08, 0x3E, 0x08, 0x08,
0x00, 0x80, 0x70, 0x30, 0x00,
0x08, 0x08, 0x08, 0x08, 0x08,
0x00, 0x00, 0x60, 0x60, 0x00,
0x20, 0x10, 0x08, 0x04, 0x02,
0x3E, 0x51, 0x49, 0x45, 0x3E,
0x00, 0x42, 0x7F, 0x40, 0x00,
0x72, 0x49, 0x49, 0x49, 0x46,
0x21, 0x41, 0x49, 0x4D, 0x33,
0x18, 0x14, 0x12, 0x7F, 0x10,
0x27, 0x45, 0x45, 0x45, 0x39,
0x3C, 0x4A, 0x49, 0x49, 0x31,
0x41, 0x21, 0x11, 0x09, 0x07,
0x36, 0x49, 0x49, 0x49, 0x36,
0x46, 0x49, 0x49, 0x29, 0x1E,
0x00, 0x00, 0x14, 0x00, 0x00,
0x00, 0x40, 0x34, 0x00, 0x00,
0x00, 0x08, 0x14, 0x22, 0x41,
0x14, 0x14, 0x14, 0x14, 0x14,
0x00, 0x41, 0x22, 0x14, 0x08,
0x02, 0x01, 0x59, 0x09, 0x06,
0x3E, 0x41, 0x5D, 0x59, 0x4E,
0x7C, 0x12, 0x11, 0x12, 0x7C,
0x7F, 0x49, 0x49, 0x49, 0x36,
0x3E, 0x41, 0x41, 0x41, 0x22,
0x7F, 0x41, 0x41, 0x41, 0x3E,
0x7F, 0x49, 0x49, 0x49, 0x41,
0x7F, 0x09, 0x09, 0x09, 0x01,
0x3E, 0x41, 0x41, 0x51, 0x73,
0x7F, 0x08, 0x08, 0x08, 0x7F,
0x00, 0x41, 0x7F, 0x41, 0x00,
0x20, 0x40, 0x41, 0x3F, 0x01,
0x7F, 0x08, 0x14, 0x22, 0x41,
0x7F, 0x40, 0x40, 0x40, 0x40,
0x7F, 0x02, 0x1C, 0x02, 0x7F,
0x7F, 0x04, 0x08, 0x10, 0x7F,
0x3E, 0x41, 0x41, 0x41, 0x3E,
0x7F, 0x09, 0x09, 0x09, 0x06,
0x3E, 0x41, 0x51, 0x21, 0x5E,
0x7F, 0x09, 0x19, 0x29, 0x46,
0x26, 0x49, 0x49, 0x49, 0x32,
0x03, 0x01, 0x7F, 0x01, 0x03,
0x3F, 0x40, 0x40, 0x40, 0x3F,
0x1F, 0x20, 0x40, 0x20, 0x1F,
0x3F, 0x40, 0x38, 0x40, 0x3F,
0x63, 0x14, 0x08, 0x14, 0x63,
0x03, 0x04, 0x78, 0x04, 0x03,
0x61, 0x59, 0x49, 0x4D, 0x43,
0x00, 0x7F, 0x41, 0x41, 0x41,
0x02, 0x04, 0x08, 0x10, 0x20,
0x00, 0x41, 0x41, 0x41, 0x7F,
0x04, 0x02, 0x01, 0x02, 0x04,
0x40, 0x40, 0x40, 0x40, 0x40,
0x00, 0x03, 0x07, 0x08, 0x00,
0x20, 0x54, 0x54, 0x78, 0x40,
0x7F, 0x28, 0x44, 0x44, 0x38,
0x38, 0x44, 0x44, 0x44, 0x28,
0x38, 0x44, 0x44, 0x28, 0x7F,
0x38, 0x54, 0x54, 0x54, 0x18,
0x00, 0x08, 0x7E, 0x09, 0x02,
0x18, 0xA4, 0xA4, 0x9C, 0x78,
0x7F, 0x08, 0x04, 0x04, 0x78,
0x00, 0x44, 0x7D, 0x40, 0x00,
0x20, 0x40, 0x40, 0x3D, 0x00,
0x7F, 0x10, 0x28, 0x44, 0x00,
0x00, 0x41, 0x7F, 0x40, 0x00,
0x7C, 0x04, 0x78, 0x04, 0x78,
0x7C, 0x08, 0x04, 0x04, 0x78,
0x38, 0x44, 0x44, 0x44, 0x38,
0xFC, 0x18, 0x24, 0x24, 0x18,
0x18, 0x24, 0x24, 0x18, 0xFC,
0x7C, 0x08, 0x04, 0x04, 0x08,
0x48, 0x54, 0x54, 0x54, 0x24,
0x04, 0x04, 0x3F, 0x44, 0x24,
0x3C, 0x40, 0x40, 0x20, 0x7C,
0x1C, 0x20, 0x40, 0x20, 0x1C,
0x3C, 0x40, 0x30, 0x40, 0x3C,
0x44, 0x28, 0x10, 0x28, 0x44,
0x4C, 0x90, 0x90, 0x90, 0x7C,
0x44, 0x64, 0x54, 0x4C, 0x44,
0x00, 0x08, 0x36, 0x41, 0x00,
0x00, 0x00, 0x77, 0x00, 0x00,
0x00, 0x41, 0x36, 0x08, 0x00,
0x02, 0x01, 0x02, 0x04, 0x02,
0x3C, 0x26, 0x23, 0x26, 0x3C,
0x1E, 0xA1, 0xA1, 0x61, 0x12,
0x3A, 0x40, 0x40, 0x20, 0x7A,
0x38, 0x54, 0x54, 0x55, 0x59,
0x21, 0x55, 0x55, 0x79, 0x41,
0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut
0x21, 0x55, 0x54, 0x78, 0x40,
0x20, 0x54, 0x55, 0x79, 0x40,
0x0C, 0x1E, 0x52, 0x72, 0x12,
0x39, 0x55, 0x55, 0x55, 0x59,
0x39, 0x54, 0x54, 0x54, 0x59,
0x39, 0x55, 0x54, 0x54, 0x58,
0x00, 0x00, 0x45, 0x7C, 0x41,
0x00, 0x02, 0x45, 0x7D, 0x42,
0x00, 0x01, 0x45, 0x7C, 0x40,
0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut
0xF0, 0x28, 0x25, 0x28, 0xF0,
0x7C, 0x54, 0x55, 0x45, 0x00,
0x20, 0x54, 0x54, 0x7C, 0x54,
0x7C, 0x0A, 0x09, 0x7F, 0x49,
0x32, 0x49, 0x49, 0x49, 0x32,
0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut
0x32, 0x4A, 0x48, 0x48, 0x30,
0x3A, 0x41, 0x41, 0x21, 0x7A,
0x3A, 0x42, 0x40, 0x20, 0x78,
0x00, 0x9D, 0xA0, 0xA0, 0x7D,
0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut
0x3D, 0x40, 0x40, 0x40, 0x3D,
0x3C, 0x24, 0xFF, 0x24, 0x24,
0x48, 0x7E, 0x49, 0x43, 0x66,
0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
0xFF, 0x09, 0x29, 0xF6, 0x20,
0xC0, 0x88, 0x7E, 0x09, 0x03,
0x20, 0x54, 0x54, 0x79, 0x41,
0x00, 0x00, 0x44, 0x7D, 0x41,
0x30, 0x48, 0x48, 0x4A, 0x32,
0x38, 0x40, 0x40, 0x22, 0x7A,
0x00, 0x7A, 0x0A, 0x0A, 0x72,
0x7D, 0x0D, 0x19, 0x31, 0x7D,
0x26, 0x29, 0x29, 0x2F, 0x28,
0x26, 0x29, 0x29, 0x29, 0x26,
0x30, 0x48, 0x4D, 0x40, 0x20,
0x38, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x38,
0x2F, 0x10, 0xC8, 0xAC, 0xBA,
0x2F, 0x10, 0x28, 0x34, 0xFA,
0x00, 0x00, 0x7B, 0x00, 0x00,
0x08, 0x14, 0x2A, 0x14, 0x22,
0x22, 0x14, 0x2A, 0x14, 0x08,
0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code
0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block
0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block
0x00, 0x00, 0x00, 0xFF, 0x00,
0x10, 0x10, 0x10, 0xFF, 0x00,
0x14, 0x14, 0x14, 0xFF, 0x00,
0x10, 0x10, 0xFF, 0x00, 0xFF,
0x10, 0x10, 0xF0, 0x10, 0xF0,
0x14, 0x14, 0x14, 0xFC, 0x00,
0x14, 0x14, 0xF7, 0x00, 0xFF,
0x00, 0x00, 0xFF, 0x00, 0xFF,
0x14, 0x14, 0xF4, 0x04, 0xFC,
0x14, 0x14, 0x17, 0x10, 0x1F,
0x10, 0x10, 0x1F, 0x10, 0x1F,
0x14, 0x14, 0x14, 0x1F, 0x00,
0x10, 0x10, 0x10, 0xF0, 0x00,
0x00, 0x00, 0x00, 0x1F, 0x10,
0x10, 0x10, 0x10, 0x1F, 0x10,
0x10, 0x10, 0x10, 0xF0, 0x10,
0x00, 0x00, 0x00, 0xFF, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0xFF, 0x10,
0x00, 0x00, 0x00, 0xFF, 0x14,
0x00, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0x00, 0x1F, 0x10, 0x17,
0x00, 0x00, 0xFC, 0x04, 0xF4,
0x14, 0x14, 0x17, 0x10, 0x17,
0x14, 0x14, 0xF4, 0x04, 0xF4,
0x00, 0x00, 0xFF, 0x00, 0xF7,
0x14, 0x14, 0x14, 0x14, 0x14,
0x14, 0x14, 0xF7, 0x00, 0xF7,
0x14, 0x14, 0x14, 0x17, 0x14,
0x10, 0x10, 0x1F, 0x10, 0x1F,
0x14, 0x14, 0x14, 0xF4, 0x14,
0x10, 0x10, 0xF0, 0x10, 0xF0,
0x00, 0x00, 0x1F, 0x10, 0x1F,
0x00, 0x00, 0x00, 0x1F, 0x14,
0x00, 0x00, 0x00, 0xFC, 0x14,
0x00, 0x00, 0xF0, 0x10, 0xF0,
0x10, 0x10, 0xFF, 0x10, 0xFF,
0x14, 0x14, 0x14, 0xFF, 0x14,
0x10, 0x10, 0x10, 0x1F, 0x00,
0x00, 0x00, 0x00, 0xF0, 0x10,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
0xFF, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0xFF,
0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
0x38, 0x44, 0x44, 0x38, 0x44,
0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta
0x7E, 0x02, 0x02, 0x06, 0x06,
0x02, 0x7E, 0x02, 0x7E, 0x02,
0x63, 0x55, 0x49, 0x41, 0x63,
0x38, 0x44, 0x44, 0x3C, 0x04,
0x40, 0x7E, 0x20, 0x1E, 0x20,
0x06, 0x02, 0x7E, 0x02, 0x02,
0x99, 0xA5, 0xE7, 0xA5, 0x99,
0x1C, 0x2A, 0x49, 0x2A, 0x1C,
0x4C, 0x72, 0x01, 0x72, 0x4C,
0x30, 0x4A, 0x4D, 0x4D, 0x30,
0x30, 0x48, 0x78, 0x48, 0x30,
0xBC, 0x62, 0x5A, 0x46, 0x3D,
0x3E, 0x49, 0x49, 0x49, 0x00,
0x7E, 0x01, 0x01, 0x01, 0x7E,
0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
0x44, 0x44, 0x5F, 0x44, 0x44,
0x40, 0x51, 0x4A, 0x44, 0x40,
0x40, 0x44, 0x4A, 0x51, 0x40,
0x00, 0x00, 0xFF, 0x01, 0x03,
0xE0, 0x80, 0xFF, 0x00, 0x00,
0x08, 0x08, 0x6B, 0x6B, 0x08,
0x36, 0x12, 0x36, 0x24, 0x36,
0x06, 0x0F, 0x09, 0x0F, 0x06,
0x00, 0x00, 0x18, 0x18, 0x00,
0x00, 0x00, 0x10, 0x10, 0x00,
0x30, 0x40, 0xFF, 0x01, 0x01,
0x00, 0x1F, 0x01, 0x01, 0x1E,
0x00, 0x19, 0x1D, 0x17, 0x12,
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP
};
GraphicsManager::GraphicsManager(EventQueue& _eventQueue) : driver(SPI_PSELMOSI0, SPI_PSELMISO0, SPI_PSELSCK0, SPI_SPEED, _eventQueue) {
driver.setBuffer(DISPLAY_WIDTH, DISPLAY_HEIGHT, buffer);
erase();
drawBuffer();
// testing
setColor(0, 0);
flipped = 0;
}
void GraphicsManager::setPixel(uint16_t x, uint16_t y) {
if (x >= DISPLAY_WIDTH || y >= DISPLAY_HEIGHT) return;
buffer[x*DISPLAY_HEIGHT + y] = 1;
}
void GraphicsManager::clearPixel(uint16_t x, uint16_t y) {
if (x >= DISPLAY_WIDTH || y >= DISPLAY_HEIGHT) return;
buffer[x*DISPLAY_HEIGHT + y] = 0;
}
void GraphicsManager::erase() {
memset(buffer, 0, sizeof(buffer));
}
void GraphicsManager::fill(uint8_t x, uint8_t y, uint8_t width, uint8_t height) {
for (int dx = x; dx < x + width; dx++) {
for (int dy = y; dy < y + height; dy++) {
setPixel(dx, dy);
}
}
}
int GraphicsManager::placeText(char text[], int horizontalOffset) {
for (uint16_t i = 0; i < strlen(text); i++) {
drawChar(text[i], horizontalOffset);
horizontalOffset += CHARACTER_WIDTH + 1;
}
return horizontalOffset;
}
void GraphicsManager::drawChar(char c, int start) {
for (int x = 0; x < CHARACTER_WIDTH; x++) {
uint8_t character = getCharByte(c, x);
for (int y = 0; y < CHARACTER_HEIGHT; y++) {
int dx = x + start;
int dy;
if (flipped) {
dy = y + 1;
} else {
dy = CHARACTER_HEIGHT - y - 1;
}
if ((character >> y) & 0x01) {
setPixel(dx, dy);
} else {
clearPixel(dx, dy);
}
}
}
}
uint8_t GraphicsManager::getCharByte(char c, uint8_t offset) {
return font[c*CHARACTER_WIDTH + offset];
}
void GraphicsManager::eraseSection(uint8_t x, uint8_t y, uint8_t width, uint8_t height) {
for (int dx = x; dx < x + width; dx++) {
for (int dy = y; dy < y + height; dy++) {
clearPixel(dx, dy);
}
}
}
void GraphicsManager::drawBitmap(const uint8_t bitmap[], uint8_t x, uint8_t y, uint8_t width, uint8_t length) {
uint16_t index = 0;
int bitIndex = 7;
for (int j = 0; j < length; j++) {
for (int i = 0; i < width; i++) {
int dx = i + x;
int dy;
if (flipped) {
dy = j + y;
} else {
dy = CHARACTER_HEIGHT - (j + y);
}
if ((bitmap[index] >> bitIndex) & 1) {
setPixel(dx, dy);
} else {
clearPixel(dx, dy);
}
bitIndex--;
if (bitIndex < 0) {
bitIndex = 7;
index++;
}
}
index++;
bitIndex = 7;
}
}
void GraphicsManager::setColor(uint16_t _hue, uint8_t _sat) {
hue = _hue;
sat = _sat;
}
void GraphicsManager::drawBuffer() {
uint32_t updatedColor = driver.getColor(hue, sat);
for (uint16_t i = 0; i < DISPLAY_WIDTH*DISPLAY_HEIGHT; i++) {
if (buffer[i] & RGB_MASK) {
buffer[i] = updatedColor;
} else {
buffer[i] = PIXEL_OFF;
}
}
driver.draw();
}
void GraphicsManager::setBrightnessConfig(uint8_t brightness) {
driver.setBrightnessConfig(brightness);
}
void GraphicsManager::setMaxCurrent(uint16_t current) {
driver.setMaxCurrent(current);
}
| [
"curtis@malainey.com"
] | curtis@malainey.com |
61ad99ca1c614d52649a49e27a543cebb2895009 | fbbf1879c937e831e4261112523a46144db9188a | /src/game/misc/luautil.cpp | 6ef4fda2f0a9e51fa5a676bdf5fb76636adafe1c | [] | no_license | TZer0/untitledproject2 | be0a43d1ac46d7c3b42269a608d1d8a436a5f108 | 763b487d025b03a99341728d95f3d51d03d13be1 | refs/heads/master | 2021-01-22T09:16:51.634345 | 2009-12-24T15:28:22 | 2009-12-24T15:28:22 | 32,141,069 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21 | cpp | #include "luautil.h"
| [
"TZer0.jan@gmail.com"
] | TZer0.jan@gmail.com |
f2d158cad5e9adc1a95e4fa98f2d17c860c8ce26 | 821b5f68948f6c4e8e7b52c10bab23b1b093239b | /0800 - 1299/Akash/24 Amusing Joke.cpp | 8117c6b9137545d2a7c6ca9e181d4516c9e07409 | [] | no_license | sukhpreet-singh1/A2OJ-Practice | 3ec23a778f396ee36731d8731851fed5326f0aaf | 3b860262b48493b49131a7b8c5f09bbda348aef5 | refs/heads/main | 2023-03-19T15:33:07.318856 | 2021-03-06T17:26:21 | 2021-03-06T17:26:21 | 343,477,439 | 2 | 0 | null | 2021-03-01T16:12:12 | 2021-03-01T16:12:11 | null | UTF-8 | C++ | false | false | 334 | cpp | //24 Amusing Joke
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(true);
cin.tie(NULL);
cout.tie(NULL);
string guest,res,pile;
cin>>guest>>res>>pile;
guest += res;
sort(guest.begin(),guest.end());
sort(pile.begin(),pile.end());
if(guest == pile)
cout<<"YES";
else
cout<<"NO";
return 0;
}
| [
"aakashrajak02@gmail.com"
] | aakashrajak02@gmail.com |
0bb88bc6b61d8169a5cd3a93663ca17631cb0cec | 2978305c06ff23d966a9643149746a00493ffc26 | /static_encoding.h | 2624dc1b7856aefcf9c6afa9026789162cbb9c1f | [] | no_license | PetrFlajsingr/kko_grayscale_compression | 60ab524b5ec62b8bbc77e959fd26cd3a3c6a2cb9 | 72e13f436024f1c00312a7dad1faec695b95750f | refs/heads/master | 2023-04-09T23:15:01.864988 | 2021-04-10T15:07:06 | 2021-04-10T15:07:06 | 350,721,954 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,399 | h | /**
* @name static_encoding.h
* @brief functions for static huffman encoding
* @author Petr Flajšingr, xflajs00
* @date 23.03.2021
*/
#ifndef PF_HUFF_CODEC__COMPRESSION_H
#define PF_HUFF_CODEC__COMPRESSION_H
#include "BinaryEncoder.h"
#include "EncodingTreeData.h"
#include "Tree.h"
#include "constants.h"
#include "models.h"
#include "utils.h"
#include <algorithm>
#include <concepts>
#include <queue>
#include <ranges>
#include <spdlog/spdlog.h>
#include <vector>
namespace pf::kko {
template<std::integral T>
std::array<std::size_t, ValueCount<T>> createHistogram(const std::ranges::forward_range auto &data) {
auto result = std::array<std::size_t, ValueCount<T>>{};
std::ranges::for_each(data, [&result](const auto value) { ++result[value]; });
return result;
}
/**
* Create a huffman tree for encoding purposes.
* @details stl heap functions are used for code simplification
* @param histogram histogram of occurrences in input data
* @return binary tree, where leaves represent symbols
*/
template<std::integral T>
Tree<StaticEncodingTreeData<T>> buildTree(const std::ranges::forward_range auto &histogram) {
using NodeType = Node<StaticEncodingTreeData<T>>;
// comparison function dereferencing ptrs
const auto compare = [](const auto &lhs, const auto &rhs) { return *lhs > *rhs; };
auto treeHeap = std::vector<std::unique_ptr<NodeType>>{};
// counter representing an encoded symbol, could be replaced with ranges library (histogram | views::enumerate)
std::integral auto counter = T{};
std::ranges::for_each(histogram, [&treeHeap, &counter, compare](const auto &occurrenceCnt) {
if (occurrenceCnt > 0) {
pushAsHeap(treeHeap, makeUniqueNode(StaticEncodingTreeData<T>{counter, occurrenceCnt, true}), compare);
}
++counter;
});
// if the tree only has one element, add special node
if (treeHeap.size() == 1) { pushAsHeap(treeHeap, makeUniqueNode(makeNYTStatic<T>()), compare); }
// heap transformation to a binary tree
while (treeHeap.size() > 1) {
auto left = popAsHeap(treeHeap, compare);
auto right = popAsHeap(treeHeap, compare);
auto newNode = makeUniqueNode(StaticEncodingTreeData<T>{0, left->getValue().weight + right->getValue().weight, true});
newNode->setLeft(std::move(left));
newNode->setRight(std::move(right));
treeHeap.emplace_back(std::move(newNode));
std::push_heap(treeHeap.begin(), treeHeap.end(), compare);
}
auto result = Tree<StaticEncodingTreeData<T>>();
result.setRoot(std::move(treeHeap.front()));
return result;
}
/**
* Implementation of huffman code creation.
* @param node currently inspected node
* @param codesForSymbols storage for results
* @param branchCode code from the previous levels of the tree
*/
template<std::integral T>
void buildCodes(Node<StaticEncodingTreeData<T>> &node, std::vector<std::pair<T, std::vector<bool>>> &codesForSymbols,
const std::vector<bool> &branchCode) {
if (node.isLeaf()) {
codesForSymbols.template emplace_back(node->value, branchCode);
return;
}
auto leftCode = branchCode;
auto rightCode = branchCode;
leftCode.template emplace_back(false);
rightCode.template emplace_back(true);
if (node.hasLeft()) { buildCodes(node.getLeft(), codesForSymbols, leftCode); }
if (node.hasRight()) { buildCodes(node.getRight(), codesForSymbols, rightCode); }
}
/**
* Create huffman code for each symbol.
* @param node tree root node
* @return vector of pairs, where pair.first is a symbol and pair.second is binary code
*/
template<std::integral T>
std::vector<std::pair<T, std::vector<bool>>> buildCodes(Node<StaticEncodingTreeData<T>> &node) {
auto result = std::vector<std::pair<T, std::vector<bool>>>{};
buildCodes(node, result, {});
return result;
}
/**
* Make code canonical in order to save some data space
* @param codes codes from buildCodes function
*/
template<std::integral T>
void transformCodes(std::vector<std::pair<T, std::vector<bool>>> &codes) {
// sort the symbols by their code length
std::ranges::sort(codes, [](const auto &lhs, const auto &rhs) { return lhs.second.size() < rhs.second.size(); });
auto &[unused1_, shortestCode] = codes.front();
const auto shortestCodeLen = shortestCode.size();
shortestCode.clear();
shortestCode.resize(shortestCodeLen, false);
if (codes.size() <= 1) { return; }
auto &[unused2_, secondShortestCode] = codes[1];
const auto secondShortestCodeOrigLen = secondShortestCode.size();
auto previousCodeLen = secondShortestCodeOrigLen;
auto previousCode = 1 << (secondShortestCodeOrigLen - shortestCodeLen);
const auto fillWithZerosAndOnePadAndReverse = [](auto &vec, auto mask, auto padLen) {
for (; mask != 0; mask >>= 1) { vec.template emplace_back(mask & 1); }
std::ranges::generate_n(std::back_inserter(vec), padLen - vec.size(), [] { return false; });
std::reverse(vec.begin(), vec.end());
};
secondShortestCode.clear();
fillWithZerosAndOnePadAndReverse(secondShortestCode, previousCode, secondShortestCodeOrigLen);
for (std::size_t cnt = 2; cnt < codes.size(); ++cnt) {
auto &symbol = codes[cnt];
const auto codeLen = symbol.second.size();
const auto code = (previousCode + 1) * (1 << (codeLen - previousCodeLen));
previousCodeLen = codeLen;
previousCode = code;
symbol.second.clear();
fillWithZerosAndOnePadAndReverse(symbol.second, code, codeLen);
}
}
/**
* Encode data using prepared symbol codes.
* @param data input data
* @param symbolCodes huffman codes for symbol
* @return encoded data
*/
template<std::integral T>
std::vector<uint8_t> encodeStatic_impl(std::ranges::forward_range auto &&data,
const std::vector<std::pair<T, std::vector<bool>>> &symbolCodes) {
const auto [minCodeLength, maxCodeLength] =
minmaxValue(symbolCodes | std::views::transform([](const auto &el) { return el.second.size(); })).value();
auto byteHeader = std::vector<std::vector<uint8_t>>{};
byteHeader.resize(maxCodeLength + 1);
auto byteTable = std::array<std::vector<bool>, ValueCount<T>>{};
std::ranges::for_each(symbolCodes, [&byteTable, &byteHeader](const auto &symbolCode) {
const auto &[symbol, code] = symbolCode;
byteTable[symbol] = code;
byteHeader[code.size()].emplace_back(symbol);
});
spdlog::info("Created header");
spdlog::trace("Start binary encoding");
auto binEncoderData = BinaryEncoder<uint8_t>{};
std::ranges::for_each(byteHeader.begin() + minCodeLength, byteHeader.end(), [&binEncoderData](const auto &v) {
const auto size = static_cast<uint8_t>(v.size());
binEncoderData.pushBack(size);
});
std::ranges::for_each(byteHeader, [&binEncoderData](auto val) { binEncoderData.pushBack(val); });
std::ranges::for_each(data,
[&binEncoderData, &byteTable](const auto &in) { binEncoderData.pushBack(byteTable[in]); });
const auto padding = binEncoderData.unusedBitsInCell();
const auto codeLengthInfo = static_cast<uint8_t>(maxCodeLength + 1);
const auto paddingInfo = static_cast<uint8_t>((minCodeLength - 1) | (static_cast<uint8_t>(padding << PADDING_SHIFT)));
auto result = std::vector<uint8_t>{};
result.template emplace_back(codeLengthInfo);
result.template emplace_back(paddingInfo);
result.resize(result.size() + binEncoderData.data().size());
std::ranges::copy(binEncoderData.releaseData(), result.begin() + 2);
spdlog::info("Data encoded, total length: {}[b]", result.size());
return result;
}
/**
* @details Model is a concept for the sake of optimisations
* @param data data to be encoded
* @param model
* @return encoded data
*/
template<std::integral T, typename Model = IdentityModel<T>>
std::vector<uint8_t> encodeStatic(std::ranges::forward_range auto &&data, Model &&model = Model{}) {
spdlog::info("Starting static encoding");
std::ranges::transform(data, std::ranges::begin(data), makeApplyLambda<T>(model));
spdlog::trace("Applied model");
const auto histogram = createHistogram<uint8_t>(data);
spdlog::trace("Created histogram");
auto tree = buildTree<T>(histogram);
spdlog::info("Built tree");
auto symbolCodes = buildCodes(tree.getRoot());
spdlog::trace("Built codes");
transformCodes(symbolCodes);
spdlog::info("Created symbol codes");
return encodeStatic_impl(data, symbolCodes);
}
}// namespace pf::kko
#endif//PF_HUFF_CODEC__COMPRESSION_H
| [
"xflajs00@stud.fit.vutbr.cz"
] | xflajs00@stud.fit.vutbr.cz |
9ef5162639a875cb94f70478f838a12c8cf13cde | 612c21ed3ef18febbccd261c5a6a1aa211b5189e | /CH3.9/main.cpp | 9d121adbb6cf27d7ef0b38e30a9979fe6d2b0ed3 | [] | no_license | karlaalatorre/ASSIGNMENT2 | 8fecbb736c1e94c8b34798185ac2deda7656e68c | 8bdf107b156ce2cd5bfdde17459e297f777201ce | refs/heads/master | 2016-09-05T17:05:47.716993 | 2015-07-06T21:07:30 | 2015-07-06T21:07:30 | 38,646,335 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,586 | cpp | /*
* File: main.cpp
* Author: Valeria Alatorre
* Purpose: calculate the monthly expenses for a car
* Created on July 5, 2015, 6:07 PM
*/
//System Libraries
#include <iostream>// File I/O
#include <iomanip>
using namespace std;// std namespace ->iostream
//User Libraries
//Global Constants
//Function Prototypes
//Execution Begins Here!
int main(int argc, char** argv) {
//Declare variables Here
double loanp;//monthly loan paqyment
double insrn;//insurance payment
double gas;//monthly payment for gas
double oil;//monthly payment for oil
double tires;//monthly payment for tires
double mntnc;//monthly payment for maintenance
double moncos;//monthly total cost
double ancos;//annual total cost
//Initialize values
cout<<"Enter your monthly loan payment: ";
cin>>loanp;
cout<<"Enter your monthly insurance: ";
cin>>insrn;
cout<<"Enter your monthly gas expense: ";
cin>>gas;
cout<<"Enter your monthly oil expenses: ";
cin>>oil;
cout<<"Enter your monthly tires expenses: ";
cin>>tires;
cout<<"Enter your monthly maintenance expenses: ";
cin>>mntnc;
//Process Inputs Here
moncos= loanp+insrn+gas+oil+tires+mntnc;
ancos=moncos*12;
//Outputs Unknown Here
cout<< setprecision(2)<<fixed;
cout<<" "
" "
" "
""
""
""<<endl;
cout<<"Your monthly expenses are: $"<<moncos<<endl;
cout<<"Your annual expenses are: $"<<ancos<<endl;
//Exit stage Right!
return 0;
}
| [
"alatorrec.karlav@hotmail.com"
] | alatorrec.karlav@hotmail.com |
71dd1ee1fc92c49cd3ee1014e6faf4f4dc55c4c4 | e71d40ad4e76272fca4494c6bcc818050d221090 | /V8/src/extensions/gc-extension.h | 54b865adf75335d42ac12415cea19f5f72cbca20 | [
"BSD-3-Clause",
"bzip2-1.0.6"
] | permissive | yuanyan/know-your-chrome | e038e49c160bdf46b28241427e99bf2816fac022 | 18cace725261122f6903c98bfdcbfa0b370138c3 | refs/heads/master | 2022-12-29T18:31:42.046729 | 2013-12-18T11:45:13 | 2013-12-18T11:45:13 | 9,907,874 | 7 | 7 | null | 2022-12-18T00:00:55 | 2013-05-07T08:55:26 | C++ | UTF-8 | C++ | false | false | 2,123 | h | // Copyright 2010 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_EXTENSIONS_GC_EXTENSION_H_
#define V8_EXTENSIONS_GC_EXTENSION_H_
#include "v8.h"
namespace v8 {
namespace internal {
class GCExtension : public v8::Extension {
public:
explicit GCExtension(const char* source) : v8::Extension("v8/gc", source) {}
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
v8::Handle<v8::String> name);
static v8::Handle<v8::Value> GC(const v8::Arguments& args);
static void Register();
};
} } // namespace v8::internal
#endif // V8_EXTENSIONS_GC_EXTENSION_H_
| [
"yuanyan.cao@gmail.com"
] | yuanyan.cao@gmail.com |
e8370e484a5f3ea8e1a7267aeae3563406ac9592 | 23957c15d6999b6cf35eaf8566fedc20504f569b | /scc/graph_reader.cpp | 7202bbe72d3182f92bd2fde5605a0ae0a959b998 | [
"BSD-3-Clause"
] | permissive | JoeXinfa/scc | b7694a7c3c1af356b50288b409fb12229cbf0982 | 199f077cbc02e226e07e1b6784c43fff47932bf5 | refs/heads/master | 2022-12-07T23:09:17.688170 | 2020-08-24T15:37:12 | 2020-08-24T15:37:12 | 282,000,369 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,479 | cpp | #include <fstream>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include "graph_reader.hpp"
using namespace std;
/*
This module will read snap data to create a graph
*/
int GraphReader::get_n() { return n_vertices; }
vector<vector<int>> GraphReader::get_edges() { return this->edges; }
vector<string>* GraphReader::get_nodes() {
return new vector<string>(this->complexId);
}
int GraphReader::n_edges() {
int counter = 0;
for (std::vector<std::vector<int>>::iterator i = edges.begin();
i != edges.end(); ++i) {
counter += i->size();
}
return counter;
}
GraphReader::GraphReader(string filename) {
ifstream raw_data;
raw_data.open(filename);
if (!raw_data.is_open()) {
cerr << "Problem opening file";
return;
}
string oriID, destID;
int counter = 0;
map<string, int> simpleId;
while (raw_data >> oriID >> destID) {
if (simpleId.find(oriID) == simpleId.end()) {
simpleId[oriID] = counter;
complexId.push_back(oriID);
edges.push_back(vector<int>());
counter++;
}
if (simpleId.find(destID) == simpleId.end()) {
simpleId[destID] = counter;
complexId.push_back(destID);
edges.push_back(vector<int>());
counter++;
}
edges[simpleId[oriID]].push_back(simpleId[destID]);
}
this->n_vertices = counter;
raw_data.close();
}
| [
"xinfazhu@gmail.com"
] | xinfazhu@gmail.com |
efbf420ffc1ee9bc79bb1a8f240d5c210c64c84f | 63c71060f36866bca4ac27304cef6d5755fdc35c | /src/CliUtil/Sample/main.cpp | 5570e915cb6f203805cd538e695efde1ff36ac2d | [] | no_license | 15831944/barry_dev | bc8441cbfbd4b62fbb42bee3dcb79ff7f5fcaf8a | d4a83421458aa28ca293caa7a5567433e9358596 | refs/heads/master | 2022-03-24T07:00:26.810732 | 2015-12-22T07:19:58 | 2015-12-22T07:19:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,054 | cpp | ////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2005
// Packet Engineering, Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification is not permitted unless authorized in writing by a duly
// appointed officer of Packet Engineering, Inc. or its derivatives
//
// File Name: main.cpp
// Description:
//
//
// Modification History:
//
////////////////////////////////////////////////////////////////////////////
#include "CliUtil/CliUtil.h"
#include "CliUtil/CliUtilProc.h"
#include "Alarm/Alarm.h"
#include "AppMgr/App.h"
#include "CliUtil/CliWrapper.h"
#include "Debug/Debug.h"
#include "Porting/ThreadDef.h"
#include "Porting/Sleep.h"
#include "SingletonClass/SingletonMgr.h"
#include "Util/OmnNew.h"
#include "Util/IpAddr.h"
static char *appname[16] = {"test"};
int JustTest(char *data, unsigned int *optlen, struct aosUserLandApiParms *parms,
char *errmsg, const int errlen)
{
unsigned int index = 0;
char* buf = CliUtil_getBuff(data);
// char local[256];
//strcpy(local, parms->mStrings[0]);
//CliUtil_checkAndCopy(buf, &index, *optlen, local, strlen(local));
CliUtil_sprintf(buf, &index, *optlen, "just a test: %d", 1);
CliUtil_sprintf(buf, &index, *optlen, "%s", "test");
*optlen = index;
return 0;
}
int
main(int argc, char **argv)
{
OmnApp theApp(argc, argv);
try
{
}
catch (const OmnExcept &e)
{
cout << "****** Failed to start the application: " << e.toString() << endl;
OmnAlarm << "Failed to start the application: " << e.toString() << enderr;
return 0;
}
CliUtil_initCli((char**)appname, 1, 0);
CliUtil_regCliCmd("just test", JustTest);
//
// Chen Ding, 05/23/2007
//
for (int i=0; i<20; i++)
{
OmnString rslt;
OmnString cmd = "?";
if (aos_run_cli(cmd, rslt))
{
cout << "Command: \"" << cmd << "\" executed correctly" << endl;
}
else
{
cout << "Command: \"" << cmd << "\" failed: " << rslt << endl;
}
}
theApp.appLoop();
theApp.exitApp();
return 0;
}
| [
"barryniu@jimodb.com"
] | barryniu@jimodb.com |
e31356f850b5c659c2a09480b1c2282973ff1641 | 5fcacbc63db76625cc60ffc9d6ed58a91f134ea4 | /vxl/vxl-1.13.0/contrib/rpl/rsdl/rsdl_kd_tree.cxx | a66b1ce7d18333e671e2caa87bb00ac93bc3c1f5 | [] | no_license | EasonZhu/rcc | c809956eb13fb732d1b2c8035db177991e3530aa | d230b542fa97da22271b200e3be7441b56786091 | refs/heads/master | 2021-01-15T20:28:26.541784 | 2013-05-14T07:18:12 | 2013-05-14T07:18:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,783 | cxx | // This is rpl/rsdl/rsdl_kd_tree.cxx
#include "rsdl_kd_tree.h"
#include <vcl_algorithm.h>
#include <vcl_cassert.h>
#include <vcl_cmath.h>
#include <vcl_iostream.h>
#include <vcl_utility.h>
#include <vnl/vnl_math.h>
#include <vnl/vnl_numeric_traits.h>
#include <rsdl/rsdl_dist.h>
rsdl_kd_tree::rsdl_kd_tree( const vcl_vector< rsdl_point >& points,
double min_angle,
int points_per_leaf )
: points_(points), min_angle_(min_angle)
{
assert(points_per_leaf > 0);
Nc_ = points_[0].num_cartesian();
Na_ = points_[0].num_angular();
// 0. Consistency check
for ( unsigned int i=1; i<points_.size(); ++i ) {
assert( Nc_ == points_[i].num_cartesian() );
assert( Na_ == points_[i].num_angular() );
}
// 1. Build the initial bounding box.
rsdl_point low(Nc_, Na_), high(Nc_, Na_);
// 1a. initialize the cartesian upper and lower limits
if ( Nc_ > 0 ) {
for ( unsigned int i=0; i<Nc_; ++i ) {
low.cartesian(i) = -vnl_numeric_traits<double>::maxval;
high.cartesian(i) = vnl_numeric_traits<double>::maxval;
}
}
// 1b. initialize the angular upper and lower limits
if ( Na_ > 0 ) {
for ( unsigned int i=0; i<Na_; ++i ) {
low.angular(i) = min_angle;
high.angular(i) = min_angle + 2*vnl_math::pi;
}
}
// 1c. create the bounding box
rsdl_bounding_box box( low, high );
#ifdef DEBUG
vcl_cout << "Initial bounding box: " << box << vcl_endl;
#endif
// 2. create the vector of ids
vcl_vector< int > indices( points_.size() );
for ( unsigned int i=0; i<indices.size(); ++i ) indices[ i ] = i;
leaf_count_ = internal_count_ = 0;
// 3. call recursive function to do the real work
root_ = build_kd_tree( points_per_leaf, box, 0, indices );
}
bool
first_less( const vcl_pair<double,int>& left,
const vcl_pair<double,int>& right )
{
return left.first < right.first;
}
rsdl_kd_node *
rsdl_kd_tree::build_kd_tree( int points_per_leaf,
const rsdl_bounding_box& outer_box,
int depth,
vcl_vector< int >& indices )
{
assert(points_per_leaf > 0);
unsigned int i;
#ifdef DEBUG
vcl_cout << "build_kd_tree:\n ids:\n";
for ( i=0; i<indices.size(); ++i )
vcl_cout << " index: " << indices[i] << ", point: " << points_[ indices[i] ] << '\n';
vcl_cout << "\n outer bounding box:\n" << outer_box << vcl_endl;
#endif
// 1. Build the inner box. This is not done inside the bounding box
// class because of the indices.
rsdl_bounding_box inner_box = this -> build_inner_box( indices );
#ifdef DEBUG
vcl_cout << "\n inner bounding box:\n" << inner_box << vcl_endl;
#endif
// 2. If the number of points is small enough, create and return a leaf node.
if ( indices.size() <= (unsigned int)points_per_leaf ) {
#ifdef DEBUG
vcl_cout << "making leaf node" << vcl_endl;
#endif
leaf_count_ ++ ;
return new rsdl_kd_node ( outer_box, inner_box, depth, indices );
}
// 3. Find the dimension along which there is the greatest variation
// in the points.
bool use_cartesian;
int dim;
this->greatest_variation( indices, use_cartesian, dim );
#ifdef DEBUG
vcl_cout << "greatest_varation returned use_cartesian = " << use_cartesian
<< ", dim = " << dim << vcl_endl;
#endif
// 4. Form and then sort a vector of temporary pairs, containing the
// indices and the values along the selected dim of the data.
// Sort by the values.
vcl_vector< vcl_pair< double, int > > values( indices.size() );
for ( i=0; i<indices.size(); ++i ) {
if ( use_cartesian ) {
values[i] = vcl_pair<double, int> ( points_[ indices[i] ].cartesian( dim ), indices[i] );
}
else {
values[i] = vcl_pair<double, int> ( points_[ indices[i] ].angular( dim ), indices[i] );
}
}
vcl_sort( values.begin(), values.end(), first_less );
#ifdef DEBUG
vcl_cout << "\nsorted values/indices:\n";
for ( i=0; i<values.size(); ++i )
vcl_cout << i << ": value = " << values[i].first << ", id = " << values[i].second << vcl_endl;
#endif
// 5. Partition the vector and the bounding box along the dimension.
unsigned int med_loc = (indices.size()-1) / 2;
double median_value = (values[med_loc].first + values[med_loc+1].first) / 2;
#ifdef DEBUG
vcl_cout << "med_loc = " << med_loc << ", median_value = " << median_value << vcl_endl;
#endif
rsdl_bounding_box left_outer_box( outer_box ), right_outer_box( outer_box );
if ( use_cartesian ) {
left_outer_box.max_cartesian( dim ) = median_value;
right_outer_box.min_cartesian( dim ) = median_value;
}
else {
left_outer_box.max_angular( dim ) = median_value;
right_outer_box.min_angular( dim ) = median_value;
}
#ifdef DEBUG
vcl_cout << "new bounding boxes: left " << left_outer_box
<< "\n right " << right_outer_box << vcl_endl;
#endif
vcl_vector< int > left_indices( med_loc+1 ), right_indices( indices.size()-med_loc-1 );
for ( i=0; i<=med_loc; ++i ) left_indices[i] = values[i].second;
for ( ; i<indices.size(); ++i ) right_indices[i-med_loc-1] = values[i].second;
rsdl_kd_node * node = new rsdl_kd_node( outer_box, inner_box, depth );
internal_count_ ++ ;
node->left_ = this->build_kd_tree( points_per_leaf, left_outer_box, depth+1, left_indices );
node->right_ = this->build_kd_tree( points_per_leaf, right_outer_box, depth+1, right_indices );
return node;
}
rsdl_bounding_box
rsdl_kd_tree :: build_inner_box( const vcl_vector< int >& indices )
{
assert( indices.size() > 0 );
rsdl_point min_point( points_[ indices[ 0 ] ] );
rsdl_point max_point( min_point );
for (unsigned int i=1; i < indices.size(); ++ i ) {
const rsdl_point& pt = points_[ indices[ i ] ];
for ( unsigned int j=0; j < Nc_; ++ j ) {
if ( pt.cartesian( j ) < min_point.cartesian( j ) )
min_point.cartesian( j ) = pt.cartesian( j );
if ( pt.cartesian( j ) > max_point.cartesian( j ) )
max_point.cartesian( j ) = pt.cartesian( j );
}
for ( unsigned int j=0; j < Na_; ++ j ) {
if ( pt.angular( j ) < min_point.angular( j ) )
min_point.angular( j ) = pt.angular( j );
if ( pt.angular( j ) > max_point.angular( j ) )
max_point.angular( j ) = pt.angular( j );
}
}
return rsdl_bounding_box( min_point, max_point );
}
void
rsdl_kd_tree::greatest_variation( const vcl_vector<int>& indices,
bool& use_cartesian,
int& dim )
{
use_cartesian = true;
bool initialized = false;
double interval_size = 0.0;
// 1. Check the Cartesian dimensions, if they exist
for ( unsigned int i=0; i<Nc_; ++i ) {
double min_v, max_v;
min_v = max_v = points_[ indices[0] ].cartesian( i );
for ( unsigned int j=1; j<indices.size(); ++j ) {
double v = points_[ indices[j] ].cartesian( i );
if ( v < min_v ) min_v = v;
if ( v > max_v ) max_v = v;
}
if ( !initialized || max_v - min_v > interval_size ) {
dim = i;
interval_size = max_v - min_v;
initialized = true;
}
}
// 2. Check the angular dimensions, if they exist
for ( unsigned int i=0; i<Na_; ++i ) {
double min_v, max_v;
min_v = max_v = points_[ indices[0] ].angular( i );
for (unsigned int j=1; j<indices.size(); ++j ) {
double v = points_[ indices[j] ].angular( i );
if ( v < min_v ) min_v = v;
if ( v > max_v ) max_v = v;
}
if ( !initialized || max_v - min_v > interval_size ) {
dim = i;
use_cartesian = false;
interval_size = max_v - min_v;
initialized = true;
}
}
assert( initialized );
}
rsdl_kd_tree::~rsdl_kd_tree( )
{
destroy_tree( root_ );
}
void
rsdl_kd_tree::destroy_tree( rsdl_kd_node*& p )
{
if ( p ) {
destroy_tree( p->left_ );
destroy_tree( p->right_ );
delete p;
p = 0;
}
}
void
rsdl_kd_tree::n_nearest( const rsdl_point& query_point,
int n,
vcl_vector< rsdl_point >& closest_points,
vcl_vector< int >& closest_indices,
bool use_heap,
int max_leaves)
{
assert(n>0);
assert( query_point.num_cartesian() == Nc_ );
assert( query_point.num_angular() == Na_ );
//if we are using approx query, then we must use heap
assert(max_leaves == -1 || (max_leaves > 0 && use_heap));
if ( closest_indices.size() != (unsigned int)n )
closest_indices.resize( n );
vcl_vector< double > sq_distances( n, 1e+10 ); // could cache for (slight) efficiency gain
int num_found = 0;
leaves_examined_ = internal_examined_ = 0;
if ( use_heap )
this->n_nearest_with_heap( query_point, n, root_, closest_indices, sq_distances, num_found, max_leaves );
else
this->n_nearest_with_stack( query_point, n, root_, closest_indices, sq_distances, num_found );
#ifdef DEBUG
vcl_cout << "\nAfter n_nearest, leaves_examined_ = " << leaves_examined_
<< ", fraction = " << float(leaves_examined_) / leaf_count_
<< "\n internal_examined_ = " << internal_examined_
<< ", fraction = " << float(internal_examined_) / internal_count_ << vcl_endl;
#endif
assert(num_found >= 0);
if ( closest_points.size() != (unsigned int)num_found )
closest_points.resize( num_found );
for ( int i=0; i<num_found; ++i ) {
closest_points[i] = points_[ closest_indices[i] ];
}
}
void
rsdl_kd_tree::n_nearest_with_stack( const rsdl_point& query_point,
int n,
rsdl_kd_node* root,
vcl_vector< int >& closest_indices,
vcl_vector< double >& sq_distances,
int & num_found )
{
assert(n>0);
#ifdef DEBUG
vcl_cout << "\n\n----------------\nn_nearest_with_stack" << vcl_endl;
#endif
vcl_vector< rsdl_kd_heap_entry > stack_vec;
stack_vec.reserve( 100 ); // way more than will ever be needed
double left_box_sq_dist, right_box_sq_dist;
double sq_dist;
bool initial_path = true;
// Go down tree,
rsdl_kd_node* current = root;
sq_dist = 0;
do {
#ifdef DEBUG
vcl_cout << "\ncurrent -- sq_dist " << sq_dist << ", depth: " << current->depth_
<< "\nouter_box: " << current->outer_box_
<< "\ninner_box: " << current->inner_box_
<< "\nstack size: " << stack_vec.size() << vcl_endl;
#endif
// if the distance is too large, skip node and take the next node
// from the stack
if ( num_found >= n && sq_dist >= sq_distances[ num_found-1 ] ) {
#ifdef DEBUG
vcl_cout << "skipping node" << vcl_endl;
#endif
if ( stack_vec.size() == 0 )
return; // DONE
else {
sq_dist = stack_vec[ stack_vec.size()-1 ].dist_;
current = stack_vec[ stack_vec.size()-1 ].p_;
stack_vec.pop_back();
}
}
// if this is a leaf node, update the set of closest points, and
// take the next node from the stack
else if ( ! current->left_ ) {
#ifdef DEBUG
vcl_cout << "At a leaf" << vcl_endl;
#endif
leaves_examined_ ++ ;
update_closest( query_point, n, current, closest_indices, sq_distances, num_found );
// If stack is empty then we're done.
if ( stack_vec.size() == 0 )
return; // done
// If we're on the first path down the tree and if we can decide there
// is no possibility of any other closer point, then quit.
else
{
if ( initial_path )
{
#ifdef DEBUG
vcl_cout << "First leaf" << vcl_endl;
#endif
initial_path = false ;
if ( this-> bounded_at_leaf( query_point, n, current, sq_distances, num_found ) )
return; // done
}
// Pop the stack as the next location.
sq_dist = stack_vec[ stack_vec.size()-1 ].dist_;
current = stack_vec[ stack_vec.size()-1 ].p_;
stack_vec.pop_back();
}
}
else
{
#ifdef DEBUG
vcl_cout << "Internal node" << vcl_endl;
#endif
internal_examined_ ++ ;
left_box_sq_dist = rsdl_dist_sq( query_point, current->left_->inner_box_ );
right_box_sq_dist = rsdl_dist_sq( query_point, current->right_->inner_box_ );
#ifdef DEBUG
vcl_cout << "left sq distance = " << left_box_sq_dist << vcl_endl
<< "right sq distance = " << right_box_sq_dist << vcl_endl;
#endif
if ( left_box_sq_dist < right_box_sq_dist )
{
#ifdef DEBUG
vcl_cout << "going left, pushing right" << vcl_endl;
#endif
stack_vec.push_back( rsdl_kd_heap_entry( right_box_sq_dist, current->right_ ) );
current = current->left_ ;
}
else {
#ifdef DEBUG
vcl_cout << "going right, pushing left" << vcl_endl;
#endif
stack_vec.push_back( rsdl_kd_heap_entry( left_box_sq_dist, current->left_ ) );
current = current->right_ ;
}
}
} while ( true );
}
void
rsdl_kd_tree::n_nearest_with_heap( const rsdl_point& query_point,
int n,
rsdl_kd_node* root,
vcl_vector< int >& closest_indices,
vcl_vector< double >& sq_distances,
int & num_found,
int max_leaves)
{
assert(n>0);
#ifdef DEBUG
vcl_cout << "\n\n----------------\nn_nearest_with_heap" << vcl_endl;
#endif
vcl_vector< rsdl_kd_heap_entry > heap_vec;
heap_vec.reserve( 100 );
double left_box_sq_dist, right_box_sq_dist;
double sq_dist;
// Go down tree,
rsdl_kd_node* current = root;
while ( current->left_ ) {
internal_examined_ ++ ;
if ( rsdl_dist_sq( query_point, current-> left_ -> outer_box_ ) < 1.0e-5 ) {
right_box_sq_dist = rsdl_dist_sq( query_point, current->right_->inner_box_ );
heap_vec.push_back( rsdl_kd_heap_entry( right_box_sq_dist, current->right_ ) );
current = current->left_ ;
}
else {
left_box_sq_dist = rsdl_dist_sq( query_point, current->left_->inner_box_ );
heap_vec.push_back( rsdl_kd_heap_entry( left_box_sq_dist, current->left_ ) );
current = current->right_ ;
}
}
vcl_make_heap( heap_vec.begin(), heap_vec.end() );
sq_dist = 0;
#ifdef DEBUG
vcl_cout << "\nAfter initial trip down the tree, here's the heap\n";
for ( int i=0; i<heap_vec.size(); ++i )
vcl_cout << " " << i << ": sq distance " << heap_vec[i].dist_
<< ", node depth " << heap_vec[i].p_->depth_ << vcl_endl;
#endif
bool first_leaf = true;
do {
#ifdef DEBUG
vcl_cout << "\ncurrent -- sq_dist " << sq_dist << ", depth: " << current->depth_
<< "\nouter_box: " << current->outer_box_
<< "\ninner_box: " << current->inner_box_
<< "\nheap size: " << heap_vec.size() << vcl_endl;
#endif
if ( num_found < n || sq_dist < sq_distances[ num_found-1 ] ) {
if ( ! current->left_ ) { // a leaf node
#ifdef DEBUG
vcl_cout << "Leaf" << vcl_endl;
#endif
leaves_examined_ ++ ;
update_closest( query_point, n, current, closest_indices, sq_distances, num_found );
if ( first_leaf ) { // check if we can quit just at this leaf node.
#ifdef DEBUG
vcl_cout << "First leaf" << vcl_endl;
#endif
first_leaf = false;
if ( this-> bounded_at_leaf( query_point, n, current, sq_distances, num_found ) )
return;
}
if (max_leaves != -1 && leaves_examined_ >= max_leaves)
return;
}
else {
#ifdef DEBUG
vcl_cout << "Internal" << vcl_endl;
#endif
internal_examined_ ++ ;
left_box_sq_dist = rsdl_dist_sq( query_point, current->left_->inner_box_ );
#ifdef DEBUG
vcl_cout << "left sq distance = " << left_box_sq_dist << vcl_endl;
#endif
if ( num_found < n || sq_distances[ num_found-1 ] > left_box_sq_dist ) {
#ifdef DEBUG
vcl_cout << "pushing left onto the heap" << vcl_endl;
#endif
heap_vec.push_back( rsdl_kd_heap_entry( left_box_sq_dist, current->left_ ) );
vcl_push_heap( heap_vec.begin(), heap_vec.end() );
};
right_box_sq_dist = rsdl_dist_sq( query_point, current->right_->inner_box_ );
#ifdef DEBUG
vcl_cout << "right sq distance = " << right_box_sq_dist << vcl_endl;
#endif
if ( num_found < n || sq_distances[ num_found-1 ] > right_box_sq_dist ) {
#ifdef DEBUG
vcl_cout << "pushing right onto the heap" << vcl_endl;
#endif
heap_vec.push_back( rsdl_kd_heap_entry( right_box_sq_dist, current->right_ ) );
vcl_push_heap( heap_vec.begin(), heap_vec.end() );
}
}
}
#ifdef DEBUG
else vcl_cout << "skipping node" << vcl_endl;
#endif
if ( heap_vec.size() == 0 )
return;
else {
vcl_pop_heap( heap_vec.begin(), heap_vec.end() );
sq_dist = heap_vec[ heap_vec.size()-1 ].dist_;
current = heap_vec[ heap_vec.size()-1 ].p_;
heap_vec.pop_back();
}
} while ( true );
}
void
rsdl_kd_tree::update_closest( const rsdl_point& query_point,
int n,
rsdl_kd_node* p,
vcl_vector< int >& closest_indices,
vcl_vector< double >& sq_distances,
int & num_found )
{
assert(n>0);
#ifdef DEBUG
vcl_cout << "Update_closest for leaf\n query_point = " << query_point
<< "\n inner bounding box =\n" << p->inner_box_
<< "\n sq_dist = " << rsdl_dist_sq( query_point, p->inner_box_ )
<< vcl_endl;
#endif
for ( unsigned int i=0; i < p->point_indices_.size(); ++i ) { // check each id
int id = p->point_indices_[i];
double sq_dist = rsdl_dist_sq( query_point, points_[ id ] );
#ifdef DEBUG
vcl_cout << " id = " << id << ", point = " << points_[ id ]
<< ", sq_dist = " << sq_dist << vcl_endl;
#endif
// if enough points have been found and the distance of this point is
// too large then skip it.
if ( num_found >= n && sq_dist >= sq_distances[ num_found-1 ] )
continue;
// Increment the num_found counter if fewer than the desired
// number have already been found.
if ( num_found < n ) {
num_found ++;
}
// Insert the id and square distance in order.
int j=num_found-2;
while ( j >= 0 && sq_distances[j] > sq_dist ) {
closest_indices[ j+1 ] = closest_indices[ j ];
sq_distances[ j+1 ] = sq_distances[ j ];
j -- ;
}
closest_indices[ j+1 ] = id;
sq_distances[ j+1 ] = sq_dist;
}
#ifdef DEBUG
vcl_cout << " End of leaf computation, num_found = " << num_found
<< ", and they are:\n";
for ( int k=0; k<num_found; ++k )
vcl_cout << " " << k << ": indices: " << closest_indices[ k ]
<< ", sq_dist " << sq_distances[ k ] << vcl_endl;
#endif
}
// If there are already n points (at the first leaf) and if a box
// drawn around the first point of half-width the distance of the
// n-th point fits inside the outer box of this node, then no points
// anywhere else in the tree will can replace any of the closest
// points.
bool
rsdl_kd_tree :: bounded_at_leaf ( const rsdl_point& query_point,
int n,
rsdl_kd_node* current,
const vcl_vector< double >& sq_distances,
int & num_found )
{
assert(n>0);
#ifdef DEBUG
vcl_cout << "bounded_at_leaf\n num_found = " << num_found << vcl_endl;
#endif
if ( num_found != n ) {
return false;
}
double radius = vcl_sqrt( sq_distances[ n-1 ] );
for ( unsigned int i = 0; i < Nc_; ++ i ) {
double x = query_point.cartesian( i );
if ( current -> outer_box_ . min_cartesian( i ) > x - radius ||
current -> outer_box_ . max_cartesian( i ) < x + radius ) {
return false;
}
}
for ( unsigned int i = 0; i < Na_; ++ i ) {
double a = query_point.angular( i );
if ( current -> outer_box_ . min_angular( i ) > a - radius ||
current -> outer_box_ . max_angular( i ) < a + radius ) {
return false;
}
}
return true;
}
// Find all points within a query's bounding box
void
rsdl_kd_tree :: points_in_bounding_box( const rsdl_bounding_box& box,
vcl_vector< rsdl_point >& points_in_box,
vcl_vector< int >& indices_in_box )
{
points_in_box.clear();
indices_in_box.clear();
this -> points_in_bounding_box( root_, box, indices_in_box );
for ( unsigned int i=0; i<indices_in_box.size(); ++i )
points_in_box.push_back( this -> points_[ indices_in_box[i] ] );
}
void
rsdl_kd_tree :: points_in_radius( const rsdl_point& query_point,
double radius,
vcl_vector< rsdl_point >& points_within_radius,
vcl_vector< int >& indices_within_radius )
{
// Form a bounding box of width 2*radius, centered at the point.
// Start by creating the corner points of this box.
rsdl_point min_point( query_point.num_cartesian(), query_point.num_angular() );
rsdl_point max_point( query_point.num_cartesian(), query_point.num_angular() );
// Fill in the cartesian values.
for ( unsigned int i=0; i < query_point.num_cartesian(); ++i ) {
min_point.cartesian( i ) = query_point.cartesian(i) - radius;
max_point.cartesian( i ) = query_point.cartesian(i) + radius;
}
// Fill in the angular values. If the radius is at least pi then
// the whole range of angles will be covered.
if ( radius >= vnl_math::pi ) {
for ( unsigned int j=0; j < query_point.num_angular(); ++j ) {
min_point.angular( j ) = this -> min_angle_;
max_point.angular( j ) = this -> min_angle_ + 2 * vnl_math::pi;
}
}
// The radius is less than pi. For each angular value, generate
// the min and max angular values. Check both for wrap-around.
else {
for ( unsigned int j=0; j < query_point.num_angular(); ++j ) {
double min_angle = query_point.angular(j) - radius;
if ( min_angle < this -> min_angle_ )
min_angle += 2 * vnl_math::pi;
double max_angle = query_point.angular(j) + radius;
if ( max_angle > this -> min_angle_ + 2 * vnl_math::pi )
max_angle -= 2 * vnl_math::pi;
min_point.angular( j ) = min_angle;
max_point.angular( j ) = max_angle;
}
}
// Now, create the bounding box, and scratch vectors.
rsdl_bounding_box box( min_point, max_point );
vcl_vector< int > indices_in_box;
// Gather the points in the bounding box:
this -> points_in_bounding_box( this -> root_, box, indices_in_box );
// Clear out the result vectors in preparation
points_within_radius.clear();
indices_within_radius.clear();
// Gather the points from the bounding box that are within the radius.
double sq_radius = radius*radius;
for ( unsigned int i=0; i < indices_in_box.size(); ++i ) {
int index = indices_in_box[ i ];
if ( rsdl_dist_sq( query_point, this -> points_[ index ] ) < sq_radius ) {
points_within_radius.push_back( this -> points_[ index ] );
indices_within_radius.push_back( index );
}
}
}
void
rsdl_kd_tree :: points_in_bounding_box( rsdl_kd_node* current,
const rsdl_bounding_box& box,
vcl_vector< int >& indices_in_box )
{
if ( ! current -> left_ ) {
for ( unsigned int i=0; i < current -> point_indices_ . size(); ++i ) {
int index = current -> point_indices_[ i ];
if ( rsdl_dist_point_in_box( this -> points_[ index ], box ) )
indices_in_box.push_back( index );
}
}
else {
bool inside, intersects;
rsdl_dist_box_relation( current -> inner_box_, box, inside, intersects );
if ( inside )
this -> report_all_in_subtree( current, indices_in_box );
else if ( intersects ) {
this -> points_in_bounding_box( current -> left_, box, indices_in_box );
this -> points_in_bounding_box( current -> right_, box, indices_in_box );
}
}
}
void
rsdl_kd_tree :: report_all_in_subtree( rsdl_kd_node* current,
vcl_vector< int >& indices )
{
if ( current -> left_ ) {
this -> report_all_in_subtree( current -> left_, indices );
this -> report_all_in_subtree( current -> right_, indices );
}
else {
for ( unsigned int i=0; i < current -> point_indices_ . size(); ++ i ) {
indices.push_back( current -> point_indices_[ i ] );
}
}
}
| [
"hieuza@gmail.com"
] | hieuza@gmail.com |
3a15bb79b0eff63f82e0ccb5e8ee26fa443946aa | 1066de8b96a9782c5d58bac1d00587cd93714a5f | /hphp/third_party/folly/folly/FBString.h | e0c5625084a93ca391b80b5dac8395d6029ad552 | [
"Apache-2.0",
"PHP-3.01",
"Zend-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | s-haffar/hiphop-php | fa9c936d24641d495e15f3029247ce5374aaa899 | e7d8f2e54d78999f907034cfb656cad7ce515030 | refs/heads/master | 2021-01-18T05:47:39.267363 | 2013-05-18T05:45:17 | 2013-05-18T05:45:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 73,194 | h | /*
* Copyright 2013 Facebook, 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.
*/
// @author: Andrei Alexandrescu (aalexandre)
// String type.
#ifndef FOLLY_BASE_FBSTRING_H_
#define FOLLY_BASE_FBSTRING_H_
/**
fbstring's behavior can be configured via two macro definitions, as
follows. Normally, fbstring does not write a '\0' at the end of
each string whenever it changes the underlying characters. Instead,
it lazily writes the '\0' whenever either c_str() or data()
called.
This is standard-compliant behavior and may save costs in some
circumstances. However, it may be surprising to some client code
because c_str() and data() are const member functions (fbstring
uses the "mutable" storage class for its own state).
In order to appease client code that expects fbstring to be
zero-terminated at all times, if the preprocessor symbol
FBSTRING_CONSERVATIVE is defined, fbstring does exactly that,
i.e. it goes the extra mile to guarantee a '\0' is always planted
at the end of its data.
On the contrary, if the desire is to debug faulty client code that
unduly assumes the '\0' is present, fbstring plants a '^' (i.e.,
emphatically NOT a zero) at the end of each string if
FBSTRING_PERVERSE is defined. (Calling c_str() or data() still
writes the '\0', of course.)
The preprocessor symbols FBSTRING_PERVERSE and
FBSTRING_CONSERVATIVE cannot be defined simultaneously. This is
enforced during preprocessing.
*/
//#define FBSTRING_PERVERSE
//#define FBSTRING_CONSERVATIVE
#ifdef FBSTRING_PERVERSE
#ifdef FBSTRING_CONSERVATIVE
#error Cannot define both FBSTRING_PERVERSE and FBSTRING_CONSERVATIVE.
#endif
#endif
// This file appears in two locations: inside fbcode and in the
// libstdc++ source code (when embedding fbstring as std::string).
// To aid in this schizophrenic use, two macros are defined in
// c++config.h:
// _LIBSTDCXX_FBSTRING - Set inside libstdc++. This is useful to
// gate use inside fbcode v. libstdc++
#include <bits/c++config.h>
#ifdef _LIBSTDCXX_FBSTRING
#pragma GCC system_header
// Handle the cases where the fbcode version (folly/Malloc.h) is included
// either before or after this inclusion.
#ifdef FOLLY_MALLOC_H_
#undef FOLLY_MALLOC_H_
#include "basic_fbstring_malloc.h"
#else
#include "basic_fbstring_malloc.h"
#undef FOLLY_MALLOC_H_
#endif
#else // !_LIBSTDCXX_FBSTRING
#include <string>
#include <cstring>
#include <cassert>
#include "folly/Traits.h"
#include "folly/Malloc.h"
#include "folly/Hash.h"
#endif
// We defined these here rather than including Likely.h to avoid
// redefinition errors when fbstring is imported into libstdc++.
#define FBSTRING_LIKELY(x) (__builtin_expect((x), 1))
#define FBSTRING_UNLIKELY(x) (__builtin_expect((x), 0))
#include <atomic>
#include <limits>
#include <type_traits>
#ifdef _LIBSTDCXX_FBSTRING
namespace std _GLIBCXX_VISIBILITY(default) {
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#else
namespace folly {
#endif
namespace fbstring_detail {
template <class InIt, class OutIt>
inline
OutIt copy_n(InIt b,
typename std::iterator_traits<InIt>::difference_type n,
OutIt d) {
for (; n != 0; --n, ++b, ++d) {
assert((const void*)&*d != &*b);
*d = *b;
}
return d;
}
template <class Pod, class T>
inline void pod_fill(Pod* b, Pod* e, T c) {
assert(b && e && b <= e);
/*static*/ if (sizeof(T) == 1) {
memset(b, c, e - b);
} else {
auto const ee = b + ((e - b) & ~7u);
for (; b != ee; b += 8) {
b[0] = c;
b[1] = c;
b[2] = c;
b[3] = c;
b[4] = c;
b[5] = c;
b[6] = c;
b[7] = c;
}
// Leftovers
for (; b != e; ++b) {
*b = c;
}
}
}
/*
* Lightly structured memcpy, simplifies copying PODs and introduces
* some asserts. Unfortunately using this function may cause
* measurable overhead (presumably because it adjusts from a begin/end
* convention to a pointer/size convention, so it does some extra
* arithmetic even though the caller might have done the inverse
* adaptation outside).
*/
template <class Pod>
inline void pod_copy(const Pod* b, const Pod* e, Pod* d) {
assert(e >= b);
assert(d >= e || d + (e - b) <= b);
memcpy(d, b, (e - b) * sizeof(Pod));
}
/*
* Lightly structured memmove, simplifies copying PODs and introduces
* some asserts
*/
template <class Pod>
inline void pod_move(const Pod* b, const Pod* e, Pod* d) {
assert(e >= b);
memmove(d, b, (e - b) * sizeof(*b));
}
} // namespace fbstring_detail
/**
* Defines a special acquisition method for constructing fbstring
* objects. AcquireMallocatedString means that the user passes a
* pointer to a malloc-allocated string that the fbstring object will
* take into custody.
*/
enum class AcquireMallocatedString {};
/*
* fbstring_core_model is a mock-up type that defines all required
* signatures of a fbstring core. The fbstring class itself uses such
* a core object to implement all of the numerous member functions
* required by the standard.
*
* If you want to define a new core, copy the definition below and
* implement the primitives. Then plug the core into basic_fbstring as
* a template argument.
template <class Char>
class fbstring_core_model {
public:
fbstring_core_model();
fbstring_core_model(const fbstring_core_model &);
~fbstring_core_model();
// Returns a pointer to string's buffer (currently only contiguous
// strings are supported). The pointer is guaranteed to be valid
// until the next call to a non-const member function.
const Char * data() const;
// Much like data(), except the string is prepared to support
// character-level changes. This call is a signal for
// e.g. reference-counted implementation to fork the data. The
// pointer is guaranteed to be valid until the next call to a
// non-const member function.
Char * mutable_data();
// Returns a pointer to string's buffer and guarantees that a
// readable '\0' lies right after the buffer. The pointer is
// guaranteed to be valid until the next call to a non-const member
// function.
const Char * c_str() const;
// Shrinks the string by delta characters. Asserts that delta <=
// size().
void shrink(size_t delta);
// Expands the string by delta characters (i.e. after this call
// size() will report the old size() plus delta) but without
// initializing the expanded region. Returns a pointer to the memory
// to be initialized (the beginning of the expanded portion). The
// caller is expected to fill the expanded area appropriately.
Char* expand_noinit(size_t delta);
// Expands the string by one character and sets the last character
// to c.
void push_back(Char c);
// Returns the string's size.
size_t size() const;
// Returns the string's capacity, i.e. maximum size that the string
// can grow to without reallocation. Note that for reference counted
// strings that's technically a lie - even assigning characters
// within the existing size would cause a reallocation.
size_t capacity() const;
// Returns true if the data underlying the string is actually shared
// across multiple strings (in a refcounted fashion).
bool isShared() const;
// Makes sure that at least minCapacity characters are available for
// the string without reallocation. For reference-counted strings,
// it should fork the data even if minCapacity < size().
void reserve(size_t minCapacity);
private:
// Do not implement
fbstring_core_model& operator=(const fbstring_core_model &);
};
*/
/**
* gcc-4.7 throws what appears to be some false positive uninitialized
* warnings for the members of the MediumLarge struct. So, mute them here.
*/
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wuninitialized"
#endif
/**
* This is the core of the string. The code should work on 32- and
* 64-bit architectures and with any Char size. Porting to big endian
* architectures would require some changes.
*
* The storage is selected as follows (assuming we store one-byte
* characters on a 64-bit machine): (a) "small" strings between 0 and
* 23 chars are stored in-situ without allocation (the rightmost byte
* stores the size); (b) "medium" strings from 24 through 254 chars
* are stored in malloc-allocated memory that is copied eagerly; (c)
* "large" strings of 255 chars and above are stored in a similar
* structure as medium arrays, except that the string is
* reference-counted and copied lazily. the reference count is
* allocated right before the character array.
*
* The discriminator between these three strategies sits in the two
* most significant bits of the rightmost char of the storage. If
* neither is set, then the string is small (and its length sits in
* the lower-order bits of that rightmost character). If the MSb is
* set, the string is medium width. If the second MSb is set, then the
* string is large.
*/
template <class Char> class fbstring_core {
public:
fbstring_core() {
// Only initialize the tag, will set the MSBs (i.e. the small
// string size) to zero too
ml_.capacity_ = maxSmallSize << (8 * (sizeof(size_t) - sizeof(Char)));
// or: setSmallSize(0);
writeTerminator();
assert(category() == isSmall && size() == 0);
}
fbstring_core(const fbstring_core & rhs) {
assert(&rhs != this);
// Simplest case first: small strings are bitblitted
if (rhs.category() == isSmall) {
assert(offsetof(MediumLarge, data_) == 0);
assert(offsetof(MediumLarge, size_) == sizeof(ml_.data_));
assert(offsetof(MediumLarge, capacity_) == 2 * sizeof(ml_.data_));
const size_t size = rhs.smallSize();
if (size == 0) {
ml_.capacity_ = rhs.ml_.capacity_;
writeTerminator();
} else {
// Just write the whole thing, don't look at details. In
// particular we need to copy capacity anyway because we want
// to set the size (don't forget that the last character,
// which stores a short string's length, is shared with the
// ml_.capacity field).
ml_ = rhs.ml_;
}
assert(category() == isSmall && this->size() == rhs.size());
} else if (rhs.category() == isLarge) {
// Large strings are just refcounted
ml_ = rhs.ml_;
RefCounted::incrementRefs(ml_.data_);
assert(category() == isLarge && size() == rhs.size());
} else {
// Medium strings are copied eagerly. Don't forget to allocate
// one extra Char for the null terminator.
auto const allocSize =
goodMallocSize((1 + rhs.ml_.size_) * sizeof(Char));
ml_.data_ = static_cast<Char*>(checkedMalloc(allocSize));
fbstring_detail::pod_copy(rhs.ml_.data_,
// 1 for terminator
rhs.ml_.data_ + rhs.ml_.size_ + 1,
ml_.data_);
// No need for writeTerminator() here, we copied one extra
// element just above.
ml_.size_ = rhs.ml_.size_;
ml_.capacity_ = (allocSize / sizeof(Char) - 1) | isMedium;
assert(category() == isMedium);
}
assert(size() == rhs.size());
assert(memcmp(data(), rhs.data(), size() * sizeof(Char)) == 0);
}
fbstring_core(fbstring_core&& goner) {
if (goner.category() == isSmall) {
// Just copy, leave the goner in peace
new(this) fbstring_core(goner.small_, goner.smallSize());
} else {
// Take goner's guts
ml_ = goner.ml_;
// Clean goner's carcass
goner.setSmallSize(0);
}
}
fbstring_core(const Char *const data, const size_t size) {
// Simplest case first: small strings are bitblitted
if (size <= maxSmallSize) {
// Layout is: Char* data_, size_t size_, size_t capacity_
/*static_*/assert(sizeof(*this) == sizeof(Char*) + 2 * sizeof(size_t));
/*static_*/assert(sizeof(Char*) == sizeof(size_t));
// sizeof(size_t) must be a power of 2
/*static_*/assert((sizeof(size_t) & (sizeof(size_t) - 1)) == 0);
// If data is aligned, use fast word-wise copying. Otherwise,
// use conservative memcpy.
if (reinterpret_cast<size_t>(data) & (sizeof(size_t) - 1)) {
fbstring_detail::pod_copy(data, data + size, small_);
} else {
// Copy one word (64 bits) at a time
const size_t byteSize = size * sizeof(Char);
if (byteSize > 2 * sizeof(size_t)) {
// Copy three words
ml_.capacity_ = reinterpret_cast<const size_t*>(data)[2];
copyTwo:
ml_.size_ = reinterpret_cast<const size_t*>(data)[1];
copyOne:
ml_.data_ = *reinterpret_cast<Char**>(const_cast<Char*>(data));
} else if (byteSize > sizeof(size_t)) {
// Copy two words
goto copyTwo;
} else if (size > 0) {
// Copy one word
goto copyOne;
}
}
setSmallSize(size);
} else if (size <= maxMediumSize) {
// Medium strings are allocated normally. Don't forget to
// allocate one extra Char for the terminating null.
auto const allocSize = goodMallocSize((1 + size) * sizeof(Char));
ml_.data_ = static_cast<Char*>(checkedMalloc(allocSize));
fbstring_detail::pod_copy(data, data + size, ml_.data_);
ml_.size_ = size;
ml_.capacity_ = (allocSize / sizeof(Char) - 1) | isMedium;
} else {
// Large strings are allocated differently
size_t effectiveCapacity = size;
auto const newRC = RefCounted::create(data, & effectiveCapacity);
ml_.data_ = newRC->data_;
ml_.size_ = size;
ml_.capacity_ = effectiveCapacity | isLarge;
}
writeTerminator();
assert(this->size() == size);
assert(memcmp(this->data(), data, size * sizeof(Char)) == 0);
}
~fbstring_core() {
auto const c = category();
if (c == isSmall) {
return;
}
if (c == isMedium) {
free(ml_.data_);
return;
}
RefCounted::decrementRefs(ml_.data_);
}
// Snatches a previously mallocated string. The parameter "size"
// is the size of the string, and the parameter "capacity" is the size
// of the mallocated block. The string must be \0-terminated, so
// data[size] == '\0' and capacity >= size + 1.
//
// So if you want a 2-character string, pass malloc(3) as "data", pass 2 as
// "size", and pass 3 as "capacity".
fbstring_core(Char *const data, const size_t size,
const size_t capacity,
AcquireMallocatedString) {
if (size > 0) {
assert(capacity > size);
assert(data[size] == '\0');
// Use the medium string storage
ml_.data_ = data;
ml_.size_ = size;
ml_.capacity_ = capacity | isMedium;
} else {
// No need for the memory
free(data);
setSmallSize(0);
}
}
// swap below doesn't test whether &rhs == this (and instead
// potentially does extra work) on the premise that the rarity of
// that situation actually makes the check more expensive than is
// worth.
void swap(fbstring_core & rhs) {
auto const t = ml_;
ml_ = rhs.ml_;
rhs.ml_ = t;
}
// In C++11 data() and c_str() are 100% equivalent.
const Char * data() const {
return c_str();
}
Char * mutable_data() {
auto const c = category();
if (c == isSmall) {
return small_;
}
assert(c == isMedium || c == isLarge);
if (c == isLarge && RefCounted::refs(ml_.data_) > 1) {
// Ensure unique.
size_t effectiveCapacity = ml_.capacity();
auto const newRC = RefCounted::create(& effectiveCapacity);
// If this fails, someone placed the wrong capacity in an
// fbstring.
assert(effectiveCapacity >= ml_.capacity());
fbstring_detail::pod_copy(ml_.data_, ml_.data_ + ml_.size_ + 1,
newRC->data_);
RefCounted::decrementRefs(ml_.data_);
ml_.data_ = newRC->data_;
// No need to call writeTerminator(), we have + 1 above.
}
return ml_.data_;
}
const Char * c_str() const {
auto const c = category();
#ifdef FBSTRING_PERVERSE
if (c == isSmall) {
assert(small_[smallSize()] == TERMINATOR || smallSize() == maxSmallSize
|| small_[smallSize()] == '\0');
small_[smallSize()] = '\0';
return small_;
}
assert(c == isMedium || c == isLarge);
assert(ml_.data_[ml_.size_] == TERMINATOR || ml_.data_[ml_.size_] == '\0');
ml_.data_[ml_.size_] = '\0';
#elif defined(FBSTRING_CONSERVATIVE)
if (c == isSmall) {
assert(small_[smallSize()] == '\0');
return small_;
}
assert(c == isMedium || c == isLarge);
assert(ml_.data_[ml_.size_] == '\0');
#else
if (c == isSmall) {
small_[smallSize()] = '\0';
return small_;
}
assert(c == isMedium || c == isLarge);
ml_.data_[ml_.size_] = '\0';
#endif
return ml_.data_;
}
void shrink(const size_t delta) {
if (category() == isSmall) {
// Check for underflow
assert(delta <= smallSize());
setSmallSize(smallSize() - delta);
} else if (category() == isMedium || RefCounted::refs(ml_.data_) == 1) {
// Medium strings and unique large strings need no special
// handling.
assert(ml_.size_ >= delta);
ml_.size_ -= delta;
} else {
assert(ml_.size_ >= delta);
// Shared large string, must make unique. This is because of the
// durn terminator must be written, which may trample the shared
// data.
if (delta) {
fbstring_core(ml_.data_, ml_.size_ - delta).swap(*this);
}
// No need to write the terminator.
return;
}
writeTerminator();
}
void reserve(size_t minCapacity) {
if (category() == isLarge) {
// Ensure unique
if (RefCounted::refs(ml_.data_) > 1) {
// We must make it unique regardless; in-place reallocation is
// useless if the string is shared. In order to not surprise
// people, reserve the new block at current capacity or
// more. That way, a string's capacity never shrinks after a
// call to reserve.
minCapacity = std::max(minCapacity, ml_.capacity());
auto const newRC = RefCounted::create(& minCapacity);
fbstring_detail::pod_copy(ml_.data_, ml_.data_ + ml_.size_ + 1,
newRC->data_);
// Done with the old data. No need to call writeTerminator(),
// we have + 1 above.
RefCounted::decrementRefs(ml_.data_);
ml_.data_ = newRC->data_;
ml_.capacity_ = minCapacity | isLarge;
// size remains unchanged
} else {
// String is not shared, so let's try to realloc (if needed)
if (minCapacity > ml_.capacity()) {
// Asking for more memory
auto const newRC =
RefCounted::reallocate(ml_.data_, ml_.size_,
ml_.capacity(), minCapacity);
ml_.data_ = newRC->data_;
ml_.capacity_ = minCapacity | isLarge;
writeTerminator();
}
assert(capacity() >= minCapacity);
}
} else if (category() == isMedium) {
// String is not shared
if (minCapacity <= ml_.capacity()) {
return; // nothing to do, there's enough room
}
if (minCapacity <= maxMediumSize) {
// Keep the string at medium size. Don't forget to allocate
// one extra Char for the terminating null.
size_t capacityBytes = goodMallocSize((1 + minCapacity) * sizeof(Char));
ml_.data_ = static_cast<Char *>(
smartRealloc(
ml_.data_,
ml_.size_ * sizeof(Char),
ml_.capacity() * sizeof(Char),
capacityBytes));
writeTerminator();
ml_.capacity_ = (capacityBytes / sizeof(Char) - 1) | isMedium;
} else {
// Conversion from medium to large string
fbstring_core nascent;
// Will recurse to another branch of this function
nascent.reserve(minCapacity);
nascent.ml_.size_ = ml_.size_;
fbstring_detail::pod_copy(ml_.data_, ml_.data_ + ml_.size_,
nascent.ml_.data_);
nascent.swap(*this);
writeTerminator();
assert(capacity() >= minCapacity);
}
} else {
assert(category() == isSmall);
if (minCapacity > maxMediumSize) {
// large
auto const newRC = RefCounted::create(& minCapacity);
auto const size = smallSize();
fbstring_detail::pod_copy(small_, small_ + size + 1, newRC->data_);
// No need for writeTerminator(), we wrote it above with + 1.
ml_.data_ = newRC->data_;
ml_.size_ = size;
ml_.capacity_ = minCapacity | isLarge;
assert(capacity() >= minCapacity);
} else if (minCapacity > maxSmallSize) {
// medium
// Don't forget to allocate one extra Char for the terminating null
auto const allocSizeBytes =
goodMallocSize((1 + minCapacity) * sizeof(Char));
auto const data = static_cast<Char*>(checkedMalloc(allocSizeBytes));
auto const size = smallSize();
fbstring_detail::pod_copy(small_, small_ + size + 1, data);
// No need for writeTerminator(), we wrote it above with + 1.
ml_.data_ = data;
ml_.size_ = size;
ml_.capacity_ = (allocSizeBytes / sizeof(Char) - 1) | isMedium;
} else {
// small
// Nothing to do, everything stays put
}
}
assert(capacity() >= minCapacity);
}
Char * expand_noinit(const size_t delta) {
// Strategy is simple: make room, then change size
assert(capacity() >= size());
size_t sz, newSz;
if (category() == isSmall) {
sz = smallSize();
newSz = sz + delta;
if (newSz <= maxSmallSize) {
setSmallSize(newSz);
writeTerminator();
return small_ + sz;
}
reserve(newSz);
} else {
sz = ml_.size_;
newSz = ml_.size_ + delta;
if (newSz > capacity()) {
reserve(newSz);
}
}
assert(capacity() >= newSz);
// Category can't be small - we took care of that above
assert(category() == isMedium || category() == isLarge);
ml_.size_ = newSz;
writeTerminator();
assert(size() == newSz);
return ml_.data_ + sz;
}
void push_back(Char c) {
assert(capacity() >= size());
size_t sz;
if (category() == isSmall) {
sz = smallSize();
if (sz < maxSmallSize) {
setSmallSize(sz + 1);
small_[sz] = c;
writeTerminator();
return;
}
reserve(maxSmallSize * 2);
} else {
sz = ml_.size_;
if (sz == capacity()) { // always true for isShared()
reserve(sz * 3 / 2); // ensures not shared
}
}
assert(!isShared());
assert(capacity() >= sz + 1);
// Category can't be small - we took care of that above
assert(category() == isMedium || category() == isLarge);
ml_.size_ = sz + 1;
ml_.data_[sz] = c;
writeTerminator();
}
size_t size() const {
return category() == isSmall ? smallSize() : ml_.size_;
}
size_t capacity() const {
switch (category()) {
case isSmall:
return maxSmallSize;
case isLarge:
// For large-sized strings, a multi-referenced chunk has no
// available capacity. This is because any attempt to append
// data would trigger a new allocation.
if (RefCounted::refs(ml_.data_) > 1) return ml_.size_;
default: {}
}
return ml_.capacity();
}
bool isShared() const {
return category() == isLarge && RefCounted::refs(ml_.data_) > 1;
}
#ifdef FBSTRING_PERVERSE
enum { TERMINATOR = '^' };
#else
enum { TERMINATOR = '\0' };
#endif
void writeTerminator() {
#if defined(FBSTRING_PERVERSE) || defined(FBSTRING_CONSERVATIVE)
if (category() == isSmall) {
const auto s = smallSize();
if (s != maxSmallSize) {
small_[s] = TERMINATOR;
}
} else {
ml_.data_[ml_.size_] = TERMINATOR;
}
#endif
}
private:
// Disabled
fbstring_core & operator=(const fbstring_core & rhs);
struct MediumLarge {
Char * data_;
size_t size_;
size_t capacity_;
size_t capacity() const {
return capacity_ & capacityExtractMask;
}
};
struct RefCounted {
std::atomic<size_t> refCount_;
Char data_[1];
static RefCounted * fromData(Char * p) {
return static_cast<RefCounted*>(
static_cast<void*>(
static_cast<unsigned char*>(static_cast<void*>(p))
- sizeof(refCount_)));
}
static size_t refs(Char * p) {
return fromData(p)->refCount_.load(std::memory_order_acquire);
}
static void incrementRefs(Char * p) {
fromData(p)->refCount_.fetch_add(1, std::memory_order_acq_rel);
}
static void decrementRefs(Char * p) {
auto const dis = fromData(p);
size_t oldcnt = dis->refCount_.fetch_sub(1, std::memory_order_acq_rel);
assert(oldcnt > 0);
if (oldcnt == 1) {
free(dis);
}
}
static RefCounted * create(size_t * size) {
// Don't forget to allocate one extra Char for the terminating
// null. In this case, however, one Char is already part of the
// struct.
const size_t allocSize = goodMallocSize(
sizeof(RefCounted) + *size * sizeof(Char));
auto result = static_cast<RefCounted*>(checkedMalloc(allocSize));
result->refCount_.store(1, std::memory_order_release);
*size = (allocSize - sizeof(RefCounted)) / sizeof(Char);
return result;
}
static RefCounted * create(const Char * data, size_t * size) {
const size_t effectiveSize = *size;
auto result = create(size);
fbstring_detail::pod_copy(data, data + effectiveSize, result->data_);
return result;
}
static RefCounted * reallocate(Char *const data,
const size_t currentSize,
const size_t currentCapacity,
const size_t newCapacity) {
assert(newCapacity > 0 && newCapacity > currentSize);
auto const dis = fromData(data);
assert(dis->refCount_.load(std::memory_order_acquire) == 1);
// Don't forget to allocate one extra Char for the terminating
// null. In this case, however, one Char is already part of the
// struct.
auto result = static_cast<RefCounted*>(
smartRealloc(dis,
sizeof(RefCounted) + currentSize * sizeof(Char),
sizeof(RefCounted) + currentCapacity * sizeof(Char),
sizeof(RefCounted) + newCapacity * sizeof(Char)));
assert(result->refCount_.load(std::memory_order_acquire) == 1);
return result;
}
};
union {
mutable Char small_[sizeof(MediumLarge) / sizeof(Char)];
mutable MediumLarge ml_;
};
enum {
lastChar = sizeof(MediumLarge) - 1,
maxSmallSize = lastChar / sizeof(Char),
maxMediumSize = 254 / sizeof(Char), // coincides with the small
// bin size in dlmalloc
categoryExtractMask = sizeof(size_t) == 4 ? 0xC0000000 : 0xC000000000000000,
capacityExtractMask = ~categoryExtractMask,
};
static_assert(!(sizeof(MediumLarge) % sizeof(Char)),
"Corrupt memory layout for fbstring.");
enum Category {
isSmall = 0,
isMedium = sizeof(size_t) == 4 ? 0x80000000 : 0x8000000000000000,
isLarge = sizeof(size_t) == 4 ? 0x40000000 : 0x4000000000000000,
};
Category category() const {
// Assumes little endian
return static_cast<Category>(ml_.capacity_ & categoryExtractMask);
}
size_t smallSize() const {
assert(category() == isSmall && small_[maxSmallSize] <= maxSmallSize);
return static_cast<size_t>(maxSmallSize)
- static_cast<size_t>(small_[maxSmallSize]);
}
void setSmallSize(size_t s) {
// Warning: this should work with uninitialized strings too,
// so don't assume anything about the previous value of
// small_[maxSmallSize].
assert(s <= maxSmallSize);
small_[maxSmallSize] = maxSmallSize - s;
}
};
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic pop
#endif
#ifndef _LIBSTDCXX_FBSTRING
/**
* Dummy fbstring core that uses an actual std::string. This doesn't
* make any sense - it's just for testing purposes.
*/
template <class Char>
class dummy_fbstring_core {
public:
dummy_fbstring_core() {
}
dummy_fbstring_core(const dummy_fbstring_core& another)
: backend_(another.backend_) {
}
dummy_fbstring_core(const Char * s, size_t n)
: backend_(s, n) {
}
void swap(dummy_fbstring_core & rhs) {
backend_.swap(rhs.backend_);
}
const Char * data() const {
return backend_.data();
}
Char * mutable_data() {
//assert(!backend_.empty());
return &*backend_.begin();
}
void shrink(size_t delta) {
assert(delta <= size());
backend_.resize(size() - delta);
}
Char * expand_noinit(size_t delta) {
auto const sz = size();
backend_.resize(size() + delta);
return backend_.data() + sz;
}
void push_back(Char c) {
backend_.push_back(c);
}
size_t size() const {
return backend_.size();
}
size_t capacity() const {
return backend_.capacity();
}
bool isShared() const {
return false;
}
void reserve(size_t minCapacity) {
backend_.reserve(minCapacity);
}
private:
std::basic_string<Char> backend_;
};
#endif // !_LIBSTDCXX_FBSTRING
/**
* This is the basic_string replacement. For conformity,
* basic_fbstring takes the same template parameters, plus the last
* one which is the core.
*/
#ifdef _LIBSTDCXX_FBSTRING
template <typename E, class T, class A, class Storage>
#else
template <typename E,
class T = std::char_traits<E>,
class A = std::allocator<E>,
class Storage = fbstring_core<E> >
#endif
class basic_fbstring {
static void enforce(
bool condition,
void (*throw_exc)(const char*),
const char* msg) {
if (!condition) throw_exc(msg);
}
bool isSane() const {
return
begin() <= end() &&
empty() == (size() == 0) &&
empty() == (begin() == end()) &&
size() <= max_size() &&
capacity() <= max_size() &&
size() <= capacity() &&
(begin()[size()] == Storage::TERMINATOR || begin()[size()] == '\0');
}
struct Invariant;
friend struct Invariant;
struct Invariant {
#ifndef NDEBUG
explicit Invariant(const basic_fbstring& s) : s_(s) {
assert(s_.isSane());
}
~Invariant() {
assert(s_.isSane());
}
private:
const basic_fbstring& s_;
#else
explicit Invariant(const basic_fbstring&) {}
#endif
Invariant& operator=(const Invariant&);
};
public:
// types
typedef T traits_type;
typedef typename traits_type::char_type value_type;
typedef A allocator_type;
typedef typename A::size_type size_type;
typedef typename A::difference_type difference_type;
typedef typename A::reference reference;
typedef typename A::const_reference const_reference;
typedef typename A::pointer pointer;
typedef typename A::const_pointer const_pointer;
typedef E* iterator;
typedef const E* const_iterator;
typedef std::reverse_iterator<iterator
#ifdef NO_ITERATOR_TRAITS
, value_type
#endif
> reverse_iterator;
typedef std::reverse_iterator<const_iterator
#ifdef NO_ITERATOR_TRAITS
, const value_type
#endif
> const_reverse_iterator;
static const size_type npos; // = size_type(-1)
private:
static void procrustes(size_type& n, size_type nmax) {
if (n > nmax) n = nmax;
}
public:
// 21.3.1 construct/copy/destroy
explicit basic_fbstring(const A& a = A()) {
}
basic_fbstring(const basic_fbstring& str)
: store_(str.store_) {
}
// Move constructor
basic_fbstring(basic_fbstring&& goner) : store_(std::move(goner.store_)) {
}
#ifndef _LIBSTDCXX_FBSTRING
// This is defined for compatibility with std::string
/* implicit */ basic_fbstring(const std::string& str)
: store_(str.data(), str.size()) {
}
#endif
basic_fbstring(const basic_fbstring& str, size_type pos,
size_type n = npos, const A& a = A()) {
assign(str, pos, n);
}
/* implicit */ basic_fbstring(const value_type* s, const A& a = A())
: store_(s, s ? traits_type::length(s) : ({
basic_fbstring<char> err = __PRETTY_FUNCTION__;
err += ": null pointer initializer not valid";
std::__throw_logic_error(err.c_str());
0;
})) {
}
basic_fbstring(const value_type* s, size_type n, const A& a = A())
: store_(s, n) {
}
basic_fbstring(size_type n, value_type c, const A& a = A()) {
auto const data = store_.expand_noinit(n);
fbstring_detail::pod_fill(data, data + n, c);
store_.writeTerminator();
}
template <class InIt>
basic_fbstring(InIt begin, InIt end,
typename std::enable_if<
!std::is_same<typename std::remove_const<InIt>::type,
value_type*>::value, const A>::type & a = A()) {
assign(begin, end);
}
// Specialization for const char*, const char*
basic_fbstring(const value_type* b, const value_type* e)
: store_(b, e - b) {
}
// Nonstandard constructor
basic_fbstring(value_type *s, size_type n, size_type c,
AcquireMallocatedString a)
: store_(s, n, c, a) {
}
~basic_fbstring() {
}
basic_fbstring& operator=(const basic_fbstring& lhs) {
if (FBSTRING_UNLIKELY(&lhs == this)) {
return *this;
}
auto const oldSize = size();
auto const srcSize = lhs.size();
if (capacity() >= srcSize && !store_.isShared()) {
// great, just copy the contents
if (oldSize < srcSize)
store_.expand_noinit(srcSize - oldSize);
else
store_.shrink(oldSize - srcSize);
assert(size() == srcSize);
fbstring_detail::pod_copy(lhs.begin(), lhs.end(), begin());
store_.writeTerminator();
} else {
// need to reallocate, so we may as well create a brand new string
basic_fbstring(lhs).swap(*this);
}
return *this;
}
// Move assignment
basic_fbstring& operator=(basic_fbstring&& goner) {
// Self move assignment is illegal, see 17.6.4.9 for the explanation
assert(&goner != this);
// No need of this anymore
this->~basic_fbstring();
// Move the goner into this
new(&store_) fbstring_core<E>(std::move(goner.store_));
return *this;
}
#ifndef _LIBSTDCXX_FBSTRING
// Compatibility with std::string
basic_fbstring & operator=(const std::string & rhs) {
return assign(rhs.data(), rhs.size());
}
// Compatibility with std::string
std::string toStdString() const {
return std::string(data(), size());
}
#else
// A lot of code in fbcode still uses this method, so keep it here for now.
const basic_fbstring& toStdString() const {
return *this;
}
#endif
basic_fbstring& operator=(const value_type* s) {
return assign(s);
}
basic_fbstring& operator=(value_type c) {
if (empty()) {
store_.expand_noinit(1);
} else if (store_.isShared()) {
basic_fbstring(1, c).swap(*this);
return *this;
} else {
store_.shrink(size() - 1);
}
*store_.mutable_data() = c;
store_.writeTerminator();
return *this;
}
// 21.3.2 iterators:
iterator begin() { return store_.mutable_data(); }
const_iterator begin() const { return store_.data(); }
iterator end() {
return store_.mutable_data() + store_.size();
}
const_iterator end() const {
return store_.data() + store_.size();
}
reverse_iterator rbegin() {
return reverse_iterator(end());
}
const_reverse_iterator rbegin() const {
return const_reverse_iterator(end());
}
reverse_iterator rend() {
return reverse_iterator(begin());
}
const_reverse_iterator rend() const {
return const_reverse_iterator(begin());
}
// Added by C++11
// C++11 21.4.5, element access:
const value_type& front() const { return *begin(); }
const value_type& back() const {
assert(!empty());
// Should be begin()[size() - 1], but that branches twice
return *(end() - 1);
}
value_type& front() { return *begin(); }
value_type& back() {
assert(!empty());
// Should be begin()[size() - 1], but that branches twice
return *(end() - 1);
}
void pop_back() {
assert(!empty());
store_.shrink(1);
}
// 21.3.3 capacity:
size_type size() const { return store_.size(); }
size_type length() const { return size(); }
size_type max_size() const {
return std::numeric_limits<size_type>::max();
}
void resize(const size_type n, const value_type c = value_type()) {
auto size = this->size();
if (n <= size) {
store_.shrink(size - n);
} else {
// Do this in two steps to minimize slack memory copied (see
// smartRealloc).
auto const capacity = this->capacity();
assert(capacity >= size);
if (size < capacity) {
auto delta = std::min(n, capacity) - size;
store_.expand_noinit(delta);
fbstring_detail::pod_fill(begin() + size, end(), c);
size += delta;
if (size == n) {
store_.writeTerminator();
return;
}
assert(size < n);
}
auto const delta = n - size;
store_.expand_noinit(delta);
fbstring_detail::pod_fill(end() - delta, end(), c);
store_.writeTerminator();
}
assert(this->size() == n);
}
size_type capacity() const { return store_.capacity(); }
void reserve(size_type res_arg = 0) {
enforce(res_arg <= max_size(), std::__throw_length_error, "");
store_.reserve(res_arg);
}
void clear() { resize(0); }
bool empty() const { return size() == 0; }
// 21.3.4 element access:
const_reference operator[](size_type pos) const {
return *(c_str() + pos);
}
reference operator[](size_type pos) {
if (pos == size()) {
// Just call c_str() to make sure '\0' is present
c_str();
}
return *(begin() + pos);
}
const_reference at(size_type n) const {
enforce(n <= size(), std::__throw_out_of_range, "");
return (*this)[n];
}
reference at(size_type n) {
enforce(n < size(), std::__throw_out_of_range, "");
return (*this)[n];
}
// 21.3.5 modifiers:
basic_fbstring& operator+=(const basic_fbstring& str) {
return append(str);
}
basic_fbstring& operator+=(const value_type* s) {
return append(s);
}
basic_fbstring& operator+=(const value_type c) {
push_back(c);
return *this;
}
basic_fbstring& append(const basic_fbstring& str) {
#ifndef NDEBUG
auto desiredSize = size() + str.size();
#endif
append(str.data(), str.size());
assert(size() == desiredSize);
return *this;
}
basic_fbstring& append(const basic_fbstring& str, const size_type pos,
size_type n) {
const size_type sz = str.size();
enforce(pos <= sz, std::__throw_out_of_range, "");
procrustes(n, sz - pos);
return append(str.data() + pos, n);
}
basic_fbstring& append(const value_type* s, size_type n) {
#ifndef NDEBUG
Invariant checker(*this);
(void) checker;
#endif
if (FBSTRING_UNLIKELY(!n)) {
// Unlikely but must be done
return *this;
}
auto const oldSize = size();
auto const oldData = data();
// Check for aliasing (rare). We could use "<=" here but in theory
// those do not work for pointers unless the pointers point to
// elements in the same array. For that reason we use
// std::less_equal, which is guaranteed to offer a total order
// over pointers. See discussion at http://goo.gl/Cy2ya for more
// info.
std::less_equal<const value_type*> le;
if (FBSTRING_UNLIKELY(le(oldData, s) && !le(oldData + oldSize, s))) {
assert(le(s + n, oldData + oldSize));
const size_type offset = s - oldData;
store_.reserve(oldSize + n);
// Restore the source
s = data() + offset;
}
// Warning! Repeated appends with short strings may actually incur
// practically quadratic performance. Avoid that by pushing back
// the first character (which ensures exponential growth) and then
// appending the rest normally. Worst case the append may incur a
// second allocation but that will be rare.
push_back(*s++);
--n;
memcpy(store_.expand_noinit(n), s, n * sizeof(value_type));
assert(size() == oldSize + n + 1);
return *this;
}
basic_fbstring& append(const value_type* s) {
return append(s, traits_type::length(s));
}
basic_fbstring& append(size_type n, value_type c) {
resize(size() + n, c);
return *this;
}
template<class InputIterator>
basic_fbstring& append(InputIterator first, InputIterator last) {
insert(end(), first, last);
return *this;
}
void push_back(const value_type c) { // primitive
store_.push_back(c);
}
basic_fbstring& assign(const basic_fbstring& str) {
if (&str == this) return *this;
return assign(str.data(), str.size());
}
basic_fbstring& assign(const basic_fbstring& str, const size_type pos,
size_type n) {
const size_type sz = str.size();
enforce(pos <= sz, std::__throw_out_of_range, "");
procrustes(n, sz - pos);
return assign(str.data() + pos, n);
}
basic_fbstring& assign(const value_type* s, const size_type n) {
Invariant checker(*this);
(void) checker;
if (size() >= n) {
std::copy(s, s + n, begin());
resize(n);
assert(size() == n);
} else {
const value_type *const s2 = s + size();
std::copy(s, s2, begin());
append(s2, n - size());
assert(size() == n);
}
store_.writeTerminator();
assert(size() == n);
return *this;
}
basic_fbstring& assign(const value_type* s) {
return assign(s, traits_type::length(s));
}
template <class ItOrLength, class ItOrChar>
basic_fbstring& assign(ItOrLength first_or_n, ItOrChar last_or_c) {
return replace(begin(), end(), first_or_n, last_or_c);
}
basic_fbstring& insert(size_type pos1, const basic_fbstring& str) {
return insert(pos1, str.data(), str.size());
}
basic_fbstring& insert(size_type pos1, const basic_fbstring& str,
size_type pos2, size_type n) {
enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
procrustes(n, str.length() - pos2);
return insert(pos1, str.data() + pos2, n);
}
basic_fbstring& insert(size_type pos, const value_type* s, size_type n) {
enforce(pos <= length(), std::__throw_out_of_range, "");
insert(begin() + pos, s, s + n);
return *this;
}
basic_fbstring& insert(size_type pos, const value_type* s) {
return insert(pos, s, traits_type::length(s));
}
basic_fbstring& insert(size_type pos, size_type n, value_type c) {
enforce(pos <= length(), std::__throw_out_of_range, "");
insert(begin() + pos, n, c);
return *this;
}
iterator insert(const iterator p, const value_type c) {
const size_type pos = p - begin();
insert(p, 1, c);
return begin() + pos;
}
private:
template <int i> class Selector {};
basic_fbstring& insertImplDiscr(iterator p,
size_type n, value_type c, Selector<1>) {
Invariant checker(*this);
(void) checker;
assert(p >= begin() && p <= end());
if (capacity() - size() < n) {
const size_type sz = p - begin();
reserve(size() + n);
p = begin() + sz;
}
const iterator oldEnd = end();
if( n < size_type(oldEnd - p)) {
append(oldEnd - n, oldEnd);
//std::copy(
// reverse_iterator(oldEnd - n),
// reverse_iterator(p),
// reverse_iterator(oldEnd));
fbstring_detail::pod_move(&*p, &*oldEnd - n, &*p + n);
std::fill(p, p + n, c);
} else {
append(n - (end() - p), c);
append(p, oldEnd);
std::fill(p, oldEnd, c);
}
store_.writeTerminator();
return *this;
}
template<class InputIter>
basic_fbstring& insertImplDiscr(iterator i,
InputIter b, InputIter e, Selector<0>) {
insertImpl(i, b, e,
typename std::iterator_traits<InputIter>::iterator_category());
return *this;
}
template <class FwdIterator>
void insertImpl(iterator i,
FwdIterator s1, FwdIterator s2, std::forward_iterator_tag) {
Invariant checker(*this);
(void) checker;
const size_type pos = i - begin();
const typename std::iterator_traits<FwdIterator>::difference_type n2 =
std::distance(s1, s2);
assert(n2 >= 0);
using namespace fbstring_detail;
assert(pos <= size());
const typename std::iterator_traits<FwdIterator>::difference_type maxn2 =
capacity() - size();
if (maxn2 < n2) {
// realloc the string
reserve(size() + n2);
i = begin() + pos;
}
if (pos + n2 <= size()) {
const iterator tailBegin = end() - n2;
store_.expand_noinit(n2);
fbstring_detail::pod_copy(tailBegin, tailBegin + n2, end() - n2);
std::copy(reverse_iterator(tailBegin), reverse_iterator(i),
reverse_iterator(tailBegin + n2));
std::copy(s1, s2, i);
} else {
FwdIterator t = s1;
const size_type old_size = size();
std::advance(t, old_size - pos);
const size_t newElems = std::distance(t, s2);
store_.expand_noinit(n2);
std::copy(t, s2, begin() + old_size);
fbstring_detail::pod_copy(data() + pos, data() + old_size,
begin() + old_size + newElems);
std::copy(s1, t, i);
}
store_.writeTerminator();
}
template <class InputIterator>
void insertImpl(iterator i,
InputIterator b, InputIterator e, std::input_iterator_tag) {
basic_fbstring temp(begin(), i);
for (; b != e; ++b) {
temp.push_back(*b);
}
temp.append(i, end());
swap(temp);
}
public:
template <class ItOrLength, class ItOrChar>
void insert(iterator p, ItOrLength first_or_n, ItOrChar last_or_c) {
Selector<std::numeric_limits<ItOrLength>::is_specialized> sel;
insertImplDiscr(p, first_or_n, last_or_c, sel);
}
basic_fbstring& erase(size_type pos = 0, size_type n = npos) {
Invariant checker(*this);
(void) checker;
enforce(pos <= length(), std::__throw_out_of_range, "");
procrustes(n, length() - pos);
std::copy(begin() + pos + n, end(), begin() + pos);
resize(length() - n);
return *this;
}
iterator erase(iterator position) {
const size_type pos(position - begin());
enforce(pos <= size(), std::__throw_out_of_range, "");
erase(pos, 1);
return begin() + pos;
}
iterator erase(iterator first, iterator last) {
const size_type pos(first - begin());
erase(pos, last - first);
return begin() + pos;
}
// Replaces at most n1 chars of *this, starting with pos1 with the
// content of str
basic_fbstring& replace(size_type pos1, size_type n1,
const basic_fbstring& str) {
return replace(pos1, n1, str.data(), str.size());
}
// Replaces at most n1 chars of *this, starting with pos1,
// with at most n2 chars of str starting with pos2
basic_fbstring& replace(size_type pos1, size_type n1,
const basic_fbstring& str,
size_type pos2, size_type n2) {
enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
return replace(pos1, n1, str.data() + pos2,
std::min(n2, str.size() - pos2));
}
// Replaces at most n1 chars of *this, starting with pos, with chars from s
basic_fbstring& replace(size_type pos, size_type n1, const value_type* s) {
return replace(pos, n1, s, traits_type::length(s));
}
// Replaces at most n1 chars of *this, starting with pos, with n2
// occurrences of c
//
// consolidated with
//
// Replaces at most n1 chars of *this, starting with pos, with at
// most n2 chars of str. str must have at least n2 chars.
template <class StrOrLength, class NumOrChar>
basic_fbstring& replace(size_type pos, size_type n1,
StrOrLength s_or_n2, NumOrChar n_or_c) {
Invariant checker(*this);
(void) checker;
enforce(pos <= size(), std::__throw_out_of_range, "");
procrustes(n1, length() - pos);
const iterator b = begin() + pos;
return replace(b, b + n1, s_or_n2, n_or_c);
}
basic_fbstring& replace(iterator i1, iterator i2, const basic_fbstring& str) {
return replace(i1, i2, str.data(), str.length());
}
basic_fbstring& replace(iterator i1, iterator i2, const value_type* s) {
return replace(i1, i2, s, traits_type::length(s));
}
private:
basic_fbstring& replaceImplDiscr(iterator i1, iterator i2,
const value_type* s, size_type n,
Selector<2>) {
assert(i1 <= i2);
assert(begin() <= i1 && i1 <= end());
assert(begin() <= i2 && i2 <= end());
return replace(i1, i2, s, s + n);
}
basic_fbstring& replaceImplDiscr(iterator i1, iterator i2,
size_type n2, value_type c, Selector<1>) {
const size_type n1 = i2 - i1;
if (n1 > n2) {
std::fill(i1, i1 + n2, c);
erase(i1 + n2, i2);
} else {
std::fill(i1, i2, c);
insert(i2, n2 - n1, c);
}
assert(isSane());
return *this;
}
template <class InputIter>
basic_fbstring& replaceImplDiscr(iterator i1, iterator i2,
InputIter b, InputIter e,
Selector<0>) {
replaceImpl(i1, i2, b, e,
typename std::iterator_traits<InputIter>::iterator_category());
return *this;
}
private:
template <class FwdIterator, class P>
bool replaceAliased(iterator i1, iterator i2,
FwdIterator s1, FwdIterator s2, P*) {
return false;
}
template <class FwdIterator>
bool replaceAliased(iterator i1, iterator i2,
FwdIterator s1, FwdIterator s2, value_type*) {
static const std::less_equal<const value_type*> le =
std::less_equal<const value_type*>();
const bool aliased = le(&*begin(), &*s1) && le(&*s1, &*end());
if (!aliased) {
return false;
}
// Aliased replace, copy to new string
basic_fbstring temp;
temp.reserve(size() - (i2 - i1) + std::distance(s1, s2));
temp.append(begin(), i1).append(s1, s2).append(i2, end());
swap(temp);
return true;
}
public:
template <class FwdIterator>
void replaceImpl(iterator i1, iterator i2,
FwdIterator s1, FwdIterator s2, std::forward_iterator_tag) {
Invariant checker(*this);
(void) checker;
// Handle aliased replace
if (replaceAliased(i1, i2, s1, s2, &*s1)) {
return;
}
auto const n1 = i2 - i1;
assert(n1 >= 0);
auto const n2 = std::distance(s1, s2);
assert(n2 >= 0);
if (n1 > n2) {
// shrinks
std::copy(s1, s2, i1);
erase(i1 + n2, i2);
} else {
// grows
fbstring_detail::copy_n(s1, n1, i1);
std::advance(s1, n1);
insert(i2, s1, s2);
}
assert(isSane());
}
template <class InputIterator>
void replaceImpl(iterator i1, iterator i2,
InputIterator b, InputIterator e, std::input_iterator_tag) {
basic_fbstring temp(begin(), i1);
temp.append(b, e).append(i2, end());
swap(temp);
}
public:
template <class T1, class T2>
basic_fbstring& replace(iterator i1, iterator i2,
T1 first_or_n_or_s, T2 last_or_c_or_n) {
const bool
num1 = std::numeric_limits<T1>::is_specialized,
num2 = std::numeric_limits<T2>::is_specialized;
return replaceImplDiscr(
i1, i2, first_or_n_or_s, last_or_c_or_n,
Selector<num1 ? (num2 ? 1 : -1) : (num2 ? 2 : 0)>());
}
size_type copy(value_type* s, size_type n, size_type pos = 0) const {
enforce(pos <= size(), std::__throw_out_of_range, "");
procrustes(n, size() - pos);
fbstring_detail::pod_copy(
data() + pos,
data() + pos + n,
s);
return n;
}
void swap(basic_fbstring& rhs) {
store_.swap(rhs.store_);
}
// 21.3.6 string operations:
const value_type* c_str() const {
return store_.c_str();
}
const value_type* data() const { return c_str(); }
allocator_type get_allocator() const {
return allocator_type();
}
size_type find(const basic_fbstring& str, size_type pos = 0) const {
return find(str.data(), pos, str.length());
}
size_type find(const value_type* needle, const size_type pos,
const size_type nsize) const {
if (!nsize) return pos;
auto const size = this->size();
if (nsize + pos > size) return npos;
// Don't use std::search, use a Boyer-Moore-like trick by comparing
// the last characters first
auto const haystack = data();
auto const nsize_1 = nsize - 1;
auto const lastNeedle = needle[nsize_1];
// Boyer-Moore skip value for the last char in the needle. Zero is
// not a valid value; skip will be computed the first time it's
// needed.
size_type skip = 0;
const E * i = haystack + pos;
auto iEnd = haystack + size - nsize_1;
while (i < iEnd) {
// Boyer-Moore: match the last element in the needle
while (i[nsize_1] != lastNeedle) {
if (++i == iEnd) {
// not found
return npos;
}
}
// Here we know that the last char matches
// Continue in pedestrian mode
for (size_t j = 0; ; ) {
assert(j < nsize);
if (i[j] != needle[j]) {
// Not found, we can skip
// Compute the skip value lazily
if (skip == 0) {
skip = 1;
while (skip <= nsize_1 && needle[nsize_1 - skip] != lastNeedle) {
++skip;
}
}
i += skip;
break;
}
// Check if done searching
if (++j == nsize) {
// Yay
return i - haystack;
}
}
}
return npos;
}
size_type find(const value_type* s, size_type pos = 0) const {
return find(s, pos, traits_type::length(s));
}
size_type find (value_type c, size_type pos = 0) const {
return find(&c, pos, 1);
}
size_type rfind(const basic_fbstring& str, size_type pos = npos) const {
return rfind(str.data(), pos, str.length());
}
size_type rfind(const value_type* s, size_type pos, size_type n) const {
if (n > length()) return npos;
pos = std::min(pos, length() - n);
if (n == 0) return pos;
const_iterator i(begin() + pos);
for (; ; --i) {
if (traits_type::eq(*i, *s)
&& traits_type::compare(&*i, s, n) == 0) {
return i - begin();
}
if (i == begin()) break;
}
return npos;
}
size_type rfind(const value_type* s, size_type pos = npos) const {
return rfind(s, pos, traits_type::length(s));
}
size_type rfind(value_type c, size_type pos = npos) const {
return rfind(&c, pos, 1);
}
size_type find_first_of(const basic_fbstring& str, size_type pos = 0) const {
return find_first_of(str.data(), pos, str.length());
}
size_type find_first_of(const value_type* s,
size_type pos, size_type n) const {
if (pos > length() || n == 0) return npos;
const_iterator i(begin() + pos),
finish(end());
for (; i != finish; ++i) {
if (traits_type::find(s, n, *i) != 0) {
return i - begin();
}
}
return npos;
}
size_type find_first_of(const value_type* s, size_type pos = 0) const {
return find_first_of(s, pos, traits_type::length(s));
}
size_type find_first_of(value_type c, size_type pos = 0) const {
return find_first_of(&c, pos, 1);
}
size_type find_last_of (const basic_fbstring& str,
size_type pos = npos) const {
return find_last_of(str.data(), pos, str.length());
}
size_type find_last_of (const value_type* s, size_type pos,
size_type n) const {
if (!empty() && n > 0) {
pos = std::min(pos, length() - 1);
const_iterator i(begin() + pos);
for (;; --i) {
if (traits_type::find(s, n, *i) != 0) {
return i - begin();
}
if (i == begin()) break;
}
}
return npos;
}
size_type find_last_of (const value_type* s,
size_type pos = npos) const {
return find_last_of(s, pos, traits_type::length(s));
}
size_type find_last_of (value_type c, size_type pos = npos) const {
return find_last_of(&c, pos, 1);
}
size_type find_first_not_of(const basic_fbstring& str,
size_type pos = 0) const {
return find_first_not_of(str.data(), pos, str.size());
}
size_type find_first_not_of(const value_type* s, size_type pos,
size_type n) const {
if (pos < length()) {
const_iterator
i(begin() + pos),
finish(end());
for (; i != finish; ++i) {
if (traits_type::find(s, n, *i) == 0) {
return i - begin();
}
}
}
return npos;
}
size_type find_first_not_of(const value_type* s,
size_type pos = 0) const {
return find_first_not_of(s, pos, traits_type::length(s));
}
size_type find_first_not_of(value_type c, size_type pos = 0) const {
return find_first_not_of(&c, pos, 1);
}
size_type find_last_not_of(const basic_fbstring& str,
size_type pos = npos) const {
return find_last_not_of(str.data(), pos, str.length());
}
size_type find_last_not_of(const value_type* s, size_type pos,
size_type n) const {
if (!this->empty()) {
pos = std::min(pos, size() - 1);
const_iterator i(begin() + pos);
for (;; --i) {
if (traits_type::find(s, n, *i) == 0) {
return i - begin();
}
if (i == begin()) break;
}
}
return npos;
}
size_type find_last_not_of(const value_type* s,
size_type pos = npos) const {
return find_last_not_of(s, pos, traits_type::length(s));
}
size_type find_last_not_of (value_type c, size_type pos = npos) const {
return find_last_not_of(&c, pos, 1);
}
basic_fbstring substr(size_type pos = 0, size_type n = npos) const {
enforce(pos <= size(), std::__throw_out_of_range, "");
return basic_fbstring(data() + pos, std::min(n, size() - pos));
}
int compare(const basic_fbstring& str) const {
// FIX due to Goncalo N M de Carvalho July 18, 2005
return compare(0, size(), str);
}
int compare(size_type pos1, size_type n1,
const basic_fbstring& str) const {
return compare(pos1, n1, str.data(), str.size());
}
int compare(size_type pos1, size_type n1,
const value_type* s) const {
return compare(pos1, n1, s, traits_type::length(s));
}
int compare(size_type pos1, size_type n1,
const value_type* s, size_type n2) const {
enforce(pos1 <= size(), std::__throw_out_of_range, "");
procrustes(n1, size() - pos1);
// The line below fixed by Jean-Francois Bastien, 04-23-2007. Thanks!
const int r = traits_type::compare(pos1 + data(), s, std::min(n1, n2));
return r != 0 ? r : n1 > n2 ? 1 : n1 < n2 ? -1 : 0;
}
int compare(size_type pos1, size_type n1,
const basic_fbstring& str,
size_type pos2, size_type n2) const {
enforce(pos2 <= str.size(), std::__throw_out_of_range, "");
return compare(pos1, n1, str.data() + pos2,
std::min(n2, str.size() - pos2));
}
// Code from Jean-Francois Bastien (03/26/2007)
int compare(const value_type* s) const {
// Could forward to compare(0, size(), s, traits_type::length(s))
// but that does two extra checks
const size_type n1(size()), n2(traits_type::length(s));
const int r = traits_type::compare(data(), s, std::min(n1, n2));
return r != 0 ? r : n1 > n2 ? 1 : n1 < n2 ? -1 : 0;
}
private:
// Data
Storage store_;
};
// non-member functions
// C++11 21.4.8.1/2
template <typename E, class T, class A, class S>
inline
basic_fbstring<E, T, A, S> operator+(const basic_fbstring<E, T, A, S>& lhs,
const basic_fbstring<E, T, A, S>& rhs) {
basic_fbstring<E, T, A, S> result;
result.reserve(lhs.size() + rhs.size());
result.append(lhs).append(rhs);
return std::move(result);
}
// C++11 21.4.8.1/2
template <typename E, class T, class A, class S>
inline
basic_fbstring<E, T, A, S> operator+(basic_fbstring<E, T, A, S>&& lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return std::move(lhs.append(rhs));
}
// C++11 21.4.8.1/3
template <typename E, class T, class A, class S>
inline
basic_fbstring<E, T, A, S> operator+(const basic_fbstring<E, T, A, S>& lhs,
basic_fbstring<E, T, A, S>&& rhs) {
if (rhs.capacity() >= lhs.size() + rhs.size()) {
// Good, at least we don't need to reallocate
return std::move(rhs.insert(0, lhs));
}
// Meh, no go. Forward to operator+(const&, const&).
auto const& rhsC = rhs;
return lhs + rhsC;
}
// C++11 21.4.8.1/4
template <typename E, class T, class A, class S>
inline
basic_fbstring<E, T, A, S> operator+(basic_fbstring<E, T, A, S>&& lhs,
basic_fbstring<E, T, A, S>&& rhs) {
return std::move(lhs.append(rhs));
}
template <typename E, class T, class A, class S>
inline
basic_fbstring<E, T, A, S> operator+(
const typename basic_fbstring<E, T, A, S>::value_type* lhs,
const basic_fbstring<E, T, A, S>& rhs) {
//
basic_fbstring<E, T, A, S> result;
const typename basic_fbstring<E, T, A, S>::size_type len =
basic_fbstring<E, T, A, S>::traits_type::length(lhs);
result.reserve(len + rhs.size());
result.append(lhs, len).append(rhs);
return result;
}
template <typename E, class T, class A, class S>
inline
basic_fbstring<E, T, A, S> operator+(
typename basic_fbstring<E, T, A, S>::value_type lhs,
const basic_fbstring<E, T, A, S>& rhs) {
basic_fbstring<E, T, A, S> result;
result.reserve(1 + rhs.size());
result.push_back(lhs);
result.append(rhs);
return result;
}
template <typename E, class T, class A, class S>
inline
basic_fbstring<E, T, A, S> operator+(
const basic_fbstring<E, T, A, S>& lhs,
const typename basic_fbstring<E, T, A, S>::value_type* rhs) {
typedef typename basic_fbstring<E, T, A, S>::size_type size_type;
typedef typename basic_fbstring<E, T, A, S>::traits_type traits_type;
basic_fbstring<E, T, A, S> result;
const size_type len = traits_type::length(rhs);
result.reserve(lhs.size() + len);
result.append(lhs).append(rhs, len);
return result;
}
template <typename E, class T, class A, class S>
inline
basic_fbstring<E, T, A, S> operator+(
const basic_fbstring<E, T, A, S>& lhs,
typename basic_fbstring<E, T, A, S>::value_type rhs) {
basic_fbstring<E, T, A, S> result;
result.reserve(lhs.size() + 1);
result.append(lhs);
result.push_back(rhs);
return result;
}
template <typename E, class T, class A, class S>
inline
bool operator==(const basic_fbstring<E, T, A, S>& lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return lhs.size() == rhs.size() && lhs.compare(rhs) == 0; }
template <typename E, class T, class A, class S>
inline
bool operator==(const typename basic_fbstring<E, T, A, S>::value_type* lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return rhs == lhs; }
template <typename E, class T, class A, class S>
inline
bool operator==(const basic_fbstring<E, T, A, S>& lhs,
const typename basic_fbstring<E, T, A, S>::value_type* rhs) {
return lhs.compare(rhs) == 0; }
template <typename E, class T, class A, class S>
inline
bool operator!=(const basic_fbstring<E, T, A, S>& lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return !(lhs == rhs); }
template <typename E, class T, class A, class S>
inline
bool operator!=(const typename basic_fbstring<E, T, A, S>::value_type* lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return !(lhs == rhs); }
template <typename E, class T, class A, class S>
inline
bool operator!=(const basic_fbstring<E, T, A, S>& lhs,
const typename basic_fbstring<E, T, A, S>::value_type* rhs) {
return !(lhs == rhs); }
template <typename E, class T, class A, class S>
inline
bool operator<(const basic_fbstring<E, T, A, S>& lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return lhs.compare(rhs) < 0; }
template <typename E, class T, class A, class S>
inline
bool operator<(const basic_fbstring<E, T, A, S>& lhs,
const typename basic_fbstring<E, T, A, S>::value_type* rhs) {
return lhs.compare(rhs) < 0; }
template <typename E, class T, class A, class S>
inline
bool operator<(const typename basic_fbstring<E, T, A, S>::value_type* lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return rhs.compare(lhs) > 0; }
template <typename E, class T, class A, class S>
inline
bool operator>(const basic_fbstring<E, T, A, S>& lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return rhs < lhs; }
template <typename E, class T, class A, class S>
inline
bool operator>(const basic_fbstring<E, T, A, S>& lhs,
const typename basic_fbstring<E, T, A, S>::value_type* rhs) {
return rhs < lhs; }
template <typename E, class T, class A, class S>
inline
bool operator>(const typename basic_fbstring<E, T, A, S>::value_type* lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return rhs < lhs; }
template <typename E, class T, class A, class S>
inline
bool operator<=(const basic_fbstring<E, T, A, S>& lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return !(rhs < lhs); }
template <typename E, class T, class A, class S>
inline
bool operator<=(const basic_fbstring<E, T, A, S>& lhs,
const typename basic_fbstring<E, T, A, S>::value_type* rhs) {
return !(rhs < lhs); }
template <typename E, class T, class A, class S>
inline
bool operator<=(const typename basic_fbstring<E, T, A, S>::value_type* lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return !(rhs < lhs); }
template <typename E, class T, class A, class S>
inline
bool operator>=(const basic_fbstring<E, T, A, S>& lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return !(lhs < rhs); }
template <typename E, class T, class A, class S>
inline
bool operator>=(const basic_fbstring<E, T, A, S>& lhs,
const typename basic_fbstring<E, T, A, S>::value_type* rhs) {
return !(lhs < rhs); }
template <typename E, class T, class A, class S>
inline
bool operator>=(const typename basic_fbstring<E, T, A, S>::value_type* lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return !(lhs < rhs);
}
// subclause 21.3.7.8:
template <typename E, class T, class A, class S>
void swap(basic_fbstring<E, T, A, S>& lhs, basic_fbstring<E, T, A, S>& rhs) {
lhs.swap(rhs);
}
// TODO: make this faster.
template <typename E, class T, class A, class S>
inline
std::basic_istream<
typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>&
operator>>(
std::basic_istream<typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>& is,
basic_fbstring<E, T, A, S>& str) {
typename std::basic_istream<E, T>::sentry sentry(is);
typedef std::basic_istream<typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>
__istream_type;
typedef typename __istream_type::ios_base __ios_base;
size_t extracted = 0;
auto err = __ios_base::goodbit;
if (sentry) {
auto n = is.width();
if (n == 0) {
n = str.max_size();
}
str.erase();
auto got = is.rdbuf()->sgetc();
for (; extracted != n && got != T::eof() && !isspace(got); ++extracted) {
// Whew. We get to store this guy
str.push_back(got);
got = is.rdbuf()->snextc();
}
if (got == T::eof()) {
err |= __ios_base::eofbit;
is.width(0);
}
}
if (!extracted) {
err |= __ios_base::failbit;
}
if (err) {
is.setstate(err);
}
return is;
}
template <typename E, class T, class A, class S>
inline
std::basic_ostream<typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>&
operator<<(
std::basic_ostream<typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>& os,
const basic_fbstring<E, T, A, S>& str) {
os.write(str.data(), str.size());
return os;
}
#ifndef _LIBSTDCXX_FBSTRING
template <typename E, class T, class A, class S>
inline
std::basic_istream<typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>&
getline(
std::basic_istream<typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>& is,
basic_fbstring<E, T, A, S>& str,
typename basic_fbstring<E, T, A, S>::value_type delim) {
// Use the nonstandard getdelim()
char * buf = NULL;
size_t size = 0;
for (;;) {
// This looks quadratic but it really depends on realloc
auto const newSize = size + 128;
buf = static_cast<char*>(checkedRealloc(buf, newSize));
is.getline(buf + size, newSize - size, delim);
if (is.bad() || is.eof() || !is.fail()) {
// done by either failure, end of file, or normal read
size += std::strlen(buf + size);
break;
}
// Here we have failed due to too short a buffer
// Minus one to discount the terminating '\0'
size = newSize - 1;
assert(buf[size] == 0);
// Clear the error so we can continue reading
is.clear();
}
basic_fbstring<E, T, A, S> result(buf, size, size + 1,
AcquireMallocatedString());
result.swap(str);
return is;
}
template <typename E, class T, class A, class S>
inline
std::basic_istream<typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>&
getline(
std::basic_istream<typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>& is,
basic_fbstring<E, T, A, S>& str) {
// Just forward to the version with a delimiter
return getline(is, str, '\n');
}
#endif
template <typename E1, class T, class A, class S>
const typename basic_fbstring<E1, T, A, S>::size_type
basic_fbstring<E1, T, A, S>::npos =
static_cast<typename basic_fbstring<E1, T, A, S>::size_type>(-1);
#ifndef _LIBSTDCXX_FBSTRING
// basic_string compatibility routines
template <typename E, class T, class A, class S>
inline
bool operator==(const basic_fbstring<E, T, A, S>& lhs,
const std::string& rhs) {
return lhs.compare(0, lhs.size(), rhs.data(), rhs.size()) == 0;
}
template <typename E, class T, class A, class S>
inline
bool operator==(const std::string& lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return rhs == lhs;
}
template <typename E, class T, class A, class S>
inline
bool operator!=(const basic_fbstring<E, T, A, S>& lhs,
const std::string& rhs) {
return !(lhs == rhs);
}
template <typename E, class T, class A, class S>
inline
bool operator!=(const std::string& lhs,
const basic_fbstring<E, T, A, S>& rhs) {
return !(lhs == rhs);
}
#if !defined(_LIBSTDCXX_FBSTRING)
typedef basic_fbstring<char> fbstring;
#endif
// fbstring is relocatable
template <class T, class R, class A, class S>
FOLLY_ASSUME_RELOCATABLE(basic_fbstring<T, R, A, S>);
#else
_GLIBCXX_END_NAMESPACE_VERSION
#endif
} // namespace folly
#ifndef _LIBSTDCXX_FBSTRING
namespace std {
template <>
struct hash< ::folly::fbstring> {
size_t operator()(const ::folly::fbstring& s) const {
return ::folly::hash::fnv32_buf(s.data(), s.size());
}
};
}
#endif // _LIBSTDCXX_FBSTRING
#undef FBSTRING_LIKELY
#undef FBSTRING_UNLIKELY
#endif // FOLLY_BASE_FBSTRING_H_
| [
"sgolemon@fb.com"
] | sgolemon@fb.com |
d091c533436431cceeb39cb88b8be331a867aedb | 3e54595cb3634edb4c60eafdbe7cba0b867281d6 | /luogu/1825/1.cpp | 62f97cdab6460b8ff660151d5aa29e93e1eeb34e | [] | no_license | Rainboylvx/pcs | 1666cc554903827b98d82689fdccc2d76bda8552 | 5dd54decfc75960194d415c09119d95bef7c27a9 | refs/heads/master | 2023-08-18T10:02:21.270507 | 2023-08-13T01:36:52 | 2023-08-13T01:36:52 | 219,274,550 | 0 | 0 | null | 2023-07-21T09:19:37 | 2019-11-03T09:56:59 | C++ | UTF-8 | C++ | false | false | 2,451 | cpp | /* author: Rainboy email: rainboylvx@qq.com time: 2022年 02月 13日 星期日 19:37:03 CST */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3+5,maxe = 1e3+5; //点与边的数量
/* 顺时针-4个方向 */
int fx[][2] = { {-1,0}, {0,1}, {1,0}, {0,-1} };
int n,m;
/* 定义全局变量 */
bool in_mg(int x,int y){
return x >= 1 && x <=n && y >=0 && y<m;
}
struct node {
int x,y,s;
};
bool vis[maxn][maxn];
string mg[maxn];
int sx,sy,tx,ty;
vector<node> v[30]; //存这样的一对装置
void init(){
std::cin >> n >> m;
for(int i=1;i<=n;++i){
std::cin >> mg[i]; //读取了一行字符串
for(int j=0;j<=m-1;++j){
if( mg[i][j] == '='){
tx = i;
ty = j;
}
else if(mg[i][j] == '@'){
sx = i;
sy = j;
}
//else if(mg[i][j] >= 'A' || mg[i][j] <= 'Z'){
else if(std::isupper(mg[i][j])){
v[mg[i][j] - 'A'].push_back({i,j,0}); // 装存置
}
}
}
}
int bfs(){
queue<node> q;
q.push({sx,sy,0});
vis[sx][sy] = 1;
while ( !q.empty() ) {
node h = q.front();
//std::cout << h.x <<" "<< h.y <<" "<< h.s << std::endl;
q.pop();
if( h.x == tx && h.y == ty ) return h.s;
for(int i=0;i<=3;++i){
int nx = h.x + fx[i][0];
int ny = h.y + fx[i][1];
if( in_mg(nx, ny) && mg[nx][ny] != '#' && vis[nx][ny] == 0){
if( isupper(mg[nx][ny])){ //是传送门
int t = mg[nx][ny] - 'A';
vis[nx][ny] = 1;
for(int k = 0 ;k < v[t].size() ; ++k){
if( v[t][k].x != nx || v[t][k].y != ny ){
nx = v[t][k].x;
ny = v[t][k].y;
break;
}
}
//if( vis[nx][ny] == 0){
q.push({nx,ny,h.s+1});
//vis[nx][ny] = 1;
//}
}
else { //no portable
q.push({nx,ny,h.s+1});
vis[nx][ny] = 1;
}
}
}
}
return -1;
}
int main(int argc,char * argv[]){
init();
int ans = bfs();
std::cout << ans << std::endl;
return 0;
}
| [
"rainboylvx@qq.com"
] | rainboylvx@qq.com |
526dac80a603fc299213e0ed1d0ba11d3e5d9d59 | b7c32f2aeb0455264fb9e2ab4ff35e4a07056b61 | /LT/cfgfunctions.hpp | 87943fa852002459a0ac2e286a96aabe76452184 | [] | no_license | TaskForce47/BMR_Insurgency.Altis | 99da34cf2b190d89036218c9cb95d06a646c5b1e | a3f3a7c81540bdcaf488510e9a5b0f3ef05109b8 | refs/heads/master | 2021-04-06T20:35:15.807668 | 2018-04-12T11:42:38 | 2018-04-12T11:42:38 | 125,452,326 | 0 | 0 | null | 2018-03-16T02:25:40 | 2018-03-16T02:25:40 | null | UTF-8 | C++ | false | false | 938 | hpp | class LT
{
tag = "LT";
class ltFunctions
{
file = "LT\functions";
class transferMenu { description = "This is a test function that returns a silly string"; };
class transferAction { description = "This is a test function that returns a silly string"; };
class transferNetwork { description = "This is a test function that returns a silly string"; };
class transferLoadout { description = "This is a test function that returns a silly string"; };
class loadoutMenu {};
class loadLoadout {};
class LTaction {};
class LTmenu {};
class saveLoad {};
class manageLoadouts {};
class loadoutChange {};
class loadoutModify {};
class changeName {};
class checkPlayerMenu {};
class trasferCheckPlayerLO {};
class saveLoChange {};
class modifyLoad {};
class saveGear {};
class KRON_StrToArray {};
class KRON_StrRight {};
class KRON_StrLen {};
class KRON_StrLeft {};
class KRON_StrIndex {};
};
};
| [
"Christian.Grandjean@web.de"
] | Christian.Grandjean@web.de |
eedf58ce7d438007e2388902f4353080e0f4b75b | 575c78d3b7a2fe90f4f0624d963bd6111dfca309 | /deps/libIGL/include/igl/smooth_corner_adjacency.cpp | 78eecff9fce1f228180539ca22051f44cb48120c | [
"GPL-3.0-only",
"MPL-2.0",
"MIT"
] | permissive | g-gisbert/Inpainting-Holes-In-Folded-Fabric-Meshes | 1898a35a848f9f16a99653c7c1e95ab0941755cd | ccce75215b742a1c971008c4f1a889bd85b6c74d | refs/heads/main | 2023-08-19T08:49:47.829392 | 2023-08-18T13:55:11 | 2023-08-18T13:55:11 | 648,992,474 | 5 | 2 | MIT | 2023-07-21T15:34:49 | 2023-06-03T12:45:00 | C++ | UTF-8 | C++ | false | false | 3,769 | cpp | #include "smooth_corner_adjacency.h"
#include "vertex_triangle_adjacency.h"
#include "matlab_format.h"
#include "parallel_for.h"
#include "unzip_corners.h"
#include <iostream>
void igl::smooth_corner_adjacency(
const Eigen::MatrixXd & V,
const Eigen::MatrixXi & F,
const double corner_threshold_radians,
Eigen::VectorXi & CI,
Eigen::VectorXi & CC)
{
typedef double Scalar;
typedef Eigen::Index Index;
Eigen::Matrix<Index,Eigen::Dynamic,1> VF,NI;
igl::vertex_triangle_adjacency(F,V.rows(),VF,NI);
// unit normals
Eigen::Matrix<Scalar,Eigen::Dynamic,3,Eigen::RowMajor> FN(F.rows(),3);
igl::parallel_for(F.rows(),[&](const Index f)
{
const Eigen::Matrix<Scalar,1,3> v10 = V.row(F(f,1))-V.row(F(f,0));
const Eigen::Matrix<Scalar,1,3> v20 = V.row(F(f,2))-V.row(F(f,0));
const Eigen::Matrix<Scalar,1,3> n = v10.cross(v20);
const Scalar a = n.norm();
FN.row(f) = n/a;
},10000);
// number of faces
const Index m = F.rows();
// valence of faces
const Index n = F.cols();
assert(n == 3);
CI.resize(m*n*8);
CI.setConstant(-1);
Index ncc = 0;
Index ci = -1;
// assumes that ci is strictly increasing and we're appending to CI
const auto append_CI = [&](Index nf)
{
// make room
if(ncc >= CI.size()) { CI.conservativeResize(CI.size()*2+1); }
CI(ncc++) = nf;
CC(ci+1)++;
};
CC.resize(m*3+1);
CC.setConstant(-1);
CC(0) = 0;
const Scalar cos_thresh = cos(corner_threshold_radians);
// parallelizing this probably requires map-reduce
for(Index i = 0;i<m;i++)
{
// Normal of this face
const auto & fnhat = FN.row(i);
// loop over corners
for(Index j = 0;j<n;j++)
{
// increment ci
ci++;
assert(ci == i*n+j);
CC(ci+1) = CC(ci);
const auto & v = F(i,j);
for(int k = NI(v); k<NI(v+1); k++)
{
const int nf = VF(k);
const auto & ifn = FN.row(nf);
// dot product between face's normal and other face's normal
const Scalar dp = fnhat.dot(ifn);
// if difference in normal is slight then add to average
if(dp > cos_thresh)
{
append_CI(nf);
}
}
}
}
CI.conservativeResize(ncc);
}
void igl::smooth_corner_adjacency(
const Eigen::MatrixXi & FV,
const Eigen::MatrixXi & FN,
Eigen::VectorXi & CI,
Eigen::VectorXi & CC)
{
typedef double Scalar;
typedef Eigen::Index Index;
assert(FV.rows() == FN.rows());
assert(FV.cols() == 3);
assert(FN.cols() == 3);
Eigen::VectorXi J;
Index nu = -1;
{
Eigen::MatrixXi U;
Eigen::MatrixXi _;
igl::unzip_corners<const Eigen::MatrixXi>({FV,FN},U,_,J);
nu = U.rows();
assert(J.maxCoeff() == nu-1);
}
// could use linear arrays here if every becomes bottleneck
std::vector<std::vector<Index>> U2F(nu);
const Index m = FV.rows();
for(Index j = 0;j<3;j++)
{
for(Index i = 0;i<m;i++)
{
// unzip_corners uses convention i+j*#F
const Index ci = i+j*m;
U2F[J(ci)].emplace_back(i);
}
}
CC.resize(m*3+1);
CC.setConstant(-1);
CC(0) = 0;
CI.resize(m*3*8);
int ncc = 0;
// assumes that ci is strictly increasing and we're appending to CI
const auto append_CI = [&CI,&CC,&ncc](Index ci, Index nf)
{
// make room
if(ncc >= CI.size()) { CI.conservativeResize(CI.size()*2+1); }
CI(ncc++) = nf;
CC(ci+1)++;
};
for(Index i = 0;i<m;i++)
{
for(Index j = 0;j<3;j++)
{
const Index J_ci = i+j*m;
// CI,CC uses convention i*3 + j
const Index C_ci = i*3+j;
CC(C_ci+1) = CC(C_ci);
for(const auto & nf : U2F[J(J_ci)])
{
append_CI(C_ci,nf);
}
}
}
CI.conservativeResize(ncc);
}
#ifdef IGL_STATIC_LIBRARY
// Explicit template instantiations
#endif
| [
"gisbert.guillaume1997@gmail.com"
] | gisbert.guillaume1997@gmail.com |
ee5ffbe539be7a7ad0b4cc29b31c5e4ae93fd15e | bd1fea86d862456a2ec9f56d57f8948456d55ee6 | /000/104/260/CWE457_Use_of_Uninitialized_Variable__twointsclass_array_new_partial_init_62a.cpp | d276055ebc5145679f206a9141680e28c8c758df | [] | no_license | CU-0xff/juliet-cpp | d62b8485104d8a9160f29213368324c946f38274 | d8586a217bc94cbcfeeec5d39b12d02e9c6045a2 | refs/heads/master | 2021-03-07T15:44:19.446957 | 2020-03-10T12:45:40 | 2020-03-10T12:45:40 | 246,275,244 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,898 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE457_Use_of_Uninitialized_Variable__twointsclass_array_new_partial_init_62a.cpp
Label Definition File: CWE457_Use_of_Uninitialized_Variable__twointsclass_array.label.xml
Template File: sources-sinks-62a.tmpl.cpp
*/
/*
* @description
* CWE: 457 Use of Uninitialized Variable
* BadSource: partial_init Initialize part, but not all of the array
* GoodSource: Initialize data
* Sinks: use
* GoodSink: Initialize then use data
* BadSink : Use data
* Flow Variant: 62 Data flow: data flows using a C++ reference from one function to another in different source files
*
* */
#include "std_testcase.h"
namespace CWE457_Use_of_Uninitialized_Variable__twointsclass_array_new_partial_init_62
{
#ifndef OMITBAD
/* bad function declaration */
void badSource(TwoIntsClass * &data);
void bad()
{
TwoIntsClass * data;
data = new TwoIntsClass[10];
badSource(data);
/* POTENTIAL FLAW: Use data without initializing it */
for(int i=0; i<10; i++)
{
printIntLine(data[i].intOne);
printIntLine(data[i].intTwo);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSource(TwoIntsClass * &data);
static void goodG2B()
{
TwoIntsClass * data;
data = new TwoIntsClass[10];
goodG2BSource(data);
/* POTENTIAL FLAW: Use data without initializing it */
for(int i=0; i<10; i++)
{
printIntLine(data[i].intOne);
printIntLine(data[i].intTwo);
}
}
/* goodB2G uses the BadSource with the GoodSink */
void goodB2GSource(TwoIntsClass * &data);
static void goodB2G()
{
TwoIntsClass * data;
data = new TwoIntsClass[10];
goodB2GSource(data);
/* FIX: Ensure data is initialized before use */
for(int i=0; i<10; i++)
{
data[i].intOne = i;
data[i].intTwo = i;
}
for(int i=0; i<10; i++)
{
printIntLine(data[i].intOne);
printIntLine(data[i].intTwo);
}
}
void good()
{
goodG2B();
goodB2G();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE457_Use_of_Uninitialized_Variable__twointsclass_array_new_partial_init_62; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| [
"frank@fischer.com.mt"
] | frank@fischer.com.mt |
cd6f38774a1443a8ebffc5f8b0aa91dfc6682929 | bf351c0f68d1c65ca578a39e73e2cd1d3107f62e | /prototype02/src/gola.h | 0daf89bc7021aa1e97a26d58e7b0b35f2ef4c9f0 | [] | no_license | bestpaul1985/differentgames2014 | 724a77b81b36b6fee1ac370a54153c5a7000a0e2 | 02761fe459831ac5b2720ed18f7bb432f503cbda | refs/heads/master | 2021-01-17T09:08:47.453660 | 2014-07-27T13:24:32 | 2014-07-27T13:24:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 359 | h | //
// gola.h
// prototype02
//
// Created by Peng Cheng on 4/8/14.
//
//
#ifndef __prototype02__gola__
#define __prototype02__gola__
#include "ofMain.h"
class gola{
public:
void setup(int where);
bool conllision(ofPoint pos, float radius);
void draw();
ofRectangle rect;
int num;
};
#endif /* defined(__prototype02__gola__) */
| [
"bestpaul1985@gmail.com"
] | bestpaul1985@gmail.com |
b5ea9cb12c740f8574e1efb0cdf6b5f5d7329b89 | 298aede82aee42fbfb8bd14aee3e64dcc6f35d10 | /tools/editor/src/project/reProject.cpp | 58df7b9a6319cc51e019599aa7bf691f7794c7fa | [] | no_license | aedotcom/recondite | dfaa5d5f586ed12830dd0e17bccd8a399c93fb5f | 2de5d92cdd24e8b9edd69f504c5a15380ca1a684 | refs/heads/master | 2021-01-13T06:28:12.440523 | 2015-04-18T23:05:08 | 2015-04-18T23:05:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,452 | cpp | #include "reProject.hpp"
reProject::reProject(rwxComponent* component){
m_component = component;
}
void reProject::Create(const wxString& directory, const wxString& name){
Close();
m_name = name;
m_projectDir.AssignDir(directory);
m_projectDir.AppendDir(name);
wxMkDir(m_projectDir.GetPath(), wxS_DIR_DEFAULT);
wxMkDir(LevelDirPath(), wxS_DIR_DEFAULT);
SaveProjectFile();
}
bool reProject::Open(const wxString& path){
Close();
wxFileName projPath(path);
m_projectDir.AssignDir(projPath.GetPath());
wxXmlDocument doc(path);
wxXmlNode* child = doc.GetRoot()->GetChildren();
while (child){
if (child->GetName() == "name") {
m_name = child->GetNodeContent();
}
if (child->GetName() == "levels") {
wxXmlNode* level = child->GetChildren();
if (level){
while (level){
m_levels.push_back(level->GetNodeContent());
level = level->GetNext();
}
}
}
child = child->GetNext();
}
return true;
}
void reProject::Close(){
if (!IsOpen())
return;
SaveActiveLevel();
SaveProjectFile();
m_projectDir.Clear();
m_name.Clear();
m_levels.Clear();
m_component->GetScene()->Clear();
}
void reProject::SaveProjectFile(){
wxXmlNode* root = new wxXmlNode(wxXML_ELEMENT_NODE, "project");
wxXmlNode* nameElement = new wxXmlNode(root, wxXML_ELEMENT_NODE, "name");
wxXmlNode* nameNode = new wxXmlNode(nameElement, wxXML_TEXT_NODE, "name", m_name);
wxXmlNode* levelsElement = new wxXmlNode(root, wxXML_ELEMENT_NODE, "levels");
for (auto& levelname : m_levels){
wxXmlNode* levelElement = new wxXmlNode(levelsElement, wxXML_ELEMENT_NODE, "level");
wxXmlNode* nameNode = new wxXmlNode(levelElement, wxXML_TEXT_NODE, "level", levelname);
}
wxXmlDocument document;
document.SetRoot(root);
wxString projFile = ProjectFilePath();
document.Save(projFile);
}
wxString reProject::Directory() const{
return m_projectDir.GetPath();
}
wxString reProject::Name() const{
return m_name;
}
wxString reProject::ProjectFilePath() const{
return m_projectDir.GetPathWithSep() + m_name + ".rprj";
}
wxString reProject::LevelDirPath() const{
return m_projectDir.GetPathWithSep() + "levels";
}
bool reProject::IsOpen() const{
return !m_name.IsEmpty();
}
const wxArrayString& reProject::Levels() const{
return m_levels;
}
bool reProject::CheckForValidNewLevelName(const wxString& name){
if (HasLevelNamed(name)){
wxMessageBox("A level with that name already exists.", "Unable To Create New Level", wxOK | wxICON_ERROR);
return false;
}
return true;
}
bool reProject::CreateLevel(const wxString& name){
if (!CheckForValidNewLevelName(name)) return false;
m_levels.push_back(name);
m_activeLevel = name;
m_component->ClearScene();
SaveActiveLevel();
SaveProjectFile();
return true;
}
bool reProject::RenameLevel(const wxString& oldName, const wxString& newName){
if (!CheckForValidNewLevelName(newName)) return false;
for (auto& level : m_levels){
if (level == oldName){
wxString oldLevelPath = LevelFilePath(oldName);
wxString newLevelPath = LevelFilePath(newName);
bool result = wxRenameFile(oldLevelPath, newLevelPath);
if (result){
level = newName;
SaveProjectFile();
}
return result;
}
}
return false;
}
bool reProject::DeleteLevel(const wxString& name){
auto end = m_levels.end();
for (auto it = m_levels.begin(); it != end; ++it){
if (name == *it){
wxString levelPath = LevelFilePath(name);
bool result = wxRemoveFile(levelPath);
if (result){
m_levels.erase(it);
SaveProjectFile();
return true;
}
}
}
return false;
}
wxString reProject::LevelFilePath(const wxString& levelName) const{
return LevelDirPath() + '/' + levelName + ".rlvl";
}
bool reProject::ActivateLevel(const wxString& name){
m_activeLevel = name;
wxString levelPath = LevelFilePath(m_activeLevel);
m_component->ClearScene();
m_component->LoadScene(levelPath.c_str().AsChar());
return true;
}
void reProject::SaveActiveLevel(){
if (!m_activeLevel.IsEmpty()){
wxString levelPath = LevelFilePath(m_activeLevel);
m_component->SaveScene(levelPath.c_str().AsChar());
}
}
bool reProject::HasLevelNamed(const wxString& name){
for (auto& levelName : m_levels){
if (levelName == name)
return true;
}
return false;
} | [
"mlarocca.cpp@gmail.com"
] | mlarocca.cpp@gmail.com |
70cdf8e9fc7b0e0dc3fff98394cb63de5487efbe | 0577a46d8d28e1fd8636893bbdd2b18270bb8eb8 | /chromium/components/webapps/browser/android/webapk/webapk_proto_builder.h | 94994a4358e0ccd291166038b0ab0a21b33368f2 | [
"BSD-3-Clause"
] | permissive | ric2b/Vivaldi-browser | 388a328b4cb838a4c3822357a5529642f86316a5 | 87244f4ee50062e59667bf8b9ca4d5291b6818d7 | refs/heads/master | 2022-12-21T04:44:13.804535 | 2022-12-17T16:30:35 | 2022-12-17T16:30:35 | 86,637,416 | 166 | 41 | BSD-3-Clause | 2021-03-31T18:49:30 | 2017-03-29T23:09:05 | null | UTF-8 | C++ | false | false | 2,940 | h | // Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_WEBAPPS_BROWSER_ANDROID_WEBAPK_WEBAPK_PROTO_BUILDER_H_
#define COMPONENTS_WEBAPPS_BROWSER_ANDROID_WEBAPK_WEBAPK_PROTO_BUILDER_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "components/webapk/webapk.pb.h"
#include "components/webapps/browser/android/shortcut_info.h"
#include "components/webapps/browser/android/webapk/webapk_icon_hasher.h"
#include "components/webapps/browser/android/webapk/webapk_types.h"
#include "url/gurl.h"
namespace base {
class FilePath;
}
namespace webapps {
// Populates webapk::WebApk and returns it.
// Must be called on a worker thread because it encodes an SkBitmap.
// The splash icon can be passed either via |icon_url_to_murmur2_hash| or via
// |splash_icon| parameter. |splash_icon| parameter is only used when the
// splash icon URL is unknown.
std::unique_ptr<std::string> BuildProtoInBackground(
const webapps::ShortcutInfo& shortcut_info,
const GURL& app_key,
const std::string& primary_icon_data,
bool is_primary_icon_maskable,
const std::string& splash_icon_data,
const std::string& package_name,
const std::string& version,
std::map<std::string, WebApkIconHasher::Icon> icon_url_to_murmur2_hash,
bool is_manifest_stale,
bool is_app_identity_update_supported,
std::vector<WebApkUpdateReason> update_reasons);
// Asynchronously builds the WebAPK proto on a background thread.
// Runs |callback| on the calling thread when complete.
void BuildProto(
const webapps::ShortcutInfo& shortcut_info,
const GURL& app_key,
const std::string& primary_icon_data,
bool is_primary_icon_maskable,
const std::string& splash_icon_data,
const std::string& package_name,
const std::string& version,
std::map<std::string, webapps::WebApkIconHasher::Icon>
icon_url_to_murmur2_hash,
bool is_manifest_stale,
bool is_app_identity_update_supported,
base::OnceCallback<void(std::unique_ptr<std::string>)> callback);
// Builds the WebAPK proto for an update request and stores it to
// |update_request_path|. Returns whether the proto was successfully written to
// disk.
bool StoreUpdateRequestToFileInBackground(
const base::FilePath& update_request_path,
const webapps::ShortcutInfo& shortcut_info,
const GURL& app_key,
const std::string& primary_icon_data,
bool is_primary_icon_maskable,
const std::string& splash_icon_data,
const std::string& package_name,
const std::string& version,
std::map<std::string, WebApkIconHasher::Icon> icon_url_to_murmur2_hash,
bool is_manifest_stale,
bool is_app_identity_update_supported,
std::vector<WebApkUpdateReason> update_reasons);
} // namespace webapps
#endif // COMPONENTS_WEBAPPS_BROWSER_ANDROID_WEBAPK_WEBAPK_PROTO_BUILDER_H_
| [
"mathieu.caroff@free.fr"
] | mathieu.caroff@free.fr |
875d3cc1cc50ef0b0427ea06195bd41949942729 | 7d42f88d0621bcdf41cfd5400b5672e8c36746d7 | /mumble/mumble-server/prebuild/src/mumble/mumble_autogen/EWIEGA46WW/moc_WebFetch.cpp | 7c5202e8d909a85c677042a3ef72d00ff571f4d0 | [] | no_license | kiesel-cyber/dockers | aeb0972ea681dbd2d47202a22172b0a333957948 | 31f82be92132d84ccf16f936fb3169f1ffe749eb | refs/heads/main | 2023-08-06T11:06:14.776094 | 2021-09-06T17:46:01 | 2021-09-06T17:46:01 | 405,122,484 | 0 | 0 | null | 2021-09-10T15:13:20 | 2021-09-10T15:13:20 | null | UTF-8 | C++ | false | false | 4,668 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'WebFetch.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.12.8)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "WebFetch.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'WebFetch.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.12.8. 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
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_WebFetch_t {
QByteArrayData data[8];
char stringdata0[66];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_WebFetch_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_WebFetch_t qt_meta_stringdata_WebFetch = {
{
QT_MOC_LITERAL(0, 0, 8), // "WebFetch"
QT_MOC_LITERAL(1, 9, 7), // "fetched"
QT_MOC_LITERAL(2, 17, 0), // ""
QT_MOC_LITERAL(3, 18, 4), // "data"
QT_MOC_LITERAL(4, 23, 3), // "url"
QT_MOC_LITERAL(5, 27, 21), // "QMap<QString,QString>"
QT_MOC_LITERAL(6, 49, 7), // "headers"
QT_MOC_LITERAL(7, 57, 8) // "finished"
},
"WebFetch\0fetched\0\0data\0url\0"
"QMap<QString,QString>\0headers\0finished"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_WebFetch[] = {
// content:
8, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
1, // signalCount
// signals: name, argc, parameters, tag, flags
1, 3, 24, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
7, 0, 31, 2, 0x09 /* Protected */,
// signals: parameters
QMetaType::Void, QMetaType::QByteArray, QMetaType::QUrl, 0x80000000 | 5, 3, 4, 6,
// slots: parameters
QMetaType::Void,
0 // eod
};
void WebFetch::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
auto *_t = static_cast<WebFetch *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->fetched((*reinterpret_cast< QByteArray(*)>(_a[1])),(*reinterpret_cast< QUrl(*)>(_a[2])),(*reinterpret_cast< QMap<QString,QString>(*)>(_a[3]))); break;
case 1: _t->finished(); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
int *result = reinterpret_cast<int *>(_a[0]);
{
using _t = void (WebFetch::*)(QByteArray , QUrl , QMap<QString,QString> );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&WebFetch::fetched)) {
*result = 0;
return;
}
}
}
}
QT_INIT_METAOBJECT const QMetaObject WebFetch::staticMetaObject = { {
&QObject::staticMetaObject,
qt_meta_stringdata_WebFetch.data,
qt_meta_data_WebFetch,
qt_static_metacall,
nullptr,
nullptr
} };
const QMetaObject *WebFetch::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *WebFetch::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_WebFetch.stringdata0))
return static_cast<void*>(this);
return QObject::qt_metacast(_clname);
}
int WebFetch::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QObject::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 2)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 2)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 2;
}
return _id;
}
// SIGNAL 0
void WebFetch::fetched(QByteArray _t1, QUrl _t2, QMap<QString,QString> _t3)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)), const_cast<void*>(reinterpret_cast<const void*>(&_t3)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
| [
"JanErWi@aol.com"
] | JanErWi@aol.com |
8b993e3a7b771972e8c9a1ecb75d5697b9560340 | 2f8b2796468d6884a86c5adfc360c0b369532075 | /modulooperator.h | ad82cded4c71fe29616e04929fdc63a678a035a4 | [] | no_license | bilasyurii/botura | 4f5da6a031f3268af5c05d546161c95295a45e55 | 8b492fd4aaa834db5d71f0426dd8761ed8071368 | refs/heads/master | 2022-04-06T07:05:53.551714 | 2019-10-20T18:07:58 | 2019-10-20T18:07:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 287 | h | #ifndef MODULOOPERATOR_H
#define MODULOOPERATOR_H
#include "binaryoperator.h"
class ModuloOperator : public BinaryOperator
{
public:
ModuloOperator(Expression *l, Expression *r);
virtual Expression *evaluate();
virtual ~ModuloOperator() {}
};
#endif // MODULOOPERATOR_H
| [
"dealog3@gmail.com"
] | dealog3@gmail.com |
2ffcb7363dcb2e5a142aa6731fe91388f802f51d | 35e0afd95984699d46057564416e048e39187748 | /2020-05-17/hanoi.cpp | d6cf0bdc58b7d4bcf88a44d7b7ab6f9ad7382b5f | [] | no_license | shudubus/OI_in__No.7_high_school | d552c50ff33d57c81dea72d067aeb059b99bdd30 | fe25eaabd0df7447167146afe516969fb6ee0f3d | refs/heads/master | 2022-11-29T17:37:59.731893 | 2020-08-10T03:11:26 | 2020-08-10T03:11:26 | 285,466,589 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 758 | cpp | #include<cstdio>
void movehn( int num, char star, char last )
{
printf ( "Move %d From %c to %c\n", num, star, last );
}
int hanoi( int cen, char A, char B, char C )
{
if ( cen == 1 )/*如果剩余层数为1,直接把他挪到c柱子*/
{
movehn( 1, A, C );
}
else/*否则*/
{
hanoi( cen-1, A, C, B );/*把除了最下面的所有圆盘从A柱挪到B柱*/
movehn( cen, A, C ); /*再把最下面的圆盘从A注挪到C柱*/
hanoi( cen-1, B, A, C );/*再把除了最下面的所有圆盘从B柱挪到C柱*/
}
}
int game()
{
int n;
char a, b, c;
scanf( "%d %c %c %c", &n, &a, &b, &c );
hanoi( n, a, b, c );
return 0;
}
int main( int argc, char**argv )
{
game();
}
| [
"shudubus@icloud.com"
] | shudubus@icloud.com |
5b1b4177a54c61642c66f7393b50e03d8dad5cb7 | 774143ca84fefa22a038d20998558b86cda39711 | /SortAlgorithms/lain.h | 18e8542ad3806da3d15be3c69674939632d38cb3 | [] | no_license | Comcx/Algo_lib | 39488bf1d9b6bd30603db8a05a980d1be570bc33 | d4ea4a2714ba1637ee8be503f86dff3b89645049 | refs/heads/master | 2021-01-01T15:56:31.837553 | 2017-08-05T11:29:00 | 2017-08-05T11:29:00 | 97,735,521 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,886 | h | /*
* Copyright (c) 2017 , LAIN
* All rights reserved
*
* name : lain.h
* contents :
*
* developed by Comcx
* created time : prefecting...
*
*/
#ifndef LAIN_H
#define LAIN_H
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cctype>
#include <cmath>
#define OK 1
#define ERROR -1
#define TRUE 1
#define FALSE 0
#define STOP 0
//=========================================================================
//Arsenal
template<class T>
class Comparable{
public:
virtual ~Comparable() {}
virtual bool compareTo(T a , T b , bool (*less)(T,T)) const = 0;
virtual void exch(int i , int j) = 0;
virtual bool isSorted(int lo , int hi , bool (*less)(T,T)) = 0;
virtual void sort(bool (*less)(T,T)) = 0;
virtual void sort(void (*_sort)(T a[] , int len , bool(*less)(T,T)) , bool(*less)(T,T)) = 0;
virtual void sort(void (*_sort)(T a[] , int lo , int hi , bool(*less)(T,T)) , bool(*less)(T,T) , int lo , int hi) = 0;
};
//-------------------------------------------------------------------------
//the abstract class of linear list
template<class T>
class LinearList{
public:
virtual ~LinearList() {};
virtual bool empty() const = 0;
virtual int size() const = 0;
virtual T& get(int theIndex) const = 0;
virtual int indexOf(const T& theElem) const = 0;
virtual void erase(int theIndex) = 0;
virtual void insert(int theIndex , const T& theElem) = 0;
virtual void show(std::ostream& out) const = 0;
};
//------------------------------------------------------------------------
//node defination for linked list
template<class T>
struct ChainNode{
T elem;
ChainNode<T> *next;
ChainNode() {}
ChainNode(const T& theElem) {this->elem = theElem;}
ChainNode(const T& theElem , ChainNode<T> *next){
this->elem = theElem;
this->next = next;
}
};
//the linked list which extends from linear list
template<class T>
class LinkedList : public LinearList<T>{
protected:
int listSize;
ChainNode<T> *firstNode;
void checkIndex(int theIndex) const;
public:
LinkedList(int initialCapacity = 20); //construction
LinkedList(const LinkedList<T>&); //copy to struct
~LinkedList(); //delete the whole linked list
bool empty() const {return listSize==0;}
int size() const {return listSize;}
T& get(int theIndex) const; //get the element of theIndex
inline ChainNode<T> *findPrior(int theIndex);
inline ChainNode<T> *findLast();
int indexOf(const T& theElem) const; //return the index of theElem
void erase(int theIndex); //erase the theIndexth node
void insert(int theIndex , const T& theElem); // insert theElem to make the node be the
// theIndexth node
void pushBack(const T &theElem);
T popBack();
void show(std::ostream& out) const;
};
template<class T>
class LinkedStack : public LinkedList<T> {};
template<class T>
LinkedList<T>::LinkedList(int initialCapacity)
{
if(initialCapacity < 1)
{
std::ostringstream s;
s << "initialCapacity = " << initialCapacity << "Must be > 0";
std::cerr << s.str();
}
this->firstNode = NULL;
this->listSize = 0;
}
template<class T>
LinkedList<T>::LinkedList(const LinkedList<T>& theList)
{
this->listSize = theList.listSize;
if(listSize == 0)
{
this->firstNode = NULL;
return;
}
ChainNode<T> *sourceNode = theList.firstNode;
firstNode = new ChainNode<T>(sourceNode->elem);
sourceNode = sourceNode->next;
ChainNode<T> *targetNode = firstNode;
while(sourceNode != NULL)
{
targetNode->next = new ChainNode<T>(sourceNode->elem);
targetNode = targetNode->next;
sourceNode = sourceNode->next;
}
targetNode->next = NULL;
}
template<class T>
LinkedList<T>::~LinkedList()
{
while(firstNode != NULL)
{
ChainNode<T> *nextNode = firstNode->next;
delete firstNode;
firstNode = nextNode;
}
}
template<class T>
T& LinkedList<T>::get(int theIndex) const
{
ChainNode<T> *currentNode = this->firstNode;
for(int i=0 ; i<theIndex ; i++)
{
currentNode = currentNode->next;
}
return currentNode->elem;
}
template<class T>
ChainNode<T>* LinkedList<T>::findPrior(int theIndex)
{
ChainNode<T> *priorNode = this->firstNode;
for(int i=0 ; i<theIndex-1 ; i++) //find the prior node of the theIndexth node
{
priorNode = priorNode->next;
}
return priorNode;
}
template<class T>
ChainNode<T> *LinkedList<T>::findLast()
{
ChainNode<T> *currentNode = this->firstNode;
while(currentNode->next != NULL)
{
currentNode = currentNode->next;
}
return currentNode;
}
template<class T>
int LinkedList<T>::indexOf(const T& theElem) const
{
ChainNode<T> *currentNode = this->firstNode;
int index = 0;
while(currentNode != NULL &&
currentNode->elem != theElem)
{
currentNode = currentNode->next;
index++;
}
if(currentNode == NULL) return FALSE;
else
return index;
}
template<class T>
void LinkedList<T>::erase(int theIndex)
{
checkIndex(theIndex);
ChainNode<T> *targetNode = this->firstNode;
if(theIndex == 0)
{
this->firstNode = this->firstNode->next;
}
else
{
ChainNode<T> *priorNode = findPrior(theIndex);
targetNode = priorNode->next;
priorNode->next = priorNode->next->next;
}
delete targetNode;
this->listSize--;
}
template<class T>
void LinkedList<T>::insert(int theIndex , const T& theElem)
{
if(theIndex<0 || theIndex>listSize)
{
std::ostringstream os;
os << "index = " << theIndex << " size = " << listSize;
std::cerr << os.str();
return;
}
if(theIndex == 0)
{
this->firstNode = new ChainNode<T>(theElem , firstNode);
}
else
{
ChainNode<T> *priorNode = findPrior(theIndex);
ChainNode<T> *targetNode = new ChainNode<T>(theElem , priorNode->next);
priorNode->next = targetNode;
}
this->listSize++;
}
template<class T>
void LinkedList<T>::pushBack(const T &theElem)
{
insert(listSize , theElem);
}
template<class T>
T LinkedList<T>::popBack()
{
T target = get(listSize-1);
erase(listSize-1);
return target;
}
template<class T>
void LinkedList<T>::show(std::ostream &out) const
{
ChainNode<T> *currentNode = this->firstNode;
while(currentNode != NULL)
{
out << currentNode->elem << " ";
currentNode = currentNode->next;
}
}
template<class T>
void LinkedList<T>::checkIndex(int theIndex) const
{
if(theIndex<0 || theIndex>listSize-1)
{
std::ostringstream os;
os << "index = " << theIndex << " size = " << listSize;
std::cerr << os.str();
}
}
template<class T>
std::ostream& operator<<(std::ostream& out , const LinkedList<T> &x)
{
x.show(out);
return out;
}
//---------------------------------------------------------------------------
//ArrayList(Stack)
template<class T>
class ArrayList : public LinearList<T> , public Comparable<T>{
protected:
T *elem;
int top;
int capacity;
int listSize;
void checkIndex(int theIndex) const;
public:
ArrayList(int capacity = 20);
ArrayList(const ArrayList<T>&);
~ArrayList() {delete [] elem;}
bool empty() const {return listSize == 0;}
int size() const {return listSize;}
T& get(int theIndex) const;
int indexOf(const T& theElem) const;
void erase(int theIndex);
void insert(int theIndex , const T& theElem);
void pushBack(const T &theElem);
T popBack();
void show(std::ostream& out) const;
bool compareTo(T a , T b , bool (*less)(T,T)) const;
void exch(int i , int j);
bool isSorted(int lo , int hi , bool (*less)(T,T));
void sort(bool (*less)(T,T));
void sort(void (*_sort)(T a[] , int len , bool(*less)(T,T)) , bool(*less)(T,T));
void sort(void (*_sort)(T a[] , int lo , int hi , bool(*less)(T,T)) , bool(*less)(T,T) , int lo , int hi);
};
template<class T>
class ArrayStack : public ArrayList<T> {
public:
ArrayStack(int capacity = 20) : ArrayList<T>::ArrayList(capacity) {}
ArrayStack(const ArrayStack<T> &theStack) : ArrayList<T>::ArrayList(theStack) {}
}; //ArrayStack
template<class T>
ArrayList<T>::ArrayList(int capacity)
{
if(capacity < 1)
{
std::cerr << "initial Capacity = " << capacity << "Must be > 0";
}
this->capacity = capacity;
this->elem = new T[capacity];
this->listSize = 0;
this->top = -1;
}
template<class T>
ArrayList<T>::ArrayList(const ArrayList<T> &theList)
{
this->capacity = theList.capacity;
this->listSize = theList.listSize;
this->elem = new T[this->capacity];
for(int i=0 ; i<this->capacity ; i++)
{
this->elem[i] = theList.elem[i];
}
this->top = theList.top;
}
template<class T>
T& ArrayList<T>::get(int theIndex) const
{
checkIndex(theIndex);
return this->elem[theIndex];
}
template<class T>
int ArrayList<T>::indexOf(const T& theElem) const
{
int index = 0;
while(index<listSize || elem[index]!=theElem)
{
index++;
}
if(index == listSize)
{
std::cerr << "Failed to find " << theElem << std::endl;
return FALSE;
}
else
{
return index;
}
}
template<class T>
void ArrayList<T>::erase(int theIndex)
{
checkIndex(theIndex);
for(int i=theIndex ; i<listSize-1 ; i++)
{
elem[i] = elem[i+1];
}
this->listSize--;
this->top--;
}
template<class T>
void ArrayList<T>::insert(int theIndex , const T& theElem)
{
if(theIndex<0 || theIndex>listSize || listSize==capacity)
{
std::ostringstream os;
os << "index = " << theIndex << " size = " << listSize;
std::cerr << os.str();
return;
}
for(int i=theIndex ; i<listSize-1 ; i++)
{
elem[i+1] = elem[i];
}
elem[theIndex] = theElem;
this->listSize++;
this->top++;
}
template<class T>
void ArrayList<T>::pushBack(const T& theElem)
{
if(listSize != capacity)
{
insert(listSize , theElem);
}
else
{
std::cerr << "the container is full!" << std::endl;
}
}
template<class T>
T ArrayList<T>::popBack()
{
if(empty())
std::cerr << "The container is empty!" << std::endl;
T target = this->elem[top];
erase(top);
return target;
}
template<class T>
void ArrayList<T>::checkIndex(int theIndex) const
{
if(theIndex<0 || theIndex>listSize-1)
{
std::ostringstream os;
os << "index = " << theIndex << " size = " << listSize;
std::cerr << os.str();
}
}
template<class T>
void ArrayList<T>::show(std::ostream &out) const
{
if(empty())
{
std::cerr << "The container is empty!" << std::endl;
return;
}
else
{
for(int i=0 ; i<listSize ; i++)
{
out << elem[i] << " ";
}
}
}
template<class T>
std::ostream& operator<<(std::ostream &out , const ArrayList<T> &x)
{
x.show(out);
return out;
}
template<class T>
bool ArrayList<T>::compareTo(T a , T b , bool (*less)(T,T)) const
{
return less(a,b);
}
template<class T>
void ArrayList<T>::exch(int i , int j)
{
T temp = elem[i];
elem[i] = elem[j];
elem[j] = temp;
}
template<class T>
bool ArrayList<T>::isSorted(int lo , int hi , bool (*less)(T,T))
{
bool flag = TRUE;
for(int i=lo ; i<hi ; i++)
{
if( less(elem[i+1],elem[i]) )
flag = FALSE;
}
return flag;
}
template<class T>
void ArrayList<T>::sort(bool (*less)(T,T))
{
for(int i=0 ; i<listSize ; i++)
{
for(int j=i ; j<listSize ; j++)
{
if( compareTo(elem[j],elem[i],less) )
{
exch(i,j);
}
}
}
}
template<class T>
void ArrayList<T>::sort(void (*_sort)(T a[] , int len , bool(*less)(T,T)) , bool(*less)(T,T))
{
if(!isSorted(0,listSize-1,less))
_sort(elem , listSize , less);
}
template<class T>
void ArrayList<T>::sort(void (*_sort)(T a[] , int lo , int hi , bool(*less)(T,T)) , bool(*less)(T,T) , int lo , int hi)
{
if(!isSorted(lo,hi,less))
_sort(elem , lo , hi , less);
}
template<class T>
class BinaryHeap : public ArrayList<T>{
public:
BinaryHeap(int capacity = 20);
BinaryHeap(const BinaryHeap<T> &theHeap);
~BinaryHeap();
T delMax();
void insert(const T theElem);
void swim(int k);
void sink(int k);
void show(std::ostream &out) const;
};
template<class T>
BinaryHeap<T>::BinaryHeap(int capacity)
:ArrayList<T>(capacity)
{
this->pushBack(-1); //start from index 1
}
template<class T>
BinaryHeap<T>::BinaryHeap(const BinaryHeap<T> &theHeap)
:ArrayList<T>::ArrayList(theHeap)
{
}
template<class T>
BinaryHeap<T>::~BinaryHeap()
{
ArrayList<T>::~ArrayList();
}
template<class T>
T BinaryHeap<T>::delMax()
{
T max = this->elem[1];
this->exch(1 , this->top);
this->popBack();
sink(1);
return max;
}
template<class T>
void BinaryHeap<T>::insert(const T theElem)
{
this->pushBack(theElem);
swim(this->top);
}
template<class T>
void BinaryHeap<T>::swim(int k)
{
while( less(this->elem[k/2],this->elem[k]) && k > 1 )
{
this->exch(k/2,k);
k = k / 2;
}
}
template<class T>
void BinaryHeap<T>::sink(int k)
{
while(2*k <= this->top)
{
int j = 2 * k;
if( j<this->top && less(this->elem[j],this->elem[j+1]) ) j++;
if( !less(this->elem[k],this->elem[j]) ) break;
this->exch(k,j);
k = j;
}
}
template<class T>
void BinaryHeap<T>::show(std::ostream &out) const
{
if(this->top == 0)
{
std::cerr << "The container is empty!" << std::endl;
return;
}
else
{
for(int i=1 ; i<this->listSize ; i++)
{
out << this->elem[i] << " ";
}
}
}
template<class T>
std::ostream& operator<<(std::ostream &out , const BinaryHeap<T> &x)
{
x.show(out);
return out;
}
template<class T>
class PriorityQueue : public BinaryHeap<T>{
protected:
public:
PriorityQueue(int capacity = 20) : BinaryHeap<T>::BinaryHeap(capacity) {}
PriorityQueue(const PriorityQueue<T> &theQueue) : BinaryHeap<T>::BinaryHeap(theQueue) {}
};
#endif
| [
"comcx@outlook.com"
] | comcx@outlook.com |
8b42dcb72922ab99d0ac60ed9d348fd223a7793b | 38340c78d2e5b2c91135e23be3823dae4655efb6 | /WOFFCEdit/TerrainSculptDialogue.h | a40ccde05314c861cc577cf950623b02b132b6b5 | [] | no_license | dylzy01/WFFC-Edit | da53acbe3a1a7c4abe9e0f0eaeaca8ca36767701 | 1f509585c33b7ef865d0314e157d75fc74dc5f32 | refs/heads/master | 2021-01-02T01:20:50.688943 | 2020-05-12T00:16:07 | 2020-05-12T00:16:07 | 239,407,836 | 0 | 0 | null | 2020-02-10T02:02:34 | 2020-02-10T02:02:33 | null | UTF-8 | C++ | false | false | 1,381 | h | #pragma once
#include "afxdialogex.h"
#include "resource.h"
#include "afxwin.h"
#include <vector>
#include "Tools.h"
// TerrainSculptDialogue dialog
class TerrainSculptDialogue : public CDialogEx
{
DECLARE_DYNAMIC(TerrainSculptDialogue)
public:
TerrainSculptDialogue(CWnd* pParent = nullptr); // standard constructor
virtual ~TerrainSculptDialogue();
// Getters
bool GetActive() { return m_active; }
TERRAIN_SCULPT GetSculpt() { return m_sculpt; }
bool GetConstraintX() { return m_x; }
bool GetConstraintY() { return m_y; }
bool GetConstraintZ() { return m_z; }
// Setters
void SetActive(bool active) { m_active = active; }
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_DIALOG5 };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
private:
// Enable/disable other buttons
void UpdateButtons(bool enable);
// Reset all constraints
void ResetConstraints() { m_x = m_y = m_z = false; }
// Controllers
bool m_active = false;
TERRAIN_SCULPT m_sculpt = TERRAIN_SCULPT::NA;
bool m_x = false, m_y = false, m_z = false;
DECLARE_MESSAGE_MAP()
private:
afx_msg void End();
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedIncrease();
afx_msg void OnBnClickedFlatten();
afx_msg void OnBnClickedDecrease();
afx_msg void OnBnClickedX();
afx_msg void OnBnClickedY();
afx_msg void OnBnClickedZ();
};
| [
"35919519+dylzy01@users.noreply.github.com"
] | 35919519+dylzy01@users.noreply.github.com |
039edb1a0547f6ca6254733bfcd82f1104905f90 | cf47614d4c08f3e6e5abe82d041d53b50167cac8 | /CS101_Spring2020-21 /LAB4_L1/uncategorized/stream/Submissions/94_stream.cpp | 34d170b7bb3a784a2cf83e1a91d01671367bdfe6 | [] | no_license | krishna-raj007/BodhiTree-Annotation | 492d782dffe3744740f48c4c7e6bbf2ee2c0febd | 28a6467038bac7710c4b3e3860a369ca0a6e31bf | refs/heads/master | 2023-02-28T18:23:05.880438 | 2021-02-07T17:55:33 | 2021-02-07T17:55:33 | 299,254,966 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 116 | cpp | #include<simplecpp>
main_program{
int a;
cin>>a;
int max=a;
while(a!=-1)
{
cin>>a;
if(a>max)
max=a;
}
cout<<max;
}
| [
"krishna_raj007@yahoo.in"
] | krishna_raj007@yahoo.in |
4881dc0820c0c70360b15008afa5932e8fb3282f | a34d21fc58df42c55ed0d2aea94a9dff9c29e01a | /src/tests/OneFunctionTests/saHpiDrtEntryGet.h | 91bc6ca20b196a469305b7b684d707bf54e60272 | [] | no_license | uslon/stress_openhpi | 2af96ffdad4c1790c5d49528673001571528ad58 | 7318942daf1651b0410bb9765eac4693431693e3 | refs/heads/master | 2022-12-27T04:10:45.835165 | 2020-10-10T18:02:09 | 2020-10-10T18:02:09 | 289,293,230 | 0 | 0 | null | 2020-09-01T15:41:02 | 2020-08-21T14:45:56 | C++ | UTF-8 | C++ | false | false | 408 | h | //
// Created by amir on 21.08.2020.
//
#ifndef STRESS_OPENHPI_SAHPIDRTENTRYGET_H
#define STRESS_OPENHPI_SAHPIDRTENTRYGET_H
#include <BaseTestCase.h>
namespace ns_saHpiDrtEntryGet {
void worker(std::atomic_int &workers_finished);
}
class saHpiDrtEntryGet : public BaseTestCase {
private:
std::string getTestName() final;
void runTest() final;
};
#endif //STRESS_OPENHPI_SAHPIDRTENTRYGET_H
| [
"uslon@yahoo.com"
] | uslon@yahoo.com |
5448b1e4d4ced2d7004f1f0ed0d7e7c70f25d813 | 719ca866888053c63c4f76207f3792b0a46b5c8a | /Libraries/FiringRateSim/StdAfx.cpp | 3ae11f41a9a6462319e850e1828806f9a04a1625 | [] | no_license | silicondosa/AnimatLabPublicSource | 08e71f28c221881bf8527bb95df8cf530c455ca0 | c5b23f8898513582afb7891eb994a7bd40a89f08 | refs/heads/master | 2023-03-20T02:16:00.390767 | 2016-10-04T18:17:59 | 2016-10-04T18:17:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 214 | cpp | // stdafx.cpp : source file that includes just the standard includes
// DevelopmentalLib.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "StdAfx.h"
| [
"dcofer@NeuroRoboticTech.com"
] | dcofer@NeuroRoboticTech.com |
7d80c812391f11f7f708c66bdcd77fd259a9821f | 93d5af39444ed8d9c9dc166a0e94540bb8ab2459 | /NDArray.cpp | 753fbd482fbf43fad5f95f8f79014abae90914ec | [] | no_license | initc3/VENEER | e33a9668591517259a83c14c0cfb67b1d836fce3 | cbcb84a9c5c4313d7b2988059b7da64b87347dc6 | refs/heads/master | 2021-01-17T07:37:03.634577 | 2016-07-23T19:44:41 | 2016-07-23T19:44:41 | 64,031,844 | 0 | 0 | null | 2016-08-08T23:42:56 | 2016-07-23T19:18:20 | C++ | UTF-8 | C++ | false | false | 911 | cpp | #include <vector>
#include <string>
#include <sstream>
#include <cassert>
#include "NDArray.h"
using namespace std;
NDArray :: NDArray(): shape() {
}
NDArray :: ~NDArray() {
}
string NDArray :: get_shape_str() const {
ostringstream os;
os << "[";
for (int i = 0; i < (int) shape.size(); ++i) {
if (i != 0)
os << ", ";
os << shape[i];
}
os << "]";
return os.str();
}
void NDArray :: check_shape() const {
int e = 1;
for (int i = 0; i < (int) shape.size(); ++i)
e = e * shape[i];
assert (e == (int) array.size());
}
float& NDArray :: get(const vector<int> &pos) {
int p = 0, mul = 1;
for (int i = (int)pos.size() - 1; i >= 0; --i) {
p += mul * pos[i];
mul *= shape[i];
}
return array[p];
}
float NDArray :: get(const vector<int> &pos) const {
int p = 0, mul = 1;
for (int i = (int)pos.size() - 1; i >= 0; --i) {
p += mul * pos[i];
mul *= shape[i];
}
return array[p];
}
| [
"yz_sjr@sjtu.edu.cn"
] | yz_sjr@sjtu.edu.cn |
ad845aa10a3c482c644c5ac6b27bd11cfcb3e7b5 | e680718836cc68a9845ede290e033d2099629c9f | /xwzgServerSource/MemLogServer/COMMON/BaseFunc.h | 3b0705a9b4b83877ed5d6020c3ecbb18d3fb6c0e | [] | no_license | liu-jack/sxkmgf | 77ebe2de8113b8bb7d63b87d71d721df0af86da8 | 5aa37b3efe49c3573a9169bcf0888f6ba8517254 | refs/heads/master | 2020-06-28T21:41:05.823423 | 2018-09-28T17:30:26 | 2018-09-28T17:30:26 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,164 | h | #ifndef _BASEFUNC_H
#define _BASEFUNC_H
#pragma warning(disable:4786)
#include <time.h>
#include "common.h"
#include "BaseType.h"
#include <vector>
using namespace std;
#include "AutoPtr.h"
//日志开关标志位
extern BOOL g_bLogSave;
String DumpBuffer(const char* buf, int nSize);
void DateTime(char * buf20, time_t tInput = 0); // 0 : curr time
bool FormatDateTime(char* buf, const char* szFormat, time_t tInput = 0); // szFormat: "%04d-%02d-%02d %02d:%02d:%02d"
void DateTimeStamp(char * buf15, time_t tInput = 0); // 0 : curr time
int DateStamp(time_t tTime=0);
int DateStampPass(int nDate, int nDays); // return -1: error
bool IsActiveTime(time_t tCurr, unsigned long nFormat);
bool IsTimeRange(unsigned long nBegin, unsigned long nEnd, time_t tCurr=0);
inline long GetCurrTime() { return time(NULL); }
char* StrStrCh(const char* string, const char* strCharSet);
enum TIME_TYPE{
TIME_MILLISECOND=0,
TIME_SECOND,
TIME_MINUTE,
TIME_DAY,
TIME_DAYTIME,
TIME_STAMP,
TIME_EPOCH_DAY,//20070402修罗:时间点.当前时间距离参考时间点的天数
};
DWORD TimeGet(TIME_TYPE type=TIME_MILLISECOND);
DWORD SysTimeGet(void);
DWORD SysTimeGetEx(void);
inline long GetClock() { return clock(); }
int RandGet (int nMax, BOOL bReset=false);
void LogSave (const char* fmt, ...);
void MyLogSave (const char* pszName, const char* fmt, ...);
BOOL StringCheck (char* pszString, BOOL bNewLineEnable=false);
BOOL TalkStrCheck(char* pszString, BOOL bNewLineEnable=false);
BOOL DisableWordCheck(char* pszString, BOOL bNewLineEnable=false);
BOOL NameStrCheck(char* pszString);
int Double2Int (double dValue);
inline int AddToTop(int nData, int nAdd, int nTop) { int res=nData+nAdd; if(nAdd>0 && res<nData || res>nTop) return nTop; else return res; }
//#define _TIMECOSTCHECK///定义时间成本检测开启
/////////////////////////////////////////////////////////////////////////////
class CTimeCostChk
{
public:
CTimeCostChk(const char* szReason,const char* pszStr, DWORD tmChk) : m_tmChk(tmChk)
{
m_tmBegin = GetTickCount();
m_pszStr = pszStr;
m_pszReason =szReason;
}
~CTimeCostChk(void)
{
DWORD tmCost = GetTickCount()-m_tmBegin;
if (tmCost > m_tmChk)
{
::LogSave("CTimeCostChk Overtime (%u) when szReason:%s chk:%s", tmCost,m_pszReason,m_pszStr);
}
}
private:
DWORD m_tmChk;
const char* m_pszStr;
const char* m_pszReason;///原因
DWORD m_tmBegin;
};
#ifdef _TIMECOSTCHECK
#define TimeCostChk(x,y) CTimeCostChk chk(x,y,100)
#else
#define TimeCostChk(x,y)
#endif
/////////////////////////////////////////////////////////////////////////////
template<TYPENAME T>
inline T CutOverflow(T x, T y) { return (x <= y) ? x : y; }
template<TYPENAME T>
inline T CutTrail(T x, T y) { return (x >= y) ? x : y; }
template<TYPENAME T>
inline T CutRange(T n, T min, T max) { return (n<min) ? min : ((n>max) ? max : n); }
//////////////////////////////////////////////////////////////////////
inline int pos2index(int x, int y, int cx, int cy) { return (x + y*cx); }
inline int index2x(int idx, int cx, int cy) { return (idx % cy); }
inline int index2y(int idx, int cx, int cy) { return (idx / cy); }
#endif
| [
"43676169+pablones@users.noreply.github.com"
] | 43676169+pablones@users.noreply.github.com |
930022fb93c9a6ea92855142fbb75884bde86e78 | 7e0655e26431a53650bfeb29aa7309c0839b21ae | /libSignatureGenerator/Components/ProcessingLayer/SignatureGenerator.cpp | 51b6b0d75d9398dd68030eb657e575de64bbf894 | [] | no_license | pestOO/SignatureGenerator | 67b6747ecc47ed0642dc504c4b1a1184413983a5 | d410e8236c0b2de9139994c59ab9e9073e2fc958 | refs/heads/master | 2021-03-19T20:01:39.741163 | 2020-03-15T16:39:35 | 2020-03-15T16:39:41 | 247,143,229 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,299 | cpp | /******************************************************************************
* Copyright (c) 2020-2020 Elisey Zamakhov, eliseyzamahov@gmail.com
*
* This file is part of the SignatureGenerator.
*
* File can not be copied and/or distributed without the express
* permission of Elisey Zamakhov.
*****************************************************************************/
#include "SignatureGenerator.h"
#include <exception>
#include <memory>
#include "Utilities/MessageQueue.h"
#include "details/ChunkSignatureImpl.h"
SignatureGenerator::SignatureGenerator(MessageQueue &message_queue)
: message_queue_(message_queue) {}
void SignatureGenerator::OnDataAvailable(const InDataChunkSptr &data_chunk_sptr) {
message_queue_.PostJob(
[data_chunk_sptr, this]() {
const auto signatureDataSptr = std::make_shared<ChunkSignatureImpl>(*data_chunk_sptr);
if (auto listener = on_data_available_listener_.lock())
listener->OnDataAvailable(signatureDataSptr);
return true;
});
}
void SignatureGenerator::SetConnectChunkDataListener(const SignatureGenerator::DataAvailableListenerSptr &listener) {
on_data_available_listener_ = listener;
}
std::size_t SignatureGenerator::GetSignatureSize() {
return ChunkSignatureImpl::GetSignatureSize();
}
| [
"Elisey.Zamakhov@tomtom.com"
] | Elisey.Zamakhov@tomtom.com |
b2ad6efd26e9834122723f1a2159c6edfb731a6b | 5f3a6a7092f5cf1577474fc1682a88bde310bfef | /src/ThreadingLayerHex.h | d05ccd0f3ed16dddc7a20841d69022d8effd80f8 | [] | no_license | vifactor/DislScatHexFITMisfitThreading | 145ae8f0a6a715aac335f44e90e666cf41d4f7ef | 81efe5f837e561a0d4c5b8ccc6e86e3d6777508b | refs/heads/master | 2021-01-19T09:42:35.304101 | 2014-04-07T14:01:11 | 2014-04-07T14:01:11 | null | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 781 | h | /*
* ThreadingLayerHex.h
*
* Created on: 11 черв. 2013
* Author: kopp
*/
#ifndef THREADINGLAYERHEX_H_
#define THREADINGLAYERHEX_H_
#include <gsl/gsl_math.h>
#include <iostream>
class ThreadingLayerHex
{
public:
ThreadingLayerHex(double rho, double b_edge, double b_screw, double rc, double Qx, double Qz, double nu);
virtual ~ThreadingLayerHex();
double T(double r, double phi) const;
double m_rho;
double m_Rc;
protected:
double m_gb_screw, m_gb2_screw;
double m_gb_edge, m_gb2_edge;
double m_C_screw, m_C1_edge, m_C2_edge;
double T_screw(double r) const;
double T_edge(double r, double phi) const;
inline double chi_screw() const;
inline double chi_edge(double phi) const;
};
#endif /* THREADINGLAYERHEX_H_ */
| [
"vifactor@gmail.com"
] | vifactor@gmail.com |
8ad9a29c5e46c48a9b844cdcef371c975ef22132 | 4f4881bc2fd6739c6649cd4bfc2443e7dd7a5f41 | /Server/Minimal/Mesh.h | 7589cb7e6d383f361cdd4677785f37d7451c250e | [] | no_license | jonnjonny/BonAppetitVR | 254654b0c84d7326d25f5ccdad9b8d49168793bc | 59de88903eb8597294a1eeee90144811f9d2d0ab | refs/heads/master | 2020-05-30T10:25:19.096108 | 2020-02-04T08:20:25 | 2020-02-04T08:20:25 | 189,667,223 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,952 | h | #ifndef MESH_H
#define MESH_H
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <vector>
#include "shader.h"
using namespace std;
struct Vertex {
// position
glm::vec3 Position;
// normal
glm::vec3 Normal;
// texCoords
glm::vec2 TexCoords;
// tangent
glm::vec3 Tangent;
// bitangent
glm::vec3 Bitangent;
};
struct Texture {
unsigned int id;
string type;
string path;
};
class Mesh {
public:
/* Mesh Data */
vector<Vertex> vertices;
vector<unsigned int> indices;
vector<Texture> textures;
unsigned int VAO;
GLuint uProjection, uModelview, uColor;
/* Functions */
// constructor
Mesh(vector<Vertex> vertices, vector<unsigned int> indices, vector<Texture> textures)
{
this->vertices = vertices;
this->indices = indices;
this->textures = textures;
// now that we have all the required data, set the vertex buffers and its attribute pointers.
setupMesh();
}
// render the mesh
void Draw(GLuint shaderId, const glm::mat4& projection, const glm::mat4& view, const glm::mat4& toWorld, int color)
{
// draw mesh
glUseProgram(shaderId);
// Calculate the combination of the model and view (camera inverse) matrices
glm::mat4 modelview = view * toWorld;
// We need to calcullate this because modern OpenGL does not keep track of any matrix other than the viewport (D)
// Consequently, we need to forward the projection, view, and model matrices to the shader programs
// Get the location of the uniform variables "projection" and "modelview"
uProjection = glGetUniformLocation(shaderId, "projection");
uModelview = glGetUniformLocation(shaderId, "modelview");
uColor = glGetUniformLocation(shaderId, "color");
// Now send these values to the shader program
glUniformMatrix4fv(uProjection, 1, GL_FALSE, &projection[0][0]);
glUniformMatrix4fv(uModelview, 1, GL_FALSE, &modelview[0][0]);
glUniform1i(uColor, color);
glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, (GLsizei)indices.size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
// always good practice to set everything back to defaults once configured.
glActiveTexture(GL_TEXTURE0);
}
private:
/* Render data */
unsigned int VBO, EBO;
/* Functions */
// initializes all the buffer objects/arrays
void setupMesh()
{
// create buffers/arrays
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glGenBuffers(1, &EBO);
glBindVertexArray(VAO);
// load data into vertex buffers
glBindBuffer(GL_ARRAY_BUFFER, VBO);
// A great thing about structs is that their memory layout is sequential for all its items.
// The effect is that we can simply pass a pointer to the struct and it translates perfectly to a glm::vec3/2 array which
// again translates to 3/2 floats which translates to a byte array.
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(Vertex), &vertices[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW);
// set the vertex attribute pointers
// vertex Positions
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)0);
// vertex normals
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, Normal));
// vertex texture coords
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, TexCoords));
// vertex tangent
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, Tangent));
// vertex bitangent
glEnableVertexAttribArray(4);
glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, Bitangent));
glBindVertexArray(0);
}
};
#endif
| [
"jkl034@UCSD.EDU"
] | jkl034@UCSD.EDU |
3455ee331edb35a1f6ef02b1418584fb2a0eb95c | 8f76cb5e386fa68f29489d479286d5ac7fac8c59 | /src/server/shtml/ShtmlConfig.h | 4c87aadd209f68cad0280f908b2377baced2ad30 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | isabella232/Heliod-Web-Server | ce672d264e705b0d2128ddd7846434804db24905 | 6fc8b2f0ed8e76979140fae7912b44cd03ca4289 | refs/heads/master | 2022-02-13T21:55:02.995051 | 2016-05-23T12:38:23 | 2016-05-23T12:38:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,657 | h | /*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
*
* THE BSD LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SHTML_CONFIG_H_
#define _SHTML_CONFIG_H_
#include <base/pblock.h>
class ShtmlConfig {
public:
enum ShtmlFileType { PARSE_SHTML_ONLY, PARSE_HTML_FILES_ALSO,
PARSE_FILES_WITH_EXEC_BIT};
static void Init(pblock* pb)
{
if (!_gShtmlConfig)
_gShtmlConfig = new ShtmlConfig(pb);
}
static ShtmlConfig* GetShtmlConfig()
{
return _gShtmlConfig;
}
ShtmlConfig(pblock* pb);
~ShtmlConfig();
PRBool IsShtmlEnabled() { return _shtmlState; }
void ActivateShtml(PRBool on) { _shtmlState = on;}
ShtmlFileType GetShtmlFileExtension() {return _shtmlExt;}
void SetShtmlFileExtension(ShtmlFileType shtmlExt) {_shtmlExt = shtmlExt;};
PRBool AllowExecTag() {return _allowExecTag;}
void AllowExecTag(PRBool allowExecTag)
{_allowExecTag = allowExecTag;};
private:
PRBool _shtmlState;
PRBool _allowExecTag;
ShtmlFileType _shtmlExt;
static ShtmlConfig* _gShtmlConfig;
};
#endif /* _SHTML_CONFIG_H_ */
| [
"jyri@virkki.com"
] | jyri@virkki.com |
6f1fdd88ba8d222c7db2827b911058d4474ada72 | 324ee2eb3b576688cdefaed47b0aae6a3d5487e1 | /util/c++/segmentation_renderer/src/main.cpp | e8135cfa15d0023dc762fbab91ff33617813494c | [] | no_license | lukasHoel/novel-view-synthesis | 2cca40bd04e61cf33f3bcb29cffd59b8dbc05c8a | 51c709a4a730f30864cded6f4a0cb1f758279175 | refs/heads/master | 2023-01-11T00:41:21.390231 | 2020-11-10T22:09:25 | 2020-11-10T22:09:25 | 254,032,781 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,276 | cpp | #include <iostream>
//#include "icl_renderer.h"
//#include "icl_parser.h"
//#include "icl_mesh_transformer.h"
//#include "icl_segmentation_provider.h"
#include "mp_renderer.h"
#include "mp_parser.h"
#include "segmentation_provider.h"
#include "mesh_transformer.h"
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <glm/glm.hpp>
/*
- TODO: Write a main.cpp pipeline which loops over all images (selected images --> loop over folder of images) for a specific region
--> Color according to segmentation + transform object from input
--> Render from specific camera pose/intrinsic for this view
--> Save as image in output folder
- TODO (optional): Before the main.cpp pipeline starts, we show the region in an interactive renderer.
--> Allow the user to somehow interactively choose which object to move and how to move it
--> From this selection, extract a transformation matrix and use that as an input for the pipeline
--> (optional 2): Let the user create a trajectory (multiple transformation matrices) and use each of them
*/
int main(int argc, char** argv){
/*
std::string seq = "seq0019";
// ICL_Parser ip("/home/lukas/Desktop/datasets/ICL-NUIM/prerendered_data/living_room_traj2_loop", 0);
ICL_Parser ip("/home/lukas/Desktop/datasets/ICL-NUIM/custom/" + seq + "/original", 0);
ICL_Renderer icl_renderer("/home/lukas/Desktop/datasets/ICL-NUIM/model_for_rendering/living_room_obj_mtl/living-room.obj");
ICL_Segmentation_Provider icl_sp("../src/icl_nuim/object_to_color.txt");
glm::mat4 t(1.0f);
t = glm::translate(t, glm::vec3(-0.15f, 0.0f, -0.26f)); // for seq0001
// t = glm::rotate(t, glm::radians(20.0f), glm::vec3(0.0f, 1.0f, 0.0f)); // for seq0002
t = glm::rotate(t, glm::radians(25.0f), glm::vec3(1.0f, 1.0f, 0.0f));
std::string move_object = "cushion3_cushion3";
std::cout << glm::to_string(t) << std::endl;
for(auto& mesh : icl_renderer.m_model->meshes){
icl_sp.change_colors(mesh);
}
// icl_renderer.renderInteractive(ip);
// RENDER ORIGINAL
icl_renderer.renderTrajectory(ip, "/home/lukas/Desktop/datasets/ICL-NUIM/custom/" + seq + "/original");
// RENDER MOVED
for(auto& mesh : icl_renderer.m_model->meshes){
ICL_Mesh_Transformer icl_mt(mesh);
icl_mt.moveVerticesOfObject(move_object, t);
}
json moved_json;
moved_json.push_back(icl_sp.getMovementAsJson(move_object, t));
std::ofstream moved_file("/home/lukas/Desktop/datasets/ICL-NUIM/custom/" + seq + "/moved.txt");
moved_file << std::setw(4) << moved_json << std::endl;
//Model icl_model("/home/lukas/Desktop/datasets/ICL-NUIM/model_for_rendering/living_room_obj_mtl/living-room.obj");
icl_renderer.renderTrajectory(ip, "/home/lukas/Desktop/datasets/ICL-NUIM/custom/" + seq + "/moved");
// icl_renderer.renderTrajectory(ip, "/home/lukas/Desktop/datasets/ICL-NUIM/prerendered_data/living_room_traj2_loop");
*/
if(argc != 3){
std::cout << "Usage: " << argv[0] << " path/to/Matterport3D/data/v1/scans <scanID>" << std::endl;
return EXIT_FAILURE;
}
string path(argv[1]);
string scanID(argv[2]);
string outdir = path + "/" + scanID + "/image_segmentations"; // TODO mkdir this
string pathToHouseFile = path + "/" + scanID + "/house_segmentations/" + scanID + "/house_segmentations/" + scanID + ".house";
MP_Parser mp(pathToHouseFile.c_str());
std::cout << "parsed .house file" << std::endl;
try{
string regionPath = path + "/" + scanID + "/region_segmentations/" + scanID + "/region_segmentations";
regionPath += "/region0."; // TODO instead loop over all regions!
MP_Renderer renderer(regionPath + "ply", mp, 0);
std::cout << "Renderer initialized" << std::endl;
for(auto& mesh : renderer.m_model->meshes){
Segmentation_Provider sp(regionPath + "semseg.json", regionPath + "vsegs.json", regionPath + "fsegs.json", mesh);
sp.change_colors(mesh);
}
std::cout << "Updated Mesh Colors according to object instance segmentation" << std::endl;
// render original (before move)
renderer.renderImages(outdir + "/original");
for(auto& mesh : renderer.m_model->meshes){
Segmentation_Provider sp(regionPath + "semseg.json", regionPath + "vsegs.json", regionPath + "fsegs.json", mesh);
Mesh_Transformer transform(mesh, sp);
transform.splitMeshAtObject(1);
glm::mat4 t = { 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, -0.5, 0.5, 1 };
transform.moveVerticesOfObject(1, t);
}
std::cout << "Splitted and transformed mesh: pillow with id 1 translated by (0, -0.5, 0.5)" << std::endl;
// render moved
renderer.renderImages(outdir + "/moved");
std::cout << "Render images completed" << std::endl;
// renderer.renderInteractive();
} catch(const exception& e){
std::cerr << "Caught exception: " << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
} | [
"lukas.hoellein@tum.de"
] | lukas.hoellein@tum.de |
ca9beaad597e913f0057b5e5a301a331a8344044 | c01b0159663fc23086cf2852ab5e1165055f4bb8 | /pkgs/FET/FETFeature.h | 7dd0f66aba55e327723bf835c4b3dfe24bd1ada2 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | Jiangjunfeng/gaps | 44e1255eb979c461183a05d27b9830d93fe31af9 | 20364a9f58d2fa65f277474a19d6f4752e2f59fc | refs/heads/master | 2021-01-23T02:39:55.311158 | 2017-03-24T00:22:02 | 2017-03-24T00:22:02 | 86,013,464 | 2 | 0 | null | 2017-03-24T01:18:50 | 2017-03-24T01:18:50 | null | UTF-8 | C++ | false | false | 9,149 | h | ////////////////////////////////////////////////////////////////////////
// Feature class definition
////////////////////////////////////////////////////////////////////////
struct FETFeature {
public:
// Constructor
FETFeature(FETReconstruction *reconstruction = NULL, int shape_type = 0,
const R3Point& position = R3Point(0,0,0), const R3Vector& direction = R3Vector(0,0,0), const R3Vector& normal = R3Vector(0,0,0),
RNLength radius = 0, const FETDescriptor& descriptor = FETDescriptor(), const RNRgb& color = RNRgb(0.5,0.5,0.5), RNFlags flags = 0);
FETFeature(const FETFeature& feature);
~FETFeature(void);
// Reconstruction access
FETReconstruction *Reconstruction(void) const;
// Shape access
FETShape *Shape(void) const;
// Correspondence access
int NCorrespondences(void) const;
FETCorrespondence *Correspondence(int k) const;
// Properties
int ShapeType(void) const;
R3Point Position(RNBoolean transformed = FALSE) const;
R3Vector Direction(RNBoolean transformed = FALSE) const;
R3Vector Normal(RNBoolean transformed = FALSE) const;
RNLength Radius(RNBoolean transformed = FALSE) const;
RNScalar Salience(void) const;
RNScalar Distinction(void) const;
const FETDescriptor& Descriptor(void) const;
const RNRgb& Color(void) const;
int GeneratorType(void) const;
RNBoolean IsPoint(void) const;
RNBoolean IsLinear(void) const;
RNBoolean IsPlanar(void) const;
RNBoolean IsOnSilhouetteBoundary(void) const;
RNBoolean IsOnShadowBoundary(void) const;
RNBoolean IsOnBorderBoundary(void) const;
RNBoolean IsOnBoundary(void) const;
// Manipulation
void Transform(const R3Affine& transformation);
void SetShapeType(int shape_type);
void SetPosition(const R3Point& position, RNBoolean transformed = FALSE);
void SetDirection(const R3Vector& direction, RNBoolean transformed = FALSE);
void SetNormal(const R3Vector& normal, RNBoolean transformed = FALSE);
void SetRadius(RNLength radius, RNBoolean transformed = FALSE);
void SetSalience(RNScalar salience);
void SetDistinction(RNScalar distinction);
void SetDescriptor(const FETDescriptor& descriptor);
void SetColor(const RNRgb& color);
void SetGeneratorType(int generator_type);
void SetFlags(const RNFlags& flags);
// Relationship
RNLength EuclideanDistance(const R3Point& position) const;
RNLength SquaredEuclideanDistance(const R3Point& position) const;
// Display
void Draw(void) const;
// Input/output
int ReadAscii(FILE *fp);
int ReadBinary(FILE *fp);
int WriteAscii(FILE *fp) const;
int WriteBinary(FILE *fp) const;
public:
// Internal correspondence manipulation
void InsertCorrespondence(FETCorrespondence *correspondence, int k);
void RemoveCorrespondence(FETCorrespondence *correspondence, int k);
void SortCorrespondences(void);
public:
// Membership stuff
FETReconstruction *reconstruction;
int reconstruction_index;
FETShape *shape;
int shape_index;
// Correspondence stuff
RNArray<FETCorrespondence *> correspondences;
// Geometry stuff
int shape_type;
R3Point position;
R3Vector direction;
R3Vector normal;
RNLength radius;
// Other stuff
RNScalar salience;
RNScalar distinction;
FETDescriptor descriptor;
RNRgb color;
RNFlags flags;
// Temporary
int generator_type;
int primitive_marker;
};
////////////////////////////////////////////////////////////////////////
// Shape types
////////////////////////////////////////////////////////////////////////
enum {
NULL_FEATURE_SHAPE,
POINT_FEATURE_SHAPE,
LINE_FEATURE_SHAPE,
PLANE_FEATURE_SHAPE,
NUM_FEATURE_SHAPES
};
////////////////////////////////////////////////////////////////////////
// Generator types
////////////////////////////////////////////////////////////////////////
#define UNKNOWN_FEATURE_TYPE 0
#define SIFT_FEATURE_TYPE 1
#define FAST_FEATURE_TYPE 2
#define CORNER_FEATURE_TYPE 3
#define BORDER_FEATURE_TYPE 11
#define SILHOUETTE_FEATURE_TYPE 12
#define SHADOW_FEATURE_TYPE 13
#define POLE_FEATURE_TYPE 14
#define RIDGE_FEATURE_TYPE 15
#define VALLEY_FEATURE_TYPE 16
#define UNIFORM_FEATURE_TYPE 21
#define PLANE_FEATURE_TYPE 22
#define STRUCTURE_FEATURE_TYPE 31
#define NUM_FEATURE_TYPES 32
////////////////////////////////////////////////////////////////////////
// Feature flags
////////////////////////////////////////////////////////////////////////
#define FEATURE_IS_POINT 0x01
#define FEATURE_IS_LINEAR 0x02
#define FEATURE_IS_PLANAR 0x04
#define FEATURE_IS_ON_SILHOUETTE_BOUNDARY 0x10
#define FEATURE_IS_ON_SHADOW_BOUNDARY 0x20
#define FEATURE_IS_ON_BORDER_BOUNDARY 0x40
#define FEATURE_IS_ON_BOUNDARY (FEATURE_IS_ON_SILHOUETTE_BOUNDARY | FEATURE_IS_ON_SHADOW_BOUNDARY | FEATURE_IS_ON_BORDER_BOUNDARY)
////////////////////////////////////////////////////////////////////////
// Feature compatibility parameters
////////////////////////////////////////////////////////////////////////
struct FETCompatibilityParameters {
public:
FETCompatibilityParameters(
RNLength max_euclidean_distance = RN_UNKNOWN,
RNLength *max_descriptor_distances = NULL,
RNAngle max_normal_angle = RN_UNKNOWN,
RNScalar min_distinction = RN_UNKNOWN,
RNScalar min_salience = RN_UNKNOWN,
RNBoolean discard_boundaries = FALSE);
public:
RNLength max_euclidean_distance_squared;
RNLength max_descriptor_distance_squared[NUM_FEATURE_TYPES];
RNAngle min_normal_dot_product;
RNScalar min_distinction;
RNScalar min_salience;
RNBoolean discard_boundaries;
};
int AreFeaturesCompatible(FETFeature *feature1, FETFeature *feature2, void *data);
////////////////////////////////////////////////////////////////////////
// Comparison function
////////////////////////////////////////////////////////////////////////
int FETCompareFeatures(const void *data1, const void *data2);
////////////////////////////////////////////////////////////////////////
// Inline feature functions
////////////////////////////////////////////////////////////////////////
inline FETReconstruction *FETFeature::
Reconstruction(void) const
{
// Return reconstruction
return reconstruction;
}
inline FETShape *FETFeature::
Shape(void) const
{
// Return shape
return shape;
}
inline int FETFeature::
NCorrespondences(void) const
{
// Return number of correspondences
return correspondences.NEntries();
}
inline FETCorrespondence *FETFeature::
Correspondence(int k) const
{
// Return kth correspondence
return correspondences.Kth(k);
}
inline int FETFeature::
ShapeType(void) const
{
// Return shape type
return shape_type;
}
inline RNScalar FETFeature::
Salience(void) const
{
// Return salience
return salience;
}
inline RNScalar FETFeature::
Distinction(void) const
{
// Return distinction
return distinction;
}
inline const FETDescriptor& FETFeature::
Descriptor(void) const
{
// Return descriptor
return descriptor;
}
inline const RNRgb& FETFeature::
Color(void) const
{
// Return color
return color;
}
inline int FETFeature::
GeneratorType(void) const
{
// Return generator type
return generator_type;
}
inline RNBoolean FETFeature::
IsPoint(void) const
{
// Return whether feature is a point
return flags[FEATURE_IS_POINT];
}
inline RNBoolean FETFeature::
IsLinear(void) const
{
// Return whether feature is linear
return flags[FEATURE_IS_LINEAR];
}
inline RNBoolean FETFeature::
IsPlanar(void) const
{
// Return whether feature is planar
return flags[FEATURE_IS_PLANAR];
}
inline RNBoolean FETFeature::
IsOnSilhouetteBoundary(void) const
{
// Return whether feature is on silhouette boundary
return flags[FEATURE_IS_ON_SILHOUETTE_BOUNDARY];
}
inline RNBoolean FETFeature::
IsOnShadowBoundary(void) const
{
// Return whether feature is on shadow boundary
return flags[FEATURE_IS_ON_SHADOW_BOUNDARY];
}
inline RNBoolean FETFeature::
IsOnBorderBoundary(void) const
{
// Return whether feature is on shadow boundary
return flags[FEATURE_IS_ON_BORDER_BOUNDARY];
}
inline RNBoolean FETFeature::
IsOnBoundary(void) const
{
// Return whether feature is on boundary
return flags[FEATURE_IS_ON_BOUNDARY];
}
inline void FETFeature::
SetShapeType(int shape_type)
{
// Set shape type
this->shape_type = shape_type;
}
inline void FETFeature::
SetSalience(RNScalar salience)
{
// Set salience
this->salience = salience;
}
inline void FETFeature::
SetDistinction(RNScalar distinction)
{
// Set distinction
this->distinction = distinction;
}
inline void FETFeature::
SetDescriptor(const FETDescriptor& descriptor)
{
// Set descriptor
this->descriptor = descriptor;
}
inline void FETFeature::
SetColor(const RNRgb& color)
{
// Set color
this->color = color;
}
inline void FETFeature::
SetGeneratorType(int generator_type)
{
// Set generator type
this->generator_type = generator_type;
}
inline void FETFeature::
SetFlags(const RNFlags& flags)
{
// Set flags
this->flags = flags;
}
| [
"funkhouser.tom@gmail.com"
] | funkhouser.tom@gmail.com |
63aacdfbfe5be6000b26a75d370c4c6564282c63 | a4ea035fe1fab319ddf337389c1981e38db07b30 | /lib/msgpack-c-068041f/test/msgpack_basic.cpp | dad92cab7ff1ff0f5afe43001bc67ce3674a4452 | [
"Apache-2.0",
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | salekseev/fluent-bit | 6cc6baea5a45b09beb4b2597d1171071d8f5abbd | 422d0093ebccc58824f7daba9842665cba6e9f5f | refs/heads/master | 2023-04-07T17:52:52.199404 | 2016-09-07T14:13:02 | 2016-09-07T14:13:02 | 68,831,976 | 0 | 0 | Apache-2.0 | 2023-04-04T01:27:32 | 2016-09-21T15:37:54 | C | UTF-8 | C++ | false | false | 17,604 | cpp | #include "msgpack.hpp"
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <deque>
#include <set>
#include <list>
#include <limits>
#include <gtest/gtest.h>
#if defined(_MSC_VER)
#define msgpack_rand() ((double)rand() / RAND_MAX)
#else // _MSC_VER
#define msgpack_rand() drand48()
#endif // _MSC_VER
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
using namespace std;
const unsigned int kLoop = 10000;
const unsigned int kElements = 100;
const double kEPS = 1e-10;
#define GEN_TEST(test_type) \
do { \
vector<test_type> v; \
v.push_back(0); \
v.push_back(1); \
v.push_back(2); \
v.push_back(numeric_limits<test_type>::min()); \
v.push_back(numeric_limits<test_type>::max()); \
for (unsigned int i = 0; i < kLoop; i++) \
v.push_back(rand()); \
for (unsigned int i = 0; i < v.size() ; i++) { \
msgpack::sbuffer sbuf; \
test_type val1 = v[i]; \
msgpack::pack(sbuf, val1); \
msgpack::object_handle oh = \
msgpack::unpack(sbuf.data(), sbuf.size()); \
EXPECT_EQ(val1, oh.get().as<test_type>()); \
} \
} while(0)
TEST(MSGPACK, simple_buffer_char)
{
GEN_TEST(char);
}
TEST(MSGPACK, simple_buffer_signed_char)
{
GEN_TEST(signed char);
}
TEST(MSGPACK, simple_buffer_unsigned_char)
{
GEN_TEST(unsigned char);
}
TEST(MSGPACK, simple_buffer_short)
{
GEN_TEST(short);
}
TEST(MSGPACK, simple_buffer_int)
{
GEN_TEST(int);
}
TEST(MSGPACK, simple_buffer_long)
{
GEN_TEST(long);
}
TEST(MSGPACK, simple_buffer_long_long)
{
GEN_TEST(long long);
}
TEST(MSGPACK, simple_buffer_unsigned_short)
{
GEN_TEST(unsigned short);
}
TEST(MSGPACK, simple_buffer_unsigned_int)
{
GEN_TEST(unsigned int);
}
TEST(MSGPACK, simple_buffer_unsigned_long)
{
GEN_TEST(unsigned long);
}
TEST(MSGPACK, simple_buffer_unsigned_long_long)
{
GEN_TEST(unsigned long long);
}
TEST(MSGPACK, simple_buffer_uint8)
{
GEN_TEST(uint8_t);
}
TEST(MSGPACK, simple_buffer_uint16)
{
GEN_TEST(uint16_t);
}
TEST(MSGPACK, simple_buffer_uint32)
{
GEN_TEST(uint32_t);
}
TEST(MSGPACK, simple_buffer_uint64)
{
GEN_TEST(uint64_t);
}
TEST(MSGPACK, simple_buffer_int8)
{
GEN_TEST(int8_t);
}
TEST(MSGPACK, simple_buffer_int16)
{
GEN_TEST(int16_t);
}
TEST(MSGPACK, simple_buffer_int32)
{
GEN_TEST(int32_t);
}
TEST(MSGPACK, simple_buffer_int64)
{
GEN_TEST(int64_t);
}
TEST(MSGPACK, simple_buffer_float)
{
vector<float> v;
v.push_back(0.0);
v.push_back(-0.0);
v.push_back(1.0);
v.push_back(-1.0);
v.push_back(numeric_limits<float>::min());
v.push_back(numeric_limits<float>::max());
v.push_back(nanf("tag"));
if (numeric_limits<float>::has_infinity) {
v.push_back(numeric_limits<float>::infinity());
v.push_back(-numeric_limits<float>::infinity());
}
if (numeric_limits<float>::has_quiet_NaN) {
v.push_back(numeric_limits<float>::quiet_NaN());
}
if (numeric_limits<float>::has_signaling_NaN) {
v.push_back(numeric_limits<float>::signaling_NaN());
}
for (unsigned int i = 0; i < kLoop; i++) {
v.push_back(static_cast<float>(msgpack_rand()));
v.push_back(static_cast<float>(-msgpack_rand()));
}
for (unsigned int i = 0; i < v.size() ; i++) {
msgpack::sbuffer sbuf;
float val1 = v[i];
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
float val2 = oh.get().as<float>();
if (std::isnan(val1))
EXPECT_TRUE(std::isnan(val2));
else if (std::isinf(val1))
EXPECT_TRUE(std::isinf(val2));
else
EXPECT_TRUE(fabs(val2 - val1) <= kEPS);
}
}
namespace {
template<typename F, typename I>
struct TypePair {
typedef F float_type;
typedef I integer_type;
};
} // namespace
template <typename T>
class IntegerToFloatingPointTest : public testing::Test {
};
TYPED_TEST_CASE_P(IntegerToFloatingPointTest);
TYPED_TEST_P(IntegerToFloatingPointTest, simple_buffer)
{
typedef typename TypeParam::float_type float_type;
typedef typename TypeParam::integer_type integer_type;
vector<integer_type> v;
v.push_back(0);
v.push_back(1);
if (numeric_limits<integer_type>::is_signed) v.push_back(-1);
else v.push_back(2);
for (unsigned int i = 0; i < kLoop; i++) {
v.push_back(rand() % 0x7FFFFF);
}
for (unsigned int i = 0; i < v.size() ; i++) {
msgpack::sbuffer sbuf;
integer_type val1 = v[i];
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
float_type val2 = oh.get().as<float_type>();
EXPECT_TRUE(fabs(val2 - val1) <= kEPS);
}
}
REGISTER_TYPED_TEST_CASE_P(IntegerToFloatingPointTest,
simple_buffer);
typedef testing::Types<TypePair<float, signed long long>,
TypePair<float, unsigned long long>,
TypePair<double, signed long long>,
TypePair<double, unsigned long long> > IntegerToFloatingPointTestTypes;
INSTANTIATE_TYPED_TEST_CASE_P(IntegerToFloatingPointTestInstance,
IntegerToFloatingPointTest,
IntegerToFloatingPointTestTypes);
TEST(MSGPACK, simple_buffer_double)
{
vector<double> v;
v.push_back(0.0);
v.push_back(-0.0);
v.push_back(1.0);
v.push_back(-1.0);
v.push_back(numeric_limits<double>::min());
v.push_back(numeric_limits<double>::max());
v.push_back(nanf("tag"));
if (numeric_limits<double>::has_infinity) {
v.push_back(numeric_limits<double>::infinity());
v.push_back(-numeric_limits<double>::infinity());
}
if (numeric_limits<double>::has_quiet_NaN) {
v.push_back(numeric_limits<double>::quiet_NaN());
}
if (numeric_limits<double>::has_signaling_NaN) {
v.push_back(numeric_limits<double>::signaling_NaN());
}
for (unsigned int i = 0; i < kLoop; i++) {
v.push_back(msgpack_rand());
v.push_back(-msgpack_rand());
}
for (unsigned int i = 0; i < kLoop; i++) {
v.push_back(msgpack_rand());
v.push_back(-msgpack_rand());
}
for (unsigned int i = 0; i < v.size() ; i++) {
msgpack::sbuffer sbuf;
double val1 = v[i];
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
double val2 = oh.get().as<double>();
if (std::isnan(val1))
EXPECT_TRUE(std::isnan(val2));
else if (std::isinf(val1))
EXPECT_TRUE(std::isinf(val2));
else
EXPECT_TRUE(fabs(val2 - val1) <= kEPS);
}
}
TEST(MSGPACK, simple_buffer_nil)
{
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
packer.pack_nil();
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(oh.get().type, msgpack::type::NIL);
}
TEST(MSGPACK, simple_buffer_true)
{
msgpack::sbuffer sbuf;
bool val1 = true;
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
bool val2 = oh.get().as<bool>();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK, simple_buffer_false)
{
msgpack::sbuffer sbuf;
bool val1 = false;
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
bool val2 = oh.get().as<bool>();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK, simple_buffer_fixext1)
{
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char const buf [] = { 2 };
packer.pack_ext(sizeof(buf), 1);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(1ul, oh.get().via.ext.size);
EXPECT_EQ(1, oh.get().via.ext.type());
EXPECT_EQ(2, oh.get().via.ext.data()[0]);
}
TEST(MSGPACK, simple_buffer_fixext2)
{
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char const buf [] = { 2, 3 };
packer.pack_ext(sizeof(buf), 0);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(2ul, oh.get().via.ext.size);
EXPECT_EQ(0, oh.get().via.ext.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), oh.get().via.ext.data()));
}
TEST(MSGPACK, simple_buffer_fixext4)
{
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char const buf [] = { 2, 3, 4, 5 };
packer.pack_ext(sizeof(buf), 1);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(4ul, oh.get().via.ext.size);
EXPECT_EQ(1, oh.get().via.ext.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), oh.get().via.ext.data()));
}
TEST(MSGPACK, simple_buffer_fixext8)
{
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char const buf [] = { 2, 3, 4, 5, 6, 7, 8, 9 };
packer.pack_ext(sizeof(buf), 1);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(8ul, oh.get().via.ext.size);
EXPECT_EQ(1, oh.get().via.ext.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), oh.get().via.ext.data()));
}
TEST(MSGPACK, simple_buffer_fixext16)
{
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char const buf [] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 };
packer.pack_ext(sizeof(buf), 1);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(16ul, oh.get().via.ext.size);
EXPECT_EQ(1, oh.get().via.ext.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), oh.get().via.ext.data()));
}
TEST(MSGPACK, simple_buffer_fixext_1byte_0)
{
std::size_t const size = 0;
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
packer.pack_ext(size, 77);
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(size, oh.get().via.ext.size);
EXPECT_EQ(77, oh.get().via.ext.type());
}
TEST(MSGPACK, simple_buffer_fixext_1byte_255)
{
std::size_t const size = 255;
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char buf[size];
for (std::size_t i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
packer.pack_ext(sizeof(buf), 77);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(size, oh.get().via.ext.size);
EXPECT_EQ(77, oh.get().via.ext.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), oh.get().via.ext.data()));
}
TEST(MSGPACK, simple_buffer_fixext_2byte_256)
{
std::size_t const size = 256;
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char buf[size];
for (std::size_t i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
packer.pack_ext(sizeof(buf), 77);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(size, oh.get().via.ext.size);
EXPECT_EQ(77, oh.get().via.ext.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), oh.get().via.ext.data()));
}
TEST(MSGPACK, simple_buffer_fixext_2byte_65535)
{
std::size_t const size = 65535;
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char buf[size];
for (std::size_t i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
packer.pack_ext(sizeof(buf), 77);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(size, oh.get().via.ext.size);
EXPECT_EQ(77, oh.get().via.ext.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), oh.get().via.ext.data()));
}
TEST(MSGPACK, simple_buffer_fixext_4byte_65536)
{
std::size_t const size = 65536;
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char buf[size];
for (std::size_t i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
packer.pack_ext(sizeof(buf), 77);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(size, oh.get().via.ext.size);
EXPECT_EQ(77, oh.get().via.ext.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), oh.get().via.ext.data()));
}
TEST(MSGPACK, simple_buffer_ext_convert)
{
std::size_t const size = 65536;
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char buf[size];
for (std::size_t i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
packer.pack_ext(sizeof(buf), 77);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
msgpack::type::ext e;
oh.get().convert(e);
EXPECT_EQ(size, e.size());
EXPECT_EQ(77, e.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), e.data()));
}
TEST(MSGPACK, simple_buffer_ext_pack_convert)
{
std::size_t const size = 65536;
msgpack::sbuffer sbuf;
msgpack::type::ext val1(77, size);
char* buf = val1.data();
for (std::size_t i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
msgpack::type::ext val2;
oh.get().convert(val2);
EXPECT_EQ(size, val2.size());
EXPECT_EQ(77, val2.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), val2.data()));
}
TEST(MSGPACK, simple_buffer_ext_ref_convert)
{
std::size_t const size = 65536;
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char buf[size];
for (std::size_t i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
packer.pack_ext(sizeof(buf), 77);
packer.pack_ext_body(buf, sizeof(buf));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
msgpack::type::ext_ref er;
oh.get().convert(er);
EXPECT_EQ(size, er.size());
EXPECT_EQ(77, er.type());
EXPECT_TRUE(
std::equal(buf, buf + sizeof(buf), er.data()));
}
TEST(MSGPACK, simple_buffer_ext_ref_pack_convert)
{
std::size_t const buf_size = 65536;
std::size_t const data_size = buf_size - 1;
msgpack::sbuffer sbuf;
char buf[buf_size];
buf[0] = static_cast<char>(77);
for (std::size_t i = 0; i != data_size; ++i) buf[i + 1] = static_cast<char>(i);
msgpack::pack(sbuf, msgpack::type::ext_ref(buf, buf_size));
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
msgpack::type::ext_ref val2;
oh.get().convert(val2);
EXPECT_EQ(data_size, val2.size());
EXPECT_EQ(77, val2.type());
EXPECT_TRUE(
std::equal(&buf[1], &buf[buf_size], val2.data()));
}
TEST(MSGPACK_STL, simple_buffer_string)
{
for (unsigned int k = 0; k < kLoop; k++) {
string val1;
for (unsigned int i = 0; i < kElements; i++)
val1 += 'a' + rand() % 26;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(oh.get().type, msgpack::type::STR);
string val2 = oh.get().as<string>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_EQ(val1, val2);
}
}
TEST(MSGPACK_STL, simple_buffer_cstring)
{
for (unsigned int k = 0; k < kLoop; k++) {
string val1;
for (unsigned int i = 0; i < kElements; i++)
val1 += 'a' + rand() % 26;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1.c_str());
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(oh.get().type, msgpack::type::STR);
string val2 = oh.get().as<string>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_EQ(val1, val2);
}
}
TEST(MSGPACK_STL, simple_buffer_non_const_cstring)
{
for (unsigned int k = 0; k < kLoop; k++) {
string val1;
for (unsigned int i = 0; i < kElements; i++)
val1 += 'a' + rand() % 26;
msgpack::sbuffer sbuf;
char* s = new char[val1.size() + 1];
std::memcpy(s, val1.c_str(), val1.size() + 1);
msgpack::pack(sbuf, s);
delete [] s;
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(oh.get().type, msgpack::type::STR);
string val2 = oh.get().as<string>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_EQ(val1, val2);
}
}
| [
"eduardo@treasure-data.com"
] | eduardo@treasure-data.com |
404008f41a10a3a38ec2324a7a9ed59571cd6c58 | 1524d15fd2aab0f8c6aa5e5a9207b83804e75ab3 | /src/QQuickLightOutputPreview.h | 6328ae6323f57e6fb1e886cc21f0471e7e45811e | [
"MIT"
] | permissive | lilieming/radiance | de44d9f9f8ced3e543e47e7e1790cdcfaafea091 | 374a88fc9a403245cd1685b5ce96e757b5f70768 | refs/heads/master | 2020-05-20T06:21:08.153897 | 2019-05-05T21:43:40 | 2019-05-05T22:51:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,107 | h | #include <QQuickFramebufferObject>
#include "VideoNode.h"
class LightOutputRenderer;
class LightOutputNode;
class QQuickLightOutputPreview : public QQuickFramebufferObject
{
Q_OBJECT
Q_PROPERTY(VideoNode *videoNode READ videoNode WRITE setVideoNode NOTIFY videoNodeChanged)
public:
QQuickLightOutputPreview();
Renderer *createRenderer() const override;
// Use this method from other threads
LightOutputNode *videoNodeSafe();
public slots:
// Watch out--
// the pointer you pass in
// will be cloned and stored internally
// so don't rely in pointer values for equality checking
// or debugging.
// instead, check *videoNode == *otherVideoNode.
VideoNode *videoNode();
void setVideoNode(VideoNode *videoNode);
// In fact, these really should take in / return VideoNode instead of VideoNode*
// but then they would be non-nullable
// Also, they are not thread-safe.
signals:
void videoNodeChanged(VideoNode *videoNode);
protected:
LightOutputRenderer *m_renderer;
VideoNode *m_videoNode{};
QMutex m_videoNodeLock;
};
| [
"eric@van.al"
] | eric@van.al |
0431043aa797e2da35ac784180af6921c691a31d | be460e66f05c0259cf45e6c0cdb653fc2913972d | /acm/Online-Judge/vjudge/code/POJ3622.cpp | 9956e4ff104aee721d47407f0043c77e62cc9177 | [] | no_license | Salvare219/CodeLibrary | 3247aee350402dac3d94e059a8dc97d5d5436524 | 8961a6d1718c58d12c21a857b23e825c16bdab14 | refs/heads/master | 2021-06-16T18:38:21.693960 | 2017-05-09T12:47:36 | 2017-05-09T12:47:36 | 81,569,241 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 907 | cpp | #include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
struct p
{
int f,w;
bool operator<(p a)const{return w<a.w;}
}c[100005],g[100005];
#include<map>
map<int,int>mp;
map<int,int>::iterator it;
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
for(int i=0;i<n;i++)
scanf("%d%d",&c[i].f,&c[i].w);
for(int i=0;i<m;i++)
scanf("%d%d",&g[i].f,&g[i].w);
sort(c,c+n);sort(g,g+m);
int p=m-1;
bool f=0;mp.clear();
long long ans=0;
for(int i=n-1;i>-1;i--)
{
while(g[p].w>=c[i].w)mp[g[p--].f]++;
it=mp.lower_bound(c[i].f);
if(it==mp.end()){f=1;break;}
ans+=it->first;
if(--it->second==0)mp.erase(it);
}
if(f)puts("-1");
else printf("%lld\n",ans);
}
return 0;
}
| [
"635149007@qq.com"
] | 635149007@qq.com |
37b022ef2682097add87231b1ff3fd0ef133a949 | 3972bc51e7d2da197f48a7d62e25fdd7f81b47bb | /TCSocks.cpp | 665908bb7db92a189cc8f4baebc091ea4b4d0b9d | [] | no_license | EonKid/Topcoder-2 | 939a7308a9d0e87378968793e4e6999e658725c6 | 8404595ad50a60dce33ec55f9dd41ca2a402df8c | refs/heads/master | 2021-01-16T19:43:53.360661 | 2015-05-09T18:48:25 | 2015-05-09T18:48:25 | 40,596,421 | 1 | 0 | null | 2015-08-12T11:11:30 | 2015-08-12T11:11:30 | null | UTF-8 | C++ | false | false | 6,760 | cpp | #include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <climits>
#include <cstdio>
#include <stack>
#include <queue>
using namespace std;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
int maxp = 0, n = 0;
int city[10][105];
int C[10][10], T[10][10];
vi money;
int visited[15];
void solve(int pos, int time, int profit){
maxp = max(profit-C[pos][0], maxp);
for(int i = 1; i < n; i++){
if(visited[i] == 1) continue;
visited[i] = 1;
int t = time+T[pos][i];
solve(i, t, profit-C[pos][i]+(money[i]/city[i][t]));
visited[i] = 0;
}
}
class TCSocks{
public:
int earnMoney(vector <int> _money, vector <string> cost, vector <string> time, vector <string> competitors) {
money = _money;
n = money.size();
maxp = 0;
for(int i = 0; i < 10; i++)
for(int j = 0; j < 105; j++)
city[i][j] = 1;
for(int i = 0; i < n; i++){
stringstream ss(cost[i]), st(time[i]);
for(int j = 0; j < n; j++){
ss>>C[i][j];
st>>T[i][j];
}
}
for(string s : competitors){
stringstream ss(s);
int t = 0, j = 0, i = 0;
while(ss>>j){
t += T[i][j];
for(int k = t; k <= 100; k++) city[j][k] *= 2;
i = j;
}
}
solve(0, 0, 0);
return maxp;
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); if ((Case == -1) || (Case == 5)) test_case_5(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { int Arr0[] = {0, 100, 100, 100}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = {"0 50 50 200", "0 0 50 200", "0 10 0 200", "0 0 0 0"}; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); string Arr2[] = {"0 1 1 1", "1 0 1 1", "1 1 0 1", "1 1 1 0"}; vector <string> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); string Arr3[] = {}; vector <string> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 140; verify_case(0, Arg4, earnMoney(Arg0, Arg1, Arg2, Arg3)); }
void test_case_1() { int Arr0[] = {0, 100, 100, 100}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = {"0 50 50 200", "0 0 50 200", "0 10 0 200", "0 0 0 0"}; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); string Arr2[] = {"0 1 1 1", "1 0 1 1", "1 1 0 1", "1 1 1 0"}; vector <string> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); string Arr3[] = {"3", "2 3 1", "2 1"}; vector <string> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 50; verify_case(1, Arg4, earnMoney(Arg0, Arg1, Arg2, Arg3)); }
void test_case_2() { int Arr0[] = {0, 100, 200}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = {"0 20 10", "10 0 20", "20 10 0"}; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); string Arr2[] = {"0 1 5", "1 0 1", "1 1 0"}; vector <string> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); string Arr3[] = {"2", "2"}; vector <string> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 240; verify_case(2, Arg4, earnMoney(Arg0, Arg1, Arg2, Arg3)); }
void test_case_3() { int Arr0[] = {0, 40, 40, 40, 40, 40}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = {"0 25 25 25 25 25", "25 0 25 25 25 25", "25 25 0 25 25 25",
"25 25 25 0 25 25", "25 25 25 25 0 25", "25 25 25 25 25 0"}; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); string Arr2[] = {"0 1 1 1 1 1", "1 0 1 1 1 1", "1 1 0 1 1 1", "1 1 1 0 1 1", "1 1 1 1 0 1", "1 1 1 1 1 0"}; vector <string> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); string Arr3[] = {"1", "2", "3", "4", "5"}; vector <string> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 0; verify_case(3, Arg4, earnMoney(Arg0, Arg1, Arg2, Arg3)); }
void test_case_4() { int Arr0[] = {0, 70, 70, 70, 70, 70}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = {"0 25 25 25 25 25", "25 0 25 25 25 25", "25 25 0 25 25 25",
"25 25 25 0 25 25", "25 25 25 25 0 25", "25 25 25 25 25 0"}; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); string Arr2[] = {"0 1 1 1 1 1", "1 0 1 1 1 1", "1 1 0 1 1 1", "1 1 1 0 1 1", "1 1 1 1 0 1", "1 1 1 1 1 0"}; vector <string> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); string Arr3[] = {"1", "2", "3", "4", "5"}; vector <string> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 25; verify_case(4, Arg4, earnMoney(Arg0, Arg1, Arg2, Arg3)); }
void test_case_5() { int Arr0[] = {0,457,434,382,818,403,265,449,214}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = {"0 204 600 800 885 542 439 823 913",
"32 0 813 687 242 129 34 447 862",
"56 462 0 727 71 309 461 867 200",
"656 96 334 0 178 650 108 477 547",
"89 856 922 495 0 821 374 100 651",
"634 810 319 947 322 0 283 227 286",
"446 416 272 551 243 880 0 47 878",
"390 315 221 765 938 732 747 0 435",
"902 616 166 830 223 406 736 712 0"}; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); string Arr2[] = {"0 1 10 6 5 5 4 7 6",
"5 0 2 7 3 2 1 4 2",
"1 9 0 8 6 1 3 9 9",
"2 8 8 0 1 9 10 4 5",
"8 8 2 7 0 5 3 9 1",
"6 8 9 9 3 0 7 4 7",
"10 8 9 10 7 1 0 9 4",
"8 6 5 1 6 6 5 0 4",
"3 8 4 4 6 10 10 3 0"}; vector <string> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); string Arr3[] = {"1 8 2 5 4 7 6","6 2 4","8 7"}; vector <string> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 785; verify_case(5, Arg4, earnMoney(Arg0, Arg1, Arg2, Arg3)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main(){
TCSocks ___test;
___test.run_test(-1);
}
// END CUT HERE
| [
"nandan.keshav55@gmail.com"
] | nandan.keshav55@gmail.com |
bbbaec6e5d8a02aae62d1003ae0d5255aa3274b0 | 62169542ab2ff2a5bc1fc2eaaab319515ad35662 | /CoarseGrainSites/src/tests/regression/test_1Dsystem.cpp | 64810974264cb80af97e7765c74c8782d3eea03b | [
"MIT"
] | permissive | alfy16/CoarseGrainSites | ae7592a6290220d505659188ced51257355e0c2e | c8068539faa9cc4a804743bb3dc85881e1b8a3d2 | refs/heads/master | 2020-12-13T09:38:35.840911 | 2020-01-04T05:17:55 | 2020-01-04T05:17:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,347 | cpp | #include <iostream>
#include <vector>
#include <memory>
#include <chrono>
#include <string>
#include <random>
#include <map>
#include <unordered_map>
#include <set>
#include <cmath>
#include <cassert>
#include <algorithm>
#include "../../../include/kmccoarsegrain/kmc_coarsegrainsystem.hpp"
#include "../../../include/kmccoarsegrain/kmc_walker.hpp"
using namespace std;
using namespace std::chrono;
using namespace kmccoarsegrain;
bool compareSecondItemOfPair(const pair<int,double> &x, const pair<int,double> & y){
return x.second<y.second;
}
int main(int argc, char* argv[]){
if(argc!=7){
cerr << "To run the program correctly you must provide the " << endl;
cerr << "following parameters: " << endl;
cerr << endl;
cerr << "distance - integer defines the length of the 1d system" << endl;
cerr << " in terms of the number of sites. [nm] " << endl;
cerr << "seed - integer value defines the random number seed" << endl;
cerr << "threshold - integer value defines minimum threshold of " << endl;
cerr << " how often the simulation will try to coarse " << endl;
cerr << " grain." << endl;
cerr << "time - a double defining how long the simulation " << endl;
cerr << " will run for." << endl;
cerr << "sample - how often the current is sampled with respect"<< endl;
cerr << "rate to the cutoff time." <<endl;
cerr << "field - the electric field across the system. [V/cm]" << endl;
cerr << endl;
cerr << "To run:" << endl;
cerr << endl;
cerr << "./performance_test_crude_vs_coarsegraining distance seed threshold time sampe_rate field" << endl;
cerr << endl;
return -1;
}
int distance = stoi(string(argv[1]));
int seed = stoi(string(argv[2]));
int threshold = stoi(string(argv[3]));
double cutoff_time = stod(string(argv[4]));
int sample_rate = stoi(string(argv[5]));
double field = stod(string(argv[6]));
cout << endl;
cout << "Parameters passed in:" << endl;
cout << endl;
cout << "distance: " << distance << endl;
cout << "seed: " << seed << endl;
cout << "threshold: " << threshold << endl;
cout << "time: " << cutoff_time << endl;
cout << "sample rate: " << sample_rate << endl;
cout << "field: " << field << endl;
cout << endl;
double field_nm = field*10E-7; // eV/nm
double nm_to_m = 1E-9; // nm/m
cout << "field [eV/nm]: " << field_nm << endl;
double reorganization_energy = 0.01;
// Record setup time
int number_of_trap_sites = distance/10;
cout << "Total number of trap sites " << number_of_trap_sites << endl;
vector<double> energies(distance,0.0);
{
// Setup the energies so that two low energy sites appear every 2 sites
for(int index=0;index<distance;++index){
if(index%8==0 || index%9==1){
energies.at(index)=-reorganization_energy*5;
}
}
}
unordered_map<int,unordered_map<int,double>> rates;
unordered_map<int,vector<int>> neighbors;
{
double J = 0.01;
double kBT = 0.025;
cout << "Calculating rates using Semiclassical Marcus theory assuming: " << endl;
cout << endl;
cout << "reoganization energy lambda: " << reorganization_energy << endl;
cout << "transfer integral J: " << J << endl;
cout << "Boltzmann constant * temperature kBT: " << kBT << endl;
double hbar = pow(6.582,-16);
double pi = 3.14;
// Define marcus coefficient
double coef = 2*pi/hbar*pow(J,2.0)*1/pow(4*pi*kBT,1.0/2.0);
for(int x=0; x<distance; ++x){
// Define neighbors
int xlow = x;
int xhigh = x;
if(xlow-1>0) --xlow;
if(xhigh+1<distance) ++xhigh;
int siteId = x;
for( int x2 = xlow; x2<=xhigh; ++x2){
double xdiff = static_cast<double>(x2-x);
// Sign change is because a positive field should lower the energy
double field_energy = -1.0*xdiff*field_nm;
assert(x2>=0);
assert(x2<distance);
int neighId = x2;
if(siteId!=neighId){
neighbors[siteId].push_back(neighId);
double deltaE = energies.at(neighId)-energies.at(siteId)-field_energy;
double exponent = -pow(reorganization_energy-deltaE,2.0)/(4.0*reorganization_energy*kBT);
rates[siteId][neighId] = coef*exp(exponent);
}
}
assert(rates[siteId].size()!=0);
}
}
// Run coarse grained Monte Carlo
cout << "Running coarse grained Monte Carlo" << endl;
{
// greating map with pointer to rates
/* unordered_map< int, unordered_map< int, double *>> rates_to_neighbors;
{
for(auto site_rates : rates){
for( auto neigh_rate : site_rates.second){
rates_to_neighbors[site_rates.first][neigh_rate.first] =&(rates[site_rates.first][neigh_rate.first]);
}
}
}*/
// Run the coarse grain simulation
{
double current_time_sample_increment = cutoff_time/static_cast<double>(sample_rate);
double sample_time = current_time_sample_increment;
KMC_CoarseGrainSystem CGsystem;
CGsystem.setRandomSeed(seed);
CGsystem.setMinCoarseGrainIterationThreshold(threshold);
CGsystem.setTimeResolution(sample_time);
CGsystem.initializeSystem(rates);
class Electron : public KMC_Walker {};
// Only a single electron is created but the simulation is repeated
// several times
int repetitions = 8;
vector<vector<double>> all_transient_currents;
cout << "Repetitions " << repetitions << endl;
for(int rep=0; rep<repetitions;++rep){
// Create the electrons using the KMC_Walker class
vector<pair<int,KMC_Walker>> electrons;
Electron electron;
int id = 0;
electrons.push_back(pair<int,KMC_Walker>(id,electron));
int siteId = 0;
electrons.at(0).second.occupySite(siteId);
CGsystem.initializeWalkers(electrons);
vector<double> transient_current(sample_rate,0.0);
// Calculate Walker dwell times and sort
list<pair<int,double>> walker_global_times;
{
mt19937 random_number_generator;
random_number_generator.seed(3);
uniform_real_distribution<double> distribution(0.0,1.0);
walker_global_times.push_back(pair<int,double>(id,electrons.at(0).second.getDwellTime()));
walker_global_times.sort(compareSecondItemOfPair);
}// Calculate walker dwell times and sort
assert(walker_global_times.begin()->second<cutoff_time);
int current_index = 0;
while(!walker_global_times.empty() && walker_global_times.begin()->second<cutoff_time){
double deltaX = 0.0;
while(!walker_global_times.empty() && walker_global_times.begin()->second<sample_time){
auto walker_index = walker_global_times.begin()->first;
KMC_Walker& electron = electrons.at(walker_index).second;
int siteId = electron.getIdOfSiteCurrentlyOccupying();
int old_x_pos = siteId;
CGsystem.hop(walker_index,electron);
siteId = electron.getIdOfSiteCurrentlyOccupying();
int new_x_pos = siteId;
deltaX+=static_cast<double>(new_x_pos-old_x_pos);
// Update the dwell time
walker_global_times.begin()->second += electron.getDwellTime();
// reorder the walkers based on which one will move next
if(new_x_pos==(distance-1)){
cout << "a. Repetition " << rep << " final position " << electrons.at(0).second.getIdOfSiteCurrentlyOccupying() << endl;
CGsystem.removeWalkerFromSystem(walker_index,electron);
walker_global_times.pop_front();
}
}
transient_current.at(current_index) = deltaX*nm_to_m/current_time_sample_increment;
++current_index;
sample_time+=current_time_sample_increment;
}
if(walker_global_times.size()!=0){
cout << "b. Repetition " << rep << " final position " << electrons.at(0).second.getIdOfSiteCurrentlyOccupying() << endl;
CGsystem.removeWalkerFromSystem(electrons.at(0).first,electrons.at(0).second);
walker_global_times.pop_front();
}
all_transient_currents.push_back(transient_current);
cout << "end of for loop" << endl;
} // End of the reps
auto clusters = CGsystem.getClusters();
cout << "Number of clusters found " << clusters.size() << endl;
// Calulate the mean of the transient currents
double sum = 0.0;
double count = 0.0;
for( auto trans : all_transient_currents){
for(auto current : trans){
count+=1.0;
sum+=current;
}
}
double mean = sum/count;
// Caluculate the standard deviation
double sum_squares=0.0;
for( auto trans : all_transient_currents){
for(auto current : trans){
sum_squares+=pow(current-mean,2.0);
}
}
double standard_deviation = pow(sum_squares/count,0.5);
cout << "Standard deviation " << standard_deviation << endl;
cout << "Mean " << mean << endl;
}// End of the Coarse grain simulation
} // End of coarse grain Monte Carlo
return 0;
}
| [
"joshbro42867@yahoo.com"
] | joshbro42867@yahoo.com |
61e32847e8a0748fc54aadf2608b8d60f7a8fa5f | 6079cdc3e356cac0db106d38bd27ca90141bba78 | /TraceRoute/TraceRoute/Device.h | 7a74428147b4426eed6721e05d0bf9ee19e35614 | [
"MIT"
] | permissive | YunYouJun/Advanced-Windows-Network-Programming | c32856a9d80409546ad545265e62cff74fbb7d17 | 1205b37fc6bd15a1c13a254d66c6940c6175fbc2 | refs/heads/master | 2022-04-14T07:17:24.801719 | 2020-04-10T16:32:55 | 2020-04-10T16:32:55 | 209,290,881 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 292 | h | #pragma once
#include "Common.h"
class Device
{
private:
pcap_if_t *alldevs;
pcap_if_t *d;
pcap_t *adhandle;
public:
int obtainDeviceList();
int openAdapter(const char *nam);
int setFilter(const char *packet_filter);
void sendPacket(const BYTE *packet);
pcap_t *getHandle() const;
}; | [
"me@yunyoujun.cn"
] | me@yunyoujun.cn |
a4a4306ccc08ebfa9b26734c120f965620ac24d5 | 86a70b4a86a9751ea19c248c047c22546b743cc5 | /include/algo/blast/api/rps_aux.hpp | 1ba4975e042508a7c1a175675503e376107261f0 | [] | no_license | mkuhn/blast-matrix | 05b9b8a274b5d8eaa220ec89df6741ffbc8c62d6 | 915ba9ac3a81549c53b314a059188c937993efd8 | refs/heads/master | 2020-12-22T10:51:47.040589 | 2012-10-24T09:14:24 | 2012-10-24T09:14:24 | 236,756,103 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,304 | hpp | /* $Id: rps_aux.hpp 103491 2007-05-04 17:18:18Z kazimird $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
*
* This software/database is a "United States Government Work" under the
* terms of the United States Copyright Act. It was written as part of
* the author's official duties as a United States Government employee and
* thus cannot be copyrighted. This software/database is freely available
* to the public for use. The National Library of Medicine and the U.S.
* Government have not placed any restriction on its use or reproduction.
*
* Although all reasonable efforts have been taken to ensure the accuracy
* and reliability of the software and data, the NLM and the U.S.
* Government do not and cannot warrant the performance or results that
* may be obtained by using this software or data. The NLM and the U.S.
* Government disclaim all warranties, express or implied, including
* warranties of performance, merchantability or fitness for any particular
* purpose.
*
* Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
* Author: Christiam Camacho
*
*/
/// @file rps_aux.hpp
/// Declares auxiliary classes to manage RPS-BLAST related C-structures
#ifndef ALGO_BLAST_API__RPS_AUX___HPP
#define ALGO_BLAST_API__RPS_AUX___HPP
#include <algo/blast/core/blast_export.h>
#include <algo/blast/core/blast_aalookup.h> // for BlastRPSLookupTable
#include <algo/blast/core/blast_rps.h>
/** @addtogroup AlgoBlast
*
* @{
*/
BEGIN_NCBI_SCOPE
BEGIN_SCOPE(blast)
// Forward declarations
class CBlastRPSAuxInfo;
class CRpsAuxFile;
class CRpsLookupTblFile;
class CRpsPssmFile;
// The BLAST Engine currently needs the BlastRPSInfo structure for both the
// preliminary stage and the traceback search. In practice, the setup code
// needs the aux_info field to copy the orig_score_matrix field, gap costs and
// scaling factor. The preliminary stage needs its lookup_header and
// profile_header fields, and the traceback search needs the profile_header
// field and the aux_info's karlin_k field. This suggests that a better
// organization might be needed.
/// Wrapper class to manage the BlastRPSInfo structure, as currently
/// there aren't any allocation or deallocation functions for this structure in
/// the CORE of BLAST. This class is meant to be kept in a CRef<>.
class NCBI_XBLAST_EXPORT CBlastRPSInfo : public CObject {
public:
/// Parametrized constructor
/// @param rps_dbname name of the RPS-BLAST database
CBlastRPSInfo(const string& rps_dbname);
/// Destructor
~CBlastRPSInfo();
/// Accessor for the underlying C structure (managed by this class)
const BlastRPSInfo* operator()() const;
/// Returns the scaling factor used to build RPS-BLAST database
double GetScalingFactor() const;
/// Returns the name of the scoring matrix used to build the RPS-BLAST
/// database
const char* GetMatrixName() const;
// FIXME: the following two methods are an interface that return the
// permissible gap costs associated with the matrix used when building the
// RPS-BLAST database... these could be removed if some other interface
// provided those given the matrix name.
/// Returns the gap opening cost associated with the scoring matrix above
int GetGapOpeningCost() const;
/// Returns the gap extension cost associated with the scoring matrix above
int GetGapExtensionCost() const;
private:
/// Prohibit copy-constructor
CBlastRPSInfo(const CBlastRPSInfo& rhs);
/// Prohibit assignment operator
CBlastRPSInfo& operator=(const CBlastRPSInfo& rhs);
/// The auxiliary RPS-BLAST file (.aux)
CRef<CRpsAuxFile> m_AuxFile;
/// The PSSM RPS-BLAST file (.rps)
CRef<CRpsPssmFile> m_PssmFile;
/// The lookup table RPS-BLAST file (.loo)
CRef<CRpsLookupTblFile> m_LutFile;
/// Pointer which contains pointers to data managed by the data members
/// above
BlastRPSInfo* m_RpsInfo;
};
END_SCOPE(blast)
END_NCBI_SCOPE
/* @} */
#endif /* ALGO_BLAST_API__RPS_AUX___HPP */
| [
"mkuhn@localhost"
] | mkuhn@localhost |
4e896b7f0c4adec18c434bc1b2138cc36b3a8fc0 | cfedaeba133c39f827df1d4ed79f53a29c2e7d90 | /Class/Gaddis_9thEdition_Prob3_KineticEnergy/main.cpp | ee0f8d33992f19c6b767535c9b00fc81a512cb0e | [] | no_license | ADLV2848113/DeLaVegaAnayely_CSC5_46740 | 909417521c73065f0254a9c68ce2df7e2267545e | eda2f0e02fefab03f68fa08d0b29958b4651ccde | refs/heads/master | 2022-11-26T03:25:38.161469 | 2020-07-29T02:48:50 | 2020-07-29T02:48:50 | 274,499,198 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,208 | cpp | /*
* File:
* Author: Anayely De La Vega
* Created on July 21, 2020 2:50 PM
* Purpose: To calculate the retail price after adding the original price with the markup percentage
*/
//System Libraries
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
//User Libraries
//Global Constants - No Global Variables
//Only Universal Constants, Math, Physics, Conversions, Higher Dimensions
//Function Prototypes
//Execution Begins Here
int main(int argc, char** argv) {
//Set Random Number seed
//Declare Variable Data Types and Constants
float kinEner;//The kinetic Energy in Joules
float mass, velocit;//Input mass in kilograms and the velocity in meters/seconds
//Initialize Variables
//Process or map Inputs to Outputs
cout<<"Enter the object's mass:"<<endl;
cin>>mass;
cout<<"Enter the object's velocity:"<<endl;
cin>>velocit;
//This will be the function call
kinEner = (0.5) * (mass) * (pow(velocit,2));
//Display Outputs
cout<<"The object has "<<setprecision(1)<<fixed<<kinEner
<<" Joule of energy.";
//Exit stage right!
return 0;
} | [
"adelavega1@student.rccd.edu"
] | adelavega1@student.rccd.edu |
dd264886caaf0981455ef6b8937e387ab87ffc09 | 63bf1112a83a8848fc255740b44b26fa89950154 | /cpp/leetcode/50.cpp | b46e7e29f1d690763726ce7a474850aa6f6e4aa7 | [] | no_license | nkuflk/fun-code | 87d204bab967ee0c085e8394ed47c55ccbe32c31 | fc42bcd99cc7a530f32a4e27a701984a827636f5 | refs/heads/master | 2020-03-29T18:28:54.597599 | 2018-05-17T13:29:14 | 2018-05-17T13:29:14 | 35,192,745 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 242 | cpp | class Solution {
public:
double myPow(double x, int n) {
double ans = 1.0;
int m = n;
if (n < 0) n = -n;
while (n > 0) {
if (n & 1)
ans *= x;
x *= x;
n >>= 1;
}
if (m < 0) return 1.0 / ans;
return ans;
}
};
| [
"heyuntao789789@163.com"
] | heyuntao789789@163.com |
4168babec5a7cc975339d16438162388508f2c69 | ace9260e065bca55235f44c1a67a52d5a375096d | /layer.cpp | 5bd1fcc9cd5e80893d22e0c80217c014c1139ec9 | [
"Apache-2.0"
] | permissive | fllaryora/ANN | 9ae06e96c3171e2efbf0a12e948b6547de621191 | 76a184d54b490bf3c6b66b6a0e9adc26039722da | refs/heads/master | 2020-11-27T14:15:34.318470 | 2020-10-23T18:23:26 | 2020-10-23T18:23:26 | 229,480,797 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,249 | cpp | /*
How to use:
first call init method, with number of input with umbral input inclusive.
then call setRankSynapses with w0 = - theta,
one by one of each neuron i= 0,1,2,3...and so on.
next call rankThresshold to get the activation function array
*/
#include <stdio.h>
#include "layer.h"
#include "neuron.h"
#include <assert.h>
Layer::Layer(){
}
void
Layer::init(int neuronAmount, int activationType, int enties, int biasType){
if (neuronAmount <= 0){
//printf("=========neuronAmount per layer must be at least 1============ \n");
assert(false);
}
this->layerNeuronAmount = neuronAmount;
this->neuronArray = new Neuron [neuronAmount];
for(int i = 0; i < neuronAmount; ++i){
this->neuronArray[i].init(enties, activationType, biasType);
}
}
/*Get the number of dentrites*/
Layer::~Layer(){
printf("=========~Layer============ \n");
delete [] neuronArray;
}
Neuron* Layer:: getNeuronAt(int index){
if( index < 0 || index >= layerNeuronAmount ) {
//printf("========= getNeuronAt index is less than 0 or greather than %i ============ \n", layerNeuronAmount-1);
assert(false);
}
return &neuronArray[index];
}
int Layer::getLayerNeuronAmount(){
return this->layerNeuronAmount;
} | [
"fllaryora@gmail.com"
] | fllaryora@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.