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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dcbcaa0129f325f5de81abbe08821356c03ac7b7
|
03ea09aa085ff986d5f774ce41e559d38e780cda
|
/samples/SecuredAmlSubscriber.cpp
|
2acf560f80439786a1e8da0d6e9e9349f6890bbb
|
[
"curl",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] |
permissive
|
mgjeong/protocol-ezmq-plus-cpp
|
7932ff65e3924f83c9b73f256be6d259915e766b
|
85159cdc9604216d680c644d83a7135c33eadb94
|
refs/heads/master
| 2020-04-07T08:05:22.343527
| 2020-04-01T06:08:23
| 2020-04-01T06:08:23
| 158,200,072
| 0
| 3
|
Apache-2.0
| 2020-04-01T06:10:23
| 2018-11-19T10:05:37
|
C++
|
UTF-8
|
C++
| false
| false
| 6,022
|
cpp
|
SecuredAmlSubscriber.cpp
|
/*******************************************************************************
* Copyright 2018 Samsung Electronics All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*******************************************************************************/
#include <iostream>
#include <EZMQXConfig.h>
#include <EZMQXException.h>
#include <EZMQXAMLSubscriber.h>
#include <EZMQXTopicDiscovery.h>
#include <condition_variable>
#include <signal.h>
bool isStarted;
std::mutex m_mutex;
std::condition_variable m_cv;
void printAMLData(const AML::AMLData& amlData, int depth)
{
std::string indent;
for (int i = 0; i < depth; i++) indent += " ";
std::cout << indent << "{" << std::endl;
std::vector<std::string> keys = amlData.getKeys();
for (std::string key : keys)
{
std::cout << indent << " \"" << key << "\" : ";
AML::AMLValueType type = amlData.getValueType(key);
if (AML::AMLValueType::String == type)
{
std::string valStr = amlData.getValueToStr(key);
std::cout << valStr;
}
else if (AML::AMLValueType::StringArray == type)
{
std::vector<std::string> valStrArr = amlData.getValueToStrArr(key);
std::cout << "[";
for (std::string val : valStrArr)
{
std::cout << val;
if (val != valStrArr.back()) std::cout << ", ";
}
std::cout << "]";
}
else if (AML::AMLValueType::AMLData == type)
{
AML::AMLData valAMLData = amlData.getValueToAMLData(key);
std::cout << std::endl;
printAMLData(valAMLData, depth + 1);
}
if (key != keys.back()) std::cout << ",";
std::cout << std::endl;
}
std::cout << indent << "}";
}
void printAMLObject(const AML::AMLObject& amlObj)
{
std::cout << "{" << std::endl;
std::cout << " \"device\" : " << amlObj.getDeviceId() << "," << std::endl;
std::cout << " \"timestamp\" : " << amlObj.getTimeStamp() << "," << std::endl;
std::cout << " \"id\" : " << amlObj.getId() << "," << std::endl;
std::vector<std::string> dataNames = amlObj.getDataNames();
for (std::string n : dataNames)
{
AML::AMLData data = amlObj.getData(n);
std::cout << " \"" << n << "\" : " << std::endl;
printAMLData(data, 1);
if (n != dataNames.back()) std::cout << "," << std::endl;
}
std::cout << "\n}" << std::endl;
}
void sigint(int /*signal*/)
{
if (isStarted)
{
std::unique_lock<std::mutex> lock(m_mutex);
m_cv.notify_all();
}
else
{
exit (EXIT_FAILURE);
}
}
int main()
{
std::string serverPublicKey = "tXJx&1^QE2g7WCXbF.$$TVP.wCtxwNhR8?iLi&S<";
std::string clientPublicKey = "-QW?Ved(f:<::3d5tJ$[4Er&]6#9yr=vha/caBc(";
std::string clientPrivateKey = "ZB1@RS6Kv^zucova$kH(!o>tZCQ.<!Q)6-0aWFmW";
isStarted = false;
//this handler is added to check stop API
signal(SIGINT, sigint);
std::string topic;
std::cout<<"Enter topic ex) /TEST/A"<<std::endl;
std::cin>>topic;
try
{
// get config class instance & add aml model file path
std::list<std::string> amlPath(1, "sample_data_model.aml");
EZMQX::Config* config = EZMQX::Config::getInstance();
config->startDockerMode("tnsConf.json");
std::list<std::string> amlId = config->addAmlModel(amlPath);
// error callback
// typedef std::function<void(std::string topic, const AML::AMLObject& payload)> SubCb;
// typedef std::function<void(std::string topic, EZMQX::ErrorCode errCode)> SubErrCb;
EZMQX::AmlSubCb subCb = [](std::string topic, const AML::AMLObject& payload){std::cout << "subCb called" << std::endl << "topic: " << topic << std::endl; printAMLObject(payload);};
EZMQX::SubErrCb errCb = [](std::string topic, EZMQX::ErrorCode errCode){std::cout << "errCb called" << std::endl << "topic: " << topic << std::endl << "err: " << errCode << std::endl;};
// create subscriber with test topic
// TODO insert ip address
EZMQX::Endpoint ep("0.0.0.0", 4000);
if (amlId.empty())
{
std::cout<<"Could parse any aml model"<<std::endl;
return -1;
}
std::cout<<"amlId: " << amlId.front() << std::endl;
//EZMQX::Topic knownTopic("/TEST/A", amlId.front(),true ,ep);
std::shared_ptr<EZMQX::TopicDiscovery> discovery(new EZMQX::TopicDiscovery());
EZMQX::Topic result = discovery->query(topic);
std::shared_ptr<EZMQX::AmlSubscriber> subscriber(EZMQX::AmlSubscriber::getSecuredSubscriber(result, serverPublicKey, clientPublicKey, clientPrivateKey, subCb, errCb));
std::cout<<"subscriber created"<<std::endl;
// push to blocked
std::cout<<"push main thread to blocked"<<std::endl;
isStarted = true;
std::unique_lock<std::mutex> lock(m_mutex);
m_cv.wait(lock);
// condition check
if (!subscriber->isTerminated())
{
std::cout << "terminate subscriber" << std::endl;
subscriber->terminate();
}
// occur exception
subscriber->terminate();
}
catch(EZMQX::Exception &e)
{
// catch terminated exception
std::cout << "catch exception" << std::endl;
std::cout << e.what() << std::endl;
}
std::cout << "done" << std::endl;
}
|
c8686b087443597740b6a33d7edbac956ef7a6b3
|
2a3e204a9fd9c25c91dbe9dcb1e7e4804d493c95
|
/src/server/scripts/Kalimdor/stonetalon_mountains.cpp
|
1e29b43f4a4ab9449294844f19fe2ca4b665cda7
|
[] |
no_license
|
TheGhostGroup/DynastyCore
|
e724ecb09ecd1ac11531b9be4e8e5de39bd4e074
|
d2596357e6fad5778b4688b8d84bd3bd073a873c
|
refs/heads/master
| 2020-07-26T05:36:59.831552
| 2019-11-06T00:26:00
| 2019-11-06T00:26:00
| 208,549,658
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,492
|
cpp
|
stonetalon_mountains.cpp
|
////////////////////////////////////////////////////////////////////////////////
//
// MILLENIUM-STUDIO
// Copyright 2016 Millenium-studio SARL
// All Rights Reserved.
//
////////////////////////////////////////////////////////////////////////////////
/* ScriptData
SDName: Stonetalon_Mountains
SD%Complete: 0
SDComment: Quest support:
SDCategory: Stonetalon Mountains
EndScriptData */
/* ContentData
EndContentData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "ScriptedEscortAI.h"
enum Rein
{
KOBOLD_CREDIT = 42024,
KOBOLD_SERVANT = 42026
};
// 42023
class npc_subjugator_devo : public CreatureScript
{
public:
npc_subjugator_devo() : CreatureScript("npc_subjugator_devo") { }
CreatureAI* GetAI(Creature* creature) const
{
return new npc_subjugator_devoAI(creature);
}
struct npc_subjugator_devoAI : public ScriptedAI
{
npc_subjugator_devoAI(Creature* creature) : ScriptedAI(creature) {}
void MoveInLineOfSight(Unit* who)
{
ScriptedAI::MoveInLineOfSight(who);
if (who->GetEntry() == KOBOLD_SERVANT && me->IsWithinDistInMap(who, 10.0f))
{
if (Player* owner = who->GetOwner()->ToPlayer())
{
if (owner->GetQuestStatus(26066) == QUEST_STATUS_INCOMPLETE)
owner->KilledMonsterCredit(KOBOLD_CREDIT,0);
who->ToCreature()->DespawnOrUnsummon();
if (owner->GetQuestStatus(26066) == QUEST_STATUS_COMPLETE)
owner->RemoveAllMinionsByEntry(KOBOLD_SERVANT);
}
}
}
};
};
class npc_kaya_flathoof : public CreatureScript
{
public:
npc_kaya_flathoof() : CreatureScript("npc_kaya_flathoof")
{
}
CreatureAI* GetAI(Creature* creature) const
{
return new npc_kaya_flathoofAI(creature);
}
struct npc_kaya_flathoofAI : public ScriptedAI
{
npc_kaya_flathoofAI(Creature* creature) : ScriptedAI(creature)
{
}
EventMap events;
void Reset()
{
events.Reset();
}
void UpdateAI(const uint32 /*p_Diff*/)
{
}
};
};
#ifndef __clang_analyzer__
void AddSC_stonetalon_mountains()
{
new npc_kaya_flathoof();
new npc_subjugator_devo();
}
#endif
|
604adaa2a1bbd415ec9083dc9414a513175f6eda
|
721b6b6dcf599c7a7c8784cb86b1fed6ca40221d
|
/src/Leetcode/628_maximum-product-of-three-numbers.cpp
|
7907a1b2a24b518f40e901912de8a34638e430cf
|
[] |
no_license
|
anveshh/cpp-book
|
e9d79dbf899b30aefbbddd5d26b73be178850c23
|
54c2ceeac916540d919b4d8686cbfbcbcfecf93d
|
refs/heads/master
| 2023-03-24T03:02:37.305470
| 2021-03-10T16:35:39
| 2021-03-10T16:35:39
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 546
|
cpp
|
628_maximum-product-of-three-numbers.cpp
|
// https://leetcode.com/problems/maximum-product-of-three-numbers/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution
{
public:
int maximumProduct(vector<int> &nums)
{
sort(nums.begin(), nums.end());
return (max(nums[0] * nums[1] * nums[nums.size() - 1], nums[nums.size() - 1] * nums[nums.size() - 2] * nums[nums.size() - 3]));
}
};
int main()
{
Solution a;
vector<int> input = {1, -4, -3, -1, -2, 60};
cout << a.maximumProduct(input) << endl;
return 0;
}
|
f1b07ecceadf85df4f6db542ad84bf3d52d71449
|
e413e4020617f2645f7f3ed89ec698183c17e919
|
/NuclearSegmentation/NucleusEditor/processor_main.cpp
|
7ff51dd558286da695d0a6881945b72334aedd3e
|
[] |
no_license
|
YanXuHappygela/Farsight-latest
|
5c349421b75262f89352cc05093c04d3d6dfb9b0
|
021b1766dc69138dcd64a5f834fdb558bc558a27
|
refs/heads/master
| 2020-04-24T13:28:25.601628
| 2014-09-30T18:51:29
| 2014-09-30T18:51:29
| 24,650,739
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,119
|
cpp
|
processor_main.cpp
|
/*
* Copyright 2009 Rensselaer Polytechnic Institute
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ftkProjectProcessor.h"
void usage(const char *funcName);
int main(int argc, char *argv[])
{
if( argc < 5 )
{
usage(argv[0]);
std::cerr << "PRESS ENTER TO EXIT\n";
getchar();
return EXIT_FAILURE;
}
std::string MyName = argv[0]; //In case the CWD is not the path of the executable
std::string inputFilename = argv[1]; // Name of the input image;
std::string labelFilename = argv[2]; // Name of the label image to apply
std::string tableFilename = argv[3]; // Name of the table file;
std::string definitionFilename = argv[4]; // Name of the process definition file
int numThreads = 0;
if( argc == 6 )
numThreads = atoi(argv[5]); // Number of threads to run tasks built with openmp
//Try to load the input image:
ftk::Image::Pointer myImg = NULL;
if( ftk::GetExtension(inputFilename) == "xml" )
{
myImg = ftk::LoadXMLImage(inputFilename);
}
else
{
myImg = ftk::Image::New();
if( !myImg->LoadFile(inputFilename) )
{
std::cout<<"Could not load input image\n";
myImg = NULL;
}
}
if(!myImg)
{
std::cerr << "COULD NOT LOAD INPUT IMAGE!!\n";
usage(argv[0]);
std::cerr << "PRESS ENTER TO EXIT\n";
getchar();
return EXIT_FAILURE;
}
//Try to load the Label image:
ftk::Image::Pointer labImg;// = NULL;
if( ftk::FileExists(labelFilename) )
{
if( ftk::GetExtension(labelFilename) == "xml" )
{
labImg = ftk::LoadXMLImage(labelFilename);
}
else
{
labImg = ftk::Image::New();
if( !labImg->LoadFile(labelFilename) )
{
std::cout<<"Could not load label image\n";
labImg = NULL;
}
}
}
//Try to load the table:
vtkSmartPointer<vtkTable> table = NULL;
if( ftk::FileExists(tableFilename) )
{
table = ftk::LoadTable(tableFilename);
}
//Load up the definition
ftk::ProjectDefinition projectDef;
if( !projectDef.Load(definitionFilename) )
{
std::cerr << "COULD NOT LOAD PROCESS DEFINITION FILE!!\n";
usage(argv[0]);
std::cerr << "PRESS ENTER TO EXIT\n";
getchar();
return EXIT_FAILURE;
}
//Do processing:
ftk::ProjectProcessor * pProc = new ftk::ProjectProcessor();
if( numThreads ) pProc->SetNumThreads( numThreads );
pProc->SetExecPath( ftk::GetFilePath( MyName ) );
std::cout<<"The executable says my path is: "<<ftk::GetFilePath( MyName )<<std::endl;
pProc->SetInputImage(myImg);
pProc->SetPath( ftk::GetFilePath(inputFilename) );
if(labImg)
pProc->SetOutputImage(labImg);
if(table)
pProc->SetTable(table);
pProc->SetDefinition(&projectDef);
pProc->Initialize();
while(!pProc->DoneProcessing())
pProc->ProcessNext();
labImg = pProc->GetOutputImage();
table = pProc->GetTable();
typedef ftk::ProjectProcessor::LabelImageType::Pointer LabelImagePointer;
std::map< std::string, LabelImagePointer > myClassImageMap = pProc->GetClassImageMap();
std::map< std::string, vtkSmartPointer<vtkTable> > myClassCentroidMap = pProc->GetClassCentroidMap();
std::string myFilename = inputFilename;
unsigned extension = ftk::GetExtension(inputFilename).size()+1;
std::string::iterator it;
it = myFilename.end() - extension;
myFilename.erase(it, it+extension);
//Save results:
if( ftk::GetExtension(labelFilename) == "xml" )
ftk::SaveXMLImage(labelFilename, labImg);
else
labImg->SaveChannelAs(0, ftk::SetExtension(labelFilename, ""), ftk::GetExtension(labelFilename));
ftk::SaveTable( tableFilename, table );
typedef itk::ImageFileWriter< ftk::ProjectProcessor::LabelImageType > LabelWriterType;
std::map< std::string, ftk::ProjectProcessor::LabelImageType::Pointer >::iterator classImageMapIter;
for(classImageMapIter = myClassImageMap.begin(); classImageMapIter != myClassImageMap.end(); ++classImageMapIter)
{
std::string className = classImageMapIter->first;
std::string classImageFileName = myFilename + "_" + className + ".nrrd";
LabelImagePointer classImage = classImageMapIter->second;
LabelWriterType::Pointer writer = LabelWriterType::New();
writer->SetFileName(classImageFileName);
writer->SetInput(classImage);
writer->Update();
}
std::map< std::string, vtkSmartPointer<vtkTable> >::iterator classCentroidMapIter;
for(classCentroidMapIter = myClassCentroidMap.begin(); classCentroidMapIter != myClassCentroidMap.end(); ++classCentroidMapIter)
{
std::string className = classCentroidMapIter->first;
std::string classCentroidsFileName = myFilename + "_" + className + "_centroids.txt";
vtkSmartPointer<vtkTable> centroid_table = classCentroidMapIter->second;
ofstream outFile;
outFile.open(classCentroidsFileName.c_str(), ios::out | ios::trunc );
if ( !outFile.is_open() )
{
std::cerr << "Failed to Load Document: " << outFile << std::endl;
return false;
}
//Write out the features:
for(int row = 0; row < (int)centroid_table->GetNumberOfRows(); ++row)
{
outFile << centroid_table->GetValue(row,0).ToInt() << "\t" ;
outFile << centroid_table->GetValue(row,1).ToInt() << "\t" ;
outFile << centroid_table->GetValue(row,2).ToInt() << "\t" ;
outFile << "\n";
}
outFile.close();
}
projectDef.Write(definitionFilename);
delete pProc;
return EXIT_SUCCESS;
}
void usage(const char *funcName)
{
std::cout << "USAGE:\n";
std::cout << " " << funcName << " InputImage LabelImage Table ProcessDefinition (Optional)NumThreads\n";
std::cout << " First four inputs are filenames\n";
}
|
d9d52c36008665be1c6fa6887307921b04fb11d9
|
0453ffb96e2c233fb04bb78e59ee70d1e66c22a3
|
/arrays/product-of-array-except-itself.cpp
|
fcd733bf4777dc27e7a7370e5c800f37f8f38a2e
|
[] |
no_license
|
rakshith53/LeetCode-Solution
|
4f8f08283610c54bf61135d16befad1c264eb054
|
bba00e9314b4ad36f1831387a9f9fab802562b8b
|
refs/heads/main
| 2023-02-15T14:13:04.870369
| 2021-01-13T08:15:38
| 2021-01-13T08:15:38
| 325,224,507
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 375
|
cpp
|
product-of-array-except-itself.cpp
|
class Solution {
public:
vector<int> productExceptSelf(vector<int>& a) {
int n =a.size();
vector<int> ans(n,0);
ans[0] = 1;
for(int i=1;i<n;i++){
ans[i] = ans[i-1] * a[i-1];
}
int r = 1;
for(int i=n-1;i>=0;i--){
ans[i] = ans[i]*r;
r*=a[i];
}
return ans;
}
};
|
e1974b4deccb47510234ad9e85df681f9a010862
|
d14d446c8617a6cb6c3914e9a64172b0a9319eab
|
/QLib/ExchangeCallPayoff.cpp
|
0a1341ba78f5e8c5b7c6932d64fc5c2d6aa8b7d0
|
[] |
no_license
|
qitianchen/QLib
|
987a712829dc9c7e66e2bd3a746f93eba958a34a
|
c85e77f8f2ac97a1030601404daeffce800edb0f
|
refs/heads/master
| 2021-01-02T08:19:35.192005
| 2012-05-22T00:16:22
| 2012-05-22T00:16:22
| 4,399,577
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 303
|
cpp
|
ExchangeCallPayoff.cpp
|
/*
* :ExchangeCallPayo.cpp
*
* Created on: May 15, 2012
* Author: Administrator
*/
#include "ExchangeCallPayoff.h"
ExchangeCallPayoff::ExchangeCallPayoff()
{
// TODO Auto-generated constructor stub
}
ExchangeCallPayoff::~ExchangeCallPayoff()
{
// TODO Auto-generated destructor stub
}
|
c9d08c28c3a96fdda9a528cde5ca470bddf35407
|
df2c0b88f25c244a4cca6ea9939673ed951021d4
|
/17-2/Algorithm/bomb.cpp
|
c681b74d15926ae1a2e405bc6a44f97bf3a3d996
|
[] |
no_license
|
gtslljzs/SKKU
|
4d0586da2455bdc54a4c431933e28446e76bfd8a
|
dd624f5bb15c9b0d6fc8dce4c460f7310b7802fa
|
refs/heads/master
| 2020-06-13T07:36:29.298158
| 2019-07-01T02:43:18
| 2019-07-01T02:43:18
| 194,574,767
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,852
|
cpp
|
bomb.cpp
|
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
struct cor {
double x;
double y;
};
int ctz, shlt;
int time, spd;
int live;
int* c_set;
int* s_set;
bool* matched;
int* depth;
vector< vector< int > > graph;
double Dist( cor u, cor v ) {
return sqrt( pow( u.x - v.x, 2 ) + pow( u.y - v.y, 2 ) );
}
void BFS() {
queue<int> Q;
int cur;
for ( int i = 0; i < ctz; i++ ) {
if ( !matched[i] ) {
depth[i] = 0;
Q.push( i );
} else
depth[i] = -1;
}
while ( !Q.empty() ) {
cur = Q.front();
Q.pop();
for ( int i = 0; i < graph[cur].size(); i++ ) {
if ( s_set[i] != -1 && depth[s_set[i]] == -1 ) {
depth[s_set[i]] = depth[i] + 1;
Q.push( s_set[i] );
}
}
}
}
bool DFS( int cur ) {
for ( int i = 0; i < graph[cur].size(); i++ ) {
if ( s_set[i] == -1 || ( depth[s_set[i]] == depth[cur] + 1 && DFS( s_set[i] ) ) ) {
matched[cur] = true;
c_set[cur] = i;
s_set[i] = cur;
return true;
}
}
return false;
}
void Runaway() {
while ( true ) {
BFS();
int path = 0;
for ( int i = 0; i < ctz; i++ ) {
if ( !matched[i] && DFS(i))
path++;
}
if ( path == 0 )
break;
live += path;
}
}
int main( int argc, char** argv ) {
FILE* ifp = fopen( argv[1], "r" );
if ( !ifp ) {
cout << "Cannot open the input file!";
return -1;
}
fscanf( ifp, "%d %d", &ctz, &shlt );
fscanf( ifp, "%d %d", &time, &spd );
cor* C;
cor* S;
C = new cor [ctz];
S = new cor [shlt];
matched = new bool [ctz];
depth = new int [ctz];
c_set = new int [ctz];
s_set = new int [shlt];
graph = vector < vector < int > > ( ctz );
for ( int i = 0; i < ctz; i++ )
fscanf( ifp, "%lf %lf", &C[i].x, &C[i].y );
fill( c_set, c_set + ctz, -1 );
for ( int i = 0; i < shlt; i++ )
fscanf( ifp, "%lf %lf", &S[i].x, &S[i].y );
fill( s_set, s_set + shlt, -1 );
fclose( ifp );
for ( int i = 0; i < ctz; i++ ) {
for ( int j = 0; j < shlt; j++ ) {
if ( Dist( C[i], S[j] ) <= time * spd )
graph[i].push_back(j);
}
}
delete [] C;
delete [] S;
Runaway();
delete [] matched;
delete [] depth;
delete [] c_set;
delete [] s_set;
FILE* ofp = fopen( argv[2], "w" );
if ( !ofp ) {
cout << "Cannot open the output file!";
return -1;
}
fprintf( ofp, "%d", ctz - live );
fclose( ofp );
return 0;
}
|
0c73edeffe0236d3ebcd0f7ae96f589899c93d79
|
fd5e72f39e2b5e68088b2edbcb306d0e34b6dc40
|
/DeferredExecutor.h
|
cc62e347d26e83beac37c8f62a679be2d9566894
|
[] |
no_license
|
s1l2/hellozigbee
|
d9cac3ac2c832d1a7f2c012674a1ade1eacbd509
|
cb281b2ad3851560b1399f4d3f127fa2bd635e71
|
refs/heads/main
| 2023-08-21T00:04:03.378444
| 2021-11-02T19:28:09
| 2021-11-02T19:28:09
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 639
|
h
|
DeferredExecutor.h
|
#ifndef DEFERREDEXECUTOR_H
#define DEFERREDEXECUTOR_H
#include "Queue.h"
#define DEFERRED_EXECUTOR_QUEUE_SIZE 20
typedef void (*deferredCallback)(uint8);
class DeferredExecutor
{
Queue<uint32, DEFERRED_EXECUTOR_QUEUE_SIZE> delayQueue;
Queue<deferredCallback, DEFERRED_EXECUTOR_QUEUE_SIZE> callbacksQueue;
Queue<uint8, DEFERRED_EXECUTOR_QUEUE_SIZE> paramsQueue;
uint8 timerHandle;
public:
DeferredExecutor();
void init();
void runLater(uint32 delay, deferredCallback cb, uint8 param);
private:
static void timerCallback(void *timerParam);
void scheduleNextCall();
};
#endif // DEFERREDEXECUTOR_H
|
21d8297715f15575895c16b331df14b5adcf62ab
|
a718e9a911792155eb99ccfcb1104557458e5323
|
/ARRAY/1313.DecompressRun-LengthEncodedList.cpp
|
5ec526bb141fb6e59cdbbce0ac0d322ab87ae9c7
|
[] |
no_license
|
HarshitaSonkar/LeetCode
|
e7564c784a968bd32fca2ab601a251647356fc12
|
808ccbfc33270346c2009cbeb34924d66cd314d3
|
refs/heads/master
| 2022-12-08T12:44:47.627784
| 2020-08-13T11:03:43
| 2020-08-13T11:03:43
| 227,737,848
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 402
|
cpp
|
1313.DecompressRun-LengthEncodedList.cpp
|
class Solution {
public:
vector<int> decompressRLElist(vector<int>& nums) {
int i;
// int j=0;
int num;
int freq;
vector<int>res;
for(i=0;i<nums.size();i=i+2){
num=nums[i+1];
freq=nums[i];
while(freq--){
res.push_back(num);
}
}
return res;
}
};
|
3aaaec4cfcba5382fde59c120d9f72f938d3fa4b
|
22069dac0dc17447536bad91a158c96165dc9889
|
/EmbSysLib/Src/MCU/STM32F4xx/Sys/System.cpp
|
9358c546c666269aec41d99420c5ecb99ce8604e
|
[
"MIT"
] |
permissive
|
Gagonjh/Embedded-C-Tic-Tac-Toe
|
6a8168e938e24ccd8ccd83d2d3763b4a97334348
|
72f0cf1d21877faf633988ff4df680f0ff9284b9
|
refs/heads/master
| 2023-06-12T02:56:19.249830
| 2021-07-09T18:44:27
| 2021-07-09T18:44:27
| 375,101,112
| 0
| 0
| null | 2021-07-06T15:24:09
| 2021-06-08T18:02:43
|
C
|
UTF-8
|
C++
| false
| false
| 9,115
|
cpp
|
System.cpp
|
//*******************************************************************
/*!
\file System.cpp
\author Thomas Breuer (Bonn-Rhein-Sieg University of Applied Sciences)
\date 23.03.2016
This file is released under the MIT License.
\brief Controller specific implementation of class cSystem
*/
//*******************************************************************
#include "MCU/System.h"
//-------------------------------------------------------------------
#include "stm32f4xx.h"
//-------------------------------------------------------------------
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT (0x05000) //!< Time out for HSE start up
#endif
//*******************************************************************
//
// cSystem
//
//*******************************************************************
//-------------------------------------------------------------------
unsigned char cSystem::cntInterrupt = 0;
//-------------------------------------------------------------------
cSystem::cSystem( unsigned char disableInterrupts )
{
disableWatchdog();
if( disableInterrupts )
{
disableInterrupt();
}
}
//-------------------------------------------------------------------
void cSystem::start( void )
{
enableInterrupt();
}
//-------------------------------------------------------------------
void cSystem::disableInterrupt( void )
{
__disable_irq();
cntInterrupt++;
}
//-------------------------------------------------------------------
void cSystem::enableInterrupt( void )
{
if(cntInterrupt > 0)
{
cntInterrupt--;
}
if(cntInterrupt == 0)
{
__enable_irq();
}
}
//-------------------------------------------------------------------
void cSystem::enterISR( void )
{
cntInterrupt++;
}
//-------------------------------------------------------------------
void cSystem::leaveISR( void )
{
if( cntInterrupt > 0 )
{
cntInterrupt--;
}
}
//-------------------------------------------------------------------
void cSystem::enableWatchdog( MODE mode )
{
DWORD pr = 0;
DWORD rlr = 0;
// timeout = LSI(40kHz) / (4*2^pr * pl)
switch( mode )
{
default:
case WD_TIMEOUT_16ms: pr = 0; rlr = 160; break; // 40kHz/4*16ms
case WD_TIMEOUT_32ms: pr = 0; rlr = 320; break; // 40kHz/4*32ms
case WD_TIMEOUT_65ms: pr = 0; rlr = 650; break; // 40kHz/4*65ms
case WD_TIMEOUT_130ms: pr = 0; rlr = 1300; break; // 40kHz/4*130ms
case WD_TIMEOUT_260ms: pr = 0; rlr = 2600; break; // 40kHz/4*260ms
case WD_TIMEOUT_520ms: pr = 1; rlr = 2600; break; // 40kHz/8*520ms
case WD_TIMEOUT_1000ms: pr = 2; rlr = 2500; break; // 40kHz/16*1000ms
case WD_TIMEOUT_2000ms: pr = 3; rlr = 2500; break; // 40kHz/32*2000ms
}
IWDG->KR = 0x5555;
IWDG->PR = pr;
IWDG->KR = 0x5555;
IWDG->RLR = rlr;
IWDG->KR = 0xAAAA;
IWDG->KR = 0xCCCC;
}
//-------------------------------------------------------------------
void cSystem::disableWatchdog( void )
{
// The watchdog can NOT be disabled by software
}
//-------------------------------------------------------------------
void cSystem::feedWatchdog( void )
{
IWDG->KR = 0xAAAA;
}
//-------------------------------------------------------------------
void cSystem::reset( void )
{
__DSB();
*((unsigned long *)(0x2000FFF0)) = 0xDEADBEEF;
NVIC_SystemReset();
}
#pragma GCC push_options
#pragma GCC optimize ("-O0")
//-------------------------------------------------------------------
void cSystem::delayMicroSec( unsigned short delay )
{
// Calibration:
delay *= 16.5;
for(;delay>0;delay--)
{
asm volatile("nop");
}
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC optimize ("-O0")
//-------------------------------------------------------------------
void cSystem::delayMilliSec( unsigned short delay )
{
for(;delay>0;delay--)
delayMicroSec(1000);
}
#pragma GCC pop_options
//*******************************************************************
//
// SystemInit
//
//*******************************************************************
/*!
This function is a summary of "system_stm32f4xx.c" generated by
"STM32L1xx_Clock_Configuration_V1.1.0.xls"
\see STMicroelectronics, AN3309 Clock configuration tool for
STM32L1xx microcontrollers, Doc ID 18200 Rev 2, January 2012
*/
void SystemInit( void )
{
// Set FPU
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
// System Control Block (SCB), Coprocessor Access Control Register
SCB->CPACR |= (3UL << 10*2) // CP10: Full access
| (3UL << 11*2); // CP11: Full access
#endif
// Clock control register
RCC->CR |= RCC_CR_HSION;
// Clock configuration register
RCC->CFGR = 0x00000000; // reset ...
// Clock control register
RCC->CR &= ~( RCC_CR_PLLON // reset ...
| RCC_CR_CSSON
| RCC_CR_HSEON );
// PLL configuration register
RCC->PLLCFGR = 0x24003010; // Reset value,
// see Reference manual
// Clock control register
RCC->CR &= ~(RCC_CR_HSEBYP); // reset ...
// Clock interrupt register
RCC->CIR = 0; // Disable all interrupts
//-----------------------------------------------------------------
#if defined (_HSE_BYPASS_ON )
RCC->CR |= (RCC_CR_HSEON | RCC_CR_HSEBYP);
#elif defined (_HSE_BYPASS_OFF )
RCC->CR |= (RCC_CR_HSEON );
#else
#error "_HSE_BYPASS not defined"
#endif
//-----------------------------------------------------------------
//! \todo Check code
// Clock control register
RCC->CR |= RCC_CR_HSION; // Need HSION in ADC (only?)
// Wait until HSE is ready or timeout
for( unsigned i = 0; i < HSE_STARTUP_TIMEOUT; i++ )
{
if( RCC->CR & RCC_CR_HSERDY )
break;
}
if( RCC->CR & RCC_CR_HSERDY )
{
// Flash Acess Control Register
FLASH->ACR = FLASH_ACR_ICEN // Instruction cache enable
| FLASH_ACR_DCEN // Data cache enable
| FLASH_ACR_LATENCY_5WS; // Latency: 5 wait states
// Advanced Peripheral Bus Enable Register
RCC->APB1ENR |= RCC_APB1ENR_PWREN; // Power interface clock: enable
// Power Control Register
PWR->CR |= (1<<14); // Regulator voltage scaling output selection:
// VOS=1: Scale 1 mode
// Clock Configuration Register
//! \todo Check clock configuration
RCC->CFGR |= RCC_CFGR_HPRE_DIV1 // AHB prescaler: HCLK = SYSCLK
| RCC_CFGR_PPRE2_DIV4 // APB high-speed prescaler (APB2): PCLK2 = HCLK/4
// PCLK2 must not exceed 84 MHz
| RCC_CFGR_PPRE1_DIV4; // APB low-speed prescaler (APB1): PCLK1 = HCLK/4
// PCLK1 must not exceed 42 MHz
//---------------------------------------------------------------
/* PLL configuration
f_osc +----+ f_in +-----+ f_out +----+ f_pllclk
------>| /M |------>| VCO |--+------+->| /P |---------->
+----+ +->| | | | +----+
| +-----+ | |
| | | +----+ f_pll48ck
| +----+ | +->| /Q |----------->
+--| *N |<--+ +----+
+----+
f_osc: HSI or HSE
f_in = f_osc / M (range: 1 to 2MHz, M = 2,..., 63)
f_out = f_in * N (range: 192 to 432MHz, N = 192,...,432)
f_pllclk = f_out / P (range: up to 168MHz, P = 2,4,6,8 )
f_pll48ck = f_out / Q (equal to 48 MHz, Q = 2,..., 15)
Allowed frequencies due to f_pll48ck:
f_out = 192, 240, 288, 336, 384, 432
Q = 4 5 6 7 8 9
*/
//---------------------------------------------------------------
const DWORD pll_M = (_HSE_CLK)/1000UL; // -> f_in = 1 MHz
const DWORD pll_N = 336; // -> f_out = 336*1 MHz
const DWORD pll_P = 4; // -> f_pllclk = 336/4 MHz = 84 MHz
const DWORD pll_Q = 7; // -> f_pll48ck = 336/7 MHz = 48 MHz
// PLL configuration register
RCC->PLLCFGR = RCC_PLLCFGR_PLLSRC_HSE
| ( pll_M )
| ( pll_N << 6)
| ((pll_P/2-1) << 16)
| ( pll_Q << 24);
// Clock control register
RCC->CR |= RCC_CR_PLLON; // PLL enable: ON
while( !(RCC->CR & RCC_CR_PLLRDY) );// Wait until PLL is ready
// Clock Configuration Register
RCC->CFGR &= ~RCC_CFGR_SW; // reset system clock switch
RCC->CFGR |= RCC_CFGR_SW_PLL; // System clock switch:
// PLL selected as system clock
// Wait for system clock switch is ready
while( (RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL );
}
else
{
// Error: Wrong clock configuration
}
// System Control Block
SCB->VTOR = FLASH_BASE | 0x00; // Vector Table Relocation in internal FLASH
}
//EOF
|
74d16ae2daa7d9a1e5bbdb9e1a7cb9dd5c5f0d3c
|
4d8834a6f7c6b86858a8b2b97992dcc3ab575304
|
/src/RenderingComponent.h
|
46ede4c6b4ff86ce248e3bdbf75826c2355ef4cd
|
[
"Apache-2.0"
] |
permissive
|
WienerTakesAll/WienerTakesAll
|
b15fd354bec7de05a8e4bbd1ed0c431c341ced95
|
6accbf6f0ac04cf990134072474e71f2bc59e7d0
|
refs/heads/master
| 2021-05-14T10:43:12.116656
| 2018-04-21T03:15:43
| 2018-04-21T03:15:43
| 116,359,750
| 2
| 0
|
Apache-2.0
| 2018-04-21T03:15:44
| 2018-01-05T08:10:55
|
C++
|
UTF-8
|
C++
| false
| false
| 1,459
|
h
|
RenderingComponent.h
|
#pragma once
#include <vector>
#include <array>
#include "GL/glew.h"
#include "SDL_opengl.h"
#include "glm/glm.hpp"
struct MeshAsset;
class TextureAsset;
class ShaderAsset;
class RenderingComponent {
public:
RenderingComponent();
//Renders the object from the camera perspective.
void render(glm::mat4x4 camera, float ambient = 0.f) const;
void render_lighting(glm::mat4x4 camera, glm::vec3 light_direction, ShaderAsset* shadow_shader) const;
// Multiplies current transform with new transform
void apply_transform(glm::mat4x4 transform);
// Sets current transform to new transform
void set_transform(glm::mat4x4 transform);
void set_colour_overlay(glm::vec4 colour);
void set_has_shadows(bool has_shadow);
const glm::mat4x4& get_transform() const;
void set_mesh(MeshAsset* mesh);
void set_shadow_mesh(MeshAsset* shadow_mesh);
void set_texture(TextureAsset* texture);
void set_shader(ShaderAsset* shader);
friend class ParticleGenerator;
private:
void setupBuffer();
void setupShadowBuffer();
std::vector<GLuint> gl_vertex_buffers_;
std::vector<GLuint> gl_index_buffers_;
std::vector<GLuint> gl_shadow_vertex_buffers_;
std::vector<GLuint> gl_shadow_index_buffers_;
glm::mat4 transform_matrix_;
glm::vec4 colour_overlay_;
MeshAsset* mesh_;
MeshAsset* shadow_mesh_;
TextureAsset* texture_;
ShaderAsset* shader_;
bool has_shadows_;
};
|
c289ecee420ae7b5d08c93ed06eef54b24b2fdf4
|
9126dcad43938cebf4d9807f713bbd4e33d5cb0e
|
/Base/src/HelloUniverse.cpp
|
518dbd7a0b522f719c4ce0bc0bafe65cd0a6dca5
|
[] |
no_license
|
ramrodBongTech/HelloUniverse
|
4525e409a30cc244937fe1edfef8473b1e892d1c
|
d151446dc82d8141eaa95d8c09125619e1e34872
|
refs/heads/master
| 2021-01-10T05:39:30.159729
| 2015-12-17T20:33:26
| 2015-12-17T20:33:26
| 45,102,373
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,982
|
cpp
|
HelloUniverse.cpp
|
// HelloUniverse.cpp : Defines the entry point for the console application.
///////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include "stdafx.h"
#ifdef _DEBUG
#pragma comment(lib,"sfml-graphics-d.lib")
#pragma comment(lib,"sfml-audio-d.lib")
#pragma comment(lib,"sfml-system-d.lib")
#pragma comment(lib,"sfml-window-d.lib")
#pragma comment(lib,"sfml-network-d.lib")
#pragma comment(lib,"thor-d.lib")
#else
#pragma comment(lib,"sfml-graphics.lib")
#pragma comment(lib,"sfml-audio.lib")
#pragma comment(lib,"sfml-system.lib")
#pragma comment(lib,"sfml-window.lib")
#pragma comment(lib,"sfml-network.lib")
#endif
#pragma comment(lib,"opengl32.lib")
#pragma comment(lib,"glu32.lib")
#include "Player.h"
#include "AsteroidManager.h"
#include "CollisionManager.h"
#include "Menu.h"
#include "Camera.h"
#include "FireworksEmitter.h"
#include "Audio.h"
#include "Controller.h"
////////////////////////////////////////////////////////////
///Entrypoint of application
////////////////////////////////////////////////////////////
sf::Clock myClock;
float rof;
sf::Font menuFont;
sf::Texture menuTexture, playerTexture, cameraTexture, fireTexture;
Player* p;
Camera* camera;
AsteroidManager* asteroidMgr;
thor::ParticleSystem pSystem;
FMOD::System* FMODsys; // Will point to the FMOD system
FMOD_RESULT result;
bool backgroundSoundOn;
FMOD::Channel* backgroundChannel;
FMOD::Sound* backgroundSound;
Asteroid* lastDestroyed;
Audio audio;
Controller controller;
sf::CircleShape reverbCircle(350);
const int MENU_STATE = 0, GAME_STATE = 1;
int state = 0;
void loadAssets()
{
// Font
if (!menuFont.loadFromFile("C:\\Windows\\Fonts\\arial.ttf"))
{
std::cout << "Font Error" << std::endl;
}
// Art
if (!menuTexture.loadFromFile("Black Hole.png") || !playerTexture.loadFromFile("playerShip1_blue.png") ||
!cameraTexture.loadFromFile("grid.png") || !fireTexture.loadFromFile("fireball.png"))
{
std::cout << "Art error" << std::endl;
}
// Loading a sound file
result = FMODsys->createSound("background.ogg", FMOD_DEFAULT, 0, &backgroundSound);
if (result != FMOD_OK)
{
std::cout << "FMOD error! (%d) %s\n" << result;
exit(-1);
}
backgroundSoundOn = true;
reverbCircle.setOrigin(350, 350);
reverbCircle.setPosition(640, 720);
reverbCircle.setFillColor(sf::Color(0, 0, 255, 100));
}
void getUserInput(sf::Time& dt)
{
if (sf::Joystick::isConnected(0) == false)
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && sf::milliseconds(rof) >= p->getFiringDelay())
{
p->fire(dt);
rof = 0;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Z))
{
if (backgroundSoundOn)
{
backgroundChannel->setPaused(true);
backgroundSoundOn = false;
}
else
{
backgroundChannel->setPaused(false);
backgroundSoundOn = true;
}
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::X))
{
if (p->getLaserSound())
{
p->setLaserSound(false);
}
else
{
p->setLaserSound(true);
}
}
}
else if (sf::Joystick::isConnected(0))
{
p->setVelocity(controller.getLeftStickVelocity());
p->setRotation(controller.getRightStickByAngle());
p->setDirection(controller.getRightStickByVector());
if (controller.RightThumbStickDirection.x >= 50 || controller.RightThumbStickDirection.x <= -50
|| controller.RightThumbStickDirection.y >= 50 || controller.RightThumbStickDirection.y <= -50)
{
if (controller.rTriggerState == controller.RTHARD)
{
p->fire(dt);
}
}
if (controller.rTriggerState == controller.RTHARD && sf::milliseconds(rof) >= p->getFiringDelay())
{
p->fire(dt);
rof = 0;
}
}
}
void checkCollisions()
{
std::vector<Bullet *> playerBullets = p->getBullets();
for (int i = 0; i < playerBullets.size(); i++)
{
std::vector<Asteroid *> asteroids = asteroidMgr->getAsteroids();
for (int j = 0; j < asteroids.size(); j++)
{
if (CollisionManager::instance()->checkAsteroidPlayerBullet(asteroids[j], playerBullets[i]))
{
asteroids[j]->setAlive(false);
playerBullets[i]->setAlive(false);
lastDestroyed = asteroids[j];
audio.sound3DSpace();
}
}
}
}
void updateGame(sf::Time& dt, sf::RenderWindow* window)
{
window->draw(reverbCircle);
getUserInput(dt);
p->update(dt);
camera->update(window);
camera->move();
BulletManager::instance()->update(dt);
asteroidMgr->update(dt);
checkCollisions();
if (lastDestroyed != nullptr)
{
audio.sound3DSpaceUpdate(p->getPosition(), p->getVelocity(), lastDestroyed->getPosition());
}
audio.reverbManager();
}
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(1280, 720, 32), "Hello Universe");
// Seed the random generator
srand((unsigned)time(NULL));
window.setFramerateLimit(30);
lastDestroyed = nullptr;
bool part1 = true;
bool part2 = true;
bool part3 = true;
bool part4 = true;
// Setup FMOD
result = FMOD::System_Create(&FMODsys); // Create the main system object.
if (result != FMOD_OK)
{
std::cout << "FMOD error!" << result << FMOD_ErrorString(result);
exit(-1);
}
result = FMODsys->init(100, FMOD_INIT_NORMAL, 0); // Initialize FMOD.
if (result != FMOD_OK)
{
std::cout << "FMOD error!" << result << FMOD_ErrorString(result);
exit(-1);
}
loadAssets();
pSystem.setTexture(fireTexture);
//system.addAffector(FireworkAffector());
asteroidMgr = new AsteroidManager(&pSystem, FMODsys);
/***********************************************************************************************************************************************************/
// Create timer that can be connected to callbacks. Initial time limit is 1 second, timer immediately starts
//thor::CallbackTimer explosionTimer;
//explosionTimer.restart(sf::seconds(1.f));
//// Connect timer to a lambda expression which restarts the timer every time it expires
////explosionTimer.connect([](thor::CallbackTimer& trigger)
////{
//// trigger.restart(explosionInterval);
////});
//// Connect timer to a lambda expression that creates an explosion at expiration
//explosionTimer.connect0([&system]()
//{
// // Compute random position on screen
// sf::Vector2f position(thor::randomDev(400.f, 300.f), thor::randomDev(300.f, 200.f));
// // Add a temporary emitter to the particle system
// system.addEmitter(FireworkEmitter(position), explosionDuration);
//});
/*thor::UniversalEmitter emitter;
emitter.setEmissionRate(30);
emitter.setParticleLifetime(sf::seconds(5));
emitter.setParticlePosition(sf::Vector2f(640, 360));
system.addEmitter(thor::refEmitter(emitter));*/
/***********************************************************************************************************************************************************/
/**************************************************************************************************************************************************************/
Menu menu(window.getSize().x, window.getSize().y, menuTexture, &menuFont);
BulletManager::instance();
CollisionManager::instance();
p = new Player(playerTexture.getSize().x / 2, 0, sf::Vector2f(window.getSize().x / 2, window.getSize().y / 2), sf::Vector2f((100) / 100.0f, (0) / 100.0f), &playerTexture, FMODsys, &pSystem, sf::Vector2f(0, 0));
camera = new Camera(window.getSize().x, window.getSize().y, cameraTexture, p);
// Create a channel to play the sound on
FMODsys->playSound(FMOD_CHANNEL_FREE, backgroundSound, true, &backgroundChannel);
backgroundChannel->setVolume(0.25f);
backgroundChannel->setPaused(false);
backgroundChannel->set3DMinMaxDistance(1, 50);
//update position of sound
if (backgroundChannel)
{
FMOD_VECTOR sourcePos = { 1280/2, 720/2 };
//source is fixed so velocity is zero
backgroundChannel->set3DAttributes(&sourcePos, 0);
}
// Start game loop
while (window.isOpen())
{
sf::Time dt = myClock.restart();
pSystem.update(dt);
audio.update();
// Process events
sf::Event Event;
while (window.pollEvent(Event))
{
// Close window : exit
if (Event.type == sf::Event::Closed)
window.close();
// Escape key : exit
if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape))
window.close();
switch (state)
{
case MENU_STATE:
// Move UI Up
if ((Event.type == sf::Event::KeyReleased) && (Event.key.code == sf::Keyboard::Up))
{
menu.moveUp();
}
// Move UI Down
if ((Event.type == sf::Event::KeyReleased) && (Event.key.code == sf::Keyboard::Down))
{
menu.moveDown();
}
if ((Event.type == sf::Event::KeyReleased) && (Event.key.code == sf::Keyboard::Z))
{
if (backgroundSoundOn)
{
backgroundChannel->setPaused(true);
backgroundSoundOn = false;
}
else
{
backgroundChannel->setPaused(false);
backgroundSoundOn = true;
}
}
// Select
if ((Event.type == sf::Event::KeyReleased) && (Event.key.code == sf::Keyboard::Return))
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::Return))
{
switch (menu.getPressedItem())
{
case 0:
state = GAME_STATE;
break;
case 1:
state = GAME_STATE;
break;
case 2:
std::cout << "High Score button has been pressed!" << std::endl;
break;
case 3:
std::cout << "Options button has been pressed!" << std::endl;
break;
case 4:
std::cout << "Quit button has been pressed!" << std::endl;
window.close();
break;
}
}
// FMOD
//Part 1
if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Num1)) { part1 = !part1; }
if (part1 == true)
{
if ((Event.type == sf::Event::MouseButtonPressed) && (Event.key.code == sf::Mouse::Left)){ audio.left(); }
if ((Event.type == sf::Event::MouseButtonPressed) && (Event.key.code == sf::Mouse::Right)){ audio.right(); }
}
// Part 2
if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Num2)) { part2 = !part2; }
if (part2 == true)
{
audio.pauseBackgroundMusic(false);
}
else { audio.pauseBackgroundMusic(true); }
// Part 3
if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Num3)) { part3 = !part3; }
if (part3 == true)
{
audio.pause3DSound(false);
}
else { audio.pause3DSound(true); }
// Part 4
if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Num4)) { part4 = !part4; }
if (part4 == true)
{
audio.pauseReverb(true);
}
else { audio.pauseReverb(false); }
break;
}
}
// Update particle system and timer
pSystem.update(dt);
//explosionTimer.update();
switch (state)
{
case MENU_STATE:
menu.update();
break;
case GAME_STATE:
updateGame(dt, &window);
controller.update(Event);
break;
}
/*if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::W)){ camera.move(sf::Vector2f(0, -5)); }
if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::A)){ camera.move(sf::Vector2f(-5, 0)); }
if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::S)){ camera.move(sf::Vector2f(0, 5)); }
if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::D)){ camera.move(sf::Vector2f(5, 0)); }*/
//prepare frame
window.clear();
switch (state)
{
case MENU_STATE:
menu.draw(&window);
break;
case GAME_STATE:
window.draw(pSystem, sf::BlendAdd);
BulletManager::instance()->draw(&window);
asteroidMgr->draw(&window);
camera->draw(&window);
break;
}
// Finally, display rendered frame on screen
window.display();
} //loop back for next frame
return EXIT_SUCCESS;
}
|
b132c88ffa913d0ba8552c7015ec7a141ceb344d
|
fbb80b23423ce0fac2abda61ee9ee46164e1371e
|
/ListaDobleEnlazadaCircular/Impl/Main.cpp
|
220e4a38cd80b3e23f789504ef39f3e10e496482
|
[] |
no_license
|
svilerino/Algoritmos-II
|
ccae33536c19b0936545f4118d78d1b078d9962e
|
e55ca55a07807f77302045a67d25c282c122a476
|
refs/heads/master
| 2021-01-10T03:14:00.031227
| 2014-05-08T14:22:02
| 2014-05-08T14:22:02
| 19,576,072
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,199
|
cpp
|
Main.cpp
|
/*
* Main.cpp
*
* Created on: 17/04/2013
* Author: Sil
*/
/*
#include<iostream>
#include "../Header/Lista.h"
using namespace std;
void agregarNodo();
void eliminarNodo();
void modificarNodo();
string obtenerDato();
Lista<string> list;
int main(int argc, char** argv){
int opcion=-1;
while(opcion!=0){
cout << "Elija opcion" << endl;
cout << "1.- Agregar Nodo" << endl;
cout << "2.- Eliminar Nodo" << endl;
cout << "3.- Modificar Nodo" << endl;
cout << "4.- Mostrar Lista" << endl;
cout << "0.- Salir" << endl;
cin >> opcion;
switch(opcion){
case 0:
break;
case 1:
agregarNodo();
break;
case 2:
eliminarNodo();
break;
case 3:
modificarNodo();
break;
case 4:
cout << list;
break;
default:
cerr << "Opc. Invalida" << endl;
break;
}
}
return 0;
}
void agregarNodo(){
string dato = obtenerDato();
list.agregarNodo(dato);
}
string obtenerDato() {
string dato;
cout << "Ingrese Dato :";
cin >> dato;
return dato;
}
void eliminarNodo(){
string dato = obtenerDato();
list.eliminarNodo(dato);
}
void modificarNodo(){
}
*/
|
b608f4e9f80a3bc82a2b457ff6b92576ef8366ea
|
4cdee6597d1801e02a1d359f8444c5de8816f8e5
|
/device/DShowCature/DSAudioCapture.h
|
3b270c3071e986f80ece764ee6681c92a21dc960
|
[] |
no_license
|
dulton/mediafactory
|
d759c3e2bd5a3e98474c5625fe9a28c27ef68bdd
|
a704e2a9776a7bbbc166bbe72713013f4c3bd64c
|
refs/heads/master
| 2021-06-23T22:11:49.075266
| 2017-09-11T03:36:00
| 2017-09-11T03:36:00
| 103,251,070
| 0
| 1
| null | 2017-09-12T09:33:20
| 2017-09-12T09:33:20
| null |
UTF-8
|
C++
| false
| false
| 1,026
|
h
|
DSAudioCapture.h
|
#ifndef _DS_AUDIOCAPTURE_H_
#define _DS_AUDIOCAPTURE_H_
#include "dscapture.h"
class DSAudioGraph;
class DSAudioCaptureDevice;
//class AudioEncoderThread;
struct DSAudioFormat
{
unsigned int samples_per_sec;
unsigned int bits_per_sample;
unsigned int channels;
};
class DSAudioCapture : virtual public DSCapture
{
public:
DSAudioCapture();
~DSAudioCapture();
void Create(const CString& audioDeviceID, const DSAudioFormat& audioFormat, const CString& audioOutname);
void Destroy();
HRESULT SetAudioFormat(DWORD dwPreferredSamplesPerSec,
WORD wPreferredBitsPerSample, WORD nPreferredChannels);
void Start();
void Stop();
int GetBuffer(MEDIA_DATA &data);
int BufferSize();
DSAudioGraph* GetAudioGraph() { return ds_audio_graph_; }
private:
DSAudioCaptureDevice* ds_audio_cap_device_;
DSAudioGraph* ds_audio_graph_;
//AudioEncoderThread* audio_encoder_thread_;
};
#endif // _DS_AUDIOCAPTURE_H_
|
7dccf1b2bd23ffa35f341df33d953859103c52f1
|
141a062e750ad1fe5b3527ff8f3bb46325acc637
|
/Students/abhaysanand/2project/WaterLevel/WaterLevel.ino
|
972064a87a3aced27efaa9cc61275d95f8d4e1b1
|
[] |
no_license
|
CourseReps/ECEN489-Fall2015
|
7edcd364cc639ea1207858dae964a96ba7ee1577
|
a3d3aee3605733ce560e5dfd7ec6729efc0bbef8
|
refs/heads/master
| 2020-04-06T04:34:42.360507
| 2015-12-11T00:39:18
| 2015-12-11T00:39:18
| 41,399,470
| 10
| 11
| null | 2015-09-06T09:11:00
| 2015-08-26T02:23:00
|
C++
|
UTF-8
|
C++
| false
| false
| 489
|
ino
|
WaterLevel.ino
|
#define IRin A0
#define ALPHA 0.0042
void setup()
{
pinMode(IRin, INPUT);
Serial.begin(9600);
}
void shortFilter(double *out, double in, double t)
{
double out1 = *out;
out1 = ((in - out1) * t) + out1;
*out = out1;
}
void loop()
{
static unsigned int a = 0;
a++;
static double IRvalFilt = 0;
double IRval = (double)analogRead(IRin) * 12 / 1023;
shortFilter(&IRvalFilt, IRval, (double)ALPHA);
if(a%100 == 0)
Serial.println(IRvalFilt);
delay(3);
}
|
eb1762fc6ab955b04ddb2d24ce4649eb1bc04238
|
b2b23771e540ab459eb1ab20c32a9238ae4535e8
|
/Subsets/Subsets.h
|
e08f22ebb6bef176b423710055d9cb6fee7b2edf
|
[] |
no_license
|
rsghotra/JUL_2021_DSA
|
8485de6585b074de68e8f424c650f035ef73b892
|
d5298e4353f14cc4a907c84f801c31cdf514a013
|
refs/heads/master
| 2023-08-16T22:55:44.005874
| 2021-09-19T18:42:32
| 2021-09-19T18:42:32
| 382,127,300
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,361
|
h
|
Subsets.h
|
#ifndef SUBSETS_H
#define SUBSETS_H
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<queue>
using namespace std;
class ParanthesisString {
public:
string str;
int openBkt = 0;
int closeBkt = 0;
ParanthesisString(string str, int open, int close) {
this->str = str;
this->openBkt = open;
this->closeBkt = close;
}
};
class TreeNode {
public:
TreeNode* left;
TreeNode* right;
int data;
TreeNode(int data) {
this->left = 0;
this->right = 0;
this->data = data;
}
};
class Subsets {
private:
static vector<vector<int>> FindSubsets(const vector<int>& nums);
static vector<vector<int>> SubsetsWithDuplicates(vector<int>& nums);
static vector<vector<int>> Permutations(const vector<int>& nums);
static vector<string> PermutationsByChangingCase(const string& str);
static vector<string> GenerateParanthesis(int num);
static vector<int> EvaluateExpression(const string& input);
static vector<TreeNode*> FindUniqueTrees(int start, int end);
static int CountUniqueTrees(int end);
public:
static void FindSubsets();
static void SubsetsWithDuplicates();
static void Permutations();
static void PermutationsByChangingCase();
static void GenerateParanthesis();
static void EvaluateExpression();
static void FindUniqueTrees();
static void CountUniqueTrees();
};
#endif
|
b0d1e33240e2a04e0c743bd88fbf24a965867b90
|
af0ecafb5428bd556d49575da2a72f6f80d3d14b
|
/CodeJamCrawler/dataset/08_20614_24.cpp
|
09eb07f22a95dbd1ca16d801f3260a19ff6aabe9
|
[] |
no_license
|
gbrlas/AVSP
|
0a2a08be5661c1b4a2238e875b6cdc88b4ee0997
|
e259090bf282694676b2568023745f9ffb6d73fd
|
refs/heads/master
| 2021-06-16T22:25:41.585830
| 2017-06-09T06:32:01
| 2017-06-09T06:32:01
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,997
|
cpp
|
08_20614_24.cpp
|
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int x, y, min1, min2, max1, max2, top1, down1, top2, down2;
int task,n, m, num, dat[10000][2];
char st[100];
int main(){
freopen("A-small-attempt1.in","r",stdin);
freopen("a.out","w",stdout);
scanf("%d\n", &task);
for (int tk=1; tk<=task; tk++){
printf("Case #%d:\n", tk);
scanf("%d\n",&n);
down1 = down2 = max1 = max2 = -100000000;
top1 = top2 = min1 = min2 = 100000000;
num=0;
for (int i=1; i<=n; i++){
scanf("%d %d", &x, &y);
gets( st );
int o=0;
while ( st[o]==' ' ) o++;
if ( st[o]=='B' ){
max1 >?= x;
min1 <?= x;
max2 >?= y;
min2 <?= y;
}else{
dat[num][0] = x;
dat[num][1] = y;
num++;
}
}
/*
for (int i=0; i<num; i++){
x = dat[i][0]; y= dat[i][1];
if ( x<min1 ) down1 >?= x;
if ( max1<x ) top1 <?= x;
if ( y<min2 ) down2 >?= y;
if ( max2<y ) top2 <?= y;
}
*/
// cout<<min1<<' '<<max1<<endl;
// cout<<min2<<' '<<max2<<endl;
// cout<<down1<<' '<<top1<<endl;
// cout<<down2<<' '<<top2<<endl;
scanf("%d\n", &m);
for (int i=1; i<=m; i++){
scanf("%d%d\n", &x, &y);
if ( min1>max1 || min2>max2 ){
bool ok = false;
for (int i=0; i<num; i++)
if ( dat[i][0]==x && dat[i][1]==y ){
ok = true;
break;
}
if ( ok ) printf("NOT BIRD\n");else
printf("UNKNOWN\n");
continue;
}
if ( min1<=x && x<=max1 && min2<=y && y<=max2 ){
printf("BIRD\n");
continue;
}
bool ok = false;
for (int i=0; i<num; i++)
if ( (dat[i][0]<min1 && x<=dat[i][0] || max1<dat[i][0] && dat[i][0]<=x || min1<=dat[i][0] && dat[i][0]<=max1) &&
(dat[i][1]<min2 && y<=dat[i][1] || max2<dat[i][1] && dat[i][1]<=y || min2<=dat[i][1] && dat[i][1]<=max2)
){
ok = true;
break;
}
if ( ok ) printf("NOT BIRD\n");else
printf("UNKNOWN\n");
}
}
return 0;
}
|
db19cbcc3c0fc3ccd28682aad6f8dd4cae01540b
|
09eaf2b22ad39d284eea42bad4756a39b34da8a2
|
/ojs/codeforces/599/A/A.cpp
|
86a6704039915a39ceac9f169b3cbacc5a5d8ac9
|
[] |
no_license
|
victorsenam/treinos
|
186b70c44b7e06c7c07a86cb6849636210c9fc61
|
72a920ce803a738e25b6fc87efa32b20415de5f5
|
refs/heads/master
| 2021-01-24T05:58:48.713217
| 2018-10-14T13:51:29
| 2018-10-14T13:51:29
| 41,270,007
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 257
|
cpp
|
A.cpp
|
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int ans;
int main () {
scanf("%d %d %d", &a, &b, &c);
ans = a+b+c;
ans = min(ans, a+a+b+b);
ans = min(ans, a+a+c+c);
ans = min(ans, b+b+c+c);
printf("%d\n", ans);
}
|
bb0e21641bef7f8ff50af98cc5a4d07fc102809f
|
3ce84c6401e12cf955a04e3692ce98dc15fa55da
|
/core/geometry/planeFrame.cpp
|
5238177d2af25d738f09730e9f2929f0fdea4a73
|
[] |
no_license
|
PimenovAlexander/corecvs
|
b3470cac2c1853d3237daafc46769c15223020c9
|
67a92793aa819e6931f0c46e8e9167cf6f322244
|
refs/heads/master_cmake
| 2021-10-09T10:12:37.980459
| 2021-09-28T23:19:31
| 2021-09-28T23:19:31
| 13,349,418
| 15
| 68
| null | 2021-08-24T18:38:04
| 2013-10-05T17:35:48
|
C++
|
UTF-8
|
C++
| false
| false
| 25
|
cpp
|
planeFrame.cpp
|
#include "planeFrame.h"
|
ac5b96864107d99a4f34931d21a0b5b1e949dbfe
|
5db060ee3dcdff9de197180acfb0de17c97ef8c0
|
/sieve_linear.cpp
|
77fb7d01c27664e9e6a63fe6d3e1d225ae1a6e92
|
[] |
no_license
|
DeveloperNasima/Number_Theory
|
2865d26c8d060580d05cf5a4f440cd63b5e06032
|
d0e0e338aa7272ab2999554fd748af7acb523c03
|
refs/heads/main
| 2023-07-06T09:36:41.738187
| 2021-08-11T01:56:49
| 2021-08-11T01:56:49
| 396,993,382
| 1
| 0
| null | 2021-08-16T22:19:04
| 2021-08-16T22:19:03
| null |
UTF-8
|
C++
| false
| false
| 420
|
cpp
|
sieve_linear.cpp
|
#include<bits/stdc++.h>
using namespace std;
const int LMT =1e7+7;
int pf[LMT]; //Smallest prime factor
vector<int> prime;
void linear_sieve()
{
for(int i=2; i<LMT; i++)
{
if(pf[i]==0) pf[i]=i,prime.push_back(i);
for(int j=0; j<(int)prime.size() && prime[j]<=pf[i] && i*prime[j]<LMT; j++)
pf[i*prime[j]]=prime[j];
}
}
int main()
{
linear_sieve();
return 0;
}
|
7acfa75ab70a2013225fe48c49a21937ae2526da
|
7bb19ed054d6557a0dafe64a5b99ca5f7aae7f96
|
/src/53.最大子序和dp.cpp
|
b507fdd8cb2dfb6cdfb5575460ce66e64e27914e
|
[] |
no_license
|
hoshinotsuki/leetcodeSolution
|
da329b8977fc67c14dbb7303801ef289469c3eb3
|
f29c64c6f322980cfde62693c119e84f668bfd51
|
refs/heads/master
| 2020-04-24T09:09:14.575801
| 2019-04-10T13:33:19
| 2019-04-10T13:33:19
| 171,854,023
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 958
|
cpp
|
53.最大子序和dp.cpp
|
/*
* @lc app=leetcode.cn id=53 lang=cpp
*
* [53] 最大子序和
*
* https://leetcode-cn.com/problems/maximum-subarray/description/
*
* algorithms
* Easy (42.37%)
* Total Accepted: 41.2K
* Total Submissions: 95.7K
* Testcase Example: '[-2,1,-3,4,-1,2,1,-5,4]'
*
* 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
*
* 示例:
*
* 输入: [-2,1,-3,4,-1,2,1,-5,4],
* 输出: 6
* 解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。
*
*
* 进阶:
*
* 如果你已经实现复杂度为 O(n) 的解法,尝试使用更为精妙的分治法求解。
*
*/
//dp
class Solution {
public:
int maxSubArray(vector<int>& nums) {
if(nums.empty()) return 0;
int sum=0,_max=nums[0];
for(auto num:nums)
{
sum=max(sum+num,num);
_max=max(sum,_max);
}
return _max;
}
};
|
2fd0d94c4a488bc273a47f2ac2469399d98adc2d
|
acdde1143c79084f33bd00e0b1c49f7364540662
|
/src/include/usr/hwas/common/vpdConstants.H
|
9461550e949eec72cb37d37ff6ada660689eb808
|
[
"Apache-2.0"
] |
permissive
|
dongshijiang/hostboot
|
1329be9424dbd23325064cb89f659d7e636fb1ff
|
f1746c417531b1264be23a8dcf1284ae204f6153
|
refs/heads/master
| 2023-06-15T16:05:09.961450
| 2021-06-29T21:04:03
| 2021-07-06T20:33:51
| 385,787,842
| 0
| 0
|
NOASSERTION
| 2021-07-14T02:13:08
| 2021-07-14T02:13:08
| null |
UTF-8
|
C++
| false
| false
| 8,866
|
h
|
vpdConstants.H
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/hwas/common/vpdConstants.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2018,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* 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. */
/* */
/* IBM_PROLOG_END_TAG */
#ifndef VPD_CONSTANTS_H
#define VPD_CONSTANTS_H
namespace HWAS
{
// NOTE: Many of the VPD_CP00_PG_X constants are used to construct an "All Good"
// vector to compare against the PG vector of a system. Changes to
// constants in this file should be reflected in
// src/usr/hwas/plugins/errludParser_pgData.H
// constants the platReadPartialGood will use for looking at the VPD data
const uint32_t VPD_CP00_PG_DATA_LENGTH = 128;
const uint32_t VPD_CP00_PG_HDR_LENGTH = 1;
const uint32_t VPD_CP00_PG_DATA_ENTRIES = VPD_CP00_PG_DATA_LENGTH / 2;
// components of the partial good vector
// * = region does not exist in Nimbus
// + = partial good region
// '0' = region is good (NOTE: opposite of P8 where '1' represented good)
// '1' = region is bad or does not exist
const uint32_t VPD_CP00_PG_FSI_INDEX = 0;
// all good - 4:FSI0, 5:FSI1, 6:FSIa
const uint32_t VPD_CP00_PG_FSI_GOOD = 0xF1FF;
const uint32_t VPD_CP00_PG_PERVASIVE_INDEX = 1;
// all good - 3:VITAL, 4:PRV, 5:NET, 6:PIB, 7:OCC, 8:ANPERV, 14:PLLNEST
const uint32_t VPD_CP00_PG_PERVASIVE_GOOD = 0xE07D;
// all good - 3:VITAL, 4:PRV, 5:NET, 6:PIB, 7:OCC, 8:BE, 9:SBE 14:PLLNEST
const uint32_t VPD_CP00_PG_PERVASIVE_GOOD_AXONE = 0xE03D;
const uint32_t VPD_CP00_PG_N0_INDEX = 2;
// all good - 3:VITAL, 4:PRV, 5:NX, 6:CXA0, 7:PBIOE0, 8:PBIOE1, 9:PBIOE2
const uint32_t VPD_CP00_PG_N0_GOOD = 0xE03F;
const uint32_t VPD_CP00_PG_N1_INDEX = 3;
// all good - 3:VITAL, 4:PRV, 5:MCD, 6:VA, 7:PBIOO0+, 8:PBIOO1+, 9:MCS23+
const uint32_t VPD_CP00_PG_N1_GOOD = 0xE03F;
const uint32_t VPD_CP00_PG_N1_PG_MASK = 0x01C0;
const uint32_t VPD_CP00_PG_N1_PBIOO0 = 0x0100;
const uint32_t VPD_CP00_PG_N1_PBIOO1 = 0x0080;
const uint32_t VPD_CP00_PG_N1_MCS23 = 0x0040;
const uint32_t VPD_CP00_PG_N2_INDEX = 4;
// all good - 3:VITAL, 4:PRV, 5:CXA1, 6:PCIS0, 7:PCIS1, 8:PCIS2, 9:IOPSI
const uint32_t VPD_CP00_PG_N2_GOOD = 0xE03F;
// all good - 3:VITAL, 4:PRV, 6:PCIS0, 7:PCIS1, 8:PCIS2, 9:IOPSI
const uint32_t VPD_CP00_PG_N2_GOOD_AXONE = 0xE43F;
const uint32_t VPD_CP00_PG_N3_INDEX = 5;
// all good - 3:VITAL, 4:PRV, 5:PB, 6:BR, 7:NPU+, 8:MM, 9:INT, 10:MCS01+
const uint32_t VPD_CP00_PG_N3_GOOD = 0xE01F;
const uint32_t VPD_CP00_PG_N3_PG_MASK = 0x0120;
const uint32_t VPD_CP00_PG_N3_NPU = 0x0100;
const uint32_t VPD_CP00_PG_N3_MCS01 = 0x0020;
const uint32_t VPD_CP00_PG_XBUS_INDEX = 6;
// all good - 3:VITAL, 4:PRV, 5:IOX0*, 6:IOX1, 7:IOX2, 8:IOPPE
// 9:PBIOX0*+, 10:PBIOX1+, 11:PBIOX2+, 14:PLLIOX
// Nimbus doesn't physically have PBIOX0 and IOX0. IOX0 is
// taken care of by xbus links, need to handle PBIOX0 as part of
// the full chiplet good, so full good is E40D instead of E44D
// Currently, there are two versions of the MVPD PG keyword:
// 0xE44D == XBUS0 bad
// 0xE45D and 0xE55D == XBUS 0,2 bad
// Spec indicates that both iox (second nibble) and pbiox
// (third nibble) are bad for sforza and monza type modules.
// We support generically the following cases:
// 0xE50D --> xbus chiplet good
// 0xE40D --> xbus chiplet good
// and rely solely on the pbiox as the Xbus target indicator
// (0x0040, 0x0020, 0x0010) for all types of chips.
const uint32_t VPD_CP00_PG_XBUS_GOOD_NIMBUS = 0xE40D;
const uint32_t VPD_CP00_PG_XBUS_GOOD_CUMULUS = 0xE00D;
const uint32_t VPD_CP00_PG_XBUS_PG_MASK = 0x00170;
const uint32_t VPD_CP00_PG_XBUS_IOX[3] = {0x0040, 0x0020, 0x0010};
const uint32_t VPD_CP00_PG_MC01_INDEX = 7;
const uint32_t VPD_CP00_PG_MC23_INDEX = 8;
const uint32_t VPD_CP00_PG_MCxx_INDEX[4] = {VPD_CP00_PG_MC01_INDEX,
VPD_CP00_PG_MC01_INDEX,
VPD_CP00_PG_MC23_INDEX,
VPD_CP00_PG_MC23_INDEX}; // by MCS
// Nimbus:
// all good - 3:VITAL, 4:PRV, 5:MC01, 6:IOM01+, 7:IOM23+, 14:PLLMEM
// all good - 3:VITAL, 4:PRV, 5:MC23, 6:IOM45+, 7:IOM67+, 14:PLLMEM
// Cumulus:
// all good - 3:VITAL, 4:PRV, 5:MC01, 6:IOM01, 7:IOM01PPE, 14:PLLMEM
// all good - 3:VITAL, 4:PRV, 5:MC23, 6:IOM23, 7:IOM23PPE, 14:PLLMEM
// Axone:
// all good - 3:VITAL, 4:PRV, 5:MC01, 6:OMI00, 7:OMI01, 8:OMI002 9:OMIPPE00 14:PLLOMI00
// all good - 3:VITAL, 4:PRV, 5:MC23, 6:OMI10, 7:OMI11, 8:OMI012 9:OMIPPE10 14:PLLOMI10
const uint32_t VPD_CP00_PG_MCxx_GOOD = 0xE0FD;
const uint32_t VPD_CP00_PG_MCxx_GOOD_AXONE = 0xE03D;
const uint32_t VPD_CP00_PG_MCxx_PG_MASK = 0x0300; // Nimbus only
// iom0 and iom4 need to be good for zqcal to work on any
// of the MCAs on that side
const uint32_t VPD_CP00_PG_MCA_MAGIC_PORT_MASK = 0x0200;
const uint32_t VPD_CP00_PG_MCxx_IOMyy[4] = {0x0200, 0x0100, 0x0200, 0x0100};
const uint32_t VPD_CP00_PG_OB0_INDEX = 9;
const uint32_t VPD_CP00_PG_OB3_INDEX = 12;
// all good - 3:VITAL, 4:PRV, 5:PLIOOAx, 6:IOOx, 14:PLLIOO; x=0, 1*, 2*, 3
const uint32_t VPD_CP00_PG_OBUS_GOOD = 0xE1FD;
const uint32_t VPD_CP00_PG_PCI0_INDEX = 13;
// all good - 3:VITAL, 4:PRV, 5:PCI00, 6:IOPCI0, 14:PLLPCI0
// all good - 3:VITAL, 4:PRV, 5:PCI11, 6:PCI12, 7:IOPCI1, 14:PLLPCI1
// all good - 3:VITAL, 4:PRV, 5:PCI23, 6:PCI24, 7:PCI25, 8:IOPCI2, 14:PLLPCI2
const uint32_t VPD_CP00_PG_PCIx_GOOD[3] = {0xE1FD, 0xE0FD, 0xE07D};
const uint32_t VPD_CP00_PG_EP0_INDEX = 16;
const uint32_t VPD_CP00_PG_EP5_INDEX = 21;
// all good - 3:VITAL, 4:PRV, 5:EQPB, 6:L30+, 7:L31+,
// 8:L20+, 9:L21+, 10:AN, 11:PBLEQ, 12:REFR0, 13:REFR1, 14:DPLL
const uint32_t VPD_CP00_PG_EPx_GOOD = 0xE001;
const uint32_t VPD_CP00_PG_EPx_PG_MASK = 0x03CC;
const uint32_t VPD_CP00_PG_EPx_L3L2REFR[2] = {0x0288, 0x0144};
const uint32_t VPD_CP00_PG_EC00_INDEX = 32;
// all good - 3:VITAL, 4:PRV, 5:C00, 6:C01
const uint32_t VPD_CP00_PG_ECxx_GOOD = 0xE1FF;
const uint32_t VPD_CP00_PG_ECxx_MAX_ENTRIES = 24;
const uint32_t VPD_CP00_PG_MAX_USED_INDEX = 55;
const uint32_t VPD_CP00_PG_xxx_VITAL = 0x1000;
const uint32_t VPD_CP00_PG_xxx_PERV = 0x0800;
const uint32_t VPD_CP00_PG_RESERVED_GOOD = 0xFFFF;
// constants the platReadPR will use for looking at the VPD data
const uint32_t VPD_VINI_PR_DATA_LENGTH = 8; //@deprecrated
// constants the platReadLx will use for looking at the VPD data
const uint32_t VPD_CRP0_LX_HDR_DATA_LENGTH = 256;
const uint32_t VPD_CRP0_LX_FREQ_INDEP_INDEX = 8;
const uint32_t VPD_CRP0_LX_PORT_DISABLED = 0;
const uint8_t VPD_CRP0_LX_MIN_X = 1;
const uint8_t VPD_CRP0_LX_MAX_X = 8;
// constants for the error log parser for partial good issues
const uint8_t MODEL_PG_DATA_ENTRIES = 2;
}
#endif
|
38426734132aaf4ef3aab975bdb2b28a70cddbd9
|
e0b89d00d436de0e708554f33ef761b5fc51c5cc
|
/Pointers/DynamicMemoryAllocation.cpp
|
3df02538ebb3b95e6442b3ee9fa3d5485288d29c
|
[] |
no_license
|
JaveedYara72/Code-For-Data-Structures-and-Algorithms-Written-in-C-
|
6c78fbda09ca953b3e68301057524974c9df9387
|
3d3911fcce4a5be65793d62d48c187c528cba49d
|
refs/heads/master
| 2023-01-11T02:48:45.506985
| 2020-11-14T18:08:45
| 2020-11-14T18:08:45
| 287,501,592
| 1
| 4
| null | 2020-10-05T11:01:37
| 2020-08-14T09:58:37
|
C
|
UTF-8
|
C++
| false
| false
| 376
|
cpp
|
DynamicMemoryAllocation.cpp
|
// Dynamic Memory Allocation
int n;
cin >> n;
int* a = new int[n][0]; //All Elements are Zeroes.
for (int i = 0; i < n; i++) {
cin >> a[i];
cout << a[i] << " ";
}
//Create 2d Array Dynamically
int **arr;
cin>>r>>c;
arr = new int[r];
for(int i=0;i<n;i++){
arr[i] = new int[c];
}
for(int i = 0;i<r;i++){
for(int j=0;i<c;j++){
cin>>arr[i][j];
}
}
|
6ca87165bca3c916b0d549fdcef6ed29eb79db11
|
c06390961e303682bd90add6ded4ae151616b3a3
|
/operator.cpp
|
3a41c7cfdf9d850608189f9b1a4c12815789ee9f
|
[] |
no_license
|
vishnuprajapati1999/Rational
|
9a293a4925a0738c5547d5b17a4cb1dcfe99cdb2
|
f9dfd7bb3ad2f4bfffe6cf6617515d48e31db8c5
|
refs/heads/master
| 2020-04-18T11:42:03.431817
| 2019-01-25T08:12:25
| 2019-01-25T08:12:25
| 167,510,241
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,102
|
cpp
|
operator.cpp
|
/* this is program for calculate arithmatic problems
of rational numbers
Made by Vishnu Prajapati
Vilnius Kolegija
Date:24/01/2019
*/
#include<iostream> //adding header file
using namespace std; //for using standard function from header files
class Complex //defining class named Complex
{
private:
float num, dem; //private class variable
public:
Complex(float r = 0, float i =1) //Constructor for class Complex
{
num = r; dem = i; //converting public class variable to private class variable.
}
friend Complex operator + (Complex const &, Complex const &); //declaring friend function inside class
friend Complex operator - (Complex const &, Complex const &);//declaring friend function inside class
friend Complex operator * (Complex const &, Complex const &);//declaring friend function inside class
friend Complex operator / (Complex const &, Complex const &);//declaring friend function inside class
friend Complex operator > (Complex const &, Complex const &);//declaring friend function inside class
};
Complex operator + (Complex const &c1, Complex const &c2) //defining operator overloading function for addition outside of class
{
Complex c3; //define a new object
c3.num=((c1.num*c2.dem)+(c1.dem*c2.num));//logic for addition
c3.dem=(c1.dem*c2.dem);
cout<<"="<<c3.num<<"/"<<c3.dem<<endl;
cout<<"\n--------------------------------------------------------------------------------------------------\n";
}
Complex operator - (Complex const &c1, Complex const &c2) //defining operator overloading function outside of class
{
Complex c3; //define a new object
c3.num=((c1.num*c2.dem)-(c1.dem*c2.num));//logic for subtraction
c3.dem=(c1.dem*c2.dem);
cout<<"="<<c3.num<<"/"<<c3.dem<<endl;
cout<<"\n--------------------------------------------------------------------------------------------------\n";
}
Complex operator * (Complex const &c1, Complex const &c2) //defining operator overloading function outside of class
{
Complex c3; //define a new object
c3.num=((c1.num*c2.num));//logic for multiply
c3.dem=(c1.dem*c2.dem);
cout<<"="<<c3.num<<"/"<<c3.dem<<endl;
cout<<"\n----------------------------------------------------------------------------------------------------\n";
}
Complex operator / (Complex const &c1, Complex const &c2) //defining operator overloading function outside of class
{
Complex c3; //define a new object
c3.num=((c1.num*c2.dem));//logic for division
c3.dem=(c1.dem*c2.num);
cout<<"="<<c3.num<<"/"<<c3.dem<<endl;
cout<<"\n----------------------------------------------------------------------------------------------------\n";
}
Complex operator > (Complex const &c1, Complex const &c2) //defining operator overloading function outside of class
{ float w,r;//member variables
Complex c3; //define a new object
w=((c1.num/c1.dem));//logic for comparision
r=(c2.num/c2.dem);
if(w>r){
cout<<c1.num<<"/"<<c1.dem<< " is "<<"greater than"<<c2.num<<"/"<<c2.dem<<endl;
cout<<"\n------------------------------------------------------------------------------------------------\n";
}
else if(w<r){
cout<<c2.num<<"/"<<c2.dem<< " is "<<"greater than"<<c1.num<<"/"<<c1.dem<<endl;
cout<<"\n------------------------------------------------------------------------------------------------\n";
}
else if(w==r){
cout<<c1.num<<"/"<<c1.dem<< " is "<<"equal to "<<c2.num<<"/"<<c2.dem<<endl;
cout<<"\n--------------------------------------------------------------------------------------------------\n";
}
}
int main()
{ int choice,a,b,c,d;//main function variables
Complex c3,c1,c2;//objects of class
while(1){
start:
cout<<"***********Welcome to Desire Calculator***********"<<endl;//options for calculator
cout<<"1. for addition"<<endl;
cout<<"2. for subtraction"<<endl;
cout<<"3. multiply"<<endl;
cout<<"4. division"<<endl;
cout<<"5. compare"<<endl;
cout<<"6. compare"<<endl;
cin>>choice;
switch(choice) {
case 1://for 1st case
{
cout<<"enter fist number:"<<endl;
cin>>a;
cout<<"/", cin>>b;
cout<<endl;
if(b==0){
cout<<"*****dinominator must not be zero.******";
goto start;
}
cout<<"enter second number:"<<endl;
cin>>c;
cout<<"/", cin>>d;
cout<<endl;
if(d==0){
cout<<"*****dinominator must not be zero.******";
goto start;
}
Complex c1(a,b), c2(c,d);//storing variables into object constructor variable
c3 = c1 + c2;//use of operator overloading and doing addition of rational numbers
break;
}
case 2:
{
cout<<"enter fist number:"<<endl;
cin>>a;
cout<<"/", cin>>b;
cout<<endl;
if(b==0){
cout<<"*****dinominator must not be zero.******";
goto start;
}
cout<<"enter second number:"<<endl;
cin>>c;
cout<<"/", cin>>d;
cout<<endl;
if(d==0){
cout<<"*****dinominator must not be zero.******";
goto start;
}
Complex c1(a,b), c2(c,d);//storing variables into object constructor variable
c3 = c1 - c2;//use of operator overloading and doing subtraction of rational numbers
break;
}
case 3:
{
cout<<"enter fist number:"<<endl;
cin>>a;
cout<<"/", cin>>b;
cout<<endl;
if(b==0){
cout<<"*****dinominator must not be zero.******";
goto start;
}
cout<<"enter second number:"<<endl;
cin>>c;
cout<<"/", cin>>d;
cout<<endl;
if(d==0){
cout<<"*****dinominator must not be zero.******";
goto start;
}
Complex c1(a,b), c2(c,d);//storing variables into object constructor variable
c3 = c1 * c2;//use of operator overloading and doing multiply of rational numbers
break;
}
case 4:
{
cout<<"enter fist number:"<<endl;
cin>>a;
cout<<"/", cin>>b;
cout<<endl;
if(b==0){
cout<<"*****dinominator must not be zero.******";
goto start;
}
cout<<"enter second number:"<<endl;
cin>>c;
cout<<"/", cin>>d;
cout<<endl;
if(d==0){
cout<<"*****dinominator must not be zero.******";
goto start;
}
Complex c1(a,b), c2(c,d);//storing variables into object constructor variable
c3 = c1 / c2;//use of operator overloading and doing division of rational numbers
break;
}
case 5:
{
cout<<"enter fist number:"<<endl;
cin>>a;
cout<<"/", cin>>b;
cout<<endl;
if(b==0){
cout<<"*****dinominator must not be zero.******";
goto start;
}
cout<<"enter second number:"<<endl;
cin>>c;
cout<<"/", cin>>d;
cout<<endl;
if(d==0){
cout<<"*****dinominator must not be zero.******";
goto start;
}
Complex c1(a,b), c2(c,d);//storing variables into object constructor variable
c3 = c1 > c2;//use of operator overloading and doing comparision of rational numbers
break;
}
case 6:
{
exit(0);
break;
}
}
}
}
|
4bb864b246e6882aca5cbe6e5b3e478a8424683c
|
22da83ee2d8c9d0c63bd48f2245b99c2149e0398
|
/graph_stats/input.hh
|
cf206a1f28f56356bd220c060ccf4073fac3ddae
|
[] |
no_license
|
dilkas/maximum-common-subgraph
|
e67cf25c2dbcb469418a916f0ab414a58343c821
|
366516b6a380e5f3d30beba77afa64b3cb96491b
|
refs/heads/master
| 2022-04-06T13:37:25.620595
| 2019-12-26T16:53:35
| 2019-12-26T16:53:35
| 104,836,115
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 721
|
hh
|
input.hh
|
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
#ifndef GUARD_INPUT_HH
#define GUARD_INPUT_HH 1
#include "graph.hh"
#include <string>
/**
* Thrown if we come across bad data in a graph file, or if we can't read a
* graph file.
*/
class GraphFileError :
public std::exception
{
private:
std::string _what;
public:
GraphFileError(const std::string & filename, const std::string & message) throw ();
auto what() const throw () -> const char *;
};
/**
* Read a LAD format file into a Graph.
*
* \throw GraphFileError
*/
auto read_lad(const std::string & filename) -> Graph;
auto read_vf(const std::string & filename, bool unlabelled, bool no_edge_labels) -> Graph;
#endif
|
24029ce2875feb775a5af5c5c984ac482e967ae8
|
2873931ff19ed91af7e13073b74d9895fbc5f20d
|
/C++/my_unique_ptr.cpp
|
65d93ddf7f3043d6a023dcece07fd62c6e48771c
|
[] |
no_license
|
rahuljain81/Algorithms
|
f1eafad90b3b37893a663092843978b9125ffc4d
|
32312c51814fefeba717037c343c138b7c393293
|
refs/heads/master
| 2021-06-18T05:23:42.485612
| 2021-03-07T15:55:07
| 2021-03-07T15:55:07
| 59,131,217
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,593
|
cpp
|
my_unique_ptr.cpp
|
//Compile using: g++ -std=c++11 my_unique_ptr.cpp
#include <iostream>
#include <vector>
using namespace std;
template <class T>
class my_unique_ptr
{
private:
T* ptr = nullptr;
public:
my_unique_ptr(): ptr(nullptr) //default constructor
{
cout << __func__ << __LINE__<< endl;
}
my_unique_ptr (T* _ptr): ptr(_ptr) //constructor
{
cout << __func__ << __LINE__<< endl;
}
//Remove copy constructor and assignment
my_unique_ptr(const my_unique_ptr & _ptr) = delete;
my_unique_ptr & operator= (const my_unique_ptr &_ptr) = delete;
//Move
my_unique_ptr(my_unique_ptr && dyingObj) //move constructor
{
cout << __func__ << __LINE__<< endl;
//Transfer ownership of memory
this->ptr = dyingObj.ptr;
dyingObj.ptr = nullptr;
}
void operator=(my_unique_ptr && dyingObj) //move assignment
{
__cleanup__(); //cleanup existing data
cout << __func__ << __LINE__<< endl;
//Transfer of ownership
this->ptr = dyingObj.ptr;
dyingObj.ptr = nullptr;
}
T* operator->() //Obtaining pointer using arrow ptr
{
cout << __func__ << endl;
return this->ptr;
}
T& operator*() //dereferencing underlying pointer
{
cout << __func__ << __LINE__<< endl;
return *(this->ptr);
}
~my_unique_ptr() //destructor
{
cout << __func__ << endl;
__cleanup__();
}
private:
void __cleanup__()
{
if (ptr != nullptr)
delete ptr;
}
};
int main()
{
my_unique_ptr <int> box(new int);
my_unique_ptr <int> box1;
vector <my_unique_ptr<int>> v;
v.push_back (my_unique_ptr <int> {new int (10)});
return 0;
}
|
abf89eee4a39085a6cec48f37c8346aef0759072
|
87afcd0e60452c44686a4c313ea63b82f93eb6f2
|
/myDockTitleBar.h
|
a08ab145c95a13dd61d28c6f10cde3be466e53a5
|
[] |
no_license
|
519984307/FaceModel
|
6a9b024c7160df470650d92b6f933fb41a9fc4ac
|
ffb869d20cdba64caf516468c4828b2781830cb7
|
refs/heads/master
| 2023-03-16T23:03:15.978846
| 2019-09-05T00:39:48
| 2019-09-05T00:39:48
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 667
|
h
|
myDockTitleBar.h
|
#pragma once
#include <QWidget>
#include <QSize>
#include <QDockWidget>
#include <QMouseEvent>
#include <QWidget>
#include <QPainter>
#include <QPaintEvent>
#include "qdebug.h"
#include <QStyle>
class MyDockTitleBar : public QWidget
{
Q_OBJECT
public:
MyDockTitleBar(QWidget *parent);
~MyDockTitleBar();
QSize sizeHint() const
{
return minimumSizeHint();
}
QSize minimumSizeHint() const;
void SetIcon(QPixmap icon);
void SetTitle(QString title);
protected:
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
public slots:
void updateMask();
private:
QPixmap minPix, closePix, floatPix,iconPix;
QString mTitle;
};
|
91659b899effbd17ac60f772c645439c24e32f6c
|
f0edfc17bbddeca80afc8cca7e06c4878868ce2a
|
/Wavelet.cpp
|
669973646df71e995fe40d4aaec885cdc47e5857
|
[] |
no_license
|
wenglihong/Digital-Image-Processing
|
1afcb8ed96136a421a38b6d3b525b7eb3983dc8e
|
1ccd2ce9136e6982c106a2b0630912ec422ef9d9
|
refs/heads/master
| 2021-01-10T02:16:56.779888
| 2015-11-12T15:04:42
| 2015-11-12T15:04:42
| 46,060,059
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 7,502
|
cpp
|
Wavelet.cpp
|
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <stdio.h>
#include <string>
#include <fstream> //文件输入输出流
using namespace cv;
using namespace std;
Mat WDT(const Mat &_src, const string _wname, const int _level);
Mat IWDT(const Mat &_src, const string _wname, const int _level);
void wavelet(const string _wname, Mat &_lowFilter, Mat &_highFilter);
Mat waveletDecompose(const Mat &_src, const Mat &_lowFilter, const Mat &_highFilter);
Mat waveletReconstruct(const Mat &_src, const Mat &_lowFilter, const Mat &_highFilter);
int main(void)
{
string filename = ".\\image\\lena.bmp";//文件路径及名称
Mat src = imread(filename);//读取源图像
if (src.empty())
return -1;
cvtColor(src,src,CV_RGB2GRAY);
Mat dst2 = WDT(src, "haar", 3);
imshow("src",src);
imshow("dst2", dst2);
waitKey();
return 0;
}
/// 小波变换
Mat WDT(const Mat &_src, const string _wname, const int _level)
{
//int reValue = THID_ERR_NONE;
Mat src = Mat_<float>(_src);
Mat dst = Mat::zeros(src.rows, src.cols, src.type());
int N = src.rows;
int D = src.cols;
/// 高通低通滤波器
Mat lowFilter;
Mat highFilter;
wavelet(_wname, lowFilter, highFilter);
/// 小波变换
int t = 1;
int row = N;
int col = D;
while (t <= _level)
{
///先进行行小波变换
for (int i = 0; i<row; i++)
{
/// 取出src中要处理的数据的一行
Mat oneRow = Mat::zeros(1, col, src.type());
for (int j = 0; j<col; j++)
{
oneRow.at<float>(0, j) = src.at<float>(i, j);
}
oneRow = waveletDecompose(oneRow, lowFilter, highFilter);
/// 将src这一行置为oneRow中的数据
for (int j = 0; j<col; j++)
{
dst.at<float>(i, j) = oneRow.at<float>(0, j);
}
}
normalize(dst, dst, 0, 1, NORM_MINMAX);
//imshow("dst1", dst);
#if 0
//normalize( dst, dst, 0, 255, NORM_MINMAX );
IplImage dstImg1 = IplImage(dst);
cvSaveImage("dst.jpg", &dstImg1);
#endif
/// 小波列变换
for (int j = 0; j<col; j++)
{
/// 取出src数据的一行输入
Mat oneCol = Mat::zeros(row, 1, src.type());
for (int i = 0; i<row; i++)
{
oneCol.at<float>(i, 0) = dst.at<float>(i, j);
}
oneCol = (waveletDecompose(oneCol.t(), lowFilter, highFilter)).t();
for (int i = 0; i<row; i++)
{
dst.at<float>(i, j) = oneCol.at<float>(i, 0);
}
}
normalize( dst, dst, 0, 1, NORM_MINMAX );
//imshow("dst2", dst);
#if 0
IplImage dstImg2 = IplImage(dst);
cvSaveImage("dst.jpg", &dstImg2);
#endif
/// 更新
row /= 2;
col /= 2;
t++;
src = dst;
}
return dst;
}
/// 小波逆变换
Mat IWDT(const Mat &_src, const string _wname, const int _level)
{
//int reValue = THID_ERR_NONE;
Mat src = Mat_<float>(_src);
Mat dst = Mat::zeros(src.rows, src.cols, src.type());
int N = src.rows;
int D = src.cols;
/// 高通低通滤波器
Mat lowFilter;
Mat highFilter;
wavelet(_wname, lowFilter, highFilter);
/// 小波变换
int t = 1;
int row = N / std::pow(2., _level - 1);
int col = D / std::pow(2., _level - 1);
while (row <= N && col <= D)
{
/// 小波列逆变换
for (int j = 0; j<col; j++)
{
/// 取出src数据的一行输入
Mat oneCol = Mat::zeros(row, 1, src.type());
for (int i = 0; i<row; i++)
{
oneCol.at<float>(i, 0) = src.at<float>(i, j);
}
oneCol = (waveletReconstruct(oneCol.t(), lowFilter, highFilter)).t();
for (int i = 0; i<row; i++)
{
dst.at<float>(i, j) = oneCol.at<float>(i, 0);
}
}
//normalize( dst, dst, 0, 1, NORM_MINMAX );
imshow("dst3",dst);
#if 0
//normalize( dst, dst, 0, 255, NORM_MINMAX );
IplImage dstImg2 = IplImage(dst);
cvSaveImage("dst.jpg", &dstImg2);
#endif
///行小波逆变换
for (int i = 0; i<row; i++)
{
/// 取出src中要处理的数据的一行
Mat oneRow = Mat::zeros(1, col, src.type());
for (int j = 0; j<col; j++)
{
oneRow.at<float>(0, j) = dst.at<float>(i, j);
}
oneRow = waveletReconstruct(oneRow, lowFilter, highFilter);
/// 将src这一行置为oneRow中的数据
for (int j = 0; j<col; j++)
{
dst.at<float>(i, j) = oneRow.at<float>(0, j);
}
}
normalize( dst, dst, 0, 1, NORM_MINMAX );
imshow("dst4",dst);
#if 0
//normalize( dst, dst, 0, 255, NORM_MINMAX );
IplImage dstImg1 = IplImage(dst);
cvSaveImage("dst.jpg", &dstImg1);
#endif
row *= 2;
col *= 2;
src = dst;
}
return dst;
}
////////////////////////////////////////////////////////////////////////////////////////////
/// 调用函数
/// 生成不同类型的小波,现在只有haar,sym2
void wavelet(const string _wname, Mat &_lowFilter, Mat &_highFilter)
{
if (_wname == "haar" || _wname == "db1")
{
int N = 2;
_lowFilter = Mat::zeros(1, N, CV_32F);
_highFilter = Mat::zeros(1, N, CV_32F);
_lowFilter.at<float>(0, 0) = 1 / sqrtf(N);
_lowFilter.at<float>(0, 1) = 1 / sqrtf(N);
_highFilter.at<float>(0, 0) = -1 / sqrtf(N);
_highFilter.at<float>(0, 1) = 1 / sqrtf(N);
}
if (_wname == "sym2")
{
int N = 4;
float h[] = { -0.483, 0.836, -0.224, -0.129 };
float l[] = { -0.129, 0.224, 0.837, 0.483 };
_lowFilter = Mat::zeros(1, N, CV_32F);
_highFilter = Mat::zeros(1, N, CV_32F);
for (int i = 0; i<N; i++)
{
_lowFilter.at<float>(0, i) = l[i];
_highFilter.at<float>(0, i) = h[i];
}
}
}
/// 小波分解
Mat waveletDecompose(const Mat &_src, const Mat &_lowFilter, const Mat &_highFilter)
{
assert(_src.rows == 1 && _lowFilter.rows == 1 && _highFilter.rows == 1);
assert(_src.cols >= _lowFilter.cols && _src.cols >= _highFilter.cols);
Mat &src = Mat_<float>(_src);
int D = src.cols;
Mat &lowFilter = Mat_<float>(_lowFilter);
Mat &highFilter = Mat_<float>(_highFilter);
/// 频域滤波,或时域卷积;ifft( fft(x) * fft(filter)) = cov(x,filter)
Mat dst1 = Mat::zeros(1, D, src.type());
Mat dst2 = Mat::zeros(1, D, src.type());
filter2D(src, dst1, -1, lowFilter);
filter2D(src, dst2, -1, highFilter);
/// 下采样
Mat downDst1 = Mat::zeros(1, D / 2, src.type());
Mat downDst2 = Mat::zeros(1, D / 2, src.type());
resize(dst1, downDst1, downDst1.size());
resize(dst2, downDst2, downDst2.size());
/// 数据拼接
for (int i = 0; i<D / 2; i++)
{
src.at<float>(0, i) = downDst1.at<float>(0, i);
src.at<float>(0, i + D / 2) = downDst2.at<float>(0, i);
}
return src;
}
/// 小波重建
Mat waveletReconstruct(const Mat &_src, const Mat &_lowFilter, const Mat &_highFilter)
{
assert(_src.rows == 1 && _lowFilter.rows == 1 && _highFilter.rows == 1);
assert(_src.cols >= _lowFilter.cols && _src.cols >= _highFilter.cols);
Mat &src = Mat_<float>(_src);
int D = src.cols;
Mat &lowFilter = Mat_<float>(_lowFilter);
Mat &highFilter = Mat_<float>(_highFilter);
/// 插值;
Mat Up1 = Mat::zeros(1, D, src.type());
Mat Up2 = Mat::zeros(1, D, src.type());
/// 插值为0
//for ( int i=0, cnt=1; i<D/2; i++,cnt+=2 )
//{
// Up1.at<float>( 0, cnt ) = src.at<float>( 0, i ); ///< 前一半
// Up2.at<float>( 0, cnt ) = src.at<float>( 0, i+D/2 ); ///< 后一半
//}
/// 线性插值
Mat roi1(src, Rect(0, 0, D / 2, 1));
Mat roi2(src, Rect(D / 2, 0, D / 2, 1));
resize(roi1, Up1, Up1.size(), 0, 0, INTER_CUBIC);
resize(roi2, Up2, Up2.size(), 0, 0, INTER_CUBIC);
/// 前一半低通,后一半高通
Mat dst1 = Mat::zeros(1, D, src.type());
Mat dst2 = Mat::zeros(1, D, src.type());
filter2D(Up1, dst1, -1, lowFilter);
filter2D(Up2, dst2, -1, highFilter);
/// 结果相加
dst1 = dst1 + dst2;
return dst1;
}
|
4a273e1f531a13476123241d4ec00b6c2beec734
|
acff1e354047becf999e10154bac01dbf210cd4c
|
/Chapter-14-Overload-Conversion/ex14.28-StrBloTest.cpp
|
6d9b04658d38fd3092b07351ef558e6adaf44ed5
|
[] |
no_license
|
middleprince/CPP-Primer
|
e1f6440a6aa4c11d9f3b3b0b88579d2294d2ef53
|
345d99a4b3f41aab24598edc61a01b6f09f0ab61
|
refs/heads/master
| 2021-06-25T00:28:01.014655
| 2021-01-18T13:27:38
| 2021-01-18T13:27:38
| 189,856,807
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 417
|
cpp
|
ex14.28-StrBloTest.cpp
|
#include "ex14.28.StrBlob.hpp"
int main() {
StrBlob strs{"one", "two", "three", "four"};
StrBlobPtr p = strs.begin();
cout << " Test output *(p+2), which should be three" << endl;
cout << *(p+2) << endl;
cout << "Test *(p-2), which should be : one" << endl;
cout << *(p-2) << endl;
cout << "Test out of index, *(p+5)" << endl;
cout << *(p+5) << endl;
return 0;
}
|
0759600df49e07a63b992d9fa877deb2d0db8c90
|
4607a055d1933dec127e9dc218b7e6d26a006668
|
/LeetCode_559_Maximum_Depth_of_N_Ary_Tree.cpp
|
60b089c97cbd136bc3062dc9fb10544eb6c05ecb
|
[] |
no_license
|
sonugiri1043/LeetCode
|
63c71e518e10c54d363740b4580b4e620d3fdf05
|
12cdf4f8d1cd2cc5f4f08e4f5cf037b45254d5bb
|
refs/heads/master
| 2021-08-16T21:52:11.590306
| 2020-06-05T21:22:23
| 2020-06-05T21:22:23
| 190,054,927
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 447
|
cpp
|
LeetCode_559_Maximum_Depth_of_N_Ary_Tree.cpp
|
/*
559. Maximum Depth of N-ary Tree
Given a n-ary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from
the root node down to the farthest leaf node.
*/
class Solution {
public:
int maxDepth( Node* root ) {
if( !root ) return 0;
int maxHeight = 0;
for( auto node : root->children ) {
maxHeight = max( maxHeight, maxDepth( node ) );
}
return 1 + maxHeight;
}
};
|
42041b894b5a45670b75c6787fa868ca0b2cf5a4
|
29c52497fbefbd7159f4d3578569df6d084644a0
|
/Jekyll/src/Jekyll/Log.h
|
b5a88e044a2566a156dcc26cc33205f89ee09c2a
|
[] |
no_license
|
shyde8/Jekyll
|
68347be5cb30d9881f5ac7501703288195c0f8e4
|
d7b4af5f180d575a53ec70432f46b76e6a779593
|
refs/heads/master
| 2022-11-25T01:04:37.545873
| 2020-07-20T00:13:38
| 2020-07-20T00:13:38
| 269,854,705
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,686
|
h
|
Log.h
|
// TODO //
// 1. write messages to alternative locations (VS, file. in-game console)
// 2. specify location in window to write messages
// 3. LogLevel enum ???
// 4. additional log categories (i.e. Fatal)
// 5. add argument parameters to the Log functions
// 6. ability to take in inputs aside from string, similarly to how std::cout works (override << )
// 7. do we need to worry about clearing old logs / flushing buffers / resetting state ???
// 8. store actual log message in std::string, or another structure ???
// 9. stacktrace / timestamps
// 10. cleanup when program ends
// 11. disable = operator
#pragma once
#include <string>
#include <iostream>
#define __LOCATION__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#if JKL_LOGLEVEL >= 2
#define LOG_INFORMATION(message) Jekyll::Log::Get().LogInformation(__LOCATION__, __LINE__, message)
#else
#define LOG_INFORMATION(message)
#endif
#if JKL_LOGLEVEL >= 1
#define LOG_WARNING(message) Jekyll::Log::Get().LogWarning(__LOCATION__, __LINE__, message)
#else
#define LOG_WARNING(message)
#endif
#if JKL_LOGLEVEL >= 0
#define LOG_ERROR(message) Jekyll::Log::Get().LogError(__LOCATION__, __LINE__, message)
#else
#define LOG_ERROR(message)
#endif
namespace Jekyll
{
class _declspec(dllexport) Log
{
public:
Log(const Log&) = delete;
static Log& Get()
{
static Log instance;
return instance;
}
void LogError(const std::string& location, int line, const std::string& message);
void LogWarning(const std::string& location, int line, const std::string& message);
void LogInformation(const std::string& location, int line, const std::string& message);
private:
Log() {};
};
}
|
6aede9a1b8acc7413b68ed5bb498de066f06f0b6
|
e8dcd07cf66ed08a0cedf45c51ad11fbd1a77d2f
|
/engine/src/components/private/postprocessorsettings.cpp
|
9ef36507affc22d762846ca8b1955a99f62b4179
|
[
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
asdlei99/thunder
|
486886321f23a71bc25024569b4a8c0646190e33
|
05df8dcfafb1e9618111e4fd758800f38a44a84a
|
refs/heads/master
| 2023-08-23T09:45:14.456135
| 2021-11-04T14:09:29
| 2021-11-04T14:09:29
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,112
|
cpp
|
postprocessorsettings.cpp
|
#include "components/private/postprocessorsettings.h"
PostProcessSettings::PostProcessSettings() {
}
map<string, Variant> &PostProcessSettings::settings() {
return s_settingsMap;
}
void PostProcessSettings::registerSetting(const string &name, const Variant &value) {
s_settingsMap[name + "_override"] = false;
s_settingsMap[name] = value;
}
Variant PostProcessSettings::readValue(const string &name) const {
auto it = m_currentValues.find(name);
if(it != m_currentValues.end()) {
return it->second;
}
return Variant();
}
void PostProcessSettings::writeValue(const string &name, const Variant &value) {
m_currentValues[name] = value;
}
void PostProcessSettings::lerp(const PostProcessSettings &settings, float t) {
for(auto &it : settings.m_currentValues) {
size_t pos = it.first.find("_override");
if(pos != std::string::npos) {
if(it.second.toBool()) {
const string key(it.first.substr(0, pos));
const Variant value1 = m_currentValues[key];
auto v = settings.m_currentValues.find(key);
if(v != settings.m_currentValues.end()) {
Variant value2 = v->second;
switch(value1.type()) {
case MetaType::INTEGER: m_currentValues[key] = MIX(value1.toInt(), value2.toInt(), t); break;
case MetaType::FLOAT: m_currentValues[key] = MIX(value1.toFloat(), value2.toFloat(), t); break;
case MetaType::VECTOR2: m_currentValues[key] = MIX(value1.toVector2(), value2.toVector2(), t); break;
case MetaType::VECTOR3: m_currentValues[key] = MIX(value1.toVector3(), value2.toVector3(), t); break;
case MetaType::VECTOR4: m_currentValues[key] = MIX(value1.toVector4(), value2.toVector4(), t); break;
default: break;
}
}
}
}
}
}
void PostProcessSettings::resetDefault() {
m_currentValues.insert(s_settingsMap.begin(), s_settingsMap.end());
}
|
ed2968fc8486001f4a9338244fd66e96a0429ad6
|
d8e24b69c17777a7d1571a10378be7a2b90f6fd6
|
/dawn/src/dawn/Optimizer/PassDataLocalityMetric.h
|
8d7a03b91a302620b12214663893877effd00f8c
|
[
"MIT"
] |
permissive
|
MeteoSwiss-APN/dawn
|
7f79ee9bca9cf3c658ae88b656ea5367ebd5e897
|
d400a38caebe25fb94654c02c3bdb0349d7e3929
|
refs/heads/master
| 2023-04-06T16:43:59.627598
| 2023-03-20T11:52:15
| 2023-03-20T11:52:15
| 104,239,379
| 28
| 20
|
MIT
| 2022-12-12T14:01:31
| 2017-09-20T16:17:56
|
C++
|
UTF-8
|
C++
| false
| false
| 1,773
|
h
|
PassDataLocalityMetric.h
|
//===--------------------------------------------------------------------------------*- C++ -*-===//
// _
// | |
// __| | __ ___ ___ ___
// / _` |/ _` \ \ /\ / / '_ |
// | (_| | (_| |\ V V /| | | |
// \__,_|\__,_| \_/\_/ |_| |_| - Compiler Toolchain
//
//
// This file is distributed under the MIT License (MIT).
// See LICENSE.txt for details.
//
//===------------------------------------------------------------------------------------------===//
#pragma once
#include "dawn/IIR/MultiStage.h"
#include "dawn/Optimizer/Pass.h"
#include <unordered_map>
namespace dawn {
/// @brief This Pass computes a heuristic measuring the data-locality of each stencil
///
/// @ingroup optimizer
///
/// This pass is not necessary to create legal code and is hence not in the debug-group
class PassDataLocalityMetric : public Pass {
public:
PassDataLocalityMetric() : Pass("PassDataLocalityMetric") {}
/// @brief Pass implementation
bool run(const std::shared_ptr<iir::StencilInstantiation>& stencilInstantiation,
const Options& options = {}) override;
};
struct ReadWriteAccumulator {
int numReads = 0;
int numWrites = 0;
int totalAccesses() const { return numReads + numWrites; }
};
std::pair<int, int>
computeReadWriteAccessesMetric(const std::shared_ptr<iir::StencilInstantiation>& instantiation,
const iir::MultiStage& multiStage);
std::unordered_map<int, ReadWriteAccumulator> computeReadWriteAccessesMetricPerAccessID(
const std::shared_ptr<iir::StencilInstantiation>& instantiation, const Options& options,
const iir::MultiStage& multiStage);
} // namespace dawn
|
967b6214407635f8f7f1972fe57d19f58432a467
|
cebdfc7cda0b86ab32bb7e0637a35aa1c8e69d82
|
/src/link-templates.cc
|
b535c4b3017eb4897aead048618eb4f95fc8bb14
|
[] |
no_license
|
mbkulik/remy
|
6df7a28335698170417468e554005ee75e6dfbf7
|
8bb1a6662a9d7a7800ce60c93a4e4b0af352623b
|
refs/heads/master
| 2021-01-18T02:06:47.243237
| 2015-12-17T23:27:44
| 2015-12-17T23:27:44
| 48,203,476
| 0
| 0
| null | 2015-12-17T23:18:51
| 2015-12-17T23:18:51
| null |
UTF-8
|
C++
| false
| false
| 345
|
cc
|
link-templates.cc
|
#include <utility>
#include "link.hh"
using namespace std;
template <class NextHop>
void Link::tick( NextHop & next, const double & tickno )
{
_pending_packet.tick( next, tickno );
if ( _pending_packet.empty() ) {
if ( not _buffer.empty() ) {
_pending_packet.accept( _buffer.front(), tickno );
_buffer.pop();
}
}
}
|
816bd7a5e035e6b5827cf2b980ef784616b6e28e
|
ee09f5e6596f9ec3ebaf2b508d10dea3803cc561
|
/src/Plugins/hardlight/Instructions_Detail.h
|
1977210172c068a3907016ad523d207745a4e249
|
[
"MIT"
] |
permissive
|
cwaldren/HL-engine
|
38100c1f8781a808d1ab20660658fc74a384c267
|
0a303759eaed6331e4e0022f59d71fd2cc5c4379
|
refs/heads/master
| 2020-04-21T15:54:04.610745
| 2019-02-08T04:35:06
| 2019-02-08T04:35:06
| 169,682,868
| 0
| 0
|
MIT
| 2019-02-08T04:07:46
| 2019-02-08T04:07:46
| null |
UTF-8
|
C++
| false
| false
| 1,234
|
h
|
Instructions_Detail.h
|
#pragma once
#include <cstdint>
namespace inst {
template<typename T>
struct param {
uint8_t value;
explicit param(uint8_t val) : value(val) {}
};
#define PARAM(name) struct name##_t {}; using name = param<name##_t>
//This is necessary to do packet serialization
//We basically loop over N tuple values, assigning them to values in an array
template<std::size_t i = 0, typename ...Tp>
inline typename std::enable_if<i == sizeof...(Tp), void>::type
for_each(const std::tuple<Tp...>&, uint8_t* data) {}
template<std::size_t i = 0, typename ...Tp>
inline typename std::enable_if<i < sizeof...(Tp), void>::type
for_each(const std::tuple<Tp...>& t, uint8_t* data) {
data[i] = std::get<i>(t).value;
for_each<i + 1, Tp...>(t, data);
}
template<std::size_t instruction_id, typename...Args>
struct instruction {
std::tuple<Args...> args;
uint8_t id = instruction_id;
instruction(Args... args) : args(std::forward<Args>(args)...) {
static_assert(std::tuple_size<std::tuple<Args...>>::value <= 9, "cannot have more than 9 arguments");
}
void serialize(uint8_t* inputBuffer) const {
for_each(args, inputBuffer);
}
};
#define INST(id, name, ...) using name = instruction<id, __VA_ARGS__>
}
|
a11a466f4ee121c0ac6483e717631065260e8f14
|
b2ac2cc956c5b7dc8a38e7a44364d0282241ed8e
|
/tags/release-0.9.6a/Sources/MP2PEvents.h
|
ef2f5d563894f97b57a92c9984638f91dfb6f9ef
|
[
"BSL-1.0"
] |
permissive
|
BackupTheBerlios/japi-svn
|
b2a9971644a4740d10aef614e09f3fdd49e8460d
|
f9a5b284e285442b485ef05824ed8e55499c8d61
|
refs/heads/master
| 2016-09-15T17:14:35.504291
| 2010-12-03T11:39:25
| 2010-12-03T11:39:25
| 40,801,061
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,996
|
h
|
MP2PEvents.h
|
// Copyright Maarten L. Hekkelman 2006-2008
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/* $Id: MP2PEvents.h 119 2007-04-25 08:26:21Z maarten $
Copyright Hekkelman Programmatuur b.v.
Maarten Hekkelman
Created: Friday April 28 2000 15:57:00
Completely rewritten in July 2005
This is an implementation of point to point events. You can deliver messages from one
object to another using the EventIn and EventOut objects. One of the huge advantages
of using p2p events instead of simply calling another objects's method is that dangling
pointers are avoided, the event objects know how to detach from each other.
For now this implementation allows the passing of 0 to 4 arguments. If needed more
can be added very easily.
Usage:
struct foo
{
MEventOut<void(int)> eBeep;
};
struct bar
{
MEventIn<void(int)> eBeep;
void Beep(int inBeeps);
bar();
};
bar::bar()
: eBeep(this, &bar::Beep)
{
}
void bar::Beep(int inBeeps)
{
cout << "beep " << inBeeps << " times" << endl;
}
...
foo f;
bar b;
AddRoute(f.eBeep, b.eBeep);
f.eBeep(2);
*/
#ifndef MP2PEVENTS_H
#define MP2PEVENTS_H
#include <memory>
#include <list>
#include <functional>
#include <algorithm>
// forward declarations of our event types
template<typename Function> class MEventIn;
template<typename Function> class MEventOut;
// shield implementation details in our namespace
namespace MP2PEvent
{
// HandlerBase is a templated pure virtual base class. This is needed to declare
// HEventIn objects without knowing the type of the object to deliver the event to.
template<typename Function> struct HandlerBase;
template<>
struct HandlerBase<void()>
{
virtual ~HandlerBase() {}
virtual void HandleEvent() = 0;
};
template<typename T1>
struct HandlerBase<void(T1)>
{
virtual ~HandlerBase() {}
virtual void HandleEvent(T1 a1) = 0;
};
template<typename T1, typename T2>
struct HandlerBase<void(T1,T2)>
{
virtual ~HandlerBase() {}
virtual void HandleEvent(T1 a1, T2 a2) = 0;
};
template<typename T1, typename T2, typename T3>
struct HandlerBase<void(T1,T2,T3)>
{
virtual ~HandlerBase() {}
virtual void HandleEvent(T1 a1, T2 a2, T3 a3) = 0;
};
template<typename T1, typename T2, typename T3, typename T4>
struct HandlerBase<void(T1,T2,T3,T4)>
{
virtual ~HandlerBase() {}
virtual void HandleEvent(T1 a1, T2 a2, T3 a3, T4 a4) = 0;
};
// Handler is a base class that delivers the actual event to the owner of MEventIn
// as stated above, it is derived from HandlerBase.
// We use the Curiously Recurring Template Pattern to capture all the needed info from the
// MEventInHandler class.
template<class Derived, class Owner, typename Function> struct Handler;
template<class Derived, class Owner>
struct Handler<Derived, Owner, void()> : public HandlerBase<void()>
{
typedef void (Owner::*Callback)();
virtual void HandleEvent()
{
Derived* self = static_cast<Derived*>(this);
Owner* owner = self->fOwner;
Callback func = self->fHandler;
(owner->*func)();
}
};
template<class Derived, class Owner, typename T1>
struct Handler<Derived, Owner, void(T1)> : public HandlerBase<void(T1)>
{
typedef void (Owner::*Callback)(T1);
virtual void HandleEvent(T1 a1)
{
Derived* self = static_cast<Derived*>(this);
Owner* owner = self->fOwner;
Callback func = self->fHandler;
(owner->*func)(a1);
}
};
template<class Derived, class Owner, typename T1, typename T2>
struct Handler<Derived, Owner, void(T1, T2)> : public HandlerBase<void(T1, T2)>
{
typedef void (Owner::*Callback)(T1, T2);
virtual void HandleEvent(T1 a1, T2 a2)
{
Derived* self = static_cast<Derived*>(this);
Owner* owner = self->fOwner;
Callback func = self->fHandler;
(owner->*func)(a1, a2);
}
};
template<class Derived, class Owner, typename T1, typename T2, typename T3>
struct Handler<Derived, Owner, void(T1, T2, T3)> : public HandlerBase<void(T1, T2, T3)>
{
typedef void (Owner::*Callback)(T1, T2, T3);
virtual void HandleEvent(T1 a1, T2 a2, T3 a3)
{
Derived* self = static_cast<Derived*>(this);
Owner* owner = self->fOwner;
Callback func = self->fHandler;
(owner->*func)(a1, a2, a3);
}
};
template<class Derived, class Owner, typename T1, typename T2, typename T3, typename T4>
struct Handler<Derived, Owner, void(T1, T2, T3, T4)> : public HandlerBase<void(T1, T2, T3, T4)>
{
typedef void (Owner::*Callback)(T1, T2, T3, T4);
virtual void HandleEvent(T1 a1, T2 a2, T3 a3, T4 a4)
{
Derived* self = static_cast<Derived*>(this);
Owner* owner = self->fOwner;
Callback func = self->fHandler;
(owner->*func)(a1, a2, a3, a4);
}
};
// MEventInHandler is the complete handler object that has all the type info
// needed to deliver the event.
template<class C, typename Function>
struct MEventInHandler : public Handler<MEventInHandler<C, Function>, C, Function>
{
typedef Handler<MEventInHandler, C, Function> base;
typedef typename base::Callback Callback;
typedef C Owner;
MEventInHandler(Owner* inOwner, Callback inHandler)
: fOwner(inOwner)
, fHandler(inHandler)
{
}
C* fOwner;
Callback fHandler;
};
// MEventOutHandler objects. Again we use the Curiously Recurring Template Pattern
// to pull in type info we don't yet know.
template<class EventOut, class EventIn, class EventInList, typename Function>
struct MEventOutHandler {};
template<class EventOut, class EventIn, class EventInList>
struct MEventOutHandler<EventOut, EventIn, EventInList, void()>
{
void operator() ()
{
typedef typename EventInList::iterator iterator;
EventInList events = static_cast<EventOut*>(this)->GetInEvents();
for (iterator iter = events.begin(); iter != events.end(); ++iter)
(*iter)->GetHandler()->HandleEvent();
}
};
template<class EventOut, class EventIn, class EventInList, typename T1>
struct MEventOutHandler<EventOut, EventIn, EventInList, void(T1)>
{
void operator() (T1 a1)
{
typedef typename EventInList::iterator iterator;
EventInList events = static_cast<EventOut*>(this)->GetInEvents();
for (iterator iter = events.begin(); iter != events.end(); ++iter)
(*iter)->GetHandler()->HandleEvent(a1);
}
};
template<class EventOut, class EventIn, class EventInList, typename T1, typename T2>
struct MEventOutHandler<EventOut, EventIn, EventInList, void(T1, T2)>
{
void operator() (T1 a1, T2 a2)
{
typedef typename EventInList::iterator iterator;
EventInList events = static_cast<EventOut*>(this)->GetInEvents();
for (iterator iter = events.begin(); iter != events.end(); ++iter)
(*iter)->GetHandler()->HandleEvent(a1, a2);
}
};
template<class EventOut, class EventIn, class EventInList, typename T1, typename T2, typename T3>
struct MEventOutHandler<EventOut, EventIn, EventInList, void(T1, T2, T3)>
{
void operator() (T1 a1, T2 a2, T3 a3)
{
typedef typename EventInList::iterator iterator;
EventInList events = static_cast<EventOut*>(this)->GetInEvents();
for (iterator iter = events.begin(); iter != events.end(); ++iter)
(*iter)->GetHandler()->HandleEvent(a1, a2, a3);
}
};
template<class EventOut, class EventIn, class EventInList, typename T1, typename T2, typename T3, typename T4>
struct MEventOutHandler<EventOut, EventIn, EventInList, void(T1, T2, T3, T4)>
{
void operator() (T1 a1, T2 a2, T3 a3, T4 a4)
{
typedef typename EventInList::iterator iterator;
EventInList events = static_cast<EventOut*>(this)->GetInEvents();
for (iterator iter = events.begin(); iter != events.end(); ++iter)
(*iter)->GetHandler()->HandleEvent(a1, a2, a3, a4);
}
};
// a type factory
template<typename Function>
struct make_eventouthandler
{
typedef MEventOutHandler<
MEventOut<Function>,
MEventIn<Function>,
std::list<MEventIn<Function>*>,
Function> type;
};
} // namespace
// the actual MEventIn class
template<typename Function>
class MEventIn
{
typedef MEventOut<Function> MEventOut_;
typedef std::list<MEventOut_*> MEventOutList;
typedef typename MP2PEvent::HandlerBase<Function> HandlerBase;
public:
template<class C>
MEventIn(C* inOwner, typename MP2PEvent::MEventInHandler<C, Function>::Callback inHandler)
: fHandler(new MP2PEvent::MEventInHandler<C, Function>(inOwner, inHandler))
{
}
virtual ~MEventIn();
HandlerBase* GetHandler() const { return fHandler.get(); }
void AddEventOut(MEventOut_* inEventOut);
void RemoveEventOut(MEventOut_* inEventOut);
private:
MEventIn(const MEventIn&);
MEventIn& operator=(const MEventIn&);
std::auto_ptr<HandlerBase>
fHandler;
MEventOutList fOutEvents;
};
// and the MEventOut class
template<typename Function>
class MEventOut : public MP2PEvent::make_eventouthandler<Function>::type
{
typedef MEventIn<Function> MEventIn_;
typedef std::list<MEventIn_*> MEventInList;
public:
MEventOut();
virtual ~MEventOut();
void AddEventIn(MEventIn_* inEventIn);
void RemoveEventIn(MEventIn_* inEventIn);
MEventInList GetInEvents() const { return fInEvents; }
unsigned int CountRoutes() const { return fInEvents.size(); }
private:
MEventOut(const MEventOut&);
MEventOut& operator=(const MEventOut&);
MEventInList fInEvents;
};
// Use these functions to create and delete routes.
template <typename Function>
void AddRoute(MEventIn<Function>& inEventIn, MEventOut<Function>& inEventOut)
{
inEventOut.AddEventIn(&inEventIn);
}
template <typename Function>
void AddRoute(MEventOut<Function>& inEventOut, MEventIn<Function>& inEventIn)
{
inEventOut.AddEventIn(&inEventIn);
}
template <class Function>
void RemoveRoute(MEventIn<Function>& inEventIn, MEventOut<Function>& inEventOut)
{
inEventOut.RemoveEventIn(&inEventIn);
}
template <class Function>
void RemoveRoute(MEventOut<Function>& inEventOut, MEventIn<Function>& inEventIn)
{
inEventOut.RemoveEventIn(&inEventIn);
}
// implementation of the MEventIn methods
template<typename Function>
MEventIn<Function>::~MEventIn()
{
MEventOutList events;
std::swap(events, fOutEvents);
std::for_each(events.begin(), events.end(),
std::bind2nd(std::mem_fun(&MEventOut_::RemoveEventIn), this));
}
template<typename Function>
void MEventIn<Function>::AddEventOut(MEventOut_* inEventOut)
{
if (std::find(fOutEvents.begin(), fOutEvents.end(), inEventOut) == fOutEvents.end())
fOutEvents.push_back(inEventOut);
}
template<typename Function>
void MEventIn<Function>::RemoveEventOut(MEventOut_* inEventOut)
{
if (fOutEvents.size())
fOutEvents.erase(std::remove(fOutEvents.begin(), fOutEvents.end(), inEventOut), fOutEvents.end());
}
// implementation of the MEventOut methods
template<typename Function>
MEventOut<Function>::MEventOut()
{
}
template<typename Function>
MEventOut<Function>::~MEventOut()
{
std::for_each(fInEvents.begin(), fInEvents.end(),
std::bind2nd(std::mem_fun(&MEventIn_::RemoveEventOut), this));
}
template<typename Function>
void MEventOut<Function>::AddEventIn(MEventIn_* inEventIn)
{
if (std::find(fInEvents.begin(), fInEvents.end(), inEventIn) == fInEvents.end())
{
inEventIn->AddEventOut(this);
fInEvents.push_back(inEventIn);
}
}
template<typename Function>
void MEventOut<Function>::RemoveEventIn(MEventIn_* inEventIn)
{
inEventIn->RemoveEventOut(this);
fInEvents.erase(std::remove(fInEvents.begin(), fInEvents.end(), inEventIn), fInEvents.end());
}
#endif
|
1d715e6559bdfc03d9eacec361702498a9cb8701
|
f28c4352af0bf398a0d97ba466a0d42ef115a328
|
/src/Alg/NonRigid/NonRigidWrapper.h
|
1dfe68de44738342a5a9dc77cf055e003998d3dc
|
[] |
no_license
|
fwzhuangCg/cranioviewer
|
b5152fed0b1d8d8ba979a092cadf598a1f278b7c
|
4659f25f234e3de3ce178105d02c4ffe1d7202e1
|
refs/heads/master
| 2021-05-28T15:01:53.244245
| 2015-04-09T19:24:15
| 2015-04-09T19:24:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 365
|
h
|
NonRigidWrapper.h
|
#ifndef NonRigidWrapper_H
#define NonRigidWrapper_H
#include <QObject>
#include "NonRigid.h"
class NonRigidWrapper : public QObject
{
Q_OBJECT
public:
NonRigidWrapper();
~NonRigidWrapper();
NonRigid *getNonRigid() { return non_rigid; };
void NonRigidIter();
signals:
void updateRenderers();
private:
NonRigid *non_rigid;
};
#endif
|
c9a02be34491bdcdf997a661a9de3abfa591305b
|
aae79375bee5bbcaff765fc319a799f843b75bac
|
/atcoder/abc_233/d.cpp
|
f110ba35dbaca879a9c1ad957a8590499035b0b6
|
[] |
no_license
|
firewood/topcoder
|
b50b6a709ea0f5d521c2c8870012940f7adc6b19
|
4ad02fc500bd63bc4b29750f97d4642eeab36079
|
refs/heads/master
| 2023-08-17T18:50:01.575463
| 2023-08-11T10:28:59
| 2023-08-11T10:28:59
| 1,628,606
| 21
| 6
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 625
|
cpp
|
d.cpp
|
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
int64_t solve(int64_t N, int64_t K, std::vector<int64_t> A) {
int64_t ans = 0, sum = 0;
map<int64_t, int64_t> m;
m[0] = 1;
for (int i = 0; i < N; ++i) {
sum += A[i];
ans += m[sum - K];
m[sum] += 1;
}
return ans;
}
int main() {
int64_t N, K;
std::cin >> N >> K;
std::vector<int64_t> A(N);
for (int i = 0; i < N; i++) {
std::cin >> A[i];
}
cout << solve(N, K, A) << endl;
return 0;
}
|
669f007634a5f452c2cf51c7baf469982085159f
|
c51febc209233a9160f41913d895415704d2391f
|
/library/ATF/CNationSettingFactoryUSInfo.hpp
|
c12f9235d75fddbb04bc9e14566add7f4548611c
|
[
"MIT"
] |
permissive
|
roussukke/Yorozuya
|
81f81e5e759ecae02c793e65d6c3acc504091bc3
|
d9a44592b0714da1aebf492b64fdcb3fa072afe5
|
refs/heads/master
| 2023-07-08T03:23:00.584855
| 2023-06-29T08:20:25
| 2023-06-29T08:20:25
| 463,330,454
| 0
| 0
|
MIT
| 2022-02-24T23:15:01
| 2022-02-24T23:15:00
| null |
UTF-8
|
C++
| false
| false
| 916
|
hpp
|
CNationSettingFactoryUSInfo.hpp
|
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
#include <CNationSettingFactoryUS.hpp>
START_ATF_NAMESPACE
namespace Info
{
using CNationSettingFactoryUSctor_CNationSettingFactoryUS2_ptr = void (WINAPIV*)(struct CNationSettingFactoryUS*);
using CNationSettingFactoryUSctor_CNationSettingFactoryUS2_clbk = void (WINAPIV*)(struct CNationSettingFactoryUS*, CNationSettingFactoryUSctor_CNationSettingFactoryUS2_ptr);
using CNationSettingFactoryUSCreate4_ptr = struct CNationSettingData* (WINAPIV*)(struct CNationSettingFactoryUS*, int, char*, bool);
using CNationSettingFactoryUSCreate4_clbk = struct CNationSettingData* (WINAPIV*)(struct CNationSettingFactoryUS*, int, char*, bool, CNationSettingFactoryUSCreate4_ptr);
}; // end namespace Info
END_ATF_NAMESPACE
|
7f6a6ca42d29622cc5a792145d6211d15929a2a5
|
431217262b641ead28075c4f58a71a6d4ed4ffdd
|
/object/Object3D.h
|
2682d60d4e842e3f8f37be77a3490b79e92ce3e8
|
[] |
no_license
|
dbsGen/grender
|
d35ff1f5a421f9e83aacbaa60c21ff2b9e46cbd4
|
ccc756cd821109e5720ca03c081f26bb401e647d
|
refs/heads/master
| 2021-07-12T04:17:01.535548
| 2018-12-26T16:53:14
| 2018-12-26T16:53:14
| 113,476,610
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,310
|
h
|
Object3D.h
|
//
// Created by gen on 16/5/30.
//
#ifndef HIRENDER_OBJECT_H
#define HIRENDER_OBJECT_H
#include <material/Material.h>
#include <mesh/Mesh.h>
#include <core/Ref.h>
#include "../math/Type.h"
#include <core/Array.h>
#include <core/Object.h>
#include <render_define.h>
namespace gr {
class Linker;
class Renderer;
class Camera;
typedef int Mask;
#define MaskMask 0xFFFFFFFF
_FORCE_INLINE_ Mask MaskAt(int i) {return (Mask) (1 << i) & MaskMask;}
#define UIMask MaskAt(31)
_FORCE_INLINE_ Mask MaskHitAt(Mask mask, int i) {return (mask | MaskAt(i)) & MaskMask;}
_FORCE_INLINE_ Mask MaskIgnoreAt(Mask mask, int i) {return (mask & ~MaskAt(i)) & MaskMask;}
_FORCE_INLINE_ bool MaskHit(Mask m1, Mask m2) {return (bool) (m1 & m2);}
CLASS_BEGIN_N(Object3D, gc::RefObject)
public:
enum _NotifyDirection {
BOTH,
UP,
DOWN,
NONE // not send
};
typedef char NotifyDirection;
enum _EventType {
TOUCH_BEGIN = 0,
TOUCH_MOVE,
TOUCH_END,
TOUCH_CANCEL,
TOUCH_MOVE_IN,
TOUCH_MOVE_OUT,
FOCUS_IN,
FOCUS_OUT
};
typedef char EventType;
private:
gc::Ref<Material> material;
gc::Ref<Mesh> mesh;
std::list<gc::Ref<Object3D>> children;
Object3D *parent;
Matrix4 pose;
Matrix4 global_pose;
bool dirty_global_pose;
Vector3f position;
Quaternion rotation;
Vector3f _scale;
int awake_count;
bool enable;
bool dirty_enable;
bool final_enable;
int update_type;
bool update_enable;
bool step_enable;
bool single;
bool _static;
bool collision;
gc::Ref<Mesh> collider;
gc::StringName name;
gc::StringName notification_key;
gc::ActionItem on_event;
pointer_map pose_update_callbacks;
Renderer *renderer;
Mask mask;
Mask hitMask;
void _addChild(const gc::Ref<Object3D> &child, Object3D *parent);
void _removeChild(const gc::Ref<Object3D> &child, Object3D *parent);
void _changeMaterial(Object3D *object, Material *old);
void _updatePose();
void _message(const gc::StringName &key, NotifyDirection direction, const gc::RArray *vars);
void _added(Renderer *renderer);
void _removed(Renderer *renderer);
void _touchBegin(Camera *renderer, const Vector2f &screenPoint);
void _touchMove(Camera *renderer, bool inside, const Vector2f &screenPoint);
void _touchEnd(Camera *renderer, const Vector2f &screenPoint);
void _touchCancel(Camera *renderer, const Vector2f &screenPoint);
void _touchMoveIn(Camera *renderer, const Vector2f &screenPoint);
void _touchMoveOut(Camera *renderer, const Vector2f &screenPoint);
static void mainThreadPoseUpdateInv(void *renderer, void *object, void *data);
void poseUpdateInv();
static void mainTreadEnableChangedInv(void *renderer, void *object, void *data);
void enableChangedInv();
static void updateCallback(void *key, void *params, void *data);
static void stepCallback(void *key, void *params, void *data);
void updateTRS();
friend class Renderer;
friend class Camera;
protected:
virtual bool onMessage(const gc::StringName &key, const gc::RArray *vars);
_FORCE_INLINE_ virtual void awake(Renderer *renderer) {}
virtual void onEnable();
virtual void onDisable();
/**
* Frame update
*/
_FORCE_INLINE_ virtual void update(double delta) {}
EVENT(void, _update)
/**
* Fixed update
*/
_FORCE_INLINE_ virtual void step(double delta) {}
EVENT(void, _step)
_FORCE_INLINE_ virtual bool onChanged() { return true; }
_FORCE_INLINE_ virtual void onPoseChanged() {}
friend class MeshIMP;
public:
/**
* Notifitied when changed
* No param
*/
static const gc::StringName MESSAGE_DISPLAY_CHANGED;
/**
* Notifity when mask changed, SELF
* @param [Object* self, Mask from, Mask to]
*/
static const gc::StringName MESSAGE_MASK_CHANGE;
/**
* Notifity when enable changed
* @param [Object* self, bool old, bool new]
*/
static const gc::StringName MESSAGE_ENABLE_CHANGE;
/**
* Notifity when hit mask changed, UP
* @param [Object* self, Mask from, Mask to]
*/
static const gc::StringName MESSAGE_HIT_MASK_CHANGE;
/**
* Notifity when added a child, UP
* @param [Object* parent, Object *child]
*/
static const gc::StringName MESSAGE_ADD_CHILD;
/**
* Notifity when removed a child, UP
* @param [Object* parent, Object *child]
*/
static const gc::StringName MESSAGE_REMOVE_CHILD;
/**
* Notifity when the material changed, UP
* @param [Object *child, Material *old_material]
*/
static const gc::StringName MESSAGE_CHANGE_MATERIAL;
/**
* Notifity when the pose updated, DOWN
* @param [Object *child]
*/
static const gc::StringName MESSAGE_UPDATE_POSE;
/**
* Notifity when receive the touch event
* @param [EventType, Vector2f screenPoint]
*/
static const gc::StringName MESSAGE_TOUCH_EVENT;
void sendMessage(const gc::StringName &key, NotifyDirection direction, const gc::RArray *vars = NULL);
METHOD _FORCE_INLINE_ void sendMessageV(const gc::StringName &key, NotifyDirection direction, const gc::RArray &vars) {
sendMessage(key, direction, &vars);
}
/**
* Material
*/
METHOD _FORCE_INLINE_ virtual const gc::Ref<Material> &getMaterial() const {return material;}
METHOD virtual void setMaterial(const gc::Ref<Material> &material) {
gc::Ref<Material> old = this->material;
this->material = material;
_changeMaterial(this, *old);
}
/**
* Mesh
*/
METHOD _FORCE_INLINE_ virtual const gc::Ref<Mesh> &getMesh() const {return mesh;}
METHOD _FORCE_INLINE_ virtual void setMesh(const gc::Ref<Mesh> &mesh) {
this->mesh = mesh;
}
/**
* Pose
*/
METHOD _FORCE_INLINE_ const Matrix4 &getPose() const {return pose;}
METHOD void setPose(const Matrix4 &pose);
PROPERTY(pose, getPose, setPose)
void addPoseCallback(void *target, gc::ActionCallback callback, void *data);
void *removePoseCallback(void *target);
METHOD virtual void rotate(float radias, const Vector3f &axis);
METHOD virtual void translate(const Vector3f &trans);
METHOD virtual void scale(const Vector3f &scale);
_FORCE_INLINE_ const Vector3f &getPosition() const {
return position;
}
void setPosition(const Vector3f &pos);
_FORCE_INLINE_ const Quaternion &getRotation() const {
return rotation;
}
void setRotation(const Quaternion & rot);
_FORCE_INLINE_ const Vector3f &getScale() const {
return _scale;
}
void setScale(const Vector3f &scale);
METHOD virtual const Matrix4 &getGlobalPose() const;
/**
* Name of object.
*/
METHOD _FORCE_INLINE_ const gc::StringName &getName() {
return name;
}
METHOD _FORCE_INLINE_ void setName(const gc::StringName &name) {
this->name = name;
}
/**
* Parent
*/
METHOD _FORCE_INLINE_ Object3D *getParent() const {return parent;}
METHOD _FORCE_INLINE_ Mask getMask() const {return mask;}
METHOD void setMask(Mask mask);
METHOD _FORCE_INLINE_ Mask getHitMask() const {return hitMask;}
METHOD void setHitMask(Mask mask);
/**
* Physics
*/
METHOD void setCollision(bool collision);
METHOD _FORCE_INLINE_ bool getCollition() const { return collision;}
METHOD const gc::Ref<Mesh> &getCollider() const;
METHOD _FORCE_INLINE_ void setCollider(gc::Ref<Mesh> collider) { this->collider = collider; }
/**
* Children manage
*/
METHOD virtual void add(const gc::Ref<Object3D> &object);
METHOD virtual void remove(const gc::Ref<Object3D> &object);
_FORCE_INLINE_ const std::list<gc::Ref<Object3D> > &getChildren() const {return children;}
_FORCE_INLINE_ void setOnEvent(gc::ActionCallback event, void *data) {
on_event.callback = event;
on_event.data = data;
}
METHOD void setEnable(bool enable);
METHOD _FORCE_INLINE_ bool getEnable() {return enable;}
METHOD bool isFinalEnable();
virtual void copyParameters(const gc::Ref<Object3D> &other);
/**
* Traversal
*/
typedef bool(TraversalChecker)(Object3D *target, void *data);
typedef void(TraversalHandle)(Object3D *target, void *data);
void traversal(TraversalChecker checker, TraversalHandle dofun, void *data);
void change();
/**
* 标记这个对象是否是一个,独立对象。
* 独立对象在渲染引擎中不会自动优化为一个。
*/
_FORCE_INLINE_ void setSingle(bool single) { this->single = single;}
_FORCE_INLINE_ bool isSingle() { return single;}
_FORCE_INLINE_ Renderer *getRenderer() {
return renderer;
}
Object3D();
~Object3D();
/**
* Set update
*/
void setUpdateEnable(bool enable);
_FORCE_INLINE_ bool getUpdateEnable() {return update_enable;}
void setStepEnable(bool enable);
_FORCE_INLINE_ bool getStepEnable() {return step_enable;}
_FORCE_INLINE_ void setStatic(bool s) {_static = s;}
_FORCE_INLINE_ bool isStatic() {return _static;}
INITIALIZE(Object3D, PARAMS(gc::Ref<Material> &material, gc::Ref<Mesh> &mesh),
this->material = material;
this->mesh = mesh;
parent = NULL;
)
protected:
ON_LOADED_BEGIN(cls, RefObject)
ADD_PROPERTY(cls, "pose", ADD_METHOD(cls, Object, getPose), ADD_METHOD(cls, Object, setPose));
ADD_METHOD(cls, Object, sendMessageV);
ADD_METHOD(cls, Object, getMaterial);
ADD_METHOD(cls, Object, setMaterial);
ADD_METHOD(cls, Object, getMesh);
ADD_METHOD(cls, Object, setMesh);
ADD_METHOD(cls, Object, rotate);
ADD_METHOD(cls, Object, translate);
ADD_METHOD(cls, Object, scale);
ADD_METHOD(cls, Object, getGlobalPose);
ADD_METHOD(cls, Object, getName);
ADD_METHOD(cls, Object, setName);
ADD_METHOD(cls, Object, getParent);
ADD_METHOD(cls, Object, getMask);
ADD_METHOD(cls, Object, setMask);
ADD_METHOD(cls, Object, getHitMask);
ADD_METHOD(cls, Object, setHitMask);
ADD_METHOD(cls, Object, setCollision);
ADD_METHOD(cls, Object, getCollition);
ADD_METHOD(cls, Object, getCollider);
ADD_METHOD(cls, Object, setCollider);
ADD_METHOD(cls, Object, add);
ADD_METHOD(cls, Object, remove);
ADD_METHOD(cls, Object, setEnable);
ADD_METHOD(cls, Object, getEnable);
ADD_METHOD(cls, Object, isFinalEnable);
ON_LOADED_END
CLASS_END
}
#endif //HIRENDER_OBJECT_H
|
1c56b3c78a008391467bff365f8344d2f3e71003
|
332d8082ccef512619322afd924dd9f2a2e46d13
|
/src/client.cpp
|
c6e5097ad3205da1ed435def75ef1a0422b622d3
|
[] |
no_license
|
aaronvark/GearVR-OSC-Handshaker
|
d0582ce360faf48595af8761f8fad44a3cb94ee2
|
cfd86e4ad199a6c54afffbc4a338282dd1cf1759
|
refs/heads/master
| 2020-12-24T07:17:13.156391
| 2017-01-19T10:38:42
| 2017-01-19T10:38:42
| 73,373,773
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,271
|
cpp
|
client.cpp
|
//
// client.cpp
// GearVR_OSC-Handshaker
//
// Created by Aaron Oostdijk on 07/12/2016.
//
//
#include "client.h"
Client::Client( string name, string ip ) {
ipaddress = ip;
objectName = name;
setup();
}
void Client::setup() {
//del button
delButton = ofRectangle(-18,-10,12,12);
//font for IP/Name
verdana14.load("verdana.ttf", 14, true, true);
verdana14.setLineHeight(18.0f);
verdana14.setLetterSpacing(1.037);
}
void Client::draw(float x, float y) {
ofSetColor(255,255,255);
verdana14.drawString(ipaddress, x, y);
verdana14.drawString(objectName, x + 160, y);
//draw the del button relative to x/y
ofSetLineWidth(1);
ofPushMatrix();
ofTranslate(x,y);
ofSetColor(255,0,0);
ofDrawRectangle(delButton);
ofPopMatrix();
ofSetColor(255,255,255);
verdana14.drawString("x", x + delButton.x + 2, y + delButton.y + 10);
}
bool Client::inside( float x, float y, int index ) {
if ( delButton.inside(x,y) ) {
ofNotifyEvent(deleteClient, index);
return true;
}
return false;
}
ofRectangle Client::getArea() {
return area;
}
string Client::getIP() {
return ipaddress;
}
string Client::getName() {
return objectName;
}
|
d4e8f56225a6157099505a43699c6e1338358847
|
c00cf697a5430de79682a60b8eb934dacc08d58d
|
/QtDbTemple/util/ConfigUtil.cpp
|
f5a9c39d0eadb2307275afc5165592d4b30e38e5
|
[] |
no_license
|
zsk2016/AkCtkFrame
|
6e6cac8561c1803cb3c8051a79a69065ab20e0ff
|
1954865ccff21fce26b1d3e03b7ca1af888f6146
|
refs/heads/master
| 2020-04-29T02:48:22.619614
| 2019-03-15T10:21:42
| 2019-03-15T10:21:42
| 175,784,112
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,622
|
cpp
|
ConfigUtil.cpp
|
#include "ConfigUtil.h"
#include "Singleton.h"
#include "JsonUtil.h"
ConfigUtil::ConfigUtil()
{
m_config = new JsonUtil(":/resource/SqlConfig.json");
}
ConfigUtil *ConfigUtil::ConfigUtil::createInstance()
{
return new ConfigUtil;
}
ConfigUtil::~ConfigUtil()
{
delete m_config;
}
ConfigUtil *ConfigUtil::getInstance()
{
return Singleton<ConfigUtil>::instance(ConfigUtil::createInstance);
}
QString ConfigUtil::getDatabaseType() const
{
return m_config->getString("database.type");
}
QString ConfigUtil::getHomeName() const
{
return m_config->getString("database.host");
}
QString ConfigUtil::getDatabaseName() const
{
return m_config->getString("database.database_name");
}
QString ConfigUtil::getUserName() const
{
return m_config->getString("database.username");
}
QString ConfigUtil::getPassword() const
{
return m_config->getString("database.password");
}
QString ConfigUtil::getTestOnBorrowSql() const
{
return m_config->getString("database.test_on_borrow_sql");
}
bool ConfigUtil::getTestOnBorrow()
{
return m_config->getBool("database.test_on_borrow", false);
}
int ConfigUtil::getPort()
{
return m_config->getInt("database.port", 3306);
}
int ConfigUtil::getMaxWaitTime()
{
return m_config->getInt("database.max_wait_time", 5000);
}
int ConfigUtil::getMaxConnectCount()
{
return m_config->getInt("database.max_connection_count", false);
}
bool ConfigUtil::getDatabaseDebug()
{
return m_config->getBool("database.debug", false);
}
QStringList ConfigUtil::getDatabaseSqlFiles() const
{
return m_config->getStringList("database.sql_files");
}
|
3c73bacf3cc51544f4e5343334b6b03b64a969e7
|
948e8b1872d57a7a2599f3542e4fb7b6722e5a64
|
/visual/code/readv4wt.cc
|
92413ebc30a255b81fa3a0f799c8987aca30849a
|
[
"LicenseRef-scancode-public-domain"
] |
permissive
|
govtmirror/lsnm
|
949e710d782c6783ee5eb136b0a663555cbe774b
|
c1f54bda00c9b2185e977bbbf4a41b1ec1e2d3b3
|
refs/heads/master
| 2021-01-13T03:04:58.951726
| 2015-06-11T16:10:21
| 2015-06-11T16:10:21
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,590
|
cc
|
readv4wt.cc
|
/* rev. 8/98*/
/* readv4wt.cc reads the v4 to IT weight files and generate a new
weight file, where the weight is the original weight*scale
e.g. If we want to generate eg4c to exgt (left v4 excitatory, corner
to left IT excitatory), the original weight file is ev4c.wt, and scale = 0.75
at the command line, type:
readv4wt ev4c.wt eg4c exgt 0.75
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define maxlen 80
int main (int argc, char **argv)
{
FILE *infile, *outfile;
char Outfile[maxlen],temp[maxlen];
int inchar;
float scale,weight;
if(argc != 5)
{
printf("enter\n","readv4wt file_to_be_copied originating_set destination_set scale\n");
exit(0);
}
if( (infile = fopen(argv[1], "r")) == NULL)
{
printf("can't open %s\n", argv[1]);
exit(0);
}
strcpy(Outfile, argv[2]);
strcat(Outfile,argv[3]);
strcat(Outfile,".w");
if( (outfile = fopen(Outfile, "w")) == NULL)
{
printf("can't open %s\n", Outfile);
exit(0);
}
scale = atof(argv[4]);
fprintf(outfile,"Connect(%s,%s) {\n",argv[2],argv[3]);
fgets(temp, maxlen,infile);
while((inchar = getc(infile)) != EOF)
{
ungetc(inchar,infile);
while( ( (inchar = getc(infile)) != ']') && (inchar != EOF) )
{
fprintf(outfile,"%c",inchar);
}
if(inchar != EOF)
{
fprintf(outfile,"%c ",inchar);
fscanf(infile, "%f", &weight);
fprintf(outfile,"%f",weight*scale);
}/*end of if inchar != EOF, writing weights*/
}/*end of while inchar !=EOF*/
fclose(infile);
fclose(outfile);
}
|
a0722931cf45d4c0ad5fa840f88786a1b646bfa1
|
8db5520ab467537358646c1b9eca1600cf19e256
|
/testclick.cpp
|
6da7b888a228e5a66ff2fd2e4e1e3dfcc95f0fe3
|
[] |
no_license
|
Zaburunier/MT_HW
|
1f7b15359dd193fae3aa9620414935a2f8fff263
|
47f1736baf7c118198f39192ac55c432381c2aa2
|
refs/heads/master
| 2023-05-10T09:49:13.663667
| 2021-05-31T20:50:04
| 2021-05-31T20:50:04
| 370,238,817
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 52
|
cpp
|
testclick.cpp
|
#include "testclick.h"
TestClick::TestClick()
{
}
|
81d3f7f46657305b31c92f0c42eca1fcc89c54e4
|
935e9171748868d2f23f42020ddc3978d7b769dd
|
/Arduino/GTNR_Motor_Controller_Demo/GTNR_Motor_Controller_Demo.ino
|
d0487398689b3613b5e9c88283bf1b690f22d50f
|
[] |
no_license
|
farzonl/gtnr
|
c51742df08b829efa9dfa1714a0fde9fe58f02fb
|
d075aec1ad6649171906cb9da53ece0a47ddaf4e
|
refs/heads/master
| 2020-04-06T04:31:34.165329
| 2019-09-07T09:04:40
| 2019-09-07T09:07:49
| 35,507,238
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,203
|
ino
|
GTNR_Motor_Controller_Demo.ino
|
#include "DFRduino_KeyLib.c"
#include "GTNR_Motor_Controller.h"
#include <Encoder.h>
#define DEBUG_SPEED 1
#define DEBUG_DISTANCE 0
#define DEBUG_PHOTOCELLS 0
#define DEBUG_IR 0
#define NUM_PHOTOCELLS 4
#define NUM_IR 2
Encoder left_motor(10,11);
Encoder right_motor(8,9);
long positionLeft = -999;
long positionRight = -999;
double distanceLeft = 0;
double distanceRight = 0;
double last = 0;
double photocells[NUM_PHOTOCELLS];
double irs[NUM_IR];
int startSpeed = 255;
char alive = 0;
char keyDown = 0;
int demo_left = 8;
int demo_down = 9;
int demo_up = 10;
int demo_right = 11;
/**
* ===========================================================
* Application Initialize
* ===========================================================
*/
void setup(void)
{
int i;
for(i=4;i<=7;i++)
pinMode(i, OUTPUT);
for(i=8;i<=11;i++) {
pinMode(i, INPUT);
digitalWrite(i, LOW);
}
pinMode(12, INPUT);
digitalWrite(12, LOW);
Serial
.begin(115200); //Set Baud Rate
pinMode(13, OUTPUT);
go(FWD);
delay(500);
go(STOP);
}
/**
* ===========================================================
* Application Functionality
* ===========================================================
*/
void loop()
{
handle_ir();
if(digitalRead(demo_down) && currDirection != BKD) {
Serial.println("Down");
go(BKD);
} else if(digitalRead(demo_up) && currDirection != FWD) {
Serial.println("Up");
go(FWD);
} else if(digitalRead(demo_left) && currDirection != LFT) {
Serial.println("Left");
go(LFT);
} else if(digitalRead(demo_right) && currDirection != RHT) {
Serial.println("Right");
go(RHT);
}
if (!(digitalRead(demo_down) | digitalRead(demo_up)|digitalRead(demo_left)|digitalRead(demo_right))) {
Serial.println("Stop");
go(STOP);
}
// blink alive
digitalWrite(13, alive);
alive = !alive;
delay(250);
}
/**
* ===========================================================
* DFRduino Key Methods
* ===========================================================
*/
void handle_key() {
int key = get_key_press();
if (key >= 0 && !keyDown) {
keyDown = 1;
if (autopilot && key == AUT) {
autopilot = !autopilot;
digitalWrite(13, autopilot);
if (autopilot) {
go(FWD);
}
else {
halt();
}
}
else if (!autopilot) {
go(key);
}
}
else if(key < 0) {
keyDown = 0;
}
}
/**
* ===========================================================
* DFRduino Motor Controller Methods
* ===========================================================
*/
void go(int dir) {
// Set new speed and new direction when necessary
if (dir == currDirection && currSpeed < MAX_SPEED && currSpeed > 0) {
//double temp = MAX_SPEED - currSpeed;
//Serial.print("diff: ");
//Serial.println(temp, DEC);
//currSpeed += temp * 0.3;
currSpeed += 20;
if (currSpeed > MAX_SPEED)
currSpeed = MAX_SPEED;
}
else if (dir != currDirection || currSpeed == 0) {
currSpeed = startSpeed;
currDirection = dir;
}
// Stop if needed other wise advance as needed
if (dir == STOP || dir < 0) {
halt();
currSpeed = 0;
currDirection = STOP;
}
else {
switch(dir) {
case FWD :
advance(currSpeed);
break;
case LFT :
turn_L(currSpeed,currSpeed);
break;
case BKD :
back_off(currSpeed);
break;
case RHT :
turn_R(currSpeed,currSpeed);
break;
default :
go(STOP);
}
}
}
void halt(void) //Stop
{
digitalWrite(E1,LOW);
digitalWrite(E2,LOW);
}
void advance(char rate) //Move forward
{
analogWrite (E1,rate); //PWM Speed Control
digitalWrite(M1,HIGH);
analogWrite (E2,rate);
digitalWrite(M2,LOW);
}
void back_off (char rate) //Move backward
{
analogWrite (E1,rate);
digitalWrite(M1,LOW);
analogWrite (E2,rate);
digitalWrite(M2,HIGH);
}
void turn_L (char a,char b) //Turn Left
{
analogWrite (E1,a);
digitalWrite(M1,HIGH);
analogWrite (E2,digitalRead(12) ? 75 : 0);
digitalWrite(M2,HIGH);
}
void turn_R (char a,char b) //Turn Right
{
analogWrite (E1,digitalRead(12) ? 75 : 0;
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
/**
* ===========================================================
* Sensor Methods
* ===========================================================
*/
void handle_encoder(int side){
long newLeft, newRight;
newLeft = left_motor.read();
newRight = right_motor.read();
if (newLeft != positionLeft || newRight != positionRight) {
positionLeft = newLeft;
positionRight = newRight;
distanceLeft += newLeft * 2.75; // add number of mm moved
distanceRight += newRight * 2.75; // add number of mm moved
if (distanceLeft - last > 20 && DEBUG_DISTANCE) {
last = distanceLeft;
Serial.print(distanceLeft);
Serial.print(",\t");
Serial.println(distanceRight);
}
//test
left_motor.write(0);
right_motor.write(0);
}
// if a character is sent from the serial monitor,
// reset both back to zero.
if (Serial.available() && 0) {
Serial.read();
left_motor.write(0);
right_motor.write(0);
}
}
/*
* 10cm - 550
* 20cm - 460
* 30cm - 350
* 40cm - 260
* 50cm - 215
* 60cm - 185
* 70cm - 160
* 80cm - 140
* 90cm - 115
* 1m - 105
* open - 40-90
*/
void handle_ir() {
for (int i=0;i<NUM_IR;i++)
irs[i] = ir_to_cm(analogRead(i+NUM_PHOTOCELLS));
if (DEBUG_IR) {
for (int i=0;i<NUM_IR;i++){
Serial.print(irs[i], DEC);
Serial.print("\t");
}
Serial.println();
}
}
int ir_to_cm(int analog) {
return (int)(30431 * pow (analog,-1.169));
}
double ir_to_voltage(int analog) {
return (((double)analog) * 5.0) / 1024.0;
}
void handle_photocells() {
for (int i=0;i<NUM_PHOTOCELLS;i++)
photocells[i] = analogRead(i);
if (DEBUG_PHOTOCELLS) {
for (int i=0;i<NUM_PHOTOCELLS;i++){
Serial.print(photocells[i], DEC);
Serial.print("\t");
}
Serial.println();
}
}
|
f304ec618d8a2293b353a06a5624af7ad643c762
|
ae90cc886f57eaadb3700e33276feb97f83d778c
|
/Arduino/Controller_Steuerung/SendPC.h
|
7f342154366346dbdd146e0456a5b28bb5af7b23
|
[] |
no_license
|
ModellbahnFreak/ArduinoGameController
|
172462a9d5e1339467f83e65cea831e80b66b4ec
|
c6bbe0ac74eb3a6739de2eb257e012ffc83748f2
|
refs/heads/master
| 2020-03-22T01:32:09.511815
| 2018-07-01T13:44:40
| 2018-07-01T13:44:40
| 139,311,822
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,926
|
h
|
SendPC.h
|
/* Arduino SendPC Library
* Entwicklung Georg Reißner, 2018
* HINWEIS: BITTE BEI NUTZUNG DER LIBRARY DEN
* SERIELLEN PORT DES ARDUINO NICHT NUTZEN!
* Sendet und Empfängt Daten für verschiedene
* Sensoren und Aktoren von/zum PC, wo eine ähnliche
* Library die Daten entgegennimmt
* Die Lirary enthält einen Puffer für die Daten
* NUR ZUR PRIVATEN VERWENDUNG
*/
#ifndef SendPC_h
#define SendPC_h
#include "Arduino.h"
class SendPC {
//Öffentliche Funktionen:
public:
//Initialisiert die Library (MAXIMAL EINE INSTANZ GLEICHZEITIG); portNum aktuell wirkungslos
SendPC(int portNum);
//Startet die serielle Schnittstelle und öffnet die Verbindung
void begin();
//Wert eines Abstandssensors senden (Wert zw. 0 und 255 in cm)
void sendDistance(byte num, byte value);
//Wert eines Potis senden
void sendPoti(byte num, byte value);
//Senden, ob Button Nummer [num] an (true) oder aus (false)
void sendBtn(byte num, boolean value);
//Werte der RGB-LED aus dem Puffer auslesen (num (aktuell) egall)
byte* getRGB(byte num);
//Text z.B. für ein LCD abfagen
String getDisplay(byte num);
//Spannungswert abfragen (num zw. 1 und 4 inkl.)
byte getVoltage(byte num);
//Servo-Stellung abfragen (num zw. 1 und 3 inkl.)
byte getServo(byte num);
//Nicht-öffentliche Funktionen/Variablen
private:
//Puffer:
//RGB-Wert-Array
byte rgb[3];
//Display-Text
String display;
//Spannungswerte (Array)
byte* voltage = new byte[4];
//Servo-Werte (Array)
byte* servo = new byte[3];
//Variablen für das einlesen der seriellen Daten
byte readData[262];
int readPos = 0;
boolean prevHead = false;
//Hilfsfunktion zum Senden der Daten
void sendData(byte sensor, byte num, byte* data, byte dataLen);
//Hilfsfunktionen zum Empfangen der Daten
void recvData();
void parseRecv();
};
#endif
|
cd98f20c0fe1c5944fb63010345870a0379e3057
|
2393ed50ddb6fda3b5fa91bde1b8f468297f7331
|
/lib/Parser/src/Parser.cpp
|
54d01c461605fa4bf4beaa744fb0a41e2600d7f8
|
[] |
no_license
|
tschabo/embroider-g
|
6ef4dd4ee89451c1b0425cd73c4d8e4403ee9782
|
10e64832dc8cc1467902856e9c98b5287435532a
|
refs/heads/master
| 2023-03-06T06:22:17.098387
| 2021-02-14T22:44:28
| 2021-02-14T22:44:28
| 335,725,480
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,767
|
cpp
|
Parser.cpp
|
#include "Parser.h"
#include "stdlib.h"
Parser::Parser()
{
}
void Parser::parseCommand(char command)
{
auto c = static_cast<decltype(Command().command)>(command);
switch (c)
{
case Command::move:
_state = findX;
_currentCommandBuffer.command = c;
break;
case 'd': // disable steppers
case 'e': // enable steppers
_currentCommandBuffer.command = c;
_finished = true;
_state = findStart;
break;
default:
break;
}
}
bool Parser::parseFloat(char floatPart, float &thePlaceToPut)
{
if (floatPart == ';')
{
thePlaceToPut = atof(_scratch_buffer.data());
_scratch_buffer.clear();
return true; // the caller has to set the new State
}
if (_scratch_buffer.full() || ((floatPart < '0' || floatPart > '9') && floatPart != '.'))
{
_state = findStart;
_scratch_buffer.clear();
return false;
}
_scratch_buffer.push_back(floatPart);
return false;
}
Command *Parser::push(char c)
{
_finished = false;
switch (_state)
{
case findStart:
if (c != '>')
break;
_currentCommandBuffer = {};
_state = evalCommand;
break;
case evalCommand:
parseCommand(c);
break;
case findX:
if (parseFloat(c, _currentCommandBuffer.var0))
_state = findY;
break;
case findY:
if (parseFloat(c, _currentCommandBuffer.var1))
_state = findSpeed;
break;
case findSpeed:
if (parseFloat(c, _currentCommandBuffer.var3))
{
_finished = true;
_state = findStart;
}
break;
}
return _finished ? &_currentCommandBuffer : nullptr;
}
|
1e99519711656a725271b32121cfbd76e65ed423
|
c48159e39819d31a0cc15a28d3b9566908fdd218
|
/src/section.cpp
|
9a4a1a5a21cf148fd19906c6307821d41d6df26a
|
[
"MIT"
] |
permissive
|
SemaiCZE/inicpp
|
ac5e5498eb2ebe7ed16af395cc052eb604e10694
|
00883c8cbf610f05e2a488e168eef6e67b39db39
|
refs/heads/master
| 2022-09-03T20:12:09.364240
| 2022-07-16T10:11:36
| 2022-07-16T10:11:36
| 54,846,992
| 58
| 21
|
MIT
| 2022-07-16T10:11:37
| 2016-03-27T20:35:52
|
C++
|
UTF-8
|
C++
| false
| false
| 4,483
|
cpp
|
section.cpp
|
#include "section.h"
namespace inicpp
{
section::section(const section &source) : options_(), options_map_(), name_(source.name_)
{
// we have to do deep copies of options
options_.reserve(source.options_.size());
for (auto &opt : source.options_) { options_.push_back(std::make_shared<option>(*opt)); }
// we already have constructed options... now push them into map
for (auto &opt : options_) { options_map_.insert(options_map_pair(opt->get_name(), opt)); }
}
section §ion::operator=(const section &source)
{
if (this != &source) {
// make copy of input source section and swap it with this
section new_src(source);
std::swap(*this, new_src);
}
return *this;
}
section::section(section &&source) : options_(), options_map_(), name_()
{
operator=(std::move(source));
}
section §ion::operator=(section &&source)
{
if (this != &source) {
options_ = std::move(source.options_);
options_map_ = std::move(source.options_map_);
name_ = std::move(source.name_);
}
return *this;
}
section::section(const std::string &name) : options_(), options_map_(), name_(name)
{
}
const std::string §ion::get_name() const
{
return name_;
}
void section::add_option(const option &opt)
{
auto add_it = options_map_.find(opt.get_name());
if (add_it == options_map_.end()) {
std::shared_ptr<option> add = std::make_shared<option>(opt);
options_.push_back(add);
options_map_.insert(options_map_pair(add->get_name(), add));
} else {
throw ambiguity_exception(opt.get_name());
}
}
void section::remove_option(const std::string &option_name)
{
auto del_it = options_map_.find(option_name);
if (del_it != options_map_.end()) {
// remove from map
options_map_.erase(del_it);
// remove from vector
options_.erase(
std::remove_if(options_.begin(),
options_.end(),
[&](std::shared_ptr<option> opt) { return (opt->get_name() == option_name ? true : false); }),
options_.end());
} else {
throw not_found_exception(option_name);
}
}
size_t section::size() const
{
return options_.size();
}
option §ion::operator[](size_t index)
{
if (index >= size()) { throw not_found_exception(index); }
return *options_[index];
}
const option §ion::operator[](size_t index) const
{
if (index >= size()) { throw not_found_exception(index); }
return *options_[index];
}
option §ion::operator[](const std::string &option_name)
{
std::shared_ptr<option> result;
try {
result = options_map_.at(option_name);
} catch (const std::out_of_range &) {
throw not_found_exception(option_name);
}
return *result;
}
const option §ion::operator[](const std::string &option_name) const
{
std::shared_ptr<option> result;
try {
result = options_map_.at(option_name);
} catch (const std::out_of_range &) {
throw not_found_exception(option_name);
}
return *result;
}
bool section::contains(const std::string &option_name) const
{
try {
options_map_.at(option_name);
return true;
} catch (const std::out_of_range &) {
return false;
}
}
void section::validate(const section_schema §_schema, schema_mode mode)
{
sect_schema.validate_section(*this, mode);
}
bool section::operator==(const section &other) const
{
if (name_ != other.name_) { return false; }
return std::equal(options_.begin(),
options_.end(),
other.options_.begin(),
[](const std::shared_ptr<option> &first, const std::shared_ptr<option> &second) {
return *first == *second;
});
}
bool section::operator!=(const section &other) const
{
return !(*this == other);
}
section::iterator section::begin()
{
return iterator(*this);
}
section::iterator section::end()
{
return iterator(*this, options_.size());
}
section::const_iterator section::begin() const
{
return const_iterator(const_cast<section &>(*this));
}
section::const_iterator section::end() const
{
return const_iterator(const_cast<section &>(*this), options_.size());
}
section::const_iterator section::cbegin() const
{
return const_iterator(const_cast<section &>(*this));
}
section::const_iterator section::cend() const
{
return const_iterator(const_cast<section &>(*this), options_.size());
}
std::ostream &operator<<(std::ostream &os, const section §)
{
os << "[" << sect.get_name() << "]" << std::endl;
for (auto &opt : sect.options_) { os << *opt; }
return os;
}
} // namespace inicpp
|
ebff0534148040f859c73e334415c1234576d72e
|
a2c3028bbb015596e6d1b83fe23bd4c9fda0d72d
|
/info/wip/in-process/src/sk/phaonir/PhaonIR/phaon-ir/scopes/phr-scope-value.h
|
91ba4efbd09d98eda9f9c698fb235dd7cfbe449c
|
[] |
no_license
|
scignscape/ntxh
|
1c025b0571ecde6b25062c4013bf8a47aeb7fdcb
|
ee9576360c1962afb742830828670aca5fa153d6
|
refs/heads/master
| 2023-04-01T07:20:26.138527
| 2021-03-17T17:59:48
| 2021-03-17T17:59:48
| 225,418,021
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 632
|
h
|
phr-scope-value.h
|
// Copyright Nathaniel Christen 2019.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef PHR_SCOPE_VALUE__H
#define PHR_SCOPE_VALUE__H
#include <QString>
#include "kans.h"
KANS_(Phaon)
class PHR_Type;
struct PHR_Scope_Value
{
PHR_Type* ty;
quint64 raw_value;
QString string_value;
PHR_Scope_Value();
PHR_Scope_Value(PHR_Type* _ty, quint64 _raw_value);
template<typename T>
T* pValue_as()
{
return reinterpret_cast<T*>(raw_value);
}
};
_KANS(Phaon)
#endif // PHR_SCOPE__H
|
eccf820052742aaa884e6f0b85f868ccec231776
|
8ee81ee9acf0652ae1c17e221a2e7e4ac40fe4ec
|
/LeetCode/construct_binary_tree_from_inorder_and_postorder_traversal/buildTree.cpp
|
c465c046ae9a03eb891c08b756c55f8e3230d6e4
|
[] |
no_license
|
veerapalla/cracking_the_coding_interview
|
b875c39a4411480c8bb752d40aa1d0427d58d28c
|
f10556d7e7a5e8de44190609f17d1c990053879d
|
refs/heads/master
| 2021-05-28T16:29:53.787989
| 2014-09-28T06:42:36
| 2014-09-28T06:42:36
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,413
|
cpp
|
buildTree.cpp
|
/*
* =====================================================================================
*
* Filename: buildTree.cpp
*
* Version: 1.0
* Created: 12/20/2013 15:00:34
* Revision: none
* Compiler: gcc
*
* =====================================================================================
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
/* memory limit exceeded */
/*
TreeNode *buildTree(vector<int> &inorder, vector<int> &postorder) {
if (inorder.size() == 0) {
return NULL;
}
int rootValue = postorder[postorder.size() - 1];
TreeNode *root = new TreeNode(rootValue);
vector<int>::iterator it = find(inorder.begin(), inorder.end(), rootValue);
vector<int> left_inorder, right_inorder, left_postorder, right_postorder;
left_inorder.assign(inorder.begin(), it);
right_inorder.assign(it + 1, inorder.end());
left_postorder.assign(postorder.begin(), postorder.begin() + left_inorder.size());
right_postorder.assign(postorder.begin() + left_inorder.size(), postorder.end() - 1);
TreeNode *left = buildTree(left_inorder, left_postorder);
TreeNode *right = buildTree(right_inorder, right_postorder);
root->left = left;
root->right = right;
return root;
}
*/
TreeNode *buildTree(vector<int> &inorder, int left1, int right1, vector<int> &postorder, int left2, int right2) {
// cout << left1 << " " << right1 << " " << left2 << " " << right2 << endl;
if (left1 > right1) {
return NULL;
}
else if (left1 == right1) {
return new TreeNode(inorder[left1]);
}
int rootValue = postorder[right2];
TreeNode *root = new TreeNode(rootValue);
vector<int>::iterator it = find(inorder.begin() + left1, inorder.end() + right1 + 1, rootValue);
int new_left1 = left1, new_right1 = it - inorder.begin() - 1;
int new_left2 = left2, new_right2 = new_left2 + new_right1 - new_left1;
// cout << new_left1 << " " << new_right1 << " " << new_left2 << " " << new_right2 << endl;
TreeNode *left = buildTree(inorder, new_left1, new_right1, postorder, new_left2, new_right2);
new_left1 = it - inorder.begin() + 1;
new_right1 = right1;
new_left2 = new_right2 + 1;
new_right2 = right2 - 1;
// cout << new_left1 << " " << new_right1 << " " << new_left2 << " " << new_right2 << endl;
TreeNode *right = buildTree(inorder, new_left1, new_right1, postorder, new_left2, new_right2);
root->left = left;
root->right = right;
return root;
}
void printTree(TreeNode *root) {
queue<TreeNode *> q;
q.push(root);
while (!q.empty()) {
TreeNode *curr = q.front();
q.pop();
if (curr) {
cout << curr->val << " ";
q.push(curr->left);
q.push(curr->right);
}
else {
cout << "#" << " ";
}
}
cout << endl;
}
int main() {
vector<int> inorder, postorder;
int in_arr[] = {4,2,5,1,3,6};
int post_arr[] = {4,5,2,6,3,1};
inorder.assign(in_arr, in_arr + 6);
postorder.assign(post_arr, post_arr + 6);
TreeNode *root = buildTree(inorder, 0, inorder.size() - 1, postorder, 0, postorder.size() - 1);
printTree(root);
return 0;
}
|
73df272efe6739e6ec5921b41fa6d4b6c990b4af
|
40962889fc7e72435d59f1c6320bfd1c52c1bb8f
|
/cpp/qt/board/game/game_data.hpp
|
56058e2a71f74912f3903f81a707dce94aeeb6c0
|
[] |
no_license
|
sfod/studying
|
0e435d8cdbe3802417c64a07c2eb8aaa717e30e8
|
cc54c3e34cf405b10e2dc5ed6a5a37f7c6539264
|
refs/heads/master
| 2016-08-05T19:23:09.668272
| 2015-03-05T13:45:33
| 2015-03-05T13:45:33
| 20,718,554
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 453
|
hpp
|
game_data.hpp
|
#ifndef GAME_DATA_HPP
#define GAME_DATA_HPP
#include <map>
#include <string>
enum class PlayerType {
PT_Human,
PT_AI,
PT_Invalid
};
static const std::map<std::string, PlayerType> str_to_player_type = {
{"human", PlayerType::PT_Human},
{"AI", PlayerType::PT_AI}
};
static const std::map<PlayerType, std::string> player_type_to_str = {
{PlayerType::PT_Human, "human"},
{PlayerType::PT_AI, "AI"}
};
#endif // GAME_DATA_HPP
|
b1ea5e47859b68189b536bc2fd1f9a63b5a87b30
|
a759c6611c855925e2a73ca437ed004d74c4c611
|
/백준문제/자료구조 - Data Structures/백준 1676.cpp
|
1e58771f235cc375cdae82e1b4262e1792d27ab4
|
[] |
no_license
|
yugo9081/My-Codes
|
dafcfb7428256b9bad06d4221cec6e208241d151
|
84bfe92865d854f9aa6a201a2ba66dae1c2abe27
|
refs/heads/master
| 2023-01-20T22:50:39.828481
| 2020-11-23T09:47:05
| 2020-11-23T09:47:05
| 283,927,861
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 579
|
cpp
|
백준 1676.cpp
|
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
using namespace std;
int main(void)
{
cin.tie(NULL);
cout.tie(NULL);
ios_base :: sync_with_stdio(false);
int n;
int count;
cin>>n;
count = n/5 + n/25 + n/125;
cout << count << "\n";
}
|
aaa4b425dab340325c26dd3a99aec45db76bd072
|
57d1d62e1a10282e8d4faa42e937c486102ebf04
|
/judges/codechef/done/CHEFFA.cpp
|
dcf88879cb460d4183202a92edcbf8846d067d5e
|
[] |
no_license
|
diegoximenes/icpc
|
91a32a599824241247a8cc57a2618563f433d6ea
|
8c7ee69cc4a1f3514dddc0e7ae37e9fba0be8401
|
refs/heads/master
| 2022-10-12T11:47:10.706794
| 2022-09-24T04:03:31
| 2022-09-24T04:03:31
| 178,573,955
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,170
|
cpp
|
CHEFFA.cpp
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast_io ios::sync_with_stdio(false)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
const double PI = acos(-1);
const double EPS = 1e-9;
inline int cmp_double(double x, double y, double tol = EPS) {
// (x < y): -1, (x == y): 0, (x > y): 1
return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
#define MAX 105
#define MOD 1000000007
#define OFFSET 50
int n;
int v[MAX], dp[MAX][MAX][MAX][MAX];
int opt(int i, int c1, int c2, int c3) {
if (i == MAX - 1) return 1;
int &ret = dp[i][c1 + OFFSET][c2 + OFFSET][c3 + OFFSET];
if (ret != -1) return ret;
ret = opt(i + 1, c2, c3, 0);
if (v[i] + c1 > 0 && v[i + 1] + c2 > 0)
ret = (ret + opt(i, c1 - 1, c2 - 1, c3 + 1)) % MOD;
return ret;
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
memset(v, 0, sizeof(v));
scanf("%d", &n);
for (int i = 0; i < n; ++i) scanf("%d", &v[i]);
memset(dp, -1, sizeof(dp));
printf("%d\n", opt(0, 0, 0, 0));
}
return 0;
}
|
206211c3e40f576172f8349cb1e5381576b0f905
|
259bacc81f4b663daac01574061b38f2cd93b867
|
/cf/1385/q4.cpp
|
08c77d8b529b4b2a283efb956b9e347e361d869b
|
[] |
no_license
|
yashrsharma44/Competitive-Programming
|
6bf310d707efcb650fa6c732132a641c3c453112
|
77317baa4681c263c5926b62864a61b826f487ea
|
refs/heads/master
| 2023-03-03T13:59:53.713477
| 2022-11-16T09:10:25
| 2022-11-16T09:10:25
| 196,458,547
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 914
|
cpp
|
q4.cpp
|
#include <bits/stdc++.h>
#define MOD 998244353
#define int long long
using namespace std;
int dfs(string s, int i){
// if(s.length() == 0){
// return 0;
// }
char cc = (char)('a'+i);
if(s.length() == 1){
if(s[0] == cc){
return 0;
}
return 1;
}
int n = s.length();
int l = dfs(s.substr(0,n/2), i+1);
int r = dfs(s.substr(n/2), i+1);
int c1 = 0,c2=0;
for(int j=0;j<n/2;j++){
if(s[j] != cc){
c1++;
}
}
for(int j=n/2;j<n;j++){
if(s[j]!=cc){
c2++;
}
}
int cost = min({c1+l, c1+r, c2+l, c2+r});
cout<<s<<" "<<cost<<endl;
cout<<c1+l<<" "<<c1+r<<" "<<c2+l<<" "<<c2+r<<endl;
cout<<"-----------"<<endl;
return cost;
}
void solve(){
int n;
cin>>n;
string s;
cin>>s;
int i = 0;
int cost = dfs(s, i);
cout<<cost<<endl;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
// t = 1;
while(t--){
solve();
}
}
|
9da857c5088a8b80085265d0fdac3b4f0b3c7922
|
d0b4456c34d8da578e60b23e9fa760560a346513
|
/src/congestion/NullSensor.h
|
75448a1a7700198ebe115c8adaff101a85c5d34c
|
[
"Apache-2.0"
] |
permissive
|
ssnetsim/supersim
|
fcb4c6245fabe8b6e202bb6278cd8b62e972ef7c
|
2ee12fef5dbbe4dafe4de542a071e0768b552a1a
|
refs/heads/main
| 2022-06-07T06:46:06.266449
| 2022-05-20T20:41:01
| 2022-05-20T20:41:01
| 236,844,270
| 5
| 4
|
Apache-2.0
| 2022-05-20T20:41:03
| 2020-01-28T21:20:21
|
C++
|
UTF-8
|
C++
| false
| false
| 1,571
|
h
|
NullSensor.h
|
/*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. 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 CONGESTION_NULLSENSOR_H_
#define CONGESTION_NULLSENSOR_H_
#include <string>
#include <vector>
#include "congestion/CongestionSensor.h"
#include "nlohmann/json.hpp"
#include "prim/prim.h"
class NullSensor : public CongestionSensor {
public:
NullSensor(const std::string& _name, const Component* _parent,
PortedDevice* _device, nlohmann::json _settings);
~NullSensor();
// CreditWatcher interface
void initCredits(u32 _vcIdx, u32 _credits);
void incrementCredit(u32 _vcIdx);
void decrementCredit(u32 _vcIdx);
// style and resolution reporting
CongestionSensor::Style style() const override;
CongestionSensor::Resolution resolution() const override;
protected:
// see CongestionSensor::computeStatus
f64 computeStatus(u32 _inputPort, u32 _inputVc, u32 _outputPort,
u32 _outputVc) const override;
};
#endif // CONGESTION_NULLSENSOR_H_
|
d7e99f9f7aaec0d64198b73548ac8898a6954ef0
|
f22e1fdd2098ca51dd5004e0b9f20cb8b4adbb2d
|
/src/main/cpp/commands/CmdSetFeederVelocity.cpp
|
670f9e86d334524956e2f4b4171e16208060eabb
|
[] |
no_license
|
Team1507/IRatHome2021
|
56b698090424efeec8532dcc5687827229c97c1e
|
73dc0443205696129c67fbba08317bfe48c7b1d1
|
refs/heads/main
| 2023-04-21T23:20:21.897044
| 2021-05-20T01:04:41
| 2021-05-20T01:04:41
| 341,006,602
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 561
|
cpp
|
CmdSetFeederVelocity.cpp
|
#include "commands/CmdSetShooterVelocity.h"
#include "commands/CmdSetFeederVelocity.h"
#include "Robot.h"
CmdSetFeederVelocity::CmdSetFeederVelocity(double rpm) {
// Use Requires() here to declare subsystem dependencies
m_rpm = rpm;
// eg. Requires(Robot::chassis.get());
}
void CmdSetFeederVelocity::Initialize() {
Robot::m_shooter.SetFeederVelocity(m_rpm);
}
void CmdSetFeederVelocity::Execute() {}
bool CmdSetFeederVelocity::IsFinished() { return true; }
void CmdSetFeederVelocity::End() {}
void CmdSetFeederVelocity::Interrupted() {}
|
06e2a50df390ddb7f211cc20158e132488efebab
|
c1c33a7f6fbb9b983a76baf21d8a834530d398ae
|
/class.cc
|
f10af0ef34cb3b0fd48420a46697c761cf5d9dac
|
[] |
no_license
|
jamesjunaidi/jordan
|
f9baf84f3b6b33d57a613cdfa017e3a50bc7bed4
|
313e7e89750202bbd8c0cd7ec6748dad60d0fea6
|
refs/heads/master
| 2022-12-02T00:01:56.517855
| 2020-08-05T21:33:56
| 2020-08-05T21:33:56
| 282,112,107
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 894
|
cc
|
class.cc
|
#include <iostream>
#include <vector>
using namespace std;
class Example {
public:
// These are the fields
int field1;
int field2;
int field3;
// this is the constructor for the class
Example(int a, int b, int c) {
field1 = a;
field2 = b;
field3 = c;
}
// this function prints out the fields
void printClass() {
cout << "Field1: " << field1 << endl;
cout << "Field2: " << field2 << endl;
cout << "Field3: " << field3 << endl;
}
};
int main(void) {
// this is a vector of classes
vector<Example> v;
// here pushing 19 items into the vector
for (unsigned int i = 0; i < 20; ++i) {
Example *a = new Example(i,i,i);
v.push_back(*a);
}
int count = 1;
// printing out the contents of each class
for (Example &a : v) {
cout << "Class # " << count++ << endl;
a.printClass();
cout << endl;
}
return 0;
}
|
7057e651b0d0932dee85781da0595c73862cc894
|
01b8b69af2a71e275012f8dc786c2569d7ad60dc
|
/Menu.cpp
|
9301c38d29e6759d91253a5466b2b912a4a61b4b
|
[] |
no_license
|
eliannevado/AVANCE
|
8359e9a718e170b07db4481094bbbe8e0e458201
|
3a108588b3363c0811f6fa1726a24b510610bcbf
|
refs/heads/master
| 2020-09-01T06:44:08.579784
| 2019-11-27T02:14:09
| 2019-11-27T02:14:09
| 218,901,480
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,929
|
cpp
|
Menu.cpp
|
#include "Menu.h"
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
// Metodo para limpiar pantalla
void limpiar() { cout << "\033[2J\033[0;0H"; }
// Metodo para esperar se presion una tecla para continuar
void esperar() {
char w;
do {
cout << "Presione X y Enter para continuar..."; cin >> w;
} while (toupper(w) != 'X');
}
// Metodo de impresion del menu principal
void Menu::imprimirMenu() {
limpiar();
cout << "========MENU PRINCIPAL========\n";
cout << string(30, '=') << "\n";
cout << "[1].- Agregar Frase\n";
cout << "[2].- Crear Carpeta y Agregar Texto\n";
cout << "[3].- Alinear a la Derecha\n";
cout << "[4].- Alinear a la Izquierda\n";
cout << "[5].- Centrar\n";
cout << "[6].- Justificar\n";
cout << "[7].- Contar repitencia de una Palabra\n";
cout << "[8].- Buscar una Palabra\n";
cout << "[9].-Reemplazar una Palabra\n";
cout << "[10].- Salir\n";
cout << string(30, '=') << "\n\n";
}
// Metodo para activar el menu principal
void Menu::ejecutar() {
do {
imprimirMenu();
cin >> opcion;
seleccionarOpcion();
} while (opcion != 10);
cout << "Hasta Luego...\n";
}
// Metodo para seleccionar un opcion en el menu
void Menu::seleccionarOpcion() {
limpiar();
switch(opcion) {
case 1: frase.agregarFrases(); break; // 1. Agregar Frase
case 2: frase.leerArchivo(); break; // 2. Leer Archivo
case 3: frase.alineaDerecha(); break; // 3. Derecha
case 4: frase.alineaIzquierda(); break; // 4. Izquierda
case 5: frase.alineaCentro(); break; // 5. Centro
case 6: frase.justificaFrase(); break; // 6 Justifica
case 7: frase.cuentaPalabra(); break; // 9. Cuenta
case 8: frase.buscaPalabra(); break; // 10. Buscar palabraCuenta
case 9: frase.reemplazar(); break; // 10.Reemplazar una Palabra
}
}
|
cea91b80c5964164dd0cfaae0012dbc1f4ceb708
|
bcf04bbf6b97ecc2f4e97572383d7c754b5a4e65
|
/backend/CommandPattern/grayScaleCommand.h
|
57458bf49681ceb67cbcf6e114381792846eee79
|
[] |
no_license
|
reed4u/image-editor
|
4197c60db31601c40c7188a5fd76d90942143552
|
511f2ad0835977b39b38a0c6260fde96623e9f7a
|
refs/heads/master
| 2023-08-26T00:36:03.215256
| 2021-11-05T13:24:27
| 2021-11-05T13:24:27
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 482
|
h
|
grayScaleCommand.h
|
#ifndef IMAGE_EDITOR_GRAYSCALECOMMAND_H
#define IMAGE_EDITOR_GRAYSCALECOMMAND_H
#include "ICommand.h"
#include "../Image.h"
class grayScaleCommand : public ICommand {
private:
Image ℑ
std::vector<Pixel>& pixelBuffer;
std::vector<Pixel> backupPixelBuffer;
void grayScale();
public:
explicit grayScaleCommand(Image &image);
void execute() override;
void undo() override;
void redo() override;
};
#endif //IMAGE_EDITOR_GRAYSCALECOMMAND_H
|
f4afa6cf2cdf0aed30c8705b20505f8d12ebcc24
|
83120258156459f6aa7575fdd360f225c3b9d797
|
/cnn-text-classification/InputLayer.cpp
|
0a112a8c7461ca766128fcf7b2336937241350e4
|
[] |
no_license
|
byeongkeunahn/cnn-text-classification
|
7ce576e840b8911beae54853183709434c8f2569
|
e20520880926907e15f72f40d1e82c4037ea3726
|
refs/heads/master
| 2020-09-24T16:34:20.296299
| 2019-12-04T14:39:59
| 2019-12-04T14:39:59
| 225,799,617
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,042
|
cpp
|
InputLayer.cpp
|
#include "pch.h"
#include "InputLayer.h"
InputLayer::InputLayer() {
m_OutputGrad = nullptr;
}
InputLayer::~InputLayer() {
}
float *InputLayer::GetCurrentData(const char *key) {
return m_pProvider->GetCurrentData(key);
}
std::vector<int> InputLayer::GetDataDimension(const char *key) {
return m_pProvider->GetDataDimension(key);
}
std::vector<int> InputLayer::GetCurrentDataDimension(const char *key) {
return m_pProvider->GetCurrentDataDimension(key);
}
std::vector<int> InputLayer::GetOutputDimension() {
throw std::exception("InputLayer: GetOutputDimension should not be called");
}
int InputLayer::GetNumberOfParams() {
return 0;
}
void InputLayer::ForwardProp() {
/* nothing */
}
void InputLayer::BackwardProp() {
/* nothing */
}
float *InputLayer::GetOutput() {
throw std::exception("InputLayer: GetOutput should not be called");
}
void InputLayer::UpdateParams() {
/* nothing */
}
void InputLayer::SetInputDataProvider(InputDataProvider *pProvider) {
m_pProvider = pProvider;
}
|
1db31e11b3253198132d3eef491f87b3342993da
|
e0ee1fee9ce54e0e512fc081ece2a77c2b21bbac
|
/resultwindow.cpp
|
4c1221bb2b5b05784e7ad27cd90a7806f5874c50
|
[] |
no_license
|
dAN0n/Expression-Solve-Trainer
|
cc3abd310512e0aeb631167332e417e839d9404f
|
6816d1fb90f3f5ba2c2e1dc7c2bb1f37e0ad61e2
|
refs/heads/master
| 2021-03-27T11:16:38.979545
| 2015-05-02T19:19:24
| 2015-05-02T19:19:24
| 34,958,417
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 826
|
cpp
|
resultwindow.cpp
|
#include "resultwindow.h"
#include "ui_resultwindow.h"
ResultWindow::ResultWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::ResultWindow)
{
Right = 0;
QString _Right = QString::number(Right);
ui->setupUi(this);
ui->RightField->setText(_Right);
QObject::connect(ui->StartButton, SIGNAL(clicked()), this, SLOT(StartButtonClicked()));
QObject::connect(&w, SIGNAL(TrainOver(int)), this, SLOT(TrainingOver(int)));
}
ResultWindow::~ResultWindow(){
delete ui;
}
void ResultWindow::StartButtonClicked(){
w.Timer->start(10000);
w.setWindowTitle("Expressions Solve Trainer");
w.show();
hide();
}
void ResultWindow::TrainingOver(int Right){
QString _Right = QString::number(Right);
ui->RightField->setText(_Right);
ui->progressBar->setValue(Right);
show();
}
|
aefa605132d9c717e3af4d509c504fdbe174c6c5
|
9ae6c946dd5d66afcde5b61418416b0c085c5c21
|
/7_Parola_Sprites/2_Rocket/2_Rocket.ino
|
d8902990d909ec805888081166c42ff85fb47a28
|
[] |
no_license
|
Altium-Designer-Projects/ESP3212_MAX7219_EXAMPLES
|
b7ca574a72f5478e204dd9e61a3cf1ea4b3da211
|
b10524b1bdc634ea06add3d0b6334476c32bba2c
|
refs/heads/master
| 2022-12-04T03:58:09.094899
| 2020-08-28T14:48:58
| 2020-08-28T14:48:58
| 291,071,038
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,108
|
ino
|
2_Rocket.ino
|
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 8
#define CS_PIN 27
#define CLK_PIN 26
#define DATA_PIN 25
MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES); // Software spi
char msg[] = "Parola Sprites";
char *buffer_text[] =
{
"istanbul",
"ankara",
"antalya",
"vedat",
"baloglu",
"ABCDEF",
"123456"
};
byte i = 0;
// Sprite Definition
const uint8_t F_ROCKET = 2;
const uint8_t W_ROCKET = 11;
const uint8_t PROGMEM rocket[F_ROCKET * W_ROCKET] = // rocket
{
0x18, 0x24, 0x42, 0x81, 0x99, 0x18, 0x99, 0x18, 0xa5, 0x5a, 0x81,
0x18, 0x24, 0x42, 0x81, 0x18, 0x99, 0x18, 0x99, 0x24, 0x42, 0x99,
};
void setup(void)
{
P.begin();
P.setSpriteData(rocket, W_ROCKET, F_ROCKET, rocket, W_ROCKET, F_ROCKET);
}
void loop(void)
{
if (P.displayAnimate()){
P.displayText(buffer_text[i], PA_CENTER, 20, 1000, PA_SPRITE, PA_SPRITE);
delay(1000);
i++;
if( i >= 7){
i=0;
}
}
}
|
1ad4ebb306d41dce986165c42d55a471b8e7bb56
|
2d0bada349646b801a69c542407279cc7bc25013
|
/src/vai_library/xnnpp/src/efficientdet_d2/anchor.cpp
|
2982f0de0bd0215d07d64ed57326245755b46b71
|
[
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"BSD-3-Clause-Open-MPI",
"LicenseRef-scancode-free-unknown",
"Libtool-exception",
"GCC-exception-3.1",
"LicenseRef-scancode-mit-old-style",
"OFL-1.1",
"JSON",
"LGPL-2.1-only",
"LGPL-2.0-or-later",
"ICU",
"LicenseRef-scancode-other-permissive",
"GPL-2.0-or-later",
"GPL-3.0-only",
"LicenseRef-scancode-issl-2018",
"MIT",
"LGPL-2.1-or-later",
"LicenseRef-scancode-unicode",
"LGPL-3.0-only",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-3.0-or-later",
"Zlib",
"BSD-Source-Code",
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"ISC",
"NCSA",
"LicenseRef-scancode-proprietary-license",
"GPL-2.0-only",
"CC-BY-4.0",
"FSFULLR",
"Minpack",
"Unlicense",
"BSL-1.0",
"NAIST-2003",
"LicenseRef-scancode-protobuf",
"LicenseRef-scancode-public-domain",
"Libpng",
"Spencer-94",
"BSD-2-Clause",
"Intel",
"GPL-1.0-or-later",
"MPL-2.0"
] |
permissive
|
Xilinx/Vitis-AI
|
31e664f7adff0958bb7d149883ab9c231efb3541
|
f74ddc6ed086ba949b791626638717e21505dba2
|
refs/heads/master
| 2023-08-31T02:44:51.029166
| 2023-07-27T06:50:28
| 2023-07-27T06:50:28
| 215,649,623
| 1,283
| 683
|
Apache-2.0
| 2023-08-17T09:24:55
| 2019-10-16T21:41:54
|
Python
|
UTF-8
|
C++
| false
| false
| 6,370
|
cpp
|
anchor.cpp
|
/*
* Copyright 2022-2023 Advanced Micro Devices 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 "./anchor.hpp"
#include <algorithm>
#include <cassert>
#include <cmath>
#include <vitis/ai/env_config.hpp>
#include <vitis/ai/profiling.hpp>
namespace vitis {
namespace ai {
namespace efficientdet_d2 {
DEF_ENV_PARAM(DEBUG_ANCHOR, "0");
Anchor::Anchor(const AnchorConfig& config) : config_(config){};
void Anchor::generate_boxes() {
int level_num = config_.max_level - config_.min_level + 1;
LOG_IF(INFO, ENV_PARAM(DEBUG_ANCHOR)) << "level_num:" << level_num;
//assert(config_.aspect_ratios.size() > 0);
//assert(config_.anchor_scales.size() == level_num);
int feat_w = config_.image_width;
int feat_h = config_.image_height;
for (auto l = config_.min_level; l <= config_.max_level; ++l) {
auto level = l;
feat_w = config_.image_width / std::round(std::exp2(level));
feat_h = config_.image_height / std::round(std::exp2(level));
LOG_IF(INFO, ENV_PARAM(DEBUG_ANCHOR))
<< "feat_w:" << feat_w << " , feat_h:" << feat_h;
int stride_w = config_.image_width / feat_w;
int stride_h = config_.image_height / feat_h;
int mesh_width = (config_.image_width + 0.5 * stride_w) / stride_w;
int mesh_height = (config_.image_height + 0.5 * stride_h) / stride_h;
LOG_IF(INFO, ENV_PARAM(DEBUG_ANCHOR))
<< "mesh_width:" << mesh_width << " , mesh_height:" << mesh_height;
int num = config_.num_scales * config_.aspect_ratios.size();
// LevelBoxes boxes(mesh_width * mesh_height * num, std::vector<float>(4));
leveled_bboxes_[level] = std::make_shared<LevelBoxes>(
mesh_width * mesh_height * num, std::vector<float>(4));
auto& boxes = *leveled_bboxes_[level];
for (auto scale_octave = 0; scale_octave < config_.num_scales;
++scale_octave) {
for (auto ii = 0u; ii < config_.aspect_ratios.size(); ++ii) {
// for (auto& aspect : config_.aspect_ratios) {
int level_idx = scale_octave * config_.aspect_ratios.size() + ii;
LOG_IF(INFO, ENV_PARAM(DEBUG_ANCHOR))
<< "num:" << num << ", level_idx:" << level_idx;
float octave_scale = ((float)scale_octave) / config_.num_scales;
float anchor_scale = config_.anchor_scales[level - config_.min_level];
float aspect = config_.aspect_ratios[ii];
LOG_IF(INFO, ENV_PARAM(DEBUG_ANCHOR))
<< "stride_w:" << stride_w << " stride_h:" << stride_h
<< " octave_scale:" << octave_scale << " aspect:" << aspect
<< " anchor_scale:" << anchor_scale;
auto base_anchor_size_x =
anchor_scale * stride_w * std::exp2(octave_scale);
auto base_anchor_size_y =
anchor_scale * stride_h * std::exp2(octave_scale);
auto aspect_x = std::sqrt(aspect);
auto aspect_y = 1.f / aspect_x;
auto anchor_size_x_2 = base_anchor_size_x * aspect_x / 2.0;
auto anchor_size_y_2 = base_anchor_size_y * aspect_y / 2.0;
for (auto y = stride_h / 2; y < config_.image_height;
y = y + stride_h) {
for (auto x = stride_w / 2; x < config_.image_width;
x = x + stride_w) {
int index =
(y / stride_h * mesh_width + x / stride_w) * num + level_idx;
// LOG_IF(INFO, ENV_PARAM(DEBUG_ANCHOR))
// << "(y / stride_h):" << y / stride_h
// << ", mesh_width:" << mesh_width
// << ", (x / stide_w):" << x / stride_w;
boxes[index][0] = y - anchor_size_y_2;
boxes[index][1] = x - anchor_size_x_2;
boxes[index][2] = y + anchor_size_y_2;
boxes[index][3] = x + anchor_size_x_2;
LOG_IF(INFO, ENV_PARAM(DEBUG_ANCHOR))
<< "y:" << y << ", x:" << x << ", index:" << index
<< ", boxes: [" << boxes[index][0] << "," << boxes[index][1]
<< "," << boxes[index][2] << "," << boxes[index][3] << "]";
}
}
}
}
}
}
std::vector<std::vector<float>> Anchor::generate_boxes_(const int stride_w,
const int stride_h,
float octave_scale,
float aspect,
float anchor_scale) {
int mesh_width = (config_.image_width + stride_w) / stride_w;
int mesh_height = (config_.image_height + stride_h) / stride_h;
LevelBoxes boxes(mesh_width * mesh_height, std::vector<float>(4));
auto base_anchor_size_x = anchor_scale * stride_w * std::exp2(octave_scale);
auto base_anchor_size_y = anchor_scale * stride_h * std::exp2(octave_scale);
auto aspect_x = std::sqrt(aspect);
auto aspect_y = 1.f / aspect_x;
auto anchor_size_x_2 = base_anchor_size_x * aspect_x / 2.0;
auto anchor_size_y_2 = base_anchor_size_y * aspect_y / 2.0;
for (auto y = stride_h / 2; y < config_.image_height; y = y + stride_h) {
for (auto x = stride_w / 2; x < config_.image_width; x = x + stride_w) {
int index = y / stride_h * mesh_width + x / stride_w;
boxes[index][0] = y - anchor_size_y_2;
boxes[index][1] = x - anchor_size_x_2;
boxes[index][2] = y + anchor_size_y_2;
boxes[index][3] = x + anchor_size_x_2;
LOG_IF(INFO, ENV_PARAM(DEBUG_ANCHOR))
<< "y:" << y << ", x:" << x << ", boxes: [" << boxes[index][0] << ","
<< boxes[index][1] << "," << boxes[index][2] << "," << boxes[index][3]
<< "]";
}
}
return boxes;
}
std::shared_ptr<Anchor::LevelBoxes> Anchor::get_boxes(int level) {
if (leveled_bboxes_.count(level) == 0) {
return nullptr;
} else {
return leveled_bboxes_[level];
}
}
} // namespace efficientdet_d2
} // namespace ai
} // namespace vitis
|
1a03113b7e1f6b2d401611ccfc4baef1cdb2c152
|
c8b2840ea52b1dcb2009b9890cac70ccd4e30875
|
/Arduino/Kiln/TempWaveForm.cpp
|
a69503c9170d4a09cbb762a9cfc474f34b2d4aec
|
[] |
no_license
|
GMTEC/Kiln
|
71e351ce416231aaff5a2e05b730400b0103e8e4
|
3a3130a5cdc380d2c4529371e58cbaec18bd87c4
|
refs/heads/master
| 2021-09-03T20:21:36.319087
| 2018-01-11T18:31:25
| 2018-01-11T18:31:25
| 106,564,047
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,302
|
cpp
|
TempWaveForm.cpp
|
//
#include "TempWaveForm.h"
#include "Nex/NexWaveform.h"
#include "Nex/NexText.h"
#include "PIDTemperature.h"
#include "PageMain.h"
//NexWaveform wafeForm(0, 2, "s0");
double XScale, YScale;
uint32_t width = 312;
uint32_t height = 164;
int XOfst = 75;
int YOfst = 60;
double X0, Y0;
int XPos, YPos;
String strBuffer1;
char buffer1[80] = {0};
NexText graphTxt(0, 9, "status");
void TempWaveFormClass::init()
{
//wafeForm.Set_channel_0_color_pco0(32768);
graphTxt.setText("");
XScale = YScale = 1;
setRange(100, 100);
//graphTxt.getParameter(".w", width);
//graphTxt.getParameter(".h", height);
// Serial.println("Width: " + String(width )+", Height: " + String(height) );
//sendCommand("draw 0,0,200,200,GREEN");
}
void TempWaveFormClass::update()
{
//drawValue(XPos, PIDTemperature.getTemperature());
//XPos ++;
//wafeForm.addValue(0, temp);
//wafeForm.Set_channel_0_color_pco0( wafeForm.Set_channel_0_color_pco0(32768);
};
void TempWaveFormClass::addValue(int time, long temp)
{
}
void TempWaveFormClass::setRange(int temp, long time)
{
XScale = width /double(time);
YScale = height / double(temp);
Serial.println("XScale: " + String(XScale )+", YScale: " + String(YScale) );
}
void TempWaveFormClass::drawValue(long time, int temp)
{
double x, y;
x = XOfst + (XScale * time);
y = YOfst + height -(YScale * temp);
strBuffer1 = "cir " + String(int(X0)) + "," + String(int(Y0)) + "," + String(int(x)) + "," + String(int(y)) + ",RED";
strBuffer1.getBytes(buffer1, strBuffer1.length()+1);
Serial.println(buffer1);
sendCommand(buffer1); //sendCommand("draw 0,0,200,200,RED");
}
void TempWaveFormClass::moveTo(long timeSP, int tempSP)
{
X0 = XOfst + (XScale * timeSP);
Y0 = YOfst + height -(YScale * tempSP);
}
void TempWaveFormClass::drawLineTo(long timeSP, int tempSP)
{
double x, y;
x = XOfst + (XScale * timeSP);
y = YOfst + height -(YScale * tempSP);
//Serial.println("X: " + String(x));
strBuffer1 = "line " + String(int(X0)) + "," + String(int(Y0)) + "," + String(int(x)) + "," + String(int(y)) + ",RED";
strBuffer1.getBytes(buffer1, strBuffer1.length()+1);
X0 = x;
Y0 = y;
Serial.println(buffer1);
sendCommand(buffer1);
}
TempWaveFormClass TempWaveForm;
|
3272a2373f23a634db5c73231aaab63ed68745a1
|
cd16e9cac8db3f321aa1ab09cd6e04b813baf4b0
|
/partition3.cpp
|
77b40ca1fb3fc1d3252d3632cb1887c1a4cc6dd1
|
[] |
no_license
|
mia392/Algorithmis-Toolbox
|
128e8eb4d4d8bd97d136a9ac3802dce4250c51c8
|
a5bbd65b2def142ea2bcf2448ac8ad560542caeb
|
refs/heads/master
| 2022-08-03T00:51:37.626440
| 2020-05-31T08:53:44
| 2020-05-31T08:53:44
| 262,473,074
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 718
|
cpp
|
partition3.cpp
|
#include <iostream>
#include <vector>
using std::vector;
int partition3(vector<int> &A) {
int sum=0;
for (int i=0; i<A.size();++i){
sum +=A[i];
}
if (sum%3!=0) return 0;
//int subsum=sum/3;
int n=A.size();
bool dp[sum+1][n+1];
for (int i=0;i<=n; ++i){
dp[0][i]=true;
}
for (int j=1;j<=sum; ++j ){
dp[j][0]=false;
}
for (int i=1; i<=sum; ++i){
for (int j=1; j<=n; ++j){
dp[i][j]=dp[i][j-1];
if (i>=A[j-1]){
dp[i][j]=dp[i][j]||dp[i-A[j-1]][j-1];
}
}
}
return dp[sum/3][n]&&dp[sum/3*2][n];
}
int main() {
int n;
std::cin >> n;
vector<int> A(n);
for (size_t i = 0; i < A.size(); ++i) {
std::cin >> A[i];
}
std::cout << partition3(A) << '\n';
}
|
479885a9d6640b5b708db4694abaeef7768975b3
|
ab506cc02c82d8d935ac2c798c05536e2fe2daff
|
/Dll1/PatcherC.cpp
|
78c12592ac304569ccdd643f41e5914cf093c87d
|
[] |
no_license
|
PyatiyEtaj/FullHax
|
1e2db172a1ad72d85eecb5be774d0014761891f8
|
a5b8853d6d693b14aa8656b82c315d1999f5d674
|
refs/heads/master
| 2022-12-06T13:39:50.100047
| 2020-07-09T08:53:37
| 2020-07-09T08:53:37
| 223,615,559
| 0
| 0
| null | null | null | null |
WINDOWS-1251
|
C++
| false
| false
| 7,395
|
cpp
|
PatcherC.cpp
|
#include "PatcherC.h"
/*Patcher_c* InitPatcher(const std::vector<int> &offs)
{
HMODULE h = GetModuleHandleA("CShell.dll");
Patcher_c* p = (Patcher_c*)VirtualAlloc(NULL, sizeof(Patcher_c), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (!p) return NULL;
p->AllWpnsOriginals = (PWeapon*)VirtualAlloc(NULL, 4000 * sizeof(void*), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
p->AdrOfGetWpnById = FindPatternInModule(
CrtVec("\x55\x8B\xEC\x66\x8B\x4D\x08\x66\x83\xF9\xFF", 11),
"CShell.dll"
);
if (!p->AdrOfGetWpnById) { free(p); return NULL; }
p->NeedToDetour = (PBYTE*)VirtualAlloc(NULL, sizeof(PBYTE) * 5, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (!p->NeedToDetour) { free(p); return NULL; }
// старые зигзаги
//PBYTE adr = p->AdrOfGetWpnById + 0x15DB1A;
//p->NeedToDetour[0] = adr - 0x12;
//p->NeedToDetour[1] = adr;
//p->NeedToDetour[2] = adr + 0x5A8;
//p->NeedToDetour[3] = adr + 0x20AB;
//p->NeedToDetour[4] = adr - 0x10946;
PBYTE adr = p->AdrOfGetWpnById + 0x17F13A;
p->NeedToDetour[0] = adr - 0x12;
p->NeedToDetour[1] = adr;
p->NeedToDetour[2] = adr + 0x5A8;
p->NeedToDetour[3] = adr + 0x209B;
p->NeedToDetour[4] = adr - 0x1099A;
// B19
// c5c
// B55
return p;
}*/
size_t WEAPON_SIZE;
size_t GetWeaponSize(PBYTE proc)
{
PBYTE ptr = (PBYTE)fGetWpnById(proc)(1897);
PBYTE ptr2 = (PBYTE)fGetWpnById(proc)(1898);
//printf_s("%X %x %d\n", ptr2, ptr, size);
return static_cast<size_t>(ptr2 - ptr);
}
Patcher_c* InitPatcher(const std::vector<int>& offs)
{
DWORD h = (DWORD)GetModuleHandleA("CShell.dll");
Patcher_c* p = (Patcher_c*)VirtualAlloc(NULL, sizeof(Patcher_c), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (!p) return NULL;
p->AllWpnsOriginals = (PWeapon*)VirtualAlloc(NULL, 4000 * sizeof(void*), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
p->AdrOfGetWpnById = (PBYTE)(h + offs[OffsEnum::SKGetWpn]);
if (!p->AdrOfGetWpnById) { free(p); return NULL; }
p->NeedToDetour = (PBYTE*)VirtualAlloc(NULL, sizeof(PBYTE) * 5, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (!p->NeedToDetour) { free(p); return NULL; }
//PBYTE adr = p->AdrOfGetWpnById + 0x17F13A;
p->NeedToDetour[0] = (PBYTE)(h + offs[OffsEnum::SKPatch2]);//adr - 0x12;
p->NeedToDetour[1] = (PBYTE)(h + offs[OffsEnum::SKPatch1]);
p->NeedToDetour[2] = (PBYTE)(h + offs[OffsEnum::SKPatch3]);
p->NeedToDetour[3] = (PBYTE)(h + offs[OffsEnum::SKPatch4]);
p->NeedToDetour[4] = (PBYTE)(h + offs[OffsEnum::SKPatch5]);
WEAPON_SIZE = GetWeaponSize(p->AdrOfGetWpnById);
std::ofstream f("Bytes/WEAPON_SIZE.txt");
f << WEAPON_SIZE << "--" << sizeof(Weapon) << std::endl;
f.close();
return p;
}
void SetPatches(Patcher_c* p, DWORD adrNew)
{
for (int i = 0; i < 5; i++)
{
DetourFunc(p->NeedToDetour[i], adrNew);
}
for (int i = 0; i < 4000; i++)
{
PBYTE ptr = (PBYTE)fGetWpnById(p->AdrOfGetWpnById)(i);
if (!ptr) continue;
int16_t id = *((int16_t*)ptr); //((int16_t)(ptr)[1] << 8) | (int16_t)((ptr)[0]);
PWeapon weapon = (PWeapon)VirtualAlloc(NULL, sizeof(Weapon), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
memcpy_s(weapon, sizeof(Weapon), ptr, sizeof(Weapon));
p->AllWpnsOriginals[id] = weapon;
}
}
void* MakeAdrOfFunc(void* ptr, size_t sz)
{
void* newAdr = VirtualAlloc(NULL, sz, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);;
DWORD temp;
if (newAdr && VirtualProtect(newAdr, sz, PAGE_EXECUTE_READWRITE, &temp))
{
memcpy_s(newAdr, sz, ptr, sz);
return newAdr;
}
return NULL;
}
void AddNewWpnByIds(Patcher_c* p, std::string path, bool izyMode)
{
// parts and them lengths
std::vector<DWORD>
parts = { 0xE , 0x1FA0 },//parts = { 0xE , 0x1E58 };
lengths = { 0xB42, 0x3468 };//lengths = { 0xB46, 0x2874 };
//----------
int16_t id_wpn, id_zamena;
PBYTE src, newOne;
std::ifstream file(path);
file >> id_wpn >> id_zamena;
src = (PBYTE)fGetWpnById(p->AdrOfGetWpnById)(id_wpn);
newOne = (PBYTE)fGetWpnById(p->AdrOfGetWpnById)(id_zamena);
if (src == nullptr || newOne == nullptr) { printf_s("SOOOKA BLYAT!\n"); return; }
for (int i = 0; i < lengths.size(); i++)
{
memcpy_s(src + parts[i], lengths[i], newOne + parts[i], lengths[i]);
}
}
void AddNewWpnTest(Patcher_c* p, std::string path, bool withoutPkm)
{
int16_t id_wpn, id_zamena;
PBYTE src, newOne;
std::ifstream file(path);
file >> id_wpn >> id_zamena;
src = (PBYTE)fGetWpnById(p->AdrOfGetWpnById)(id_wpn);
newOne = (PBYTE)fGetWpnById(p->AdrOfGetWpnById)(id_zamena);
if (src == nullptr || newOne == nullptr) { /*printf_s("wpn with id %d or %d doesnt exist. continue...\n", id_wpn, id_zamena);*/ return; }
memcpy_s( src + 0x2, sizeof(Weapon) - 2, p->AllWpnsOriginals[id_zamena]->data + 0x2, sizeof(Weapon) - 2);
memcpy_s(newOne + 0x2, sizeof(Weapon) - 2, p->AllWpnsOriginals[id_wpn]->data + 0x2, sizeof(Weapon) - 2);
memcpy_s(src + 0x990, 0x40, p->AllWpnsOriginals[id_wpn]->data + 0x990, 0x40);
memcpy_s(src + 0xEBD, 0x1C, p->AllWpnsOriginals[id_wpn]->data + 0xEBD, 0x1C);
if (withoutPkm)
memcpy_s(src + 0xDF0, 0x6D0, p->AllWpnsOriginals[id_wpn]->data + 0xDF0, 0x6D0);
//*(float*)(src + 3088) = 0.0001f;//damageperdistance
//*(float*)(src + 4348) = 0.0f;//speedpenalty
}
void AddNewWpnRaw(Patcher_c* p, std::string path)
{
auto zamena = ReadFileHex(path.c_str());
int16_t id = *((int16_t*)zamena.data());
if (id < 0 || id > 4000) return;
PBYTE src = (PBYTE)fGetWpnById(p->AdrOfGetWpnById)(id);
memcpy_s(src, sizeof(Weapon), zamena.data(), sizeof(Weapon));
}
void GM(Patcher_c* p, bool lifewithoutgrenade)
{
auto setzero = [](PBYTE ptr, size_t sz)->void {
for (size_t i = 0; i < sz; i++)
{
*(ptr+ i) = 0;
}
};
DWORD offwpn = 0x2445;
for (int i = 0; i < 4000; i++)
{
auto ptr = (PBYTE)fGetWpnById(p->AdrOfGetWpnById)(i);
if (ptr == nullptr) continue;
if (strcmp((char*)(ptr + 0x99F), "grenade") == 0)
{
if (lifewithoutgrenade) setzero(ptr + 0x3C0, 0x1D0);
}
else
{
setzero(ptr + offwpn, 0x20);
}
}
}
std::vector<std::string> Dir(std::string root, std::string pattern)
{
WIN32_FIND_DATAA fd;
std::vector<std::string> res;
HANDLE hFind = FindFirstFileA((root + pattern).c_str(), &fd);
if (hFind != INVALID_HANDLE_VALUE)
{
do {
//printf("%s: %s\n", (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? "Folder" : "File", fd.cFileName);
std::string s = root;
s += fd.cFileName;
res.push_back(s);
} while (FindNextFileA(hFind, &fd));
FindClose(hFind);
}
return res;
}
void AddABanchOfWpns(Patcher_c* p)
{
auto dotT = Dir("Bytes//", "*.semi.txt");
auto dotTest = Dir("Bytes//", "*.full.txt");
auto dotTest2 = Dir("Bytes//", "*.full2.txt");
auto raw = Dir("Bytes//", "*.raw.txt");
for (auto el : dotT)
{
AddNewWpnByIds(p, el, false);
}
for (auto el : dotTest)
{
AddNewWpnTest(p, el);
}
for (auto el : dotTest2)
{
AddNewWpnTest(p, el, true);
}
for (auto el : raw)
{
AddNewWpnRaw(p, el);
}
}
void MakeDumpAllWpns(Patcher_c* p, std::string path, bool full)
{
std::ofstream f(path + "weapons.txt");
for (int i = 0; i < 4000; i++)
{
auto ptr = (PBYTE)fGetWpnById(p->AdrOfGetWpnById)(i);
if (ptr == nullptr) continue;
f << std::string((char*)(ptr + 0xE)) + " [" + std::to_string(i) + "]\n";
if (full)
{
auto s = path + "//wpnsdatas//" + std::string((char*)(ptr + 0xE)) + " [" + std::to_string(i) + "].data";
MakeBin(ptr, sizeof(Weapon), s.c_str());
}
}
f.close();
}
|
988e9ef183a7a7a3fcb333e6c62fca0b71c6074e
|
7de9724c235ffdddae5f15236d1016ea4e95bc9a
|
/scene/Camera.cpp
|
af6b1886713512bcddda98ebd5266ab5df6aa989
|
[] |
no_license
|
Mecrof/3DCharacterAnimation55
|
8566b8dbb6f5d28818f803cbd3ab3610706ed563
|
cbffdf4a24cc171cfe09174ed618295b6e11bd3d
|
refs/heads/master
| 2016-09-05T17:16:27.516777
| 2014-06-13T17:39:18
| 2014-06-13T17:39:18
| 18,703,800
| 5
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,995
|
cpp
|
Camera.cpp
|
#include "Camera.hpp"
namespace scene
{
/////////////////////////////// PUBLIC ///////////////////////////////////////
//============================= LIFECYCLE ====================================
Camera::Camera()
{
m_Phi = 0.0f;
m_Theta = 0.0f;
m_Orientation = glm::vec3(0.0f, 0.0f, 0.0f);
m_Verticalaxis = glm::vec3(0.0f, 0.0f, 1.0f);
m_SideMove = glm::vec3(0.0f, 0.0f, 0.0f);
m_Position = glm::vec3(0.0f, 0.0f, 0.0f);
m_Target = glm::vec3(0.0f, 0.0f, 0.0f);
m_Sensivity = 0.5f;
}
Camera::Camera(glm::vec3 position, glm::vec3 target, glm::vec3 verticalaxis)
{
m_Phi = -35.26f;
m_Theta = -135.0f;
m_Orientation = glm::vec3(0.0f, 0.0f, 0.0f);
m_Verticalaxis = verticalaxis;
m_SideMove = glm::vec3(0.0f, 0.0f, 0.0f);
m_Position = position;
m_Target = target;
m_Sensivity = 0.5f;
}
Camera::~Camera()
{
}
//============================= OPERATIONS ===================================
/**************************************************************************
* Name: Orientation
* Description: Move the camera depending of the given inputs
* Inputs:
- parameter1: xRel Relative mouse position on x
- parameter2: yRel Relative mouse position on y
- parameter3: sensibility set the camera movement speed
* Returns: void
**************************************************************************/
void Camera::orientation(int xRel, int yRel, float sensibility)
{
// "-=" for trigonometric angles
m_Phi -= yRel*sensibility;
m_Theta -= xRel*sensibility;
if(m_Phi > 89.0f)
{
m_Phi = 89.0f;
}
else if(m_Phi < -89.0f)
{
m_Phi = -89.0f;
}
float phiRadian = m_Phi * M_PI / 180;
float thetaRadian = m_Theta * M_PI / 180;
// If vertical axis is x
if(m_Verticalaxis.x == 1.0)
{
m_Orientation.x = sin(phiRadian);
m_Orientation.y = cos(phiRadian) * cos(thetaRadian);
m_Orientation.z = cos(phiRadian) * sin(thetaRadian);
}
// If vertical axis is y
else if(m_Verticalaxis.y == 1.0)
{
m_Orientation.x = cos(phiRadian) * sin(thetaRadian);
m_Orientation.y = sin(phiRadian);
m_Orientation.z = cos(phiRadian) * cos(thetaRadian);
}
// If vertical axis is z
else
{
m_Orientation.x = cos(phiRadian) * cos(thetaRadian);
m_Orientation.y = cos(phiRadian) * sin(thetaRadian);
m_Orientation.z = sin(phiRadian);
}
// Normal calcul
m_SideMove = glm::cross(m_Verticalaxis, m_Orientation);
m_SideMove = glm::normalize(m_SideMove);
// Target calcul
m_Target = m_Position + m_Orientation;
}
/**************************************************************************
* Name: Move
* Description: Catch a key event and move the camera
* Inputs:
- parameter1: QEvent key event
* Returns: void
**************************************************************************/
void Camera::move(QEvent *event)
{
if(event->type() == QKeyEvent::KeyPress)
{
QKeyEvent *key = static_cast<QKeyEvent *>(event);
switch(key->key())
{
case Qt::Key_Up:
m_Position = m_Position + m_Orientation * m_Sensivity;
m_Target = m_Position + m_Orientation;
break;
case Qt::Key_Down:
m_Position = m_Position - m_Orientation * m_Sensivity;
m_Target = m_Position + m_Orientation;
break;
case Qt::Key_Left:
m_Position = m_Position + m_SideMove * m_Sensivity;
m_Target = m_Position + m_Orientation;
break;
case Qt::Key_Right:
m_Position = m_Position - m_SideMove * m_Sensivity;
m_Target = m_Position + m_Orientation;
break;
}
}
}
/**************************************************************************
* Name: LookAt
* Description: Allow the camera to look at the given modelview
* Inputs:
- parameter1: modelview is the view of the world
* Returns: void
**************************************************************************/
void Camera::lookat(glm::mat4 &modelview)
{
modelview = glm::lookAt(m_Position, m_Target, m_Verticalaxis);
}
//============================= ATTRIBUTE ACCESSORS ==========================
void Camera::setTarget(glm::vec3 target)
{
// Orientation vector calcul
m_Orientation = m_Target - m_Position;
m_Orientation = glm::normalize(m_Orientation);
// If vertical axis is x
if(m_Verticalaxis.x == 1.0)
{
m_Phi = asin(m_Orientation.x);
m_Theta = acos(m_Orientation.y / cos(m_Phi));
if(m_Orientation.y < 0)
m_Theta *= -1;
}
// If vertical axis is y
else if(m_Verticalaxis.y == 1.0)
{
m_Phi = asin(m_Orientation.y);
m_Theta = acos(m_Orientation.z / cos(m_Phi));
if(m_Orientation.z < 0)
m_Theta *= -1;
}
// If vertical axis is z
else
{
m_Phi = asin(m_Orientation.x);
m_Theta = acos(m_Orientation.z / cos(m_Phi));
if(m_Orientation.z < 0)
m_Theta *= -1;
}
m_Phi = m_Phi * 180 / M_PI;
m_Theta = m_Theta * 180 / M_PI;
}
void Camera::setPosition(glm::vec3 position)
{
m_Position = position;
m_Target = m_Position + m_Orientation;
}
void Camera::setSensivity(float sensivity)
{
sensivity = sensivity;
}
}
|
13357a63ca9fab786dfebb3cff6175cf0a03f2bd
|
98c39b5950902b4a16d6b78f1ffc1eaf34107890
|
/Mouth.cpp
|
781c74e43ebee850599c9005d2f92775011084a9
|
[] |
no_license
|
breeannwilson/CS273-Review-Homework
|
5650feb78e634951b08f013f79185eff3614c3a4
|
91541873e389044a651fc9aa8f73431cd2e2dc70
|
refs/heads/master
| 2021-01-22T04:05:26.732006
| 2017-05-25T18:26:36
| 2017-05-25T18:26:36
| 92,430,512
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 156
|
cpp
|
Mouth.cpp
|
#include "Mouth.h"
using namespace std;
//default number of teeth is 50
Mouth::Mouth() {
teeth = 50;
}
int Mouth::getTeeth() {
return teeth;
}
|
511504366de637785f829de174d61c16a862ee9c
|
54f352a242a8ad6ff5516703e91da61e08d9a9e6
|
/Source Codes/AtCoder/arc077/B/2866130.cpp
|
526496ba30afd7d624e652ed0c3929b2e3e5ee81
|
[] |
no_license
|
Kawser-nerd/CLCDSA
|
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
|
aee32551795763b54acb26856ab239370cac4e75
|
refs/heads/master
| 2022-02-09T11:08:56.588303
| 2022-01-26T18:53:40
| 2022-01-26T18:53:40
| 211,783,197
| 23
| 9
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,724
|
cpp
|
2866130.cpp
|
// D.
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
using namespace std;
typedef long long LL;
static const LL MOD = 1000000007;
static const size_t MAX_N = 100001;
struct modll {
long long x;
modll() { }
modll(long long _x) : x(_x) { }
operator int() const { return (int)x; }
modll operator+(const modll &r) { return (x + r.x) % MOD; }
modll operator+=(const modll &r) { return x = (x + r.x) % MOD; }
modll operator-(const modll &r) { return (x + MOD - r.x) % MOD; }
modll operator-=(const modll &r) { return x = (x + MOD - r.x) % MOD; }
modll operator*(const modll &r) { return (x * r.x) % MOD; }
modll operator*(int r) { return (x * r) % MOD; }
modll operator*=(const modll &r) { return x = (x * r.x) % MOD; }
static modll modinv(int a) { return modpow(a, MOD - 2); }
static modll modpow(int a, int b) {
modll x = a, r = 1;
for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
return r;
}
};
modll combination(LL n, LL r) {
static modll fact[MAX_N + 1], inv[MAX_N + 1];
if (!fact[0]) {
fact[0] = 1;
for (int i = 1; i <= MAX_N; ++i) {
fact[i] = fact[i - 1] * i;
}
inv[MAX_N] = modll::modinv(fact[MAX_N]);
for (int i = MAX_N; i >= 1; --i) {
inv[i - 1] = inv[i] * i;
}
}
if (r > n) {
return 0;
}
return (fact[n] * inv[r]) * inv[n - r];
}
int main(int argc, char *argv[]) {
int n, d;
cin >> n;
vector<int> pos(n + 1, -1);
for (int i = 0; i <= n; ++i) {
int a;
cin >> a;
if (pos[a] >= 0) {
d = i - pos[a];
}
pos[a] = i;
}
for (int i = 1; i <= n + 1; ++i) {
modll ans = combination(n + 1, i) - combination(n - d, i - 1);
cout << ans << endl;
}
return 0;
}
|
421412cca13d88618ef3fe1476cc657215375b95
|
6b2a8dd202fdce77c971c412717e305e1caaac51
|
/solutions_2453486_1/C++/pix1gg/a.cpp
|
a45a94a186bc79d20d2bdd5bd1f5045708e78f48
|
[] |
no_license
|
alexandraback/datacollection
|
0bc67a9ace00abbc843f4912562f3a064992e0e9
|
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
|
refs/heads/master
| 2021-01-24T18:27:24.417992
| 2017-05-23T09:23:38
| 2017-05-23T09:23:38
| 84,313,442
| 2
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,944
|
cpp
|
a.cpp
|
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
bool check_dot(const vector<string> & map) {
for (int i=0; i<4; i++) {
for (int j=0; j<4; j++) {
if (map[i][j] == '.') {
return true;
}
}
}
return false;
}
void get_case(const vector<string> & map, vector<string> & cases) {
cases.clear();
for (int i=0; i<4; i++) {
cases.push_back(map[i]);
}
for (int i=0; i<4; i++) {
string str;
for (int j=0; j<4; j++) {
str += map[j][i];
}
cases.push_back(str);
}
string d1;
string d2;
for (int i=0; i<4; i++) {
d1 += map[i][i];
d2 += map[i][3-i];
}
cases.push_back(d1);
cases.push_back(d2);
}
void find_T(const vector<string> & map, int & row, int & col) {
for (int i=0; i<4; i++) {
for (int j=0; j<4; j++) {
if (map[i][j] == 'T') {
row = i;
col = j;
return;
}
}
}
}
int main(int argc, char * argv[]) {
string res[] = {"X won",
"O won",
"Draw",
"Game has not completed"};
int num;
cin >> num;
for (int i=0; i<num; i++) {
cout << "Case #" << i+1 << ": ";
vector<string> map;
for (int j=0; j<4; j++) {
string line;
cin >> line;
map.push_back(line);
}
int row, col;
row = 100;
find_T(map, row, col);
int winner = 2;
vector<string> cases;
if (row<4) {
map[row][col] = 'X';
}
get_case(map, cases);
for (int j=0; j<cases.size(); j++) {
if (cases[j] == "XXXX") {
winner = 0;
break;
}
}
if (row<4) {
map[row][col] = 'O';
}
get_case(map, cases);
for (int j=0; j<cases.size(); j++) {
if (cases[j] == "OOOO") {
winner = 1;
break;
}
}
if (winner == 2 && check_dot(map)) {
winner = 3;
}
cout << res[winner] << endl;
}
return 0;
}
|
9075b3a031a077a36790d12eaef9f9e98e454eb8
|
408a6a47509db59838a45d362707ffe6d2967a70
|
/Classes/Enemy.h
|
e8d9d87ee90cb0530db3c35a7614174bdac9e92f
|
[] |
no_license
|
DanicaMeng/RabbitRun
|
87d511645b90d9129d026b636adcb3e1b8854dd8
|
97892a01876186a2e69ff9776c70bdf2ea10f9bd
|
refs/heads/master
| 2021-05-15T21:14:05.028696
| 2018-10-19T04:08:30
| 2018-10-19T04:08:30
| 27,667,757
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 816
|
h
|
Enemy.h
|
#ifndef __ENEMY_H__
#define __ENEMY_H__
#include "cocos2d.h"
USING_NS_CC;
enum ENEMY_TYPE
{
EAGLE, // ӥ
};
enum MOVETYPE
{
MOVE_NULL = 0,
MOVE_ATTACK = 1,
MOVE_PATROL,
MOVE_FLYAWAY,
};
enum DIRECTTYPE
{
DIRECT_LEFT = 1,
DIRECT_RIGHT = 2,
};
class Enemy : public CCNode
{
public:
Enemy();
~Enemy();
bool init(ENEMY_TYPE type);
static Enemy* create(ENEMY_TYPE type);
CCSprite* getSprite(){return _sprite;}
private:
virtual void update(float dt);
void setMoveType(MOVETYPE mtype);
void patrolMove();
void attack();
void attackEnd();
void flyAway();
void flyAwayEnd();
void setDirection(CCPoint curPos,CCPoint newPos);
void setDirection(DIRECTTYPE direct);
CCSprite *_sprite;
ENEMY_TYPE _type;
MOVETYPE _moveType;
float _parSpeed;
float _attSpeed;
CCPoint _attBiginPos;
};
#endif
|
4a345942dc808285201a7c5b48e7f538a99a2267
|
3b350130226cdf1a4edacdcd4306f336f234732b
|
/Ch3/ex3_44.cpp
|
06515401ee2ea56d6fe0805ea31807fe712f9595
|
[] |
no_license
|
melodybabee/CppPrimer
|
0027eeaa7aed86907c9680f998f50e150fc8ccf0
|
85d4f2300daf3748a5eab58679baf480ff1fb88e
|
refs/heads/master
| 2020-03-22T07:48:57.869139
| 2018-09-20T00:42:29
| 2018-09-20T00:42:29
| 139,726,243
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 876
|
cpp
|
ex3_44.cpp
|
#include <iostream>
using std::endl;
using std::cout;
//范围for循环
int main()
{
int ia[3][4] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
using int_array = int[4];
for(int_array &i :ia)//第一层遍历ia的外层数组,此处指行,每一行是含有4个整数的数组的引用,因此大小为4
for (int q : i){//q来循环i所指的每一行的整数型的数
cout << q <<endl;
//for循环下标运算
for(size_t i = 0; i < 3; ++i)//第一层遍历ia的外层数组,此处指行,每一行是含有4个整数的数组的引用,因此大小为4
for (size_t j = 0; j < 4 ;++j){//q来循环i所指的每一行的整数型的数
cout << ia[i][j] <<endl;
//for 循环指针运算
for(int_array *i = ia; i != ia + 3; ++i)//直接表示指向首地址
for (int *j = *i; j != *i + 4 ;++j){//j指向i地址的值
cout << *j <<endl;
}
}
|
37de1e285b883342e6db1a3bf99950a700bb8493
|
fdfc146f88ae537938023a76057a1fd9fd7e9003
|
/old_code/v0.3/timer.h
|
c14028517fce572b44fd687a45cb1232d8e6903e
|
[] |
no_license
|
CS-Jackson/Solver
|
a374bf3cef1e3ba95832e26d9b6ffdc023197a60
|
076cd8693fc245ddb5c4f1cf6f2f8746c6642c69
|
refs/heads/master
| 2020-06-19T01:21:59.001344
| 2020-06-16T08:09:41
| 2020-06-16T08:09:41
| 196,517,168
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,164
|
h
|
timer.h
|
#pragma once
#include "http_conn.h"
#include "./base/nocopyable.hpp"
#include "./base/locker.hpp"
#include <unistd.h>
#include <memory>
#include <queue>
#include <deque>
// #include <iostream>
// using namespace std;
class Solver;
class mytimer
{
typedef std::shared_ptr<Solver> SP_Solver;
private:
bool deleted;
size_t expired_time;
SP_Solver solver_data;
public:
mytimer(SP_Solver _solver_data, int timeout);
~mytimer();
void update(int timeout);
bool isvalid();
void clearReq();
void setDeleted();
bool isDeleted() const;
size_t getExpTime() const;
};
struct timerCmp
{
bool operator()(std::shared_ptr<mytimer> &a, std::shared_ptr<mytimer> &b) const
{
return a->getExpTime() > b->getExpTime();
}
};
class HeapTimer
{
typedef std::shared_ptr<Solver> SP_Solver;
typedef std::shared_ptr<mytimer> SP_Timer;
private:
std::priority_queue<SP_Timer, std::deque<SP_Timer>, timerCmp> TimerQueue;
MutexLock lock;
public:
HeapTimer();
~HeapTimer();
void addTimer(SP_Solver Solver, int timeout);
void addTimer(SP_Timer timer_node);
void handle_expired_event();
};
|
ce94494056de5603062ac252f6268d5c89979d24
|
cf31c0a4e58c7943ef127dd96c3c4befe3198cf8
|
/src/physics.cpp
|
adc37466c0d64fe6856b5e65d280941a1635659e
|
[] |
no_license
|
dash-rai/labyrinth-opengl
|
31fae826dc30f08e25c276cac9bf06c42e71f575
|
b83ea1f77a9cb87dd9a4b94c1fb1659fde0c34e4
|
refs/heads/master
| 2016-09-05T20:43:10.437442
| 2015-05-24T05:28:12
| 2015-05-24T05:28:12
| 33,435,220
| 0
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,913
|
cpp
|
physics.cpp
|
#include <GL/glut.h>
#include <math.h>
#include <Box2D/Box2D.h>
#include "drawboard.h"
#include "physics.h"
b2Body *ballBody;
extern b2World world;
extern b2Vec2 hole_position;
extern bool gameover;
class HoleContactListener : public b2ContactListener
{
void BeginContact(b2Contact *contact)
{
b2Fixture *fixA, *fixB;
/* Process only hole-ball collisions */
fixA = contact->GetFixtureA();
fixB = contact->GetFixtureB();
if (fixA->IsSensor() || fixB->IsSensor()) {
if (fixA->IsSensor())
hole_position = fixA->GetBody()->GetPosition();
else
hole_position = fixB->GetBody()->GetPosition();
// finishPlay();
gameover = true;
}
}
};
/* Create collision listener */
HoleContactListener holeContactListenerInstance;
void calcGravity(float *x, float *y, float rotate_x, float rotate_y)
{
*x = sin(rotate_y * PI / 180.0) * GRAVITY;
// As this is basically rotation of the matrix along the X axis
// and is counter-clockwise, negate it to get the linear Y movement
*y = sin(-rotate_x * PI / 180.0) * GRAVITY;
}
void createBallObject()
{
b2BodyDef ballBodyDef;
ballBodyDef.position.Set(-X + T + BALL_RADIUS, Y - T - BALL_RADIUS);
ballBodyDef.type = b2_dynamicBody;
ballBody = world.CreateBody(&ballBodyDef);
b2CircleShape ballCircle;
ballCircle.m_radius = BALL_RADIUS;
b2FixtureDef ballFixtureDef;
ballFixtureDef.shape = &ballCircle;
ballFixtureDef.density = BALL_DENSITY;
ballFixtureDef.friction = FRICTION;
ballFixtureDef.restitution = RESTITUTION;
ballBody->CreateFixture(&ballFixtureDef);
}
void createWallObjects()
{
extern float walls[NUMBER_OF_WALLS][8][3];
for(int i = 0; i < NUMBER_OF_WALLS; i++) {
b2BodyDef wallBodyDef;
// only works for rectangles
float width = walls[i][2][0] - walls[i][0][0];
float height = walls[i][2][1] - walls[i][0][1];
width = (width < 0) ? -width : width;
height = (height < 0) ? -height : height;
float center_x = walls[i][0][0] + width / 2 ;
float center_y = walls[i][0][1] + height / 2;
wallBodyDef.position.Set(center_x, center_y);
wallBodyDef.type = b2_staticBody;
b2Body *wallBody = world.CreateBody(&wallBodyDef);
b2PolygonShape wallBox;
wallBox.SetAsBox(width / 2, height / 2);
b2FixtureDef wallFixtureDef;
wallFixtureDef.shape = &wallBox;
wallFixtureDef.density = WALL_DENSITY;
wallFixtureDef.friction = FRICTION;
wallFixtureDef.restitution = RESTITUTION;
wallBody->CreateFixture(&wallFixtureDef);
}
}
void createHoleObjects()
{
extern float holes[NUMBER_OF_HOLES][3];
for (int i = 0; i < NUMBER_OF_HOLES; i++) {
b2BodyDef holeBodyDef;
holeBodyDef.position.Set(holes[i][0], holes[i][1]);
b2Body *holeBody = world.CreateBody(&holeBodyDef);
b2CircleShape holeCircle;
/*
* TODO: allow some leeway by reducing the size of
* the hole's fixture
*/
holeCircle.m_radius = HOLE_RADIUS;
b2FixtureDef holeFixtureDef;
holeFixtureDef.shape = &holeCircle;
holeFixtureDef.isSensor = true;
holeBody->CreateFixture(&holeFixtureDef);
world.SetContactListener(&holeContactListenerInstance);
}
}
|
cffda81bb0522be3721923a5cc05751297999086
|
11d86f5c270757a0fac0aab101533a86db3c05cd
|
/libretro/nukleargui/sdl_wrapper/retro_surface.c
|
27df157ce87addd56a3c116ba368b2fb67c317f0
|
[] |
no_license
|
r-type/libretro-cap32-nuklear
|
faea5319645045e36fd1fbbb11fe6d8bc58a22c5
|
cc8edf2c5d8dda044d689eb78eb784b1c657dc10
|
refs/heads/master
| 2021-01-12T06:36:18.491022
| 2016-12-26T16:06:39
| 2016-12-26T16:06:39
| 77,394,161
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,919
|
c
|
retro_surface.c
|
#include "SDL_wrapper.h"
#include <stdio.h>
#include <string.h>
unsigned int Retro_MapRGB(RSDL_PixelFormat *a, int r, int g, int b){
return (r >> a->Rloss) << a->Rshift
| (g >> a->Gloss) << a->Gshift
| (b >> a->Bloss) << a->Bshift
| a->Amask;
}
unsigned int Retro_MapRGBA(RSDL_PixelFormat *a, int r, int g, int b,int alpha){
return (r >> a->Rloss) << a->Rshift
| (g >> a->Gloss) << a->Gshift
| (b >> a->Bloss) << a->Bshift
| ((alpha >> a->Aloss) << a->Ashift & a->Amask);
}
static __inline__
RSDL_bool RSDL_IntersectRect(const RSDL_Rect *A, const RSDL_Rect *B, RSDL_Rect *intersection)
{
int Amin, Amax, Bmin, Bmax;
/* Horizontal intersection */
Amin = A->x;
Amax = Amin + A->w;
Bmin = B->x;
Bmax = Bmin + B->w;
if(Bmin > Amin)
Amin = Bmin;
intersection->x = Amin;
if(Bmax < Amax)
Amax = Bmax;
intersection->w = Amax - Amin > 0 ? Amax - Amin : 0;
/* Vertical intersection */
Amin = A->y;
Amax = Amin + A->h;
Bmin = B->y;
Bmax = Bmin + B->h;
if(Bmin > Amin)
Amin = Bmin;
intersection->y = Amin;
if(Bmax < Amax)
Amax = Bmax;
intersection->h = Amax - Amin > 0 ? Amax - Amin : 0;
return (intersection->w && intersection->h);
}
/*
* Set the clipping rectangle for a blittable surface
*/
RSDL_bool RSDL_SetClipRect(RSDL_Surface *surface, const RSDL_Rect *rect)
{
RSDL_Rect full_rect;
/* Don't do anything if there's no surface to act on */
if ( ! surface ) {
return RSDL_FALSE;
}
/* Set up the full surface rectangle */
full_rect.x = 0;
full_rect.y = 0;
full_rect.w = surface->w;
full_rect.h = surface->h;
/* Set the clipping rectangle */
if ( ! rect ) {
surface->clip_rect = full_rect;
return 1;
}
return RSDL_IntersectRect(rect, &full_rect, &surface->clip_rect);
}
void RSDL_GetClipRect(RSDL_Surface *surface, RSDL_Rect *rect)
{
if ( surface && rect ) {
*rect = surface->clip_rect;
}
}
void Retro_FreeSurface(RSDL_Surface *surf )
{
printf("free surf format palette color\n");
if(surf->format->palette->colors)
free(surf->format->palette->colors);
printf("free surf format palette \n");
if(surf->format->palette)
free(surf->format->palette);
printf("free surf format \n");
if(surf->format)
free(surf->format);
printf("free surf pixel \n");
if(surf->pixels)
free(surf->pixels);
printf("free surf \n");
if(surf)
free(surf);
}
RSDL_Surface *Retro_CreateRGBSurface32( int w,int h, int d, int rm,int rg,int rb,int ra)
{
printf("s(%d,%d,%d) (%x,%x,%x,%x)\n",w,h,d,rm,rg,rb,ra);
RSDL_Surface *bitmp;
bitmp = (RSDL_Surface *) calloc(1, sizeof(*bitmp));
if (bitmp == NULL)
{
printf("tex surface failed");
return NULL;
}
bitmp->format = (RSDL_PixelFormat *) calloc(1,sizeof(*bitmp->format));
if (bitmp->format == NULL)
{
printf("tex format failed");
return NULL;
}
bitmp->format->palette =(RSDL_Palette *) calloc(1,sizeof(*bitmp->format->palette));
if (bitmp->format->palette == NULL)
{
printf("tex format palette failed");
return NULL;
}
printf("create surface XR8G8B8 libretro\n");
//FIXME: why pal for 32 bits surface ?
bitmp->format->palette->ncolors=256;
bitmp->format->palette->colors=(RSDL_Color *)malloc(1024);
bitmp->format->palette->version=0;
bitmp->format->palette->refcount=0;
memset(bitmp->format->palette->colors,0x0,1024);
bitmp->format->BitsPerPixel = 32;
bitmp->format->BytesPerPixel = 4;
bitmp->format->Rloss=0;
bitmp->format->Gloss=0;
bitmp->format->Bloss=0;
bitmp->format->Aloss=0;
bitmp->format->Rshift=16;
bitmp->format->Gshift=8;
bitmp->format->Bshift=0;
bitmp->format->Ashift=24;
bitmp->format->Rmask=0x00ff0000;
bitmp->format->Gmask=0x0000ff00;
bitmp->format->Bmask=0x000000ff;
bitmp->format->Amask=0xff000000;
/*
bitmp->format->Rshift=16;
bitmp->format->Gshift=8;
bitmp->format->Bshift=0;
bitmp->format->Ashift=24;
bitmp->format->Rmask=0x00ff0000;
bitmp->format->Gmask=0x0000ff00;
bitmp->format->Bmask=0x000000ff;
bitmp->format->Amask=0xff000000;
*/
bitmp->format->colorkey=0;
bitmp->format->alpha=255;//0;
//bitmp->format->palette = NULL;
bitmp->flags=0;
bitmp->w=w;
bitmp->h=h;
bitmp->pitch=w*4;
bitmp->pixels=malloc(sizeof(unsigned char)*h*w*4);// (unsigned char *)&Retro_Screen[0];
if (!bitmp->pixels) {
printf("failed alloc pixels\n");
Retro_FreeSurface(bitmp);
return NULL;
}
memset(bitmp->pixels,0, h*w*4);
bitmp->clip_rect.x=0;
bitmp->clip_rect.y=0;
bitmp->clip_rect.w=w;
bitmp->clip_rect.h=h;
//printf("fin prepare tex:%dx%dx%d\n",bitmp->w,bitmp->h,bitmp->format->BytesPerPixel);
return bitmp;
}
RSDL_Surface *Retro_CreateRGBSurface16( int w,int h, int d, int rm,int rg,int rb,int ra)
{
printf("s(%d,%d,%d) (%x,%x,%x,%x)\n",w,h,d,rm,rg,rb,ra);
RSDL_Surface *bitmp;
bitmp = (RSDL_Surface *) calloc(1, sizeof(*bitmp));
if (bitmp == NULL)
{
printf("tex surface failed");
return NULL;
}
bitmp->format =(RSDL_PixelFormat *) calloc(1,sizeof(*bitmp->format));
if (bitmp->format == NULL)
{
printf("tex format failed");
return NULL;
}
bitmp->format->palette = (RSDL_Palette *)calloc(1,sizeof(*bitmp->format->palette));
if (bitmp->format->palette == NULL)
{
printf("tex format palette failed");
return NULL;
}
printf("create surface RGB565 libretro\n");
//FIXME: why pal for 32 bits surface ?
bitmp->format->palette->ncolors=256;
bitmp->format->palette->colors=(RSDL_Color *)malloc(256*2);
bitmp->format->palette->version=0;
bitmp->format->palette->refcount=0;
memset(bitmp->format->palette->colors,0x0,256*2);
bitmp->format->BitsPerPixel = 16;
bitmp->format->BytesPerPixel = 2;
bitmp->format->Rloss=3;
bitmp->format->Gloss=3;
bitmp->format->Bloss=3;
bitmp->format->Aloss=0;
bitmp->format->Rshift=11;
bitmp->format->Gshift=6;
bitmp->format->Bshift=0;
bitmp->format->Ashift=0;
bitmp->format->Rmask=0x0000F800;
bitmp->format->Gmask=0x000007E0;
bitmp->format->Bmask=0x0000001F;
bitmp->format->Amask=0x00000000;
/*
bitmp->format->Rshift=16;
bitmp->format->Gshift=8;
bitmp->format->Bshift=0;
bitmp->format->Ashift=24;
bitmp->format->Rmask=0x00ff0000;
bitmp->format->Gmask=0x0000ff00;
bitmp->format->Bmask=0x000000ff;
bitmp->format->Amask=0xff000000;
*/
bitmp->format->colorkey=0;
bitmp->format->alpha=255;//0;
//bitmp->format->palette = NULL;
bitmp->flags=0;
bitmp->w=w;
bitmp->h=h;
bitmp->pitch=w*2;
bitmp->pixels=malloc(sizeof(unsigned char)*h*w*2);// (unsigned char *)&Retro_Screen[0];
if (!bitmp->pixels) {
printf("failed alloc pixels\n");
Retro_FreeSurface(bitmp);
return NULL;
}
memset(bitmp->pixels,0, h*w*2);
bitmp->clip_rect.x=0;
bitmp->clip_rect.y=0;
bitmp->clip_rect.w=w;
bitmp->clip_rect.h=h;
//printf("fin prepare tex:%dx%dx%d\n",bitmp->w,bitmp->h,bitmp->format->BytesPerPixel);
return bitmp;
}
#include "font2.i"
#ifdef M16B
void Retro_Draw_string(RSDL_Surface *surface, signed short int x, signed short int y, const char *string,unsigned short maxstrlen,unsigned short xscale, unsigned short yscale, unsigned short fg, unsigned short bg)
#else
void Retro_Draw_string(RSDL_Surface *surface, signed short int x, signed short int y, const char *string,unsigned short maxstrlen,unsigned short xscale, unsigned short yscale, unsigned fg, unsigned bg)
#endif
{
int k,strlen;
unsigned char *linesurf;
int col, bit;
unsigned char b;
int xrepeat, yrepeat;
#ifdef M16B
signed short int ypixel;
unsigned short *yptr;
unsigned short*mbuffer=(unsigned short*)surface->pixels;
#else
signed int ypixel;
unsigned *yptr;
unsigned *mbuffer=(unsigned*)surface->pixels;
#endif
#define VIRTUAL_WIDTH surface->w
if ((surface->clip_rect.w==0) || (surface->clip_rect.h==0)) {
return;
}
#define charWidthLocal 8
#define charHeightLocal 8
Sint16 left, right, top, bottom;
Sint16 x1, y1, x2, y2;
left = surface->clip_rect.x;
x2 = x + charWidthLocal;
if (x2<left) {
return;
}
right = surface->clip_rect.x + surface->clip_rect.w - 1;
x1 = x;
if (x1>right) {
return;
}
top = surface->clip_rect.y;
y2 = y + charHeightLocal;
if (y2<top) {
return;
}
bottom = surface->clip_rect.y + surface->clip_rect.h - 1;
y1 = y;
if (y1>bottom) {
return;
}
if(string==NULL)return;
for(strlen = 0; strlen<maxstrlen && string[strlen]; strlen++) {}
int surfw=strlen * 7 * xscale;
int surfh=8 * yscale;
#ifdef M16B
linesurf =(unsigned char *)malloc(sizeof(unsigned short)*surfw*surfh );
yptr = (unsigned short *)&linesurf[0];
#else
linesurf =(unsigned char *)malloc(sizeof(unsigned )*surfw*surfh );
yptr = (unsigned *)&linesurf[0];
#endif
// yptr = (unsigned *)&linesurf[0];
for(ypixel = 0; ypixel<8; ypixel++) {
for(col=0; col<strlen; col++) {
b = font_array[(string[col]^0x80)*8 + ypixel];
for(bit=0; bit<7; bit++, yptr++) {
*yptr = (b & (1<<(7-bit))) ? fg : bg;
for(xrepeat = 1; xrepeat < xscale; xrepeat++, yptr++)
yptr[1] = *yptr;
}
}
for(yrepeat = 1; yrepeat < yscale; yrepeat++)
for(xrepeat = 0; xrepeat<surfw; xrepeat++, yptr++)
*yptr = yptr[-surfw];
}
#ifdef M16B
yptr = (unsigned short*)&linesurf[0];
#else
yptr = (unsigned *)&linesurf[0];
#endif
for(yrepeat = y; yrepeat < y+ surfh; yrepeat++)
for(xrepeat = x; xrepeat< x+surfw; xrepeat++,yptr++)
if(*yptr!=0 && (xrepeat+yrepeat*VIRTUAL_WIDTH) < surface->w*surface->h )mbuffer[xrepeat+yrepeat*VIRTUAL_WIDTH] = *yptr;
free(linesurf);
}
#ifdef M16B
void Retro_Draw_char(RSDL_Surface *surface, signed short int x, signed short int y, char string,unsigned short xscale, unsigned short yscale, unsigned short fg, unsigned short bg)
#else
void Retro_Draw_char(RSDL_Surface *surface, signed short int x, signed short int y, char string,unsigned short xscale, unsigned short yscale, unsigned fg, unsigned bg)
#endif
{
int k,strlen;
unsigned char *linesurf;
// signed int ypixel;
int col, bit;
unsigned char b;
int xrepeat, yrepeat;
#ifdef M16B
signed short int ypixel;
unsigned short *yptr;
unsigned short*mbuffer=(unsigned short*)surface->pixels;
#else
signed int ypixel;
unsigned *yptr;
unsigned *mbuffer=(unsigned*)surface->pixels;
#endif
// unsigned *yptr;
// unsigned *mbuffer=(unsigned*)surface->pixels;
#define VIRTUAL_WIDTH surface->w
if ((surface->clip_rect.w==0) || (surface->clip_rect.h==0)) {
return;
}
#define charWidthLocal 7*xscale
#define charHeightLocal 8*yscale
Sint16 left, right, top, bottom;
Sint16 x1, y1, x2, y2;
left = surface->clip_rect.x;
x2 = x + charWidthLocal;
if (x2<left) {
return;
}
right = surface->clip_rect.x + surface->clip_rect.w - 1;
x1 = x;
if (x1>right) {
return;
}
top = surface->clip_rect.y;
y2 = y + charHeightLocal;
if (y2<top) {
return;
}
bottom = surface->clip_rect.y + surface->clip_rect.h - 1;
y1 = y;
if (y1>bottom) {
return;
}
strlen = 1;
int surfw=strlen * 7 * xscale;
int surfh=8 * yscale;
#ifdef M16B
linesurf =(unsigned char *)malloc(sizeof(unsigned short)*surfw*surfh );
yptr = (unsigned short *)&linesurf[0];
#else
linesurf =(unsigned char *)malloc(sizeof(unsigned )*surfw*surfh );
yptr = (unsigned *)&linesurf[0];
#endif
// linesurf =(unsigned char *)malloc(sizeof(unsigned )*surfw*surfh );
// yptr = (unsigned *)&linesurf[0];
for(ypixel = 0; ypixel<8; ypixel++) {
//for(col=0; col<strlen; col++) {
b = font_array[(string^0x80)*8 + ypixel];
for(bit=0; bit<7; bit++, yptr++) {
*yptr = (b & (1<<(7-bit))) ? fg : bg;
for(xrepeat = 1; xrepeat < xscale; xrepeat++, yptr++)
yptr[1] = *yptr;
}
//}
for(yrepeat = 1; yrepeat < yscale; yrepeat++)
for(xrepeat = 0; xrepeat<surfw; xrepeat++, yptr++)
*yptr = yptr[-surfw];
}
#ifdef M16B
yptr = (unsigned short*)&linesurf[0];
#else
yptr = (unsigned *)&linesurf[0];
#endif
// yptr = (unsigned *)&linesurf[0];
for(yrepeat = y; yrepeat < y+ surfh; yrepeat++)
for(xrepeat = x; xrepeat< x+surfw; xrepeat++,yptr++)
if(*yptr!=0 && (xrepeat+yrepeat*VIRTUAL_WIDTH) < surface->w*surface->h )mbuffer[xrepeat+yrepeat*VIRTUAL_WIDTH] = *yptr;
free(linesurf);
}
|
0b23c4cf90c1ca7f13e6add6b9b7c2af00cfd00d
|
c38d4fd366180fc4bf55a6c3816363c6517916ae
|
/src/RobotManager.h
|
9f73809c8c5489ab2e077b56cbd10738d63bbd0e
|
[] |
no_license
|
olegsmvl/RobotArduino
|
085372f9fb960573d187a13b08405df125eab24d
|
a818dbc4b5727a4034073a2f53f1bcb67e585e17
|
refs/heads/master
| 2021-06-29T17:17:18.747444
| 2021-03-10T09:11:39
| 2021-03-10T09:11:39
| 219,105,431
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 392
|
h
|
RobotManager.h
|
#ifndef ROBOTMANAGER_H
#define ROBOTMANAGER_H
#include "Commands.h"
#include "Robot\Robot.h"
class RobotManager
{
public:
RobotManager();
void ExecuteCommand(int command);
void Loop();
int GetOdometerL();
int GetOdometerR();
void IncOdometerL();
void IncOdometerR();
Robot robot;
private:
};
#endif
|
6470001ce0c9ccd61a9a4b6525a203a28166bff7
|
d1aa937cc9807333d86f7dec58feffbd5ecc70a5
|
/CCNY Data Structures (C++)/5 - Trees/src/hw5q3.cpp
|
20932707b554703960147bf66e60ed60f14e885a
|
[] |
no_license
|
xburrito/Data-Structures
|
69d9273692397b079a11404b377b02f08c5e00fb
|
d5b829b2ed9c6eecfcaa51cd526d1aafdb031f3f
|
refs/heads/master
| 2021-08-19T13:03:13.309451
| 2020-05-30T01:03:51
| 2020-05-30T01:03:51
| 188,781,256
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,971
|
cpp
|
hw5q3.cpp
|
#ifndef __BT_CLASS_DA_CPP__
#define __BT_CLASS_DA_CPP__
#include "hw5q3.h"
// CONSTRUCTORS and DESTRUCTOR
template <class Item>
binaryTreeDA<Item>::binaryTreeDA( ){
capacity = DEF_CAP;
tree = new Item[capacity];
count = 0;
curr = 0;
}
template <class Item>
binaryTreeDA<Item>::binaryTreeDA(const binaryTreeDA& source){
if(source.count < DEF_CAP){
capacity = DEF_CAP;
count = source.count;
curr = source.curr;
tree = new Item[capacity];
for(size_t i = 0; i < capacity; i++){
tree[i] = source.tree[i];
}
}
}
template <class Item>
binaryTreeDA<Item>::~binaryTreeDA( ){
delete[] tree;
capacity = 0;
count = 0;
curr = -1;
}
// MODIFICATION MEMBER FUNCTIONS
template <class Item>
void binaryTreeDA<Item>::createFirstNode(const Item& entry){
if(count == 0){
tree[0] = entry;
curr = 0;
count = 1;
}
}
template <class Item>
void binaryTreeDA<Item>::shiftToRoot( ){
assert((size() > 0) && ((curr >= 0) && (curr < capacity)));
curr = 0;
}
template <class Item>
void binaryTreeDA<Item>::shiftUp( ){
if (hasParent()){
curr - floor((curr-1)/2);
}
}
template <class Item>
void binaryTreeDA<Item>::shiftLeft( ){
if(hasLeft()){
curr = (2 * curr) + 1;
}
}
template <class Item>
void binaryTreeDA<Item>::shiftRight( ){
if(hasRight());
curr = (2 * curr) + 2;
}
template <class Item>
void binaryTreeDA<Item>::shiftInd(const size_t& ind){
if((count > 0) && (ind < count)){
curr = ind;
}
}
template <class Item>
void binaryTreeDA<Item>::change(const Item& newEntry){
assert(size() > 0);
tree[curr] = newEntry;
}
template <class Item>
void binaryTreeDA<Item>::addLeft(const Item& entry){
if(!hasLeft()){
size_t addInd = (2 * curr) + 1;
tree[addInd] = entry;
count++;
}
}
template <class Item>
void binaryTreeDA<Item>::removeLeft(){
if((count > 0) && (hasLeft())){
size_t leftInd = (2 * curr) + 1;
tree[leftInd] = 0;
count--;
}
}
template <class Item>
void binaryTreeDA<Item>::addRight(const Item& entry){
if(!hasRight()){
size_t addInd = (2 * curr) + 2;
tree[addInd] = entry;
count++;
}
}
template <class Item>
void binaryTreeDA<Item>::removeRight(){
if((count > 0) && (hasRight())){
size_t rightInd = (2 * curr) + 2;
tree[rightInd] = 0;
count--;
}
}
// CONSTANT MEMBER FUNCTIONS
template <class Item>
size_t binaryTreeDA<Item>::size( ) const{
return count;
}
template <class Item>
Item binaryTreeDA<Item>::retrieve( ) const{
assert((size() > 0) && ((curr >= 0) && (curr < capacity)));
return tree[curr];
}
template <class Item>
bool binaryTreeDA<Item>::hasParent( ) const{
assert((size() > 0) && ((curr >= 0) && (curr < capacity)));
return curr != 0;
}
template <class Item>
bool binaryTreeDA<Item>::hasLeft( ) const{
assert((size() > 0) && ((curr >= 0) && (curr < capacity)));
return(2 * curr + 1) < count;
}
template <class Item>
bool binaryTreeDA<Item>::hasRight( ) const{
assert((size() > 0) && ((curr >= 0) && (curr < capacity)));
return(2 * curr + 2) < count;
}
#endif
|
7def05b9ed67f3cd6b9383d608ce168798c0cb36
|
7e38e0f067534393f0b36ca79bf4cba94d7e797a
|
/main.cpp
|
81a85f613525e8d23d2010e1a076697525c0d16e
|
[] |
no_license
|
DocX/action-bomberman
|
113346ace0a0f3c710d15cab7c919092270bcb20
|
fabdb5a6fa1999fa1479e3d199ef3e803f3e75c5
|
refs/heads/master
| 2021-03-12T23:16:08.245521
| 2014-01-19T15:07:00
| 2014-01-19T15:07:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 339
|
cpp
|
main.cpp
|
/*
ActionBomberman
Hra ve stylu bombermana s moznosti hry vice hracu a AI.
Zapoctova prace
2010, Lukas Dolezal
*/
#include <QApplication>
#include "ActionBomberman.h"
int main(int argc, char** argv)
{
QApplication app(argc, argv);
ActionBomberman *bomber = new ActionBomberman();
bomber->show();
return app.exec();
}
|
906cbc61d8ef5de3c13cb6a98a6c7f3c9b5231ac
|
a05cd145e36d1c549f894a152c5aab656b1cd186
|
/ulib/src/Datablock.cpp
|
24acbfc96194903ff3700e0567f02740f8f4b9f9
|
[
"MIT"
] |
permissive
|
enbock/Warp10Server
|
7a27db2382fab07a32f2cdf95182e705b400d3e5
|
96aae8d401b090dcacb61aad3cbadb2c78ee936b
|
refs/heads/master
| 2021-01-24T00:53:05.362146
| 2017-10-07T16:43:46
| 2017-10-07T16:43:46
| 68,477,205
| 2
| 0
| null | 2017-03-22T20:44:36
| 2016-09-17T20:44:59
|
C++
|
UTF-8
|
C++
| false
| false
| 3,522
|
cpp
|
Datablock.cpp
|
/*
* Datablock.cpp
*
* Created on: 31.03.2011
* Author: Endre Bock
*/
#include <Datablock>
using namespace u;
Datablock::Datablock() : Object()
{
}
Datablock::Datablock(Datablock & value)
{
*this = value;
}
Datablock& Datablock::operator=(Datablock& value)
{
deleteAttributes();
int64 i, l;
l = value._list.size();
for(i=0; i<l; i++)
{
saveAttribute(value._list[i]);
}
return *this;
}
void Datablock::destroy()
{
delete (Datablock*) this;
}
Datablock::~Datablock()
{
deleteAttributes();
}
void Datablock::deleteAttributes()
{
_attribute * entry;
while(!_list.empty())
{
//trace("Remove a entry.");
entry = _list.back();
deleteAttribute(entry);
entry->destroy();
}
}
String Datablock::className()
{
return "u::Datablock";
}
Datablock::_attribute & Datablock::operator[](String name)
{
int64 i,l;
_attribute *entry;
l = _list.size();
for(i=0; i<l; i++)
{
entry = _list[i];
if(entry->name == name) return *entry;
}
entry = new _attribute(name);
saveAttribute(entry);
return *entry;
}
void Datablock::saveAttribute(Datablock::_attribute *entry)
{
entry->ref.push_back(this);
_list.push_back(entry);
}
void Datablock::deleteAttribute(Datablock::_attribute *entry)
{
int64 i,l;
l=_list.size();
for(i=0; i<l; i++)
{
if(_list[i] == entry)
{
_list.erase(i);
break;
}
}
l = entry->ref.size();
for(i=0; i<l; i++)
{
if(entry->ref[i] == this)
{
entry->ref.erase(i);
break;
}
}
}
String Datablock::toString()
{
String str = "[" + className();
str += " length=" + int2string(_list.size());
str += "]";
return str;
}
Datablock::_attribute::operator Object*()
{
return (Object*)value;
}
Datablock::_attribute::operator String*()
{
return (String*)value;
}
Datablock::_attribute::operator Datablock*()
{
return (Datablock*)value;
}
Datablock::_attribute::operator int64()
{
return *((int64*)value);
}
Object *Datablock::_attribute::operator =(Object *value)
{
destroyValue();
isObject = true;
this->value = value;
//trace("Save as Object.");
return value;
}
int64 Datablock::_attribute::operator =(int64 value)
{
destroyValue();
isObject = false;
this->value = new int64();
*((int64*)this->value) = value;
return value;
}
void Datablock::_attribute::destroy()
{
if(ref.empty()) destroyValue();
//else trace("Ref not empty.");
}
void Datablock::_attribute::destroyValue()
{
if(value != null)
{
if(isObject == true)
{
//trace("Destroy object.");
if(valid((Object *)value)) ((Object*)value)->destroy();
}
else
{
//trace("Destroy a int.");
delete (int64*)value;
}
value = null;
if(_noDelete == false) delete (_attribute*)this;
}
}
u::Datablock::_attribute::_attribute(String keyName)
{
_noDelete = false;
value = null;
isObject = false;
name = keyName;
}
u::Datablock::_attribute::~_attribute()
{
_noDelete = true;
while(!ref.empty())
{
ref[0]->deleteAttribute(this);
}
}
bool u::Datablock::hasKey(String key)
{
int64 l = _list.length(), i;
for(i = 0; i < l; i++)
{
if(_list[i]->name == key) return true;
}
return false;
}
/**
* Get the list of keys.
*/
Vector<String> u::Datablock::getKeys()
{
Vector<String> result;
int length = _list.length(), i;
for(i = 0; i < length; i++)
{
result.push(_list[i]->name);
}
return result;
}
/**
* Delete a key, if the key exists.
*/
void u::Datablock::remove(String key)
{
int64 l = _list.length(), i;
for(i = 0; i < l; i++)
{
if(_list[i]->name == key) {
delete (_attribute*)_list[i];
return;
}
}
}
|
21f36068dd6d46f2c01f57a147e4189673844bf1
|
833c67af81d5519b48bb868ae785b24266bd7dcb
|
/BaekJun1753.cpp
|
ea499fae2b91a9dc10309bd39426541e7802e83c
|
[] |
no_license
|
xtream9029/algorithm
|
5a728752fdd122ba5149abfbaa9922c0960bbd3a
|
8ca068165196092181e8793a7f96f7ed508030a7
|
refs/heads/master
| 2022-11-26T23:04:23.847503
| 2020-07-30T13:12:14
| 2020-07-30T13:12:14
| 283,770,779
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,758
|
cpp
|
BaekJun1753.cpp
|
/*#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define MAX 210000000
struct node {
int a;
int b;
};
struct cmp {
bool operator()(node x, node y){
return x.b < y.b;//거리가 작은순으로 min heap에삽입
}
};
int d[20001];
vector<node> graph[20001];
int n, m;
void dijkstra_bfs(int start){
priority_queue <node, vector<node>, cmp > q;
node ins;
ins.a = start;
ins.b = 0;
q.push(ins);
while (!q.empty()) {
node cur = q.top();
q.pop();
int curNode = cur.a;
int curDis = cur.b;
for (int i = 0; i < graph[curNode].size(); i++) {
int k = graph[curNode][i].a;
if (d[k] > d[curNode] + graph[curNode][i].b) {
d[k] = d[curNode] + graph[curNode][i].b;//비용 갱신
}
}
//현재 노드에서 인접한 노드중 최소거리로 갈수 있는 노드를 우선순위 큐에 삽입 해야함
int minDis = d[graph[curNode][0].b];
int idx = -1;
for (int i = 1; i < graph[curNode].size(); i++) {
if (minDis > d[graph[curNode][i].b]) {
idx = i;
}
}
if (idx == -1){
node k;
k.a =graph[curNode][0].a;
k.b= graph[curNode][0].b;
q.push(k);
}
else {
node k;
k.a = graph[curNode][idx].a;
k.b = graph[curNode][idx].b;
q.push(k);
}
}
}
int main() {
cin >> n>>m;
int first;
cin >> first;
for (int i = 0; i < m; i++) {
int s, d, c;
cin >> s >> d >> c;
node data;
data.a = d;
data.b = c;
graph[s].push_back(data);
}
fill(d, d + 20001, MAX);
dijkstra_bfs(first);
for (int i = 1; i <= n; i++) {
if (d[i] == MAX) {
cout << "INF" << endl;
}
else {
cout << d[i] << endl;
}
}
return 0;
}*/
|
946c8a8807fb52f22ebe40313f5f59c1cc219b92
|
1d465efb639c64468fa114f3b0d602f8ab7bb865
|
/CModbus.h
|
c29c5978032c043d840e83e8ad22a52fc8b2cdac
|
[] |
no_license
|
nikshev/cmodbus
|
f5c7b480ba9e966e75db0b94edef28d8252056bc
|
1b0cbd3fd02b721d24ec48d51fe6df7478c4e5c1
|
refs/heads/master
| 2021-01-18T14:11:35.624715
| 2014-06-18T08:27:35
| 2014-06-18T08:27:35
| null | 0
| 0
| null | null | null | null |
WINDOWS-1251
|
C++
| false
| false
| 958
|
h
|
CModbus.h
|
#include <vcl.h>
class CModbus{
public:
CModbus(WORD wAddress); //Конструктор
~CModbus(); //Деструктор
WORD Connect(char *lpszPort,int nBaudeRate,
int nByteSize, int nParity, int nStopBits,
int nReadInterval);
WORD CalcCrc(UCHAR *Str,WORD NumBytes);
WORD loopback();
void CModbus::Disconnect();
WORD ReadDiscreteOutputOrCoil(WORD wAddressCoil, WORD *wResult);
WORD ReadDiscreteInput(WORD wAddressInput, WORD *wResult);
WORD ReadInputRegister(WORD wAddressInputReg, WORD *wResult);
WORD ReadHoldingRegister(WORD wAddressHoldReg, WORD *wResult);
WORD WriteSingleCoil(WORD wAddressCoil, BOOL Coil);
WORD WriteSingleRegister(WORD wAddressHoldReg, WORD wRegValue);
void FloatToHex(float Data, WORD *Result);
float HexToFloat(WORD *Data);
private:
WORD wAddress;
WORD Write(BYTE *wpData,ULONG ulWriteByte);
WORD Read(BYTE *wpData,WORD *wpResult);
};
|
652dafe924f3423ac53714a7a76c240217243de8
|
b9126df0d761987516a7146dc54887c828b893e4
|
/include/cpp_essentials/geo/matrix.hpp
|
4ffa15dc132465b6db0e2aad4ca0be20c4c807b1
|
[] |
no_license
|
volsungdenichor/cpp_essentials
|
63c979057dcb6d5cd69013ee015060b3b1a48867
|
28287ddb10362efbac5cdced6fdf66caf92b8e0d
|
refs/heads/master
| 2022-06-23T00:40:19.294054
| 2022-06-08T16:39:18
| 2022-06-08T16:39:18
| 146,165,601
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,173
|
hpp
|
matrix.hpp
|
#ifndef CPP_ESSENTIALS_GEO_MATRIX_HPP_
#define CPP_ESSENTIALS_GEO_MATRIX_HPP_
#pragma once
#include <cpp_essentials/math/matrix.hpp>
namespace cpp_essentials::geo
{
using math::matrix;
using math::square_matrix;
using math::square_matrix_2d;
using math::square_matrix_3d;
using math::vector;
using math::vector_2d;
using math::vector_3d;
using math::matrix_traits;
using math::elementwise_divide;
using math::elementwise_multiply;
using math::make_vector;
using math::as_tuple;
using math::identity;
using math::ones;
using math::zeros;
using math::get;
using math::identity;
using math::make_scale;
using math::make_rotation;
using math::make_translation;
using math::minor;
using math::determinant;
using math::is_invertible;
using math::invert;
using math::transpose;
using math::transform;
using math::dot;
using math::norm;
// using math::length;
using math::normalize;
using math::unit;
using math::clamp;
// using math::distance;
using math::cross;
// using math::projection;
using math::rejection;
// using math::perpendicular;
using math::angle;
using math::bisector;
} /* namespace cpp_essentials::geo */
#endif /* CPP_ESSENTIALS_GEO_MATRIX_HPP_ */
|
1e1ca6123cbd7f44561edfdbc108080c5c7f8828
|
b7f19d628ca8962398f530db9fb57e4de696ed89
|
/sopnet/sopnet/segments/SegmentPair.h
|
7870d273a386283e853acd783eb5294bb5e99330
|
[] |
no_license
|
thanujadax/sopnet
|
473e8316c0d7a0d13094402121c4e8647cc45359
|
e59d365c63ed68ad68eb02e007ff5023c77b174a
|
refs/heads/master
| 2020-04-05T18:56:40.001871
| 2014-10-17T12:12:59
| 2014-10-17T12:12:59
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,199
|
h
|
SegmentPair.h
|
/*
* SegmentPair.h
*
* Created on: May 13, 2014
* Author: thanuja
*/
#ifndef SOPNET_SEGMENTPAIR_H_
#define SOPNET_SEGMENTPAIR_H_
#include "Segment.h"
#include "ContinuationSegment.h"
class SegmentPair: public Segment {
public:
SegmentPair(unsigned int id, Direction direction,
boost::shared_ptr<ContinuationSegment> continuationSegment1,
boost::shared_ptr<ContinuationSegment> continuationSegment2,
boost::shared_ptr<Slice> sourceSlice,
boost::shared_ptr<Slice> midSlice,
boost::shared_ptr<Slice> targetSlice);
boost::shared_ptr<ContinuationSegment> getContinuationSegment1() const;
boost::shared_ptr<ContinuationSegment> getContinuationSegment2() const;
std::vector<boost::shared_ptr<Slice> > getSlices() const;
boost::shared_ptr<Slice> getSourceSlice() const;
boost::shared_ptr<Slice> getMidSlice() const;
boost::shared_ptr<Slice> getTargetSlice() const;
private:
boost::shared_ptr<ContinuationSegment> _continuationSegment1;
boost::shared_ptr<ContinuationSegment> _continuationSegment2;
boost::shared_ptr<Slice> _sourceSlice;
boost::shared_ptr<Slice> _midSlice;
boost::shared_ptr<Slice> _targetSlice;
};
#endif /* SOPNET_SEGMENTPAIR_H_ */
|
0864c97bc829155e4ed561852a65b0cb3635f7e4
|
50c8df32a6a58c45457d16823a081012dca0fc81
|
/PbPb_pixeltracks/HiEvtPlaneFlatten/MoveFlatParamsToDB/EPCalib/src/Loop3.h
|
e9d718399a5e14c24aa7efd027cad805071cc2e0
|
[] |
no_license
|
ssanders50/pbpb2015
|
587235c8602f98d1628a561ad0b5dc715b352af3
|
8083e5f84915160be895dbf7a3ef0d0712123ee9
|
refs/heads/master
| 2021-01-17T18:37:21.850003
| 2016-09-25T17:34:26
| 2016-09-25T17:34:26
| 68,733,554
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,076
|
h
|
Loop3.h
|
#include "TFile.h"
#include "TTree.h"
#include "TH1F.h"
#include "TH1I.h"
#include "TDirectory.h"
#include <iostream>
#include "string.h"
#include "stdio.h"
#include "EPCalib/HiEvtPlaneList.h"
#include "EPCalib/HiEvtPlaneFlatten.h"
void Loop3(){
save = fopen("tmpsave","rb");
cout<<"Loop 3:"<<endl;
ncnt = 0;
while(fread(&sout, sizeof(struct sout_struct), 1, save) >0) {
EPcent = (float) sout.cent;
EPvtx = (float) sout.vtx;
EPntrk = sout.ntrk;
EPrun = sout.run;
vtx = sout.vtx;
bin = sout.bin;
centval=sout.cent;
for(int j = 0; j<NumEPNames; j++) {
double psiOffset = -10;
double psiFlat = -10;
EPAngs[j] = -10;
if(sout.msum[j]>0) {
psiOffset = flat[j]->getOffsetPsi(sout.ws[j],sout.wc[j]);
if(centval<80 && fabs(vtx)<15&&bin>=0) {
hPsiOffset2[j]->Fill(psiOffset);
}
psiFlat = flatOffset[j]->getFlatPsi(psiOffset,vtx,bin);
EPAngs[j]=psiFlat;
if(centval<80 && fabs(vtx)<15&&bin>=0) {
hPsiFlat[j]->Fill(psiFlat);
}
}
}
++ncnt;
//if(ncnt==100) break;
EPtree->Fill();
}
}
|
8c9867d61e9421dacce4191cc0869e252ded6f64
|
107390cabe9c466c7c68a90554763b5a1699b395
|
/CppModule05/ex00/Bureaucrat.hpp
|
23e3107b85721836b050a5795cdc02f4aab7ed60
|
[] |
no_license
|
europaplus/CPP_modules
|
756d4700f99f0a16d814c637088e94b75f4370d2
|
6d7794bc70f89f8c4e5aa2f82aed78a7c40563df
|
refs/heads/master
| 2023-05-10T07:30:02.911933
| 2021-06-13T16:13:26
| 2021-06-13T16:13:26
| 376,586,094
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,899
|
hpp
|
Bureaucrat.hpp
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Bureaucrat.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: knfonda <knfonda@student.21-school.ru> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/28 15:14:52 by knfonda #+# #+# */
/* Updated: 2021/03/30 14:39:19 by knfonda ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef BUREAUCRAT_H
# define BUREAUCRAT_H
# include <iostream>
# include <string>
# include <exception>
class Bureaucrat
{
private:
const std::string _name;
int _grade;
public:
Bureaucrat(std::string name, int _grade);
virtual ~Bureaucrat();
Bureaucrat(Bureaucrat const ©);
Bureaucrat &operator=(Bureaucrat const &assign);
const std::string &getName() const;
int getGrade() const;
void incGrade();
void decGrade();
class GradeTooHighException : public std::exception
{
private:
const char *_msg;
public:
GradeTooHighException(const char *msg) : _msg(msg) {}
~GradeTooHighException() throw();
const char *what() const throw();
};
class GradeTooLowException : public std::exception
{
private:
const char *_msg;
public:
GradeTooLowException(const char *msg) : _msg(msg) {}
~GradeTooLowException() throw();
const char *what() const throw();
};
};
std::ostream &operator<<(std::ostream &out, const Bureaucrat &sp);
#endif
|
c434a582ccc69a01fe3dda12cc471e1848d60161
|
e87433ebed69640ba4666691460b507180291a90
|
/lintcode/System_Design/0530-Geohash II/0530-Geohash II.cpp
|
1df31b98a9ca64927d24797331bfc734ea1b779b
|
[
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] |
permissive
|
karolinaWu/leetcode-lintcode
|
4501ad284c4124e691cfdaaa566660edc32d672e
|
bc06cf8bd20b6e4753b9c5d5ec74d9c43a8140ee
|
refs/heads/master
| 2022-11-22T18:22:54.881897
| 2020-07-24T13:57:50
| 2020-07-24T13:57:50
| 282,246,839
| 1
| 0
|
MIT
| 2020-07-24T14:55:17
| 2020-07-24T14:55:16
| null |
UTF-8
|
C++
| false
| false
| 1,715
|
cpp
|
0530-Geohash II.cpp
|
class GeoHash {
public:
/**
* @param geohash a base32 string
* @return latitude and longitude a location coordinate pair
*/
vector<double> decode(string& geohash) {
// Write your code here
string dict = "0123456789bcdefghjkmnpqrstuvwxyz";
string num;
for (char c : geohash)
{
int val;
if (isdigit(c))
{
val = c - '0';
}
else if (c >= 'b' && c <= 'h')
{
val = c - 'b' + 10;
}
else if (c >= 'j' && c <= 'k')
{
val = c - 'j' + 17;
}
else if (c >= 'm' && c <= 'n')
{
val = c - 'm' + 19;
}
else if (c >= 'p' && c <= 'z')
{
val = c - 'p' + 21;
}
string temp;
while (temp.size() != 5)
{
temp += '0' + (val % 2);
val /= 2;
}
reverse(temp.begin(), temp.end());
num += temp;
}
vector<double> result(2);
result[0] = translate(num, -90, 90, 1);
result[1] = translate(num, -180, 180, 0);
return result;
}
private:
double translate(string& num, double start, double end, int head)
{
for (int i = head; i < num.size(); i += 2)
{
double mid = (start + end) / 2;
if (num[i] == '1')
{
start = mid;
}
else
{
end = mid;
}
}
return (start + end) / 2;
}
};
|
af5b84e4e36d01d1d799525b987e057f2b64b5f5
|
628154dcf1e1bdb61a0bb0054919b8aab305dc9a
|
/2d/kill_separates_declare_from_use/tbb/main.reference.cpp
|
9760a6cb11d1d7db693900e85bbd5fd9b17b7f9a
|
[
"MIT"
] |
permissive
|
realincubus/clang_plugin_tests
|
616b3d9a187b419bcd0d4c2c6c3ab27d291fdaef
|
018e22f37baaa7c072de8d455ad16057c953fd96
|
refs/heads/master
| 2021-01-17T10:20:40.078576
| 2018-11-28T11:11:25
| 2018-11-28T11:11:25
| 56,518,193
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 232
|
cpp
|
main.reference.cpp
|
#include <tbb/parallel_for.h>
int main(int argc, char** argv){
tbb::parallel_for (0,999 + 1,[&](int t1) {
int x = 4711;
tbb::parallel_for (0,499 + 1,[&](int t2) {
x = 9 + x ;
} );
} );
return 0;
}
|
4d6805cfcc7f1eef0e4f092d3a7890a925e1fdfd
|
ef966de26c0f233e27061828a0f9fc946f6566db
|
/3rd Party/WindowsAPICodePack/DirectX/DirectX/Direct3D10/D3D10ShaderResourceView.cpp
|
3a656b40529856d76da14feab016caef905f8372
|
[
"MIT"
] |
permissive
|
aliozgur/pragmasql
|
66fc9ff1d021acf074539c651d2f6f53e95f9fd5
|
44732dd6c8ac52950d7d6b7ba8704c0459896bf2
|
refs/heads/master
| 2020-05-31T13:36:15.044158
| 2019-01-05T17:24:27
| 2019-01-05T17:24:27
| 14,684,647
| 2
| 3
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 417
|
cpp
|
D3D10ShaderResourceView.cpp
|
// Copyright (c) Microsoft Corporation. All rights reserved.
#include "stdafx.h"
#include "D3D10ShaderResourceView.h"
using namespace Microsoft::WindowsAPICodePack::DirectX::Direct3D10;
ShaderResourceViewDescription ShaderResourceView::Description::get()
{
D3D10_SHADER_RESOURCE_VIEW_DESC desc;
GetInterface<ID3D10ShaderResourceView>()->GetDesc(&desc);
return ShaderResourceViewDescription(desc);
}
|
614aaa0e3c8bba9a7abd012504d31e5daa17e9c4
|
43df099baa0808c6be5387bafe7ec2fdfce2e311
|
/Game/AIAgentPhysicalVechicle.h
|
d1b9929f57435437480d89d685a97ec3e8630b93
|
[
"MIT"
] |
permissive
|
michalzaw/vbcpp
|
85fd59cdb8ffeef7f2031a8e3c021eb645661e44
|
c969f697e7c55027d5a5226069ac26ef99b271fd
|
refs/heads/master
| 2023-04-05T01:32:45.506125
| 2023-03-12T18:07:58
| 2023-03-12T18:07:58
| 271,097,287
| 11
| 1
|
MIT
| 2023-09-12T20:48:00
| 2020-06-09T19:58:36
|
C++
|
UTF-8
|
C++
| false
| false
| 447
|
h
|
AIAgentPhysicalVechicle.h
|
#ifndef AIAGENTPHYSICALVECHICLE_H_INCLUDED
#define AIAGENTPHYSICALVECHICLE_H_INCLUDED
#include "AIAgent.h"
class PhysicalBodyRaycastVehicle;
class AIAgentPhysicalVechicle final : public AIAgent
{
private:
PhysicalBodyRaycastVehicle* _vechicle;
glm::vec3 _centerPoint;
public:
AIAgentPhysicalVechicle(PhysicalBodyRaycastVehicle* vechicle);
void update(float deltaTime) override;
};
#endif // AIAGENTPHYSICALVECHICLE_H_INCLUDED
|
d330b225d441d3b7c7747049b91ff0f11d7e66ff
|
591d9080d81a03b54ca1666c0eeeebae9c847982
|
/Test/Oak/Platform/Thread/ThreadTest.cpp
|
03ce7ba7bd2e25828c647f323f7c02a7cdaae524
|
[
"MIT"
] |
permissive
|
n-suudai/OakPlanet
|
e939b57b0d8bea6d5123d065679cc074885fa4e9
|
fd13328ad97b87151bf3fafb00fc01440832393a
|
refs/heads/master
| 2020-04-18T05:49:03.111465
| 2020-02-29T06:40:08
| 2020-02-29T06:40:08
| 167,292,813
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,753
|
cpp
|
ThreadTest.cpp
|
#include "ThreadTest.hpp"
#include "Oak/Platform/Thread/Thread.hpp"
#include <cstdio>
using namespace Oak;
namespace ThreadTest
{
Void ShowMessage(const Char* message)
{
MessageBoxA(NULL, message, NULL, MB_OK);
}
//ウィンドウハンドル
HWND g_hwnd;
//インスタンスハンドル
HINSTANCE hinst;
//ウィンドウ横幅
const int WIDTH = 500;
const int HEIGHT = 300;
Oak::Thread* g_pThread = nullptr;
Bool g_flag = true;
UInt32 ThreadProc(Void* pArgumentBlock, SizeT argumentSize)
{
UNREFERENCED_PARAMETER(pArgumentBlock);
UNREFERENCED_PARAMETER(argumentSize);
int count = 0;
char buf[1000];
while (g_flag)
{
sprintf_s(buf, "カウント数表示 : %d", count);
SetWindowTextA(g_hwnd, buf);
++count;
Thread::Sleep(1000);
}
return 0;
}
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_CREATE:
//スレッドを作成
g_pThread = new Oak::Thread("スレッド", ThreadProc);
g_pThread->Start(nullptr, 0);
return 0;
case WM_CLOSE:
g_flag = false;
g_pThread->Wait();
delete g_pThread;
//ウィンドウを破棄
DestroyWindow(hwnd);
return 0;
}
return DefWindowProcA(hwnd, msg, wp, lp);
}
} // namespace ThreadTest
int ThreadTestMain()
{
using namespace ThreadTest;
HINSTANCE hInstance = GetModuleHandleA(NULL);
MSG msg;
WNDCLASSA wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WinProc;
wc.cbClsExtra = wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hCursor = wc.hIcon = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszClassName = "test";
wc.lpszMenuName = NULL;
if (!RegisterClassA(&wc))
{
ShowMessage("クラスの登録失敗");
return -1;
}
g_hwnd =
CreateWindowA("test", "テストウィンドウ",
WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, 0, 0,
400, 400, NULL, NULL, hInstance, NULL);
if (g_hwnd == NULL)
{
ShowMessage("ウィンドウ作成失敗");
return -1;
}
//インスタンスハンドル
hinst = hInstance;
//エラーチェック用変数
int check;
check = GetMessageA(&msg, NULL, 0, 0);
while (check)
{
check = GetMessageA(&msg, NULL, 0, 0);
if (check == -1)
{
break;
}
DispatchMessageA(&msg);
}
//クラス解放
UnregisterClassA("test", hinst);
return 0;
}
|
b5aa934cf8f4d8cce9be5709598328797b28bcac
|
40fe88c5b1e70ad31b454079b1ad41c31cb22075
|
/src/DivideSamples_v4.cc
|
7a538be35569a403386923020ef23e9163e4ee3a
|
[] |
no_license
|
dav7824/tqHGG
|
f20ebff178b7309084bb8e50dc00e147fd6e580b
|
d9a8b4ed5332330035d71b7e4015ec5211f00c04
|
refs/heads/master
| 2021-08-17T07:57:00.797168
| 2021-06-29T13:40:31
| 2021-06-29T13:40:31
| 217,187,218
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,840
|
cc
|
DivideSamples_v4.cc
|
/*
* Divide trees using tree event index.
*
* Usage:
* ./DivideSamples_v4 <fin> <vec_tree> <vec_fout>
*/
#include "include/utility.h"
#include "TString.h"
#include "TFile.h"
#include "TTree.h"
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char **argv)
{
// Command line arguments
TString fin_name = argv[1];
vector<TString> treename; ParseCStringList(argv[2], treename);
vector<TString> fout_name; ParseCStringList(argv[3], fout_name);
int ntree = treename.size();
int nfout = fout_name.size();
// Get input tree
cout << "[INFO] Openning file: " << fin_name << endl;
TFile *fin = new TFile(fin_name);
vector<TTree*> Tin;
for (int i=0; i<ntree; ++i) Tin.push_back( (TTree*)fin->Get(treename[i]) );
// Create new trees
vector<TFile*> fout(nfout);
vector<vector<TTree*>> Tout(nfout);
for (int ifout=0; ifout<nfout; ++ifout) {
fout[ifout] = new TFile(fout_name[ifout], "recreate");
vector<TTree*> Tout_(ntree);
for (int itree=0; itree<ntree; ++itree) Tout_[itree] = Tin[itree]->CloneTree(0);
Tout[ifout] = Tout_;
}
// Start event loop
for (int evt=0; evt<Tin[0]->GetEntries(); ++evt)
{
for (int itree=0; itree<ntree; ++itree) Tin[itree]->GetEntry(evt);
int ifout = evt % nfout;
for (int itree=0; itree<ntree; ++itree) Tout[ifout][itree]->Fill();
}
// end of event loop
// Save new trees
for (int ifout = 0; ifout<nfout; ++ifout) {
cout << "[INFO] Saved output file " << ifout << ": " << fout_name[ifout] << " (" << Tout[ifout][0]->GetEntries() << ")" << endl;
for (int itree=0; itree<ntree; ++itree)
fout[ifout]->WriteTObject(Tout[ifout][itree]);
fout[ifout]->Close();
}
fin->Close();
return 0;
}
|
18900c7653bc5f9ad5eae8db781aaaf6cc257c72
|
7156b6909eed95b408f399fc2ee3522d8f1be33d
|
/StarCraft/Interceptor.cpp
|
826e03acccdb5929be239465bfa0640c6cf74894
|
[] |
no_license
|
beckchul/DirectX9_2D_StarCraft
|
9cfda97a05dfb5e8619edf59b01773ed71b0238e
|
9bb3c21749efa8c1ac3d9d96509b5074a5eee416
|
refs/heads/master
| 2022-11-15T08:24:33.742964
| 2020-07-13T14:10:59
| 2020-07-13T14:10:59
| 279,316,274
| 0
| 0
| null | null | null | null |
WINDOWS-1252
|
C++
| false
| false
| 10,158
|
cpp
|
Interceptor.cpp
|
#include "stdafx.h"
#include "Interceptor.h"
#include "AttEffect.h"
#include "Factory.h"
#include "ObjMgr.h"
#include "Device.h"
#include "TextureMgr.h"
#include "TimeMgr.h"
#include "Carrier.h"
#include "Interpace.h"
#include "Effect.h"
CInterceptor::CInterceptor()
{
}
CInterceptor::~CInterceptor()
{
Release();
}
HRESULT CInterceptor::Initialize(void)
{
list<UNIT*> UnitList = ObjMgr->GetUnitList();
list<UNIT*>::iterator iter = UnitList.begin();
list<UNIT*>::iterator iter_end = UnitList.end();
lstrcpy(m_tInfo.szObjKey, L"Interceptor");
lstrcpy(m_tInfo.szStateKey, L"Normal");
lstrcpy(m_tUnitInfo.szName, L"Interceptor");
for (; iter != iter_end; ++iter)
{
if (!lstrcmp((*iter)->szName, m_tInfo.szObjKey))
{
m_tUnitInfo = (*(*iter));
break;
}
}
m_bCommand = false;
m_tUnitInfo.eType = UNIT_ARR;
m_dwState = UNIT_STAND;
m_tInfo.vSize = D3DXVECTOR3(16.f, 16.f, 0.f);
m_fSpeed = 130.f;
m_fFrameTime = 0.f;
m_iFrameCount = 0;
m_bRender = false;
m_bPattonClear = true;
m_vEndPoint = D3DXVECTOR3(0.f, 0.f, 0.f);
m_eRenderType = RENDER_AIR_UNIT;
m_bPattonAttack = false;
m_iView = 7;
m_tInfo.vPos = m_Carrier->GetPos();
return S_OK;
}
int CInterceptor::Update(void)
{
if (m_Carrier == NULL || m_Carrier->GetState() == UNIT_DEAD)
m_bDeadCheck = true;
if (m_dwState == UNIT_DEAD || m_tUnitInfo.iHp <= 0)
m_bDeadCheck = true;
CGameObject* pInterpace = ObjMgr->GetList()[OBJ_INTERPACE].front();
if (m_bDeadCheck)
{
D_CAST(CInterpace, pInterpace)->EraseUnitList(this);
if(m_Carrier != NULL && m_Carrier->GetState() != UNIT_DEAD && m_Carrier->GetUnitInfo().iHp >= 1)
D_CAST(CCarrier, m_Carrier)->InterceptorPop(this);
ObjMgr->AddGameObject(CFactory<CEffect>::CreateGameEffect(m_tInfo.vPos, EFFECT_INTERCEPTOR_DEAD), OBJ_EFFECT);
return 1;
}
if (m_bCommand)
m_bRender = true;
if (m_bRender)
{
SetAttTarget(m_Carrier->GetAttTArget());
if (m_AttTarget == NULL)
{
m_bCommand = false;
}
Function();
Cloocking();
Frame();
Move();
}
else
{
m_tInfo.vPos = m_Carrier->GetPos();
}
return 0;
}
void CInterceptor::Render(void)
{
if (!m_bRender)
return;
D3DXMATRIX matScale, matTrans;
if (m_bSelect)
{
CObjectRenderMgr::SelectUnitUIRender(this, 0, 4.f, 0, 20.f);
}
const TEX_INFO* pShuttletexture = TextureMgr->GetTexture(m_tInfo.szObjKey
, m_tInfo.szStateKey, S_INT_CAST(m_tFrame.fFrame));
D3DXMatrixScaling(&matScale, m_tInfo.vLook.x, 1.f, 0.f);
D3DXMatrixTranslation(&matTrans
, m_tInfo.vPos.x - m_vScroll.x
, m_tInfo.vPos.y - m_vScroll.y
, 0.f);
matScale *= matTrans;
float fX = pShuttletexture->ImageInfo.Width / 2.f;
float fY = pShuttletexture->ImageInfo.Height / 2.f;
if (m_eTeamType == TEAM_PLAYER)
{
Device->GetSprite()->SetTransform(&matScale);
Device->GetSprite()->Draw(pShuttletexture->pTexture
, NULL
, &D3DXVECTOR3(fX, fY, 0.f)
, NULL
, D3DCOLOR_ARGB(S_INT_CAST(255 - m_tAlphCount.fFrame), 255, 255, 255));
}
else if (m_eTeamType == TEAM_ENEMY)
{
if (m_eAlphType == ALPH_NOMAL_CLOOCKING)
{
Device->GetSprite()->SetTransform(&matScale);
Device->GetSprite()->Draw(pShuttletexture->pTexture
, NULL
, &D3DXVECTOR3(fX, fY, 0.f)
, NULL
, D3DCOLOR_ARGB(S_INT_CAST(255 - m_tAlphCount.fFrame - 85), 255, 160, 160));
}
else
{
Device->GetSprite()->SetTransform(&matScale);
Device->GetSprite()->Draw(pShuttletexture->pTexture
, NULL
, &D3DXVECTOR3(fX, fY, 0.f)
, NULL
, D3DCOLOR_ARGB(S_INT_CAST(255 - m_tAlphCount.fFrame), 255, 160, 160));
}
}
if (m_dwUnitState == UNIT_STASISFIELD && m_dwState != UNIT_DEAD)
{
const TEX_INFO* pProbetexture = TextureMgr->GetTexture(L"Effect"
, L"Frozen", S_INT_CAST(m_tStateCount.fFrame) + m_iStasis);
D3DXMatrixTranslation(&matTrans
, m_tInfo.vPos.x - m_vScroll.x
, m_tInfo.vPos.y - m_vScroll.y
, 0.f);
fX = pProbetexture->ImageInfo.Width / 2.f;
fY = pProbetexture->ImageInfo.Height / 2.f;
Device->GetSprite()->SetTransform(&matTrans);
Device->GetSprite()->Draw(pProbetexture->pTexture
, NULL
, &D3DXVECTOR3(fX, fY, 0.f)
, NULL
, D3DCOLOR_ARGB(80, 255, 255, 255));
}
}
void CInterceptor::Release(void)
{
}
void CInterceptor::Function(void)
{
if (m_dwUnitState == UNIT_STASISFIELD)
return;
if (!m_bCommand)
{
float fWidth = m_Carrier->GetPos().x - m_tInfo.vPos.x;
float fHeight = m_Carrier->GetPos().y - m_tInfo.vPos.y;
float fDistance = sqrtf((fWidth * fWidth) + (fHeight * fHeight));
float fAngle = acosf(fWidth / fDistance);
if (m_Carrier->GetPos().y < m_tInfo.vPos.y)
fAngle *= -1.f;
m_fAngle = D3DXToDegree(fAngle);
m_tInfo.vDir = m_Carrier->GetPos() - m_tInfo.vPos;
float fDist = D3DXVec3Length(&m_tInfo.vDir);
D3DXVec3Normalize(&m_tInfo.vDir, &m_tInfo.vDir);
m_tInfo.vPos += m_tInfo.vDir * 800.f * GET_TIME;
if (m_Carrier->GetState() == UNIT_STAND &&
m_Carrier->GetPos().x - m_Carrier->GetInfo().vSize.x / 2.f < m_tInfo.vPos.x &&
m_Carrier->GetPos().x + m_Carrier->GetInfo().vSize.x / 2.f > m_tInfo.vPos.x &&
m_Carrier->GetPos().y - m_Carrier->GetInfo().vSize.y / 2.f < m_tInfo.vPos.y &&
m_Carrier->GetPos().y + m_Carrier->GetInfo().vSize.y / 2.f > m_tInfo.vPos.y)
{
m_bRender = false;
m_tUnitInfo.iShield = m_tUnitInfo.iShieldMax;
m_tUnitInfo.iHp = m_tUnitInfo.iHpMax;
}
}
else
{
if (m_bPattonClear)
{
m_vEndPoint.x = (m_AttTarget->GetPos().x + rand() % 500 - 250);
m_vEndPoint.y = (m_AttTarget->GetPos().y + rand() % 500 - 250);
m_dwState = UNIT_MOVE;
m_fSpeed = S_FLOAT_CAST(230.f + rand() % 220);
m_bPattonClear = false;
m_bPattonAttack = true;
lstrcpy(m_tInfo.szStateKey, L"Normal");
}
else
{
if (m_bPattonAttack &&
fabs(m_tInfo.vPos.x - m_AttTarget->GetPos().x) < 50.f &&
fabs(m_tInfo.vPos.y - m_AttTarget->GetPos().y) < 50.f)
{
SoundMgr->PlaySound(L"phohit00.wav", CHANNEL_EFFECT_ATT4, 0.5f, m_tInfo.vPos);
m_bPattonAttack = false;
ObjMgr->AddGameObject(CFactory<CAttEffect>::CreateGameUnitEffectTarget(m_tInfo.vPos, EFFECT_INTERCEPTOR_ATT, m_AttTarget, m_tUnitInfo), OBJ_EFFECT);
lstrcpy(m_tInfo.szStateKey, L"Att");
}
}
}
}
void CInterceptor::Cloocking(void)
{
list<CGameObject*> pUnitList = ObjMgr->GetList()[OBJ_UNIT];
list<CGameObject*> pBuildList = ObjMgr->GetList()[OBJ_BUILD];
CDistanceMgr::CheckNoamlCloking(this, pUnitList);
CDistanceMgr::CheckCloking(this, pUnitList, pBuildList);
if ((m_eAlphType == ALPH_NOMAL_CLOOCKING || m_eAlphType == LOOK_ALPH_NOMAL_CLOOCKING) && m_tAlphCount.fFrame < m_tAlphCount.fMax)
{
m_tAlphCount.fFrame += m_tAlphCount.fCount * GET_TIME;
if (m_tAlphCount.fFrame >= m_tAlphCount.fMax)
{
m_tAlphCount.fFrame = m_tAlphCount.fMax;
}
}
else if (m_eAlphType == ALPH_NOMAL && m_tAlphCount.fFrame > 0)
{
m_tAlphCount.fFrame -= m_tAlphCount.fCount * GET_TIME;
if (m_tAlphCount.fFrame <= 0)
{
m_tAlphCount.fFrame = 0;
}
}
}
void CInterceptor::Frame(void)
{
if (m_fAngle < -168.75 || m_fAngle > 168.75)
{
m_tFrame = FRAME(8.f, 5.f, 9.f);
m_tInfo.vLook.x = -1;
}
else if (m_fAngle >= -168.75 && m_fAngle < -146.25)
{
m_tFrame = FRAME(6.f, 5.f, 7.f);
m_tInfo.vLook.x = -1;
}
else if (m_fAngle >= -146.25 && m_fAngle < -123.75)
{
m_tFrame = FRAME(4.f, 5.f, 5.f);
m_tInfo.vLook.x = -1;
}
else if (m_fAngle >= -123.75 && m_fAngle < -101.25)
{
m_tFrame = FRAME(2.f, 5.f, 3.f);
m_tInfo.vLook.x = -1;
}
else if (m_fAngle >= -101.25 && m_fAngle < -78.75)
{
m_tFrame = FRAME(0.f, 5.f, 1.f);
m_tInfo.vLook.x = 1;
}
else if (m_fAngle >= -78.75 && m_fAngle < -56.25)
{
m_tFrame = FRAME(2.f, 5.f, 3.f);
m_tInfo.vLook.x = 1;
}
else if (m_fAngle >= -56.25 && m_fAngle < -33.75)
{
m_tFrame = FRAME(4.f, 5.f, 5.f);
m_tInfo.vLook.x = 1;
}
else if (m_fAngle >= -33.75 && m_fAngle < -11.25)
{
m_tFrame = FRAME(6.f, 5.f, 7.f);
m_tInfo.vLook.x = 1;
}
else if (m_fAngle >= -11.25 && m_fAngle < 11.25)
{
m_tFrame = FRAME(8.f, 5.f, 9.f);
m_tInfo.vLook.x = 1;
}
else if (m_fAngle >= 11.25 && m_fAngle < 33.75)
{
m_tFrame = FRAME(10.f, 5.f, 11.f);
m_tInfo.vLook.x = 1;
}
else if (m_fAngle >= 33.75 && m_fAngle < 56.25)
{
m_tFrame = FRAME(12.f, 5.f, 13.f);
m_tInfo.vLook.x = 1;
}
else if (m_fAngle >= 56.25 && m_fAngle < 78.75)
{
m_tFrame = FRAME(14.f, 5.f, 15.f);
m_tInfo.vLook.x = 1;
}
else if (m_fAngle >= 78.75 && m_fAngle < 101.25)
{
m_tFrame = FRAME(16.f, 5.f, 16.f);
m_tInfo.vLook.x = 1;
}
else if (m_fAngle >= 101.25 && m_fAngle < 123.75)
{
m_tFrame = FRAME(14.f, 5.f, 15.f);
m_tInfo.vLook.x = -1;
}
else if (m_fAngle >= 123.75 && m_fAngle < 146.25)
{
m_tFrame = FRAME(12.f, 5.f, 13.f);
m_tInfo.vLook.x = -1;
}
else if (m_fAngle >= 146.25 && m_fAngle < 168.75)
{
m_tFrame = FRAME(10.f, 5.f, 11.f);
m_tInfo.vLook.x = -1;
}
if (m_dwUnitState == UNIT_STASISFIELD)
{
m_fStateCount += GET_TIME * m_tStateCount.fCount;
m_AttTarget = NULL;
m_bUnitAtt = false;
m_dwState = UNIT_STAND;
m_dwSubState = UNIT_STAND;
if (m_fStateCount >= 1.f)
{
m_fStateCount = 0.f;
++m_iStateCount;
if (m_iStasis < 12)
++m_iStasis;
if (m_dwUnitState == UNIT_STASISFIELD)
{
if (m_tStateCount.fFrame + m_iStateCount >= (m_tStateCount.fMax / 2))
{
m_iStateCount = 0;
--m_iStateTime;
}
}
}
if (m_iStateTime <= 0)
{
m_iStasis = 0;
m_dwUnitState = UNIT_NORMAL;
}
}
}
void CInterceptor::Move(void)
{
if (m_dwState != UNIT_MOVE || m_dwUnitState == UNIT_STASISFIELD)
return;
float fWidth = m_vEndPoint.x - m_tInfo.vPos.x;
float fHeight = m_vEndPoint.y - m_tInfo.vPos.y;
float fDistance = sqrtf((fWidth * fWidth) + (fHeight * fHeight));
float fAngle = acosf(fWidth / fDistance);
if (m_vEndPoint.y < m_tInfo.vPos.y)
fAngle *= -1.f;
m_fAngle = D3DXToDegree(fAngle);
//¹æÇâ
m_tInfo.vDir = m_vEndPoint - m_tInfo.vPos;
float fDist = D3DXVec3Length(&m_tInfo.vDir);
D3DXVec3Normalize(&m_tInfo.vDir, &m_tInfo.vDir);
m_tInfo.vPos += m_tInfo.vDir * m_fSpeed * GET_TIME;
if (fabs(m_vEndPoint.x - m_tInfo.vPos.x) < 4 && fabs(m_vEndPoint.y - m_tInfo.vPos.y) < 4)
{
m_bPattonClear = true;
}
}
|
b112f50d51fece09f2ee2cdedb3222d4c7d7562c
|
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
|
/app/src/main/cpp/dir7941/dir7942/dir8062/dir8063/dir12766/dir12767/dir13029/dir15097/dir15260/dir15321/dir17820/file17864.cpp
|
975833c970360a97e3ede75794b05dc3a0d0cd92
|
[] |
no_license
|
tgeng/HugeProject
|
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
|
4488d3b765e8827636ce5e878baacdf388710ef2
|
refs/heads/master
| 2022-08-21T16:58:54.161627
| 2020-05-28T01:54:03
| 2020-05-28T01:54:03
| 267,468,475
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 115
|
cpp
|
file17864.cpp
|
#ifndef file17864
#error "macro file17864 must be defined"
#endif
static const char* file17864String = "file17864";
|
91771ef49d38dc6b5ae355d183f9ef7c8cfbeef6
|
c2277ca02a9c9b3c2d2fd99dd952addf7eb656bf
|
/rbuffer.tpp
|
b28eb44899e4dafe49875161e091fbf8b6e6f66a
|
[
"BSD-3-Clause"
] |
permissive
|
heliosfa/Generics
|
602f55ad80f7261f45b1293a5d014933cd0b0545
|
82c82f25dc68159c8bb2e158d2e486e08e13f20d
|
refs/heads/master
| 2021-02-26T01:35:04.609885
| 2020-03-09T22:56:12
| 2020-03-09T22:56:12
| 245,484,153
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,670
|
tpp
|
rbuffer.tpp
|
//------------------------------------------------------------------------------
#include <typeinfo>
#include <stdio.h>
#include <iostream.h>
#include "macros.h"
#include "flat.h"
#include "e.h"
//==============================================================================
RBuffer::RBuffer()
// Build the whole thing from nothing
{
}
//------------------------------------------------------------------------------
RBuffer::RBuffer(string s)
// Restore constructor
{
name = s; // Source file name
FILE * fp = fopen(s.c_str(),"rb"); // Open the binary file
if (fp==0) throw(E(__FILE__,__LINE__));// It wasn't there!
Header H(fp); // Pull in the header
char Rtype;
fread(&Rtype,1,1,fp); // Record type
if (Rtype!=0x74) throw(E(__FILE__,__LINE__)); // Not for me
unsigned bits; // Ensure the 32/64 environments match
fread(&bits,SUINT,1,fp);
if (bits!=sizeof(void *)*8) throw(E(__FILE__,__LINE__));
unsigned _suint; // Ensure the unsigned sizes match
fread(&_suint,SUINT,1,fp);
if (SUINT!=_suint) throw(E(__FILE__,__LINE__));
freadstr(name,fp); // Object name as written
unsigned nbuf;
fread(&nbuf,SUINT,1,fp); // Buffer count
for(unsigned i=0;i<nbuf;i++) { // Loop to pull in each buffer
string sBuf;
freadstr(sBuf,fp); // Buffer name
m_R[sBuf] = new _R(fp); // Whack it directly into the map
}
unsigned banksiz; // Size of string bank (can be 0)
fread(&banksiz,SUINT,1,fp); // Stringbank contents
for (unsigned i=0;i<banksiz;i++) {
string s;
freadstr(s,fp);
strbank.push_back(s);
}
fread(&Rtype,1,1,fp); // Closing record
if (Rtype!=0x7d) throw(E(__FILE__,__LINE__));
fclose(fp); // And go, happy bunnies all round
}
//------------------------------------------------------------------------------
RBuffer::~RBuffer(void)
{
// Walk top-level map; kill each buffer
WALKMAP(string,_R *,m_R,i) delete (*i).second;
}
//------------------------------------------------------------------------------
void RBuffer::Dump(string s)
{
printf("\n++------------------\n");
printf("\nResults Buffer object %s\n",name.c_str());
WALKMAP(string,_R *,m_R,i) {
void * hBuff = GetBufferHandle((*i).first);
printf("Buffer: %s, handle: %#0x\n",(*i).first.c_str(),hBuff);
WALKMAP(string,_B *,(*i).second->m_B,j) {
printf(" Line: %s, handle: %#0x",
(*j).first.c_str(),GetLineHandle(hBuff,(*j).first));
printf(" %u bytes, %u items, size %u, \n type %s\n",
(*j).second->_data.size(),(*j).second->_size(),(*j).second->_sizeof,
(*j).second->_type.c_str());
HexDump(stdout,&((*j).second->_data[0]),(*j).second->_data.size());
}
}
printf("String bank (%u entries)\n",strbank.size());
unsigned cnt = 0;
WALKVECTOR(string,strbank,i) printf("%4u : ||%s||\n",cnt++,(*i).c_str());
printf("--------------------\n");
}
//------------------------------------------------------------------------------
string RBuffer::Get(void * _,unsigned i)
// Pull out a single data item from the line handle "_", offset "i"
{
_B * p_B = static_cast<_B *>(_); // Decode the handle
if (p_B==0) throw(E(__FILE__,__LINE__));
i *= p_B->_sizeof; // Get byte address
unsigned buff; // Somewhere to put it
memcpy(&buff,&(p_B->_data[i]),p_B->_sizeof);
return strbank[buff]; // And get the data
}
//------------------------------------------------------------------------------
template<typename T> T RBuffer::Get(void * _,unsigned i)
// Pull out a single data item from the line handle "_", offset "i"
{
_B * p_B = static_cast<_B *>(_); // Decode the handle
if (p_B==0) throw(E(__FILE__,__LINE__));
i *= p_B->_sizeof; // Get byte address
T buff; // Somewhere to put it
memcpy(&buff,&(p_B->_data[i]),p_B->_sizeof);
return buff; // And get the data
}
//------------------------------------------------------------------------------
void * RBuffer::GetBufferHandle(string name)
// Given an existing buffer name, find the handle - if any
{
// Not there?
if (m_R.find(name)==m_R.end()) return (void *)0;
return static_cast<void *>(m_R[name]); // Found it
}
//------------------------------------------------------------------------------
void * RBuffer::GetLineHandle(void * hBuff,string name)
// Given an existing buffer handle and line name, find the handle - if any
{
if (hBuff==0) return (void *)0; // No buffer, then
_R * pBuff = static_cast<_R *>(hBuff);
if (pBuff->m_B.find(name)!=pBuff->m_B.end()) // Found it!
return static_cast<void *>(pBuff->m_B[name]);
return (void *)0; // Not there
}
//------------------------------------------------------------------------------
unsigned RBuffer::Lines(void * _)
// Return the number of lines in a given buffer
{
if (_==0) return 0; // No buffer
_R * p_R = static_cast<_R *>(_); // Get buffer handle
return p_R->m_B.size();
}
//------------------------------------------------------------------------------
void * RBuffer::MakeBuffer(string n)
// Create a new (named) buffer and return the handle
{
_R * p_R = new _R; // Create it
m_R[n] = p_R; // Load the map
return (void *) p_R; // Return the handle
}
//------------------------------------------------------------------------------
void * RBuffer::MakeLine(void * _,string n)
// Create a new data line (called "n") in the buffer with handle "_", return
// the line handle
{
if (_==0) throw(E(__FILE__,__LINE__));
_R * p_R = static_cast<_R *>(_); // Find the buffer
_B * p_B = new _B(); // Build a new line
p_R->m_B[n] = p_B; // Add line to buffer
return (void *) p_B; // Return line handle
}
//------------------------------------------------------------------------------
string RBuffer::Name()
// Return the object name
{
return name;
}
//------------------------------------------------------------------------------
void RBuffer::Name(string n)
// Set the object name
{
name = n;
}
//------------------------------------------------------------------------------
unsigned RBuffer::Put(void * _,string v)
// Insert a data item (v) into line handle "_". This is a special case of the
// template below, because we have to pull the string data on the heap (the
// actual string) out separately. The string (for all lines) goes into the
// object-wide stringbank, and the offset in the bank is stored as the line data
{
if(_==0) throw(E(__FILE__,__LINE__)); // No line?
_B * p_B = static_cast<_B *>(_); // Get line handle
if (p_B->_type.empty()) { // We don't know the type name yet
p_B->_type = typeid(string).name(); // So set it
p_B->_sizeof = SUINT; // Type size (offset in stringbank)
}
// We do know it, and it's inconsistent
if (typeid(string).name()!=p_B->_type) throw(E(__FILE__,__LINE__));
byte buff[SUINT];
strbank.push_back(v); // Store the string data itself
unsigned adr = strbank.size()-1; // Address in stringbank
memcpy(&buff[0],&adr,SUINT); // Stringbank offset for main buffer
for (unsigned i=0;i<SUINT;i++) p_B->_data.push_back(buff[i]);
return p_B->_size()-1; // Return the storage offset
}
//------------------------------------------------------------------------------
template<typename T> unsigned RBuffer::Put(void * _,T v)
// Insert a data item (v) into line handle "_"
// I have no idea why I have to copy from the incoming to a temporary, and from
// that to the store. I get access violations if I try to go direct.
{
if(_==0) throw(E(__FILE__,__LINE__)); // No line?
_B * p_B = static_cast<_B *>(_); // Get line handle
if (p_B->_type.empty()) { // We don't know the type name yet
p_B->_type = typeid(T).name(); // So set it
p_B->_sizeof = sizeof(T); // And the type size
}
// We do know it, and it's inconsistent
if (typeid(T).name()!=p_B->_type) throw(E(__FILE__,__LINE__));
const unsigned BUF = 1024;
byte buff[BUF]; // Stack buffer
byte * pbuff = &buff[0]; // Start of....
// Use heap instead?
if (p_B->_sizeof>=BUF) pbuff = (byte *) new byte[p_B->_sizeof];
memcpy(&buff[0],&v,p_B->_sizeof); // Copy incoming data to buffer
// And copy this to the store
for (unsigned i=0;i<p_B->_sizeof;i++) p_B->_data.push_back(buff[i]);
if (pbuff!=&buff[0]) delete [] pbuff; // Kill the heap buffer (if any)
return p_B->_size()-1; // Return the storage offset
}
//------------------------------------------------------------------------------
void RBuffer::Save(string fname)
// Save the entire object to the file "fname"
{
Header H; // Housekeeping.....
H.Name(fname);
FILE * fp = fopen(fname.c_str(),"wb"); // Open the save file
H.SaveB(fp); // Save the header
char Rtype = 0x74;
fwrite(&Rtype,1,1,fp); // Record type
unsigned bits = sizeof(void *) * 8; // 32/64 bit land?
fwrite(&bits,SUINT,1,fp);
fwrite(&SUINT,SUINT,1,fp); // Sizeof unsigned
fwritestr(name,fp); // Object name
unsigned nbuf = m_R.size();
fwrite(&nbuf,SUINT,1,fp); // Number of buffers to come
WALKMAP(string,_R *,m_R,i) // Write each buffer
(*i).second->SaveB(fp,(*i).first);
unsigned banksiz = strbank.size(); // Size of string bank (can be 0)
fwrite(&banksiz,SUINT,1,fp); // Stringbank contents
WALKVECTOR(string,strbank,i) fwritestr(*i,fp);
Rtype = 0x7d; // EOF
fwrite(&Rtype,1,1,fp);
fclose(fp);
}
//------------------------------------------------------------------------------
unsigned RBuffer::Size(void * _)
// Return number of data items (NOT bytes) in the line "_"
{
if (_==0) return 0; // Silly question
_B * p_B = static_cast<_B *>(_); // Get line handle
if (p_B->_sizeof==0) return 0; // Type not committed yet
return p_B->_data.size()/p_B->_sizeof; // sum(bytes)/size(item)
}
//------------------------------------------------------------------------------
unsigned RBuffer::Sizeof(void * _)
// Return the size of the data items in a line
{
if (_==0) return 0; // Get line handle
_B * p_B = static_cast<_B *>(_);
return p_B->_sizeof; // And answer the question
}
//==============================================================================
RBuffer::_R::_R()
// Buffer vanilla constructor
{
}
//------------------------------------------------------------------------------
RBuffer::_R::_R(FILE * fp)
// Reconstruct buffer from binary save
{
unsigned nlines;
fread(&nlines,SUINT,1,fp); // Number of lines in the buffer
for(unsigned i=0;i<nlines;i++) {
string name; // Line name
freadstr(name,fp);
m_B[name]= new _B(fp); // And the line itself
}
}
//------------------------------------------------------------------------------
RBuffer::_R::~_R()
// Kill all the lines in the buffer
{
WALKMAP(string,_B *,m_B,i) delete (*i).second;
}
//------------------------------------------------------------------------------
void RBuffer::_R::SaveB(FILE * fp,string name)
// Save the line to an open file
{
fwritestr(name,fp); // Buffer name
unsigned nline = m_B.size(); // Number of lines in the buffer
fwrite(&nline,SUINT,1,fp);
// And write the lines
WALKMAP(string,_B *,m_B,i) (*i).second->SaveB(fp,(*i).first);
}
//==============================================================================
RBuffer::_B::_B()
// Build an empty line
{
_sizeof = 0;
}
//------------------------------------------------------------------------------
RBuffer::_B::_B(FILE * fp)
// Restore from a binary save
{
freadstr(_type,fp); // Line data type name
fread(&_sizeof,SUINT,1,fp); // Size of each data item
unsigned size;
fread(&size,SUINT,1,fp); // Number of bytes
byte buff;
for (unsigned i=0;i<size;i++) { // Pull in the byte stream
fread(&buff,1,1,fp);
_data.push_back(buff);
}
}
//------------------------------------------------------------------------------
RBuffer::_B::~_B()
{
}
//------------------------------------------------------------------------------
unsigned RBuffer::_B::_size()
// Number of user-defined items in the data store
{
if (_data.empty()) return 0; // Nothing there at all
return _data.size()/_sizeof; // Do the sums
}
//------------------------------------------------------------------------------
void RBuffer::_B::SaveB(FILE * fp,string name)
// Save the line as a byte stream to an open file
{
fwritestr(name,fp); // Line name
fwritestr(_type,fp); // Line data type name
fwrite(&_sizeof,SUINT,1,fp); // Size of each data item
unsigned size = _data.size();
fwrite(&size,SUINT,1,fp); // Number of bytes to come
fwrite(&_data[0],1,size,fp); // And.... plop.
}
//==============================================================================
|
6264d35cbe97f7ec1742077df939262e34d482fa
|
eea4fc1902d4462621d680052f0dca1203ef75de
|
/Trine/Jogo.h
|
d9e797514dfa7af7216a77c23e8f7ae04bfa8a14
|
[] |
no_license
|
vit090/Trine-C-
|
b7dd84c03a84b18300c3426a6fc35989fe31d04d
|
e2eaf5d7d78c0e0d49448695319dac8299b8388b
|
refs/heads/master
| 2020-03-28T16:32:28.712591
| 2018-10-04T17:35:58
| 2018-10-04T17:35:58
| 148,705,845
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 391
|
h
|
Jogo.h
|
#pragma once
#include "libUnicornio.h"
#include<fstream>
#include"Mago.h"
#include"Guerreiro.h"
#include"Ladrao.h"
#include"CarregadordeAssets.h"
class Jogo
{
public:
Jogo();
~Jogo();
void inicializar();
void finalizar();
void executar();
protected:
Personagem* classe[3];
fstream mapa_assets;
int select;
TileMap mapa;
Vetor2D posicao;
BolaDeFogo* bola = new BolaDeFogo;
};
|
1e407746e1017124a6f73f3d82c2b5d00c093f06
|
1cab6b27a0a68cc738e80ed0a90b9a45a1729aaa
|
/soa_sample_app/interface_20JUN16/interfacewindow.cpp
|
3e1aaf7d64944933ac8495c712096a3acd1daabc
|
[] |
no_license
|
mhaque3/soa_interface
|
585c602539a93957f2e93de18f5a511a1c38c9b4
|
275beb3cdd18da4619778b8f807e123c17360809
|
refs/heads/master
| 2021-01-20T07:03:19.532912
| 2017-08-18T12:21:08
| 2017-08-18T12:21:08
| 89,953,515
| 0
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,145
|
cpp
|
interfacewindow.cpp
|
// interfacewindow.cpp
//
// Created by Musad Haque
// 2016
#include "interfacewindow.h"
#include "ui_interfacewindow.h"
#include "borderlayout.h"
#include <QTabWidget>
InterfaceWindow::InterfaceWindow(QWidget * parent) :
QWidget(parent)
{
QString file = "../build/SampleAutonomy";
/*
* The JS scripts to place icons through the
* Google Maps API lives in
* ~/Downloads/soa_sample_app/blarg2/mapWidget/Scripts/RVA_derived.htm
*/
m_pLogicWidget = new LogicWidget(this);
m_pLogicWidget->setFileName("./Scripts/RVA_derived.htm"); //right click file to edit
//Map area dimensions
m_pLogicWidget->setMinimumHeight(800);
m_pLogicWidget->setMinimumWidth(1000);
//m_pTabPanelWidget = new TabPanelWidget(this);
m_pTabPanel2 = new TabPanel2(this);
m_pTabPanel2->setMinimumHeight(800);
m_pTaskPanelWidget = new TaskPanelWidget(this);
//m_pTaskPanelWidget->setMaximumHeight(300);
//Operator interface dimensions, layout, title, and icon
BorderLayout * layout = new BorderLayout;
layout->addWidget(m_pLogicWidget, BorderLayout::Center);
//layout->addWidget(m_pTabPanelWidget, BorderLayout::East);
layout->addWidget(m_pTabPanel2, BorderLayout::East);
layout->addWidget(m_pTaskPanelWidget, BorderLayout::South);
setLayout(layout);
setWindowTitle(tr("SOA Operator Interface"));
setWindowIcon(QIcon("maria2.png"));
//Connections between the three widgets are made here.
//Connect TaskPanelWidget's taskShapeAndColor to LogicWidget's enableTaskDraw informing about color and shape for task
connect(m_pTaskPanelWidget, SIGNAL(taskShapeAndColor(QString, QString)), m_pLogicWidget, SLOT(enableTaskDraw(QString, QString)));
//Connect LogicWidget's coordinates recvd from JS to taskPanelWidget's mapCoordFromJS
connect(m_pLogicWidget, SIGNAL(actuallySendCoord(QString)), m_pTaskPanelWidget, SLOT(mapCoordFromJS(QString)));
//regionTasking *** *** ***
/*
* *************
*
* If scripting for video use two connects:
* v1 and v2
* comment out nv1, nv2, nv3
*
* If not scripting use three connects:
* nv1, nv2, and nv3
* comment out v1, v2
*
* Not elegant on purpose.
*
* *************
*/
//nv1, nv2, nv3:
//connect(m_pTaskPanelWidget, SIGNAL(sendTaskInfo(taskInfo*)), m_pLogicWidget, SIGNAL(commitTask(taskInfo*))); //nv1
//connect(m_pTaskPanelWidget, SIGNAL(sendTaskInfo(taskInfo*)), m_pLogicWidget, SLOT(taskSOA(taskInfo*))); //nv2
//connect(m_pTaskPanelWidget, SIGNAL(sendTaskInfo(taskInfo*)), m_pTabPanel2, SLOT(addTask(taskInfo*))); //nv3
//v1, v2:
connect(m_pTaskPanelWidget, SIGNAL(sendTaskInfo(taskInfo*)), m_pLogicWidget, SLOT(tasksForVideo(taskInfo*))); //v1
connect(m_pLogicWidget, SIGNAL(commitTask(taskInfo*)), m_pTabPanel2, SLOT(addTask(taskInfo*))); //v2
//endRegionTasking *** *** ***
//logicWindow's endTask informs tabPanel2 that task has ended
connect(m_pLogicWidget, SIGNAL(endTask(int)), m_pTabPanel2, SLOT(endTask(int)));
}
void InterfaceWindow::debug(QString msg){
qDebug()<<msg;
}
|
e3f768a793956c611119f99cc187029adfa32630
|
dae70ba33a64f30e65367e5f95f13965fe89558c
|
/20190805/add.h
|
f686cae36a3269a9c73b106a80a407b6fa15303c
|
[] |
no_license
|
stz91/wangdaoC-
|
23b2e213a6361574a5d695b5f62a4fa5ac2c1ba3
|
2e4025523cbd4c636cb74231ede5a15e98b006c9
|
refs/heads/master
| 2020-06-25T03:16:54.927041
| 2019-08-16T09:47:05
| 2019-08-16T09:47:05
| 199,183,297
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 287
|
h
|
add.h
|
#pragma once
#include <iostream>
//使用模板时,要看到其所有的实现,不能仅仅只是一部分
//
//所以一般情况下,不会将模板分为头文件和实现文件
//
//c++的头文件没有.h的后缀
template<class T>
T add(T x, T y);
#if 0
#include "add.cc"
#endif
|
a925230e2409f07c9ba646c9d6f6bed09b38c427
|
a4dd2559b211ed9e06796749b3cda6fca1784f2c
|
/LearningMPI/mpi_cmd.cpp
|
e71f78ee41defdc1b55993f28954af011fba02e5
|
[] |
no_license
|
wenleix/Playground
|
6947f43c22c556567bbd5de35f6e86118d68a427
|
fd36886bcc6814535c231b91c0de7fbdd2a456f7
|
refs/heads/master
| 2020-04-11T16:45:13.614947
| 2015-11-25T22:00:10
| 2015-11-25T22:00:10
| 6,528,239
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 478
|
cpp
|
mpi_cmd.cpp
|
// Test the command-line input for MPI
#include <mpi.h>
#include <cstdio>
using namespace std;
int main(int argc, char** argv) {
MPI::Init(argc, argv);
int worldSize = MPI::COMM_WORLD.Get_size();
int worldRank = MPI::COMM_WORLD.Get_rank();
fprintf(stderr, "Process %d has %d parameters.\n", worldRank, argc);
for (int i = 0; i < argc; i++) {
fprintf(stderr, "Process %d, parameter %d: %s\n", worldRank, i, argv[i]);
}
MPI::Finalize();
}
|
6c624aa87766995f3890b016991794e8cfda71e2
|
9472b09dc918f82fa3e1796803f9430c3bee493c
|
/2-COLAS Y MONTÍCULOS/VolandoDroness/VolandoDroness/VoladoDrones.cpp
|
ea10196128c2bbdc987e90ee0e0b1094e70c7391
|
[] |
no_license
|
merchf/tais
|
9a0b16f56a5187f74693b0fbfea2f9deca753017
|
e8ff18bae64c15f1880e0b8f71b1a52c21826dfd
|
refs/heads/master
| 2023-02-20T00:15:33.105297
| 2021-01-10T18:31:29
| 2021-01-10T18:31:29
| 301,706,529
| 0
| 0
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 2,547
|
cpp
|
VoladoDrones.cpp
|
// Mercedes Herrero Fernandez
// Comentario general sobre la solución,
// explicando cómo se resuelve el problema
#include <iostream>
#include <fstream>
#include <vector>
#include "PriorityQueue.h" // propios o los de las estructuras de datos de clase
using namespace std;
// resuelve un caso de prueba, leyendo de la entrada la
// configuración, y escribiendo la respuesta
bool resuelveCaso() {
// leer los datos de la entrada
int numDrones, A, B, dato;
cin >> numDrones >> A >> B;
if (!std::cin) // fin de la entrada
return false;
PriorityQueue<int, greater<>> colaA;
PriorityQueue<int, greater<>> colaB;
for (int i = 0; i < A; i++)
{
cin >> dato;
colaA.push(dato);
}
for (int i = 0; i < B; i++)
{
cin >> dato;
colaB.push(dato);
}
// escribir sol
while (!colaA.empty() && !colaB.empty()) {
int horasVuelo = 0;
int cont = 0;
vector<int> pilasUsadasA, pilasUsadasB; // hay que ir almacenando las usadas para evitar volverlas a coger
while (!colaA.empty() && !colaB.empty() && cont < numDrones) {
int cargaPilaA = colaA.top();
colaA.pop();
int cargaPilaB = colaB.top();
colaB.pop();
// estará volando el tiempo de la pila que menos carga tenga
int min = std::min(cargaPilaA, cargaPilaB);
horasVuelo += min;
// restamos el tiempo que ha estado volando a las cargas de las pilas
cargaPilaA -= min;
cargaPilaB -= min;
if (cargaPilaA != 0) {
pilasUsadasA.push_back(cargaPilaA);
}
if (cargaPilaB != 0) {
pilasUsadasB.push_back(cargaPilaB);
}
cont++;
}
/*una vez volvemos a club guardamos las pilas que aun tienen carga */
for (int i = 0; i < pilasUsadasA.size(); i++)
{
colaA.push(pilasUsadasA[i]);
}
for (int i = 0; i < pilasUsadasB.size(); i++)
{
colaB.push(pilasUsadasB[i]);
}
cout << horasVuelo << " ";
}
cout << '\n';
return true;
}
int main() {
// ajustes para que cin extraiga directamente de un fichero
#ifndef DOMJUDGE
std::ifstream in("casos.txt");
auto cinbuf = std::cin.rdbuf(in.rdbuf());
#endif
while (resuelveCaso());
// para dejar todo como estaba al principio
#ifndef DOMJUDGE
std::cin.rdbuf(cinbuf);
system("PAUSE");
#endif
return 0;
}
|
6b800f96a5bca2fb1effd3b14757171278090bd5
|
f6baa8402f034d886bcde23503bcae7e0d817524
|
/src/Game.cpp
|
61ed024e250b16bedc2f784a37b02fb1030f85ba
|
[] |
no_license
|
tuomt/tower-defense
|
72eff44f724955431464b43f92175a93c57db15b
|
169f99bda86ee587b13c7b381877177f8ba3d135
|
refs/heads/master
| 2023-08-01T00:55:06.325366
| 2021-09-14T20:42:43
| 2021-09-14T20:42:43
| 371,126,767
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 16,288
|
cpp
|
Game.cpp
|
#include <fstream>
#include "Game.h"
#include "Helper.h"
#include "TextureManager.h"
#include "CollisionHandler.h"
#include "SceneManager.h"
#include "Debug.h"
using namespace Helper;
Game::Game(sf::RenderWindow& window)
: Scene(window), m_shop((loadAttributes(), m_towerAttributes), m_font, m_money)
{
m_window.setKeyRepeatEnabled(false);
// Load font
if (!m_font.loadFromFile(DEFAULT_FONT_PATH))
return;
// Position healthbar
m_healthBar.setPosition(m_window.getSize().x - 210.f, m_window.getSize().y - 110.f);
// Configure texts
m_roundText.setFont(m_font);
m_roundText.setCharacterSize(20);
m_roundText.setPosition(5.f, 5.f);
m_roundText.setOutlineColor(sf::Color::Black);
m_roundText.setOutlineThickness(1.f);
m_roundText.setString("Round: ");
m_moneyText.setFont(m_font);
m_moneyText.setCharacterSize(20);
m_moneyText.setPosition(m_healthBar.getPosition().x, m_healthBar.getPosition().y + m_healthBar.getSize().y + 10.f);
m_moneyText.setOutlineColor(sf::Color::Black);
m_moneyText.setOutlineThickness(1.f);
// Load map and textures
auto& textureManager = TextureManager::getInstance();
loadTextures();
loadMap("level_1");
//loadAttributes(); // Must be loaded before textures
m_mapSprite.setTexture(textureManager.getTexture("background"));
//m_shop.setAttributes(m_towerAttributes);
m_shop.init(m_window);
setMoney(250);
// Debug text
debugText.setFont(m_font);
debugText.setCharacterSize(20);
debugText.setPosition(10.f, 50.f);
}
Game::~Game()
{
unloadTextures();
}
void Game::handleInput(sf::Event& event, float dt)
{
if (event.type == sf::Event::KeyPressed) {
if (event.key.code == sf::Keyboard::Escape) {
SceneManager::getInstance().quit();
}
else if (event.key.code == sf::Keyboard::D) {
m_showDebug = !m_showDebug;
}
else if (event.key.code == sf::Keyboard::Space) {
if (!m_round.isInProgress()) {
DEBUG_COUT("Starting new round..\n");
// Start round
m_round.start();
m_roundText.setString("Round: " + std::to_string(m_round.getNumber()));
fillArmorQueue();
}
}
else if (event.key.code == sf::Keyboard::P) {
m_pause = !m_pause;
}
else if (event.key.code == sf::Keyboard::R) {
if (m_selection.isActive() &&
m_selection.object->getType() == Placeable::Type::Tower) {
m_selection.state = Selection::State::Rotating;
m_window.setMouseCursorVisible(false);
}
}
}
else if (event.type == sf::Event::KeyReleased) {
if (event.key.code == sf::Keyboard::R) {
if (m_selection.isActive()) {
sf::Mouse::setPosition((sf::Vector2i)m_selection.object->getPosition(), m_window);
m_selection.state = Selection::State::Moving;
}
m_window.setMouseCursorVisible(true);
}
}
else if (event.type == sf::Event::MouseMoved) {
auto& mousePos = getMousePos();
if (m_selection.isActive()) {
switch (m_selection.state)
{
case Selection::State::Moving:
m_selection.object->setPosition(mousePos);
break;
case Selection::State::Rotating:
float angle = radToDeg(getAngle(mousePos, m_towers.back().getPosition()));
m_towers.back().setRotation(angle);
m_towers.back().setBaseDirection(m_towers.back().getRotation());
updateDebug(m_towers.back());
break;
}
}
auto item = m_shop.isMouseOnItem(mousePos);
if (item) {
m_shop.clearSelection();
m_shop.selectItem(item);
}
else {
m_shop.clearSelection();
}
}
else if (event.type == sf::Event::MouseButtonPressed) {
if (event.mouseButton.button == sf::Mouse::Left) {
if (m_leftMouse == MouseState::RELEASED) {
if (m_selection.isActive() && m_selection.canBePlaced) {
placeSelectedItem();
setDebug(m_towers.back());
}
else if (!m_selection.isActive()) {
Shop::Item* selectedItem = m_shop.getSelectedItem();
if (selectedItem && getMoney() >= selectedItem->getCost()) {
startPlacingItem();
setDebug(m_towers.back());
}
}
m_leftMouse = MouseState::PRESSED;
}
}
else if (event.mouseButton.button == sf::Mouse::Right) {
if (m_rightMouse == MouseState::RELEASED) {
if (m_selection.isActive()) {
// Unselect item
m_towers.pop_back();
m_selection.deactivate();
}
}
m_rightMouse = MouseState::PRESSED;
}
}
else if (event.type == sf::Event::MouseButtonReleased) {
if (event.mouseButton.button == sf::Mouse::Left) {
if (m_leftMouse == MouseState::PRESSED) {
m_leftMouse = MouseState::RELEASED;
}
}
else if (event.mouseButton.button == sf::Mouse::Right) {
m_rightMouse = MouseState::RELEASED;
}
}
}
void Game::update(float dt)
{
if (m_pause) return;
if (m_round.isInProgress()) {
m_timeSinceSpawn += dt;
if (m_armorQueue.empty() && m_armors.empty()) {
m_round.end();
m_timeSinceSpawn = 0.f;
}
else if (!m_armorQueue.empty() && m_timeSinceSpawn >= m_spawnDelay) {
spawnNextArmor();
m_timeSinceSpawn = 0.f;
}
}
if (m_selection.isActive()) {
for (auto& area : m_restrictedAreas) {
if (CollisionHandler::collides(*m_selection.object, area) ||
!m_selection.object->isInBounds(m_mapSprite.getGlobalBounds())) {
debugRect.setFillColor(sf::Color::Red);
debugText.setString("TRUE");
debugText.setFillColor(sf::Color::Green);
m_selection.canBePlaced = false;
break;
}
else {
debugRect.setFillColor(sf::Color::Green);
debugText.setString("FALSE");
debugText.setFillColor(sf::Color::Red);
m_selection.canBePlaced = true;
}
}
}
auto armor = m_armors.begin();
bool oncePerTower = true;
std::vector<bool> towerTargets(m_towers.size(), false);
while (armor != m_armors.end()) {
bool armorErased = false;
armor->move(armor->getVelocity().x * dt, armor->getVelocity().y * dt);
int i = 0;
for (auto& tower : m_towers) {
// Skip if the tower is being placed
if (&tower == &m_towers.back() && m_selection.isActive()) {
break;
}
if (tower.isReloading()) {
tower.reload(dt);
}
// Check if the armor is inside the tower's FOV
if (!towerTargets[i] && tower.isInFOV(*armor)) {
auto dist = getDistance(tower.getPosition(), armor->getPosition());
debugAim.setSize(sf::Vector2f(dist, debugAim.getSize().y));
debugAim.setPosition(tower.getPosition());
debugAim.setRotation(tower.getRotation());
// Aim the tower at the armor
tower.aim(armor->getPosition());
towerTargets[i] = true;
if (!tower.isReloading()) {
tower.fire();
}
}
// Check if any of the tower's projectiles collide with the armor
auto proj = tower.m_projectiles.begin();
while (proj != tower.m_projectiles.end()) {
if (oncePerTower) {
proj->move(proj->getVelocity().x * dt, proj->getVelocity().y * dt);
if (!proj->isInWindow(m_window)) {
proj = tower.m_projectiles.erase(proj);
continue;
}
}
if (CollisionHandler::collides(*armor, *proj)) {
armor->setHealth(armor->getHealth() - proj->getDamage());
proj = tower.m_projectiles.erase(proj);
}
else {
++proj;
}
}
// Check health of the armor
if (armor->getHealth() <= 0.f) {
// Give reward for destroying the armor
setMoney(getMoney() + armor->getDestroyReward());
// Remove the armor
armor = m_armors.erase(armor);
armorErased = true;
break;
}
i++;
}
oncePerTower = false;
if (armorErased) {
if (m_armors.empty() && m_armorQueue.empty()) {
// Remove all projectiles when there's no armors left
for (auto& tower : m_towers) {
tower.m_projectiles.clear();
}
break;
}
else {
continue;
}
}
if (armor->hasReachedWaypoint() && armor->selectNextWaypoint() == false) {
// All waypoints have been reached
// Remove the armor
armor = m_armors.erase(armor);
m_health -= 1.f;
if (m_health <= 0) {
// Game over
m_healthBar.setRemaining(0.f);
}
else {
m_healthBar.setRemaining(m_health / m_maxHealth);
}
}
else ++armor;
}
if (m_towers.size() > 0)
updateDebug(m_towers.back());
}
void Game::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
m_window.draw(m_mapSprite);
m_window.draw(m_shop);
for (auto& armor : m_armors) {
m_window.draw(armor);
}
if (m_showDebug) m_window.draw(debugRect);
for (auto& tower : m_towers) {
m_window.draw(tower);
for (auto& p : tower.m_projectiles) {
m_window.draw(p);
}
}
m_window.draw(m_roundText);
m_window.draw(m_moneyText);
m_window.draw(m_healthBar);
if (m_showDebug) {
for (auto& area : m_restrictedAreas) {
m_window.draw(area);
}
m_window.draw(debugCircle);
m_window.draw(debugMuzzle);
m_window.draw(debugText);
m_window.draw(debugTraverseCenter);
m_window.draw(debugTraverseLeft);
m_window.draw(debugTraverseRight);
m_window.draw(debugAim);
}
}
void Game::loadTextures()
{
auto& textureManager = TextureManager::getInstance();
textureManager.loadTexture("background", "level_1.png", this);
textureManager.loadTexture("restricted_area", "restricted_area.png", this);
textureManager.getTexture("restricted_area").setRepeated(true);
textureManager.getTexture("restricted_area").setSmooth(true);
textureManager.loadTexture("shop_bar", "shop_bar.png", this);
textureManager.loadTexture("shop_item_background", "shop_item_background.png", this);
textureManager.loadTexture("buy_button", "buy_button.png", this);
for (auto& tower : m_towerAttributes) {
textureManager.loadTexture(tower["name"], tower["texture"], this);
for (auto& projectile : tower["projectiles"]) {
textureManager.loadTexture(projectile["name"], projectile["texture"], this);
textureManager.getTexture(projectile["name"]).setSmooth(true);
}
textureManager.getTexture(tower["name"]).setSmooth(true);
}
for (auto& armor : m_armorAttributes) {
textureManager.loadTexture(armor["name"], armor["texture"], this);
textureManager.getTexture(armor["name"]).setSmooth(true);
}
}
void Game::unloadTextures()
{
TextureManager::getInstance().unloadSceneSpecificTextures(this);
}
bool Game::isReadyToSpawn() {
return m_timeSinceSpawn >= m_spawnDelay;
}
unsigned long Game::getMoney()
{
return m_money;
}
void Game::setMoney(unsigned long money)
{
m_money = money;
// Update money text
m_moneyText.setString("Money: " + std::to_string(m_money));
// Update shop
m_shop.updateBuyableItems();
}
void Game::fillArmorQueue() {
std::size_t minIndex = m_round.getMinArmorIndex();
std::size_t maxIndex = m_round.getMaxArmorIndex();
std::vector<size_t> attributes;
for (std::size_t i = minIndex; i <= maxIndex; i++) {
attributes.push_back(i);
}
std::list<size_t> armorIndices;
float strength = 0.f;
while (attributes.size() > 0 && strength < m_round.getAttackerStrength()) {
std::size_t randIndex = rand() % attributes.size();
float addedStrength = m_armorAttributes[randIndex]["strength"];
if (strength + addedStrength <= m_round.getAttackerStrength()) {
strength += addedStrength;
// Insert armors in order by their speed
float speed = m_armorAttributes[randIndex]["speed"];
auto it = armorIndices.begin();
while (it != armorIndices.end()) {
if (speed >= m_armorAttributes[*it]["speed"]) {
break;
}
it++;
}
armorIndices.insert(it, randIndex);
}
else {
attributes.erase(attributes.begin() + randIndex);
}
}
DEBUG_PRINTF("Queue: ");
for (auto& armor : armorIndices) {
m_armorQueue.push(armor);
DEBUG_COUT(armor);
}
DEBUG_COUT("\n");
}
void Game::spawnNextArmor() {
std::size_t index = m_armorQueue.front();
m_armorQueue.pop();
Armor armor(m_armorAttributes[index], m_waypoints);
armor.setOrigin(armor.getGlobalBounds().width / 2.f, armor.getGlobalBounds().height / 2.f);
armor.setPosition(m_waypoints[0]);
armor.selectNextWaypoint();
auto diff = armor.getWaypoint() - armor.getPosition();
auto normalized = normalize(diff);
armor.setVelocity(sf::Vector2f(armor.getSpeed() * normalized.x, armor.getSpeed() * normalized.y));
m_armors.push_back(armor);
}
void Game::loadAttributes()
{
std::ifstream ifStream;
ifStream.open("../cfg/towers.json");
ifStream >> m_towerAttributes;
ifStream.close();
ifStream.open("../cfg/armors.json");
ifStream >> m_armorAttributes;
ifStream.close();
}
void Game::loadMap(std::string mapName)
{
auto& textureManager = TextureManager::getInstance();
std::ifstream mapFile("../cfg/maps/" + mapName + ".json");
json map;
mapFile >> map;
for (auto& wp : map["waypoints"]) {
m_waypoints.push_back(sf::Vector2f(wp["x"], wp["y"]));
}
for (auto& area : map["restrictedAreas"]) {
sf::Sprite ra;
ra.setTexture(textureManager.getTexture("restricted_area"));
sf::Vector2f size(area["size"]["x"], area["size"]["y"]);
sf::IntRect textureRect;
textureRect.width = size.x;
textureRect.height = size.y;
ra.setTextureRect(textureRect);
ra.setOrigin(sf::Vector2f(area["origin"]["x"], area["origin"]["y"]));
ra.setPosition(sf::Vector2f(area["position"]["x"], area["position"]["y"]));
ra.setRotation(area["rotation"]);
m_restrictedAreas.push_back(ra);
/*
sf::RectangleShape rect;
rect.setFillColor(sf::Color::Transparent);
rect.setOutlineColor(sf::Color::Red);
rect.setOutlineThickness(-2.f);
rect.setSize(sf::Vector2f(area["size"]["x"], area["size"]["y"]));
rect.setOrigin(sf::Vector2f(area["origin"]["x"], area["origin"]["y"]));
rect.setPosition(sf::Vector2f(area["position"]["x"], area["position"]["y"]));
rect.setRotation(area["rotation"]);
m_restrictedAreas.push_back(rect);
*/
}
}
void Game::startPlacingItem()
{
auto item = m_shop.getSelectedItem();
switch (item->getType())
{
default:
// TODO: add new types
break;
case Placeable::Type::Tower:
Tower tower(m_towerAttributes[m_shop.getSelectedItem()->getId()]);
tower.setOrigin(tower.getGlobalBounds().width / 2.f, tower.getGlobalBounds().height / 2.f);
tower.setPosition(getMousePos());
tower.setScale(0.5f, 0.5f);
m_towers.push_back(tower);
m_selection.activate(&m_towers.back());
break;
}
}
void Game::placeSelectedItem()
{
setMoney(getMoney() - m_selection.object->getCost());
debugRect.setFillColor(sf::Color::Transparent);
m_selection.deactivate();
}
void Game::setDebug(Tower& tower)
{
sf::Vector2f size(tower.getGlobalBounds().width, tower.getGlobalBounds().height);
// DEBUG RECT
debugRect.setSize(size);
debugRect.setOrigin(size.x / 2.f, size.y / 2.f);
debugRect.setOutlineThickness(1.f);
debugRect.setOutlineColor(sf::Color::Green);
debugRect.setFillColor(sf::Color(0, 255, 0, 100));
debugRect.setPosition(tower.getPosition());
// DEBUG CIRCLE
debugCircle.setPointCount(250);
debugCircle.setRadius(tower.getRange());
debugCircle.setOrigin(tower.getRange(), tower.getRange());
debugCircle.setOutlineThickness(1.f);
debugCircle.setOutlineColor(sf::Color::White);
debugCircle.setFillColor(sf::Color::Transparent);
debugCircle.setPosition(tower.getPosition());
// DEBUG FIRING OFFSET
debugMuzzle.setRadius(2.f);
debugMuzzle.setOrigin(debugMuzzle.getRadius(), debugMuzzle.getRadius());
debugMuzzle.setPosition(tower.getMuzzlePosition());
// DEBUG FIELD OF VIEW
debugTraverseLeft.setFillColor(sf::Color::Red);
debugTraverseLeft.setPosition(tower.getPosition());
debugTraverseLeft.setSize(sf::Vector2f(tower.getRange(), 1.f));
debugTraverseLeft.setOrigin(sf::Vector2f(0.f, 0.f));
debugTraverseLeft.setRotation(tower.getBaseDirection() - tower.getTraverse() / 2.f);
debugTraverseRight.setFillColor(sf::Color::Red);
debugTraverseRight.setPosition(tower.getPosition());
debugTraverseRight.setSize(sf::Vector2f(tower.getRange(), 1.f));
debugTraverseRight.setOrigin(sf::Vector2f(0.f, 0.f));
debugTraverseRight.setRotation(tower.getBaseDirection() + tower.getTraverse() / 2.f);
debugAim.setFillColor(sf::Color::Cyan);
debugAim.setSize(sf::Vector2f(1.f, 1.f));
}
void Game::updateDebug(Tower& tower)
{
debugRect.setPosition(tower.getPosition());
debugCircle.setPosition(tower.getPosition());
debugMuzzle.setPosition(tower.getMuzzlePosition());
debugTraverseCenter.setPosition(tower.getPosition());
debugTraverseLeft.setPosition(tower.getPosition());
debugTraverseLeft.setRotation(tower.getBaseDirection() - tower.getTraverse() / 2.f);
debugTraverseRight.setPosition(tower.getPosition());
debugTraverseRight.setRotation(tower.getBaseDirection() + tower.getTraverse() / 2.f);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.