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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1a8be61d0620585dbe0bf8dc6ee5e753e2d2aa9b | 7503734fc80074163aa112162f5dbc00301adc85 | /apps/dg_test/Argmax.h | b74fa72f95f181fb5398b6b4680abc5cd7c1ec5d | [
"MIT"
] | permissive | streamhsa/MIVisionX | f725315299771409dc0300e02de53e9922e07135 | 0d0e927d8fbfdce0305b1158bfb24903ae275f99 | refs/heads/master | 2020-08-25T00:30:10.509581 | 2019-10-15T23:56:10 | 2019-10-15T23:56:10 | 216,934,241 | 0 | 0 | MIT | 2019-10-23T00:28:51 | 2019-10-23T00:28:51 | null | UTF-8 | C++ | false | false | 1,458 | h | Argmax.h | #pragma once
#include <vector>
#include <fstream>
/**
* Utility class for reading the tensor file and argmax it against the label file
*/
class Argmax
{
public:
Argmax(const char* fileName, const std::string labelName, const std::string tagName);
~Argmax();
/**
* Caculate the index number with the maximum probability
*/
void setIndex (const std::vector<float> &vec);
/**
* Get the current index
*/
int getIndex ();
/**
* Get the size of the label file
*/
int getLabelSize();
/**
* Get the size of the label file
*/
int getTagSize();
/**
* Prints out the result
*/
void printResult(const std::vector<std::string> &list, const std::vector<std::string> &tag);
/**
* Converts the text file to the vector
*/
std::vector<std::string> txtToVector(std::ifstream &textFile);
/**
* Run the argmax
*/
void run();
private:
/**
* The index of the maximum probability will be stored
*/
int mIndex;
/**
* The count of a current image
*/
static int mCount;
/**
* File name to open and read the tensor object
*/
const char* mFileName;
/**
* File stream to open and read the label text file
*/
std::vector<std::string> mLabel;
/**
* File stream to open and read the tag text file
*/
std::vector<std::string> mTag;
}; |
5793f9e5b94069cc697c6ec5eeeccd56a170fff6 | 3dbfb18d5953ffd135aebcf03ed004327aad9b8b | /cpp/templated_struct_static_member_ext_affectation.cpp | cf5548cb2ca119bd3132fea4cd692468bdea11cb | [] | no_license | ahonorat/sand-box | 7d7d2680c0a47c11d63f464fce7bb5155dd13268 | 60db33f5af1b8b52d4c1ecfe85b91f062de1f8b7 | refs/heads/master | 2023-05-11T18:33:53.920214 | 2023-05-08T12:19:01 | 2023-05-08T12:19:01 | 52,306,537 | 1 | 0 | null | 2022-07-01T22:17:22 | 2016-02-22T21:17:48 | C | UTF-8 | C++ | false | false | 329 | cpp | templated_struct_static_member_ext_affectation.cpp | #include <iostream>
using namespace std;
template<typename T>
struct A {
static int id;
};
// static templated struct parameter
// must be declared globally once
template<typename T>
int A<T>::id = 2;
void init() {
A<int>::id = 3;
}
int main(int argc, char** argv) {
init();
cout << A<int>::id << endl;
return 0;
}
|
253cc20a64fb8d2678482577e765afa0fce1ffb6 | 8c7773dae31e7fd97fd964dfa1c0a584db3cb4a1 | /NetworkLib/SocketLib/udp_sock.h | 644cb451f45b7dc5be9e72498dec75d3c139d3fe | [
"MIT"
] | permissive | BaldwinJoshua/NRMC_ControlServer | d8afa93073412b7e373228e94e42a0f41d2f60fa | 8a12361eae8ac5c2d95dcf4f3f4a2f0f3127268f | refs/heads/master | 2021-01-22T13:02:49.145113 | 2015-12-08T00:15:25 | 2015-12-08T00:15:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,049 | h | udp_sock.h | #ifndef UDP_SOCK_H
#define UDP_SOCK_H
#include "networkinterface.h"
#include "notimplementedexception.h"
namespace Sockets
{
class UDP_Sock: public NetworkInterface {
// Associations
// Attributes
private:
int port;
struct sockaddr_in defaultAddr;
int sct;
exception lastException;
pthread_t rcvThread;
void (*handler)(struct sockaddr_in&, char*);
volatile bool rx;
// Operations
public:
exception getLastException ( );
void clearError ( );
UDP_Sock ( int port, bool multicast );
UDP_Sock ( int port, int timeout, bool multicast );
UDP_Sock ( const UDP_Sock& socket );
~UDP_Sock ( );
void close ( );
bool connect ( string addr );
bool send ( char* msg );
bool send ( char* msg, string ip );
send ( char* msg, const struct sockaddr_in& addr );
bool startReceive ( void (*handler)(struct sockaddr_in&, char*) );
bool stopReceive ( );
char* receive ( );
protected:
void receive ( void (*handler)(struct sockaddr_in, char*) );
};
}
#endif
|
db2d955f7b6ac94347284b510782f3a45c1f8eee | 7e8cdd60d965ecb77a7ba46f9fcc096a32f17fe4 | /CGame7/Headers/Game.h | 9f5ae438b6e1ced3b4ca97e53a2b731030b79d77 | [] | no_license | themagpimag/magpi-issue71 | a58ccd6b8178cfddb1016433e27e661c4c982881 | 527814412a005ee899d928589c232817db9314f1 | refs/heads/master | 2021-06-06T03:00:19.918864 | 2018-07-26T13:13:11 | 2018-07-26T13:13:11 | 139,009,639 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 11,151 | h | Game.h | #pragma once
#include "OGL.h"
#include "SimpleObj.h"
#include <vector> // a new thing to add, vector is a kind of
#define SOLID 0b1
#define LADDER 0b10
#define WATER 0b100
#define METAL 0b1000
#define EARTH 0b10000
class Game
{
public:
Game(); //standard constructor
~Game(); //standard destructor
//list the functions we want to have (called methods in C++)
void Update();
static std::vector<SimpleObj*> MyObjects;
// this time we've given the Attributes bit values which allows us to make an attribute have multiple properties
int Attributes[16] =
{
0,
//0 the empty background
SOLID,
//1
SOLID,
//2
SOLID,
//3
METAL + SOLID,
//4 Look how we can combine attributes
WATER,
//5
WATER,
//6
SOLID,
//7
SOLID,
//8
SOLID,
//9
SOLID,
//10
SOLID,
//11
0,
//12 this is the background brick, we don't want to interact at all with this
SOLID,
//13
LADDER,
//14 // ladder
SOLID //15
};
// this is a new map, but the principles are he same, though we will test a tiles attributes not the tile value
int Map2[40][64] = {
{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 },
{ 4, 0, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 },
{ 4, 0, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 },
{ 4, 0, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 },
{ 4, 0, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 7, 7, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 },
{ 4, 0, 0, 2, 2, 12, 12, 2, 2, 12, 12, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 },
{ 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 2, 2, 2, 2, 2, 2, 2, 12, 12, 12, 11, 9, 9, 9, 9, 9, 9, 9, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 2, 2, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 8, 8, 8, 3, 3, 3, 3, 3, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 2, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, 1, 1, 12, 12, 1, 1, 1, 12, 12, 1, 1, 1, 12, 12, 1, 1, 1, 1, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 2, 2, 2, 2, 2, 2, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 2, 2, 2, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4 },
{ 4, 12, 12, 12, 12, 12, 12, 12, 12, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 13, 13, 13, 13, 13, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4 },
{ 4, 12, 12, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 12, 13, 13, 13, 13, 13, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4 },
{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 13, 13, 13, 13, 13, 6, 6, 6, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 4 },
{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 },
};
OGL OGLES;
//this is just an example of how we can now create an example of our new type, we could also initialise
//its contents here but its best to do that a different way.
simpleVec2 TestVector2;
};
|
570200ea60fc8aeb54059fe3b406ba98681e0a20 | 35d5630340e959f4a45d9073c0f53110b2816c57 | /foo/main.cpp | 24871190e611e0251108dff9327b514708bca8b4 | [] | no_license | app0pi/csci262 | 8eca986bf5f04b0f34c9673ab4f540dfce7d8897 | 3672daebda68b5915d41faa5d55de46b57c52bcd | refs/heads/master | 2021-04-21T17:37:21.555529 | 2020-03-24T19:40:16 | 2020-03-24T19:40:16 | 249,800,596 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 497 | cpp | main.cpp | // find example
#include <iostream> // std::cout
#include <algorithm> // std::find
#include <vector> // std::vector
using namespace std;
int main () {
int myints[] = { 10, 20, 30, 40 };
vector<int> myvector (myints,myints+4);vector<int>::iterator it;
it = find (myvector.begin(), myvector.end(), 50);
if (it != myvector.end())
cout << "Element found in myvector: " << *it << '\n';
else
cout << "Element not found in myvector\n";
return 0;
} |
88d0a453d334a73e7be956ffa62d6b42d33debcb | fe50fca386dc79ff7ad75185903209f07bcdab30 | /Practice/merge_sort.cpp | 3ad0bf7cd33ca4f1117eadbed2fda0e29b4985ca | [] | no_license | sainiak009/cpp_practice_codes | a5163e146b2851d8d7342fb440b508ea315410ce | 5c4fb23678f1f664abccfc490e6484368023d60d | refs/heads/master | 2020-03-20T18:20:39.397907 | 2018-06-16T13:49:49 | 2018-06-16T13:49:49 | 137,583,722 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,064 | cpp | merge_sort.cpp | #include <iostream>
using namespace std;
void print_array(int arr[], int n){
for(int i=0;i<n;++i){
cout << arr[i] << " ";
}
}
//Merge two sorted parts of an array
int* myMerge(int arr[], int be, int en){
int mid = (be+en)/2;
int nLeft = mid-be+1;
int nRight = en-mid;
int* left = new int[nLeft];
int* right = new int[nRight];
for(int i=0; i<nLeft; ++i) left[i] = arr[be+i];
for(int j=0; j<nRight; ++j) right[j] = arr[mid+1+j];
int k=be;
int i = 0;
int j = 0;
while(i<nLeft && j<nRight){
if(left[i]<right[j]){
arr[k]=left[i];
++k;++i;
}else{
arr[k]=right[j];
++k;++j;
}
}
while(i<nLeft){
arr[k]=left[i];
++k;++i;
}
while(j<nRight){
arr[k]=right[j];
++k;++j;
}
delete [] left;
delete [] right;
}
void mergeSort(int arr[], int be, int en){
int mid = (be + en)/2;
if(be >= en){
return ;
}
mergeSort(arr, be, mid);
mergeSort(arr, mid+1, en);
myMerge(arr,be,en);
}
int main(){
int arr[100];
int n; cin >> n;
for(int i = 0; i<n ; i++) cin >> arr[i];
mergeSort(arr,0,n-1);
print_array(arr,n);
} |
8fefb01df814c0ae6362f90b55cc259e81b5cce8 | 56b7545ec3f1692d404663bcf530ad4bb2142524 | /FinalsProject/ZavrsniRad/Alpha/Skybox.h | 0c60966b7a71cb0352075a40c195ffd84e59507a | [] | no_license | UnrlGit/Zavrsni | 9d805e8442c5ea56529b2ae08b56e6cf1a8b0dd3 | 218a07b71c1a0ac9ca4ba84726a64000be87798e | refs/heads/master | 2020-04-27T09:43:56.365817 | 2019-03-06T23:52:10 | 2019-03-06T23:52:10 | 174,226,580 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 570 | h | Skybox.h | #ifndef SKYBOX_H
#define SKYBOX_H
#include <vector>
#include <string>
#include <GL\glew.h>
#include <GLM\glm.hpp>
#include <GLM\gtc\matrix_transform.hpp>
#include <GLM\gtc\type_ptr.hpp>
#include "StbImage.h"
#include "Mesh.h"
#include "Shader.h"
class Skybox
{
public:
Skybox();
Skybox(std::vector<std::string> faceLocations);
void RenderSkybox(glm::mat4 viewMatrix, glm::mat4 projectionMatrix);
~Skybox();
private:
Mesh * _skyboxMesh;
Shader * _skyboxShader;
GLuint _textureId;
GLuint _uniformProjection;
GLuint _uniformView;
};
#endif // !SKYBOX_H
|
dffc6d606e0b356c41a3ddf23914f4244f696254 | 016c6c021dcbf1d20f3d78d2066cafedc28b2847 | /CannotDetermineRoomDimensions.cpp | 7fc4cf4fe862bafa0702d712ea1c9f529711ebc4 | [] | no_license | andrew-monroe/EECS268_Lab03 | 3563eb52f40996943ee03671a1fb95e78f2c04c5 | d4d578655f65e0b1a51a1ee334309242367e2eb8 | refs/heads/master | 2021-01-13T10:15:37.598480 | 2016-09-30T04:42:05 | 2016-09-30T04:42:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 320 | cpp | CannotDetermineRoomDimensions.cpp | /**
* @file CannotDetermineRoomDimensions.cpp
* @author Andy Monroe
* @date 09-29-2016
* @brief Implementation file for CannotDetermineRoomDimensions exception
*/
#include "CannotDetermineRoomDimensions.h"
CannotDetermineRoomDimensions::CannotDetermineRoomDimensions(const char* msg):
std::runtime_error(msg)
{
}
|
448909080e213e9656b8e30e7c871b77cee8a6ed | 4a91b28db5b6132af0bcddeacb165e94ae0cf514 | /几何/凸包.cpp | 5406530316905dadc0a47aad51cf79ed66412b53 | [] | no_license | MinchaoLiang/Acm_Study | ef48433ba6f816292620d738d298b432ef3c13b1 | 386cdf31ace6b854f2747ec0038d5f030dc42434 | refs/heads/master | 2022-09-24T06:45:52.534166 | 2019-09-28T09:04:41 | 2019-09-28T09:04:41 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,871 | cpp | 凸包.cpp | #define eps 0.000001
class Point
{
public:
double x, y;
Point(double x = 0, double y = 0) :x(x), y(y) {}
Point operator + (Point a)
{
return Point(a.x + x, a.y + y);
}
Point operator - (Point a)
{
return Point(x - a.x, y - a.y);
}
bool operator < (const Point& a) const
{
if (x == a.x)
return y < a.y;
return x < a.x;
}
};
double cross(Point a, Point b)//叉积
{
return a.x * b.y - a.y * b.x;
}
double dot(Point a, Point b)//点积
{
return a.x * b.x + a.y * b.y;
}
bool isclock(Point p0, Point p1, Point p2)
{
Point a = p1 - p0;
Point b = p2 - p0;
if (cross(a, b) < -eps) return true;
return false;
}
double getDistance(Point a, Point b)
{
return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
}
typedef vector<Point> Polygon;
Polygon andrewScan(Polygon s)
{
Polygon u, l;
if (s.size() < 3) return s;
sort(s.begin(), s.end());
u.push_back(s[0]);
u.push_back(s[1]);
l.push_back(s[s.size() - 1]);
l.push_back(s[s.size() - 2]);
for (int i = 2; i < s.size(); i++)//构造凸包上部
{
for (int n = u.size(); n >= 2 && isclock(u[n - 2], u[n - 1], s[i]) != true; n--)
{
u.pop_back();
}
u.push_back(s[i]);
}
for (int i = s.size() - 3; i >= 0; i--)//构造凸包下部
{
for (int n = l.size(); n >= 2 && isclock(l[n - 2], l[n - 1], s[i]) != true; n--)
{
l.pop_back();
}
l.push_back(s[i]);
}
for (int i = 1; i < u.size() - 1; i++) l.push_back(u[i]);
return l;
}
int main()
{
int n;
scanf("%d", &n);
Polygon vec;
for (int i = 0;i < n;i++)
{
double a, b;
scanf("%lf%lf", &a, &b);
vec.push_back({ a,b });
}
vec = andrewScan(vec);
double ans = 0;
for (int i = 1;i < vec.size();i++)
{
ans += getDistance(vec[i - 1], vec[i]);
}
ans += getDistance(vec[vec.size() - 1], vec[0]);
printf("%.2lf", ans);
}
|
9b0080718030e0cfb0aaff3301a2123da4a953a0 | b6a0f512d8c7b1c5b998fb1dbd969872f758a3ce | /lab08/ex2/ex2.cpp | 0092f6124d51e8a2f621f0275fc41f55279e5bd1 | [] | no_license | gramanicu/labAPD | f759a6ab99d9ddfd4023f927e7ce67329d7a6727 | b4e7b89951c31756390e90bdcdd29e958ce96d3d | refs/heads/master | 2023-02-13T13:57:10.832768 | 2021-01-17T21:06:57 | 2021-01-17T21:06:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 671 | cpp | ex2.cpp | #include <mpi.h>
#include <iostream>
#include <stdlib.h>
#define ROOT 0
int main (int argc, char *argv[])
{
int numtasks, rank;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numtasks);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
int rand_num;
// Root process generates a random number.
// Broadcasts to all processes.
if(rank == ROOT) {
srand(time(NULL));
rand_num = rand() % 100 + 1;
std::cout << "Root process generated: " << rand_num << "\n";
}
MPI_Bcast(&rand_num, 1, MPI_INT, ROOT, MPI_COMM_WORLD);
printf("Process [%d], after broadcast %d.\n", rank, rand_num);
MPI_Finalize();
}
|
56441fac36aca62db3449dede13298daf11f49cc | fab8a98797381c176c6a66bff637e3e375f8bf13 | /CodeChef/April2020Long/5.cpp | 26260e568cc024404c1369878ecd8cb11ef9265e | [] | no_license | ujjawalgupta29/Coding-Stuff | 4e6bf69ca75f64ea9695d2aa065a14089bd5671a | 2cc0dd9a1baea8d541e6ceb5def96d932bf7e315 | refs/heads/master | 2021-05-17T17:13:52.690326 | 2020-10-12T13:04:47 | 2020-10-12T13:04:47 | 250,889,867 | 1 | 0 | null | 2020-10-12T13:04:48 | 2020-03-28T20:44:05 | C++ | UTF-8 | C++ | false | false | 1,475 | cpp | 5.cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define v(n) vector<int> v(n)
#define ifor(i, a, b) for(int i=a; i<b; i++)
#define dfor(i, a, b) for(int i=a; i>=b; i--)
typedef map<int, int> MI;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<vector<int>> VV;
static auto x = [](){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
return nullptr;
}();
ll findSubarraySum(vector<ll> &arr, ll sum)
{
unordered_map<ll, ll> prevSum;
ll n = arr.size();
ll res = 0;
ll currsum = 0;
for (ll i = 0; i < n; i++) {
currsum += arr[i];
if (currsum == sum)
res++;
if (prevSum.find(currsum - sum) != prevSum.end())
res += (prevSum[currsum - sum]);
prevSum[currsum]++;
}
return res;
}
int main()
{
//Code
int t;
cin >> t;
while(t--)
{
ll n;
cin >> n;
vector<ll> nums(n);
for(ll i=0; i<n; i++)
{
cin >> nums[i];
nums[i] = abs(nums[i]);
if(nums[i] % 2 != 0)
nums[i] = 0;
else if(nums[i] % 4 == 0)
nums[i] = 2;
else
{
nums[i] = 1;
}
}
ll total = (n * (n+1)) / 2;
cout << total - findSubarraySum(nums, 1) << endl;
}
return 0;
} |
28418ccf2ae6a3a817be52dd74cff0fd81d8c83a | 46bf9b44b61bc58fcd668f74f870e40473c49bb5 | /SeComLib/private_recommendations_data_packing/secure_comparison_client.h | 7ea733598749b3b7f8dd70d66b8d549c90c406af | [
"Apache-2.0"
] | permissive | tutzauel/BA | 48e4ce14ff5ce8dab073fe752c39659f22112564 | fe5ede5a4a788152e9afdb67f5f030cdd8fa5f78 | refs/heads/master | 2021-05-05T12:24:01.299629 | 2017-09-25T17:21:17 | 2017-09-25T17:21:17 | 104,764,189 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,394 | h | secure_comparison_client.h | /*
SeComLib
Copyright 2012-2013 TU Delft, Information Security & Privacy Lab (http://isplab.tudelft.nl/)
Contributors:
Inald Lagendijk (R.L.Lagendijk@TUDelft.nl)
Mihai Todor (todormihai@gmail.com)
Thijs Veugen (P.J.M.Veugen@tudelft.nl)
Zekeriya Erkin (z.erkin@tudelft.nl)
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.
*/
/**
@file private_recommendations_data_packing/secure_comparison_client.h
@brief Definition of class SecureComparisonClient.
@author Mihai Todor (todormihai@gmail.com)
*/
#ifndef SECURE_COMPARISON_CLIENT_HEADER_GUARD
#define SECURE_COMPARISON_CLIENT_HEADER_GUARD
//include our headers
#include "utils/config.h"
#include "core/big_integer.h"
#include "core/random_provider.h"
#include "core/paillier.h"
#include "core/dgk.h"
#include "private_recommendations_utils/dgk_comparison_client.h"
//include C++ headers
#include <deque>
namespace SeComLib {
using namespace Core;
using namespace PrivateRecommendationsUtils;
namespace PrivateRecommendationsDataPacking {
//forward-declare required classes
class SecureComparisonServer;
/**
@brief Secure Comparison Client
*/
class SecureComparisonClient {
public:
/// Constructor
SecureComparisonClient (const Paillier &paillierCryptoProvider, const Dgk &dgkCryptoProvider);
/// Destructor - void implementation
~SecureComparisonClient () {}
/// Computes @f$ z^{(i)} @f$
void UnpackZ (const Paillier::Ciphertext &z, const std::deque<BigInteger> &emptyBuckets, const size_t encryptedBucketsCount);
/// Specifies which @f$ z^{(i)} @f$ to send to the dgkComparisonClient for the current comparison
void SetZi (const size_t i) const;
/// Setter for this->secureComparisonServer
void SetServer (const std::shared_ptr<SecureComparisonServer> &secureComparisonServer);
/// Getter for this->dgkComparisonClient
const std::shared_ptr<DgkComparisonClient> &GetDgkComparisonClient () const;
/// Decrypts and prints a Paillier encrypted integer
void DebugPaillierEncryption (const Paillier::Ciphertext &input) const;
private:
/// Reference to the Paillier crypto provider
const Paillier &paillierCryptoProvider;
/// Reference to the DGK crypto provider
const Dgk &dgkCryptoProvider;
/// A reference to the SecureComparisonServer
std::shared_ptr<const SecureComparisonServer> secureComparisonServer;
/// A reference to the DgkComparisonClient
const std::shared_ptr<DgkComparisonClient> dgkComparisonClient;
/// @f$ z^{(i)} @f$
std::deque<BigInteger> zi;
/// Copy constructor - not implemented
SecureComparisonClient (SecureComparisonClient const &);
/// Copy assignment operator - not implemented
SecureComparisonClient operator= (SecureComparisonClient const &);
};
}//namespace PrivateRecommendationsDataPacking
}//namespace SeComLib
#endif//SECURE_COMPARISON_CLIENT_HEADER_GUARD |
64e9eb10bab2efc8d205137f021b66e4204f6ef2 | 877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a | /app/src/main/cpp/dir7941/dir22441/dir22442/dir22443/dir22444/dir22869/dir22870/dir23065/file23168.cpp | 890bb008a2994b34c24dc464e0de1aacc6b0ff8a | [] | no_license | tgeng/HugeProject | 829c3bdfb7cbaf57727c41263212d4a67e3eb93d | 4488d3b765e8827636ce5e878baacdf388710ef2 | refs/heads/master | 2022-08-21T16:58:54.161627 | 2020-05-28T01:54:03 | 2020-05-28T01:54:03 | 267,468,475 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 115 | cpp | file23168.cpp | #ifndef file23168
#error "macro file23168 must be defined"
#endif
static const char* file23168String = "file23168"; |
a2ed7499bd758c681e13fcca3889af9a96012cc7 | 8f3271ae18f3f1058970f41b179c31c198d664ff | /bank_account.h | 98c1e0b89c07fdb7d55c1b9d0b2dd69155f48415 | [] | no_license | tejas369/Account-Management-System | db0b592bec807af162d4077054149dab529935e6 | da960a648b853e82c39da84e0ec348aa8c47ab38 | refs/heads/master | 2021-04-27T22:36:32.253759 | 2018-02-20T22:00:25 | 2018-02-20T22:00:25 | 122,261,152 | 0 | 1 | null | 2020-10-01T18:49:23 | 2018-02-20T21:53:35 | C++ | UTF-8 | C++ | false | false | 519 | h | bank_account.h | //Name :-Tejas Rajput
#ifndef BANK_ACCOUNT_H
#define BANK_ACCOUNT_H
#include <iostream>
#include <fstream>
#include <string>
#include<map>
#include<time.h>
#include "Account.h"
using namespace std;
class bankaccount :public account
{
public:
bankaccount();
~bankaccount();
void view_balance();
void deposit();
void withdraw();
virtual void print_history();
void write_bal1();
private:
double depo_cash;
double with_cash;
ofstream bank_his;
ifstream read;
};
#endif
|
681e814ec933c8f77ffa2fa55e4cdd413876e334 | 433286e87672a10b0cfc08f8e0df4664d03b3d2f | /546B Soldier and Badges.cpp | de641a12dd507b99d52e33cfe19450554813e227 | [] | no_license | LeeTaeSoon/Codeforces | ed4115888d23bf26162319358e0cf4f60011b598 | e298c0456b6d72f43293170f0523f54350e2679a | refs/heads/master | 2021-04-12T08:15:56.254939 | 2018-06-05T09:11:30 | 2018-06-05T09:11:30 | 126,024,414 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,397 | cpp | 546B Soldier and Badges.cpp | /*
546B. Soldier and Badges
대령은 n 개의 배지가 있다. 그는 n 명의 병사들에게 배지를 하나씩 주고 싶다. 각각의 배지는 그것의 주인이 도달한 수준을 보여주는 coolness factor 를 가진다.(?) coolness factor 는 동전 하나의 비용으로 증가될 수 있다.
모든 병사 쌍 중에 한 명은 반드시 다른 병사보다 높은 factor 를 가져야 한다. factor 의 정확한 값은 중요하지 않고 다른 factor 를 가지기만 하면 된다.
대령은 처음에 어떤 병사가 어떤 배지를 받을지 알고 있지만 문제가 있다. 배지 중 일부는 같은 factor 를 가질 수 있다. 모든 배지들이 다른 coolness factor 를 가지기 위해 얼마나 많은 돈이 필요한지 계산해 그를 도와라.
*/
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int* arr = new int[n];
for (int i = 0; i < n; i++) cin >> arr[i];
// sort
for (int i = 0; i < n - 1; i++) {
int min = i;
for (int j = i + 1; j < n; j++) {
if (arr[j] < arr[min]) min = j;
}
if (min != i) {
int t = arr[i];
arr[i] = arr[min];
arr[min] = t;
}
}
int pre = arr[0], sum = 0;
for (int i = 1; i < n; i++) {
if (arr[i] <= pre) {
sum += pre + 1 - arr[i];
arr[i] = pre + 1;
}
pre = arr[i];
}
cout << sum << endl;
return 0;
}
|
3f99fc95754f6bfe218ffb57e7471e9c4277d1b3 | cf0ee127bb2155f6c1d336b67db39d243f001983 | /main/src/Engine/Render/RenderSorter.cpp | e78d523226caa6a55a729fcf2954dd6ee2bca0dc | [
"MIT"
] | permissive | qxly/open | 089abe6bf853e70f39229fe0069e60f1b249397e | 05bf8f51a330a53da7e3f1aa9207c1d8ac01b4db | refs/heads/master | 2021-01-02T09:23:47.409973 | 2017-08-03T07:37:20 | 2017-08-03T07:37:20 | null | 0 | 0 | null | null | null | null | ISO-8859-7 | C++ | false | false | 3,699 | cpp | RenderSorter.cpp | #include "RenderSorter.h"
#include <RenderSystem/RenderStatesInterface.h>
#include <RenderSystem/RenderInterface.h>
#include <Scene/NodeInterface.h>
#include <Scene/MeshInterface.h>
#include <common/Algorithm.h>
namespace open
{
void SimpleRenderSorter::begin()
{
destoryRenderTraces(_transparentList);
destoryRenderTraces(_opacityList);
_transparentList.clear();
_opacityList.clear();
}
void SimpleRenderSorter::sort(ICamera* camera, INode** nodes, int32 count, bool ignorMaterial)
{
_ignorMaterial = ignorMaterial;
for (int32 i = 0; i < count; i++)
{
INode* node = nodes[i];
IDrawable* drawable = node->getDrawable();
////
_currentDrawInstance.matrix = camera->getProject() * camera->getViewMatrix() * node->getMatrix();
_currentDrawInstance.matrix = _currentDrawInstance.matrix.getTranspose();
////·¨Οί
_currentDrawInstance.normalMatrix = camera->getViewMatrix() * node->getMatrix();
RQuat nn = _currentDrawInstance.normalMatrix.getRotate();
_currentDrawInstance.normalMatrix.makeRotate(nn);
_currentDrawInstance.normalMatrix = _currentDrawInstance.normalMatrix.getTranspose();
drawable->accept(functor(*this, &SimpleRenderSorter::sortGeometry));
}
}
struct Find_Material
{
inline static bool compare(const RenderTrace& l, const RenderTrace& r)
{
return l.material < r.material;
}
};
RenderTrace& SimpleRenderSorter::getOrCreateRenderTrace(RenderTraceArray& rts, IMaterial* material)
{
RenderTrace rt(material);
if (rts.empty())
{
rt.geometries = new GeometryInstanceArray;
rts.push_back(rt);
return rts[0];
}
int32 find = lower_bound<RenderTrace, Find_Material>(rts.getDataPointer(), rts.size(), rt);
if (find == -1 || find >= rts.size() || Find_Material::compare(rt, rts[find]))
{
rt.geometries = new GeometryInstanceArray;
rts.insert(find, rt);
}
return rts[find];
}
GeometryInstance& SimpleRenderSorter::getOrCreateGeometryInstance(RenderTrace& rt, IGeometry* geometry)
{
for (int32 i = 0; i < rt.geometries->size(); i++)
{
GeometryInstance& gi = rt.geometries->at(i);
if (gi.geometry == geometry)
{
return gi;
}
}
GeometryInstance gi;
gi.geometry = geometry;
gi.instanceInfos = new GeneralInstanceArray;
rt.geometries->push_back(gi);
return rt.geometries->back();
}
void SimpleRenderSorter::setInstanceInfos(GeometryInstance& gi)
{
gi.instanceInfos->push_back(_currentDrawInstance);
}
void SimpleRenderSorter::sortGeometry(IGeometry* geometry, IMaterial* material)
{
if (!_ignorMaterial)
{
if (material->isTransparentMaterial())
{
Real3 ps = _currentDrawInstance.matrix.getTrans();
Real lg = (ps - _eyePoint).length2();
Real d = _dirction * ps;
lg = d > 0 ? lg : -lg;
RenderTrace& rt = getOrCreateRenderTrace(_transparentList, material);
GeometryInstance& gi = getOrCreateGeometryInstance(rt, geometry);
setInstanceInfos(gi);
}
else
{
RenderTrace& rt = getOrCreateRenderTrace(_opacityList, material);
GeometryInstance& gi = getOrCreateGeometryInstance(rt, geometry);
setInstanceInfos(gi);
}
}
else
{
RenderTrace& rt = getOrCreateRenderTrace(_opacityList, NULL);
GeometryInstance& gi = getOrCreateGeometryInstance(rt, geometry);
setInstanceInfos(gi);
}
}
void SimpleRenderSorter::insert(Real lg, IGeometry* geometry, IMaterial* material)
{
}
RenderTraceArray& SimpleRenderSorter::end()
{
return _opacityList;
}
RenderTraceArray& SimpleRenderSorter::endTransparents()
{
return _transparentList;
}
} |
7e23e5613301fcfdfcfc416b627a5910c98de022 | 01ee7680e1c6c12bdad946e44604538116949e1e | /C8/test06.cpp | 52a031d262a9ff6dc6781cca2faed81a9dfbceaf | [] | no_license | Dylan13531/CPLUS | a944439ebc5abc6e76158b14391fd1fa357bb085 | d6d9c319c89fa4b3943a5e58582956155338bda0 | refs/heads/master | 2020-12-08T10:41:52.170807 | 2020-01-30T13:15:46 | 2020-01-30T13:15:46 | 232,961,225 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,160 | cpp | test06.cpp | /*************************************************************************
> File Name: test06.cpp
> Author: DylanYang
> Mail: 13162687569@163.com
> Created Time: 二 1/21 18:17:20 2020
************************************************************************/
#include <iostream>
#include <cstring>
template<typename T>
T maxn(T * test, const int n);
template<>
char * maxn<char *>(char ** test, const int n);
int main()
{
using namespace std;
int a[6] = {1,2,3,4,5,6};
double b[4] = {2.29,10.2,7.3,9.3};
char * test[] = {"hello", "What's your name?", "Oh","I am sorry"};
cout << "Int: " << maxn(a,6) << endl;
cout << "Double : " << maxn(b,4) << endl;
cout << "char * : " << maxn(test,4) << endl;
return 0;
}
template<typename T>
T maxn(T * test, const int n)
{
T temp = test[0];
for (int i=1; i<n; i++)
{
if (test[i] > temp)
temp = test[i];
}
return temp;
}
template<>
char * maxn(char ** test, const int n)
{
int num;
int temp;
int index;
num = strlen(test[0]);
index = 0;
for (int i=0; i<n; i++)
{
temp = strlen(test[i]);
if (num < temp)
{
num = temp;
index = i;
}
}
return test[index];
}
|
1207a67c5c7de35b7eaeb2a867c70e5c8afb5339 | 6dc0ab4ee026c952680a2fc7d37fc2646b360864 | /tests/example_conv.cc | 14dcfee5db88dc6355b54a62f54afbb48948a061 | [
"MIT"
] | permissive | nhartland/APFELgrid | c3c6dd4498af8b93b5840892fccda8b4be4358e0 | 3ca47aab85b76a5e1e677f7e39bfcf8152f01800 | refs/heads/master | 2021-01-14T08:22:03.840847 | 2020-05-11T13:38:55 | 2020-05-11T13:38:55 | 50,047,730 | 1 | 2 | NOASSERTION | 2023-06-03T10:25:19 | 2016-01-20T17:37:25 | C++ | UTF-8 | C++ | false | false | 2,880 | cc | example_conv.cc | // APFELgrid
// =========
// FastKernel table convolution
// ----------------------------
// This example demonstrates how an **FK** table may be read from file and convoluted with a given PDF.
// For this demonstration, we need some standard headers
#include <iostream>
#include <cstdlib>
// Along with **LHAPDF** to provide initial scale PDFs
#include "LHAPDF/LHAPDF.h"
// And the required **APFELgrid** headers
#include "APFELgrid/fastkernel.h"
#include "APFELgrid/transform.h"
// We start with some boilerplate, a typedef named *ctype* so that we may switch between
// double and single precision convolutions simply, and a handle for the **LHAPDF** (v5-style)
// interface for **PDF** evolution (as per standard **APPLgrid** procedure).
typedef float ctype;
extern "C" void evolvepdf_(const double& , const double& , double* );
// Now we setup an equivalent bit of boilerplate for the **FK** convolution.
// Unlike **APPLgrids**, **FK** tables require PDFs in the DGLAP or Evolution (EVLN) basis
// (see the reference manual for details). **APFELgrid** provides a helper utility to
// perform the rotation to the EVLN basis from the **LHAPDF** basis.
// No implicit rotation is performed, as this would require prior knowledge of the
// internal representation of PDFs used in the fit.
// The function *fkpdf* therefore interfaces the **LHAPDF** call *evolvepdf_* with
// the **FK** convolution by means of this rotation. The double *lha_pdf* holds the
// intermediate values in the **LHAPDF** basis. Here the member argument *n* is unused.
static double* lha_pdf;
void fkpdf (const double& x, const double& Q, const size_t& n, ctype* pdf)
{
evolvepdf_(x,Q,lha_pdf);
NNPDF::LHA2EVLN<double, ctype>(lha_pdf, pdf);
}
// With the boilerplate completed, we start the main loop by initialising the *lha_pdf* array
int main(int argc, char* argv[]) {
lha_pdf = new double[13];
// The **FK** table is then read from file, and a PDF set is initialised
std::ifstream infile; infile.open("./tests/atlas-Z0-rapidity.fk");
NNPDF::FKTable<ctype> FK(infile);
LHAPDF::initPDFSet("NNPDF30_nlo_as_0118", LHAPDF::LHGRID, 0);
// We now allocate an array (of type *ctype*) for results and perform the convolution.
// The arguments to *FK::Convolute* here are
// + *fkpdf* - a pointer to a function providing PDFs for individual values of *x*, *Q* and member *n* as defined above
// + *1* - Here we only require one PDF member to be convoluted, but this may be increased if required.
// + *results* - The results array
ctype* results = new ctype[FK.GetNData()];
FK.Convolute(fkpdf, 1, results);
// For a single member convolution, the results of the product can be simply displayed as so
for (int i=0; i < FK.GetNData(); i++)
std::cout << results[i] <<std::endl;
// Finally we clean up and end the program.
delete[] results;
delete[] lha_pdf;
exit(0);
}
|
e203fa9e372f366c038ab0eee03322db4715bb52 | fb03995d5807509a66d35a2f3e366849f4184f05 | /OOP/HW3/p3/MyStack.cpp | 6cfd3e2c366763b5178545d679e3365ffb4d05b9 | [
"MIT"
] | permissive | calee0219/Course | 2b641c6d4c6fa49e87c1d600ea3927a96b8b5252 | 10bd72fcb57aae34a7ee99b0daf8c2efbd29d8dc | refs/heads/master | 2021-01-23T20:57:06.353586 | 2018-03-27T15:15:59 | 2018-03-27T15:15:59 | 90,666,096 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,578 | cpp | MyStack.cpp | /*************************************************************************
> File Name: MyStack.cpp
> Author: Gavin Lee
> School: National Chiao Tung University
> Team: NCTU_Ragnorok
> Mail: sz110010@gmail.com
> Created Time: Sun 03 Apr 2016 09:39:44 PM CST
************************************************************************/
#include <bits/stdc++.h>
#include "MyStack.h"
#include "Coordinate.h"
using namespace std;
// MyStack
template <class T>
MyStack<T>::MyStack():size(0),head(NULL) {}
template <class T>
MyStack<T>::~MyStack()
{
if(head == NULL) return;
while(head->next != NULL)
{
Node *tmp_head = head;
while((tmp_head->next)->next != NULL)
tmp_head = tmp_head->next;
delete(tmp_head->next);
tmp_head->next = NULL;
}
return;
}
template <class T>
void MyStack<T>::push(T &t)
{
if(head == NULL)
{
head = new Node(t,NULL);
size = 1;
return;
}
Node *tmp = new Node(t,head);
head = tmp;
size++;
return;
}
template <class T>
void MyStack<T>::pop()
{
if(head == NULL) return;
Node *tmp = head;
head = tmp->next;
delete(tmp);
size--;
return;
}
template <class T>
T& MyStack<T>::top()
{
return head->value;
}
template <class T>
size_t MyStack<T>::getSize() const { return size; }
template <class T>
bool MyStack<T>::empty() const { return head == NULL; }
// Node
template <class T>
MyStack<T>::Node::Node(T &t, Node *node):value(t),next(node) {}
template class MyStack<char>;
template class MyStack<Coordinate>;
|
219eaebf5e145456fb45ea16e0707c08d4db2572 | 81ae1a9d4e937088acd120e9a61f59df005652c5 | /main.cpp | 1e0f0134bf9b194185336a6449f086af8e30bc04 | [] | no_license | ElessarCuthalion/Kvest-Mason_order_FV3 | e3ca3071524ce2b5b145a58bf693a972b9775607 | 85eb94d691fa0a74e82cd72777cc841c389782aa | refs/heads/master | 2020-03-30T16:35:07.032468 | 2019-01-16T10:34:14 | 2019-01-16T10:34:14 | 151,416,197 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,915 | cpp | main.cpp | /*
* File: main.cpp
* Author: Elessar
* Project: MasonOrder
*
* Created on May 27, 2016, 6:37 PM
*/
#include "main.h"
#include "SimpleSensors.h"
#include "PinSnsSettings.h"
#include "buttons.h"
#include "kl_adc.h"
//#include "led.h"
//#include "Sequences.h"
#include "sound.h"
#include "Soundlist.h"
#include "Woodman.h"
#include "Piano.h"
#if 1 // ======================== Variables and defines ========================
App_t App;
SndList_t SndList;
PinInput_t ExternalPWR{ExternalPWR_Pin};
enum AppState_t {
asStandby, asGame,
};
AppState_t State = asStandby;
//void BtnHandler(BtnEvt_t BtnEvt, uint8_t BtnID);
void BtnHandler(BtnEvt_t BtnEvt);
//void LoadSettings(const char* FileName);
#endif
// =============================== Main ========================================
int main() {
#if 1 // ==== Init ====
// ==== Setup clock ====
Clk.UpdateFreqValues();
uint8_t ClkResult = retvFail;
Clk.SetupFlashLatency(24); // Setup Flash Latency for clock in MHz
// 12 MHz/6 = 2; 2*192 = 384; 384/8 = 48 (preAHB divider); 384/8 = 48 (USB clock)
Clk.SetupPLLDividers(6, 192, pllSysDiv8, 8);
// 48/4 = 12 MHz core clock. APB1 & APB2 clock derive on AHB clock
Clk.SetupBusDividers(ahbDiv4, apbDiv1, apbDiv1); // for 24MHz work: ahbDiv2, apbDiv1, apbDiv1
if((ClkResult = Clk.SwitchToPLL()) == 0) Clk.HSIDisable();
Clk.UpdateFreqValues();
// ==== Init OS ====
halInit();
chSysInit();
App.InitThread();
// ==== Init Hard & Soft ====
Uart.Init(115200, UART_GPIO, UART_TX_PIN, UART_GPIO, UART_RX_PIN);
Uart.Printf("\r%S %S\r", APP_NAME, BUILD_TIME);
Clk.PrintFreqs();
// Report problem with clock if any
if(ClkResult) Uart.Printf("Clock failure\r");
// Setup inputs
SimpleSensors::Init();
// Setup outputs
chThdSleepMilliseconds(100); // Let power to stabilize
// Random
Random::TrueInit();
// SD
SD.Init(); // No power delay
// Sound
Sound.Init();
Sound.SetupSeqEndEvt(EVT_PLAY_ENDS);
// LoadSettings("Settings.ini");
if (ExternalPWR.IsHi()) App.SignalEvt(EVT_USB_CONNECTED);
// USB related
MassStorage.Init();
// LEDs
// LedWs.Init();
// LedWs.ISetCurrentColors();
// Timers
// Game
State = asStandby;
#if QUEST_ROOM == WoodmanRoom
Woodman.Init();
Woodman.DefaultState();
#elif QUEST_ROOM == PianoRoom
Piano.Init();
Piano.DefaultState();
#endif
#endif
// ==== Main cycle ====
App.ITask();
}
#if 0
void LoadSettings(const char* SettingsFileName) {
// Load Sound Settings
uint8_t VolLevel = 0;
if (iniRead(SettingsFileName, "Game", "SndVolume", &VolLevel) == retvOk)
Sound.SetVolume(VolLevel);
else {
Uart.Printf(" Sound <- Def VolLevel\r");
Sound.SetVolume(DEF_VolLevel);
}
if (iniRead(SettingsFileName, "Game", "LEDbright", &LEDs_Bright) != retvOk) {
Uart.Printf(" LEDs <- Def LEDbright\r");
LEDs_Bright = DEF_LEDs_Bright;
}
uint32_t LockDelay;
if (iniRead(SettingsFileName, "Game", "LockDelay", &LockDelay) == retvOk)
TmrLockBTN.SetNewPeriod_ms(LockDelay);
else {
Uart.Printf(" Time <- Def LockDelay\r");
TmrLockBTN.SetNewPeriod_ms(DEF_Lock_delay_MS);
}
if (iniReadString(SettingsFileName, "Game", "CallTrack", &CallFileName) != retvOk) {
Uart.Printf(" CallTrack <- Def FileName\r");
strcpy(CallFileName, DEF_CallTrack);
}
}
#endif
__attribute__ ((__noreturn__))
void App_t::ITask() {
while(true) {
eventmask_t EvtMsk = chEvtWaitAny(ALL_EVENTS);
#if QUEST_ROOM == WoodmanRoom // ---------------------------------------------
if(EvtMsk & EVT_WoodmanCameToLife) {
Sound.ONChannel(WoodmanMonologue_Channel);
Sound.SetVolume(WoodmanMonologue_VolLevel);
Sound.Play(WoodmanMonologue_file);
Woodman.StartGesture(&WoodmanMonologue[0]);
}
if(EvtMsk & EVT_PLAY_ENDS) {
// if (!ExternalPWR.IsHi()) {
switch(Woodman.GetState()) {
case wsHeartReturned:
Woodman.SetState(wsMonologueCompleted);
Sound.OFFChannel(WoodmanMonologue_Channel);
Woodman.StartGesture(&WoodmanSmile[0]);
break;
default: break;
}
// }
}
if(EvtMsk & EVT_WoodmanGestureCompleted) {
switch(Woodman.GetState()) {
case wsMonologueCompleted:
Woodman.ToWink();
Woodman.OpenDoor();
Woodman.SignalToHandcar();
break;
default: break;
}
}
#elif QUEST_ROOM == PianoRoom // ---------------------------------------------
if(EvtMsk & EVT_PianoCodeOk) {
Sound.ONChannelOnly(Cupboard_Channel);
chThdSleepMilliseconds(500);
Sound.SetVolume(Cupboard_VolLevel);
Sound.Play(OpenedCupboard_file);
Piano.CupboardBacklightON();
Piano.OpenCupboard();
}
#endif
if(EvtMsk & EVT_BUTTONS) {
BtnEvtInfo_t EInfo;
while(BtnGetEvt(&EInfo) == retvOk) BtnHandler(EInfo.Type);
// while(BtnGetEvt(&EInfo) == retvOk) BtnHandler(EInfo.Type, EInfo.BtnID);
}
// ==== USB connected/disconnected ====
if(EvtMsk & EVT_USB_CONNECTED) {
Sound.Stop();
chSysLock();
Clk.SetFreq48Mhz();
chSysUnlock();
Usb.Init();
chThdSleepMilliseconds(540);
Usb.Connect();
Uart.Printf("Usb On\r");
Clk.PrintFreqs();
}
if(EvtMsk & EVT_USB_DISCONNECTED) {
Usb.Shutdown();
MassStorage.Reset();
chSysLock();
Clk.SetFreq12Mhz();
chSysUnlock();
Uart.Printf("Usb Off\r");
Clk.PrintFreqs();
}
if(EvtMsk & EVT_UART_NEW_CMD) {
OnCmd(&Uart);
Uart.SignalCmdProcessed();
}
} // while true
} // App_t::ITask()
//void BtnHandler(BtnEvt_t BtnEvt, uint8_t BtnID) {
void BtnHandler(BtnEvt_t BtnEvt) {
// if(BtnEvt == beShortPress) Uart.Printf("Btn %u Short\r", BtnID);
// if(BtnEvt == beLongPress) Uart.Printf("Btn %u Long\r", BtnID);
// if(BtnEvt == beRelease) Uart.Printf("Btn %u Release\r", BtnID);
// if(BtnEvt == beRepeat) Uart.Printf("Btn %u Repeat\r", BtnID);
// if(BtnEvt == beClick) Uart.Printf("Btn %u Click\r", BtnID);
// if(BtnEvt == beDoubleClick)Uart.Printf("Btn %u DoubleClick\r", BtnID);
#if QUEST_ROOM == WoodmanRoom
if (BtnEvt == beShortPress) {
if (!Woodman.BacklightIsOn() ) {
Woodman.HeadUp();
Woodman.BacklightON();
Woodman.TunnelLightingON();
Woodman.EyeON_and_HeartBlinkOFF();
chThdSleepMilliseconds(100);
Woodman.StartGesture(&WoodmanSmile[0]);
} else {
Woodman.DefaultState();
}
}
#elif QUEST_ROOM == PianoRoom
if (BtnEvt == beClick) {
if (Piano.CommonLightingIsOn())
Piano.DefaultState();
else Piano.CommonLightingON();
} else if (BtnEvt == beLongPress) {
App.SignalEvt(EVT_PianoCodeOk);
}
#endif
}
// Snsors
void Process5VSns(PinSnsState_t *PState, uint32_t Len) {
// Uart.Printf(" %S\r", __FUNCTION__);
if(PState[0] == pssRising) App.SignalEvt(EVT_USB_CONNECTED);
else if(PState[0] == pssFalling) App.SignalEvt(EVT_USB_DISCONNECTED);
}
#if QUEST_ROOM == WoodmanRoom
void ProcessDoorK1K2Sns(PinSnsState_t *PState, uint32_t Len) {
if(PState[0] == pssRising) Woodman.SignalEvt(WM_EVT_DoorK1K2Opened);
}
void ProcessHandcarStartSns(PinSnsState_t *PState, uint32_t Len) {
if(PState[0] == pssFalling) Woodman.SignalEvt(WM_EVT_HandcarParked);
}
void ProcessHandcarCenterSns(PinSnsState_t *PState, uint32_t Len) {
if(PState[0] == pssFalling) Woodman.SignalEvt(WM_EVT_HandcarInTransit);
}
void ProcessHandcarStopSns(PinSnsState_t *PState, uint32_t Len) {
if(PState[0] == pssFalling) Woodman.SignalEvt(WM_EVT_HandcarStoped);
}
void ProcessHeartSns(PinSnsState_t *PState, uint32_t Len) {
if(PState[0] == pssFalling) Woodman.SignalEvt(WM_EVT_HeartReturn);
}
#elif QUEST_ROOM == PianoRoom
void ProcessKeySens(PinSnsState_t *PState, uint32_t Len) {
for(uint8_t i=0; i<PianoKeys_CNT; i++)
if(PState[i] == pssFalling) {
switch(Piano.GetState()) {
case psExpectation:
Piano.SetState(psMelodyPlaying);
Piano.CommonLightingON();
case psCupboardOpened:
Sound.ONChannelOnly(Piano_Channel);
// chThdSleepMilliseconds(500);
Sound.SetVolume(Piano_VolLevel);
break;
default: break;
}
Piano.CodeProcessing(i+1);
Sound.Play(PianoKeysFileNames[i]);
}
}
#endif
#if UART_RX_ENABLED // ================= Command processing ====================
void App_t::OnCmd(Shell_t *PShell) {
Cmd_t *PCmd = &PShell->Cmd;
__attribute__((unused)) int32_t Data = 0; // May be unused in some configurations
// Uart.Printf("\r New Cmd: %S\r", PCmd->Name);
// Handle command
if(PCmd->NameIs("Ping")) {
PShell->Ack(retvOk);
}
else if(PCmd->NameIs("Play")) {
SndList.PlayRandomFileFromDir(PlayDir);
PShell->Ack(retvOk);
}
else if(PCmd->NameIs("CameToLife")) {
App.SignalEvt(EVT_WoodmanCameToLife);
PShell->Ack(retvOk);
}
else if(PCmd->NameIs("Smile")) {
Woodman.EyeON_and_HeartBlinkOFF();
Woodman.SetState(wsMonologueCompleted);
Woodman.StartGesture(&WoodmanSmile[0]);
PShell->Ack(retvOk);
}
else if(PCmd->NameIs("Wink")) {
Woodman.ToWink();
PShell->Ack(retvOk);
}
else if(PCmd->NameIs("PianoCodeOk")) {
App.SignalEvt(EVT_PianoCodeOk);
PShell->Ack(retvOk);
}
else PShell->Ack(retvCmdUnknown);
}
#endif
|
d458140066f9975a32b28d36625dfa752f3fad7b | 9b20714e051cd9820295eec8fcef587718753e1a | /src/board.cpp | 1aaca364e83db65b79b9ce9771ae1b3cabc731da | [] | no_license | Alice-For/BE_Cpp_Alice_Xiaohu | 3d539fe221465d5af0ac9611875b8ef42fad671b | 90953e882a5a8ed609fdd3b1e70d45f636936270 | refs/heads/master | 2022-09-04T11:11:05.422394 | 2020-05-31T08:24:34 | 2020-05-31T08:24:34 | 263,543,886 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,379 | cpp | board.cpp | #include "core_simulation.h"
#include "mydevices.h"
#include "environnement.h"
#define PIN_HUMIDITE 10
#define PIN_TEMPERATURE 9
#define PIN_LUMIERE 11
#define PIN_CO2 12
#define PIN_CHAUFFAGE 5
#define PIN_VENTILATEUR 6
#define PIN_FENETRE 4
#define PIN_ARROSAGE 8
#define PIN_LAMPE 7
int main(){
// creation d'une board
Board esp8266;
// achat des senseurs et actionneurs
AnalogSensorTemperature temperature(DELAY,Environnement::Get_temp());
AnalogSensorLuminosity lumiere(DELAY,Environnement::Get_lum());
AnalogSensorHumidity humidite(DELAY, Environnement::Get_hum());
AnalogSensorCO2 dioxyde(DELAY, Environnement::Get_CO2());
MoteurFenetre turbo(DELAY);
Chauffage feu(DELAY); //-> ok :)
Ventilateur AirFrais(DELAY); //-> ok :)
Lampe Loupiote(DELAY);
Arrosage Tuyau(DELAY);
I2CActuatorScreen screen;
// branchement des capteurs
esp8266.pin(PIN_TEMPERATURE,temperature);
esp8266.pin(PIN_HUMIDITE,humidite);
esp8266.pin(PIN_LUMIERE,lumiere);
esp8266.pin(PIN_CO2,dioxyde);
// branchement des actionneurs
esp8266.pin(PIN_FENETRE,turbo);
esp8266.pin(PIN_CHAUFFAGE,feu); // -> ok
esp8266.pin(PIN_VENTILATEUR,AirFrais); // -> ok
esp8266.pin(PIN_LAMPE,Loupiote);
esp8266.pin(PIN_ARROSAGE,Tuyau);
esp8266.i2c(1,screen);
// allumage de la carte
esp8266.run();
//Destructeurs a appeler ?
return 0;
}
|
d36a8ec4e5bf1b563e5585cf5804b2a15bb2fd64 | c13719a92c23dcade0eb9a43d6638de5ef17ed81 | /minimum_loss.cpp | dd035c01b222927f22566598f7ff5a10f92cc7bf | [] | no_license | kwkwok1980/hackerrank | 0993d8da18bfbe3ed3a9f0469c663f69ef2b0b5e | 0c80fa4beb0eecb1454c8e0f603772f2de694999 | refs/heads/master | 2021-10-01T19:05:21.034491 | 2018-11-28T16:11:27 | 2018-11-28T16:11:27 | 61,634,612 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,860 | cpp | minimum_loss.cpp | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <limits>
struct Value
{
int i;
long long p;
};
int Solve(std::vector<Value>& values)
{
auto func = [](auto&& a, auto&& b) -> bool {return a.p < b.p;};
std::sort(values.begin(), values.end(), func);
auto g1b = values.begin();
auto g1e = g1b + 1;
while(g1e!=values.end() && g1b->p == g1e->p) ++g1e;
long long d = std::numeric_limits<long long>::max();
while(g1e != values.end())
{
auto g2b = g1e;
auto g2e = g2b + 1;
while(g2e!=values.end() && g2b->p == g2e->p) ++g2e;
if (g2b->p - g1b->p < d)
{
bool find = false;
for(auto it1=g1b; it1!=g1e; ++it1)
{
for(auto it2=g2b; it2!=g2e; ++it2)
{
if (it2->i < it1->i)
{
//std::cout << "f " << it1->i << " " << it1->p << std::endl;
//std::cout << "f " << it2->i << " " << it2->p << std::endl;
find = true;
break;
}
}
if (find)
{
break;
}
}
if (find)
{
d = g2b->p - g1b->p;
}
}
g1b = g2b;
g1e = g2e;
}
return d;
}
int main() {
int n;
std::cin >> n;
std::vector<Value> values;
for (int i=0; i<n; ++i)
{
long long p;
std::cin >> p;
values.emplace_back(Value{i,p});
}
for (auto&& value : values)
{
//std::cout << value.i << "," << value.p << std::endl;
}
long long d = Solve(values);
std::cout << d << std::endl;
return 0;
}
|
7f9fa325fcdbabb8a207f3d80e8509261f43a0cf | 221e2ef6eef91991a883d21e46cac67a8957dad5 | /Codigo/src/ficheros/getcarpeta.cpp | 9e0f839a4b65cd68a33bc0a10cc4b8f34a614bf9 | [] | no_license | antoniosastre/Sincronizador | 53211d9f9057c71ab8d6d35a986736467204283b | d5769d5b5678d70b8932f5ff6cb5b3118d6fe530 | refs/heads/master | 2020-02-26T15:29:33.789755 | 2014-06-29T21:04:20 | 2014-06-29T21:04:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 910 | cpp | getcarpeta.cpp | #include <dirent.h>
#include <sys/stat.h>
#include <cstring>
#include <fstream>
using namespace std;
int getCarpeta(const char *dir, char **&files, int &n) {
DIR *dp;
struct dirent *dirp;
if((dp = opendir(dir)) == 0) {
return -1;
}
n= 0;
while ((dirp = readdir(dp)) != 0) {
n++;
}
closedir(dp);
n-= 2; // Quitamos 2 por la carpeta "." y la carpeta ".."
files= new char *[n];
if (files == 0)
return -2;
dp= opendir(dir);
int j= 0;
for (int i= 0; i<n+2; i++) {
dirp= readdir(dp);
if ((strcmp(dirp->d_name, ".") != 0) && (strcmp(dirp->d_name, "..") != 0)) {
files[j]= new char [strlen(dirp->d_name)+1];
if (files[j] == 0) {
for (int k= 0; k<j; k++)
delete [] files[k];
delete [] files;
files= 0;
n= 0;
return -2;
}
strcpy(files[j], dirp->d_name);
j++;
}
}
return 0;
}
|
6b877b4f6165b3a1daf9098d5cc71a9a6c1be029 | 049755681a1c0b1688754877162e81c026619489 | /Project1/Project1.cpp | a1e89ac3793b2e57da5435cac0acff40d458666a | [] | no_license | Sam-Connor/CSC2040-Practical2 | 58d09379143090f7dce7b08ef665e43f0c465188 | 40e1e371b5a4fa10fe3bed9d46732b03e0fe72da | refs/heads/master | 2020-08-09T20:33:56.347879 | 2019-10-10T11:52:45 | 2019-10-10T11:52:45 | 214,169,248 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 526 | cpp | Project1.cpp | #include <iostream>
#include <string>
using namespace std;
int main()
{
int sample[10];
for (int t = 0; t < 10; t++)
{
sample[t] = t;
}
for (int t = 0; t < 10; t++)
{
cout << "This is sample [" << t << "]: " << sample[t] << endl;
cout << endl;
}
char sample2[20] = "This is a test.";
cout << sample2 << endl;
int* p = sample;
for (int t = 0; t < 10; t++)
{
*p++ = t * t;
}
p = sample;
for (int t = 0; t < 10; t++)
{
cout << "This is sample [" << t << "]: " << *p++ << endl;
}
return 0;
} |
92dfa0bdc86f774639980e8510dcf84ef00a947d | 19737d80f92b108dd37be327dfa1ba35729283c9 | /src/ShaderScreen.h | a162cf3aa5a7e6977b1e60c3b05c2dc59d203b9a | [] | no_license | andyinabox/helen-of | 81c33ef51c99a8224e0cef4b5920658613d3396f | 622a5086defe8b942e67b818730fdd06c1966ca2 | refs/heads/master | 2021-05-01T12:31:11.174017 | 2020-03-24T16:28:05 | 2020-03-24T16:28:05 | 57,398,363 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,205 | h | ShaderScreen.h | #pragma once
//
// ShaderScreen.h
// helen1
//
// Created by Andrew Dayton on 4/29/16.
//
//
#include "ofMain.h"
class ShaderScreen {
public:
ofMesh mesh;
void setup(int w, int h, bool arb= true) {
// set gl mode
mesh.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
// add indexes
mesh.addIndex(0);
mesh.addIndex(1);
mesh.addIndex(2);
mesh.addIndex(3);
// set vertices and tex coordinates
update(w, h, arb);
};
void update(int w, int h, bool arb=true) {
// set texture coordinates for arbitrary
// or non-arbitrary texture coords
int tw = arb ? w : 1;
int th = arb ? h : 1;
// reset
mesh.clearVertices();
mesh.clearTexCoords();
// add vertices
mesh.addVertex(ofVec3f(0, 0, 0));
mesh.addVertex(ofVec3f(w, 0, 0));
mesh.addVertex(ofVec3f(w, h, 0));
mesh.addVertex(ofVec3f(0, h, 0));
// add texture coordinates
mesh.addTexCoord(ofVec2f(0, 0));
mesh.addTexCoord(ofVec2f(tw, 0));
mesh.addTexCoord(ofVec2f(tw, th));
mesh.addTexCoord(ofVec2f(0, th));
}
void draw() {
mesh.draw();
};
}; |
a45119262c11fe02db93a30cdc04fb642c0a36fb | fa40524bf36a16503ad2532472c8f35351c22d80 | /MFC표준컨트롤/대화상자에서만들기/대화상자에서만들기View.h | e911e10a0134df3f9d8a87366aaf6c94e4c4e2bc | [] | no_license | kyuhwajeong/CPlus | 49c29ffab26638e765fd2409bdb09193c5a35493 | 5848d925fba47b9f36ee3949511a29d8aec5b302 | refs/heads/master | 2020-03-21T05:51:21.617151 | 2018-10-11T14:41:28 | 2018-10-11T14:41:28 | 138,185,426 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 1,438 | h | 대화상자에서만들기View.h |
// 대화상자에서만들기View.h : C대화상자에서만들기View 클래스의 인터페이스
//
#pragma once
#include "resource.h"
#include "afxwin.h"
class C대화상자에서만들기View : public CFormView
{
protected: // serialization에서만 만들어집니다.
C대화상자에서만들기View();
DECLARE_DYNCREATE(C대화상자에서만들기View)
public:
enum{ IDD = IDD_MY_FORM };
// 특성입니다.
public:
C대화상자에서만들기Doc* GetDocument() const;
// 작업입니다.
public:
// 재정의입니다.
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
virtual void OnInitialUpdate(); // 생성 후 처음 호출되었습니다.
// 구현입니다.
public:
virtual ~C대화상자에서만들기View();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// 생성된 메시지 맵 함수
protected:
DECLARE_MESSAGE_MAP()
public:
// CButton m_pushbutton;
CButton m_checkbox;
CButton m_radio1;
CButton m_radio2;
afx_msg void OnClickedButton1();
void OnRadio(UINT uID);
};
#ifndef _DEBUG // 대화상자에서만들기View.cpp의 디버그 버전
inline C대화상자에서만들기Doc* C대화상자에서만들기View::GetDocument() const
{ return reinterpret_cast<C대화상자에서만들기Doc*>(m_pDocument); }
#endif
|
09b0f67205c000b0214435966dd1e5439c7b9a78 | 30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a | /contest/1542581325.cpp | 870b897b4bdff71a0471fae699e9c781b95c58bf | [] | 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 | 1,323 | cpp | 1542581325.cpp | /*
* test.cpp
*
*
* Author: Fireworks
*/
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cmath>
#include<bitset>
#include<set>
#include<iomanip>
#include<fstream>
#include<bitset>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<list>
#include<sstream>
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
long long mod = 1000000007LL;
long long base = 10000007;
long long large = 1000000000000000000LL;
int main(){
int n,k;
cin>>n>>k;
vector<int> cnt(1<<k,0);
for(int i=0;i<n;i++){
int x = 0;
for(int j=0;j<k;j++){
int y;
cin>>y;
x*=2;
x+=y;
}
cnt[x]++;
}
if(cnt[0]>0){
cout<<"YES"<<endl;
return 0;
}
for(int i=0;i<(int)cnt.size();i++){
for(int j=0;j<(int)cnt.size();j++){
if((i&j)==0){
if(cnt[i]>0&&cnt[j]>0){
cout<<"YES"<<endl;
return 0;
}
}
}
}
cout<<"NO"<<endl;
return 0;
}
|
df16f1f4a9bfe885e163483b310433d9dc1074dd | 0b88521958f1913c2844684e71ff439f8f16b8ad | /code.ino | e87b01f917323f78a7e1799eaeedf363b9a267e9 | [] | no_license | electrofun-smart/bigDisplayArduinoTempHum | eb38f4317d595d14d077312e6ec07effad817a45 | fee460f80a474050eb86415d8b8fc0d9b946f0a6 | refs/heads/main | 2023-03-20T10:26:11.218638 | 2021-03-21T19:22:13 | 2021-03-21T19:22:13 | 350,091,939 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,911 | ino | code.ino | #include <Adafruit_NeoPixel.h>
#include <DHT.h>
#define PIXELS_PER_SEGMENT 3
#define DIGITS 2
#define PIN 5
#define DHTPIN 4
#define DHTTYPE DHT22 // Sensor DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
byte segments[10] = {
0b1111110,
0b0011000,
0b0110111,
0b0111101,
0b1011001,
0b1101101,
0b1101111,
0b0111000,
0b1111111,
0b1111001
};
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXELS_PER_SEGMENT * 7 * DIGITS, PIN, NEO_GRB + NEO_KHZ800);
void setup()
{
strip.begin();
Serial.begin(9600);
dht.begin();
}
void writeNum(int num, int type) {
for (int i = 0; i <= DIGITS - 1; i++) {
writeDigit(i, num % 10, type);
num /= 10;
}
}
void writeDigit(int index, int value, int type) {
byte seg = segments[value];
for (int i = 6; i >= 0; i--) {
int offset = index * (PIXELS_PER_SEGMENT * 7) + i * PIXELS_PER_SEGMENT;
uint32_t color = 0;
if (type == 1){
color = seg & 0x01 != 0 ? strip.Color(255, 0, 0) : strip.Color(0, 0, 0);
}else{
color = seg & 0x01 != 0 ? strip.Color(0, 0, 255) : strip.Color(0, 0, 0);
}
for (int x = offset; x < offset + PIXELS_PER_SEGMENT; x++) {
strip.setPixelColor(x, color);
}
seg = seg >> 1;
}
}
void clearDisplay() {
for (int i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(0, 0, 0));
}
}
void loop()
{
clearDisplay();
// Read Humidity
float h = dht.readHumidity();
// Read temperature Celsius
float t = dht.readTemperature();
Serial.print("Humidity: ");
Serial.print(h);
Serial.println(" %");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" C ");
writeNum(t,1);// temp - 1=color red
strip.show();
delay(3000);
writeNum(h,0);// humidity - 0=color blue
strip.show();
delay(3000);
}
|
85fa186da6bd00472e43c85f396e09394cc4ab77 | 377e817c5a3bf2a3bab841432e3ab246195d81b5 | /cpp_code/Robot/MG966/include/MG966_API.hpp | 8e4d41f13189deff43b2da2b2f7dcdb65f152818 | [] | no_license | NGliese/RPI_Robot_Aarm | 69f140ec1d51381b52cc22a7dcb0286fa96021c7 | 8c16a19c43b25085bcbd7176ab25c308dba351de | refs/heads/master | 2022-11-26T09:15:52.449988 | 2020-07-30T08:35:07 | 2020-07-30T08:35:07 | 250,791,840 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 961 | hpp | MG966_API.hpp | /*
* MG996_API.hpp
*
* Created on: Mar 28, 2020
* Author: nikolaj
*/
#ifndef MG966_INCLUDE_MG966_API_HPP_
#define MG966_INCLUDE_MG966_API_HPP_
#include "General_Error.hpp"
#include "i2c_API.hpp"
#include <stdint.h>
#include <wiringPi.h> /* include wiringPi library */
#include <stdio.h>
#include <iostream>
class MG966_API {
public:
MG966_API(uint8_t pwm_pin, i2c_API * i2c);
~MG966_API();
general_err_t initialize(); // define referance point
general_err_t set_position(uint8_t pos);
uint8_t get_position(void);
private:
general_err_t set_duty_cycle(uint8_t duty_cycle);
i2c_API * m_i2c;
uint8_t m_position;
uint8_t m_pwm_pin;
uint8_t m_duty_cycle;
uint8_t m_frequency = 200; // 50 hz is standard for mg966
// define boundery
const uint8_t m_max_rotation = 120;
const uint8_t m_min_rotation = 0;
const uint8_t m_max_duty_cycle = 200;
const uint8_t m_min_duty_cycle = 0;
};
#endif /* MG966_INCLUDE_MG966_API_HPP_ */
|
cf0c2a931867a27c3b3cc3eb8dd0aef770939923 | f00a4c7ad3fa9d2394131002ca1d024c30681e71 | /LibrarySystem/LibrarySystem/borrowInfoClass.cpp | 4dddbcdffa3c4bb20cacf04712a03616983bc065 | [] | no_license | belowthetree/LibrarySystem | 4b9a54644ec8b6a5615feaaf7058278207991789 | f8f4ace2bcee83fe504a736dc43e18679b1e37f1 | refs/heads/master | 2020-07-30T08:10:17.372314 | 2019-10-28T04:27:10 | 2019-10-28T04:27:10 | 210,144,506 | 3 | 1 | null | null | null | null | GB18030 | C++ | false | false | 6,335 | cpp | borrowInfoClass.cpp | #include <cstring>
#include"borrowInfoClass.h"
#include <stdio.h>
#include <windows.h>
#include <string.h>
static long SumOfBorrowInfo = 0; //借阅记录总条数
void ReadInfo()
{
BorrowInfo myBorrowInfo;
ifstream file("borrowInfo.dat", ios::in | ios::binary);
if (!file)
{
cout << "读取失败";
}
while (file.read((char *)&myBorrowInfo,sizeof(myBorrowInfo))) { //一直读到文件结束
cout << myBorrowInfo.userId << " " << myBorrowInfo.userName << " " << myBorrowInfo.bookId << " "
<< myBorrowInfo.bookName << " " <<myBorrowInfo.borrowDate << " "
<<myBorrowInfo.backDate<< " " << endl;
SumOfBorrowInfo++;
}
file.close();
}
void ReverseReadInfo()
{
BorrowInfo TmpmyBorrowInfo;
SumOfBorrowInfo = 0;
ifstream fileCount("borrowInfo.dat", ios::in | ios::binary);
if (!fileCount)
{
cout << "读取失败";
}
while (fileCount.read((char *)&TmpmyBorrowInfo,sizeof(TmpmyBorrowInfo))) { //一直读到文件结束
SumOfBorrowInfo++;
}
fileCount.close();
BorrowInfo* myBorrowInfo = new BorrowInfo[SumOfBorrowInfo];
ifstream file("borrowInfo.dat", ios::in | ios::binary);
if (!file)
{
cout << "读取失败";
}
int count = 0;
while (file.read((char *)&myBorrowInfo[count],sizeof(myBorrowInfo[count]))) { //一直读到文件结束
count++;
}
file.close();
int TmpCount = count;
for (TmpCount = count-1; TmpCount >=0; TmpCount--) {
cout << myBorrowInfo[TmpCount].userId << " " << myBorrowInfo[TmpCount].userName << " "
<< myBorrowInfo[TmpCount].bookId << " " << myBorrowInfo[TmpCount].bookName << " "
<<myBorrowInfo[TmpCount].borrowDate << " " <<myBorrowInfo[TmpCount].backDate << " "
<< endl;
}
delete[] myBorrowInfo;
}
void SaveInfo(char* userId, char* userName, char* bookId, char* bookName)
{
BorrowInfo OneTimeBorrow;
int avglen = 30;
char borrowDate[20];
char backDate[20];
char userid[30];
char username[30];
char bookid[30];
char bookname[30];
strcpy(userid,userId);
strcpy(username,userName);
strcpy(bookid,bookId);
strcpy(bookname,bookName);
ofstream file("borrowInfo.dat", ios::out | ios::app | ios::binary);
if (!file)
{
cout << "借阅信息保存失败";
}
SYSTEMTIME sys;
GetLocalTime(&sys);
sprintf(borrowDate, "%4d-%02d-%02d\n", sys.wYear, sys.wMonth, sys.wDay);
if ((sys.wMonth + 1) > 12) {
sys.wYear += 1;
sys.wMonth = 1;
}
else {
sys.wMonth += 1;
}
sprintf(backDate, "%4d-%02d-%02d\n", sys.wYear, sys.wMonth, sys.wDay);
strcpy(OneTimeBorrow.userId,userid);
strcpy(OneTimeBorrow.userName, username);
strcpy(OneTimeBorrow.bookId,bookid);
strcpy(OneTimeBorrow.bookName,bookname);
strcpy(OneTimeBorrow.borrowDate,borrowDate);
strcpy(OneTimeBorrow.backDate,backDate);
//strcpy(OneTimeBorrow.backDate,"2019-10-21");//应该归还日期
OneTimeBorrow.isBack = 0;//0表示未归还
file.write((char*)(&OneTimeBorrow), sizeof(OneTimeBorrow));
SumOfBorrowInfo++;
file.close();
cout << "借阅信息保存成功";
}
void ReadInfoById(char* TmpId){
BorrowInfo TmpmyBorrowInfo;
SumOfBorrowInfo = 0;
ifstream fileCount("borrowInfo.dat", ios::in | ios::binary);
if (!fileCount)
{
cout << "读取失败";
}
while (fileCount.read((char *)&TmpmyBorrowInfo,sizeof(TmpmyBorrowInfo))) { //一直读到文件结束
SumOfBorrowInfo++;
}
fileCount.close();
BorrowInfo* myBorrowInfo = new BorrowInfo[SumOfBorrowInfo];
ifstream file("borrowInfo.dat", ios::in | ios::binary);
if (!file)
{
cout << "读取失败";
}
int count = 0;
while (file.read((char *)&myBorrowInfo[count],sizeof(myBorrowInfo[count]))) { //一直读到文件结束
count++;
}
file.close();
int TmpCount = count;
for (TmpCount = count-1; TmpCount >=0; TmpCount--) {
if(strcmp(myBorrowInfo[TmpCount].userId,TmpId)==0)
{
cout << myBorrowInfo[TmpCount].userId << " " << myBorrowInfo[TmpCount].userName << " "
<< myBorrowInfo[TmpCount].bookId << " " << myBorrowInfo[TmpCount].bookName << " "
<<myBorrowInfo[TmpCount].borrowDate << " " <<myBorrowInfo[TmpCount].backDate<< endl;
}
}
delete[] myBorrowInfo;
};
void ReadEndInfo(){//有待测试
BorrowInfo TmpmyBorrowInfo;
SumOfBorrowInfo = 0;
ifstream fileCount("borrowInfo.dat", ios::in | ios::binary);
if (!fileCount)
{
cout << "读取失败";
}
while (fileCount.read((char *)&TmpmyBorrowInfo,sizeof(TmpmyBorrowInfo))) { //一直读到文件结束
SumOfBorrowInfo++;
}
fileCount.close();
BorrowInfo* myBorrowInfo = new BorrowInfo[SumOfBorrowInfo];
int* endInfo = new int[SumOfBorrowInfo];
ifstream file("borrowInfo.dat", ios::in | ios::binary);
if (!file)
{
cout << "读取失败";
}
SYSTEMTIME sys;
GetLocalTime(&sys);
char nowDate[20];
sprintf(nowDate, "%4d-%02d-%02d\n", sys.wYear, sys.wMonth, sys.wDay);
int count = 0;
while (file.read((char *)&myBorrowInfo[count],sizeof(myBorrowInfo[count]))) { //一直读到文件结束
endInfo[count] = strcmp(nowDate,myBorrowInfo[count].backDate);
//nowDate>backDate返回>0表示已经超期
if(myBorrowInfo[count].isBack==1){
endInfo[count]=-1;//使得endInfo大于0即可
continue;
}//0表示未归还,1表示已经归还
count++;
}
file.close();
int TmpCount = count;
for (TmpCount = count-1; TmpCount >=0; TmpCount--) {
if(endInfo[TmpCount]>0)
{
cout << myBorrowInfo[TmpCount].userId << " " << myBorrowInfo[TmpCount].userName << " "
<< myBorrowInfo[TmpCount].bookId << " " << myBorrowInfo[TmpCount].bookName << " "
<<myBorrowInfo[TmpCount].borrowDate << " " <<myBorrowInfo[TmpCount].backDate<< endl;
}
}
delete[] myBorrowInfo;
delete[] endInfo;
};
int main(){
//保存测试 成功
/*char userId[]="111467423";
char userName[]="111467423AAA";
char bookId[]="114216743BBB";
char bookName[]="AS167414D66345";
SaveInfo(userId,userName,bookId,bookName);*/
//读取测试 成功
/*ReadInfo();//显示最早借阅历史(正序显示)
ReverseReadInfo();//显示最新借阅历史(倒序显示)*/
//显示超期图书测试 成功
//ReadEndInfo();
//按照用户id查看借阅历史测试 成功
/*char TmpId[]="1114423";
ReadInfoById(TmpId);*/
//控制台保留
/*string TmpEnd;
cin >> TmpEnd;*/
return 0;
}
|
f7376dad76439e4fc72cb759f7e508a5574771b9 | da3c3b663b09fb6481909f6cc9c1d287c8429f52 | /src/SyntaxException.h | 1330fa245040404ea5bec1b12ca8d5386cfa6425 | [] | no_license | mitasov-ra/compiler | 923add3f0c7f2488057b756383c31c66bdc5c863 | e77eea9b8c940fdfb3c59c02539d5d5c6d2ac636 | refs/heads/master | 2021-08-31T12:18:58.770350 | 2017-11-11T16:13:01 | 2017-11-11T16:13:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,050 | h | SyntaxException.h | //
// Created by ROMAN on 03.10.2017.
//
#ifndef COMPILER_SYNTAXEXCEPTION_H
#define COMPILER_SYNTAXEXCEPTION_H
#include <string>
namespace compiler {
class SyntaxException {
public:
enum class Errors {
UNKNOWN_TOKEN,
UNEXPECTED_TOKEN,
LINESEP_MISSING,
CODE_AFTER_END,
KEYWORD_MISSING,
IDENTIFIER_MISSING,
LBRACE_MISSING,
RBRACE_MISSING,
LPAREN_MISSING,
RPAREN_MISSING,
LBRACKET_MISSING,
RBRACKET_MISSING,
OPERAND_MISSING,
OPERATOR_MISSING,
};
private:
int position;
int line;
std::string errorMessage;
Errors errorId;
public:
explicit SyntaxException(Errors err);
SyntaxException setMessage(const std::string& message);
SyntaxException setLineAndPos(int line, int pos);
std::string getErrorMessage() const;
void printError();
};
}
#endif //COMPILER_SYNTAXEXCEPTION_H
|
1e80dc9939a39a3cdf4cbd89d7cd4dc0005608d9 | cad84e1a68afa4d91c49dba2474d3b7a58818ae1 | /ezio/acceptor.h | 572898058822c5236da13c2bcdef1309e8e5587c | [
"MIT"
] | permissive | oceancx/ezio | f5e1a47b452a2713e36a591af1637ca2bc4eaba1 | 87107d2ab1a2c52625b89d490782dc1ffe5e7a5c | refs/heads/master | 2020-03-31T12:12:46.190136 | 2018-11-17T12:45:58 | 2018-12-02T08:54:09 | 152,207,188 | 0 | 0 | MIT | 2018-10-09T07:28:45 | 2018-10-09T07:28:44 | null | UTF-8 | C++ | false | false | 1,305 | h | acceptor.h | /*
@ 0xCCCCCCCC
*/
#ifndef EZIO_ACCEPTOR_H_
#define EZIO_ACCEPTOR_H_
#include <functional>
#include "kbase/basic_macros.h"
#include "ezio/notifier.h"
#include "ezio/scoped_socket.h"
#include "ezio/socket_address.h"
#if defined(OS_POSIX)
#include "kbase/scoped_handle.h"
#elif defined(OS_WIN)
#include "ezio/io_context.h"
#endif
namespace ezio {
class EventLoop;
class Acceptor {
public:
using NewConnectionHandler = std::function<void(ScopedSocket&&, const SocketAddress&)>;
Acceptor(EventLoop* loop, const SocketAddress& addr);
~Acceptor();
DISALLOW_COPY(Acceptor);
DISALLOW_MOVE(Acceptor);
void Listen();
void set_on_new_connection(NewConnectionHandler handler)
{
on_new_connection_ = std::move(handler);
}
bool listening() const noexcept
{
return listening_;
}
private:
#if defined(OS_WIN)
void PostAccept();
#endif
void HandleNewConnection();
private:
EventLoop* loop_;
ScopedSocket listening_sock_;
Notifier listening_notifier_;
NewConnectionHandler on_new_connection_;
#if defined(OS_POSIX)
kbase::ScopedFD sentinel_fd_;
#elif defined(OS_WIN)
ScopedSocket accept_conn_;
IORequest accept_req_;
#endif
bool listening_;
};
} // namespace ezio
#endif // EZIO_ACCEPTOR_H_
|
0b5302cbf6ddeef0bbadb1b068165adcbff545aa | 87f0383e90f08036009897d537ac4e2ebdfacd90 | /programs/Config/include/DataWindowInterface.h | 50f8d08945105643624e1650ac613580c22a235d | [] | no_license | mcdullfeng/GnuRadar | 2256157c6c8fe69bc0f95ad2bcb9f17187fdbf5a | 75c004202fbed84309212850692d7b9e41f56f49 | refs/heads/master | 2021-01-18T11:54:31.255185 | 2011-09-13T00:22:09 | 2011-09-13T00:22:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,183 | h | DataWindowInterface.h | // Copyright (c) 2010 Ryan Seal <rlseal -at- gmail.com>
//
// This file is part of GnuRadar Software.
//
// GnuRadar 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 3 of the License, or
// (at your option) any later version.
//
// GnuRadar 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 GnuRadar. If not, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////////////
///DataWindowInterface.h
///
///Used to add/remove data window used in data acquisition
///
///Author: Ryan Seal
///Modified: 08/06/08
////////////////////////////////////////////////////////////////////////////////
#ifndef DATA_WINDOW_INTERFACE_H
#define DATA_WINDOW_INTERFACE_H
#include <FL/Fl_Int_Input.H>
#include <FL/Fl_Choice.h>
#include <FL/fl_ask.H>
#include "CustomTab.h"
#include "DataGroup.h"
#include "UsrpConfigStruct.h"
#include "DataWindowStruct.h"
#include "DataWindowPredicate.h"
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <vector>
using std::cout;
using std::endl;
using std::string;
using std::vector;
using boost::shared_ptr;
namespace USRP {
typedef shared_ptr<DataGroup> DataGroupPtr;
};
///\todo Add rule checking to DataWindowInterface
///Class definition
class DataWindowInterface : public CustomTab {
vector<USRP::DataGroupPtr> dataGroupArray_;
UsrpConfigStruct& usrpConfigStruct_;
int numWindows_;
bool defaultWindow_;
bool arrayTouched_;
int x0_;
int y0_;
int w0_;
int h0_;
static void Update ( Fl_Widget* flw, void* userData ) {
DataGroup* dgPtr = reinterpret_cast<DataGroup*> ( flw );
const int& id = dgPtr->ID();
cout << "DataWindowInterface::Update - state change from ID " << id << endl;
UsrpConfigStruct* ucsPtr = reinterpret_cast<UsrpConfigStruct*> ( userData );
USRP::WindowVector& dws = ucsPtr->WindowRef();
//make sure positive values exist for window parameters
if ( dgPtr->WindowValid() ) {
dws[id].name = dgPtr->Label();
dws[id].start = dgPtr->Start();
dws[id].size = dgPtr->Size();
dws[id].units = dgPtr->Units();
} else {
cerr << "DataWindowInterface::Update - invalid window settings detected "
<< "in window " << id << " - global structure not updated." << endl;
}
}
void RemoveAll();
public:
///Constructor
DataWindowInterface ( UsrpConfigStruct& usrpConfigStruct, int x, int y,
int width = 325, int height = 245, const char* label = NULL );
void Add ( const string& label );
void Remove ( const string label );
void Modify ( const string oldLabel, const string newLabel );
void Units ( const int& units );
void Load();
};
#endif
|
097e65b35a48a07e9f6212e8e3f7d8077b4d58b3 | e2e37fd592fa0cbdbf068467246c424a874c139f | /src/twist_marker.cpp | c22b31cc7bfc663aa3c4b95b9619d131de009f4a | [] | no_license | zachlambert/cga-robotics-ros | 634d964428de229398871f4f1acadcf20ee65e50 | 8aa4c43d8f50978a4ace95a6507218d3b9d995db | refs/heads/master | 2023-05-02T00:32:08.648594 | 2021-05-26T20:17:14 | 2021-05-26T20:17:14 | 329,368,425 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,834 | cpp | twist_marker.cpp | #include <ros/ros.h>
#include <geometry_msgs/PoseStamped.h>
#include <geometry_msgs/TwistStamped.h>
#include <geometry_msgs/Vector3.h>
#include <geometry_msgs/Quaternion.h>
#include <visualization_msgs/Marker.h>
#include <Eigen/Core>
#include <Eigen/Geometry>
void configure_arrow(
const geometry_msgs::PoseStamped pose,
const geometry_msgs::Vector3 vector,
visualization_msgs::Marker &arrow)
{
arrow.header.frame_id = pose.header.frame_id;
arrow.header.stamp = ros::Time::now();
arrow.ns = "";
arrow.id = 0;
arrow.type = visualization_msgs::Marker::ARROW;
arrow.pose.position = pose.pose.position;
// Quaternion rotates from [1 0 0] to vector;
Eigen::Vector3d a(1, 0, 0);
Eigen::Vector3d b(vector.x, vector.y, vector.z);
auto quat = Eigen::Quaterniond::FromTwoVectors(a, b.normalized());
arrow.pose.orientation.x = quat.x();
arrow.pose.orientation.y = quat.y();
arrow.pose.orientation.z = quat.z();
arrow.pose.orientation.w = quat.w();
arrow.scale.x = b.norm();
arrow.scale.y = 0.01;
arrow.scale.z = 0.01;
}
class Node {
public:
Node(ros::NodeHandle &n)
{
ee_pose_sub = n.subscribe(
"ee_pose", 1, &Node::ee_pose_callback, this
);
ee_twist_sub = n.subscribe(
"ee_twist", 1, &Node::ee_twist_callback, this
);
loop_timer = n.createTimer(ros::Duration(1.0/20), &Node::loop, this);
linear_pub = n.advertise<visualization_msgs::Marker>(
"ee_twist_linear", 1
);
angular_pub = n.advertise<visualization_msgs::Marker>(
"ee_twist_angular", 1
);
}
void ee_pose_callback(const geometry_msgs::PoseStamped &ee_pose)
{
this->ee_pose = ee_pose;
}
void ee_twist_callback(const geometry_msgs::TwistStamped &ee_twist)
{
this->ee_twist = ee_twist;
}
void loop(const ros::TimerEvent &timer)
{
visualization_msgs::Marker linear;
configure_arrow(ee_pose, ee_twist.twist.linear, linear);
linear.color.a = 1.0;
linear.color.r = 0;
linear.color.g = 1.0;
linear.color.b = 1.0;
linear_pub.publish(linear);
visualization_msgs::Marker angular;
configure_arrow(ee_pose, ee_twist.twist.angular, angular);
angular.color.a = 1.0;
angular.color.r = 1.0;
angular.color.g = 1.0;
angular.color.b = 0;
angular_pub.publish(angular);
}
private:
ros::Subscriber ee_pose_sub, ee_twist_sub;
geometry_msgs::PoseStamped ee_pose;
geometry_msgs::TwistStamped ee_twist;
ros::Publisher linear_pub, angular_pub;
ros::Timer loop_timer;
};
int main(int argc, char **argv)
{
ros::init(argc, argv, "twist_marker");
ros::NodeHandle n;
Node node(n);
ros::spin();
}
|
25fd1f5f89690e6e0a8577a2e68e069c353e8a9b | c1d5274184a3a701e1243994ccacadb3ef1fbbe5 | /Daemon/daemon.h | 6771e34385d899d6d376f7e94c26e0c76be8c0eb | [] | no_license | svitkovsergey/TRIKdashboard | 5644155d918de85c8005e87d8d1283d5ac232fe6 | 8a8d2740df02781b84a8f7b93f8d56c105fcd4d9 | refs/heads/master | 2021-06-07T08:11:10.362358 | 2016-09-21T18:18:12 | 2016-09-21T18:18:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,521 | h | daemon.h | #pragma once
#include <QObject>
#include <QVector>
#include <QTimer>
#include "brickInterface.h"
#include "accelobserver.h"
#include "batteryobserver.h"
#include "encoderobserver.h"
#include "powermotorobserver.h"
#include "gyroobserver.h"
#include "tcpcommunicator.h"
#include "udpcommunicator.h"
#include "telemetry_const.h"
class Daemon : public QObject
{
Q_OBJECT
public:
explicit Daemon(QThread *guiThread, QString configPath);
void attach(Observer *obs);
signals:
public slots:
private slots:
void testSensors(int times);
void notify();
void zipPackage();
void startTelemetry();
void closeTelemetry();
const void parseMessage(QString message) const;
private:
trikControl::BrickInterface *brick = nullptr;
TcpCommunicator *tcpCommunicator = nullptr;
UdpCommunicator *udpCommunicator = nullptr;
QVector<Observer*> observers = QVector<Observer*>();
GyroObserver *gyroObserver = nullptr;
AccelObserver *accelObserver = nullptr;
BatteryObserver* batteryObserver = nullptr;
PowerMotorObserver* powerMotor1 = nullptr;
PowerMotorObserver* powerMotor2 = nullptr;
PowerMotorObserver* powerMotor3 = nullptr;
PowerMotorObserver* powerMotor4 = nullptr;
EncoderObserver* encoder1 = nullptr;
EncoderObserver* encoder2 = nullptr;
EncoderObserver* encoder3 = nullptr;
EncoderObserver* encoder4 = nullptr;
QTimer timer;
int updatePeriod;
};
|
35a0409c59c20b45e05a5fbfc94ac1914b6f9a35 | d973b3a5ca390ecceceb630a09873d9f4cee29f1 | /BOJ/그래프/위상정렬/1516_게임 개발.cpp | f8369fe4931804eb671e46a1da24b2bf27b22347 | [] | no_license | hschoi1104/Algorithm | f06a111f44e674b38f1e0d65193b4b98ab8ac7d5 | 8317a843354c2530590c871d8a10850a0303f18a | refs/heads/master | 2023-08-09T13:01:22.646030 | 2023-08-02T08:02:43 | 2023-08-02T08:02:43 | 201,705,544 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,009 | cpp | 1516_게임 개발.cpp | #include <stdio.h>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;
vector<vector<int>>v;
queue<pair<int, int>>q;
int in[502];
int time[502];
int finish[502];
int visited[502];
void bfs() {
while (!q.empty()) {
auto cur = q.front();
visited[cur.first] = 1;
q.pop();
for (int i = 0; i < v[cur.first].size(); i++) {
int next = v[cur.first][i];
in[next]--;
finish[next] = max(finish[next], cur.second + time[next]);
if (visited[next] == 0 && in[next] == 0) {
q.push({ next, finish[next] });
}
}
}
}
int main() {
int n, x, a, b;
scanf("%d", &n);
v.resize(n + 1);
for (int i = 1; i <= n; i++) {
int cnt = 0;
while (cnt += 1) {
scanf("%d", &x);
if (x == -1) break;
if (cnt == 1) time[i] = x;
else {
v[x].push_back(i);
in[i] += 1;
}
}
}
for (int i = 1; i <= n; i++) {
if (in[i] == 0) {
q.push({ i,time[i] });
finish[i] = time[i];
}
}
bfs();
for (int i = 1; i <= n; i++) printf("%d\n", finish[i]);
return 0;
} |
b9d1c52fd827c36f415fdb4e2443866319bec35d | ff93b3d44693687f0e8dd9dec525ce4ac08c317c | /agents/minilibs/CmdRoute.cpp | 3611cff50d2d80e96a59eb8fc86123f5a4435949 | [] | no_license | agiordana/HAT | 6ea2b5a6b3a635e6702ccf8573133a65c8c14c9a | f61f0783c8d9f9d4e3b1374eb6475f4d88f95ff9 | refs/heads/master | 2020-12-24T07:54:07.078444 | 2018-10-01T12:39:05 | 2018-10-01T12:39:05 | 59,103,594 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,329 | cpp | CmdRoute.cpp | #include "agentlib.h"
MMessage CmdRoute::exec(std::string uri, std::vector<std::string> params, std::string method, std::string body) {
MMessage mreq, mresp, rpcanswer;
rpcanswer.clear();
size_t i;
string dummy = "*";
mresp.add("content", "plain/text");
if (params.size() < 3){
mresp.add("body", "Not Found");
return mresp;
}
mreq = MMessage("cmd");
if (uri != "") {
if(params[0] == "cmd" || params[0] == "cmdw") mreq.mtype= "cmd";
else if(params[0] == "set" || params[0] == "setw") mreq.mtype= "set";
mreq.add("url", uri);
} else {
mreq.add("url", ".");
}
if (method == "cmdExec") {
mreq.msubtype = params[1];
mreq.add("value", params[2]);
if(body !="") addBody(mreq, body);;
if (SubjectSet::check_subject(mreq.mtype, params[1])||SubjectSet::check_subject(mreq.mtype,dummy)) {
if((params[0] == "cmdw" || params[0] == "setw") && hsrv::rpctab != NULL) hsrv::rpctab->callRegister(mreq);
SubjectSet::notify(mreq);
}
if((params[0] == "cmdw" || params[0] == "setw") && hsrv::rpctab != NULL) {
rpcanswer = hsrv::rpctab->wait(mreq.getString("tag"));
}
}
else if (method == "webcmdExec") {
for (i=0; i<params.size() && params[i]!="Devices"; i++);
if (i >= params.size()-2 || params[i] != "Devices") {
mresp.add("body", "Not Found");
return mresp;
}
mreq.msubtype = params[i+1];
mreq.add("value", FileManager::getStem(params[i+2]));
if (SubjectSet::check_subject(mreq.mtype, mreq.msubtype)||SubjectSet::check_subject(mreq.mtype,dummy)) {
SubjectSet::notify(mreq);
}
}
if(rpcanswer.getString("answer_tag") != "") {
string value = rpcanswer.getString("value");
mresp.add("body", "done:"+value);
}
else mresp.add("body", "done");
return mresp;
}
bool CmdRoute::addBody(MMessage& m, std::string body) {
if(isHtml(body)) {
NameList tmp;
tmp.init(body,'&');
for(size_t i=0; i<tmp.size(); i++) {
NameList row;
row.init(tmp[i], '=');
if(row.size()==2) m.add(row[0], row[1]);
}
}
else {
m.add("body", body);
}
return true;
}
bool CmdRoute::isHtml(std::string& body) {
if(body.find("&")!=std::string::npos) return true;
else return false;
}
|
78dd3f72e647df445d0e58b6385398846c7dc765 | b013562927e347376bfd43b57be229fda60cb607 | /ax_core/include/ax/core/data_structure/axConnection.h | f8d9f578242912c6ef20d9c260a13edf2683bf17 | [] | no_license | Jasonchan35/libax | 82102e2b2fa577f333815f99709ebbb9250ec9f5 | 931f18f8baf46b1e7087ea93a5f0c2ee667a540c | refs/heads/master | 2021-05-04T10:02:13.008748 | 2018-06-23T16:48:21 | 2018-06-23T16:48:21 | 46,000,639 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,922 | h | axConnection.h | //
// axConnection.h
// ax_core
//
// Created by Jason on 2012-09-29.
//
//
#ifndef ax_core_axConnection_h
#define ax_core_axConnection_h
template<class T> class axConnection;
template<class T> class axConnector;
//---------------------------
template<class T>
class axConnector {
public:
class Input : public axNonCopyable {
public:
Input() : head_(NULL) {}
T* head () { return head_; }
const T* head () const { return head_; }
void insert ( T* conn );
void remove ( T* conn );
void clear () { while( head_ ) { delete head_; } }
private:
T* head_;
};
class Output : public axNonCopyable {
public:
Output() : head_(NULL) {}
T* head () { return head_; }
const T* head () const { return head_; }
void insert ( T* conn );
void remove ( T* conn );
void clear () { while( head_ ) { delete head_; } }
private:
T* head_;
};
void clear() { input.clear(); output.clear(); }
Input input;
Output output;
};
template<class T>
class axConnection {
public:
typedef axConnector<T> List;
~axConnection();
void removeFromList();
bool isInList();
class Input : public axNonCopyable {
public:
Input() : prev_(NULL), next_(NULL), list_(NULL) {}
T* prev() { return prev_; }
const T* prev() const { return prev_; }
T* next() { return next_; }
const T* next() const { return next_; }
friend class List::Input;
friend class axConnection<T>;
protected:
T* prev_;
T* next_;
typename List::Input* list_;
};
class Output : public axNonCopyable {
public:
Output() : prev_(NULL), next_(NULL), list_(NULL) {}
T* prev() { return prev_; }
const T* prev() const { return prev_; }
T* next() { return next_; }
const T* next() const { return next_; }
friend class List::Output;
friend class axConnection<T>;
protected:
T* prev_;
T* next_;
typename List::Output* list_;
};
Input input;
Output output;
protected:
void connect ( typename List::Input & inList, typename List::Output & outList );
};
//------ inline -------
template<class T> inline
axConnection<T> :: ~axConnection() {
removeFromList();
}
template<class T> inline
void axConnection<T> :: removeFromList() {
if( input.list_ ) input.list_ ->remove( (T*)this );
if( output.list_ ) output.list_->remove( (T*)this );
}
template<class T> inline
bool axConnection<T> :: isInList() {
if( input.list_ || output.list_ ) return true;
return false;
}
template<class T> inline
void axConnector<T>::Output :: insert( T* conn ) {
assert( conn->output.prev_ == NULL );
assert( conn->output.next_ == NULL );
if( head_ ) head_->output.prev_ = conn;
conn->output.prev_ = NULL;
conn->output.next_ = head_;
conn->output.list_ = this;
head_ = conn;
}
template<class T> inline
void axConnector<T>::Output :: remove( T* conn ) {
assert( conn->output.list_ == this );
if( conn->output.prev_ ) {
conn->output.prev_->output.next_ = conn->output.next_;
}else{
head_ = conn->output.next_;
}
if( conn->output.next_ ) {
conn->output.next_->output.prev_ = conn->output.prev_;
}
conn->output.next_ = NULL;
conn->output.prev_ = NULL;
conn->output.list_ = NULL;
}
template<class T> inline
void axConnector<T>::Input :: insert( T* conn ) {
assert( conn->input.prev_ == NULL );
assert( conn->input.next_ == NULL );
if( head_ ) head_->input.prev_ = conn;
conn->input.prev_ = NULL;
conn->input.next_ = head_;
conn->input.list_ = this;
head_ = conn;
}
template<class T> inline
void axConnector<T>::Input :: remove( T* conn ) {
assert( conn->input.list_ == this );
if( conn->input.prev_ ) {
conn->input.prev_->input.next_ = conn->input.next_;
}else{
head_ = conn->input.next_;
}
if( conn->input.next_ ) {
conn->input.next_->input.prev_ = conn->input.prev_;
}
conn->input.next_ = NULL;
conn->input.prev_ = NULL;
conn->input.list_ = NULL;
}
#endif
|
002e2db4e0b71b9bedbab95ea4a4e667d3761ec4 | 016c5987d47e59cbf3e3a1ab3b38dd41ce40e53f | /mpmissions/Mission.Altis/dialog/key_chain.hpp | 6b95b274a7e36d7ef23f948ae69b5a625f3226fa | [] | no_license | arma3code/altislife | 160183888699a6cca24fa7ebeb967f6f4872691d | d88776d9ce3a71b3458a6a722362802a90cc481e | refs/heads/master | 2021-08-08T21:38:08.121179 | 2017-11-11T09:18:36 | 2017-11-11T09:18:36 | 110,332,225 | 6 | 12 | null | null | null | null | UTF-8 | C++ | false | false | 2,199 | hpp | key_chain.hpp | class UnionDialogKeyManagement {
idd = 2700;
name= "UnionDialogKeyManagement";
movingEnable = 0;
enableSimulation = 1;
onLoad = "[_this select 0] call UnionClient_gui_Tiles; [] spawn UnionClient_system_keyMenu;";
class controlsBackground {
class Blackout: RscText
{
idc = -1;
x = "safezoneX";
y = "safezoneY";
w = "safezoneW";
h = "safezoneH";
colorBackground[] = { 0, 0, 0, 0.5 };
};
class Tiles: RscTiles {};
class padImage : RscPicture {
idc = 2704;
text = "";
x = -0.0875004;
y = -0.38;
w = 1.175;
h = 1.72;
};
class BackButton: RscPictureButtonMenu
{
idc = -1;
text = "";
onButtonClick = "closeDialog 0; [] spawn UnionClient_pad_openMain";
tooltip = "$STR_PM_BackToMainMenu";
colorBackground[] = {1,1,1,0.004};
colorBackgroundFocused[] = {1,1,1,0.008};
colorBackground2[] = {0.75,0.75,0.75,0.004};
x = 0.375001;
y = 0.86;
w = 0.0624999;
h = 0.06;
};
class HomeButton: RscPictureButtonMenu
{
idc = -1;
text = "";
onButtonClick = "closeDialog 0";
tooltip = "$STR_Global_Close";
colorBackground[] = {1,1,1,0.004};
colorBackgroundFocused[] = {1,1,1,0.008};
colorBackground2[] = {0.75,0.75,0.75,0.004};
x = 0.462499;
y = 0.86;
w = 0.075;
h = 0.06;
};
};
class controls {
class Title : RscTitle {
colorBackground[] = {1,1,1,0.2};
idc = -1;
text = "$STR_Keys_Title";
x = 0.0374988;
y = 0.1;
w = 0.925;
h = 0.04;
};
class KeyChainList : RscListBox
{
idc = 2701;
text = "";
x = 0.0374988;
y = 0.16;
w = 0.925;
h = 0.4;
};
class NearPlayers : RscCombo {
idc = 2702;
x = 0.0374988;
y = 0.58;
w = 0.2625;
h = 0.04;
};
class DropKey : RscButtonMenu {
idc = -1;
text = "$STR_Keys_DropKey";
onButtonClick = "[] call UnionClient_system_keyDrop";
x = 0.737499;
y = 0.58;
w = 0.225;
h = 0.04;
};
class GiveKey : RscButtonMenu {
idc = 2703;
text = "$STR_Keys_GiveKey";
onButtonClick = "[] call UnionClient_system_keyGive";
x = 0.312501;
y = 0.58;
w = 0.2625;
h = 0.04;
};
};
}; |
da0c59895ecec85792f71d653ec94166e7473d1d | 78223e4b15d5c0794e7fb978c068d63861b899a3 | /dialogsslerrors.cpp | f0079e133ea38a0591974d01ce90e126f4bf7bac | [
"MIT"
] | permissive | rpoisel/telnetssl | 3a012d912dbeba54ef38497680ee71909b1733ca | 46be271e9200c22fd3e1ac4083f9a0fb88ec1ef6 | refs/heads/master | 2016-09-06T19:21:52.680501 | 2014-02-24T15:18:02 | 2014-02-24T15:18:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 526 | cpp | dialogsslerrors.cpp | #include <dialogsslerrors.h>
#include <qcolor.h>
#include <qlistwidget.h>
#include <qstring.h>
#include <ui_dialogsslerrors.h>
DialogSslErrors::DialogSslErrors(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogSslErrors)
{
ui->setupUi(this);
}
DialogSslErrors::~DialogSslErrors()
{
delete ui;
}
void DialogSslErrors::addError(QString errorMessage)
{
QListWidgetItem* item = new QListWidgetItem(errorMessage);
item->setForeground(QColor::fromRgb(255, 0, 0));
ui->listWidget->addItem(item);
}
|
3dd301940e4b98d64f9830dec2ac15c294d9f435 | c8ba735922784b283ef6333a641acb325228085e | /Components/Metrics/PointToSurfaceDistance/elxPointToSurfaceDistanceMetric.hxx | 13da141982413d32be4e30b92e4708540b220d42 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | gokhangg/elastix | a9520455b3273f425a5d2e01772d47eddd51d86a | 7a793af5d663a7a2bf2f18d42ca50f84a3e88a8f | refs/heads/develop | 2021-06-03T09:15:33.867838 | 2020-04-04T10:28:48 | 2021-02-05T13:23:51 | 252,985,709 | 0 | 0 | Apache-2.0 | 2020-04-04T12:03:05 | 2020-04-04T12:03:04 | null | UTF-8 | C++ | false | false | 6,790 | hxx | elxPointToSurfaceDistanceMetric.hxx | /*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* 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.txt
*
* 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 __elxPointToSurfaceDistanceMetric_HXX__
#define __elxPointToSurfaceDistanceMetric_HXX__
#include "elxPointToSurfaceDistanceMetric.h"
#include "itkTransformixInputPointFileReader.h"
namespace elastix
{
/**
* ******************* Initialize ***********************
*/
template< class TElastix >
void
PointToSurfaceDistanceMetric< TElastix >
::Initialize( void )
{
}
/**
* ***************** BeforeAllBase ***********************
*/
template< class TElastix >
int
PointToSurfaceDistanceMetric< TElastix >
::BeforeAllBase()
{
this->Superclass2::BeforeAllBase();
/** Check if the current configuration uses this metric. */
unsigned int count = 0;
for( unsigned int i = 0; i < this->m_Configuration->CountNumberOfParameterEntries( "Metric" ); ++i )
{
std::string metricName = "";
this->m_Configuration->ReadParameter( metricName, "Metric", i );
if( metricName == "PointToSurfaceDistance" ) { count++; }
}
if( count == 0 ) { return 0; }
/** Check Command line options and print them to the log file. */
elxout << "Command line options from PointToSurfaceDistanceMetric:" << std::endl;
/** Check for appearance of parameter "PointToSurfaceDistanceAverage". */
std::string PointToSurfaceDistanceAverageStr = "true";
this->m_AvPointWeigh = true;
if (this->m_Configuration->CountNumberOfParameterEntries( "PointToSurfaceDistanceAverage" ) == 1)
{
this->m_Configuration->ReadParameter( PointToSurfaceDistanceAverageStr, "PointToSurfaceDistanceAverage", 0 );
if (PointToSurfaceDistanceAverageStr == "false") this->m_AvPointWeigh = false;
}
elxout << "\nAverage of points in annotation set : "
<< PointToSurfaceDistanceAverageStr <<"\n"
<< std::endl;
/** Check for appearance of "-fp". */
auto _fp = this->m_Configuration->GetCommandLineArgument( "-fp" );
if( _fp.empty() )
{
elxout << "-fp unspecified" << std::endl;
}
else
{
elxout << "-fp " << _fp << std::endl;
}
/** Check for appearance of "-dt". */
auto _dt = this->m_Configuration->GetCommandLineArgument( "-dt" );
if( _dt.empty() )
{
elxout << "-dt unspecified" << std::endl;
}
else
{
elxout << "-dt " << _dt << std::endl;
this->Superclass1::SetDTImageIn(_dt);
}
/** Check for appearance of "-seg". */
auto _seg = this->m_Configuration->GetCommandLineArgument( "-seg" );
if( _seg.empty() )
{
elxout << "-seg unspecified" << std::endl;
}
else
{
elxout << "-seg " << _seg << std::endl;
this->Superclass1::SetSegImageIn(_seg);
}
/** Check for appearance of "-dtout". */
auto _dtout = this->m_Configuration->GetCommandLineArgument( "-dtout" );
if( _dtout.empty() )
{
elxout << "-dtout unspecified" << std::endl;
}
else
{
elxout << "-dtout " << _dtout << std::endl;
this->Superclass1::SetDTImageOut(_dtout);
}
this->Superclass1::Initialize();
return 0;
}
/**
* ***************** BeforeRegistration ***********************
*/
template< class TElastix >
void
PointToSurfaceDistanceMetric< TElastix >
::BeforeRegistration()
{
/** Read and set the fixed pointset. */
auto fixedPointsetFileName = this->GetConfiguration()->GetCommandLineArgument( "-fp" );
typename PointSetType::Pointer fixedPointSet;
const typename FixedImageType::ConstPointer Image = this->GetElastix()->GetFixedImage();
ReadLandmarks( fixedPointsetFileName, fixedPointSet, Image );
this->SetFixedPointSet( fixedPointSet );////this is pointset interface for the layer a code
}
/**
* ***************** ReadLandmarks ***********************
*/
template< class TElastix >
unsigned int
PointToSurfaceDistanceMetric< TElastix >
::ReadLandmarks( const std::string & landmarkFileName, typename PointSetType::Pointer & pointSet, const typename FixedImageType::ConstPointer image )
{
using PointSetReaderType = itk::TransformixInputPointFileReader<PointSetType >;
elxout << "Loading landmarks for " << this->GetComponentLabel()
<< ":" << this->elxGetClassName() << "." << std::endl;
/** Read the landmarks. */
auto reader = PointSetReaderType::New();
reader->SetFileName( landmarkFileName.c_str() );
elxout << " Reading landmark file: " << landmarkFileName << std::endl;
try
{
reader->Update();
}
catch( itk::ExceptionObject & err )
{
xl::xout[ "error" ] << " Error while opening " << landmarkFileName << std::endl;
xl::xout[ "error" ] << err << std::endl;
itkExceptionMacro( << "ERROR: unable to configure " << this->GetComponentLabel() );
}
/** Some user-feedback. */
const auto nrofpoints = reader->GetNumberOfPoints();
if( reader->GetPointsAreIndices() )
{
elxout << " Landmarks are specified as image indices." << std::endl;
}
else
{
elxout << " Landmarks are specified in world coordinates." << std::endl;
}
elxout << " Number of specified points: " << nrofpoints << std::endl;
/** Get the pointset. */
pointSet = reader->GetOutput();
/** Convert from index to point if necessary */
pointSet->DisconnectPipeline();
if( reader->GetPointsAreIndices() )
{
/** Convert to world coordinates */
for( auto j = 0u; j < nrofpoints; ++j )
{
/** The landmarks from the pointSet are indices. We first cast to the
* proper type, and then convert it to world coordinates.
*/
typename ImageType::PointType point;
typename ImageType::IndexType index;
pointSet->GetPoint( j, &point );
for( auto d = 0u; d < FixedImageDimension; ++d )
{
index[ d ] = static_cast<typename ImageType::IndexValueType>( itk::Math::Round< double >( point[ d ] ) );
}
/** Compute the input point in physical coordinates. */
image->TransformIndexToPhysicalPoint( index, point );
pointSet->SetPoint( j, point );
} // end for all points
} // end for points are indices
return nrofpoints;
}
} // end namespace elastix
#endif // end #ifndef __elxPointToSurfaceDistanceMetric_HXX__
|
1c953995c67f2e9c69217934f47fe496101b6ce1 | 572e221485e1ff3c0025d570b69304fd9c776550 | /SystemImpl.h | d53d185ccf28956971e24324d6026a32d1caba18 | [] | no_license | duenti/Software-Enginner | b0237add3001f92f4969a23592d09387d64c40df | aed394af02ee84fe7fe5ea4624b9886ca477e28f | refs/heads/master | 2016-09-08T01:44:31.639127 | 2014-12-18T03:10:45 | 2014-12-18T03:10:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,051 | h | SystemImpl.h | #include <string>
#include <vector>
#include <list>
#include <iostream>
#include "System.h"
#include "HandleBody.h"
using namespace std;
#ifndef SYSTEM_BODY_H
#define SYSTEM_BODY_H
#define DEBUGING
#ifdef DEBUGING
extern int numHandleCreated;
extern int numHandleDeleted;
extern int numBodyCreated;
extern int numBodyDeleted;
#endif
class SystemBody : public Body{
public:
SystemBody();
SystemBody(double v);
virtual ~SystemBody();
virtual void setValue(double);
virtual void addValue(double);
virtual void redValue(double);
virtual string getName();
virtual void setName(string);
virtual double getValue();
virtual void addResult(double);
virtual void clearResult();
virtual vector<double> impress();
virtual int getID();
virtual void setID(int);
private:
SystemBody(const SystemBody&);
SystemBody& operator=(const SystemBody&);
protected:
int idsav_;
string name_;
double value_;
vector<double> result_;
};
#endif
#ifndef SYSTEMHANDLE_H_
#define SYSTEMHANDLE_H_
class SystemHandle : public System, public Handle<SystemBody>
{
public:
SystemHandle(){
pImpl_->setValue(0);
pImpl_->attach();
}
SystemHandle(double n){
pImpl_->setValue(n);
pImpl_->attach();
}
virtual ~SystemHandle(){
pImpl_->detach();
}
virtual void setValue(double v){ return pImpl_->setValue(v);}
virtual void addValue(double v){ return pImpl_->addValue(v);}
virtual void redValue(double v){ return pImpl_->redValue(v);}
virtual string getName(){ return pImpl_->getName();}
virtual void setName(string t) { return pImpl_->setName(t);}
virtual double getValue(){ return pImpl_->getValue();}
virtual void addResult(double r){ return pImpl_->addResult(r);}
virtual void clearResult(){ return pImpl_->clearResult();}
virtual vector<double> impress(){return pImpl_->impress();}
virtual int getID(){return pImpl_->getID();}
virtual void setID(int id){return pImpl_->setID(id);}
};
#endif
|
7b58a45ec40d3439d7adea3ef7abd16ccc8169cb | f0b7bcc41298354b471a72a7eeafe349aa8655bf | /codebase/libs/euclid/src/include/euclid/WorldPolygon2D.hh | 3eff6700bdbfc70df220ca62335f834760a9a9a3 | [
"BSD-3-Clause"
] | permissive | NCAR/lrose-core | 23abeb4e4f1b287725dc659fb566a293aba70069 | be0d059240ca442883ae2993b6aa112011755688 | refs/heads/master | 2023-09-01T04:01:36.030960 | 2023-08-25T00:41:16 | 2023-08-25T00:41:16 | 51,408,988 | 90 | 53 | NOASSERTION | 2023-08-18T21:59:40 | 2016-02-09T23:36:25 | C++ | UTF-8 | C++ | false | false | 8,354 | hh | WorldPolygon2D.hh | // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
// ** Copyright UCAR (c) 1990 - 2016
// ** University Corporation for Atmospheric Research (UCAR)
// ** National Center for Atmospheric Research (NCAR)
// ** Boulder, Colorado, USA
// ** BSD licence applies - redistribution and use in source and binary
// ** forms, with or without modification, are permitted provided that
// ** the following conditions are met:
// ** 1) If the software is modified to produce derivative works,
// ** such modified software should be clearly marked, so as not
// ** to confuse it with the version available from UCAR.
// ** 2) Redistributions of source code must retain the above copyright
// ** notice, this list of conditions and the following disclaimer.
// ** 3) 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.
// ** 4) Neither the name of UCAR nor the names of its contributors,
// ** if any, may be used to endorse or promote products derived from
// ** this software without specific prior written permission.
// ** DISCLAIMER: THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
// ** OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
/************************************************************************
* WorldPolygon2D.hh: class implementing a polygon specified by
* WorldPoint2D points.
*
* RAP, NCAR, Boulder CO
*
* January 1999
*
* Nancy Rehak
*
************************************************************************/
#ifndef WorldPolygon2D_HH
#define WorldPolygon2D_HH
#include <cstdio>
#include <vector>
#include <euclid/Pjg.hh>
#include <euclid/WorldPoint2D.hh>
typedef float fl32;
using namespace std;
class WorldPolygon2D
{
public:
// Constructors
WorldPolygon2D();
WorldPolygon2D(const WorldPolygon2D& rhs);
// Destructor
~WorldPolygon2D(void);
/////////////////////////////////
// Polygon maintenance methods //
/////////////////////////////////
// Adds the given point to the end of the polygon. The pointer to the
// point is saved as a part of the polygon, so you must not change the
// values or delete the point object after calling this routine.
void addPoint(WorldPoint2D *point);
void addPoint(const double lat, const double lon);
/**********************************************************************
* growKm() - Increases the size of the polygon all around the perimeter
* by the given length in kilometers.
*/
void growKm(const double growth_km);
/////////////////////////////////
// Polygon calculation methods //
/////////////////////////////////
/**********************************************************************
* calcCentroid() - Calculate the centroid of the polygon.
*/
WorldPoint2D calcCentroid(void);
/**********************************************************************
* extrapolate() - Extrapolate the polyline as specified.
*/
void extrapolate(const double distance_km,
const double direction_rad);
/**********************************************************************
* inPolyline() - Determine if the given point falls within the polyline
* when it is gridded.
*
* Returns the true if the point lies within the polyline, false otherwise.
*/
bool inPolyline(const Pjg &projection,
const double lat, const double lon) const;
/**********************************************************************
* getGridMax() - Get the maximum data value from the given grid within
* this polygon.
*
* Returns the maximum data value found, or missing_data_value if no
* data values were found.
*/
double getGridMax(const Pjg &projection,
const double missing_data_value,
const double bad_data_value,
const fl32 *data_grid) const;
/**********************************************************************
* getGridMin() - Get the minimum data value from the given grid within
* this polygon.
*
* Returns the minimum data value found, or missing_data_value if no
* data values were found.
*/
double getGridMin(const Pjg &projection,
const double missing_data_value,
const double bad_data_value,
const fl32 *data_grid) const;
/**********************************************************************
* getGridAvg() - Get the average data value from the given grid within
* this polygon.
*
* Returns the average data value found, or missing_data_value if no
* data values were found.
*/
double getGridAvg(const Pjg &projection,
const double missing_data_value,
const double bad_data_value,
const fl32 *data_grid) const;
/**********************************************************************
* getGridNumValues() - Get the number of grid squares within this polygon
* with the given data value.
*
* Returns the number of grid points found.
*/
size_t getGridNumValues(const Pjg &projection,
const double data_value,
const fl32 *data_grid) const;
/**********************************************************************
* getGridSize() - Get the number of grid squares within this polygon.
*
* Returns the number of grid squares.
*/
size_t getGridSize(const Pjg &projection) const;
////////////////////
// Access methods //
////////////////////
// Iterate through the points in the polygon. These routines
// return NULL if there is no point to return. To iterate through the
// points list, do something like the following:
//
// for (WorldPoint2D *point = polygon.getFirstPoint();
// point != (WorldPoint2D *)NULL;
// point = polygon.getNextPoint())
// ...
WorldPoint2D *getFirstPoint(void) const;
WorldPoint2D *getNextPoint(void) const;
// Retrieve the number of points in the polygon
int getNumPoints(void) const
{
return _points.size();
}
//////////////////////////
// Input/Output methods //
//////////////////////////
friend ostream& operator<< (ostream&, const WorldPolygon2D*);
friend ostream& operator<< (ostream&, const WorldPolygon2D&);
///////////////
// Operators //
///////////////
WorldPolygon2D& operator= (const WorldPolygon2D &rhs);
protected:
// The points in the polygon
mutable vector< WorldPoint2D* > _points;
// The points list iterator, manipulated using getFirstPoint()
// and getNextPoint()
mutable vector< WorldPoint2D* >::iterator _pointsIterator;
// The gridded version of the polygon. If this pointer is set
// to 0, the grid hasn't been constructed yet and will be constructed
// by a call to _getGriddedPolygon().
mutable Pjg _polygonProjection;
mutable unsigned char *_polygonGrid;
mutable int _minPolygonX;
mutable int _maxPolygonX;
mutable int _minPolygonY;
mutable int _maxPolygonY;
///////////////////////
// Protected methods //
///////////////////////
/**********************************************************************
* _getGriddedPolygon() - Convert the given polygon to a grid on the
* given projection.
*
* Constructs a grid matching the given projection with non-zero entries
* in grid spaces within the polygon and saves the grid in the _polygonGrid
* private member.
*
* Also fills _minPolygonX, _maxPolygonX, _minPolygonY and _maxPolygonY
* members with the minimum and maximum X/Y indices of the polygon in
* the returned grid.
*/
void _getGriddedPolygon(const Pjg &projection) const;
};
#endif
|
401a582421fef0ec20591f57c1dce7914317b6f2 | 9dede60d44eb74a7ec2679f2d650ccabac3c5d71 | /Примеры СИМПР/simpr-volki-zaicy/HasXY.cpp | 3b0660e1c3a015300f08d41f19b511fff943a9bb | [] | no_license | operatie-penguins/Artificial-Intelligence | acc0df0e7c5a9845088145ee121485ba36fe7396 | 0b0d71eea875f70172c880e1055913e2f3ec29fd | refs/heads/master | 2021-01-22T14:38:33.358034 | 2015-01-19T06:11:16 | 2015-01-19T06:11:16 | 24,188,812 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 234 | cpp | HasXY.cpp | //---------------------------------------------------------------------------
#pragma hdrstop
#include "HasXY.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
|
c8ecd20c702ad2f6dd3756349e32e7a2386b1da9 | 94e86a1abfe8e1cc2aaec022c34886f92016d5cb | /tools/NLS/Xlat/Xlat.cpp | 3ef3057130964907c7501b80ea814509594c65e2 | [
"Apache-2.0"
] | permissive | apache/xerces-c | e4bcb76343d63d51d363c7a196c97f75dbea908b | b597a0f79cb97be0d20870f7598b56776596dd7f | refs/heads/master | 2023-08-18T10:25:53.286052 | 2023-06-02T14:56:17 | 2023-06-09T10:15:30 | 233,018,446 | 98 | 78 | Apache-2.0 | 2023-08-18T11:08:27 | 2020-01-10T10:00:34 | C++ | UTF-8 | C++ | false | false | 33,469 | cpp | Xlat.cpp | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id$
*/
// ---------------------------------------------------------------------------
// This program is designed to parse an XML file which holds error text
// data. It will build a DOM tree from that source file and can output it
// a number of different formats.
//
// In order to drastically simplify the program, it is designed only to run
// on platforms/compilers that understand Unicode. It can output the data
// in whatever format is required, so it can handle outputting for other
// platforms. This also simplifies bootstrapping new releases up on other
// platforms. Once the Win32 version is working, it can generate output for
// the other platforms so that they can have loadable text from day one.
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "Xlat.hpp"
// ---------------------------------------------------------------------------
// Static data
//
// gRelativeInputPath
// This is the path, relative to the given input source root, to the
// input file. The given local suffix must also be added to it.
// ---------------------------------------------------------------------------
XMLCh* gRelativeInputPath = 0;
// ---------------------------------------------------------------------------
// Global data
// ---------------------------------------------------------------------------
XMLCh* typePrefixes[MsgTypes_Count];
// ---------------------------------------------------------------------------
// temporary variables/conversion utility functions
// We need different temps depending on treatment of wide characters
// ---------------------------------------------------------------------------
#ifdef longChars
char* fTmpStr = 0;
#else
wchar_t fTmpWStr[256];
#endif
// ---------------------------------------------------------------------------
// Local data
//
// gLocale
// This is the locale suffix, e.g. US_EN, that is used to find the
// correct file and can be used on output files as well. Its set via
// the /Locale= parameter.
//
// gOutFormat
// This is the output format, which is given on the command line as
// /OutFmt= Its mapped to the internal enum which is stored here.
//
// gOutPath
// This is the path to the output path, which is given on the command
// line as /OutPath=. Its just the path, not a name, since the output
// might consist of multiple output files. They will all be based on
// the base part of the input name.
//
// gSrcRoot
// This the path to the root of the build tree. The input files needed
// are found in known places relative to it.
// ---------------------------------------------------------------------------
const XMLCh* gLocale = 0;
OutFormats gOutFormat = OutFormat_Unknown;
const XMLCh* gOutPath = 0;
const XMLCh* gSrcRoot = 0;
// ---------------------------------------------------------------------------
// Local utility methods
// ---------------------------------------------------------------------------
// Initialize the global "constants" (that really require use of the transcoder)
void init_Globals(void)
{
typePrefixes[0] = XMLString::transcode("W_");
typePrefixes[1] = XMLString::transcode("E_");
typePrefixes[2] = XMLString::transcode("F_");
gRelativeInputPath = XMLString::transcode("src/xercesc/NLS/");
}
// Release the global "constants" (that really require use of the transcoder)
void release_Globals(void)
{
for(int i=0; i<3; i++)
{
XMLString::release(&typePrefixes[i]);
}
XMLString::release(&gRelativeInputPath);
}
//
// This method is called to parse the parameters. They must be in this
// order and format, for simplicity:
//
// /SrcRoot=xxx /OutPath=xxx /OutFmt=xxx /Locale=xxx
//
//static bool parseParms(const int argC, XMLCh** argV)
bool parseParms(const int argC, XMLCh** argV)
{
if (argC < 5)
return false;
unsigned int curParm = 1;
XMLCh *tmpXMLStr = XMLString::transcode("/SrcRoot=");
if (XMLString::startsWith(argV[curParm], tmpXMLStr))
{
gSrcRoot = &argV[curParm][9];
}
else
{
wprintf(L"\nExpected /SrcRoot=xxx. Got: %s\n", argV[curParm]);
XMLString::release(&tmpXMLStr);
return false;
}
XMLString::release(&tmpXMLStr);
curParm++;
tmpXMLStr = XMLString::transcode("/OutPath=");
if (XMLString::startsWith(argV[curParm], tmpXMLStr ))
{
gOutPath = &argV[curParm][9];
}
else
{
wprintf(L"\nExpected /OutPath=xxx. Got: %s\n", argV[curParm]);
XMLString::release(&tmpXMLStr);
return false;
}
XMLString::release(&tmpXMLStr);
curParm++;
tmpXMLStr = XMLString::transcode("/OutFmt=");
if (XMLString::startsWith(argV[curParm], tmpXMLStr ))
{
XMLString::release(&tmpXMLStr);
const XMLCh* tmpFmt = &argV[curParm][8];
tmpXMLStr = XMLString::transcode("ResBundle");
XMLCh *tmpXMLStr2 = XMLString::transcode("Win32RC");
XMLCh *tmpXMLStr3 = XMLString::transcode("CppSrc");
XMLCh *tmpXMLStr4 = XMLString::transcode("MsgCat");
if (!XMLString::compareIString(tmpFmt, tmpXMLStr ))
gOutFormat = OutFormat_ResBundle;
else if (!XMLString::compareIString(tmpFmt, tmpXMLStr2 ))
gOutFormat = OutFormat_Win32RC;
else if (!XMLString::compareIString(tmpFmt, tmpXMLStr3 ))
gOutFormat = OutFormat_CppSrc;
else if (!XMLString::compareIString(tmpFmt, tmpXMLStr4 ))
gOutFormat = OutFormat_MsgCatalog;
else
{
wprintf(L"\n'%s' is not a legal output format\n", tmpFmt);
XMLString::release(&tmpXMLStr);
XMLString::release(&tmpXMLStr2);
XMLString::release(&tmpXMLStr3);
XMLString::release(&tmpXMLStr4);
return false;
}
XMLString::release(&tmpXMLStr);
XMLString::release(&tmpXMLStr2);
XMLString::release(&tmpXMLStr3);
XMLString::release(&tmpXMLStr4);
}
else
{
wprintf(L"\nExpected /OutFmt=xxx. Got: %s\n", argV[curParm]);
XMLString::release(&tmpXMLStr);
return false;
}
curParm++;
tmpXMLStr = XMLString::transcode("/Locale=");
if (XMLString::startsWith(argV[curParm], tmpXMLStr ))
{
gLocale = &argV[curParm][8];
}
else
{
wprintf(L"\nExpected /Locale=xxx. Got: %s\n", argV[curParm]);
XMLString::release(&tmpXMLStr);
return false;
}
XMLString::release(&tmpXMLStr);
return true;
}
//static void parseError(const XMLException& toCatch)
void parseError(const XMLException& toCatch)
{
wprintf
(
L"Exception\n (Line.File):%d.%s\n ERROR: %s\n\n"
, toCatch.getSrcLine()
, toCatch.getSrcFile()
, toCatch.getMessage()
);
throw ErrReturn_ParseErr;
}
//static void parseError(const SAXParseException& toCatch)
void parseError(const SAXParseException& toCatch)
{
wprintf
(
L"SAX Parse Error:\n (Line.Col.SysId): %d.%d.%s\n ERROR: %s\n\n"
, toCatch.getLineNumber()
, toCatch.getColumnNumber()
, toCatch.getSystemId()
, toCatch.getMessage()
);
throw ErrReturn_ParseErr;
}
//static void
void
enumMessages( const DOMElement* srcElem
, XlatFormatter* const toCall
, FILE* const headerFl
, const MsgTypes msgType
, unsigned int& count)
{
fwprintf
(
headerFl
, L" , %s%-30s = %d\n"
, xmlStrToPrintable(typePrefixes[msgType])
, longChars("LowBounds")
, count++
);
releasePrintableStr
//
// We just run through each of the child elements, each of which is
// a Message element. Each one represents a message to output. We keep
// a count so that we can output a const value afterwards.
//
DOMNode* curNode = srcElem->getFirstChild();
while (curNode)
{
// Skip over text nodes or comment nodes ect...
if (curNode->getNodeType() != DOMNode::ELEMENT_NODE)
{
curNode = curNode->getNextSibling();
continue;
}
// Convert it to an element node
const DOMElement* curElem = (const DOMElement*)curNode;
// Ok, this should be a Message node
XMLCh *tmpXMLStr = XMLString::transcode("Message");
if (XMLString::compareString(curElem->getTagName(), tmpXMLStr ))
{
wprintf(L"Expected a Message node\n\n");
XMLString::release(&tmpXMLStr);
throw ErrReturn_SrcFmtError;
}
XMLString::release(&tmpXMLStr);
//
// Ok, lets pull out the id, text value, and message type. These are
// to be passed to the formatter. We have to translate the message
// type into one of the offical enum values.
//
tmpXMLStr = XMLString::transcode("Text");
const XMLCh* msgText = curElem->getAttribute(tmpXMLStr );
XMLString::release(&tmpXMLStr);
tmpXMLStr = XMLString::transcode("Id");
const XMLCh* msgId = curElem->getAttribute(tmpXMLStr );
XMLString::release(&tmpXMLStr);
//
// Write out an entry to the target header file. These are enums, so
// we use the id as the enum name.
//
if (XMLString::stringLen(msgText) >= 128) {
wprintf(L"Message text '%s' is too long (%d chars), 128 character limit\n\n", xmlStrToPrintable(msgText),XMLString::stringLen(msgText));
throw ErrReturn_SrcFmtError;
}
fwprintf(headerFl, L" , %-32s = %d\n", xmlStrToPrintable(msgId), count);
releasePrintableStr
// And tell the formatter about this one
toCall->nextMessage
(
msgText
, msgId
, count
, count
);
// Bump the counter, which is also the id assigner
count++;
// Move to the next child of the source element
curNode = curNode->getNextSibling();
}
// Write out an upper range bracketing id for this type of error
fwprintf
(
headerFl
, L" , %s%-30s = %d\n"
, xmlStrToPrintable(typePrefixes[msgType])
, longChars("HighBounds")
, count++
);
releasePrintableStr
}
// ---------------------------------------------------------------------------
// Program entry point
// ---------------------------------------------------------------------------
//
// This is the program entry point. It checks the parms, parses the input
// file to get a DOM tree, then passes the DOM tree to the appropriate
// output method to output the info in a particular format.
//
int Xlat_main(int argC, XMLCh** argV);
int main (int argC, char** argV) {
try
{
XMLPlatformUtils::Initialize();
}
catch(const XMLException& toCatch)
{
wprintf(L"Parser init error.\n ERROR: %s\n\n", toCatch.getMessage());
return ErrReturn_ParserInit;
}
int i;
XMLCh** newArgV = new XMLCh*[argC];
for(i=0;i<argC; i++)
{
newArgV[i] = XMLString::transcode(argV[i]);
}
int toReturn = (Xlat_main(argC,newArgV));
for (i=0; i<argC; i++)
{
XMLString::release(&newArgV[i]);
}
delete [] newArgV;
XMLPlatformUtils::Terminate();
return toReturn;
}
int Xlat_main(int argC, XMLCh** argV)
{
init_Globals();
//
// Lets check the parameters and save them away in globals for use by
// the processing code.
//
if (!parseParms(argC, argV))
{
wprintf(L"Usage:\n NLSXlat /SrcRoot=xx /OutPath=xx /OutFmt=xx /Locale=xx\n\n");
return ErrReturn_BadParameters;
}
{
// Nest entire code in an inner block.
DOMDocument* srcDoc;
const unsigned int bufSize = 4095;
XMLCh *tmpFileBuf = new XMLCh [bufSize + 1];
tmpFileBuf[0] = 0;
XMLCh *tmpXMLStr = XMLString::transcode("/XMLErrList_");
XMLCh *tmpXMLStr2 = XMLString::transcode(".Xml");
try
{
try
{
// Build the input file name
XMLString::catString(tmpFileBuf, gSrcRoot);
XMLString::catString(tmpFileBuf, gRelativeInputPath);
XMLString::catString(tmpFileBuf, gLocale);
XMLString::catString(tmpFileBuf, tmpXMLStr );
XMLString::catString(tmpFileBuf, gLocale);
XMLString::catString(tmpFileBuf, tmpXMLStr2 );
XMLString::release(&tmpXMLStr);
XMLString::release(&tmpXMLStr2);
//
// Ok, lets invoke the DOM parser on the input file and build
// a DOM tree. Turn on validation when we do this.
//
XercesDOMParser parser;
parser.setValidationScheme(AbstractDOMParser::Val_Always);
XlatErrHandler errHandler;
parser.setErrorHandler(&errHandler);
parser.parse(tmpFileBuf);
srcDoc = parser.adoptDocument();
}
catch(const XMLException& toCatch)
{
parseError(toCatch);
}
delete tmpFileBuf;
//
// Use the output format parm to create the correct kind of output
// formatter.
//
XlatFormatter* formatter = 0;
switch(gOutFormat)
{
case OutFormat_CppSrc :
formatter = new CppSrcFormatter;
break;
case OutFormat_Win32RC :
formatter = new Win32RCFormatter;
break;
case OutFormat_MsgCatalog :
formatter = new MsgCatFormatter;
break;
case OutFormat_ResBundle:
formatter = new ICUResBundFormatter;
break;
default :
wprintf(L"Unknown formatter type enum\n\n");
throw ErrReturn_Internal;
}
//
// Lets handle the root element stuff first. This one holds any over
// all information.
//
DOMElement* rootElem = srcDoc->getDocumentElement();
tmpXMLStr = XMLString::transcode("Locale");
const XMLCh* localeStr = rootElem->getAttribute(tmpXMLStr);
XMLString::release(&tmpXMLStr);
// Make sure that the locale matches what we were given
if (XMLString::compareString(localeStr, gLocale))
{
wprintf(L"The file's locale does not match the target locale\n");
throw ErrReturn_LocaleErr;
}
//
// Get a list of all the MsgDomain children. These each hold one of
// the sets of (potentially separately) loadable messages. More
// importantly they all have their own error id space.
//
tmpXMLStr = XMLString::transcode("MsgDomain");
DOMNodeList* msgSetList = rootElem->getElementsByTagName(tmpXMLStr);
XMLString::release(&tmpXMLStr);
//
// Loop through them and look for the domains that we know are
// supposed to be there.
//
const XMLSize_t count = msgSetList->getLength();
//
// Normalize locale string
//
// locale = ll[[_CC][_VARIANT]]
// where ll is language code
// CC is country code
// VARIANT is variant code
//
XMLCh normalizedLocale[256];
normalizedLocale[0] = localeStr[0];
normalizedLocale[1] = localeStr[1];
normalizedLocale[2] = 0;
XMLString::lowerCase(normalizedLocale);
if (XMLString::stringLen(localeStr) > 2)
{
XMLString::catString(&(normalizedLocale[2]), &(localeStr[2]));
XMLString::upperCase(&(normalizedLocale[2]));
}
//
// Ok, its good enough to get started. So lets call the start output
// method on the formatter.
//
formatter->startOutput(normalizedLocale, gOutPath);
//
// For each message domain element, we call start and end domain
// events bracketed around the loop that sends out each message
// in that domain.
//
// Within each domain, we check for the Warning, Error, and Validity
// subelements, and then iterate all the messages in each one.
//
for (unsigned int index = 0; index < count; index++)
{
// We know its a DOM Element, so go ahead and cast it
DOMNode* curNode = msgSetList->item(index);
const DOMElement* curElem = (const DOMElement*)curNode;
//
// Get some of the attribute strings that we need, and transcode
// couple that need to be in local format.
//
tmpXMLStr = XMLString::transcode("Domain");
const XMLCh* domainStr = curElem->getAttribute(tmpXMLStr );
XMLString::release(&tmpXMLStr);
//
// Look at the domain and set up our application specific info
// that is on a per-domain basis. We need to indicate what the
// name of the header is and what the namespace is that they
// codes will go into
//
XMLCh* headerName = 0;
XMLCh* errNameSpace = 0;
if (!XMLString::compareString(domainStr, XMLUni::fgXMLErrDomain))
{
headerName = XMLString::transcode("XMLErrorCodes.hpp");
errNameSpace = XMLString::transcode("XMLErrs");
}
else if (!XMLString::compareString(domainStr, XMLUni::fgValidityDomain))
{
headerName = XMLString::transcode("XMLValidityCodes.hpp");
errNameSpace = XMLString::transcode("XMLValid");
}
else if (!XMLString::compareString(domainStr, XMLUni::fgExceptDomain))
{
headerName = XMLString::transcode("XMLExceptMsgs.hpp");
errNameSpace = XMLString::transcode("XMLExcepts");
}
else if (!XMLString::compareString(domainStr, XMLUni::fgXMLDOMMsgDomain))
{
headerName = XMLString::transcode("XMLDOMMsg.hpp");
errNameSpace = XMLString::transcode("XMLDOMMsg");
}
else
{
// Not one of ours, so skip it
continue;
}
//
// Lets try to create the header file that was indicated for
// this domain.
//
tmpFileBuf = new XMLCh [bufSize + 1];
tmpFileBuf[0] = 0;
XMLString::catString(tmpFileBuf, gOutPath);
XMLString::catString(tmpFileBuf, headerName);
char *tmpFileBufCh = XMLString::transcode(tmpFileBuf);
FILE* outHeader = fopen(tmpFileBufCh, "wt+");
XMLString::release(&tmpFileBufCh);
if ((!outHeader) || (fwide(outHeader, 1) < 0))
{
wprintf(L"Could not open domain header file: %s\n\n", xmlStrToPrintable(tmpFileBuf));
releasePrintableStr
XMLString::release(&tmpFileBuf);
XMLString::release(&headerName);
XMLString::release(&errNameSpace);
throw ErrReturn_OutFileOpenFailed;
}
delete tmpFileBuf;
//
// Write out the opening of the class they are nested within, and
// the header protection define.
//
fwprintf(outHeader, L"// This file is generated, don't edit it!!\n\n");
fwprintf(outHeader, L"#if !defined(XERCESC_INCLUDE_GUARD_ERRHEADER_%s)\n", xmlStrToPrintable(errNameSpace) );
releasePrintableStr
fwprintf(outHeader, L"#define XERCESC_INCLUDE_GUARD_ERRHEADER_%s\n\n", xmlStrToPrintable(errNameSpace) );
releasePrintableStr
// If its not the exception domain, then we need a header included
if (XMLString::compareString(domainStr, XMLUni::fgExceptDomain))
fwprintf(outHeader, L"#include <xercesc/framework/XMLErrorReporter.hpp>\n");
// Write out the namespace declaration
fwprintf(outHeader, L"#include <xercesc/util/XercesDefs.hpp>\n");
fwprintf(outHeader, L"#include <xercesc/dom/DOMError.hpp>\n\n");
fwprintf(outHeader, L"namespace XERCES_CPP_NAMESPACE {\n\n");
// Now the message codes
fwprintf(outHeader, L"class %s\n{\npublic :\n enum Codes\n {\n", xmlStrToPrintable(errNameSpace) );
releasePrintableStr
// Tell the formatter that a new domain is starting
formatter->startDomain
(
domainStr
, errNameSpace
);
//
// Force out the first message, which is always implicit and is
// the 'no error' entry for that domain.
//
unsigned int count = 0;
fwprintf(outHeader, L" %-32s = %d\n", longChars("NoError"), count++);
//
// Loop through the children of this node, which should take us
// through the optional Warning, Error, and Validity subsections.
//
DOMNode* typeNode = curElem->getFirstChild();
bool typeGotten[3] = { false, false, false };
while (typeNode)
{
// Skip over text nodes or comment nodes ect...
if (typeNode->getNodeType() != DOMNode::ELEMENT_NODE)
{
typeNode = typeNode->getNextSibling();
continue;
}
// Convert it to an element node
const DOMElement* typeElem = (const DOMElement*)typeNode;
// Now get its tag name and convert that to a message type enum
const XMLCh* typeName = typeElem->getTagName();
MsgTypes type;
tmpXMLStr = XMLString::transcode("Warning");
XMLCh* tmpXMLStr2 = XMLString::transcode("Error");
XMLCh* tmpXMLStr3 =XMLString::transcode("FatalError");
if (!XMLString::compareString(typeName, tmpXMLStr ))
{
type = MsgType_Warning;
typeGotten[0] = true;
}
else if (!XMLString::compareString(typeName, tmpXMLStr2 ))
{
type = MsgType_Error;
typeGotten[1] = true;
}
else if (!XMLString::compareString(typeName, tmpXMLStr3 ))
{
type = MsgType_FatalError;
typeGotten[2] = true;
}
else
{
wprintf(L"Expected a Warning, Error, or FatalError node\n\n");
XMLString::release(&tmpXMLStr);
XMLString::release(&tmpXMLStr2);
XMLString::release(&tmpXMLStr3);
throw ErrReturn_SrcFmtError;
}
XMLString::release(&tmpXMLStr);
XMLString::release(&tmpXMLStr2);
XMLString::release(&tmpXMLStr3);
// Call the start message type event
formatter->startMsgType(type);
// Enumerate the messages under this subsection
enumMessages
(
typeElem
, formatter
, outHeader
, type
, count
);
// Call the end message type event
formatter->endMsgType(type);
// Move to the next child of the source element
typeNode = typeNode->getNextSibling();
}
//
// For any that we did not get, spit out faux boundary
// values for it.
//
for (unsigned int subIndex = 0; subIndex < 3; subIndex++)
{
if (!typeGotten[subIndex])
{
fwprintf
(
outHeader
, L" , %s%-30s = %d\n"
, xmlStrToPrintable(typePrefixes[subIndex])
, longChars("LowBounds")
, count++
);
releasePrintableStr
fwprintf
(
outHeader
, L" , %s%-30s = %d\n"
, xmlStrToPrintable(typePrefixes[subIndex])
, longChars("HighBounds")
, count++
);
releasePrintableStr
}
}
// Tell the formatter that this domain is ending
formatter->endDomain(domainStr, count);
// Close out the enum declaration
fwprintf(outHeader, L" };\n\n");
//
// Generate the code that creates the simple static methods
// for testing the error types. We don't do this for the
// exceptions header.
//
if (XMLString::compareString(domainStr, XMLUni::fgExceptDomain))
{
fwprintf
(
outHeader
, L" static bool isFatal(const %s::Codes toCheck)\n"
L" {\n"
L" return ((toCheck >= F_LowBounds) && (toCheck <= F_HighBounds));\n"
L" }\n\n"
, xmlStrToPrintable(errNameSpace)
);
releasePrintableStr
fwprintf
(
outHeader
, L" static bool isWarning(const %s::Codes toCheck)\n"
L" {\n"
L" return ((toCheck >= W_LowBounds) && (toCheck <= W_HighBounds));\n"
L" }\n\n"
, xmlStrToPrintable(errNameSpace)
);
releasePrintableStr
fwprintf
(
outHeader
, L" static bool isError(const %s::Codes toCheck)\n"
L" {\n"
L" return ((toCheck >= E_LowBounds) && (toCheck <= E_HighBounds));\n"
L" }\n\n"
, xmlStrToPrintable(errNameSpace)
);
releasePrintableStr
fwprintf
(
outHeader
, L" static XMLErrorReporter::ErrTypes errorType(const %s::Codes toCheck)\n"
L" {\n"
L" if ((toCheck >= W_LowBounds) && (toCheck <= W_HighBounds))\n"
L" return XMLErrorReporter::ErrType_Warning;\n"
L" else if ((toCheck >= F_LowBounds) && (toCheck <= F_HighBounds))\n"
L" return XMLErrorReporter::ErrType_Fatal;\n"
L" else if ((toCheck >= E_LowBounds) && (toCheck <= E_HighBounds))\n"
L" return XMLErrorReporter::ErrType_Error;\n"
L" return XMLErrorReporter::ErrTypes_Unknown;\n"
L" }\n"
, xmlStrToPrintable(errNameSpace)
);
releasePrintableStr
fwprintf
(
outHeader
, L" static DOMError::ErrorSeverity DOMErrorType(const %s::Codes toCheck)\n"
L" {\n"
L" if ((toCheck >= W_LowBounds) && (toCheck <= W_HighBounds))\n"
L" return DOMError::DOM_SEVERITY_WARNING;\n"
L" else if ((toCheck >= F_LowBounds) && (toCheck <= F_HighBounds))\n"
L" return DOMError::DOM_SEVERITY_FATAL_ERROR;\n"
L" else return DOMError::DOM_SEVERITY_ERROR;\n"
L" }\n"
, xmlStrToPrintable(errNameSpace)
);
releasePrintableStr
}
// the private default ctor
fwprintf(outHeader, L"\n");
fwprintf(outHeader, L"private:\n");
fwprintf(outHeader, L" // -----------------------------------------------------------------------\n");
fwprintf(outHeader, L" // Unimplemented constructors and operators\n");
fwprintf(outHeader, L" // -----------------------------------------------------------------------\n");
fwprintf(outHeader, L" %s();\n", xmlStrToPrintable(errNameSpace));
releasePrintableStr
// And close out the class declaration, the namespace declaration and the header file
fwprintf(outHeader, L"};\n\n");
fwprintf(outHeader, L"}\n\n");
fwprintf(outHeader, L"#endif\n\n");
fclose(outHeader);
XMLString::release(&headerName);
XMLString::release(&errNameSpace);
}
// Ok, we are done so call the end output method
formatter->endOutput();
// And clean up the stuff we allocated
delete formatter;
}
catch(const ErrReturns retVal)
{
// And call the termination method
if(srcDoc)
delete srcDoc;
return retVal;
}
delete srcDoc;
}
// And call the termination method
release_Globals();
// Went ok, so return success
return ErrReturn_Success;
}
// -----------------------------------------------------------------------
// XlatErrHandler: Implementation of the error handler interface
// -----------------------------------------------------------------------
void XlatErrHandler::warning(const SAXParseException& toCatch)
{
parseError(toCatch);
}
void XlatErrHandler::error(const SAXParseException& toCatch)
{
parseError(toCatch);
}
void XlatErrHandler::fatalError(const SAXParseException& toCatch)
{
parseError(toCatch);
}
void XlatErrHandler::resetErrors()
{
}
// if longChars is a macro, don't bother
#ifndef longChars
wchar_t* longChars(const char *str)
{
mbstowcs(fTmpWStr, str, 255);
return (fTmpWStr);
}
#endif
|
2c798e73849eb8eb0a9820ed9fd7eed34de16ac2 | 39fe085377f3c7327e82d92dcb38083d039d8447 | /core/sqf/src/stfs/stfslib/libmkstemp.cpp | eb584f694073cf2e524aa7de5d10dd1d1a679f89 | [
"Apache-2.0"
] | permissive | naveenmahadevuni/incubator-trafodion | 0da8d4c7d13a47d3247f260b4e67618c0fae1539 | ed24b19436530b2c214e4bf73280bc8e3f419669 | refs/heads/master | 2021-01-22T04:40:52.402291 | 2015-07-16T00:02:50 | 2015-07-16T00:02:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,875 | cpp | libmkstemp.cpp | ///////////////////////////////////////////////////////////////////////////////
//
/// \file libmkstemp.cpp
/// \brief STFS_mkstemp implementation
///
/// This file contains the implementation of the STFS_mkstemp() function,
/// starting with the functional STFSLIB_mkstemp function and drilling
/// down to supporting functions.
//
// @@@ START COPYRIGHT @@@
//
// (C) Copyright 2008-2014 Hewlett-Packard Development Company, L.P.
//
// 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.
//
// @@@ END COPYRIGHT @@@
///////////////////////////////////////////////////////////////////////////////
#include <unistd.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#include <iostream>
#include "stfs/stfslib.h"
#include "stfs_metadata.h"
#include "stfs_defs.h"
#include "stfs_util.h"
#include "stfs_message.h"
#include "stfsd.h"
#include "send.h"
namespace STFS {
// Rev: Missing doxygen hdr
stfs_fhndl_t
STFSLIB_mkstemp(char *pp_Ctemplate)
{
const char *WHERE = "STFSLIB_mkstemp";
STFS_ScopeTrace lv_st(WHERE);
// Rev: Add an ASSERT for pp_Ctemplate
if (!pp_Ctemplate) {
return -1;
}
STFS_ExternalFileMetadata *lp_Efm = 0;
STFS_FragmentFileMetadata *lp_Ffm = 0;
STFS_OpenIdentifier *lp_OpenId = 0;
int lv_ret = 0;
#ifdef SQ_PACK
lv_ret = SendToSTFSd_mkstemp(pp_Ctemplate,
STFS_util::GetMyNodeId(),
STFS_util::GetMyPID(),
lp_Efm,
lp_OpenId);
#else
lv_ret = STFSd_mkstemp(pp_Ctemplate,
STFS_util::GetMyNodeId(),
STFS_util::GetMyPID(),
lp_Efm,
lp_OpenId);
#endif
// lp_OpenID was NEW'd in SendToSTFSd_mkstemp. We need to free it
// here after we're done. Really, we should allocate and free at
// the same level...
// Rev: Check for (!= 0)
if (lv_ret < 0) {
// Rev: Add ASSERTs to check that lp_Efm, lp_OpenId are NULL
delete lp_OpenId;
return lv_ret;
}
// Rev: Remove this and add ASSERTs for lp_Efm/lp_OpenId being not NULL
if (!lp_Efm) {
delete lp_OpenId;
return -1;
}
if (!lp_Efm->IsEyeCatcherValid()) {
delete lp_OpenId;
STFS_util::SoftwareFailureHandler(WHERE);
return -1;
}
// Rev: Remove this
STFS_util::ValidateEFM(lp_Efm);
STFS_ExternalFileHandle *lp_Efh = lp_Efm->Open(false);
if (!lp_Efh) {
//TBD cleanup
// Rev: Send a message to the STFSd to cleanup/ delete directories
delete lp_OpenId;
return -1;
}
lp_Efh->OpenFlagsSet(O_RDWR);
lp_Efh->OpenIdentifierSet(*lp_OpenId);
//Rev: Valgrind shows that there is a memory leak here. However if the following 'delete'
// is uncommented then our tests fail with SQ_PACK=0; and SQ_STFSD=0. Need to figure
// out what is the cause of the tests failing in order to allow this memory leak fix.
//delete lp_OpenId;
lp_Ffm = lp_Efm->GetFragment (0); // This is mkstemp, so there's only one fragment!
// Rev: Check for lp_Ffm
STFS_FragmentFileHandle *lp_Ffh = new STFS_FragmentFileHandle(lp_Ffm);
// Rev: Check for lp_Ffh
lp_Efh->InsertFFH(lp_Ffh);
//Rev: Did the Insert work?
return (stfs_fhndl_t) lp_Efh;
}
} // namespace STFS
|
8510141fbc3fffa1f01a84388d6b160a7f3f82cb | 49925b80e02a8f8e16ad199ba7009b93112f5205 | /Lafore-exercise-solutions/chapter_10/10chapter_06exercise.cpp | f0edc98f3831d92fb73106780b3d95719237a6c9 | [] | no_license | ilyachalov/lafore-book-examples | c43aff5b8c333f34c6920981924a50430051d7ef | d6737f0db122e4bf91c9d859d0cce4a0a59d22be | refs/heads/master | 2021-06-17T17:39:05.884393 | 2021-02-17T05:41:55 | 2021-02-17T05:41:55 | 172,665,245 | 17 | 16 | null | 2020-11-16T07:49:05 | 2019-02-26T08:02:45 | C++ | UTF-8 | C++ | false | false | 7,464 | cpp | 10chapter_06exercise.cpp | // исходный текст программы сохранен в кодировке UTF-8 с сигнатурой
// 10chapter_06exercise.cpp
// Требуется написать свою собственную версию библиотечной функции wcscmp,
// сравнивающую две заданных строки и возвращающую результат сравнения.
// Новую функцию предлагается назвать compwcs. В main требуется написать
// программу, тестирующую написанную функцию.
// Библиотечная функция wcscmp принимает в качестве аргументов две строки,
// которые требуется сравнить, и возвращает результат в виде числа типа int.
// В случае, если первая строка меньше второй, возвращаемое число будет
// отрицательным (< 0). Если первая строка идентична второй, возвращаемое
// число будет равно нулю. Если первая строка больше второй, возвращаемое
// число будет положительным (> 0).
// Заданные строки сравниваются посимвольно. Сравнение останавливается на первом
// символе, различном для заданных строк, после чего возвращается результат.
// Если длины строк разные, а посимвольно короткая строка совпадает с длинной,
// то большей считается более длинная строка. Например, "123" < "1234",
// но "124" > "1234".
#include <io.h> // для функции _setmode
#include <fcntl.h> // для константы _O_U16TEXT
#include <iostream>
using namespace std;
int compwcs(const wchar_t *, const wchar_t *); // прототип функции
int main()
{
// переключение стандартного потока вывода в формат Юникода
_setmode(_fileno(stdout), _O_U16TEXT);
// переключение стандартного потока ввода в формат Юникода
_setmode(_fileno(stdin), _O_U16TEXT);
const wchar_t *str1, *str2; // строки для сравнения
// При сортировке фамилий по возрастанию (то есть по алфавиту) фамилии
// отсортируются так (фамилия выше (ближе к началу алфавита) считается меньшей):
// 1. Petrov
// 2. Архангельский
// 3. Петров
// 4. Петровский
// 5. Сидоров
// 6. Яковлев
// 7. сидоров (с прописной буквы)
str1 = L"Сидоров"; str2 = L"Петровский"; // результат: 1 (str1 > str2)
wcout << L'"' << str1 << L"\", \"" << str2 << L"\", результат: " << compwcs(str1, str2) << endl;
str1 = L"Петровский"; str2 = L"Сидоров"; // результат: -1 (str1 < str2)
wcout << L'"' << str1 << L"\", \"" << str2 << L"\", результат: " << compwcs(str1, str2) << endl;
str1 = L"Петров"; str2 = L"Петров"; // результат: 0 (str1 == str2)
wcout << L'"' << str1 << L"\", \"" << str2 << L"\", результат: " << compwcs(str1, str2) << endl;
str1 = L"Петров"; str2 = L"Петровский"; // результат: -1 (str1 < str2)
wcout << L'"' << str1 << L"\", \"" << str2 << L"\", результат: " << compwcs(str1, str2) << endl;
str1 = L"Петровcкий"; str2 = L"Петров"; // результат: 1 (str1 > str2)
wcout << L'"' << str1 << L"\", \"" << str2 << L"\", результат: " << compwcs(str1, str2) << endl;
// Предположим, оператор ошибся и ввел фамилию с прописной буквы: "сидоров". Такая фамилия
// в списке станет после всех фамилий, введенных с ЗАГЛАВНОЙ буквы, так как коды
// прописных букв в Юникоде больше, чем коды ЗАГЛАВНЫХ
str1 = L"сидоров"; str2 = L"Яковлев"; // результат: 1 (str1 > str2)
wcout << L'"' << str1 << L"\", \"" << str2 << L"\", результат: " << compwcs(str1, str2) << endl;
// Предположим, оператор ввел одну из фамилий латиницей: "Petrov". В списке фамилий
// фамилии, введенные латиницей, станут выше, чем фамилии, введенные кириллицей, так как
// коды латинских букв в Юникоде меньше, чем коды кириллических
str1 = L"Petrov"; str2 = L"Архангельский"; // результат: -1 (str1 < str2)
wcout << L'"' << str1 << L"\", \"" << str2 << L"\", результат: " << compwcs(str1, str2) << endl;
return 0;
}
// функция сравнивает две заданные строки и возвращает результат сравнения:
// 0 — строки равны;
// -1 — первая строка меньше второй;
// 1 — первая строка больше второй
int compwcs(const wchar_t *s1, const wchar_t *s2)
{
while (*s1 && *s2) // пока не достигнут конец ни одной из строк,
{ // сравниваем их посимвольно:
if (*s1 > *s2) // если символ первой строки больше символа второй,
return 1; // возвращаем 1 (первая строка больше второй)
else if (*s1 < *s2) // если символ первой строки меньше символа второй,
return -1; // возвращаем -1 (первая строка меньше второй)
s1++; s2++; // переходим к следующему символу в каждой из строк
}
// если программа дошла сюда, значит был достигнут конец либо одной из строк,
// либо конец обеих строк одновременно, при этом короткая строка полностью
// совпадает с началом длинной
if (!*s1 && !*s2) // если строки равны по длине и совпадают посимвольно,
return 0; // возвращаем 0 (строки равны)
else if (!*s1) // если первая строка короче, а посимвольно строки совпадают,
return -1; // возвращаем -1 (первая строка меньше второй)
else // если вторая строка короче, а посимвольно строки совпадают,
return 1; // возвращаем 1 (первая строка больше второй)
} |
385cbb41e6a8f6be51c1fe7b673b10451522410c | 6006c75f0b3ed13d0cb6b8b4996351a1fd4d6615 | /Day 28 Counting Bits.cpp | b173c98e17148148b2106e11956f06e327f7f6c3 | [] | no_license | tusharjaiswal123/leetcode-may-challenge | 51a4220d0a3ce114d66286ddca7b2a147fcc6f3d | 290131be399104a3355af636711419f008d1c049 | refs/heads/master | 2022-09-10T20:48:22.859684 | 2020-05-31T07:25:18 | 2020-05-31T07:25:18 | 260,406,283 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,154 | cpp | Day 28 Counting Bits.cpp | PROBLEM:
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their
binary representation and return them as an array.
Example 1:
Input: 2
Output: [0,1,1]
Example 2:
Input: 5
Output: [0,1,1,2,1,2]
Follow up:
1. It is very easy to come up with a solution with run time O(n*sizeof(integer)). But can you do it in linear time
O(n) /possibly in a single pass?
2. Space complexity should be O(n).
3. Can you do it like a boss? Do it without using any builtin function like __builtin_popcount in c++ or in any other language.
SOLUTION:
class Solution {
public:
vector<int> countBits(int num) {
int i;
vector<int> v;
for(i=0;i<=num;i++)
{
v.push_back(__builtin_popcount(i));
}
return v;
}
};class Solution {
public:
vector<int> countBits(int num) {
int i;
vector<int> v;
for(i=0;i<=num;i++)
{
v.push_back(__builtin_popcount(i));
}
return v;
}
};
|
37cabd2a41eff2708af040af28580df93b754c93 | 9a4534ddff234a8bd85193afbb7e4eaea99d9bca | /SmallWorld/Aggressive.cpp | 473013c22ec9b5c00e2db5dea3e6970d8757b5fe | [] | no_license | rameenrastan/SmallWorld | 1863829d2dec541a3de685eaff2b18e926b408cc | 18ec98938eddc987c280e809c7ddc19f0d7c0ecc | refs/heads/master | 2021-03-24T13:11:27.995625 | 2018-04-12T23:33:23 | 2018-04-12T23:33:23 | 120,060,429 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,169 | cpp | Aggressive.cpp | #include "stdafx.h"
#include "Aggressive.h"
Aggressive::Aggressive()
{
}
Aggressive::~Aggressive()
{
}
void Aggressive::execute(Map* gameMap, Player* player, string phase, GameLoop* gl, GameDeck* gd)
{
if (phase == "Picks Race") {
int x = rand() % 6;
player->picks_race(gl->pairs[x].first, gl->pairs[x].second, gd);
cout << "You have chosen: " << gl->pairs[x].second.getBadgeName() << " " << gl->pairs[x].first.getRaceName() << endl;
gl->pairs.erase(gl->pairs.begin() + x);
cout << "\nUpdated list of race power combos: " << endl;
for (int i = 0; i < 6; i++) {
cout << i << ". " << gl->pairs[i].second.getBadgeName() << " " << gl->pairs[i].first.getRaceName() << endl;
}
}
if (phase == "Conquer Regions" && player->getTokenCount() > 2) {
for (auto & region : gameMap->regions) {
(*player).conquers(region, true);
}
}
if (phase == "Following Turn" && player->getTokenCount() <= 2) {
player->decline(gl->pairs[0].first, gl->pairs[0].second, gd);
}
else if (phase == "Following Turn" && player->getTokenCount() > 2) {
for (auto & region : gameMap->regions){
(*player).conquers(region, true);
}
}
}
|
784ef6bb9cf9931942ab83b2b12ee86c313d889c | 54f62e14405fb25bae9c88e4767944a1d75dec2e | /files/asobiba/rti_Lib/VCL/rti_vcl_comb_event.h | 4b5716340887c8bf2192034e17541e94dcdc75d5 | [] | no_license | Susuo/rtilabs | 408975914dde59f44c1670ce3db663ed785d00b2 | 822a39d1605de7ea2639bdffdc016d8cc46b0875 | refs/heads/master | 2020-12-11T01:48:08.562065 | 2012-04-10T14:22:37 | 2012-04-10T14:22:37 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,967 | h | rti_vcl_comb_event.h | /**********************************************************/
// コンボボックスのイベントとか
/**********************************************************/
#include "StartWithExeFile.h"
#ifdef COMB_LIFE
#ifndef ___TCOMBEVENTH
#define ___TCOMBEVENTH
#include <.\VCL\rti_vcl_object.h>
#include <.\VCL\rti_vcl_base.h>
//コンボボックスのイベントクラス
//コンボボックスから作るコンポーネントはこれを継承させます.
//COMBOBOX
class TCombEvent : public TBaseObject
{
public:
//リストの最後に追加
void Add(char *String)
{SendMessage(hWnd,CB_ADDSTRING,0L,(LPARAM)String);};
//リストのPosに追加
void Insert(int Pos,char *String)
{SendMessage(hWnd,CB_INSERTSTRING,(WPARAM)Pos,(LPARAM)String);};
//リストをクリア
void Clear()
{SendMessage(hWnd,CB_RESETCONTENT,0L,0L);};
//現在選択されているところをかえしまっするるるるるー
int GetSelect()
{return SendMessage(hWnd,CB_GETCURSEL,0L,0L);};
//リストの項目数
int GetMax()
{return SendMessage(hWnd,CB_GETCOUNT,0L,0L);};
//リストより項目の削除
void Delete(int Index)
{SendMessage(hWnd,CB_DELETESTRING,(WPARAM)Index,0L);};
//リストのIndexのところをStringに変更する
void Change(int Index,char *String)
{
SendMessage(hWnd,CB_DELETESTRING,(WPARAM)Index,0L);
SendMessage(hWnd,CB_INSERTSTRING,(WPARAM)Index,(LPARAM)String);
};
//リストの Index 番目を選択させる
void Select(int Index)
{SendMessage(hWnd, CB_SETCURSEL, (WPARAM)Index, 0L);};
//リストの Index の内容をゲット
char* GetData(int Index)
{return (char*)SendMessage(hWnd, CB_GETITEMDATA, (WPARAM)Index, 0L);};
TCombEvent();
void WmCommandCome(WPARAM wParam);
SimpleEvent OnClose;
SimpleEvent OnDropDown;
SimpleEvent OnEditChange;
SimpleEvent OnEditUpDate;
SimpleEvent OnChange;
SimpleEvent OnCancel;
SimpleEvent OnOk;
};
#endif
#endif
|
1805b846cd62b3629b05e0c7fcd199a1143d1311 | 6e6e1203a095c7128f27dc3adf022b4cbe0356b4 | /src/base/DNAUtil.cxx | c637ced9cbc83cfbacd8d11f30cd6e59949062df | [
"Apache-2.0"
] | permissive | theclashingfritz/libtoontown | c0dcbfa44a22a5f3200f3b1522c16a5436e1578c | e453b1de7185e056f95d4ee4831612b1a6598631 | refs/heads/master | 2021-06-30T08:00:35.586822 | 2017-09-19T00:43:44 | 2017-09-19T00:43:44 | 103,720,426 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,007 | cxx | DNAUtil.cxx | #include "DNAUtil.h"
#include "DNAGroup.h"
#include <decalEffect.h>
#include <nodePathCollection.h>
#include <pandabase.h>
DNAUtil::DNAUtil(){
}
DNAUtil::~DNAUtil(){
}
void DNAUtil::reparent_node_to(NodePath np, NodePath np1) {
np.reparent_to(np1);
}
void DNAUtil::apply_decal_effect_to_node(NodePath np) {
np.set_effect(DecalEffect::make());
}
void DNAUtil::flatten_node_strong(NodePath np) {
np.flatten_strong();
}
void DNAUtil::set_node_scale(NodePath np, LPoint3f scale) {
np.set_scale(scale);
}
void DNAUtil::set_node_pos_hpr(NodePath np, int32_t x, int32_t y, int32_t z, int32_t h, int32_t p, int32_t r) {
np.set_x(x);
np.set_y(y);
np.set_z(z);
np.set_h(h);
np.set_p(p);
np.set_r(r);
}
void DNAUtil::set_node_pos(NodePath np, int32_t x, int32_t y, int32_t z) {
np.set_x(x);
np.set_y(y);
np.set_z(z);
}
void DNAUtil::set_node_hpr(NodePath np, int32_t h, int32_t p, int32_t r) {
np.set_h(h);
np.set_p(p);
np.set_r(r);
}
|
f7f95eaf56b35b94490fedd5e342d4f9470c3271 | f0b37dabd94fc5f92b2c7cf45205fcd8461b5373 | /CSCI 322/brgc-knapsack/menu/Menu.h | aa7cab7fe9999c6e63debc9d2af06bfe8c453c34 | [] | no_license | BrandonMitchell1920/CSCI332 | fa5c0da4fb8ea4a48299942cf28575ac89a2e068 | afc34a1a06b0e8f7b486fd4028d7c0ea20ed9965 | refs/heads/main | 2023-04-12T22:28:19.083515 | 2021-04-23T19:53:19 | 2021-04-23T19:53:19 | 360,991,103 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,033 | h | Menu.h | /** Application Menu via Textual User Interface
*
* CSCI 332 Design and Analysis of Algorithms
* Menu Class
*
* Phillip J. Curtiss, Associate Professor
* pcurtiss@mtech.edu, 406-496-4807
* Department of Computer Science, Montana Tech
*/
#ifndef MENU_H
#define MENU_H
#include <string>
#include <vector>
#include <memory>
#include "MenuItem.h"
namespace tui {
class Menu {
private:
// title of the application menu
std::string title;
// subtitle of the application menu
std::string subTitle;
// prompt for the application menu
std::string prompt;
// virtual terminal row where
// the application menu will begin
int startLine;
// virtual terminal row where
// additional help information about a menu
// item will be displayed
int helpLine;
// virtual terminal column where
// the menu item will begin to be displayed
int leftMargin;
std::vector<std::shared_ptr<MenuItem> > Items;
// function to exit the textual users interface
// cleanly and restore terminal functionality
static void exitCurses(int signal);
public:
// constructor
Menu();
// destructor
~Menu();
// methods to modify the Items collection with MenuItem instances
std::shared_ptr<MenuItem> Insert(std::shared_ptr<MenuItem> Item);
std::shared_ptr<MenuItem> Update(char cmd, std::shared_ptr<MenuItem> Item);
std::shared_ptr<MenuItem> Remove(char cmd);
// Display the application menu and obtain a valid input from the user
// return the menu item instance corresponding with the menu item selected
std::shared_ptr<MenuItem> Prompt() const;
// mutator methods for the virtual terminal window parameters
void SetTitle(std::string msg);
void SetSubTitle(std::string msg);
void SetPrompt(std::string msg);
}; // end Menu
} // end namespace
#endif |
4d0b54eeeee597937513a071a79735291daf9401 | 8029517ebbfc93e706dd15c29ba5f92eaca51e8a | /Server/Src/DataPool.cpp | 4f491afcc792fe356033b700ce946ad5e8bdda9c | [
"Apache-2.0"
] | permissive | JasonBucotte/Cry_HPSocket | 856dd94f7877510e8f28b672e9ff1782dbebd111 | b9c56f6b855448a3597d28fd1af7cafe14f89ce6 | refs/heads/master | 2020-06-13T01:40:52.625923 | 2019-04-18T02:12:26 | 2019-04-18T02:12:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,829 | cpp | DataPool.cpp | #include "stdafx.h"
#include "DataPool.h"
#define MAX_BLOCK_SIZE (64*1024)
#define DEFAULT_BLOCK_NUM 64
DataPool::DataPool()
{
Reset();
m_dataBlocks.resize(DEFAULT_BLOCK_NUM);
for (int i = 0; i < DEFAULT_BLOCK_NUM; i++)
{
BYTE* dataChunk = new BYTE[m_maxBlockSize];
memset(dataChunk, 0, m_maxBlockSize);
m_dataBlocks[i] = dataChunk;
}
}
DataPool::~DataPool()
{
for (int i = 0; i < DEFAULT_BLOCK_NUM; i++)
{
SAFE_DELETE_ARRAY(m_dataBlocks[i]);
}
m_dataBlocks.clear();
}
void DataPool::PutData(const uint8_t* data, uint32_t size)
{
if (size <= m_curBlockFreeSize)
{
memcpy(m_dataBlocks[m_curEmptyBlockIndex] + m_curBlockDataPos, data, size);
m_curBlockDataPos += size;
m_curBlockFreeSize -= size;
}
else
{
memcpy(m_dataBlocks[m_curEmptyBlockIndex] + m_curBlockDataPos, data, m_curBlockFreeSize);
memcpy(m_dataBlocks[++m_curEmptyBlockIndex], data + m_curBlockFreeSize, size - m_curBlockFreeSize);
m_curBlockDataPos = size - m_curBlockFreeSize;
m_curBlockFreeSize = m_maxBlockSize - m_curBlockDataPos;
}
}
void DataPool::GetAllData(CBufferPtr& dataBufferPtr)
{
DWORD dataSize = m_curEmptyBlockIndex*m_maxBlockSize + m_curBlockDataPos;
dataBufferPtr.Realloc(dataSize);
DWORD size = 0;
for (int i = 0; i < m_curEmptyBlockIndex; i++)
{
memcpy(dataBufferPtr.Ptr() + size, m_dataBlocks[i], m_maxBlockSize);
memset(m_dataBlocks[i], 0, m_maxBlockSize);
size += m_maxBlockSize;
}
memcpy(dataBufferPtr.Ptr() + size, m_dataBlocks[m_curEmptyBlockIndex], m_curBlockDataPos);
memset(m_dataBlocks[m_curEmptyBlockIndex], 0, m_curBlockDataPos);
size += m_curBlockDataPos;
Reset();
}
void DataPool::Reset()
{
m_curEmptyBlockIndex = 0;
m_curBlockDataPos = 0;
m_maxBlockSize = MAX_BLOCK_SIZE;
m_curBlockFreeSize = m_maxBlockSize;
}
|
1571f27d3ce0126a2a900d77f03e161eb5d89869 | e993b06fbdaf60ee5f11f69c8564b35f3fc48400 | /Number letter counts.cpp | f14b4d79052277fa750581dca331a93c7a09367f | [] | no_license | Are-Jeh/PEuler | 2f0921ceed98f82993018a4fe8d266ebd7f11a12 | c762ee69a9a4af7e273d5e5c18301f2f35e2c8a8 | refs/heads/main | 2023-08-10T18:11:19.756196 | 2021-09-17T03:58:52 | 2021-09-17T03:58:52 | 399,065,163 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,075 | cpp | Number letter counts.cpp | #include<iostream>
using namespace std;
int main()
{
string oneto9[] = {"","one", "two", "three", "four", "five", "six", "seven","eight", "nine"};
string elevento19[] = {"","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
string x10s[] = {"","ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
int sum1to9 = 0, sum11to19 = 0; int s99 = 0, s999 = 0;
for(int i=0;i<10;++i)
{
sum1to9+=oneto9[i].length();
sum11to19+=elevento19[i].length();
}
s99 = sum1to9 + x10s[1].length() + sum11to19 ;
for(int i=20;i<100;++i)
s99 = s99 + x10s[i/10 ].length() + oneto9[i%10 ].length() ;
int hundred = strlen("hundred"),
thousand = strlen("thousand"),
andd = strlen("and");
s999 = s99 + strlen("one")+ hundred;
for(int i=101;i<1000;++i)
{
s999 += 1* oneto9[i/100].length()+ hundred+andd;
if(i%100==0)s999-=andd;
}
s999 += 9*s99;
s999 += strlen("one") + thousand ;
cout<<s999;
} |
491d19f913390c43b91334344113b4236b4a73a3 | f19a734ebeaa22ae0d8a0d347aea5810f159d9bc | /Euler Method/BZOJ4173.cpp | a8c9a95e4d43ee8807a22dffb4954f79314942a9 | [] | no_license | iiyiyi/solution-book-till-2020 | 2d0b75dc9e1468d846b176551acaa2a930428afb | faf1c04735627df8ee600b55d72df9bec50089b5 | refs/heads/master | 2023-03-07T05:54:48.824987 | 2021-02-20T10:59:55 | 2021-02-20T10:59:55 | 340,558,407 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 461 | cpp | BZOJ4173.cpp | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MOD 998244353
using namespace std;
typedef long long ll;
ll phi(ll x)
{
ll ret=x;
for (ll i=2;i*i<=x;i++)
{
if (x%i==0)
{
ret-=ret/i;
while (x%i==0) x/=i;
}
}
if (x>1) ret-=ret/x;
return ret%MOD;
}
void solve()
{
ll n,m;
scanf("%lld%lld",&n,&m);
printf("%lld",(phi(n)%MOD)*(phi(m)%MOD)%MOD*(n%MOD)%MOD*(m%MOD)%MOD);
}
int main()
{
solve();
return 0;
}
|
267fa0a10f73d956bf813be59c46c31cf92bc516 | 721ecafc8ab45066f3661cbde2257f6016f5b3a8 | /codechef/tourists.cpp | bcb6eed6a8b9cf3c3c54c709bffcc8359908cff5 | [] | no_license | dr0pdb/competitive | 8651ba9722ec260aeb40ef4faf5698e6ebd75d4b | fd0d17d96f934d1724069c4e737fee37a5874887 | refs/heads/master | 2022-04-08T02:14:39.203196 | 2020-02-15T19:05:38 | 2020-02-15T19:05:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,462 | cpp | tourists.cpp | #include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x ) cerr << #x << " = "<< x << endl;
#define endl "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}
template<typename T>
using maxpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using minpq = priority_queue<T>;
/*----------------------------------------------------------------------*/
const int N = 1e5+5;
set<int> g[N];
int deg[N] = {0}, vcount = 0;
bool visited[N], poss = true;
vii edges;
void dfs(int curr) {
visited[curr] = true; vcount++;
while(!g[curr].empty()) {
int idx = *g[curr].begin();
int nxt = curr ^ edges[idx].ff ^ edges[idx].ss; // either curr = edges[idx].ff or curr = edges[idx].ss
if(nxt != edges[idx].ss) {
swap(edges[idx].ff, edges[idx].ss);
}
g[curr].erase(idx);
g[nxt].erase(idx);
dfs(nxt);
}
}
int main(){
std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int n,m,u,v; cin>>n>>m;
FOR(i, 0, m) {
cin>>u>>v; u--; v--;
g[u].insert(edges.size());
g[v].insert(edges.size());
edges.push_back({u, v});
deg[u]++; deg[v]++;
}
memset(visited, false, sizeof(visited));
dfs(0);
FOR(i, 0, n) {
poss &= (deg[i] % 2 == 0);
poss &= visited[i];
}
if(!poss) {
cout<<"NO";
return 0;
}
cout<<"YES\n";
FOR(i, 0, m) {
cout<<edges[i].ff+1<<" "<<edges[i].ss+1<<endl;
}
return 0;
} |
e0e89152362c7275a99dc2b1e835285ed60cdab3 | d4433d8c51e9dc6e0c2904def0a524c9125555de | /Battle/TrapData.h | 1c1d30d93a0b6c01e24aef30720ac005ba84fb38 | [] | no_license | 54993306/Classes | 3458d9e86d1f0e2caa791cde87aff383b2a228bb | d4d1ec5ca100162bd64156deba3748ce1410151d | refs/heads/master | 2020-04-12T06:23:49.273040 | 2016-11-17T04:00:19 | 2016-11-17T04:00:19 | 58,427,218 | 1 | 3 | null | null | null | null | GB18030 | C++ | false | false | 1,850 | h | TrapData.h | /*************************************************************
*
*
* Data : 2016.5.26
*
* Name : BattleTrap
*
* Author : Lin_Xiancheng
*
* Description :
*
*
*************************************************************/
#ifndef __BattleTrap__
#define __BattleTrap__
namespace protos{
namespace common{
class Trap;
}
}
#include "cocos2d.h"
using namespace cocos2d;
namespace BattleSpace
{
enum struct sTrapType
{
eNullType = 0,//
eFireObstacle = 100,//火属性障碍 预留的可能存在类型,目前不存在
eFireTrap = 1,//火属性地形
eWaterTrap = 2,//水属性地形
eWoodTrap = 3,//木属性地形
eObstacle = 4,//障碍类地形(所有武将都不可通过)
ePlayerObstacle = 5,//玩家不可通过
eMonsterObstacle = 6,//怪物不可通过
eBlood = 7,//掉血类地形
};
class BuffData;
class TrapData : public CCObject
{
public:
TrapData();
virtual ~TrapData();
static TrapData* createTrap(const protos::common::Trap *pTrap);
CC_SYNTHESIZE(int,mTrapID,TrapID);
CC_SYNTHESIZE(int,mTrapModel,TrapModel); //地形ID,也是地形效果ID,每个地形的效果是固定的
CC_SYNTHESIZE(sTrapType,mTrapType,TrapType); //地形类型
CC_SYNTHESIZE(int,mPosition,Position); //位置
CC_SYNTHESIZE(int,mAttribute,AtbType); //属性类型
CC_SYNTHESIZE(float,mRate,Rate); //影响比率
CC_SYNTHESIZE(int,mDmage,Dmage); //造成的伤害
CC_SYNTHESIZE(int,mTouch,TouchNum); //地形效果ID
CC_SYNTHESIZE(int,mRound,RoundNum); //地形命中效果ID
CC_SYNTHESIZE(int,mRotatione,Rotatione); //地形旋转角度
const BuffData* getTrapBuff() const;
protected:
void readData(const protos::common::Trap *pTrap);
private:
BuffData* mTrapBuff; //地形附带buff 有可能为一个列表
};
//
}
#endif |
46ce3b18574a1b209be65a00ae217d0839ed738f | 5b633913a456f8419591a7a51d60d804f598c324 | /button_wifi.ino | 9130d1fc93c0209053a059e763376b1b50c5be6f | [] | no_license | olgaBd/BoutonDASH | c574bf070f30e622a461e3fa8e5ccfb8c62189f4 | 257f674af0792b6e4e198528f76c156777ed6482 | refs/heads/master | 2020-04-23T22:28:59.619085 | 2019-02-20T14:52:48 | 2019-02-20T14:52:48 | 171,503,321 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 901 | ino | button_wifi.ino | #include <WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "uTimerLib.h"
WiFiClient wiFiClient;
Adafruit_MQTT_Client mqttClient(&wiFiClient, "192.168.0.108", 1883);
Adafruit_MQTT_Publish bouttonPub(&mqttClient, "/boutton");
int compteur = 0;
void bouttonStatut() {
int down = digitalRead(27);
int up = digitalRead(26);
if(up == 1){
compteur += 1;
bouttonPub.publish(compteur);
}
if(down == 1){
compteur -= 1;
bouttonPub.publish(compteur);
}
}
void setup() {
Serial.begin(115200);
WiFi.begin("createch2019", "createch2019");
delay(4000);
pinMode(27, INPUT);
pinMode(26, INPUT);
TimerLib.setInterval_s(bouttonStatut, 0.5);
}
void loop() {
if (mqttClient.connected()) {
mqttClient.processPackets(10000);
mqttClient.ping();
} else {
mqttClient.disconnect();
mqttClient.connect();
}
}
|
607a2ce53c73e97b6713767d39fdf24050967435 | 2802df7c2502fd3cfd430325b7c681ee55b40059 | /scripts/shuffle_fastq.cpp | a6566d1dd171681f6ddbb6f0d204b98430d70b64 | [] | no_license | Jonasgrove/file_utilities | 1158f7661b43dc1a201b098893ac439564791cf7 | 543f527d31a9ac5f84eabf6ca2c130ac77d732d0 | refs/heads/master | 2023-03-23T11:17:41.291063 | 2021-03-12T17:47:23 | 2021-03-12T17:47:23 | 337,523,107 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,539 | cpp | shuffle_fastq.cpp | #include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <unordered_map>
// FASTQ 'MAGIC CARD' SHUFFLE
// write out to file based on dictionary
void write_to_file(std::string out_file_name, std::string full_record){
// write line out to file indicated by argument
// open file
std::ofstream out_file;
// append to file
out_file.open(out_file_name, std::ios_base::app);
out_file << full_record << "\n";
// close file
out_file.close();
}
//
int main(int num_args, char** input_file_name){
// record variables
std::string header;
// full record
std::string full_record;
std::string whole_record = "";
// other variables
std::string line;
std::string out_file_name;
int out_file_int = 0;
std::string out_file_name_full;
// read file with ifstream
std::ifstream in_file(input_file_name[1]);
// process first read
// header
getline(in_file, line);
header = line;
// seq
getline(in_file, line);
//record_array.push_back(line);
whole_record = whole_record + "\n" + line;
// plus
getline(in_file, line);
//record_array.push_back(line);
whole_record = whole_record + "\n" + line;
// qual
getline(in_file, line);
//record_array.push_back(line);
whole_record = whole_record + "\n" + line;
// go through file with while loop
while (getline(in_file, line)){
// increment counter
out_file_int++;
// reset out file name if at 100
if (out_file_int == 100){
out_file_int = 1;
}
// if header line
char check = line[0];
char at = '@';
if (check == at){
// concatanate line into whole record
full_record = header + whole_record;
//std::cout << full_record << "\n";
// write out to file
// convert int to string
out_file_name = std::to_string(out_file_int);
out_file_name_full = "./database/" + out_file_name + ".fastq";
write_to_file(out_file_name_full, full_record);
// clear record array
whole_record = "";
// increment file name
// turn string to int
int out_file_int = stoi(out_file_name);
// set header
header = line;
}
else{
whole_record = whole_record + "\n" + line;
}
}
//close file
in_file.close();
return 0;
} |
55ffef9e75f2d85f27dff5ca8b271188fba16caa | 1e7869d7e1ab45fefb75b573d5ea5aa4b761a38a | /LISTA F/5f.cpp | 97b865517063aa2cadf1211175947d899de51f74 | [
"MIT"
] | permissive | cassiocamargos/C | 07d3814d85d0f71b88b279b24d2ca44a8981adfe | cfb03e6fb2b4788cb3d5fc0a738b0c90f07a47ee | refs/heads/main | 2023-06-15T19:41:19.014996 | 2021-07-13T16:38:18 | 2021-07-13T16:38:18 | 385,670,600 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 1,200 | cpp | 5f.cpp | /*
Lista F - Exercício 5
*/
typedef struct
{
char nome[101];
float altura;
float peso;
} Corpo;
// c. Escreva as instruções necessárias para definir o tipo Casal, contendo dois membros do tipo Corpo;
typedef struct
{
Corpo pessoa1;
Corpo pessoa2;
} Casal;
int main()
{
//a. Escreva uma instrução que declare uma variável chamada p1 do tipo Corpo;
Corpo p1;
// b. Escreva uma instrução que atribua o valor 1.68 para a altura da variável acima.
p1.altura = 1.68;
// d. Escreva a instrução necessária para declarar uma matriz de 10 elementos do tipo Casal;
Casal encontro[10];
/*
e. Escreva as instruções necessárias para preencher o quinto elemento da matriz
criada acima com os dados do casal Toinho (nome = Antonio Pegatudo, peso =
80kg, altura = 1.80m) e Tiana (nome = Sebastiana Pulabrejo, peso = 65kg, altura
= 1.55m).
*/
encontro[4].pessoa1.altura = 1.80;
encontro[4].pessoa1.peso = 80;
strcpy(encontro[4].pessoa1.nome,"Antonio Pegatudo");
encontro[4].pessoa2.altura = 1.55;
encontro[4].pessoa2.peso = 65;
strcpy(encontro[4].pessoa2.nome,"Sebastiana Pulabrejo");
return 0;
}
|
a00c6a785650b069d50119b4421907c1985e0915 | c367420fc012714bae5838a450e3c71a45f4ba43 | /bezGameEngine/src/Drawable.hpp | b918a6c2de9a53c96a456cfe2ebfddb9c0101110 | [
"MIT"
] | permissive | Gustvo/bezGameEngine | b65335e8ec7268ef359fc4cb30039ef3076c0aa2 | 8d0ac4613d1a1aac65cab51d337b9a77d56f29ec | refs/heads/master | 2020-12-08T10:49:06.514554 | 2020-01-13T06:36:53 | 2020-01-13T06:36:53 | 224,266,145 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 243 | hpp | Drawable.hpp | #ifndef DRAWABLE_H
#define DRAWABLE_H
namespace bez {
class Drawable {
public:
protected:
Drawable(){};
virtual ~Drawable(){};
virtual void draw() const = 0;
private:
friend class Window;
};
} // namespace bez
#endif // DRAWABLE_H
|
791d4543bf9e1f72666eae10ad3e637f5634ca86 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5631989306621952_1/C++/terashi/A.cc | 20a2be2335a7ce739d4694ae6c0307b73a166ea6 | [] | 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 | 590 | cc | A.cc | #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
bool isUpper(const string& str, char c) {
for (char s : str) {
if (c > s) return true;
if (c < s) return false;
}
return false;
}
int main() {
int nnn;
cin >> nnn;
for (int iii = 0; iii < nnn; ++iii) {
string in;
cin >> in;
string out;
for (char c : in) {
if (isUpper(out, c)) {
out = c + out;
} else {
out += c;
}
}
cout << "Case #" << iii+1 << ": " << out << endl;
}
}
|
af19792f8b6bff52a7e7f111d94af1e5663de33c | 72742d4ee57fb66cfe3f10290ccb596dcde1e59e | /Ubilo/Solutions/Yaz Kampi 2012/trezor.cpp | 0de38f7e74e0580bdcf3bc35078b230a8b7215c9 | [] | no_license | mertsaner/Algorithms | cd5cf84548ea10aafb13b4a3df07c67c1a007aef | f7aecb7e8aadff1e9cf49cc279530bc956d54260 | refs/heads/master | 2023-03-18T03:18:26.122361 | 2016-02-14T22:48:31 | 2016-02-14T22:48:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,704 | cpp | trezor.cpp | #include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int gcd(int a, int b)
{
return b == 0 ? a : gcd(b, a%b);
}
int A, B, L;
vector<int> divisors[4001];
vector<int> uni(vector<int> a, vector<int> b)
{
vector<int> ret;
for(vector<int>::iterator it = a.begin(); it != a.end(); it++)
for(vector<int>::iterator jt = b.begin(); jt != b.end(); jt++)
if( *it == *jt )
ret.push_back(*it);
else
ret.push_back(*it * *jt);
sort(ret.begin(), ret.end());
ret.erase(unique(ret.begin(), ret.end()), ret.end());
return ret;
}
long long int canSee(vector<int> a)
{
long long int ret = 0;
int n=a.size();
for(int mask=1; mask<(1<<n); mask++)
{
int x = 1;
int bits = 0;
for(int i=0;i<n;i++)
if((mask>>i)&1)
{
x = x/gcd(x, a[i])*a[i];
bits++;
}
if(bits&1)ret+=L/x;
else ret-=L/x;
}
return ret;
}
void generateDivisors()
{
for(int i=1;i<=4000;i++)
{
int x=i;
for(int d=2;d*d<=x;d++)
{
if(x%d==0)
{
while(x%d==0)x/=d;
divisors[i].push_back(d);
}
}
if(x>1)divisors[i].push_back(x);
}
}
int main()
{
ifstream inp("trezor.gir");
ofstream oup("trezor.cik");
generateDivisors();
long long int sn=0, s=0, sp=0;
inp >> A >> B >> L;
for(int i=0;i<=(A+B)/2;i++)
{
long long int a = i == 0 ? L-1 : canSee(divisors[i]);
long long int b = canSee(divisors[A+B-i]);
long long int c = i == 0 ? b : canSee(uni(divisors[i], divisors[A+B-i]));
int todoub = (2*i == (A+B)) ? 1 : 2;
sp += todoub*c;
s += todoub*(a + b - 2*c);
sn += todoub*(L-a-b+c);
}
oup << sp << endl << s << endl << sn << endl;
return 0;
}
|
5c732fb2d1bc555b8e93b219a894265f8ec52f99 | 4f6ddc12104ff4900830ab1cf357953b24b12165 | /Modulo/funcion_modulo.cpp | 1e014c5bd11f6eb4f7fc70193b731895c6f90f48 | [] | no_license | fernando-peralta/FernandoJair_PeraltaBustamante | d54d4455b02dc37a968125e024db8dea7ed1dead | 628f1fec46f1aa5ee1ec07d9b56660d42eb79862 | refs/heads/main | 2023-07-19T14:35:01.446938 | 2021-09-06T10:32:25 | 2021-09-06T10:32:25 | 351,824,320 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,169 | cpp | funcion_modulo.cpp | #include <iostream>
using namespace std;
int resto(int a, int n){ //funcion resto recibe a (dividendo) y n )(divisor)
int q,r; // Las dos salidas a entregar en la division: q (cociente) y r (resto)
if (a<0){//en caso a sea negativo
q=a/n; //resolvemos q
r=a-((q-1)*n); //realizamos la operacion original del resto pero se le aumenta 1 al cociente para exceder y obtener el resto positivo.
return r; //basicamente es siguiendo la logica de Galo
}else{// En caso a sea positivo
q=a/n;
r=a-(q*n);// simplemente la diferencia entre a y la multiplicacion
return r;
}
}
int main(){
int a,n,q,r; // todos los enteros que se necesitan
cout<<"Ingrese el numero a: "; cin>>a;cout<<endl;
cout<<"Ingrese el numero n (Siempre tiene que ser positivo): "; cin>>n;cout<<endl;
while (n<0) //restriccion en la que n siempre es positivo
{
cout<<"Ingrese un numero correcto\n";
cout<<"Ingrese el numero n (Siempre tiene que ser positivo)"; cin>>n;cout<<endl;
}
cout<<resto(a,n); // llamamos a la función
cout<<"\nPrograma terminado";
} |
0a886a6bcee499637c4248ab77ebff4dffe56391 | 04fdd565922fe5df2c789568a2a8bc2a7f3c056a | /Bidochka_O/Pr №7/4.cpp | e49261150d2b3869302d5edd71f726e2891df782 | [] | no_license | kotsolesya/OPtaAM_PS_2015 | 5c855fc0d0ddefbfa138798828e0154ed32d03b5 | 9651535bb58a1848b9f76ef0508b6ba7467be666 | refs/heads/master | 2021-09-06T15:05:22.002304 | 2017-10-18T09:32:59 | 2017-10-18T09:32:59 | 107,361,522 | 54 | 30 | null | 2018-02-11T20:03:01 | 2017-10-18T05:11:12 | C++ | UTF-8 | C++ | false | false | 451 | cpp | 4.cpp | #include <iostream>
#include <fstream>
using namespace std;
main(){
srand(time(NULL));
ofstream file1("D://string.txt", ios_base::out | ios_base::trunc);
if(!file1.is_open()){
cout << "File cannot be opened ro readed";
return 1;
}
char str[40];
for(int i = 0; i < 40; i++)
{
file1 << (char)(rand()%(122 - 65) + 65);
cout << (rand()%(172 - 101) + 101) << " " ;
}
file1.close();
system("pause");
return 0;
}
|
84fbd12af27ba86d6db799b33ea1871a27b74f75 | 5244b478acd55017fe53c68bd4ebf66bb01bf349 | /spidervnAccel/src/spidervnAccel/interface/IArchiveExtrator.h | 1db0b3020bcd83ab89f8ddc41c0b72a4d4f6c36e | [] | no_license | spidervn/android_agent | 7360fb9cb8db57d702829ed70af791d049fdd329 | 9f61bd4ed01a7486c47f4cc7e4204a2bc75a7525 | refs/heads/master | 2023-01-02T10:06:56.439942 | 2020-10-23T08:52:50 | 2020-10-23T08:52:50 | 92,178,225 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 470 | h | IArchiveExtrator.h | /*
* IArchiveExtrator.h
*
* Created on: Jan 25, 2018
* Author: ducvd
*/
#ifndef SPIDERVNACCEL_INTERFACE_IARCHIVEEXTRATOR_H_
#define SPIDERVNACCEL_INTERFACE_IARCHIVEEXTRATOR_H_
#include <string>
class IArchiveExtrator
{
public:
virtual ~IArchiveExtrator() {}
virtual int extract_Archive__(std::string fileArchive, std::string dir_Out) = 0;
virtual bool isArchiveFile(std::string sfile) = 0;
};
#endif /* SPIDERVNACCEL_INTERFACE_IARCHIVEEXTRATOR_H_ */
|
0085ba743e7ef79580b164fe08db2cad6f9e13bd | 44e5284edac5a2bfc1637630911ebbd054e580d2 | /SPI_RAM.h | 7963836e9efb53e5c72b7f05267bb09131c2610f | [
"MIT"
] | permissive | helloworld8686/stem6s2 | 8efcd55a91a479a561043a09a6015931746b0390 | 3fefd420d100902a349aff79203651fb0306ed69 | refs/heads/master | 2020-07-03T11:58:41.284395 | 2019-08-27T03:41:00 | 2019-08-27T03:41:00 | 201,898,182 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,171 | h | SPI_RAM.h | /*****************************************************************************
* | File : SPI_RAM.h
* | Author : Waveshare team
* | Function : FM25V05 DRIVER
* | Info :
*----------------
* | This version: V1.0
* | Date : 2017-12-12
* | Info : Basic version
*
******************************************************************************/
#ifndef __SPI_RAM_H_
#define __SPI_RAM_H_
//data
#define BYTE unsigned char
#define WORD unsigned short
// SRAM opcodes
#define CMD_WREN 0x06
#define CMD_WRDI 0x04
#define CMD_RDSR 0x05
#define CMD_WRSR 0x01
#define CMD_READ 0x03
#define CMD_WRITE 0x02
// SRAM modes
#define BYTE_MODE 0x00
#define PAGE_MODE 0x80
#define STREAM_MODE 0x40
class SPIRAM{
public:
void SPIRAM_SPI_Init(void);
void SPIRAM_Set_Mode(BYTE mode);
BYTE SPIRAM_RD_Byte(WORD Addr);
void SPIRAM_WR_Byte(WORD Addr, BYTE Data);
void SPIRAM_RD_Page(WORD Addr, BYTE *pBuf);
void SPIRAM_WR_Page(WORD Addr, BYTE *pBuf);
void SPIRAM_RD_Stream(WORD Addr, BYTE *pBuf, unsigned long Len);
void SPIRAM_WR_Stream(WORD Addr, BYTE *pBuf, unsigned long Len);
};
#endif
|
2166b377e3da65559c3c65f4e661260eb8e709e7 | bd3054e3359fdeb6415ed15d76b4b98c037e2484 | /DelFEM4Net/DelFEM4Net/DelFEM4Net/src/com/vector3d.cpp | 6412a71f5f87ea971ff7c142073a8d4c583f6fbc | [] | no_license | ryujimiya/delfem4net | 0af1619e375161b8f2a4c1c59c53f953e4d875b0 | 43ca8198ea9589d8d4b6141be16196b864c2393e | refs/heads/master | 2020-05-16T06:35:13.394134 | 2018-04-30T01:50:16 | 2018-04-30T01:50:16 | 42,876,545 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,057 | cpp | vector3d.cpp | /*
DelFEM (Finite Element Analysis)
Copyright (C) 2009 Nobuyuki Umetani n.umetani@gmail.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
////////////////////////////////////////////////////////////////
// Vector3D.cpp: CVector3D クラスのインプリメンテーション
////////////////////////////////////////////////////////////////
#if defined(__VISUALC__)
#pragma warning ( disable : 4786 )
#endif
#include <cassert>
#include <math.h>
#include <iostream>
#include <stack>
#include "DelFEM4Net/vector3d.h"
using namespace DelFEM4NetCom;
////////////////////////////////////////////////////////////////////
// メンバ関数のフレンド関数
////////////////////////////////////////////////////////////////////
namespace DelFEM4NetCom{
/*
bool operator == (const CVector3D% lhs, const CVector3D% rhs)
{
return Com::operator == (*(lhs.Self), *(rhs.Self));
}
bool operator != (const CVector3D% lhs, const CVector3D% rhs)
{
return Com::operator != (*(lhs.Self), *(rhs.Self));
}
*/
}
//////////////////////////////////////////////////////////////////////
// メンバ関数の非フレンド関数
//////////////////////////////////////////////////////////////////////
namespace DelFEM4NetCom{
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
COctTree::COctTree()
{
this->self = new Com::COctTree();
}
COctTree::COctTree(const COctTree% rhs)
{
const Com::COctTree& rhs_instance_ = *(rhs.self);
this->self = new Com::COctTree(rhs_instance_);
}
COctTree::COctTree(Com::COctTree *self)
{
this->self = self;
}
COctTree::~COctTree()
{
this->!COctTree();
}
COctTree::!COctTree()
{
delete this->self;
}
Com::COctTree * COctTree::Self::get()
{
return this->self;
}
void COctTree::SetBoundingBox(CBoundingBox3D^ bb )
{
Com::CBoundingBox3D *bb_ = bb->Self;
this->self->SetBoundingBox(*bb_);
}
bool COctTree::Check()
{
return this->self->Check();
}
void COctTree::GetAllPointInCell(unsigned int icell_in, [Runtime::InteropServices::Out] IList<unsigned int>^% aIndexVec ) // OUT:aIndexVec
{
std::vector<unsigned int> aIndexVec_;
std::vector<unsigned int>::iterator itr;
this->self->GetAllPointInCell(icell_in, aIndexVec_);
List<unsigned int>^ list = gcnew List<unsigned int>();
if (aIndexVec_.size() > 0)
{
for (itr = aIndexVec_.begin(); itr != aIndexVec_.end(); itr++)
{
list->Add(*itr);
}
}
aIndexVec = list;
}
int COctTree::GetIndexCell_IncludePoint( CVector3D^ VecIns )
{
Com::CVector3D *VecIns_ = VecIns->Self;
return this->self->GetIndexCell_IncludePoint(*VecIns_);
}
bool COctTree::IsPointInSphere( double radius, CVector3D^ vec )
{
Com::CVector3D *vec_ = vec->Self;
return this->self->IsPointInSphere(radius, *vec_);
}
void COctTree::GetBoundaryOfCell(unsigned int icell_in, CBoundingBox3D^% bb )
{
Com::CBoundingBox3D *bb_ = new Com::CBoundingBox3D();
this->self->GetBoundaryOfCell(icell_in, *bb_);
bb = gcnew CBoundingBox3D(bb_);
}
// -1:成功
// -2:範囲外
// 0~:ダブってる点の番号
int COctTree::InsertPoint( unsigned int ipo_ins, CVector3D^ VecIns )
{
Com::CVector3D *VecIns_ = VecIns->Self;
return this->self->InsertPoint(ipo_ins, *VecIns_);
}
} |
9af48dab0e38c9d8d31457ef0a9d912dc91b526b | 1169cc24e1d2af554e37bb1d008014a2bdd8999e | /xru_ZGM/Poppy/Dialog.hpp | 65e97a9a9d740313d699190c952feb7a8ec1b3b7 | [] | no_license | xrufix/ZGM | 4b6cb53364667a648f84eb0506dcb0b80d891386 | 5b12b238e41eb2a946230cf7ca480225da500650 | refs/heads/master | 2021-06-08T21:03:18.523673 | 2019-12-22T14:02:00 | 2019-12-22T14:02:00 | 107,270,391 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,989 | hpp | Dialog.hpp | class RscPoppyMessageBox {
idd = -1;
movingEnable = 0;
enableSimulation = 1;
controlsBackground[] = {
"pnlBackground",
"lblHeader",
"lblMessage",
"imgBtnPrevious",
"imgBtnNext",
"imgBtnClose"
};
controls[] = {
"btnPrevious",
"btnNext",
"btnClose"
};
class pnlBackground {
idc = 0;
type = 0;
style = 0;
moving = 0;
text = "";
font = "PuristaMedium";
sizeEx = 0.03;
colorBackground[] = {0.2, 0.2, 0.2, 1};
colorText[] = {0, 0, 0, 0};
x = "safeZoneX + safeZoneW - 0.4";
y = "safeZoneY + safeZoneH";
w = "0.4 + 0.1";
h = "0.25 + 0.1";
};
class lblHeader {
idc = 20;
type = 0;
style = 0;
moving = 0;
text = "";
font = "PuristaMedium";
sizeEx = 0.04;
colorBackground[] = {0, 0, 0, 0};
colorText[] = {1, 1, 1, 1};
x = "safeZoneX + safeZoneW - 0.4 + 0.015 * 3 / 4";
y = "safeZoneY + safeZoneH + 0.01";
w = "0.4 - 0.03 * 3 / 4";
h = "0.06";
};
class lblMessage {
idc = 21;
type = 0;
style = 528;
moving = 0;
lineSpacing = 1;
text = "";
font = "PuristaMedium";
sizeEx = 0.03;
colorBackground[] = {0, 0, 0, 0};
colorText[] = {1, 1, 1, 1};
x = "safeZoneX + safeZoneW - 0.4 + 0.015 * 3 / 4";
y = "safeZoneY + safeZoneH + 0.06";
w = "0.4 - 0.03 * 3 / 4";
h = "0.25 - 0.1";
};
class imgBtnPrevious {
idc = 22;
type = 0;
style = 2096;
moving = 0;
text = "Poppy\UI\previous.paa";
font = "PuristaMedium";
sizeEx = 0.03;
colorBackground[] = {0.2, 0.2, 0.2, 1};
colorText[] = {1, 1, 1, 1};
x = "safeZoneX + safeZoneW - 0.03 * 3";
y = "safeZoneY + safeZoneH + 0.02";
w = "0.03";
h = "0.03";
};
class imgBtnNext: imgBtnPrevious {
idc = 23;
text = "Poppy\UI\next.paa";
x = "safeZoneX + safeZoneW - 0.03 * 2";
y = "safeZoneY + safeZoneH + 0.02";
};
class imgBtnClose: imgBtnPrevious {
idc = 24;
text = "Poppy\UI\close.paa";
x = "safeZoneX + safeZoneW - 0.03 * 2";
y = "safeZoneY + safeZoneH + 0.02";
};
class btnPrevious {
idc = 10;
type = 1;
style = 0;
moving = 0;
text = "";
font = "PuristaMedium";
sizeEx = 0.03;
borderSize = 0;
colorBackground[] = {0, 0, 0, 0};
colorBackgroundActive[] = {0, 0, 0, 0};
colorBackgroundDisabled[] = {0, 0, 0, 0};
colorBorder[] = {0, 0, 0, 0};
colorDisabled[] = {0, 0, 0, 0};
colorFocused[] = {0, 0, 0, 0};
colorShadow[] = {0, 0, 0, 0};
colorText[] = {0, 0, 0, 0};
default = 0;
offsetPressedX = 0;
offsetPressedY = 0;
offsetX = 0;
offsetY = 0;
soundClick[] = {"", 0, 1};
soundEnter[] = {"", 0, 1};
soundEscape[] = {"", 0, 1};
soundPush[] = {"", 0, 1};
x = "safeZoneX + safeZoneW - 0.03 * 3";
y = "safeZoneY + safeZoneH + 0.02";
w = "0.03";
h = "0.03";
onButtonClick = "Poppy_logIndex = Poppy_logIndex - 1; [ctrlParent (_this select 0)] call Poppy_fnc_updateMessageBox;";
};
class btnNext: btnPrevious {
idc = 11;
x = "safeZoneX + safeZoneW - 0.03 * 2";
y = "safeZoneY + safeZoneH + 0.02";
onButtonClick = "Poppy_logIndex = Poppy_logIndex + 1; [ctrlParent (_this select 0)] call Poppy_fnc_updateMessageBox;";
};
class btnClose: btnPrevious {
idc = 12;
x = "safeZoneX + safeZoneW - 0.03 * 2";
y = "safeZoneY + safeZoneH + 0.02";
onButtonClick = "Poppy_log = []; (ctrlParent (_this select 0)) closeDisplay 1";
};
};
|
e2fa20d44897cf2ef4da16a7c8ddcca6308ae626 | eae8c2b8970210ef5e3b25bfb77d703818b351c1 | /Server/GameThread.cpp | 8f25031ed577df3fa1ba71a692df87c1e4e43c41 | [] | no_license | fpusderkis/TP-Final-Taller-I | 62f971d025c544953d341e711fa448341cd1719a | d30301a96fea7ba641574112e39646211924db49 | refs/heads/master | 2022-01-19T23:00:49.506962 | 2019-06-26T02:49:01 | 2019-06-26T02:49:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,391 | cpp | GameThread.cpp | #include <Common/exceptions.h>
#include <algorithm>
#include <iostream>
#include <chrono>
#include "GameThread.h"
#include "DTOProcessor.h"
#include "Stage.h"
#include "Player.h"
#define NEW_PLAYER_ADDED_MSG "Nuevo jugador agregado a la partida\n"
#define PLAYER_DELETED_MSG "Un jugador ha salido de la partida\n"
#define NEW_OWNER_MSG "Ahora sos el owner de la partida, ingresa 's' para comenzar la partida\n"
#define OWNER_BEGAN_GAME "Owner inicio la partida, presiona 's' para comenzar\n"
#define NEW_OWNER (uint8_t) 2
#define NOTIFICATION (uint8_t) 1
#define BEGIN_GAME (uint8_t) 0
using namespace std::chrono;
using std::move;
using std::ref;
using std::lock_guard;
using std::mutex;
using std::cout;
using std::endl;
using std::for_each;
using std::shared_ptr;
using std::cerr;
void GameThread::sendToAllPlayers(std::shared_ptr<ProtocolDTO> &dto, Stage &stage) {
std::vector<size_t> to_delete;
for_each(_players.begin(), _players.end(), [this, &dto, &to_delete] (Player* &player) {
try {
if (dto) // Verifico no sea nullptr
player->send(dto);
} catch(FailedSendException& e) { // Medida seguridad, almaceno ids de clientes desonectados
to_delete.push_back(player->id());
}
});
// Elimino clientes que se desonectaron
for_each(to_delete.begin(), to_delete.end(), [&](size_t &id) {
stage.deletePlayer(id);
deletePlayer(id);
});
}
void GameThread::run(shared_ptr<Configuration> c) {
try {
Stage stage(_map_filename, c); // Creo stage en tiempo de espera al comienzo
// Loop esperando a que owner inicie la partida. Verifico haya jugadores conectados
while (!_begin_game && !_empty_game && !_game_finished) {
std::this_thread::sleep_for(milliseconds(500)); // Duermo thread esperando el inicio
auto event = _events_queue.getTopAndPop();
if (event != nullptr)
switch (event->getProtocolId()) {
case PROTOCOL_QUIT: // Jugador que salio de la partida
deletePlayer(event->getPlayerId()); // Elimino jugador de la partida
break;
case PROTOCOL_BEGIN:
if (event->getPlayerId() == 0) { // Solo owner puede iniciar partida
_begin_game = true;
notifyOwnerBeganGame();
}
break;
}
}
if (_begin_game && !_empty_game && !_game_finished) {
stage.createChells(_players.size()); // Creo los chells determinados los jugadores
// Envio escenario completo a cada jugador
auto stage_dtos = stage.getInitialConfiguration();
for_each(stage_dtos.begin(), stage_dtos.end(), [&](shared_ptr<ProtocolDTO> &dto) {
sendToAllPlayers(dto, ref(stage));
});
// Notifico a cada jugador su id
std::vector<size_t> to_delete;
for_each(_players.begin(), _players.end(), [this, &to_delete](Player* &player) {
auto player_id_dto = DTOProcessor::createPlayerIdDTO(player->id());
try {
player->send(player_id_dto);
} catch(FailedSendException& e) { // Cliente desconectado
to_delete.push_back(player->id());
}
});
// Elimino posibles clientes que se desonectaron
for_each(to_delete.begin(), to_delete.end(), [&](size_t &id) {
stage.deletePlayer(id);
deletePlayer(id);
});
to_delete.clear();
// Notifico a cada jugador que comienza la partida
auto begin_dto = DTOProcessor::createBeginDTO();
sendToAllPlayers(begin_dto, ref(stage));
cout << "Comienza la partida " << _id << endl;
// Loop mientras haya jugadores y no haya terminado el juego
while (!_empty_game && !_game_finished) {
auto start = high_resolution_clock::now();
for (auto e = _events_queue.getTopAndPop(); e; e = _events_queue.getTopAndPop()) {
stage.apply(e->getPtr().get(), e->getPlayerId());
if (e->getProtocolId() == PROTOCOL_QUIT)
deletePlayer(e->getPlayerId()); // Elimino jugador de la partida
}
// Step
stage.step();
// Notifico cambios a los jugadores
auto dto_vector = stage.getUpdatedDTO();
for_each(dto_vector.begin(), dto_vector.end(), [&](shared_ptr<ProtocolDTO>dto){
sendToAllPlayers(dto, ref(stage));
}); // Envio DTO de objetos a actualizar
dto_vector = stage.getDeletedDTO();
for_each(dto_vector.begin(), dto_vector.end(), [&](shared_ptr<ProtocolDTO>dto){
sendToAllPlayers(dto, ref(stage));
}); // Envio DTO de objetos a eliminar
if (stage.someoneWon()) {
auto winner_dto = DTOProcessor::createWinnerDTO();
sendToAllPlayers(winner_dto, ref(stage));
_game_finished = true;
}
// Sleep
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
int sleep_time = (1 / c->getFps()) * 1000 - duration.count();
if (sleep_time > 0)
std::this_thread::sleep_for(milliseconds(sleep_time));
}
}
cout << "Partida "<<_id << " finalizada"<<endl;
_dead_thread = true; // Registro que se llego al fin del thread
} catch(const std::exception& e) {
_dead_thread = true; // Registro que se llego al fin del thread
cerr << "Game Thread: " << e.what();
} catch(...) {
_dead_thread = true; // Registro que se llego al fin del thread
cerr << "Game Thread: " << UnknownException().what();
}
}
GameThread::GameThread(Player* new_player, const size_t &max_players, std::string &&map_filename,
const size_t &id, std::shared_ptr<Configuration> configuration) :
_map_filename(move(map_filename)), _game_finished(false), _empty_game(false),
_begin_game(false), _dead_thread(false), _max_players(max_players),_id(id),
_gameloop(&GameThread::run, this, configuration) {
addPlayerIfOpenToNewPlayersAndNotFull(new_player);
}
bool GameThread::addPlayerIfOpenToNewPlayersAndNotFull(Player *new_player) {
lock_guard<mutex> lock(_m);
// Maximo de jugadores alcanzado o partida ya comenzo
if (_players.size() >= _max_players || _begin_game)
return false;
new_player->setId(_players.size());
if (new_player->id() != 0) // No notifico cuando es el primer jugador
notifyAllNewPlayer();
_players.push_back(new_player);
return true;
}
void GameThread::deletePlayer(const size_t &id) {
lock_guard<mutex> lock(_m);
_players.remove_if([this, &id](Player* p) {
if (!_begin_game && p->id() > id) {
p->setId(p->id() - 1); // Actualizo ids mientras busco, en caso de juego aun no inciado
return false;
}
return (p->id() == id) ? (p->disconnectAndJoin(), delete p, p = nullptr, true) : false;
});
if (!_begin_game) { // Notificaciones previas al inicio del juego
notifyAllDeletedPlayer();
if (id == 0) // Elimine al owner, notifico al nuevo
notifyNewOwner();
}
if (_players.empty()) { // Se desconectaron todos los jugadores
_empty_game = true;
_game_finished = true;
}
}
const size_t GameThread::id() const {
return _id;
}
SafeQueue<std::shared_ptr<Event>>& GameThread::getEventsQueue() {
return _events_queue;
}
bool GameThread::isDead() {
return _dead_thread;
}
void GameThread::endGameAndJoin() {
_game_finished = true;
_gameloop.join();
// Una vez finalizado el gameloop elimino los jugadores
std::for_each(_players.begin(), _players.end(), [](Player* &player) {
player->disconnectAndJoin();
delete player;
player = nullptr;
});
}
bool GameThread::openToNewPlayers() {
return !_begin_game; // Juego no comenzo
}
size_t GameThread::maxPlayers() {
return _max_players;
}
size_t GameThread::playersJoined() {
return _players.size();
}
std::string &GameThread::mapFileName() {
return _map_filename;
}
void GameThread::notifyAllNewPlayer() {
for_each(_players.begin(), _players.end(), [this] (Player* &player) {
player->notify(NOTIFICATION, NEW_PLAYER_ADDED_MSG);
});
}
void GameThread::notifyAllDeletedPlayer() {
for_each(_players.begin(), _players.end(), [this] (Player* &player) {
player->notify(NOTIFICATION, PLAYER_DELETED_MSG);
});
}
void GameThread::notifyNewOwner() {
if (!_players.empty()) {
auto new_owner = _players.front();
new_owner->notify(NEW_OWNER, NEW_OWNER_MSG);
}
}
void GameThread::notifyOwnerBeganGame() {
for_each(_players.begin(), _players.end(), [this] (Player* &player) {
player->notify(BEGIN_GAME, OWNER_BEGAN_GAME);
});
}
|
1a9d5a2fd4bafc75839c3a838ac4fec74bd9868f | ea4bcc1aab9dcc65a9ed22dd19e2a379412f2960 | /BFS/B1613/역사.cpp | 61de4d5bed01add63f6c6acf8c47caf86158f3a7 | [] | no_license | yoon1fe/ProblemSolving | 3315e582f01da29571b3341dc50415b25da4af04 | 32c7c9baeebec752bfc8dac33ebd51774fc4fae2 | refs/heads/master | 2023-07-18T15:35:53.366737 | 2021-09-10T13:39:34 | 2021-09-10T13:39:34 | 280,450,614 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 1,824 | cpp | 역사.cpp | //BFS로 풀면 시간초과가 뜬다. 플로이드 와샬 알고리즘 이용
#include <iostream>
using namespace std;
int n, k, s;
int start, dest;
int d[401][401];
void floyd() {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= n; k++) {
if (i == j || j == k || k == i) continue;
if (d[j][k] == 0) {
if (d[j][i] == 1 && d[i][k] == 1)
d[j][k] = 1;
if (d[j][i] == -1 && d[i][k] == -1)
d[j][k] = -1;
}
}
}
}
}
int main() {
cin >> n >> k;
int a, b;
for (int i = 0; i < k; i++) {
cin >> a >> b;
d[a][b] = -1;
d[b][a] = 1;
}
floyd();
cin >> s;
for (int i = 0; i < s; i++) {
cin >> start >> dest;
cout << d[start][dest] << "\n";
}
return 0;
}
//#include <iostream>
//#include <algorithm>
//#include <vector>
//#include <queue>
//#include <cstring>
//using namespace std;
//
//int n, k, s;
//int start, dest;
//vector<int> v[401];
//vector<int> r[401];
//bool c[401] = { 0, };
//
//int bfs(int s, vector<int> v[]) {
// queue<int> q;
// q.push(s);
// c[s] = true;
//
// while (!q.empty()) {
// int cur = q.front();
// q.pop();
// if (cur == dest)
// return 1;
//
// for (int i = 0; i < v[cur].size(); i++) {
// int next = v[cur].at(i);
// if (!c[next]) {
// q.push(next);
// c[next] = true;
// }
// }
// }
//
// return -1;
//}
//int main() {
// int a, b, ans1, ans2;
// cin >> n >> k;
// for (int i = 0; i < k; i++) {
// cin >> a >> b;
// v[a].push_back(b);
// r[b].push_back(a);
// }
//
// cin >> s;
//
// for (int i = 0; i < s; i++) {
// cin >> start >> dest;
// ans1 = bfs(start, v);
// ans2 = bfs(start, r);
// if (ans1 == ans2)
// cout << 0 << "\n";
// else
// (ans1 > ans2) ? (cout << -1 << "\n") : (cout << 1 << "\n");
//
// memset(c, false, sizeof(c));
// }
//
// return 0;
//} |
0d28d9573caf945e2029c3a786a00f5c8d7bdd7c | 1b06d5bf179f0d75a30a4b020dd88fc5b57a39bc | /Repository/Logix/system/ndg/phase2/ctl_pe/tells_bodies.cp | 64f62d2b11b1b5c94a831e84f65b31e1b583ac0d | [] | no_license | ofirr/bill_full_cvs | b508f0e8956b5a81d6d6bca6160054d7eefbb2f1 | 128421e23c7eff22afe6292f88a01dbddd8b1974 | refs/heads/master | 2022-11-07T23:32:35.911516 | 2007-07-06T08:51:59 | 2007-07-06T08:51:59 | 276,023,188 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,688 | cp | tells_bodies.cp | /* $Header: /baz/users/cvs-root/Source/system/ndg/phase2/ctl_pe/tells_bodies.cp,v 1.1.1.1 1993/12/31 10:42:21 fcp Exp $ */
-language(compound).
-export([tells_bodies/8]).
-mode(trust).
procedure tells_bodies(Dg, BH, Dic, Ctl, Ch, Name, SC, Done).
tells_bodies(Dg, BH, Dic, Ctl, Ch, Name, SC, Done)
:-
Dg = [{[],DgBodies}] : BH = _ |
bodies#bodies(DgBodies, Ctl, Dic, Ch, Name, SC, Done) ;
Dg ? Dg1, Dg1 = {DgTells,DgBodies},
Dg1 =\= goto(_), Dg1 =\= suspend(_),
DgTells =\= [],
Dg' =\= [suspend], Dg' =\= [suspend(_)], Dg' =\= [suspend(_,_)],
Ctl = CtlH\CtlT, SC = {L,R}, Done = {DL,DR} :
CtlH ! set_HBT |
tell_body#tell_body(DgTells, DgBodies, CtlH'\[label(L1)|CtlM],
label(L1), Dic, Ch, Name, {L,M}, {DL,DM}),
tells_bodies_nexts(Dg', BH, Dic, CtlM\CtlT, Ch, Name, {M,R}, {DM,DR}) ;
Dg ? Dg1, Dg1 = {DgTells,DgBodies},
Dg1 =\= goto(_), Dg1 =\= suspend(_),
DgTells =\= [],
Dg' = [suspend],
Ctl = CtlH\CtlT, SC = {L,R}, Done = {DL,DR} :
Ctl' = CtlM\CtlT, SC' = {M,R}, Done' = {DM,DR} |
tell_body#tell_body(DgTells, DgBodies, CtlH\[label(L1)|CtlM],
label(L1), Dic, Ch, Name, {L,M}, {DL,DM}),
tells_bodies ;
Dg ? Dg1, Dg1 = {DgTells,DgBodies},
Dg1 =\= goto(_), Dg1 =\= suspend(_),
DgTells =\= [],
Dg' = [suspend(_)],
Ctl = CtlH\CtlT, SC = {L,R}, Done = {DL,DR} :
Ctl' = CtlM\CtlT, SC' = {M,R}, Done' = {DM,DR} |
tell_body#tell_body(DgTells, DgBodies, CtlH\[label(L1)|CtlM],
label(L1), Dic, Ch, Name, {L,M}, {DL,DM}),
tells_bodies ;
Dg ? Dg1, Dg1 = {DgTells,DgBodies},
Dg1 =\= goto(_), Dg1 =\= suspend(_),
DgTells =\= [],
Dg' = [suspend(_,_)],
Ctl = CtlH\CtlT, SC = {L,R}, Done = {DL,DR} :
Ctl' = CtlM\CtlT, SC' = {M,R}, Done' = {DM,DR} |
tell_body#tell_body(DgTells, DgBodies, CtlH\[label(L1)|CtlM],
label(L1), Dic, Ch, Name, {L,M}, {DL,DM}),
tells_bodies ;
Dg = [suspend], Ctl = CtlH\CtlT, Ch = {_,Ch1} : BH = _|
store_regs(Dic, CtlH\[suspend|CtlT], Ch1, Name, SC, Done) ;
Dg = [suspend(F)], Ctl = CtlH\CtlT, Ch = {Ch2,Ch1}, SC = {L,R},
Name = {_,_,_,Dic1,_} : BH = _,
write_channel(spawn({F,Dic1,Addr,{L,M}}),Ch2) |
% build_dic(Dic1, Dic2),
store_regs(Dic, CtlH\[suspend(Addr)|CtlT], Ch1, Name, {M,R}, Done) ;
Dg = [suspend(F,S)], Ctl = CtlH\CtlT, Ch = {Ch2,Ch1}, SC = {L,R},
Name = {_,_,_,Dic1,_} : BH = _,
write_channel(spawn({F,Dic1,AddrF,{L,M}}),Ch2),
write_channel(spawn({S,Dic1,AddrS,{M,M1}}),Ch2) |
% build_dic(Dic1, Dic2),
store_regs(Dic, CtlH\[suspend(AddrF,AddrS)|CtlT], Ch1, Name,
{M1,R}, Done) ;
Dg = [goto(Lab)], BH = {_,_,[]},
Ctl = CtlH\CtlT, SC = {L,R}, Done = {DL,DR} :
CtlH = [goto(Lab)|CtlT], L = R, DL = DR, Dic = _, Ch = _, Name = _ ;
Dg = [goto(_)], BH = {_,_,Go}, Go =\= [],
Ctl = CtlH\CtlT, SC = {L,R}, Done = {DL,DR} :
CtlH = [Go|CtlT], L = R, DL = DR, Dic = _, Ch = _, Name = _.
tells_bodies_nexts(Dg, BH, Dic, Ctl, Ch, Name, SC, Done)
:-
Dg ? Dg1, Dg1 = {DgTells,DgBodies},
Dg1 =\= goto(_), Dg1 =\= suspend(_),
DgTells =\= [],
Ctl = CtlH\CtlT, SC = {L,R}, Done = {DL,DR} :
CtlH ! undo,
Ctl' = CtlM\CtlT, SC' = {M,R}, Done' = {DM,DR} |
tell_body#tell_body(DgTells, DgBodies, CtlH'\[label(L1)|CtlM],
label(L1), Dic, Ch, Name, {L,M}, {DL,DM}),
tells_bodies_nexts ;
Dg = [suspend], Ctl = CtlH\CtlT, Ch = {_,Ch1} : BH = _ |
store_regs(Dic, CtlH\[suspend|CtlT], Ch1, Name, SC, Done) ;
Dg = [suspend(F)], Ctl = CtlH\CtlT, Ch = {Ch2,Ch1}, SC = {L,R},
Name = {_,_,_,Dic1,_} :
write_channel(spawn({F,Dic1,Addr,{L,M}}),Ch2), BH = _ |
% build_dic(Dic1, Dic2),
store_regs(Dic, CtlH\[suspend(Addr)|CtlT], Ch1, Name, {M,R}, Done) ;
Dg = [suspend(F,S)], Ctl = CtlH\CtlT, Ch = {Ch2,Ch1}, SC = {L,R},
Name = {_,_,_,Dic1,_} :
write_channel(spawn({F,Dic1,AddrF,{L,M}}),Ch2),
write_channel(spawn({S,Dic1,AddrS,{M,M1}}),Ch2), BH = _ |
% build_dic(Dic1, Dic2),
store_regs(Dic, CtlH\[suspend(AddrF,AddrS)|CtlT], Ch1, Name,
{M1,R}, Done) ;
/*
Dg = [goto(Lab)], BH = {_,_,[]},
Ctl = CtlH\CtlT, SC = {L,R}, Done = {DL,DR} :
CtlH = [undo,goto(Lab)|CtlT],
L = R, DL = DR, Dic = _, Ch = _, Name = _ ;
*/
Dg = [goto(_)], BH = {_,_,Go}, Go =\= [],
Ctl = CtlH\CtlT, SC = {L,R}, Done = {DL,DR} :
CtlH = [undo,Go|CtlT],
L = R, DL = DR, Dic = _, Ch = _, Name = _.
store_regs(Dic, Ctl, Ch, Name, SC, Done)
:-
Name = {{_,Ar,_,_},_,_,_,_}, Ctl = CtlH\CtlT, SC = {L,R} |
assignment(Src, Dest, CtlM\CtlT, {L,M}),
prepare_assignment(Ar, Src, Dest, Dic, CtlH\CtlM, Ch, {M,R}, Done).
assignment(Src, Dest, Ctl, SC)
:-
Src =\= [], Dest =\= [], Ctl = CtlH\CtlT, SC = {L,R} :
CtlH = [multiple_copy(Src,Dest)|CtlT], L = R ;
Src = [], Dest = [], Ctl = CtlH\CtlT, SC = {L,R} : CtlH = CtlT, L = R.
prepare_assignment(Ar, Src, Dest, Dic, Ctl, Ch, SC, Done)
:-
Ar > 0, Ctl = CtlH\CtlT : Ctl' = CtlM\CtlT,
write_channel(look([Ar],{AddrReg,_,_,_},Dic),Ch) |
assign(a(Ar), AddrReg, CtlH\CtlM, Dest, Dest', Src, Src'),
Ar' := Ar - 1,
prepare_assignment ;
Ar = 0, Ctl = CtlH\CtlT, SC = {L,R}, Done = {DL,DR} :
Dest = [], Src = [], CtlH = CtlT, L = R, DL = DR, Dic = _, Ch = _.
assign(Reg, AddrReg, Ctl, Dest, DestT, Src, SrcT)
:-
AddrReg = {Areg,-1}, Areg =\= Reg, Ctl = CtlH\CtlT :
CtlH = [decrement_pointer(Areg,Reg)|CtlT], Dest = DestT, Src = SrcT;
AddrReg = {Reg,-1}, Ctl = CtlH\CtlT :
CtlH = [decrement_pointer(Reg)|CtlT], Dest = DestT, Src = SrcT;
AddrReg = Reg, Ctl = CtlH\CtlT : Dest = DestT, Src = SrcT, CtlH = CtlT;
AddrReg = a(_), AddrReg =\= Reg, Ctl = CtlH\CtlT :
Dest = [Reg|DestT], Src = [AddrReg|SrcT], CtlH = CtlT.
|
cd958324a5794d48c3f313cf537db7bc404a044a | 572547fb46d8425892a81b135cb1910eb0a2d04b | /example/20.显示器类/6.WS2812/1.test.cpp | 9bd5fbb90fe4efd67917ed7243d8171bd5309094 | [] | no_license | shentqlf/eBox_Transmitter | 6f239c51046f20fc7bfd921b282f543940f9041c | fe6771743c368ea7e3c802a77329d6b91673db42 | refs/heads/master | 2020-03-19T04:45:52.188044 | 2018-06-07T13:12:27 | 2018-06-07T13:12:27 | 135,863,350 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 834 | cpp | 1.test.cpp | /**
******************************************************************************
* @file : *.cpp
* @author : shentq
* @version: V1.2
* @date : 2016/08/14
* @brief ebox application example .
*
* Copyright 2016 shentq. All Rights Reserved.
******************************************************************************
*/
#include "ebox.h"
#include "WS2812B.h"
WS2812B ws2812b(&PA11);
void setup()
{
ebox_init();
ws2812b.initialize(8);
}
int main(void)
{
setup();
ws2812b.set_color(10,80,0,0);
ws2812b.set_color(20,70,0,1);
ws2812b.set_color(30,60,0,2);
ws2812b.set_color(40,50,0,3);
ws2812b.set_color(50,40,0,4);
ws2812b.set_color(60,30,0,5);
ws2812b.set_color(70,20,0,6);
ws2812b.set_color(80,10,0,7);
ws2812b.enable();
while(1)
{
delay_ms(1000);
}
}
|
51eba91fb3b98a3a0127b58471c9dc35d8fb8835 | 41279e0ed19e26cc0fcaafa229604d1094aed6a8 | /include/IUpdateable.hpp | 79283db6f22e71808c85dc61449161337ee58182 | [] | no_license | ChuxiongMa/TextAdventure | 20a180747414ede1a8b0e85869809f955b067b11 | 4f217106de6908909f17408c16df822ed9543284 | refs/heads/master | 2016-08-13T02:01:58.490646 | 2016-02-21T23:26:48 | 2016-02-21T23:26:48 | 52,233,748 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 405 | hpp | IUpdateable.hpp | #ifndef IUPDATEABLE_H
#define IUPDATEABLE_H
namespace textadventure {
class IUpdateable {
public:
/**
* This will act as the updatable's "main loop".
*/
virtual void update() = 0;
/**
* This notifies the client code whether or not the game has stopped.d
*
* @returns whether or not the game has stopped.
*/
virtual bool hasStopped() = 0;
};
}
#endif
|
ef8c231f2ab629403d171a059fad17b4e0d56a42 | 50e94a66c8ea2ec3035d341b1d10b5507bd23ef8 | /TouchGFX/generated/gui_generated/src/containers/ScreenBackgroundContainerBase.cpp | e4ffa84bc38c45ab913e40271e8b30e659e375f1 | [] | no_license | frigodaw/pathTracker | 7b76d4972280f6bdfd827fb4493747016fc5051b | 5198198f4fc2466aeb499b523cd14bf3005dfb82 | refs/heads/master | 2020-12-10T21:43:55.574214 | 2020-10-06T19:39:00 | 2020-10-06T19:39:00 | 233,717,928 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,503 | cpp | ScreenBackgroundContainerBase.cpp | /*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/containers/ScreenBackgroundContainerBase.hpp>
#include <touchgfx/Color.hpp>
#include "BitmapDatabase.hpp"
ScreenBackgroundContainerBase::ScreenBackgroundContainerBase() :
buttonCallback(this, &ScreenBackgroundContainerBase::buttonCallbackHandler)
{
setWidth(240);
setHeight(320);
Background.setPosition(0, 0, 240, 320);
Background.setColor(touchgfx::Color::getColorFrom24BitRGB(211, 236, 252));
ExitButton.setXY(0, 260);
ExitButton.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_ICON_BUTTON_ID), touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_ICON_BUTTON_PRESSED_ID), touchgfx::Bitmap(BITMAP_BLUE_ICONS_HOME_32_ID), touchgfx::Bitmap(BITMAP_BLUE_ICONS_HOME_32_ID));
ExitButton.setIconXY(15, 16);
ExitButton.setAction(buttonCallback);
add(Background);
add(ExitButton);
}
void ScreenBackgroundContainerBase::initialize()
{
}
void ScreenBackgroundContainerBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
if (&src == &ExitButton)
{
//GoToStartScreen
//When ExitButton clicked change screen to StartScreen
//Go to StartScreen with no screen transition
application().gotoStartScreenScreenNoTransition();
}
}
|
e9a40b9ef102366692a7d89da54919f94cf4a7ef | aecfc8d854067106630c839c1858c25528e28a79 | /conquest_mp/src/ui/UINetDisplay.h | 77bdc2f6f999f5fa90bdfa943379fd328d412ad6 | [
"MIT"
] | permissive | kaapomoi/conquest | 54ad3057a629252e43d0610c1f9fd3ba7b694270 | af2993b7fe7fa1cc7b1c574f56814194b8b11bbd | refs/heads/master | 2023-06-01T17:41:22.434659 | 2021-05-07T12:33:32 | 2021-05-07T12:33:32 | 288,390,193 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 966 | h | UINetDisplay.h | #pragma once
#include <core/Application.h>
#include <ui/UIBase.h>
#include <ui/UIClickable.h>
#include <neuralnet/NeuralNet.h>
class UINetDisplay : public UIBase, public UIClickable
{
public:
UINetDisplay(std::string name, k2d::vf2d position, k2d::vf2d size, float depth, k2d::GLTexture texture, k2d::SpriteBatch* sb, k2d::Application* app);
~UINetDisplay();
void Update(double dt) override;
void SetNeuralNetPtr(NeuralNet* nn);
void UpdateAlphas();
void AddBackground(k2d::Color color);
void OnClick() override;
void ToggleWeightsOnlyMode();
private:
NeuralNet* net;
k2d::Application* app;
k2d::GLTexture texture;
k2d::SpriteBatch* sb;
bool weights_only_mode;
k2d::vf2d node_size;
k2d::vf2d weight_size;
k2d::Sprite* background_sprite;
std::vector<int> topology;
std::vector<k2d::Sprite*> node_sprites;
std::vector<k2d::Sprite*> weight_sprites;
std::vector<std::vector<k2d::vf2d>> node_positions;
}; |
44f11cc217ce03112e7feb3c268ec95bffd84fdc | 01140446d6211a53e4c46d7acdfe2341ecadf4fc | /src/Event.cpp | 6b9b794da750d3dc240278ee91e5464ac99aa434 | [] | no_license | mmnuria/Shopping3 | 5fa4c8c76fa84795c3b843262ee4df9464013809 | e950637069d4003c8cd810bb0016015c0b962288 | refs/heads/master | 2023-04-22T01:05:25.178677 | 2021-05-08T18:10:26 | 2021-05-08T18:10:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,093 | cpp | Event.cpp | /**
* @file Event.cpp
* @author MP-Team DECSAI
* @warning Update the class. Methods print and read To be implemented by students
*
*/
#include "Event.h"
using namespace std;
Event::Event() {
initDefault();
}
void Event::initDefault() {
set(EVENT_DEFAULT);
}
Event::Event(const string &line) {
set(line);
}
DateTime Event::getDateTime() const {
return _dateTime;
}
string Event::getType() const {
return _type;
}
string Event::getProductID() const {
return _prod_id;
}
string Event::getCategoryID() const {
return _cat_id;
}
string Event::getCategoryCode() const {
return _cat_cod;
}
string Event::getBrand() const {
return _brand;
}
double Event::getPrice() const {
return _price;
}
string Event::getUserID() const {
return _user_id;
}
string Event::getSession() const {
return _session;
}
void Event::setDateTime(string const &time) {
_dateTime.set(time);
}
void Event::setType(std::string const &type) {
bool valid = false;
for (int i = 0; i < sizeof (VALID_TYPES) / sizeof (string) && valid == false; i++) { // Checks if the input type is among the valid types.
if (type == VALID_TYPES[i]) {
valid = true;
}
}
if (valid) {
_type = type;
} else {
_type = VALID_TYPES[0];
}
}
void Event::setProductID(std::string const &prod_id) {
if (prod_id != "") {
_prod_id = prod_id;
} else {
_prod_id = EMPTY_FIELD;
}
}
void Event::setCategoryID(std::string const &cat_id) {
_cat_id = cat_id;
}
void Event::setCategoryCode(std::string const &cat_cod) {
_cat_cod = cat_cod;
}
void Event::setBrand(std::string const &brand) {
_brand = brand;
}
void Event::setPrice(const double price) {
if (price >= 0) {
_price = price;
} else {
_price = -1.0;
}
}
void Event::setPrice(const std::string price) { //Added this function to not need to make the conversion from string to double before calling the function
try {
setPrice(stod(price));
} catch (...) {
setPrice(-1.0);
}
}
void Event::setUserID(std::string const &user_id) {
if (user_id != "") {
_user_id = user_id;
} else {
_user_id = EMPTY_FIELD;
}
}
void Event::setSession(std::string const &session) {
if (session != "") {
_session = session;
} else {
_session = EMPTY_FIELD;
}
}
void Event::set(std::string const &line) {
string aux[9];
for (int i = 0, j = 0; i < 9; i++) {
aux[i] = line.substr(j, line.find(",", j) - j);
j = line.find(",", j) + 1;
}
setDateTime(aux[0]);
setType(aux[1]);
setProductID(aux[2]);
setCategoryID(aux[3]);
setCategoryCode(aux[4]);
setBrand(aux[5]);
setPrice(aux[6]);
setUserID(aux[7]);
setSession(aux[8]);
}
string Event::to_string() const {
string salida;
salida += _dateTime.to_string();
salida += "," + _type;
salida += "," + _prod_id;
salida += "," + _cat_id;
salida += "," + _cat_cod;
salida += "," + _brand;
salida += "," + std::to_string(_price);
salida += "," + _user_id;
salida += "," + _session;
// salida = salida +"," + DAYNAME[this->getDateTime().weekDay()];
return salida;
}
bool Event::isEmpty() const {
return _prod_id == EMPTY_FIELD || _user_id == EMPTY_FIELD || _session == EMPTY_FIELD || _dateTime.to_string() == DATETIME_DEFAULT;
}
string Event::getField(const string &field) const {
string s, event = to_string();
for (int i = 0; i < sizeof (VALID_FIELDS) / sizeof (*VALID_FIELDS); i++) {
if (field == VALID_FIELDS[i]) {
int x = 0;
for (int j = 0; j < i; j++) {
x = event.find(',', x) + 1;
}
s = event.substr(x, event.find(',', x) - x);
}
}
return s;
}
void Event::write(ofstream &os) {
if (os.is_open()) {
os << to_string();
}
}
void Event::read(ifstream &is) {
if (is.is_open()) {
string line;
getline(is, line);
set(line);
}
}
|
244fcb49f17e623557991121aeb353b4698efdb6 | 0035101c52694ebafad3a501360ec879982f5a2a | /ctci/chapter3_stacks_and_queues/animalShelter.cpp | 1b801e433779b217895577cb738ed6a87937b5f8 | [] | no_license | kimjihwan0208/CodingPractice | 61e28de89254b9cc6edf9c681f9e61b2746a1380 | 526de3c8d7cd9e887db1921fb7f56f499f14b09b | refs/heads/master | 2020-04-10T14:40:12.356427 | 2019-09-28T22:48:54 | 2019-09-28T22:48:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 461 | cpp | animalShelter.cpp | //incomplete
#include <iostream>
#include <iterator>
#include <list>
using namespace std;
struct Animal{
string name = "";
string type = "";
int id;
Animal(string name, string type, int id){
h
}
};
class AnimalQueue{
private:
list<Animal> Dog;
list<Animal> Cat;
public:
void enqueue(Animal animal){
}
void dequeueAny(){
}
void dequeueDog(){
}
void dequeueCat(){
}
};
int main(){
return 0;
} |
39e0dba8b2e338ee1cd4a9472f6e0192042ea6e0 | 74af6e37ed7178c371853538e900750a7704faab | /EspSoftSerialRx.h | 3ad7b7592bec6010f1300897bbc2c5b12f87228f | [] | no_license | scottwday/EspSoftSerial | 1bdd75d00b85c449911dd8d81d359b6e6bea33a9 | f0f14495e05acae9196736d259e56bfa979cd0b8 | refs/heads/master | 2020-05-30T21:39:32.900489 | 2015-12-10T17:58:03 | 2015-12-10T17:58:03 | 40,392,424 | 7 | 1 | null | 2015-12-10T17:58:05 | 2015-08-08T05:17:20 | C++ | UTF-8 | C++ | false | false | 1,512 | h | EspSoftSerialRx.h | /* EspSoftSerial receiver
Scott Day 2015
github.com/scottwday/EspSoftSerial
Uses a pin change interrupt and the tick timer as a uart receiver
*/
#ifndef ESPSOFTSERIAL_H
#define ESPSOFTSERIAL_H
#define MAX_ESPSOFTSERIAL_INSTANCES 4
#define SOFTSERIAL_BUFFER_LEN 256
#define SOFTSERIAL_ERROR_LONGLOW 1
#define SOFTSERIAL_ERROR_STOPBIT 2
#include <Arduino.h>
#include "CircularBuffer.h"
class EspSoftSerialRx
{
private:
typedef void (EspSoftSerialRx::*InterruptHandler)();
unsigned long _halfBitRate;
byte _rxPin;
unsigned long _lastChangeTicks = 0;
byte _errorState = 0;
byte _bitCounter = 0;
unsigned short _bitBuffer = 0;
byte _inInterrupt = 0;
byte _instanceId = 0;
CircularBuffer<byte, SOFTSERIAL_BUFFER_LEN> _buffer;
static byte _numInstances;
static EspSoftSerialRx* _instances[MAX_ESPSOFTSERIAL_INSTANCES];
public:
// Supply the baud rate and the pin you want to use
void begin(const unsigned long baud, const byte rxPin);
// Call this at least every 10 seconds to prevent bytes getting lost
void service();
// Read the next byte from the buffer
bool read(byte& c);
void setEnabled(bool enabled);
void reset();
private:
static void onRxPinChange0();
static void onRxPinChange1();
static void onRxPinChange2();
static void onRxPinChange3();
byte getNumBitPeriodsSinceLastChange(unsigned long ticks);
inline void addBits(byte numBits, byte value);
void onRxPinChange();
};
#endif
|
fae55f15b324a798a16e37cccdd4ed55a74c9415 | bc800acdd48e53165f9fcfcf34e7aa30c4683ce6 | /backends/gdx-backend-iosmonotouch/natives/iosgles20.cpp | 7aafe9e3ff9e728951c49a914cbca56345051a88 | [] | no_license | jaredbracken/libgdx | e905064f6a0e27de331051a2c8a70c5c219862d4 | 15fb5ded7a8914fc77cea0efa5da2af703d631fe | refs/heads/master | 2016-09-06T19:25:33.138335 | 2012-11-10T03:37:48 | 2012-11-10T03:37:48 | 6,623,954 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 55,104 | cpp | iosgles20.cpp | #include <iosgles20.h>
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#include <stdio.h>
static jclass bufferClass;
static jclass byteBufferClass;
static jclass charBufferClass;
static jclass shortBufferClass;
static jclass intBufferClass;
static jclass longBufferClass;
static jclass floatBufferClass;
static jclass doubleBufferClass;
static jclass OOMEClass;
static jclass UOEClass;
static jclass IAEClass;
static jmethodID positionID;
static void
nativeClassInitBuffer(JNIEnv *_env)
{
jclass bufferClassLocal = _env->FindClass("java/nio/Buffer");
bufferClass = (jclass) _env->NewGlobalRef(bufferClassLocal);
byteBufferClass = (jclass) _env->NewGlobalRef(_env->FindClass("java/nio/ByteBuffer"));
charBufferClass = (jclass) _env->NewGlobalRef(_env->FindClass("java/nio/CharBuffer"));
shortBufferClass = (jclass) _env->NewGlobalRef(_env->FindClass("java/nio/ShortBuffer"));
intBufferClass = (jclass) _env->NewGlobalRef(_env->FindClass("java/nio/IntBuffer"));
longBufferClass = (jclass) _env->NewGlobalRef(_env->FindClass("java/nio/LongBuffer"));
floatBufferClass = (jclass) _env->NewGlobalRef(_env->FindClass("java/nio/FloatBuffer"));
doubleBufferClass = (jclass) _env->NewGlobalRef(_env->FindClass("java/nio/DoubleBuffer"));
positionID = _env->GetMethodID(bufferClass, "position","()I");
if(positionID == 0) _env->ThrowNew(IAEClass, "Couldn't fetch position() method");
}
static void
nativeClassInit(JNIEnv *_env)
{
nativeClassInitBuffer(_env);
jclass IAEClassLocal =
_env->FindClass("java/lang/IllegalArgumentException");
jclass OOMEClassLocal =
_env->FindClass("java/lang/OutOfMemoryError");
jclass UOEClassLocal =
_env->FindClass("java/lang/UnsupportedOperationException");
IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
}
static jint getElementSizeShift(JNIEnv *_env, jobject buffer) {
/*if(_env->IsInstanceOf(buffer, byteBufferClass)) return 0;
if(_env->IsInstanceOf(buffer, floatBufferClass)) return 2;
if(_env->IsInstanceOf(buffer, shortBufferClass)) return 1;
if(_env->IsInstanceOf(buffer, charBufferClass)) return 1;
if(_env->IsInstanceOf(buffer, intBufferClass)) return 2;
if(_env->IsInstanceOf(buffer, longBufferClass)) return 3;
if(_env->IsInstanceOf(buffer, doubleBufferClass)) return 3;
_env->ThrowNew(IAEClass, "buffer type unkown! (Not a ByteBuffer, ShortBuffer, etc.)");*/
return 0;
}
inline jint getBufferPosition(JNIEnv *env, jobject buffer)
{
jint ret = env->CallIntMethodA(buffer, positionID, 0);
return ret;
}
static void *
getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
if (!buffer) {
return NULL;
}
void* buf = _env->GetDirectBufferAddress(buffer);
if (buf) {
jint position = getBufferPosition(_env, buffer);
jint elementSizeShift = getElementSizeShift(_env, buffer);
buf = ((char*) buf) + (position << elementSizeShift);
} else {
_env->ThrowNew(IAEClass, "Must use a native order direct Buffer");
}
return buf;
}
static const char* getString( JNIEnv *env, jstring string )
{
return (const char*)env->GetStringUTFChars(string, NULL);
}
static void releaseString( JNIEnv *env, jstring string, const char* cString )
{
env->ReleaseStringUTFChars(string, cString);
}
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_init
(JNIEnv *env, jclass)
{
nativeClassInit( env );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glActiveTexture
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glActiveTexture
(JNIEnv *, jobject, jint texture)
{
glActiveTexture( texture );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glAttachShader
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glAttachShader
(JNIEnv *, jobject, jint program, jint shader)
{
glAttachShader( program, shader );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBindAttribLocation
* Signature: (IILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBindAttribLocation
(JNIEnv *env, jobject, jint program, jint index, jstring name)
{
const char* namePtr = getString( env, name );
glBindAttribLocation( program, index, namePtr );
releaseString( env, name, namePtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBindBuffer
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBindBuffer
(JNIEnv *env, jobject, jint target, jint buffer)
{
glBindBuffer( target, buffer );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBindFramebuffer
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBindFramebuffer
(JNIEnv *env, jobject, jint target, jint framebuffer)
{
glBindFramebuffer( target, framebuffer );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBindRenderbuffer
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBindRenderbuffer
(JNIEnv *env, jobject, jint target, jint renderbuffer)
{
glBindRenderbuffer( target, renderbuffer );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBindTexture
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBindTexture
(JNIEnv *env, jobject, jint target, jint texture)
{
glBindTexture( target, texture );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBlendColor
* Signature: (FFFF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBlendColor
(JNIEnv *env, jobject, jfloat red, jfloat green, jfloat blue, jfloat alpha)
{
glBlendColor( red, green, blue, alpha );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBlendEquation
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBlendEquation
(JNIEnv *env, jobject, jint mode)
{
glBlendEquation( mode );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBlendEquationSeparate
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBlendEquationSeparate
(JNIEnv *env, jobject, jint modeRGB, jint modeAlpha)
{
glBlendEquationSeparate( modeRGB, modeAlpha );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBlendFunc
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBlendFunc
(JNIEnv *env, jobject, jint sfactor, jint dfactor)
{
glBlendFunc( sfactor, dfactor );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBlendFuncSeparate
* Signature: (IIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBlendFuncSeparate
(JNIEnv *env, jobject, jint srcRGB, jint dstRGB, jint srcAlpha, jint dstAlpha)
{
glBlendFuncSeparate( srcRGB, dstRGB, srcAlpha, dstAlpha);
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBufferData
* Signature: (IILjava/nio/Buffer;I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBufferData
(JNIEnv * env, jobject, jint target, jint size, jobject data, jint usage)
{
void* dataPtr = getDirectBufferPointer( env, data );
glBufferData( target, size, dataPtr, usage );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glBufferSubData
* Signature: (IIILjava/nio/Buffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glBufferSubData
(JNIEnv *env, jobject, jint target, jint offset, jint size, jobject data)
{
void* dataPtr = getDirectBufferPointer( env, data );
glBufferSubData( target, offset, size, dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glCheckFramebufferStatus
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glCheckFramebufferStatus
(JNIEnv *env, jobject, jint target)
{
return glCheckFramebufferStatus( target );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glClear
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glClear
(JNIEnv *env, jobject, jint mask)
{
glClear( mask );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glClearColor
* Signature: (FFFF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glClearColor
(JNIEnv *env, jobject, jfloat red, jfloat green, jfloat blue, jfloat alpha)
{
glClearColor( red, green, blue, alpha );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glClearDepthf
* Signature: (F)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glClearDepthf
(JNIEnv *env, jobject, jfloat depth)
{
glClearDepthf( depth );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glClearStencil
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glClearStencil
(JNIEnv *env, jobject, jint s)
{
glClearStencil( s );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glColorMask
* Signature: (ZZZZ)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glColorMask
(JNIEnv *env, jobject, jboolean red, jboolean green, jboolean blue, jboolean alpha)
{
glColorMask( red, green, blue, alpha );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glCompileShader
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glCompileShader
(JNIEnv *env, jobject, jint shader)
{
glCompileShader( shader );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glCompressedTexImage2D
* Signature: (IIIIIIILjava/nio/Buffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glCompressedTexImage2D
(JNIEnv *env, jobject, jint target, jint level, jint internalFormat, jint width, jint height, jint border, jint imageSize, jobject data)
{
void* dataPtr = getDirectBufferPointer( env, data );
glCompressedTexImage2D( target, level, internalFormat, width, height, border, imageSize, dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glCompressedTexSubImage2D
* Signature: (IIIIIIIILjava/nio/Buffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glCompressedTexSubImage2D
(JNIEnv *env, jobject, jint target, jint level, jint xoffset, jint yoffset, jint width, jint height, jint format, jint imageSize, jobject data)
{
void* dataPtr = getDirectBufferPointer( env, data );
glCompressedTexSubImage2D( target, level, xoffset, yoffset, width, height, format, imageSize, dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glCopyTexImage2D
* Signature: (IIIIIIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glCopyTexImage2D
(JNIEnv *env, jobject, jint target, jint level, jint internalFormat, jint x, jint y, jint width, jint height, jint border)
{
glCopyTexImage2D( target, level, internalFormat, x, y, width, height, border );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glCopyTexSubImage2D
* Signature: (IIIIIIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glCopyTexSubImage2D
(JNIEnv *env, jobject, jint target, jint level, jint xoffset, jint yoffset, jint x, jint y, jint width, jint height)
{
glCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glCreateProgram
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glCreateProgram
(JNIEnv *env, jobject)
{
return glCreateProgram( );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glCreateShader
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glCreateShader
(JNIEnv *env, jobject, jint type)
{
return glCreateShader( type );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glCullFace
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glCullFace
(JNIEnv *env, jobject, jint mode)
{
glCullFace( mode );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDeleteBuffers
* Signature: (ILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDeleteBuffers
(JNIEnv *env, jobject, jint n, jobject buffers)
{
void* dataPtr = getDirectBufferPointer( env, buffers );
glDeleteBuffers( n, (GLuint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDeleteFramebuffers
* Signature: (ILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDeleteFramebuffers
(JNIEnv *env, jobject, jint n, jobject framebuffers)
{
void* dataPtr = getDirectBufferPointer( env, framebuffers );
glDeleteFramebuffers( n, (GLuint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDeleteProgram
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDeleteProgram
(JNIEnv *env, jobject, jint program)
{
glDeleteProgram( program );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDeleteRenderbuffers
* Signature: (ILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDeleteRenderbuffers
(JNIEnv *env, jobject, jint n, jobject renderbuffers)
{
void* dataPtr = getDirectBufferPointer( env, renderbuffers );
glDeleteRenderbuffers( n, (GLuint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDeleteShader
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDeleteShader
(JNIEnv *env, jobject, jint shader)
{
glDeleteShader( shader );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDeleteTextures
* Signature: (ILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDeleteTextures
(JNIEnv *env, jobject, jint n, jobject textures)
{
void* dataPtr = getDirectBufferPointer( env, textures );
glDeleteTextures( n, (GLuint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDepthFunc
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDepthFunc
(JNIEnv *env, jobject, jint func)
{
glDepthFunc( func );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDepthMask
* Signature: (Z)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDepthMask
(JNIEnv *env, jobject, jboolean flag)
{
glDepthMask( flag );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDepthRangef
* Signature: (FF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDepthRangef
(JNIEnv *env, jobject, jfloat zNear, jfloat zFar)
{
glDepthRangef( zNear, zFar );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDetachShader
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDetachShader
(JNIEnv *env, jobject, jint program, jint shader)
{
glDetachShader( program, shader );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDisable
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDisable
(JNIEnv *env, jobject, jint cap)
{
glDisable( cap );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDisableVertexAttribArray
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDisableVertexAttribArray
(JNIEnv *env, jobject, jint index)
{
glDisableVertexAttribArray( index );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDrawArrays
* Signature: (III)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDrawArrays
(JNIEnv *env, jobject, jint mode, jint first, jint count)
{
glDrawArrays( mode, first, count );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glDrawElements
* Signature: (IIILjava/nio/Buffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDrawElements__IIILjava_nio_Buffer_2
(JNIEnv *env, jobject, jint mode, jint count, jint type, jobject indices)
{
void* dataPtr = getDirectBufferPointer( env, indices );
//__android_log_print(ANDROID_LOG_INFO, "GL2", "drawelements");
glDrawElements( mode, count, type, dataPtr );
}
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glDrawElements__IIII
(JNIEnv *, jobject, jint mode, jint count, jint type, jint indices)
{
glDrawElements( mode, count, type, (const void*)indices );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glEnable
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glEnable
(JNIEnv *env, jobject, jint cap)
{
glEnable( cap );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glEnableVertexAttribArray
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glEnableVertexAttribArray
(JNIEnv *env, jobject, jint index)
{
glEnableVertexAttribArray( index );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glFinish
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glFinish
(JNIEnv *env, jobject)
{
glFinish();
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glFlush
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glFlush
(JNIEnv *env, jobject)
{
glFlush();
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glFramebufferRenderbuffer
* Signature: (IIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glFramebufferRenderbuffer
(JNIEnv *env, jobject, jint target, jint attachment, jint renderbuffertarget, jint renderbuffer)
{
glFramebufferRenderbuffer( target, attachment, renderbuffertarget, renderbuffer );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glFramebufferTexture2D
* Signature: (IIIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glFramebufferTexture2D
(JNIEnv *env, jobject, jint target, jint attachment, jint textarget, jint texture, jint level)
{
glFramebufferTexture2D( target, attachment, textarget, texture, level );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glFrontFace
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glFrontFace
(JNIEnv *env, jobject, jint mode)
{ //XXXX
glFrontFace( mode );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGenBuffers
* Signature: (ILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGenBuffers
(JNIEnv *env, jobject, jint n, jobject buffers)
{
void* dataPtr = getDirectBufferPointer( env, buffers );
glGenBuffers( n, (GLuint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGenerateMipmap
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGenerateMipmap
(JNIEnv *env, jobject, jint target)
{
glGenerateMipmap( target );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGenFramebuffers
* Signature: (ILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGenFramebuffers
(JNIEnv *env, jobject, jint n, jobject framebuffers)
{
void* dataPtr = getDirectBufferPointer( env, framebuffers );
glGenFramebuffers( n, (GLuint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGenRenderbuffers
* Signature: (ILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGenRenderbuffers
(JNIEnv *env, jobject, jint n, jobject renderbuffers)
{
void* dataPtr = getDirectBufferPointer( env, renderbuffers );
glGenRenderbuffers( n, (GLuint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGenTextures
* Signature: (ILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGenTextures
(JNIEnv *env, jobject, jint n, jobject textures)
{
void* dataPtr = getDirectBufferPointer( env, textures );
glGenTextures( n, (GLuint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetActiveAttrib
* Signature: (IIILjava/nio/Buffer;Ljava/nio/IntBuffer;Ljava/nio/Buffer;Ljava/lang/String;)V
*/
JNIEXPORT jstring JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetActiveAttrib
(JNIEnv *env, jobject, jint program, jint index, jobject size, jobject type )
{
// FIXME is this wrong?
char cname[2048];
void* sizePtr = getDirectBufferPointer( env, size );
void* typePtr = getDirectBufferPointer( env, type );
glGetActiveAttrib( program, index, 2048, NULL, (GLint*)sizePtr, (GLenum*)typePtr, cname );
return env->NewStringUTF( cname );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetActiveUniform
* Signature: (IIILjava/nio/Buffer;Ljava/nio/IntBuffer;Ljava/nio/Buffer;Ljava/lang/String;)V
*/
JNIEXPORT jstring JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetActiveUniform
(JNIEnv *env, jobject, jint program, jint index, jobject size, jobject type)
{
// FIXME is this wrong?
char cname[2048];
void* sizePtr = getDirectBufferPointer( env, size );
void* typePtr = getDirectBufferPointer( env, type );
glGetActiveUniform( program, index, 2048, NULL, (GLint*)sizePtr, (GLenum*)typePtr, cname );
return env->NewStringUTF( cname );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetAttachedShaders
* Signature: (IILjava/nio/Buffer;Ljava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetAttachedShaders
(JNIEnv *env, jobject, jint program, jint maxcount, jobject count, jobject shaders)
{
void* countPtr = getDirectBufferPointer( env, count );
void* shaderPtr = getDirectBufferPointer( env, shaders );
glGetAttachedShaders( program, maxcount, (GLsizei*)countPtr, (GLuint*)shaderPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetAttribLocation
* Signature: (ILjava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetAttribLocation
(JNIEnv *env, jobject, jint program, jstring name)
{
const char* cname = getString( env, name );
int loc = glGetAttribLocation( program, cname );
releaseString( env, name, cname );
return loc;
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetBooleanv
* Signature: (ILjava/nio/Buffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetBooleanv
(JNIEnv *env, jobject, jint program, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetBooleanv( program, (GLboolean*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetBufferParameteriv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetBufferParameteriv
(JNIEnv *env, jobject, jint target, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetBufferParameteriv( target, pname, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetError
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetError
(JNIEnv *env, jobject)
{
return glGetError();
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetFloatv
* Signature: (ILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetFloatv
(JNIEnv *env, jobject, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetFloatv( pname, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetFramebufferAttachmentParameteriv
* Signature: (IIILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetFramebufferAttachmentParameteriv
(JNIEnv *env, jobject, jint target, jint attachment, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetFramebufferAttachmentParameteriv( target, attachment, pname, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetIntegerv
* Signature: (ILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetIntegerv
(JNIEnv *env, jobject, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetIntegerv( pname, (GLint*)dataPtr);
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetProgramiv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetProgramiv
(JNIEnv *env, jobject, jint program, jint pname, jobject params)
{
void *dataPtr = getDirectBufferPointer( env, params );
glGetProgramiv( program, pname, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetProgramInfoLog
* Signature: (IILjava/nio/Buffer;Ljava/lang/String;)V
*/
JNIEXPORT jstring JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetProgramInfoLog
(JNIEnv *env, jobject, jint program )
{
char info[1024*10]; // FIXME 10k limit should suffice
int length = 0;
glGetProgramInfoLog( program, 1024*10, &length, info );
return env->NewStringUTF( info );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetRenderbufferParameteriv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetRenderbufferParameteriv
(JNIEnv *env, jobject, jint target, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetRenderbufferParameteriv( target, pname, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetShaderiv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetShaderiv
(JNIEnv *env, jobject, jint shader, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetShaderiv( shader, pname, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetShaderInfoLog
* Signature: (IILjava/nio/Buffer;Ljava/lang/String;)V
*/
JNIEXPORT jstring JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetShaderInfoLog
(JNIEnv *env, jobject, jint shader )
{
char info[1024*10]; // FIXME 10k limit should suffice
int length = 0;
glGetShaderInfoLog( shader, 1024*10, &length, info );
return env->NewStringUTF( info );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetShaderPrecisionFormat
* Signature: (IILjava/nio/IntBuffer;Ljava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetShaderPrecisionFormat
(JNIEnv *env, jobject, jint shadertype, jint precisiontype, jobject range, jobject precision)
{
void* rangePtr = getDirectBufferPointer( env, range );
void* precisionPtr = getDirectBufferPointer( env, precision );
glGetShaderPrecisionFormat( shadertype, precisiontype, (GLint*)rangePtr, (GLint*)precisionPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetShaderSource
* Signature: (IILjava/nio/Buffer;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetShaderSource
(JNIEnv *env, jobject, jint shader, jint bufsize, jobject length, jstring source)
{
env->ThrowNew(UOEClass, "This method is not supported"); // FIXME won't implement this shit.
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetString
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetString
(JNIEnv *env, jobject, jint name)
{
const char * chars = (const char *)glGetString((GLenum)name);
jstring output = env->NewStringUTF(chars);
return output;
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetTexParameterfv
* Signature: (IILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetTexParameterfv
(JNIEnv *env, jobject, jint target, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetTexParameterfv( target, pname, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetTexParameteriv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetTexParameteriv
(JNIEnv *env, jobject, jint target, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetTexParameteriv( target, pname, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetUniformfv
* Signature: (IILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetUniformfv
(JNIEnv *env, jobject, jint program, jint location, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetUniformfv( program, location, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetUniformiv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetUniformiv
(JNIEnv *env, jobject, jint program, jint location, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetUniformiv( program, location, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetUniformLocation
* Signature: (ILjava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetUniformLocation
(JNIEnv *env, jobject, jint program, jstring name)
{
const char* cname = getString( env, name );
int location = glGetUniformLocation( program, cname );
releaseString( env, name, cname );
return location;
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetVertexAttribfv
* Signature: (IILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetVertexAttribfv
(JNIEnv *env, jobject, jint index, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetVertexAttribfv( index, pname, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetVertexAttribiv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetVertexAttribiv
(JNIEnv *env, jobject, jint index, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glGetVertexAttribiv( index, pname, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glGetVertexAttribPointerv
* Signature: (IILjava/nio/Buffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glGetVertexAttribPointerv
(JNIEnv *env, jobject, jint index, jint pname, jobject pointer)
{
env->ThrowNew(UOEClass, "This method is not supported"); // FIXME won't implement this shit
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glHint
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glHint
(JNIEnv *env, jobject, jint target, jint mode)
{
glHint( target, mode );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glIsBuffer
* Signature: (I)C
*/
JNIEXPORT jboolean JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glIsBuffer
(JNIEnv *env, jobject, jint buffer)
{
return glIsBuffer( buffer );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glIsEnabled
* Signature: (I)C
*/
JNIEXPORT jboolean JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glIsEnabled
(JNIEnv *env, jobject, jint cap)
{
return glIsEnabled( cap );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glIsFramebuffer
* Signature: (I)C
*/
JNIEXPORT jboolean JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glIsFramebuffer
(JNIEnv *env, jobject, jint framebuffer)
{
return glIsFramebuffer( framebuffer );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glIsProgram
* Signature: (I)C
*/
JNIEXPORT jboolean JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glIsProgram
(JNIEnv *env, jobject, jint program)
{
return glIsProgram( program );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glIsRenderbuffer
* Signature: (I)C
*/
JNIEXPORT jboolean JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glIsRenderbuffer
(JNIEnv *env, jobject, jint renderbuffer)
{
return glIsRenderbuffer( renderbuffer );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glIsShader
* Signature: (I)C
*/
JNIEXPORT jboolean JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glIsShader
(JNIEnv *env, jobject, jint shader)
{
return glIsShader( shader );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glIsTexture
* Signature: (I)C
*/
JNIEXPORT jboolean JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glIsTexture
(JNIEnv *env, jobject, jint texture)
{
return glIsTexture( texture );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glLineWidth
* Signature: (F)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glLineWidth
(JNIEnv *env, jobject, jfloat width)
{
glLineWidth( width );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glLinkProgram
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glLinkProgram
(JNIEnv *env, jobject, jint program)
{
glLinkProgram( program );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glPixelStorei
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glPixelStorei
(JNIEnv *env, jobject, jint pname, jint param)
{
glPixelStorei( pname, param );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glPolygonOffset
* Signature: (FF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glPolygonOffset
(JNIEnv *env, jobject, jfloat factor, jfloat units)
{
glPolygonOffset( factor, units );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glReadPixels
* Signature: (IIIIIILjava/nio/Buffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glReadPixels
(JNIEnv *env, jobject, jint x, jint y, jint width, jint height, jint format, jint type, jobject pixels)
{
void* dataPtr = getDirectBufferPointer( env, pixels );
glReadPixels( x, y, width, height, format, type, dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glReleaseShaderCompiler
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glReleaseShaderCompiler
(JNIEnv *env, jobject)
{
glReleaseShaderCompiler();
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glRenderbufferStorage
* Signature: (IIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glRenderbufferStorage
(JNIEnv *env, jobject, jint target, jint internalFormat, jint width, jint height)
{
glRenderbufferStorage( target, internalFormat, width, height );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glSampleCoverage
* Signature: (FZ)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glSampleCoverage
(JNIEnv *env, jobject, jfloat value, jboolean inver)
{
glSampleCoverage( value, inver );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glScissor
* Signature: (IIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glScissor
(JNIEnv *env, jobject, jint x, jint y, jint width, jint height)
{
glScissor( x, y, width, height );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glShaderBinary
* Signature: (ILjava/nio/IntBuffer;ILjava/nio/Buffer;I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glShaderBinary
(JNIEnv *env, jobject, jint n, jobject shaders, jint binaryformat, jobject binary, jint length)
{
void* shaderPtr = getDirectBufferPointer( env, shaders );
void* binaryPtr = getDirectBufferPointer( env, binary );
glShaderBinary( n, (GLuint*)shaderPtr, binaryformat, binaryPtr, length );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glShaderSource
* Signature: (IILjava/lang/String;Ljava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glShaderSource
(JNIEnv *env, jobject, jint shader, jstring string )
{
const char* cstring = getString( env, string );
glShaderSource( shader, 1, &cstring, NULL );
releaseString( env, string, cstring );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glStencilFunc
* Signature: (III)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glStencilFunc
(JNIEnv *env, jobject, jint func, jint ref, jint mask)
{
glStencilFunc( func, ref, mask );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glStencilFuncSeparate
* Signature: (IIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glStencilFuncSeparate
(JNIEnv *env, jobject, jint face, jint func, jint ref, jint mask)
{
glStencilFuncSeparate( face, func, ref, mask );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glStencilMask
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glStencilMask
(JNIEnv *env, jobject, jint mask)
{
glStencilMask( mask );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glStencilMaskSeparate
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glStencilMaskSeparate
(JNIEnv *env, jobject, jint face, jint mask)
{
glStencilMaskSeparate( face, mask );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glStencilOp
* Signature: (III)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glStencilOp
(JNIEnv *env, jobject, jint fail, jint zFail, jint zpass)
{
glStencilOp( fail, zFail, zpass );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glStencilOpSeparate
* Signature: (IIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glStencilOpSeparate
(JNIEnv *env, jobject, jint face, jint fail, jint zFail, jint zPass)
{
glStencilOpSeparate( face, fail, zFail, zPass );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glTexImage2D
* Signature: (IIIIIIIILjava/nio/Buffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glTexImage2D
(JNIEnv *env, jobject, jint target, jint level, jint internalformat, jint width, jint height, jint border, jint format, jint type, jobject pixels)
{
void* dataPtr = getDirectBufferPointer( env, pixels );
glTexImage2D( target, level, internalformat, width, height, border, format, type, dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glTexParameterf
* Signature: (IIF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glTexParameterf
(JNIEnv *env, jobject, jint target, jint pname, jfloat param)
{
glTexParameterf( target, pname, param );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glTexParameterfv
* Signature: (IILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glTexParameterfv
(JNIEnv *env, jobject, jint target, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glTexParameterfv( target, pname, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glTexParameteri
* Signature: (III)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glTexParameteri
(JNIEnv *env, jobject, jint target, jint pname, jint param)
{
glTexParameteri( target, pname, param );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glTexParameteriv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glTexParameteriv
(JNIEnv *env, jobject, jint target, jint pname, jobject params)
{
void* dataPtr = getDirectBufferPointer( env, params );
glTexParameteriv( target, pname, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glTexSubImage2D
* Signature: (IIIIIIIILjava/nio/Buffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glTexSubImage2D
(JNIEnv *env, jobject, jint target, jint level, jint xoffset, jint yoffset, jint width, jint height, jint format, jint type, jobject pixels)
{
void* dataPtr = getDirectBufferPointer( env, pixels );
glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform1f
* Signature: (IF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform1f
(JNIEnv *env, jobject, jint location, jfloat x)
{
glUniform1f( location, x );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform1fv
* Signature: (IILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform1fv
(JNIEnv *env, jobject, jint location, jint count, jobject v)
{
void* dataPtr = getDirectBufferPointer( env, v );
glUniform1fv( location, count, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform1i
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform1i
(JNIEnv *env, jobject, jint location, jint x)
{
glUniform1i( location, x );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform1iv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform1iv
(JNIEnv *env, jobject, jint location, jint count, jobject v)
{
void* dataPtr = getDirectBufferPointer( env, v );
glUniform1iv( location, count, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform2f
* Signature: (IFF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform2f
(JNIEnv *env, jobject, jint location, jfloat x, jfloat y)
{
glUniform2f( location, x, y );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform2fv
* Signature: (IILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform2fv
(JNIEnv *env, jobject, jint location, jint count, jobject v)
{
void* dataPtr = getDirectBufferPointer( env, v );
glUniform2fv( location, count, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform2i
* Signature: (III)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform2i
(JNIEnv *env, jobject, jint location, jint x, jint y)
{
glUniform2i( location, x, y );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform2iv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform2iv
(JNIEnv *env, jobject, jint location, jint count, jobject v)
{
void* dataPtr = getDirectBufferPointer( env, v );
glUniform2iv( location, count, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform3f
* Signature: (IFFF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform3f
(JNIEnv *env, jobject, jint location, jfloat x, jfloat y, jfloat z)
{
glUniform3f( location, x, y, z );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform3fv
* Signature: (IILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform3fv
(JNIEnv *env, jobject, jint location, jint count, jobject v)
{
void* dataPtr = getDirectBufferPointer( env, v );
glUniform3fv( location, count, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform3i
* Signature: (IIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform3i
(JNIEnv *env, jobject, jint location, jint x, jint y, jint z)
{
glUniform3i( location, x, y, z );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform3iv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform3iv
(JNIEnv *env, jobject, jint location, jint count, jobject v)
{
void* dataPtr = getDirectBufferPointer( env, v );
glUniform3iv( location, count, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform4f
* Signature: (IFFFF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform4f
(JNIEnv *env, jobject, jint location, jfloat x, jfloat y, jfloat z, jfloat w)
{
glUniform4f( location, x, y, z, w );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform4fv
* Signature: (IILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform4fv
(JNIEnv *env, jobject, jint location, jint count, jobject v)
{
void* dataPtr = getDirectBufferPointer( env, v );
glUniform4fv( location, count, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform4i
* Signature: (IIIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform4i
(JNIEnv *env, jobject, jint location, jint x, jint y, jint z, jint w)
{
glUniform4i( location, x, y, z, w );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniform4iv
* Signature: (IILjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniform4iv
(JNIEnv *env, jobject, jint location, jint count, jobject v)
{
void* dataPtr = getDirectBufferPointer( env, v );
glUniform4iv( location, count, (GLint*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniformMatrix2fv
* Signature: (IIZLjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniformMatrix2fv
(JNIEnv *env, jobject, jint location, jint count, jboolean transpose, jobject value)
{
void* dataPtr = getDirectBufferPointer( env, value );
glUniformMatrix2fv( location, count, transpose, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniformMatrix3fv
* Signature: (IIZLjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniformMatrix3fv
(JNIEnv *env, jobject, jint location, jint count, jboolean transpose, jobject value)
{
void* dataPtr = getDirectBufferPointer( env, value );
glUniformMatrix3fv( location, count, transpose, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUniformMatrix4fv
* Signature: (IIZLjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUniformMatrix4fv
(JNIEnv *env, jobject, jint location, jint count, jboolean transpose, jobject value)
{
void* dataPtr = getDirectBufferPointer( env, value );
glUniformMatrix4fv( location, count, transpose, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glUseProgram
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glUseProgram
(JNIEnv *env, jobject, jint program)
{
glUseProgram( program );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glValidateProgram
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glValidateProgram
(JNIEnv *env, jobject, jint program)
{
glValidateProgram( program );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glVertexAttrib1f
* Signature: (IF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glVertexAttrib1f
(JNIEnv *env, jobject, jint indx, jfloat x)
{
glVertexAttrib1f( indx, x );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glVertexAttrib1fv
* Signature: (ILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glVertexAttrib1fv
(JNIEnv *env, jobject, jint indx, jobject values)
{
void* dataPtr = getDirectBufferPointer( env, values );
glVertexAttrib1fv( indx, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glVertexAttrib2f
* Signature: (IFF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glVertexAttrib2f
(JNIEnv *env, jobject, jint indx, jfloat x, jfloat y)
{
glVertexAttrib2f( indx, x, y );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glVertexAttrib2fv
* Signature: (ILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glVertexAttrib2fv
(JNIEnv *env, jobject, jint indx, jobject values)
{
void* dataPtr = getDirectBufferPointer( env, values );
glVertexAttrib2fv( indx, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glVertexAttrib3f
* Signature: (IFFF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glVertexAttrib3f
(JNIEnv *env, jobject, jint indx, jfloat x, jfloat y, jfloat z)
{
glVertexAttrib3f( indx, x, y, z );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glVertexAttrib3fv
* Signature: (ILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glVertexAttrib3fv
(JNIEnv *env, jobject, jint indx, jobject values)
{
void* dataPtr = getDirectBufferPointer( env, values );
glVertexAttrib3fv( indx, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glVertexAttrib4f
* Signature: (IFFFF)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glVertexAttrib4f
(JNIEnv *env, jobject, jint indx, jfloat x, jfloat y, jfloat z, jfloat w)
{
glVertexAttrib4f( indx, x, y, z, w );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glVertexAttrib4fv
* Signature: (ILjava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glVertexAttrib4fv
(JNIEnv *env, jobject, jint indx, jobject values)
{
void* dataPtr = getDirectBufferPointer( env, values );
glVertexAttrib4fv( indx, (GLfloat*)dataPtr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glVertexAttribPointer
* Signature: (IIIZILjava/nio/Buffer;)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glVertexAttribPointer__IIIZILjava_nio_Buffer_2
(JNIEnv *env, jobject, jint indx, jint size, jint type, jboolean normalized, jint stride, jobject ptr)
{
void* dataPtr = getDirectBufferPointer( env, ptr );
glVertexAttribPointer( indx, size, type, normalized, stride, dataPtr );
}
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glVertexAttribPointer__IIIZII
(JNIEnv *, jobject, jint indx, jint size, jint type, jboolean normalized, jint stride, jint ptr)
{
glVertexAttribPointer( indx, size, type, normalized, stride, (const void*)ptr );
}
/*
* Class: com_badlogic_gdx_backends_ios_IOSGLES20
* Method: glViewport
* Signature: (IIII)V
*/
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_ios_IOSGLES20_glViewport
(JNIEnv *env, jobject, jint x, jint y, jint width, jint height)
{
glViewport( x, y, width, height );
}
|
c87c30b7aeae975055cfd5fdf42c476e48aebd7b | feac0a0a42e22ddbab31863647e68ce7ece8af50 | /SVN INSIDE/a1647264/newsvn/a1647264/2013/s2/oop/workshop4/example1.cpp | 9c68afbc2d33af83d3e685dcf4d6123925bfaea3 | [] | no_license | cotrat/UBUNTU-FILES | 43c8aa0d0ac33a915808124190d576b8e3f2c9df | 57f0aaaad46886c245a9bb142850e8836e8af2e4 | refs/heads/master | 2020-05-16T23:43:15.413005 | 2015-03-09T13:48:46 | 2015-03-09T13:48:46 | 31,899,681 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 268 | cpp | example1.cpp | #include <iostream>
using namespace std;
int main() {
int a = 1;
char b = '1';
float c = 1.0;
cout << "Values:" << endl;
cout << "Int: \t" << a << endl;
cout << "Char: \t" << b << endl;
cout << "Float: \t" << c << endl;
return 0;
}
|
646af2b26efb9b35b84b6d78523090dcbd7ff44f | 740eea09764634a32e747a7cce139c5a9e50dc68 | /MPZ/Training/test67.cpp | d811a2486ae7ae4481e4c6be33eb2c65aaae522e | [] | no_license | mpzadmin/yuc | ceeae65fe72cbd4212ebdf20774f9e2cda7f5fce | e6c73c24ff41b48617ec2e436e356516291a4656 | refs/heads/master | 2023-02-28T21:35:13.407372 | 2021-02-11T08:42:08 | 2021-02-11T08:42:08 | 321,592,407 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 465 | cpp | test67.cpp | #include <iostream>
using namespace std;
void test(int &a, int &b);
void exchange(int &x, int &y);
int main()
{
int a = 10;
int b = 20;
cout << "a = " << a << " , b = " << b << endl;
test(a,b);
cout << "a = " << a << " , b = " << b << endl;
exchange(a,b);
cout << "a = " << a << " , b = " << b << endl;
}
void test(int &a, int &b)
{
a++;
b++;
}
void exchange(int &x, int &y)
{
int z = y;
y = x;
x = z;
} |
f4351bb8bb41a76d477fbbc3dae404699a40cdc4 | 4554bf2ef932f3356deed0c7a896a01f2a72003f | /RenderEngine/Include/RenderSystemD3D/RenderTargetManagerD3D9.h | 1cb2b95c25849b8fd7027428ba0d869851d4b65a | [] | no_license | kevinchen2015/xgame | 61364bf24daae2b69202df609b1e4c52a821fd46 | e4cc0916923c624beedd17592a6dd89ff30525af | refs/heads/master | 2021-01-23T18:45:07.418341 | 2017-09-08T02:09:48 | 2017-09-08T02:09:48 | 102,805,922 | 0 | 0 | null | 2017-09-08T02:08:11 | 2017-09-08T02:08:11 | null | GB18030 | C++ | false | false | 3,306 | h | RenderTargetManagerD3D9.h | #ifndef __RenderTargetManagerD3D9_H__
#define __RenderTargetManagerD3D9_H__
/*
切换渲染目标时,要设定m_pcsBeginEndPrimitiveProxy的当前属性
*/
namespace xs
{
class RenderTargetD3D9;
class RenderSystemD3D9;
class RenderTargetManagerD3D9;
class RenderTargetManagerD3D9Creater
{
public:
static RenderTargetManagerD3D9 * create(RenderSystemD3D9 * pRenderSystem);
};
class RenderTargetManagerD3D9
{
public:
/**添加Overlay RenderTarget,只能添加一个
*/
bool addOverlayRenderTarget();
/**删除Overlay RenderTarget
*/
void removeOverlayRenderTarget();
/** 设置overlay render target 为当前渲染目标
*/
bool setOverlayRenderTarget();
/**添加渲染到窗口的渲染目标
@param hwnd 渲染窗口句柄
*/
bool addRenderTarget(uint hwnd);
/**添加渲染到纹理的渲染目标
@param width 宽度
@param height 高度
@param alpha 渲染目标是否有alpha通道
@param min 最小滤波器
@param mag 最大滤波器
@param mip mipmap滤波方式
@param s 纹理s寻址方式
@param t 纹理t寻址方式
@return 生成的RTT的句柄
*/
uint addRTT(
int width,
int height,
bool alpha = false,
FilterOptions min = FO_LINEAR,
FilterOptions mag = FO_LINEAR,
FilterOptions mip = FO_NONE,
TextureAddressingMode s = TAM_WRAP,
TextureAddressingMode t = TAM_WRAP);
/**删除渲染目标
@param hwnd 窗口句柄
@return 是否成功
*/
bool removeRenderTarget(uint hwnd);
/**多线程添加RenderTarget,多线程添加渲染目标只是用于异步加载
@param hwnd 窗口句柄
@return 是否成功
*/
uint MTaddRenderTarget();
/**多线程删除渲染目标,多线程添加渲染目标只是用于异步加载
@param hwnd 窗口句柄
@return 是否成功
*/
bool MTremoveRenderTarget(uint key);
/**设置当前的渲染目标
@param hwnd 窗口句柄或者RTT句柄
@return 是否成功
*/
bool setCurrentRenderTarget(uint hwnd);
/**获得当前的渲染目标id
@return 当前的渲染目标的窗口句柄,或者是RTT的句柄
*/
uint getCurrentRenderTargetID();
/**获得当前的渲染目标
@return 当前的渲染目标的窗口句柄,或者是RTT的句柄
*/
RenderTargetD3D9 * getCurrentRenderTarget() { return m_pCurrentRenderTarget; }
/** 获取渲染目标
@return 渲染目标
*/
RenderTargetD3D9 * getRenderTarget(uint id);
public:
/**释放渲染目标管理器
*/
void release();
public:
/** 设备丢失,或者设备重置前调用此函数释放资源
*/
void onDeviceLost();
/** 设备重置后调用此函数释放资源
*/
void onDeviceReset();
private:
friend class RenderTargetManagerD3D9Creater;
RenderTargetManagerD3D9();
~RenderTargetManagerD3D9();
bool create(RenderSystemD3D9 * pRenderSystem);
private:
RenderSystemD3D9 * m_pRenderSystem;//渲染系统
typedef stdext::hash_map<uint, RenderTargetD3D9*> RenderTargetContainer;
typedef RenderTargetContainer::iterator RenderTargetContainerIterator;
RenderTargetContainer m_vRenderTargets;//渲染目标
uint m_currentRenderTargetID;//当前渲染目标id
RenderTargetD3D9 * m_pCurrentRenderTarget;//当前渲染目标
uint m_uiRTTID;//RTT的id
};
}
#endif |
9f214a15497c93bdb3ea4180b44038282189d5bb | bb92586c3accb07b99b5004d719434fd018bd135 | /leetcode/LRU_Cache.cc | d291481838d49e2c7141944a19e4c81413d1a256 | [] | no_license | lc19890306/Exercise | 4a6070296aadb021d35dfae54d9352c289b9c2db | 153f73c015a9c64aa35aa440fce926c1d26f76c8 | refs/heads/master | 2021-07-17T21:01:15.881080 | 2021-02-19T15:34:55 | 2021-02-19T15:34:55 | 40,798,802 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,524 | cc | LRU_Cache.cc | class LRUCache{
public:
LRUCache(int capacity) : m_capacity(capacity) {}
int get(int key) {
auto it(cache.find(key));
if (it == cache.end())
return -1;
history.splice(history.begin(), history, it->second); // move the target key-value pair to the front of the list
return it->second->second;
}
void set(int key, int value) {
auto it(cache.find(key));
if (it != cache.end()) {
history.splice(history.begin(), history, it->second); // move the target key-value pair to the front of the list
it->second->second = value;
return;
}
if (cache.size() == m_capacity) {
auto key_to_be_deleted = history.back().first; // find the least used key-value pair on the list, namely, the last one
history.pop_back(); // pop the last one which is used least
cache.erase(key_to_be_deleted); // erase the element least used from the cache
}
history.emplace_front(key, value); // add newly added key-value pair to the front of the list
cache[key] = history.begin(); // set current key point to the iterator to the newly added key-value pair on the list
}
private:
unordered_map<int, list<pair<int, int> >::iterator> cache; // maintain all keys mapping to the iterator to the key-value pairs on the list
list<pair<int, int> > history; // maintain a list of key-value pairs with the LRU order
size_t m_capacity;
};
|
4700e06eb2082906f5de756b438b9053bcd25c1a | a4016e3a099af344cbb07eff1a9268b621305a10 | /kattis/musicalchairs.cpp | 33cbb5413ffcdc56b8d54fc90e9f5e77c885e505 | [
"MIT"
] | permissive | btjanaka/algorithm-problems | 4d92ae091676a90f5a8cb5a0b6b8c65e34946aee | e3df47c18451802b8521ebe61ca71ee348e5ced7 | refs/heads/master | 2021-06-17T22:10:01.324863 | 2021-02-09T11:29:35 | 2021-02-09T11:29:35 | 169,714,578 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 770 | cpp | musicalchairs.cpp | // Author: btjanaka (Bryon Tjanaka)
// Problem: (Kattis) musicalchairs
// Title: Musical Chairs
// Link: https://open.kattis.com/problems/musicalchairs
// Idea: Brute force - n is small enough that we can just remove from the list
// in O(n) time.
// Difficulty: easy
// Tags: math, brute-force
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<pair<int, int>> k; // {original, fav num}
for (int i = 0; i < n; ++i) {
int fav;
cin >> fav;
k.push_back({i, fav});
}
int cur = 0;
for (int i = 1; i < n; ++i) {
int remove = (cur + k[cur].second - 1) % k.size();
cur = remove % (k.size() - 1);
k.erase(k.begin() + remove, k.begin() + remove + 1);
}
cout << k[0].first + 1 << endl;
return 0;
}
|
b2a8b8fbf52f1b027a4cf4b5d47aabcc3fbe77ce | 32e1b816aff36fc5708ec495221da9e9cf3c9716 | /shuffled_anagram.cpp | 7892b565802e388342d34474c8034a8d370817c0 | [] | no_license | blank-27/C-coding | 2e276ef3872c7f0b6ec01b7baf4b2ad27a0404df | 92e0e506d927ee911be0fa7d7ca5ba76f045ecef | refs/heads/master | 2022-10-31T16:06:02.415295 | 2022-10-26T03:51:05 | 2022-10-26T03:51:05 | 212,297,396 | 0 | 21 | null | 2022-10-26T03:51:06 | 2019-10-02T09:08:27 | C++ | UTF-8 | C++ | false | false | 3,874 | cpp | shuffled_anagram.cpp | #include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define f0(i,k,n) for(i=k;i<n;i++)
#define fr(i,k,n) for(i=k-1;i>=n;i--)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define setbits(x) __builtin_popcountll(x)
#define endl '\n'
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x,y) cout << #x << "=" << x << "," << #y << "=" << y <<endl
#define pb push_back
#define mk make_tuple
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define MI INT_MIN
#define MX INT_MAX
#define gcd(x,y) __gcd(x,y)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it,a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.145926535897932384626
#define inf 1e18
#define sp(x,y) fixed<<setprecision(x)<<y
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef priority_queue<int, vector<int>,greater<int> > pqri;
typedef priority_queue<ll, vector<ll>,greater<ll> > pqrl;
typedef priority_queue<int> pqi;
typedef priority_queue<int> pql;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef vector <vi> vvi;
typedef vector <vl> vvl;
typedef stack <int> sti;
typedef stack <ll> stl;
typedef queue <int> qi;
typedef queue <ll> ql;
typedef map<int,int> mpi;
typedef map<ll,ll> mpl;
const int mod = 1'000'000'007;
const int N = 3e5, M=N;
int p=1;
ll pw(ll n,ll a)
{
ll ans = 1;
while(a)
{
if(a&1)
ans = (n*ans)%mod;
n = (n*n)%mod;
a>>=1;
}
return ans;
}
ll modInv(ll n, ll p)
{
return pw(n, p - 2);
}
bool prime[10000001];
int call[10000001];
void Sieve(int n)
{
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= n; p++)
{
if (prime[p] == true)
{
for (ll i = p * p; i <= n; i += p)
prime[i] = false;
}
}
for(ll i=2;i<=n;i++)
if(prime[i])call[i]=call[i-1]+1;
else call[i]=call[i-1];
}
void google(){
ll i,j,k,m,n,x,y,z,mi,mx,count=0,ans=0;
string s;
cin>>s;
string ss = s;
// map<char,int> mp;
cout<<"Case #"<<p<<": ";
ll a[26]={};
for(auto i:s){
int ind = (int)i-'a';
a[ind]++;
if(a[ind]*2>s.length()){
cout<<"IMPOSSIBLE\n";
p++;
return;
}
}
map<char,int> mp;
for(auto i:s){
mp[i]=a[i-'a'];
// cout<<i<<" "<<mp[i]<<endl;
}
j=0;
k=0;
map<char,stack<char> > mpp;
for(auto &i:s)
{
for(j=0;;j++)
{
j=j%((int)s.length());
deb(mp[i]);
if(mp[i]==0)break;
if(mpp[s[j]].size()==a[(int)s[j]-'a'])continue;
if(i==s[j])continue;
mpp[s[j]].push(i);
mp[i]--;
k++;
// if(rand()>300)break;
if(k>=1000)break;
}
}
for(auto i:s){
if(mpp[i].size()==0)continue;
cout<<mpp[i].top();
mpp[i].pop();
}
cout<<endl;
p++;
}
void solve(){
ll i,j,k,m,n,x,y,z,mi,mx,count=0,ans=0,sum=0;
}
int main() {
fast();
// Sieve(10000000);
int t = 1;
cin>>t;
while(t--) {
// solve();
google();
}
}
|
e538f233428b7cb3ba3bd8b0d2341bf8715bf8e0 | 16bd3971553a5045c1694417a8b5791034b0d788 | /ConsoleEngine C++ 17092019/File.h | e1babbf73b18e63fcf21e5125fd6e67972373476 | [] | no_license | jonash871j/Sprite-Editor | 2bff2a6a86271d2a6ec49cc46ef1d84d36e4cbf5 | cbb0b33f41188ae94ed013283852e20bce7d8dde | refs/heads/master | 2023-01-02T23:03:10.874410 | 2020-11-02T08:30:04 | 2020-11-02T08:30:04 | 309,305,003 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 303 | h | File.h | #pragma once
#include "EngineCore.h"
#include <fstream>
class File
{
private:
std::string fileName;
std::string formatName;
std::fstream stFile;
public:
File();
void Create(std::string fileName, std::string formatName);
void SaveInt(std::string description, int varInt, int lineNumber);
};
|
c71f5156482f345968be7ef91e4b6b8cb6d890b9 | ba776dea2742b3e54796bd8a202b7c96f15e070a | /include/GPUWrapper.h | fe58d24c6f7903a05d41cbc98428a3710344e52b | [
"MIT"
] | permissive | jteuber/GPUAbstractionLayer | 287f8cb15e850731acf12f8ba6822037043ee43f | 5413768c370298992c7b731c14624352dd200415 | refs/heads/master | 2021-01-10T09:25:51.049575 | 2017-10-04T09:28:10 | 2017-10-04T09:28:10 | 44,117,460 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,376 | h | GPUWrapper.h | #ifndef IGPGPU_H
#define IGPGPU_H
#include "GPUAbstractionLayer_global.h"
#include "Cuda_.h"
#include "OpenCL.h"
#include "DevMem.h"
enum EGPGPUType
{
GPCuda = 0,
GPOpenCL,
GPNone
};
class GAL_EXPORT GPUWrapper
{
public:
static GPUWrapper* getSingletonPtr()
{
if( sm_pInstance == NULL )
Log::getLog("GPUAbstractionLayer").logFatalError("GPGPU singleton not initialized! Call one of the static init() methods first.");
return sm_pInstance;
}
static bool init( int argc, const char **argv );
static bool init( EGPGPUType eGPGPUType, int argc, const char **argv );
static bool init( EGPGPUType eGPGPUType = GPCuda, unsigned int uiDeviceID = 0, unsigned int uiPlatformID = 0 );
template<typename T> DevMem<T>* devNew( unsigned int size = 1 );
template<typename T> DevMem<T>* devNew( unsigned int size, int data );
template<typename T> DevMem<T>* copyToDev( const T* hostData, unsigned int uiNrOfElements = 1 );
void scan( DevMem<unsigned int>* dIn, DevMem<unsigned int>* dOut );
DevMem<unsigned int>* scan( DevMem<unsigned int>* dIn );
unsigned int reduce( DevMem<unsigned int>* dIn );
void sort( DevMem<unsigned int>* dKeys, DevMem<unsigned int>* dValues, size_t numElements = 0 );
void sort( DevMem<float>* dKeys, DevMem<unsigned int>* dValues, size_t numElements = 0 );
unsigned int getTotalAvailableVRAM();
int getFreeVRAM();
EGPGPUType getType() const;
#ifdef USE_CUDA
Cuda* getRawCUDA() { return m_pCuda; }
#endif // USE_CUDA
#ifdef USE_OPENCL
OpenCL* getRawOpenCL() { return m_pOpenCL; }
#endif // USE_OPENCL
private:
static GPUWrapper* sm_pInstance;
#ifdef USE_CUDA
Cuda* m_pCuda;
#endif // USE_CUDA
#ifdef USE_OPENCL
OpenCL* m_pOpenCL;
#endif // USE_OPENCL
GPUWrapper();
virtual ~GPUWrapper();
};
template<typename T>
DevMem<T>* GPUWrapper::devNew( unsigned int size )
{
if( size == 0 )
return 0;
DevMem<T>* pTemp = 0;
#ifdef USE_CUDA
if( m_pCuda )
{
pTemp = new DevMem<T>( m_pCuda->devNew<T>( size ), size );
}
#ifdef USE_OPENCL
else
#endif // USE_OPENCL
#endif // USE_CUDA
#ifdef USE_OPENCL
if( m_pOpenCL )
{
pTemp = new DevMem<T>( m_pOpenCL->devNew<T>( size ), size );
}
#endif // USE_OPENCL
// make sure that the memory is valid before returning
if ( pTemp )
{
if ( pTemp->isValid() )
return pTemp;
else // if not, delete the invalid object
delete pTemp;
}
return 0;
}
template<typename T>
DevMem<T>* GPUWrapper::devNew(unsigned int size, int data)
{
DevMem<T>* pTemp = devNew<T>( size );
if ( pTemp)
{
#ifdef USE_CUDA
if ( m_pCuda != NULL )
{
m_pCuda->devMemSet( pTemp->getCUDA(), size, data );
}
#ifdef USE_OPENCL
else
#endif // USE_OPENCL
#endif // USE_CUDA
#ifdef USE_OPENCL
if ( m_pOpenCL != NULL )
{
m_pOpenCL->devMemSet<T>( pTemp->getOCL(), size, data );
}
#endif // USE_OPENCL
}
return pTemp;
}
template<typename T>
DevMem<T>* GPUWrapper::copyToDev(const T* hostData, unsigned int uiNrOfElements)
{
#ifdef USE_CUDA
if( m_pCuda != NULL )
{
DevMem<T>* pTemp = devNew<T>( uiNrOfElements );
m_pCuda->copyToDev( pTemp->m_pCUDAMem, hostData, uiNrOfElements );
return pTemp;
}
#ifdef USE_OPENCL
else
#endif // USE_OPENCL
#endif // USE_CUDA
#ifdef USE_OPENCL
if ( m_pOpenCL != NULL )
{
return new DevMem<T>( m_pOpenCL->copyToDev( hostData, uiNrOfElements ), uiNrOfElements );
}
#endif // USE_OPENCL
return 0;
}
#endif // IGPGPU_H
|
7b7a0a541bfe224c449781289e834ec9861676ea | 6a151d774c8230cf2a6a04cd6566c5aa813f9a3a | /Codeforces/Two Rival Students CF 1257A.cpp | 5495b85ecdd318f1359f6d3fc90ee8e109c843f1 | [] | no_license | RakibulRanak/Solved-ACM-problems | fdc5b39bdbe1bcc06f95c2a77478534362dca257 | 7d28d4da7bb01989f741228c4039a96ab307a8a6 | refs/heads/master | 2021-07-01T09:50:02.039776 | 2020-10-11T20:46:28 | 2020-10-11T20:46:28 | 168,976,930 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 411 | cpp | Two Rival Students CF 1257A.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--)
{
int n,x,a,b;
cin>>n>>x>>a>>b;
if(a>b)
swap(a,b);
int t;
if(x<a)
{
a=a-x;
cout<<b-a<<endl;
}
else
{
x=x-(a-1);
a=1;
int t=n-b;
if(t<=x)
{
b+=t;
}
else
{
b+=x;
}
cout<<b-a<<endl;
}
}
return 0;
} |
b7fec911bffbd2b39391d4ec1c229a68ddfaf672 | 86492a61522453ff076ee07d85baca98ace9e615 | /Uno/RotaryJoystickMame/Rotary_Joystick_To_MAME_4pin.ino | f5b0e750d1677c6cf66b3e016e810c8f006d1eab | [] | no_license | wilson3682/Arduino-2 | 04419fb332d70b901847588bbd65d5d9f6446035 | 88bf6ba76c79c889c0db94668f57532d6d4537dd | refs/heads/master | 2020-04-27T23:15:00.237533 | 2019-03-09T20:18:45 | 2019-03-09T20:18:45 | 174,768,028 | 1 | 0 | null | 2019-03-10T02:15:10 | 2019-03-10T02:15:09 | null | UTF-8 | C++ | false | false | 6,650 | ino | Rotary_Joystick_To_MAME_4pin.ino | // LS-30 Rotary Joystick to MAME Interface
// Reads the 12 rotary switches and detects when the position has changed.
// Generates a momentary output pulse to indicate a clockwise or
// counter-clockwise movement has occurred.
//
// MAME is configured to take CW/CCW inputs to play arcade games that used
// these joysticks with 12 inputs so this adapter is required to translate
// the joystick switches into usable rotation signals for MAME.
//
// Target Hardware: Arduino Uno
// Rotary Joystick with 12 position switch and common connection
//
// Connections:
// Joystick Harness Pin Arduino Pin
// 1, 5, 9 2
// 2, 6, 10 3
// 3, 7, 11 4
// 4, 8, 12 5
// 13 GND
//
// Outputs:
// Clockwise 8
// Counter-Clockwise 9
//
// Required libraries and board files:
// Bounce2 switch debouncer https://github.com/thomasfredericks/Bounce2
//
// Gadget Reboot
// https://www.youtube.com/gadgetreboot
#define DEBUG 0
#include <Bounce2.h>
#define debounceTime 40 // switch debounce in ms
#define cwOut 8 // cw output pin
#define ccwOut 9 // ccw output pin
#define numInputs 4 // use 4 inputs to read the rotary switches
const uint8_t rotarySwitch[numInputs] = {2, 3, 4, 5}; // digital inputs for rotary switches
byte lastState = 0; // previous stored joystick reading
byte curState = 0; // current joystick reading to evaluate against last reading
bool cw = false; // detected a clockwise rotation
bool ccw = false; // detected a counter-clockwise rotation
bool outputOn = false; // a cw or ccw output is currently being asserted (controlled by a timer)
unsigned long outputOnTime = 100; // duration to assert outputs, in mS. keyboard encoder needed a long press time
unsigned long outputTimer = 0; // timer for asserting outputs for required time lapse
#if Debug
byte debugCount = 0; // for debug purposes, how many rotations detected since power on?
#endif
Bounce * buttons = new Bounce[numInputs];
void setup() {
#if Debug
Serial.begin(9600);
Serial.println("\nStart...\n");
#endif
// outputs must idle high and assert active low
// configure cw/ccw outputs by first setting them high,
// then set them as outputs so they will be guaranteed high
digitalWrite(cwOut, 1);
digitalWrite(ccwOut, 1);
pinMode(cwOut, OUTPUT);
pinMode(ccwOut, OUTPUT);
for (int i = 0; i < numInputs; i++) {
buttons[i].attach( rotarySwitch[i] , INPUT_PULLUP ); // setup the bounce instance for the current button
buttons[i].interval(debounceTime); // debounce interval in ms
}
// take an initial reading of the rotary switches
for (int i = 0; i < numInputs; i++) {
buttons[i].update(); // update the switch status
if (buttons[i].read() == LOW) { // if a switch was grounded, update the status register
bitSet(curState, i);
}
}
lastState = curState; // make last and current readings identical to avoid a false output trigger on power up
#if Debug
Serial.print("Last Reading: ");
Serial.println(lastState, BIN);
Serial.print("Cur Reading: ");
Serial.println(curState, BIN);
#endif
} // end setup()
void loop() {
readJoystick(); // read the current rotary switch states into curState register
processJoystick(); // determine if a rotation has occurred and set a flag if so
if (cw | ccw) { // if a rotation has been flagged, generate required output pulse
generateOutput();
}
// if an output is being asserted and the timer has lapsed,
// stop asserting the output
if ( (outputOn) && (millis() > outputTimer + outputOnTime) ) {
cancelOutput();
}
} // end loop()
// read the joystick rotary switches into the curState register
void readJoystick() {
for (int i = 0; i < numInputs; i++) {
buttons[i].update(); // update the debouncer status
if (buttons[i].fell()) { // if a switch was grounded, update the status register
curState = 0; // clear the register and re-build it from current switch reading
bitSet(curState, i);
}
}
} // end readJoystick()
// check if rotary switches are different from last saved reading
// and set the appropriate flag for the detected rotation
void processJoystick() {
int diff = (lastState - curState); // check for a difference in joystick readings
// clockwise rotation has occurred
if ( ((diff < 0) && !((lastState == B0001) && (curState == B1000))) |
((diff > 0) && (lastState == B1000) && (curState == B0001)) ) {
#if Debug
Serial.println("-----");
Serial.println("CW Detected - Process Joystick");
Serial.print("Last Reading: ");
Serial.println(lastState, BIN);
Serial.print("Cur Reading: ");
Serial.println(curState, BIN);
Serial.println();
#endif
cw = true;
}
// counter-clockwise rotation has occurred
if ( ((diff > 0) && !((lastState == B1000) && (curState == B0001))) |
((diff < 0) && (lastState == B0001) && (curState == B1000)) ) {
#if Debug
Serial.println("-----");
Serial.println("CCW Detected - Process Joystick");
Serial.print("Last Reading: ");
Serial.println(lastState, BIN);
Serial.print("Cur Reading: ");
Serial.println(curState, BIN);
Serial.println();
#endif
ccw = true;
}
// update the last joystick reading if there's a new position
if (cw | ccw)
lastState = curState;
} // end processJoystick()
// assert the cw or ccw output signals low to indicate the direction of rotation.
void generateOutput() {
if (cw) {
#if Debug
Serial.println("Generating CW Out");
#endif
digitalWrite(cwOut, 0);
cw = false;
}
if (ccw) {
#if Debug
Serial.println("Generating CCW Out");
#endif
digitalWrite(ccwOut, 0);
ccw = false;
}
outputOn = true;
outputTimer = millis(); // reset timer for asserted output signal
} // end generateOutput()
// cancel active output flag and stop asserting outputs, letting them idle high
void cancelOutput() {
#if Debug
debugCount += 1;
Serial.println("Clearing Outputs");
Serial.print("Count: ");
Serial.println(debugCount);
Serial.println("-----");
#endif
digitalWrite(cwOut, 1);
digitalWrite(ccwOut, 1);
outputOn = false;
} // end cancelOutput()
|
5b508e29b413bd64e6e1f8527965cf8776280308 | 112e119bc9baf584550045b249b283b02901e0b1 | /U/Plugins/Client/TableModule/Source/TableModule/Public/SkillTable.h | 84bc05eca0e5c0dea8d5efad596e62abc2ea25c8 | [] | no_license | Iliketoshootunity/UE4 | 17a42513004606d1338cb902c881eee3a43ddad1 | dee869b5594002d621ca86131c961db4a2e0d084 | refs/heads/master | 2020-12-13T15:24:17.615337 | 2020-01-17T09:50:07 | 2020-01-17T09:50:07 | 234,457,306 | 1 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 847 | h | SkillTable.h | #pragma once
#pragma once
#pragma once
// Fill out your copyright notice in the Description page of Project Settings.
#include "CoreMinimal.h"
#include "BaseTable.h"
/************************************************************************
* Desc : Skill±í
* Author : XiaoHailin
* Time : [14/10/2019 xhl]
************************************************************************/
typedef struct tagSkillTableInfo
{
int32 Index;
int32 SkillID;
FString SkillName;
int32 TriggerType;
FString FirstComboMontage;
int32 Kind;
int32 SkillNeedRace;
int32 SkillNeedWeapon;
int32 FirstComboClipId;
}FSkillTableData;
class TABLEMODULE_API SkillTable : public STabBaseTable<SkillTable, FSkillTableData>
{
public:
SkillTable();
virtual ~SkillTable();
public:
virtual bool ReadTable(int32 nRow, int32& nCol) override;
}; |
f8db26cb6e19878b88321c6924d38f600b48ed61 | f1716d5fc26f85c78b8a4f2ceb37df19cf3b37b6 | /sooi/syntatic/SyntaticAnalysis.cpp | 4cd2a6bb6de44f95618be224304dc2ad24c926af | [] | no_license | igorldep/Programming-Languages-Class | 609a592e1d26f34666bc38356bdeb5efaaf9ee86 | e82629ad5f0b150a37d759e4b9ac25b161e5bd3d | refs/heads/master | 2021-09-14T07:21:36.752453 | 2018-05-09T15:41:21 | 2018-05-09T15:41:21 | 126,070,700 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,420 | cpp | SyntaticAnalysis.cpp | #include <iostream>
#include <cstdlib>
#include "SyntaticAnalysis.h"
#include "../interpreter/command/AssignCommand.h"
#include "../interpreter/command/Command.h"
#include "../interpreter/command/CommandsBlock.h"
#include "../interpreter/command/IfCommand.h"
#include "../interpreter/command/WhileCommand.h"
#include "../interpreter/expr/AccessExpr.h"
#include "../interpreter/expr/BoolExpr.h"
#include "../interpreter/expr/CompositeBoolExpr.h"
#include "../interpreter/expr/CompositeExpr.h"
#include "../interpreter/expr/ConstExpr.h"
#include "../interpreter/expr/Expr.h"
#include "../interpreter/expr/FunctionCallExpr.h"
#include "../interpreter/expr/FunctionRhs.h"
#include "../interpreter/expr/NotBoolExpr.h"
#include "../interpreter/expr/Rhs.h"
#include "../interpreter/expr/RelOp.h"
#include "../interpreter/expr/SingleBoolExpr.h"
#include "../interpreter/util/AccessPath.h"
#include "../interpreter/util/StandardFunction.h"
#include "../interpreter/value/IntegerValue.h"
#include "../interpreter/value/FunctionValue.h"
#include "../interpreter/value/StringValue.h"
SyntaticAnalysis::SyntaticAnalysis(LexicalAnalysis& lex) :
m_lex(lex), m_current(m_lex.nextToken()) {
}
SyntaticAnalysis::~SyntaticAnalysis() {
}
Command* SyntaticAnalysis::start() {
Command* c = procCode();
matchToken(END_OF_FILE);
return c;
}
void SyntaticAnalysis::matchToken(enum TokenType type) {
if (type == m_current.type) {
m_current = m_lex.nextToken();
} else {
showError();
}
}
void SyntaticAnalysis::showError() {
printf("%02d: ", m_lex.line());
switch (m_current.type) {
case INVALID_TOKEN:
printf("Lexema inválido [%s]\n", m_current.token.c_str());
break;
case UNEXPECTED_EOF:
case END_OF_FILE:
printf("Fim de arquivo inesperado\n");
break;
default:
printf("Lexema não esperado [%s]\n", m_current.token.c_str());
break;
}
exit(1);
}
std::string SyntaticAnalysis::procName(){
std::string name = m_current.token;
matchToken(NAME);
return name;
}
ConstExpr* SyntaticAnalysis::procNumber(){
int line = m_lex.line();
std::string tmp = m_current.token;
matchToken(NUMBER);
int n = atoi(tmp.c_str());
IntegerValue* iv = new IntegerValue(n);
ConstExpr* ce = new ConstExpr(iv, line);
return ce;
}
ConstExpr* SyntaticAnalysis::procString(){
int line = m_lex.line();
std::string tmp = m_current.token;
matchToken(STRING);
StringValue* sv = new StringValue(tmp);
ConstExpr* ce = new ConstExpr(sv, line);
return ce;
}
// <code> ::= { <statement> }
CommandsBlock* SyntaticAnalysis::procCode(){
CommandsBlock* cb = new CommandsBlock();
while( m_current.type == IF ||
m_current.type == WHILE ||
m_current.type == SYSTEM ||
m_current.type == SELF ||
m_current.type == ARGS ||
m_current.type == NAME){
Command* c = procStatement();
cb->addCommand(c);
}
return cb;
}
// <statement> ::= <if> | <while> | <cmd>
Command* SyntaticAnalysis::procStatement(){
Command* c = 0;
switch(m_current.type){
case IF:
c = procIf();
break;
case WHILE:
c = procWhile();
break;
default:
c = procCmd();
break;
}
return c;
}
// <if> ::= if '(' <boolexpr> ')' '{' <code> '}' [else '{' <code> '}']
IfCommand* SyntaticAnalysis::procIf(){
Command* _else = 0;
matchToken(IF);
matchToken(OPEN_PAR);
int line = m_lex.line();
BoolExpr* _bool = procBoolExpr();
matchToken(CLOSE_PAR);
matchToken(OPEN_CUR);
Command* _then = procCode();
matchToken(CLOSE_CUR);
if(m_current.type == ELSE){
matchToken(ELSE);
matchToken(OPEN_CUR);
_else = procCode();
matchToken(CLOSE_CUR);
}
IfCommand* _if;
if(_else)
_if = new IfCommand(_bool, _then, _else, line);
else
_if = new IfCommand(_bool, _then, line);
return _if;
}
// <while> ::= while '(' <boolexpr> ')' '{' <code> '}'
WhileCommand* SyntaticAnalysis::procWhile(){
matchToken(WHILE);
matchToken(OPEN_PAR);
int line = m_lex.line();
BoolExpr* _bool = procBoolExpr();
matchToken(CLOSE_PAR);
matchToken(OPEN_CUR);
Command* _do = procCode();
matchToken(CLOSE_CUR);
WhileCommand* _while = new WhileCommand(_bool, _do, line);
return _while;
}
// <cmd> ::= <access> ( <assign> | <call> ) ';'
AssignCommand* SyntaticAnalysis::procCmd(){
AccessPath* path = procAccess();
AssignCommand* ac = 0;
if(m_current.type == ASSIGN){
ac = procAssign(path);
}else if(m_current.type == OPEN_PAR){
int line = m_lex.line();
FunctionCallExpr* fce = procCall(path);
ac = new AssignCommand(0, fce, line);
}else{
showError();
}
matchToken(DOT_COMMA);
return ac;
}
// <access> ::= <var> {'.' <name>}
AccessPath* SyntaticAnalysis::procAccess(){
int line = m_lex.line();
std::string name = procVar();
AccessPath* path = new AccessPath(name, line);
while(m_current.type == DOT){
matchToken(DOT);
name = procName();
path->addName(name);
}
return path;
}
// <assign> ::= '=' <rhs>
AssignCommand* SyntaticAnalysis::procAssign(AccessPath* path){
int line = m_lex.line();
matchToken(ASSIGN);
Rhs* rhs = procRhs();
AssignCommand* ac = new AssignCommand(path, rhs, line);
return ac;
}
// <call> ::= '(' [ <rhs> { ',' <rhs> } ] ')'
FunctionCallExpr* SyntaticAnalysis::procCall(AccessPath* path){
FunctionCallExpr* fce = new FunctionCallExpr(path, m_lex.line());
matchToken(OPEN_PAR);
if( m_current.type == FUNCTION ||
m_current.type == NUMBER ||
m_current.type == STRING ||
m_current.type == SYSTEM ||
m_current.type == SELF ||
m_current.type == ARGS ||
m_current.type == NAME ||
m_current.type == OPEN_PAR){
Rhs* rhs = procRhs();
fce->addParam(rhs);
while(m_current.type == COMMA){
matchToken(COMMA);
rhs = procRhs();
fce->addParam(rhs);
}
}
matchToken(CLOSE_PAR);
return fce;
}
// <boolexpr> ::= [ '!' ] <cmpexpr> [ ('&' | '|') <boolexpr> ]
BoolExpr* SyntaticAnalysis::procBoolExpr(){
bool negative = false;
if(m_current.type == NEGATIVE){
matchToken(NEGATIVE);
negative = true;
}
BoolExpr* _bool = procCmpExpr();
if(m_current.type == OR|| m_current.type == AND){
int line = m_lex.line();
enum BoolOp _op = BOOL_INVALID;
switch(m_current.type){
case AND: _op = BOOL_AND; break;
case OR: _op = BOOL_OR; break;
default: showError(); break;
}
matchToken(m_current.type);
_bool = new CompositeBoolExpr(_bool, _op, procBoolExpr(), line);
}
int line = m_lex.line();
if(negative)
_bool = new NotBoolExpr(_bool, line);
return _bool;
}
// <cmpexpr> ::= <expr> <relop> <expr>
SingleBoolExpr* SyntaticAnalysis::procCmpExpr(){
Expr* _left = procExpr();
enum RelOp _relop = procRelop();
int line = m_lex.line();
Expr* _right = procExpr();
SingleBoolExpr* _sbe = new SingleBoolExpr(_left, _relop, _right, line);
return _sbe;
}
// <relop> ::= '==' | '!=' | '<' | '>' | '<=' | '>='
enum RelOp SyntaticAnalysis::procRelop(){
if( m_current.type == EQUAL) {
matchToken(EQUAL);
return RELOP_EQUAL;
} else if (m_current.type == DIFFERENT) {
matchToken(DIFFERENT);
return RELOP_NOTEQUAL;
} else if (m_current.type == SMALLER) {
matchToken(SMALLER);
return RELOP_LOWER;
} else if (m_current.type == BIGGER) {
matchToken(BIGGER);
return RELOP_GREATER;
} else if (m_current.type == SMALLER_EQUAL) {
matchToken(SMALLER_EQUAL);
return RELOP_LOWEREQUAL;
} else if (m_current.type == BIGGER_EQUAL) {
matchToken(BIGGER_EQUAL);
return RELOP_GREATEREQUAL;
}
return RELOP_INVALID;
}
// <rhs> ::= <function> | <expr>
Rhs* SyntaticAnalysis::procRhs(){
Rhs* rhs = 0;
if(m_current.type == FUNCTION){
rhs = procFunction();
}else{
rhs = procExpr();
}
return rhs;
}
// <function> ::= function '{' <code> [ return <rhs> ] '}'
FunctionRhs* SyntaticAnalysis::procFunction(){
matchToken(FUNCTION);
matchToken(OPEN_CUR);
int line = m_lex.line();
Command* _cmd = procCode();
StandardFunction* sf = new StandardFunction(_cmd);
if(m_current.type == RETURN){
matchToken(RETURN);
Rhs* _rhs = procRhs();
sf = new StandardFunction(_cmd, _rhs);
matchToken(DOT_COMMA);
}
FunctionValue* func = new FunctionValue(sf);
FunctionRhs* fr = new FunctionRhs(line, func);
matchToken(CLOSE_CUR);
return fr;
}
// <expr> ::= <term> { ('+' | '-') <term> }
/*Expr* SyntaticAnalysis::procExpr(){
Expr* e = procTerm();
while(m_current.type == ADD || m_current.type == SUB){
if(m_current.type == ADD)
matchToken(ADD);
else
matchToken(SUB);
Expr* e2 = procTerm();
}
return e;
}*/
Expr* SyntaticAnalysis::procExpr(){
Expr* e = procTerm();
while(m_current.type == ADD || m_current.type == SUB){
int line = m_lex.line();
enum CompositeExpr::CompOp _op = CompositeExpr::INVALID;
if(m_current.type == ADD){
_op = CompositeExpr::ADD;
matchToken(ADD);
}else{
_op = CompositeExpr::SUB;
matchToken(SUB);
}
Expr* e2 = procExpr(); // procTerm
e = new CompositeExpr(e, _op, e2, line);
}
return e;
}
// <term> ::= <factor> { ('*' | '/' | '%') <factor> }
/*Expr* SyntaticAnalysis::procTerm(){
Expr* e = procFactor();
while(m_current.type == MUL || m_current.type == DIV || m_current.type == MOD){
if(m_current.type == MUL)
matchToken(MUL);
else if(m_current.type == DIV)
matchToken(DIV);
else
matchToken(MOD);
Expr* e2 = procFactor();
//e = new CompositeExpr(e, e2, ...);
}
return e;
}*/
Expr* SyntaticAnalysis::procTerm(){
Expr* e = procFactor();
while(m_current.type == MUL || m_current.type == DIV || m_current.type == MOD){
int line = m_lex.line();
enum CompositeExpr::CompOp _op = CompositeExpr::INVALID;
if(m_current.type == MUL){
_op = CompositeExpr::MUL;
matchToken(MUL);
}else if(m_current.type == DIV){
_op = CompositeExpr::DIV;
matchToken(DIV);
}else{
_op = CompositeExpr::MOD;
matchToken(MOD);
}
Expr* e2 = procTerm();
e = new CompositeExpr(e, _op, e2, line);
}
return e;
}
// <factor> ::= <number> | <string> | <access> [ <call> ] | '(' <expr> ')'
Expr* SyntaticAnalysis::procFactor(){
Expr* e = 0;
switch(m_current.type){
case NUMBER:
e = procNumber();
break;
case STRING:
e = procString();
break;
case OPEN_PAR:
matchToken(OPEN_PAR);
e = procExpr();
matchToken(CLOSE_PAR);
break;
default:
int line = m_lex.line();
AccessPath* path = procAccess();
if(m_current.type == OPEN_PAR){
e = procCall(path);
} else {
e = new AccessExpr(path, line);
//e = ae;
}
break;
}
return e;
}
// <var> ::= system | self | args | <name>
std::string SyntaticAnalysis::procVar(){
std::string var = "";
switch(m_current.type){
case SYSTEM:
matchToken(SYSTEM);
var = "system";
break;
case SELF:
matchToken(SELF);
var = "self";
break;
case ARGS:
matchToken(ARGS);
var = "args";
break;
default: // case NAME:
var = procName();
break;
}
return var;
}
|
339914aea49ae64fba88741a97fb747a3aa245e3 | f5c0a0b286e54b9d8a0628594a7e999a8145e367 | /offlinePrograms/IsDivisibleBy11.cpp | cf9606dd5aee4ddc2ebb19de98ff200877cab63d | [] | no_license | makaravind/extra_problems | 159efc12b65d97fc384c477ff3b1e7a51a4cb2cc | 11dda531c615ee425430549410c70df09d6c0fda | refs/heads/master | 2021-01-21T13:44:06.133927 | 2016-06-01T19:01:08 | 2016-06-01T19:01:08 | 47,326,520 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 842 | cpp | IsDivisibleBy11.cpp | /*Given a unsigned number as a string input(it can be of length, max 10000 chars) write a function to
find whether the number is divisible by 11 or not*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int IsDivisible_11(char*);
int Validate(char*);
void main(){
char number[50];
gets_s(number);
if (Validate(number)){
if (IsDivisible_11(number)) printf("divisible by 11");
else printf("not divisible by 11");
}
else printf("Invalid");
_getch();
}
int Validate(char *num){
for (int i = 0; num[i] != '\0'; i++)
if ((int)num < 48 || (int)num > 57) return 0;
return 1;
}
int IsDivisible_11(char *num){
int even = 0;
int odd = 0;
for (int i = 0; num[i] != '\0'; i++){
if ( (i+1) % 2 != 0)
odd += ((int)num[i] - 48);
else
even += ((int)num[i] - 48);
}
if ((odd - even) % 11 == 0) return 1;
return 0;
} |
830d792defc0c924c65c92cec84e2c24164ca3b7 | f8431af3b73fb9b016577fa8b39ef00518e05cfa | /Learnding/CoolQuestion/CF_1243B 0-1 MST(贪心+BFS)/main.cpp | 204b021913f1d7a8420a93c2b0e85169923ea994 | [] | no_license | HZH7318/ACM | 5b71ab16ee69b38d424ba150fd3b7b52d85a215b | 6f903b8f935ade6b6e434490ee138eba3d44b59a | refs/heads/main | 2023-06-25T13:26:41.801548 | 2021-07-29T08:11:38 | 2021-07-29T08:11:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,417 | cpp | main.cpp | /**********************************************
贪心+bfs
有一个完全图,有m条边的权值为1,其余边的权值为0,求MST
思路:瞎搞,设两个点集合S, T, S代表已经选中在最小生成树
中的点,T代表未在最小生成树中的点,初始所有点在T中。
随机选一个在T中的点,结果加1,然后将其放入队列,从队列中
取出点u,遍历u的所有边,如果终点在T中,则不处理,如果终点
不在T中,则将其放入队列(代表连接边权为0的边),继续运行直至
队列为空。
这种思路实质上就是求输入的图的补图,然后对于求其补图有多少个
连通块。
题目链接:https://codeforces.com/contest/1243/problem/D
**************************************************/
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctype.h>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<iostream>
#include<iterator>
#define dbg(x) cout<<#x<<" = "<<x<<endl;
#define INF 0x3f3f3f3f
#define eps 1e-8
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int maxn = 100100;
const int mod = 1e9+7;
vector<int> g[maxn];
//st1代表集合T
int in[maxn], vis[maxn], st1[maxn], st2[maxn];
int solve(int n);
int main()
{
int n, m, i, j, k, ans;
scanf("%d %d", &n, &m);
for(i=0;i<m;i++)
{
scanf("%d %d", &j, &k);
if(j == k)continue;
g[j].push_back(k);
g[k].push_back(j);
}
ans = solve(n);
printf("%d\n", ans-1);
return 0;
}
int solve(int n)
{
queue<int> que;
int ans = 0, i, j, num=0, top, top2;
for(i=0;i<n;i++)
st1[i] = i+1;
top = n;
while(num < n)
{
//任取一个不在S中的点
for(i=1;i<=n;i++)
if(!vis[i]){
que.push(i);
ans++;
break;
}
while(!que.empty())
{
int u = que.front();que.pop();
if(vis[u])continue;vis[u] = 1;num++;
top2 = 0;
for(j=0;j<g[u].size();j++)
in[g[u][j]] = 1;
//对于T中的点v,如果输入中没有(u,v),则说明边权为0,则连接该
//边,否则仍将该点留在T中
for(j=0;j<top;j++)
if(in[st1[j]] == 1)
st2[top2++] = st1[j];
else if(!vis[st1[j]]){
que.push(st1[j]);
}
for(j=0;j<top2;j++)
st1[j] = st2[j];
top = top2;
for(j=0;j<g[u].size();j++)
in[g[u][j]] = 0;
}
}
return ans;
} |
760ce9bf2ce1710cf3900568e9baa2c33f3c4395 | 954d216e92924a84fbd64452680bc58517ae53e8 | /source/math/nckStatistics.h | 9af26a673d39229be30bb2e8017c2feaf3dcb4e7 | [
"MIT"
] | permissive | nczeroshift/nctoolkit | e18948691844a8657f8937d2d490eba1b522d548 | c9f0be533843d52036ec45200512ac54c1faeb11 | refs/heads/master | 2021-01-17T07:25:02.626447 | 2020-06-10T14:07:03 | 2020-06-10T14:07:03 | 47,587,062 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 643 | h | nckStatistics.h |
/**
* NCtoolKit © 2007-2017 Luís F.Loureiro, under zlib software license.
* https://github.com/nczeroshift/nctoolkit
*/
#ifndef _NCK_STATISTICS_
#define _NCK_STATISTICS_
#include "nckMathConfig.h"
#include <vector>
_MATH_BEGIN
class Statistics{
public:
Statistics(int capacity);
~Statistics();
void Add(double val, bool rolling = false);
void Clear();
int GetN();
int GetCapacity();
double GetMean();
double GetMin();
double GetMax();
private:
void Compute();
void Sort();
int m_Index;
int m_Capacity;
std::vector<double> m_Values;
double m_Mean;
double m_Min;
double m_Max;
bool m_Updated;
};
_MATH_END
#endif |
2d6b5771c563c9a55ea3da07f06c8a897ae161de | 55a0a9c86b4af4fdda1ec481434252e1f6eed63f | /5days/assignment/main.cpp | d0085933dc5e5398203ec644eff700bbbca15b4e | [] | no_license | krud0726/C_PLUS_PLUS | 6ec2df3d1427a129ba5af5a81330fba29e157ef6 | 966e36e86bb798a97466eb5e363edc81ad06d283 | refs/heads/main | 2023-06-19T07:29:44.923166 | 2021-07-19T14:53:21 | 2021-07-19T14:53:21 | 381,121,757 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,290 | cpp | main.cpp | #include "school.h"
#include <algorithm>
#include <map>
using namespace std;
enum Command { ADD, DELETE, PRINT, FIND, MODIFY, QUIT, INVALID };
pair<string, Student> make_student(){
cout << "Enter id, name, gpa: ";
string id;
string studentName;
double gpa;
cin >> id >> studentName >> gpa;
Student s{id, studentName, gpa};
pair<string, Student> result = pair<string, Student>{id, s};
return result;
}
Command getCommand(const string& command){
static map<string, Command> cmd = {
{"add", ADD}, {"delete",DELETE}, {"print", PRINT},
{"find",FIND}, {"modify", MODIFY}, {"quit", QUIT},
{"invalid", INVALID}
};
auto find_it = cmd.find(command);
if(find_it != end(cmd))
return cmd[command];
else
return cmd["invalid"];
}
int main() {
cout << "Set School Name: ";
string schoolName;
cin >> schoolName;
School& school = School::getInstance(schoolName);
while(true)
{
cout<< "Enter Command: ";
string cmd;
cin >> cmd;
transform(begin(cmd), end(cmd), begin(cmd), [](char& c){ return tolower(c);});
Command c = getCommand(cmd);
switch(c)
{
case ADD:{
auto r = make_student();
school.addStudent(r.first, r.second);
break;
}
case DELETE:{
cout<< "Enter id: ";
string id;
cin >> id;
school.deleteStudent(id);
break;
}
case FIND:{
cout<<"Enter id: ";
string id;
cin >> id;
auto r = school.findStudent(id);
if(r) school.print(id);
break;
}
case PRINT: {
school.print();
break;
}
case MODIFY: {
cout << "Enter id, gpa: ";
string id;
double gpa;
cin >> id >> gpa;
school.modifyStudentGPA(id, gpa);
break;
}
case QUIT:
return 0;
default:
cout << "Invalid Command"<<endl;
}
}
}
|
51590269e35f0377f9f42de488ff2c8beb33d519 | fa35c5b787c1a35b0735dcf03a3e6e38f3f54a6d | /Bronze/Simulation/stuck_in_a_rut.cpp | 4b1c379bdaaa58ccdd4b6e2aaa72c90fda9bf814 | [] | no_license | rbruno95/usaco-guide | fc69d2b17f05609e97be7130f1f41abe144c7ec7 | bfbf38476f237a190b1d11684f16c42357911919 | refs/heads/master | 2023-06-21T00:07:13.107873 | 2021-07-19T01:18:46 | 2021-07-19T01:18:46 | 383,178,780 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 957 | cpp | stuck_in_a_rut.cpp | #include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int oo = 1e9;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<char> D(n);
vector<int> x(n), y(n);
for(int i=0;i<n;i++) cin >> D[i] >> x[i] >> y[i];
vector<int> times;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++){
times.push_back(abs(y[i] - y[j]));
times.push_back(abs(x[i] - x[j]));
}
sort(times.begin(), times.end());
vector<int> sol(n, oo);
for(auto t: times)
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
if(D[i] != D[j] and D[i] == 'N' and x[j] < x[i] and y[i] < y[j]){
if(y[i] + t == y[j] and x[j] + min(sol[j], t) > x[i]) sol[i] = min(sol[i], t);
else if(y[i] + min(sol[i], t) > y[j] and x[j] + t == x[i]) sol[j] = min(sol[j], t);
}
for(auto x: sol)
if(x == oo) cout << "Infinity" << endl;
else cout << x << endl;
return 0;
}
|
a5b43da90c2b519fbe14989a65a8945cc0117a03 | 4b3f0d900c3b1a5acd3aba338a409fff7025895e | /projects/Vk_12/src/timer.cpp | 1b797aa0c5f3b55f246455346a249c582dead4b3 | [
"MIT"
] | permissive | AnselmoGPP/Vulkan_samples | 40a87cb3babdfea9dc1c6087c4a8d8bbf296964b | 9aaefcff024962b41539be70a9179e78856ff6a7 | refs/heads/master | 2023-08-29T20:11:15.007802 | 2021-11-10T02:46:11 | 2021-11-10T02:46:11 | 354,443,483 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,385 | cpp | timer.cpp |
#include "timer.hpp"
#include <iostream>
#include <thread>
#include <chrono>
#include <cmath>
TimerSet::TimerSet(int maximumFPS)
: currentTime(std::chrono::system_clock::duration::zero()), maxFPS(maximumFPS)
{
startTimer();
time = 0;
deltaTime = 0;
FPS = 0;
frameCounter = 0;
}
void TimerSet::startTimer()
{
startTime = std::chrono::high_resolution_clock::now();
prevTime = startTime;
//std::this_thread::sleep_for(std::chrono::microseconds(1000)); // Avoids deltaTime == 0 (i.e. currentTime == lastTime)
}
void TimerSet::computeDeltaTime()
{
// Get deltaTime
currentTime = std::chrono::high_resolution_clock::now();
//time = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - startTime).count() / 1000000.l;
//time = std::chrono::duration<float, std::chrono::seconds::period>(currentTime - startTime).count();
deltaTime = std::chrono::duration<long double, std::chrono::seconds::period>(currentTime - prevTime).count();
// Add some time to deltaTime to adjust the FPS (if FPS control is enabled)
if (maxFPS > 0)
{
int waitTime = (1.l / maxFPS - deltaTime) * 1000000; // microseconds (for the sleep)
if (waitTime > 0)
{
std::this_thread::sleep_for(std::chrono::microseconds(waitTime));
currentTime = std::chrono::high_resolution_clock::now();
deltaTime = std::chrono::duration<long double, std::chrono::seconds::period>(currentTime - prevTime).count();
}
}
prevTime = currentTime;
// Get FPS
FPS = std::round(1 / deltaTime);
// Get time
time = std::chrono::duration<long double, std::chrono::seconds::period>(currentTime - startTime).count();
// Increment the frame count
++frameCounter;
}
long double TimerSet::getDeltaTime() { return deltaTime; }
long double TimerSet::getTime() { return time; }
long double TimerSet::getTimeNow()
{
std::chrono::high_resolution_clock::time_point timeNow = std::chrono::high_resolution_clock::now();
return std::chrono::duration<long double, std::chrono::seconds::period>(timeNow - startTime).count();
}
int TimerSet::getFPS() { return FPS; }
void TimerSet::setMaxFPS(int newFPS) { maxFPS = newFPS; }
size_t TimerSet::getFrameCounter() { return frameCounter; }; |
c5f279cb4451fdf5d2515050a83987bd05892e91 | 693ef6e7fb51dcffbede887a56884f653d9022bd | /OJ/POJ/POJ_3666.cpp | 9f99e717d842a8f5c244e55413e4ebe9f0d10538 | [] | no_license | kumasento/VELVET-PROGRAMMING | e56a2950445cedfbe25cf06c19a0ea1d2924424d | 14620f7a738b085606d6bd9262f1e4a933ddaeaa | refs/heads/master | 2020-12-31T06:32:10.537694 | 2015-10-27T14:33:12 | 2015-10-27T14:33:12 | 26,422,804 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,779 | cpp | POJ_3666.cpp | #include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <stack>
#define N 2005
using namespace std;
struct node{
int k, d;
node *l, *r;
};
node *head[N];
int l[N], r[N];
int a[N];
void Left_tree_Merge(node *t1, node *t2){
node *t=t1->r; t1->r=t2;
if(t==NULL) return ;
node *w=t1;
while(w->r!=NULL && w->r->k > t->k)
w=w->r;
if(w->r==NULL)
w->r=t;
else{
node *tmp = w->r;
w->r = t;
Left_tree_Merge(t,tmp);
}
}
node * Left_tree_pop(node *t){
if(t->l==NULL && t->r!=NULL)
return t->r;
if(t->l!=NULL && t->r==NULL)
return t->l;
if(t->l->k<t->r->k){
swap(t->l,t->r);
}
Left_tree_Merge(t->l, t->r);
return t->l;
}
int update(node * t){
if(t==NULL) return -1;
int l1=update(t->l);
int l2=update(t->r);
t->d=min(l1,l2)+1;
if(l1<l2)
swap(t->l,t->r);
return t->d;
}
int solve(int n){
int I = 0;
for(int i = 0; i < n; i++, I++){
head[I]=new node();
head[I]->d=0;
head[I]->l=head[I]->r=NULL;
head[I]->k=a[i];
l[I]=r[I]=i;
while(I>0 && head[I-1]->k>=head[I]->k){
Left_tree_Merge(head[I-1],head[I]);
update(head[I-1]);
if((r[I]-l[I]+1)%2==1 && (r[I-1]-l[I-1]+1)%2==1){
head[I-1]=Left_tree_pop(head[I-1]);
update(head[I-1]);
}
r[I-1]=r[I];
I--;
}
}
int ans=0;
for(int i=0; i<I; i++){
for(int j=l[i]; j<=r[i]; j++)
ans+=(abs(head[i]->k-a[j]));
}
return ans;
}
int main(){
freopen("data_3666.in","r",stdin);
int n;
while(scanf("%d",&n)!=EOF){
for(int i=0;i<n;++i)
scanf("%d",&a[i]);//先求非递减的解
int ans=solve(n);
for(int i=0;i<n/2;++i)
{
swap(a[i],a[n-i-1]);//将数组逆序后 再求一边便是 非递加的了
}
ans=min(ans,solve(n));
printf("%d\n",ans);
}
return 0;
} |
edd92dd9b212b6a4173dd7c45f9d68554faa307e | d13f18e9deadd124e677f967879af3a2f642bdd8 | /lars_loadbalance_agent/src/agent_udp_server.cpp | 50d1284a0fc3a1d6552f760809dc13eaf2328679 | [] | no_license | zhaoyaogit/Lars-1 | 1545562ecac373518fbd9569b0163c93e0db13c6 | 95a58242832ae67e7fe64fbc7a8bef2da6b4ae21 | refs/heads/main | 2023-05-04T12:14:47.283082 | 2021-05-27T07:35:06 | 2021-05-27T07:35:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,840 | cpp | agent_udp_server.cpp | #include "main_server.h"
void report_cb(const char *data, uint32_t len, int msgid, net_connection *conn, void *user_data)
{
lars::ReportRequest req;
req.ParseFromArray(data, len);
route_lb *route_lb_p = (route_lb*)user_data;
route_lb_p->report_host(req);
}
void get_host_cb(const char *data, uint32_t len, int msgid, net_connection *conn, void *user_data)
{
lars::GetHostRequest req;
req.ParseFromArray(data, len);
int modid = req.modid();
int cmdid = req.cmdid();
//设置回复的消息
lars::GetHostResponse rsp;
rsp.set_seq(req.seq());
rsp.set_modid(modid);
rsp.set_cmdid(cmdid);
//通过 route_lb 获取一个可用host 添加到rsp中
route_lb *route_lb_p = (route_lb*)user_data;
route_lb_p->get_host(modid, cmdid, rsp);
//将 rsp 发送回给 api
std::string responseString;
rsp.SerializeToString(&responseString);
conn->send_message(responseString.c_str(), responseString.size(), lars::ID_GetHostResponse);
}
void get_route_cb(const char *data, uint32_t len, int msgid , net_connection *conn, void *user_data)
{
lars::GetRouteRequest req;
req.ParseFromArray(data, len);
int modid = req.modid();
int cmdid = req.cmdid();
//设置回复的消息
lars::GetRouteResponse rsp;
rsp.set_modid(modid);
rsp.set_cmdid(cmdid);
//通过 route_lb 获取一个可用host 添加到rsp中
route_lb *route_lb_p = (route_lb*)user_data;
route_lb_p->get_route(modid, cmdid, rsp);
//将 rsp 发送回给 api
std::string responseString;
rsp.SerializeToString(&responseString);
conn->send_message(responseString.c_str(), responseString.size(), lars::ID_API_GetRouteResponse);
}
//一个udp server
void *agent_server_main(void* args)
{
long index = (long)args;
short port = index + 8888;
event_loop loop;
udp_server server(&loop, "0.0.0.0", port) ;
//给udp server注册一些消息路由业务
//针对API的获取主机信息接口
server.add_msg_router(lars::ID_GetHostRequest, get_host_cb, r_lb[port-8888]); //8888->r_lb[0], 8889->r_lb[1], 8890->r_lb[2]
//针对API的上报主机调用结果接口
server.add_msg_router(lars::ID_ReportRequest, report_cb, r_lb[port-8888]);
//针对API获取路由全部主机信息的接口
server.add_msg_router(lars::ID_API_GetRouteRequest, get_route_cb, r_lb[port-8888]);
printf("agent UDP server :port %d is started...\n", port);
loop.event_process();
return NULL;
}
void start_UDP_servers(void)
{
for (long i = 0; i < 3; i ++) {
pthread_t tid;
int ret = pthread_create(&tid, NULL, agent_server_main, (void*)i);
if (ret == -1) {
perror("pthread create udp error\n");
exit(1);
}
pthread_detach(tid);
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.