blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
247
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 4
111
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
58
| visit_date
timestamp[ns]date 2015-07-25 18:16:41
2023-09-06 10:45:08
| revision_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| github_id
int64 3.89k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 25
values | gha_event_created_at
timestamp[ns]date 2012-06-07 00:51:45
2023-09-14 21:58:52
⌀ | gha_created_at
timestamp[ns]date 2008-03-27 23:40:48
2023-08-24 19:49:39
⌀ | gha_language
stringclasses 159
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
10.5M
| extension
stringclasses 111
values | filename
stringlengths 1
195
| text
stringlengths 7
10.5M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
70490c70fc7aa556902e1fd8e0936bff5ce55ef4
|
0b737ef49ba9e3e7b0b27c3e5a4c45b30556aa4a
|
/Synatexer_Analizer.h
|
c89e0785bf6af43d153bbe8e9066e03b3c4860be
|
[] |
no_license
|
liffert/Translator
|
44ed05bbfbd654371069b7d2ec11162611994846
|
546e27e8aa19fa914c1aba311fca6a57f9b7ee77
|
refs/heads/master
| 2020-12-29T21:12:00.956009
| 2020-05-28T21:23:11
| 2020-05-28T21:23:11
| 238,733,488
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 920
|
h
|
Synatexer_Analizer.h
|
#pragma once
#include <iostream>
#include "Tables.h"
#include "Tree.h"
#include "Lexical_Analizer.h"
#include <sstream>
class Synatexer_Analizer {
private:
bool program();
bool block();
bool declaration();
bool label_declaration();
bool label_list();
bool parameters_list();
bool identifiers_list();
bool statements_list();
bool statement(bool& err);
bool variable_identifier();
bool procedure_identifier();
bool asfi();
bool identifier();
bool unsigned_integer();
bool currentAdd();
std::shared_ptr<std::vector<Lexical_Analizer::lexStruct>> lex;
std::shared_ptr<Tables> tables;
Tree tree;
std::vector<Lexical_Analizer::lexStruct>::iterator current;
std::stringstream error;
bool succsess = false;
public:
Synatexer_Analizer(std::shared_ptr<Tables>& Tables, std::vector<Lexical_Analizer::lexStruct>& lex);
Tree start();
bool isSuccsess() const;
std::string getError() const;
};
|
f2c4d4b7b29ce0d050d5ea8984f850ba9c863b75
|
6280dceebbfe6a0d85c2a7320413e2e4a7cb1223
|
/Round_492_Div2/A.cpp
|
7068cf1a63399e9a2dd41a051fd80184fff2bed9
|
[] |
no_license
|
AleksandarTulic/Codeforces
|
fbbccae1ba6be48efce3d62ba67e2cacb075a1fd
|
78c9a39aa4c60df7668ee08bf5bb6c626e179ab1
|
refs/heads/master
| 2020-06-23T11:46:54.752711
| 2019-08-30T21:10:59
| 2019-08-30T21:10:59
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 361
|
cpp
|
A.cpp
|
#include <iostream>
#include <fstream>
#include <string>
#include <utility>
#include <map>
using namespace std;
int main() {
int n;
cin>>n;
int br = 0;
while (n>=100) br++, n-=100;
while (n>=20) br++, n-=20;
while (n>=10) br++, n-=10;
while (n>=5) br++, n-=5;
while (n>=1) br++, n-=1;
cout<<br<<endl;
return 0;
}
|
232851fb4139a1f900c6eb363c7721020dcae2a5
|
89bc274c951480d5d728294dcbabd9d11b5f00ec
|
/framework/JPetTSlot/JPetTSlot.h
|
0db1f1c7c5dff6d8df0a980a4a46acd541d74024
|
[
"MIT"
] |
permissive
|
wictus/oldScopeAnalysis
|
f73c680e48155cfeba75a0ca99a578d60471f823
|
e8a15f11c504c1a1a880d4a5096cdbfac0edf2de
|
refs/heads/master
| 2020-07-19T07:26:11.618505
| 2019-09-04T20:02:42
| 2019-09-04T20:02:42
| 206,401,149
| 0
| 0
|
MIT
| 2019-09-04T20:02:43
| 2019-09-04T19:50:15
| null |
UTF-8
|
C++
| false
| false
| 1,776
|
h
|
JPetTSlot.h
|
#ifndef _JPETTSLOT_H_
#define _JPETTSLOT_H_
#include <vector>
#include <map>
#include <TNamed.h>
#include "../JPetSigCh/JPetSigCh.h"
#include <TClonesArray.h>
/**
* @brief Data class representing a time window of the TRB board.
*
* A single TSlot contains many SigCh objects representing TDC hits recorded during a time window of the TRB board.
*/
class JPetTSlot: public TNamed
{
public:
/// @todo think about changing TClonesArray to something else ? what about cleaning
JPetTSlot()
{
SetName("JPetTSlot");
}
void addCh(JPetSigCh& new_ch);
inline size_t size() const {
return fSigChannels.size();
}
inline size_t getNumberOfSigCh() const {
return fSigChannels.size();
}
inline const std::vector<JPetSigCh*>& getSigChVect() const {
return fSigChannels;
}
/**
* @brief Get i-th SigCh object from this time window as if from an array
*
* @param i number of SigCh object to be returned; i should be between 0 and getNumberOfSigCh-1
*/
inline JPetSigCh& operator[](int i) const {
return *((JPetSigCh*)fSigChannels[i]);
}
virtual ~JPetTSlot() {
// fSigChannels.Clear("C");
}
/**
* @brief Get the index number of this TSlot
*
* Each TSlot (time window) in a HLD file is assigned an index number, counting from first TSlot in the file. This number may be useful if empty TSlots are skipped during analysis.
* @oaram index a squential number of this TSlot counting from sirst TSlot in a HLD file
*/
inline unsigned int getIndex() const { return fIndex; }
inline void setIndex(unsigned int index) { fIndex = index; }
ClassDef(JPetTSlot, 1);
private:
std::vector<JPetSigCh*> fSigChannels;
unsigned int fIndex; ///< sequential number of this TSlot in the HLD file
};
#endif
|
ed4c514468d7a9fc8c7eccbe77cafdf7b97b4706
|
3a082e44fd5297f5c461a5b8a54260547f09dbec
|
/309div2/test.cpp
|
efa7eced359e279aa57040ecc6807b4e5bb58915
|
[] |
no_license
|
atyamsriharsha/codeforces_contests
|
e7397f56ef2c391d35aaa0baeed5720a4da69ffc
|
a92180b1bebfcca834ee2dbb0bbc397637a5ea2c
|
refs/heads/master
| 2021-01-19T07:49:23.325015
| 2015-08-03T04:04:32
| 2015-08-03T04:04:32
| 40,104,346
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 777
|
cpp
|
test.cpp
|
#include <bits/stdc++.h>
using namespace std;
#define fr(i,n,m) for (int i = (n) ; i < (m) ; i ++)
#define rp(i,n,m) for (int i = (n - 1) ; i >= (m) ; i --)
#define fr_(i,n,m,k) for (int i = (n) ; i < (m) ; i += k)
#define rp_(i,n,m,k) for (int i = (n - 1) ; i >= (m) ; i -= k)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define f first
#define s second
typedef long long ll;
ll const mod = 1e9 + 7;
ll c[2015][2015] , a[1010] , b[1010] , k , ans = 1;
int main(){
fr(i,0,2015){
c[i][i] = 1;
fr(j,i+1,2015){
if (!i) c[i][j] = 1;
else c[i][j] = (c[i-1][j-1] + c[i][j-1]) % mod;
}
}
cin >> k;
fr(i,1,k+1){
cin >> a[i];
b[i] = a[i-1] + b[i-1];
}
fr(i,2,k+1){
(ans *= c[b[i]][a[i]+b[i]-1]) %= mod;
}
return cout << ans , 0;
}
|
1cb794c560314cec6e256487606745caf3fd66c7
|
3938cada3da2235ae099cea44ca0294e9b03a225
|
/303 Range Sum Query/Range Sum Query_cpp/Range Sum Query_cpp/Range Sum Query_cpp.cpp
|
c5d94955ebdc8c8a031addd2e8f7aa5fb433ef98
|
[] |
no_license
|
WuminWu/Leetcode-Project
|
43618f0610a2545ae944ddbd0ee82c3a293405ed
|
ea2c340ef41058402363261b144285fee7fba613
|
refs/heads/master
| 2016-09-13T09:05:15.343889
| 2016-06-03T09:45:33
| 2016-06-03T09:45:33
| 58,518,080
| 0
| 0
| null | null | null | null |
BIG5
|
C++
| false
| false
| 463
|
cpp
|
Range Sum Query_cpp.cpp
|
// Range Sum Query_cpp.cpp : 定義主控台應用程式的進入點。
//
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
class NumArray {
public:
NumArray(vector<int> &nums) {
}
int sumRange(int i, int j) {
}
};
// Your NumArray object will be instantiated and called as such:
// NumArray numArray(nums);
// numArray.sumRange(0, 1);
// numArray.sumRange(1, 2);
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
|
93fe3bda9d1e2f2fe17528f92a3987a34b394e8d
|
66286815cc5aa5e2598056060cc3a14d6bf297ef
|
/src/app/core/Entities/AbstractSeq.h
|
5f05176874253bbc0e35644a1552c5841f0c0128
|
[] |
no_license
|
lukeulrich/alignshop-qt
|
07b022d8b15a75a7474e13f7c0ef3c0e43275577
|
030614f8fcc6c5bb4f6ed7f10987b5e5d11fe764
|
refs/heads/master
| 2020-07-28T03:06:04.528197
| 2016-11-10T21:19:41
| 2016-11-10T21:19:41
| 73,421,548
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,000
|
h
|
AbstractSeq.h
|
/****************************************************************************
**
** Copyright (C) 2011 Agile Genomics, LLC
** All rights reserved.
** Author: Luke Ulrich
**
****************************************************************************/
#ifndef ABSTRACTSEQ_H
#define ABSTRACTSEQ_H
#include <QtCore/QString>
#include "AbstractBasicEntity.h"
#include "AbstractAnonSeq.h"
class Seq;
struct AbstractSeqPod;
class AbstractSeq : public AbstractBasicEntity
{
public:
typedef boost::shared_ptr<AbstractSeq> SPtr;
AbstractAnonSeqSPtr abstractAnonSeq() const;
BioString parentBioString() const;
BioString bioString() const;
int length() const;
ClosedIntRange range() const;
int seqLength() const; //!< Returns the total length of the parent seq object
int start() const;
int stop() const;
QString source() const;
bool setStart(int start);
bool setStop(int stop);
void setSource(const QString &source);
protected:
AbstractSeq(int id,
int start,
int stop,
const QString &name,
const QString &source,
const QString &description,
const QString ¬es,
const AbstractAnonSeqSPtr &abstractAnonSeq);
// These are protected fields rather than public so that when they are changed, we can toggle the dirty status
// of this object
int start_;
int stop_;
QString source_;
AbstractAnonSeqSPtr abstractAnonSeq_;
// TODO: Implement relative start
// int relativeStart_;
};
Q_DECLARE_TYPEINFO(AbstractSeq, Q_MOVABLE_TYPE);
typedef boost::shared_ptr<AbstractSeq> AbstractSeqSPtr;
struct AbstractSeqPod : public AbstractBasicEntityPod
{
int start_;
int stop_;
QString source_;
AbstractSeqPod(int id = 0)
: AbstractBasicEntityPod(id), start_(0), stop_(-1)
{
}
};
Q_DECLARE_TYPEINFO(AbstractSeqPod, Q_MOVABLE_TYPE);
#endif // ABSTRACTSEQ_H
|
f6d5c4bf927169783f552deef35f7c23e96b59d9
|
fb5b25b4fbe66c532672c14dacc520b96ff90a04
|
/export/release/windows/obj/include/flixel/util/_FlxSignal/FlxSignal3.h
|
e71fa5b933c1682e6fd7a7cd8854780b338b293c
|
[
"Apache-2.0"
] |
permissive
|
Tyrcnex/tai-mod
|
c3849f817fe871004ed171245d63c5e447c4a9c3
|
b83152693bb3139ee2ae73002623934f07d35baf
|
refs/heads/main
| 2023-08-15T07:15:43.884068
| 2021-09-29T23:39:23
| 2021-09-29T23:39:23
| 383,313,424
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,899
|
h
|
FlxSignal3.h
|
#ifndef INCLUDED_flixel_util__FlxSignal_FlxSignal3
#define INCLUDED_flixel_util__FlxSignal_FlxSignal3
#ifndef HXCPP_H
#include <hxcpp.h>
#endif
#ifndef INCLUDED_flixel_util__FlxSignal_FlxBaseSignal
#include <flixel/util/_FlxSignal/FlxBaseSignal.h>
#endif
HX_DECLARE_CLASS2(flixel,util,IFlxDestroyable)
HX_DECLARE_CLASS2(flixel,util,IFlxSignal)
HX_DECLARE_CLASS3(flixel,util,_FlxSignal,FlxBaseSignal)
HX_DECLARE_CLASS3(flixel,util,_FlxSignal,FlxSignal3)
namespace flixel{
namespace util{
namespace _FlxSignal{
class HXCPP_CLASS_ATTRIBUTES FlxSignal3_obj : public ::flixel::util::_FlxSignal::FlxBaseSignal_obj
{
public:
typedef ::flixel::util::_FlxSignal::FlxBaseSignal_obj super;
typedef FlxSignal3_obj OBJ_;
FlxSignal3_obj();
public:
enum { _hx_ClassId = 0x6170b6f6 };
void __construct();
inline void *operator new(size_t inSize, bool inContainer=true,const char *inName="flixel.util._FlxSignal.FlxSignal3")
{ return ::hx::Object::operator new(inSize,inContainer,inName); }
inline void *operator new(size_t inSize, int extra)
{ return ::hx::Object::operator new(inSize+extra,true,"flixel.util._FlxSignal.FlxSignal3"); }
static ::hx::ObjectPtr< FlxSignal3_obj > __new();
static ::hx::ObjectPtr< FlxSignal3_obj > __alloc(::hx::Ctx *_hx_ctx);
static void * _hx_vtable;
static Dynamic __CreateEmpty();
static Dynamic __Create(::hx::DynamicArray inArgs);
//~FlxSignal3_obj();
HX_DO_RTTI_ALL;
::hx::Val __Field(const ::String &inString, ::hx::PropertyAccess inCallProp);
static void __register();
bool _hx_isInstanceOf(int inClassId);
::String __ToString() const { return HX_("FlxSignal3",99,26,0e,70); }
void dispatch3( ::Dynamic value1, ::Dynamic value2, ::Dynamic value3);
::Dynamic dispatch3_dyn();
};
} // end namespace flixel
} // end namespace util
} // end namespace _FlxSignal
#endif /* INCLUDED_flixel_util__FlxSignal_FlxSignal3 */
|
7ae55bf05e40505cdc8a15278616cf62822f66e9
|
7916ff49ef9e4233eb05094b79c839511044b0c0
|
/HAL.CanModules/src/Real/Camera.h
|
93cb7fac46fb8df9cce67b68cc904dc5dac781fe
|
[] |
no_license
|
hadzim/fit-mbot
|
aa971a8cbd7201d4a4a80316c1b5980e02a76fd5
|
05405de4d7b9af876cad237009014fe859e3e150
|
refs/heads/master
| 2021-01-16T17:48:49.325883
| 2015-02-05T14:00:15
| 2015-02-05T14:00:15
| 10,641,921
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,327
|
h
|
Camera.h
|
//------------------------------------------------------------------------------
//
// Project: VG20102014024
// Robot for search of human beings in crushes and avalanches
//
// Brno University of Technology
// Faculty of Information Technology
//
//------------------------------------------------------------------------------
//
// This project was financially supported by project
// VG20102014024 funds provided by MV CR.
//
//------------------------------------------------------------------------------
/*!
@file
@brief Header file
@details Details
@authors Jan Vana (<ivanajan@fit.vutbr.cz>)
@date 2010-2014
@note This project was supported by project funds of the MV CR grant VG20102014024.
*/
#ifndef Camera_H_
#define Camera_H_
#include "HAL/API/Camera.h"
#include <Poco/Types.h>
#include "TBS/Robo/RoboCan/Task/ModuleCommandTask.h"
#include "TBS/Robo/RoboCan/HW/CanNode.h"
#include "MBot/HW/CameraModules.h"
#include "TBS/Robo/RoboCan/Communicaton/IChannel.h"
#include "TBS/Robo/TaskExecutor.h"
namespace MBot {
class Camera: public HAL::API::Camera::ICamera, public Poco::Runnable {
public:
struct Status {
};
Camera(TBS::NotificationWorker::Ptr nw, TBS::Robo::RoboCan::IChannel::Ptr canChannel);
~Camera();
void Enable();
void Disable();
void GoMinEngine();
void GoMaxEngine();
void GoRelEngine(const double & speed);
void GoMinServo1();
void GoMaxServo1();
void GoRelServo1(const double & speed);
void GoMinServo2();
void GoMaxServo2();
void GoRelServo2(const double & speed);
void LightOn();
void LightOff();
private:
void run();
private:
TBS::Robo::RoboCan::CanNode node;
TBS::Task::OneActiveTaskExectution motorExecution;
TBS::Task::OneActiveTaskExectution servo1Execution;
TBS::Task::OneActiveTaskExectution servo2Execution;
TBS::Task::OneActiveTaskExectution lightExecution;
MBot::CameraMotorModule motorModule;
MBot::CameraMotorModule servo1Module;
MBot::CameraMotorModule servo2Module;
MBot::LightModule lightModule;
int speed;
int maxRelDurationTimeInMs;
Poco::Thread t;
bool finished;
bool enabled;
Poco::Mutex m;
Status currentStatus;
};
} /* namespace MBot */
#endif /* Camera_H_ */
|
9355cdd2fc1b69341172b7aac4914efd1b09ae9c
|
2fdcf56c5e791dd9a4605a41ef7bc601e2fc9135
|
/Info/Closing Ceremony at Lolympics/main.cpp
|
97f6229c2f36f259a99b44286e30dc01e834fe40
|
[] |
no_license
|
DinuCr/CS
|
42cc4a7920fb5a2ac5e1179930169e4d8d71592e
|
8d381a622e70dd234d7a978501dcb7cf67e83adc
|
refs/heads/master
| 2020-06-02T14:11:49.223214
| 2020-05-24T01:27:46
| 2020-05-24T01:27:46
| 191,174,654
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 508
|
cpp
|
main.cpp
|
#include <iostream>
using namespace std;
const int mod = 1e9+7;
int dp[100100];
int v[1100];
int n,i,j,k;
int main()
{
cin>>n>>k;
for(i=1; i<=n; ++i)
cin>>v[i];
dp[0]=1;
for(i=1; i<=n; ++i)
{
for(j=k-1; j>=0; --j)
if(dp[j] && j+v[i]<k)
dp[j+v[i]]=(dp[j]+dp[j+v[i]])%mod;
}
long long ans = 1;
for(i=1; i<=n; ++i)
ans = ans*2%mod;
for(i=0; i<k; ++i)
ans = (1LL*ans+1LL*2*mod-1LL*2*dp[i])%mod;
cout<<ans;
}
|
220bd0554735fbadcd7bd2fac402a9803db716e7
|
4b127c72de113ec8029652bb4fbf5b0956f19dcc
|
/TemplePlus/d20_levelup.cpp
|
943c9d5d12f80821ccb544b50dbfa5e19b09fb80
|
[
"MIT"
] |
permissive
|
ema29/TemplePlus
|
d72a0cfef549e6433c0b46d48777d528ced68813
|
670c33574f8dedbde8e8eaacbfbd87f59bce1bea
|
refs/heads/master
| 2021-01-16T19:42:04.116442
| 2016-02-04T17:57:48
| 2016-02-04T17:57:48
| 51,106,307
| 0
| 0
| null | 2016-02-04T21:19:53
| 2016-02-04T21:19:53
| null |
UTF-8
|
C++
| false
| false
| 576
|
cpp
|
d20_levelup.cpp
|
#include "stdafx.h"
#include "d20_levelup.h"
#include "common.h"
#include "obj.h"
struct D20LevelupSystemAddresses : temple::AddressTable
{
int(__cdecl* LevelupApply)(objHndl objHnd, LevelupPacket* lvlPkt);
void(__cdecl * LevelupStateInit)(LevelupState *lvlStat, objHndl objHnd); // uses critter_pad_i_4 and critter_pad_i_5
void(__cdecl* ApplyLevelFromLevelupTabEntry)(objHndl objHnd);
D20LevelupSystemAddresses()
{
rebase(LevelupApply, 0x100731E0);
rebase(LevelupStateInit, 0x100F37C0);
rebase(ApplyLevelFromLevelupTabEntry, 0x100F3870);
}
} addresses;
|
91c80a5e83bb5c1c4208688d082f3a3b4ec4a84e
|
1a50923ab3c5a4c453de4780cdae59d4fb75137d
|
/C++/AssetInterfaces/resourceholder.hpp
|
810069f2747793fa8f8a2a5f7fbabbb8b686c7dc
|
[] |
no_license
|
hyptos/snz-server
|
0c6b4a1b558512f8955a82597a49b9ff146fba29
|
ca3eb16f02add590fcd0ac90dc4551e189efa140
|
refs/heads/master
| 2020-05-09T20:01:59.145831
| 2015-06-21T17:51:58
| 2015-06-21T17:51:58
| 34,102,520
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,949
|
hpp
|
resourceholder.hpp
|
#ifndef RESOURCEHOLDER_H
#define RESOURCEHOLDER_H
#include "AssetInterfaces/internals.hpp"
#include "AssetInterfaces/isharedresource.hpp"
#include "AssetInterfaces/isharedresourceloader.hpp"
#include "AssetInterfaces/isharedresourcemanager.hpp"
class BaseResourceDescriptor
{
public:
virtual ~BaseResourceDescriptor () {}
QString mResourceClassName;
QUuid mResourceTypeID;
SharedResourceManagerPtr mManager;
virtual SharedResourcePtr Create () = 0;
virtual SharedResourcePtr Create (QString name) = 0;
protected:
BaseResourceDescriptor () {}
};
template < class ResourceType >
class ResourceDescriptor :
virtual public BaseResourceDescriptor
{
public:
virtual ~ResourceDescriptor () {}
QUuid mInterfaceID;
static char* mImplementationName;
virtual SharedResourcePtr Create () {
SharedResourcePtr ptr ( new ResourceType );
return ptr;
}
virtual SharedResourcePtr Create (QString name) {
uint index=0;
QString tmp = "Resource[" + mResourceClassName + ":" + name + "]";
if ( mNameCount.find ( tmp ) != mNameCount.end () ) {
index = mNameCount[tmp] + 1;
}
mNameCount[tmp] = index;
QString sindex = QString::number(index);
QString reference = "Resource[" + mResourceClassName + ":" + name + ":" + sindex + "]";
QUuid uuid = UUIDManager::createUUID(reference);
SharedResourcePtr ptr ( new ResourceType (reference) );
ptr->setUUID ( uuid );
return ptr;
}
protected:
ResourceDescriptor () {}
QMap < QString, uint > mNameCount;
friend class ResourceHolder;
};
template < class ResourceType > char* ResourceDescriptor<ResourceType>::mImplementationName;
template < class ResourceType >
class ResourceInterfaceDescriptor :
virtual public BaseResourceDescriptor
{
public:
virtual ~ResourceInterfaceDescriptor () {}
static char* mInterfaceName;
virtual SharedResourcePtr Create () {
SharedResourcePtr ptr;
return ptr;
}
virtual SharedResourcePtr Create (QString name) {
SharedResourcePtr ptr;
return ptr;
}
protected:
ResourceInterfaceDescriptor () {}
friend class ResourceHolder;
};
template < class ResourceType > char* ResourceInterfaceDescriptor<ResourceType>::mInterfaceName;
class ResourceHolder
{
public:
template < class ResourceType, class ManagerType > static void RegisterInterface ( QString name ) {
SharedResourceManagerPtr mgr = ManagerType::Instance ();
ResourceInterfaceDescriptor < ResourceType >* tmp = new ResourceInterfaceDescriptor < ResourceType >;
tmp->mResourceClassName = name;
tmp->mResourceTypeID = UUIDManager::createUUID( "AssetInterface::" + name );
tmp->mManager = mgr;
mResourceDescriptors [ tmp->mResourceTypeID ] = tmp;
ResourceInterfaceDescriptor < ResourceType >::mInterfaceName = strdup ( name.toStdString().c_str() );
}
template < class ResourceType, class InterfaceType > static void RegisterImplementation ( QString name ) {
QString interfaceName = ResourceInterfaceDescriptor < InterfaceType >::mInterfaceName;
QUuid type = UUIDManager::createUUID( "AssetInterface::" + interfaceName );
BaseResourceDescriptor* desc = mResourceDescriptors [ type ];
ResourceDescriptor < ResourceType >* tmp = new ResourceDescriptor < ResourceType >;
tmp->mInterfaceID = desc->mResourceTypeID;
tmp->mResourceClassName = name;
tmp->mResourceTypeID = UUIDManager::createUUID( "AssetImplementation::" + name );
tmp->mManager = desc->mManager;
mResourceDescriptors [ tmp->mResourceTypeID ] = tmp;
ResourceDescriptor < ResourceType >::mImplementationName = strdup ( name.toStdString().c_str() );
}
template < class ResourceType, class LoaderType > static void RegisterLoader ( QMimeType fileType ) {
SharedResourceLoaderPtr ldr = LoaderType::Instance ();
mResourceLoaders [ fileType.name () ] = ldr;
}
///
/// \brief CreateByUUID
/// \param type, UUID of resource type
/// \return shared pointer on the resource
///
static SharedResourcePtr CreateByUUID ( QUuid type ) {
BaseResourceDescriptor* desc = mResourceDescriptors [ type ];
SharedResourcePtr result = desc->Create();
result->mTypeID = desc->mResourceTypeID;
return result;
}
///
/// \brief CreateByName
/// \param name, name of resource type
/// \return shared pointer on the resource
///
static SharedResourcePtr CreateByName ( QString name ) {
QUuid type = UUIDManager::createUUID( "AssetImplementation::" + name );
BaseResourceDescriptor* desc = mResourceDescriptors [ type ];
SharedResourcePtr result = desc->Create();
result->mTypeID = desc->mResourceTypeID;
return result;
}
///
/// \brief CreateByName
/// \param name, name of resource type
/// \param resname, name of resource
/// \return shared pointer on the resource
///
static SharedResourcePtr CreateByName ( QString name, QString resname ) {
QUuid type = UUIDManager::createUUID( "AssetImplementation::" + name );
BaseResourceDescriptor* desc = mResourceDescriptors [ type ];
SharedResourcePtr result = desc->Create(resname);
result->mTypeID = desc->mResourceTypeID;
return result;
}
///
/// \brief GetByUUID
/// \param uuid, UUID of the requested resource
/// \return shared pointer on the resource
///
static SharedResourcePtr GetByUUID ( QUuid uuid ) {
return mResources [ uuid ];
}
///
/// \brief AllKeys
/// \return
///
static QList < QUuid > AllKeys () { return mResources.keys(); }
///
/// \brief Load
/// \param filename
/// \return
///
static SharedResourceList Load ( FileDescriptor filename ) {
QMimeDatabase db;
QUuid uuidFile = UUIDManager::createUUID( filename.fullFilename );
if ( mLibraries.find ( uuidFile ) != mLibraries.end () )
return mLibraries [ uuidFile ];
SharedResourceList lib;
SharedResourceLoaderPtr loader;
QMimeType mimeType = db.mimeTypeForFile(filename.fullFilename);
if ( mResourceLoaders.find ( mimeType.name () ) != mResourceLoaders.end () )
loader = mResourceLoaders [ mimeType.name () ];
if ( ! loader.isNull() )
lib = loader->load(filename);
mLibraries[uuidFile] = lib;
foreach ( SharedResourcePtr res, lib ) {
res->InitializeUUID("Assets:"+filename.fullFilename+":"+res->getName());
mResources [ res->getUUID () ] = res;
mResourceDescriptors [ res->mTypeID ]->mManager->mLoadedResources [ res->getUUID() ] = res;
}
return lib;
}
static SharedResourcePtr FromBuffer ( const ByteBuffer& buffer, unsigned long long& index ) {
QUuid resTypeUUID;
QString resTypeName;
unsigned int dataSize;
unsigned long long lindex = index;
lindex = ::fromBuffer ( buffer, lindex, resTypeUUID );
lindex = ::fromBuffer ( buffer, lindex, resTypeName );
lindex = ::fromBuffer ( buffer, lindex, dataSize );
BaseResourceDescriptor* desc = mResourceDescriptors [ resTypeUUID ];
SharedResourcePtr result ( desc->Create() );
lindex = result->convertFromBuffer ( buffer, lindex );
index = lindex;
return result;
}
static ByteBuffer ToBuffer ( const SharedResourcePtr& res ) {
BaseResourceDescriptor* desc = mResourceDescriptors [ res->mTypeID ];
ByteBuffer uuid = toBuffer ( desc->mResourceTypeID );
ByteBuffer name = toBuffer ( desc->mResourceClassName );
ByteBuffer data = res->convertToBuffer();
unsigned int dataSize = data.getLength();
unsigned long long index = 0;
ByteBuffer buffer ( uuid.getLength() + name.getLength() + sizeof ( unsigned int ) + dataSize );
index = ::toBuffer ( buffer, index, uuid.getData(), uuid.getLength() );
index = ::toBuffer ( buffer, index, name.getData(), name.getLength() );
index = ::toBuffer ( buffer, index, dataSize );
index = ::toBuffer ( buffer, index, data.getData(), data.getLength() );
return buffer;
}
///
/// \brief Usage
///
static void Usage () {
std::cout << mResourceLoaders.size() << std::endl;
std::cout << mResourceDescriptors.size() << std::endl;
std::cout << mResources.size() << std::endl;
}
protected:
static QMap < QString, SharedResourceLoaderPtr > mResourceLoaders;
static QMap < QUuid, BaseResourceDescriptor* > mResourceDescriptors;
//
static QMap < QUuid, SharedResourceList > mLibraries;
static QMap < QUuid, SharedResourcePtr > mResources;
};
#endif // RESOURCEHOLDER_H
|
6ae81f3a8f5ab529212b64a071dd94ce93fea18e
|
9db1720ff68ba7a5a3a042c4a79964c3cb77ef0e
|
/code/graphic/ctexture.cpp
|
a1d9cc858912e11f9b9b8dcd217eaea1f8f89730
|
[] |
no_license
|
mowenli/onyx2d
|
5a09198dc0775556bcd4097ccfa7a79e21d7d4c9
|
d993ff7281e5ba9049890cc4e4c361f795fa1df6
|
refs/heads/master
| 2021-06-08T14:26:42.822247
| 2016-10-28T16:11:03
| 2016-10-28T16:11:03
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,545
|
cpp
|
ctexture.cpp
|
/*
cTexture - Class that loads and contain texture data
Copyright (C) 2010-2011 Josue Candela Perdomo (josuecp.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**/
#include "ctexture.h"
#include "..\core\cconsole.h"
namespace onyx2d
{
cTexture::cTexture(cTexture* tex)
{
m_sPath = tex->m_sPath;
m_vSize = tex->m_vSize;
m_uTextureID = tex->m_uTextureID;
m_uTextureList = tex->m_uTextureList;
m_cTexture = tex->m_cTexture;
}
cTexture::cTexture(string path)
{
Load(path);
}
bool cTexture::Load(string path)
{
m_sPath = path;
//Check if the file exist
fstream fp(path.c_str());
if (!fp)
{
string log_str = "cTexture : File not found : " + path;
Console()->AddRecord(log_str, RecordType::Error);
return false;
}else{
fp.close();
}
FREE_IMAGE_FORMAT format = FreeImage_GetFileType(path.c_str(),0);//Automatocally detects the format(from over 20 formats!)
FIBITMAP* image = FreeImage_Load(format, path.c_str());
FIBITMAP* temp = image;
image = FreeImage_ConvertTo32Bits(image);
if (!image)
{
string log_str = "cTexture : Error loading texture : " + path;
Console()->AddRecord(log_str, RecordType::Error);
return false;
}
FreeImage_SetTransparent(image, true);
FreeImage_Unload(temp);
m_vSize.x = FreeImage_GetWidth(image);
m_vSize.y = FreeImage_GetHeight(image);
//FreeImage loads in BGR format, so you need to swap some bytes(Or use GL_BGR).
m_cTexture = new GLubyte[4* m_vSize.x* m_vSize.y];
char* pixels = (char*)FreeImage_GetBits(image);
for(int j= 0; j< m_vSize.x* m_vSize.y; j++){
m_cTexture[j*4+0]= pixels[j*4+2];
m_cTexture[j*4+1]= pixels[j*4+1];
m_cTexture[j*4+2]= pixels[j*4+0];
m_cTexture[j*4+3]= pixels[j*4+3];
}
//Now generate the OpenGL texture object
glGenTextures(1, &m_uTextureID);
glBindTexture(GL_TEXTURE_2D, m_uTextureID);
glNewList(m_uTextureList = glGenLists(1), GL_COMPILE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
//glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);
glTexEnvi( GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_MODULATE );
// Define the 2D texture image.
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,
m_vSize.x,
m_vSize.y,
0, GL_RGBA,GL_UNSIGNED_BYTE,
(GLvoid*)m_cTexture );
glEndList();
GLenum wasError = glGetError();
if(wasError){
string log_str = "cTexture : Error generating texture : " + path;
Console()->AddRecord(log_str, RecordType::Error);
return false;
}
}
cTexture::~cTexture()
{
//dtor
}
}
|
853ccb2b8b7ab6e2e2a07ffd40838d6b4809c73d
|
c538893c989213f57b0233f760a3fff0e336b528
|
/region_detection/gdg/main.cpp
|
45cad493821b0105d0048400a10694dc49d9c609
|
[] |
no_license
|
tuanfeng/texture_transfer
|
bb2a82468059a9ec3445c1197e683281460fa77c
|
1646e714c171a13d2dffee631e4f94120068eb0b
|
refs/heads/master
| 2021-01-10T02:24:11.755949
| 2015-11-06T21:36:35
| 2015-11-06T21:36:35
| 42,999,420
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,570
|
cpp
|
main.cpp
|
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <random>
#include <ctime>
#include <opencv2/core/core.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main( int argc, char** argv )
{
std::clock_t time_start;
time_start = std::clock();
Mat src, src_gray;
Mat dst, detected_edges;
// int edgeThresh = 1;
int lowThreshold;
int ratio = 3;
int kernel_size = 3;
/// Load an image
src = imread( argv[1] );
std::string file_string = argv[1];
Size tmp_size(400,400);
resize(src,src,tmp_size);//resize image
if( !src.data )
{ return -1; }
/// Create a matrix of the same type and size as src (for dst)
//dst.create( src.size(), src.type() );
/// Convert the image to grayscale
cvtColor( src, src_gray, CV_BGR2GRAY );
blur( src_gray, detected_edges, Size(3,3) );
lowThreshold = 30;
/// Canny detector
Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size );
/// Using Canny's output as a mask, we display our result
imwrite(file_string.substr(0,file_string.length()-4)+"_output_1.png",detected_edges);
Mat out2;
out2.create( src.size(), detected_edges.type());
detected_edges.copyTo(out2);
int radius = 2;
for (int i=0; i<detected_edges.size().height; i++){
for (int j=0; j<detected_edges.size().width; j++){
if (detected_edges.at<uchar>(i,j) == 255) {
for (int pi=-radius; pi<=radius; pi++){
for (int pj=-radius; pj<=radius; pj++){
float dis = sqrt(pi*pi+pj*pj);
if ((dis<=radius) && (i+pi>=0) && (i+pi<detected_edges.size().height) && (j+pj>=0) && (j+pj<detected_edges.size().width)) {
uchar pv=(uchar)(255-dis/(float)(radius+1)*255);
if (pv>out2.at<uchar>(i+pi,j+pj)) {
out2.at<uchar>(i+pi,j+pj) = pv;
}
}
}
}
}
}
}
imwrite(file_string.substr(0,file_string.length()-4)+"_output_2.png",out2);
Mat out3(out2.size(), CV_32S, Scalar::all(0));
int patch_dx = 80;
int patch_dy = 80;
int patch_locx,patch_locy;
//check
if (1>0) {
Mat out_tmp(src.size(),src.type());
Mat out_t2(src.size(),CV_32S, Scalar::all(10000));
int patch_locx = 200;
int patch_locy = 200;
double minerr = 100000000;
Mat target_patch = out2.colRange(patch_locx,patch_locx+patch_dx).rowRange(patch_locy,patch_locy+patch_dy);
for (int i=0; i<out2.size().width-patch_dx; i+=1){
for (int j=0; j<out2.size().height-patch_dy; j+=1){
if ((i-patch_locx)*(i-patch_locx)+(j-patch_locy)*(j-patch_locy)>=50) {
Mat current_patch = out2.colRange(i,i+patch_dx).rowRange(j,j+patch_dy);
Mat diff = target_patch-current_patch;
double diff_norm = norm(diff);
//if (diff_norm<1500) {
// std::cout<<'*';
// out_tmp.at<Vec3b>(j,i)[0] = 0;
// out_tmp.at<Vec3b>(j,i)[1] = 0;
// out_tmp.at<Vec3b>(j,i)[2] = 255;
//}
if (diff_norm < minerr) {
minerr = diff_norm;
}
out_t2.at<int>(j,i) = diff_norm;
if (out_t2.at<int>(j,i) > 10000) {
out_t2.at<int>(j,i) = 10000;
}
}
}
}
normalize(out_t2,out_t2,0,255,NORM_MINMAX);
for (int i=0; i<out2.size().width; i+=1){
for (int j=0; j<out2.size().height; j+=1){
out_tmp.at<Vec3b>(i,j)[0] = 0;
out_tmp.at<Vec3b>(i,j)[1] = 0;
out_tmp.at<Vec3b>(i,j)[2] = 255-out_t2.at<int>(i,j);
}
}
for (int i=-2; i<3; i++){
for (int j=-2; j<3; j++){
out_tmp.at<Vec3b>(patch_locx+i,patch_locy+j)[0]=0;
out_tmp.at<Vec3b>(patch_locx+i,patch_locy+j)[1]=255;
out_tmp.at<Vec3b>(patch_locx+i,patch_locy+j)[2]=0;
}
}
std::cout<<minerr<<" check done\n";
imwrite(file_string.substr(0,file_string.length()-4)+"_output_check.png",out_tmp);
}
//checkend///////////
Mat mark_patch (patch_dx,patch_dy,CV_32S,Scalar::all(1));
//Mat gre_patch (5,5,src.type(),Scalar(0, 255, 0));
//Mat red_patch (5,5,src.type(),Scalar(0, 0, 255));
std::vector<Point2i> patch_candi;
patch_candi.clear();
//std::cout<<'*'<<int(src.at<Vec3b>(0,0)[0])<<' '<<int(src.at<Vec3b>(0,0)[1])<<' '<<int(src.at<Vec3b>(0,0)[2])<<'\n';
for (int i=0; i<out2.size().width-patch_dx; i+=1){
for (int j=0; j<out2.size().height-patch_dy; j+=1){
Point2i tmp_loc;
tmp_loc.y=i;
tmp_loc.x=j;
bool flag = true;
for (int pi=0; pi<patch_dx; pi+=20){
for (int pj=0; pj<patch_dy; pj+=20){
if (((src.at<Vec3b>(i+pi,j+pj)[1] == 255) && (src.at<Vec3b>(i+pi,j+pj)[2] == 0) && (src.at<Vec3b>(i+pi,j+pj)[0] == 0))
|| ((src.at<Vec3b>(i+pi,j+pj)[1] == 0) && (src.at<Vec3b>(i+pi,j+pj)[2] == 255) && (src.at<Vec3b>(i+pi,j+pj)[0] == 0))){
flag = false;
break;
}
}
if (!flag) {
break;
}
}
if (flag) {
patch_candi.push_back(tmp_loc);
//src.at<Vec3b>(i,j)[0]=255;
//src.at<Vec3b>(i,j)[1]=255;
//src.at<Vec3b>(i,j)[2]=255;
}
}
}
//imwrite(file_string.substr(0,file_string.length()-4)+"_output_tmp.png",src);
std::vector<Point2i> patch_list;
patch_list.clear();
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine generator(seed);
std::uniform_real_distribution<double> distribution(0.0,1.0);
double ratio_select = double(5000)/double(patch_candi.size());
std::cout<<"patch candidates size: "<<patch_candi.size()<<'\n';
for (int i=0; i<patch_candi.size(); i+=1){
double number = distribution(generator);
if (number<=ratio_select){
patch_list.push_back(patch_candi[i]);
Point2i tmp;
tmp = patch_list.back();
src.at<Vec3b>(tmp.y+patch_dy/2,tmp.x+patch_dx/2)[0]=255;
src.at<Vec3b>(tmp.y+patch_dy/2,tmp.x+patch_dx/2)[1]=255;
src.at<Vec3b>(tmp.y+patch_dy/2,tmp.x+patch_dx/2)[2]=255;
}
}
imwrite(file_string.substr(0,file_string.length()-4)+"_output_tmp.png",src);
//std::cout<<patch_list[0].x<<' '<<patch_list[0].y<<'\n';
std::cout<<"patch list size: "<<patch_list.size()<<'\n';
int count = 0;
for (int idx1=0;idx1<patch_list.size()-1; idx1++){
patch_locx = patch_list[idx1].x;
patch_locy = patch_list[idx1].y;
Mat target_patch = out2.colRange(patch_locx,patch_locx+patch_dx).rowRange(patch_locy,patch_locy+patch_dy);
Mat target_patch_3 = out3.colRange(patch_locx,patch_locx+patch_dx).rowRange(patch_locy,patch_locy+patch_dy);
for (int idx2=idx1+1; idx2<patch_list.size(); idx2++){
int i = patch_list[idx2].x;
int j = patch_list[idx2].y;
Mat current_patch = out2.colRange(i,i+patch_dx).rowRange(j,j+patch_dy);
Mat diff = target_patch-current_patch;
double diff_norm = norm(diff);
if ((diff_norm<2000) && ((i-patch_locx)*(i-patch_locx)+(j-patch_locy)*(j-patch_locy)>50)) {
count++;
//std::cout<<idx1<<' '<<idx2<<' '<<i<<' '<<j<<' '<<patch_locx<<' '<<patch_locy<<'\n';
Mat current_patch_3 = out3.colRange(i,i+patch_dx).rowRange(j,j+patch_dy);
Mat new_current_patch_3 = current_patch_3 + mark_patch;
new_current_patch_3.copyTo(current_patch_3);
Mat new_target_patch_3 = target_patch_3 + mark_patch;
new_target_patch_3.copyTo(target_patch_3);
//Mat out_tmp;
//out3.convertTo(out_tmp, CV_8U);
//imwrite(file_string.substr(0,file_string.length()-4)+"_output_3.png",out_tmp);
//if (count%100 == 0) {std::cin.ignore();}
}
}
}
std::cout<<count<<'\n';
double minval,maxval;
Point2i minLoc,maxLoc;
cv::minMaxLoc(out3,&minval,&maxval, &minLoc, &maxLoc );
std::cout<<minval<<' '<<maxval<<'\n';
normalize(out3,out3,0,255,NORM_MINMAX);
out3.convertTo(out3, CV_8U);
imwrite(file_string.substr(0,file_string.length()-4)+"_output_3.png",out3);
for (int i=0; i<out3.size().height; i+=1){
for (int j=0; j<out3.size().width; j+=1){
if (out3.at<uchar>(i,j)<100) {
out3.at<uchar>(i,j) = 0;
} else {
out3.at<uchar>(i,j) = 255;
}
}
}
imwrite(file_string.substr(0,file_string.length()-4)+"_output_4.png",out3);
std::cout << "Time: " << (std::clock() - time_start) / (double)(CLOCKS_PER_SEC) << " s" << std::endl;
return 0;
}
|
809bc49b4c932fa836a9bd31a3a4266d23bc9af9
|
26ad30a699b4a7c06c263ba417ed3c66069f6533
|
/person/client/client.h
|
6dd41b693d8de87f4c55e1ca39e040a8867098dc
|
[] |
no_license
|
Poodlers/aeda_hotel_projeto
|
9e6f304bc693d635c7028137885d5b0b7225d430
|
6180832b214966a4dca645b97717c18cba6e99d7
|
refs/heads/main
| 2023-02-13T17:23:37.972062
| 2021-01-01T15:00:36
| 2021-01-01T15:00:36
| 306,400,321
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,331
|
h
|
client.h
|
#ifndef CLIENT_H
#define CLIENT_H
#include <string>
#include <vector>
#include "../../hotel/reservation.h"
#include "../person.h"
#include "../../exceptions/exceptions.h"
#include "unordered_set"
/// \class Client
/// Class which represents a Client.
///
/// Is defined by a NIF and a name (inherited from class person), a vector with the history of the client's reservations, a vector with the client's future reservations and a vector
/// for current reservations i.e. the client is at the hotel at the moment.
class Client: public Person{
public:
/// Client constructor.
///
/// \param name client's name.
/// \param NIF client's NIF.
Client(const std::string &name, const unsigned int &NIF);
/// Return history vector.
///
/// \return history.
std::vector<Reservation*>& getHistory();
/// Return future reservations' vector.
///
/// \return futureReservations.
std::vector<Reservation*> getFutureReservations() const;
/// Return the current reservations' vector.
///
/// \return currentReservations.
std::vector<Reservation*> getCurrentReservations() const;
/// Adds reservation to history vector.
///
/// \param reservation reservation to add.
void addToHistory(Reservation *reservation);
/// Adds reservation to new reservations.
///
/// \param reservation reservation to add.
void addNewReservation(Reservation *reservation);
/// Adds reservation to current reservations.
///
/// \param reservation reservation to add.
void addCurrentReservation(Reservation *reservation);
/// deletes reservation.
///
/// \param reservation reservation to delete.
void deleteReservation(Reservation* reservation);
/// Check Out.
///
/// Goes through the vector 'currentReservations' and if the date is bigger or equal to the check out date for a specific reservation, proceeds
/// to remove it from the vector 'currentReservations' and put it in the client's history.
/// \param date current date.
/// \return positions of the reservations that were checked out.
/// \exception throws NoReservationsToCheckOut if there are no reservations from the client to check out currently.
std::vector<int> checkOut (Date* date);
/// Check In.
///
/// Goes through the vector 'futureReservations' and if the date is bigger or equal to the check in date for a specific reservation, proceeds
/// to remove it from the vector 'futureReservations' vector and put it in the vector 'currentReservations'.
/// \param date current date.
/// \return reservation IDs of the reservations that were checked in.
/// \exception throws NoReservationsToCheckIn if there are no reservations from client to check in.
std::vector<int> checkIn (Date* date);
/// Archives expired reservations.
///
/// If a reservation in 'futureReservations' expires on date (i.e. check out date <= current date) it is removed from
/// the 'futureReservations' and appended to the client's history.
/// \param date current sate.
void archiveExpiredReservations(Date* date);
/// Prints clients in the format:
///
///NIF: nif Name: name
///Client History: (if empty does not print)
///...
///Current Reservations: (if empty does not print)
///...
///Future Reservations: (if empty does not print)
///...
void printConsole();
/// Overload for ==.
///
/// \param client
/// \return this-> == client.
bool operator==(Client* client);
/// Return all reservation.
///
/// \return all reservations.
std::vector<Reservation*>& getAllReservations();
/// Changes history
///
/// \param history new history
void setHistory(const std::vector<Reservation*> &history);
/// Changes future reservations
///
/// \param futureReservations new future reservations
void setFutureReservations(const std::vector<Reservation*> &futureReservations);
/// Changes current reservations
///
/// \param currentReservations new current reservations
void setCurrentReservations(const std::vector<Reservation*> ¤tReservations);
/// Changes all reservations
///
/// \param allReservations all new reservations
void setAllReservations(const std::vector<Reservation*> &allReservations);
private:
/// Vector with past reservations
std::vector<Reservation*> history;
/// Vector with future reservations
std::vector<Reservation*> futureReservations;
/// Vector with current reservation i.e. the person is currently staying at the hotel
std::vector<Reservation*> currentReservations;
/// Vector with all reservations
std::vector<Reservation*> allReservations;
};
/// Hash function fot hash table.
struct clientHash
{
///
/// \param c Client.
/// \return First letter of the client's name.
int operator() (const Client& c) const
{
return c.getName()[0];
}
///
/// \param c1 Client 1.
/// \param c2 Client 2.
/// \return c1.getNIF() == c2.getNIF().
bool operator() (const Client& c1, const Client& c2) const
{
return c1.getNIF() == c2.getNIF();
}
};
typedef std::unordered_set<Client, clientHash, clientHash> ClientTable;
#endif
|
a15314c4726557b7544eeec5df76bd84cca35935
|
bbac388eb6b53daec63190e2f271a18fe9bfb163
|
/abc197/FConstructAPalindrome.cpp
|
004d81a3bd977433ee54fa68250180b974bc9117
|
[] |
no_license
|
tatsumack/atcoder
|
8d94cf29160b6553b0c089cb795c54efd3fb0f7b
|
fbe1e1eab80c4c0680ec046acdc6214426b19650
|
refs/heads/master
| 2023-06-17T23:09:54.056132
| 2021-07-04T13:03:59
| 2021-07-04T13:03:59
| 124,963,709
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,914
|
cpp
|
FConstructAPalindrome.cpp
|
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define fcout cout << fixed << setprecision(12)
using namespace std;
typedef pair<int, int> PP;
int dist[1003][1003];
class FConstructAPalindrome {
public:
void solve(std::istream& cin, std::ostream& cout) {
int N, M;
cin >> N >> M;
vector<vector<vector<int>>> G(N, vector<vector<int>>(26));
REP(i, M) {
int a, b;
char c;
cin >> a >> b >> c;
a--, b--;
G[a][c - 'a'].push_back(b);
G[b][c - 'a'].push_back(a);
}
int INF = (1 << 30) - 1;
queue<pair<int, int>> que;
REP(i, N) REP(j, N) dist[i][j] = INF;
dist[0][N - 1] = 0;
que.push({0, N - 1});
while (!que.empty()) {
PP p = que.front();
que.pop();
REP(c, 26) {
for (auto u : G[p.first][c]) {
for (auto v : G[p.second][c]) {
if (dist[u][v] > dist[p.first][p.second] + 2) {
dist[u][v] = dist[p.first][p.second] + 2;
que.push({u, v});
}
}
}
}
}
int res = INF;
REP(i, N) {
res = min(res, dist[i][i]);
}
REP(i, N) {
REP(c, 26) {
for (auto to : G[i][c]) {
res = min(res, dist[i][to] + 1);
res = min(res, dist[to][i] + 1);
}
}
}
if (res == INF) res = -1;
cout << res << endl;
}
};
|
f9bb28e73edb4be3697b32d475d531ad36d226f8
|
e85338f6d8666eb476698de5025c742b9b838a50
|
/ojs/cf/909C.cpp
|
29e2e23e45fea0db7edb1d442911065df4119efe
|
[] |
no_license
|
yancouto/competitive-programming
|
8104bb3c45e0b385c2abb4cfcac14c35cce0619e
|
ac849e3aa858eea56b0aa6b7eb93e9a9e70f9475
|
refs/heads/master
| 2022-10-19T11:29:46.932829
| 2022-10-07T00:16:43
| 2022-10-07T00:16:43
| 66,641,933
| 7
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 824
|
cpp
|
909C.cpp
|
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#ifdef ONLINE_JUDGE
# define debug(args...) ((void) 0)
#else
# define debug(args...) fprintf(stderr, args)
#endif
int n;
char s[5009];
int memo[5009][5009][2];
ll solve(int i, int id, bool can) {
if(i == n) return 1;
int &r = memo[i][id][can];
if(r != -1) return r;
r = 0;
if(id > 0 && can) r = solve(i, id - 1, true);
if(s[i] == 's') r = mod(r + solve(i + 1, id, true));
else r = mod(r + solve(i + 1, id + 1, false));
return r;
}
int main() {
memset(memo, -1, sizeof memo);
int i, j;
scanf("%d", &n);
for(i = 0; i < n; i++) scanf(" %c", &s[i]);
printf("%lld\n", solve(0, 0, true));
}
|
a2e43d23356798506d0845f90efc6669ce283381
|
1b93a9b3c023f8c82e92e36206a916302597e3d3
|
/gl_05/include/objects/sceneObject.h
|
6be4af4d08311e08dd17d1bbaa420fde8a3d2856
|
[] |
no_license
|
Demongo2009/GKOM_Crane
|
a7f66d3e251b324c269f745b27e9d2e94bc6a4f6
|
522b586ebfc4d6208b28512cbb0089e8d92e4dd6
|
refs/heads/main
| 2023-05-01T04:30:06.409509
| 2021-05-14T14:01:40
| 2021-05-14T14:01:40
| 367,379,931
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,543
|
h
|
sceneObject.h
|
#pragma once
#include <memory>
#include <glm/gtc/matrix_transform.hpp>
#include "../meshes/mesh.h"
#include "../shader.h"
#include "../material.h"
#include "../transform.h"
#include "../meshes/cube.h"
class SceneObject
{
public:
SceneObject(SceneObject* parent = nullptr)
:parent(parent)
{
transform = std::make_shared<Transform>();
}
SceneObject(std::shared_ptr<Material> material, SceneObject* parent = nullptr)
: material(material), parent(parent)
{
transform = std::make_shared<Transform>();
}
void addMesh(std::shared_ptr<Mesh> mesh);
void setMaterial(std::shared_ptr<Material> material);
void setParent(SceneObject* parent);
virtual void init()
{
meshes.at(0)->start();
}
virtual void render(Shader& shader);
virtual void rotate(const glm::vec3& rotation) { transform->rotate(rotation); }
virtual void move(const glm::vec3& displacement) { transform->move(displacement); }
virtual void setRotation(const glm::vec3& rotation) { transform->setRotation(rotation); }
virtual void setPosition(const glm::vec3& position) { transform->setPosition(position); }
void setScale(const glm::vec3& scale) { transform->setScale(scale); }
glm::vec3 getPosition() { return transform->getPosition(); }
glm::vec3 getRotation() { return transform->getRotation(); }
glm::vec3 getScale() { return transform->getScale(); }
glm::mat4 makeLocalToWorld();
protected:
std::shared_ptr<Transform> transform;
std::vector<std::shared_ptr<Mesh> > meshes;
std::shared_ptr<Material> material;
SceneObject* parent;
};
|
05893191cbd6ddc9c0ac2d986158e93298c1cd83
|
ef6540bded332b928e87e9622548796d8307a1bb
|
/Lab01 - BinaryAlpha/Squidley/VertexShaderInfo.cpp
|
16decb2a5d8b9073a7150363f153a76235ef6d53
|
[] |
no_license
|
JoshuaKauer/OldRenderEngine
|
0f78593f38d717818aff34493277093c5f688b69
|
ba44975cdb42cff29ad4007bb0709e177d4b5622
|
refs/heads/master
| 2020-05-03T19:08:28.124510
| 2019-04-01T07:27:42
| 2019-04-01T07:27:42
| 178,778,958
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 87
|
cpp
|
VertexShaderInfo.cpp
|
#include "VertexShaderInfo.h"
VertexShaderInfo::VertexShaderInfo()
{
callback = 0;
}
|
b1bba7d3f8b8bf6a9380ca34ded9e7fde75e7de7
|
a1248a74d6fb2a20a65567baeaae25af97e950e6
|
/ProgrammingBeauty/Q1/main.cpp
|
e974ec783327a1d8112750c13d027b921422f814
|
[] |
no_license
|
mihawk2010/MyHihocoder
|
289f74329b10c9d438cab63c8e799bf15e6cd6c0
|
9ea2e9dfcb910f9afeea12b309f370e234280952
|
refs/heads/master
| 2016-09-11T03:29:35.011709
| 2015-09-03T00:20:50
| 2015-09-03T00:20:50
| 41,847,528
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,253
|
cpp
|
main.cpp
|
#include <queue>
#include <stdio.h>
#include <string.h>
using namespace std;
const int MAXN=1100;
const int INF=1<<28;
int g[MAXN][MAXN],Mx[MAXN],My[MAXN],Nx,Ny;
int dx[MAXN],dy[MAXN],dis;
int num[MAXN];
bool vst[MAXN];
bool searchP()
{
queue<int>Q;
dis=INF;
memset(dx,-1,sizeof(dx));
memset(dy,-1,sizeof(dy));
for(int i=0;i<Nx;i++)
if(Mx[i]==-1)
{
Q.push(i);
dx[i]=0;
}
while(!Q.empty())
{
int u=Q.front();
Q.pop();
if(dx[u]>dis) break;
for(int v=0;v<Ny;v++)
if(g[u][v]&&dy[v]==-1)
{
dy[v]=dx[u]+1;
if(My[v]==-1) dis=dy[v];
else
{
dx[My[v]]=dy[v]+1;
Q.push(My[v]);
}
}
}
return dis!=INF;
}
bool DFS(int u)
{
for(int v=0;v<Ny;v++)
if(!vst[v]&&g[u][v]&&dy[v]==dx[u]+1)
{
vst[v]=1;
if(My[v]!=-1&&dy[v]==dis) continue;
if(My[v]==-1||DFS(My[v]))
{
My[v]=u;
Mx[u]=v;
return 1;
}
}
return 0;
}
int MaxMatch()
{
int res=0;
memset(Mx,-1,sizeof(Mx));
memset(My,-1,sizeof(My));
while(searchP())
{
memset(vst,0,sizeof(vst));
for(int i=0;i<Nx;i++)
if(Mx[i]==-1&&DFS(i)) res++;
}
return res;
}
bool isprime(int n)
{
if(n<2)
return false;
for (int i=2;i*i<=n;i++)
{
if(n % i == 0)
return false;
}
return true;
}
bool prime_related(int i, int j){
int a, b;
a = max(i, j);
b = min(i, j);
if (isprime(a / b) && (a % b ==0))
return true;
return false;
}
int main(){
int t, i, n, j;
int counter=0;
scanf("%d", &t);
while (counter++ < t){
scanf("%d", &n);
scanf("%d", &num[0]);
for (i=1; i<n; i++){
scanf("%d", &num[i]);
for (j=i-1; j>=0; j--){
if (!prime_related(num[i], num[j]))
g[i][j] = g[j][i] = 1;
}
}
Nx = Ny = n;
printf("Case #%d: %d\n", counter, MaxMatch());
}
return 0;
}
|
028cf381ea62692cfeef51a6952b0764b18b42d8
|
12a2c698531896823b5252079a2869fde46a81d0
|
/include/Managers/ConfigManager.hpp
|
4f61a9c43894eb1794b78872fa30bf9fff89c2ae
|
[] |
no_license
|
Phosfor/Pseudoform-2
|
a189d00c20e17049e3f6d62b95d14c52ae818433
|
cb07b44ef0d756aa244b7a6da5f03baf56275418
|
refs/heads/master
| 2020-12-24T18:32:10.953346
| 2010-09-05T09:39:11
| 2010-09-05T09:39:11
| 866,070
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,454
|
hpp
|
ConfigManager.hpp
|
#ifndef _CONFIG_MANAGER_H_
#define _CONFIG_MANAGER_H_
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/serialization/singleton.hpp>
#include <boost/foreach.hpp>
#include "Managers/LogManager.hpp"
#include <vector>
#include <map>
using namespace boost::serialization;
using boost::property_tree::ptree;
using namespace std;
#define CONFIG(key, type, def) ConfigManager::get_mutable_instance().getValue<type>(key, def)
#define configManager (ConfigManager::get_mutable_instance())
#define configManagerConst (ConfigManager::get_const_instance())
class ConfigManager : public singleton<ConfigManager>
{
protected:
string mDefaultPath;
map<string, ptree> mPtreeList;
void _forcePtree(const string &configPath);
public:
ConfigManager();
template<typename T>
T getValue(const string &key, const T &defaultValue = T(), const string &ownConfig = "")
{
if (key == "") LOG_META("Trying to get config value of empty key!");
if (ownConfig != "")
{
_forcePtree(ownConfig);
return mPtreeList[ownConfig].get<T>(key, defaultValue);
}
else
{
return mPtreeList[mDefaultPath].get<T>(key, defaultValue);
}
}
vector<string> getListValue(const string &key, const string &ownConfig = "");
};
#endif
|
219512e868aaa7457a5883e50295535737e513fd
|
807285158038bf1f9c7b7d1666ce8c8f90ef7581
|
/src/query/ops/join/JoinArray.h
|
ced4a5e547c479ac41ee31b24a654f2d192efe52
|
[] |
no_license
|
jonghunDB/SciDB19.3
|
177ccc421175977d45b679bd61841218c8ea8b17
|
e413d086b715112b37b0ae9a2882e0fff3b4cfe6
|
refs/heads/master
| 2020-05-23T11:42:23.435694
| 2019-07-03T11:12:42
| 2019-07-03T11:12:42
| 186,736,377
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,315
|
h
|
JoinArray.h
|
/*
**
* BEGIN_COPYRIGHT
*
* Copyright (C) 2008-2019 SciDB, Inc.
* All Rights Reserved.
*
* SciDB is free software: you can redistribute it and/or modify
* it under the terms of the AFFERO GNU General Public License as published by
* the Free Software Foundation.
*
* SciDB is distributed "AS-IS" AND WITHOUT ANY WARRANTY OF ANY KIND,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
* NON-INFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. See
* the AFFERO GNU General Public License for the complete license terms.
*
* You should have received a copy of the AFFERO GNU General Public License
* along with SciDB. If not, see <http://www.gnu.org/licenses/agpl-3.0.html>
*
* END_COPYRIGHT
*/
/*
* JoinArray.h
*
* Created on: Oct 22, 2010
* Author: Knizhnik
*/
#ifndef _JOIN_ARRAY_H_
#define _JOIN_ARRAY_H_
#include "array/DelegateArray.h"
namespace scidb {
class JoinEmptyableArray;
class JoinEmptyableArrayIterator;
class JoinChunkIterator : public DelegateChunkIterator
{
public:
void operator ++() override;
bool end() override;
void restart() override;
bool setPosition(Coordinates const& pos) override;
JoinChunkIterator(JoinEmptyableArrayIterator const& arrayIterator,
DelegateChunk const* chunk,
int iterationMode);
protected:
bool join();
void alignIterators();
std::shared_ptr<ConstChunkIterator> joinIterator;
int mode;
bool hasCurrent;
};
class JoinBitmapChunkIterator : public JoinChunkIterator
{
public:
Value& getItem() override;
JoinBitmapChunkIterator(JoinEmptyableArrayIterator const& arrayIterator,
DelegateChunk const* chunk,
int iterationMode);
private:
Value value;
};
class JoinEmptyableArrayIterator : public DelegateArrayIterator
{
friend class JoinChunkIterator;
friend class JoinEmptyableArray;
public:
bool setPosition(Coordinates const& pos) override;
void restart() override;
void operator ++() override;
bool end() override;
ConstChunk const& getChunk() override;
JoinEmptyableArrayIterator(JoinEmptyableArray const& array,
const AttributeDesc& attrID,
std::shared_ptr<ConstArrayIterator> inputIterator,
std::shared_ptr<ConstArrayIterator> joinIterator,
bool chunkLevelJoin);
private:
void alignIterators();
std::shared_ptr<ConstArrayIterator> _joinIterator;
bool _hasCurrent;
bool _chunkLevelJoin;
};
class JoinEmptyableArray : public DelegateArray
{
friend class JoinEmptyableArrayIterator;
friend class JoinChunkIterator;
public:
DelegateChunkIterator* createChunkIterator(DelegateChunk const* chunk, int iterationMode) const override;
DelegateArrayIterator* createArrayIterator(const AttributeDesc& id) const override;
JoinEmptyableArray(ArrayDesc const& desc, std::shared_ptr<Array> left, std::shared_ptr<Array> right);
private:
std::shared_ptr<Array> _left;
std::shared_ptr<Array> _right;
AttributeID _nLeftAttributes;
const AttributeDesc* _leftEmptyTagPosition;
const AttributeDesc* _rightEmptyTagPosition;
const AttributeDesc* _emptyTagPosition;
};
}
#endif
|
730967b0e8170d897f57f8fe1558a1eba03d5909
|
8e02857c8d7c862652007cbbe147c6c363b094ef
|
/src/opt/ssa/ssa.cpp
|
cc68b4d592dcc1af1ee09b0268027738819e754c
|
[] |
permissive
|
nlsynth/iroha
|
fb1d503c05f50c09dc928167e2fb84f8ff03565d
|
7fc5da7408b7ffb449d28737ab01fe0feea885c1
|
refs/heads/master
| 2021-07-16T15:11:56.684866
| 2021-07-09T13:42:27
| 2021-07-09T13:42:27
| 47,931,688
| 37
| 5
|
BSD-3-Clause
| 2021-07-09T13:42:28
| 2015-12-13T18:46:24
|
C++
|
UTF-8
|
C++
| false
| false
| 728
|
cpp
|
ssa.cpp
|
#include "opt/ssa/ssa.h"
#include "opt/ssa/phi_cleaner.h"
#include "opt/ssa/ssa_converter.h"
namespace iroha {
namespace opt {
namespace ssa {
SSAConverterPass::~SSAConverterPass() {}
Pass *SSAConverterPass::Create() { return new SSAConverterPass(); }
bool SSAConverterPass::ApplyForTable(const string &key, ITable *table) {
SSAConverter converter(table, opt_log_);
converter.Perform();
return true;
}
PhiCleanerPass::~PhiCleanerPass() {}
Pass *PhiCleanerPass::Create() { return new PhiCleanerPass(); }
bool PhiCleanerPass::ApplyForTable(const string &key, ITable *table) {
PhiCleaner cleaner(table, opt_log_);
cleaner.Perform();
return true;
}
} // namespace ssa
} // namespace opt
} // namespace iroha
|
40c51086ac4f4a5c1512fdab6066ac5027a2cf20
|
be07db027422115293c041bc805b24c1a16c7b9f
|
/Practice20160412/GenSubset01.cpp
|
4b98bf2db03b0711b1e328578053b389bd194145
|
[
"Apache-2.0"
] |
permissive
|
mkhrussell/ExamPractice
|
4dce4ab682dbb380a0c481a480ea1a0055d5518e
|
17b7ffa0b62ea663fee5493290551d1007bbe83d
|
refs/heads/master
| 2021-01-01T05:23:50.870222
| 2016-04-13T10:30:51
| 2016-04-13T10:30:51
| 56,027,664
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 398
|
cpp
|
GenSubset01.cpp
|
/*
#include <iostream>
#include <cstdio>
using namespace std;
int A[100], N;
void readSet()
{
cin >> N;
for (int i = 0; i < N; i++)
{
cin >> A[i];
}
}
void printSet()
{
bool flag = false;
printf("{");
for (int i = 0; i < N; i++)
{
if (flag) { printf(", "); }
else { flag = true; }
printf("%d", A[i]);
}
printf("}\n");
}
int main()
{
readSet();
printSet();
return 0;
}
*/
|
25a9df8902dee0b0fa125a0c7742c9c7133e2805
|
559207eb5beae4ba9fd638d19bd3009cbe3a6d11
|
/src/mod_spdy/common/http_to_spdy_converter.cc
|
cbcb1cf56c96aeff0244714a00fe9c2a5785b278
|
[
"Apache-2.0"
] |
permissive
|
voku/mod-spdy
|
2a8989668fe0c0f0de48c0b7ecd85b5b5b554ed1
|
bcfb388cbc5415ee660c2b5dbcf61f6f43c2a5ca
|
refs/heads/master
| 2023-04-05T09:50:46.847114
| 2015-03-19T17:58:09
| 2015-03-19T17:58:09
| 32,537,692
| 0
| 0
|
NOASSERTION
| 2023-04-04T01:40:41
| 2015-03-19T17:56:26
|
C++
|
UTF-8
|
C++
| false
| false
| 6,839
|
cc
|
http_to_spdy_converter.cc
|
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "mod_spdy/common/http_to_spdy_converter.h"
#include <string>
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/string_piece.h"
#include "mod_spdy/common/http_response_visitor_interface.h"
#include "mod_spdy/common/protocol_util.h"
#include "net/spdy/spdy_protocol.h"
namespace {
// This is the number of bytes we want to send per data frame. We never send
// data frames larger than this, but we might send smaller ones if we have to
// flush early.
// TODO The SPDY folks say that smallish (~4kB) data frames are good; however,
// we should experiment later on to see what value here performs the best.
const size_t kTargetDataFrameBytes = 4096;
} // namespace
namespace mod_spdy {
class HttpToSpdyConverter::ConverterImpl : public HttpResponseVisitorInterface{
public:
ConverterImpl(spdy::SpdyVersion spdy_version, SpdyReceiver* receiver);
virtual ~ConverterImpl();
void Flush();
// HttpResponseVisitorInterface methods:
virtual void OnStatusLine(const base::StringPiece& version,
const base::StringPiece& status_code,
const base::StringPiece& status_phrase);
virtual void OnLeadingHeader(const base::StringPiece& key,
const base::StringPiece& value);
virtual void OnLeadingHeadersComplete(bool fin);
virtual void OnData(const base::StringPiece& data, bool fin);
private:
void SendDataIfNecessary(bool flush, bool fin);
void SendDataFrame(const char* data, size_t size, bool flag_fin);
const spdy::SpdyVersion spdy_version_;
SpdyReceiver* const receiver_;
net::SpdyHeaderBlock headers_;
std::string data_buffer_;
bool sent_flag_fin_;
DISALLOW_COPY_AND_ASSIGN(ConverterImpl);
};
HttpToSpdyConverter::SpdyReceiver::SpdyReceiver() {}
HttpToSpdyConverter::SpdyReceiver::~SpdyReceiver() {}
HttpToSpdyConverter::HttpToSpdyConverter(spdy::SpdyVersion spdy_version,
SpdyReceiver* receiver)
: impl_(new ConverterImpl(spdy_version, receiver)),
parser_(impl_.get()) {}
HttpToSpdyConverter::~HttpToSpdyConverter() {}
bool HttpToSpdyConverter::ProcessInput(base::StringPiece input_data) {
return parser_.ProcessInput(input_data);
}
void HttpToSpdyConverter::Flush() {
impl_->Flush();
}
HttpToSpdyConverter::ConverterImpl::ConverterImpl(
spdy::SpdyVersion spdy_version, SpdyReceiver* receiver)
: spdy_version_(spdy_version),
receiver_(receiver),
sent_flag_fin_(false) {
DCHECK_NE(spdy::SPDY_VERSION_NONE, spdy_version);
CHECK(receiver_);
}
HttpToSpdyConverter::ConverterImpl::~ConverterImpl() {}
void HttpToSpdyConverter::ConverterImpl::Flush() {
SendDataIfNecessary(true, // true = do flush
false); // false = not fin yet
}
void HttpToSpdyConverter::ConverterImpl::OnStatusLine(
const base::StringPiece& version,
const base::StringPiece& status_code,
const base::StringPiece& status_phrase) {
DCHECK(headers_.empty());
const bool spdy2 = spdy_version_ < spdy::SPDY_VERSION_3;
headers_[spdy2 ? spdy::kSpdy2Version : spdy::kSpdy3Version] =
version.as_string();
headers_[spdy2 ? spdy::kSpdy2Status : spdy::kSpdy3Status] =
status_code.as_string();
}
void HttpToSpdyConverter::ConverterImpl::OnLeadingHeader(
const base::StringPiece& key,
const base::StringPiece& value) {
// Filter out headers that are invalid in SPDY.
if (IsInvalidSpdyResponseHeader(key)) {
return;
}
MergeInHeader(key, value, &headers_);
}
void HttpToSpdyConverter::ConverterImpl::OnLeadingHeadersComplete(bool fin) {
if (sent_flag_fin_) {
LOG(DFATAL) << "Trying to send headers after sending FLAG_FIN";
return;
}
if (fin) {
sent_flag_fin_ = true;
}
receiver_->ReceiveSynReply(&headers_, fin);
headers_.clear();
}
void HttpToSpdyConverter::ConverterImpl::OnData(const base::StringPiece& data,
bool fin) {
data.AppendToString(&data_buffer_);
SendDataIfNecessary(false, fin); // false = don't flush
}
void HttpToSpdyConverter::ConverterImpl::SendDataIfNecessary(bool flush,
bool fin) {
// If we have (strictly) more than one frame's worth of data waiting, send it
// down the filter chain, kTargetDataFrameBytes bytes at a time. If we are
// left with _exactly_ kTargetDataFrameBytes bytes of data, we'll deal with
// that in the next code block (see the comment there to explain why).
if (data_buffer_.size() > kTargetDataFrameBytes) {
const char* start = data_buffer_.data();
size_t size = data_buffer_.size();
while (size > kTargetDataFrameBytes) {
SendDataFrame(start, kTargetDataFrameBytes, false);
start += kTargetDataFrameBytes;
size -= kTargetDataFrameBytes;
}
data_buffer_.erase(0, data_buffer_.size() - size);
}
DCHECK(data_buffer_.size() <= kTargetDataFrameBytes);
// We may still have some leftover data. We need to send another data frame
// now (rather than waiting for a full kTargetDataFrameBytes) if:
// 1) This is the end of the response,
// 2) we're supposed to flush and the buffer is nonempty, or
// 3) we still have a full data frame's worth in the buffer.
//
// Note that because of the previous code block, condition (3) will only be
// true if we have exactly kTargetDataFrameBytes of data. However, dealing
// with that case here instead of in the above block makes it easier to make
// sure we correctly set FLAG_FIN on the final data frame, which is why the
// above block uses a strict, > comparison rather than a non-strict, >=
// comparison.
if (fin || (flush && !data_buffer_.empty()) ||
data_buffer_.size() >= kTargetDataFrameBytes) {
SendDataFrame(data_buffer_.data(), data_buffer_.size(), fin);
data_buffer_.clear();
}
}
void HttpToSpdyConverter::ConverterImpl::SendDataFrame(
const char* data, size_t size, bool flag_fin) {
if (sent_flag_fin_) {
LOG(DFATAL) << "Trying to send data after sending FLAG_FIN";
return;
}
if (flag_fin) {
sent_flag_fin_ = true;
}
receiver_->ReceiveData(base::StringPiece(data, size), flag_fin);
}
} // namespace mod_spdy
|
b127cd312a246f9ba33347b35113b5e4a1d60042
|
5e8d200078e64b97e3bbd1e61f83cb5bae99ab6e
|
/main/source/src/apps/benchmark/performance/FastRelax.bench.hh
|
17e38ab3a9d16aa6286641d23cb7db1ee826e11e
|
[] |
no_license
|
MedicaicloudLink/Rosetta
|
3ee2d79d48b31bd8ca898036ad32fe910c9a7a28
|
01affdf77abb773ed375b83cdbbf58439edd8719
|
refs/heads/master
| 2020-12-07T17:52:01.350906
| 2020-01-10T08:24:09
| 2020-01-10T08:24:09
| 232,757,729
| 2
| 6
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,027
|
hh
|
FastRelax.bench.hh
|
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
// vi: set ts=2 noet:
//
// (c) Copyright Rosetta Commons Member Institutions.
// (c) This file is part of the Rosetta software suite and is made available under license.
// (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
// (c) For more information, see http://www.rosettacommons.org. Questions about this can be
// (c) addressed to University of Washington CoMotion, email: license@uw.edu.
/// @file rosetta/benchmark/FastRelax.bench.cc
/// @brief Performance benchmark running the fullatom fast-relax protocol.
/// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
#ifndef INCLUDED_apps_benchmark_FastRelax_bench_hh
#define INCLUDED_apps_benchmark_FastRelax_bench_hh
#include <apps/benchmark/performance/performance_benchmark.hh>
#include <core/types.hh>
#include <core/pose/Pose.hh>
#include <core/import_pose/import_pose.hh>
#include <core/scoring/ScoreFunction.hh>
#include <core/scoring/methods/EnergyMethodOptions.hh>
#include <core/scoring/hbonds/HBondOptions.hh>
#include <protocols/relax/FastRelax.hh>
//#include <core/scoring/ScoringManager.hh>
//#include <core/scoring/ScoreTypeManager.hh>
//#include <core/scoring/Energies.hh>
//#include <core/scoring/EnergyGraph.hh>
//#include <core/scoring/methods/OneBodyEnergy.hh>
//#include <core/scoring/methods/ShortRangeTwoBodyEnergy.hh>
//#include <core/scoring/methods/LongRangeTwoBodyEnergy.hh>
//#include <core/scoring/LREnergyContainer.hh>
#include <utility/vector1.hh>
#include <utility/excn/Exceptions.hh>
#include <basic/Tracer.hh>
enum fast_relax_perf_benchmark {
fast_relax_perfbench_score12,
fast_relax_perfbench_sc12sp2,
fast_relax_perfbench_sc12he,
fast_relax_perfbench_mmstd,
fast_relax_perfbench_sp2hecart
};
class FastRelaxPerformanceBenchmark : public PerformanceBenchmark
{
public:
FastRelaxPerformanceBenchmark(
std::string name,
fast_relax_perf_benchmark benchtype
) :
PerformanceBenchmark( name ),
benchtype_( benchtype )
{}
virtual void setUp() {
pose_ = utility::pointer::make_shared< core::pose::Pose >();
// Use smaller pdb to test relax
core::import_pose::pose_from_file(*pose_, "test_in2.pdb", core::import_pose::PDB_file);
scorefxn_ = utility::pointer::make_shared< core::scoring::ScoreFunction >();
switch ( benchtype_ ) {
case fast_relax_perfbench_score12 :
setup_for_score12();
break;
case fast_relax_perfbench_sc12sp2 :
setup_for_sc12sp2();
break;
case fast_relax_perfbench_sc12he :
setup_for_sc12he();
break;
case fast_relax_perfbench_mmstd :
setup_for_mmstd();
break;
case fast_relax_perfbench_sp2hecart :
setup_for_sp2hecart();
break;
}
}
virtual void run(core::Real scaleFactor) {
core::Size reps( (core::Size)(1 * scaleFactor) );
if ( reps == 0 ) { reps = 1; } // do at least one repetition, regardless of scale factor.
for ( core::Size ii = 1; ii <= reps; ++ii ) {
core::pose::Pose runpose = *pose_; // don't start from the last iteration's pose
fr_->apply( runpose );
}
}
virtual void tearDown() {
pose_.reset();
scorefxn_.reset();
fr_.reset();
}
void setup_for_score12() {
using namespace core::scoring;
using namespace protocols::relax;
scorefxn_->set_weight( fa_atr, 0.8 );
scorefxn_->set_weight( fa_rep, 0.44 );
scorefxn_->set_weight( fa_sol, 0.65 );
scorefxn_->set_weight( fa_intra_rep, 0.004 );
scorefxn_->set_weight( fa_pair, 0.49 );
//scorefxn_->set_weight( fa_plane, 0 );
scorefxn_->set_weight( fa_dun, 0.56 );
scorefxn_->set_weight( ref, 1 );
scorefxn_->set_weight( hbond_lr_bb, 1.17 );
scorefxn_->set_weight( hbond_sr_bb, 0.585 );
scorefxn_->set_weight( hbond_bb_sc, 1.17 );
scorefxn_->set_weight( hbond_sc, 1.1 );
scorefxn_->set_weight( p_aa_pp, 0.32 );
scorefxn_->set_weight( dslf_ss_dst, 0.5 );
scorefxn_->set_weight( dslf_cs_ang, 2.0 );
scorefxn_->set_weight( dslf_ss_dih, 5.0 );
scorefxn_->set_weight( dslf_ca_dih, 5.0 );
scorefxn_->set_weight( pro_close, 1.0 );
scorefxn_->set_weight( omega, 0.5 );
scorefxn_->set_weight( rama, 0.2 );
fr_ = utility::pointer::make_shared< FastRelax >( scorefxn_ );
}
void setup_for_sc12sp2() {
using namespace core::scoring;
using namespace core::scoring::methods;
using namespace core::scoring::hbonds;
using namespace protocols::relax;
EnergyMethodOptions emo;
HBondOptions hbo;
hbo.use_sp2_chi_penalty( true );
hbo.measure_sp3acc_BAH_from_hvy( true );
hbo.fade_energy( true );
emo.hbond_options( hbo );
scorefxn_->set_energy_method_options( emo );
scorefxn_->set_weight( fa_atr, 0.8 );
scorefxn_->set_weight( fa_rep, 0.44 );
scorefxn_->set_weight( fa_sol, 0.65 );
scorefxn_->set_weight( fa_intra_rep, 0.004 );
scorefxn_->set_weight( fa_pair, 0.49 );
//scorefxn_->set_weight( fa_plane, 0 );
scorefxn_->set_weight( fa_dun, 0.56 );
scorefxn_->set_weight( ref, 1 );
scorefxn_->set_weight( hbond_lr_bb, 1.17 );
scorefxn_->set_weight( hbond_sr_bb, 1.17 );
scorefxn_->set_weight( hbond_bb_sc, 1.17 );
scorefxn_->set_weight( hbond_sc, 1.1 );
scorefxn_->set_weight( p_aa_pp, 0.32 );
scorefxn_->set_weight( dslf_ss_dst, 0.5 );
scorefxn_->set_weight( dslf_cs_ang, 2.0 );
scorefxn_->set_weight( dslf_ss_dih, 5.0 );
scorefxn_->set_weight( dslf_ca_dih, 5.0 );
scorefxn_->set_weight( pro_close, 1.0 );
scorefxn_->set_weight( omega, 0.5 );
scorefxn_->set_weight( rama, 0.2 );
fr_ = utility::pointer::make_shared< FastRelax >( scorefxn_ );
}
void setup_for_sc12he() {
using namespace core::scoring;
using namespace protocols::relax;
scorefxn_->set_weight( fa_atr, 0.8 );
scorefxn_->set_weight( fa_rep, 0.44 );
scorefxn_->set_weight( fa_sol, 0.65 );
scorefxn_->set_weight( fa_intra_rep, 0.004 );
scorefxn_->set_weight( fa_pair, 0.49 );
//scorefxn_->set_weight( fa_plane, 0 );
scorefxn_->set_weight( fa_dun, 0.56 );
scorefxn_->set_weight( ref, 1 );
scorefxn_->set_weight( hbond_lr_bb, 1.17 );
scorefxn_->set_weight( hbond_sr_bb, 0.585 );
scorefxn_->set_weight( hbond_bb_sc, 1.17 );
scorefxn_->set_weight( hbond_sc, 1.1 );
scorefxn_->set_weight( p_aa_pp, 0.32 );
scorefxn_->set_weight( dslf_ss_dst, 0.5 );
scorefxn_->set_weight( dslf_cs_ang, 2.0 );
scorefxn_->set_weight( dslf_ss_dih, 5.0 );
scorefxn_->set_weight( dslf_ca_dih, 5.0 );
scorefxn_->set_weight( pro_close, 1.0 );
scorefxn_->set_weight( omega, 0.5 );
scorefxn_->set_weight( rama, 0.2 );
scorefxn_->set_weight( fa_elec, 0.7 );
fr_ = utility::pointer::make_shared< FastRelax >( scorefxn_ );
}
void setup_for_mmstd() {
using namespace core::scoring;
using namespace core::scoring::methods;
using namespace protocols::relax;
EnergyMethodOptions emo;
emo.unfolded_energies_type( "UNFOLDED_MM_STD" );
scorefxn_->set_energy_method_options( emo );
scorefxn_->set_weight( fa_atr, 0.8 );
scorefxn_->set_weight( fa_rep, 0.634454 );
scorefxn_->set_weight( fa_sol, 1.16497 );
//scorefxn_->set_weight( mm_lj_intra_rep, 0.324341 ); // UNCOMMENT THESE WHEN THEY STOP NOT WORKING
//scorefxn_->set_weight( mm_lj_intra_atr, 0.537815 );
scorefxn_->set_weight( mm_twist, 0.2662 );
scorefxn_->set_weight( pro_close, 1.44777 );
scorefxn_->set_weight( hbond_sr_bb, 0.656728 );
scorefxn_->set_weight( hbond_lr_bb, 1.50186 );
scorefxn_->set_weight( hbond_bb_sc, 1.45367 );
scorefxn_->set_weight( hbond_sc, 1.18477 );
scorefxn_->set_weight( dslf_ss_dst, 0.5 );
scorefxn_->set_weight( dslf_cs_ang, 2 );
scorefxn_->set_weight( dslf_ss_dih, 5 );
scorefxn_->set_weight( dslf_ca_dih, 5 );
scorefxn_->set_weight( unfolded, -0.904283 );
fr_ = utility::pointer::make_shared< FastRelax >( scorefxn_ );
}
void setup_for_sp2hecart() {
using namespace core::scoring;
using namespace core::scoring::methods;
using namespace core::scoring::hbonds;
using namespace protocols::relax;
EnergyMethodOptions emo;
HBondOptions hbo;
hbo.use_sp2_chi_penalty( true );
hbo.measure_sp3acc_BAH_from_hvy( true );
hbo.fade_energy( true );
emo.hbond_options( hbo );
scorefxn_->set_energy_method_options( emo );
scorefxn_->set_weight( fa_atr, 0.8 );
scorefxn_->set_weight( fa_rep, 0.44 );
scorefxn_->set_weight( fa_sol, 0.65 );
scorefxn_->set_weight( fa_intra_rep, 0.004 );
scorefxn_->set_weight( fa_pair, 0.49 );
//scorefxn_->set_weight( fa_plane, 0 );
scorefxn_->set_weight( fa_dun, 0.56 );
scorefxn_->set_weight( ref, 1 );
scorefxn_->set_weight( hbond_lr_bb, 1.17 );
scorefxn_->set_weight( hbond_sr_bb, 1.17 );
scorefxn_->set_weight( hbond_bb_sc, 1.17 );
scorefxn_->set_weight( hbond_sc, 1.1 );
scorefxn_->set_weight( p_aa_pp, 0.32 );
scorefxn_->set_weight( dslf_ss_dst, 0.5 );
scorefxn_->set_weight( dslf_cs_ang, 2.0 );
scorefxn_->set_weight( dslf_ss_dih, 5.0 );
scorefxn_->set_weight( dslf_ca_dih, 5.0 );
scorefxn_->set_weight( pro_close, 1.0 );
scorefxn_->set_weight( omega, 0.5 );
scorefxn_->set_weight( rama, 0.2 );
scorefxn_->set_weight( fa_elec, 0.7 );
scorefxn_->set_weight( cart_bonded, 0.5 );
fr_ = utility::pointer::make_shared< FastRelax >( scorefxn_ );
fr_->cartesian( true );
}
private:
fast_relax_perf_benchmark benchtype_;
core::pose::PoseOP pose_;
core::scoring::ScoreFunctionOP scorefxn_;
protocols::relax::FastRelaxOP fr_;
};
FastRelaxPerformanceBenchmark frpb_sc12( "protocols.relax.fast_relax_performance_benchmark_score12", fast_relax_perfbench_score12 );
FastRelaxPerformanceBenchmark frpb_sc12sp2( "protocols.relax.fast_relax_performance_benchmark_sc12sp2", fast_relax_perfbench_sc12sp2 );
FastRelaxPerformanceBenchmark frpb_sc12he( "protocols.relax.fast_relax_performance_benchmark_sc12he", fast_relax_perfbench_sc12he );
FastRelaxPerformanceBenchmark frpb_mmstd( "protocols.relax.fast_relax_performance_benchmark_mmstd", fast_relax_perfbench_mmstd );
//FastRelaxPerformanceBenchmark frpb_sp2hecart( "protocols.relax.fast_relax_performance_benchmark_sp2hecart", fast_relax_perfbench_sp2hecart );
#endif
|
6ba3995b5406187f0e97eb641165318127684ef5
|
4a70206488bc1959ab347fbbcb6a0ddbabb920bb
|
/libraries/animation/src/AnimOverlay.cpp
|
e086413dde987341c59811bc73fe1fae9aef0280
|
[
"Apache-2.0"
] |
permissive
|
zzmp/hifi
|
60dc87dffb67a315fc1334b28615dc33d381e421
|
9ae390853c6b28132ca9cec7c7f68b002ff8fc4a
|
refs/heads/master
| 2020-04-05T14:58:33.041164
| 2017-06-25T15:17:16
| 2017-06-25T15:17:16
| 45,364,529
| 2
| 0
| null | 2017-07-11T04:41:54
| 2015-11-02T01:02:18
|
C++
|
UTF-8
|
C++
| false
| false
| 6,597
|
cpp
|
AnimOverlay.cpp
|
//
// AnimOverlay.cpp
//
// Created by Anthony J. Thibault on 9/2/15.
// Copyright (c) 2015 High Fidelity, Inc. All rights reserved.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "AnimOverlay.h"
#include "AnimUtil.h"
#include <queue>
AnimOverlay::AnimOverlay(const QString& id, BoneSet boneSet, float alpha) :
AnimNode(AnimNode::Type::Overlay, id), _boneSet(boneSet), _alpha(alpha) {
}
AnimOverlay::~AnimOverlay() {
}
void AnimOverlay::buildBoneSet(BoneSet boneSet) {
assert(_skeleton);
switch (boneSet) {
case FullBodyBoneSet: buildFullBodyBoneSet(); break;
case UpperBodyBoneSet: buildUpperBodyBoneSet(); break;
case LowerBodyBoneSet: buildLowerBodyBoneSet(); break;
case LeftArmBoneSet: buildLeftArmBoneSet(); break;
case RightArmBoneSet: buildRightArmBoneSet(); break;
case AboveTheHeadBoneSet: buildAboveTheHeadBoneSet(); break;
case BelowTheHeadBoneSet: buildBelowTheHeadBoneSet(); break;
case HeadOnlyBoneSet: buildHeadOnlyBoneSet(); break;
case SpineOnlyBoneSet: buildSpineOnlyBoneSet(); break;
case LeftHandBoneSet: buildLeftHandBoneSet(); break;
case RightHandBoneSet: buildRightHandBoneSet(); break;
case HipsOnlyBoneSet: buildHipsOnlyBoneSet(); break;
default:
case EmptyBoneSet: buildEmptyBoneSet(); break;
}
}
const AnimPoseVec& AnimOverlay::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) {
// lookup parameters from animVars, using current instance variables as defaults.
// NOTE: switching bonesets can be an expensive operation, let's try to avoid it.
auto prevBoneSet = _boneSet;
_boneSet = (BoneSet)animVars.lookup(_boneSetVar, (int)_boneSet);
if (_boneSet != prevBoneSet && _skeleton) {
buildBoneSet(_boneSet);
}
_alpha = animVars.lookup(_alphaVar, _alpha);
if (_children.size() >= 2) {
auto& underPoses = _children[1]->evaluate(animVars, context, dt, triggersOut);
auto& overPoses = _children[0]->overlay(animVars, context, dt, triggersOut, underPoses);
if (underPoses.size() > 0 && underPoses.size() == overPoses.size()) {
_poses.resize(underPoses.size());
assert(_boneSetVec.size() == _poses.size());
for (size_t i = 0; i < _poses.size(); i++) {
float alpha = _boneSetVec[i] * _alpha;
::blend(1, &underPoses[i], &overPoses[i], alpha, &_poses[i]);
}
}
}
return _poses;
}
template <typename Func>
void for_each_child_joint(AnimSkeleton::ConstPointer skeleton, int startJoint, Func f) {
std::queue<int> q;
q.push(startJoint);
while(q.size() > 0) {
int jointIndex = q.front();
for (int i = 0; i < skeleton->getNumJoints(); i++) {
if (jointIndex == skeleton->getParentIndex(i)) {
f(i);
q.push(i);
}
}
q.pop();
}
}
void AnimOverlay::buildFullBodyBoneSet() {
assert(_skeleton);
_boneSetVec.resize(_skeleton->getNumJoints());
for (int i = 0; i < _skeleton->getNumJoints(); i++) {
_boneSetVec[i] = 1.0f;
}
}
void AnimOverlay::buildUpperBodyBoneSet() {
assert(_skeleton);
buildEmptyBoneSet();
int spineJoint = _skeleton->nameToJointIndex("Spine");
for_each_child_joint(_skeleton, spineJoint, [&](int i) {
_boneSetVec[i] = 1.0f;
});
}
void AnimOverlay::buildLowerBodyBoneSet() {
assert(_skeleton);
buildFullBodyBoneSet();
int hipsJoint = _skeleton->nameToJointIndex("Hips");
int spineJoint = _skeleton->nameToJointIndex("Spine");
_boneSetVec.resize(_skeleton->getNumJoints());
for_each_child_joint(_skeleton, spineJoint, [&](int i) {
_boneSetVec[i] = 0.0f;
});
_boneSetVec[hipsJoint] = 0.0f;
}
void AnimOverlay::buildLeftArmBoneSet() {
assert(_skeleton);
buildEmptyBoneSet();
int leftShoulderJoint = _skeleton->nameToJointIndex("LeftShoulder");
for_each_child_joint(_skeleton, leftShoulderJoint, [&](int i) {
_boneSetVec[i] = 1.0f;
});
}
void AnimOverlay::buildRightArmBoneSet() {
assert(_skeleton);
buildEmptyBoneSet();
int rightShoulderJoint = _skeleton->nameToJointIndex("RightShoulder");
for_each_child_joint(_skeleton, rightShoulderJoint, [&](int i) {
_boneSetVec[i] = 1.0f;
});
}
void AnimOverlay::buildAboveTheHeadBoneSet() {
assert(_skeleton);
buildEmptyBoneSet();
int headJoint = _skeleton->nameToJointIndex("Head");
for_each_child_joint(_skeleton, headJoint, [&](int i) {
_boneSetVec[i] = 1.0f;
});
}
void AnimOverlay::buildBelowTheHeadBoneSet() {
assert(_skeleton);
buildFullBodyBoneSet();
int headJoint = _skeleton->nameToJointIndex("Head");
for_each_child_joint(_skeleton, headJoint, [&](int i) {
_boneSetVec[i] = 0.0f;
});
}
void AnimOverlay::buildHeadOnlyBoneSet() {
assert(_skeleton);
buildEmptyBoneSet();
int headJoint = _skeleton->nameToJointIndex("Head");
_boneSetVec[headJoint] = 1.0f;
}
void AnimOverlay::buildSpineOnlyBoneSet() {
assert(_skeleton);
buildEmptyBoneSet();
int spineJoint = _skeleton->nameToJointIndex("Spine");
_boneSetVec[spineJoint] = 1.0f;
}
void AnimOverlay::buildEmptyBoneSet() {
assert(_skeleton);
_boneSetVec.resize(_skeleton->getNumJoints());
for (int i = 0; i < _skeleton->getNumJoints(); i++) {
_boneSetVec[i] = 0.0f;
}
}
void AnimOverlay::buildLeftHandBoneSet() {
assert(_skeleton);
buildEmptyBoneSet();
int handJoint = _skeleton->nameToJointIndex("LeftHand");
for_each_child_joint(_skeleton, handJoint, [&](int i) {
_boneSetVec[i] = 1.0f;
});
}
void AnimOverlay::buildRightHandBoneSet() {
assert(_skeleton);
buildEmptyBoneSet();
int handJoint = _skeleton->nameToJointIndex("RightHand");
for_each_child_joint(_skeleton, handJoint, [&](int i) {
_boneSetVec[i] = 1.0f;
});
}
void AnimOverlay::buildHipsOnlyBoneSet() {
assert(_skeleton);
buildEmptyBoneSet();
int hipsJoint = _skeleton->nameToJointIndex("Hips");
_boneSetVec[hipsJoint] = 1.0f;
}
// for AnimDebugDraw rendering
const AnimPoseVec& AnimOverlay::getPosesInternal() const {
return _poses;
}
void AnimOverlay::setSkeletonInternal(AnimSkeleton::ConstPointer skeleton) {
AnimNode::setSkeletonInternal(skeleton);
// we have to re-build the bone set when the skeleton changes.
buildBoneSet(_boneSet);
}
|
3c82dc6c74a5b9af29bd77ec6b70dd8c2648c8f8
|
f46e5258241338e79e062ead8ed8b6952ac5016a
|
/leetcode/dynamic_programming/413.arithmetic-slices.cpp
|
f3128edef63a4ce33254be5f5569b598f5088e96
|
[] |
no_license
|
riveridea/algorithm
|
a58fde65ac693b56329bc2dc064a131d9a519b69
|
6151ae9ae7684b020c03a85da154b1b9b00661e8
|
refs/heads/master
| 2021-01-02T09:32:25.500821
| 2019-11-04T00:32:13
| 2019-11-04T00:32:13
| 8,842,964
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,791
|
cpp
|
413.arithmetic-slices.cpp
|
/*
* @lc app=leetcode id=413 lang=cpp
*
* [413] Arithmetic Slices
*
* https://leetcode.com/problems/arithmetic-slices/description/
*
* algorithms
* Medium (54.75%)
* Total Accepted: 53.2K
* Total Submissions: 97.2K
* Testcase Example: '[1,2,3,4]'
*
* A sequence of number is called arithmetic if it consists of at least three
* elements and if the difference between any two consecutive elements is the
* same.
*
* For example, these are arithmetic sequence:
* 1, 3, 5, 7, 9
* 7, 7, 7, 7
* 3, -1, -5, -9
*
* The following sequence is not arithmetic. 1, 1, 2, 5, 7
*
*
* A zero-indexed array A consisting of N numbers is given. A slice of that
* array is any pair of integers (P, Q) such that 0
*
* A slice (P, Q) of array A is called arithmetic if the sequence:
* A[P], A[p + 1], ..., A[Q - 1], A[Q] is arithmetic. In particular, this
* means that P + 1 < Q.
*
* The function should return the number of arithmetic slices in the array
* A.
*
*
* Example:
*
* A = [1, 2, 3, 4]
*
* return: 3, for 3 arithmetic slices in A: [1, 2, 3], [2, 3, 4] and [1, 2, 3,
* 4] itself.
*
*/
class Solution {
public:
int numberOfArithmeticSlices(vector<int>& A) {
//this is typical DP problem
//define dp[i] as the number of Arithmetics ending at A[i], and A[i] must be included
//then from bottomer to up, update dp[i+1] according the difference
//between A[i], A[i-1] and A[i+1]
int n = A.size();
if(n < 3) return 0;
//vector<int> dp(n, 0);
int result = 0;
int curr = 0;
if(A[2] - A[1] == A[1] - A[0]) curr = 1;
result += curr;
for(int i = 3; i < n; i++)
{
if(A[i] - A[i-1] == A[i-1] - A[i-2])
curr = curr + 1;
else
curr = 0;
result += curr;
}
return result;
}
};
|
2bcd26218d869f9e0b97ad04f8446ff5066173ce
|
869a9a78bd4f9ecc01005bfae35c30350c3d1f53
|
/src/jimic/core/jimic_def.h
|
3cba8dd3a5dbae3686235a09c22a43e20a9b2ae2
|
[
"MIT"
] |
permissive
|
bactq/jimi
|
d7f8f4e89803352bc9e7b4471b3c0b55ff08465a
|
5dc585753ecfec4132e0582d919b725688ea6eaf
|
refs/heads/master
| 2021-01-16T20:59:23.378992
| 2014-07-31T22:44:59
| 2014-07-31T22:44:59
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,054
|
h
|
jimic_def.h
|
#ifndef _JIMIC_DEF_H_
#define _JIMIC_DEF_H_
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <jimi/platform/jimi_platform_def.h>
#include <jimi/platform/jimi_compiler_def.h>
#if JIMI_IS_WINDOWS
#include <jimic/platform/jimic_targetver.h>
#endif
#include <jimic/core/jimic_config.h>
#include <jimic/core/jimic_export.h>
// Define type size_t
#ifndef _SIZE_T_DEFINED
#include <stddef.h>
#endif
// linux maybe need #include <sys/types.h>
// Define integer types with known size: int32_t, uint32_t, int64_t, uint64_t.
// If this doesn't work then insert compiler-specific definitions here:
// (stdint.h defined from visual studio 2010)
#if defined(JIMI_IS_GNUC) || (defined(JIMI_MSC_VER) && JIMI_MSC_VER >= 1600)
// Compilers supporting C99 or C++0x have stdint.h defining these integer types
#include <stdint.h>
#define INT64_SUPPORTED // Remove this if the compiler doesn't support 64-bit integers
#elif defined(JIMI_MSC_VER)
#include <jimic/core/win32/vs_stdint.h>
#else
#ifndef _STDINT
#define _STDINT
// This works with most compilers
typedef signed short int int16_t;
typedef unsigned short int uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
#define INT64_SUPPORTED // Remove this if the compiler doesn't support 64-bit integers
#endif
#endif
#include <jimi/core/jimi_common.h>
/**
* @file jimic_def.h
* @brief JIMIC Platform Definitions
* @remark This is a generated header generated from include/jimic_def.h.in by
* ./configure, or copied from include/jimic_def.hw or include/jimic_def.hnw
* for Win32 or Netware by those build environments, respectively.
*/
#if defined(JIMI_IS_WINDOWS) || defined(JIMI_IS_DOXYGEN)
/* Ignore most warnings (back down to /W3) for poorly constructed headers
*/
#if defined(_MSC_VER) && _MSC_VER >= 1200
//#pragma warning(push, 3)
#endif
/* disable or reduce the frequency of...
* C4057: indirection to slightly different base types
* C4075: slight indirection changes (unsigned short* vs short[])
* C4100: unreferenced formal parameter
* C4127: conditional expression is constant
* C4163: '_rotl64' : not available as an intrinsic function
* C4201: nonstandard extension nameless struct/unions
* C4244: int to char/short - precision loss
* C4514: unreferenced inline function removed
*/
//#pragma warning(disable: 4100 4127 4163 4201 4514; once: 4057 4075 4244)
/* Ignore Microsoft's interpretation of secure development
* and the POSIX string handling API
*/
#if defined(_MSC_VER) && _MSC_VER >= 1400
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#pragma warning(disable: 4996)
#endif /* _MSC_VER */
/* Has windows.h already been included? If so, our preferences don't matter,
* but we will still need the winsock things no matter what was included.
* If not, include a restricted set of windows headers to our tastes.
*/
#ifndef _WINDOWS_
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif /* WIN32_LEAN_AND_MEAN */
#ifndef _WIN32_WINNT
/* Restrict the server to a subset of Windows XP header files by default
*/
#define _WIN32_WINNT 0x0501
#endif /* _WIN32_WINNT */
#ifndef NOUSER
#define NOUSER
#endif
#ifndef NOMCX
#define NOMCX
#endif
#ifndef NOIME
#define NOIME
#endif
#include <windows.h>
#ifdef _MSC_VER
/*
* Add a _very_few_ declarations missing from the restricted set of headers
* (If this list becomes extensive, re-enable the required headers above!)
* winsock headers were excluded by WIN32_LEAN_AND_MEAN, so include them now
*/
#define SW_HIDE 0
#ifndef _WIN32_WCE
#include <winsock2.h>
#include <ws2tcpip.h>
#include <mswsock.h>
#else
#include <winsock.h>
#endif /* _WIN32_WCE */
#endif /* _MSC)VER */
#endif /* _WINDOWS_ */
#endif /* defined(JIMI_IS_WINDOWS) || defined(JIMI_IS_DOXYGEN) */
#define JIMIC_MIN(a, b) ((a) < (b) ? (a) : (b))
#define JIMIC_MAX(a, b) ((a) > (b) ? (a) : (b))
#ifndef TRUE
#define TRUE 1
#endif // TRUE
#ifndef FALSE
#define FALSE 0
#endif // FALSE
// for precompiled macro to string
#define JIMIC_STRING_ESCAPE(x) #x
#define JIMIC_TO_STRING(x) JIMIC_STRING_ESCAPE(x)
#define JIMIC_MAKE_STRING(x) { #x, JIMIC_STRING_ESCAPE(x) }
typedef struct JIMIC_MACRO_T
{
const char *name;
const char *value;
} JIMIC_MACRO_T;
#ifndef JM_CONST
#define JM_CONST const
#endif /* JM_CONST */
#ifndef JM_CHAR_DEFINED
#define JM_CHAR_DEFINED
typedef char jm_char;
#endif /* JM_CHAR_DEFINED */
#ifndef JM_UCHAR_DEFINED
#define JM_UCHAR_DEFINED
typedef unsigned char jm_uchar;
#endif /* JM_UCHAR_DEFINED */
/**
* JMC public API wrap for C++ compilers.
*/
#ifdef __cplusplus
#define JMC_BEGIN_DECLS extern "C" {
#define JMC_END_DECLS }
#else
#define JMC_BEGIN_DECLS
#define JMC_END_DECLS
#endif /* __cplusplus */
/**
* for jimic assert defines
*/
#include <jimic/core/jimic_assert.h>
/**
* for JMC_DECLARE define
*/
#if (!defined(JIMI_IS_WINDOWS)) || defined(JIMI_IS_DOXYGEN)
#define JMC_DECLARE(type) type
#define JMC_DECLARE_NONSTD(type) type
#define JMC_INLINE_DECLARE(type) JMC_INLINE type
#define JMC_INLINE_NONSTD(type) JMC_INLINE type
#define JMC_FORCEINLINE_DECLARE(type) JMC_FORCEINLINE type
#define JMC_FORCEINLINE_NONSTD(type) JMC_FORCEINLINE type
#define JMC_DECLARE_DATA
#elif defined(JIMI_DECLARE_IMPORT)
#define JMC_DECLARE(type) __declspec(dllimport) type __stdcall
#define JMC_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
#define JMC_INLINE_DECLARE(type) JMC_INLINE __declspec(dllimport) type __stdcall
#define JMC_INLINE_NONSTD(type) JMC_INLINE __declspec(dllimport) type __cdecl
#define JMC_FORCEINLINE_DECLARE(type) JMC_FORCEINLINE __declspec(dllimport) type __stdcall
#define JMC_FORCEINLINE_NONSTD(type) JMC_FORCEINLINE __declspec(dllimport) type __cdecl
#define JMC_DECLARE_DATA __declspec(dllimport)
#elif defined(JIMI_DECLARE_EXPORT)
#define JMC_DECLARE(type) __declspec(dllexport) type __stdcall
#define JMC_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
#define JMC_INLINE_DECLARE(type) JMC_INLINE __declspec(dllexport) type __stdcall
#define JMC_INLINE_NONSTD(type) JMC_INLINE __declspec(dllexport) type __cdecl
#define JMC_FORCEINLINE_DECLARE(type) JMC_FORCEINLINE __declspec(dllexport) type __stdcall
#define JMC_FORCEINLINE_NONSTD(type) JMC_FORCEINLINE __declspec(dllexport) type __cdecl
#define JMC_DECLARE_DATA __declspec(dllexport)
#else
#define JMC_DECLARE(type) type __stdcall
#define JMC_DECLARE_NONSTD(type) type __cdecl
#define JMC_INLINE_DECLARE(type) JMC_INLINE type __stdcall
#define JMC_INLINE_NONSTD(type) JMC_INLINE type __cdecl
#define JMC_FORCEINLINE_DECLARE(type) JMC_FORCEINLINE type __stdcall
#define JMC_FORCEINLINE_NONSTD(type) JMC_FORCEINLINE type __cdecl
#define JMC_DECLARE_DATA
#endif /* (!defined(JIMI_IS_WINDOWS)) || defined(JIMI_IS_DOXYGEN) */
/**
* for thread func define
*/
#if defined(JIMI_IS_WINDOWS)
#define JIMIC_THREAD_FUNC __stdcall
#else
#define JIMIC_THREAD_FUNC
#endif /* JIMI_IS_WINDOWS */
#if !defined(__GNUC__) && !defined(__attribute__)
#define __attribute__(__x)
#endif
/**
* for exported func
*/
#if _MSC_VER >= 1400
#define JIMIC_EXPORTED_FUNC __cdecl
#define JIMIC_EXPORTED_METHOD __thiscall
#else
#define JIMIC_EXPORTED_FUNC
#define JIMIC_EXPORTED_METHOD
#endif
#if _MSC_VER || __INTEL_COMPILER
#define JIMIC_NOINLINE(decl) __declspec(noinline) decl
#elif __GNUC__
#define JIMIC_NOINLINE(decl) decl __attribute__ ((noinline))
#else
#define JIMIC_NOINLINE(decl) decl
#endif
/**
* for jmc_countof helper
*/
#if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64)
#define ALIGNMENT_MACHINE
#define UNALIGNED __unaligned
#if defined(_WIN64)
#define UNALIGNED64 __unaligned
#else
#define UNALIGNED64
#endif
#else
#undef ALIGNMENT_MACHINE
#ifndef UNALIGNED
#define UNALIGNED
#endif
#ifndef UNALIGNED64
#define UNALIGNED64
#endif
#endif
/**
* jmc_countof helper
*/
#if !defined(jmc_countof)
#if !defined(__cplusplus)
#define jmc_countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
#else
extern "C++"
{
template <typename _CountofType, size_t _SizeOfArray>
char (*__jmc_countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
#define jmc_countof(_Array) sizeof(*__jmc_countof_helper(_Array))
}
#endif /* !defined(__cplusplus) */
#endif /* !defined(jmc_countof) */
/* Done with badly written headers
*/
#if defined(_MSC_VER) && _MSC_VER >= 1200
//#pragma warning(pop)
//#pragma warning(disable: 4996)
#endif
#endif /* _JIMIC_DEF_H_ */
|
68a8a2a355aa34cfaa0f9d98274c576af12dc43c
|
b37057fdb32850390e54d56fddbbe3d1f4ec6b14
|
/checkOut.cpp
|
01d3f00d537d0cb67250ef5ca870344842af7e18
|
[] |
no_license
|
AiSuna-Izumi/Mini-Project
|
7eec5d927ed92f42633380c1b3b60f1d98a694b8
|
23309db6828854ca202263bc366bfaf81ee7df6c
|
refs/heads/master
| 2022-06-20T16:14:04.044423
| 2020-05-01T14:48:36
| 2020-05-01T14:48:36
| 260,483,147
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,389
|
cpp
|
checkOut.cpp
|
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <ctime>
using namespace std;
//create the structure of the list
struct hotel{
int number;
string guestName;
string date;
string time;
string room;
int price;
string phone;
string ic;
hotel *next;
};
hotel *head;
int main()
{
hotel *newptr, *cur, *prev;
newptr= new hotel;
cur=head;
int choice,number,y;
string x;
ifstream checkOut; //declare showProduct
checkOut.open("totalPrice.txt",ios::out);
if (checkOut.is_open())
{
while(!checkOut.eof())
{
checkOut>>newptr->price;
checkOut>>newptr->number;
getline(checkOut,newptr->room);
getline(checkOut,x);
cout<<"price : "<<newptr->price<<endl;
cout<<"number :"<<newptr->number<<endl;
cout<<"room: "<<newptr->room<<endl<<endl;
if(head==NULL)
head = newptr;
else
{
cur = head;
while(cur != NULL){
prev = cur;
cur = cur->next;
}
prev->next = newptr;
}
}
cout<<"Enter Guest Number \n";
cin>>y;
while(cur != NULL && y != cur->number){
cur = cur->next;
}
if(cur == NULL)
cout<<"\nSorry the data is not found\n";
else
cout<<"\nYes, the data is found!\n";
}
else
cout<<"FILE NOT FOUND \n";
}
|
cf87bc4bd777d419efd8ccd5f9274ef0b26bfacb
|
81a41ec4979121564d3e7c9f0dc687adab460bde
|
/ToyMC/bin/simulate.cpp
|
53e1fbc327fce9d78dee034d204afbbc8e9d4d95
|
[] |
no_license
|
allenji/StoppedHSCP
|
01e37dc34b4c5f88b933164ebe5e8a2bf5561573
|
c49f18914c7fa36b59c9fbb046e6c8be4f3aa42d
|
refs/heads/master
| 2021-01-17T13:33:42.889485
| 2016-03-29T18:10:13
| 2016-03-29T18:10:13
| 35,041,646
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,335
|
cpp
|
simulate.cpp
|
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include "StoppedHSCP/ToyMC/interface/Simulator.h"
#include "StoppedHSCP/ToyMC/interface/Experiment.h"
int main(int argc, char* argv[]) {
if (argc < 2) {
std::cout << "Insufficient arguments" << std::endl;
std::cout << "Usage : simulate <params file>" << std::endl;
exit(1);
}
// arguments
std::string paramfile = std::string(argv[1]);
Experiment* e;
// read parameters from file and create experiment object
e = new Experiment(paramfile);
std::cout << "Simulation parameters" << std::endl;
std::cout << "From file : " << paramfile << std::endl;
std::cout << *e << std::endl;
// setup tree to write out
TFile f("outfile.root", "RECREATE");
TTree *tree = new TTree("T", "Experiments from the Stopped Particle MC");
tree->Branch("Experiment", "Experiment", &e);
// fills file
std::ofstream fillsfile;
fillsfile.open("fills.txt");
// setup simulation
Simulator sim;
// set parameters
sim.setParameters(e);
// set observed events
sim.setupObservedEvents();
// set up luminosity data
sim.setupLumi(false, false, true, e->lumiFile);
// set up lifetime mask
sim.setupLifetimeMask();
// sim.getLhcFills().print(std::cout);
// loop over fills
for (unsigned f=0; f!=e->fills.size(); ++f) {
unsigned fill = e->fills.at(f);
std::cout << "Simulating fill " << fill << std::endl;
std::cout << "With filling scheme " << sim.getLhcFills().getFillingScheme(fill) << std::endl;
sim.reset();
//sim.printMaskInfo(fill);
// expected background
sim.calculateExpectedBG(fill, fill);
// get observed events
sim.calculateObservedEvents(fill, fill);
// run MC
sim.simulateSignal(fill, fill);
// write fills file
fillsfile << fill << "\t" << sim.getEffLumi() << "\t" << sim.getNObs() << "\t" << sim.getNExp() << "\t" << sim.getNExpErr() << std::endl;
std::cout << std::endl;
}
// calculate limit
sim.calculateLimit();
std::cout << std::endl;
// write results summary
std::ofstream summaryfile;
summaryfile.open("summary.txt", std::ios::app);
e->summary(summaryfile);
summaryfile.close();
std::cout << *e << std::endl;
tree->Fill();
f.cd();
tree->Write();
fillsfile.close();
return 0;
}
|
f0b903bcc4aa96c0fc8c47839f643dea42991aab
|
62d48af115ea9d14bc5a7dd85212e616a48dcac6
|
/src/communication/headers/SimpleSendObjectRequest.cc
|
5b3a7fbd727b3ecfeeb6df15c21756ecae690b3a
|
[
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause"
] |
permissive
|
asu-cactus/lachesis
|
ab1ab1704e4f0f2d6aef1a2bff2dc99ea8f09337
|
92efa7b124a23894485a900bb394670487051948
|
refs/heads/master
| 2023-03-05T11:41:35.016673
| 2021-02-14T21:50:32
| 2021-02-14T21:50:32
| 151,744,205
| 2
| 0
|
Apache-2.0
| 2021-02-14T16:37:54
| 2018-10-05T15:49:15
|
C++
|
UTF-8
|
C++
| false
| false
| 4,038
|
cc
|
SimpleSendObjectRequest.cc
|
#ifndef SIMPLE_SEND_OBJECT_REQUEST_CC
#define SIMPLE_SEND_OBJECT_REQUEST_CC
#include "InterfaceFunctions.h"
#include "UseTemporaryAllocationBlock.h"
#ifndef MAX_RETRIES
#define MAX_RETRIES 5
#endif
#ifndef HEADER_SIZE
#define HEADER_SIZE 20
#endif
namespace pdb {
template <class RequestType,
class DataType,
class ResponseType,
class ReturnType,
class... RequestTypeParams>
ReturnType simpleSendObjectRequest(PDBLoggerPtr myLogger,
int port,
std::string address,
ReturnType onErr,
size_t bytesForRequest,
function<ReturnType(Handle<ResponseType>)> processResponse,
DataType dataToSend,
RequestTypeParams&&... args) {
int retries = 0;
while (retries <= MAX_RETRIES) {
PDBCommunicator temp;
string errMsg;
bool success;
if (temp.connectToInternetServer(myLogger, port, address, errMsg)) {
myLogger->error(errMsg);
myLogger->error("simpleSendDataRequest: not able to connect to server.\n");
std::cout << "ERROR: can't connect to remote server with port =" << port
<< " and address =" << address << std::endl;
return onErr;
}
// build the request
if (bytesForRequest < HEADER_SIZE) {
std::cout << "ERROR: block size is too small" << std::endl;
return onErr;
}
const UseTemporaryAllocationBlock tempBlock{bytesForRequest};
Handle<RequestType> request = makeObject<RequestType>(args...);
if (!temp.sendObject(request, errMsg)) {
myLogger->error(errMsg);
myLogger->error("simpleSendDataRequest: not able to send request to server.\n");
if (retries < MAX_RETRIES) {
retries++;
continue;
} else {
return onErr;
}
}
// now, send the data
if (!temp.sendObject(dataToSend, errMsg)) {
myLogger->error(errMsg);
myLogger->error("simpleSendDataRequest: not able to send data to server.\n");
if (retries < MAX_RETRIES) {
retries++;
continue;
} else {
return onErr;
}
}
// get the response and process it
size_t objectSize = temp.getSizeOfNextObject();
if (objectSize == 0) {
myLogger->error("simpleRequest: not able to get next object size");
std::cout << "simpleRequest: not able to get next object size" << std::endl;
if (retries < MAX_RETRIES) {
retries++;
continue;
} else {
return onErr;
}
}
void* memory = malloc(objectSize);
if (memory == nullptr) {
myLogger->error(std::string("FATAL ERROR: not able to allocate memory with size=") +
std::to_string(objectSize));
std::cout << "FATAL ERROR: not able to allocate memory" << std::endl;
exit(-1);
}
ReturnType finalResult;
{
Handle<ResponseType> result = temp.getNextObject<ResponseType>(memory, success, errMsg);
if (!success) {
myLogger->error(errMsg);
myLogger->error("simpleRequest: not able to get next object over the wire.\n");
// JiaNote: we need free memory here!!!
free(memory);
if (retries < MAX_RETRIES) {
retries++;
continue;
} else {
return onErr;
}
}
finalResult = processResponse(result);
}
free(memory);
return finalResult;
}
return onErr;
}
}
#endif
|
f8843796e0b24889faab617dade5183748f5fb1b
|
b955ab4d264001ac744831e98819fc1799d5c976
|
/book/3_exercise.cpp
|
47cffb1cc485270a1d1a75be1174a94769cad011
|
[] |
no_license
|
kdzmcqn/coding_studies
|
4d9a84b9b94c87f45e84885c5dddcdbd5eee7f85
|
69a18909e7e532b0f89ac7d4f1551b099146eedf
|
refs/heads/master
| 2022-12-27T09:01:45.867336
| 2020-10-08T06:33:20
| 2020-10-08T06:33:20
| 299,523,494
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,001
|
cpp
|
3_exercise.cpp
|
#include "std_lib_facilities.h"
int main()
{
cout << "Please enter a floating-point value: ";
double n;
cin >> n;
cout << "n == " << n
<< "\nn + 1 == " << n + 1
<< "\nthree times n == " << 3 * n
<< "\ntwice n == " << n + n
<< "\nn squared == " << n * n
<< "\nn half of n == " << n / 2
<< "\nsquare root of n == " << sqrt(n)
<< '\n';
cout << "Please enter your first and second names\n";
string first;
string second;
cin >> first >> second;
string name = first + ' ' + second;
cout << "Hello, " << name << '\n';
cout << "To read and compare names\n enter two names\n";
string name1;
string name2;
cin >> name1 >> name2;
if (name1 == name2)
cout << "that's the same name twice\n";
if (name1 < name1)
cout << name1 << " is alphabetically before " << name2 << '\n';
if (name1 > name2)
cout << name1 << " is alphabetically after " << name2 << '\n';
}
|
9405ee93c48b1a5f596f1a39b5773cb3b0e4be65
|
e1c2c0d23f25256c1b913c7be0c19fe0ec3ffd61
|
/potionstructure.h
|
6ded41401d1d81fda72ab0a6dab6bf38fd2666c9
|
[] |
no_license
|
mbottini/lab2
|
468432da9a0f5b676af45426c45ff81c2299e79e
|
430e03bfb44851b39bbce107f2526f860605b79d
|
refs/heads/master
| 2020-12-24T15:22:48.206037
| 2015-07-19T19:31:31
| 2015-07-19T19:31:31
| 38,906,132
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 781
|
h
|
potionstructure.h
|
// potionstructure.h
// Michael Bottini
// Created for CS 260
// Header file for potion structure base class.
#ifndef POTIONSTRUCTURE_H
#define POTIONSTRUCTURE_H
#include "potion.h"
#include <iostream>
class PotionStructure {
private:
PotionNode *_first;
PotionNode *_last;
int _size;
public:
PotionStructure();
void chainDelete();
~PotionStructure();
PotionStructure(const PotionStructure& OriginalStructure);
PotionStructure& operator =(const PotionStructure& originalStructure);
PotionNode* getFront() const;
PotionNode* getBack() const;
void enqueue(const Potion& newPotion);
void pushFront(const Potion& newPotion);
Potion popFront();
void printAll();
int getSize();
bool operator ==(const PotionStructure& otherStructure) const;
};
#endif
|
afe06e64e989e96490d9fb722d5f19ff3ecfac1b
|
f2ee87ad057c80ed04fbfadf287f293aff1e3c5f
|
/Intersection/Bmpfile.cpp
|
7eeb442aafea4143bf5e074ad180059739569544
|
[
"MIT"
] |
permissive
|
SylvainRajkoumar/ray-tracing
|
a8094701bfa229733458f16a53c580c233d56159
|
0c563fac1b167e21120f7f23fecaedc818d8c71a
|
refs/heads/master
| 2020-04-19T00:59:30.592652
| 2019-01-28T21:11:17
| 2019-01-28T21:11:17
| 167,861,168
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,616
|
cpp
|
Bmpfile.cpp
|
#include "Bmpfile.h"
#include <cstdio>
void BMPFile::SaveBmp(std::string fileName,unsigned char *img,unsigned int w,unsigned int h)
{
int filesize = 54 + 3*w*h; //w is your image width, h is image height, both int
unsigned char bmpfileheader[14] = {'B','M', 0,0,0,0, 0,0, 0,0, 54,0,0,0};
unsigned char bmpinfoheader[40] = {40,0,0,0, 0,0,0,0, 0,0,0,0, 1,0, 24,0};
unsigned char bmppad[3] = {0,0,0};
bmpfileheader[ 2] = (unsigned char)(filesize );
bmpfileheader[ 3] = (unsigned char)(filesize>> 8);
bmpfileheader[ 4] = (unsigned char)(filesize>>16);
bmpfileheader[ 5] = (unsigned char)(filesize>>24);
bmpinfoheader[ 4] = (unsigned char)( w );
bmpinfoheader[ 5] = (unsigned char)( w>> 8);
bmpinfoheader[ 6] = (unsigned char)( w>>16);
bmpinfoheader[ 7] = (unsigned char)( w>>24);
bmpinfoheader[ 8] = (unsigned char)( h );
bmpinfoheader[ 9] = (unsigned char)( h>> 8);
bmpinfoheader[10] = (unsigned char)( h>>16);
bmpinfoheader[11] = (unsigned char)( h>>24);
/*
#ifndef fopen_s
FILE *f = fopen(fileName.c_str(),"wb");
fwrite(bmpfileheader,1,14,f);
fwrite(bmpinfoheader,1,40,f);
for(unsigned int i=0; i<h; i++)
{
fwrite(img+(w*(h-i-1)*3),3,w,f);
fwrite(bmppad,1,(4-(w*3)%4)%4,f);
}
fclose(f);
#endif*/
#ifndef fopen_s
FILE *f;
errno_t err;
if ((err = fopen_s(&f, fileName.c_str(), "wb")) == 0) {
fwrite(bmpfileheader, 1, 14, f);
fwrite(bmpinfoheader, 1, 40, f);
for (unsigned int i = 0; i<h; i++)
{
fwrite(img + (w*(h - i - 1) * 3), 3, w, f);
fwrite(bmppad, 1, (4 - (w * 3) % 4) % 4, f);
}
fclose(f);
}
#endif
}
// http://stackoverflow.com/questions/14279242/read-bitmap-file-into-structure
/*unsigned char *BMPFile::LoadBitmapFile(std::string filename, BITMAPINFOHEADER *bitmapInfoHeader)
{
FILE *filePtr; //our file pointer
BITMAPFILEHEADER bitmapFileHeader; //our bitmap file header
unsigned char *bitmapImage; //store image data
unsigned int imageIdx=0; //image index counter
unsigned char tempRGB; //our swap variable
//open filename in read binary mode
filePtr = fopen(filename.c_str(),"rb");
if (filePtr == NULL)
return NULL;
//read the bitmap file header
fread(&bitmapFileHeader, sizeof(BITMAPFILEHEADER),1,filePtr);
//verify that this is a bmp file by check bitmap id
if (bitmapFileHeader.bfType !=0x4D42)
{
fclose(filePtr);
return NULL;
}
//read the bitmap info header
fread(bitmapInfoHeader, sizeof(BITMAPINFOHEADER),1,filePtr); // small edit. forgot to add the closing bracket at sizeof
//move file point to the begging of bitmap data
fseek(filePtr, bitmapFileHeader.bOffBits, SEEK_SET);
//allocate enough memory for the bitmap image data
bitmapImage = (unsigned char*)malloc(bitmapInfoHeader->biSizeImage);
//verify memory allocation
if (!bitmapImage)
{
free(bitmapImage);
fclose(filePtr);
return NULL;
}
//read in the bitmap image data
fread(bitmapImage,1,bitmapInfoHeader->biSizeImage,filePtr);
//make sure bitmap image data was read
if (bitmapImage == NULL)
{
fclose(filePtr);
return NULL;
}
//swap the r and b values to get RGB (bitmap is BGR)
for (imageIdx = 0;imageIdx < bitmapInfoHeader->biSizeImage;imageIdx+=3) // fixed semicolon
{
tempRGB = bitmapImage[imageIdx];
bitmapImage[imageIdx] = bitmapImage[imageIdx + 2];
bitmapImage[imageIdx + 2] = tempRGB;
}
//close file and return bitmap iamge data
fclose(filePtr);
return bitmapImage;
}*/
|
e0ca58791475693843854facc7c3fe1724a83b7b
|
4c6574534cc8dd7f582ee98603116b46ab608160
|
/PhaseJump/PhaseJump/Classes/Render/RenderModel.h
|
b248bb3ab3790af9082050615a9c78fe79647321
|
[
"MIT"
] |
permissive
|
coinbump/PhaseJumpPro
|
01b1805aac4a8dd0a17feb3ae9a06d76fbf63926
|
52f806cc7db9ef134a5e1786347c350cb8e2e4c3
|
refs/heads/main
| 2023-06-27T13:30:37.192977
| 2023-06-18T03:25:38
| 2023-06-18T03:25:38
| 127,684,651
| 50
| 5
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,510
|
h
|
RenderModel.h
|
#ifndef PJRENDERMODEL_H
#define PJRENDERMODEL_H
#include "VectorList.h"
#include "Color.h"
#include "RenderMaterial.h"
#include "Vector3.h"
#include "Matrix4x4.h"
#include "SomeTexture.h"
#include "_Set.h"
#include "_Map.h"
/*
RATING: 4 stars
Simple type. Needs more features
CODE REVIEW: 4/17/23
*/
namespace PJ {
class SomeShaderProgram;
/// Sent to the render engine which then interprets it, does any
/// necessary batching or caching, and then performs the render
struct RenderModel {
/// Vertices to render (sent to vertex shader `a_position` attribute)
VectorList<Vector3> vertices;
VectorList<Color> colors;
/// Used by IBO to determine vertex offsets
VectorList<uint32_t> indices;
/// Texture position for vertex (Range: 0-1.0)
VectorList<Vector2> uvs;
VectorList<SP<SomeTexture>> textures;
VectorList<Color> uniformColors;
VectorList<float> uniformFloats;
SomeShaderProgram& shaderProgram;
Map<String, RenderFeatureStatus> features;
/// Use to sort blended objects back-to-front
float z = 0;
bool IsFeatureEnabled(String feature) const {
auto i = features.find(feature);
if (i == features.end()) { return false; }
return i->second == RenderFeatureStatus::Enable;
}
Matrix4x4 matrix;
RenderModel(SomeShaderProgram& shaderProgram) : shaderProgram(shaderProgram) {
}
};
}
#endif
|
d9a9d28e5956107e44a253911b26de081f17e5bc
|
bee740fe778f9cf0404a483dfc135a91234e4865
|
/ide/plugins/interpreter/external-system-template/src/ExternalSystem.hpp
|
8fa007752f55700d650357455fb4993f5093059d
|
[] |
no_license
|
ibrahimshiyam/SymphonyIDE
|
a1c6bb08f1f538ceeadd7ea474b65f5f5478d529
|
9b3d13160782c848c9f3a3193596c34c50148fdb
|
refs/heads/master
| 2021-01-10T01:00:46.078501
| 2014-09-29T12:47:37
| 2014-09-29T12:47:37
| 25,225,245
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,321
|
hpp
|
ExternalSystem.hpp
|
#ifndef EXTERNAL_SYSTEM_HPP
#define EXTERNAL_SYSTEM_HPP
#include <iostream>
#include <CoSimulationTransportLayer.hpp>
#include <CoSimulationFramework.hpp>
namespace ExternalSystem
{
template <typename S, typename D>
void LOG(S& stream, const D& data)
{
stream << data << std::endl;
}
//callback class, will be called by the cosim framework
class ExternalSystemBasicImpl : public CoSimulationFramework::ACoSimulationCallback<>
{
public:
CoSimulationTransportLayer::IChannelEventObject::ChannelEventObjectSet inspect()
{
LOG(std::cout, "ExternalSystemBasicImpl::inspect()");
CoSimulationTransportLayer::IChannelEventObject::ChannelEventObjectSet eventOptions;
return eventOptions;
}
void execute(CoSimulationTransportLayer::IChannelEventObject::ChannelEventObjectSmartPtr evt)
{
LOG(std::cout, "ExternalSystemBasicImpl::execute()");
}
bool finished()const
{
LOG(std::cout, "ExternalSystemBasicImpl::finished()");
return false;
}
void init()
{
LOG(std::cout, "ExternalSystemBasicImpl::init()");
}
void deInit()
{
LOG(std::cout, "ExternalSystemBasicImpl::deInit()");
}
};
// create frontend object by using as typedef
typedef CoSimulationFramework::ACoSimulationModel<ExternalSystemBasicImpl> ExternalSystemBasicImplCoSimulationModel;
}
#endif
|
00790124a056d971c4e9d0b52c6a6e7a877bfcde
|
b4f847577ef5e1784d3e0794e136e155f5d08949
|
/src/Project.cpp
|
ee6e04e9aa9166478afc36e16bb85967427c40ad
|
[] |
no_license
|
atduskgreg/Brat-Pack
|
f2fb8f21a8d5d9fd5fbccbecbe54641c4abb5c84
|
c7c6e2c8751a9962b335c6a15c1af0886874e107
|
refs/heads/master
| 2020-06-01T13:50:03.976013
| 2011-04-17T17:49:42
| 2011-04-17T17:49:42
| 1,482,872
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,294
|
cpp
|
Project.cpp
|
#include "Project.h"
Project::Project()
{
font.loadFont("Helvetica LT.ttf", 12);
startPressed = false;
stopPressed = false;
pos.x = 0;
pos.y = 0;
running = false;
start = new CustomButton("startserver.png");
stop = new CustomButton("stopserver.png");
}
void Project::update()
{
start->update();
stop->update();
}
void Project::draw()
{
ofSetColor(0, 0, 0);
ofFill();
font.drawString(name, pos.x, pos.y);
//ofDrawBitmapString(name, pos.x, pos.y);
ofSetColor(255, 255, 255);
ofEnableAlphaBlending();
if(running)
{
stop->draw();
if(stop->isMousePressed())
{
running = false;
cout << "Stop server \n";
string command = ofToDataPath("ruby/apps/" + name, true);
string result = Tools::getEscapedPath(command) + " -k";
system(result.c_str());
}
}
else
{
start->draw();
if(start->isMousePressed())
{
running = true;
cout << "Start server \n";
string command = ofToDataPath("ruby/apps/" + name, true);
string result = Tools::getEscapedPath(command);
system(result.c_str());
}
}
ofDisableAlphaBlending();
}
void Project::setPos(int newX, int newY)
{
pos.x = newX;
pos.y = newY;
start->setPos(pos.x + 200, pos.y - 15);
stop->setPos(pos.x + 335, pos.y - 15);
}
string Project::getURL()
{
}
|
6f92688dd4574a9410b0a8aad92015ccba4d8730
|
b25a8c57cade3b090b8b4eb2026b3b57db0f5cc1
|
/src/audio/Listener.cpp
|
24e06895eede40fffa18c63a331f9459d7e75488
|
[] |
no_license
|
jacopocav/Maze
|
dd750bdb894f65938c560669171cb4f6eb5fa3ed
|
fcd5bcf6ed5069f6f21252fc051cac4b6347bf51
|
refs/heads/master
| 2021-05-04T09:30:18.840774
| 2016-10-11T10:32:56
| 2016-10-11T10:32:56
| 59,230,854
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 346
|
cpp
|
Listener.cpp
|
#include <AL/al.h>
#include "Listener.h"
void audio::Listener::setOrientation(float atx, float aty, float atz, float upx, float upy, float upz) {
float ori[6] = {atx, aty, atz, upx, upy, upz};
alListenerfv(AL_ORIENTATION, ori);
}
void audio::Listener::setPosition(float x, float y, float z) {
alListener3f(AL_POSITION, x, y, z);
}
|
cba548610dcc240cfb15718d36ecf8228e8fb9e2
|
50a0185de28f3d92594509009e271341803e934a
|
/lab1_binarization/bw/filter.cpp
|
676723637659ec4e616192ae7c481250ef6f4dcd
|
[] |
no_license
|
kr3r/ImageProcessing
|
61cdc8795d20db7c1f0cf594dd8ddd0dd78c32a5
|
1aef2cf3edbc3635ad4c47806d65d84ac094589c
|
refs/heads/master
| 2022-11-07T21:47:27.405242
| 2017-05-24T16:09:31
| 2017-05-24T16:09:31
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 261
|
cpp
|
filter.cpp
|
//
// filter.cpp
// bw
//
// Created by Кирилл Рябинин on 03.03.17.
// Copyright © 2017 Кирилл Рябинин. All rights reserved.
//
#include <opencv2/opencv.hpp>
#include <stdio.h>
using namespace cv;
Mat filter(Mat& img) {
}
|
a429c30d8f7355390c7145544f3cc0639433de51
|
c0f2b22ca32bbfa864ff965e1339f3656a2746df
|
/include/io/multistream.h
|
2ea67fe1d93694846d090a192475e26d73445e90
|
[
"Apache-2.0"
] |
permissive
|
StanfordPL/cpputil
|
2199e76b532e7eaa6b963b5dad609bedf58b80eb
|
f44bf5ff224536553105c912638dc34e14f05123
|
refs/heads/develop
| 2021-01-17T10:21:14.348417
| 2018-11-04T16:50:07
| 2018-11-04T16:50:07
| 2,747,319
| 15
| 5
| null | 2016-11-27T18:06:49
| 2011-11-10T08:25:03
|
C++
|
UTF-8
|
C++
| false
| false
| 1,593
|
h
|
multistream.h
|
// Copyright 2014 eric schkufza
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CPPUTIL_INCLUDE_IO_MULTISTREAM_H
#define CPPUTIL_INCLUDE_IO_MULTISTREAM_H
#include <iostream>
#include <streambuf>
#include "include/io/multibuf.h"
namespace cpputil {
template <typename Ch, typename Tr>
class basic_omultistream : public std::basic_ostream<Ch, Tr> {
public:
explicit basic_omultistream()
: std::basic_ostream<Ch, Tr>(&buf_), buf_() { }
explicit basic_omultistream(std::basic_ostream<Ch, Tr>& os)
: std::basic_ostream<Ch, Tr>(&buf_), buf_(os.rdbuf()) { }
explicit basic_omultistream(std::basic_streambuf<Ch, Tr>& sb)
: std::basic_ostream<Ch, Tr>(&buf_), buf_(sb) { }
virtual ~basic_omultistream() { }
void insert(std::basic_ostream<Ch, Tr>& os) {
buf_.insert(os.rdbuf());
}
void clear() {
buf_.clear();
}
private:
basic_multibuf<Ch, Tr> buf_;
};
typedef basic_omultistream<char, std::char_traits<char>> omultistream;
typedef basic_omultistream<wchar_t, std::char_traits<wchar_t>> womultistream;
} // namespace cpputil
#endif
|
90377257b0d346d076fa64d6e90f30317a49eacc
|
a6561d0a1886fedf3a23d74ba2a64e427a64697d
|
/bi-protocols/software-tagging-brain-invaders/boxes/ovpCBoxStimulationTransformer.h
|
fe4d97ce35f29ffaf1abc67891aa00f91c5f95bd
|
[] |
no_license
|
Daeda88/BrainInvaders
|
f799bb464fc57cbab74fc4ce6178b85ae3e24b8c
|
fd321eec5c7a122d3cdf71fd73e7b6276842220b
|
refs/heads/master
| 2021-01-10T17:39:04.337416
| 2015-05-25T12:54:15
| 2015-05-25T12:54:15
| 36,230,839
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,100
|
h
|
ovpCBoxStimulationTransformer.h
|
#ifndef __OpenViBEPlugins_BoxAlgorithm_StimulationTransformer_H__
#define __OpenViBEPlugins_BoxAlgorithm_StimulationTransformer_H__
#include "../ovp_defines.h"
#include <openvibe/ov_all.h>
#include <openvibe-toolkit/ovtk_all.h>
#include <iostream>
#include <deque>
#include <vector>
#include <fstream>
#include <string>
#include <boost/algorithm/string.hpp>
#include <sstream>
#include <exception>
#define OVP_ClassId_BoxStimulationTransformer OpenViBE::CIdentifier(0x2E0D2C8D, 0x1DA84D36)
#define OVP_ClassId_BoxStimulationTransformerDesc OpenViBE::CIdentifier(0x1BD92639, 0x39B5671A)
namespace OpenViBEPlugins
{
namespace SignalProcessing
{
/*
Converts stimulations from one to another (changes stimulation code) and redirects to specific output channel
*/
class CBoxStimulationTransformer : public OpenViBEToolkit::TBoxAlgorithm < OpenViBE::Plugins::IBoxAlgorithm >
{
public:
virtual void release(void) { delete this; }
virtual OpenViBE::boolean initialize(void);
virtual OpenViBE::boolean uninitialize(void);
virtual OpenViBE::boolean processInput(OpenViBE::uint32 ui32InputIndex);
virtual OpenViBE::boolean process(void);
_IsDerivedFromClass_Final_(OpenViBEToolkit::TBoxAlgorithm < OpenViBE::Plugins::IBoxAlgorithm >, OVP_ClassId_BoxStimulationTransformer);
struct ConversionEntry //maps incoming stimulations to output stimulations with the channel requested
{
OpenViBE::uint64 InputStimulation;
OpenViBE::uint64 OutputStimulation;
OpenViBE::uint32 OutputChannel;
ConversionEntry(OpenViBE::uint64 pInputStimulation,OpenViBE::uint64 pOutputStimulation,OpenViBE::uint32 pOutputChannel) : InputStimulation(pInputStimulation), OutputStimulation(pOutputStimulation), OutputChannel(pOutputChannel)
{
}
};
std::vector < ConversionEntry > m_vConversionEntries;
protected:
//stimulation input 1
OpenViBE::Kernel::IAlgorithmProxy* m_pStimulationDecoderTrigger;
OpenViBE::Kernel::TParameterHandler <const OpenViBE::IMemoryBuffer* > ip_pMemoryBufferToDecodeTrigger;
OpenViBE::Kernel::TParameterHandler < OpenViBE::IStimulationSet* > op_pStimulationSetTrigger;
//Stimulation 1
OpenViBE::Kernel::IAlgorithmProxy* m_pStimulationEncoder1;
OpenViBE::Kernel::TParameterHandler < OpenViBE::IStimulationSet* > ip_pStimulationsToEncode1;
OpenViBE::Kernel::TParameterHandler < OpenViBE::IMemoryBuffer* > op_pEncodedMemoryBuffer1;
//Stimulation 2
OpenViBE::Kernel::IAlgorithmProxy* m_pStimulationEncoder2;
OpenViBE::Kernel::TParameterHandler < OpenViBE::IStimulationSet* > ip_pStimulationsToEncode2;
OpenViBE::Kernel::TParameterHandler < OpenViBE::IMemoryBuffer* > op_pEncodedMemoryBuffer2;
OpenViBE::CString m_sConversionListFileLocation;
//Example file:
//0x00008100,0x00008101,1
//0x0000810A,0x00008102,2
//0x0000810B,0x00008103,1
OpenViBE::boolean CBoxStimulationTransformer::ReadConversionList();
};
class CBoxStimulationTransformerDesc : public OpenViBE::Plugins::IBoxAlgorithmDesc
{
public:
virtual void release(void) { }
virtual OpenViBE::CString getName(void) const { return OpenViBE::CString("Stimulation Transformer"); }
virtual OpenViBE::CString getAuthorName(void) const { return OpenViBE::CString("Anton Andreev"); }
virtual OpenViBE::CString getAuthorCompanyName(void) const { return OpenViBE::CString("GIPSA-Lab"); }
virtual OpenViBE::CString getShortDescription(void) const { return OpenViBE::CString("Replaces stimulations and/or redirects them."); }
virtual OpenViBE::CString getDetailedDescription(void) const { return OpenViBE::CString("Enables you to replace one stimulation with another one (from a list) and to redirect stimulations to another channel."); }
virtual OpenViBE::CString getCategory(void) const { return OpenViBE::CString("Signal processing/Basic"); }
virtual OpenViBE::CString getVersion(void) const { return OpenViBE::CString("1.0"); }
virtual OpenViBE::CString getStockItemName(void) const { return OpenViBE::CString("gtk-jump-to"); }
virtual OpenViBE::CIdentifier getCreatedClass(void) const { return OVP_ClassId_BoxStimulationTransformer; }
virtual OpenViBE::Plugins::IPluginObject* create(void) { return new OpenViBEPlugins::SignalProcessing::CBoxStimulationTransformer; }
virtual OpenViBE::boolean getBoxPrototype(
OpenViBE::Kernel::IBoxProto& rBoxAlgorithmPrototype) const
{
rBoxAlgorithmPrototype.addInput ("Input stimulation channel", OV_TypeId_Stimulations);
rBoxAlgorithmPrototype.addOutput ("Output stimulations 1", OV_TypeId_Stimulations);
rBoxAlgorithmPrototype.addOutput ("Output stimulations 2", OV_TypeId_Stimulations);
rBoxAlgorithmPrototype.addSetting("Transformation file list location:",OV_TypeId_Filename,"");
return true;
}
_IsDerivedFromClass_Final_(OpenViBE::Plugins::IBoxAlgorithmDesc, OVP_ClassId_BoxStimulationTransformerDesc);
};
};
};
#endif // __OpenViBEPlugins_BoxAlgorithm_StimulationTransformer_H__
|
aa3d65945555a8091ed00755b1494fb54c920163
|
41228f46efca8cfaf8ce4ccbf743680d73012ce0
|
/test/operator_spacing_good.cpp
|
91b28b2c27e247c27d316804585230c88af3b31d
|
[] |
no_license
|
willwolfram18/183lint
|
3951454d44b756d7ff66ad92cce4d487375a917a
|
b841db77d5229f79f0f5974009cec9268d2c93b5
|
refs/heads/master
| 2021-05-31T00:32:04.679067
| 2015-11-02T07:27:06
| 2015-11-02T07:27:06
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 725
|
cpp
|
operator_spacing_good.cpp
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int x = 0;
x = 2;
// check compound operators
x += 1;
x -= 1;
x *= 1;
x /= 1;
x %= 2;
x &= 1;
x |= 0;
x != 1;
x == 1;
x == false;
x >= 2;
x <= 2;
x && false;
x || true;
// increment/decrement operators
x++;
x--;
++x;
--x;
// normal operators
x + 1;
x - 1;
x * 2;
x / 1;
x % 2;
x > 1;
x < 1;
x = 1;
!x;
-x;
+x;
// Multiple operators on one line
x + 1 - 1;
x + -1;
x += x - 1;
x && true == x || false;
cout << "hello world"
<< endl << x;
cin >> x >> x;
return 0;
}
|
44269f3bc9a7a1ec0351bf899b3226c28f3f6c01
|
0124333581ebbd1ce79ed72d9a4bfcf834f9b8d8
|
/189-RotateArray.cpp
|
304c99180bf8d3f527f9cbaf0a4c1462cc416f01
|
[] |
no_license
|
dufuhang/LeetCode
|
48624e0bfee057dab756af3d429693c6d5672453
|
4306619cf133b292c465aa75245a836fad7ec1a9
|
refs/heads/master
| 2021-08-22T10:32:36.086335
| 2020-03-28T11:03:28
| 2020-03-28T11:03:28
| 147,092,349
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 414
|
cpp
|
189-RotateArray.cpp
|
class Solution
{
public:
void rotate(vector<int>& nums, int k)
{
//k为几,就进行几轮轮换:[1,2,3],k=5 => [2,3,1]
//不要误认为k为从数组末往前数几个元素进行轮换
k %= nums.size();
vector<int> vec(nums.end() - k, nums.end());
nums.erase(nums.end() - k, nums.end());
nums.insert(nums.begin(), vec.begin(), vec.end());
}
};
|
fea348506391fd4031ae246c94e94066e1ed5716
|
269e4554569f5b6cbba877102f6b5b21e721a46f
|
/level B/B. Sum of Digits/main.cpp
|
778f87f75ae343c6a94081c9acaddde9ad8b4921
|
[] |
no_license
|
KhaledAbdelgalil/sheet-mostafa-saad-problem-solving-
|
f1b289a8115579417b8f075ca4f792768e0c7e5d
|
4e2a72caeb3b3752b7170723a7190b1745d2f5e2
|
refs/heads/master
| 2022-04-02T08:48:52.967835
| 2020-02-01T03:47:27
| 2020-02-01T03:47:27
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 572
|
cpp
|
main.cpp
|
#include <bits/stdc++.h>
using namespace std;
long long s=0;
string in;
int main()
{
cin>>in;
if(in.size()==1){cout<<0;return 0;}
long long out=0;
for(long long i=0;i<in.size();i++)
{
s+=int(in[i])-48;
}
if(s/10==0){cout<<1; return 0;}
//cout<<s;
out++;
long long s2=0;
while(1)
{
s2+=s%10;
s/=10;
if(s==0)
{
out++;
s=s2;
s2=0;
if(s/10==0) break;
}
}
cout<<out;
}
|
d37477ef237d15c1e0da44d00fd4817eafcf5ea2
|
8e388a3f334c60fbc6427020738e867c113940a4
|
/DL_A10_c5_p8.cpp
|
e37b5eec2de951dbb743ea68dcce69ee1c03d62b
|
[] |
no_license
|
Danloza/C-class
|
4a94ef9f20b6cc864eec9e124cba23568a73c104
|
310b837635956b49cde51c0ac050cc9f7868571f
|
refs/heads/master
| 2021-06-29T14:32:27.127420
| 2017-09-20T07:30:10
| 2017-09-20T07:30:10
| 104,181,294
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,330
|
cpp
|
DL_A10_c5_p8.cpp
|
// Your Name: Daniel Loza
// Date:3/7/17
// Class C++, engr 1540
// Assignment Name Assignment 10
//Problem Pennies for Pay
// =========================================
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main()
{
//input days worked
double dayPay = 0.5, totalPay, days, loopCounter =0;
cout << "This program will calculate the monthly earnings of an employee." << endl;
cout << "How many days did this person work?" << endl ;
cin >> days;
//validates input as valid
while (days < 1 || days > 31)
{
cout << "You entered an invalid value. Days worked must be between 1 and 31." << endl;
cout << "How many days did this person work?" << endl ;
cin >> days;
}
//output header
cout << "Day" << setw(25) << "Dollars earned" << endl;
cout << "-------------------------------------" << endl;
//calculate daily pay and running total.
loopCounter = 1;
while (loopCounter < (days +1))
{
dayPay *= 2;
cout << setw(4) << loopCounter << setw(20) << "$"<< (dayPay * 0.01) << endl;
totalPay = totalPay + dayPay;
loopCounter++;
}
cout << "The total earnings for this month are $" << totalPay*0.01 << endl;
return 0;
}
|
ce9661916d5dbdddd1b196d791ea348f6510d895
|
bea698595acf98c96089a202c3606090c5bfeab2
|
/Server/Core/Debug/DLSources/AMMO/AMMO-2/Ammo2.h
|
f68ae61addb60590db473da89e2c775939968c32
|
[] |
no_license
|
ekersale/RType
|
1b904a1094820c150134d1152308c5874ec40d1a
|
1ce77e9eb69efeeeebf83a3d049cc96ab5ce804f
|
refs/heads/master
| 2020-12-25T10:34:32.068425
| 2016-08-01T13:05:57
| 2016-08-01T13:05:57
| 62,563,089
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 243
|
h
|
Ammo2.h
|
#ifndef AMMO2_H_
#define AMMO2_H_
#include "IAmmo.h"
class Ammo2 : public IAmmo
{
public:
Ammo2();
~Ammo2();
DRect calcPos(DRect);
e_type getType() const;
int getPower() const;
void setMovement(int);
private:
int _movement;
};
#endif
|
b166f0946c803ac913fb8910ab3543ea53634dfd
|
07fe910f4a2c7d14e67db40ab88a8c91d9406857
|
/game/mga/Object_Filter.h
|
c28f379e90736fbc96e7a11bd7ffbd6e4173431e
|
[] |
no_license
|
SEDS/GAME
|
e6d7f7a8bb034e421842007614d306b3a6321fde
|
3e4621298624b9189b5b6b43ff002306fde23f08
|
refs/heads/master
| 2021-03-12T23:27:39.115003
| 2015-09-22T15:05:33
| 2015-09-22T15:05:33
| 20,278,561
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,249
|
h
|
Object_Filter.h
|
// -*- C++ -*-
//=============================================================================
/**
* @file Filter.h
*
* $Id$
*
* @author James H. Hill
*/
//=============================================================================
#ifndef _GME_FILTER_H_
#define _GME_FILTER_H_
#include "Project.h"
namespace GAME
{
namespace Mga
{
/**
* @class Filter
*
* Help class for filter objects in a project. The main goal of the
* filter to the perform a recursive search based on where it starts,
* which can be the project, model, or folder.
*/
class GAME_MGA_Export Filter
{
public:
/**
* Initializing constructor.
*
* @param[in] project Owner of the filter.
*/
Filter (Project project);
/// Destructor.
~Filter (void);
/**
* Apply the filter. The elements that match the filter are
* returned in \a result. This perform a recursive search of the
* entire project.
*
* @param[in] result Number of elements in result.
*/
template <typename T>
size_t apply (std::vector <T> & result) const;
template <typename T>
Iterator <T> apply (void) const;
/**
* @overloaded
*
* Performs a recursive search starting at the specified model.
*/
template <typename T>
size_t apply (const Model_in & model, std::vector <T> & result) const;
template <typename T>
Iterator <T> apply (const Model_in & model) const;
/**
* @overloaded
*
* Performs a recursive search starting at the specified folder.
*/
template <typename T>
size_t apply (const Folder_in & folder, std::vector <T> & result) const;
template <typename T>
Iterator <T> apply (const Folder_in & folder) const;
/**
* Set the kind attribute for the filter.
*
* @param[in] name The kind value
*/
void kind (const std::string & value);
void kind (std::vector <std::string> & value);
void kind (std::vector <Meta::FCO> & fcos);
void name (const std::string & value);
void name (std::vector <std::string> & value);
private:
/// Reference to the project.
Project project_;
/// Pointer to the actual filter.
ATL::CComPtr <IMgaFilter> filter_;
};
}
}
#include "Object_Filter_T.cpp"
#endif // !defined _GME_FILTER_H_
|
268cf1edc91831f136013bbec1026e15f12eb813
|
fac2ca8a90115ccf3d1e0f4979c2f3cebf51deb3
|
/LargeNumber/Large_Number1.cpp
|
4ff5e5d86d6906d9a0df3c0a17016c0f02e4efa2
|
[] |
no_license
|
ITISStudy/CPP
|
da726cda5133096438abfbabd1524d88e5dc57cd
|
8879001a814124f30288101cc20ee826f8376080
|
refs/heads/master
| 2023-01-27T14:09:54.078066
| 2020-12-08T11:01:05
| 2020-12-08T11:01:05
| 311,673,770
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 782
|
cpp
|
Large_Number1.cpp
|
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string a,b;
int n,m;
void Nhap(){
cin>>a>>b;
n=a.length();
m=b.length();
}
void ins(string a,string b){
vector <int> c,d;
n=a.length();m=b.length();
for(int i=0;i<n;i++) d.push_back(a[i]-'0');
for(int i=0;i<n-m;i++) c.push_back(0);
for(int i=0;i<m;i++) c.push_back(b[i]-'0');
int nho=0;
for(int i=n-1;i>=0;i--){
d[i]-=nho;
if(d[i]<c[i]){
d[i]=d[i]+10-c[i];
nho=1;
}
else{
d[i]=d[i]-c[i];nho=0;
}
}
for(int j=0;j<d.size();j++) cout<<d[j];
cout<<endl;
}
void Res(){
if(n>m) ins(a,b);
else if(n<m) ins(b,a);
else{
if(a>b) ins(a,b);
else ins(b,a);
}
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int test;
cin>>test;
while(test--){
Nhap();
Res();
}
}
|
d7850cf807eede988239ac58a23c3557f1d2d98e
|
32fa0ff7c6f84f19afcd9f38db443367e0002389
|
/WJets/MergeVV_BVeto.cc
|
68d6536b0075157faa8740e2ae7685909c600770
|
[] |
no_license
|
ahortian/WJetsTreeAnalysis
|
6c8e253c5a806af60ece44e6b5add9af3baedc98
|
fb966bafd82817c52188d6f55e9bb2735ae78840
|
refs/heads/master
| 2021-01-19T07:53:34.812185
| 2017-11-13T21:39:48
| 2017-11-13T21:39:48
| 87,585,370
| 3
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,677
|
cc
|
MergeVV_BVeto.cc
|
// History
//---- 2015_05_17
// Also merge top and DY (and generate outputs) for the regions of QCD1,2,3.
#include <iostream>
#include <TH1.h>
#include <TH2.h>
#include <TFile.h>
#include <sstream>
#include <RooUnfoldResponse.h>
void runMergeVV_BVeto(string lepSelection = "DE", int systematics =0 , int jetPtCutMin = 30 , int doQCD = 0 );
void MergeVV_BVeto(){
runMergeVV_BVeto("SMu",0,30,0);
//runMergeTop_BVeto("SMu",0,30,1);
//runMergeTop_BVeto("SMu",0,30,2);
//runMergeTop_BVeto("SMu",0,30,3);
//runMergeTop("DE",0,20,0);
//runMergeTop("DE",1,20,0);
//runMergeTop("DE",-1,20,0);
//runMergeTop("DE",3,20,0);
//runMergeTop("DE",-3,20,0);
}
void runMergeVV_BVeto(string lepSelection, int systematics, int jetPtCutMin, int doQCD)
{
TH1::SetDefaultSumw2();
TH2::SetDefaultSumw2();
cout << __FILE__ << endl;
ostringstream strJetPtCutMin; strJetPtCutMin << jetPtCutMin;
ostringstream doQCDStr; doQCDStr << doQCD ;
string syst;
if (systematics == 0) syst = "Syst_0_";
else if (systematics == 1) syst = "Syst_1_Up_";
else if (systematics == -1) syst = "Syst_1_Down_";
else if (systematics == 3) syst = "Syst_3_Up_";
else if (systematics == -3) syst = "Syst_3_Down_";
cout << doQCD << endl;
//string str1, str2, str3, str4, str5, str6, strf;
string str1, str2, str3, strf;
int nDYfiles = 2 ;
string sstrDY[10];
if (doQCD == 0) {
str1 = "HistoFiles/"+ lepSelection + "_13TeV_WW_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
str2 = "HistoFiles/"+ lepSelection + "_13TeV_WZ_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
str3 = "HistoFiles/"+ lepSelection + "_13TeV_ZZ_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
//str4 = "HistoFiles/"+ lepSelection + "_13TeV_ST_tW_antitop_channel_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
// str4 = "HistoFiles/"+ lepSelection + "_13TeV_Tbar_s_channel_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
// str5 = "HistoFiles/"+ lepSelection + "_13TeV_Tbar_t_channel_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
// str6 = "HistoFiles/"+ lepSelection + "_13TeV_Tbar_tW_channel_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
strf = "HistoFiles/"+ lepSelection + "_13TeV_VV_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
//--- DY Files
//sstrDY[0] = "HistoFiles/"+ lepSelection + "_13TeV_DYJets10to50_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
sstrDY[0] = "HistoFiles/"+ lepSelection + "_13TeV_DYJets50toInf_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
sstrDY[1] = "HistoFiles/"+ lepSelection + "_13TeV_DYJets10toInf3_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto.root";
}
if (doQCD > 0){
str1 = "HistoFiles/"+ lepSelection + "_13TeV_WW_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
str2 = "HistoFiles/"+ lepSelection + "_13TeV_WZ_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
str3 = "HistoFiles/"+ lepSelection + "_13TeV_ZZ_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
//str4 = "HistoFiles/"+ lepSelection + "_13TeV_ST_tW_antitop_channel_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
// str4 = "HistoFiles/"+ lepSelection + "_13TeV_Tbar_s_channel_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
// str5 = "HistoFiles/"+ lepSelection + "_13TeV_Tbar_t_channel_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
// str6 = "HistoFiles/"+ lepSelection + "_13TeV_Tbar_tW_channel_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
strf = "HistoFiles/"+ lepSelection + "_13TeV_VV_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
//--- DY Files
//sstrDY[0] = "HistoFiles/"+ lepSelection + "_13TeV_DYJets10to50_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
sstrDY[0] = "HistoFiles/"+ lepSelection + "_13TeV_DYJets50toInf_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str()+ "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
sstrDY[1] = "HistoFiles/"+ lepSelection + "_13TeV_DYJets10toInf3_dR_5311_List_EffiCorr_1_TrigCorr_1_" + syst + "JetPtMin_" + strJetPtCutMin.str() + "_VarWidth_BVeto_QCD" + doQCDStr.str() + ".root";
}
cout << "Output file: " << strf << endl;
TFile *f1 = new TFile(str1.c_str(), "read");
TFile *f2 = new TFile(str2.c_str(), "read");
TFile *f3 = new TFile(str3.c_str(), "read");
//TFile *f4 = new TFile(str4.c_str(), "read");
// TFile *f4 = new TFile(str4.c_str(), "read");
//TFile *f5 = new TFile(str5.c_str(), "read");
//TFile *f6 = new TFile(str6.c_str(), "read");
TFile *ff = new TFile(strf.c_str(), "RECREATE");
int nHist = f1->GetListOfKeys()->GetEntries();
for (int i(0); i < nHist; i++){
string hName = f1->GetListOfKeys()->At(i)->GetName();
if (hName.find("hresponse") != string::npos){
continue;
/*
TH2D *hr1 = (TH2D*) f1->Get(hName.c_str());
TH2D *hr2 = (TH2D*) f2->Get(hName.c_str());
TH2D *hr3 = (TH2D*) f3->Get(hName.c_str());
TH2D *hr4 = (TH2D*) f4->Get(hName.c_str());
TH2D *hr5 = (TH2D*) f5->Get(hName.c_str());
TH2D *hr6 = (TH2D*) f6->Get(hName.c_str());
TH2D *hrSum = (TH2D*) hr1->Clone();
hrSum->Add(*hr2);
hrSum->Add(*hr3);
hrSum->Add(*hr4);
hrSum->Add(*hr5);
hrSum->Add(*hr6);
ff->cd();
hrSum->Write(hName.c_str());
*/
}
else {
TH1D *h1 = (TH1D*) f1->Get(hName.c_str());
TH1D *h2 = (TH1D*) f2->Get(hName.c_str());
TH1D *h3 = (TH1D*) f3->Get(hName.c_str());
//TH1D *h4 = (TH1D*) f4->Get(hName.c_str());
//TH1D *h5 = (TH1D*) f5->Get(hName.c_str());
//TH1D *h6 = (TH1D*) f6->Get(hName.c_str());
TH1D *hSum = (TH1D*) h1->Clone();
hSum->Add(h2);
hSum->Add(h3);
//hSum->Add(h4);
// hSum->Add(h5);
// hSum->Add(h6);
ff->cd();
hSum->Write();
}
}
cout << "closing single top files" << endl;
f1->Close();
f2->Close();
f3->Close();
//f4->Close();
// f5->Close();
// f6->Close();
ff->Close();
//--- merge DY files
int countHist(0);
if (lepSelection == "SMu"){
TFile *fDY[10] = {NULL};
for ( int i = 0 ; i < nDYfiles ; i++){
if ( i == nDYfiles - 1 ) fDY[i] = new TFile(sstrDY[i].c_str(), "recreate");
else fDY[i] = new TFile(sstrDY[i].c_str(), "read");
}
cout << "Output file: " << sstrDY[nDYfiles - 1] << endl;
nHist = fDY[0]->GetListOfKeys()->GetEntries();
for (int i(0); i < nHist; i++){
string hName = fDY[0]->GetListOfKeys()->At(i)->GetName();
if (hName.find("hresponse") != string::npos){
continue;
/*
cout << i << " TH2D " << hName << " " << nHist << endl;
TH2D* hrSum = NULL; TH2D* hrDY[10] = {NULL};
for ( int j = 0 ; j < nDYfiles -1 ; j++){
hrDY[j] = (TH2D*) fDY[j]->Get(hName.c_str());
if ( j == 0 ) hrSum = (TH2D*) hrDY[j]->Clone();
else hrSum->Add(hrDY[j]);
}
fDY[nDYfiles -1]->cd();
hrSum->Write();
*/
}
else {
countHist++;
cout << countHist << " " << i << " TH1D " << hName << " " << nHist << endl;
TH1D* hSum = NULL; TH1D* hDY[10] = {NULL};
for ( int j = 0 ; j < nDYfiles -1 ; j++){
hDY[j] = (TH1D*) fDY[j]->Get(hName.c_str());
if ( j == 0 ) hSum = (TH1D*) hDY[j]->Clone();
else hSum->Add(hDY[j]);
}
fDY[nDYfiles -1]->cd();
hSum->Write();
}
}
cout << "closing DY files" << endl;
for ( int i = 0 ; i < nDYfiles ; i++){
fDY[i] ->Close();
}
}
}
|
9a15add0329800d39c0b9ea553156d905f48f5a4
|
fc751a4cfa36fe067fe746b05dae58628c994ae2
|
/manager/filemanager.h
|
bb581788f3abadc2ba789f90ac7af160a37c340e
|
[] |
no_license
|
RolandoAndrade/NubeUCABManager
|
e21152c54a24dc721f1f2e9d980015dfcc4749fd
|
9c148c077f502548c9c76ac3b6e55f1f09d35727
|
refs/heads/master
| 2020-11-29T16:34:10.273910
| 2020-01-06T00:11:55
| 2020-01-06T00:11:55
| 230,169,276
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 876
|
h
|
filemanager.h
|
#ifndef FILEMANAGER_H
#define FILEMANAGER_H
#include <QObject>
#include <QQmlApplicationEngine>
#include "../server/NubeUCAB-servidor/commands.h"
using namespace std;
class FileManager : public QObject
{
Q_OBJECT
private:
string getNameOfFile(string);
string getTypeOfFile(string);
void insertNewDirectory(vector<map<string,string>> &v,map<string,string>map);
vector<map<string,string>> listOfFiles();
public:
explicit FileManager(QObject *parent = nullptr);
public slots:
void enterToFolder(QString folderName);
QVariantList getFiles();
QString getActualDir();
void copyFile(QString src, QString dest);
void deleteFile(QString fileName);
void createFolder(QString folderName);
void moveFile(QString file, QString route);
};
#endif // FILEMANAGER_H
|
4d76e377e93f6c1a9e5dc317b7d1cb211b1a3f8d
|
906784701763ff93539eff9c15b43dbbdabc8046
|
/main/page7.cpp
|
c1d588fd9a5f18b82552f71b8ba356a92083415e
|
[] |
no_license
|
sandeep123patel/Tao
|
f964f1a36712017abcb1c76223602444cd23efff
|
8dfbca53362582e26afe7d5fa554db93a7c6cd74
|
refs/heads/master
| 2021-01-20T10:05:33.396743
| 2017-12-28T19:06:50
| 2017-12-28T19:06:50
| 101,622,044
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 297
|
cpp
|
page7.cpp
|
#include "page7.h"
#include "ui_page7.h"
#include "page8.h"
page7::page7(QWidget *parent) :
QDialog(parent),
ui(new Ui::page7)
{
ui->setupUi(this);
}
page7::~page7()
{
delete ui;
}
void page7::on_pushButton_clicked()
{
page8 pag8;
pag8.setModal(true);
pag8.exec();
}
|
e72bb4f0f846e2d72ddc75082053abd5c5920550
|
d9a642ed3b0047b56045a05e243a018069dc8133
|
/source code/1676_팩토리얼 0의 개수.cpp
|
3065b25ce41e1611c61c3e83ac56dccb4b10e52a
|
[] |
no_license
|
kingkk31/BOJ
|
7562c7b92a1761120ad159653107e0ec23be2b29
|
03335203cd880607803d28a1fb5cd862e7013e4b
|
refs/heads/master
| 2021-05-04T11:39:05.781066
| 2018-01-09T16:52:15
| 2018-01-09T16:52:15
| 49,325,443
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 368
|
cpp
|
1676_팩토리얼 0의 개수.cpp
|
#include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
int n;
cin >> n;
int cnt2 = 0, cnt5 = 0;
for (int i = 1; i <= n; i++)
{
int t = i, c2 = 0, c5 = 0;
while (t % 5 == 0)
{
c5++;
t /= 5;
}
while (t % 2 == 0)
{
c2++;
t /= 2;
}
cnt2 += c2;
cnt5 += c5;
}
cout << min(cnt2, cnt5) << endl;
return 0;
}
|
1baa11cedd9b5e3045d5acb185b59b17fdc6336f
|
ffd0a067ddf3502dacb3aea30988a28241f7aee3
|
/walksat/Walksat.h
|
dcc09344e47bee2d7df1973c35b15f1eec802c55
|
[] |
no_license
|
lcymq/walksat
|
71a5fb625b9f5b40d0b3286d0bc8783bb6f5e08f
|
4622cff5f2245080e3a78e9b269246e9a6926fcd
|
refs/heads/master
| 2022-12-03T18:02:55.032677
| 2020-08-25T23:28:25
| 2020-08-25T23:28:25
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,196
|
h
|
Walksat.h
|
#include <iostream>
#include <string>
#include <map>
#include <vector>
#ifndef WALKSAT_H
#define WALKSAT_H
using namespace std;
class Walksat {
private:
vector<vector<int>> clauses;
int num_vbles;
int num_clauses;
public:
Walksat();
~Walksat();
// getters
vector<vector<int>> get_clauses();
int get_num_vbles();
int get_num_clauses();
void readfile(const char *filepath);
// split the input string by space ' '
vector<string> split_input(string& clause_str);
// check if the clause is satisfiable
bool is_sat(vector<int>& clause, map<int, bool>& model);
// get the number of satisfied clauses when flip a variable vbles
int get_num_sat_clauses(int vble, map<int, bool> model);
// get the unsatisfied clause
vector<vector<int>> get_unsat_clauses(map<int, bool>& model);
map<int, bool> walksat_alg(float p, int max_flips);
// void print_info(parse_time, eliminated_clauses, restarts, conflicts, conflits_time, decidions, decision_time, propagations, propagation_time, conflict_literals, memory_use, cpu_time);
// TODO: test the program, remember to delete
void print_clauses(vector<vector<int>> clauses);
void print_model(map<int, bool> model);
};
#endif
|
3c43da35ebae88be6bdc4b77eb863be02bc66783
|
86b49295796e559a01fd9495d6d5e6bf3030ce05
|
/EventAnalyzer/interface/ProductMakerUnion.h
|
91e1a4b76019e4f5aa1d28faf4a4a698b13df95f
|
[
"MIT"
] |
permissive
|
peterthomassen/RutgersIAF
|
88310697bd4fc8e1df913cac55c2c4486710ce7c
|
50fd20b79b8bce30478d49e1ce7c763424e094f1
|
refs/heads/master
| 2020-05-29T09:15:38.571846
| 2016-09-22T10:27:09
| 2016-09-22T10:27:09
| 69,040,707
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 396
|
h
|
ProductMakerUnion.h
|
#ifndef ProductMakerUnion_h
#define ProductMakerUnion_h
#include "ProductMaker.h"
class ProductMakerUnion : public ProductMaker{
public:
ProductMakerUnion(TString,TString);
virtual ~ProductMakerUnion() {}
void addSource(TString);
virtual std::vector<SignatureObject*> makeProduct(BaseHandler*);
private:
std::vector<TString> m_sources;
ClassDef(ProductMakerUnion,1);
};
#endif
|
c9d388b155fb823d97eae33841883b33564cd644
|
5ee0eb940cfad30f7a3b41762eb4abd9cd052f38
|
/Case_save/case9/2500/k
|
ce4bb34d45aeaf603381bb8905aa5a81eec1386d
|
[] |
no_license
|
mamitsu2/aircond5_play4
|
052d2ff593661912b53379e74af1f7cee20bf24d
|
c5800df67e4eba5415c0e877bdeff06154d51ba6
|
refs/heads/master
| 2020-05-25T02:11:13.406899
| 2019-05-20T04:56:10
| 2019-05-20T04:56:10
| 187,570,146
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,779
|
k
|
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "2500";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
459
(
0.00257286
0.00308716
0.00320903
0.00353439
0.00385379
0.00416972
0.00449774
0.00480795
0.00502078
0.00509216
0.00498759
0.00469373
0.00422219
0.00362695
0.00300627
0.00052614
0.000767479
0.000971988
0.000968732
0.000906148
0.000824666
0.000725537
0.000633104
0.000554674
0.00048944
0.000435123
0.00038958
0.00035122
0.000318493
0.000289776
0.000263423
0.000237561
0.000222063
0.000186421
0.00476318
0.00896567
0.00521642
0.00556058
0.00610819
0.0067426
0.00743509
0.00814039
0.00875587
0.00914489
0.00920259
0.00888221
0.00817605
0.00712205
0.00572848
0.0031751
0.00108516
0.000592776
0.00132417
0.00161776
0.00170076
0.00164344
0.00150293
0.00127434
0.00106333
0.000890091
0.000751767
0.000641431
0.000552835
0.000480542
0.000420418
0.000371184
0.000336471
0.000315545
0.000553531
0.000327611
0.00707381
0.0162791
0.00652845
0.00633383
0.00685117
0.00756648
0.0084097
0.00929245
0.0100462
0.0105327
0.0106713
0.0104385
0.0098274
0.00892065
0.00779301
0.00644628
0.00334988
0.00221361
0.00229473
0.00228555
0.00221906
0.00208868
0.00189317
0.00146267
0.00113848
0.000907121
0.000739616
0.000615888
0.000522607
0.000451104
0.000395908
0.000353958
0.00032056
0.000316681
0.000813901
0.000446543
0.00969676
0.0262865
0.00830566
0.0066764
0.0070491
0.00785672
0.00893087
0.00999819
0.0108005
0.0112868
0.011433
0.0112298
0.0106289
0.00973978
0.00874386
0.00774205
0.00629737
0.00465836
0.00392086
0.00347681
0.00316073
0.00288033
0.00261169
0.00233589
0.00185009
0.00153341
0.00132496
0.001175
0.00105297
0.000947535
0.000851168
0.000755687
0.000652376
0.000484065
0.000401521
0.00115398
0.000546619
0.0127788
0.0393521
0.0123048
0.00743236
0.00742966
0.00843198
0.00998665
0.0111431
0.0118232
0.0121918
0.0122664
0.0119948
0.0113153
0.0102799
0.00904655
0.00779829
0.00664272
0.00574276
0.00500375
0.00439476
0.00387862
0.00343275
0.00304692
0.00272053
0.00244522
0.00224391
0.00208966
0.0019497
0.00180175
0.00162714
0.00143228
0.0012257
0.00101456
0.000775559
0.000585645
0.00095789
0.000663143
0.000811742
0.00115885
0.00145304
0.0164937
0.0530057
0.0215038
0.0107846
0.00968326
0.0110557
0.0126169
0.0132471
0.013477
0.0135672
0.0135093
0.0131325
0.012292
0.0109944
0.00942132
0.00785957
0.00657696
0.00570833
0.00511967
0.00459816
0.00408267
0.00360504
0.00319661
0.00287984
0.00266385
0.00252887
0.0024229
0.0023118
0.00217626
0.00199847
0.00177325
0.00152579
0.00127129
0.00101813
0.000824542
0.000867813
0.000778599
0.000803019
0.00196352
0.00159824
0.0201877
0.0613724
0.0358213
0.0217836
0.0184359
0.0180694
0.0172228
0.0164036
0.0158596
0.0155792
0.0153239
0.0147538
0.0136318
0.011953
0.00995199
0.00802724
0.00653748
0.00558894
0.00497745
0.00444829
0.00392774
0.00345875
0.00308338
0.00282218
0.00267194
0.00259726
0.00254932
0.00250195
0.00244063
0.00234867
0.00218388
0.00195897
0.00170245
0.00144141
0.00125791
0.00120234
0.00124152
0.00157954
0.00248078
0.00212112
0.0208607
0.0586426
0.0423317
0.0344161
0.0292883
0.0247355
0.0214525
0.0194975
0.0185736
0.0182055
0.0178263
0.0169213
0.0152558
0.0129276
0.0102906
0.00791336
0.00621156
0.00516557
0.00449545
0.00394469
0.00345526
0.00305741
0.00277138
0.00259707
0.00251679
0.00250014
0.00252019
0.00256655
0.00263846
0.00273624
0.00285264
0.00289443
0.00284979
0.00282655
0.00293219
0.00356476
0.00514658
0.00807938
0.0155718
0.00505655
0.0196973
0.0273746
0.0257464
0.0227915
0.0207284
0.01989
0.0200291
0.0207783
0.0216392
0.0220285
0.0214144
0.0194958
0.0165221
0.0130058
0.00944442
0.00677814
0.00525264
0.00434279
0.00371473
0.00321337
0.00281109
0.00251537
0.00232545
0.00222698
0.002198
0.00221763
0.00227325
0.00236172
0.00248495
0.0026464
0.00284947
0.00310536
0.00343624
0.00391223
0.0045614
0.00535322
0.00609236
0.00650484
0.00662307
0.0042836
0.00772174
0.016394
0.0250401
0.0293058
0.0314168
0.0317843
0.0303192
0.0272392
0.0229432
0.017642
0.0130792
0.00946406
0.00683755
0.00515493
0.00412895
0.00345738
0.00296679
0.00258212
0.00228451
0.00207568
0.00194836
0.00188468
0.00186767
0.00188609
0.00193519
0.00201598
0.00213429
0.00230121
0.00253433
0.00284872
0.00325052
0.00374947
0.0043189
0.00485118
0.00514581
0.00502867
0.0044175
0.00278118
0.00951232
0.0253523
0.0297472
0.0280475
0.0263582
0.0239513
0.0207588
0.0171597
0.0135251
0.0101747
0.00754222
0.00566898
0.00443178
0.00364167
0.00311677
0.00273472
0.00243422
0.00219306
0.00200418
0.00186247
0.00176889
0.00171734
0.00170335
0.00172588
0.00178636
0.00188771
0.00203359
0.00222983
0.0024907
0.00282651
0.00324912
0.00376078
0.00433089
0.00489987
0.00523976
0.00553142
0.00460094
0.0028504
0.00763318
0.00858813
0.0093117
0.0108335
0.00999654
0.00924722
0.00865009
0.00781884
0.00676285
0.00559629
0.00442692
0.00338069
0.00256513
0.00199302
0.00161097
0.00135614
0.00118278
0.00106368
0.000984289
0.000936699
0.000915632
0.000916585
0.000933108
0.000963316
0.00100648
0.00106284
0.00113349
0.00122059
0.00132799
0.00146091
0.00162031
0.00181106
0.00203864
0.00230975
0.00262988
0.00308679
0.00322431
0.00306732
0.00266907
0.00227174
)
;
boundaryField
{
floor
{
type kqRWallFunction;
value nonuniform List<scalar>
29
(
0.00300627
0.00052614
0.000767479
0.000971988
0.000968732
0.000906148
0.000824666
0.000725537
0.000633104
0.000554674
0.00048944
0.000435123
0.00038958
0.00035122
0.000318493
0.000289776
0.000263423
0.000237561
0.000222063
0.000186421
0.000186421
0.000327611
0.000446543
0.000546619
0.00300627
0.00052614
0.000592776
0.00221361
0.00465836
)
;
}
ceiling
{
type kqRWallFunction;
value nonuniform List<scalar>
43
(
0.00763318
0.00858813
0.0093117
0.0108335
0.00999654
0.00924722
0.00865009
0.00781884
0.00676285
0.00559629
0.00442692
0.00338069
0.00256513
0.00199302
0.00161097
0.00135614
0.00118278
0.00106368
0.000984289
0.000936699
0.000915632
0.000916585
0.000933108
0.000963316
0.00100648
0.00106284
0.00113349
0.00122059
0.00132799
0.00146091
0.00162031
0.00181106
0.00203864
0.00230975
0.00262988
0.00308679
0.00322431
0.00306732
0.00266907
0.00227174
0.0196973
0.0273746
0.00951232
)
;
}
sWall
{
type kqRWallFunction;
value uniform 0.00763318;
}
nWall
{
type kqRWallFunction;
value nonuniform List<scalar> 6(0.00145304 0.00159824 0.00212112 0.00278118 0.0028504 0.00227174);
}
sideWalls
{
type empty;
}
glass1
{
type kqRWallFunction;
value nonuniform List<scalar> 9(0.00257286 0.00476318 0.00707381 0.00969676 0.0127788 0.0164937 0.0201877 0.0208607 0.0196973);
}
glass2
{
type kqRWallFunction;
value nonuniform List<scalar> 2(0.00505655 0.0042836);
}
sun
{
type kqRWallFunction;
value nonuniform List<scalar>
14
(
0.00257286
0.00308716
0.00320903
0.00353439
0.00385379
0.00416972
0.00449774
0.00480795
0.00502078
0.00509216
0.00498759
0.00469373
0.00422219
0.00362695
)
;
}
heatsource1
{
type kqRWallFunction;
value nonuniform List<scalar> 3(0.000811742 0.00115885 0.00145304);
}
heatsource2
{
type kqRWallFunction;
value nonuniform List<scalar> 4(0.0031751 0.00108516 0.00108516 0.00334988);
}
Table_master
{
type kqRWallFunction;
value nonuniform List<scalar> 9(0.00146267 0.00113848 0.000907121 0.000739616 0.000615888 0.000522607 0.000451104 0.000395908 0.000353958);
}
Table_slave
{
type kqRWallFunction;
value nonuniform List<scalar> 9(0.00185009 0.00153341 0.00132496 0.001175 0.00105297 0.000947535 0.000851168 0.000755687 0.000652376);
}
inlet
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.05;
value uniform 0.0003375;
}
outlet
{
type zeroGradient;
}
}
// ************************************************************************* //
|
|
1a8d24fe471b0872545b79a55f9558d1d14c578d
|
d8aabc7cfff208a358f60e83a2db4af7d1e505a9
|
/P-7.5 Binary/BST.cpp
|
480f2ad68463daf87bd2b31521164c1fe0ef89ad
|
[] |
no_license
|
Buenz/cprojects
|
4b91bf0b33ce3249c6d02da19ca56dc669cda4ab
|
c90dff5b6e8a4550f032233f0e768aa587ee9209
|
refs/heads/master
| 2020-04-28T02:37:54.718826
| 2019-08-25T03:43:25
| 2019-08-25T03:43:25
| 174,906,185
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,923
|
cpp
|
BST.cpp
|
#include <iostream>
#include <cstdlib>
#include "BST.h"
using namespace std;
#define SPACE 5
BST::BST()
{
root=NULL; //make sure root doesn't point to anything
}
BST::node* BST::CreateLeaf(int key){
node* n=new node;
n->key=key;
n->left=NULL;
n->right=NULL;
return n; //return pointer to null}
}
void BST::addLeaf(int key){
addLeafPrivate(key, root);
}
void BST::addLeafPrivate(int key, node *ptr){
if(root==NULL){ ///no nodes made yet
root=CreateLeaf(key);
}
else if(key < ptr->key){//if node is smaller than root
if(ptr->left!=NULL){
addLeafPrivate(key, ptr->left);
}
else{
ptr->left=CreateLeaf(key);
}
}
else if(key > ptr->key){
if(ptr->right!=NULL){
addLeafPrivate(key, ptr->right);
}
else
{
ptr->right=CreateLeaf(key);
}
}
else
{
cout<<" The number has already been added.\n";
}
}
void BST::printTree(){
;
printPrivateTree(root,0);
}
void BST::printPrivateTree(node* ptr, int space){
if(ptr==NULL){
for(int i=0;i<space;++i){
cout<<"\t";}
cout<<'*'<<endl;
return;}
space+=SPACE;
printPrivateTree(ptr->right, space+1);
for(int i=SPACE;i<space;i++)
cout<<"\t";
cout<<ptr->key<<endl;
printPrivateTree(ptr->left, space+1);
}
void BST::printInOrder(){
printInOrderPrivate(root);
}
void BST::printInOrderPrivate(node *ptr){
if(root!=NULL){
if(ptr->left!=NULL)
{
printInOrderPrivate(ptr->left);
}
cout<<ptr->key<<" ";
if(ptr->right!=NULL){
printInOrderPrivate(ptr->right);
}
}
else
{
cout<<"The tree is empty.";
}
}
|
1cf7d498c0de3b5e191cff384901380ccdbc1272
|
79e74cd79429165826afb3418e26221f94760695
|
/week10.2/map.h
|
15a16bf0d4055c44844451692c5e77c3f64a705a
|
[] |
no_license
|
Camthack13/cs235
|
c06271af4b2026f7fe475ef5f0c371f3127cf953
|
a74879f953f2d2283d66d1c72d75d73228f72051
|
refs/heads/master
| 2020-03-22T00:43:12.548344
| 2018-07-07T16:36:56
| 2018-07-07T16:36:56
| 139,261,427
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,299
|
h
|
map.h
|
#ifndef map_H
#define map_H
#include <iostream>
#include <cassert> // because I am paranoid
#include <string>
#include "bst.h" // for Stack
#include "pair.h"
// a little helper macro to write debug code
#ifdef NDEBUG
#define Debug(statement)
#else
#define Debug(statement) statement
#endif // !NDEBUG
namespace custom{
/************************************************
* map
* A class that holds stuff
***********************************************/
template <class T1, class T2>
class map
{
private:
BST<pair<T1, T2> > data;
public:
//Constructor
map() {
}
//Copy Constuctor
map(const map<T1,T2> & rhs)
{
data = rhs.data;
}
//Assignment
map & operator = (const map & rhs) throw (const char *)
{
data = rhs.data;
return * this;
}
//size
int size()
{
return data.size();
}
//Empty
bool empty()
{
return data.empty();
}
//Clear
void clear()
{
data.clear();
}
//insert()
void insert(T1 key, T2 value) throw(const char *)
{
pair<T1,T2> pair(key,value);
data.insert(pair);
}
//insert()
void insert(pair<T1,T2> pair) throw(const char *)
{
data.insert(pair);
}
//[] operator
T2 & operator [] (T1 index) throw (const char *)
{
pair<T1,T2> pair(index,T2());
if(data.find(pair) == NULL)
{
data.insert(pair);
}
return (data.find(pair)).getNode()->data.second;
}
// const T2 & operator [] (T1 index) const throw (const char *)
// {
// pair<T1,T2> pair(index,T2());
// return
// }
class iterator;
//find()
iterator find(T1 t)
{
pair<T1,T2> pPPair(t,T2());
BSTIterator< pair<T1,T2> > bstit;
bstit = data.find(pPPair);
iterator it(bstit);
return it;
}
//begin()
iterator begin()
{
BSTIterator< pair<T1,T2> > bstit;
bstit = data.begin();
iterator it(bstit);
return it;
}
//end()
iterator end()
{
BSTIterator< pair<T1,T2> > bstit;
bstit = data.end();
iterator it(bstit);
return it;
}
};
template <class T1, class T2>
class map<T1,T2> :: iterator
{
private:
public:
BSTIterator< pair<T1,T2> > it;
iterator() {}
iterator(BSTIterator<pair<T1,T2> > & itU)
{
it = itU;
}
iterator (const iterator& itU)
{
it = itU.it;
}
//assigment
iterator & operator = (const iterator & rhs)
{
it = rhs.it;
}
//isequal
bool operator == (const iterator & rhs) const
{
return(it == rhs.it);
}
//isNotEwial
bool operator != (const iterator & rhs) const
{
return(it != rhs.it);
}
//incremtn
iterator & operator ++ ()
{
it++;
return *this;
}
//decremtnt
iterator & operator -- ()
{
it--;
return *this;
}
//defrencerence
pair<T1,T2> & operator * ()
{
return *it;
}
};
};//ending namespace custom
#endif // map_H
|
e2cfd20910f1cece452400965485e666ca702d42
|
f6b790075314a5cd82d73f1c3560e0a7b91c4166
|
/classes/union.cc
|
fb4e00ebda8356b31c0b8bae993c760650aedf04
|
[] |
no_license
|
yshivatest/cplusplus
|
6e81c786e32925c4169fd20f4eb100c5226844ff
|
b8c25f91f182def40a8b6c154664ef6bd73a4f2e
|
refs/heads/master
| 2021-01-17T11:11:40.489949
| 2016-05-20T19:40:07
| 2016-05-20T19:40:07
| 35,382,629
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 525
|
cc
|
union.cc
|
#include<iostream>
using namespace std;
enum class Type {str, num};
union Value {
public:
char *s;
int i;
ostream& operator<<(ostream& out) { out<<i<<endl;}
};
struct Entry {
Value v;
Type t;
};
void print_entry(const Entry& x)
{
if (x.t == Type::str)
cout<<x.v.s<<endl;
else
cout<<x.v.i<<endl;
}
int main()
{
Value str; str.s = "siva";
Value num; num.i = 1;
Entry x = {num, Type::num};
Entry y = {str, Type::str};
print_entry(x);
print_entry(y);
}
|
b49f07dfe2b4e2308fbf1ae30050e6d503ba6d23
|
29a1640379e728b15b4f20a8a1f4e216eb769681
|
/sorts/sorter.cpp
|
2534c78b9d447fa6e924b4fe4bee7cdbfa4776d8
|
[] |
no_license
|
minivesper/ProjectBits
|
5b05bfe4178e64e0de415ae24f6b8c92a8e44c67
|
d909dd3c877d3cd2f4e2347e9a533c2f4b80e244
|
refs/heads/master
| 2021-05-06T00:32:37.038192
| 2017-12-15T00:51:38
| 2017-12-15T00:51:38
| 114,310,505
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,538
|
cpp
|
sorter.cpp
|
#include<stdlib.h>
#include <array>
#include <iostream>
#include "sorts.h"
using namespace std;
class Sorter {
int listlength;
int nummax;
int* unsorted;
public:
void init_list (int,int);
void print_list(int*);
int * getList();
bool sortTest(int*, int);
};
int * Sorter::getList()
{
return unsorted;
}
void Sorter::print_list(int * l)
{
int t;
for(int a = 0; a < listlength; a = a + 1) {
cout << l[a] << " ";
}
cout << "\n";
t = sortTest(l,listlength);
if(t) { cout << "Sort test succeded\n\n"; }
else { cout << "sort test failed\n\n"; }
}
void Sorter::init_list(int llength, int nummax) {
listlength = llength;
int * l = new int [listlength];
for(int i = 0; i < listlength; i=i+1) {
l[i] = (rand() % nummax + 1);
}
unsorted = l;
}
bool Sorter::sortTest(int* theo_sort, int length) {
for( int i = 0; i < length-1; i = i+1) {
if (theo_sort[i] > theo_sort[i+1]) {
return 0;
}
}
return 1;
}
int main()
{
int * sorted;
int ll,rn;
Sorter s;
Sorts st;
printf("size of list: ");
scanf("%d",&ll);
printf("range of random nums: ");
scanf("%d",&rn);
s.init_list(ll,rn);
cout << "Initial list: \n";
s.print_list(s.getList());
sorted = st.selectionSort(s.getList(), ll);
s.print_list(sorted);
sorted = st.insertionSort(s.getList(), ll);
s.print_list(sorted);
sorted = st.bubbleSort(s.getList(), ll);
s.print_list(sorted);
sorted = st.mergeHelp(s.getList(), ll);
s.print_list(sorted);
sorted = st.quickHelp(s.getList(), ll);
s.print_list(sorted);
free(sorted);
return 0;
}
|
f64f2632c67937d32e0a0e0ed10f2dd4b86aac5a
|
aa8a3d6d26aef12652ad842d3bddd4e71fb7f8d7
|
/uViewAllResourcesWindow.h
|
a6d84630e4b49e17f5df9e954273b5cc38b75e75
|
[] |
no_license
|
GrzegorzSol/MojaBibliaNG
|
d8137b7d50040d168aeec155c50769771962a0a4
|
f05bbcf4cc2a1143ae19a5760f240611db0e714d
|
refs/heads/master
| 2023-09-01T08:57:13.146588
| 2023-08-30T04:12:19
| 2023-08-30T04:12:19
| 187,962,830
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,844
|
h
|
uViewAllResourcesWindow.h
|
//---------------------------------------------------------------------------
#ifndef uViewAllResourcesWindowH
#define uViewAllResourcesWindowH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include "GsComponents\GsViewAllResourcesClass.h"
#include <Vcl.ComCtrls.hpp>
#include <Vcl.ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TViewAllResourcesWindow : public TForm
{
__published: // IDE-managed Components
TRichEdit *REditInfoSelectItem;
TPanel *PanelViews;
TPanel *PanelDisplay;
TSplitter *SplitterDisplay;
TSplitter *SplitterViews;
TImage *ImageDisplayResource;
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
void __fastcall PanelDisplayResize(TObject *Sender);
void __fastcall ImageDisplayResourceDblClick(TObject *Sender);
private: // User declarations
float fFactorProp;
TForm *_pDisplayWindow=nullptr;
TImage *_pImageScr=nullptr;
void __fastcall _OnKeyPress(TObject *Sender, System::WideChar &Key);
GsViewAllResourcesClass *_pGsViewAllResourcesClass;
void __fastcall _OnSelectItem(System::TObject* Sender, TListItem* Item, bool Selected);
void __fastcall _DisplaySelectVersAllTrans(const DataItemResources *pDataItemResources);
void __fastcall _DisplayImage(const UnicodeString _pathImages);
public: // User declarations
__fastcall TViewAllResourcesWindow(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TViewAllResourcesWindow *ViewAllResourcesWindow;
//---------------------------------------------------------------------------
#endif
|
235946b56a5a453378c8c264e9303456cf3e3a42
|
25c38d440e06d362d053a58aa1f20158ccdae003
|
/src/ast/stmt_ast/cond_stmt.h
|
85b397b61f7f7dce2fc4222f4f369391655dc251
|
[
"MIT"
] |
permissive
|
Zx55/c0-cli
|
76fe308903b5097c9d9d88abb15d7ca09c5b337b
|
e17d1f682c00937884e52b81bc4e160f61dc69a1
|
refs/heads/master
| 2020-09-15T01:15:32.724240
| 2019-12-21T12:21:56
| 2019-12-21T12:21:56
| 223,313,564
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,496
|
h
|
cond_stmt.h
|
/*
* Created by zx5 on 2019/11/28.
* Copyright (c) zx5. All rights reserved.
*/
#ifndef C0_COND_STMT_H
#define C0_COND_STMT_H
#include "basic_stmt.h"
#include <unordered_set>
namespace cc0::ast {
class IfElseStmtAST final: public StmtAST {
private:
_ptr<CondExprAST> _cond;
_ptr<StmtAST> _true;
_ptr<StmtAST> _false;
public:
explicit IfElseStmtAST(range_t range, _ptr<CondExprAST> cond, _ptr<StmtAST> s_true, _ptr<StmtAST> s_false):
StmtAST(range), _cond(std::move(cond)), _true(std::move(s_true)), _false(std::move(s_false)) { }
void graphize(std::ostream& out, int t) override {
out << "<if-else-stmt>\n" << _mid(t);
_cond->graphize(out, t + 1);
if (_false == nullptr) out << _end(t);
else out << _mid(t);
_true->graphize(out, t + 1);
if (_false != nullptr) {
out << _end(t);
_false->graphize(out, t + 1);
}
}
[[nodiscard]] _GenResult generate(_GenParam param) override {
auto cond = _cond->generate({ param._level, param._offset, param._slot,
param._ret, false });
auto len = cond._len;
if (len == 0)
return _gen_ret(0);
auto jmp_to_false = _gen_ist_off;
_gen_ist1(_make_jn(_cond->get_op()), 0);
++len;
auto true_stmt = _true->generate({ param._level, param._offset + len,
param._slot, param._ret, true });
if (true_stmt._len == 0) {
_gen_popn(len);
return _gen_ret(0);
}
len += true_stmt._len;
if (_false == nullptr) {
/*
* `if (cond) stmt` will generate:
*
* ...cond
* j$(!op) .End
* ...stmt
* .End
*
* and the .End here is false offset
*/
_gen_ist(jmp_to_false).set_op1(param._offset + len);
return { len, std::move(true_stmt._breaks), std::move(true_stmt._continues) };
}
/*
* `if (cond) stmt1 else stmt2` will generate:
*
* ...cond
* j$(!op) .False
* ...stmt1
* jmp .End
* .False
* ...stmt2
* .End
*/
auto jmp_to_end = _gen_ist_off;
_gen_ist1(InstType::JMP, 0);
++len;
_gen_ist(jmp_to_false).set_op1(param._offset + len);
auto false_stmt = _false->generate({ param._level, param._offset + len,
param._slot, param._ret, true });
if (false_stmt._len == 0) {
_gen_popn(len);
return _gen_ret(0);
}
len += false_stmt._len;
_gen_ist(jmp_to_end).set_op1(param._offset + len);
auto breaks = std::move(true_stmt._breaks);
auto continues = std::move(true_stmt._continues);
_gen_move_back(breaks, false_stmt._breaks);
_gen_move_back(continues, false_stmt._continues);
return { len, std::move(breaks), std::move(continues) };
}
};
class LabelStmtAST final: public StmtAST {
private:
_ptr<ExprAST> _case;
_ptr<StmtAST> _stmt;
public:
explicit LabelStmtAST(range_t range, _ptr<ExprAST> e_case, _ptr<StmtAST> stmt):
StmtAST(range), _case(std::move(e_case)), _stmt(std::move(stmt)) { }
[[nodiscard]] inline _ptr<ExprAST>& get_case() { return _case; }
void graphize(std::ostream& out, int t) override {
out << "[case] ";
_case->graphize(out, t + 1);
out << _end(t);
_stmt->graphize(out, t + 1);
}
[[nodiscard]] _GenResult generate(_GenParam param) override {
auto stmt = _stmt->generate(param);
if (stmt._len == 0)
return _gen_ret(0);
return { stmt._len, std::move(stmt._breaks), std::move(stmt._continues) };
}
};
class SwitchStmtAST final: public StmtAST {
private:
_ptr<ExprAST> _cond;
_ptrs<LabelStmtAST> _cases;
uint32_t _reachable_cases;
_ptr<StmtAST> _default;
public:
explicit SwitchStmtAST(range_t range, _ptr<ExprAST> cond, _ptrs<LabelStmtAST> cases,
uint32_t reachable, _ptr<StmtAST> s_default):
StmtAST(range), _cond(std::move(cond)), _cases(std::move(cases)),
_reachable_cases(reachable), _default(std::move(s_default)) { }
void graphize(std::ostream& out, int t) override {
out << "<switch-stmt>\n" << ((_cases.empty() && _default == nullptr) ? _end(t) : _mid(t)) << "[cond] ";
_cond->graphize(out, t + 1);
if (!_cases.empty()) {
for (auto it = _cases.cbegin(); it != _cases.cbegin() + _reachable_cases - 1; ++it) {
out << _mid(t);
(*it)->graphize(out, t + 1);
}
out << (_default == nullptr ? _end(t) : _mid(t));
(*(_cases.cbegin() + _reachable_cases - 1))->graphize(out, t + 1);
}
if (_default != nullptr) {
out << _end(t) << "[default] ";
_default->graphize(out, t + 1);
}
}
[[nodiscard]] _GenResult generate(_GenParam param) override {
/*
* switch '(' expr ')' '{' {case} [default] '}'
*
* without default:
*
* ...expr
* ...cond1
* icmp
* je .Case1
* ...expr
* ...cond2
* icmp
* je .Case2
* jmp .End
* .Case1:
* ...stmt1
* jmp .End
* .Case2:
* ...stmt2
* jmp .End
* .End
*
* with default:
*
* ...expr
* ...cond1
* icmp
* je .Case1
* jmp .Default
* .Case1
* ...stmt1
* jmp .End
* .Default
* ...stmt
* .End
*
*/
uint32_t len = 0;
auto jmp_to_case = std::vector<uint32_t>();
auto breaks = std::vector<_JmpInfo>();
auto continues = std::vector<_JmpInfo>();
auto case_set = std::unordered_set<int32_t>();
if (auto type = _cond->get_type(); type != Type::INT && type != Type::CHAR) {
GeneratorContext::put_fatal(C0Err(ErrCode::ErrInvalidSwitchCond, _cond->get_range()));
return _gen_ret(0);
}
// generate jump of each case
for (auto it = _cases.begin(); it != _cases.begin() + _reachable_cases; ++it) {
auto& case_cond = (*it)->get_case();
auto case_value = case_cond->get_value();
if (case_set.find(case_value) != case_set.end()) {
// repeated case
GeneratorContext::put_fatal(C0Err(ErrCode::ErrRepeatedCase, case_cond->get_range()));
_gen_popn(len);
return _gen_ret(0);
}
case_set.insert(case_value);
auto cond = _cond->generate({ param._level, param._offset, param._slot,
param._ret, false });
if (cond._len == 0) {
_gen_popn(len);
return _gen_ret(0);
}
len += cond._len;
if (auto res = case_cond->generate({ param._level, param._offset, param._slot,
param._ret, false }); res._len == 0) {
_gen_popn(len);
return _gen_ret(0);
}
else
len += res._len;
_gen_ist0(InstType::ICMP);
jmp_to_case.push_back(_gen_ist_off);
_gen_ist1(InstType::JE, 0);
len += 2;
}
auto jmp_to_default_or_end = _gen_ist_off;
_gen_ist1(InstType::JMP, 0);
++len;
// generate stmt of each case
for (auto it = _cases.begin(); it != _cases.begin() + _reachable_cases; ++it) {
_gen_ist(jmp_to_case[it - _cases.begin()]).set_op1(param._offset + len);
auto stmt = (*it)->generate({ param._level, param._offset + len,
param._slot, param._ret, true });
if (stmt._len == 0) {
_gen_popn(len);
return _gen_ret(0);
}
len += stmt._len;
_gen_move_back(breaks, stmt._breaks);
_gen_move_back(continues, stmt._continues);
}
if (_default != nullptr) {
_gen_ist(jmp_to_default_or_end).set_op1(param._offset + len);
auto res = _default->generate({ param._level, param._offset + len,
param._slot, param._ret, true });
if (res._len == 0) {
_gen_popn(len);
return _gen_ret(0);
}
len += res._len;
_gen_move_back(breaks, res._breaks);
_gen_move_back(continues, res._continues);
} else {
_gen_pop;
--len;
_gen_ist(jmp_to_default_or_end).set_op1(param._offset + len);
}
// handle break;
for (const auto jmp_to_end: breaks) {
auto slot = _symtbl.get_slot_by_level();
_gen_ist(jmp_to_end.ist_off - 1).set_op1(jmp_to_end.slot - slot);
_gen_ist(jmp_to_end.ist_off).set_op1(param._offset + len);
}
return { len, {}, std::move(continues) };
}
};
}
#endif //C0_COND_STMT_H
|
0f662946722e3fb291108598e67cc460ce7e136c
|
820b6af9fd43b270749224bb278e5f714f655ac9
|
/Rendering/LICOpenGL2/vtkImageDataLIC2D.h
|
af51577c843664b8acebe58281d99e0d2b5a5246
|
[
"BSD-3-Clause"
] |
permissive
|
Kitware/VTK
|
49dee7d4f83401efce8826f1759cd5d9caa281d1
|
dd4138e17f1ed5dfe6ef1eab0ff6643fdc07e271
|
refs/heads/master
| 2023-09-01T10:21:57.496189
| 2023-09-01T08:20:15
| 2023-09-01T08:21:05
| 631,615
| 2,253
| 1,243
|
NOASSERTION
| 2023-09-14T07:53:03
| 2010-04-27T15:12:58
|
C++
|
UTF-8
|
C++
| false
| false
| 4,179
|
h
|
vtkImageDataLIC2D.h
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
* @class vtkImageDataLIC2D
*
*
* GPU implementation of a Line Integral Convolution, a technique for
* imaging vector fields.
*
* The input on port 0 is an vtkImageData with extents of a 2D image. It needs
* a vector field on point data. This filter only works on point vectors. One
* can use a vtkCellDataToPointData filter to convert cell vectors to point
* vectors.
*
* Port 1 is a special port for customized noise input. It is an optional port.
* If noise input is not specified, then the filter using vtkImageNoiseSource to
* generate a 128x128 noise texture.
*
* @sa
* vtkSurfaceLICPainter vtkLineIntegralConvolution2D
*/
#ifndef vtkImageDataLIC2D_h
#define vtkImageDataLIC2D_h
#include "vtkImageAlgorithm.h"
#include "vtkRenderingLICOpenGL2Module.h" // For export macro
#include "vtkWeakPointer.h" // needed for vtkWeakPointer.
VTK_ABI_NAMESPACE_BEGIN
class vtkRenderWindow;
class vtkOpenGLRenderWindow;
class vtkImageNoiseSource;
class vtkImageCast;
class VTKRENDERINGLICOPENGL2_EXPORT vtkImageDataLIC2D : public vtkImageAlgorithm
{
public:
static vtkImageDataLIC2D* New();
vtkTypeMacro(vtkImageDataLIC2D, vtkImageAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) override;
///@{
/**
* Get/Set the context. Context must be a vtkOpenGLRenderWindow.
* This does not increase the reference count of the
* context to avoid reference loops.
* SetContext() may raise an error if the OpenGL context does not support the
* required OpenGL extensions. Return 0 upon failure and 1 upon success.
*/
int SetContext(vtkRenderWindow* context);
vtkRenderWindow* GetContext();
///@}
///@{
/**
* Number of steps. Initial value is 20.
* class invariant: Steps>0.
* In term of visual quality, the greater the better.
*/
vtkSetMacro(Steps, int);
vtkGetMacro(Steps, int);
///@}
///@{
/**
* Step size.
* Specify the step size as a unit of the cell length of the input vector
* field. Cell length is the length of the diagonal of a cell.
* Initial value is 1.0.
* class invariant: StepSize>0.0.
* In term of visual quality, the smaller the better.
* The type for the interface is double as VTK interface is double
* but GPU only supports float. This value will be converted to
* float in the execution of the algorithm.
*/
vtkSetMacro(StepSize, double);
vtkGetMacro(StepSize, double);
///@}
///@{
/**
* The magnification factor. Default is 1
*/
vtkSetMacro(Magnification, int);
vtkGetMacro(Magnification, int);
///@}
///@{
/**
* Check if the required OpenGL extensions / GPU are supported.
*/
vtkGetMacro(OpenGLExtensionsSupported, int);
///@}
void TranslateInputExtent(const int* inExt, const int* inWholeExtent, int* outExt);
protected:
vtkImageDataLIC2D();
~vtkImageDataLIC2D() override;
int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
/**
* Fill the input port information objects for this algorithm. This
* is invoked by the first call to GetInputPortInformation for each
* port so subclasses can specify what they can handle.
* Redefined from the superclass.
*/
int FillInputPortInformation(int port, vtkInformation* info) override;
int RequestUpdateExtent(vtkInformation* vtkNotUsed(request), vtkInformationVector** inputVector,
vtkInformationVector* vtkNotUsed(outputVector)) override;
/**
* This is called by the superclass.
* This is the method you should override.
*/
int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;
vtkWeakPointer<vtkOpenGLRenderWindow> Context;
bool OwnWindow;
int OpenGLExtensionsSupported;
vtkImageNoiseSource* NoiseSource;
vtkImageCast* ImageCast;
int Steps;
double StepSize;
int Magnification;
private:
vtkImageDataLIC2D(const vtkImageDataLIC2D&) = delete;
void operator=(const vtkImageDataLIC2D&) = delete;
};
VTK_ABI_NAMESPACE_END
#endif
|
9ce57c7401a14c9d335d43a51b388ffe8768eb97
|
cbcb499c8196b4a7e9c4fb153440a1ab56fe7fe5
|
/SciDac2007/test.cpp
|
c8ec0118fe0632c88ccd085e78f562f445e8e1fe
|
[] |
no_license
|
mdipierro/fermiqcd
|
6b8a2526f1f41c2eef7d0a498aabd91ceae6744c
|
49870936e1555bf50686c9f7de963f874893586d
|
refs/heads/master
| 2021-01-21T13:41:11.625537
| 2013-06-23T09:09:55
| 2013-06-23T09:09:55
| 48,326,329
| 7
| 7
| null | 2016-05-23T10:59:43
| 2015-12-20T15:28:34
|
HTML
|
UTF-8
|
C++
| false
| false
| 1,361
|
cpp
|
test.cpp
|
/*
python qcd.py code +hot TxXxYxZ=4x4x4x4 +loop n=10 { +heatbath +plaquette } +loop n=1 { +ape_smear steps=1 +plaquette +topological_charge_vtk }
+hot warning: assuming default argument nc=3
+heatbath warning: assuming default argument beta=5.0
+heatbath warning: assuming default argument steps=1
+ape_smear warning: assuming default argument alpha=0.7
+ape_smear warning: assuming default argument cooling_steps=10
+topological_charge_vtk warning: assuming default argument prefix=topological_charge
+topological_charge_vtk warning: assuming default argument t=-1
*/
#include "fermiqcd.h"
int main(int argc, char** argv) {
mdp.open_wormholes(argc,argv);
string filename;
coefficients coeff;
int L[]={4,4,4,4};
mdp_lattice spacetime(4,L);
int nc=3;
gauge_field U(spacetime,nc);
set_hot(U);
for(int i0=0; i0<10; i0++) {
coeff["beta"]=5.0;
WilsonGaugeAction::heatbath(U,coeff,1);
mdp << "average_plaquette=" << average_plaquette(U) << endl;
}
for(int i0=0; i0<10; i0++) {
ApeSmearing::smear(U,0.7,1,10);
U.save("test*");
mdp << "average_plaquette=" << average_plaquette(U) << endl;
{float tc=topological_charge_vtk(U,"topological_charge*",-1);
mdp << "total topological charge=" << tc << endl; }
}
mdp.close_wormholes();
return 0;
}
|
310e72bd9af27aa1f87727fbf415c361a923a5bc
|
171b27ba265922de7836df0ac14db9ac1377153a
|
/include/eve/module/real/core/function/regular/simd/x86/average.hpp
|
4e553b8a75798d157ef9bf7ffdb673c5af835dda
|
[
"MIT"
] |
permissive
|
JPenuchot/eve
|
30bb84af4bfb4763910fab96f117931343beb12b
|
aeb09001cd6b7d288914635cb7bae66a98687972
|
refs/heads/main
| 2023-08-21T21:03:07.469433
| 2021-10-16T19:36:50
| 2021-10-16T19:36:50
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,392
|
hpp
|
average.hpp
|
//==================================================================================================
/*
EVE - Expressive Vector Engine
Copyright : EVE Contributors & Maintainers
SPDX-License-Identifier: MIT
*/
//==================================================================================================
#pragma once
#include <eve/detail/overload.hpp>
#include <eve/detail/abi.hpp>
#include <eve/forward.hpp>
#include <eve/detail/skeleton.hpp>
#include <eve/concept/value.hpp>
#include <eve/detail/apply_over.hpp>
namespace eve::detail
{
template<unsigned_scalar_value T, typename N>
EVE_FORCEINLINE wide<T, N> average_(EVE_SUPPORTS(sse2_), wide<T, N> a, wide<T, N> b) noexcept
requires x86_abi<abi_t<T, N>>
{
if constexpr ( sizeof(T) == 2 )
{
if constexpr ( std::same_as<abi_t<T, N>, x86_512_> ) return _mm512_avg_epu16(a, b);
else if constexpr ( current_api >= avx2 && std::same_as<abi_t<T, N>, x86_256_> ) return _mm256_avg_epu16(a, b);
else if constexpr ( std::same_as<abi_t<T, N>, x86_128_> ) return _mm_avg_epu16 (a, b);
else return average_ (EVE_RETARGET(cpu_), a, b);
}
if constexpr ( sizeof(T) == 1 )
{
if constexpr ( std::same_as<abi_t<T, N>, x86_512_> ) return _mm512_avg_epu8 (a, b);
else if constexpr ( current_api >= avx2 && std::same_as<abi_t<T, N>, x86_256_> ) return _mm256_avg_epu8 (a, b);
else if constexpr ( std::same_as<abi_t<T, N>, x86_128_> ) return _mm_avg_epu8 (a, b);
else return average_ (EVE_RETARGET(cpu_), a, b);
}
else return average_(EVE_RETARGET(cpu_), a, b);
}
// -----------------------------------------------------------------------------------------------
// Masked case
template<conditional_expr C, real_scalar_value T, typename N>
EVE_FORCEINLINE
wide<T, N> average_(EVE_SUPPORTS(sse2_), C const &cx, wide<T, N> const &v, wide<T, N> const &w) noexcept
requires x86_abi<abi_t<T, N>>
{
constexpr auto c = categorize<wide<T, N>>();
if constexpr( C::is_complete || abi_t<T, N>::is_wide_logical )
{
return average_(EVE_RETARGET(cpu_),cx,v,w);
}
else
{
auto src = alternative(cx,v,as<wide<T, N>>{});
auto m = expand_mask(cx,as<wide<T, N>>{}).storage().value;
if constexpr(c && category::float_ ) return if_else(cx,eve::average(v, w),src);
else if constexpr(c && category::int_ ) return if_else(cx,eve::average(v, w),src);
else if constexpr(c == category::uint16x32 ) return _mm512_mask_avg_epu16(src,m,v,w);
else if constexpr(c == category::uint16x16 ) return _mm256_mask_avg_epu16(src,m,v,w);
else if constexpr(c == category::uint16x8 ) return _mm_mask_avg_epu16 (src,m,v,w);
else if constexpr(c == category::uint8x64 ) return _mm512_mask_avg_epu8 (src,m,v,w);
else if constexpr(c == category::uint8x32 ) return _mm256_mask_avg_epu8 (src,m,v,w);
else if constexpr(c == category::uint8x16 ) return _mm_mask_avg_epu8 (src,m,v,w);
else if constexpr(c && category::uint_ ) return if_else(cx,eve::average(v, w),src);
}
}
}
|
168ec887e2d9160cce01a41a5672fc9e8a0527c3
|
e0dca452f8ebf10b8575576b688053ab523c33fc
|
/tests/MockCopier/AllTests.cpp
|
bbdd4093b14f8f70d3ee1fd70a13aa603f963ca5
|
[] |
no_license
|
KevinWMatthews/CppUTest-examples
|
8c44dcd8b858e2fbbf77fb89644eee6366bbd4e6
|
fb85efa23b2f5a7a0529627bbd18a447c77e6d33
|
refs/heads/master
| 2020-03-08T04:58:01.300712
| 2018-04-10T15:11:44
| 2018-04-10T15:11:44
| 127,935,558
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 840
|
cpp
|
AllTests.cpp
|
#include "CppUTest/CommandLineTestRunner.h"
#include "CppUTest/TestPlugin.h"
#include "CppUTest/TestRegistry.h"
#include "CppUTestExt/MockSupportPlugin.h"
#include "SomeStructCopier.h"
#include "SomeStructInitParamsComparator.h"
#include "HiddenStructCopier.h"
int main(int ac, char **av)
{
SomeStructCopier some_struct_copier;
SomeStructInitParamsComparator some_struct_init_params_comparator;
HiddenStructCopier hidden_struct_copier;
MockSupportPlugin mockPlugin;
mockPlugin.installCopier("SOME_STRUCT", some_struct_copier);
mockPlugin.installComparator("SOME_STRUCT_INIT_PARAMS", some_struct_init_params_comparator);
mockPlugin.installCopier("HIDDEN_STRUCT", hidden_struct_copier);
TestRegistry::getCurrentRegistry()->installPlugin(&mockPlugin);
return CommandLineTestRunner::RunAllTests(ac, av);
}
|
32c2cd95c9bd3b48a1a7579b2bd4919d5010d063
|
f9359a88f0f81929eb73774e8685b11d532cbab4
|
/configurator.cpp
|
b47775ee5b4fa6e30a8ab47ef034fc3858175d15
|
[] |
no_license
|
newmen/diamond_easy
|
63991d18d154896d31a69c849d7f0c826c4ea76d
|
9d1c787cc46786b9d41d4bbedeb4c8e31bee0684
|
refs/heads/master
| 2020-05-07T17:19:55.399512
| 2013-05-07T06:39:44
| 2013-05-07T06:39:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,589
|
cpp
|
configurator.cpp
|
/*
* configurator.cpp
*
* Created on: 30.05.2011
* Author: newmen
*/
#include <boost/regex.hpp>
#include <sstream>
#include "configurator.h"
#include "parse_error.h"
#include "parse_params_error.h"
namespace DiamondCA {
Configurator::Configurator() : _need_help(false), _config_file_name(CONFIG_FILE),
_initial_spec(INITIAL_SPEC),
// _steps(STEPS), _any_step(ANY_STEP),
_full_time(FULL_TIME), _any_time(ANY_TIME),
_prefix("")
{
_automata_config["dimers-form-drop"] = true;
_automata_config["hydrogen-migration"] = true;
_automata_config["activate-surface"] = true;
_automata_config["deactivate-surface"] = true;
_automata_config["methyl-adsorption"] = true;
_automata_config["bridge-migration"] = true;
_automata_config["bridge-migration-up-down"] = true;
_outputer_config["only-info"] = false;
_outputer_config["only-specs"] = false;
_outputer_config["clear-output-buffers"] = false;
_outputer_config["without-area"] = false;
_outputer_config["without-info"] = false;
_outputer_config["with-specs"] = false;
}
void Configurator::parseParams(int argc, char* argv[]) {
_program_name = argv[0];
boost::regex rx_help("-h|--help");
boost::regex rx_config_file_name("(-c|--config)=([\\/\\w\\._-]+)");
boost::regex rx_size_x("(-x|--size-x)=(\\d+)");
boost::regex rx_size_y("(-y|--size-y)=(\\d+)");
boost::regex rx_size_z("(-z|--size-z)=(\\d+)");
boost::regex rx_spec("(-is|--spec)=([*H]{2})");
// boost::regex rx_steps("(-st|--steps)=(\\d+)");
// boost::regex rx_any_step("(-as|--any-step)=(\\d+)");
boost::regex rx_ft("(-ft|--full-time)=([\\d\\.]+)");
boost::regex rx_at("(-at|--any-time)=([\\d\\.]+)");
boost::regex rx_wo_dfd("-wo-dfd|--without-dimers-form-drop");
boost::regex rx_wo_hm("-wo-hm|--without-hydrogen-migration");
boost::regex rx_wo_as("-wo-as|--without-activate-surface");
boost::regex rx_wo_ds("-wo-ds|--without-deactivate-surface");
boost::regex rx_wo_ma("-wo-ma|--without-methyl-adsorption");
boost::regex rx_wo_bm("-wo-bm|--without-bridge-migration");
boost::regex rx_wo_bm_ud("-wo-bm-ud|--without-bridge-migration-up-down");
boost::regex rx_oi("-oi|--only-info");
boost::regex rx_os("-os|--only-specs");
boost::regex rx_cob("-cob|--clear-output-buffers");
boost::regex rx_wo_a("-wo-a|--without-area");
boost::regex rx_wo_i("-wo-i|--without-info");
boost::regex rx_w_s("-w-s|--with-specs");
boost::regex rx_migration_test("--migration-test");
boost::regex rx_prefix("^([^-][\\S]*)$");
for (int i = 1; i < argc; ++i) {
std::string current_param = argv[i];
boost::smatch matches;
if (boost::regex_match(current_param, matches, rx_help)) _need_help = true;
else if (boost::regex_match(current_param, matches, rx_config_file_name)) _config_file_name = matches[2];
else if (boost::regex_match(current_param, matches, rx_size_x)) _sizes.x = atoi(matches[2].str().c_str());
else if (boost::regex_match(current_param, matches, rx_size_y)) _sizes.y = atoi(matches[2].str().c_str());
else if (boost::regex_match(current_param, matches, rx_size_z)) _sizes.z = atoi(matches[2].str().c_str());
else if (boost::regex_match(current_param, matches, rx_spec)) _initial_spec = matches[2];
// else if (boost::regex_match(current_param, matches, rx_steps)) _steps = atoi(matches[2].str().c_str());
// else if (boost::regex_match(current_param, matches, rx_any_step)) _any_step = atoi(matches[2].str().c_str());
else if (boost::regex_match(current_param, matches, rx_ft)) _full_time = atof(matches[2].str().c_str());
else if (boost::regex_match(current_param, matches, rx_at)) _any_time = atof(matches[2].str().c_str());
else if (boost::regex_match(current_param, matches, rx_wo_dfd)) _automata_config["dimers-form-drop"] = false;
else if (boost::regex_match(current_param, matches, rx_wo_hm)) _automata_config["hydrogen-migration"] = false;
else if (boost::regex_match(current_param, matches, rx_wo_as)) _automata_config["activate-surface"] = false;
else if (boost::regex_match(current_param, matches, rx_wo_ds)) _automata_config["deactivate-surface"] = false;
else if (boost::regex_match(current_param, matches, rx_wo_ma)) _automata_config["methyl-adsorption"] = false;
else if (boost::regex_match(current_param, matches, rx_wo_bm)) _automata_config["bridge-migration"] = false;
else if (boost::regex_match(current_param, matches, rx_wo_bm_ud)) _automata_config["bridge-migration-up-down"] = false;
else if (boost::regex_match(current_param, matches, rx_oi)) _outputer_config["only-info"] = true;
else if (boost::regex_match(current_param, matches, rx_os)) _outputer_config["only-specs"] = true;
else if (boost::regex_match(current_param, matches, rx_cob)) _outputer_config["clear-output-buffers"] = true;
else if (boost::regex_match(current_param, matches, rx_wo_a)) _outputer_config["without-area"] = true;
else if (boost::regex_match(current_param, matches, rx_wo_i)) _outputer_config["without-info"] = true;
else if (boost::regex_match(current_param, matches, rx_w_s)) _outputer_config["with-specs"] = true;
else if (i == argc - 1 && boost::regex_match(current_param, matches, rx_prefix)) _prefix = matches[1];
else throw ParseParamsError("Undefined parameter", current_param);
}
if (_outputer_config["only-info"] && _outputer_config["only-specs"]) {
throw ParseError("Cannot use -oi (--only-info) with -os (--only-specs)");
}
}
std::string Configurator::help() const {
std::stringstream result;
result << "Расчёт процесса роста кристалла алмаза CVD методом клеточного автомата\n"
<< "(c) 2009-2012 РХТУ им. Д.И. Менделеева, каф. ИКТ, Г.Ю. Аверчук\n"
<< "\n"
<< "Запуск программы:\n"
<< " " << _program_name << " [параметры] [префикс_выходных_файлов]\n"
<< "\n"
<< "Параметры:\n"
<< " -h, --help - эта справка\n"
<< "\n"
<< " -c=конфигурационный_файл, --config=конфигурационный_файл - задаёт конфигурационный файл "
<< "(по умолчанию "<< _config_file_name << ")\n"
<< "\n"
<< "Размеры автомата, заменяют указанные в конфигурационном файле\n"
<< " -x=число, --size-x=число - размер автомата по X\n"
<< " -y=число, --size-x=число - размер автомата по Y\n"
<< " -z=число, --size-x=число - размер автомата по Z\n"
<< "\n"
<< " -is=содержание, --spec=содержание - инициализация нижнего слоя углеродов активными связями и водородом, "
<< "общее количество активных связей и водорода должно быть равно двум (по умолчанию "
<< _initial_spec << ")\n"
<< "\n"
// << " -st=число, --steps=число - число шагов по времени (по умолчанию " << _steps << ")\n"
// << " -as=число, --any-step=число - вывод результатов, когда шаг кратен этому значению"
// << "(по умолчанию " << _any_step << ")\n"
<< " -ft=число, --full-time=число - количество рассчитываемых секунд процесса (по умолчанию "
<< _full_time << ")\n"
<< " -at=число, --any-time=число - вывод результатов, когда время кратно этому значению секунд (по умолчанию "
<< _any_time << ")\n"
<< "\n"
<< " -wo-dfd, --without-dimers-form-drop - не использовать образование/рызрыв димеров\n"
<< " -wo-hm, --without-hydrogen-migration - не использовать миграцию водорода по димеру\n"
<< " -wo-as, --without-activate-surface - не активировать поверхность водородом газовой фазы\n"
<< " -wo-ds, --without-deactivate-surface - не деактивировать поверхность водородом газовой фазы\n"
<< " -wo-ma, --without-methyl-adsorption - не осаждать метил радикал\n"
<< " -wo-bm, --without-bridge-migration - отменить миграцию мостовой группы\n"
<< " -wo-bm-ud, --without-bridge-migration-up-down - отменить миграцию мостовой группы вверх-вниз "
<< "(миграция вверх-вниз не работает без \"обычной\" миграции)\n"
<< "\n"
<< " -oi, --only-info - выводить информацию в стандартный поток вывода и не сохранять выходные файлы\n"
<< " -os, --only-specs - выводить содержащиеся виды в стандартный поток вывода и не сохранять выходные файлы\n"
<< "\n"
<< " -cob, --clear-output-buffers - отчищать каждый раз буфер, при сохранении выходных файлов\n"
<< "\n"
<< " -wo-a, --without-area - не сохранять файл для визуализации\n"
<< " -wo-i, --without-info - не сохранять инфо\n"
<< " -w-s, --with-specs - сохранять содержащиеся виды в текстовом виде\n";
return result.str();
}
}
|
d6911fd37d1f6a547099d4998f29c9a4c1d1edb8
|
4a963c126bd43b990a7c55a281870f77b4d7eed0
|
/ctrldesk/cli.cpp
|
f21f4d170019a3ad7bd3683c0dd3b64b715b886e
|
[] |
no_license
|
Arancreat/ctrldesk
|
eb9e8395a6a94e348cca81d7514ffba3afcf831c
|
ca5c04a1583a2033abed2ad6178742c5b72cb8a2
|
refs/heads/master
| 2023-03-03T23:44:22.217161
| 2021-02-16T08:57:06
| 2021-02-16T08:57:06
| 337,785,858
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,569
|
cpp
|
cli.cpp
|
#include "cli.h"
//Private
string CLI::ConvertWideToUtf8(wstring wstr)
{
if (wstr.empty())
{
return string();
}
int count = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wstr.c_str(), (int)wstr.size(), NULL, 0, NULL, NULL);
string str;
if (count)
{
str.resize(count);
if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wstr.c_str(), (int)wstr.size(), &str[0], count, NULL, NULL))
{
return str;
}
}
return string();
}
wstring CLI::ConvertUtf8ToWide(string str)
{
if (str.empty())
{
return wstring();
}
int count = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.c_str(), (int)str.size(), NULL, 0);
wstring wstr;
if (count)
{
wstr.resize(count);
if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.c_str(), (int)str.size(), &wstr[0], count))
{
return wstr;
}
}
return wstring();
}
//Public
CLI::CLI()
{
}
DWORD CLI::getError()
{
return dwError;
}
bool CLI::checkForErrors()
{
if ((dwError != ERROR_NO_MORE_FILES) && (dwError != 0))
{
return true;
}
return false;
}
vector <string> CLI::getPath(vector <string> argv_vector)
{
vector <string> path_vector;
wstring targetPath;
wstring targetFormat;
WIN32_FIND_DATA ffd;
HANDLE hFind = INVALID_HANDLE_VALUE;
// If the directory is not specified as a command-line argument,
// print usage.
if (argv_vector.size() != 2)
{
string thisProgName = argv_vector[0].substr(argv_vector[0].rfind("\\") + 1);
cout << "Usage: " << thisProgName << " <directory name>" << endl;
dwError = 11;
return path_vector;
}
// Check that the input path plus 7 is not longer than MAX_PATH.
// Three characters are for the "\*" plus NULL appended below.
if (argv_vector[1].length() > (MAX_PATH - 7))
{
cout << "Directory path is too long." << endl;
dwError = 11;
return path_vector;
}
// Prepare string for use with FindFile functions. First, copy the
// string to a buffer, then append '\*' to the directory name.
targetPath = ConvertUtf8ToWide(argv_vector[1]);
targetPath = ConvertUtf8ToWide(argv_vector[1]);
if (targetPath[targetPath.size() - 1] != '\\' &&
targetPath[targetPath.size() - 1] != '/')
{
targetPath = targetPath + L"\\";
}
targetFormat = L"*.bmp";
wcout << L"Target directory is " << targetPath + targetFormat << endl;
// Find the first file in the directory.
hFind = FindFirstFileW((targetPath + targetFormat).c_str(), &ffd);
if (INVALID_HANDLE_VALUE == hFind)
{
dwError = GetLastError();
cout << "FindFirstFile ERROR: " << dwError << endl;
return path_vector;
}
// List all the files in the directory with some info about them.
do
{
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
string fullPath = ConvertWideToUtf8(targetPath + ffd.cFileName);
path_vector.push_back(fullPath);
}
} while (FindNextFileW(hFind, &ffd) != 0);
dwError = GetLastError();
if (dwError != ERROR_NO_MORE_FILES)
{
cout << "FindNextFile ERROR: " << dwError << endl;
}
FindClose(hFind);
#ifdef _DEBUG
for (vector <string>::iterator iter = path_vector.begin(); iter != path_vector.end(); ++iter)
{
cout << " " + *iter << endl;
}
#endif // _DEBUG
return path_vector;
}
|
8a81e5732b64e77e63488c5b13a554431536d8b4
|
920fe5fac4eb93493b14905801ca9f13a4dd2d11
|
/src/p10789.cpp
|
d6020a5eb002eeb8a630c52f75e951d3a81d83c1
|
[] |
no_license
|
jamesdjuhartono/UVa-Problems
|
e11ec667178f608c5dd59c5f9bb7268e6e6bb61f
|
96ec3552d13b3141d82fad91824ae64e8063170e
|
refs/heads/master
| 2021-01-13T02:30:06.934691
| 2014-06-10T08:05:04
| 2014-06-10T08:05:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,479
|
cpp
|
p10789.cpp
|
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
bool prime[1000000];
void fill_prime()
{
for(int i = 0; i < 1000000; i++)
prime[i] = true;
prime[0] = false; prime[1] = false;
for(int i = 2; i < 1000000; i++)
{
if(prime[i])
{
for(int j = 2*i; j < 1000000; j += i)
prime[j] = false;
}
}
}
int main()
{
int numCase;
int freq[63];
string input, output;
char ch;
fill_prime();
cin >> numCase;
getline(cin,input);
for(int i = 0; i < numCase; i++)
{
getline(cin,input);
memset(freq,0,sizeof freq);
for(int j = 0; j < input.length(); j++)
{
ch = input.at(j);
if((int)ch >= 48 && ch <= 57)
freq[(int)ch-48]++;
else if((int)ch >= 65 && ch <= 90)
freq[(int)ch - 55]++;
else
freq[(int)ch - 61]++;
}
output = "";
for(int j = 0; j < 63; j++)
{
if(prime[freq[j]])
{
if(j >= 0 && j <= 9)
output += (char)(j+48);
else if(j >= 10 && j <= 35)
output += (char)(j+55);
else
output += (char)(j+61);
}
}
if(output == "") output = "empty";
cout << "Case " << (i+1) << ": " << output << endl;
}
return 0;
}
|
cadb6eb716f7d799eef8afe0f2d6c2f99180782d
|
8596f63928ef8a3bf643322516dbe2d7011caec3
|
/114.flatten-binary-tree-to-linked-list.cpp
|
78f1d004d33ae8bcd98694e0aba2863428abe41b
|
[] |
no_license
|
Joory2016/MyLeetCode
|
0965777bc9608ef937aa3045c85cbd7bb687a68d
|
1e7fe42b31ba25295acff4930465a65cd3da4df9
|
refs/heads/master
| 2020-06-01T06:44:21.112925
| 2019-07-15T10:58:16
| 2019-07-15T10:58:16
| 190,684,218
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,695
|
cpp
|
114.flatten-binary-tree-to-linked-list.cpp
|
/*
* @lc app=leetcode id=114 lang=cpp
*
* [114] Flatten Binary Tree to Linked List
*/
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution
{
public:
void flatten(TreeNode *root)
{
TreeNode *last = nullptr;
preOrder(root, last);
}
private:
void preOrder(TreeNode *node, TreeNode *&last)
{
if (!node)
return;
if (!node->left && !node->right)
{
last = node;
return;
}
TreeNode *left = node->left;
TreeNode *right = node->right;
TreeNode *left_last = nullptr;
TreeNode *right_last = nullptr;
if (left)
{
preOrder(left, left_last);
node->left = nullptr;
node->right = left;
last = left_last;
}
if (right)
{
preOrder(right, right_last);
if (left_last)
{
left_last->right = right;
}
last = right_last;
}
}
};
/*
class Solution
{
public:
void flatten(TreeNode *root)
{
vector<TreeNode *> v;
preOrder(root, v);
v.push_back(nullptr);
for (int i = 0; i < v.size() - 1; i++)
{
v[i]->right = v[i + 1];
v[i]->left = nullptr;
}
}
void preOrder(TreeNode *node, vector<TreeNode *> &v)
{
if (node == nullptr)
return;
v.push_back(node);
preOrder(node->left, v);
preOrder(node->right, v);
}
};
*/
|
cada1a57315336d5da0e4a0bf979f43095aee953
|
c46fe10e8074e4a1deacb68054c10c1aa978347b
|
/InputExample/inputcontex/iconfont/iconhelper.h
|
504adc8c6e3d7948100d9edc5ca19179f9eb8db9
|
[] |
no_license
|
birdman1992/toolmodules
|
bc5c6cd13cacae75ff7675b8df6beee81987cae9
|
532105dcafd4e8e40ade41d3bc38371a5af5c7c4
|
refs/heads/master
| 2021-09-19T01:42:53.796967
| 2021-08-13T14:10:22
| 2021-08-13T14:10:22
| 97,546,453
| 1
| 1
| null | 2020-04-27T12:30:03
| 2017-07-18T03:04:10
|
C++
|
UTF-8
|
C++
| false
| false
| 1,147
|
h
|
iconhelper.h
|
#ifndef ICONHELPER_H
#define ICONHELPER_H
#include <QObject>
#include <QFont>
#include <QFontDatabase>
#include <QMutex>
#include <QLabel>
#include <QIcon>
#include <QList>
#include <QPushButton>
#include <QApplication>
class IconHelper:public QObject
{
Q_OBJECT
private:
explicit IconHelper(QObject *parent = 0);
QList<QFont> lstFont;
QFont iconFont;
static IconHelper* _instance;
QFont loadFont(QString fontSrc);
void initFonts();
public:
static IconHelper* Instance()
{
static QMutex mutex;
if(!_instance)
{
QMutexLocker locker(&mutex);
if(!_instance)
{
_instance = new IconHelper;
}
}
return _instance;
}
void SetIcon(QLabel* lab, QChar c, int size = 10, QString color="#ffffff", QString backGroundColor="#00000000");
void SetIcon(QPushButton* btn, QChar c, int size = 10, QString color="#ffffff", QString backGroundColor="#00000000");
QIcon GetIcon(int backGroundSize, QChar c, int fontSize, QString color="#ffffff", QString backGroundColor="#00000000");
};
#endif // ICONHELPER_H
|
fc1e7321b27c6dbc7e996d57f50a22822dfddc7e
|
7454f4cb2e49186ce11013469fc8508d458b48a5
|
/src/lib/utils/column_ids_after_pruning.hpp
|
1e23941e26886cdbfceab85cc17d5580a1dabfde
|
[
"MIT"
] |
permissive
|
bengelhaupt/hyrise
|
0f8f5af736dae0b98adb09627c8e9d4d52fea822
|
dc2b6d9f205b9f31f989dc8821b6167ad7202fab
|
refs/heads/master
| 2023-07-15T11:40:23.813975
| 2021-08-24T17:07:19
| 2021-08-24T17:07:19
| 373,451,697
| 1
| 0
|
MIT
| 2021-08-24T10:28:11
| 2021-06-03T09:27:16
|
C++
|
UTF-8
|
C++
| false
| false
| 504
|
hpp
|
column_ids_after_pruning.hpp
|
#pragma once
#include "types.hpp"
namespace opossum {
// Stores the updated ColumnID at the index of the original ID if the original column was not pruned.
// If the original column with ColumnID c was pruned, the id_mapping vector contains nullopt at index c.
std::vector<std::optional<ColumnID>> column_ids_after_pruning(const size_t original_table_column_count,
const std::vector<ColumnID>& pruned_column_ids);
} // namespace opossum
|
63b62a4030170f5785cf234716aa976b681db10e
|
bcf138c82fcba9acc7d7ce4d3a92618b06ebe7c7
|
/gta5/0xB096419DF0D06CE7.cpp
|
33372ddf06d3efc73602293e43cf0b4711ea937f
|
[] |
no_license
|
DeepWolf413/additional-native-data
|
aded47e042f0feb30057e753910e0884c44121a0
|
e015b2500b52065252ffbe3c53865fe3cdd3e06c
|
refs/heads/main
| 2023-07-10T00:19:54.416083
| 2021-08-12T16:00:12
| 2021-08-12T16:00:12
| 395,340,507
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 412
|
cpp
|
0xB096419DF0D06CE7.cpp
|
// main_persistent.ysc @ L332066
void func_5245()
{
int iVar0;
if ((func_5260(Global_110719) != 4 || func_5259(Global_110719) < 40) || func_5259(Global_110719) > 50)
{
iVar0 = Global_110719;
func_5250(&iVar0, 0, 2, 0, 0, 0, 0);
CLOCK::SET_CLOCK_TIME(func_5260(iVar0), func_5259(iVar0), func_5249(iVar0));
CLOCK::SET_CLOCK_DATE(func_5248(iVar0), func_5247(iVar0), func_5246(iVar0));
}
}
|
a155e908b2e55c8765f2eef0596788f57ea7338c
|
9aea695ff093bd979e923a5fcfc0b2319d2309cf
|
/src/browse.cpp
|
3da421a757b6ad60c0b92514b9f6602c57f1e6e6
|
[] |
no_license
|
Sedisan/TODO
|
11be865c4652ef6a1d634ad9e2990e9e2ecb8209
|
d19c25c9aa928d5871f3f16b1e08bc8825650a96
|
refs/heads/master
| 2020-03-14T13:39:34.617312
| 2018-05-02T14:45:46
| 2018-05-02T14:45:46
| 131,637,352
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,793
|
cpp
|
browse.cpp
|
#include "../Header/header_for_all_files.hpp"
void Browse::make_basic_activity(Keep &keep, std::vector<Keep> & vector_with_all_activity, std::string day)
{
std::string var_to_split = OpenFile().get_all_lines_from_file(StaticClassToTest::name_of_base);
auto splitted_vector = OpenFile().split_file_by_delimeter(var_to_split, "\n");
std::cout << "Enter day(only day's number e.g. 30) you want to find: ";
unsigned int temp_variable_to_load = StaticClassToTest::load_variable_with_limit<unsigned int>(31);
std::string string_representation = std::to_string(temp_variable_to_load);
char first = '0';
if (temp_variable_to_load > 10)
first = string_representation[0];
auto number_of_lines = OpenFile().size_of_file(StaticClassToTest::name_of_base) + 1;
bool found = false;
unsigned long long counter = 0;
for(unsigned long long start_from = 0; start_from < number_of_lines; start_from += 28){
auto number = std::find_if(splitted_vector.begin() + counter ,splitted_vector.end(), [&](auto x)
{
counter++;
if (temp_variable_to_load > 10){
if(string_representation[0]-'0' == x[0]-'0' && string_representation[1]-'0' == x[1]-'0')
return true;
}
else{
if(first == x[0])
return true;
}
return false;
});
if(number != std::end(splitted_vector)){
std::cout << "Number: " << *number << " " << "was found at the: " << counter << " position" << '\n';
found = true;
}
}
if(!found)
std::cout << "Day not found\n";
}
|
166997d265796bb6090430bf239d6e1ca2cf4dd7
|
037c7a8bc39146c31449e248f8a9c025ec1c01d0
|
/02.device/c++/chapter8/ex03_deepcopy.cpp
|
374604a7017483e095fe643c8a7e4b344c5b0994
|
[] |
no_license
|
cooluks2/iot
|
e62874624bc06acbe5647fed35f6ec62bd582e7f
|
e452b29f0c6967dad9b11207c3b5189cec385497
|
refs/heads/master
| 2023-01-22T17:19:58.456577
| 2020-11-20T11:36:34
| 2020-11-20T11:36:34
| 292,755,019
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 368
|
cpp
|
ex03_deepcopy.cpp
|
class MyArray{
public:
int size;
int *data;
MyArray(const MyArray& other){
size = other.size;
data = new int[other.size];
for(int i=0; i<size; i++){
data[i] = other.data[i]; // 복사 생성자 호출
}
}
~MyArray(){
if(data != NULL){
delete []data;
}
}
};
|
a7566006177418f98c731df48228df50917de81b
|
1584d1af83996c63adb25973cc61abf31c6364d8
|
/BaseDefender/common/QuadTree.h
|
e457cd9514c763c73edd85a0b5ef9aa1058e2ed3
|
[] |
no_license
|
bcboschTU/BaseDeffender
|
2275c0d45531fe0e0076248e99168e634615d108
|
a441ae3d2fecac4e7d2d7e858c6297b549266d36
|
refs/heads/master
| 2020-04-10T11:55:30.064199
| 2015-06-02T11:34:15
| 2015-06-02T11:34:15
| 31,467,799
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 957
|
h
|
QuadTree.h
|
//
// QuadTree.h
// BaseDefender
//
// Created by Bert Bosch on 03-03-15.
// Copyright (c) 2015 Bossos. All rights reserved.
//
#ifndef __BaseDefender__QuadTree__
#define __BaseDefender__QuadTree__
#include <stdio.h>
#include <vector>
#include "Bullet.h"
class QuadtreeBullet {
public:
QuadtreeBullet(float x, float y, float width, float height, int level, int maxLevel, int maxObjects);
void AddObject(Bullet *object);
std::vector<Bullet*> GetObjectsAt(float x, float y);
void empty();
private:
float x;
float y;
float width;
float height;
int level;
int maxLevel;
int maxObjects;
bool nextLevel;
bool addedChildern;
std::vector<Bullet*> objects;
QuadtreeBullet * parent;
QuadtreeBullet * NW;
QuadtreeBullet * NE;
QuadtreeBullet * SW;
QuadtreeBullet * SE;
bool contains(QuadtreeBullet *child, Bullet *object);
};
#endif /* defined(__BaseDefender__QuadTree__) */
|
09accffc7532d66cd0dcd639e356b118013009e5
|
9e5ec0f973fdd062760a607a6cfc086abd61a257
|
/src/AHZArmorInfo.cpp
|
3ef8f416bd0ee9a706205bbde9f5382fdfb971c2
|
[
"MIT"
] |
permissive
|
ahzaab/moreHUDSE
|
c3f42ffd74942a49a1238c29eb75b75cdcb3ddca
|
0b6995a8628cec786f822d2e177eae46dcee0569
|
refs/heads/master
| 2023-02-03T06:43:57.914016
| 2023-01-31T16:02:46
| 2023-01-31T16:02:46
| 107,052,110
| 4
| 5
|
MIT
| 2022-09-22T22:39:56
| 2017-10-15T21:56:24
|
C++
|
UTF-8
|
C++
| false
| false
| 2,619
|
cpp
|
AHZArmorInfo.cpp
|
#include "pch.h"
#include "AHZTarget.h"
#include "AHZArmorInfo.h"
auto CAHZArmorInfo::GetWornExtraList(RE::BSSimpleList<RE::ExtraDataList*>* extraList) -> RE::ExtraDataList*
{
if (extraList) {
for (auto entryListIT = extraList->begin(); entryListIT != extraList->end(); ++entryListIT) {
auto extraData = *entryListIT;
if (extraData &&
(extraData->HasType(RE::ExtraDataType::kWorn) || extraData->HasType(RE::ExtraDataType::kWornLeft))) {
return extraData;
}
}
}
return nullptr;
}
auto CAHZArmorInfo::GetArmorFromSlotMask(RE::BIPED_MODEL::BipedObjectSlot slotMask) -> AHZArmorData
{
AHZArmorData data;
auto pPC = RE::PlayerCharacter::GetSingleton();
if (!pPC)
return data;
auto inventoryChanges = pPC->GetInventoryChanges();
RE::TESBoundObject* armor;
if (inventoryChanges) {
auto list = inventoryChanges->entryList;
if (list) {
for (auto it = list->begin(); it != list->end(); ++it) {
auto element = *it;
if (element) {
if (element->object && (element->object->GetFormType() == RE::FormType::Armor || element->object->GetFormType() == RE::FormType::Light)) {
auto form = element->object->As<RE::BGSBipedObjectForm>();
if (form && (static_cast<uint32_t>(form->GetSlotMask()) & static_cast<uint32_t>(slotMask))) {
armor = element->object;
auto wornList = GetWornExtraList(element->extraLists);
if (wornList && armor) {
data.equipData.boundObject = armor;
data.equipData.pExtraData = wornList;
if (data.equipData.boundObject) {
if (data.equipData.boundObject->GetFormType() == RE::FormType::Armor) {
data.armor = data.equipData.boundObject->As<RE::TESObjectARMO>();
}
if (data.equipData.boundObject->GetFormType() == RE::FormType::Light) {
data.torch = data.equipData.boundObject->As<RE::TESObjectLIGH>();
}
}
return data;
}
}
}
}
}
}
}
return data;
}
|
08473746d00438f4816fdada0096ae0e44752ce1
|
b8653e310e55f38af2ef26e6a1ccc67b97870bb8
|
/lib/my_objects_lib/Panel.cpp
|
e30ae4498e3d4921efb95efc6ef2566311b931ca
|
[] |
no_license
|
MonkeYKonG/Enchiladas-s-shmup
|
d73221038d3eb5412418b639215610050317e8e9
|
509f6f54d2d3853e49e2ce3d93722b7e1ea06160
|
refs/heads/master
| 2021-09-03T10:51:19.146507
| 2018-01-08T12:41:14
| 2018-01-08T12:41:14
| 106,934,528
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,562
|
cpp
|
Panel.cpp
|
#include "Panel.hpp"
namespace my
{
Panel::Panel()
{}
Panel::~Panel()
{}
bool Panel::IsIntersect(const sf::Vector2f & point) const noexcept
{
return (false);
}
bool Panel::IsIntersect(const sf::FloatRect & square) const noexcept
{
return (false);
}
const sf::FloatRect Panel::GetHitBox() const noexcept
{
return (sf::FloatRect());
}
SpriteObject::SpriteObjectPtr Panel::GetBackground() const noexcept
{
return (m_background);
}
Border::BorderPtr Panel::GetBorder() const noexcept
{
return (m_border);
}
TextObject::TextObjectPtr Panel::GetTitle() const noexcept
{
return (m_title);
}
const Panel::SpriteButtons &Panel::GetSpriteButtons() const noexcept
{
return (m_spriteButtons);
}
const Panel::TextButtons &Panel::GetTextButtons() const noexcept
{
return (m_textButtons);
}
const Panel::TextList &Panel::GetTexts() const noexcept
{
return (m_texts);
}
const Panel::SpriteList &Panel::GetSprites() const noexcept
{
return (m_sprites);
}
const Panel::ProgressBarList &Panel::GetProgressBars() const noexcept
{
return (m_progressBars);
}
void Panel::SetBackground(SpriteObject::SpriteObjectPtr background) noexcept
{
m_background = background;
}
void Panel::SetBorder(Border::BorderPtr border) noexcept
{
m_border = border;
}
void Panel::SetTitle(TextObject::TextObjectPtr title) noexcept
{
m_title = title;
m_title->SetOrigin(m_title->GetText().getGlobalBounds().width / 2, m_title->GetText().getGlobalBounds().height / 2);
if (m_background)
m_title->setPosition(0, -m_background->GetSprite().getGlobalBounds().height / 2 + m_title->GetText().getGlobalBounds().height);
}
void Panel::SetSpriteButtons(const Panel::SpriteButtons & buttons) noexcept
{
m_spriteButtons = buttons;
}
void Panel::AddSpriteButton(const Panel::PanelSpriteButton & newButton) noexcept
{
m_spriteButtons.push_back(newButton);
}
void Panel::SetTextButtons(const Panel::TextButtons & buttons) noexcept
{
m_textButtons.clear();
for (unsigned i = 0; i < buttons.size(); ++i)
AddTextButton(buttons[i]);
}
void Panel::AddTextButton(const Panel::TextButton & newButton) noexcept
{
m_textButtons.push_back(newButton);
newButton->SetOrigin(newButton->GetText().getGlobalBounds().width / 2, newButton->GetText().getGlobalBounds().height / 2);
}
void Panel::SetTexts(const Panel::TextList & texts) noexcept
{
m_texts.clear();
for (unsigned i = 0; i < texts.size(); ++i)
AddText(texts[i]);
}
void Panel::AddText(const TextObject::TextObjectPtr & newText) noexcept
{
m_texts.push_back(newText);
newText->SetOrigin(0, newText->GetText().getGlobalBounds().height / 2);
}
void Panel::SetSprites(const SpriteList & sprites) noexcept
{
m_sprites.clear();
for (unsigned i = 0; i < sprites.size(); ++i)
AddSprite(sprites[i]);
}
void Panel::AddSprite(const SpriteObject::SpriteObjectPtr & newSprite) noexcept
{
m_sprites.push_back(newSprite);
newSprite->SetOrigin(newSprite->GetHitBox().width / 2, newSprite->GetHitBox().height / 2);
}
void Panel::SetProgressBars(const ProgressBarList & progressBars) noexcept
{
m_progressBars.clear();
for (unsigned i = 0; i < progressBars.size(); ++i)
AddProgressBars(progressBars[i]);
}
void Panel::AddProgressBars(const ProgressBar::ProgressBarPtr & newProgressBar) noexcept
{
m_progressBars.push_back(newProgressBar);
}
void Panel::UpdateBackground() noexcept
{
if (!m_background)
return;
m_background->Update();
}
void Panel::UpdateBorder() noexcept
{
if (!m_border)
return;
m_border->Update();
}
void Panel::UpdateTitle() noexcept
{
if (!m_title)
return;
m_title->Update();
}
void Panel::UpdateSpriteButtons(const sf::Vector2f & mousePos) noexcept
{
for (unsigned i = 0; i < m_spriteButtons.size(); ++i)
m_spriteButtons[i]->Update(mousePos);
}
void Panel::UpdateTextButtons(const sf::Vector2f & mousePos) noexcept
{
for (unsigned i = 0; i < m_textButtons.size(); ++i)
m_textButtons[i]->Update();
}
void Panel::UpdateButtons(const sf::Vector2f & mousePos) noexcept
{
UpdateSpriteButtons(mousePos);
UpdateTextButtons(mousePos);
}
void Panel::UpdateSprites() noexcept
{
for (unsigned i = 0; i < m_sprites.size(); ++i)
m_sprites[i]->Update();
}
void Panel::UpdateProgressBars() noexcept
{
for (unsigned i = 0; i < m_progressBars.size(); ++i)
m_progressBars[i]->Update();
}
void Panel::Update(const sf::Vector2f & mousePos) noexcept
{
sf::Vector2f tranfromedMousePos;
tranfromedMousePos = getTransform().getInverse().transformPoint(mousePos);
UpdateBackground();
UpdateBorder();
UpdateTitle();
UpdateButtons(tranfromedMousePos);
UpdateSprites();
UpdateProgressBars();
}
void Panel::draw(sf::RenderTarget & target, sf::RenderStates states) const noexcept
{
if (!m_visible)
return;
Node::draw(target, states);
states.transform *= getTransform();
if (m_background)
target.draw(*m_background, states);
if (m_border)
target.draw(*m_border, states);
if (m_title)
target.draw(*m_title, states);
for (unsigned i = 0; i < m_spriteButtons.size(); ++i)
target.draw(*m_spriteButtons[i], states);
for (unsigned i = 0; i < m_textButtons.size(); ++i)
target.draw(*m_textButtons[i], states);
for (unsigned i = 0; i < m_texts.size(); ++i)
target.draw(*m_texts[i], states);
for (unsigned i = 0; i < m_sprites.size(); ++i)
target.draw(*m_sprites[i], states);
for (unsigned i = 0; i < m_progressBars.size(); ++i)
target.draw(*m_progressBars[i], states);
}
}
|
c5e02cff1d130f189fdd4c16007ccf431bb641cc
|
7ab41799fd38489c93282f1beb3b20e7ef8ff165
|
/cpp/76.cpp
|
281f26930350c41a4ae46279962b52a46592ac8f
|
[] |
no_license
|
scturtle/leetcode-sol
|
86c4095df6b31a9fcad683f2d63669ce1691633c
|
e1a9ce5d9b8fe4bd11e50bd1d5ba1933de845db7
|
refs/heads/master
| 2020-04-23T00:01:37.016267
| 2015-11-21T04:15:27
| 2015-11-21T04:15:27
| 32,385,573
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,124
|
cpp
|
76.cpp
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <utility>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <climits>
#include <numeric>
using namespace std;
template<typename T>
void prints(vector<T> &v){
cout << "[";
for(uint i=0; i<v.size()-1; ++i)
cout << v[i] << ", ";
if(v.size()) cout << v[v.size()-1];
cout << "]\n";
}
class Solution {
public:
string minWindow(string S, string T) {
map<char, int> tcnt;
for(auto &c : T) ++tcnt[c];
map<char, int> scnt;
int l = 0, r = 0, todo = tcnt.size(),
ans = INT_MAX, ansl = -1, ansr = -1;
while(r < S.length()){
++scnt[S[r]];
if(scnt[S[r]] == tcnt[S[r]])
--todo;
++r;
if(todo == 0){
while(scnt[S[l]] > tcnt[S[l]])
--scnt[S[l++]];
if(r-l < ans)
ans = r-l, ansl = l, ansr = r;
--scnt[S[l++]]; ++todo;
}
}
if(ans != INT_MAX)
return S.substr(ansl, ansr - ansl);
else
return "";
}
};
int main(){
auto sol = Solution();
cout << sol.minWindow("a", "aa");
}
|
c8ec3dbaaef7144e23b326e695430c83504b71e2
|
76a5686e643a6e2903eb17990a16b2bc40368fe9
|
/tool12-scanTest4 (dataformat)/src/testApp.h
|
cbf1a4af8d0b086c96b26c4492aa76e370d37632
|
[] |
no_license
|
carlesgutierrez/HanRiver-openFrameworks
|
cb42aeaef06d6cf1d9679e2fb0cb3e629e1dcb0c
|
0fc4ba45846d9b9bfa67e3fcef674fbea7ba7a1d
|
refs/heads/master
| 2021-01-17T21:32:57.938974
| 2012-05-09T05:21:39
| 2012-05-09T05:21:39
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 857
|
h
|
testApp.h
|
#pragma once
#include "ofMain.h"
#include "ofxOsc.h"
#include "ofxCvGui.h"
#define SERVER_PORT 5588
#define CLIENT_PORT 5588 + 1
#include "ofxGraycode.h"
#include "CameraHead.h"
using namespace ofxGraycode;
class testApp : public ofBaseApp {
public:
~testApp();
void setup();
void update();
void draw();
void keyPressed (int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
void processInput();
void moveThreshold(int distance);
ofxCvGui::Builder gui;
ofxOscReceiver rx;
ofxOscSender tx;
string remoteIp;
PayloadGraycode payload;
vector<ofPtr<CameraHead> > cameras;
};
|
af9ccea58a866b24e83bb7f1b9341fed844b45f3
|
aa7817e54c6bdb42a9983c7ea8ee71131e414c30
|
/rod-cut/main.cpp
|
d9cc622824dd49331238d7bbbea29def2463b51a
|
[] |
no_license
|
mndxpnsn/cut-rod
|
37aa9e279a644b7b9aadda9266e4be7ae0565616
|
7fe6da2afbe8d154152fbaed06cbd1923a9f3f56
|
refs/heads/master
| 2023-08-20T05:17:28.393386
| 2021-10-26T11:04:03
| 2021-10-26T11:04:03
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,375
|
cpp
|
main.cpp
|
//
// main.cpp
// rod-cut
//
// Created by mndx on 26/10/2021.
//
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include "cut_rod.hpp"
#include "cut_rod_ref.hpp"
#include "user_types.hpp"
int main(int argc, char* argv[]) {
int N = 100; //Total length of the rod
int *A = new int[N]; //Cost array for the rod
//Arrays to store solution
bool *rod_cut_at = new bool[N+1];
int *cut_counter = new int[N+1];
//Initialize cost array with random numbers
srand((unsigned) time(NULL));
for(int i = 0; i < N; ++i) {
A[i] = rand() % 4 + (5*i)/2;
}
//Get maximum revenue
int max_rev = get_optimum_solution(N, A, rod_cut_at, cut_counter);
//Print results
printf("total length of rod n: %d\n", N);
printf("total revenue: %d\n", max_rev);
for(int i = 0; i < N + 1; ++i) {
if(rod_cut_at[i] == true) {
printf("rod cut at %i a total of %i times\n", i, cut_counter[i]);
}
}
//Print reference solution
print_cut_rod_sol(A, N);
//Verify computation
int total_rev = 0;
for(int i = 1; i < N + 1; ++i) {
if(rod_cut_at[i] == true) {
total_rev = total_rev + cut_counter[i]*A[i-1];
}
}
printf("total revenue verification: %i\n", total_rev);
printf("done\n");
return 0;
}
|
eab880f84d95ccd64f4c1bcaf8a1424eb256df94
|
029fffd176559418ed867631eac063ed895f88a8
|
/Input/TransformInputDialog.h
|
a6516b53fbcb087b329bca1a713080abd240531c
|
[] |
no_license
|
CISMM/sketchbio
|
451200a8c9cf3a96abb221e11917e10dd1d80a2d
|
eb40df18ecd38750fe7597f51d59e0041afa9aef
|
refs/heads/main
| 2023-06-26T23:35:31.301054
| 2021-07-29T13:50:03
| 2021-07-29T13:50:03
| 390,739,422
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,638
|
h
|
TransformInputDialog.h
|
#ifndef TRANSFORMINPUTDIALOG_H
#define TRANSFORMINPUTDIALOG_H
#include <QDialog>
#include <QVector>
class QDoubleSpinBox;
class TransformInputDialog : public QDialog
{
Q_OBJECT
public:
// Creates a new TransformInputDialog with the given title
explicit TransformInputDialog(const QString &title,QWidget *parent = 0);
// Gets the translation of the transform as a vector. The parameter should
// be an array of length >=3 (the first 3 positions will be overwritten)
void getTranslation(double *out);
// Gets the rotation of the transform input as a vector. The parameter
// should be an array of length >= 3 (the first 3 positions will be overwritten)
void getRotation(double *out);
// Sets the translation of the transform from the given 3-vector. This
// assumes the parameter is the address of the first of 3 doubles
void setTranslation(double *in);
// Sets the rotation of the transform from the given 3-vector. This
// assumes the parameter is the address of the first of 3 doubles
void setRotation(double *in);
signals:
// emitted when Ok is pressed to send the resulting transform via a signal
void transformAquired(double xTranslation, double yTranslation,
double zTranslation, double xRotation,
double yRotation, double zRotation);
public slots:
void emitTransformAndClose();
private:
QDoubleSpinBox *makeTransformationEditBox(bool inputIsAngle = false);
QVector< QDoubleSpinBox * > translate;
QVector< QDoubleSpinBox * > rotate;
};
#endif // TRANSFORMINPUTDIALOG_H
|
1ab8014419e2ffb3bfea2b2f0de24681c619d735
|
449dbc9c7d26de12588ac27c4628ce75da0629c6
|
/db/Db_redis.cpp
|
8123d3aa16f00e9467e0d32f7c22c2cfbe2e3a52
|
[
"BSD-3-Clause"
] |
permissive
|
berak/opencv_smallfry
|
fde87d2b9aa0698cfc3cdd2d3ac286e0da7e0509
|
2653a3b823499d1412c5a1d6dd977502d88d6590
|
refs/heads/master
| 2022-07-07T23:41:39.914141
| 2022-07-03T19:58:06
| 2022-07-03T19:58:06
| 12,484,192
| 61
| 28
| null | 2019-01-16T07:01:08
| 2013-08-30T10:39:40
|
C
|
UTF-8
|
C++
| false
| false
| 4,811
|
cpp
|
Db_redis.cpp
|
//
//
#include "opencv2/core/core.hpp"
#include "birds/birds.h"
#include "opencv_db.h"
#include <cstdio>
#include <iostream>
using namespace cv;
using namespace std;
//
// table and image names get concatenated to a key: "tab.img"
// each item is a list: type,w,h,pixels(binary) (RPUSH,LRANGE,LINDEX,..)
//
struct RedisDb : opencv_db
{
int port;
int sock;
int _readline( char *line )
{
int nb = 0;
line[0] = 0;
while(true)
{
int b = Birds::ReadByte(sock);
if ( b < 0 )
break;
if ( b == '\r' )
continue;
if ( b == '\n' )
break;
line[nb] = b;
nb ++;
}
line[nb]=0;
return nb;
}
bool _error( const char *a=0, const char *b=0 )
{
if ( a ) cerr << a;
if ( b ) cerr << " " << b;
cerr << endl;
return false;
}
bool _result()
{
char line[500];
_readline(line);
if ( (line[0]!='+' || line[2]!='K') && (line[0]!=':') )
return _error(line);
return true;
}
bool _handshake(const string &mes)
{
int n = Birds::Write(sock, (char*)mes.c_str(), 0);
if ( n<=0 )
return _error("writing", mes.c_str() );
return _result();
}
RedisDb(int port=6379) : port(port),sock(-1) {}
~RedisDb() { close();}
virtual bool open( const char * db, const char * host, const char * user, const char * pw )
{
sock = Birds::Client((char*)host,port);
if ( sock < 0 )
return _error("connecting to ", host );
if ( pw && pw[0] )
{
string msg(format("auth %s\r\n", pw ));
if ( Birds::Write(sock,(char*)msg.c_str(),0)<1 )
return false;
}
if ( ! _result() )
return false;
// try to select the db, if it was a number:
int dbn = -1;
sscanf(db,"%i",&dbn);
if ( dbn > -1 )
{
string mes = format(
"*2\r\n"
"$6\r\n"
"SELECT\r\n"
"$1\r\n"
"%d\r\n", dbn );
if ( ! _handshake(mes) )
return false;
}
return true;
}
virtual bool write( const char * table, const char * name, const cv::Mat & mat )
{
string key = format("%s.%s",table,name);
string t = format("%d",mat.type());
string w = format("%d",mat.cols);
string h = format("%d",mat.rows);
int numbytes = mat.total() * mat.elemSize();
// my 'prepared statements' look pretty much like gnu assembler ;)
string stmt_pre = format(
"*6\r\n"
"$5\r\n"
"RPUSH\r\n"
"$%d\r\n"
"%s\r\n"
"$%d\r\n"
"%s\r\n"
"$%d\r\n"
"%s\r\n"
"$%d\r\n"
"%s\r\n"
"$%d\r\n", key.length(),key.c_str(),
t.length(),t.c_str(),
w.length(),w.c_str(),
h.length(),h.c_str(),numbytes);
Birds::Write(sock,(char*)stmt_pre.c_str(),stmt_pre.length());
Birds::Write(sock,(char*)mat.data,numbytes);
Birds::Write(sock,"\r\n",2);
return _result();
}
virtual bool read ( const char * table, const char * name, cv::Mat & mat )
{
string key = format("%s.%s",table,name);
string stmt_pre = format(
"*4\r\n"
"$6\r\n"
"LRANGE\r\n"
"$%d\r\n"
"%s\r\n"
"$1\r\n"
"0\r\n"
"$1\r\n"
"3\r\n", key.length(),key.c_str());
Birds::Write(sock,(char*)stmt_pre.c_str(),stmt_pre.length());
int t=0,w=0,h=0,nb=0;
char line[600];
_readline(line);
if ( line[0]!='*' || line[1]!='4' )
return _error("key not found : ",key.c_str());
_readline(line);//$1
_readline(line); t=atoi(line);
_readline(line);//$1
_readline(line); w=atoi(line);
_readline(line);//$1
_readline(line); h=atoi(line);
_readline(line); nb=atoi(line+1);
if ( nb<1 )
return _error("protocol error, expected: $num_bytes : ", line);
mat.create(h,w,t);
uchar *d = mat.data;
for ( int bread=0; bread<nb; bread++ )
{
*d++ = Birds::ReadByte(sock); // TODO: read blocks
}
_readline(line); // flush last linebreak
return !mat.empty();
}
virtual bool close()
{
return Birds::Close(sock)!=0;
}
};
Ptr<opencv_db> createRedisDb(int port=6379) { return makePtr<RedisDb>(port); }
|
70d1e842ac5cdebcbd12e0e0cbfe3487ab9e0de9
|
c6f08f2bb8b812bcb63a6216fbd674e1ebdf00d8
|
/ni_header/NiShaderToolkit.h
|
f9f64cd333db7421ea93928492c02434a0fe1a7e
|
[] |
no_license
|
yuexiae/ns
|
b45e2e97524bd3d5d54e8a79e6796475b13bd3f9
|
ffeb846c0204981cf9ae8033a83b2aca2f8cc3ac
|
refs/heads/master
| 2021-01-19T19:11:39.353269
| 2016-06-08T05:56:35
| 2016-06-08T05:56:35
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,620
|
h
|
NiShaderToolkit.h
|
// NUMERICAL DESIGN LIMITED PROPRIETARY INFORMATION
//
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Numerical Design Limited and may not
// be copied or disclosed except in accordance with the terms of that
// agreement.
//
// Copyright (c) 1996-2004 Numerical Design Limited.
// All Rights Reserved.
//
// Numerical Design Limited, Chapel Hill, North Carolina 27514
// http://www.ndl.com
#ifndef NISHADERTOOLKIT_H
#define NISHADERTOOLKIT_H
#pragma warning( disable : 4786)
#include "NiShaderToolkitLibType.h"
#include <NiTStringMap.h>
#include "NiShaderHelpers.h"
class NiShaderLibraryDesc;
class NiShaderDesc;
class NISHADERTOOLKIT_ENTRY NiShaderToolkit
{
public:
static NiShaderToolkit* CreateToolkit();
static void DestroyToolkit();
static NiShaderToolkit* GetToolkit();
void LoadFromDLL(const char* pcShaderPath);
void ReIndex();
static void ReloadShaders();
static void UnloadShaders();
NiShaderLibraryDesc* GetLibraryDesc(const char* pcName);
NiShaderLibraryDesc* GetLibraryDescAt(unsigned int uiWhichLibrary);
const char* GetLibraryNameAt(unsigned int uiWhichLibrary);
unsigned int GetLibraryDescCount();
NiShaderDesc* GetShaderDesc(const char* pcName);
void DeleteShaderDesc(NiShaderDesc* pkDesc);
const char* GetAppStringForShaderDesc(const char* pcName);
bool SetAppStringForShaderDesc(const char* pcName,
const char* pcAppDesc);
void SetShaderDirectory(const char* pcDir, bool bAppend = false);
static void UpdateShaderDirectory();
protected:
class NiShaderLibraryContainer
{
public:
NiShaderLibraryContainer();
~NiShaderLibraryContainer();
NiShaderLibraryDesc * m_pkLibraryDesc;
};
class NiShaderDescContainer
{
public:
NiShaderDescContainer();
~NiShaderDescContainer();
NiShaderDesc* m_pkDesc;
char* m_pcApplicationDescription;
};
NiShaderToolkit();
NiShaderToolkit(NiShaderToolkit& kToolkit);
~NiShaderToolkit();
bool ParseNPShaders(const char* pcLibraryPath,
const char* pcShaderPath);
void LoadShaders();
void UnIndex();
static NiShaderToolkit* ms_pkThis;
char* m_pcShaderPath;
char* m_pcShaderProgramPath;
bool m_bAppendSubdir;
bool m_bUpdateShaderProgramDir;
NiTStringPointerMap<NiShaderLibraryContainer*> m_kLibraries;
NiTStringPointerMap<NiShaderDescContainer*> m_kShaderDescCache;
};
#endif
|
a345cbdda8d81655d8b96b76710c02c269e78826
|
045945f2556a0f03e08b5f251fa295016ba1b4a1
|
/src/models/andortree.h
|
d0677c67d0062056323c5ce5028bcfc364088625
|
[] |
no_license
|
Rextuz/And-or-Tree
|
50d792305955971741ee0f75f1e447e790652428
|
2a93b95358ccb5df8b2165ee646f8b40b45ae551
|
refs/heads/master
| 2021-03-24T12:45:31.587590
| 2017-06-16T22:09:04
| 2017-06-16T22:09:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,265
|
h
|
andortree.h
|
#ifndef ANDORTREE_H
#define ANDORTREE_H
#include <QJsonObject>
#include "node.h"
// Polymorphic tree container
namespace kkcs {
template <class T>
class AndOrTree
{
private:
Node<T> *root;
AndOrTree(AndOrTree const&);
AndOrTree& operator= (AndOrTree const&);
public:
AndOrTree(NodeType type)
{
root = new Node<T>(nullptr, type);
}
AndOrTree(Node<T> *root)
{
this->root = root;
}
size_t size() {
return root->size() + 1;
}
Node<T> *addNode(Node<T> *parent, NodeType type)
{
Node<T> *newNode = new Node<T>(parent, type);
parent->addChild(newNode);
return newNode;
}
Node<T> *addLeaf(Node<T> *parent, T *data)
{
Node<T> *newNode = new Node<T>(parent, data);
parent->addChild(newNode);
return newNode;
}
typename Node<T>::Iterator begin() {
return root->begin();
}
typename Node<T>::Iterator end() {
return root->end();
}
// Returns root element
Node<T> *getRoot()
{
return root;
}
void setRootType(NodeType type)
{
root->setType(type);
}
// Tree destructor
~AndOrTree()
{
delete root;
}
};
}
#endif // ANDORTREE_H
|
8a46320636897e03e5cb876b5e0ac01bb7c36f6a
|
abaa47fb6e684f280036cdc4c5fe7f2083f56d06
|
/day04/ex01/srcs/Undead.cpp
|
2e6d415f313e77ceb3c5e24fcf1009744c3d0564
|
[] |
no_license
|
Althis974/PiscineCPP
|
91b4015a1b96f0e39289a1463e61a67edd03c741
|
b4fc4e44a8be4882275b22260b82bba9821fdc98
|
refs/heads/master
| 2020-09-13T08:38:15.834788
| 2020-02-05T11:12:23
| 2020-02-05T11:12:23
| 222,714,310
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,574
|
cpp
|
Undead.cpp
|
/* ************************************************************************** */
/* LE - / */
/* / */
/* Undead.cpp .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: rlossy <rlossy@student.le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2019/12/12 17:32:13 by rlossy #+# ## ## #+# */
/* Updated: 2019/12/12 17:32:13 by rlossy ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "../includes/Undead.hpp"
// Constructor
Undead::Undead() : Enemy("Undead", 100)
{
std::cout << "Braiiiiiiinnnssss..." << std::endl;
}
// Copy constructor
Undead::Undead(const Undead &src) : Enemy(src)
{
std::cout << "Braiiiiiiinnnssss..." << std::endl;
}
// Destructor
Undead::~Undead()
{
std::cout << "Aaaaarggggghhh..." << std::endl;
}
Undead & Undead::operator=(const Undead &rhs)
{
Enemy::operator=(rhs);
return (*this);
}
// takeDamage overload
void Undead::takeDamage(int damage)
{
damage - 5 > 0 ? this->_hp -= damage - 5 : 0;
this->_hp < 0 ? this->_hp = 0 : 0;
}
|
0eb8f136350ffc8ca9b5ed68953b93ec4a5ad9ea
|
0107598661343ef29e33f4b45ad88d3159383147
|
/programmi usati/DHT11/DHT11.ino
|
1945ee29020eb1c2076270d325e9b5d422201d01
|
[] |
no_license
|
CampanelliEmanuele/High-school-graduation-project
|
f31616242f6e126b8fbe1b02e06fb39b1f540343
|
dc524a61e58465fb7f88dc9d2d05156c86464e11
|
refs/heads/main
| 2023-08-03T01:32:20.242390
| 2021-09-19T01:40:58
| 2021-09-19T01:40:58
| 350,371,457
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 716
|
ino
|
DHT11.ino
|
#include <SimpleDHT.h>
SimpleDHT11 dht11;
#include <LiquidCrystal.h>
LiquidCrystal lcd (7, 6, 5, 4, 3, 2);
bool FIRST = true;
byte t = 0;
byte h = 0;
void setup() {
Serial.begin(9600);
lcd.begin(16,2);
}
void loop() {
int err = SimpleDHTErrSuccess;
if ((err = dht11.read(9, &t, &h, NULL)) != SimpleDHTErrSuccess){
Serial.println("ERR");
delay(1000);
return;
}
Serial.print("t: ");
Serial.print((int)t);
Serial.print("°C h: ");
Serial.print((int)h);
Serial.println("% ");
delay(1500);
lcd.clear();
lcd.print("Temp: "); lcd.print(t); lcd.print(".C");
lcd.setCursor(0,1);
lcd.print("Humidity: "); lcd.print(h); lcd.print("%");
}
|
5638bd4dbc2e54db256c7d91f9fd6650efc3632c
|
03602b1b1350a4a7500da9625580f96adc48e765
|
/src/main/moc_mainview.cpp
|
a2578af6788bbfb8e73b635b031299d8be1d474e
|
[] |
no_license
|
fernandobt8/cg
|
c70e9314619615332f866ddcee935957cec90ee8
|
0fc45d5b0e423d80b4e8878484ed470ab6b14304
|
refs/heads/master
| 2021-01-22T08:14:22.645410
| 2020-09-21T22:46:04
| 2020-09-21T22:46:04
| 18,000,422
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,396
|
cpp
|
moc_mainview.cpp
|
/****************************************************************************
** Meta object code from reading C++ file 'MainView.h'
**
** Created: Wed May 14 22:51:37 2014
** by: The Qt Meta Object Compiler version 63 (Qt 4.8.4)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "MainView.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'MainView.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.4. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_MainView[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
12, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: signature, parameters, type, tag, flags
10, 9, 9, 9, 0x0a,
32, 9, 9, 9, 0x0a,
57, 9, 9, 9, 0x0a,
81, 9, 9, 9, 0x0a,
105, 9, 9, 9, 0x0a,
130, 9, 9, 9, 0x0a,
154, 9, 9, 9, 0x0a,
180, 9, 9, 9, 0x0a,
207, 9, 9, 9, 0x0a,
236, 9, 9, 9, 0x0a,
267, 9, 9, 9, 0x0a,
295, 9, 9, 9, 0x0a,
0 // eod
};
static const char qt_meta_stringdata_MainView[] = {
"MainView\0\0on_upButton_clicked()\0"
"on_rightButton_clicked()\0"
"on_downButton_clicked()\0on_leftButton_clicked()\0"
"on_forthButton_clicked()\0"
"on_backButton_clicked()\0"
"on_zoomInButton_clicked()\0"
"on_zoomOutButton_clicked()\0"
"on_adicionarButton_clicked()\0"
"on_transformarButton_clicked()\0"
"on_windowOkButton_clicked()\0"
"on_rotacionarButton_clicked()\0"
};
void MainView::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
MainView *_t = static_cast<MainView *>(_o);
switch (_id) {
case 0: _t->on_upButton_clicked(); break;
case 1: _t->on_rightButton_clicked(); break;
case 2: _t->on_downButton_clicked(); break;
case 3: _t->on_leftButton_clicked(); break;
case 4: _t->on_forthButton_clicked(); break;
case 5: _t->on_backButton_clicked(); break;
case 6: _t->on_zoomInButton_clicked(); break;
case 7: _t->on_zoomOutButton_clicked(); break;
case 8: _t->on_adicionarButton_clicked(); break;
case 9: _t->on_transformarButton_clicked(); break;
case 10: _t->on_windowOkButton_clicked(); break;
case 11: _t->on_rotacionarButton_clicked(); break;
default: ;
}
}
Q_UNUSED(_a);
}
const QMetaObjectExtraData MainView::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject MainView::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_MainView,
qt_meta_data_MainView, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &MainView::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *MainView::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *MainView::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_MainView))
return static_cast<void*>(const_cast< MainView*>(this));
if (!strcmp(_clname, "OnAdicionarObjetoTipoEvent"))
return static_cast< OnAdicionarObjetoTipoEvent*>(const_cast< MainView*>(this));
if (!strcmp(_clname, "OnOkTransformcaoEvent"))
return static_cast< OnOkTransformcaoEvent*>(const_cast< MainView*>(this));
return QWidget::qt_metacast(_clname);
}
int MainView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 12)
qt_static_metacall(this, _c, _id, _a);
_id -= 12;
}
return _id;
}
QT_END_MOC_NAMESPACE
|
003e65e1a3c3f67c925dc5758b1c631e88688f73
|
2dd21c84aea35b1c140e1e937f56bd49605a614c
|
/include/Contrac_twopoint.h
|
82c7a03ccc30157172f40069f843896b59ac54a6
|
[] |
no_license
|
CT0322/coupled_4channel_code
|
e7c9fb3c7b6298a96103e7824f1492adce3b2150
|
461638a06e59a8b31873e00d7f3e72a319f06776
|
refs/heads/master
| 2021-01-20T06:17:53.867865
| 2017-05-25T04:57:43
| 2017-05-25T04:57:43
| 89,864,193
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,319
|
h
|
Contrac_twopoint.h
|
/*
* Contrac_twopoint.h
*
* Created on: Mar 26, 2013
* Author: knippsch
*/
#ifndef CONTRAC_TWOPOINT_H_
#define CONTRAC_TWOPOINT_H_
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <typeinfo>
#include <fstream>
#include <Eigen/Dense>
#include <Eigen/Core>
#include <Eigen/SparseCore>
#include "GlobalData.h"
#include "propagator_io.h"
#include "quark.h"
/******* two point contractions ************/
Eigen::VectorXcd Contractions_TwoPoint_SiSiSoSo(int, Eigen::MatrixXcd* , Eigen::MatrixXcd*);
Eigen::VectorXcd Contractions_TwoPoint_SoSoSiSi(int, Eigen::MatrixXcd* , Eigen::MatrixXcd*);
Eigen::VectorXcd Contractions_TwoPoint_SoSiSiSo(int, Eigen::MatrixXcd* , Eigen::MatrixXcd*);
Eigen::VectorXcd Contractions_TwoPoint_SiSoSoSi(int, Eigen::MatrixXcd* , Eigen::MatrixXcd*);
std::complex<double> Contractions_TwoPoint_SiSiSoSo(int, int, Eigen::MatrixXcd* , Eigen::MatrixXcd*);
std::complex<double> Contractions_TwoPoint_SoSoSiSi(int, int, Eigen::MatrixXcd* , Eigen::MatrixXcd*);
std::complex<double> Contractions_TwoPoint_SoSiSiSo(int, int, Eigen::MatrixXcd* , Eigen::MatrixXcd*);
std::complex<double> Contractions_TwoPoint_SiSoSoSi(int, int, Eigen::MatrixXcd* , Eigen::MatrixXcd*);
#endif /* CONTRAC_TWOPOINT_H_ */
|
1982abc1c9c844c7cbce84cba67173b4966b0178
|
3cbea0497545c00ffc87fe1fa8a74dfe88dc9509
|
/454_4SumII.cpp
|
87abad016b405ed1c60f505f0a291a1f0aeed73c
|
[] |
no_license
|
yuhenghuang/Leetcode
|
40b954676feb3a2ef350188a6d86dadc44e84d71
|
3c5aafa7969a5a1eb01106676a5b94d404d07d9f
|
refs/heads/master
| 2023-08-30T18:17:16.209053
| 2023-08-25T01:05:49
| 2023-08-25T01:05:49
| 249,166,616
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 763
|
cpp
|
454_4SumII.cpp
|
#include "utils.hpp"
#include <unordered_map>
class Solution {
private:
unordered_map<int, int> product(const vector<int>& a, const vector<int>& b) {
unordered_map<int, int> m;
for (int i=0; i<a.size(); ++i)
for (int j=0; j<b.size(); ++j)
++m[a[i]+b[j]];
return m;
}
public:
int fourSumCount(vector<int>& A, vector<int>& B, vector<int>& C, vector<int>& D) {
unordered_map<int, int> m1 = product(A, B);
unordered_map<int, int> m2 = product(C, D);
int res = 0;
for (const auto& p : m1) {
auto q = m2.find(-p.first);
if (q!=m2.end())
res += p.second * q->second;
}
return res;
}
};
int main() {
UFUNC(Solution::fourSumCount);
return 0;
}
|
6ac0d3933a77aa5ff4b2a792decb4a04f9fc96ab
|
5e7098aa1d4cac17873f77a626d95e97f2d5c07b
|
/dijkstra.cpp
|
b7cc1312d3cad3b84c5924c7a0376ce53c98e145
|
[] |
no_license
|
vartulbiet/uva
|
e73f82ae5f0b9d82baa9612be73322574919a91d
|
85d3328185cbf9df8b0e18a1902b27dcd6b6eb68
|
refs/heads/master
| 2016-09-03T07:13:04.510472
| 2015-07-09T06:52:42
| 2015-07-09T06:52:42
| 38,802,883
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,419
|
cpp
|
dijkstra.cpp
|
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<map>
using namespace std;
int arr[100][100];
int ans;
int r,c;
int dist[100][100];
int m,n;
map<pair<int,int>,bool>mymap;
int find_set(int*arr,int m)
{
if(arr[m] == m)
return m;
else
return arr[m] = find_set(arr,arr[m]);
}
void merge_set(int*arr,int m,int n)
{
arr[find_set(arr,m)] = find_set(arr,n);
}
void kruskals()
{
vector<pair<int,pair<int,int> > >vec;
for(int i =0;i<m;i++)
{
for(int j =0;j<m;j++)
{
if(dist[i][j]>0)
{
pair<int,pair<int,int> >p;
pair<int,int>x;
x.first= i;
x.second =j;
p.first =dist[i][j];
p.second =x;
vec.push_back(p);
}
}
}
int arr[m];
for(int i =0;i<m;i++)
arr[i] = i;
ans =0;
sort(vec.begin(),vec.end());
while(vec.size()!=0)
{
pair<int,pair<int,int> >p = vec.front();
vec.erase(vec.begin());
if(find_set(arr,p.second.first)!=find_set(arr,p.second.second))
{
ans +=p.first;
merge_set(arr,p.second.first,p.second.second);
//cout<<p.second.first<<"--"<<p.second.second<<endl;
}
}
}
void min_dist()
{
std::map<pair<int,int>,bool>::iterator it;
std::map<pair<int,int>,bool>::iterator bt;
ans = 0;m =0;n=0;
for(it = mymap.begin();it!=mymap.end();it++ )
{
int sum =0;m;n =0;
for(bt = mymap.begin();bt!=mymap.end();bt++)
{
dist[m][n++] = max(abs(bt->first.first-it->first.first),abs(bt->first.second-it->first.second));
}
m++;
}
m =n =mymap.size();
}
void func()
{
for(int i =0;i<r;i++)
{
for(int j =0;j<c;j++)
{
pair<int,int>p =make_pair(i,j);
if(arr[i][j] == 1)
{
mymap[p] = true;
// cout<<i<<" "<<j<<endl;
}
}
}
}
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
cin>>r>>c;
for(int i =0;i<r;i++)
{
for(int j =0;j<c;j++)
{
cin>>arr[i][j];
}
}
func();
min_dist();
kruskals();
cout<<ans<<endl;
return 0;
}
|
c74bb666ccdd3a81a7f7f7163d538265942bcdce
|
3cd21e6bcc24db8b9f71c1fef5232a37267ad66f
|
/interviewbit/KnightOnChessBoard.cpp
|
64da50634d98ebf2a931f6f78e7e70236bd394ad
|
[] |
no_license
|
nishantydv97/competitive_coding
|
4f3df9a140ca42cfb923af8669ebe386e1e1fb43
|
b4f07331087b7ee3b82cc6c286392736655048fb
|
refs/heads/master
| 2022-05-18T02:59:50.626798
| 2022-04-07T19:18:58
| 2022-04-07T19:18:58
| 101,529,239
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,284
|
cpp
|
KnightOnChessBoard.cpp
|
/*
Given any source point, (C, D) and destination point, (E, F) on a chess board, we need to find whether Knight can move to the destination or not.
Knight's movements on a chess board
The above figure details the movements for a knight ( 8 possibilities ).
If yes, then what would be the minimum number of steps for the knight to move to the said point.
If knight can not move from the source point to the destination point, then return -1.
Note: A knight cannot go out of the board.
Input Format:
The first argument of input contains an integer A.
The second argument of input contains an integer B.
=> The chessboard is of size A x B.
The third argument of input contains an integer C.
The fourth argument of input contains an integer D.
=> The Knight is initially at position (C, D).
The fifth argument of input contains an integer E.
The sixth argument of input contains an integer F.
=> The Knight wants to reach position (E, F).
Output Format:
If it is possible to reach the destination point, return the minimum number of moves.
Else return -1.
Constraints:
1 <= A, B <= 500
Example
Input 1:
A = 8
B = 8
C = 1
D = 1
E = 8
F = 8
Output 1:
6
Explanation 1:
The size of the chessboard is 8x8, the knight is initially at (1, 1) and the knight wants to reach position (8, 8).
The minimum number of moves required for this is 6.
*/
int Solution::knight(int A, int B, int C, int D, int E, int F) {
int row=A, col=B, x1=C-1, y1=D-1, x2=E-1, y2=F-1;
vector<vector<int>> vis(row, vector<int>(col, 0));
/*
for(auto i : vis){
for(auto j : i){
cout<<j<<" ";
}
cout<<"\n";
}
*/
//cout<<"target is "<<x2<<" "<<y2<<endl;
stack<pair<int, int>> stk1;
stack<pair<int, int>> stk2;
if(x1==x2 and y1==y2) return 0;
int cnt=0;
stk1.push(make_pair(x1, y1));
while(!stk1.empty() or !stk2.empty()){
/*
for(auto i : vis){
for(auto j : i){
cout<<j<<" ";
}
cout<<"\n";
}
*/
if(!stk1.empty()){
while(!stk1.empty()){
pair<int, int> p1=stk1.top();
if(p1.first==x2 and p1.second==y2) return cnt;
int i=p1.first;
int j=p1.second;
//cout<<i<<" "<<j<<endl;
stk1.pop();
//i-2, j+1
if(i-2>=0 and i-2<row and j+1>=0 and j+1<col and !vis[i-2][j+1]){
stk2.push(make_pair(i-2, j+1));
vis[i-2][j+1]=1;
}
//i-1, j+2
if(i-1>=0 and i-1<row and j+2>=0 and j+2<col and !vis[i-1][j+2]){
stk2.push(make_pair(i-1, j+2));
vis[i-1][j+2]=1;
}
//i+1, j+2
if(i+1>=0 and i+1<row and j+2>=0 and j+2<col and !vis[i+1][j+2]){
stk2.push(make_pair(i+1, j+2));
vis[i+1][j+2]=1;
}
//i+2, j+1
if(i+2>=0 and i+2<row and j+1>=0 and j+1<col and !vis[i+2][j+1]){
stk2.push(make_pair(i+2, j+1));
vis[i+2][j+1]=1;
}
//i+2, j-1
if(i+2>=0 and i+2<row and j-1>=0 and j-1<col and !vis[i+2][j-1]){
stk2.push(make_pair(i+2, j-1));
vis[i+2][j-1]=1;
}
//i+1, j-2
if(i+1>=0 and i+1<row and j-2>=0 and j-2<col and !vis[i+1][j-2]){
stk2.push(make_pair(i+1, j-2));
vis[i+1][j-2]=1;
}
//i-1, j-2
if(i-1>=0 and i-1<row and j-2>=0 and j-2<col and !vis[i-1][j-2]){
stk2.push(make_pair(i-1, j-2));
vis[i-1][j-2]=1;
}
//i-2, j-1
if(i-2>=0 and i-2<row and j-1>=0 and j-1<col and !vis[i-2][j-1]){
stk2.push(make_pair(i-2, j-1));
vis[i-2][j-1]=1;
}
}
cnt++;
}else{
while(!stk2.empty()){
pair<int, int> p1=stk2.top();
if(p1.first==x2 and p1.second==y2) return cnt;
int i=p1.first;
int j=p1.second;
//cout<<i<<" "<<j<<endl;
stk2.pop();
//i-2, j+1
if(i-2>=0 and i-2<row and j+1>=0 and j+1<col and !vis[i-2][j+1]){
stk1.push(make_pair(i-2, j+1));
vis[i-2][j+1]=1;
}
//i-1, j+2
if(i-1>=0 and i-1<row and j+2>=0 and j+2<col and !vis[i-1][j+2]){
stk1.push(make_pair(i-1, j+2));
vis[i-1][j+2]=1;
}
//i+1, j+2
if(i+1>=0 and i+1<row and j+2>=0 and j+2<col and !vis[i+1][j+2]){
stk1.push(make_pair(i+1, j+2));
vis[i+1][j+2]=1;
}
//i+2, j+1
if(i+2>=0 and i+2<row and j+1>=0 and j+1<col and !vis[i+2][j+1]){
stk1.push(make_pair(i+2, j+1));
vis[i+2][j+1]=1;
}
//i+2, j-1
if(i+2>=0 and i+2<row and j-1>=0 and j-1<col and !vis[i+2][j-1]){
stk1.push(make_pair(i+2, j-1));
vis[i+2][j-1]=1;
}
//i+1, j-2
if(i+1>=0 and i+1<row and j-2>=0 and j-2<col and !vis[i+1][j-2]){
stk1.push(make_pair(i+1, j-2));
vis[i+1][j-2]=1;
}
//i-1, j-2
if(i-1>=0 and i-1<row and j-2>=0 and j-2<col and !vis[i-1][j-2]){
stk1.push(make_pair(i-1, j-2));
vis[i-1][j-2]=1;
}
//i-2, j-1
if(i-2>=0 and i-2<row and j-1>=0 and j-1<col and !vis[i-2][j-1]){
stk1.push(make_pair(i-2, j-1));
vis[i-2][j-1]=1;
}
}
cnt++;
}
}
return -1;
}
|
ffaedad85a800c61f963047734c7068091e11155
|
39a0387458aeb07aeb8aebd195a3ce53109ef6c9
|
/Homework2/Solution/pq.cpp
|
bb30ff26e3ce093965de5aaf624cf74cfcf9f819
|
[] |
no_license
|
incesubaris/Analysis-of-Algorithms-I
|
943de5e3a289e90cb01d46ac08a33cbd998e7d85
|
7176c9dd328673f1ad9d33dababf937636c41084
|
refs/heads/main
| 2023-05-11T23:41:33.354908
| 2021-04-25T12:13:36
| 2021-04-25T12:13:36
| 318,811,590
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,956
|
cpp
|
pq.cpp
|
// priority-queue using vector implementation of binary heap
#include <bits/stdc++.h>
#include <vector>
using namespace std;
vector<double> taxi;
int size = -1;
// Function to return the index of the parent node of a given node
int parent(int i)
{
return (i - 1) / 2;
}
// Function to return the index of the left child of the given node
int leftChild(int i)
{
return ((2 * i) + 1);
}
// Function to return the index of the right child of the given node
int rightChild(int i)
{
return ((2 * i) + 2);
}
// Function to shift up the node in order to maintain the heap property
void shiftUp(int i)
{
while (i > 0 && taxi[parent(i)] > taxi[i])
{
// Swap parent and current node
swap(taxi[parent(i)], taxi[i]);
// Update i to parent of i
i = parent(i);
}
}
// Function to shift down the node in order to maintain the heap property
void shiftDown(int i)
{
int current = i;
// Left Child
int l = leftChild(i);
if (l <= size && taxi[l] < taxi[current])
{
current = l;
}
// Right Child
int r = rightChild(i);
if (r <= size && taxi[r] < taxi[current])
{
current = r;
}
// If i not same as current
if (i != current)
{
swap(taxi[i], taxi[current]);
shiftDown(current);
}
}
// Function to add a new taxi in the binary heap
void add(double p)
{
size = size + 1;
taxi.push_back(p);
// Shift Up to maintain heap property
shiftUp(size);
}
// Function to call the element with maximum priority
double call()
{
double called = taxi[0];
// Replace the value at the root with the last leaf
swap(taxi[0], taxi[size]);
taxi.pop_back();
size = size - 1;
// Shift down the replaced element to maintain the heap property
shiftDown(0);
return called;
}
// Function to update the distance of an taxi
void update(int i)
{
taxi[i] = taxi[i] - 0.01;
shiftUp(i);
}
|
db3ce38470a3878fea0c450245cf68f672e0a141
|
485f702cf2b637e37e90e21a2eaf01b6a8716fa5
|
/mainwindow.cpp
|
2768094f89a287cd8f51952aab11680fe20223bf
|
[] |
no_license
|
alikanarya/metergui
|
c9731364e2f680e48001a4bca0fbd388d690a4f7
|
eef1219727da803e05e84e8164c5f16570afac86
|
refs/heads/master
| 2020-12-10T01:07:07.071290
| 2020-01-13T21:56:17
| 2020-01-13T21:56:17
| 233,466,922
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,271
|
cpp
|
mainwindow.cpp
|
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_loadButton_clicked()
{
loadedFileNamewPath = QFileDialog::getOpenFileName(this,
//tr("Open Image"), "", tr("Image Files (*.png *.jpg *.bmp)"));
tr("Open Image"), "D:/Engineering/Repository Data/meter/ngmeter-data", tr("Image Files (*.jpeg *.png *.jpg *.bmp)"));
if (!loadedFileNamewPath.isEmpty() && !loadedFileNamewPath.isNull()) {
fileOpenDir = QFileInfo(loadedFileNamewPath).absoluteDir();
filesInDirList = fileOpenDir.entryList(fileFilters, QDir::Files);
//foreach(QString temp, filesInDirList){ qDebug() << temp; }
loadedFileName = QFileInfo(loadedFileNamewPath).fileName();
filesInDirListIndex = filesInDirList.indexOf(loadedFileName,0);
//ui->labelPicNo->setText(QString::number(w->filesInDirListIndex)+": "+ w->loadedFileName);
imageFile.load(loadedFileNamewPath);
ui->labelPicture->setPixmap( QPixmap::fromImage( imageFile ).scaled( imageFile.width(), imageFile.height(), Qt::KeepAspectRatio));
}
}
void MainWindow::on_nextImage_clicked()
{
if(filesInDirListIndex != (filesInDirList.size()- 1)){
filesInDirListIndex++;
loadedFileName = filesInDirList.at(filesInDirListIndex);
//ui->labelPicNo->setText(QString::number(w->filesInDirListIndex)+": "+ w->loadedFileName);
imageFile.load(fileOpenDir.path() + "/" + loadedFileName);
ui->labelPicture->setPixmap( QPixmap::fromImage( imageFile ).scaled( imageFile.width(), imageFile.height(), Qt::KeepAspectRatio));
}
}
void MainWindow::on_prevImage_clicked()
{
if(filesInDirListIndex != 0){
filesInDirListIndex--;
loadedFileName = filesInDirList.at(filesInDirListIndex);
//ui->labelPicNo->setText(QString::number(w->filesInDirListIndex)+": "+ w->loadedFileName);
imageFile.load(fileOpenDir.path() + "/" + loadedFileName);
ui->labelPicture->setPixmap( QPixmap::fromImage( imageFile ).scaled( imageFile.width(), imageFile.height(), Qt::KeepAspectRatio));
}
}
|
9c0d2f0ae412fa7e61ab3f695b53c745a0144af5
|
a92c5102c20986eadd02145925bd1e825d94bc29
|
/COMP371-Project/Object.cpp
|
b462adbc5ddbad506de5022520c8f3c6b5099b38
|
[] |
no_license
|
mwPlouffe/COMP371-Project
|
43c89208717feea45df30a0224ac30bb69cc0c16
|
b395fc7fbabe1da626d12269ece02110fe0ff47e
|
refs/heads/master
| 2020-03-20T22:26:16.221936
| 2018-06-18T19:49:54
| 2018-06-18T19:49:54
| 137,798,791
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 968
|
cpp
|
Object.cpp
|
//
// Object.cpp
// COMP371-Project
//
// Created by Mathew Plouffe on 2018-06-04.
// Copyright © 2018 Mathew Plouffe. All rights reserved.
//
#include "Object.h"
Object::Object(void)
{
material = Material();
}
Object::Object(const Point& p) : Entity(p)
{
material = Material();
}
Object::Object(const Point& p, const Material& m) : Entity(p)
{
material = m;
}
bool Object::intersects(const Ray& r) const
{
#ifdef cached
cache_intersect = intersection(r);
return (cache_intersect != (Point) NULL) ? true : false;
#endif
return (intersection(r) != (Point) NULL) ? true : false;
}
Colour Object::surface_colour(const Point& intersect, const Light& l, const Point& cameraPos) const
{
return material.calculate_colour(glm::normalize(intersect - cameraPos), normal_at(intersect), glm::normalize(intersect - l.location()), l.light_colour());
}
Colour Object::shadow_colour(const Light& l) const
{
return material.calculate_shadow_colour(l.light_colour());
}
|
603f647c2810a838a0448de13659d97567f74999
|
0a8588d8e9df1dfaec54224fe6d55cc5b8091257
|
/uva/106-fermat-pythagoras.cpp
|
d4155749d96b81641fedb33ae8cd1c5d9d0e1a13
|
[] |
no_license
|
skalyanasundaram/BrainTuners
|
17e686e540bad3e809c78e0a9462e95fc12b5370
|
2605550e18750485b693804c3d83c3c97706362b
|
refs/heads/master
| 2021-01-06T20:41:45.395191
| 2019-02-04T08:45:36
| 2019-02-04T08:45:36
| 12,889,243
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,272
|
cpp
|
106-fermat-pythagoras.cpp
|
#include <iostream>
#include <math.h>
using namespace std;
// #define MAX_SIZE 1000000
// #define COUNT(x) if(!flags[x]) { count--; flags[x] = 1; }
// inline int GCD(unsigned long a, unsigned long b) {
// unsigned long temp = 0;
// while(b > 0) {
// temp = b;
// b = a % b;
// a = temp;
// }
// return a;
// }
// int main() {
// unsigned long n = 0;
// int flags[MAX_SIZE] = {0};
// while(cin >> n) {
// int count = n;
// int pythogras_triple = 0;
// for(int i=1;i<=count; i++)
// flags[i] = 0;
// for(unsigned long i=1; i<=n; i++)
// for(unsigned long j=i+1; j<=n; j++)
// for(unsigned long k=j+1; k<=n; k++)
// if (pow(i, 2) + pow(j, 2) == pow(k, 2)) {
// cout << i << " " << j << " " << k << endl;
// COUNT(i);
// COUNT(j);
// COUNT(k);
// if (GCD(i, GCD(j, k)) == 1)
// pythogras_triple ++;
// }
// cout << pythogras_triple << " " << count << endl;
// }
// }
#define MAX_SIZE 1000000
#define COUNT(x) flags[x] = 1;
inline int GCD(unsigned long a, unsigned long b) {
unsigned long temp = 0;
while(b > 0) {
temp = b;
b = a % b;
a = temp;
}
return a;
}
int main() {
unsigned long N = 0;
int flags[MAX_SIZE+1] = {0};
while(cin >> N) {
unsigned long count = 0;
unsigned long pythogras_triple = 0;
unsigned long target = sqrt(N);
for(unsigned long n=1; n<=target; n++)
for(unsigned long m=n+1; m<=target; m++) {
unsigned long x = m*m - n*n;
unsigned long y = 2 * m * n;
unsigned long z = m*m + n*n;
if (z > N)
break;
// COUNT(x);
// COUNT(y);
// COUNT(z);
//x,y,z or co-primes iff m,n are co-prime and one of (m,n) should be odd and other should be even
//wiki: The triple generated by Euclid's formula is primitive if and only if m and n are coprime and m − n is odd.
if (GCD(m,n) == 1 && ((m+n) % 2) != 0)
pythogras_triple ++;
//Euclid's formula does not produce all triples. This can be remedied by inserting an additional parameter k to the formula.
//The following will generate all Pythagorean triples (although not uniquely):
for (unsigned long k=1; k<N; k++) {
unsigned long kx = k*x;
unsigned long ky = k*y;
unsigned long kz = k*z;
if (kz > N)
break;
COUNT(kx);
COUNT(ky);
COUNT(kz);
}
}
for(unsigned long i=1; i<=N; i++) {
if(!flags[i])
count++;
flags[i] = 0;
}
cout << pythogras_triple << " " << count << endl;
}
return 0;
}
// 1 2 9
// 11 14 18
// 19 21 22 23
|
9a9f7bb0f8ae91c4853526291dc2a4ddcbb004dd
|
477877d03637c6ceeb24d25d7537ef3ea71899e9
|
/Stemmer/Stemmer.cpp
|
69cdcf54360a4565666fae38989b23748796b440
|
[] |
no_license
|
abokov/tools
|
88a978105071008fb6498b1b83aaba9c43adac63
|
ee35c28a9cacd8aef719bf0e858bbf985c4f0006
|
refs/heads/master
| 2021-03-12T21:20:47.599404
| 2017-10-16T14:42:51
| 2017-10-16T14:42:51
| 35,889,235
| 0
| 0
| null | null | null | null |
WINDOWS-1251
|
C++
| false
| false
| 5,429
|
cpp
|
Stemmer.cpp
|
#include <iostream>
#include <string>
#include "..\..\dllobjs\Lang_dll.h"
#include "..\..\common\ini_log.h"
#include "..\..\common\utils.h"
#include "..\..\common\errdefs.h"
// dummy object for linking with ini_log.cpp
char Section[]= "";
enum LanguageTypes { lang_russian, lang_english };
void usage(void);
void do_action(LanguageTypes lang,LanguageDll *dll_obj);
WORD16 ExtractStems(LanguageDll *dll_obj,char* pWord, char* pBuff, WORD16 SzBuff,Bool *pfSelf);
class MyClass {
public:
/* int field;
void get1(void) {
};
void get2(void) {
};
static foo(void) {
};*/
virtual void v_foo_1(void) {
};
virtual void v_foo_2(void) {
};
virtual void v_foo_3(void) {
};
};
int main (int argc, char* argv []) {
/*1 статическая ф-ция
3 виртуальных ф-ции
2 ф-ции-члена (невиртуальных)
1 поле типа int.*/
int size_of=sizeof(MyClass);
LanguageTypes lang;
switch (argc) {
case 3:
if (strcmpi(argv[1],"-l")!=0) {
usage();
return 1;
};
if (strcmpi(argv[2],"ru")==0) {
lang=lang_russian;
break;
};
if (strcmpi(argv[2],"en")==0) {
lang=lang_english;
break;
}; // go to usage section ( because language isn't specified correctly )
case 0: default:
usage();
return 1;
};
{ HMODULE hModule = GetModuleHandle(NULL);
MakeIniLogPathes ( hModule );
};
try {
LanguageDll dll_obj;
switch (lang) {
case lang_russian:
if (dll_obj.LoadDll("LngRus32.dll")==false) {
IniLogUtils::LogClass log("log_error.log");
log<<"Can't open LngRus32.dll "<<IniLogUtils::flush;
return 1;
};
break;
case lang_english:
if (dll_obj.LoadDll("LngEng32.dll")==false) {
IniLogUtils::LogClass log("log_error.log");
log<<"Can't open LngEng32.dll "<<IniLogUtils::flush;
return 1;
};
break;
};
do_action(lang,&dll_obj);
} catch (...) {
IniLogUtils::LogClass log("log_error.log");
log<<"Unknown exception at main()"<<IniLogUtils::flush;
};
FreeIniLogPathes();
return 0;
};
void usage(void) {
const char *About="\nUsage: stemmer.exe -l {ru | en}"
"\nOptions:\n -l <lang> language of source file ('ru' or 'en')."
"\nExample: stemmer.exe -l en <words.txt >stems.txt";
std::cout<<About<<std::endl;
};
void do_action(LanguageTypes lang,LanguageDll *dll_obj) {
std::string s;
while (std::cin) {
if (std::cin.fail() || ( std::cin.eof()==true) )
break;
std::getline(std::cin,s);
{ char buff[nsLanguageDll::MAX_STEMS*(nsLanguageDll::MAX_WORD_LEN)];
Bool fSelf;
WORD16 cnt=ExtractStems(dll_obj,(char*)s.c_str(), buff, sizeof (buff), &fSelf);
if (cnt==0) {
std::cout<<s.c_str()<<"\t"<<s.c_str()<<"\n";
continue;
};
if (cnt==1) {
std::cout<<s.c_str()<<"\t"<<buff<<"\n";
continue;
};
{ char *ptr=buff;
while (cnt!=0) {
std::string str=ptr;
std::cout<<s.c_str()<<"\t"<<str<<"\n";
ptr+=str.length()+1;
cnt--;
};
};
};
} // while (std::cin) {
};
WORD16 ExtractStems(LanguageDll *dll_obj,char* pWord, char* pBuff, WORD16 SzBuff,Bool *pfSelf) {
// INT32 i;
WORD16 j, k, nNormForms = 0;
WORD16 SzRest;
char* pInBuff, *lp1, *lp2, *lp3;
*pfSelf = FALSE;
*pBuff = 0;
// for (i = 0; i < Count; i++) /// core Seg.fault...
//{
j = 0;
pInBuff = pBuff;
while (j++ < nNormForms)
{
pInBuff += strlen (pInBuff) + 1;
}
SzRest = SzBuff - (WORD16) (pInBuff - pBuff);
//LanguageModule* module = (LanguageModule*) At (i);
nNormForms += dll_obj->GetWordStems (pWord, pInBuff, SzRest);
// }
// Set necessary case
lp1 = pBuff;
/*for (i = 0; i < nNormForms; i++)
{
PrepWordForIdx (lp1, lp1);
lp1 += strlen (lp1) + 1;
}*/
// Clear identical wordforms
lp1 = pBuff;
j = 0;
while (nNormForms >= 2 && j < nNormForms-1)
{
lp2 = lp1 + strlen (lp1) + 1;
for (k = j+1; k < nNormForms; k++)
{
if (strcmp (lp1, lp2) == 0)
{
// Identical strings! Remove 2nd word
lp3 = lp2 + strlen (lp2) + 1;
memmove (lp2, lp3, SzBuff - (lp3 - pBuff));
nNormForms--;
k--;
}
else
{
lp2 += strlen (lp2) + 1;
}
}
j++;
lp1 += strlen (lp1) + 1;
}
// Clear wordforms, identical to pWord
lp1 = pBuff;
j = 0;
while (nNormForms >= 1 && j < nNormForms)
{
if (strcmp (lp1, pWord) == 0)
{
// One of forms is Identical to original! Remove it
if (lp1 == pBuff && nNormForms == 1)
*lp1 = 0;
else
{
lp3 = lp1 + strlen (lp1) + 1;
memmove (lp1, lp3, SzBuff - (lp3 - pBuff));
}
nNormForms--;
*pfSelf = TRUE;
}
else
{
lp1 += strlen (lp1) + 1;
}
j++;
}
return nNormForms;
}
|
b025168d4c5c65c526300c2443d5c7538a74f8a9
|
d05555aa4da349b8a1cc219b4c3fae881577f7ab
|
/A1599/1599笨重的石子.cpp
|
a374ef2ab07ad83e1d447955b8d7b0634c0acac2
|
[
"MIT"
] |
permissive
|
instr3/BZOJ-solution-legacy
|
c95cc0882d24c8b74b72a546cf9f2b84d541faea
|
a71f7df2241602ad744e8ca2453a8423590d5678
|
refs/heads/master
| 2021-01-11T05:19:01.069622
| 2016-09-26T03:19:38
| 2016-09-26T03:19:38
| 69,208,796
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,310
|
cpp
|
1599笨重的石子.cpp
|
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
#define each(i,n) (int i=1;i<=(n);++i)
#define every(i,a,b) (int i=(a);i<=(b);++i)
int tres[81];
int n1,n2,n3;
int main()
{
freopen("1599.in","r",stdin);
freopen("1599.out","w",stdout);
scanf("%d%d%d",&n1,&n2,&n3);
srand(321);
int n=n1+n2+n3;
int tot=99999999;
int tmin=0,tminat;
for each(i1,n1)
for each(i2,n2)
for each(i3,n3)
{
tres[i1+i2+i3]+=1;
}
for each(i,n)
{
if(tmin<tres[i])
{
tmin=tres[i];
tminat=i;
}
}
cout<<tminat<<endl;
return 0;
int t1,t2,t3;
for each(j,10)
{
memset(tres,0,sizeof tres);
for each(i,10000000)
{
t1=rand()%n1+1;
t2=rand()%n2+1;
t3=rand()%n3+1;
//cout<<t1<<","<<t2<<","<<t3<<endl;
tres[t1+t2+t3]++;
}
tmin=0;
for each(i,n)
{
if(tmin<tres[i])
{
tmin=tres[i];
tminat=i;
}
}
cout<<tminat<<" ";
tot=min(tot,tminat);
}
cout<<tot<<endl;
for each(i,n)
cout<<tres[i]<<endl;
}
|
ca801c5c9728daebe8a126bb71c65f3d62bf157b
|
70549e8671ea72b9c4e460e135783b6917a39860
|
/NewPageTable.cpp
|
178e2fd46d3df8222af238abea9bea29908e2672
|
[] |
no_license
|
isha97/Custom-Memory-Manager
|
ec91c1d410d5e309aecf962ac77783ffa635f9de
|
f48afad45a5b56ff1c3ab22bf8d028749679ac99
|
refs/heads/master
| 2021-01-01T05:13:58.588472
| 2016-09-21T14:14:33
| 2016-09-21T14:14:33
| 57,883,141
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,453
|
cpp
|
NewPageTable.cpp
|
// It uses overrode new and delete functions
#include <sys/types.h>
#include<bits/stdc++.h>
#include<time.h>
#include<stdio.h>
#include "mmanager.h"
//#define POOLSIZE 32
class PageTable
{
public:
PageTable (double a, double b): frameno (a), pageno (b) {}
inline void* operator new(size_t);
inline void operator delete(void*);
private:
int frameno; // Real Part
int pageno; // PageTable Part
};
void MemoryManager::expandPoolSize ()
{
size_t size = (sizeof(PageTable) > sizeof(FreeStore*)) ?
sizeof(PageTable) : sizeof(FreeStore*);
FreeStore* head = reinterpret_cast <FreeStore*> (new char[size]);
freeStoreHead = head;
for (int i = 0; i < POOLSIZE; i++) {
head->next = reinterpret_cast <FreeStore*> (new char [size]);
head = head->next;
}
head->next = 0;
}
MemoryManager gMemoryManager;
void* PageTable::operator new (size_t size)
{
return gMemoryManager.allocate(size);
}
void PageTable::operator delete (void* pointerToDelete)
{
gMemoryManager.free(pointerToDelete);
}
using namespace std;
int main(int argc, char* argv[])
{
clock_t tStart = clock();
PageTable* array[1000];
for (int i = 0;i < 6000; i++) {
for (int j = 0; j < 1000; j++) {
array[j] = new PageTable (i, j);
}
for (int j = 0; j < 1000; j++) {
delete array[j];
}
}
printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
return 0;
}
|
5af6f7aed65d5945d46424371e743365421a8008
|
951309889c9cf4b3a0deb2fc424fe39cdedc4860
|
/tasker.h
|
a2494d99fc5996ea1986c096b21bb3358935555e
|
[] |
no_license
|
urizilber/Schular
|
9bd4f607fcee5c101330a4b63ee5636397e03604
|
376d4cf67c38f717efc48928fa7e044615209314
|
refs/heads/master
| 2023-04-04T02:52:16.334754
| 2021-04-10T20:57:01
| 2021-04-10T20:57:01
| 356,282,076
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 436
|
h
|
tasker.h
|
#ifndef TASKER_H
#define TASKER_H
#include <iostream>
#include <chrono>
typedef void (*Callable)();
class Tasker
{
public:
Tasker(std::chrono::system_clock::time_point &timt_a,Callable f);
std::chrono::system_clock::time_point getTime();
bool operator< (class Tasker* rhs) {
return this->timt_t < rhs->getTime();
}
Callable returnFunc();
private:
std::chrono::system_clock::time_point timt_t;
Callable func;
};
#endif
|
60c2571e36fcd55ca8c0564ab58d1e0b54b83a78
|
165be8367f5753b03fae11430b1c3ebf48aa834a
|
/source/backend/cpu/CPUArgMax.hpp
|
0314091bd809c64abf85e77781e1924efb947677
|
[
"Apache-2.0"
] |
permissive
|
alibaba/MNN
|
f21b31e3c62d9ba1070c2e4e931fd9220611307c
|
c442ff39ec9a6a99c28bddd465d8074a7b5c1cca
|
refs/heads/master
| 2023-09-01T18:26:42.533902
| 2023-08-22T11:16:44
| 2023-08-22T11:16:44
| 181,436,799
| 8,383
| 1,789
| null | 2023-09-07T02:01:43
| 2019-04-15T07:40:18
|
C++
|
UTF-8
|
C++
| false
| false
| 979
|
hpp
|
CPUArgMax.hpp
|
//
// CPUArgMax.hpp
// MNN
//
// Created by MNN on 2018/07/17.
// Copyright © 2018, Alibaba Group Holding Limited
//
#ifndef CPUArgMax_hpp
#define CPUArgMax_hpp
#include "core/Execution.hpp"
namespace MNN {
class CPUArgMax : public Execution {
public:
enum ArgMinOrMax {
ARGMIN,
ARGMAX
};
CPUArgMax(Backend *backend, ArgMinOrMax mode, int topk, int outMaxVal, int softmaxThreshold, int axis);
virtual ~CPUArgMax() = default;
virtual ErrorCode onResize(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
virtual ErrorCode onExecute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
private:
Tensor mInputBuffer;
Tensor mOutputBuffer;
int mTopk;
int mOutMaxVal;
int mSoftmaxThreshold;
int mAxis;
int mNum;
int mDim;
int mKeyExtent;
bool mFromNHWC;
ArgMinOrMax mMode;
};
} // namespace MNN
#endif /* CPUArgMax_hpp */
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.