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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b20e06a3a5ac09360d933536d80f73424fadab78 | 858913743cab20c8a87dda037703808cdbdfab41 | /srcs/AEntity.class.hpp | 807a3bc11cdfe28691100ac0a1434246a33b7590 | [] | no_license | Arubinu/Rush00---Shoot-Em-Up | b0daf153bd2736dc190e2921c7f2ffcab31a3e3a | cd6aa2964da6de2110191596753deceec9eeadaa | refs/heads/master | 2021-01-18T16:51:53.245597 | 2015-01-12T10:41:34 | 2015-01-12T10:41:34 | 29,130,355 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,963 | hpp | AEntity.class.hpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* AEntity.class.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apergens <apergens@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/01/10 12:06:30 by svachere #+# #+# */
/* Updated: 2015/01/11 21:19:25 by apergens ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef AENTITY_H
# define AENTITY_H
# include <string>
# include <ctime>
class AEntity
{
public:
AEntity( std::string tile );
AEntity( AEntity const & src );
virtual ~AEntity( void );
AEntity & operator=( AEntity const & rhs );
std::string getTile( void ) const;
int getX( void ) const;
int getY( void ) const;
int getVX( void ) const;
int getVY( void ) const;
int getHP( void ) const;
int getSX( void ) const;
int getSY( void ) const;
bool getHostile( void ) const;
void setHostile ( bool hostile );
void move( int x, int y );
void moveRel( int x, int y );
virtual void updatePosition( void ) = 0;
void takeDamage( int damage );
bool checkCollision( AEntity & entity ); // virtual
void tileOrigine( int & x, int & y );
virtual bool checkFire(int & x, int & y);
virtual void die( void );
static int count;
static int score;
protected:
bool _hostile;
std::string _tile;
float _x;
float _y;
float _vx;
float _vy;
int _hp;
int _sx;
int _sy;
AEntity( void );
};
#endif
|
f438be64f10c5a28c228e9700aafec2abf414f15 | c3d5ad602cd0acb02c3c45fbf815e071f8a36421 | /p96---balance/balance.cpp | 079252ebb88dda07cea8e2b54a0547321ae475d2 | [] | no_license | kankanla/Cjiajia | a529f025860b9a1c51c0a6d42507421c40c33044 | 274d114fa90a1c17e7bc030c0598dbb96de2ed63 | refs/heads/master | 2021-04-04T03:45:48.578316 | 2021-02-21T06:00:46 | 2021-02-21T06:00:46 | 248,422,461 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 319 | cpp | balance.cpp | #include <iostream>
int balance_owed; // amount owed
int main()
{
std::cout << "Enter number of dollars owed:";
std::cin >> balance_owed;
if (balance_owed = 0)
std::cout << "You owe nothing.\n";
else
std::cout << "You owe " << balance_owed << " dollars.\n";
return (0);
}
|
fe4cb2d1a0cf7aa0779a2b2634f9b4275a6d9564 | 7c556f3005250cbccc852ef8c517d2e5385b4247 | /OpcUaServer/opcua/src/protocol/binary_data_value.cpp | 0d59d199c5400a9375e25323e914f6d614780f4b | [] | no_license | kadirlua/OpcUaServer | 04cc2883d9d4de1a8cabdc1d173a08917ef2540e | 2f5affc7152f991ed1045d4758fe92d8bcfe055f | refs/heads/main | 2023-03-14T02:48:59.551073 | 2021-02-26T17:18:45 | 2021-02-26T17:18:45 | 342,634,352 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,824 | cpp | binary_data_value.cpp | // @author Alexander Rykovanov 2012
/// @email rykovanov.as@gmail.com
/// @brief Opc Ua binary session services.
/// @license GNU LGPL
///
/// Distributed under the GNU LGPL License
/// (See accompanying file LICENSE or copy at
/// http://www.gnu.org/licenses/lgpl.html)
///
#include "binary_serialization.h"
#include <opc/ua/protocol/binary/stream.h>
#include <opc/ua/protocol/types.h>
#include <opc/ua/protocol/data_value.h>
#include <algorithm>
#include <functional>
#include <memory>
#include <stdexcept>
#include <string>
namespace OpcUa
{
namespace Binary
{
template<>
std::size_t RawSize<DataValue>(const DataValue & val)
{
std::size_t size = RawSize(val.Encoding);
if (val.Encoding & DATA_VALUE)
{
size += RawSize(val.Value);
}
if (val.Encoding & DATA_VALUE_STATUS_CODE)
{
size += RawSize(val.Status);
}
if (val.Encoding & DATA_VALUE_SOURCE_TIMESTAMP)
{
size += RawSize(val.SourceTimestamp);
}
if (val.Encoding & DATA_VALUE_Server_TIMESTAMP)
{
size += RawSize(val.ServerTimestamp);
}
if (val.Encoding & DATA_VALUE_SOURCE_PICOSECONDS)
{
size += RawSize(val.SourcePicoseconds);
}
if (val.Encoding & DATA_VALUE_Server_PICOSECONDS)
{
size += RawSize(val.ServerPicoseconds);
}
return size;
}
template<>
void DataSerializer::Serialize<DataValue>(const DataValue & val)
{
*this << val.Encoding;
if (val.Encoding & DATA_VALUE)
{
*this << val.Value;
}
if (val.Encoding & DATA_VALUE_STATUS_CODE)
{
*this << val.Status;
}
if (val.Encoding & DATA_VALUE_SOURCE_TIMESTAMP)
{
*this << val.SourceTimestamp;
}
if (val.Encoding & DATA_VALUE_SOURCE_PICOSECONDS)
{
*this << val.SourcePicoseconds;
}
if (val.Encoding & DATA_VALUE_Server_TIMESTAMP)
{
*this << val.ServerTimestamp;
}
if (val.Encoding & DATA_VALUE_Server_PICOSECONDS)
{
*this << val.ServerPicoseconds;
}
}
template<>
void DataDeserializer::Deserialize<DataValue>(DataValue & val)
{
*this >> val.Encoding;
if (val.Encoding & DATA_VALUE)
{
*this >> val.Value;
}
if (val.Encoding & DATA_VALUE_STATUS_CODE)
{
*this >> val.Status;
}
if (val.Encoding & DATA_VALUE_SOURCE_TIMESTAMP)
{
*this >> val.SourceTimestamp;
}
if (val.Encoding & DATA_VALUE_SOURCE_PICOSECONDS)
{
*this >> val.SourcePicoseconds;
}
if (val.Encoding & DATA_VALUE_Server_TIMESTAMP)
{
*this >> val.ServerTimestamp;
}
if (val.Encoding & DATA_VALUE_Server_PICOSECONDS)
{
*this >> val.ServerPicoseconds;
}
}
} // namespace Binary
} // namespace OpcUa
|
ecfe33d99d8197d046593e9ed67fa096622fd585 | d9903208f0e4bb6f1bada07aac2dd3b26f15cda7 | /source/ZeroSampler.cpp | c785936dbd7dc440aee1fb8dc9957a72af4d63b0 | [
"MIT"
] | permissive | EnricoCorsaro/DIAMONDS | 616bd1113e95d71e0c642ca31f697d903e54b5c6 | c00d90297213368f1db97dfde2f43372df75353d | refs/heads/master | 2022-07-28T00:45:11.504874 | 2022-07-12T14:13:37 | 2022-07-12T14:13:37 | 76,955,254 | 7 | 4 | null | 2017-09-25T15:25:29 | 2016-12-20T12:37:15 | C++ | UTF-8 | C++ | false | false | 2,991 | cpp | ZeroSampler.cpp | #include "ZeroSampler.h"
// ZeroSampler::ZeroSampler()
//
// PURPOSE:
// Constructor. Sets initial information, logEvidence and type
// of prior and likelihood distributions to be used.
//
// INPUT:
// printOnTheScreen: Boolean value specifying whether the results are to
// be printed on the screen or not.
// initialNlivePoints: Initial number of live points to start the nesting process
// minNlivePoints: Minimum number of live points allowed in the nesting process
// ptrPriors: Vector of pointers to Prior class objects
// likelihood: Likelihood class object used for likelihood sampling.
// metric: Metric class object to contain the metric used in the problem.
// clusterer: Clusterer class object specifying the type of clustering algorithm to be used.
//
ZeroSampler::ZeroSampler(const bool printOnTheScreen, const int initialNlivePoints, const int minNlivePoints, vector<Prior*> ptrPriors,
Likelihood &likelihood, Metric &metric, Clusterer &clusterer)
: NestedSampler(printOnTheScreen, initialNlivePoints, minNlivePoints, ptrPriors, likelihood, metric, clusterer)
{
}
// ZeroSampler::~ZeroSampler()
//
// PURPOSE:
// Base class destructor.
//
ZeroSampler::~ZeroSampler()
{
}
// ZeroSampler::drawWithConstraint()
//
// PURPOSE:
// Empty function not to be used.
//
// INPUT:
// totalSample: Eigen Array matrix of size (Ndimensions, NlivePoints)
// containing the total sample of active points at a given nesting iteration
// Nclusters: Optimal number of clusters found by clustering algorithm
// clusterIndices: Indices of clusters for each point of the sample
// clusterSizes: A vector of integers containing the number of points belonging to each cluster
// drawnPoint: Eigen Array matrix of size (Ndimensions,Ndraws) to contain the
// coordinates of the drawn point to be used for the next nesting loop.
// When used for the first time, the array contains the coordinates of the
// worst nested object to be updated.
// maxNdrawAttempts: Maximum number of attempts allowed when drawing from a single ellipsoid.
//
//
// OUTPUT:
// A boolean value that is true if a new point in the sampling process is found and false otherwise.
//
bool ZeroSampler::drawWithConstraint(const RefArrayXXd totalSample, const unsigned int Nclusters, const vector<int> &clusterIndices,
const vector<int> &clusterSizes, RefArrayXd drawnPoint,
double &logLikelihoodOfDrawnPoint, const int maxNdrawAttempts)
{
return false;
}
|
a55cb126a276e21d0280a781aa03fcf3c9770ec8 | ee566f1e387d6c4009cb299a4d5f4c00bd3cc901 | /test/corecel/data/HyperslabIndexer.test.cc | f447f5fde253e4ced16fa56e6d2fb3dfabf4ac75 | [
"MIT",
"Apache-2.0"
] | permissive | celeritas-project/celeritas | 3d4f5aedd01c9c21b62ae0712c84f027e05179d3 | e7fe01331baf055393d78bdaceff8c1f7db4c9c4 | refs/heads/develop | 2023-09-01T14:10:32.210033 | 2023-08-31T21:14:20 | 2023-08-31T21:14:20 | 250,622,820 | 48 | 24 | NOASSERTION | 2023-09-14T17:11:38 | 2020-03-27T19:06:46 | C++ | UTF-8 | C++ | false | false | 3,212 | cc | HyperslabIndexer.test.cc | //----------------------------------*-C++-*----------------------------------//
// Copyright 2020-2023 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file corecel/data/HyperslabIndexer.test.cc
//---------------------------------------------------------------------------//
#include "corecel/data/HyperslabIndexer.hh"
#include "corecel/cont/Range.hh"
#include "celeritas_test.hh"
namespace celeritas
{
namespace test
{
//---------------------------------------------------------------------------//
TEST(HyperslabIndexerTest, 2D)
{
Array<size_type, 2> const dims{3, 4};
HyperslabIndexer<2> to_index(dims);
HyperslabInverseIndexer<2> to_coords(dims);
size_type index = 0;
for (size_type a : range(3))
{
for (size_type b : range(4))
{
Array<size_type, 2> coords{a, b};
EXPECT_EQ(index, to_index(coords));
EXPECT_EQ(coords, to_coords(index));
index++;
}
}
}
TEST(HyperslabIndexerTest, 3D)
{
Array<size_type, 3> const dims{3, 4, 5};
HyperslabIndexer<3> to_index(dims);
HyperslabInverseIndexer<3> to_coords(dims);
size_type index = 0;
for (size_type a : range(3))
{
for (size_type b : range(4))
{
for (size_type c : range(5))
{
Array<size_type, 3> coords{a, b, c};
EXPECT_EQ(index, to_index(coords));
EXPECT_EQ(coords, to_coords(index));
index++;
}
}
}
}
TEST(HyperslabIndexerTest, 4D)
{
Array<size_type, 4> const dims{4, 6, 3, 2};
HyperslabIndexer<4> to_index(dims);
HyperslabInverseIndexer<4> to_coords(dims);
size_type index = 0;
for (size_type a : range(4))
{
for (size_type b : range(6))
{
for (size_type c : range(3))
{
for (size_type d : range(2))
{
Array<size_type, 4> coords{a, b, c, d};
EXPECT_EQ(index, to_index(coords));
EXPECT_EQ(coords, to_coords(index));
index++;
}
}
}
}
}
TEST(HyperslabIndexerTest, 5D_with_ones)
{
Array<size_type, 5> const dims{3, 1, 4, 1, 5};
HyperslabIndexer<5> to_index(dims);
HyperslabInverseIndexer<5> to_coords(dims);
size_type index = 0;
for (size_type a : range(3))
{
for (size_type b : range(4))
{
for (size_type c : range(5))
{
Array<size_type, 5> coords{a, 0, b, 0, c};
EXPECT_EQ(index, to_index(coords));
EXPECT_EQ(coords, to_coords(index));
index++;
}
}
}
}
TEST(HyperslabIndexerTest, TEST_IF_CELERITAS_DEBUG(error))
{
Array<size_type, 3> const dims{2, 0, 3};
EXPECT_THROW((HyperslabIndexer<3>(dims)), DebugError);
}
//---------------------------------------------------------------------------//
} // namespace test
} // namespace celeritas
|
c65dce56d6e4258bb4bb56db63665a28b2285f06 | 2a394cc6f908ee98ef94b5f4e3bf03c92d64ddc6 | /5/16340242吴宇祺Exp5/code/Matrix.h | 8d0dc040f5abeea4c2bc7308d59e8cb5f352a040 | [] | no_license | WuYuQi0301/Computer-Vision | c7d2b25e3421464113203c744d5b574a4758eaa1 | 0f37d7cf80ee812d01bcf61d0d5cfbb6d1025755 | refs/heads/master | 2020-04-03T18:39:40.809098 | 2018-12-01T11:28:07 | 2018-12-01T11:28:07 | 155,492,340 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 881 | h | Matrix.h | #ifndef MATRIX_H
#define MATRIX_H
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "Point.hpp"
using namespace std;
#define MYDIM 3 //测试矩阵维数定义
//得到一个空矩阵
extern double** getAMatrix(int row, int col);
//得到三个点的值组成的矩阵
extern double** makeAMatrix(Point &p0, Point &p1, Point &p2);
//删除矩阵
extern void deleteAMatrix(double **matrix);
extern double getA(double** arcs, int n);
//计算每一行每一列的每个元素所对应的余子式,组成A*
extern void getAStart(double** arcs, int n, double** ans);
//得到给定矩阵src的逆矩阵保存到des中。
extern bool GetMatrixInverse(double** src, int n, double** des);
//求逆
extern double** getInverse(double** matrix_before);
//求矩阵的积
extern double** getMatrixProduct(double** m1, double** m2);
#endif
|
3eb5d64c92d2193ebef42b1116b1a8b6c62f5733 | 6226d6aed3629aa4069c46971ffe764bb6c743f6 | /D3D9RenderSystem/MWD3D9VertexShader.h | 93f19ef87532805376c6456eb09c2e4b6a42bc2a | [] | no_license | Myway3D/Myway3D | 83c30258f1e3eae90e619269406acd0ddeac7887 | 39cf569993f62fc648cbba49ebf74b3f8a64e46a | refs/heads/master | 2020-04-22T20:24:15.817427 | 2014-03-09T14:25:23 | 2014-03-09T14:25:23 | 170,640,096 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 68 | h | MWD3D9VertexShader.h | #pragma once
#include "MWD3D9Mapping.h"
namespace Myway
{
} |
4286efb92e7815fca22f5444046653020b770a37 | 5a9fd26dd8d874cc338955bf1e2f99541669e88d | /include/warren/Feature.h | f025fc886a8ca5c17e92b6ed0761e4ef6d00ab00 | [] | no_license | buchanae/warren | 0f8dd84031fda9659189e808d46b3da0e6912e5c | 9044a8d24e35ef21672faf005372c39826568a4f | refs/heads/master | 2021-05-29T14:14:29.069758 | 2012-08-07T01:03:41 | 2012-08-07T01:03:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,140 | h | Feature.h | #ifndef WARREN_FEATURE_H
#define WARREN_FEATURE_H
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <boost/assign/list_of.hpp>
#include <boost/algorithm/string.hpp>
#include "warren/Attributes.h"
#include "warren/tokenizer.h"
using std::string;
using std::vector;
using boost::assign::list_of;
using boost::algorithm::to_lower;
struct Feature
{
std::set<string> transcript_types;
std::set<string> exon_types;
Feature(void)
{
seqid = ".";
source = ".";
type = ".";
start = 0;
end = 0;
score = ".";
strand = '.';
phase = '.';
raw_attributes = ".";
transcript_types = list_of("mrna")
("mrna_te_gene")
("ncrna")
("mirna")
("snorna")
("snrna")
("rrna")
("trna")
("pseudogenic_transcript");
exon_types = list_of("exon")
("pseudogenic_exon");
}
bool initFromGFF(string& raw)
{
// split the tab-delimited columns
std::vector<string> cols;
tokenizer tokens(raw, separator("\t"));
std::copy(tokens.begin(), tokens.end(), std::back_inserter(cols));
if (cols.size() != 9) return false;
seqid = cols.at(0);
source = cols.at(1);
type = cols.at(2);
start = atoi(cols.at(3).c_str());
end = atoi(cols.at(4).c_str());
score = cols.at(5);
strand = *(cols.at(6).c_str());
phase = *(cols.at(7).c_str());
raw_attributes = cols.at(8);
attributes = Attributes();
attributes.addFromGFF(raw_attributes);
return true;
}
string seqid;
string source;
string type;
unsigned int start;
unsigned int end;
string score;
char strand;
char phase;
string raw_attributes;
Attributes attributes;
vector<Feature> children;
bool hasStrand(void) const
{
return strand == '+' || strand == '-';
}
bool isRevStrand(void) const
{
return strand == '-';
}
int getLength(void) const
{
return end - start + 1;
}
bool isTranscriptType()
{
string s(type);
to_lower(s);
return transcript_types.find(s) != transcript_types.end();
}
bool isExonType()
{
string s(type);
to_lower(s);
return exon_types.find(s) != exon_types.end();
}
bool overlaps (Feature& other)
{
return other.start >= start && other.start <= end
|| start >= other.start && start <= other.end;
}
};
struct FeaturePositionComparator
{
bool operator() (const Feature& a, const Feature& b) const
{
return (a.seqid < b.seqid)
|| (a.seqid == b.seqid && a.start < b.start)
|| (a.seqid == b.seqid && a.start == b.start && a.end < b.end);
}
};
#endif
|
7737145320a983dd96e173b5d229e532da16f88a | 3f8f0fc5a6a81739500f4bd91c33534171bca30a | /4_omp.cpp | 5d943aa253a50056aea8de535e11876e57547fc9 | [] | no_license | GolovkinMaxim/Parallel-computing | a3a5c28bd33cb7cb53251a14249af3f47673c5ce | 18185b2ccf1fd40cff1486625bb70e841962028a | refs/heads/master | 2022-11-03T12:34:17.164468 | 2020-06-22T14:21:11 | 2020-06-22T14:21:11 | 272,102,513 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,133 | cpp | 4_omp.cpp | #include <stdio.h>
#include <cstdlib>
#include <omp.h>
double f (double x, double y)
{
return x*x + (y-2) * (y-2);
}
int main(){
double a1, a2, b1, b2, h1, h2, *mins, minimum;
int n, num_threads;
a1 = 0.0;
b1 = 4.0;
a2 = -1.0;
b2 = 1.0;
n = 100000000;
num_threads = 4;
h1 = (b1-a1)/n;
h2 = (b2-a2)/n;
double timein = omp_get_wtime();
omp_set_num_threads(num_threads);
mins = (double *) malloc(sizeof(double) * num_threads);
for(int i = 0; i < num_threads; i++){
mins[i] = f(a1,a2);
}
#pragma omp parallel for
for(int i = 0; i < n; i++){
int th_num = omp_get_thread_num();
double x = a1 + (double)rand()/ RAND_MAX*(b1-a1);
double y = a2 + (double)rand()/ RAND_MAX*(b2-a2);
double t = f(x, y);
if (t < mins[th_num]) {
mins[th_num] = t;
}
}
minimum = mins[0];
for (int i = 1; i < num_threads; i++)
if (mins[i] < minimum)
minimum = mins[i];
printf("%lf\n", minimum);
printf("%i: Work took %f sec. time.\n", num_threads, omp_get_wtime() - timein);
}
|
6042ec77dd775bb54a26d78f69b703505b8fd2e6 | ad74f7a42e8dec14ec7576252fcbc3fc46679f27 | /AresSupernode/AresSupernodeUDPDispatcher.h | 66a72c28ec81def142105fe88f19d5363ecdbf02 | [] | no_license | radtek/TrapperKeeper | 56fed7afa259aee20d6d81e71e19786f2f0d9418 | 63f87606ae02e7c29608fedfdf8b7e65339b8e9a | refs/heads/master | 2020-05-29T16:49:29.708375 | 2013-05-15T08:33:23 | 2013-05-15T08:33:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 810 | h | AresSupernodeUDPDispatcher.h | #pragma once
#include "..\tkcom\vector.h"
#include "..\tkcom\threadedobject.h"
#include "..\tkcom\Buffer2000.h"
#include "AresSNUDPHost.h"
class AresSupernodeUDPDispatcher : public ThreadedObject
{
class UDPDispatchJob : public Object
{
public:
Buffer2000* mp_packet;
string m_host_ip;
unsigned short m_port;
UDPDispatchJob(Buffer2000* packet, const char* ip, unsigned short port){
mp_packet=packet;
m_host_ip=ip;
m_port=port;
mp_packet->ref();
}
~UDPDispatchJob(){
mp_packet->deref(); //if its out of references, it will delete itself
mp_packet=NULL;
}
};
Vector mv_packets_to_send;
CAsyncSocket m_send_socket;
public:
AresSupernodeUDPDispatcher(void);
~AresSupernodeUDPDispatcher(void);
void AddPacket(AresSNUDPHost *host, Buffer2000* packet);
UINT Run(void);
};
|
5859df23f9045b046f82ea9eff09d84fe5037e3b | 8696404296a25637aa3c85ece2cfc38d8c46d8c6 | /Game/TeleportComponent.cpp | 7beb0ca309f343f74db94b3fb2a20ec7892991bf | [] | no_license | DylanDeWaele/DDWEngine | 5b3dbf67c144ff0b41ff7ba75638de6ebeaf90b4 | 877f0a279a06ded3f9e7cfadc57c42a4ec23b978 | refs/heads/master | 2021-04-08T18:35:11.354564 | 2020-06-14T16:53:42 | 2020-06-14T16:53:42 | 248,797,800 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 790 | cpp | TeleportComponent.cpp | #include "GamePCH.h"
//Components
#include "TeleportComponent.h"
#include "BoxColliderComponent.h"
#include "TransformComponent.h"
void TeleportComponent::Update()
{
//If a player or enemy collides with the trigger, teleport to the teleport location
BoxColliderComponent* pBoxCollider = m_pGameObject->GetComponent<BoxColliderComponent>();
if (pBoxCollider->IsTriggered())
{
GameObject* pCollidedObject = pBoxCollider->GetCollidedObject();
const std::string& tag = pCollidedObject->GetTag();
if (tag == "Player" || tag == "Enemy" || tag == "Player2")
{
const glm::vec2& tpPosition = m_pGameObject->GetChild(0)->GetComponent<TransformComponent>()->GetPosition();
pCollidedObject->GetComponent<TransformComponent>()->SetPosition({ tpPosition.x, tpPosition.y });
}
}
}
|
41e5dae781dcfdb76e0d0b6be5d1eec2909eaea5 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5766201229705216_0/C++/imai0917/b.cpp | 22d765dd1ae9d9169114d4a08f38cbd015bf4d7e | [] | 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,370 | cpp | b.cpp | #include <stdio.h>
#include <vector>
using namespace std;
FILE *fin, *fout;
int N;
int E[1010][2];
vector<int> T[1010];
void init(void)
{
int i;
for (i=1;i<=N;++i){
while (!T[i].empty()){
T[i].pop_back();
}
}
}
void input(void)
{
fscanf(fin, "%d", &N);
int i;
for (i=0;i<N-1;++i){
fscanf(fin, "%d %d", &E[i][0], &E[i][1]);
T[E[i][0]].push_back(E[i][1]);
T[E[i][1]].push_back(E[i][0]);
}
}
int chk[1010]={0};
void sswap(int &t1, int &t2){
int t;
t = t1; t1 = t2; t2 = t;
}
int dy(int r)
{
chk[r] = 1;
int n = T[r].size();
int mmax[3];
int i;
int tmp;
for (i=0;i<3;++i) mmax[i] = -1;
for (i=0;i<n;++i){
int t = T[r][i];
if (chk[t] == 1) continue;
mmax[2] = dy(t);
if (mmax[2]>mmax[1]) sswap(mmax[2], mmax[1]);
if (mmax[1]>mmax[0]) sswap(mmax[1], mmax[0]);
}
if (mmax[1] == -1) return 1;
return mmax[0]+mmax[1]+1;
}
void process(void)
{
int r;
int dab = N-1;
int tmp, i;
for (r=1;r<=N;++r){
for (i=1;i<=N;++i) chk[i] = 0;
tmp = dy(r);
//printf("%d -- %d\n", r, tmp);
if (N-tmp < dab) dab = N-tmp;
}
fprintf(fout, "%d\n", dab);
}
int main(void)
{
int T, t;
fin = fopen("input.txt", "r");
fout = fopen("output.txt", "w");
fscanf(fin, "%d", &T);
for (t=1;t<=T;++t){
input();
//printf("Case #%d:\n", t);
fprintf(fout, "Case #%d: ", t);
process();
init();
}
fclose(fout);
fclose(fin);
return 0;
}
|
7824fc46ea1067976cbd4e7741db01028a742370 | 02c201b1afd2de7f8237adc3737734e19b77cd2b | /src/ir/lubs.h | afc5c067603a7073d88abd2cd7aca1240f4a601c | [
"Apache-2.0"
] | permissive | WebAssembly/binaryen | 1ce65e58489c99b5a66ab51927a5b218c70ae315 | 90d8185ba2be34fa6b6a8f8ce0cbb87e0a9ed0da | refs/heads/main | 2023-08-31T21:01:27.020148 | 2023-08-31T19:32:33 | 2023-08-31T19:32:33 | 45,208,608 | 7,061 | 768 | Apache-2.0 | 2023-09-14T21:41:04 | 2015-10-29T20:26:28 | WebAssembly | UTF-8 | C++ | false | false | 2,245 | h | lubs.h | /*
* Copyright 2021 WebAssembly Community Group participants
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef wasm_ir_lubs_h
#define wasm_ir_lubs_h
#include "ir/module-utils.h"
#include "wasm.h"
namespace wasm {
//
// Helper to find a LUB of a series of expressions. This works incrementally so
// that if we see we are not improving on an existing type then we can stop
// early.
//
struct LUBFinder {
LUBFinder() {}
LUBFinder(Type initialType) { note(initialType); }
// Note another type to take into account in the lub.
void note(Type type) { lub = Type::getLeastUpperBound(lub, type); }
// Returns whether we noted any (reachable) value.
bool noted() { return lub != Type::unreachable; }
// Returns the lub.
Type getLUB() { return lub; }
// Combines the information in another LUBFinder into this one, and returns
// whether we changed anything.
bool combine(const LUBFinder& other) {
// Check if the lub was changed.
auto old = lub;
note(other.lub);
return old != lub;
}
private:
// The least upper bound. As we go this always contains the latest value based
// on everything we've seen so far, except for nulls.
Type lub = Type::unreachable;
};
namespace LUB {
// Given a function, computes a LUB for its results. The caller can then decide
// to apply a refined type if we found one.
//
// This modifies the called function even if it fails to find a refined type as
// it does a refinalize in order to be able to compute the new types. We could
// roll back that change, but it's not harmful and can help, so we keep it
// regardless.
LUBFinder getResultsLUB(Function* func, Module& wasm);
} // namespace LUB
} // namespace wasm
#endif // wasm_ir_lubs_h
|
f8f81f946679beac8eed25cd9045354a796d0ba1 | 184587fd937b723cdea99e2e1f5653dcb58c9438 | /C++14/dp/lis.cpp | df52518e68093d8052eb8f3d21ddd3bc83934fba | [] | no_license | Samy-33/Competitive-Coding | 2e3373a0ad5a61a9e4138ef17d260803625e8620 | 0e1499cabc1a9ea645d0def046f9ea9483d58d75 | refs/heads/master | 2021-01-12T01:18:10.052683 | 2017-01-05T15:16:14 | 2017-01-05T15:16:14 | 78,368,451 | 1 | 0 | null | 2017-01-08T20:25:12 | 2017-01-08T20:25:12 | null | UTF-8 | C++ | false | false | 1,600 | cpp | lis.cpp | const int MAX = 1003;
int dp[MAX], prev[MAX], a[MAX];
// DYNAMIC PROGRAMMING APPROACH - O(n^2)
// dp[i] to be the length of the LIS(Longest increasing subsequence) which is ending at element with index i
int increasingSubsequece(int n) {
int maxLength = 1, bestEnd = 0;
dp[0] = 1;
prev[0] = -1;
for (int i = 1; i < n; ++i) {
dp[i] = 1;
prev[i] = -1;
for (int j = i-1; j >= 0; --j) {
if (dp[j] + 1 > dp[i] && a[j] < a[i]) {
dp[i] = dp[j] + 1;
prev[i] = j;
}
}
if (dp[i] > maxLength) {
bestEnd = i;
maxLength = dp[i];
}
}
// constructing the longest increasing subsequence from prev[] array
/*
vector <int> lis;
for (int j = 0; j < maxLength; ++j)
{
lis.push_back(a[bestEnd]);
bestEnd = prev[bestEnd];
}
reverse(lis.begin(), lis.end());
for (int i = 0; i < lis.size(); ++i)
printf("%d ", lis[i]);
printf("\n");
*/
return maxLength;
}
// BINARY SEARCH, GREEDY ALGORITHM - O(n logn)
// link wikipedia.org/wiki/Longest_increasing_subsequence
int increasingSubsequece2(int n) {
vector<int> temp;
vector<int>::iterator v;
temp.push_back(a[0]);
for (int i = 1; i < n; ++i) {
if (a[i] > temp.back()) temp.push_back(a[i]);
else {
v = upper_bound(temp.begin(), temp.end(), a[i]);
*v = a[i];
}
}
//for (int i=0; i<temp.size(); ++i) printf("%d ", temp[i]);
return temp.size();
} |
40d3abb6c48ef36f9eb465cfaa4d8f5d88b530b0 | d20dd18bc27babe23d6d23e0c7439967f3c46862 | /XmlLib/SaxString.h | 19ac5bf5e5fabc06c0a691b0d3544cdf7abc8e1c | [] | no_license | Maetrim/DDOBuilder | 0de2c53c43fa881d6884cfc13374ab549bbdbc1b | bcd2700eba09805eee86b94285a5767ec652f09f | refs/heads/master | 2023-08-31T15:21:51.948242 | 2023-08-24T18:13:47 | 2023-08-24T18:13:47 | 97,280,896 | 83 | 31 | null | 2022-05-25T15:17:32 | 2017-07-14T23:58:46 | C++ | UTF-8 | C++ | false | false | 1,648 | h | SaxString.h | // SaxString.h
//
#pragma once
#include "XmlLibExports.h"
#include <string>
#include <ostream>
namespace XmlLib
{
class SaxString
{
public:
SaxString();
SaxString(const wchar_t * start, const wchar_t * end); // start up to not including end
SaxString(const wchar_t * start, size_t length);
SaxString(const wchar_t * start); // null terminated
explicit SaxString(const std::wstring & str);
explicit SaxString(const std::string & str);
explicit SaxString(const char * start, const char * end); // start up to not including end
explicit SaxString(const char * start, size_t length);
explicit SaxString(const char * start); // null terminated
SaxString(const SaxString & copy);
const SaxString & operator=(const SaxString & copy);
operator std::string () const;
operator std::wstring () const;
const wchar_t * start() const;
const wchar_t * c_str() const;
size_t size() const;
SaxString Trim() const;
bool operator < (const SaxString & other) const;
bool operator == (const SaxString & other) const;
bool operator != (const SaxString & other) const;
private:
void SetOwnBufferFromAscii(const char * begin, const char * end);
const wchar_t * m_start;
size_t m_length;
mutable std::wstring m_ownBuffer; // holds the string in wide when needed
};
}
std::ostream & operator << (std::ostream & o, const XmlLib::SaxString & str);
|
c1f64257c5e4efd478c6a2b80bb2ce7689b7cfb2 | 8b55fe6c8b0fde8af69a8dc25f46f05ce522580f | /include/sPlotsPdfsComparison.h | 825cf340859ac6b16c5c5f6314ac92833fda4482 | [] | no_license | VecbosApp/EgammaAnalysisTools | 8e2c9c417482302909fb6eb9b552180de055809b | e968db52750fcaf7e24c0e63a5d02669bec56f79 | refs/heads/master | 2021-01-25T07:28:09.824135 | 2013-04-03T07:03:01 | 2013-04-03T07:03:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,016 | h | sPlotsPdfsComparison.h | //////////////////////////////////////////////////////////
// This class has been automatically generated on
// Thu Apr 15 01:31:13 2010 by ROOT version 5.22/00a
// from TTree dataset/dataset with sWeights
// found on file: ../results/sPlotsTree/sPlots_tree.root
//////////////////////////////////////////////////////////
#ifndef sPlotsPdfsComparison_h
#define sPlotsPdfsComparison_h
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TH1F.h>
#include <iostream>
#include <vector>
#include "EgammaAnalysisTools/include/ElectronLikelihood.h"
class sPlotsPdfsComparison {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
Int_t fCurrent; //!current Tree number in a TChain
// Declaration of leaf types for data
Double_t N_sig_sw;
Double_t L_N_sig;
Double_t N_qcd_sw;
Double_t L_N_qcd;
Double_t trackerIso;
Double_t ecalJIso;
Double_t ecalGTIso;
Double_t hcalIso;
Double_t combinedIso;
Double_t classification;
Double_t deta;
Double_t dphi;
Double_t hoe;
Double_t see;
Double_t spp;
Double_t eop;
Double_t esc;
Double_t pin;
Double_t rho;
Double_t fbrem;
Double_t nbrem;
Double_t met;
Double_t tcmet;
Double_t pfmet;
Double_t mt;
Double_t tcmt;
Double_t pfmt;
Double_t pt;
Double_t eta;
Double_t phi;
Double_t charge;
Double_t weight;
Double_t nPFJets;
Double_t nJets;
Double_t event;
Double_t isIdWP70;
Double_t isIdWP80;
Double_t isIdWP85;
Double_t isIdWP90;
Double_t isIdWP95;
Double_t isIsoWP70;
Double_t isIsoWP80;
Double_t isIsoWP85;
Double_t isIsoWP90;
Double_t isIsoWP95;
Double_t isConvRejWP70;
Double_t isConvRejWP80;
Double_t isConvRejWP85;
Double_t isConvRejWP90;
Double_t isConvRejWP95;
Double_t isWP70;
Double_t isWP80;
Double_t isWP85;
Double_t isWP90;
Double_t isWP95;
Int_t f_nPU;
Float_t f_trackerIso;
Float_t f_ecalJIso;
Float_t f_ecalGTIso;
Float_t f_hcalIso;
Float_t f_combinedIso;
Float_t f_classification;
Float_t f_deta;
Float_t f_dphi;
Float_t f_hoe;
Float_t f_see;
Float_t f_spp;
Float_t f_eop;
Float_t f_esc;
Float_t f_pin;
Float_t f_rho;
Float_t f_fbrem;
Int_t f_nbrem;
Float_t f_met;
Float_t f_tcmet;
Float_t f_pfmet;
Float_t f_mt;
Float_t f_tcmt;
Float_t f_pfmt;
Float_t f_pt;
Float_t f_eta;
Float_t f_phi;
Int_t f_charge;
Float_t f_weight;
Int_t f_nPFJets;
Int_t f_nJets;
Float_t f_event;
Float_t f_isIdWP70;
Float_t f_isIdWP80;
Float_t f_isIdWP85;
Float_t f_isIdWP90;
Float_t f_isIdWP95;
Float_t f_isIsoWP70;
Float_t f_isIsoWP80;
Float_t f_isIsoWP85;
Float_t f_isIsoWP90;
Float_t f_isIsoWP95;
Float_t f_isConvRejWP70;
Float_t f_isConvRejWP80;
Float_t f_isConvRejWP85;
Float_t f_isConvRejWP90;
Float_t f_isConvRejWP95;
Float_t f_isWP70;
Float_t f_isWP80;
Float_t f_isWP85;
Float_t f_isWP90;
Float_t f_isWP95;
// Declaration of leaf types for Z T & P
Double_t ztap_N_sig_sw;
Double_t ztap_L_N_sig;
Double_t ztap_N_bkg_sw;
Double_t ztap_L_N_bkg;
Double_t ztap_eopout;
Double_t ztap_eop;
Double_t ztap_esc;
Double_t ztap_pin;
Double_t ztap_hoe;
Double_t ztap_deta;
Double_t ztap_dphi;
Double_t ztap_s9s25;
Double_t ztap_s1s9;
Double_t ztap_see;
Double_t ztap_fbrem;
Double_t ztap_missingHits;
Double_t ztap_convDcot;
Double_t ztap_convDist;
Double_t ztap_zmass;
Double_t ztap_charge;
Double_t ztap_eta;
Double_t ztap_pt;
Double_t ztap_iecal;
Double_t ztap_iptbin;
Double_t ztap_iclass;
Double_t ztap_weight;
// List of branches
TBranch *b_nPU;
TBranch *b_N_sig_sw; //!
TBranch *b_L_N_sig; //!
TBranch *b_N_qcd_sw; //!
TBranch *b_L_N_qcd; //!
TBranch *b_trackerIso; //!
TBranch *b_ecalJIso; //!
TBranch *b_ecalGTIso; //!
TBranch *b_hcalIso; //!
TBranch *b_combinedIso; //!
TBranch *b_classification; //!
TBranch *b_deta; //!
TBranch *b_dphi; //!
TBranch *b_hoe; //!
TBranch *b_see; //!
TBranch *b_spp; //!
TBranch *b_eop; //!
TBranch *b_esc; //!
TBranch *b_pin; //!
TBranch *b_rho; //!
TBranch *b_fbrem; //!
TBranch *b_nbrem; //!
TBranch *b_met; //!
TBranch *b_tcmet; //!
TBranch *b_pfmet; //!
TBranch *b_mt; //!
TBranch *b_tcmt; //!
TBranch *b_pfmt; //!
TBranch *b_pt; //!
TBranch *b_eta; //!
TBranch *b_phi; //!
TBranch *b_charge; //!
TBranch *b_weight; //!
TBranch *b_nPFJets; //!
TBranch *b_nJets; //!
TBranch *b_event; //!
TBranch *b_isIdWP70; //!
TBranch *b_isIdWP80; //!
TBranch *b_isIdWP85; //!
TBranch *b_isIdWP90; //!
TBranch *b_isIdWP95; //!
TBranch *b_isIsoWP70; //!
TBranch *b_isIsoWP80; //!
TBranch *b_isIsoWP85; //!
TBranch *b_isIsoWP90; //!
TBranch *b_isIsoWP95; //!
TBranch *b_isConvRejWP70; //!
TBranch *b_isConvRejWP80; //!
TBranch *b_isConvRejWP85; //!
TBranch *b_isConvRejWP90; //!
TBranch *b_isConvRejWP95; //!
TBranch *b_isWP70; //!
TBranch *b_isWP80; //!
TBranch *b_isWP85; //!
TBranch *b_isWP90; //!
TBranch *b_isWP95; //!
// List of branches for Z T & P
TBranch *b_N_bkg_sw; //!
TBranch *b_L_N_bkg; //!
TBranch *b_EoPout; //!
TBranch *b_EoP; //!
TBranch *b_Esc; //!
TBranch *b_Pin; //!
TBranch *b_HoE; //!
TBranch *b_deltaEtaCorr; //!
TBranch *b_deltaPhiCorr; //!
TBranch *b_s9s25; //!
TBranch *b_s1s9; //!
TBranch *b_sigmaIEtaIEta; //!
TBranch *b_fBrem; //!
TBranch *b_missingHits; //!
TBranch *b_convDcot; //!
TBranch *b_convDist; //!
TBranch *b_zmass; //!
TBranch *b_iecal; //!
TBranch *b_iptbin; //!
TBranch *b_iclass; //!
sPlotsPdfsComparison();
virtual ~sPlotsPdfsComparison();
virtual Int_t Cut(Long64_t entry);
virtual Int_t GetEntry(Long64_t entry);
virtual Long64_t LoadTree(Long64_t entry);
virtual void Init(TTree *treel, int isMC=1, int isZTaP=0);
virtual void Loop();
virtual Bool_t Notify();
virtual void Show(Long64_t entry = -1);
virtual void bookHistosVariableBinning();
virtual void bookHistosFixedBinning();
virtual void bookFullHistos();
virtual void doSignalsPlots(bool what) { m_doSignal = what; }
virtual float likelihoodRatio(int isMc, ElectronLikelihood &lh);
protected:
bool m_isMC;
bool m_doSignal;
bool m_isDataZTaP;
TH1F *etaEle;
TH1F *dPhiEle[3];
TH1F *dEtaEle[3];
TH1F *EoPEle[3];
TH1F *OneOverEMinusOneOverPEle[3];
TH1F *HoEEle[3];
TH1F *sigmaIEtaIEtaEle[3];
TH1F *fbremEle[3];
TH1F *phiEle[3];
TH1F *chargeEle[3];
TH1F *lhEle[3];
// ---------- monitoring histograms ------------
/// Electrons: not splitted
/// histo[ecalsubdet][ptbin]
TH1F *dPhiUnsplitEle[3][2];
TH1F *dEtaUnsplitEle[3][2];
TH1F *EoPUnsplitEle[3][2];
TH1F *OneOverEMinusOneOverPUnsplitEle[3][2];
TH1F *HoEUnsplitEle[3][2];
TH1F *sigmaIEtaIEtaUnsplitEle[3][2];
TH1F *sigmaIPhiIPhiUnsplitEle[3][2];
TH1F *fBremUnsplitEle[3][2];
TH1F *lhUnsplitEle[3][2];
/// Electrons class-splitted
/// histo[ecalsubdet][ptbin][class]
TH1F *dPhiClassEle[3][2][2];
TH1F *dEtaClassEle[3][2][2];
TH1F *EoPClassEle[3][2][2];
TH1F *OneOverEMinusOneOverPClassEle[3][2][2];
TH1F *HoEClassEle[3][2][2];
TH1F *sigmaIEtaIEtaClassEle[3][2][2];
TH1F *sigmaIPhiIPhiClassEle[3][2][2];
TH1F *fBremClassEle[3][2][2];
TH1F *lhClassEle[3][2][2];
// the likelihood algorithm
ElectronLikelihood *LH;
};
#endif
#ifdef sPlotsPdfsComparison_cxx
sPlotsPdfsComparison::sPlotsPdfsComparison() {}
sPlotsPdfsComparison::~sPlotsPdfsComparison()
{
if (!fChain) return;
delete fChain->GetCurrentFile();
}
Int_t sPlotsPdfsComparison::GetEntry(Long64_t entry)
{
// Read contents of entry.
if (!fChain) return 0;
return fChain->GetEntry(entry);
}
Long64_t sPlotsPdfsComparison::LoadTree(Long64_t entry)
{
// Set the environment to read one entry
if (!fChain) return -5;
Long64_t centry = fChain->LoadTree(entry);
if (centry < 0) return centry;
if (!fChain->InheritsFrom(TChain::Class())) return centry;
TChain *chain = (TChain*)fChain;
if (chain->GetTreeNumber() != fCurrent) {
fCurrent = chain->GetTreeNumber();
Notify();
}
return centry;
}
void sPlotsPdfsComparison::Init(TTree *tree, int isMC, int data_ZTaP)
{
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the branch addresses and branch
// pointers of the tree will be set.
// It is normally not necessary to make changes to the generated
// code, but the routine can be extended by the user if needed.
// Init() will be called many times when running on PROOF
// (once per file to be processed).
// Set branch addresses and branch pointers
if (!tree) return;
fChain = tree;
fCurrent = -1;
fChain->SetMakeClass(1);
if(isMC) {
std::cout << "Setting branches for MC tree" << std::endl;
m_isMC = 1;
fChain->SetBranchAddress("nPU", &f_nPU, &b_nPU);
fChain->SetBranchAddress("trackerIso", &f_trackerIso, &b_trackerIso);
fChain->SetBranchAddress("ecalJIso", &f_ecalJIso, &b_ecalJIso);
fChain->SetBranchAddress("ecalGTIso", &f_ecalGTIso, &b_ecalGTIso);
fChain->SetBranchAddress("hcalIso", &f_hcalIso, &b_hcalIso);
fChain->SetBranchAddress("combinedIso", &f_combinedIso, &b_combinedIso);
fChain->SetBranchAddress("classification", &f_classification, &b_classification);
fChain->SetBranchAddress("deta", &f_deta, &b_deta);
fChain->SetBranchAddress("dphi", &f_dphi, &b_dphi);
fChain->SetBranchAddress("hoe", &f_hoe, &b_hoe);
fChain->SetBranchAddress("see", &f_see, &b_see);
fChain->SetBranchAddress("spp", &f_spp, &b_spp);
fChain->SetBranchAddress("eop", &f_eop, &b_eop);
fChain->SetBranchAddress("esc", &f_esc, &b_esc);
fChain->SetBranchAddress("pin", &f_pin, &b_pin);
fChain->SetBranchAddress("fbrem", &f_fbrem, &b_fbrem);
fChain->SetBranchAddress("nbrem", &f_nbrem, &b_nbrem);
fChain->SetBranchAddress("met", &f_met, &b_met);
fChain->SetBranchAddress("tcmet", &f_tcmet, &b_tcmet);
fChain->SetBranchAddress("pfmet", &f_pfmet, &b_pfmet);
fChain->SetBranchAddress("mt", &f_mt, &b_mt);
fChain->SetBranchAddress("tcmt", &f_tcmt, &b_tcmt);
fChain->SetBranchAddress("pfmt", &f_pfmt, &b_pfmt);
fChain->SetBranchAddress("pt1", &f_pt, &b_pt);
fChain->SetBranchAddress("eta1", &f_eta, &b_eta);
fChain->SetBranchAddress("phi1", &f_phi, &b_phi);
fChain->SetBranchAddress("charge", &f_charge, &b_charge);
fChain->SetBranchAddress("weight", &f_weight, &b_weight);
fChain->SetBranchAddress("event", &f_event, &b_event);
fChain->SetBranchAddress("nPFJetsHi", &f_nPFJets, &b_nPFJets);
fChain->SetBranchAddress("nJetsHi", &f_nJets, &b_nJets);
fChain->SetBranchAddress("isIdWP70", &f_isIdWP70, &b_isIdWP70);
fChain->SetBranchAddress("isIdWP80", &f_isIdWP80, &b_isIdWP80);
fChain->SetBranchAddress("isIdWP85", &f_isIdWP85, &b_isIdWP85);
fChain->SetBranchAddress("isIdWP90", &f_isIdWP90, &b_isIdWP90);
fChain->SetBranchAddress("isIdWP95", &f_isIdWP95, &b_isIdWP95);
fChain->SetBranchAddress("isIsoWP70", &f_isIsoWP70, &b_isIsoWP70);
fChain->SetBranchAddress("isIsoWP80", &f_isIsoWP80, &b_isIsoWP80);
fChain->SetBranchAddress("isIsoWP85", &f_isIsoWP85, &b_isIsoWP85);
fChain->SetBranchAddress("isIsoWP90", &f_isIsoWP90, &b_isIsoWP90);
fChain->SetBranchAddress("isIsoWP95", &f_isIsoWP95, &b_isIsoWP95);
fChain->SetBranchAddress("isConvRejWP70", &f_isConvRejWP70, &b_isConvRejWP70);
fChain->SetBranchAddress("isConvRejWP80", &f_isConvRejWP80, &b_isConvRejWP80);
fChain->SetBranchAddress("isConvRejWP85", &f_isConvRejWP85, &b_isConvRejWP85);
fChain->SetBranchAddress("isConvRejWP90", &f_isConvRejWP90, &b_isConvRejWP90);
fChain->SetBranchAddress("isConvRejWP95", &f_isConvRejWP95, &b_isConvRejWP95);
fChain->SetBranchAddress("isWP70", &f_isWP70, &b_isWP70);
fChain->SetBranchAddress("isWP80", &f_isWP80, &b_isWP80);
fChain->SetBranchAddress("isWP85", &f_isWP85, &b_isWP85);
fChain->SetBranchAddress("isWP90", &f_isWP90, &b_isWP90);
fChain->SetBranchAddress("isWP95", &f_isWP95, &b_isWP95);
} else {
m_isMC = 0;
fChain->SetBranchAddress("N_sig_sw", &N_sig_sw, &b_N_sig_sw);
fChain->SetBranchAddress("L_N_sig", &L_N_sig, &b_L_N_sig);
fChain->SetBranchAddress("N_qcd_sw", &N_qcd_sw, &b_N_qcd_sw);
fChain->SetBranchAddress("L_N_qcd", &L_N_qcd, &b_L_N_qcd);
fChain->SetBranchAddress("trackerIso", &trackerIso, &b_trackerIso);
fChain->SetBranchAddress("ecalJIso", &ecalJIso, &b_ecalJIso);
fChain->SetBranchAddress("ecalGTIso", &ecalGTIso, &b_ecalGTIso);
fChain->SetBranchAddress("hcalIso", &hcalIso, &b_hcalIso);
fChain->SetBranchAddress("combinedIso", &combinedIso, &b_combinedIso);
fChain->SetBranchAddress("classification", &classification, &b_classification);
fChain->SetBranchAddress("deta", &deta, &b_deta);
fChain->SetBranchAddress("dphi", &dphi, &b_dphi);
fChain->SetBranchAddress("hoe", &hoe, &b_hoe);
fChain->SetBranchAddress("see", &see, &b_see);
fChain->SetBranchAddress("spp", &spp, &b_spp);
fChain->SetBranchAddress("eop", &eop, &b_eop);
fChain->SetBranchAddress("esc", &esc, &b_esc);
fChain->SetBranchAddress("pin", &pin, &b_pin);
fChain->SetBranchAddress("fbrem", &fbrem, &b_fbrem);
fChain->SetBranchAddress("nbrem", &nbrem, &b_nbrem);
fChain->SetBranchAddress("met", &met, &b_met);
fChain->SetBranchAddress("tcmet", &tcmet, &b_tcmet);
fChain->SetBranchAddress("pfmet", &pfmet, &b_pfmet);
fChain->SetBranchAddress("mt", &mt, &b_mt);
fChain->SetBranchAddress("tcmt", &tcmt, &b_tcmt);
fChain->SetBranchAddress("pfmt", &pfmt, &b_pfmt);
fChain->SetBranchAddress("pt", &pt, &b_pt);
fChain->SetBranchAddress("eta", &eta, &b_eta);
fChain->SetBranchAddress("phi", &phi, &b_phi);
fChain->SetBranchAddress("charge", &charge, &b_charge);
fChain->SetBranchAddress("weight", &weight, &b_weight);
fChain->SetBranchAddress("event", &event, &b_event);
fChain->SetBranchAddress("nPFJetsHi", &nPFJets, &b_nPFJets);
fChain->SetBranchAddress("nJetsHi", &nJets, &b_nJets);
fChain->SetBranchAddress("isIdWP70", &isIdWP70, &b_isIdWP70);
fChain->SetBranchAddress("isIdWP80", &isIdWP80, &b_isIdWP80);
fChain->SetBranchAddress("isIdWP85", &isIdWP85, &b_isIdWP85);
fChain->SetBranchAddress("isIdWP90", &isIdWP90, &b_isIdWP90);
fChain->SetBranchAddress("isIdWP95", &isIdWP95, &b_isIdWP95);
fChain->SetBranchAddress("isIsoWP70", &isIsoWP70, &b_isIsoWP70);
fChain->SetBranchAddress("isIsoWP80", &isIsoWP80, &b_isIsoWP80);
fChain->SetBranchAddress("isIsoWP85", &isIsoWP85, &b_isIsoWP85);
fChain->SetBranchAddress("isIsoWP90", &isIsoWP90, &b_isIsoWP90);
fChain->SetBranchAddress("isIsoWP95", &isIsoWP95, &b_isIsoWP95);
fChain->SetBranchAddress("isConvRejWP70", &isConvRejWP70, &b_isConvRejWP70);
fChain->SetBranchAddress("isConvRejWP80", &isConvRejWP80, &b_isConvRejWP80);
fChain->SetBranchAddress("isConvRejWP85", &isConvRejWP85, &b_isConvRejWP85);
fChain->SetBranchAddress("isConvRejWP90", &isConvRejWP90, &b_isConvRejWP90);
fChain->SetBranchAddress("isConvRejWP95", &isConvRejWP95, &b_isConvRejWP95);
fChain->SetBranchAddress("isWP70", &isWP70, &b_isWP70);
fChain->SetBranchAddress("isWP80", &isWP80, &b_isWP80);
fChain->SetBranchAddress("isWP85", &isWP85, &b_isWP85);
fChain->SetBranchAddress("isWP90", &isWP90, &b_isWP90);
fChain->SetBranchAddress("isWP95", &isWP95, &b_isWP95);
}
if(data_ZTaP) {
m_isDataZTaP = 1;
fChain->SetBranchAddress("N_sig_sw", &ztap_N_sig_sw, &b_N_sig_sw);
fChain->SetBranchAddress("L_N_sig", &ztap_L_N_sig, &b_L_N_sig);
fChain->SetBranchAddress("N_bkg_sw", &ztap_N_bkg_sw, &b_N_bkg_sw);
fChain->SetBranchAddress("L_N_bkg", &ztap_L_N_bkg, &b_L_N_bkg);
fChain->SetBranchAddress("EoPout", &ztap_eopout, &b_EoPout);
fChain->SetBranchAddress("EoP", &ztap_eop, &b_EoP);
fChain->SetBranchAddress("esc", &ztap_esc, &b_Esc);
fChain->SetBranchAddress("pin", &ztap_pin, &b_Pin);
fChain->SetBranchAddress("HoE", &ztap_hoe, &b_HoE);
fChain->SetBranchAddress("deltaEtaCorr", &ztap_deta, &b_deltaEtaCorr);
fChain->SetBranchAddress("deltaPhiCorr", &ztap_dphi, &b_deltaPhiCorr);
fChain->SetBranchAddress("s9s25", &ztap_s9s25, &b_s9s25);
fChain->SetBranchAddress("s1s9", &ztap_s1s9, &b_s1s9);
fChain->SetBranchAddress("sigmaIEtaIEta", &ztap_see, &b_sigmaIEtaIEta);
fChain->SetBranchAddress("fBrem", &ztap_fbrem, &b_fBrem);
fChain->SetBranchAddress("missingHits", &ztap_missingHits, &b_missingHits);
fChain->SetBranchAddress("convDcot", &ztap_convDcot, &b_convDcot);
fChain->SetBranchAddress("convDist", &ztap_convDist, &b_convDist);
fChain->SetBranchAddress("zmass", &ztap_zmass, &b_zmass);
fChain->SetBranchAddress("charge", &ztap_charge, &b_charge);
fChain->SetBranchAddress("eta", &ztap_eta, &b_eta);
fChain->SetBranchAddress("pt", &ztap_pt, &b_pt);
fChain->SetBranchAddress("iecal", &ztap_iecal, &b_iecal);
fChain->SetBranchAddress("iptbin", &ztap_iptbin, &b_iptbin);
fChain->SetBranchAddress("iclass", &ztap_iclass, &b_iclass);
fChain->SetBranchAddress("weight", &ztap_weight, &b_weight);
} else {m_isDataZTaP=0;}
Notify();
}
Bool_t sPlotsPdfsComparison::Notify()
{
// The Notify() function is called when a new file is opened. This
// can be either for a new TTree in a TChain or when when a new TTree
// is started when using PROOF. It is normally not necessary to make changes
// to the generated code, but the routine can be extended by the
// user if needed. The return value is currently not used.
return kTRUE;
}
void sPlotsPdfsComparison::Show(Long64_t entry)
{
// Print contents of entry.
// If entry is not specified, print current entry
if (!fChain) return;
fChain->Show(entry);
}
Int_t sPlotsPdfsComparison::Cut(Long64_t entry)
{
// This function may be called from Loop.
// returns 1 if entry is accepted.
// returns -1 otherwise.
return 1;
}
#endif // #ifdef sPlotsPdfsComparison_cxx
|
5e63ad0ea3b282654eeb89054673062f60c422ec | 8bf6e2bbe2784f8541a6faa490a7a63801397893 | /Smart_home/Smart_home.ino | 440a13d5bb6a0157f0be3d30eeacd5126a060632 | [] | no_license | Mrtony94/Smart-Home | 50f8c5e37846ccea4d5e452a6549c1c0785062dc | 53391b5662c3a1f180d1b8a4aaf4eb9989a248e3 | refs/heads/master | 2022-10-25T02:44:38.135776 | 2020-06-19T00:02:11 | 2020-06-19T00:02:11 | 273,363,984 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,599 | ino | Smart_home.ino | //Librerias
#include <Servo.h>
#include <Keypad.h>
#include <Password.h>
//--------------------------------------------------------------------------------------------------------------
//PINES
//--------------------------------------------------------------------------------------------------------------
//SENSOR TEMPERATURA y HUMEDAD
const int Sensor = A2 ; // Pin que lee la temperatura
const int ventilador = 10; //pin digital 10
const int ventilador2 = 11; //Pin digital 11
//--------------------------------------------------------------------------------------------------------------
//ILUMINACION
//SENSOR PORCHE
const int ledporche = 26; // el pin donde ponemos el led
const int ldrporche = A0; // el pin donde ponemos el LDR
//SENSOR PUERTA
const int ledpuerta = 27; // el pin donde ponemos el led
const int ldrpuerta = A1; // el pin donde ponemos el LDR
//--------------------------------------------------------------------------------------------------------------
//TOUCH
const int touch = 37;
const int servo = 38;
Servo myservo; //coge informacion de la libreria
//variables
int angle = 0;
int estado_ultimo_toque;
int estado_tactil_actual;
//--------------------------------------------------------------------------------------------------------------
//SENSOR DE MOVIMIENTO SEGUNDA PLANTA
byte sensorfloor = 12;
byte ledfloor = 13;
int movimiento_second_floor_on;
//SENSOR SALON
byte sensorsalon = 22;
byte ledsalon = 23;
int movimiento_salon_on;
//SENSOR COCINA
byte sensorcocina = 25;
byte ledcocina = 24;
int movimiento_cocina_on;
//--------------------------------------------------------------------------------------------------------------
//RIEGO
#define bomba 39
#define sensor_humedad A8
// cuanto mayor numero más seca estará la tierra
#define seco 700
//--------------------------------------------------------------------------------------------------------------
//PERSIANAS
int ldrx = A4;//constante del ldr
int v_luzx = 0;//constante
//PERSIANA DERECHA ARRIBA
Servo servo1;//para poder coger las cosas de la libreria
//PERSIANA DERECHA ABAJO
Servo servo2;//para poder coger las cosas de la libreria
//PERSIANA IZQUIERDA ARRIBA
Servo servo3;//para poder coger las cosas de la libreria
//PERSIANA IZQUIERDA ABAJO
Servo servo4;//para poder coger las cosas de la libreria
//--------------------------------------------------------------------------------------------------------------
//GARAJE
//PINES DE ULTRASONIDO
#define echoo 32
#define trig 33
//PINES DE LOS SERVOS Y LED
Servo miniservo1;
Servo miniservo2;
int led = 34;
//VARIABLES
long duracion, distancia;
//--------------------------------------------------------------------------------------------------------------
//SISTEMA DE SEGURIDAD
//POSICIÓN DE ALARMA
boolean activada = false;
boolean activarAlarma = false;// Cuenta atras para la activacion de la alarma
boolean alarmaActivada = false; //cuenta atras para sonar
boolean estaActivada;
//CONSTANTES-VARIABLES
int ct = 15; //tiempo de calibración
int pir = 41;// conexion al pin 41 de arduino
int ledred = 42;// conexion al pin 42 de arduino
int ledgreen = 43;//conexion al pin 43 de arduino
int buzzer = 45;// conexion al pin 45 de arduino
int pantalla = 0;
int i;
int l;
//---------------------------------------
//TECLADO
const byte FILAS = 4; // define numero de filas
const byte COLUMNAS = 4; // define numero de columnas
// define la distribucion de teclas
char keys[FILAS][COLUMNAS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte pinesFilas[FILAS] = {9,8,7,6}; // pines correspondientes a las filas
byte pinesColumnas[COLUMNAS] = {5,4,3,2}; // pines correspondientes a las columnas
Keypad teclado = Keypad(makeKeymap(keys), pinesFilas, pinesColumnas, FILAS, COLUMNAS); // crea el teclado (objeto)
char tecla;
String clave = "1234";
String claveIntroducida;
boolean introducirClave;
//---------------------------------------
//--------------------------------------------------------------------------------------------------------------
void setup(){
Serial.begin(9600);
//SENSOR TEMPERATURA y HUMEDAD
pinMode(ventilador,OUTPUT);
pinMode(ventilador2,OUTPUT);
//ILUMINACION
//PORCHE
pinMode(ledporche, OUTPUT);//le decimos que el led pin 26 será de salida
pinMode(ledporche, INPUT);//le decimos que el LDR pin A0 será de entrada
//PUERTA
pinMode(ledpuerta, OUTPUT);//le decimos que el led pin 27 será de salida
pinMode(ldrpuerta, INPUT);//le decimos que el LDR pin A1 será de entrada
//TOUCH
pinMode(touch, INPUT);
myservo.attach(servo);
myservo.write(angle);
estado_tactil_actual = digitalRead(touch);
//SENSOR DE MOVIMIENTO
//SEGUNDA PLANTA
pinMode(ledfloor,OUTPUT); //configurar como salida
pinMode(sensorfloor, INPUT); // configurar como entrada
//SALON
pinMode(ledsalon,OUTPUT); //configurar como salida
pinMode(sensorsalon, INPUT); // configurar como entrada
//COCINA
pinMode(ledcocina,OUTPUT); //configurar como salida
pinMode(sensorcocina, INPUT); // configurar como entrada
//RIEGO
pinMode(bomba, OUTPUT);//configurar como salida
pinMode(sensor_humedad,INPUT);//configurar como entrada
//PERSIANAS
pinMode(ldrx, INPUT); //declaracion LDR comun
//PERSIANA DERECHA ARRIBA
servo1.attach(28);// pin del servo
servo1.write(0); //variable en el que en el angulo escribiremos el angulo que queremos
//PERSIANA DERECHA ABAJO
servo2.attach(29);// pin del servo
servo2.write(0); //variable en el que en el angulo escribiremos el angulo que queremos
//PERSIANA IZQUIERDA ARRIBA
servo3.attach(30);// pin del servo
servo3.write(0); //variable en el que en el angulo escribiremos el angulo que queremos
//PERSIANA IZQUIERDA ABAJO
servo4.attach(31);// pin del servo
servo4.write(0); //variable en el que en el angulo escribiremos el angulo que queremos
//GARAJE
//PINES DE LOS SERVOS
miniservo1.attach (35);
miniservo2.attach (36);
//LOS SERVOS SE MOVERÁN 90º
miniservo1.write(90);
miniservo2.write(90);
pinMode(led, OUTPUT);//led será de salida
//ULTRASONIDO
pinMode (echoo, INPUT);
pinMode (trig, OUTPUT);
//SISTEMA DE SEGURIDAD
pinMode(buzzer, OUTPUT);
pinMode(ledred,OUTPUT);
pinMode(ledgreen,OUTPUT);
pinMode(pir,INPUT);
calibracion_pir();
}
//FUNCIONES
void sensor_temperatura_humedad(){
int lectura = analogRead(Sensor);
float voltaje = 5.0 / 1024 * lectura;
float temp = voltaje * 100;
Serial.println(temp);
delay(1000);
if (temp >= 25){
Serial.println("Ventilador esta encendido");
digitalWrite(ventilador, HIGH);
digitalWrite(ventilador2, HIGH);
delay(2000);
}else{
digitalWrite(ventilador, LOW);
digitalWrite(ventilador2, LOW);
}
}
void iluminacion(){
int ldrStatus_porche = analogRead(ldrporche); //leer valor LDR
int ldrStatus_puerta = analogRead(ldrpuerta); //leer valor LDR
if (ldrStatus_porche <= 150){
digitalWrite(ledporche, HIGH);//la luz se enciende
Serial.println("No hay sufuciente luz, enciende las luces");
delay(2000);
}else{
digitalWrite(ledporche, LOW);//la luz se apaga
Serial.println("Hay luz, apagar las luces");
delay(2000);
}
if (ldrStatus_puerta <= 150){
digitalWrite(ledpuerta, HIGH);//la luz se enciende
Serial.println("No hay sufuciente luz, enciende las luces");
delay(2000);
}else{
digitalWrite(ledpuerta, LOW);//la luz se apaga
Serial.println("Hay luz, apagar las luces");
delay(2000);
}
}
void sensor_touch(){
estado_ultimo_toque = estado_tactil_actual;
estado_tactil_actual = digitalRead(touch);
if(estado_ultimo_toque == LOW && estado_tactil_actual == HIGH){
Serial.println("touch");
if(angle == 0)
angle = 90;
else
if(angle == 90)
angle = 0;
myservo.write(angle);
}
}
void sensor_de_movimiento(){
//Segunda planta
movimiento_second_floor_on = digitalRead(sensorfloor) == HIGH;
if(movimiento_second_floor_on){
Serial.println("movimiento");
digitalWrite(ledfloor, HIGH); //se enciende el LED
}else{
Serial.println("NO hay movimiento");
digitalWrite(ledfloor, LOW); //se apaga el LED
}
//COCINA
movimiento_cocina_on = digitalRead(sensorcocina) == HIGH;
if(movimiento_cocina_on){
Serial.println("movimiento");
digitalWrite(ledcocina, HIGH);
}else{
Serial.println("No hay movimiento");
digitalWrite(ledcocina, LOW);
}
//SALON
movimiento_salon_on = digitalRead(sensorsalon) == HIGH;
if(movimiento_salon_on){
Serial.println("movimiento");
digitalWrite(ledsalon, HIGH);
}else{
Serial.println("NO movimiento");
digitalWrite(ledsalon, LOW);
}
}
void riego(){
int SensorValue = analogRead(sensor_humedad); //coge una muestra de la humedad de la tierra
Serial.print(SensorValue); Serial.print(" - ");
if(SensorValue >= seco)
{
// Si el suelo esta demasiado seco comienza a regar por unos segundos
// y luego se espera unos segundos antes de volver a medir la humedad
Serial.println("Necesita agua");
digitalWrite(bomba, LOW);
delay(1000);
digitalWrite(bomba, HIGH);
delay(1000);
}
delay(500);
}
void persianas(){
v_luzx = analogRead(ldrx);
if(v_luzx >= 130 && v_luzx <= 160){ //menos intensidad de luz, sube persiana
servo1.write(0);//angulo cuando reciben ese rango de luz
servo2.write(0);//angulo cuando reciben ese rango de luz
servo3.write(0);//angulo cuando reciben ese rango de luz
servo4.write(0);//angulo cuando reciben ese rango de luz
Serial.print("minima intensidad de luz =");
Serial.println(v_luzx);// se observa la luz que recibe
delay(500);
}else if (v_luzx > 180 && v_luzx < 300){ //maxima intensidad baja persiana
servo1.write(90);//angulo cuando reciben ese rango de luz
servo2.write(90);//angulo cuando reciben ese rango de luz
servo3.write(90);//angulo cuando reciben ese rango de luz
servo4.write(90);//angulo cuando reciben ese rango de luz
Serial.print("máxima intensidad =");
Serial.println(v_luzx);// se observa la luz que recibe
delay(500);
}
}
void garaje(){
digitalWrite(trig, LOW);
digitalWrite(trig, HIGH);
digitalWrite(trig, LOW);
duracion = pulseIn(echoo, HIGH);
distancia = (duracion/2)/29;
Serial.print(distancia);
Serial.println("cm");
if(distancia <= 20){
miniservo1.write(180);
miniservo2.write(0);
digitalWrite(led, HIGH);
delay(2000);
}else{
miniservo1.write(90);
miniservo2.write(90);
digitalWrite(led, LOW);
delay(2000);
}
}
//SISTEMA DE SEGURIDAD
void sistema_de_seguridad(){
// CODIGO PRINCIPAL
inicializacion_alarma();
funcionamiento_alarma();
}
//Funciones-------------------------------------------------------------------
void calibracion_pir(){
//INICIACIÓN DEL PIR
Serial.println("Espere, ahora calibrando el sensor....");
for(int i = 0; i <= ct; i++){ //vamos a darle un tiempo de calibracion
Serial.print(((i*100)/ct)); //porcentaje de iniciacion, esperando 15 segundos
Serial.print("%");
Serial.println(" COMPLETADO.....");
delay(1000);
}
Serial.println("Calibracion Completada Satisfactoriamente.");
Serial.println("** SENSOR ACTIVO **");
delay(50);
}
void inicializacion_alarma(){
//PRINCIPIO DE EJECUCION --------------------------------------------------
//si la alarma no está activada
if (!alarmaActivada){
if(pantalla == 0){
//opcion A
Serial.println("Pulsa 'A' para Activar la Alarma");
//opcion B
pantalla = 1;
}
tecla = teclado.getKey();
if(tecla == 'A'){//se activa y la cuenta atras
tone(buzzer, 1000, 200);
activarAlarma = true;
}
}
}//Fin de la inicializacion de la alarma-------------------------------------
void funcionamiento_alarma(){
if(activarAlarma){
Serial.println("Inicializacion de la Alarma en... ");
int cuenta_atras = 9;
while (cuenta_atras != 0){
Serial.println(cuenta_atras);
cuenta_atras--;
tone(buzzer,700,100);
digitalWrite(ledred,HIGH);
delay(500);
digitalWrite(ledred,LOW);
delay(500);
}
Serial.println("La Alarma ha sido Activada");
activarAlarma = false;
alarmaActivada = true;
}
//Con la Alarma activada nos encontramos en 2 situaciones que queramos desactivarla y pongamos bien el codigo o no
if (alarmaActivada == true){
//Activamos el Sensor de movimiento
if(digitalRead(pir) == HIGH){
//Cuando detecta movimiento, comienza a sonar el Buzzer
tone(buzzer,1000);
//Introduccion de Teclas, para desactivacion de la alarma
int j = 5; //contraseña 5 digitos
claveIntroducida ="";
Serial.println("ALARMA SONANDO");
Serial.println("Introduce la clave");
activada = true;
while(activada){
tecla = teclado.getKey();
if (tecla != NO_KEY){
if (tecla == '0'|| tecla == '1'|| tecla == '2'|| tecla == '3'||
tecla == '4'|| tecla == '5'|| tecla == '6'|| tecla == '7'||
tecla == '8'|| tecla == '9'){
//Añade cada valor que introducimos en el teclado a la variable 'tecla' en la primera posicion
//y vamos sumandole 1 al valor para añadirlo de forma continuada hasta completar la clave
claveIntroducida += tecla;
Serial.print("*");
j++;
}
}
//Una vez introducida la clave tenemos 2 opciones:
//Si alfinal de la clave añadimos '#' borramos lo introducido y podemos volver a escribir o si escribimos mas de 9 digitos se borra
if (j > 9 || tecla == '#' ){
claveIntroducida = "";
j = 5;
Serial.println("ALARMA SONANDO");
Serial.println("Ha habido un error vuelva a introducir la clave");
}
//Si alfinal de la clave añadimos '*' admitimos que la clave es la que queremos introducir (ok)
if(tecla == '*'){
//Si la clave es correcta se apaga la alarma
if (claveIntroducida == clave){
activada = false;
alarmaActivada = false;
noTone(buzzer);
pantalla = 0;
digitalWrite(ledred,LOW);
digitalWrite(ledgreen,HIGH);
delay(2000);
//si la clave no es correcta, podemos volver a introducir la clave de nuevo.
}else if(claveIntroducida != clave){ //clave erronea
Serial.println("prueba de nuevo");
digitalWrite(ledred,HIGH);
delay(2000);
Serial.println("ALARMA SONANDO");
Serial.println("La clave no es correcta intentelo de nuevo: ");
}
}
}
digitalWrite(ledred,LOW);
digitalWrite(ledgreen,LOW);
}
}
}
void loop(){
//Codigo Principal
void sistema_de_seguridad();
void iluminacion();
void sensor_touch();
void sensor_de_movimiento();
void riego();
void persianas();
void garaje();
}
|
b97664d9f33ff1cf8d5054920148a7a63af215bf | 0b3dcad5d7900581ee5f87e87f6457159f2fa24e | /Dynamic Programming/MinCost Path Matrix.cpp | d143e3316b276a7c81d281ca467f31021b991b4a | [] | no_license | SwarnenduGanguli25/DATA_STRUCTURES | dc292d5fb3d66ec051ff694e45173f414dc2d4d6 | 96d473c9ac3db5fcea9bf1d9fd260aa85ad4a1e1 | refs/heads/master | 2022-11-08T01:14:45.220745 | 2020-06-29T11:53:53 | 2020-06-29T11:53:53 | 266,082,597 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 677 | cpp | MinCost Path Matrix.cpp | #include<iostream>
using namespace std;
int minn(int num1,int num2,int num3){
int smt=num1<num2?(num1<num3?num1:num3):(num2<num3?num2:num3);
return smt;
}
int minCostDP(int cost[3][3],int i,int j,int m,int n,int row,int column){
int dp[row][column];
if(i==m && j==n) return dp[i][j]=cost[m][n];
if(i>=row || j>=column) return dp[i][j]=INT_MAX;
return dp[i][j]=cost[i][j]+minn(minCostDP(cost,i,j+1,m,n,row,column),minCostDP(cost,i+1,j,m,n,row,column),minCostDP(cost,i+1,j+1,m,n,row,column));
}
int main(){
int cost[3][3] = {{1,2,3},{4,8,2},{1,5,3}};
int row=3;
int column=3;
cout<<minCostDP(cost,0,0,2,2,row,column)<<endl;
return 0;
}
|
b512070a0d64b7b011a134e4062c574caff1f41b | 682be4e1d2b5824a6b0b839468f74391e1332364 | /day01/ex03/ZombieHorde.hpp | 4485c787a0e85b6057ff35ed72f11cc6a604b0b3 | [] | no_license | lprunier/PiscineCPP | ddca3a647a43ce89c6f0c367cab73a5aaa94bb58 | c0dc564aac13c76d787e011b50ec0e0c0a55b7b1 | refs/heads/master | 2020-03-18T19:04:10.752920 | 2018-06-07T14:20:12 | 2018-06-07T14:20:12 | 135,132,207 | 0 | 1 | null | 2019-08-23T15:35:12 | 2018-05-28T08:27:48 | C++ | UTF-8 | C++ | false | false | 1,139 | hpp | ZombieHorde.hpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ZombieHorde.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lprunier <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/05/29 18:11:56 by lprunier #+# #+# */
/* Updated: 2018/05/29 18:11:57 by lprunier ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ZOMBIEHORDE_HPP
# define ZOMBIEHORDE_HPP
# include "Zombie.hpp"
class ZombieHorde {
public:
ZombieHorde(int n);
~ZombieHorde(void);
void announce(void) const ;
private:
Zombie *_horde;
int _len;
};
#endif
|
34b8ddf74cc2fa8309d7dabcd6c1e3e0f0d47908 | 5793887005d7507a0a08dc82f389d8b8849bc4ed | /vendor/mediatek/proprietary/hardware/mtkcam/legacy/platform/mt6735m/hal/sensor/seninf_drv.h | 0ce9cc55c0f8c74d1d208bdabefb38bb74b55526 | [] | no_license | wangbichao/dual_camera_x | 34b0e70bf2dc294c7fa077c637309498654430fa | fa4bf7e6d874adb7cf4c658235a8d24399f29f30 | refs/heads/master | 2020-04-05T13:40:56.119933 | 2017-07-10T13:57:33 | 2017-07-10T13:57:33 | 94,966,927 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,730 | h | seninf_drv.h | /********************************************************************************************
* LEGAL DISCLAIMER
*
* (Header of MediaTek Software/Firmware Release or Documentation)
*
* BY OPENING OR USING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") RECEIVED
* FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON AN "AS-IS" BASIS
* ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
* A PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY
* WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
* INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK
* ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION
* OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE LIABILITY WITH
* RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION,
TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE
* FEES OR SERVICE CHARGE PAID BY BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE WITH THE LAWS
* OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF LAWS PRINCIPLES.
************************************************************************************************/
#ifndef _SENINF_DRV_BASE_H_
#define _SENINF_DRV_BASE_H_
/*******************************************************************************
*
********************************************************************************/
enum{
SENINF_TOP_TG1 = 0x0,
SENINF_TOP_TG2 = 0x1,
SENINF_TOP_SV1 = 0x2,
SENINF_TOP_SV2 = 0x3,
};
enum{
SENINF_1 = 0x0,
SENINF_2 = 0x1,
SENINF_3 = 0x2,
SENINF_4 = 0x3,
};
typedef enum {
PAD_10BIT = 0x0,
PAD_8BIT_7_0 = 0x3,
PAD_8BIT_9_2 = 0x4,
}PAD2CAM_DATA_ENUM;
typedef enum { //0:CSI2, 3: parallel, 8:nCSI2
CSI2 = 0x0,
TEST_MODEL = 0x1,
CCIR656 = 0x2,
PARALLEL_SENSOR = 0x3,
SERIAL_SENSOR = 0x4,
HD_TV = 0x5,
EXT_CSI2_OUT1 = 0x6,
EXT_CSI2_OUT2 = 0x7,
MIPI_SENSOR = 0x8,
VIRTUAL_CHANNEL_1 = 0x9,
VIRTUAL_CHANNEL_2 = 0xA,
VIRTUAL_CHANNEL_3 = 0xB,
}SENINF_SOURCE_ENUM;
typedef enum {
TG_12BIT = 0x0,
TG_10BIT = 0x1,
TG_8BIT = 0x2
}SENSOR_DATA_BITS_ENUM;
typedef enum {
RAW_8BIT_FMT = 0x0,
RAW_10BIT_FMT = 0x1,
RAW_12BIT_FMT = 0x2,
YUV422_FMT = 0x3,
RAW_14BIT_FMT = 0x4,
RGB565_MIPI_FMT = 0x5,
RGB888_MIPI_FMT = 0x6,
JPEG_FMT = 0x7
}TG_FORMAT_ENUM;
typedef enum {
ACTIVE_HIGH = 0x0,
ACTIVE_LOW = 0x1,
}CCIR656_OUTPUT_POLARITY_ENUM;
typedef enum {
IMMIDIANT_TRIGGER = 0x0,
REFERENCE_VS1 = 0x1,
I2C1_BEFORE_I2C2 = 0x2,
I2C2_BEFORE_I2C1 = 0x3
}N3D_I2C_TRIGGER_MODE_ENUM;
typedef enum drvSeninfCmd_s {
CMD_SET_DEVICE = 0x1000,
CMD_GET_SENINF_ADDR = 0x2001,
CMD_DRV_SENINF_MAX = 0xFFFF
} drvSeninfCmd_e;
#define CAM_PLL_48_GROUP (1)
#define CAM_PLL_52_GROUP (2)
/*******************************************************************************
*
********************************************************************************/
class SeninfDrv {
public:
//
static SeninfDrv* createInstance();
virtual void destroyInstance() = 0;
protected:
virtual ~SeninfDrv() {};
public:
virtual int init() = 0;
//
virtual int uninit() = 0;
//
typedef struct reg_s {
unsigned long addr;
unsigned long val;
} reg_t;
//
virtual int setMclk1(unsigned long pcEn, unsigned long mclkSel,
unsigned long clkCnt, unsigned long clkPol,
unsigned long clkFallEdge, unsigned long clkRiseEdge, unsigned long padPclkInv) = 0;
//
virtual int setMclk2(unsigned long pcEn, unsigned long mclkSel,
unsigned long clkCnt, unsigned long clkPol,
unsigned long clkFallEdge, unsigned long clkRiseEdge, unsigned long padPclkInv) = 0;
//
virtual int setMclk3(unsigned long pcEn, unsigned long mclkSel,
unsigned long clkCnt, unsigned long clkPol,
unsigned long clkFallEdge, unsigned long clkRiseEdge, unsigned long padPclkInv) = 0;
//
virtual int setTg1GrabRange(unsigned long pixelStart, unsigned long pixelEnd,
unsigned long lineStart, unsigned long lineEnd) = 0;
//
virtual int setTg2GrabRange(unsigned long pixelStart, unsigned long pixelEnd,
unsigned long lineStart, unsigned long lineEnd) = 0;
//
virtual int setSV1GrabRange(unsigned long pixelStart, unsigned long pixelEnd,
unsigned long lineStart, unsigned long lineEnd) = 0;
//
virtual int setSV2GrabRange(unsigned long pixelStart, unsigned long pixelEnd,
unsigned long lineStart, unsigned long lineEnd) = 0;
//
virtual int setTg1ViewFinderMode(unsigned long spMode) = 0;
//
virtual int setTg2ViewFinderMode(unsigned long spMode) = 0;
//
virtual int setSV1ViewFinderMode(unsigned long spMode) = 0;
//
virtual int setSV2ViewFinderMode(unsigned long spMode) = 0;
//
virtual int sendCommand(int cmd, unsigned long arg1 = 0, unsigned long arg2 = 0, unsigned long arg3 = 0) = 0;
//
virtual int setTg1Cfg(TG_FORMAT_ENUM inDataType, SENSOR_DATA_BITS_ENUM senInLsb, unsigned int twoPxlMode) = 0;
//
virtual int setTg2Cfg(TG_FORMAT_ENUM inDataType, SENSOR_DATA_BITS_ENUM senInLsb, unsigned int twoPxlMode) = 0;
//
virtual int setSV1Cfg(TG_FORMAT_ENUM inDataType, SENSOR_DATA_BITS_ENUM senInLsb, unsigned int twoPxlMode) = 0;
//
virtual int setSV2Cfg(TG_FORMAT_ENUM inDataType, SENSOR_DATA_BITS_ENUM senInLsb, unsigned int twoPxlMode) = 0;
//
virtual int setSeninfTopMuxCtrl(unsigned int seninfTopIdx, unsigned int seninfSrc) = 0;
//
virtual int setSeninf1VC(unsigned int vc0Id, unsigned int vc1Id, unsigned int vc2Id, unsigned int vc3Id,unsigned int vcNum )= 0;
//
virtual int setSeninf2VC(unsigned int vc0Id, unsigned int vc1Id, unsigned int vc2Id, unsigned int vc3Id,unsigned int vcNum )= 0;
//
virtual int setSeninf3VC(unsigned int vc0Id, unsigned int vc1Id, unsigned int vc2Id, unsigned int vc3Id,unsigned int vcNum )= 0;
//
virtual int setSeninf1MuxCtrl(unsigned long hsPol, unsigned long vsPol, SENINF_SOURCE_ENUM inSrcTypeSel, TG_FORMAT_ENUM inDataType, unsigned int twoPxlMode) = 0;
//
virtual int setSeninf2MuxCtrl(unsigned long hsPol, unsigned long vsPol, SENINF_SOURCE_ENUM inSrcTypeSel, TG_FORMAT_ENUM inDataType, unsigned int twoPxlMode) = 0;
//
virtual int setSeninf3MuxCtrl(unsigned long hsPol, unsigned long vsPol, SENINF_SOURCE_ENUM inSrcTypeSel, TG_FORMAT_ENUM inDataType, unsigned int twoPxlMode) = 0;
//
virtual int setSeninf4MuxCtrl(unsigned long hsPol, unsigned long vsPol, SENINF_SOURCE_ENUM inSrcTypeSel, TG_FORMAT_ENUM inDataType, unsigned int twoPxlMode) = 0;
//
virtual int setSeninf1Ctrl(PAD2CAM_DATA_ENUM padSel, SENINF_SOURCE_ENUM inSrcTypeSel) = 0;
//
virtual int setSeninf2Ctrl(PAD2CAM_DATA_ENUM padSel, SENINF_SOURCE_ENUM inSrcTypeSel) = 0;
//
virtual int setSeninf3Ctrl(PAD2CAM_DATA_ENUM padSel, SENINF_SOURCE_ENUM inSrcTypeSel) = 0;
//
virtual int setSeninf4Ctrl(PAD2CAM_DATA_ENUM padSel, SENINF_SOURCE_ENUM inSrcTypeSel) = 0;
//
virtual int setSeninf1NCSI2(unsigned long dataTermDelay,
unsigned long dataSettleDelay,
unsigned long clkTermDelay,
unsigned long vsyncType,
unsigned long dlaneNum,
unsigned long ncsi2En,
unsigned long dataheaderOrder,
unsigned long mipi_type,
unsigned long HSRXDET,
unsigned long dpcm) = 0;
//
virtual int setSeninf2NCSI2(unsigned long dataTermDelay,
unsigned long dataSettleDelay,
unsigned long clkTermDelay,
unsigned long vsyncType,
unsigned long dlaneNum,
unsigned long ncsi2En,
unsigned long dataheaderOrder,
unsigned long mipi_type,
unsigned long HSRXDET,
unsigned long dpcm) = 0;
//
virtual int setSeninf3NCSI2(unsigned long dataTermDelay,
unsigned long dataSettleDelay,
unsigned long clkTermDelay,
unsigned long vsyncType,
unsigned long dlaneNum,
unsigned long ncsi2En,
unsigned long dataheaderOrder,
unsigned long mipi_type,
unsigned long HSRXDET,
unsigned long dpcm) = 0;
//
virtual int setSeninf4Scam(unsigned int scamEn,
unsigned int clkInv,
unsigned int width,
unsigned int height,
unsigned int contiMode,
unsigned int csdNum,
unsigned int DDR_EN) = 0;
//
virtual int setSeninf4Parallel(unsigned int parallelEn, unsigned int inDataType) = 0;
//
virtual int setMclk1IODrivingCurrent(unsigned long ioDrivingCurrent) = 0;
//
virtual int setMclk2IODrivingCurrent(unsigned long ioDrivingCurrent) = 0;
//
virtual int setMclk3IODrivingCurrent(unsigned long ioDrivingCurrent) = 0;
//
virtual int setTG1_TM_Ctl(unsigned int seninfSrc, unsigned int TM_En, unsigned int dummypxl,unsigned int vsync,
unsigned int line,unsigned int pxl) = 0;
//
virtual int setFlashA(unsigned long endFrame, unsigned long startPoint, unsigned long lineUnit, unsigned long unitCount, unsigned long startLine, unsigned long startPixel, unsigned long flashPol) = 0;
//
virtual int setFlashB(unsigned long contiFrm, unsigned long startFrame, unsigned long lineUnit, unsigned long unitCount, unsigned long startLine, unsigned long startPixel) = 0;
//
virtual int setFlashEn(bool flashEn) = 0;
//
virtual int setCCIR656Cfg(CCIR656_OUTPUT_POLARITY_ENUM vsPol, CCIR656_OUTPUT_POLARITY_ENUM hsPol, unsigned long hsStart, unsigned long hsEnd) = 0;
//
virtual int setN3DCfg(unsigned long n3dEn, unsigned long i2c1En, unsigned long i2c2En, unsigned long n3dMode, unsigned long diffCntEn, unsigned long diffCntThr) = 0;
//
virtual int setN3DI2CPos(unsigned long n3dPos) = 0;
//
virtual int setN3DTrigger(bool i2c1TrigOn, bool i2c2TrigOn) = 0;
//
virtual int getN3DDiffCnt(MUINT32 *pCnt) = 0;
//
virtual int checkSeninf1Input() = 0;
//
virtual int checkSeninf2Input() = 0;
//
virtual int autoDeskewCalibrationSeninf1() = 0;
virtual int autoDeskewCalibrationSeninf2() = 0;
virtual int autoDeskewCalibrationSeninf3() = 0;
//ToDo :remove
//virtual int setPdnRst(int camera, bool on) = 0;
virtual void resetCSI2() = 0;
};
#endif // _ISP_DRV_H_
|
b94138bac1b9ecd2332a30fe7a53d0af55b9fc00 | 1dba1a2a78692d3d7a7cf449cc38dd94b868a29e | /Stream of Characters.cpp | d595c95e9106e941fff40c6c4fd9f37e1d873ca8 | [] | no_license | vikasatverma/LeetCode-August-Challenge | 53e733952e874b8b06addec81098096128957ce7 | 16749a1434ba1aa212709e65cc9cff0f33ad3ab2 | refs/heads/master | 2023-01-06T01:38:32.175633 | 2020-11-09T05:31:05 | 2020-11-09T05:31:05 | 285,593,251 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,013 | cpp | Stream of Characters.cpp | class tirenode{
public:
//Words will only consist of lowercase English letters.
tirenode(){
children.resize(26, nullptr);
}
vector<tirenode*> children;
bool isEnd = false;
};
class StreamChecker {
public:
tirenode* root;
string str = "";
int maxLen = 0;
StreamChecker(vector<string>& words) {
root = new tirenode();
if(!words.empty()){
for(auto s : words){
reverse(s.begin(), s.end());
maxLen = max(maxLen, (int)s.size());
auto r = root;
for(int i = 0; i < s.size(); ++i){
int idx = s[i] - 'a';
if(r->children[idx] == nullptr){
r->children[idx] = new tirenode();
}
r = r->children[idx];
}
r->isEnd = true;
}
}
}
bool query(char letter) {
if(str.size() > maxLen){
str = str.substr(1);
}
auto r = root;
str.push_back(letter);
for(int i = str.size()-1; i >= 0; --i){
int idx = str[i] - 'a';
if(r->children[idx] == nullptr) return false;
r = r->children[idx];
if(r->isEnd) return true;
}
return r->isEnd;
}
};
|
b3466d973324d6a295081e010d6144c4b86741ec | b48710b5bcdc7632775301ca24f27d264cbde816 | /hull.cpp | 596627b22bfe58e46e1b4c7d47ee039cd765d6ad | [] | no_license | hhyc2/Uva | 7c241ce6e76e9548e91391d83604013813a8abfa | 7953d067498959f770e22d5f1ae68074a75655da | refs/heads/master | 2023-01-28T03:00:25.277907 | 2020-12-01T16:23:00 | 2020-12-01T16:23:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,439 | cpp | hull.cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#define MAX_N 20001
using namespace std;
typedef long long int llt;
ifstream fin;
ofstream fout;
class point {
public:
llt x, y, dx, dy;
point(llt x = 0, llt y = 0) :x(x), y(y), dx(0), dy(0) {}
bool operator<(const point& p) const {
if (dy * p.dx != dx * p.dy) return dy * p.dx < dx * p.dy;
//return y == p.y ? x < p.x : y < p.y;
return x == p.x ? y < p.y : x < p.x;
}
}pos[MAX_N];
vector<point> hull;
int n, x, y;
bool cmp(const point& p1, const point& p2) {
return p1.x == p2.x ? p1.y < p2.y : p1.x < p2.x;
}
llt ccw(point a, point b, point c) {
return a.x * b.y + b.x * c.y + c.x * a.y - a.y * b.x - b.y * c.x - c.y * a.x;
}
int main() {
fin.open("hull.inp");
fout.open("hull.out");
ios_base::sync_with_stdio(0);
fin.tie(0); fout.tie(0);
fin >> n;
for (int i = 0; i < n; ++i) fin >> pos[i].x >> pos[i].y;
sort(pos, pos + n);
for (int i = 1; i < n; ++i) pos[i].dx = pos[i].x - pos[0].x, pos[i].dy = pos[i].y - pos[0].y;
sort(pos + 1, pos + n);
for (int i = 0; i < n; ++i) {
while (hull.size() > 1 && ccw(hull[hull.size() - 2], hull.back(), pos[i]) <= 0)
hull.pop_back();
hull.push_back(pos[i]);
}
fout << hull.size() << '\n';
for (int i = 0; i < hull.size(); ++i) fout << hull[i].x << ' ' << hull[i].y << '\n';
return 0;
} |
e6fc1c42094ef4620ba38f0abbb50e242028214b | a38954e126283c848c9c8ee9f0a5a584b2ffc1a7 | /src/Transfers/SynchronizationState.h | 80d1de5ae8210b5fb92e2934f640c30178f9baf2 | [
"MIT"
] | permissive | ConcealNetwork/conceal-core | ddf5adfc587358dbe52d73f58770932545cbd722 | 18cb15e356ae1d03fe2abfcab3ee952247a869aa | refs/heads/master | 2023-06-28T05:25:06.657878 | 2023-06-18T11:34:21 | 2023-06-18T11:34:21 | 131,538,892 | 250 | 111 | MIT | 2023-06-18T11:34:22 | 2018-04-29T23:42:44 | C++ | UTF-8 | C++ | false | false | 1,475 | h | SynchronizationState.h | // Copyright (c) 2011-2017 The Cryptonote developers
// Copyright (c) 2017-2018 The Circle Foundation & Conceal Devs
// Copyright (c) 2018-2023 Conceal Network & Conceal Devs
//
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#include "CommonTypes.h"
#include "IStreamSerializable.h"
#include "Serialization/ISerializer.h"
#include <vector>
#include <map>
namespace cn {
class SynchronizationState : public IStreamSerializable {
public:
struct CheckResult {
bool detachRequired;
uint32_t detachHeight;
bool hasNewBlocks;
uint32_t newBlockHeight;
};
typedef std::vector<crypto::Hash> ShortHistory;
explicit SynchronizationState(const crypto::Hash& genesisBlockHash) {
m_blockchain.push_back(genesisBlockHash);
}
ShortHistory getShortHistory(uint32_t localHeight) const;
CheckResult checkInterval(const BlockchainInterval& interval) const;
void detach(uint32_t height);
void addBlocks(const crypto::Hash* blockHashes, uint32_t height, uint32_t count);
uint32_t getHeight() const;
const std::vector<crypto::Hash>& getKnownBlockHashes() const;
// IStreamSerializable
virtual void save(std::ostream& os) override;
virtual void load(std::istream& in) override;
// serialization
cn::ISerializer& serialize(cn::ISerializer& s, const std::string& name);
private:
std::vector<crypto::Hash> m_blockchain;
};
}
|
d512e1d80115be3b209b487b632cf239046f884b | 5d83739af703fb400857cecc69aadaf02e07f8d1 | /Archive2/ee/a635a75a390a2f/main.cpp | 8ef3afe77a7365d385ff405b8117222c3b1b9fa0 | [] | no_license | WhiZTiM/coliru | 3a6c4c0bdac566d1aa1c21818118ba70479b0f40 | 2c72c048846c082f943e6c7f9fa8d94aee76979f | refs/heads/master | 2021-01-01T05:10:33.812560 | 2015-08-24T19:09:22 | 2015-08-24T19:09:22 | 56,789,706 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 382 | cpp | main.cpp | #include <memory>
#include <iostream>
#include <map>
#include <initializer_list>
std::shared_ptr<int> foo(std::initializer_list<std::pair<std::string, std::shared_ptr<int> > >) {return {};}
std::shared_ptr<int> foo(std::initializer_list<std::shared_ptr<int> >) { return {}; }
std::shared_ptr<int> foo(int) { return {}; }
int main()
{
foo({ { "a", foo(10) } });
} |
83ba55b1a2ec7a5f8f65ba214c47be23b5c71509 | a17d5e594df40f2915d4d5b78ddde81c78934af6 | /vectorIterator.cpp | ae510655e7dabf3e41d188ab9507d34042434417 | [] | no_license | william00007/tp2 | 101274259ea48325c90ba7c3420ffbc7e07fb4c4 | 0eb07255cbdca340559fb22826bedb546a16c4fb | refs/heads/master | 2020-12-24T08:41:24.375034 | 2016-12-03T16:58:13 | 2016-12-03T16:58:13 | 73,327,960 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 333 | cpp | vectorIterator.cpp | #include "vectorIterator.h"
template <class T>
VectorIterator<T>::VectorIterator(std::vector<T> v)
: vector_(v), index_(-1)
{
}
template <class T>
bool VectorIterator<T>::hasNext()
{
return index_ < int(vector_.size() - 1);
}
template <class T>
T VectorIterator<T>::next()
{
index_++;
return vector_.at(index_);
}
|
efc6100c5232a2d18920fd2620b2e55752347ddc | 087cbbd3099ff8fd8d2051c60461a0458333dbac | /contests/CFgym101982/D.cpp | 2264f6f83c2c511ccff8b9aef8330f7ee15cb957 | [] | no_license | 1998factorial/Codeforces | 1046ffb2dbee582191fa59e7290c53e902c0af5c | f5b8139810e0724828e6ce7e26f3f8228589b00a | refs/heads/master | 2021-07-05T21:34:45.053171 | 2021-04-10T06:21:33 | 2021-04-10T06:21:33 | 228,158,437 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 760 | cpp | D.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000009;
ll DP[130][130][1005] , f[130];
int N , K;
void add(ll& a , ll b){
a += b;
if(a >= MOD)a -= MOD;
}
int main(){
cin >> K >> N;
f[0] = 1;
for(int i = 1; i <= N; ++i)f[i] = f[i - 1] * 2 % K;
DP[0][0][0] = 1;
for(int i = 0; i < N; ++i){
for(int j = 0; j <= i; ++j){
for(int k = 0; k < K; ++k){
for(int d = 0; d < 2; ++d){
int nk = (k + f[i] * d) % K;
add(DP[i + 1][j + d][nk] , DP[i][j][k]);
}
}
}
}
ll ret = 0;
for(int j = 1; j <= N; ++j){
add(ret , DP[N][j][0] * j % MOD);
}
cout << ret << endl;
} |
5ca9fd9c16c9c58575e0d17056ca49c6ae4d4bd3 | ec231b24eedf1d1b01c4bdfa76e8a39dc6fc3d19 | /AutoPrint/crawlDoc/crawlDoc/Printer.cpp | 8ce82de461914b1c4be8f68a351888638b7c4e64 | [] | no_license | asdlei99/WinProject | 1be5021c2ba1afaa831b214a8f163473d30b8971 | 3a95650b683be54f63937475e36676864a60b136 | refs/heads/master | 2020-05-29T20:59:33.957237 | 2018-11-02T08:27:02 | 2018-11-02T08:27:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,767 | cpp | Printer.cpp | #include "stdafx.h"
#include "printer.h"
#using "..\sendToPrinter.dll"
using namespace sendToPrinter;
using namespace std;
Printer::Printer()
{
hPrinter = (LPHANDLE)malloc(sizeof(LPHANDLE));
bStatus = OpenPrinter(NAMEOFPRINTER, hPrinter, NULL);
}
int Printer::addPrinter()
{
return 0;
}
void Printer::Clear()
{
this->bStatus = 0;
this->hPrinter = NULL;
this->pPrinterEnum = NULL;
}
int Printer::enumPrinters()
{
/*
DWORD pcbNeeded = 0, pcReturned = 0;
int dwError = 0;
EnumPrinters(PRINTER_ENUM_NAME, NULL, 2, NULL, 0, &pcbNeeded, &pcReturned);
pPrinterEnum = (PRINTER_INFO_2 *)malloc(pcbNeeded);
if (EnumPrinters(PRINTER_ENUM_NAME, NULL, 2, (LPBYTE)pPrinterEnum, pcbNeeded, &pcbNeeded, &pcReturned) == 0)
{
dwError = GetLastError();
}
for (DWORD i = 0; i < pcReturned; i++)
{
_tprintf(L"Printer Name:%s\n", pPrinterEnum[i].pPrinterName);
if (StrCmpW(pPrinterEnum[i].pPrinterName, L"HP Deskjet F2100 series") == 0)
pPrinter = pPrinterEnum[i];
}
return dwError;
*/
return 0;
}
int Printer::print(LPBYTE lpData, DWORD dwCount, DWORD dwWritten)
{
DOCINFO DocInfo;
DOC_INFO_3 DocInfo3;
DWORD dwJob = 0L, dwError = 0;
int dwId = 0;
PRINTER_DEFAULTS pDefault;
HDC hdcPrinter = NULL;
HANDLE hSpool = NULL;
pDefault.DesiredAccess = PRINTER_ACCESS_USE;
pDefault.pDatatype = L"RAW";
pDefault.pDevMode = (LPDEVMODE)NAMEOFPRINTER;
hdcPrinter = CreateDC(NULL, NAMEOFPRINTER, NULL, NULL);
//StringCchLength(lpData, 1024, &dwCount);
bStatus = OpenPrinter(NAMEOFPRINTER, hPrinter, &pDefault);
if (bStatus) {
// Fill in the structure with info about this "document."
DocInfo3.pDocName = (LPTSTR)_T("my.pdf");
DocInfo3.pOutputFile = (LPTSTR)_T("USB001");
DocInfo3.pDatatype = (LPTSTR)_T("NT EMF 1.008");
DocInfo3.dwFlags = DI_MEMORYMAP_WRITE;
DocInfo.lpszDocName = (LPTSTR)_T("my.pdf");
DocInfo.lpszOutput = (LPTSTR)_T("USB001");
DocInfo.fwType = 0;
DocInfo.lpszDatatype = NULL;
DocInfo.cbSize = sizeof(DocInfo);
// Inform the spooler the document is beginning.
dwId = StartDoc(hdcPrinter, &DocInfo);
if (dwId <= 0)
{
_tprintf(L"Failed to StartDoc!\n");
dwError = GetLastError();
return 0;
}
//dwJob = StartDocPrinter(hPrinter, 3, (LPBYTE)&DocInfo3);
dwJob = 1;
if (dwJob > 0) {
hSpool = GetSpoolFileHandle(hPrinter);
// Start a page.
bStatus = StartPage(hdcPrinter);
//bStatus = StartPagePrinter(hPrinter);
if (bStatus) {
TextOut(hdcPrinter, 20, 20, L"Hello World!", 12);
// Send the data to the printer.
//bStatus = WritePrinter(hPrinter, lpData, dwCount, &dwWritten);
//CommitSpoolData(hPrinter, hSpool, dwWritten);
//EndPagePrinter(hPrinter);
EndPage(hdcPrinter);
}
// Inform the spooler that the document is ending.
//EndDocPrinter(hPrinter);
EndDoc(hdcPrinter);
}
// Close the printer handle.
ClosePrinter(hPrinter);
}
// Check to see if correct number of bytes were written.
if (!bStatus || (dwWritten != dwCount)) {
bStatus = FALSE;
}
else {
bStatus = TRUE;
}
return bStatus;
}
int Printer::readDoc(const TCHAR * filename)
{
DocPrint ^ docPrint = gcnew DocPrint;
HANDLE hFile = NULL;
TCHAR *buffer;
DWORD dwRead = 0, dwWritten = 0;
System::String ^ sFileName = gcnew System::String(filename);
docPrint->Senddoc(sFileName);
/*
hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE == hFile)
return 0;
for (int size = GetFileSize(hFile, NULL); size; size -= dwRead)
{
buffer = (TCHAR*)malloc(size);
if (!ReadFile(hFile, buffer, size, &dwRead, NULL))
{
break;
}
//printer::print((LPBYTE)cbuffer, sizeof(cbuffer), dwWritten);
_tprintf(L"Written : %d", dwWritten);
}
*/
return 0;
}
|
c8c9d8c6ea00309bab66dd4962c63643792ace5e | bed05496e526a2716d6aa2ca7904c1b89c9058f3 | /CODECHEF/MAY18/testing.cpp | cbfac2741954820350936b188535845447c3921c | [] | no_license | dushyant7917/Competitive-Programming | 2e5b6141e87f42bb5dbb61db3b6bcb383c559c16 | d25bbb12235bdaf42435342e4865b5b0b6b37a31 | refs/heads/master | 2020-06-28T12:05:58.959849 | 2019-08-02T12:24:15 | 2019-08-02T12:24:15 | 200,230,019 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,163 | cpp | testing.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define fr(x,a,b) for(ll x=a;x<b;x++)
#define rf(x,a,b) for(ll x=a;x>=b;x--)
#define pii pair<ll,ll>
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define gmax LLONG_MAX
#define gmin LLONG_MIN
#define INF 2e9
#define N 500005
#define MAX(a,b,c) max(max(a,b),c)
#define MIN(a,b,c) min(min(a,b),c)
#define SZ(s) s.size()
#define MS(x,v) memset(x,v,sizeof(x))
bool valley(ll a[],ll i){
if(a[i]<a[i-1] && a[i]<a[i+1]) return true;
else return false;
}
bool check(ll a[],ll i){
if(a[i]+a[i+2]>=a[i+1]) return true;
else return false;
}
ll ans[N],mn;
void F(ll a[],ll n,ll i,ll sum){
if(i==n+1){
bool flag=true;
fr(j,1,n+1){
if(j+2<=n && valley(a,j) && !valley(a,j+1) && valley(a,j+2) && a[j]+a[j+1]+a[j+2]<=0){
flag=false;
break;
}
}
if(flag && sum<mn){
mn=sum;
fr(j,1,n+1) ans[j]=a[j];
}
}
else{
F(a,n,i+1,sum+a[i]);
if(valley(a,i)){
a[i]=-a[i];
F(a,n,i+1,sum+a[i]);
}
}
}
struct MAP{
ll val,ind;
};
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t;
t=100;
//cin>>t;
srand((unsigned)time(0));
ll n,ind,cur,left,right,cnt,sum,prv;
while(t--){
//cin>>n;
n=(rand()%50)+2;
ll a[n+2],b[n+2];
a[0]=a[n+1]=b[0]=b[n+1]=INF;
fr(i,1,n+1){
//cin>>a[i];
a[i]=(rand()%1000)+1;
b[i]=a[i];
}
// BRUTE-FORCE
mn=N*INF;
F(a,n,1,0);
//fr(i,1,n+1) cout<<ans[i]<<" "; cout<<"\n";
// EFFICIENT
fr(i,1,n+1) a[i]=b[i];
ind=1;
while(ind<=n){
cur=left=ind;
vector<ll> v;
v.PB(0);
cnt=1;
if(valley(a,cur)) v.PB(cur);
while(cur<=n-2 && valley(a,cur) && valley(a,cur+2) && check(a,cur)){
cur+=2;
cnt++;
v.PB(cur);
}
right=cur;
if(left==right && valley(a,left)) b[left]=-b[left];
else if(left!=right){
ll x=SZ(v);
stack<ll> st;
ll dp[x];
dp[0]=0;
dp[1]=a[v[1]];
st.push(v[1]);
prv=v[1]+3;
fr(i,2,x){
if(dp[i-2]+a[v[i]]>dp[i-1]){
dp[i]=dp[i-2]+a[v[i]];
st.push(v[i]);
prv=v[i]+3;
}
else dp[i]=dp[i-1];
}
while(SZ(st)){
if(prv-st.top()>=3){
b[st.top()]=-b[st.top()];
prv=st.top();
}
st.pop();
}
}
else {}
//cout<<"\n";
//cout<<sum1<<" "<<sum2<<"\n";
//cout<<left<<" - "<<right<<"\n";
ind=right+1;
}
//fr(i,1,n+1) cout<<b[i]<<" "; cout<<"\n";
bool flag=true;
fr(i,1,n+1){
if(b[i]!=ans[i]){
flag=false;
break;
}
}
ll s1,s2;
s1=s2=0;
fr(i,1,n+1){
s1+=ans[i];
s2+=b[i];
}
if(!flag && s1!=s2){
cout<<n<<"\n";
fr(i,1,n+1) cout<<a[i]<<" "; cout<<"\n";
fr(i,1,n+1) cout<<ans[i]<<" "; cout<<"\n";
fr(i,1,n+1) cout<<b[i]<<" "; cout<<"\n\n";
break;
}
else{
cout<<"RIGHT\n";
}
}
return 0;
}
|
302e37cc8ce5851d2e9ef2458f0d5051a5505837 | 444421ff992d4cb220d289d9c211145961c640f1 | /cppMarProg/Paradox/main.cpp | ce462c435760ffda5a5cef0eb0a33a8ba002c9fd | [] | no_license | nerzhul250/Marathons | c93e4fb8be7e73e0e4c5b0a534442c0f0b07e900 | 6074d5b1ac48e1199f619e8be43d89387db30a41 | refs/heads/master | 2021-07-03T22:58:27.113693 | 2020-09-07T16:23:40 | 2020-09-07T16:23:40 | 168,785,501 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,267 | cpp | main.cpp | #include <iostream>
#include <vector>
using namespace std;
typedef pair<int,int> ii;
vector<int> real;
ii adj[105];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
while(n!=0){
for(int i=0;i<n;i++){
string val;
int go;
int binary;
cin >> go >> val;
go--;
if(val=="false"){
binary=0;
}else{
binary=1;
}
adj[i]=ii(go,binary);
}
int isParadox=0;
for(int i=0;i<n && !isParadox;i++){
real.assign(105,-1);
real[i]=1;
int currentNode=i;
while(real[adj[currentNode].first]==-1){
real[adj[currentNode].first]=(real[currentNode]^adj[currentNode].second)?0:1;
currentNode=adj[currentNode].first;
}
int inferred=(real[currentNode]^adj[currentNode].second)?0:1;
int originalValue=real[adj[currentNode].first];
if(originalValue!=inferred){
cout << "PARADOX" << endl;
isParadox=1;
}
}
if(!isParadox)cout << "NOT PARADOX" << endl;
cin >> n;
}
return 0;
}
|
f56860c2984a76ef1badbf3f632a02e9a18b53b4 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_1595491_0/C++/retep998/main.cpp | 4e238a084a6ec868bf73eecac7885d4c6fd3ecee | [] | 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 | 822 | cpp | main.cpp | #include <string>
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <ctime>
#include <functional>
using namespace std;
char c[256];
int main() {
ifstream in("input.txt");
ofstream out("output.txt");
int cases;
in >> cases;
for (int i = 1; i <= cases; ++i) {
int n;
in >> n;
int s;
in >> s;
int p;
in >> p;
vector<int> t(n);
int b = 0;
for (int j = 0; j < n; ++j) {
in >> t[j];
int dif = t[j] - p*3;
if (t[j] == 0) {
if (p == 0) {
++b;
}
} else if (t[j] == 1) {
if (p <= 1) {
++b;
}
} else if (dif >= -2) {
++b;
} else if (s && dif >= -4) {
++b;
--s;
} else {
}
}
out << "Case #" << i << ": " << b << endl;
}
} |
b8b83abc716563d7629737dc7571abf00361c88a | a7d0d90142c3535de5de62d4b4c41c3350601aa4 | /beng_beng Engine/CBaseApp.h | 956b76c2bc0ca386ccd157bb64fd2c5ce446ab2f | [] | no_license | hoisin/beng_beng | 828a693cee35b1bc6ebf09bb9e694f10c0d7cf36 | 3ded69da83eef12728f7d06bbebe29c4bb089373 | refs/heads/master | 2020-03-22T00:43:47.560836 | 2019-01-02T13:31:56 | 2019-01-02T13:31:56 | 139,262,018 | 0 | 0 | null | 2019-01-02T13:31:57 | 2018-06-30T16:06:16 | HTML | UTF-8 | C++ | false | false | 1,550 | h | CBaseApp.h | //--------------------------------------------------------------------------
//
// Base Application framework
//
// 03/11/2017
//
//--------------------------------------------------------------------------
#pragma once
#include <string>
#include <vector>
#include <windows.h>
#include "Errors.h"
#define DEFAULT_WINDOW_TITLE "Default"
class CBaseApp
{
public:
CBaseApp();
virtual ~CBaseApp();
ErrorId Initialise(const std::string& windowTitle, UINT windowWidth,
UINT windowHeight, HINSTANCE hInstance = nullptr);
virtual void AppRun() = 0;
virtual void CloseRun();
virtual void ShutDown();
UINT GetWindowWidth() const;
UINT GetWindowHeight() const;
const std::string& GetWindowName() const;
const std::string& GetWindowClassName() const;
HINSTANCE GetHInstance() const;
HANDLE GetMutex() const;
bool IsInitialised() const;
protected:
// Callback function definition
static LRESULT CALLBACK MsgHandlerMain(HWND hWnd, UINT uiMsg,
WPARAM wParam, LPARAM lParam);
bool RegisterAppClass(HINSTANCE hAppInstance);
bool CreateAppWindow(HINSTANCE hAppInstance, const std::string& windowTitle,
UINT windowWidth, UINT windowHeight);
void UpdateWindowName(const std::string& name);
// Overrides
virtual ErrorId OnInitialise();
virtual bool OnEvent(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam);
public:
HWND m_hWnd;
protected:
HINSTANCE m_hInstance;
HANDLE m_hMutex;
std::string m_windowName;
std::string m_appName;
UINT m_width;
UINT m_height;
bool m_bAppActive;
bool m_bRun;
bool m_bInitialised;
}; |
1e7a2207ca027b6c87f072659b2fa009cd908f32 | 61770154796c036cd1412bcdb3226e29237aa767 | /7-bit_manipulation/unique_no3.cpp | e2a7ec99724648d45247503f70809dbafca20e5e | [] | no_license | kkunalguptaaa/codingBlocks | fc0bf645932ba217b090417453e80d309f9113b3 | 472d1871a4348d938ab4973fb8e9f2bf67e4eab6 | refs/heads/main | 2023-01-05T23:05:52.409554 | 2020-11-07T11:43:34 | 2020-11-07T11:43:34 | 310,830,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 969 | cpp | unique_no3.cpp | #include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int unique_no3(vector<int> &vec,int n){
int max_num=vec[0];
int max_num_index=0;
vector<int> sum_bit(n,0); //initilise a vector with 0 n values
for(int i=1;i<n;i++){
if(max_num<vec[i]){
max_num=vec[i];
max_num_index=i;
}
}
int k=0;
while(vec[max_num_index]>0){
for(int i=0;i<n;i++){
if(vec[i]&1){
sum_bit[k]++;
}
vec[i]=vec[i]>>1;
}
k++;
}
for(int i=0;i<k;i++){
sum_bit[i]%=3;
}
int res=0;
for(int i=0;i<k;i++){
res=res+(sum_bit[i]*pow(2,i));
}
return res;
}
int main(){
int n,i;
vector<int> vec;
cin >> n;
for(int i=0;i<n;i++){
int temp;
cin >> temp;
vec.push_back(temp);
}
int res=unique_no3(vec,n);
cout << res;
return 0;
} |
c80d96165c1f22a798737af19a78d90fc2c51d9f | 30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a | /Codes/AC/3039.cpp | f664d5f9deab00356a59a46d9478fc5d6f945dbb | [] | no_license | thegamer1907/Code_Analysis | 0a2bb97a9fb5faf01d983c223d9715eb419b7519 | 48079e399321b585efc8a2c6a84c25e2e7a22a61 | refs/heads/master | 2020-05-27T01:20:55.921937 | 2019-11-20T11:15:11 | 2019-11-20T11:15:11 | 188,403,594 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 616 | cpp | 3039.cpp | #include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
typedef unsigned long long LL;
const int N=1000010;
int n,nxt[N];bool tag[N];
char str[N];
int main(){
//freopen("article.in","r",stdin);
//freopen("article.out","w",stdout);
scanf("%s",str+1);n=strlen(str+1);
int j=0,ans;
for(int i=2;i<=n;i++){
while(j&&str[i]!=str[j+1])j=nxt[j];
if(str[i]==str[j+1])j++;
nxt[i]=j;if(i<n)tag[j]=1;
}
for(ans=n;ans;ans=nxt[ans])
if(tag[ans])break;
if(ans)for(int i=1;i<=ans;i++)printf("%c",str[i]);
else puts("Just a legend");
return 0;
}
|
d102a942693f083e68c9f6e4b9858af6df7812de | 3f3a42f429f8bcd769644148b24c3b0e6e2589ed | /U2_3D/Src/main/U2Segment3D.h | 94d2d44efde30289a4b6b9d13963e449e3b71c9c | [] | no_license | DanielNeander/my-3d-engine | d10ad3e57a205f6148357f47467b550c7e0e0f33 | 7f0babbfdf0b719ea4b114a89997d3e52bcb2b6c | refs/heads/master | 2021-01-10T17:58:25.691360 | 2013-04-24T07:37:31 | 2013-04-24T07:37:31 | 53,236,587 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 788 | h | U2Segment3D.h | /************************************************************************
module : U2Segment3D
Author : Yun sangyong
Desc : GT, Section 5.1: Linear Components
GT, Section 9.1: Linear Components
************************************************************************/
#pragma once
#ifndef U2_SEGMENT_H
#define U2_SEGMENT_H
#include <U2_3D/src/U2_3DLibType.h>
#include <U2lib/src/U2RefObject.h>
#include <U2lib/src/U2SmartPtr.h>
class U2Segment3D : public U2RefObject
{
public:
U2Segment3D();
U2Segment3D(const D3DXVECTOR3& origin, const D3DXVECTOR3& dir,
float fExtent);
D3DXVECTOR3 GetPosEnd() const; // P+e*D
D3DXVECTOR3 GetNegEnd() const; // P-e*D
D3DXVECTOR3 m_vOrigin, m_vDir;
float m_fExtent;
};
#include "U2Segment3D.inl"
#endif |
bd76450c68d5180f76e26a96b0b3b918f3e2ee08 | c69539927ca23ae2837684c4d2e2ad4aac445117 | /RandomHubbard/rrg_random_hubbard.cc | ebb4f3f3c0d687842e879a654c14ae4088096770 | [] | no_license | brendenroberts/RigorousRG | 2ec94c306087e53481278e38900025419795724b | 8e1bd942f6347180be306963d9e73e9bb684dead | refs/heads/main | 2022-12-02T15:44:34.042900 | 2022-11-09T14:17:43 | 2022-11-09T14:17:43 | 61,067,364 | 9 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 8,725 | cc | rrg_random_hubbard.cc | #include "rrg.h"
#include "itensor/mps/sites/fermion.h"
#include <fstream>
#include <iostream>
#include <iomanip>
double dist(int i , int j , vector<double> dx , vector<double> dy) {
return sqrt((i+dx.at(i)-j-dx.at(j))*(i+dx.at(i)-j-dx.at(j)) + (dy.at(i)-dy.at(j))*(dy.at(i)-dy.at(j)));
}
int parseDisorder(string const& disFileName , vector<double> &dis , const int lineNum , const char delim = '\t') {
dis.clear();
std::ifstream disFile;
disFile.open(disFileName);
if(disFile.is_open()) {
string line;
for(auto i = 0 ; i <= lineNum ; ++i) std::getline(disFile,line);
std::stringstream data(line);
for(string val ; std::getline(data,val,delim) ; )
dis.push_back(stod(val));
} else { std::cerr << "error opening disorder file " << disFileName << std::endl; return 1; }
disFile.close();
return 0;
}
int main(int argc, char *argv[]) {
if(argc != 3) { std::cerr << "usage: " << argv[0] << " config_file line_num" << std::endl; return 1; }
std::ostringstream ss;
std::map<string,string> configParams;
std::ofstream logFile;
std::cout.fill('0');
std::ifstream configFile;
configFile.open(argv[1]);
if(configFile.is_open()) parseConfig(configFile,configParams);
else { std::cerr << "error opening config file" << std::endl; return 1; }
configFile.close();
// RRG & AGSP parameters
const size_t N = stoul(configParams.at("N")); // system size
const double tau = stod(configParams.at("tau")); // AGSP temperature
const size_t M = stoul(configParams.at("M")); // num Trotter steps
const size_t s = stoul(configParams.at("s")); // formal s param
const size_t D = stoul(configParams.at("D")); // formal D param
const double eps = stod(configParams.at("eps")); // MPVS error tolerance
const bool doLanczos = true; // diag restricted Hamiltonian iteratively?
// User can request more than s states at the final step
const size_t sts = configParams.find("states") == configParams.end() ? s : stoul(configParams.at("states"));
// State targeting parameters (for continuous symmetry)
const vector<int> targetQNs = {stoi(configParams.at("Nf"))};
const int qnSpread = stoi(configParams.at("qnSpread")); // maximum allowed deviation for local blocks
// Hamitonian parameters
const double t = stod(configParams.at("t")); // fermion hopping
const double lambda_ne = stod(configParams.at("lne"));
const double lambda_ee = stod(configParams.at("lee"));
const double Z = stod(configParams.at("Z"));
const double zeta = stod(configParams.at("zeta"));
const double f_ex = stod(configParams.at("fex"));
const double a = stod(configParams.at("a")); // exp hopping correction
const auto hSpGen = [](size_t x) -> SiteSet { return Fermion(x,{"ConserveQNs",true}); };
auto const& hs = hSpGen(N);
// Load disorder realization from text file
const auto lineNum = atoi(argv[2]);
vector<double> dx , dy;
if(lineNum < 0) { dx = vector<double>(N,0.0); dy = vector<double>(N,0.0); }
else {
if(parseDisorder(configParams.at("dxFile"),dx,lineNum) != 0) return 1;
if(parseDisorder(configParams.at("dyFile"),dy,lineNum) != 0) return 1;
}
auto r = [&dx,&dy](int i , int j) { return dist(i,j,dx,dy); };
// IO stream stuff for setting up output filenames
auto configId = configParams.find("id");
ss.setf(std::ios::fixed);
ss.fill('0');
if(configId == configParams.end())
ss << argv[0] << "_N" << std::setw(3) << N;
else ss << (*configId).second;
auto dbFilename = ss.str();
auto id = ss.str();
if(configParams.find("log") != configParams.end())
if(auto doLog = configParams.at("log") ; doLog == "true" || doLog == "True" || doLog == "1") {
ss << "_l" << std::setw(3) << lineNum << ".log";
auto logFilename = ss.str();
std::cout << "writing output to " << logFilename << std::endl;
logFile.open(logFilename);
std::cout.rdbuf(logFile.rdbuf()); // redirect cout to log file buffer
}
std::ostringstream().swap(ss);
// Create MPO for H using AutoMPO functionality
AutoMPO autoH(hs);
for(auto i = 0 ; static_cast<size_t>(i) < N ; ++i) {
if(static_cast<size_t>(i) < N-1) {
auto hop = exp(-(r(i,i+1)-1)/a);
autoH += -t*hop,"C",i+1,"Cdag",i+2;
autoH += -t*hop,"C",i+2,"Cdag",i+1;
}
auto pTerm = -1.0/zeta;
for(auto j = 0 ; static_cast<size_t>(j) < N ; ++j)
pTerm += 1.0/(r(i,j)+zeta);
pTerm *= -lambda_ne*Z;
autoH += pTerm,"N",i+1;
for(auto j = 0 ; j < i ; ++j)
autoH += lambda_ee*(abs(i-j) == 1 ? 1.0-f_ex : 1.0)/(r(i,j)+zeta),"N",i+1,"N",j+1;
}
auto H = toMPO(autoH,{"Cutoff",epx});
// Generate AGSP thermal operator exp(-H/t)
auto K = Trotter(tau,M,autoH,1e-10);
std::cout << "maximum AGSP bond dim = " << maxLinkDim(K) << std::endl;
// Do RRG, obtaining a single MPVS object
auto [res,time] = rrg(autoH,K,configParams.at("n"),hSpGen,targetQNs,{"Cutoff",eps,"ExtDim",s,"OpDim",D,"ExtDimLast",sts,
"TruncateQNs",true,"QNSpread",qnSpread,"Iterative",doLanczos});
// CLEANUP: extract MPS from MPVS and do some rounds of DMRG
auto [extIndex,eSite] = findExt(res);
auto [U,Dg] = diagHermitian(inner(res,res,eSite),{"Tags","Ext"});
Dg.apply([](Real r) {return 1.0/sqrt(r);});
res.ref(eSite) *= U*dag(Dg);
res.ref(eSite).noPrime();
auto [P,S] = diagHermitian(-inner(res,H,res,eSite),{"Tags","Ext"});
res.ref(eSite) *= P;
extIndex = findIndex(res(eSite),"Ext");
for(auto j : range1(N-1)) std::cout << rightLinkIndex(res,j).dim() << " ";
std::cout << std::endl;
for(auto n : range1(dim(extIndex))) std::cout << std::fixed << std::setprecision(8) << -S.elt(n,n) << " ";
std::cout << std::endl;
using ePair = pair<double,MPS>;
vector<ePair> eigenstates;
for(auto i : range1(dim(extIndex))) {
auto fc = MPS(res);
fc.ref(eSite) *= setElt(dag(extIndex)=i);
fc.orthogonalize({"Cutoff",epx,"RespectDegenerate",true});
fc.normalize();
eigenstates.push_back({inner(fc,H,fc),fc});
}
std::cout << "DMRG steps:" << std::endl;
auto nSweep = 2lu , nDMRG = 6lu;
auto t3 = std::chrono::high_resolution_clock::now();
for(auto i : range(nDMRG)) {
dmrgMPO(H,eigenstates,nSweep,{"Exclude",true,"Cutoff",eps});
std::sort(eigenstates.begin(), eigenstates.end(),[](auto const& a, auto const& b) { return a.first < b.first; });
for(auto const& v : eigenstates) std::cout << v.first << " ";
std::cout << std::endl;
}
auto t4 = std::chrono::high_resolution_clock::now();
auto tDMRG = std::chrono::duration_cast<std::chrono::duration<double>>(t4 - t3);
std::cout << "dmrg elapsed: " << std::fixed << std::setprecision(0) << tDMRG.count() << " s" << std::endl;
if(logFile.is_open()) logFile.close();
// EXIT: write out spectrum, save states to disk
std::ostringstream().swap(ss);
ss << id << "_sites.dat";
auto sitesFilename = ss.str();
writeToFile(sitesFilename,hs);
std::ostringstream().swap(ss);
std::ostringstream dbEntry;
dbEntry.setf(std::ios::fixed);
dbEntry.fill('0');
for(auto i : range(eigenstates)) {
dbEntry << "# N s D tau M t lne lee zeta fex a Nf time lineNum eIndex E" << std::endl;
dbEntry << std::setw(3) << N << " " << std::setw(2) << s << " " << std::setw(2) << D
<< " " << std::setprecision(3) << tau << " " << std::setw(4) << M << " " << std::setw(4) << t
<< " " << std::setw(4) << lambda_ne << " " << std::setw(4) << lambda_ee << " " << std::setw(4) << zeta
<< " " << std::setw(4) << f_ex << " " << std::setw(4) << a << " " << std::setw(3) << -qn(extIndex,1).val(1)
<< " " << std::setprecision(2) << time << " " << std::setw(4) << lineNum << " " << std::setw(4) << i
<< " " << std::setprecision(16) << eigenstates.at(i).first << std::endl;
std::ostringstream().swap(ss);
ss.fill('0');
ss << id << "_l" << std::setw(3) << lineNum << "_e" << std::setw(2) << i << ".dat";
auto stateFilename = ss.str();
writeToFile(stateFilename,eigenstates.at(i).second);
}
// Minimize amount of time spent with db file open (but don't bother with locking)
std::ofstream dbFile(dbFilename,std::fstream::app);
dbFile << dbEntry.str();
dbFile.flush();
dbFile.close();
return 0;
}
|
100338376b721e7713e9f1248dec0739f69e409a | 416b5243781741c81e85f9dde2a8053e1958cf8c | /fsm/include/control_bus/states.h | 72b4244138741e5029246bb14f1bea2f48fb5153 | [] | no_license | chipsneutrino/chips-daq | 657450aef2b43ea4b38fd0f8a0d170e062ff03b9 | 5f6c15f534eddf5a2e2c7bd201c3d7178a5428d4 | refs/heads/main | 2023-06-02T03:16:37.262177 | 2020-05-21T18:12:21 | 2020-05-21T18:12:21 | 378,112,060 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 340 | h | states.h | #pragma once
#include "control_bus/fsm.h"
namespace ControlBus {
namespace states {
class Offline : public FSM {
void entry() override;
void react(events::Connected const& e);
};
class Online : public FSM {
void entry() override;
void react(events::Disconnected const& e) override;
};
}
}
|
6d84433a012531eabacc7ec5562407e26d9825c4 | dead9ba62a993f66dcfad13552a0b684f9342d9d | /src/graphics/cubemap.cpp | 23af8f2295b49056de38a6854495ccdce7c12bbf | [] | no_license | timostrating/PokeWorld | 32682cff9a54c6cf424c52d6f8622afb54fc1eca | 4c00c3dba9b875ff9ffb5c9920742f09735ada00 | refs/heads/master | 2021-06-24T15:51:29.497785 | 2021-01-16T21:03:47 | 2021-01-16T21:03:47 | 192,098,963 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,718 | cpp | cubemap.cpp | //
// Created by sneeuwpop on 08-12-19.
//
#include <iostream>
#include <vector>
#include "cubemap.h"
#include "../util/external/stb_image.hpp"
//Cubemap Cubemap::fromAssetFile()
//{
//
// return Cubemap(faces);
//}
Cubemap::Cubemap(std::vector<std::string> faces)
{
glGenTextures(1, &textureId);
std::cout << "Cubemap " << textureId << " created\n";
bind(0); // TODO: test support multiple textures
int width, height, nrChannels;
for (unsigned int i = 0; i < faces.size(); i++)
{
unsigned char *data = stbi_load(faces[i].c_str(), &width, &height, &nrChannels, 0);
if (data)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data );
else
std::cout << "Cubemap texture failed to load at path: " << faces[i] << std::endl;
stbi_image_free(data);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
}
void Cubemap::bind(unsigned int cubemapI)
{
glActiveTexture(GL_TEXTURE0 + cubemapI);
glBindTexture(GL_TEXTURE_CUBE_MAP, textureId);
}
void Cubemap::bind(unsigned int cubemapI, const ShaderProgram &shader, const char *name)
{
bind(cubemapI);
glUniform1i(shader.uniformLocation(name), cubemapI);
}
Cubemap::~Cubemap()
{
glDeleteTextures(1, &textureId);
std::cout << "Cubemap " << textureId << " destroyed\n";
} |
4c51faf8520555829d373e31c9d66c8fd176a965 | 1501f50acc22b9e915d04df435210d68e2a907ee | /include/UnityEngine/AvatarTarget.hpp | 116e102fc4c09ff26d365b07480df2142ce1ab51 | [
"Unlicense"
] | permissive | sc2ad/BeatSaber-Quest-Codegen | cd944128d6c7b61f2014f13313d2d6cf424df811 | 4bfd0c0f705e7a302afe6ec1ef996b5b2e3f4600 | refs/heads/master | 2023-03-11T11:07:22.074423 | 2023-02-28T22:15:16 | 2023-02-28T22:15:16 | 285,669,750 | 31 | 25 | Unlicense | 2023-02-28T22:15:18 | 2020-08-06T20:56:01 | C++ | UTF-8 | C++ | false | false | 4,435 | hpp | AvatarTarget.hpp | // Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
#include "beatsaber-hook/shared/utils/byref.hpp"
// Including type: System.Enum
#include "System/Enum.hpp"
// Completed includes
// Type namespace: UnityEngine
namespace UnityEngine {
// Forward declaring type: AvatarTarget
struct AvatarTarget;
}
#include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp"
DEFINE_IL2CPP_ARG_TYPE(::UnityEngine::AvatarTarget, "UnityEngine", "AvatarTarget");
// Type namespace: UnityEngine
namespace UnityEngine {
// Size: 0x4
#pragma pack(push, 1)
// Autogenerated type: UnityEngine.AvatarTarget
// [TokenAttribute] Offset: FFFFFFFF
struct AvatarTarget/*, public ::System::Enum*/ {
public:
public:
// public System.Int32 value__
// Size: 0x4
// Offset: 0x0
int value;
// Field size check
static_assert(sizeof(int) == 0x4);
public:
// Creating value type constructor for type: AvatarTarget
constexpr AvatarTarget(int value_ = {}) noexcept : value{value_} {}
// Creating interface conversion operator: operator ::System::Enum
operator ::System::Enum() noexcept {
return *reinterpret_cast<::System::Enum*>(this);
}
// Creating interface conversion operator: i_Enum
inline ::System::Enum* i_Enum() noexcept {
return reinterpret_cast<::System::Enum*>(this);
}
// Creating conversion operator: operator int
constexpr operator int() const noexcept {
return value;
}
// static field const value: static public UnityEngine.AvatarTarget Root
static constexpr const int Root = 0;
// Get static field: static public UnityEngine.AvatarTarget Root
static ::UnityEngine::AvatarTarget _get_Root();
// Set static field: static public UnityEngine.AvatarTarget Root
static void _set_Root(::UnityEngine::AvatarTarget value);
// static field const value: static public UnityEngine.AvatarTarget Body
static constexpr const int Body = 1;
// Get static field: static public UnityEngine.AvatarTarget Body
static ::UnityEngine::AvatarTarget _get_Body();
// Set static field: static public UnityEngine.AvatarTarget Body
static void _set_Body(::UnityEngine::AvatarTarget value);
// static field const value: static public UnityEngine.AvatarTarget LeftFoot
static constexpr const int LeftFoot = 2;
// Get static field: static public UnityEngine.AvatarTarget LeftFoot
static ::UnityEngine::AvatarTarget _get_LeftFoot();
// Set static field: static public UnityEngine.AvatarTarget LeftFoot
static void _set_LeftFoot(::UnityEngine::AvatarTarget value);
// static field const value: static public UnityEngine.AvatarTarget RightFoot
static constexpr const int RightFoot = 3;
// Get static field: static public UnityEngine.AvatarTarget RightFoot
static ::UnityEngine::AvatarTarget _get_RightFoot();
// Set static field: static public UnityEngine.AvatarTarget RightFoot
static void _set_RightFoot(::UnityEngine::AvatarTarget value);
// static field const value: static public UnityEngine.AvatarTarget LeftHand
static constexpr const int LeftHand = 4;
// Get static field: static public UnityEngine.AvatarTarget LeftHand
static ::UnityEngine::AvatarTarget _get_LeftHand();
// Set static field: static public UnityEngine.AvatarTarget LeftHand
static void _set_LeftHand(::UnityEngine::AvatarTarget value);
// static field const value: static public UnityEngine.AvatarTarget RightHand
static constexpr const int RightHand = 5;
// Get static field: static public UnityEngine.AvatarTarget RightHand
static ::UnityEngine::AvatarTarget _get_RightHand();
// Set static field: static public UnityEngine.AvatarTarget RightHand
static void _set_RightHand(::UnityEngine::AvatarTarget value);
// Get instance field reference: public System.Int32 value__
[[deprecated("Use field access instead!")]] int& dyn_value__();
}; // UnityEngine.AvatarTarget
#pragma pack(pop)
static check_size<sizeof(AvatarTarget), 0 + sizeof(int)> __UnityEngine_AvatarTargetSizeCheck;
static_assert(sizeof(AvatarTarget) == 0x4);
}
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
|
1193af089384b78a2b73c28e854c3fbd237cc286 | 5f95a1fb02a372bc49d5f6758727c9736781bfbb | /eyes_2018/SpritePixel.h | cf910d3359d78b0d98961ed97daacb13158d1466 | [] | no_license | pmrobotix/EYES | 52014d9246e7f950c3032ce7f63bc33e814c6c58 | 5c8043f02c840e52a6db96418dd88d9a499818ec | refs/heads/master | 2023-05-02T20:20:00.703705 | 2023-04-20T14:29:35 | 2023-04-20T14:29:35 | 85,198,828 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 484 | h | SpritePixel.h | /*
* SpritePixel.h
*
* Created on: 8 avr. 2018
* Author: gmo
*/
#ifndef SPRITEPIXEL_H_
#define SPRITEPIXEL_H_
namespace eyes {
class SpritePixel {
public:
char mX;
char mY;
unsigned char mRed;
unsigned char mGreen;
unsigned char mBlue;
SpritePixel(char x, char y, unsigned char red, unsigned char green, unsigned char blue);
SpritePixel();
void setColour(unsigned short rgb565);
};
} /* namespace eyes */
#endif /* SPRITEPIXEL_H_ */
|
fe827886c198765f0f66657719dc1172958a12ff | c26f4e6bef5c01e924e981a99f0848c36287751c | /ArduinoTest/ARDUINO_CODE/ARDUINO_CODE.ino | e997ab96288197b652921e6ad030ea6a4b3bed50 | [] | no_license | rbalaz/liveproject3dglove- | cf82ef5a8cd06e6a08706f97f497ba17155bdef7 | 5422be6d2c254370a39ccb77dd613e4e2a454a85 | refs/heads/master | 2021-09-07T01:29:25.123133 | 2018-02-14T19:28:40 | 2018-02-14T19:28:40 | 106,589,845 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,283 | ino | ARDUINO_CODE.ino | #include <Servo.h>
Servo servo1;
int servoPos = 0;
const int MAX_BUFFER_LEN = 30;
char rcvBuffer[MAX_BUFFER_LEN];
bool newData = false;
void setup()
{
servo1.attach(9);
servo1.write(0);
Serial.begin(115200);
Serial.setTimeout(100);
}
void loop()
{
receiveData();
controlServo();
}
void receiveData()
{
static int i = 0;
char endTag = '#';
char rcv;
while (Serial.available() > 0 && !newData)
{
rcv = Serial.read();
/* Serial.print("rcv: ");
Serial.println(rcv);*/
if (rcv != endTag)
{
rcvBuffer[i] = rcv;
i++;
if (i >= MAX_BUFFER_LEN)
{
i = MAX_BUFFER_LEN - 1;
}
}
else
{
rcvBuffer[i] = '\0';
i = 0;
newData = true;
/*Serial.print("rcvBuffer: ");
Serial.println(rcvBuffer);
Serial.print("i: ");
Serial.println(i);*/
}
}
}
void controlServo()
{
if (newData == true)
{
int incPos = atoi(rcvBuffer);
/* Serial.print("incpos: ");
Serial.println(incPos);*/
servoPos = constrain(incPos, 0, 164);
servo1.write(servoPos);
newData = false;
}
}
|
2f1f6e1ff9c9f80e3b611993dcb47f83b66d1513 | ae55176b3fe4fc9b77ee0af71f142e174a65cf60 | /GameAI/steering/BoxCollider.cpp | f3daef11b25a17c0829560e015aff1b3c94c1721 | [] | no_license | theMagicDunky/EGP-410 | a055405067ecd345fccd3d8c6029249f2de64ce2 | 35ce0d4e427150d97321a3f7c3cc95aa70d11f83 | refs/heads/master | 2021-01-23T02:22:57.208580 | 2016-12-17T04:58:33 | 2016-12-17T04:58:33 | 68,652,319 | 0 | 1 | null | 2016-09-19T22:34:32 | 2016-09-19T22:34:31 | null | UTF-8 | C++ | false | false | 1,419 | cpp | BoxCollider.cpp | #include "BoxCollider.h"
BoxCollider::BoxCollider(Vector2D topCorner, Vector2D bottomCorner)
:mTopLeftCorner(topCorner), mBottomRightCorner(bottomCorner)
{
}
BoxCollider::~BoxCollider()
{
}
//calculates center using width length and adding half to the corrdinates of the top left corner
Vector2D BoxCollider::getCenter() const
{
Vector2D center;
float x = mBottomRightCorner.getX() - mTopLeftCorner.getX();
float y = mBottomRightCorner.getY() - mTopLeftCorner.getY();
center.setX(mTopLeftCorner.getX() + (x / 2));
center.setY(mTopLeftCorner.getY() + (y / 2));
return center;
}
float BoxCollider::getWidth() const
{
return mBottomRightCorner.getX() - mTopLeftCorner.getX();
}
float BoxCollider::getHeight() const
{
return mBottomRightCorner.getY() - mTopLeftCorner.getY();;
}
//check if bound of rectangles intersect with each other
bool BoxCollider::checkCollision(BoxCollider * coll)
{
if (mBottomRightCorner.getX() < coll->getTopCorner().getX())
return false;
if (mTopLeftCorner.getX() > coll->getBottomCorner().getX())
return false;
if (mBottomRightCorner.getY() < coll->getTopCorner().getY())
return false;
if (mTopLeftCorner.getY() > coll->getBottomCorner().getY())
return false;
return true;
}
void BoxCollider::update(Vector2D deltaDistance)
{
mTopLeftCorner += deltaDistance;
mBottomRightCorner += deltaDistance;
//std::cout << "y: " << mTopLeftCorner.getY() << std::endl;
} |
c2a168f8a8bcce9af5ae9a0e41b965b87368ba0f | 358168e463be15ca76f223229339af136cf33eb5 | /Enemy.h | a2a2f56779ba45dfa0a7b9d9098fa5b3b17ff779 | [] | no_license | josaph17/MyGame | 562686cba38693e09637d38e3fd97500934df98c | a23b33bb3933e1c0c6aa0b3e9caeb273ad028a5e | refs/heads/main | 2023-03-13T20:18:14.988790 | 2021-03-04T09:33:07 | 2021-03-04T09:33:07 | 321,710,925 | 1 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 447 | h | Enemy.h | #include <iostream>
#include "Matrix.h"
#include "Personage.h"
#include "Player.h"
#pragma once
class Enemy: public Personage
{
public:
Enemy(Matrix* /*_board*/, Player* /*_player*/);/*board не нужно иначе это будет другой board,
не важно, где он будет, в private или public*/
void GoDown();
void GoUp();
void GoRight();
void GoLeft();
virtual void Step();
protected:
Player* player;
}; |
cd972e436ec56286c61d757091060df33b704eef | cd11bddfb93701d5d1df2848328cd9f6f3bcc750 | /src/net/smbclient.cpp | fa607f82dcb8d84d0992fba267c091792b8d8bc7 | [] | no_license | denniscaudell/scout | 193ca18aa2d68784314ced20f24235e3aaa9f401 | c992a05303e9b39e440a48dcc7a65d53c7d24b4f | refs/heads/master | 2021-04-27T12:58:07.902919 | 2017-11-25T10:25:25 | 2017-11-25T10:25:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,787 | cpp | smbclient.cpp | #include "smbclient.h"
/**
* @brief SMBClient::SMBClient
* @param parent
*/
SMBClient::SMBClient(QObject *parent) : QObject(parent)
{
this->pool = QList<QProcess *>();
this->hostsRemaining = 0;
}
/**
* @brief SMBClient::prepareResult
*/
void SMBClient::prepareResult()
{
// Iterate process and add result to internal results buffer
QProcess *process;
foreach(process, this->pool) {
QString rawOutput = process->readAll();
emit this->collectorOutput(rawOutput);
QProcessEnvironment env = process->processEnvironment();
QString ip = env.value("HOST");
QList<Host::Share> shares = this->parseProcessOutput(ip , rawOutput);
this->addSharesToHost(ip, shares);
if (process->isOpen()) {
process->close();
}
}
emit this->collectorFinished(this->results);
}
/**
* @brief SMBClient::parseOutput
* @return
*/
QList<Host::Share> SMBClient::parseProcessOutput(QString ip, QString rawOutput)
{
QList<Host::Share> shares;
QStringList shareLines = rawOutput.split("\n");
QString line;
foreach(line, shareLines) {
QStringList parts = line.split("|");
if (parts.length() > 1) {
Host::Share share;
share.ip = ip;
share.type = parts.at(0).trimmed();
share.name = parts.at(1).trimmed();
share.comment = parts.at(2).trimmed();
shares.append(share);
}
}
return shares;
}
/**
* @brief SMBClient::addSharesToHost
* @param ip
* @param shares
*/
void SMBClient::addSharesToHost(QString ip, QList<Host::Share> shares)
{
Host *host;
foreach(host, this->results) {
if (QString::compare(host->ip, ip)) {
host->shares = shares;
// Nothing more to do here
return;
}
}
}
/**
* @brief SMBClient::start
* @param hosts
*/
void SMBClient::start(QList<Host *> hosts)
{
if(hosts.length() == 0) {
emit this->collectorError("No hosts to collect");
return;
}
this->hostsRemaining = hosts.length();
this->results = hosts;
QString program = "/usr/bin/smbclient";
Host *host;
foreach(host, hosts) {
QProcess *process = new QProcess(this);
QProcessEnvironment env = QProcessEnvironment();
env.insert("HOST", host->ip);
process->setProcessEnvironment(env);
connect(process, SIGNAL(finished(int)), this, SLOT(onProcessFinished(int)));
connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onProcessError(QProcess::ProcessError)));
QStringList args;
args.append("-g");
args.append("-N");
args.append("-L" + host->ip);
process->start(program, args);
QString command = process->program() + " " + process->arguments().join(" ");
emit this->collectorOutput("<b style=\"color: rgb(145, 255, 98);\">" + command + "</b>");
this->pool.append(process);
}
}
/**
* @brief SMBClient::onSingleHostFinished
* @param rawOutput
*/
void SMBClient::onProcessFinished(int status)
{
this->hostsRemaining--;
emit this->progressUpdate(this->results.length() - this->hostsRemaining);
if (0 != status) {
qDebug() << "Process finished with strange status: " + QString::number(status);
}
if (0 == this->hostsRemaining) {
this->prepareResult();
}
}
/**
* @brief SMBClient::onProcessError
*/
void SMBClient::onProcessError(QProcess::ProcessError error)
{
this->hostsRemaining--;
emit this->progressUpdate(this->results.length() - this->hostsRemaining);
qDebug() << "Collector process ERROR with code: " + QString::number(error);
if (0 == this->hostsRemaining) {
this->prepareResult();
}
}
|
528069af5bed69da27d4c126f77d3aab6fb02859 | 008606671393ce8bf51ebce7eb9f609735319874 | /src/AABB.h | 74bbb2498278cdd42587f0485ada2144927971f1 | [] | no_license | cpecoraro18/Game | 8eb7518d87713036c930c2eee506afbe653dfdf0 | 30a75dfd549277896dc8d07165fa3c1d9565d478 | refs/heads/master | 2021-07-13T10:51:30.100567 | 2020-08-21T21:59:23 | 2020-08-21T21:59:23 | 196,301,960 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 409 | h | AABB.h | #pragma once
#ifndef SRC_AABB_H_
#define SRC_AABB_H_
class AABB {
public:
AABB(float x, float y, float width, float height);
AABB() {}
void setDimentions(float x, float y);
void setDimentions(float x, float y, float width, float height);
AABB Union(AABB a, AABB b);
float Area();
float rightside;
float leftside;
float bottom;
float top;
float width;
float height;
};
#endif /* SRC_AABB_H_ */ |
c442421732a1502ab5aa2e53c98253db1f2011ed | 565e7cf2dd4a879dbc9fde81f9fac05d029260f1 | /Speaker.cpp | dd3eab22cd44705caeafb9d1f9f7ba3cc929bce4 | [] | no_license | TheresaBultinck/ProjectlabElektronicaICT1 | c7714665462db62169ef85013077db97e9ccd768 | b55ed287875089522d7cc7c85379d8d6e6e798e8 | refs/heads/master | 2021-04-18T18:42:31.843048 | 2018-03-23T13:47:14 | 2018-03-23T13:47:14 | 126,490,871 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,421 | cpp | Speaker.cpp | #include "Speaker.h"
int Speaker :: frequency[17] = { 110, 110, 110, 98, 130, 110, 98, 130, 110, 165, 165, 165, 175, 130, 104, 98, 130 };
int Speaker :: length[17] = {480, 480, 480, 360, 120, 480, 360, 120, 960, 480, 480, 480, 360, 120, 480, 360, 120};
int Speaker :: delay[17] = {100, 100, 100, 75, 100, 100, 75, 100, 100, 100, 100, 100, 75, 100, 100, 75, 100};
Speaker :: Speaker() : speakerPin(p26) {}
bool Speaker :: play(string start, string stop)
{
/**
String argumenten moeten worden omgevormd naar integers om te kunnen gebruiken in de gedefinieerde arrays.
Dit kan gebeuren aan de hand van de methode atoi() (in library std) die strings zal omzetten naar integers, maar atoi() verwacht als argument
een pointer naar een character van arrays. Vandaar wordt functie c_str() aangeroepen op de argumenten start en stop.
*/
int begin = std::atoi(start.c_str());
int end = std::atoi(stop.c_str());
/**
Opgegeven argumenten komen niet overeen met de mogelijke waarden in de tabel.
*/
if(end < begin || begin < 1 || begin > 17 || end < 1 || end > 17)
return false;
for(int i = begin; i <= end; i++) {
speakerPin.period(1.0 / frequency[i-1]);
speakerPin = 0.5;
//Delen door 1000, want werken in milliseconden
wait(length[i-1]/1000.0);
speakerPin = 0.0;
wait(delay[i-1]/1000.0);
}
return true;
} |
e65b9b510f350d3f5ee713ed51b4374d36e8ff51 | a5c3b4d98ddc0d9f919fa5597580cceb39bd5072 | /week_4/2016201096GJC/src/HTMLParser.cpp | fe69dfb3e9a97def42d8a5bfed65ebfc61454e67 | [] | no_license | WhiteCatFly/Turing_Student_Code_2019 | 17f4ed781327706b14b66ef90b0b90478792915b | 4d744f6a3072dc9184c10c5daad60dee4a83a588 | refs/heads/master | 2021-06-15T02:32:07.977336 | 2019-07-05T07:06:32 | 2019-07-05T07:06:32 | 173,031,113 | 8 | 27 | null | 2020-01-09T01:44:23 | 2019-02-28T03:04:38 | C++ | UTF-8 | C++ | false | false | 3,016 | cpp | HTMLParser.cpp | #include "HTMLParser.h"
void HTMLParser::DownloadFromUrl(){
std::stringstream downloadOrder;
downloadOrder << "curl ";
downloadOrder << url_;
downloadOrder << " >> ";
downloadOrder << location_;
std::cout << downloadOrder.str() << std::endl;
system(downloadOrder.str().c_str());
}
HTMLParser::HTMLParser(string url){
url_ = url;
location_ = GetCmdResult("pwd");
location_ = location_.append("/htmlFile.html");
DownloadFromUrl();
std::ifstream inhtml;
inhtml.open(location_);
string tmp;
while(getline(inhtml,tmp)){
tmp += '\n';
html_ += tmp;
}
inhtml.close();
}
HTMLParser::~HTMLParser(){
std::stringstream rmOrder;
rmOrder << "rm ";
rmOrder << location_;
system(rmOrder.str().c_str());
}
HTMLParser::HTMLParser(std::ifstream &file){
string tmp;
while(getline(file, tmp)){
tmp += '\n';
html_ += tmp;
}
}
string HTMLParser::GetTitle(){
string regularExpression = "<title>[\\s\\S]*?</title>";
std::regex linkxp(regularExpression);
string title;
for (std::sregex_iterator it(html_.begin(), html_.end(), linkxp), end; it != end; ++it){
title = it->str();
}
title.erase(0, 7);
title.erase(title.length()-8, 8);//7 and 8 is the length of <title> and </title>
return title;
}
string HTMLParser::replace(string str, string pattern, string repattern){
string retStr = "";
string::size_type pos;
int i = 0, l_count = 0, szStr = str.length();
int count = szStr;
for(i = 0; i < szStr; i++){
if(string::npos == (pos=str.find(pattern,i))) break;
if(pos < szStr){
retStr += str.substr(i,pos-i) + repattern;
i = pos + pattern.length() - 1;
if(++l_count >= count){
i++;
break;
}
}
}
retStr += str.substr(i);
return retStr;
}
void HTMLParser::DeleteLabel(string& body){
string regularExpression = "<[^>]*>";
std::regex linkxp(regularExpression);
std::vector<string>labels;
for (std::sregex_iterator it4(body.begin(), body.end(), linkxp), end; it4 != end; ++it4){
string label = it4->str();
labels.push_back(label);
}
for (int i = 0; i < labels.size(); i++){
body = replace(body, labels[i], "");
}
}
string HTMLParser::GetBody(){
string regularExpression = "<p>[\\s\\S]*</p>";
string body;
std::regex linkxp(regularExpression);
for (std::sregex_iterator it2(html_.begin(), html_.end(), linkxp), end; it2 != end; ++it2){
body = it2->str();
}
body = replace(body, " ", " ");
body = replace(body, "“", "“");
body = replace(body, "”", "”");
DeleteLabel(body);
//std::cout << "body = " << body << std::endl;
return body;
}
string HTMLParser::GetSubLinks(){
string regularExpression = "href\\s*=\\s*(?:\"([^\"]*)\"|\'([^\']*)\'|([^\"\'>\\s]+))";
std::regex linkxp(regularExpression);
string subLinks;
for (std::sregex_iterator it3(html_.begin(), html_.end(), linkxp), end; it3 != end; ++it3){
string link = it3->str();
if (link.find("css") == string::npos){
link.erase(0, 5);//5 is the length of href=
subLinks += link;
subLinks += "\n";
}
}
return subLinks;
}
|
0027f8b98520e161c13787bb5dc43274215a8b85 | 7beb8f24e96cbe6e647b3657912c8d99d97f2ec0 | /codes/subset1.cpp | 004af5ecf002603a49647388ae88d05f41a82352 | [] | no_license | Yash0150/Competitive-Coding | 5fd3fa05d09b02084f241853dbd89c5d650cd0b8 | 13431f8f41565a844d54b1326e0ef96224eaff5f | refs/heads/master | 2020-11-24T12:27:54.976944 | 2019-12-15T07:06:42 | 2019-12-15T07:06:42 | 228,142,503 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 245 | cpp | subset1.cpp | #include<bits/stdc++.h>
using namespace std;
int subset(string s){
for(int i=0; i<pow(2,s.size()); i++){
for(int j=0;j<s.size();j++){
if(i&(1<<j)){
cout<<s[j];
}
}
cout<<endl;
}
}
int main(){
string s;
cin>>s;
subset(s);
} |
bf75135c2e938cf513844b92d4035d0dc7f2a336 | ea5a6df3eb3345e0b579a91abe63d30d53854e00 | /prob_11988.cpp | 7815ded6e46250ddd051b7d2f82ab401bc55c4c5 | [] | no_license | abhicse32/UVa-Solutions | ce7032dc29cf37235ee44c4e34bddd4151524954 | 7dd80345f18401d36002a4dbcc74234bb414be2b | refs/heads/master | 2022-03-21T22:36:35.598712 | 2019-11-24T17:24:46 | 2019-11-24T17:24:46 | 93,602,706 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 791 | cpp | prob_11988.cpp | #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <climits>
#include <list>
#define rep(i,a,b) for(i=a;i<b;++i)
#define vectIter(vect) for(auto &val: vect)
#define mapIter(map_) for(auto &val_: map_)
#define gc getchar_unlocked
using namespace std;
int main(int argc, char* argv[]){
string str;
list<char> lst;
int i,j,k;
while(getline(cin,str)){
lst.clear();
auto iter=lst.begin();
for(auto& val: str){
if(val=='[')
iter=lst.begin();
else if(val==']')
iter=lst.end();
else lst.insert(iter,val);
}
string str1(lst.begin(),lst.end());
cout << str1 <<endl;
}
} |
a9f05016f86eaaf8dda5d0ea0f21523a9de8e7d0 | 15d575dd84ac83c6175531ff405046a57791b9f6 | /vector.hpp | c9679efe291501d16b6ceff28b1185bc8c5b6c12 | [] | no_license | trash-repos/_foo_liquid_model | a59e396cba4014ba271303a868bc7d0c708d441f | 6f16ebddabc6bdc3b004d39a3f1d6ae97d1087a7 | refs/heads/master | 2021-01-10T22:10:42.475930 | 2014-05-03T21:39:51 | 2014-05-03T21:39:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 711 | hpp | vector.hpp | #ifndef VECTOR_H
#define VECTOR_H
#include "math.hpp"
class Vector {
public:
float x;
float y;
Vector(float x, float y){
this->x = x;
this->y = y;
};
const Vector clone(){ return Vector(this->x, this->y); };
Vector times(float s);
Vector add(Vector v);
Vector add(Vector* v){ return this->add(*v); };
const float dist(Vector v);
const float dist(Vector* v){ return this->dist(*v); };
const float dir(Vector v);
const float dir(Vector* v){ return this->dir(*v); };
const float abs();
const float angle();
};
class VectorAngle: public Vector {
public:
VectorAngle(float s,float a): Vector(x,y){
this->x = cos(a)*s;
this->y = sin(a)*s;
};
};
#endif
|
d2a2e91ba92fc8c40b3c0224fc13a4d81969deef | fac759e1b130227629cbfab3f7b339a4276b3c1a | /include/pxcblobmodule.h | 489e5cff390181b60d52165e853f07fe26ab7430 | [] | no_license | ks32/libpxc | a289dd04741ebe9c4fb51faa36558b41e7e4f5fa | 60ab38ac4e9f3d5fc3bb3e844b21247605102a49 | refs/heads/master | 2020-09-23T22:58:13.797052 | 2016-06-13T07:48:53 | 2016-06-13T07:48:53 | 250,139,376 | 0 | 4 | null | 2020-03-26T02:14:33 | 2020-03-26T02:14:33 | null | UTF-8 | C++ | false | false | 2,623 | h | pxcblobmodule.h | /*
Copyright (c) 2011-2015, Intel Corporation
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "pxcblobconfiguration.h"
#include "pxcblobdata.h"
/**
@Class PXCBlobModule
@brief The main interface to the blob module's classes.
The blob module allows you to extract "blobs" (silhouettes of objects identified by the sensor) and their contour lines.
Use the PXCBlobModule interface to access to the module's configuration and blob and contour line data.
*/
class PXCBlobModule : public PXCBase
{
public:
PXC_CUID_OVERWRITE(PXC_UID('B','M','M','D'));
/**
@brief Create a new instance of the blob module's active configuration.
Use the PXCBlobConfiguration object to examine the current configuration or to set new configuration values.
@return A pointer to the configuration instance.
@see PXCBlobConfiguration
*/
virtual PXCBlobConfiguration* PXCAPI CreateActiveConfiguration() = 0;
/**
@brief Create a new instance of the blob module's output data (extracted blobs and contour lines).
@return A pointer to a PXCBlobData instance.
@see PXCBlobData
*/
virtual PXCBlobData* PXCAPI CreateOutput() = 0;
};
|
5fa2c7a77903e99a9ca17894a350eb4ce56cf1eb | 5d14e99d5090f019cb9ed18516a7325a67095ca6 | /ACM/2027/6946822_AC_0MS_204K.cpp | 00afd15d0979c8569f26d4c6c06b76e35d0abf45 | [] | no_license | jxlh999/Fantasia | 33e2543b56dd3626ebd6a1b8ccffc6f8c8af221a | f8494dfe86957c344f87707ae01c2a7e62036218 | refs/heads/master | 2020-06-06T15:26:08.159052 | 2013-02-17T14:19:09 | 2013-02-17T14:19:09 | 3,493,450 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 388 | cpp | 6946822_AC_0MS_204K.cpp | #include <iostream>
using namespace std;
int main() {
int num = 0;
int x = 0;
int y = 0;
int i = 0;
char *result[100];
cin >> num;
for (i = 0; i < num; i++) {
cin >> x;
cin >> y;
if (x >= y) {
result[i] = "MMM BRAINS";
} else {
result[i] = "NO BRAINS";
}
}
for (int j = 0; j < i; j++) {
cout << result[j] << endl;
}
return 0;
}
|
20942fe532522a76968d61340ea68a0db17bce4d | b64471cfaaa3af165df272505dc9894056378262 | /source/kernel/membench/cache.h | e7af4b5ecff5d24a78821d42cf4f90e4c03f593a | [
"MIT"
] | permissive | PFLab-OS/Raph_Kernel | 94f39ecc2f7ceaf45284542d83ec3b55bc62c1a0 | 1ceab607ed0fde16286f49bc83aef840028b3ea4 | refs/heads/develop | 2019-07-31T01:27:27.534438 | 2018-04-29T03:49:40 | 2018-04-29T03:49:40 | 55,387,285 | 17 | 1 | null | 2018-04-29T03:49:40 | 2016-04-04T05:30:56 | C | UTF-8 | C++ | false | false | 2,268 | h | cache.h | /*
*
* Copyright (c) 2017 Raphine Project
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* Author: Liva
*
*/
#pragma once
#include <cpu.h>
#include <tty.h>
#include <global.h>
class CacheCtrl {
public:
void Init() {
int cpuid = cpu_ctrl->GetCpuId().GetRawId();
if (cpuid == 0) {
// CLFLUSHOPT exists?
uint32_t regs[4];
asm volatile("cpuid;"
: "=a"(regs[0]), "=b"(regs[1]), "=c"(regs[2]), "=d"(regs[3])
: "a"(7), "c"(0));
if ((regs[1] & (1 << 23)) != 0) {
gtty->Printf("info: CLFLUSHOPT exists!\n");
_use_clflushopt = true;
}
// CLFLUSH exists?
asm volatile("cpuid;"
: "=a"(regs[0]), "=b"(regs[1]), "=c"(regs[2]), "=d"(regs[3])
: "a"(1));
if ((regs[3] & (1 << 19)) == 0) {
gtty->Printf("error: CLFLUSH not exists!\n");
kassert(false);
}
// cache line size
asm volatile("cpuid;"
: "=a"(regs[0]), "=b"(regs[1]), "=c"(regs[2]), "=d"(regs[3])
: "a"(1));
_cacheline_size = ((regs[1] >> 8) & 0xFF) * 8;
gtty->Printf("info: cacheline size is %d.\n", _cacheline_size);
}
}
template <class T>
void Clear(T *ptr, size_t size) {
// use clflushopt if it exists
for (size_t i = 0; i < size; i += _cacheline_size) {
__builtin_ia32_clflush(
reinterpret_cast<void *>(reinterpret_cast<uint8_t *>(ptr) + i));
}
}
private:
bool _use_clflushopt = false;
size_t _cacheline_size = 0;
};
extern CacheCtrl *cache_ctrl;
|
d1cb9b2bd6a529ade21ae089f462df8d62ee4ad4 | 74fc7c5d39baa6c30aa929e629ff60bf40500c61 | /test/unit-tests/metafs/mim/mio_handler_mock.h | 347fcf15bb98505b810931696ed888e9847d1347 | [
"BSD-3-Clause"
] | permissive | jhyunleehi/poseidonos | e472be680d0e85dc62f0e2c0d7356dbee74a3bd6 | 1d90e4320855d61742ff37af8c0148da579d95d4 | refs/heads/develop | 2023-07-13T03:37:29.754509 | 2021-08-23T15:26:08 | 2021-08-23T15:26:08 | 393,203,347 | 0 | 0 | BSD-3-Clause | 2021-08-20T00:04:14 | 2021-08-06T00:30:35 | C | UTF-8 | C++ | false | false | 244 | h | mio_handler_mock.h | #include <gmock/gmock.h>
#include <list>
#include <string>
#include <vector>
#include "src/metafs/mim/mio_handler.h"
namespace pos
{
class MockMioHandler : public MioHandler
{
public:
using MioHandler::MioHandler;
};
} // namespace pos
|
9af22c3a0189b3efe543479f40644e96de98956b | 07518b924a59ca49da1e027b98ef3757fb1c1518 | /GDW4_Game/Classes/Boss/Ability States/BossIdleState.cpp | 91e819edee2f7c82c075b8104eb1d408dfce55d9 | [] | no_license | MatKostDev/EchosOfArem-GDW4-Game | 5e5c26d646a25ff302c5fb46f11bd52181cc15fa | 50117cade970ca5f0943b82177fd6877c50cdf0b | refs/heads/master | 2021-10-25T09:59:30.147183 | 2019-04-03T18:35:15 | 2019-04-03T18:35:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,544 | cpp | BossIdleState.cpp | #include "BossIdleState.h"
#include "Boss/General/Boss.h"
//Static function initialize
int Idling4FirstBoss::numberOfCast = 0;
const int Idling4FirstBoss::maxNumberOfCastPerRound = 7;
Idling4FirstBoss::Idling4FirstBoss(Boss *boss)
: FirstBossState(boss), cooldownBeforeNextAbility{ 2.5f }
{
//Get the animation
const auto animationForIdling = marcos::AnimationManager::getAnimation("boss_idle_animation_key");
//Run the animation
boss->getSprite()->stopAllActions();
boss->getSprite()->runAction(cocos2d::RepeatForever::create(animationForIdling));
}
/**
* @brief Delete number of cast to 0
*/
Idling4FirstBoss::~Idling4FirstBoss()
{
}
/**
* @brief Updates the idling time. When the time reaches
* 0, the boss will perform an ability
*
* @param deltaT The change of time from last frame to current
* frame
*/
void Idling4FirstBoss::update(const float &deltaT)
{
cooldownBeforeNextAbility -= deltaT;
//Start shooting ability
if (cooldownBeforeNextAbility <= 0)
{
bossPointer->getSprite()->stopAllActions();
if (numberOfCast == maxNumberOfCastPerRound)
{
numberOfCast = 0;
changeToRestingState();
}
else
{
numberOfCast++;
chooseRandomAbility();
}
}
}
/**
* @brief Chooses a random ability to perform
*/
void Idling4FirstBoss::chooseRandomAbility()
{
const int randomNum = cocos2d::RandomHelper::random_int(1, 20);
if (randomNum >= 1 && randomNum <= 5)
changeToExplosiveBullet();
else if (randomNum >= 6 && randomNum <= 14)
changeToFlameSplit();
else
changeToFlameThrower();
} |
a6d2940b8838d2bc44183e2699ec4bf84ee4987c | d92936d392ead7413e203f169f821215b9af3166 | /labs/lab1/Radix/Radix.cpp | 60b78a1b3ee66417e369007d2c271e9958254751 | [
"MIT"
] | permissive | denis-petrov/oop | 1d98fc5b500106becc4db57575673a5e8dfa1547 | 6bd2679e8f2f39f41cf6520cbbeafa8c01c7bc96 | refs/heads/main | 2023-05-05T22:08:21.847355 | 2021-05-24T08:11:50 | 2021-05-24T08:11:50 | 337,420,820 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,070 | cpp | Radix.cpp | // Radix.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "Radix.h"
#include <cmath>
#include <iostream>
#include <optional>
#include <string>
struct Args
{
std::string sourceNotation;
std::string destinationNotation;
std::string value;
};
struct Error
{
bool wasError;
std::string message;
};
const int ASCII_MINUS = 45;
const int ASCII_ZERO = 48;
const int ASCII_NINE = 57;
const int ASCII_A = 65;
const int ASCII_Z = 90;
const int COEF_FOR_CONVERT_LETTER = 55;
const int INCORRECT_SYMBOL = -1;
std::optional<Args> ParseArgs(int argc, char* argv[])
{
if (argc != 4)
{
std::cout << "Invalid argument count.\n";
std::cout << "Usage: CopyFile.exe <source notation> <destination notation> <value>.\n";
return std::nullopt;
}
Args args;
args.sourceNotation = argv[1];
args.destinationNotation = argv[2];
args.value = argv[3];
return args;
}
char IntToSymbol(const int value)
{
char convert[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
return convert[value];
}
int SymbolToInt(const char symbol)
{
int symbolCode = symbol;
if (symbolCode == ASCII_MINUS)
{
return ASCII_MINUS;
}
else if ((ASCII_ZERO <= symbolCode) && (symbolCode <= ASCII_NINE))
{
return (symbolCode - ASCII_ZERO);
}
else if ((ASCII_A <= symbolCode) && (symbolCode <= ASCII_Z))
{
return (symbolCode - COEF_FOR_CONVERT_LETTER);
}
else
{
return INCORRECT_SYMBOL;
}
}
bool IsFoundFirstMinusInString(const int symbolInt, const bool& isMinusMet)
{
return (symbolInt == ASCII_MINUS) && (!isMinusMet);
}
void ValidateFirstMetMinusInString(const int symbolInt, bool& isMinusMet, const size_t& position, int& power, Error& error)
{
if (IsFoundFirstMinusInString(symbolInt, isMinusMet))
{
if (position == 0)
{
isMinusMet = true;
power--;
}
else
{
error.message = "Position of minus is incorrect. \n";
error.wasError = true;
}
}
}
bool IsSymbolIncorrectInNotation(const int symbolInt, const int radix)
{
return ((symbolInt >= radix) || (symbolInt == INCORRECT_SYMBOL));
}
bool IsCurrentIsNotMinus(const bool& isMinusMet, const size_t& position)
{
return ((isMinusMet) && (position != 0)) || (!isMinusMet);
}
void ValidateSymbolLessMaxInNotation(const int symbolInt, const bool& isMinusMet, const int radix, const std::string& value, const size_t& position, Error& error)
{
if (IsSymbolIncorrectInNotation(symbolInt, radix) && IsCurrentIsNotMinus(isMinusMet, position))
{
std::string symbol(1, value[position]);
error.message = "Symbol " + symbol + std::string(" is incorrect in ") + std::to_string(radix) + " notation. \n";
error.wasError = true;
}
}
bool IsOverflow(const int number, const int digit, const int radix, const bool& isMinusMet)
{
if (!isMinusMet)
{
return ((number >= (INT_MAX / radix)) && (abs(digit) > (INT_MAX % radix))) || (number < 0);
}
else
{
return ((number <= (INT_MIN / radix)) && (abs(digit) > abs(INT_MIN % radix)));
}
}
int StringToInt(const std::string& value, const int radix, Error& error)
{
bool isMinusMet = false;
int result = 0;
for (size_t i = 0; i < value.length(); i++)
{
int currentDigit = SymbolToInt(value[i]);
int power = value.length() - (i + 1);
if (!isMinusMet)
{
ValidateFirstMetMinusInString(currentDigit, isMinusMet, i, power, error);
}
ValidateSymbolLessMaxInNotation(currentDigit, isMinusMet, radix, value, i, error);
if (IsOverflow(result, currentDigit, radix, isMinusMet))
{
error.wasError = true;
error.message = "Overflow integer value. \n";
}
if (error.wasError)
{
break;
}
if (IsCurrentIsNotMinus(isMinusMet, i))
{
if (isMinusMet)
{
result = result * radix - currentDigit;
}
else
{
result = result * radix + currentDigit;
}
}
}
return result;
}
std::string IntToString(int number, const int radix)
{
std::string result;
bool isNegative = (number < 0);
int remainder;
while (number != 0)
{
remainder = abs(number % radix);
number /= radix;
result = IntToSymbol(remainder) + result;
}
if (isNegative)
{
result.insert(0, "-");
}
return result;
}
std::string ConvertValueToDestinationNotation(const int sourceNotation, const int destinationNotation, const std::string& value, Error& error)
{
if (value == "0")
{
return std::to_string(0);
}
int valueInTenNotation = StringToInt(value, sourceNotation, error);
if (!error.wasError)
{
return IntToString(valueInTenNotation, destinationNotation);
}
return "";
}
bool IsNotationNotCorrect(const int notation)
{
return !(notation >= 2 && notation <= 36);
}
int main(int argc, char* argv[])
{
auto args = ParseArgs(argc, argv);
if (!args)
{
return 1;
}
int sourceNotation = 0;
int destinationNotation = 0;
try
{
sourceNotation = std::stoi(args->sourceNotation);
destinationNotation = std::stoi(args->destinationNotation);
if (IsNotationNotCorrect(sourceNotation))
{
throw std::invalid_argument("Invalid <" + args->sourceNotation + "> notation value.\n");
}
if (IsNotationNotCorrect(destinationNotation))
{
throw std::invalid_argument("Invalid <" + args->destinationNotation + "> notation value.\n");
}
}
catch (std::out_of_range& e)
{
std::cout << "Value of <notation> is not in range from 2 to 36";
return 1;
}
catch (std::invalid_argument& e)
{
std::cout << e.what();
return 1;
}
catch (std::exception& e)
{
std::cout << e.what();
return 1;
}
Error error;
error.wasError = false;
std::string valueInRadixNotation = ConvertValueToDestinationNotation(sourceNotation, destinationNotation, args->value, error);
if (error.wasError)
{
error.message += "Please try again.\n";
std::cout << error.message;
return 1;
}
else
{
std::cout << "Value in " << args->sourceNotation << " notation = " << args->value << "\n"
<< "Value in " << args->destinationNotation << " noation = " << valueInRadixNotation << "\n";
}
return 0;
}
|
6ade5fd8b0ddabd511659a2c6c5ae6faa75a6ea7 | 400fd356eb75d95ab35e8dcce2f5b03b3d272e83 | /DesignPatterns/c++_design_pattern/3行为/6备忘录/constraintSolverMemento.h | 8aaef7711bc23d1593bb35f9c146a1445bb2ca7a | [] | no_license | shandaming/Martial_arts | 4eba4c3856d0fbbcddc460790b4a06ba79a9c3ed | 896f10a7c457a9f166e7991e54943d46b6a953b5 | refs/heads/master | 2022-11-11T08:05:21.439745 | 2022-10-22T05:55:23 | 2022-10-22T05:55:23 | 116,259,077 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 230 | h | constraintSolverMemento.h | #ifndef CONSTRAINTSOLVERMEMENTO_H
#define CONSTRAINTSOLVERMEMENT_H
class ConstraintSolverMemento
{
public:
virtual ~ConstraintSolverMemento();
private:
friend class ConstraintSolver;
ConstraintSolverMemento();
};
#endif
|
3003157deb7e0a9e8a930c79243c4de8eb61add4 | e25bbf96cbe3402967d0c730bfad9bd66d1c06e4 | /3rd Year IN613 C++ Programming/Assignments/JoelPickworthTetrisAssignment/TetrisAssignment/Cell.h | 4eb6187c8fdce598014bbc70425249c697997fea | [] | no_license | pickjd1/BITCourseWork-Year3 | 2939ce30a7e2e427321313658791ccd719838cf4 | cc5974a0d18df86885e85b82eb2e7524c5c6c6e2 | refs/heads/master | 2016-08-04T22:45:35.238179 | 2015-05-19T01:11:28 | 2015-05-19T01:11:28 | 35,251,476 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 516 | h | Cell.h | #pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
ref class Cell
{
//cell fields
private:
//bool filled;
//Color c;
int row;
int col;
//cell methods
public:
//cell constructor
Cell(int row, int col);
int GetRow() {return row;}
int GetCol() {return col;}
void SetRow(int inc) {row += inc;}
void SetCol(int inc) {col += inc;}
};
|
dac89317b776f4651014b55cf5114a2252735051 | 1f45bf1127ff868bf4d22753a65047d874c2ffb1 | /src/components/policy/test/policy/src/test_stress_policy_manager_impl.cc | 9a52bc3d1709a6a9757c81fb22125f30d026ac03 | [] | no_license | smartdevice475/sdl_core_v3.6_wince | 50207a89fa2bfe0487409e4ad3babae52e477b54 | 5fff3bd40f83517f89428895b3dbe069b0f2f262 | refs/heads/master | 2021-01-18T09:34:08.202701 | 2016-08-10T01:57:23 | 2016-08-10T01:57:23 | 55,580,033 | 2 | 0 | null | 2016-04-06T06:05:08 | 2016-04-06T06:05:08 | null | UTF-8 | C++ | false | false | 8,052 | cc | test_stress_policy_manager_impl.cc | /* Copyright (c) 2013, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of the Ford Motor Company nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <string>
#include <set>
#include <sstream>
#include <fstream>
#include "policy/policy_manager_impl.h"
#include "mock_policy_listener.h"
using ::testing::_;
using ::policy::PolicyManagerImpl;
using ::policy::BinaryMessage;
using ::policy::MockPolicyListener;
namespace test {
namespace components {
namespace policy {
class PolicyManagerImplTest : public ::testing::Test {
protected:
static const std::string kNameFile;
static const int kNumberGroups = 100;
static const int kNumberFuncs = 200;
static const int kNumberApps = 100;
static const int kNumberAppGroups = 50;
static PolicyManagerImpl* manager;
static void SetUpTestCase() {
std::ofstream ofs;
ofs.open(kNameFile.c_str(), std::ofstream::out);
CreateTable(ofs);
ofs.close();
manager = new PolicyManagerImpl();
ASSERT_TRUE(manager->InitPT(kNameFile));
}
static void TearDownTestCase() {
delete manager;
remove(kNameFile.c_str());
remove("policy.sqlite");
}
static void CreateTable(std::ofstream& ofs);
static void CreateGroups(std::ofstream& ofs);
static void CreateFuncs(std::ofstream& ofs);
static void CreateApps(std::ofstream& ofs);
static void CreateAppGroups(std::ofstream& ofs);
};
const std::string PolicyManagerImplTest::kNameFile = "pt.json";
PolicyManagerImpl* PolicyManagerImplTest::manager = 0;
void PolicyManagerImplTest::CreateGroups(std::ofstream& ofs) {
std::stringstream ss;
std::string number;
for (int i = 0; i < kNumberGroups - 1; ++i) {
ss << i << std::endl;
ss >> number;
ofs << "\"Group-" << number << "\":{ \"rpcs\":{";
CreateFuncs(ofs);
ofs << "} },";
}
ss << kNumberGroups - 1 << std::endl;
ss >> number;
ofs << "\"Group-" << number << "\":{ \"rpcs\":{";
CreateFuncs(ofs);
ofs << "} }";
}
void PolicyManagerImplTest::CreateFuncs(std::ofstream& ofs) {
std::string func = "{"
"\"hmi_levels\":["
"\"BACKGROUND\","
"\"FULL\","
"\"LIMITED\""
"],"
"\"parameters\":["
"\"gps\","
"\"speed\","
"\"enginetorque\","
"\"externaltemperature\","
"\"fuellevel\","
"\"fuellevel_state\","
"\"headlampstatus\","
"\"instantfuelconsumption\","
"\"odometer\","
"\"tirepressure\","
"\"wiperstatus\","
"\"vin\","
"\"accpedalposition\","
"\"beltstatus\","
"\"driverbraking\","
"\"prndl\","
"\"rpm\","
"\"steeringwheelangle\""
"]"
"}";
std::stringstream ss;
std::string number;
for (int i = 0; i < kNumberFuncs - 1; ++i) {
ss << i << std::endl;
ss >> number;
ofs << "\"Func-" << number << "\":" << func << ",";
}
ss << kNumberFuncs - 1 << std::endl;
ss >> number;
ofs << "\"Func-" << number << "\":" + func;
}
void PolicyManagerImplTest::CreateApps(std::ofstream& ofs) {
ofs << "\"default\":{"
"\"groups\":["
"\"Group-1\""
"]"
"},";
std::stringstream ss;
std::string number;
for (int i = 0; i < kNumberApps - 1; ++i) {
ss << i << std::endl;
ss >> number;
ofs << "\"" << number << "\": { \"groups\": ";
CreateAppGroups(ofs);
ofs << "},";
}
ss << kNumberApps - 1 << std::endl;
ss >> number;
ofs << "\"" << number << "\": { \"groups\": ";
CreateAppGroups(ofs);
ofs << "}";
}
void PolicyManagerImplTest::CreateAppGroups(std::ofstream& ofs) {
ofs << "[";
std::stringstream ss;
std::string number;
std::set<int> app_groups;
for (int i = 0; i < kNumberAppGroups; ++i) {
app_groups.insert(rand() % kNumberGroups);
}
std::set<int>::const_iterator i = app_groups.begin();
ss << *i << std::endl;
ss >> number;
ofs << "\"Group-" << number << "\"";
++i;
for (; i != app_groups.end(); ++i) {
ss << *i << std::endl;
ss >> number;
ofs << ",\"Group-" << number << "\"";
}
ofs << "]";
}
void PolicyManagerImplTest::CreateTable(std::ofstream& ofs) {
ofs << "{"
"\"policy_table\":{"
"\"module_config\":{"
"\"preloaded_pt\":true,"
"\"endpoints\":{"
"\"default\": {"
"\"default\":["
"\"http://sdl.net/api\""
"]"
"}"
"},"
"\"exchange_after_x_ignition_cycles\": 40,"
"\"exchange_after_x_kilometers\" : 2,"
"\"exchange_after_x_days\" : 23,"
"\"timeout_after_x_seconds\" : 20,"
"\"seconds_between_retries\" : [10, 7, 5, 3, 1]"
"},"
"\"consumer_friendly_messages\":{"
"\"version\":\"001.001.001\","
"\"messages\":{} },"
"\"functional_groupings\":{";
CreateGroups(ofs);
ofs << "}, \"app_policies\":{";
CreateApps(ofs);
ofs << "}";
}
TEST_F(PolicyManagerImplTest, StressTestOneCheck) {
MockPolicyListener mock_listener;
EXPECT_CALL(mock_listener, OnCurrentDeviceIdUpdateRequired("2")).Times(1);
manager->set_listener(&mock_listener);
::policy::CheckPermissionResult output = manager->CheckPermissions("2",
"FULL",
"Func-1");
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
}
TEST_F(PolicyManagerImplTest, StressTestNoPermission) {
MockPolicyListener mock_listener;
EXPECT_CALL(mock_listener, OnCurrentDeviceIdUpdateRequired("150")).Times(1);
manager->set_listener(&mock_listener);
::policy::CheckPermissionResult output = manager->CheckPermissions(
"150", "FULL", "Func-400");
EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
}
TEST_F(PolicyManagerImplTest, StressTestFewChecks) {
MockPolicyListener mock_listener;
EXPECT_CALL(mock_listener, OnCurrentDeviceIdUpdateRequired(_)).Times(100);
manager->set_listener(&mock_listener);
const int kNumberOfCheckings = 100;
std::stringstream ss;
int app, func;
std::string app_number, func_number;
for (int i = 0; i < kNumberOfCheckings; ++i) {
app = rand() % kNumberApps;
func = rand() % kNumberFuncs;
ss << app << std::endl;
ss >> app_number;
ss << func << std::endl;
ss >> func_number;
::policy::CheckPermissionResult output = manager->CheckPermissions(
app_number, "FULL", "Func-" + func_number);
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
}
}
} // namespace policy
} // namespace components
} // namespace test
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
|
ad373e49aca90db1191741dd8c3f14d683c874f6 | c0356aa3b1904728696734293276c9e24e8b32bf | /Arduino/robomower/Ros_SubscriberLaser/Ros_SubscriberLaser.ino | 853bee309d07bd7c173035c5741e99bfe46cacfe | [] | no_license | parkersell/Robomower | fef43a7b68f379a43ea7fad8f69ef1895c130bd4 | 45805a6a993bcf7ff39d9588ce7507eea58c9940 | refs/heads/master | 2022-12-28T07:55:41.071364 | 2020-08-04T13:09:49 | 2020-08-04T13:09:49 | 301,860,448 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,062 | ino | Ros_SubscriberLaser.ino | #include <ros.h>
#include <geometry_msgs/PoseStamped.h>
#include <geometry_msgs/Pose.h>
#include <sensor_msgs/LaserScan.h>
#include <std_msgs/Float32.h>
//include a list or array message for points of obstacles on point cloud
ros::NodeHandle nh;
sensor_msgs::LaserScan msg;
//list variable
void positionCallback(const std_msgs::Float32& msg) {
//double scandistance = 39.37 * (msg.ranges[360]);
double scandistance = msg;
}
/*void objectAvoidanceCallback("list variable"){
//
}*/
ros::Subscriber<sensor_msgs::LaserScan> pose_subscriber("scan", positionCallback);
//ros::Subscriber<geometry_msgs::Pose> pose_subscriber("/orb_slam2_mono/pose", positionCallback);
//ros::Subscriber<list> list_subscriber("echo", &objectAvoidanceCallback);//echo topic that displays list of x y z coordinates of the objects
void setup() {
// put your setup code here, to run once:
nh.initNode();
nh.subscribe(pose_subscriber);
////nh.subscribe(list_subscriber);
}
void loop() {
// put your main code here, to run repeatedly:
nh.spinOnce();
delay(500);
}
|
b1bd0b9a35526f2d0b3485e847080f399198b9a4 | fc770f723896e83e080495ab128b4d3e65c56ccb | /MyCode/Chapter 8/8Drill2/8Drill2/dec.h | 43f035172a63e427a0e1e28a7b4caa93bdbf9f47 | [] | no_license | p4lewandowski/ProgrammingPrinciples | 5d0946be1de3ed5becbf52ab5402ae9b0779d490 | 93b3e868f6af3e3dd5bee1b242efc8110ed6d1c1 | refs/heads/master | 2020-04-01T15:51:24.321892 | 2018-12-21T12:43:24 | 2018-12-21T12:43:24 | 153,355,025 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 203 | h | dec.h | #include "pch.h"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
void swap_v(int, int);
void swap_r(int&, int&);
void swap_cr(const int&, const int&); |
7f0f7a6e5cf95e49c9d2135b603519d7941adb45 | a9e308c81c27a80c53c899ce806d6d7b4a9bbbf3 | /engine/xray/console_command_inline.h | 38aa652df6b84d8dd1642a89424eaedae8e8f821 | [] | no_license | NikitaNikson/xray-2_0 | 00d8e78112d7b3d5ec1cb790c90f614dc732f633 | 82b049d2d177aac15e1317cbe281e8c167b8f8d1 | refs/heads/master | 2023-06-25T16:51:26.243019 | 2020-09-29T15:49:23 | 2020-09-29T15:49:23 | 390,966,305 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 683 | h | console_command_inline.h | ////////////////////////////////////////////////////////////////////////////
// Created : 13.02.2009
// Author : Andrew Kolomiets
// Copyright (C) GSC Game World - 2009
////////////////////////////////////////////////////////////////////////////
#ifndef CONSOLE_COMMAND_INLINE_H_INCLUDED
#define CONSOLE_COMMAND_INLINE_H_INCLUDED
namespace xray {
namespace console_commands{
template<class T>
inline cc_value<T>::cc_value(pcstr name, T& value, T const min, T const max)
:super(name), m_value(value), m_min(min), m_max(max)
{
m_need_args = true;
m_serializable = true;
}
} // namespace console_commands
} // namespace xray
#endif // #ifndef CONSOLE_COMMAND_INLINE_H_INCLUDED |
50956c548fcf53df9e8b0dd723a280e6e9515adb | f14471ad6993834266bf3328b4126d921c959c3b | /kokkos-kernels/src/blas/impl/KokkosBlas3_trmm_spec.hpp | 41a6d0d85222f0661ec65457baa26419abe616cc | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | sandialabs/compadre | 07b06f095ed0f171aba66839e8e01e619b7403ea | bf4cd8db7104a2102ee9af5fbc8962f43c6df876 | refs/heads/master | 2023-08-31T11:47:01.409672 | 2023-05-03T15:13:07 | 2023-05-03T15:13:07 | 165,897,408 | 8 | 1 | NOASSERTION | 2023-05-03T15:13:09 | 2019-01-15T17:52:40 | C++ | UTF-8 | C++ | false | false | 8,241 | hpp | KokkosBlas3_trmm_spec.hpp | /*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Siva Rajamanickam (srajama@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOSBLAS3_TRMM_SPEC_HPP_
#define KOKKOSBLAS3_TRMM_SPEC_HPP_
#include "KokkosKernels_config.h"
#include "Kokkos_Core.hpp"
#if !defined(KOKKOSKERNELS_ETI_ONLY) || KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
#include <KokkosBlas3_trmm_impl.hpp>
#endif
namespace KokkosBlas {
namespace Impl {
// Specialization struct which defines whether a specialization exists
template <class AVIT, class BVIT>
struct trmm_eti_spec_avail {
enum : bool { value = false };
};
} // namespace Impl
} // namespace KokkosBlas
//
// This Macro is for readability of the template arguments.
//
#define KOKKOSBLAS3_TRMM_ETI_SPEC_AVAIL_LAYOUT(SCALAR, LAYOUTA, LAYOUTB, \
EXEC_SPACE, MEM_SPACE) \
template <> \
struct trmm_eti_spec_avail< \
Kokkos::View<const SCALAR**, LAYOUTA, \
Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Kokkos::View<SCALAR**, LAYOUTB, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> > > { \
enum : bool { value = true }; \
};
//
// This Macros provides the ETI specialization of trmm
//
#define KOKKOSBLAS3_TRMM_ETI_SPEC_AVAIL(SCALAR, LAYOUT, EXEC_SPACE, MEM_SPACE) \
KOKKOSBLAS3_TRMM_ETI_SPEC_AVAIL_LAYOUT(SCALAR, LAYOUT, LAYOUT, EXEC_SPACE, \
MEM_SPACE)
// Include the actual specialization declarations
#include <KokkosBlas3_trmm_tpl_spec_avail.hpp>
#include <generated_specializations_hpp/KokkosBlas3_trmm_eti_spec_avail.hpp>
namespace KokkosBlas {
namespace Impl {
//
// trmm
//
// Unification layer
template <class AVIT, class BVIT,
bool tpl_spec_avail = trmm_tpl_spec_avail<AVIT, BVIT>::value,
bool eti_spec_avail = trmm_eti_spec_avail<AVIT, BVIT>::value>
struct TRMM {
static void trmm(const char side[], const char uplo[], const char trans[],
const char diag[], typename BVIT::const_value_type& alpha,
const AVIT& A, const BVIT& B);
};
#if !defined(KOKKOSKERNELS_ETI_ONLY) || KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
template <class AVIT, class BVIT>
struct TRMM<AVIT, BVIT, false, KOKKOSKERNELS_IMPL_COMPILE_LIBRARY> {
static void trmm(const char side[], const char uplo[], const char trans[],
const char diag[], typename BVIT::const_value_type& alpha,
const AVIT& A, const BVIT& B) {
static_assert(Kokkos::is_view<AVIT>::value, "AVIT must be a Kokkos::View.");
static_assert(Kokkos::is_view<BVIT>::value, "BVIT must be a Kokkos::View.");
static_assert(static_cast<int>(AVIT::rank) == 2, "AVIT must have rank 2.");
static_assert(static_cast<int>(BVIT::rank) == 2, "BVIT must have rank 2.");
Kokkos::Profiling::pushRegion(KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
? "KokkosBlas::trmm[ETI]"
: "KokkosBlas::trmm[noETI]");
typename AVIT::HostMirror host_A = Kokkos::create_mirror_view(A);
typename BVIT::HostMirror host_B = Kokkos::create_mirror_view(B);
// Copy A to host_A and B to host_B
// no-op if A and B MemorySpace is HostSpace
Kokkos::deep_copy(host_A, A);
Kokkos::deep_copy(host_B, B);
SerialTrmm_Invoke<typename AVIT::HostMirror, typename BVIT::HostMirror>(
side, uplo, trans, diag, alpha, host_A, host_B);
// Copy host_B to B
// no-op if B's MemorySpace is HostSpace
Kokkos::deep_copy(B, host_B);
Kokkos::Profiling::popRegion();
}
};
#endif //! defined(KOKKOSKERNELS_ETI_ONLY) ||
//! KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
} // namespace Impl
} // namespace KokkosBlas
//
// These Macros are for readability.
//
#define KOKKOSBLAS3_TRMM_ETI_SPEC_DECL_LAYOUTS(SCALAR, LAYOUTA, LAYOUTB, \
EXEC_SPACE, MEM_SPACE) \
extern template struct TRMM< \
Kokkos::View<const SCALAR**, LAYOUTA, \
Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Kokkos::View<SCALAR**, LAYOUTB, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
false, true>;
#define KOKKOSBLAS3_TRMM_ETI_SPEC_INST_LAYOUTS(SCALAR, LAYOUTA, LAYOUTB, \
EXEC_SPACE, MEM_SPACE) \
template struct TRMM< \
Kokkos::View<const SCALAR**, LAYOUTA, \
Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Kokkos::View<SCALAR**, LAYOUTB, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
false, true>;
//
// These Macros are only included when we are not compiling libkokkoskernels but
// are auto generating files. These macros provide the explicit instantiation
// declaration and definition of TRMM, potentially reducing user code size. The
// "extern template" skips the implicit instatiation step ensuring that the
// callers code uses this explicit instantiation definition of TRMM.
//
#define KOKKOSBLAS3_TRMM_ETI_SPEC_DECL(SCALAR, LAYOUT, EXEC_SPACE, MEM_SPACE) \
KOKKOSBLAS3_TRMM_ETI_SPEC_DECL_LAYOUTS(SCALAR, LAYOUT, LAYOUT, EXEC_SPACE, \
MEM_SPACE)
#define KOKKOSBLAS3_TRMM_ETI_SPEC_INST(SCALAR, LAYOUT, EXEC_SPACE, MEM_SPACE) \
KOKKOSBLAS3_TRMM_ETI_SPEC_INST_LAYOUTS(SCALAR, LAYOUT, LAYOUT, EXEC_SPACE, \
MEM_SPACE)
#include <KokkosBlas3_trmm_tpl_spec_decl.hpp>
#include <generated_specializations_hpp/KokkosBlas3_trmm_eti_spec_decl.hpp>
#endif // KOKKOSBLAS3_TRMM_SPEC_HPP_
|
b3874e0731c4c0d0573f72bed1e4e4245bfcac3d | b0b27e04c44c6e276ba8064958e6d6838b802954 | /Number Theory/primeFactoristion.cpp | 4be0fa81fb9c4600057aee0de6621160b42bb884 | [] | no_license | deveshjha489/template | 810b4c105aeaedcd877c082eddcfbfdfc40e0724 | bbd1785c03e14407b03d1de8c43782c5d6d8597f | refs/heads/master | 2022-12-24T05:06:57.107038 | 2020-10-01T17:37:57 | 2020-10-01T17:37:57 | 258,991,554 | 0 | 1 | null | 2020-10-01T17:37:59 | 2020-04-26T09:35:11 | C++ | UTF-8 | C++ | false | false | 869 | cpp | primeFactoristion.cpp | #include <bits/stdc++.h>
#define MAXN 100001
#define ll long long int
using namespace std;
//O(sqrt(n))
int numOfFactor(int n){
int count = 0;
while (n % 2 == 0)
{
++count;
n = n/2;
}
for (int i = 3; i <= sqrt(n); i = i + 2)
{
while (n % i == 0)
{
++count;
n = n/i;
}
}
if(n>2) ++count;
return count;
}
vector<int> factor(MAXN,-1);
void sievefactorisation(){
for(ll i=2;i<=MAXN;i++){
if(factor[i] == -1){
for(ll j=i*i; j<=MAXN;j+=i){
if(factor[j] == -1) factor[j] = i;
}
}
}
}
//O(logn)
void getFactorisation(int n){
for(int i=n;i>1;){
if(factor[i]==-1)cout<<i<<" ";
else cout<<factor[i]<<" ";
i /= factor[i];
}
}
int main(){
sievefactorisation();
getFactorisation(18);
cout<<endl;
getFactorisation(59150);
}
|
2ddb4a95f4261a1cc5e28493e73d5b83c26c0f77 | 24df79b5d1b72963c345b2ae75712a1a3c1dbbc6 | /Classes/System/cursor.h | 8949683b44ae1aecf202350f6755a8a8e2b66502 | [] | no_license | ugonight/rifujin2 | d7a65128d937e4d0e0f8cd0442d05af3f8e20eb9 | 6deba35a6fefceea77c18e255fe33364431aea12 | refs/heads/master | 2021-01-19T19:26:47.282959 | 2020-03-31T13:06:33 | 2020-03-31T13:06:33 | 88,414,600 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 637 | h | cursor.h | #pragma once
#pragma execution_character_set("utf-8")
#include "cocos2d.h"
#define CURSOR_NUM 8
class Cursor : public cocos2d::Layer {
private:
//cocos2d::Sprite* mCursorImg[CURSOR_NUM];
int mCursorNum;
bool mTouchNow;
bool touchEvent(cocos2d::Touch* touch, cocos2d::Event* event);
bool moveEvent(cocos2d::Touch* touch, cocos2d::Event* event);
bool endEvent(cocos2d::Touch* touch, cocos2d::Event* event);
public:
enum CursorID {
NOMAL,
NEW,
INFO,
BACK,
RIGHT,
LEFT,
CANUSE,
FORWARD,
NOVEL,
ENTER
};
virtual bool init();
void setCursorNum(CursorID id);
int getCursorNum();
CREATE_FUNC(Cursor);
}; |
9f12dfc29a94410845da8e9ba04d00f104a71db8 | 0c7e20a002108d636517b2f0cde6de9019fdf8c4 | /Sources/Elastos/Packages/Apps/Dialer/src/elastos/droid/dialer/settings/DialerSettingsActivity.cpp | 4d695b20d4fda6ab23c951fb51add9e35c12f16f | [
"Apache-2.0"
] | permissive | kernal88/Elastos5 | 022774d8c42aea597e6f8ee14e80e8e31758f950 | 871044110de52fcccfbd6fd0d9c24feefeb6dea0 | refs/heads/master | 2021-01-12T15:23:52.242654 | 2016-10-24T08:20:15 | 2016-10-24T08:20:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,898 | cpp | DialerSettingsActivity.cpp |
#include "elastos/droid/dialer/settings/DialerSettingsActivity.h"
#include "Elastos.Droid.Preference.h"
#include "Elastos.CoreLibrary.Core.h"
#include "R.h"
using Elastos::Droid::Os::IUserHanlde;
using Elastos::Droid::Preference::IPreferenceActivityHeader;
using Elastos::Droid::Preference::CPreferenceActivityHeader;
using Elastos::Droid::Preference::IPreferenceManagerHelper;
using Elastos::Droid::Preference::CPreferenceManagerHelper;
using Elastos::Core::ICharSequence;
using Elastos::Core::CArrayList;
namespace Elastos {
namespace Droid {
namespace Dialer {
namespace Settings {
//=================================================================
// DialerSettingsActivity::HeaderAdapter
//=================================================================
ECode DialerSettingsActivity::HeaderAdapter::constructor(
/* [in] */ IContext* context,
/* [in] */ IList* objects)
{
ArrayAdapter::constructor(context, 0, objects);
AutoPtr<IInterface> service;
context->GetSystemService(IContext::LAYOUT_INFLATER_SERVICE, (IInterface**)&service);
mInflater = ILayoutInflater::Probe(service);
return NOERROR;
}
ECode DialerSettingsActivity::HeaderAdapter::GetView(
/* [in] */ Int32 position,
/* [in] */ IView* convertView,
/* [in] */ IViewGroup* parent,
/* [out] */ IView** result)
{
VALIDATE_NOT_NULL(result);
AutoPtr<HeaderViewHolder> holder;
AutoPtr<IView> view;
if (convertView == NULL) {
mInflater->Inflate(R::layout::dialer_preferences, parent, FALSE, (IView**)&view);
holder = new HeaderViewHolder();
AutoPtr<IView> temp;
view->FindViewById(R::id::title, (IView**)&temp);
holder->mTitle = ITextView::Probe(temp);
temp = NULL;
view->FindViewById(R::id::summary, (IView**)&temp);
holder->mSummary = ITextView::Probe(temp);
view->SetTag(holder);
}
else {
view = convertView;
AutoPtr<IInterface> tag;
view->GetTag((IInterface**)&tag);
holder = (HeaderViewHolder*)tag;
}
// All view fields must be updated every time, because the view may be recycled
AutoPtr<IInterface> item;
GetItem(position, (IInterface**)&item);
IPreferenceActivityHeader* header = IPreferenceActivityHeader::Probe(item);
AutoPtr<IContext> context;
GetContext((IContext**)&context);
AutoPtr<IResources> res;
context->GetResources((IResources**)&res);
AutoPtr<ICharSequence> title;
header->GetTitle(res, (ICharSequence**)&title);
holder->mTitle->SetText(title);
AutoPtr<ICharSequence> summary;
header->GetSummary(res);
if (!TextUtils::IsEmpty(summary)) {
holder->mSummary->SetVisibility(IView::VISIBLE);
holder->mSummary->SetText(summary);
}
else {
holder->mSummary->SetVisibility(IView::GONE);
}
*result = view;
REFCOUNT_ADD(*result)
return NOERROR;
}
//=================================================================
// DialerSettingsActivity
//=================================================================
// TODO:
CAR_INTERFACE_IMPL(DialerSettingsActivity, /*AnalyticsPreferenceActivity*/Activity, IDialerSettingsActivity);
ECode DialerSettingsActivity::OnCreate(
/* [in] */ IBundle* savedInstanceState)
{
assert(0 && "TODO");
// AnalyticsPreferenceActivity::OnCreate(savedInstanceState);
AutoPtr<IPreferenceManagerHelper> helper;
CPreferenceManagerHelper::AcquireSingleton((IPreferenceManagerHelper**)&helper);
helper->GetDefaultSharedPreferences(this, (ISharedPreferences**)&mPreferences);
return NOERROR;
}
ECode DialerSettingsActivity::OnBuildHeaders(
/* [in] */ IList* target)
{
AutoPtr<IPreferenceActivityHeader> generalSettingsHeader;
CPreferenceActivityHeader::New((IPreferenceActivityHeader**)&generalSettingsHeader);
generalSettingsHeader->SetTitleRes(R::string::general_settings_label);
generalSettingsHeader->SetSummaryRes(R::string::general_settings_description);
generalSettingsHeader->SetFragment(String("GeneralSettingsFragment"));
target->Sdd(generalSettingsHeader);
// Only add the call settings header if the current user is the primary/owner user.
if (IsPrimaryUser()) {
AutoPtr<IPreferenceActivityHeader> callSettingHeader;
CPreferenceActivityHeader::New((IPreferenceActivityHeader**)&callSettingHeader);
callSettingHeader->SetTitleRes(R::string::call_settings_label);
callSettingHeader->SetSummaryRes(R::string::call_settings_description);
assert(0 && "TODO");
// callSettingHeader->SetIntent(DialtactsActivity::GetCallSettingsIntent());
target->Add(callSettingHeader);
}
return NOERROR;
}
ECode DialerSettingsActivity::OnOptionsItemSelected(
/* [in] */ IMenuItem* item,
/* [out] */ Boolean* result)
{
VALIDATE_NOT_NULL(result);
Int32 id;
if (item->GetItemId(&id), id == Elastos::R::id::home) {
OnBackPressed();
*result = TRUE;
return NOERROR;
}
*result = FALSE;
return NOERROR;
}
ECode DialerSettingsActivity::IsValidFragment(
/* [in] */ const String& fragmentName,
/* [out] */ Boolean* result)
{
VALIDATE_NOT_NULL(result);
*result = TRUE;
return NOERROR;
}
ECode DialerSettingsActivity::SetListAdapter(
/* [in] */ IListAdapter* adapter)
{
if (adapter == NULL) {
assert(0 && "TODO");
// AnalyticsPreferenceActivity::SetListAdapter(NULL);
}
else {
// We don't have access to the hidden getHeaders() method, so grab the headers from
// the intended adapter and then replace it with our own.
Int32 headerCount;
adapter->GetCount(&headerCount);
AutoPtr<IList> headers;
CArrayList::New((IList**)&headers);
for (int i = 0; i < headerCount; i++) {
AutoPtr<IInterface> item;
adapter->GetItem(i, (IInterface**)&item);
headers->Add(item);
}
mHeaderAdapter = new HeaderAdapter();
mHeaderAdapter->constructor((IContext*)this, headers);
assert(0 && "TODO");
// AnalyticsPreferenceActivity::SetListAdapter(mHeaderAdapter);
}
return NOERROR;
}
Boolean DialerSettingsActivity::IsPrimaryUser()
{
AutoPtr<IInterface> service;
GetSystemService(IContext::USER_SERVICE, (IInterface**)&service);
IUserManager* userManager = IUserManager::Probe(service);
AutoPtr<IList> userHandles;
userManager->GetUserProfiles((IList**)&userHandles);
Int32 size;
userHandles->GetSize(&size);
for (Int32 i = 0; i < size; i++){
AutoPtr<IInterface> item;
userHandles->Get(i, (IInterface**)&item);
Int32 id;
IUserHanlde::Probe(item)->GetMyUserId(&id);
if (id == OWNER_HANDLE_ID) {
return TRUE;
}
}
return FALSE;
}
} // Settings
} // Dialer
} // Droid
} // Elastos
|
9e0d165a7e03977068405d4e2b400564d9b33951 | 79f5cdf88cdafe410db884b541984e3a2eb7acc0 | /Source/Games/Battleship/BattleshipManager.cpp | b2aa64c39b1702c12da9ec478d8408c76d305fb5 | [
"MIT"
] | permissive | gorkinovich/GAGC | 963782b4144be3fd94c976c1c5a777ff4d034b4c | 4f4517c216690d311e3ef3f23cf72d9b71f21815 | refs/heads/master | 2021-12-30T14:29:46.642944 | 2015-04-09T19:58:10 | 2015-04-09T19:58:10 | 33,688,201 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 15,563 | cpp | BattleshipManager.cpp | /******************************************************************************
Copyright (c) 2014 Gorka Suárez García
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
******************************************************************************/
#include "BattleshipManager.h"
#include <SFML/Graphics/Texture.hpp>
#include <SFML/System/Time.hpp>
#include <System/CoreManager.h>
#include <System/AtariPalette.h>
#include <System/Sound.h>
#include <Menu/DesktopState.h>
#include <Games/Battleship/BattleshipBoard.h>
#include <Games/Battleship/BattleshipEnterNameState.h>
#include <Games/Battleship/BattleshipPutShipsState.h>
#include <Games/Battleship/BattleshipGameState.h>
#include <Games/Battleship/BattleshipWaitState.h>
#include <Games/Battleship/BattleshipGameMenuState.h>
#include <Games/Battleship/BattleshipGameOverState.h>
//********************************************************************************
// Constants
//********************************************************************************
const int P1_NAME_STATE = 0;
const int P1_SHIPS_STATE = 1;
const int P2_NAME_STATE = 2;
const int P2_SHIPS_STATE = 3;
const int P1_PLAY_STATE = 4;
const int P1_WAIT_STATE = 5;
const int P2_PLAY_STATE = 6;
const int P2_WAIT_STATE = 7;
//********************************************************************************
// InnerData
//********************************************************************************
struct BattleshipManager::Player {
int turn;
std::string name;
BattleshipBoard board;
};
struct BattleshipManager::InnerData {
SharedTexture tileset;
int winner;
int substate;
int numberOfPlayers;
BattleshipManager::Player player1;
BattleshipManager::Player player2;
Sound keyboardSound;
Sound clickSound;
Sound waterSound;
Sound hitSound;
Sound sunkSound;
};
//********************************************************************************
// Properties
//********************************************************************************
SharedTexture & BattleshipManager::Tileset() {
return data_->tileset;
}
//--------------------------------------------------------------------------------
int BattleshipManager::Winner() {
return data_->winner;
}
//--------------------------------------------------------------------------------
const std::string & BattleshipManager::Player1Name() {
return data_->player1.name;
}
//--------------------------------------------------------------------------------
const std::string & BattleshipManager::Player2Name() {
return data_->player2.name;
}
//--------------------------------------------------------------------------------
Sound & BattleshipManager::KeyboardSound() { return data_->keyboardSound; }
Sound & BattleshipManager::ClickSound() { return data_->clickSound; }
Sound & BattleshipManager::WaterSound() { return data_->waterSound; }
Sound & BattleshipManager::HitSound() { return data_->hitSound; }
Sound & BattleshipManager::SunkSound() { return data_->sunkSound; }
//********************************************************************************
// Methods
//********************************************************************************
/**
* Initializes the data of the object.
*/
void BattleshipManager::Initialize() {
if (!initialized_) {
auto * core = CoreManager::Instance();
// Get memory for the internal data.
data_.reset(new InnerData());
// Load the textures of the game.
data_->tileset = core->LoadTexture("Content/Textures/Battleship.png");
// Load the sounds of the game.
data_->keyboardSound.Load("Content/Sounds/SharedKey.wav");
data_->clickSound.Load("Content/Sounds/SharedClick.wav");
data_->waterSound.Load("Content/Sounds/BattleshipWater.wav");
data_->hitSound.Load("Content/Sounds/BattleshipHit.wav");
data_->sunkSound.Load("Content/Sounds/BattleshipSunk.wav");
// Set the initialized flag.
initialized_ = true;
}
}
//--------------------------------------------------------------------------------
/**
* Releases the data of the object.
*/
void BattleshipManager::Release() {
if (initialized_ && data_) {
// Wait to the sound to end.
data_->keyboardSound.WaitUntilStop();
data_->clickSound.WaitUntilStop();
// Unload the sounds of the game.
data_->keyboardSound.Unload();
data_->clickSound.Unload();
data_->waterSound.Unload();
data_->hitSound.Unload();
data_->sunkSound.Unload();
// Unload the textures of the game.
data_->tileset = nullptr;
// Remove the inner data of the game.
data_.reset(nullptr);
}
// Change the initialized flag and set the next state.
initialized_ = false;
CoreManager::Instance()->SetNextState(MakeSharedState<DesktopState>());
}
//********************************************************************************
// Game methods
//********************************************************************************
/**
* Starts a new game.
*/
void BattleshipManager::StartGame(int numberOfPlayers) {
auto * core = CoreManager::Instance();
auto language = core->Language();
// Set the general fields.
data_->winner = NO_WINNER;
data_->substate = P1_NAME_STATE;
data_->numberOfPlayers = numberOfPlayers;
// Initialize the players.
auto initPlayer = [language] (Player & victim) {
victim.turn = 0;
victim.name = language == TEXT_LANGUAGE_SPANISH ?
"Jugador" : "Player";
};
initPlayer(data_->player1);
initPlayer(data_->player2);
data_->player1.name += " 1";
data_->player2.name += " 2";
// Change the next state.
core->SetNextState(MakeSharedState<BattleshipEnterNameState>());
}
//--------------------------------------------------------------------------------
/**
* Returns the name of the current player.
*/
const std::string & BattleshipManager::GetPlayerName() {
if (data_->substate == P2_NAME_STATE || data_->substate == P2_SHIPS_STATE ||
data_->substate == P2_PLAY_STATE || data_->substate == P2_WAIT_STATE) {
return data_->player2.name;
} else {
return data_->player1.name;
}
}
//--------------------------------------------------------------------------------
/**
* Adds the player's name to the current player.
*/
void BattleshipManager::AddPlayerName(const std::string & name) {
// After add a name we'll have to update the player
// name and set the next substate of the game.
if (data_->substate == P1_NAME_STATE) {
data_->player1.name = name;
nextSubstate();
} else if (data_->substate == P2_NAME_STATE) {
data_->player2.name = name;
nextSubstate();
}
}
//--------------------------------------------------------------------------------
/**
* Adds the player's fleet to the current player.
*/
void BattleshipManager::AddPlayerBoard(const BattleshipBoard & board) {
// After finish to put the fleet on the board, we'll add to the current player
// the board. We'll need to reset the count, because the ships count is used
// to check the victory condition. Finally we'll set the next substate.
if (data_->substate == P1_SHIPS_STATE) {
data_->player1.board = board;
data_->player1.board.ResetCount();
nextSubstate();
} else if (data_->substate == P2_SHIPS_STATE) {
data_->player2.board = board;
data_->player2.board.ResetCount();
nextSubstate();
}
}
//--------------------------------------------------------------------------------
/**
* Gets the current data.
*/
void BattleshipManager::GetCurrentData(CurrentData & data) {
switch (data_->substate) {
case P1_PLAY_STATE:
case P2_WAIT_STATE:
data.name = data_->player1.name;
data.turn = data_->player1.turn;
data.playerBoard = &(data_->player1.board);
data.enemyBoard = &(data_->player2.board);
break;
case P2_PLAY_STATE:
case P1_WAIT_STATE:
data.name = data_->player2.name;
data.turn = data_->player2.turn;
data.playerBoard = &(data_->player2.board);
data.enemyBoard = &(data_->player1.board);
break;
default:
data.name = "";
data.turn = 0;
data.playerBoard = nullptr;
data.enemyBoard = nullptr;
}
}
//--------------------------------------------------------------------------------
/**
* Is called after fire over an enemy board.
*/
void BattleshipManager::OnFireUpdate() {
// After any of the players make a fire movement, we'll update the turn field.
// Then we'll check the victory condition and change the next substate.
switch (data_->substate) {
case P1_PLAY_STATE:
data_->player1.turn++;
if (!data_->player2.board.AnyShipAvailable()) {
data_->winner = P1_WINNER;
}
nextSubstate();
break;
case P2_PLAY_STATE:
data_->player2.turn++;
if (!data_->player1.board.AnyShipAvailable()) {
data_->winner = P2_WINNER;
}
nextSubstate();
break;
}
}
//--------------------------------------------------------------------------------
/**
* Is called after the wait is over.
*/
void BattleshipManager::WaitDone() {
if (data_->substate == P1_WAIT_STATE || data_->substate == P2_WAIT_STATE) {
nextSubstate();
}
}
//--------------------------------------------------------------------------------
/**
* Executes the machine turn.
*/
void BattleshipManager::machineTurn() {
// The machine fires over the player board and then checks the victory condition.
data_->player1.board.MachineFires();
if (!data_->player1.board.AnyShipAvailable()) {
data_->winner = AI_WINNER;
CoreManager::Instance()->SetNextState(MakeSharedState<BattleshipGameOverState>());
}
}
//--------------------------------------------------------------------------------
/**
* Changes the game to the next substate.
*/
void BattleshipManager::nextSubstate() {
auto * core = CoreManager::Instance();
switch (data_->substate) {
case P1_NAME_STATE:
// After add the player's name, we'll send her/him to the put ships state.
data_->substate = P1_SHIPS_STATE;
core->SetNextState(MakeSharedState<BattleshipPutShipsState>());
break;
case P1_SHIPS_STATE:
// After add the player's fleet, we'll check the number of players.
if (data_->numberOfPlayers > 1) {
// If there are 2 players, we'll need to recieve the next player data.
data_->substate = P2_NAME_STATE;
core->SetNextState(MakeSharedState<BattleshipEnterNameState>());
} else {
// If we play against the machine, we'll have to initialize this
// "virtual" player that will play as "player 2".
data_->substate = P1_PLAY_STATE;
data_->player2.board.Initialize();
data_->player2.board.SetModeAIPutFleet();
data_->player2.board.SetRandomFleet();
data_->player2.board.ResetCount();
core->SetNextState(MakeSharedState<BattleshipGameState>());
}
break;
case P2_NAME_STATE:
// After add the player's name, we'll send her/him to the put ships state.
data_->substate = P2_SHIPS_STATE;
core->SetNextState(MakeSharedState<BattleshipPutShipsState>());
break;
case P2_SHIPS_STATE:
// After add the player's fleet, we'll send her/him to the game state.
data_->substate = P1_PLAY_STATE;
core->SetNextState(MakeSharedState<BattleshipGameState>());
break;
case P1_WAIT_STATE:
// The wait ends and the player 1 can now play.
data_->substate = P1_PLAY_STATE;
core->SetNextState(MakeSharedState<BattleshipGameState>());
break;
case P1_PLAY_STATE:
// First, we'll check that there is no winner.
if (data_->winner == NO_WINNER) {
// When there is no winner, we'll continue with the next turn.
if (data_->numberOfPlayers > 1) {
data_->substate = P2_WAIT_STATE;
core->SetNextState(MakeSharedState<BattleshipWaitState>());
} else {
machineTurn();
}
} else {
// If there is a winner, we'll call the game over state.
core->SetNextState(MakeSharedState<BattleshipGameOverState>());
}
break;
case P2_WAIT_STATE:
// The wait ends and the player 2 can now play.
data_->substate = P2_PLAY_STATE;
core->SetNextState(MakeSharedState<BattleshipGameState>());
break;
case P2_PLAY_STATE:
// First, we'll check that there is no winner.
if (data_->winner == NO_WINNER) {
// When there is no winner, we'll continue with the next turn.
data_->substate = P1_WAIT_STATE;
core->SetNextState(MakeSharedState<BattleshipWaitState>());
} else {
// If there is a winner, we'll call the game over state.
core->SetNextState(MakeSharedState<BattleshipGameOverState>());
}
break;
}
}
//********************************************************************************
// Singleton pattern ( http://en.wikipedia.org/wiki/Singleton_pattern )
//********************************************************************************
/**
* The main instance of the class.
*/
BattleshipManager * BattleshipManager::instance_ = nullptr;
//--------------------------------------------------------------------------------
/**
* Constructs a new object.
*/
BattleshipManager::BattleshipManager() : initialized_(false), data_(nullptr) {}
//--------------------------------------------------------------------------------
/**
* The destructor of the object.
*/
BattleshipManager::~BattleshipManager() {}
//--------------------------------------------------------------------------------
/**
* Gets the main instance of the class.
*/
BattleshipManager * BattleshipManager::Instance() {
if (!instance_) {
instance_ = new BattleshipManager();
}
return instance_;
}
//--------------------------------------------------------------------------------
/**
* Gets the main instance of the class.
*/
BattleshipManager & BattleshipManager::Reference() {
return *(Instance());
}
|
33f5e71b8da8cb8ed41b46eb6a5276a548e5104e | dd80a584130ef1a0333429ba76c1cee0eb40df73 | /external/chromium_org/chrome/browser/ui/webui/options/managed_user_learn_more_handler.h | 89cc25758544904e0fd61d3fabbfd1eff2742cbe | [
"BSD-3-Clause",
"MIT"
] | permissive | karunmatharu/Android-4.4-Pay-by-Data | 466f4e169ede13c5835424c78e8c30ce58f885c1 | fcb778e92d4aad525ef7a995660580f948d40bc9 | refs/heads/master | 2021-03-24T13:33:01.721868 | 2017-02-18T17:48:49 | 2017-02-18T17:48:49 | 81,847,777 | 0 | 2 | MIT | 2020-03-09T00:02:12 | 2017-02-13T16:47:00 | null | UTF-8 | C++ | false | false | 986 | h | managed_user_learn_more_handler.h | // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_LEARN_MORE_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_LEARN_MORE_HANDLER_H_
#include "chrome/browser/ui/webui/options/options_ui.h"
namespace base {
class DictionaryValue;
}
namespace options {
// Handler for the "Learn more" dialog available during creation of a managed
// user.
class ManagedUserLearnMoreHandler : public OptionsPageUIHandler {
public:
ManagedUserLearnMoreHandler();
virtual ~ManagedUserLearnMoreHandler();
// OptionsPageUIHandler implementation.
virtual void GetLocalizedValues(
base::DictionaryValue* localized_strings) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(ManagedUserLearnMoreHandler);
};
} // namespace options
#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_LEARN_MORE_HANDLER_H_
|
df9e053a024ac2ba0e645b14b41c28abfc7a745b | 3797cd31e9b09ae0a48cbd54bb2a211752294977 | /CG - programs in CPP/curve drawing/CIRCLE.CPP | 7c5eefd8558bbf795f29dd24911b638c375b2c45 | [
"Apache-2.0"
] | permissive | ranjiGT/Ton-of-Fun-with-Computer-Graphics | a079b028a5fb1d54bb4b8b011b8ad58e8715d7eb | e65103f0d962d37bceb5241a49c002ec95bd0db2 | refs/heads/master | 2023-05-03T06:36:38.443041 | 2021-05-26T20:45:52 | 2021-05-26T20:45:52 | 370,773,286 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,130 | cpp | CIRCLE.CPP | #include<stdio.h>
#include<conio.h>
#include<graphics.h>
void draw_circle(int r,int p,int q)
{
int d=(1.25-r),x,y;
x=0;
y=r;
while(x<y)
{
putpixel (x+320+p,y+240-q,WHITE);
putpixel (x+320+p,-y+240-q,WHITE);
putpixel (-x+320+p,y+240-q,WHITE);
putpixel (-x+320+p,-y+240-q,WHITE);
putpixel (y+320+p,x+240-q,WHITE);
putpixel (y+320+p,-x+240-q,WHITE);
putpixel (-y+320+p,x+240-q,WHITE);
putpixel (-y+320+p,-x+240-q,WHITE);
if (d<0)
{
x=x+1;
y=y;
d=d+(2*x)+1;
}
else
{
x=x+1;
y=y-1;
d=d+(2*x)-(2*y)+1;
}
}
}
void s_q()
{
setcolor(2);
cleardevice();
line(320,0,320,480);
line(0,240,640,240);
outtextxy(310,230,"O");
outtextxy(530,240,"X");
outtextxy(320,450,"-Y");
outtextxy(100,240,"-X");
outtextxy(320,30,"Y");
}
void main()
{
int r,x,y,i,j;
int gdriver = DETECT, gmode, errorcode;
clrscr();
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
s_q();
printf("enter radius & center(x,y)");
scanf("%d%d%d",&r,&x,&y);
putpixel(x+320,-y+240,WHITE);
draw_circle(r,x,y);
getch();
}
|
fe7b70c10ee55e5bc678e8842c164a651b7c03fe | f800ad9c5a45d47b689d6b08a9c50fbc4e7dfe3f | /inc/Graphics/Cursor.h | 735ea61c3981e415ceb05d6a383a33c01a937ebf | [] | no_license | toddsharpe/MetalOS | eeda64ed4bf933c6c21f9f0dc9674ca834383806 | 49832a02e14ddf1277b991efffe464a01ecc7ac5 | refs/heads/master | 2023-05-24T20:13:08.669451 | 2023-05-19T14:46:25 | 2023-05-19T14:46:25 | 207,470,032 | 39 | 0 | null | 2023-05-19T14:46:26 | 2019-09-10T05:08:11 | C++ | UTF-8 | C++ | false | false | 740 | h | Cursor.h | #pragma once
#include <cstdint>
#include <Graphics/FrameBuffer.h>
// Constant: font8x8_basic
// Contains an 8x8 font map for unicode points U+0000 - U+007F (basic latin)
namespace Graphics
{
class Cursor
{
public:
const uint16_t* GetMap() const
{
return (this->cursor8x8_basic);
}
private:
static constexpr uint16_t cursor8x8_basic[16] =
{
0b0011110000000000,
0b0011111000000000,
0b0011111100000000,
0b0011111110000000,
0b0011111111000000,
0b0011111111100000,
0b0011111111110000,
0b0011111111111000,
0b0011111111111100,
0b0011111111111100,
0b0011111111000000,
0b0011110111100000,
0b0011100111100000,
0b0011000011110000,
0b0000000011110000,
0b0000000001100000
};
};
}
|
dd28e493409f5698b657dd17eccee710be347a7a | f936f508e2c01b227706c2e1dd34d0f6e7a1221e | /src/sdl2/main_sdl.cpp | 7d83c9669e46c2d7c8808e8d3bd68d8b16919273 | [] | no_license | ComeDemolliere/SoCarre | 88449ece298c7fee2f6cbce1e408f34ba4aabf19 | 308d7e4687e5424c278aef9a9f75a70075b5a9bb | refs/heads/master | 2020-04-10T13:02:43.108336 | 2019-01-06T10:52:53 | 2019-01-06T10:52:53 | 161,038,189 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 153 | cpp | main_sdl.cpp | #include "sdlJeu.h"
#include <iostream>
using namespace std;
int main (int argc, char** argv)
{
sdlJeu j;
j.sdlBoucle();
return EXIT_SUCCESS;
}
|
1074b52312b18ebd1c83ac9ceef71a4a9b36d7f3 | 51baeb1f56beaf6f00b6a405550c2ee768827752 | /source/_old_code/mainwindow.cpp | a0600e4c22123e7380a10c913d6a5def99b39372 | [
"MIT"
] | permissive | DarkZeros/FreedomDB | 15c1ec7332a76278dd91b4db640eaf800139a602 | 1c653ca99e2f753fb1a683f440511f914fe82d89 | refs/heads/master | 2023-04-14T14:45:01.287684 | 2021-04-13T01:43:46 | 2021-04-14T00:07:20 | 341,376,788 | 0 | 1 | MIT | 2021-04-23T15:35:03 | 2021-02-23T00:23:09 | C | UTF-8 | C++ | false | false | 1,873 | cpp | mainwindow.cpp | #include "mainwindow.h"
#include "ui_mainwindow.h"
#include <functional>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
dbc_auto_logger("DB Client")
{
ui->setupUi(this);
//Attach the logger
dbc_auto_logger.attach(std::bind(&MainWindow::logs_callback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
//Initialize core
if(!dbc.initialize()){
//TODO show window with the reason
QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);
}
}
MainWindow::~MainWindow() {
delete ui;
}
void MainWindow::logs_callback(DBC::LogType type, DBC::LogLevel level, const std::string & str){
//Create color with level
QColor color(0,0,0);
switch(level){
case DBC::LogLevel::DEBUG: color.setBlue(200); break;
case DBC::LogLevel::INFO: color.setGreen(100); break;
case DBC::LogLevel::WARNING: color = QColor(239, 127, 26); break;
case DBC::LogLevel::ERROR: color.setRed(250); break;
default: break;
}
//Construct string from str & type
QString qstr;
if(type != DBC::LogType::NOTYPE){
qstr.append(QString(DBC::Logger::type2str[type]));
qstr.append(QString(": "));
}
qstr.append(QString(str.c_str()));
//Queue it to be run by the UI
QMetaObject::invokeMethod(this, "append_log", Qt::QueuedConnection,
Q_ARG(QColor, color), Q_ARG(QString, qstr));
}
void MainWindow::append_log(QColor color, QString qstr){
ui->textBrowser->setTextColor(color);
ui->textBrowser->append(qstr);
}
void MainWindow::update_p2p(){
ui->status_p2p_connections->setText(QString(dbc.mP2P.mClientSocket));
ui->textBrowser->append(qstr);
}
void MainWindow::on_actionClose_triggered() {
QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);
}
|
97c3025b9b7405e01a05b5d9871e80e058b370ad | 07a950800a4170115a9d037fc8e147d521e906a3 | /pattern/patterns/pattern28/p28.cpp | a48f72711a72caf706b5e113e8f295025fb2371c | [] | no_license | Smit6/AlgorithmQuestions | 39504444a70ea3d4c767e43c409287719544797b | adf8211a92262e6d927a0ace2ac2ca68f14d567c | refs/heads/master | 2020-03-25T16:53:29.031780 | 2018-11-15T09:24:40 | 2018-11-15T09:24:40 | 143,952,561 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 967 | cpp | p28.cpp | #include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main () {
int k;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 5; j++) {
if (i <= 3) {
if (j >= 6 - i)
cout << "*";
else
cout << " ";
} else if (i <= 6) {
k = 0;
if (j == 3) {
k = 1;
cout << "|";
}
if (j <= i - 4) {
k = 1;
cout << "*";
}
if (j >= i) {
k = 1;
cout << "*";
}
if (k == 0)
cout << " ";
} else if (i <= 9) {
if (j <= 10 - i)
cout << "*";
else
cout << " ";
}
}
cout << endl;
}
} |
eca33fe21b2ed6b44df7ce980bae421d2cfa14a2 | a756eed9030c5afa645436412d777a1774357c70 | /CP/june.cpp | 91007059dbbf56c1556db19fc159381608416035 | [] | no_license | jainsourav43/DSA | fc92faa7f8e95151c8f0af4c69228d4db7e1e5ce | deb46f70a1968b44bb28389d01b35cb571a8c293 | refs/heads/master | 2021-05-25T09:13:42.418930 | 2020-06-30T07:36:56 | 2020-06-30T07:36:56 | 126,943,860 | 0 | 1 | null | 2020-06-30T07:36:57 | 2018-03-27T07:07:51 | C++ | UTF-8 | C++ | false | false | 2,148 | cpp | june.cpp | #include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define mod2 1000000006
#define ll long long
using namespace std;
ll a[100001],b[100001],c[100001];
ll prea[100001],preb[100001],prec[100001];
bool comp(ll a,ll b)
{
return a>b;
}
int main()
{
int t;
cin>>t;
while(t--)
{
ll p,q,r,i,j,k;
scanf("%lld %lld %lld ",&p,&q,&r);
// cout<<p<<q<<r;
// cin>>p>>q>>r;
for(i=0;i<p;i++)
{
scanf("%lld",&a[i]);
//cin>>a[i];
}
for(j=0;j<q;j++)
{
scanf("%lld",&b[j]);
// cin>>b[j];
}
for(i=0;i<r;i++)
{
scanf("%lld",&c[i]);
// cin>>c[i];
}
sort(a,a+p);
sort(b,b+q,comp);
sort(c,c+r);
ll sum=0,count=0;
prea[0]=a[0];
preb[0]=b[0];
prec[0]=c[0];
for(i=1;i<p;i++)
{
prea[i]=(prea[i-1]+a[i]);
if(prea[i]>mod2)
prea[i]=prea[i]%mod;
}
for(i=1;i<r;i++)
{
prec[i]=prec[i-1]+c[i];
if(prec[i]>mod2)
prec[i]=prec[i]%mod;
}
ll p1,p2,p3,a1,b1,c1,d1,e1,f1,g1;
i=0;
//p1=upper_bound(a,a+p,b[0])-a;
// p2=upper_bound(c,c+r,b[0])-c;
while(b[i]>=c[r-1]&&b[i]>=a[p-1]&&i<q)
{
a1=prea[p-1];
b1=p*b[i];
c1=prec[r-1];
d1=r*b[i];
if(b1>mod2)
b1=b1%mod;
if(d1>mod2)
d1=d1%mod;
e1=a1+b1;
f1=c1+d1;
if(e1>mod2)
e1=e1%mod;
if(f1>mod2)
f1=f1%mod;
g1=e1*f1;
if(g1>mod2)
g1=g1%mod;
sum=sum+g1;
if(sum>mod2)
sum=sum%mod;
// sum=(sum+((((prea[p-1]+(p*b[i])%mod)%mod)*((prec[r-1]+(r*b[i])%mod)%mod))%mod))%mod;
i++;
}
int i1=i;
// cout<<i1<<endl;
for(i=i1;i<q;i++)
{
p1=upper_bound(a,a+p,b[i])-a;
p2=upper_bound(c,c+r,b[i])-c;
if(p1>0&&p2>0)
{
a1=prea[p1-1];
b1=p1*b[i];
c1=prec[p2-1];
d1=p2*b[i];
if(b1>mod2)
b1=b1%mod;
if(d1>mod2)
d1=d1%mod;
e1=a1+b1;
f1=c1+d1;
if(e1>mod2)
e1=e1%mod;
if(f1>mod2)
f1=f1%mod;
g1=e1*f1;
if(g1>mod2)
g1=g1%mod;
sum=sum+g1;
if(sum>mod2)
sum=sum%mod;
}
else
break;
}
cout<<sum<<endl;
}
}
|
2bf190976ca6fe3d81de800e42116bce1d2e5ce5 | 0b69a011c9ffee099841c140be95ed93c704fb07 | /problemsets/UVA/450.cpp | 2b361a6b6f6a3cf0a5b00809850c331a6bff8b60 | [
"Apache-2.0"
] | permissive | juarezpaulino/coderemite | 4bd03f4f2780eb6013f07c396ba16aa7dbbceea8 | a4649d3f3a89d234457032d14a6646b3af339ac1 | refs/heads/main | 2023-01-31T11:35:19.779668 | 2020-12-18T01:33:46 | 2020-12-18T01:33:46 | 320,931,351 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,358 | cpp | 450.cpp | /**
*
* Author: Juarez Paulino(coderemite)
* Email: juarez.paulino@gmail.com
*
*/
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
using namespace std;
struct data {
string s[8];
};
vector<int> I;
vector<data> D;
bool cmp(const int &A, const int &B) {
return D[A].s[3] < D[B].s[3];
}
int main() {
int N, M = 0;
scanf("%d ", &N);
while (N--) {
char dep[1010], S[1010], *s;
if (!gets(dep)) break;
while (gets(S)) {
if (!*S) break;
s = strtok(S,",");
data d;
d.s[0] = dep;
for (int i = 1; i < 8; i++) {
d.s[i] = s;
s = strtok(NULL,",");
}
D.push_back(d);
I.push_back(M++);
}
}
sort(I.begin(), I.end(), cmp);
for (int i = 0; i < M; i++) {
puts("----------------------------------------");
printf("%s %s %s\n", D[I[i]].s[1].c_str(), D[I[i]].s[2].c_str(), D[I[i]].s[3].c_str());
printf("%s\n", D[I[i]].s[4].c_str());
printf("Department: %s\n", D[I[i]].s[0].c_str());
printf("Home Phone: %s\n", D[I[i]].s[5].c_str());
printf("Work Phone: %s\n", D[I[i]].s[6].c_str());
printf("Campus Box: %s\n", D[I[i]].s[7].c_str());
}
return 0;
}
|
35f3f7e0b9e508625e8a857f4695fac0dfd85fc7 | 6840ae43a5940718926e74de4848a7153d176fd0 | /Software/Regional/Bibliotecas/ArduinoSensors/examples/Ultrasonic Sensors/HCSR04/HCSR04.ino | c60d4854e452b3f4e751f9ccc522f55433a4c0cb | [
"MIT"
] | permissive | rodigozeus/OBR-2017 | 91cc3f9680d2e5f5d94756b3063c3a905600e455 | 12c86cae5523ffc360d0658d08a0c3d84a21c100 | refs/heads/master | 2021-06-24T00:46:48.086896 | 2017-09-08T20:17:11 | 2017-09-08T20:17:11 | 208,912,693 | 1 | 0 | MIT | 2019-09-16T22:56:00 | 2019-09-16T22:56:00 | null | UTF-8 | C++ | false | false | 485 | ino | HCSR04.ino | #include <Thread.h>
#include <ArduinoSensors.h>
#include <sensors/PingUltrasonic.h>
/*
Echo and Trigger pins must be the same
to your connections on the arduino
*/
int echoPin = 12;
int triggerPin = 13;
PingUltrasonic myUltrasonic(triggerPin, echoPin);
void setup() {
Serial.begin(9600);
Serial.println("I'm alive!");
}
void loop()
{
float distance = myUltrasonic.readDistance();
Serial.print("Distance: ");
Serial.print(distance);
Serial.println("cm");
delay(100);
}
|
b577e77284239a37edfe23edb4cf780bbe6e6939 | 0c47cd869933d025bfab82ea064b69d7b1d203d7 | /ElectorsList.h | 48f9070aca98af63036eb0e944d1cd845690c6a0 | [] | no_license | keissar3/Election-system | 150f1389218c652d1741388f9ed5dfd2e3d8192f | 84d1b5690071d806d23320de2e5c76542c0fbe41 | refs/heads/main | 2023-03-10T02:29:12.325701 | 2021-02-22T15:27:06 | 2021-02-22T15:27:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 322 | h | ElectorsList.h | #pragma once
#include "CitizenList.h"
#include "DynamicArray.h"
class ElectorsList : public CitizenList {
public:
ElectorsList() :CitizenList() {}
virtual ~ElectorsList() {}
ElectorsList(const CitizenList& citlist) :CitizenList(citlist) {}
void load(istream& in_file, DynamicArray<District*> disArray);
}; |
05966f6a3e726142f4e079ff5a1d9abd1816a165 | 53c7be0b11e36b0cfec43b27e844b100df5f455b | /src/platform/platform.hpp | e905d981626d70853e468a630c2f4d7c068d0669 | [] | no_license | enigames/mirb | 39539fa2e086eac3d79ac7f44a90e2fcb0acec9c | 14c2fe2d2a026fb3bb62c883e8839e1078ebc3b6 | refs/heads/master | 2022-01-28T15:46:44.326325 | 2012-06-29T18:16:13 | 2012-06-29T18:16:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,769 | hpp | platform.hpp | #pragma once
#include "../common.hpp"
#include "../char-array.hpp"
#include "../runtime.hpp"
#include "../stream.hpp"
namespace Mirb
{
namespace Platform
{
enum Access
{
Read = 1,
Write = 2
};
enum Mode
{
Open,
CreateTruncate,
CreateAppend
};
size_t stack_start();
size_t stack_limit();
double get_time();
struct empty_path_error {};
template<typename F> void wrap(F func)
{
try
{
func();
}
catch(empty_path_error)
{
raise(context->system_call_error, "Empty path");
}
}
struct ColorWrapperBase
{
value_t output;
OnStack<1> os;
ColorWrapperBase(value_t output) : output(output), os(output) {}
void print(const CharArray &string);
};
CharArray join(const CharArray &left, const CharArray &right);
CharArray native_path(const CharArray &path);
CharArray ruby_path(const CharArray &path);
class NativeStream;
NativeStream *open(const CharArray &path, size_t access, Mode mode);
class ConsoleStream;
enum ConsoleStreamType
{
StandardInput,
StandardOutput,
StandardError
};
ConsoleStream *console_stream(ConsoleStreamType type);
bool has_size(const CharArray &path) throw();
bool is_file(const CharArray &path) throw();
bool is_directory(const CharArray &path) throw();
bool is_executable(const CharArray &path) throw();
bool file_exists(const CharArray &path) throw();
void remove_file(const CharArray &path);
void remove_dir(const CharArray &path);
void mkdir(const CharArray &path);
CharArray cwd();
void *allocate_region(size_t bytes);
void free_region(void *region, size_t bytes);
void initialize();
void finalize();
};
};
#ifdef WIN32
#include "winapi.hpp"
#else
#include "posix.hpp"
#endif
|
39f21045211a123bda831af67f36bfc2ac92b3a7 | c86d1d27476ad5275e7b3dc20ea409d4bdb513c1 | /Homework/hw6/GameObject.cpp | 6f6d3607cd3a58c6ddd05ce02db881a2280d279e | [] | no_license | benjamin-weinberg/CIE2017 | 4581dd37c0f23a65d46e85d71c95506009466ab7 | ce77be515866eefc5bc1ee58a45a7398e5915008 | refs/heads/master | 2020-04-21T07:08:56.675219 | 2019-02-06T10:20:26 | 2019-02-06T10:20:26 | 169,385,190 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 438 | cpp | GameObject.cpp | //
// Created by Johnson, Hans J on 4/22/17.
//
#include "CharacterBase.h"
GameObject::GameObject(const string name, const HealthStatus& hs)
:m_name{name}, m_HealthStatus{hs} { }
const string& GameObject::getName() const
{
return m_name;
}
const HealthStatus& GameObject::getHealthStatus() const
{
return m_HealthStatus;
}
void GameObject::setHealthStatus(const HealthStatus& HealthStatus)
{
m_HealthStatus = HealthStatus;
}
|
3a7ca0a0a1f73f4a88b350c497550df5b5af0b1e | 4334b7da7337d01f1f8043e0d260fd2be99473d9 | /src/PartSelectionDialog.cpp | 0347134e0f9c174f6f6c7c85a3a701ba6e1f4d94 | [] | no_license | nightingalesystem/thrustTester | fae27295f32f71637e54393341f93dd7fc074c31 | 2f6584b24d23b3d95fc6b26a030e83aa7719663f | refs/heads/master | 2021-04-26T11:57:10.276945 | 2018-03-06T23:56:27 | 2018-03-06T23:56:27 | 124,006,128 | 0 | 0 | null | 2018-03-06T23:56:28 | 2018-03-06T02:05:50 | C++ | UTF-8 | C++ | false | false | 11,624 | cpp | PartSelectionDialog.cpp | #include <QUrl>
#include <QCloseEvent>
#include <QKeyEvent>
#include "json/json.h"
#include "PartSelectionDialog.h"
#include "ui_partselectiondialog.h"
#include "Log.h"
#include "Settings.h"
#include "util.h"
PartSelectionDialog::PartSelectionDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::PartSelectionDialog)
{
ui->setupUi(this);
m_ignoreComboboxSelections = false;
m_urls[PC_MOTOR] = "/tts/motors.php";
m_urls[PC_ESC] = "/tts/escs.php";
m_urls[PC_PROP] = "/tts/props.php";
m_urls[PC_MCU] = "/tts/mcus.php";
m_urls[PC_MATERIAL] = "/tts/materials.php";
// these will be displayed in the dialog
m_partNames.append("motor");
m_partNames.append("ESC");
m_partNames.append("propeller");
m_partNames.append("MCU");
m_partNames.append("material");
// these are for keys in the saved settings
m_settingsKeys.append("motor");
m_settingsKeys.append("esc");
m_settingsKeys.append("prop");
m_settingsKeys.append("mcu");
m_settingsKeys.append("material");
m_requestInProgress = false;
//m_http = new QHttp(this);
//connect(m_http, SIGNAL(done(bool)), this, SLOT(onRequestCompleted(bool)));
{
SetBoolTemporarily dummy(&m_ignoreComboboxSelections, true);
updateMotorCombobox();
updateESCCombobox();
updatePropCombobox();
updateMcuCombobox();
updateMaterialCombobox();
}
}
PartSelectionDialog::~PartSelectionDialog()
{
delete ui;
}
void PartSelectionDialog::accept()
{
if ( m_requestInProgress )
return;
writeSettings();
QDialog::accept();
}
void PartSelectionDialog::reject()
{
if ( m_requestInProgress )
return;
writeSettings();
QDialog::reject();
}
void PartSelectionDialog::on_partsDownloadButton_clicked()
{
ui->partsDownloadButton->setEnabled(false);
m_currentPartCategory = 0;
m_requestInProgress = true;
ui->partsDownloadTextBrowser->append( "Contacting server..." );
startRequest();
}
void PartSelectionDialog::startRequest()
{
QUrl url;
url.setPath( m_urls[m_currentPartCategory] );
//url.addQueryItem( "param" , value);
/*m_http->setHost( "www.iforce2d.net" );
m_http->get(url.toString());*/
QUrl serviceUrl = QUrl( QString("http://www.iforce2d.net/") + m_urls[m_currentPartCategory] );
QNetworkRequest request( serviceUrl );
QByteArray data;
QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onRequestCompleted(QNetworkReply*)));
networkManager->post(request, data );
g_log.log(LL_DEBUG, QString("Downloading %1 data...").arg( m_partNames[m_currentPartCategory]));
}
void PartSelectionDialog::onRequestCompleted(QNetworkReply *reply)
{
g_log.log(LL_DEBUG, QString("Finished request, error:%1").arg(reply->error()));
m_requestInProgress = false;
if ( reply->error() ) {
ui->partsDownloadTextBrowser->append( "Error contacting server." );
ui->partsDownloadTextBrowser->append( reply->errorString() );
ui->partsDownloadButton->setEnabled(true);
return;
}
QString jsonStr = QString::fromUtf8( reply->readAll() );
g_log.log(LL_DEBUG, QString(" response: %1").arg(jsonStr));
Json::Value responseValue;
Json::Reader reader;
if ( ! reader.parse(jsonStr.toStdString(), responseValue) )
{
QString("Failed to parse JSON : %1").arg( QString(reader.getFormatedErrorMessages().c_str()) );
ui->partsDownloadTextBrowser->append( "Error parsing response." );
ui->partsDownloadButton->setEnabled(true);
return;
}
if ( !responseValue.isArray() ) {
ui->partsDownloadTextBrowser->append( "Error finding main array." );
ui->partsDownloadButton->setEnabled(true);
return;
}
// save
switch (m_currentPartCategory) {
case PC_MOTOR: g_motorData = jsonStr; break;
case PC_ESC: g_escData = jsonStr; break;
case PC_PROP: g_propData = jsonStr; break;
case PC_MCU: g_mcuData = jsonStr; break;
case PC_MATERIAL: g_materialData = jsonStr; break;
default: g_log.log(LL_ERROR, "Invalid part category");
}
m_currentPartCategory++;
if ( m_currentPartCategory < PC_MAX ) {
startRequest();
return;
}
// success!
writeSettings();
g_log.log(LL_DEBUG, QString("... finished."));
ui->partsDownloadTextBrowser->append( "Download finished OK." );
ui->partsDownloadTextBrowser->append( "Updating UI..." );
{
SetBoolTemporarily dummy(&m_ignoreComboboxSelections, true);
updateMotorCombobox();
updateESCCombobox();
updatePropCombobox();
updateMcuCombobox();
updateMaterialCombobox();
}
ui->partsDownloadTextBrowser->append( "Done." );
ui->partsDownloadButton->setEnabled(true);
}
void PartSelectionDialog::updateMotorCombobox()
{
g_log.log(LL_DEBUG, __PRETTY_FUNCTION__);
if ( g_motorData == "" )
return; // probably first time run
Json::Value arrayValue;
Json::Reader reader;
if ( ! reader.parse( g_motorData.toStdString(), arrayValue) )
{
QString("Failed to parse motor JSON : %1").arg( QString(reader.getFormatedErrorMessages().c_str()) );
ui->partsDownloadTextBrowser->append( "Error parsing response." );
return;
}
ui->motorSelectComboBox->clear();
ui->motorSelectComboBox->addItem("Unknown", -1);
for (int i = 0; i < (int)arrayValue.size(); i++) {
Json::Value part = arrayValue[i];
int partId = part.get("id",0).asInt();
string maker = part.get("maker","").asString();
string name = part.get("name","").asString();
int diameter = part.get("diameter",0).asInt();
int height = part.get("height",0).asInt();
int kv = part.get("kv",0).asInt();
QString displayText = QString("%1 %2 %3%4 %5kv").arg(maker.c_str()).arg(name.c_str()).arg(diameter).arg(height,2,10,QChar('0')).arg(kv);
ui->motorSelectComboBox->addItem(displayText, partId);
}
setCurrentIndexByItemData(ui->motorSelectComboBox, g_selectedMotorId);
}
void PartSelectionDialog::updateESCCombobox()
{
g_log.log(LL_DEBUG, __PRETTY_FUNCTION__);
if ( g_escData == "" )
return; // probably first time run
Json::Value arrayValue;
Json::Reader reader;
if ( ! reader.parse( g_escData.toStdString(), arrayValue) )
{
QString("Failed to parse ESC JSON : %1").arg( QString(reader.getFormatedErrorMessages().c_str()) );
ui->partsDownloadTextBrowser->append( "Error parsing response." );
return;
}
ui->escSelectComboBox->clear();
ui->escSelectComboBox->addItem("Unknown", -1);
for (int i = 0; i < (int)arrayValue.size(); i++) {
Json::Value part = arrayValue[i];
int partId = part.get("id",0).asInt();
string maker = part.get("maker","").asString();
string name = part.get("name","").asString();
int current = part.get("current",0).asInt();
QString displayText = QString("%1 %2 %3A").arg(maker.c_str()).arg(name.c_str()).arg(current);
ui->escSelectComboBox->addItem(displayText, partId);
}
setCurrentIndexByItemData(ui->escSelectComboBox, g_selectedEscId);
}
void PartSelectionDialog::updatePropCombobox()
{
g_log.log(LL_DEBUG, __PRETTY_FUNCTION__);
if ( g_propData == "" )
return; // probably first time run
Json::Value arrayValue;
Json::Reader reader;
if ( ! reader.parse( g_propData.toStdString(), arrayValue) )
{
QString("Failed to parse prop JSON : %1").arg( QString(reader.getFormatedErrorMessages().c_str()) );
ui->partsDownloadTextBrowser->append( "Error parsing response." );
return;
}
ui->propSelectComboBox->clear();
ui->propSelectComboBox->addItem("Unknown", -1);
for (int i = 0; i < (int)arrayValue.size(); i++) {
Json::Value part = arrayValue[i];
int partId = part.get("id",0).asInt();
string maker = part.get("maker","").asString();
string name = "";//part.get("name","").asString();
float diameter = part.get("diameter",0).asFloat();
int blades = part.get("blades",0).asInt();
float pitch = part.get("pitch",0).asFloat();
string material = part.get("material","").asString();
QString displayText = QString("%1 %2 %3x%4 %5 blade %6").arg(maker.c_str()).arg(name.c_str()).arg(diameter).arg(pitch).arg(blades).arg(material.c_str());
ui->propSelectComboBox->addItem(displayText, partId);
}
setCurrentIndexByItemData(ui->propSelectComboBox, g_selectedPropId);
}
void PartSelectionDialog::updateMcuCombobox()
{
g_log.log(LL_DEBUG, __PRETTY_FUNCTION__);
if ( g_mcuData == "" )
return; // probably first time run
Json::Value arrayValue;
Json::Reader reader;
if ( ! reader.parse( g_mcuData.toStdString(), arrayValue) )
{
QString("Failed to parse mcu JSON : %1").arg( QString(reader.getFormatedErrorMessages().c_str()) );
ui->partsDownloadTextBrowser->append( "Error parsing response." );
return;
}
ui->escMcuComboBox->clear();
for (int i = 0; i < (int)arrayValue.size(); i++) {
Json::Value part = arrayValue[i];
int partId = part.get("id",0).asInt();
string maker = part.get("maker","").asString();
string mcu = part.get("mcu","").asString();
QString displayText = QString("%1 %2").arg(maker.c_str()).arg(mcu.c_str());
ui->escMcuComboBox->addItem(displayText, partId);
}
}
void PartSelectionDialog::updateMaterialCombobox()
{
g_log.log(LL_DEBUG, __PRETTY_FUNCTION__);
if ( g_materialData == "" )
return; // probably first time run
Json::Value arrayValue;
Json::Reader reader;
if ( ! reader.parse( g_materialData.toStdString(), arrayValue) )
{
QString("Failed to parse material JSON : %1").arg( QString(reader.getFormatedErrorMessages().c_str()) );
ui->partsDownloadTextBrowser->append( "Error parsing response." );
return;
}
ui->propMaterialComboBox->clear();
for (int i = 0; i < (int)arrayValue.size(); i++) {
Json::Value part = arrayValue[i];
int partId = part.get("id",0).asInt();
string name = part.get("name","").asString();
//string material = part.get("material","").asString();
QString displayText = QString("%1").arg(name.c_str());
ui->propMaterialComboBox->addItem(displayText, partId);
}
}
void PartSelectionDialog::on_motorSelectComboBox_currentIndexChanged(int index)
{
if ( m_ignoreComboboxSelections )
return;
int partId = ui->motorSelectComboBox->itemData( index ).toInt();
g_log.log(LL_DEBUG, QString("Selected motor %1").arg(partId));
g_selectedMotorId = partId;
}
void PartSelectionDialog::on_propSelectComboBox_currentIndexChanged(int index)
{
if ( m_ignoreComboboxSelections )
return;
int partId = ui->propSelectComboBox->itemData( index ).toInt();
g_log.log(LL_DEBUG, QString("Selected prop %1").arg(partId));
g_selectedPropId = partId;
}
void PartSelectionDialog::on_escSelectComboBox_currentIndexChanged(int index)
{
if ( m_ignoreComboboxSelections )
return;
int partId = ui->escSelectComboBox->itemData( index ).toInt();
g_log.log(LL_DEBUG, QString("Selected ESC %1").arg(partId));
g_selectedEscId = partId;
}
|
7457209df279ac78a3ad4591be0763c12e0c35ed | 4352b5c9e6719d762e6a80e7a7799630d819bca3 | /tutorials/eulerVortex.twitch/eulerVortex.cyclic.twitch.test.test/processor3/2.57/rho | 4027c4b1da9ea58a4c4b9b6d163919e4991baed4 | [] | no_license | dashqua/epicProject | d6214b57c545110d08ad053e68bc095f1d4dc725 | 54afca50a61c20c541ef43e3d96408ef72f0bcbc | refs/heads/master | 2022-02-28T17:20:20.291864 | 2019-10-28T13:33:16 | 2019-10-28T13:33:16 | 184,294,390 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 45,951 | rho | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "2.57";
object rho;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -3 0 0 0 0 0];
internalField nonuniform List<scalar>
5625
(
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.39999
1.39999
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40002
1.40002
1.40002
1.40002
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40002
1.40002
1.40002
1.40002
1.40002
1.40002
1.40002
1.40002
1.40002
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.4
1.4
1.40001
1.40001
1.40001
1.40002
1.40002
1.40002
1.40002
1.40002
1.40003
1.40003
1.40003
1.40002
1.40002
1.40002
1.40002
1.40002
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39999
1.39999
1.39999
1.39999
1.39998
1.39998
1.39998
1.39998
1.39998
1.39998
1.39998
1.39999
1.39999
1.39999
1.4
1.4
1.40001
1.40001
1.40002
1.40002
1.40002
1.40003
1.40003
1.40003
1.40003
1.40003
1.40003
1.40003
1.40003
1.40003
1.40003
1.40002
1.40002
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39999
1.39998
1.39998
1.39998
1.39998
1.39998
1.39997
1.39997
1.39997
1.39998
1.39998
1.39998
1.39999
1.39999
1.4
1.4
1.40001
1.40001
1.40002
1.40003
1.40003
1.40003
1.40004
1.40004
1.40004
1.40004
1.40004
1.40004
1.40004
1.40004
1.40003
1.40003
1.40003
1.40002
1.40002
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39998
1.39998
1.39998
1.39997
1.39997
1.39997
1.39997
1.39997
1.39997
1.39997
1.39997
1.39998
1.39998
1.39999
1.4
1.4
1.40001
1.40002
1.40003
1.40003
1.40004
1.40005
1.40005
1.40005
1.40005
1.40005
1.40005
1.40005
1.40005
1.40004
1.40004
1.40004
1.40003
1.40003
1.40003
1.40002
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39998
1.39997
1.39997
1.39996
1.39996
1.39996
1.39996
1.39996
1.39996
1.39996
1.39997
1.39997
1.39998
1.39999
1.4
1.40001
1.40002
1.40003
1.40004
1.40005
1.40005
1.40006
1.40006
1.40007
1.40007
1.40007
1.40007
1.40006
1.40006
1.40006
1.40005
1.40005
1.40004
1.40004
1.40003
1.40003
1.40002
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39997
1.39996
1.39996
1.39996
1.39995
1.39995
1.39995
1.39995
1.39995
1.39996
1.39996
1.39997
1.39998
1.39999
1.40001
1.40002
1.40003
1.40004
1.40006
1.40007
1.40008
1.40008
1.40009
1.40009
1.40009
1.40009
1.40009
1.40008
1.40008
1.40007
1.40007
1.40006
1.40005
1.40004
1.40004
1.40003
1.40003
1.40002
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39996
1.39996
1.39995
1.39995
1.39994
1.39994
1.39994
1.39994
1.39995
1.39996
1.39997
1.39998
1.39999
1.40001
1.40002
1.40004
1.40005
1.40007
1.40008
1.40009
1.4001
1.40011
1.40012
1.40012
1.40012
1.40012
1.40011
1.40011
1.4001
1.40009
1.40008
1.40007
1.40006
1.40006
1.40005
1.40004
1.40003
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39995
1.39995
1.39994
1.39994
1.39993
1.39993
1.39993
1.39994
1.39995
1.39996
1.39997
1.39999
1.40001
1.40003
1.40005
1.40007
1.40009
1.40011
1.40012
1.40014
1.40015
1.40016
1.40016
1.40016
1.40016
1.40016
1.40015
1.40014
1.40013
1.40012
1.40011
1.40009
1.40008
1.40007
1.40006
1.40005
1.40004
1.40003
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39994
1.39994
1.39993
1.39993
1.39993
1.39993
1.39993
1.39994
1.39996
1.39997
1.39999
1.40002
1.40004
1.40007
1.4001
1.40012
1.40015
1.40017
1.40019
1.4002
1.40021
1.40022
1.40022
1.40022
1.40022
1.40021
1.4002
1.40018
1.40017
1.40015
1.40013
1.40012
1.4001
1.40009
1.40007
1.40006
1.40005
1.40004
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39994
1.39993
1.39993
1.39992
1.39993
1.39993
1.39994
1.39996
1.39998
1.40001
1.40004
1.40007
1.40011
1.40014
1.40018
1.40021
1.40024
1.40027
1.40029
1.4003
1.40031
1.40031
1.40031
1.40031
1.40029
1.40028
1.40026
1.40024
1.40022
1.4002
1.40017
1.40015
1.40013
1.40011
1.40009
1.40007
1.40006
1.40005
1.40004
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39993
1.39993
1.39992
1.39993
1.39993
1.39995
1.39997
1.4
1.40003
1.40007
1.40011
1.40016
1.40021
1.40026
1.4003
1.40034
1.40038
1.40041
1.40043
1.40045
1.40045
1.40045
1.40044
1.40043
1.40041
1.40038
1.40035
1.40032
1.40029
1.40025
1.40022
1.40019
1.40016
1.40014
1.40011
1.40009
1.40007
1.40006
1.40004
1.40003
1.40003
1.40002
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39993
1.39993
1.39993
1.39994
1.39996
1.39999
1.40002
1.40007
1.40012
1.40018
1.40024
1.40031
1.40037
1.40044
1.4005
1.40055
1.4006
1.40063
1.40065
1.40067
1.40066
1.40065
1.40063
1.4006
1.40057
1.40052
1.40048
1.40043
1.40038
1.40034
1.40029
1.40025
1.40021
1.40017
1.40014
1.40011
1.40009
1.40007
1.40005
1.40004
1.40003
1.40002
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39994
1.39994
1.39996
1.39998
1.40001
1.40006
1.40011
1.40018
1.40026
1.40035
1.40044
1.40053
1.40063
1.40071
1.40079
1.40086
1.40092
1.40096
1.40098
1.40098
1.40097
1.40095
1.4009
1.40085
1.40079
1.40073
1.40066
1.40059
1.40051
1.40045
1.40038
1.40032
1.40027
1.40022
1.40018
1.40014
1.40011
1.40009
1.40006
1.40005
1.40003
1.40002
1.40002
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.39996
1.39998
1.4
1.40005
1.4001
1.40018
1.40027
1.40037
1.40049
1.40062
1.40075
1.40088
1.40101
1.40113
1.40123
1.40132
1.40139
1.40143
1.40145
1.40145
1.40142
1.40136
1.4013
1.40121
1.40112
1.40101
1.40091
1.4008
1.4007
1.4006
1.40051
1.40043
1.40035
1.40029
1.40023
1.40018
1.40014
1.40011
1.40008
1.40006
1.40004
1.40003
1.40002
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.40004
1.40009
1.40016
1.40026
1.40037
1.40051
1.40066
1.40083
1.40102
1.4012
1.40139
1.40157
1.40173
1.40187
1.40198
1.40207
1.40211
1.40213
1.4021
1.40205
1.40196
1.40185
1.40172
1.40157
1.40142
1.40126
1.40111
1.40095
1.40081
1.40068
1.40057
1.40046
1.40037
1.4003
1.40023
1.40018
1.40013
1.4001
1.40007
1.40005
1.40003
1.40002
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40007
1.40014
1.40023
1.40034
1.40049
1.40066
1.40087
1.4011
1.40134
1.4016
1.40187
1.40212
1.40237
1.40259
1.40277
1.40292
1.40302
1.40307
1.40307
1.40302
1.40293
1.40279
1.40262
1.40243
1.40221
1.40198
1.40175
1.40153
1.40131
1.40111
1.40093
1.40076
1.40062
1.40049
1.40039
1.4003
1.40023
1.40017
1.40012
1.40008
1.40005
1.40003
1.40002
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40019
1.40029
1.40044
1.40062
1.40084
1.4011
1.40139
1.40172
1.40207
1.40244
1.4028
1.40316
1.40349
1.40378
1.40403
1.40421
1.40434
1.40439
1.40438
1.4043
1.40415
1.40395
1.4037
1.40341
1.40309
1.40277
1.40244
1.40212
1.40181
1.40152
1.40126
1.40103
1.40083
1.40066
1.40051
1.40039
1.40029
1.40021
1.40015
1.4001
1.40007
1.40004
1.40002
1.40001
1.4
1.4
1.39999
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40036
1.40053
1.40075
1.40102
1.40134
1.40172
1.40214
1.4026
1.40309
1.4036
1.4041
1.40458
1.40502
1.40541
1.40573
1.40597
1.40613
1.40618
1.40615
1.40602
1.4058
1.40551
1.40515
1.40474
1.4043
1.40384
1.40337
1.40292
1.40249
1.40209
1.40172
1.4014
1.40112
1.40088
1.40068
1.40052
1.40038
1.40028
1.40019
1.40013
1.40008
1.40005
1.40002
1.40001
1.4
1.39999
1.39999
1.39999
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40062
1.40088
1.4012
1.40159
1.40206
1.40259
1.40318
1.40382
1.40449
1.40517
1.40585
1.40649
1.40707
1.40758
1.408
1.40831
1.4085
1.40856
1.4085
1.40831
1.408
1.40759
1.4071
1.40653
1.40592
1.40528
1.40464
1.40401
1.40341
1.40286
1.40235
1.40191
1.40152
1.40119
1.40091
1.40069
1.40051
1.40036
1.40025
1.40017
1.40011
1.40006
1.40003
1.40001
1.4
1.39999
1.39999
1.39998
1.39999
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.401
1.40137
1.40184
1.40239
1.40305
1.40378
1.40459
1.40546
1.40636
1.40727
1.40816
1.409
1.40976
1.41042
1.41095
1.41134
1.41157
1.41164
1.41154
1.41128
1.41087
1.41032
1.40965
1.40889
1.40806
1.4072
1.40633
1.40547
1.40465
1.40389
1.4032
1.40259
1.40206
1.40161
1.40123
1.40092
1.40068
1.40048
1.40033
1.40022
1.40014
1.40008
1.40004
1.40001
1.39999
1.39998
1.39998
1.39998
1.39998
1.39998
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40152
1.40206
1.40271
1.40348
1.40438
1.40538
1.40647
1.40762
1.40881
1.40999
1.41114
1.41222
1.41319
1.41403
1.4147
1.41518
1.41547
1.41554
1.4154
1.41506
1.41452
1.4138
1.41292
1.41193
1.41084
1.40969
1.40853
1.40739
1.40629
1.40527
1.40434
1.40351
1.40279
1.40218
1.40166
1.40125
1.40091
1.40065
1.40045
1.4003
1.40018
1.4001
1.40005
1.40001
1.39999
1.39998
1.39997
1.39997
1.39997
1.39998
1.39998
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40224
1.40298
1.40388
1.40494
1.40614
1.40747
1.4089
1.41041
1.41194
1.41345
1.41491
1.41626
1.41747
1.4185
1.41932
1.41992
1.42026
1.42034
1.42016
1.41973
1.41905
1.41814
1.41703
1.41576
1.41436
1.41288
1.41137
1.40987
1.40843
1.40707
1.40583
1.40473
1.40376
1.40293
1.40224
1.40168
1.40123
1.40087
1.4006
1.4004
1.40025
1.40014
1.40007
1.40002
1.39999
1.39997
1.39997
1.39996
1.39997
1.39997
1.39997
1.39998
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4032
1.40421
1.40543
1.40683
1.40841
1.41015
1.412
1.41391
1.41584
1.41773
1.41952
1.42118
1.42264
1.42388
1.42486
1.42556
1.42597
1.42606
1.42584
1.42532
1.42449
1.42339
1.42203
1.42046
1.41871
1.41686
1.41494
1.41302
1.41116
1.40939
1.40777
1.40631
1.40503
1.40393
1.40301
1.40226
1.40165
1.40118
1.40082
1.40054
1.40034
1.4002
1.4001
1.40003
1.39999
1.39997
1.39996
1.39996
1.39996
1.39996
1.39997
1.39997
1.39998
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40446
1.40582
1.40742
1.40925
1.4113
1.41351
1.41583
1.41821
1.42057
1.42286
1.42501
1.42696
1.42868
1.43012
1.43125
1.43205
1.43251
1.43261
1.43237
1.43176
1.43081
1.42952
1.42793
1.42606
1.42396
1.42169
1.41932
1.41692
1.41457
1.41232
1.41023
1.40834
1.40667
1.40523
1.40402
1.40302
1.40222
1.40159
1.4011
1.40074
1.40047
1.40028
1.40014
1.40006
1.4
1.39997
1.39995
1.39995
1.39995
1.39995
1.39996
1.39997
1.39997
1.39998
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40609
1.40787
1.40994
1.41229
1.41486
1.41761
1.42046
1.42333
1.42614
1.42882
1.43129
1.43352
1.43544
1.43703
1.43827
1.43915
1.43965
1.43977
1.4395
1.43885
1.43782
1.4364
1.43461
1.43248
1.43005
1.42738
1.42455
1.42164
1.41874
1.41594
1.4133
1.41089
1.40875
1.40689
1.40531
1.40401
1.40296
1.40212
1.40148
1.401
1.40064
1.40039
1.40021
1.40009
1.40002
1.39997
1.39995
1.39994
1.39994
1.39994
1.39995
1.39996
1.39997
1.39998
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40815
1.41044
1.41307
1.416
1.41917
1.42249
1.42588
1.42923
1.43245
1.43546
1.43819
1.44059
1.44263
1.44429
1.44557
1.44647
1.44698
1.4471
1.44685
1.4462
1.44515
1.44369
1.44181
1.43952
1.43685
1.43384
1.43059
1.42717
1.42371
1.4203
1.41705
1.41405
1.41135
1.40898
1.40696
1.40527
1.40391
1.40282
1.40198
1.40134
1.40087
1.40054
1.4003
1.40014
1.40004
1.39998
1.39995
1.39993
1.39993
1.39993
1.39994
1.39995
1.39996
1.39997
1.39998
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.41071
1.41359
1.41685
1.42043
1.42422
1.42812
1.43201
1.43577
1.43929
1.4425
1.44534
1.44777
1.44978
1.45138
1.45259
1.45341
1.45389
1.45401
1.45379
1.45322
1.45226
1.45089
1.44907
1.44679
1.44404
1.44085
1.43728
1.43343
1.42943
1.42542
1.42152
1.41786
1.41452
1.41156
1.40901
1.40687
1.40511
1.40372
1.40263
1.4018
1.40118
1.40074
1.40043
1.40021
1.40008
1.39999
1.39995
1.39993
1.39992
1.39992
1.39993
1.39994
1.39995
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.41383
1.41738
1.42132
1.42557
1.42997
1.43438
1.43866
1.44268
1.44632
1.44953
1.45225
1.45449
1.45627
1.45762
1.4586
1.45925
1.45961
1.45972
1.45957
1.45914
1.45841
1.4573
1.45576
1.45372
1.45114
1.44799
1.44432
1.44022
1.4358
1.43124
1.4267
1.42235
1.41831
1.41468
1.41152
1.40883
1.40662
1.40484
1.40344
1.40238
1.40158
1.401
1.40059
1.40032
1.40013
1.40002
1.39996
1.39992
1.39991
1.39991
1.39992
1.39993
1.39994
1.39996
1.39997
1.39998
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.41754
1.42181
1.42646
1.43134
1.43626
1.44104
1.44552
1.44955
1.45304
1.45595
1.45827
1.46004
1.46133
1.46222
1.4628
1.46315
1.46333
1.46339
1.46334
1.46315
1.46277
1.46213
1.46111
1.4596
1.4575
1.45473
1.45128
1.44718
1.44256
1.4376
1.43251
1.42749
1.42273
1.41838
1.41453
1.41122
1.40847
1.40623
1.40447
1.40311
1.40209
1.40135
1.40082
1.40045
1.40021
1.40006
1.39997
1.39992
1.39991
1.3999
1.39991
1.39992
1.39994
1.39995
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.42186
1.42687
1.43218
1.43759
1.44285
1.44776
1.45213
1.45584
1.45883
1.46109
1.46268
1.46368
1.46422
1.46443
1.46444
1.46436
1.46428
1.46427
1.46433
1.46445
1.46456
1.46457
1.46432
1.46365
1.46239
1.46038
1.45754
1.45383
1.44934
1.44425
1.43877
1.43319
1.42774
1.42265
1.41806
1.41407
1.4107
1.40793
1.40573
1.40402
1.40273
1.40178
1.4011
1.40063
1.40032
1.40012
1.4
1.39993
1.3999
1.39989
1.3999
1.39991
1.39993
1.39994
1.39995
1.39997
1.39998
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.42676
1.43246
1.43832
1.44405
1.44938
1.45408
1.45797
1.46096
1.46304
1.46428
1.46479
1.46474
1.46428
1.46362
1.46292
1.46231
1.46192
1.4618
1.46199
1.46247
1.46317
1.46397
1.4647
1.46514
1.46506
1.46423
1.46244
1.45957
1.45565
1.45079
1.44523
1.43927
1.43326
1.42746
1.42212
1.41738
1.41333
1.40996
1.40726
1.40514
1.40353
1.40233
1.40147
1.40087
1.40046
1.4002
1.40004
1.39995
1.3999
1.39989
1.39989
1.3999
1.39992
1.39993
1.39995
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.43215
1.43842
1.44461
1.45036
1.45539
1.45946
1.46243
1.46428
1.46507
1.46495
1.46409
1.46274
1.46112
1.45945
1.45794
1.45674
1.45599
1.45576
1.45609
1.45696
1.45829
1.45997
1.46181
1.46356
1.46494
1.46563
1.46532
1.46379
1.46091
1.45675
1.4515
1.44549
1.4391
1.43271
1.42665
1.42116
1.41638
1.41235
1.40907
1.40648
1.40449
1.403
1.40192
1.40117
1.40065
1.40031
1.4001
1.39998
1.39991
1.39989
1.39988
1.39989
1.39991
1.39992
1.39994
1.39995
1.39997
1.39998
1.39998
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.43788
1.44451
1.45071
1.45611
1.46039
1.46337
1.46499
1.46531
1.46447
1.46271
1.46029
1.45749
1.4546
1.45187
1.44951
1.44771
1.44659
1.44625
1.44671
1.44797
1.44995
1.45254
1.45554
1.4587
1.4617
1.46416
1.46568
1.4659
1.46458
1.46162
1.45716
1.45149
1.44503
1.43825
1.43158
1.42537
1.41983
1.4151
1.41119
1.40806
1.40564
1.40382
1.40248
1.40153
1.40088
1.40045
1.40018
1.40002
1.39993
1.39989
1.39988
1.39988
1.3999
1.39991
1.39993
1.39995
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.44373
1.4504
1.45623
1.46081
1.46389
1.46536
1.46524
1.46371
1.46101
1.45744
1.45335
1.44906
1.44489
1.44109
1.43791
1.43552
1.43405
1.4336
1.4342
1.43584
1.43845
1.44192
1.44607
1.45065
1.45532
1.45966
1.46323
1.46553
1.46618
1.46493
1.46176
1.45689
1.45075
1.44387
1.43677
1.42992
1.42366
1.41819
1.41361
1.4099
1.40699
1.40478
1.40315
1.40198
1.40117
1.40063
1.40028
1.40007
1.39995
1.39989
1.39987
1.39988
1.39989
1.39991
1.39993
1.39994
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.44942
1.45575
1.46075
1.46407
1.46552
1.4651
1.46296
1.45938
1.4547
1.44928
1.44351
1.43774
1.43232
1.4275
1.42353
1.42058
1.4188
1.41826
1.419
1.421
1.42422
1.42854
1.43379
1.43972
1.44602
1.45226
1.45794
1.46251
1.46542
1.46628
1.46488
1.46132
1.45595
1.44931
1.44204
1.43471
1.42779
1.42161
1.41633
1.41199
1.40855
1.40591
1.40394
1.40252
1.40152
1.40085
1.40042
1.40015
1.39999
1.39991
1.39988
1.39987
1.39988
1.3999
1.39992
1.39994
1.39995
1.39997
1.39998
1.39998
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.45464
1.46019
1.46392
1.46555
1.46502
1.46247
1.45816
1.45245
1.44576
1.43851
1.4311
1.42392
1.41729
1.41149
1.40676
1.40329
1.4012
1.40058
1.40147
1.40385
1.40766
1.4128
1.41911
1.42634
1.43419
1.44225
1.45002
1.45688
1.46223
1.46548
1.46624
1.46444
1.4603
1.45432
1.44718
1.43959
1.43215
1.4253
1.41932
1.41433
1.41031
1.4072
1.40485
1.40315
1.40194
1.40112
1.40058
1.40024
1.40004
1.39993
1.39988
1.39987
1.39988
1.39989
1.39991
1.39993
1.39995
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.45907
1.46341
1.46546
1.46509
1.46236
1.45754
1.451
1.44318
1.43453
1.4255
1.41652
1.40795
1.40014
1.39337
1.38789
1.38388
1.38148
1.38079
1.38184
1.3846
1.38904
1.39501
1.40236
1.41086
1.42021
1.43002
1.43978
1.4489
1.4567
1.46248
1.46568
1.46601
1.46352
1.45862
1.45199
1.44441
1.43661
1.42919
1.42255
1.4169
1.41228
1.40865
1.4059
1.40387
1.40243
1.40144
1.40078
1.40036
1.40011
1.39997
1.3999
1.39987
1.39987
1.39989
1.3999
1.39992
1.39994
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.46244
1.46519
1.46526
1.46266
1.45762
1.45052
1.44178
1.43191
1.42137
1.41061
1.40006
1.3901
1.38107
1.37327
1.36697
1.36238
1.35965
1.35888
1.36011
1.36331
1.36842
1.37529
1.38375
1.39355
1.40439
1.41589
1.42758
1.43887
1.44907
1.4574
1.46318
1.46591
1.46543
1.46201
1.45625
1.44898
1.44105
1.4332
1.42596
1.41966
1.41444
1.41027
1.40707
1.4047
1.40299
1.40181
1.40101
1.4005
1.40019
1.40001
1.39992
1.39988
1.39987
1.39988
1.3999
1.39992
1.39994
1.39995
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.46457
1.46542
1.4633
1.4584
1.45104
1.4417
1.43084
1.41899
1.40659
1.3941
1.38194
1.37048
1.36011
1.35115
1.34392
1.33864
1.33552
1.33466
1.33611
1.33983
1.34572
1.35362
1.3633
1.3745
1.3869
1.40012
1.41371
1.4271
1.43961
1.45046
1.45885
1.46413
1.46593
1.46432
1.45979
1.45315
1.44534
1.43722
1.42948
1.42258
1.41675
1.41204
1.40837
1.40562
1.40363
1.40223
1.40129
1.40067
1.40029
1.40006
1.39994
1.39989
1.39987
1.39988
1.3999
1.39992
1.39993
1.39995
1.39996
1.39998
1.39998
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.46536
1.46411
1.45973
1.45252
1.44291
1.43141
1.41851
1.4047
1.39043
1.37612
1.36219
1.34906
1.33713
1.32681
1.31845
1.31236
1.30877
1.30781
1.30954
1.3139
1.32075
1.32986
1.34097
1.35375
1.36785
1.38288
1.39839
1.41385
1.42862
1.44191
1.45288
1.46076
1.465
1.46546
1.46248
1.45678
1.44935
1.44115
1.43305
1.42561
1.4192
1.41393
1.40978
1.40664
1.40434
1.40271
1.4016
1.40087
1.40041
1.40013
1.39998
1.39991
1.39988
1.39988
1.39989
1.39991
1.39993
1.39995
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.46483
1.4614
1.45475
1.44529
1.43352
1.41995
1.40505
1.38927
1.37302
1.35671
1.34077
1.32567
1.31189
1.29992
1.29021
1.28313
1.27897
1.27792
1.28001
1.28518
1.29322
1.30383
1.31665
1.33128
1.34729
1.36428
1.3818
1.39935
1.41633
1.43198
1.44548
1.45596
1.46273
1.46544
1.46424
1.45977
1.45297
1.44491
1.43657
1.42869
1.42174
1.41593
1.41129
1.40774
1.40512
1.40324
1.40195
1.40109
1.40055
1.40021
1.40003
1.39993
1.39989
1.39988
1.39989
1.39991
1.39993
1.39995
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.46307
1.45745
1.4486
1.437
1.42317
1.40758
1.39068
1.37283
1.35441
1.33583
1.31755
1.30011
1.28411
1.27014
1.25877
1.2505
1.24568
1.24453
1.2471
1.25329
1.26282
1.27529
1.2902
1.30703
1.32526
1.34444
1.36411
1.3838
1.40297
1.42094
1.43688
1.44991
1.45922
1.46428
1.46506
1.46204
1.45611
1.4484
1.43999
1.43177
1.42433
1.418
1.41288
1.40891
1.40595
1.40382
1.40234
1.40134
1.4007
1.40031
1.40008
1.39996
1.39991
1.39989
1.39989
1.39991
1.39993
1.39994
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.46025
1.45249
1.44154
1.42791
1.41209
1.39452
1.37554
1.35546
1.33461
1.3134
1.29236
1.27214
1.25346
1.2371
1.22376
1.21405
1.20843
1.20719
1.21037
1.21783
1.22922
1.24398
1.26145
1.28093
1.30177
1.32344
1.34546
1.3674
1.38878
1.40901
1.42731
1.44281
1.45463
1.46209
1.46496
1.46357
1.45873
1.45156
1.44323
1.43478
1.42693
1.42012
1.41453
1.41014
1.40684
1.40444
1.40276
1.40162
1.40088
1.40042
1.40014
1.4
1.39993
1.3999
1.3999
1.39991
1.39993
1.39994
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.45654
1.44676
1.43383
1.41826
1.40052
1.38093
1.35976
1.33722
1.3136
1.28934
1.26506
1.24155
1.21972
1.20052
1.18483
1.17343
1.16688
1.16552
1.16944
1.17845
1.19209
1.20964
1.23022
1.2529
1.27684
1.30138
1.32601
1.35034
1.37398
1.39642
1.417
1.43488
1.44912
1.45897
1.464
1.46438
1.46079
1.45433
1.44625
1.43768
1.42949
1.42225
1.41621
1.41142
1.40777
1.40509
1.4032
1.40191
1.40107
1.40054
1.40022
1.40004
1.39995
1.39991
1.39991
1.39991
1.39993
1.39994
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.45216
1.44047
1.42567
1.40826
1.38861
1.36695
1.34343
1.31816
1.2914
1.26363
1.23559
1.20826
1.18275
1.16025
1.14184
1.12847
1.12083
1.11933
1.12409
1.13491
1.15121
1.17208
1.19637
1.22286
1.25046
1.27833
1.3059
1.33282
1.35878
1.38343
1.4062
1.42633
1.44291
1.45507
1.46228
1.4645
1.46229
1.45669
1.44899
1.44042
1.43198
1.42436
1.4179
1.41271
1.40872
1.40577
1.40367
1.40223
1.40127
1.40067
1.4003
1.40009
1.39998
1.39993
1.39991
1.39992
1.39993
1.39994
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.44731
1.43383
1.41728
1.3981
1.37653
1.35272
1.32665
1.29836
1.26807
1.23632
1.204
1.17231
1.14261
1.11635
1.09487
1.07928
1.0704
1.06872
1.07441
1.08726
1.1066
1.1313
1.1599
1.19083
1.22268
1.25438
1.28528
1.31502
1.34342
1.37025
1.39512
1.41738
1.43617
1.45057
1.45991
1.46399
1.46325
1.45863
1.45143
1.44297
1.43436
1.42642
1.41958
1.41401
1.40969
1.40647
1.40416
1.40256
1.40149
1.40081
1.40039
1.40014
1.40001
1.39995
1.39992
1.39992
1.39993
1.39995
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.44215
1.42702
1.40883
1.38791
1.36443
1.33836
1.30957
1.27797
1.24377
1.20759
1.1705
1.13395
1.09962
1.06923
1.04439
1.0264
1.01615
1.01424
1.02089
1.03591
1.05858
1.08755
1.121
1.15696
1.19364
1.22968
1.26429
1.29711
1.32807
1.35711
1.38401
1.40827
1.42911
1.44562
1.45701
1.46295
1.46371
1.46015
1.45355
1.4453
1.4366
1.42839
1.42121
1.41529
1.41065
1.40717
1.40465
1.4029
1.40172
1.40095
1.40048
1.4002
1.40005
1.39997
1.39994
1.39993
1.39994
1.39995
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.43687
1.42022
1.40047
1.37787
1.35244
1.32403
1.29235
1.25722
1.21879
1.1778
1.13553
1.09371
1.0544
1.01965
0.991302
0.970789
0.959095
0.956864
0.964431
0.981685
1.00784
1.04136
1.08008
1.12157
1.16359
1.20444
1.24314
1.2793
1.31294
1.34421
1.37306
1.3992
1.42194
1.4404
1.45374
1.46148
1.46374
1.46129
1.45536
1.44739
1.43868
1.43026
1.42278
1.41654
1.4116
1.40786
1.40514
1.40324
1.40195
1.4011
1.40058
1.40026
1.40009
1.39999
1.39995
1.39994
1.39994
1.39995
1.39996
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.43161
1.41356
1.39235
1.3681
1.34072
1.30991
1.27524
1.23639
1.19353
1.14746
1.09972
1.0524
1.00795
0.968766
0.936903
0.913861
0.90066
0.898017
0.906408
0.925823
0.955473
0.993636
1.03782
1.08515
1.1329
1.17896
1.22207
1.2618
1.29825
1.33174
1.36248
1.39036
1.41483
1.43508
1.45022
1.45967
1.4634
1.46207
1.45687
1.44923
1.44057
1.432
1.42426
1.41773
1.41251
1.40854
1.40563
1.40357
1.40218
1.40126
1.40068
1.40033
1.40013
1.40002
1.39997
1.39995
1.39995
1.39996
1.39997
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.4265
1.40718
1.38459
1.35875
1.32942
1.29619
1.25849
1.2159
1.16852
1.11728
1.06397
1.01111
0.961557
0.918056
0.882808
0.85732
0.842599
0.839464
0.848547
0.869973
0.902953
0.945623
0.995208
1.04843
1.10209
1.15359
1.20137
1.24484
1.28419
1.31991
1.35245
1.38192
1.40796
1.42982
1.44661
1.45764
1.46278
1.46255
1.45808
1.45084
1.44227
1.43359
1.42563
1.41885
1.41338
1.40918
1.40609
1.4039
1.4024
1.40141
1.40078
1.4004
1.40017
1.40005
1.39999
1.39997
1.39996
1.39996
1.39997
1.39998
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.42167
1.40119
1.37733
1.34996
1.31873
1.28312
1.24247
1.1962
1.1444
1.08808
1.02934
0.971112
0.916712
0.86918
0.830803
0.803034
0.786862
0.783214
0.792892
0.816125
0.85212
0.898916
0.953538
1.01239
1.07183
1.12882
1.18137
1.22869
1.27097
1.30889
1.34314
1.37407
1.40149
1.42477
1.44303
1.45551
1.46195
1.46277
1.45903
1.4522
1.44377
1.43503
1.42689
1.41988
1.41419
1.40979
1.40654
1.40422
1.40262
1.40156
1.40088
1.40047
1.40022
1.40008
1.40001
1.39998
1.39997
1.39997
1.39997
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.4172
1.39569
1.37068
1.34187
1.30882
1.27095
1.22749
1.1778
1.12188
1.06082
0.997003
0.933818
0.874992
0.823839
0.782684
0.752898
0.73545
0.731377
0.741609
0.766417
0.804989
0.855314
0.914325
0.978219
1.04302
1.10524
1.16246
1.2136
1.2588
1.29886
1.3347
1.36692
1.39555
1.42006
1.4396
1.45337
1.461
1.46279
1.45976
1.45333
1.44505
1.43629
1.42801
1.42081
1.41492
1.41035
1.40695
1.40451
1.40283
1.40171
1.40098
1.40053
1.40027
1.40011
1.40003
1.39999
1.39998
1.39998
1.39998
1.39998
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.41321
1.39078
1.36475
1.33464
1.2999
1.25992
1.21393
1.1612
1.10165
1.03643
0.968155
0.900609
0.837923
0.783646
0.740131
0.708669
0.69023
0.685929
0.696726
0.722857
0.763473
0.816572
0.879104
0.947193
1.01663
1.08356
1.14512
1.19991
1.2479
1.28997
1.32727
1.36062
1.39027
1.41581
1.43645
1.45132
1.45999
1.46267
1.46028
1.45425
1.44614
1.43737
1.42899
1.42163
1.41558
1.41085
1.40732
1.40478
1.40302
1.40184
1.40108
1.4006
1.40031
1.40015
1.40006
1.40001
1.39999
1.39998
1.39998
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40975
1.38653
1.35963
1.3284
1.29215
1.25029
1.20209
1.14683
1.08434
1.01576
0.943861
0.872734
0.806858
0.750004
0.704568
0.671815
0.652724
0.648424
0.659807
0.686991
0.729075
0.784121
0.849194
0.92047
0.993626
1.06451
1.12987
1.18793
1.23848
1.28239
1.32096
1.35526
1.38574
1.41212
1.43365
1.44946
1.45902
1.46246
1.46064
1.45497
1.44702
1.43827
1.42981
1.42232
1.41613
1.41128
1.40764
1.40502
1.40319
1.40196
1.40116
1.40066
1.40036
1.40018
1.40008
1.40003
1.4
1.39999
1.39999
1.39999
1.39999
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40691
1.38303
1.35541
1.32327
1.28578
1.24231
1.19228
1.13504
1.07042
0.999459
0.924959
0.851184
0.782871
0.724004
0.677068
0.643374
0.623926
0.619801
0.63174
0.65969
0.702688
0.758888
0.825535
0.898946
0.974797
1.04874
1.1172
1.17803
1.23077
1.27624
1.31588
1.35093
1.38204
1.40906
1.43129
1.44784
1.45813
1.46221
1.46087
1.4555
1.44771
1.43898
1.43046
1.42289
1.41659
1.41163
1.40791
1.40522
1.40334
1.40207
1.40124
1.40072
1.4004
1.40021
1.4001
1.40004
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40474
1.38033
1.35216
1.31937
1.28093
1.23619
1.18473
1.1261
1.06016
0.987886
0.911938
0.836575
0.766659
0.706347
0.658285
0.623914
0.60428
0.600375
0.612754
0.641177
0.684602
0.741274
0.808636
0.883209
0.960739
1.03679
1.10753
1.1705
1.22496
1.27167
1.31211
1.3477
1.37923
1.40669
1.42943
1.44654
1.45738
1.46195
1.461
1.45588
1.44821
1.43951
1.43095
1.42331
1.41694
1.41191
1.40812
1.40538
1.40346
1.40216
1.40131
1.40077
1.40044
1.40024
1.40012
1.40006
1.40003
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40331
1.3785
1.34994
1.31675
1.27775
1.23215
1.17968
1.12016
1.05366
0.981079
0.904858
0.82904
0.758425
0.697273
0.648441
0.613578
0.593814
0.590049
0.602668
0.631258
0.674692
0.731277
0.79865
0.873536
0.951812
1.02902
1.10118
1.16557
1.22122
1.26877
1.30972
1.3456
1.37736
1.40507
1.42811
1.44559
1.45681
1.46172
1.46104
1.4561
1.44852
1.43984
1.43128
1.42359
1.41717
1.4121
1.40827
1.4055
1.40356
1.40224
1.40137
1.40082
1.40047
1.40027
1.40015
1.40008
1.40004
1.40002
1.40001
1.40001
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40263
1.37759
1.34879
1.31545
1.27629
1.23033
1.17731
1.11738
1.05091
0.978843
0.903382
0.8282
0.757833
0.696522
0.647338
0.612196
0.592339
0.588595
0.601206
0.629636
0.672689
0.728718
0.795516
0.869997
0.948182
1.02566
1.09837
1.16343
1.21967
1.26761
1.30874
1.34467
1.37645
1.40421
1.42738
1.44503
1.45645
1.46155
1.46101
1.45617
1.44865
1.43999
1.43142
1.42373
1.41729
1.4122
1.40836
1.40557
1.40362
1.40229
1.40142
1.40086
1.40051
1.40029
1.40017
1.40009
1.40005
1.40003
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40273
1.37763
1.34876
1.31549
1.27655
1.23078
1.17779
1.11793
1.05192
0.98093
0.906979
0.83333
0.76411
0.703405
0.654442
0.619396
0.599609
0.595832
0.608198
0.636121
0.678397
0.733425
0.799124
0.872556
0.949883
1.02679
1.09921
1.16417
1.22037
1.26822
1.30918
1.34491
1.37649
1.40412
1.42723
1.44487
1.45631
1.46144
1.46093
1.45611
1.4486
1.43996
1.4314
1.42372
1.41729
1.41222
1.40839
1.4056
1.40365
1.40233
1.40145
1.40089
1.40053
1.40032
1.40018
1.40011
1.40006
1.40004
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40357
1.37865
1.3499
1.31688
1.27848
1.23344
1.18115
1.12193
1.05682
0.987242
0.91524
0.843723
0.776388
0.717075
0.669078
0.634729
0.615379
0.611645
0.623592
0.650675
0.69177
0.745345
0.809411
0.881161
0.956884
1.03239
1.10369
1.16779
1.22332
1.27059
1.31103
1.3463
1.37749
1.40481
1.42767
1.44511
1.4564
1.4614
1.4608
1.45591
1.44838
1.43974
1.4312
1.42356
1.41718
1.41214
1.40834
1.40559
1.40366
1.40234
1.40147
1.40091
1.40055
1.40033
1.4002
1.40012
1.40007
1.40005
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40515
1.3806
1.35222
1.31966
1.28204
1.23817
1.18724
1.12939
1.06571
0.997895
0.928092
0.859046
0.794116
0.736915
0.690702
0.6578
0.639384
0.635862
0.647278
0.673236
0.712775
0.764451
0.826331
0.895723
0.969081
1.04237
1.11173
1.17422
1.22846
1.27468
1.31425
1.34881
1.37941
1.40624
1.42868
1.44576
1.45671
1.46143
1.4606
1.45557
1.44797
1.43933
1.43084
1.42326
1.41695
1.41198
1.40824
1.40553
1.40363
1.40233
1.40148
1.40092
1.40057
1.40035
1.40022
1.40013
1.40008
1.40006
1.40004
1.40003
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40746
1.38342
1.35566
1.3238
1.28718
1.2448
1.19579
1.14006
1.07855
1.013
0.945713
0.879396
0.817254
0.762754
0.719064
0.688293
0.671251
0.668091
0.678888
0.703489
0.741153
0.790512
0.849663
0.916019
0.986236
1.0565
1.12314
1.18332
1.23567
1.28039
1.31877
1.35238
1.38221
1.40839
1.43025
1.44677
1.45722
1.46149
1.46033
1.45509
1.44738
1.43873
1.4303
1.42281
1.41661
1.41174
1.40807
1.40543
1.40357
1.40231
1.40147
1.40093
1.40058
1.40036
1.40023
1.40015
1.40009
1.40006
1.40004
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.41048
1.38709
1.36013
1.32925
1.29387
1.25321
1.20651
1.15353
1.09495
1.0324
0.968157
0.90496
0.845993
0.794681
0.754052
0.725828
0.710356
0.707567
0.717642
0.740714
0.776243
0.822921
0.878852
0.941552
1.00791
1.07441
1.13762
1.19485
1.24478
1.28759
1.32449
1.35694
1.38585
1.41122
1.43232
1.44812
1.45789
1.46158
1.45997
1.45444
1.4466
1.43795
1.4296
1.42223
1.41616
1.41141
1.40785
1.40528
1.40349
1.40226
1.40145
1.40092
1.40059
1.40037
1.40024
1.40016
1.4001
1.40007
1.40005
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.41417
1.39156
1.36554
1.33586
1.30199
1.26329
1.21915
1.16932
1.11431
1.0555
0.995007
0.935518
0.88022
0.832531
0.795257
0.769655
0.755663
0.753106
0.762357
0.783786
0.816996
0.860694
0.912995
0.971531
1.03345
1.09556
1.15472
1.20847
1.25555
1.29611
1.33129
1.36242
1.39024
1.41466
1.43484
1.44975
1.45867
1.46164
1.45948
1.45361
1.44563
1.43699
1.42874
1.42152
1.41561
1.41101
1.40757
1.4051
1.40337
1.4022
1.40142
1.40091
1.40059
1.40038
1.40025
1.40016
1.40011
1.40007
1.40005
1.40004
1.40003
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.41842
1.39679
1.37183
1.34349
1.31135
1.27484
1.23348
1.18706
1.13602
1.08152
1.02541
0.970261
0.919185
0.875491
0.841642
0.818472
0.805705
0.803222
0.811589
0.831339
0.862119
0.902618
0.95097
1.00496
1.06201
1.11928
1.17396
1.22381
1.2677
1.30576
1.33904
1.3687
1.39532
1.41864
1.43775
1.45159
1.45952
1.46164
1.45885
1.4526
1.44446
1.43584
1.42772
1.42069
1.41497
1.41054
1.40725
1.40489
1.40324
1.40212
1.40138
1.40089
1.40058
1.40038
1.40025
1.40017
1.40011
1.40008
1.40006
1.40004
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4231
1.40264
1.37892
1.35202
1.32172
1.28759
1.2492
1.20639
1.15955
1.10967
1.05838
1.00805
0.96165
0.922162
0.891616
0.870576
0.858786
0.856308
0.86384
0.881945
0.91024
0.94739
0.991577
1.04076
1.09266
1.14482
1.19476
1.24046
1.28094
1.31634
1.3476
1.37569
1.401
1.42309
1.44096
1.45358
1.46035
1.46151
1.45802
1.45137
1.44309
1.43452
1.42657
1.41975
1.41425
1.41002
1.40689
1.40465
1.40309
1.40203
1.40133
1.40087
1.40057
1.40038
1.40025
1.40017
1.40012
1.40008
1.40006
1.40004
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.42808
1.40897
1.38666
1.36133
1.33295
1.30126
1.26593
1.22686
1.18435
1.13924
1.09298
1.04775
1.00623
0.970922
0.943428
0.924258
0.913326
0.910886
0.917693
0.934233
0.960011
0.993699
1.03359
1.07785
1.12451
1.17145
1.21652
1.25798
1.29497
1.32764
1.35681
1.38327
1.40717
1.42789
1.44438
1.4556
1.4611
1.4612
1.45698
1.44991
1.44152
1.43302
1.42528
1.41872
1.41346
1.40945
1.40649
1.40438
1.40292
1.40193
1.40127
1.40084
1.40056
1.40037
1.40025
1.40017
1.40012
1.40009
1.40006
1.40004
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.43323
1.41561
1.39486
1.37124
1.34486
1.31561
1.28334
1.24798
1.2098
1.16948
1.12831
1.08826
1.05157
1.0202
0.995508
0.978074
0.968005
0.965694
0.971887
0.986916
1.01016
1.04032
1.07587
1.11521
1.15667
1.19846
1.23872
1.27598
1.3095
1.33946
1.36655
1.39133
1.41372
1.43294
1.44788
1.45757
1.46167
1.46065
1.45567
1.44822
1.43974
1.43138
1.42388
1.4176
1.41262
1.40883
1.40607
1.4041
1.40274
1.40182
1.40121
1.4008
1.40054
1.40037
1.40025
1.40018
1.40012
1.40009
1.40006
1.40004
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.43845
1.42238
1.40331
1.38153
1.35722
1.33042
1.30112
1.26936
1.23535
1.19967
1.1635
1.12848
1.09633
1.06861
1.04656
1.03085
1.02172
1.01964
1.0253
1.03883
1.05952
1.08615
1.1174
1.15194
1.18839
1.22523
1.26088
1.29409
1.32427
1.35161
1.37666
1.39973
1.42052
1.43811
1.45135
1.45936
1.46197
1.4598
1.45408
1.44628
1.43777
1.42959
1.42237
1.41641
1.41173
1.40819
1.40562
1.40381
1.40255
1.4017
1.40114
1.40076
1.40052
1.40036
1.40025
1.40017
1.40012
1.40009
1.40006
1.40005
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
)
;
boundaryField
{
emptyPatches_empt
{
type empty;
}
top_cyc
{
type cyclic;
}
bottom_cyc
{
type cyclic;
}
inlet_cyc
{
type cyclic;
}
outlet_cyc
{
type cyclic;
}
procBoundary3to1
{
type processor;
value nonuniform List<scalar>
75
(
1.4436
1.42915
1.41182
1.39195
1.36977
1.34542
1.319
1.29063
1.26053
1.22925
1.19779
1.16743
1.13942
1.11508
1.09562
1.08167
1.07354
1.07179
1.07694
1.08895
1.10707
1.13022
1.15733
1.18732
1.21905
1.25126
1.28261
1.31202
1.33907
1.36393
1.38699
1.40835
1.42744
1.44325
1.45463
1.46085
1.46191
1.45859
1.45217
1.44409
1.43562
1.42767
1.42079
1.41518
1.41081
1.40754
1.40517
1.4035
1.40236
1.40158
1.40106
1.40072
1.40049
1.40034
1.40024
1.40017
1.40012
1.40009
1.40006
1.40005
1.40003
1.40002
1.40002
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
)
;
}
procBoundary3to1throughtop_cyc
{
type processorCyclic;
value nonuniform List<scalar>
75
(
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.4
1.4
1.4
1.4
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
)
;
}
procBoundary3to2
{
type processor;
value nonuniform List<scalar>
75
(
1.4
1.4
1.4
1.4
1.4
1.4
1.4
1.39999
1.39999
1.39999
1.39998
1.39998
1.39997
1.39996
1.39995
1.39995
1.39994
1.39994
1.39994
1.39995
1.39998
1.40003
1.40011
1.40024
1.40043
1.40071
1.4011
1.40164
1.40238
1.40335
1.40461
1.40622
1.40825
1.41074
1.41376
1.41733
1.42146
1.42613
1.43125
1.4367
1.44227
1.44774
1.45284
1.45729
1.46087
1.46341
1.46483
1.46512
1.46436
1.46269
1.46025
1.45721
1.45375
1.45003
1.44619
1.44237
1.43868
1.43525
1.43214
1.42946
1.42725
1.42558
1.42448
1.42395
1.42402
1.42469
1.42597
1.42785
1.43027
1.43316
1.43641
1.43993
1.44362
1.44738
1.45111
)
;
}
procBoundary3to2throughoutlet_cyc
{
type processorCyclic;
value nonuniform List<scalar>
75
(
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
1.40001
)
;
}
}
// ************************************************************************* //
| |
4aade3a11cce5b144739c8a775bc29313624b239 | 69e1e4c6986d03b73a0e557cab9ca13daae3fd0a | /source/zlauncher/CNewApp/ZUpdate.h | 6f2b5e45ddd2fdca97126aa83bc9d8d34e8be99c | [] | no_license | WhyWolfie/GunZ-The-Duel | 7985d9d17f77dbb91d9e9e50e7a25465be897ea8 | fb8f740f5b55ca2184ce0ec75927a738f6a39ac5 | refs/heads/master | 2023-07-24T17:15:13.845881 | 2023-07-12T08:50:43 | 2023-07-12T08:50:43 | 229,615,966 | 37 | 18 | null | 2022-12-15T10:33:13 | 2019-12-22T18:59:07 | C++ | UTF-8 | C++ | false | false | 5,210 | h | ZUpdate.h | /******************************************************************
ZUpdate.h
Corperation : MAIET entertainment
Programmer : Lim Dong Hwan
Date : 22.June.2005
*******************************************************************/
#ifndef _ZUPDATE
#define _ZUPDATE
#include "ZFileTransfer.h"
#include <windows.h>
#include <list>
using namespace std;
#define STR_TEMP_DOWNLOADFOLDER "PATCH"
// Update patch file node
class ZUpdatePatchNode
{
protected:
char m_szFileName[ _MAX_DIR];
unsigned long m_nSize;
unsigned long m_nCheckSum;
char m_nCheckSumSTR[ _MAX_DIR];
bool m_bValidate;
bool m_bPatchSuccess;
public:
ZUpdatePatchNode( const char* pszName, unsigned long nSize, unsigned long nChecksum);
ZUpdatePatchNode( const char* pszName, unsigned long nSize, const char* nChecksum);
virtual ~ZUpdatePatchNode();
const char* GetFileName() { return m_szFileName; }
unsigned long GetSize() { return m_nSize; }
unsigned long GetChecksum() { return m_nCheckSum; }
const char* GetChecksumSTR() { return m_nCheckSumSTR; }
bool IsValid() { return m_bValidate; }
void SetValid( bool bValid) { m_bValidate = bValid; }
bool IsPatchSuccess() { return m_bPatchSuccess; }
void SetPatchSuccess( bool bSuccess) { m_bPatchSuccess = bSuccess; }
bool CheckValid( CString* pstrErrorMsg);
};
class ZUpdatePatchList : public list<ZUpdatePatchNode*>{};
// Update UI infomation
class ZUpdateUIInfo
{
protected:
ZFileTransferUI* m_pFileTransferUI;
unsigned long m_nTotalPatchFileSize;
unsigned long m_nCurrPatchedFileSize;
unsigned long m_nTotalPatchFileCount;
unsigned long m_nCurrPatchedFileCount;
int m_nPatchFailedCount;
public:
ZUpdateUIInfo()
{
m_nTotalPatchFileSize = 0;
m_nCurrPatchedFileSize = 0;
m_nTotalPatchFileCount = 0;
m_nCurrPatchedFileCount = 0;
m_nPatchFailedCount = 0;
};
void SetTransferUI( ZFileTransferUI* pUI) { m_pFileTransferUI = pUI; }
const char* GetCurrPatchFileName() { return m_pFileTransferUI->GetDownloadFileName(); }
unsigned long GetTotalDownloadSize() { return m_pFileTransferUI->GetTotalDownloadSize(); }
unsigned long GetCurrDownloadSize() { return m_pFileTransferUI->GetCurrDownloadSize(); }
unsigned long GetTotalPatchFileSize() { return m_nTotalPatchFileSize; }
void SetTotalPatchFileSize( unsigned long nSize) { m_nTotalPatchFileSize = nSize; }
void AddTotalPatchFileSize( unsigned long nSize) { m_nTotalPatchFileSize += nSize; }
void ClearTotalPatchFileSize() { m_nTotalPatchFileSize = 0; }
unsigned long GetCurrPatchedFileSize() { return m_nCurrPatchedFileSize; }
void SetCurrPatchedFileSize( unsigned long nSize) { m_nCurrPatchedFileSize = nSize; }
void AddCurrPatchedFileSize( unsigned long nSize) { m_nCurrPatchedFileSize += nSize; }
void ClearCurrPatchedFileSize() { m_nCurrPatchedFileSize = 0; }
unsigned long GetTotalPatchFileCount() { return m_nTotalPatchFileCount; }
void SetTotalPatchFileCount( unsigned long nCount) { m_nTotalPatchFileCount = nCount; }
void AddTotalPatchFileCount( unsigned long nCount) { m_nTotalPatchFileCount += nCount; }
void ClearTotalPatchFileCount() { m_nTotalPatchFileCount = 0; }
unsigned long GetCurrPatchedFileCount() { return m_nCurrPatchedFileCount; }
void SetCurrPatchedFileCount( unsigned long nCount) { m_nCurrPatchedFileCount = nCount; }
void AddCurrPatchedFileCount( unsigned long nCount) { m_nCurrPatchedFileCount += nCount; }
void ClearCurrPatchedFileCount() { m_nCurrPatchedFileCount = 0; }
int GetPatchFailedCount() { return m_nPatchFailedCount; }
void SetPatchFailedCount( int nCount) { m_nPatchFailedCount = nCount; }
void AddPatchFailedCount( int nCount) { m_nPatchFailedCount += nCount; }
void ClearPatchFailedCount() { m_nPatchFailedCount = 0; }
};
// class ZUpdate
class ZUpdate
{
protected:
ZUpdatePatchList m_pUpdatePatchList;
ZFileTransfer m_FileTransfer;
ZUpdateUIInfo m_UpdateInfo;
bool m_bInitialize;
char m_szAddress[ 256];
unsigned long m_nPort;
char m_szID[ 256];
char m_szPassword[ 256];
bool m_bStopUpdate;
bool m_bPatchComplete;
CString m_strErrorMsg;
bool m_bReboot;
public:
ZUpdate();
virtual ~ZUpdate();
bool Create( const char* pszAddress, unsigned long nPort, const char* pszDefDirectory, const char* pszID, const char* pszPassword);
bool Destroy();
bool CheckUpdate( const char* pszPatchFileName);
bool StartUpdate();
bool StopUpdate();
ZUpdateUIInfo GetUpdateInfo() { return m_UpdateInfo;}
bool IsPatchComplete() { return m_bPatchComplete; }
CString* GetErrorMsg() { return &m_strErrorMsg; }
char* GetFileTransferError() { return m_FileTransfer.GetLastError(); }
bool IsCreated() { return m_bInitialize; }
bool IsReboot() { return m_bReboot; }
protected:
bool GetUpdateInfo( const char* pszPatchFileName);
bool CheckValidFromPatchList();
bool PatchFiles();
bool MovePatchFiles();
};
#endif
|
1cef5432c11cae498c17154d5f0163949d6666bc | 5dc9ed490eea2b83bf563505d9c788db7ce466e3 | /2020-08-28git/ejemplo2.cpp | 126e415b44b8848d1ebfc4b847e84f6f65dca232 | [] | no_license | dspuertamo/2020-II-Prog | 65ce3d3e65b94c7c54bf93580c5c25ba387da5f4 | 6eaba0392563ab25c97ebafd5611ef46ecfeb32f | refs/heads/master | 2022-12-21T04:01:24.583464 | 2020-09-15T16:58:32 | 2020-09-15T16:58:32 | 292,115,273 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 201 | cpp | ejemplo2.cpp | //Primer programa ejemplo c++
/*
dfadf
dhds
vhfmhcgmhcmc.
*/
#include <iostream>
#include <cmath>
int main(void)
{
std::cout <<"Hello World!\n";
std::cout <<"Hola Mundo!\n";
return 0;
}
|
8704e3c67f9b4117ee38bb0950f7e1d83a3b7b9a | 353734d55037587e0b8d999402d3b158168d1c51 | /searchRange.h | d423c787669f57b9b8af477be031fc973542b10d | [] | no_license | lixx1746/LeetCode | ba57c5085731e3d95164c47207ce5bf63de99449 | 1c752c7c77439accf590231be77cafe526b84342 | refs/heads/master | 2021-01-16T18:56:34.208928 | 2014-12-09T20:30:33 | 2014-12-09T20:30:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 304 | h | searchRange.h | class Solution {
public:
vector<int> searchRange(int A[], int n, int target) {
int l = lower_bound(A, A + n, target) - A;
int r = upper_bound(A, A + n, target) - A;
vector<int> res(2, -1);
if(A[l] != target) return res;
return vector<int> {l, r - 1};
}
};
|
d77405124f2371844040b19e82d3ec717f959e11 | 5d83739af703fb400857cecc69aadaf02e07f8d1 | /Archive2/05/e792041c071f3d/main.cpp | 126f63daa3241d135023f6f8d2f9ba6f9a80581c | [] | no_license | WhiZTiM/coliru | 3a6c4c0bdac566d1aa1c21818118ba70479b0f40 | 2c72c048846c082f943e6c7f9fa8d94aee76979f | refs/heads/master | 2021-01-01T05:10:33.812560 | 2015-08-24T19:09:22 | 2015-08-24T19:09:22 | 56,789,706 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 391 | cpp | main.cpp | #include <tuple>
#include <initializer_list>
template<typename T> struct Small_set {
Small_set(std::initializer_list<T>) { }
};
template< class... Values >
auto small_set( Values const... values )
-> Small_set< typename std::tuple_element<0, std::tuple< Values... > >::type >
{ return { values... }; }
int main()
{
auto ss = small_set(42, 56, 7);
(void) ss;
}
|
b1934d87786bfb7e2e1d549623176b5723f886f8 | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /third_party/WebKit/Source/wtf/text/TextCodecUserDefinedTest.cpp | 9442ab5a21092da40f44b700577fbf680e6e0c8e | [
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 1,763 | cpp | TextCodecUserDefinedTest.cpp | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "wtf/text/TextCodecUserDefined.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "wtf/text/CString.h"
#include "wtf/text/TextCodec.h"
#include "wtf/text/TextEncoding.h"
#include "wtf/text/TextEncodingRegistry.h"
#include <memory>
TEST(TextCodecUserDefinedTest, QuestionMarksAndSurrogates) {
WTF::TextEncoding encoding("x-user-defined");
std::unique_ptr<WTF::TextCodec> codec(newTextCodec(encoding));
{
const LChar testCase[] = {0xd1, 0x16, 0x86};
size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
CString result = codec->encode(testCase, testCaseSize,
WTF::QuestionMarksForUnencodables);
EXPECT_STREQ("?\x16?", result.data());
}
{
const UChar testCase[] = {0xd9f0, 0xdcd9};
size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
CString result = codec->encode(testCase, testCaseSize,
WTF::QuestionMarksForUnencodables);
EXPECT_STREQ("?", result.data());
}
{
const UChar testCase[] = {0xd9f0, 0xdcd9, 0xd9f0, 0xdcd9};
size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
CString result = codec->encode(testCase, testCaseSize,
WTF::QuestionMarksForUnencodables);
EXPECT_STREQ("??", result.data());
}
{
const UChar testCase[] = {0x0041, 0xd9f0, 0xdcd9, 0xf7c1, 0xd9f0, 0xdcd9};
size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
CString result = codec->encode(testCase, testCaseSize,
WTF::QuestionMarksForUnencodables);
EXPECT_STREQ("A?\xC1?", result.data());
}
}
|
de84be3aa7f216bfdcdd8bad5bd8ea0113e827ee | 5ec75208b0177d7c6e4bb406a8a288f298386d56 | /Practice/ProjectA/Calculate/calculate.h | 4a37fa5a236e03aa7b06820b5dbd41149b06f3df | [] | no_license | wolf-bolin/Jigsaw | 31d4c95ba06381eeba5b2d33c4230567c7fb7ae4 | d7ac175c0168d502b03dde58ea3159dbcf032b7b | refs/heads/master | 2021-01-20T17:34:36.954300 | 2017-07-13T13:43:03 | 2017-07-13T13:43:03 | 95,748,921 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 219 | h | calculate.h | #ifndef CALCULATE_H
#define CALCULATE_H
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
using namespace std;
string calc(string exp);
#endif // CALCULATE_H
|
33a70f9c8e85aec13deb3791ca14a7fd37f71c46 | a5a99f646e371b45974a6fb6ccc06b0a674818f2 | /RecoTracker/MkFitCore/interface/MkJob.h | 3f9b0dbd56cc7da2749baa29d66657e04b62b941 | [
"Apache-2.0"
] | permissive | cms-sw/cmssw | 4ecd2c1105d59c66d385551230542c6615b9ab58 | 19c178740257eb48367778593da55dcad08b7a4f | refs/heads/master | 2023-08-23T21:57:42.491143 | 2023-08-22T20:22:40 | 2023-08-22T20:22:40 | 10,969,551 | 1,006 | 3,696 | Apache-2.0 | 2023-09-14T19:14:28 | 2013-06-26T14:09:07 | C++ | UTF-8 | C++ | false | false | 1,417 | h | MkJob.h | #ifndef RecoTracker_MkFitCore_interface_MkJob_h
#define RecoTracker_MkFitCore_interface_MkJob_h
#include "RecoTracker/MkFitCore/interface/IterationConfig.h"
namespace mkfit {
class MkJob {
public:
const TrackerInfo &m_trk_info;
// Config &config; // If we want to get rid of namespace / global config
const IterationConfig &m_iter_config;
const EventOfHits &m_event_of_hits;
const BeamSpot &m_beam_spot;
const IterationMaskIfcBase *m_iter_mask_ifc = nullptr;
bool m_in_fwd = true;
void switch_to_backward() { m_in_fwd = false; }
int num_regions() const { return m_iter_config.m_n_regions; }
const auto regions_begin() const { return m_iter_config.m_region_order.begin(); }
const auto regions_end() const { return m_iter_config.m_region_order.end(); }
const auto &steering_params(int i) { return m_iter_config.m_steering_params[i]; }
const auto ¶ms() const { return m_iter_config.m_params; }
const auto ¶ms_bks() const { return m_iter_config.m_backward_params; }
const auto ¶ms_cur() const { return m_in_fwd ? params() : params_bks(); }
int max_max_cands() const { return std::max(params().maxCandsPerSeed, params_bks().maxCandsPerSeed); }
const std::vector<bool> *get_mask_for_layer(int layer) {
return m_iter_mask_ifc ? m_iter_mask_ifc->get_mask_for_layer(layer) : nullptr;
}
};
} // namespace mkfit
#endif
|
c7ba572efb79d9bf67483ae169b7e814116a7c63 | d73cf4af65fffc16c2326281fb7de3344566d6a1 | /TVMCHLib/AFCLogApi.cpp | ed3e7d656001ccce0b9f7e0ee65d9dbbbf29d34f | [] | no_license | yongchaohu/WH_DEVICE | c3299ddd63ff15ca5ba3fa476cb90eee01ddb541 | 5212d3b15dfcf5a542c0936ebf0e72ed66b85d05 | refs/heads/master | 2020-05-27T20:38:35.562316 | 2019-06-24T03:02:29 | 2019-06-24T03:02:29 | 188,782,571 | 0 | 0 | null | 2019-05-27T06:18:48 | 2019-05-27T06:18:48 | null | GB18030 | C++ | false | false | 3,512 | cpp | AFCLogApi.cpp | #include "StdAfx.h"
#include "AFCLogApi.h"
const char CrLf[3] = {13,10,0};
CAFCLogApi CAFCLogApi::theInstance;
CAFCLogApi::CAFCLogApi(void)
{
m_hFile = INVALID_HANDLE_VALUE;
m_strFileName = _T("");
m_strTracePath = _T("");
}
CAFCLogApi::~CAFCLogApi(void)
{
CloseLog();
::DeleteCriticalSection(&m_hLock);
}
void CAFCLogApi::MakeFileName()
{
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
m_strFileName.Format(_T("%s%04d%02d%02d.log"),m_strFileName,sysTime.wYear, sysTime.wMonth, sysTime.wDay);
}
// 要写日志,必须先调用Initialize对api初始化
void CAFCLogApi::Initialize(CString path,CString filename)
{
::InitializeCriticalSection(&m_hLock);
m_strTracePath = path;
m_strFileName = filename;
MakeFileName();
CString strFullName = _T("");
MakeFullName(strFullName);
m_hFile = ::CreateFile(strFullName.GetBuffer(strFullName.GetLength()), GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
strFullName.ReleaseBuffer();
}
// 需要关闭日志,否则无法上传
void CAFCLogApi::CloseLog(void)
{
if (m_hFile!=INVALID_HANDLE_VALUE){
::CloseHandle( m_hFile );
m_hFile = INVALID_HANDLE_VALUE;
}
}
void CAFCLogApi::MakeFullName(CString& strFullName)
{
if (m_strTracePath.Right(1) != _T("\\") && m_strTracePath.Right(1) != _T("//"))
{
m_strTracePath += _T("\\");
}
CheckAndCreatePath();
strFullName = m_strTracePath + m_strFileName;
}
// 写日志
void CAFCLogApi::WriteLog(CString className, CString methodName, int line, CString format, ...)
{
try
{
// 固定头
CString head = _T("");
head.Format(_T("%-s %-s %d "), className, methodName, line);
// 日志内容
CString data = _T("");
va_list args;
va_start(args, format);
data.FormatV(format, args);
va_end(args);
WriteData(head + data + _T("\r\n"));
}
catch (...)
{
}
}
// 写日志
void CAFCLogApi::WriteData(CString& data)
{
// 进入临界区
::EnterCriticalSection(&m_hLock);
if (m_hFile == INVALID_HANDLE_VALUE)
{
CString strFullName = _T("");
MakeFullName(strFullName);
m_hFile = ::CreateFile(strFullName.GetBuffer(strFullName.GetLength()), GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
strFullName.ReleaseBuffer();
}
// 操作时间
SYSTEMTIME dtCurTime;
::GetLocalTime(&dtCurTime);
CString strPrefix = _T("");
strPrefix.Format(_T("%.4d/%.2d/%.2d %.2d:%.2d:%.2d.%.3d threadID %d"),dtCurTime.wYear,dtCurTime.wMonth,dtCurTime.wDay,
dtCurTime.wHour,dtCurTime.wMinute,dtCurTime.wSecond,dtCurTime.wMilliseconds,GetCurrentThreadId());
CString logData = strPrefix + _T(",") + data;
DWORD x;
// 找到文件末尾
SetFilePointer(m_hFile,0,0,FILE_END);
// 写入日志内容
char *buf = NULL;
USES_CONVERSION;
buf = T2A(logData);
WriteFile(m_hFile,buf, lstrlenA(buf), &x,0);
// 换行
WriteFile(m_hFile,CrLf, lstrlenA(CrLf), &x,0);
// 离开临界区
::LeaveCriticalSection( &m_hLock );
}
void CAFCLogApi::CheckAndCreatePath()
{
if (!m_strTracePath.IsEmpty())
{
CStringArray pathArray;
int nIndex = -1,lastIndex = 0;
nIndex = m_strTracePath.Find(_T("\\"));
while(nIndex != -1)
{
pathArray.Add(m_strTracePath.Mid(lastIndex,nIndex+1));
lastIndex = nIndex+1;
nIndex = m_strTracePath.Find(_T("\\"),lastIndex);
}
CString path = _T("");
while(pathArray.GetSize()>0)
{
path += pathArray.GetAt(0);
if (!PathIsDirectory(path))
{
::CreateDirectory(path, NULL);
}
pathArray.RemoveAt(0);
}
}
}
|
0a62d51e63f4fac4de919c94cfb84d5c160f4587 | b6e9b157439011ea1602ed0ae4eeda45ab04f68a | /Banker.cpp | e7c789b19a74a396d47e29e4e48e7a9738934707 | [] | no_license | spisneha25/Banker-s-Algorithm | c8b0af4e280765fbba77142eab97191690df763b | 18330c0fa9cf5541f6122581de1a9cad92855064 | refs/heads/master | 2021-01-10T19:34:34.083478 | 2015-02-04T04:03:40 | 2015-02-04T04:03:40 | 30,280,142 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,305 | cpp | Banker.cpp | #include<iostream.h>
#include<graphics.h>
#include<conio.h>
#define MAX 20
void tblshp(int ,int a[MAX][MAX],int b[MAX][MAX],int c[MAX][MAX],int d[MAX]);
int nop, al[MAX][MAX],m[MAX][MAX],n[MAX][MAX],avail[MAX],result[MAX];
class bankers
{
private:
int nor,k,pnum,work[MAX],finish[MAX];
public:
bankers();
void input();
void method();
int search(int);
void display();
};
bankers::bankers()
{
k=0;
for(int i=0;i<MAX;i++)
{
for(int j=0;j<MAX;j++)
{
al[i][j]=0;
m[i][j]=0;
n[i][j]=0;
}
avail[i]=0;
result[i]=0;
finish[i]=0;
}
}
void bankers::input()
{
int i,j;
cout<<"Enter the number of processes:";
cin>>nop;
nor=3;
cout<<"Enter the allocated resources for each process: "<<endl;
for(i=0;i<nop;i++)
{
cout<<"\nProcess "<<i;
for(j=0;j<nor;j++)
{
cout<<"\nResource "<<j<<":";
cin>>al[i][j];
}
}
cout<<"Enter the maximum resources that are needed for each process: "<<endl;
for(i=0;i<nop;i++)
{
cout<<"\nProcess "<<i;
for(j=0;j<nor;j++)
{
cout<<"\nResouce "<<j<<":";
cin>>m[i][j];
n[i][j]=m[i][j]-al[i][j];
}
}
cout<<"Enter the currently available resources in the system: ";
for(j=0;j<nor;j++)
{
cout<<"Resource "<<j<<":";
cin>>avail[j];
work[j]=-1;
}
for(i=0;i<nop;i++)
finish[i]=0;
}
void bankers::method()
{
int i=0,j,flag;
while(1)
{
if(finish[i]==0)
{
pnum =search(i);
if(pnum!=-1)
{
result[k++]=i;
finish[i]=1;
for(j=0;j<nor;j++)
{
avail[j]=avail[j]+al[i][j];
}
}
}
i++;
if(i==nop)
{
flag=0;
for(j=0;j<nor;j++)
if(avail[j]!=work[j])
flag=1;
for(j=0;j<nor;j++)
work[j]=avail[j];
if(flag==0)
break;
else
i=0;
}
}
}
int bankers::search(int i)
{
int j;
for(j=0;j<nor;j++)
if(n[i][j]>avail[j])
return -1;
return 0;
}
void bankers::display()
{
int i,j;
cout<<endl<<"OUTPUT:";
cout<<endl<<"========";
cout<<endl<<"PROCESS\t ALLOTED\t MAXIMUM\t NEED";
for(i=0;i<nop;i++)
{
cout<<"\nP"<<i+1<<"\t ";
for(j=0;j<nor;j++)
{
cout<<al[i][j]<<" ";
}
cout<<"\t ";
for (j=0;j<nor;j++)
{
cout<<m[i][j]<<" ";
}
cout<<"\t ";
for(j=0;j<nor;j++ )
{
cout<<n[i][j]<<" ";
}
}
cout<<"\nThe sequence of the safe processes are: \n";
for(i=0;i<k;i++)
{
int temp = result[i]+1 ;
cout<<"P"<<temp<<" ";
}
cout<<"\nThe sequence of unsafe processes are: \n";
int flg=0;
for (i=0;i<nop;i++)
{
if(finish[i]==0)
{
flg=1;
}
cout<<"P"<<i<<" ";
}
cout<<endl<<"RESULT:";
cout<<endl<<"=======";
if(flg==1)
cout<<endl<<"The system is not in safe state and deadlock may occur!!";
else
cout<<endl<<"The system is in safe state and deadlock will not occur!!";
}
int main()
{
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
clrscr();
cout<<" DEADLOCK BANKER’S ALGORITHM "<<endl;
bankers B;
B.input ( );
B.method ( );
B.display ( );
clrscr();
tblshp(nop,al,m,n,result);
getch();
}
void tblshp(int i,int x[20][20],int y[20][20],int z[20][20],int result[20])
{ //int i=5;
int n;
setcolor(RED);
settextstyle(4,0,6);
outtextxy(100,4,"Banker's Algorithm");
rectangle(90,10,530,70);
settextstyle(0,0,0);
int a[]={1,2,3,4,5},l;
char p[]={'A','B','C'};
for(n=0,l=0;n<=i;n++,l++)
{
for(int k=0; k<4; k++)
{
rectangle(0+k*160,120+n*50,150+k*160,170+n*50);
if (k!=0)
{
for(int j=0;j<3;j++)
{
rectangle(160*k+j*50,120+n*50,210+160*(k-1)+j*50,170+n*50);
gotoxy(23+7*j+(k-1)*20,10);
cout<<p[j];
if (l!=0)
{
gotoxy(23+7*j+(k-1)*20,10+n*3);
switch(k-1)
{
case 0:
cout<<x[l-1][j];
break;
case 1:
cout<<y[l-1][j];
break;
case 2:
cout<<z[l-1][j];
break;
}
}
}
}
}
if (n!=0)
{
gotoxy(14,10+n*3);
cout<<n;
}
}
outtextxy(0,110,"Process name");
outtextxy(160,110,"Allocation");
outtextxy(320,110,"Maximum need");
outtextxy(480,110,"Available");
getch();
clrscr();
outtextxy(0,20,"safe sequence");
for(n=0;n<nop;n++)
{
rectangle(0+50*n,30,50+50*n,80);
gotoxy(4+6*n,4);
cout<<result[n];
gotoxy(14,4);
}
}
|
05e6542dca8b6e6bb878b47070881387001a55c9 | 6671c1892d93f0dd9d9799c35b984f209ca5db28 | /C++/practice/inheritance_prac_4.cpp | 2b52369f1e0fe4170c3d10d97120d4b0b8fd7ffc | [] | no_license | kcarollee/Problem-Solving | 011417798f1c27e6e11e381bdfe61037497dfe0f | 2ff75cfdfe7e2cb1e59e255ea12c1b0beb6f55ec | refs/heads/master | 2021-11-13T07:18:00.039952 | 2021-11-07T09:45:50 | 2021-11-07T09:45:50 | 153,068,096 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 902 | cpp | inheritance_prac_4.cpp | #include <iostream>
using namespace std;
class Base
{
private:
int baseNum;
public:
Base() : baseNum(20)
{
cout << "Constructor of Base called" << endl;
}
Base(int n) : baseNum(n)
{
cout << "Second Constructor of Base called" << endl;
}
void showBaseData()
{
cout << baseNum << endl;
}
};
class Derived : public Base
{
private:
int derivedNum;
public:
Derived() : derivedNum(30)
{
cout << "First Constructor of Derived called" << endl;
}
Derived(int n) : derivedNum(n)
{
cout << "Second Constructor of Derived called" << endl;
}
Derived(int n1, int n2) : Base(n1), derivedNum(n2)
{
cout << "Third Constructor of Derived called" << endl;
}
void showDerivedData()
{
showBaseData();
cout << derivedNum << endl;
}
};
int main()
{
cout << "case 1: ---------------------" << endl;
Derived *derived = new Derived();
derived->showDerivedData();
return 0;
}
|
d29ad5c16918a860cf49eb6bc9a8018823f585b0 | 6ab0fc072867b7f39f71dd6304f2671797ee5eb7 | /ButtonMidi2.ino | e2f2eb1740f34150ad9f7a02b42d65238d52f982 | [] | no_license | williamspmedia/typewritermidi | 55103cc3806fde7edfbc6af342907727edded299 | 2587a7204d9bc1bfab379c75a687e487744e6de9 | refs/heads/master | 2022-12-09T07:34:47.993149 | 2020-09-18T21:14:58 | 2020-09-18T21:14:58 | 258,038,449 | 8 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 8,258 | ino | ButtonMidi2.ino |
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD
// Wiring: SDA pin is connected to A4 and SCL pin to A5.
// Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered)
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27,16,2); // Change to (0x27,16,2) for 16x2 LCD.
struct MySettings : public midi::DefaultSettings {
static const long BaudRate = 128000;
};
enum NoteStatus : bool {
NOT_PLAYING = 0,
PLAYING
};
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial, MIDI, MySettings)
// constants won't change. They're used here to set pin numbers:
const int buttonPin[17] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38}; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState[17] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // current state of the button
int lastButtonState[17] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // previous state of the button
unsigned long cd[17] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //Cooldown
int hamIdx = 0;
String ham[273] =
{
"I am William",
"Heres some music",
"Sam I am",
"That Sam-I-am",
"That Sam-I-am!",
"I do not like",
"That Sam-I-am",
"Do you like",
"Green eggs ",
"and ham.",
"I do not ",
"like them,",
"Sam-I-am.",
"I do not like",
"Green eggs",
"and ham.",
"Would you ",
"like them",
"Here or there?",
"I would not",
"like them",
"Here or there.",
"I would not",
"like them",
"Anywhere.",
"I do not like",
"Green eggs",
"and ham.",
"I do not like",
"them, Sam-I-am",
"Would you like",
"in them a house?",
"Would you like",
"them with a",
"mouse?",
"I do not like",
"them in a house.",
"I do not like",
"them with ",
"a mouse.",
"I do not like",
"them here",
"or there",
"I do not like",
"them Anywhere.",
"I do not like",
"Green eggs",
"and ham.",
"I do not like",
"them, Sam-I-am",
"Would you eat",
"them in a box?",
"Would you eat",
"them with a fox?",
"Not in a box.",
"Not with a fox.",
"Not in a house.",
"Not with a mouse.",
"I would not eat",
"them here ",
"or there.",
"I would not eat",
"them anywhere.",
"I would not eat",
"green eggs ",
"and ham.",
"I do not like ",
"them, Sam-I-am.",
"Would you? ",
"Could you?",
"In a car?",
"Eat them! ",
"Eat them! ",
"Here they are.",
"I would not,",
"Could not,",
"In a car",
"You may ",
"like them.",
"You will see.",
"You may ",
"like them",
"In a tree?",
"I would not, ",
"could not ",
"in a tree.",
"Not in a car!",
"You let me be.",
"I do not like ",
"them in a box.",
"I do not like",
"them with a fox.",
"I do not like",
"them in a house.",
"I do not like",
"them with ",
"a mouse.",
"I do not like",
"them here ",
"or there.",
"I do not like ",
"them anywhere.",
"I do not like",
"green eggs",
"and ham.",
"I do not like",
"them, Sam-I-am.",
"A train!A train!",
"A train!A train!",
"Could you, ",
"would you",
"On a train?",
"Not on a train!",
"Not in a tree!",
"Not in a car!",
"Sam! Let me be!",
"I would not,",
"could not,",
"in a box.",
"I could not,",
"would not,",
"with a fox.",
"I will not eat ",
"them with",
"a mouse.",
"I will not eat",
"them in a house",
"I will not eat",
"them here",
"or there.",
"I will not eat ",
"them anywhere.",
"I do not like ",
"them, Sam-I-am.",
"Say!",
"In the dark?",
"Here",
"in the dark!",
"Would you, ",
"could you, ",
"in the dark?",
"I would not,",
"could not,",
"In the dark.",
"Would you,",
"could you,",
"In the rain?",
"I would not,",
"could not,",
"in the rain.",
"Not in the dark",
"Not on a train,",
"Not in a car,",
"Not in a tree.",
"I do not like",
"them, Sam,",
"you see.",
"Not in a house.",
"Not in a box.",
"Not with",
"a mouse.",
"Not with a fox.",
"I will not eat ",
"them here ",
"or there.",
"I do not like",
"them anywhere!",
"You do not like",
"Green eggs",
"and ham?",
"I do not",
"Like them,",
"Sam-I-am.",
"Could you,",
"would you,",
"With a goat?",
"I would not,",
"Could not.",
"With a goat!",
"Would you, ",
"could you,",
"On a boat?",
"I could not,",
"would not,",
"on a boat.",
"I will not,",
"will not,",
"with a goat.",
"I will not eat ",
"them in ",
"the rain.",
"I will not eat ",
"them on",
"a train.",
"Not in the dark",
"Not in a tree!",
"Not in a car!",
"You let me be!",
"I do not like ",
"them in a box.",
"I do not like",
"them with a fox.",
"I will not eat ",
"them in a house.",
"I do not like ",
"them with ",
"a mouse.",
"I do not like ",
"them here ",
"or there.",
"I do not like ",
"them anywhere!",
"I do not like",
"Green eggs",
"And ham!",
"I do not like",
"them ,Sam-I-am.",
"You do not ",
"like them.",
"So you say.",
"Try them! ",
"Try them! ",
"And you may.",
"Try them and ",
"you may I say.",
"Sam!",
"If you will ",
"let me be,",
"I will try them.",
"You will see.",
"Say!",
"I like ",
"green eggs ",
"and ham!",
"I do! ",
"I like them, ",
"Sam-I-am!",
"And I would",
"eat them in",
"a boat!",
"And I would ",
"eat them",
"with a goat...",
"And I will eat ",
"them in the rain",
"And in the dark.",
"And on a train.",
"And in a car.",
"And in a tree.",
"They are so good",
"so good",
"you see!",
"So I will eat",
"them in a box.",
"And I will eat",
"them with a fox.",
"And I will eat ",
"them in a house.",
"And I will eat",
"them with ",
"a mouse.",
"And I will eat ",
"them here ",
"and there.",
"Say! ",
"I will eat them ",
"Anywhere!",
"I do so like",
"Green eggs",
"and ham!",
"Thank you!",
"Thank you!",
"William",
};
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
// Initiate the LCD:
lcd.init();
lcd.backlight();
// Print 'Hello World!' on the first line of the LCD:
lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
lcd.print(ham[hamIdx]); //
lcd.setCursor(0, 1);
lcd.print(ham[hamIdx+1]);
//LaunchMidi and listen
MIDI.begin(5);
}
void loop()
{
unsigned long currTime = millis();
for(int x = 0; x<17; x++)
{
// read the state of the pushbutton value:
buttonState[x] = digitalRead(buttonPin[x]);
if(buttonState[x] != lastButtonState[x]) //If there is a change in button state
{
if(buttonState[x] == HIGH)//If the button is pressed
{
if(currTime - cd[x] >= 30)//Has enough time passed so we can press the button again?
{
lcd.clear();
// Print 'Hello World!' on the first line of the LCD:
lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
lcd.print(ham[hamIdx]); // Print the string "Hello World!"
lcd.setCursor(0, 1);
lcd.print(ham[hamIdx+1]);
hamIdx=hamIdx+1;
if(hamIdx > 271)
{
hamIdx = 0;
}
cd[x]=currTime;
MIDI.sendNoteOn((67+x), 127, 1);
lastButtonState[x] = buttonState[x];
}
else
{
}
}
else if(buttonState[x] == LOW)
{
MIDI.sendNoteOff((67+x), 0, 1);
lastButtonState[x] = buttonState[x];
}
//Error Handling
else
{
}
}
}
}
|
d567ad3da6816d2261dead82ded843068e294c2c | f153b04464e0bbe7c2db57f7b6c2d64d87f8953b | /leetcode/BinaryTreeMaximumPathSum.cpp | c8f39b4023a412a200d37e329d80f7357df74f39 | [] | no_license | alvas/ms_interview_100 | 82f4f7222db775c68b035dc616d812c63f3127a7 | 8587116a3c4227f71783e7dac42517b6561d17b0 | refs/heads/master | 2022-03-18T10:48:46.834899 | 2022-02-24T04:10:05 | 2022-02-24T04:10:05 | 16,854,684 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,289 | cpp | BinaryTreeMaximumPathSum.cpp | #include <iostream>
#include <vector>
#include "NormalData.h"
#include "Tree.h"
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int maxPathSum(TreeNode* root) {
int maxSum = INT_MIN;
findMax(root, maxSum);
return maxSum;
}
// 1. max(left subtree) + node
// 2. max(right subtree) + node
// 3. max(left subtree) + max(right subtree) + node
// 4. node
int findMax(TreeNode *root, int &maxSum)
{
if (root == NULL)
{
return 0;
}
int left = findMax(root->left, maxSum);
int right = findMax(root->right, maxSum);
maxSum = max(root->val + left + right, maxSum);
// IMPORTANT!! We are not returning maxSumhere.
int ret = root->val + max(left, right);
return ret ? ret : 0;
}
// This is really difficault. Got a lot of failure before tuning it right.
int maxPathSum1(TreeNode* root) {
int max = INT_MIN;
traverseSum(root, max);
return max;
}
// Really need to consider all kinds of situations.
int traverseSum(TreeNode *root, int &localMax)
{
// Be carefull, can't check root == NULL and return 0.
// Otherwise, if {-3} would return 0, instead of -3.
// The default value 0 may not suitible in some situation,
// because there can be negative number.
if (root->left == NULL && root->right == NULL)
{
localMax = max(localMax, root->val);
return root->val;
}
// Be careful, don't initialize left and right as INT_MIN, because they
// are added together later. And this would cause overflow.
int left = 0, right = 0;
if (root->left != NULL)
{
// Get the max value of the left child subtree.
left = traverseSum(root->left, localMax);
// Need to check the max among previous localMax, root and left + root.
localMax = max(localMax, root->val);
localMax = max(localMax, left + root->val);
}
else
{
localMax = max(localMax, root->val);
}
if (root->right != NULL)
{
// Get the max value of the right child subtree.
right = traverseSum(root->right, localMax);
// Need to check the max among previous localMax, root and right + root.
localMax = max(localMax, root->val);
localMax = max(localMax, right + root->val);
}
else
{
// Be careful, we can't assign root->val to localMax directly.
// Have to get the max between previous localMax and root->val,
// because the localMax would be set by the left child branch.
localMax = max(localMax, root->val);
}
// Need to get the max among previous localMax, root + left subtree + right subtree
localMax = max(localMax, root->val + left + right);
// Be very careful about the return value. The if the left/right subtree is negative, then don't add it to the return value. Otherwise, add the max of left/right subtree to root.
return max(0, max(left, right)) + root->val;
}
};
int main()
{
Solution sln;
std::vector<string> s = {"-3"};
//std::vector<string> s = {"-2", "-1"};
//std::vector<string> s = {"-2", "1"};
//std::vector<string> s = {"2", "-1", "-2"};
//std::vector<string> s = {"2", "-1"};
//std::vector<string> s = {"2", "-1", "-2"};
//std::vector<string> s = {"4", "2", "7", "1", "3", "8", "9"};
//std::vector<string> s = {"-1", "5", "#", "4", "#", "#", "2", "-4"};
//std::vector<string> s = {"-3", "2", "#", "3", "-6", "#", "#", "2"};
//std::vector<string> s = {"9", "6", "-3", "#", "#", "-6", "2", "#", "#", "2", "#", "-6", "-6", "-6"};
//std::vector<string> s = {"5", "6", "-6", "3", "5", "3", "#", "-7"};
TreeNode *root = NULL;
ReBuildTreeFromOrderLevel<TreeNode>(s, root);
printTreeLevelOrder<TreeNode>(root);
std::cout << sln.maxPathSum(root) << endl;
CleanUp2(root);
return 0;
}
|
2090e24a1c8b343a479302a62f11e4322b312e0a | aafa69798f6d0d38830c6d13bbf2fb9fa544d3be | /UVA/1124 Celebrity jeopardy.cpp | d6659abcead53965d5050b4ba684118496f3e202 | [] | no_license | anik-chy/OnlineJudges | 28f4cc6f2ff6206bc81d99955a8e218887d27674 | a057f2a4974d6cfc6fe3e628fd424a8ba928cafa | refs/heads/master | 2023-04-20T23:57:50.522983 | 2021-05-03T19:18:06 | 2021-05-03T19:18:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 354 | cpp | 1124 Celebrity jeopardy.cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
//freopen ("input.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
//system("notepad.exe input.txt");
string str;
while(getline(cin,str))
cout << str << endl;
//system("notepad.exe out.txt");
return 0;
}
|
eaad728063df4f6d25a0b2da3225d103ac81b22e | e366027ffef496d43350b044d0574127c512d690 | /src/xpcc/architecture/platform/board/al_avreb_can/al_avreb_can_serial.cpp | 1ac8d93b208c54f119620439bb065f03f449ca35 | [
"BSD-3-Clause"
] | permissive | roboterclubaachen/xpcc | aa504f3d0a8246861dd00ea437cc7b938a869669 | 010924901947381d20e83b838502880eb2ffea72 | refs/heads/develop | 2021-01-24T11:18:27.233788 | 2019-01-03T18:55:35 | 2019-01-03T18:55:35 | 3,626,127 | 163 | 51 | null | 2018-06-30T19:15:55 | 2012-03-05T10:49:18 | C | UTF-8 | C++ | false | false | 416 | cpp | al_avreb_can_serial.cpp | /* Copyright (c) 2016, Roboterclub Aachen e.V.
* All Rights Reserved.
*
* The file is part of the xpcc library and is released under the 3-clause BSD
* license. See the file `LICENSE` for the full license governing this code.
* ------------------------------------------------------------------------ */
#include "al_avreb_can.hpp"
Board::LoggerDevice serialDevice;
xpcc::IOStream serialStream(serialDevice);
|
3e77c0db6181eee75ca9c0e9e2968507a889623d | c66b1d5a698f67e7bac8c3d91169f4ba4c0c60cc | /src/uiInputs.h | 87e2f514bf3a7a887401f1d7c28bc9933555aea5 | [
"MIT"
] | permissive | dietmar153/OpenPixelMapper | e96ea01dae430d4346f44a2f7dedb78074156fb2 | 6521aa45517c6ccaf5685e8a89e6f269abaed298 | refs/heads/master | 2021-01-13T08:01:13.408617 | 2014-05-20T07:11:54 | 2014-05-20T07:11:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 355 | h | uiInputs.h | //
// uiInputs.h
// openPixelMapper
//
// Created by Tobias Ebsen on 14/03/14.
//
//
#pragma once
#include "ofxUI.h"
class uiInputs : public ofxUISuperCanvas {
public:
uiInputs(float x, float y, float w, float h);
void setup();
private:
ofxUIImageToggle *inputChecker, *inputImage, *inputMovie, *inputWebcam, *inputSyphon;
}; |
6404168da3377ec7869c209be2ce4220dfd034bb | 255cd9f19d866576910650c45581873fcb9ae51f | /source/wrapper/tools/zet_debug.cpp | 82cdc798d6f7be61c6c9ad2c76066fd07215a2c6 | [
"MIT"
] | permissive | hassoon1986/level-zero | b1188435099d2b2e58f1d97cd46e310648f0ae4b | 875fef26e2a4a2eb9f4f61dc25e35f30362dc5e9 | refs/heads/master | 2022-06-08T21:30:32.449447 | 2020-04-14T20:42:08 | 2020-04-14T20:45:29 | 260,108,442 | 1 | 0 | MIT | 2020-04-30T03:53:28 | 2020-04-30T03:53:27 | null | UTF-8 | C++ | false | false | 19,451 | cpp | zet_debug.cpp | /*
*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
* @file zet_debug.cpp
*
* @brief C++ wrapper of Intel 'One API' Level-Zero Tool APIs for Program Debug
*
*/
#include "zet_api.hpp"
#include "ze_singleton.h"
#define _STRING(s) #s
#define STRING(s) _STRING(s)
namespace zet
{
///////////////////////////////////////////////////////////////////////////////
Debug::Debug(
debug_session_handle_t handle ///< [in] debug session handle
) :
m_handle( handle )
{
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Attach to a device.
///
/// @returns
/// - Debug*: debug session handle
///
/// @throws result_t
Debug* __zecall
Debug::Attach(
Device* pDevice, ///< [in] device handle
const config_t* config ///< [in] the debug configuration
)
{
zet_debug_session_handle_t hDebug;
auto result = static_cast<result_t>( ::zetDebugAttach(
reinterpret_cast<zet_device_handle_t>( pDevice->getHandle() ),
reinterpret_cast<const zet_debug_config_t*>( config ),
&hDebug ) );
if( result_t::SUCCESS != result )
throw exception_t( result, __FILE__, STRING(__LINE__), "zet::Debug::Attach" );
Debug* pDebug = nullptr;
try
{
pDebug = new Debug( reinterpret_cast<debug_session_handle_t>( hDebug ) );
}
catch( std::bad_alloc& )
{
delete pDebug;
pDebug = nullptr;
throw exception_t( result_t::ERROR_OUT_OF_HOST_MEMORY, __FILE__, STRING(__LINE__), "zet::Debug::Attach" );
}
return pDebug;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Close a debug session.
///
/// @throws result_t
void __zecall
Debug::Detach(
void
)
{
auto result = static_cast<result_t>( ::zetDebugDetach(
reinterpret_cast<zet_debug_session_handle_t>( getHandle() ) ) );
if( result_t::SUCCESS != result )
throw exception_t( result, __FILE__, STRING(__LINE__), "zet::Debug::Detach" );
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Query the number of device threads for a debug session.
///
/// @returns
/// - uint64_t: the maximal number of threads
///
/// @throws result_t
uint64_t __zecall
Debug::GetNumThreads(
void
)
{
uint64_t numThreads;
auto result = static_cast<result_t>( ::zetDebugGetNumThreads(
reinterpret_cast<zet_debug_session_handle_t>( getHandle() ),
&numThreads ) );
if( result_t::SUCCESS != result )
throw exception_t( result, __FILE__, STRING(__LINE__), "zet::Debug::GetNumThreads" );
return numThreads;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Read the topmost debug event.
///
/// @returns
/// - ze::bool_t:'0' when ZE::RESULT_NOT_READY
/// @throws result_t
ze::bool_t __zecall
Debug::ReadEvent(
uint64_t timeout, ///< [in] timeout in milliseconds (or ::ZET_DEBUG_TIMEOUT_INFINITE)
size_t size, ///< [in] the size of the buffer in bytes
void* buffer ///< [in,out] a buffer to hold the event data
)
{
auto result = static_cast<result_t>( ::zetDebugReadEvent(
reinterpret_cast<zet_debug_session_handle_t>( getHandle() ),
timeout,
size,
buffer ) );
if( result_t::NOT_READY == result )
return 0; // false
if( result_t::SUCCESS != result )
throw exception_t( result, __FILE__, STRING(__LINE__), "zet::Debug::ReadEvent" );
return 1; // true
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Interrupt device threads.
///
/// @throws result_t
void __zecall
Debug::Interrupt(
uint64_t threadid ///< [in] the thread to inerrupt or ::ZET_DEBUG_THREAD_ALL
)
{
auto result = static_cast<result_t>( ::zetDebugInterrupt(
reinterpret_cast<zet_debug_session_handle_t>( getHandle() ),
threadid ) );
if( result_t::SUCCESS != result )
throw exception_t( result, __FILE__, STRING(__LINE__), "zet::Debug::Interrupt" );
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Resume device threads.
///
/// @throws result_t
void __zecall
Debug::Resume(
uint64_t threadid ///< [in] the thread to resume or ::ZET_DEBUG_THREAD_ALL
)
{
auto result = static_cast<result_t>( ::zetDebugResume(
reinterpret_cast<zet_debug_session_handle_t>( getHandle() ),
threadid ) );
if( result_t::SUCCESS != result )
throw exception_t( result, __FILE__, STRING(__LINE__), "zet::Debug::Resume" );
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Read memory.
///
/// @throws result_t
void __zecall
Debug::ReadMemory(
uint64_t threadid, ///< [in] the thread context or ::ZET_DEBUG_THREAD_NONE
int memSpace, ///< [in] the (device-specific) memory space
uint64_t address, ///< [in] the virtual address of the memory to read from
size_t size, ///< [in] the number of bytes to read
void* buffer ///< [in,out] a buffer to hold a copy of the memory
)
{
auto result = static_cast<result_t>( ::zetDebugReadMemory(
reinterpret_cast<zet_debug_session_handle_t>( getHandle() ),
threadid,
memSpace,
address,
size,
buffer ) );
if( result_t::SUCCESS != result )
throw exception_t( result, __FILE__, STRING(__LINE__), "zet::Debug::ReadMemory" );
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Write memory.
///
/// @throws result_t
void __zecall
Debug::WriteMemory(
uint64_t threadid, ///< [in] the thread context or ::ZET_DEBUG_THREAD_NONE
int memSpace, ///< [in] the (device-specific) memory space
uint64_t address, ///< [in] the virtual address of the memory to write to
size_t size, ///< [in] the number of bytes to write
const void* buffer ///< [in] a buffer holding the pattern to write
)
{
auto result = static_cast<result_t>( ::zetDebugWriteMemory(
reinterpret_cast<zet_debug_session_handle_t>( getHandle() ),
threadid,
memSpace,
address,
size,
buffer ) );
if( result_t::SUCCESS != result )
throw exception_t( result, __FILE__, STRING(__LINE__), "zet::Debug::WriteMemory" );
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Read register state.
///
/// @throws result_t
void __zecall
Debug::ReadState(
uint64_t threadid, ///< [in] the thread context
uint64_t offset, ///< [in] the offset into the register state area
size_t size, ///< [in] the number of bytes to read
void* buffer ///< [in,out] a buffer to hold a copy of the register state
)
{
auto result = static_cast<result_t>( ::zetDebugReadState(
reinterpret_cast<zet_debug_session_handle_t>( getHandle() ),
threadid,
offset,
size,
buffer ) );
if( result_t::SUCCESS != result )
throw exception_t( result, __FILE__, STRING(__LINE__), "zet::Debug::ReadState" );
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Write register state.
///
/// @throws result_t
void __zecall
Debug::WriteState(
uint64_t threadid, ///< [in] the thread context
uint64_t offset, ///< [in] the offset into the register state area
size_t size, ///< [in] the number of bytes to write
const void* buffer ///< [in] a buffer holding the pattern to write
)
{
auto result = static_cast<result_t>( ::zetDebugWriteState(
reinterpret_cast<zet_debug_session_handle_t>( getHandle() ),
threadid,
offset,
size,
buffer ) );
if( result_t::SUCCESS != result )
throw exception_t( result, __FILE__, STRING(__LINE__), "zet::Debug::WriteState" );
}
} // namespace zet
namespace zet
{
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::event_flags_t to std::string
std::string to_string( const Debug::event_flags_t val )
{
const auto bits = static_cast<uint32_t>( val );
std::string str;
if( 0 == bits )
str += "DEBUG_EVENT_FLAG_NONE ";
if( static_cast<uint32_t>(Debug::event_flags_t::DEBUG_EVENT_FLAG_STOPPED) & bits )
str += "DEBUG_EVENT_FLAG_STOPPED | ";
return ( str.size() > 3 )
? "Debug::event_flags_t::{ " + str.substr(0, str.size() - 3) + " }"
: "Debug::event_flags_t::{ ? }";
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::event_type_t to std::string
std::string to_string( const Debug::event_type_t val )
{
std::string str;
switch( val )
{
case Debug::event_type_t::DEBUG_EVENT_INVALID:
str = "Debug::event_type_t::DEBUG_EVENT_INVALID";
break;
case Debug::event_type_t::DEBUG_EVENT_DETACHED:
str = "Debug::event_type_t::DEBUG_EVENT_DETACHED";
break;
case Debug::event_type_t::DEBUG_EVENT_PROCESS_ENTRY:
str = "Debug::event_type_t::DEBUG_EVENT_PROCESS_ENTRY";
break;
case Debug::event_type_t::DEBUG_EVENT_PROCESS_EXIT:
str = "Debug::event_type_t::DEBUG_EVENT_PROCESS_EXIT";
break;
case Debug::event_type_t::DEBUG_EVENT_MODULE_LOAD:
str = "Debug::event_type_t::DEBUG_EVENT_MODULE_LOAD";
break;
case Debug::event_type_t::DEBUG_EVENT_MODULE_UNLOAD:
str = "Debug::event_type_t::DEBUG_EVENT_MODULE_UNLOAD";
break;
case Debug::event_type_t::DEBUG_EVENT_EXCEPTION:
str = "Debug::event_type_t::DEBUG_EVENT_EXCEPTION";
break;
default:
str = "Debug::event_type_t::?";
break;
};
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::detach_reason_t to std::string
std::string to_string( const Debug::detach_reason_t val )
{
std::string str;
switch( val )
{
case Debug::detach_reason_t::DEBUG_DETACH_INVALID:
str = "Debug::detach_reason_t::DEBUG_DETACH_INVALID";
break;
case Debug::detach_reason_t::DEBUG_DETACH_HOST_EXIT:
str = "Debug::detach_reason_t::DEBUG_DETACH_HOST_EXIT";
break;
default:
str = "Debug::detach_reason_t::?";
break;
};
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::memory_space_intel_graphics_t to std::string
std::string to_string( const Debug::memory_space_intel_graphics_t val )
{
std::string str;
switch( val )
{
case Debug::memory_space_intel_graphics_t::DEBUG_MEMORY_SPACE_GEN_DEFAULT:
str = "Debug::memory_space_intel_graphics_t::DEBUG_MEMORY_SPACE_GEN_DEFAULT";
break;
case Debug::memory_space_intel_graphics_t::DEBUG_MEMORY_SPACE_GEN_SLM:
str = "Debug::memory_space_intel_graphics_t::DEBUG_MEMORY_SPACE_GEN_SLM";
break;
default:
str = "Debug::memory_space_intel_graphics_t::?";
break;
};
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::state_intel_graphics_t to std::string
std::string to_string( const Debug::state_intel_graphics_t val )
{
std::string str;
switch( val )
{
case Debug::state_intel_graphics_t::DEBUG_STATE_GEN_INVALID:
str = "Debug::state_intel_graphics_t::DEBUG_STATE_GEN_INVALID";
break;
case Debug::state_intel_graphics_t::DEBUG_STATE_GEN_GRF:
str = "Debug::state_intel_graphics_t::DEBUG_STATE_GEN_GRF";
break;
case Debug::state_intel_graphics_t::DEBUG_STATE_GEN_ACC:
str = "Debug::state_intel_graphics_t::DEBUG_STATE_GEN_ACC";
break;
case Debug::state_intel_graphics_t::DEBUG_STATE_GEN_ADDR:
str = "Debug::state_intel_graphics_t::DEBUG_STATE_GEN_ADDR";
break;
case Debug::state_intel_graphics_t::DEBUG_STATE_GEN_FLAG:
str = "Debug::state_intel_graphics_t::DEBUG_STATE_GEN_FLAG";
break;
default:
str = "Debug::state_intel_graphics_t::?";
break;
};
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::config_v1_t to std::string
std::string to_string( const Debug::config_v1_t val )
{
std::string str;
str += "Debug::config_v1_t::pid : ";
str += std::to_string(val.pid);
str += "\n";
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::config_variants_t to std::string
std::string to_string( const Debug::config_variants_t val )
{
std::string str;
str += "Debug::config_variants_t::v1 : ";
str += to_string(val.v1);
str += "\n";
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::config_t to std::string
std::string to_string( const Debug::config_t val )
{
std::string str;
str += "Debug::config_t::version : ";
str += std::to_string(val.version);
str += "\n";
str += "Debug::config_t::variant : ";
str += to_string(val.variant);
str += "\n";
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::event_info_detached_t to std::string
std::string to_string( const Debug::event_info_detached_t val )
{
std::string str;
str += "Debug::event_info_detached_t::reason : ";
str += std::to_string(val.reason);
str += "\n";
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::event_info_module_t to std::string
std::string to_string( const Debug::event_info_module_t val )
{
std::string str;
str += "Debug::event_info_module_t::moduleBegin : ";
str += std::to_string(val.moduleBegin);
str += "\n";
str += "Debug::event_info_module_t::moduleEnd : ";
str += std::to_string(val.moduleEnd);
str += "\n";
str += "Debug::event_info_module_t::load : ";
str += std::to_string(val.load);
str += "\n";
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::event_info_t to std::string
std::string to_string( const Debug::event_info_t val )
{
std::string str;
str += "Debug::event_info_t::detached : ";
str += to_string(val.detached);
str += "\n";
str += "Debug::event_info_t::module : ";
str += to_string(val.module);
str += "\n";
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::event_t to std::string
std::string to_string( const Debug::event_t val )
{
std::string str;
str += "Debug::event_t::type : ";
str += std::to_string(val.type);
str += "\n";
str += "Debug::event_t::thread : ";
str += std::to_string(val.thread);
str += "\n";
str += "Debug::event_t::flags : ";
str += std::to_string(val.flags);
str += "\n";
str += "Debug::event_t::info : ";
str += to_string(val.info);
str += "\n";
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::state_section_t to std::string
std::string to_string( const Debug::state_section_t val )
{
std::string str;
str += "Debug::state_section_t::type : ";
str += std::to_string(val.type);
str += "\n";
str += "Debug::state_section_t::version : ";
str += std::to_string(val.version);
str += "\n";
str += "Debug::state_section_t::size : ";
str += std::to_string(val.size);
str += "\n";
str += "Debug::state_section_t::offset : ";
str += std::to_string(val.offset);
str += "\n";
return str;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Converts Debug::state_t to std::string
std::string to_string( const Debug::state_t val )
{
std::string str;
str += "Debug::state_t::size : ";
str += std::to_string(val.size);
str += "\n";
str += "Debug::state_t::headerSize : ";
str += std::to_string(val.headerSize);
str += "\n";
str += "Debug::state_t::secSize : ";
str += std::to_string(val.secSize);
str += "\n";
str += "Debug::state_t::numSec : ";
str += std::to_string(val.numSec);
str += "\n";
return str;
}
} // namespace zet
|
0c5640d1c9252ba55cf3e131d9509a4056a6d570 | 7f44649ed154669320be8866b7099aab34703425 | /ZZip/ZipHeaders.cpp | e6e9cf2810d5bce61416c235cd2ac30e4e74042e | [
"MIT"
] | permissive | azvenigo/ZZipUpdate | 84cb46ed06d034dab5421a9b461259d809b1f48b | 2f00b6eada227d8f711237dee36caa03a7033202 | refs/heads/master | 2022-11-03T00:57:42.991537 | 2022-09-27T06:51:19 | 2022-09-27T06:51:19 | 180,079,321 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 37,286 | cpp | ZipHeaders.cpp | // MIT License
// Copyright 2019 Alex Zvenigorodsky
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "ZipHeaders.h"
//#include <boost/lexical_cast.hpp>
#include <time.h>
#include <ctime>
#include <filesystem>
#include <iostream>
#include <iomanip>
#include "common/FNMatch.h"
using namespace std;
string cExtensibleFieldEntry::HeaderToString()
{
switch (mnHeader)
{
case 0x0001: return "0x01-Zip64 extended information extra field";
case 0x0007: return "0x07-AV Info";
case 0x0008: return "0x08-Reserved for extended language encoding data(PFS)";
case 0x0009: return "0x09-OS/2";
case 0x000a: return "0x0a-NTFS";
case 0x000c: return "0x0c-OpenVMS";
case 0x000d: return "0x0d-UNIX";
case 0x000e: return "0x0e-Reserved for file stream and fork descriptors";
case 0x000f: return "0x0f-Patch Descriptor";
case 0x0014: return "0x14-PKCS#7 Store for X.509 Certificates";
case 0x0015: return "0x15-X.509 Certificate ID and Signature for individual file";
case 0x0016: return "0x16-X.509 Certificate ID for Central Directory";
case 0x0017: return "0x17-Strong Encryption Header";
case 0x0018: return "0x18-Record Management Controls";
case 0x0019: return "0x19-PKCS#7 Encryption Recipient Certificate List";
case 0x0065: return "0x65-IBM S / 390 (Z390), AS / 400 (I400)attributes-uncompressed";
case 0x0066: return "0x66-Reserved for IBM S / 390 (Z390), AS / 400 (I400)attributes - compressed";
case 0x4690: return "0x4690-POSZIP 4690 (reserved)";
}
return "";
}
cExtensibleFieldEntry::cExtensibleFieldEntry(const cExtensibleFieldEntry& from)
{
mnHeader = from.mnHeader;
mnSize = from.mnSize;
if (mnSize > 0)
{
mpData = from.mpData;
}
}
string cExtensibleFieldEntry::ToString()
{
return "Header:" + HeaderToString() + " Size:" + to_string(mnSize) + " Data: [" + binary_to_hex(mpData.get(), mnSize) + "]";
}
bool ParseExtendedFields(uint8_t* pSearch, int32_t nSize, tExtensibleFieldList& list)
{
uint8_t* pEnd = pSearch + nSize;
while (pSearch < pEnd)
{
cExtensibleFieldEntry entry;
entry.mnHeader = *((uint16_t*)(pSearch));
entry.mnSize = *((uint16_t*)(pSearch + 2));
if (entry.mnSize > 0)
{
entry.mpData.reset(new uint8_t[entry.mnSize]);
memcpy(entry.mpData.get(), pSearch + 4, entry.mnSize);
}
list.push_back(entry);
pSearch += sizeof(uint16_t) + sizeof(uint16_t) + entry.mnSize;
}
return true;
}
bool cLocalFileHeader::ParseRaw(uint8_t* pBuffer, uint32_t& nNumBytesProcessed)
{
mLocalFileTag = *((uint32_t*)pBuffer);
if (mLocalFileTag != kZipLocalFileHeaderTag)
{
cout << "Couldn't read LocalFileHeader signature.\n";
return false;
}
mMinVersionToExtract = *((uint16_t*)(pBuffer + 4));
mGeneralPurposeBitFlag = *((uint16_t*)(pBuffer + 6));
mCompressionMethod = *((uint16_t*)(pBuffer + 8));
mLastModificationTime = *((uint16_t*)(pBuffer + 10));
mLastModificationDate = *((uint16_t*)(pBuffer + 12));
mCRC32 = *((uint32_t*)(pBuffer + 14));
mCompressedSize = *((uint32_t*)(pBuffer + 18));
mUncompressedSize = *((uint32_t*)(pBuffer + 22));
mFilenameLength = *((uint16_t*)(pBuffer + 26));
mExtraFieldLength = *((uint16_t*)(pBuffer + 28));
mFilename.assign((char*)(pBuffer + kStaticDataSize), mFilenameLength);
uint8_t* pSearch = pBuffer + kStaticDataSize + mFilenameLength;
ParseExtendedFields(pSearch, mExtraFieldLength, mExtensibleFieldList);
uint8_t* pExtraFieldEnd = pSearch + mExtraFieldLength;
while (pSearch < pExtraFieldEnd)
{
uint16_t nTag = *((uint16_t*)pSearch);
if (nTag == kZipExtraFieldZip64ExtendedInfoTag)
{
pSearch += sizeof(uint16_t); // skip the 16 bit tag
// uint16_t nSizeOfExtendedField = *((uint16_t*)pSearch);
pSearch += sizeof(uint16_t); // skip the size of this extended field
if (mUncompressedSize == 0xffffffff)
{
mUncompressedSize = *((uint64_t*)(pSearch));
pSearch += sizeof(uint64_t);
}
if (mCompressedSize == 0xffffffff)
{
mCompressedSize = *((uint64_t*)(pSearch));
pSearch += sizeof(uint64_t);
}
break;
}
uint16_t nFieldBlock = *((uint16_t*)(pSearch + sizeof(uint16_t)));
pSearch += (nFieldBlock + sizeof(uint32_t)); // past the tag
}
nNumBytesProcessed = kStaticDataSize + mFilenameLength + mExtraFieldLength;
return true;
}
string cLocalFileHeader::FieldNames(eToStringFormat format)
{
return FormatStrings(format, "MinVersionToExtract", "GeneralPurposeBitFlag", "CompressionMethod", "LastModificationTime", "LastModificationDate", "CRC32", "CompressedSize", "UncompressedSize", "FilenameLength", "ExtraFieldLength", "Filename", "ExtraField");
}
string cLocalFileHeader::ToString(eToStringFormat format)
{
string sExtendedFields;
for (tExtensibleFieldList::iterator it = mExtensibleFieldList.begin(); it != mExtensibleFieldList.end(); it++)
sExtendedFields += (*it).ToString() + " ";
return FormatStrings(format,
to_string(mMinVersionToExtract),
to_string(mGeneralPurposeBitFlag),
to_string(mCompressionMethod),
to_string(mLastModificationTime),
to_string(mLastModificationDate),
int_to_hex_string(mCRC32),
to_string(mCompressedSize),
to_string(mUncompressedSize),
to_string(mFilenameLength),
to_string(mExtraFieldLength),
mFilename,
sExtendedFields);
}
bool cLocalFileHeader::Read(cZZFile& file, uint64_t nOffsetToLocalFileHeader, uint32_t& nNumBytesProcessed)
{
// First we calculate how much data we need to read the LocalFileHeader
// The LocalFileHeader is a static size of 30 bytes + FileNameLength + ExtraFieldLength which are stored at offset 26 and 28 respectively.
const uint64_t kOffsetToFilenameLength = 26;
uint16_t nFilenameLength;
uint16_t nExtraFieldLength;
uint32_t nNumRead;
file.Read(nOffsetToLocalFileHeader + kOffsetToFilenameLength, sizeof(uint16_t), (uint8_t*)&nFilenameLength, nNumRead);
file.Read(nOffsetToLocalFileHeader + kOffsetToFilenameLength + sizeof(uint16_t), sizeof(uint16_t), (uint8_t*)&nExtraFieldLength, nNumRead);
uint32_t nLocalFileHeaderRawSize = kStaticDataSize + nFilenameLength + nExtraFieldLength;
uint8_t* pBuffer = new uint8_t[nLocalFileHeaderRawSize];
if (!file.Read(nOffsetToLocalFileHeader, nLocalFileHeaderRawSize, pBuffer, nNumRead))
{
delete[] pBuffer;
cout << "Couldn't read LocalFileHeader\n";
return false;
}
ParseRaw(pBuffer, nNumBytesProcessed);
delete[] pBuffer;
return true;
}
bool cLocalFileHeader::Write(cZZFile& file, uint64_t nOffsetToLocalFileHeader)
{
bool bSuccess = true;
uint32_t nWritten = 0;
bSuccess &= file.Write(nOffsetToLocalFileHeader, sizeof(uint32_t), (uint8_t*)&mLocalFileTag, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mMinVersionToExtract, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mGeneralPurposeBitFlag, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mCompressionMethod, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mLastModificationTime, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mLastModificationDate, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&mCRC32, nWritten);
uint16_t nExtraFieldLengthToWrite = kExtendedFieldLength;
uint16_t nExtendedFieldLengthToWrite = kExtendedFieldLength - sizeof(uint16_t) - sizeof(uint16_t);
uint32_t nNegOne = (uint32_t)-1;
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&nNegOne, nWritten); // compressed size
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&nNegOne, nWritten); // uncompressed size
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mFilenameLength, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&nExtraFieldLengthToWrite, nWritten);
// write the filename
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, mFilenameLength, (uint8_t*)mFilename.c_str(), nWritten);
// now write the extra field
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&kZipExtraFieldZip64ExtendedInfoTag, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&nExtendedFieldLengthToWrite, nWritten); // extra field just includes this extended field minus tag and size of data
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mUncompressedSize, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mCompressedSize, nWritten);
if (!bSuccess)
{
cout << "cLocalFileHeader::Write - Failure to write LocalFileHeader!\n";
return false;
}
return true;
}
uint64_t cLocalFileHeader::Size()
{
return kStaticDataSize + mFilenameLength + kExtendedFieldLength;
}
bool cEndOfCDRecord::ParseRaw(uint8_t* pBuffer, uint32_t& nNumBytesProcessed)
{
mEndOfCDRecTag = *((uint32_t*)pBuffer);
if (mEndOfCDRecTag != kZipEndofCDTag)
{
cout << "Couldn't parse EndOfCDRecord\n";
return false;
}
mDiskNum = *((uint16_t*)(pBuffer + 4));
mDiskNumOfCD = *((uint16_t*)(pBuffer + 6));
mNumCDRecordsThisDisk = *((uint16_t*)(pBuffer + 8));
mNumTotalRecords = *((uint16_t*)(pBuffer + 10));
mNumBytesOfCD = *((uint32_t*)(pBuffer + 12));
mCDStartOffset = *((uint32_t*)(pBuffer + 16));
mNumBytesOfComment = *((uint16_t*)(pBuffer + 20));
mComment.assign((char*)(pBuffer + 22), mNumBytesOfComment);
nNumBytesProcessed = 22 + mNumBytesOfComment; // end of comment
return true;
}
bool cEndOfCDRecord::Write(cZZFile& file)
{
bool bSuccess = true;
uint32_t nWritten = 0;
bSuccess &= file.Write(cZZFile::ZZFILE_SEEK_END, sizeof(uint32_t), (uint8_t*)&mEndOfCDRecTag, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mDiskNum, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mDiskNumOfCD, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mNumCDRecordsThisDisk, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mNumTotalRecords, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&mNumBytesOfCD, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&mCDStartOffset, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mNumBytesOfComment, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, (uint32_t) mComment.length(), (uint8_t*)mComment.c_str(), nWritten);
if (!bSuccess)
{
cout << "cEndOfCDRecord::Write - Failure to write cEndOfCDRecord!\n";
return false;
}
return true;
}
string cEndOfCDRecord::FieldNames(eToStringFormat format)
{
return FormatStrings(format, "DiskNum", "DiskNumOfCD", "NumCDRecordsThisDisk", "NumTotalRecords", "NumBytesOfCD", "CDStartOffset", "NumBytesOfComment", "Comment");
}
string cEndOfCDRecord::ToString(eToStringFormat format)
{
return FormatStrings(format,
to_string(mDiskNum),
to_string(mDiskNumOfCD),
to_string(mNumCDRecordsThisDisk),
to_string(mNumTotalRecords),
to_string(mNumBytesOfCD),
to_string(mCDStartOffset),
to_string(mNumBytesOfComment),
mComment);
}
cZip64EndOfCDRecord::~cZip64EndOfCDRecord()
{
delete[] mpZip64ExtensibleDataSector; // delete any allocated buffer if it exists. Safe to do if null.
}
bool cZip64EndOfCDRecord::ParseRaw(uint8_t* pBuffer, uint32_t& nNumBytesProcessed)
{
mZip64EndOfCDRecTag = *((uint32_t*)pBuffer);
if (mZip64EndOfCDRecTag != kZip64EndofCDTag)
{
cout << "Couldn't parse Zip64EndOfCDRecord\n";
return false;
}
mSizeOfZiP64EndOfCDRecord = *((uint64_t*)(pBuffer + 4));
mVersionMadeBy = *((uint16_t*)(pBuffer + 12));
mMinVersionToExtract = *((uint16_t*)(pBuffer + 14));
mDiskNum = *((uint32_t*)(pBuffer + 16));
mDiskNumOfCD = *((uint32_t*)(pBuffer + 20));
mNumCDRecordsThisDisk = *((uint64_t*)(pBuffer + 24));
mNumTotalRecords = *((uint64_t*)(pBuffer + 32));
mNumBytesOfCD = *((uint64_t*)(pBuffer + 40));
mCDStartOffset = *((uint64_t*)(pBuffer + 48));
mnDerivedSizeOfExtensibleDataSector = (uint32_t)(mSizeOfZiP64EndOfCDRecord + 12 - 56);
if (mnDerivedSizeOfExtensibleDataSector > 0)
{
mpZip64ExtensibleDataSector = new uint8_t[mnDerivedSizeOfExtensibleDataSector];
memcpy(mpZip64ExtensibleDataSector, pBuffer + 56, mnDerivedSizeOfExtensibleDataSector);
}
else
{
mpZip64ExtensibleDataSector = NULL;
}
nNumBytesProcessed = sizeof(uint32_t) + sizeof(uint64_t) + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(uint32_t) + mnDerivedSizeOfExtensibleDataSector;
return true;
}
bool cZip64EndOfCDRecord::Write(cZZFile& file)
{
bool bSuccess = true;
uint32_t nWritten = 0;
bSuccess &= file.Write(cZZFile::ZZFILE_SEEK_END, sizeof(uint32_t), (uint8_t*)&mZip64EndOfCDRecTag, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mSizeOfZiP64EndOfCDRecord, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mVersionMadeBy, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mMinVersionToExtract, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&mDiskNum, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&mDiskNumOfCD, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mNumCDRecordsThisDisk, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mNumTotalRecords, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mNumBytesOfCD, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mCDStartOffset, nWritten);
if (mpZip64ExtensibleDataSector)
{
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, mnDerivedSizeOfExtensibleDataSector, (uint8_t*)mpZip64ExtensibleDataSector, nWritten);
}
if (!bSuccess)
{
cout << "cCDFileHeader::Write - Failure to write CDFileHeader!\n";
return false;
}
return true;
}
string cZip64EndOfCDRecord::FieldNames(eToStringFormat format)
{
return FormatStrings(format, "SizeOfZiP64EndOfCDRecord", "VersionMadeBy", "MinVersionToExtract", "DiskNum", "DiskNumOfCD", "NumCDRecordsThisDisk", "NumTotalRecords", "NumBytesOfCD", "CDStartOffset", "nDerivedSizeOfExtensibleDataSector");
}
string cZip64EndOfCDRecord::ToString(eToStringFormat format)
{
return FormatStrings(format,
to_string(mSizeOfZiP64EndOfCDRecord),
to_string(mVersionMadeBy),
to_string(mMinVersionToExtract),
to_string(mDiskNum),
to_string(mDiskNumOfCD),
to_string(mNumCDRecordsThisDisk),
to_string(mNumTotalRecords),
to_string(mNumBytesOfCD),
to_string(mCDStartOffset),
to_string(mnDerivedSizeOfExtensibleDataSector));
}
bool cZip64EndOfCDLocator::ParseRaw(uint8_t* pBuffer, uint32_t& nNumBytesProcessed)
{
mZip64EndOfCDLocatorTag = *((uint32_t*)pBuffer);
if (mZip64EndOfCDLocatorTag != kZip64EndofCDLocatorTag)
{
cout << "Couldn't parse CD Header Tag\n";
return false;
}
mDiskNumOfCD = *((uint32_t*)(pBuffer + 4));
mZip64EndofCDOffset = *((uint64_t*)(pBuffer + 8));
mNumTotalDisks = *((uint32_t*)(pBuffer + 16));
nNumBytesProcessed = sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint64_t) + sizeof(uint32_t);
return true;
}
bool cZip64EndOfCDLocator::Write(cZZFile& file)
{
bool bSuccess = true;
uint32_t nWritten = 0;
bSuccess &= file.Write(cZZFile::ZZFILE_SEEK_END, sizeof(uint32_t), (uint8_t*)&mZip64EndOfCDLocatorTag, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&mDiskNumOfCD, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mZip64EndofCDOffset, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&mNumTotalDisks, nWritten);
if (!bSuccess)
{
cout << "cZip64EndOfCDLocator::Write - Failure to write cZip64EndOfCDLocator!\n";
return false;
}
return true;
}
string cZip64EndOfCDLocator::FieldNames(eToStringFormat format)
{
return FormatStrings(format, "DiskNumOfCD", "Zip64EndofCDOffset", "NumTotalDisks");
}
string cZip64EndOfCDLocator::ToString(eToStringFormat format)
{
return FormatStrings(format, to_string(mDiskNumOfCD), to_string(mZip64EndofCDOffset), to_string(mNumTotalDisks));
}
bool cCDFileHeader::ParseRaw(uint8_t* pBuffer, uint32_t& nNumBytesProcessed)
{
mCDTag = *((uint32_t*)pBuffer);
if (mCDTag != kZipCDTag)
{
cout << "Couldn't parse CD Header Tag\n";
return false;
}
mVersionMadeBy = *((uint16_t*)(pBuffer + 4));
mMinVersionToExtract = *((uint16_t*)(pBuffer + 6));
mGeneralPurposeBitFlag = *((uint16_t*)(pBuffer + 8));
mCompressionMethod = *((uint16_t*)(pBuffer + 10));
mLastModificationTime = *((uint16_t*)(pBuffer + 12));
mLastModificationDate = *((uint16_t*)(pBuffer + 14));
mCRC32 = *((uint32_t*)(pBuffer + 16));
mCompressedSize = *((uint32_t*)(pBuffer + 20));
mUncompressedSize = *((uint32_t*)(pBuffer + 24));
mFilenameLength = *((uint16_t*)(pBuffer + 28));
mExtraFieldLength = *((uint16_t*)(pBuffer + 30));
mFileCommentLength = *((uint16_t*)(pBuffer + 32));
mDiskNumFileStart = *((uint16_t*)(pBuffer + 34));
mInternalFileAttributes = *((uint16_t*)(pBuffer + 36));
mExternalFileAttributes = *((uint32_t*)(pBuffer + 38));
mLocalFileHeaderOffset = *((uint32_t*)(pBuffer + 42));
mFileName.assign((char*)pBuffer + kStaticDataSize, mFilenameLength);
mFileComment.assign((char*)pBuffer + kStaticDataSize + mFilenameLength + mExtraFieldLength, mFileCommentLength);
uint8_t* pSearch = pBuffer + kStaticDataSize + mFilenameLength;
ParseExtendedFields(pSearch, mExtraFieldLength, mExtensibleFieldList);
uint8_t* pExtraFieldEnd = pSearch + mExtraFieldLength;
while (pSearch < pExtraFieldEnd)
{
uint16_t nTag = *((uint16_t*)pSearch);
if (nTag == kZipExtraFieldZip64ExtendedInfoTag)
{
pSearch += sizeof(uint16_t); // skip the 16 bit tag
// uint16_t nSizeOfExtendedField = *((uint16_t*)pSearch);
pSearch += sizeof(uint16_t); // skip the size of this extended field
if (mUncompressedSize == 0xffffffff)
{
mUncompressedSize = *((uint64_t*)(pSearch));
pSearch += sizeof(uint64_t);
}
if (mCompressedSize == 0xffffffff)
{
mCompressedSize = *((uint64_t*)(pSearch));
pSearch += sizeof(uint64_t);
}
if (mLocalFileHeaderOffset == 0xffffffff)
{
mLocalFileHeaderOffset = *((uint64_t*)(pSearch));
pSearch += sizeof(uint64_t);
}
break;
}
else if (nTag == kZipExtraFieldUnicodePathTag)
{
cout << "found unicode path tag";
// TBD. Add unicode path parsing/handling
}
else if (nTag == kZipExtraFieldUnicodeCommentTag)
{
cout << "found unicode comment tag";
// TBD. Add unicode comment parsing/handling
}
uint16_t nFieldBlock = *((uint16_t*)(pSearch + sizeof(uint16_t)));
pSearch += (nFieldBlock + sizeof(uint32_t)); // past the tag
}
nNumBytesProcessed = 46 + mFilenameLength + mExtraFieldLength + mFileCommentLength;
return true;
}
bool cCDFileHeader::Write(cZZFile& file)
{
bool bSuccess = true;
uint32_t nWritten = 0;
bSuccess &= file.Write(cZZFile::ZZFILE_SEEK_END, sizeof(uint32_t), (uint8_t*)&mCDTag, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mVersionMadeBy, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mMinVersionToExtract, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mGeneralPurposeBitFlag, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mCompressionMethod, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mLastModificationTime, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mLastModificationDate, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&mCRC32, nWritten);
uint32_t nNegOne = (uint32_t)-1;
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&nNegOne, nWritten); // compressed size
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&nNegOne, nWritten); // uncompressed size
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mFilenameLength, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&kExtraFieldLength, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mFileCommentLength, nWritten);
uint16_t n16NegOne = 0xffff;
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&n16NegOne, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&mInternalFileAttributes, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&mExternalFileAttributes, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&nNegOne, nWritten); // local file header offset
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, mFilenameLength, (uint8_t*)mFileName.c_str(), nWritten);
// now write the extra field
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&kZipExtraFieldZip64ExtendedInfoTag, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint16_t), (uint8_t*)&kExtendedFieldLength, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mUncompressedSize, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mCompressedSize, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint64_t), (uint8_t*)&mLocalFileHeaderOffset, nWritten);
uint32_t nDiskNum = mDiskNumFileStart;
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, sizeof(uint32_t), (uint8_t*)&nDiskNum, nWritten);
bSuccess &= file.Write(cZZFile::ZZFILE_NO_SEEK, mFileCommentLength, (uint8_t*)mFileComment.c_str(), nWritten);
if (!bSuccess)
{
cout << "cCDFileHeader::Write - Failure to write CDFileHeader!\n";
return false;
}
return true;
}
uint64_t cCDFileHeader::Size()
{
return kStaticDataSize + mFilenameLength + mFileCommentLength + kExtraFieldLength;
}
string cCDFileHeader::FieldNames(eToStringFormat format)
{
return FormatStrings(format, "FileName", "CompressedSize", "UncompressedSize", "LocalFileHeaderOffset", "CRC32", "VersionMadeBy", "MinVersionToExtract", "GeneralPurposeBitFlag", "CompressionMethod", "LastModificationTime", "LastModificationDate", "FilenameLength", "ExtraFieldLength", "FileCommentLength", "DiskNumFileStart", "InternalFileAttributes", "ExternalFileAttributes", "ExtraField", "FileComment");
}
string cCDFileHeader::ToString(eToStringFormat format)
{
string sExtendedFields;
for (tExtensibleFieldList::iterator it = mExtensibleFieldList.begin(); it != mExtensibleFieldList.end(); it++)
sExtendedFields += (*it).ToString() + " ";
return FormatStrings(format, string("\"" + mFileName + "\""),
to_string(mCompressedSize),
to_string(mUncompressedSize),
to_string(mLocalFileHeaderOffset),
int_to_hex_string(mCRC32),
to_string(mVersionMadeBy),
to_string(mMinVersionToExtract),
to_string(mGeneralPurposeBitFlag),
to_string(mCompressionMethod),
to_string(mLastModificationTime),
to_string(mLastModificationDate),
to_string(mFilenameLength),
to_string(mExtraFieldLength),
to_string(mFileCommentLength),
to_string(mDiskNumFileStart),
to_string(mInternalFileAttributes),
to_string(mExternalFileAttributes),
sExtendedFields,
string("\"" + mFileComment + "\""));
}
cZipCD::cZipCD()
{
mbInitted = false;
mbIsZip64 = false;
}
cZipCD::~cZipCD()
{
}
bool cZipCD::Init(cZZFile& zzFile)
{
// Find the end of CD Record
const int32_t kMaxSizeOfCDRec = 1024;
std::streampos nZipFileSize = zzFile.GetFileSize();
int32_t nReadSizeofCDRec = kMaxSizeOfCDRec;
if (nReadSizeofCDRec > nZipFileSize)
nReadSizeofCDRec = (int32_t)nZipFileSize;
int64_t nSeekPosition = nZipFileSize - std::streampos(nReadSizeofCDRec);
uint8_t* pBuf = new uint8_t[nReadSizeofCDRec]; // Should be more than enough space for this record
// fill the buffer with the end of the zip file
uint32_t nBytesRead = 0;
if (!zzFile.Read(nSeekPosition, nReadSizeofCDRec, pBuf, nBytesRead))
{
delete[] pBuf;
cout << "Failed to read " << nReadSizeofCDRec << " bytes for End of CD Record.\n";
return false;
}
bool bFoundEndOfCDRecord = false;
for (int32_t nSeek = nReadSizeofCDRec - sizeof(kZipEndofCDTag); nSeek >= 0; nSeek--)
{
uint32_t* pTag = (uint32_t*)(pBuf + nSeek);
if (*pTag == kZipEndofCDTag)
{
// Found a 32 bit tag
uint32_t nNumBytesProcessed = 0;
mEndOfCDRecord.ParseRaw(pBuf + nSeek, nNumBytesProcessed);
bFoundEndOfCDRecord = true;
break;
}
}
if (!bFoundEndOfCDRecord)
{
delete[] pBuf;
cout << "Couldn't find End of CD Tag\n";
return false;
}
// Now look for ZiP64 End of CD Directory Locator
bool bFoundZip64EndOfCDLocator = false;
for (int32_t nSeek = nReadSizeofCDRec - sizeof(kZip64EndofCDLocatorTag); nSeek >= 0; nSeek--)
{
uint32_t* pTag = (uint32_t*)(pBuf + nSeek);
if (*pTag == kZip64EndofCDLocatorTag)
{
// Found
// cout << "Found kZip64EndofCDLocatorTag.\n";
uint32_t nNumBytesProcessed = 0;
mZip64EndOfCDLocator.ParseRaw(pBuf + nSeek, nNumBytesProcessed);
bFoundZip64EndOfCDLocator = true;
break;
}
}
// Found a Zip64 locator, now read zip64 end of CD record
if (bFoundZip64EndOfCDLocator)
{
bool bFoundZip64EndOfCDRecord = false;
for (int32_t nSeek = nReadSizeofCDRec - sizeof(kZip64EndofCDTag); nSeek >= 0; nSeek--)
{
uint32_t* pTag = (uint32_t*)(pBuf + nSeek);
if (*pTag == kZip64EndofCDTag)
{
// cout << "Found kZip64EndofCDTag.\n";
uint32_t nNumBytesProcessed = 0;
mZip64EndOfCDRecord.ParseRaw(pBuf + nSeek, nNumBytesProcessed);
bFoundZip64EndOfCDRecord = true;
mbIsZip64 = true; // Treat archive as zip64
break;
}
}
}
delete[] pBuf;
uint64_t nOffsetOfCD = mEndOfCDRecord.mCDStartOffset;
uint64_t nCDBytes = mEndOfCDRecord.mNumBytesOfCD; // central directory
uint64_t nCDRecords = mEndOfCDRecord.mNumTotalRecords;
if (mbIsZip64)
{
nOffsetOfCD = mZip64EndOfCDRecord.mCDStartOffset;
nCDBytes = (uint32_t)mZip64EndOfCDRecord.mNumBytesOfCD;
nCDRecords = mZip64EndOfCDRecord.mNumTotalRecords;
}
const uint32_t kMaxReasonableCDBytes = 64 * 1024 * 1024; // 64 megs ought to be far far beyond anything we'd ever encounter
if ((uint32_t)nCDBytes > kMaxReasonableCDBytes)
{
cout << "CD Size read as " << nCDBytes << " which exceeds the maximum accepted of " << kMaxReasonableCDBytes << ". If this assumpiton was unreasonable then the author of this code humbly apologizes.\n";
return false;
}
///////////////////////
pBuf = new uint8_t[(uint32_t)nCDBytes];
// fill the buffer with the raw CD data
if (!zzFile.Read(nOffsetOfCD, (uint32_t)nCDBytes, pBuf, nBytesRead))
{
delete[] pBuf;
cout << "Failed to read " << nCDBytes << " bytes for the CD.\n";
return false;
}
int32_t nBufOffset = 0;
for (int32_t i = 0; i < nCDRecords; i++)
{
cCDFileHeader fileHeader;
uint32_t nNumBytesProcessed = 0;
fileHeader.ParseRaw(pBuf + nBufOffset, nNumBytesProcessed);
// cout << "read header for file \"" << fileHeader.mFileName << "\" at offset " << (uint32_t) (nBufOffset + nOffsetOfCD) << fileHeader.ToString() << "\n";
nBufOffset += nNumBytesProcessed;
mCDFileHeaderList.push_back(fileHeader);
}
delete[] pBuf;
mbInitted = true;
return true;
}
uint64_t cZipCD::GetNumTotalFiles()
{
uint64_t nTotal = 0;
for (tCDFileHeaderList::iterator it = mCDFileHeaderList.begin(); it != mCDFileHeaderList.end(); it++)
{
cCDFileHeader& file = *it;
if (file.mUncompressedSize > 0)
nTotal++;
}
return nTotal;
}
uint64_t cZipCD::GetNumTotalFolders()
{
uint64_t nTotal = 0;
for (tCDFileHeaderList::iterator it = mCDFileHeaderList.begin(); it != mCDFileHeaderList.end(); it++)
{
cCDFileHeader& file = *it;
if (file.mUncompressedSize == 0 && file.mCompressedSize == 0)
nTotal++;
}
return nTotal;
}
uint64_t cZipCD::GetTotalCompressedBytes()
{
uint64_t nTotal = 0;
for (tCDFileHeaderList::iterator it = mCDFileHeaderList.begin(); it != mCDFileHeaderList.end(); it++)
{
cCDFileHeader& file = *it;
nTotal += file.mCompressedSize;
}
return nTotal;
}
uint64_t cZipCD::GetTotalUncompressedBytes()
{
uint64_t nTotal = 0;
for (tCDFileHeaderList::iterator it = mCDFileHeaderList.begin(); it != mCDFileHeaderList.end(); it++)
{
cCDFileHeader& file = *it;
nTotal += file.mUncompressedSize;
}
return nTotal;
}
bool cZipCD::ComputeCDRecords(uint64_t nStartOfCDOffset)
{
// Only supporting single "disk" (for now?)
mEndOfCDRecord.mComment = "Test comment!";
mEndOfCDRecord.mNumBytesOfComment = 13;
mEndOfCDRecord.mNumBytesOfCD = (uint32_t)Size();
mEndOfCDRecord.mNumTotalRecords = (uint16_t)mCDFileHeaderList.size();
mEndOfCDRecord.mNumCDRecordsThisDisk = mEndOfCDRecord.mNumTotalRecords;
mEndOfCDRecord.mCDStartOffset = 0xffffffff;
mZip64EndOfCDRecord.mSizeOfZiP64EndOfCDRecord = mZip64EndOfCDRecord.Size();
mZip64EndOfCDRecord.mNumCDRecordsThisDisk = mCDFileHeaderList.size();
mZip64EndOfCDRecord.mNumTotalRecords = mCDFileHeaderList.size();
mZip64EndOfCDRecord.mNumBytesOfCD = Size();
mZip64EndOfCDRecord.mCDStartOffset = nStartOfCDOffset;
return true;
}
uint64_t cZipCD::Size()
{
uint64_t nSize = 0;
for (tCDFileHeaderList::iterator it = mCDFileHeaderList.begin(); it != mCDFileHeaderList.end(); it++)
{
cCDFileHeader& cdFileHeader = *it;
nSize += cdFileHeader.Size();
}
nSize += mEndOfCDRecord.Size();
nSize += mZip64EndOfCDLocator.Size();
nSize += mZip64EndOfCDRecord.Size();
return nSize;
}
void cZipCD::DumpCD(std::ostream& out, const string& sPattern, bool bVerbose, eToStringFormat format)
{
int32_t nIndex = 0;
if (bVerbose)
{
out << NextLine(format);
out << "Package Central Directory";
out << NextLine(format);
}
out << NextLine(format);
uint32_t nPatternMatchingFiles = 0;
// CD Entries
if (bVerbose)
{
out << NextLine(format);
out << "List of Files";
}
if (format == kHTML)
out << "<table border='1'>\n";
if (bVerbose)
{
out << cCDFileHeader::FieldNames(format).c_str();
out << NextLine(format);
}
for (tCDFileHeaderList::iterator it = mCDFileHeaderList.begin(); it != mCDFileHeaderList.end(); it++)
{
cCDFileHeader& cdFileHeader = *it;
if (FNMatch(sPattern, cdFileHeader.mFileName.c_str()))
{
nPatternMatchingFiles++;
if (bVerbose)
out << cdFileHeader.ToString(format).c_str();
else
out << cdFileHeader.mFileName.c_str() << NextLine(format);
}
nIndex++;
}
if (format == kHTML)
out << "</table>\n";
out << NextLine(format);
if (bVerbose)
{
// CD Stats
if (format == kHTML)
out << "<table border='1'>\n";
out << FormatStrings(format, "Total Files", "Total Folders", "Total Compressed Size", "Total Uncompressed Size", "Compression Ratio");
out << FormatStrings(format, to_string(GetNumTotalFiles()), to_string(GetNumTotalFolders()), to_string(GetTotalCompressedBytes()), to_string(GetTotalUncompressedBytes()), to_string((double)GetTotalCompressedBytes() / (double)GetTotalUncompressedBytes()));
if (format == kHTML)
out << "</table>\n";
}
// If a pattern was specified then provide stats
if (!sPattern.empty())
{
out << "Found " << nPatternMatchingFiles << " out of " << GetNumTotalFiles() + GetNumTotalFolders() << " matching pattern: \"" << sPattern.c_str() << "\"\n";
}
out << NextLine(format);
}
bool cZipCD::GetFileHeader(const string& sFilename, cCDFileHeader& fileHeader)
{
if (!mbInitted)
return false;
for (tCDFileHeaderList::iterator it = mCDFileHeaderList.begin(); it != mCDFileHeaderList.end(); it++)
{
cCDFileHeader& cdFileHeader = *it;
if (cdFileHeader.mFileName == sFilename)
{
fileHeader = *it;
return true;
}
}
return false;
}
bool cZipCD::Write(cZZFile& file)
{
bool bSuccess = true;
for (tCDFileHeaderList::iterator it = mCDFileHeaderList.begin(); it != mCDFileHeaderList.end(); it++)
{
cCDFileHeader& cdFileHeader = *it;
//cout << "writing header for file \"" << cdFileHeader.mFileName << "\" at offset " << file.tellg() << cdFileHeader.ToString() << "\n";
bSuccess &= cdFileHeader.Write(file);
}
// Write Zip64 End of CD Record
// but first record the offset to it
//mZip64EndOfCDLocator.mZip64EndofCDOffset = file.tellg();
mZip64EndOfCDLocator.mZip64EndofCDOffset = file.GetFileSize();
bSuccess &= mZip64EndOfCDRecord.Write(file);
// Write Zip64 End of CD Locator
bSuccess &= mZip64EndOfCDLocator.Write(file);
// Write End of CD Record
bSuccess &= mEndOfCDRecord.Write(file);
return bSuccess;
}
|
8c375977760a73846b8e3d886d92f0abeb2933ef | f42f8c79eb74e97135903cedca042a4cdd35bce3 | /search_server.cpp | 45bab4c9a15cbcdd977aad4eb01bbcdad93678e2 | [] | no_license | VorkovN/coursera-red-belt | 25f136475631541208dbb87a9026410cb7e32ced | 645798ef52b1b0670739adfc45725a9d6569cff0 | refs/heads/master | 2022-12-09T11:15:13.559222 | 2020-09-18T15:02:43 | 2020-09-18T15:02:43 | 296,352,710 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,961 | cpp | search_server.cpp | #include "search_server.h"
#include "iterator_range.h"
#include <algorithm>
#include <iterator>
#include <sstream>
#include <iostream>
#include <numeric>
vector<string> SplitIntoWords(const string &line) {
istringstream words_input(line);
return {istream_iterator<string>(words_input), istream_iterator<string>()};
}
SearchServer::SearchServer(istream &document_input) {
UpdateDocumentBase(document_input);
}
void SearchServer::UpdateDocumentBase(istream &document_input) {
InvertedIndex new_index;
for (string current_document; getline(document_input, current_document);) {
new_index.Add(current_document);
}
index = move(new_index);
}
void SearchServer::AddQueriesStream(istream &query_input, ostream &search_results_output) {
const size_t deq_size = index.GetDocument().size();
for (string current_query; getline(query_input, current_query);) {
const auto words = SplitIntoWords(current_query);
vector<size_t> docid_count(deq_size, 0);
for (const auto &word : words) {
for (const auto&[docid, hit_count] : index.Lookup(word)) {
docid_count[docid] += hit_count;
}
}
int results_count = 5;
vector<pair<size_t, size_t>> search_results(5, make_pair(0, 0));
for (int i = 0; i < 5; ++i) {
pair<size_t, size_t> &result = search_results[i];
int kostylJ = 0;
for (int j = 0; j < deq_size; ++j) {
size_t &count = docid_count[j];
if (result.second < count) {
result = {j, count};
kostylJ = j;
}
}
docid_count[kostylJ] = 0;
if (result.second == 0) {
results_count = i;
break;
}
}
search_results_output << current_query << ':';
for (const auto&[docid, hitcount] : Head(search_results, results_count)) {
search_results_output << " {"
<< "docid: " << docid << ", "
<< "hitcount: " << hitcount << '}';
}
search_results_output << "\n";
}
}
void InvertedIndex::Add(const string &document) {
docs.push_back(document);
const size_t docid = docs.size() - 1;
map<string, pair<size_t, size_t>> vsp_map;
for (const auto &word : SplitIntoWords(document)) {
if (vsp_map.find(word) == vsp_map.end())
vsp_map[word] = {docid, 0};
vsp_map[word].first = docid;
vsp_map[word].second++;
}
for (auto&[word, pair]: vsp_map) {
index[word].push_back(pair);
}
}
vector<pair<size_t, size_t>> InvertedIndex::Lookup(const string &word) const {
auto it = index.find(word);
if (it != index.end())
return it->second;
return {};
} |
03fc6b832cbc6bbed02ca0a628bd3f3bd783a7c8 | 9ca6885d197aaf6869e2080901b361b034e4cc37 | /CondTools/RPC/src/RPCTempSH.cc | 2463ee4607e0d9545797d863d4c9b134687e7cd6 | [] | no_license | ktf/cmssw-migration | 153ff14346b20086f908a370029aa96575a2c51a | 583340dd03481dff673a52a2075c8bb46fa22ac6 | refs/heads/master | 2020-07-25T15:37:45.528173 | 2013-07-11T04:54:56 | 2013-07-11T04:54:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,283 | cc | RPCTempSH.cc | /*
* See headers for a description
*
* \author D. Pagano - Dip. Fis. Nucl. e Teo. & INFN Pavia
*/
#include "CondTools/RPC/interface/RPCTempSH.h"
#include<sstream>
#include<iostream>
popcon::RpcDataT::RpcDataT(const edm::ParameterSet& pset) :
m_name(pset.getUntrackedParameter<std::string>("name","RpcData")),
host(pset.getUntrackedParameter<std::string>("host", "source db host")),
user(pset.getUntrackedParameter<std::string>("user", "source username")),
passw(pset.getUntrackedParameter<std::string>("passw", "source password")),
m_first(pset.getUntrackedParameter<bool>("first",false)),
m_since(pset.getUntrackedParameter<unsigned long long>("since",1)),
m_range(pset.getUntrackedParameter<unsigned long long>("range",72000)){
}
popcon::RpcDataT::~RpcDataT()
{
}
void popcon::RpcDataT::getNewObjects() {
std::cout << "------- " << m_name << " - > getNewObjects\n"
<< "got offlineInfo "<< tagInfo().name
<< ", size " << tagInfo().size << ", last object valid since "
<< tagInfo().lastInterval.first << " token "
<< tagInfo().lastPayloadToken << std::endl;
std::cout << " ------ last entry info regarding the payload (if existing): "
<< logDBEntry().usertext << "last record with the correct tag has been written in the db: "
<< logDBEntry().destinationDB << std::endl;
// Get from the logDBEntry the till unix time query and the number of values stored
std::stringstream is;
std::string a = logDBEntry().usertext;
unsigned int l = a.find('>');
unsigned int preTill;
if (l < a.size()){
is <<a.substr(l+3,a.npos);
std::string b1,b2;
unsigned int nVals;
is >>b1>>nVals>>b2>>preTill;
std::cout <<" Unix Time of the Prev Till "<<preTill<<std::endl;
}else{
std::cout <<" No infos from usertext in logDB"<<std::endl;
}
if (!m_first) {
m_since = preTill;
}
unsigned int m_till = m_since + m_range;
std::cout << std::endl << "=============================================" << std::endl;
std::cout << std::endl << "================ TEMPERATURE ==============" << std::endl;
std::cout << std::endl << "=============================================" << std::endl << std::endl;
std::cout << ">> Range mode [" << m_since << ", " << m_till << "]" << std::endl;
std::cout << std::endl << "=============================================" << std::endl << std::endl;
RPCFw caen ( host, user, passw );
std::vector<RPCObTemp::T_Item> Tcheck;
Tcheck = caen.createT(m_since, m_till);
Tdata = new RPCObTemp();
RPCObTemp::T_Item Tfill;
std::vector<RPCObTemp::T_Item>::iterator Tit;
for(Tit = Tcheck.begin(); Tit != Tcheck.end(); Tit++){
Tfill = *(Tit);
Tdata->ObTemp_rpc.push_back(Tfill);
}
std::cout << " >> Final object size: " << Tdata->ObTemp_rpc.size() << std::endl;
if (Tdata->ObTemp_rpc.size() == 0) {
std::cout << "NO DATA TO BE STORED" << std::endl;
}
edm::TimeValue_t daqtime=0LL;
daqtime=m_since;
daqtime=(daqtime<<32);
std::cout << "===> New IOV: since is = " << daqtime << std::endl;
m_to_transfer.push_back(std::make_pair((RPCObTemp*)Tdata,daqtime));
std::stringstream os;
os<<"\n-->> NumberOfValue "<<Tdata->ObTemp_rpc.size()<<" until "<<m_till;
m_userTextLog=os.str();
}
|
a80c9854cb51edc7e4409931ea596bc5b80a2791 | 4d24cffbff8f60b00cd1780a96a12626399d1df8 | /text-justification.cc | 3d09cbf29169411608a1cf92f3dac0907e9f5fe9 | [
"MIT"
] | permissive | tyrowang/CC | a37a4d4925952f8b11b810f8cb47863b4a277a06 | 9be3602a40567187ee27eb744773f8092c36b6b6 | refs/heads/master | 2021-01-10T00:53:10.338843 | 2014-08-18T02:50:35 | 2014-08-18T02:50:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,113 | cc | text-justification.cc | class Solution {
public:
string cline(vector<string> &words,int left,int wordNum, int L){
string line="";
string space="";
int charNum=0;
for(int i=left;i<left+wordNum;i++){
charNum+=words[i].size();
}
if(left+wordNum==words.size()){
line=words[left];
for(int i=left+1;i<left+wordNum;i++){
line+=(" "+words[i]);
}
int spaceNum=L-line.size();
while(spaceNum>0){space+=" ";spaceNum--;}
line+=space;
return line;
}
else if(wordNum==1){
int spaceNum=L-charNum;
while(spaceNum>0){space+=" ";spaceNum--;}
return words[left]+space;
}else{
int remainder=(L-charNum)%(wordNum-1);
int spaceNum=(L-charNum-remainder)/(wordNum-1);
while(spaceNum>0){space+=" ";spaceNum--;}
line=words[left];
if(remainder==0){
for(int i=left+1;i<left+wordNum;i++){
line+=(space+words[i]);
}
}else{
for(int i=left+1;i<left+wordNum;i++){
if(remainder>0){
line+=(space+" "+words[i]);
remainder--;
}else line+=(space+words[i]);
}
}
return line;
}
}
vector<string> fullJustify(vector<string> &words, int L) {
int left=0;
int charNumWithinNextWord=words[0].size();
int n=charNumWithinNextWord;
vector<string> ret;
int i;
for(i=1;i<words.size();i++){
n=charNumWithinNextWord;
charNumWithinNextWord=n+words[i].size()+1;
if(charNumWithinNextWord>L){
string line=cline(words,left,i-left,L);
ret.push_back(line);
left=i;
charNumWithinNextWord=words[i].size();
}
}
string line=cline(words,left,i-left,L);
ret.push_back(line);
return ret;
}
}; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.